@splinetool/viewer 2.0.121 → 2.0.123

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.
@@ -358,13 +358,13 @@ ${t.stack}`:r}function kMt(t){t<1028||(lh[t]=Nb,Nb=t)}function Xo(t,e){return t=
358
358
  }
359
359
  post({ kind: 'ready' });
360
360
  }, 250);
361
- })();`});function PM(t){return t==null||t===""?void 0:String(t)}var DG,eft=j(()=>{DG=class{constructor(t,e,i){this.deps=t,this.onConsole=e,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let t of this.eventUnsubs.values())t();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(t,e){let i=this.deps;switch(t){case"setVariable":{let r=i.setVariable(String(e[0]),e[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=e[0]??{},s=!0;for(let[n,a]of Object.entries(r)){let o=i.setVariable(n,a);o.warning&&this.onConsole("warn",o.warning),s=s&&o.ok}return s}case"getVariable":return i.getVariable(String(e[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(e[0]));case"getGeometry":{let r=i.getGeometry(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(e[0]),e[1]??{});case"createObject":return i.createObject(String(e[0]),e[1]??{});case"createCustomMaterial":if(i.createCustomMaterial===void 0)throw new Error("createCustomMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(e[0]);case"getTexture":if(i.getTexture===void 0)throw new Error("getTexture: not available on this surface \u2014 a three.js texture instance needs the inline HTML-content mode (editor Preview/Play and web exports).");return i.getTexture(String(e[0]),e[1]??{});case"setMaterial":if(i.setMaterial===void 0)throw new Error("setMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(e[0]),e[1]);case"cloneObject":return i.cloneObject(String(e[0]),e[1]??{});case"removeObject":return i.removeObject(String(e[0]));case"spawnObject":{let r=i.spawnObject(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let r=e[1]===null||e[1]===void 0?null:e[1],s=i.setInstanceTransforms(String(e[0]),r);return s<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(e[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),s}case"getAnimations":{let r=i.getAnimations(PM(e[0]));return r.warning&&this.onConsole("warn",`spline.${t}: ${r.warning}`),r.clips}case"playAnimation":{let r=typeof e[1]=="object"&&e[1]!==null,s=i.playAnimation(String(e[0]),r?void 0:PM(e[1]),(r?e[1]:e[2])??{});return s.warning&&this.onConsole("warn",`spline.${t}: ${s.warning}`),s.clip}case"pauseAnimation":case"stopAnimation":{let r=PM(e[0]),s=PM(e[1]),n=t==="pauseAnimation"?i.pauseAnimation(r,s):i.stopAnimation(r,s);return n.warning&&this.onConsole("warn",`spline.${t}: ${n.warning}`),n.ok}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(e[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,s=>{this.onEvent(r,s)})),!0}case"unlistenEvent":{let r=String(e[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${t}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let t=this.deps.getVariables(),e=function(i,r){let s=[];for(let n of Object.keys(r))i[n]!==r[n]&&s.push({name:n,value:r[n]});return s}(this.lastVariables??{},t);this.lastVariables=t;for(let i of e)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function XAt(t,e,i,r){return[t[0]*e+t[4]*i+t[8]*r+t[12],t[1]*e+t[5]*i+t[9]*r+t[13],t[2]*e+t[6]*i+t[10]*r+t[14]]}var YAt=j(()=>{}),ift,KAt=j(()=>{}),ZAt=j(()=>{RG(),eft(),ift=class{constructor(t,e,i){this.iframe=t,this.deps=e,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=r=>{if(this.disposed||r.source!==this.iframe.contentWindow)return;let s=r.data;var n;typeof(n=s)!="object"||n===null||n[qp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new DG(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[qp]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) \u2014 if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),this.handshakeTimer!==null&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(t){switch(t.kind){case"ready":this.handshakeSeen=!0,this.send({[qp]:!0,kind:"ready-ack"});break;case"console":this.onConsole(t.level,t.text);break;case"call":{let e;try{e=Promise.resolve(this.host.execute(t.method,t.args))}catch(i){e=Promise.reject(i)}e.then(i=>{this.send({[qp]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[qp]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[qp]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey};switch(t.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":e.dispatchEvent(new PointerEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,movementX:t.movementX,movementY:t.movementY}));break;case"click":case"dblclick":e.dispatchEvent(new MouseEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,deltaX:t.deltaX,deltaY:t.deltaY,deltaMode:t.deltaMode});typeof t.wheelDeltaX=="number"&&Object.defineProperty(s,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(s,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(s);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...r,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ir=j(()=>{PG(),IAt(),NAt(),BAt(),VAt(),zAt(),LAt(),FAt(),UAt(),jAt(),GAt(),HAt(),RG(),$At(),eft(),YAt(),KAt(),ZAt()}),QAt=j(()=>{});function rft(t){return Array.isArray(t)?t:[t]}function y4(t,e){let i=0;for(;i<t.length&&i<e.length;){if(t[i]<e[i])return-1;if(t[i]>e[i])return 1;i+=1}return i!==e.length?-1:i!==t.length?1:0}var JAt=j(()=>{});function $a(t,e){return Object.setPrototypeOf(t,e),t}function mI(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function im(t,e,i){if(t===void 0?e===void 0?(t=0,e=10):t=e-10:e===void 0&&(e=t+10),t>e){let n=t;t=e,e=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=t+(e-t)*(n+.75+.5*Math.random())*s;r.push(a)}return r}function e0(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array}var t3t=j(()=>{});function OG(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let r=t[i];r&&typeof r=="object"&&OG(r)}return Object.freeze(t)}function sft(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var fI,v4,gU,ke,IG,e3t=j(()=>{}),un=j(()=>{QAt(),JAt(),t3t(),e3t()}),NG=j(()=>{fI=class{},v4=class extends fI{constructor(t){super(),this.id=t}},gU=class extends fI{constructor(t){super(),this.data=t}}}),i3t=j(()=>{}),Z5=j(()=>{ke=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let r={...i,[t]:e};return Object.setPrototypeOf(r,ke.prototype),r}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let i,r=e[t.id];i=r===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:r};let{id:s,data:n}=t,a={...e,[s]:n};return Object.setPrototypeOf(a,ke.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,r=e[i];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,ke.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),BG=j(()=>{IG=class extends Error{}});function nft(t,e){for(let i of t)e(i.id,i.data)!==!0&&nft(i.children,e)}function aft(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)aft(i,e)}var Nn,RM,Bv,ce,a0=j(()=>{un(),BG(),un(),Nn=class extends Array{constructor(...t){super(...t),fc(this,"partialObjectCaches"),fc(this,"objCaches"),fc(this,"parentCaches"),Object.setPrototypeOf(this,Nn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)OG(this[t]),t++}fillCaches0(t,e){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,e);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,e){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}rootAcestor(t){for(;t;){let e=this.parent(t);if(!e)return t;t=e}return t}isDescendantOf(t,e){for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}partialCache(t){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let e=this.get(t);e!==void 0&&this.partialObjectCaches.set(t,e)}get(t){if(this.partialObjectCaches!==void 0){let e=this.partialObjectCaches.get(t);if(e!==void 0)return e}return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,e){if(t===null)this.traverse(e);else{let i=this.get(t);i&&aft(i,e)}}traverse(t){nft(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this.parent(t),r=this.childrenArray(i),s=r.findIndex(o=>o.id===t);if(s<0)throw new Error("not expected");let n=r[s];r=[...r],r[s]={...n,data:e};let a=new Map;return a.set(t,r[s]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(t,e,i=void 0){let r=t,s=e;for(;r!==null;){let a=s,o=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let l=s.findIndex(h=>h.id===o);if(l<0)throw new Error;s=[...s],s[l]={...s[l],children:a},i&&i.set(o,s[l])}Object.setPrototypeOf(s,Nn.prototype);let n=s;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){n.objCaches=this.objCaches;for(let[a,o]of i)n.objCaches.set(a,o);n.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else n.fillCaches();return n}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:e}){if(this.get(t)!==void 0)return!0;for(let i of e)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:e,fi:i,id:r,data:s,children:n}=t;if(e!==null&&this.get(e)===void 0||this.checkDuplicatedIdRec(t))return null;{let a=e,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:r}}}}deleteOp(t){let{id:e}=t;if(this.get(e)===null)return null;{let i=this.parent(e);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);t.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:t,reverse:{type:7,...n,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:r}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:r});if(e!==null){let d=e;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new IG("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=e,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:t,reverse:{type:9,parent:n,fi:u,id:r}}}previous(t,e){if(e===null){let r=this.childrenArray(t);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(t)){if(r.id===e)return i;i=r.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)+1;if(r<i.length)return i[r].id;if(e)return this.traverseSortNext(e)}}sortNext(t){let e=this.childrenArray(t);return e.length>0?e[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let e=this.childrenArray(t);return e.length>0?this.traverseSortPrevious(e[e.length-1].id):t}sortPrevious(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)-1;return r>=0?this.traverseSortPrevious(i[r].id):e}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push({...i,...r})}e.sort((i,r)=>y4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i);r!==void 0&&e.push(r)}e.sort((i,r)=>y4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],r=this.get(e),s=r;if(r!==void 0){for(;e;)i.splice(0,0,r.fi),e=this.parent(e),e!==null&&(r=this.get(e));return{...s,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let r=this.childrenArray(t);if(e===null){if(r.length===0)return im(0,i,i);{let s=r[0].fi;return im(s-i,s,i)}}{let s=this.get(e);if(s===void 0||this.parent(e)!==t)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return im(a,a+i,i)}return im(s.fi,n.fi,i)}}}}),kG=j(()=>{var t;un(),RM=null,(t=Bv||(Bv={})).setPreservePrototype=function(e){RM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===RM&&Object.setPrototypeOf(i,RM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||e0(e)){let r=i.props,s={},n=e0(e)?e.slice():[...e],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");s[o]=n[l],n[l]=r[o],a=!0}return a?{data:n,actual:i,reverse:{type:0,props:s}}:null}{let r=i.props,s={},n={...e},a=!1;if(r)for(let o of Object.keys(r)){s[o]=n[o];let l=r[o];l===void 0?delete n[o]:n[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,n),actual:i,reverse:{type:0,props:s}}:null}}}),o0=j(()=>{un(),un(),ce=class extends Array{constructor(...t){super(...t),fc(this,"objCaches"),Object.setPrototypeOf(this,ce.prototype)}deepFreeze(){let t=0;for(;t<this.length;)OG(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===t);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,ce.prototype);let e=t;return typeof process<"u"||e.fillCaches(),e}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:e,id:i,data:r}=t,s=this,n={fi:e,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),t.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,r=i.findIndex(n=>n.id===e);if(r===-1)return null;t.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...s}}}moveOp(t){let{fi:e,id:i}=t,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:e};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),t.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:t,reverse:{type:6,fi:n,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let e=null;for(let i of this){if(i.id===t)return e;e=i.id}return null}insertBeforeHelper(t,e){return this.insertAfterHelper(this.previous(t),e)}insertAfterHelper(t,e){let i=this;if(t===null){if(i.length===0)return im(0,e,e);{let r=i[0].fi;return im(r-e,r,e)}}{let r=this.get(t);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return im(n,n+e,e)}return im(r.fi,s.fi,e)}}}});function r3t(t,e){let i={cur:[],result:[],len:0};return[t=hv(t,e,i)??t,i.result]}function qP(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function HP(t){t&&(t.len-=1)}function oft(t,e,i){let r=!1,s=t.map(n=>{let a=n.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=hv(n.data,e,qP(i,a));HP(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=oft(n.children,e,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function hv(t,e,i){if(t instanceof Nn){let r=oft(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ce)return function(r,s,n){let a=!1,o=r.map(l=>{let h=l.id,u=s[h];if(u!==void 0&&typeof u=="string"&&(a=!0,h=u,n!==null))throw new Error("not supported");let d=hv(l.data,s,qP(n,h));return HP(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:h,data:d}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(r)),o}(t,e,i);if(Array.isArray(t)){let r=!1,s=t.map((n,a)=>{let o=hv(n,e,qP(i,a));return HP(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(t)),s):void 0}if(t&&typeof t=="object"&&!e0(t)){let r={},s=!1;for(let[n,a]of Object.entries(t))if(n!=="name"&&n!=="variableId"){let o=e[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=hv(a,e,qP(i,n));HP(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(typeof t=="string"){let r=e[t];return r!==void 0&&function(s){if(s===null)return null;s.result.push(s.cur.slice(0,s.len))}(i),r}}var lft=j(()=>{a0(),o0(),un()});function uv(t){return t&&typeof t=="object"&&t instanceof Es}function VG(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=eS(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=VG(s.children,e);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}return{...s,id:n,data:a}});return i?r:void 0}function eS(t,e){if(!uv(e))return e;if(t instanceof Nn){let i=VG(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ce)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=eS(a.data,r[o]);return s=s||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return s?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}(t,e);if(Array.isArray(t)){let i=!1,r=t.map((s,n)=>{let a=eS(s,e[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t instanceof Es)return zG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=eS(n,e[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function zG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!uv(e))return e;if(!uv(t))return gm.apply(t,e);let i=new Set;for(let s of Object.keys(t))i.add(s);for(let s of Object.keys(e))i.add(s);let r=new Es;for(let s of i){let n=zG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var Es,gm,b4,ta,xX,Q5=j(()=>{var t;a0(),o0(),J5(),un(),Es=class{unusedFunOverridesTable(e){}runOp(e){let i=[],r=this,s=0,n={};for(;s<e.path.length;){if(i.push(r),r=r===void 0?void 0:r[e.path[s]],r!==void 0&&!uv(r))return null;s+=1}r=r?mI(r):new Es;for(let[a,o]of Object.entries(e.props)){let l=r[a];n[a]=l,o===void 0?delete r[a]:r[a]=o}for(;s>0;){if(Object.keys(r).length===0){let a=i[s-1];a&&(r=mI(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=mI(a);o[e.path[s-1]]=r,r=o}else{let o=new Es;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,Es.prototype),actual:e,reverse:{...e,props:n}}}},(t=gm||(gm={})).apply=function(e,i){return eS(e,i)??e},t.merge=function(e,i){return zG(e,i)},t.filterOp=function(e,i){let r=0,s=i.path,n=e;for(;r<s.length&&n!==void 0;){if(n=Dn.zoomOnce(n,s[r]),n===void 0)return i;if(!uv(n))return;r+=1}if(n===void 0)return i;if(uv(n)){if(i.type===0){let a={...i.props};for(let o of Object.keys(n))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=VG([i],n);return a?a[0]:i}return i}}}),s3t=j(()=>{un(),J5(),Z5(),a0(),BG(),kG(),o0(),lft(),Q5(),(b4||(b4={})).replaceProps=function(t,e){let i=Dn.zoom(e,t.path);if(typeof i=="object"){let r={};for(let s of Object.keys(t.props))r[s]=i[s];return{...t,props:r}}return{...t,props:{}}},(t=>{function e(s,n){let a=n.path,o=[];for(;;){let l;if(s instanceof Es&&n.type===0&&(l=s.runOp({...n,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=s instanceof Nn||s instanceof ce||s instanceof ke?s.runOp(n):Bv.runOp(s,n)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],m=o[c];if(m instanceof Nn){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ce){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ke){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Es){let f={...m,[p]:d};d=Object.setPrototypeOf(f,Es.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||e0(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=e0(m)?m.slice():[...m],d[p]=f}else d=Bv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let h,u=a[o.length];if(s instanceof Nn){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else if(s instanceof ce){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else s!==null&&(h=s[u]);if(h===void 0)return null;o.push(s),s=h}}function i(s,n){for(let a=0;a<s.length&&a<n.length;a++)if(s[a]!==n[a])return!0;return!1}function r(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==n[a])return!1;return!0}t.drop=function(s,n){return{...s,path:s.path.slice(n)}},t.applySimple=function(s,n){return e(s,n)?.data??s},t.apply=e,t.pathDisjoint=i,t.pathEq=r,t.commutative=function(s,n){return i(s.path,n.path)},t.subsumed=function(s,n){return!(s.type!==0||n.type!==0||!r(s.path,n.path))&&Object.keys(s.props).every(a=>n.props[a]!==void 0)}})(ta||(ta={})),(t=>{function e(i,r){let s=i,n=[],a=[];for(let o of r)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=ta.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=ta.apply(s,o)),h!==null){s=h.data;let[u,d]=r3t(s,{[o.id]:l});s=u;for(let c=0;c<d.length;c++){let p,m,f=d[c],g=f.pop();if(typeof g=="number"){let y=[g];for(let b=c+1;b<d.length;b++){let _=d[b],x=_[_.length-1];if(typeof x!="number"||!Dn.equal(f,_.slice(0,_.length-1)))break;y.push(x),d.splice(b,1)}let v=Dn.zoom(s,f);m=v.map((b,_)=>y.includes(_)?o.id:b),p=v,g=f.pop()}else p=l,(g==="alphaOverride"||g==="alpha")&&(p=l/100,Dn.zoom(s,f)[g]=p),m=o.id;n.push({type:0,path:f,props:{[g]:p}}),a.push({type:0,path:f,props:{[g]:m}})}a.push(h.reverse),n.push(h.actual)}}else{let l=ta.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof IG)return null;throw l}return{data:s,actual:n,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,r){let s=[];for(let n of i){let[a,...o]=n.path;a===r&&s.push({...n,path:o})}return s},t.addPrefix=function(i,r){return i.map(s=>({...s,path:[r,...s.path]}))},t.concat=function(i,r){return[...i,...r]},t.compress=function(i,r){return[...i.filter(s=>!r.some(n=>ta.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>ta.commutative(s,n)))},t.applyAll=function(i,r){for(let s of r){let n=e(i,s);n!==null&&(i=n.data)}return i},t.apply=e})(xX||(xX={}))});function wX(t,e){return t instanceof Es?Object.setPrototypeOf(e,Es.prototype):Bv.tryPreservePrototype(t,e)}function gI(t,e,i){if(t.length>0){let r=t[t.length-1];if(r.type===0&&e.type===0&&Dn.equal(r.path,i))return void Object.assign(r.props,e.props)}t.push({...e,path:i})}function $P(t,e,i){return i instanceof Nn?new oT(t,e,i):i instanceof ce?new lT(t,e,i):i instanceof ke?new Proxy(new uft(t,e,i),cft):i!==null&&typeof i=="object"?e0(i)?i:new Proxy(new hft(t,e,i),dft):i}function Qw(t){let e=new yU(t);return[$P(e,"",t),e]}function _4(t,e){let[i,r]=Qw(t);return e(i),r.result()}function Ns(t){return t instanceof oT||t instanceof lT?t._current:t!==null&&typeof t=="object"?t[x4]:t}function Jw(t){if(t instanceof oT||t instanceof lT)return t._current;if(t!==null&&typeof t=="object"){let e=t[x4];return e!==void 0?e:t}return t}var x4,SX,h_,F0,hft,uft,yI,dft,cft,oT,lT,yU,Dn,pft=j(()=>{Z5(),a0(),kG(),o0(),un(),J5(),Q5(),x4=Symbol(),SX=Symbol(),h_=Symbol(),F0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof yU);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[h_];i&&i(),delete this._children[t]}}}},hft=class extends F0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=wX(this._current,{...this._current,[t]:e})}runOp(t){let e=Bv.runOp(this._current,t);e!==null&&(e.data=wX(this._current,e.data)),this.reportOp(t,e,t.path)}},uft=class extends F0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,ke.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},yI={get(t,e){if(e===h_)return()=>{t._parent=null};if(e===x4)return t._current;if(e===SX)return t;let{_current:i,_children:r}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[e];if(s!==void 0)return s;let n=i[e],a=$P(t,e,n);return a!==n?(r===void 0&&(r={},t._children=r),r[e]=a,a):n},has:(t,e)=>e in t._current,ownKeys:t=>Reflect.ownKeys(t._current),defineProperty(){throw Error("not supported")},getPrototypeOf:t=>Object.getPrototypeOf(t._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(t,e){let i=t._current,r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[e]}}},dft={...yI,set(t,e,i){let r={type:0,props:{[e]:Ns(i)??i}};return t.deleteChildren(e),t.runOp(r),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},cft={...yI,set(t,e,i){return i===void 0?this.deleteProperty(t,e):(t.deleteChildren(e),t.runOp({type:1,id:e,data:i})),!0},deleteProperty:(t,e)=>(t.runOp({type:2,id:e}),!0)},oT=class extends F0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[h_]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,i)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=$P(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}add(t,e,i,r,s){this.runOp({type:7,parent:t,fi:e,id:i,data:r,children:s})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}insertBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}moveAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}moveBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},lT=class extends F0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[h_]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id,s=this._current[i].fi;t(this.data(this._current[i].id),r,s,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:i}=this._current.at(t);return{id:e,fi:i,data:this.data(e)}}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=$P(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,i){this.runOp({type:4,fi:t,id:e,data:i})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},yU=class extends F0{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,i,r){gI(this.ts,e,t),gI(this.actual,i,t),gI(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),J5=j(()=>{NG(),pft(),o0(),a0(),un(),(t=>{function e(r,s){return(r instanceof Nn||r instanceof oT)&&typeof s=="string"||(r instanceof ce||r instanceof lT)&&typeof s=="string"?r.data(s):typeof s=="number"&&Array.isArray(r)||typeof s=="string"&&typeof r=="object"&&r!==null?r[s]:void 0}function i(r,s,n=0){for(;n<s.length&&r!==void 0;)r=e(r,s[n]),n+=1;return r}t.equal=function(r,s){if(s.length!==r.length)return!1;{let n=0;for(;n<r.length;){if(r[n]!==s[n])return!1;n+=1}}return!0},t.removeOverridden=function(r,s,n){let a=i(n,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...s};return Object.keys(a).forEach(l=>{delete o[l]}),o}return s},t.zoomOnce=e,t.zoom=i,t.findPathes=function(r,s){let n=[];return function a(o,l){if(o instanceof v4&&o.id===s.id)n.push(l);else if(o instanceof ce)for(let h=0;h<o.length;h++)a(o[h].data,[...l,o[h].id]);else if(o instanceof Nn)o.traverse((h,u)=>{a(u,[...l,h])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let h=0;h<o.length;h++)a(o[h],[...l,h])}else{if(e0(o))return;if(typeof o=="object"&&o!==null)for(let h in o)a(o[h],[...l,h])}}(r,[]),n}})(Dn||(Dn={}))}),n3t=j(()=>{});function er(t,e){let i=[];if(!(e.length<=t.length))return null;{let r=0;for(;r<e.length;){if(e[r]==="*")i.push(t[r]);else if(t[r]!==e[r])return null;r+=1}}return i}var a3t=j(()=>{});function DM(t){try{if(!Er.trusted&&!vc){let i=qi.sharedLength||0;i<qi.length&&(qi.length=i)}let e;if(Er.randomAccessStructure&&me[ft]<64&&me[ft]>=32&&PX?(e=PX(me,ft,th,Er),me=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),ft=th):e=Zs(),Ra&&(ft=Ra.postBundlePosition,Ra=null),vc&&(qi.restoreStructures=null),ft==th)qi&&qi.restoreStructures&&TX(),qi=null,me=null,yc&&(yc=null);else{if(ft>th)throw new Error("Unexpected end of MessagePack data");if(!vc){let i;try{i=JSON.stringify(e,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw qi&&qi.restoreStructures&&TX(),bU(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||ft>th)&&(e.incomplete=!0),e}}function TX(){for(let t in qi.restoreStructures)qi[t]=qi.restoreStructures[t];qi.restoreStructures=null}function Zs(){let t=me[ft++];if(t<160){if(t<128){if(t<64)return t;{let e=qi[63&t]||Er.getStructures&&mft()[63&t];return e?(e.read||(e.read=vU(e,63&t)),e.read()):t}}if(t<144){if(t-=128,Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=gft();r==="__proto__"&&(r="__proto_"),e[r]=Zs()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Zs(),Zs());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=Zs();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(qh>=ft)return rm.slice(ft-fl,(ft+=e)-fl);if(qh==0&&th<140){let i=e<16?LG(e):fft(e);if(i!=null)return i}return T4(e)}{let e;switch(t){case 192:return null;case 193:return Ra?(e=Zs(),e>0?Ra[1].slice(Ra.position1,Ra.position1+=e):Ra[0].slice(Ra.position0,Ra.position0-=e)):bft;case 194:return!1;case 195:return!0;case 196:if(e=me[ft++],e===void 0)throw new Error("Unexpected end of buffer");return vI(e);case 197:return e=zi.getUint16(ft),ft+=2,vI(e);case 198:return e=zi.getUint32(ft),ft+=4,vI(e);case 199:return of(me[ft++]);case 200:return e=zi.getUint16(ft),ft+=2,of(e);case 201:return e=zi.getUint32(ft),ft+=4,of(e);case 202:if(e=zi.getFloat32(ft),Er.useFloat32>2){let i=MU[(127&me[ft])<<1|me[ft+1]>>7];return ft+=4,(i*e+(e>0?.5:-.5)|0)/i}return ft+=4,e;case 203:return e=zi.getFloat64(ft),ft+=8,e;case 204:return me[ft++];case 205:return e=zi.getUint16(ft),ft+=2,e;case 206:return e=zi.getUint32(ft),ft+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*zi.getUint32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigUint64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigUint64(ft),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigUint64(ft),ft+=8,e;case 208:return zi.getInt8(ft++);case 209:return e=zi.getInt16(ft),ft+=2,e;case 210:return e=zi.getInt32(ft),ft+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*zi.getInt32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigInt64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigInt64(ft),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigInt64(ft),ft+=8,e;case 212:if(e=me[ft++],e==114)return TU(63&me[ft++]);{let i=Ta[e];if(i)return i.read?(ft++,i.read(Zs())):i.noBuffer?(ft++,i()):i(me.subarray(ft,++ft));throw new Error("Unknown extension "+e)}case 213:return e=me[ft],e==114?(ft++,TU(63&me[ft++],me[ft++])):of(2);case 214:return of(4);case 215:return of(8);case 216:return of(16);case 217:return e=me[ft++],qh>=ft?rm.slice(ft-fl,(ft+=e)-fl):xft(e);case 218:return e=zi.getUint16(ft),qh>=(ft+=2)?rm.slice(ft-fl,(ft+=e)-fl):wft(e);case 219:return e=zi.getUint32(ft),qh>=(ft+=4)?rm.slice(ft-fl,(ft+=e)-fl):Sft(e);case 220:return e=zi.getUint16(ft),ft+=2,MX(e);case 221:return e=zi.getUint32(ft),ft+=4,MX(e);case 222:return e=zi.getUint16(ft),ft+=2,AX(e);case 223:return e=zi.getUint32(ft),ft+=4,AX(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+t)}}}function vU(t,e){function i(){if(i.count++>xU){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":_ft.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")(Zs)}catch{return xU=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=wU(e,t.read)),s()}let r={};for(let s=0,n=t.length;s<n;s++){let a=t[s];a==="__proto__"&&(a="__proto_"),r[a]=Zs()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?wU(e,i):i}function mft(){let t=vft(()=>(me=null,Er.getStructures()));return qi=Er._mergeStructures(t,qi)}function t2(t){let e;if(t<16&&(e=LG(t)))return e;if(t>64&&_U)return _U.decode(me.subarray(ft,ft+=t));let i=ft+t,r=[];for(e="";ft<i;){let s=me[ft++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&me[ft++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&me[ft++])<<6|63&me[ft++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&me[ft++])<<12|(63&me[ft++])<<6|63&me[ft++];n<65536||n>1114111?r.push(65533):(n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n))}else r.push(65533);else r.push(s);r.length>=4096&&(e+=Tn.apply(String,r),r.length=0)}return r.length>0&&(e+=Tn.apply(String,r)),e}function MX(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=Zs();return Er.freezeData?Object.freeze(e):e}function AX(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=gft();r==="__proto__"&&(r="__proto_"),e[r]=Zs()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Zs(),Zs());return e}}function fft(t){let e=ft,i=new Array(t);for(let r=0;r<t;r++){let s=me[ft++];if((128&s)>0)return void(ft=e);i[r]=s}return Tn.apply(String,i)}function LG(t){if(t<4){if(t<2){if(t===0)return"";{let e=me[ft++];return(128&e)>1?void(ft-=1):Tn(e)}}{let e=me[ft++],i=me[ft++];if((128&e)>0||(128&i)>0)return void(ft-=2);if(t<3)return Tn(e,i);let r=me[ft++];return(128&r)>0?void(ft-=3):Tn(e,i,r)}}{let e=me[ft++],i=me[ft++],r=me[ft++],s=me[ft++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(ft-=4);if(t<6){if(t===4)return Tn(e,i,r,s);{let n=me[ft++];return(128&n)>0?void(ft-=5):Tn(e,i,r,s,n)}}if(t<8){let n=me[ft++],a=me[ft++];if((128&n)>0||(128&a)>0)return void(ft-=6);if(t<7)return Tn(e,i,r,s,n,a);let o=me[ft++];return(128&o)>0?void(ft-=7):Tn(e,i,r,s,n,a,o)}{let n=me[ft++],a=me[ft++],o=me[ft++],l=me[ft++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(ft-=8);if(t<10){if(t===8)return Tn(e,i,r,s,n,a,o,l);{let h=me[ft++];return(128&h)>0?void(ft-=9):Tn(e,i,r,s,n,a,o,l,h)}}if(t<12){let h=me[ft++],u=me[ft++];if((128&h)>0||(128&u)>0)return void(ft-=10);if(t<11)return Tn(e,i,r,s,n,a,o,l,h,u);let d=me[ft++];return(128&d)>0?void(ft-=11):Tn(e,i,r,s,n,a,o,l,h,u,d)}{let h=me[ft++],u=me[ft++],d=me[ft++],c=me[ft++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(ft-=12);if(t<14){if(t===12)return Tn(e,i,r,s,n,a,o,l,h,u,d,c);{let p=me[ft++];return(128&p)>0?void(ft-=13):Tn(e,i,r,s,n,a,o,l,h,u,d,c,p)}}{let p=me[ft++],m=me[ft++];if((128&p)>0||(128&m)>0)return void(ft-=14);if(t<15)return Tn(e,i,r,s,n,a,o,l,h,u,d,c,p,m);let f=me[ft++];return(128&f)>0?void(ft-=15):Tn(e,i,r,s,n,a,o,l,h,u,d,c,p,m,f)}}}}}function CX(){let t,e=me[ft++];if(e<192)t=e-160;else switch(e){case 217:t=me[ft++];break;case 218:t=zi.getUint16(ft),ft+=2;break;case 219:t=zi.getUint32(ft),ft+=4;break;default:throw new Error("Expected string")}return t2(t)}function vI(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(me,ft,ft+=t):me.subarray(ft,ft+=t)}function of(t){let e=me[ft++];if(Ta[e]){let i;return Ta[e](me.subarray(ft,i=ft+=t),r=>{ft=r;try{return Zs()}finally{ft=i}})}throw new Error("Unknown extension type "+e)}function gft(){let t=me[ft++];if(!(t>=160&&t<192))return ft--,yft(Zs());if(t-=160,qh>=ft)return rm.slice(ft-fl,(ft+=t)-fl);if(!(qh==0&&th<180))return T4(t);let e,i=4095&(t<<5^(t>1?zi.getUint16(ft):t>0?me[ft]:0)),r=SU[i],s=ft,n=ft+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=zi.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=me[s++],e!=r[a++]){s=1879048192;break}if(s===n)return ft=s,r.string;n-=3,s=ft}for(r=[],SU[i]=r,r.bytes=t;s<n;)e=zi.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=me[s++],r.push(e);let o=t<16?LG(t):fft(t);return r.string=o??T4(t)}function yft(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(Er.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error("Invalid property type for record: "+typeof t)}function vft(t){RX&&RX();let e=th,i=ft,r=S4,s=fl,n=qh,a=rm,o=w4,l=yc,h=Ra,u=new Uint8Array(me.slice(0,th)),d=qi,c=qi.slice(0,qi.length),p=Er,m=vc,f=t();return th=e,ft=i,S4=r,fl=s,qh=n,rm=a,w4=o,yc=l,Ra=h,me=u,vc=m,(qi=d).splice(0,qi.length,...c),Er=p,zi=new DataView(me.buffer,me.byteOffset,me.byteLength),f}function bU(){me=null,yc=null,qi=null}function o3t(t){t.unpack?Ta[t.type]=t.unpack:Ta[t.type]=t}var _U,me,th,ft,EX,w4,S4,Er,qi,rm,fl,qh,Ra,yc,Ta,zi,bI,bft,vc,xU,PX,RX,e2,_ft,wU,T4,xft,wft,Sft,Tn,SU,TU,_I,DX,OX,IX,MU,OM,NX,BX,kX,AU,xI,FS,l3t=j(()=>{try{_U=new TextDecoder}catch{}ft=0,w4=EX=[],S4=0,Er={},fl=0,qh=0,Ta=[],bI={useRecords:!1,mapsAsObjects:!0},(bft=new class{}).name="MessagePack 0xC1",vc=!1,xU=2,e2=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=0&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(me)return vft(()=>(bU(),this?this.unpack(t,e):e2.prototype.unpack.call(bI,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(th=e.end||t.length,ft=e.start||0):(ft=0,th=e>-1?e:t.length),S4=0,qh=0,rm=null,w4=EX,Ra=null,me=t;try{zi=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw me=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e2){if(Er=this,this.structures)return qi=this.structures,DM(e);(!qi||qi.length>0)&&(qi=[])}else Er=bI,(!qi||qi.length>0)&&(qi=[]);return DM(e)}unpackMultiple(t,e){let i,r=0;try{vc=!0;let s=t.length,n=this?this.unpack(t,s):OM.unpack(t,s);if(!e){for(i=[n];ft<s;)r=ft,i.push(DM());return i}if(e(n,r,ft)===!1)return;for(;ft<s;)if(r=ft,e(DM(),r,ft)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{vc=!1,bU()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,r=t.length;i<r;i++){let s=t[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let r=t[i],s=e[i];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[i]=r),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},_ft=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,wU=(t,e)=>function(){let i=me[ft++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=qi[r]||mft()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=vU(s,t)),s.read()},T4=t2,xft=t2,wft=t2,Sft=t2,Tn=String.fromCharCode,SU=new Array(4096),TU=(t,e)=>{let i=Zs().map(yft),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=qi[t];return s&&(s.isShared||vc)&&((qi.restoreStructures||(qi.restoreStructures=[]))[t]=s),qi[t]=i,i.read=vU(i,r),(i.read0||i.read)()},Ta[0]=()=>{},Ta[0].noBuffer=!0,Ta[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let r=1;r<e;r++)i<<=BigInt(8),i+=BigInt(t[r]);if(t.byteLength!==e){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=(n,a)=>{let o=a-n;if(o<=40){let d=r.getBigUint64(n);for(let c=n+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=n+(o>>4<<3),h=s(n,l),u=s(l,a);return h<<BigInt(8*(a-l))|u};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},_I={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},Ta[101]=()=>{let t=Zs();if(!_I[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return _I[t[0]](t[1],{cause:t[2]})},Ta[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4);yc||(yc=new Map);let i,r=me[ft];i=r>=144&&r<160||r==220||r==221?[]:r>=128&&r<144||r==222||r==223?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&me[ft+1]===115?new Set:{};let s={target:i};yc.set(e,s);let n=Zs();if(!s.used)return s.target=n;if(Object.assign(i,n),i instanceof Map)for(let[a,o]of n.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(n))i.add(a);return i},Ta[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4),i=yc.get(e);return i.used=!0,i.target},Ta[115]=()=>new Set(Zs()),DX=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),OX=typeof globalThis=="object"?globalThis:window,Ta[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=DX[e];if(!r){if(e===16)return i;if(e===17)return new DataView(i);throw new Error("Could not find typed array for code "+e)}return new OX[r](i)},Ta[120]=()=>{let t=Zs();return new RegExp(t[0],t[1])},IX=[],Ta[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=ft;return ft+=e-t.length,Ra=IX,(Ra=[CX(),CX()]).position0=0,Ra.position1=0,Ra.postBundlePosition=ft,ft=i,Zs()},Ta[255]=t=>t.length==4?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid"),MU=new Array(147);for(let t=0;t<256;t++)MU[t]=+("1e"+Math.floor(45.15-.30103*t));(OM=new e2({useRecords:!1})).unpack,OM.unpackMultiple,OM.unpack,NX=new Float32Array(1),new Uint8Array(NX.buffer,0,4)}),h3t=j(()=>{l3t(),NG(),Q5(),o0(),Z5(),a0(),BX=[{Class:ke.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,ke.prototype),t)},{Class:ce.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ce.prototype),t)},{Class:Nn.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Nn.prototype),t)},{Class:v4.prototype.constructor,type:4,write:t=>t.id,read:t=>new v4(t)},{Class:gU.prototype.constructor,type:5,write:t=>t.data,read:t=>new gU(t)},{Class:Es.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Es.prototype),t)}];for(let t of BX)o3t(t);kX=new e2({structuredClone:!0}),(AU||(AU={})).deserialize=function(t){return kX.unpack(t)}}),u3t=j(()=>{h3t(),xI=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},FS={deserialize:AU.deserialize,serialize:xI("CollabSerialize.serialize"),checksum:xI("CollabSerialize.checksum")}}),Ui=j(()=>{J5(),i3t(),BG(),a0(),Z5(),kG(),o0(),s3t(),n3t(),pft(),a3t(),NG(),u3t(),lft(),Q5()});function CU(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var VX,EU,iS,IM,wI,zX,LX,FX,PU,RU,UX,jX,GX,WX,qX,DU,OU,HX,$X,XX,YX,Tft=j(()=>{var t,e,i;Ui(),ht(),(t=VX||(VX={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},t.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},EU={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(r=>{r.is=function(s){return s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"},r.defaultData=function(s){return s==="MouseDown"||s==="MouseUp"||s==="MousePress"?{type:s,mode:"Object",disabled:!1,name:"",actions:new ce}:{type:s,disabled:!1,name:"",key:void 0,actions:new ce}}})(iS||(iS={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(IM||(IM={})),(e=wI||(wI={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:IM.propertyDefaultData(r),rOperand:{...IM.valueDefaultData}}},e.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},e.stateDefaultData=function(r,s){return{type:"State",object:r??null,state:s??null}},(zX||(zX={})).isConditionalSubActions=function(r){return r.find(s=>s==="ifActions"||s==="elseActions")!==void 0},(r=>{r.is=function(s){return s.type==="Conditional"},r.defaultData=function(s){return{type:"Conditional",disabled:!1,name:"",inActions:new ce,outActions:new ce,condition:wI.distanceDefaultData(s)}}})(LX||(LX={})),(FX||(FX={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ce,drop:new ce}},(PU||(PU={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ce},(RU||(RU={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(r=>{r.is=function(s){return s.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new ce}}})(UX||(UX={})),(r=>{r.is=function(s){return s.type==="Scroll"},r.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ce}}})(jX||(jX={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ce}}})(GX||(GX={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ce}}})(WX||(WX={})),(r=>{r.is=function(s){return s.type==="Trigger"},r.defaultData=function(s,n){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new ce,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(qX||(qX={})),(i=DU||(DU={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(r){return r.type==="Resize"},i.sizeToDevice=function(r){return typeof r=="string"?r:"custom"},i.deviceToSize=function(r){return typeof r=="string"?[...i.defaultSizes[r]]:[...r]},i.defaultData=function(){let r={size:"mobile",operator:"<",actions:new ce},s={size:"tablet",operator:"<",actions:new ce},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ce},a=new ce;return a.push({id:Ft.generateUUID(),fi:0,data:r},{id:Ft.generateUUID(),fi:1,data:s},{id:Ft.generateUUID(),fi:2,data:n}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new ce}},(r=>{r.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},r.is=function(s){return s.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new ce,variableId:"",objectId:null,property:"Position X"}}})(OU||(OU={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ce,errorActions:new ce,userAPIId:""}}})(HX||(HX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ce,userWebhookId:""}}})($X||($X={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ce,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(XX||(XX={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ce}}})(YX||(YX={}))});function KX(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function IU(t){return typeof t=="string"&&t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}var l0,dv,Mft,i0,ZX,Hu,ym,US,QX,SI,wl,Ks,Hi,NU,JX,sm,kv,tY,eY,iY,rY,sY,nY,aY,oY,TI,lY,hY,MI,uY,dY,cY,AI,pY,CI,mY,fY,EI,gY,BU,yY,vY,bY,_Y,xY,wY,r0,bc,nm,kU,VU,M4,A4,C4,E4,P4,zU,LU,R4,FU,cv,SY,PI,RI,UU,TY,D4,O4,DI,MY,jU,OI,AY,CY,EY,PY,RY,DY,OY,IY,tD,FG,Bs,ls,C1,Aft,Vv,I4,wg,GU,UG,N4,B4,k4,dc,XP,ea,II,Qp,qo=j(()=>{var t,e,i,r,s,n,a,o;l0="personal camera",dv="a218fcc3-276b-49b9-b485-49037fd14f5f",Mft=2500134,i0=5526619,(t=ZX||{}).x="x",t.y="y",t.z="z",ZX=t,(l=>{function h(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function u(c,p){return Math.sqrt(h(c,p))}function d(c,p,m){let f=l.sub(p,c),g=l.sub(m,c),y=l.dot(f,g)/l.dot(f,f),v=l.scalarMultiply(f,y);return l.add(c,v)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,m){return[c[0]+(p[0]-c[0])*m,c[1]+(p[1]-c[1])*m]},l.add=function(c,p){return[c[0]+p[0],c[1]+p[1]]},l.sub=function(c,p){return[c[0]-p[0],c[1]-p[1]]},l.multiply=function(c,p){return[c[0]*p[0],c[1]*p[1]]},l.divide=function(c,p){return[c[0]/p[0],c[1]/p[1]]},l.distanceSquared=h,l.distance=u,l.dot=function(c,p){return c[0]*p[0]+c[1]*p[1]},l.scalarMultiply=function(c,p){return[c[0]*p,c[1]*p]},l.projectionOnto=d,l.projectionOntoDistance=function(c,p,m){return u(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Hu||(Hu={})),(e=ym||(ym={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]},e.add=function(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]},e.sub=function(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]},e.div=function(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]},e.mul=function(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]},e.dist=function(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])},e.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]},(i=US||(US={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]&&l[3]===h[3]},i.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u,l[3]+(h[3]-l[3])*u]},(l=>{let h=180/Math.PI,u=Math.PI/180;function d(p){return typeof p=="number"?p*h:p}function c(p){return typeof p=="number"?p*u:p}l.radToDeg=function(p){return[d(p[0]),d(p[1]),d(p[2])]},l.degToRad=function(p){return[c(p[0]),c(p[1]),c(p[2])]}})(QX||(QX={})),(r=SI||(SI={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,h){for(let u=0;u<16;u++)if(l[u]!==h[u])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,h){let u=h.slice(0);for(let d=0,c=h.length;d<c;d+=3){let p=l[3]*h[d]+l[7]*h[d+1]+l[11]*h[d+2]+l[15];u[d]=(l[0]*h[d]+l[4]*h[d+1]+l[8]*h[d+2]+l[12])/p,u[d+1]=(l[1]*h[d]+l[5]*h[d+1]+l[9]*h[d+2]+l[13])/p,u[d+2]=(l[2]*h[d]+l[6]*h[d+1]+l[10]*h[d+2]+l[14])/p}return u},(l=>{l.zero=[0,0,0,0,0,0],l.INDEX_MAP=[4,8,1,9,2,6],l.toMatrix=function(h){let u=[...SI.identity];for(let d=0;d<6;d++)u[l.INDEX_MAP[d]]=h[d];return u},l.fromMatrix=function(h){return[h[l.INDEX_MAP[0]],h[l.INDEX_MAP[1]],h[l.INDEX_MAP[2]],h[l.INDEX_MAP[3]],h[l.INDEX_MAP[4]],h[l.INDEX_MAP[5]]]}})(wl||(wl={})),(s=Ks||(Ks={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},s.clone=function(l){return{r:l.r,g:l.g,b:l.b}},s.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},s.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},s.equals=function(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b},s.equalsFixed=function(l,h){return l.r.toFixed(2)===h.r.toFixed(2)&&l.g.toFixed(2)===h.g.toFixed(2)&&l.b.toFixed(2)===h.b.toFixed(2)},s.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}},s.is=function(l){return!!KX(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=Hi||(Hi={})).white={...Ks.white,a:1},n.is=function(l){return!!KX(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...Ks.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,h){return{...Ks.fromHex(l),a:h}},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},n.equals=function(l,h){return Ks.equals(l,h)&&l.a===h.a},n.equalsFixed=function(l,h){return Ks.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)},n.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u,a:l.a+(h.a-l.a)*u}},n.toStyle=function({r:l,g:h,b:u,a:d}=n.white){return`rgba(${255*l}, ${255*h}, ${255*u}, ${d})`},(NU||(NU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=JX||{})[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING",a[a.ARC=7]="ARC",a[a.NONE=8]="NONE",JX=a,(sm||(sm={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(kv||(kv={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=tY||(tY={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),d3t=j(()=>{var t,e;Ui(),Tft(),(eY||(eY={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(iY||(iY={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(rY||(rY={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(sY||(sY={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(nY||(nY={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(aY||(aY={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(oY||(oY={})).defaultData={type:"Reset",name:"",delay:0},(TI||(TI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=lY||(lY={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=hY||(hY={})).defaultData={type:"Audio",name:"",...TI.defaultData},e.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),e.hasAudioByEvents=i=>e.getAudiosByEvents(i).length>0,e.getAudiosByActions=i=>{let r=[];return i.forEach(s=>{let n=s.data;n.type==="Audio"&&n.interaction==="play"&&n.audio&&r.push(s),n.type==="Conditional"&&(r.push(...e.getAudiosByActions(n.ifActions)),r.push(...e.getAudiosByActions(n.elseActions)))}),r},e.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:s})=>{iS.is(s)||s.type==="Collision"||s.type==="Start"||s.type==="Trigger"||s.type==="VariableChange"||s.type==="WEBHOOK"||s.type==="AIAssistantTrigger"?r.push(...e.getAudiosByActions(s.actions)):s.type==="Conditional"?(r.push(...e.getAudiosByActions(s.inActions)),r.push(...e.getAudiosByActions(s.outActions))):s.type==="GameControl"?Object.values(s.gameActions).forEach(n=>{r.push(...e.getAudiosByActions(n))}):s.type==="DragDrop"?(r.push(...e.getAudiosByActions(s.dragDropActions.drag)),r.push(...e.getAudiosByActions(s.dragDropActions.drop))):s.type==="Resize"?s.breakpoints.forEach(({data:n})=>{r.push(...e.getAudiosByActions(n.actions))}):s.type==="API"&&(r.push(...e.getAudiosByActions(s.successActions)),r.push(...e.getAudiosByActions(s.errorActions)))}),r},(MI||(MI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(uY||(uY={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...MI.defaultData},i.hasVideoByActions=r=>r.some(({data:s})=>s.type==="Video"&&s.interaction==="play"&&s.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:s}of r.events)if((iS.is(s)||s.type==="Start")&&i.hasVideoByActions(s.actions))return!0}},i.getVideosByActions=r=>{let s=[];return r.forEach(n=>{let a=n.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&s.push(n)}),s},i.getVideosByEvents=r=>{let s=[];return r.forEach(({data:n})=>{(iS.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(dY||(dY={})),(cY||(cY={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(AI||(AI={})).defaultData=function(){return{tweens:new ce,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(pY||(pY={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...AI.defaultData()}},(CI||(CI={})).defaultData=function(i){return{interaction:"play",timeline:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(mY||(mY={})),(fY||(fY={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...CI.defaultData(i)}},(EI||(EI={})).defaultData=function(i,r,s){return{interaction:"play",object:i,clipId:r,crop:s,crop2:s,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(gY||(gY={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...EI.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(BU||(BU={})),(yY||(yY={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(vY||(vY={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ce,elseActions:new ce,condition:[]}),(bY||(bY={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(_Y||(_Y={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(xY||(xY={})).defaultData={name:"",type:"UserAPI"}}),c3t=j(()=>{var t;(t=wY||(wY={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),Cft=j(()=>{var t;(t=r0||(r0={})).all=["PerspectiveCamera","OrthographicCamera"],t.is=function(e){return t.all.includes(e)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(n){return n===void 0||!Number.isFinite(n)||n<e.MinTargetOffset?e.DefaultTargetOffset:n},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,r=e.DefaultElevation*Math.PI/180,s=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(r),e.DefaultTargetOffset*Math.sin(r),e.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],e.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*s,Math.asin(Math.sin(i)*Math.cos(r))*s,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*s],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}})(bc||(bc={}))}),Eft=j(()=>{var t;(t=nm||(nm={})).defaultData=function(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof e[0]=="number"?e[0]:1,typeof e[1]=="number"?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof e[0]=="number"?e[0]+e[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(r=>(typeof r=="number"?r:1)*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},t.merge=function(e,i){let r={...e};if(VU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;M4.forEach(a=>{Object.assign(r.radial,{[a]:n[a]??s[a]})})}if(r.linear={...e.linear},i.linear){let s=e.linear,n=i.linear;A4.forEach(a=>{Object.assign(r.linear,{[a]:n[a]??s[a]})})}if(r.grid={...e.grid},i.grid){let s=e.grid,n=i.grid;C4.forEach(a=>{Object.assign(r.grid,{[a]:n[a]??s[a]})})}if(r.toObject={...e.toObject},i.toObject){let s=e.toObject,n=i.toObject;E4.forEach(a=>{Object.assign(r.toObject,{[a]:n[a]??s[a]})})}if(r.randomnessObject={...e.randomnessObject},i.randomnessObject){let s=e.randomnessObject,n=i.randomnessObject;P4.forEach(a=>{Object.assign(r.randomnessObject,{[a]:n[a]??s[a]})})}return r},t.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}})(kU||(kU={})),VU=["count"],M4=["radius","start","end","position","scale","rotation"],A4=["position","scale","rotation"],C4=["count","size"],E4=["count","position","scale","rotation"],P4=["strength","scale","rotation","position","movement","seed","freqScale"]}),Pft=j(()=>{var t;qo(),(t=zU||(zU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(LU||(LU={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:Hi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:Hi.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(i==="DirectionalLight")return{type:i,color:Hi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),Rft=j(()=>{var t;(t=R4||(R4={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...t.defaultCollisionData}}),Dft=j(()=>{var t;(t=FU||(FU={})).defaultData={gravity:10,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:0,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},t.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),jG=j(()=>{(cv||(cv={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),Oft=j(()=>{var t,e;(t=SY||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",SY=t,(e=PI||(PI={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(r,s){return r.flatShading===s.flatShading&&r.side===s.side&&r.wireframe===s.wireframe&&(r.shadowCatcher??!1)===(s.shadowCatcher??!1)}})(RI||(RI={})),(UU||(UU={})).defaultData={...RI.defaultData,...PI.defaultData},(TY||(TY={})).getMaterialData=function(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}}),Ift=j(()=>{var t;(t=D4||(D4={})).bytesFromFlattened=function(e){if(typeof e!="object"||e===null||Array.isArray(e)||ArrayBuffer.isView(e)||typeof e[0]!="number")return null;let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)return null;let r=Object.keys(e),s=new Uint8Array(r.length),n=e;for(let a=0;a<r.length;a++){let o=n[a];if(r[a]!==String(a)||typeof o!="number"||!Number.isInteger(o)||o<0||o>255)return null;s[a]=o}return s},t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),Nft=j(()=>{var t;(t=O4||(O4={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),hT=j(()=>{var t,e,i,r;Ui(),qo(),Ift(),Nft(),qo(),(DI||(DI={})).is=function(s){return s==="texture"||s==="video"||s==="color"||s==="depth"||s==="normal"||s==="gradient"||s==="noise"||s==="fresnel"||s==="cavity"||s==="dust"||s==="rainbow"||s==="toon"||s==="outline"||s==="particle"||s==="transmission"||s==="reflection"||s==="matcap"||s==="displace"||s==="pattern"||s==="vertexColor"||s==="light"},(MY||(MY={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(jU||(jU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(OI||(OI={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(r=AY||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",AY=r,CY=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(CY||{}),EY=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))(EY||{}),(i=PY||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",PY=i,(e=RY||{})[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",RY=e,(t=DY||{})[t.F1=0]="F1",t[t.F2=1]="F2",t[t.F2MinusF1=2]="F2MinusF1",t[t.SmoothBlend=3]="SmoothBlend",t[t.Edge=4]="Edge",t[t.Power=5]="Power",t[t.Lines=6]="Lines",t[t.Cells=7]="Cells",DY=t,OY=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(OY||{}),IY=(s=>(s[s.Circle=0]="Circle",s[s.Ring=1]="Ring",s[s.Polygon=2]="Polygon",s[s.Cross=3]="Cross",s[s.Diamond=4]="Diamond",s[s.Checkerboard=5]="Checkerboard",s[s.Line=6]="Line",s[s.Wave=7]="Wave",s))(IY||{}),tD=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],FG=["wrapping","image","video","name","minFilter","magFilter"],(s=>{function n(a,o){return a==="light"&&o?function(l){let h={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(l){case"phong":return{...h,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...h,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...h,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...h,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(o):function(l){let h={alpha:1,mode:0,isMask:!1,visible:!0};switch(l){case"texture":return{...h,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...h,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:O4.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...h,type:"color",color:Ks.fromHex(i0)};case"vertexColor":return{...h,type:"vertexColor"};case"depth":return{...h,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...h,type:"normal",cnormal:[1,1,1]};case"gradient":return{...h,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...h,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ks.fromHex(6710886),a:1},colorB:{...Ks.fromHex(6710886),a:1},colorC:{...Ks.fromHex(16777215),a:1},colorD:{...Ks.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...h,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...h,type:"fresnel",color:Hi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...h,type:"dust",color:Hi.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...h,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...h,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Hi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...h,type:"outline",outlineColor:Hi.fromHexAndA(0,1),contourColor:Hi.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...h,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...h,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...h,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...h,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ks.fromHex(0),a:1},colorB:{...Ks.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(a)}s.patch=function(a,o){let{texture:l,...h}=o;if(Object.assign(a,h),l){let u=a.texture;u&&Object.assign(u,l)}},s.defaultColorLayer=function(a){return{...s.defaultData("color"),color:a}},s.defaultData=n,s.defaultDataFor=function(a,o){return a!=="light"?n(a):n("light",typeof o=="string"&&OI.is(o)?o:"physical")}})(Bs||(Bs={})),(s=>{function n(l,h){if(typeof l!="string"||!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(l))return l;let{r:u,g:d,b:c}=Ks.fromHex(parseInt(l.slice(1,7),16)),p=l.length===9?parseInt(l.slice(7),16)/255:void 0;if(Array.isArray(h))return h.length>3?[u,d,c,p??h[3]]:[u,d,c];let m=h;return typeof m?.r!="number"?l:typeof m.a=="number"?{r:u,g:d,b:c,a:p??m.a}:{r:u,g:d,b:c}}function a(l){let h=l?.data;return typeof h=="object"&&h!==null}function o(l,h="layer1",u="layer2",d=Ks.fromHex(16777215)){let c=new ce;return c.push({fi:0,data:Bs.defaultData("light",l),id:h}),c.push({fi:1,data:Bs.defaultData("color"),id:u}),{layers:c}}s.restoreImageBytes=function(l){let h=[],u=new Map,d=(p,m)=>{let f=Jw(p);if(typeof f!="object"||f===null||ArrayBuffer.isView(f))return p;if(u.has(f))return u.get(f)??p;u.set(f,void 0);let g=c(f,m)??p;return u.set(f,g),g},c=(p,m)=>{let f=p;if(!Array.isArray(p)){if(typeof f[0]=="number")return;if(typeof f.name=="string"){let y=D4.bytesFromFlattened(Jw(f.data));if(y!==null)return h.push({path:`${m}/data`,bytes:y.byteLength}),Object.setPrototypeOf({...f,data:y},Object.getPrototypeOf(p))}}let g=null;for(let y of Object.keys(p)){let v=f[y],b=d(v,`${m}/${y}`);b!==v&&(g===null&&(g=Array.isArray(p)?[...p]:{...f},Object.setPrototypeOf(g,Object.getPrototypeOf(p))),g[y]=b)}return g??void 0};return{material:d(l,""),restored:h}},s.restoreLayersSeq=function(l){let h=Jw(l.layers);if(!Array.isArray(h)||h instanceof ce||!h.every(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.data=="object"))return{material:l,restored:!1};let u=Object.setPrototypeOf([...h],ce.prototype),d=Jw(l);return{material:Object.setPrototypeOf({...d,layers:u},Object.getPrototypeOf(d)),restored:!0}},s.isMergable=function(l){return!l.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="dust"&&h.data.noiseStrength!==0||h.data.type==="displace")},s.getHash=function(l){let h="";return l.layers.forEach(u=>{Object.entries(u.data).forEach(([d,c])=>{h+=`${d}${c}`,Array.isArray(c)?c.forEach(p=>h+=`${p}`):typeof c=="object"?Object.values(c).forEach(p=>{h+=typeof p=="number"?`${p.toFixed(4)}`:`${p}`}):h+=`${c}`})}),h},s.defaultEmptyData=function(){return{layers:new ce}},s.defaultData=function(l="layer1",h="layer2"){return o("physical",l,h)},s.withName=function(l,h){return{...l,name:h}},s.isLayerEntry=a,s.withRepairedLayers=function(l){if(l.layers===void 0)return{...l,layers:o("phong").layers};let h=Array.from(l.layers);if(h.every(a))return l;let u=new ce;return h.forEach((d,c)=>{if(a(d))return void u.push(d);let{id:p,fi:m,...f}=d??{};if(typeof f.type!="string"||!DI.is(f.type))return;let g=Bs.defaultDataFor(f.type,f.category),y={...g,...f};for(let[v,b]of Object.entries(f)){let _=g[v];y[v]=Array.isArray(b)&&Array.isArray(_)&&Array.isArray(_[0])?b.map(x=>n(x,_[0])):n(b,_)}u.push({id:typeof p=="string"&&p?p:`layer${c+1}`,fi:typeof m=="number"?m:c,data:y})}),{...l,layers:u}},s.defaultTwoLayerData=o,s.defaultColorMaterial=function(l,h,u="layer1",d="layer2"){let c=new ce;return c.push({fi:0,data:Bs.defaultData("light",h),id:u}),c.push({fi:1,data:Bs.defaultColorLayer(l),id:d}),{layers:c}},s.defaultUIObjectMaterial=function(l){let h=Bs.defaultData("texture");l&&Object.assign(h.texture,{image:l});let u=new ce;return u.push({fi:0,data:h,id:"layer1"}),u.push({fi:1,data:{...Bs.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...Bs.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}},s.defaultTwoLayerTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Bs.defaultData("texture");Object.assign(c.texture,{image:l});let p=new ce;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Bs.defaultData("light",h),id:d}),{layers:p}},s.defaultTwoLayerVideoTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Bs.defaultData("video");Object.assign(c.texture,{video:l});let p=new ce;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Bs.defaultData("light",h),id:d}),{layers:p}}})(ls||(ls={}))}),p3t=j(()=>{C1="Roboto_regular",Aft="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),m3t=j(()=>{p3t()}),Bft=j(()=>{var t;Ui(),(t=Vv||(Vv={})).defaultData=function(){return{points:new ce,roundness:0,shapeHoles:[],isClosed:!1}},t.scaled=function e(i,r,s){let n=a=>[a[0]*r,a[1]*s];return{...i,points:new ce(...i.points.map(({id:a,fi:o,data:l})=>({id:a,fi:o,data:{...l,position:n(l.position),controlPrevious:{position:n(l.controlPrevious.position)},controlNext:{position:n(l.controlNext.position)}}}))),shapeHoles:i.shapeHoles.map(a=>e(a,r,s))}}}),kft=j(()=>{Ui(),(I4||(I4={})).defaultData=function(){return{points:new ce,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},wg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(GU||(GU={})).merge=function(t,e){let i={...t};return N4.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},UG={shape:wg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},N4=["depth","offset","angle","twist","startScale","endScale"]}),GG=j(()=>{var t,e;Bft(),kft(),(t=B4||(B4={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},t.isParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"||i==="DecalGeometry"},t.isSwappableGeometry=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"},(k4||(k4={})).merge=function(i,r){let s={...i};if(Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,GU.merge(s.extrusion,r.extrusion))),i.type==="VectorGeometry"&&s.type==="VectorGeometry"){let n=(l,h)=>typeof l=="number"&&typeof h=="number"&&h!==0?l/h:1,a=n(s.width,i.width),o=n(s.height,i.height);(a!==1||o!==1)&&(s.shape=Vv.scaled(i.shape,a,o))}return s},(e=dc||(dc={})).defaultData=function(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:I4.defaultData(),extrusion:UG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Vv.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="DecalGeometry")return{type:i,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")},XP=["width","height","depth"]}),Vft=j(()=>{qo(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:Ks.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let r=e(i);return r==="height"?1:r==="both"?2:0},t.getDensity=function(i){return i.density??t.defaultData.density},t.getHeightFalloff=function(i){return i.heightFalloff??t.defaultData.heightFalloff},t.getHeightBase=function(i){return i.heightBase??t.defaultData.heightBase}})(ea||(ea={}))}),WG=j(()=>{(II||(II={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Qp||(Qp={})).defaultData={enabled:!1,mode:"hdri",hdri:II.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function f3t(t){let e=typeof t=="string"?Number.parseInt(t,10):t;return typeof e=="number"&&Number.isFinite(e)?Math.min(5,Math.max(0,Math.round(e))):3}var V4,pv,NI,BI,kI,mv,VI,WU,qU,NY,U0,zft,on,z4,BY,kY,VY,zY,ku,rS,L4,F4,_c,Hg,LY,am,U4,xc,zI,LI,Pg,s0,Rg,sS,HU,FY,Da,FI,UY,jY,cc,Jl,fv,Lft=j(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(V4||(V4={})).defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})()}),qG=j(()=>{var t;Vft(),WG(),Lft(),qo(),(t=pv||(pv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(NI||(NI={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(BI||(BI={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(kI||(kI={})),(mv||(mv={})).defaultData={usePhysics:!1,gravity:-10},(VI||(VI={})).defaultData={playCamera:l0,gameControlObject:null},(WU||(WU={})).defaultData={backgroundColor:Hi.fromHexAndA(Mft,1),postprocessing:V4.defaultData,fog:ea.defaultData,sky:Qp.defaultData,globalPhysics:mv.defaultData,ambient:NI.defaultData,ao:BI.defaultData,shadow:pv.defaultData,publish:VI.defaultData,grading:kI.defaultData}}),g3t=j(()=>{(qU||(qU={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),eD=j(()=>{var t,e,i;Ui(),Cft(),Pft(),Rft(),Dft(),jG(),Oft(),qo(),hT(),GG(),Eft(),un(),qG(),g3t(),(t=NY||(NY={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=U0||(U0={})).identity={...NU.identity,shear:wl.zero},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,shear:r.shear}},e.merge=function(r,s){return{position:s?.position||r.position,rotation:s?.rotation||r.rotation,pivot:s?.pivot||r.pivot,pivotRotation:s?.pivotRotation||r.pivotRotation,scale:s?.scale||r.scale,shear:s?.shear||r.shear}},e.diff=function(r,s){return sft({position:ym.isEqual(r.position,s.position)?void 0:s.position,rotation:ym.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:ym.isEqual(r.scale,s.scale)?null:s.scale,shear:s.shear?.every((n,a)=>n===r.shear?.[a])?void 0:s.shear})},zft=["slide","offset"],(on||(on={})).defaultData={states:new ce,events:new ce,visible:!0,raycastLock:!1,physics:cv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...U0.identity,cloner:null},(z4||(z4={})).defaultData={type:"Empty",...on.defaultData},(BY||(BY={})).defaultData={type:"ParticleCollider",...qU.defaultData,...on.defaultData},(kY||(kY={})).defaultData={type:"Component",...on.defaultData},(VY||(VY={})).defaultData={type:"Particle",...on.defaultData,...R4.defaultData},(zY||(zY={})).defaultData={type:"Hair",...on.defaultData,...FU.defaultData},(ku||(ku={})).defaultData={type:"Mesh",...on.defaultData,...UU.defaultData},(rS||(rS={})).defaultData={...on.defaultData,...U0.identity,position:bc.DefaultPosition,rotation:bc.DefaultRotation,...bc.defaultData},(r=>{r.defaultData=function(s){return{...on.defaultData,...LU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(L4||(L4={})),(r=>{function s(n,a,o=0){for(;o<a.length;){let l=n?n[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;n=l.descendants,o+=1}}r.resolveWithDes=s,r.resolve=function(n,a,o=0){let l=s(n,a,o);if(l){let h=Object.keys(l);if(h.length===1&&h[0]==="descendants")return}return l}})(F4||(F4={})),(r=>{function s(n,a){return{...on.defaultData,...a,component:n,overrides:new Es,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=s,r.fromComponentData=function(n){let a=U0.fromObject(n.data);return s(n.id,a)}})(_c||(_c={})),(r=>{r.defaultData={type:"Page",...on.defaultData,physics:{...cv.defaultData,fusedBody:!1},...WU.defaultData,camera:rS.defaultData,timelines:new ke},r.isUIPage=function(s){return s.uiScene!==void 0}})(Hg||(Hg={})),(i=LY||(LY={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],shear:wl.zero,name:"Play Camera",visible:!0,raycastLock:!1,physics:cv.defaultData,states:new ce,events:new ce,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...bc.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","shear"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("RectangleGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("BooleanGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("ShapeBlendGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("TextGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("InputGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(s,n){let a={name:n};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Es}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new Es})))):r0.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function h(u,d){for(let[c,p]of Object.entries(d.layers)){let{texture:m,...f}=p;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...u,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...u,"layers",c],props:f,type:0};o.push(g)}}}for(let[u,d]of Object.entries(n)){let c=d;if(u!=="name")if(u==="cloner")o.push(...kU.toOps(c,["cloner"]));else if(u==="pathSnapping")o.push({path:[u],props:{slide:c.slide,offset:c.offset},type:0});else if(u==="material")h(["material"],c);else if(u==="materials")for(let[p,m]of Object.entries(c))h(["materials",p],m);else if(l[u]===0){if(u==="geometry"&&c.extrusion!==void 0){let p={path:[u,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[u],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[u]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,U0.merge(a,n)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:n.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??a.pathSnapping?.offset??0})}),r0.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=n;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(a,{geometry:k4.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let h={...o};return"material"in h&&"material"in l&&l.material&&(h.material=_4(h.material,u=>{if(typeof u!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=u.layers.data(d);p&&Bs.patch(p,c)}}).data),h.materials&&l.materials&&(h.materials=_4(h.materials,u=>{for(let d=0;d<h.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=u[d]?.layers?.data(p);f&&Bs.patch(f,m)}}}).data),h}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:nm.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:nm.merge(a.cloner,n.cloner)});else if(zU.is(s.type)){let o=n;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=Ks.clone(o.color))}return a}})(am||(am={}))}),HG=j(()=>{(U4||(U4={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),iD=j(()=>{HG(),qo(),(xc||(xc={})).defaultData={orbitControls:U4.defaultData,playPage:dv,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,r=0;return e<5?r=-30:e<10&&(r=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,r],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu",asyncShaderCompilation:!0}}),Fft=j(()=>{var t;(zI||(zI={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(LI||(LI={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=Pg||(Pg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...zI.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:LI.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),$G=j(()=>{eD(),Ui(),iD(),qo(),un(),Fft(),(t=>{function e(i,r){let s=i.scene.objects.get(r);if(s&&s.data.type==="Component")return s;{let n=i.shared.lib.components[r];if(n)return{...n.asset,id:r}}}t.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,r){let s=i.find(n=>n.data.type==="Page"&&n.data.timelines?.[r]!==void 0);return s&&s.data.timelines?.[r]},t.getComponentData=e,t.traverseModuleInstances=function(i,r,s){i.scene.objects.traverseFrom(r,(n,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&s(n,a,o.events)}else s(n,a,a.events)})}})(s0||(s0={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new Nn;return a.push({fi:1,id:dv,data:{...Hg.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:$a(r,Nn.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:L4.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:xc.defaultData,styles:Pg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new Nn,publish:xc.defaultData,styles:Pg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:xc.defaultData,styles:Pg.defaultData()}},t.emptyData=function(){return{objects:new Nn,publish:{...xc.defaultData},styles:Pg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(Rg||(Rg={}))}),Uft=j(()=>{(sS||(sS={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),XG=j(()=>{var t,e;Ui(),un(),(t=HU||(HU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ce}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(FY||(FY={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ce,queries:new ce,autoStart:!0}),(i=>{function r(n){return n.textValue!==void 0}function s(n){return typeof n=="boolean"}i.isTextValue=r,i.isNumber=function(n){return typeof n=="number"},i.isBoolean=s,i.typeOfVariable=function(n){return r(n)?"string":s(n)?"boolean":"number"},i.getDisplayedValue=function(n){return i.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(a=>a.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():i.isBoolean(n)?n?"True":"False":i.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}})(Da||(Da={})),(FI||(FI={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(UY||(UY={})).all=[...FI.all,"components"],(jY||(jY={})).defaultData=function(){return{images:new ke,videos:new ke,colors:new ke,audios:new ke,particles:new ke,fonts:new ke,materials:new ke,components:new ke,variables:new ke,userAPIs:new ke,userWebhooks:new ke}},(cc||(cc={})).defaultData=function(){return{images:new ke,videos:new ke,colors:new ke,audios:new ke,particles:new ke,fonts:new ke,materials:new ke,components:new ke,variables:new ke,userAPIs:new ke,userWebhooks:new ke}},(e=Jl||(Jl={})).defaultColors=function(){return $a({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},ke.prototype)},e.defaultImages=function(){return $a({},ke.prototype)},e.emptyData=function(){return{catelogs:new ke,materials:new ke,images:new ke,videos:new ke,colors:new ke,audios:new ke,particles:new ke,fonts:new ke,variables:new ce,userAPIs:new ke,userWebhooks:new ke,lib:cc.defaultData()}},e.defaultVariables=function(i){switch(i){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let r=[0,0,0];return{name:"Time",value:{textValue:r,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:r,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",i)}},e.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let s=Math.floor(i/3600),n=Math.floor((i-3600*s)/60);return{textValue:[s,n,Math.round(i-3600*s-60*n)]}}if(r.format==="mm:ss"){let s=Math.floor(i/60);return{textValue:[s,Math.round(i-60*s)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),y3t=j(()=>{}),jft=j(()=>{var t;Ui(),$G(),Uft(),XG(),(t=fv||(fv={})).defaultData={schema:135,scene:Rg.defaultData,frames:new ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sS.defaultData),shared:{...Jl.emptyData(),colors:Jl.defaultColors()}},t.createDefaultData=function(){return FS.deserialize(FS.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:135,scene:Rg.emptyDataWithPage(),frames:new ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sS.defaultData),shared:{...Jl.emptyData(),colors:Jl.defaultColors(),images:Jl.defaultImages()}}},t.emptyData=function(){return{schema:135,scene:Rg.emptyDataWithPage(),frames:new ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sS.defaultData),shared:Jl.emptyData()}},t.clipboard2dData=function(){return{schema:135,scene:Rg.emptyData(),frames:new ke,shared:Jl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:cc.defaultData()}}},t.getComponentData=function(e,i){return s0.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let r of i){let s=r.headers;for(let n of s)if(n.data.key.toLowerCase()==="authorization"&&n.data.value!=="")return!0}return!1}});function Pc(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function u_(t,e,i){switch(t){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:r,control2:s}=e??{...kv.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...sm.defaultData},o=new Gft(r,s,n,a),l=o.solve(1);return()=>h=>o.solve(h)/l}case 8:return()=>r=>Math.floor(r)}}var GY,WY,vm,jS,Gft,j4,G4,YG=j(()=>{Ui(),qo(),(GY||(GY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new ke}},(WY||(WY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(u,d){let c=[0,0],p=[1,1];if(u?.cubicControls)c=Pc(u.cubicControls.control1,c);else switch(u?.type){case 2:case 4:c=[.42,0];break;case 3:case 0:c=[0,0];break;case 1:c=[.25,.1];break;case 7:c=[.25,1]}if(d?.cubicControls)p=Pc(d.cubicControls.control2,p);else switch(d?.type){case 2:case 0:p=[1,1];break;case 3:case 4:p=[.58,1];break;case 1:p=[.25,1];break;case 7:p=[.5,1]}return{control1:c,control2:p}}function i(u){if(!t.BEZIER_PRESETS.includes(u))return;let d={type:u};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(u,d){return Math.abs(u[0]-d[0])<.001&&Math.abs(u[1]-d[1])<.001}function s(u){let d=t.ROOT_PROPERTY_ORDER.indexOf(u[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(u){return u.layerId??u.path.join(".")}function a(u){let d=u[u.length-1];return jS.includes(d)?d:void 0}function o(u){return u.layerId?u.layerId:(a(u.path)?u.path.slice(0,-1):u.path).join(".")}function l(u){return["material",u.type==="light"?`${u.category} lighting`:u.type]}function h(u,d,c){return{id:u,data:{id:u,time:c?.time??0,path:d,value:{},layerId:c?.layerId,index:c?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}t.getControlsWithDefault=e,t.BEZIER_PRESETS=[0,1,2,3,4,7],t.presetHandles=i,t.presetForHandles=function(u){return t.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,u.control1)&&r(c.control2,u.control2)})},t.defaultData=function(u){return{id:u,keyframes:new ce}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=s,t.propertyKey=n,t.groupKeyframes=function(u,d){let c=new Map;for(let p of u){let m=p.data;if(d?.(m))continue;let f=n(m),g=c.get(f);g||(g={id:f,path:m.path,keyframes:[],layerId:m.layerId,index:m.index},c.set(f,g)),m.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,m)=>{let f=s(p.path)-s(m.path);return f!==0?f:(p.index??0)-(m.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(u){let d=new Map;for(let c of u){let p=a(c.path),m=p?c.path.slice(0,-1):c.path,f=o(c),g=d.get(f);g||(g={id:f,path:m,layerId:c.layerId,index:c.index,tracks:[]},d.set(f,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},t.sortedKeyframes=function(u){return[...u].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(u,d){return u.map(({data:c,id:p},m)=>h(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=h,t.createName=function(u){return Object.entries(u).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:u_(3),duration:1e3},opacity:{value:[0,1],easing:u_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:u_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:u_(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:u_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(vm||(vm={})),jS=["x","y","z"],Gft=class{constructor(t=1,e=100,i=10,r=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(e/t),this.m_zeta=i/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(t){return 1-(this.m_zeta<1?Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0))}getDuration(){let t=.16666666666666666,e=0,i=0;for(;;)if(e+=t,this.solve(e)===1){if(i++,i>=16)break}else i=0;return e*t*1e3}}}),KG=j(()=>{var t;qo(),Ui(),(j4||(j4={})).list=["idle","move","jump","run"],(t=G4||(G4={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ce,move:new ce,jump:new ce,run:new ce},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Hi.fromHexAndA(3728051,1)}}});function dg(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function qY(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,r=e.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...dg(Ns(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,a)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let i={...Ns(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Jd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function tc(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=ls.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ls.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ls.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Es.prototype&&e(s.material)})})}function HY(t){t.layers===void 0&&Object.assign(t,ls.defaultTwoLayerData("lambert"))}function UI(t){!t.layers||t.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let i=[...e.colors];i.push(e.colors[9]);let r=[...e.steps];r.push(e.steps[9]);let s={...Ns(e),colors:i,steps:r};Object.assign(e,s)}})}function $Y(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&UI(r)}):"material"in i&&typeof i.material!="string"&&UI(i.material)}),Object.values(t.shared.materials).forEach(e=>UI(e))}function XY(t){t.layers&&t.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function YY(t){t.layers&&t.layers.forEach(e=>{(function(i){return i.type!=="displace"})(e)&&e.isMask===void 0&&(e.isMask=!1),(e.type==="texture"||e.type==="video")&&e.blending===void 0&&(e.blending=0),(e.type==="noise"||e.type==="displace"&&e.displacementType==="noise")&&(e.voronoiStyle===void 0&&(e.voronoiStyle=0),e.highCut===void 0&&(e.highCut=1),e.lowCut===void 0&&(e.lowCut=0),e.smoothness===void 0&&(e.smoothness=.3),e.seed===void 0&&(e.seed=0),e.quality===void 0&&(e.quality=1))})}function KY(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Bs.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function ZY(t){Jd(t,KY),tc(t,KY)}function QY(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function JY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var v3t=j(()=>{hT(),qo(),HG(),eD(),Ui(),iD(),un(),ht(),GG(),KG(),Fft(),$G(),jG(),qG()});function Wft(t){let e=t.elements;jh.set(e[0],e[1],e[2]),Gh.set(e[4],e[5],e[6]),zu.set(e[8],e[9],e[10])}function qft(){let t=Math.max(jh.lengthSq(),Gh.lengthSq(),zu.lengthSq());jh.lengthSq()>i2*t?gl.copy(jh).normalize():gl.set(1,0,0),yl.crossVectors(zu,gl),yl.lengthSq()<=i2*t&&(yl.copy(Gh).addScaledVector(gl,-Gh.dot(gl)),yl.lengthSq()<=i2*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=i2&&e.set(0,1,0).cross(i),e.normalize()}(yl,gl)),yl.normalize(),Dg.crossVectors(gl,yl)}function Hft(t,e,i){return Wft(t),qft(),e.makeBasis(gl,yl,Dg),i.set(gl.dot(jh),gl.dot(Gh),gl.dot(zu),0,yl.dot(jh),yl.dot(Gh),yl.dot(zu),0,Dg.dot(jh),Dg.dot(Gh),Dg.dot(zu),0,0,0,0,1),function(){let r=jh.length(),s=Gh.length(),n=zu.length(),a=Math.max(r,s,n);if(a-r>r2||a-s>r2||a-n>r2)return!0;let o=r2*a*a;return Math.abs(jh.dot(Gh))>o||Math.abs(jh.dot(zu))>o||Math.abs(Gh.dot(zu))>o}()}function $ft(t){return Wft(t),qft(),Xft.makeBasis(gl,yl,Dg)}var jh,Gh,zu,gl,yl,Dg,Xft,i2,r2,rD=j(()=>{ht(),jh=new P,Gh=new P,zu=new P,gl=new P,yl=new P,Dg=new P,Xft=new xt,i2=1e-12,r2=.01});function j0(t,e){return e===0?0:t/e}function ZG(t){Hft(t,XU,$U),K1.setFromRotationMatrix(XU);let e=function(r,s,n){let a=2*Math.PI,o=d=>d-a*Math.round(d/a),l=o(r+Math.PI),h=o(Math.PI-s),u=o(n+Math.PI);return Math.abs(l)+Math.abs(u)<Math.abs(r)+Math.abs(n)-1e-9?[l,h,u]:[r,s,n]}(K1.x,K1.y,K1.z),i=$U.elements;return{position:[t.elements[12],t.elements[13],t.elements[14]],rotation:[e[0]*Ft.RAD2DEG,e[1]*Ft.RAD2DEG,e[2]*Ft.RAD2DEG],scale:[i[0],i[5],i[10]],shear:[j0(i[4],i[5]),j0(i[8],i[10]),j0(i[1],i[0]),j0(i[9],i[10]),j0(i[2],i[0]),j0(i[6],i[5])]}}function wc(t,{translation:e,quaternion:i,scale:r,shearMatrix:s}={}){let n=ZG(t);if(e!==void 0&&e.fromArray(n.position),i!==void 0){let a=n.rotation;i.setFromEuler(K1.set(a[0]*Ft.DEG2RAD,a[1]*Ft.DEG2RAD,a[2]*Ft.DEG2RAD))}r!==void 0&&r.fromArray(n.scale),s!==void 0&&s.fromArray(wl.toMatrix(n.shear))}var $U,XU,K1,uT=j(()=>{ht(),rD(),Cgt(),$U=new xt,XU=new xt,K1=new Fi});function Yft(t){return t.length>=4&&function(e){return typeof e=="object"&&e!==null&&e.v===1&&e.data instanceof Float32Array&&Array.isArray(e.tracks)}(t[3])}function Kft(t,e,i){let r={name:e,duration:i.duration,tracks:[],uuid:t};return i.blendMode!==void 0&&(r.blendMode=i.blendMode),JSON.stringify(r)}function b3t(t,e,i){for(let r=0;r<i.length;r++)if(!Object.is(t[e+r],i[r]))return!1;return!0}function _3t(t){if(!Array.isArray(t)||t.length>3)return t;let e,[i,r,s]=t;if(typeof i!="string"||typeof s!="string")return t;try{e=JSON.parse(s)}catch{return t}return e&&Array.isArray(e.tracks)&&!e.tracks.some(n=>!n?.type||!n.times||!n.values)?function(n,a,o){let l=[],h=0,u=g=>{let y=[h,g.length];return l.push(g),h+=g.length,y},d=new Map,c=o.tracks.map(g=>{let y=(_=>{let x=Float32Array.from(_),S=x.length+":"+x[0]+":"+x[x.length-1],w=d.get(S)??[];for(let C of w)if(b3t(C.run,0,x))return C.span;let T=u(x);return w.push({span:T,run:x}),d.set(S,w),T})(g.times),v=!Zft.has(g.type),b={name:g.name,type:g.type,times:y,values:v?u(Float32Array.from(g.values)):[0,0]};return v||(b.list=Array.from(g.values)),g.interpolation!==void 0&&(b.interpolation=g.interpolation),b}),p=new Float32Array(h),m=0;for(let g of l)p.set(g,m),m+=g.length;let f={v:1,duration:o.duration,data:p,tracks:c};return o.blendMode!==void 0&&(f.blendMode=o.blendMode),o.userData!==void 0&&o.userData!=="{}"&&(f.userData=o.userData),[n,a,Kft(n,a,f),f]}(i,typeof e.name=="string"?e.name:r,e):t}function x3t(t,e,i){return t.map(r=>{let s=e();return i[r[0]]=s,function(n,a){let[o,l,h]=n;if(Yft(n))return[a,l,Kft(a,l,n[3]),n[3]];let u=h.indexOf(o);return[a,l,u!==-1?h.slice(0,u)+a+h.slice(u+o.length):h,...n.slice(3)]}(r,s)})}var Zft,Qft=j(()=>{Zft=new Set(["bool","string"])});function NM(t,[e,i]){return Math.min(Math.max(t,e),i)}function Jft(t,e,i,r,s){t=NM(t,sgt),e=NM(e,ngt),i=NM(i,agt),r=NM(r,ogt);let n=Math.sqrt(e/t),a=i/(2*Math.sqrt(e*t)),o=a<1?n*Math.sqrt(1-a*a):0,l=a<1?(a*n-r)/o:-r+n;return h=>{let u=s!==void 0?s*h:h;return u=a<1?Math.exp(-u*a*n)*(1*Math.cos(o*u)+l*Math.sin(o*u)):(1+l*u)*Math.exp(-u*n),h===0||h===1?h:1-u}}function tgt(t,e){return ri(ri(1-ri(3*e))+ri(3*t))}function egt(t,e){return ri(ri(3*e)-ri(6*t))}function igt(t){return ri(3*t)}function BM(t,e,i){return ri(ri(ri(ri(ri(tgt(e,i)*t)+egt(e,i))*t)+igt(e))*t)}function tK(t,e,i){let r=ri(ri(ri(3*tgt(e,i))*t)*t),s=ri(ri(2*egt(e,i))*t);return ri(ri(r+s)+igt(e))}function G0(t,e,i,r){if(t=ri(t),e=ri(e),i=ri(i),r=ri(r),t<0||t>1||i<0||i>1||t===e&&i===r)return cgt;let s=new Float32Array(YP);for(let n=0;n<YP;n++)s[n]=BM(ri(n*s2),t,i);return n=>(n=ri(n))===0||n===1?n:BM((a=>{let o=0,l=1,h=YP-1;for(;l!==h&&s[l]<=a;)o=ri(o+s2),l+=1;l-=1;let u=ri(ri(a-s[l])/ri(s[l+1]-s[l])),d=ri(o+ri(u*s2)),c=tK(d,t,i);return c>=hgt?function(p,m,f,g){for(let y=0;y<lgt;y++){let v=tK(m,f,g);if(v===0)return m;let b=ri(BM(m,f,g)-p);m=ri(m-ri(b/v))}return m}(a,d,t,i):c===0?d:function(p,m,f,g,y){let v,b=0,_=0;do b=ri(m+ri(ri(f-m)/2)),v=ri(BM(b,g,y)-p),v>0?f=b:m=b,_+=1;while(Math.abs(v)>ugt&&_<dgt);return b}(a,o,ri(o+s2),t,i)})(n),e,r)}function rgt(t,e,i){switch(t.easing){case 0:default:return i;case 1:return G0(.25,.1,.25,1)(i);case 2:return G0(.42,0,1,1)(i);case 3:return G0(0,0,.58,1)(i);case 4:return G0(.42,0,.58,1)(i);case 7:return G0(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:r,control2:s}=t;return r&&s?G0(r[0],r[1],s[0],s[1])(i):i}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=t;return r===void 0||s===void 0||n===void 0||a===void 0?i:ri(Jft(r,s,n,a,e)(i))}}}var ri,sgt,ngt,agt,ogt,lgt,hgt,ugt,dgt,YP,s2,cgt,eK,w3t=j(()=>{ri=Math.fround,sgt=[.01,100],ngt=[.01,1e4],agt=[.01,1e3],ogt=[.01,1e3],lgt=4,hgt=ri(.001),ugt=ri(1e-7),dgt=10,s2=ri(1/((YP=11)-1)),cgt=t=>t,eK=ri(1.70158),ri(eK+1)});function pgt(t,e){if(t.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(e<=t[0].time)return{index0:0,index1:0,t:1};let{found:i,index:r}=function(h,u){let d=h.length,c=0,p=d;for(;c<p;){let m=c+Math.floor(d/2),f=h[m].time;if(f<u)c=m+1;else{if(!(f>u))return{found:!0,index:m};p=m}d=p-c}return{found:!1,index:c}}(t,e);if(i)return{index0:r,index1:r,t:1};if(r>=t.length){let h=t.length-1;return{index0:h,index1:h,t:1}}let s=r-1,n=r,a=t[s].time,o=t[n].time;if(o===a)return{index0:s,index1:n,t:.5};let l=KP(o-a);return{index0:s,index1:n,t:rgt({...t[s].ease,control2:t[n].ease.control2},l,KP(KP(e-a)/l))}}function mgt(t){return[...t].sort((e,i)=>e.time-i.time)}var KP,S3t=j(()=>{w3t(),KP=Math.fround});function T3t(t){if(t?.length!==2)return;let e=`${t[0]}.${t[1]}`;return QG.includes(e)?e:void 0}function fgt(t){return t.slice(0,t.indexOf("."))}function ggt(t){return bm.indexOf(t.slice(-1))}function M3t(t){return{easing:t?.type,control1:Pc(t?.cubicControls?.control1,[0,0]),control2:Pc(t?.cubicControls?.control2,[1,1]),...t?.springParameters}}function A3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function iK(t,e,i){let r=fgt(t);if(r==="position"){let s=ggt(t);return bm.flatMap((n,a)=>Math.abs(e.elements[4*a+s])>1e-9?[`position.${n}`]:[])}return(i?[r]:["rotation","scale"]).flatMap(s=>bm.map(n=>`${s}.${n}`))}function C3t(t,e){let[i,r,s]=t,n=[[i,r,s],[i+180,180-r,s+180]],a=[i,r,s],o=1/0;for(let l of n){let h=l.map((d,c)=>d+360*Math.round((e[c]-d)/360)),u=h.reduce((d,c,p)=>d+Math.abs(c-e[p]),0);u<o-1e-9&&(a=h,o=u)}return a}function E3t(t,e,i){if(t==="rotation"){let r=((e-i)%360+540)%360-180;return Math.abs(r)<1e-6}return Math.abs(e-i)<1e-9*Math.max(1,Math.abs(e),Math.abs(i))}function P3t(t,e,i,r){let s=new Map;for(let{id:p,data:m}of t.unproxy()){if(m.isPlaceholder)continue;let f=T3t(m.path);if(!f){if(n2.includes(m.path?.[0]))return;continue}if(typeof m.value!="number"||!Number.isFinite(m.value))return;let g=s.get(f)??{keys:[],sampled:[]};g.keys.push({id:p,time:m.time,value:m.value,keyframe:m}),s.set(f,g)}if(s.size===0)return;for(let p of s.values())p.keys.sort((m,f)=>m.time-f.time),p.sampled=mgt(p.keys.map(m=>({time:m.time,ease:M3t(m.keyframe.easing),value:m.value})));let n=(p,m)=>{let f=s.get(p);return f?function(g,y){let{index0:v,index1:b,t:_}=pgt(g.sampled,y),x=g.sampled[v].value;return x+(g.sampled[b].value-x)*_}(f,m):i[fgt(p)][ggt(p)]},a=new Te,o=new Fi,l=new xt,h=new P,u=new P,d=p=>{let m=(f=>{let g={};for(let y of n2)g[y]=bm.map((v,b)=>n(QG[3*n2.indexOf(y)+b],f));return g})(p);return o.set(m.rotation[0]*Ft.DEG2RAD,m.rotation[1]*Ft.DEG2RAD,m.rotation[2]*Ft.DEG2RAD),l.compose(h.fromArray(m.position),a.setFromEuler(o),u.fromArray(m.scale)).premultiply(e),{pose:m,out:ZG(l)}},c=function(p){let m=p.elements,f=[0,4,8].map(v=>new P(m[v],m[v+1],m[v+2])),g=f[0].lengthSq(),y=1e-9*Math.max(1,g);return Math.abs(f[1].lengthSq()-g)<y&&Math.abs(f[2].lengthSq()-g)<y&&Math.abs(f[0].dot(f[1]))<y&&Math.abs(f[0].dot(f[2]))<y&&Math.abs(f[1].dot(f[2]))<y}(e);for(let p of n2){let m,f=bm.map(b=>`${p}.${b}`),g=b=>{let _=new Set;for(let x of iK(b,e,c))for(let S of s.get(x)?.keys??[])_.add(S.time);return[..._].sort((x,S)=>x-S)},y=[...new Set(f.flatMap(b=>g(b)))].sort((b,_)=>b-_),v=new Map;for(let b of y){let{pose:_,out:x}=d(b),S=[...x[p]];p==="rotation"&&(S=C3t(S,m?m.out.map((w,T)=>w+_.rotation[T]-m.in[T]):_.rotation),m={in:_.rotation,out:S}),v.set(b,S)}f.forEach((b,_)=>{let x=s.get(b)?.keys??[],S=g(b),w=new Set(S);if(x.length!==0||!S.every(T=>E3t(p,v.get(T)[_],r[p][_]))){for(let T of x)w.has(T.time)||t.delete(T.id);for(let T of S){let C=v.get(T)[_],M=x.find(I=>I.time===T);if(M){let I=t.data(M.id);I&&(I.value=C);continue}let A=iK(b,e,c).sort((I,O)=>Number(O===b)-Number(I===b)).map(I=>s.get(I)?.keys.find(O=>O.time===T)).find(I=>I!==void 0),R=Ft.generateUUID();t.insertBefore(null,[{id:R,data:{id:R,time:T,path:[p,bm[_]],value:C,easing:A3t(A.keyframe.easing),index:vm.rowOrder([p])}}])}}})}}var n2,bm,QG,R3t=j(()=>{ht(),YG(),S3t(),uT(),bm=["x","y","z"],QG=(n2=["position","rotation","scale"]).flatMap(t=>bm.map(e=>`${t}.${e}`))}),ygt={};function rK(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function vgt(t){let e=t.geometry;e!==void 0&&Tgt.has(e.type)&&e.extrusionVersion===void 0&&(e.extrusionVersion=1)}function bgt(t){if(t.type!=="Empty")return;let e=Ns(t.animations);if(!Array.isArray(e))return;let i=e.map(_3t);i.some((r,s)=>r!==e[s])&&(t.animations=i)}function sK(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),u=Math.sin(s),d=[o*h,n*u+a*h*l,a*u-n*h*l],c=Math.hypot(e[0],e[1],e[2])||1;return Math.abs((d[0]*e[0]+d[1]*e[1]+d[2]*e[2])/c)}function _gt(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*kp)})(t),t.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(s,n){let a=Array.isArray(n)&&n.length>=3&&n.every(h=>typeof h=="number"&&Number.isFinite(h))?n:[0,1,0],o=sK(s,a),l=sK(s.map(h=>h*Mgt),a);return Math.abs(o-l)<1e-6?s.some(h=>Math.abs(h)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*kp)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*kp))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*kp),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*kp),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=kp,e.extrusion.twist*=kp),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(Ns(t.events))&&t.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function D3t(t){t.scene.objects.traverse((e,i)=>{})}function O3t(t){let e=t.schema??104;e!==135&&(e<130&&(JG(t.asset),t.schema=130),e<135&&(tW(t.asset),t.schema=135))}function Nu(t,e){e(t.data);for(let i of t.children)Nu(i,e)}function xgt(t){let e=t.schema??104;e!==135&&(e<105&&(Nu(t.asset,_gt),t.schema=105),e<118&&(Nu(t.asset,wgt),t.schema=118),e<121&&(Nu(t.asset,ZU),t.schema=121),e<130&&(Nu(t.asset,i=>nK(i,JG)),t.schema=130),e<132&&(Nu(t.asset,vgt),t.schema=132),e<133&&(Nu(t.asset,i=>Sgt(i,()=>{})),t.schema=133),e<134&&(Nu(t.asset,bgt),t.schema=134),e<135&&(Nu(t.asset,i=>nK(i,tW)),t.schema=135))}function YU(t,e){tc(t,e),Jd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function JG(t){t.layers===void 0&&Object.assign(t,ls.defaultTwoLayerData("phong"))}function tW(t){let e=Jw(t),i=ls.withRepairedLayers(e);i!==e&&(t.layers=i.layers)}function nK(t,e){"materials"in t?t.materials.forEach(i=>{i!==void 0&&typeof i!="string"&&e(i)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&e(t.material)}function wgt(t){t.timelineAnimations=$a({},ke.prototype)}function I3t(t){let e=[];return t?(t.forEach((i,r)=>{let{path:s,keyframes:n}=i.data,a=s[0]==="material"?i.id:void 0;n?.length?n.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:s,layerId:a,index:r}})}):e.push(vm.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ce(...e.map((i,r)=>({...i,fi:r})))):new ce}function N3t(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!Agt.includes(r))continue;let s=KU(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let h of l){let u=Ft.generateUUID();t.insertBefore(null,[{id:u,data:{...i,id:u,path:[r,h],value:a[h],easing:B3t(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function KU(t){return t===null||typeof t!="object"?[]:jS.filter(e=>e in t)}function B3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function k3t(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function V3t(t){let e=function(n){let a=[];for(let o of vm.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(u=>KU(u.data.value))),h=l.size?[...l].map(u=>o.keyframes.filter(d=>KU(d.data.value).includes(u))):[o.keyframes];for(let u of h){let d=[...u].sort((c,p)=>c.data.time-p.data.time);for(let c=0;c+1<d.length;c++)a.push({left:d[c],right:d[c+1]})}}return a}([...t.unproxy()]),i=new Map,r=new Set;for(let{left:n,right:a}of e){let o=n.data.easing?.type,l=(o===void 0?void 0:vm.presetHandles(o))?.control2??(o===5?Pc(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let h=i.get(a.id);h?k3t(h,l)||r.add(a.id):i.set(a.id,l)}let s=new Map;for(let{id:n,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:vm.presetHandles(o);l&&s.set(n,l.control1)}for(let{left:n,right:a}of e)r.has(a.id)&&s.delete(n.id);for(let[n,a]of s){let o=t.data(n);!o?.easing||(o.easing.cubicControls={control1:a,control2:Pc(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:n,right:a}of e){if(!s.has(n.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Pc(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function aK(t,e){t.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="Page"&&s.timelines)for(let n of Object.values(s.timelines))for(let a of Object.values(n.objectTimelines??{}))e(a.keyframes)})}function ZU(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function Sgt(t,e,i=[]){let r=["position","rotation","scale","shear"];function s(c,p,m){return c?.map(f=>typeof f=="string"?e(f)??m:f)??[...p]}function n(c,p){if(c&&!function(m){return m.every((f,g)=>Math.abs(f-(g%5==0?1:0))<1e-6)}(c))return ZG(new xt().fromArray(c).multiply(new xt().compose(new P().fromArray(p.position),new Te().setFromEuler(new Fi(p.rotation[0]*Ft.DEG2RAD,p.rotation[1]*Ft.DEG2RAD,p.rotation[2]*Ft.DEG2RAD)),new P().fromArray(p.scale))))}function a(c,p){return c.length===p.length&&c.every((m,f)=>m===p[f])}t.shear=wl.zero;let o=t,l=o.hiddenMatrix;l!==void 0&&delete o.hiddenMatrix;let h={position:s(o.position,[0,0,0],0),rotation:s(o.rotation,[0,0,0],0),scale:s(o.scale,[1,1,1],1)},u=n(l,h);if(u&&Object.assign(o,u),u){let c=new xt().fromArray(l);for(let p of i)P3t(p,c,h,u)}let d=u??{...h,shear:[...wl.zero]};o.states?.forEach(c=>{let p=c.hiddenMatrix;if(p!==void 0&&delete c.hiddenMatrix,p===void 0&&c.position==null&&c.rotation==null&&c.scale==null)return;let m={position:s(c.position,h.position,0),rotation:s(c.rotation,h.rotation,0),scale:s(c.scale,h.scale,1)},f=n(p??l,m);if(!u&&!f)return;let g=f??{...m,shear:[...wl.zero]};for(let y of r)(c[y]!=null||!a(g[y],d[y]))&&(c[y]=g[y])})}function z3t(t){}function L3t(t){let e=t.schema??0;if(e!==135){if(e>135)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 135). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",135),function(i,r){if(r<1&&(tc(i,qY),Jd(i,qY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{...U4.defaultData,...Ns(s.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(s){function n(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,h]of Object.entries(o))if((tD.includes(l)||typeof h=="boolean")&&delete o[l],l==="texture")for(let[u,d]of Object.entries(h))(FG.includes(u)||typeof d=="boolean")&&delete h[u]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let h=l;h.material?n(h.material):h.materials&&h.materials.forEach(u=>{n(u)})})})}(i),i.schema=3),r<4&&(function(s){s.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(s){s.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),r<7&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&($Y(i),i.schema=9),r<10&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(s){s.scene.environment.ambientLight.softShadows=!1,s.scene.environment.ambientLight.softShadowQuality="low",s.scene.objects.traverse((n,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),s.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&($Y(i),i.schema=12),r<13&&(function(s){s.shared.audios=$a({},ke.prototype)}(i),i.schema=13),r<14&&(function(s){let n=s.shared.materials;Object.entries(n).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(n,{[a]:l})}})}(i),i.schema=14),r<15&&(function(s){Object.entries(Ns(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(Ns(s.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.audios[n]})}(i),i.schema=15),r<16&&(function(s){s.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(tc(i,XY),Jd(i,XY),i.schema=17),r<18&&(tc(i,HY),Jd(i,HY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...xc.defaultData.settings.video,...Ns(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=$a({},ke.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let h=ls.defaultTwoLayerData("phong"),u=typeof l.color=="string"?s.shared.colors[l.color]:l.color;h.layers[1].data.color={r:u.r,g:u.g,b:u.b},h.layers[1].data.alpha=l.alpha;let d=function(m){return m.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}(l.font);s.shared.fonts[d]===void 0&&(s.shared.fonts[d]={name:d});let c={name:l.name,...on.defaultData,...ku.defaultData,flatShading:!1,wireframe:!1,geometry:{...dc.defaultData("TextGeometry"),width:l.width,height:l.height,font:d,depth:0,horizontalAlign:l.horizontalAlign,verticalAlign:l.verticalAlign,fontSize:1.40625*l.fontSize,lineHeight:l.lineHeight/1.40625,letterSpacing:l.letterSpacing-1,text:l.text,textTransform:l.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:h,states:Ns(l.states),events:Ns(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Ns(s.scene.objects).parent(a);s.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),n.push(a)}}),n.forEach(a=>{s.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(s){let n={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};s.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(n[Number(l.type)])if(Object.assign(l,{type:n[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new ce,move:new ce,jump:new ce}});else{let h=new ce;Object.assign(l,{actions:h}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&h.push({fi:0,id:Ft.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((u,d,c)=>{let p={easing:u.easing,duration:u.duration};u.easing===6?Object.assign(p,dg(u,"mass","stiffness","damping","velocity")):u.easing===5&&Object.assign(p,{control1:{...u.control1},control2:{...u.control2}});let m={repeat:u.repeat?-1:0,delay:u.delay,delayDirection:u.delayDirection,direction:u.cycle&&u.rewind?"pingpong-rewind":u.cycle?"pingpong":"normal"},f={state:u.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:u.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ce({fi:0,id:Ft.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:Ft.generateUUID(),data:f})};h.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,h){let u=new ce,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===h){let f;d.push(p),c.interaction==="play"?f={...dg(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(f={...dg(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&u.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),u.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,u):a.events.insertBefore(null,[{id:Ft.generateUUID(),data:{type:l,actions:u}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),r<22&&(ZY(i),i.schema=22),r<23&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(s){s.scene.objects.traverse((n,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(function(s){s.shared.videos=$a({},ke.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(s){s.scene.objects.traverse((n,a)=>{let o=s.scene.objects.unproxy().parent(n);if(o){let l=Ns(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Ns(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(s){s.scene.objects.traverse((n,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),r<28&&(ZY(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,Es.prototype),o.texture&&Object.setPrototypeOf(o.texture,Es.prototype)}function a(o){Object.setPrototypeOf(o,Es.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(h=>{let u=h;if(u.material){let d=Ns(u.material).layers;a(d),u.material.layers=d}if(u.materials)for(let d=0;d<u.materials.length;d++){let c=u.materials[d],p=Ns(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=ls.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(s){s.scene.publish.orbitControls.autoZoom===void 0&&(s.scene.publish.orbitControls.autoZoom=!1),s.scene.objects.traverse((n,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),r<33&&(function(s){s.scene.objects.traverse((n,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),r<34&&(function(s){s.scene.publish.mouseEventTarget===void 0&&(s.scene.publish.mouseEventTarget="canvas"),s.scene.publish.settings.web.hint===void 0&&(s.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(s){let{video:n}=s.scene.publish.settings;n.format==="gif"&&n.fps>48&&(n.fps=15)}(i),i.schema=35),r<36&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(s){let n=s.scene.environment.usePhysics;s.scene.objects.traverse((a,o)=>{n&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(tc(i,YY),Jd(i,YY),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=G4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=Pg.defaultData())}(i),i.schema=40),r<41&&(function(s){s.scene.environment.ambientLight.occlusion===void 0&&(s.scene.environment.ambientLight.occlusion=!1),s.scene.environment.ambientLight.aoFullRes===void 0&&(s.scene.environment.ambientLight.aoFullRes=!1),s.scene.environment.ambientLight.radius===void 0&&(s.scene.environment.ambientLight.radius=256),s.scene.environment.ambientLight.bias===void 0&&(s.scene.environment.ambientLight.bias=.5),s.scene.environment.ambientLight.aoColor===void 0&&(s.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),tc(s,QY),Jd(s,QY)}(i),i.schema=41),r<42&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new ce})})})}(i),i.schema=42),r<43&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){tc(i,JY),Jd(i,JY),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=l0);let s=Ns(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=dv,n.insertBefore(null,null,[{id:dv,data:{...Hg.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:dg(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:dg(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...mv.defaultData,...dg(i.scene.environment,"usePhysics","gravity")},camera:Ns(i.scene.ownerCamera)??Hg.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==Rg.TRASH_CAN_ID&&n.move(dv,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,h)=>{h.type==="DirectionalLight"?(h.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):h.type==="SpotLight"&&(h.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(h.physics===void 0||h.physics===null)&&h.type!=="Instance"&&(h.physics={},Object.assign(h.physics,cv.defaultData)),h.physics!==void 0&&h.physics!==null&&(h.physics.enabled=h.collision??"visibility",delete h.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=xc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(tc(t,rK),Jd(t,rK),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new ke,t.shared.lib=cc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=$a({},ke.prototype)}(t),t.scene.objects.traverse((i,r)=>{_gt(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))xgt(i);if(e<106&&(function(i){let r=Ns(i.shared.variables);i.shared.variables=$a(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ce.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=cc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=$a({},ke.prototype),i.shared.lib&&(i.shared.lib.particles=cc.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Particle"&&typeof s.renderMaterial.size=="number"&&Object.assign(s.renderMaterial,{size:[s.renderMaterial.size,s.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,r)=>{(function(s){Array.isArray(Ns(s.events))&&s.events?.forEach(n=>{"disabled"in n||(n.disabled=!1),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress")&&(n.mode=n.mode||"Object")})})(r)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Page"&&(s.postprocessing.depthOfField.focusDistance=100,s.postprocessing.depthOfField.focalLength=20,s.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((r,s)=>{Array.isArray(Ns(s.events))!==!1&&s.events?.forEach(n=>{let a=n.runMode;n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="Collision"||n.type==="Trigger"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):n.type==="MouseHover"||n.type==="MousePress"||n.type==="KeyPress"?n.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):n.type==="GameControl"?(delete n.actions,Object.keys(n.gameActions).forEach(o=>{n.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):n.type==="DragDrop"?(delete n.actions,n.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),n.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):n.type==="Resize"?(delete n.actions,n.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):n.type==="Start"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="VariableChange"||n.type==="Scroll"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="Conditional"&&(delete n.actions,n.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),n.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(t),t.schema=113),e<114&&(t.scene.publish.settings.web.imageQuality===void 0&&(t.scene.publish.settings.web.imageQuality=70),t.schema=114),e<115&&(function(i){i.shared.userAPIs=$a({},ke.prototype),i.shared.userWebhooks=$a({},ke.prototype),i.shared.lib&&(i.shared.lib.userAPIs=cc.defaultData().userAPIs,i.shared.lib.userWebhooks=cc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=xc.defaultData.settings.videoStatic)}(t),t.schema=116),e<117&&(t.scene.publish.settings.web.pixelRatioMobile===void 0&&(t.scene.publish.settings.web.pixelRatioMobile=0),t.scene.publish.settings.web.pixelRatioDesktop===void 0&&(t.scene.publish.settings.web.pixelRatioDesktop=0),t.schema=117),e<118&&(t.shared.timelineAnimations=$a({},ke.prototype),t.scene.objects.traverse((i,r)=>{wgt(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=fv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=fv.defaultData.scene.publish.settings.videoStatic.imageFormat,t.schema=119),e<120&&(t.scene.publish.settings.image.colorSpace="display-p3",t.scene.publish.settings.videoStatic.colorSpace="display-p3",t.schema=120),e<121&&(t.scene.objects.traverse((i,r)=>{ZU(r),r.type==="Page"&&r.camera!==void 0&&ZU(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=fv.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=Qp.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(typeof s.exposure=="number"&&(s.exposure=Math.round(s.exposure/5e-4*1e4)/1e4),s.lighting===void 0&&(s.lighting=Qp.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingIntensity===void 0&&(s.lightingIntensity=Qp.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(s.mode===void 0&&(s.mode="physical"),s.hdri===void 0?s.hdri={...Qp.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=Qp.defaultData.hdri.blur),Array.isArray(s.hdri.rotation)&&(s.hdri.rotation=s.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s?.hdri!==void 0&&s.hdri.showBackground===void 0&&(s.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingQuality===void 0&&(s.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=Hg.defaultData.camera);let s=r.camera;s.far=1e5,s.perspective?s.perspective.near=70:s.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(YU(t,JG),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.states;if(!n)return;let a=s.timelineAnimations,o=[];n.forEach((l,h)=>{(l.isAnimation||a?.[h])&&o.push(h)}),o.forEach(l=>n.delete(l))})}(t),function(i){let r=i.shared,s=r.timelineAnimations;if(!s)return;let n=i.scene.objects,a=n.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(s)){let h=$a({},ke.prototype),u=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(u=Math.max(u,g.to??0),d=d||Boolean(g.loop),h[m]={id:m,keyframes:I3t(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=$a({},ke.prototype)))[o]={id:o,name:l.name,duration:u||5,...d?{loop:d}:{},objectTimelines:h})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),aK(t,N3t),aK(t,V3t),t.schema=131),e<132&&(t.scene.objects.traverse((i,r)=>vgt(r)),t.schema=132),e<133){let i=function(s){return n=>s.get(n)?.data?.value}(t.shared.variables),r=new Map;t.scene.objects.traverse((s,n)=>{let a=n;if(a.type==="Page"&&a.timelines)for(let o of Object.values(a.timelines))for(let[l,h]of Object.entries(o.objectTimelines??{})){let u=r.get(l)??[];u.push(h.keyframes),r.set(l,u)}}),t.scene.objects.traverse((s,n)=>Sgt(n,i,r.get(s))),t.schema=133}e<134&&(t.scene.objects.traverse((i,r)=>bgt(r)),t.schema=134),e<135&&(YU(t,tW),t.schema=135)}}nT(ygt,{updateAllMaterials:()=>YU,updateDocumentSchema:()=>L3t,updateLibSchema:()=>z3t,updateMaterialSchema:()=>O3t,updateObjectStateRec:()=>Nu,updateObjectsSchema:()=>xgt,updateTextValues:()=>D3t});var Tgt,kp,Mgt,Agt,oK,kM,jI,lK,VM,Og,d_,W0,zM,GI,ZP,WI,qI,hK,QP,HI,$g,QU,sD=j(()=>{ht(),jft(),Ui(),YG(),v3t(),iD(),hT(),qo(),un(),XG(),eD(),WG(),uT(),Qft(),R3t(),Tgt=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),kp=180/Math.PI,Mgt=Math.PI/180,Agt=["position","rotation","scale","shape size"]}),F3t=j(()=>{var t,e,i;qo(),Ui(),un(),(oK||(oK={})).is=function(r){return!0},(t=kM||(kM={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}},t.diff=function(r,s){return sft({position:Hu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:Hu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&Hu.isEqual(r.shear,s.shear)?void 0:s.shear})},(jI||(jI={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(lK||(lK={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(VM||(VM={})).defaultData={opacity:1,fill:{color:Hi.fromHexAndA(i0,1),enabled:!0},stroke:{color:Hi.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Hi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Hi.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=Og||(Og={})).newEmpty=function(r,s){return{name:s}},e.patch=function(r,s){if(s===void 0)return r;let n={...r};return Object.assign(n,kM.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},h=["width","height","cornerRadius"];for(let u of h)u in l&&u in o&&o[u]!==void 0&&Object.assign(l,{[u]:o[u]});return l}(n,s),n=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(n,s),n},e.toOps=function(r,s){let n,a=[];for(let[o,l]of Object.entries(s))o!=="name"&&(n===void 0&&(n={path:[],props:{},type:0},a.push(n)),n.props[o]=l);return a},(d_||(d_={})).defaultData={...kM.defaultData,...jI.defaultData,states:new ce,events:new ce,visible:!0,raycastLock:!1},(W0||(W0={})).defaultData={...d_.defaultData,...VM.defaultData},(zM||(zM={})).defaultData={cornerRadius:[0,0,0,0]},(GI||(GI={})).defaultData={...W0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(ZP||(ZP={})).defaultData={...W0.defaultData,...zM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(WI||(WI={})).defaultData={...W0.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(qI||(qI={})).defaultData={...W0.defaultData,type:"path2d",path:"",name:"Path"},(hK||(hK={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(QP||(QP={})).defaultData={...d_.defaultData,name:"Group",type:"group2d"},(HI||(HI={})).defaultData=()=>({...d_.defaultData,...zM.defaultData,...VM.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Hi.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Hi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(s){switch(s){case"rectangle2d":case"vector2d":return{...ZP.defaultData};case"ellipse2d":return{...GI.defaultData};case"text2d":return{...WI.defaultData};case"path2d":return{...qI.defaultData};case"frame2d":return{...HI.defaultData()};case"group2d":return{...QP.defaultData}}},r.getPivot=function(s){return"width"in s&&"height"in s?[typeof s.width=="number"?.5*s.width:0,typeof s.height=="number"?.5*s.height:0]:[0,0]},r.isResizeable=function(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"},r.isAutoLayoutable=function(s){return s.type==="frame2d"&&s.autoLayout!==void 0},r.hasCorners=function(s){return s.type==="rectangle2d"||s.type==="frame2d"}})($g||($g={})),(i=QU||(QU={})).defaultData={name:"UI",type:"scene2d",objects:new Nn},i.emptyData=function(){return{type:"scene2d",objects:new Nn}}}),Cgt=j(()=>{d3t(),c3t(),Cft(),Eft(),jft(),Tft(),Ift(),Nft(),Vft(),WG(),sD(),Uft(),GG(),jG(),Pft(),hT(),Oft(),Lft(),qo(),iD(),eD(),Qft(),HG(),kft(),XG(),$G(),m3t(),Bft(),KG(),qG(),Rft(),Dft(),F3t()});function Ig(t,e=!1){let i=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),n={},a={},o=t[0].morphTargetsRelative,l=new ye,h=0;for(let u=0;u<t.length;++u){let d=t[u],c=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.attributes[p]),c++}if(c!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(d.morphAttributes[p])}if(e){let p;if(i)p=d.index.count;else{if(d.attributes.position===void 0)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;p=d.attributes.position.count}l.addGroup(h,p,u),h+=p}}if(i){let u=0,d=[];for(let c=0;c<t.length;++c){let p=t[c].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+u);u+=t[c].attributes.position.count}l.setIndex(d)}for(let u in n){let d=uK(n[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,d)}for(let u in a){let d=a[u][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[u].length;++f)p.push(a[u][f][c]);let m=uK(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(m)}}}return l}function uK(t){let e,i,r,s=-1,n=0;for(let h=0;h<t.length;++h){let u=t[h];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=u.itemSize),i!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=u.count*i}let a=new e(n),o=new _e(a,i,r),l=0;for(let h=0;h<t.length;++h){let u=t[h];if(u.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=u.count;c<p;c++)for(let m=0;m<i;m++){let f=u.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(u.array,l);l+=u.count*i}return s!==void 0&&(o.gpuType=s),o}var dT=j(()=>{ht()});function Egt(t){let e=t.points.length/7,i=new ce;for(let r=0;r<e;r++){let s=7*r,n=t.points[s+0],a=t.points[s+1],o=t.points[s+2],l=t.points[s+3],h=t.points[s+4],u=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:Ft.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[h,u]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>Egt(r))??[]}}function Pgt(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:h}=a,u=h?.groups,d=h?.attributes??{},c=h?.morphAttributes??{},p=h?.interleavedBuffers,m=h?.arrayBuffers,f=h?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(y){let v=1/0,b=1/0,_=1/0,x=-1/0,S=-1/0,w=-1/0;for(let T=0;T<y.length;T+=3){let C=y[T],M=y[T+1],A=y[T+2];v=Math.min(v,C),b=Math.min(b,M),_=Math.min(_,A),x=Math.max(x,C),S=Math.max(S,M),w=Math.max(w,A)}return{width:x-v,height:S-b,depth:w-_}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:m},...o===void 0?{}:o,type:"NonParametricGeometry"};return f!==void 0&&Object.assign(g.data,{index:f}),u!==void 0&&Object.assign(g.data,{groups:u.map(y=>({...y,materialIndex:y.materialIndex??0}))}),g}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let h=new ye;if(o?.position===void 0||o?.faceMap===void 0)return null;let u=o.position.array,d=o.faceMap.array,c=r.data.index.array;h.setAttribute("position",new ge(u,3)),h.setIndex(new fm(c,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let b={},_=y.getIndex(),x=y.getAttribute("position"),S=_?_.count:x.count,w=0,T=Object.keys(y.attributes),C={},M={},A=[],R=["getX","getY","getZ","getW"],I=["setX","setY","setZ","setW"];for(let L=0,H=T.length;L<H;L++){let W=T[L],X=y.attributes[W];C[W]=new X.constructor(new X.array.constructor(X.count*X.itemSize),X.itemSize,X.normalized);let nt=y.morphAttributes[W];nt&&(M[W]||(M[W]=[]),nt.forEach((st,yt)=>{let pt=new st.array.constructor(st.count*st.itemSize);M[W][yt]=new st.constructor(pt,st.itemSize,st.normalized)}))}let O=.5*v,B=Math.log10(1/v),V=Math.pow(10,B),z=O*V;for(let L=0;L<S;L++){let H=_?_.getX(L):L,W="";for(let X=0,nt=T.length;X<nt;X++){let st=T[X],yt=y.getAttribute(st),pt=yt.itemSize;for(let Q=0;Q<pt;Q++)W+=~~(yt[R[Q]](H)*V+z)+","}if(W in b)A.push(b[W]);else{for(let X=0,nt=T.length;X<nt;X++){let st=T[X],yt=y.getAttribute(st),pt=y.morphAttributes[st],Q=yt.itemSize,ut=C[st],wt=M[st];for(let St=0;St<Q;St++){let Tt=R[St],vt=I[St];if(ut[vt](w,yt[Tt](H)),pt)for(let It=0,Ut=pt.length;It<Ut;It++)wt[It][vt](w,pt[It][Tt](H))}}b[W]=w,A.push(w),w++}}let k=y.clone();for(let L in y.attributes){let H=C[L];if(k.setAttribute(L,new H.constructor(H.array.slice(0,w*H.itemSize),H.itemSize,H.normalized)),L in M)for(let W=0;W<M[L].length;W++){let X=M[L][W];k.morphAttributes[L][W]=new X.constructor(X.array.slice(0,w*X.itemSize),X.itemSize,X.normalized)}}return k.setIndex(A),k}(h),m=[],f=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let y=0,v=d.length;y<v;)d[y]===d[y+1]?(f[d[y]]++,m.push(...new Set(g.slice(3*y,3*y+6))),y+=2):(m.push(...g.slice(3*y,3*y+3)),y++);o.indexWASM={array:m},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:f}}if(o?.positionWASM===void 0||o?.positionWASM.length===0||o?.indexWASM===void 0||o?.indexWASM.length===0||o?.verticesPerFaceWASM===void 0||o?.verticesPerFaceWASM.length===0)return null;let l={type:a,...U3t(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let h in o)h==="positionWASM"?l[h]=new Float32Array(o[h].array):h==="indexWASM"?l[h]=new Int32Array(o[h].array):h==="verticesPerFaceWASM"&&(l[h]=new Int8Array(o[h].array));return l.scaleBaked=[1,1,1],l}let s=e.type,n=e.parameters;return s==="VectorGeometry"?(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,width:100,height:100,shape:Egt(e.shape),type:s}):s==="LatheGeometry"?{...e.parameters,type:s,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,type:s})}function U3t(t){return JU.setFromArray(t),JU.getSize(a2),{width:a2.x,height:a2.y,depth:a2.z}}var JU,a2,$I,j3t=j(()=>{Ui(),ht(),dT(),new xt,new Te,new Fi,new P,new P,JU=new cr,a2=new P}),G3t=j(()=>{var t;(t=$I||{}).view="view",t.edit="edit",(($I=t)||($I={})).canWrite=function(e){return e!=="view"},class extends Error{constructor(e,i){super(`This is a ${e.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=e,this.expected=i,this.name="DocumentKindMismatchError"}}}),Rgt,tj,JP,Dgt,Ogt,Jv,c_,LM,XI,tb,dK,YI,cK,KI,zv,Kc,Zc,cd,ZI,pK,mK,QI,ej,Sc,Igt=j(()=>{G3t()}),W3t=j(()=>{}),q3t=j(()=>{Ui(),sD(),Igt()}),H3t=j(()=>{hT(),[...tD],new Set(FG)}),Be=j(()=>{Cgt(),W3t(),y3t(),sD(),q3t(),Igt(),YG(),H3t(),KG(),Ui()}),nD=j(()=>{Rgt=[3,4,8,9],tj=5,JP=3,Dgt=32,Ogt=.98}),cT=j(()=>{ht(),Jv=t=>{var e;return(e=class extends t{}).geometryHelper=new Zh(30,30,30),e}}),pT=j(()=>{ht(),c_=new gc,LM=new Jn,XI=new xt,tb=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),LM.copy(a.boundingSphere),LM.applyMatrix4(o),i.ray.intersectsSphere(LM)===!1||(XI.copy(o).invert(),c_.copy(i.ray).applyMatrix4(XI),a.boundingBox!==null&&c_.intersectsBox(a.boundingBox)===!1))return;let l,h,u,d,c,p,m=a.index,f=a.attributes.position,g=a.drawRange;if(s===!1){for(c=Math.max(0,g.start),p=Math.min(m.count,g.start+g.count);c<p;c+=3)if(h=m.getX(c),u=m.getX(c+1),d=m.getX(c+2),l=y(t,i,c_,f,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new P,_=new P,x=new P,S=new P,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T;for(let M=Math.max(0,g.start),A=Math.min(v.count,g.start+g.count)-1;M<A;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),c_.distanceSqToSegment(b,_,S,x)>C)continue;S.applyMatrix4(n.matrixWorld);let R=i.ray.origin.distanceTo(S);R<i.near||R>i.far||r.push({distance:R,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let C=new P,M=new P,A=new P,R=new P,I=new P;if(C.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),A.fromBufferAttribute(x,T),_.intersectTriangle(C,M,A,!1,R)===null)return null;I.copy(R),I.applyMatrix4(v.matrixWorld);let O=b.ray.origin.distanceTo(I);return O<b.near||O>b.far?null:{faceIndex:1,distance:O,point:I.clone(),object:v}}}}),aD=j(()=>{ht(),cT(),pT(),dK=new P(1,1,1),YI=new P,cK=new P,KI=new Te,zv=class extends Jv(Kmt){constructor(t,e=15){super(e),this.object=t,this.dummy=new Qv,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,e){tb(this.object,zv.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(YI,KI,cK),this.matrix.compose(YI,KI,dK),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),$3t=j(()=>{ht(),Kc=new P,Zc=new P,cd=new xt,ZI=[new P(-1,1,1),new P(-1,-1,1),new P(1,-1,1),new P(1,1,1),new P(-1,1,-1),new P(-1,-1,-1),new P(1,-1,-1),new P(1,1,-1)],pK=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],mK=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],QI=(t,e,i)=>{t.updateEntityBoxSize(Kc,Zc),cd.copy(e).multiply(t.matrixWorld),Zc.x===0&&Zc.y===0&&Zc.z===0?i.push(new P(Kc.x,Kc.y,Kc.z).applyMatrix4(cd)):ZI.forEach(r=>{i.push(r.clone().multiply(Zc).add(Kc).applyMatrix4(cd))})},ej=class extends cr{constructor(){super(...arguments),this.matrix=new xt,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(e=>e.clone()),this.faces=t.faces.map(e=>e.clone()),this.edges=t.edges.map(e=>e.clone()),this.centerEdges=t.centerEdges.map(e=>e.clone()),this}setFromObjectSize(t,e=!1){t.updateWorldMatrix(!1,e),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new xt().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let r=[];if(i===!0){let s=[];t.traverseEntity(n=>{if(n.visible||n.cloner&&n.data.visible){if(!("geometry"in n))return cd.copy(e).multiply(n.matrixWorld),void s.push(new P().applyMatrix4(cd));QI(n,e,r)}}),r.length===0&&r.push(...s)}else QI(t,e,r);return this.setFromPoints(r)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(cd.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Zc).multiplyScalar(.5),this.getCenter(Kc),cd.copy(this.matrix).setPosition(Kc),this.vertices=ZI.map(t=>t.clone().multiply(Zc).applyMatrix4(cd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=pK.map(([t,e])=>new bl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=mK.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),W4=j(()=>{Sc={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function nS(t){return t?.isParticleSystem===!0}function n0(t){return t?.isHairSystem===!0}function Ic(t){return t?.isShapeBlendEntity===!0}function oD(t){return t?.isPathObject===!0}function Go(t){return t?.isObject2D===!0}function Ya(t){return t?.isUIObject===!0}function om(t){return t?.isCloner===!0}function lm(t){return t?.isClone===!0}function tR(t){return t?.isComponentObject===!0}var ts=j(()=>{});function Nr(t){eW.add(t)}function On(t,e){let i=`${t}:${e}`;sj.has(i)||sj.add(i)}function q4(t,e){iW.set(t,e)}function JI(t){return iW.get(t)}function eb(t,e){rW.set(t,e)}function tN(t){return rW.get(t)}function ij(t,e){sW.set(t,e)}function Ngt(t){return sW.get(t)}function rj(){return lD}var eW,sj,iW,rW,sW,lD,H4,Ni=j(()=>{eW=new Set,sj=new Set,iW=new Map,rW=new Map,sW=new Map,lD=null,H4=null});function Bgt(t,e,i,r,s=new xt){return s.compose(t,e,kgt).multiply(i).scale(r)}var kgt,eN,Ng,hD,ib=j(()=>{ht(),rD(),kgt=new P(1,1,1),eN=new xt,(Ng||(Ng={})).is=function(t){return t&&t.__isSPEObject},hD=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new xt,this.copyPreviousMatrix=!0,this.pivotMatrix=new xt,this.matrixWorldRigid=new xt,this.shearScale=new xt,this.shearScaleInv=new xt,this.shearMatrix=new xt}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(eN.copy(this.parent.matrixWorld).invert()),e.multiply(eN.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof ur&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrix(){!this.shearMatrix||(Bgt(this.position,this.quaternion,this.shearMatrix,this.scale,this.matrix),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let i of this.children)i.updateMatrixWorld(e)}updateWorldMatrix(e,i){let r=this.parent;if(e&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.multiply(this.pivotMatrix),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let r of this.children)Ng.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Ng.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=Hft(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,i){this.updateWorldMatrix(!0,!1);let r=new xt().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),r.multiply(e.parent.matrixWorld)),e.applyMatrix4(r),e.updateWorldMatrix(!1,!1),this.add(e),i!==void 0&&(this.children.pop(),this.children.splice(i,0,e)),this}copy(e,i=!1){return super.copy(e,i),this}onAfterRender(e,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function fK(t,e,i){return Jp.subVectors(e,t),GS.subVectors(e,i),Jp.cross(GS).length()<=aS}function Vgt(t){let e=oj.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(r){let s=r.points,n=[s[0]],a=[new P(...s[0].data.position)];cg.copy(a[0]);for(let y=0;y<s.length-1;y++)Jp.fromArray(s[y].data.position),GS.fromArray(s[y+1].data.position),E1.subVectors(Jp,cg),P1.subVectors(Jp,GS),E1.cross(P1).length()>aS&&(n.push(s[y]),a.push(new P().copy(Jp)),cg.copy(Jp));let o=s[s.length-1];n.push(o),a.push(new P(...o.data.position));let l=r.isClosed,h=n.length-(l?0:1),u=n.length,d=[],c=[];for(let y=0;y<u;y++){let v=n[y].data;d.push(new P(...v.controlPrevious.position)),c.push(new P(...v.controlNext.position))}let p=[];for(let y=0;y<h;y++){let v=y===u-1?0:y+1;p.push(fK(a[y],c[y],a[v])&&fK(a[y],d[v],a[v]))}let m=[];for(let y=0;y<u;y++){let v=n[y].data,b=a[y],_={position:b,prevDir:void 0,nextDir:void 0,controlPrevious:d[y],controlNext:c[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(m.push(_),v.roundness===0||!l&&(y===0||y===u-1))continue;let x=l&&y==0?u-1:y-1,S=l&&y==u-1?0:y+1,w=new P().subVectors(a[x],b).normalize(),T=new P().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let C=p[l&&y===0?u-1:y-1],M=p[y];if(C&&M){pg.addVectors(w,T).normalize();let A=cg.crossVectors(pg,w).length()/w.dot(pg);_.tan=A,_.removedLength=v.roundness/A}}for(let y=0;y<h;y++){let v=l&&y===u-1?0:y+1,b=m[y],_=m[v];if(b.removedLength!==0||_.removedLength!==0){let x=b.position.distanceTo(_.position);b.removedLength=Math.min(b.removedLength,x/2),_.removedLength=Math.min(_.removedLength,x/2)}}let f=new Array(2*u).fill(null);for(let y=0;y<h;y++){let v=l&&y===u-1?0:y+1,b=m[y],_=m[v],x=null;if(p[y]){let S=b.position.clone(),w=_.position.clone();(b.removedLength!==0||_.removedLength!==0)&&(b.nextDir&&S.add(cg.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(cg.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>aS&&(x=new Z2(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>aS&&(x=new Z2(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<u;y++){let v=m[y];if(v.removedLength===0)continue;let b=v.position,_=v.prevDir.clone().multiplyScalar(v.removedLength).add(b),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(b),S=v.tan*v.removedLength;pg.addVectors(v.prevDir,v.nextDir).normalize(),E1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;aj.copy(pg).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(E1),eR.copy(pg).multiplyScalar(-S).add(aj);let T=b.distanceTo(eR)/b.distanceTo(E1);P1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),nj.copy(P1).lerp(eR,2);let C=_.clone().lerp(P1,4/3),M=x.clone().lerp(nj,4/3);f[2*y]=new Z2(_,C,M,x)}let g=new zgt;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return oj.set(t.points,{isClosed:t.isClosed,curve:i}),i}var zgt,aS,Jp,GS,cg,pg,E1,eR,P1,nj,aj,oj,R1,lj,iR,Lgt,Fgt,Ugt,xi,Vu,gK,yK,p_,iN,FM,rN,sN,uD,hj,h0,Lu,jgt=j(()=>{ht(),zgt=class extends tU{constructor(){super()}getPoints(t=12){let e,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(t*l/s),u=o.getPoints(h);for(let d=0;d<u.length;d++){let c=u[d];e&&e.equals(c)||(i.push(c),e=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},aS=.001,Jp=new P,GS=new P,cg=new P,pg=new P,E1=new P,eR=new P,P1=new P,nj=new P,aj=new P,oj=new WeakMap}),X3t=j(()=>{ht(),R1=new xt,lj=new Te,iR=new Te,Lgt=new Fi,Fgt=new P,Ugt=new P(0,1,0)}),bo=j(()=>{ht(),Be(),$3t(),Ui(),W4(),ts(),Ni(),ib(),jgt(),X3t(),ir(),(xi||(xi={})).is=function(t){return t&&t.__isEntity},Vu=t=>xi.is(t),gK={type:"completeState",isfromEntity:!0},yK=["x","y","z"],p_=new P,iN=new P(1,1,1),FM=new Te,rN=new Fi,sN=new xt,uD=t=>class extends hD(t){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.transitionState={settled:!0,state:null},this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new ej,this._recursiveBBox=new ej,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let i=this.children[e];if(xi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(xi.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let e=this;for(;e.data.type!=="Instance";){let i=e.parent;if(!xi.is(i))return;e=i}return e}forInstancesRec(e){this.instances.forEach(i=>{i.disposed||e(i),i.forInstancesRec(e)})}super_Entity(e,i){typeof e=="string"&&(this.uuid=e),this.identity=e,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,i,r=!1){if(this.data.states.length!==0||r){for(let s of this.data.states)am.toOps(this.data,s.data).forEach(n=>{let a=b4.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let s=this.data.states.data(e);s&&(this.dataPatched=am.patch(this.data,s),am.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,i){e.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{Vu(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(r=>{r.uuid===e&&(i=r)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,r=i.indexOf(this)+1;if(xi.is(i[r]))return i[r];if(xi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&xi.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let i=this;for(;e>0&&i!==null;)i=i.parent,e-=1;return i}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let i=this.parent;for(;i;){if(e===i)return!0;i=i.parent}return!1}countToAccestor(e){let i=0,r=this;for(;r!==e;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Vu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{xi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Vu(i)&&i.visible&&i.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,i=!1){return super.copy(e,i),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this}hasEntityChild(){return this.children.some(e=>Vu(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),fU({position:this.position.toArray(),rotation:[this.rotation.x*Ft.RAD2DEG,this.rotation.y*Ft.RAD2DEG,this.rotation.z*Ft.RAD2DEG],scale:this.scale.toArray(),shear:wl.fromMatrix(this.shearMatrix.toArray()),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,r){return i[e].map((s,n)=>r?.shared.getVariable(s,[this.uuid,e,yK[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(p_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(Ft.DEG2RAD),this.rotation.setFromVector3(p_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.shear&&(this.shearMatrix.fromArray(wl.toMatrix(e.shear)),r=!0),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(p_.fromArray(e.pivot).negate(),FM.setFromEuler(rN.fromArray(e.pivotRotation.map(s=>s*Ft.DEG2RAD))).invert(),iN);else if(e.pivot!==void 0)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(e.pivotRotation!==void 0){let s=p_.setFromMatrixPosition(this.pivotMatrix);FM.setFromEuler(rN.fromArray(e.pivotRotation.map(n=>n*Ft.DEG2RAD))).invert(),this.pivotMatrix.compose(s,FM,iN)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)xi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{xi.is(e)&&e.disposeRecursively()})}toState(e=[]){return fU({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,i){e!==void 0&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},i,!1)}updateByOp(e,i,r,s){let n=this.data;this.data=i;let a=e,o=er(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let h={...e.props};if(delete h.name,Object.values(e.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let d=Dn.zoom(u,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(h[c]=d[c])}}a={...e,props:h,path:e.path.slice(2)}}}}else if(e.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(e.props.name!==void 0&&l.name){let{name:u,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:u,...d}=l;l=d}let h=Dn.removeOverridden(e.path,e.props,l);a={...e,props:h}}}if(this.updateByPatchedOpBase(a,am.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),er(e.path,["overrides"])){let l=[],h=[...e.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let u of Object.keys(e.props)){l[l.length-1]=u;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[u],d.updateState(gm.apply(d.component.data,d.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let d=Dn.zoom(u.component.data,h);if((e={...e,path:h}).type===0){let c=e.props;if(d)for(let[p,m]of Object.entries(e.props))m===void 0&&(c===e.props&&(c={...e.props}),c[p]=d[p]);e={...e,props:c}}u.overrideData=F4.resolve(i.overrides,l),u.updateByOp(e,ta.applySimple(u.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let h;for(let u of _c.rootOverrideProps)u in e.props&&(h===void 0&&(h={}),h[u]=e.props[u]);h&&(l={...e,props:h})}else for(let h of _c.rootOverrideProps)if(er(e.path,[h])){l=e;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=gm.filterOp(h.overrideData,l);u&&h.updateByOp(u,ta.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=gm.filterOp(h.overrideData,e);if(u){let d;d=n===h.data&&e===u?i:ta.applySimple(h.data,u),h.updateByOp(u,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!r0.is(e.props.type)&&Sc.changeEntityProptotype(this,this.data,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){Sc.changeEntityProptotype(this,this.data,r);for(let s of this.children)xi.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(e,i,r)}updateByPatchedOp(e,i,r){if(e.path.length===0&&e.type===0?this.updateState(e.props,r):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,r),e.path[0]==="morphTargetInfluences"&&e.type===0){let s=i.morphTargetInfluences.get(e.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",s]))}if(er(e.path,["pathSnapping"])!==null&&(this.updatePathSnapping(i.pathSnapping),this.isVirtualEntity&&r.scene?.syncInstancePathConstraint(this)),er(e.path,["cloner"])!==null){let s=ta.drop(e,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=e.find(this.isVirtualEntity&&e.pathConstraints.getConstraint(this.uuid)||i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=Vgt(o.geometry.path),h=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),u=null;try{u=l.curves.length?l.getPointAt(h):null}catch{}if(u===null)return;a.updateMatrixWorld();let d=this.parent?sN.copy(this.parent.matrixWorld):sN.identity(),c=function(p,m,f,g){lj.setFromRotationMatrix(R1.extractRotation(g));let y=p.clone().applyMatrix4(R1.copy(g).invert().multiply(f));if(m===null)iR.setFromRotationMatrix(R1.extractRotation(f));else{let v=m.clone().applyMatrix4(R1.extractRotation(f));iR.setFromRotationMatrix(R1.lookAt(Fgt.set(0,0,0),v,Ugt))}return{position:y,rotation:new P().setFromEuler(Lgt.setFromQuaternion(lj.invert().multiply(iR))).multiplyScalar(Ft.RAD2DEG)}}(u,n==="tangential"?l.getTangentAt(h):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(gK)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!e)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&e.reloadSplats()}updateState_Entity(e,i){e.name!==void 0&&(this.name=e.name),e.raycastLock!==void 0&&(this.raycastLock=e.raycastLock),e.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in e&&e.cloner!==void 0&&(this.setFromClonerState(e.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(e,i)}get attachedSurfaceCloners(){return this.children.filter(e=>om(e)&&e.parameters.type==="toObject")}setFromClonerState(e,i){if(!this.disposed)if(e===null||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Sc.Cloner===null)return void On("cloners","a cloner");this.cloner=new Sc.Cloner(this,e),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,i)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),u0=j(()=>{ht(),bo(),(hj||(hj={})).is=t=>"objectHelper"in t,h0=(t,e)=>class extends uD(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof kS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Zh?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof kS&&(r.visible=!1)}}}}),dD=j(()=>{ht(),aD(),u0(),Lu=class extends h0(Qv,zv){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}}});function ch(t,e,i,r,s,n,a){o2.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],o2.x,o2.y,o2.z)}}var o2,Ko,vK,Ggt,Y3t=j(()=>{ht(),cT(),pT(),o2=new P,Ko=new Eg,vK=class extends S1{constructor(t){let e=new ye,i=new Lh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new ae(15711266),o=new ae(15711266),l=new ae(2857471);function h(d,c,p){u(d,p),u(c,p)}function u(d,c){r.push(0,0,0),s.push(c.r,c.g,c.b),n[d]===void 0&&(n[d]=[]),n[d].push(r.length/3-1)}h("n1","n2",a),h("n2","n4",a),h("n4","n3",a),h("n3","n1",a),h("f1","f2",a),h("f2","f4",a),h("f4","f3",a),h("f3","f1",a),h("n1","f1",a),h("n2","f2",a),h("n3","f3",a),h("n4","f4",a),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),e.setAttribute("position",new ge(r,3)),e.setAttribute("color",new ge(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update()}update(){let t=this.geometry,e=this.pointMap;Ko.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;ch("n1",e,t,Ko,-1,-1,i),ch("n2",e,t,Ko,1,-1,i),ch("n3",e,t,Ko,-1,1,i),ch("n4",e,t,Ko,1,1,i);let r=i;ch("f1",e,t,Ko,-1,-1,r),ch("f2",e,t,Ko,1,-1,r),ch("f3",e,t,Ko,-1,1,r),ch("f4",e,t,Ko,1,1,r);let s=r;ch("u1",e,t,Ko,.35,1.1,s),ch("u2",e,t,Ko,-.35,1.1,s),ch("u3",e,t,Ko,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},Ggt=class extends Jv(vK){constructor(t){super(t),this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,e){tb(this.object,this.geometry,t,e,!0)}}});function bK(t){return 1-Math.pow(1-t,3)}var lf,UM,jM,GM,q0,WM,uu,Us,Qh=j(()=>{ht(),Y3t(),Be(),u0(),ir(),lf=new P,UM=new P,jM=new Te,GM=new P,q0=new P,WM=new P,uu=class extends h0(Eg,Ggt){constructor(t="",e={...rS.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=bc.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let s=this._projectionTransition;if(s===void 0)return;if(this.disposed)return void this._endProjectionTransition();s.raf=requestAnimationFrame(this._tickProjectionTransition);let n=uu.projectionTransitionRequestRender??s.requestRender;this.updateProjectionMatrix(),n?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new xt,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Nv(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new zh(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(t){let e=uu.projectionTransitionsEnabled;uu.projectionTransitionsEnabled=!1;try{return t()}finally{uu.projectionTransitionsEnabled=e}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(t){this.perspCamera.fov=t}get fov(){return this.perspCamera.fov}setNear(t,e){t==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(t,e){e>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t,e,i){typeof t=="number"&&(t=new P(t,e,i)),super.lookAt(t),this.getWorldPosition(lf),this.targetOffset=lf.distanceTo(t)}getTarget(t=new P){return this.getWorldDirection(UM),this.getWorldPosition(lf),UM.multiplyScalar(this.targetOffset),t.copy(lf).add(UM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(lf),lf.distanceTo(t)}updateUp(){this.getWorldQuaternion(jM),GM.set(0,0,1).applyQuaternion(jM),q0.copy(ur.DEFAULT_UP),this.isUpVectorFlipped&&q0.negate(),q0.applyQuaternion(jM),WM.copy(ur.DEFAULT_UP).projectOnPlane(GM),this.angleOffsetFromUp=WM.angleTo(q0),this.angleOffsetFromUp*=WM.cross(q0).dot(GM)>=0?1:-1}updateTransformState(t,e){let i=super.updateTransformState(t,e);return t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(t){let e=t.getWorldPosition(new P),i=t.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new P;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let r=t>e?this.aspect:1,s=t>e?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/s*395,this.bottom=1/s*-395}else this.left=.5*-t,this.right=.5*t,this.top=.5*e,this.bottom=.5*-e;this.updateProjectionMatrix()}copyViewPlaneSize(t){this.aspect=t.aspect,this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let t=this._projectionTransition;if(t===void 0)return 1;let e=(performance.now()-t.start)/t.duration;return e>=1?1:e<=0?0:bK(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return uu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=uu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new xt,blend:new xt,blendInverse:new xt,start:0,duration:uu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=uu.projectionTransitionDuration,e.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,t&&(e.requestRender=t),e.raf!==0&&cancelAnimationFrame(e.raf),e.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;let e=(performance.now()-t.start)/t.duration;if(e>=1)return void this._endProjectionTransition();let i=bK(e),r=t.from.elements,s=this._activeSubCamera.projectionMatrix.elements,n=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*a));for(let h=0;h<16;h++)n[h]=r[h]+(s[h]-r[h])*l;t.blendInverse.copy(t.blend).invert(),this.projectionMatrix=t.blend,this.projectionMatrixInverse=t.blendInverse}_endProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;t.raf!==0&&cancelAnimationFrame(t.raf),this._projectionTransition=void 0;let e=this._activeSubCamera;this.projectionMatrix=e.projectionMatrix,this.projectionMatrixInverse=e.projectionMatrixInverse}_syncProjectionTransition(t){let e=t._projectionTransition;if(e===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new xt,blend:new xt,blendInverse:new xt,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(e.from),i.start=e.start,i.duration=e.duration,i.referenceDepth=e.referenceDepth,this._applyProjectionTransition()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,e,i,r,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,r,s,n):this.orthoCamera.setViewOffset(t,e,i,r,s,n),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,e){return super.copy(t,e),this.parent=t.parent,this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=bc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return fU({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},t)}updateCameraSubtype(t,e){let i=t==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(i,e.zoom),e.near!==void 0&&this.setNear(i,e.near),e.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(t,e){this.updateCameraState(t,e)}updateCameraState(t,e){this.updateState_Entity(t,e),t.far!==void 0&&(this.far=t.far),t.orthographic!==void 0&&this.updateCameraSubtype("orthographic",t.orthographic),t.perspective!==void 0&&this.updateCameraSubtype("perspective",t.perspective),t.type!==void 0&&(t.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(e?.shared.requestRender),this.cameraType=t.type),t.up!==void 0&&this.up.fromArray(t.up.map(i=>typeof i=="number"?i:0)),t.targetOffset!==void 0&&(this.targetOffset=bc.sanitizeTargetOffset(t.targetOffset)),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.type===0&&this.updateCameraSubtype(t.path[0],t.props)}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}},(Us=uu).projectionTransitionsEnabled=!1,Us.projectionTransitionDuration=350,Us.projectionTransitionMinAgeMs=1e3});function Wgt(t){return t.type==="TorusGeometry"&&t.arc===360}var qgt,qM,uj,WS=j(()=>{ht(),qgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(t){let{width:e,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:d}=t.parameters,c=new uj(!1,e,i,r,s,n,a,o,l,h,u,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},qM=new fm([0,0,0],1),uj=class extends ye{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),u>100&&(u=100),u===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new P,S=new P,w=x(),T=x(),C=x(),M=x(),A=x(),R=x(),I=x(),O=x(),B=x(),V=x(),z=x(),k=i-2*o+.001,L=k/n,H=Math.ceil(a*n),W=H+1,X=k/H,nt=-k/2,st=h+1,yt=2*Math.PI/h,pt=Math.PI/2/d,Q=Math.min((1-u/100)*o,o-.01),ut=o-Q,wt=0,St=2*d+2,Tt=st*St/2,vt=Tt+st*W,It=Math.max(0,st*(W+St)),[Ut,Bt,zt]=[3,3,2].map(Ve=>Array(It*Ve).fill(0)),kt=[],qt=s-o;function $t(Ve,ie){let oi=Math.PI/2;v=ie*X,_=2*Math.PI*(v%L)/L+oi,v+=nt,b=Math.sin(_)*qt,y=Math.cos(_)*qt,t?Ve.set(y,b,v):Ve.set(y,v,b)}$t(S,-1e-10),$t(w,0),M.copy(S),$t(S,1);let Pt=S.distanceTo(w),oe=c?0:ut+Q,Gt=Pt*H+2*oe,Zt=Q,Jt=Gt-oe;for(let Ve=0;Ve<=H;Ve++){$t(T,Ve),z.subVectors(T,M).normalize(),M.copy(T),B.copy(T).setComponent(+t+1,0).normalize(),V.crossVectors(z,B).normalize();let ie=Ve===0,oi=Ve===H,wi=ie?3*Math.PI/2:pt,Qs=ie?Zt:Jt,$i=ie?st:vt,li=ie?0:It-st,jr=z.clone().multiplyScalar(ie?-ut:ut).add(T),es=z.clone().multiplyScalar(ie?-1:1).normalize();for(let Gr=0;Gr<st;Gr++){let ji=Gr*yt;if(A.addVectors(S.copy(B).multiplyScalar(o*Math.cos(ji)),w.copy(V).multiplyScalar(o*Math.sin(ji))),R.copy(A).normalize(),ie||oi){c||(wt=li+Gr,[0,1,2].forEach(Ci=>{Ut[3*wt+Ci]=jr.getComponent(Ci),Bt[3*wt+Ci]=es.getComponent(Ci)}),zt[2*wt]=+oi,zt[2*wt+1]=Gr/h),w.copy(R).multiplyScalar(Q),C.addVectors(T,w);for(let Ci=0;Ci<d;Ci++){let Js=Ci*pt+wi;I.addVectors(S.copy(z).multiplyScalar(ut*Math.sin(Js)),w.copy(R).multiplyScalar(ut*Math.cos(Js))),O.copy(I).normalize(),w.addVectors(C,I),I.normalize(),wt=$i+Ci*st+Gr,[0,1,2].forEach(br=>{Ut[3*wt+br]=w.getComponent(br),Bt[3*wt+br]=O.getComponent(br)});let fs=+ie+Math.sin(Js);zt[2*wt]=(Qs+ut*fs)/Gt,zt[2*wt+1]=Gr/h}}w.addVectors(T,A),wt=Tt+Ve*st+Gr,[0,1,2].forEach(Ci=>{Ut[3*wt+Ci]=w.getComponent(Ci),Bt[3*wt+Ci]=R.getComponent(Ci)}),zt[2*wt]=(oe+Ve*Pt)/Gt,zt[2*wt+1]=Gr/h}}let $=W+2*d+2,[se,Pe]=[+c,$-1];for(let Ve=se;Ve<=Pe-1;Ve++){let ie=c&&Ve===Pe-1;for(let oi=0;oi<st-1;oi++)p=Ve*st+oi,m=p+1,f=(ie?oi:p)+st,g=(ie?oi+1:m)+st,Ve===0?kt.push(m,g,f):Ve===$-2?kt.push(p,m,f):kt.push(p,m,f,m,g,f)}this.setIndex(kt),this.setAttribute("position",new ge(Ut,3)),this.setAttribute("normal",new ge(Bt,3)),this.setAttribute("uv",new ge(zt,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,r,s=this.userData.parameters,n=Math.ceil(s.tubularSegments),a=s.radialSegments,o=a+1,l=[];for(let h=1;h<n;h++)for(let u=0;u<a;u++)t=h*o+u,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let h=0;h<a;h++)t=n*o+h,e=t+1,i=h+o,r=h+1+o,l.push(t,e,i,e,r,i);return qM.array=new Uint32Array(l),qM.count=l.length,qM}}});function K3t(t){return xK||(xK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.121/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),qS=r}())}function $4(){if(qS===void 0)throw new Error("boolean-wasm is not loaded");return qS}function nW(t){let e=HS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function aW(t){return HS.set(++dj,t),dj}function Z3t(t,e,i){if(qS===void 0)return-1;let{positions:r,indices:s,normals:n}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,m=[];for(let f=0,g=0;f<p.verticesPerFace.length;f++){let y=p.verticesPerFace[f];for(let v=1;v<y-1;v++)m.push(p.indices[g],p.indices[g+v],p.indices[g+v+1]);g+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(m)}}let l;l=Wgt(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let h,u=a.getAttribute("position");if(l===null){h=new Uint32Array(u.count);for(let p=0;p<h.length;p++)h[p]=p}else h=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===u.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:u.array,indices:h,normals:c}}(t,e);return aW(new qS.CsgMesh(r,s,n))}function _K(t,e){let i=$4(),r=$gt[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(nW);if(s.length===1)return i.clone_mesh(s[0]);let n,a=[];if(e===2&&s.length>2){let o=s[0];for(let l=1;l<s.length-1;l++)o=i.boolean_mesh(o,s[l],0),a.push(o);n=i.boolean_mesh(s[s.length-1],o,2)}else if(e===2)n=i.boolean_mesh(s[1],s[0],2);else{let o=s[s.length-1];for(let l=0;l<s.length-1&&(o=i.boolean_mesh(o,s[l],r),a.push(o),o.tri_count()!==0);l++);n=o,a.pop()}for(let o of a)o.free();return n}function nN(t,e){nW(t).transform(new Float32Array(e.elements))}function Hgt(t){let e=HS.get(t);e!==void 0&&(e.free(),HS.delete(t))}var qS,HS,dj,xK,$gt,cD=j(()=>{ht(),WS(),HS=new Map,dj=0,$gt={0:0,1:1,2:2}});function hf(t){return t!==null&&"booleanOp"in t}var cj,Xgt,Q3t=j(()=>{ht(),bo(),cD(),cj=class extends uD(yr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new xt}updateVisible(t){super.updateVisible(t),this.visible=!hf(this.parent)&&this.visible,hf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){hf(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hgt(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}dispose(){super.dispose(),this.freeBooleanPointer()}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),hf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof cj&&(t.freeBooleanPointer(),hf(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&hf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),hf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),J3t=j(()=>{Xgt=null});function oW(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let d=e;d<i;d++){let c=t.getX(d),p=t.getY(d),m=t.getZ(d);c<n&&(n=c),p<a&&(a=p),m<o&&(o=m),c>l&&(l=c),p>h&&(h=p),m>u&&(u=m)}l2.min.set(n,a,o),l2.max.set(l,h,u),l2.getCenter(r),l2.getSize(s).multiplyScalar(.5)}var l2,wK,SK,Fs,oa=j(()=>{ht(),Q3t(),J3t(),l2=new cr,wK=new ye,SK=new jo,Fs=class extends cj{constructor(t,e){super(wK,SK),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){if(this.raycastDeformed(t,e))return;let i=Xgt;i===null?super.raycast(t,e):i(this,t,e)}raycastDeformed(t,e){return!1}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?oW(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function Ygt(t){return t?.isClassicNodeMaterial===!0}var Dr,pj,Kgt,Zgt,oS,Qgt,Jgt,t0t,e0t=j(()=>{}),kc=j(()=>{ht(),Dr=class extends ae{constructor(t,e,i,r){super(t,e,i),this.isColorA=!0,this.a=r}setRGBA(t,e,i,r){super.setRGB(t,e,i),this.a=r}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(t){return super.equals(t)&&this.a===t.a}setStyle(t,e="srgb"){let i;if(t==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(t)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(t,e)}}return super.setStyle(t,e)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}}}),tCt=j(()=>{kc(),pj=class extends Dr{}}),eCt=j(()=>{Kgt=class{constructor(t=1e4){this.timeout=t,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let i=e;e=e.next,e.prev=this.head,this.head.next=e,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),i=this.cache.get(t);return i===void 0?(i={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,i)):(i.time=e,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),i0t=j(()=>{eCt(),Zgt=class extends Kgt{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),r0t=j(()=>{Qgt=class{constructor(t,e){this.data=t,this.cache=e,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Jgt=class{constructor(){this.cache=new Map}remove(t){this.cache.delete(t.data)}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}}}),iCt=j(()=>{ht(),t0t=class extends Umt{constructor(t){super(t),this.type=ai}parse(t){let e=function(p,m){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},i=function(p,m,f){m=m||1024;let g=p.pos,y=-1,v=0,b="",_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(y=_.indexOf(`
361
+ })();`});function PM(t){return t==null||t===""?void 0:String(t)}var DG,eft=j(()=>{DG=class{constructor(t,e,i){this.deps=t,this.onConsole=e,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let t of this.eventUnsubs.values())t();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(t,e){let i=this.deps;switch(t){case"setVariable":{let r=i.setVariable(String(e[0]),e[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=e[0]??{},s=!0;for(let[n,a]of Object.entries(r)){let o=i.setVariable(n,a);o.warning&&this.onConsole("warn",o.warning),s=s&&o.ok}return s}case"getVariable":return i.getVariable(String(e[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(e[0]));case"getGeometry":{let r=i.getGeometry(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(e[0]),e[1]??{});case"createObject":return i.createObject(String(e[0]),e[1]??{});case"createCustomMaterial":if(i.createCustomMaterial===void 0)throw new Error("createCustomMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(e[0]);case"getTexture":if(i.getTexture===void 0)throw new Error("getTexture: not available on this surface \u2014 a three.js texture instance needs the inline HTML-content mode (editor Preview/Play and web exports).");return i.getTexture(String(e[0]),e[1]??{});case"setMaterial":if(i.setMaterial===void 0)throw new Error("setMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(e[0]),e[1]);case"cloneObject":return i.cloneObject(String(e[0]),e[1]??{});case"removeObject":return i.removeObject(String(e[0]));case"spawnObject":{let r=i.spawnObject(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let r=e[1]===null||e[1]===void 0?null:e[1],s=i.setInstanceTransforms(String(e[0]),r);return s<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(e[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),s}case"getAnimations":{let r=i.getAnimations(PM(e[0]));return r.warning&&this.onConsole("warn",`spline.${t}: ${r.warning}`),r.clips}case"playAnimation":{let r=typeof e[1]=="object"&&e[1]!==null,s=i.playAnimation(String(e[0]),r?void 0:PM(e[1]),(r?e[1]:e[2])??{});return s.warning&&this.onConsole("warn",`spline.${t}: ${s.warning}`),s.clip}case"pauseAnimation":case"stopAnimation":{let r=PM(e[0]),s=PM(e[1]),n=t==="pauseAnimation"?i.pauseAnimation(r,s):i.stopAnimation(r,s);return n.warning&&this.onConsole("warn",`spline.${t}: ${n.warning}`),n.ok}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(e[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,s=>{this.onEvent(r,s)})),!0}case"unlistenEvent":{let r=String(e[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${t}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let t=this.deps.getVariables(),e=function(i,r){let s=[];for(let n of Object.keys(r))i[n]!==r[n]&&s.push({name:n,value:r[n]});return s}(this.lastVariables??{},t);this.lastVariables=t;for(let i of e)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function XAt(t,e,i,r){return[t[0]*e+t[4]*i+t[8]*r+t[12],t[1]*e+t[5]*i+t[9]*r+t[13],t[2]*e+t[6]*i+t[10]*r+t[14]]}var YAt=j(()=>{}),ift,KAt=j(()=>{}),ZAt=j(()=>{RG(),eft(),ift=class{constructor(t,e,i){this.iframe=t,this.deps=e,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=r=>{if(this.disposed||r.source!==this.iframe.contentWindow)return;let s=r.data;var n;typeof(n=s)!="object"||n===null||n[qp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new DG(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[qp]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) \u2014 if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),this.handshakeTimer!==null&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(t){switch(t.kind){case"ready":this.handshakeSeen=!0,this.send({[qp]:!0,kind:"ready-ack"});break;case"console":this.onConsole(t.level,t.text);break;case"call":{let e;try{e=Promise.resolve(this.host.execute(t.method,t.args))}catch(i){e=Promise.reject(i)}e.then(i=>{this.send({[qp]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[qp]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[qp]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey};switch(t.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":e.dispatchEvent(new PointerEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,movementX:t.movementX,movementY:t.movementY}));break;case"click":case"dblclick":e.dispatchEvent(new MouseEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,deltaX:t.deltaX,deltaY:t.deltaY,deltaMode:t.deltaMode});typeof t.wheelDeltaX=="number"&&Object.defineProperty(s,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(s,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(s);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...r,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ir=j(()=>{PG(),IAt(),NAt(),BAt(),VAt(),zAt(),LAt(),FAt(),UAt(),jAt(),GAt(),HAt(),RG(),$At(),eft(),YAt(),KAt(),ZAt()}),QAt=j(()=>{});function rft(t){return Array.isArray(t)?t:[t]}function y4(t,e){let i=0;for(;i<t.length&&i<e.length;){if(t[i]<e[i])return-1;if(t[i]>e[i])return 1;i+=1}return i!==e.length?-1:i!==t.length?1:0}var JAt=j(()=>{});function $a(t,e){return Object.setPrototypeOf(t,e),t}function mI(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function im(t,e,i){if(t===void 0?e===void 0?(t=0,e=10):t=e-10:e===void 0&&(e=t+10),t>e){let n=t;t=e,e=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=t+(e-t)*(n+.75+.5*Math.random())*s;r.push(a)}return r}function e0(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array}var t3t=j(()=>{});function OG(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let r=t[i];r&&typeof r=="object"&&OG(r)}return Object.freeze(t)}function sft(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var fI,v4,gU,ke,IG,e3t=j(()=>{}),un=j(()=>{QAt(),JAt(),t3t(),e3t()}),NG=j(()=>{fI=class{},v4=class extends fI{constructor(t){super(),this.id=t}},gU=class extends fI{constructor(t){super(),this.data=t}}}),i3t=j(()=>{}),Z5=j(()=>{ke=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let r={...i,[t]:e};return Object.setPrototypeOf(r,ke.prototype),r}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let i,r=e[t.id];i=r===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:r};let{id:s,data:n}=t,a={...e,[s]:n};return Object.setPrototypeOf(a,ke.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,r=e[i];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,ke.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),BG=j(()=>{IG=class extends Error{}});function nft(t,e){for(let i of t)e(i.id,i.data)!==!0&&nft(i.children,e)}function aft(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)aft(i,e)}var Nn,RM,Bv,ce,a0=j(()=>{un(),BG(),un(),Nn=class extends Array{constructor(...t){super(...t),fc(this,"partialObjectCaches"),fc(this,"objCaches"),fc(this,"parentCaches"),Object.setPrototypeOf(this,Nn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)OG(this[t]),t++}fillCaches0(t,e){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,e);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,e){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}rootAcestor(t){for(;t;){let e=this.parent(t);if(!e)return t;t=e}return t}isDescendantOf(t,e){for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}partialCache(t){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let e=this.get(t);e!==void 0&&this.partialObjectCaches.set(t,e)}get(t){if(this.partialObjectCaches!==void 0){let e=this.partialObjectCaches.get(t);if(e!==void 0)return e}return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,e){if(t===null)this.traverse(e);else{let i=this.get(t);i&&aft(i,e)}}traverse(t){nft(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this.parent(t),r=this.childrenArray(i),s=r.findIndex(o=>o.id===t);if(s<0)throw new Error("not expected");let n=r[s];r=[...r],r[s]={...n,data:e};let a=new Map;return a.set(t,r[s]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(t,e,i=void 0){let r=t,s=e;for(;r!==null;){let a=s,o=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let l=s.findIndex(h=>h.id===o);if(l<0)throw new Error;s=[...s],s[l]={...s[l],children:a},i&&i.set(o,s[l])}Object.setPrototypeOf(s,Nn.prototype);let n=s;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){n.objCaches=this.objCaches;for(let[a,o]of i)n.objCaches.set(a,o);n.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else n.fillCaches();return n}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:e}){if(this.get(t)!==void 0)return!0;for(let i of e)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:e,fi:i,id:r,data:s,children:n}=t;if(e!==null&&this.get(e)===void 0||this.checkDuplicatedIdRec(t))return null;{let a=e,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:r}}}}deleteOp(t){let{id:e}=t;if(this.get(e)===null)return null;{let i=this.parent(e);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);t.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:t,reverse:{type:7,...n,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:r}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:r});if(e!==null){let d=e;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new IG("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=e,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:t,reverse:{type:9,parent:n,fi:u,id:r}}}previous(t,e){if(e===null){let r=this.childrenArray(t);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(t)){if(r.id===e)return i;i=r.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)+1;if(r<i.length)return i[r].id;if(e)return this.traverseSortNext(e)}}sortNext(t){let e=this.childrenArray(t);return e.length>0?e[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let e=this.childrenArray(t);return e.length>0?this.traverseSortPrevious(e[e.length-1].id):t}sortPrevious(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)-1;return r>=0?this.traverseSortPrevious(i[r].id):e}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push({...i,...r})}e.sort((i,r)=>y4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i);r!==void 0&&e.push(r)}e.sort((i,r)=>y4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],r=this.get(e),s=r;if(r!==void 0){for(;e;)i.splice(0,0,r.fi),e=this.parent(e),e!==null&&(r=this.get(e));return{...s,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let r=this.childrenArray(t);if(e===null){if(r.length===0)return im(0,i,i);{let s=r[0].fi;return im(s-i,s,i)}}{let s=this.get(e);if(s===void 0||this.parent(e)!==t)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return im(a,a+i,i)}return im(s.fi,n.fi,i)}}}}),kG=j(()=>{var t;un(),RM=null,(t=Bv||(Bv={})).setPreservePrototype=function(e){RM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===RM&&Object.setPrototypeOf(i,RM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||e0(e)){let r=i.props,s={},n=e0(e)?e.slice():[...e],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");s[o]=n[l],n[l]=r[o],a=!0}return a?{data:n,actual:i,reverse:{type:0,props:s}}:null}{let r=i.props,s={},n={...e},a=!1;if(r)for(let o of Object.keys(r)){s[o]=n[o];let l=r[o];l===void 0?delete n[o]:n[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,n),actual:i,reverse:{type:0,props:s}}:null}}}),o0=j(()=>{un(),un(),ce=class extends Array{constructor(...t){super(...t),fc(this,"objCaches"),Object.setPrototypeOf(this,ce.prototype)}deepFreeze(){let t=0;for(;t<this.length;)OG(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===t);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,ce.prototype);let e=t;return typeof process<"u"||e.fillCaches(),e}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:e,id:i,data:r}=t,s=this,n={fi:e,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),t.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,r=i.findIndex(n=>n.id===e);if(r===-1)return null;t.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...s}}}moveOp(t){let{fi:e,id:i}=t,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:e};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),t.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:t,reverse:{type:6,fi:n,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let e=null;for(let i of this){if(i.id===t)return e;e=i.id}return null}insertBeforeHelper(t,e){return this.insertAfterHelper(this.previous(t),e)}insertAfterHelper(t,e){let i=this;if(t===null){if(i.length===0)return im(0,e,e);{let r=i[0].fi;return im(r-e,r,e)}}{let r=this.get(t);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return im(n,n+e,e)}return im(r.fi,s.fi,e)}}}});function r3t(t,e){let i={cur:[],result:[],len:0};return[t=hv(t,e,i)??t,i.result]}function qP(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function HP(t){t&&(t.len-=1)}function oft(t,e,i){let r=!1,s=t.map(n=>{let a=n.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=hv(n.data,e,qP(i,a));HP(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=oft(n.children,e,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function hv(t,e,i){if(t instanceof Nn){let r=oft(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ce)return function(r,s,n){let a=!1,o=r.map(l=>{let h=l.id,u=s[h];if(u!==void 0&&typeof u=="string"&&(a=!0,h=u,n!==null))throw new Error("not supported");let d=hv(l.data,s,qP(n,h));return HP(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:h,data:d}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(r)),o}(t,e,i);if(Array.isArray(t)){let r=!1,s=t.map((n,a)=>{let o=hv(n,e,qP(i,a));return HP(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(t)),s):void 0}if(t&&typeof t=="object"&&!e0(t)){let r={},s=!1;for(let[n,a]of Object.entries(t))if(n!=="name"&&n!=="variableId"){let o=e[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=hv(a,e,qP(i,n));HP(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(typeof t=="string"){let r=e[t];return r!==void 0&&function(s){if(s===null)return null;s.result.push(s.cur.slice(0,s.len))}(i),r}}var lft=j(()=>{a0(),o0(),un()});function uv(t){return t&&typeof t=="object"&&t instanceof Es}function VG(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=eS(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=VG(s.children,e);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}return{...s,id:n,data:a}});return i?r:void 0}function eS(t,e){if(!uv(e))return e;if(t instanceof Nn){let i=VG(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ce)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=eS(a.data,r[o]);return s=s||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return s?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}(t,e);if(Array.isArray(t)){let i=!1,r=t.map((s,n)=>{let a=eS(s,e[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t instanceof Es)return zG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=eS(n,e[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function zG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!uv(e))return e;if(!uv(t))return gm.apply(t,e);let i=new Set;for(let s of Object.keys(t))i.add(s);for(let s of Object.keys(e))i.add(s);let r=new Es;for(let s of i){let n=zG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var Es,gm,b4,ta,xX,Q5=j(()=>{var t;a0(),o0(),J5(),un(),Es=class{unusedFunOverridesTable(e){}runOp(e){let i=[],r=this,s=0,n={};for(;s<e.path.length;){if(i.push(r),r=r===void 0?void 0:r[e.path[s]],r!==void 0&&!uv(r))return null;s+=1}r=r?mI(r):new Es;for(let[a,o]of Object.entries(e.props)){let l=r[a];n[a]=l,o===void 0?delete r[a]:r[a]=o}for(;s>0;){if(Object.keys(r).length===0){let a=i[s-1];a&&(r=mI(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=mI(a);o[e.path[s-1]]=r,r=o}else{let o=new Es;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,Es.prototype),actual:e,reverse:{...e,props:n}}}},(t=gm||(gm={})).apply=function(e,i){return eS(e,i)??e},t.merge=function(e,i){return zG(e,i)},t.filterOp=function(e,i){let r=0,s=i.path,n=e;for(;r<s.length&&n!==void 0;){if(n=Dn.zoomOnce(n,s[r]),n===void 0)return i;if(!uv(n))return;r+=1}if(n===void 0)return i;if(uv(n)){if(i.type===0){let a={...i.props};for(let o of Object.keys(n))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=VG([i],n);return a?a[0]:i}return i}}}),s3t=j(()=>{un(),J5(),Z5(),a0(),BG(),kG(),o0(),lft(),Q5(),(b4||(b4={})).replaceProps=function(t,e){let i=Dn.zoom(e,t.path);if(typeof i=="object"){let r={};for(let s of Object.keys(t.props))r[s]=i[s];return{...t,props:r}}return{...t,props:{}}},(t=>{function e(s,n){let a=n.path,o=[];for(;;){let l;if(s instanceof Es&&n.type===0&&(l=s.runOp({...n,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=s instanceof Nn||s instanceof ce||s instanceof ke?s.runOp(n):Bv.runOp(s,n)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],m=o[c];if(m instanceof Nn){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ce){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ke){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Es){let f={...m,[p]:d};d=Object.setPrototypeOf(f,Es.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||e0(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=e0(m)?m.slice():[...m],d[p]=f}else d=Bv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let h,u=a[o.length];if(s instanceof Nn){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else if(s instanceof ce){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else s!==null&&(h=s[u]);if(h===void 0)return null;o.push(s),s=h}}function i(s,n){for(let a=0;a<s.length&&a<n.length;a++)if(s[a]!==n[a])return!0;return!1}function r(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==n[a])return!1;return!0}t.drop=function(s,n){return{...s,path:s.path.slice(n)}},t.applySimple=function(s,n){return e(s,n)?.data??s},t.apply=e,t.pathDisjoint=i,t.pathEq=r,t.commutative=function(s,n){return i(s.path,n.path)},t.subsumed=function(s,n){return!(s.type!==0||n.type!==0||!r(s.path,n.path))&&Object.keys(s.props).every(a=>n.props[a]!==void 0)}})(ta||(ta={})),(t=>{function e(i,r){let s=i,n=[],a=[];for(let o of r)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=ta.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=ta.apply(s,o)),h!==null){s=h.data;let[u,d]=r3t(s,{[o.id]:l});s=u;for(let c=0;c<d.length;c++){let p,m,f=d[c],g=f.pop();if(typeof g=="number"){let y=[g];for(let b=c+1;b<d.length;b++){let _=d[b],x=_[_.length-1];if(typeof x!="number"||!Dn.equal(f,_.slice(0,_.length-1)))break;y.push(x),d.splice(b,1)}let v=Dn.zoom(s,f);m=v.map((b,_)=>y.includes(_)?o.id:b),p=v,g=f.pop()}else p=l,(g==="alphaOverride"||g==="alpha")&&(p=l/100,Dn.zoom(s,f)[g]=p),m=o.id;n.push({type:0,path:f,props:{[g]:p}}),a.push({type:0,path:f,props:{[g]:m}})}a.push(h.reverse),n.push(h.actual)}}else{let l=ta.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof IG)return null;throw l}return{data:s,actual:n,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,r){let s=[];for(let n of i){let[a,...o]=n.path;a===r&&s.push({...n,path:o})}return s},t.addPrefix=function(i,r){return i.map(s=>({...s,path:[r,...s.path]}))},t.concat=function(i,r){return[...i,...r]},t.compress=function(i,r){return[...i.filter(s=>!r.some(n=>ta.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>ta.commutative(s,n)))},t.applyAll=function(i,r){for(let s of r){let n=e(i,s);n!==null&&(i=n.data)}return i},t.apply=e})(xX||(xX={}))});function wX(t,e){return t instanceof Es?Object.setPrototypeOf(e,Es.prototype):Bv.tryPreservePrototype(t,e)}function gI(t,e,i){if(t.length>0){let r=t[t.length-1];if(r.type===0&&e.type===0&&Dn.equal(r.path,i))return void Object.assign(r.props,e.props)}t.push({...e,path:i})}function $P(t,e,i){return i instanceof Nn?new oT(t,e,i):i instanceof ce?new lT(t,e,i):i instanceof ke?new Proxy(new uft(t,e,i),cft):i!==null&&typeof i=="object"?e0(i)?i:new Proxy(new hft(t,e,i),dft):i}function Qw(t){let e=new yU(t);return[$P(e,"",t),e]}function _4(t,e){let[i,r]=Qw(t);return e(i),r.result()}function Ns(t){return t instanceof oT||t instanceof lT?t._current:t!==null&&typeof t=="object"?t[x4]:t}function Jw(t){if(t instanceof oT||t instanceof lT)return t._current;if(t!==null&&typeof t=="object"){let e=t[x4];return e!==void 0?e:t}return t}var x4,SX,h_,F0,hft,uft,yI,dft,cft,oT,lT,yU,Dn,pft=j(()=>{Z5(),a0(),kG(),o0(),un(),J5(),Q5(),x4=Symbol(),SX=Symbol(),h_=Symbol(),F0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof yU);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[h_];i&&i(),delete this._children[t]}}}},hft=class extends F0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=wX(this._current,{...this._current,[t]:e})}runOp(t){let e=Bv.runOp(this._current,t);e!==null&&(e.data=wX(this._current,e.data)),this.reportOp(t,e,t.path)}},uft=class extends F0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,ke.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},yI={get(t,e){if(e===h_)return()=>{t._parent=null};if(e===x4)return t._current;if(e===SX)return t;let{_current:i,_children:r}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[e];if(s!==void 0)return s;let n=i[e],a=$P(t,e,n);return a!==n?(r===void 0&&(r={},t._children=r),r[e]=a,a):n},has:(t,e)=>e in t._current,ownKeys:t=>Reflect.ownKeys(t._current),defineProperty(){throw Error("not supported")},getPrototypeOf:t=>Object.getPrototypeOf(t._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(t,e){let i=t._current,r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[e]}}},dft={...yI,set(t,e,i){let r={type:0,props:{[e]:Ns(i)??i}};return t.deleteChildren(e),t.runOp(r),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},cft={...yI,set(t,e,i){return i===void 0?this.deleteProperty(t,e):(t.deleteChildren(e),t.runOp({type:1,id:e,data:i})),!0},deleteProperty:(t,e)=>(t.runOp({type:2,id:e}),!0)},oT=class extends F0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[h_]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,i)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=$P(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}add(t,e,i,r,s){this.runOp({type:7,parent:t,fi:e,id:i,data:r,children:s})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}insertBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}moveAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}moveBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},lT=class extends F0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[h_]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id,s=this._current[i].fi;t(this.data(this._current[i].id),r,s,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:i}=this._current.at(t);return{id:e,fi:i,data:this.data(e)}}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=$P(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,i){this.runOp({type:4,fi:t,id:e,data:i})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},yU=class extends F0{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,i,r){gI(this.ts,e,t),gI(this.actual,i,t),gI(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),J5=j(()=>{NG(),pft(),o0(),a0(),un(),(t=>{function e(r,s){return(r instanceof Nn||r instanceof oT)&&typeof s=="string"||(r instanceof ce||r instanceof lT)&&typeof s=="string"?r.data(s):typeof s=="number"&&Array.isArray(r)||typeof s=="string"&&typeof r=="object"&&r!==null?r[s]:void 0}function i(r,s,n=0){for(;n<s.length&&r!==void 0;)r=e(r,s[n]),n+=1;return r}t.equal=function(r,s){if(s.length!==r.length)return!1;{let n=0;for(;n<r.length;){if(r[n]!==s[n])return!1;n+=1}}return!0},t.removeOverridden=function(r,s,n){let a=i(n,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...s};return Object.keys(a).forEach(l=>{delete o[l]}),o}return s},t.zoomOnce=e,t.zoom=i,t.findPathes=function(r,s){let n=[];return function a(o,l){if(o instanceof v4&&o.id===s.id)n.push(l);else if(o instanceof ce)for(let h=0;h<o.length;h++)a(o[h].data,[...l,o[h].id]);else if(o instanceof Nn)o.traverse((h,u)=>{a(u,[...l,h])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let h=0;h<o.length;h++)a(o[h],[...l,h])}else{if(e0(o))return;if(typeof o=="object"&&o!==null)for(let h in o)a(o[h],[...l,h])}}(r,[]),n}})(Dn||(Dn={}))}),n3t=j(()=>{});function er(t,e){let i=[];if(!(e.length<=t.length))return null;{let r=0;for(;r<e.length;){if(e[r]==="*")i.push(t[r]);else if(t[r]!==e[r])return null;r+=1}}return i}var a3t=j(()=>{});function DM(t){try{if(!Er.trusted&&!vc){let i=qi.sharedLength||0;i<qi.length&&(qi.length=i)}let e;if(Er.randomAccessStructure&&me[ft]<64&&me[ft]>=32&&PX?(e=PX(me,ft,th,Er),me=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),ft=th):e=Zs(),Ra&&(ft=Ra.postBundlePosition,Ra=null),vc&&(qi.restoreStructures=null),ft==th)qi&&qi.restoreStructures&&TX(),qi=null,me=null,yc&&(yc=null);else{if(ft>th)throw new Error("Unexpected end of MessagePack data");if(!vc){let i;try{i=JSON.stringify(e,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw qi&&qi.restoreStructures&&TX(),bU(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||ft>th)&&(e.incomplete=!0),e}}function TX(){for(let t in qi.restoreStructures)qi[t]=qi.restoreStructures[t];qi.restoreStructures=null}function Zs(){let t=me[ft++];if(t<160){if(t<128){if(t<64)return t;{let e=qi[63&t]||Er.getStructures&&mft()[63&t];return e?(e.read||(e.read=vU(e,63&t)),e.read()):t}}if(t<144){if(t-=128,Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=gft();r==="__proto__"&&(r="__proto_"),e[r]=Zs()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Zs(),Zs());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=Zs();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(qh>=ft)return rm.slice(ft-fl,(ft+=e)-fl);if(qh==0&&th<140){let i=e<16?LG(e):fft(e);if(i!=null)return i}return T4(e)}{let e;switch(t){case 192:return null;case 193:return Ra?(e=Zs(),e>0?Ra[1].slice(Ra.position1,Ra.position1+=e):Ra[0].slice(Ra.position0,Ra.position0-=e)):bft;case 194:return!1;case 195:return!0;case 196:if(e=me[ft++],e===void 0)throw new Error("Unexpected end of buffer");return vI(e);case 197:return e=zi.getUint16(ft),ft+=2,vI(e);case 198:return e=zi.getUint32(ft),ft+=4,vI(e);case 199:return of(me[ft++]);case 200:return e=zi.getUint16(ft),ft+=2,of(e);case 201:return e=zi.getUint32(ft),ft+=4,of(e);case 202:if(e=zi.getFloat32(ft),Er.useFloat32>2){let i=MU[(127&me[ft])<<1|me[ft+1]>>7];return ft+=4,(i*e+(e>0?.5:-.5)|0)/i}return ft+=4,e;case 203:return e=zi.getFloat64(ft),ft+=8,e;case 204:return me[ft++];case 205:return e=zi.getUint16(ft),ft+=2,e;case 206:return e=zi.getUint32(ft),ft+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*zi.getUint32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigUint64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigUint64(ft),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigUint64(ft),ft+=8,e;case 208:return zi.getInt8(ft++);case 209:return e=zi.getInt16(ft),ft+=2,e;case 210:return e=zi.getInt32(ft),ft+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*zi.getInt32(ft),e+=zi.getUint32(ft+4)):Er.int64AsType==="string"?e=zi.getBigInt64(ft).toString():Er.int64AsType==="auto"?(e=zi.getBigInt64(ft),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigInt64(ft),ft+=8,e;case 212:if(e=me[ft++],e==114)return TU(63&me[ft++]);{let i=Ta[e];if(i)return i.read?(ft++,i.read(Zs())):i.noBuffer?(ft++,i()):i(me.subarray(ft,++ft));throw new Error("Unknown extension "+e)}case 213:return e=me[ft],e==114?(ft++,TU(63&me[ft++],me[ft++])):of(2);case 214:return of(4);case 215:return of(8);case 216:return of(16);case 217:return e=me[ft++],qh>=ft?rm.slice(ft-fl,(ft+=e)-fl):xft(e);case 218:return e=zi.getUint16(ft),qh>=(ft+=2)?rm.slice(ft-fl,(ft+=e)-fl):wft(e);case 219:return e=zi.getUint32(ft),qh>=(ft+=4)?rm.slice(ft-fl,(ft+=e)-fl):Sft(e);case 220:return e=zi.getUint16(ft),ft+=2,MX(e);case 221:return e=zi.getUint32(ft),ft+=4,MX(e);case 222:return e=zi.getUint16(ft),ft+=2,AX(e);case 223:return e=zi.getUint32(ft),ft+=4,AX(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+t)}}}function vU(t,e){function i(){if(i.count++>xU){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":_ft.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")(Zs)}catch{return xU=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=wU(e,t.read)),s()}let r={};for(let s=0,n=t.length;s<n;s++){let a=t[s];a==="__proto__"&&(a="__proto_"),r[a]=Zs()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?wU(e,i):i}function mft(){let t=vft(()=>(me=null,Er.getStructures()));return qi=Er._mergeStructures(t,qi)}function t2(t){let e;if(t<16&&(e=LG(t)))return e;if(t>64&&_U)return _U.decode(me.subarray(ft,ft+=t));let i=ft+t,r=[];for(e="";ft<i;){let s=me[ft++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&me[ft++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&me[ft++])<<6|63&me[ft++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&me[ft++])<<12|(63&me[ft++])<<6|63&me[ft++];n<65536||n>1114111?r.push(65533):(n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n))}else r.push(65533);else r.push(s);r.length>=4096&&(e+=Tn.apply(String,r),r.length=0)}return r.length>0&&(e+=Tn.apply(String,r)),e}function MX(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=Zs();return Er.freezeData?Object.freeze(e):e}function AX(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=gft();r==="__proto__"&&(r="__proto_"),e[r]=Zs()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Zs(),Zs());return e}}function fft(t){let e=ft,i=new Array(t);for(let r=0;r<t;r++){let s=me[ft++];if((128&s)>0)return void(ft=e);i[r]=s}return Tn.apply(String,i)}function LG(t){if(t<4){if(t<2){if(t===0)return"";{let e=me[ft++];return(128&e)>1?void(ft-=1):Tn(e)}}{let e=me[ft++],i=me[ft++];if((128&e)>0||(128&i)>0)return void(ft-=2);if(t<3)return Tn(e,i);let r=me[ft++];return(128&r)>0?void(ft-=3):Tn(e,i,r)}}{let e=me[ft++],i=me[ft++],r=me[ft++],s=me[ft++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(ft-=4);if(t<6){if(t===4)return Tn(e,i,r,s);{let n=me[ft++];return(128&n)>0?void(ft-=5):Tn(e,i,r,s,n)}}if(t<8){let n=me[ft++],a=me[ft++];if((128&n)>0||(128&a)>0)return void(ft-=6);if(t<7)return Tn(e,i,r,s,n,a);let o=me[ft++];return(128&o)>0?void(ft-=7):Tn(e,i,r,s,n,a,o)}{let n=me[ft++],a=me[ft++],o=me[ft++],l=me[ft++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(ft-=8);if(t<10){if(t===8)return Tn(e,i,r,s,n,a,o,l);{let h=me[ft++];return(128&h)>0?void(ft-=9):Tn(e,i,r,s,n,a,o,l,h)}}if(t<12){let h=me[ft++],u=me[ft++];if((128&h)>0||(128&u)>0)return void(ft-=10);if(t<11)return Tn(e,i,r,s,n,a,o,l,h,u);let d=me[ft++];return(128&d)>0?void(ft-=11):Tn(e,i,r,s,n,a,o,l,h,u,d)}{let h=me[ft++],u=me[ft++],d=me[ft++],c=me[ft++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(ft-=12);if(t<14){if(t===12)return Tn(e,i,r,s,n,a,o,l,h,u,d,c);{let p=me[ft++];return(128&p)>0?void(ft-=13):Tn(e,i,r,s,n,a,o,l,h,u,d,c,p)}}{let p=me[ft++],m=me[ft++];if((128&p)>0||(128&m)>0)return void(ft-=14);if(t<15)return Tn(e,i,r,s,n,a,o,l,h,u,d,c,p,m);let f=me[ft++];return(128&f)>0?void(ft-=15):Tn(e,i,r,s,n,a,o,l,h,u,d,c,p,m,f)}}}}}function CX(){let t,e=me[ft++];if(e<192)t=e-160;else switch(e){case 217:t=me[ft++];break;case 218:t=zi.getUint16(ft),ft+=2;break;case 219:t=zi.getUint32(ft),ft+=4;break;default:throw new Error("Expected string")}return t2(t)}function vI(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(me,ft,ft+=t):me.subarray(ft,ft+=t)}function of(t){let e=me[ft++];if(Ta[e]){let i;return Ta[e](me.subarray(ft,i=ft+=t),r=>{ft=r;try{return Zs()}finally{ft=i}})}throw new Error("Unknown extension type "+e)}function gft(){let t=me[ft++];if(!(t>=160&&t<192))return ft--,yft(Zs());if(t-=160,qh>=ft)return rm.slice(ft-fl,(ft+=t)-fl);if(!(qh==0&&th<180))return T4(t);let e,i=4095&(t<<5^(t>1?zi.getUint16(ft):t>0?me[ft]:0)),r=SU[i],s=ft,n=ft+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=zi.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=me[s++],e!=r[a++]){s=1879048192;break}if(s===n)return ft=s,r.string;n-=3,s=ft}for(r=[],SU[i]=r,r.bytes=t;s<n;)e=zi.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=me[s++],r.push(e);let o=t<16?LG(t):fft(t);return r.string=o??T4(t)}function yft(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(Er.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error("Invalid property type for record: "+typeof t)}function vft(t){RX&&RX();let e=th,i=ft,r=S4,s=fl,n=qh,a=rm,o=w4,l=yc,h=Ra,u=new Uint8Array(me.slice(0,th)),d=qi,c=qi.slice(0,qi.length),p=Er,m=vc,f=t();return th=e,ft=i,S4=r,fl=s,qh=n,rm=a,w4=o,yc=l,Ra=h,me=u,vc=m,(qi=d).splice(0,qi.length,...c),Er=p,zi=new DataView(me.buffer,me.byteOffset,me.byteLength),f}function bU(){me=null,yc=null,qi=null}function o3t(t){t.unpack?Ta[t.type]=t.unpack:Ta[t.type]=t}var _U,me,th,ft,EX,w4,S4,Er,qi,rm,fl,qh,Ra,yc,Ta,zi,bI,bft,vc,xU,PX,RX,e2,_ft,wU,T4,xft,wft,Sft,Tn,SU,TU,_I,DX,OX,IX,MU,OM,NX,BX,kX,AU,xI,FS,l3t=j(()=>{try{_U=new TextDecoder}catch{}ft=0,w4=EX=[],S4=0,Er={},fl=0,qh=0,Ta=[],bI={useRecords:!1,mapsAsObjects:!0},(bft=new class{}).name="MessagePack 0xC1",vc=!1,xU=2,e2=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=0&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(me)return vft(()=>(bU(),this?this.unpack(t,e):e2.prototype.unpack.call(bI,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(th=e.end||t.length,ft=e.start||0):(ft=0,th=e>-1?e:t.length),S4=0,qh=0,rm=null,w4=EX,Ra=null,me=t;try{zi=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw me=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e2){if(Er=this,this.structures)return qi=this.structures,DM(e);(!qi||qi.length>0)&&(qi=[])}else Er=bI,(!qi||qi.length>0)&&(qi=[]);return DM(e)}unpackMultiple(t,e){let i,r=0;try{vc=!0;let s=t.length,n=this?this.unpack(t,s):OM.unpack(t,s);if(!e){for(i=[n];ft<s;)r=ft,i.push(DM());return i}if(e(n,r,ft)===!1)return;for(;ft<s;)if(r=ft,e(DM(),r,ft)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{vc=!1,bU()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,r=t.length;i<r;i++){let s=t[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let r=t[i],s=e[i];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[i]=r),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},_ft=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,wU=(t,e)=>function(){let i=me[ft++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=qi[r]||mft()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=vU(s,t)),s.read()},T4=t2,xft=t2,wft=t2,Sft=t2,Tn=String.fromCharCode,SU=new Array(4096),TU=(t,e)=>{let i=Zs().map(yft),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=qi[t];return s&&(s.isShared||vc)&&((qi.restoreStructures||(qi.restoreStructures=[]))[t]=s),qi[t]=i,i.read=vU(i,r),(i.read0||i.read)()},Ta[0]=()=>{},Ta[0].noBuffer=!0,Ta[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let r=1;r<e;r++)i<<=BigInt(8),i+=BigInt(t[r]);if(t.byteLength!==e){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=(n,a)=>{let o=a-n;if(o<=40){let d=r.getBigUint64(n);for(let c=n+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=n+(o>>4<<3),h=s(n,l),u=s(l,a);return h<<BigInt(8*(a-l))|u};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},_I={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},Ta[101]=()=>{let t=Zs();if(!_I[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return _I[t[0]](t[1],{cause:t[2]})},Ta[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4);yc||(yc=new Map);let i,r=me[ft];i=r>=144&&r<160||r==220||r==221?[]:r>=128&&r<144||r==222||r==223?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&me[ft+1]===115?new Set:{};let s={target:i};yc.set(e,s);let n=Zs();if(!s.used)return s.target=n;if(Object.assign(i,n),i instanceof Map)for(let[a,o]of n.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(n))i.add(a);return i},Ta[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(ft-4),i=yc.get(e);return i.used=!0,i.target},Ta[115]=()=>new Set(Zs()),DX=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),OX=typeof globalThis=="object"?globalThis:window,Ta[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=DX[e];if(!r){if(e===16)return i;if(e===17)return new DataView(i);throw new Error("Could not find typed array for code "+e)}return new OX[r](i)},Ta[120]=()=>{let t=Zs();return new RegExp(t[0],t[1])},IX=[],Ta[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=ft;return ft+=e-t.length,Ra=IX,(Ra=[CX(),CX()]).position0=0,Ra.position1=0,Ra.postBundlePosition=ft,ft=i,Zs()},Ta[255]=t=>t.length==4?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid"),MU=new Array(147);for(let t=0;t<256;t++)MU[t]=+("1e"+Math.floor(45.15-.30103*t));(OM=new e2({useRecords:!1})).unpack,OM.unpackMultiple,OM.unpack,NX=new Float32Array(1),new Uint8Array(NX.buffer,0,4)}),h3t=j(()=>{l3t(),NG(),Q5(),o0(),Z5(),a0(),BX=[{Class:ke.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,ke.prototype),t)},{Class:ce.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ce.prototype),t)},{Class:Nn.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Nn.prototype),t)},{Class:v4.prototype.constructor,type:4,write:t=>t.id,read:t=>new v4(t)},{Class:gU.prototype.constructor,type:5,write:t=>t.data,read:t=>new gU(t)},{Class:Es.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Es.prototype),t)}];for(let t of BX)o3t(t);kX=new e2({structuredClone:!0}),(AU||(AU={})).deserialize=function(t){return kX.unpack(t)}}),u3t=j(()=>{h3t(),xI=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},FS={deserialize:AU.deserialize,serialize:xI("CollabSerialize.serialize"),checksum:xI("CollabSerialize.checksum")}}),Ui=j(()=>{J5(),i3t(),BG(),a0(),Z5(),kG(),o0(),s3t(),n3t(),pft(),a3t(),NG(),u3t(),lft(),Q5()});function CU(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var VX,EU,iS,IM,wI,zX,LX,FX,PU,RU,UX,jX,GX,WX,qX,DU,OU,HX,$X,XX,YX,Tft=j(()=>{var t,e,i;Ui(),ht(),(t=VX||(VX={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},t.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},EU={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(r=>{r.is=function(s){return s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"},r.defaultData=function(s){return s==="MouseDown"||s==="MouseUp"||s==="MousePress"?{type:s,mode:"Object",disabled:!1,name:"",actions:new ce}:{type:s,disabled:!1,name:"",key:void 0,actions:new ce}}})(iS||(iS={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(IM||(IM={})),(e=wI||(wI={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:IM.propertyDefaultData(r),rOperand:{...IM.valueDefaultData}}},e.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},e.stateDefaultData=function(r,s){return{type:"State",object:r??null,state:s??null}},(zX||(zX={})).isConditionalSubActions=function(r){return r.find(s=>s==="ifActions"||s==="elseActions")!==void 0},(r=>{r.is=function(s){return s.type==="Conditional"},r.defaultData=function(s){return{type:"Conditional",disabled:!1,name:"",inActions:new ce,outActions:new ce,condition:wI.distanceDefaultData(s)}}})(LX||(LX={})),(FX||(FX={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ce,drop:new ce}},(PU||(PU={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ce},(RU||(RU={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(r=>{r.is=function(s){return s.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new ce}}})(UX||(UX={})),(r=>{r.is=function(s){return s.type==="Scroll"},r.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ce}}})(jX||(jX={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ce}}})(GX||(GX={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ce}}})(WX||(WX={})),(r=>{r.is=function(s){return s.type==="Trigger"},r.defaultData=function(s,n){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new ce,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(qX||(qX={})),(i=DU||(DU={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(r){return r.type==="Resize"},i.sizeToDevice=function(r){return typeof r=="string"?r:"custom"},i.deviceToSize=function(r){return typeof r=="string"?[...i.defaultSizes[r]]:[...r]},i.defaultData=function(){let r={size:"mobile",operator:"<",actions:new ce},s={size:"tablet",operator:"<",actions:new ce},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ce},a=new ce;return a.push({id:Ft.generateUUID(),fi:0,data:r},{id:Ft.generateUUID(),fi:1,data:s},{id:Ft.generateUUID(),fi:2,data:n}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new ce}},(r=>{r.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},r.is=function(s){return s.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new ce,variableId:"",objectId:null,property:"Position X"}}})(OU||(OU={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ce,errorActions:new ce,userAPIId:""}}})(HX||(HX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ce,userWebhookId:""}}})($X||($X={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ce,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(XX||(XX={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ce}}})(YX||(YX={}))});function KX(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function IU(t){return typeof t=="string"&&t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}var l0,dv,Mft,i0,ZX,Hu,ym,US,QX,SI,wl,Ks,Hi,NU,JX,sm,kv,tY,eY,iY,rY,sY,nY,aY,oY,TI,lY,hY,MI,uY,dY,cY,AI,pY,CI,mY,fY,EI,gY,BU,yY,vY,bY,_Y,xY,wY,r0,bc,nm,kU,VU,M4,A4,C4,E4,P4,zU,LU,R4,FU,cv,SY,PI,RI,UU,TY,D4,O4,DI,MY,jU,OI,AY,CY,EY,PY,RY,DY,OY,IY,tD,FG,Bs,ls,C1,Aft,Vv,I4,wg,GU,UG,N4,B4,k4,dc,XP,ea,II,Qp,qo=j(()=>{var t,e,i,r,s,n,a,o;l0="personal camera",dv="a218fcc3-276b-49b9-b485-49037fd14f5f",Mft=2500134,i0=5526619,(t=ZX||{}).x="x",t.y="y",t.z="z",ZX=t,(l=>{function h(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function u(c,p){return Math.sqrt(h(c,p))}function d(c,p,m){let f=l.sub(p,c),g=l.sub(m,c),y=l.dot(f,g)/l.dot(f,f),v=l.scalarMultiply(f,y);return l.add(c,v)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,m){return[c[0]+(p[0]-c[0])*m,c[1]+(p[1]-c[1])*m]},l.add=function(c,p){return[c[0]+p[0],c[1]+p[1]]},l.sub=function(c,p){return[c[0]-p[0],c[1]-p[1]]},l.multiply=function(c,p){return[c[0]*p[0],c[1]*p[1]]},l.divide=function(c,p){return[c[0]/p[0],c[1]/p[1]]},l.distanceSquared=h,l.distance=u,l.dot=function(c,p){return c[0]*p[0]+c[1]*p[1]},l.scalarMultiply=function(c,p){return[c[0]*p,c[1]*p]},l.projectionOnto=d,l.projectionOntoDistance=function(c,p,m){return u(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Hu||(Hu={})),(e=ym||(ym={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]},e.add=function(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]},e.sub=function(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]},e.div=function(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]},e.mul=function(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]},e.dist=function(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])},e.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]},(i=US||(US={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]&&l[3]===h[3]},i.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u,l[3]+(h[3]-l[3])*u]},(l=>{let h=180/Math.PI,u=Math.PI/180;function d(p){return typeof p=="number"?p*h:p}function c(p){return typeof p=="number"?p*u:p}l.radToDeg=function(p){return[d(p[0]),d(p[1]),d(p[2])]},l.degToRad=function(p){return[c(p[0]),c(p[1]),c(p[2])]}})(QX||(QX={})),(r=SI||(SI={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,h){for(let u=0;u<16;u++)if(l[u]!==h[u])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,h){let u=h.slice(0);for(let d=0,c=h.length;d<c;d+=3){let p=l[3]*h[d]+l[7]*h[d+1]+l[11]*h[d+2]+l[15];u[d]=(l[0]*h[d]+l[4]*h[d+1]+l[8]*h[d+2]+l[12])/p,u[d+1]=(l[1]*h[d]+l[5]*h[d+1]+l[9]*h[d+2]+l[13])/p,u[d+2]=(l[2]*h[d]+l[6]*h[d+1]+l[10]*h[d+2]+l[14])/p}return u},(l=>{l.zero=[0,0,0,0,0,0],l.INDEX_MAP=[4,8,1,9,2,6],l.toMatrix=function(h){let u=[...SI.identity];for(let d=0;d<6;d++)u[l.INDEX_MAP[d]]=h[d];return u},l.fromMatrix=function(h){return[h[l.INDEX_MAP[0]],h[l.INDEX_MAP[1]],h[l.INDEX_MAP[2]],h[l.INDEX_MAP[3]],h[l.INDEX_MAP[4]],h[l.INDEX_MAP[5]]]}})(wl||(wl={})),(s=Ks||(Ks={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},s.clone=function(l){return{r:l.r,g:l.g,b:l.b}},s.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},s.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},s.equals=function(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b},s.equalsFixed=function(l,h){return l.r.toFixed(2)===h.r.toFixed(2)&&l.g.toFixed(2)===h.g.toFixed(2)&&l.b.toFixed(2)===h.b.toFixed(2)},s.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}},s.is=function(l){return!!KX(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=Hi||(Hi={})).white={...Ks.white,a:1},n.is=function(l){return!!KX(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...Ks.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,h){return{...Ks.fromHex(l),a:h}},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},n.equals=function(l,h){return Ks.equals(l,h)&&l.a===h.a},n.equalsFixed=function(l,h){return Ks.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)},n.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u,a:l.a+(h.a-l.a)*u}},n.toStyle=function({r:l,g:h,b:u,a:d}=n.white){return`rgba(${255*l}, ${255*h}, ${255*u}, ${d})`},(NU||(NU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=JX||{})[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING",a[a.ARC=7]="ARC",a[a.NONE=8]="NONE",JX=a,(sm||(sm={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(kv||(kv={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=tY||(tY={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),d3t=j(()=>{var t,e;Ui(),Tft(),(eY||(eY={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(iY||(iY={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(rY||(rY={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(sY||(sY={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(nY||(nY={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(aY||(aY={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(oY||(oY={})).defaultData={type:"Reset",name:"",delay:0},(TI||(TI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=lY||(lY={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=hY||(hY={})).defaultData={type:"Audio",name:"",...TI.defaultData},e.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),e.hasAudioByEvents=i=>e.getAudiosByEvents(i).length>0,e.getAudiosByActions=i=>{let r=[];return i.forEach(s=>{let n=s.data;n.type==="Audio"&&n.interaction==="play"&&n.audio&&r.push(s),n.type==="Conditional"&&(r.push(...e.getAudiosByActions(n.ifActions)),r.push(...e.getAudiosByActions(n.elseActions)))}),r},e.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:s})=>{iS.is(s)||s.type==="Collision"||s.type==="Start"||s.type==="Trigger"||s.type==="VariableChange"||s.type==="WEBHOOK"||s.type==="AIAssistantTrigger"?r.push(...e.getAudiosByActions(s.actions)):s.type==="Conditional"?(r.push(...e.getAudiosByActions(s.inActions)),r.push(...e.getAudiosByActions(s.outActions))):s.type==="GameControl"?Object.values(s.gameActions).forEach(n=>{r.push(...e.getAudiosByActions(n))}):s.type==="DragDrop"?(r.push(...e.getAudiosByActions(s.dragDropActions.drag)),r.push(...e.getAudiosByActions(s.dragDropActions.drop))):s.type==="Resize"?s.breakpoints.forEach(({data:n})=>{r.push(...e.getAudiosByActions(n.actions))}):s.type==="API"&&(r.push(...e.getAudiosByActions(s.successActions)),r.push(...e.getAudiosByActions(s.errorActions)))}),r},(MI||(MI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(uY||(uY={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...MI.defaultData},i.hasVideoByActions=r=>r.some(({data:s})=>s.type==="Video"&&s.interaction==="play"&&s.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:s}of r.events)if((iS.is(s)||s.type==="Start")&&i.hasVideoByActions(s.actions))return!0}},i.getVideosByActions=r=>{let s=[];return r.forEach(n=>{let a=n.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&s.push(n)}),s},i.getVideosByEvents=r=>{let s=[];return r.forEach(({data:n})=>{(iS.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(dY||(dY={})),(cY||(cY={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(AI||(AI={})).defaultData=function(){return{tweens:new ce,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(pY||(pY={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...AI.defaultData()}},(CI||(CI={})).defaultData=function(i){return{interaction:"play",timeline:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(mY||(mY={})),(fY||(fY={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...CI.defaultData(i)}},(EI||(EI={})).defaultData=function(i,r,s){return{interaction:"play",object:i,clipId:r,crop:s,crop2:s,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(gY||(gY={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...EI.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(BU||(BU={})),(yY||(yY={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(vY||(vY={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ce,elseActions:new ce,condition:[]}),(bY||(bY={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(_Y||(_Y={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(xY||(xY={})).defaultData={name:"",type:"UserAPI"}}),c3t=j(()=>{var t;(t=wY||(wY={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),Cft=j(()=>{var t;(t=r0||(r0={})).all=["PerspectiveCamera","OrthographicCamera"],t.is=function(e){return t.all.includes(e)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(n){return n===void 0||!Number.isFinite(n)||n<e.MinTargetOffset?e.DefaultTargetOffset:n},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,r=e.DefaultElevation*Math.PI/180,s=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(r),e.DefaultTargetOffset*Math.sin(r),e.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],e.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*s,Math.asin(Math.sin(i)*Math.cos(r))*s,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*s],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}})(bc||(bc={}))}),Eft=j(()=>{var t;(t=nm||(nm={})).defaultData=function(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof e[0]=="number"?e[0]:1,typeof e[1]=="number"?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof e[0]=="number"?e[0]+e[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(r=>(typeof r=="number"?r:1)*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},t.merge=function(e,i){let r={...e};if(VU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;M4.forEach(a=>{Object.assign(r.radial,{[a]:n[a]??s[a]})})}if(r.linear={...e.linear},i.linear){let s=e.linear,n=i.linear;A4.forEach(a=>{Object.assign(r.linear,{[a]:n[a]??s[a]})})}if(r.grid={...e.grid},i.grid){let s=e.grid,n=i.grid;C4.forEach(a=>{Object.assign(r.grid,{[a]:n[a]??s[a]})})}if(r.toObject={...e.toObject},i.toObject){let s=e.toObject,n=i.toObject;E4.forEach(a=>{Object.assign(r.toObject,{[a]:n[a]??s[a]})})}if(r.randomnessObject={...e.randomnessObject},i.randomnessObject){let s=e.randomnessObject,n=i.randomnessObject;P4.forEach(a=>{Object.assign(r.randomnessObject,{[a]:n[a]??s[a]})})}return r},t.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}})(kU||(kU={})),VU=["count"],M4=["radius","start","end","position","scale","rotation"],A4=["position","scale","rotation"],C4=["count","size"],E4=["count","position","scale","rotation"],P4=["strength","scale","rotation","position","movement","seed","freqScale"]}),Pft=j(()=>{var t;qo(),(t=zU||(zU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(LU||(LU={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:Hi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:Hi.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(i==="DirectionalLight")return{type:i,color:Hi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),Rft=j(()=>{var t;(t=R4||(R4={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...t.defaultCollisionData}}),Dft=j(()=>{var t;(t=FU||(FU={})).defaultData={gravity:10,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:0,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},t.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),jG=j(()=>{(cv||(cv={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),Oft=j(()=>{var t,e;(t=SY||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",SY=t,(e=PI||(PI={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(r,s){return r.flatShading===s.flatShading&&r.side===s.side&&r.wireframe===s.wireframe&&(r.shadowCatcher??!1)===(s.shadowCatcher??!1)}})(RI||(RI={})),(UU||(UU={})).defaultData={...RI.defaultData,...PI.defaultData},(TY||(TY={})).getMaterialData=function(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}}),Ift=j(()=>{var t;(t=D4||(D4={})).bytesFromFlattened=function(e){if(typeof e!="object"||e===null||Array.isArray(e)||ArrayBuffer.isView(e)||typeof e[0]!="number")return null;let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)return null;let r=Object.keys(e),s=new Uint8Array(r.length),n=e;for(let a=0;a<r.length;a++){let o=n[a];if(r[a]!==String(a)||typeof o!="number"||!Number.isInteger(o)||o<0||o>255)return null;s[a]=o}return s},t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),Nft=j(()=>{var t;(t=O4||(O4={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),hT=j(()=>{var t,e,i,r;Ui(),qo(),Ift(),Nft(),qo(),(DI||(DI={})).is=function(s){return s==="texture"||s==="video"||s==="color"||s==="depth"||s==="normal"||s==="gradient"||s==="noise"||s==="fresnel"||s==="cavity"||s==="dust"||s==="rainbow"||s==="toon"||s==="outline"||s==="particle"||s==="transmission"||s==="reflection"||s==="matcap"||s==="displace"||s==="pattern"||s==="vertexColor"||s==="light"},(MY||(MY={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(jU||(jU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(OI||(OI={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(r=AY||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",AY=r,CY=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(CY||{}),EY=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))(EY||{}),(i=PY||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",PY=i,(e=RY||{})[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",RY=e,(t=DY||{})[t.F1=0]="F1",t[t.F2=1]="F2",t[t.F2MinusF1=2]="F2MinusF1",t[t.SmoothBlend=3]="SmoothBlend",t[t.Edge=4]="Edge",t[t.Power=5]="Power",t[t.Lines=6]="Lines",t[t.Cells=7]="Cells",DY=t,OY=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(OY||{}),IY=(s=>(s[s.Circle=0]="Circle",s[s.Ring=1]="Ring",s[s.Polygon=2]="Polygon",s[s.Cross=3]="Cross",s[s.Diamond=4]="Diamond",s[s.Checkerboard=5]="Checkerboard",s[s.Line=6]="Line",s[s.Wave=7]="Wave",s))(IY||{}),tD=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],FG=["wrapping","image","video","name","minFilter","magFilter"],(s=>{function n(a,o){return a==="light"&&o?function(l){let h={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(l){case"phong":return{...h,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...h,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...h,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...h,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(o):function(l){let h={alpha:1,mode:0,isMask:!1,visible:!0};switch(l){case"texture":return{...h,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...h,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:O4.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...h,type:"color",color:Ks.fromHex(i0)};case"vertexColor":return{...h,type:"vertexColor"};case"depth":return{...h,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...h,type:"normal",cnormal:[1,1,1]};case"gradient":return{...h,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...h,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ks.fromHex(6710886),a:1},colorB:{...Ks.fromHex(6710886),a:1},colorC:{...Ks.fromHex(16777215),a:1},colorD:{...Ks.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...h,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...h,type:"fresnel",color:Hi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...h,type:"dust",color:Hi.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...h,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...h,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Hi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...h,type:"outline",outlineColor:Hi.fromHexAndA(0,1),contourColor:Hi.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...h,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...h,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...h,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...h,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ks.fromHex(0),a:1},colorB:{...Ks.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(a)}s.patch=function(a,o){let{texture:l,...h}=o;if(Object.assign(a,h),l){let u=a.texture;u&&Object.assign(u,l)}},s.defaultColorLayer=function(a){return{...s.defaultData("color"),color:a}},s.defaultData=n,s.defaultDataFor=function(a,o){return a!=="light"?n(a):n("light",typeof o=="string"&&OI.is(o)?o:"physical")}})(Bs||(Bs={})),(s=>{function n(l,h){if(typeof l!="string"||!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(l))return l;let{r:u,g:d,b:c}=Ks.fromHex(parseInt(l.slice(1,7),16)),p=l.length===9?parseInt(l.slice(7),16)/255:void 0;if(Array.isArray(h))return h.length>3?[u,d,c,p??h[3]]:[u,d,c];let m=h;return typeof m?.r!="number"?l:typeof m.a=="number"?{r:u,g:d,b:c,a:p??m.a}:{r:u,g:d,b:c}}function a(l){let h=l?.data;return typeof h=="object"&&h!==null}function o(l,h="layer1",u="layer2",d=Ks.fromHex(16777215)){let c=new ce;return c.push({fi:0,data:Bs.defaultData("light",l),id:h}),c.push({fi:1,data:Bs.defaultData("color"),id:u}),{layers:c}}s.restoreImageBytes=function(l){let h=[],u=new Map,d=(p,m)=>{let f=Jw(p);if(typeof f!="object"||f===null||ArrayBuffer.isView(f))return p;if(u.has(f))return u.get(f)??p;u.set(f,void 0);let g=c(f,m)??p;return u.set(f,g),g},c=(p,m)=>{let f=p;if(!Array.isArray(p)){if(typeof f[0]=="number")return;if(typeof f.name=="string"){let y=D4.bytesFromFlattened(Jw(f.data));if(y!==null)return h.push({path:`${m}/data`,bytes:y.byteLength}),Object.setPrototypeOf({...f,data:y},Object.getPrototypeOf(p))}}let g=null;for(let y of Object.keys(p)){let v=f[y],b=d(v,`${m}/${y}`);b!==v&&(g===null&&(g=Array.isArray(p)?[...p]:{...f},Object.setPrototypeOf(g,Object.getPrototypeOf(p))),g[y]=b)}return g??void 0};return{material:d(l,""),restored:h}},s.restoreLayersSeq=function(l){let h=Jw(l.layers);if(!Array.isArray(h)||h instanceof ce||!h.every(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.data=="object"))return{material:l,restored:!1};let u=Object.setPrototypeOf([...h],ce.prototype),d=Jw(l);return{material:Object.setPrototypeOf({...d,layers:u},Object.getPrototypeOf(d)),restored:!0}},s.isMergable=function(l){return!l.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="dust"&&h.data.noiseStrength!==0||h.data.type==="displace")},s.getHash=function(l){let h="";return l.layers.forEach(u=>{Object.entries(u.data).forEach(([d,c])=>{h+=`${d}${c}`,Array.isArray(c)?c.forEach(p=>h+=`${p}`):typeof c=="object"?Object.values(c).forEach(p=>{h+=typeof p=="number"?`${p.toFixed(4)}`:`${p}`}):h+=`${c}`})}),h},s.defaultEmptyData=function(){return{layers:new ce}},s.defaultData=function(l="layer1",h="layer2"){return o("physical",l,h)},s.withName=function(l,h){return{...l,name:h}},s.isLayerEntry=a,s.withRepairedLayers=function(l){if(l.layers===void 0)return{...l,layers:o("phong").layers};let h=Array.from(l.layers);if(h.every(a))return l;let u=new ce;return h.forEach((d,c)=>{if(a(d))return void u.push(d);let{id:p,fi:m,...f}=d??{};if(typeof f.type!="string"||!DI.is(f.type))return;let g=Bs.defaultDataFor(f.type,f.category),y={...g,...f};for(let[v,b]of Object.entries(f)){let _=g[v];y[v]=Array.isArray(b)&&Array.isArray(_)&&Array.isArray(_[0])?b.map(x=>n(x,_[0])):n(b,_)}u.push({id:typeof p=="string"&&p?p:`layer${c+1}`,fi:typeof m=="number"?m:c,data:y})}),{...l,layers:u}},s.defaultTwoLayerData=o,s.defaultColorMaterial=function(l,h,u="layer1",d="layer2"){let c=new ce;return c.push({fi:0,data:Bs.defaultData("light",h),id:u}),c.push({fi:1,data:Bs.defaultColorLayer(l),id:d}),{layers:c}},s.defaultUIObjectMaterial=function(l){let h=Bs.defaultData("texture");l&&Object.assign(h.texture,{image:l});let u=new ce;return u.push({fi:0,data:h,id:"layer1"}),u.push({fi:1,data:{...Bs.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...Bs.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}},s.defaultTwoLayerTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Bs.defaultData("texture");Object.assign(c.texture,{image:l});let p=new ce;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Bs.defaultData("light",h),id:d}),{layers:p}},s.defaultTwoLayerVideoTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Bs.defaultData("video");Object.assign(c.texture,{video:l});let p=new ce;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Bs.defaultData("light",h),id:d}),{layers:p}}})(ls||(ls={}))}),p3t=j(()=>{C1="Roboto_regular",Aft="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),m3t=j(()=>{p3t()}),Bft=j(()=>{var t;Ui(),(t=Vv||(Vv={})).defaultData=function(){return{points:new ce,roundness:0,shapeHoles:[],isClosed:!1}},t.scaled=function e(i,r,s){let n=a=>[a[0]*r,a[1]*s];return{...i,points:new ce(...i.points.map(({id:a,fi:o,data:l})=>({id:a,fi:o,data:{...l,position:n(l.position),controlPrevious:{position:n(l.controlPrevious.position)},controlNext:{position:n(l.controlNext.position)}}}))),shapeHoles:i.shapeHoles.map(a=>e(a,r,s))}}}),kft=j(()=>{Ui(),(I4||(I4={})).defaultData=function(){return{points:new ce,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},wg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(GU||(GU={})).merge=function(t,e){let i={...t};return N4.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},UG={shape:wg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},N4=["depth","offset","angle","twist","startScale","endScale"]}),GG=j(()=>{var t,e;Bft(),kft(),(t=B4||(B4={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},t.isParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"||i==="DecalGeometry"},t.isSwappableGeometry=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"},(k4||(k4={})).merge=function(i,r){let s={...i};if(Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,GU.merge(s.extrusion,r.extrusion))),i.type==="VectorGeometry"&&s.type==="VectorGeometry"){let n=(l,h)=>typeof l=="number"&&typeof h=="number"&&h!==0?l/h:1,a=n(s.width,i.width),o=n(s.height,i.height);(a!==1||o!==1)&&(s.shape=Vv.scaled(i.shape,a,o))}return s},(e=dc||(dc={})).defaultData=function(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:I4.defaultData(),extrusion:UG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Vv.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="DecalGeometry")return{type:i,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")},XP=["width","height","depth"]}),Vft=j(()=>{qo(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:Ks.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let r=e(i);return r==="height"?1:r==="both"?2:0},t.getDensity=function(i){return i.density??t.defaultData.density},t.getHeightFalloff=function(i){return i.heightFalloff??t.defaultData.heightFalloff},t.getHeightBase=function(i){return i.heightBase??t.defaultData.heightBase}})(ea||(ea={}))}),WG=j(()=>{(II||(II={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Qp||(Qp={})).defaultData={enabled:!1,mode:"hdri",hdri:II.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function f3t(t){let e=typeof t=="string"?Number.parseInt(t,10):t;return typeof e=="number"&&Number.isFinite(e)?Math.min(5,Math.max(0,Math.round(e))):3}var V4,pv,NI,BI,kI,mv,VI,WU,qU,NY,U0,zft,on,z4,BY,kY,VY,zY,ku,rS,L4,F4,_c,Hg,LY,am,U4,xc,zI,LI,Pg,s0,Rg,sS,HU,FY,Da,FI,UY,jY,cc,Jl,fv,Lft=j(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(V4||(V4={})).defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})()}),qG=j(()=>{var t;Vft(),WG(),Lft(),qo(),(t=pv||(pv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(NI||(NI={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(BI||(BI={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(kI||(kI={})),(mv||(mv={})).defaultData={usePhysics:!1,gravity:-10},(VI||(VI={})).defaultData={playCamera:l0,gameControlObject:null},(WU||(WU={})).defaultData={backgroundColor:Hi.fromHexAndA(Mft,1),postprocessing:V4.defaultData,fog:ea.defaultData,sky:Qp.defaultData,globalPhysics:mv.defaultData,ambient:NI.defaultData,ao:BI.defaultData,shadow:pv.defaultData,publish:VI.defaultData,grading:kI.defaultData}}),g3t=j(()=>{(qU||(qU={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),eD=j(()=>{var t,e,i;Ui(),Cft(),Pft(),Rft(),Dft(),jG(),Oft(),qo(),hT(),GG(),Eft(),un(),qG(),g3t(),(t=NY||(NY={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=U0||(U0={})).identity={...NU.identity,shear:wl.zero},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,shear:r.shear}},e.merge=function(r,s){return{position:s?.position||r.position,rotation:s?.rotation||r.rotation,pivot:s?.pivot||r.pivot,pivotRotation:s?.pivotRotation||r.pivotRotation,scale:s?.scale||r.scale,shear:s?.shear||r.shear}},e.diff=function(r,s){return sft({position:ym.isEqual(r.position,s.position)?void 0:s.position,rotation:ym.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:ym.isEqual(r.scale,s.scale)?null:s.scale,shear:s.shear?.every((n,a)=>n===r.shear?.[a])?void 0:s.shear})},zft=["slide","offset"],(on||(on={})).defaultData={states:new ce,events:new ce,visible:!0,raycastLock:!1,physics:cv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...U0.identity,cloner:null},(z4||(z4={})).defaultData={type:"Empty",...on.defaultData},(BY||(BY={})).defaultData={type:"ParticleCollider",...qU.defaultData,...on.defaultData},(kY||(kY={})).defaultData={type:"Component",...on.defaultData},(VY||(VY={})).defaultData={type:"Particle",...on.defaultData,...R4.defaultData},(zY||(zY={})).defaultData={type:"Hair",...on.defaultData,...FU.defaultData},(ku||(ku={})).defaultData={type:"Mesh",...on.defaultData,...UU.defaultData},(rS||(rS={})).defaultData={...on.defaultData,...U0.identity,position:bc.DefaultPosition,rotation:bc.DefaultRotation,...bc.defaultData},(r=>{r.defaultData=function(s){return{...on.defaultData,...LU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(L4||(L4={})),(r=>{function s(n,a,o=0){for(;o<a.length;){let l=n?n[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;n=l.descendants,o+=1}}r.resolveWithDes=s,r.resolve=function(n,a,o=0){let l=s(n,a,o);if(l){let h=Object.keys(l);if(h.length===1&&h[0]==="descendants")return}return l}})(F4||(F4={})),(r=>{function s(n,a){return{...on.defaultData,...a,component:n,overrides:new Es,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=s,r.fromComponentData=function(n){let a=U0.fromObject(n.data);return s(n.id,a)}})(_c||(_c={})),(r=>{r.defaultData={type:"Page",...on.defaultData,physics:{...cv.defaultData,fusedBody:!1},...WU.defaultData,camera:rS.defaultData,timelines:new ke},r.isUIPage=function(s){return s.uiScene!==void 0}})(Hg||(Hg={})),(i=LY||(LY={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],shear:wl.zero,name:"Play Camera",visible:!0,raycastLock:!1,physics:cv.defaultData,states:new ce,events:new ce,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...bc.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","shear"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("RectangleGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("BooleanGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("ShapeBlendGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("TextGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...on.defaultData,...ku.defaultData,geometry:dc.defaultData("InputGeometry"),material:ls.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(s,n){let a={name:n};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Es}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new Es})))):r0.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function h(u,d){for(let[c,p]of Object.entries(d.layers)){let{texture:m,...f}=p;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...u,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...u,"layers",c],props:f,type:0};o.push(g)}}}for(let[u,d]of Object.entries(n)){let c=d;if(u!=="name")if(u==="cloner")o.push(...kU.toOps(c,["cloner"]));else if(u==="pathSnapping")o.push({path:[u],props:{slide:c.slide,offset:c.offset},type:0});else if(u==="material")h(["material"],c);else if(u==="materials")for(let[p,m]of Object.entries(c))h(["materials",p],m);else if(l[u]===0){if(u==="geometry"&&c.extrusion!==void 0){let p={path:[u,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[u],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[u]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,U0.merge(a,n)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:n.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??a.pathSnapping?.offset??0})}),r0.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=n;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(a,{geometry:k4.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let h={...o};return"material"in h&&"material"in l&&l.material&&(h.material=_4(h.material,u=>{if(typeof u!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=u.layers.data(d);p&&Bs.patch(p,c)}}).data),h.materials&&l.materials&&(h.materials=_4(h.materials,u=>{for(let d=0;d<h.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=u[d]?.layers?.data(p);f&&Bs.patch(f,m)}}}).data),h}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:nm.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:nm.merge(a.cloner,n.cloner)});else if(zU.is(s.type)){let o=n;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=Ks.clone(o.color))}return a}})(am||(am={}))}),HG=j(()=>{(U4||(U4={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),iD=j(()=>{HG(),qo(),(xc||(xc={})).defaultData={orbitControls:U4.defaultData,playPage:dv,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,r=0;return e<5?r=-30:e<10&&(r=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,r],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu",asyncShaderCompilation:!0}}),Fft=j(()=>{var t;(zI||(zI={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(LI||(LI={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=Pg||(Pg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...zI.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:LI.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),$G=j(()=>{eD(),Ui(),iD(),qo(),un(),Fft(),(t=>{function e(i,r){let s=i.scene.objects.get(r);if(s&&s.data.type==="Component")return s;{let n=i.shared.lib.components[r];if(n)return{...n.asset,id:r}}}t.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,r){let s=i.find(n=>n.data.type==="Page"&&n.data.timelines?.[r]!==void 0);return s&&s.data.timelines?.[r]},t.getComponentData=e,t.traverseModuleInstances=function(i,r,s){i.scene.objects.traverseFrom(r,(n,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&s(n,a,o.events)}else s(n,a,a.events)})}})(s0||(s0={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new Nn;return a.push({fi:1,id:dv,data:{...Hg.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:$a(r,Nn.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:L4.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:xc.defaultData,styles:Pg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new Nn,publish:xc.defaultData,styles:Pg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:xc.defaultData,styles:Pg.defaultData()}},t.emptyData=function(){return{objects:new Nn,publish:{...xc.defaultData},styles:Pg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(Rg||(Rg={}))}),Uft=j(()=>{(sS||(sS={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),XG=j(()=>{var t,e;Ui(),un(),(t=HU||(HU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ce}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(FY||(FY={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ce,queries:new ce,autoStart:!0}),(i=>{function r(n){return n.textValue!==void 0}function s(n){return typeof n=="boolean"}i.isTextValue=r,i.isNumber=function(n){return typeof n=="number"},i.isBoolean=s,i.typeOfVariable=function(n){return r(n)?"string":s(n)?"boolean":"number"},i.getDisplayedValue=function(n){return i.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(a=>a.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():i.isBoolean(n)?n?"True":"False":i.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}})(Da||(Da={})),(FI||(FI={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(UY||(UY={})).all=[...FI.all,"components"],(jY||(jY={})).defaultData=function(){return{images:new ke,videos:new ke,colors:new ke,audios:new ke,particles:new ke,fonts:new ke,materials:new ke,components:new ke,variables:new ke,userAPIs:new ke,userWebhooks:new ke}},(cc||(cc={})).defaultData=function(){return{images:new ke,videos:new ke,colors:new ke,audios:new ke,particles:new ke,fonts:new ke,materials:new ke,components:new ke,variables:new ke,userAPIs:new ke,userWebhooks:new ke}},(e=Jl||(Jl={})).defaultColors=function(){return $a({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},ke.prototype)},e.defaultImages=function(){return $a({},ke.prototype)},e.emptyData=function(){return{catelogs:new ke,materials:new ke,images:new ke,videos:new ke,colors:new ke,audios:new ke,particles:new ke,fonts:new ke,variables:new ce,userAPIs:new ke,userWebhooks:new ke,lib:cc.defaultData()}},e.defaultVariables=function(i){switch(i){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let r=[0,0,0];return{name:"Time",value:{textValue:r,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:r,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",i)}},e.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let s=Math.floor(i/3600),n=Math.floor((i-3600*s)/60);return{textValue:[s,n,Math.round(i-3600*s-60*n)]}}if(r.format==="mm:ss"){let s=Math.floor(i/60);return{textValue:[s,Math.round(i-60*s)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),y3t=j(()=>{}),jft=j(()=>{var t;Ui(),$G(),Uft(),XG(),(t=fv||(fv={})).defaultData={schema:135,scene:Rg.defaultData,frames:new ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sS.defaultData),shared:{...Jl.emptyData(),colors:Jl.defaultColors()}},t.createDefaultData=function(){return FS.deserialize(FS.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:135,scene:Rg.emptyDataWithPage(),frames:new ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sS.defaultData),shared:{...Jl.emptyData(),colors:Jl.defaultColors(),images:Jl.defaultImages()}}},t.emptyData=function(){return{schema:135,scene:Rg.emptyDataWithPage(),frames:new ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",sS.defaultData),shared:Jl.emptyData()}},t.clipboard2dData=function(){return{schema:135,scene:Rg.emptyData(),frames:new ke,shared:Jl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:cc.defaultData()}}},t.getComponentData=function(e,i){return s0.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let r of i){let s=r.headers;for(let n of s)if(n.data.key.toLowerCase()==="authorization"&&n.data.value!=="")return!0}return!1}});function Pc(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function u_(t,e,i){switch(t){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:r,control2:s}=e??{...kv.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...sm.defaultData},o=new Gft(r,s,n,a),l=o.solve(1);return()=>h=>o.solve(h)/l}case 8:return()=>r=>Math.floor(r)}}var GY,WY,vm,jS,Gft,j4,G4,YG=j(()=>{Ui(),qo(),(GY||(GY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new ke}},(WY||(WY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(u,d){let c=[0,0],p=[1,1];if(u?.cubicControls)c=Pc(u.cubicControls.control1,c);else switch(u?.type){case 2:case 4:c=[.42,0];break;case 3:case 0:c=[0,0];break;case 1:c=[.25,.1];break;case 7:c=[.25,1]}if(d?.cubicControls)p=Pc(d.cubicControls.control2,p);else switch(d?.type){case 2:case 0:p=[1,1];break;case 3:case 4:p=[.58,1];break;case 1:p=[.25,1];break;case 7:p=[.5,1]}return{control1:c,control2:p}}function i(u){if(!t.BEZIER_PRESETS.includes(u))return;let d={type:u};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(u,d){return Math.abs(u[0]-d[0])<.001&&Math.abs(u[1]-d[1])<.001}function s(u){let d=t.ROOT_PROPERTY_ORDER.indexOf(u[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(u){return u.layerId??u.path.join(".")}function a(u){let d=u[u.length-1];return jS.includes(d)?d:void 0}function o(u){return u.layerId?u.layerId:(a(u.path)?u.path.slice(0,-1):u.path).join(".")}function l(u){return["material",u.type==="light"?`${u.category} lighting`:u.type]}function h(u,d,c){return{id:u,data:{id:u,time:c?.time??0,path:d,value:{},layerId:c?.layerId,index:c?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}t.getControlsWithDefault=e,t.BEZIER_PRESETS=[0,1,2,3,4,7],t.presetHandles=i,t.presetForHandles=function(u){return t.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,u.control1)&&r(c.control2,u.control2)})},t.defaultData=function(u){return{id:u,keyframes:new ce}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=s,t.propertyKey=n,t.groupKeyframes=function(u,d){let c=new Map;for(let p of u){let m=p.data;if(d?.(m))continue;let f=n(m),g=c.get(f);g||(g={id:f,path:m.path,keyframes:[],layerId:m.layerId,index:m.index},c.set(f,g)),m.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,m)=>{let f=s(p.path)-s(m.path);return f!==0?f:(p.index??0)-(m.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(u){let d=new Map;for(let c of u){let p=a(c.path),m=p?c.path.slice(0,-1):c.path,f=o(c),g=d.get(f);g||(g={id:f,path:m,layerId:c.layerId,index:c.index,tracks:[]},d.set(f,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},t.sortedKeyframes=function(u){return[...u].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(u,d){return u.map(({data:c,id:p},m)=>h(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=h,t.createName=function(u){return Object.entries(u).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:u_(3),duration:1e3},opacity:{value:[0,1],easing:u_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:u_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:u_(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:u_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(vm||(vm={})),jS=["x","y","z"],Gft=class{constructor(t=1,e=100,i=10,r=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(e/t),this.m_zeta=i/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(t){return 1-(this.m_zeta<1?Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0))}getDuration(){let t=.16666666666666666,e=0,i=0;for(;;)if(e+=t,this.solve(e)===1){if(i++,i>=16)break}else i=0;return e*t*1e3}}}),KG=j(()=>{var t;qo(),Ui(),(j4||(j4={})).list=["idle","move","jump","run"],(t=G4||(G4={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ce,move:new ce,jump:new ce,run:new ce},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Hi.fromHexAndA(3728051,1)}}});function dg(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function qY(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,r=e.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...dg(Ns(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,a)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let i={...Ns(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Jd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function tc(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=ls.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ls.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ls.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Es.prototype&&e(s.material)})})}function HY(t){t.layers===void 0&&Object.assign(t,ls.defaultTwoLayerData("lambert"))}function UI(t){!t.layers||t.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let i=[...e.colors];i.push(e.colors[9]);let r=[...e.steps];r.push(e.steps[9]);let s={...Ns(e),colors:i,steps:r};Object.assign(e,s)}})}function $Y(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&UI(r)}):"material"in i&&typeof i.material!="string"&&UI(i.material)}),Object.values(t.shared.materials).forEach(e=>UI(e))}function XY(t){t.layers&&t.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function YY(t){t.layers&&t.layers.forEach(e=>{(function(i){return i.type!=="displace"})(e)&&e.isMask===void 0&&(e.isMask=!1),(e.type==="texture"||e.type==="video")&&e.blending===void 0&&(e.blending=0),(e.type==="noise"||e.type==="displace"&&e.displacementType==="noise")&&(e.voronoiStyle===void 0&&(e.voronoiStyle=0),e.highCut===void 0&&(e.highCut=1),e.lowCut===void 0&&(e.lowCut=0),e.smoothness===void 0&&(e.smoothness=.3),e.seed===void 0&&(e.seed=0),e.quality===void 0&&(e.quality=1))})}function KY(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Bs.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function ZY(t){Jd(t,KY),tc(t,KY)}function QY(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function JY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var v3t=j(()=>{hT(),qo(),HG(),eD(),Ui(),iD(),un(),ht(),GG(),KG(),Fft(),$G(),jG(),qG()});function Wft(t){let e=t.elements;jh.set(e[0],e[1],e[2]),Gh.set(e[4],e[5],e[6]),zu.set(e[8],e[9],e[10])}function qft(){let t=Math.max(jh.lengthSq(),Gh.lengthSq(),zu.lengthSq());jh.lengthSq()>i2*t?gl.copy(jh).normalize():gl.set(1,0,0),yl.crossVectors(zu,gl),yl.lengthSq()<=i2*t&&(yl.copy(Gh).addScaledVector(gl,-Gh.dot(gl)),yl.lengthSq()<=i2*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=i2&&e.set(0,1,0).cross(i),e.normalize()}(yl,gl)),yl.normalize(),Dg.crossVectors(gl,yl)}function Hft(t,e,i){return Wft(t),qft(),e.makeBasis(gl,yl,Dg),i.set(gl.dot(jh),gl.dot(Gh),gl.dot(zu),0,yl.dot(jh),yl.dot(Gh),yl.dot(zu),0,Dg.dot(jh),Dg.dot(Gh),Dg.dot(zu),0,0,0,0,1),function(){let r=jh.length(),s=Gh.length(),n=zu.length(),a=Math.max(r,s,n);if(a-r>r2||a-s>r2||a-n>r2)return!0;let o=r2*a*a;return Math.abs(jh.dot(Gh))>o||Math.abs(jh.dot(zu))>o||Math.abs(Gh.dot(zu))>o}()}function $ft(t){return Wft(t),qft(),Xft.makeBasis(gl,yl,Dg)}var jh,Gh,zu,gl,yl,Dg,Xft,i2,r2,rD=j(()=>{ht(),jh=new P,Gh=new P,zu=new P,gl=new P,yl=new P,Dg=new P,Xft=new xt,i2=1e-12,r2=.01});function j0(t,e){return e===0?0:t/e}function ZG(t){Hft(t,XU,$U),K1.setFromRotationMatrix(XU);let e=function(r,s,n){let a=2*Math.PI,o=d=>d-a*Math.round(d/a),l=o(r+Math.PI),h=o(Math.PI-s),u=o(n+Math.PI);return Math.abs(l)+Math.abs(u)<Math.abs(r)+Math.abs(n)-1e-9?[l,h,u]:[r,s,n]}(K1.x,K1.y,K1.z),i=$U.elements;return{position:[t.elements[12],t.elements[13],t.elements[14]],rotation:[e[0]*Ft.RAD2DEG,e[1]*Ft.RAD2DEG,e[2]*Ft.RAD2DEG],scale:[i[0],i[5],i[10]],shear:[j0(i[4],i[5]),j0(i[8],i[10]),j0(i[1],i[0]),j0(i[9],i[10]),j0(i[2],i[0]),j0(i[6],i[5])]}}function wc(t,{translation:e,quaternion:i,scale:r,shearMatrix:s}={}){let n=ZG(t);if(e!==void 0&&e.fromArray(n.position),i!==void 0){let a=n.rotation;i.setFromEuler(K1.set(a[0]*Ft.DEG2RAD,a[1]*Ft.DEG2RAD,a[2]*Ft.DEG2RAD))}r!==void 0&&r.fromArray(n.scale),s!==void 0&&s.fromArray(wl.toMatrix(n.shear))}var $U,XU,K1,uT=j(()=>{ht(),rD(),Cgt(),$U=new xt,XU=new xt,K1=new Fi});function Yft(t){return t.length>=4&&function(e){return typeof e=="object"&&e!==null&&e.v===1&&e.data instanceof Float32Array&&Array.isArray(e.tracks)}(t[3])}function Kft(t,e,i){let r={name:e,duration:i.duration,tracks:[],uuid:t};return i.blendMode!==void 0&&(r.blendMode=i.blendMode),JSON.stringify(r)}function b3t(t,e,i){for(let r=0;r<i.length;r++)if(!Object.is(t[e+r],i[r]))return!1;return!0}function _3t(t){if(!Array.isArray(t)||t.length>3)return t;let e,[i,r,s]=t;if(typeof i!="string"||typeof s!="string")return t;try{e=JSON.parse(s)}catch{return t}return e&&Array.isArray(e.tracks)&&!e.tracks.some(n=>!n?.type||!n.times||!n.values)?function(n,a,o){let l=[],h=0,u=g=>{let y=[h,g.length];return l.push(g),h+=g.length,y},d=new Map,c=o.tracks.map(g=>{let y=(_=>{let x=Float32Array.from(_),S=x.length+":"+x[0]+":"+x[x.length-1],w=d.get(S)??[];for(let C of w)if(b3t(C.run,0,x))return C.span;let T=u(x);return w.push({span:T,run:x}),d.set(S,w),T})(g.times),v=!Zft.has(g.type),b={name:g.name,type:g.type,times:y,values:v?u(Float32Array.from(g.values)):[0,0]};return v||(b.list=Array.from(g.values)),g.interpolation!==void 0&&(b.interpolation=g.interpolation),b}),p=new Float32Array(h),m=0;for(let g of l)p.set(g,m),m+=g.length;let f={v:1,duration:o.duration,data:p,tracks:c};return o.blendMode!==void 0&&(f.blendMode=o.blendMode),o.userData!==void 0&&o.userData!=="{}"&&(f.userData=o.userData),[n,a,Kft(n,a,f),f]}(i,typeof e.name=="string"?e.name:r,e):t}function x3t(t,e,i){return t.map(r=>{let s=e();return i[r[0]]=s,function(n,a){let[o,l,h]=n;if(Yft(n))return[a,l,Kft(a,l,n[3]),n[3]];let u=h.indexOf(o);return[a,l,u!==-1?h.slice(0,u)+a+h.slice(u+o.length):h,...n.slice(3)]}(r,s)})}var Zft,Qft=j(()=>{Zft=new Set(["bool","string"])});function NM(t,[e,i]){return Math.min(Math.max(t,e),i)}function Jft(t,e,i,r,s){t=NM(t,sgt),e=NM(e,ngt),i=NM(i,agt),r=NM(r,ogt);let n=Math.sqrt(e/t),a=i/(2*Math.sqrt(e*t)),o=a<1?n*Math.sqrt(1-a*a):0,l=a<1?(a*n-r)/o:-r+n;return h=>{let u=s!==void 0?s*h:h;return u=a<1?Math.exp(-u*a*n)*(1*Math.cos(o*u)+l*Math.sin(o*u)):(1+l*u)*Math.exp(-u*n),h===0||h===1?h:1-u}}function tgt(t,e){return ri(ri(1-ri(3*e))+ri(3*t))}function egt(t,e){return ri(ri(3*e)-ri(6*t))}function igt(t){return ri(3*t)}function BM(t,e,i){return ri(ri(ri(ri(ri(tgt(e,i)*t)+egt(e,i))*t)+igt(e))*t)}function tK(t,e,i){let r=ri(ri(ri(3*tgt(e,i))*t)*t),s=ri(ri(2*egt(e,i))*t);return ri(ri(r+s)+igt(e))}function G0(t,e,i,r){if(t=ri(t),e=ri(e),i=ri(i),r=ri(r),t<0||t>1||i<0||i>1||t===e&&i===r)return cgt;let s=new Float32Array(YP);for(let n=0;n<YP;n++)s[n]=BM(ri(n*s2),t,i);return n=>(n=ri(n))===0||n===1?n:BM((a=>{let o=0,l=1,h=YP-1;for(;l!==h&&s[l]<=a;)o=ri(o+s2),l+=1;l-=1;let u=ri(ri(a-s[l])/ri(s[l+1]-s[l])),d=ri(o+ri(u*s2)),c=tK(d,t,i);return c>=hgt?function(p,m,f,g){for(let y=0;y<lgt;y++){let v=tK(m,f,g);if(v===0)return m;let b=ri(BM(m,f,g)-p);m=ri(m-ri(b/v))}return m}(a,d,t,i):c===0?d:function(p,m,f,g,y){let v,b=0,_=0;do b=ri(m+ri(ri(f-m)/2)),v=ri(BM(b,g,y)-p),v>0?f=b:m=b,_+=1;while(Math.abs(v)>ugt&&_<dgt);return b}(a,o,ri(o+s2),t,i)})(n),e,r)}function rgt(t,e,i){switch(t.easing){case 0:default:return i;case 1:return G0(.25,.1,.25,1)(i);case 2:return G0(.42,0,1,1)(i);case 3:return G0(0,0,.58,1)(i);case 4:return G0(.42,0,.58,1)(i);case 7:return G0(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:r,control2:s}=t;return r&&s?G0(r[0],r[1],s[0],s[1])(i):i}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=t;return r===void 0||s===void 0||n===void 0||a===void 0?i:ri(Jft(r,s,n,a,e)(i))}}}var ri,sgt,ngt,agt,ogt,lgt,hgt,ugt,dgt,YP,s2,cgt,eK,w3t=j(()=>{ri=Math.fround,sgt=[.01,100],ngt=[.01,1e4],agt=[.01,1e3],ogt=[.01,1e3],lgt=4,hgt=ri(.001),ugt=ri(1e-7),dgt=10,s2=ri(1/((YP=11)-1)),cgt=t=>t,eK=ri(1.70158),ri(eK+1)});function pgt(t,e){if(t.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(e<=t[0].time)return{index0:0,index1:0,t:1};let{found:i,index:r}=function(h,u){let d=h.length,c=0,p=d;for(;c<p;){let m=c+Math.floor(d/2),f=h[m].time;if(f<u)c=m+1;else{if(!(f>u))return{found:!0,index:m};p=m}d=p-c}return{found:!1,index:c}}(t,e);if(i)return{index0:r,index1:r,t:1};if(r>=t.length){let h=t.length-1;return{index0:h,index1:h,t:1}}let s=r-1,n=r,a=t[s].time,o=t[n].time;if(o===a)return{index0:s,index1:n,t:.5};let l=KP(o-a);return{index0:s,index1:n,t:rgt({...t[s].ease,control2:t[n].ease.control2},l,KP(KP(e-a)/l))}}function mgt(t){return[...t].sort((e,i)=>e.time-i.time)}var KP,S3t=j(()=>{w3t(),KP=Math.fround});function T3t(t){if(t?.length!==2)return;let e=`${t[0]}.${t[1]}`;return QG.includes(e)?e:void 0}function fgt(t){return t.slice(0,t.indexOf("."))}function ggt(t){return bm.indexOf(t.slice(-1))}function M3t(t){return{easing:t?.type,control1:Pc(t?.cubicControls?.control1,[0,0]),control2:Pc(t?.cubicControls?.control2,[1,1]),...t?.springParameters}}function A3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function iK(t,e,i){let r=fgt(t);if(r==="position"){let s=ggt(t);return bm.flatMap((n,a)=>Math.abs(e.elements[4*a+s])>1e-9?[`position.${n}`]:[])}return(i?[r]:["rotation","scale"]).flatMap(s=>bm.map(n=>`${s}.${n}`))}function C3t(t,e){let[i,r,s]=t,n=[[i,r,s],[i+180,180-r,s+180]],a=[i,r,s],o=1/0;for(let l of n){let h=l.map((d,c)=>d+360*Math.round((e[c]-d)/360)),u=h.reduce((d,c,p)=>d+Math.abs(c-e[p]),0);u<o-1e-9&&(a=h,o=u)}return a}function E3t(t,e,i){if(t==="rotation"){let r=((e-i)%360+540)%360-180;return Math.abs(r)<1e-6}return Math.abs(e-i)<1e-9*Math.max(1,Math.abs(e),Math.abs(i))}function P3t(t,e,i,r){let s=new Map;for(let{id:p,data:m}of t.unproxy()){if(m.isPlaceholder)continue;let f=T3t(m.path);if(!f){if(n2.includes(m.path?.[0]))return;continue}if(typeof m.value!="number"||!Number.isFinite(m.value))return;let g=s.get(f)??{keys:[],sampled:[]};g.keys.push({id:p,time:m.time,value:m.value,keyframe:m}),s.set(f,g)}if(s.size===0)return;for(let p of s.values())p.keys.sort((m,f)=>m.time-f.time),p.sampled=mgt(p.keys.map(m=>({time:m.time,ease:M3t(m.keyframe.easing),value:m.value})));let n=(p,m)=>{let f=s.get(p);return f?function(g,y){let{index0:v,index1:b,t:_}=pgt(g.sampled,y),x=g.sampled[v].value;return x+(g.sampled[b].value-x)*_}(f,m):i[fgt(p)][ggt(p)]},a=new Te,o=new Fi,l=new xt,h=new P,u=new P,d=p=>{let m=(f=>{let g={};for(let y of n2)g[y]=bm.map((v,b)=>n(QG[3*n2.indexOf(y)+b],f));return g})(p);return o.set(m.rotation[0]*Ft.DEG2RAD,m.rotation[1]*Ft.DEG2RAD,m.rotation[2]*Ft.DEG2RAD),l.compose(h.fromArray(m.position),a.setFromEuler(o),u.fromArray(m.scale)).premultiply(e),{pose:m,out:ZG(l)}},c=function(p){let m=p.elements,f=[0,4,8].map(v=>new P(m[v],m[v+1],m[v+2])),g=f[0].lengthSq(),y=1e-9*Math.max(1,g);return Math.abs(f[1].lengthSq()-g)<y&&Math.abs(f[2].lengthSq()-g)<y&&Math.abs(f[0].dot(f[1]))<y&&Math.abs(f[0].dot(f[2]))<y&&Math.abs(f[1].dot(f[2]))<y}(e);for(let p of n2){let m,f=bm.map(b=>`${p}.${b}`),g=b=>{let _=new Set;for(let x of iK(b,e,c))for(let S of s.get(x)?.keys??[])_.add(S.time);return[..._].sort((x,S)=>x-S)},y=[...new Set(f.flatMap(b=>g(b)))].sort((b,_)=>b-_),v=new Map;for(let b of y){let{pose:_,out:x}=d(b),S=[...x[p]];p==="rotation"&&(S=C3t(S,m?m.out.map((w,T)=>w+_.rotation[T]-m.in[T]):_.rotation),m={in:_.rotation,out:S}),v.set(b,S)}f.forEach((b,_)=>{let x=s.get(b)?.keys??[],S=g(b),w=new Set(S);if(x.length!==0||!S.every(T=>E3t(p,v.get(T)[_],r[p][_]))){for(let T of x)w.has(T.time)||t.delete(T.id);for(let T of S){let C=v.get(T)[_],M=x.find(I=>I.time===T);if(M){let I=t.data(M.id);I&&(I.value=C);continue}let A=iK(b,e,c).sort((I,O)=>Number(O===b)-Number(I===b)).map(I=>s.get(I)?.keys.find(O=>O.time===T)).find(I=>I!==void 0),R=Ft.generateUUID();t.insertBefore(null,[{id:R,data:{id:R,time:T,path:[p,bm[_]],value:C,easing:A3t(A.keyframe.easing),index:vm.rowOrder([p])}}])}}})}}var n2,bm,QG,R3t=j(()=>{ht(),YG(),S3t(),uT(),bm=["x","y","z"],QG=(n2=["position","rotation","scale"]).flatMap(t=>bm.map(e=>`${t}.${e}`))}),ygt={};function rK(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function vgt(t){let e=t.geometry;e!==void 0&&Tgt.has(e.type)&&e.extrusionVersion===void 0&&(e.extrusionVersion=1)}function bgt(t){if(t.type!=="Empty")return;let e=Ns(t.animations);if(!Array.isArray(e))return;let i=e.map(_3t);i.some((r,s)=>r!==e[s])&&(t.animations=i)}function sK(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),u=Math.sin(s),d=[o*h,n*u+a*h*l,a*u-n*h*l],c=Math.hypot(e[0],e[1],e[2])||1;return Math.abs((d[0]*e[0]+d[1]*e[1]+d[2]*e[2])/c)}function _gt(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*kp)})(t),t.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(s,n){let a=Array.isArray(n)&&n.length>=3&&n.every(h=>typeof h=="number"&&Number.isFinite(h))?n:[0,1,0],o=sK(s,a),l=sK(s.map(h=>h*Mgt),a);return Math.abs(o-l)<1e-6?s.some(h=>Math.abs(h)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*kp)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*kp))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*kp),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*kp),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=kp,e.extrusion.twist*=kp),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(Ns(t.events))&&t.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function D3t(t){t.scene.objects.traverse((e,i)=>{})}function O3t(t){let e=t.schema??104;e!==135&&(e<130&&(JG(t.asset),t.schema=130),e<135&&(tW(t.asset),t.schema=135))}function Nu(t,e){e(t.data);for(let i of t.children)Nu(i,e)}function xgt(t){let e=t.schema??104;e!==135&&(e<105&&(Nu(t.asset,_gt),t.schema=105),e<118&&(Nu(t.asset,wgt),t.schema=118),e<121&&(Nu(t.asset,ZU),t.schema=121),e<130&&(Nu(t.asset,i=>nK(i,JG)),t.schema=130),e<132&&(Nu(t.asset,vgt),t.schema=132),e<133&&(Nu(t.asset,i=>Sgt(i,()=>{})),t.schema=133),e<134&&(Nu(t.asset,bgt),t.schema=134),e<135&&(Nu(t.asset,i=>nK(i,tW)),t.schema=135))}function YU(t,e){tc(t,e),Jd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function JG(t){t.layers===void 0&&Object.assign(t,ls.defaultTwoLayerData("phong"))}function tW(t){let e=Jw(t),i=ls.withRepairedLayers(e);i!==e&&(t.layers=i.layers)}function nK(t,e){"materials"in t?t.materials.forEach(i=>{i!==void 0&&typeof i!="string"&&e(i)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&e(t.material)}function wgt(t){t.timelineAnimations=$a({},ke.prototype)}function I3t(t){let e=[];return t?(t.forEach((i,r)=>{let{path:s,keyframes:n}=i.data,a=s[0]==="material"?i.id:void 0;n?.length?n.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:s,layerId:a,index:r}})}):e.push(vm.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ce(...e.map((i,r)=>({...i,fi:r})))):new ce}function N3t(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!Agt.includes(r))continue;let s=KU(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let h of l){let u=Ft.generateUUID();t.insertBefore(null,[{id:u,data:{...i,id:u,path:[r,h],value:a[h],easing:B3t(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function KU(t){return t===null||typeof t!="object"?[]:jS.filter(e=>e in t)}function B3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function k3t(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function V3t(t){let e=function(n){let a=[];for(let o of vm.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(u=>KU(u.data.value))),h=l.size?[...l].map(u=>o.keyframes.filter(d=>KU(d.data.value).includes(u))):[o.keyframes];for(let u of h){let d=[...u].sort((c,p)=>c.data.time-p.data.time);for(let c=0;c+1<d.length;c++)a.push({left:d[c],right:d[c+1]})}}return a}([...t.unproxy()]),i=new Map,r=new Set;for(let{left:n,right:a}of e){let o=n.data.easing?.type,l=(o===void 0?void 0:vm.presetHandles(o))?.control2??(o===5?Pc(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let h=i.get(a.id);h?k3t(h,l)||r.add(a.id):i.set(a.id,l)}let s=new Map;for(let{id:n,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:vm.presetHandles(o);l&&s.set(n,l.control1)}for(let{left:n,right:a}of e)r.has(a.id)&&s.delete(n.id);for(let[n,a]of s){let o=t.data(n);!o?.easing||(o.easing.cubicControls={control1:a,control2:Pc(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:n,right:a}of e){if(!s.has(n.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Pc(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function aK(t,e){t.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="Page"&&s.timelines)for(let n of Object.values(s.timelines))for(let a of Object.values(n.objectTimelines??{}))e(a.keyframes)})}function ZU(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function Sgt(t,e,i=[]){let r=["position","rotation","scale","shear"];function s(c,p,m){return c?.map(f=>typeof f=="string"?e(f)??m:f)??[...p]}function n(c,p){if(c&&!function(m){return m.every((f,g)=>Math.abs(f-(g%5==0?1:0))<1e-6)}(c))return ZG(new xt().fromArray(c).multiply(new xt().compose(new P().fromArray(p.position),new Te().setFromEuler(new Fi(p.rotation[0]*Ft.DEG2RAD,p.rotation[1]*Ft.DEG2RAD,p.rotation[2]*Ft.DEG2RAD)),new P().fromArray(p.scale))))}function a(c,p){return c.length===p.length&&c.every((m,f)=>m===p[f])}t.shear=wl.zero;let o=t,l=o.hiddenMatrix;l!==void 0&&delete o.hiddenMatrix;let h={position:s(o.position,[0,0,0],0),rotation:s(o.rotation,[0,0,0],0),scale:s(o.scale,[1,1,1],1)},u=n(l,h);if(u&&Object.assign(o,u),u){let c=new xt().fromArray(l);for(let p of i)P3t(p,c,h,u)}let d=u??{...h,shear:[...wl.zero]};o.states?.forEach(c=>{let p=c.hiddenMatrix;if(p!==void 0&&delete c.hiddenMatrix,p===void 0&&c.position==null&&c.rotation==null&&c.scale==null)return;let m={position:s(c.position,h.position,0),rotation:s(c.rotation,h.rotation,0),scale:s(c.scale,h.scale,1)},f=n(p??l,m);if(!u&&!f)return;let g=f??{...m,shear:[...wl.zero]};for(let y of r)(c[y]!=null||!a(g[y],d[y]))&&(c[y]=g[y])})}function z3t(t){}function L3t(t){let e=t.schema??0;if(e!==135){if(e>135)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 135). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",135),function(i,r){if(r<1&&(tc(i,qY),Jd(i,qY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{...U4.defaultData,...Ns(s.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(s){function n(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,h]of Object.entries(o))if((tD.includes(l)||typeof h=="boolean")&&delete o[l],l==="texture")for(let[u,d]of Object.entries(h))(FG.includes(u)||typeof d=="boolean")&&delete h[u]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let h=l;h.material?n(h.material):h.materials&&h.materials.forEach(u=>{n(u)})})})}(i),i.schema=3),r<4&&(function(s){s.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(s){s.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),r<7&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&($Y(i),i.schema=9),r<10&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(s){s.scene.environment.ambientLight.softShadows=!1,s.scene.environment.ambientLight.softShadowQuality="low",s.scene.objects.traverse((n,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),s.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&($Y(i),i.schema=12),r<13&&(function(s){s.shared.audios=$a({},ke.prototype)}(i),i.schema=13),r<14&&(function(s){let n=s.shared.materials;Object.entries(n).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(n,{[a]:l})}})}(i),i.schema=14),r<15&&(function(s){Object.entries(Ns(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(Ns(s.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.audios[n]})}(i),i.schema=15),r<16&&(function(s){s.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(tc(i,XY),Jd(i,XY),i.schema=17),r<18&&(tc(i,HY),Jd(i,HY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...xc.defaultData.settings.video,...Ns(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=$a({},ke.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let h=ls.defaultTwoLayerData("phong"),u=typeof l.color=="string"?s.shared.colors[l.color]:l.color;h.layers[1].data.color={r:u.r,g:u.g,b:u.b},h.layers[1].data.alpha=l.alpha;let d=function(m){return m.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}(l.font);s.shared.fonts[d]===void 0&&(s.shared.fonts[d]={name:d});let c={name:l.name,...on.defaultData,...ku.defaultData,flatShading:!1,wireframe:!1,geometry:{...dc.defaultData("TextGeometry"),width:l.width,height:l.height,font:d,depth:0,horizontalAlign:l.horizontalAlign,verticalAlign:l.verticalAlign,fontSize:1.40625*l.fontSize,lineHeight:l.lineHeight/1.40625,letterSpacing:l.letterSpacing-1,text:l.text,textTransform:l.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:h,states:Ns(l.states),events:Ns(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Ns(s.scene.objects).parent(a);s.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),n.push(a)}}),n.forEach(a=>{s.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(s){let n={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};s.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(n[Number(l.type)])if(Object.assign(l,{type:n[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new ce,move:new ce,jump:new ce}});else{let h=new ce;Object.assign(l,{actions:h}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&h.push({fi:0,id:Ft.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((u,d,c)=>{let p={easing:u.easing,duration:u.duration};u.easing===6?Object.assign(p,dg(u,"mass","stiffness","damping","velocity")):u.easing===5&&Object.assign(p,{control1:{...u.control1},control2:{...u.control2}});let m={repeat:u.repeat?-1:0,delay:u.delay,delayDirection:u.delayDirection,direction:u.cycle&&u.rewind?"pingpong-rewind":u.cycle?"pingpong":"normal"},f={state:u.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:u.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ce({fi:0,id:Ft.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:Ft.generateUUID(),data:f})};h.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,h){let u=new ce,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===h){let f;d.push(p),c.interaction==="play"?f={...dg(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(f={...dg(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&u.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),u.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,u):a.events.insertBefore(null,[{id:Ft.generateUUID(),data:{type:l,actions:u}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),r<22&&(ZY(i),i.schema=22),r<23&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(s){s.scene.objects.traverse((n,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(function(s){s.shared.videos=$a({},ke.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(s){s.scene.objects.traverse((n,a)=>{let o=s.scene.objects.unproxy().parent(n);if(o){let l=Ns(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Ns(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(s){s.scene.objects.traverse((n,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),r<28&&(ZY(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,Es.prototype),o.texture&&Object.setPrototypeOf(o.texture,Es.prototype)}function a(o){Object.setPrototypeOf(o,Es.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(h=>{let u=h;if(u.material){let d=Ns(u.material).layers;a(d),u.material.layers=d}if(u.materials)for(let d=0;d<u.materials.length;d++){let c=u.materials[d],p=Ns(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=ls.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(s){s.scene.publish.orbitControls.autoZoom===void 0&&(s.scene.publish.orbitControls.autoZoom=!1),s.scene.objects.traverse((n,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),r<33&&(function(s){s.scene.objects.traverse((n,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),r<34&&(function(s){s.scene.publish.mouseEventTarget===void 0&&(s.scene.publish.mouseEventTarget="canvas"),s.scene.publish.settings.web.hint===void 0&&(s.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(s){let{video:n}=s.scene.publish.settings;n.format==="gif"&&n.fps>48&&(n.fps=15)}(i),i.schema=35),r<36&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(s){let n=s.scene.environment.usePhysics;s.scene.objects.traverse((a,o)=>{n&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(tc(i,YY),Jd(i,YY),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=G4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=Pg.defaultData())}(i),i.schema=40),r<41&&(function(s){s.scene.environment.ambientLight.occlusion===void 0&&(s.scene.environment.ambientLight.occlusion=!1),s.scene.environment.ambientLight.aoFullRes===void 0&&(s.scene.environment.ambientLight.aoFullRes=!1),s.scene.environment.ambientLight.radius===void 0&&(s.scene.environment.ambientLight.radius=256),s.scene.environment.ambientLight.bias===void 0&&(s.scene.environment.ambientLight.bias=.5),s.scene.environment.ambientLight.aoColor===void 0&&(s.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),tc(s,QY),Jd(s,QY)}(i),i.schema=41),r<42&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new ce})})})}(i),i.schema=42),r<43&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){tc(i,JY),Jd(i,JY),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=l0);let s=Ns(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=dv,n.insertBefore(null,null,[{id:dv,data:{...Hg.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:dg(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:dg(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...mv.defaultData,...dg(i.scene.environment,"usePhysics","gravity")},camera:Ns(i.scene.ownerCamera)??Hg.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==Rg.TRASH_CAN_ID&&n.move(dv,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,h)=>{h.type==="DirectionalLight"?(h.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):h.type==="SpotLight"&&(h.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(h.physics===void 0||h.physics===null)&&h.type!=="Instance"&&(h.physics={},Object.assign(h.physics,cv.defaultData)),h.physics!==void 0&&h.physics!==null&&(h.physics.enabled=h.collision??"visibility",delete h.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=xc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(tc(t,rK),Jd(t,rK),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new ke,t.shared.lib=cc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=$a({},ke.prototype)}(t),t.scene.objects.traverse((i,r)=>{_gt(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))xgt(i);if(e<106&&(function(i){let r=Ns(i.shared.variables);i.shared.variables=$a(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ce.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=cc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=$a({},ke.prototype),i.shared.lib&&(i.shared.lib.particles=cc.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Particle"&&typeof s.renderMaterial.size=="number"&&Object.assign(s.renderMaterial,{size:[s.renderMaterial.size,s.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,r)=>{(function(s){Array.isArray(Ns(s.events))&&s.events?.forEach(n=>{"disabled"in n||(n.disabled=!1),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress")&&(n.mode=n.mode||"Object")})})(r)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Page"&&(s.postprocessing.depthOfField.focusDistance=100,s.postprocessing.depthOfField.focalLength=20,s.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((r,s)=>{Array.isArray(Ns(s.events))!==!1&&s.events?.forEach(n=>{let a=n.runMode;n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="Collision"||n.type==="Trigger"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):n.type==="MouseHover"||n.type==="MousePress"||n.type==="KeyPress"?n.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):n.type==="GameControl"?(delete n.actions,Object.keys(n.gameActions).forEach(o=>{n.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):n.type==="DragDrop"?(delete n.actions,n.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),n.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):n.type==="Resize"?(delete n.actions,n.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):n.type==="Start"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="VariableChange"||n.type==="Scroll"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="Conditional"&&(delete n.actions,n.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),n.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(t),t.schema=113),e<114&&(t.scene.publish.settings.web.imageQuality===void 0&&(t.scene.publish.settings.web.imageQuality=70),t.schema=114),e<115&&(function(i){i.shared.userAPIs=$a({},ke.prototype),i.shared.userWebhooks=$a({},ke.prototype),i.shared.lib&&(i.shared.lib.userAPIs=cc.defaultData().userAPIs,i.shared.lib.userWebhooks=cc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=xc.defaultData.settings.videoStatic)}(t),t.schema=116),e<117&&(t.scene.publish.settings.web.pixelRatioMobile===void 0&&(t.scene.publish.settings.web.pixelRatioMobile=0),t.scene.publish.settings.web.pixelRatioDesktop===void 0&&(t.scene.publish.settings.web.pixelRatioDesktop=0),t.schema=117),e<118&&(t.shared.timelineAnimations=$a({},ke.prototype),t.scene.objects.traverse((i,r)=>{wgt(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=fv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=fv.defaultData.scene.publish.settings.videoStatic.imageFormat,t.schema=119),e<120&&(t.scene.publish.settings.image.colorSpace="display-p3",t.scene.publish.settings.videoStatic.colorSpace="display-p3",t.schema=120),e<121&&(t.scene.objects.traverse((i,r)=>{ZU(r),r.type==="Page"&&r.camera!==void 0&&ZU(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=fv.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=Qp.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(typeof s.exposure=="number"&&(s.exposure=Math.round(s.exposure/5e-4*1e4)/1e4),s.lighting===void 0&&(s.lighting=Qp.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingIntensity===void 0&&(s.lightingIntensity=Qp.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(s.mode===void 0&&(s.mode="physical"),s.hdri===void 0?s.hdri={...Qp.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=Qp.defaultData.hdri.blur),Array.isArray(s.hdri.rotation)&&(s.hdri.rotation=s.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s?.hdri!==void 0&&s.hdri.showBackground===void 0&&(s.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingQuality===void 0&&(s.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=Hg.defaultData.camera);let s=r.camera;s.far=1e5,s.perspective?s.perspective.near=70:s.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(YU(t,JG),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.states;if(!n)return;let a=s.timelineAnimations,o=[];n.forEach((l,h)=>{(l.isAnimation||a?.[h])&&o.push(h)}),o.forEach(l=>n.delete(l))})}(t),function(i){let r=i.shared,s=r.timelineAnimations;if(!s)return;let n=i.scene.objects,a=n.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(s)){let h=$a({},ke.prototype),u=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(u=Math.max(u,g.to??0),d=d||Boolean(g.loop),h[m]={id:m,keyframes:I3t(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=$a({},ke.prototype)))[o]={id:o,name:l.name,duration:u||5,...d?{loop:d}:{},objectTimelines:h})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),aK(t,N3t),aK(t,V3t),t.schema=131),e<132&&(t.scene.objects.traverse((i,r)=>vgt(r)),t.schema=132),e<133){let i=function(s){return n=>s.get(n)?.data?.value}(t.shared.variables),r=new Map;t.scene.objects.traverse((s,n)=>{let a=n;if(a.type==="Page"&&a.timelines)for(let o of Object.values(a.timelines))for(let[l,h]of Object.entries(o.objectTimelines??{})){let u=r.get(l)??[];u.push(h.keyframes),r.set(l,u)}}),t.scene.objects.traverse((s,n)=>Sgt(n,i,r.get(s))),t.schema=133}e<134&&(t.scene.objects.traverse((i,r)=>bgt(r)),t.schema=134),e<135&&(YU(t,tW),t.schema=135)}}nT(ygt,{updateAllMaterials:()=>YU,updateDocumentSchema:()=>L3t,updateLibSchema:()=>z3t,updateMaterialSchema:()=>O3t,updateObjectStateRec:()=>Nu,updateObjectsSchema:()=>xgt,updateTextValues:()=>D3t});var Tgt,kp,Mgt,Agt,oK,kM,jI,lK,VM,Og,d_,W0,zM,GI,ZP,WI,qI,hK,QP,HI,$g,QU,sD=j(()=>{ht(),jft(),Ui(),YG(),v3t(),iD(),hT(),qo(),un(),XG(),eD(),WG(),uT(),Qft(),R3t(),Tgt=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),kp=180/Math.PI,Mgt=Math.PI/180,Agt=["position","rotation","scale","shape size"]}),F3t=j(()=>{var t,e,i;qo(),Ui(),un(),(oK||(oK={})).is=function(r){return!0},(t=kM||(kM={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}},t.diff=function(r,s){return sft({position:Hu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:Hu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&Hu.isEqual(r.shear,s.shear)?void 0:s.shear})},(jI||(jI={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(lK||(lK={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(VM||(VM={})).defaultData={opacity:1,fill:{color:Hi.fromHexAndA(i0,1),enabled:!0},stroke:{color:Hi.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Hi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Hi.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=Og||(Og={})).newEmpty=function(r,s){return{name:s}},e.patch=function(r,s){if(s===void 0)return r;let n={...r};return Object.assign(n,kM.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},h=["width","height","cornerRadius"];for(let u of h)u in l&&u in o&&o[u]!==void 0&&Object.assign(l,{[u]:o[u]});return l}(n,s),n=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(n,s),n},e.toOps=function(r,s){let n,a=[];for(let[o,l]of Object.entries(s))o!=="name"&&(n===void 0&&(n={path:[],props:{},type:0},a.push(n)),n.props[o]=l);return a},(d_||(d_={})).defaultData={...kM.defaultData,...jI.defaultData,states:new ce,events:new ce,visible:!0,raycastLock:!1},(W0||(W0={})).defaultData={...d_.defaultData,...VM.defaultData},(zM||(zM={})).defaultData={cornerRadius:[0,0,0,0]},(GI||(GI={})).defaultData={...W0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(ZP||(ZP={})).defaultData={...W0.defaultData,...zM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(WI||(WI={})).defaultData={...W0.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(qI||(qI={})).defaultData={...W0.defaultData,type:"path2d",path:"",name:"Path"},(hK||(hK={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(QP||(QP={})).defaultData={...d_.defaultData,name:"Group",type:"group2d"},(HI||(HI={})).defaultData=()=>({...d_.defaultData,...zM.defaultData,...VM.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Hi.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Hi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(s){switch(s){case"rectangle2d":case"vector2d":return{...ZP.defaultData};case"ellipse2d":return{...GI.defaultData};case"text2d":return{...WI.defaultData};case"path2d":return{...qI.defaultData};case"frame2d":return{...HI.defaultData()};case"group2d":return{...QP.defaultData}}},r.getPivot=function(s){return"width"in s&&"height"in s?[typeof s.width=="number"?.5*s.width:0,typeof s.height=="number"?.5*s.height:0]:[0,0]},r.isResizeable=function(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"},r.isAutoLayoutable=function(s){return s.type==="frame2d"&&s.autoLayout!==void 0},r.hasCorners=function(s){return s.type==="rectangle2d"||s.type==="frame2d"}})($g||($g={})),(i=QU||(QU={})).defaultData={name:"UI",type:"scene2d",objects:new Nn},i.emptyData=function(){return{type:"scene2d",objects:new Nn}}}),Cgt=j(()=>{d3t(),c3t(),Cft(),Eft(),jft(),Tft(),Ift(),Nft(),Vft(),WG(),sD(),Uft(),GG(),jG(),Pft(),hT(),Oft(),Lft(),qo(),iD(),eD(),Qft(),HG(),kft(),XG(),$G(),m3t(),Bft(),KG(),qG(),Rft(),Dft(),F3t()});function Ig(t,e=!1){let i=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),n={},a={},o=t[0].morphTargetsRelative,l=new ye,h=0;for(let u=0;u<t.length;++u){let d=t[u],c=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.attributes[p]),c++}if(c!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(d.morphAttributes[p])}if(e){let p;if(i)p=d.index.count;else{if(d.attributes.position===void 0)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;p=d.attributes.position.count}l.addGroup(h,p,u),h+=p}}if(i){let u=0,d=[];for(let c=0;c<t.length;++c){let p=t[c].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+u);u+=t[c].attributes.position.count}l.setIndex(d)}for(let u in n){let d=uK(n[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,d)}for(let u in a){let d=a[u][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[u].length;++f)p.push(a[u][f][c]);let m=uK(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(m)}}}return l}function uK(t){let e,i,r,s=-1,n=0;for(let h=0;h<t.length;++h){let u=t[h];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=u.itemSize),i!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=u.count*i}let a=new e(n),o=new _e(a,i,r),l=0;for(let h=0;h<t.length;++h){let u=t[h];if(u.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=u.count;c<p;c++)for(let m=0;m<i;m++){let f=u.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(u.array,l);l+=u.count*i}return s!==void 0&&(o.gpuType=s),o}var dT=j(()=>{ht()});function Egt(t){let e=t.points.length/7,i=new ce;for(let r=0;r<e;r++){let s=7*r,n=t.points[s+0],a=t.points[s+1],o=t.points[s+2],l=t.points[s+3],h=t.points[s+4],u=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:Ft.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[h,u]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>Egt(r))??[]}}function Pgt(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:h}=a,u=h?.groups,d=h?.attributes??{},c=h?.morphAttributes??{},p=h?.interleavedBuffers,m=h?.arrayBuffers,f=h?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(y){let v=1/0,b=1/0,_=1/0,x=-1/0,S=-1/0,w=-1/0;for(let T=0;T<y.length;T+=3){let C=y[T],M=y[T+1],A=y[T+2];v=Math.min(v,C),b=Math.min(b,M),_=Math.min(_,A),x=Math.max(x,C),S=Math.max(S,M),w=Math.max(w,A)}return{width:x-v,height:S-b,depth:w-_}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:m},...o===void 0?{}:o,type:"NonParametricGeometry"};return f!==void 0&&Object.assign(g.data,{index:f}),u!==void 0&&Object.assign(g.data,{groups:u.map(y=>({...y,materialIndex:y.materialIndex??0}))}),g}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let h=new ye;if(o?.position===void 0||o?.faceMap===void 0)return null;let u=o.position.array,d=o.faceMap.array,c=r.data.index.array;h.setAttribute("position",new ge(u,3)),h.setIndex(new fm(c,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let b={},_=y.getIndex(),x=y.getAttribute("position"),S=_?_.count:x.count,w=0,T=Object.keys(y.attributes),C={},M={},A=[],R=["getX","getY","getZ","getW"],I=["setX","setY","setZ","setW"];for(let L=0,H=T.length;L<H;L++){let W=T[L],X=y.attributes[W];C[W]=new X.constructor(new X.array.constructor(X.count*X.itemSize),X.itemSize,X.normalized);let nt=y.morphAttributes[W];nt&&(M[W]||(M[W]=[]),nt.forEach((st,yt)=>{let pt=new st.array.constructor(st.count*st.itemSize);M[W][yt]=new st.constructor(pt,st.itemSize,st.normalized)}))}let O=.5*v,B=Math.log10(1/v),V=Math.pow(10,B),z=O*V;for(let L=0;L<S;L++){let H=_?_.getX(L):L,W="";for(let X=0,nt=T.length;X<nt;X++){let st=T[X],yt=y.getAttribute(st),pt=yt.itemSize;for(let Q=0;Q<pt;Q++)W+=~~(yt[R[Q]](H)*V+z)+","}if(W in b)A.push(b[W]);else{for(let X=0,nt=T.length;X<nt;X++){let st=T[X],yt=y.getAttribute(st),pt=y.morphAttributes[st],Q=yt.itemSize,ut=C[st],wt=M[st];for(let St=0;St<Q;St++){let Tt=R[St],vt=I[St];if(ut[vt](w,yt[Tt](H)),pt)for(let It=0,Ut=pt.length;It<Ut;It++)wt[It][vt](w,pt[It][Tt](H))}}b[W]=w,A.push(w),w++}}let k=y.clone();for(let L in y.attributes){let H=C[L];if(k.setAttribute(L,new H.constructor(H.array.slice(0,w*H.itemSize),H.itemSize,H.normalized)),L in M)for(let W=0;W<M[L].length;W++){let X=M[L][W];k.morphAttributes[L][W]=new X.constructor(X.array.slice(0,w*X.itemSize),X.itemSize,X.normalized)}}return k.setIndex(A),k}(h),m=[],f=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let y=0,v=d.length;y<v;)d[y]===d[y+1]?(f[d[y]]++,m.push(...new Set(g.slice(3*y,3*y+6))),y+=2):(m.push(...g.slice(3*y,3*y+3)),y++);o.indexWASM={array:m},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:f}}if(o?.positionWASM===void 0||o?.positionWASM.length===0||o?.indexWASM===void 0||o?.indexWASM.length===0||o?.verticesPerFaceWASM===void 0||o?.verticesPerFaceWASM.length===0)return null;let l={type:a,...U3t(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let h in o)h==="positionWASM"?l[h]=new Float32Array(o[h].array):h==="indexWASM"?l[h]=new Int32Array(o[h].array):h==="verticesPerFaceWASM"&&(l[h]=new Int8Array(o[h].array));return l.scaleBaked=[1,1,1],l}let s=e.type,n=e.parameters;return s==="VectorGeometry"?(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,width:100,height:100,shape:Egt(e.shape),type:s}):s==="LatheGeometry"?{...e.parameters,type:s,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,type:s})}function U3t(t){return JU.setFromArray(t),JU.getSize(a2),{width:a2.x,height:a2.y,depth:a2.z}}var JU,a2,$I,j3t=j(()=>{Ui(),ht(),dT(),new xt,new Te,new Fi,new P,new P,JU=new cr,a2=new P}),G3t=j(()=>{var t;(t=$I||{}).view="view",t.edit="edit",(($I=t)||($I={})).canWrite=function(e){return e!=="view"},class extends Error{constructor(e,i){super(`This is a ${e.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=e,this.expected=i,this.name="DocumentKindMismatchError"}}}),Rgt,tj,JP,Dgt,Ogt,Jv,c_,LM,XI,tb,dK,YI,cK,KI,zv,Kc,Zc,cd,ZI,pK,mK,QI,ej,Sc,Igt=j(()=>{G3t()}),W3t=j(()=>{}),q3t=j(()=>{Ui(),sD(),Igt()}),H3t=j(()=>{hT(),[...tD],new Set(FG)}),Be=j(()=>{Cgt(),W3t(),y3t(),sD(),q3t(),Igt(),YG(),H3t(),KG(),Ui()}),nD=j(()=>{Rgt=[3,4,8,9],tj=5,JP=3,Dgt=32,Ogt=.98}),cT=j(()=>{ht(),Jv=t=>{var e;return(e=class extends t{}).geometryHelper=new Zh(30,30,30),e}}),pT=j(()=>{ht(),c_=new gc,LM=new Jn,XI=new xt,tb=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),LM.copy(a.boundingSphere),LM.applyMatrix4(o),i.ray.intersectsSphere(LM)===!1||(XI.copy(o).invert(),c_.copy(i.ray).applyMatrix4(XI),a.boundingBox!==null&&c_.intersectsBox(a.boundingBox)===!1))return;let l,h,u,d,c,p,m=a.index,f=a.attributes.position,g=a.drawRange;if(s===!1){for(c=Math.max(0,g.start),p=Math.min(m.count,g.start+g.count);c<p;c+=3)if(h=m.getX(c),u=m.getX(c+1),d=m.getX(c+2),l=y(t,i,c_,f,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new P,_=new P,x=new P,S=new P,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T;for(let M=Math.max(0,g.start),A=Math.min(v.count,g.start+g.count)-1;M<A;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),c_.distanceSqToSegment(b,_,S,x)>C)continue;S.applyMatrix4(n.matrixWorld);let R=i.ray.origin.distanceTo(S);R<i.near||R>i.far||r.push({distance:R,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let C=new P,M=new P,A=new P,R=new P,I=new P;if(C.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),A.fromBufferAttribute(x,T),_.intersectTriangle(C,M,A,!1,R)===null)return null;I.copy(R),I.applyMatrix4(v.matrixWorld);let O=b.ray.origin.distanceTo(I);return O<b.near||O>b.far?null:{faceIndex:1,distance:O,point:I.clone(),object:v}}}}),aD=j(()=>{ht(),cT(),pT(),dK=new P(1,1,1),YI=new P,cK=new P,KI=new Te,zv=class extends Jv(Kmt){constructor(t,e=15){super(e),this.object=t,this.dummy=new Qv,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,e){tb(this.object,zv.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(YI,KI,cK),this.matrix.compose(YI,KI,dK),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),$3t=j(()=>{ht(),Kc=new P,Zc=new P,cd=new xt,ZI=[new P(-1,1,1),new P(-1,-1,1),new P(1,-1,1),new P(1,1,1),new P(-1,1,-1),new P(-1,-1,-1),new P(1,-1,-1),new P(1,1,-1)],pK=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],mK=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],QI=(t,e,i)=>{t.updateEntityBoxSize(Kc,Zc),cd.copy(e).multiply(t.matrixWorld),Zc.x===0&&Zc.y===0&&Zc.z===0?i.push(new P(Kc.x,Kc.y,Kc.z).applyMatrix4(cd)):ZI.forEach(r=>{i.push(r.clone().multiply(Zc).add(Kc).applyMatrix4(cd))})},ej=class extends cr{constructor(){super(...arguments),this.matrix=new xt,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(e=>e.clone()),this.faces=t.faces.map(e=>e.clone()),this.edges=t.edges.map(e=>e.clone()),this.centerEdges=t.centerEdges.map(e=>e.clone()),this}setFromObjectSize(t,e=!1){t.updateWorldMatrix(!1,e),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new xt().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let r=[];if(i===!0){let s=[];t.traverseEntity(n=>{if(n.visible||n.cloner&&n.data.visible){if(!("geometry"in n))return cd.copy(e).multiply(n.matrixWorld),void s.push(new P().applyMatrix4(cd));QI(n,e,r)}}),r.length===0&&r.push(...s)}else QI(t,e,r);return this.setFromPoints(r)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(cd.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Zc).multiplyScalar(.5),this.getCenter(Kc),cd.copy(this.matrix).setPosition(Kc),this.vertices=ZI.map(t=>t.clone().multiply(Zc).applyMatrix4(cd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=pK.map(([t,e])=>new bl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=mK.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),W4=j(()=>{Sc={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function nS(t){return t?.isParticleSystem===!0}function n0(t){return t?.isHairSystem===!0}function Ic(t){return t?.isShapeBlendEntity===!0}function oD(t){return t?.isPathObject===!0}function Go(t){return t?.isObject2D===!0}function Ya(t){return t?.isUIObject===!0}function om(t){return t?.isCloner===!0}function lm(t){return t?.isClone===!0}function tR(t){return t?.isComponentObject===!0}var ts=j(()=>{});function Nr(t){eW.add(t)}function On(t,e){let i=`${t}:${e}`;sj.has(i)||sj.add(i)}function q4(t,e){iW.set(t,e)}function JI(t){return iW.get(t)}function eb(t,e){rW.set(t,e)}function tN(t){return rW.get(t)}function ij(t,e){sW.set(t,e)}function Ngt(t){return sW.get(t)}function rj(){return lD}var eW,sj,iW,rW,sW,lD,H4,Ni=j(()=>{eW=new Set,sj=new Set,iW=new Map,rW=new Map,sW=new Map,lD=null,H4=null});function Bgt(t,e,i,r,s=new xt){return s.compose(t,e,kgt).multiply(i).scale(r)}var kgt,eN,Ng,hD,ib=j(()=>{ht(),rD(),kgt=new P(1,1,1),eN=new xt,(Ng||(Ng={})).is=function(t){return t&&t.__isSPEObject},hD=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new xt,this.copyPreviousMatrix=!0,this.pivotMatrix=new xt,this.matrixWorldRigid=new xt,this.shearScale=new xt,this.shearScaleInv=new xt,this.shearMatrix=new xt}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(eN.copy(this.parent.matrixWorld).invert()),e.multiply(eN.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof ur&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrix(){!this.shearMatrix||(Bgt(this.position,this.quaternion,this.shearMatrix,this.scale,this.matrix),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let i of this.children)i.updateMatrixWorld(e)}updateWorldMatrix(e,i){let r=this.parent;if(e&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.multiply(this.pivotMatrix),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let r of this.children)Ng.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Ng.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=Hft(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,i){this.updateWorldMatrix(!0,!1);let r=new xt().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),r.multiply(e.parent.matrixWorld)),e.applyMatrix4(r),e.updateWorldMatrix(!1,!1),this.add(e),i!==void 0&&(this.children.pop(),this.children.splice(i,0,e)),this}copy(e,i=!1){return super.copy(e,i),this}onAfterRender(e,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function fK(t,e,i){return Jp.subVectors(e,t),GS.subVectors(e,i),Jp.cross(GS).length()<=aS}function Vgt(t){let e=oj.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(r){let s=r.points,n=[s[0]],a=[new P(...s[0].data.position)];cg.copy(a[0]);for(let y=0;y<s.length-1;y++)Jp.fromArray(s[y].data.position),GS.fromArray(s[y+1].data.position),E1.subVectors(Jp,cg),P1.subVectors(Jp,GS),E1.cross(P1).length()>aS&&(n.push(s[y]),a.push(new P().copy(Jp)),cg.copy(Jp));let o=s[s.length-1];n.push(o),a.push(new P(...o.data.position));let l=r.isClosed,h=n.length-(l?0:1),u=n.length,d=[],c=[];for(let y=0;y<u;y++){let v=n[y].data;d.push(new P(...v.controlPrevious.position)),c.push(new P(...v.controlNext.position))}let p=[];for(let y=0;y<h;y++){let v=y===u-1?0:y+1;p.push(fK(a[y],c[y],a[v])&&fK(a[y],d[v],a[v]))}let m=[];for(let y=0;y<u;y++){let v=n[y].data,b=a[y],_={position:b,prevDir:void 0,nextDir:void 0,controlPrevious:d[y],controlNext:c[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(m.push(_),v.roundness===0||!l&&(y===0||y===u-1))continue;let x=l&&y==0?u-1:y-1,S=l&&y==u-1?0:y+1,w=new P().subVectors(a[x],b).normalize(),T=new P().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let C=p[l&&y===0?u-1:y-1],M=p[y];if(C&&M){pg.addVectors(w,T).normalize();let A=cg.crossVectors(pg,w).length()/w.dot(pg);_.tan=A,_.removedLength=v.roundness/A}}for(let y=0;y<h;y++){let v=l&&y===u-1?0:y+1,b=m[y],_=m[v];if(b.removedLength!==0||_.removedLength!==0){let x=b.position.distanceTo(_.position);b.removedLength=Math.min(b.removedLength,x/2),_.removedLength=Math.min(_.removedLength,x/2)}}let f=new Array(2*u).fill(null);for(let y=0;y<h;y++){let v=l&&y===u-1?0:y+1,b=m[y],_=m[v],x=null;if(p[y]){let S=b.position.clone(),w=_.position.clone();(b.removedLength!==0||_.removedLength!==0)&&(b.nextDir&&S.add(cg.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(cg.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>aS&&(x=new Z2(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>aS&&(x=new Z2(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<u;y++){let v=m[y];if(v.removedLength===0)continue;let b=v.position,_=v.prevDir.clone().multiplyScalar(v.removedLength).add(b),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(b),S=v.tan*v.removedLength;pg.addVectors(v.prevDir,v.nextDir).normalize(),E1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;aj.copy(pg).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(E1),eR.copy(pg).multiplyScalar(-S).add(aj);let T=b.distanceTo(eR)/b.distanceTo(E1);P1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),nj.copy(P1).lerp(eR,2);let C=_.clone().lerp(P1,4/3),M=x.clone().lerp(nj,4/3);f[2*y]=new Z2(_,C,M,x)}let g=new zgt;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return oj.set(t.points,{isClosed:t.isClosed,curve:i}),i}var zgt,aS,Jp,GS,cg,pg,E1,eR,P1,nj,aj,oj,R1,lj,iR,Lgt,Fgt,Ugt,xi,Vu,gK,yK,p_,iN,FM,rN,sN,uD,hj,h0,Lu,jgt=j(()=>{ht(),zgt=class extends tU{constructor(){super()}getPoints(t=12){let e,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(t*l/s),u=o.getPoints(h);for(let d=0;d<u.length;d++){let c=u[d];e&&e.equals(c)||(i.push(c),e=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},aS=.001,Jp=new P,GS=new P,cg=new P,pg=new P,E1=new P,eR=new P,P1=new P,nj=new P,aj=new P,oj=new WeakMap}),X3t=j(()=>{ht(),R1=new xt,lj=new Te,iR=new Te,Lgt=new Fi,Fgt=new P,Ugt=new P(0,1,0)}),bo=j(()=>{ht(),Be(),$3t(),Ui(),W4(),ts(),Ni(),ib(),jgt(),X3t(),ir(),(xi||(xi={})).is=function(t){return t&&t.__isEntity},Vu=t=>xi.is(t),gK={type:"completeState",isfromEntity:!0},yK=["x","y","z"],p_=new P,iN=new P(1,1,1),FM=new Te,rN=new Fi,sN=new xt,uD=t=>class extends hD(t){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.transitionState={settled:!0,state:null},this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new ej,this._recursiveBBox=new ej,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let i=this.children[e];if(xi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(xi.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let e=this;for(;e.data.type!=="Instance";){let i=e.parent;if(!xi.is(i))return;e=i}return e}forInstancesRec(e){this.instances.forEach(i=>{i.disposed||e(i),i.forInstancesRec(e)})}super_Entity(e,i){typeof e=="string"&&(this.uuid=e),this.identity=e,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,i,r=!1){if(this.data.states.length!==0||r){for(let s of this.data.states)am.toOps(this.data,s.data).forEach(n=>{let a=b4.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let s=this.data.states.data(e);s&&(this.dataPatched=am.patch(this.data,s),am.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,i){e.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{Vu(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(r=>{r.uuid===e&&(i=r)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,r=i.indexOf(this)+1;if(xi.is(i[r]))return i[r];if(xi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&xi.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let i=this;for(;e>0&&i!==null;)i=i.parent,e-=1;return i}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let i=this.parent;for(;i;){if(e===i)return!0;i=i.parent}return!1}countToAccestor(e){let i=0,r=this;for(;r!==e;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Vu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{xi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Vu(i)&&i.visible&&i.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,i=!1){return super.copy(e,i),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this}hasEntityChild(){return this.children.some(e=>Vu(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),fU({position:this.position.toArray(),rotation:[this.rotation.x*Ft.RAD2DEG,this.rotation.y*Ft.RAD2DEG,this.rotation.z*Ft.RAD2DEG],scale:this.scale.toArray(),shear:wl.fromMatrix(this.shearMatrix.toArray()),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,r){return i[e].map((s,n)=>r?.shared.getVariable(s,[this.uuid,e,yK[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(p_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(Ft.DEG2RAD),this.rotation.setFromVector3(p_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.shear&&(this.shearMatrix.fromArray(wl.toMatrix(e.shear)),r=!0),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(p_.fromArray(e.pivot).negate(),FM.setFromEuler(rN.fromArray(e.pivotRotation.map(s=>s*Ft.DEG2RAD))).invert(),iN);else if(e.pivot!==void 0)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(e.pivotRotation!==void 0){let s=p_.setFromMatrixPosition(this.pivotMatrix);FM.setFromEuler(rN.fromArray(e.pivotRotation.map(n=>n*Ft.DEG2RAD))).invert(),this.pivotMatrix.compose(s,FM,iN)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)xi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{xi.is(e)&&e.disposeRecursively()})}toState(e=[]){return fU({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,i){e!==void 0&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},i,!1)}updateByOp(e,i,r,s){let n=this.data;this.data=i;let a=e,o=er(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let h={...e.props};if(delete h.name,Object.values(e.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let d=Dn.zoom(u,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(h[c]=d[c])}}a={...e,props:h,path:e.path.slice(2)}}}}else if(e.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(e.props.name!==void 0&&l.name){let{name:u,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:u,...d}=l;l=d}let h=Dn.removeOverridden(e.path,e.props,l);a={...e,props:h}}}if(this.updateByPatchedOpBase(a,am.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),er(e.path,["overrides"])){let l=[],h=[...e.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let u of Object.keys(e.props)){l[l.length-1]=u;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[u],d.updateState(gm.apply(d.component.data,d.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let d=Dn.zoom(u.component.data,h);if((e={...e,path:h}).type===0){let c=e.props;if(d)for(let[p,m]of Object.entries(e.props))m===void 0&&(c===e.props&&(c={...e.props}),c[p]=d[p]);e={...e,props:c}}u.overrideData=F4.resolve(i.overrides,l),u.updateByOp(e,ta.applySimple(u.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let h;for(let u of _c.rootOverrideProps)u in e.props&&(h===void 0&&(h={}),h[u]=e.props[u]);h&&(l={...e,props:h})}else for(let h of _c.rootOverrideProps)if(er(e.path,[h])){l=e;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=gm.filterOp(h.overrideData,l);u&&h.updateByOp(u,ta.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=gm.filterOp(h.overrideData,e);if(u){let d;d=n===h.data&&e===u?i:ta.applySimple(h.data,u),h.updateByOp(u,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!r0.is(e.props.type)&&Sc.changeEntityProptotype(this,this.data,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){Sc.changeEntityProptotype(this,this.data,r);for(let s of this.children)xi.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(e,i,r)}updateByPatchedOp(e,i,r){if(e.path.length===0&&e.type===0?this.updateState(e.props,r):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,r),e.path[0]==="morphTargetInfluences"&&e.type===0){let s=i.morphTargetInfluences.get(e.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",s]))}if(er(e.path,["pathSnapping"])!==null&&(this.updatePathSnapping(i.pathSnapping),this.isVirtualEntity&&r.scene?.syncInstancePathConstraint(this)),er(e.path,["cloner"])!==null){let s=ta.drop(e,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=e.find(this.isVirtualEntity&&e.pathConstraints.getConstraint(this.uuid)||i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=Vgt(o.geometry.path),h=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),u=null;try{u=l.curves.length?l.getPointAt(h):null}catch{}if(u===null)return;a.updateMatrixWorld();let d=this.parent?sN.copy(this.parent.matrixWorld):sN.identity(),c=function(p,m,f,g){lj.setFromRotationMatrix(R1.extractRotation(g));let y=p.clone().applyMatrix4(R1.copy(g).invert().multiply(f));if(m===null)iR.setFromRotationMatrix(R1.extractRotation(f));else{let v=m.clone().applyMatrix4(R1.extractRotation(f));iR.setFromRotationMatrix(R1.lookAt(Fgt.set(0,0,0),v,Ugt))}return{position:y,rotation:new P().setFromEuler(Lgt.setFromQuaternion(lj.invert().multiply(iR))).multiplyScalar(Ft.RAD2DEG)}}(u,n==="tangential"?l.getTangentAt(h):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(gK)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!e)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&e.reloadSplats()}updateState_Entity(e,i){e.name!==void 0&&(this.name=e.name),e.raycastLock!==void 0&&(this.raycastLock=e.raycastLock),e.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in e&&e.cloner!==void 0&&(this.setFromClonerState(e.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(e,i)}get attachedSurfaceCloners(){return this.children.filter(e=>om(e)&&e.parameters.type==="toObject")}setFromClonerState(e,i){if(!this.disposed)if(e===null||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Sc.Cloner===null)return void On("cloners","a cloner");this.cloner=new Sc.Cloner(this,e),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,i)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),u0=j(()=>{ht(),bo(),(hj||(hj={})).is=t=>"objectHelper"in t,h0=(t,e)=>class extends uD(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof kS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Zh?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof kS&&(r.visible=!1)}}}}),dD=j(()=>{ht(),aD(),u0(),Lu=class extends h0(Qv,zv){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}}});function ch(t,e,i,r,s,n,a){o2.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],o2.x,o2.y,o2.z)}}var o2,Ko,vK,Ggt,Y3t=j(()=>{ht(),cT(),pT(),o2=new P,Ko=new Eg,vK=class extends S1{constructor(t){let e=new ye,i=new Lh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new ae(15711266),o=new ae(15711266),l=new ae(2857471);function h(d,c,p){u(d,p),u(c,p)}function u(d,c){r.push(0,0,0),s.push(c.r,c.g,c.b),n[d]===void 0&&(n[d]=[]),n[d].push(r.length/3-1)}h("n1","n2",a),h("n2","n4",a),h("n4","n3",a),h("n3","n1",a),h("f1","f2",a),h("f2","f4",a),h("f4","f3",a),h("f3","f1",a),h("n1","f1",a),h("n2","f2",a),h("n3","f3",a),h("n4","f4",a),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),e.setAttribute("position",new ge(r,3)),e.setAttribute("color",new ge(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update()}update(){let t=this.geometry,e=this.pointMap;Ko.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;ch("n1",e,t,Ko,-1,-1,i),ch("n2",e,t,Ko,1,-1,i),ch("n3",e,t,Ko,-1,1,i),ch("n4",e,t,Ko,1,1,i);let r=i;ch("f1",e,t,Ko,-1,-1,r),ch("f2",e,t,Ko,1,-1,r),ch("f3",e,t,Ko,-1,1,r),ch("f4",e,t,Ko,1,1,r);let s=r;ch("u1",e,t,Ko,.35,1.1,s),ch("u2",e,t,Ko,-.35,1.1,s),ch("u3",e,t,Ko,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},Ggt=class extends Jv(vK){constructor(t){super(t),this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,e){tb(this.object,this.geometry,t,e,!0)}}});function bK(t){return 1-Math.pow(1-t,3)}var lf,UM,jM,GM,q0,WM,uu,Us,Qh=j(()=>{ht(),Y3t(),Be(),u0(),ir(),lf=new P,UM=new P,jM=new Te,GM=new P,q0=new P,WM=new P,uu=class extends h0(Eg,Ggt){constructor(t="",e={...rS.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=bc.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let s=this._projectionTransition;if(s===void 0)return;if(this.disposed)return void this._endProjectionTransition();s.raf=requestAnimationFrame(this._tickProjectionTransition);let n=uu.projectionTransitionRequestRender??s.requestRender;this.updateProjectionMatrix(),n?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new xt,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Nv(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new zh(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(t){let e=uu.projectionTransitionsEnabled;uu.projectionTransitionsEnabled=!1;try{return t()}finally{uu.projectionTransitionsEnabled=e}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(t){this.perspCamera.fov=t}get fov(){return this.perspCamera.fov}setNear(t,e){t==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(t,e){e>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t,e,i){typeof t=="number"&&(t=new P(t,e,i)),super.lookAt(t),this.getWorldPosition(lf),this.targetOffset=lf.distanceTo(t)}getTarget(t=new P){return this.getWorldDirection(UM),this.getWorldPosition(lf),UM.multiplyScalar(this.targetOffset),t.copy(lf).add(UM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(lf),lf.distanceTo(t)}updateUp(){this.getWorldQuaternion(jM),GM.set(0,0,1).applyQuaternion(jM),q0.copy(ur.DEFAULT_UP),this.isUpVectorFlipped&&q0.negate(),q0.applyQuaternion(jM),WM.copy(ur.DEFAULT_UP).projectOnPlane(GM),this.angleOffsetFromUp=WM.angleTo(q0),this.angleOffsetFromUp*=WM.cross(q0).dot(GM)>=0?1:-1}updateTransformState(t,e){let i=super.updateTransformState(t,e);return t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(t){let e=t.getWorldPosition(new P),i=t.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new P;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let r=t>e?this.aspect:1,s=t>e?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/s*395,this.bottom=1/s*-395}else this.left=.5*-t,this.right=.5*t,this.top=.5*e,this.bottom=.5*-e;this.updateProjectionMatrix()}copyViewPlaneSize(t){this.aspect=t.aspect,this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let t=this._projectionTransition;if(t===void 0)return 1;let e=(performance.now()-t.start)/t.duration;return e>=1?1:e<=0?0:bK(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return uu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=uu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new xt,blend:new xt,blendInverse:new xt,start:0,duration:uu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=uu.projectionTransitionDuration,e.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,t&&(e.requestRender=t),e.raf!==0&&cancelAnimationFrame(e.raf),e.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;let e=(performance.now()-t.start)/t.duration;if(e>=1)return void this._endProjectionTransition();let i=bK(e),r=t.from.elements,s=this._activeSubCamera.projectionMatrix.elements,n=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*a));for(let h=0;h<16;h++)n[h]=r[h]+(s[h]-r[h])*l;t.blendInverse.copy(t.blend).invert(),this.projectionMatrix=t.blend,this.projectionMatrixInverse=t.blendInverse}_endProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;t.raf!==0&&cancelAnimationFrame(t.raf),this._projectionTransition=void 0;let e=this._activeSubCamera;this.projectionMatrix=e.projectionMatrix,this.projectionMatrixInverse=e.projectionMatrixInverse}_syncProjectionTransition(t){let e=t._projectionTransition;if(e===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new xt,blend:new xt,blendInverse:new xt,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(e.from),i.start=e.start,i.duration=e.duration,i.referenceDepth=e.referenceDepth,this._applyProjectionTransition()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,e,i,r,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,r,s,n):this.orthoCamera.setViewOffset(t,e,i,r,s,n),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,e){return super.copy(t,e),this.parent=t.parent,this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=bc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return fU({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},t)}updateCameraSubtype(t,e){let i=t==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(i,e.zoom),e.near!==void 0&&this.setNear(i,e.near),e.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(t,e){this.updateCameraState(t,e)}updateCameraState(t,e){this.updateState_Entity(t,e),t.far!==void 0&&(this.far=t.far),t.orthographic!==void 0&&this.updateCameraSubtype("orthographic",t.orthographic),t.perspective!==void 0&&this.updateCameraSubtype("perspective",t.perspective),t.type!==void 0&&(t.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(e?.shared.requestRender),this.cameraType=t.type),t.up!==void 0&&this.up.fromArray(t.up.map(i=>typeof i=="number"?i:0)),t.targetOffset!==void 0&&(this.targetOffset=bc.sanitizeTargetOffset(t.targetOffset)),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.type===0&&this.updateCameraSubtype(t.path[0],t.props)}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}},(Us=uu).projectionTransitionsEnabled=!1,Us.projectionTransitionDuration=350,Us.projectionTransitionMinAgeMs=1e3});function Wgt(t){return t.type==="TorusGeometry"&&t.arc===360}var qgt,qM,uj,WS=j(()=>{ht(),qgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(t){let{width:e,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:d}=t.parameters,c=new uj(!1,e,i,r,s,n,a,o,l,h,u,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},qM=new fm([0,0,0],1),uj=class extends ye{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),u>100&&(u=100),u===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new P,S=new P,w=x(),T=x(),C=x(),M=x(),A=x(),R=x(),I=x(),O=x(),B=x(),V=x(),z=x(),k=i-2*o+.001,L=k/n,H=Math.ceil(a*n),W=H+1,X=k/H,nt=-k/2,st=h+1,yt=2*Math.PI/h,pt=Math.PI/2/d,Q=Math.min((1-u/100)*o,o-.01),ut=o-Q,wt=0,St=2*d+2,Tt=st*St/2,vt=Tt+st*W,It=Math.max(0,st*(W+St)),[Ut,Bt,zt]=[3,3,2].map(Ve=>Array(It*Ve).fill(0)),kt=[],qt=s-o;function $t(Ve,ie){let oi=Math.PI/2;v=ie*X,_=2*Math.PI*(v%L)/L+oi,v+=nt,b=Math.sin(_)*qt,y=Math.cos(_)*qt,t?Ve.set(y,b,v):Ve.set(y,v,b)}$t(S,-1e-10),$t(w,0),M.copy(S),$t(S,1);let Pt=S.distanceTo(w),oe=c?0:ut+Q,Gt=Pt*H+2*oe,Zt=Q,Jt=Gt-oe;for(let Ve=0;Ve<=H;Ve++){$t(T,Ve),z.subVectors(T,M).normalize(),M.copy(T),B.copy(T).setComponent(+t+1,0).normalize(),V.crossVectors(z,B).normalize();let ie=Ve===0,oi=Ve===H,wi=ie?3*Math.PI/2:pt,Qs=ie?Zt:Jt,$i=ie?st:vt,li=ie?0:It-st,jr=z.clone().multiplyScalar(ie?-ut:ut).add(T),es=z.clone().multiplyScalar(ie?-1:1).normalize();for(let Gr=0;Gr<st;Gr++){let ji=Gr*yt;if(A.addVectors(S.copy(B).multiplyScalar(o*Math.cos(ji)),w.copy(V).multiplyScalar(o*Math.sin(ji))),R.copy(A).normalize(),ie||oi){c||(wt=li+Gr,[0,1,2].forEach(Ci=>{Ut[3*wt+Ci]=jr.getComponent(Ci),Bt[3*wt+Ci]=es.getComponent(Ci)}),zt[2*wt]=+oi,zt[2*wt+1]=Gr/h),w.copy(R).multiplyScalar(Q),C.addVectors(T,w);for(let Ci=0;Ci<d;Ci++){let Js=Ci*pt+wi;I.addVectors(S.copy(z).multiplyScalar(ut*Math.sin(Js)),w.copy(R).multiplyScalar(ut*Math.cos(Js))),O.copy(I).normalize(),w.addVectors(C,I),I.normalize(),wt=$i+Ci*st+Gr,[0,1,2].forEach(br=>{Ut[3*wt+br]=w.getComponent(br),Bt[3*wt+br]=O.getComponent(br)});let fs=+ie+Math.sin(Js);zt[2*wt]=(Qs+ut*fs)/Gt,zt[2*wt+1]=Gr/h}}w.addVectors(T,A),wt=Tt+Ve*st+Gr,[0,1,2].forEach(Ci=>{Ut[3*wt+Ci]=w.getComponent(Ci),Bt[3*wt+Ci]=R.getComponent(Ci)}),zt[2*wt]=(oe+Ve*Pt)/Gt,zt[2*wt+1]=Gr/h}}let $=W+2*d+2,[se,Pe]=[+c,$-1];for(let Ve=se;Ve<=Pe-1;Ve++){let ie=c&&Ve===Pe-1;for(let oi=0;oi<st-1;oi++)p=Ve*st+oi,m=p+1,f=(ie?oi:p)+st,g=(ie?oi+1:m)+st,Ve===0?kt.push(m,g,f):Ve===$-2?kt.push(p,m,f):kt.push(p,m,f,m,g,f)}this.setIndex(kt),this.setAttribute("position",new ge(Ut,3)),this.setAttribute("normal",new ge(Bt,3)),this.setAttribute("uv",new ge(zt,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,r,s=this.userData.parameters,n=Math.ceil(s.tubularSegments),a=s.radialSegments,o=a+1,l=[];for(let h=1;h<n;h++)for(let u=0;u<a;u++)t=h*o+u,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let h=0;h<a;h++)t=n*o+h,e=t+1,i=h+o,r=h+1+o,l.push(t,e,i,e,r,i);return qM.array=new Uint32Array(l),qM.count=l.length,qM}}});function K3t(t){return xK||(xK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.123/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),qS=r}())}function $4(){if(qS===void 0)throw new Error("boolean-wasm is not loaded");return qS}function nW(t){let e=HS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function aW(t){return HS.set(++dj,t),dj}function Z3t(t,e,i){if(qS===void 0)return-1;let{positions:r,indices:s,normals:n}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,m=[];for(let f=0,g=0;f<p.verticesPerFace.length;f++){let y=p.verticesPerFace[f];for(let v=1;v<y-1;v++)m.push(p.indices[g],p.indices[g+v],p.indices[g+v+1]);g+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(m)}}let l;l=Wgt(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let h,u=a.getAttribute("position");if(l===null){h=new Uint32Array(u.count);for(let p=0;p<h.length;p++)h[p]=p}else h=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===u.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:u.array,indices:h,normals:c}}(t,e);return aW(new qS.CsgMesh(r,s,n))}function _K(t,e){let i=$4(),r=$gt[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(nW);if(s.length===1)return i.clone_mesh(s[0]);let n,a=[];if(e===2&&s.length>2){let o=s[0];for(let l=1;l<s.length-1;l++)o=i.boolean_mesh(o,s[l],0),a.push(o);n=i.boolean_mesh(s[s.length-1],o,2)}else if(e===2)n=i.boolean_mesh(s[1],s[0],2);else{let o=s[s.length-1];for(let l=0;l<s.length-1&&(o=i.boolean_mesh(o,s[l],r),a.push(o),o.tri_count()!==0);l++);n=o,a.pop()}for(let o of a)o.free();return n}function nN(t,e){nW(t).transform(new Float32Array(e.elements))}function Hgt(t){let e=HS.get(t);e!==void 0&&(e.free(),HS.delete(t))}var qS,HS,dj,xK,$gt,cD=j(()=>{ht(),WS(),HS=new Map,dj=0,$gt={0:0,1:1,2:2}});function hf(t){return t!==null&&"booleanOp"in t}var cj,Xgt,Q3t=j(()=>{ht(),bo(),cD(),cj=class extends uD(yr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new xt}updateVisible(t){super.updateVisible(t),this.visible=!hf(this.parent)&&this.visible,hf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){hf(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hgt(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}dispose(){super.dispose(),this.freeBooleanPointer()}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),hf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof cj&&(t.freeBooleanPointer(),hf(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&hf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),hf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),J3t=j(()=>{Xgt=null});function oW(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let d=e;d<i;d++){let c=t.getX(d),p=t.getY(d),m=t.getZ(d);c<n&&(n=c),p<a&&(a=p),m<o&&(o=m),c>l&&(l=c),p>h&&(h=p),m>u&&(u=m)}l2.min.set(n,a,o),l2.max.set(l,h,u),l2.getCenter(r),l2.getSize(s).multiplyScalar(.5)}var l2,wK,SK,Fs,oa=j(()=>{ht(),Q3t(),J3t(),l2=new cr,wK=new ye,SK=new jo,Fs=class extends cj{constructor(t,e){super(wK,SK),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){if(this.raycastDeformed(t,e))return;let i=Xgt;i===null?super.raycast(t,e):i(this,t,e)}raycastDeformed(t,e){return!1}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?oW(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function Ygt(t){return t?.isClassicNodeMaterial===!0}var Dr,pj,Kgt,Zgt,oS,Qgt,Jgt,t0t,e0t=j(()=>{}),kc=j(()=>{ht(),Dr=class extends ae{constructor(t,e,i,r){super(t,e,i),this.isColorA=!0,this.a=r}setRGBA(t,e,i,r){super.setRGB(t,e,i),this.a=r}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(t){return super.equals(t)&&this.a===t.a}setStyle(t,e="srgb"){let i;if(t==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(t)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(t,e)}}return super.setStyle(t,e)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}}}),tCt=j(()=>{kc(),pj=class extends Dr{}}),eCt=j(()=>{Kgt=class{constructor(t=1e4){this.timeout=t,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let i=e;e=e.next,e.prev=this.head,this.head.next=e,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),i=this.cache.get(t);return i===void 0?(i={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,i)):(i.time=e,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),i0t=j(()=>{eCt(),Zgt=class extends Kgt{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),r0t=j(()=>{Qgt=class{constructor(t,e){this.data=t,this.cache=e,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Jgt=class{constructor(){this.cache=new Map}remove(t){this.cache.delete(t.data)}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}}}),iCt=j(()=>{ht(),t0t=class extends Umt{constructor(t){super(t),this.type=ai}parse(t){let e=function(p,m){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},i=function(p,m,f){m=m||1024;let g=p.pos,y=-1,v=0,b="",_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(y=_.indexOf(`
362
362
  `))&&v<m&&g<p.byteLength;)b+=_,v+=_.length,g+=128,_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));return-1<y&&(f!==!1&&(p.pos+=v+y+1),b+_.slice(0,y))},r=function(p,m,f,g){let y=p[m+3],v=Math.pow(2,y-128)/255;f[g+0]=p[m+0]*v,f[g+1]=p[m+1]*v,f[g+2]=p[m+2]*v,f[g+3]=1},s=function(p,m,f,g){let y=p[m+3],v=Math.pow(2,y-128)/255;f[g+0]=Kh.toHalfFloat(Math.min(p[m+0]*v,65504)),f[g+1]=Kh.toHalfFloat(Math.min(p[m+1]*v,65504)),f[g+2]=Kh.toHalfFloat(Math.min(p[m+2]*v,65504)),f[g+3]=Kh.toHalfFloat(1)},n=new Uint8Array(t);n.pos=0;let a,o,l,h=function(p){let m,f,g=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,v=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*FORMAT=(\S+)\s*$/,_=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,x={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};for((p.pos>=p.byteLength||!(m=i(p)))&&e(1,"no header found"),(f=m.match(g))||e(3,"bad initial token"),x.valid|=1,x.programtype=f[1],x.string+=m+`
363
363
  `;m=i(p),m!==!1;)if(x.string+=m+`
364
364
  `,m.charAt(0)!=="#"){if((f=m.match(y))&&(x.gamma=parseFloat(f[1])),(f=m.match(v))&&(x.exposure=parseFloat(f[1])),(f=m.match(b))&&(x.valid|=2,x.format=f[1]),(f=m.match(_))&&(x.valid|=4,x.height=parseInt(f[1],10),x.width=parseInt(f[2],10)),2&x.valid&&4&x.valid)break}else x.comments+=m+`
365
- `;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),u=h.width,d=h.height,c=function(p,m,f){let g=m;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*m*f);y.length||e(4,"unable to allocate buffer space");let v=0,b=0,_=4*g,x=new Uint8Array(4),S=new Uint8Array(_),w=f;for(;w>0&&b<p.byteLength;){b+4>p.byteLength&&e(1),x[0]=p[b++],x[1]=p[b++],x[2]=p[b++],x[3]=p[b++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&e(3,"bad rgbe scanline format");let T,C=0;for(;C<_&&b<p.byteLength;){T=p[b++];let A=T>128;if(A&&(T-=128),(T===0||C+T>_)&&e(3,"bad scanline data"),A){let R=p[b++];for(let I=0;I<T;I++)S[C++]=R}else S.set(p.subarray(b,b+T),C),C+=T,b+=T}let M=g;for(let A=0;A<M;A++){let R=0;y[v]=S[A+R],R+=g,y[v+1]=S[A+R],R+=g,y[v+2]=S[A+R],R+=g,y[v+3]=S[A+R],v+=4}w--}return y}(n.subarray(n.pos),u,d);switch(this.type){case Qe:l=c.length/4;let p=new Float32Array(4*l);for(let f=0;f<l;f++)r(c,4*f,p,4*f);a=p,o=Qe;break;case ai:l=c.length/4;let m=new Uint16Array(4*l);for(let f=0;f<l;f++)s(c,4*f,m,4*f);a=m,o=ai;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:u,height:d,data:a,header:h.string,gamma:h.gamma,exposure:h.exposure,type:o,colorSpace:Yu,minFilter:fe,magFilter:fe,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function TK(t){return t.length>2&&t[0]===35&&t[1]===63}function aN(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function s0t(t){let e=new vr(t.data,t.width,t.height,ln,ai);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var MK,lW,Sg,n0t=j(()=>{ht(),iCt()}),a0t=j(()=>{ht(),i0t(),r0t(),n0t(),MK=0,lW=class extends Qgt{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++MK,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=t.type==="video",this.isBuffer=t.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?t:t.data)}async updateSrc(t){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let e=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))for(let n of Object.values(s))n&&(n.image=this.img,n.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=t,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof t!="string"){let r,s=new FileReader;s.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(n=>{s.onloadend=a=>{r=a.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?TK(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let r=t instanceof Uint8Array?t:null;if(r===null)try{r=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{r=null}let s=r!==null&&TK(r)?function(n){try{let a=new t0t().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,h=a.data,u=new Uint16Array(h.length),d=4*o,c=f=>Kh.toHalfFloat(Math.pow(Math.max(Kh.fromHalfFloat(f),0),1/2.2)),p=new Map,m=f=>{let g=p.get(f);return g===void 0&&(g=c(f),p.set(f,g)),g};for(let f=0;f<l;f++){let g=f*d,y=(l-1-f)*d;for(let v=0;v<d;v+=4)u[y+v]=m(h[g+v]),u[y+v+1]=m(h[g+v+1]),u[y+v+2]=m(h[g+v+2]),u[y+v+3]=h[g+v+3]}return{isSplineHdr:!0,data:u,width:o,height:l}}catch{return null}}(r):null;s!==null&&(this.isHdr=!0,this.img=s,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:(oS||(oS=new Zgt),oS.load(i)),this.img.onload=e,await new Promise(r=>{this.img.onload=()=>{e(),r(null)}});var i}getTexture(t,e=1008,i=1006){let r=this._cache[t]?.[e]?.[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new SG(this.img,void 0,t,t):this.isHdr?(s=s0t(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new pi(this.img,void 0,t,t,i,e),this.isBuffer||(s.anisotropy=8,s.generateMipmaps=e===1008),this.loaded&&(s.needsUpdate=!0),this._cache[t]===void 0&&(this._cache[t]={}),this._cache[t][e]===void 0&&(this._cache[t][e]={}),this._cache[t][e][i]=s,s}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let r of Object.values(i))r&&(r.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,r]of Object.entries(e))for(let[s,n]of Object.entries(r))n?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),o0t=j(()=>{a0t(),Sg=class extends lW{}});function rCt(t){if(typeof t=="string")return t;let e=mj.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},mj.set(t,e)),e.url}var mj,sCt=j(()=>{mj=new Map});function nCt(){if(!fj)return AK||(AK=async function(){await Promise.resolve().then(()=>(rH(),t2t)),l0t(window!==void 0?window:global),fj=!0}())}var l0t,h0t,fj,AK,u0t=j(()=>{h0t=new Promise(t=>{l0t=t}),fj=!1});function CK(t,e){t.forEach(i=>{"dragDropActions"in i.data?(e.push(...i.data.dragDropActions.drag),e.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(e.push(...i.data.inActions),e.push(...i.data.outActions)):"gameActions"in i.data?(e.push(...i.data.gameActions.idle),e.push(...i.data.gameActions.move),e.push(...i.data.gameActions.jump),e.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{e.push(...r.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(e.push(...r.data.ifActions),e.push(...r.data.elseActions))}))})}function aCt(t){let e=!1,i=[];return t.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((n,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;CK(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;CK(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var EK,Z1,hW=j(()=>{sCt(),u0t(),h0t.then(t=>EK=t),Z1=class{constructor({src:t,volume:e,delay:i,loop:r}){let s;this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)},s=typeof t=="string"?{src:t}:{src:rCt(t),format:"wav"},this.sound=new EK.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,i){this.sound.on(t,e,i)}off(t,e,i){this.sound.off(t,e,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function PK(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(e=!0)}),e}var uW,dW=j(()=>{uW=null});function RK(t){return new Z(t.y,-t.x)}var cW,gj,d0t,c0t,HM,DK,X4,p0t,oN,Y4=j(()=>{ht(),cW=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,r=t.parameters?.radiusBottom,s=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);s.thetaLength=Ft.clamp(s.thetaLength,0,360),s.hollow=Ft.clamp(s.hollow??0,0,1);let n=s.width/2,a=s.radiusTop??n,o=s.radiusBottom??n;if(a===o?(a=n,o=n):a>o?(a=n,o=o*n/a):(a=a*n/o,o=n),s.shapeBlendNode){a=i??n,o=r??n;let l=2*Math.max(a,o);s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;h===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=c||m?new gj(u,d,s,n,a,o,l,h*Math.PI/180,c,c,p,m):new K2(u,d,s,n,a,o,l,h*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},gj=class extends ye{constructor(t,e,i,r,s,n,a,o,l,h,u,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0&&n,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,n&&(l=0,h=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=h);let m=new Z(t,p),f=new Z(e,-p),g=null,y=null,v=null,b=null,_=m.clone().sub(f),x=0,S=0,w=0;d>0&&(x=Math.min(t,e)*(1-d),S=t-x,w=e-x);let T=m.clone();T.x-=x;let C=Math.PI-_.angle(),M=_.angle(),A=Math.tan(M/2),R=Math.tan(C/2),I=A+R,O=d?I:R,B=d?I:A;if(l=Math.min(l,(t-S)/O,_.length()/I),h=Math.min(h,(e-w)/B,_.length()/I),l>0){let kt=l/A;g=m.clone().sub(new Z(kt,l)),d&&(v=g.clone(),v.x-=x-I*l),m.sub(_.clone().setLength(kt))}if(h>0){let kt=h/R;y=f.clone().sub(new Z(kt,-h)),f.add(_.clone().setLength(kt)),d&&(b=y.clone(),b.x-=x-I*h,T.sub(_.clone().setLength(kt)))}_=m.clone().sub(f);let V=_.length()<.5,z=[],k=[],L=[],H=[],W=[],X=[],nt=(kt,qt,$t,Pt,oe)=>{for(let Gt=0;Gt<u+1;Gt++){let Zt=Gt/u,Jt=Pt<0?Zt:1-Zt;oe&&(Jt-=1),Jt*=kt;let $=Math.sin(Jt),se=Math.cos(Jt)*Pt,Pe=se*qt+$t.y;z.push($*qt+$t.x),k.push(Pe),L.push($),H.push(se),W.push(.5+Pe/i),X.push(!1)}},st=(kt,qt,$t)=>{let Pt=[kt,qt];$t<0&&Pt.reverse();for(let oe of Pt)z.push(oe),k.push(p*$t),L.push(0),H.push($t),W.push(.5),X.push(!0)};if(b&&y?(nt(C,h,b,-1,!0),nt(M,h,y,-1,!1)):y?(st(y.x,0,-1),nt(M,h,y,-1,!1)):n||st(e,w,-1),!V){let kt=RK(_).normalize();for(let qt=0;qt<=s;qt++){let $t=qt/s,Pt=_.y*$t+f.y;z.push(_.x*$t+f.x),k.push(Pt),L.push(kt.x),H.push(kt.y),W.push(.5+Pt/i),X.push(!1)}}if(v&&g?(nt(C,l,g,1,!1),nt(M,l,v,1,!0)):g?(nt(C,l,g,1,!1),st(g.x,0,1)):n||st(t,S,1),d&&!V){let kt=RK(_).multiplyScalar(-1).normalize();for(let qt=0;qt<=s;qt++){let $t=qt/s,Pt=_.y*-$t+T.y;z.push(_.x*-$t+T.x),k.push(Pt),L.push(kt.x),H.push(kt.y),W.push(.5+Pt/i),X.push(!1)}}let yt=z.length,pt=yt+(d&&!n?1:0),Q=(kt,qt)=>kt*yt+(qt===yt?0:qt),ut=o<2*Math.PI,wt=(r+1)*yt+(ut?2*(1+pt):0),St=new Float32Array(3*wt),Tt=new Float32Array(3*wt),vt=new Float32Array(2*wt),It=wt-1>65535?new Uint32Array(r*Math.max(0,pt-1)*6+(ut?2*(pt+1)*3:0)):new Uint16Array(r*Math.max(0,pt-1)*6+(ut?2*(pt+1)*3:0)),Ut=0,Bt=0;for(let kt=0;kt<=r;kt++){let qt=kt/r,$t=qt*o+a,Pt=Math.sin($t),oe=Math.cos($t);for(let Gt=0;Gt<yt;Gt++){let Zt=3*Bt,Jt=2*Bt,$=z[Gt],se=L[Gt];St[Zt]=$*Pt,St[Zt+1]=k[Gt],St[Zt+2]=$*oe,Tt[Zt]=se*Pt,Tt[Zt+1]=H[Gt],Tt[Zt+2]=se*oe,X[Gt]?(vt[Jt]=.5,vt[Jt+1]=.5):(vt[Jt]=qt,vt[Jt+1]=W[Gt]),Bt++}}for(let kt=0;kt<r;kt++)for(let qt=0;qt<pt-1;qt++){if(n&&d&&qt==s)continue;let $t=Q(kt,qt),Pt=Q(kt+1,qt),oe=Q(kt+1,qt+1),Gt=Q(kt,qt+1),Zt=St[3*oe+0],Jt=St[3*oe+2];It[Ut++]=$t,It[Ut++]=Pt,It[Ut++]=Gt,(Zt!=0||Jt!=0)&&(It[Ut++]=Pt,It[Ut++]=oe,It[Ut++]=Gt)}function zt(kt,qt,$t){let Pt=Math.sin($t),oe=Math.cos($t),Gt=-oe,Zt=Pt,Jt=kt<0?(ie,oi,wi)=>{It[Ut++]=ie,It[Ut++]=oi,It[Ut++]=wi}:(ie,oi,wi)=>{It[Ut++]=ie,It[Ut++]=wi,It[Ut++]=oi},$=(t+e+S+w)/4,se=3*Bt,Pe=2*Bt;St[se]=$*Pt,St[se+1]=0,St[se+2]=$*oe,Tt[se]=Gt,Tt[se+1]=0,Tt[se+2]=Zt,vt[Pe]=.5,vt[Pe+1]=.5;let Ve=Bt++;for(let ie=0;ie<pt;ie++){let oi=3*(qt+(ie===yt?0:ie));se=3*Bt,Pe=2*Bt,St[se]=St[oi],St[se+1]=St[oi+1],St[se+2]=St[oi+2],Tt[se]=Gt,Tt[se+1]=0,Tt[se+2]=Zt;let wi=oi/3*2|0;vt[Pe]=vt[wi],vt[Pe+1]=vt[wi+1],Bt++}for(let ie=Ve+1;ie<Bt-1;ie++)Jt(Ve,ie,ie+1);Jt(Ve,Bt-1,Ve+1)}ut&&(zt(-1,0,a),zt(1,r*yt,a+o)),this.setIndex(new _e(It.slice(0,Ut),1)),this.setAttribute("position",new _e(St,3)),this.setAttribute("normal",new _e(Tt,3)),this.setAttribute("uv",new _e(vt,2))}}}),OK=j(()=>{ht(),Y4(),d0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},t.parameters);return i.thetaLength=Ft.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;h===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=u>0||d>0||h<360?new gj(0,i/2,s,n,a,o,l,h*Math.PI/180,u,d,c,0,!0):new m4(i/2,s,n,a,o);let p=r/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),IK=j(()=>{ht(),c0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,height:r,depth:s,widthSegments:n,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:h}=t.parameters;return e=l===0?new Zh(i,r,s,n,a,o):new DK(i,r,s,n,a,o,l,h),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},HM=Math.PI/2,DK=class extends ye{constructor(t=1,e=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,h=o+1,u=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*h*(n+1+(r+1)+(s+1))+h*(h+1)/2*8:0),d=2*(n*s+r*n+r*s)+(l?4*o*(n+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*u),m=new Float32Array(3*u),f=new Float32Array(2*u),g=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(h),_=new Float64Array(h),x=new Float64Array(h),S=new Float64Array(h);for(let I=0;I<h;I++){let O=I/o*HM;b[I]=Math.sin(O)*a,_[I]=(1-Math.cos(O))*a,x[I]=Math.sin(O),S[I]=Math.cos(O)}let w=h*(h+1)/2,T=new Float64Array(3*w),C=new Float64Array(3*w);{let I=new P(t/2,e/2,i/2);I.subScalar(a);let O=0;for(let B=0;B<=o;B++){let V=HM*(1-B/o),z=Math.cos(V),k=Math.sin(V),L=0;for(let H=0;H<=B;H++){let W=z*Math.cos(L),X=k,nt=z*Math.sin(L);T[3*O]=W,T[3*O+1]=X,T[3*O+2]=nt,C[3*O]=I.x+W*a,C[3*O+1]=I.y+X*a,C[3*O+2]=I.z+nt*a,O++,L+=HM/B}}}function M(I,O,B,V,z,k,L,H,W,X){let nt=(k-2*a)/W,st=(L-2*a)/X,yt=k/2-a,pt=L/2-a,Q=H/2,ut=W+1,wt=X+1,St=0,Tt=new P;for(let vt=0;vt<wt;vt++){let It=vt*st-pt;for(let Ut=0;Ut<ut;Ut++){let Bt=Ut*nt-yt,zt=3*(y+St),kt=2*(y+St);Tt[I]=Bt*V,Tt[O]=It*z,Tt[B]=Q,p[zt]=Tt.x,p[zt+1]=Tt.y,p[zt+2]=Tt.z,Tt[I]=0,Tt[O]=0,Tt[B]=H>0?1:-1,m[zt]=Tt.x,m[zt+1]=Tt.y,m[zt+2]=Tt.z,f[kt]=Ut/W,f[kt+1]=1-vt/X,St+=1}}for(let vt=0;vt<X;vt++)for(let It=0;It<W;It++){let Ut=y+It+ut*vt,Bt=y+It+ut*(vt+1),zt=y+(It+1)+ut*(vt+1),kt=y+(It+1)+ut*vt;g[v++]=Ut,g[v++]=Bt,g[v++]=kt,g[v++]=Bt,g[v++]=zt,g[v++]=kt}y+=St}function A(I,O,B,V,z,k,L,H,W,X){let nt=(L-2*a)/X,st=L/2-a,yt=H/2-a,pt=W/2,Q=X+1,ut=0,wt=new P,St=new P;for(let Tt=0;Tt<o+1;Tt++){wt[O]=(yt+b[Tt])*z,wt[B]=(pt-_[Tt])*k,St[I]=0,St[O]=x[Tt]*Math.sign(wt[O]),St[B]=S[Tt]*Math.sign(wt[B]);for(let vt=0;vt<Q;vt++){let It=vt*nt-st;wt[I]=It*V;let Ut=3*(y+ut),Bt=2*(y+ut);p[Ut]=wt.x,p[Ut+1]=wt.y,p[Ut+2]=wt.z,m[Ut]=St.x,m[Ut+1]=St.y,m[Ut+2]=St.z,f[Bt]=vt/X,f[Bt+1]=0,ut+=1}}for(let Tt=0;Tt<o;Tt++)for(let vt=0;vt<X;vt++){let It=y+vt+Q*Tt,Ut=y+vt+Q*(Tt+1),Bt=y+(vt+1)+Q*(Tt+1),zt=y+(vt+1)+Q*Tt;g[v++]=It,g[v++]=Ut,g[v++]=zt,g[v++]=Ut,g[v++]=Bt,g[v++]=zt}y+=ut}function R(I,O,B){let V=I*O*B>0?(k,L,H)=>{g[v++]=k,g[v++]=L,g[v++]=H}:(k,L,H)=>{g[v++]=k,g[v++]=H,g[v++]=L},z=y;for(let k=0;k<w;k++){let L=3*k,H=3*y,W=2*y;p[H]=I*C[L],p[H+1]=O*C[L+1],p[H+2]=B*C[L+2],m[H]=I*T[L],m[H+1]=O*T[L+1],m[H+2]=B*T[L+2],f[W]=0,f[W+1]=0,y++}for(let k=0;k<o;k++){let L=z+k*(k+1)/2,H=z+(k+1)*(k+2)/2;V(L,H+1,H);for(let W=1;W<=k;W++)V(L+W-1,L+W,H+W),V(L+W,H+W+1,H+W)}}M("z","y","x",-1,-1,i,e,t,n,s),M("z","y","x",1,-1,i,e,-t,n,s),M("x","z","y",1,1,t,i,e,r,n),M("x","z","y",1,-1,t,i,-e,r,n),M("x","y","z",1,-1,t,e,i,r,s),M("x","y","z",-1,-1,t,e,-i,r,s),a>0&&(A("z","y","x",-1,-1,1,i,e,t,n),A("z","y","x",1,-1,-1,i,e,t,n),A("z","y","x",-1,1,-1,i,e,t,n),A("z","y","x",1,1,1,i,e,t,n),A("x","y","z",-1,-1,-1,t,e,i,r),A("x","y","z",1,-1,1,t,e,i,r),A("x","y","z",-1,1,1,t,e,i,r),A("x","y","z",1,1,-1,t,e,i,r),A("y","x","z",-1,-1,1,e,t,i,s),A("y","x","z",1,-1,-1,e,t,i,s),A("y","x","z",1,1,1,e,t,i,s),A("y","x","z",-1,1,-1,e,t,i,s),R(1,1,1),R(-1,1,1),R(1,-1,1),R(-1,-1,1),R(1,1,-1),R(-1,1,-1),R(1,-1,-1),R(-1,-1,-1)),this.setIndex(new _e(g,1)),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(m,3)),this.setAttribute("uv",new _e(f,2))}}}),m0t=j(()=>{ht(),X4=class extends ye{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,h=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new zs,m=s*r,f=r-m,g=n+1,y=new P,v=(Q,ut)=>y.subVectors(Q,ut).normalize(),b=(Q,ut)=>Array(Q).fill(void 0).map(ut),_=b(t.length/3,(Q,ut)=>new P().fromArray(t,3*ut).setLength(r)),x=[],S=1e6;for(let Q=0;Q<_.length;Q++){let ut,wt,St,Tt=_[Q],vt=[],It=1e10,Ut=-1;for(;(Ut=e.indexOf(Q,Ut+1))!=-1;){let qt=Ut-Ut%3;ut=e[qt+(Ut+1)%3],wt=e[qt+(Ut+2)%3],St=Tt.distanceToSquared(_[ut]),It=Math.min(It,St),vt.push([ut,wt,St])}It+=1e-6;let Bt=[],zt=0,kt=vt.length;for(let qt=0;qt<kt;qt++){[ut,wt,St]=vt[zt];let $t=x[ut]?.includes(Q)==1;St<=It&&Bt.push(ut+ +$t*S),zt=vt.findIndex(Pt=>Pt[0]==wt)}x.push(Bt)}let w=[];{let Q,ut,wt=0,St=0,Tt=u==3;for(let vt=0;vt<=n;vt++){Q=vt*(vt+1)/2,ut=(vt+1)*(vt+2)/2;for(let It=0;It<n-vt;It++)[wt,St]=[Q+It+vt+2,ut+It+vt+3],w.push(Q,ut,...Tt?[St,Q]:[wt,ut],St,wt),[Q,ut]=[wt,St];w.push(Q,ut,Q+n+2)}}let T=0;for(let Q=0;Q<x.length;Q++)for(let ut=0;ut<u;ut++)x[Q][ut]<S&&T++;let C=_.length*u*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(C),o=new Float64Array(C),l=new Float64Array(C/3*2);let M=(Q,ut,wt)=>{let St=h/3*2;l[St]=Math.atan2(wt,-Q)/2/Math.PI+.5,l[St+1]=1-(Math.atan2(-ut,Math.sqrt(Q*Q+wt*wt))/Math.PI+.5)},A=Q=>{a[h]=Q.x,a[h+1]=Q.y,a[h+2]=Q.z,o[h]=y.x,o[h+1]=y.y,o[h+2]=y.z,M(Q.x,Q.y,Q.z),h+=3},R=Q=>{a[h]=Q[0].x,a[h+1]=Q[0].y,a[h+2]=Q[0].z,o[h]=Q[1].x,o[h+1]=Q[1].y,o[h+2]=Q[1].z,M(Q[0].x,Q[0].y,Q[0].z),h+=3},I=(n+2)*(n+3)/2,O=new Float64Array(3*I),B=new Float64Array(3*I),V=new Float64Array(2*I),z=b(2*u*g,()=>new P),k=b(n*Math.max(0,n-1)/2,()=>new P),L=d.clone(),H=d.clone(),W=d.clone(),X=d.clone(),nt=d.clone(),st=[],yt=b(_.length,()=>b(u,()=>d.clone()));for(let Q=0;Q<_.length;Q++){d.copy(_[Q]).normalize(),L.copy(d).multiplyScalar(f);let ut=x[Q];for(let Bt=0;Bt<ut.length;Bt++){let zt=ut[Bt],kt=ut[(Bt+1)%u];p.setFromPointsAndIndices(_,Q,zt%S,kt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(L,yt[Q][Bt])}let wt=0,St=[],Tt=[],vt=new P;n==0&&[...yt[Q]].reduce((Bt,zt)=>Bt.add(zt),vt).multiplyScalar(1/u);for(let Bt=0;Bt<u;Bt++){let zt=[],kt=(Bt-1+u)%u,qt=yt[Q][kt],$t=yt[Q][Bt];d.copy(qt).sub(L),c.copy($t).sub(L);let Pt=L.angleTo(d),oe=d.angleTo(c),Gt=Math.cos(Pt)*m;n==0?H.copy(vt):H.copy(L).setLength(f+Gt),St.push(Gt);let Zt=[H,qt,$t];for(let Jt=0;Jt<2;Jt++){let $=Zt[Jt],se=Zt[Jt+1];X.subVectors($,L),nt.subVectors(se,L),W.crossVectors(X,nt).normalize();for(let Pe=0;Pe<g;Pe++){let Ve=[Pt,oe][Jt]*Pe/g;d.copy(X).applyAxisAngle(W,Ve).add(L),z[wt++].copy(d),Jt&&(v(d,L),zt.push([Pe==0?$:d.clone(),y.clone()]))}Jt&&(v(se,L),zt.push([se,y.clone()]))}Tt.push(zt)}st.push(Tt);let It=2*g,Ut=2;for(let Bt=0;Bt<u;Bt++){let zt=It*Bt,kt=It*((Bt+1)%u),qt=0,$t=[z[zt]];for(let Pt=1;Pt<g;Pt++){let oe=z[zt+Pt],Gt=z[kt+Pt];$t.push(oe);for(let Zt=1,Jt=Pt-Ut+1;Zt<=Jt;Zt++)d.lerpVectors(oe,Gt,Zt/(Jt+1)),d.sub(L).setLength(St[Bt]).add(L),$t.push(k[qt++].copy(d));$t.push(Gt)}for(let Pt=0;Pt<g;Pt++)$t.push(z[Pt+g+zt]);$t.push(z[kt+g]);for(let Pt=0,oe=$t.length;Pt<oe;Pt++){let Gt=$t[Pt],Zt=3*Pt,Jt=2*Pt;O[Zt]=Gt.x,O[Zt+1]=Gt.y,O[Zt+2]=Gt.z,v(Gt,L),B[Zt]=y.x,B[Zt+1]=y.y,B[Zt+2]=y.z,V[Jt]=Math.atan2(Gt.z,-Gt.x)/2/Math.PI+.5,V[Jt+1]=1-(Math.atan2(-Gt.y,Math.sqrt(Gt.x*Gt.x+Gt.z*Gt.z))/Math.PI+.5)}for(let Pt=0,oe=w.length;Pt<oe;Pt++){let Gt=3*w[Pt],Zt=2*w[Pt],Jt=h/3*2;a[h]=O[Gt],a[h+1]=O[Gt+1],a[h+2]=O[Gt+2],o[h]=B[Gt],o[h+1]=B[Gt+1],o[h+2]=B[Gt+2],l[Jt]=V[Zt],l[Jt+1]=V[Zt+1],h+=3}}}let pt=[];for(let Q=0;Q<x.length;Q++)for(let ut=0;ut<u;ut++){let wt=x[Q][ut];if(wt<S){let St=x[wt].findIndex(It=>It%S==Q),Tt=st[Q][ut],vt=st[wt][St];for(let It=0;It<g;It++){let Ut=Tt[It],Bt=vt[g-It],zt=Tt[It+1],kt=vt[g-(It+1)];R(Ut),R(Bt),R(zt),R(zt),R(Bt),R(kt)}pt.push(Tt[0][0],vt[g][0],Tt[g][0],vt[0][0])}}for(;pt.length;){let Q,ut,wt,[St,Tt]=pt.splice(0,2);Q=Tt;let vt=[St];for(;St!=Q;)vt.push(Q),ut=pt.indexOf(Q),wt=ut%2,Q=pt.splice(ut-wt,2)[1-wt];y.subVectors(vt[0],vt[1]).cross(d.subVectors(vt[0],vt[2])).normalize();let It=y.dot(vt[0])<0;It&&y.negate();for(let Ut=1;Ut<=vt.length-2;Ut++)A(vt[Ut+ +It]),A(vt[Ut+1-+It]),A(vt[0])}}(),function(){let u=new P,d=new P,c=new P,p=new P,m=new Z,f=new Z,g=new Z,y=(_,x,S,w)=>{w<0&&_.x===1&&(l[x]=_.x-1),S.x===0&&S.z===0&&(l[x]=w/2/Math.PI+.5)};for(let _=0,x=0;_<h;_+=9,x+=6){u.set(a[_+0],a[_+1],a[_+2]),d.set(a[_+3],a[_+4],a[_+5]),c.set(a[_+6],a[_+7],a[_+8]),m.set(l[x+0],l[x+1]),f.set(l[x+2],l[x+3]),g.set(l[x+4],l[x+5]),p.copy(u).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,u,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=h/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),C=Math.min(x,S,w);T>.9&&C<.1&&(x<.2&&(l[_+0]+=1),S<.2&&(l[_+2]+=1),w<.2&&(l[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}}(),this.setAttribute("position",new _e(new Float32Array(a.subarray(0,h)),3)),this.setAttribute("normal",new _e(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new _e(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(t){return new X4(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),NK=j(()=>{m0t(),ht(),p0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new oN(.5*e,n,a):new Q8(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},oN=class extends X4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],n,t,e,i),this.type=n}static fromJSON(t){return new oN(t.radius,t.corner,t.cornerSides)}}});function BK(t,e=new Z){let i=t.length();return e.set(-t.y/i,t.x/i)}function oCt(t){let e=new Z;e.addVectors(t.v0,kg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(t.v2,$S.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Ql(t.v0,e,i,t.v2)}function h2(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function lCt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function hCt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function f0t(t,e,i){let r=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function uCt(t,e,i){return VK(t,e)&&VK(e,i)&&yj(t.position,e.position,i.position)}function yj(t,e,i){return kg.copy(e).sub(t).cross($S.copy(i).sub(t))===0}function dCt(t,e,i,r,s){let n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=(t.y+e.y)/2,o=(t.x+e.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.y-e.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function cCt(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function pCt(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,h=i.x-t.x,u=i.y-t.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return f0t(e,t,i)>Math.PI&&(d*=-1),a=h2(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*u,i.y-a*h),[s,n]}function kK(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function VK(t,e){return yj(t.position,t.controls[1].position,e.position)&&yj(t.position,e.controls[0].position,e.position)}function zK(t,e=12,i=!1){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Bg(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Bg(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Bg(t[0].roundedCurveCorner,e)),r}function Bg(t,e=12){return t&&t instanceof Kw?2*e:t&&(t instanceof ml||t instanceof J8)?1:t&&t instanceof jP?e*t.points.length:e}var D1,$M,XM,Xg,rR,kg,$S,g0t,y0t,v0t,b0t,vj,bj,YM,LK,FK,UK,jK,GK,ms,_0t=j(()=>{ht(),D1=1e-12,$M=class{constructor(t){this.position=new Z,this.startPosition=new Z,this.uuid=Ft.generateUUID(),this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new $M(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},XM=class extends $M{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new XM(this.parent).copy(this)}},Xg=class extends $M{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new XM(this),new XM(this))}static create(t,e){let i=new Xg(t,new Z(...e.position));return i.controls[0].position.set(...e.controlPrevious.position),i.controls[1].position.set(...e.controlNext.position),i.roundness=e.roundness,i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored,i}getOppositeControl(t){let e=this.controls.indexOf(t);return e===0?this.controls[1]:e===1?this.controls[0]:null}applyOffsetToControls(t,e=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=e?s.position.copy(this.position):s.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new Xg(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),e=this.curveAfter?.getTangentAt(0);return[t,e]}computeNormals(t=new Z,e=new Z){let[i,r]=this.computeTangents();return i&&r&&(BK(i,t),BK(r,e)),[t,e]}computeTangent(t=new Z){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Z){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},rR=t=>t,kg=new Z,$S=new Z,g0t=new Z,y0t=new Z,v0t=new Z,b0t=new Z,vj=new P,bj=new P}),Em=j(()=>{ht(),_0t(),YM=new Z,LK=new Z,FK=new Z,UK=new Z,jK=new Z,GK=new Z,ms=class extends OS{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Pa(new P(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Ft.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ms;return r.isClosed=t.isClosed,r.points=t.points.map(s=>Xg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ms.createFromState(s)),e!==void 0&&i!==void 0&&r.applySize(e,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let e=0,i=this.points.length;e<i;e++)this.points[e].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(e=>this.getPointIndexById(e)).filter(e=>e>=0)}getPointIndexById(t){let e=this.points.length,i=this.points.findIndex(r=>r.uuid===t);if(i<0){let r=e;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let e=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=t-e;if(n<=s.points.length-1)return s.points[n];e+=s.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let e=this.points.indexOf(t);if(e>=0)return e;if(e=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(t);if(n>=0)return e+n;e+=s.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(e=>e.points));return[...this.points,...t]}applySize(t,e){t===0&&(t=.001),e===0&&(e=.001),this._width=t,this._height=e}applyScale(t,e){let i=YM.set(t,e);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(t,e);this._update()}createPoint(t,e=0,i=Ft.generateUUID()){let r;r=t instanceof Z?t:new Z(t,e);let s=new Xg(i,r);return s.roundness=this.roundness,s}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,e){this.points.splice(e,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(r.uuid===t)return r}for(let e=0,i=this.shapeHoles.length;e<i;e++){let r=this.shapeHoles[e].getPointByUuid(t);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let e=this.points.indexOf(t);e>=0&&this.points.splice(e,1),this.needsUpdate=!0}removePointById(t){let e=this.points.find(i=>i.uuid===t);e&&this.removePoint(e)}update(){for(let t=0,e=this.shapeHoles.length;t<e;t++)this.shapeHoles[t].update();this._update()}extractShapePointsToBuffer(t,e=12,i=!1){this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(s,n,a=12,o=!0){let l,h=bj.set(0,0,0),u=0,d=[];for(let c=0;c<n.length;c++){let p=rR(n[c]),m=kg,f=Bg(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Ql||p instanceof uc||p instanceof ml){if(p.getPoint(g/f,m),h.set(m.x,m.y,0),l!==void 0&&hCt(l,h))continue;l===void 0&&(l=vj),l.copy(h),s.setXYZ(u,h.x,h.y,h.z),u++}}o&&u>1&&(s.getX(u-1)!==s.getX(0)||s.getY(u-1)!==s.getY(0)||s.getZ(u-1)!==s.getZ(0))&&(s.setXYZ(u,s.getX(0),s.getY(0),s.getZ(0)),u++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=zK(this.points,t,!1),this.roundedCurveDivisions=zK(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=bj.set(0,0,0),h=0,u=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=rR(s[d]),m=kg,f=Bg(p,a);u.push(f);for(let g=0;g<=f;g++)if(p instanceof Ql||p instanceof uc||p instanceof ml){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=vj:(r.setXYZ(h,c.x,c.y,c.z),h++,r.setXYZ(h,l.x,l.y,l.z),h++),c.copy(l)}}return o&&h>1&&!(r.getX(h-1)===r.getX(0)&&r.getY(h-1)===r.getY(0)&&r.getZ(h-1)===r.getZ(0))&&(r.setXYZ(h,r.getX(0),r.getY(0),r.getZ(0)),h++),u}(t,this.curves,e,i,this.autoClose).reduce((r,s)=>r+s,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,r,s=12,n=!0){let a,o=0;for(let l=0;l<r.length;l++){let h=rR(r[l]),u=Bg(h,s),d=kg;for(let c=0;c<=u;c++)if(h instanceof Ql||h instanceof uc||h instanceof ml){if(h.getPoint(c/u,d),a!==void 0&&lCt(a,d,D1))continue;a===void 0&&(a=$S),a.copy(d),i.push(d.x,d.y),o++}}return h2(i[0],i[i.length-2],D1)&&h2(i[1],i[i.length-1],D1)&&(i.pop(),i.pop()),n&&o>1&&!(h2(i[o-1],i[1],D1)&&h2(i[o-2],i[0],D1))&&(i.push(i[0],i[1]),o++),i}(t,this.roundedCurves,e,this.autoClose)}getCurveIndexFromVertexId(t,e=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=e?this.roundedCurveDivisions:this.curveDivisions,s=0;e&&this.points[0].roundedCurveCorner!==void 0&&(s=.5*Bg(this.points[0].roundedCurveCorner,this.subdivision));let n=t-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let r=this.points[t],s=this.points[t>=this.points.length-1?0:t+1],n=this.curveDivisions,a=n[t];if(kK(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(YM.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=n[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){kK(e,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(e.controls[1].position.x,e.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,e.curveAfter=i;let r=i.clone();t.roundedCurveBefore=r,e.roundedCurveAfter=r,t.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(e===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[e-1];this._applyCurveForPoint(r,s)}}let t=this.getLastPoint();if(t?.curveAfter&&(t.curveAfter=void 0),this.isClosed){let e=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(e,i)}if(this.points.length>2){let e=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&uCt(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=h instanceof ml?h.v1.distanceTo(h.v2):h.getLength(),f=u instanceof ml?u.v1.distanceTo(u.v2):u.getLength(),g=Math.min(o,.499*m),y=Math.min(o,.499*f),v=Math.min(g,y),b=1-v/m,_=v/f,x=h.getPointAt(b,YM),S=u.getPointAt(_,LK);if(this._subSplitCurve(h,c,b,x,void 0),this._subSplitCurve(u,p,_,void 0,S),this.useCubicForRoundedCorners){let w=f0t(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[C,M]=dCt(x,S,T,FK,UK),A=cCt(C,M,s.position),[R,I]=pCt(A,x,S,T,jK,GK);d=new Ql(x.clone(),R.clone(),I.clone(),S.clone())}else d=new uc(x.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=d,this.roundedCurves.splice(i+e,0,d),e++}}}}_subSplitCurve(t,e,i,r,s){if(!(t instanceof ml)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(h,u,d,c,p=.5){let m=kg.subVectors(u,h).multiplyScalar(p).add(h),f=$S.subVectors(d,u).multiplyScalar(p).add(u),g=g0t.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=y0t.subVectors(f,m).multiplyScalar(p).add(m),b=v0t.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=b0t.subVectors(b,v).multiplyScalar(p).add(v);return[h.x,h.y,y.x,y.y,v.x,v.y,x.x,x.y,b.x,b.y,_.x,_.y,c.x,c.y]}(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return r!==void 0&&e.v2.copy(r),s!==void 0&&e.v1.copy(s),e}clone(){let t=new ms(this._width,this._height);return t.points=this.points.map(e=>e.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(e=>e.clone()),t}toJSON(){return{points:this.points.reduce((t,e)=>t.concat(e.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let e=t.points.length/7;for(let i=0;i<e;i++){let r=7*i,s=t.points[r+0],n=t.points[r+1],a=t.points[r+2],o=t.points[r+3],l=t.points[r+4],h=t.points[r+5],u=t.points[r+6],d=new Xg(Ft.generateUUID(),new Z(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,h),d.roundness=u,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ms;return r.fromJSON(i),r}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(r,s)=>{s instanceof Ql&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)};return this.points=(r=>{let s,n,a=[];for(s=0,n=r.length;s<n;s++)r[s]instanceof uc&&(r[s]=oCt(r[s]));for(s=0,n=r.length;s<n;s++){let h,u=r[s],d=s>0?r[s-1]:null;u instanceof Ql?(h=this.createPoint(u.v0),h.controls[1].position.copy(u.v1)):u instanceof ml&&(h=this.createPoint(u.v1)),h!==void 0&&(d!==null&&i(h,d),a.push(h))}let o=r[r.length-1],l=!1;return o instanceof Ql?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof ml&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof OS&&(this.shapeHoles=t.holes.map(r=>{let s=new ms;return s.fromShape(r),s})),this.update(),this}updatePoint(t,e){let i=this.getPointByUuid(t);i&&(e.position!==void 0&&i.position.fromArray(e.position),e.roundness!==void 0&&(i.roundness=e.roundness),e.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(t,e){let i=this.getPointByUuid(t)?.controls[0];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}updateNextControl(t,e){let i=this.getPointByUuid(t)?.controls[1];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}}});function lN({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function mCt(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(t),s=Math.sin(t),n=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function WK(t,e,i,r){let s=t*r-e*i<0?-1:1,n=Math.min(1,Math.max(-1,t*i+e*r));return s*Math.acos(n)}var sR,fCt=j(()=>{sR=2*Math.PI});function Xe(t,e){if(!t)throw e||"Assertion Failed!"}function lS(t){var e=t.windingRule,i=e===void 0?as.ODD:e,r=t.elementType,s=r===void 0?Ca.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,h=t.normal,u=h===void 0?[0,0,1]:h,d=t.contours,c=d===void 0?[]:d,p=t.strict,m=p===void 0||p,f=t.debug,g=f!==void 0&&f;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new x0t;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,a,l,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var as,Ca,je,H0,m_,uf,hN,uN,dN,qK,KM,cN,HK,$K,x0t,mT=j(()=>{var t;(t=as||(as={}))[t.ODD=0]="ODD",t[t.NONZERO=1]="NONZERO",t[t.POSITIVE=2]="POSITIVE",t[t.NEGATIVE=3]="NEGATIVE",t[t.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(Ca||(Ca={})),je=function(){function e(){}return e.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},e.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},e.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},e.edgeGoesLeft=function(i){return e.vertLeq(i.Dst,i.Org)},e.edgeGoesRight=function(i){return e.vertLeq(i.Org,i.Dst)},e.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},e.edgeEval=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?n<a?r.t-i.t+(i.t-s.t)*(n/(n+a)):r.t-s.t+(s.t-i.t)*(a/(n+a)):0},e.edgeSign=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?(r.t-s.t)*n+(r.t-i.t)*a:0},e.transEval=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?n<a?r.s-i.s+(i.s-s.s)*(n/(n+a)):r.s-s.s+(s.s-i.s)*(a/(n+a)):0},e.transSign=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?(r.s-s.s)*n+(r.s-i.s)*a:0},e.vertCCW=function(i,r,s){return i.s*(r.t-s.t)+r.s*(s.t-i.t)+s.s*(i.t-r.t)>=0},e.interpolate=function(i,r,s,n){return(i=i<0?0:i)<=(s=s<0?0:s)?s===0?(r+n)/2:r+i/(i+s)*(n-r):n+s/(i+s)*(r-n)},e.intersect=function(i,r,s,n,a){var o,l,h;e.vertLeq(i,r)||(h=i,i=r,r=h),e.vertLeq(s,n)||(h=s,s=n,n=h),e.vertLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),e.vertLeq(s,r)?e.vertLeq(r,n)?((o=e.edgeEval(i,s,r))+(l=e.edgeEval(s,r,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,r.s)):((o=e.edgeSign(i,s,r))+(l=-e.edgeSign(i,n,r))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,n.s)):a.s=(s.s+r.s)/2,e.transLeq(i,r)||(h=i,i=r,r=h),e.transLeq(s,n)||(h=s,s=n,n=h),e.transLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),e.transLeq(s,r)?e.transLeq(r,n)?((o=e.transEval(i,s,r))+(l=e.transEval(s,r,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,r.t)):((o=e.transSign(i,s,r))+(l=-e.transSign(i,n,r))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,n.t)):a.t=(s.t+r.t)/2},e}(),H0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},m_=function(){function e(i){this.side=i,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),e}(),uf=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},hN=function(){function e(){var i=new uf,r=new H0,s=new m_(0),n=new m_(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,s.next=s,s.Sym=n,n.next=n,n.Sym=s,this.vHead=i,this.fHead=r,this.eHead=s,this.eHeadSym=n}return e.prototype.makeEdge_=function(i){var r=new m_(0),s=new m_(1);i.Sym.side<i.side&&(i=i.Sym);var n=i.Sym.next;return s.next=n,n.Sym.next=r,r.next=i,i.Sym.next=s,r.Sym=s,r.Onext=r,r.Lnext=s,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,s.Sym=r,s.Onext=s,s.Lnext=r,s.Org=null,s.Lface=null,s.winding=0,s.activeRegion=null,r},e.prototype.splice_=function(i,r){var s=i.Onext,n=r.Onext;s.Sym.Lnext=r,n.Sym.Lnext=i,i.Onext=n,r.Onext=s},e.prototype.makeVertex_=function(i,r,s){var n=i;Xe(n,"Vertex can't be null!");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r;var o=r;do o.Org=n,o=o.Onext;while(o!==r)},e.prototype.makeFace_=function(i,r,s){var n=i;Xe(n,"Face can't be null");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r,n.trail=null,n.marked=!1,n.inside=s.inside;var o=r;do o.Lface=n,o=o.Lnext;while(o!==r)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,s=i.Sym.next;r.Sym.next=s,s.Sym.next=r},e.prototype.killVertex_=function(i,r){var s=i.anEdge,n=s;do n.Org=r,n=n.Onext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,r){var s=i.anEdge,n=s;do n.Lface=r,n=n.Lnext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new uf,r=new uf,s=new H0,n=this.makeEdge_(this.eHead);return this.makeVertex_(i,n,this.vHead),this.makeVertex_(r,n.Sym,this.vHead),this.makeFace_(s,n,this.fHead),n},e.prototype.splice=function(i,r){var s=!1,n=!1;if(i!==r){if(r.Org!==i.Org&&(n=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!n){var a=new uf;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new H0;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var r=i.Sym,s=!1;if(i.Lface!==i.Rface&&(s=!0,this.killFace_(i.Lface,i.Rface)),i.Onext===i)this.killVertex_(i.Org,null);else if(i.Rface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev),!s){var n=new H0;this.makeFace_(n,i,i.Lface)}r.Onext===r?(this.killVertex_(r.Org,null),this.killFace_(r.Lface,null)):(i.Lface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),s=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var n=new uf;return this.makeVertex_(n,s,r.Org),r.Lface=s.Lface=i.Lface,r},e.prototype.splitEdge=function(i){var r=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,r),i.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=i.Rface,r.winding=i.winding,r.Sym.winding=i.Sym.winding,r.idx=i.idx,r.Sym.idx=i.Sym.idx,r},e.prototype.connect=function(i,r){var s=!1,n=this.makeEdge_(i),a=n.Sym;if(r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(n,i.Lnext),this.splice_(a,r),n.Org=i.Dst,a.Org=r.Org,n.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!s){var o=new H0;this.makeFace_(o,n,i.Lface)}return n},e.prototype.zapFace=function(i){var r,s,n,a,o,l=i.anEdge;s=l.Lnext;do s=(r=s).Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),(n=r.Sym).Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var r=i.anEdge,s=0;do s++,r=r.Lnext;while(r!==i.anEdge);return s},e.prototype.mergeConvexFaces=function(i){var r,s,n,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(s=r.anEdge).Org;n=s.Lnext,(a=s.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&je.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&je.vertCCW(a.Lprev.Org,a.Org,s.Lnext.Lnext.Org)&&(n=a.Lnext,this.delete(a),s=null,a=null),!s||s.Lnext.Org!==o;)s=n;return!0},e.prototype.check=function(){var i,r,s,n,a,o,l=this.fHead,h=this.vHead,u=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Xe(i.prev===r),a=i.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Xe(i.prev===r&&i.anEdge===null),n=h,n=h;(s=n.next)!==h;n=s){Xe(s.prev===n),a=s.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(Xe(s.prev===n&&s.anEdge===null),o=u,o=u;(a=o.next)!==u;o=a)Xe(a.Sym.next===o.Sym),Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Org!==null),Xe(a.Dst!==null),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a);Xe(a.Sym.next===o.Sym&&a.Sym===this.eHeadSym&&a.Sym.Sym===a&&a.Org===null&&a.Dst===null&&a.Lface===null&&a.Rface===null)},e}(),uN=function(){this.handle=null},dN=function(){this.key=null,this.node=0},qK=function(){function e(i,r){this.leq=r,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=i,this.nodes=[],this.handles=[];for(var s=0;s<i+1;s++)this.nodes[s]=new uN,this.handles[s]=new dN;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((n=i<<1)<this.size&&this.leq(o[a[n+1].handle].key,o[a[n].handle].key)&&++n,Xe(n<=this.max),s=a[n].handle,n>this.size||this.leq(o[r].key,o[s].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.floatUp_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(s=a[n=i>>1].handle,n===0||this.leq(o[s].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(i){var r,s;if(2*(r=++this.size)>this.max){var n,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,n=a;n<this.nodes.length;n++)this.nodes[n]=new uN;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new dN}return this.freeList===0?s=r:(s=this.freeList,this.freeList=this.handles[s].node),this.nodes[r].handle=s,this.handles[s].node=r,this.handles[s].key=i,this.initialized&&this.floatUp_(r),s},e.prototype.extractMin=function(){var i=this.nodes,r=this.handles,s=i[1].handle,n=r[s].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[s].key=null,r[s].node=this.freeList,this.freeList=s,--this.size,this.size>0&&this.floatDown_(1)),n},e.prototype.delete=function(i){var r,s=this.nodes,n=this.handles;Xe(i>=1&&i<=this.max&&n[i].key!==null),s[r=n[i].node].handle=s[this.size].handle,n[s[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[s[r>>1].handle].key,n[s[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[i].key=null,n[i].node=this.freeList,this.freeList=i},e}(),KM=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},cN=function(){this.key=null,this.next=null,this.prev=null},HK=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new cN,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(i){return this.insertBefore(this.head,i)},e.prototype.search=function(i){var r=this.head;do r=r.next;while(r.key!==null&&!this.leq(this.frame,i,r.key));return r},e.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var s=new cN;return s.key=r,s.next=i.next,i.next.prev=s,s.prev=i,i.next=s,s},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),$K=function(){function e(){}return e.regionBelow=function(i){return i.nodeUp.prev.key},e.regionAbove=function(i){return i.nodeUp.next.key},e.debugEvent=function(i){},e.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.edgeLeq=function(i,r,s){var n=i.event,a=r.eUp,o=s.eUp;return a.Dst===n?o.Dst===n?je.vertLeq(a.Org,o.Org)?je.edgeSign(o.Dst,a.Org,o.Org)<=0:je.edgeSign(a.Dst,o.Org,a.Org)>=0:je.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?je.edgeSign(a.Dst,n,a.Org)>=0:je.edgeEval(a.Dst,n,a.Org)>=je.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&Xe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){Xe(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=s,s.activeRegion=r},e.topLeftRegion=function(i,r){var s,n=r.eUp.Org;do r=e.regionAbove(r);while(r.eUp.Org===n);if(r.fixUpperEdge){if((s=i.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;e.fixUpperEdge(i,r,s),r=e.regionAbove(r)}return r},e.topRightRegion=function(i){var r=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===r);return i},e.addRegionBelow=function(i,r,s){var n=new KM;return n.eUp=s,n.nodeUp=i.dict.insertBefore(r.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,s.activeRegion=n,n},e.isWindingInside=function(i,r){switch(i.windingRule){case as.ODD:return!!(1&r);case as.NONZERO:return r!==0;case as.POSITIVE:return r>0;case as.NEGATIVE:return r<0;case as.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(i,r.windingNumber)},e.finishRegion=function(i,r){var s=r.eUp,n=s.Lface;n.inside=r.inside,n.anEdge=s,e.deleteRegion(i,r)},e.finishLeftRegions=function(i,r,s){for(var n,a=null,o=r,l=r.eUp;o!==s;){if(o.fixUpperEdge=!1,(n=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}n=i.mesh.connect(l.Lprev,n.Sym),e.fixUpperEdge(i,a,n)}l.Onext!==n&&(i.mesh.splice(n.Oprev,n),i.mesh.splice(l,n)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,r,s,n,a,o){var l,h,u,d,c=!0;u=s;do Xe(je.vertLeq(u.Org,u.Dst)),e.addRegionBelow(i,r,u.Sym),u=u.Onext;while(u!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),h=r,d=a;(u=(l=e.regionBelow(h)).eUp.Sym).Org===d.Org;)u.Onext!==d&&(i.mesh.splice(u.Oprev,u),i.mesh.splice(d.Oprev,u)),l.windingNumber=h.windingNumber-u.winding,l.inside=e.isWindingInside(i,l.windingNumber),h.dirty=!0,!c&&e.checkForRightSplice(i,h)&&(e.addWinding(u,d),e.deleteRegion(i,h),i.mesh.delete(d)),c=!1,h=l,d=u;h.dirty=!0,Xe(h.windingNumber-u.winding===l.windingNumber),o&&e.walkDirtyRegions(i,h)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=je.vertL1dist(r,i),a=je.vertL1dist(s,i),o=.5*a/(n+a),l=.5*n/(n+a);i.coords[0]+=o*r.coords[0]+l*s.coords[0],i.coords[1]+=o*r.coords[1]+l*s.coords[1],i.coords[2]+=o*r.coords[2]+l*s.coords[2]},e.getIntersectData=function(i,r,s,n,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,s,n),e.vertexWeights(r,a,o)},e.checkForRightSplice=function(i,r){var s=e.regionBelow(r),n=r.eUp,a=s.eUp;if(je.vertLeq(n.Org,a.Org)){if(je.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;je.vertEq(n.Org,a.Org)?n.Org!==a.Org&&(i.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,n)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(n,a.Oprev),r.dirty=s.dirty=!0)}else{if(je.edgeSign(n.Dst,a.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(n.Sym),i.mesh.splice(a.Oprev,n)}return!0},e.checkForLeftSplice=function(i,r){var s,n=e.regionBelow(r),a=r.eUp,o=n.eUp;if(Xe(!je.vertEq(a.Dst,o.Dst)),je.vertLeq(a.Dst,o.Dst)){if(je.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,s=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,s),s.Lface.inside=r.inside}else{if(je.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,s=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),s.Rface.inside=r.inside}return!0},e.checkForIntersect=function(i,r){var s,n,a=e.regionBelow(r),o=r.eUp,l=a.eUp,h=o.Org,u=l.Org,d=o.Dst,c=l.Dst,p=new uf;if(Xe(!je.vertEq(c,d)),Xe(je.edgeSign(d,i.event,h)<=0),Xe(je.edgeSign(c,i.event,u)>=0),Xe(h!==i.event&&u!==i.event),Xe(!r.fixUpperEdge&&!a.fixUpperEdge),h===u||Math.min(h.t,d.t)>Math.max(u.t,c.t))return!1;if(je.vertLeq(h,u)){if(je.edgeSign(c,h,u)>0)return!1}else if(je.edgeSign(d,u,h)<0)return!1;return e.debugEvent(i),je.intersect(d,h,c,u,p),Xe(Math.min(h.t,d.t)<=p.t),Xe(p.t<=Math.max(u.t,c.t)),Xe(Math.min(c.s,d.s)<=p.s),Xe(p.s<=Math.max(u.s,h.s)),je.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=je.vertLeq(h,u)?h:u,je.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),je.vertEq(p,h)||je.vertEq(p,u)?(e.checkForRightSplice(i,r),!1):!je.vertEq(d,i.event)&&je.edgeSign(d,i.event,p)>=0||!je.vertEq(c,i.event)&&je.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=e.topLeftRegion(i,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),a),e.addRightEdges(i,r,o.Oprev,o,o,!0),!0):d===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,r,l.Onext,o.Rprev,n,!0),!0):(je.edgeSign(d,i.event,p)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),je.edgeSign(c,i.event,p)<=0&&(r.dirty=a.dirty=!0,i.mesh.splitEdge(l.Sym),l.Org.s=i.event.s,l.Org.t=i.event.t),!1):(i.mesh.splitEdge(o.Sym),i.mesh.splitEdge(l.Sym),i.mesh.splice(l.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=i.pq.insert(o.Org),e.getIntersectData(i,o.Org,h,d,u,c),e.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,r){for(var s,n,a=e.regionBelow(r);;){for(;a.dirty;)r=a,a=e.regionBelow(a);if(!r.dirty&&(a=r,(r=e.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,s=r.eUp,n=a.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(n),n=(a=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(i,r),i.mesh.delete(s),s=(r=e.regionAbove(a)).eUp)),s.Org!==n.Org){if(s.Dst===n.Dst||r.fixUpperEdge||a.fixUpperEdge||s.Dst!==i.event&&n.Dst!==i.event)e.checkForRightSplice(i,r);else if(e.checkForIntersect(i,r))return}s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(i,r),i.mesh.delete(s),r=e.regionAbove(a))}},e.connectRightVertex=function(i,r,s){var n,a=s.Onext,o=e.regionBelow(r),l=r.eUp,h=o.eUp,u=!1;l.Dst!==h.Dst&&e.checkForIntersect(i,r),je.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=e.topLeftRegion(i,r),a=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),o),u=!0),je.vertEq(h.Org,i.event)&&(i.mesh.splice(s,h.Oprev),s=e.finishLeftRegions(i,o,null),u=!0),u?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=je.vertLeq(h.Org,l.Org)?h.Oprev:l,n=i.mesh.connect(s.Lprev,n),e.addRightEdges(i,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,r))},e.connectLeftDegenerate=function(i,r,s){var n,a,o,l,h;return n=r.eUp,je.vertEq(n.Org,s)?(Xe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):je.vertEq(n.Dst,s)?(Xe(!1),r=e.topRightRegion(r),a=l=(o=(h=e.regionBelow(r)).eUp.Sym).Onext,h.fixUpperEdge&&(Xe(a!==o),e.deleteRegion(i,h),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),je.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(i.mesh.delete(n.Onext),r.fixUpperEdge=!1),i.mesh.splice(s.anEdge,n),void e.sweepEvent(i,s))},e.connectLeftVertex=function(i,r){var s,n,a,o,l,h,u=new KM;if(u.eUp=r.anEdge.Sym,s=i.dict.search(u).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,je.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=je.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(h=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,h):e.computeWinding(i,e.addRegionBelow(i,s,h)),e.sweepEvent(i,r)):e.addRightEdges(i,s,r.anEdge,r.anEdge,null,!0)}},e.sweepEvent=function(i,r){i.event=r,e.debugEvent(i);for(var s=r.anEdge;s.activeRegion===null;)if((s=s.Onext)===r.anEdge)return void e.connectLeftVertex(i,r);var n=e.topLeftRegion(i,s.activeRegion);Xe(n!==null);var a=e.regionBelow(n),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,n,l):e.addRightEdges(i,n,l.Onext,o,o,!0)},e.addSentinel=function(i,r,s,n){var a=new KM,o=i.mesh.makeEdge();o.Org.s=s,o.Org.t=n,o.Dst.s=r,o.Dst.t=n,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},e.initEdgeDict=function(i){i.dict=new HK(i,e.edgeLeq);var r=i.bmax[0]-i.bmin[0],s=i.bmax[1]-i.bmin[1],n=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-s,l=i.bmax[1]+s;e.addSentinel(i,n,a,o),e.addSentinel(i,n,a,l)},e.doneEdgeDict=function(i){for(var r,s=0;(r=i.dict.min().key)!==null;)r.sentinel||(Xe(r.fixUpperEdge),Xe(++s===1)),Xe(r.windingNumber===0),e.deleteRegion(i,r)},e.removeDegenerateEdges=function(i){var r,s,n,a=i.mesh.eHead;for(r=a.next;r!==a;r=s)s=r.next,n=r.Lnext,je.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(i,n,r),i.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&((n===s||n===s.Sym)&&(s=s.next),i.mesh.delete(n)),(r===s||r===s.Sym)&&(s=s.next),i.mesh.delete(r))},e.initPriorityQ=function(i){var r,s,n,a=0;for(s=(n=i.mesh.vHead).next;s!==n;s=s.next)a++;for(a+=8,r=i.pq=new qK(a,je.vertLeq),s=(n=i.mesh.vHead).next;s!==n;s=s.next)s.pqHandle=r.insert(s);return s===n&&(r.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,r){var s,n,a;for(s=r.fHead.next;s!==r.fHead;s=n)n=s.next,Xe((a=s.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,r){var s,n;if(r===void 0&&(r=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(s=i.pq.extractMin())!==null;){for(;(n=i.pq.min())!==null&&je.vertEq(n,s);)n=i.pq.extractMin(),e.spliceMergeVertices(i,s.anEdge,n.anEdge);e.sweepEvent(i,s)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},e}(),x0t=function(){function e(){this.mesh=new hN,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=as.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},e.prototype.normalize_=function(i){var r=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!r)throw"Zero-size vector!";r=Math.sqrt(r),i[0]/=r,i[1]/=r,i[2]/=r},e.prototype.longAxis_=function(i){var r=0;return Math.abs(i[1])>Math.abs(i[0])&&(r=1),Math.abs(i[2])>Math.abs(i[r])&&(r=2),r},e.prototype.computeNormal_=function(i){var r,s,n,a,o,l,h=[0,0,0],u=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],g=this.mesh.vHead;r=g.next;for(var y=0;y<3;++y)a=r.coords[y],u[y]=a,f[y]=r,h[y]=a,m[y]=r;for(r=g.next;r!==g;r=r.next)for(var v=0;v<3;++v)(a=r.coords[v])<u[v]&&(u[v]=a,f[v]=r),a>h[v]&&(h[v]=a,m[v]=r);var b=0;if(h[1]-u[1]>h[0]-u[0]&&(b=1),h[2]-u[2]>h[b]-u[b]&&(b=2),u[b]>=h[b])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,s=f[b],n=m[b],d[0]=s.coords[0]-n.coords[0],d[1]=s.coords[1]-n.coords[1],d[2]=s.coords[2]-n.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],p[0]=d[1]*c[2]-d[2]*c[1],p[1]=d[2]*c[0]-d[0]*c[2],p[2]=d[0]*c[1]-d[1]*c[0],(o=p[0]*p[0]+p[1]*p[1]+p[2]*p[2])>l&&(l=o,i[0]=p[0],i[1]=p[1],i[2]=p[2]);l<=0&&(i[0]=i[1]=i[2]=0,i[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var i,r,s=this.mesh.fHead,n=this.mesh.vHead,a=0,o=s.next;o!==s;o=o.next)if(!((r=o.anEdge).winding<=0))do a+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(a<0){for(i=n.next;i!==n;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var i,r,s=this.mesh.vHead,n=[0,0,0],a=!1;n[0]=this.normal[0],n[1]=this.normal[1],n[2]=this.normal[2],!n[0]&&!n[1]&&!n[2]&&(this.computeNormal_(n),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(n);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=n[o]>0?1:-1;for(var l=s.next;l!==s;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,r);a&&this.checkOrientation_();for(var h=!0,u=s.next;u!==s;u=u.next)h?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,h=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},e.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,r){var s,n;if((s=r.anEdge).Lnext===s||s.Lnext.Lnext===s)throw"Mono region invalid";for(;je.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;je.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(je.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(je.edgeGoesLeft(n.Lnext)||je.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(je.edgeGoesRight(s.Lprev)||je.edgeSign(s.Dst,s.Org,s.Lprev.Org)>=0);)s=i.connect(s,s.Lprev).Sym;s=s.Lnext}if(n.Lnext===s)throw"Mono region invalid";for(;n.Lnext.Lnext!==s;)n=i.connect(n.Lnext,n).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)if(r=s.next,s.inside&&!this.tessellateMonoRegion_(i,s))return!1;return!0},e.prototype.discardExterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)r=s.next,s.inside||i.zapFace(s)},e.prototype.setWindingNumber_=function(i,r,s){for(var n,a=i.eHead.next;a!==i.eHead;a=n)n=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:s?i.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},e.prototype.outputPolymesh_=function(i,r,s,n){var a,o,l=0,h=0;s>3&&i.mergeConvexFaces(s);for(var u=i.vHead.next;u!==i.vHead;u=u.next)u.n=-1;for(var d=i.fHead.next;d!==i.fHead;d=d.next)if(d.n=-1,d.inside){a=d.anEdge,o=0;do(u=a.Org).n===-1&&(u.n=h,h++),o++,a=a.Lnext;while(a!==d.anEdge);if(o>s)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===Ca.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=h,this.vertices=[],this.vertices.length=h*n,this.vertexIndices=[],this.vertexIndices.length=h,u=i.vHead.next;u!==i.vHead;u=u.next)if(u.n!==-1){var c=u.n*n;this.vertices[c+0]=u.coords[0],this.vertices[c+1]=u.coords[1],n>2&&(this.vertices[c+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do u=a.Org,this.elements[p++]=u.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ca.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=o;f<s;++f)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,r){var s,n,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){n=s=l.anEdge;do this.vertexCount++,s=s.Lnext;while(s!==n);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*r,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var h=0,u=0,d=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,n=s=l.anEdge;do this.vertices[h++]=s.Org.coords[0],this.vertices[h++]=s.Org.coords[1],r>2&&(this.vertices[h++]=s.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(s):s.Org.idx,o++,s=s.Lnext;while(s!==n);this.elements[d++]=a,this.elements[d++]=o,a+=o}},e.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new hN),i<2&&(i=2),i>3&&(i=3);for(var s=null,n=0;n<r.length;n+=i)s===null?(s=this.mesh.makeEdge(),this.mesh.splice(s,s.Sym)):(this.mesh.splitEdge(s),s=s.Lnext),s.Org.coords[0]=r[n+0],s.Org.coords[1]=r[n+1],s.Org.coords[2]=i>2?r[n+2]:0,s.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(s),s.winding=1,s.Sym.winding=-1},e.prototype.tesselate=function(i,r,s,n,a,o){if(i===void 0&&(i=as.ODD),r===void 0&&(r=Ca.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),$K.computeInterior(this,o);var l=this.mesh;return r===Ca.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ca.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),as.ODD,as.NONZERO,as.POSITIVE,as.NEGATIVE,as.ABS_GEQ_TWO,Ca.POLYGONS,Ca.CONNECTED_POLYGONS,Ca.BOUNDARY_CONTOURS});function w0t(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let h=(l+1)%i;r+=t[2*l]*t[2*h+1]-t[2*h]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let h=(l+1)%i,u=t[2*h]-t[2*l],d=t[2*h+1]-t[2*l+1],c=Math.hypot(u,d);n.push(c>0?[s*d/c,-s*u/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,h)=>{if(l[0]*h[0]+l[1]*h[1]<=a)return l;let[u,d]=[l[0]+h[0],l[1]+h[1]],c=Math.hypot(u,d);return c>0?[u/c,d/c]:l};return n.map((l,h)=>[o(l,n[(h+i-1)%i]),o(l,n[(h+1)%i])])}function S0t(t,e,i){let r=t.length/2,s=new Float32Array(r+1);if(!(e>0)||!(i>0)||r<2)return{u:s,vScale:0};let n=0;for(let a=0;a<r;a++){let o=(a+1)%r;n+=Math.hypot((t[2*o]-t[2*a])/e,(t[2*o+1]-t[2*a+1])/i),s[a+1]=n}return{u:s,vScale:Math.sqrt(e*i)}}function T0t(t,e,i){for(let r=0;r<i.length;r+=3){let s=3*i[r],n=3*i[r+1],a=3*i[r+2],o=t[n]-t[s],l=t[n+1]-t[s+1],h=t[n+2]-t[s+2],u=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=h*u-o*c,m=o*d-l*u;if((l*c-h*d)*(e[s]+e[n]+e[a])+p*(e[s+1]+e[n+1]+e[a+1])+m*(e[s+2]+e[n+2]+e[a+2])<0){let f=i[r+1];i[r+1]=i[r+2],i[r+2]=f}}}var pW,M0t,mW,A0t=j(()=>{}),fW=j(()=>{pW={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},M0t={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},mW={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0}});function C0t(t,e){return t.normals[3*e+2]<.9999}function E0t(t){let e=_j.get(t);if(e!==void 0)return e;if(!(t.rise>0))return t;let i=new Float32Array(t.normals),r=t.positions.length/3;for(let n=0;n<r;n++){if(!C0t(t,n))continue;let a=i[3*n],o=i[3*n+1],l=Math.hypot(a,o);if(l===0)continue;let h=t.rise-t.positions[3*n+2],u=Math.min(1,Math.max(0,1-h/t.rise)),d=Math.sqrt(1-u*u);i[3*n]=a/l*d,i[3*n+1]=o/l*d,i[3*n+2]=u}let s={...t,normals:i};return _j.set(t,s),s}function P0t(t,e,i,r){let s=(e-t.minX)/t.spanX,n=(i-t.minY)/t.spanY;return r?[n,s]:[s,n]}var _j,K4,xj,gW=j(()=>{_j=new WeakMap}),gCt=j(()=>{ht(),mT(),ir(),A0t(),fW(),gW(),K4=class extends ye{constructor(t,e,i=12,r=as.ODD,s,n=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=t,this._depth=e,this._curveSegments=i,this._windingRule=r,this._uvPitch=n?void 0:s,this._legacy=n;let a,o=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(z=>z.extractShapePointsToFlatArray([],i))];try{a=lS({contours:o,windingRule:r,elementType:Ca.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=mW}let l=a?.vertexCount??0,h=a?.elementCount??0,u=1/0,d=1/0,c=-1/0,p=-1/0;for(let z of o)for(let k=0;k<z.length;k+=2)z[k]<u&&(u=z[k]),z[k]>c&&(c=z[k]),z[k+1]<d&&(d=z[k+1]),z[k+1]>p&&(p=z[k+1]);let m=this._uvPitch,f=m??(c-u||1),g=m??(p-d||1),y=m===void 0?u:0,v=m===void 0?d:0,b=o.map((z,k)=>w0t(z,k>0)),_=0;for(let z of b)_+=z.length;let x=2*l+4*_,S=3*h*2+6*_,w=new Float32Array(3*x),T=new Float32Array(3*x),C=new Float32Array(2*x),M=new Uint32Array(S),A=new Uint8Array(x),R=0,I=0,O=0,B=!1,V=(z,k,L,H,W,X,nt=(z-y)/f,st=(k-v)/g)=>{let yt=3*I;w[yt]=z,w[yt+1]=k,w[yt+2]=L,T[yt]=H,T[yt+1]=W,T[yt+2]=X,A[I]=L===e?B?2:1:0,C[2*I]=nt,C[2*I+1]=st,I++};if(a!==void 0)for(let[z,k]of[[e,1],[0,-1]]){let L=I;for(let H=0;H<l;H++)V(a.vertices[2*H],a.vertices[2*H+1],z,0,0,k);for(let H=0;H<h;H++){let[W,X,nt]=[a.elements[3*H],a.elements[3*H+1],a.elements[3*H+2]];M[O++]=L+W,M[O++]=L+(k>0?X:nt),M[O++]=L+(k>0?nt:X)}}B=!0;for(let z=0;z<o.length;z++){let k=o[z],L=b[z],H=k.length/2,{u:W,vScale:X}=n?{u:new Float32Array(H+1),vScale:0}:S0t(k,f,g);R=X;let nt=X===0?0:e/X,st={minX:y,minY:v,spanX:f,spanY:g},yt=(pt,[Q,ut],wt,St)=>{let Tt=k[2*pt],vt=k[2*pt+1],[It,Ut]=n?P0t(st,Tt,vt,wt):[St,wt?0:nt];V(Tt,vt,wt?0:e,Q,ut,0,It,Ut)};for(let pt=0;pt<L.length;pt++){let Q=(pt+1)%H,[ut,wt]=L[pt],[St,Tt]=[W[pt],W[pt+1]],vt=I;yt(pt,ut,!1,St),yt(pt,ut,!0,St),yt(Q,wt,!1,Tt),yt(Q,wt,!0,Tt),M[O++]=vt,M[O++]=vt+1,M[O++]=vt+2,M[O++]=vt+3,M[O++]=vt+2,M[O++]=vt+1}}T0t(w,T,M),this.setAttribute("position",new _e(w,3)),this.setAttribute("normal",new _e(T,3)),this.setAttribute("uv",new _e(C,2)),this.setIndex(new _e(M,1)),this._nearSide=A,this._vScale=R}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale)}canShiftDepthTo(t){return this._nearSide.length>0&&this._depth>0&&t>0}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=e,h===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=new K4(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return t.userData=K5(this.userData),t}}}),R0t=j(()=>{ht(),mT(),ir(),fW(),xj=class extends ye{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=as.ODD,this.elementType=Ca.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:as.ODD,elementType:Ca.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,n,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,h=!0;for(let c=0,p=a.length/2;c<p;c++){let m=2*c,f=a[m+0],g=a[m+1];if(s!==void 0&&f!==s&&(l=!1),n!==void 0&&g!==n&&(h=!1),s=f,n=g,!l&&!h)break}if(!l&&!h)try{r=lS({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=pW}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new _e(new Float32Array(3*u),3),this._normalAttribute=new _e(new Float32Array(3*u),3),this._uvAttribute=new _e(new Float32Array(2*u),2),this._indexAttribute=new _e(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=u;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1];x<c&&(c=x),x>p&&(p=x),S<m&&(m=S),S>f&&(f=S)}let g=p-c,y=f-m;for(let v=0,b=u;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1],w=(x-c)/g,T=(S-m)/y;this._positionAttribute.setXYZ(v,x,S,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,w,T)}for(let v=0,b=d;v<b;v++){let _=3*v,x=r.elements[_+0],S=r.elements[_+1],w=r.elements[_+2];this._indexAttribute.setX(_+0,x),this._indexAttribute.setX(_+1,S),this._indexAttribute.setX(_+2,w)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let t=new xj(this._shape,this._curveSegments);return t.userData=K5(this.userData),t}}});function yCt(t){return XK||(XK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.121/build",i=Promise.resolve().then(()=>(hH(),lH)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),fT=r}())}function vCt(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(N0t.has(s.type)&&s.depth!==void 0&&s.depth>0&&(s.extrudeBevelSize??0)>0&&(e=!0),s.type==="PathGeometry")){let n=s.extrusion;n!==void 0&&n.capType==="round"&&(n.bevel??0)>0&&(e=!0)}}),e}function D0t(t,e){let i=[t.extractShapePointsToFlatArray([],e)];for(let o of t.shapeHoles)i.push(o.extractShapePointsToFlatArray([],e));let r=0;for(let o of i)r+=o.length>>1;let s=new Float64Array(2*r),n=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)s.set(i[o],2*a),a+=i[o].length>>1,n[o]=a;return{points:s,ends:n}}function Z4(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=B0t.getNormalMatrix(s).elements;for(let u=0;u<a;u++){let d=3*u,c=3*(i+u),p=t.positions[d],m=t.positions[d+1],f=t.positions[d+2];e.positions[c]=o[0]*p+o[4]*m+o[8]*f+o[12],e.positions[c+1]=o[1]*p+o[5]*m+o[9]*f+o[13],e.positions[c+2]=o[2]*p+o[6]*m+o[10]*f+o[14];let g=t.normals[d],y=t.normals[d+1],v=t.normals[d+2];e.normals[c]=l[0]*g+l[3]*y+l[6]*v,e.normals[c+1]=l[1]*g+l[4]*y+l[7]*v,e.normals[c+2]=l[2]*g+l[5]*y+l[8]*v;let b=2*(i+u);if(n===void 0)e.uvs[b]=t.uvs[2*u],e.uvs[b+1]=t.uvs[2*u+1];else{let[_,x]=n(p,m,t.uvs[2*u],t.uvs[2*u+1],u);e.uvs[b]=_,e.uvs[b+1]=x}}let h=s.determinant()<0;for(let u=0;u<t.indices.length;u+=3)e.indices[r+u]=t.indices[u]+i,e.indices[r+u+1]=t.indices[u+(h?2:1)]+i,e.indices[r+u+2]=t.indices[u+(h?1:2)]+i}function O0t(t){let{owner:e,shape:i,curveSegments:r,assembledAt:s,bevel:n,bevelSegments:a}=t,o=function(c,p){let m=[p],f=g=>{m.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let y of g.points){m.push(y.roundness??0,y.position.x,y.position.y);for(let v of y.controls)m.push(v.position.x,v.position.y)}m.push(g.shapeHoles.length);for(let y of g.shapeHoles)f(y)};return f(c),function(g){let y=2166136261;for(let v=0;v<g.length;v++)y^=g[v],y=Math.imul(y,16777619)>>>0;return y}(new Uint8Array(new Float64Array(m).buffer))}(i,r),l=e??`outline:${o}`,h=`${n}/${a}`,u=Q4.get(l);if(u!==void 0&&u.outlineVersion===o&&u.capKey===h&&(t.stillServes?.(u)??1))return wj.placements++,u.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=D0t(c,p);return fT.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),I0t,40)}(i,r,s,n,a);wj.assemblies++;try{let c=function(p,m){return function(f,g,y,v,b){let _=1/0;for(let x=2;x<f.length;x+=3)f[x]<_&&(_=f[x]);if(_===1/0&&(_=0),_!==0)for(let x=2;x<f.length;x+=3)f[x]-=_;return{positions:f,normals:g,uvs:y,indices:v,rise:b-_}}(p.positions(),p.normals(),p.uvs(),p.indices(),m)}(d,s);return Q4.set(l,{outlineVersion:o,capKey:h,assembledAt:s,cap:c}),c}finally{d.free()}}function Q1(t,e){return .5*e>1.001*t}var fT,I0t,XK,N0t,B0t,YK,KK,ZK,Q4,wj,Sj,Pm,rb=j(()=>{ht(),ir(),A0t(),gW(),I0t=.4,N0t=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),B0t=new As,YK=new xt,KK=new xt,ZK=new xt().makeScale(1,1,-1),Q4=new Map,wj={assemblies:0,placements:0},Sj=class extends ye{constructor(t,e,i=0,r=12,s=3,n,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,fT===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._legacy=o,this._depth=e,this._bevel=i,this._curveSegments=r,this._bevelSegments=s,this._ownerId=n,this.rebuild()}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length>0&&Q1(this._effectiveBevel,t)&&Q1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=e,h===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}setDepth(t){t!==this._depth&&(this._depth=t,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let t=O0t({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>Q1(a.cap.rise,this._depth)&&Q1(a.cap.rise,a.assembledAt)}),e=function(a,o,l,h,u,d=!1){let c=h.positions.length/3,p=l-h.rise,m=h.rise,{points:f,ends:g}=D0t(a,o),y=1/0,v=1/0,b=-1/0,_=-1/0;for(let st=0;st<f.length;st+=2)f[st]<y&&(y=f[st]),f[st]>b&&(b=f[st]),f[st+1]<v&&(v=f[st+1]),f[st+1]>_&&(_=f[st+1]);d&&(u=void 0);let x=u??b-y,S=u??_-v,w={minX:y,minY:v,spanX:b-y||1,spanY:_-v||1},T=[],C=0;for(let st of g)T.push({at:C,count:st-C}),C=st;let M=0;for(let st of T)M+=st.count;let A=2*c+4*M,R=new Float32Array(3*A),I=new Float32Array(3*A),O=new Float32Array(2*A),B=new Uint32Array(2*h.indices.length+6*M),V=new Uint8Array(A),z=0,k=u===void 0?void 0:(st,yt)=>[st/u,yt/u],L=d?(st,yt,pt,Q,ut)=>C0t(h,ut)?[Q,pt]:[pt,Q]:k,H=d?E0t(h):h,W={positions:R,normals:I,uvs:O,indices:B};Z4(H,W,0,0,YK.makeTranslation(0,0,p),k),Z4(H,W,c,h.indices.length,KK.makeTranslation(0,0,m).multiply(ZK),L),V.fill(1,0,c);let X=2*c,nt=2*h.indices.length;for(let st=0;st<T.length;st++){let{at:yt,count:pt}=T[st],Q=f.subarray(2*yt,2*(yt+pt)),ut=w0t(Q,st>0),wt=d?{u:new Float32Array(pt+1),vScale:0}:S0t(Q,x,S),St=wt.u;z=wt.vScale;for(let Tt=0;Tt<pt;Tt++){let vt=(Tt+1)%pt,[It,Ut]=ut[Tt],Bt=X;for(let[zt,kt,qt,$t,Pt,oe]of[[Q[2*Tt],Q[2*Tt+1],It,p,St[Tt],2],[Q[2*vt],Q[2*vt+1],Ut,p,St[Tt+1],2],[Q[2*vt],Q[2*vt+1],Ut,m,St[Tt+1],0],[Q[2*Tt],Q[2*Tt+1],It,m,St[Tt],0]]){let Gt=3*X;if(R[Gt]=zt,R[Gt+1]=kt,R[Gt+2]=$t,I[Gt]=qt[0],I[Gt+1]=qt[1],I[Gt+2]=0,d){let[Zt,Jt]=P0t(w,zt,kt,oe===0);O[2*X]=Zt,O[2*X+1]=Jt}else O[2*X]=Pt,O[2*X+1]=z===0?0:($t-m)/z;V[X]=oe,X++}B[nt++]=Bt,B[nt++]=Bt+1,B[nt++]=Bt+2,B[nt++]=Bt,B[nt++]=Bt+2,B[nt++]=Bt+3}}return T0t(R,I,B),{positions:R,normals:I,uvs:O,indices:B,nearSide:V,vScale:z}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch,this._legacy);this._nearSide=e.nearSide,this._vScale=e.vScale,this._effectiveBevel=t.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),s=this.getAttribute("uv"),n=this.getIndex();if(i!==void 0&&r!==void 0&&s!==void 0&&n!==null&&i.array.length===e.positions.length&&r.array.length===e.normals.length&&s.array.length===e.uvs.length&&n.array.length===e.indices.length)return i.array.set(e.positions),r.array.set(e.normals),s.array.set(e.uvs),n.array.set(e.indices),i.needsUpdate=!0,r.needsUpdate=!0,s.needsUpdate=!0,void(n.needsUpdate=!0);this.setAttribute("position",new _e(e.positions,3)),this.setAttribute("normal",new _e(e.normals,3)),this.setAttribute("uv",new _e(e.uvs,2)),this.setIndex(new _e(e.indices,1))}clone(){let t=new Sj(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return t.userData=K5(this.userData),t}}}),Tm=j(()=>{Em(),gCt(),R0t(),rb(),mT(),Pm=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:as.ODD},t.parameters),s=Math.abs(r.width),n=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=t.shape??e?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ms?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ms(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let h=i??new ms(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:h,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:h}=t.parameters,u=h===1;return t.shape.roundness=a,i<=0?e=new xj(t.shape,n,{windingRule:o}):r<=0?e=new K4(t.shape,i,n,o,l,u):fT!==void 0?e=new Sj(t.shape,i,r,n,s,t.ownerId,l,u):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new K4(t.shape,i,n,o,l,u)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function bCt(t,e,i,r,s,n){if(r>=yW)return s>30||s%4==0?(function(u,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;u.addPoint(ZM(m-d,f,m-d,f-v,m-d,f+v)),u.addPoint(ZM(m,f+c,m-y,f+c,m+y,f+c)),u.addPoint(ZM(m+d,f,m+d,f+v,m+d,f-v)),u.addPoint(ZM(m,f-c,m+y,f-c,m-y,f-c)),p>0&&V0t(u,d,c,p)}(t,e,i,n),Math.round(s/4)):QK(t,r,s,e,i,n);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},h=function({px:u,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(u-c)/2,_=(d-p)/2;if(b===0&&_===0)return[];m=Math.abs(m),f=Math.abs(f);let x=Math.pow(b,2)/Math.pow(m,2)+Math.pow(_,2)/Math.pow(f,2);x>1&&(m*=Math.sqrt(x),f*=Math.sqrt(x));let S=function(I,O,B,V,z,k,L,H,W,X){let nt=Math.pow(z,2),st=Math.pow(k,2),yt=Math.pow(L,2),pt=Math.pow(H,2),Q=nt*st-nt*pt-st*yt;Q<0&&(Q=0),Q/=nt*pt+st*yt,Q=Math.sqrt(Q)*(W===X?-1:1);let ut=Q*z/k*H,wt=Q*-k/z*L,St=ut+(I+B)/2,Tt=wt+(O+V)/2,vt=(L-ut)/z,It=(H-wt)/k,Ut=(-L-ut)/z,Bt=(-H-wt)/k,zt=WK(1,0,vt,It),kt=WK(vt,It,Ut,Bt);return!X&&kt>0&&(kt-=sR),X&&kt<0&&(kt+=sR),{centerx:St,centery:Tt,ang1:zt,ang2:kt}}(u,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:C,centery:M}=S,A=Math.abs(T)/(sR/4);Math.abs(1-A)<1e-7&&(A=1);let R=Math.max(Math.ceil(A),1);T/=R;for(let I=0;I<R;I++)v.push(mCt(w,T)),w+=T;return v.map(I=>{let{x:O,y:B}=lN(I[0],m,f,C,M),{x:V,y:z}=lN(I[1],m,f,C,M),{x:k,y:L}=lN(I[2],m,f,C,M);return{x1:O,y1:B,x2:V,y2:z,x:k,y:L}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?function(u,d,c,p,m,f,g,y){let v=Math.round(m/p.length);u.addPoint(gv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=u.points[b],w=gv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),u.addPoint(w)}return y>0?k0t(u,f,g,y):u.addPoint(gv(0,0)),v}(t,a.x,a.y,h,s,e,i,n):QK(t,r,s,e,i,n)}function QK(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;t.addPoint(gv(h,u))}return e<yW?n>0?k0t(t,r,s,n):t.addPoint(gv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&V0t(t,r,s,n)),1}function gv(t,e){return new Xg(Ft.generateUUID(),new Z(t,e))}function ZM(t,e,i,r,s,n){let a=gv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function k0t(t,e,i,r){z0t(t,e,i,r).forEach(s=>t.addPoint(s))}function V0t(t,e,i,r){let s=z0t(t,e,i,r),n=new ms;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function z0t(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Z(s/e,n/i),o=t.points.map(l=>{let h=l.clone();return h.uuid=Ft.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var yW,pD,L0t,pN,F0t,J4=j(()=>{Em(),_0t(),fCt(),Tm(),ht(),yW=2*Math.PI,pD=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return i.angle=Ft.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let e,{width:i,height:r,spikes:s,angle:n,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=t.parameters,d=t.shape,c=bCt(d,.5*i,.5*r,n*Math.PI/180,s,a);return d.isClosed=!0,d.update(),n===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=Pm.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),JK=j(()=>{ht(),m0t(),L0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new pN(.5*e,n,a):new iU(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},pN=class extends X4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s,t,e,i),this.type=s}static fromJSON(t){return new pN(t.radius,t.corner,t.cornerSides)}}}),tZ=j(()=>{ht(),F0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{points:e,segments:i,verticalSegments:r}=t.parameters,s=new OS;s.moveTo(e[0].x,e[0].y),s.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new rU(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function $0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function _Ct(t){let{positions:e,faces:i,materialIndices:r,uvs:s}=t,n=e.length/3,a=i.length/3,o=s!==null&&a>0,l=3*a,h=new Uint32Array(l),u=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,f=8;for(;f<2*l;)f*=2;let g=f-1,y=new Int32Array(f).fill(-1),v=(O,B)=>{let V=(Math.imul(O,2654435761)^B)&g;for(;;){let z=y[V];if(z===-1)return y[V]=m,h[m]=O,u[m]=B,m++;if(h[z]===O&&u[z]===B)return z;V=V+1&g}},b=(O,B)=>{let V=O<B?O:B,z=O<B?B:O,k=(Math.imul(V,2654435761)^z)&g;for(;;){let L=y[k];if(h[L]===V&&u[L]===z)return L;k=k+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(O,B,V)=>{let z=O<B?v(O,B):v(B,O),k=++d[z];k===1?c[z]=V:k===2&&(p[z]=V),_[O]++,_[B]++,x[3*O]+=e[3*B],x[3*O+1]+=e[3*B+1],x[3*O+2]+=e[3*B+2],x[3*B]+=e[3*O],x[3*B+1]+=e[3*O+1],x[3*B+2]+=e[3*O+2]};for(let O=0;O<a;O++){let B=i[3*O],V=i[3*O+1],z=i[3*O+2];S(B,V,z),S(V,z,B),S(z,B,V)}let w=new Float64Array(3*m);for(let O=0;O<m;O++){let B=3*h[O],V=3*u[O];if(d[O]===2){let z=3*c[O],k=3*p[O];w[3*O]=.375*(e[B]+e[V])+.125*(e[z]+e[k]),w[3*O+1]=.375*(e[B+1]+e[V+1])+.125*(e[z+1]+e[k+1]),w[3*O+2]=.375*(e[B+2]+e[V+2])+.125*(e[z+2]+e[k+2])}else w[3*O]=.5*(e[B]+e[V]),w[3*O+1]=.5*(e[B+1]+e[V+1]),w[3*O+2]=.5*(e[B+2]+e[V+2])}let T,C=new Float64Array(3*n);for(let O=0;O<n;O++){let B=_[O];B===3?T=3/16:B>3&&(T=3/(8*B));let V=1-B*Number(T),z=Number(T);B===2&&(V=3/4,z=1/8),C[3*O]=e[3*O]*V+x[3*O]*z,C[3*O+1]=e[3*O+1]*V+x[3*O+1]*z,C[3*O+2]=e[3*O+2]*V+x[3*O+2]*z}let M=new Float64Array(3*(n+m));M.set(C),M.set(w,3*n);let A=new Uint32Array(12*a),R=new Array(4*a),I=o?new Float64Array(24*a):null;for(let O=0;O<a;O++){let B=i[3*O],V=i[3*O+1],z=i[3*O+2],k=b(B,V)+n,L=b(V,z)+n,H=b(z,B)+n,W=12*O;A[W++]=k,A[W++]=L,A[W++]=H,A[W++]=B,A[W++]=k,A[W++]=H,A[W++]=V,A[W++]=L,A[W++]=k,A[W++]=z,A[W++]=H,A[W++]=L;let X=r[O];if(R[4*O]=X,R[4*O+1]=X,R[4*O+2]=X,R[4*O+3]=X,I!==null){let nt=6*O,st=s[nt],yt=s[nt+1],pt=s[nt+2],Q=s[nt+3],ut=s[nt+4],wt=s[nt+5],St=$0(st,pt),Tt=$0(yt,Q),vt=$0(pt,ut),It=$0(Q,wt),Ut=$0(st,ut),Bt=$0(yt,wt),zt=24*O;I[zt++]=St,I[zt++]=Tt,I[zt++]=vt,I[zt++]=It,I[zt++]=Ut,I[zt++]=Bt,I[zt++]=st,I[zt++]=yt,I[zt++]=St,I[zt++]=Tt,I[zt++]=Ut,I[zt++]=Bt,I[zt++]=pt,I[zt++]=Q,I[zt++]=vt,I[zt++]=It,I[zt++]=St,I[zt++]=Tt,I[zt++]=ut,I[zt++]=wt,I[zt++]=Ut,I[zt++]=Bt,I[zt++]=vt,I[zt++]=It}}return{positions:M,faces:A,materialIndices:R,uvs:I}}var QM,U0t,sn,j0t,vW,xCt=j(()=>{ht(),QM=1e4,U0t=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(r){let s=r.getAttribute("position");if(s===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let n=r.getAttribute("uv"),a=r.getIndex(),o=s.count,l=new Map,h=new Uint32Array(o),u=[],d=0;for(let v=0;v<o;v++){let b=s.getX(v),_=s.getY(v),x=s.getZ(v),S=Math.round(b*QM),w=Math.round(_*QM),T=Math.round(x*QM),C=l.get(S);C===void 0&&(C=new Map,l.set(S,C));let M=C.get(w);M===void 0&&(M=new Map,C.set(w,M));let A=M.get(T);A===void 0&&(A=d++,M.set(T,A),u.push(b,_,x)),h[v]=A}let c=[],p=[],m=n===void 0?null:[],f=a!==null?a.count:o,g=(v,b)=>{let _=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,S=a!==null?a.getX(v+2):v+2;if(!(_<o&&x<o&&S<o))return;let w=h[_],T=h[x],C=h[S];w===T||T===C||C===w||(c.push(w,T,C),p.push(b),m!==null&&m.push(n.getX(_),n.getY(_),n.getX(x),n.getY(x),n.getX(S),n.getY(S)))},y=r.groups;if(y.length>0)for(let v=0;v<y.length;v++){let b=y[v],_=b.materialIndex===void 0?0:b.materialIndex,x=Math.max(b.start,0),S=Math.min(b.start+b.count,f);for(let w=x;w<S&&w+2<f;w+=3)g(w,_)}else for(let v=0;v+2<f;v+=3)g(v,0);return{positions:Float64Array.from(u),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=_Ct(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,h=n.length/3,u=a.length/3,d=new Float64Array(3*h);for(let y=0;y<u;y++){let v=3*a[3*y],b=3*a[3*y+1],_=3*a[3*y+2],x=n[_]-n[b],S=n[_+1]-n[b+1],w=n[_+2]-n[b+2],T=n[v]-n[b],C=n[v+1]-n[b+1],M=n[v+2]-n[b+2],A=S*M-w*C,R=w*T-x*M,I=x*C-S*T;d[v]+=A,d[v+1]+=R,d[v+2]+=I,d[b]+=A,d[b+1]+=R,d[b+2]+=I,d[_]+=A,d[_+1]+=R,d[_+2]+=I}for(let y=0;y<h;y++){let v=d[3*y],b=d[3*y+1],_=d[3*y+2],x=Math.sqrt(v*v+b*b+_*_)||1;d[3*y]=v/x,d[3*y+1]=b/x,d[3*y+2]=_/x}let c=3*u,p=new Float32Array(3*c),m=new Float32Array(3*c),f=l!==null&&l.length>0?new Float32Array(2*c):null;for(let y=0;y<c;y++){let v=3*a[y];p[3*y]=n[v],p[3*y+1]=n[v+1],p[3*y+2]=n[v+2],m[3*y]=d[v],m[3*y+1]=d[v+1],m[3*y+2]=d[v+2]}f!==null&&f.set(l.subarray(0,2*c));let g=new ye;g.setAttribute("position",new _e(p,3)),c>0&&(g.setAttribute("normal",new _e(m,3)),g.setAttribute("color",new _e(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new _e(f,2));for(let y=0;y<u;){let v=o[y],b=y;do y++;while(y<u&&o[y]===v);g.addGroup(3*b,3*(y-b),v)}return s.boundingBox!==null&&(g.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(g.boundingSphere=s.boundingSphere.clone()),g}(e,t)}}}),eZ=j(()=>{ht(),xCt(),sn=new P,j0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new ye().copy(new Zh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(sn),i={width:sn.x,height:sn.y,depth:sn.z,subdivisions:0}):i=e.parameters;let s={...i,...t.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(t){let{width:e,height:i,depth:r,subdivisions:s}=t.parameters,n=t.geometry??new ye().copy(new Zh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let h=new cr,u=l.attributes.position;return u?(h.setFromBufferAttribute(u),h):(h.makeEmpty(),h)}(n),n.boundingBox.getSize(sn)):sn.set(a.width,a.height,a.depth),(e!==sn.x||i!==sn.y||r!==sn.z)&&n.scale(sn.x===0?1:e/sn.x,sn.y===0?1:i/sn.y,sn.z===0?1:r/sn.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new U0t(s).modify(o)):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete t.geometry,Object.assign(n,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new MG(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(sn);let n=100/sn.x;Object.assign(s.parameters,{width:100,height:sn.y*n,depth:sn.z*n}),e(this.build(s))})}}}),Tj=j(()=>{Em(),Tm(),vW=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},t.parameters);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i,c=2*Math.PI/r;for(let m=0;m<r;m++){let f=c*m,g=0+Math.sin(f)*u,y=0+Math.cos(f)*d;h.addPoint(h.createPoint(g,y))}h.isClosed=!0;for(let m=0,f=h.points.length;m<f;m++)h.points[m].roundness=s;h.roundness=s,h.update();let p=Pm.create({shape:h,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...t,type:"PolygonGeometry"}})}}});function f_(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function mN(t,e,i,r,s,n){let a=W0t.copy(e).sub(t),o=q0t.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(t).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function wCt(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var G0t,W0t,q0t,iZ,mD,H0t,$0t,X0t,rZ,bW,Y0t,K0t,Z0t,Q0t,sZ=j(()=>{ht(),G0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,h=new iZ(.5*e,i,s,n,a,o,l),u=r/e;return u!==1&&h.scale(1,1,u),Object.assign(h,{userData:{...t,type:"PyramidGeometry"}})}},W0t=new P,q0t=new P,iZ=class extends ye{constructor(t=.5,e=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o,l=[],h=[],u=[],d=[],c=0,p=e/2,m=Math.PI/i,f=t*Math.cos(Math.PI/i),g=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new P(0,-p,0),_=new P(0,p,0),x=new Z(t,-p),S=new Z(f,-p),w=new Z(0,_.y).sub(S),T=new Z(0,_.y).sub(x),C=new Z(w.y,-w.x).normalize(),M=new Z(T.y,-T.x).normalize(),A=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,A);{let k=new P(C.x,C.y,0),L=new P(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);o=k.angleTo(L)}let R=n/Math.tan((Math.PI-w.angle())/2),I=n/Math.tan((Math.PI-o)/2),O=new P;if(!s){h.push(b.x,b.y,b.z),u.push(0,-1,0),d.push(0,0);let k=c++,L=[],H=x.clone(),W=R/Math.cos(Math.PI/i);H.x-=W;for(let X=0;X<i;X++){let nt=X/i*Math.PI*2+m;f_(H,new Z(Math.sin(nt),Math.cos(nt)),O),h.push(O.x,O.y,O.z),u.push(0,-1,0),d.push(0,0),L.push(c++)}for(let X=0;X<L.length;X++)l.push(L[X],k,L[(X+1)%L.length])}let B=[];{let k=new P,L=new P,H=new P,W=new P,X=new P,nt=new P;for(let st=0;st<i;st++){let yt=st/i*Math.PI*2+m,pt=(st+.5)/i*Math.PI*2+m,Q=(st+1)/i*Math.PI*2+m,ut=new Z(Math.sin(yt),Math.cos(yt)),wt=new Z(Math.sin(pt),Math.cos(pt)),St=new Z(Math.sin(Q),Math.cos(Q));f_(x,ut,L),f_(x,St,H),f_(C,wt,k),mN(_,L,H,I,I,W),h.push(W.x,W.y,W.z),mN(L,_,H,I,R,X),h.push(X.x,X.y,X.z),mN(H,L,_,R,I,nt),h.push(nt.x,nt.y,nt.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),d.push(0,0),d.push(0,0),d.push(0,0);let Tt=c++,vt=c++,It=c++;if(l.push(Tt,vt,It),n>0){{let zt=L.clone().add(H).multiplyScalar(.5),kt=_.clone().sub(zt).normalize(),qt=b.clone().sub(zt).normalize().add(kt).normalize().multiplyScalar(-1);V(zt,nt.clone().sub(X),qt,w.angle())}let Ut,Bt;{let zt=new P;f_(M,St,zt);let kt=nt.clone().add(W).multiplyScalar(.5);kt=wCt(kt,H,_);let qt=nt.clone().sub(W);[Ut,Bt]=V(kt,qt,zt,o,W.y)}{let zt=Ut,kt=zt.clone().setY(0).normalize(),qt=new P(0,-1,0),$t=kt.clone().cross(qt);z(zt,kt,qt,$t)}B.concat(Bt);{let zt=w.angle(),kt=Math.PI-zt,qt=_.clone();qt.y-=n/Math.sin(zt-Math.PI/2);let $t=new P,Pt=[];for(let Gt=0;Gt<a;Gt++){let Zt=[],Jt=Math.PI/2-kt*Gt/a,$=Math.cos(Jt),se=Math.sin(Jt),Pe=pt;for(let Ve=0;Ve<=Gt;Ve++){let ie=Math.cos(Pe),oi=Math.sin(Pe);k.x=$*oi,k.y=se,k.z=$*ie,$t.copy(qt).addScaledVector(k,n),h.push($t.x,$t.y,$t.z),u.push(k.x,k.y,k.z),d.push(0,0),Zt.push(c++),Pe+=2*Math.PI/Gt/i}Pt.push(Zt)}Bt.reverse(),Pt.push(Bt);let oe=Pt.length-1;for(let Gt=0;Gt<oe;Gt++){let Zt=Pt[Gt],Jt=Pt[Gt+1],$=Zt.length-1;l.push(Jt[1],Zt[0],Jt[0]);for(let se=1;se<=$;se++)l.push(Zt[se],Zt[se-1],Jt[se]),l.push(Jt[se+1],Zt[se],Jt[se])}}}}}function V(k,L,H,W,X){let nt=-W/2,st=(Math.PI-W)/2,yt=L.clone().normalize().cross(H);k.addScaledVector(H,-n/Math.sin(st));let pt=new P,Q=new P,ut=c,wt=[];for(let St=0;St<=a;St++){let Tt=nt+St/a*W;Q.set(0,0,0),Q.addScaledVector(yt,Math.sin(Tt)),Q.addScaledVector(H,Math.cos(Tt));for(let vt=0;vt<=1;vt++){let It=vt/1-.5;if(pt.copy(k),pt.addScaledVector(L,It),pt.addScaledVector(Q,n),X!=null){let Ut=Math.max(0,pt.y-X);pt.addScaledVector(L,-Ut/L.y)}h.push(pt.x,pt.y,pt.z),u.push(Q.x,Q.y,Q.z),d.push(0,0),vt===0&&wt.push(c),c++}}for(let St=0;St<a;St++)for(let Tt=0;Tt<1;Tt++){let vt=ut+Tt+2*St,It=vt+2,Ut=It+1,Bt=vt+1;l.push(vt,It,Bt),l.push(It,Ut,Bt)}return[k.clone().addScaledVector(L,.5),wt]}function z(k,L,H,W){let X=Math.PI/2,nt=T.angle()-X,st=[],yt=new P,pt=new P;for(let ut=0;ut<=a;ut++){let wt=[],St=ut/a;for(let Tt=0;Tt<=ut;Tt++){let vt=((ut?Tt/ut:0)-.5)*v,It=Math.cos(vt),Ut=Math.sin(vt),Bt=(X+Math.atan(Math.tan(nt)*It))*St,zt=Math.cos(Bt),kt=Math.sin(Bt);yt.set(0,0,0),yt.addScaledVector(L,kt*It),yt.addScaledVector(H,zt),yt.addScaledVector(W,kt*Ut),pt.copy(k).addScaledVector(yt,n),h.push(pt.x,pt.y,pt.z),u.push(yt.x,yt.y,yt.z),d.push(0,0),wt.push(c++)}st.push(wt)}let Q=st.length-1;for(let ut=0;ut<Q;ut++){let wt=st[ut],St=st[ut+1],Tt=wt.length-1;l.push(wt[0],St[1],St[0]);for(let vt=1;vt<=Tt;vt++)l.push(wt[vt-1],wt[vt],St[vt]),l.push(wt[vt],St[vt+1],St[vt])}}this.setIndex(l),this.setAttribute("position",new ge(h,3)),this.setAttribute("normal",new ge(u,3)),this.setAttribute("uv",new ge(d,2))}}}),t5=j(()=>{Em(),Tm(),mD=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters),r=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(t){let e=t.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}=t.parameters,u={x:.5*i,y:.5*r},d={x:-u.x,y:-u.y},c={x:u.x,y:u.y};function p(x,S,w){return S>i&&w>r?Math.min(x*i/S,x*r/w):S>i?x*i/S:w>r?x*r/w:x}let m=[];m[0]=s[0]===0?0:p(s[0],s[0]+s[3],s[0]+s[1]),m[1]=s[1]===0?0:p(s[1],s[1]+s[2],s[1]+s[0]),m[2]=s[2]===0?0:p(s[2],s[2]+s[1],s[2]+s[3]),m[3]=s[3]===0?0:p(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,g=c.x,y=c.y,v=d.y;e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(g,v)),e.addPoint(e.createPoint(f,v)),e.isClosed=!0;let b=!0;for(let x=0,S=e.points.length;x<S;x++)e.points[x].roundness=m[x],x>0&&m[x]!==m[x-1]&&(b=!1);b&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let _=Pm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),nZ=j(()=>{ht(),H0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},t.parameters);return i.thetaLength=Ft.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i=100,height:r=i,depth:s=i,widthSegments:n=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:h,thetaLength:u}=t.parameters;return u===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=new Ec(.5*i,n,a,o,l,h,u*Ft.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),aZ=j(()=>{ht(),$0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(t){let{width:e=100,height:i=e,widthSegments:r=8,heightSegments:s=8}=t.parameters,n=new Oc(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),oZ=j(()=>{ht(),X0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=t.parameters,o=new rZ(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},rZ=class extends ye{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(pt=0,Q=0,ut=0)=>new P(pt,Q,ut),p=c(),m=c(),[f,g,y]=[e/2,t/2,i/2],v=-g,b=+g,[_,x,S]=[c(v,-f,+y),c(v,-f,-y),c(v,+f,-y)],w=(pt,Q=!1)=>Math.sin(pt-Math.PI/(+Q+1)),T=(pt,Q=!1)=>Math.cos(pt-Math.PI/(+Q+1));S.y=Math.sin(r)*e-f;let C=Math.cos(r)*e-y,M=_.z-h;r<=d?(S.z=Math.min(C,M),S.z==M&&(S.y-=(C-M)/Math.tan(d-r))):x.z=Math.min(x.z-C-y,_.z-h),p.subVectors(_,x),m.subVectors(S,x);let A=Math.min(p.length(),m.length())*s/100,R=A*Math.tan(r/2),I=A/Math.cos(r/2),O=p.clone().normalize().add(m.normalize()).setLength(I).add(x);p.set(0,w(r,!0),T(r,!0)),u.push([S,p.clone()]);let B=(Math.PI-r)/n;for(let pt=0;pt<=n;pt++){let Q=d+r+pt*B;p.set(0,Math.sin(Q)*R,Math.cos(Q)*R),p.add(O),m.set(0,w(Q),T(Q)),u.push([p.clone(),m.clone()])}u.push([_,c(0,1,0)]);let V=Math.sin(B/2)*R*2,z=u.length-1,k=u[0][0].distanceTo(u[1][0]),L=k+V*n+u[z-1][0].distanceTo(u[z][0]);u[0].push(1);for(let pt=0;pt<=n;pt++)u[pt+1].push(1-(k+pt*V)/L);u[z].push(0);let H,W,X,[nt,st,yt]=u[0];for(let pt=1;pt<u.length;pt++)[H,W,X]=u[pt],a.push(v,nt.y,nt.z,v,H.y,H.z,b,nt.y,nt.z,b,nt.y,nt.z,v,H.y,H.z,b,H.y,H.z),o.push(0,st.y,st.z,0,W.y,W.z,0,st.y,st.z,0,st.y,st.z,0,W.y,W.z,0,W.y,W.z),l.push(0,yt,0,X,1,yt,1,yt,0,X,1,X),[nt,st,yt]=[H,W,X];this.setAttribute("position",new ge(a,3)),this.setAttribute("normal",new ge(o,3)),this.setAttribute("uv",new ge(l,2))}}}),Mj=j(()=>{Em(),Tm(),bW=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=t.parameters,d=t.shape,c=.5*e,p=.5*i,m=a*Math.PI/360/s,f=Math.PI/2*3*-1,g=c*r/100,y=p*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let _=m*b,x=0+Math.sin(_)*c,S=0+Math.cos(_)*p;d.addPoint(d.createPoint(x,S))}}else for(let b=0;b<s;b++){let _=0+Math.cos(f)*c,x=0+Math.sin(f)*p;d.addPoint(d.createPoint(_,x)),f+=m,_=0+Math.cos(f)*g,x=0+Math.sin(f)*y,d.addPoint(d.createPoint(_,x)),f+=m}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let v=Pm.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}});return Object.assign(v,{userData:{...t,type:"StarGeometry"}})}}}),lZ=j(()=>{ht(),Y0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i}=t.parameters,r=new Oc(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),hZ=j(()=>{ht(),WS(),K0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let n=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,h=function(u,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=Ft.clamp(m/360,0,1);if(x===0){let S=new ye;return S.setAttribute("position",new ge([],3)),S}return x===1&&(b=0),new uj(!0,u,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return h.scale(1,i/e,1),Object.assign(h,{userData:{...t,type:"TorusGeometry"}})}}}),uZ=j(()=>{ht(),Z0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??.125*i.width})}}static build(t){let{width:e,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new sU(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),dZ=j(()=>{Em(),Tm(),Q0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},t.parameters);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i;o?(h.addPoint(h.createPoint(-u,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))):(h.addPoint(h.createPoint(0,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))),h.isClosed=!0;for(let p=0,m=h.points.length;p<m;p++)h.points[p].roundness=r;h.roundness=r,h.update();let c=Pm.create({shape:h,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...t,type:"TriangleGeometry"}})}}}),SCt=j(()=>{ht()}),TCt=j(()=>{ht(),new Jn,new xt,new gc,new P,new P,new P,new P});function cZ(){let t=new ye;return t.setAttribute("position",new _e(new Float32Array([]),3)),t.setIndex(new _e(new Uint16Array([]),1)),t}var pZ,Aj,J0t=j(()=>{un(),Be(),mT(),ht(),dT(),Em(),Tm(),rb(),pZ=cZ().attributes,Aj=class extends ye{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this._nearSide=new Uint8Array(0),this._depth=0,this._effectiveBevel=0,this._vScale=0,Object.assign(this.attributes,pZ),this.userData={parameters:t,type:"TextGeometry"};let i=e.getFont(t.font);i?.isLoaded?(this.font=i,this.update(t,e)):this.updateFont(t.font,e).then(()=>{this.update(t,e),e?.requestRender()})}async updateFont(t,e){let i=e.getFont(t);i&&(this.font=i,await i.loadingPromise)}update(t,e){let i=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:h,fontSize:u,extrusionVersion:d}=t,c=Da.getDisplayedValue(l),p=function(S,w,T,C){let M=typeof S.width=="string"?Number(C.getVariable(S.width)):S.width,A=[""],R="";for(let I of T)R+=I,I===" "||I===`
365
+ `;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),u=h.width,d=h.height,c=function(p,m,f){let g=m;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*m*f);y.length||e(4,"unable to allocate buffer space");let v=0,b=0,_=4*g,x=new Uint8Array(4),S=new Uint8Array(_),w=f;for(;w>0&&b<p.byteLength;){b+4>p.byteLength&&e(1),x[0]=p[b++],x[1]=p[b++],x[2]=p[b++],x[3]=p[b++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&e(3,"bad rgbe scanline format");let T,C=0;for(;C<_&&b<p.byteLength;){T=p[b++];let A=T>128;if(A&&(T-=128),(T===0||C+T>_)&&e(3,"bad scanline data"),A){let R=p[b++];for(let I=0;I<T;I++)S[C++]=R}else S.set(p.subarray(b,b+T),C),C+=T,b+=T}let M=g;for(let A=0;A<M;A++){let R=0;y[v]=S[A+R],R+=g,y[v+1]=S[A+R],R+=g,y[v+2]=S[A+R],R+=g,y[v+3]=S[A+R],v+=4}w--}return y}(n.subarray(n.pos),u,d);switch(this.type){case Qe:l=c.length/4;let p=new Float32Array(4*l);for(let f=0;f<l;f++)r(c,4*f,p,4*f);a=p,o=Qe;break;case ai:l=c.length/4;let m=new Uint16Array(4*l);for(let f=0;f<l;f++)s(c,4*f,m,4*f);a=m,o=ai;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:u,height:d,data:a,header:h.string,gamma:h.gamma,exposure:h.exposure,type:o,colorSpace:Yu,minFilter:fe,magFilter:fe,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function TK(t){return t.length>2&&t[0]===35&&t[1]===63}function aN(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function s0t(t){let e=new vr(t.data,t.width,t.height,ln,ai);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var MK,lW,Sg,n0t=j(()=>{ht(),iCt()}),a0t=j(()=>{ht(),i0t(),r0t(),n0t(),MK=0,lW=class extends Qgt{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++MK,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=t.type==="video",this.isBuffer=t.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?t:t.data)}async updateSrc(t){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let e=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))for(let n of Object.values(s))n&&(n.image=this.img,n.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=t,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof t!="string"){let r,s=new FileReader;s.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(n=>{s.onloadend=a=>{r=a.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?TK(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let r=t instanceof Uint8Array?t:null;if(r===null)try{r=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{r=null}let s=r!==null&&TK(r)?function(n){try{let a=new t0t().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,h=a.data,u=new Uint16Array(h.length),d=4*o,c=f=>Kh.toHalfFloat(Math.pow(Math.max(Kh.fromHalfFloat(f),0),1/2.2)),p=new Map,m=f=>{let g=p.get(f);return g===void 0&&(g=c(f),p.set(f,g)),g};for(let f=0;f<l;f++){let g=f*d,y=(l-1-f)*d;for(let v=0;v<d;v+=4)u[y+v]=m(h[g+v]),u[y+v+1]=m(h[g+v+1]),u[y+v+2]=m(h[g+v+2]),u[y+v+3]=h[g+v+3]}return{isSplineHdr:!0,data:u,width:o,height:l}}catch{return null}}(r):null;s!==null&&(this.isHdr=!0,this.img=s,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:(oS||(oS=new Zgt),oS.load(i)),this.img.onload=e,await new Promise(r=>{this.img.onload=()=>{e(),r(null)}});var i}getTexture(t,e=1008,i=1006){let r=this._cache[t]?.[e]?.[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new SG(this.img,void 0,t,t):this.isHdr?(s=s0t(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new pi(this.img,void 0,t,t,i,e),this.isBuffer||(s.anisotropy=8,s.generateMipmaps=e===1008),this.loaded&&(s.needsUpdate=!0),this._cache[t]===void 0&&(this._cache[t]={}),this._cache[t][e]===void 0&&(this._cache[t][e]={}),this._cache[t][e][i]=s,s}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let r of Object.values(i))r&&(r.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,r]of Object.entries(e))for(let[s,n]of Object.entries(r))n?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),o0t=j(()=>{a0t(),Sg=class extends lW{}});function rCt(t){if(typeof t=="string")return t;let e=mj.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},mj.set(t,e)),e.url}var mj,sCt=j(()=>{mj=new Map});function nCt(){if(!fj)return AK||(AK=async function(){await Promise.resolve().then(()=>(rH(),t2t)),l0t(window!==void 0?window:global),fj=!0}())}var l0t,h0t,fj,AK,u0t=j(()=>{h0t=new Promise(t=>{l0t=t}),fj=!1});function CK(t,e){t.forEach(i=>{"dragDropActions"in i.data?(e.push(...i.data.dragDropActions.drag),e.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(e.push(...i.data.inActions),e.push(...i.data.outActions)):"gameActions"in i.data?(e.push(...i.data.gameActions.idle),e.push(...i.data.gameActions.move),e.push(...i.data.gameActions.jump),e.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{e.push(...r.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(e.push(...r.data.ifActions),e.push(...r.data.elseActions))}))})}function aCt(t){let e=!1,i=[];return t.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((n,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;CK(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;CK(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var EK,Z1,hW=j(()=>{sCt(),u0t(),h0t.then(t=>EK=t),Z1=class{constructor({src:t,volume:e,delay:i,loop:r}){let s;this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)},s=typeof t=="string"?{src:t}:{src:rCt(t),format:"wav"},this.sound=new EK.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,i){this.sound.on(t,e,i)}off(t,e,i){this.sound.off(t,e,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function PK(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(e=!0)}),e}var uW,dW=j(()=>{uW=null});function RK(t){return new Z(t.y,-t.x)}var cW,gj,d0t,c0t,HM,DK,X4,p0t,oN,Y4=j(()=>{ht(),cW=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,r=t.parameters?.radiusBottom,s=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);s.thetaLength=Ft.clamp(s.thetaLength,0,360),s.hollow=Ft.clamp(s.hollow??0,0,1);let n=s.width/2,a=s.radiusTop??n,o=s.radiusBottom??n;if(a===o?(a=n,o=n):a>o?(a=n,o=o*n/a):(a=a*n/o,o=n),s.shapeBlendNode){a=i??n,o=r??n;let l=2*Math.max(a,o);s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;h===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=c||m?new gj(u,d,s,n,a,o,l,h*Math.PI/180,c,c,p,m):new K2(u,d,s,n,a,o,l,h*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},gj=class extends ye{constructor(t,e,i,r,s,n,a,o,l,h,u,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0&&n,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,n&&(l=0,h=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=h);let m=new Z(t,p),f=new Z(e,-p),g=null,y=null,v=null,b=null,_=m.clone().sub(f),x=0,S=0,w=0;d>0&&(x=Math.min(t,e)*(1-d),S=t-x,w=e-x);let T=m.clone();T.x-=x;let C=Math.PI-_.angle(),M=_.angle(),A=Math.tan(M/2),R=Math.tan(C/2),I=A+R,O=d?I:R,B=d?I:A;if(l=Math.min(l,(t-S)/O,_.length()/I),h=Math.min(h,(e-w)/B,_.length()/I),l>0){let kt=l/A;g=m.clone().sub(new Z(kt,l)),d&&(v=g.clone(),v.x-=x-I*l),m.sub(_.clone().setLength(kt))}if(h>0){let kt=h/R;y=f.clone().sub(new Z(kt,-h)),f.add(_.clone().setLength(kt)),d&&(b=y.clone(),b.x-=x-I*h,T.sub(_.clone().setLength(kt)))}_=m.clone().sub(f);let V=_.length()<.5,z=[],k=[],L=[],H=[],W=[],X=[],nt=(kt,qt,$t,Pt,oe)=>{for(let Gt=0;Gt<u+1;Gt++){let Zt=Gt/u,Jt=Pt<0?Zt:1-Zt;oe&&(Jt-=1),Jt*=kt;let $=Math.sin(Jt),se=Math.cos(Jt)*Pt,Pe=se*qt+$t.y;z.push($*qt+$t.x),k.push(Pe),L.push($),H.push(se),W.push(.5+Pe/i),X.push(!1)}},st=(kt,qt,$t)=>{let Pt=[kt,qt];$t<0&&Pt.reverse();for(let oe of Pt)z.push(oe),k.push(p*$t),L.push(0),H.push($t),W.push(.5),X.push(!0)};if(b&&y?(nt(C,h,b,-1,!0),nt(M,h,y,-1,!1)):y?(st(y.x,0,-1),nt(M,h,y,-1,!1)):n||st(e,w,-1),!V){let kt=RK(_).normalize();for(let qt=0;qt<=s;qt++){let $t=qt/s,Pt=_.y*$t+f.y;z.push(_.x*$t+f.x),k.push(Pt),L.push(kt.x),H.push(kt.y),W.push(.5+Pt/i),X.push(!1)}}if(v&&g?(nt(C,l,g,1,!1),nt(M,l,v,1,!0)):g?(nt(C,l,g,1,!1),st(g.x,0,1)):n||st(t,S,1),d&&!V){let kt=RK(_).multiplyScalar(-1).normalize();for(let qt=0;qt<=s;qt++){let $t=qt/s,Pt=_.y*-$t+T.y;z.push(_.x*-$t+T.x),k.push(Pt),L.push(kt.x),H.push(kt.y),W.push(.5+Pt/i),X.push(!1)}}let yt=z.length,pt=yt+(d&&!n?1:0),Q=(kt,qt)=>kt*yt+(qt===yt?0:qt),ut=o<2*Math.PI,wt=(r+1)*yt+(ut?2*(1+pt):0),St=new Float32Array(3*wt),Tt=new Float32Array(3*wt),vt=new Float32Array(2*wt),It=wt-1>65535?new Uint32Array(r*Math.max(0,pt-1)*6+(ut?2*(pt+1)*3:0)):new Uint16Array(r*Math.max(0,pt-1)*6+(ut?2*(pt+1)*3:0)),Ut=0,Bt=0;for(let kt=0;kt<=r;kt++){let qt=kt/r,$t=qt*o+a,Pt=Math.sin($t),oe=Math.cos($t);for(let Gt=0;Gt<yt;Gt++){let Zt=3*Bt,Jt=2*Bt,$=z[Gt],se=L[Gt];St[Zt]=$*Pt,St[Zt+1]=k[Gt],St[Zt+2]=$*oe,Tt[Zt]=se*Pt,Tt[Zt+1]=H[Gt],Tt[Zt+2]=se*oe,X[Gt]?(vt[Jt]=.5,vt[Jt+1]=.5):(vt[Jt]=qt,vt[Jt+1]=W[Gt]),Bt++}}for(let kt=0;kt<r;kt++)for(let qt=0;qt<pt-1;qt++){if(n&&d&&qt==s)continue;let $t=Q(kt,qt),Pt=Q(kt+1,qt),oe=Q(kt+1,qt+1),Gt=Q(kt,qt+1),Zt=St[3*oe+0],Jt=St[3*oe+2];It[Ut++]=$t,It[Ut++]=Pt,It[Ut++]=Gt,(Zt!=0||Jt!=0)&&(It[Ut++]=Pt,It[Ut++]=oe,It[Ut++]=Gt)}function zt(kt,qt,$t){let Pt=Math.sin($t),oe=Math.cos($t),Gt=-oe,Zt=Pt,Jt=kt<0?(ie,oi,wi)=>{It[Ut++]=ie,It[Ut++]=oi,It[Ut++]=wi}:(ie,oi,wi)=>{It[Ut++]=ie,It[Ut++]=wi,It[Ut++]=oi},$=(t+e+S+w)/4,se=3*Bt,Pe=2*Bt;St[se]=$*Pt,St[se+1]=0,St[se+2]=$*oe,Tt[se]=Gt,Tt[se+1]=0,Tt[se+2]=Zt,vt[Pe]=.5,vt[Pe+1]=.5;let Ve=Bt++;for(let ie=0;ie<pt;ie++){let oi=3*(qt+(ie===yt?0:ie));se=3*Bt,Pe=2*Bt,St[se]=St[oi],St[se+1]=St[oi+1],St[se+2]=St[oi+2],Tt[se]=Gt,Tt[se+1]=0,Tt[se+2]=Zt;let wi=oi/3*2|0;vt[Pe]=vt[wi],vt[Pe+1]=vt[wi+1],Bt++}for(let ie=Ve+1;ie<Bt-1;ie++)Jt(Ve,ie,ie+1);Jt(Ve,Bt-1,Ve+1)}ut&&(zt(-1,0,a),zt(1,r*yt,a+o)),this.setIndex(new _e(It.slice(0,Ut),1)),this.setAttribute("position",new _e(St,3)),this.setAttribute("normal",new _e(Tt,3)),this.setAttribute("uv",new _e(vt,2))}}}),OK=j(()=>{ht(),Y4(),d0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},t.parameters);return i.thetaLength=Ft.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;h===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=u>0||d>0||h<360?new gj(0,i/2,s,n,a,o,l,h*Math.PI/180,u,d,c,0,!0):new m4(i/2,s,n,a,o);let p=r/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),IK=j(()=>{ht(),c0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,height:r,depth:s,widthSegments:n,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:h}=t.parameters;return e=l===0?new Zh(i,r,s,n,a,o):new DK(i,r,s,n,a,o,l,h),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},HM=Math.PI/2,DK=class extends ye{constructor(t=1,e=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,h=o+1,u=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*h*(n+1+(r+1)+(s+1))+h*(h+1)/2*8:0),d=2*(n*s+r*n+r*s)+(l?4*o*(n+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*u),m=new Float32Array(3*u),f=new Float32Array(2*u),g=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(h),_=new Float64Array(h),x=new Float64Array(h),S=new Float64Array(h);for(let I=0;I<h;I++){let O=I/o*HM;b[I]=Math.sin(O)*a,_[I]=(1-Math.cos(O))*a,x[I]=Math.sin(O),S[I]=Math.cos(O)}let w=h*(h+1)/2,T=new Float64Array(3*w),C=new Float64Array(3*w);{let I=new P(t/2,e/2,i/2);I.subScalar(a);let O=0;for(let B=0;B<=o;B++){let V=HM*(1-B/o),z=Math.cos(V),k=Math.sin(V),L=0;for(let H=0;H<=B;H++){let W=z*Math.cos(L),X=k,nt=z*Math.sin(L);T[3*O]=W,T[3*O+1]=X,T[3*O+2]=nt,C[3*O]=I.x+W*a,C[3*O+1]=I.y+X*a,C[3*O+2]=I.z+nt*a,O++,L+=HM/B}}}function M(I,O,B,V,z,k,L,H,W,X){let nt=(k-2*a)/W,st=(L-2*a)/X,yt=k/2-a,pt=L/2-a,Q=H/2,ut=W+1,wt=X+1,St=0,Tt=new P;for(let vt=0;vt<wt;vt++){let It=vt*st-pt;for(let Ut=0;Ut<ut;Ut++){let Bt=Ut*nt-yt,zt=3*(y+St),kt=2*(y+St);Tt[I]=Bt*V,Tt[O]=It*z,Tt[B]=Q,p[zt]=Tt.x,p[zt+1]=Tt.y,p[zt+2]=Tt.z,Tt[I]=0,Tt[O]=0,Tt[B]=H>0?1:-1,m[zt]=Tt.x,m[zt+1]=Tt.y,m[zt+2]=Tt.z,f[kt]=Ut/W,f[kt+1]=1-vt/X,St+=1}}for(let vt=0;vt<X;vt++)for(let It=0;It<W;It++){let Ut=y+It+ut*vt,Bt=y+It+ut*(vt+1),zt=y+(It+1)+ut*(vt+1),kt=y+(It+1)+ut*vt;g[v++]=Ut,g[v++]=Bt,g[v++]=kt,g[v++]=Bt,g[v++]=zt,g[v++]=kt}y+=St}function A(I,O,B,V,z,k,L,H,W,X){let nt=(L-2*a)/X,st=L/2-a,yt=H/2-a,pt=W/2,Q=X+1,ut=0,wt=new P,St=new P;for(let Tt=0;Tt<o+1;Tt++){wt[O]=(yt+b[Tt])*z,wt[B]=(pt-_[Tt])*k,St[I]=0,St[O]=x[Tt]*Math.sign(wt[O]),St[B]=S[Tt]*Math.sign(wt[B]);for(let vt=0;vt<Q;vt++){let It=vt*nt-st;wt[I]=It*V;let Ut=3*(y+ut),Bt=2*(y+ut);p[Ut]=wt.x,p[Ut+1]=wt.y,p[Ut+2]=wt.z,m[Ut]=St.x,m[Ut+1]=St.y,m[Ut+2]=St.z,f[Bt]=vt/X,f[Bt+1]=0,ut+=1}}for(let Tt=0;Tt<o;Tt++)for(let vt=0;vt<X;vt++){let It=y+vt+Q*Tt,Ut=y+vt+Q*(Tt+1),Bt=y+(vt+1)+Q*(Tt+1),zt=y+(vt+1)+Q*Tt;g[v++]=It,g[v++]=Ut,g[v++]=zt,g[v++]=Ut,g[v++]=Bt,g[v++]=zt}y+=ut}function R(I,O,B){let V=I*O*B>0?(k,L,H)=>{g[v++]=k,g[v++]=L,g[v++]=H}:(k,L,H)=>{g[v++]=k,g[v++]=H,g[v++]=L},z=y;for(let k=0;k<w;k++){let L=3*k,H=3*y,W=2*y;p[H]=I*C[L],p[H+1]=O*C[L+1],p[H+2]=B*C[L+2],m[H]=I*T[L],m[H+1]=O*T[L+1],m[H+2]=B*T[L+2],f[W]=0,f[W+1]=0,y++}for(let k=0;k<o;k++){let L=z+k*(k+1)/2,H=z+(k+1)*(k+2)/2;V(L,H+1,H);for(let W=1;W<=k;W++)V(L+W-1,L+W,H+W),V(L+W,H+W+1,H+W)}}M("z","y","x",-1,-1,i,e,t,n,s),M("z","y","x",1,-1,i,e,-t,n,s),M("x","z","y",1,1,t,i,e,r,n),M("x","z","y",1,-1,t,i,-e,r,n),M("x","y","z",1,-1,t,e,i,r,s),M("x","y","z",-1,-1,t,e,-i,r,s),a>0&&(A("z","y","x",-1,-1,1,i,e,t,n),A("z","y","x",1,-1,-1,i,e,t,n),A("z","y","x",-1,1,-1,i,e,t,n),A("z","y","x",1,1,1,i,e,t,n),A("x","y","z",-1,-1,-1,t,e,i,r),A("x","y","z",1,-1,1,t,e,i,r),A("x","y","z",-1,1,1,t,e,i,r),A("x","y","z",1,1,-1,t,e,i,r),A("y","x","z",-1,-1,1,e,t,i,s),A("y","x","z",1,-1,-1,e,t,i,s),A("y","x","z",1,1,1,e,t,i,s),A("y","x","z",-1,1,-1,e,t,i,s),R(1,1,1),R(-1,1,1),R(1,-1,1),R(-1,-1,1),R(1,1,-1),R(-1,1,-1),R(1,-1,-1),R(-1,-1,-1)),this.setIndex(new _e(g,1)),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(m,3)),this.setAttribute("uv",new _e(f,2))}}}),m0t=j(()=>{ht(),X4=class extends ye{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,h=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new zs,m=s*r,f=r-m,g=n+1,y=new P,v=(Q,ut)=>y.subVectors(Q,ut).normalize(),b=(Q,ut)=>Array(Q).fill(void 0).map(ut),_=b(t.length/3,(Q,ut)=>new P().fromArray(t,3*ut).setLength(r)),x=[],S=1e6;for(let Q=0;Q<_.length;Q++){let ut,wt,St,Tt=_[Q],vt=[],It=1e10,Ut=-1;for(;(Ut=e.indexOf(Q,Ut+1))!=-1;){let qt=Ut-Ut%3;ut=e[qt+(Ut+1)%3],wt=e[qt+(Ut+2)%3],St=Tt.distanceToSquared(_[ut]),It=Math.min(It,St),vt.push([ut,wt,St])}It+=1e-6;let Bt=[],zt=0,kt=vt.length;for(let qt=0;qt<kt;qt++){[ut,wt,St]=vt[zt];let $t=x[ut]?.includes(Q)==1;St<=It&&Bt.push(ut+ +$t*S),zt=vt.findIndex(Pt=>Pt[0]==wt)}x.push(Bt)}let w=[];{let Q,ut,wt=0,St=0,Tt=u==3;for(let vt=0;vt<=n;vt++){Q=vt*(vt+1)/2,ut=(vt+1)*(vt+2)/2;for(let It=0;It<n-vt;It++)[wt,St]=[Q+It+vt+2,ut+It+vt+3],w.push(Q,ut,...Tt?[St,Q]:[wt,ut],St,wt),[Q,ut]=[wt,St];w.push(Q,ut,Q+n+2)}}let T=0;for(let Q=0;Q<x.length;Q++)for(let ut=0;ut<u;ut++)x[Q][ut]<S&&T++;let C=_.length*u*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(C),o=new Float64Array(C),l=new Float64Array(C/3*2);let M=(Q,ut,wt)=>{let St=h/3*2;l[St]=Math.atan2(wt,-Q)/2/Math.PI+.5,l[St+1]=1-(Math.atan2(-ut,Math.sqrt(Q*Q+wt*wt))/Math.PI+.5)},A=Q=>{a[h]=Q.x,a[h+1]=Q.y,a[h+2]=Q.z,o[h]=y.x,o[h+1]=y.y,o[h+2]=y.z,M(Q.x,Q.y,Q.z),h+=3},R=Q=>{a[h]=Q[0].x,a[h+1]=Q[0].y,a[h+2]=Q[0].z,o[h]=Q[1].x,o[h+1]=Q[1].y,o[h+2]=Q[1].z,M(Q[0].x,Q[0].y,Q[0].z),h+=3},I=(n+2)*(n+3)/2,O=new Float64Array(3*I),B=new Float64Array(3*I),V=new Float64Array(2*I),z=b(2*u*g,()=>new P),k=b(n*Math.max(0,n-1)/2,()=>new P),L=d.clone(),H=d.clone(),W=d.clone(),X=d.clone(),nt=d.clone(),st=[],yt=b(_.length,()=>b(u,()=>d.clone()));for(let Q=0;Q<_.length;Q++){d.copy(_[Q]).normalize(),L.copy(d).multiplyScalar(f);let ut=x[Q];for(let Bt=0;Bt<ut.length;Bt++){let zt=ut[Bt],kt=ut[(Bt+1)%u];p.setFromPointsAndIndices(_,Q,zt%S,kt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(L,yt[Q][Bt])}let wt=0,St=[],Tt=[],vt=new P;n==0&&[...yt[Q]].reduce((Bt,zt)=>Bt.add(zt),vt).multiplyScalar(1/u);for(let Bt=0;Bt<u;Bt++){let zt=[],kt=(Bt-1+u)%u,qt=yt[Q][kt],$t=yt[Q][Bt];d.copy(qt).sub(L),c.copy($t).sub(L);let Pt=L.angleTo(d),oe=d.angleTo(c),Gt=Math.cos(Pt)*m;n==0?H.copy(vt):H.copy(L).setLength(f+Gt),St.push(Gt);let Zt=[H,qt,$t];for(let Jt=0;Jt<2;Jt++){let $=Zt[Jt],se=Zt[Jt+1];X.subVectors($,L),nt.subVectors(se,L),W.crossVectors(X,nt).normalize();for(let Pe=0;Pe<g;Pe++){let Ve=[Pt,oe][Jt]*Pe/g;d.copy(X).applyAxisAngle(W,Ve).add(L),z[wt++].copy(d),Jt&&(v(d,L),zt.push([Pe==0?$:d.clone(),y.clone()]))}Jt&&(v(se,L),zt.push([se,y.clone()]))}Tt.push(zt)}st.push(Tt);let It=2*g,Ut=2;for(let Bt=0;Bt<u;Bt++){let zt=It*Bt,kt=It*((Bt+1)%u),qt=0,$t=[z[zt]];for(let Pt=1;Pt<g;Pt++){let oe=z[zt+Pt],Gt=z[kt+Pt];$t.push(oe);for(let Zt=1,Jt=Pt-Ut+1;Zt<=Jt;Zt++)d.lerpVectors(oe,Gt,Zt/(Jt+1)),d.sub(L).setLength(St[Bt]).add(L),$t.push(k[qt++].copy(d));$t.push(Gt)}for(let Pt=0;Pt<g;Pt++)$t.push(z[Pt+g+zt]);$t.push(z[kt+g]);for(let Pt=0,oe=$t.length;Pt<oe;Pt++){let Gt=$t[Pt],Zt=3*Pt,Jt=2*Pt;O[Zt]=Gt.x,O[Zt+1]=Gt.y,O[Zt+2]=Gt.z,v(Gt,L),B[Zt]=y.x,B[Zt+1]=y.y,B[Zt+2]=y.z,V[Jt]=Math.atan2(Gt.z,-Gt.x)/2/Math.PI+.5,V[Jt+1]=1-(Math.atan2(-Gt.y,Math.sqrt(Gt.x*Gt.x+Gt.z*Gt.z))/Math.PI+.5)}for(let Pt=0,oe=w.length;Pt<oe;Pt++){let Gt=3*w[Pt],Zt=2*w[Pt],Jt=h/3*2;a[h]=O[Gt],a[h+1]=O[Gt+1],a[h+2]=O[Gt+2],o[h]=B[Gt],o[h+1]=B[Gt+1],o[h+2]=B[Gt+2],l[Jt]=V[Zt],l[Jt+1]=V[Zt+1],h+=3}}}let pt=[];for(let Q=0;Q<x.length;Q++)for(let ut=0;ut<u;ut++){let wt=x[Q][ut];if(wt<S){let St=x[wt].findIndex(It=>It%S==Q),Tt=st[Q][ut],vt=st[wt][St];for(let It=0;It<g;It++){let Ut=Tt[It],Bt=vt[g-It],zt=Tt[It+1],kt=vt[g-(It+1)];R(Ut),R(Bt),R(zt),R(zt),R(Bt),R(kt)}pt.push(Tt[0][0],vt[g][0],Tt[g][0],vt[0][0])}}for(;pt.length;){let Q,ut,wt,[St,Tt]=pt.splice(0,2);Q=Tt;let vt=[St];for(;St!=Q;)vt.push(Q),ut=pt.indexOf(Q),wt=ut%2,Q=pt.splice(ut-wt,2)[1-wt];y.subVectors(vt[0],vt[1]).cross(d.subVectors(vt[0],vt[2])).normalize();let It=y.dot(vt[0])<0;It&&y.negate();for(let Ut=1;Ut<=vt.length-2;Ut++)A(vt[Ut+ +It]),A(vt[Ut+1-+It]),A(vt[0])}}(),function(){let u=new P,d=new P,c=new P,p=new P,m=new Z,f=new Z,g=new Z,y=(_,x,S,w)=>{w<0&&_.x===1&&(l[x]=_.x-1),S.x===0&&S.z===0&&(l[x]=w/2/Math.PI+.5)};for(let _=0,x=0;_<h;_+=9,x+=6){u.set(a[_+0],a[_+1],a[_+2]),d.set(a[_+3],a[_+4],a[_+5]),c.set(a[_+6],a[_+7],a[_+8]),m.set(l[x+0],l[x+1]),f.set(l[x+2],l[x+3]),g.set(l[x+4],l[x+5]),p.copy(u).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,u,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=h/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),C=Math.min(x,S,w);T>.9&&C<.1&&(x<.2&&(l[_+0]+=1),S<.2&&(l[_+2]+=1),w<.2&&(l[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}}(),this.setAttribute("position",new _e(new Float32Array(a.subarray(0,h)),3)),this.setAttribute("normal",new _e(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new _e(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(t){return new X4(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),NK=j(()=>{m0t(),ht(),p0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new oN(.5*e,n,a):new Q8(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},oN=class extends X4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],n,t,e,i),this.type=n}static fromJSON(t){return new oN(t.radius,t.corner,t.cornerSides)}}});function BK(t,e=new Z){let i=t.length();return e.set(-t.y/i,t.x/i)}function oCt(t){let e=new Z;e.addVectors(t.v0,kg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(t.v2,$S.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Ql(t.v0,e,i,t.v2)}function h2(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function lCt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function hCt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function f0t(t,e,i){let r=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function uCt(t,e,i){return VK(t,e)&&VK(e,i)&&yj(t.position,e.position,i.position)}function yj(t,e,i){return kg.copy(e).sub(t).cross($S.copy(i).sub(t))===0}function dCt(t,e,i,r,s){let n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=(t.y+e.y)/2,o=(t.x+e.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.y-e.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function cCt(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function pCt(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,h=i.x-t.x,u=i.y-t.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return f0t(e,t,i)>Math.PI&&(d*=-1),a=h2(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*u,i.y-a*h),[s,n]}function kK(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function VK(t,e){return yj(t.position,t.controls[1].position,e.position)&&yj(t.position,e.controls[0].position,e.position)}function zK(t,e=12,i=!1){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Bg(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Bg(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Bg(t[0].roundedCurveCorner,e)),r}function Bg(t,e=12){return t&&t instanceof Kw?2*e:t&&(t instanceof ml||t instanceof J8)?1:t&&t instanceof jP?e*t.points.length:e}var D1,$M,XM,Xg,rR,kg,$S,g0t,y0t,v0t,b0t,vj,bj,YM,LK,FK,UK,jK,GK,ms,_0t=j(()=>{ht(),D1=1e-12,$M=class{constructor(t){this.position=new Z,this.startPosition=new Z,this.uuid=Ft.generateUUID(),this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new $M(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},XM=class extends $M{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new XM(this.parent).copy(this)}},Xg=class extends $M{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new XM(this),new XM(this))}static create(t,e){let i=new Xg(t,new Z(...e.position));return i.controls[0].position.set(...e.controlPrevious.position),i.controls[1].position.set(...e.controlNext.position),i.roundness=e.roundness,i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored,i}getOppositeControl(t){let e=this.controls.indexOf(t);return e===0?this.controls[1]:e===1?this.controls[0]:null}applyOffsetToControls(t,e=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=e?s.position.copy(this.position):s.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new Xg(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),e=this.curveAfter?.getTangentAt(0);return[t,e]}computeNormals(t=new Z,e=new Z){let[i,r]=this.computeTangents();return i&&r&&(BK(i,t),BK(r,e)),[t,e]}computeTangent(t=new Z){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Z){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},rR=t=>t,kg=new Z,$S=new Z,g0t=new Z,y0t=new Z,v0t=new Z,b0t=new Z,vj=new P,bj=new P}),Em=j(()=>{ht(),_0t(),YM=new Z,LK=new Z,FK=new Z,UK=new Z,jK=new Z,GK=new Z,ms=class extends OS{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Pa(new P(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Ft.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ms;return r.isClosed=t.isClosed,r.points=t.points.map(s=>Xg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ms.createFromState(s)),e!==void 0&&i!==void 0&&r.applySize(e,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let e=0,i=this.points.length;e<i;e++)this.points[e].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(e=>this.getPointIndexById(e)).filter(e=>e>=0)}getPointIndexById(t){let e=this.points.length,i=this.points.findIndex(r=>r.uuid===t);if(i<0){let r=e;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let e=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=t-e;if(n<=s.points.length-1)return s.points[n];e+=s.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let e=this.points.indexOf(t);if(e>=0)return e;if(e=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(t);if(n>=0)return e+n;e+=s.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(e=>e.points));return[...this.points,...t]}applySize(t,e){t===0&&(t=.001),e===0&&(e=.001),this._width=t,this._height=e}applyScale(t,e){let i=YM.set(t,e);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(t,e);this._update()}createPoint(t,e=0,i=Ft.generateUUID()){let r;r=t instanceof Z?t:new Z(t,e);let s=new Xg(i,r);return s.roundness=this.roundness,s}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,e){this.points.splice(e,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(r.uuid===t)return r}for(let e=0,i=this.shapeHoles.length;e<i;e++){let r=this.shapeHoles[e].getPointByUuid(t);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let e=this.points.indexOf(t);e>=0&&this.points.splice(e,1),this.needsUpdate=!0}removePointById(t){let e=this.points.find(i=>i.uuid===t);e&&this.removePoint(e)}update(){for(let t=0,e=this.shapeHoles.length;t<e;t++)this.shapeHoles[t].update();this._update()}extractShapePointsToBuffer(t,e=12,i=!1){this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(s,n,a=12,o=!0){let l,h=bj.set(0,0,0),u=0,d=[];for(let c=0;c<n.length;c++){let p=rR(n[c]),m=kg,f=Bg(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Ql||p instanceof uc||p instanceof ml){if(p.getPoint(g/f,m),h.set(m.x,m.y,0),l!==void 0&&hCt(l,h))continue;l===void 0&&(l=vj),l.copy(h),s.setXYZ(u,h.x,h.y,h.z),u++}}o&&u>1&&(s.getX(u-1)!==s.getX(0)||s.getY(u-1)!==s.getY(0)||s.getZ(u-1)!==s.getZ(0))&&(s.setXYZ(u,s.getX(0),s.getY(0),s.getZ(0)),u++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=zK(this.points,t,!1),this.roundedCurveDivisions=zK(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=bj.set(0,0,0),h=0,u=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=rR(s[d]),m=kg,f=Bg(p,a);u.push(f);for(let g=0;g<=f;g++)if(p instanceof Ql||p instanceof uc||p instanceof ml){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=vj:(r.setXYZ(h,c.x,c.y,c.z),h++,r.setXYZ(h,l.x,l.y,l.z),h++),c.copy(l)}}return o&&h>1&&!(r.getX(h-1)===r.getX(0)&&r.getY(h-1)===r.getY(0)&&r.getZ(h-1)===r.getZ(0))&&(r.setXYZ(h,r.getX(0),r.getY(0),r.getZ(0)),h++),u}(t,this.curves,e,i,this.autoClose).reduce((r,s)=>r+s,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,r,s=12,n=!0){let a,o=0;for(let l=0;l<r.length;l++){let h=rR(r[l]),u=Bg(h,s),d=kg;for(let c=0;c<=u;c++)if(h instanceof Ql||h instanceof uc||h instanceof ml){if(h.getPoint(c/u,d),a!==void 0&&lCt(a,d,D1))continue;a===void 0&&(a=$S),a.copy(d),i.push(d.x,d.y),o++}}return h2(i[0],i[i.length-2],D1)&&h2(i[1],i[i.length-1],D1)&&(i.pop(),i.pop()),n&&o>1&&!(h2(i[o-1],i[1],D1)&&h2(i[o-2],i[0],D1))&&(i.push(i[0],i[1]),o++),i}(t,this.roundedCurves,e,this.autoClose)}getCurveIndexFromVertexId(t,e=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=e?this.roundedCurveDivisions:this.curveDivisions,s=0;e&&this.points[0].roundedCurveCorner!==void 0&&(s=.5*Bg(this.points[0].roundedCurveCorner,this.subdivision));let n=t-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let r=this.points[t],s=this.points[t>=this.points.length-1?0:t+1],n=this.curveDivisions,a=n[t];if(kK(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(YM.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=n[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){kK(e,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(e.controls[1].position.x,e.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,e.curveAfter=i;let r=i.clone();t.roundedCurveBefore=r,e.roundedCurveAfter=r,t.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(e===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[e-1];this._applyCurveForPoint(r,s)}}let t=this.getLastPoint();if(t?.curveAfter&&(t.curveAfter=void 0),this.isClosed){let e=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(e,i)}if(this.points.length>2){let e=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&uCt(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=h instanceof ml?h.v1.distanceTo(h.v2):h.getLength(),f=u instanceof ml?u.v1.distanceTo(u.v2):u.getLength(),g=Math.min(o,.499*m),y=Math.min(o,.499*f),v=Math.min(g,y),b=1-v/m,_=v/f,x=h.getPointAt(b,YM),S=u.getPointAt(_,LK);if(this._subSplitCurve(h,c,b,x,void 0),this._subSplitCurve(u,p,_,void 0,S),this.useCubicForRoundedCorners){let w=f0t(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[C,M]=dCt(x,S,T,FK,UK),A=cCt(C,M,s.position),[R,I]=pCt(A,x,S,T,jK,GK);d=new Ql(x.clone(),R.clone(),I.clone(),S.clone())}else d=new uc(x.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=d,this.roundedCurves.splice(i+e,0,d),e++}}}}_subSplitCurve(t,e,i,r,s){if(!(t instanceof ml)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(h,u,d,c,p=.5){let m=kg.subVectors(u,h).multiplyScalar(p).add(h),f=$S.subVectors(d,u).multiplyScalar(p).add(u),g=g0t.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=y0t.subVectors(f,m).multiplyScalar(p).add(m),b=v0t.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=b0t.subVectors(b,v).multiplyScalar(p).add(v);return[h.x,h.y,y.x,y.y,v.x,v.y,x.x,x.y,b.x,b.y,_.x,_.y,c.x,c.y]}(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return r!==void 0&&e.v2.copy(r),s!==void 0&&e.v1.copy(s),e}clone(){let t=new ms(this._width,this._height);return t.points=this.points.map(e=>e.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(e=>e.clone()),t}toJSON(){return{points:this.points.reduce((t,e)=>t.concat(e.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let e=t.points.length/7;for(let i=0;i<e;i++){let r=7*i,s=t.points[r+0],n=t.points[r+1],a=t.points[r+2],o=t.points[r+3],l=t.points[r+4],h=t.points[r+5],u=t.points[r+6],d=new Xg(Ft.generateUUID(),new Z(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,h),d.roundness=u,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ms;return r.fromJSON(i),r}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(r,s)=>{s instanceof Ql&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)};return this.points=(r=>{let s,n,a=[];for(s=0,n=r.length;s<n;s++)r[s]instanceof uc&&(r[s]=oCt(r[s]));for(s=0,n=r.length;s<n;s++){let h,u=r[s],d=s>0?r[s-1]:null;u instanceof Ql?(h=this.createPoint(u.v0),h.controls[1].position.copy(u.v1)):u instanceof ml&&(h=this.createPoint(u.v1)),h!==void 0&&(d!==null&&i(h,d),a.push(h))}let o=r[r.length-1],l=!1;return o instanceof Ql?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof ml&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof OS&&(this.shapeHoles=t.holes.map(r=>{let s=new ms;return s.fromShape(r),s})),this.update(),this}updatePoint(t,e){let i=this.getPointByUuid(t);i&&(e.position!==void 0&&i.position.fromArray(e.position),e.roundness!==void 0&&(i.roundness=e.roundness),e.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(t,e){let i=this.getPointByUuid(t)?.controls[0];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}updateNextControl(t,e){let i=this.getPointByUuid(t)?.controls[1];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}}});function lN({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function mCt(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(t),s=Math.sin(t),n=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function WK(t,e,i,r){let s=t*r-e*i<0?-1:1,n=Math.min(1,Math.max(-1,t*i+e*r));return s*Math.acos(n)}var sR,fCt=j(()=>{sR=2*Math.PI});function Xe(t,e){if(!t)throw e||"Assertion Failed!"}function lS(t){var e=t.windingRule,i=e===void 0?as.ODD:e,r=t.elementType,s=r===void 0?Ca.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,h=t.normal,u=h===void 0?[0,0,1]:h,d=t.contours,c=d===void 0?[]:d,p=t.strict,m=p===void 0||p,f=t.debug,g=f!==void 0&&f;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new x0t;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,a,l,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var as,Ca,je,H0,m_,uf,hN,uN,dN,qK,KM,cN,HK,$K,x0t,mT=j(()=>{var t;(t=as||(as={}))[t.ODD=0]="ODD",t[t.NONZERO=1]="NONZERO",t[t.POSITIVE=2]="POSITIVE",t[t.NEGATIVE=3]="NEGATIVE",t[t.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(Ca||(Ca={})),je=function(){function e(){}return e.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},e.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},e.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},e.edgeGoesLeft=function(i){return e.vertLeq(i.Dst,i.Org)},e.edgeGoesRight=function(i){return e.vertLeq(i.Org,i.Dst)},e.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},e.edgeEval=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?n<a?r.t-i.t+(i.t-s.t)*(n/(n+a)):r.t-s.t+(s.t-i.t)*(a/(n+a)):0},e.edgeSign=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?(r.t-s.t)*n+(r.t-i.t)*a:0},e.transEval=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?n<a?r.s-i.s+(i.s-s.s)*(n/(n+a)):r.s-s.s+(s.s-i.s)*(a/(n+a)):0},e.transSign=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?(r.s-s.s)*n+(r.s-i.s)*a:0},e.vertCCW=function(i,r,s){return i.s*(r.t-s.t)+r.s*(s.t-i.t)+s.s*(i.t-r.t)>=0},e.interpolate=function(i,r,s,n){return(i=i<0?0:i)<=(s=s<0?0:s)?s===0?(r+n)/2:r+i/(i+s)*(n-r):n+s/(i+s)*(r-n)},e.intersect=function(i,r,s,n,a){var o,l,h;e.vertLeq(i,r)||(h=i,i=r,r=h),e.vertLeq(s,n)||(h=s,s=n,n=h),e.vertLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),e.vertLeq(s,r)?e.vertLeq(r,n)?((o=e.edgeEval(i,s,r))+(l=e.edgeEval(s,r,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,r.s)):((o=e.edgeSign(i,s,r))+(l=-e.edgeSign(i,n,r))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,n.s)):a.s=(s.s+r.s)/2,e.transLeq(i,r)||(h=i,i=r,r=h),e.transLeq(s,n)||(h=s,s=n,n=h),e.transLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),e.transLeq(s,r)?e.transLeq(r,n)?((o=e.transEval(i,s,r))+(l=e.transEval(s,r,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,r.t)):((o=e.transSign(i,s,r))+(l=-e.transSign(i,n,r))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,n.t)):a.t=(s.t+r.t)/2},e}(),H0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},m_=function(){function e(i){this.side=i,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),e}(),uf=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},hN=function(){function e(){var i=new uf,r=new H0,s=new m_(0),n=new m_(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,s.next=s,s.Sym=n,n.next=n,n.Sym=s,this.vHead=i,this.fHead=r,this.eHead=s,this.eHeadSym=n}return e.prototype.makeEdge_=function(i){var r=new m_(0),s=new m_(1);i.Sym.side<i.side&&(i=i.Sym);var n=i.Sym.next;return s.next=n,n.Sym.next=r,r.next=i,i.Sym.next=s,r.Sym=s,r.Onext=r,r.Lnext=s,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,s.Sym=r,s.Onext=s,s.Lnext=r,s.Org=null,s.Lface=null,s.winding=0,s.activeRegion=null,r},e.prototype.splice_=function(i,r){var s=i.Onext,n=r.Onext;s.Sym.Lnext=r,n.Sym.Lnext=i,i.Onext=n,r.Onext=s},e.prototype.makeVertex_=function(i,r,s){var n=i;Xe(n,"Vertex can't be null!");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r;var o=r;do o.Org=n,o=o.Onext;while(o!==r)},e.prototype.makeFace_=function(i,r,s){var n=i;Xe(n,"Face can't be null");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r,n.trail=null,n.marked=!1,n.inside=s.inside;var o=r;do o.Lface=n,o=o.Lnext;while(o!==r)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,s=i.Sym.next;r.Sym.next=s,s.Sym.next=r},e.prototype.killVertex_=function(i,r){var s=i.anEdge,n=s;do n.Org=r,n=n.Onext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,r){var s=i.anEdge,n=s;do n.Lface=r,n=n.Lnext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new uf,r=new uf,s=new H0,n=this.makeEdge_(this.eHead);return this.makeVertex_(i,n,this.vHead),this.makeVertex_(r,n.Sym,this.vHead),this.makeFace_(s,n,this.fHead),n},e.prototype.splice=function(i,r){var s=!1,n=!1;if(i!==r){if(r.Org!==i.Org&&(n=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!n){var a=new uf;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new H0;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var r=i.Sym,s=!1;if(i.Lface!==i.Rface&&(s=!0,this.killFace_(i.Lface,i.Rface)),i.Onext===i)this.killVertex_(i.Org,null);else if(i.Rface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev),!s){var n=new H0;this.makeFace_(n,i,i.Lface)}r.Onext===r?(this.killVertex_(r.Org,null),this.killFace_(r.Lface,null)):(i.Lface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),s=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var n=new uf;return this.makeVertex_(n,s,r.Org),r.Lface=s.Lface=i.Lface,r},e.prototype.splitEdge=function(i){var r=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,r),i.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=i.Rface,r.winding=i.winding,r.Sym.winding=i.Sym.winding,r.idx=i.idx,r.Sym.idx=i.Sym.idx,r},e.prototype.connect=function(i,r){var s=!1,n=this.makeEdge_(i),a=n.Sym;if(r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(n,i.Lnext),this.splice_(a,r),n.Org=i.Dst,a.Org=r.Org,n.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!s){var o=new H0;this.makeFace_(o,n,i.Lface)}return n},e.prototype.zapFace=function(i){var r,s,n,a,o,l=i.anEdge;s=l.Lnext;do s=(r=s).Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),(n=r.Sym).Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var r=i.anEdge,s=0;do s++,r=r.Lnext;while(r!==i.anEdge);return s},e.prototype.mergeConvexFaces=function(i){var r,s,n,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(s=r.anEdge).Org;n=s.Lnext,(a=s.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&je.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&je.vertCCW(a.Lprev.Org,a.Org,s.Lnext.Lnext.Org)&&(n=a.Lnext,this.delete(a),s=null,a=null),!s||s.Lnext.Org!==o;)s=n;return!0},e.prototype.check=function(){var i,r,s,n,a,o,l=this.fHead,h=this.vHead,u=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Xe(i.prev===r),a=i.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Xe(i.prev===r&&i.anEdge===null),n=h,n=h;(s=n.next)!==h;n=s){Xe(s.prev===n),a=s.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(Xe(s.prev===n&&s.anEdge===null),o=u,o=u;(a=o.next)!==u;o=a)Xe(a.Sym.next===o.Sym),Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Org!==null),Xe(a.Dst!==null),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a);Xe(a.Sym.next===o.Sym&&a.Sym===this.eHeadSym&&a.Sym.Sym===a&&a.Org===null&&a.Dst===null&&a.Lface===null&&a.Rface===null)},e}(),uN=function(){this.handle=null},dN=function(){this.key=null,this.node=0},qK=function(){function e(i,r){this.leq=r,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=i,this.nodes=[],this.handles=[];for(var s=0;s<i+1;s++)this.nodes[s]=new uN,this.handles[s]=new dN;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((n=i<<1)<this.size&&this.leq(o[a[n+1].handle].key,o[a[n].handle].key)&&++n,Xe(n<=this.max),s=a[n].handle,n>this.size||this.leq(o[r].key,o[s].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.floatUp_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(s=a[n=i>>1].handle,n===0||this.leq(o[s].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(i){var r,s;if(2*(r=++this.size)>this.max){var n,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,n=a;n<this.nodes.length;n++)this.nodes[n]=new uN;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new dN}return this.freeList===0?s=r:(s=this.freeList,this.freeList=this.handles[s].node),this.nodes[r].handle=s,this.handles[s].node=r,this.handles[s].key=i,this.initialized&&this.floatUp_(r),s},e.prototype.extractMin=function(){var i=this.nodes,r=this.handles,s=i[1].handle,n=r[s].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[s].key=null,r[s].node=this.freeList,this.freeList=s,--this.size,this.size>0&&this.floatDown_(1)),n},e.prototype.delete=function(i){var r,s=this.nodes,n=this.handles;Xe(i>=1&&i<=this.max&&n[i].key!==null),s[r=n[i].node].handle=s[this.size].handle,n[s[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[s[r>>1].handle].key,n[s[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[i].key=null,n[i].node=this.freeList,this.freeList=i},e}(),KM=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},cN=function(){this.key=null,this.next=null,this.prev=null},HK=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new cN,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(i){return this.insertBefore(this.head,i)},e.prototype.search=function(i){var r=this.head;do r=r.next;while(r.key!==null&&!this.leq(this.frame,i,r.key));return r},e.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var s=new cN;return s.key=r,s.next=i.next,i.next.prev=s,s.prev=i,i.next=s,s},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),$K=function(){function e(){}return e.regionBelow=function(i){return i.nodeUp.prev.key},e.regionAbove=function(i){return i.nodeUp.next.key},e.debugEvent=function(i){},e.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.edgeLeq=function(i,r,s){var n=i.event,a=r.eUp,o=s.eUp;return a.Dst===n?o.Dst===n?je.vertLeq(a.Org,o.Org)?je.edgeSign(o.Dst,a.Org,o.Org)<=0:je.edgeSign(a.Dst,o.Org,a.Org)>=0:je.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?je.edgeSign(a.Dst,n,a.Org)>=0:je.edgeEval(a.Dst,n,a.Org)>=je.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&Xe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){Xe(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=s,s.activeRegion=r},e.topLeftRegion=function(i,r){var s,n=r.eUp.Org;do r=e.regionAbove(r);while(r.eUp.Org===n);if(r.fixUpperEdge){if((s=i.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;e.fixUpperEdge(i,r,s),r=e.regionAbove(r)}return r},e.topRightRegion=function(i){var r=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===r);return i},e.addRegionBelow=function(i,r,s){var n=new KM;return n.eUp=s,n.nodeUp=i.dict.insertBefore(r.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,s.activeRegion=n,n},e.isWindingInside=function(i,r){switch(i.windingRule){case as.ODD:return!!(1&r);case as.NONZERO:return r!==0;case as.POSITIVE:return r>0;case as.NEGATIVE:return r<0;case as.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(i,r.windingNumber)},e.finishRegion=function(i,r){var s=r.eUp,n=s.Lface;n.inside=r.inside,n.anEdge=s,e.deleteRegion(i,r)},e.finishLeftRegions=function(i,r,s){for(var n,a=null,o=r,l=r.eUp;o!==s;){if(o.fixUpperEdge=!1,(n=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}n=i.mesh.connect(l.Lprev,n.Sym),e.fixUpperEdge(i,a,n)}l.Onext!==n&&(i.mesh.splice(n.Oprev,n),i.mesh.splice(l,n)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,r,s,n,a,o){var l,h,u,d,c=!0;u=s;do Xe(je.vertLeq(u.Org,u.Dst)),e.addRegionBelow(i,r,u.Sym),u=u.Onext;while(u!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),h=r,d=a;(u=(l=e.regionBelow(h)).eUp.Sym).Org===d.Org;)u.Onext!==d&&(i.mesh.splice(u.Oprev,u),i.mesh.splice(d.Oprev,u)),l.windingNumber=h.windingNumber-u.winding,l.inside=e.isWindingInside(i,l.windingNumber),h.dirty=!0,!c&&e.checkForRightSplice(i,h)&&(e.addWinding(u,d),e.deleteRegion(i,h),i.mesh.delete(d)),c=!1,h=l,d=u;h.dirty=!0,Xe(h.windingNumber-u.winding===l.windingNumber),o&&e.walkDirtyRegions(i,h)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=je.vertL1dist(r,i),a=je.vertL1dist(s,i),o=.5*a/(n+a),l=.5*n/(n+a);i.coords[0]+=o*r.coords[0]+l*s.coords[0],i.coords[1]+=o*r.coords[1]+l*s.coords[1],i.coords[2]+=o*r.coords[2]+l*s.coords[2]},e.getIntersectData=function(i,r,s,n,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,s,n),e.vertexWeights(r,a,o)},e.checkForRightSplice=function(i,r){var s=e.regionBelow(r),n=r.eUp,a=s.eUp;if(je.vertLeq(n.Org,a.Org)){if(je.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;je.vertEq(n.Org,a.Org)?n.Org!==a.Org&&(i.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,n)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(n,a.Oprev),r.dirty=s.dirty=!0)}else{if(je.edgeSign(n.Dst,a.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(n.Sym),i.mesh.splice(a.Oprev,n)}return!0},e.checkForLeftSplice=function(i,r){var s,n=e.regionBelow(r),a=r.eUp,o=n.eUp;if(Xe(!je.vertEq(a.Dst,o.Dst)),je.vertLeq(a.Dst,o.Dst)){if(je.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,s=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,s),s.Lface.inside=r.inside}else{if(je.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,s=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),s.Rface.inside=r.inside}return!0},e.checkForIntersect=function(i,r){var s,n,a=e.regionBelow(r),o=r.eUp,l=a.eUp,h=o.Org,u=l.Org,d=o.Dst,c=l.Dst,p=new uf;if(Xe(!je.vertEq(c,d)),Xe(je.edgeSign(d,i.event,h)<=0),Xe(je.edgeSign(c,i.event,u)>=0),Xe(h!==i.event&&u!==i.event),Xe(!r.fixUpperEdge&&!a.fixUpperEdge),h===u||Math.min(h.t,d.t)>Math.max(u.t,c.t))return!1;if(je.vertLeq(h,u)){if(je.edgeSign(c,h,u)>0)return!1}else if(je.edgeSign(d,u,h)<0)return!1;return e.debugEvent(i),je.intersect(d,h,c,u,p),Xe(Math.min(h.t,d.t)<=p.t),Xe(p.t<=Math.max(u.t,c.t)),Xe(Math.min(c.s,d.s)<=p.s),Xe(p.s<=Math.max(u.s,h.s)),je.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=je.vertLeq(h,u)?h:u,je.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),je.vertEq(p,h)||je.vertEq(p,u)?(e.checkForRightSplice(i,r),!1):!je.vertEq(d,i.event)&&je.edgeSign(d,i.event,p)>=0||!je.vertEq(c,i.event)&&je.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=e.topLeftRegion(i,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),a),e.addRightEdges(i,r,o.Oprev,o,o,!0),!0):d===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,r,l.Onext,o.Rprev,n,!0),!0):(je.edgeSign(d,i.event,p)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),je.edgeSign(c,i.event,p)<=0&&(r.dirty=a.dirty=!0,i.mesh.splitEdge(l.Sym),l.Org.s=i.event.s,l.Org.t=i.event.t),!1):(i.mesh.splitEdge(o.Sym),i.mesh.splitEdge(l.Sym),i.mesh.splice(l.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=i.pq.insert(o.Org),e.getIntersectData(i,o.Org,h,d,u,c),e.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,r){for(var s,n,a=e.regionBelow(r);;){for(;a.dirty;)r=a,a=e.regionBelow(a);if(!r.dirty&&(a=r,(r=e.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,s=r.eUp,n=a.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(n),n=(a=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(i,r),i.mesh.delete(s),s=(r=e.regionAbove(a)).eUp)),s.Org!==n.Org){if(s.Dst===n.Dst||r.fixUpperEdge||a.fixUpperEdge||s.Dst!==i.event&&n.Dst!==i.event)e.checkForRightSplice(i,r);else if(e.checkForIntersect(i,r))return}s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(i,r),i.mesh.delete(s),r=e.regionAbove(a))}},e.connectRightVertex=function(i,r,s){var n,a=s.Onext,o=e.regionBelow(r),l=r.eUp,h=o.eUp,u=!1;l.Dst!==h.Dst&&e.checkForIntersect(i,r),je.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=e.topLeftRegion(i,r),a=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),o),u=!0),je.vertEq(h.Org,i.event)&&(i.mesh.splice(s,h.Oprev),s=e.finishLeftRegions(i,o,null),u=!0),u?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=je.vertLeq(h.Org,l.Org)?h.Oprev:l,n=i.mesh.connect(s.Lprev,n),e.addRightEdges(i,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,r))},e.connectLeftDegenerate=function(i,r,s){var n,a,o,l,h;return n=r.eUp,je.vertEq(n.Org,s)?(Xe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):je.vertEq(n.Dst,s)?(Xe(!1),r=e.topRightRegion(r),a=l=(o=(h=e.regionBelow(r)).eUp.Sym).Onext,h.fixUpperEdge&&(Xe(a!==o),e.deleteRegion(i,h),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),je.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(i.mesh.delete(n.Onext),r.fixUpperEdge=!1),i.mesh.splice(s.anEdge,n),void e.sweepEvent(i,s))},e.connectLeftVertex=function(i,r){var s,n,a,o,l,h,u=new KM;if(u.eUp=r.anEdge.Sym,s=i.dict.search(u).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,je.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=je.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(h=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,h):e.computeWinding(i,e.addRegionBelow(i,s,h)),e.sweepEvent(i,r)):e.addRightEdges(i,s,r.anEdge,r.anEdge,null,!0)}},e.sweepEvent=function(i,r){i.event=r,e.debugEvent(i);for(var s=r.anEdge;s.activeRegion===null;)if((s=s.Onext)===r.anEdge)return void e.connectLeftVertex(i,r);var n=e.topLeftRegion(i,s.activeRegion);Xe(n!==null);var a=e.regionBelow(n),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,n,l):e.addRightEdges(i,n,l.Onext,o,o,!0)},e.addSentinel=function(i,r,s,n){var a=new KM,o=i.mesh.makeEdge();o.Org.s=s,o.Org.t=n,o.Dst.s=r,o.Dst.t=n,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},e.initEdgeDict=function(i){i.dict=new HK(i,e.edgeLeq);var r=i.bmax[0]-i.bmin[0],s=i.bmax[1]-i.bmin[1],n=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-s,l=i.bmax[1]+s;e.addSentinel(i,n,a,o),e.addSentinel(i,n,a,l)},e.doneEdgeDict=function(i){for(var r,s=0;(r=i.dict.min().key)!==null;)r.sentinel||(Xe(r.fixUpperEdge),Xe(++s===1)),Xe(r.windingNumber===0),e.deleteRegion(i,r)},e.removeDegenerateEdges=function(i){var r,s,n,a=i.mesh.eHead;for(r=a.next;r!==a;r=s)s=r.next,n=r.Lnext,je.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(i,n,r),i.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&((n===s||n===s.Sym)&&(s=s.next),i.mesh.delete(n)),(r===s||r===s.Sym)&&(s=s.next),i.mesh.delete(r))},e.initPriorityQ=function(i){var r,s,n,a=0;for(s=(n=i.mesh.vHead).next;s!==n;s=s.next)a++;for(a+=8,r=i.pq=new qK(a,je.vertLeq),s=(n=i.mesh.vHead).next;s!==n;s=s.next)s.pqHandle=r.insert(s);return s===n&&(r.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,r){var s,n,a;for(s=r.fHead.next;s!==r.fHead;s=n)n=s.next,Xe((a=s.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,r){var s,n;if(r===void 0&&(r=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(s=i.pq.extractMin())!==null;){for(;(n=i.pq.min())!==null&&je.vertEq(n,s);)n=i.pq.extractMin(),e.spliceMergeVertices(i,s.anEdge,n.anEdge);e.sweepEvent(i,s)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},e}(),x0t=function(){function e(){this.mesh=new hN,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=as.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},e.prototype.normalize_=function(i){var r=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!r)throw"Zero-size vector!";r=Math.sqrt(r),i[0]/=r,i[1]/=r,i[2]/=r},e.prototype.longAxis_=function(i){var r=0;return Math.abs(i[1])>Math.abs(i[0])&&(r=1),Math.abs(i[2])>Math.abs(i[r])&&(r=2),r},e.prototype.computeNormal_=function(i){var r,s,n,a,o,l,h=[0,0,0],u=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],g=this.mesh.vHead;r=g.next;for(var y=0;y<3;++y)a=r.coords[y],u[y]=a,f[y]=r,h[y]=a,m[y]=r;for(r=g.next;r!==g;r=r.next)for(var v=0;v<3;++v)(a=r.coords[v])<u[v]&&(u[v]=a,f[v]=r),a>h[v]&&(h[v]=a,m[v]=r);var b=0;if(h[1]-u[1]>h[0]-u[0]&&(b=1),h[2]-u[2]>h[b]-u[b]&&(b=2),u[b]>=h[b])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,s=f[b],n=m[b],d[0]=s.coords[0]-n.coords[0],d[1]=s.coords[1]-n.coords[1],d[2]=s.coords[2]-n.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],p[0]=d[1]*c[2]-d[2]*c[1],p[1]=d[2]*c[0]-d[0]*c[2],p[2]=d[0]*c[1]-d[1]*c[0],(o=p[0]*p[0]+p[1]*p[1]+p[2]*p[2])>l&&(l=o,i[0]=p[0],i[1]=p[1],i[2]=p[2]);l<=0&&(i[0]=i[1]=i[2]=0,i[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var i,r,s=this.mesh.fHead,n=this.mesh.vHead,a=0,o=s.next;o!==s;o=o.next)if(!((r=o.anEdge).winding<=0))do a+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(a<0){for(i=n.next;i!==n;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var i,r,s=this.mesh.vHead,n=[0,0,0],a=!1;n[0]=this.normal[0],n[1]=this.normal[1],n[2]=this.normal[2],!n[0]&&!n[1]&&!n[2]&&(this.computeNormal_(n),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(n);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=n[o]>0?1:-1;for(var l=s.next;l!==s;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,r);a&&this.checkOrientation_();for(var h=!0,u=s.next;u!==s;u=u.next)h?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,h=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},e.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,r){var s,n;if((s=r.anEdge).Lnext===s||s.Lnext.Lnext===s)throw"Mono region invalid";for(;je.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;je.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(je.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(je.edgeGoesLeft(n.Lnext)||je.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(je.edgeGoesRight(s.Lprev)||je.edgeSign(s.Dst,s.Org,s.Lprev.Org)>=0);)s=i.connect(s,s.Lprev).Sym;s=s.Lnext}if(n.Lnext===s)throw"Mono region invalid";for(;n.Lnext.Lnext!==s;)n=i.connect(n.Lnext,n).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)if(r=s.next,s.inside&&!this.tessellateMonoRegion_(i,s))return!1;return!0},e.prototype.discardExterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)r=s.next,s.inside||i.zapFace(s)},e.prototype.setWindingNumber_=function(i,r,s){for(var n,a=i.eHead.next;a!==i.eHead;a=n)n=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:s?i.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},e.prototype.outputPolymesh_=function(i,r,s,n){var a,o,l=0,h=0;s>3&&i.mergeConvexFaces(s);for(var u=i.vHead.next;u!==i.vHead;u=u.next)u.n=-1;for(var d=i.fHead.next;d!==i.fHead;d=d.next)if(d.n=-1,d.inside){a=d.anEdge,o=0;do(u=a.Org).n===-1&&(u.n=h,h++),o++,a=a.Lnext;while(a!==d.anEdge);if(o>s)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===Ca.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=h,this.vertices=[],this.vertices.length=h*n,this.vertexIndices=[],this.vertexIndices.length=h,u=i.vHead.next;u!==i.vHead;u=u.next)if(u.n!==-1){var c=u.n*n;this.vertices[c+0]=u.coords[0],this.vertices[c+1]=u.coords[1],n>2&&(this.vertices[c+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do u=a.Org,this.elements[p++]=u.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ca.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=o;f<s;++f)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,r){var s,n,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){n=s=l.anEdge;do this.vertexCount++,s=s.Lnext;while(s!==n);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*r,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var h=0,u=0,d=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,n=s=l.anEdge;do this.vertices[h++]=s.Org.coords[0],this.vertices[h++]=s.Org.coords[1],r>2&&(this.vertices[h++]=s.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(s):s.Org.idx,o++,s=s.Lnext;while(s!==n);this.elements[d++]=a,this.elements[d++]=o,a+=o}},e.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new hN),i<2&&(i=2),i>3&&(i=3);for(var s=null,n=0;n<r.length;n+=i)s===null?(s=this.mesh.makeEdge(),this.mesh.splice(s,s.Sym)):(this.mesh.splitEdge(s),s=s.Lnext),s.Org.coords[0]=r[n+0],s.Org.coords[1]=r[n+1],s.Org.coords[2]=i>2?r[n+2]:0,s.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(s),s.winding=1,s.Sym.winding=-1},e.prototype.tesselate=function(i,r,s,n,a,o){if(i===void 0&&(i=as.ODD),r===void 0&&(r=Ca.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),$K.computeInterior(this,o);var l=this.mesh;return r===Ca.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ca.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),as.ODD,as.NONZERO,as.POSITIVE,as.NEGATIVE,as.ABS_GEQ_TWO,Ca.POLYGONS,Ca.CONNECTED_POLYGONS,Ca.BOUNDARY_CONTOURS});function w0t(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let h=(l+1)%i;r+=t[2*l]*t[2*h+1]-t[2*h]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let h=(l+1)%i,u=t[2*h]-t[2*l],d=t[2*h+1]-t[2*l+1],c=Math.hypot(u,d);n.push(c>0?[s*d/c,-s*u/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,h)=>{if(l[0]*h[0]+l[1]*h[1]<=a)return l;let[u,d]=[l[0]+h[0],l[1]+h[1]],c=Math.hypot(u,d);return c>0?[u/c,d/c]:l};return n.map((l,h)=>[o(l,n[(h+i-1)%i]),o(l,n[(h+1)%i])])}function S0t(t,e,i){let r=t.length/2,s=new Float32Array(r+1);if(!(e>0)||!(i>0)||r<2)return{u:s,vScale:0};let n=0;for(let a=0;a<r;a++){let o=(a+1)%r;n+=Math.hypot((t[2*o]-t[2*a])/e,(t[2*o+1]-t[2*a+1])/i),s[a+1]=n}return{u:s,vScale:Math.sqrt(e*i)}}function T0t(t,e,i){for(let r=0;r<i.length;r+=3){let s=3*i[r],n=3*i[r+1],a=3*i[r+2],o=t[n]-t[s],l=t[n+1]-t[s+1],h=t[n+2]-t[s+2],u=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=h*u-o*c,m=o*d-l*u;if((l*c-h*d)*(e[s]+e[n]+e[a])+p*(e[s+1]+e[n+1]+e[a+1])+m*(e[s+2]+e[n+2]+e[a+2])<0){let f=i[r+1];i[r+1]=i[r+2],i[r+2]=f}}}var pW,M0t,mW,A0t=j(()=>{}),fW=j(()=>{pW={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},M0t={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},mW={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0}});function C0t(t,e){return t.normals[3*e+2]<.9999}function E0t(t){let e=_j.get(t);if(e!==void 0)return e;if(!(t.rise>0))return t;let i=new Float32Array(t.normals),r=t.positions.length/3;for(let n=0;n<r;n++){if(!C0t(t,n))continue;let a=i[3*n],o=i[3*n+1],l=Math.hypot(a,o);if(l===0)continue;let h=t.rise-t.positions[3*n+2],u=Math.min(1,Math.max(0,1-h/t.rise)),d=Math.sqrt(1-u*u);i[3*n]=a/l*d,i[3*n+1]=o/l*d,i[3*n+2]=u}let s={...t,normals:i};return _j.set(t,s),s}function P0t(t,e,i,r){let s=(e-t.minX)/t.spanX,n=(i-t.minY)/t.spanY;return r?[n,s]:[s,n]}var _j,K4,xj,gW=j(()=>{_j=new WeakMap}),gCt=j(()=>{ht(),mT(),ir(),A0t(),fW(),gW(),K4=class extends ye{constructor(t,e,i=12,r=as.ODD,s,n=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=t,this._depth=e,this._curveSegments=i,this._windingRule=r,this._uvPitch=n?void 0:s,this._legacy=n;let a,o=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(z=>z.extractShapePointsToFlatArray([],i))];try{a=lS({contours:o,windingRule:r,elementType:Ca.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=mW}let l=a?.vertexCount??0,h=a?.elementCount??0,u=1/0,d=1/0,c=-1/0,p=-1/0;for(let z of o)for(let k=0;k<z.length;k+=2)z[k]<u&&(u=z[k]),z[k]>c&&(c=z[k]),z[k+1]<d&&(d=z[k+1]),z[k+1]>p&&(p=z[k+1]);let m=this._uvPitch,f=m??(c-u||1),g=m??(p-d||1),y=m===void 0?u:0,v=m===void 0?d:0,b=o.map((z,k)=>w0t(z,k>0)),_=0;for(let z of b)_+=z.length;let x=2*l+4*_,S=3*h*2+6*_,w=new Float32Array(3*x),T=new Float32Array(3*x),C=new Float32Array(2*x),M=new Uint32Array(S),A=new Uint8Array(x),R=0,I=0,O=0,B=!1,V=(z,k,L,H,W,X,nt=(z-y)/f,st=(k-v)/g)=>{let yt=3*I;w[yt]=z,w[yt+1]=k,w[yt+2]=L,T[yt]=H,T[yt+1]=W,T[yt+2]=X,A[I]=L===e?B?2:1:0,C[2*I]=nt,C[2*I+1]=st,I++};if(a!==void 0)for(let[z,k]of[[e,1],[0,-1]]){let L=I;for(let H=0;H<l;H++)V(a.vertices[2*H],a.vertices[2*H+1],z,0,0,k);for(let H=0;H<h;H++){let[W,X,nt]=[a.elements[3*H],a.elements[3*H+1],a.elements[3*H+2]];M[O++]=L+W,M[O++]=L+(k>0?X:nt),M[O++]=L+(k>0?nt:X)}}B=!0;for(let z=0;z<o.length;z++){let k=o[z],L=b[z],H=k.length/2,{u:W,vScale:X}=n?{u:new Float32Array(H+1),vScale:0}:S0t(k,f,g);R=X;let nt=X===0?0:e/X,st={minX:y,minY:v,spanX:f,spanY:g},yt=(pt,[Q,ut],wt,St)=>{let Tt=k[2*pt],vt=k[2*pt+1],[It,Ut]=n?P0t(st,Tt,vt,wt):[St,wt?0:nt];V(Tt,vt,wt?0:e,Q,ut,0,It,Ut)};for(let pt=0;pt<L.length;pt++){let Q=(pt+1)%H,[ut,wt]=L[pt],[St,Tt]=[W[pt],W[pt+1]],vt=I;yt(pt,ut,!1,St),yt(pt,ut,!0,St),yt(Q,wt,!1,Tt),yt(Q,wt,!0,Tt),M[O++]=vt,M[O++]=vt+1,M[O++]=vt+2,M[O++]=vt+3,M[O++]=vt+2,M[O++]=vt+1}}T0t(w,T,M),this.setAttribute("position",new _e(w,3)),this.setAttribute("normal",new _e(T,3)),this.setAttribute("uv",new _e(C,2)),this.setIndex(new _e(M,1)),this._nearSide=A,this._vScale=R}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale)}canShiftDepthTo(t){return this._nearSide.length>0&&this._depth>0&&t>0}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=e,h===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=new K4(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return t.userData=K5(this.userData),t}}}),R0t=j(()=>{ht(),mT(),ir(),fW(),xj=class extends ye{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=as.ODD,this.elementType=Ca.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:as.ODD,elementType:Ca.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,n,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,h=!0;for(let c=0,p=a.length/2;c<p;c++){let m=2*c,f=a[m+0],g=a[m+1];if(s!==void 0&&f!==s&&(l=!1),n!==void 0&&g!==n&&(h=!1),s=f,n=g,!l&&!h)break}if(!l&&!h)try{r=lS({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=pW}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new _e(new Float32Array(3*u),3),this._normalAttribute=new _e(new Float32Array(3*u),3),this._uvAttribute=new _e(new Float32Array(2*u),2),this._indexAttribute=new _e(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=u;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1];x<c&&(c=x),x>p&&(p=x),S<m&&(m=S),S>f&&(f=S)}let g=p-c,y=f-m;for(let v=0,b=u;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1],w=(x-c)/g,T=(S-m)/y;this._positionAttribute.setXYZ(v,x,S,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,w,T)}for(let v=0,b=d;v<b;v++){let _=3*v,x=r.elements[_+0],S=r.elements[_+1],w=r.elements[_+2];this._indexAttribute.setX(_+0,x),this._indexAttribute.setX(_+1,S),this._indexAttribute.setX(_+2,w)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let t=new xj(this._shape,this._curveSegments);return t.userData=K5(this.userData),t}}});function yCt(t){return XK||(XK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.123/build",i=Promise.resolve().then(()=>(hH(),lH)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),fT=r}())}function vCt(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(N0t.has(s.type)&&s.depth!==void 0&&s.depth>0&&(s.extrudeBevelSize??0)>0&&(e=!0),s.type==="PathGeometry")){let n=s.extrusion;n!==void 0&&n.capType==="round"&&(n.bevel??0)>0&&(e=!0)}}),e}function D0t(t,e){let i=[t.extractShapePointsToFlatArray([],e)];for(let o of t.shapeHoles)i.push(o.extractShapePointsToFlatArray([],e));let r=0;for(let o of i)r+=o.length>>1;let s=new Float64Array(2*r),n=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)s.set(i[o],2*a),a+=i[o].length>>1,n[o]=a;return{points:s,ends:n}}function Z4(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=B0t.getNormalMatrix(s).elements;for(let u=0;u<a;u++){let d=3*u,c=3*(i+u),p=t.positions[d],m=t.positions[d+1],f=t.positions[d+2];e.positions[c]=o[0]*p+o[4]*m+o[8]*f+o[12],e.positions[c+1]=o[1]*p+o[5]*m+o[9]*f+o[13],e.positions[c+2]=o[2]*p+o[6]*m+o[10]*f+o[14];let g=t.normals[d],y=t.normals[d+1],v=t.normals[d+2];e.normals[c]=l[0]*g+l[3]*y+l[6]*v,e.normals[c+1]=l[1]*g+l[4]*y+l[7]*v,e.normals[c+2]=l[2]*g+l[5]*y+l[8]*v;let b=2*(i+u);if(n===void 0)e.uvs[b]=t.uvs[2*u],e.uvs[b+1]=t.uvs[2*u+1];else{let[_,x]=n(p,m,t.uvs[2*u],t.uvs[2*u+1],u);e.uvs[b]=_,e.uvs[b+1]=x}}let h=s.determinant()<0;for(let u=0;u<t.indices.length;u+=3)e.indices[r+u]=t.indices[u]+i,e.indices[r+u+1]=t.indices[u+(h?2:1)]+i,e.indices[r+u+2]=t.indices[u+(h?1:2)]+i}function O0t(t){let{owner:e,shape:i,curveSegments:r,assembledAt:s,bevel:n,bevelSegments:a}=t,o=function(c,p){let m=[p],f=g=>{m.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let y of g.points){m.push(y.roundness??0,y.position.x,y.position.y);for(let v of y.controls)m.push(v.position.x,v.position.y)}m.push(g.shapeHoles.length);for(let y of g.shapeHoles)f(y)};return f(c),function(g){let y=2166136261;for(let v=0;v<g.length;v++)y^=g[v],y=Math.imul(y,16777619)>>>0;return y}(new Uint8Array(new Float64Array(m).buffer))}(i,r),l=e??`outline:${o}`,h=`${n}/${a}`,u=Q4.get(l);if(u!==void 0&&u.outlineVersion===o&&u.capKey===h&&(t.stillServes?.(u)??1))return wj.placements++,u.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=D0t(c,p);return fT.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),I0t,40)}(i,r,s,n,a);wj.assemblies++;try{let c=function(p,m){return function(f,g,y,v,b){let _=1/0;for(let x=2;x<f.length;x+=3)f[x]<_&&(_=f[x]);if(_===1/0&&(_=0),_!==0)for(let x=2;x<f.length;x+=3)f[x]-=_;return{positions:f,normals:g,uvs:y,indices:v,rise:b-_}}(p.positions(),p.normals(),p.uvs(),p.indices(),m)}(d,s);return Q4.set(l,{outlineVersion:o,capKey:h,assembledAt:s,cap:c}),c}finally{d.free()}}function Q1(t,e){return .5*e>1.001*t}var fT,I0t,XK,N0t,B0t,YK,KK,ZK,Q4,wj,Sj,Pm,rb=j(()=>{ht(),ir(),A0t(),gW(),I0t=.4,N0t=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),B0t=new As,YK=new xt,KK=new xt,ZK=new xt().makeScale(1,1,-1),Q4=new Map,wj={assemblies:0,placements:0},Sj=class extends ye{constructor(t,e,i=0,r=12,s=3,n,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,fT===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._legacy=o,this._depth=e,this._bevel=i,this._curveSegments=r,this._bevelSegments=s,this._ownerId=n,this.rebuild()}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length>0&&Q1(this._effectiveBevel,t)&&Q1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=e,h===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}setDepth(t){t!==this._depth&&(this._depth=t,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let t=O0t({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>Q1(a.cap.rise,this._depth)&&Q1(a.cap.rise,a.assembledAt)}),e=function(a,o,l,h,u,d=!1){let c=h.positions.length/3,p=l-h.rise,m=h.rise,{points:f,ends:g}=D0t(a,o),y=1/0,v=1/0,b=-1/0,_=-1/0;for(let st=0;st<f.length;st+=2)f[st]<y&&(y=f[st]),f[st]>b&&(b=f[st]),f[st+1]<v&&(v=f[st+1]),f[st+1]>_&&(_=f[st+1]);d&&(u=void 0);let x=u??b-y,S=u??_-v,w={minX:y,minY:v,spanX:b-y||1,spanY:_-v||1},T=[],C=0;for(let st of g)T.push({at:C,count:st-C}),C=st;let M=0;for(let st of T)M+=st.count;let A=2*c+4*M,R=new Float32Array(3*A),I=new Float32Array(3*A),O=new Float32Array(2*A),B=new Uint32Array(2*h.indices.length+6*M),V=new Uint8Array(A),z=0,k=u===void 0?void 0:(st,yt)=>[st/u,yt/u],L=d?(st,yt,pt,Q,ut)=>C0t(h,ut)?[Q,pt]:[pt,Q]:k,H=d?E0t(h):h,W={positions:R,normals:I,uvs:O,indices:B};Z4(H,W,0,0,YK.makeTranslation(0,0,p),k),Z4(H,W,c,h.indices.length,KK.makeTranslation(0,0,m).multiply(ZK),L),V.fill(1,0,c);let X=2*c,nt=2*h.indices.length;for(let st=0;st<T.length;st++){let{at:yt,count:pt}=T[st],Q=f.subarray(2*yt,2*(yt+pt)),ut=w0t(Q,st>0),wt=d?{u:new Float32Array(pt+1),vScale:0}:S0t(Q,x,S),St=wt.u;z=wt.vScale;for(let Tt=0;Tt<pt;Tt++){let vt=(Tt+1)%pt,[It,Ut]=ut[Tt],Bt=X;for(let[zt,kt,qt,$t,Pt,oe]of[[Q[2*Tt],Q[2*Tt+1],It,p,St[Tt],2],[Q[2*vt],Q[2*vt+1],Ut,p,St[Tt+1],2],[Q[2*vt],Q[2*vt+1],Ut,m,St[Tt+1],0],[Q[2*Tt],Q[2*Tt+1],It,m,St[Tt],0]]){let Gt=3*X;if(R[Gt]=zt,R[Gt+1]=kt,R[Gt+2]=$t,I[Gt]=qt[0],I[Gt+1]=qt[1],I[Gt+2]=0,d){let[Zt,Jt]=P0t(w,zt,kt,oe===0);O[2*X]=Zt,O[2*X+1]=Jt}else O[2*X]=Pt,O[2*X+1]=z===0?0:($t-m)/z;V[X]=oe,X++}B[nt++]=Bt,B[nt++]=Bt+1,B[nt++]=Bt+2,B[nt++]=Bt,B[nt++]=Bt+2,B[nt++]=Bt+3}}return T0t(R,I,B),{positions:R,normals:I,uvs:O,indices:B,nearSide:V,vScale:z}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch,this._legacy);this._nearSide=e.nearSide,this._vScale=e.vScale,this._effectiveBevel=t.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),s=this.getAttribute("uv"),n=this.getIndex();if(i!==void 0&&r!==void 0&&s!==void 0&&n!==null&&i.array.length===e.positions.length&&r.array.length===e.normals.length&&s.array.length===e.uvs.length&&n.array.length===e.indices.length)return i.array.set(e.positions),r.array.set(e.normals),s.array.set(e.uvs),n.array.set(e.indices),i.needsUpdate=!0,r.needsUpdate=!0,s.needsUpdate=!0,void(n.needsUpdate=!0);this.setAttribute("position",new _e(e.positions,3)),this.setAttribute("normal",new _e(e.normals,3)),this.setAttribute("uv",new _e(e.uvs,2)),this.setIndex(new _e(e.indices,1))}clone(){let t=new Sj(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return t.userData=K5(this.userData),t}}}),Tm=j(()=>{Em(),gCt(),R0t(),rb(),mT(),Pm=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:as.ODD},t.parameters),s=Math.abs(r.width),n=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=t.shape??e?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ms?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ms(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let h=i??new ms(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:h,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:h}=t.parameters,u=h===1;return t.shape.roundness=a,i<=0?e=new xj(t.shape,n,{windingRule:o}):r<=0?e=new K4(t.shape,i,n,o,l,u):fT!==void 0?e=new Sj(t.shape,i,r,n,s,t.ownerId,l,u):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new K4(t.shape,i,n,o,l,u)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function bCt(t,e,i,r,s,n){if(r>=yW)return s>30||s%4==0?(function(u,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;u.addPoint(ZM(m-d,f,m-d,f-v,m-d,f+v)),u.addPoint(ZM(m,f+c,m-y,f+c,m+y,f+c)),u.addPoint(ZM(m+d,f,m+d,f+v,m+d,f-v)),u.addPoint(ZM(m,f-c,m+y,f-c,m-y,f-c)),p>0&&V0t(u,d,c,p)}(t,e,i,n),Math.round(s/4)):QK(t,r,s,e,i,n);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},h=function({px:u,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(u-c)/2,_=(d-p)/2;if(b===0&&_===0)return[];m=Math.abs(m),f=Math.abs(f);let x=Math.pow(b,2)/Math.pow(m,2)+Math.pow(_,2)/Math.pow(f,2);x>1&&(m*=Math.sqrt(x),f*=Math.sqrt(x));let S=function(I,O,B,V,z,k,L,H,W,X){let nt=Math.pow(z,2),st=Math.pow(k,2),yt=Math.pow(L,2),pt=Math.pow(H,2),Q=nt*st-nt*pt-st*yt;Q<0&&(Q=0),Q/=nt*pt+st*yt,Q=Math.sqrt(Q)*(W===X?-1:1);let ut=Q*z/k*H,wt=Q*-k/z*L,St=ut+(I+B)/2,Tt=wt+(O+V)/2,vt=(L-ut)/z,It=(H-wt)/k,Ut=(-L-ut)/z,Bt=(-H-wt)/k,zt=WK(1,0,vt,It),kt=WK(vt,It,Ut,Bt);return!X&&kt>0&&(kt-=sR),X&&kt<0&&(kt+=sR),{centerx:St,centery:Tt,ang1:zt,ang2:kt}}(u,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:C,centery:M}=S,A=Math.abs(T)/(sR/4);Math.abs(1-A)<1e-7&&(A=1);let R=Math.max(Math.ceil(A),1);T/=R;for(let I=0;I<R;I++)v.push(mCt(w,T)),w+=T;return v.map(I=>{let{x:O,y:B}=lN(I[0],m,f,C,M),{x:V,y:z}=lN(I[1],m,f,C,M),{x:k,y:L}=lN(I[2],m,f,C,M);return{x1:O,y1:B,x2:V,y2:z,x:k,y:L}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?function(u,d,c,p,m,f,g,y){let v=Math.round(m/p.length);u.addPoint(gv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=u.points[b],w=gv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),u.addPoint(w)}return y>0?k0t(u,f,g,y):u.addPoint(gv(0,0)),v}(t,a.x,a.y,h,s,e,i,n):QK(t,r,s,e,i,n)}function QK(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;t.addPoint(gv(h,u))}return e<yW?n>0?k0t(t,r,s,n):t.addPoint(gv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&V0t(t,r,s,n)),1}function gv(t,e){return new Xg(Ft.generateUUID(),new Z(t,e))}function ZM(t,e,i,r,s,n){let a=gv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function k0t(t,e,i,r){z0t(t,e,i,r).forEach(s=>t.addPoint(s))}function V0t(t,e,i,r){let s=z0t(t,e,i,r),n=new ms;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function z0t(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Z(s/e,n/i),o=t.points.map(l=>{let h=l.clone();return h.uuid=Ft.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var yW,pD,L0t,pN,F0t,J4=j(()=>{Em(),_0t(),fCt(),Tm(),ht(),yW=2*Math.PI,pD=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return i.angle=Ft.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let e,{width:i,height:r,spikes:s,angle:n,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=t.parameters,d=t.shape,c=bCt(d,.5*i,.5*r,n*Math.PI/180,s,a);return d.isClosed=!0,d.update(),n===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=Pm.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),JK=j(()=>{ht(),m0t(),L0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new pN(.5*e,n,a):new iU(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},pN=class extends X4{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s,t,e,i),this.type=s}static fromJSON(t){return new pN(t.radius,t.corner,t.cornerSides)}}}),tZ=j(()=>{ht(),F0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{points:e,segments:i,verticalSegments:r}=t.parameters,s=new OS;s.moveTo(e[0].x,e[0].y),s.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new rU(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function $0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function _Ct(t){let{positions:e,faces:i,materialIndices:r,uvs:s}=t,n=e.length/3,a=i.length/3,o=s!==null&&a>0,l=3*a,h=new Uint32Array(l),u=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,f=8;for(;f<2*l;)f*=2;let g=f-1,y=new Int32Array(f).fill(-1),v=(O,B)=>{let V=(Math.imul(O,2654435761)^B)&g;for(;;){let z=y[V];if(z===-1)return y[V]=m,h[m]=O,u[m]=B,m++;if(h[z]===O&&u[z]===B)return z;V=V+1&g}},b=(O,B)=>{let V=O<B?O:B,z=O<B?B:O,k=(Math.imul(V,2654435761)^z)&g;for(;;){let L=y[k];if(h[L]===V&&u[L]===z)return L;k=k+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(O,B,V)=>{let z=O<B?v(O,B):v(B,O),k=++d[z];k===1?c[z]=V:k===2&&(p[z]=V),_[O]++,_[B]++,x[3*O]+=e[3*B],x[3*O+1]+=e[3*B+1],x[3*O+2]+=e[3*B+2],x[3*B]+=e[3*O],x[3*B+1]+=e[3*O+1],x[3*B+2]+=e[3*O+2]};for(let O=0;O<a;O++){let B=i[3*O],V=i[3*O+1],z=i[3*O+2];S(B,V,z),S(V,z,B),S(z,B,V)}let w=new Float64Array(3*m);for(let O=0;O<m;O++){let B=3*h[O],V=3*u[O];if(d[O]===2){let z=3*c[O],k=3*p[O];w[3*O]=.375*(e[B]+e[V])+.125*(e[z]+e[k]),w[3*O+1]=.375*(e[B+1]+e[V+1])+.125*(e[z+1]+e[k+1]),w[3*O+2]=.375*(e[B+2]+e[V+2])+.125*(e[z+2]+e[k+2])}else w[3*O]=.5*(e[B]+e[V]),w[3*O+1]=.5*(e[B+1]+e[V+1]),w[3*O+2]=.5*(e[B+2]+e[V+2])}let T,C=new Float64Array(3*n);for(let O=0;O<n;O++){let B=_[O];B===3?T=3/16:B>3&&(T=3/(8*B));let V=1-B*Number(T),z=Number(T);B===2&&(V=3/4,z=1/8),C[3*O]=e[3*O]*V+x[3*O]*z,C[3*O+1]=e[3*O+1]*V+x[3*O+1]*z,C[3*O+2]=e[3*O+2]*V+x[3*O+2]*z}let M=new Float64Array(3*(n+m));M.set(C),M.set(w,3*n);let A=new Uint32Array(12*a),R=new Array(4*a),I=o?new Float64Array(24*a):null;for(let O=0;O<a;O++){let B=i[3*O],V=i[3*O+1],z=i[3*O+2],k=b(B,V)+n,L=b(V,z)+n,H=b(z,B)+n,W=12*O;A[W++]=k,A[W++]=L,A[W++]=H,A[W++]=B,A[W++]=k,A[W++]=H,A[W++]=V,A[W++]=L,A[W++]=k,A[W++]=z,A[W++]=H,A[W++]=L;let X=r[O];if(R[4*O]=X,R[4*O+1]=X,R[4*O+2]=X,R[4*O+3]=X,I!==null){let nt=6*O,st=s[nt],yt=s[nt+1],pt=s[nt+2],Q=s[nt+3],ut=s[nt+4],wt=s[nt+5],St=$0(st,pt),Tt=$0(yt,Q),vt=$0(pt,ut),It=$0(Q,wt),Ut=$0(st,ut),Bt=$0(yt,wt),zt=24*O;I[zt++]=St,I[zt++]=Tt,I[zt++]=vt,I[zt++]=It,I[zt++]=Ut,I[zt++]=Bt,I[zt++]=st,I[zt++]=yt,I[zt++]=St,I[zt++]=Tt,I[zt++]=Ut,I[zt++]=Bt,I[zt++]=pt,I[zt++]=Q,I[zt++]=vt,I[zt++]=It,I[zt++]=St,I[zt++]=Tt,I[zt++]=ut,I[zt++]=wt,I[zt++]=Ut,I[zt++]=Bt,I[zt++]=vt,I[zt++]=It}}return{positions:M,faces:A,materialIndices:R,uvs:I}}var QM,U0t,sn,j0t,vW,xCt=j(()=>{ht(),QM=1e4,U0t=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(r){let s=r.getAttribute("position");if(s===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let n=r.getAttribute("uv"),a=r.getIndex(),o=s.count,l=new Map,h=new Uint32Array(o),u=[],d=0;for(let v=0;v<o;v++){let b=s.getX(v),_=s.getY(v),x=s.getZ(v),S=Math.round(b*QM),w=Math.round(_*QM),T=Math.round(x*QM),C=l.get(S);C===void 0&&(C=new Map,l.set(S,C));let M=C.get(w);M===void 0&&(M=new Map,C.set(w,M));let A=M.get(T);A===void 0&&(A=d++,M.set(T,A),u.push(b,_,x)),h[v]=A}let c=[],p=[],m=n===void 0?null:[],f=a!==null?a.count:o,g=(v,b)=>{let _=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,S=a!==null?a.getX(v+2):v+2;if(!(_<o&&x<o&&S<o))return;let w=h[_],T=h[x],C=h[S];w===T||T===C||C===w||(c.push(w,T,C),p.push(b),m!==null&&m.push(n.getX(_),n.getY(_),n.getX(x),n.getY(x),n.getX(S),n.getY(S)))},y=r.groups;if(y.length>0)for(let v=0;v<y.length;v++){let b=y[v],_=b.materialIndex===void 0?0:b.materialIndex,x=Math.max(b.start,0),S=Math.min(b.start+b.count,f);for(let w=x;w<S&&w+2<f;w+=3)g(w,_)}else for(let v=0;v+2<f;v+=3)g(v,0);return{positions:Float64Array.from(u),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=_Ct(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,h=n.length/3,u=a.length/3,d=new Float64Array(3*h);for(let y=0;y<u;y++){let v=3*a[3*y],b=3*a[3*y+1],_=3*a[3*y+2],x=n[_]-n[b],S=n[_+1]-n[b+1],w=n[_+2]-n[b+2],T=n[v]-n[b],C=n[v+1]-n[b+1],M=n[v+2]-n[b+2],A=S*M-w*C,R=w*T-x*M,I=x*C-S*T;d[v]+=A,d[v+1]+=R,d[v+2]+=I,d[b]+=A,d[b+1]+=R,d[b+2]+=I,d[_]+=A,d[_+1]+=R,d[_+2]+=I}for(let y=0;y<h;y++){let v=d[3*y],b=d[3*y+1],_=d[3*y+2],x=Math.sqrt(v*v+b*b+_*_)||1;d[3*y]=v/x,d[3*y+1]=b/x,d[3*y+2]=_/x}let c=3*u,p=new Float32Array(3*c),m=new Float32Array(3*c),f=l!==null&&l.length>0?new Float32Array(2*c):null;for(let y=0;y<c;y++){let v=3*a[y];p[3*y]=n[v],p[3*y+1]=n[v+1],p[3*y+2]=n[v+2],m[3*y]=d[v],m[3*y+1]=d[v+1],m[3*y+2]=d[v+2]}f!==null&&f.set(l.subarray(0,2*c));let g=new ye;g.setAttribute("position",new _e(p,3)),c>0&&(g.setAttribute("normal",new _e(m,3)),g.setAttribute("color",new _e(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new _e(f,2));for(let y=0;y<u;){let v=o[y],b=y;do y++;while(y<u&&o[y]===v);g.addGroup(3*b,3*(y-b),v)}return s.boundingBox!==null&&(g.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(g.boundingSphere=s.boundingSphere.clone()),g}(e,t)}}}),eZ=j(()=>{ht(),xCt(),sn=new P,j0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new ye().copy(new Zh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(sn),i={width:sn.x,height:sn.y,depth:sn.z,subdivisions:0}):i=e.parameters;let s={...i,...t.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(t){let{width:e,height:i,depth:r,subdivisions:s}=t.parameters,n=t.geometry??new ye().copy(new Zh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let h=new cr,u=l.attributes.position;return u?(h.setFromBufferAttribute(u),h):(h.makeEmpty(),h)}(n),n.boundingBox.getSize(sn)):sn.set(a.width,a.height,a.depth),(e!==sn.x||i!==sn.y||r!==sn.z)&&n.scale(sn.x===0?1:e/sn.x,sn.y===0?1:i/sn.y,sn.z===0?1:r/sn.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new U0t(s).modify(o)):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete t.geometry,Object.assign(n,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new MG(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(sn);let n=100/sn.x;Object.assign(s.parameters,{width:100,height:sn.y*n,depth:sn.z*n}),e(this.build(s))})}}}),Tj=j(()=>{Em(),Tm(),vW=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},t.parameters);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i,c=2*Math.PI/r;for(let m=0;m<r;m++){let f=c*m,g=0+Math.sin(f)*u,y=0+Math.cos(f)*d;h.addPoint(h.createPoint(g,y))}h.isClosed=!0;for(let m=0,f=h.points.length;m<f;m++)h.points[m].roundness=s;h.roundness=s,h.update();let p=Pm.create({shape:h,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...t,type:"PolygonGeometry"}})}}});function f_(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function mN(t,e,i,r,s,n){let a=W0t.copy(e).sub(t),o=q0t.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(t).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function wCt(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var G0t,W0t,q0t,iZ,mD,H0t,$0t,X0t,rZ,bW,Y0t,K0t,Z0t,Q0t,sZ=j(()=>{ht(),G0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,h=new iZ(.5*e,i,s,n,a,o,l),u=r/e;return u!==1&&h.scale(1,1,u),Object.assign(h,{userData:{...t,type:"PyramidGeometry"}})}},W0t=new P,q0t=new P,iZ=class extends ye{constructor(t=.5,e=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o,l=[],h=[],u=[],d=[],c=0,p=e/2,m=Math.PI/i,f=t*Math.cos(Math.PI/i),g=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new P(0,-p,0),_=new P(0,p,0),x=new Z(t,-p),S=new Z(f,-p),w=new Z(0,_.y).sub(S),T=new Z(0,_.y).sub(x),C=new Z(w.y,-w.x).normalize(),M=new Z(T.y,-T.x).normalize(),A=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,A);{let k=new P(C.x,C.y,0),L=new P(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);o=k.angleTo(L)}let R=n/Math.tan((Math.PI-w.angle())/2),I=n/Math.tan((Math.PI-o)/2),O=new P;if(!s){h.push(b.x,b.y,b.z),u.push(0,-1,0),d.push(0,0);let k=c++,L=[],H=x.clone(),W=R/Math.cos(Math.PI/i);H.x-=W;for(let X=0;X<i;X++){let nt=X/i*Math.PI*2+m;f_(H,new Z(Math.sin(nt),Math.cos(nt)),O),h.push(O.x,O.y,O.z),u.push(0,-1,0),d.push(0,0),L.push(c++)}for(let X=0;X<L.length;X++)l.push(L[X],k,L[(X+1)%L.length])}let B=[];{let k=new P,L=new P,H=new P,W=new P,X=new P,nt=new P;for(let st=0;st<i;st++){let yt=st/i*Math.PI*2+m,pt=(st+.5)/i*Math.PI*2+m,Q=(st+1)/i*Math.PI*2+m,ut=new Z(Math.sin(yt),Math.cos(yt)),wt=new Z(Math.sin(pt),Math.cos(pt)),St=new Z(Math.sin(Q),Math.cos(Q));f_(x,ut,L),f_(x,St,H),f_(C,wt,k),mN(_,L,H,I,I,W),h.push(W.x,W.y,W.z),mN(L,_,H,I,R,X),h.push(X.x,X.y,X.z),mN(H,L,_,R,I,nt),h.push(nt.x,nt.y,nt.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),u.push(k.x,k.y,k.z),d.push(0,0),d.push(0,0),d.push(0,0);let Tt=c++,vt=c++,It=c++;if(l.push(Tt,vt,It),n>0){{let zt=L.clone().add(H).multiplyScalar(.5),kt=_.clone().sub(zt).normalize(),qt=b.clone().sub(zt).normalize().add(kt).normalize().multiplyScalar(-1);V(zt,nt.clone().sub(X),qt,w.angle())}let Ut,Bt;{let zt=new P;f_(M,St,zt);let kt=nt.clone().add(W).multiplyScalar(.5);kt=wCt(kt,H,_);let qt=nt.clone().sub(W);[Ut,Bt]=V(kt,qt,zt,o,W.y)}{let zt=Ut,kt=zt.clone().setY(0).normalize(),qt=new P(0,-1,0),$t=kt.clone().cross(qt);z(zt,kt,qt,$t)}B.concat(Bt);{let zt=w.angle(),kt=Math.PI-zt,qt=_.clone();qt.y-=n/Math.sin(zt-Math.PI/2);let $t=new P,Pt=[];for(let Gt=0;Gt<a;Gt++){let Zt=[],Jt=Math.PI/2-kt*Gt/a,$=Math.cos(Jt),se=Math.sin(Jt),Pe=pt;for(let Ve=0;Ve<=Gt;Ve++){let ie=Math.cos(Pe),oi=Math.sin(Pe);k.x=$*oi,k.y=se,k.z=$*ie,$t.copy(qt).addScaledVector(k,n),h.push($t.x,$t.y,$t.z),u.push(k.x,k.y,k.z),d.push(0,0),Zt.push(c++),Pe+=2*Math.PI/Gt/i}Pt.push(Zt)}Bt.reverse(),Pt.push(Bt);let oe=Pt.length-1;for(let Gt=0;Gt<oe;Gt++){let Zt=Pt[Gt],Jt=Pt[Gt+1],$=Zt.length-1;l.push(Jt[1],Zt[0],Jt[0]);for(let se=1;se<=$;se++)l.push(Zt[se],Zt[se-1],Jt[se]),l.push(Jt[se+1],Zt[se],Jt[se])}}}}}function V(k,L,H,W,X){let nt=-W/2,st=(Math.PI-W)/2,yt=L.clone().normalize().cross(H);k.addScaledVector(H,-n/Math.sin(st));let pt=new P,Q=new P,ut=c,wt=[];for(let St=0;St<=a;St++){let Tt=nt+St/a*W;Q.set(0,0,0),Q.addScaledVector(yt,Math.sin(Tt)),Q.addScaledVector(H,Math.cos(Tt));for(let vt=0;vt<=1;vt++){let It=vt/1-.5;if(pt.copy(k),pt.addScaledVector(L,It),pt.addScaledVector(Q,n),X!=null){let Ut=Math.max(0,pt.y-X);pt.addScaledVector(L,-Ut/L.y)}h.push(pt.x,pt.y,pt.z),u.push(Q.x,Q.y,Q.z),d.push(0,0),vt===0&&wt.push(c),c++}}for(let St=0;St<a;St++)for(let Tt=0;Tt<1;Tt++){let vt=ut+Tt+2*St,It=vt+2,Ut=It+1,Bt=vt+1;l.push(vt,It,Bt),l.push(It,Ut,Bt)}return[k.clone().addScaledVector(L,.5),wt]}function z(k,L,H,W){let X=Math.PI/2,nt=T.angle()-X,st=[],yt=new P,pt=new P;for(let ut=0;ut<=a;ut++){let wt=[],St=ut/a;for(let Tt=0;Tt<=ut;Tt++){let vt=((ut?Tt/ut:0)-.5)*v,It=Math.cos(vt),Ut=Math.sin(vt),Bt=(X+Math.atan(Math.tan(nt)*It))*St,zt=Math.cos(Bt),kt=Math.sin(Bt);yt.set(0,0,0),yt.addScaledVector(L,kt*It),yt.addScaledVector(H,zt),yt.addScaledVector(W,kt*Ut),pt.copy(k).addScaledVector(yt,n),h.push(pt.x,pt.y,pt.z),u.push(yt.x,yt.y,yt.z),d.push(0,0),wt.push(c++)}st.push(wt)}let Q=st.length-1;for(let ut=0;ut<Q;ut++){let wt=st[ut],St=st[ut+1],Tt=wt.length-1;l.push(wt[0],St[1],St[0]);for(let vt=1;vt<=Tt;vt++)l.push(wt[vt-1],wt[vt],St[vt]),l.push(wt[vt],St[vt+1],St[vt])}}this.setIndex(l),this.setAttribute("position",new ge(h,3)),this.setAttribute("normal",new ge(u,3)),this.setAttribute("uv",new ge(d,2))}}}),t5=j(()=>{Em(),Tm(),mD=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters),r=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(t){let e=t.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}=t.parameters,u={x:.5*i,y:.5*r},d={x:-u.x,y:-u.y},c={x:u.x,y:u.y};function p(x,S,w){return S>i&&w>r?Math.min(x*i/S,x*r/w):S>i?x*i/S:w>r?x*r/w:x}let m=[];m[0]=s[0]===0?0:p(s[0],s[0]+s[3],s[0]+s[1]),m[1]=s[1]===0?0:p(s[1],s[1]+s[2],s[1]+s[0]),m[2]=s[2]===0?0:p(s[2],s[2]+s[1],s[2]+s[3]),m[3]=s[3]===0?0:p(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,g=c.x,y=c.y,v=d.y;e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(g,v)),e.addPoint(e.createPoint(f,v)),e.isClosed=!0;let b=!0;for(let x=0,S=e.points.length;x<S;x++)e.points[x].roundness=m[x],x>0&&m[x]!==m[x-1]&&(b=!1);b&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let _=Pm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),nZ=j(()=>{ht(),H0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},t.parameters);return i.thetaLength=Ft.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i=100,height:r=i,depth:s=i,widthSegments:n=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:h,thetaLength:u}=t.parameters;return u===0?(e=new ye,e.setAttribute("position",new ge([],3))):e=new Ec(.5*i,n,a,o,l,h,u*Ft.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),aZ=j(()=>{ht(),$0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(t){let{width:e=100,height:i=e,widthSegments:r=8,heightSegments:s=8}=t.parameters,n=new Oc(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),oZ=j(()=>{ht(),X0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=t.parameters,o=new rZ(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},rZ=class extends ye{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(pt=0,Q=0,ut=0)=>new P(pt,Q,ut),p=c(),m=c(),[f,g,y]=[e/2,t/2,i/2],v=-g,b=+g,[_,x,S]=[c(v,-f,+y),c(v,-f,-y),c(v,+f,-y)],w=(pt,Q=!1)=>Math.sin(pt-Math.PI/(+Q+1)),T=(pt,Q=!1)=>Math.cos(pt-Math.PI/(+Q+1));S.y=Math.sin(r)*e-f;let C=Math.cos(r)*e-y,M=_.z-h;r<=d?(S.z=Math.min(C,M),S.z==M&&(S.y-=(C-M)/Math.tan(d-r))):x.z=Math.min(x.z-C-y,_.z-h),p.subVectors(_,x),m.subVectors(S,x);let A=Math.min(p.length(),m.length())*s/100,R=A*Math.tan(r/2),I=A/Math.cos(r/2),O=p.clone().normalize().add(m.normalize()).setLength(I).add(x);p.set(0,w(r,!0),T(r,!0)),u.push([S,p.clone()]);let B=(Math.PI-r)/n;for(let pt=0;pt<=n;pt++){let Q=d+r+pt*B;p.set(0,Math.sin(Q)*R,Math.cos(Q)*R),p.add(O),m.set(0,w(Q),T(Q)),u.push([p.clone(),m.clone()])}u.push([_,c(0,1,0)]);let V=Math.sin(B/2)*R*2,z=u.length-1,k=u[0][0].distanceTo(u[1][0]),L=k+V*n+u[z-1][0].distanceTo(u[z][0]);u[0].push(1);for(let pt=0;pt<=n;pt++)u[pt+1].push(1-(k+pt*V)/L);u[z].push(0);let H,W,X,[nt,st,yt]=u[0];for(let pt=1;pt<u.length;pt++)[H,W,X]=u[pt],a.push(v,nt.y,nt.z,v,H.y,H.z,b,nt.y,nt.z,b,nt.y,nt.z,v,H.y,H.z,b,H.y,H.z),o.push(0,st.y,st.z,0,W.y,W.z,0,st.y,st.z,0,st.y,st.z,0,W.y,W.z,0,W.y,W.z),l.push(0,yt,0,X,1,yt,1,yt,0,X,1,X),[nt,st,yt]=[H,W,X];this.setAttribute("position",new ge(a,3)),this.setAttribute("normal",new ge(o,3)),this.setAttribute("uv",new ge(l,2))}}}),Mj=j(()=>{Em(),Tm(),bW=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=t.parameters,d=t.shape,c=.5*e,p=.5*i,m=a*Math.PI/360/s,f=Math.PI/2*3*-1,g=c*r/100,y=p*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let _=m*b,x=0+Math.sin(_)*c,S=0+Math.cos(_)*p;d.addPoint(d.createPoint(x,S))}}else for(let b=0;b<s;b++){let _=0+Math.cos(f)*c,x=0+Math.sin(f)*p;d.addPoint(d.createPoint(_,x)),f+=m,_=0+Math.cos(f)*g,x=0+Math.sin(f)*y,d.addPoint(d.createPoint(_,x)),f+=m}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let v=Pm.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}});return Object.assign(v,{userData:{...t,type:"StarGeometry"}})}}}),lZ=j(()=>{ht(),Y0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i}=t.parameters,r=new Oc(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),hZ=j(()=>{ht(),WS(),K0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let n=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,h=function(u,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=Ft.clamp(m/360,0,1);if(x===0){let S=new ye;return S.setAttribute("position",new ge([],3)),S}return x===1&&(b=0),new uj(!0,u,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return h.scale(1,i/e,1),Object.assign(h,{userData:{...t,type:"TorusGeometry"}})}}}),uZ=j(()=>{ht(),Z0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??.125*i.width})}}static build(t){let{width:e,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new sU(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),dZ=j(()=>{Em(),Tm(),Q0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},t.parameters);return{shape:t.shape&&t.shape instanceof ms?t.shape:new ms,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i;o?(h.addPoint(h.createPoint(-u,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))):(h.addPoint(h.createPoint(0,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))),h.isClosed=!0;for(let p=0,m=h.points.length;p<m;p++)h.points[p].roundness=r;h.roundness=r,h.update();let c=Pm.create({shape:h,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...t,type:"TriangleGeometry"}})}}}),SCt=j(()=>{ht()}),TCt=j(()=>{ht(),new Jn,new xt,new gc,new P,new P,new P,new P});function cZ(){let t=new ye;return t.setAttribute("position",new _e(new Float32Array([]),3)),t.setIndex(new _e(new Uint16Array([]),1)),t}var pZ,Aj,J0t=j(()=>{un(),Be(),mT(),ht(),dT(),Em(),Tm(),rb(),pZ=cZ().attributes,Aj=class extends ye{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this._nearSide=new Uint8Array(0),this._depth=0,this._effectiveBevel=0,this._vScale=0,Object.assign(this.attributes,pZ),this.userData={parameters:t,type:"TextGeometry"};let i=e.getFont(t.font);i?.isLoaded?(this.font=i,this.update(t,e)):this.updateFont(t.font,e).then(()=>{this.update(t,e),e?.requestRender()})}async updateFont(t,e){let i=e.getFont(t);i&&(this.font=i,await i.loadingPromise)}update(t,e){let i=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:h,fontSize:u,extrusionVersion:d}=t,c=Da.getDisplayedValue(l),p=function(S,w,T,C){let M=typeof S.width=="string"?Number(C.getVariable(S.width)):S.width,A=[""],R="";for(let I of T)R+=I,I===" "||I===`
366
366
  `?(A[A.length-1]+=R,R="",I===`
367
- `&&A.push("")):w.getTextWidth(A[A.length-1]+R,S)>M&&(A[A.length-1].length&&A.push(""),w.getTextWidth(A[A.length-1]+R,S)>M&&(R.length===1?(A[A.length-1]+=R,R=""):(A[A.length-1]+=R.slice(0,-1),R=R[R.length-1],A.push(""))));return A[A.length-1]+=R,A}(t,i,h===2?c.toUpperCase():h===3?c.toLowerCase():c,e),{shapes:m,charWidths:f,charCoords:g}=i.generateShapes(p,t,e),y=.5*(typeof r=="number"?r:Number(e.getVariable(r))),v=.5*(typeof s=="number"?s:Number(e.getVariable(s))),b=m.map(S=>new ms().fromShape(S,!0));this.vectorShapes=b;let _=b.map(S=>Pm.create({shape:S,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:u,extrusionVersion:d,windingRule:n<=0?as.NONZERO:as.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),x=_.length?Ig(_):cZ();x.translate(-y,v,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([S,w])=>{this.setAttribute(S,w)}),this.setIndex(x.index),this.adoptNearSide(_,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,h=l._nearSide;if(h===void 0||h.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=h.length,r=Math.max(r,l._effectiveBevel??0),s=l._vScale??s}this._effectiveBevel=r,this._vScale=s;let n=new Uint8Array(i),a=0;for(let o of t){let l=o._nearSide;n.set(l,a),a+=l.length}this._nearSide=n}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length===this.getAttribute("position")?.count&&Q1(this._effectiveBevel,t)&&Q1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position"),r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=e,h===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=$a(new ye,Aj.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([e,i])=>{this.setAttribute(e,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t,e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:t}},e)}get text(){return this.userData.parameters.text??""}}});function MCt(t){if(!Cj)return mZ||(mZ=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.121/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});tyt(a),Cj=!0}())}var tyt,_W,Cj,mZ,fD=j(()=>{_W=new Promise(t=>{tyt=t}),Cj=!1});function fN(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),r=Object.keys(e.attributes);if(i.length!==r.length)return!1;for(let l of r){let h=t.attributes[l],u=e.attributes[l];if(h===void 0||h.isInterleavedBufferAttribute===!0||u.isInterleavedBufferAttribute===!0||h.itemSize!==u.itemSize||h.normalized!==u.normalized||h.array.constructor!==u.array.constructor||h.array.length!==u.array.length)return!1}let s=t.index,n=e.index;if(s===null!=(n===null))return!1;let a=!1;if(s!==null&&n!==null){if(s.array.length!==n.array.length)return!1;let l=s.array.constructor,h=n.array.constructor;if(l!==h){if(l!==Uint32Array||h!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let h=t.groups[l],u=e.groups[l];if(h.start!==u.start||h.count!==u.count||h.materialIndex!==u.materialIndex)return!1}for(let l of r){let h=t.attributes[l],u=e.attributes[l];h.array.set(u.array),h.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,h=n.array;for(let u=0,d=h.length;u<d;u++){let c=h[u];l[u]=c===65535?4294967295:c}}else s.array.set(n.array);s.needsUpdate=!0}return t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t.boundingBox=null,t.boundingSphere=null,!0}function Ej(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,h=eyt.makeScale(e,i,r).invert().elements;for(let u=0,d=o.length;u<d;u+=3)o[u]*=e,o[u+1]*=i,o[u+2]*=r,s=l[u],n=l[u+1],a=l[u+2],l[u]=h[0]*s+h[4]*n+h[8]*a,l[u+1]=h[1]*s+h[5]*n+h[9]*a,l[u+2]=h[2]*s+h[6]*n+h[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var eyt,iyt=j(()=>{ht(),eyt=new xt});function Pj(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function JM(t){if(t!=null){if(Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView))return t;if(typeof t=="object")return function(e){let i=Object.keys(e),r=0;for(let n of i){let a=Pj(n);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let s=new Array(r);for(let n=0;n<r;n++){let a=e[n];if(typeof a!="number")return;s[n]=a}return s}(t)}}function gN(t){if(t==null)return"missing";if(Array.isArray(t))return`Array(${t.length})`;if(ArrayBuffer.isView(t)){let l=t;return`${t.constructor.name}(${l.length})`}if(typeof t!="object")return typeof t;let e=Object.keys(t),i=e.filter(l=>Pj(l)===-1),r=0;for(let l of e){let h=Pj(l);h>=r&&(r=h+1)}let s=t,n=-1,a=-1;for(let l=0;l<r;l++)l in s?typeof s[l]!="number"&&a===-1&&(a=l):n===-1&&(n=l);let o=[`${e.length} keys`,"max index "+(r-1)];return n!==-1&&o.push(`first missing index ${n}`),a!==-1&&o.push(`non-number at ${a} (${typeof s[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function ryt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function xW(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let u=0;u<i;u++){let d=e?e.getX(u):u,c=t.getX(d),p=t.getY(d),m=t.getZ(d),f=Math.round(c*s),g=Math.round(p*s),y=Math.round(m*s),v=n.get(f);v===void 0&&(v=new Map,n.set(f,v));let b=v.get(g);b===void 0&&(b=new Map,v.set(g,b));let _=b.get(y);_===void 0&&(_=r++,b.set(y,_),o.push(c,p,m)),a[u]=_}let l=[],h=[];for(let u=0;u<a.length;u+=3)a[u]===a[u+1]||a[u]===a[u+2]||a[u+1]===a[u+2]||(l.push(a[u],a[u+1],a[u+2]),h.push(e?e.getX(u):u,e?e.getX(u+1):u+1,e?e.getX(u+2):u+2));return{positions:o,triIndices:l,triOriginals:h}}var g_,df,Ne,yN,vN,bN,ps,y_,tA,eA,iA,Rj,nR,sb=j(()=>{ht(),fD(),Be(),gD(),iyt(),WS(),g_=new cr,df=new P,_W.then(t=>{Ne=t}),yN=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),vN=new Uint32Array([0,1,2,3]),bN=new Uint8Array([4]),ps=class extends ye{constructor(t,e){super(),this.data=t,this.flatShading=e,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,e){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=ym.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&Ej(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Ej(this.originalGeometry.attributes,...r),this.data=t;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(df.fromArray(r));let n=df.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(t){this.freeSubdivPointer(),this.data=t;let e=t.phongAngle??35;this.flatShading&&(e=-1);let i=null;if(t.subdivisions>0){let s=0;try{s=ps.allocate(t),i=ps.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&ps.freeSubdivPointer(s)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=ps.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Zh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ps.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Jn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;g_.setFromBufferAttribute(e),g_.getCenter(i),t.boundingSphere.radius=i.distanceTo(g_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),g_.getSize(df);let r={width:df.x,height:df.y,depth:df.z};return this.userData.parameters=r,r}static build(t,e,i,r){let s,n,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Ne.free_bvh(e),Ne.free_subdivision_surface(e));try{s=ps.allocate(t,r)}catch(l){console.error(l,t),s=ps.allocate({positionWASM:yN,indexWASM:vN,verticesPerFaceWASM:bN},r)}Ne.set_destination_refinement_level(s,0);let o=ps.buildLevel(s,!0,a);return n=t.subdivisions>0?ps.buildRefined(s,t.subdivisions,a):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:n}}static buildRefined(t,e,i){try{return Ne.set_destination_refinement_level(t,e),ps.buildLevel(t,!1,i)??null}catch{try{return Ne.set_destination_refinement_level(t,e-1),ps.buildLevel(t,!1,i)??null}catch{return null}}}static primitiveToQuads(t,e,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let r,s=t.shape!==void 0||t.path!==void 0?e.geometry:hm(t,i,!1,e);r=Wgt(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=xW(s.getAttribute("position"),r);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let c=t.radialSegments*t.heightSegments*3*2;n=[c,c+3*t.radialSegments]}let{indices:h,verticesPerFace:u,uvs:d}=function(c,p,m,f,g){let y=[],v=[],b=g?m.getAttribute("uv"):void 0,_=b&&b.itemSize===2?[]:void 0,x=T=>{if(_){let C=g[T];_.push(b.getX(C),b.getY(C))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),C=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&C<=24&&C%4==0&&m.userData.parameters.angle>=360){let R=T.length/2/C;T=T.filter((I,O)=>Math.floor(O/2)%R===0)}let M=0;for(let R=0;R<T.length;R+=2)M+=(T[R]-T[(R===0?T.length:R)-2])*(T[R+1]+T[(R===0?T.length:R)-1]);c.length=0;let A=0;if(M<0)for(let R=0;R<T.length;R+=2)c.push(T[R],T[R+1],0),y.push(A++);else for(let R=T.length-2;R>=0;R-=2)c.push(T[R],T[R+1],0),y.push(A++);return v.push(A),{indices:y,verticesPerFace:v}}let S=new Float32Array([m.userData.parameters.depth])[0],w=0;for(;w<p.length;){if(m.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[w]+2]===S||c[3*p[w]+2]===0)&&T++,(c[3*p[w+1]+2]===S||c[3*p[w+1]+2]===0)&&T++,(c[3*p[w+2]+2]===S||c[3*p[w+2]+2]===0)&&T++,T===3)break}if(p[w+1]===p[w+3]&&p[w+2]===p[w+5]||p[w+0]===p[w+3]&&p[w+2]===p[w+4]){y_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),tA.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),eA.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),iA.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),tA.sub(y_).normalize(),eA.sub(y_).normalize(),iA.sub(y_).normalize();let T=tA.cross(eA).dot(iA),C=w;Math.abs(T)>.005||f&&f.some((M,A)=>A%2!=1&&C>=f[A]&&C<f[A+1])?(y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3):(y.push(p[w],p[w+1],p[w+4],p[w+5]),x(w),x(w+1),x(w+4),x(w+5),v.push(4),w+=6)}else y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3}if(m.useNgonForTopBottomFaceDuringBake){let T=[],C=[],M=0;for(let A=0,R=0;A<c.length;A+=3,R++)c[A+2]===0&&(T.push(R),M++),c[A+2]===S&&C.push(R);if(m.userData.parameters.extrudeBevelSize===0){let A=C[0];C[0]=C[1],C[1]=A}T.reverse(),y.push(...T,...C),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:h,verticesPerFace:u,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=JM(t.positionWASM),l=JM(t.indexWASM),h=JM(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!h?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${gN(t.positionWASM)}, indexWASM ${gN(t.indexWASM)}, verticesPerFaceWASM ${gN(t.verticesPerFaceWASM)}`);i=o,r=l,s=h;let w=JM(t.uvWASM);Ne.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=yN,r=vN,s=bN;let u=i.length,d=r.length,c=s.length,p=i.length+n.length+a.length,m=r.length+s.length,f=p*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,y=Ne._malloc(f);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${f}) failed`);let v,b=new Float32Array(Ne.HEAPF32.buffer,y,p),_=new Uint32Array(Ne.HEAPU32.buffer,y+g,m);b.set(i,0),b.set(n,i.length),b.set(a,i.length+n.length),_.set(r,0),_.set(s,r.length),t?.scaleBaked?.some(w=>w!==1)&&(v=new xt().makeScale(...t.scaleBaked.map(w=>typeof w=="number"?w:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+n.length)*Float32Array.BYTES_PER_ELEMENT,S=a.length?v?Ne.alloc_subdivision_surface_uvs2(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ne.alloc_subdivision_surface_uvs(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ne.alloc_subdivision_surface2(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ne.alloc_subdivision_surface(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return Ne._free(y),S}static buildLevel(t,e,i,r,s,n=!1){let a=s?Ne.get_mesh_data2(t,e?Ne.Level.CONTROL:Ne.Level.REFINED,i,s.elements):Ne.get_mesh_data(t,e?Ne.Level.CONTROL:Ne.Level.REFINED,i),o=Ne.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),h=0,u=Ne.HEAPU32[o[h]>>2],d=Ne.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=Ne.HEAPU32[o[h]>>2],p=Ne.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let m=Ne.HEAPU32[o[h]>>2],f=Ne.HEAPU32.subarray(m>>2,(m>>2)+l[h]);h++;let g,y=Ne.HEAPU32[o[h]>>2],v=Ne.HEAPU32.subarray(y>>2,(y>>2)+l[h]);if(h++,Ne.alloc_subdivision_surface_uvs){let _=o[9];if(_>0){let x=Ne.HEAPU32[o[8]>>2];g=Ne.HEAPF32.subarray(x>>2,(x>>2)+_)}}if(r===void 0){let _=new ye;if(_.setIndex(new fm(v,1)),_.setAttribute("position",new ge(d,3)),_.setAttribute("normal",new ge(p,3)),g&&_.setAttribute("uv",new ge(g,2)),e){_.setAttribute("faceMap",new fm(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new _e(x,4))}return Ne.free_mesh_data(a),_.userData.type="SubdivGeometry",_}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,n){let _=r.getIndex();_!==null&&_.array.length===v.length&&(_.copyArray(v),_.needsUpdate=!0)}let b=r.getAttribute("uv");g&&b&&b.array.length===g.length&&(b.copyArray(g),b.needsUpdate=!0),Ne.free_mesh_data(a)}static freeSubdivPointer(t){Ne.free_bvh(t),Ne.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let r=Ne.get_wireframe_data_for_base_level(t),s=Ne.HEAPU32.subarray(r>>2,4+(r>>2)),n=s.subarray(2,4),a=0,o=Ne.HEAPU32[s[a]>>2],l=Ne.HEAPF32.subarray(o>>2,(o>>2)+n[a]);a++;let h=Ne.HEAPU32[s[a]>>2],u=Ne.HEAPU32.subarray(h>>2,(h>>2)+n[a]);if(e===void 0){let d=new ye;d.setAttribute("position",new ge(l,3));let c=new Float32Array(l.length);for(let p=0,m=l.length;p<m;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new _e(c,3)),d.setIndex(new fm(u,1)),Ne.free_wireframe_data_for_base_level(r),d}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Ne.free_wireframe_data_for_base_level(r)}static updateCollabMesh(t,e,i){let r=e===0;r||Ne.set_destination_refinement_level(t,e);let s=i?Ne.get_topological_data2(t,r?Ne.Level.CONTROL:Ne.Level.REFINED,i.elements):Ne.get_topological_data(t,r?Ne.Level.CONTROL:Ne.Level.REFINED),n=Ne.HEAPU32.subarray(s>>2,8+(s>>2)),a=n.subarray(3,6),o=0,l=Ne.HEAPU32[n[o]>>2],h=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=Ne.HEAPU32[n[o]>>2],d=new Uint32Array(Ne.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let c,p=Ne.HEAPU32[n[o]>>2],m=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Ne.alloc_subdivision_surface_uvs){let f=n[7];if(f>0){let g=Ne.HEAPU32[n[6]>>2];c=new Float32Array(Ne.HEAPF32.subarray(g>>2,(g>>2)+f))}}return Ne.free_topological_data(s),{positions:h,indices:d,verticesPerFace:m,uvs:c}}},y_=new P,tA=new P,eA=new P,iA=new P}),syt=j(()=>{OK(),IK(),Y4(),NK(),J4(),WS(),JK(),tZ(),eZ(),Tj(),sZ(),t5(),nZ(),aZ(),oZ(),Mj(),lZ(),hZ(),uZ(),dZ(),Tm(),Ni(),OK(),IK(),Y4(),NK(),J4(),SCt(),WS(),JK(),tZ(),eZ(),Tj(),sZ(),t5(),nZ(),aZ(),oZ(),Mj(),lZ(),hZ(),uZ(),dZ(),Tm(),TCt(),R0t(),J0t(),sb(),fD(),cD(),rb(),Rj={ConeGeometry:d0t,CubeGeometry:c0t,CylinderGeometry:cW,DodecahedronGeometry:p0t,EllipseGeometry:pD,HelixGeometry:qgt,IcosahedronGeometry:L0t,LatheGeometry:F0t,NonParametricGeometry:j0t,PolygonGeometry:vW,PyramidGeometry:G0t,RectangleGeometry:mD,SphereGeometry:H0t,PlaneGeometry:$0t,BackdropGeometry:X0t,StarGeometry:bW,TextFrameGeometry:Y0t,TorusGeometry:K0t,TorusKnotGeometry:Z0t,TriangleGeometry:Q0t,VectorGeometry:Pm},nR=t=>{let e=Rj[t.type]??Ngt(t.type);if(e===void 0)throw new Error(`No geometry factory registered for "${t.type}" \u2014 was its feature compiled out of this runtime build?`);return e.create(t)}});function hm(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let h of a){let u=n;for(let d of h)u=u[d];for(s in u){let d=u[s];IU(d)&&!nyt.includes(s)&&(u[s]=e.getVariable(d,[r.uuid,"geometry",...h,s]),IU(u[s])&&(u[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let h=r.profileShape;h!==void 0&&(l.shapeData=h),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let h=ms.createFromState(n.shape,n.width,n.height);l.shape=h,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),l.geometry=new MG().parse(n),l.geometry.groups.length===0){let h=l.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let h=new ps(n,i);return h.data=t,h}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let h=Ngt(n.type);if(h)return h.create(n,e);On("text",`a ${n.type}`);let u=ms.createFromState(Vv.defaultData(),100,100);return nR({...n,shape:u,type:"VectorGeometry"})}if(n.type==="UIGeometry")return mD.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=nR(l)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${l}`);let u=ms.createFromState(Vv.defaultData(),100,100);l.shape=u,l.type="VectorGeometry",o=nR(l)}return o}var nyt,gD=j(()=>{Be(),ht(),syt(),Ni(),t5(),Em(),sb(),nyt=["font"]});function Dj(t){switch(typeof t){case"number":return Number.isFinite(t)?JSON.stringify(t):void 0;case"boolean":return JSON.stringify(t);case"string":return IU(t)?void 0:JSON.stringify(t);case"object":{if(t===null)return"null";if(Array.isArray(t)){let s="[";for(let n=0;n<t.length;n++){let a=Dj(t[n]);if(a===void 0)return;s+=(n>0?",":"")+a}return s+"]"}let e=t,i="{",r=!0;for(let s of Object.keys(e).sort()){if(e[s]===void 0)continue;let n=Dj(e[s]);if(n===void 0)return;i+=`${r?"":","}${JSON.stringify(s)}:${n}`,r=!1}return i+"}"}default:return}}var ayt,fZ,Oj,ACt=j(()=>{Be(),ayt=new Set(["CubeGeometry","SphereGeometry","CylinderGeometry","ConeGeometry","TorusGeometry","TorusKnotGeometry","IcosahedronGeometry","DodecahedronGeometry","PyramidGeometry","PlaneGeometry","BackdropGeometry","HelixGeometry"])}),CCt=j(()=>{gD(),ACt(),fZ=class{constructor(){this.objects=new Map,this.refs=new Map,this.sharedByKey=new WeakSet,this.unreachable=new Set}resolveObject(t,e,i){return this.createObject(t,e,i)}onObjectDisposed(t){}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,i){let r=this.objects.get(t);return r===void 0?(r=this.resolveObject(t,e,i),this.objects.set(t,r),this.retain(r)):(this.sharedByKey.add(r),r.isShared=!0),r}forceDelete(t){let e=this.objects.get(t);e&&(this.objects.delete(t),this.release(e))}adopt(t,e){this.replace(t,e),this.retain(e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.replace(e,i),i}replace(t,e){let i=this.objects.get(t);this.objects.set(t,e),i!==void 0&&i!==e&&this.release(i)}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){e===this.objects.get(t)&&this.unreachable.delete(t)}endGc(){this.unreachable.forEach(t=>{let e=this.objects.get(t);this.objects.delete(t),this.release(e)}),this.unreachable.clear()}dispose(){new Set(this.objects.values()).forEach(t=>{this.disposeObject(t),this.onObjectDisposed(t)}),this.objects.clear(),this.refs.clear()}retain(t){let e=(this.refs.get(t)??0)+1;this.refs.set(t,e),e>1&&(t.isShared=!0)}release(t){let e=(this.refs.get(t)??1)-1;if(e>0)return this.refs.set(t,e),void(e===1&&!this.sharedByKey.has(t)&&(t.isShared=!1));this.refs.delete(t),this.disposeObject(t),this.onObjectDisposed(t)}},Oj=class extends fZ{constructor(t){super(),this.flatShading=t,this.dedupeByValue=!1,this.byValue=new Map,this.valueKeyOf=new Map}disposeObject(t){t.dispose()}createObject(t,e,i){let r=hm(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}resolveObject(t,e,i){let r=this.dedupeByValue?function(n,a,o){if(!ayt.has(n.type))return;let l=n;if(l.shapeBlendNode!=null||o.isTransientGeometryKey(n))return;let h=a.material;if(h===void 0||Array.isArray(h))return;let u=h;if(typeof u.getLayersOfType!="function"||u.getLayersOfType("outline").length>0||u.getLayersOfType("cavity").length>0)return;let d=n.type;for(let c of Object.keys(l).sort()){let p=l[c];if(p===void 0||c==="type")continue;let m=Dj(p);if(m===void 0)return;d+=`|${c}=${m}`}return d}(t,i,e):void 0;if(r!==void 0){let n=this.byValue.get(r);if(n!==void 0)return n}let s=this.createObject(t,e,i);return r!==void 0&&(this.byValue.set(r,s),this.valueKeyOf.set(s,r)),s}mutateIfUnique(t,e){let i=super.mutateIfUnique(t,e);return i!==void 0&&this.forgetValue(i),i}onObjectDisposed(t){this.forgetValue(t)}forgetValue(t){let e=this.valueKeyOf.get(t);e!==void 0&&(this.valueKeyOf.delete(t),this.byValue.get(e)===t&&this.byValue.delete(e))}}});function e5(){return gT}function oyt(){if(gT==="webgpu"){if(Nj!==void 0)return Nj;Bj||(Bj=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(vZ===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return vZ}function lyt(t,e){return oyt().createRootMaterial(t,e)}function gZ(t,e,i){return oyt().createSharedMaterial(t,e,i)}function yZ(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function Ij(){return hyt}var gT,Nj,vZ,Bj,kj,hyt,uyt,Rm=j(()=>{gT="webgl",Bj=!1}),ECt=j(()=>{uyt={markNeedsUpdateRendererDirty:()=>{}}});function bZ(t){return t.data.type!=="displace"&&!!t.data.isMask}function um(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,a=Number(e.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?a/100:n.alphaOverride)<1)return!0}let s=t.layers;for(let n=0;n<s.length;n++){let a=s[n];if(!bZ(a)){if(n>0&&bZ(s[n-1])){if(a.data.type==="light"&&!a.data.visible)return!0;continue}if(a.data.type!=="displace"&&"alpha"in a.data&&a.data.type!=="light"&&a.data.type!=="fresnel"&&a.data.type!=="cavity"&&a.data.type!=="dust"&&a.data.type!=="texture"&&a.data.type!=="matcap"&&a.data.type!=="rainbow"&&a.data.type!=="outline"&&a.data.type!=="pattern"){let o=a.data.visible?a.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(e.getVariable(o)??100)/100))),o===1&&a.data.type==="depth"||a.data.type==="gradient"){for(let l of a.data.colors)if(l[3]<1){o=l[3];break}}else if(o===1&&a.data.type==="noise"){let l=e.color(a.data.colorA).a,h=e.color(a.data.colorB).a,u=e.color(a.data.colorC).a,d=e.color(a.data.colorD).a,c=Math.min(l,Math.min(h,Math.min(u,d)));c<1&&(o=c)}i+=(1-i)*o}}}return i<1}var yD=j(()=>{});function yv(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Lv,os,dyt,cyt,yT,pyt,_Z,xZ,Ja,nb=j(()=>{ht(),Lv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,os=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),dyt=(t,e)=>(t||(t=new P),t.x=os(t.x,e)??0,t.y=os(t.y,e)??0,t.z=os(t.z,e)??0,t),cyt=(t,e)=>(t||(t=new Z),t.x=os(t.x,e)??0,t.y=os(t.y,e)??0,t),yT={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},pyt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),ab=j(()=>{ht(),ib(),ts(),_Z=class extends hD(ur){},xZ=t=>t.type==="Mesh",Ja=class extends _Z{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];(!(i instanceof Ja)||i.object!==e)&&(i=new Ja(e),this._replaceChildAt(t,i),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.shearMatrix=e.shearMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(let i of this.object.children){if(!om(i)||i.object.parent!==this.object)continue;let r=this.children[t];r?.source!==i&&(r=i.createCopy(),this._replaceChildAt(t,r)),r.expand(),t+=1}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}_replaceChildAt(t,e){let i=this.children[t];i&&this.remove(i),this.add(e),this.children.splice(t,0,this.children.pop())}get visible(){let t=this.parent,e=om(t)&&t.object===this.object;return(!e||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||e&&this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return xZ(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(t){}}});function wZ(){return wW}var wW,SW,TW=j(()=>{wW=null,SW=null});function Vj(t){return"variable_"+t}var _N,xN,wN,SZ,SN,TZ,TN,MZ,i5,MW=j(()=>{Be(),tCt(),a0t(),o0t(),kc(),hW(),dW(),CCt(),Rm(),r0t(),ECt(),yD(),nb(),bo(),ab(),Ui(),ht(),TW(),Ni(),_N=new xt,xN=new P,wN=new Te,SZ=new P,SN=new Fi,TZ=class extends Jgt{constructor(t){super(),this.shared=t}create(t){return new lW(t,this.shared)}},TN=new Set,(i5=MZ=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new Oj(!0),this.geometryCache2=new Oj(!1),this.imageHolderCache=new TZ(this),this.thisContext={scene:uyt,shared:this},this.deletedImage=new Sg(D4.emptyImage,this),this.deletedVideo=new Sg(O4.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,e.images)for(let[s,n]of Object.entries(e.images))this.addImage(s,n);if(e.videos)for(let[s,n]of Object.entries(e.videos))this.addVideo(s,n);if(e.audios)for(let[s,n]of Object.entries(e.audios))this.addAudio(s,n);if(e.particles)for(let[s,n]of Object.entries(e.particles))this.addParticle(s,n);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=gZ(ls.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,i=!1){this.data=t,this.resetLib(t.lib);for(let{id:r,data:s}of t.variables)this.addVariableHolder(r,s),e&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(t.userAPIs??{}))this.addUserAPI(r,s);for(let[r,s]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(t.images))this.addImage(r,s);for(let[r,s]of Object.entries(t.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(t.colors))this.addColor(r,s);for(let[r,s]of Object.entries(t.lib.materials))this.addMaterial(r,s.asset);for(let[r,s]of Object.entries(t.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(t.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(t.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(t.fonts))this.addFont(r,s)}addMaterial(t,e){if(e=ls.withRepairedLayers(e),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=gZ(e,this.thisContext,t);this.materials[t]=i}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){return this.materials[t]}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):lyt(ls.withRepairedLayers(t),this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Sg(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Sg(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let i=t.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let s=r.root??r;for(let n of s?.data?.layers??[]){let a=n?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||e.layer!==void 0&&n.id!==e.layer&&a.type!==e.layer)continue;let o=a.texture?.image;if(o==null)continue;let l=(typeof o=="string"?this.uiBuffer(o):void 0)??this.image(o);if(!l)continue;let h=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),u=l.img;return{texture:h,width:u?.width??0,height:u?.height??0,layerId:n.id,layerType:a.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Sg(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):(this.colors[t]=new pj(e.r,e.g,e.b,"a"in e?e.a:1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[t];return this.colors[t].r=e.r??i.r,this.colors[t].g=e.g??i.g,this.colors[t].b=e.b??i.b,this.colors[t].a=e.a??i.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t!="string")return new Dr(t.r,t.g,t.b,"a"in t?t.a:1);{let i=this.getColor(t);i?e=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Dr(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Z1)return e;{let i=new Z1({src:e.data});return this.audios[t]=i,i}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Z1&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=uW;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):On("text","a font asset")}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._requestRender=void 0,Object.values(this.audios).forEach(t=>{t instanceof Z1&&t.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let i=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let r=localStorage.getItem(Vj(t));i=r!==null?JSON.parse(r):e.value}return this.variables[t]={value:i,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(Vj(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let o=a[1],l=i,h={scene:r,shared:this},u=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(u,l,h)});let d=this.materials[o];d&&d.onVariableUpdate(u,l,h)}else{let o=r.find(a[0]);if(o===void 0){this.variables[t].locations.splice(n,1);continue}if(s=!0,a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)o=o[a[l]];a[1]==="rotation"?o[a[a.length-1]]=i*Ft.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),xi.is(o))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")o.onVariableUpdate();else if(a[1]==="geometry"){let l=o;o.component&&(l=o.component);let h=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(h.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let d=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(d.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}isTransientGeometryKey(t){return this.transientGeometryKeys.has(t)}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||typeof s.type!="string"||s.type==="VectorGeometry"||s.type==="PathGeometry")return!1;let n=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let h of Object.keys(s))a.set(n(h),h);let o={};for(let[h,u]of Object.entries(e??{})){let d=a.get(n(h));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof u=="string"||typeof u=="number")&&(o[d]={textValue:String(u)});continue}let c=s[d];typeof u=="number"&&isFinite(u)&&(typeof c=="number"||typeof c=="string")&&(o[d]=u)}if(Object.keys(o).length===0)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||s.type!=="NonParametricGeometry")return!1;let n=e?.vertices;if(n===void 0||typeof n.length!="number"||n.length<9||n.length%3!=0||n.length/3>MZ.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,h=n instanceof Float32Array?n:Float32Array.from(n),u=h.length/3;if(e.normals!==void 0){if(e.normals.length!==h.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*u)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=u>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(x.length===0||x.length%3!=0)return!1;for(let S=0;S<x.length;S++)if(x[S]>=u)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=s.data,S=x?.index;if(S?.array?.length){let w=(x?.attributes?.position?.array?.length??0)/3;if(u!==w)return function(T,C){let M=`${T}/${C}`;TN.has(M)||(TN.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${C}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}(u,w),!1;l=S}}let d=1/0,c=1/0,p=1/0,m=-1/0,f=-1/0,g=-1/0;for(let x=0;x<h.length;x+=3){let S=h[x],w=h[x+1],T=h[x+2];S<d&&(d=S),S>m&&(m=S),w<c&&(c=w),w>f&&(f=w),T<p&&(p=T),T>g&&(g=T)}let y=(x,S)=>({array:x,itemSize:S,type:"Float32Array",normalized:!1}),v={position:y(h,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:f-c,depth:g-p,data:{attributes:v,...l?{index:l}:{}}},_=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,_),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let s=r.children,n=Math.PI/180,a=!1;if(e===null)for(let o of s)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return s.length;{let o=Math.min(e.length,s.length);for(let l=0;l<o;l++){let h=e[l],u=s[l];if(h==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,a=!0);continue}let d=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};h.position&&(typeof h.position.x=="number"&&(d.position[0]=h.position.x),typeof h.position.y=="number"&&(d.position[1]=h.position.y),typeof h.position.z=="number"&&(d.position[2]=h.position.z)),h.rotation&&(typeof h.rotation.x=="number"&&(d.rotation[0]=h.rotation.x*n),typeof h.rotation.y=="number"&&(d.rotation[1]=h.rotation.y*n),typeof h.rotation.z=="number"&&(d.rotation[2]=h.rotation.z*n)),h.scale&&(typeof h.scale.x=="number"&&(d.scale[0]=h.scale.x),typeof h.scale.y=="number"&&(d.scale[1]=h.scale.y),typeof h.scale.z=="number"&&(d.scale[2]=h.scale.z)),u.transformOverride=d,u.position.fromArray(d.position),u.rotation.fromArray(d.rotation),u.scale.fromArray(d.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}}return a?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let r=new Ja(t);r.playModeVisible=e.visible!==!1,r.expand(),typeof e.name=="string"&&(r.name=e.name);let s=Math.PI/180;return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.shearMatrix.copy(t.shearMatrix),e.position&&(typeof e.position.x=="number"&&(r.position.x=e.position.x),typeof e.position.y=="number"&&(r.position.y=e.position.y),typeof e.position.z=="number"&&(r.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(r.rotation.x=e.rotation.x*s),typeof e.rotation.y=="number"&&(r.rotation.y=e.rotation.y*s),typeof e.rotation.z=="number"&&(r.rotation.z=e.rotation.z*s)),e.scale&&(typeof e.scale.x=="number"&&(r.scale.x=e.scale.x),typeof e.scale.y=="number"&&(r.scale.y=e.scale.y),typeof e.scale.z=="number"&&(r.scale.z=e.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let r=[];for(let h of Array.isArray(i)?i:[i]){let u=h.root??h;u&&Array.isArray(u.layers)&&u.data&&!r.includes(u)&&r.push(u)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=h=>{if(typeof h=="string"){let u=new Dr(1,1,1,1);try{u.set(h)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(h&&typeof h=="object"&&"r"in h){let u=h;if([u.r,u.g,u.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*d,g:u.g*d,b:u.b*d,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},o=(h,u,d)=>{if(!h.hasValue(u))return!1;let c=h.getValue(u);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof pj?h.setValue(u,new Dr(d.r,d.g,d.b,p)):typeof c.setRGBA=="function"?c.setRGBA(d.r,d.g,d.b,p):c.setRGB(d.r,d.g,d.b),!0},l=!1;for(let h of r){let u=h.data.layers??[],d=c=>h.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=u.find(f=>f.data.type==="color"),m=p&&d(p.id);if(c&&m&&o(m,"color",c)&&(l=!0,c.a!==void 0)){let f=c.a<1||um(h.data,this);h.setTransparent?h.setTransparent(f,s.scene):h.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(h.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),s),l=!0);for(let c of e.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?u.find(y=>y.id===c.id):typeof c.index=="number"?u[c.index]:typeof c.type=="string"?u.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=yT[p.data.type]??[],g=Object.keys(p.data);for(let[y,v]of Object.entries(c)){if(y==="id"||y==="index"||y==="type")continue;let b=g.find(x=>x===y)??g.find(x=>n(x)===n(y))??y;if(f.includes(b))continue;let _=a(v);if(_&&o(m,b,_))l=!0;else if(typeof v=="number"&&isFinite(v))h.onVariableUpdate?.(["layer",p.id,b],v,s),l=!0;else if(Array.isArray(v)&&v.length<=3&&v.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];v.forEach((S,w)=>{h.onVariableUpdate?.(["layer",p.id,b,x[w]],S,s)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(t){this.variables[t]&&delete this.variables[t]}referencesMissingObject(t){return Array.isArray(t)&&t[0]!=="mouse"&&t[0]!=="raycast"&&this.entityOpContext.scene.find(t[0])===void 0}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let i=this.entityOpContext.scene.find(t[0]);if(i===void 0)return;if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return i.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&i?.getPhysicsLocalMatrix?.(_N))return _N.decompose(xN,wN,SZ),t[1]==="position"?xN[t[2]]:(SN.setFromQuaternion(wN,i.rotation.order),SN[t[2]]*Ft.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=Ft.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let r=this.variables[i],s=r.locations?.findIndex(n=>Dn.equal(n,e));s!==void 0&&s!==-1&&r.locations.splice(s,1)}if(typeof t=="string"){let i=t,r=t;do{if(r=i,this.variables[i]===void 0)break;let s=this.variables[i].value;e&&this.variables[r]!==void 0&&this.variables[r].locations.push(e),i=s}while(typeof i=="string");return i}return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,i]of Object.entries(t.images))this.addImage(e,i.asset);for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i.asset);for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i.asset);for(let[e,i]of Object.entries(t.colors))this.addColor(e,i.asset);for(let[e,i]of Object.entries(t.fonts))this.addFont(e,i.asset);for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i.asset);for(let[e,i]of Object.entries(t.variables))this.addVariableHolder(e,i.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,i){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ta.drop(t,2),e.materials[t.path[1]],{shared:this,scene:i});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,i):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let r=e.userAPIs[t.path[1]];if(r){let s=t.type===0&&t.props.debounce===void 0,n=this.getUserAPI(t.path[1]);n!==void 0&&n===this.openAIRealtime?n.update(r):n?.update(r,this,s)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let r=e.userWebhooks[t.path[1]];r&&this.getUserWebhook(t.path[1])?.update(r)}}else t.path[0]==="lib"&&this.updateLibByOp(ta.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let r=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let i=SW;return i===null?(On("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=wZ();return i===null?(On("api-services","a user API integration"),!1):(this.userAPIs[t]=i.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let i=wZ();return i===null?(On("api-services","a user webhook"),!1):(this.userWebhooks[t]=i.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new i5(Jl.emptyData())});function r5(t){return Ygt(t)||t?.isTSLNodeMaterial===!0}var vo,MN,AN,CN,AZ,EN,pd,CZ,EZ,v_,Ur,AW=j(()=>{e0t()}),d0=j(()=>{Be(),oa(),Rm(),AW(),Ui(),un(),vo=class extends Fs{setMaterialOverride(t,e){this.materialOverride=yZ(t),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),e.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(t,e,i){if(super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.syncShadowCatcher(i),function(r,s){let n=[];if(s.length!==r.length)return null;{let a=0;for(;a<r.length;){if(s[a]==="*")n.push(r[a]);else if(r[a]!==s[a])return null;a+=1}}return n}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(t.props)){let n=this.material[Number(r)],a=i.shared.material(s);a!==n&&vo.disposeOneMaterial(n),this.material[Number(r)]=a}else if(er(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(ta.drop(t,1),e.material,i)}else if(er(t.path,["materials","*"])&&Array.isArray(this.material)){let r=t.path[1];if("materials"in e&&r<this.material.length){let s=e.materials[r];typeof s!="string"&&this.material[r].updateByOp(ta.drop(t,2),s,i)}}}get needsAO(){return this.material!==void 0&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(t,e){super.updateState(t,e),t.castShadow!==void 0&&(this.castShadow=t.castShadow),t.receiveShadow!==void 0&&(this.receiveShadow=t.receiveShadow);let i,r=this.dataPatched;this.syncShapeBlendNodeLayer(),this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let s=this.materialOverride!==void 0;!s&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!s&&(t.geometry?.type==="NonParametricGeometry"||"materials"in t)&&("materials"in t&&t.materials!==void 0?(this.disposeMaterial(),this.material=t.materials.map(a=>e.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let n=this.data;if(!s&&n.geometry?.type!=="NonParametricGeometry"&&"materials"in n&&n.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(n.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(t.flatShading!==void 0||t.wireframe!==void 0||t.side!==void 0))if(Array.isArray(this.material))for(let a=0;a<this.material.length;a++)this.material[a]=this.material[a].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe,i);this.syncShadowCatcher(e)}shadowCatcherActive(){let t=this.dataPatched,e=t.geometry?.type;return t.shadowCatcher===!0&&(e==="RectangleGeometry"||e==="PlaneGeometry")}syncShadowCatcher(t){let e=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=gT==="webgpu"&&kj!==void 0?kj:void 0;return r===void 0?null:yZ(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=e.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,t.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.material=t.shared.material(e.material).getFlavor(e.flatShading,e.side,e.wireframe),t.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow)}static disposeOneMaterial(t){var e;r5(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&rft(this.material).forEach(t=>{vo.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),_o=j(()=>{Be(),Ui(),MW(),d0(),ht(),gD(),rb(),sb(),iyt(),MN=new P,AN=new Me,CN=new Me,AZ=new P,EN=new xt,pd=new yr,CZ=pd.geometry,EZ=pd.material,v_=new P,Ur=class extends vo{constructor(t,e,i){super(t,e),this.data=e,this.isSkinnedMesh=!1,this.localGeometry=void 0,e.bindMode&&e.bindMatrix&&(this.bindMode=e.bindMode,this.bindMatrix=new xt().fromArray(e.bindMatrix),this.bindMatrixInverse=new xt)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof ye&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof ye?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof i5){let t=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(t),i=this.dataPatched.geometry;this.geometryCreateDeleyed=e.get(i,t,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(t){this.localGeometry=t}get is2DAndNoDepth(){let t=this.dataPatched.geometry;return B4.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return B4.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.updateByPatchedOpGeometry(ta.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,Q4.delete(t),this._posed=void 0}get appliedGeometrySize(){let t=this.localGeometry?.userData;if(t!==void 0&&t.sxPrev!==void 0)return[t.sxPrev,t.syPrev,t.szPrev]}updateGeometryInteractions(t,e){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,s,n,a=t;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=hm(d,e,this.data.flatShading,this)}a.scaleBaked?[r,s,n]=a.scaleBaked:{width:r,height:s,depth:n}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,h=typeof s=="number"?s:1,u=typeof n=="number"?n:1;o.sxPrev!==void 0&&Ej(this.localGeometry.attributes,l/o.sxPrev,h/o.syPrev,u/o.szPrev),o.sxPrev=l,o.syPrev=h,o.szPrev=u}else if(!this.absorbDepthInteraction(t)){let r=hm(i==="VectorGeometry"?k4.merge(this.data.geometry,t):{...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&fN(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(t){let e=this.localGeometry;if(e?.shiftDepthTo===void 0)return!1;let i=t;if(typeof i.depth!="number")return!1;let r=e.userData?.parameters;if(r===void 0)return!1;for(let s of Object.keys(i))if(s!=="depth"&&i[s]!==r[s])return!1;return!!e.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(t){for(let e of this.attachedSurfaceCloners)e.update(t)}refreshAttachedCloners(t){for(let e of this.attachedSurfaceCloners)t.scene.addPendingUpdateCloner(e.object)}refreshAttachedPaths(t){for(let e of this.attachedPaths)t.scene.addPendingCommand(()=>e.updateShape())}createGeometryDelayed(t){this.geometryCreateDeleyed=t.shared,this.refreshAttachedCloners(t),this.refreshAttachedPaths(t)}updateByPatchedOpGeometry(t,e,i){let r=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof ps&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&ryt(t.props)&&this.geometryCreateDeleyed instanceof ps&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof ps)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=i.shared,n=this.chooseGeoemtryCache(s),a=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=hm(o,s,this.data.flatShading,this);fN(a,l)?(l.dispose(),a.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(t,e){this.createGeometryDelayed(e)}applyTransientGeometryData(t,e){let i=t.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof ps)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=this.chooseGeoemtryCache(i),n=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===n&&n.isShared!==!0){let a=hm(r,i,this.data.flatShading,this);return fN(n,a)?(a.dispose(),n.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(t),void this.refreshAttachedPaths(t)}}e&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),t.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(t)}updateState(t,e){t.geometry!==void 0&&this.updateGeometryOnStateUpdate(t.geometry,e);let i=t.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:s}}of i)this.updateMorphInfluences(r,e.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}super.updateState(t,e)}updateMorphInfluences(t,e){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[t];i!==void 0&&(this.morphTargetInfluences[i]=e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(t,e){let i=this.posedGeometry()?.boundingBox;if(i)return i.getCenter(t),void i.getSize(e).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*r.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?t.fromArray(r.centerOffset):t.setScalar(0),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(t,e){this.skeleton=t,this.isSkinnedMesh=!0,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(t){let e=new Me,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){e.fromBufferAttribute(i,r);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),i.setXYZW(r,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;AN.fromBufferAttribute(r.attributes.skinIndex,t),CN.fromBufferAttribute(r.attributes.skinWeight,t),MN.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=CN.getComponent(s);if(n!==0){let a=AN.getComponent(s);EN.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(AZ.copy(MN).applyMatrix4(EN),n)}}return e.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(t,e){let i=this.posedGeometry();if(i===void 0)return!1;pd.geometry=i,pd.material=this.material,pd.matrixWorld.copy(this.matrixWorld);let r=e.length;pd.raycast(t,e);for(let s=r;s<e.length;s++)e[s].object=this;return pd.geometry=CZ,pd.material=EZ,!0}posedGeometry(){let t=this.skeleton;if(!this.isSkinnedMesh||t===void 0)return;let e=this.geometry,{position:i,skinIndex:r,skinWeight:s}=e.attributes;if(!i||!r||!s)return;let n=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<t.bones.length;d++){let c=t.bones[d];if(!c||!t.boneInverses[d])return;n.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===e&&a.version===i.version&&a.pose.length===n.length&&a.pose.every((d,c)=>d===n[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,h=l?.count===o?l:new _e(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,v_)),h.setXYZ(d,v_.x,v_.y,v_.z);let u=new ye;u.setAttribute("position",h);for(let d of["normal","uv","uv1"]){let c=e.attributes[d];c&&u.setAttribute(d,c)}return u.setIndex(e.index),u.groups=e.groups,u.drawRange=e.drawRange,u.computeBoundingSphere(),u.computeBoundingBox(),this._posed={source:e,version:i.version,pose:n,geometry:u},u}}});function vv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!Ygt(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Ur&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,r=new Float32Array(i.length),s=new P;for(let n=0;n<i.length;n+=3)s.set(i[n],i[n+1],i[n+2]).normalize(),r[n]=s.x,r[n+1]=s.y,r[n+2]=s.z;e.geometry.setAttribute("extrudeNormal",new ge(r,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,r=e.geometry.attributes,s=r.position.array,n=r.normal.array,a=new Float32Array(s.length);for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,h=new P(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(h):i.set(l,{normals:[h],result:new P})}i.forEach((o,l)=>{for(let h of o.normals)o.result.add(h);o.result.divideScalar(o.normals.length)});for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,h=i.get(l)?.result;h&&(a[o]=h.x,a[o+1]=h.y,a[o+2]=h.z)}e.geometry.setAttribute("extrudeNormal",new ge(a,3))}(t)}function PN(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function bv(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,r=e.randomColor;if(r!==void 0&&3*r.count===i.length)return;let s=new Float32Array(i.length),n=parseInt(t.uuid.replace(/\D/g,"")),a=[PN(Ft.seededRandom(n)),PN(Ft.seededRandom(n+1e4)),PN(Ft.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new _e(s,3))}var vD=j(()=>{ht(),e0t(),_o()});function PZ(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function PCt(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function RZ(t,e,i,r){let s=16*(e.children.length+1);u2.length<s&&(u2=new Float32Array(s));let n=0,a=l=>{l.toArray(u2,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),zj.copy(t.matrix);for(let l of e.children)!lm(l)||l.playModeVisible===!1||(Lj.copy(l.matrix).multiply(l.pivotMatrix),aR.multiplyMatrices(zj,Lj),(!o||!aR.equals(r))&&a(aR));try{return n===0?0:function(l,h){return aW($4().instanced_union(nW(l),h))}(i,u2.subarray(0,16*n))}finally{Hgt(i)}}var md,DZ,zj,Lj,aR,u2,_m,vT=j(()=>{oa(),ht(),cD(),vD(),d0(),ts(),md=new xt,DZ=new xt,zj=new xt,Lj=new xt,aR=new xt,u2=new Float32Array(0),_m=class extends vo{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new ye,this.onAfterRender=(r,s,n,a,o,l)=>{super.onAfterRender(r,s,n,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&t.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(t,e=!0){if(this.booleanMeshSetAddress!==-1&&!t)return;for(let r=0;r<this.children.length;r++){let s=this.children[r];s instanceof _m&&s.dataPatched.visible===!0&&s.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let s=this.children[r];if(s instanceof Fs&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){md.copy(s.matrix).multiply(s.pivotMatrix);try{let n=PCt(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=Z3t(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:RZ(s,n,a,md)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&nN(s.booleanMeshSetAddress,md),s.booleanMatrixInvOld.copy(md).invert(),s.booleanWasTransformed=!1}else s instanceof _m&&s.needsTransformForDownstream===!0?(n===void 0?nN(s.booleanMeshSetAddress,md):s.booleanMeshSetAddress=RZ(s,n,s.booleanMeshSetAddress,md),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(nN(s.booleanMeshSetAddress,DZ.multiplyMatrices(md,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(md).invert(),s.booleanWasTransformed=!1)}catch(n){console.error(n),s.booleanMeshSetAddress=0,s.geometry.userData.booleanOperationDidFail=!0;continue}if(s.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let r=this.geometry;r.dispose(),this.geometry=new ye,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new ge([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=$4(),a=_K(r,s),o=n.mesh_topological_data(a),l=o.positions(),h=o.indices();return o.free(),a.free(),{positions:l,indices:h,verticesPerFace:new Uint8Array(h.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new ye,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=$4(),l=_K(r,s),h=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new ge(h.positions(),3)),n.setAttribute("normal",new ge(h.normals(),3)),h.free(),n.boundingSphere===null&&(n.boundingSphere=new Jn),l.tri_count()===0)n.boundingSphere.center.set(0,0,0),n.boundingSphere.radius=0,n.userData.parameters={width:0,height:0,depth:0};else{let u=l.bounds();n.boundingSphere.center.set(u[0],u[1],u[2]),n.boundingSphere.radius=(u[3]**2+u[4]**2+u[5]**2)**.5,n.userData.parameters={width:2*u[3],height:2*u[4],depth:2*u[5]}}return aW(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(r){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(r)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,vv(this),bv(this)}dispose(){super.dispose(),this.geometry.dispose()}}});function RCt(t){return t.isPointLight?oR.PointLight:t.isSpotLight?oR.SpotLight:oR.DirectionalLight}function OZ(t){return t.isDirectionalLight?0:t.isSpotLight?1:2}var oR,hS,mg,s5,bD,Hh,$u,n5,myt=j(()=>{oR={PointLight:1,SpotLight:3,DirectionalLight:3},hS=new WeakSet,mg=[]}),bT=j(()=>{ht(),myt(),bo(),u0(),(s5||(s5={})).is=function(t){return xi.is(t)&&t instanceof Xd},bD=(t,e)=>class extends h0(t,e){updateState_Light(i,r){if(this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let s=this.shadow;s.camera.far=i.depth,s.needsUpdate=!0}i.shadows!==void 0&&(function(s){hS.delete(s)}(this),this.castShadow=i.shadows)}}}),Dm=j(()=>{ht(),vT(),oa(),u0(),Hh=t=>t instanceof Fs,$u=t=>t!==null&&t instanceof _m,n5=t=>hj.is(t)});function wa(t,e){return e.color(t)}function IZ(t=new Date,e){let i=e.format,r=t.getSeconds(),s=t;e&&e.timeZone!==null&&(s=function(d,c){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(d),m=f=>Number(p.find(g=>g.type===f)?.value);return new Date(m("year"),m("month")-1,m("day"),m("hour"),m("minute"),m("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let n,a=s.getHours(),o=s.getMinutes();e.format12h24h==="12ampm"&&(n=a>=12?"PM":"AM");let l,h,u=a;switch(e.format12h24h!=="24"&&(u=a%12,u===0&&(u=12)),i){case"HH:mm:ss":l=[u,o,r];break;case"HH:mm":l=[u,o];break;case"HH":l=[u],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":h=s.getFullYear();break;case"month":h=s.getMonth()+1;break;case"dayOfYear":h=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":h=s.getDate();break;case"secondOfDay":h=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),h=0}return l!==void 0?{textValue:l,suffix:n}:h}var Fj,ob,CW=j(()=>{}),DCt=j(()=>{ht(),cT(),pT(),Fj=class extends Jv(Ymt){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){tb(this.object,Fj.geometryHelper,t,e)}}}),_D=j(()=>{ht(),DCt(),bT(),ob=class extends bD(NS,Fj){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new BS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof BS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&function(r,s){r.shadow.camera.right=s/2,r.shadow.camera.left=-s/2,r.shadow.camera.top=s/2,r.shadow.camera.bottom=-s/2,r.shadow.needsUpdate=!0}(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),i&&this.update()}}});function EW(t){return t instanceof vo&&t.needsAO&&!Ic(t)&&t.isDecalObject!==!0}function PW(t){let e=t.cloner;if(e&&Array.isArray(e.children))for(let i of e.children)i?.layers&&(i.layers.mask=t.layers.mask)}function RW(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function OCt(t){let e=1/0,i=-1/0;for(let r of t.getLayersOfType("reflection")){let s=r.data;if(!s.visible||s.mirror===1)continue;let n=typeof s.blur=="number"?s.blur:null;e=Math.min(e,n??0),i=Math.max(i,n??10)}return e===1/0?null:{min:e,max:i}}function ICt(t){for(let e of t.getLayersOfType("reflection")){let i=e.data;if(!i.visible)continue;let{blur:r,thickness:s,steps:n,stepSize:a}=i;return typeof r!="number"||typeof s!="number"||typeof n!="number"||typeof a!="number"?"variable":{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function NZ(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&xD,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=RW(e),o=e.getLayersOfType("cavity");return(n.length>0||o.length>0)&&(t.layers.set(8),s.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=n.length>0,i.cavity=o.length>0,bv(t),vv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&EW(t)&&t.layers.enable(5),PW(t),i}function BZ(t,e){if(!e.layers)return!1;let i=t.layers.mask&xD,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=RW(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return s.length>0&&(t.layers.set(3),(n.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),r=!0),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&EW(t)&&t.layers.enable(5),PW(t),r}function kZ(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&xD,s=!1,n=RW(e),a=e.getLayersOfType("transmission").filter(h=>h.data.visible),o=e.getLayersOfType("outline").filter(h=>h.data.visible),l=e.getLayersOfType("cavity").filter(h=>h.data.visible);return n>0&&((i=t.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),t.layers.set(4),a.length>0&&t.layers.enable(3),(o.length>0||l.length>0)&&t.layers.enable(8),s=!0),n===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),r&&t.layers.set(9),!r&&EW(t)&&t.layers.enable(5),PW(t),s}function Uj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if((t.raycast===yr.prototype.raycast||t.raycast===Fs.prototype.raycast)&&t.isSkinnedMesh!==!0){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&(jj.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(jj)))continue;let o=gyt.copy(a.matrixWorld).invert(),l=yyt.copy(e.ray).applyMatrix4(o),h=t.matrixWorld;l.applyMatrix4(h);let u=fyt;u.set(l.origin,l.direction),u.near=e.near,u.far=e.far,u.layers.mask=e.layers.mask;let d=u.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var xD,fyt,gyt,yyt,jj,rA,vyt,RN,DN,ON,lb,Or,DW=j(()=>{ts(),vD(),oa(),d0(),ht(),xD=512,fyt=new Y5,gyt=new xt,yyt=new gc,jj=new Jn}),NCt=j(()=>{ht(),cT(),pT(),rA=class extends Jv($mt){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){tb(this.object,rA.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=rA._vector,e=this.object.distance?this.object.distance:1e3,i=e*Math.tan(this.object.angle);this.cone.scale.set(i,i,e),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},(vyt=rA)._vector=new P}),wD=j(()=>{ht(),NCt(),bT(),RN=new P,DN=new P,ON=new Te,lb=class extends bD(Wg,vyt){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=2*Ft.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new BS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof BS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),DN.setFromMatrixPosition(this.matrixWorld),ON.setFromRotationMatrix(this.matrixWorld),RN.copy(this.up).applyQuaternion(ON).negate().multiplyScalar(this.distance),this.target.position.copy(DN).add(RN),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),sh=j(()=>{Be(),Qh(),ht(),bo(),kc(),CW(),nD(),_D(),Ui(),Rm(),ht(),d0(),Dm(),DW(),wD(),Ni(),vT(),Or=class extends uD(Ku){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new j8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ea.getDensity({}),this.fogHeightFalloff=ea.getHeightFalloff({}),this.fogHeightBase=ea.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ae,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new Us(l0,{...rS.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new X5(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),e.uiScene){let r=rj();r===null?On("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(t)?t[0]:t)+"-ui",e.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else e.uiFrame&&this.createUICanvas(e.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(t,e){let i=rj();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,e),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(t),this.uiCanvas?.applySize()})):On("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(t,e){t.color!==void 0&&(this.ambientLight.color=wa(t.color,e)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity*Math.PI),t.enabled!==void 0&&(t.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(t){this.isActive=!0,t.fog=this.fog,this.traverseEntity(e=>{e instanceof _m&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof vo)if(Array.isArray(t.material))for(let e of t.material)e.needsUpdate=!0;else t.material.needsUpdate=!0,t.material.dispose()})}updateShadow(t){if(t.softShadowQuality===void 0&&t.type===void 0||!this.isActive)return;let e=this.data.shadow;pv.isSoft(e)}updateFog(t,e){t.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=wa(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ea.getMode(t),this.fogDensity=ea.getDensity(t),this.fogHeightFalloff=ea.getHeightFalloff(t),this.fogHeightBase=ea.getHeightBase(t)}updateSky(t,e){this.skyState=t??null,this.skyStateVersion++;let i=t?.hdri?.image;this.skyHdriHolder=i!=null?e.image(i):null}updateAo(t,e){t.aoColor!==void 0&&(this.aoColor=wa(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;er(t.path,["fog"])?this.updateFog(n.fog,i.shared):er(t.path,["sky"])?this.updateSky(n.sky,i.shared):er(t.path,["grading"])?this.gradingState=n.grading??null:er(t.path,["ao"])?this.updateAo(n.ao,i.shared):er(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):er(t.path,["shadow"])?this.updateShadow(n.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||s!==n.uiFrame)&&this.updateUIFrame(t.props.uiFrame,i)}updateUIFrame(t,e){t?(this.uiCanvas||this.createUICanvas(t,e),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(t)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(t,e){this.updateState_Entity(t,e),t.backgroundColor!==void 0&&this.setBackgroundColor(wa(t.backgroundColor,e.shared)),t.fog!==void 0&&this.updateFog(t.fog,e.shared),t.sky!==void 0&&this.updateSky(t.sky,e.shared),t.grading!==void 0&&(this.gradingState=t.grading),t.ambient!==void 0&&this.updateAmbientLight(t.ambient,e.shared),t.ao!==void 0&&this.updateAo(t.ao,e.shared),t.shadow!==void 0&&this.updateShadow(t.shadow)}createFrame(t,e){}raycast(t,e){super.raycast(t,e)}switchActiveCamera(t){t instanceof Us&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){let t=this.scene?.find(this.data.publish.playCamera);return t instanceof Us?t:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(tj).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof ob&&i.visible&&t<JP&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof lb&&i.visible&&t<tj-JP&&(this.penumbraSizeArrayCache[JP+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;xi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||n5(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),Uj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function VZ(){return OW}function IN(){if(Gj===null)throw new Error('[spe] Classic (WebGL) particles are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return Gj}function NN(t){return t?.isWebGPUSplineRenderer===!0}var OW,Gj,byt=j(()=>{OW=null,Gj=null});function Wj(){return NW}var IW,NW,BW=j(()=>{IW=null,NW=null});function zZ(t,e,i){return d2.setRGB(t,e,i,ks),{r:d2.r,g:d2.g,b:d2.b}}function BCt(t,e,i){let r,s=XS(t.angle,0),[n,a]=qj(t.offset),[o,l]=qj(t.morph),h=t.colors??[],u=t.steps??[],d=Math.min(10,h.length,u.length);if(d===0)return[1,1,1,1];if(t.gradientType===1){let g=3*(e+o)-(e+n)-1,y=3*(i+l)-(i+a)-1;r=Math.hypot(g,y)+s}else if(t.gradientType===2){let g=-1*Math.atan2(e+o-.5+n,i+l-.5+a),y=s/Math.PI/-2+.5*g/Math.PI;r=y-Math.floor(y)}else{let g=.5+o/(e!==0?e:1e-6),y=l/(i!==0?i:1e-6),v=Math.cos(s)*g-Math.sin(s)*y,b=Math.sin(s)*g+Math.cos(s)*y,_=v*v+b*b;r=_>1e-12?(((e-.5+n)/2+v/2)*v+((i-.5+a)/2+b/2)*b)/_:0}let c=h[0][0],p=h[0][1],m=h[0][2],f=h[0][3];for(let g=1;g<d;g++){let y=u[g-1],v=u[g]-y,b=v!==0?Math.min(1,Math.max(0,(r-y)/v)):r>=y?1:0;t.smooth&&(b=b*b*(3-2*b)),c+=(h[g][0]-c)*b,p+=(h[g][1]-p)*b,m+=(h[g][2]-m)*b,f+=(h[g][3]-f)*b}return[c,p,m,f]}function kCt(t,e){let i=t,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let s=e,n=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=XS(o.alpha,1);if(!(l<=0))if(o.type==="color"){let h,u=o.color;typeof u=="string"?h=typeof s?.color=="function"?s.color(u):void 0:u&&typeof u.r=="number"&&(h=u),h&&n.push({kind:"color",layer:o,rgb:{...zZ(h.r,h.g,h.b),a:h.a??1},alpha:l})}else o.type==="gradient"&&n.push({kind:"gradient",layer:o,alpha:l})}),n.length===0?null:(a,o)=>{let l=1,h=1,u=1,d=!0;for(let c of n){let p,m,f,g;if(c.kind==="color")({r:p,g:m,b:f}=c.rgb),g=c.rgb.a;else{let[v,b,_,x]=BCt(c.layer,a,o);({r:p,g:m,b:f}=zZ(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,h+=(m-h)*y,u+=(f-u)*y,d=!1}return{r:l,g:h,b:u}}}if(i?.color&&i.color.isColor===!0){let{r:s,g:n,b:a}=i.color;return()=>({r:s,g:n,b:a})}return null}var d2,XS,qj,VCt=j(()=>{ht(),d2=new ae,XS=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,qj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function zCt(t,e){if(t==="torus"){let l=e()*Math.PI*2,h=e()*Math.PI*2,u=Math.cos(l),d=Math.sin(l),c=Math.cos(h),p=Math.sin(h);return{x:(1.4+.7*c)*u,y:-(1.4+.7*c)*d,z:.7*p,nx:c*u,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,h=Math.cos(l),u=Math.sin(l);return{x:.8*h,y:1.6*(e()-.5),z:.8*u,nx:h,ny:0,nz:u,cr:1,cg:1,cb:1}}let i=e()*Math.PI*2,r=2*e()-1,s=Math.acos(r),n=Math.sin(s)*Math.cos(i),a=Math.cos(s),o=Math.sin(s)*Math.sin(i);return{x:n,y:a,z:o,nx:n,ny:a,nz:o,cr:1,cg:1,cb:1}}function LCt(t){let{geometry:e,matrix:i}=t,r=e.getAttribute("position");if(!r||r.count<3)return null;let s=e.getAttribute("normal"),n=e.getAttribute("uv"),a=e.getAttribute("color"),o=e.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let h=(y,v)=>o?o.getX(3*y+v):3*y+v,u=i?i.elements:null,d=i?new As().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[0]*v+u[4]*b+u[8]*_+u[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[1]*v+u[5]*b+u[9]*_+u[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[2]*v+u[6]*b+u[10]*_+u[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=h(y,0),b=h(y,1),_=h(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,C=p(b)-S,M=m(b)-w,A=c(_)-x,R=p(_)-S,I=m(_)-w,O=C*I-M*R,B=M*A-T*I,V=T*R-C*A;g+=.5*Math.sqrt(O*O+B*B+V*V),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let X=b+_>>1;f[X]<y?b=X+1:_=X}let x=b,S=h(x,0),w=h(x,1),T=h(x,2),C=v(),M=v();C+M>1&&(C=1-C,M=1-M);let A,R,I,O=1-C-M,B=c(S)*O+c(w)*C+c(T)*M,V=p(S)*O+p(w)*C+p(T)*M,z=m(S)*O+m(w)*C+m(T)*M;if(s){if(A=s.getX(S)*O+s.getX(w)*C+s.getX(T)*M,R=s.getY(S)*O+s.getY(w)*C+s.getY(T)*M,I=s.getZ(S)*O+s.getZ(w)*C+s.getZ(T)*M,d){let X=d[0]*A+d[3]*R+d[6]*I,nt=d[1]*A+d[4]*R+d[7]*I,st=d[2]*A+d[5]*R+d[8]*I;A=X,R=nt,I=st}}else{let X=c(S),nt=p(S),st=m(S),yt=c(w)-X,pt=p(w)-nt,Q=m(w)-st,ut=c(T)-X,wt=p(T)-nt,St=m(T)-st;A=pt*St-Q*wt,R=Q*ut-yt*St,I=yt*wt-pt*ut}let k=Math.sqrt(A*A+R*R+I*I)||1,L=1,H=1,W=1;if(a)L=a.getX(S)*O+a.getX(w)*C+a.getX(T)*M,H=a.getY(S)*O+a.getY(w)*C+a.getY(T)*M,W=a.getZ(S)*O+a.getZ(w)*C+a.getZ(T)*M;else if(t.sampleColor){let X=n?n.getX(S)*O+n.getX(w)*C+n.getX(T)*M:.5,nt=n?n.getY(S)*O+n.getY(w)*C+n.getY(T)*M:.5,st=t.sampleColor(X,nt);st&&(L=st.r,H=st.g,W=st.b)}return{x:B,y:V,z,nx:A/k,ny:R/k,nz:I/k,cr:L,cg:H,cb:W}}}}function LZ(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),_v),i=function(l){let h=l>>>0;return()=>{h|=0,h=h+1831565813|0;let u=Math.imul(h^h>>>15,1|h);return u=u+Math.imul(u^u>>>7,61|u)^u,((u^u>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Fh:Fh,n=new Float32Array(4*sc),a=new Float32Array(sc),o=new Float32Array(4*_v).fill(1);for(let l=0;l<e;l++){let h=r?t.sampler(i):zCt(t.shape,i),u=r?h.x:h.x*s,d=r?h.y:h.y*s,c=r?h.z:h.z*s,{nx:p,ny:m,nz:f}=h;o[4*l+0]=h.cr,o[4*l+1]=h.cg,o[4*l+2]=h.cb;let g,y,v,b=l*Tg,_=(1.8+.8*i())*t.hairLength*s/(Tg-1),x=.5+1.5*i(),S=(.02+.06*i())*s;Math.abs(m)<.99?(g=-f,y=0,v=p):(g=1,y=0,v=0);let w=Math.sqrt(g*g+y*y+v*v)||1;for(let T=0;T<Tg;T++){let C=T/(Tg-1),M=C*C*.4*s,A=S*Math.sin(C*x*Math.PI*2),R=4*(b+T);n[R+0]=u+p*_*T+A*g/w,n[R+1]=d+m*_*T-M+A*y/w,n[R+2]=c+f*_*T+A*v/w,n[R+3]=T===0?0:1,T<Tg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var Tg,_v,sc,Fh,Hp,b_,X0,cf,Y0,lR,_yt=j(()=>{ht(),sc=(_v=16384)*(Tg=32),Fh=100}),xyt=j(()=>{ht(),oa(),BW(),VCt(),_yt(),Hp=1/60,b_=new xt,X0=new Te,cf=new P,Y0=new P,lR=class extends Fs{constructor(t,e,i){super(t,e),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.settledSimSeconds=0,this.lastMotionFingerprint=0,this.lastBoneQuat=new Te,this.lastBonePos=new P,this.hasLastBone=!1,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=i,this.data=e,this.geometry.setAttribute("position",new _e(new Float32Array(0),3)),this.material=new jo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new yr(new Ec(Fh,48,32),new jo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new g4;r.setAttribute("position",new _e(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new yr(r,new jo({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=e.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:e.guideStrands,hairLength:e.hairLength,spreadRadius:e.spreadRadius,headShape:e.headShape,baseObjectId:e.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(t){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+t/1e3,4*Hp*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(X0,cf);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(X0))<.9999995||this.lastBonePos.distanceToSquared(cf)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(X0),this.lastBonePos.copy(cf),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+t}motionFingerprint(){let t=this.data;return t.gravity+2*t.damping+3*t.localStiffness+4*t.globalStiffness+5*t.globalRange+6*t.stiffnessFalloff+7*t.windStrength+8*t.vspCoefficient+9*t.kink+10*t.kinkFrequency+11*t.clumpStrength+12*t.clumpSize+13*t.clumpTipScale}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>6}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(t){this.playModeActive=t,t&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(t,e){super.updateState(t,e),this.updateHairState(t)}updateHairState(t){if((t.guideStrands!==void 0||t.hairLength!==void 0||t.spreadRadius!==void 0||t.headShape!==void 0||t.baseObjectId!==void 0)&&this.regenerate(),(t.headShape!==void 0||t.baseObjectId!==void 0)&&this.applyScalpState(),t.headColor!==void 0){let e=this.scalpMesh.material;e.isMeshBasicMaterial===!0&&e.color.setRGB(t.headColor.r,t.headColor.g,t.headColor.b,ks)}(t.castShadow!==void 0||t.receiveShadow!==void 0)&&this.applyShadowState(),t.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let t=this.data.castShadow??!0,e=this.data.receiveShadow??!0;this.castShadow=t,this.receiveShadow=e,this.scalpMesh.castShadow=t,this.scalpMesh.receiveShadow=e,this.ribbonMesh.castShadow=t,this.ribbonMesh.receiveShadow=e}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let t=this.data,e=this.regenSnapshot;if(e===null||e.guideStrands!==t.guideStrands||e.hairLength!==t.hairLength||e.spreadRadius!==t.spreadRadius||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId){let i=e===null||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:t,baseObjectId:e,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,t==="object"&&e){let s=this.context.scene.find(e);if(s){this.baseFoundAtRegen=!0,s.updateWorldMatrix(!0,!0);let n=this.collectBaseSources(s),a=n?function(o){let l=[];for(let d of o){let c=LCt(d);c&&l.push(c)}if(l.length===0)return null;let h=new Float64Array(l.length),u=0;for(let d=0;d<l.length;d++)u+=l[d].total,h[d]=u;return u<=0?null:d=>{let c=d()*u,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;h[g]<c?p=g+1:m=g}let f=p===0?c:c-h[p-1];return l[p].sample(f,d)}}(n.sources):null;if(this.baseSourceGeomsAtRegen=n?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=n?.hashes??[],this.baseColorHashAtRegen=n?.colorHash??0,n&&a){let o=this.baseWorldScale(s),l=Math.max(n.radius*o,.001);this.baseScaleAtRegen=o;let h=o;return LZ({shape:"object",guideStrands:i,hairLength:r,sampler:u=>{let d=a(u);return{...d,x:d.x*h,y:d.y*h,z:d.z*h}},samplerRadius:l})}}}return LZ({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;b_.copy(t.matrixWorld).invert();let n=b_.clone(),a=o=>{if(o.isHairSystem===!0||o!==t&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let h=o===t?void 0:new xt().multiplyMatrices(n,o.matrixWorld),u=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:h,sampleColor:kCt(u,this.context.shared)??void 0}),i.push(lR.matrixHash(h)),s+=function(c,p){let m=c,f=0,g=1,y=b=>{f+=b*g,g+=1},v=m?.data?.layers;if(v&&typeof v.forEach=="function"){let b=p;v.forEach(_=>{let x=_.data;if(x.visible!==!1){if(x.type==="color"){let S=x.color,w=typeof S=="string"?typeof b?.color=="function"?b.color(S):void 0:S;w&&typeof w.r=="number"&&(y(w.r),y(w.g),y(w.b)),y(XS(x.alpha,1))}else if(x.type==="gradient"){let S=x;for(let w of S.colors??[])y(w[0]),y(w[1]),y(w[2]),y(w[3]);for(let w of S.steps??[])y(w);y(XS(S.angle,0)),y(S.gradientType),y(S.smooth?1:0)}}})}else m?.color&&m.color.isColor===!0&&(y(m.color.r),y(m.color.g),y(m.color.b));return f}(u,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;h?(cf.copy(d.center).applyMatrix4(h),c=cf.length(),p=lR.matrixMaxScale(h)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let h of o.children)a(h)};return a(t),e.length===0?null:{sources:e,hashes:i,radius:Math.max(r,.001),colorHash:s}}static matrixHash(t){if(!t)return 0;let e=t.elements,i=0;for(let r=0;r<16;r++)i+=e[r]*(r+1);return i}static matrixMaxScale(t){let e=t.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);return Math.max(i,r,s,1e-6)}baseWorldScale(t){return b_.copy(t.matrixWorld).decompose(cf,X0,Y0),Math.max(Math.abs(Y0.x),Math.abs(Y0.y),Math.abs(Y0.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let t=this.context.scene.find(this.data.baseObjectId);if(!t)return;if(!this.baseFoundAtRegen)return void this.regenerate();t.updateWorldMatrix(!0,!0);let e=this.collectBaseSources(t),i=e?.sources??[],r=e?.hashes??[],s=this.baseSourceGeomsAtRegen,n=this.baseSourceHashesAtRegen,a=i.length!==s.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==s[o]||Math.abs(r[o]-n[o])>1e-4*Math.max(Math.abs(n[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(e?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(t);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let t=this.data.headShape,e=t==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!e,!e&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=t==="torus"?new f4(1.4*Fh,.7*Fh,24,48):t==="cylinder"?new K2(.8*Fh,.8*Fh,1.6*Fh,48,1):new Ec(Fh,48,32))}boneTransform(t,e){let i=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let r=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;r&&(i=r)}b_.copy(i).decompose(e,t,Y0)}raycast(t,e){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(t,i);for(let r of i)r.object=this,e.push(r)}get shadowBoundsRadius(){let t=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(t+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(t){return this.boneTransform(X0,t),t}updateEntityBoxSize(t,e){let i=this.shadowBoundsRadius;t.set(0,0,0),e.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),Wj()?.release(this)}}});function hR(){return{shapeInput:()=>`
367
+ `&&A.push("")):w.getTextWidth(A[A.length-1]+R,S)>M&&(A[A.length-1].length&&A.push(""),w.getTextWidth(A[A.length-1]+R,S)>M&&(R.length===1?(A[A.length-1]+=R,R=""):(A[A.length-1]+=R.slice(0,-1),R=R[R.length-1],A.push(""))));return A[A.length-1]+=R,A}(t,i,h===2?c.toUpperCase():h===3?c.toLowerCase():c,e),{shapes:m,charWidths:f,charCoords:g}=i.generateShapes(p,t,e),y=.5*(typeof r=="number"?r:Number(e.getVariable(r))),v=.5*(typeof s=="number"?s:Number(e.getVariable(s))),b=m.map(S=>new ms().fromShape(S,!0));this.vectorShapes=b;let _=b.map(S=>Pm.create({shape:S,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:u,extrusionVersion:d,windingRule:n<=0?as.NONZERO:as.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),x=_.length?Ig(_):cZ();x.translate(-y,v,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([S,w])=>{this.setAttribute(S,w)}),this.setIndex(x.index),this.adoptNearSide(_,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,h=l._nearSide;if(h===void 0||h.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=h.length,r=Math.max(r,l._effectiveBevel??0),s=l._vScale??s}this._effectiveBevel=r,this._vScale=s;let n=new Uint8Array(i),a=0;for(let o of t){let l=o._nearSide;n.set(l,a),a+=l.length}this._nearSide=n}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length===this.getAttribute("position")?.count&&Q1(this._effectiveBevel,t)&&Q1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position"),r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=e,h===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=$a(new ye,Aj.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([e,i])=>{this.setAttribute(e,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t,e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:t}},e)}get text(){return this.userData.parameters.text??""}}});function MCt(t){if(!Cj)return mZ||(mZ=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.123/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});tyt(a),Cj=!0}())}var tyt,_W,Cj,mZ,fD=j(()=>{_W=new Promise(t=>{tyt=t}),Cj=!1});function fN(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),r=Object.keys(e.attributes);if(i.length!==r.length)return!1;for(let l of r){let h=t.attributes[l],u=e.attributes[l];if(h===void 0||h.isInterleavedBufferAttribute===!0||u.isInterleavedBufferAttribute===!0||h.itemSize!==u.itemSize||h.normalized!==u.normalized||h.array.constructor!==u.array.constructor||h.array.length!==u.array.length)return!1}let s=t.index,n=e.index;if(s===null!=(n===null))return!1;let a=!1;if(s!==null&&n!==null){if(s.array.length!==n.array.length)return!1;let l=s.array.constructor,h=n.array.constructor;if(l!==h){if(l!==Uint32Array||h!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let h=t.groups[l],u=e.groups[l];if(h.start!==u.start||h.count!==u.count||h.materialIndex!==u.materialIndex)return!1}for(let l of r){let h=t.attributes[l],u=e.attributes[l];h.array.set(u.array),h.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,h=n.array;for(let u=0,d=h.length;u<d;u++){let c=h[u];l[u]=c===65535?4294967295:c}}else s.array.set(n.array);s.needsUpdate=!0}return t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t.boundingBox=null,t.boundingSphere=null,!0}function Ej(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,h=eyt.makeScale(e,i,r).invert().elements;for(let u=0,d=o.length;u<d;u+=3)o[u]*=e,o[u+1]*=i,o[u+2]*=r,s=l[u],n=l[u+1],a=l[u+2],l[u]=h[0]*s+h[4]*n+h[8]*a,l[u+1]=h[1]*s+h[5]*n+h[9]*a,l[u+2]=h[2]*s+h[6]*n+h[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var eyt,iyt=j(()=>{ht(),eyt=new xt});function Pj(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function JM(t){if(t!=null){if(Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView))return t;if(typeof t=="object")return function(e){let i=Object.keys(e),r=0;for(let n of i){let a=Pj(n);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let s=new Array(r);for(let n=0;n<r;n++){let a=e[n];if(typeof a!="number")return;s[n]=a}return s}(t)}}function gN(t){if(t==null)return"missing";if(Array.isArray(t))return`Array(${t.length})`;if(ArrayBuffer.isView(t)){let l=t;return`${t.constructor.name}(${l.length})`}if(typeof t!="object")return typeof t;let e=Object.keys(t),i=e.filter(l=>Pj(l)===-1),r=0;for(let l of e){let h=Pj(l);h>=r&&(r=h+1)}let s=t,n=-1,a=-1;for(let l=0;l<r;l++)l in s?typeof s[l]!="number"&&a===-1&&(a=l):n===-1&&(n=l);let o=[`${e.length} keys`,"max index "+(r-1)];return n!==-1&&o.push(`first missing index ${n}`),a!==-1&&o.push(`non-number at ${a} (${typeof s[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function ryt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function xW(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let u=0;u<i;u++){let d=e?e.getX(u):u,c=t.getX(d),p=t.getY(d),m=t.getZ(d),f=Math.round(c*s),g=Math.round(p*s),y=Math.round(m*s),v=n.get(f);v===void 0&&(v=new Map,n.set(f,v));let b=v.get(g);b===void 0&&(b=new Map,v.set(g,b));let _=b.get(y);_===void 0&&(_=r++,b.set(y,_),o.push(c,p,m)),a[u]=_}let l=[],h=[];for(let u=0;u<a.length;u+=3)a[u]===a[u+1]||a[u]===a[u+2]||a[u+1]===a[u+2]||(l.push(a[u],a[u+1],a[u+2]),h.push(e?e.getX(u):u,e?e.getX(u+1):u+1,e?e.getX(u+2):u+2));return{positions:o,triIndices:l,triOriginals:h}}var g_,df,Ne,yN,vN,bN,ps,y_,tA,eA,iA,Rj,nR,sb=j(()=>{ht(),fD(),Be(),gD(),iyt(),WS(),g_=new cr,df=new P,_W.then(t=>{Ne=t}),yN=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),vN=new Uint32Array([0,1,2,3]),bN=new Uint8Array([4]),ps=class extends ye{constructor(t,e){super(),this.data=t,this.flatShading=e,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,e){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=ym.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&Ej(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Ej(this.originalGeometry.attributes,...r),this.data=t;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(df.fromArray(r));let n=df.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(t){this.freeSubdivPointer(),this.data=t;let e=t.phongAngle??35;this.flatShading&&(e=-1);let i=null;if(t.subdivisions>0){let s=0;try{s=ps.allocate(t),i=ps.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&ps.freeSubdivPointer(s)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=ps.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Zh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ps.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Jn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;g_.setFromBufferAttribute(e),g_.getCenter(i),t.boundingSphere.radius=i.distanceTo(g_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),g_.getSize(df);let r={width:df.x,height:df.y,depth:df.z};return this.userData.parameters=r,r}static build(t,e,i,r){let s,n,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Ne.free_bvh(e),Ne.free_subdivision_surface(e));try{s=ps.allocate(t,r)}catch(l){console.error(l,t),s=ps.allocate({positionWASM:yN,indexWASM:vN,verticesPerFaceWASM:bN},r)}Ne.set_destination_refinement_level(s,0);let o=ps.buildLevel(s,!0,a);return n=t.subdivisions>0?ps.buildRefined(s,t.subdivisions,a):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:n}}static buildRefined(t,e,i){try{return Ne.set_destination_refinement_level(t,e),ps.buildLevel(t,!1,i)??null}catch{try{return Ne.set_destination_refinement_level(t,e-1),ps.buildLevel(t,!1,i)??null}catch{return null}}}static primitiveToQuads(t,e,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let r,s=t.shape!==void 0||t.path!==void 0?e.geometry:hm(t,i,!1,e);r=Wgt(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=xW(s.getAttribute("position"),r);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let c=t.radialSegments*t.heightSegments*3*2;n=[c,c+3*t.radialSegments]}let{indices:h,verticesPerFace:u,uvs:d}=function(c,p,m,f,g){let y=[],v=[],b=g?m.getAttribute("uv"):void 0,_=b&&b.itemSize===2?[]:void 0,x=T=>{if(_){let C=g[T];_.push(b.getX(C),b.getY(C))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),C=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&C<=24&&C%4==0&&m.userData.parameters.angle>=360){let R=T.length/2/C;T=T.filter((I,O)=>Math.floor(O/2)%R===0)}let M=0;for(let R=0;R<T.length;R+=2)M+=(T[R]-T[(R===0?T.length:R)-2])*(T[R+1]+T[(R===0?T.length:R)-1]);c.length=0;let A=0;if(M<0)for(let R=0;R<T.length;R+=2)c.push(T[R],T[R+1],0),y.push(A++);else for(let R=T.length-2;R>=0;R-=2)c.push(T[R],T[R+1],0),y.push(A++);return v.push(A),{indices:y,verticesPerFace:v}}let S=new Float32Array([m.userData.parameters.depth])[0],w=0;for(;w<p.length;){if(m.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[w]+2]===S||c[3*p[w]+2]===0)&&T++,(c[3*p[w+1]+2]===S||c[3*p[w+1]+2]===0)&&T++,(c[3*p[w+2]+2]===S||c[3*p[w+2]+2]===0)&&T++,T===3)break}if(p[w+1]===p[w+3]&&p[w+2]===p[w+5]||p[w+0]===p[w+3]&&p[w+2]===p[w+4]){y_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),tA.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),eA.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),iA.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),tA.sub(y_).normalize(),eA.sub(y_).normalize(),iA.sub(y_).normalize();let T=tA.cross(eA).dot(iA),C=w;Math.abs(T)>.005||f&&f.some((M,A)=>A%2!=1&&C>=f[A]&&C<f[A+1])?(y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3):(y.push(p[w],p[w+1],p[w+4],p[w+5]),x(w),x(w+1),x(w+4),x(w+5),v.push(4),w+=6)}else y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3}if(m.useNgonForTopBottomFaceDuringBake){let T=[],C=[],M=0;for(let A=0,R=0;A<c.length;A+=3,R++)c[A+2]===0&&(T.push(R),M++),c[A+2]===S&&C.push(R);if(m.userData.parameters.extrudeBevelSize===0){let A=C[0];C[0]=C[1],C[1]=A}T.reverse(),y.push(...T,...C),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:h,verticesPerFace:u,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=JM(t.positionWASM),l=JM(t.indexWASM),h=JM(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!h?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${gN(t.positionWASM)}, indexWASM ${gN(t.indexWASM)}, verticesPerFaceWASM ${gN(t.verticesPerFaceWASM)}`);i=o,r=l,s=h;let w=JM(t.uvWASM);Ne.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=yN,r=vN,s=bN;let u=i.length,d=r.length,c=s.length,p=i.length+n.length+a.length,m=r.length+s.length,f=p*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,y=Ne._malloc(f);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${f}) failed`);let v,b=new Float32Array(Ne.HEAPF32.buffer,y,p),_=new Uint32Array(Ne.HEAPU32.buffer,y+g,m);b.set(i,0),b.set(n,i.length),b.set(a,i.length+n.length),_.set(r,0),_.set(s,r.length),t?.scaleBaked?.some(w=>w!==1)&&(v=new xt().makeScale(...t.scaleBaked.map(w=>typeof w=="number"?w:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+n.length)*Float32Array.BYTES_PER_ELEMENT,S=a.length?v?Ne.alloc_subdivision_surface_uvs2(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ne.alloc_subdivision_surface_uvs(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ne.alloc_subdivision_surface2(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ne.alloc_subdivision_surface(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return Ne._free(y),S}static buildLevel(t,e,i,r,s,n=!1){let a=s?Ne.get_mesh_data2(t,e?Ne.Level.CONTROL:Ne.Level.REFINED,i,s.elements):Ne.get_mesh_data(t,e?Ne.Level.CONTROL:Ne.Level.REFINED,i),o=Ne.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),h=0,u=Ne.HEAPU32[o[h]>>2],d=Ne.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=Ne.HEAPU32[o[h]>>2],p=Ne.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let m=Ne.HEAPU32[o[h]>>2],f=Ne.HEAPU32.subarray(m>>2,(m>>2)+l[h]);h++;let g,y=Ne.HEAPU32[o[h]>>2],v=Ne.HEAPU32.subarray(y>>2,(y>>2)+l[h]);if(h++,Ne.alloc_subdivision_surface_uvs){let _=o[9];if(_>0){let x=Ne.HEAPU32[o[8]>>2];g=Ne.HEAPF32.subarray(x>>2,(x>>2)+_)}}if(r===void 0){let _=new ye;if(_.setIndex(new fm(v,1)),_.setAttribute("position",new ge(d,3)),_.setAttribute("normal",new ge(p,3)),g&&_.setAttribute("uv",new ge(g,2)),e){_.setAttribute("faceMap",new fm(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new _e(x,4))}return Ne.free_mesh_data(a),_.userData.type="SubdivGeometry",_}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,n){let _=r.getIndex();_!==null&&_.array.length===v.length&&(_.copyArray(v),_.needsUpdate=!0)}let b=r.getAttribute("uv");g&&b&&b.array.length===g.length&&(b.copyArray(g),b.needsUpdate=!0),Ne.free_mesh_data(a)}static freeSubdivPointer(t){Ne.free_bvh(t),Ne.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let r=Ne.get_wireframe_data_for_base_level(t),s=Ne.HEAPU32.subarray(r>>2,4+(r>>2)),n=s.subarray(2,4),a=0,o=Ne.HEAPU32[s[a]>>2],l=Ne.HEAPF32.subarray(o>>2,(o>>2)+n[a]);a++;let h=Ne.HEAPU32[s[a]>>2],u=Ne.HEAPU32.subarray(h>>2,(h>>2)+n[a]);if(e===void 0){let d=new ye;d.setAttribute("position",new ge(l,3));let c=new Float32Array(l.length);for(let p=0,m=l.length;p<m;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new _e(c,3)),d.setIndex(new fm(u,1)),Ne.free_wireframe_data_for_base_level(r),d}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Ne.free_wireframe_data_for_base_level(r)}static updateCollabMesh(t,e,i){let r=e===0;r||Ne.set_destination_refinement_level(t,e);let s=i?Ne.get_topological_data2(t,r?Ne.Level.CONTROL:Ne.Level.REFINED,i.elements):Ne.get_topological_data(t,r?Ne.Level.CONTROL:Ne.Level.REFINED),n=Ne.HEAPU32.subarray(s>>2,8+(s>>2)),a=n.subarray(3,6),o=0,l=Ne.HEAPU32[n[o]>>2],h=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=Ne.HEAPU32[n[o]>>2],d=new Uint32Array(Ne.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let c,p=Ne.HEAPU32[n[o]>>2],m=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Ne.alloc_subdivision_surface_uvs){let f=n[7];if(f>0){let g=Ne.HEAPU32[n[6]>>2];c=new Float32Array(Ne.HEAPF32.subarray(g>>2,(g>>2)+f))}}return Ne.free_topological_data(s),{positions:h,indices:d,verticesPerFace:m,uvs:c}}},y_=new P,tA=new P,eA=new P,iA=new P}),syt=j(()=>{OK(),IK(),Y4(),NK(),J4(),WS(),JK(),tZ(),eZ(),Tj(),sZ(),t5(),nZ(),aZ(),oZ(),Mj(),lZ(),hZ(),uZ(),dZ(),Tm(),Ni(),OK(),IK(),Y4(),NK(),J4(),SCt(),WS(),JK(),tZ(),eZ(),Tj(),sZ(),t5(),nZ(),aZ(),oZ(),Mj(),lZ(),hZ(),uZ(),dZ(),Tm(),TCt(),R0t(),J0t(),sb(),fD(),cD(),rb(),Rj={ConeGeometry:d0t,CubeGeometry:c0t,CylinderGeometry:cW,DodecahedronGeometry:p0t,EllipseGeometry:pD,HelixGeometry:qgt,IcosahedronGeometry:L0t,LatheGeometry:F0t,NonParametricGeometry:j0t,PolygonGeometry:vW,PyramidGeometry:G0t,RectangleGeometry:mD,SphereGeometry:H0t,PlaneGeometry:$0t,BackdropGeometry:X0t,StarGeometry:bW,TextFrameGeometry:Y0t,TorusGeometry:K0t,TorusKnotGeometry:Z0t,TriangleGeometry:Q0t,VectorGeometry:Pm},nR=t=>{let e=Rj[t.type]??Ngt(t.type);if(e===void 0)throw new Error(`No geometry factory registered for "${t.type}" \u2014 was its feature compiled out of this runtime build?`);return e.create(t)}});function hm(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let h of a){let u=n;for(let d of h)u=u[d];for(s in u){let d=u[s];IU(d)&&!nyt.includes(s)&&(u[s]=e.getVariable(d,[r.uuid,"geometry",...h,s]),IU(u[s])&&(u[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let h=r.profileShape;h!==void 0&&(l.shapeData=h),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let h=ms.createFromState(n.shape,n.width,n.height);l.shape=h,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),l.geometry=new MG().parse(n),l.geometry.groups.length===0){let h=l.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let h=new ps(n,i);return h.data=t,h}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let h=Ngt(n.type);if(h)return h.create(n,e);On("text",`a ${n.type}`);let u=ms.createFromState(Vv.defaultData(),100,100);return nR({...n,shape:u,type:"VectorGeometry"})}if(n.type==="UIGeometry")return mD.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=nR(l)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${l}`);let u=ms.createFromState(Vv.defaultData(),100,100);l.shape=u,l.type="VectorGeometry",o=nR(l)}return o}var nyt,gD=j(()=>{Be(),ht(),syt(),Ni(),t5(),Em(),sb(),nyt=["font"]});function Dj(t){switch(typeof t){case"number":return Number.isFinite(t)?JSON.stringify(t):void 0;case"boolean":return JSON.stringify(t);case"string":return IU(t)?void 0:JSON.stringify(t);case"object":{if(t===null)return"null";if(Array.isArray(t)){let s="[";for(let n=0;n<t.length;n++){let a=Dj(t[n]);if(a===void 0)return;s+=(n>0?",":"")+a}return s+"]"}let e=t,i="{",r=!0;for(let s of Object.keys(e).sort()){if(e[s]===void 0)continue;let n=Dj(e[s]);if(n===void 0)return;i+=`${r?"":","}${JSON.stringify(s)}:${n}`,r=!1}return i+"}"}default:return}}var ayt,fZ,Oj,ACt=j(()=>{Be(),ayt=new Set(["CubeGeometry","SphereGeometry","CylinderGeometry","ConeGeometry","TorusGeometry","TorusKnotGeometry","IcosahedronGeometry","DodecahedronGeometry","PyramidGeometry","PlaneGeometry","BackdropGeometry","HelixGeometry"])}),CCt=j(()=>{gD(),ACt(),fZ=class{constructor(){this.objects=new Map,this.refs=new Map,this.sharedByKey=new WeakSet,this.unreachable=new Set}resolveObject(t,e,i){return this.createObject(t,e,i)}onObjectDisposed(t){}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,i){let r=this.objects.get(t);return r===void 0?(r=this.resolveObject(t,e,i),this.objects.set(t,r),this.retain(r)):(this.sharedByKey.add(r),r.isShared=!0),r}forceDelete(t){let e=this.objects.get(t);e&&(this.objects.delete(t),this.release(e))}adopt(t,e){this.replace(t,e),this.retain(e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.replace(e,i),i}replace(t,e){let i=this.objects.get(t);this.objects.set(t,e),i!==void 0&&i!==e&&this.release(i)}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){e===this.objects.get(t)&&this.unreachable.delete(t)}endGc(){this.unreachable.forEach(t=>{let e=this.objects.get(t);this.objects.delete(t),this.release(e)}),this.unreachable.clear()}dispose(){new Set(this.objects.values()).forEach(t=>{this.disposeObject(t),this.onObjectDisposed(t)}),this.objects.clear(),this.refs.clear()}retain(t){let e=(this.refs.get(t)??0)+1;this.refs.set(t,e),e>1&&(t.isShared=!0)}release(t){let e=(this.refs.get(t)??1)-1;if(e>0)return this.refs.set(t,e),void(e===1&&!this.sharedByKey.has(t)&&(t.isShared=!1));this.refs.delete(t),this.disposeObject(t),this.onObjectDisposed(t)}},Oj=class extends fZ{constructor(t){super(),this.flatShading=t,this.dedupeByValue=!1,this.byValue=new Map,this.valueKeyOf=new Map}disposeObject(t){t.dispose()}createObject(t,e,i){let r=hm(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}resolveObject(t,e,i){let r=this.dedupeByValue?function(n,a,o){if(!ayt.has(n.type))return;let l=n;if(l.shapeBlendNode!=null||o.isTransientGeometryKey(n))return;let h=a.material;if(h===void 0||Array.isArray(h))return;let u=h;if(typeof u.getLayersOfType!="function"||u.getLayersOfType("outline").length>0||u.getLayersOfType("cavity").length>0)return;let d=n.type;for(let c of Object.keys(l).sort()){let p=l[c];if(p===void 0||c==="type")continue;let m=Dj(p);if(m===void 0)return;d+=`|${c}=${m}`}return d}(t,i,e):void 0;if(r!==void 0){let n=this.byValue.get(r);if(n!==void 0)return n}let s=this.createObject(t,e,i);return r!==void 0&&(this.byValue.set(r,s),this.valueKeyOf.set(s,r)),s}mutateIfUnique(t,e){let i=super.mutateIfUnique(t,e);return i!==void 0&&this.forgetValue(i),i}onObjectDisposed(t){this.forgetValue(t)}forgetValue(t){let e=this.valueKeyOf.get(t);e!==void 0&&(this.valueKeyOf.delete(t),this.byValue.get(e)===t&&this.byValue.delete(e))}}});function e5(){return gT}function oyt(){if(gT==="webgpu"){if(Nj!==void 0)return Nj;Bj||(Bj=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(vZ===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return vZ}function lyt(t,e){return oyt().createRootMaterial(t,e)}function gZ(t,e,i){return oyt().createSharedMaterial(t,e,i)}function yZ(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function Ij(){return hyt}var gT,Nj,vZ,Bj,kj,hyt,uyt,Rm=j(()=>{gT="webgl",Bj=!1}),ECt=j(()=>{uyt={markNeedsUpdateRendererDirty:()=>{}}});function bZ(t){return t.data.type!=="displace"&&!!t.data.isMask}function um(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,a=Number(e.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?a/100:n.alphaOverride)<1)return!0}let s=t.layers;for(let n=0;n<s.length;n++){let a=s[n];if(!bZ(a)){if(n>0&&bZ(s[n-1])){if(a.data.type==="light"&&!a.data.visible)return!0;continue}if(a.data.type!=="displace"&&"alpha"in a.data&&a.data.type!=="light"&&a.data.type!=="fresnel"&&a.data.type!=="cavity"&&a.data.type!=="dust"&&a.data.type!=="texture"&&a.data.type!=="matcap"&&a.data.type!=="rainbow"&&a.data.type!=="outline"&&a.data.type!=="pattern"){let o=a.data.visible?a.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(e.getVariable(o)??100)/100))),o===1&&a.data.type==="depth"||a.data.type==="gradient"){for(let l of a.data.colors)if(l[3]<1){o=l[3];break}}else if(o===1&&a.data.type==="noise"){let l=e.color(a.data.colorA).a,h=e.color(a.data.colorB).a,u=e.color(a.data.colorC).a,d=e.color(a.data.colorD).a,c=Math.min(l,Math.min(h,Math.min(u,d)));c<1&&(o=c)}i+=(1-i)*o}}}return i<1}var yD=j(()=>{});function yv(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Lv,os,dyt,cyt,yT,pyt,_Z,xZ,Ja,nb=j(()=>{ht(),Lv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,os=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),dyt=(t,e)=>(t||(t=new P),t.x=os(t.x,e)??0,t.y=os(t.y,e)??0,t.z=os(t.z,e)??0,t),cyt=(t,e)=>(t||(t=new Z),t.x=os(t.x,e)??0,t.y=os(t.y,e)??0,t),yT={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},pyt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),ab=j(()=>{ht(),ib(),ts(),_Z=class extends hD(ur){},xZ=t=>t.type==="Mesh",Ja=class extends _Z{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];(!(i instanceof Ja)||i.object!==e)&&(i=new Ja(e),this._replaceChildAt(t,i),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.shearMatrix=e.shearMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(let i of this.object.children){if(!om(i)||i.object.parent!==this.object)continue;let r=this.children[t];r?.source!==i&&(r=i.createCopy(),this._replaceChildAt(t,r)),r.expand(),t+=1}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}_replaceChildAt(t,e){let i=this.children[t];i&&this.remove(i),this.add(e),this.children.splice(t,0,this.children.pop())}get visible(){let t=this.parent,e=om(t)&&t.object===this.object;return(!e||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||e&&this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return xZ(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(t){}}});function wZ(){return wW}var wW,SW,TW=j(()=>{wW=null,SW=null});function Vj(t){return"variable_"+t}var _N,xN,wN,SZ,SN,TZ,TN,MZ,i5,MW=j(()=>{Be(),tCt(),a0t(),o0t(),kc(),hW(),dW(),CCt(),Rm(),r0t(),ECt(),yD(),nb(),bo(),ab(),Ui(),ht(),TW(),Ni(),_N=new xt,xN=new P,wN=new Te,SZ=new P,SN=new Fi,TZ=class extends Jgt{constructor(t){super(),this.shared=t}create(t){return new lW(t,this.shared)}},TN=new Set,(i5=MZ=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new Oj(!0),this.geometryCache2=new Oj(!1),this.imageHolderCache=new TZ(this),this.thisContext={scene:uyt,shared:this},this.deletedImage=new Sg(D4.emptyImage,this),this.deletedVideo=new Sg(O4.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,e.images)for(let[s,n]of Object.entries(e.images))this.addImage(s,n);if(e.videos)for(let[s,n]of Object.entries(e.videos))this.addVideo(s,n);if(e.audios)for(let[s,n]of Object.entries(e.audios))this.addAudio(s,n);if(e.particles)for(let[s,n]of Object.entries(e.particles))this.addParticle(s,n);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=gZ(ls.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,i=!1){this.data=t,this.resetLib(t.lib);for(let{id:r,data:s}of t.variables)this.addVariableHolder(r,s),e&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(t.userAPIs??{}))this.addUserAPI(r,s);for(let[r,s]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(t.images))this.addImage(r,s);for(let[r,s]of Object.entries(t.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(t.colors))this.addColor(r,s);for(let[r,s]of Object.entries(t.lib.materials))this.addMaterial(r,s.asset);for(let[r,s]of Object.entries(t.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(t.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(t.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(t.fonts))this.addFont(r,s)}addMaterial(t,e){if(e=ls.withRepairedLayers(e),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=gZ(e,this.thisContext,t);this.materials[t]=i}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){return this.materials[t]}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):lyt(ls.withRepairedLayers(t),this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Sg(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Sg(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let i=t.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let s=r.root??r;for(let n of s?.data?.layers??[]){let a=n?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||e.layer!==void 0&&n.id!==e.layer&&a.type!==e.layer)continue;let o=a.texture?.image;if(o==null)continue;let l=(typeof o=="string"?this.uiBuffer(o):void 0)??this.image(o);if(!l)continue;let h=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),u=l.img;return{texture:h,width:u?.width??0,height:u?.height??0,layerId:n.id,layerType:a.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Sg(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):(this.colors[t]=new pj(e.r,e.g,e.b,"a"in e?e.a:1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[t];return this.colors[t].r=e.r??i.r,this.colors[t].g=e.g??i.g,this.colors[t].b=e.b??i.b,this.colors[t].a=e.a??i.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t!="string")return new Dr(t.r,t.g,t.b,"a"in t?t.a:1);{let i=this.getColor(t);i?e=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Dr(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Z1)return e;{let i=new Z1({src:e.data});return this.audios[t]=i,i}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Z1&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=uW;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):On("text","a font asset")}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._requestRender=void 0,Object.values(this.audios).forEach(t=>{t instanceof Z1&&t.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let i=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let r=localStorage.getItem(Vj(t));i=r!==null?JSON.parse(r):e.value}return this.variables[t]={value:i,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(Vj(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let o=a[1],l=i,h={scene:r,shared:this},u=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(u,l,h)});let d=this.materials[o];d&&d.onVariableUpdate(u,l,h)}else{let o=r.find(a[0]);if(o===void 0){this.variables[t].locations.splice(n,1);continue}if(s=!0,a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)o=o[a[l]];a[1]==="rotation"?o[a[a.length-1]]=i*Ft.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),xi.is(o))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")o.onVariableUpdate();else if(a[1]==="geometry"){let l=o;o.component&&(l=o.component);let h=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(h.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let d=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(d.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}isTransientGeometryKey(t){return this.transientGeometryKeys.has(t)}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||typeof s.type!="string"||s.type==="VectorGeometry"||s.type==="PathGeometry")return!1;let n=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let h of Object.keys(s))a.set(n(h),h);let o={};for(let[h,u]of Object.entries(e??{})){let d=a.get(n(h));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof u=="string"||typeof u=="number")&&(o[d]={textValue:String(u)});continue}let c=s[d];typeof u=="number"&&isFinite(u)&&(typeof c=="number"||typeof c=="string")&&(o[d]=u)}if(Object.keys(o).length===0)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||s.type!=="NonParametricGeometry")return!1;let n=e?.vertices;if(n===void 0||typeof n.length!="number"||n.length<9||n.length%3!=0||n.length/3>MZ.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,h=n instanceof Float32Array?n:Float32Array.from(n),u=h.length/3;if(e.normals!==void 0){if(e.normals.length!==h.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*u)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=u>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(x.length===0||x.length%3!=0)return!1;for(let S=0;S<x.length;S++)if(x[S]>=u)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=s.data,S=x?.index;if(S?.array?.length){let w=(x?.attributes?.position?.array?.length??0)/3;if(u!==w)return function(T,C){let M=`${T}/${C}`;TN.has(M)||(TN.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${C}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}(u,w),!1;l=S}}let d=1/0,c=1/0,p=1/0,m=-1/0,f=-1/0,g=-1/0;for(let x=0;x<h.length;x+=3){let S=h[x],w=h[x+1],T=h[x+2];S<d&&(d=S),S>m&&(m=S),w<c&&(c=w),w>f&&(f=w),T<p&&(p=T),T>g&&(g=T)}let y=(x,S)=>({array:x,itemSize:S,type:"Float32Array",normalized:!1}),v={position:y(h,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:f-c,depth:g-p,data:{attributes:v,...l?{index:l}:{}}},_=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,_),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let s=r.children,n=Math.PI/180,a=!1;if(e===null)for(let o of s)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return s.length;{let o=Math.min(e.length,s.length);for(let l=0;l<o;l++){let h=e[l],u=s[l];if(h==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,a=!0);continue}let d=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};h.position&&(typeof h.position.x=="number"&&(d.position[0]=h.position.x),typeof h.position.y=="number"&&(d.position[1]=h.position.y),typeof h.position.z=="number"&&(d.position[2]=h.position.z)),h.rotation&&(typeof h.rotation.x=="number"&&(d.rotation[0]=h.rotation.x*n),typeof h.rotation.y=="number"&&(d.rotation[1]=h.rotation.y*n),typeof h.rotation.z=="number"&&(d.rotation[2]=h.rotation.z*n)),h.scale&&(typeof h.scale.x=="number"&&(d.scale[0]=h.scale.x),typeof h.scale.y=="number"&&(d.scale[1]=h.scale.y),typeof h.scale.z=="number"&&(d.scale[2]=h.scale.z)),u.transformOverride=d,u.position.fromArray(d.position),u.rotation.fromArray(d.rotation),u.scale.fromArray(d.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}}return a?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let r=new Ja(t);r.playModeVisible=e.visible!==!1,r.expand(),typeof e.name=="string"&&(r.name=e.name);let s=Math.PI/180;return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.shearMatrix.copy(t.shearMatrix),e.position&&(typeof e.position.x=="number"&&(r.position.x=e.position.x),typeof e.position.y=="number"&&(r.position.y=e.position.y),typeof e.position.z=="number"&&(r.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(r.rotation.x=e.rotation.x*s),typeof e.rotation.y=="number"&&(r.rotation.y=e.rotation.y*s),typeof e.rotation.z=="number"&&(r.rotation.z=e.rotation.z*s)),e.scale&&(typeof e.scale.x=="number"&&(r.scale.x=e.scale.x),typeof e.scale.y=="number"&&(r.scale.y=e.scale.y),typeof e.scale.z=="number"&&(r.scale.z=e.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let r=[];for(let h of Array.isArray(i)?i:[i]){let u=h.root??h;u&&Array.isArray(u.layers)&&u.data&&!r.includes(u)&&r.push(u)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=h=>{if(typeof h=="string"){let u=new Dr(1,1,1,1);try{u.set(h)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(h&&typeof h=="object"&&"r"in h){let u=h;if([u.r,u.g,u.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*d,g:u.g*d,b:u.b*d,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},o=(h,u,d)=>{if(!h.hasValue(u))return!1;let c=h.getValue(u);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof pj?h.setValue(u,new Dr(d.r,d.g,d.b,p)):typeof c.setRGBA=="function"?c.setRGBA(d.r,d.g,d.b,p):c.setRGB(d.r,d.g,d.b),!0},l=!1;for(let h of r){let u=h.data.layers??[],d=c=>h.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=u.find(f=>f.data.type==="color"),m=p&&d(p.id);if(c&&m&&o(m,"color",c)&&(l=!0,c.a!==void 0)){let f=c.a<1||um(h.data,this);h.setTransparent?h.setTransparent(f,s.scene):h.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(h.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),s),l=!0);for(let c of e.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?u.find(y=>y.id===c.id):typeof c.index=="number"?u[c.index]:typeof c.type=="string"?u.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=yT[p.data.type]??[],g=Object.keys(p.data);for(let[y,v]of Object.entries(c)){if(y==="id"||y==="index"||y==="type")continue;let b=g.find(x=>x===y)??g.find(x=>n(x)===n(y))??y;if(f.includes(b))continue;let _=a(v);if(_&&o(m,b,_))l=!0;else if(typeof v=="number"&&isFinite(v))h.onVariableUpdate?.(["layer",p.id,b],v,s),l=!0;else if(Array.isArray(v)&&v.length<=3&&v.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];v.forEach((S,w)=>{h.onVariableUpdate?.(["layer",p.id,b,x[w]],S,s)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(t){this.variables[t]&&delete this.variables[t]}referencesMissingObject(t){return Array.isArray(t)&&t[0]!=="mouse"&&t[0]!=="raycast"&&this.entityOpContext.scene.find(t[0])===void 0}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let i=this.entityOpContext.scene.find(t[0]);if(i===void 0)return;if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return i.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&i?.getPhysicsLocalMatrix?.(_N))return _N.decompose(xN,wN,SZ),t[1]==="position"?xN[t[2]]:(SN.setFromQuaternion(wN,i.rotation.order),SN[t[2]]*Ft.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=Ft.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let r=this.variables[i],s=r.locations?.findIndex(n=>Dn.equal(n,e));s!==void 0&&s!==-1&&r.locations.splice(s,1)}if(typeof t=="string"){let i=t,r=t;do{if(r=i,this.variables[i]===void 0)break;let s=this.variables[i].value;e&&this.variables[r]!==void 0&&this.variables[r].locations.push(e),i=s}while(typeof i=="string");return i}return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,i]of Object.entries(t.images))this.addImage(e,i.asset);for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i.asset);for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i.asset);for(let[e,i]of Object.entries(t.colors))this.addColor(e,i.asset);for(let[e,i]of Object.entries(t.fonts))this.addFont(e,i.asset);for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i.asset);for(let[e,i]of Object.entries(t.variables))this.addVariableHolder(e,i.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,i){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ta.drop(t,2),e.materials[t.path[1]],{shared:this,scene:i});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,i):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let r=e.userAPIs[t.path[1]];if(r){let s=t.type===0&&t.props.debounce===void 0,n=this.getUserAPI(t.path[1]);n!==void 0&&n===this.openAIRealtime?n.update(r):n?.update(r,this,s)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let r=e.userWebhooks[t.path[1]];r&&this.getUserWebhook(t.path[1])?.update(r)}}else t.path[0]==="lib"&&this.updateLibByOp(ta.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let r=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let i=SW;return i===null?(On("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=wZ();return i===null?(On("api-services","a user API integration"),!1):(this.userAPIs[t]=i.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let i=wZ();return i===null?(On("api-services","a user webhook"),!1):(this.userWebhooks[t]=i.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new i5(Jl.emptyData())});function r5(t){return Ygt(t)||t?.isTSLNodeMaterial===!0}var vo,MN,AN,CN,AZ,EN,pd,CZ,EZ,v_,Ur,AW=j(()=>{e0t()}),d0=j(()=>{Be(),oa(),Rm(),AW(),Ui(),un(),vo=class extends Fs{setMaterialOverride(t,e){this.materialOverride=yZ(t),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),e.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(t,e,i){if(super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.syncShadowCatcher(i),function(r,s){let n=[];if(s.length!==r.length)return null;{let a=0;for(;a<r.length;){if(s[a]==="*")n.push(r[a]);else if(r[a]!==s[a])return null;a+=1}}return n}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(t.props)){let n=this.material[Number(r)],a=i.shared.material(s);a!==n&&vo.disposeOneMaterial(n),this.material[Number(r)]=a}else if(er(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(ta.drop(t,1),e.material,i)}else if(er(t.path,["materials","*"])&&Array.isArray(this.material)){let r=t.path[1];if("materials"in e&&r<this.material.length){let s=e.materials[r];typeof s!="string"&&this.material[r].updateByOp(ta.drop(t,2),s,i)}}}get needsAO(){return this.material!==void 0&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(t,e){super.updateState(t,e),t.castShadow!==void 0&&(this.castShadow=t.castShadow),t.receiveShadow!==void 0&&(this.receiveShadow=t.receiveShadow);let i,r=this.dataPatched;this.syncShapeBlendNodeLayer(),this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let s=this.materialOverride!==void 0;!s&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!s&&(t.geometry?.type==="NonParametricGeometry"||"materials"in t)&&("materials"in t&&t.materials!==void 0?(this.disposeMaterial(),this.material=t.materials.map(a=>e.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let n=this.data;if(!s&&n.geometry?.type!=="NonParametricGeometry"&&"materials"in n&&n.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(n.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(t.flatShading!==void 0||t.wireframe!==void 0||t.side!==void 0))if(Array.isArray(this.material))for(let a=0;a<this.material.length;a++)this.material[a]=this.material[a].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe,i);this.syncShadowCatcher(e)}shadowCatcherActive(){let t=this.dataPatched,e=t.geometry?.type;return t.shadowCatcher===!0&&(e==="RectangleGeometry"||e==="PlaneGeometry")}syncShadowCatcher(t){let e=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=gT==="webgpu"&&kj!==void 0?kj:void 0;return r===void 0?null:yZ(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=e.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,t.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.material=t.shared.material(e.material).getFlavor(e.flatShading,e.side,e.wireframe),t.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow)}static disposeOneMaterial(t){var e;r5(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&rft(this.material).forEach(t=>{vo.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),_o=j(()=>{Be(),Ui(),MW(),d0(),ht(),gD(),rb(),sb(),iyt(),MN=new P,AN=new Me,CN=new Me,AZ=new P,EN=new xt,pd=new yr,CZ=pd.geometry,EZ=pd.material,v_=new P,Ur=class extends vo{constructor(t,e,i){super(t,e),this.data=e,this.isSkinnedMesh=!1,this.localGeometry=void 0,e.bindMode&&e.bindMatrix&&(this.bindMode=e.bindMode,this.bindMatrix=new xt().fromArray(e.bindMatrix),this.bindMatrixInverse=new xt)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof ye&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof ye?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof i5){let t=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(t),i=this.dataPatched.geometry;this.geometryCreateDeleyed=e.get(i,t,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(t){this.localGeometry=t}get is2DAndNoDepth(){let t=this.dataPatched.geometry;return B4.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return B4.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.updateByPatchedOpGeometry(ta.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,Q4.delete(t),this._posed=void 0}get appliedGeometrySize(){let t=this.localGeometry?.userData;if(t!==void 0&&t.sxPrev!==void 0)return[t.sxPrev,t.syPrev,t.szPrev]}updateGeometryInteractions(t,e){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,s,n,a=t;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=hm(d,e,this.data.flatShading,this)}a.scaleBaked?[r,s,n]=a.scaleBaked:{width:r,height:s,depth:n}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,h=typeof s=="number"?s:1,u=typeof n=="number"?n:1;o.sxPrev!==void 0&&Ej(this.localGeometry.attributes,l/o.sxPrev,h/o.syPrev,u/o.szPrev),o.sxPrev=l,o.syPrev=h,o.szPrev=u}else if(!this.absorbDepthInteraction(t)){let r=hm(i==="VectorGeometry"?k4.merge(this.data.geometry,t):{...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&fN(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(t){let e=this.localGeometry;if(e?.shiftDepthTo===void 0)return!1;let i=t;if(typeof i.depth!="number")return!1;let r=e.userData?.parameters;if(r===void 0)return!1;for(let s of Object.keys(i))if(s!=="depth"&&i[s]!==r[s])return!1;return!!e.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(t){for(let e of this.attachedSurfaceCloners)e.update(t)}refreshAttachedCloners(t){for(let e of this.attachedSurfaceCloners)t.scene.addPendingUpdateCloner(e.object)}refreshAttachedPaths(t){for(let e of this.attachedPaths)t.scene.addPendingCommand(()=>e.updateShape())}createGeometryDelayed(t){this.geometryCreateDeleyed=t.shared,this.refreshAttachedCloners(t),this.refreshAttachedPaths(t)}updateByPatchedOpGeometry(t,e,i){let r=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof ps&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&ryt(t.props)&&this.geometryCreateDeleyed instanceof ps&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof ps)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=i.shared,n=this.chooseGeoemtryCache(s),a=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=hm(o,s,this.data.flatShading,this);fN(a,l)?(l.dispose(),a.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(t,e){this.createGeometryDelayed(e)}applyTransientGeometryData(t,e){let i=t.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof ps)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=this.chooseGeoemtryCache(i),n=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===n&&n.isShared!==!0){let a=hm(r,i,this.data.flatShading,this);return fN(n,a)?(a.dispose(),n.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(t),void this.refreshAttachedPaths(t)}}e&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),t.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(t)}updateState(t,e){t.geometry!==void 0&&this.updateGeometryOnStateUpdate(t.geometry,e);let i=t.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:s}}of i)this.updateMorphInfluences(r,e.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}super.updateState(t,e)}updateMorphInfluences(t,e){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[t];i!==void 0&&(this.morphTargetInfluences[i]=e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(t,e){let i=this.posedGeometry()?.boundingBox;if(i)return i.getCenter(t),void i.getSize(e).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*r.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?t.fromArray(r.centerOffset):t.setScalar(0),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(t,e){this.skeleton=t,this.isSkinnedMesh=!0,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(t){let e=new Me,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){e.fromBufferAttribute(i,r);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),i.setXYZW(r,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;AN.fromBufferAttribute(r.attributes.skinIndex,t),CN.fromBufferAttribute(r.attributes.skinWeight,t),MN.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=CN.getComponent(s);if(n!==0){let a=AN.getComponent(s);EN.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(AZ.copy(MN).applyMatrix4(EN),n)}}return e.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(t,e){let i=this.posedGeometry();if(i===void 0)return!1;pd.geometry=i,pd.material=this.material,pd.matrixWorld.copy(this.matrixWorld);let r=e.length;pd.raycast(t,e);for(let s=r;s<e.length;s++)e[s].object=this;return pd.geometry=CZ,pd.material=EZ,!0}posedGeometry(){let t=this.skeleton;if(!this.isSkinnedMesh||t===void 0)return;let e=this.geometry,{position:i,skinIndex:r,skinWeight:s}=e.attributes;if(!i||!r||!s)return;let n=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<t.bones.length;d++){let c=t.bones[d];if(!c||!t.boneInverses[d])return;n.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===e&&a.version===i.version&&a.pose.length===n.length&&a.pose.every((d,c)=>d===n[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,h=l?.count===o?l:new _e(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,v_)),h.setXYZ(d,v_.x,v_.y,v_.z);let u=new ye;u.setAttribute("position",h);for(let d of["normal","uv","uv1"]){let c=e.attributes[d];c&&u.setAttribute(d,c)}return u.setIndex(e.index),u.groups=e.groups,u.drawRange=e.drawRange,u.computeBoundingSphere(),u.computeBoundingBox(),this._posed={source:e,version:i.version,pose:n,geometry:u},u}}});function vv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!Ygt(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Ur&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,r=new Float32Array(i.length),s=new P;for(let n=0;n<i.length;n+=3)s.set(i[n],i[n+1],i[n+2]).normalize(),r[n]=s.x,r[n+1]=s.y,r[n+2]=s.z;e.geometry.setAttribute("extrudeNormal",new ge(r,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,r=e.geometry.attributes,s=r.position.array,n=r.normal.array,a=new Float32Array(s.length);for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,h=new P(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(h):i.set(l,{normals:[h],result:new P})}i.forEach((o,l)=>{for(let h of o.normals)o.result.add(h);o.result.divideScalar(o.normals.length)});for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,h=i.get(l)?.result;h&&(a[o]=h.x,a[o+1]=h.y,a[o+2]=h.z)}e.geometry.setAttribute("extrudeNormal",new ge(a,3))}(t)}function PN(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function bv(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,r=e.randomColor;if(r!==void 0&&3*r.count===i.length)return;let s=new Float32Array(i.length),n=parseInt(t.uuid.replace(/\D/g,"")),a=[PN(Ft.seededRandom(n)),PN(Ft.seededRandom(n+1e4)),PN(Ft.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new _e(s,3))}var vD=j(()=>{ht(),e0t(),_o()});function PZ(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function PCt(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function RZ(t,e,i,r){let s=16*(e.children.length+1);u2.length<s&&(u2=new Float32Array(s));let n=0,a=l=>{l.toArray(u2,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),zj.copy(t.matrix);for(let l of e.children)!lm(l)||l.playModeVisible===!1||(Lj.copy(l.matrix).multiply(l.pivotMatrix),aR.multiplyMatrices(zj,Lj),(!o||!aR.equals(r))&&a(aR));try{return n===0?0:function(l,h){return aW($4().instanced_union(nW(l),h))}(i,u2.subarray(0,16*n))}finally{Hgt(i)}}var md,DZ,zj,Lj,aR,u2,_m,vT=j(()=>{oa(),ht(),cD(),vD(),d0(),ts(),md=new xt,DZ=new xt,zj=new xt,Lj=new xt,aR=new xt,u2=new Float32Array(0),_m=class extends vo{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new ye,this.onAfterRender=(r,s,n,a,o,l)=>{super.onAfterRender(r,s,n,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&t.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(t,e=!0){if(this.booleanMeshSetAddress!==-1&&!t)return;for(let r=0;r<this.children.length;r++){let s=this.children[r];s instanceof _m&&s.dataPatched.visible===!0&&s.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let s=this.children[r];if(s instanceof Fs&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){md.copy(s.matrix).multiply(s.pivotMatrix);try{let n=PCt(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=Z3t(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:RZ(s,n,a,md)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&nN(s.booleanMeshSetAddress,md),s.booleanMatrixInvOld.copy(md).invert(),s.booleanWasTransformed=!1}else s instanceof _m&&s.needsTransformForDownstream===!0?(n===void 0?nN(s.booleanMeshSetAddress,md):s.booleanMeshSetAddress=RZ(s,n,s.booleanMeshSetAddress,md),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(nN(s.booleanMeshSetAddress,DZ.multiplyMatrices(md,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(md).invert(),s.booleanWasTransformed=!1)}catch(n){console.error(n),s.booleanMeshSetAddress=0,s.geometry.userData.booleanOperationDidFail=!0;continue}if(s.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let r=this.geometry;r.dispose(),this.geometry=new ye,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new ge([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=$4(),a=_K(r,s),o=n.mesh_topological_data(a),l=o.positions(),h=o.indices();return o.free(),a.free(),{positions:l,indices:h,verticesPerFace:new Uint8Array(h.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new ye,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=$4(),l=_K(r,s),h=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new ge(h.positions(),3)),n.setAttribute("normal",new ge(h.normals(),3)),h.free(),n.boundingSphere===null&&(n.boundingSphere=new Jn),l.tri_count()===0)n.boundingSphere.center.set(0,0,0),n.boundingSphere.radius=0,n.userData.parameters={width:0,height:0,depth:0};else{let u=l.bounds();n.boundingSphere.center.set(u[0],u[1],u[2]),n.boundingSphere.radius=(u[3]**2+u[4]**2+u[5]**2)**.5,n.userData.parameters={width:2*u[3],height:2*u[4],depth:2*u[5]}}return aW(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(r){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(r)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,vv(this),bv(this)}dispose(){super.dispose(),this.geometry.dispose()}}});function RCt(t){return t.isPointLight?oR.PointLight:t.isSpotLight?oR.SpotLight:oR.DirectionalLight}function OZ(t){return t.isDirectionalLight?0:t.isSpotLight?1:2}var oR,hS,mg,s5,bD,Hh,$u,n5,myt=j(()=>{oR={PointLight:1,SpotLight:3,DirectionalLight:3},hS=new WeakSet,mg=[]}),bT=j(()=>{ht(),myt(),bo(),u0(),(s5||(s5={})).is=function(t){return xi.is(t)&&t instanceof Xd},bD=(t,e)=>class extends h0(t,e){updateState_Light(i,r){if(this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let s=this.shadow;s.camera.far=i.depth,s.needsUpdate=!0}i.shadows!==void 0&&(function(s){hS.delete(s)}(this),this.castShadow=i.shadows)}}}),Dm=j(()=>{ht(),vT(),oa(),u0(),Hh=t=>t instanceof Fs,$u=t=>t!==null&&t instanceof _m,n5=t=>hj.is(t)});function wa(t,e){return e.color(t)}function IZ(t=new Date,e){let i=e.format,r=t.getSeconds(),s=t;e&&e.timeZone!==null&&(s=function(d,c){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(d),m=f=>Number(p.find(g=>g.type===f)?.value);return new Date(m("year"),m("month")-1,m("day"),m("hour"),m("minute"),m("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let n,a=s.getHours(),o=s.getMinutes();e.format12h24h==="12ampm"&&(n=a>=12?"PM":"AM");let l,h,u=a;switch(e.format12h24h!=="24"&&(u=a%12,u===0&&(u=12)),i){case"HH:mm:ss":l=[u,o,r];break;case"HH:mm":l=[u,o];break;case"HH":l=[u],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":h=s.getFullYear();break;case"month":h=s.getMonth()+1;break;case"dayOfYear":h=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":h=s.getDate();break;case"secondOfDay":h=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),h=0}return l!==void 0?{textValue:l,suffix:n}:h}var Fj,ob,CW=j(()=>{}),DCt=j(()=>{ht(),cT(),pT(),Fj=class extends Jv(Ymt){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){tb(this.object,Fj.geometryHelper,t,e)}}}),_D=j(()=>{ht(),DCt(),bT(),ob=class extends bD(NS,Fj){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new BS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof BS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&function(r,s){r.shadow.camera.right=s/2,r.shadow.camera.left=-s/2,r.shadow.camera.top=s/2,r.shadow.camera.bottom=-s/2,r.shadow.needsUpdate=!0}(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),i&&this.update()}}});function EW(t){return t instanceof vo&&t.needsAO&&!Ic(t)&&t.isDecalObject!==!0}function PW(t){let e=t.cloner;if(e&&Array.isArray(e.children))for(let i of e.children)i?.layers&&(i.layers.mask=t.layers.mask)}function RW(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function OCt(t){let e=1/0,i=-1/0;for(let r of t.getLayersOfType("reflection")){let s=r.data;if(!s.visible||s.mirror===1)continue;let n=typeof s.blur=="number"?s.blur:null;e=Math.min(e,n??0),i=Math.max(i,n??10)}return e===1/0?null:{min:e,max:i}}function ICt(t){for(let e of t.getLayersOfType("reflection")){let i=e.data;if(!i.visible)continue;let{blur:r,thickness:s,steps:n,stepSize:a}=i;return typeof r!="number"||typeof s!="number"||typeof n!="number"||typeof a!="number"?"variable":{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function NZ(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&xD,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=RW(e),o=e.getLayersOfType("cavity");return(n.length>0||o.length>0)&&(t.layers.set(8),s.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=n.length>0,i.cavity=o.length>0,bv(t),vv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&EW(t)&&t.layers.enable(5),PW(t),i}function BZ(t,e){if(!e.layers)return!1;let i=t.layers.mask&xD,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=RW(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return s.length>0&&(t.layers.set(3),(n.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),r=!0),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&EW(t)&&t.layers.enable(5),PW(t),r}function kZ(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&xD,s=!1,n=RW(e),a=e.getLayersOfType("transmission").filter(h=>h.data.visible),o=e.getLayersOfType("outline").filter(h=>h.data.visible),l=e.getLayersOfType("cavity").filter(h=>h.data.visible);return n>0&&((i=t.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),t.layers.set(4),a.length>0&&t.layers.enable(3),(o.length>0||l.length>0)&&t.layers.enable(8),s=!0),n===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),r&&t.layers.set(9),!r&&EW(t)&&t.layers.enable(5),PW(t),s}function Uj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if((t.raycast===yr.prototype.raycast||t.raycast===Fs.prototype.raycast)&&t.isSkinnedMesh!==!0){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&(jj.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(jj)))continue;let o=gyt.copy(a.matrixWorld).invert(),l=yyt.copy(e.ray).applyMatrix4(o),h=t.matrixWorld;l.applyMatrix4(h);let u=fyt;u.set(l.origin,l.direction),u.near=e.near,u.far=e.far,u.layers.mask=e.layers.mask;let d=u.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var xD,fyt,gyt,yyt,jj,rA,vyt,RN,DN,ON,lb,Or,DW=j(()=>{ts(),vD(),oa(),d0(),ht(),xD=512,fyt=new Y5,gyt=new xt,yyt=new gc,jj=new Jn}),NCt=j(()=>{ht(),cT(),pT(),rA=class extends Jv($mt){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){tb(this.object,rA.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=rA._vector,e=this.object.distance?this.object.distance:1e3,i=e*Math.tan(this.object.angle);this.cone.scale.set(i,i,e),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},(vyt=rA)._vector=new P}),wD=j(()=>{ht(),NCt(),bT(),RN=new P,DN=new P,ON=new Te,lb=class extends bD(Wg,vyt){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=2*Ft.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new BS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof BS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),DN.setFromMatrixPosition(this.matrixWorld),ON.setFromRotationMatrix(this.matrixWorld),RN.copy(this.up).applyQuaternion(ON).negate().multiplyScalar(this.distance),this.target.position.copy(DN).add(RN),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),sh=j(()=>{Be(),Qh(),ht(),bo(),kc(),CW(),nD(),_D(),Ui(),Rm(),ht(),d0(),Dm(),DW(),wD(),Ni(),vT(),Or=class extends uD(Ku){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new j8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ea.getDensity({}),this.fogHeightFalloff=ea.getHeightFalloff({}),this.fogHeightBase=ea.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ae,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new Us(l0,{...rS.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new X5(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),e.uiScene){let r=rj();r===null?On("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(t)?t[0]:t)+"-ui",e.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else e.uiFrame&&this.createUICanvas(e.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(t,e){let i=rj();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,e),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(t),this.uiCanvas?.applySize()})):On("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(t,e){t.color!==void 0&&(this.ambientLight.color=wa(t.color,e)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity*Math.PI),t.enabled!==void 0&&(t.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(t){this.isActive=!0,t.fog=this.fog,this.traverseEntity(e=>{e instanceof _m&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof vo)if(Array.isArray(t.material))for(let e of t.material)e.needsUpdate=!0;else t.material.needsUpdate=!0,t.material.dispose()})}updateShadow(t){if(t.softShadowQuality===void 0&&t.type===void 0||!this.isActive)return;let e=this.data.shadow;pv.isSoft(e)}updateFog(t,e){t.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=wa(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ea.getMode(t),this.fogDensity=ea.getDensity(t),this.fogHeightFalloff=ea.getHeightFalloff(t),this.fogHeightBase=ea.getHeightBase(t)}updateSky(t,e){this.skyState=t??null,this.skyStateVersion++;let i=t?.hdri?.image;this.skyHdriHolder=i!=null?e.image(i):null}updateAo(t,e){t.aoColor!==void 0&&(this.aoColor=wa(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;er(t.path,["fog"])?this.updateFog(n.fog,i.shared):er(t.path,["sky"])?this.updateSky(n.sky,i.shared):er(t.path,["grading"])?this.gradingState=n.grading??null:er(t.path,["ao"])?this.updateAo(n.ao,i.shared):er(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):er(t.path,["shadow"])?this.updateShadow(n.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||s!==n.uiFrame)&&this.updateUIFrame(t.props.uiFrame,i)}updateUIFrame(t,e){t?(this.uiCanvas||this.createUICanvas(t,e),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(t)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(t,e){this.updateState_Entity(t,e),t.backgroundColor!==void 0&&this.setBackgroundColor(wa(t.backgroundColor,e.shared)),t.fog!==void 0&&this.updateFog(t.fog,e.shared),t.sky!==void 0&&this.updateSky(t.sky,e.shared),t.grading!==void 0&&(this.gradingState=t.grading),t.ambient!==void 0&&this.updateAmbientLight(t.ambient,e.shared),t.ao!==void 0&&this.updateAo(t.ao,e.shared),t.shadow!==void 0&&this.updateShadow(t.shadow)}createFrame(t,e){}raycast(t,e){super.raycast(t,e)}switchActiveCamera(t){t instanceof Us&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){let t=this.scene?.find(this.data.publish.playCamera);return t instanceof Us?t:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(tj).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof ob&&i.visible&&t<JP&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof lb&&i.visible&&t<tj-JP&&(this.penumbraSizeArrayCache[JP+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;xi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||n5(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),Uj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function VZ(){return OW}function IN(){if(Gj===null)throw new Error('[spe] Classic (WebGL) particles are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return Gj}function NN(t){return t?.isWebGPUSplineRenderer===!0}var OW,Gj,byt=j(()=>{OW=null,Gj=null});function Wj(){return NW}var IW,NW,BW=j(()=>{IW=null,NW=null});function zZ(t,e,i){return d2.setRGB(t,e,i,ks),{r:d2.r,g:d2.g,b:d2.b}}function BCt(t,e,i){let r,s=XS(t.angle,0),[n,a]=qj(t.offset),[o,l]=qj(t.morph),h=t.colors??[],u=t.steps??[],d=Math.min(10,h.length,u.length);if(d===0)return[1,1,1,1];if(t.gradientType===1){let g=3*(e+o)-(e+n)-1,y=3*(i+l)-(i+a)-1;r=Math.hypot(g,y)+s}else if(t.gradientType===2){let g=-1*Math.atan2(e+o-.5+n,i+l-.5+a),y=s/Math.PI/-2+.5*g/Math.PI;r=y-Math.floor(y)}else{let g=.5+o/(e!==0?e:1e-6),y=l/(i!==0?i:1e-6),v=Math.cos(s)*g-Math.sin(s)*y,b=Math.sin(s)*g+Math.cos(s)*y,_=v*v+b*b;r=_>1e-12?(((e-.5+n)/2+v/2)*v+((i-.5+a)/2+b/2)*b)/_:0}let c=h[0][0],p=h[0][1],m=h[0][2],f=h[0][3];for(let g=1;g<d;g++){let y=u[g-1],v=u[g]-y,b=v!==0?Math.min(1,Math.max(0,(r-y)/v)):r>=y?1:0;t.smooth&&(b=b*b*(3-2*b)),c+=(h[g][0]-c)*b,p+=(h[g][1]-p)*b,m+=(h[g][2]-m)*b,f+=(h[g][3]-f)*b}return[c,p,m,f]}function kCt(t,e){let i=t,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let s=e,n=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=XS(o.alpha,1);if(!(l<=0))if(o.type==="color"){let h,u=o.color;typeof u=="string"?h=typeof s?.color=="function"?s.color(u):void 0:u&&typeof u.r=="number"&&(h=u),h&&n.push({kind:"color",layer:o,rgb:{...zZ(h.r,h.g,h.b),a:h.a??1},alpha:l})}else o.type==="gradient"&&n.push({kind:"gradient",layer:o,alpha:l})}),n.length===0?null:(a,o)=>{let l=1,h=1,u=1,d=!0;for(let c of n){let p,m,f,g;if(c.kind==="color")({r:p,g:m,b:f}=c.rgb),g=c.rgb.a;else{let[v,b,_,x]=BCt(c.layer,a,o);({r:p,g:m,b:f}=zZ(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,h+=(m-h)*y,u+=(f-u)*y,d=!1}return{r:l,g:h,b:u}}}if(i?.color&&i.color.isColor===!0){let{r:s,g:n,b:a}=i.color;return()=>({r:s,g:n,b:a})}return null}var d2,XS,qj,VCt=j(()=>{ht(),d2=new ae,XS=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,qj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function zCt(t,e){if(t==="torus"){let l=e()*Math.PI*2,h=e()*Math.PI*2,u=Math.cos(l),d=Math.sin(l),c=Math.cos(h),p=Math.sin(h);return{x:(1.4+.7*c)*u,y:-(1.4+.7*c)*d,z:.7*p,nx:c*u,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,h=Math.cos(l),u=Math.sin(l);return{x:.8*h,y:1.6*(e()-.5),z:.8*u,nx:h,ny:0,nz:u,cr:1,cg:1,cb:1}}let i=e()*Math.PI*2,r=2*e()-1,s=Math.acos(r),n=Math.sin(s)*Math.cos(i),a=Math.cos(s),o=Math.sin(s)*Math.sin(i);return{x:n,y:a,z:o,nx:n,ny:a,nz:o,cr:1,cg:1,cb:1}}function LCt(t){let{geometry:e,matrix:i}=t,r=e.getAttribute("position");if(!r||r.count<3)return null;let s=e.getAttribute("normal"),n=e.getAttribute("uv"),a=e.getAttribute("color"),o=e.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let h=(y,v)=>o?o.getX(3*y+v):3*y+v,u=i?i.elements:null,d=i?new As().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[0]*v+u[4]*b+u[8]*_+u[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[1]*v+u[5]*b+u[9]*_+u[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[2]*v+u[6]*b+u[10]*_+u[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=h(y,0),b=h(y,1),_=h(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,C=p(b)-S,M=m(b)-w,A=c(_)-x,R=p(_)-S,I=m(_)-w,O=C*I-M*R,B=M*A-T*I,V=T*R-C*A;g+=.5*Math.sqrt(O*O+B*B+V*V),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let X=b+_>>1;f[X]<y?b=X+1:_=X}let x=b,S=h(x,0),w=h(x,1),T=h(x,2),C=v(),M=v();C+M>1&&(C=1-C,M=1-M);let A,R,I,O=1-C-M,B=c(S)*O+c(w)*C+c(T)*M,V=p(S)*O+p(w)*C+p(T)*M,z=m(S)*O+m(w)*C+m(T)*M;if(s){if(A=s.getX(S)*O+s.getX(w)*C+s.getX(T)*M,R=s.getY(S)*O+s.getY(w)*C+s.getY(T)*M,I=s.getZ(S)*O+s.getZ(w)*C+s.getZ(T)*M,d){let X=d[0]*A+d[3]*R+d[6]*I,nt=d[1]*A+d[4]*R+d[7]*I,st=d[2]*A+d[5]*R+d[8]*I;A=X,R=nt,I=st}}else{let X=c(S),nt=p(S),st=m(S),yt=c(w)-X,pt=p(w)-nt,Q=m(w)-st,ut=c(T)-X,wt=p(T)-nt,St=m(T)-st;A=pt*St-Q*wt,R=Q*ut-yt*St,I=yt*wt-pt*ut}let k=Math.sqrt(A*A+R*R+I*I)||1,L=1,H=1,W=1;if(a)L=a.getX(S)*O+a.getX(w)*C+a.getX(T)*M,H=a.getY(S)*O+a.getY(w)*C+a.getY(T)*M,W=a.getZ(S)*O+a.getZ(w)*C+a.getZ(T)*M;else if(t.sampleColor){let X=n?n.getX(S)*O+n.getX(w)*C+n.getX(T)*M:.5,nt=n?n.getY(S)*O+n.getY(w)*C+n.getY(T)*M:.5,st=t.sampleColor(X,nt);st&&(L=st.r,H=st.g,W=st.b)}return{x:B,y:V,z,nx:A/k,ny:R/k,nz:I/k,cr:L,cg:H,cb:W}}}}function LZ(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),_v),i=function(l){let h=l>>>0;return()=>{h|=0,h=h+1831565813|0;let u=Math.imul(h^h>>>15,1|h);return u=u+Math.imul(u^u>>>7,61|u)^u,((u^u>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Fh:Fh,n=new Float32Array(4*sc),a=new Float32Array(sc),o=new Float32Array(4*_v).fill(1);for(let l=0;l<e;l++){let h=r?t.sampler(i):zCt(t.shape,i),u=r?h.x:h.x*s,d=r?h.y:h.y*s,c=r?h.z:h.z*s,{nx:p,ny:m,nz:f}=h;o[4*l+0]=h.cr,o[4*l+1]=h.cg,o[4*l+2]=h.cb;let g,y,v,b=l*Tg,_=(1.8+.8*i())*t.hairLength*s/(Tg-1),x=.5+1.5*i(),S=(.02+.06*i())*s;Math.abs(m)<.99?(g=-f,y=0,v=p):(g=1,y=0,v=0);let w=Math.sqrt(g*g+y*y+v*v)||1;for(let T=0;T<Tg;T++){let C=T/(Tg-1),M=C*C*.4*s,A=S*Math.sin(C*x*Math.PI*2),R=4*(b+T);n[R+0]=u+p*_*T+A*g/w,n[R+1]=d+m*_*T-M+A*y/w,n[R+2]=c+f*_*T+A*v/w,n[R+3]=T===0?0:1,T<Tg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var Tg,_v,sc,Fh,Hp,b_,X0,cf,Y0,lR,_yt=j(()=>{ht(),sc=(_v=16384)*(Tg=32),Fh=100}),xyt=j(()=>{ht(),oa(),BW(),VCt(),_yt(),Hp=1/60,b_=new xt,X0=new Te,cf=new P,Y0=new P,lR=class extends Fs{constructor(t,e,i){super(t,e),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.settledSimSeconds=0,this.lastMotionFingerprint=0,this.lastBoneQuat=new Te,this.lastBonePos=new P,this.hasLastBone=!1,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=i,this.data=e,this.geometry.setAttribute("position",new _e(new Float32Array(0),3)),this.material=new jo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new yr(new Ec(Fh,48,32),new jo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new g4;r.setAttribute("position",new _e(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new yr(r,new jo({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=e.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:e.guideStrands,hairLength:e.hairLength,spreadRadius:e.spreadRadius,headShape:e.headShape,baseObjectId:e.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(t){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+t/1e3,4*Hp*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(X0,cf);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(X0))<.9999995||this.lastBonePos.distanceToSquared(cf)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(X0),this.lastBonePos.copy(cf),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+t}motionFingerprint(){let t=this.data;return t.gravity+2*t.damping+3*t.localStiffness+4*t.globalStiffness+5*t.globalRange+6*t.stiffnessFalloff+7*t.windStrength+8*t.vspCoefficient+9*t.kink+10*t.kinkFrequency+11*t.clumpStrength+12*t.clumpSize+13*t.clumpTipScale}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>6}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(t){this.playModeActive=t,t&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(t,e){super.updateState(t,e),this.updateHairState(t)}updateHairState(t){if((t.guideStrands!==void 0||t.hairLength!==void 0||t.spreadRadius!==void 0||t.headShape!==void 0||t.baseObjectId!==void 0)&&this.regenerate(),(t.headShape!==void 0||t.baseObjectId!==void 0)&&this.applyScalpState(),t.headColor!==void 0){let e=this.scalpMesh.material;e.isMeshBasicMaterial===!0&&e.color.setRGB(t.headColor.r,t.headColor.g,t.headColor.b,ks)}(t.castShadow!==void 0||t.receiveShadow!==void 0)&&this.applyShadowState(),t.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let t=this.data.castShadow??!0,e=this.data.receiveShadow??!0;this.castShadow=t,this.receiveShadow=e,this.scalpMesh.castShadow=t,this.scalpMesh.receiveShadow=e,this.ribbonMesh.castShadow=t,this.ribbonMesh.receiveShadow=e}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let t=this.data,e=this.regenSnapshot;if(e===null||e.guideStrands!==t.guideStrands||e.hairLength!==t.hairLength||e.spreadRadius!==t.spreadRadius||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId){let i=e===null||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:t,baseObjectId:e,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,t==="object"&&e){let s=this.context.scene.find(e);if(s){this.baseFoundAtRegen=!0,s.updateWorldMatrix(!0,!0);let n=this.collectBaseSources(s),a=n?function(o){let l=[];for(let d of o){let c=LCt(d);c&&l.push(c)}if(l.length===0)return null;let h=new Float64Array(l.length),u=0;for(let d=0;d<l.length;d++)u+=l[d].total,h[d]=u;return u<=0?null:d=>{let c=d()*u,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;h[g]<c?p=g+1:m=g}let f=p===0?c:c-h[p-1];return l[p].sample(f,d)}}(n.sources):null;if(this.baseSourceGeomsAtRegen=n?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=n?.hashes??[],this.baseColorHashAtRegen=n?.colorHash??0,n&&a){let o=this.baseWorldScale(s),l=Math.max(n.radius*o,.001);this.baseScaleAtRegen=o;let h=o;return LZ({shape:"object",guideStrands:i,hairLength:r,sampler:u=>{let d=a(u);return{...d,x:d.x*h,y:d.y*h,z:d.z*h}},samplerRadius:l})}}}return LZ({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;b_.copy(t.matrixWorld).invert();let n=b_.clone(),a=o=>{if(o.isHairSystem===!0||o!==t&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let h=o===t?void 0:new xt().multiplyMatrices(n,o.matrixWorld),u=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:h,sampleColor:kCt(u,this.context.shared)??void 0}),i.push(lR.matrixHash(h)),s+=function(c,p){let m=c,f=0,g=1,y=b=>{f+=b*g,g+=1},v=m?.data?.layers;if(v&&typeof v.forEach=="function"){let b=p;v.forEach(_=>{let x=_.data;if(x.visible!==!1){if(x.type==="color"){let S=x.color,w=typeof S=="string"?typeof b?.color=="function"?b.color(S):void 0:S;w&&typeof w.r=="number"&&(y(w.r),y(w.g),y(w.b)),y(XS(x.alpha,1))}else if(x.type==="gradient"){let S=x;for(let w of S.colors??[])y(w[0]),y(w[1]),y(w[2]),y(w[3]);for(let w of S.steps??[])y(w);y(XS(S.angle,0)),y(S.gradientType),y(S.smooth?1:0)}}})}else m?.color&&m.color.isColor===!0&&(y(m.color.r),y(m.color.g),y(m.color.b));return f}(u,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;h?(cf.copy(d.center).applyMatrix4(h),c=cf.length(),p=lR.matrixMaxScale(h)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let h of o.children)a(h)};return a(t),e.length===0?null:{sources:e,hashes:i,radius:Math.max(r,.001),colorHash:s}}static matrixHash(t){if(!t)return 0;let e=t.elements,i=0;for(let r=0;r<16;r++)i+=e[r]*(r+1);return i}static matrixMaxScale(t){let e=t.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);return Math.max(i,r,s,1e-6)}baseWorldScale(t){return b_.copy(t.matrixWorld).decompose(cf,X0,Y0),Math.max(Math.abs(Y0.x),Math.abs(Y0.y),Math.abs(Y0.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let t=this.context.scene.find(this.data.baseObjectId);if(!t)return;if(!this.baseFoundAtRegen)return void this.regenerate();t.updateWorldMatrix(!0,!0);let e=this.collectBaseSources(t),i=e?.sources??[],r=e?.hashes??[],s=this.baseSourceGeomsAtRegen,n=this.baseSourceHashesAtRegen,a=i.length!==s.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==s[o]||Math.abs(r[o]-n[o])>1e-4*Math.max(Math.abs(n[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(e?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(t);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let t=this.data.headShape,e=t==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!e,!e&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=t==="torus"?new f4(1.4*Fh,.7*Fh,24,48):t==="cylinder"?new K2(.8*Fh,.8*Fh,1.6*Fh,48,1):new Ec(Fh,48,32))}boneTransform(t,e){let i=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let r=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;r&&(i=r)}b_.copy(i).decompose(e,t,Y0)}raycast(t,e){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(t,i);for(let r of i)r.object=this,e.push(r)}get shadowBoundsRadius(){let t=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(t+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(t){return this.boneTransform(X0,t),t}updateEntityBoxSize(t,e){let i=this.shadowBoundsRadius;t.set(0,0,0),e.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),Wj()?.release(this)}}});function hR(){return{shapeInput:()=>`
368
368
  const float posRowCoord = ${.5/pc};
369
369
  const float quatRowCoord = ${1.5/pc};
370
370
  const float param1RowCoord = ${2.5/pc};
@@ -1561,7 +1561,7 @@ function sortWorker(self) {
1561
1561
  gl_FragColor = vec4(color.rgb, A);
1562
1562
  gVelocity = vec4(0.0);
1563
1563
  }`,transparent:!0,alphaTest:1,blending:Uh,depthTest:!0,depthWrite:!1,side:Rn})}static buildGeomtery(t){let e=new ye;e.setIndex([0,1,2,0,2,3]);let i=new Float32Array(12),r=new _e(i,3);e.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new g4().copy(e),n=new Uint32Array(t),a=new mo(n,1,!1);return a.setUsage(Yh),s.setAttribute("splatIndex",a),s.instanceCount=t,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(6*this.splatCount),this.colors=new Uint8Array(4*this.splatCount),this.centers=new Float32Array(3*this.splatCount);let t=0,e=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(t,t+4*s).set(r.colorsA),t+=4*s,this.centers.subarray(e,e+3*s).set(r.decoded.xyz.denormDequant().data),e+=3*s,this.covariances.subarray(i,i+6*s).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=6*s}}allocateAndStoreLocalSplatDataInTextures(){let t=this.splatCount,e=new Z(4096,1024);for(;e.x*e.y*2<6*t;)e.y*=2;let i,r,s=new Z(4096,1024);for(;s.x*s.y*4<4*t;)s.y*=2;if(this.halfPrecisionCovariancesOnGPU){r=new Uint16Array(e.x*e.y*2);for(let h=0;h<this.covariances.length;h++)r[h]=Kh.toHalfFloat(this.covariances[h]);i=new vr(r,e.x,e.y,ko,ai)}else r=new Float32Array(e.x*e.y*2),r.set(this.covariances),i=new vr(r,e.x,e.y,ko,Qe);i.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=i,this.material.uniforms.covariancesTextureSize.value.copy(e);let n=new Uint32Array(s.x*s.y*4);for(let h=0;h<t;h++){let u=4*h,d=3*h,c=4*h;n[c]=e1t(this.colors[u],this.colors[u+1],this.colors[u+2],this.colors[u+3]),n[c+1]=pR(this.centers[d]),n[c+2]=pR(this.centers[d+1]),n[c+3]=pR(this.centers[d+2])}let a=new vr(n,s.x,s.y,_G,Cn);e5()!=="webgpu"&&(a.internalFormat="RGBA32UI"),a.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=a,this.material.uniforms.centersColorsTextureSize.value.copy(s);let o=new Float32Array(4096);for(let h=0;h<this.meshMatrixWorlds.length;h++)o.set(this.meshMatrixWorlds[h].elements,16*h);let l=new vr(o,1024,1,ln,Qe);l.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=l,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:r,texture:i,size:e},centerColors:{data:n,texture:a,size:s},meshMatrixWorlds:{data:o,texture:l}}}updateIndexes(t){let e=this.geometry;e.attributes.splatIndex.set(t),e.attributes.splatIndex.needsUpdate=!0,e.instanceCount=t.length}updateUniforms(t,e,i,r){this.splatCount>0&&(S_.set(t.x*this.devicePixelRatio,t.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(S_),this.material.uniforms.basisViewport.value.set(2/S_.x,2/S_.y),this.material.uniforms.focal.value.set(e,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}}});function cEt(){if(!t9)return tQ||(tQ=async function(){let t=await Promise.resolve().then(()=>(zH(),VH));s1t(t),t9=!0}())}var s1t,n1t,t9,tQ,eQ,a1t,o1t,QN,Vg,l1t=j(()=>{n1t=new Promise(t=>{s1t=t}),t9=!1}),pEt=j(()=>{uEt(),ht(),r1t(),l1t(),n1t.then(t=>eQ=t),a1t=class{constructor(t={}){fc(this,"updateView",function(){let e=new xt,i=[],r=new P(0,0,-1),s=new P(0,0,-1),n=new P,a=new P;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(l.quaternion);let c=!1,p=!1;if(s.dot(r)<=.95&&(c=!0),a.copy(l.position).sub(n).length()>=1&&(p=!0),!(c||p||h||u||this.needsInitialRender))return}this.needsInitialRender=!1,n.copy(l.position),r.copy(s),e.copy(l.matrixWorld).invert(),e.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:e.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}()),this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new xt().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let i=new Z;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(t.getSize(i),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new P().fromArray(t.position)),t.orientation&&(t.orientation=new Te().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(n=>{n.data.type==="Splat"&&e.push(n)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(n=>n.matrixWorld),this.meshMatrixWorldsOld=e.map(n=>n.matrixWorld.clone()),this.cropsArray=e.map(n=>n.data.crops.map(a=>a.data)),this._splatBufferCache??(this._splatBufferCache=new WeakMap);let i=e.map(n=>{let a=this._splatBufferCache.get(n.data.buffer);return a===void 0&&(a=new eQ.GSplineBuffer(new Uint8Array(n.data.buffer).buffer),this._splatBufferCache.set(n.data.buffer,a)),a}),r=0,s=[0];for(let n of i)r+=n.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,16*e);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,!this.meshMatrixWorlds.every((e,i)=>e.equals(this.meshMatrixWorldsOld[i]))&&(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,i)=>{e.data.crops.forEach((r,s)=>{this.cropsArray[i][s]===void 0?(t=!0,this.cropsArray[i][s]=r.data):Object.entries(r.data).forEach(([n,a])=>{(Array.isArray(a)&&a.some((o,l)=>o!==this.cropsArray[i][s][n][l])||a!==this.cropsArray[i][s]?.[n])&&(t=!0,this.cropsArray[i][s][n]=a)})}),e.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,i=new P,r=new Te,s=!1,n=1,a,o){this.splatMesh=v2.buildMesh(t,e,s,n,a,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(l,h,u)=>this.update(l,u)}setupSortWorker(t){this.sortWorker=function(e){let i=new Worker(URL.createObjectURL(new Blob(["(",t1t,")(self)"],{type:"application/javascript"}))),r=atob(Jyt),s=new Uint8Array(r.length);for(let n=0;n<r.length;n++)s[n]=r.charCodeAt(n);return i.postMessage({init:{sorterWasmBytes:s.buffer,splatCount:e,Constants:{BytesPerFloat:dm.BytesPerFloat,BytesPerInt:dm.BytesPerInt,DepthMapRange:dm.DepthMapRange,MemoryPageSize:dm.MemoryPageSize}}}),i}(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}}}),HW=j(()=>{ht(),Qh(),bo(),Dm(),Be(),$yt(),Ui(),DW(),AW(),oa(),vT(),aEt(),dD(),_o(),ts(),sh(),Uyt(),ts(),un(),ib(),oEt(),pEt(),(o1t=new jo).wireframe=!0,QN=new P,Vg=class extends Ku{constructor(t,e){super(),this.data=t,this.sharedAssets=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this._normalPassNeeds={outline:!1,cavity:!1},this._needsReflection=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.hairInstances=[],this.shadowsDirty=!0,this.instanceGroupsDirty=!0,this._autoInstancing=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new Qyt,this.invisibleObjects=new Lu("jflkdsafjasdifjaslk",{...z4.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(t,e),this.matrixAutoUpdate=!1,this.errorPage=new Or("fdasfa",{...Hg.defaultData,name:""},{shared:e,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markShadowsDirty(){this.shadowsDirty=!0}markInstanceGroupsDirty(){this.instanceGroupsDirty=!0}get autoInstancing(){return this._autoInstancing}updateInstanceGroups(t,e){let i=this._autoInstancing;(i===null||i.minGroupSize!==e)&&(i?.dispose(),i=new Hyt(e),this._autoInstancing=i);let r=this.instanceGroupsDirty;return this.instanceGroupsDirty=!1,i.update(t,r),i.stats}releaseInstanceGroups(){this._autoInstancing?.teardown(),this.instanceGroupsDirty=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this.shadowsDirty=!0,this.instanceGroupsDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=function(t){let e=!1;return t.traverseEntity(i=>{if(i instanceof vo)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)BZ(i,i.material[r])&&(e=!0);else BZ(i,i.material)&&(e=!0)}),e}(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._normalPassNeeds=function(t){let e={outline:!1,cavity:!1},i=r=>{e.outline=e.outline||r.outline,e.cavity=e.cavity||r.cavity};return t.traverseEntity(r=>{if(r instanceof vo)if(Array.isArray(r.material))for(let s=0;s<r.material.length;s++)i(NZ(r,r.material[s]));else i(NZ(r,r.material))}),e}(this),this._needsNormal=this._normalPassNeeds.outline||this._normalPassNeeds.cavity,this.needsNormalDirty=!1),this._needsNormal}normalPassNeeds(){return this.needsNormal(),this._normalPassNeeds}needsReflection(){return this.needsReflectionDirty&&(this._needsReflection=function(t){let e=!1;return t.traverseEntity(i=>{if(i instanceof vo)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)kZ(i,i.material[r])&&(e=!0);else kZ(i,i.material)&&(e=!0)}),e}(this),this.needsReflectionDirty=!1),this._needsReflection}registerInstanceAndSetUuid(t){let e=t.identity.join("-"),i=this.entityIdentityToEntity[e];i&&(t.uuid=i.uuid),this.entityIdentityToEntity[e]=t,this.entityByUuid[t.uuid]=t}markPenumbraSizeDirty(){for(let t of this.children)t instanceof Or&&(t.penumbraSizeArrayCache=null)}findInstance(t){return this.entityIdentityToEntity[t.join("-")]}findInInstance(t,e){let i=e??null;if(!xi.is(i))return;let r=i.data.type==="Instance";if(!r&&!i.isVirtualEntity)return;let s=typeof i.identity=="string"?[i.identity]:i.identity;for(let n=s.length-(r?0:1);n>=1;n--){let a=this.findInstance([...s.slice(0,n),t]);if(a)return a}for(let n=i;xi.is(n);n=n.parent)if(n.data.type==="Instance"&&n.data.component===t)return n}findFrom(t,e){return this.findInInstance(t,e)??this.find(t)}syncInstancePathConstraint(t){let e=t.data.pathSnapping?.pathId;if(e){let i=this.findFrom(e,t);this.pathConstraints.setConstraint(t.uuid,i?.uuid??e)}else this.pathConstraints.removeDependencies(t.uuid)}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let i=[],r=e;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:e,sortKey:i}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push(r)}return e.sort((i,r)=>y4(i.sortKey,r.sortKey)),e.map(i=>i.entity)}nonExistOrDescendantOf(t,e){let i=this.find(t);if(i===void 0)return!0;for(;i;){if(i.uuid===e)return!0;i=i.parent}return!1}find(t){if(this.activePage&&this.activePage.personalCamera.parent){if(t==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(t===l0)return this.activePage.personalCamera}if(t===""||t===void 0)return;let e=this.entityByUuid[t];return e===void 0?this.getObjectByProperty("uuid",t):e}find2D(t){for(let e of this.children)if(e instanceof Or&&e.uiScene){let i=e.uiScene.find(t);if(i)return i}}findScene2DfromObject2D(t){for(let e of this.children)if(e instanceof Or&&e.uiScene&&e.uiScene.find(t))return e.uiScene}find2DInUIObjects(t){let e;return this.traverseEntity(i=>{e===void 0&&Ya(i)&&(e=i.uiCanvas.find(t))}),e}traverse2D(t){for(let e of this.children)e instanceof Or&&e.uiScene&&e.uiScene.traverse(t)}debugEnsureEntity(t){let e=this.find(t);e?Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0&&console.error("not found instance"):console.error("not found")}addPendingExpandCloner(t){this.toExpandCloner.add(t)}addPendingUpdateCloner(t){this.toUpdateCloner.add(t)}markToExpandCloner(t){this.toExpandCloner.add(t),t.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(t){this.toExpandCloner.forEach(e=>{e.expandCloner(t)}),this.toExpandCloner.clear()}doPendingUpdateCloner(t){this.toUpdateCloner.forEach(e=>{e.cloner?.update(t)}),this.toUpdateCloner.clear()}doPendingUpdates(t){this.doPendingExpandCloner(t),this.doPendingUpdateCloner(t),this.applyPendingCommands()}addPendingCommand(t){this.pendingCommands.push(t)}applyPendingCommands(){this.pendingCommands.forEach(t=>t()),this.pendingCommands.length=0}updateByLibOp(t,e){t.path.length===1&&t.path[0]==="components"&&t.type===1&&this.createChildrenObjects([{...t.data.asset,id:t.id}],this.invisibleObjects,e)}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let i=t.parent===null?this:this.find(t.parent);if(i===void 0)throw new Error(`scene tree add: parent ${t.parent} not found for object ${t.id}`);let r=this.createObject(t.id,t.data,t.children,i,t.localIndex,e);r.updateVisible(this),r.resetBBoxNeedsUpdate(),Hh(r)&&$u(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(t.path.length===0&&t.type===8){let i=this.find(t.id);if(i===void 0)throw new Error(`scene tree delete: object ${t.id} not found`);i.traverseEntity(s=>{Ic(s)&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(n=>n!==s)),n0(s)&&(this.hairInstances=this.hairInstances.filter(n=>n!==s))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),$u(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Hh(i)&&(i.freeBooleanPointer(),r instanceof _m&&r.invalidateDownstreamBooleanData().recomputeBoolean()),oD(i)&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(t.path.length===0&&t.type===9){let i=this.find(t.id);if(i===void 0)throw new Error(`scene tree move: object ${t.id} not found`);this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=t.parent===null?this:this.find(t.parent);if(s===void 0)throw new Error(`scene tree move: new parent ${t.parent} not found for object ${t.id}`);s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=t.localIndex;s.children.splice(n,0,s.children.pop()),Hh(i)&&(i.invalidateUpstreamBooleanData(),$u(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof _m&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(t){this.shadowsDirty=!0,this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let e of this.children)e instanceof Or&&(e.visible=e.uuid===t,e.visible&&(this.activePage=e,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(t,e,i,r){if(this.shadowsDirty=!0,e.type===0){if(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),"visible"in e.props&&this.markPenumbraSizeDirty(),e.path.includes("overrides")&&"states"in e.props){let{rest:n}=e.props;e={...e,props:n},this.markNeedsRecomputeInstances()}e.path[0]==="pathSnapping"&&e.props.pathId!==void 0&&this.pathConstraints.setConstraint(t,e.props.pathId)}let s=this.find(t);if(s)try{(function(n,a,o,l){n.updateByOp(a,o,l,!1)})(s,e,i,{scene:this,shared:r}),s instanceof Ur&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}updateEntity2DByOp(t,e,i,r,s,n=[]){t.updateEntityByOp(e,i,r,s),this.traverseEntity(a=>{(Ya(a)||a instanceof Or)&&(n.includes(a.frameId??"")||a.frameId===e)&&a.updateEntity2DByOp(e,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(t){this.activePage.switchActiveCamera(t)}isInvisibleObjects(t){return t===this.invisibleObjects||t.hasAnccestor(this.invisibleObjects)}init(t,e){let i=Object.entries(e.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:e}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,e),this.createChildrenObjects(t.objects,this,e),this.updatePage(t.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(e,!0),this.traverseEntity(r=>{r instanceof Us&&r.updateUp()}),this.doPendingExpandCloner({scene:this,shared:e}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(t){t.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(t){xi.is(t)&&(t.data.type==="Component"&&this.markNeedsRecomputeInstances(),t.traverseAncestors(e=>{xi.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(t,e,i,r,s,n,a){if(t){let o=r.find(t);o&&o!==r&&s.forInstancesRec(l=>{l.data=_4(l.data,h=>{let u=h.events.data(a.id),d=l.goUp(n);if(d){let c=[...rft(d.identity),t].join("-"),p=this.entityIdentityToEntity[c];if(p){let m=p.uuid;Dn.zoom(u,e)[i]=m}else console.warn("cannot find instance")}}).data})}}rewriteActions(t,e,i,r,s,n){t.forEach(a=>{a.data.type==="Transition"||a.data.type==="Animation"&&a.data.object?this.relativeizeInner(a.data.object,[...e,a.id],"object",i,r,s,n):a.data.type==="Conditional"&&(this.rewriteActions(a.data.ifActions,[...e,a.id,"ifActions"],i,r,s,n),this.rewriteActions(a.data.elseActions,[...e,a.id,"elseActions"],i,r,s,n))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(t=>{if(tR(t)&&typeof t.identity=="string"&&t.data.type==="Component")return t.traverseEntity((e,i)=>{e.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(e.forInstancesRec(n=>{n.data=_4(n.data,a=>{n.isInstanceRoot||(a.events.delete(r.id),s=!0)}).data}),s===!1)for(let n of j4.list)this.rewriteActions(r.data.gameActions[n],["gameActions",n],t,e,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",t,e,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",t,e,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",t,e,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,t,e,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,t,e,i,r)),this.rewriteActions(r.data.inActions,["inActions"],t,e,i,r),this.rewriteActions(r.data.outActions,["outActions"],t,e,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],t,e,i,r)})}),!0})}expandInstances(t,e,i){let r=new Set;this.traverseEntity(s=>{if(tR(s)&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:t,pendingDeletes:r}),e||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(n=>{i.addClip(n)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),jW(s)}recomputeInstances(t,e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{tR(i)&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(t,!1,e))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(t){t.traverseEntity(e=>{let i=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[i]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[i],this.pathConstraints.removeDependencies(e.uuid)),e.dispose()})}clearScene(){this._autoInstancing?.dispose(),this._autoInstancing=null,this.instanceGroupsDirty=!0;for(let t of this.children)xi.is(t)&&t.disposeRecursively();this.children.length=0}resetAfterClear(t,e){this.init(t,e)}raycast(t){return this.raycast1(t,!1)}raycast1(t,e){let i=[],r=s=>{for(let n of s.children){let a=n.cloner;if(xi.is(n)&&!n.raycastLock&&(n.visible||a?.object.data.visible))if(e===!0&&n.isInstanceRoot){let o=[];if(t.intersectObject(n,!0,o),o.length){let l=o[0];l.object=n,l.point.applyMatrix4(l.object.matrixWorld);let h=n.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Hh(n)||n5(n)&&this.enableHelpers&&n.objectHelper.visible)&&(t.intersectObject(n,!1,i),Uj(n,t,i)),r(n)}};return r(this.activePage),i}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;xi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||n5(s)&&this.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),Uj(s,t,e,!0)),i(s))}};return i(this),e}forEachEntity(t){for(let e of this.children)xi.is(e)&&t(e)}traverseConcreteEntity(t){for(let e of this.children)xi.is(e)&&e.isConcreteEntity&&e.traverseEntity(t)}traverseEntity(t){for(let e of this.children)xi.is(e)&&e.traverseEntity(t)}updateFont(t,e){this.traverseEntity(i=>{if(i instanceof Ur&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===t){let r=i.geometry,s=i.data.geometry;r.updateFont(t,e).then(()=>{r.update(s,e);let n=i.invalidateDownstreamBooleanData();$u(n)&&n.recomputeBoolean()})}})}traverseObject(t){for(let e of this.children)Ng.is(e)&&e.traverseObject(t)}traverseVisibleEntity(t){for(let e of this.children)xi.is(e)&&e.visible&&e.traverseVisibleEntity(t)}dispose(){this.clearScene()}createChildrenObjects(t,e,i){let r=0;for(let s of t)this.createObject(s.id,s.data,s.children,e,r,i),r+=1}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let e of t.children)this.unregisterObject(e)}createObject(t,e,i,r,s,n){let a={scene:this,shared:n},o=qW(t,e,a);return Ic(o)&&this.shapeBlendIntances.push(o),n0(o)&&this.hairInstances.push(o),o&&(this.entityByUuid[t]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(e,a),o instanceof Ur&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),e.pathSnapping?.pathId&&this.pathConstraints.setConstraint(t,e.pathSnapping.pathId)),e.type==="Empty"&&e.animations&&o.traverseEntity(l=>{let h=l.dataPatched;if(l instanceof Ur&&h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),d=h.boneInverses.map(p=>new xt().fromArray(p)),c=new p4(u,d);l.bind(c,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(t){let e=[];for(let r=0,s=t.length;r<s;++r){let{id:n,recursive:a}=t[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;e.push(...l.vertices)}let i=new cr;return i.setFromPoints(e),i.getCenter(QN),QN}copyMatrixWorld(t,e){if(t===null)return void e.identity();let i=this.find(t);i?(i.updateWorldMatrix(!0,!1),e.copy(i.matrixWorld)):e.identity()}copyParentMatrixWorld(t,e){if(t===null)return void e.identity();let i=this.find(t)?.parent;i?(i.updateWorldMatrix(!0,!1),e.copy(i.matrixWorld)):e.identity()}traverseMaterial(t){this.traverseEntity(e=>{if(e instanceof Fs)if(Array.isArray(e.material))for(let i of e.material)r5(i)&&t(i);else r5(e.material)&&t(e.material)})}updateViewPlaneSize(t,e,i=!1){this.traverseConcreteEntity(r=>{r instanceof Us&&r.setViewplaneSize(t,e,i)})}initializeSplatViewer(){this.splatViewer=new a1t({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}}}),h1t={};function mEt(){let t,e;function i(r,s,n,a,o,l){let h=n.num_points(),u=l.num_components(),d=function(_,x){switch(x){case Float32Array:return _.DT_FLOAT32;case Int8Array:return _.DT_INT8;case Int16Array:return _.DT_INT16;case Int32Array:return _.DT_INT32;case Uint8Array:return _.DT_UINT8;case Uint16Array:return _.DT_UINT16;case Uint32Array:return _.DT_UINT32}}(r,o),c=u*o.BYTES_PER_ELEMENT,p=4*Math.ceil(c/4),m=p/o.BYTES_PER_ELEMENT,f=h*c,g=h*p,y=r._malloc(f);s.GetAttributeDataArrayForAllPoints(n,l,d,f,y);let v,b=new o(r.HEAPF32.buffer,y,f/o.BYTES_PER_ELEMENT);if(c===p)v=b.slice();else{v=new o(g/o.BYTES_PER_ELEMENT);let _=0;for(let x=0,S=b.length;x<S;x++){for(let w=0;w<u;w++)v[_+w]=b[x*u+w];_+=m}}return r._free(y),{name:a,count:h,itemSize:u,array:v,stride:m}}onmessage=function(r){let s=r.data;switch(s.type){case"init":t=s.decoderConfig,e=new Promise(function(o){t.onModuleLoaded=function(l){o({draco:l})},DracoDecoderModule(t)});break;case"decode":let n=s.buffer,a=s.taskConfig;e.then(o=>{let l=o.draco,h=new l.Decoder;try{let u=function(c,p,m,f){let g,y,v=f.attributeIDs,b=f.attributeTypes,_=p.GetEncodedGeometryType(m);if(_===c.TRIANGULAR_MESH)g=new c.Mesh,y=p.DecodeArrayToMesh(m,m.byteLength,g);else{if(_!==c.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");g=new c.PointCloud,y=p.DecodeArrayToPointCloud(m,m.byteLength,g)}if(!y.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());let x={index:null,attributes:[]};for(let S in v){let w,T,C=self[b[S]];if(f.useUniqueIDs)T=v[S],w=p.GetAttributeByUniqueId(g,T);else{if(T=p.GetAttributeId(g,c[v[S]]),T===-1)continue;w=p.GetAttribute(g,T)}let M=i(c,p,g,S,C,w);S==="color"&&(M.vertexColorSpace=f.vertexColorSpace),x.attributes.push(M)}return _===c.TRIANGULAR_MESH&&(x.index=function(S,w,T){let C=3*T.num_faces(),M=4*C,A=S._malloc(M);w.GetTrianglesUInt32Array(T,M,A);let R=new Uint32Array(S.HEAPF32.buffer,A,C).slice();return S._free(A),{array:R,itemSize:1}}(c,p,g)),c.destroy(g),x}(l,h,new Int8Array(n),a),d=u.attributes.map(c=>c.array.buffer);u.index&&d.push(u.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:u},d)}catch(u){console.error(u),self.postMessage({type:"error",id:s.id,error:u.message})}finally{l.destroy(h)}})}}}nT(h1t,{DRACOLoader:()=>d1t,DRACO_GLTF_CONFIG:()=>u1t});var cA,u1t,d1t,fEt=j(()=>{ht(),cA=new WeakMap,u1t={js:"",wasm:""},d1t=class extends ug{constructor(t){super(t),this.decoderPaths={js:"",wasm:"",dep_js:""},this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){let{decoderPaths:e}=this;return typeof t=="object"?(e.js=t.js,e.wasm=t.wasm,e.dep_js=null):(e.js=WP.resolveURL("draco_wasm_wrapper.js",t),e.wasm=WP.resolveURL("draco_decoder.wasm",t),e.dep_js=WP.resolveURL("draco_decoder.js",t)),this}setDecoderConfig(t){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,r){let s=new J2(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,n=>{this.parse(n,e,r)},i,r)}parse(t,e,i=()=>{}){this.decodeDracoFile(t,e,null,null,ks,i).catch(i)}decodeDracoFile(t,e,i,r,s=Yu,n=()=>{}){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(t,a).then(e).catch(n)}decodeGeometry(t,e){let i=JSON.stringify(e);if(cA.has(t)){let o=cA.get(t);if(o.key===i)return o.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,n=t.byteLength,a=this._getWorker(s,n).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),cA.set(t,{key:i,promise:a}),a}_createGeometry(t){let e=new ye;t.index&&e.setIndex(new _e(t.index.array,1));for(let i=0;i<t.attributes.length;i++){let r,{name:s,array:n,itemSize:a,stride:o,vertexColorSpace:l}=t.attributes[i];if(a===o)r=new _e(n,a);else{let h=new X1(n,o);r=new Wp(h,a,0)}s==="color"&&(this._assignVertexColorSpace(r,l),r.normalized=!(n instanceof Float32Array)),e.setAttribute(s,r)}return e}_assignVertexColorSpace(t,e){if(e!==ks)return;let i=new ae;for(let r=0,s=t.count;r<s;r++)i.fromBufferAttribute(t,r),Qi.colorSpaceToWorking(i,ks),t.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(t,e){let i=new J2(this.manager);return i.setResponseType(e),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(t,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[],{decoderPaths:i}=this;if(t){if(i.dep_js===null)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");e.push(this._loadLibrary(i.dep_js,"text"))}else e.push(this._loadLibrary(i.js,"text")),e.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(e).then(r=>{let s=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let n=mEt.toString(),a=["/* draco decoder */",s,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
1564
- `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),gEt=j(()=>{});function c1t(t){return function(e,{basePath:i,moduleUrl:r,cdnBuild:s}){if(i!==void 0)return{url:`${i}/${e}`};let n=`${s}/${e}`;if(r===void 0||r.startsWith("file:"))return{url:n};let a=r.slice(0,r.lastIndexOf("/")+1)+e;return a===n?{url:a}:{url:a,fallback:n}}(t,{basePath:p1t,moduleUrl:typeof import.meta.url=="string"?import.meta.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.121/build"})}function iQ(t,e){let{url:i,fallback:r}=c1t(e);r!==void 0&&t.addEventListener("error",()=>{t.src=r},{once:!0}),t.src=i}var p1t,$W=j(()=>{gEt()});function m1t(t,e){XW.set(t,e)}function rQ(t){return XW.get(t)}function sQ(t,e){let i=`${e}:${t}`;e9.has(i)||e9.add(i)}var XW,e9,YW=j(()=>{XW=new Map,e9=new Set});function JN(t,e=0){let i=3735928559^e,r=1103547991^e;if(Array.isArray(t))for(let s,n=0;n<t.length;n++)s=t[n],i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);else for(let s,n=0;n<t.length;n++)s=t.charCodeAt(n),i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function nQ(t){return S1t.get(t)}function pA(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function aQ(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?9:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new Ts)}function yEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?12:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new Ts)}function vEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)||/vec4/.test(t)?4:/mat2/.test(t)?2:/mat3/.test(t)||/mat4/.test(t)?4:void Xt(`TSL: Unsupported type: ${t}`,new Ts)}function Qc(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function tB(t,...e){let i=t?t.slice(-4):void 0;return e.length===1&&(i==="vec2"?e=[e[0],e[0]]:i==="vec3"?e=[e[0],e[0],e[0]]:i==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new ae(...e):i==="vec2"?new Z(...e):i==="vec3"?new P(...e):i==="vec4"?new Me(...e):i==="mat2"?new CG(...e):i==="mat3"?new As(...e):i==="mat4"?new xt(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?function(r){return Uint8Array.from(atob(r),s=>s.charCodeAt(0)).buffer}(e[0]):null}function oQ(t){let e=r9.get(t);return e===void 0&&(e={},r9.set(t,e)),e}function At(t,e){if(c5.has(t))ne(`TSL: Redefinition of method chaining '${t}'.`);else{if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);c5.set(t,e),t!=="assign"&&(Ee.prototype[t]=function(...i){return this.isStackNode?this.addToStack(e(...i)):e(this,...i)},Ee.prototype[t+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],e(...i)):this.assign(e(this,...i))})}}function mA(t,e,i){wv[t]=wv[e]=wv[i]={get(){this._cache=this._cache||{};let a=this._cache[t];return a===void 0&&(a=new s9(this,t),this._cache[t]=a),a},set(a){this[t].assign(ve(a))}};let r=t.toUpperCase(),s=e.toUpperCase(),n=i.toUpperCase();Ee.prototype["set"+r]=Ee.prototype["set"+s]=Ee.prototype["set"+n]=function(a){let o=n9(t);return new T1t(this,o,ve(a))},Ee.prototype["flip"+r]=Ee.prototype["flip"+s]=Ee.prototype["flip"+n]=function(){let a=n9(t);return new M1t(this,a)}}function lQ(t){return t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)}function Q0(t){return t&&t.isNode&&t.traverse(e=>{e.isConstNode&&(t=e.value)}),Boolean(t)}function J0(t,e){return new A1t(t,e)}function it(t,e=null){let i=new C1t(t,e);return new Proxy(()=>{},{apply:(r,s,n)=>i.call(...n),get:(r,s,n)=>Reflect.get(i,s,n),set:(r,s,n,a)=>Reflect.set(i,s,n,a)})}function fA(t){return ec&&ec.addToStack(t),t}function hQ(t,e,i=null){return nc(i,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(t):s})}function uQ(t,e=null){return nc(e,{getAO:(i,{material:r})=>r.transparent===!0?i:i!==null?i.mul(t):t})}function dQ(t,e){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),fR(t,e)}function cQ(t,e){let i=a9.get(t);return i===void 0&&(i=new X1(t,e),a9.set(t,i)),i}function gA(t,e=null,i=0,r=0,s=Cg,n=!1){return e==="mat3"||e===null&&t.itemSize===9?wn(new Zd(t,"vec3",9,0).setUsage(s).setInstanced(n),new Zd(t,"vec3",9,3).setUsage(s).setInstanced(n),new Zd(t,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&t.itemSize===16?ic(new Zd(t,"vec4",16,0).setUsage(s).setInstanced(n),new Zd(t,"vec4",16,4).setUsage(s).setInstanced(n),new Zd(t,"vec4",16,8).setUsage(s).setInstanced(n),new Zd(t,"vec4",16,12).setUsage(s).setInstanced(n)):new Zd(t,e,i,r).setUsage(s)}function pQ(t,e=!0){return ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),gg(t).setParent(e)}function mQ(t,e,i,r=U(0),s=U(1)){return o9(t,e,i,r,s,!0)}function fQ(t,e="",i=null){return(t=ve(t)).before(new E1t(t,e,i))}function bEt(t){ne("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}function gQ(t,e,i){let r;if(e.isStorageInstancedBufferAttribute===!0)r=Qd(e,"mat4",Math.max(i,1)).element(Kl);else if(16*i*4<=t.getUniformBufferLimit())r=Mg(e.array,"mat4",Math.max(i,1)).element(Kl);else{let s=p5.get(e);s||(s=new AG(e.array,16,1),p5.set(e,s));let n=e.usage===Yh?gR:b2,a=[n(s,"vec4",16,0),n(s,"vec4",16,4),n(s,"vec4",16,8),n(s,"vec4",16,12)];r=ic(...a)}return r}function i9(t,e,i,r,s,n){let a=t.element(s.x),o=t.element(s.y),l=t.element(s.z),h=t.element(s.w),u=i.mul(e),d=Is(a.mul(n.x).mul(u),o.mul(n.y).mul(u),l.mul(n.z).mul(u),h.mul(n.w).mul(u));return r.mul(d).xyz}function yQ(t,e,i,r,s,n,a){let o=t.element(n.x),l=t.element(n.y),h=t.element(n.z),u=t.element(n.w),d=Is(a.x.mul(o),a.y.mul(l),a.z.mul(h),a.w.mul(u));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(e).xyz,skinTangent:d.transformDirection(i).xyz}}function vQ(t,e,i,r,s){let n=t.skeleton,a=fS.get(n);if(a===void 0){n.update();let o=new Float32Array(n.boneMatrices);a={previousBoneMatrices:o,node:Mg(o,"mat4",n.bones.length)},fS.set(n,a)}return i9(a.node,Fp,e,i,r,s)}function f1t(t){let e=t.target;e.removeEventListener("dispose",f1t);let i=J1.get(e);i!==void 0&&(J1.delete(e),i.dispose())}function bQ(t,e){e===a4?t.mapping=jg:e===o4&&(t.mapping=j2)}function _Q(t,e,i){let r=new si(t,e,{magFilter:fe,minFilter:fe,generateMipmaps:!1,type:ai,format:ln,colorSpace:Yu,depthBuffer:i});return r.texture.mapping=G2,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function d5(t){let e=new Re;return e.depthTest=!1,e.depthWrite=!1,e.blending=dr,e.name=`PMREM_${t}`,e}function xQ(t){let e=d5("cubemap");return e.fragmentNode=Ha(t,gS),e}function wQ(t){let e=d5("equirect");return e.fragmentNode=Di(t,yR(gS),0),e}function SQ(t){return Object.freeze({isMaterial:!0,isDrawState:!0,id:t.id,name:t.name,type:t.type,transparent:t.transparent,blending:t.blending,premultipliedAlpha:t.premultipliedAlpha,blendSrc:t.blendSrc,blendDst:t.blendDst,blendEquation:t.blendEquation,blendSrcAlpha:t.blendSrcAlpha,blendDstAlpha:t.blendDstAlpha,blendEquationAlpha:t.blendEquationAlpha,blendColor:t.blendColor,blendAlpha:t.blendAlpha,colorWrite:t.colorWrite,depthWrite:t.depthWrite,depthTest:t.depthTest,depthFunc:t.depthFunc,stencilWrite:t.stencilWrite,stencilFunc:t.stencilFunc,stencilRef:t.stencilRef,stencilFail:t.stencilFail,stencilZFail:t.stencilZFail,stencilZPass:t.stencilZPass,stencilFuncMask:t.stencilFuncMask,stencilWriteMask:t.stencilWriteMask,side:t.side,wireframe:t.wireframe===!0,alphaToCoverage:t.alphaToCoverage,forceSinglePass:t.forceSinglePass,polygonOffset:t.polygonOffset,polygonOffsetFactor:t.polygonOffsetFactor,polygonOffsetUnits:t.polygonOffsetUnits})}function TQ(t,e){if(t===null||e===null)return t===e;for(let i in t)if(t[i]!==e[i])return!1;return!0}function g1t(t){return t.index!==null?t.index.version:t.attributes.position.version}function y1t(t){return t.index!==null?t.index.id:t.attributes.position.id}function MQ(t){let e=[],i=t.index,r=t.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],h=n[a+1],u=n[a+2];e.push(l,h,h,u,u,l)}}else for(let n=0,a=r.array.length/3-1;n<a;n+=3){let o=n+0,l=n+1,h=n+2;e.push(o,l,l,h,h,o)}let s=new(r.count>=65535?fm:G8)(e,1);return s.version=g1t(t),s.__id=y1t(t),s}function _Et(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?t.z-e.z:t.id-e.id}function AQ(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function CQ(t){return!!(t.transparent===!0||t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode||t.backdropNode&&t.backdropNode.isNode)}function EQ(t){return(t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode)&&t.side===Rn&&t.forceSinglePass===!1}function PQ(t,e=null,i=null){if(e&&e.isNode){let r=e;e=()=>r}return new QW(new Map([[t,e]]),i)}function RQ(t,e=null){let i=new Map;for(let[r,s]of t){let n=s!==null?typeof s=="function"?s:()=>s:null;i.set(r,n)}return new QW(i,e)}function DQ(t,e){for(let i=0;i<t.length;i++)if(t[i].name===e)return i;return-1}function xEt(t,e=null){return nc(e,{getUV:typeof t=="function"?t:()=>t})}function v1t(t){let e=b9.get(t);return e===void 0&&(e={},b9.set(t,e)),e}function OQ(t,e=0){let i=v1t(t),r=i[e];return r===void 0&&(i[e]=r=new xt,i[e].copy(t.matrixWorld)),r}function eB(t){let e,i=t.context.getViewZ;return i!==void 0&&(e=i(this)),(e||Ss.z).negate()}function AD(t){let e=(y6=y6||new WeakMap).get(t);return e===void 0&&y6.set(t,e={}),e}function mR(t){let e=AD(t);return e.shadowMatrix||(e.shadowMatrix=we("mat4").setGroup(Ce).onRenderUpdate(i=>((t.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(t.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(t.shadow.camera.coordinateSystem=i.camera.coordinateSystem,t.shadow.camera.updateProjectionMatrix()),t.shadow.updateMatrices(t)),t.shadow.matrix)))}function IQ(t,e=Ih){let i=mR(t).mul(e);return i.xyz.div(i.w)}function iB(t){let e=AD(t);return e.position||(e.position=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.matrixWorld)))}function NQ(t){let e=AD(t);return e.targetPosition||(e.targetPosition=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.target.matrixWorld)))}function rB(t){let e=AD(t);return e.viewPosition||(e.viewPosition=we(new P).setGroup(Ce).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new P,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}))}function KW(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new ae),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function b1t(t,e){return e=KW(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function _1t(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function ZW(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function x1t(t,e){return e=ZW(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function w1t(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function wEt(t,e,i={}){return ZW(e,i=KW(t,i))}function BQ(t,e,i){return x1t(e,i=b1t(t,i))}function kQ(t,e,i){_1t(t,i),w1t(e,i)}function VQ(t){return t+(ac-t%ac)%ac}function ty(){return xR===null&&((xR=new vr(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),xR}function du(t,e){wR[0]=e,t.queue.submit(wR),wR[0]=null}function zQ(t,e,i,r,s,n,a,o,l,h){Ma.texture=e,Ma.mipLevel=i,Ma.origin.z=r,ju.offset=r*n,ju.bytesPerRow=a,ju.rowsPerImage=o,Sa.width=l,Sa.height=h,t.queue.writeTexture(Ma,s.data,ju,Sa),Ma.reset(),ju.reset(),Sa.reset()}function sB(t,e){let i,r=t.format,s=t.type,n=t.normalized,a=t.colorSpace,o=Qi.getTransfer(a),l=!1;if(n&&(l=e.features.has(yS.TextureFormatsTier1),l===!1&&ne("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),t.isCompressedTexture===!0||t.isCompressedArrayTexture===!0)switch(r){case Apt:case Cpt:i=o===wr?tt.BC1RGBAUnormSRGB:tt.BC1RGBAUnorm;break;case Ept:i=o===wr?tt.BC2RGBAUnormSRGB:tt.BC2RGBAUnorm;break;case Ppt:i=o===wr?tt.BC3RGBAUnormSRGB:tt.BC3RGBAUnorm;break;case Jpt:i=tt.BC4RUnorm;break;case tmt:i=tt.BC4RSnorm;break;case wG:i=tt.BC5RGUnorm;break;case emt:i=tt.BC5RGSnorm;break;case Kpt:i=o===wr?tt.BC7RGBAUnormSRGB:tt.BC7RGBAUnorm;break;case Zpt:i=tt.BC6HRGBFloat;break;case Qpt:i=tt.BC6HRGBUFloat;break;case Dpt:case Rpt:i=o===wr?tt.ETC2RGB8UnormSRGB:tt.ETC2RGB8Unorm;break;case Opt:i=o===wr?tt.ETC2RGBA8UnormSRGB:tt.ETC2RGBA8Unorm;break;case Ipt:i=tt.EACR11Unorm;break;case Npt:i=tt.EACR11Snorm;break;case xG:i=tt.EACRG11Unorm;break;case Bpt:i=tt.EACRG11Snorm;break;case kpt:i=o===wr?tt.ASTC4x4UnormSRGB:tt.ASTC4x4Unorm;break;case Vpt:i=o===wr?tt.ASTC5x4UnormSRGB:tt.ASTC5x4Unorm;break;case zpt:i=o===wr?tt.ASTC5x5UnormSRGB:tt.ASTC5x5Unorm;break;case Lpt:i=o===wr?tt.ASTC6x5UnormSRGB:tt.ASTC6x5Unorm;break;case Fpt:i=o===wr?tt.ASTC6x6UnormSRGB:tt.ASTC6x6Unorm;break;case Upt:i=o===wr?tt.ASTC8x5UnormSRGB:tt.ASTC8x5Unorm;break;case jpt:i=o===wr?tt.ASTC8x6UnormSRGB:tt.ASTC8x6Unorm;break;case Gpt:i=o===wr?tt.ASTC8x8UnormSRGB:tt.ASTC8x8Unorm;break;case Wpt:i=o===wr?tt.ASTC10x5UnormSRGB:tt.ASTC10x5Unorm;break;case qpt:i=o===wr?tt.ASTC10x6UnormSRGB:tt.ASTC10x6Unorm;break;case Hpt:i=o===wr?tt.ASTC10x8UnormSRGB:tt.ASTC10x8Unorm;break;case $pt:i=o===wr?tt.ASTC10x10UnormSRGB:tt.ASTC10x10Unorm;break;case Xpt:i=o===wr?tt.ASTC12x10UnormSRGB:tt.ASTC12x10Unorm;break;case Ypt:i=o===wr?tt.ASTC12x12UnormSRGB:tt.ASTC12x12Unorm;break;case ln:i=o===wr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case ln:switch(s){case W2:i=tt.RGBA8Snorm;break;case q2:i=l?tt.RGBA16Snorm:tt.RGBA16Sint;break;case $1:i=l?tt.RGBA16Unorm:tt.RGBA16Uint;break;case Cn:i=tt.RGBA32Uint;break;case vl:i=tt.RGBA32Sint;break;case xl:i=o===wr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;case ai:i=tt.RGBA16Float;break;case Qe:i=tt.RGBA32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case l4:switch(s){case vG:i=tt.RGB9E5UFloat;break;case bG:i=tt.RG11B10UFloat;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Qa:switch(s){case W2:i=tt.R8Snorm;break;case q2:i=l?tt.R16Snorm:tt.R16Sint;break;case $1:i=l?tt.R16Unorm:tt.R16Uint;break;case Cn:i=tt.R32Uint;break;case vl:i=tt.R32Sint;break;case xl:i=tt.R8Unorm;break;case ai:i=tt.R16Float;break;case Qe:i=tt.R32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case ko:switch(s){case W2:i=tt.RG8Snorm;break;case q2:i=l?tt.RG16Snorm:tt.RG16Sint;break;case $1:i=l?tt.RG16Unorm:tt.RG16Uint;break;case Cn:i=tt.RG32Uint;break;case vl:i=tt.RG32Sint;break;case xl:i=tt.RG8Unorm;break;case ai:i=tt.RG16Float;break;case Qe:i=tt.RG32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case em:switch(s){case $1:i=tt.Depth16Unorm;break;case Cn:i=tt.Depth24Plus;break;case Qe:i=tt.Depth32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case lv:switch(s){case H2:i=tt.Depth24PlusStencil8;break;case Qe:e&&e.features.has(yS.Depth32FloatStencil8)===!1&&Xt('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=tt.Depth32FloatStencil8;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case h4:switch(s){case vl:i=tt.R32Sint;break;case Cn:i=tt.R32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case u4:switch(s){case vl:i=tt.RG32Sint;break;case Cn:i=tt.RG32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case _G:switch(s){case vl:i=tt.RGBA32Sint;break;case Cn:i=tt.RGBA32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}return i}var LQ,nB,aB,oB,FQ,UQ,Ts,pf,ey,iy,S1t,r9,mf,Ue,jQ,Fn,lB,T_,M_,ff,GQ,WQ,Ee,Jc,hB,Cr,qQ,HQ,s9,T1t,M1t,yA,uB,fh,$Q,ec,c5,XQ,n9,wv,gh,yh,vh,YQ,KQ,ZQ,dB,QQ,JQ,A1t,tJ,eJ,iJ,cB,vA,bA,_A,A_,C_,pB,xA,Hs,mB,ve,ry,E_,tp,ui,te,Wt,wA,rJ,C1t,sy,SA,Se,sJ,fB,U,J,jt,To,Kt,ss,TA,gB,rt,MA,ep,AA,he,CA,EA,yB,P_,wn,ic,vB,bB,nJ,aJ,Gi,cu,ip,Ei,rp,PA,bh,pu,R_,gf,Mo,yd,D_,O_,I_,N_,vd,ny,sp,bd,np,ap,B_,yf,op,ay,oJ,oy,k_,RA,DA,OA,IA,NA,_B,xB,BA,lJ,Ce,wB,ly,we,SB,TB,hJ,uJ,dJ,cJ,bs,Is,Mi,qe,Ao,V_,MB,AB,CB,kA,EB,PB,RB,DB,OB,IB,NB,BB,kB,VB,zB,LB,FB,UB,jB,GB,ct,z_,pJ,L_,mJ,fJ,gJ,WB,qB,HB,$B,VA,vf,F_,_h,ka,zA,xh,U_,ca,Nl,Va,XB,Bl,YB,KB,ZB,QB,JB,LA,tk,FA,ek,xr,UA,wh,jA,ik,GA,WA,rk,sk,qA,HA,nk,ak,ok,ao,ns,lp,lk,hk,uk,Zo,mu,Qo,$A,dk,XA,ck,pk,mk,fk,YA,vi,kl,j_,KA,Co,ZA,gk,yk,vk,bk,yJ,vJ,za,QA,nc,_k,fR,JA,t3,bJ,xk,wk,_J,hp,_d,Sk,Tk,Mk,e3,i3,xJ,G_,wJ,SJ,Ak,TJ,MJ,Ck,AJ,Ek,Pk,a9,Zd,r3,CJ,b2,gR,cs,Rk,Kl,EJ,PJ,RJ,Dk,DJ,s3,OJ,mS,gg,IJ,o9,n3,Eo,NJ,BJ,a3,Ok,kJ,Ik,VJ,zJ,Nk,E1t,Bk,La,Xi,up,o3,kk,l3,xd,LJ,Di,FJ,_s,UJ,jJ,GJ,h3,Mg,WJ,qJ,Un,fu,W_,q_,$r,u3,Vl,dp,cp,bf,d3,Vk,HJ,$J,c3,H_,p3,$_,m3,X_,f3,Y_,g3,K_,y3,Z_,v3,Q_,wd,Sd,Td,Fa,zk,Md,hy,XJ,Lk,YJ,Fk,Bi,KJ,ZJ,QJ,JJ,ttt,ett,zl,itt,Jo,rtt,stt,ntt,att,Uk,ott,Sh,jk,b3,_3,Gk,jn,Xr,Fp,Ih,x3,Ss,fr,Wk,w3,pp,ltt,J_,pa,qk,_f,Hk,Pi,Ad,Cd,$k,S3,htt,utt,dtt,T3,Xk,tx,ex,Yk,Kk,Zk,Qk,Jk,M3,Ha,ctt,ptt,ix,Mr,tV,mtt,gu,eV,ftt,gtt,iV,rV,sV,nV,aV,A3,C3,oV,lV,ytt,vtt,rx,Ed,sx,hV,nx,btt,_tt,uV,xtt,mp,dV,wtt,cV,E3,pV,P3,Stt,Ttt,R3,Mtt,Att,D3,mV,Rt,fV,gV,yV,vV,O3,bV,I3,_V,uy,ax,xV,wV,SV,TV,MV,AV,CV,EV,PV,RV,DV,OV,IV,NV,BV,kV,VV,zV,N3,B3,k3,ox,V3,LV,FV,z3,UV,xf,jV,Ds,fp,lx,Ctt,GV,Ett,Ptt,Rtt,Dtt,Ott,Itt,Qd,p5,WV,L3,F3,qV,HV,Ntt,Btt,U3,$V,hx,fS,XV,ktt,Vtt,Yi,ztt,YV,j3,Po,KV,ZV,QV,wf,Ltt,JV,Ftt,gp,G3,Utt,W3,jtt,q3,H3,$3,tl,yp,Gtt,tz,X3,ez,ux,dx,Wtt,iz,Y3,cx,qtt,Th,Htt,$tt,Xtt,rz,sz,Ytt,Ktt,nz,Re,Ztt,l9,Qtt,h9,Jtt,px,K3,az,vp,oz,tet,eet,iet,P1t,ret,u9,yR,Z3,lz,J1,hz,Q3,set,Ag,uz,net,d9,Sf,bp,aet,oet,het,Sv,uet,c9,det,p9,dz,J3,cz,cet,pz,pet,met,tC,fet,yu,dy,get,mz,eC,yet,vet,bet,fz,_et,mx,iC,fx,gz,rC,yz,sC,vz,bz,_z,xz,wz,nC,xet,Sz,wet,Tet,Met,Tz,Mz,Aet,Cet,Eet,Az,Pet,Cz,cy,py,gx,vR,Ez,aC,yx,oC,vx,lC,bx,hC,Pz,Ret,Rz,Det,Oet,Iet,Net,Dz,Oz,my,uC,Iz,Bet,ket,Vet,Nz,Bz,fy,gy,zet,kz,dC,cC,pC,Let,_x,Fet,mC,gS,Uet,Vz,fC,zz,m9,Lz,jet,Get,bR,Wet,f9,qet,Het,$et,g9,Fz,Xet,y9,yy,Yet,_R,Ket,Zet,YS,Qet,Jet,tit,v9,eit,Pd,iit,Uz,rit,sit,nit,ait,oit,jz,lit,Rd,el,ac,hit,uit,dit,Gz,Wz,cit,pit,qz,mit,fit,git,xx,yit,Tf,vit,bit,_it,xit,wit,Sit,gC,QW,Hz,Tit,wx,Mit,Ait,Cit,Eit,Pit,Rit,Dit,Oit,Iit,$z,Sx,Xz,Nit,Yz,Bit,kit,Tx,Ll,Vit,zit,Lit,Fit,yC,Uit,jit,Git,Kz,Wit,qit,Hit,Zz,$it,Xit,Yit,vu,Kit,Zit,Qit,Gn,Mf,Jit,Qz,trt,ert,irt,rrt,srt,nrt,art,ort,lrt,Jz,hrt,Af,_p,Cf,vC,vy,Mx,Mh,by,Ax,_y,Cx,Ex,urt,Px,t6,drt,crt,bC,prt,Pr,mrt,frt,e6,grt,Ef,yrt,vrt,_C,Fl,brt,_rt,xrt,wrt,Srt,Trt,Mrt,xC,i6,wC,r6,Art,s6,Crt,Ert,Prt,SC,Rrt,Drt,Ort,Irt,b9,R1t,Nrt,Brt,krt,Vrt,zrt,Lrt,Frt,Urt,jrt,Grt,TC,Wrt,qrt,Rx,Hrt,Dx,n6,a6,bu,$rt,Xrt,Yrt,Krt,Zrt,o6,l6,h6,Qrt,u6,Jrt,tst,est,d6,c6,Yr,Ox,ist,rst,sst,p6,m6,nst,ast,f6,g6,ost,MC,xp,wp,lst,hst,Ix,ust,dst,cst,pst,mst,AC,fst,gst,yst,vst,bst,_st,bn,xst,Ah,wst,Sst,Tst,Mst,Ast,Cst,Est,Pst,Rst,le,Dst,Ost,Ist,Nst,Bst,kst,Vst,zst,Lst,Fst,Ust,jst,Gst,Wst,qst,Hst,$st,Xst,Yst,Kst,Zst,Qst,Jst,tnt,ent,y6,CC,int,rnt,snt,nnt,ant,EC,xy,PC,ont,lnt,RC,_9,Nx,v6,b6,_6,x6,w6,S6,T6,Pf,M6,hnt,unt,dnt,A6,Bx,C6,E6,cnt,P6,wy,DC,pnt,mnt,fnt,gnt,R6,D6,ynt,vnt,O6,Sp,OC,I6,x9,bnt,_nt,Sy,kx,Os,Kr,xnt,wnt,N6,Snt,Tnt,B6,Mnt,Ant,_n,Cnt,Ent,il,Pnt,Rnt,Dnt,k6,Ont,V6,Ro,z6,Ty,ma,Ch,Int,Nnt,Bnt,knt,Vnt,nr,znt,Lnt,rl,Fnt,Unt,IC,jnt,Gnt,My,Wnt,qnt,Hnt,$nt,Xnt,Ynt,Knt,Znt,Qnt,Vx,zx,Lx,Jnt,tat,eat,iat,Rf,rat,sat,nat,aat,oat,lat,hat,uat,NC,dat,cat,pat,mat,fat,L6,F6,gat,yat,vat,U6,bat,_at,xat,wat,Sat,Tat,Mat,Aat,Cat,Eat,Pat,Rat,Dat,Oat,Iat,Nat,Bat,kat,Vat,zat,Lat,Fat,Uat,jat,Gat,Wat,qat,Hat,$at,Xat,Yat,Kat,Zat,Qat,Jat,tot,eot,j6,D,Ul,iot,rot,BC,sot,G6,not,W6,aot,oot,lot,kC,hot,Dd,uot,dot,cot,pot,mot,fot,got,yot,vot,bot,_ot,xot,wot,Sot,Tot,Mot,Aot,q6,H6,Cot,Eot,Fx,$6,Pot,X6,Rot,Dot,w9,S9,_2,Oot,Iot,Not,Bot,VC,Ux,Ay,kot,Vot,zot,sl,_u,Y6,Lot,zC,LC,Fot,Od,Uot,K6,jot,Z6,Got,Wot,Q6,Df,FC,jx,Gx,Of,xu,qot,Hot,J6,tL,eL,$ot,Xot,Yot,Kot,Zot,iL,Qot,Jot,xR,UC,tlt,rL,jC,If,elt,ilt,Nf,Eh,Wn,Ua,Ki,sL,nL,GC,tt,WC,nl,Ri,Tp,aL,Id,oL,qC,lL,Mp,hL,qn,rlt,Wx,yS,uL,slt,nlt,alt,olt,wR,llt,dL,Bf,Cy,cL,Ey,Py,pL,hlt,mL,HC,$C,Nd,Bd,qx,XC,YC,kf,Ry,Hx,Vf,xs,ult,dlt,$x,clt,plt,mlt,flt,fL,Xx,glt,fa,Ma,Yx,ju,Kx,zf,kd,Sa,ylt,vlt,blt,_lt,xlt,gL,wlt,Slt,Tlt,Mlt,yL,KC,vL,Alt,Clt,bL,Dy,Elt,_L,Plt,ga,ZC,xL,Rlt,Dlt,Olt,ja,Oy,Lf,Ilt,Nlt,Blt,klt,Vlt,Iy,Ff,Uf,Do,zlt,wL,Ph,Llt,Ny,Flt,Ult,Zx,jlt,jl,Oo,Ga,Qx,By,Jx,tw,al,Rh,Zr,wu,Glt,Wlt,qlt,Hlt,D1t,O1t,I1t,Yg,ra,SR,Et,_t,Ji,N1t,T9,B1t,gr,Le,TR,JW,tq,Tc,ul,yg,Io,MR,Uv,k1t,V1t,z1t,L1t,Nc,hb,F1t,rh,m5,Ae,U1t,j1t,eq,G1t,W1t,Ka,Qr,q1t,jv,Gv,CD,Vo,H1t,Vt,M9,ED,B1,PD,N,pe,$1t,Ii,X1t,A9,Dc,Mm,iq,co,Pn,Jr,$p,Y1t,mt,rq,AR,K1t,Z1t,Q1t,Zn,Qn,mi,J1t,tvt,CR,Wv,RD,xm,sq,evt,ER,ivt,Qt,rvt,ii,Yt,$h,svt,nvt,avt,PR,DD,ovt,qv,lvt,C9,hvt,uvt,nq,Oa,KS,dvt,xe,aq,Rr,cvt,pvt,mvt,fvt,gvt,yvt,vvt,OD,Hv,ID,Bc,$v,Wo,Fo,bvt,_vt,oq,xvt,ZS,wvt,k1,lq,Svt,zg,to,eh,fi,Tvt,Mvt,f5,Zu,Bn,tr,tv,E9,Sl,Ai,Avt,Xp,x2,Cvt,Evt,ee,Mc,Pvt,Rvt,hq,g5,Li,gt,QS,Yp,bi,Dvt,Ovt,Fr,at,G,lt,Ivt,vS,P9,R9,Lg,mc,Nvt,V1,RR,pr=j(()=>{ht(),ht(),LQ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],nB=new WeakMap,aB=new WeakMap,oB=new WeakMap,FQ=class{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=LQ,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1&&(this.getRenderObjectData(t),!0)}needsVelocity(t){let e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){let{geometry:i,object:r}=t;if(e={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(e.center=r.center.clone()),r.morphTargetInfluences&&(e.morphTargetInfluences=r.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),t.material.transmission>0){let{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}let{environmentIntensity:s,environmentRotation:n}=t.scene;e.environmentIntensity=s,e.environmentRotation=n.clone(),e.lights=this.getLightsData(t.lightsNode.getLights(),[]),this.renderObjects.set(t,e)}return e}getAttributesData(t){let e={};for(let i in t){let r=t[i];e[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return e}containsNode(t){let e=t.material;for(let i in e)if(e[i]&&e[i].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getGeometryData(t){let e=oB.get(t);return e===void 0&&(e={_renderId:-1,_equal:!1,attributes:this.getAttributesData(t.attributes),indexId:t.index?t.index.id:null,indexVersion:t.index?t.index.version:null,drawRange:{start:t.drawRange.start,count:t.drawRange.count}},oB.set(t,e)),e}getMaterialData(t){let e=aB.get(t);if(e===void 0){e={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=t[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?e[i]={id:r.id,version:0}:e[i]=r.clone():e[i]=r)}aB.set(t,e)}return e}equals(t,e,i){let{object:r,material:s,geometry:n}=t,a=this.getRenderObjectData(t);if(a.worldMatrix.equals(r.matrixWorld)!==!0)return a.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(t.material);if(o._renderId!==i){o._renderId=i;for(let u in o){let d=o[u],c=s[u];if(u!=="_renderId"&&u!=="_equal"){if(d.equals!==void 0){if(d.equals(c)===!1)return d.copy(c),o._equal=!1,!1}else if(c.isTexture===!0){if(d.id!==c.id||d.version!==c.version)return d.id=c.id,d.version=c.version,o._equal=!1,!1}else if(d!==c)return o[u]=c,o._equal=!1,!1}}if(o.transmission>0){let{width:u,height:d}=t.context;if(a.bufferWidth!==u||a.bufferHeight!==d)return a.bufferWidth=u,a.bufferHeight=d,o._equal=!1,!1}o._equal=!0}else if(o._equal===!1)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;let l=this.getGeometryData(t.geometry);if(l._renderId!==i){l._renderId=i;let u=n.attributes,d=l.attributes,c=0,p=0;for(let b in u)c++;for(let b in d){p++;let _=d[b],x=u[b];if(x===void 0)return delete d[b],l._equal=!1,!1;let S=x.isInterleavedBufferAttribute?x.data.uuid:x.id,w=x.isInterleavedBufferAttribute?x.data.version:x.version;if(_.id!==S||_.version!==w)return _.id=S,_.version=w,l._equal=!1,!1}if(p!==c)return l.attributes=this.getAttributesData(u),l._equal=!1,!1;let m=n.index,f=l.indexId,g=l.indexVersion,y=m?m.id:null,v=m?m.version:null;if(f!==y||g!==v)return l.indexId=y,l.indexVersion=v,l._equal=!1,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let u=!1;for(let d=0;d<a.morphTargetInfluences.length;d++)a.morphTargetInfluences[d]!==r.morphTargetInfluences[d]&&(a.morphTargetInfluences[d]=r.morphTargetInfluences[d],u=!0);if(u)return!1}if(a.lights){for(let u=0;u<e.length;u++)if(a.lights[u].map!==e[u].map)return!1}let h=t.scene;return h.environment===null||s.envMap!==null||a.environmentIntensity===h.environmentIntensity&&a.environmentRotation.equals(h.environmentRotation)!==!1?a.center&&a.center.equals(r.center)===!1?(a.center.copy(r.center),!1):(t.bundle!==null&&(a.version=t.bundle.version),!0):(a.environmentIntensity=h.environmentIntensity,a.environmentRotation.copy(h.environmentRotation),!1)}getLightsData(t,e){e.length=0;for(let i of t)i.isSpotLight===!0&&i.map!==null&&e.push({map:i.map.version});return e}getLights(t,e){let i=nB.get(t);return i===void 0&&(i={renderId:-1,lightsData:[]},nB.set(t,i)),i.renderId===e||(i.renderId=e,this.getLightsData(t.getLights(),i.lightsData)),i.lightsData}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;let{renderId:i}=e;if(this.renderId!==i){this.renderId=i;let a=this.getRenderObjectData(t);if(a.worldMatrix.copy(t.object.matrixWorld),a.morphTargetInfluences){let o=t.object.morphTargetInfluences;for(let l=0;l<a.morphTargetInfluences.length;l++)a.morphTargetInfluences[l]=o[l]}return a.center&&t.object.center&&a.center.copy(t.object.center),!0}let r=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(r||s)return!1;let n=this.getLights(t.lightsNode,i);return this.equals(t,n,i)!==!0}},UQ=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],Ts=class{constructor(t=null){this.isStackTrace=!0,this.stack=function(e){let i=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
1564
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),gEt=j(()=>{});function c1t(t){return function(e,{basePath:i,moduleUrl:r,cdnBuild:s}){if(i!==void 0)return{url:`${i}/${e}`};let n=`${s}/${e}`;if(r===void 0||r.startsWith("file:"))return{url:n};let a=r.slice(0,r.lastIndexOf("/")+1)+e;return a===n?{url:a}:{url:a,fallback:n}}(t,{basePath:p1t,moduleUrl:typeof import.meta.url=="string"?import.meta.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.123/build"})}function iQ(t,e){let{url:i,fallback:r}=c1t(e);r!==void 0&&t.addEventListener("error",()=>{t.src=r},{once:!0}),t.src=i}var p1t,$W=j(()=>{gEt()});function m1t(t,e){XW.set(t,e)}function rQ(t){return XW.get(t)}function sQ(t,e){let i=`${e}:${t}`;e9.has(i)||e9.add(i)}var XW,e9,YW=j(()=>{XW=new Map,e9=new Set});function JN(t,e=0){let i=3735928559^e,r=1103547991^e;if(Array.isArray(t))for(let s,n=0;n<t.length;n++)s=t[n],i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);else for(let s,n=0;n<t.length;n++)s=t.charCodeAt(n),i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function nQ(t){return S1t.get(t)}function pA(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function aQ(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?9:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new Ts)}function yEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?12:/mat4/.test(t)?16:void Xt(`TSL: Unsupported type: ${t}`,new Ts)}function vEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)||/vec4/.test(t)?4:/mat2/.test(t)?2:/mat3/.test(t)||/mat4/.test(t)?4:void Xt(`TSL: Unsupported type: ${t}`,new Ts)}function Qc(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function tB(t,...e){let i=t?t.slice(-4):void 0;return e.length===1&&(i==="vec2"?e=[e[0],e[0]]:i==="vec3"?e=[e[0],e[0],e[0]]:i==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new ae(...e):i==="vec2"?new Z(...e):i==="vec3"?new P(...e):i==="vec4"?new Me(...e):i==="mat2"?new CG(...e):i==="mat3"?new As(...e):i==="mat4"?new xt(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?function(r){return Uint8Array.from(atob(r),s=>s.charCodeAt(0)).buffer}(e[0]):null}function oQ(t){let e=r9.get(t);return e===void 0&&(e={},r9.set(t,e)),e}function At(t,e){if(c5.has(t))ne(`TSL: Redefinition of method chaining '${t}'.`);else{if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);c5.set(t,e),t!=="assign"&&(Ee.prototype[t]=function(...i){return this.isStackNode?this.addToStack(e(...i)):e(this,...i)},Ee.prototype[t+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],e(...i)):this.assign(e(this,...i))})}}function mA(t,e,i){wv[t]=wv[e]=wv[i]={get(){this._cache=this._cache||{};let a=this._cache[t];return a===void 0&&(a=new s9(this,t),this._cache[t]=a),a},set(a){this[t].assign(ve(a))}};let r=t.toUpperCase(),s=e.toUpperCase(),n=i.toUpperCase();Ee.prototype["set"+r]=Ee.prototype["set"+s]=Ee.prototype["set"+n]=function(a){let o=n9(t);return new T1t(this,o,ve(a))},Ee.prototype["flip"+r]=Ee.prototype["flip"+s]=Ee.prototype["flip"+n]=function(){let a=n9(t);return new M1t(this,a)}}function lQ(t){return t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)}function Q0(t){return t&&t.isNode&&t.traverse(e=>{e.isConstNode&&(t=e.value)}),Boolean(t)}function J0(t,e){return new A1t(t,e)}function it(t,e=null){let i=new C1t(t,e);return new Proxy(()=>{},{apply:(r,s,n)=>i.call(...n),get:(r,s,n)=>Reflect.get(i,s,n),set:(r,s,n,a)=>Reflect.set(i,s,n,a)})}function fA(t){return ec&&ec.addToStack(t),t}function hQ(t,e,i=null){return nc(i,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(t):s})}function uQ(t,e=null){return nc(e,{getAO:(i,{material:r})=>r.transparent===!0?i:i!==null?i.mul(t):t})}function dQ(t,e){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),fR(t,e)}function cQ(t,e){let i=a9.get(t);return i===void 0&&(i=new X1(t,e),a9.set(t,i)),i}function gA(t,e=null,i=0,r=0,s=Cg,n=!1){return e==="mat3"||e===null&&t.itemSize===9?wn(new Zd(t,"vec3",9,0).setUsage(s).setInstanced(n),new Zd(t,"vec3",9,3).setUsage(s).setInstanced(n),new Zd(t,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&t.itemSize===16?ic(new Zd(t,"vec4",16,0).setUsage(s).setInstanced(n),new Zd(t,"vec4",16,4).setUsage(s).setInstanced(n),new Zd(t,"vec4",16,8).setUsage(s).setInstanced(n),new Zd(t,"vec4",16,12).setUsage(s).setInstanced(n)):new Zd(t,e,i,r).setUsage(s)}function pQ(t,e=!0){return ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),gg(t).setParent(e)}function mQ(t,e,i,r=U(0),s=U(1)){return o9(t,e,i,r,s,!0)}function fQ(t,e="",i=null){return(t=ve(t)).before(new E1t(t,e,i))}function bEt(t){ne("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}function gQ(t,e,i){let r;if(e.isStorageInstancedBufferAttribute===!0)r=Qd(e,"mat4",Math.max(i,1)).element(Kl);else if(16*i*4<=t.getUniformBufferLimit())r=Mg(e.array,"mat4",Math.max(i,1)).element(Kl);else{let s=p5.get(e);s||(s=new AG(e.array,16,1),p5.set(e,s));let n=e.usage===Yh?gR:b2,a=[n(s,"vec4",16,0),n(s,"vec4",16,4),n(s,"vec4",16,8),n(s,"vec4",16,12)];r=ic(...a)}return r}function i9(t,e,i,r,s,n){let a=t.element(s.x),o=t.element(s.y),l=t.element(s.z),h=t.element(s.w),u=i.mul(e),d=Is(a.mul(n.x).mul(u),o.mul(n.y).mul(u),l.mul(n.z).mul(u),h.mul(n.w).mul(u));return r.mul(d).xyz}function yQ(t,e,i,r,s,n,a){let o=t.element(n.x),l=t.element(n.y),h=t.element(n.z),u=t.element(n.w),d=Is(a.x.mul(o),a.y.mul(l),a.z.mul(h),a.w.mul(u));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(e).xyz,skinTangent:d.transformDirection(i).xyz}}function vQ(t,e,i,r,s){let n=t.skeleton,a=fS.get(n);if(a===void 0){n.update();let o=new Float32Array(n.boneMatrices);a={previousBoneMatrices:o,node:Mg(o,"mat4",n.bones.length)},fS.set(n,a)}return i9(a.node,Fp,e,i,r,s)}function f1t(t){let e=t.target;e.removeEventListener("dispose",f1t);let i=J1.get(e);i!==void 0&&(J1.delete(e),i.dispose())}function bQ(t,e){e===a4?t.mapping=jg:e===o4&&(t.mapping=j2)}function _Q(t,e,i){let r=new si(t,e,{magFilter:fe,minFilter:fe,generateMipmaps:!1,type:ai,format:ln,colorSpace:Yu,depthBuffer:i});return r.texture.mapping=G2,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function d5(t){let e=new Re;return e.depthTest=!1,e.depthWrite=!1,e.blending=dr,e.name=`PMREM_${t}`,e}function xQ(t){let e=d5("cubemap");return e.fragmentNode=Ha(t,gS),e}function wQ(t){let e=d5("equirect");return e.fragmentNode=Di(t,yR(gS),0),e}function SQ(t){return Object.freeze({isMaterial:!0,isDrawState:!0,id:t.id,name:t.name,type:t.type,transparent:t.transparent,blending:t.blending,premultipliedAlpha:t.premultipliedAlpha,blendSrc:t.blendSrc,blendDst:t.blendDst,blendEquation:t.blendEquation,blendSrcAlpha:t.blendSrcAlpha,blendDstAlpha:t.blendDstAlpha,blendEquationAlpha:t.blendEquationAlpha,blendColor:t.blendColor,blendAlpha:t.blendAlpha,colorWrite:t.colorWrite,depthWrite:t.depthWrite,depthTest:t.depthTest,depthFunc:t.depthFunc,stencilWrite:t.stencilWrite,stencilFunc:t.stencilFunc,stencilRef:t.stencilRef,stencilFail:t.stencilFail,stencilZFail:t.stencilZFail,stencilZPass:t.stencilZPass,stencilFuncMask:t.stencilFuncMask,stencilWriteMask:t.stencilWriteMask,side:t.side,wireframe:t.wireframe===!0,alphaToCoverage:t.alphaToCoverage,forceSinglePass:t.forceSinglePass,polygonOffset:t.polygonOffset,polygonOffsetFactor:t.polygonOffsetFactor,polygonOffsetUnits:t.polygonOffsetUnits})}function TQ(t,e){if(t===null||e===null)return t===e;for(let i in t)if(t[i]!==e[i])return!1;return!0}function g1t(t){return t.index!==null?t.index.version:t.attributes.position.version}function y1t(t){return t.index!==null?t.index.id:t.attributes.position.id}function MQ(t){let e=[],i=t.index,r=t.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],h=n[a+1],u=n[a+2];e.push(l,h,h,u,u,l)}}else for(let n=0,a=r.array.length/3-1;n<a;n+=3){let o=n+0,l=n+1,h=n+2;e.push(o,l,l,h,h,o)}let s=new(r.count>=65535?fm:G8)(e,1);return s.version=g1t(t),s.__id=y1t(t),s}function _Et(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?t.z-e.z:t.id-e.id}function AQ(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function CQ(t){return!!(t.transparent===!0||t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode||t.backdropNode&&t.backdropNode.isNode)}function EQ(t){return(t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode)&&t.side===Rn&&t.forceSinglePass===!1}function PQ(t,e=null,i=null){if(e&&e.isNode){let r=e;e=()=>r}return new QW(new Map([[t,e]]),i)}function RQ(t,e=null){let i=new Map;for(let[r,s]of t){let n=s!==null?typeof s=="function"?s:()=>s:null;i.set(r,n)}return new QW(i,e)}function DQ(t,e){for(let i=0;i<t.length;i++)if(t[i].name===e)return i;return-1}function xEt(t,e=null){return nc(e,{getUV:typeof t=="function"?t:()=>t})}function v1t(t){let e=b9.get(t);return e===void 0&&(e={},b9.set(t,e)),e}function OQ(t,e=0){let i=v1t(t),r=i[e];return r===void 0&&(i[e]=r=new xt,i[e].copy(t.matrixWorld)),r}function eB(t){let e,i=t.context.getViewZ;return i!==void 0&&(e=i(this)),(e||Ss.z).negate()}function AD(t){let e=(y6=y6||new WeakMap).get(t);return e===void 0&&y6.set(t,e={}),e}function mR(t){let e=AD(t);return e.shadowMatrix||(e.shadowMatrix=we("mat4").setGroup(Ce).onRenderUpdate(i=>((t.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(t.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(t.shadow.camera.coordinateSystem=i.camera.coordinateSystem,t.shadow.camera.updateProjectionMatrix()),t.shadow.updateMatrices(t)),t.shadow.matrix)))}function IQ(t,e=Ih){let i=mR(t).mul(e);return i.xyz.div(i.w)}function iB(t){let e=AD(t);return e.position||(e.position=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.matrixWorld)))}function NQ(t){let e=AD(t);return e.targetPosition||(e.targetPosition=we(new P).setGroup(Ce).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.target.matrixWorld)))}function rB(t){let e=AD(t);return e.viewPosition||(e.viewPosition=we(new P).setGroup(Ce).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new P,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}))}function KW(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new ae),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function b1t(t,e){return e=KW(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function _1t(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function ZW(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function x1t(t,e){return e=ZW(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function w1t(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function wEt(t,e,i={}){return ZW(e,i=KW(t,i))}function BQ(t,e,i){return x1t(e,i=b1t(t,i))}function kQ(t,e,i){_1t(t,i),w1t(e,i)}function VQ(t){return t+(ac-t%ac)%ac}function ty(){return xR===null&&((xR=new vr(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),xR}function du(t,e){wR[0]=e,t.queue.submit(wR),wR[0]=null}function zQ(t,e,i,r,s,n,a,o,l,h){Ma.texture=e,Ma.mipLevel=i,Ma.origin.z=r,ju.offset=r*n,ju.bytesPerRow=a,ju.rowsPerImage=o,Sa.width=l,Sa.height=h,t.queue.writeTexture(Ma,s.data,ju,Sa),Ma.reset(),ju.reset(),Sa.reset()}function sB(t,e){let i,r=t.format,s=t.type,n=t.normalized,a=t.colorSpace,o=Qi.getTransfer(a),l=!1;if(n&&(l=e.features.has(yS.TextureFormatsTier1),l===!1&&ne("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),t.isCompressedTexture===!0||t.isCompressedArrayTexture===!0)switch(r){case Apt:case Cpt:i=o===wr?tt.BC1RGBAUnormSRGB:tt.BC1RGBAUnorm;break;case Ept:i=o===wr?tt.BC2RGBAUnormSRGB:tt.BC2RGBAUnorm;break;case Ppt:i=o===wr?tt.BC3RGBAUnormSRGB:tt.BC3RGBAUnorm;break;case Jpt:i=tt.BC4RUnorm;break;case tmt:i=tt.BC4RSnorm;break;case wG:i=tt.BC5RGUnorm;break;case emt:i=tt.BC5RGSnorm;break;case Kpt:i=o===wr?tt.BC7RGBAUnormSRGB:tt.BC7RGBAUnorm;break;case Zpt:i=tt.BC6HRGBFloat;break;case Qpt:i=tt.BC6HRGBUFloat;break;case Dpt:case Rpt:i=o===wr?tt.ETC2RGB8UnormSRGB:tt.ETC2RGB8Unorm;break;case Opt:i=o===wr?tt.ETC2RGBA8UnormSRGB:tt.ETC2RGBA8Unorm;break;case Ipt:i=tt.EACR11Unorm;break;case Npt:i=tt.EACR11Snorm;break;case xG:i=tt.EACRG11Unorm;break;case Bpt:i=tt.EACRG11Snorm;break;case kpt:i=o===wr?tt.ASTC4x4UnormSRGB:tt.ASTC4x4Unorm;break;case Vpt:i=o===wr?tt.ASTC5x4UnormSRGB:tt.ASTC5x4Unorm;break;case zpt:i=o===wr?tt.ASTC5x5UnormSRGB:tt.ASTC5x5Unorm;break;case Lpt:i=o===wr?tt.ASTC6x5UnormSRGB:tt.ASTC6x5Unorm;break;case Fpt:i=o===wr?tt.ASTC6x6UnormSRGB:tt.ASTC6x6Unorm;break;case Upt:i=o===wr?tt.ASTC8x5UnormSRGB:tt.ASTC8x5Unorm;break;case jpt:i=o===wr?tt.ASTC8x6UnormSRGB:tt.ASTC8x6Unorm;break;case Gpt:i=o===wr?tt.ASTC8x8UnormSRGB:tt.ASTC8x8Unorm;break;case Wpt:i=o===wr?tt.ASTC10x5UnormSRGB:tt.ASTC10x5Unorm;break;case qpt:i=o===wr?tt.ASTC10x6UnormSRGB:tt.ASTC10x6Unorm;break;case Hpt:i=o===wr?tt.ASTC10x8UnormSRGB:tt.ASTC10x8Unorm;break;case $pt:i=o===wr?tt.ASTC10x10UnormSRGB:tt.ASTC10x10Unorm;break;case Xpt:i=o===wr?tt.ASTC12x10UnormSRGB:tt.ASTC12x10Unorm;break;case Ypt:i=o===wr?tt.ASTC12x12UnormSRGB:tt.ASTC12x12Unorm;break;case ln:i=o===wr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case ln:switch(s){case W2:i=tt.RGBA8Snorm;break;case q2:i=l?tt.RGBA16Snorm:tt.RGBA16Sint;break;case $1:i=l?tt.RGBA16Unorm:tt.RGBA16Uint;break;case Cn:i=tt.RGBA32Uint;break;case vl:i=tt.RGBA32Sint;break;case xl:i=o===wr?tt.RGBA8UnormSRGB:tt.RGBA8Unorm;break;case ai:i=tt.RGBA16Float;break;case Qe:i=tt.RGBA32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case l4:switch(s){case vG:i=tt.RGB9E5UFloat;break;case bG:i=tt.RG11B10UFloat;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Qa:switch(s){case W2:i=tt.R8Snorm;break;case q2:i=l?tt.R16Snorm:tt.R16Sint;break;case $1:i=l?tt.R16Unorm:tt.R16Uint;break;case Cn:i=tt.R32Uint;break;case vl:i=tt.R32Sint;break;case xl:i=tt.R8Unorm;break;case ai:i=tt.R16Float;break;case Qe:i=tt.R32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case ko:switch(s){case W2:i=tt.RG8Snorm;break;case q2:i=l?tt.RG16Snorm:tt.RG16Sint;break;case $1:i=l?tt.RG16Unorm:tt.RG16Uint;break;case Cn:i=tt.RG32Uint;break;case vl:i=tt.RG32Sint;break;case xl:i=tt.RG8Unorm;break;case ai:i=tt.RG16Float;break;case Qe:i=tt.RG32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case em:switch(s){case $1:i=tt.Depth16Unorm;break;case Cn:i=tt.Depth24Plus;break;case Qe:i=tt.Depth32Float;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case lv:switch(s){case H2:i=tt.Depth24PlusStencil8;break;case Qe:e&&e.features.has(yS.Depth32FloatStencil8)===!1&&Xt('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=tt.Depth32FloatStencil8;break;default:Xt("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case h4:switch(s){case vl:i=tt.R32Sint;break;case Cn:i=tt.R32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case u4:switch(s){case vl:i=tt.RG32Sint;break;case Cn:i=tt.RG32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case _G:switch(s){case vl:i=tt.RGBA32Sint;break;case Cn:i=tt.RGBA32Uint;break;default:Xt("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:Xt("WebGPURenderer: Unsupported texture format.",r)}return i}var LQ,nB,aB,oB,FQ,UQ,Ts,pf,ey,iy,S1t,r9,mf,Ue,jQ,Fn,lB,T_,M_,ff,GQ,WQ,Ee,Jc,hB,Cr,qQ,HQ,s9,T1t,M1t,yA,uB,fh,$Q,ec,c5,XQ,n9,wv,gh,yh,vh,YQ,KQ,ZQ,dB,QQ,JQ,A1t,tJ,eJ,iJ,cB,vA,bA,_A,A_,C_,pB,xA,Hs,mB,ve,ry,E_,tp,ui,te,Wt,wA,rJ,C1t,sy,SA,Se,sJ,fB,U,J,jt,To,Kt,ss,TA,gB,rt,MA,ep,AA,he,CA,EA,yB,P_,wn,ic,vB,bB,nJ,aJ,Gi,cu,ip,Ei,rp,PA,bh,pu,R_,gf,Mo,yd,D_,O_,I_,N_,vd,ny,sp,bd,np,ap,B_,yf,op,ay,oJ,oy,k_,RA,DA,OA,IA,NA,_B,xB,BA,lJ,Ce,wB,ly,we,SB,TB,hJ,uJ,dJ,cJ,bs,Is,Mi,qe,Ao,V_,MB,AB,CB,kA,EB,PB,RB,DB,OB,IB,NB,BB,kB,VB,zB,LB,FB,UB,jB,GB,ct,z_,pJ,L_,mJ,fJ,gJ,WB,qB,HB,$B,VA,vf,F_,_h,ka,zA,xh,U_,ca,Nl,Va,XB,Bl,YB,KB,ZB,QB,JB,LA,tk,FA,ek,xr,UA,wh,jA,ik,GA,WA,rk,sk,qA,HA,nk,ak,ok,ao,ns,lp,lk,hk,uk,Zo,mu,Qo,$A,dk,XA,ck,pk,mk,fk,YA,vi,kl,j_,KA,Co,ZA,gk,yk,vk,bk,yJ,vJ,za,QA,nc,_k,fR,JA,t3,bJ,xk,wk,_J,hp,_d,Sk,Tk,Mk,e3,i3,xJ,G_,wJ,SJ,Ak,TJ,MJ,Ck,AJ,Ek,Pk,a9,Zd,r3,CJ,b2,gR,cs,Rk,Kl,EJ,PJ,RJ,Dk,DJ,s3,OJ,mS,gg,IJ,o9,n3,Eo,NJ,BJ,a3,Ok,kJ,Ik,VJ,zJ,Nk,E1t,Bk,La,Xi,up,o3,kk,l3,xd,LJ,Di,FJ,_s,UJ,jJ,GJ,h3,Mg,WJ,qJ,Un,fu,W_,q_,$r,u3,Vl,dp,cp,bf,d3,Vk,HJ,$J,c3,H_,p3,$_,m3,X_,f3,Y_,g3,K_,y3,Z_,v3,Q_,wd,Sd,Td,Fa,zk,Md,hy,XJ,Lk,YJ,Fk,Bi,KJ,ZJ,QJ,JJ,ttt,ett,zl,itt,Jo,rtt,stt,ntt,att,Uk,ott,Sh,jk,b3,_3,Gk,jn,Xr,Fp,Ih,x3,Ss,fr,Wk,w3,pp,ltt,J_,pa,qk,_f,Hk,Pi,Ad,Cd,$k,S3,htt,utt,dtt,T3,Xk,tx,ex,Yk,Kk,Zk,Qk,Jk,M3,Ha,ctt,ptt,ix,Mr,tV,mtt,gu,eV,ftt,gtt,iV,rV,sV,nV,aV,A3,C3,oV,lV,ytt,vtt,rx,Ed,sx,hV,nx,btt,_tt,uV,xtt,mp,dV,wtt,cV,E3,pV,P3,Stt,Ttt,R3,Mtt,Att,D3,mV,Rt,fV,gV,yV,vV,O3,bV,I3,_V,uy,ax,xV,wV,SV,TV,MV,AV,CV,EV,PV,RV,DV,OV,IV,NV,BV,kV,VV,zV,N3,B3,k3,ox,V3,LV,FV,z3,UV,xf,jV,Ds,fp,lx,Ctt,GV,Ett,Ptt,Rtt,Dtt,Ott,Itt,Qd,p5,WV,L3,F3,qV,HV,Ntt,Btt,U3,$V,hx,fS,XV,ktt,Vtt,Yi,ztt,YV,j3,Po,KV,ZV,QV,wf,Ltt,JV,Ftt,gp,G3,Utt,W3,jtt,q3,H3,$3,tl,yp,Gtt,tz,X3,ez,ux,dx,Wtt,iz,Y3,cx,qtt,Th,Htt,$tt,Xtt,rz,sz,Ytt,Ktt,nz,Re,Ztt,l9,Qtt,h9,Jtt,px,K3,az,vp,oz,tet,eet,iet,P1t,ret,u9,yR,Z3,lz,J1,hz,Q3,set,Ag,uz,net,d9,Sf,bp,aet,oet,het,Sv,uet,c9,det,p9,dz,J3,cz,cet,pz,pet,met,tC,fet,yu,dy,get,mz,eC,yet,vet,bet,fz,_et,mx,iC,fx,gz,rC,yz,sC,vz,bz,_z,xz,wz,nC,xet,Sz,wet,Tet,Met,Tz,Mz,Aet,Cet,Eet,Az,Pet,Cz,cy,py,gx,vR,Ez,aC,yx,oC,vx,lC,bx,hC,Pz,Ret,Rz,Det,Oet,Iet,Net,Dz,Oz,my,uC,Iz,Bet,ket,Vet,Nz,Bz,fy,gy,zet,kz,dC,cC,pC,Let,_x,Fet,mC,gS,Uet,Vz,fC,zz,m9,Lz,jet,Get,bR,Wet,f9,qet,Het,$et,g9,Fz,Xet,y9,yy,Yet,_R,Ket,Zet,YS,Qet,Jet,tit,v9,eit,Pd,iit,Uz,rit,sit,nit,ait,oit,jz,lit,Rd,el,ac,hit,uit,dit,Gz,Wz,cit,pit,qz,mit,fit,git,xx,yit,Tf,vit,bit,_it,xit,wit,Sit,gC,QW,Hz,Tit,wx,Mit,Ait,Cit,Eit,Pit,Rit,Dit,Oit,Iit,$z,Sx,Xz,Nit,Yz,Bit,kit,Tx,Ll,Vit,zit,Lit,Fit,yC,Uit,jit,Git,Kz,Wit,qit,Hit,Zz,$it,Xit,Yit,vu,Kit,Zit,Qit,Gn,Mf,Jit,Qz,trt,ert,irt,rrt,srt,nrt,art,ort,lrt,Jz,hrt,Af,_p,Cf,vC,vy,Mx,Mh,by,Ax,_y,Cx,Ex,urt,Px,t6,drt,crt,bC,prt,Pr,mrt,frt,e6,grt,Ef,yrt,vrt,_C,Fl,brt,_rt,xrt,wrt,Srt,Trt,Mrt,xC,i6,wC,r6,Art,s6,Crt,Ert,Prt,SC,Rrt,Drt,Ort,Irt,b9,R1t,Nrt,Brt,krt,Vrt,zrt,Lrt,Frt,Urt,jrt,Grt,TC,Wrt,qrt,Rx,Hrt,Dx,n6,a6,bu,$rt,Xrt,Yrt,Krt,Zrt,o6,l6,h6,Qrt,u6,Jrt,tst,est,d6,c6,Yr,Ox,ist,rst,sst,p6,m6,nst,ast,f6,g6,ost,MC,xp,wp,lst,hst,Ix,ust,dst,cst,pst,mst,AC,fst,gst,yst,vst,bst,_st,bn,xst,Ah,wst,Sst,Tst,Mst,Ast,Cst,Est,Pst,Rst,le,Dst,Ost,Ist,Nst,Bst,kst,Vst,zst,Lst,Fst,Ust,jst,Gst,Wst,qst,Hst,$st,Xst,Yst,Kst,Zst,Qst,Jst,tnt,ent,y6,CC,int,rnt,snt,nnt,ant,EC,xy,PC,ont,lnt,RC,_9,Nx,v6,b6,_6,x6,w6,S6,T6,Pf,M6,hnt,unt,dnt,A6,Bx,C6,E6,cnt,P6,wy,DC,pnt,mnt,fnt,gnt,R6,D6,ynt,vnt,O6,Sp,OC,I6,x9,bnt,_nt,Sy,kx,Os,Kr,xnt,wnt,N6,Snt,Tnt,B6,Mnt,Ant,_n,Cnt,Ent,il,Pnt,Rnt,Dnt,k6,Ont,V6,Ro,z6,Ty,ma,Ch,Int,Nnt,Bnt,knt,Vnt,nr,znt,Lnt,rl,Fnt,Unt,IC,jnt,Gnt,My,Wnt,qnt,Hnt,$nt,Xnt,Ynt,Knt,Znt,Qnt,Vx,zx,Lx,Jnt,tat,eat,iat,Rf,rat,sat,nat,aat,oat,lat,hat,uat,NC,dat,cat,pat,mat,fat,L6,F6,gat,yat,vat,U6,bat,_at,xat,wat,Sat,Tat,Mat,Aat,Cat,Eat,Pat,Rat,Dat,Oat,Iat,Nat,Bat,kat,Vat,zat,Lat,Fat,Uat,jat,Gat,Wat,qat,Hat,$at,Xat,Yat,Kat,Zat,Qat,Jat,tot,eot,j6,D,Ul,iot,rot,BC,sot,G6,not,W6,aot,oot,lot,kC,hot,Dd,uot,dot,cot,pot,mot,fot,got,yot,vot,bot,_ot,xot,wot,Sot,Tot,Mot,Aot,q6,H6,Cot,Eot,Fx,$6,Pot,X6,Rot,Dot,w9,S9,_2,Oot,Iot,Not,Bot,VC,Ux,Ay,kot,Vot,zot,sl,_u,Y6,Lot,zC,LC,Fot,Od,Uot,K6,jot,Z6,Got,Wot,Q6,Df,FC,jx,Gx,Of,xu,qot,Hot,J6,tL,eL,$ot,Xot,Yot,Kot,Zot,iL,Qot,Jot,xR,UC,tlt,rL,jC,If,elt,ilt,Nf,Eh,Wn,Ua,Ki,sL,nL,GC,tt,WC,nl,Ri,Tp,aL,Id,oL,qC,lL,Mp,hL,qn,rlt,Wx,yS,uL,slt,nlt,alt,olt,wR,llt,dL,Bf,Cy,cL,Ey,Py,pL,hlt,mL,HC,$C,Nd,Bd,qx,XC,YC,kf,Ry,Hx,Vf,xs,ult,dlt,$x,clt,plt,mlt,flt,fL,Xx,glt,fa,Ma,Yx,ju,Kx,zf,kd,Sa,ylt,vlt,blt,_lt,xlt,gL,wlt,Slt,Tlt,Mlt,yL,KC,vL,Alt,Clt,bL,Dy,Elt,_L,Plt,ga,ZC,xL,Rlt,Dlt,Olt,ja,Oy,Lf,Ilt,Nlt,Blt,klt,Vlt,Iy,Ff,Uf,Do,zlt,wL,Ph,Llt,Ny,Flt,Ult,Zx,jlt,jl,Oo,Ga,Qx,By,Jx,tw,al,Rh,Zr,wu,Glt,Wlt,qlt,Hlt,D1t,O1t,I1t,Yg,ra,SR,Et,_t,Ji,N1t,T9,B1t,gr,Le,TR,JW,tq,Tc,ul,yg,Io,MR,Uv,k1t,V1t,z1t,L1t,Nc,hb,F1t,rh,m5,Ae,U1t,j1t,eq,G1t,W1t,Ka,Qr,q1t,jv,Gv,CD,Vo,H1t,Vt,M9,ED,B1,PD,N,pe,$1t,Ii,X1t,A9,Dc,Mm,iq,co,Pn,Jr,$p,Y1t,mt,rq,AR,K1t,Z1t,Q1t,Zn,Qn,mi,J1t,tvt,CR,Wv,RD,xm,sq,evt,ER,ivt,Qt,rvt,ii,Yt,$h,svt,nvt,avt,PR,DD,ovt,qv,lvt,C9,hvt,uvt,nq,Oa,KS,dvt,xe,aq,Rr,cvt,pvt,mvt,fvt,gvt,yvt,vvt,OD,Hv,ID,Bc,$v,Wo,Fo,bvt,_vt,oq,xvt,ZS,wvt,k1,lq,Svt,zg,to,eh,fi,Tvt,Mvt,f5,Zu,Bn,tr,tv,E9,Sl,Ai,Avt,Xp,x2,Cvt,Evt,ee,Mc,Pvt,Rvt,hq,g5,Li,gt,QS,Yp,bi,Dvt,Ovt,Fr,at,G,lt,Ivt,vS,P9,R9,Lg,mc,Nvt,V1,RR,pr=j(()=>{ht(),ht(),LQ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],nB=new WeakMap,aB=new WeakMap,oB=new WeakMap,FQ=class{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=LQ,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1&&(this.getRenderObjectData(t),!0)}needsVelocity(t){let e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){let{geometry:i,object:r}=t;if(e={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(e.center=r.center.clone()),r.morphTargetInfluences&&(e.morphTargetInfluences=r.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),t.material.transmission>0){let{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}let{environmentIntensity:s,environmentRotation:n}=t.scene;e.environmentIntensity=s,e.environmentRotation=n.clone(),e.lights=this.getLightsData(t.lightsNode.getLights(),[]),this.renderObjects.set(t,e)}return e}getAttributesData(t){let e={};for(let i in t){let r=t[i];e[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return e}containsNode(t){let e=t.material;for(let i in e)if(e[i]&&e[i].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getGeometryData(t){let e=oB.get(t);return e===void 0&&(e={_renderId:-1,_equal:!1,attributes:this.getAttributesData(t.attributes),indexId:t.index?t.index.id:null,indexVersion:t.index?t.index.version:null,drawRange:{start:t.drawRange.start,count:t.drawRange.count}},oB.set(t,e)),e}getMaterialData(t){let e=aB.get(t);if(e===void 0){e={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=t[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?e[i]={id:r.id,version:0}:e[i]=r.clone():e[i]=r)}aB.set(t,e)}return e}equals(t,e,i){let{object:r,material:s,geometry:n}=t,a=this.getRenderObjectData(t);if(a.worldMatrix.equals(r.matrixWorld)!==!0)return a.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(t.material);if(o._renderId!==i){o._renderId=i;for(let u in o){let d=o[u],c=s[u];if(u!=="_renderId"&&u!=="_equal"){if(d.equals!==void 0){if(d.equals(c)===!1)return d.copy(c),o._equal=!1,!1}else if(c.isTexture===!0){if(d.id!==c.id||d.version!==c.version)return d.id=c.id,d.version=c.version,o._equal=!1,!1}else if(d!==c)return o[u]=c,o._equal=!1,!1}}if(o.transmission>0){let{width:u,height:d}=t.context;if(a.bufferWidth!==u||a.bufferHeight!==d)return a.bufferWidth=u,a.bufferHeight=d,o._equal=!1,!1}o._equal=!0}else if(o._equal===!1)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;let l=this.getGeometryData(t.geometry);if(l._renderId!==i){l._renderId=i;let u=n.attributes,d=l.attributes,c=0,p=0;for(let b in u)c++;for(let b in d){p++;let _=d[b],x=u[b];if(x===void 0)return delete d[b],l._equal=!1,!1;let S=x.isInterleavedBufferAttribute?x.data.uuid:x.id,w=x.isInterleavedBufferAttribute?x.data.version:x.version;if(_.id!==S||_.version!==w)return _.id=S,_.version=w,l._equal=!1,!1}if(p!==c)return l.attributes=this.getAttributesData(u),l._equal=!1,!1;let m=n.index,f=l.indexId,g=l.indexVersion,y=m?m.id:null,v=m?m.version:null;if(f!==y||g!==v)return l.indexId=y,l.indexVersion=v,l._equal=!1,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let u=!1;for(let d=0;d<a.morphTargetInfluences.length;d++)a.morphTargetInfluences[d]!==r.morphTargetInfluences[d]&&(a.morphTargetInfluences[d]=r.morphTargetInfluences[d],u=!0);if(u)return!1}if(a.lights){for(let u=0;u<e.length;u++)if(a.lights[u].map!==e[u].map)return!1}let h=t.scene;return h.environment===null||s.envMap!==null||a.environmentIntensity===h.environmentIntensity&&a.environmentRotation.equals(h.environmentRotation)!==!1?a.center&&a.center.equals(r.center)===!1?(a.center.copy(r.center),!1):(t.bundle!==null&&(a.version=t.bundle.version),!0):(a.environmentIntensity=h.environmentIntensity,a.environmentRotation.copy(h.environmentRotation),!1)}getLightsData(t,e){e.length=0;for(let i of t)i.isSpotLight===!0&&i.map!==null&&e.push({map:i.map.version});return e}getLights(t,e){let i=nB.get(t);return i===void 0&&(i={renderId:-1,lightsData:[]},nB.set(t,i)),i.renderId===e||(i.renderId=e,this.getLightsData(t.getLights(),i.lightsData)),i.lightsData}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;let{renderId:i}=e;if(this.renderId!==i){this.renderId=i;let a=this.getRenderObjectData(t);if(a.worldMatrix.copy(t.object.matrixWorld),a.morphTargetInfluences){let o=t.object.morphTargetInfluences;for(let l=0;l<a.morphTargetInfluences.length;l++)a.morphTargetInfluences[l]=o[l]}return a.center&&t.object.center&&a.center.copy(t.object.center),!0}let r=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(r||s)return!1;let n=this.getLights(t.lightsNode,i);return this.equals(t,n,i)!==!0}},UQ=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],Ts=class{constructor(t=null){this.isStackTrace=!0,this.stack=function(e){let i=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
1565
1565
  `).map(r=>{let s=r.match(i);if(!s)return null;let n=s[1]||s[2]||"",a=s[3].split("?")[0],o=parseInt(s[4],10),l=parseInt(s[5],10);return{fn:n,file:a.split("/").pop(),line:o,column:l}}).filter(r=>r&&!UQ.some(s=>s.test(r.file)))}(t||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";let t=this.stack[0],e=t.fn;return`${e?`"${e}()" at `:""}"${t.file}:${t.line}"`}getError(t){return this.stack.length===0?t:`${t}
1566
1566
  ${this.stack.map(e=>{let i=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${i})`:` at ${i}`}).join(`
1567
1567
  `)}`}},pf=t=>JN(t),ey=t=>JN(t),iy=(...t)=>JN(t),S1t=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),r9=new WeakMap,mf={VERTEX:"vertex",FRAGMENT:"fragment"},Ue={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},jQ={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Fn={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},lB=["fragment","vertex"],T_=["setup","analyze","generate"],M_=[...lB,"compute"],ff=["x","y","z","w"],GQ={analyze:"setup",generate:"analyze"},WQ=0,(Ee=class extends En{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=Ue.NONE,this.updateBeforeType=Ue.NONE,this.updateAfterType=Ue.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=WQ++,this.stackTrace=null,Ee.captureStackTrace===!0&&(this.stackTrace=new Ts)}set needsUpdate(t){t===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=Ft.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,Ue.FRAME)}onRenderUpdate(t){return this.onUpdate(t,Ue.RENDER)}onObjectUpdate(t){return this.onUpdate(t,Ue.OBJECT)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let e of this.getChildren())e.traverse(t)}_getChildren(t=new Set){let e=[];t.add(this);for(let i of Object.getOwnPropertyNames(this)){let r=this[i];if(i.startsWith("_")!==!0&&!t.has(r)){if(Array.isArray(r)===!0)for(let s=0;s<r.length;s++){let n=r[s];n&&n.isNode===!0&&e.push({property:i,index:s,childNode:n})}else if(r&&r.isNode===!0)e.push({property:i,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let s in r){if(s.startsWith("_")===!0)continue;let n=r[s];n&&n.isNode===!0&&e.push({property:i,index:s,childNode:n})}}}return e}getCacheKey(t=!1,e=null){if((t=t||this.version!==this._cacheKeyVersion)===!0||this._cacheKey===null){e===null&&(e=new Set);let i=[];for(let{property:r,childNode:s}of this._getChildren(e))i.push(pf(r.slice(0,-4)),s.getCacheKey(t,e));this._cacheKey=iy(ey(i),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){let e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t,e=null){let i,r=t.getDataFromNode(this);return e!==null?(r.typeFromOutput=r.typeFromOutput||{},i=r.typeFromOutput[e],i===void 0&&(i=this.generateNodeType(t,e),r.typeFromOutput[e]=i)):(i=r.type,i===void 0&&(i=this.generateNodeType(t),r.type=i)),i}generateNodeType(t,e=null){let i=t.getNodeProperties(this);return i.outputNode?i.outputNode.getNodeType(t,e):this.nodeType}getShared(t){let e=this.getHash(t),i=t.getNodeFromHash(e),r=null;if(i&&i!==this)r=i;else if(t.context.overrideNodes){let s=t.context.overrideNodes.get(this);if(s){let n=t.getDataFromNode(this);n.isOverwritten!==!0?(n.isOverwritten=!0,r=s(t).overrideNode(this,null),n.sharedNode=r):r=n.sharedNode}}return r||this}getArrayCount(){return null}setup(t){let e=t.getNodeProperties(this),i=0;for(let r of this.getChildren())e["node"+i++]=r;return e.outputNode||null}analyze(t,e=null){let i=t.increaseUsage(this);if(this.parents===!0){let r=t.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[t.shaderStage]=r.stages[t.shaderStage]||[],r.stages[t.shaderStage].push(e)}if(i===1){let r=t.getNodeProperties(this);for(let s of Object.values(r))s&&s.isNode===!0&&s.build(t,this)}}generate(t,e){let{outputNode:i}=t.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(t,e)}updateBefore(){ne("Abstract function.")}updateAfter(){ne("Abstract function.")}update(){ne("Abstract function.")}before(t){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,e=null){let i=this.getShared(t);if(this!==i)return i.build(t,e);if(this._beforeNodes!==null){let o=this._beforeNodes;this._beforeNodes=null;for(let l of o)l.build(t,e);this._beforeNodes=o}let r=t.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[t.buildStage]=!0;let s=GQ[t.buildStage];if(s&&r.buildStages[s]!==!0){let o=t.getBuildStage();t.setBuildStage(s),this.build(t),t.setBuildStage(o)}t.addChain(this);let n=null,a=t.getBuildStage();if(a==="setup"){t.addNode(this),this.updateReference(t);let o=t.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(t)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=t.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(t)}t.addSequentialNode(this)}n=o.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate"){if(this.generate.length<2){let o=this.getNodeType(t),l=t.getDataFromNode(this);n=l.snippet,n===void 0?l.generated===void 0?(l.generated=!0,n=this.generate(t)||"",l.snippet=n):(ne("Node: Recursion detected.",this),n="/* Recursion detected. */"):l.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,o,e)}else n=this.generate(t,e)||"";n===""&&e!==null&&e!=="void"&&e!=="OutputType"&&(Xt(`TSL: Invalid generated code, expected a "${e}".`),n=t.generateConst(e))}return t.removeChain(this),n}getSerializeChildren(){return this._getChildren()}serialize(t){let e=this.getSerializeChildren(),i={};for(let{property:r,index:s,childNode:n}of e)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=n.toJSON(t.meta).uuid):i[r]=n.toJSON(t.meta).uuid;Object.keys(i).length>0&&(t.inputNodes=i)}deserialize(t){if(t.inputNodes!==void 0){let e=t.meta.nodes;for(let i in t.inputNodes)if(Array.isArray(t.inputNodes[i])){let r=[];for(let s of t.inputNodes[i])r.push(e[s]);this[i]=r}else if(typeof t.inputNodes[i]=="object"){let r={};for(let s in t.inputNodes[i]){let n=t.inputNodes[i][s];r[s]=e[n]}this[i]=r}else{let r=t.inputNodes[i];this[i]=e[r]}}}toJSON(t){let{uuid:e,type:i}=this,r=t===void 0||typeof t=="string";r&&(t={textures:{},images:{},nodes:{}});let s=t.nodes[e];function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s===void 0&&(s={uuid:e,type:i,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(t.nodes[s.uuid]=s),this.serialize(s),delete s.meta),r){let a=n(t.textures),o=n(t.images),l=n(t.nodes);a.length>0&&(s.textures=a),o.length>0&&(s.images=o),l.length>0&&(s.nodes=l)}return s}}).captureStackTrace=!1,Jc=class extends Ee{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}generateNodeType(t){return this.node.getElementType(t)}getMemberType(t,e){return this.node.getMemberType(t,e)}generate(t){let e=this.indexNode.getNodeType(t);return`${this.node.build(t)}[ ${this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint")} ]`}},hB=class extends Ee{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}generateNodeType(t){let e=this.node.getNodeType(t),i=null;for(let r of this.convertTo.split("|"))(i===null||t.getTypeLength(e)===t.getTypeLength(r))&&(i=r);return i}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){let i=this.node,r=this.getNodeType(t),s=i.build(t,r);return t.format(s,r,e)}},Cr=class extends Ee{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){let i=t.getVectorType(this.getNodeType(t,e)),r=t.getDataFromNode(this);if(r.propertyName!==void 0)return t.format(r.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){let s=super.build(t,i),n=t.getVarFromNode(this,null,i),a=t.getPropertyName(n);return t.addLineFlowCode(`${a} = ${s}`,this),r.snippet=s,r.propertyName=a,t.format(r.propertyName,i,e)}}return super.build(t,e)}},qQ=class extends Cr{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}generateNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,i)=>e+t.getTypeLength(i.getNodeType(t)),0))}generate(t,e){let i=this.getNodeType(t),r=t.getTypeLength(i),s=this.nodes,n=t.getComponentType(i),a=[],o=0;for(let h of s){if(o>=r){Xt(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let u,d=h.getNodeType(t),c=t.getTypeLength(d);if(o+c>r&&(Xt(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-o,d=t.getTypeFromLength(c)),o+=c,u=h.build(t,d),t.getComponentType(d)!==n){let p=t.getTypeFromLength(c,n);u=t.format(u,d,p)}a.push(u)}let l=`${t.getType(i)}( ${a.join(", ")} )`;return t.format(l,i,e)}},HQ=ff.join(""),s9=class extends Ee{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(let e of this.components)t=Math.max(ff.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}generateNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}getScope(){return this.node.getScope()}generate(t,e){let i=this.node,r=t.getTypeLength(i.getNodeType(t)),s=null;if(r>1){let n=null;this.getVectorLength()>=r&&(n=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));let a=i.build(t,n);s=this.components.length===r&&this.components===HQ.slice(0,this.components.length)?t.format(a,n,e):t.format(`${a}.${this.components}`,this.getNodeType(t),e)}else s=i.build(t,e);return s}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}},T1t=class extends Cr{static get type(){return"SetNode"}constructor(t,e,i){super(),this.sourceNode=t,this.components=e,this.targetNode=i}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:i,targetNode:r}=this,s=this.getNodeType(t),n=t.getComponentType(r.getNodeType(t)),a=t.getTypeFromLength(i.length,n),o=r.build(t,a),l=e.build(t,s),h=t.getTypeLength(s),u=[];for(let d=0;d<h;d++){let c=ff[d];c===i[0]?(u.push(o),d+=i.length-1):u.push(l+"."+c)}return`${t.getType(s)}( ${u.join(", ")} )`}},M1t=class extends Cr{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{components:e,sourceNode:i}=this,r=this.getNodeType(t),s=i.build(t),n=t.getVarFromNode(this),a=t.getPropertyName(n);t.addLineFlowCode(a+" = "+s,this);let o=t.getTypeLength(r),l=[],h=0;for(let u=0;u<o;u++){let d=ff[u];d===e[h]?(l.push("1.0 - "+a+"."+d),h++):l.push(a+"."+d)}return`${t.getType(r)}( ${l.join(", ")} )`}},yA=class extends Ee{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}generateNodeType(){return this.nodeType===null?Qc(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Qc(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=function(e){let i="",r=new Uint8Array(e);for(let s=0;s<r.length;s++)i+=String.fromCharCode(r[s]);return btoa(i)}(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?tB(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){ne("Abstract function.")}},uB=/float|u?int/,fh=class extends yA{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let i=this.getNodeType(t);return uB.test(i)&&uB.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),i,e)}},$Q=class extends Ee{static get type(){return"MemberNode"}constructor(t,e){super(),this.structNode=t,this.property=e,this.isMemberNode=!0}hasMember(t){return(!this.structNode.isMemberNode||this.structNode.hasMember(t)!==!1)&&this.structNode.getMemberType(t,this.property)!=="void"}generateNodeType(t){return this.hasMember(t)===!1?"float":this.structNode.getMemberType(t,this.property)}getMemberType(t,e){if(this.hasMember(t)===!1)return"float";let i=this.getNodeType(t);return t.getStructTypeNode(i).getMemberType(t,e)}generate(t){if(this.hasMember(t)===!1){ne(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let e=this.getNodeType(t);return t.generateConst(e)}return this.structNode.build(t)+"."+this.property}},ec=null,c5=new Map,XQ=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),n9=t=>XQ(t).split("").sort().join(""),Ee.prototype.assign=function(...t){if(this.isStackNode!==!0)return ec!==null?ec.assign(this,...t):Xt("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Ts),this;{let e=c5.get("assign");return this.addToStack(e(...t))}},Ee.prototype.toVarIntent=function(){return this},Ee.prototype.get=function(t){return new $Q(this,t)},wv={},gh=["x","y","z","w"],yh=["r","g","b","a"],vh=["s","t","p","q"];for(let t=0;t<4;t++){let e=gh[t],i=yh[t],r=vh[t];mA(e,i,r);for(let s=0;s<4;s++){e=gh[t]+gh[s],i=yh[t]+yh[s],r=vh[t]+vh[s],mA(e,i,r);for(let n=0;n<4;n++){e=gh[t]+gh[s]+gh[n],i=yh[t]+yh[s]+yh[n],r=vh[t]+vh[s]+vh[n],mA(e,i,r);for(let a=0;a<4;a++)e=gh[t]+gh[s]+gh[n]+gh[a],i=yh[t]+yh[s]+yh[n]+yh[a],r=vh[t]+vh[s]+vh[n]+vh[a],mA(e,i,r)}}}for(let t=0;t<32;t++)wv[t]={get(){this._cache=this._cache||{};let e=this._cache[t];return e===void 0&&(e=new Jc(this,new fh(t,"uint")),this._cache[t]=e),e},set(e){this[t].assign(ve(e))}};Object.defineProperties(Ee.prototype,wv),YQ=function(t,e=null){let i=Qc(t);return i==="node"?t:e===null&&(i==="float"||i==="boolean")||i&&i!=="shader"&&i!=="string"?ve(xA(t,e)):i==="shader"?t.isFn?t:it(t):t},KQ=function(t,e=null){for(let i in t)t[i]=ve(t[i],e);return t},ZQ=function(t,e=null){let i=t.length;for(let r=0;r<i;r++)t[r]=ve(t[r],e);return t},dB=function(t,e=null,i=null,r=null){function s(u){return r!==null?(u=ve(Object.assign(u,r)),r.intent===!0&&(u=u.toVarIntent())):u=ve(u),u}let n,a,o,l=e;function h(u){let d;return d=l?/[a-z]/i.test(l)?l+"()":l:t.type,a!==void 0&&u.length<a?(Xt(`TSL: "${d}" parameter length is less than minimum required.`,new Ts),u.concat(new Array(a-u.length).fill(0))):o!==void 0&&u.length>o?(Xt(`TSL: "${d}" parameter length exceeds limit.`,new Ts),u.slice(0,o)):u}return e===null?n=(...u)=>s(new t(...tp(h(u)))):i!==null?(i=ve(i),n=(...u)=>s(new t(e,...tp(h(u)),i))):n=(...u)=>s(new t(e,...tp(h(u)))),n.setParameterLength=(...u)=>(u.length===1?a=o=u[0]:u.length===2&&([a,o]=u),n),n.setName=u=>(l=u,n),n},QQ=function(t,...e){return new t(...tp(e))},JQ=class extends Ee{constructor(t,e){super(),this.shaderNode=t,this.rawInputs=e,this.isShaderCallNodeInternal=!0}generateNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getElementType(t){return this.getOutputNode(t).getElementType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,rawInputs:i}=this,r=t.getNodeProperties(e),s=t.getClosestSubBuild(e.subBuilds)||"",n=s||"default";if(r[n])return r[n];let a=t.subBuildFn,o=t.fnCall;t.subBuildFn=s,t.fnCall=this;let l=null;if(e.layout){if(i){let d=e.layout.inputs;if(lQ(i)){let c=i;for(let p=0;p<d.length;p++){let m=c[p];m&&m.isNode&&m.build(t)}}else{let c=i[0];for(let p of d){let m=c[p.name];m&&m.isNode&&m.build(t)}}}let h=t.buildFunctionNode(e);t.addInclude(h);let u=i?function(d){let c;return E_(d),c=lQ(d)?[...d]:d[0],c}(i):null;l=h.call(u)}else{let h=new Proxy(t,{get:(m,f,g)=>{let y;return y=Symbol.iterator===f?function*(){yield}:Reflect.get(m,f,g),y}}),u=i?function(m){let f=0;return E_(m),new Proxy(m,{get:(g,y,v)=>{let b;if(y==="length")return b=m.length,b;if(Symbol.iterator===y)b=function*(){for(let _ of m)yield ve(_)};else{if(m.length>0)if(Object.getPrototypeOf(m[0])===Object.prototype){let _=m[0];b=_[y]===void 0?_[f++]:Reflect.get(_,y,v)}else m[0]instanceof Ee&&(b=m[y]===void 0?m[f++]:Reflect.get(m,y,v));else b=Reflect.get(g,y,v);b=ve(b)}return b}})}(i):null,d=Array.isArray(i)?i.length>0:i!==null,c=e.jsFunc,p=d||c.length>1?c(u,h):c(h);l=ve(p)}return t.subBuildFn=a,t.fnCall=o,e.once&&(r[n]=l),l}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),i=t.getSubBuildOutput(this);return e[i]=e[i]||this.setupOutput(t),e[i].subBuild=t.getClosestSubBuild(this),e[i]}build(t,e=null){let i=null,r=t.getBuildStage(),s=t.getNodeProperties(this),n=t.getSubBuildOutput(this),a=this.getOutputNode(t),o=t.fnCall;if(t.fnCall=this,r==="setup"){let l=t.getSubBuildProperty("initialized",this);if(s[l]!==!0&&(s[l]=!0,s[n]=this.getOutputNode(t),s[n].build(t),this.shaderNode.subBuilds))for(let h of t.chaining){let u=t.getDataFromNode(h,"any");u.subBuilds=u.subBuilds||new Set;for(let d of this.shaderNode.subBuilds)u.subBuilds.add(d)}i=s[n]}else r==="analyze"?a.build(t,e):r==="generate"&&(i=a.build(t,e)||"");return t.fnCall=o,i}},A1t=class extends Ee{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}getLayout(){return this.layout}call(t=null){return new JQ(this,t)}setup(){return this.call()}},tJ=[!1,!0],eJ=[0,1,2,3],iJ=[-1,-2],cB=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],vA=new Map;for(let t of tJ)vA.set(t,new fh(t));bA=new Map;for(let t of eJ)bA.set(t,new fh(t,"uint"));_A=new Map([...bA].map(t=>new fh(t.value,"int")));for(let t of iJ)_A.set(t,new fh(t,"int"));A_=new Map([..._A].map(t=>new fh(t.value)));for(let t of cB)A_.set(t,new fh(t));for(let t of cB)A_.set(-t,new fh(-t));C_={bool:vA,uint:bA,ints:_A,float:A_},pB=new Map([...vA,...A_]),xA=(t,e)=>pB.has(t)?pB.get(t):t.isNode===!0?t:new fh(t,e),Hs=function(t,e=null){return(...i)=>{for(let s of i)if(s===void 0)return Xt(`TSL: Invalid parameter for the type "${t}".`,new Ts),new fh(0,t);if((i.length===0||!["bool","float","int","uint"].includes(t)&&i.every(s=>{let n=typeof s;return n!=="object"&&n!=="function"}))&&(i=[tB(t,...i)]),i.length===1&&e!==null&&e.has(i[0]))return ry(e.get(i[0]));if(i.length===1){let s=xA(i[0],t);return s.nodeType===t?ry(s):ry(new hB(s,t))}let r=i.map(s=>xA(s));return ry(new qQ(r,t))}},mB=t=>t!=null?t.nodeType||t.convertTo||(typeof t=="string"?t:null):null,ve=(t,e=null)=>YQ(t,e),ry=(t,e=null)=>ve(t,e).toVarIntent(),E_=(t,e=null)=>new KQ(t,e),tp=(t,e=null)=>new ZQ(t,e),ui=(t,e=null,i=null,r=null)=>new dB(t,e,i,r),te=(t,...e)=>new QQ(t,...e),Wt=(t,e=null,i=null,r={})=>new dB(t,e,i,{...r,intent:!0}),wA=(t,e)=>new Proxy(t,{get:(i,r,s)=>Reflect.get(e,r,s),set:(i,r,s)=>Reflect.set(e,r,s)}),rJ=0,C1t=class extends Ee{constructor(t,e=null){super();let i=null;e!==null&&(typeof e=="object"?i=e.return:(typeof e=="string"?i=e:Xt("TSL: Invalid layout type.",new Ts),e=null)),this.shaderNode=new J0(t,i),e!==null&&this.setLayout(e),this.isFn=!0}setLayout(t){let e=this.shaderNode.nodeType;if(typeof t.inputs!="object"){let i={name:"fn"+rJ++,type:e,inputs:[]};for(let r in t)r!=="return"&&i.inputs.push({name:r,type:t[r]});t=i}return this.shaderNode.setLayout(t),this}generateNodeType(t){return this.shaderNode.getNodeType(t)||"float"}call(...t){let e=this.shaderNode.call(t);return this.shaderNode.nodeType==="void"&&e.toStack(),e.toVarIntent()}once(t=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=t,this}generate(t){let e=this.getNodeType(t);return Xt('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),t.generateConst(e)}},sy=t=>{ec=t},SA=()=>ec,Se=(...t)=>ec.If(...t),sJ=(...t)=>ec.Switch(...t),At("toStack",fA),fB=new Hs("color"),U=new Hs("float",C_.float),J=new Hs("int",C_.ints),jt=new Hs("uint",C_.uint),To=new Hs("bool",C_.bool),Kt=new Hs("vec2"),ss=new Hs("ivec2"),TA=new Hs("uvec2"),gB=new Hs("bvec2"),rt=new Hs("vec3"),MA=new Hs("ivec3"),ep=new Hs("uvec3"),AA=new Hs("bvec3"),he=new Hs("vec4"),CA=new Hs("ivec4"),EA=new Hs("uvec4"),yB=new Hs("bvec4"),P_=new Hs("mat2"),wn=new Hs("mat3"),ic=new Hs("mat4"),At("toColor",fB),At("toFloat",U),At("toInt",J),At("toUint",jt),At("toBool",To),At("toVec2",Kt),At("toIVec2",ss),At("toUVec2",TA),At("toBVec2",gB),At("toVec3",rt),At("toIVec3",MA),At("toUVec3",ep),At("toBVec3",AA),At("toVec4",he),At("toIVec4",CA),At("toUVec4",EA),At("toBVec4",yB),At("toMat2",P_),At("toMat3",wn),At("toMat4",ic),vB=ui(Jc).setParameterLength(2),bB=(t,e)=>new hB(ve(t),e),nJ=(t,e)=>new s9(ve(t),e),At("element",vB),At("convert",bB),aJ=t=>(ne("TSL: append() has been renamed to Stack().",new Ts),fA(t)),At("append",t=>(ne("TSL: .append() has been renamed to .toStack().",new Ts),fA(t))),cu=(t,e,i=null)=>new Gi(t,e,!1,i),ip=(t,e,i=null)=>new Gi(t,e,!0,i),Ei=te(Gi=class extends Ee{static get type(){return"PropertyNode"}constructor(t,e=null,i=!1,r=null){super(t),this.name=e,this.varying=i,this.placeholderNode=ve(r),this.isPropertyNode=!0,this.global=!0}getNodeType(t){let e=super.getNodeType(t);return e==="output"?t.getOutputType():e}customCacheKey(){return pf(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(t){return this.name||super.getHash(t)}generate(t){let e;if(this.varying===!0)e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0;else if(e=t.getVarFromNode(this,this.name),this.placeholderNode!==null&&t.hasWriteUsage(this)===!1){let i=this.placeholderNode.build(t,this.getNodeType(t));t.addLineFlowCode(`${t.getPropertyName(e)} = ${i}`,this)}return t.getPropertyName(e)}},"vec4","DiffuseColor"),rp=te(Gi,"vec3","DiffuseContribution"),PA=te(Gi,"vec3","EmissiveColor"),bh=te(Gi,"float","Roughness"),pu=te(Gi,"float","Metalness"),R_=te(Gi,"float","Clearcoat"),gf=te(Gi,"float","ClearcoatRoughness"),Mo=te(Gi,"vec3","Sheen"),yd=te(Gi,"float","SheenRoughness"),D_=te(Gi,"float","Iridescence"),O_=te(Gi,"float","IridescenceIOR"),I_=te(Gi,"float","IridescenceThickness"),N_=te(Gi,"float","AlphaT"),vd=te(Gi,"float","Anisotropy"),ny=te(Gi,"vec3","AnisotropyT"),sp=te(Gi,"vec3","AnisotropyB"),bd=te(Gi,"color","SpecularColor"),np=te(Gi,"color","SpecularColorBlended"),ap=te(Gi,"float","SpecularF90"),B_=te(Gi,"float","Shininess"),yf=te(Gi,"output","Output"),op=te(Gi,"float","dashSize"),ay=te(Gi,"float","gapSize"),oJ=te(Gi,"float","pointWidth"),oy=te(Gi,"float","IOR"),k_=te(Gi,"float","Transmission"),RA=te(Gi,"float","Thickness"),DA=te(Gi,"float","AttenuationDistance"),OA=te(Gi,"color","AttenuationColor"),IA=te(Gi,"float","Dispersion"),NA=te(Gi,"float","AmbientOcclusion",!1,1),_B=class extends Ee{static get type(){return"UniformGroupNode"}constructor(t,e=!1,i=1,r=null){super("string"),this.name=t,this.shared=e,this.order=i,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}},xB=(t,e=1,i=null)=>new _B(t,!1,e,i),lJ=(BA=(t,e=0,i=null)=>new _B(t,!0,e,i))("frame",0,Ue.FRAME),Ce=BA("render",0,Ue.RENDER),wB=xB("object",1,Ue.OBJECT),ly=class extends yA{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=wB}setName(t){return this.name=t,this}label(t){return ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new Ts),this.setName(t)}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){return t=t.bind(this),super.onUpdate(i=>{let r=t(i,this);r!==void 0&&(this.value=r)},e)}getInputType(t){let e=super.getInputType(t);return e==="bool"&&(e="uint"),e}generate(t,e){let i=this.getNodeType(t),r=this.getUniformHash(t),s=t.getNodeFromHash(r);s===void 0&&(t.setHashNode(this,r),s=this);let n=s.getInputType(t),a=t.getUniformFromNode(s,n,t.shaderStage,this.name||t.context.nodeName),o=t.getPropertyName(a);t.context.nodeName!==void 0&&delete t.context.nodeName;let l=o;if(i==="bool"){let h=t.getDataFromNode(this),u=h.propertyName;if(u===void 0){let d=t.getVarFromNode(this,null,"bool");u=t.getPropertyName(d),h.propertyName=u,l=t.format(o,n,i),t.addLineFlowCode(`${u} = ${l}`,this)}l=u}return t.format(l,i,e)}},we=(t,e)=>{let i=mB(e||t);if(i===t&&(t=tB(i)),t&&t.isNode===!0){let r=t.value;t.traverse(s=>{s.isConstNode===!0&&(r=s.value)}),t=r}return new ly(t,i)},SB=class extends Cr{static get type(){return"ArrayNode"}constructor(t,e,i=null){super(t),this.count=e,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(t){return this.nodeType===null?this.values[0].getNodeType(t):this.nodeType}getElementType(t){return this.getNodeType(t)}getMemberType(t,e){return this.nodeType===null?this.values[0].getMemberType(t,e):super.getMemberType(t,e)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}},TB=(...t)=>{let e;if(t.length===1){let i=t[0];e=new SB(null,i.length,i)}else{let i=t[0],r=t[1];e=new SB(i,r)}return ve(e)},At("toArray",(t,e)=>TB(Array(e).fill(t))),At("assign",hJ=ui(class extends Cr{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let i=t.getTypeLength(e.node.getNodeType(t));return ff.join("").slice(0,i)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:i}=this,r=e.getScope();t.getDataFromNode(r).assign=!0;let s=t.getNodeProperties(this);s.sourceNode=i,s.targetNode=e.context({assign:!0})}generate(t,e){let i,{targetNode:r,sourceNode:s}=t.getNodeProperties(this),n=this.needsSplitAssign(t),a=r.build(t),o=r.getNodeType(t),l=s.build(t,o),h=s.getNodeType(t),u=t.getDataFromNode(this);if(u.initialized===!0)e!=="void"&&(i=a);else if(n){let d=t.getVarFromNode(this,null,o),c=t.getPropertyName(d);t.addLineFlowCode(`${c} = ${l}`,this);let p=r.node,m=p.node.context({assign:!0}).build(t);for(let f=0;f<p.components.length;f++){let g=p.components[f];t.addLineFlowCode(`${m}.${g} = ${c}[ ${f} ]`,this)}e!=="void"&&(i=a)}else i=`${a} = ${l}`,(e==="void"||h==="void")&&(t.addLineFlowCode(i,this),e!=="void"&&(i=a));return u.initialized=!0,t.format(i,o,e)}}).setParameterLength(2)),uJ=class extends Cr{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}generateNodeType(t){return this.functionNode.getNodeType(t)}getMemberType(t,e){return this.functionNode.getMemberType(t,e)}generate(t){let e=[],i=this.functionNode,r=i.getInputs(t),s=this.parameters,n=(a,o)=>{let l,h=o.type;return l=h==="pointer"?"&"+a.build(t):a.build(t,h),l};if(Array.isArray(s)){if(s.length>r.length)Xt("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length<r.length)for(Xt("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<r.length;)s.push(U(0));for(let a=0;a<s.length;a++)e.push(n(s[a],r[a]))}else for(let a of r){let o=s[a.name];o!==void 0?e.push(n(o,a)):(Xt(`TSL: Input '${a.name}' not found in 'Fn()'.`),e.push(n(U(0),a)))}return`${i.build(t,"property")}( ${e.join(", ")} )`}},At("call",dJ=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?tp(e):E_(e[0]),new uJ(ve(t),e))),cJ={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},Is=Wt(bs=class extends Cr{static get type(){return"OperatorNode"}constructor(t,e,i,...r){if(super(),r.length>0){let s=new bs(t,e,i);for(let n=0;n<r.length-1;n++)s=new bs(t,s,r[n]);e=s,i=r[r.length-1]}this.op=t,this.aNode=e,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(cJ[this.op],e)}generateNodeType(t,e=null){let i=this.op,r=this.aNode,s=this.bNode,n=r.getNodeType(t),a=s?s.getNodeType(t):null;if(n==="void"||a==="void")return e||"void";if(i==="%")return n;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return t.getIntegerType(n);if(i==="&&"||i==="||"||i==="^^")return"bool";if(i==="!"){let o=t.getTypeLength(n);return o>1?`bvec${o}`:"bool"}if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}generate(t,e){let i=this.op,{aNode:r,bNode:s}=this,n=this.getNodeType(t,e),a=null,o=null;n!=="void"?(a=r.getNodeType(t),o=s?s.getNodeType(t):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?t.isVector(a)?o=a:t.isVector(o)?a=o:a!==o&&(a=o="float"):i===">>"||i==="<<"?(a=n,o=t.changeComponentType(o,"uint")):i==="%"?(a=n,o=t.isInteger(a)&&t.isInteger(o)?o:a):t.isMatrix(a)?o==="float"?o="float":t.isVector(o)?o=t.getVectorFromMatrix(a):t.isMatrix(o)||(a=o=n):a=t.isMatrix(o)?a==="float"?"float":t.isVector(a)?t.getVectorFromMatrix(o):o=n:o=n):a=o=n;let l=r.build(t,a),h=s?s.build(t,o):null,u=t.getFunctionOperator(i);if(e!=="void"){let d=t.renderer.coordinateSystem===Bo;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return d&&t.isVector(a)?t.format(`${this.getOperatorMethod(t,e)}( ${l}, ${h} )`,n,e):t.format(`( ${l} ${i} ${h} )`,n,e);if(i==="%")return t.isInteger(o)?t.format(`( ${l} % ${h} )`,n,e):t.format(`${this.getOperatorMethod(t,n)}( ${l}, ${h} )`,n,e);if(i==="!")return d&&t.isVector(a)?t.format(`not( ${l} )`,e):t.format(`( ${i} ${l} )`,a,e);if(i==="~")return t.format(`( ${i} ${l} )`,a,e);if(u)return t.format(`${u}( ${l}, ${h} )`,n,e);if(t.isMatrix(a)&&o==="float")return t.format(`( ${h} ${i} ${l} )`,n,e);if(a==="float"&&t.isMatrix(o))return t.format(`${l} ${i} ${h}`,n,e);{let c=`( ${l} ${i} ${h} )`;return!d&&n==="bool"&&t.isVector(a)&&t.isVector(o)&&(c=`all${c}`),t.format(c,n,e)}}if(a!=="void")return u?t.format(`${u}( ${l}, ${h} )`,n,e):t.isMatrix(a)&&o==="float"?t.format(`${h} ${i} ${l}`,n,e):t.format(`${l} ${i} ${h}`,n,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}},"+").setParameterLength(2,1/0).setName("add"),Mi=Wt(bs,"-").setParameterLength(2,1/0).setName("sub"),qe=Wt(bs,"*").setParameterLength(2,1/0).setName("mul"),Ao=Wt(bs,"/").setParameterLength(2,1/0).setName("div"),V_=Wt(bs,"%").setParameterLength(2).setName("mod"),MB=Wt(bs,"==").setParameterLength(2).setName("equal"),AB=Wt(bs,"!=").setParameterLength(2).setName("notEqual"),CB=Wt(bs,"<").setParameterLength(2).setName("lessThan"),kA=Wt(bs,">").setParameterLength(2).setName("greaterThan"),EB=Wt(bs,"<=").setParameterLength(2).setName("lessThanEqual"),PB=Wt(bs,">=").setParameterLength(2).setName("greaterThanEqual"),RB=Wt(bs,"&&").setParameterLength(2,1/0).setName("and"),DB=Wt(bs,"||").setParameterLength(2,1/0).setName("or"),OB=Wt(bs,"!").setParameterLength(1).setName("not"),IB=Wt(bs,"^^").setParameterLength(2).setName("xor"),NB=Wt(bs,"&").setParameterLength(2).setName("bitAnd"),BB=Wt(bs,"~").setParameterLength(1).setName("bitNot"),kB=Wt(bs,"|").setParameterLength(2).setName("bitOr"),VB=Wt(bs,"^").setParameterLength(2).setName("bitXor"),zB=Wt(bs,"<<").setParameterLength(2).setName("shiftLeft"),LB=Wt(bs,">>").setParameterLength(2).setName("shiftRight"),FB=it(([t])=>(t.addAssign(1),t)),UB=it(([t])=>(t.subAssign(1),t)),jB=it(([t])=>{let e=J(t).toConst();return t.addAssign(1),e}),GB=it(([t])=>{let e=J(t).toConst();return t.subAssign(1),e}),At("add",Is),At("sub",Mi),At("mul",qe),At("div",Ao),At("mod",V_),At("equal",MB),At("notEqual",AB),At("lessThan",CB),At("greaterThan",kA),At("lessThanEqual",EB),At("greaterThanEqual",PB),At("and",RB),At("or",DB),At("not",OB),At("xor",IB),At("bitAnd",NB),At("bitNot",BB),At("bitOr",kB),At("bitXor",VB),At("shiftLeft",zB),At("shiftRight",LB),At("incrementBefore",FB),At("decrementBefore",UB),At("increment",jB),At("decrement",GB),(ct=class extends Cr{static get type(){return"MathNode"}constructor(t,e,i=null,r=null){if(super(),(t===ct.MAX||t===ct.MIN)&&arguments.length>3){let s=new ct(t,e,i);for(let n=3;n<arguments.length-1;n++)s=new ct(t,s,arguments[n]);e=s,i=arguments[arguments.length-1],r=null}this.method=t,this.aNode=e,this.bNode=i,this.cNode=r,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),i=this.bNode?this.bNode.getNodeType(t):null,r=this.cNode?this.cNode.getNodeType(t):null,s=t.isMatrix(e)?0:t.getTypeLength(e),n=t.isMatrix(i)?0:t.getTypeLength(i),a=t.isMatrix(r)?0:t.getTypeLength(r);return s>n&&s>a?e:n>a?i:a>s?r:e}generateNodeType(t){let e=this.method;return e===ct.LENGTH||e===ct.DISTANCE||e===ct.DOT?"float":e===ct.CROSS?"vec3":e===ct.ALL||e===ct.ANY?"bool":e===ct.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:i,method:r}=this,s=null;if(r===ct.ONE_MINUS)s=Mi(1,e);else if(r===ct.RECIPROCAL)s=Ao(1,e);else if(r===ct.DIFFERENCE)s=xr(Mi(e,i));else if(r===ct.TRANSFORM_DIRECTION){let n,a;t.isMatrix(e.getNodeType(t))?(n=e,a=i):(n=i,a=e),s=ca(qe(n,he(rt(a),0)).xyz)}return s!==null?s:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,r=this.getNodeType(t),s=this.getInputType(t),n=this.aNode,a=this.bNode,o=this.cNode,l=t.renderer.coordinateSystem;if(i===ct.NEGATE)return t.format("( - "+n.build(t,s)+" )",r,e);{let h=[];return i===ct.CROSS?h.push(n.build(t,r),a.build(t,r)):l===Bo&&i===ct.STEP?h.push(n.build(t,t.getTypeLength(n.getNodeType(t))===1?"float":s),a.build(t,s)):l!==Bo||i!==ct.MIN&&i!==ct.MAX?i===ct.REFRACT?h.push(n.build(t,s),a.build(t,s),o.build(t,"float")):i===ct.MIX?h.push(n.build(t,s),a.build(t,s),o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":s)):(l===Lo&&i===ct.ATAN&&a!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===ct.DFDX||i===ct.DFDY)&&(ne(`TSL: '${i}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),h.push(n.build(t,s)),a!==null&&h.push(a.build(t,s)),o!==null&&h.push(o.build(t,s))):h.push(n.build(t,s),a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":s)),t.format(`${t.getMethod(i,r)}( ${h.join(", ")} )`,r,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}).ALL="all",ct.ANY="any",ct.RADIANS="radians",ct.DEGREES="degrees",ct.EXP="exp",ct.EXP2="exp2",ct.LOG="log",ct.LOG2="log2",ct.SQRT="sqrt",ct.INVERSE_SQRT="inversesqrt",ct.FLOOR="floor",ct.CEIL="ceil",ct.NORMALIZE="normalize",ct.FRACT="fract",ct.SIN="sin",ct.SINH="sinh",ct.COS="cos",ct.COSH="cosh",ct.TAN="tan",ct.TANH="tanh",ct.ASIN="asin",ct.ASINH="asinh",ct.ACOS="acos",ct.ACOSH="acosh",ct.ATAN="atan",ct.ATANH="atanh",ct.ABS="abs",ct.SIGN="sign",ct.LENGTH="length",ct.NEGATE="negate",ct.ONE_MINUS="oneMinus",ct.DFDX="dFdx",ct.DFDY="dFdy",ct.ROUND="round",ct.RECIPROCAL="reciprocal",ct.TRUNC="trunc",ct.FWIDTH="fwidth",ct.TRANSPOSE="transpose",ct.DETERMINANT="determinant",ct.INVERSE="inverse",ct.EQUALS="equals",ct.MIN="min",ct.MAX="max",ct.STEP="step",ct.REFLECT="reflect",ct.DISTANCE="distance",ct.DIFFERENCE="difference",ct.DOT="dot",ct.CROSS="cross",ct.POW="pow",ct.TRANSFORM_DIRECTION="transformDirection",ct.MIX="mix",ct.CLAMP="clamp",ct.REFRACT="refract",ct.SMOOTHSTEP="smoothstep",ct.FACEFORWARD="faceforward",z_=U(1e-6),pJ=U(1e6),L_=U(Math.PI),mJ=U(2*Math.PI),fJ=U(2*Math.PI),gJ=U(.5*Math.PI),WB=Wt(ct,ct.ALL).setParameterLength(1),qB=Wt(ct,ct.ANY).setParameterLength(1),HB=Wt(ct,ct.RADIANS).setParameterLength(1),$B=Wt(ct,ct.DEGREES).setParameterLength(1),VA=Wt(ct,ct.EXP).setParameterLength(1),vf=Wt(ct,ct.EXP2).setParameterLength(1),F_=Wt(ct,ct.LOG).setParameterLength(1),_h=Wt(ct,ct.LOG2).setParameterLength(1),ka=Wt(ct,ct.SQRT).setParameterLength(1),zA=Wt(ct,ct.INVERSE_SQRT).setParameterLength(1),xh=Wt(ct,ct.FLOOR).setParameterLength(1),U_=Wt(ct,ct.CEIL).setParameterLength(1),ca=Wt(ct,ct.NORMALIZE).setParameterLength(1),Nl=Wt(ct,ct.FRACT).setParameterLength(1),Va=Wt(ct,ct.SIN).setParameterLength(1),XB=Wt(ct,ct.SINH).setParameterLength(1),Bl=Wt(ct,ct.COS).setParameterLength(1),YB=Wt(ct,ct.COSH).setParameterLength(1),KB=Wt(ct,ct.TAN).setParameterLength(1),ZB=Wt(ct,ct.TANH).setParameterLength(1),QB=Wt(ct,ct.ASIN).setParameterLength(1),JB=Wt(ct,ct.ASINH).setParameterLength(1),LA=Wt(ct,ct.ACOS).setParameterLength(1),tk=Wt(ct,ct.ACOSH).setParameterLength(1),FA=Wt(ct,ct.ATAN).setParameterLength(1,2),ek=Wt(ct,ct.ATANH).setParameterLength(1),xr=Wt(ct,ct.ABS).setParameterLength(1),UA=Wt(ct,ct.SIGN).setParameterLength(1),wh=Wt(ct,ct.LENGTH).setParameterLength(1),jA=Wt(ct,ct.NEGATE).setParameterLength(1),ik=Wt(ct,ct.ONE_MINUS).setParameterLength(1),GA=Wt(ct,ct.DFDX).setParameterLength(1),WA=Wt(ct,ct.DFDY).setParameterLength(1),rk=Wt(ct,ct.ROUND).setParameterLength(1),sk=Wt(ct,ct.RECIPROCAL).setParameterLength(1),qA=Wt(ct,ct.TRUNC).setParameterLength(1),HA=Wt(ct,ct.FWIDTH).setParameterLength(1),nk=Wt(ct,ct.TRANSPOSE).setParameterLength(1),ak=Wt(ct,ct.DETERMINANT).setParameterLength(1),ok=Wt(ct,ct.INVERSE).setParameterLength(1),ao=Wt(ct,ct.MIN).setParameterLength(2,1/0),ns=Wt(ct,ct.MAX).setParameterLength(2,1/0),lp=Wt(ct,ct.STEP).setParameterLength(2),lk=Wt(ct,ct.REFLECT).setParameterLength(2),hk=Wt(ct,ct.DISTANCE).setParameterLength(2),uk=Wt(ct,ct.DIFFERENCE).setParameterLength(2),Zo=Wt(ct,ct.DOT).setParameterLength(2),mu=Wt(ct,ct.CROSS).setParameterLength(2),Qo=Wt(ct,ct.POW).setParameterLength(2),$A=t=>qe(t,t),dk=t=>qe(t,t,t),XA=t=>qe(t,t,t,t),ck=Wt(ct,ct.TRANSFORM_DIRECTION).setParameterLength(2),pk=(t,e)=>ca(qe(e,he(rt(t),0)).xyz),mk=(t,e)=>ca(he(rt(t),0).mul(e).xyz),fk=t=>qe(UA(t),Qo(xr(t),1/3)),YA=t=>Zo(t,t),vi=Wt(ct,ct.MIX).setParameterLength(3),kl=(t,e=0,i=1)=>new ct(ct.CLAMP,ve(t),ve(e),ve(i)),j_=t=>kl(t),KA=Wt(ct,ct.REFRACT).setParameterLength(3),Co=Wt(ct,ct.SMOOTHSTEP).setParameterLength(3),ZA=Wt(ct,ct.FACEFORWARD).setParameterLength(3),gk=it(([t])=>{let e=Zo(t.xy,Kt(12.9898,78.233)),i=V_(e,L_);return Nl(Va(i).mul(43758.5453))}),yk=(t,e,i)=>vi(e,i,t),vk=(t,e,i)=>Co(e,i,t),bk=(t,e)=>lp(e,t),yJ=ZA,vJ=zA,At("all",WB),At("any",qB),At("radians",HB),At("degrees",$B),At("exp",VA),At("exp2",vf),At("log",F_),At("log2",_h),At("sqrt",ka),At("inverseSqrt",zA),At("floor",xh),At("ceil",U_),At("normalize",ca),At("fract",Nl),At("sin",Va),At("sinh",XB),At("cos",Bl),At("cosh",YB),At("tan",KB),At("tanh",ZB),At("asin",QB),At("asinh",JB),At("acos",LA),At("acosh",tk),At("atan",FA),At("atanh",ek),At("abs",xr),At("sign",UA),At("length",wh),At("lengthSq",YA),At("negate",jA),At("oneMinus",ik),At("dFdx",GA),At("dFdy",WA),At("round",rk),At("reciprocal",sk),At("trunc",qA),At("fwidth",HA),At("min",ao),At("max",ns),At("step",bk),At("reflect",lk),At("distance",hk),At("dot",Zo),At("cross",mu),At("pow",Qo),At("pow2",$A),At("pow3",dk),At("pow4",XA),At("transformDirection",ck),At("transformNormalByViewMatrix",pk),At("transformNormalByInverseViewMatrix",mk),At("mix",yk),At("clamp",kl),At("refract",KA),At("smoothstep",vk),At("faceForward",ZA),At("difference",uk),At("saturate",j_),At("cbrt",fk),At("transpose",nk),At("determinant",ak),At("inverse",ok),At("rand",gk),At("select",za=ui(class extends Ee{static get type(){return"ConditionalNode"}constructor(t,e,i=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=i}generateNodeType(t){let{ifNode:e,elseNode:i}=t.getNodeProperties(this);if(e===void 0)return t.flowBuildStage(this,"setup"),this.getNodeType(t);let r=e.getNodeType(t);if(i!==null){let s=i.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(r))return s}return r}setup(t){let e=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=t.context.nodeBlock;t.getDataFromNode(i).parentNodeBlock=s,r!==null&&(t.getDataFromNode(r).parentNodeBlock=s);let n=t.context.uniformFlow,a=t.getNodeProperties(this);a.condNode=e,a.ifNode=n?i:i.context({nodeBlock:i}),a.elseNode=r?n?r:r.context({nodeBlock:r}):null}generate(t,e){let i=this.getNodeType(t),r=t.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",h=l?cu(i).build(t):"";r.nodeProperty=h;let u=s.build(t,"bool");if(t.context.uniformFlow&&a!==null){let c=n.build(t,i),p=a.build(t,i),m=t.getTernary(u,c,p);return t.format(m,i,e)}t.addFlowCode(`
@@ -4463,7 +4463,7 @@ fn HdriSampleBlurred(
4463
4463
  skyTex: texture_2d<f32>, skySamp: sampler,
4464
4464
  cloudsTex: texture_2d<f32>,
4465
4465
  exposure: f32, gamma: f32) -> vec4f {${W_t}}`,[Lg(R7)])({uv:eh,skyTex:ee(t),skySamp:zg(t),cloudsTex:ee(e),exposure:this._uExposure,gamma:this._uGamma})}_rebindComposeTextures(){let t=this.backgroundMesh?.material;!t||!this._skyTarget||!this._cloudsTarget||(t.colorNode=this._buildComposeNode(this._skyTarget.texture,this._cloudsTarget.texture),t.needsUpdate=!0)}detach(){this.backgroundMesh?.parent?.remove(this.backgroundMesh),this._hdri?.detach(),this._teardownLighting(),this._lightingOn=!1}dispose(){this._disposed=!0,this._highCloudsPending=!1,this.detach(),this._hdri?.dispose(),this._hdri=null,this._sunLight?.dispose(),this._sunLight=null,this._skyHemi?.dispose(),this._skyHemi=null,this._luts?.dispose(),this._luts=null,this._baseNoise?.dispose(),this._detailNoise?.dispose(),this._weatherCur.dispose(),this._weatherNext.dispose(),this._highClouds.dispose(),this._skyTarget?.dispose(),this._cloudsTarget?.dispose(),this._envTarget?.dispose(),this._envTarget=null,this._lastEnvKey=null,this._envQuad?.material?.dispose(),this.backgroundMesh?.material?.dispose(),this.backgroundMesh?.geometry.dispose(),this.backgroundMesh=null,this._skyQuad=null,this._cloudsQuad=null,this._envQuad=null,this._cloudsArgs=null,this._cloudsLib=null,this._lastSkyPassKey=null,this._lastCloudsPassKey=null}}}),hRt=j(()=>{wbt(),lRt(),vq=t=>new hxt(t)});function EF(t,e,i){let r=Bh(t.element(e));return or(r.element(i))}var or,Bh,kE,VE,uxt,uRt=j(()=>{ht(),pr(),We(),or=t=>t,Bh=t=>t,kE=Fr("vec4","vSplatColor"),VE=Fr("vec2","vSplatPosition"),uxt=class extends Re{constructor(t){super(),this.uniformsNeedUpdate=!1,this._covariancesTex=ee(new pi),this._centersColorsTex=ee(new pi),this._meshMatrixWorldsTex=ee(new pi),this._focal=gt(new Z),this._viewport=gt(new Z),this._basisViewport=gt(new Z),this._covariancesTextureSize=gt(new Z(1024,1024)),this._centersColorsTextureSize=gt(new Z(1024,1024)),this._orthoZoom=gt(-1),this._velocityMRT=qv({velocity:lt(0)}),this.name="WebGPUSplatMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.side=Rn,this.lights=!1;let e=s=>({get value(){return s.value},set value(n){n&&n.isTexture&&(s.value=n)}}),i=s=>({get value(){return s.value},set value(n){s.value=n}}),r=s=>({value:s});this.uniforms={covariancesTexture:e(this._covariancesTex),centersColorsTexture:e(this._centersColorsTex),meshMatrixWorldsTexture:e(this._meshMatrixWorldsTex),focal:i(this._focal),viewport:i(this._viewport),basisViewport:i(this._basisViewport),covariancesTextureSize:i(this._covariancesTextureSize),centersColorsTextureSize:i(this._centersColorsTextureSize),orthoZoom:i(this._orthoZoom),meshIndexIntervals:r(t),debugColor:r(new ae)},this._buildGraph(t)}_buildGraph(t){let e=this._covariancesTex,i=this._centersColorsTex,r=this._meshMatrixWorldsTex,s=this._focal,n=this._basisViewport,a=this._covariancesTextureSize,o=this._centersColorsTextureSize,l=this._orthoZoom,h=Et(()=>{let d=Uv("splatIndex","uint"),c=(Pt,oe,Gt)=>{let Zt=d.mul(Li(Pt)).add(Li(oe)).toFloat().div(or(Gt.x));return at(Ii(Zt),pe(Zt).div(or(Gt.y)))},p=i.sample(c(1,0,o)).toVar(),m=Bh(k1t(Dvt(p.y,p.z,p.w),"vec3")).toVar(),f=p.x;kE.assign(lt(f.bitAnd(Li(255)).toFloat(),f.shiftRight(Li(8)).bitAnd(Li(255)).toFloat(),f.shiftRight(Li(16)).bitAnd(Li(255)).toFloat(),f.shiftRight(Li(24)).bitAnd(Li(255)).toFloat()).mul(1/255));let g=Bh(Uv("position","vec3")).xy.mul(2).toVar();VE.assign(g);let y=N(0);for(let Pt=1;Pt<t.length-1;Pt++)y=or(y.add(d.greaterThanEqual(Li(t[Pt])).select(N(1),N(0))));let v=y.mul(4).toVar(),b=Pt=>r.sample(at(v.add(Pt).div(1024),0)),_=sq(b(0),b(1),b(2),b(3)),x=rh.mul(_).toVar(),S=x.mul(lt(m,1)).toVar(),w=hb.mul(S).toVar(),T=e.sample(c(3,0,a)).xy.toVar(),C=e.sample(c(3,1,a)).xy.toVar(),M=e.sample(c(3,2,a)).xy.toVar(),A=or(T.x),R=or(T.y),I=or(C.x),O=or(C.y),B=or(M.x),V=or(M.y),z=xm(A,R,I,R,O,B,I,B,V),k=N(1).div(or(S.z).mul(or(S.z))).toVar(),L=x,H=xm(Bh(L.element(0).xyz),Bh(L.element(1).xyz),Bh(L.element(2).xyz)).transpose(),W=xm(or(s.x).div(or(S.z)),0,or(s.x).mul(or(S.x)).negate().mul(k),0,or(s.y).div(or(S.z)),or(s.y).mul(or(S.y)).negate().mul(k),0,0,0),X=Pt=>{let oe=Pt.transpose().mul(z).mul(Pt);return Bh(lt(EF(oe,0,0).add(.3),EF(oe,0,1),EF(oe,1,1).add(.3),0).xyz)},nt=l.greaterThan(0),st=Bh(nt.select(X(H),X(H.mul(W)))).toVar(),yt=Bh(w.xyz.div(or(w.w))).toVar(),pt=or(st.x),Q=or(st.z),ut=or(st.y),wt=pt.mul(Q).sub(ut.mul(ut)),St=pt.add(Q),Tt=St.mul(.5),vt=Sl(Qt(St.mul(St).div(4).sub(wt),0)).toVar(),It=Tt.add(vt).toVar(),Ut=Qt(Tt.sub(vt),0).toVar(),Bt=xe(at(ut,It.sub(pt))).toVar(),zt=at(or(Bt.y),or(Bt.x).negate()).toVar(),kt=Bt.mul(ii(Sl(It.mul(2)),1024)).toVar(),qt=zt.mul(ii(Sl(Ut.mul(2)),1024)).toVar(),$t=kt.mul(or(g.x)).add(qt.mul(or(g.y))).mul(n).toVar();return $t.assign(nt.select($t.mul(l),$t)),lt(yt.xy.add($t),or(yt.z),1)}),u=Et(()=>{let d=VE.dot(VE).negate().toVar();d.lessThan(-4).discard();let c=ED(d).mul(or(kE.w));return lt(Bh(kE.xyz),c)});this.vertexNode=h(),this.colorNode=u(),this.needsUpdate=!0}setup(t){let e=t.renderer.getMRT?.();this.mrtNode=e?this._velocityMRT:null,super.setup(t)}nodeMaterialDispose(){this.dispose()}}});function dRt(){let t=gt(1),e=gt(.6),i=gt(1),r=gt(1),s=gt(new ae(16603997)),n=gt(new ae(2857471)),a=gt(new ae(3728051)),o=gt(9),l=gt(new Z),h=new Re;h.name="EditorGridNodeMaterial",h.transparent=!0,h.lights=!1,h.fog=!1;let u=fi(kh(o).equal(10),W1(a),W1(n)),d=fi(kh(o).equal(8),W1(a),W1(s)),c=fi(Hv.x.equal(kh(l.x)),u,fi(Hv.z.equal(kh(l.y)),d,G(.5)));h.colorNode=W1(c);let p=Bc.z.negate(),m=tr(kh(i).mul(500),kh(i).mul(4500),p).mul(kh(r));h.opacityNode=kh(Yt(kh(t).mul(kh(e)),N(0),m));let f={get value(){return r.value===0?1/0:i.value},set value(g){Number.isFinite(g)?(i.value=g,r.value=1):r.value=0}};return h.uniforms={angleFadeFactor:t,opacityFactor:e,gridScale:f,red:s,blue:n,green:a,mode:o,offset:l},h}var kh,W1,cRt=j(()=>{ht(),pr(),We(),kh=t=>t,W1=t=>t}),$R={};function pRt(){return typeof navigator<"u"&&navigator.gpu!==void 0}async function mRt(t={}){let e=!1;try{e=new URLSearchParams(window.location.search).get("dbglimits")==="default"}catch{}let i=e?{}:t.requiredLimits??await async function(s){if(!(s.forceWebGL||typeof navigator>"u"||navigator.gpu===void 0))try{let n=await navigator.gpu.requestAdapter({powerPreference:s.powerPreference,featureLevel:"compatibility"});if(!n)return;let a={},o=n.limits;for(let l of dxt){let h=o[l];typeof h=="number"&&Number.isFinite(h)&&(a[l]=h)}return a}catch{return}}(t),r=new A5({...t,requiredLimits:i});await r.init();try{let s=new URLSearchParams(window.location.search);if(s.get("taa")==="off"&&(r.temporalAAEnabled=!1),s.get("nojit")==="1"){let n=r.taaHistory;n.beginJitter=()=>{},n.endJitter=()=>{}}s.get("dbghdt")==="1"&&(r.hdTransmission=!0)}catch{}return r}nT($R,{SPE_BLENDING_MULTIPLY:()=>m7,SPE_BLENDING_NORMAL:()=>p7,SPE_BLENDING_OVERLAY:()=>g7,SPE_BLENDING_SCREEN:()=>f7,TSLLayerParams:()=>xq,TSLRootMaterial:()=>Kp,TSLSharedMaterial:()=>Sq,WebGPUPostPipeline:()=>fq,WebGPUSplineRenderer:()=>A5,createEditorGridNodeMaterial:()=>dRt,createWebGPUSplineRenderer:()=>mRt,getTSLLayerBuilder:()=>Cbt,hasTSLLayerBuilder:()=>nPt,isWebGPUSupported:()=>pRt,ownUniformValue:()=>c7,registerTSLLayer:()=>kn,setRenderUniformValue:()=>_q,simpleCalpha:()=>ub,speBlend:()=>FR,speObjectNormal:()=>wT,speObjectPosition:()=>Za,splitUniformValueSlots:()=>bq,standardCalpha:()=>td,unsupportedTSLLayerBuilder:()=>wq,webgpuGlobals:()=>Lt});var dxt,PF=j(()=>{Rht(),pr(),ht(),Rm(),RPt(),p_t(),BPt(),qPt(),XPt(),hRt(),i1t(),uRt(),Rht(),Xvt(),cn(),cRt(),pn(),u5={createSplatMaterial:t=>new uxt(t)},function(t){Nj=t}({createRootMaterial:(t,e)=>new Kp(t,e),createSharedMaterial:(t,e,i)=>new Sq(t,e,i)}),hyt={tsl:D,NodeMaterial:Re,MeshBasicNodeMaterial:d9,MeshStandardNodeMaterial:bR,MeshPhysicalNodeMaterial:f9,MeshPhongNodeMaterial:p9,MeshLambertNodeMaterial:c9,MeshToonNodeMaterial:g9,MeshMatcapNodeMaterial:y9,MeshNormalNodeMaterial:u9,SpriteNodeMaterial:_R,PointsNodeMaterial:YS,LineBasicNodeMaterial:l9,LineDashedNodeMaterial:h9,Color:ae,Vector2:Z,Vector3:P,Vector4:Me,Matrix3:As,Matrix4:xt,Texture:pi,CanvasTexture:TG,DataTexture:vr,VideoTexture:SG,FrontSide:_l,BackSide:$n,DoubleSide:Rn,NormalBlending:Uh,AdditiveBlending:e4,MultiplyBlending:r4,SubtractiveBlending:i4,RepeatWrapping:Mn,ClampToEdgeWrapping:An,MirroredRepeatWrapping:Gg,NearestFilter:De,LinearFilter:fe,LinearMipmapLinearFilter:ia,SRGBColorSpace:ks,LinearSRGBColorSpace:Yu},kj=()=>{let t=new v9;return t.depthWrite=!1,t.opacity=.5,t},dxt=["maxUniformBuffersPerShaderStage","maxSampledTexturesPerShaderStage","maxSamplersPerShaderStage","maxStorageBuffersPerShaderStage","maxStorageBufferBindingSize","maxBufferSize","maxVertexBuffers","maxVertexAttributes","maxUniformBufferBindingSize","maxColorAttachmentBytesPerSample"]}),cxt={};function pxt(t){let e;if(t.index)for(let i=0;i<t.index.array.length;i+=3)e=t.index.array[i],t.index.array[i]=t.index.array[i+2],t.index.array[i+2]=e}function vw(t){return t instanceof Fv?"SubdivObject":t.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function fRt(t,e){let i=function(c,p){let m={};return c.traverseEntity(f=>{if(!f.visible||!(f instanceof Fs)||f.type!=="Mesh"||Array.isArray(f.material)||f.states&&Object.keys(f.states).length)return;let g=f.parent;for(;g;){if(g instanceof Fs&&f.states&&Object.keys(f.states).length)return;g=g.parent}let y=f.material.uuid,v=p.shared.materials[y];if(v){if(!ls.isMergable(v))return}else{let _=p.scene.objects.get(f.uuid)?.data;if(_&&"material"in _&&typeof _.material!="string"){if(!ls.isMergable(_.material))return;y=ls.getHash(_.material)}}m[y]||(m[y]={});let b=m[y][vw(f)];if(b){if(b.push(f),f.cloner)for(let _ of f.cloner.children)b.push(_)}else if(m[y][vw(f)]=[f],f.cloner)for(let _ of f.cloner.children)m[y][vw(f)].push(_)}),m}(e,t),r=function(c){let p=0;return Object.values(c).forEach(m=>{Object.values(m).forEach(f=>{let g=f.length;g>p&&(p=g)})}),p}(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),d=0;for(let[c,p]of Object.entries(i))for(let m of Object.values(p)){if(o=0,h=0,m.forEach(g=>{g instanceof Fs&&(a[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),a[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&pxt(a[g]);let f=Ig(a.slice(0,o),!1);if(f){let g;c==="SubdivObject"?(console.warn("Turning subdiv object into mesh"),g=new yr(f,l[0].material)):g=new yr(f,l[0].material),g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,e.add(g);let y=v=>{d=0;for(let b of v)b.children&&y(b.children),b instanceof Fs&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][vw(b)]&&i[b.material.uuid][vw(b)].length>1||(u[d++]=b));for(let b=0;b<d;b++)e.attach(u[b])};for(let v=0;v<h;v++){let b=l[v];y(b.children),s[n++]=b}}}for(let c=0;c<n;c++)s[c].removeFromParent()}nT(cxt,{mergeStaticGeometries:()=>fRt,reverseWindingOrder:()=>pxt});var gRt=j(()=>{Be(),ht(),dT(),oa(),_T()});ht();var bw=".",z7=Symbol("target"),mxt=Symbol("unsubscribe");function L7(t){return t instanceof Date||t instanceof Set||t instanceof Map||t instanceof WeakSet||t instanceof WeakMap||ArrayBuffer.isView(t)}var Wu=Array.isArray;function Aq(t){return typeof t=="symbol"}var yRt={after:(t,e)=>Wu(t)?t.slice(e.length):e===""?t:t.slice(e.length+1),concat:(t,e)=>Wu(t)?(t=[...t],e&&t.push(e),t):e&&e.toString!==void 0?(t!==""&&(t+=bw),Aq(e)?t+e.toString():t+e):t,initial:t=>{if(Wu(t))return t.slice(0,-1);if(t==="")return t;let e=t.lastIndexOf(bw);return e===-1?"":t.slice(0,e)},last:t=>{if(Wu(t))return t[t.length-1]||"";if(t==="")return t;let e=t.lastIndexOf(bw);return e===-1?t:t.slice(e+1)},walk:(t,e)=>{if(Wu(t))for(let i of t)e(i);else if(t!==""){let i=0,r=t.indexOf(bw);if(r===-1)e(t);else for(;i<t.length;)r===-1&&(r=t.length),e(t.slice(i,r)),i=r+1,r=t.indexOf(bw,i)}},get(t,e){return this.walk(e,i=>{t&&(t=t[i])}),t}},Zl=yRt;function Fut(t,e,i){return t.isUnsubscribed||e.ignoreSymbols&&Aq(i)||e.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(i)}var vRt=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),i=e.get(t);return i===void 0&&(i={},e.set(t,i)),i}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let i=this._getProperties(t),r=i[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),i[e]=r),r}getProxy(t,e,i,r){if(this.isUnsubscribed)return t;let s=t[r],n=s||t;this._pathCache.set(n,e);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(t,i):t,this._proxyCache.set(n,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Zl.get(e,this.getPath(t)))}defineProperty(t,e,i){return!!Reflect.defineProperty(t,e,i)&&(this.isUnsubscribed||(this._getProperties(t)[e]=i),!0)}setProperty(t,e,i,r,s){if(!this._equals(s,i)||!(e in t)){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&"set"in n?Reflect.set(t,e,i,r):Reflect.set(t,e,i)}return!0}deleteProperty(t,e,i){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(t,e,i){let r=this._getOwnPropertyDescriptor(e,i);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let i=this._getOwnPropertyDescriptor(t,e);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function F7(t){return toString.call(t)==="[object Object]"}function zE(){return!0}function Qy(t,e){return t.length!==e.length||t.some((i,r)=>e[r]!==i)}var fxt=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),bRt=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),gxt={push:zE,pop:zE,shift:zE,unshift:zE,copyWithin:Qy,reverse:Qy,sort:Qy,splice:Qy,flat:Qy,fill:Qy},_Rt=new Set([...fxt,...bRt,...Object.keys(gxt)]);function LE(t,e){if(t.size!==e.size)return!0;for(let i of t)if(!e.has(i))return!0;return!1}var yxt=["keys","values","entries"],vxt=new Set(["has","toString"]),bxt={add:LE,clear:LE,delete:LE,forEach:LE},xRt=new Set([...vxt,...Object.keys(bxt),...yxt]);function FE(t,e){if(t.size!==e.size)return!0;let i;for(let[r,s]of t)if(i=e.get(r),i!==s||i===void 0&&!e.has(r))return!0;return!1}var wRt=new Set([...vxt,"get"]),_xt={set:FE,clear:FE,delete:FE,forEach:FE},SRt=new Set([...wRt,...Object.keys(_xt),...yxt]),Am=class{constructor(t,e,i,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return fxt.has(t)}_shallowClone(t){let e=t;if(F7(t))e={...t};else if(Wu(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(i=>this._shallowClone(i)));else if(t instanceof Map){e=new Map;for(let[i,r]of t.entries())e.set(i,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,i,r){return t?(Wu(r)?this._onIsChanged=gxt[e]:r instanceof Set?this._onIsChanged=bxt[e]:r instanceof Map&&(this._onIsChanged=_xt[e]),r):i}update(t,e,i){let r=Zl.after(t,this._path);if(e!=="length"){let s=this.clone;Zl.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:i}),s&&s[e]&&(s[e]=i)}this._isChanged=!0}undo(t){let e;for(let i=this._changes.length-1;i!==-1;i--)e=this._changes[i],Zl.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}},Uut=class extends Am{static isHandledMethod(t){return _Rt.has(t)}},TRt=class extends Am{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}},jut=class extends Am{static isHandledMethod(t){return xRt.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}},Gut=class extends Am{static isHandledMethod(t){return SRt.has(t)}undo(t){for(let[e,i]of this.clone.entries())t.set(e,i);for(let e of t.keys())this.clone.has(e)||t.delete(e)}},MRt=class extends Am{constructor(t,e,i,r){super(void 0,e,i,r),this._arg1=i[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}},ARt=class extends Am{constructor(t,e,i,r){super(void 0,e,i,r),this._weakKey=i[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}},q1=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return F7(t)||Wu(t)||L7(t)}static isHandledMethod(t,e){return F7(t)?Am.isHandledMethod(e):Wu(t)?Uut.isHandledMethod(e):t instanceof Set?jut.isHandledMethod(e):t instanceof Map?Gut.isHandledMethod(e):L7(t)}get isCloning(){return this._stack.length>0}start(t,e,i){let r=Am;Wu(t)?r=Uut:t instanceof Date?r=TRt:t instanceof Set?r=jut:t instanceof Map?r=Gut:t instanceof WeakSet?r=MRt:t instanceof WeakMap&&(r=ARt),this._stack.push(new r(t,e,i,this._hasOnValidate))}update(t,e,i){this._stack[this._stack.length-1].update(t,e,i)}preferredThisArg(t,e,i){let{name:r}=t,s=q1.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,i)}isChanged(t,e,i){return this._stack[this._stack.length-1].isChanged(t,e,i)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},CRt={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},U7=(t,e,i={})=>{i={...CRt,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new vRt(s),h=typeof i.onValidate=="function",u=new q1(h),d=(v,b,_,x,S)=>!h||u.isCloning||i.onValidate(Zl.concat(l.getPath(v),b),_,x,S)===!0,c=(v,b,_,x)=>{!Fut(l,i,b)&&(!a||!l.isDetached(v,t))&&p(l.getPath(v),b,_,x)},p=(v,b,_,x,S)=>{u.isCloning?u.update(v,b,x):e(Zl.concat(v,b),_,x,S)},m=v=>v&&(v[r]||v),f=(v,b,_,x)=>function(S){return(typeof S=="object"?S===null:typeof S!="function")||S instanceof RegExp}(v)||_==="constructor"||n&&!q1.isHandledMethod(b,_)||Fut(l,i,_)||l.isGetInvariant(b,_)||a&&l.isDetached(b,t)?v:(x===void 0&&(x=l.getPath(b)),l.getProxy(v,Zl.concat(x,_),g,r)),g={get(v,b,_){if(Aq(b)){if(b===r||b===z7)return v;if(b===mxt&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let x=L7(v)?Reflect.get(v,b):Reflect.get(v,b,_);return f(x,v,b)},set(v,b,_,x){_=m(_);let S=v[r]||v,w=S[b];if(s(w,_)&&b in v)return!0;let T=d(v,b,_,w);return T&&l.setProperty(S,b,_,x,w)?(c(v,b,v[b],w),!0):!T},defineProperty(v,b,_){if(!l.isSameDescriptor(_,v,b)){let x=v[b];d(v,b,_.value,x)&&l.defineProperty(v,b,_,x)&&c(v,b,_.value,x)}return!0},deleteProperty(v,b){if(!Reflect.has(v,b))return!0;let _=Reflect.get(v,b),x=d(v,b,void 0,_);return x&&l.deleteProperty(v,b,_)?(c(v,b,void 0,_),!0):!x},apply(v,b,_){let x=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(v,x,_);if((o===!1||o!==!0&&!o.includes(v.name))&&q1.isHandledType(x)){let S=Zl.initial(l.getPath(v)),w=q1.isHandledMethod(x,v.name);u.start(x,S,_);let T=Reflect.apply(v,u.preferredThisArg(v,b,x),w?_.map(A=>m(A)):_),C=u.isChanged(x,s),M=u.stop();if(q1.isHandledType(T)&&w&&(b instanceof Map&&v.name==="get"&&(S=Zl.concat(S,_[0])),T=l.getProxy(T,S,g)),C){let A={name:v.name,args:_,result:T},R=u.isCloning?Zl.initial(S):S,I=u.isCloning?Zl.last(S):"";d(Zl.get(t,R),I,x,M,A)?p(R,I,x,M,A):u.undo(x)}return(b instanceof Map||b instanceof Set)&&function(A){return typeof A=="object"&&typeof A.next=="function"}(T)?function(A,R,I,O,B){let V=A.next;if(R.name==="entries")A.next=function(){let z=V.call(this);return z.done===!1&&(z.value[0]=B(z.value[0],R,z.value[0],O),z.value[1]=B(z.value[1],R,z.value[0],O)),z};else if(R.name==="values"){let z=I[z7].keys();A.next=function(){let k=V.call(this);return k.done===!1&&(k.value=B(k.value,R,z.next().value,O)),k}}else A.next=function(){let z=V.call(this);return z.done===!1&&(z.value=B(z.value,R,z.value,O)),z};return A}(T,v,b,S,f):T}return Reflect.apply(v,b,_)}},y=l.getProxy(t,i.pathAsArray?[]:"",g);return e=e.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};U7.target=t=>t&&t[z7]||t,U7.unsubscribe=t=>t[mxt]||t;var RF=U7;ir(),ir(),ht(),nD();var ERt=class extends Y5{constructor(){super(),function(t){for(let e of Rgt)t.enable(e)}(this.layers)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,i=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,i)}),i}createRaycastLineHelper(){let t=new Lh({color:65280,linewidth:10}),e=new P(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new P(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new P().addVectors(e,i.multiplyScalar(r)),n=new ye;return n.setFromPoints([e,s]),new Xw(n,t)}};dD(),bo(),Dm(),ts();var xxt=t=>t instanceof Lu||tR(t);function PRt(t,e){return t.distance-e.distance}function wxt(t,e,i){if(Vu(e)&&e.visible){Hh(e)&&e.raycast(t,i);for(let r of e.children)wxt(t,r,i)}}function XR(t,e,i,r=!1){if(!r&&!i.some(n=>k5(t,n)!==void 0))return[];let s=[];return e.children.forEach(n=>wxt(t,n,s)),s.sort(PRt),s}function j7(t){let e=[];if(t.length){let i=t[0].object;Vu(i)&&e.push(i);let r=i.parent;for(;r;)xxt(r)&&e.push(r),r=r.parent}return e}function lc(t,e,i,r){let s=t.frame;if(s){let n=e[0]*s.width,a=(1-e[1])*s.height;for(let o of i){let l=o===s.uuid?s:s.find(o);if(l?.intersects(n,a))return r(l),!0}}return!1}function k5(t,e){if(Hh(e)){if(e.visible){let i=[];return e.raycast(t,i),i.length?i[0]:void 0}}else if(xxt(e))return Sxt(t,e)}function Sxt(t,e){if(Vu(e)&&e.visible){if(Hh(e)){let i=[];if(e.raycast(t,i),i.length)return i[0]}for(let i of e.children){let r=Sxt(t,i);if(r)return r}}}var RRt=class{constructor(t,e,i,r,s,n,a,o){this.renderer=t,this.publish=e,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=n,this.isExport=a,this.frame=o,this.raycaster=new ERt,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}get domRect(){return this._domRect}updateRaycaster(t){let{pageX:e,pageY:i}=t.touches?.length>0?t.touches[0]:t;this.pointerWorld=function(r,s,n){return{x:(r-(n.left+window.scrollX))/n.width*2-1,y:-(s-(n.top+window.scrollY))/n.height*2+1}}(e,i,this._domRect),this.pointerScreen=function(r,s,n){return{x:(r-(n.left+window.scrollX))/n.width,y:1-(s-(n.top+window.scrollY))/n.height}}(e,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}dispose(){this.scene=void 0,this.sharedAssets=void 0,this.publish=void 0,this.getCamera=void 0,this.requestRender=void 0,this.frame=void 0,this.isExport=void 0}},ro=class{constructor(t){this.eventContext=t,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}dispose(){this.disconnect(),this.eventContext=void 0}};Be(),Be();var Dt=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Dt.version}static addUnaryOp(t){return Dt.max_unop_len=Math.max(t.length,Dt.max_unop_len),Dt.unary_ops[t]=1,Dt}static addBinaryOp(t,e,i){return Dt.max_binop_len=Math.max(t.length,Dt.max_binop_len),Dt.binary_ops[t]=e,i?Dt.right_associative.add(t):Dt.right_associative.delete(t),Dt}static addIdentifierChar(t){return Dt.additional_identifier_chars.add(t),Dt}static addLiteral(t,e){return Dt.literals[t]=e,Dt}static removeUnaryOp(t){return delete Dt.unary_ops[t],t.length===Dt.max_unop_len&&(Dt.max_unop_len=Dt.getMaxKeyLen(Dt.unary_ops)),Dt}static removeAllUnaryOps(){return Dt.unary_ops={},Dt.max_unop_len=0,Dt}static removeIdentifierChar(t){return Dt.additional_identifier_chars.delete(t),Dt}static removeBinaryOp(t){return delete Dt.binary_ops[t],t.length===Dt.max_binop_len&&(Dt.max_binop_len=Dt.getMaxKeyLen(Dt.binary_ops)),Dt.right_associative.delete(t),Dt}static removeAllBinaryOps(){return Dt.binary_ops={},Dt.max_binop_len=0,Dt}static removeLiteral(t){return delete Dt.literals[t],Dt}static removeAllLiterals(){return Dt.literals={},Dt}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new Dt(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return Dt.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!Dt.binary_ops[String.fromCharCode(t)]||Dt.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return Dt.isIdentifierStart(t)||Dt.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(Dt.hooks[t]){let i={context:this,node:e};return Dt.hooks.run(t,i),i.node}return e}searchHook(t){if(Dt.hooks[t]){let e={context:this};return Dt.hooks[t].find(function(i){return i.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===Dt.SPACE_CODE||t===Dt.TAB_CODE||t===Dt.LF_CODE||t===Dt.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:Dt.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e,i,r=[];for(;this.index<this.expr.length;)if(e=this.code,e===Dt.SEMCOL_CODE||e===Dt.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())r.push(i);else if(this.index<this.expr.length){if(e===t)break;this.throwError('Unexpected "'+this.char+'"')}return r}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,Dt.max_binop_len),e=t.length;for(;e>0;){if(Dt.binary_ops.hasOwnProperty(t)&&(!Dt.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Dt.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,i,r,s,n,a,o,l;if(n=this.gobbleToken(),!n||(e=this.gobbleBinaryOp(),!e))return n;for(s={value:e,prec:Dt.binaryPrecedence(e),right_a:Dt.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),r=[n,s,a];e=this.gobbleBinaryOp();){if(i=Dt.binaryPrecedence(e),i===0){this.index-=e.length;break}s={value:e,prec:i,right_a:Dt.right_associative.has(e)},l=e;let h=u=>s.right_a&&u.right_a?i>u.prec:i<=u.prec;for(;r.length>2&&h(r[r.length-2]);)a=r.pop(),e=r.pop().value,n=r.pop(),t={type:Dt.BINARY_EXP,operator:e,left:n,right:a},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),r.push(s,t)}for(o=r.length-1,t=r[o];o>1;)t={type:Dt.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:t},o-=2;return t}gobbleToken(){let t,e,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,Dt.isDecimalDigit(t)||t===Dt.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===Dt.SQUOTE_CODE||t===Dt.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===Dt.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,Dt.max_unop_len),i=e.length;i>0;){if(Dt.unary_ops.hasOwnProperty(e)&&(!Dt.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Dt.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Dt.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--i)}Dt.isIdentifierStart(t)?(r=this.gobbleIdentifier(),Dt.literals.hasOwnProperty(r.name)?r={type:Dt.LITERAL,value:Dt.literals[r.name],raw:r.name}:r.name===Dt.this_str&&(r={type:Dt.THIS_EXP})):t===Dt.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===Dt.PERIOD_CODE||e===Dt.OBRACK_CODE||e===Dt.OPAREN_CODE||e===Dt.QUMARK_CODE;){let i;if(e===Dt.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Dt.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===Dt.OBRACK_CODE?(t={type:Dt.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==Dt.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===Dt.OPAREN_CODE?t={type:Dt.CALL_EXP,arguments:this.gobbleArguments(Dt.CPAREN_CODE),callee:t}:(e===Dt.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),t={type:Dt.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),i&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t,e,i="";for(;Dt.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);if(this.code===Dt.PERIOD_CODE)for(i+=this.expr.charAt(this.index++);Dt.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(i+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(i+=this.expr.charAt(this.index++));Dt.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);Dt.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+i+this.char+")")}return e=this.code,Dt.isIdentifierStart(e)?this.throwError("Variable names cannot start with a number ("+i+this.char+")"):(e===Dt.PERIOD_CODE||i.length===1&&i.charCodeAt(0)===Dt.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Dt.LITERAL,value:parseFloat(i),raw:i}}gobbleStringLiteral(){let t="",e=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
4466
- `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return r||this.throwError('Unclosed quote after "'+t+'"'),{type:Dt.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(Dt.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Dt.isIdentifierPart(t));)this.index++;return{type:Dt.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){i=!0,this.index++,t===Dt.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(s===Dt.COMMA_CODE){if(this.index++,r++,r!==e.length){if(t===Dt.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Dt.CBRACK_CODE)for(let n=e.length;n<r;n++)e.push(null)}}else if(e.length!==r&&r!==0)this.throwError("Expected comma");else{let n=this.gobbleExpression();(!n||n.type===Dt.COMPOUND)&&this.throwError("Expected comma"),e.push(n)}}return i||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Dt.CPAREN_CODE);if(this.code===Dt.CPAREN_CODE)return this.index++,t.length===1?t[0]:!!t.length&&{type:Dt.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Dt.ARRAY_EXP,elements:this.gobbleArguments(Dt.CBRACK_CODE)}}},DRt=new class{add(t,e,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],e&&this[r][i?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(i){i.call(e&&e.context?e.context:e,e)})}};Object.assign(Dt,{hooks:DRt,plugins:new class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(Dt),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),Dt.max_unop_len=Dt.getMaxKeyLen(Dt.unary_ops),Dt.max_binop_len=Dt.getMaxKeyLen(Dt.binary_ops);var Rv=t=>new Dt(t).parse();Object.getOwnPropertyNames(Dt).forEach(t=>{Rv[t]===void 0&&t!=="prototype"&&(Rv[t]=Dt[t])}),Rv.Jsep=Dt;var ORt={name:"ternary",init(t){t.hooks.add("after-expression",function(e){if(e.node&&this.code===t.QUMARK_CODE){this.index++;let i=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===t.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:"ConditionalExpression",test:i,consequent:r,alternate:s},i.operator&&t.binary_ops[i.operator]<=.9){let n=i;for(;n.right.operator&&t.binary_ops[n.right.operator]<=.9;)n=n.right;e.node.test=n.right,n.right=e.node,e.node=i}}else this.throwError("Expected :")}})}};Rv.plugins.register(ORt);var IRt=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],NRt=["0","1","2","3","4","5","6","7","8","9","."],BRt=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function kRt(t){return typeof t=="string"&&!isNaN(t)&&!isNaN(parseFloat(t))}function Txt(t,e,i="number"){let r,s,n="";for(let a=0;a<t.length;a++){let o=t[a];if("objType"in o&&o.objType==="api"){let l=JSON.parse(o.id),h=l[0],u=e.getUserAPI(h);if(u!==void 0&&typeof u.retrieveValue=="function"){let d=u.retrieveValue(l.slice(1));d!==void 0&&(n+=d)}continue}if("objType"in o&&o.objType==="webhook"){let l=JSON.parse(o.id),[h,u]=l,d=e.getUserWebhook(h);if(d!==void 0){let c=d.getParameterValue(u);c!==void 0&&(n+=c)}continue}if("objType"in o&&o.objType==="aiAssistant"){let l=e.openAIRealtime;if("objId"in o&&o.objId!==void 0){let h;if(e.scene.data.objects.traverse((u,d)=>{let c=d.events?.find(p=>p.id===o.objId);c&&(h=c)}),h!==void 0&&h.data.type==="AIAssistantListener"){let u=l?.computeAnalysisForListenerEvent(h.data);if(u!==void 0){n+=u;continue}}}n+=l?.voice??0;continue}if("id"in o){let l=t[a-1];if(a>0&&"id"in l)return void console.error("Two variables in a row",t);if(Array.isArray(o.id)&&e.referencesMissingObject(o.id))return;let h=e.getVariable(o.id),u=Da.getDisplayedValue(h);i==="number"&&Da.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?u=parseFloat(u).toString():i==="boolean"&&Da.isBoolean(h)?u=h?"true":"false":i==="boolean"&&Da.isTextValue(h)&&!Array.isArray(h.textValue)&&(u='"'+u+'"'),n+=u;continue}i!=="string"?o.name!=="and"?o.name!=="or"?o.name!=="True"?o.name!=="False"?i!=="boolean"||kRt(o.name)||NRt.includes(o.name)||IRt.includes(o.name)||BRt.includes(o.name.replace(/\($/g,""))?n+=o.name:n+='"'+o.name+'"':n+="false":n+="true":n+="||":n+="&&":(o.name!=='"'&&(o.name!=="+"||o.escaped)&&(n+=o.name),o.name==="+"&&!o.escaped&&n[n.length-1]==="\\"&&(n=n.slice(0,-1)+o.name))}if(i==="string")return n;if(t.length===0){if(i==="number")return 0;if(i==="boolean")return!1}try{r=Rv(n)}catch(a){return void console.error(n,a)}try{s=Wi(r)}catch(a){console.error(n,r,a)}if(i!=="number"||s===void 0||Number.isFinite(s))return s;console.error(n,"evaluated to",s)}function Wi(t){switch(t.type){case"BinaryExpression":switch(t.operator){case"==":return Number(Wi(t.left)===Wi(t.right));case"!=":return Number(Wi(t.left)!==Wi(t.right));case">":return Number(Wi(t.left)>Wi(t.right));case">=":return Number(Wi(t.left)>=Wi(t.right));case"<":return Number(Wi(t.left)<Wi(t.right));case"<=":return Number(Wi(t.left)<=Wi(t.right));case"+":return Wi(t.left)+Wi(t.right);case"-":return Wi(t.left)-Wi(t.right);case"*":return Wi(t.left)*Wi(t.right);case"/":return Wi(t.left)/Wi(t.right);case"%":return Wi(t.left)%Wi(t.right);case"&&":return Wi(t.left)&&Wi(t.right);case"||":return Wi(t.left)||Wi(t.right);case"^":return Math.pow(Wi(t.left),Wi(t.right));default:throw new Error("Unknown operator: "+t.operator)}case"UnaryExpression":switch(t.operator){case"-":return-Wi(t.argument);case"!":return Number(!Wi(t.argument));default:throw new Error("Unknown operator: "+t.operator)}case"Identifier":throw new Error("Unknown identifier: "+t.name);case"Literal":return t.value;case"CallExpression":if(t.callee.type==="Identifier"){if(t.callee.name==="random"){let e=0,i=1;if(t.arguments.length>=1)try{e=Wi(t.arguments[0])}catch(r){console.warn(r)}if(t.arguments.length>=2)try{i=Wi(t.arguments[1])}catch(r){console.warn(r)}return e=Math.min(i,e),i=Math.max(i,e),e+Math.random()*(i-e)}return Math[t.callee.name].apply(null,t.arguments.map(Wi))}throw new Error("Unknown node");default:throw new Error("Unknown node type: "+t.type)}}Rv.addBinaryOp("^",11,!0);var Mxt=new Map;function eo(t,e){Mxt.set(t,e)}Ni(),Object.keys({mousehover:!0,scroll:!0,dragdrop:!0,tracking:!0,resize:!0,conditional:!0,variables:!0,"api-services":!0,"ai-assistant":!0,textinputs:!0,audio:!0,video:!0,"create-destroy":!0,"scene-transition":!0,timeline:!0,transitions:!0,"misc-actions":!0});var VRt={MouseHover:"mousehover",Scroll:"scroll",DragDrop:"dragdrop",Follow:"tracking",LookAt:"tracking",Resize:"resize",Conditional:"conditional",VariableChange:"variables",API:"api-services",WEBHOOK:"api-services",AIAssistantListener:"ai-assistant",AIAssistantTrigger:"ai-assistant"},zRt={Audio:"audio",Video:"video",Particles:"particles",Link:"misc-actions",Reset:"misc-actions",SwitchCamera:"misc-actions",ClearLocalStorage:"misc-actions",Create:"create-destroy",Destroy:"create-destroy",Transition:"transitions",Animation:"transitions",TimelineAnimation:"timeline",SceneTransition:"scene-transition",SetVariable:"variables",DynamicVariablePlay:"variables",UserAPI:"api-services"};function Ir(t,e){if(e===void 0)return!0;if(e.expression.length===0||function(r,s){return r.some(n=>"id"in n&&Array.isArray(n.id)&&s.referencesMissingObject(n.id))}(e.expression,t))return!1;let i=Txt(e.expression,t,"boolean");return e.negate?!i:!!i}function dn(t,e,i,r,s,n,a){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},l=h=>({id:u,data:d})=>{try{if(d.type==="Conditional")return void(EU[t.type].includes("Conditional")&&(d.ifActions.forEach(l({expression:d.condition,negate:!1})),d.elseActions.forEach(l({expression:d.condition,negate:!0}))));if(!EU[t.type].includes(d.type))return;let c=function(m){return Mxt.get(m)}(d.type);if(c===void 0)return void On(zRt[d.type]??"misc-actions",`a "${d.type}" action`);let p=c({id:u,data:d,object:n,page:i,shared:r,eventManager:s,eventType:t.type,actionCondition:h,runModeOverride:a});p!=null&&d.type in o&&o[d.type].push(p)}catch{}};return e.forEach(l()),o}function sa(t){Object.values(t).forEach(e=>{e.forEach(i=>{typeof i.dispose=="function"&&i.dispose()})})}var Cq=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],Axt=t=>Cq.find(([e,i])=>i===t)?.[0],TT=t=>Cq.find(([e])=>e===t)?.[1],LRt=(t,e)=>{let i=Axt(t);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:e}),r}},FRt=class extends ro{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=t=>{if(!t.eventName||!t.target||t.eventName==="Scroll")return;let e=this.splineEvents[Axt(t.eventName)]?.[t.target.uuid];if(!e)return;t.eventName==="Scroll"&&t.deltaY!==void 0&&Object.assign(e,{deltaY:t.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(e)}}connect(){let{page:t}=this.eventContext;t.traverseEntity(e=>{if(e.data?.events.length){for(let[i,r]of Cq)if(e.data.events.some(s=>s.data.type===r&&!s.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(e):this.objectsPerEvents.set(i,[e]);let s={id:e.uuid,name:e.name},n=LRt(r,s),a=this.splineEvents[i];a?a[e.uuid]=n:this.splineEvents[i]={[e.uuid]:n}}}}),this.objectsPerEvents.forEach(e=>{e.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(t=>{t.forEach(e=>{e.removeEventListener("beginEvent",this.onBeginEvent)})})}};_o(),ts(),sh();var URt=class{constructor(t,e,i,r,s,n){if(this.id=t,this.data=e,this.object=i,this.entered=!1,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=dn(e,e.actions,r,s,n,i)}disconnect(){sa(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(e=>e.playing&&e.data.runMode!=="Toggle")||this.actions.Transition.forEach(e=>e.play()),this.actions.SwitchCamera.some(e=>e.playing&&e.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},jRt=class extends ro{constructor(t,e,i){super(t),this.eventManager=e,this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=XR(s,n,[],!0);this.sceneInterects=a,a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{(s.data.type==="MouseDown"||s.data.type==="MousePress")&&(this.onCanvasRaycast(r),s.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{s.data.type==="MouseUp"?(this.onCanvasRaycast(r),s.dispatch()):s.data.type==="MousePress"&&s.dispatchRelease()})},this.onMouseDown=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=TT(r);a&&(a==="MouseDown"||a==="MouseUp"||a==="MousePress"?(s.dispatchEvent({type:"beginEvent",eventName:a}),this.eventsPerObjects[a]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent(n)}),this.canvasMouseEvents.forEach(o=>{o.dispatchUserEvent(n)})):(a==="KeyDown"||a==="KeyUp"||a==="KeyPress")&&(s.dispatchEvent({type:"beginEvent",eventName:a}),this.eventsPerObjects[a]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:t,sharedAssets:e,domElement:i}=this.eventContext,r=(s,n)=>{if(!s.data?.events.length)return;let a=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of a){let l=this.eventsPerObjects[o];if(s.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let d=new URt(h,u,s,t,e,this.eventManager);d.actions.Video.length&&(this.hasVideoAction=!0),u.type!=="MouseDown"&&u.type!=="MouseUp"&&u.type!=="MousePress"||u.mode!=="Canvas"&&u.mode!=="Window"?(l[s.uuid]?l[s.uuid].some(c=>c.id===d.id)||l[s.uuid].push(d):l[s.uuid]=[d],Ic(s)&&s.traverseChildren(c=>{if(!c.visible)return!0;c instanceof Ur&&"shapeBlendNode"in c.data.geometry&&c.data.geometry.shapeBlendNode?.operation!==2&&(l[c.uuid]?l[c.uuid].push(d):l[c.uuid]=[d])})):this.canvasMouseEvents.push(d)}catch{}}),l[s.uuid]?.length&&(this.objectsPerTypes[o].push(!Go(s)||o!=="MouseDown"&&o!=="MouseUp"&&o!=="MousePress"?s:n),Ic(s))){let h=this.objectsPerTypes[o];s.traverseChildren(u=>{if(!u.visible)return!0;u instanceof Ur&&h.indexOf(u)===-1&&h.push(u)})}}};t.traverseEntity(s=>{(Ya(s)||s instanceof Or)&&s.frame?.traverse(n=>{r(n,s)}),r(s)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([s,n])=>{n.forEach(a=>{a.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(s=>{s.object.addEventListener("userEvent",this._onUserEvent)})}disconnect(){let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},t.removeEventListener("pointerdown",this.onCanvasMouseDown),t.removeEventListener("pointerup",this.onCanvasMouseUp),t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerdown",this.onMousePressDown),t.removeEventListener("pointerup",this.onMouseUp),t.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(e=>{Object.values(e).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(e=>{e.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([e,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(e=>{e.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(t){let{stopRaycast:e,raycaster:i,page:r,pointerScreen:s}=this.eventContext,n=this.objectsPerTypes[t],a=n.filter(o=>!Go(o));if((n.length||this.useForRaycastProperty)&&(!r.uiCanvas||!lc(r,[s.x,s.y],Object.keys(this.eventsPerObjects[t]),o=>{this.handleObjectMouseEventDispatch(o,t)}))){if(e||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=XR(i,r,a,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),e){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];j7(o).forEach(h=>{Ya(h)&&lc(h,l,Object.keys(this.eventsPerObjects[t]),u=>{this.handleObjectMouseEventDispatch(u,t)}),this.eventsPerObjects[t][h.uuid]&&this.handleObjectMouseEventDispatch(h,t)})}}e||a.forEach(o=>{let l=k5(i,o);l&&(this.handleObjectMouseEventDispatch(o,t),Ya(o)&&lc(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),h=>{this.handleObjectMouseEventDispatch(h,t)}))})}}handleMousePressEvent(t=!1){let e="MousePress",i=this.objectsPerTypes[e],r=i.filter(n=>!Go(n)),s=[];if(i.length){if(!t){let{stopRaycast:n,raycaster:a,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=lc(o,[l.x,l.y],Object.keys(this.eventsPerObjects[e]),u=>{s.push(u)})),n&&!h){let u=XR(a,o,r);s=j7(u),u.forEach(d=>{Ya(d.object)&&lc(d.object,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),c=>{s.push(c)})})}else r.forEach(u=>{let d=k5(a,u);d&&(s.push(u),Ya(u)&&lc(u,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),c=>{s.push(c)}))})}this._prevObjects.length&&this._prevObjects.forEach(n=>{s.includes(n)||this.handleObjectMouseEventDispatchRelease(n,e)}),s.length&&s.forEach(n=>{this.handleObjectMouseEventDispatch(n,e)}),this._prevObjects=s}}handleObjectMouseEventDispatch(t,e){t.dispatchEvent({type:"beginEvent",eventName:e}),this.eventsPerObjects[e]?.[t.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(t,e){t.dispatchEvent({type:"beginEvent",eventName:e}),this.eventsPerObjects[e]?.[t.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(t,e,i=!1){this.objectsPerTypes[e].forEach(r=>{let s=this.eventsPerObjects[e][r.uuid];s.some(({data:n})=>"key"in n&&n.key===t.key)&&r.dispatchEvent({type:"beginEvent",eventName:e}),s.forEach(n=>{"key"in n.data&&n.data.key===t.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(t,e,i=!1){this.objectsPerTypes[e].forEach(r=>{this.eventsPerObjects[e][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===t.key&&s.dispatchHeld(i)})})}};ts(),sh();var G7=t=>t?.isPlayAudioAction===!0,Wut=t=>t?.isPauseAudioAction===!0,z2=t=>t?.isPlayVideoAction===!0,qut=t=>t?.isPauseVideoAction===!0,GRt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.actions=dn(e,e.actions,r,s,n,i)}disconnect(){sa(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(G7(e.interaction)?e.interaction.audioPlayer?.play():Wut(e.interaction)&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let i=e.interaction.data.triggerAfter??"autoplay";i===t&&(z2(e.interaction)?e.interaction.play(i==="autoplay"):qut(e.interaction)&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}async seekVideos(t){let e=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&z2(i.interaction)&&e.push(i.interaction.seek(t))}),await Promise.all(e)}pauseVideos(){this.actions.Video.forEach(t=>{z2(t.interaction)&&t.interaction.pause()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{G7(e.interaction)?e.interaction.audioPlayer?.play():Wut(e.interaction)&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{z2(e.interaction)?e.interaction.play():qut(e.interaction)&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},WRt=class extends ro{constructor(t,e){super(t),this.eventManager=e,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.removeEventListener("pointerdown",this.onAny),s.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(n=>{G7(n.interaction)&&n.interaction.audioPlayer?.play()}),s.actions.Video.forEach(n=>{let a=n.interaction.data.triggerAfter??"autoplay";z2(n.interaction)&&n.interaction.play(a==="autoplay")}),s.actions.Particles.forEach(n=>{n.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{!s.data.visible||n.forEach(a=>{r.push(a.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>{s.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let n=TT(i);n&&n==="Start"&&(Go(r)||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:t,page:e}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:s,data:n}of r.data.events){if(n.disabled||n.type!=="Start")continue;let a=new GRt(s,n,r,e,t,this.eventManager);(a.actions.Transition.length||a.actions.TimelineAnimation.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.Reset.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length||a.actions.ClearLocalStorage.length||a.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}};if(e.traverseEntity(r=>{(Ya(r)||r instanceof Or)&&r.frame?.traverse(s=>{i(s)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,n=s?document:r;n.addEventListener("pointerdown",this.onMouseDown,{once:!0}),n.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),n.addEventListener("pointerdown",this.onAny),n.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,o])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>n.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:e}=this.eventContext,i=e?document:t;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([t,e])=>{t.removeEventListener("userEvent",this.onUserEvent),e.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},Cxt=new Map;function Tl(t,e){Cxt.set(t,e)}Ni();var qRt=class{constructor(t,e,i,r,s){this.publish=t,this.controlsManager=e,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=n=>{let a=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(n.touches.length>1||this.preventTouchScroll||a===!1&&o===!1)&&n.preventDefault()},this.onMouseWheelPreventScroll=n=>{this.preventScroll&&n.preventDefault()},this.onMouseMove=n=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(n),pressed:n.buttons>0}},this.onMouseDown=n=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(n),pressed:!0}},this.onMouseUp=n=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(n),pressed:!1}},this.getMousePosition=n=>{let{domRect:a}=this.eventContext,{pageX:o,pageY:l}=n.touches?.length>0?n.touches[0]:n;return{x:o-(a.left+window.scrollX),y:l-(a.top+window.scrollY)}},this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}warnMissingEventFeatures(){this.eventContext.page.traverseEntity(t=>{for(let e of t.dataPatched.events){if(e.data.disabled===!0)continue;let i=e.data.type;if(this.handlers[i]!==void 0)continue;let r=VRt[i];r!==void 0&&On(r,`a "${i}" event`)}})}activate(t=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown));let e={eventContext:this.eventContext,eventManager:this,sharedVariables:this.sharedVariables,needsMouse:this.needsMouse,needsRaycast:this.needsRaycast};this.handlers={};let i=(n,a)=>{let o=(l=n,Cxt.get(l));var l;o!==void 0?this.handlers[n]=o(e):a!==void 0&&(this.handlers[n]=a())};i("Spline",()=>new FRt(this.eventContext)),i("VariableChange"),i("API"),i("WEBHOOK"),i("AIAssistantListener"),i("AIAssistantTrigger"),i("Conditional"),i("Start",()=>new WRt(this.eventContext,this)),i("Basic",()=>new jRt(this.eventContext,this,this.needsRaycast)),i("MouseHover"),i("Scroll"),i("Follow"),i("DragDrop"),i("LookAt"),i("Resize"),i("Textfields"),this.warnMissingEventFeatures();let{page:r,domElement:s}=this.eventContext;this.hideCursor&&(s.style.cursor="none"),r.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),s.addEventListener("wheel",this.onMouseWheelPreventScroll),s.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,t||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(t=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:i}=this.eventContext;i.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),t||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}dispose(){this.deactivate(),Object.values(this.handlers).forEach(t=>t.dispose())}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(e),i.data.elseActions.forEach(e)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&t.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length)for(let r of i.data.events)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(e);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(e);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(e);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(e);else r.data.type==="LookAt"||r.data.type==="API"||r.data.actions.forEach(e)})}};ht(),ir(),ir();var UE={type:"change"},_w={type:"start"},Jf={type:"end",nonOrbit:!0},HRt={type:"end",nonOrbit:!1},$Rt={type:"end",isZoom:!0,nonOrbit:!0},XRt={type:"end",changed:!1},DF={type:"cameraAnimatingInTimeline"},OF=new Te,Hut=new Z,YRt=2*Math.PI,jE=new P,GE=new Z,xw=new P,ww=new Te,$ut=new xt,KRt={type:"requestRender"},Ext=class extends En{constructor(t,e,i={isPlayMode:!1,isExport:!1},r){super(),this.object=t,this.domElement=e,this.options=i,this.timelineState=r,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,ll.DOLLY_ROTATE,ll.PAN],this.offset=new P,this.eye=new P,this.lastPosition=new P,this.lastQuaternion=new Te,this.current=new Z,this.overShoot=new Z,this.overRatio=new Z,this.spherical=new dU,this.sphericalDelta=new dU,this.panOffset=new P,this.panLeftV=new P,this.panUpV=new P,this.panV=new P,this.rotateStart=new Z,this.rotateEnd=new Z,this.rotateDelta=new Z,this.panStart=new Z,this.panEnd=new Z,this.panDelta=new Z,this.dollyStart=new Z,this.dollyEnd=new Z,this.dollyDelta=new Z,this.rotationRangeFactor=new Z,this.panRangeFactor=new Z,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=s=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=s.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(xw,ww,jE),this.offset.copy(xw).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(OF.copy(ww).invert()),this.panOffset.applyQuaternion(OF),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(ww),this.panOffset.applyQuaternion(ww)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state!==-1||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),xw.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&($ut.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4($ut));let s=this.spherical.phi%YRt;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(ur.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),s>0&&s>Math.PI||s<0&&s>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0){let n=this.hoverRotatePanMode===1?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-n,this.sphericalDelta.phi*=1-n}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(UE),this.object.dispatchEvent(KRt),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=s=>{this.enabled!==!1&&(s.pointerType==="touch"||s.pointerType==="pen"&&Uo?this.onPointerDownTouch(s):this.onPointerDownMouse(s),this.state!==-1&&(this.isPointerDown=!0,this.dispatchEvent(_w),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),s.stopPropagation(),s.pointerType==="touch"||s.pointerType==="pen"&&Uo||this.domElement.setPointerCapture(s.pointerId)))},this.onPointerLeave=s=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(this.hoverRotatePanMode===1?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,jE.subVectors(this.position0,this.target0),this.spherical.setFromVector3(jE),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):this.hoverRotatePanMode===2&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=s},this.onPointerEnter=s=>{this.resetHoverEffectOnPointerLeave||this.pointerLeaveEvent===void 0?GE.set(s.clientX-this.domElement.clientWidth/2,s.clientY-this.domElement.clientHeight/2):GE.set(s.clientX-this.pointerLeaveEvent.clientX,s.clientY-this.pointerLeaveEvent.clientY),this.hoverRotatePanMode===1?(this.rotateDelta.copy(GE).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(Hut,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(s.clientX,s.clientY)):this.hoverRotatePanMode===2&&(this.panDelta.copy(GE).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(s.clientX,s.clientY)),this.update()},this.onPointerMove=s=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(DF):this.enabled!==!1&&(this.checkRaycastLock()||(s.pointerType==="touch"||s.pointerType==="pen"&&Uo?this.onPointerMoveTouch(s):this.onPointerMoveMouse(s),s.stopPropagation()))},this.onPointerUp=s=>{this.isPointerDown=!1,Ge.length===0&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),Ge.length>1&&s.preventDefault(),this.hasChange?this.dispatchEvent(this.state===0?HRt:Jf):this.dispatchEvent(XRt),this.state=-1,s&&(s.stopPropagation(),s.pointerType==="touch"||s.pointerType==="pen"&&Uo||this.domElement.releasePointerCapture(s.pointerId))},this.onPointerDownMouse=s=>{let n;switch(n=this.useKeyEvents?this.mouseButtons[s.button]:this.mouseButtonsPlay[s.button],n){case 0:if(s.altKey!==!0||s.shiftKey||l_(s)){if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2}}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(s),this.state=0}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2;break;case 3:if(l_(s)||s.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(s),this.state=0}break;case 5:if(l_(s)||s.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(s),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=s=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(s);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(s);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(s)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=s=>{switch(Ge.length>1&&s.preventDefault(),this.touches[Ge.length-1]){case ll.ROTATE:if(this.enableRotate===!1)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case ll.PAN:if(this.enablePan===!1)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case ll.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case ll.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=s=>{switch(Ge.length>1&&s.preventDefault(),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(s),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(s),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(s),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(s),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=LS(()=>{this.zoomChanged?this.dispatchEvent($Rt):this.dispatchEvent(Jf),this.zoomChanged=!1},33),this.onMouseWheel=s=>{if(this.enabled!==!1&&(this.enableZoom!==!1||this.enablePan!==!1)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&s.preventDefault(),this.dispatchEvent(_w),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(DF);this.handleMouseWheel(s),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=s=>{if(s.preventDefault(),this.enabled!==!1&&!this.checkRaycastLock()&&!aT){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(DF);if(s.type==="gesturechange"){if(this.enableZoom===!1||this.isTouchZoom===!1)return;this.dispatchEvent(_w),s.scale>this.prevScale?this.dollyIn(this.getZoomScale()):s.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=s.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(Jf)}},this.onContextMenu=s=>{s.preventDefault()},this.onTouchEnd=s=>{s.preventDefault()},this.onKeyDown=s=>{this.enabled!==!1&&(this.key=s.key,s.key===" "&&this.dispatchEvent(_w))},this.onKeyUp=s=>{this.key=void 0,this.enabled!==!1&&(this.state!==-1&&s.key==="Alt"&&this.onPointerUp(Ge[0]),s.key===" "&&this.dispatchEvent(Jf))},this.onPointerHover=s=>{s.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot||(this.isPointerDown=!0,this.hoverRotatePanMode===2?this.handleMouseMovePan(s,this.hoverRotatePanStrength):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(s,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=s=>{s.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(xw,ww,jE),this.offset.copy(xw).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(t){t.type==="start"?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(t)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(t){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=t,this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(t,e){this.rotateFactor=t.rotationSpeed??1,this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.thetaIsFree=t.rotationHorizontalOffset.min===t.rotationHorizontalOffset.max&&t.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=t.rotationVerticalOffset.min===t.rotationVerticalOffset.max&&t.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.hoverRotateDamping=t.hoverRotateDamping??this.dampingFactor,this.useWindowEvents=e==="window",this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=t.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,this.autoRotateSpeed=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let r=this.object.getTarget().applyQuaternion(OF.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+r.y,this.maxV=t.panVerticalOffset.max+r.y,this.minH=-t.panHorizontalOffset.min+r.x,this.maxH=t.panHorizontalOffset.max+r.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Cu(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=Cu(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=Cu(Cu(this.spherical.theta)-t.rotationHorizontalOffset.min),this.maxTheta=Cu(Cu(this.spherical.theta)+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,t.orbitTouches===1&&(this.touches[0]=ll.ROTATE),t.panTouches===1&&(this.touches[0]=ll.PAN),t.orbitTouches===2&&(this.touches[1]=ll.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=ll.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=ll.ROTATE),t.panTouches===3&&(this.touches[2]=ll.PAN),this.isTouchZoom=t.isTouchZoom,this.resetHoverEffectOnPointerLeave=t.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,e,i,r,s,n,a,o){let l,h,u;this.overShoot.set(0,0),t instanceof P?(l=t.x,h=t.y,this.current.set(this.target.x,this.target.y),u=!0):(l=t.theta,h=t.phi,this.current.set(Cu(this.spherical.theta),Cu(this.spherical.phi)),u=!1),i===0&&(this.current.x+=l,this.current.y+=h),(e===3||e===2)&&(!u&&this.isThetaFlipped?this.current.x>r&&this.current.x<0?this.overShoot.x=r-this.current.x:this.current.x<s&&this.current.x>0&&(this.overShoot.x=s-this.current.x):this.current.x>r?this.overShoot.x=r-this.current.x:this.current.x<s&&(this.overShoot.x=s-this.current.x)),(e===3||e===1)&&(this.current.y>n?this.overShoot.y=n-this.current.y:this.current.y<a&&(this.overShoot.y=a-this.current.y)),u||(this.overShoot.x=Cu(this.overShoot.x),this.overShoot.y=Cu(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(o),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=Xut(Math.abs(this.overRatio.x)),this.overRatio.y=Xut(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(l*this.overShoot.x<0&&!this.thetaIsFree&&(l*=1-this.overRatio.x),h*this.overShoot.y<0&&!this.phiIsFree&&(h*=1-this.overRatio.y)):i===2&&(!u&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||u&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(l=.05*this.overShoot.x),this.phiIsFree||(h=.05*this.overShoot.y),u?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):u?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(l+=this.overShoot.x,h+=this.overShoot.y),t instanceof P?(t.x=l,t.y=h):(this.thetaIsFree||(t.theta=l),this.phiIsFree||(t.phi=h))}setEnableDampingSpeed(t){this.enableDamping=t,this.rotateSpeed=(t===!0?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(t,e,i){this.stopDamping(),this.target.set(t,e,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,e){this.panLeftV.setFromMatrixColumn(e,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,e){this.panUpV.setFromMatrixColumn(e,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,e){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let r=this.object.position;this.panV.copy(r).sub(this.target);let s=this.panV.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*s/i.clientHeight,this.object.matrixWorld),this.panUp(2*e*s/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(UE)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(UE)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(UE)}setZoom(t){if(this.dispatchEvent(_w),this.object.isPerspectiveCamera){let e=this.initialSphericalRadius/t/this.spherical.radius;this.scale=e}else this.object.isOrthographicCamera&&(this.object.zoom=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(Jf)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,e=1){t.movementX!==void 0?this.rotateDelta.set(t.movementX,t.movementY):(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*e).rotateAround(Hut,-this.object.angleOffsetFromUp);let i=this.domElement,r=this.useWindowEvents?window.innerHeight:i.clientHeight,s=2*Math.PI*this.rotateDelta.x/r,n=2*Math.PI*this.rotateDelta.y/r;this.rotateLeft(s),this.rotateUp(n),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,e=1){t.movementX!==void 0?this.panDelta.set(t.movementX,t.movementY):(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*e),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(t.deltaX===0&&t.deltaY===0)return;let e=t.ctrlKey===!0||l_(t)===!0,i=l_(t)===!1&&((n=t).wheelDeltaY===0||n.deltaY===0?!(VS&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120)&&(n.wheelDeltaX?yX(n.wheelDeltaX,n.deltaX):n.deltaMode===0):n.wheelDeltaY?yX(n.wheelDeltaY,n.deltaY):n.deltaMode===0)===!0,r=e===!1&&(this.gesture===!0||t.timeStamp-this.lastTrackpadPanTime<300),s=e===!1&&r===!1&&t.timeStamp-this.lastMouseWheelZoomTime<300;var n;if(Qmt!==!1||s!==!1||i!==!0&&r!==!0){if(this.enableZoom===!1)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(Jf)),e===!1&&i===!1&&(this.lastMouseWheelZoomTime=t.timeStamp),t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(this.enablePan===!1)return;let a=this.gesture===!1&&r===!1;this.lastTrackpadPanTime=t.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),a===!1&&(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(Jf)},100)}}handleTouchStartRotate(){if(Ge.length===2){let t=.5*(Ge[0].pageX+Ge[1].pageX),e=.5*(Ge[0].pageY+Ge[1].pageY);this.rotateStart.set(t,e)}else this.rotateStart.set(Ge[0].pageX,Ge[0].pageY)}handleTouchStartPan(){if(Ge.length===2){let t=.5*(Ge[0].pageX+Ge[1].pageX),e=.5*(Ge[0].pageY+Ge[1].pageY);this.panStart.set(t,e)}else this.panStart.set(Ge[0].pageX,Ge[0].pageY)}handleTouchStartDolly(){let t=Ge[0].pageX-Ge[1].pageX,e=Ge[0].pageY-Ge[1].pageY,i=Math.sqrt(t*t+e*e);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(Ge.length===2){let i=pI(t),r=.5*(t.pageX+i.x),s=.5*(t.pageY+i.y);this.rotateEnd.set(r,s)}else{if(t.pointerId!==Ge[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;e&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(Ge.length===2){let e=pI(t),i=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);this.panEnd.set(i,r)}else{if(t.pointerId!==Ge[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let e=pI(t),i=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(i*i+r*r);this.dollyEnd.set(0,s),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=this.options?.showCameraLock;return t&&t(),!0}}return!1}};function Cu(t){let e=2*Math.PI;for(;t<=-Math.PI;)t+=e;for(;t>Math.PI;)t-=e;return t}function Xut(t){return 1-Math.pow(1-t,4)}ht();var ZRt=class{constructor(t,e,i,r){this.enableResponsive=!1,this._renderer=t,this._camera=e,this._frameSize=new Z().copy(i),this._fov=r??e.fov}set frameSize(t){this._frameSize.copy(t)}setRenderSize(t,e){this._renderSize=t===void 0||e===void 0?void 0:new Z(t,e)}updateRenderer(){if(!this._renderer)return;let t=this._renderSize??this._frameSize;this._renderer.setSize(t.x,t.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._renderSize??this._frameSize;this._renderer.setViewport(0,0,t.x,t.y)}updateCamera(){!this._camera||(this._camera.cameraType==="PerspectiveCamera"?(this._camera.aspect=this._frameSize.x/this._frameSize.y,this._camera.updateProjectionMatrix()):this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive))}setCamera(t){this._camera=t,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};oa(),ht(),ht(),ht();var ws=new zs,WE=new P,Yut=new Z,Kut=new Z,Zut=new Z,QRt=class{constructor(t){this.geometry=t.geometry,this.randomFunction=Math.random,this.indexAttribute=this.geometry.index,this.positionAttribute=this.geometry.getAttribute("position"),this.normalAttribute=this.geometry.getAttribute("normal"),this.colorAttribute=this.geometry.getAttribute("color"),this.uvAttribute=this.geometry.getAttribute("uv"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(t){return this.weightAttribute=t?this.geometry.getAttribute(t):null,this}build(){let t=this.indexAttribute,e=this.positionAttribute,i=this.weightAttribute,r=t?t.count/3:e.count/3,s=new Float32Array(r);for(let o=0;o<r;o++){let l=1,h=3*o,u=3*o+1,d=3*o+2;t&&(h=t.getX(h),u=t.getX(u),d=t.getX(d)),i&&(l=i.getX(h)+i.getX(u)+i.getX(d)),ws.a.fromBufferAttribute(e,h),ws.b.fromBufferAttribute(e,u),ws.c.fromBufferAttribute(e,d),l*=ws.getArea(),s[o]=l}let n=new Float32Array(r),a=0;for(let o=0;o<r;o++)a+=s[o],n[o]=a;return this.distribution=n,this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e,i,r){let s=this._sampleFaceIndex();return this._sampleFace(s,t,e,i,r)}_sampleFaceIndex(){let t=this.distribution[this.distribution.length-1];return this._binarySearch(this.randomFunction()*t)}_binarySearch(t){let e=this.distribution,i=0,r=e.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||e[n-1]<=t&&e[n]>t){s=n;break}t<e[n]?r=n-1:i=n+1}return s}_sampleFace(t,e,i,r,s){let n=this.randomFunction(),a=this.randomFunction();n+a>1&&(n=1-n,a=1-a);let o=this.indexAttribute,l=3*t,h=3*t+1,u=3*t+2;return o&&(l=o.getX(l),h=o.getX(h),u=o.getX(u)),ws.a.fromBufferAttribute(this.positionAttribute,l),ws.b.fromBufferAttribute(this.positionAttribute,h),ws.c.fromBufferAttribute(this.positionAttribute,u),e.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,a).addScaledVector(ws.c,1-(n+a)),i!==void 0&&(this.normalAttribute!==void 0?(ws.a.fromBufferAttribute(this.normalAttribute,l),ws.b.fromBufferAttribute(this.normalAttribute,h),ws.c.fromBufferAttribute(this.normalAttribute,u),i.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,a).addScaledVector(ws.c,1-(n+a)).normalize()):ws.getNormal(i)),r!==void 0&&this.colorAttribute!==void 0&&(ws.a.fromBufferAttribute(this.colorAttribute,l),ws.b.fromBufferAttribute(this.colorAttribute,h),ws.c.fromBufferAttribute(this.colorAttribute,u),WE.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,a).addScaledVector(ws.c,1-(n+a)),r.r=WE.x,r.g=WE.y,r.b=WE.z),s!==void 0&&this.uvAttribute!==void 0&&(Yut.fromBufferAttribute(this.uvAttribute,l),Kut.fromBufferAttribute(this.uvAttribute,h),Zut.fromBufferAttribute(this.uvAttribute,u),s.set(0,0).addScaledVector(Yut,n).addScaledVector(Kut,a).addScaledVector(Zut,1-(n+a))),this}};function Qut(t,e){let i=t,r=new Float32Array(4*e*e);for(let n=0;n<e*e;n++)r[4*n]=i[3*n],r[4*n+1]=i[3*n+1],r[4*n+2]=i[3*n+2],r[4*n+3]=0;let s=new vr(r,e,e,ln,Qe);return s.needsUpdate=!0,s}byt(),ht(),ht(),ht(),ht();var IF=class{constructor(t,e,i,r){this.type="SphereEmitterShape",this.targetMesh=void 0,this.size=t,this.type=i,this.textureSize=function(o){let l=Math.ceil(Math.sqrt(o));return Math.max(l,1)}(e),this.targetMesh=r?.geometry.type==="BufferGeometry"||r?.type==="Mesh"&&r&&r.geometry.hasAttribute("position")&&r.geometry.hasAttribute("normal")?r:this.getMesh(i,1);let{positions:s,dataTexture:n,dataTextureNormals:a}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(i,1));this.positionsTexture=n,this.positionsAttribute=s,this.directionsTexture=a}createPositions(t,e){let{positions:i,normals:r}=function(s,n){let a=new yr(s.geometry,s.material),o=[],l=[],h=new P,u=new P;a.geometry.index!==null&&(a.geometry=a.geometry.toNonIndexed());let d=new QRt(a).build();for(let c=0;c<n;c++)d.sample(h,u),o.push(h.x,h.y,h.z),l.push(u.x,u.y,u.z);return{positions:new Float32Array(o),normals:new Float32Array(l)}}(e,t*t);return{dataTexture:Qut(i,t),positions:i,dataTextureNormals:Qut(r,t)}}getMesh(t,e){let i=null;switch(t){case"SphereEmitterShape":i=new Ec(.5*e,32,32);break;case"TorusEmitterShape":i=new f4(.5*e,.3,15,40);break;case"ConeEmitterShape":i=new m4(e,e,15);break;case"BoxEmitterShape":i=new Zh(e,e,e);break;case"PlaneEmitterShape":i=new Oc(e,e),i.rotateX(-Math.PI/2);break;default:i=new Ec(e,32,32)}return new yr(i,new jo({color:16711680}))}applyToShader(t,e){this.size=new P().fromArray(e.size.map(i=>typeof i=="number"?i:1)),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function H1(t){let e={...t},i=R4.defaultData;e.forceFieldObjectId&&(e.colliderEntityId=e.forceFieldObjectId);let r={...i.shape,...e.shape},s={...i.renderMaterial,...e.renderMaterial};return{...i,...e,shape:r,renderMaterial:s}}Be();var JRt=class extends ur{constructor(t,e){super(),this.type="ParticleEmitter",this.debugMode=!1,this.worldSpace=!0,this.rootObject=null,this.gpuCompute=null,this.positionSimRT=null,this.velocitySimRT=null,this.emissionRateSimRT=null,this.emitterShape=void 0,this.isEmitting=!1,this.hasBeenReset=!1,this.emittedParticlesAmount=0,this.lastEmitTime=0,this.globalTime=0,this.targetFPS=60,this.previousRatio=1,this.lerpFactor=.4,this.particlesAmount=0,this.noiseStrength=0,this.noiseScale=0,this.isBillboardBased=!0,this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1},this.textureLoader=new jmt,this.textureRequestId=0,this.currentWorldPosition=new P,this.systemQuaternion=new Te,this.worldGravity=new P(0,0,0),this.directionAxis=new P(0,0,0),this.colliderV3=new P(0,0,0),this.colliderQuaternion=new Te(0,0,0,1),this.matrixAutoUpdate=!0,this.renderer=t,this.system=e,this.shared=e.context.shared;let i=e.data;this.material=NN(t)?VZ()?.createMaterial(i.renderMaterial,e.context)??IN().createMaterial(i.renderMaterial,e.context):IN().createMaterial(i.renderMaterial,e.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:i.renderMaterial.color},uColor2:{value:i.renderMaterial.color2},uPosition:{value:new P(0,0,0)},uEmissionData:{value:new P(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new P(0,0,0)},uWorldQuaternion:{value:new Me(0,0,0,1)},uRandScaleFactor:{value:i.randomScale??0},uRandRotationFactor:{value:i.randomRotation??0},uRotation:{value:i.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:i.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,i.renderMaterial.texture),this.init(i)}setTexture(t,e){let i=e.data,r=++this.textureRequestId;if(typeof e=="string"){let s=this.shared.image(e),n=()=>{if(r!==this.textureRequestId)return;let a=new pi(s.img);a.needsUpdate=!0,t.uTexture.value=a};return void(s.loaded?n():s.loadPromise.then(n))}if(typeof i!="string"){let s=new Image;s.onload=()=>{if(r!==this.textureRequestId)return;let o=new pi(s);o.needsUpdate=!0,t.uTexture.value=o};let n=new Blob([i],{type:"image/*"}),a=URL.createObjectURL(n);s.src=a}}updateGeometryAttributes(t,e){let i=function(s){let n=new Float32Array(s*s*2);for(let a=0;a<s;a++)for(let o=0;o<s;o++){let l=a*s+o;n[2*l+0]=a/(s-1),n[2*l+1]=o/(s-1)}return n}(e);if(!this.emitterShape?.positionsAttribute)return;let r=new mo(i,2);t.geometry.setAttribute("ref",r),NN(this.renderer)&&t.geometry.setAttribute("particleRef",r)}applyWorldSpace(){if(!(this.system.started&&this.worldSpace&&this.positionSimRT&&this.velocitySimRT))return;let t=this.system;t.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),t.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(t,e){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset)return void this.reset();this.applyWorldSpace(),this.globalTime=t,this.positionSimRT.material.uniforms.uTime.value=t,this.emissionRateSimRT.material.uniforms.uTime.value=t;let i=1e3/e,r=this.targetFPS/i,s=this.previousRatio+(r-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=s,this.previousRatio=s;let n=this.isEmitting?this.GoEmitSomeParticles(t,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=n,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let t=this.system.colliderEntities[0],e=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(t.destroyedInAction&&e&&this.init(H1({...this.system.data,colliderEntityId:null})),!t||t.destroyedInAction)return;t.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=t.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),t.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(t){!this.velocitySimRT||!this.positionSimRT||(t.renderMaterial&&this.updateMaterialState(t.renderMaterial),this.updateParticleState(t))}updateVariableState(t,e){if(!this.velocitySimRT||!this.positionSimRT)return;e[2]==="size"&&this.material.updateState({size:[t,this.material.uniforms.uSizeEnd.value]}),e[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,t]});let i=(r,s)=>{let n=[...this.system.data.shape.size];n[r]=s,this.updateParticleState({shape:{...this.system.data.shape,size:n}})};e[2]==="shape_size_0"&&i(0,t),e[2]==="shape_size_1"&&i(1,t),e[2]==="shape_size_2"&&i(2,t),e[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=t/10),e[2]==="gravity"&&this.worldGravity.set(0,t/100,0),e[2]==="noiseStrength"&&(this.noiseStrength=t,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e[2]==="noiseScale"&&(this.noiseScale=t,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(t),this.system.data.direction[1],this.system.data.direction[2]])),e[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(t),this.system.data.direction[2]])),e[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(t)]))}updateMaterialState(t){this.material.updateState({...t,size:t.size?[Number(this.shared.getVariable(t.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(t.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),t.texture&&(this.setTexture(this.material.uniforms,t.texture),this.material.needsUpdate=!0)}updateParticleState(t){if(this.positionSimRT&&this.velocitySimRT){if(this.shouldReInitGPUCompute(t)&&this.init(H1(this.system.data)),t.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=t.life),t.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(t.speed,[this.uuid,"particles","speed"]))/10),t.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=t.collisionBounce),t.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(t.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(t.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=t.noiseSeed),t.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=t.randomMass),t.renderMaterial?.size!==void 0){let e=this.shared.getVariable(t.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(e)}if(t.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=t.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=t.renderMaterial.spriteRotation[1]),t.shape!==void 0){let e=t.shape.size??this.system.data.shape.size,i=[Number(this.shared.getVariable(e[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e[2],[this.uuid,"particles","shape_size_2"]))],r={...H1(this.system.data).shape,size:i};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,r)}if(t.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),t.direction!==void 0){let e=this.getDirectionFromVariable(t.direction);this.directionAxis=this.getDirectionAxis(e),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}t.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=t.randomRotation),t.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=t.randomScale)}}updateForceFieldParameters(t){!this.velocitySimRT||(t.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=t.forceIntensity),t.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=t.forceDambing))}getDirectionAxis(t){let e=[Number(t[0])*Ft.DEG2RAD,Number(t[1])*Ft.DEG2RAD,Number(t[2])*Ft.DEG2RAD],i=new Fi(e[0],e[1],e[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(t){let{birthRatePerSec:e,rootObjectType:i,colliderEntityId:r,shape:s,emitTimeDuration:n,emitTimeCycle:a,life:o,directionMode:l,noiseType:h}=t;return e!==void 0||i!==void 0||r||r===null||a!==void 0||s!==void 0||o!==void 0||n!==void 0||l!==void 0||h!==void 0}init(t){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:t.birthRatePerSec,particleMaxLifeTime:t.life,loopDuration:t.emitTimeCycle==="infinity"?0:t.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn("The maximum number of particles is limited to 100000."),this.particlesAmount=1e5),this.emitterShape=this.createShape(t.shape,this.particlesAmount);let e=setInterval(()=>{if(!this.emitterShape)return;let f=this.emitterShape.positionsTexture.source.data.data;f&&!isNaN(f[0])?clearInterval(e):this.init(t)},100);if(!this.emitterShape)return;let i=this.updateSimulationDefinition(t),r=NN(this.renderer)?VZ().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer,this.simFeaturesDefinition):IN().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),s=r.addVariable("uCurrentPosition",i+`
4466
+ `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return r||this.throwError('Unclosed quote after "'+t+'"'),{type:Dt.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(Dt.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Dt.isIdentifierPart(t));)this.index++;return{type:Dt.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){i=!0,this.index++,t===Dt.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(s===Dt.COMMA_CODE){if(this.index++,r++,r!==e.length){if(t===Dt.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Dt.CBRACK_CODE)for(let n=e.length;n<r;n++)e.push(null)}}else if(e.length!==r&&r!==0)this.throwError("Expected comma");else{let n=this.gobbleExpression();(!n||n.type===Dt.COMPOUND)&&this.throwError("Expected comma"),e.push(n)}}return i||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Dt.CPAREN_CODE);if(this.code===Dt.CPAREN_CODE)return this.index++,t.length===1?t[0]:!!t.length&&{type:Dt.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Dt.ARRAY_EXP,elements:this.gobbleArguments(Dt.CBRACK_CODE)}}},DRt=new class{add(t,e,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],e&&this[r][i?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(i){i.call(e&&e.context?e.context:e,e)})}};Object.assign(Dt,{hooks:DRt,plugins:new class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(Dt),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),Dt.max_unop_len=Dt.getMaxKeyLen(Dt.unary_ops),Dt.max_binop_len=Dt.getMaxKeyLen(Dt.binary_ops);var Rv=t=>new Dt(t).parse();Object.getOwnPropertyNames(Dt).forEach(t=>{Rv[t]===void 0&&t!=="prototype"&&(Rv[t]=Dt[t])}),Rv.Jsep=Dt;var ORt={name:"ternary",init(t){t.hooks.add("after-expression",function(e){if(e.node&&this.code===t.QUMARK_CODE){this.index++;let i=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===t.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:"ConditionalExpression",test:i,consequent:r,alternate:s},i.operator&&t.binary_ops[i.operator]<=.9){let n=i;for(;n.right.operator&&t.binary_ops[n.right.operator]<=.9;)n=n.right;e.node.test=n.right,n.right=e.node,e.node=i}}else this.throwError("Expected :")}})}};Rv.plugins.register(ORt);var IRt=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],NRt=["0","1","2","3","4","5","6","7","8","9","."],BRt=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function kRt(t){return typeof t=="string"&&!isNaN(t)&&!isNaN(parseFloat(t))}function Txt(t,e,i="number"){let r,s,n="";for(let a=0;a<t.length;a++){let o=t[a];if("objType"in o&&o.objType==="api"){let l=JSON.parse(o.id),h=l[0],u=e.getUserAPI(h);if(u!==void 0&&typeof u.retrieveValue=="function"){let d=u.retrieveValue(l.slice(1));d!==void 0&&(n+=d)}continue}if("objType"in o&&o.objType==="webhook"){let l=JSON.parse(o.id),[h,u]=l,d=e.getUserWebhook(h);if(d!==void 0){let c=d.getParameterValue(u);c!==void 0&&(n+=c)}continue}if("objType"in o&&o.objType==="aiAssistant"){let l=e.openAIRealtime;if("objId"in o&&o.objId!==void 0){let h;if(e.scene.data.objects.traverse((u,d)=>{let c=d.events?.find(p=>p.id===o.objId);c&&(h=c)}),h!==void 0&&h.data.type==="AIAssistantListener"){let u=l?.computeAnalysisForListenerEvent(h.data);if(u!==void 0){n+=u;continue}}}n+=l?.voice??0;continue}if("id"in o){let l=t[a-1];if(a>0&&"id"in l)return void console.error("Two variables in a row",t);if(Array.isArray(o.id)&&e.referencesMissingObject(o.id))return;let h=e.getVariable(o.id),u=Da.getDisplayedValue(h);i==="number"&&Da.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?u=parseFloat(u).toString():i==="boolean"&&Da.isBoolean(h)?u=h?"true":"false":i==="boolean"&&Da.isTextValue(h)&&!Array.isArray(h.textValue)&&(u='"'+u+'"'),n+=u;continue}i!=="string"?o.name!=="and"?o.name!=="or"?o.name!=="True"?o.name!=="False"?i!=="boolean"||kRt(o.name)||NRt.includes(o.name)||IRt.includes(o.name)||BRt.includes(o.name.replace(/\($/g,""))?n+=o.name:n+='"'+o.name+'"':n+="false":n+="true":n+="||":n+="&&":(o.name!=='"'&&(o.name!=="+"||o.escaped)&&(n+=o.name),o.name==="+"&&!o.escaped&&n[n.length-1]==="\\"&&(n=n.slice(0,-1)+o.name))}if(i==="string")return n;if(t.length===0){if(i==="number")return 0;if(i==="boolean")return!1}try{r=Rv(n)}catch(a){return void console.error(n,a)}try{s=Wi(r)}catch(a){console.error(n,r,a)}if(i!=="number"||s===void 0||Number.isFinite(s))return s;console.error(n,"evaluated to",s)}function Wi(t){switch(t.type){case"BinaryExpression":switch(t.operator){case"==":return Number(Wi(t.left)===Wi(t.right));case"!=":return Number(Wi(t.left)!==Wi(t.right));case">":return Number(Wi(t.left)>Wi(t.right));case">=":return Number(Wi(t.left)>=Wi(t.right));case"<":return Number(Wi(t.left)<Wi(t.right));case"<=":return Number(Wi(t.left)<=Wi(t.right));case"+":return Wi(t.left)+Wi(t.right);case"-":return Wi(t.left)-Wi(t.right);case"*":return Wi(t.left)*Wi(t.right);case"/":return Wi(t.left)/Wi(t.right);case"%":return Wi(t.left)%Wi(t.right);case"&&":return Wi(t.left)&&Wi(t.right);case"||":return Wi(t.left)||Wi(t.right);case"^":return Math.pow(Wi(t.left),Wi(t.right));default:throw new Error("Unknown operator: "+t.operator)}case"UnaryExpression":switch(t.operator){case"-":return-Wi(t.argument);case"!":return Number(!Wi(t.argument));default:throw new Error("Unknown operator: "+t.operator)}case"Identifier":throw new Error("Unknown identifier: "+t.name);case"Literal":return t.value;case"CallExpression":if(t.callee.type==="Identifier"){if(t.callee.name==="random"){let e=0,i=1;if(t.arguments.length>=1)try{e=Wi(t.arguments[0])}catch(r){console.warn(r)}if(t.arguments.length>=2)try{i=Wi(t.arguments[1])}catch(r){console.warn(r)}return e=Math.min(i,e),i=Math.max(i,e),e+Math.random()*(i-e)}return Math[t.callee.name].apply(null,t.arguments.map(Wi))}throw new Error("Unknown node");default:throw new Error("Unknown node type: "+t.type)}}Rv.addBinaryOp("^",11,!0);var Mxt=new Map;function eo(t,e){Mxt.set(t,e)}Ni(),Object.keys({mousehover:!0,scroll:!0,dragdrop:!0,tracking:!0,resize:!0,conditional:!0,variables:!0,"api-services":!0,"ai-assistant":!0,textinputs:!0,audio:!0,video:!0,"create-destroy":!0,"scene-transition":!0,timeline:!0,transitions:!0,"misc-actions":!0});var VRt={MouseHover:"mousehover",Scroll:"scroll",DragDrop:"dragdrop",Follow:"tracking",LookAt:"tracking",Resize:"resize",Conditional:"conditional",VariableChange:"variables",API:"api-services",WEBHOOK:"api-services",AIAssistantListener:"ai-assistant",AIAssistantTrigger:"ai-assistant"},zRt={Audio:"audio",Video:"video",Particles:"particles",Link:"misc-actions",Reset:"misc-actions",SwitchCamera:"misc-actions",ClearLocalStorage:"misc-actions",Create:"create-destroy",Destroy:"create-destroy",Transition:"transitions",Animation:"transitions",TimelineAnimation:"timeline",SceneTransition:"scene-transition",SetVariable:"variables",DynamicVariablePlay:"variables",UserAPI:"api-services"};function Ir(t,e){if(e===void 0)return!0;if(e.expression.length===0||function(r,s){return r.some(n=>"id"in n&&Array.isArray(n.id)&&s.referencesMissingObject(n.id))}(e.expression,t))return!1;let i=Txt(e.expression,t,"boolean");return e.negate?!i:!!i}function dn(t,e,i,r,s,n,a){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},l=h=>({id:u,data:d})=>{try{if(d.type==="Conditional")return void(EU[t.type].includes("Conditional")&&(d.ifActions.forEach(l({expression:d.condition,negate:!1})),d.elseActions.forEach(l({expression:d.condition,negate:!0}))));if(!EU[t.type].includes(d.type))return;let c=function(m){return Mxt.get(m)}(d.type);if(c===void 0)return void On(zRt[d.type]??"misc-actions",`a "${d.type}" action`);let p=c({id:u,data:d,object:n,page:i,shared:r,eventManager:s,eventType:t.type,actionCondition:h,runModeOverride:a});p!=null&&d.type in o&&o[d.type].push(p)}catch{}};return e.forEach(l()),o}function sa(t){Object.values(t).forEach(e=>{e.forEach(i=>{typeof i.dispose=="function"&&i.dispose()})})}var Cq=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],Axt=t=>Cq.find(([e,i])=>i===t)?.[0],TT=t=>Cq.find(([e])=>e===t)?.[1],LRt=(t,e)=>{let i=Axt(t);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:e}),r}},FRt=class extends ro{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=t=>{if(!t.eventName||!t.target||t.eventName==="Scroll")return;let e=this.splineEvents[Axt(t.eventName)]?.[t.target.uuid];if(!e)return;t.eventName==="Scroll"&&t.deltaY!==void 0&&Object.assign(e,{deltaY:t.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(e)}}connect(){let{page:t}=this.eventContext;t.traverseEntity(e=>{if(e.data?.events.length){for(let[i,r]of Cq)if(e.data.events.some(s=>s.data.type===r&&!s.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(e):this.objectsPerEvents.set(i,[e]);let s={id:e.uuid,name:e.name},n=LRt(r,s),a=this.splineEvents[i];a?a[e.uuid]=n:this.splineEvents[i]={[e.uuid]:n}}}}),this.objectsPerEvents.forEach(e=>{e.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(t=>{t.forEach(e=>{e.removeEventListener("beginEvent",this.onBeginEvent)})})}};_o(),ts(),sh();var URt=class{constructor(t,e,i,r,s,n){if(this.id=t,this.data=e,this.object=i,this.entered=!1,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=dn(e,e.actions,r,s,n,i)}disconnect(){sa(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(e=>e.playing&&e.data.runMode!=="Toggle")||this.actions.Transition.forEach(e=>e.play()),this.actions.SwitchCamera.some(e=>e.playing&&e.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},jRt=class extends ro{constructor(t,e,i){super(t),this.eventManager=e,this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=XR(s,n,[],!0);this.sceneInterects=a,a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{(s.data.type==="MouseDown"||s.data.type==="MousePress")&&(this.onCanvasRaycast(r),s.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{s.data.type==="MouseUp"?(this.onCanvasRaycast(r),s.dispatch()):s.data.type==="MousePress"&&s.dispatchRelease()})},this.onMouseDown=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{Ge.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=TT(r);a&&(a==="MouseDown"||a==="MouseUp"||a==="MousePress"?(s.dispatchEvent({type:"beginEvent",eventName:a}),this.eventsPerObjects[a]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent(n)}),this.canvasMouseEvents.forEach(o=>{o.dispatchUserEvent(n)})):(a==="KeyDown"||a==="KeyUp"||a==="KeyPress")&&(s.dispatchEvent({type:"beginEvent",eventName:a}),this.eventsPerObjects[a]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:t,sharedAssets:e,domElement:i}=this.eventContext,r=(s,n)=>{if(!s.data?.events.length)return;let a=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of a){let l=this.eventsPerObjects[o];if(s.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let d=new URt(h,u,s,t,e,this.eventManager);d.actions.Video.length&&(this.hasVideoAction=!0),u.type!=="MouseDown"&&u.type!=="MouseUp"&&u.type!=="MousePress"||u.mode!=="Canvas"&&u.mode!=="Window"?(l[s.uuid]?l[s.uuid].some(c=>c.id===d.id)||l[s.uuid].push(d):l[s.uuid]=[d],Ic(s)&&s.traverseChildren(c=>{if(!c.visible)return!0;c instanceof Ur&&"shapeBlendNode"in c.data.geometry&&c.data.geometry.shapeBlendNode?.operation!==2&&(l[c.uuid]?l[c.uuid].push(d):l[c.uuid]=[d])})):this.canvasMouseEvents.push(d)}catch{}}),l[s.uuid]?.length&&(this.objectsPerTypes[o].push(!Go(s)||o!=="MouseDown"&&o!=="MouseUp"&&o!=="MousePress"?s:n),Ic(s))){let h=this.objectsPerTypes[o];s.traverseChildren(u=>{if(!u.visible)return!0;u instanceof Ur&&h.indexOf(u)===-1&&h.push(u)})}}};t.traverseEntity(s=>{(Ya(s)||s instanceof Or)&&s.frame?.traverse(n=>{r(n,s)}),r(s)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([s,n])=>{n.forEach(a=>{a.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(s=>{s.object.addEventListener("userEvent",this._onUserEvent)})}disconnect(){let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},t.removeEventListener("pointerdown",this.onCanvasMouseDown),t.removeEventListener("pointerup",this.onCanvasMouseUp),t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerdown",this.onMousePressDown),t.removeEventListener("pointerup",this.onMouseUp),t.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(e=>{Object.values(e).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(e=>{e.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([e,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(e=>{e.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(t){let{stopRaycast:e,raycaster:i,page:r,pointerScreen:s}=this.eventContext,n=this.objectsPerTypes[t],a=n.filter(o=>!Go(o));if((n.length||this.useForRaycastProperty)&&(!r.uiCanvas||!lc(r,[s.x,s.y],Object.keys(this.eventsPerObjects[t]),o=>{this.handleObjectMouseEventDispatch(o,t)}))){if(e||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=XR(i,r,a,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),e){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];j7(o).forEach(h=>{Ya(h)&&lc(h,l,Object.keys(this.eventsPerObjects[t]),u=>{this.handleObjectMouseEventDispatch(u,t)}),this.eventsPerObjects[t][h.uuid]&&this.handleObjectMouseEventDispatch(h,t)})}}e||a.forEach(o=>{let l=k5(i,o);l&&(this.handleObjectMouseEventDispatch(o,t),Ya(o)&&lc(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),h=>{this.handleObjectMouseEventDispatch(h,t)}))})}}handleMousePressEvent(t=!1){let e="MousePress",i=this.objectsPerTypes[e],r=i.filter(n=>!Go(n)),s=[];if(i.length){if(!t){let{stopRaycast:n,raycaster:a,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=lc(o,[l.x,l.y],Object.keys(this.eventsPerObjects[e]),u=>{s.push(u)})),n&&!h){let u=XR(a,o,r);s=j7(u),u.forEach(d=>{Ya(d.object)&&lc(d.object,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),c=>{s.push(c)})})}else r.forEach(u=>{let d=k5(a,u);d&&(s.push(u),Ya(u)&&lc(u,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),c=>{s.push(c)}))})}this._prevObjects.length&&this._prevObjects.forEach(n=>{s.includes(n)||this.handleObjectMouseEventDispatchRelease(n,e)}),s.length&&s.forEach(n=>{this.handleObjectMouseEventDispatch(n,e)}),this._prevObjects=s}}handleObjectMouseEventDispatch(t,e){t.dispatchEvent({type:"beginEvent",eventName:e}),this.eventsPerObjects[e]?.[t.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(t,e){t.dispatchEvent({type:"beginEvent",eventName:e}),this.eventsPerObjects[e]?.[t.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(t,e,i=!1){this.objectsPerTypes[e].forEach(r=>{let s=this.eventsPerObjects[e][r.uuid];s.some(({data:n})=>"key"in n&&n.key===t.key)&&r.dispatchEvent({type:"beginEvent",eventName:e}),s.forEach(n=>{"key"in n.data&&n.data.key===t.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(t,e,i=!1){this.objectsPerTypes[e].forEach(r=>{this.eventsPerObjects[e][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===t.key&&s.dispatchHeld(i)})})}};ts(),sh();var G7=t=>t?.isPlayAudioAction===!0,Wut=t=>t?.isPauseAudioAction===!0,z2=t=>t?.isPlayVideoAction===!0,qut=t=>t?.isPauseVideoAction===!0,GRt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.actions=dn(e,e.actions,r,s,n,i)}disconnect(){sa(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(G7(e.interaction)?e.interaction.audioPlayer?.play():Wut(e.interaction)&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let i=e.interaction.data.triggerAfter??"autoplay";i===t&&(z2(e.interaction)?e.interaction.play(i==="autoplay"):qut(e.interaction)&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}async seekVideos(t){let e=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&z2(i.interaction)&&e.push(i.interaction.seek(t))}),await Promise.all(e)}pauseVideos(){this.actions.Video.forEach(t=>{z2(t.interaction)&&t.interaction.pause()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{G7(e.interaction)?e.interaction.audioPlayer?.play():Wut(e.interaction)&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{z2(e.interaction)?e.interaction.play():qut(e.interaction)&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},WRt=class extends ro{constructor(t,e){super(t),this.eventManager=e,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.removeEventListener("pointerdown",this.onAny),s.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(n=>{G7(n.interaction)&&n.interaction.audioPlayer?.play()}),s.actions.Video.forEach(n=>{let a=n.interaction.data.triggerAfter??"autoplay";z2(n.interaction)&&n.interaction.play(a==="autoplay")}),s.actions.Particles.forEach(n=>{n.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{!s.data.visible||n.forEach(a=>{r.push(a.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>{s.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let n=TT(i);n&&n==="Start"&&(Go(r)||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:t,page:e}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:s,data:n}of r.data.events){if(n.disabled||n.type!=="Start")continue;let a=new GRt(s,n,r,e,t,this.eventManager);(a.actions.Transition.length||a.actions.TimelineAnimation.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.Reset.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length||a.actions.ClearLocalStorage.length||a.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}};if(e.traverseEntity(r=>{(Ya(r)||r instanceof Or)&&r.frame?.traverse(s=>{i(s)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,n=s?document:r;n.addEventListener("pointerdown",this.onMouseDown,{once:!0}),n.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),n.addEventListener("pointerdown",this.onAny),n.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,o])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>n.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:e}=this.eventContext,i=e?document:t;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([t,e])=>{t.removeEventListener("userEvent",this.onUserEvent),e.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},Cxt=new Map;function Tl(t,e){Cxt.set(t,e)}Ni();var qRt=class{constructor(t,e,i,r,s){this.publish=t,this.controlsManager=e,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=n=>{let a=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(n.touches.length>1||this.preventTouchScroll||a===!1&&o===!1)&&n.preventDefault()},this.onMouseWheelPreventScroll=n=>{this.preventScroll&&n.preventDefault()},this.onMouseMove=n=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(n),pressed:n.buttons>0}},this.onMouseDown=n=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(n),pressed:!0}},this.onMouseUp=n=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(n),pressed:!1}},this.getMousePosition=n=>{let{domRect:a}=this.eventContext,{pageX:o,pageY:l}=n.touches?.length>0?n.touches[0]:n;return{x:o-(a.left+window.scrollX),y:l-(a.top+window.scrollY)}},this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}warnMissingEventFeatures(){this.eventContext.page.traverseEntity(t=>{for(let e of t.dataPatched.events){if(e.data.disabled===!0)continue;let i=e.data.type;if(this.handlers[i]!==void 0)continue;let r=VRt[i];r!==void 0&&On(r,`a "${i}" event`)}})}activate(t=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown));let e={eventContext:this.eventContext,eventManager:this,sharedVariables:this.sharedVariables,needsMouse:this.needsMouse,needsRaycast:this.needsRaycast};this.handlers={};let i=(n,a)=>{let o=(l=n,Cxt.get(l));var l;o!==void 0?this.handlers[n]=o(e):a!==void 0&&(this.handlers[n]=a())};i("Spline",()=>new FRt(this.eventContext)),i("VariableChange"),i("API"),i("WEBHOOK"),i("AIAssistantListener"),i("AIAssistantTrigger"),i("Conditional"),i("Start",()=>new WRt(this.eventContext,this)),i("Basic",()=>new jRt(this.eventContext,this,this.needsRaycast)),i("MouseHover"),i("Scroll"),i("Follow"),i("DragDrop"),i("LookAt"),i("Resize"),i("Textfields"),this.warnMissingEventFeatures();let{page:r,domElement:s}=this.eventContext;this.hideCursor&&(s.style.cursor="none"),r.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),s.addEventListener("wheel",this.onMouseWheelPreventScroll),s.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,t||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(t=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:i}=this.eventContext;i.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),t||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}dispose(){this.deactivate(),Object.values(this.handlers).forEach(t=>t.dispose())}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(e),i.data.elseActions.forEach(e)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&t.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length)for(let r of i.data.events)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(e);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(e);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(e);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(e);else r.data.type==="LookAt"||r.data.type==="API"||r.data.actions.forEach(e)})}};ht(),ir(),ir();var UE={type:"change"},_w={type:"start"},Jf={type:"end",nonOrbit:!0},HRt={type:"end",nonOrbit:!1},$Rt={type:"end",isZoom:!0,nonOrbit:!0},XRt={type:"end",changed:!1},DF={type:"cameraAnimatingInTimeline"},OF=new Te,Hut=new Z,YRt=2*Math.PI,jE=new P,GE=new Z,xw=new P,ww=new Te,$ut=new xt,KRt={type:"requestRender"},Ext=class extends En{constructor(t,e,i={isPlayMode:!1,isExport:!1},r){super(),this.object=t,this.domElement=e,this.options=i,this.timelineState=r,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,ll.DOLLY_ROTATE,ll.PAN],this.offset=new P,this.eye=new P,this.lastPosition=new P,this.lastQuaternion=new Te,this.current=new Z,this.overShoot=new Z,this.overRatio=new Z,this.spherical=new dU,this.sphericalDelta=new dU,this.panOffset=new P,this.panLeftV=new P,this.panUpV=new P,this.panV=new P,this.rotateStart=new Z,this.rotateEnd=new Z,this.rotateDelta=new Z,this.panStart=new Z,this.panEnd=new Z,this.panDelta=new Z,this.dollyStart=new Z,this.dollyEnd=new Z,this.dollyDelta=new Z,this.rotationRangeFactor=new Z,this.panRangeFactor=new Z,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=s=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=s.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(xw,ww,jE),this.offset.copy(xw).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(OF.copy(ww).invert()),this.panOffset.applyQuaternion(OF),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(ww),this.panOffset.applyQuaternion(ww)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state!==-1||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),xw.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&($ut.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4($ut));let s=this.spherical.phi%YRt;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(ur.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),s>0&&s>Math.PI||s<0&&s>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0){let n=this.hoverRotatePanMode===1?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-n,this.sphericalDelta.phi*=1-n}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(UE),this.object.dispatchEvent(KRt),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=s=>{this.enabled!==!1&&(s.pointerType==="touch"||s.pointerType==="pen"&&Uo?this.onPointerDownTouch(s):this.onPointerDownMouse(s),this.state!==-1&&(this.isPointerDown=!0,this.dispatchEvent(_w),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),s.stopPropagation(),s.pointerType==="touch"||s.pointerType==="pen"&&Uo||this.domElement.setPointerCapture(s.pointerId)))},this.onPointerLeave=s=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(this.hoverRotatePanMode===1?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,jE.subVectors(this.position0,this.target0),this.spherical.setFromVector3(jE),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):this.hoverRotatePanMode===2&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=s},this.onPointerEnter=s=>{this.resetHoverEffectOnPointerLeave||this.pointerLeaveEvent===void 0?GE.set(s.clientX-this.domElement.clientWidth/2,s.clientY-this.domElement.clientHeight/2):GE.set(s.clientX-this.pointerLeaveEvent.clientX,s.clientY-this.pointerLeaveEvent.clientY),this.hoverRotatePanMode===1?(this.rotateDelta.copy(GE).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(Hut,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(s.clientX,s.clientY)):this.hoverRotatePanMode===2&&(this.panDelta.copy(GE).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(s.clientX,s.clientY)),this.update()},this.onPointerMove=s=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(DF):this.enabled!==!1&&(this.checkRaycastLock()||(s.pointerType==="touch"||s.pointerType==="pen"&&Uo?this.onPointerMoveTouch(s):this.onPointerMoveMouse(s),s.stopPropagation()))},this.onPointerUp=s=>{this.isPointerDown=!1,Ge.length===0&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),Ge.length>1&&s.preventDefault(),this.hasChange?this.dispatchEvent(this.state===0?HRt:Jf):this.dispatchEvent(XRt),this.state=-1,s&&(s.stopPropagation(),s.pointerType==="touch"||s.pointerType==="pen"&&Uo||this.domElement.releasePointerCapture(s.pointerId))},this.onPointerDownMouse=s=>{let n;switch(n=this.useKeyEvents?this.mouseButtons[s.button]:this.mouseButtonsPlay[s.button],n){case 0:if(s.altKey!==!0||s.shiftKey||l_(s)){if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2}}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(s),this.state=0}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2;break;case 3:if(l_(s)||s.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(s),this.state=0}break;case 5:if(l_(s)||s.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(s),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(s),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=s=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(s);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(s);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(s)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=s=>{switch(Ge.length>1&&s.preventDefault(),this.touches[Ge.length-1]){case ll.ROTATE:if(this.enableRotate===!1)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case ll.PAN:if(this.enablePan===!1)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case ll.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case ll.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=s=>{switch(Ge.length>1&&s.preventDefault(),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(s),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(s),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(s),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(s),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=LS(()=>{this.zoomChanged?this.dispatchEvent($Rt):this.dispatchEvent(Jf),this.zoomChanged=!1},33),this.onMouseWheel=s=>{if(this.enabled!==!1&&(this.enableZoom!==!1||this.enablePan!==!1)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&s.preventDefault(),this.dispatchEvent(_w),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(DF);s.ctrlKey&&this.enableZoom&&s.preventDefault(),this.handleMouseWheel(s),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=s=>{if(s.preventDefault(),this.enabled!==!1&&!this.checkRaycastLock()&&!aT){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(DF);if(s.type==="gesturechange"){if(this.enableZoom===!1||this.isTouchZoom===!1)return;this.dispatchEvent(_w),s.scale>this.prevScale?this.dollyIn(this.getZoomScale()):s.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=s.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(Jf)}},this.onContextMenu=s=>{s.preventDefault()},this.onTouchEnd=s=>{s.preventDefault()},this.onKeyDown=s=>{this.enabled!==!1&&(this.key=s.key,s.key===" "&&this.dispatchEvent(_w))},this.onKeyUp=s=>{this.key=void 0,this.enabled!==!1&&(this.state!==-1&&s.key==="Alt"&&this.onPointerUp(Ge[0]),s.key===" "&&this.dispatchEvent(Jf))},this.onPointerHover=s=>{s.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot||(this.isPointerDown=!0,this.hoverRotatePanMode===2?this.handleMouseMovePan(s,this.hoverRotatePanStrength):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(s,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=s=>{s.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(xw,ww,jE),this.offset.copy(xw).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(t){t.type==="start"?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(t)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(t){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=t,this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(t,e){this.rotateFactor=t.rotationSpeed??1,this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.thetaIsFree=t.rotationHorizontalOffset.min===t.rotationHorizontalOffset.max&&t.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=t.rotationVerticalOffset.min===t.rotationVerticalOffset.max&&t.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.hoverRotateDamping=t.hoverRotateDamping??this.dampingFactor,this.useWindowEvents=e==="window",this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=t.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,this.autoRotateSpeed=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let r=this.object.getTarget().applyQuaternion(OF.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+r.y,this.maxV=t.panVerticalOffset.max+r.y,this.minH=-t.panHorizontalOffset.min+r.x,this.maxH=t.panHorizontalOffset.max+r.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Cu(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=Cu(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=Cu(Cu(this.spherical.theta)-t.rotationHorizontalOffset.min),this.maxTheta=Cu(Cu(this.spherical.theta)+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,t.orbitTouches===1&&(this.touches[0]=ll.ROTATE),t.panTouches===1&&(this.touches[0]=ll.PAN),t.orbitTouches===2&&(this.touches[1]=ll.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=ll.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=ll.ROTATE),t.panTouches===3&&(this.touches[2]=ll.PAN),this.isTouchZoom=t.isTouchZoom,this.resetHoverEffectOnPointerLeave=t.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,e,i,r,s,n,a,o){let l,h,u;this.overShoot.set(0,0),t instanceof P?(l=t.x,h=t.y,this.current.set(this.target.x,this.target.y),u=!0):(l=t.theta,h=t.phi,this.current.set(Cu(this.spherical.theta),Cu(this.spherical.phi)),u=!1),i===0&&(this.current.x+=l,this.current.y+=h),(e===3||e===2)&&(!u&&this.isThetaFlipped?this.current.x>r&&this.current.x<0?this.overShoot.x=r-this.current.x:this.current.x<s&&this.current.x>0&&(this.overShoot.x=s-this.current.x):this.current.x>r?this.overShoot.x=r-this.current.x:this.current.x<s&&(this.overShoot.x=s-this.current.x)),(e===3||e===1)&&(this.current.y>n?this.overShoot.y=n-this.current.y:this.current.y<a&&(this.overShoot.y=a-this.current.y)),u||(this.overShoot.x=Cu(this.overShoot.x),this.overShoot.y=Cu(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(o),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=Xut(Math.abs(this.overRatio.x)),this.overRatio.y=Xut(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(l*this.overShoot.x<0&&!this.thetaIsFree&&(l*=1-this.overRatio.x),h*this.overShoot.y<0&&!this.phiIsFree&&(h*=1-this.overRatio.y)):i===2&&(!u&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||u&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(l=.05*this.overShoot.x),this.phiIsFree||(h=.05*this.overShoot.y),u?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):u?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(l+=this.overShoot.x,h+=this.overShoot.y),t instanceof P?(t.x=l,t.y=h):(this.thetaIsFree||(t.theta=l),this.phiIsFree||(t.phi=h))}setEnableDampingSpeed(t){this.enableDamping=t,this.rotateSpeed=(t===!0?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(t,e,i){this.stopDamping(),this.target.set(t,e,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,e){this.panLeftV.setFromMatrixColumn(e,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,e){this.panUpV.setFromMatrixColumn(e,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,e){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let r=this.object.position;this.panV.copy(r).sub(this.target);let s=this.panV.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*s/i.clientHeight,this.object.matrixWorld),this.panUp(2*e*s/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(UE)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(UE)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(UE)}setZoom(t){if(this.dispatchEvent(_w),this.object.isPerspectiveCamera){let e=this.initialSphericalRadius/t/this.spherical.radius;this.scale=e}else this.object.isOrthographicCamera&&(this.object.zoom=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(Jf)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,e=1){t.movementX!==void 0?this.rotateDelta.set(t.movementX,t.movementY):(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*e).rotateAround(Hut,-this.object.angleOffsetFromUp);let i=this.domElement,r=this.useWindowEvents?window.innerHeight:i.clientHeight,s=2*Math.PI*this.rotateDelta.x/r,n=2*Math.PI*this.rotateDelta.y/r;this.rotateLeft(s),this.rotateUp(n),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,e=1){t.movementX!==void 0?this.panDelta.set(t.movementX,t.movementY):(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*e),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(t.deltaX===0&&t.deltaY===0)return;let e=t.ctrlKey===!0||l_(t)===!0,i=l_(t)===!1&&((n=t).wheelDeltaY===0||n.deltaY===0?!(VS&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120)&&(n.wheelDeltaX?yX(n.wheelDeltaX,n.deltaX):n.deltaMode===0):n.wheelDeltaY?yX(n.wheelDeltaY,n.deltaY):n.deltaMode===0)===!0,r=e===!1&&(this.gesture===!0||t.timeStamp-this.lastTrackpadPanTime<300),s=e===!1&&r===!1&&t.timeStamp-this.lastMouseWheelZoomTime<300;var n;if(Qmt!==!1||s!==!1||i!==!0&&r!==!0){if(this.enableZoom===!1)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(Jf)),e===!1&&i===!1&&(this.lastMouseWheelZoomTime=t.timeStamp),t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(this.enablePan===!1)return;let a=this.gesture===!1&&r===!1;this.lastTrackpadPanTime=t.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),a===!1&&(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(Jf)},100)}}handleTouchStartRotate(){if(Ge.length===2){let t=.5*(Ge[0].pageX+Ge[1].pageX),e=.5*(Ge[0].pageY+Ge[1].pageY);this.rotateStart.set(t,e)}else this.rotateStart.set(Ge[0].pageX,Ge[0].pageY)}handleTouchStartPan(){if(Ge.length===2){let t=.5*(Ge[0].pageX+Ge[1].pageX),e=.5*(Ge[0].pageY+Ge[1].pageY);this.panStart.set(t,e)}else this.panStart.set(Ge[0].pageX,Ge[0].pageY)}handleTouchStartDolly(){let t=Ge[0].pageX-Ge[1].pageX,e=Ge[0].pageY-Ge[1].pageY,i=Math.sqrt(t*t+e*e);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(Ge.length===2){let i=pI(t),r=.5*(t.pageX+i.x),s=.5*(t.pageY+i.y);this.rotateEnd.set(r,s)}else{if(t.pointerId!==Ge[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;e&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(Ge.length===2){let e=pI(t),i=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);this.panEnd.set(i,r)}else{if(t.pointerId!==Ge[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let e=pI(t),i=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(i*i+r*r);this.dollyEnd.set(0,s),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=this.options?.showCameraLock;return t&&t(),!0}}return!1}};function Cu(t){let e=2*Math.PI;for(;t<=-Math.PI;)t+=e;for(;t>Math.PI;)t-=e;return t}function Xut(t){return 1-Math.pow(1-t,4)}ht();var ZRt=class{constructor(t,e,i,r){this.enableResponsive=!1,this._renderer=t,this._camera=e,this._frameSize=new Z().copy(i),this._fov=r??e.fov}set frameSize(t){this._frameSize.copy(t)}setRenderSize(t,e){this._renderSize=t===void 0||e===void 0?void 0:new Z(t,e)}updateRenderer(){if(!this._renderer)return;let t=this._renderSize??this._frameSize;this._renderer.setSize(t.x,t.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._renderSize??this._frameSize;this._renderer.setViewport(0,0,t.x,t.y)}updateCamera(){!this._camera||(this._camera.cameraType==="PerspectiveCamera"?(this._camera.aspect=this._frameSize.x/this._frameSize.y,this._camera.updateProjectionMatrix()):this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive))}setCamera(t){this._camera=t,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};oa(),ht(),ht(),ht();var ws=new zs,WE=new P,Yut=new Z,Kut=new Z,Zut=new Z,QRt=class{constructor(t){this.geometry=t.geometry,this.randomFunction=Math.random,this.indexAttribute=this.geometry.index,this.positionAttribute=this.geometry.getAttribute("position"),this.normalAttribute=this.geometry.getAttribute("normal"),this.colorAttribute=this.geometry.getAttribute("color"),this.uvAttribute=this.geometry.getAttribute("uv"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(t){return this.weightAttribute=t?this.geometry.getAttribute(t):null,this}build(){let t=this.indexAttribute,e=this.positionAttribute,i=this.weightAttribute,r=t?t.count/3:e.count/3,s=new Float32Array(r);for(let o=0;o<r;o++){let l=1,h=3*o,u=3*o+1,d=3*o+2;t&&(h=t.getX(h),u=t.getX(u),d=t.getX(d)),i&&(l=i.getX(h)+i.getX(u)+i.getX(d)),ws.a.fromBufferAttribute(e,h),ws.b.fromBufferAttribute(e,u),ws.c.fromBufferAttribute(e,d),l*=ws.getArea(),s[o]=l}let n=new Float32Array(r),a=0;for(let o=0;o<r;o++)a+=s[o],n[o]=a;return this.distribution=n,this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e,i,r){let s=this._sampleFaceIndex();return this._sampleFace(s,t,e,i,r)}_sampleFaceIndex(){let t=this.distribution[this.distribution.length-1];return this._binarySearch(this.randomFunction()*t)}_binarySearch(t){let e=this.distribution,i=0,r=e.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||e[n-1]<=t&&e[n]>t){s=n;break}t<e[n]?r=n-1:i=n+1}return s}_sampleFace(t,e,i,r,s){let n=this.randomFunction(),a=this.randomFunction();n+a>1&&(n=1-n,a=1-a);let o=this.indexAttribute,l=3*t,h=3*t+1,u=3*t+2;return o&&(l=o.getX(l),h=o.getX(h),u=o.getX(u)),ws.a.fromBufferAttribute(this.positionAttribute,l),ws.b.fromBufferAttribute(this.positionAttribute,h),ws.c.fromBufferAttribute(this.positionAttribute,u),e.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,a).addScaledVector(ws.c,1-(n+a)),i!==void 0&&(this.normalAttribute!==void 0?(ws.a.fromBufferAttribute(this.normalAttribute,l),ws.b.fromBufferAttribute(this.normalAttribute,h),ws.c.fromBufferAttribute(this.normalAttribute,u),i.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,a).addScaledVector(ws.c,1-(n+a)).normalize()):ws.getNormal(i)),r!==void 0&&this.colorAttribute!==void 0&&(ws.a.fromBufferAttribute(this.colorAttribute,l),ws.b.fromBufferAttribute(this.colorAttribute,h),ws.c.fromBufferAttribute(this.colorAttribute,u),WE.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,a).addScaledVector(ws.c,1-(n+a)),r.r=WE.x,r.g=WE.y,r.b=WE.z),s!==void 0&&this.uvAttribute!==void 0&&(Yut.fromBufferAttribute(this.uvAttribute,l),Kut.fromBufferAttribute(this.uvAttribute,h),Zut.fromBufferAttribute(this.uvAttribute,u),s.set(0,0).addScaledVector(Yut,n).addScaledVector(Kut,a).addScaledVector(Zut,1-(n+a))),this}};function Qut(t,e){let i=t,r=new Float32Array(4*e*e);for(let n=0;n<e*e;n++)r[4*n]=i[3*n],r[4*n+1]=i[3*n+1],r[4*n+2]=i[3*n+2],r[4*n+3]=0;let s=new vr(r,e,e,ln,Qe);return s.needsUpdate=!0,s}byt(),ht(),ht(),ht(),ht();var IF=class{constructor(t,e,i,r){this.type="SphereEmitterShape",this.targetMesh=void 0,this.size=t,this.type=i,this.textureSize=function(o){let l=Math.ceil(Math.sqrt(o));return Math.max(l,1)}(e),this.targetMesh=r?.geometry.type==="BufferGeometry"||r?.type==="Mesh"&&r&&r.geometry.hasAttribute("position")&&r.geometry.hasAttribute("normal")?r:this.getMesh(i,1);let{positions:s,dataTexture:n,dataTextureNormals:a}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(i,1));this.positionsTexture=n,this.positionsAttribute=s,this.directionsTexture=a}createPositions(t,e){let{positions:i,normals:r}=function(s,n){let a=new yr(s.geometry,s.material),o=[],l=[],h=new P,u=new P;a.geometry.index!==null&&(a.geometry=a.geometry.toNonIndexed());let d=new QRt(a).build();for(let c=0;c<n;c++)d.sample(h,u),o.push(h.x,h.y,h.z),l.push(u.x,u.y,u.z);return{positions:new Float32Array(o),normals:new Float32Array(l)}}(e,t*t);return{dataTexture:Qut(i,t),positions:i,dataTextureNormals:Qut(r,t)}}getMesh(t,e){let i=null;switch(t){case"SphereEmitterShape":i=new Ec(.5*e,32,32);break;case"TorusEmitterShape":i=new f4(.5*e,.3,15,40);break;case"ConeEmitterShape":i=new m4(e,e,15);break;case"BoxEmitterShape":i=new Zh(e,e,e);break;case"PlaneEmitterShape":i=new Oc(e,e),i.rotateX(-Math.PI/2);break;default:i=new Ec(e,32,32)}return new yr(i,new jo({color:16711680}))}applyToShader(t,e){this.size=new P().fromArray(e.size.map(i=>typeof i=="number"?i:1)),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function H1(t){let e={...t},i=R4.defaultData;e.forceFieldObjectId&&(e.colliderEntityId=e.forceFieldObjectId);let r={...i.shape,...e.shape},s={...i.renderMaterial,...e.renderMaterial};return{...i,...e,shape:r,renderMaterial:s}}Be();var JRt=class extends ur{constructor(t,e){super(),this.type="ParticleEmitter",this.debugMode=!1,this.worldSpace=!0,this.rootObject=null,this.gpuCompute=null,this.positionSimRT=null,this.velocitySimRT=null,this.emissionRateSimRT=null,this.emitterShape=void 0,this.isEmitting=!1,this.hasBeenReset=!1,this.emittedParticlesAmount=0,this.lastEmitTime=0,this.globalTime=0,this.targetFPS=60,this.previousRatio=1,this.lerpFactor=.4,this.particlesAmount=0,this.noiseStrength=0,this.noiseScale=0,this.isBillboardBased=!0,this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1},this.textureLoader=new jmt,this.textureRequestId=0,this.currentWorldPosition=new P,this.systemQuaternion=new Te,this.worldGravity=new P(0,0,0),this.directionAxis=new P(0,0,0),this.colliderV3=new P(0,0,0),this.colliderQuaternion=new Te(0,0,0,1),this.matrixAutoUpdate=!0,this.renderer=t,this.system=e,this.shared=e.context.shared;let i=e.data;this.material=NN(t)?VZ()?.createMaterial(i.renderMaterial,e.context)??IN().createMaterial(i.renderMaterial,e.context):IN().createMaterial(i.renderMaterial,e.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:i.renderMaterial.color},uColor2:{value:i.renderMaterial.color2},uPosition:{value:new P(0,0,0)},uEmissionData:{value:new P(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new P(0,0,0)},uWorldQuaternion:{value:new Me(0,0,0,1)},uRandScaleFactor:{value:i.randomScale??0},uRandRotationFactor:{value:i.randomRotation??0},uRotation:{value:i.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:i.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,i.renderMaterial.texture),this.init(i)}setTexture(t,e){let i=e.data,r=++this.textureRequestId;if(typeof e=="string"){let s=this.shared.image(e),n=()=>{if(r!==this.textureRequestId)return;let a=new pi(s.img);a.needsUpdate=!0,t.uTexture.value=a};return void(s.loaded?n():s.loadPromise.then(n))}if(typeof i!="string"){let s=new Image;s.onload=()=>{if(r!==this.textureRequestId)return;let o=new pi(s);o.needsUpdate=!0,t.uTexture.value=o};let n=new Blob([i],{type:"image/*"}),a=URL.createObjectURL(n);s.src=a}}updateGeometryAttributes(t,e){let i=function(s){let n=new Float32Array(s*s*2);for(let a=0;a<s;a++)for(let o=0;o<s;o++){let l=a*s+o;n[2*l+0]=a/(s-1),n[2*l+1]=o/(s-1)}return n}(e);if(!this.emitterShape?.positionsAttribute)return;let r=new mo(i,2);t.geometry.setAttribute("ref",r),NN(this.renderer)&&t.geometry.setAttribute("particleRef",r)}applyWorldSpace(){if(!(this.system.started&&this.worldSpace&&this.positionSimRT&&this.velocitySimRT))return;let t=this.system;t.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),t.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(t,e){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset)return void this.reset();this.applyWorldSpace(),this.globalTime=t,this.positionSimRT.material.uniforms.uTime.value=t,this.emissionRateSimRT.material.uniforms.uTime.value=t;let i=1e3/e,r=this.targetFPS/i,s=this.previousRatio+(r-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=s,this.previousRatio=s;let n=this.isEmitting?this.GoEmitSomeParticles(t,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=n,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let t=this.system.colliderEntities[0],e=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(t.destroyedInAction&&e&&this.init(H1({...this.system.data,colliderEntityId:null})),!t||t.destroyedInAction)return;t.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=t.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),t.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(t){!this.velocitySimRT||!this.positionSimRT||(t.renderMaterial&&this.updateMaterialState(t.renderMaterial),this.updateParticleState(t))}updateVariableState(t,e){if(!this.velocitySimRT||!this.positionSimRT)return;e[2]==="size"&&this.material.updateState({size:[t,this.material.uniforms.uSizeEnd.value]}),e[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,t]});let i=(r,s)=>{let n=[...this.system.data.shape.size];n[r]=s,this.updateParticleState({shape:{...this.system.data.shape,size:n}})};e[2]==="shape_size_0"&&i(0,t),e[2]==="shape_size_1"&&i(1,t),e[2]==="shape_size_2"&&i(2,t),e[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=t/10),e[2]==="gravity"&&this.worldGravity.set(0,t/100,0),e[2]==="noiseStrength"&&(this.noiseStrength=t,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e[2]==="noiseScale"&&(this.noiseScale=t,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(t),this.system.data.direction[1],this.system.data.direction[2]])),e[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(t),this.system.data.direction[2]])),e[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(t)]))}updateMaterialState(t){this.material.updateState({...t,size:t.size?[Number(this.shared.getVariable(t.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(t.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),t.texture&&(this.setTexture(this.material.uniforms,t.texture),this.material.needsUpdate=!0)}updateParticleState(t){if(this.positionSimRT&&this.velocitySimRT){if(this.shouldReInitGPUCompute(t)&&this.init(H1(this.system.data)),t.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=t.life),t.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(t.speed,[this.uuid,"particles","speed"]))/10),t.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=t.collisionBounce),t.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(t.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(t.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=t.noiseSeed),t.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=t.randomMass),t.renderMaterial?.size!==void 0){let e=this.shared.getVariable(t.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(e)}if(t.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=t.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=t.renderMaterial.spriteRotation[1]),t.shape!==void 0){let e=t.shape.size??this.system.data.shape.size,i=[Number(this.shared.getVariable(e[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e[2],[this.uuid,"particles","shape_size_2"]))],r={...H1(this.system.data).shape,size:i};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,r)}if(t.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),t.direction!==void 0){let e=this.getDirectionFromVariable(t.direction);this.directionAxis=this.getDirectionAxis(e),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}t.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=t.randomRotation),t.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=t.randomScale)}}updateForceFieldParameters(t){!this.velocitySimRT||(t.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=t.forceIntensity),t.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=t.forceDambing))}getDirectionAxis(t){let e=[Number(t[0])*Ft.DEG2RAD,Number(t[1])*Ft.DEG2RAD,Number(t[2])*Ft.DEG2RAD],i=new Fi(e[0],e[1],e[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(t){let{birthRatePerSec:e,rootObjectType:i,colliderEntityId:r,shape:s,emitTimeDuration:n,emitTimeCycle:a,life:o,directionMode:l,noiseType:h}=t;return e!==void 0||i!==void 0||r||r===null||a!==void 0||s!==void 0||o!==void 0||n!==void 0||l!==void 0||h!==void 0}init(t){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:t.birthRatePerSec,particleMaxLifeTime:t.life,loopDuration:t.emitTimeCycle==="infinity"?0:t.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn("The maximum number of particles is limited to 100000."),this.particlesAmount=1e5),this.emitterShape=this.createShape(t.shape,this.particlesAmount);let e=setInterval(()=>{if(!this.emitterShape)return;let f=this.emitterShape.positionsTexture.source.data.data;f&&!isNaN(f[0])?clearInterval(e):this.init(t)},100);if(!this.emitterShape)return;let i=this.updateSimulationDefinition(t),r=NN(this.renderer)?VZ().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer,this.simFeaturesDefinition):IN().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),s=r.addVariable("uCurrentPosition",i+`
4467
4467
 
4468
4468
 
4469
4469
 
@@ -5099,11 +5099,11 @@ void main() {
5099
5099
  void main() {
5100
5100
  vec4 texel = texture2D( tDiffuse, vUv );
5101
5101
  gl_FragColor = texel;
5102
- }`}),S4t=new class{constructor(t){this._mesh=new yr(w4t,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,x4t)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(zxt),FF=null,UF=null,T4t=ei.identity(),Lxt=class{constructor(t,e,i,r){var s;this.uuid=t,this.width=e,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||pS.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=_dt(n,a,this.dpr,this.isScreenSpace),this.renderer.setSize(n,a)},this.onFrameOverrideObjectEvent=n=>{if(n.target?.uuid!==void 0){let a=this.frameRoot?.find(n.target.uuid);a&&a.dispatchEvent({...n,target:a})}},this.scene2d=new Rq(Ft.generateUUID(),QU.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(FF===null&&(FF=document.createElement("canvas")),FF),this.renderer=(s=this.canvas,UF===null&&(UF=new m4t(s)),UF),this.promise=this.init(),this.renderTarget=new xg(1,1,{type:ai,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new TG(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(t){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,t.blitTextureToTarget)t.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{zxt.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),S4t.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,r){this.scene2d.updateEntityByOp(t,e,i,r),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,i=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=i,this.frameOverride.localMatrix=T4t,this.isScreenSpace&&(this.frameOverride.fill.color=Hi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},Fxt({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let i=Math.max(1,t?.width??this.width),r=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=r,this._innerApplySize();let s=function(n,a,o,l){let h=_dt(n,a,o,l),u=Math.max(o,512/Math.min(n,a)),d=Math.min(u,h);return{width:Math.max(1,Math.ceil(n*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,e,this.isScreenSpace);this.renderTarget.setSize(s.width,s.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(e&&e instanceof Qu)return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent),i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginState",this.onFrameOverrideObjectEvent),t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function Fxt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Qu&&e instanceof Qu||t instanceof wm&&e instanceof wm)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],h=e.children[a];l&&h&&l.uuid===h.uuid&&M4t({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function M4t({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(jF(d))return[d.width,d.height];if(d instanceof F5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof wm){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:h,position:u}=Vxt({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=u,t.data={...t.data,position:u},t.states)for(let d in t.states)A4t({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(jF(t)||t instanceof wm)jF(t)&&(t.width=l,t.height=h,t.data={...t.data,width:l,height:h}),Fxt({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:h,initialParentWidth:a,initialParentHeight:o});else if(t instanceof F5){let d=e,c=a!==0?l/a:1,p=o!==0?h/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(Bxt(m))return console.warn("Cannot scale invalid path",m),LF([]);if(f===1&&g===1)return m;try{return LF((0,_4t.parseSVG)(m).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*f),"y"in v&&(v.y=v.y*g),"x1"in v&&(v.x1=v.x1*f),"x2"in v&&(v.x2=v.x2*f),"y1"in v&&(v.y1=v.y1*g),"y2"in v&&(v.y2=v.y2*g),"rx"in v&&(v.rx=v.rx*f),"ry"in v&&(v.ry=v.ry*g),v}))}catch(y){return console.warn("Error parsing SVG path",y),LF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function A4t({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:h,height:u,position:d}=Vxt({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:$g.isResizeable(l)?l.width:0,objectInitialHeight:$g.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),$g.isResizeable(o)&&Object.assign(e.states[t],{width:h,height:u})}}function jF(t){return t instanceof MT||t instanceof Qu||t instanceof Eq||t instanceof Pq}gD();var xdt,C4t=class extends Ur{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new Lxt(t+"-canvas",e.geometry.width,e.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),t.type===0&&(t.props.frame!==void 0&&this.applyFrame(t.props.frame,i.shared),(t.props.width!==void 0||t.props.height!==void 0)&&this.applySize(t.props,i.shared))}applySize(t,e){let i=t?.width??this.dataPatched.geometry.width,r=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(e)}applyFrame(t,e){this.uiCanvas.applyFrame(t),this.applyGeometryParametersFromFrame(e),this.applyMaterialParametersFromFrame({shared:e})}applyGeometryParametersFromFrame(t){let e=this.frame;e&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=hm(this.dataPatched.geometry,t,this.data.flatShading,this))}applyMaterialParametersFromFrame(t){let e=this.frame;if(e){let i=e.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset?.(this.dataPatched.material,t,!0)}}updateEntity2DByOp(t,e,i,r){this.uiCanvas.updateEntity2DByOp(t,e,i,r),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):er(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(t){super.removeInteractionGeometry(t),this.applySize({},t)}updateGeometryInteractions(t,e){super.updateGeometryInteractions(t,e),this.applySize({width:t.width,height:t.height},e);let i={...this.data.geometry,...t};this.localGeometry?.dispose(),this.localGeometry=hm(i,e,this.data.flatShading,this)}};Ni(),eb("UIGeometry",(t,e,i)=>new C4t(t,e,i)),lD=xdt={Scene2D:Rq,UICanvas:Lxt,loadHanaUIRUNTIME:function(){return V5||(V5=async()=>async function(t,e){return await t.default(e?{module_or_path:e}:void 0),Object.getOwnPropertyDescriptor(t.Engine.prototype,"scene")||Object.defineProperty(t.Engine.prototype,"scene",{get:function(){let i=Object.create(t.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>t.Engine.create(i,JSON.parse('{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}'),!0)}}(await Promise.resolve().then(()=>(a$(),n$)),adt??function(){let t=typeof process<"u"?"2.0.121":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),Ixt().then(()=>{})},setHanaUIWasmUrl:function(t){adt=t}},H4!==null&&xdt.setHanaUIWasmUrl(H4),Nr("ui-2d"),LW(),J0t(),ht();var Uxt,GF,E4t=class{constructor(){this.type="ShapePath",this.color=new ae,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Q2,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,s,n){return this.currentPath?.bezierCurveTo(t,e,i,r,s,n),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(h,u,d,c){let p=h.x,m=u.x,f=d.x,g=c.x,y=h.y,v=u.y,b=d.y,_=c.y,x=(g-f)*(y-b)-(_-b)*(p-f),S=(_-b)*(m-p)-(g-f)*(v-y),w=x/S,T=((m-p)*(y-b)-(v-y)*(p-f))/S;if(S===0&&x!==0||w<=0||w>=1||T<0||T>1)return null;if(x===0&&S===0){for(let C=0;C<2;C++){if(i(C===0?d:c,h,u),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(m-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let C=0;C<2;C++)if(i(C===0?d:c,h,u),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}return{x:+(p+w*(m-p)).toPrecision(10),y:+(y+w*(v-y)).toPrecision(10),t:w}}function i(h,u,d){let c,p=d.x-u.x,m=d.y-u.y,f=h.x-u.x,g=h.y-u.y,y=p*g-f*m;return h.x===u.x&&h.y===u.y?(t.loc=0,void(t.t=0)):h.x===d.x&&h.y===d.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*f<0||m*g<0?t.loc=5:Math.sqrt(p*p+m*m)<Math.sqrt(f*f+g*g)?t.loc=6:(c=p!==0?f/p:g/m,t.loc=2,t.t=c))}let r=0,s=999999999,n=-999999999,a=[];this.subPaths.forEach(h=>{let u=h.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<u.length;f++){let g=u[f];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<m&&(m=g.x)}n<=p&&(n=p+1),s>=m&&(s=m-1),u.length&&a.push({curves:h.curves,points:u,isCW:eU.isClockWise(u),identifier:r++,boundingBox:new EG(new Z(m,c),new Z(p,d))})});let o=a.map(h=>function(u,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Z;u.boundingBox.getCenter(f);let g=function(S,w,T){let C=new Z;w.getCenter(C);let M=[];return T.forEach(A=>{A.boundingBox.containsPoint(C)&&function(R,I){let O=[],B=[];for(let V=1;V<R.length;V++){let z=R[V-1],k=R[V];for(let L=1;L<I.length;L++){let H=e(z,k,I[L-1],I[L]);H!==null&&O.find(W=>W.t<=H.t+Number.EPSILON&&W.t>=H.t-Number.EPSILON)===void 0&&(O.push(H),B.push(new Z(H.x,H.y)))}}return B}(S,A.points).forEach(R=>{M.push({identifier:A.identifier,isCW:A.isCW,point:R})})}),M.sort((A,R)=>A.point.x-R.point.x),M}([new Z(c,f.y),new Z(p,f.y)],u.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===u.identifier?y.push(S):v.push(S)});let b=y[0].point.x,_=[],x=0;for(;x<v.length&&v[x].point.x<b;)_.length>0&&_[_.length-1]===v[x].identifier?_.pop():_.push(v[x].identifier),x++;if(_.push(u.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:u.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let C=0;C<_.length;C++){let M=_[C];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:u.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(h,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(h=>{let u=o[h.identifier];if(u&&!u.isHole){let d=new OS;d.curves=h.curves,o.filter(c=>c?.isHole&&c.for===h.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new Q2;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},jxt=!1,wdt=new Promise(t=>{Uxt=t}),Sdt=!1;function Tdt(){if(jxt=!0,!Sdt)return GF||(GF=async function(){let t=await import("./opentype.js");Uxt(t),Sdt=!0}(),GF)}var P4t=new class{async load(t,e,i=()=>{}){let{load:r}=await wdt;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await wdt;try{let r=e(t),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};function R4t(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}ht(),dW(),Ni(),eb("TextGeometry",(t,e,i)=>new TD(t,e,i));var Mdt={create:(t,e)=>new Aj(t,e)};ij("TextGeometry",Mdt),ij("InputGeometry",Mdt),uW=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{this._layoutErrorWarned=!1;let e=await async function(i){let r,s,n=!1;if(i.url?(r=await async function(a){let o;try{o=await fetch(a)}catch(l){throw new Error(`could not fetch the font at ${a}: ${l}`)}if(!o.ok)throw new Error(`${o.status} ${o.statusText} fetching the font at ${a}`);return await o.arrayBuffer()}(i.url),s=i.url,n=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!jxt)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await P4t.parse(r);if(a)return{font:a.font,url:s,intercepted:n,arr:r,bidi:a.bidi}}}}(t);e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}warnLayoutError(t){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,t))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,u=String.fromCharCode(i[l].unicode),d=s[a];if(R4t(h,d)||o)n.push({char:u,index:h,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",m=[d.state.glyphIndex],f=[],g=!1;for(;!g;)a++,p=e.charAt(a),c+=p,m.push(t.charToGlyphIndex(p)),f=t.stringToGlyphs(c),f.length===1&&f[0].index===h&&(g=!0),a>e.length&&(g=!0);n.push({char:u,index:h,replacements:m,replacementChars:Array.from(c)}),a++}}return n}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,s=e.fontSize/this.unitsPerEm,n=e.fontSize*e.lineHeight,a=t.map(y=>this.getTextWidth(y,e)),o=typeof e.width=="string"?Number(i.getVariable(e.width)):e.width,l=typeof e.height=="string"?Number(i.getVariable(e.height)):e.height,h=this.getCharWidth(`
5102
+ }`}),S4t=new class{constructor(t){this._mesh=new yr(w4t,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,x4t)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(zxt),FF=null,UF=null,T4t=ei.identity(),Lxt=class{constructor(t,e,i,r){var s;this.uuid=t,this.width=e,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||pS.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=_dt(n,a,this.dpr,this.isScreenSpace),this.renderer.setSize(n,a)},this.onFrameOverrideObjectEvent=n=>{if(n.target?.uuid!==void 0){let a=this.frameRoot?.find(n.target.uuid);a&&a.dispatchEvent({...n,target:a})}},this.scene2d=new Rq(Ft.generateUUID(),QU.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(FF===null&&(FF=document.createElement("canvas")),FF),this.renderer=(s=this.canvas,UF===null&&(UF=new m4t(s)),UF),this.promise=this.init(),this.renderTarget=new xg(1,1,{type:ai,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new TG(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(t){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,t.blitTextureToTarget)t.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{zxt.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),S4t.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,r){this.scene2d.updateEntityByOp(t,e,i,r),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,i=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=i,this.frameOverride.localMatrix=T4t,this.isScreenSpace&&(this.frameOverride.fill.color=Hi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},Fxt({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let i=Math.max(1,t?.width??this.width),r=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=r,this._innerApplySize();let s=function(n,a,o,l){let h=_dt(n,a,o,l),u=Math.max(o,512/Math.min(n,a)),d=Math.min(u,h);return{width:Math.max(1,Math.ceil(n*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,e,this.isScreenSpace);this.renderTarget.setSize(s.width,s.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(e&&e instanceof Qu)return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent),i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginState",this.onFrameOverrideObjectEvent),t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function Fxt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Qu&&e instanceof Qu||t instanceof wm&&e instanceof wm)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],h=e.children[a];l&&h&&l.uuid===h.uuid&&M4t({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function M4t({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(jF(d))return[d.width,d.height];if(d instanceof F5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof wm){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:h,position:u}=Vxt({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=u,t.data={...t.data,position:u},t.states)for(let d in t.states)A4t({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(jF(t)||t instanceof wm)jF(t)&&(t.width=l,t.height=h,t.data={...t.data,width:l,height:h}),Fxt({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:h,initialParentWidth:a,initialParentHeight:o});else if(t instanceof F5){let d=e,c=a!==0?l/a:1,p=o!==0?h/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(Bxt(m))return console.warn("Cannot scale invalid path",m),LF([]);if(f===1&&g===1)return m;try{return LF((0,_4t.parseSVG)(m).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*f),"y"in v&&(v.y=v.y*g),"x1"in v&&(v.x1=v.x1*f),"x2"in v&&(v.x2=v.x2*f),"y1"in v&&(v.y1=v.y1*g),"y2"in v&&(v.y2=v.y2*g),"rx"in v&&(v.rx=v.rx*f),"ry"in v&&(v.ry=v.ry*g),v}))}catch(y){return console.warn("Error parsing SVG path",y),LF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function A4t({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:h,height:u,position:d}=Vxt({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:$g.isResizeable(l)?l.width:0,objectInitialHeight:$g.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),$g.isResizeable(o)&&Object.assign(e.states[t],{width:h,height:u})}}function jF(t){return t instanceof MT||t instanceof Qu||t instanceof Eq||t instanceof Pq}gD();var xdt,C4t=class extends Ur{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new Lxt(t+"-canvas",e.geometry.width,e.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),t.type===0&&(t.props.frame!==void 0&&this.applyFrame(t.props.frame,i.shared),(t.props.width!==void 0||t.props.height!==void 0)&&this.applySize(t.props,i.shared))}applySize(t,e){let i=t?.width??this.dataPatched.geometry.width,r=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(e)}applyFrame(t,e){this.uiCanvas.applyFrame(t),this.applyGeometryParametersFromFrame(e),this.applyMaterialParametersFromFrame({shared:e})}applyGeometryParametersFromFrame(t){let e=this.frame;e&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=hm(this.dataPatched.geometry,t,this.data.flatShading,this))}applyMaterialParametersFromFrame(t){let e=this.frame;if(e){let i=e.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset?.(this.dataPatched.material,t,!0)}}updateEntity2DByOp(t,e,i,r){this.uiCanvas.updateEntity2DByOp(t,e,i,r),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):er(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(t){super.removeInteractionGeometry(t),this.applySize({},t)}updateGeometryInteractions(t,e){super.updateGeometryInteractions(t,e),this.applySize({width:t.width,height:t.height},e);let i={...this.data.geometry,...t};this.localGeometry?.dispose(),this.localGeometry=hm(i,e,this.data.flatShading,this)}};Ni(),eb("UIGeometry",(t,e,i)=>new C4t(t,e,i)),lD=xdt={Scene2D:Rq,UICanvas:Lxt,loadHanaUIRUNTIME:function(){return V5||(V5=async()=>async function(t,e){return await t.default(e?{module_or_path:e}:void 0),Object.getOwnPropertyDescriptor(t.Engine.prototype,"scene")||Object.defineProperty(t.Engine.prototype,"scene",{get:function(){let i=Object.create(t.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>t.Engine.create(i,JSON.parse('{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}'),!0)}}(await Promise.resolve().then(()=>(a$(),n$)),adt??function(){let t=typeof process<"u"?"2.0.123":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),Ixt().then(()=>{})},setHanaUIWasmUrl:function(t){adt=t}},H4!==null&&xdt.setHanaUIWasmUrl(H4),Nr("ui-2d"),LW(),J0t(),ht();var Uxt,GF,E4t=class{constructor(){this.type="ShapePath",this.color=new ae,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Q2,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,s,n){return this.currentPath?.bezierCurveTo(t,e,i,r,s,n),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(h,u,d,c){let p=h.x,m=u.x,f=d.x,g=c.x,y=h.y,v=u.y,b=d.y,_=c.y,x=(g-f)*(y-b)-(_-b)*(p-f),S=(_-b)*(m-p)-(g-f)*(v-y),w=x/S,T=((m-p)*(y-b)-(v-y)*(p-f))/S;if(S===0&&x!==0||w<=0||w>=1||T<0||T>1)return null;if(x===0&&S===0){for(let C=0;C<2;C++){if(i(C===0?d:c,h,u),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(m-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let C=0;C<2;C++)if(i(C===0?d:c,h,u),t.loc===0){let M=C===0?d:c;return{x:M.x,y:M.y,t:t.t}}return{x:+(p+w*(m-p)).toPrecision(10),y:+(y+w*(v-y)).toPrecision(10),t:w}}function i(h,u,d){let c,p=d.x-u.x,m=d.y-u.y,f=h.x-u.x,g=h.y-u.y,y=p*g-f*m;return h.x===u.x&&h.y===u.y?(t.loc=0,void(t.t=0)):h.x===d.x&&h.y===d.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*f<0||m*g<0?t.loc=5:Math.sqrt(p*p+m*m)<Math.sqrt(f*f+g*g)?t.loc=6:(c=p!==0?f/p:g/m,t.loc=2,t.t=c))}let r=0,s=999999999,n=-999999999,a=[];this.subPaths.forEach(h=>{let u=h.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<u.length;f++){let g=u[f];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<m&&(m=g.x)}n<=p&&(n=p+1),s>=m&&(s=m-1),u.length&&a.push({curves:h.curves,points:u,isCW:eU.isClockWise(u),identifier:r++,boundingBox:new EG(new Z(m,c),new Z(p,d))})});let o=a.map(h=>function(u,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Z;u.boundingBox.getCenter(f);let g=function(S,w,T){let C=new Z;w.getCenter(C);let M=[];return T.forEach(A=>{A.boundingBox.containsPoint(C)&&function(R,I){let O=[],B=[];for(let V=1;V<R.length;V++){let z=R[V-1],k=R[V];for(let L=1;L<I.length;L++){let H=e(z,k,I[L-1],I[L]);H!==null&&O.find(W=>W.t<=H.t+Number.EPSILON&&W.t>=H.t-Number.EPSILON)===void 0&&(O.push(H),B.push(new Z(H.x,H.y)))}}return B}(S,A.points).forEach(R=>{M.push({identifier:A.identifier,isCW:A.isCW,point:R})})}),M.sort((A,R)=>A.point.x-R.point.x),M}([new Z(c,f.y),new Z(p,f.y)],u.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===u.identifier?y.push(S):v.push(S)});let b=y[0].point.x,_=[],x=0;for(;x<v.length&&v[x].point.x<b;)_.length>0&&_[_.length-1]===v[x].identifier?_.pop():_.push(v[x].identifier),x++;if(_.push(u.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:u.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let C=0;C<_.length;C++){let M=_[C];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:u.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(h,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(h=>{let u=o[h.identifier];if(u&&!u.isHole){let d=new OS;d.curves=h.curves,o.filter(c=>c?.isHole&&c.for===h.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new Q2;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},jxt=!1,wdt=new Promise(t=>{Uxt=t}),Sdt=!1;function Tdt(){if(jxt=!0,!Sdt)return GF||(GF=async function(){let t=await import("./opentype.js");Uxt(t),Sdt=!0}(),GF)}var P4t=new class{async load(t,e,i=()=>{}){let{load:r}=await wdt;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await wdt;try{let r=e(t),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};function R4t(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}ht(),dW(),Ni(),eb("TextGeometry",(t,e,i)=>new TD(t,e,i));var Mdt={create:(t,e)=>new Aj(t,e)};ij("TextGeometry",Mdt),ij("InputGeometry",Mdt),uW=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{this._layoutErrorWarned=!1;let e=await async function(i){let r,s,n=!1;if(i.url?(r=await async function(a){let o;try{o=await fetch(a)}catch(l){throw new Error(`could not fetch the font at ${a}: ${l}`)}if(!o.ok)throw new Error(`${o.status} ${o.statusText} fetching the font at ${a}`);return await o.arrayBuffer()}(i.url),s=i.url,n=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!jxt)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await P4t.parse(r);if(a)return{font:a.font,url:s,intercepted:n,arr:r,bidi:a.bidi}}}}(t);e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}warnLayoutError(t){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,t))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,u=String.fromCharCode(i[l].unicode),d=s[a];if(R4t(h,d)||o)n.push({char:u,index:h,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",m=[d.state.glyphIndex],f=[],g=!1;for(;!g;)a++,p=e.charAt(a),c+=p,m.push(t.charToGlyphIndex(p)),f=t.stringToGlyphs(c),f.length===1&&f[0].index===h&&(g=!0),a>e.length&&(g=!0);n.push({char:u,index:h,replacements:m,replacementChars:Array.from(c)}),a++}}return n}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,s=e.fontSize/this.unitsPerEm,n=e.fontSize*e.lineHeight,a=t.map(y=>this.getTextWidth(y,e)),o=typeof e.width=="string"?Number(i.getVariable(e.width)):e.width,l=typeof e.height=="string"?Number(i.getVariable(e.height)):e.height,h=this.getCharWidth(`
5103
5103
  `,e),u=e.horizontalAlign===1?h:0,d=this.getLineInitialOffsetX(a[0],o,e.horizontalAlign,t[0],h),c=this.getLineInitialOffsetY(n,t.length,l,s,e.verticalAlign),p=[],m=t.map(()=>[]),f=t.map(()=>[]);for(let y=0;y<t.length;y++){let v=t[y],b={features:{liga:!0},letterSpacing:e.letterSpacing},_=[];try{_=r.stringToGlyphs(v,b)}catch(C){this.warnLayoutError(C)}d=this.getLineInitialOffsetX(a[y],o,e.horizontalAlign,v,h);let x=[];try{x=this.reverseLigaturesTable(r,v,_)}catch(C){this.warnLayoutError(C)}let S=this.computeSpaceWidthForLine(t,y,e,i),w=0,T=_[0];T&&e.horizontalAlign===2&&T.leftSideBearing!==void 0&&(d-=T.leftSideBearing*s);try{this.font?.forEachGlyph(v,d,c,e.fontSize,b,(C,M,A,R,I)=>{let O=C.index===0?`
5104
5104
  `:C.unicode?String.fromCharCode(C.unicode):void 0,B=x[w],V=0;if(O===`
5105
5105
  `)V=u;else if(O===" ")V=S;else{let z=this.createPath(C,s,M,A,e);z&&(V=z.offsetX,p.push(z.path))}if(B&&B.replacements.length!==1){let z=B.replacements.map(W=>(r.glyphs.get(W).advanceWidth??0)*s),k=z.reduce((W,X)=>W+X,0),L=z.map(W=>W/k),H=M;for(let W=0;W<L.length;W++){let X=V*L[W];f[y].push([H,A]),m[y].push(X),H+=X}}else f[y].push([M,A]),m[y].push(V);w++})}catch(C){this.warnLayoutError(C)}c-=n}let g=[];for(let y=0,v=p.length;y<v;y++)g.push(...p[y].toShapes());return{shapes:g,charWidths:m,lineWidths:a,charCoords:f}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,i,r,s){return(i===3||i===2)&&r.indexOf(`
5106
- `)>=0&&(t-=s),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,r,s){let n=e*t,a=t-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return s===3?-(i-n-o):s===2?-(.5*i-.5*n-o):o}createPath(t,e,i,r,s){let n=t.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!n)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new E4t,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let h=a.currentPath?.currentPoint;if(!h||l.type==="Z"||h.x!==l.x||-h.y!==l.y)switch(l.type){case"M":a.moveTo(l.x,-l.y);break;case"L":a.lineTo(l.x,-l.y);break;case"Q":a.quadraticCurveTo(l.x1,-l.y1,l.x,-l.y);break;case"C":a.bezierCurveTo(l.x1,-l.y1,l.x2,-l.y2,l.x,-l.y)}}return a.subPaths.forEach(l=>{let h=function(u){if(u.length){let d=u[0];if(d instanceof ml)return d.v1;if(d instanceof Ql||d instanceof uc)return d.v0}}(l.curves);h!==void 0&&l.currentPoint.distanceTo(h)>0&&l.lineTo(h.x,h.y)}),{offsetX:o,path:a}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(t,e,i,r){let s=this.getCharWidth(" ",i),n=t[e];if(n){let a=this.countSpaces(n.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(n,i)-a*s))/a}return s}countSpaces(t){return(t.match(/ /g)||[]).length}},Nr("text"),Be();var Gxt=null;function Adt(){return Gxt}function D4t(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&s0.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ir();var YE=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},WF=t=>t*(Math.PI/180),KE=new Map,U5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.addEventListener?t.addEventListener(r,i,!1):t.attachEvent&&t.attachEvent(r,i)},j5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.removeEventListener?t.removeEventListener(r,i):t.detachEvent&&t.detachEvent(r,i)},Wxt=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),Cdt=()=>{if(!(typeof window>"u"))return{x:window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},qF=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},HF=(t,e,i)=>{let r=qxt(t);for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s))if(typeof e=="string")r[s]=e+" "+i;else{let n="";for(let a=0,o=e.length;a<o;a+=1)n+=e[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},qxt=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},$F=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},q7=(t,e)=>{if(t.length)for(let i=0,r=t.length;i<r;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(Hxt="ontouchstart"in window,$xt=!!window.PointerEvent,Xxt=!!window.MSPointerEvent);var Hxt,$xt,Xxt,e1,Edt={start:"mousedown",move:"mousemove",end:"mouseup"},Sw={};function bg(){}$xt?e1={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:Xxt?e1={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Hxt?(e1={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Sw=Edt):e1=Edt,bg.prototype.on=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(e);return r},bg.prototype.off=function(t,e){var i=this;return i._handlers_=i._handlers_||{},t===void 0?i._handlers_={}:e===void 0?i._handlers_[t]=null:i._handlers_[t]&&i._handlers_[t].indexOf(e)>=0&&i._handlers_[t].splice(i._handlers_[t].indexOf(e),1),i},bg.prototype.trigger=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},e)})},bg.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,r)=>{let s={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&Object.prototype.hasOwnProperty.call(r,n)?s[n]=r[n]:Object.prototype.hasOwnProperty.call(i,n)&&(s[n]=i[n]);return s})(e.options,t))},bg.prototype.bindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[e]=function(){typeof i["on"+e]=="function"?i["on"+e].apply(i,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},U5(t,e1[e],i._domHandlers_[e]),Sw[e]&&U5(t,Sw[e],i._domHandlers_[e]),i},bg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},j5(t,e1[e],i._domHandlers_[e]),Sw[e]&&j5(t,Sw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var Dq=bg;function Sn(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Sn.id,Sn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Sn.prototype=new Dq,Sn.constructor=Sn,Sn.id=0,Sn.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Sn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=qxt("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=HF("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},$F(r.el,i),this.options.shape==="circle"&&$F(r.back,e),$F(r.front,e),this.applyStyles(r),this},Sn.prototype.applyStyles=function(t){for(var e in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,e))for(var i in t[e])this.ui[e].style[i]=t[e][i];return this},Sn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Sn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Sn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null},Sn.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof t=="function"&&t.call(this)},e.options.fadeTime)),e},Sn.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var i=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=i,typeof t=="function"&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let i=e.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},Sn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var r=i.options.fadeTime+"ms",s={};s.front=HF("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Sn.prototype.restCallback=function(){var t=this,e={};e.front=HF("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Sn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Sn.prototype.computeDirection=function(t){var e,i,r,s=t.angle.radian,n=Math.PI/4,a=Math.PI/2;if(s>n&&s<3*n&&!t.lockX?e="up":s>-n&&s<=n&&!t.lockY?e="left":s>3*-n&&s<=-n&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=s>-a&&s<a?"left":"right"),t.lockX||(r=s>0?"up":"down"),t.force>this.options.threshold){var o,l={};for(o in this.direction)Object.prototype.hasOwnProperty.call(this.direction,o)&&(l[o]=this.direction[o]);var h={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(h[o]=!0);if(h.x&&h.y&&h.angle)return t;(!h.x||!h.y)&&this.trigger("plain",t),h.x||this.trigger("plain:"+i,t),h.y||this.trigger("plain:"+r,t),h.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var O4t=Sn;function Xs(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=Xs.id,Xs.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Xs.prototype=new Dq,Xs.constructor=Xs,Xs.id=0,Xs.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(i){if(i===void 0)return e[0];for(var r=0,s=e.length;r<s;r+=1)if(e[r].identifier===i)return e[r];return!1}},Xs.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},Xs.prototype.begin=function(){var t=this,e=t.options;if(e.mode==="static"){var i=t.createNipple(e.position,t.manager.getIdentifier());i.add(),t.idles.push(i)}},Xs.prototype.createNipple=function(t,e){var i=this,r=i.manager.scroll,s={},n=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(t.x&&t.y)s={x:t.x-a,y:t.y-o};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",n.zone.appendChild(l);var h=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:h.left+r.x,y:h.top+r.y}}var u=new O4t(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:e,position:t,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(qF(u.ui.el,s),qF(u.ui.front,u.frontPosition)),i.nipples.push(u),i.trigger("added "+u.identifier+":added",u),i.manager.trigger("added "+u.identifier+":added",u),i.bindNipple(u),u},Xs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},Xs.prototype.bindNipple=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},Xs.prototype.pressureFn=function(t,e,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==s&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),s=n)}.bind(r),100)},Xs.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=Wxt(t),e.updateBox(),q7(t,function(s){e.actives.length<i.maxNumberOfNipples?e.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(o){return o.identifier===n})<0){var a=[t[0]];a.identifier=n,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(s))}),e.manager.bindDocument(),!1},Xs.prototype.processOnStart=function(t){var e,i=this,r=i.options,s=i.manager.getIdentifier(t),n=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(s,a);o.identifier!==s&&i.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(h){h.trigger("start",h),i.trigger("start "+h.id+":start",h),h.show(),n>0&&i.pressureFn(t,h,h.identifier),i.processOnMove(t)};if((e=i.idles.indexOf(o))>=0&&i.idles.splice(e,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(YE(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},Xs.prototype.getOrCreate=function(t,e){var i,r=this,s=r.options;return/(semi|static)/.test(s.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):s.mode==="semi"?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(e,t)},Xs.prototype.processOnMove=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.scroll;if((b=>isNaN(b.buttons)?b.pressure!==0:b.buttons!==0)(t)){if(!s)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h,u,d=YE(l,s.position),c=((b,_)=>{let x=_.x-b.x,S=_.y-b.y;return(w=>w*(180/Math.PI))(Math.atan2(S,x))})(l,s.position),p=WF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(h=Math.min(d,o),u=((b,_,x)=>{let S={x:0,y:0};return x=WF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,h,c)):(u=((b,_,x)=>({x:Math.min(Math.max(b.x,_.x-x),_.x+x),y:Math.min(Math.max(b.y,_.y-x),_.y+x)}))(l,s.position,o),h=YE(u,s.position)),i.follow){if(d>o){let b=l.x-u.x,_=l.y-u.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(e.box.top+n.y)+"px",s.el.style.left=s.position.x-(e.box.left+n.x)+"px",d=YE(l,s.position)}}else l=u,d=h;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||qF(s.ui.front,s.frontPosition);var v={identifier:s.identifier,position:l,force:m,pressure:t.force||t.pressure||t.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-y/o},raw:f,instance:s,lockX:i.lockX,lockY:i.lockY};(v=s.computeDirection(v)).angle={radian:WF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},Xs.prototype.processOnEnd=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),e.trigger("removed "+s.id+":removed",s),e.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(e.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),e.trigger("end "+s.id+":end",s),e.ids.indexOf(s.identifier)>=0&&e.ids.splice(e.ids.indexOf(s.identifier),1),e.actives.indexOf(s)>=0&&e.actives.splice(e.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?e.idles.push(s):e.nipples.indexOf(s)>=0&&e.nipples.splice(e.nipples.indexOf(s),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[n.id]=n.identifier))},Xs.prototype.onDestroyed=function(t,e){var i=this;i.nipples.indexOf(e)>=0&&i.nipples.splice(i.nipples.indexOf(e),1),i.actives.indexOf(e)>=0&&i.actives.splice(i.actives.indexOf(e),1),i.idles.indexOf(e)>=0&&i.idles.splice(i.idles.indexOf(e),1),i.ids.indexOf(e.identifier)>=0&&i.ids.splice(i.ids.indexOf(e.identifier),1),i.manager.removeIdentifier(e.identifier),i.manager.unbindDocument()},Xs.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(i){i.destroy()}),t.pressureIntervals)Object.prototype.hasOwnProperty.call(t.pressureIntervals,e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off(),t.pressureIntervals={},t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.manager=null};var I4t=Xs;function an(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Cdt(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var r;e.collections.forEach(function(s){s.forEach(function(n){r=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+r.left,y:e.scroll.y+r.top}})})};return e._onResize=function(){(r=>{KE.has(r)&&clearTimeout(KE.get(r)),KE.set(r,setTimeout(function(){KE.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=Cdt()},e.collections}an.prototype=new Dq,an.constructor=an,an.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var i;return t.collections.every(function(r){return!(i=r.get(e))}),i}},an.prototype.create=function(t){return this.createCollection(t)},an.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,U5(window,"resize",t._onResize),U5(window,"scroll",t._onScroll))},an.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,j5(window,"resize",t._onResize),j5(window,"scroll",t._onScroll))},an.prototype.createCollection=function(t){var e=this,i=new I4t(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},an.prototype.bindCollection=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},an.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},an.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},an.prototype.getIdentifier=function(t){var e;return t?(e=t.identifier===void 0?t.pointerId:t.identifier)===void 0&&(e=this.latest||0):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},an.prototype.removeIdentifier=function(t){var e={};for(var i in this.ids)if(this.ids[i]===t){e.id=i,e.identifier=this.ids[i],delete this.ids[i];break}return e},an.prototype.onmove=function(t){return this.onAny("move",t),!1},an.prototype.onend=function(t){return this.onAny("end",t),!1},an.prototype.oncancel=function(t){return this.onAny("end",t),!1},an.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=Wxt(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return q7(e,function(a){i=r.getIdentifier(a),q7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},an.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.unbindWindowEvents(),t.ids={},t.index=0,t.collections.forEach(function(e){e.destroy()}),t.collections=[],t.off()},an.prototype.onDestroyed=function(t,e){var i=this;if(i.collections.indexOf(e)<0)return!1;i.collections.splice(i.collections.indexOf(e),1),i.collections.length===0&&i.unbindWindowEvents()};var N4t=an,Dv=null;function Pdt(){return Dv||(Dv=new N4t),Dv}var B4t={create:function(t){return Pdt().create(t)},destroy:function(){Dv&&(Dv.destroy(),Dv=null)},get factory(){return Pdt()}},k4t=B4t;ir(),Be(),ht(),Qh(),ib(),sh(),bo(),Be();var Yxt=null;function XF(){return Yxt}var Kxt,YF,V4t=new Promise(t=>{Kxt=t});function z4t(t){return YF||(YF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.121/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),Kxt(r)}(),YF)}function Zxt(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,r=e[4]**2+e[5]**2+e[6]**2,s=e[8]**2+e[9]**2+e[10]**2,n=e[0]**2+e[4]**2+e[8]**2,a=e[1]**2+e[5]**2+e[9]**2,o=e[2]**2+e[6]**2+e[10]**2,l=1e-8;return i<l||r<l||s<l||n<l||a<l||o<l}function hc(t,e){let i=new ye;if(e&&Zxt(e))return i.setAttribute("position",new ge([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new ge([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=xW(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new ge(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}ts(),bo(),Ni(),kW(),ht(),ht(),sb(),dT();var Vi,L4t=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=dn(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){sa(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>e.play()),this.actions.Animation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},Rdt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=dn(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.scene.findFrom(a,i);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(t){return this.target==="all"||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){sa(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};ts(),uT(),rD(),V4t.then(t=>Vi=t);var nn=new P,ql=new Te,KF=new P,F4t=new P(1,1,1),ZF=(new Fi(0,0,0,"YXZ"),new Fi(0,0,0,"XYZ")),Ud=new P,Ddt=new P,Tw=new Te,ZE=new xt,Odt=new xt,U4t={type:"updateMatrix"},QF=(new Te,new Jn),JF=.01,H7={type:"beginEvent",eventName:"Collision"},j4t={type:"beginEvent",eventName:"Trigger"},G5=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.shear!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function i1(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(lm(t)?t.object:t)}var G4t=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==Vi.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r]=this.rigidBodyToMesh.get(e.handle);if(nn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),ql.copy(e.rotation()),i.matrixWorld.makeRotationFromQuaternion(ql).setPosition(nn),i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(U4t),r){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let n of s.children)n.updateMatrixWorld(!0)}for(let n of i.children)n.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,r)=>{if(r===!1)return;let s,n;if(this.sensorToTriggerEvent[e]?(s=this.sensorToTriggerEvent[e],n=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],n=this.sharedGameControlGlobals.colliderToEntity.get(e)),s&&n&&s.isValidTriggeringObject(n))s.dispatch();else{for(let a=this.sharedGameControlGlobals.createdObjects.length-1;a>=0;a--){let o=this.sharedGameControlGlobals.createdObjects[a];if(o.userData.hasCollisionDestroy&&(o.rigidBody?.collider(0).handle===e||o.rigidBody?.collider(0).handle===i)){this.sharedGameControlGlobals.createdObjects.splice(a,1),o.removeFromParent();let l=o.rigidBody;requestAnimationFrame(()=>{o.rigidBody===l&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(l),o.rigidBody=void 0)});break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let a=this.sharedGameControlGlobals.colliderToEntity.get(i),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,i)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,e)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let u of o)u.data.target==="scene"&&this.dispatchCollisionEvent(u,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),h=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(h!==void 0)for(let u of h)u.data.target==="scene"&&this.dispatchCollisionEvent(u,l,i)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(r)for(let s of r.objects){let n=this.page.scene.find(s);n&&(n.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return e===void 0&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(XF()===null)return void On("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof xv,n=nS(i);if(om(i)||s||n)return;r=lm(i)?i.object:i;let a=r.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=r.userData.hasDestroy===!0,h=r.userData.hasDrag===!0;if(G5(a)||l||h||r.dataPatched.events.some(u=>u.data.disabled!==!0&&(u.data.type==="GameControl"||u.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let u=o.getAttribute("position");if(u!==void 0&&u.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(u),u.version,o.index!==null?this._staticBVHIdOf(o.index):-1,o.index!==null?o.index.version:-1);for(let d of i.matrixWorld.elements)e.push(d)}}return!!i1(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((n,a)=>n===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=Ig(t.map(n=>hc(n.geometry,n.matrixWorld)),!1),s=new(XF())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(Zxt(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(hc(s,t.shearScale)),n.physics.fusedBody){let a=this.gatherChildrenGeom(t,r);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&n.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&n.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Vi.RigidBodyDesc.dynamic(),a.setLinearDamping(n.physics.damping).setAngularDamping(n.physics.damping).setAdditionalMass(1e-9).setGravityScale(n.physics.gravityScale).enabledRotations(...n.physics.enabledRotation).enabledTranslations(...n.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Vi.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Vi.RigidBodyDesc.fixed();let h=Ig(r);nn.setFromMatrixPosition(t.matrixWorld),ql.setFromRotationMatrix(t.matrixWorldRigid),t.position0=nn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=ql.clone(),nn.divideScalar(this.pixelsPerMeter),a.setTranslation(nn.x,nn.y,nn.z).setRotation(ql),h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let u=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(n.geometry===void 0||n.geometry.type==="SubdivGeometry"||n.geometry.type==="NonParametricGeometry"||n.geometry.type==="BooleanGeometry"||n.geometry.type==="VectorGeometry"||n.geometry.type==="StarGeometry"||n.geometry.type==="RectangleGeometry"||n.geometry.type==="EllipseGeometry"||n.geometry.type==="TriangleGeometry"||n.geometry.type==="TorusGeometry"||n.geometry.type==="HelixGeometry");try{this.addCollider(u,n.physics,h,e,d)}catch{try{this.addCollider(u,n.physics,h,e,!1)}catch(c){console.error(c)}}if(u.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(u);l?this.rigidBodyToMesh.set(u.handle,[t,n.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,u,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=u}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(hc(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Ig(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(XF())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,r,s=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let n;i&&(n=e.colliderType==="trimesh"?Vi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Vi.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(Vi.CoefficientCombineRule.Average).setRestitutionCombineRule(Vi.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(n,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Vi.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=i1(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if(om(r)){if(!r.objectForSample)return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(r.objectForSample.dataPatched.physics.fusedBody)return;n=r.object}else if(lm(r))n=r.object;else if(n=r,n.dataPatched.cloner?.hideBase)return!0;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;s===1?r.matrixWorld.copy(t.shearScale):r.matrixWorld.copy(r.parent.matrixWorld),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(hc(o,r.matrixWorld)),!!i1(r)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(a=>{for(let o of a.dataPatched.events)if(o.data.disabled===!1&&o.data.type==="Trigger")return this.needsCollisionDetection=!0,!0});let r=Adt();if(r!==null?i=r.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&On("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:h,hoverRotatePanMode:u}=this.eventManager.publish.orbitControls;(a||o||l||h||u!==0)&&(this.orbitControls=new Ext(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let s=this.renderer.domElement.width/this.renderer.getPixelRatio(),n=this.renderer.domElement.height/this.renderer.getPixelRatio();Adt()?.createJoysticks(this,s,n),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Vi.World(new Vi.Vector3(0,this.gravity,0)),this.events=new Vi.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(om(a)){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(lm(a))o=a.object;else{if(nS(a)||n0(a)||a instanceof xv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,h=o.dataPatched;for(let g of h.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!h.physics||(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled))return!0;a.updateMatrixWorldRigid();let u=G5(h),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of h.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new L4t(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(v=>v.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){m=!0;let y=g.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=Vi.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(nn,ql,KF),a.position0=nn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=ql.clone(),nn.divideScalar(this.pixelsPerMeter),g.setTranslation(nn.x,nn.y,nn.z).setRotation(ql);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?Vi.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Vi.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Vi.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(Vi.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(0).setRestitutionCombineRule(Vi.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),nn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(KF.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(nn);let _=new Te().setFromEuler(new Fi().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(Vi.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else h.physics.rigidBody==="dynamic"||u||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,h.physics.fusedBody)):(f&&t.push(hc(f,a.matrixWorld)),h.physics.fusedBody&&!i1(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if(om(g)){if(!g.objectForSample)return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(g.objectForSample.dataPatched.physics.fusedBody)return;v=g.object}else{if(nS(g)||n0(g)||g instanceof xv)return;if(lm(g))v=g.object;else if(v=g,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;return _?.getAttribute("position")!==void 0&&t.push(hc(_,g.matrixWorld)),!!i1(g)||void 0}),this.generateSensorColliderDescs(o,h.physics.fusedBody,e));return!(h.physics?.fusedBody!==!0&&!l&&!i1(a))||void 0}),t.length===0)return;let i=Ig(t),r=i.getIndex().count>0;if(!r&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=Vi.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=Vi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Vi.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Vi.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,n)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,n);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let i=new Rdt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new xt().compose(Ud.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Tw.setFromEuler(ZF.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),F4t);if(e.data.triggerZone==="box"){let s=new cr;s.min.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):this.initializationCounter===2&&this.gameControl&&(e=!this.gameControl.update(t)&&e),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(t===0)e=this.stepPhysics()&&e;else{let r=t/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),n=0,a=6;for(;this.accumulator>=i&&n<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,n++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(nn,ql,KF);let e=t;e.prevQ===void 0?(e.prevQ=ql.clone(),e.prevT=nn.clone()):(e.prevQ.copy(ql),e.prevT.copy(nn))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,r]=this.fixedBodiesToWatch[t];e.rigidBody===i?(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(r)||(i.setBodyType(Vi.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1)):this.fixedBodiesToWatch.splice(t,1)}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(t===void 0)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),r=t.translation(),s=Math.hypot(i.x,i.z);for(let n=0;n<t.numColliders();n++){let a=t.collider(n);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let h=l.translation(),u=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(h.x-r.x)+v.y*(h.y-r.y)+v.z*(h.z-r.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let _=b*v.x,x=b*v.z,S=Math.hypot(_,x);if(S<1e-4)return;let w=(i.x*_+i.z*x)/S;w>u&&(u=w,d=_/S,c=x/S)}),u===-1/0)return;let p=i.x*d+i.z*c;if(p<-JF)return;let m=l.linvel();if(s>JF&&p>JF){let y=m.x*d+m.z*c;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:d*v,y:m.y,z:c*v},!0)}let f=m.x*d+m.z*c-Math.max(0,p);if(f<=0)return;let g=.5*f;l.setLinvel({x:m.x-d*g,y:m.y,z:m.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let t=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[e,i]of t)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(nn.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(ql)):t.delete(e);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)e.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let n of e.cloner.children)if(n.rigidBody===s){r=n;break}}t.dispatch(r),e.dispatchEvent(H7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=Odt.copy(t.matrixWorld).invert();t.traverseEntity((s,n)=>{if(e===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new Rdt(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Vi.ColliderDesc.cuboid(...a.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):Vi.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Vi.ActiveEvents.COLLISION_EVENTS),Ud.fromArray(a.data.position.map(h=>typeof h=="number"?h:0)),Tw.setFromEuler(ZF.fromArray(a.data.rotation.map(h=>typeof h=="number"?h:0))),ZE.makeRotationFromEuler(ZF).setPosition(Ud).premultiply(s.matrixWorld),i?(wc(ZE,{translation:Ud,quaternion:Tw,scale:Ddt}),o.setActiveCollisionTypes(Vi.ActiveCollisionTypes.KINEMATIC_FIXED|Vi.ActiveCollisionTypes.DYNAMIC_FIXED)):(wc(ZE.premultiply(r),{translation:Ud,quaternion:Tw,scale:Ddt}),t.rigidBody.bodyType()===Vi.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Vi.RigidBodyType.Fixed?o.setActiveCollisionTypes(Vi.ActiveCollisionTypes.KINEMATIC_FIXED|Vi.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Vi.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Vi.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ud.divideScalar(this.pixelsPerMeter),o.setTranslation(Ud.x,Ud.y,Ud.z),o.setRotation(Tw),i)i.push([o,l]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[h.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(xi.is(o)?o:o.object)===!1)continue;let l=Odt.copy($ft(s.matrixWorld)).copyPosition(s.matrixWorld).multiply(r),h=ZE.copy(o.matrixWorld).invert().multiply(l),u=o.bvhGeometry.boundsTree;i instanceof cr?t=u.intersectsBox(i,h):(QF.radius=i,QF.center.setFromMatrixPosition(h),t=u.intersectsSphere(QF)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(j4t)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};ab(),ht(),Y4(),Ui(),uT(),Rm();var t8=.02,Idt=new P,Ndt=new P,W4t=new P,Wa=new P,jd=new P,r1=new P,e8=new xt,Bdt=new xt,q4t=new xt,ol=new Te,tg=new Te,s1=new Fi(0,0,0,"YXZ"),H4t=new P(1,0,0),Eu=new P(0,1,0),$4t=new P(0,0,1),kdt=new P(1,1,1),Vdt=[],zdt=t=>Vdt[t]??(Vdt[t]=new P),i8=new P,X4t=new P,Y4t=new P,K4t=new P,Ldt=new Te,Z4t=new P,Fdt=new Te,Hn=new bl,Hl=new cr,Q4t={type:"requestRender"},J4t={type:"updateMatrix"},$7=class extends En{constructor(t,e,i,r,s,n,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.target0=new P,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Fi(0,0,0,"YXZ"),this.shearMatrix0=new xt,this.cameraShearMatrix0=new xt,this.position0Cam=new P,this.quat0Cam=new Te,this.scale0Cam=new P,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new bl(new P(0,-40,0),new P(0,40,0)),matrix:new xt,position:new P,rotation:new Te},this.euler=new Fi(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Te,this.lastCameraPosition=new P,this.PI_2=Math.PI/2,this.prevMouse=new Z,this.velocityTarget=new P,this.velocity=new P,this.directionXZ=new P,this.rotVelocityStick=new P,this.rotVelocityTarget=new P,this.rotVelocity=new P,this.rotDirection=new P,this.nonColliderRotOffset=new xt,this.nonColliderPosOffset=new xt,this.firstPointerId=-1,this.rot=new P,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new xt,this.objectToTarget=new P,this.objectToTarget0=new P,this.objectToCamXZ=new P,this.objectToCamXZ0=new P,this.targetToCamera=new P,this.targetToCamera0=new P,this.cameraPolarAxis0=new P,this.targetPos=new P,this.targetQuat=new Te,this.lerpFactorPos=new P().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Te,this.objXZQuatInv=new Te,this.objXZRotMat=new xt,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Te,this.colliderWorldQuat=new Te,this.groundNormal=new P,this.groundTilt=new Te,this.groundTiltInv=new Te,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Te,this.scale=new P,this.initialAction=!0,this.onPointerDown=m=>{!(m.target===this.domElement||m.target instanceof HTMLElement&&m.target.tagName==="SPLINE-VIEWER"&&m.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Uo&&!cU&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let f=m.clientX-this.prevMouse.x,g=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(cU&&Jmt<15.5&&!Uo?(this.eulerDelta.y=-f*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-f*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?$7.isLocked=!0:$7.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let m in this.movementState)this.movementState[m]=0},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]){this.movementState[f[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=m=>{for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]||m.code.slice(3,m.code.length).toUpperCase()===f[1]){this.movementState[f[0]]=0;break}},this.copyVRGamePadValues=(m,f)=>{for(let g=2;g<4;g++){let y=m.axes[g];f===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,t===a&&(this.isFirstPerson=!0),this.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),this.shearMatrix0.copy(this.object.shearMatrix),wc(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix}),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),this.cameraShearMatrix0.copy(this.camera.shearMatrix),wc(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix})),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m,f=new P(0,0,-1).applyQuaternion(this.camera.quaternion),g=new P().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(f.y)<1e-6?(g.y=0,f.y=0,m=g.projectOnVector(f)):m=g.y/f.y>0?f.multiplyScalar(g.y/f.y):f.multiplyScalar(g.length()),this.targetToCamera0.copy(m).negate();let y=this.camera.position.clone().add(m);this.objectToTarget0.subVectors(y,this.position);let v=new Fi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof Us&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(m=>{let f=[m[0],m[1]];return f[1]==="\u25B2"?f[1]="ArrowUp":f[1]==="\u25C0"?f[1]="ArrowLeft":f[1]==="\u25BC"?f[1]="ArrowDown":f[1]==="\u25B6"?f[1]="ArrowRight":f[1]==="\u21E7"?f[1]="Shift":f[1]==="\u21B5"?f[1]="Enter":f[1]==="Space"?f[1]=" ":f[1]==="\u2318"?f[1]="Meta":f[1]==="Ctrl"?f[1]="Control":f[1]==="Esc"&&(f[1]="Escape"),f}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(f=>f[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??mv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??mv.defaultData.usePhysics,this.jumpPower=20*i.jumpPower,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??G4.defaultDataThirdPerson.orientWith,this.slopeThresh=65*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*t8/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*t8/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*t8/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new P().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new Te().setFromEuler(new Fi().fromArray([...i.collider.rotation.map(m=>typeof m=="number"?m:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,kdt),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let m=new ce;m.push({fi:0,data:{...Bs.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Bs.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=lyt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new yr(cW.create({parameters:{width:p,height:p/10,hollow:.7}}),f),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(t=!1){if(this.object.matrixWorldAutoUpdate=!0,this.camera.matrixWorldAutoUpdate=!0,this.object.shearMatrix.copy(this.shearMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),wc(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix});let e=new Fi().setFromQuaternion(this.quaternion,"YXZ"),i=e.y;this.objectRealQuat.copy(this.quaternion),e.y=0,this.quaternion.setFromEuler(e),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),e.set(0,i,0),this.quaternion.setFromEuler(e),this.rot.setFromEuler(e),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Us?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.shearMatrix.copy(this.cameraShearMatrix0),t?(this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),wc(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix}))):this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let t=this.data,e=this.sharedAssets;t.gameActions!==void 0&&(this.actions={},j4.list.forEach(i=>{this.actions[i]=dn({...t,disabled:!1,type:"GameControl"},t.gameActions[i],this.page,e,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),sa(this.actions.idle),sa(this.actions.move),sa(this.actions.run),sa(this.actions.jump)}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].Transition.forEach(e=>{e.play()}),this.actions[t].Animation.forEach(e=>{e.play(this.initialAction===!1)}),this.actions[t].TimelineAnimation.forEach(e=>{e.play()}),this.actions[t].Create.forEach(e=>{e.dispatchStart()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("start")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].Transition.forEach(e=>{e.stop(),e.object.currentState!==null&&e.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[t].TimelineAnimation.forEach(e=>{e.stop()}),this.actions[t].Create.forEach(e=>{e.dispatchStop()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("stop")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Wa.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(t){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let e=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*e,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let n=jd.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*e,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(r=!0),a.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let o=a.collider.parent(),l=o!==null&&o.isKinematic()?o:null,h=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&h?.userData.isFollowingObj!==this.object.uuid){let u=this.object.getWorldPosition(Wa).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(u);this.groundVelocity.set(d.x,d.y,d.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=l.angvel().y*e}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let n=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=Wa.subVectors(this.path[1],this.position),o=jd.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),n.opacity=n.userData.opacity0}else n.opacity-=.05*n.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let s=W4t.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=jd.copy(s);n.y=0,s.set(0,s.y,n.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let n=Wa;this.camera.getWorldDirection(n);let a=r1.copy(Eu).multiplyScalar(n.dot(Eu));n.sub(a);let o=jd.copy(this.directionXZ);o.x*=-1,this.rot.y=n.angleTo(o)*(n.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(s1.setFromVector3(this.rot),this.moveMode==="walk"&&(s1.x=0),s.applyEuler(s1),r&&(tg.setFromUnitVectors(Eu,this.groundNormal),s.applyQuaternion(tg)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let n=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(i8,Ldt,X4t);let o=this.object.getWorldPosition(Y4t).add(this.collider.position).sub(i8);Fdt.copy(a.prevQ).invert().premultiply(Ldt);let l=r1.subVectors(i8,a.prevT).add(K4t.copy(o).applyQuaternion(Fdt).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),h=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Wa.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let u=xi.is(a)?a:a.object;if(h!==null&&this.lastHitObj!==u){let d;a instanceof Ja&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),u.dispatchEvent(H7));this.lastHitObj=u}h!==null&&(Math.abs(l.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=l.x),Math.abs(l.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=l.y),Math.abs(l.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=l.z),zdt(n++).copy(h.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=zdt(a),l=o.dot(s);l<0&&s.addScaledVector(o,-l)}s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(e),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*e,this.euler.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*e),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Eu,this.euler.y-this.euler0.y);let n=jd.copy(this.objectToCamXZ).normalize(),a=r1.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(Wa.copy(n).multiplyScalar(a.dot(n))).cross(n).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Ft.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Ft.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Ft.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(s1.copy(this.euler),s1.y=0,this.nonColliderRotOffset.makeRotationFromEuler(s1)),ol.setFromAxisAngle(H4t,this.rot.x),tg.setFromAxisAngle(Eu,this.rot.y),tg.multiply(ol),ol.setFromAxisAngle($4t,this.rot.z),tg.multiply(ol),this.quaternion.copy(tg),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let n=jd.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let u=0;u<5;u++){let d=n.length(),c=r1.copy(n).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,c,this.object.rigidBody.collider(0).shape,0,d,!1,12,void 0,void 0,this.object.rigidBody),a===null){u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(n);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let v of y)if(v.data.target==="character"){let b,_=(this.sharedGameControlGlobals.rapierWorld?.getCollider(a.collider.handle))._parent;if(p.cloner){for(let x of p.cloner.children)if(x.rigidBody===_){b=x;break}}v.dispatch(b),p.dispatchEvent(H7)}}}let m=Idt.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=Ndt.copy(c).multiplyScalar(a.time_of_impact).dot(m),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),f>this.offset&&(g=a.time_of_impact*(f-this.offset)/f,o.addScaledVector(c,g)),n.copy(c).multiplyScalar(d-g),Math.acos(-m.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=r1.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let b=y.add(v);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);_!==null&&_.time_of_impact===0&&(m.y=0,m.normalize())}n.addScaledVector(m,-n.dot(m))}}this.position.addScaledVector(o,this.pixelsPerMeter),Wa.copy(this.position).divideScalar(this.pixelsPerMeter),ol.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,h=l!==void 0&&Z4t.copy(Wa).sub(l.translation()).lengthSq()>1;l!==void 0&&(h?(l.setTranslation(Wa,!0),l.setRotation(ol,!0)):(l.setNextKinematicTranslation(Wa),l.setNextKinematicRotation(ol)))}else{let n=this.onObject?1:5,a=s.multiplyScalar(e/n);for(let o=0;o<n;o++)this.position.add(a),this.collisionAdjustment(e/n)}else this.position.addScaledVector(s,e);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),Bgt(this.position,this.quaternion,this.object.shearMatrix,this.scale,this.object.matrix).multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.parent instanceof Or?this.object.matrixWorld.multiplyMatrices(this.object.parent.matrixWorld,this.object.matrix).multiply(this.object.pivotMatrix):this.object.matrixWorld.copy(this.object.matrix),this.object.children.forEach(n=>{n.updateMatrixWorld(!0)}),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let n=this.objectToTarget.add(this.position),a=this.targetToCamera.add(n);e8.lookAt(a,n,Eu).setPosition(a),e8.decompose(this.targetPos,this.targetQuat,Wa),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.matrixWorld.copy(this.camera.matrix),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Ft.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Ft.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(J4t),!(this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)||(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Q4t),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=ol.setFromAxisAngle(Eu,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Ft.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e),t=this.cameraXAxis==="Limit"?Ft.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):Ft.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Wa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=tg.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Eu.angleTo(t)/Math.PI<15||180*Eu.angleTo(t)/Math.PI>85?ol.identity():ol.setFromUnitVectors(Eu,t),this.groundTilt.slerp(ol,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=Ndt.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=e8.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Wa,ol,jd).compose(Wa,ol,kdt);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;Hl.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=Bdt.copy(n).invert(),o=q4t.copy(Bdt).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=Idt.copy(this.position).applyMatrix4(a);Hl.expandByPoint(Hn.start),Hl.expandByPoint(Hn.end),Hl.min.addScalar(-this.collider.radius),Hl.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:h=>h.distanceToPoint(Hn.end),intersectsBounds:h=>h.intersectsBox(Hl),intersectsTriangle:h=>{let u=Wa,d=jd,c=h.closestPointToSegment(Hn,u,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(u).normalize(),f=r1.copy(l);f.addScaledVector(m,p);let g=f.applyMatrix4(n).sub(this.position);e.add(g),Hn.start.addScaledVector(m,p),Hn.end.addScaledVector(m,p)}}})}),Hl.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),Hl.expandByPoint(Hn.start),Hl.expandByPoint(Hn.end),Hl.min.addScalar(-this.collider.radius),Hl.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(Hl),intersectsTriangle:s=>{let n=Wa,a=jd,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),e.addScaledVector(h,l),Hn.start.addScaledVector(h,l),Hn.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(r),this.position.add(e)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},Qxt=$7;Qxt.isLocked=!1,ht(),dT(),MD(),ab(),sb();var Jxt,twt,r8,t5t=new Promise(t=>{Jxt=t});function e5t(t){return r8||(r8=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.121/build";typeof window<"u"&&(twt=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});Jxt(a)}(),r8)}ir();var ewt,Oi,ba,i5t=t=>`
5106
+ `)>=0&&(t-=s),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,r,s){let n=e*t,a=t-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return s===3?-(i-n-o):s===2?-(.5*i-.5*n-o):o}createPath(t,e,i,r,s){let n=t.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!n)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new E4t,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let h=a.currentPath?.currentPoint;if(!h||l.type==="Z"||h.x!==l.x||-h.y!==l.y)switch(l.type){case"M":a.moveTo(l.x,-l.y);break;case"L":a.lineTo(l.x,-l.y);break;case"Q":a.quadraticCurveTo(l.x1,-l.y1,l.x,-l.y);break;case"C":a.bezierCurveTo(l.x1,-l.y1,l.x2,-l.y2,l.x,-l.y)}}return a.subPaths.forEach(l=>{let h=function(u){if(u.length){let d=u[0];if(d instanceof ml)return d.v1;if(d instanceof Ql||d instanceof uc)return d.v0}}(l.curves);h!==void 0&&l.currentPoint.distanceTo(h)>0&&l.lineTo(h.x,h.y)}),{offsetX:o,path:a}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(t,e,i,r){let s=this.getCharWidth(" ",i),n=t[e];if(n){let a=this.countSpaces(n.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(n,i)-a*s))/a}return s}countSpaces(t){return(t.match(/ /g)||[]).length}},Nr("text"),Be();var Gxt=null;function Adt(){return Gxt}function D4t(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&s0.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ir();var YE=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},WF=t=>t*(Math.PI/180),KE=new Map,U5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.addEventListener?t.addEventListener(r,i,!1):t.attachEvent&&t.attachEvent(r,i)},j5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.removeEventListener?t.removeEventListener(r,i):t.detachEvent&&t.detachEvent(r,i)},Wxt=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),Cdt=()=>{if(!(typeof window>"u"))return{x:window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},qF=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},HF=(t,e,i)=>{let r=qxt(t);for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s))if(typeof e=="string")r[s]=e+" "+i;else{let n="";for(let a=0,o=e.length;a<o;a+=1)n+=e[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},qxt=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},$F=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},q7=(t,e)=>{if(t.length)for(let i=0,r=t.length;i<r;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(Hxt="ontouchstart"in window,$xt=!!window.PointerEvent,Xxt=!!window.MSPointerEvent);var Hxt,$xt,Xxt,e1,Edt={start:"mousedown",move:"mousemove",end:"mouseup"},Sw={};function bg(){}$xt?e1={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:Xxt?e1={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Hxt?(e1={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Sw=Edt):e1=Edt,bg.prototype.on=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(e);return r},bg.prototype.off=function(t,e){var i=this;return i._handlers_=i._handlers_||{},t===void 0?i._handlers_={}:e===void 0?i._handlers_[t]=null:i._handlers_[t]&&i._handlers_[t].indexOf(e)>=0&&i._handlers_[t].splice(i._handlers_[t].indexOf(e),1),i},bg.prototype.trigger=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},e)})},bg.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,r)=>{let s={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&Object.prototype.hasOwnProperty.call(r,n)?s[n]=r[n]:Object.prototype.hasOwnProperty.call(i,n)&&(s[n]=i[n]);return s})(e.options,t))},bg.prototype.bindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[e]=function(){typeof i["on"+e]=="function"?i["on"+e].apply(i,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},U5(t,e1[e],i._domHandlers_[e]),Sw[e]&&U5(t,Sw[e],i._domHandlers_[e]),i},bg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},j5(t,e1[e],i._domHandlers_[e]),Sw[e]&&j5(t,Sw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var Dq=bg;function Sn(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Sn.id,Sn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Sn.prototype=new Dq,Sn.constructor=Sn,Sn.id=0,Sn.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Sn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=qxt("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=HF("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},$F(r.el,i),this.options.shape==="circle"&&$F(r.back,e),$F(r.front,e),this.applyStyles(r),this},Sn.prototype.applyStyles=function(t){for(var e in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,e))for(var i in t[e])this.ui[e].style[i]=t[e][i];return this},Sn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Sn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Sn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null},Sn.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof t=="function"&&t.call(this)},e.options.fadeTime)),e},Sn.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var i=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=i,typeof t=="function"&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let i=e.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},Sn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var r=i.options.fadeTime+"ms",s={};s.front=HF("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Sn.prototype.restCallback=function(){var t=this,e={};e.front=HF("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Sn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Sn.prototype.computeDirection=function(t){var e,i,r,s=t.angle.radian,n=Math.PI/4,a=Math.PI/2;if(s>n&&s<3*n&&!t.lockX?e="up":s>-n&&s<=n&&!t.lockY?e="left":s>3*-n&&s<=-n&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=s>-a&&s<a?"left":"right"),t.lockX||(r=s>0?"up":"down"),t.force>this.options.threshold){var o,l={};for(o in this.direction)Object.prototype.hasOwnProperty.call(this.direction,o)&&(l[o]=this.direction[o]);var h={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(h[o]=!0);if(h.x&&h.y&&h.angle)return t;(!h.x||!h.y)&&this.trigger("plain",t),h.x||this.trigger("plain:"+i,t),h.y||this.trigger("plain:"+r,t),h.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var O4t=Sn;function Xs(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=Xs.id,Xs.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Xs.prototype=new Dq,Xs.constructor=Xs,Xs.id=0,Xs.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(i){if(i===void 0)return e[0];for(var r=0,s=e.length;r<s;r+=1)if(e[r].identifier===i)return e[r];return!1}},Xs.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},Xs.prototype.begin=function(){var t=this,e=t.options;if(e.mode==="static"){var i=t.createNipple(e.position,t.manager.getIdentifier());i.add(),t.idles.push(i)}},Xs.prototype.createNipple=function(t,e){var i=this,r=i.manager.scroll,s={},n=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(t.x&&t.y)s={x:t.x-a,y:t.y-o};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",n.zone.appendChild(l);var h=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:h.left+r.x,y:h.top+r.y}}var u=new O4t(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:e,position:t,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(qF(u.ui.el,s),qF(u.ui.front,u.frontPosition)),i.nipples.push(u),i.trigger("added "+u.identifier+":added",u),i.manager.trigger("added "+u.identifier+":added",u),i.bindNipple(u),u},Xs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},Xs.prototype.bindNipple=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},Xs.prototype.pressureFn=function(t,e,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==s&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),s=n)}.bind(r),100)},Xs.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=Wxt(t),e.updateBox(),q7(t,function(s){e.actives.length<i.maxNumberOfNipples?e.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(o){return o.identifier===n})<0){var a=[t[0]];a.identifier=n,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(s))}),e.manager.bindDocument(),!1},Xs.prototype.processOnStart=function(t){var e,i=this,r=i.options,s=i.manager.getIdentifier(t),n=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(s,a);o.identifier!==s&&i.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(h){h.trigger("start",h),i.trigger("start "+h.id+":start",h),h.show(),n>0&&i.pressureFn(t,h,h.identifier),i.processOnMove(t)};if((e=i.idles.indexOf(o))>=0&&i.idles.splice(e,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(YE(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},Xs.prototype.getOrCreate=function(t,e){var i,r=this,s=r.options;return/(semi|static)/.test(s.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):s.mode==="semi"?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(e,t)},Xs.prototype.processOnMove=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.scroll;if((b=>isNaN(b.buttons)?b.pressure!==0:b.buttons!==0)(t)){if(!s)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h,u,d=YE(l,s.position),c=((b,_)=>{let x=_.x-b.x,S=_.y-b.y;return(w=>w*(180/Math.PI))(Math.atan2(S,x))})(l,s.position),p=WF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(h=Math.min(d,o),u=((b,_,x)=>{let S={x:0,y:0};return x=WF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,h,c)):(u=((b,_,x)=>({x:Math.min(Math.max(b.x,_.x-x),_.x+x),y:Math.min(Math.max(b.y,_.y-x),_.y+x)}))(l,s.position,o),h=YE(u,s.position)),i.follow){if(d>o){let b=l.x-u.x,_=l.y-u.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(e.box.top+n.y)+"px",s.el.style.left=s.position.x-(e.box.left+n.x)+"px",d=YE(l,s.position)}}else l=u,d=h;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||qF(s.ui.front,s.frontPosition);var v={identifier:s.identifier,position:l,force:m,pressure:t.force||t.pressure||t.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-y/o},raw:f,instance:s,lockX:i.lockX,lockY:i.lockY};(v=s.computeDirection(v)).angle={radian:WF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},Xs.prototype.processOnEnd=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),e.trigger("removed "+s.id+":removed",s),e.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(e.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),e.trigger("end "+s.id+":end",s),e.ids.indexOf(s.identifier)>=0&&e.ids.splice(e.ids.indexOf(s.identifier),1),e.actives.indexOf(s)>=0&&e.actives.splice(e.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?e.idles.push(s):e.nipples.indexOf(s)>=0&&e.nipples.splice(e.nipples.indexOf(s),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[n.id]=n.identifier))},Xs.prototype.onDestroyed=function(t,e){var i=this;i.nipples.indexOf(e)>=0&&i.nipples.splice(i.nipples.indexOf(e),1),i.actives.indexOf(e)>=0&&i.actives.splice(i.actives.indexOf(e),1),i.idles.indexOf(e)>=0&&i.idles.splice(i.idles.indexOf(e),1),i.ids.indexOf(e.identifier)>=0&&i.ids.splice(i.ids.indexOf(e.identifier),1),i.manager.removeIdentifier(e.identifier),i.manager.unbindDocument()},Xs.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(i){i.destroy()}),t.pressureIntervals)Object.prototype.hasOwnProperty.call(t.pressureIntervals,e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off(),t.pressureIntervals={},t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.manager=null};var I4t=Xs;function an(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Cdt(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var r;e.collections.forEach(function(s){s.forEach(function(n){r=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+r.left,y:e.scroll.y+r.top}})})};return e._onResize=function(){(r=>{KE.has(r)&&clearTimeout(KE.get(r)),KE.set(r,setTimeout(function(){KE.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=Cdt()},e.collections}an.prototype=new Dq,an.constructor=an,an.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var i;return t.collections.every(function(r){return!(i=r.get(e))}),i}},an.prototype.create=function(t){return this.createCollection(t)},an.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,U5(window,"resize",t._onResize),U5(window,"scroll",t._onScroll))},an.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,j5(window,"resize",t._onResize),j5(window,"scroll",t._onScroll))},an.prototype.createCollection=function(t){var e=this,i=new I4t(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},an.prototype.bindCollection=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},an.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},an.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},an.prototype.getIdentifier=function(t){var e;return t?(e=t.identifier===void 0?t.pointerId:t.identifier)===void 0&&(e=this.latest||0):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},an.prototype.removeIdentifier=function(t){var e={};for(var i in this.ids)if(this.ids[i]===t){e.id=i,e.identifier=this.ids[i],delete this.ids[i];break}return e},an.prototype.onmove=function(t){return this.onAny("move",t),!1},an.prototype.onend=function(t){return this.onAny("end",t),!1},an.prototype.oncancel=function(t){return this.onAny("end",t),!1},an.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=Wxt(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return q7(e,function(a){i=r.getIdentifier(a),q7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},an.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.unbindWindowEvents(),t.ids={},t.index=0,t.collections.forEach(function(e){e.destroy()}),t.collections=[],t.off()},an.prototype.onDestroyed=function(t,e){var i=this;if(i.collections.indexOf(e)<0)return!1;i.collections.splice(i.collections.indexOf(e),1),i.collections.length===0&&i.unbindWindowEvents()};var N4t=an,Dv=null;function Pdt(){return Dv||(Dv=new N4t),Dv}var B4t={create:function(t){return Pdt().create(t)},destroy:function(){Dv&&(Dv.destroy(),Dv=null)},get factory(){return Pdt()}},k4t=B4t;ir(),Be(),ht(),Qh(),ib(),sh(),bo(),Be();var Yxt=null;function XF(){return Yxt}var Kxt,YF,V4t=new Promise(t=>{Kxt=t});function z4t(t){return YF||(YF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.123/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),Kxt(r)}(),YF)}function Zxt(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,r=e[4]**2+e[5]**2+e[6]**2,s=e[8]**2+e[9]**2+e[10]**2,n=e[0]**2+e[4]**2+e[8]**2,a=e[1]**2+e[5]**2+e[9]**2,o=e[2]**2+e[6]**2+e[10]**2,l=1e-8;return i<l||r<l||s<l||n<l||a<l||o<l}function hc(t,e){let i=new ye;if(e&&Zxt(e))return i.setAttribute("position",new ge([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new ge([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=xW(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new ge(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}ts(),bo(),Ni(),kW(),ht(),ht(),sb(),dT();var Vi,L4t=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=dn(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){sa(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>e.play()),this.actions.Animation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},Rdt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=dn(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.scene.findFrom(a,i);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(t){return this.target==="all"||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){sa(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};ts(),uT(),rD(),V4t.then(t=>Vi=t);var nn=new P,ql=new Te,KF=new P,F4t=new P(1,1,1),ZF=(new Fi(0,0,0,"YXZ"),new Fi(0,0,0,"XYZ")),Ud=new P,Ddt=new P,Tw=new Te,ZE=new xt,Odt=new xt,U4t={type:"updateMatrix"},QF=(new Te,new Jn),JF=.01,H7={type:"beginEvent",eventName:"Collision"},j4t={type:"beginEvent",eventName:"Trigger"},G5=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.shear!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function i1(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(lm(t)?t.object:t)}var G4t=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==Vi.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r]=this.rigidBodyToMesh.get(e.handle);if(nn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),ql.copy(e.rotation()),i.matrixWorld.makeRotationFromQuaternion(ql).setPosition(nn),i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(U4t),r){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let n of s.children)n.updateMatrixWorld(!0)}for(let n of i.children)n.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,r)=>{if(r===!1)return;let s,n;if(this.sensorToTriggerEvent[e]?(s=this.sensorToTriggerEvent[e],n=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],n=this.sharedGameControlGlobals.colliderToEntity.get(e)),s&&n&&s.isValidTriggeringObject(n))s.dispatch();else{for(let a=this.sharedGameControlGlobals.createdObjects.length-1;a>=0;a--){let o=this.sharedGameControlGlobals.createdObjects[a];if(o.userData.hasCollisionDestroy&&(o.rigidBody?.collider(0).handle===e||o.rigidBody?.collider(0).handle===i)){this.sharedGameControlGlobals.createdObjects.splice(a,1),o.removeFromParent();let l=o.rigidBody;requestAnimationFrame(()=>{o.rigidBody===l&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(l),o.rigidBody=void 0)});break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let a=this.sharedGameControlGlobals.colliderToEntity.get(i),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,i)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,e)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let u of o)u.data.target==="scene"&&this.dispatchCollisionEvent(u,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),h=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(h!==void 0)for(let u of h)u.data.target==="scene"&&this.dispatchCollisionEvent(u,l,i)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(r)for(let s of r.objects){let n=this.page.scene.find(s);n&&(n.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return e===void 0&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(XF()===null)return void On("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof xv,n=nS(i);if(om(i)||s||n)return;r=lm(i)?i.object:i;let a=r.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=r.userData.hasDestroy===!0,h=r.userData.hasDrag===!0;if(G5(a)||l||h||r.dataPatched.events.some(u=>u.data.disabled!==!0&&(u.data.type==="GameControl"||u.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let u=o.getAttribute("position");if(u!==void 0&&u.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(u),u.version,o.index!==null?this._staticBVHIdOf(o.index):-1,o.index!==null?o.index.version:-1);for(let d of i.matrixWorld.elements)e.push(d)}}return!!i1(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((n,a)=>n===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=Ig(t.map(n=>hc(n.geometry,n.matrixWorld)),!1),s=new(XF())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(Zxt(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(hc(s,t.shearScale)),n.physics.fusedBody){let a=this.gatherChildrenGeom(t,r);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&n.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&n.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Vi.RigidBodyDesc.dynamic(),a.setLinearDamping(n.physics.damping).setAngularDamping(n.physics.damping).setAdditionalMass(1e-9).setGravityScale(n.physics.gravityScale).enabledRotations(...n.physics.enabledRotation).enabledTranslations(...n.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Vi.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Vi.RigidBodyDesc.fixed();let h=Ig(r);nn.setFromMatrixPosition(t.matrixWorld),ql.setFromRotationMatrix(t.matrixWorldRigid),t.position0=nn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=ql.clone(),nn.divideScalar(this.pixelsPerMeter),a.setTranslation(nn.x,nn.y,nn.z).setRotation(ql),h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let u=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(n.geometry===void 0||n.geometry.type==="SubdivGeometry"||n.geometry.type==="NonParametricGeometry"||n.geometry.type==="BooleanGeometry"||n.geometry.type==="VectorGeometry"||n.geometry.type==="StarGeometry"||n.geometry.type==="RectangleGeometry"||n.geometry.type==="EllipseGeometry"||n.geometry.type==="TriangleGeometry"||n.geometry.type==="TorusGeometry"||n.geometry.type==="HelixGeometry");try{this.addCollider(u,n.physics,h,e,d)}catch{try{this.addCollider(u,n.physics,h,e,!1)}catch(c){console.error(c)}}if(u.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(u);l?this.rigidBodyToMesh.set(u.handle,[t,n.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,u,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=u}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(hc(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Ig(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(XF())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,r,s=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let n;i&&(n=e.colliderType==="trimesh"?Vi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Vi.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(Vi.CoefficientCombineRule.Average).setRestitutionCombineRule(Vi.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(n,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Vi.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=i1(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if(om(r)){if(!r.objectForSample)return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(r.objectForSample.dataPatched.physics.fusedBody)return;n=r.object}else if(lm(r))n=r.object;else if(n=r,n.dataPatched.cloner?.hideBase)return!0;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;s===1?r.matrixWorld.copy(t.shearScale):r.matrixWorld.copy(r.parent.matrixWorld),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(hc(o,r.matrixWorld)),!!i1(r)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(a=>{for(let o of a.dataPatched.events)if(o.data.disabled===!1&&o.data.type==="Trigger")return this.needsCollisionDetection=!0,!0});let r=Adt();if(r!==null?i=r.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&On("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:h,hoverRotatePanMode:u}=this.eventManager.publish.orbitControls;(a||o||l||h||u!==0)&&(this.orbitControls=new Ext(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let s=this.renderer.domElement.width/this.renderer.getPixelRatio(),n=this.renderer.domElement.height/this.renderer.getPixelRatio();Adt()?.createJoysticks(this,s,n),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Vi.World(new Vi.Vector3(0,this.gravity,0)),this.events=new Vi.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(om(a)){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(lm(a))o=a.object;else{if(nS(a)||n0(a)||a instanceof xv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,h=o.dataPatched;for(let g of h.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!h.physics||(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled))return!0;a.updateMatrixWorldRigid();let u=G5(h),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of h.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new L4t(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(v=>v.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){m=!0;let y=g.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=Vi.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(nn,ql,KF),a.position0=nn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=ql.clone(),nn.divideScalar(this.pixelsPerMeter),g.setTranslation(nn.x,nn.y,nn.z).setRotation(ql);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?Vi.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Vi.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Vi.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(Vi.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(0).setRestitutionCombineRule(Vi.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),nn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(KF.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(nn);let _=new Te().setFromEuler(new Fi().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(Vi.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else h.physics.rigidBody==="dynamic"||u||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,h.physics.fusedBody)):(f&&t.push(hc(f,a.matrixWorld)),h.physics.fusedBody&&!i1(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if(om(g)){if(!g.objectForSample)return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(g.objectForSample.dataPatched.physics.fusedBody)return;v=g.object}else{if(nS(g)||n0(g)||g instanceof xv)return;if(lm(g))v=g.object;else if(v=g,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;return _?.getAttribute("position")!==void 0&&t.push(hc(_,g.matrixWorld)),!!i1(g)||void 0}),this.generateSensorColliderDescs(o,h.physics.fusedBody,e));return!(h.physics?.fusedBody!==!0&&!l&&!i1(a))||void 0}),t.length===0)return;let i=Ig(t),r=i.getIndex().count>0;if(!r&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=Vi.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=Vi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Vi.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Vi.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,n)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,n);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let i=new Rdt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new xt().compose(Ud.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Tw.setFromEuler(ZF.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),F4t);if(e.data.triggerZone==="box"){let s=new cr;s.min.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):this.initializationCounter===2&&this.gameControl&&(e=!this.gameControl.update(t)&&e),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(t===0)e=this.stepPhysics()&&e;else{let r=t/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),n=0,a=6;for(;this.accumulator>=i&&n<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,n++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(nn,ql,KF);let e=t;e.prevQ===void 0?(e.prevQ=ql.clone(),e.prevT=nn.clone()):(e.prevQ.copy(ql),e.prevT.copy(nn))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,r]=this.fixedBodiesToWatch[t];e.rigidBody===i?(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(r)||(i.setBodyType(Vi.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1)):this.fixedBodiesToWatch.splice(t,1)}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(t===void 0)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),r=t.translation(),s=Math.hypot(i.x,i.z);for(let n=0;n<t.numColliders();n++){let a=t.collider(n);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let h=l.translation(),u=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(h.x-r.x)+v.y*(h.y-r.y)+v.z*(h.z-r.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let _=b*v.x,x=b*v.z,S=Math.hypot(_,x);if(S<1e-4)return;let w=(i.x*_+i.z*x)/S;w>u&&(u=w,d=_/S,c=x/S)}),u===-1/0)return;let p=i.x*d+i.z*c;if(p<-JF)return;let m=l.linvel();if(s>JF&&p>JF){let y=m.x*d+m.z*c;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:d*v,y:m.y,z:c*v},!0)}let f=m.x*d+m.z*c-Math.max(0,p);if(f<=0)return;let g=.5*f;l.setLinvel({x:m.x-d*g,y:m.y,z:m.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let t=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[e,i]of t)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(nn.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(ql)):t.delete(e);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)e.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let n of e.cloner.children)if(n.rigidBody===s){r=n;break}}t.dispatch(r),e.dispatchEvent(H7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=Odt.copy(t.matrixWorld).invert();t.traverseEntity((s,n)=>{if(e===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new Rdt(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Vi.ColliderDesc.cuboid(...a.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):Vi.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Vi.ActiveEvents.COLLISION_EVENTS),Ud.fromArray(a.data.position.map(h=>typeof h=="number"?h:0)),Tw.setFromEuler(ZF.fromArray(a.data.rotation.map(h=>typeof h=="number"?h:0))),ZE.makeRotationFromEuler(ZF).setPosition(Ud).premultiply(s.matrixWorld),i?(wc(ZE,{translation:Ud,quaternion:Tw,scale:Ddt}),o.setActiveCollisionTypes(Vi.ActiveCollisionTypes.KINEMATIC_FIXED|Vi.ActiveCollisionTypes.DYNAMIC_FIXED)):(wc(ZE.premultiply(r),{translation:Ud,quaternion:Tw,scale:Ddt}),t.rigidBody.bodyType()===Vi.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Vi.RigidBodyType.Fixed?o.setActiveCollisionTypes(Vi.ActiveCollisionTypes.KINEMATIC_FIXED|Vi.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Vi.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Vi.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ud.divideScalar(this.pixelsPerMeter),o.setTranslation(Ud.x,Ud.y,Ud.z),o.setRotation(Tw),i)i.push([o,l]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[h.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(xi.is(o)?o:o.object)===!1)continue;let l=Odt.copy($ft(s.matrixWorld)).copyPosition(s.matrixWorld).multiply(r),h=ZE.copy(o.matrixWorld).invert().multiply(l),u=o.bvhGeometry.boundsTree;i instanceof cr?t=u.intersectsBox(i,h):(QF.radius=i,QF.center.setFromMatrixPosition(h),t=u.intersectsSphere(QF)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(j4t)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};ab(),ht(),Y4(),Ui(),uT(),Rm();var t8=.02,Idt=new P,Ndt=new P,W4t=new P,Wa=new P,jd=new P,r1=new P,e8=new xt,Bdt=new xt,q4t=new xt,ol=new Te,tg=new Te,s1=new Fi(0,0,0,"YXZ"),H4t=new P(1,0,0),Eu=new P(0,1,0),$4t=new P(0,0,1),kdt=new P(1,1,1),Vdt=[],zdt=t=>Vdt[t]??(Vdt[t]=new P),i8=new P,X4t=new P,Y4t=new P,K4t=new P,Ldt=new Te,Z4t=new P,Fdt=new Te,Hn=new bl,Hl=new cr,Q4t={type:"requestRender"},J4t={type:"updateMatrix"},$7=class extends En{constructor(t,e,i,r,s,n,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.target0=new P,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Fi(0,0,0,"YXZ"),this.shearMatrix0=new xt,this.cameraShearMatrix0=new xt,this.position0Cam=new P,this.quat0Cam=new Te,this.scale0Cam=new P,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new bl(new P(0,-40,0),new P(0,40,0)),matrix:new xt,position:new P,rotation:new Te},this.euler=new Fi(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Te,this.lastCameraPosition=new P,this.PI_2=Math.PI/2,this.prevMouse=new Z,this.velocityTarget=new P,this.velocity=new P,this.directionXZ=new P,this.rotVelocityStick=new P,this.rotVelocityTarget=new P,this.rotVelocity=new P,this.rotDirection=new P,this.nonColliderRotOffset=new xt,this.nonColliderPosOffset=new xt,this.firstPointerId=-1,this.rot=new P,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new xt,this.objectToTarget=new P,this.objectToTarget0=new P,this.objectToCamXZ=new P,this.objectToCamXZ0=new P,this.targetToCamera=new P,this.targetToCamera0=new P,this.cameraPolarAxis0=new P,this.targetPos=new P,this.targetQuat=new Te,this.lerpFactorPos=new P().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Te,this.objXZQuatInv=new Te,this.objXZRotMat=new xt,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Te,this.colliderWorldQuat=new Te,this.groundNormal=new P,this.groundTilt=new Te,this.groundTiltInv=new Te,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Te,this.scale=new P,this.initialAction=!0,this.onPointerDown=m=>{!(m.target===this.domElement||m.target instanceof HTMLElement&&m.target.tagName==="SPLINE-VIEWER"&&m.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Uo&&!cU&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let f=m.clientX-this.prevMouse.x,g=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(cU&&Jmt<15.5&&!Uo?(this.eulerDelta.y=-f*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-f*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?$7.isLocked=!0:$7.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let m in this.movementState)this.movementState[m]=0},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]){this.movementState[f[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=m=>{for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]||m.code.slice(3,m.code.length).toUpperCase()===f[1]){this.movementState[f[0]]=0;break}},this.copyVRGamePadValues=(m,f)=>{for(let g=2;g<4;g++){let y=m.axes[g];f===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,t===a&&(this.isFirstPerson=!0),this.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),this.shearMatrix0.copy(this.object.shearMatrix),wc(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix}),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),this.cameraShearMatrix0.copy(this.camera.shearMatrix),wc(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix})),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m,f=new P(0,0,-1).applyQuaternion(this.camera.quaternion),g=new P().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(f.y)<1e-6?(g.y=0,f.y=0,m=g.projectOnVector(f)):m=g.y/f.y>0?f.multiplyScalar(g.y/f.y):f.multiplyScalar(g.length()),this.targetToCamera0.copy(m).negate();let y=this.camera.position.clone().add(m);this.objectToTarget0.subVectors(y,this.position);let v=new Fi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof Us&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(m=>{let f=[m[0],m[1]];return f[1]==="\u25B2"?f[1]="ArrowUp":f[1]==="\u25C0"?f[1]="ArrowLeft":f[1]==="\u25BC"?f[1]="ArrowDown":f[1]==="\u25B6"?f[1]="ArrowRight":f[1]==="\u21E7"?f[1]="Shift":f[1]==="\u21B5"?f[1]="Enter":f[1]==="Space"?f[1]=" ":f[1]==="\u2318"?f[1]="Meta":f[1]==="Ctrl"?f[1]="Control":f[1]==="Esc"&&(f[1]="Escape"),f}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(f=>f[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??mv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??mv.defaultData.usePhysics,this.jumpPower=20*i.jumpPower,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??G4.defaultDataThirdPerson.orientWith,this.slopeThresh=65*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*t8/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*t8/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*t8/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new P().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new Te().setFromEuler(new Fi().fromArray([...i.collider.rotation.map(m=>typeof m=="number"?m:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,kdt),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let m=new ce;m.push({fi:0,data:{...Bs.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Bs.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=lyt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new yr(cW.create({parameters:{width:p,height:p/10,hollow:.7}}),f),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(t=!1){if(this.object.matrixWorldAutoUpdate=!0,this.camera.matrixWorldAutoUpdate=!0,this.object.shearMatrix.copy(this.shearMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),wc(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix});let e=new Fi().setFromQuaternion(this.quaternion,"YXZ"),i=e.y;this.objectRealQuat.copy(this.quaternion),e.y=0,this.quaternion.setFromEuler(e),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),e.set(0,i,0),this.quaternion.setFromEuler(e),this.rot.setFromEuler(e),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Us?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.shearMatrix.copy(this.cameraShearMatrix0),t?(this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),wc(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix}))):this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let t=this.data,e=this.sharedAssets;t.gameActions!==void 0&&(this.actions={},j4.list.forEach(i=>{this.actions[i]=dn({...t,disabled:!1,type:"GameControl"},t.gameActions[i],this.page,e,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),sa(this.actions.idle),sa(this.actions.move),sa(this.actions.run),sa(this.actions.jump)}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].Transition.forEach(e=>{e.play()}),this.actions[t].Animation.forEach(e=>{e.play(this.initialAction===!1)}),this.actions[t].TimelineAnimation.forEach(e=>{e.play()}),this.actions[t].Create.forEach(e=>{e.dispatchStart()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("start")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].Transition.forEach(e=>{e.stop(),e.object.currentState!==null&&e.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[t].TimelineAnimation.forEach(e=>{e.stop()}),this.actions[t].Create.forEach(e=>{e.dispatchStop()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("stop")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Wa.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(t){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let e=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*e,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let n=jd.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*e,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(r=!0),a.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let o=a.collider.parent(),l=o!==null&&o.isKinematic()?o:null,h=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&h?.userData.isFollowingObj!==this.object.uuid){let u=this.object.getWorldPosition(Wa).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(u);this.groundVelocity.set(d.x,d.y,d.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=l.angvel().y*e}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let n=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=Wa.subVectors(this.path[1],this.position),o=jd.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),n.opacity=n.userData.opacity0}else n.opacity-=.05*n.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let s=W4t.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=jd.copy(s);n.y=0,s.set(0,s.y,n.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let n=Wa;this.camera.getWorldDirection(n);let a=r1.copy(Eu).multiplyScalar(n.dot(Eu));n.sub(a);let o=jd.copy(this.directionXZ);o.x*=-1,this.rot.y=n.angleTo(o)*(n.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(s1.setFromVector3(this.rot),this.moveMode==="walk"&&(s1.x=0),s.applyEuler(s1),r&&(tg.setFromUnitVectors(Eu,this.groundNormal),s.applyQuaternion(tg)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let n=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(i8,Ldt,X4t);let o=this.object.getWorldPosition(Y4t).add(this.collider.position).sub(i8);Fdt.copy(a.prevQ).invert().premultiply(Ldt);let l=r1.subVectors(i8,a.prevT).add(K4t.copy(o).applyQuaternion(Fdt).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),h=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Wa.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let u=xi.is(a)?a:a.object;if(h!==null&&this.lastHitObj!==u){let d;a instanceof Ja&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),u.dispatchEvent(H7));this.lastHitObj=u}h!==null&&(Math.abs(l.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=l.x),Math.abs(l.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=l.y),Math.abs(l.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=l.z),zdt(n++).copy(h.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=zdt(a),l=o.dot(s);l<0&&s.addScaledVector(o,-l)}s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(e),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*e,this.euler.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*e),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Eu,this.euler.y-this.euler0.y);let n=jd.copy(this.objectToCamXZ).normalize(),a=r1.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(Wa.copy(n).multiplyScalar(a.dot(n))).cross(n).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Ft.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Ft.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Ft.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(s1.copy(this.euler),s1.y=0,this.nonColliderRotOffset.makeRotationFromEuler(s1)),ol.setFromAxisAngle(H4t,this.rot.x),tg.setFromAxisAngle(Eu,this.rot.y),tg.multiply(ol),ol.setFromAxisAngle($4t,this.rot.z),tg.multiply(ol),this.quaternion.copy(tg),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let n=jd.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let u=0;u<5;u++){let d=n.length(),c=r1.copy(n).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,c,this.object.rigidBody.collider(0).shape,0,d,!1,12,void 0,void 0,this.object.rigidBody),a===null){u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(n);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let v of y)if(v.data.target==="character"){let b,_=(this.sharedGameControlGlobals.rapierWorld?.getCollider(a.collider.handle))._parent;if(p.cloner){for(let x of p.cloner.children)if(x.rigidBody===_){b=x;break}}v.dispatch(b),p.dispatchEvent(H7)}}}let m=Idt.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=Ndt.copy(c).multiplyScalar(a.time_of_impact).dot(m),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),f>this.offset&&(g=a.time_of_impact*(f-this.offset)/f,o.addScaledVector(c,g)),n.copy(c).multiplyScalar(d-g),Math.acos(-m.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=r1.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let b=y.add(v);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);_!==null&&_.time_of_impact===0&&(m.y=0,m.normalize())}n.addScaledVector(m,-n.dot(m))}}this.position.addScaledVector(o,this.pixelsPerMeter),Wa.copy(this.position).divideScalar(this.pixelsPerMeter),ol.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,h=l!==void 0&&Z4t.copy(Wa).sub(l.translation()).lengthSq()>1;l!==void 0&&(h?(l.setTranslation(Wa,!0),l.setRotation(ol,!0)):(l.setNextKinematicTranslation(Wa),l.setNextKinematicRotation(ol)))}else{let n=this.onObject?1:5,a=s.multiplyScalar(e/n);for(let o=0;o<n;o++)this.position.add(a),this.collisionAdjustment(e/n)}else this.position.addScaledVector(s,e);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),Bgt(this.position,this.quaternion,this.object.shearMatrix,this.scale,this.object.matrix).multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.parent instanceof Or?this.object.matrixWorld.multiplyMatrices(this.object.parent.matrixWorld,this.object.matrix).multiply(this.object.pivotMatrix):this.object.matrixWorld.copy(this.object.matrix),this.object.children.forEach(n=>{n.updateMatrixWorld(!0)}),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let n=this.objectToTarget.add(this.position),a=this.targetToCamera.add(n);e8.lookAt(a,n,Eu).setPosition(a),e8.decompose(this.targetPos,this.targetQuat,Wa),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.matrixWorld.copy(this.camera.matrix),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Ft.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Ft.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(J4t),!(this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)||(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Q4t),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=ol.setFromAxisAngle(Eu,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Ft.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e),t=this.cameraXAxis==="Limit"?Ft.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):Ft.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Wa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=tg.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Eu.angleTo(t)/Math.PI<15||180*Eu.angleTo(t)/Math.PI>85?ol.identity():ol.setFromUnitVectors(Eu,t),this.groundTilt.slerp(ol,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=Ndt.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=e8.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Wa,ol,jd).compose(Wa,ol,kdt);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;Hl.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=Bdt.copy(n).invert(),o=q4t.copy(Bdt).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=Idt.copy(this.position).applyMatrix4(a);Hl.expandByPoint(Hn.start),Hl.expandByPoint(Hn.end),Hl.min.addScalar(-this.collider.radius),Hl.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:h=>h.distanceToPoint(Hn.end),intersectsBounds:h=>h.intersectsBox(Hl),intersectsTriangle:h=>{let u=Wa,d=jd,c=h.closestPointToSegment(Hn,u,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(u).normalize(),f=r1.copy(l);f.addScaledVector(m,p);let g=f.applyMatrix4(n).sub(this.position);e.add(g),Hn.start.addScaledVector(m,p),Hn.end.addScaledVector(m,p)}}})}),Hl.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),Hl.expandByPoint(Hn.start),Hl.expandByPoint(Hn.end),Hl.min.addScalar(-this.collider.radius),Hl.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(Hl),intersectsTriangle:s=>{let n=Wa,a=jd,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),e.addScaledVector(h,l),Hn.start.addScaledVector(h,l),Hn.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(r),this.position.add(e)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},Qxt=$7;Qxt.isLocked=!1,ht(),dT(),MD(),ab(),sb();var Jxt,twt,r8,t5t=new Promise(t=>{Jxt=t});function e5t(t){return r8||(r8=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.123/build";typeof window<"u"&&(twt=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});Jxt(a)}(),r8)}ir();var ewt,Oi,ba,i5t=t=>`
5107
5107
  (async function() {
5108
5108
  const [wasmImport, wasmBinary] = await Promise.all([
5109
5109
  import('${t}' + 'navmesh.js'),
@@ -5113,7 +5113,7 @@ void main() {
5113
5113
  self.module = await wasmModule({ wasmBinary });
5114
5114
  postMessage('ready');
5115
5115
  })();
5116
- `,r5t={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};t5t.then(t=>{ewt=t,Oi=new t.Vec3,ba=new t.Vec3});var s5t=new P,n5t=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ge.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let n=s.raycastWithClones(r);if(n.length!==0){if(this.gameControl){let a=s5t.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,n[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{let n;if(s instanceof Rc){if(!s.objectForSample)return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else if(s instanceof Ja)n=s.object;else if(n=s,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!n.userData.navmesh)return;let a=n.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;s.updateMatrixWorldRigid();let o=G5(a),l=n.userData.hasDestroy,h=n.userData.hasDrag,u=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?u=!0:c.data.type==="Follow"&&(d=!0));if(u||o||d||l||h)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in s&&s.geometry&&i.push(hc(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof Rc){if(!c.objectForSample)return c.object.dataPatched.physics.fusedBody===!0&&c.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(c.objectForSample.dataPatched.physics.fusedBody)return;m=c.object}else if(c instanceof Ja)m=c.object;else if(m=c,c.dataPatched.cloner?.hideBase)return!0;let f=m.dataPatched;if(!f.visible&&f.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(hc(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof Rc)return;n=s instanceof Ja?s.object:s;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!n.userData.navmesh)return;let o=s.geometry,l=n.userData.hasDestroy===!0,h=n.userData.hasDrag===!0;if(G5(a)||l||h||n.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&i.push(hc(o,s.matrixWorld))},this.navmeshWasm=ewt,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?i5t(twt??"https://cdn.spline.design/@splinetool/runtime@2.0.121/build/"):`
5116
+ `,r5t={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};t5t.then(t=>{ewt=t,Oi=new t.Vec3,ba=new t.Vec3});var s5t=new P,n5t=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ge.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let n=s.raycastWithClones(r);if(n.length!==0){if(this.gameControl){let a=s5t.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,n[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{let n;if(s instanceof Rc){if(!s.objectForSample)return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else if(s instanceof Ja)n=s.object;else if(n=s,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!n.userData.navmesh)return;let a=n.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;s.updateMatrixWorldRigid();let o=G5(a),l=n.userData.hasDestroy,h=n.userData.hasDrag,u=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?u=!0:c.data.type==="Follow"&&(d=!0));if(u||o||d||l||h)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in s&&s.geometry&&i.push(hc(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof Rc){if(!c.objectForSample)return c.object.dataPatched.physics.fusedBody===!0&&c.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(c.objectForSample.dataPatched.physics.fusedBody)return;m=c.object}else if(c instanceof Ja)m=c.object;else if(m=c,c.dataPatched.cloner?.hideBase)return!0;let f=m.dataPatched;if(!f.visible&&f.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(hc(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof Rc)return;n=s instanceof Ja?s.object:s;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!n.userData.navmesh)return;let o=s.geometry,l=n.userData.hasDestroy===!0,h=n.userData.hasDrag===!0;if(G5(a)||l||h||n.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&i.push(hc(o,s.matrixWorld))},this.navmeshWasm=ewt,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?i5t(twt??"https://cdn.spline.design/@splinetool/runtime@2.0.123/build/"):`
5117
5117
  (async function() {
5118
5118
  const [wasmImport, wasmBinary] = await Promise.all([
5119
5119
  import(self.location.origin + '/_libraries/navmesh.js'),
@@ -5184,11 +5184,11 @@ onmessage = function(messageEvent) {
5184
5184
  `:"")+F2(i.children,e);if(i.type==="variable"){let s=e.getVariable(i.variableId);if(s!==void 0)return hwt(s,e)}}return""}).join("");Be();var _8=1e3,gct=512e3,EDt=class{constructor(t,e){this.id=t,this.userWebhook=e,this.result=void 0,this._connected=!1,this.emitter=zD(),this.reconnectWaitFor=_8,this._onError=i=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()},this._onConnected=i=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=_8,this._connected=!0},this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=_8,this._connected=!1},this._onMessage=i=>{let r,s=i.data;try{r=JSON.parse(s)}catch(n){console.error("Error parsing webhook message",n)}if(r){let n=!1;this.userWebhook.parametersSchemas.forEach(({data:a})=>{r[a.name]!==void 0&&function(o,l){let h=typeof o;return!!((l==="string"||l==="number")&&h===l||l==="boolean"&&(o==="true"||o==="false"||o===!0||o===!1)||l==="image"&&h==="string"&&o.startsWith("http"))}(r[a.name],a.type)&&(this.result===void 0&&(this.result={}),this.result[a.name]=r[a.name],n=!0)}),n&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource("https://hooks.spline.design/events?hashFile="+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>gct&&(this.reconnectWaitFor=gct),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let e of this.userWebhook.parametersSchemas)if(e.data.name===t)return HU.defaultParameterValueByType(e.data.type)}}};Ni(),Tl("API",({eventContext:t,eventManager:e})=>new xDt(t,e)),Tl("WEBHOOK",({eventContext:t,eventManager:e})=>new SDt(t,e)),eo("UserAPI",({data:t,page:e,shared:i,actionCondition:r})=>new MDt(t,e,i,r)),function(t){wW=t}({createUserAPI:(t,e,i)=>new ADt(t,e,i),createUserWebhook:(t,e)=>new EDt(t,e)}),Nr("api-services");var PDt=class extends ro{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.onVoice=({value:i,frequencies:r})=>{this.events.forEach(s=>{s.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="AIAssistantListener"&&!e.data.disabled).forEach(e=>{this.events.push(new RDt(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},RDt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.actions=dn(e,e.actions,r,s,n,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{!e.shouldReinit()||(e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init())}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}},DDt=class extends ro{constructor(t,e){super(t),this.eventManager=e,this.events=[],this.onTriggerEvent=({description:i,direction:r})=>{let s=this.events.find(n=>n.data.description===i);s&&(r==="backward"?s.dispatchReverse():s.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(e=>e.data.type==="AIAssistantTrigger"&&!e.data.disabled).forEach(e=>{this.events.push(new ODt(e.id,e.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},ODt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.actions=dn(e,e.actions,r,s,n,i)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{!e.shouldReinit()||(e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init())}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};TW();var IDt=function(t){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(i,r,s,n)=>String(r+r+s+s+n+n));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null},yct=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],NDt=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Sm=[],Bq=[];for(let t=1;t<=8;t++)for(let e=0;e<yct.length;e++){let i=yct[e];Sm.push(i/Math.pow(2,8-t)),Bq.push(NDt[e]+t)}var q5=[32,2e3],vct=Sm.filter((t,e)=>Sm[e]>q5[0]&&Sm[e]<q5[1]),BDt=Bq.filter((t,e)=>Sm[e]>q5[0]&&Sm[e]<q5[1]),kDt=class{static getFrequencies(t,e,i,r="frequency",s=-100,n=-30){i||(i=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(i));let a,o,l,h=e/2,u=1/i.length*h;if(r==="music"||r==="voice"){let c=r==="voice"?vct:Sm,p=Array(c.length).fill(s);for(let m=0;m<i.length;m++){let f=m*u,g=i[m];for(let y=c.length-1;y>=0;y--)if(f>c[y]){p[y]=Math.max(p[y],g);break}}a=p,o=r==="voice"?vct:Sm,l=r==="voice"?BDt:Bq}else a=Array.from(i),o=a.map((c,p)=>u*p),l=o.map(c=>`${c.toFixed(2)} Hz`);let d=a.map(c=>Math.max(0,Math.min((c-s)/(n-s),1)));return{values:new Float32Array(d),frequencies:o,labels:l}}},VDt=class{constructor(t){this.value=0,this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return kDt.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((i,r)=>i+r,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},zDt=class{constructor(t){this.callbacks=t,this.rafId=0,this.isOpen=!1,this.onMessage=e=>{this.callbacks.onMessage(e.data)},this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()},this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(t){let e=await async function(n){try{return(await(await fetch("https://relayserver.spline.design/session?uuidfile="+n)).json()).token}catch(a){console.error("Token generation error:",a)}}(t);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=n=>{let a=n.streams[0];this.audioElement.srcObject=a,this.analyser=new VDt(a)};let i=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(i.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let r=await this.pc.createOffer();await this.pc.setLocalDescription(r);let s={type:"answer",sdp:await(await fetch("https://api.openai.com/v1/realtime/calls?model=gpt-realtime",{method:"POST",body:r.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(s),this.animate()}send(t){return!!this.dc&&(this.dc.send(t),!0)}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}},LDt=class{constructor(t,e,i){this.data=t,this.id=e,this.shared=i,this.emitter=zD(),this.voice=0,this.frequencies=new Float32Array([0]),this.events=[],this.isConnected=!1,this.isToolsAdded=!1,this.tools=[],this.onServerEvent=r=>{let s=JSON.parse(r);if(this.appendEvent(s),s.type==="session.created"&&this.onSessionCreated(),s.type==="response.done"&&s.response?.output){for(let n of s.response.output)if(n.type==="function_call")for(let[a,o]of this.tools)n.name===a.name&&(o(JSON.parse(n.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}},this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()},this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(t){this.data=t}setColorByName(t,e){let i=this.shared.getColorByName(t);if(i){let{id:r}=i,{r:s,g:n,b:a}=IDt(e)??{r:0,g:0,b:0};this.shared.updateColor(r,{r:s/255,g:n/255,b:a/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let t={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,i)=>{this.voice=e,this.frequencies=i,this.emitter.emit("voice",{value:e,frequencies:i})}};this.hosted=function(e,i,r){if(!function(){try{return window.__SPLINE_PLAY_VOICE_HOST__===!0&&window.parent!==window}catch{return!1}}())return null;let s=!1,n=o=>{window.parent.postMessage({__splinePlayFrame:!0,...o},"*")},a=o=>{if(o.source!==window.parent)return;let l=o.data;!l||l.__splinePlayFrameHost!==!0||l.id!==e||(l.type==="voice-open"?(s=!0,r.onOpen()):l.type==="voice-message"&&typeof l.data=="string"?r.onMessage(l.data):l.type==="voice-level"&&typeof l.value=="number"?r.onVoice(l.value,l.frequencies instanceof Float32Array?l.frequencies:new Float32Array(0)):l.type==="voice-error"&&console.error("Voice assistant host error:",l.message))};return window.addEventListener("message",a),n({type:"voice-connect",id:e,hash:i}),{send:o=>!!s&&(n({type:"voice-send",id:e,message:o}),!0),disconnect:()=>{s=!1,window.removeEventListener("message",a),n({type:"voice-disconnect",id:e})}}}(this.id,this.data.integration.hash,t),!this.hosted&&(this.session=new zDt(t),await this.session.connect(this.data.integration.hash))}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){t.event_id=t.event_id||crypto.randomUUID();let e=JSON.stringify(t);(this.hosted?this.hosted.send(e):this.session?.send(e))?this.appendEvent(t):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:s})=>{this.setColorByName("Voice Assistant Color",s)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:s,value:n})=>{let a=this.shared.getVariableByName(s);if(a){let o,l=this.shared.getVariable(a.id);if(typeof l=="number"){if(o=parseFloat(n),!Number.isFinite(o))return}else o=typeof l=="boolean"?n.toLowerCase()==="true":{textValue:n};this.shared.updateVariable(a.id,o)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:s,value:n})=>{this.setColorByName(s,n)});let i=this.shared.scene,r=[];i.traverseEntity(s=>{s.data.events.forEach(n=>{if(n.data.type==="AIAssistantTrigger"){let{description:a}=n.data;r.push(a)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(r)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:s,direction:n})=>{this.emitter.emit("trigger_event",{description:s,direction:n})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([s])=>s)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((i,r)=>i+r,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};Ni(),Tl("AIAssistantListener",({eventContext:t,eventManager:e})=>new PDt(t,e)),Tl("AIAssistantTrigger",({eventContext:t,eventManager:e})=>new DDt(t,e)),SW=(t,e,i)=>new LDt(t,e,i),Nr("ai-assistant"),ir(),LW();var kq=class extends TD{constructor(t,e,i){super(t,e,i),this.data=e}};Be(),ht(),Be(),ht();var uwt=class extends Qv{constructor(){super(),this.caretIndex=0,this._caretVisibleAlpha=1,this._selectionVisibleAlpha=.3,this.current={start:0,end:void 0},this.matrixAutoUpdate=!1,this.caretMesh=new yr(new Oc(1,1),new jo({transparent:!0,opacity:0,side:Rn})),this.add(this.caretMesh),this.selectionMesh=new yr(new Oc(1,1),new jo({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:Rn})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(t){this.visible=!0,this.object=t,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=.5*-this.caretHeight,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(this.object===void 0)return;this.updateHelperMatrix();let{depth:t}=this.object.geometry.userData.parameters;this.caretMesh.position.z=t,this.selectionMesh.position.z=t}updateHelperMatrix(){if(this.object===void 0)return;let t=this.object,e=t.parent;e!==null&&e.updateWorldMatrix(!0,!1),t.matrixAutoUpdate&&t.updateMatrix(),e!==null?(this.matrixWorld.copy(e.matrixWorld),this.matrixWorld.multiplyMatrices(this.matrixWorld,t.matrix)):this.matrixWorld.copy(t.matrix),this.matrix.copy(this.matrixWorld);for(let i of this.children)i.matrixWorld.copy(this.matrixWorld);t.updateWorldMatrix(!0,!0)}setCaretColor(t){let e=this.caretMesh.material;e.color.setRGB(t.r,t.g,t.b);let i=this._caretVisibleAlpha===e.opacity;this._caretVisibleAlpha=t.a,i&&(e.opacity=this._caretVisibleAlpha)}setSelectionColor(t){this.selectionMesh.material.color.setRGB(t.r,t.g,t.b)}setCaretPosition(t,e={}){if(this.object===void 0)return;this.caretIndex=t;let i=this.object.wrappedText,[r,s]=yP(i,t),[n,a]=t>0?yP(i,t-1):[null,null];(t>0&&i.length?i[n].charAt(a):null)===`
5185
5185
  `&&(r++,s=0),this.current.start=t,this.current.end=void 0;let[o,l]=x8(this.object,r,s),{AD:h,descender:u}=this.object,d=u+.5*h,{width:c,height:p,depth:m}=this.object.geometry.userData.parameters,f=typeof c=="string"?0:c,g=typeof p=="string"?0:p;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(o-.5*f,l+d+.5*g,m),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(t,e){if(this.object===void 0)return;let i=this.object.wrappedText;this.current.start=t,this.current.end=e;let r=[],s=[],n=function(g,y,v){let[b,_]=yP(g,y),[x,S]=yP(g,v),w=[];_>=g[b].length&&(b++,_=0);for(let T=b;T<=x;T++){let C=g[T],M=T===b?_:0,A=T===x?S:C.length;w.push([T,M,A])}return w}(i,t,e),{lineHeight:a,AD:o,descender:l}=this.object,h=l+.5*o-.5*a;for(let[g,y,v]of n)if(y!==v){let[b,_]=x8(this.object,g,y),[x,S]=x8(this.object,g,v),w=_,T=S;w+=h,T+=h,T+=a;let C=r.length/3;r.push(b,w,0),r.push(x,w,0),r.push(x,T,0),r.push(b,T,0),s.push(C+0,C+1,C+2),s.push(C+2,C+3,C+0)}let u=new ye;u.setIndex(s),u.setAttribute("position",new ge(r,3));let{width:d,height:c,depth:p}=this.object.geometry.userData.parameters,m=typeof d=="string"?0:d,f=typeof c=="string"?0:c;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=u,this.selectionMesh.position.x=.5*-m,this.selectionMesh.position.y=.5*f,this.selectionMesh.position.z=p,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(t,e,i="previous"){if(this.object===void 0||this.object.font===void 0)return;let r=this.object.wrappedText,s=r.length,n=this.object.lineHeight,a=s*n,{height:o,verticalAlign:l}=this.object.geometry.userData.parameters,h=typeof o=="string"?0:o,u=0;l===3?u=h-a:l===2&&(u=.5*h-.5*a);let d=Math.min(Math.floor(Math.max(Math.min(-e-u,a),0)/n),s-1),c=this.object.charCoords[d],p=this.object.charWidths[d],m=0,f=!1;if(i==="previous"){for(let g=0;g<c.length;g++)if(c[g][0]+.5*p[g]-t>0){m=g,f=!0;break}}else if(i==="closest"){let g=1/0;for(let y=0;y<c.length;y++){let v=c[y][0]+.5*p[y],b=Math.abs(v-t);b<g&&(g=b,m=y,f=!0)}}else for(let g=0;g<c.length;g++){let y=c[g][0],v=c[g][0]+p[g];if(t>=y&&t<v){m=g,f=!0;break}}return f||(m=c.length),{index:this.getGlobalIndexFromLineAndCharIndexes(r,d,m),lineIndex:d,characterIndex:m}}getGlobalIndexFromLineAndCharIndexes(t,e,i){return t.slice(0,e).reduce((r,s)=>r+s.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function x8(t,e,i){let{charCoords:r,charWidths:s,initialOffsetY:n,lineHeight:a}=t;if(r[e]&&r[e].length===0||r.length===0){let d=0,{horizontalAlign:c}=t.data.geometry,p=t.wrappedText,{width:m}=t.geometry.userData.parameters;return p.length===1&&p[0].length===0&&(c===3?d=.5*m:c===2&&(d=m)),[d,n-a*e]}let o=r[e];if(o===void 0||o.length===0)return[0,0];let[l,h]=o[Math.min(i,o.length-1)],u=l;return i>=o.length&&(u+=s[e][i-1]),[u,h]}function yP(t,e){let i=0;for(let r=0;r<t.length;r++){let s=t[r],n=e-i;if(n<=s.length)return[r,n];i+=s.length}return[Math.max(0,t.length-1),t[t.length-1]?.length??0]}function FDt(t,e){return typeof t=="string"?e.data.colors[t]:t}function UDt(t){return t.colors[0]}ht();var jDt=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=t=>{let e=[t.clientX,t.clientY],i=new Date().getTime();if(this._clickCount>0){let r=e[0]-this._lastPosition[0],s=e[1]-this._lastPosition[1];Math.sqrt(r*r+s*s)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=t=>{}}start(t,e=500,i=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=i,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}};ir();var GDt=new P(0,0,1),bct=new P,_ct=new P,xct=new As,WDt=class{constructor(t,e,i,r,s){this.containerScene=t,this.raycaster=e,this.sharedAssets=i,this.requestRender=r,this.onExit=s,this.htmlInput=null,this.virtualInput=null,this.helper=new uwt,this.doubleClickHandler=new jDt,this.isDragging=!1,this.plane=new Pa,this.caretInterval=0,this.planeIntersection=new P,this.projected=new Z,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{let n=this.virtualInput?.data;if(this.virtualInput!==void 0&&n){let a=n.material,o=function(l,h){let u=Ks.fromHex(3223857),d=.8;for(let c of l.layers){if(c.data.type==="light"||c.data.type==="displace"||c.data.type==="fresnel"||c.data.type==="dust"||c.data.type==="matcap"||c.data.type==="texture"||c.data.type==="toon"||c.data.type==="outline"||c.data.type==="transmission"||c.data.type==="noise"||c.data.type==="vertexColor")continue;let p=typeof c.data.alpha=="string"?Number(h.getVariable(c.data.alpha)):c.data.alpha;if(c.data.type==="color"&&p>.3){u=FDt(c.data.color,h),d=p;break}if((c.data.type==="depth"||c.data.type==="gradient")&&p>.3){let m=UDt(c.data);u={r:m[0],g:m[1],b:m[2]},d=typeof c.data.alpha=="string"?1:c.data.alpha;break}}return{...u,a:d}}(typeof a=="string"?this.sharedAssets.data.materials[a]:a,this.sharedAssets);this.helper.setCaretColor(o)}},this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)},this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))},this.handleCaretUpdate=n=>{if(!this.htmlInput||!this.virtualInput)return;let a=this.helper,o=n?.key==="ArrowLeft"||n?.key==="ArrowRight",l=n?.key==="ArrowUp"||n?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(a.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:o,verticalKeyMove:l}),this.startAnimateTextCursor()):a.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=function(){let t=document.createElement("textarea");return t.style.position="fixed",t.style.top="200px",t.style.left="400px",t.style.zIndex="-1",t.style.border="1px solid rgba(255,0,0,0.5)",t.style.width="10px",t.style.height="500px",t.style.color="white",t.style.opacity="0.5",t.style.background="transparent",t.style.display="none",t.style.margin="0px",t.style.padding="0px",t.style.boxSizing="content-box",t.style.pointerEvents="none",t}(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,e=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0},{lineIndex:i}=e,{index:r,characterIndex:s}=e;this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[i][Math.max(0,s-1)]===`
5186
5186
  `&&(r--,s--),this._lastIndex=r,this._isFirstDragMove=!0;let n=this.checkClickedObject();if(t===1){if(n===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=r,this.isDragging=!0,this.setInputSelection(r)}else n===this.virtualInput&&(t===2?this.selectClosestWord(i,s):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let e=this.data?.geometry.text;this.htmlInput.value=typeof e=="string"?"":e?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0},s=e;i!==void 0&&r!==void 0&&this.virtualInput?.wrappedText[i][r-1]===`
5187
- `&&s--,this.htmlInput.setSelectionRange(Math.min(t,s),Math.max(t,s))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof kq)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[t],s=e+1,n=e;r[e]!==" "&&(s=this.findNextCharOccurence(r,e,"forward"," "),n=this.findNextCharOccurence(r,e,"backward"," "),n>0&&n++,s>=r.length-1&&t===i.length-1&&s++);let a=this.helper,o=a.getGlobalIndexFromLineAndCharIndexes(i,t,n),l=a.getGlobalIndexFromLineAndCharIndexes(i,t,s);this.setInputSelection(o,l)}findNextCharOccurence(t,e,i,r=" "){let s=Math.max(0,t.length-1),n=i==="forward"?s:0,a=i==="forward"?1:-1,o=Math.max(Math.min(e,s),0);for(;o!==n;)if(o+=a,t.charAt(o)===r)return o;return n}getPointOnPlane(){let t=this.virtualInput?.data;if(this.virtualInput&&t&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new P);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let i=typeof t.geometry.width=="number"?t.geometry.width:1,r=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+.5*i,e.y-.5*r)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(xct.getNormalMatrix(this.virtualInput.matrixWorld),bct.copy(GDt).applyMatrix3(xct).normalize(),this.virtualInput.localToWorld(_ct.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(bct,_ct))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),aT&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=function(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}(t.geometry.horizontalAlign))}},dwt=(t,e)=>{if(typeof t=="string"){let i=e.data(t);if(i)return dwt(i.value,e)}return Da.getDisplayedValue(t)};function wct(t,e){let i=t.text,r="";if(typeof i=="string"){let s=e.variables.data(r);s&&(r=dwt(s.value,e.variables))}else r=i.textValue.toString();return r}var qDt=class extends ro{constructor(t,e){super(t),this.eventManager=e,this._textInputs=[],this.sceneHelpers=new Ku,this.helper=new uwt,this._onMouseDownFocusIn=i=>{if(Ge.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let s of this._textInputs)if(this.eventContext.raycaster.intersectObject(s,!0).length>0){r=s;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDown,!1),s.removeEventListener("pointerup",this._onMouseUp,!1),s.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),s.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:s,helper:n}=this.textInputManager;if(!r||!s)return;let a=r.value;s.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=s.data;n.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new WDt(this.sceneHelpers,t.raycaster,t.sharedAssets,t.requestRender,this.onExit)}connect(){let t=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof kq&&t.push(r)}),this._textInputs=t,t.length===0)return;let{domElement:e}=this.eventContext;e.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let t=this.textInputManager.htmlInput,{domElement:e,sharedAssets:i}=this.eventContext;e.removeEventListener("pointerdown",this._onMouseDownFocusIn),t?.removeEventListener("keyup",this._onCaretUpdate),t?.removeEventListener("keydown",this._onCaretUpdate),t?.removeEventListener("beforeinput",this._onCaretUpdate),t?.removeEventListener("paste",this._onCaretUpdate),t?.removeEventListener("cut",this._onCaretUpdate),t?.removeEventListener("select",this._onCaretUpdate),t?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(r=>{let s=wct(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(s,i)}),e.removeEventListener("pointerdown",this._onMouseDown,!1),e.removeEventListener("pointerup",this._onMouseUp,!1),e.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(t){this.textInputManager.focus(t),this.textInputManager.onTextMaterialChanged();let e=this.textInputManager.htmlInput;if(!e||t===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=wct(t.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);e.value=i,e.setSelectionRange(0,0),this.textInputManager.helper.show(t),e.style.display="block",e.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};Ni(),Tl("Textfields",({eventContext:t,eventManager:e})=>new qDt(t,e)),eb("InputGeometry",(t,e,i)=>new kq(t,e,i)),Nr("textinputs"),hW();var cwt=new Map,MS=new Map,vP=class{constructor(t,e,i,r){this.data=e,this.isPlayAudioAction=!0;let{audio:s,volume:n,delay:a,loop:o}=e;if(!s)throw new Error("Missing property");try{let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Z1({src:l,volume:n,delay:a,loop:o})}catch{console.warn(`Could not create an audio player for this object: "${i.name}" and this audio: "${s}"`)}MS.has(i.uuid)?MS.get(i.uuid).push(this):MS.set(i.uuid,[this]),cwt.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},HDt=class{constructor(t){this.data=t,this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=cwt.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=MS.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...MS.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},$Dt=class{constructor(t,e,i,r,s){if(this.data=e,this.shared=r,this.condition=s,e.interaction==="play")this.interaction=new vP(t,e,i,r);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new HDt(e)}}dispatchBasic(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof vP?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof vP?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof vP&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};Ni(),eo("Audio",({id:t,data:e,object:i,shared:r,actionCondition:s})=>new $Dt(t,e,i,r,s)),Nr("audio"),ir();var pwt=new Map,AS=new Map,w8=class{constructor(t,e,i){this.data=e,this.isPlayVideoAction=!0,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=e;if(this.object=i,r===void 0)throw new Error("Missing property");let o=function(l,h){let u;if("material"in l){let c=l.material;u=Array.isArray(c)?l.material[0].layers.find(p=>p.uuid===h):l.material.layers.find(p=>p.uuid===h)}if(!u)return;let d=u.color?.texture?.image?.img??u.holders?.find(c=>c.isVideo)?.img;return d instanceof HTMLVideoElement?d:void 0}(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,aT&&(this.videoElement.autoplay=!0),n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),AS.has(i.uuid)?AS.get(i.uuid).push(this):AS.set(i.uuid,[this]),pwt.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let i=this.videoElement.duration;if(i>0){let r=t%i;this.videoElement.currentTime=r}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},XDt=class{constructor(t){this.data=t,this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=pwt.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=AS.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let t=[...AS.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},YDt=class{constructor(t,e,i,r,s){if(this.data=e,this.shared=r,this.condition=s,e.interaction==="play")this.interaction=new w8(t,e,i);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new XDt(e)}}dispatchBasic(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof w8?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof w8?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};ts(),Ni(),eo("Video",({id:t,data:e,object:i,shared:r,actionCondition:s})=>Go(i)?null:new YDt(t,e,i,r,s)),Nr("video"),ir(),ht(),MD(),ab();var S8=(()=>{let t,e,i,r,s=!1;function n(l){!t&&!Sct()&&(e?.sharedGameControlGlobals.createdObjects.length??0)>0&&(t=requestAnimationFrame(a)),l&&(e=l,r=l.requestRender,!s&&typeof document<"u"&&(document.addEventListener("visibilitychange",o),s=!0))}function a(l){if(!e||!r)return t=void 0,void(i=void 0);let h=i?l-i:0,u=e.sharedGameControlGlobals.createdObjects,d=e.sharedGameControlGlobals.nCreatedPerAction,c=u.length,p=0;for(;p<c;){let m=u[p];m.userData.createdTime===void 0&&(m.userData.createdTime=l),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&l-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&d[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,h/1e3),m.updateMatrix(),m.userData.parentMatrix&&m.matrix.premultiply(m.userData.parentMatrix),r()),p++):(d[m.userData.actionId]>m.userData.quantity&&d[m.userData.actionId]--,u.splice(p,1),m.removeFromParent(),e.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(e.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),e.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,e.sharedGameControlGlobals.entitiesWithTransformAnim=e.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}t=p>0?requestAnimationFrame(a):void 0,i=p>0?l:void 0}function o(){Sct()?t&&(cancelAnimationFrame(t),t=void 0,i=void 0):n()}return{play:n,dispose:function(){t&&(cancelAnimationFrame(t),t=void 0),s&&typeof document<"u"&&(document.removeEventListener("visibilitychange",o),s=!1),e=void 0,r=void 0,i=void 0}}})();function Sct(){return!!document&&document.hidden}var Tct=new Te,KDt=new P,ZDt=new P,QDt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Ft.generateUUID(),this.dispatch=()=>{if(Ir(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()},this.dispatchFromStart=()=>{if(Ir(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))},this.dispatchThrottled=function(a,o=0,l={}){return LS(a,o,{leading:l.leading!==!1,trailing:l.trailing!==!1,maxWait:o})}(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let a=new Ja(this.object);if(a.playModeVisible=!0,a.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldRigid(),a.userData.parentMatrix=h.matrixWorldRigid)}a.scale.copy(this.object.scale),a.position.fromArray(this.data.position.map(l=>typeof l=="number"?l:0)),a.rotation.fromArray(this.data.rotation.map(l=>typeof l=="number"?l:0)),a.updateMatrix(),a.userData.parentMatrix&&a.matrix.premultiply(a.userData.parentMatrix),this.page.add(a);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(a),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,a.updateWorldMatrix(!0,!0),a.traverseObject(this.traverseObjectCB),S8.play(),this.controlsManager.requestRender()},this.traverseObjectCB=a=>{let o;if(a.updateMatrixWorldRigid(),this.controlsManager.sharedGameControlGlobals.rapierWorld){if(a instanceof Rc){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(a instanceof Ja)o=a.object;else if(o=a,o.dataPatched.cloner?.hideBase)return!0}else{if(a instanceof Rc)return;o=a instanceof Ja?a.object:a}this.data.destroy==="Time"?a.userData.lifetime=1e3*this.data.lifetime:this.data.destroy==="Quantity"&&(a.userData.quantity=this.data.destroyAfterQuantity,a.userData.actionId=this.uniqueId);let l=new P().fromArray(this.data.velocity.map(u=>typeof u=="number"?u:0)),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(a,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(a.rigidBody?.collider(0).setActiveEvents(1),a.userData.hasCollisionDestroy=!0),a.matrixWorld.decompose(KDt,Tct,ZDt),l.applyQuaternion(Tct),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&a.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in a.object&&this.controlsManager.addBoundsTree(a),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&(a.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let n=this.page.scene.find(this.data.object);if(!n)throw new Error("Missing Property");if(this.object=n,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");S8.play(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],S8.dispose()}},JDt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=n=>{this.timeoutIdQueue.shift();let a=this.page.scene.find(n);if(a===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=!o||a.dataPatched.physics?.fusedBody;if(a.cloner){for(let h of a.cloner.children)l?(h.playModeVisible=!1,a.dataPatched.physics?.rigidBody==="positioned"&&this.removeBody(h),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,this.removeBody(h)):h.playModeVisible===void 0&&(h.playModeVisible=!0);a.cloner.syncInstanceMatrices(),(l||this.clone===void 0||this.clone===!1)&&(a.visible=!1,this.removeBody(a),a.bvhGeometry&&(a.bvhGeometry=void 0))}else this.removeBody(a),a.bvhGeometry&&(a.bvhGeometry=void 0),a.visible=!1;this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),a.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...t.objects]}removeBody(t){let e=t.rigidBody;if(!e)return;let i=this.controlsManager.sharedGameControlGlobals;i.colliderToEntity.delete(e.collider(0).handle),i.kinematicBodyToEntity.delete(e.handle);let r=this.controlsManager;r.fixedBodiesToWatch=r.fixedBodiesToWatch.filter(([,s])=>s!==e),i.rapierWorld.removeRigidBody(e),t.rigidBody=void 0}dispatch(t){if(Ir(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()}dispatchFromStart(){if(Ir(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};Ni(),eo("Create",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new QDt(t,e,i.controlsManager,r,s)),eo("Destroy",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new JDt(t,e,i.controlsManager,r,s)),Nr("create-destroy"),Be(),Be(),bo(),ht(),Qh(),_o(),ts();var Mct=new P;function Vq(t,e,i=!1){let r=[],s=n=>{let a=n.data;delete n.states,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let o of a.states){let l={...o.data};n.states||(n.states={}),n.states[o.id]=Og.patch(a,l)}Cct(t.scene,n,null,e,a.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),Act(t)};t.scene.traverse2D(s),t.traverseChildren(n=>{if(i&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(Mct,!0),n.rigidBody?.setAngvel(Mct,!0)),!xi.is(n))return;let a=n.uuid,o=n.data;if(delete n.states,n.uuid===l0)return;let l=!1;r.some(h=>t.scene.find(a)?.isDescendantOf(h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(a),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null,n.transitionState={settled:!0,state:null};for(let h of o.states){let u={...h.data};t.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete u.position,h.data.rotation!==void 0&&delete u.rotation),n.states||(n.states={}),n.states[h.id]=am.patch(o,u)}Cct(t.scene,n,null,e,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),Ya(n)&&n.frame&&(n.frame.traverse(h=>s(h)),n.uiCanvas?.applySize())}),Act(t),t.frame&&(t.frame.traverse(n=>s(n)),t.uiCanvas?.applySize())}function Act(t){t.traverseEntity(e=>{for(let i of e.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions)}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let n=t.scene.find(s.data.object);n&&(n.visible=!1)}}})}function Cct(t,e,i,r,s=!1){if(t.markShadowsDirty(),e instanceof Ur&&!Ic(e)&&e.removeInteractionGeometry(r),Go(e)?e.changeSelectedState(i,{shared:r},s):e.changeSelectedState(i,{scene:t,shared:r},s),e instanceof Ur&&e.updateGeometryGroupsIfNeeded(),e instanceof Us&&e.updateCameraState(e.dataPatched,{scene:t,shared:r}),!Go(e)){if(e.cloner){let n=!1;for(let a of e.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,n=!0);n&&t.addPendingUpdateCloner(e),e.cloner.syncInstanceMatrices()}e.updateVisible()}}var tOt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=e.scene}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},1e3*this.data.delay))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(e=>e.uuid!==this.data.target||e.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,1e3*this.data.duration),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.sleep(),e.wakeUp(),e.data.autoPlay?e.start():e.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Vq(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function eOt(t){return{easing:t.type,control1:Pc(t.cubicControls?.control1,[0,0]),control2:Pc(t.cubicControls?.control2,[1,1]),...t.springParameters}}function g1(t,e){let i=[];for(let r of t??[]){let s=e(r.data);s!==void 0&&i.push({time:r.data.time,ease:eOt(r.data.easing),value:s})}return{keyframes:mgt(i)}}function Du(t,e){if(t.keyframes.length===0)return;let{index0:i,index1:r,t:s}=pgt(t.keyframes,e),n=t.read;if(n&&n.index0===i&&n.index1===r&&n.t===s)return;let a={index0:i,index1:r,from:t.keyframes[i].value,to:t.keyframes[r].value,t:s};return t.read=a,a}function iOt(t){t.read=void 0}function bP(t,e,i){return t+(e-t)*i}Ni(),eo("SceneTransition",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new tOt(t,e,i,r,s)),Nr("scene-transition"),Be(),ht(),Be(),Be(),ht(),oa(),Qh(),_D(),WW(),wD(),_o(),ts(),nb(),AW(),yD(),Be(),ir(),Be(),ht(),kc();var{degToRad:hIt,radToDeg:uIt}=Ft;function xa(t,e,i,r,s,n){let a=i[t]!==void 0?i[t]:void 0,o=r[t];if(o==null)return;let l=a!=null?typeof a=="string"?Number(s.getVariable(a)??0):a:e[t],h=typeof o=="string"?Number(s.getVariable(o)??0):o;return l!==h?{update:u=>{let d=Ft.lerp(l,h,u);e[t]=n?Math.trunc(d):d},start:()=>{e[t]=l},end:()=>{e[t]=h}}:void 0}function lG(t,e,i,r,s,n){let a=i[t]?i[t]:void 0,o=r[t];if(!o)return;let l=e[t],h=[...a??l].map(d=>typeof d=="string"?Number(s.getVariable(d)??0):d),u=[...o].map(d=>typeof d=="string"?Number(s.getVariable(d)??0):d);return h.length!==u.length||qg(h,u)?void 0:{update:d=>{h.forEach((c,p)=>{let m=Ft.lerp(c,u[p],d);e[t][p]=n?Math.trunc(m):m})},start:()=>{Object.assign(e[t],h)},end:()=>{Object.assign(e[t],u)}}}function H5(t,e,i){return e.forEach((r,s)=>{t.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),t}function Ect(t,e,i,r,s){let n=i[t]?i[t]:void 0,a=r[t];if(!a)return;let o=e[t],l=n?H5(new P,n,s):o.clone(),h=H5(new P,a,s);return l.equals(h)?void 0:{update:u=>{o.lerpVectors(l,h,u)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function Pct(t,e,i){return e.forEach((r,s)=>{t.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),t}function _P(t,e,i,r,s){let n=i[t]?i[t]:void 0,a=r[t];if(!a)return;let o=e[t],l=!(o instanceof Z),h=o instanceof Z?o:new Z().fromArray(o),u=n?Pct(new Z,n,s):h.clone(),d=Pct(new Z,a,s);return u.equals(d)?void 0:{update:c=>{h.lerpVectors(u,d,c),l&&(e[t]=h.toArray())},start:()=>{h.copy(u),l&&(e[t]=h.toArray())},end:()=>{h.copy(d),l&&(e[t]=h.toArray())}}}function xP(t,e,i,r,s){let n=i[t]?i[t]:void 0,a=r[t];if(!a)return;let o=e[t],l=new Dr(o.r,o.g,o.b,o.a),h=n?typeof n=="string"?s.getColor(n).clone():new Dr(n.r,n.g,n.b,n.a):l.clone(),u=typeof a=="string"?s.getColor(a).clone():new Dr(a.r,a.g,a.b,a.a);return h.equals(u)?void 0:{update:d=>{l.lerpColors(h,u,d);let c=Ft.lerp(h.a,u.a,d);l.a=c,e[t]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(u)}}}function Ip(t,e,i,r,s){return typeof e[t]=="number"?xa(t,e,i??{},r,s):Array.isArray(e[t])?lG(t,e,i??{},r,s):void 0}function rOt(t,e){if(t)for(let[i,r]of Object.entries(e)){let s=t[i];if(Array.isArray(s)&&Array.isArray(r)){let n=Math.min(s.length,r.length);for(let a=0;a<n;a++)s[a]=r[a]}else t[i]=r}}function wP(t,e,i,r){let s={};if(!e||!i)return s;for(let n of t){let a=e[n],o=i[n];if(typeof a=="number"&&typeof o=="number")s[n]=Ft.lerp(a,o,r);else if(Array.isArray(a)&&Array.isArray(o)){let l=Math.min(a.length,o.length);s[n]=Array.from({length:l},(h,u)=>Ft.lerp(a[u],o[u],r))}}return s}new P,new Fi;var Rct=[["radial",M4],["linear",A4],["grid",C4],["toObject",E4],["randomnessObject",P4]];function mwt(t,e,i,r,s){let n=t.getValue(r);if(n!==void 0){if(r==="colors")return function(a,o,l,h="colors"){if(!a.hasValue(h)||!(h in l))return;let u=[],d=a.getValue(h),c=o?o[h]:d.map(m=>m.toArray()),p=l[h];for(let m=0;m<d.length;++m){let f=[...c[m]],g=[...p[m]];US.isEqual(f,g)||u.push({update:y=>{d[m].fromArray(US.lerp(f,g,y))},start:()=>{d[m].fromArray(f)},end:()=>{d[m].fromArray(g)}})}return u.length?u:void 0}(t,e,i,r);if(Array.isArray(n))return r==="steps"?function(a,o,l,h="steps"){if(!a.hasValue(h)||!(h in l))return;let u=[],d=a.getValue(h),c=o?o[h]:d,p=l[h];return qg(c,p)||u.push({update:m=>{let f=[...d];for(let g=0;g<d.length;++g){let y=c[g],v=p[g];f[g]=Ft.lerp(y,v,m)}a.setValue(h,f)},start:()=>{a.setValue(h,c)},end:()=>{a.setValue(h,p)}}),u.length?u:void 0}(t,e,i,r):void 0;if(typeof n=="number")return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=o?o[h]:a.getValue(h),c=l[h],p=typeof d=="string"?Number(u.getVariable(d)??0):d,m=typeof c=="string"?Number(u.getVariable(c)??0):c;return{update:f=>{a.setValue(h,Ft.lerp(p,m,f))},start:()=>{a.setValue(h,p)},end:()=>{a.setValue(h,m)}}}(t,e,i,r,s);if(typeof n!="boolean"){if(n instanceof Z)return function(a,o,l,h){if(!a.hasValue(h)||!(h in l))return;let u=a.getValue(h),d=o?new Z().fromArray(o[h]):u.clone(),c=new Z().fromArray(l[h]);return d.equals(c)?void 0:{update:p=>{u.lerpVectors(d,c,p)},start:()=>{u.copy(d)},end:()=>{u.copy(c)}}}(t,e,i,r);if(n instanceof P)return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=a.getValue(h),c=o?o[h]:void 0,p=l[h],m=c?H5(new P,c,u):d.clone(),f=H5(new P,p,u);return m.equals(f)?void 0:{update:g=>{d.lerpVectors(m,f,g)},start:()=>{d.copy(m)},end:()=>{d.copy(f)}}}(t,e,i,r,s);if(n instanceof Dr)return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=o?o[h]:void 0,c=l[h],p=a.getValue(h),m=d?typeof d=="string"?u.color(d).clone():new ae().setRGB(d.r,d.g,d.b):p.clone(),f=typeof c=="string"?u.color(c).clone():new Dr(c.r,c.g,c.b,c.a);if(m.equals(f))return;let g=p.clone();return{update:y=>{a.getValue(h)!==g&&a.setValue(h,g),g.lerpColors(m,f,y)},start:()=>{g.copy(m)},end:()=>{g.copy(f)}}}(t,e,i,r,s);if(n instanceof ae)return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=o?o[h]:void 0,c=l[h],p=a.getValue(h),m=d?typeof d=="string"?u.color(d).clone():new ae().setRGB(d.r,d.g,d.b):p.clone(),f=typeof c=="string"?u.color(c).clone():new ae().setRGB(c.r,c.g,c.b);if(m.equals(f))return;let g=p.clone();return{update:y=>{a.getValue(h)!==g&&a.setValue(h,g),g.lerpColors(m,f,y)},start:()=>{g.copy(m)},end:()=>{g.copy(f)}}}(t,e,i,r,s);if("isTexture"in n)return function(a,o,l,h="texture",u){if(!a.hasValue(h)||!(h in l))return;let d=T=>Number(typeof T=="string"?u?.getVariable(T)??0:T??0),c=a.getNode("rotation"),p=o?d(o[h]?.rotation):(c?.value??0)*Ft.RAD2DEG,m=d(l[h]?.rotation);if(c&&Math.abs(p-m)>1e-9)return{update:T=>{c.value=Ft.lerp(p,m,T)*Ft.DEG2RAD},start:()=>{c.value=p*Ft.DEG2RAD},end:()=>{c.value=m*Ft.DEG2RAD}};let f=function(T){let C=T.getNode("mat");if(typeof C?.updateMatrix=="function")return C;let M=T.getValue("mat");return typeof M?.updateMatrix=="function"?M:void 0}(a);if(!f)return;let g=o?o[h]:f,y=l[h],v=[...g.repeat],b=[...g.offset],_=[...y.repeat],x=[...y.offset],S=g.rotation??0,w=y.rotation??0;return Hu.isEqual(v,_)&&Hu.isEqual(b,x)&&S===w?void 0:{update:T=>{f.repeat=Hu.lerp(v,_,T),f.offset=Hu.lerp(b,x,T),f.rotation=Ft.lerp(S,w,T),f.updateMatrix()},start:()=>{f.repeat=[...v],f.offset=[...b],f.rotation=S,f.updateMatrix()},end:()=>{f.repeat=[..._],f.offset=[...x],f.rotation=w,f.updateMatrix()}}}(t,e,i,r,s)}}}function Dct(t,e,i,r){let s=[],n=e.layers?um(e,r):t.transparent,a=um(i,r);s.push(function(o,l,h){let u=l||h;return{update:d=>{o.setTransparent(d===1?h:u)}}}(t,n,a)),function(o,l,h){let u=o.ensureRainbowNoiseCompiled;if(typeof u=="function")for(let d of[...o.layers]){if(d.type!=="rainbow")continue;let c=l.layers?.data(d.uuid),p=h.layers.data(d.uuid);(yv(c?.noiseStrength)||yv(p?.noiseStrength))&&u.call(o,d.uuid)}}(t,e,i);for(let o of t.layers){let l=e.layers?.data(o.uuid),h=i.layers.data(o.uuid);if(!h||o.type!=="light"&&(!(o.visible??1)||!(h.visible??1)))continue;let u=yT[o.type]??[],d=o.getNames().filter(c=>!u.includes(c)&&!tD.some(p=>c.includes(p)));for(let c of d)try{let p=mwt(o,l,h,c,r);p&&(Array.isArray(p)?s.push(...p):s.push(p))}catch(p){console.error(`lerpMaterial: unexpected material layer for ${c}`,p)}}return s}function Oct(t,e,i,r,s,n){let a=mwt(e,i,r,t,n);!a||(Array.isArray(a)?a.forEach(o=>o.update(s)):a.update(s))}function Hd(t,e,i){!t||(t[e]={...t[e],...i})}function sOt(t,e,i,r,s,n,a){let o=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(t.on){case"position":case"scale":{let l=Du(t.track,i);if(!l)return;let h=bP(l.from,l.to,l.t);return e[t.on][t.axis]=h,Hd(n,t.on,{[t.axis]:h}),void o()}case"rotation":{let l=Du(t.track,i);if(!l)return;let h=bP(l.from,l.to,l.t);return e.rotation[t.axis]=h*Ft.DEG2RAD,Hd(n,"rotation",{[t.axis]:h}),void o()}case"shapeSize":{let l=Du(t.track,i);if(!(l&&e instanceof Ur))return;let h=bP(l.from,l.to,l.t);return e.userData.value={...e.userData.value,[t.axis]:h},Hd(n,"shapeSize",{[t.axis]:h}),a.size=!0,a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"opacity":{let l=Du(t.track,i);if(!l||!(e instanceof Fs)||Array.isArray(e.material))return;let h=e.material.getLayersOfType("light")[0];if(h===void 0)return;let u=Ft.lerp(l.from,l.to,l.t),d=e.material,c=l.to>=1&&(l.t===1||l.from>=1);return d.setTransparent(!c||um(d.data,r.shared),r.scene),Oct("alphaOverride",h,{alphaOverride:u},{alphaOverride:u+1},0,r.shared),n&&(n.opacity=u),void(a.render=!0)}case"material":{let l=Du(t.track,i);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:h}=t,u={};for(let d in h.data){if(!(d in l.from)||!(d in l.to))continue;let c=hG(l.from[d],l.to[d],l.t,s);if(c===void 0)continue;u[d]=c;let p=h.getValue(d);p!==void 0&&(d==="alpha"&&typeof p=="number"&&p>0&&e instanceof Fs&&!Array.isArray(e.material)&&(e.material.transparent=!0),Oct(d,h,l.from,l.to,l.t,r.shared))}return Hd(n,"material",{[h.uuid]:u}),void(a.render=!0)}case"light":{let l=Du(t.track,i);if(!l||!(e instanceof ob||e instanceof xT||e instanceof lb))return;let h=hG(l.from,l.to,l.t,s);return e[t.field]=h,Hd(n,"light",{[t.field]:h}),void(a.render=!0)}case"camera":{let l=Du(t.track,i);if(!(l&&e instanceof Us))return;let h=bP(l.from,l.to,l.t);return e[t.field]=h,void Hd(n,"camera",{[t.field]:h})}case"cloner":{let l=Du(t.track,i);if(!l)return;let h=e.cloner?.parameters,u=function(d,c,p,m){if(!d)return{};let f=wP(["count"],c,p,m);f.count!==void 0&&(f.count=Math.trunc(f.count));for(let[g,y]of Rct){if(!d[g])continue;let v=wP(y,c[g],p[g],m);Object.keys(v).length&&(f[g]=v)}return f}(h,l.from,l.to,l.t);return function(d,c){if(d){c.count!==void 0&&(d.count=c.count);for(let[p]of Rct){let m=c[p];m&&rOt(d[p],m)}}}(h,u),Hd(n,"cloner",u),a.cloner=!0,a.boolean=!0,void(a.render=!0)}case"pathExtrusion":{let l=Du(t.track,i);if(!l||!oD(e))return;let h=wP(N4,l.from,l.to,l.t),u=e.geometry.userData.parameters;return u.extrusion={...u.extrusion,...h},Hd(n,"pathExtrusion",h),e.updateGeometryInteractions({extrusion:{...u.extrusion}},r.shared),a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"pathSnapping":{let l=Du(t.track,i);if(!l)return;let h=e,u=wP(zft,l.from,l.to,l.t);return h.userData.pathSnapping={...h.userData.pathSnapping,...u},Hd(n,"pathSnapping",u),h.updatePathSnapping(h.userData.pathSnapping),void(a.render=!0)}}}function hG(t,e,i,r){if(typeof t=="string"&&r&&(t=r.color(t)),typeof e=="string"&&r&&(e=r.color(e)),typeof t=="number")return Ft.lerp(t,e,i);if(Hi.is(t))return Hi.lerp(t,e,i);if(Ks.is(t))return Ks.lerp(t,e,i);if(Array.isArray(t))return(t.length>e.length?e:t).map((s,n)=>{if(Array.isArray(s)){let a=t[n].length>e[n].length?e[n].length:t[n].length;return(a===4?US:a===3?ym:Hu).lerp(t[n],e[n],i)}return Ft.lerp(t[n],e[n],i)});if(typeof t=="object"&&t!==null){let s={};for(let n in t){let a=hG(t[n],e[n],i,r);a!==void 0&&(s[n]=a)}return s}}Be(),ht(),kc(),yD(),nb(),ir(),ir(),ts(),Be(),Qh(),ts(),oa(),Qh(),bT(),_o(),d0(),ht(),Be(),ht(),_T(),ts(),ir(),ts(),ht(),Dm(),ht();var T8=new P,Ict=new Fi;function nOt(t,e,i,r,s){let n=[];return t.data.visible&&n.push(...function(a,o,l,h,u){let d,c,p,m,f,g,y,v=[];if(Go(a)?(d=_P("position",a,o,l,u),d&&v.push(d),p=xa("rotation",a,o,l,u),p&&v.push(p),m=_P("shear",a,o,l,u),m&&v.push(m)):(y={slide:o.pathSnapping?.slide??a.updatedPathSnapping?.slide??a.dataPatched.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.updatedPathSnapping?.offset??a.dataPatched.pathSnapping?.offset??0},f=xa("slide",y,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,u),f&&v.push(f),g=xa("offset",y,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,u),g&&v.push(g),!f&&!g&&(d=Ect("position",a,o,l,u),d&&v.push(d),c=Ect("scale",a,o,l,u),c&&v.push(c),p=function(b,_,x,S,w){let T=_?.rotation?_.rotation.map(I=>(typeof I=="string"?Number(w.getVariable(I)??0):I)*Ft.DEG2RAD):void 0,C=x.rotation?.map(I=>(typeof I=="string"?Number(w.getVariable(I)??0):I)*Ft.DEG2RAD);if(!C)return;let M=T?new P().fromArray(T):new P().setFromEuler(b.rotation),A=new P().fromArray(C);if(M.equals(A))return;let R=T8.subVectors(A,M);if(S&&R.toArray().every(I=>Math.abs(I)<2*Math.PI)){let I=new Te().setFromEuler(Ict.setFromVector3(M)),O=new Te().setFromEuler(Ict.setFromVector3(A));return{update:B=>{(function(V,z,k,L){if(L===0)return k.copy(V);if(L===1)return k.copy(z);let H=V.w*z.w+V.x*z.x+V.y*z.y+V.z*z.z;if(H>=1)return k.copy(V);let W=1-H*H;if(W<=Number.EPSILON){let pt=1-L;return k.w=pt*V.w+L*z.w,k.x=pt*V.x+L*z.x,k.y=pt*V.y+L*z.y,k.z=pt*V.z+L*z.z,k.normalize(),k}let X=Math.sqrt(W),nt=Math.atan2(X,H),st=Math.sin((1-L)*nt)/X,yt=Math.sin(L*nt)/X;k.w=V.w*st+z.w*yt,k.x=V.x*st+z.x*yt,k.y=V.y*st+z.y*yt,k.z=V.z*st+z.z*yt})(I,O,b.quaternion,B)},start:()=>{b.rotation.setFromVector3(M)},end:()=>{b.rotation.setFromVector3(A)}}}return{update:I=>{T8.lerpVectors(M,A,I),b.rotation.setFromVector3(T8)},start:()=>{b.rotation.setFromVector3(M)},end:()=>{b.rotation.setFromVector3(A)}}}(a,o,l,h,u),p&&v.push(p),m=function(b,_,x){let S=_.shear,w=x.shear;if(!w)return;let T=b.shearMatrix,C=S??[T.elements[4],T.elements[8],T.elements[1],T.elements[9],T.elements[2],T.elements[6]],M=w;return C.every((A,R)=>A===M[R])?void 0:{update:A=>{C.forEach((R,I)=>{let O=Ft.lerp(R,M[I],A);T.elements[wl.INDEX_MAP[I]]=O})},start:()=>{C.forEach((A,R)=>{T.elements[wl.INDEX_MAP[R]]=A})},end:()=>{M.forEach((A,R)=>{T.elements[wl.INDEX_MAP[R]]=A})}}}(a,o,l),m&&v.push(m))),d||c||p||m||f||g){let b=Go(a)?()=>{a.updateWorldMatrix(!0,!1,!0),a.resetBBoxNeedsUpdate()}:()=>{a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldRigid()),a.parent?.matrixWorldFusedFalse&&(a.matrixWorld.multiplyMatrices(a.parent.matrixWorldFusedFalse,a.matrix),a.matrixWorldNeedsUpdate=!1),Hh(a)&&$u(a.parent)&&a.invalidateDownstreamBooleanData(!0),a.updatePathSnapping(Object.assign({},o.pathSnapping,y))};v.push({update:b,start:b,end:b})}return v}(t,e,i,s,r.shared)),Go(t)?n.push(...function(a,o,l,h,u){let d,c,p,m,f,g,y,v,b,_,x,S,w,T,C,M=[];if("width"in a&&(d=xa("width",a,o,l,u),d&&M.push(d)),"height"in a&&(c=xa("height",a,o,l,u),c&&M.push(c)),a instanceof Yn||a instanceof Qu){let A={...o.fill},R={...l.fill};A.enabled!==void 0&&A.enabled!==R.enabled&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.fill.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),p=xP("color",a.fill,A,R,u),p&&M.push(p)}if(a instanceof Yn){let A={...o.stroke},R={...l.stroke};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.stroke.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),m=xP("color",a.stroke,A,R,u),m&&M.push(m),f=xa("thickness",a.stroke,A,R,u),f&&M.push(f)}if(a instanceof Yn){let A={...o.dropShadow},R={...l.dropShadow};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.dropShadow.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),g=xP("color",a.dropShadow,A,R,u),g&&M.push(g),y=xa("blurRadius",a.dropShadow,A,R,u),y&&M.push(y),b=xa("spread",a.dropShadow,A,R,u),b&&M.push(b),v=_P("offset",a.dropShadow,A,R,u),v&&M.push(v)}if(a instanceof Yn){let A={...o.innerShadow},R={...l.innerShadow};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.innerShadow.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),_=xP("color",a.innerShadow,A,R,u),_&&M.push(_),x=xa("blurRadius",a.innerShadow,A,R,u),x&&M.push(x),w=xa("spread",a.innerShadow,A,R,u),w&&M.push(w),S=_P("offset",a.innerShadow,A,R,u),S&&M.push(S)}if(a instanceof Yn||a instanceof Qu){let A={...o.backgroundBlur},R={...l.backgroundBlur};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.backgroundBlur.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),T=xa("radius",a.backgroundBlur,A,R,u),T&&M.push(T)}if(a instanceof Yn){let A={...o.layerBlur},R={...l.layerBlur};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.layerBlur.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),C=xa("radius",a.layerBlur,A,R,u),C&&M.push(C)}if(a instanceof Qu||a instanceof MT){let A=lG("cornerRadius",a,o,l,u);A&&M.push(A)}return M}(t,e,i,0,r.shared)):(t.data.visible&&n.push(...function(a,o,l,h){let u=[];if(!("cloner"in l)||!a.cloner)return u;let d=a.cloner,c="cloner"in o?o.cloner:{},p=l.cloner;VU.forEach(b=>{let _;_=b==="count"?xa("count",d.parameters,c,p,h.shared,!0):Ip(b,d.parameters,c??{},p,h.shared),_&&u.push(_)});let m=function(b,_,x,S){if(b.parameters.type!=="radial")return;let w=_.radial,T=x.radial;if(!T)return;let C=b.parameters.radial,M=[];return M4.forEach(A=>{let R=Ip(A,C,w??{},T,S);R&&M.push(R)}),M}(d,c,p,h.shared);m?.length&&u.push(...m);let f=function(b,_,x,S){if(b.parameters.type!=="linear")return;let w=_.linear,T=x.linear;if(!T)return;let C=[],M=b.parameters.linear;return A4.forEach(A=>{let R=Ip(A,M,w??{},T,S);R&&C.push(R)}),C}(d,c,p,h.shared);f?.length&&u.push(...f);let g=function(b,_,x,S){if(b.parameters.type!=="grid")return;let w=_.grid,T=x.grid;if(!T)return;let C=[],M=b.parameters.grid;return C4.forEach(A=>{let R;R=A==="count"?lG(A,M,w??{},T,S,!0):Ip(A,M,w??{},T,S),R&&C.push(R)}),C}(d,c,p,h.shared);g?.length&&u.push(...g);let y=function(b,_,x,S){if(b.parameters.type!=="toObject")return;let w=_.toObject,T=x.toObject;if(!T)return;let C=[],M=b.parameters.toObject;return E4.forEach(A=>{let R;R=A==="count"?xa(A,M,w??{},T,S,!0):Ip(A,M,w??{},T,S),R&&C.push(R)}),C}(d,c,p,h.shared);y?.length&&u.push(...y);let v=function(b,_,x,S){if(!b.parameters.randomness)return;let w=_.randomnessObject,T=x.randomnessObject;if(!T)return;let C=[],M=b.parameters.randomnessObject;return P4.forEach(A=>{let R=Ip(A,M,w??{},T,S);R&&C.push(R)}),C}(d,c,p,h.shared);return v?.length&&u.push(...v),u.length&&u.push({update:()=>{d.update(h)}}),u}(t,e,i,r)),t instanceof Fs?(t instanceof Ur&&t.data.visible&&n.push(...function(a,o,l,h){let u=[];if(!("geometry"in l)||Ic(a))return u;let d=a.geometry.userData.parameters,c="geometry"in o?o.geometry:{},p=l.geometry;if(a instanceof Fv){let m=function(f,g,y,v){if(y.scaleBaked===void 0)return;let b=(g.scaleBaked??f.appliedGeometrySize??f.data.geometry.scaleBaked).map(S=>typeof S=="string"?Number(v.shared.getVariable(S)??0):S),_=y.scaleBaked.map(S=>typeof S=="string"?Number(v.shared.getVariable(S)??0):S);if(ym.isEqual(b,_))return;let x=[];return x.push({update:S=>{f.updateGeometryInteractions({scaleBaked:[Ft.lerp(b[0],_[0],S),Ft.lerp(b[1],_[1],S),Ft.lerp(b[2],_[2],S)]},v.shared),f.invalidateDownstreamBooleanData(),f.refreshAttachedClonersInteractions(v)},start:()=>{f.updateGeometryInteractions({scaleBaked:b},v.shared),f.invalidateDownstreamBooleanData(),f.refreshAttachedClonersInteractions(v)},end:()=>{f.updateGeometryInteractions({scaleBaked:_},v.shared),f.invalidateDownstreamBooleanData(),f.refreshAttachedClonersInteractions(v)}}),x}(a,c,p,h);m&&u.push(...m)}else{let m={},f=a.appliedGeometrySize;if(Object.assign(m,mU(d,XP),f?{width:f[0],height:f[1],depth:f[2]}:{},mU(c,XP)),XP.forEach(g=>{let y=Ip(g,m,c,p,h.shared);y&&u.push(y)}),oD(a)){Object.assign(m,{extrusion:{...d.extrusion}});let g=function(y,v,b,_){if(!b.extrusion)return;let x=y.extrusion,S=v.extrusion??{},w=b.extrusion,T=[];return N4.forEach(C=>{let M=Ip(C,x,S,w,_);M&&T.push(M)}),T}(m,c,p,h.shared);g&&u.push(...g)}u.length&&u.push({update:g=>{a.updateGeometryInteractions(m,h.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(h)},start:g=>{a.updateGeometryInteractions(m,h.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(h)},end:g=>{a.updateGeometryInteractions(m,h.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(h)}})}return u}(t,e,i,r)),t.data.visible&&!(t instanceof vo&&t.materialOverride)&&n.push(...function(a,o,l,h){let u=[];if(Array.isArray(a.material)){if(!("materials"in l)||!l.materials)return u;let d="materials"in o&&o.materials?o.materials:[],c=l.materials;a.material.forEach((p,m)=>{if(!c[m])return;let f=d[m]??{},g=c[m];typeof f=="string"||typeof g=="string"||u.push(...Dct(p,f,g,h))})}else{if(!("material"in l)||!l.material)return u;let d="material"in o&&o.material?o.material:{},c=l.material;if(typeof d=="string"||typeof c=="string")return u;u.push(...Dct(a.material,d,c,h))}return u}(t,e,i,r.shared))):s5.is(t)?t.data.visible&&n.push(...function(a,o,l,h){let u=[];if(l.intensity!==void 0){let d=xa("intensity",a,o,l,h);d&&u.push(d)}if(l.color!==void 0){let d=function(c,p,m,f,g){let y=m[c]?m[c]:void 0,v=f[c];if(!v)return;let b=p[c],_=y?typeof y=="string"?g.getColor(y).clone():new ae().setRGB(y.r,y.g,y.b):b.clone(),x=typeof v=="string"?g.getColor(v).clone():new ae().setRGB(v.r,v.g,v.b);if(_.equals(x))return;let S=b.clone();return{update:w=>{S.lerpColors(_,x,w),p[c]?.copy?.(S)},start:()=>{S.copy(_)},end:()=>{S.copy(x)}}}("color",a,o,l,h);d&&u.push(d)}return u}(t,e,i,r.shared)):t instanceof Us&&n.push(...function(a,o,l,h){let u=[],d=a.cameraType==="OrthographicCamera"?o.orthographic?.zoom:o.perspective?.zoom,c=a.cameraType==="OrthographicCamera"?l.orthographic?.zoom:l.perspective?.zoom;if(c!==void 0){let p=d??a.zoom,m=c;p!==m&&u.push({update:f=>{a.zoom=Ft.lerp(p,m,f),a.updateProjectionMatrix()},start:()=>{a.zoom=p,a.updateProjectionMatrix()},end:()=>{a.zoom=m,a.updateProjectionMatrix()}})}if(l.targetOffset!==void 0){let p=xa("targetOffset",a,o,l,h);p&&u.push(p)}return u}(t,e,i,r.shared))),n.length?{update:a=>{n.forEach(o=>o.update(a))},start:a=>{n.forEach(o=>o.start?.(a))},end:a=>{n.forEach(o=>o.end?.(a))}}:void 0}var fwt={type:"beginState"};function gwt(t){if(t.easing===5){let{control1:e,control2:i}=t;return{easing:5,control1:e??kv.defaultData.control1,control2:i??kv.defaultData.control2}}if(t.easing===6){let{mass:e,stiffness:i,damping:r,velocity:s}=t;return{easing:6,mass:e??sm.defaultData.mass,stiffness:i??sm.defaultData.stiffness,damping:r??sm.defaultData.damping,velocity:s??sm.defaultData.velocity}}return{easing:t.easing}}function ywt(t){return{delay:t.delay,delayDirection:t.delayDirection??"start-end",direction:t.direction??"normal",repeat:t.repeat}}var vwt={type:"completeState",isfromEntity:!1};function CS(t,e){let i,r;if(typeof e=="string"?(i=e,r=t.states?.[i]):e===null&&(i=null,r=t.data),i!==void 0&&r!==void 0)return{id:i,data:r}}var aOt=["position","rotation","scale","shear"],uG=new Set,dG=class{constructor(t,e,i,r,s,n,a,o={},l=()=>uG){this.object=t,this.fromRef=e,this.toRef=i,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.page=a,this.hooks=o,this.inert=l,this.builtReversed=!1,this.startStateId=null,this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=Go(this.object)?null:this.object.transitionState.state,this.callback=nOt(this.object,{},function(h,u){if(u.size===0)return h;let d={...h};for(let c of u)delete d[c];return d}(this.end.data,this.inert()),{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)},this.onChange=h=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(h),this.object.requestRender()),this.writeState(h)},this.runner=new awt(function(h){return{duration:h.duration,ease:gwt(h),...ywt(h)}}(r),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let r=CS(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!r)throw new Error("Missing property");this.from=r}else{let r=CS(this.object,t);if(!r)throw new Error("Missing property");this.from=r}if(e===void 0)throw new Error("Missing property");let i=CS(this.object,e);if(!i)throw new Error("Missing property");this.to=i,this.buildCallback()}refresh(){this.buildCallback()}get endpointData(){return[this.from.data,this.to.data]}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||Go(this.object))return;let e=t===1,i=t>.5?this.targetStateId:this.startStateId,r=this.object.transitionState;r.settled===e&&r.state===i||(this.object.transitionState={settled:e,state:i},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=i,this.object.dispatchEvent({type:"transitionState",settled:e,state:i}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:i}),this.object.traverseEntity(s=>{s!==this.object&&s instanceof Us&&s.dispatchEvent(e?vwt:fwt)}),e?this.hooks.onComplete?.(i):this.hooks.onBegin?.(i))}};Qh();var cG=new Map,ES=new Map,Yl=class extends En{constructor(t,e,i,r,s,n){super(),this.id=t,this.data=e,this.scene=i,this.sharedAssets=r,this.object=s,this.eventType=n,this.evaluators=[],this.elapsed=0,this.lastTime=null,this.direction=1,this._playing=!1,this._finished=!1,this.hasPlayedOnce=!1,this.pauseOnNextCycleEnd=!1,this.lastCycleIndex=0;try{let a=s0.findTimeline(this.scene.data.objects,this.data.timeline),o=a.duration;this.animatedObjectIds=Object.keys(a.objectTimelines),this.animatedObjectIds.forEach(l=>{let h=this.scene.find(l);if(!h)return;let u=a.objectTimelines[l];!u||this.evaluators.push(function(d,c,p,m,f){let g=function(y,v){let b=[];return vm.groupKeyframes(v.keyframes).forEach(_=>{let x=_.path?.[0],S=_.path[1],w=()=>g1(_.keyframes,T=>T.value);switch(x){case"position":case"rotation":case"scale":return void(S&&jS.includes(S)&&b.push({on:x,axis:S,track:w()}));case"shape size":return void(S&&jS.includes(S)&&"geometry"in y&&b.push({on:"shapeSize",axis:S,track:w()}));case"path extrusion":return void(oD(y)&&b.push({on:"pathExtrusion",track:g1(_.keyframes,T=>T.value)}));case"path snapping":return void(y.data.pathSnapping&&b.push({on:"pathSnapping",track:g1(_.keyframes,T=>T.value)}));case"material":return void(y.type==="Mesh"&&"material"in y&&function(T,C){let M=r5(T.material)?T.material:void 0,A=C.layerId;if(!M||!A)return[];let R=C.keyframes.some(k=>yv(k.data.value?.noiseStrength)),I=M.ensureRainbowNoiseCompiled,O=k=>{R&&typeof I=="function"&&I.call(M,k)},B=k=>"data"in k?[{on:"material",layer:k,track:g1(C.keyframes,L=>L.value)}]:[];O(A);let V=M.getLayerByUuid(A);if(V)return B(V);let z=C.path[1];for(let k of M.getLayersOfType(z))O(k.uuid);return(M.getLayersOfType(z)??[]).flatMap(B)}(y,_).forEach(T=>b.push(T)));case"opacity":return void(y.type==="Mesh"&&"material"in y&&b.push({on:"opacity",track:w()}));case"cloner":return void b.push({on:"cloner",track:g1(_.keyframes,T=>T.value)});case"camera":return void(y instanceof Us&&b.push({on:"camera",field:"zoom",track:w()}));case"light":return void((y instanceof ob||y instanceof xT||y instanceof lb)&&b.push({on:"light",field:_.path[1],track:g1(_.keyframes,T=>T.value)}))}}),b}(d,c);return{duration:p,evaluate(y,v){d.resetBBoxNeedsUpdate();let b={transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1};for(let _ of g)sOt(_,d,y,m,f,v,b);(function(_,x,S){if(x.size&&_ instanceof Ur){let{x:w,y:T,z:C}=_.userData.value;_.updateGeometryInteractions({width:w,height:T,depth:C},S.shared)}x.cloner&&_.cloner?.update(S),x.transform&&_.updateMatrix(),x.bounds&&_.resetBBoxNeedsUpdate(),x.boolean&&_ instanceof Ur&&_.invalidateDownstreamBooleanData(),x.render&&_.dispatchEvent({type:"requestRender"})})(d,b,m)},invalidate(){for(let y of g)iOt(y.track)}}}(h,{...u},o,{scene:i,shared:r},this.sharedAssets))}),this.schedule=new W5t(function(l,h){return{duration:h,delay:_a(l.delay/1e3),delayDirection:l.delayDirection??"start-end",direction:l.direction??"normal",repeat:l.repeat}}(this.data,o))}catch{throw new Error("Missing property")}s&&(ES.has(s.uuid)?ES.get(s.uuid).push(this):ES.set(s.uuid,[this])),cG.set(t,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(t){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(t-this.lastTime)*this.direction)),this.lastTime=t,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0)return void this.pause();let t=this.schedule.resolve(this.elapsed);if(t){if(t.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=t.cycleIndex,this.pauseOnNextCycleEnd))return this.pauseOnNextCycleEnd=!1,void this.pause();for(let e of this.evaluators)e.evaluate(t.localTime)}else this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(t=>{let e=this.scene.find(t);e instanceof Us&&e.dispatchEvent(vwt)})}startTicking(){this._playing=!0,this.lastTime=null;for(let t of this.evaluators)t.invalidate();Ls.add(this)}play(){let t=this.eventType!==void 0&&CU(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&CU(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!t||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(e=>{let i=this.scene.find(e);i instanceof Us&&i.dispatchEvent(fwt)}),!t&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,Ls.remove(this)}rewind(){this.pause(),this.elapsed=0,this.lastCycleIndex=0}stop(){this.rewind(),this.applyAtElapsed(),this._finished=!1}pauseAndRewind(){this.rewind(),this.direction=1,this.pauseOnNextCycleEnd=!1,this._finished=!1}seek(t){let e=this.schedule.totalDuration;this.elapsed=t*(Number.isFinite(e)?e:this.schedule.effectiveCycleDuration);for(let i of this.evaluators)i.invalidate();this.applyAtElapsed()}toggle(t){let e=t??this.direction===-1;this._playing&&this.direction===(e?1:-1)?e&&(this.pauseOnNextCycleEnd=!1):(e?(this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.pauseOnNextCycleEnd=!1):(this.direction=this.schedule.resolve(this.elapsed)?.isReverse?1:-1,this.pauseOnNextCycleEnd=!0),this.startTicking())}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},oOt=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>{i[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(i=>{i[this.data.interaction]()}))}getTimelineActions(t){let e=cG.get(t);return e?[e]:[...cG.values()].filter(i=>i.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=ES.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllTimelines(){let t=[...ES.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},lOt=class{constructor(t,e,i,r,s,n,a){this.data=e,this.sharedAssets=r,this.actionCondition=a;let o="interaction"in e?e.interaction:"play";if(o==="play"||o===void 0)this.interaction=new Yl(t,e,i,r,s,n);else{if(o!=="pause"&&o!=="stop")throw new Error("Missing property");this.interaction=new oOt(e)}}get playing(){return this.interaction instanceof Yl&&this.interaction.playing}get finished(){return!(this.interaction instanceof Yl)||this.interaction.finished}get paused(){return!(this.interaction instanceof Yl)||this.interaction.paused}branchTaken(){return Ir(this.sharedAssets,this.actionCondition)}play(){return!!this.branchTaken()&&(this.interaction instanceof Yl?this.interaction.play():void this.interaction.dispatch())}get animatedObjectIds(){return this.interaction instanceof Yl?this.interaction.animatedObjectIds:[]}pauseAndRewind(){this.interaction instanceof Yl&&this.interaction.pauseAndRewind()}stop(){this.interaction instanceof Yl&&this.interaction.stop()}seek(t){!this.branchTaken()||this.interaction instanceof Yl&&this.interaction.seek(t)}toggle(t){!this.branchTaken()||(this.interaction instanceof Yl?this.interaction.toggle(t):this.interaction.dispatch())}playFromCurrent(){!this.branchTaken()||(this.interaction instanceof Yl?this.interaction.playFromCurrent():this.interaction.dispatch())}dispatchConditional(){this.playFromCurrent()}reverseFromCurrent(){!this.branchTaken()||this.interaction instanceof Yl&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};function Nct(t){let e=t.tweens[0]?.data;return{delay:e?.delay??t.delay,delayDirection:e?.delayDirection??"start-once",direction:e?.direction??t.direction,repeat:e?.repeat??t.repeat}}Ni(),eo("TimelineAnimation",({id:t,data:e,page:i,shared:r,object:s,eventType:n,actionCondition:a})=>new lOt(t,e,i.scene,r,s,n,a)),Nr("timeline"),ts(),Be(),ht(),Qh();var hOt={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},uOt=class extends En{constructor(t,e,i,r,s,n,a){if(super(),this.eventType=t,this.data=e,this.page=i,this.shared=r,this.condition=s,this.runModeOverride=n,this.tweens=[],this.hasPlayedOnce=!1,this.inert=uG,!e.object)throw new Error("Missing property");let o=this.page.scene.findFrom(e.object,a)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,e.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}get claimTime(){return this.runner?.claimTime}get contested(){let t=this.object.previousAction;return t!==null&&t!==this&&t.animating}init(){this.initialCurrentState=CS(this.object,this.object.currentState).id,this.build()}shouldReinit(){return!!Ir(this.shared,this.condition)||!(this.animating&&!this.loopsForever)}get loopsForever(){return Nct(this.data).repeat===-1||this.data.tweens.some((t,e)=>e>0&&t.data.repeat===-1)}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:CU(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}get opensOnCurrent(){return this.data.tweens[0].data.state===void 0&&this.runMode!=="Toggle"}build(){let t=this.data.tweens,e=[];try{let i=t[0].data.state;i!==void 0&&e.push(new dG(this.object,i,i,hOt,this.shared,this.data.allowSlerp??!1,this.page,{},()=>this.inert));for(let r=1;r<t.length;r++){let s=t[r-1],n=t[r];e.push(new dG(this.object,s.data.state===void 0?this.currentState:s.data.state,n.data.state===void 0?this.currentState:n.data.state,n.data,this.shared,this.data.allowSlerp??!1,this.page,{},()=>this.inert))}}catch(i){return void(i instanceof Error&&console.error(i.message))}this.tweens=e,this.syncInert(),this.runner=new nwt({...ywt(Nct(this.data)),runMode:this.runMode},e.map(i=>i.runner),{claim:i=>this.claimObject(i),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(t){if(this.object.previousAction===this)return!1;let e=this.object.previousAction;if(e?.animating===!0){if(t!==void 0&&e.claimTime!==void 0&&e.claimTime>t)return!1;e.pause()}return this.object.previousAction=this,!0}rebindTweens(){for(let t of this.tweens)try{t.rebind()}catch(e){e instanceof Error&&console.error(e.message)}this.syncInert(),this.object instanceof Us&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}syncInert(){let t=this.tweens.flatMap(e=>e.endpointData);if(this.opensOnCurrent&&t.length>0){let e=CS(this.object,this.object.currentState);e&&(t[0]=e.data)}this.inert=this.notMovedByOwner(function(e){if(e.length<2)return uG;let i=new Set,[r,...s]=e;for(let n of aOt){let a=r[n];a!==void 0&&s.every(o=>qg(o[n],a))&&i.add(n)}return i}(t));for(let e of this.tweens)e.refresh()}notMovedByOwner(t){let e=this.object.previousAction;if(t.size===0||e===null||e===this||!e.animating)return t;let i=e.leavesAlone;return new Set([...t].filter(r=>i.has(r)))}get leavesAlone(){return this.inert}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ls.remove(this)}branchTaken(){return Ir(this.shared,this.condition)}play(){if(!this.branchTaken()||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(Ls.time),this.runner.isPlaying&&Ls.add(this))}pause(){this.runner?.stop(),Ls.remove(this)}stop(){this.pause();let t=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;Go(this.object)?this.object.changeSelectedState(t,{shared:this.shared}):this.object.changeSelectedState(t,{scene:this.page.scene,shared:this.shared}),this.object.currentState=t}seek(t){if(Ir(this.shared,this.condition)===!1)return!1;this.runner?.seek(t)}playDirected(t){if(Ir(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(Ls.time,t),this.runner.isPlaying&&Ls.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};function dOt(t){let e=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+t,n=this._loopCount,a=r===c4;if(t===0)return n===-1||!a||1&~n?s:e-(s-i);if(r===V8){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(s>=e)s=e;else{if(!(s<0)){this.time=s;break t}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(n===-1&&(t>=0?(n=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=e||s<i){let o=Math.floor((s-i)/(e-i));s-=(e-i)*o,n+=Math.abs(o);let l=this.repetitions-n;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a||(s=t>0?e:i,this.repetitions===1&&(s=e)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let h=t<0;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(a&&!(1&~n))return e-(s-i)}return s}function bwt(t){let e=t?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(e?.length){let i=function(r){if(!r||r.length===0)return;let s;for(let n of r)n==n&&(s===void 0||n>s)&&(s=n);return s}(e);return i&&i>2?i:2}return 2}Be(),ht(),Be(),ht(),ht(),ir();var Bct=!1,ag=new WeakSet;function pG(t){return Array.isArray(t.identity)?t.identity[0]:t.uuid}function SP(t){return t.data.type==="Empty"&&Array.isArray(t.data.animations)?t.data.animations:[]}function cOt(t){return t===void 0||t===!0?-1:typeof t=="number"&&t>=1?Math.round(t)-1:0}function kct(t,e){return typeof t=="number"&&isFinite(t)&&t>0?t:e}function Vct(t,e){let i=t.filter(a=>a.info.id===e);if(i.length)return i;let r=t.filter(a=>a.info.name===e);if(r.length)return r;let s=e.toLowerCase(),n=t.filter(a=>a.info.name.toLowerCase()===s);return n.length?n:t.filter(a=>a.info.name.toLowerCase().endsWith("_"+s))}function zct(t){return`"${t.name}" has no imported animation clips \u2014 getAnimations() lists the objects that do.`}function Lct(t,e,i){if(!i)return`no clip "${t}" in the scene \u2014 getAnimations() lists them.`;let r=e.map(s=>`"${s.info.name}"`).join(", ");return`"${i.name}" has no clip "${t}" \u2014 its clips: ${r}.`}var pOt=class{constructor(t,e,i,r){this.scene=t,this.requestRender=e,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.clipDurations=new WeakMap,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&Array.isArray(s.data.animations)&&s.data.animations.forEach((n,a)=>{let o=n[0]+"/"+pG(s);if(this.clipIdToAction[o])return;let l=GP.parse(function(u){if(!Yft(u))return JSON.parse(u[2]);let[d,c,,p]=u,m=([g,y])=>p.data.slice(g,g+y),f={name:c,duration:p.duration,uuid:d,tracks:p.tracks.map(g=>{let y={name:g.name,type:g.type,times:m(g.times),values:g.list?[...g.list]:m(g.values)};return g.interpolation!==void 0&&(y.interpolation=g.interpolation),y})};return p.blendMode!==void 0&&(f.blendMode=p.blendMode),p.userData!==void 0&&(f.userData=p.userData),f}(n));s.animations[a]=l,this.clipDurations.set(l,l.duration);let h=this.mixer.clipAction(l,s);Bct===!1&&(Object.getPrototypeOf(h)._updateTime=dOt,Bct=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new hU(t),this.scene.traverseEntity(this.addClip)}rebindClips(){this.mixer.stopAllAction(),this.mixer=new hU(this.scene),this.clipIdToAction={},this.activeClip=null,this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let i=this.scene.find(e);if(!i)return;let r=i.animations.find(n=>n.uuid===t);if(!r)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[t],i.animations=i.animations.filter(n=>n.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.scene.markShadowsDirty(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=d4,t.timeScale=1,ag.delete(t)}),this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,i=this.clipIdToAction[e];if(i)return i.repetitions=t.repeat>=0?t.repeat+1:1/0,i.loop=t.direction!=="pingpong"&&t.direction!=="pingpong-rewind"||t.repeat===0?d4:c4,i.play(),i.paused=!1,this.requestRender(),i}startClip(t,e,{start:i=0,end:r,fade:s=0}){ag.delete(t),t.reset(),t.time=i;let n=t.getClip();n.start=i,n.duration=r??this.fullDuration(t),this.replaceOtherClips(t,e,s)}replaceOtherClips(t,e,i=0){Object.entries(this.clipIdToAction).forEach(([r,s])=>{s===t||r.split("/")[1]!==e||(ag.delete(s),i>0?s.fadeOut(i):s.stop())}),i>0&&t.fadeIn(i)}resumeClip(t){return!!ag.has(t)&&(ag.delete(t),t.paused=!1,t.play(),this.requestRender(),!0)}holdClips(t,e){let i=!1;Object.entries(this.clipIdToAction).forEach(([r,s])=>{let[n,a]=r.split("/");if(e(n,a))if(t==="pause"){if(!s.isRunning())return;s.paused=!0,ag.add(s)}else{if(!s.enabled||!s.isRunning()&&!s.paused)return;s.paused=!0,ag.delete(s),s.time=s.getClip().start??0,s._loopCount=-1,i=!0}}),i&&(this.needsUpdate=!0,this.scene.markShadowsDirty(),this.requestRender())}animatedEntity(t){let e;return t.traverseEntity(i=>!!e||(SP(i).length?(e=i,!0):void 0)),e||t.traverseEntityAncestors(i=>{!e&&SP(i).length&&(e=i)}),e}clips(t){return this.ownedClips(t).map(e=>e.info)}playClip(t,e,i={}){let r=this.ownedClips(t);if(!r.length)return{ok:!1,warning:zct(t)};let s=e===void 0?r[0]:Vct(r,e)[0];if(!s)return{ok:!1,warning:Lct(e,r,t)};let n=this.play({clipId:s.info.id,object:s.key,repeat:cOt(i.loop),direction:i.pingpong?"pingpong":"normal"});return n?(n.timeScale=kct(i.speed,1),this.resumeClip(n)||this.startClip(n,s.key,{fade:kct(i.fade,0)}),{ok:!0,clip:s.info}):{ok:!1,warning:`clip "${s.info.name}" has not loaded yet.`}}holdClipsOf(t,e,i){let r=this.ownedClips(e);if(e&&!r.length)return{ok:!1,warning:zct(e)};if(i!==void 0){let n=Vct(r,i);if(!n.length)return{ok:!1,warning:Lct(i,r,e)};r=n}let s=new Set(r.map(n=>n.info.id+"/"+n.key));return this.holdClips(t,(n,a)=>s.has(n+"/"+a)),{ok:!0}}ownedClips(t){let e=[];if(t){let i=this.animatedEntity(t);i&&e.push(i)}else this.scene.traverseEntity(i=>{SP(i).length&&e.push(i)});return e.flatMap(i=>{let r=pG(i),s={id:i.uuid,name:i.name};return SP(i).map(([n,a])=>{let o=this.clipIdToAction[n+"/"+r];return{info:{id:n,name:a,duration:o?Math.round(1e3*this.fullDuration(o))/1e3:0,object:s},key:r,action:o}})})}fullDuration(t){let e=t.getClip();return this.clipDurations.get(e)??e.duration}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.scene.markShadowsDirty(),this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return bwt(this.activeClip??void 0)}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let i=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(t/(this.maxFrames-1),.9999)*this.activeClip.duration),this.scene.markShadowsDirty(),this.requestRender(),i&&(this.clipIdToAction[e].paused=!0)}},M8="imported animations only play while the scene runs (Play mode, the Preview tab, exports).";function mOt(t,e){let i=s=>`no object named "${s}".`,r=(s,n,a)=>{let o=t();if(!o)return{ok:!1,warning:M8};if(n===void 0)return o.holdClipsOf(s,void 0,a);let l=e(n);return l?o.holdClipsOf(s,l,a):{ok:!1,warning:i(n)}};return{getAnimations:s=>{let n=t();if(!n)return{clips:[],warning:M8};if(s===void 0)return{clips:n.clips()};let a=e(s);return a?{clips:n.clips(a)}:{clips:[],warning:i(s)}},playAnimation:(s,n,a)=>{let o=t();if(!o)return{warning:M8};let l=e(s);if(!l)return{warning:i(s)};let h=o.playClip(l,n,a);return{clip:h.clip,warning:h.warning}},pauseAnimation:(s,n)=>r("pause",s,n),stopAnimation:(s,n)=>r("stop",s,n)}}var nv=new Map;function _wt(t,e){if(e===void 0)return;let i=t.scene.find(e);return i?pG(i):e}var $d=class extends En{constructor(t,e,i,r,s){super(),this.page=e,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let n=_wt(e,t.object)??t.object;this.data={...t,object:n};let a=this.animationControls.clipIdToAction[t.clipId+"/"+n];if(this.duration=a?.getClip()?.duration??1,this.data.crop2){let l=bwt(a?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=a?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=t.delay;let o=nv.get(n);o||(o=new Set,nv.set(n,o)),o.add(this)}get playing(){return this.threeAnimAction?.isRunning()??!1}cancelPending(){window.clearTimeout(this.timeoutId),delete this.timeoutId}resume(){let t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object];return!(!t||!this.animationControls.resumeClip(t)||(this.threeAnimAction=t,0))}play(t=!1){if(Ir(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.resume()||(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&this.animationControls.startClip(this.threeAnimAction,this.data.object,{start:this.leftFrameTime,end:this.rightFrameTime,fade:t?.2:0}))},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),this.cancelPending()}stop(){this.threeAnimAction?.fadeOut(.2)}seek(t){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Ft.clamp(this.threeAnimAction.time+1/60*t,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(t,e=!1){if(Ir(this.shared,this.condition)===!1)return!1;this.toggleIsForward=t??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing||this.resume()?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;let[i,r]=this.toggleIsForward?[this.leftFrameTime,this.rightFrameTime]:[this.rightFrameTime,this.leftFrameTime];this.threeAnimAction.time=i,this.threeAnimAction._clip.start=i,this.threeAnimAction._clip.duration=r,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.animationControls.replaceOtherClips(this.threeAnimAction,this.data.object,e?.2:0)},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();t&&(t.duration=this.duration),this.pause();let e=nv.get(this.data.object);e&&(e.delete(this),e.size===0&&nv.delete(this.data.object))}},fOt=class{constructor(t,e,i){this.data=t,this.page=e,this.animationControls=i,this.objectId=_wt(e,t.object)}dispatch(){this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{this.apply(),this.disposeDelay()},this.data.delay)):this.apply()}targetsClip(t,e){return!(this.objectId!==void 0&&e!==this.objectId||this.data.clipId&&t!==this.data.clipId)}apply(){(this.objectId!==void 0?[nv.get(this.objectId)]:[...nv.values()]).forEach(t=>{t?.forEach(e=>{this.targetsClip(e.data.clipId,e.data.object)&&e.cancelPending()})}),this.animationControls.holdClips(this.data.interaction,(t,e)=>this.targetsClip(t,e))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){this.disposeDelay()}},gOt=class{constructor(t,e,i,r,s){BU.isPause(t)?this.interaction=new fOt(t,e,i):this.interaction=new $d(t,e,i,r,s)}get data(){return this.interaction.data}get playing(){return this.interaction instanceof $d&&this.interaction.playing}play(t=!1){if(this.interaction instanceof $d)return this.interaction.play(t);this.interaction.dispatch()}pause(){this.interaction instanceof $d&&this.interaction.pause()}stop(){this.interaction instanceof $d&&this.interaction.stop()}seek(t){this.interaction instanceof $d&&this.interaction.seek(t)}toggle(t,e=!1){if(this.interaction instanceof $d)return this.interaction.toggle(t,e);this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof $d?this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof $d&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}},xwt=null;Ni(),xwt=dG,eo("Transition",({eventType:t,data:e,page:i,shared:r,actionCondition:s,runModeOverride:n,object:a})=>new uOt(t,e,i,r,s,n,a)),eo("Animation",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new gOt(t,e,i.animationControls,r,s)),Nr("transitions"),ir();var Fct=(t,e)=>e.some(i=>i instanceof RegExp?i.test(t):i===t),yOt=class{constructor({url:t,context:e},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:function(n,a){if(a={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...a},n=n.trim(),/^data:/i.test(n))return((u,{stripHash:d})=>{let c=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(u);if(!c)throw new Error(`Invalid URL: ${u}`);let{type:p,data:m,hash:f}=c.groups,g=p.split(";");f=d?"":f;let y=!1;g[g.length-1]==="base64"&&(g.pop(),y=!0);let v=(g.shift()||"").toLowerCase(),b=[...g.map(_=>{let[x,S=""]=_.split("=").map(w=>w.trim());return x==="charset"&&(S=S.toLowerCase(),S==="us-ascii")?"":`${x}${S?`=${S}`:""}`}).filter(Boolean)];return y&&b.push("base64"),(b.length>0||v&&v!=="text/plain")&&b.unshift(v),`data:${b.join(";")},${y?m.trim():m}${f?`#${f}`:""}`})(n,a);if(/^view-source:/i.test(n))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let o=n.startsWith("//");!o&&/^\.*\//.test(n)||(n=n.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,a.defaultProtocol));let l=new URL(n);if(a.forceHttp&&a.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(a.forceHttp&&l.protocol==="https:"&&(l.protocol="http:"),a.forceHttps&&l.protocol==="http:"&&(l.protocol="https:"),a.stripAuthentication&&(l.username="",l.password=""),a.stripHash?l.hash="":a.stripTextFragment&&(l.hash=l.hash.replace(/#?:~:text.*?$/i,"")),l.pathname){let u=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,d=0,c="";for(;;){let p=u.exec(l.pathname);if(!p)break;let m=p[0],f=p.index;c+=l.pathname.slice(d,f).replace(/\/{2,}/g,"/"),c+=m,d=f+m.length}c+=l.pathname.slice(d,l.pathname.length).replace(/\/{2,}/g,"/"),l.pathname=c}if(l.pathname)try{l.pathname=decodeURI(l.pathname)}catch{}if(a.removeDirectoryIndex===!0&&(a.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(a.removeDirectoryIndex)&&a.removeDirectoryIndex.length>0){let u=l.pathname.split("/"),d=u[u.length-1];Fct(d,a.removeDirectoryIndex)&&(u=u.slice(0,-1),l.pathname=u.slice(1).join("/")+"/")}if(l.hostname&&(l.hostname=l.hostname.replace(/\.$/,""),a.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(l.hostname)&&(l.hostname=l.hostname.replace(/^www\./,""))),Array.isArray(a.removeQueryParameters))for(let u of[...l.searchParams.keys()])Fct(u,a.removeQueryParameters)&&l.searchParams.delete(u);if(a.removeQueryParameters===!0&&(l.search=""),a.sortQueryParameters){l.searchParams.sort();try{l.search=decodeURIComponent(l.search)}catch{}}a.removeTrailingSlash&&(l.pathname=l.pathname.replace(/\/$/,""));let h=n;return n=l.toString(),!a.removeSingleSlash&&l.pathname==="/"&&!h.endsWith("/")&&l.hash===""&&(n=n.replace(/\/$/,"")),(a.removeTrailingSlash||l.pathname==="/")&&l.hash===""&&a.removeSingleSlash&&(n=n.replace(/\/$/,"")),o&&!a.normalizeProtocol&&(n=n.replace(/^http:\/\//,"//")),a.stripProtocol&&(n=n.replace(/^(?:https?:)?\/\//,"")),n}(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;aT?window.location.assign(this.url):(this.context==="tab"||Zmt&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(Ge[0]),Ge.splice(0,Ge.length))}},vOt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.shared=i,this.eventManager=r,this.condition=s}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Vq(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},1e3*(this.data.delay??0))}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};ht();var bOt={type:"beginState"},Uct={type:"completeState",isfromEntity:!1},jct={type:"requestRender"},_Ot=class extends En{constructor(t,e,i,r){super(),this.data=t,this.page=e,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new P,this.posEnd=new P,this.qStart=new Te,this.qEnd=new Te,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(t){if(!this.data.animate)return;let e=this.page.scene.find(this.data.targetCamera);if(!e||!e.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let i={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:gwt(this.data)},r=s=>{let n=this.page.activeCamera;n.position.lerpVectors(this.posStart,this.posEnd,s),n.quaternion.slerpQuaternions(this.qStart,this.qEnd,s),n.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*s,n.wasMovedBySwitchCameraAction=!0,n.updateMatrix(),n.updateMatrixWorld(),n.updateProjectionMatrix(),n.dispatchEvent(jct),s===1&&n.dispatchEvent(Uct)};this.runner=new awt(i,r,()=>{t?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(e.position),this.qEnd.copy(e.quaternion),this.zoomEnd=e.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(e.uuid)),this.page.activeCamera.dispatchEvent(bOt),r(0)})}get togglesBack(){return this.data.runMode==="Toggle"&&!this.toggleIsForward}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ls.remove(this)}start(){!this.runner||(this.runner.start(Ls.time),Ls.add(this))}switchCamera(t){let e=this.page.activeCamera,i=this.page.scene.find(t);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),e.dispatchEvent({type:"cameraChange",camera:i})}jumpToCamera(t){this.switchCamera(t),this.page.activeCamera.dispatchEvent(Uct),this.page.activeCamera.dispatchEvent(jct)}play(){if(Ir(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(!1),this.start()):this.jumpToCamera(this.data.targetCamera)},1e3*this.data.delay)}catch{}}pause(){this.runner?.stop(),Ls.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(t){if(Ir(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,t!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=t??!this.toggleIsForward,this.buildAnimation(this.togglesBack),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=t??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(this.togglesBack),this.start()):this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.jumpToCamera(this.data.targetCamera)):this.fromCamera&&this.jumpToCamera(this.fromCamera.uuid)},1e3*this.data.delay)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};MW();var xOt=class{constructor(t,e,i,r){this.data=t,this.page=e,this.shared=i,this.condition=r}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(t=>{this.shared.getVariable(t);let e=this.shared.data.variables.data(t)?.value;e!==void 0&&this.shared.updateVariable(t,e),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(Vj(t))})}dispose(){}};Ni(),eo("Link",({data:t,eventManager:e,shared:i,actionCondition:r})=>new yOt(t,e.controlsManager,i,r)),eo("Reset",({data:t,page:e,shared:i,eventManager:r,actionCondition:s})=>new vOt(t,e,i,r,s)),eo("SwitchCamera",({data:t,page:e,shared:i,actionCondition:r})=>new _Ot(t,e,i,r)),eo("ClearLocalStorage",({data:t,page:e,shared:i,actionCondition:r})=>new xOt(t,e,i,r)),Nr("misc-actions"),Ni(),_o(),sh(),HW(),MW();var wOt=class{get sharedAssets(){return this.shared}constructor(t,e={},i=!0,{dedupeParametricGeometries:r=!1}={}){this.shared=new i5(t.shared,e,!0,i),this.shared.geometryCache.dedupeByValue=r,this.scene=new Vg(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof Or&&!t.uiScene&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.scene.releaseInstanceGroups(),this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Ur&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};HW(),Ui();var av,A8,C8="vertexOrder";function Gct(t){return A8||(A8=Promise.resolve().then(()=>(fEt(),h1t)).then(({DRACOLoader:e})=>((av=new e).setDecoderPath(t!==void 0?`${t}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload(),av.decoderPending))),A8}async function SOt(t){if(av){let e,i={attributeIDs:{...av.defaultAttributeIDs,[C8]:"GENERIC"},attributeTypes:{...av.defaultAttributeTypes,[C8]:"Uint32Array"},useUniqueIDs:!1};try{e=await av.decodeGeometry(new Int8Array(t).buffer,i)}catch(r){console.error(r)}if(e)return function(r){let s=r.attributes.find(u=>u.name===C8);if(!s)return r;let n=s.array,a=n.length,o=0;for(let u=0;u<a;u++)o=Math.max(o,n[u]+1);let l,h=r.attributes.filter(u=>u!==s).map(({name:u,itemSize:d,array:c})=>{let p=new Float32Array(o*d);for(let m=0;m<a;m++){let f=n[m]*d,g=m*d;for(let y=0;y<d;y++)p[f+y]=c[g+y]}return{name:u,itemSize:d,array:p}});if(r.index){let u=r.index.array,d=new Uint32Array(u.length);for(let c=0;c<u.length;c++)d[c]=n[u[c]];l={array:d}}return{index:l,attributes:h}}({index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))})}return null}async function Wct(t){for(let e of t){let i=await SOt(e.geometry.data.draco);if(i){let r=e.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};i.attributes.forEach(({name:n,array:a,itemSize:o})=>{s[n]={array:a,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=s,r.draco=void 0}}}cD(),rb(),vT(),_T(),dW(),Dm(),fD(),r1t(),l1t(),kc(),nD(),sh(),u0t(),d0(),bT(),i0t(),$W();var TOt={bloom:()=>Promise.resolve().then(()=>(AEt(),MEt)),depthOfField:()=>Promise.resolve().then(()=>(REt(),PEt))};function MOt(t){return function(e,i){return Promise.all(e.map(r=>i[r]?.().catch(s=>{console.warn(`[spline] Failed to load the ${r} postprocessing effect (webgpu); the effect will be skipped.`,s)}))).then(()=>{})}(t,TOt)}var TP=new WeakMap,qct=new WeakMap;function Hct(t,e,i){let r=s=>{t.removeEventListener(e,r,!0),s.stopImmediatePropagation(),i(s)};return t.addEventListener(e,r,!0),()=>t.removeEventListener(e,r,!0)}ir();var AOt=Zv(DEt(),1);function MP(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function COt(t){return{id:t.uuid,name:t.name,type:t.object.data?.type??t.object.type,visible:t.playModeVisible!==!1,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ft.RAD2DEG,y:t.rotation.y*Ft.RAD2DEG,z:t.rotation.z*Ft.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},spawned:!0}}function AP(t){return{id:t.uuid,name:t.name,type:t.type??"Object",visible:t.visible,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ft.RAD2DEG,y:t.rotation.y*Ft.RAD2DEG,z:t.rotation.z*Ft.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}}function wwt(t,e,i){let r=a=>t.findObjectById(a)??t.findObjectByName(a),s=new Map,n=a=>{let o=s.get(a);if(o)return o;for(let l of s.values())if(l.name===a)return l};return{setVariable:(a,o)=>a in t.getVariables()?(t.setVariable(a,o),{ok:!0}):{ok:!1,warning:`spline.setVariable: no variable named "${a}" in this scene.`},getVariable:a=>t.getVariable(a),getVariables:()=>t.getVariables(),getAllObjects:()=>t.getAllObjects().map(AP),findObject:a=>{let o=r(a);return o?AP(o):void 0},getGeometry:(a,o)=>{if(!i)return{warning:"spline.getGeometry: not available in this runtime integration."};let l=n(a),h=l?l.object:(()=>{let p=r(a);return p?i.findEntity(p.uuid):void 0})();if(!h)return{warning:`spline.getGeometry: no object named "${a}" (names/ids come from getAllObjects).`};let u,d=l??h;o.space==="world"&&(d.updateWorldMatrix?.(!0,!1),u=d.matrixWorld?.elements);let c=function(p,m){let f=p?.getAttribute("position");if(!f||!f.count)return null;let g=f.count,y=m??null,v=p.getIndex?.()??null,b=Math.floor((v?v.count:g)/3),_=1/0,x=1/0,S=1/0,w=-1/0,T=-1/0,C=-1/0,M=new Float32Array(3*g);for(let O=0;O<g;O++){let B=f.getX(O),V=f.getY(O),z=f.getZ(O);y&&([B,V,z]=XAt(y,B,V,z)),B<_&&(_=B),V<x&&(x=V),z<S&&(S=z),B>w&&(w=B),V>T&&(T=V),z>C&&(C=z),M[3*O]=B,M[3*O+1]=V,M[3*O+2]=z}let A={space:y?"world":"local",vertexCount:g,triangleCount:b,indexed:v!==null,bounds:{min:[_,x,S],max:[w,T,C],size:[w-_,T-x,C-S]},vertices:M};if(v){let O=new Uint32Array(v.count);for(let B=0;B<v.count;B++)O[B]=v.getX(B);A.indices=O}let R=p.getAttribute("normal");if(R&&R.count===g){let O=y?function(B){let V=B[0],z=B[4],k=B[8],L=B[1],H=B[5],W=B[9],X=B[2],nt=B[6],st=B[10],yt=V*(H*st-W*nt)-z*(L*st-W*X)+k*(L*nt-H*X);if(!isFinite(yt)||Math.abs(yt)<1e-12)return null;let pt=1/yt,Q=[(H*st-W*nt)*pt,(k*nt-z*st)*pt,(z*W-k*H)*pt,(W*X-L*st)*pt,(V*st-k*X)*pt,(k*L-V*W)*pt,(L*nt-H*X)*pt,(z*X-V*nt)*pt,(V*H-z*L)*pt];return[Q[0],Q[3],Q[6],Q[1],Q[4],Q[7],Q[2],Q[5],Q[8]]}(y):void 0;if(!y||O){let B=new Float32Array(3*g);for(let V=0;V<g;V++){let z=R.getX(V),k=R.getY(V),L=R.getZ(V);if(O){let H=O[0]*z+O[1]*k+O[2]*L,W=O[3]*z+O[4]*k+O[5]*L,X=O[6]*z+O[7]*k+O[8]*L,nt=Math.hypot(H,W,X);nt>1e-12?(z=H/nt,k=W/nt,L=X/nt):(z=H,k=W,L=X)}B[3*V]=z,B[3*V+1]=k,B[3*V+2]=L}A.normals=B}}let I=p.getAttribute("uv");if(I&&I.count===g){let O=new Float32Array(2*g);for(let B=0;B<g;B++)O[2*B]=I.getX(B),O[2*B+1]=I.getY(B);A.uvs=O}return A}(h.geometry,u);return c?{data:{id:d.uuid,name:d.name,geometry:h.data?.geometry?.type,...c}}:{warning:`spline.getGeometry: "${d.name}" has no readable geometry \u2014 only meshes do (lights, cameras and groups have none; read a group's child meshes instead).`}},updateObject:(a,o)=>{let l=n(a);if(l){let{position:g,rotation:y,scale:v,visible:b}=o;return g&&(typeof g.x=="number"&&(l.position.x=g.x),typeof g.y=="number"&&(l.position.y=g.y),typeof g.z=="number"&&(l.position.z=g.z)),y&&(typeof y.x=="number"&&(l.rotation.x=y.x*Ft.DEG2RAD),typeof y.y=="number"&&(l.rotation.y=y.y*Ft.DEG2RAD),typeof y.z=="number"&&(l.rotation.z=y.z*Ft.DEG2RAD)),v&&(typeof v.x=="number"&&(l.scale.x=v.x),typeof v.y=="number"&&(l.scale.y=v.y),typeof v.z=="number"&&(l.scale.z=v.z)),typeof b=="boolean"&&(l.playModeVisible=b),l.updateMatrix(),t.requestRender(),!0}let h=r(a);if(!h)return!1;let{position:u,rotation:d,scale:c,visible:p,geometry:m,material:f}=o;if(m&&typeof m=="object"&&i){let g=i.findEntity(h.uuid);if(g){let{vertices:y,normals:v,uvs:b,indices:_,...x}=m;MP(y)&&i.shared.updateEntityGeometryVertices(g,{vertices:y,normals:MP(v)?v:void 0,uvs:MP(b)?b:void 0,indices:MP(_)?_:void 0}),Object.keys(x).length>0&&i.shared.updateEntityGeometryParams(g,x)}}if(f&&typeof f=="object"&&i){let g=i.findEntity(h.uuid);g&&i.shared.updateEntityMaterialParams(g,f)}return u&&(typeof u.x=="number"&&(h.position.x=u.x),typeof u.y=="number"&&(h.position.y=u.y),typeof u.z=="number"&&(h.position.z=u.z)),d&&(typeof d.x=="number"&&(h.rotation.x=d.x*Ft.DEG2RAD),typeof d.y=="number"&&(h.rotation.y=d.y*Ft.DEG2RAD),typeof d.z=="number"&&(h.rotation.z=d.z*Ft.DEG2RAD)),c&&(typeof c.x=="number"&&(h.scale.x=c.x),typeof c.y=="number"&&(h.scale.y=c.y),typeof c.z=="number"&&(h.scale.z=c.z)),typeof p=="boolean"&&(h.visible=p),t.requestRender(),!0},createObject:async(a,o)=>AP(await t.createObject(a,o)),createCustomMaterial:a=>t.createCustomMaterial(a),getTexture:(a,o)=>{if(!i)return null;let l=r(a),h=l?i.findEntity(l.uuid):void 0;if(!h)return null;let u=i.shared.getEntityTexture(h,o??{});return u?{texture:u.texture,width:u.width,height:u.height,layer:u.layerType}:null},setMaterial:(a,o)=>t.setMaterial(a,o),cloneObject:(a,o)=>AP(t.cloneObject(a,o)),removeObject:a=>t.removeObject(a),spawnObject:(a,o)=>{if(!i)return{warning:"spline.spawnObject: not available in this runtime integration."};let l=r(a),h=l?i.findEntity(l.uuid):void 0;if(!h)return{warning:`spline.spawnObject: no object named "${a}" to use as a template.`};if(s.size>=500)return{warning:"spline.spawnObject: spawn budget reached (500 live copies) \u2014 destroyObject old copies (or reuse them) instead of spawning more."};let u=i.shared.spawnRuntimeClone(h,o??{});return u?(s.set(u.uuid,u),t.requestRender(),{object:COt(u)}):{warning:`spline.spawnObject: "${a}" cannot be spawned from.`}},destroyObject:a=>{let o=n(a);return!(!i||!o||(s.delete(o.uuid),i.shared.destroyRuntimeClone(o),t.requestRender(),0))},setInstanceTransforms:(a,o)=>{if(!i)return-1;let l=r(a),h=l?i.findEntity(l.uuid):void 0;if(!h)return-1;let u=i.shared.setEntityInstanceTransforms(h,o);return u>=0&&t.requestRender(),u},...mOt(()=>i?.getAnimationControls(),a=>{let o=r(a);return o?i?.findEntity(o.uuid):void 0}),emitEvent:(a,o,l)=>{let h=r(o);return h?(l?h.emitEventReverse(a):h.emitEvent(a),{ok:!0}):{ok:!1,warning:`spline.emitEvent: no object named "${o}".`}},requestRender:()=>t.requestRender(),addSplineEventListener:(a,o)=>{let l=h=>{o({target:{id:h.target?.id??"",name:h.target?.name??""}})};return t.addEventListener(a,l),()=>t.removeEventListener(a,l)},getCanvas:()=>e}}ht(),ir();var Swt=class{constructor(t,e,i){this.iframe=t,this.bridge=e,this.observer=i}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("iframe");n.setAttribute("sandbox","allow-scripts allow-forms allow-pointer-lock"),n.title="Spline HTML content";let a=n.style;a.position="absolute",a.border="0",a.background="transparent",a.pointerEvents="auto",a.colorScheme="normal";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(s),n.srcdoc=function(u){let d=`<script>${tft}<\/script>`,c=/<head(\s[^>]*)?>/i.exec(u);if(c){let m=c.index+c[0].length;return u.slice(0,m)+d+u.slice(m)}let p=/<html(\s[^>]*)?>/i.exec(u);if(p){let m=p.index+p[0].length;return u.slice(0,m)+`<head>${d}</head>`+u.slice(m)}return d+u}(i),s.insertBefore(n,e.nextSibling);let h=new ift(n,wwt(t,e,r),(u,d)=>{u==="warn"?console.warn(`[spline html] ${d}`):u==="error"&&console.error(`[spline html] ${d}`)});return h.attach(),new Swt(n,h,l)}dispose(){this.bridge.dispose(),this.observer.disconnect(),this.iframe.remove()}};ir();var QR="data-spline-html-content",EOt=`
5187
+ `&&s--,this.htmlInput.setSelectionRange(Math.min(t,s),Math.max(t,s))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof kq)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[t],s=e+1,n=e;r[e]!==" "&&(s=this.findNextCharOccurence(r,e,"forward"," "),n=this.findNextCharOccurence(r,e,"backward"," "),n>0&&n++,s>=r.length-1&&t===i.length-1&&s++);let a=this.helper,o=a.getGlobalIndexFromLineAndCharIndexes(i,t,n),l=a.getGlobalIndexFromLineAndCharIndexes(i,t,s);this.setInputSelection(o,l)}findNextCharOccurence(t,e,i,r=" "){let s=Math.max(0,t.length-1),n=i==="forward"?s:0,a=i==="forward"?1:-1,o=Math.max(Math.min(e,s),0);for(;o!==n;)if(o+=a,t.charAt(o)===r)return o;return n}getPointOnPlane(){let t=this.virtualInput?.data;if(this.virtualInput&&t&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new P);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let i=typeof t.geometry.width=="number"?t.geometry.width:1,r=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+.5*i,e.y-.5*r)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(xct.getNormalMatrix(this.virtualInput.matrixWorld),bct.copy(GDt).applyMatrix3(xct).normalize(),this.virtualInput.localToWorld(_ct.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(bct,_ct))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),aT&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=function(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}(t.geometry.horizontalAlign))}},dwt=(t,e)=>{if(typeof t=="string"){let i=e.data(t);if(i)return dwt(i.value,e)}return Da.getDisplayedValue(t)};function wct(t,e){let i=t.text,r="";if(typeof i=="string"){let s=e.variables.data(r);s&&(r=dwt(s.value,e.variables))}else r=i.textValue.toString();return r}var qDt=class extends ro{constructor(t,e){super(t),this.eventManager=e,this._textInputs=[],this.sceneHelpers=new Ku,this.helper=new uwt,this._onMouseDownFocusIn=i=>{if(Ge.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let s of this._textInputs)if(this.eventContext.raycaster.intersectObject(s,!0).length>0){r=s;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDown,!1),s.removeEventListener("pointerup",this._onMouseUp,!1),s.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),s.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:s,helper:n}=this.textInputManager;if(!r||!s)return;let a=r.value;s.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=s.data;n.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new WDt(this.sceneHelpers,t.raycaster,t.sharedAssets,t.requestRender,this.onExit)}connect(){let t=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof kq&&t.push(r)}),this._textInputs=t,t.length===0)return;let{domElement:e}=this.eventContext;e.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let t=this.textInputManager.htmlInput,{domElement:e,sharedAssets:i}=this.eventContext;e.removeEventListener("pointerdown",this._onMouseDownFocusIn),t?.removeEventListener("keyup",this._onCaretUpdate),t?.removeEventListener("keydown",this._onCaretUpdate),t?.removeEventListener("beforeinput",this._onCaretUpdate),t?.removeEventListener("paste",this._onCaretUpdate),t?.removeEventListener("cut",this._onCaretUpdate),t?.removeEventListener("select",this._onCaretUpdate),t?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(r=>{let s=wct(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(s,i)}),e.removeEventListener("pointerdown",this._onMouseDown,!1),e.removeEventListener("pointerup",this._onMouseUp,!1),e.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(t){this.textInputManager.focus(t),this.textInputManager.onTextMaterialChanged();let e=this.textInputManager.htmlInput;if(!e||t===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=wct(t.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);e.value=i,e.setSelectionRange(0,0),this.textInputManager.helper.show(t),e.style.display="block",e.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};Ni(),Tl("Textfields",({eventContext:t,eventManager:e})=>new qDt(t,e)),eb("InputGeometry",(t,e,i)=>new kq(t,e,i)),Nr("textinputs"),hW();var cwt=new Map,MS=new Map,vP=class{constructor(t,e,i,r){this.data=e,this.isPlayAudioAction=!0;let{audio:s,volume:n,delay:a,loop:o}=e;if(!s)throw new Error("Missing property");try{let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Z1({src:l,volume:n,delay:a,loop:o})}catch{console.warn(`Could not create an audio player for this object: "${i.name}" and this audio: "${s}"`)}MS.has(i.uuid)?MS.get(i.uuid).push(this):MS.set(i.uuid,[this]),cwt.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},HDt=class{constructor(t){this.data=t,this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=cwt.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=MS.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...MS.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},$Dt=class{constructor(t,e,i,r,s){if(this.data=e,this.shared=r,this.condition=s,e.interaction==="play")this.interaction=new vP(t,e,i,r);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new HDt(e)}}dispatchBasic(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof vP?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof vP?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof vP&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};Ni(),eo("Audio",({id:t,data:e,object:i,shared:r,actionCondition:s})=>new $Dt(t,e,i,r,s)),Nr("audio"),ir();var pwt=new Map,AS=new Map,w8=class{constructor(t,e,i){this.data=e,this.isPlayVideoAction=!0,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=e;if(this.object=i,r===void 0)throw new Error("Missing property");let o=function(l,h){let u;if("material"in l){let c=l.material;u=Array.isArray(c)?l.material[0].layers.find(p=>p.uuid===h):l.material.layers.find(p=>p.uuid===h)}if(!u)return;let d=u.color?.texture?.image?.img??u.holders?.find(c=>c.isVideo)?.img;return d instanceof HTMLVideoElement?d:void 0}(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,aT&&(this.videoElement.autoplay=!0),n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),AS.has(i.uuid)?AS.get(i.uuid).push(this):AS.set(i.uuid,[this]),pwt.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let i=this.videoElement.duration;if(i>0){let r=t%i;this.videoElement.currentTime=r}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},XDt=class{constructor(t){this.data=t,this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=pwt.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=AS.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let t=[...AS.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},YDt=class{constructor(t,e,i,r,s){if(this.data=e,this.shared=r,this.condition=s,e.interaction==="play")this.interaction=new w8(t,e,i);else{if(e.interaction!=="pause"&&e.interaction!=="stop")throw new Error("Missing property");this.interaction=new XDt(e)}}dispatchBasic(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof w8?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Ir(this.shared,this.condition)===!1)return!1;this.interaction instanceof w8?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};ts(),Ni(),eo("Video",({id:t,data:e,object:i,shared:r,actionCondition:s})=>Go(i)?null:new YDt(t,e,i,r,s)),Nr("video"),ir(),ht(),MD(),ab();var S8=(()=>{let t,e,i,r,s=!1;function n(l){!t&&!Sct()&&(e?.sharedGameControlGlobals.createdObjects.length??0)>0&&(t=requestAnimationFrame(a)),l&&(e=l,r=l.requestRender,!s&&typeof document<"u"&&(document.addEventListener("visibilitychange",o),s=!0))}function a(l){if(!e||!r)return t=void 0,void(i=void 0);let h=i?l-i:0,u=e.sharedGameControlGlobals.createdObjects,d=e.sharedGameControlGlobals.nCreatedPerAction,c=u.length,p=0;for(;p<c;){let m=u[p];m.userData.createdTime===void 0&&(m.userData.createdTime=l),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&l-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&d[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,h/1e3),m.updateMatrix(),m.userData.parentMatrix&&m.matrix.premultiply(m.userData.parentMatrix),r()),p++):(d[m.userData.actionId]>m.userData.quantity&&d[m.userData.actionId]--,u.splice(p,1),m.removeFromParent(),e.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(e.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),e.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,e.sharedGameControlGlobals.entitiesWithTransformAnim=e.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}t=p>0?requestAnimationFrame(a):void 0,i=p>0?l:void 0}function o(){Sct()?t&&(cancelAnimationFrame(t),t=void 0,i=void 0):n()}return{play:n,dispose:function(){t&&(cancelAnimationFrame(t),t=void 0),s&&typeof document<"u"&&(document.removeEventListener("visibilitychange",o),s=!1),e=void 0,r=void 0,i=void 0}}})();function Sct(){return!!document&&document.hidden}var Tct=new Te,KDt=new P,ZDt=new P,QDt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Ft.generateUUID(),this.dispatch=()=>{if(Ir(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()},this.dispatchFromStart=()=>{if(Ir(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))},this.dispatchThrottled=function(a,o=0,l={}){return LS(a,o,{leading:l.leading!==!1,trailing:l.trailing!==!1,maxWait:o})}(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let a=new Ja(this.object);if(a.playModeVisible=!0,a.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldRigid(),a.userData.parentMatrix=h.matrixWorldRigid)}a.scale.copy(this.object.scale),a.position.fromArray(this.data.position.map(l=>typeof l=="number"?l:0)),a.rotation.fromArray(this.data.rotation.map(l=>typeof l=="number"?l:0)),a.updateMatrix(),a.userData.parentMatrix&&a.matrix.premultiply(a.userData.parentMatrix),this.page.add(a);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(a),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,a.updateWorldMatrix(!0,!0),a.traverseObject(this.traverseObjectCB),S8.play(),this.controlsManager.requestRender()},this.traverseObjectCB=a=>{let o;if(a.updateMatrixWorldRigid(),this.controlsManager.sharedGameControlGlobals.rapierWorld){if(a instanceof Rc){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(a instanceof Ja)o=a.object;else if(o=a,o.dataPatched.cloner?.hideBase)return!0}else{if(a instanceof Rc)return;o=a instanceof Ja?a.object:a}this.data.destroy==="Time"?a.userData.lifetime=1e3*this.data.lifetime:this.data.destroy==="Quantity"&&(a.userData.quantity=this.data.destroyAfterQuantity,a.userData.actionId=this.uniqueId);let l=new P().fromArray(this.data.velocity.map(u=>typeof u=="number"?u:0)),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(a,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(a.rigidBody?.collider(0).setActiveEvents(1),a.userData.hasCollisionDestroy=!0),a.matrixWorld.decompose(KDt,Tct,ZDt),l.applyQuaternion(Tct),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&a.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in a.object&&this.controlsManager.addBoundsTree(a),this.data.velocity.some(u=>u!==0)&&this.data.dynamic&&(a.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let n=this.page.scene.find(this.data.object);if(!n)throw new Error("Missing Property");if(this.object=n,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");S8.play(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],S8.dispose()}},JDt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=n=>{this.timeoutIdQueue.shift();let a=this.page.scene.find(n);if(a===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=!o||a.dataPatched.physics?.fusedBody;if(a.cloner){for(let h of a.cloner.children)l?(h.playModeVisible=!1,a.dataPatched.physics?.rigidBody==="positioned"&&this.removeBody(h),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,this.removeBody(h)):h.playModeVisible===void 0&&(h.playModeVisible=!0);a.cloner.syncInstanceMatrices(),(l||this.clone===void 0||this.clone===!1)&&(a.visible=!1,this.removeBody(a),a.bvhGeometry&&(a.bvhGeometry=void 0))}else this.removeBody(a),a.bvhGeometry&&(a.bvhGeometry=void 0),a.visible=!1;this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),a.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...t.objects]}removeBody(t){let e=t.rigidBody;if(!e)return;let i=this.controlsManager.sharedGameControlGlobals;i.colliderToEntity.delete(e.collider(0).handle),i.kinematicBodyToEntity.delete(e.handle);let r=this.controlsManager;r.fixedBodiesToWatch=r.fixedBodiesToWatch.filter(([,s])=>s!==e),i.rapierWorld.removeRigidBody(e),t.rigidBody=void 0}dispatch(t){if(Ir(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay)):this.dispatchInner()}dispatchFromStart(){if(Ir(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,1e3*this.data.delay))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};Ni(),eo("Create",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new QDt(t,e,i.controlsManager,r,s)),eo("Destroy",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new JDt(t,e,i.controlsManager,r,s)),Nr("create-destroy"),Be(),Be(),bo(),ht(),Qh(),_o(),ts();var Mct=new P;function Vq(t,e,i=!1){let r=[],s=n=>{let a=n.data;delete n.states,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let o of a.states){let l={...o.data};n.states||(n.states={}),n.states[o.id]=Og.patch(a,l)}Cct(t.scene,n,null,e,a.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),Act(t)};t.scene.traverse2D(s),t.traverseChildren(n=>{if(i&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(Mct,!0),n.rigidBody?.setAngvel(Mct,!0)),!xi.is(n))return;let a=n.uuid,o=n.data;if(delete n.states,n.uuid===l0)return;let l=!1;r.some(h=>t.scene.find(a)?.isDescendantOf(h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(a),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null,n.transitionState={settled:!0,state:null};for(let h of o.states){let u={...h.data};t.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete u.position,h.data.rotation!==void 0&&delete u.rotation),n.states||(n.states={}),n.states[h.id]=am.patch(o,u)}Cct(t.scene,n,null,e,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),Ya(n)&&n.frame&&(n.frame.traverse(h=>s(h)),n.uiCanvas?.applySize())}),Act(t),t.frame&&(t.frame.traverse(n=>s(n)),t.uiCanvas?.applySize())}function Act(t){t.traverseEntity(e=>{for(let i of e.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions)}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let n=t.scene.find(s.data.object);n&&(n.visible=!1)}}})}function Cct(t,e,i,r,s=!1){if(t.markShadowsDirty(),e instanceof Ur&&!Ic(e)&&e.removeInteractionGeometry(r),Go(e)?e.changeSelectedState(i,{shared:r},s):e.changeSelectedState(i,{scene:t,shared:r},s),e instanceof Ur&&e.updateGeometryGroupsIfNeeded(),e instanceof Us&&e.updateCameraState(e.dataPatched,{scene:t,shared:r}),!Go(e)){if(e.cloner){let n=!1;for(let a of e.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,n=!0);n&&t.addPendingUpdateCloner(e),e.cloner.syncInstanceMatrices()}e.updateVisible()}}var tOt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=e.scene}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},1e3*this.data.delay))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(e=>e.uuid!==this.data.target||e.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,1e3*this.data.duration),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.sleep(),e.wakeUp(),e.data.autoPlay?e.start():e.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Vq(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function eOt(t){return{easing:t.type,control1:Pc(t.cubicControls?.control1,[0,0]),control2:Pc(t.cubicControls?.control2,[1,1]),...t.springParameters}}function g1(t,e){let i=[];for(let r of t??[]){let s=e(r.data);s!==void 0&&i.push({time:r.data.time,ease:eOt(r.data.easing),value:s})}return{keyframes:mgt(i)}}function Du(t,e){if(t.keyframes.length===0)return;let{index0:i,index1:r,t:s}=pgt(t.keyframes,e),n=t.read;if(n&&n.index0===i&&n.index1===r&&n.t===s)return;let a={index0:i,index1:r,from:t.keyframes[i].value,to:t.keyframes[r].value,t:s};return t.read=a,a}function iOt(t){t.read=void 0}function bP(t,e,i){return t+(e-t)*i}Ni(),eo("SceneTransition",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new tOt(t,e,i,r,s)),Nr("scene-transition"),Be(),ht(),Be(),Be(),ht(),oa(),Qh(),_D(),WW(),wD(),_o(),ts(),nb(),AW(),yD(),Be(),ir(),Be(),ht(),kc();var{degToRad:hIt,radToDeg:uIt}=Ft;function xa(t,e,i,r,s,n){let a=i[t]!==void 0?i[t]:void 0,o=r[t];if(o==null)return;let l=a!=null?typeof a=="string"?Number(s.getVariable(a)??0):a:e[t],h=typeof o=="string"?Number(s.getVariable(o)??0):o;return l!==h?{update:u=>{let d=Ft.lerp(l,h,u);e[t]=n?Math.trunc(d):d},start:()=>{e[t]=l},end:()=>{e[t]=h}}:void 0}function lG(t,e,i,r,s,n){let a=i[t]?i[t]:void 0,o=r[t];if(!o)return;let l=e[t],h=[...a??l].map(d=>typeof d=="string"?Number(s.getVariable(d)??0):d),u=[...o].map(d=>typeof d=="string"?Number(s.getVariable(d)??0):d);return h.length!==u.length||qg(h,u)?void 0:{update:d=>{h.forEach((c,p)=>{let m=Ft.lerp(c,u[p],d);e[t][p]=n?Math.trunc(m):m})},start:()=>{Object.assign(e[t],h)},end:()=>{Object.assign(e[t],u)}}}function H5(t,e,i){return e.forEach((r,s)=>{t.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),t}function Ect(t,e,i,r,s){let n=i[t]?i[t]:void 0,a=r[t];if(!a)return;let o=e[t],l=n?H5(new P,n,s):o.clone(),h=H5(new P,a,s);return l.equals(h)?void 0:{update:u=>{o.lerpVectors(l,h,u)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function Pct(t,e,i){return e.forEach((r,s)=>{t.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),t}function _P(t,e,i,r,s){let n=i[t]?i[t]:void 0,a=r[t];if(!a)return;let o=e[t],l=!(o instanceof Z),h=o instanceof Z?o:new Z().fromArray(o),u=n?Pct(new Z,n,s):h.clone(),d=Pct(new Z,a,s);return u.equals(d)?void 0:{update:c=>{h.lerpVectors(u,d,c),l&&(e[t]=h.toArray())},start:()=>{h.copy(u),l&&(e[t]=h.toArray())},end:()=>{h.copy(d),l&&(e[t]=h.toArray())}}}function xP(t,e,i,r,s){let n=i[t]?i[t]:void 0,a=r[t];if(!a)return;let o=e[t],l=new Dr(o.r,o.g,o.b,o.a),h=n?typeof n=="string"?s.getColor(n).clone():new Dr(n.r,n.g,n.b,n.a):l.clone(),u=typeof a=="string"?s.getColor(a).clone():new Dr(a.r,a.g,a.b,a.a);return h.equals(u)?void 0:{update:d=>{l.lerpColors(h,u,d);let c=Ft.lerp(h.a,u.a,d);l.a=c,e[t]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(u)}}}function Ip(t,e,i,r,s){return typeof e[t]=="number"?xa(t,e,i??{},r,s):Array.isArray(e[t])?lG(t,e,i??{},r,s):void 0}function rOt(t,e){if(t)for(let[i,r]of Object.entries(e)){let s=t[i];if(Array.isArray(s)&&Array.isArray(r)){let n=Math.min(s.length,r.length);for(let a=0;a<n;a++)s[a]=r[a]}else t[i]=r}}function wP(t,e,i,r){let s={};if(!e||!i)return s;for(let n of t){let a=e[n],o=i[n];if(typeof a=="number"&&typeof o=="number")s[n]=Ft.lerp(a,o,r);else if(Array.isArray(a)&&Array.isArray(o)){let l=Math.min(a.length,o.length);s[n]=Array.from({length:l},(h,u)=>Ft.lerp(a[u],o[u],r))}}return s}new P,new Fi;var Rct=[["radial",M4],["linear",A4],["grid",C4],["toObject",E4],["randomnessObject",P4]];function mwt(t,e,i,r,s){let n=t.getValue(r);if(n!==void 0){if(r==="colors")return function(a,o,l,h="colors"){if(!a.hasValue(h)||!(h in l))return;let u=[],d=a.getValue(h),c=o?o[h]:d.map(m=>m.toArray()),p=l[h];for(let m=0;m<d.length;++m){let f=[...c[m]],g=[...p[m]];US.isEqual(f,g)||u.push({update:y=>{d[m].fromArray(US.lerp(f,g,y))},start:()=>{d[m].fromArray(f)},end:()=>{d[m].fromArray(g)}})}return u.length?u:void 0}(t,e,i,r);if(Array.isArray(n))return r==="steps"?function(a,o,l,h="steps"){if(!a.hasValue(h)||!(h in l))return;let u=[],d=a.getValue(h),c=o?o[h]:d,p=l[h];return qg(c,p)||u.push({update:m=>{let f=[...d];for(let g=0;g<d.length;++g){let y=c[g],v=p[g];f[g]=Ft.lerp(y,v,m)}a.setValue(h,f)},start:()=>{a.setValue(h,c)},end:()=>{a.setValue(h,p)}}),u.length?u:void 0}(t,e,i,r):void 0;if(typeof n=="number")return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=o?o[h]:a.getValue(h),c=l[h],p=typeof d=="string"?Number(u.getVariable(d)??0):d,m=typeof c=="string"?Number(u.getVariable(c)??0):c;return{update:f=>{a.setValue(h,Ft.lerp(p,m,f))},start:()=>{a.setValue(h,p)},end:()=>{a.setValue(h,m)}}}(t,e,i,r,s);if(typeof n!="boolean"){if(n instanceof Z)return function(a,o,l,h){if(!a.hasValue(h)||!(h in l))return;let u=a.getValue(h),d=o?new Z().fromArray(o[h]):u.clone(),c=new Z().fromArray(l[h]);return d.equals(c)?void 0:{update:p=>{u.lerpVectors(d,c,p)},start:()=>{u.copy(d)},end:()=>{u.copy(c)}}}(t,e,i,r);if(n instanceof P)return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=a.getValue(h),c=o?o[h]:void 0,p=l[h],m=c?H5(new P,c,u):d.clone(),f=H5(new P,p,u);return m.equals(f)?void 0:{update:g=>{d.lerpVectors(m,f,g)},start:()=>{d.copy(m)},end:()=>{d.copy(f)}}}(t,e,i,r,s);if(n instanceof Dr)return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=o?o[h]:void 0,c=l[h],p=a.getValue(h),m=d?typeof d=="string"?u.color(d).clone():new ae().setRGB(d.r,d.g,d.b):p.clone(),f=typeof c=="string"?u.color(c).clone():new Dr(c.r,c.g,c.b,c.a);if(m.equals(f))return;let g=p.clone();return{update:y=>{a.getValue(h)!==g&&a.setValue(h,g),g.lerpColors(m,f,y)},start:()=>{g.copy(m)},end:()=>{g.copy(f)}}}(t,e,i,r,s);if(n instanceof ae)return function(a,o,l,h,u){if(!a.hasValue(h)||!(h in l))return;let d=o?o[h]:void 0,c=l[h],p=a.getValue(h),m=d?typeof d=="string"?u.color(d).clone():new ae().setRGB(d.r,d.g,d.b):p.clone(),f=typeof c=="string"?u.color(c).clone():new ae().setRGB(c.r,c.g,c.b);if(m.equals(f))return;let g=p.clone();return{update:y=>{a.getValue(h)!==g&&a.setValue(h,g),g.lerpColors(m,f,y)},start:()=>{g.copy(m)},end:()=>{g.copy(f)}}}(t,e,i,r,s);if("isTexture"in n)return function(a,o,l,h="texture",u){if(!a.hasValue(h)||!(h in l))return;let d=T=>Number(typeof T=="string"?u?.getVariable(T)??0:T??0),c=a.getNode("rotation"),p=o?d(o[h]?.rotation):(c?.value??0)*Ft.RAD2DEG,m=d(l[h]?.rotation);if(c&&Math.abs(p-m)>1e-9)return{update:T=>{c.value=Ft.lerp(p,m,T)*Ft.DEG2RAD},start:()=>{c.value=p*Ft.DEG2RAD},end:()=>{c.value=m*Ft.DEG2RAD}};let f=function(T){let C=T.getNode("mat");if(typeof C?.updateMatrix=="function")return C;let M=T.getValue("mat");return typeof M?.updateMatrix=="function"?M:void 0}(a);if(!f)return;let g=o?o[h]:f,y=l[h],v=[...g.repeat],b=[...g.offset],_=[...y.repeat],x=[...y.offset],S=g.rotation??0,w=y.rotation??0;return Hu.isEqual(v,_)&&Hu.isEqual(b,x)&&S===w?void 0:{update:T=>{f.repeat=Hu.lerp(v,_,T),f.offset=Hu.lerp(b,x,T),f.rotation=Ft.lerp(S,w,T),f.updateMatrix()},start:()=>{f.repeat=[...v],f.offset=[...b],f.rotation=S,f.updateMatrix()},end:()=>{f.repeat=[..._],f.offset=[...x],f.rotation=w,f.updateMatrix()}}}(t,e,i,r,s)}}}function Dct(t,e,i,r){let s=[],n=e.layers?um(e,r):t.transparent,a=um(i,r);s.push(function(o,l,h){let u=l||h;return{update:d=>{o.setTransparent(d===1?h:u)}}}(t,n,a)),function(o,l,h){let u=o.ensureRainbowNoiseCompiled;if(typeof u=="function")for(let d of[...o.layers]){if(d.type!=="rainbow")continue;let c=l.layers?.data(d.uuid),p=h.layers.data(d.uuid);(yv(c?.noiseStrength)||yv(p?.noiseStrength))&&u.call(o,d.uuid)}}(t,e,i);for(let o of t.layers){let l=e.layers?.data(o.uuid),h=i.layers.data(o.uuid);if(!h||o.type!=="light"&&(!(o.visible??1)||!(h.visible??1)))continue;let u=yT[o.type]??[],d=o.getNames().filter(c=>!u.includes(c)&&!tD.some(p=>c.includes(p)));for(let c of d)try{let p=mwt(o,l,h,c,r);p&&(Array.isArray(p)?s.push(...p):s.push(p))}catch(p){console.error(`lerpMaterial: unexpected material layer for ${c}`,p)}}return s}function Oct(t,e,i,r,s,n){let a=mwt(e,i,r,t,n);!a||(Array.isArray(a)?a.forEach(o=>o.update(s)):a.update(s))}function Hd(t,e,i){!t||(t[e]={...t[e],...i})}function sOt(t,e,i,r,s,n,a){let o=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(t.on){case"position":case"scale":{let l=Du(t.track,i);if(!l)return;let h=bP(l.from,l.to,l.t);return e[t.on][t.axis]=h,Hd(n,t.on,{[t.axis]:h}),void o()}case"rotation":{let l=Du(t.track,i);if(!l)return;let h=bP(l.from,l.to,l.t);return e.rotation[t.axis]=h*Ft.DEG2RAD,Hd(n,"rotation",{[t.axis]:h}),void o()}case"shapeSize":{let l=Du(t.track,i);if(!(l&&e instanceof Ur))return;let h=bP(l.from,l.to,l.t);return e.userData.value={...e.userData.value,[t.axis]:h},Hd(n,"shapeSize",{[t.axis]:h}),a.size=!0,a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"opacity":{let l=Du(t.track,i);if(!l||!(e instanceof Fs)||Array.isArray(e.material))return;let h=e.material.getLayersOfType("light")[0];if(h===void 0)return;let u=Ft.lerp(l.from,l.to,l.t),d=e.material,c=l.to>=1&&(l.t===1||l.from>=1);return d.setTransparent(!c||um(d.data,r.shared),r.scene),Oct("alphaOverride",h,{alphaOverride:u},{alphaOverride:u+1},0,r.shared),n&&(n.opacity=u),void(a.render=!0)}case"material":{let l=Du(t.track,i);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:h}=t,u={};for(let d in h.data){if(!(d in l.from)||!(d in l.to))continue;let c=hG(l.from[d],l.to[d],l.t,s);if(c===void 0)continue;u[d]=c;let p=h.getValue(d);p!==void 0&&(d==="alpha"&&typeof p=="number"&&p>0&&e instanceof Fs&&!Array.isArray(e.material)&&(e.material.transparent=!0),Oct(d,h,l.from,l.to,l.t,r.shared))}return Hd(n,"material",{[h.uuid]:u}),void(a.render=!0)}case"light":{let l=Du(t.track,i);if(!l||!(e instanceof ob||e instanceof xT||e instanceof lb))return;let h=hG(l.from,l.to,l.t,s);return e[t.field]=h,Hd(n,"light",{[t.field]:h}),void(a.render=!0)}case"camera":{let l=Du(t.track,i);if(!(l&&e instanceof Us))return;let h=bP(l.from,l.to,l.t);return e[t.field]=h,void Hd(n,"camera",{[t.field]:h})}case"cloner":{let l=Du(t.track,i);if(!l)return;let h=e.cloner?.parameters,u=function(d,c,p,m){if(!d)return{};let f=wP(["count"],c,p,m);f.count!==void 0&&(f.count=Math.trunc(f.count));for(let[g,y]of Rct){if(!d[g])continue;let v=wP(y,c[g],p[g],m);Object.keys(v).length&&(f[g]=v)}return f}(h,l.from,l.to,l.t);return function(d,c){if(d){c.count!==void 0&&(d.count=c.count);for(let[p]of Rct){let m=c[p];m&&rOt(d[p],m)}}}(h,u),Hd(n,"cloner",u),a.cloner=!0,a.boolean=!0,void(a.render=!0)}case"pathExtrusion":{let l=Du(t.track,i);if(!l||!oD(e))return;let h=wP(N4,l.from,l.to,l.t),u=e.geometry.userData.parameters;return u.extrusion={...u.extrusion,...h},Hd(n,"pathExtrusion",h),e.updateGeometryInteractions({extrusion:{...u.extrusion}},r.shared),a.bounds=!0,a.boolean=!0,void(a.render=!0)}case"pathSnapping":{let l=Du(t.track,i);if(!l)return;let h=e,u=wP(zft,l.from,l.to,l.t);return h.userData.pathSnapping={...h.userData.pathSnapping,...u},Hd(n,"pathSnapping",u),h.updatePathSnapping(h.userData.pathSnapping),void(a.render=!0)}}}function hG(t,e,i,r){if(typeof t=="string"&&r&&(t=r.color(t)),typeof e=="string"&&r&&(e=r.color(e)),typeof t=="number")return Ft.lerp(t,e,i);if(Hi.is(t))return Hi.lerp(t,e,i);if(Ks.is(t))return Ks.lerp(t,e,i);if(Array.isArray(t))return(t.length>e.length?e:t).map((s,n)=>{if(Array.isArray(s)){let a=t[n].length>e[n].length?e[n].length:t[n].length;return(a===4?US:a===3?ym:Hu).lerp(t[n],e[n],i)}return Ft.lerp(t[n],e[n],i)});if(typeof t=="object"&&t!==null){let s={};for(let n in t){let a=hG(t[n],e[n],i,r);a!==void 0&&(s[n]=a)}return s}}Be(),ht(),kc(),yD(),nb(),ir(),ir(),ts(),Be(),Qh(),ts(),oa(),Qh(),bT(),_o(),d0(),ht(),Be(),ht(),_T(),ts(),ir(),ts(),ht(),Dm(),ht();var T8=new P,Ict=new Fi;function nOt(t,e,i,r,s){let n=[];return t.data.visible&&n.push(...function(a,o,l,h,u){let d,c,p,m,f,g,y,v=[];if(Go(a)?(d=_P("position",a,o,l,u),d&&v.push(d),p=xa("rotation",a,o,l,u),p&&v.push(p),m=_P("shear",a,o,l,u),m&&v.push(m)):(y={slide:o.pathSnapping?.slide??a.updatedPathSnapping?.slide??a.dataPatched.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.updatedPathSnapping?.offset??a.dataPatched.pathSnapping?.offset??0},f=xa("slide",y,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,u),f&&v.push(f),g=xa("offset",y,o.pathSnapping??a.updatedPathSnapping??a.dataPatched.pathSnapping,l.pathSnapping??a.dataPatched.pathSnapping,u),g&&v.push(g),!f&&!g&&(d=Ect("position",a,o,l,u),d&&v.push(d),c=Ect("scale",a,o,l,u),c&&v.push(c),p=function(b,_,x,S,w){let T=_?.rotation?_.rotation.map(I=>(typeof I=="string"?Number(w.getVariable(I)??0):I)*Ft.DEG2RAD):void 0,C=x.rotation?.map(I=>(typeof I=="string"?Number(w.getVariable(I)??0):I)*Ft.DEG2RAD);if(!C)return;let M=T?new P().fromArray(T):new P().setFromEuler(b.rotation),A=new P().fromArray(C);if(M.equals(A))return;let R=T8.subVectors(A,M);if(S&&R.toArray().every(I=>Math.abs(I)<2*Math.PI)){let I=new Te().setFromEuler(Ict.setFromVector3(M)),O=new Te().setFromEuler(Ict.setFromVector3(A));return{update:B=>{(function(V,z,k,L){if(L===0)return k.copy(V);if(L===1)return k.copy(z);let H=V.w*z.w+V.x*z.x+V.y*z.y+V.z*z.z;if(H>=1)return k.copy(V);let W=1-H*H;if(W<=Number.EPSILON){let pt=1-L;return k.w=pt*V.w+L*z.w,k.x=pt*V.x+L*z.x,k.y=pt*V.y+L*z.y,k.z=pt*V.z+L*z.z,k.normalize(),k}let X=Math.sqrt(W),nt=Math.atan2(X,H),st=Math.sin((1-L)*nt)/X,yt=Math.sin(L*nt)/X;k.w=V.w*st+z.w*yt,k.x=V.x*st+z.x*yt,k.y=V.y*st+z.y*yt,k.z=V.z*st+z.z*yt})(I,O,b.quaternion,B)},start:()=>{b.rotation.setFromVector3(M)},end:()=>{b.rotation.setFromVector3(A)}}}return{update:I=>{T8.lerpVectors(M,A,I),b.rotation.setFromVector3(T8)},start:()=>{b.rotation.setFromVector3(M)},end:()=>{b.rotation.setFromVector3(A)}}}(a,o,l,h,u),p&&v.push(p),m=function(b,_,x){let S=_.shear,w=x.shear;if(!w)return;let T=b.shearMatrix,C=S??[T.elements[4],T.elements[8],T.elements[1],T.elements[9],T.elements[2],T.elements[6]],M=w;return C.every((A,R)=>A===M[R])?void 0:{update:A=>{C.forEach((R,I)=>{let O=Ft.lerp(R,M[I],A);T.elements[wl.INDEX_MAP[I]]=O})},start:()=>{C.forEach((A,R)=>{T.elements[wl.INDEX_MAP[R]]=A})},end:()=>{M.forEach((A,R)=>{T.elements[wl.INDEX_MAP[R]]=A})}}}(a,o,l),m&&v.push(m))),d||c||p||m||f||g){let b=Go(a)?()=>{a.updateWorldMatrix(!0,!1,!0),a.resetBBoxNeedsUpdate()}:()=>{a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldRigid()),a.parent?.matrixWorldFusedFalse&&(a.matrixWorld.multiplyMatrices(a.parent.matrixWorldFusedFalse,a.matrix),a.matrixWorldNeedsUpdate=!1),Hh(a)&&$u(a.parent)&&a.invalidateDownstreamBooleanData(!0),a.updatePathSnapping(Object.assign({},o.pathSnapping,y))};v.push({update:b,start:b,end:b})}return v}(t,e,i,s,r.shared)),Go(t)?n.push(...function(a,o,l,h,u){let d,c,p,m,f,g,y,v,b,_,x,S,w,T,C,M=[];if("width"in a&&(d=xa("width",a,o,l,u),d&&M.push(d)),"height"in a&&(c=xa("height",a,o,l,u),c&&M.push(c)),a instanceof Yn||a instanceof Qu){let A={...o.fill},R={...l.fill};A.enabled!==void 0&&A.enabled!==R.enabled&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.fill.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),p=xP("color",a.fill,A,R,u),p&&M.push(p)}if(a instanceof Yn){let A={...o.stroke},R={...l.stroke};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.stroke.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),m=xP("color",a.stroke,A,R,u),m&&M.push(m),f=xa("thickness",a.stroke,A,R,u),f&&M.push(f)}if(a instanceof Yn){let A={...o.dropShadow},R={...l.dropShadow};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.dropShadow.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),g=xP("color",a.dropShadow,A,R,u),g&&M.push(g),y=xa("blurRadius",a.dropShadow,A,R,u),y&&M.push(y),b=xa("spread",a.dropShadow,A,R,u),b&&M.push(b),v=_P("offset",a.dropShadow,A,R,u),v&&M.push(v)}if(a instanceof Yn){let A={...o.innerShadow},R={...l.innerShadow};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.innerShadow.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}}),R.enabled||Object.assign(R,{enabled:!0,color:{...R.color,a:0}})),_=xP("color",a.innerShadow,A,R,u),_&&M.push(_),x=xa("blurRadius",a.innerShadow,A,R,u),x&&M.push(x),w=xa("spread",a.innerShadow,A,R,u),w&&M.push(w),S=_P("offset",a.innerShadow,A,R,u),S&&M.push(S)}if(a instanceof Yn||a instanceof Qu){let A={...o.backgroundBlur},R={...l.backgroundBlur};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.backgroundBlur.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),T=xa("radius",a.backgroundBlur,A,R,u),T&&M.push(T)}if(a instanceof Yn){let A={...o.layerBlur},R={...l.layerBlur};(A.enabled||R.enabled)&&(M.push(function(I){return{update:()=>{I instanceof Yn&&(I.layerBlur.enabled=!0)}}}(a)),A.enabled||Object.assign(A,{enabled:!0,radius:0}),R.enabled||Object.assign(R,{enabled:!0,radius:0})),C=xa("radius",a.layerBlur,A,R,u),C&&M.push(C)}if(a instanceof Qu||a instanceof MT){let A=lG("cornerRadius",a,o,l,u);A&&M.push(A)}return M}(t,e,i,0,r.shared)):(t.data.visible&&n.push(...function(a,o,l,h){let u=[];if(!("cloner"in l)||!a.cloner)return u;let d=a.cloner,c="cloner"in o?o.cloner:{},p=l.cloner;VU.forEach(b=>{let _;_=b==="count"?xa("count",d.parameters,c,p,h.shared,!0):Ip(b,d.parameters,c??{},p,h.shared),_&&u.push(_)});let m=function(b,_,x,S){if(b.parameters.type!=="radial")return;let w=_.radial,T=x.radial;if(!T)return;let C=b.parameters.radial,M=[];return M4.forEach(A=>{let R=Ip(A,C,w??{},T,S);R&&M.push(R)}),M}(d,c,p,h.shared);m?.length&&u.push(...m);let f=function(b,_,x,S){if(b.parameters.type!=="linear")return;let w=_.linear,T=x.linear;if(!T)return;let C=[],M=b.parameters.linear;return A4.forEach(A=>{let R=Ip(A,M,w??{},T,S);R&&C.push(R)}),C}(d,c,p,h.shared);f?.length&&u.push(...f);let g=function(b,_,x,S){if(b.parameters.type!=="grid")return;let w=_.grid,T=x.grid;if(!T)return;let C=[],M=b.parameters.grid;return C4.forEach(A=>{let R;R=A==="count"?lG(A,M,w??{},T,S,!0):Ip(A,M,w??{},T,S),R&&C.push(R)}),C}(d,c,p,h.shared);g?.length&&u.push(...g);let y=function(b,_,x,S){if(b.parameters.type!=="toObject")return;let w=_.toObject,T=x.toObject;if(!T)return;let C=[],M=b.parameters.toObject;return E4.forEach(A=>{let R;R=A==="count"?xa(A,M,w??{},T,S,!0):Ip(A,M,w??{},T,S),R&&C.push(R)}),C}(d,c,p,h.shared);y?.length&&u.push(...y);let v=function(b,_,x,S){if(!b.parameters.randomness)return;let w=_.randomnessObject,T=x.randomnessObject;if(!T)return;let C=[],M=b.parameters.randomnessObject;return P4.forEach(A=>{let R=Ip(A,M,w??{},T,S);R&&C.push(R)}),C}(d,c,p,h.shared);return v?.length&&u.push(...v),u.length&&u.push({update:()=>{d.update(h)}}),u}(t,e,i,r)),t instanceof Fs?(t instanceof Ur&&t.data.visible&&n.push(...function(a,o,l,h){let u=[];if(!("geometry"in l)||Ic(a))return u;let d=a.geometry.userData.parameters,c="geometry"in o?o.geometry:{},p=l.geometry;if(a instanceof Fv){let m=function(f,g,y,v){if(y.scaleBaked===void 0)return;let b=(g.scaleBaked??f.appliedGeometrySize??f.data.geometry.scaleBaked).map(S=>typeof S=="string"?Number(v.shared.getVariable(S)??0):S),_=y.scaleBaked.map(S=>typeof S=="string"?Number(v.shared.getVariable(S)??0):S);if(ym.isEqual(b,_))return;let x=[];return x.push({update:S=>{f.updateGeometryInteractions({scaleBaked:[Ft.lerp(b[0],_[0],S),Ft.lerp(b[1],_[1],S),Ft.lerp(b[2],_[2],S)]},v.shared),f.invalidateDownstreamBooleanData(),f.refreshAttachedClonersInteractions(v)},start:()=>{f.updateGeometryInteractions({scaleBaked:b},v.shared),f.invalidateDownstreamBooleanData(),f.refreshAttachedClonersInteractions(v)},end:()=>{f.updateGeometryInteractions({scaleBaked:_},v.shared),f.invalidateDownstreamBooleanData(),f.refreshAttachedClonersInteractions(v)}}),x}(a,c,p,h);m&&u.push(...m)}else{let m={},f=a.appliedGeometrySize;if(Object.assign(m,mU(d,XP),f?{width:f[0],height:f[1],depth:f[2]}:{},mU(c,XP)),XP.forEach(g=>{let y=Ip(g,m,c,p,h.shared);y&&u.push(y)}),oD(a)){Object.assign(m,{extrusion:{...d.extrusion}});let g=function(y,v,b,_){if(!b.extrusion)return;let x=y.extrusion,S=v.extrusion??{},w=b.extrusion,T=[];return N4.forEach(C=>{let M=Ip(C,x,S,w,_);M&&T.push(M)}),T}(m,c,p,h.shared);g&&u.push(...g)}u.length&&u.push({update:g=>{a.updateGeometryInteractions(m,h.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(h)},start:g=>{a.updateGeometryInteractions(m,h.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(h)},end:g=>{a.updateGeometryInteractions(m,h.shared),a.updateGeometryGroupsIfNeeded(),a.refreshAttachedClonersInteractions(h)}})}return u}(t,e,i,r)),t.data.visible&&!(t instanceof vo&&t.materialOverride)&&n.push(...function(a,o,l,h){let u=[];if(Array.isArray(a.material)){if(!("materials"in l)||!l.materials)return u;let d="materials"in o&&o.materials?o.materials:[],c=l.materials;a.material.forEach((p,m)=>{if(!c[m])return;let f=d[m]??{},g=c[m];typeof f=="string"||typeof g=="string"||u.push(...Dct(p,f,g,h))})}else{if(!("material"in l)||!l.material)return u;let d="material"in o&&o.material?o.material:{},c=l.material;if(typeof d=="string"||typeof c=="string")return u;u.push(...Dct(a.material,d,c,h))}return u}(t,e,i,r.shared))):s5.is(t)?t.data.visible&&n.push(...function(a,o,l,h){let u=[];if(l.intensity!==void 0){let d=xa("intensity",a,o,l,h);d&&u.push(d)}if(l.color!==void 0){let d=function(c,p,m,f,g){let y=m[c]?m[c]:void 0,v=f[c];if(!v)return;let b=p[c],_=y?typeof y=="string"?g.getColor(y).clone():new ae().setRGB(y.r,y.g,y.b):b.clone(),x=typeof v=="string"?g.getColor(v).clone():new ae().setRGB(v.r,v.g,v.b);if(_.equals(x))return;let S=b.clone();return{update:w=>{S.lerpColors(_,x,w),p[c]?.copy?.(S)},start:()=>{S.copy(_)},end:()=>{S.copy(x)}}}("color",a,o,l,h);d&&u.push(d)}return u}(t,e,i,r.shared)):t instanceof Us&&n.push(...function(a,o,l,h){let u=[],d=a.cameraType==="OrthographicCamera"?o.orthographic?.zoom:o.perspective?.zoom,c=a.cameraType==="OrthographicCamera"?l.orthographic?.zoom:l.perspective?.zoom;if(c!==void 0){let p=d??a.zoom,m=c;p!==m&&u.push({update:f=>{a.zoom=Ft.lerp(p,m,f),a.updateProjectionMatrix()},start:()=>{a.zoom=p,a.updateProjectionMatrix()},end:()=>{a.zoom=m,a.updateProjectionMatrix()}})}if(l.targetOffset!==void 0){let p=xa("targetOffset",a,o,l,h);p&&u.push(p)}return u}(t,e,i,r.shared))),n.length?{update:a=>{n.forEach(o=>o.update(a))},start:a=>{n.forEach(o=>o.start?.(a))},end:a=>{n.forEach(o=>o.end?.(a))}}:void 0}var fwt={type:"beginState"};function gwt(t){if(t.easing===5){let{control1:e,control2:i}=t;return{easing:5,control1:e??kv.defaultData.control1,control2:i??kv.defaultData.control2}}if(t.easing===6){let{mass:e,stiffness:i,damping:r,velocity:s}=t;return{easing:6,mass:e??sm.defaultData.mass,stiffness:i??sm.defaultData.stiffness,damping:r??sm.defaultData.damping,velocity:s??sm.defaultData.velocity}}return{easing:t.easing}}function ywt(t){return{delay:t.delay,delayDirection:t.delayDirection??"start-end",direction:t.direction??"normal",repeat:t.repeat}}var vwt={type:"completeState",isfromEntity:!1};function CS(t,e){let i,r;if(typeof e=="string"?(i=e,r=t.states?.[i]):e===null&&(i=null,r=t.data),i!==void 0&&r!==void 0)return{id:i,data:r}}var aOt=["position","rotation","scale","shear"],uG=new Set,dG=class{constructor(t,e,i,r,s,n,a,o={},l=()=>uG){this.object=t,this.fromRef=e,this.toRef=i,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.page=a,this.hooks=o,this.inert=l,this.builtReversed=!1,this.startStateId=null,this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=Go(this.object)?null:this.object.transitionState.state,this.callback=nOt(this.object,{},function(h,u){if(u.size===0)return h;let d={...h};for(let c of u)delete d[c];return d}(this.end.data,this.inert()),{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)},this.onChange=h=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(h),this.object.requestRender()),this.writeState(h)},this.runner=new awt(function(h){return{duration:h.duration,ease:gwt(h),...ywt(h)}}(r),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let r=CS(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!r)throw new Error("Missing property");this.from=r}else{let r=CS(this.object,t);if(!r)throw new Error("Missing property");this.from=r}if(e===void 0)throw new Error("Missing property");let i=CS(this.object,e);if(!i)throw new Error("Missing property");this.to=i,this.buildCallback()}refresh(){this.buildCallback()}get endpointData(){return[this.from.data,this.to.data]}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||Go(this.object))return;let e=t===1,i=t>.5?this.targetStateId:this.startStateId,r=this.object.transitionState;r.settled===e&&r.state===i||(this.object.transitionState={settled:e,state:i},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=i,this.object.dispatchEvent({type:"transitionState",settled:e,state:i}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:i}),this.object.traverseEntity(s=>{s!==this.object&&s instanceof Us&&s.dispatchEvent(e?vwt:fwt)}),e?this.hooks.onComplete?.(i):this.hooks.onBegin?.(i))}};Qh();var cG=new Map,ES=new Map,Yl=class extends En{constructor(t,e,i,r,s,n){super(),this.id=t,this.data=e,this.scene=i,this.sharedAssets=r,this.object=s,this.eventType=n,this.evaluators=[],this.elapsed=0,this.lastTime=null,this.direction=1,this._playing=!1,this._finished=!1,this.hasPlayedOnce=!1,this.pauseOnNextCycleEnd=!1,this.lastCycleIndex=0;try{let a=s0.findTimeline(this.scene.data.objects,this.data.timeline),o=a.duration;this.animatedObjectIds=Object.keys(a.objectTimelines),this.animatedObjectIds.forEach(l=>{let h=this.scene.find(l);if(!h)return;let u=a.objectTimelines[l];!u||this.evaluators.push(function(d,c,p,m,f){let g=function(y,v){let b=[];return vm.groupKeyframes(v.keyframes).forEach(_=>{let x=_.path?.[0],S=_.path[1],w=()=>g1(_.keyframes,T=>T.value);switch(x){case"position":case"rotation":case"scale":return void(S&&jS.includes(S)&&b.push({on:x,axis:S,track:w()}));case"shape size":return void(S&&jS.includes(S)&&"geometry"in y&&b.push({on:"shapeSize",axis:S,track:w()}));case"path extrusion":return void(oD(y)&&b.push({on:"pathExtrusion",track:g1(_.keyframes,T=>T.value)}));case"path snapping":return void(y.data.pathSnapping&&b.push({on:"pathSnapping",track:g1(_.keyframes,T=>T.value)}));case"material":return void(y.type==="Mesh"&&"material"in y&&function(T,C){let M=r5(T.material)?T.material:void 0,A=C.layerId;if(!M||!A)return[];let R=C.keyframes.some(k=>yv(k.data.value?.noiseStrength)),I=M.ensureRainbowNoiseCompiled,O=k=>{R&&typeof I=="function"&&I.call(M,k)},B=k=>"data"in k?[{on:"material",layer:k,track:g1(C.keyframes,L=>L.value)}]:[];O(A);let V=M.getLayerByUuid(A);if(V)return B(V);let z=C.path[1];for(let k of M.getLayersOfType(z))O(k.uuid);return(M.getLayersOfType(z)??[]).flatMap(B)}(y,_).forEach(T=>b.push(T)));case"opacity":return void(y.type==="Mesh"&&"material"in y&&b.push({on:"opacity",track:w()}));case"cloner":return void b.push({on:"cloner",track:g1(_.keyframes,T=>T.value)});case"camera":return void(y instanceof Us&&b.push({on:"camera",field:"zoom",track:w()}));case"light":return void((y instanceof ob||y instanceof xT||y instanceof lb)&&b.push({on:"light",field:_.path[1],track:g1(_.keyframes,T=>T.value)}))}}),b}(d,c);return{duration:p,evaluate(y,v){d.resetBBoxNeedsUpdate();let b={transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1};for(let _ of g)sOt(_,d,y,m,f,v,b);(function(_,x,S){if(x.size&&_ instanceof Ur){let{x:w,y:T,z:C}=_.userData.value;_.updateGeometryInteractions({width:w,height:T,depth:C},S.shared)}x.cloner&&_.cloner?.update(S),x.transform&&_.updateMatrix(),x.bounds&&_.resetBBoxNeedsUpdate(),x.boolean&&_ instanceof Ur&&_.invalidateDownstreamBooleanData(),x.render&&_.dispatchEvent({type:"requestRender"})})(d,b,m)},invalidate(){for(let y of g)iOt(y.track)}}}(h,{...u},o,{scene:i,shared:r},this.sharedAssets))}),this.schedule=new W5t(function(l,h){return{duration:h,delay:_a(l.delay/1e3),delayDirection:l.delayDirection??"start-end",direction:l.direction??"normal",repeat:l.repeat}}(this.data,o))}catch{throw new Error("Missing property")}s&&(ES.has(s.uuid)?ES.get(s.uuid).push(this):ES.set(s.uuid,[this])),cG.set(t,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(t){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(t-this.lastTime)*this.direction)),this.lastTime=t,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0)return void this.pause();let t=this.schedule.resolve(this.elapsed);if(t){if(t.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=t.cycleIndex,this.pauseOnNextCycleEnd))return this.pauseOnNextCycleEnd=!1,void this.pause();for(let e of this.evaluators)e.evaluate(t.localTime)}else this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(t=>{let e=this.scene.find(t);e instanceof Us&&e.dispatchEvent(vwt)})}startTicking(){this._playing=!0,this.lastTime=null;for(let t of this.evaluators)t.invalidate();Ls.add(this)}play(){let t=this.eventType!==void 0&&CU(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&CU(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!t||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(e=>{let i=this.scene.find(e);i instanceof Us&&i.dispatchEvent(fwt)}),!t&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,Ls.remove(this)}rewind(){this.pause(),this.elapsed=0,this.lastCycleIndex=0}stop(){this.rewind(),this.applyAtElapsed(),this._finished=!1}pauseAndRewind(){this.rewind(),this.direction=1,this.pauseOnNextCycleEnd=!1,this._finished=!1}seek(t){let e=this.schedule.totalDuration;this.elapsed=t*(Number.isFinite(e)?e:this.schedule.effectiveCycleDuration);for(let i of this.evaluators)i.invalidate();this.applyAtElapsed()}toggle(t){let e=t??this.direction===-1;this._playing&&this.direction===(e?1:-1)?e&&(this.pauseOnNextCycleEnd=!1):(e?(this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.pauseOnNextCycleEnd=!1):(this.direction=this.schedule.resolve(this.elapsed)?.isReverse?1:-1,this.pauseOnNextCycleEnd=!0),this.startTicking())}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},oOt=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>{i[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(i=>{i[this.data.interaction]()}))}getTimelineActions(t){let e=cG.get(t);return e?[e]:[...cG.values()].filter(i=>i.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=ES.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(i=>i[this.data.interaction]()))}pauseAllTimelines(){let t=[...ES.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},lOt=class{constructor(t,e,i,r,s,n,a){this.data=e,this.sharedAssets=r,this.actionCondition=a;let o="interaction"in e?e.interaction:"play";if(o==="play"||o===void 0)this.interaction=new Yl(t,e,i,r,s,n);else{if(o!=="pause"&&o!=="stop")throw new Error("Missing property");this.interaction=new oOt(e)}}get playing(){return this.interaction instanceof Yl&&this.interaction.playing}get finished(){return!(this.interaction instanceof Yl)||this.interaction.finished}get paused(){return!(this.interaction instanceof Yl)||this.interaction.paused}branchTaken(){return Ir(this.sharedAssets,this.actionCondition)}play(){return!!this.branchTaken()&&(this.interaction instanceof Yl?this.interaction.play():void this.interaction.dispatch())}get animatedObjectIds(){return this.interaction instanceof Yl?this.interaction.animatedObjectIds:[]}pauseAndRewind(){this.interaction instanceof Yl&&this.interaction.pauseAndRewind()}stop(){this.interaction instanceof Yl&&this.interaction.stop()}seek(t){!this.branchTaken()||this.interaction instanceof Yl&&this.interaction.seek(t)}toggle(t){!this.branchTaken()||(this.interaction instanceof Yl?this.interaction.toggle(t):this.interaction.dispatch())}playFromCurrent(){!this.branchTaken()||(this.interaction instanceof Yl?this.interaction.playFromCurrent():this.interaction.dispatch())}dispatchConditional(){this.playFromCurrent()}reverseFromCurrent(){!this.branchTaken()||this.interaction instanceof Yl&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};function Nct(t){let e=t.tweens[0]?.data;return{delay:e?.delay??t.delay,delayDirection:e?.delayDirection??"start-once",direction:e?.direction??t.direction,repeat:e?.repeat??t.repeat}}Ni(),eo("TimelineAnimation",({id:t,data:e,page:i,shared:r,object:s,eventType:n,actionCondition:a})=>new lOt(t,e,i.scene,r,s,n,a)),Nr("timeline"),ts(),Be(),ht(),Qh();var hOt={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},uOt=class extends En{constructor(t,e,i,r,s,n,a){if(super(),this.eventType=t,this.data=e,this.page=i,this.shared=r,this.condition=s,this.runModeOverride=n,this.tweens=[],this.hasPlayedOnce=!1,this.inert=uG,!e.object)throw new Error("Missing property");let o=this.page.scene.findFrom(e.object,a)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,e.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}get claimTime(){return this.runner?.claimTime}get contested(){let t=this.object.previousAction;return t!==null&&t!==this&&t.animating}init(){this.initialCurrentState=CS(this.object,this.object.currentState).id,this.build()}shouldReinit(){return!!Ir(this.shared,this.condition)||!(this.animating&&!this.loopsForever)}get loopsForever(){return Nct(this.data).repeat===-1||this.data.tweens.some((t,e)=>e>0&&t.data.repeat===-1)}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:CU(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}get opensOnCurrent(){return this.data.tweens[0].data.state===void 0&&this.runMode!=="Toggle"}build(){let t=this.data.tweens,e=[];try{let i=t[0].data.state;i!==void 0&&e.push(new dG(this.object,i,i,hOt,this.shared,this.data.allowSlerp??!1,this.page,{},()=>this.inert));for(let r=1;r<t.length;r++){let s=t[r-1],n=t[r];e.push(new dG(this.object,s.data.state===void 0?this.currentState:s.data.state,n.data.state===void 0?this.currentState:n.data.state,n.data,this.shared,this.data.allowSlerp??!1,this.page,{},()=>this.inert))}}catch(i){return void(i instanceof Error&&console.error(i.message))}this.tweens=e,this.syncInert(),this.runner=new nwt({...ywt(Nct(this.data)),runMode:this.runMode},e.map(i=>i.runner),{claim:i=>this.claimObject(i),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(t){if(this.object.previousAction===this)return!1;let e=this.object.previousAction;if(e?.animating===!0){if(t!==void 0&&e.claimTime!==void 0&&e.claimTime>t)return!1;e.pause()}return this.object.previousAction=this,!0}rebindTweens(){for(let t of this.tweens)try{t.rebind()}catch(e){e instanceof Error&&console.error(e.message)}this.syncInert(),this.object instanceof Us&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}syncInert(){let t=this.tweens.flatMap(e=>e.endpointData);if(this.opensOnCurrent&&t.length>0){let e=CS(this.object,this.object.currentState);e&&(t[0]=e.data)}this.inert=this.notMovedByOwner(function(e){if(e.length<2)return uG;let i=new Set,[r,...s]=e;for(let n of aOt){let a=r[n];a!==void 0&&s.every(o=>qg(o[n],a))&&i.add(n)}return i}(t));for(let e of this.tweens)e.refresh()}notMovedByOwner(t){let e=this.object.previousAction;if(t.size===0||e===null||e===this||!e.animating)return t;let i=e.leavesAlone;return new Set([...t].filter(r=>i.has(r)))}get leavesAlone(){return this.inert}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ls.remove(this)}branchTaken(){return Ir(this.shared,this.condition)}play(){if(!this.branchTaken()||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(Ls.time),this.runner.isPlaying&&Ls.add(this))}pause(){this.runner?.stop(),Ls.remove(this)}stop(){this.pause();let t=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;Go(this.object)?this.object.changeSelectedState(t,{shared:this.shared}):this.object.changeSelectedState(t,{scene:this.page.scene,shared:this.shared}),this.object.currentState=t}seek(t){if(Ir(this.shared,this.condition)===!1)return!1;this.runner?.seek(t)}playDirected(t){if(Ir(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(Ls.time,t),this.runner.isPlaying&&Ls.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};function dOt(t){let e=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+t,n=this._loopCount,a=r===c4;if(t===0)return n===-1||!a||1&~n?s:e-(s-i);if(r===V8){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(s>=e)s=e;else{if(!(s<0)){this.time=s;break t}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(n===-1&&(t>=0?(n=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=e||s<i){let o=Math.floor((s-i)/(e-i));s-=(e-i)*o,n+=Math.abs(o);let l=this.repetitions-n;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a||(s=t>0?e:i,this.repetitions===1&&(s=e)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let h=t<0;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(a&&!(1&~n))return e-(s-i)}return s}function bwt(t){let e=t?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(e?.length){let i=function(r){if(!r||r.length===0)return;let s;for(let n of r)n==n&&(s===void 0||n>s)&&(s=n);return s}(e);return i&&i>2?i:2}return 2}Be(),ht(),Be(),ht(),ht(),ir();var Bct=!1,ag=new WeakSet;function pG(t){return Array.isArray(t.identity)?t.identity[0]:t.uuid}function SP(t){return t.data.type==="Empty"&&Array.isArray(t.data.animations)?t.data.animations:[]}function cOt(t){return t===void 0||t===!0?-1:typeof t=="number"&&t>=1?Math.round(t)-1:0}function kct(t,e){return typeof t=="number"&&isFinite(t)&&t>0?t:e}function Vct(t,e){let i=t.filter(a=>a.info.id===e);if(i.length)return i;let r=t.filter(a=>a.info.name===e);if(r.length)return r;let s=e.toLowerCase(),n=t.filter(a=>a.info.name.toLowerCase()===s);return n.length?n:t.filter(a=>a.info.name.toLowerCase().endsWith("_"+s))}function zct(t){return`"${t.name}" has no imported animation clips \u2014 getAnimations() lists the objects that do.`}function Lct(t,e,i){if(!i)return`no clip "${t}" in the scene \u2014 getAnimations() lists them.`;let r=e.map(s=>`"${s.info.name}"`).join(", ");return`"${i.name}" has no clip "${t}" \u2014 its clips: ${r}.`}var pOt=class{constructor(t,e,i,r){this.scene=t,this.requestRender=e,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.clipDurations=new WeakMap,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&Array.isArray(s.data.animations)&&s.data.animations.forEach((n,a)=>{let o=n[0]+"/"+pG(s);if(this.clipIdToAction[o])return;let l=GP.parse(function(u){if(!Yft(u))return JSON.parse(u[2]);let[d,c,,p]=u,m=([g,y])=>p.data.slice(g,g+y),f={name:c,duration:p.duration,uuid:d,tracks:p.tracks.map(g=>{let y={name:g.name,type:g.type,times:m(g.times),values:g.list?[...g.list]:m(g.values)};return g.interpolation!==void 0&&(y.interpolation=g.interpolation),y})};return p.blendMode!==void 0&&(f.blendMode=p.blendMode),p.userData!==void 0&&(f.userData=p.userData),f}(n));s.animations[a]=l,this.clipDurations.set(l,l.duration);let h=this.mixer.clipAction(l,s);Bct===!1&&(Object.getPrototypeOf(h)._updateTime=dOt,Bct=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new hU(t),this.scene.traverseEntity(this.addClip)}rebindClips(){this.mixer.stopAllAction(),this.mixer=new hU(this.scene),this.clipIdToAction={},this.activeClip=null,this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let i=this.scene.find(e);if(!i)return;let r=i.animations.find(n=>n.uuid===t);if(!r)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[t],i.animations=i.animations.filter(n=>n.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.scene.markShadowsDirty(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=d4,t.timeScale=1,ag.delete(t)}),this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,i=this.clipIdToAction[e];if(i)return i.repetitions=t.repeat>=0?t.repeat+1:1/0,i.loop=t.direction!=="pingpong"&&t.direction!=="pingpong-rewind"||t.repeat===0?d4:c4,i.play(),i.paused=!1,this.requestRender(),i}startClip(t,e,{start:i=0,end:r,fade:s=0}){ag.delete(t),t.reset(),t.time=i;let n=t.getClip();n.start=i,n.duration=r??this.fullDuration(t),this.replaceOtherClips(t,e,s)}replaceOtherClips(t,e,i=0){Object.entries(this.clipIdToAction).forEach(([r,s])=>{s===t||r.split("/")[1]!==e||(ag.delete(s),i>0?s.fadeOut(i):s.stop())}),i>0&&t.fadeIn(i)}resumeClip(t){return!!ag.has(t)&&(ag.delete(t),t.paused=!1,t.play(),this.requestRender(),!0)}holdClips(t,e){let i=!1;Object.entries(this.clipIdToAction).forEach(([r,s])=>{let[n,a]=r.split("/");if(e(n,a))if(t==="pause"){if(!s.isRunning())return;s.paused=!0,ag.add(s)}else{if(!s.enabled||!s.isRunning()&&!s.paused)return;s.paused=!0,ag.delete(s),s.time=s.getClip().start??0,s._loopCount=-1,i=!0}}),i&&(this.needsUpdate=!0,this.scene.markShadowsDirty(),this.requestRender())}animatedEntity(t){let e;return t.traverseEntity(i=>!!e||(SP(i).length?(e=i,!0):void 0)),e||t.traverseEntityAncestors(i=>{!e&&SP(i).length&&(e=i)}),e}clips(t){return this.ownedClips(t).map(e=>e.info)}playClip(t,e,i={}){let r=this.ownedClips(t);if(!r.length)return{ok:!1,warning:zct(t)};let s=e===void 0?r[0]:Vct(r,e)[0];if(!s)return{ok:!1,warning:Lct(e,r,t)};let n=this.play({clipId:s.info.id,object:s.key,repeat:cOt(i.loop),direction:i.pingpong?"pingpong":"normal"});return n?(n.timeScale=kct(i.speed,1),this.resumeClip(n)||this.startClip(n,s.key,{fade:kct(i.fade,0)}),{ok:!0,clip:s.info}):{ok:!1,warning:`clip "${s.info.name}" has not loaded yet.`}}holdClipsOf(t,e,i){let r=this.ownedClips(e);if(e&&!r.length)return{ok:!1,warning:zct(e)};if(i!==void 0){let n=Vct(r,i);if(!n.length)return{ok:!1,warning:Lct(i,r,e)};r=n}let s=new Set(r.map(n=>n.info.id+"/"+n.key));return this.holdClips(t,(n,a)=>s.has(n+"/"+a)),{ok:!0}}ownedClips(t){let e=[];if(t){let i=this.animatedEntity(t);i&&e.push(i)}else this.scene.traverseEntity(i=>{SP(i).length&&e.push(i)});return e.flatMap(i=>{let r=pG(i),s={id:i.uuid,name:i.name};return SP(i).map(([n,a])=>{let o=this.clipIdToAction[n+"/"+r];return{info:{id:n,name:a,duration:o?Math.round(1e3*this.fullDuration(o))/1e3:0,object:s},key:r,action:o}})})}fullDuration(t){let e=t.getClip();return this.clipDurations.get(e)??e.duration}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.scene.markShadowsDirty(),this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return bwt(this.activeClip??void 0)}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let i=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(t/(this.maxFrames-1),.9999)*this.activeClip.duration),this.scene.markShadowsDirty(),this.requestRender(),i&&(this.clipIdToAction[e].paused=!0)}},M8="imported animations only play while the scene runs (Play mode, the Preview tab, exports).";function mOt(t,e){let i=s=>`no object named "${s}".`,r=(s,n,a)=>{let o=t();if(!o)return{ok:!1,warning:M8};if(n===void 0)return o.holdClipsOf(s,void 0,a);let l=e(n);return l?o.holdClipsOf(s,l,a):{ok:!1,warning:i(n)}};return{getAnimations:s=>{let n=t();if(!n)return{clips:[],warning:M8};if(s===void 0)return{clips:n.clips()};let a=e(s);return a?{clips:n.clips(a)}:{clips:[],warning:i(s)}},playAnimation:(s,n,a)=>{let o=t();if(!o)return{warning:M8};let l=e(s);if(!l)return{warning:i(s)};let h=o.playClip(l,n,a);return{clip:h.clip,warning:h.warning}},pauseAnimation:(s,n)=>r("pause",s,n),stopAnimation:(s,n)=>r("stop",s,n)}}var nv=new Map;function _wt(t,e){if(e===void 0)return;let i=t.scene.find(e);return i?pG(i):e}var $d=class extends En{constructor(t,e,i,r,s){super(),this.page=e,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let n=_wt(e,t.object)??t.object;this.data={...t,object:n};let a=this.animationControls.clipIdToAction[t.clipId+"/"+n];if(this.duration=a?.getClip()?.duration??1,this.data.crop2){let l=bwt(a?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=a?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=t.delay;let o=nv.get(n);o||(o=new Set,nv.set(n,o)),o.add(this)}get playing(){return this.threeAnimAction?.isRunning()??!1}cancelPending(){window.clearTimeout(this.timeoutId),delete this.timeoutId}resume(){let t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object];return!(!t||!this.animationControls.resumeClip(t)||(this.threeAnimAction=t,0))}play(t=!1){if(Ir(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.resume()||(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&this.animationControls.startClip(this.threeAnimAction,this.data.object,{start:this.leftFrameTime,end:this.rightFrameTime,fade:t?.2:0}))},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),this.cancelPending()}stop(){this.threeAnimAction?.fadeOut(.2)}seek(t){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Ft.clamp(this.threeAnimAction.time+1/60*t,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(t,e=!1){if(Ir(this.shared,this.condition)===!1)return!1;this.toggleIsForward=t??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing||this.resume()?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;let[i,r]=this.toggleIsForward?[this.leftFrameTime,this.rightFrameTime]:[this.rightFrameTime,this.leftFrameTime];this.threeAnimAction.time=i,this.threeAnimAction._clip.start=i,this.threeAnimAction._clip.duration=r,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.animationControls.replaceOtherClips(this.threeAnimAction,this.data.object,e?.2:0)},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();t&&(t.duration=this.duration),this.pause();let e=nv.get(this.data.object);e&&(e.delete(this),e.size===0&&nv.delete(this.data.object))}},fOt=class{constructor(t,e,i){this.data=t,this.page=e,this.animationControls=i,this.objectId=_wt(e,t.object)}dispatch(){this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{this.apply(),this.disposeDelay()},this.data.delay)):this.apply()}targetsClip(t,e){return!(this.objectId!==void 0&&e!==this.objectId||this.data.clipId&&t!==this.data.clipId)}apply(){(this.objectId!==void 0?[nv.get(this.objectId)]:[...nv.values()]).forEach(t=>{t?.forEach(e=>{this.targetsClip(e.data.clipId,e.data.object)&&e.cancelPending()})}),this.animationControls.holdClips(this.data.interaction,(t,e)=>this.targetsClip(t,e))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){this.disposeDelay()}},gOt=class{constructor(t,e,i,r,s){BU.isPause(t)?this.interaction=new fOt(t,e,i):this.interaction=new $d(t,e,i,r,s)}get data(){return this.interaction.data}get playing(){return this.interaction instanceof $d&&this.interaction.playing}play(t=!1){if(this.interaction instanceof $d)return this.interaction.play(t);this.interaction.dispatch()}pause(){this.interaction instanceof $d&&this.interaction.pause()}stop(){this.interaction instanceof $d&&this.interaction.stop()}seek(t){this.interaction instanceof $d&&this.interaction.seek(t)}toggle(t,e=!1){if(this.interaction instanceof $d)return this.interaction.toggle(t,e);this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof $d?this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof $d&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}},xwt=null;Ni(),xwt=dG,eo("Transition",({eventType:t,data:e,page:i,shared:r,actionCondition:s,runModeOverride:n,object:a})=>new uOt(t,e,i,r,s,n,a)),eo("Animation",({data:t,page:e,eventManager:i,shared:r,actionCondition:s})=>new gOt(t,e,i.animationControls,r,s)),Nr("transitions"),ir();var Fct=(t,e)=>e.some(i=>i instanceof RegExp?i.test(t):i===t),yOt=class{constructor({url:t,context:e},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:function(n,a){if(a={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...a},n=n.trim(),/^data:/i.test(n))return((u,{stripHash:d})=>{let c=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(u);if(!c)throw new Error(`Invalid URL: ${u}`);let{type:p,data:m,hash:f}=c.groups,g=p.split(";");f=d?"":f;let y=!1;g[g.length-1]==="base64"&&(g.pop(),y=!0);let v=(g.shift()||"").toLowerCase(),b=[...g.map(_=>{let[x,S=""]=_.split("=").map(w=>w.trim());return x==="charset"&&(S=S.toLowerCase(),S==="us-ascii")?"":`${x}${S?`=${S}`:""}`}).filter(Boolean)];return y&&b.push("base64"),(b.length>0||v&&v!=="text/plain")&&b.unshift(v),`data:${b.join(";")},${y?m.trim():m}${f?`#${f}`:""}`})(n,a);if(/^view-source:/i.test(n))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let o=n.startsWith("//");!o&&/^\.*\//.test(n)||(n=n.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,a.defaultProtocol));let l=new URL(n);if(a.forceHttp&&a.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(a.forceHttp&&l.protocol==="https:"&&(l.protocol="http:"),a.forceHttps&&l.protocol==="http:"&&(l.protocol="https:"),a.stripAuthentication&&(l.username="",l.password=""),a.stripHash?l.hash="":a.stripTextFragment&&(l.hash=l.hash.replace(/#?:~:text.*?$/i,"")),l.pathname){let u=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,d=0,c="";for(;;){let p=u.exec(l.pathname);if(!p)break;let m=p[0],f=p.index;c+=l.pathname.slice(d,f).replace(/\/{2,}/g,"/"),c+=m,d=f+m.length}c+=l.pathname.slice(d,l.pathname.length).replace(/\/{2,}/g,"/"),l.pathname=c}if(l.pathname)try{l.pathname=decodeURI(l.pathname)}catch{}if(a.removeDirectoryIndex===!0&&(a.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(a.removeDirectoryIndex)&&a.removeDirectoryIndex.length>0){let u=l.pathname.split("/"),d=u[u.length-1];Fct(d,a.removeDirectoryIndex)&&(u=u.slice(0,-1),l.pathname=u.slice(1).join("/")+"/")}if(l.hostname&&(l.hostname=l.hostname.replace(/\.$/,""),a.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(l.hostname)&&(l.hostname=l.hostname.replace(/^www\./,""))),Array.isArray(a.removeQueryParameters))for(let u of[...l.searchParams.keys()])Fct(u,a.removeQueryParameters)&&l.searchParams.delete(u);if(a.removeQueryParameters===!0&&(l.search=""),a.sortQueryParameters){l.searchParams.sort();try{l.search=decodeURIComponent(l.search)}catch{}}a.removeTrailingSlash&&(l.pathname=l.pathname.replace(/\/$/,""));let h=n;return n=l.toString(),!a.removeSingleSlash&&l.pathname==="/"&&!h.endsWith("/")&&l.hash===""&&(n=n.replace(/\/$/,"")),(a.removeTrailingSlash||l.pathname==="/")&&l.hash===""&&a.removeSingleSlash&&(n=n.replace(/\/$/,"")),o&&!a.normalizeProtocol&&(n=n.replace(/^http:\/\//,"//")),a.stripProtocol&&(n=n.replace(/^(?:https?:)?\/\//,"")),n}(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;aT?window.location.assign(this.url):(this.context==="tab"||Zmt&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(Ge[0]),Ge.splice(0,Ge.length))}},vOt=class{constructor(t,e,i,r,s){this.data=t,this.page=e,this.shared=i,this.eventManager=r,this.condition=s}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Vq(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},1e3*(this.data.delay??0))}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};ht();var bOt={type:"beginState"},Uct={type:"completeState",isfromEntity:!1},jct={type:"requestRender"},_Ot=class extends En{constructor(t,e,i,r){super(),this.data=t,this.page=e,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new P,this.posEnd=new P,this.qStart=new Te,this.qEnd=new Te,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(t){if(!this.data.animate)return;let e=this.page.scene.find(this.data.targetCamera);if(!e||!e.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let i={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:gwt(this.data)},r=s=>{let n=this.page.activeCamera;n.position.lerpVectors(this.posStart,this.posEnd,s),n.quaternion.slerpQuaternions(this.qStart,this.qEnd,s),n.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*s,n.wasMovedBySwitchCameraAction=!0,n.updateMatrix(),n.updateMatrixWorld(),n.updateProjectionMatrix(),n.dispatchEvent(jct),s===1&&n.dispatchEvent(Uct)};this.runner=new awt(i,r,()=>{t?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(e.position),this.qEnd.copy(e.quaternion),this.zoomEnd=e.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(e.uuid)),this.page.activeCamera.dispatchEvent(bOt),r(0)})}get togglesBack(){return this.data.runMode==="Toggle"&&!this.toggleIsForward}update(t){this.runner?.update(t),this.runner?.isPlaying!==!0&&Ls.remove(this)}start(){!this.runner||(this.runner.start(Ls.time),Ls.add(this))}switchCamera(t){let e=this.page.activeCamera,i=this.page.scene.find(t);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),e.dispatchEvent({type:"cameraChange",camera:i})}jumpToCamera(t){this.switchCamera(t),this.page.activeCamera.dispatchEvent(Uct),this.page.activeCamera.dispatchEvent(jct)}play(){if(Ir(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(!1),this.start()):this.jumpToCamera(this.data.targetCamera)},1e3*this.data.delay)}catch{}}pause(){this.runner?.stop(),Ls.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(t){if(Ir(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,t!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=t??!this.toggleIsForward,this.buildAnimation(this.togglesBack),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=t??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(this.togglesBack),this.start()):this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.jumpToCamera(this.data.targetCamera)):this.fromCamera&&this.jumpToCamera(this.fromCamera.uuid)},1e3*this.data.delay)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};MW();var xOt=class{constructor(t,e,i,r){this.data=t,this.page=e,this.shared=i,this.condition=r}dispatch(){if(Ir(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(t=>{this.shared.getVariable(t);let e=this.shared.data.variables.data(t)?.value;e!==void 0&&this.shared.updateVariable(t,e),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(Vj(t))})}dispose(){}};Ni(),eo("Link",({data:t,eventManager:e,shared:i,actionCondition:r})=>new yOt(t,e.controlsManager,i,r)),eo("Reset",({data:t,page:e,shared:i,eventManager:r,actionCondition:s})=>new vOt(t,e,i,r,s)),eo("SwitchCamera",({data:t,page:e,shared:i,actionCondition:r})=>new _Ot(t,e,i,r)),eo("ClearLocalStorage",({data:t,page:e,shared:i,actionCondition:r})=>new xOt(t,e,i,r)),Nr("misc-actions"),Ni(),_o(),sh(),HW(),MW();var wOt=class{get sharedAssets(){return this.shared}constructor(t,e={},i=!0,{dedupeParametricGeometries:r=!1}={}){this.shared=new i5(t.shared,e,!0,i),this.shared.geometryCache.dedupeByValue=r,this.scene=new Vg(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof Or&&!t.uiScene&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.scene.releaseInstanceGroups(),this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Ur&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};HW(),Ui();var av,A8,C8="vertexOrder";function Gct(t){return A8||(A8=Promise.resolve().then(()=>(fEt(),h1t)).then(({DRACOLoader:e})=>((av=new e).setDecoderPath(t!==void 0?`${t}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload(),av.decoderPending))),A8}async function SOt(t){if(av){let e,i={attributeIDs:{...av.defaultAttributeIDs,[C8]:"GENERIC"},attributeTypes:{...av.defaultAttributeTypes,[C8]:"Uint32Array"},useUniqueIDs:!1};try{e=await av.decodeGeometry(new Int8Array(t).buffer,i)}catch(r){console.error(r)}if(e)return function(r){let s=r.attributes.find(u=>u.name===C8);if(!s)return r;let n=s.array,a=n.length,o=0;for(let u=0;u<a;u++)o=Math.max(o,n[u]+1);let l,h=r.attributes.filter(u=>u!==s).map(({name:u,itemSize:d,array:c})=>{let p=new Float32Array(o*d);for(let m=0;m<p.length;m++)p[m]=c[m%d];for(let m=0;m<a;m++){let f=n[m]*d,g=m*d;for(let y=0;y<d;y++)p[f+y]=c[g+y]}return{name:u,itemSize:d,array:p}});if(r.index){let u=r.index.array,d=new Uint32Array(u.length);for(let c=0;c<u.length;c++)d[c]=n[u[c]];l={array:d}}return{index:l,attributes:h}}({index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))})}return null}async function Wct(t){for(let e of t){let i=await SOt(e.geometry.data.draco);if(i){let r=e.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};i.attributes.forEach(({name:n,array:a,itemSize:o})=>{s[n]={array:a,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=s,r.draco=void 0}}}cD(),rb(),vT(),_T(),dW(),Dm(),fD(),r1t(),l1t(),kc(),nD(),sh(),u0t(),d0(),bT(),i0t(),$W();var TOt={bloom:()=>Promise.resolve().then(()=>(AEt(),MEt)),depthOfField:()=>Promise.resolve().then(()=>(REt(),PEt))};function MOt(t){return function(e,i){return Promise.all(e.map(r=>i[r]?.().catch(s=>{console.warn(`[spline] Failed to load the ${r} postprocessing effect (webgpu); the effect will be skipped.`,s)}))).then(()=>{})}(t,TOt)}var TP=new WeakMap,qct=new WeakMap;function Hct(t,e,i){let r=s=>{t.removeEventListener(e,r,!0),s.stopImmediatePropagation(),i(s)};return t.addEventListener(e,r,!0),()=>t.removeEventListener(e,r,!0)}ir();var AOt=Zv(DEt(),1);function MP(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function COt(t){return{id:t.uuid,name:t.name,type:t.object.data?.type??t.object.type,visible:t.playModeVisible!==!1,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ft.RAD2DEG,y:t.rotation.y*Ft.RAD2DEG,z:t.rotation.z*Ft.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},spawned:!0}}function AP(t){return{id:t.uuid,name:t.name,type:t.type??"Object",visible:t.visible,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x*Ft.RAD2DEG,y:t.rotation.y*Ft.RAD2DEG,z:t.rotation.z*Ft.RAD2DEG},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}}function wwt(t,e,i){let r=a=>t.findObjectById(a)??t.findObjectByName(a),s=new Map,n=a=>{let o=s.get(a);if(o)return o;for(let l of s.values())if(l.name===a)return l};return{setVariable:(a,o)=>a in t.getVariables()?(t.setVariable(a,o),{ok:!0}):{ok:!1,warning:`spline.setVariable: no variable named "${a}" in this scene.`},getVariable:a=>t.getVariable(a),getVariables:()=>t.getVariables(),getAllObjects:()=>t.getAllObjects().map(AP),findObject:a=>{let o=r(a);return o?AP(o):void 0},getGeometry:(a,o)=>{if(!i)return{warning:"spline.getGeometry: not available in this runtime integration."};let l=n(a),h=l?l.object:(()=>{let p=r(a);return p?i.findEntity(p.uuid):void 0})();if(!h)return{warning:`spline.getGeometry: no object named "${a}" (names/ids come from getAllObjects).`};let u,d=l??h;o.space==="world"&&(d.updateWorldMatrix?.(!0,!1),u=d.matrixWorld?.elements);let c=function(p,m){let f=p?.getAttribute("position");if(!f||!f.count)return null;let g=f.count,y=m??null,v=p.getIndex?.()??null,b=Math.floor((v?v.count:g)/3),_=1/0,x=1/0,S=1/0,w=-1/0,T=-1/0,C=-1/0,M=new Float32Array(3*g);for(let O=0;O<g;O++){let B=f.getX(O),V=f.getY(O),z=f.getZ(O);y&&([B,V,z]=XAt(y,B,V,z)),B<_&&(_=B),V<x&&(x=V),z<S&&(S=z),B>w&&(w=B),V>T&&(T=V),z>C&&(C=z),M[3*O]=B,M[3*O+1]=V,M[3*O+2]=z}let A={space:y?"world":"local",vertexCount:g,triangleCount:b,indexed:v!==null,bounds:{min:[_,x,S],max:[w,T,C],size:[w-_,T-x,C-S]},vertices:M};if(v){let O=new Uint32Array(v.count);for(let B=0;B<v.count;B++)O[B]=v.getX(B);A.indices=O}let R=p.getAttribute("normal");if(R&&R.count===g){let O=y?function(B){let V=B[0],z=B[4],k=B[8],L=B[1],H=B[5],W=B[9],X=B[2],nt=B[6],st=B[10],yt=V*(H*st-W*nt)-z*(L*st-W*X)+k*(L*nt-H*X);if(!isFinite(yt)||Math.abs(yt)<1e-12)return null;let pt=1/yt,Q=[(H*st-W*nt)*pt,(k*nt-z*st)*pt,(z*W-k*H)*pt,(W*X-L*st)*pt,(V*st-k*X)*pt,(k*L-V*W)*pt,(L*nt-H*X)*pt,(z*X-V*nt)*pt,(V*H-z*L)*pt];return[Q[0],Q[3],Q[6],Q[1],Q[4],Q[7],Q[2],Q[5],Q[8]]}(y):void 0;if(!y||O){let B=new Float32Array(3*g);for(let V=0;V<g;V++){let z=R.getX(V),k=R.getY(V),L=R.getZ(V);if(O){let H=O[0]*z+O[1]*k+O[2]*L,W=O[3]*z+O[4]*k+O[5]*L,X=O[6]*z+O[7]*k+O[8]*L,nt=Math.hypot(H,W,X);nt>1e-12?(z=H/nt,k=W/nt,L=X/nt):(z=H,k=W,L=X)}B[3*V]=z,B[3*V+1]=k,B[3*V+2]=L}A.normals=B}}let I=p.getAttribute("uv");if(I&&I.count===g){let O=new Float32Array(2*g);for(let B=0;B<g;B++)O[2*B]=I.getX(B),O[2*B+1]=I.getY(B);A.uvs=O}return A}(h.geometry,u);return c?{data:{id:d.uuid,name:d.name,geometry:h.data?.geometry?.type,...c}}:{warning:`spline.getGeometry: "${d.name}" has no readable geometry \u2014 only meshes do (lights, cameras and groups have none; read a group's child meshes instead).`}},updateObject:(a,o)=>{let l=n(a);if(l){let{position:g,rotation:y,scale:v,visible:b}=o;return g&&(typeof g.x=="number"&&(l.position.x=g.x),typeof g.y=="number"&&(l.position.y=g.y),typeof g.z=="number"&&(l.position.z=g.z)),y&&(typeof y.x=="number"&&(l.rotation.x=y.x*Ft.DEG2RAD),typeof y.y=="number"&&(l.rotation.y=y.y*Ft.DEG2RAD),typeof y.z=="number"&&(l.rotation.z=y.z*Ft.DEG2RAD)),v&&(typeof v.x=="number"&&(l.scale.x=v.x),typeof v.y=="number"&&(l.scale.y=v.y),typeof v.z=="number"&&(l.scale.z=v.z)),typeof b=="boolean"&&(l.playModeVisible=b),l.updateMatrix(),t.requestRender(),!0}let h=r(a);if(!h)return!1;let{position:u,rotation:d,scale:c,visible:p,geometry:m,material:f}=o;if(m&&typeof m=="object"&&i){let g=i.findEntity(h.uuid);if(g){let{vertices:y,normals:v,uvs:b,indices:_,...x}=m;MP(y)&&i.shared.updateEntityGeometryVertices(g,{vertices:y,normals:MP(v)?v:void 0,uvs:MP(b)?b:void 0,indices:MP(_)?_:void 0}),Object.keys(x).length>0&&i.shared.updateEntityGeometryParams(g,x)}}if(f&&typeof f=="object"&&i){let g=i.findEntity(h.uuid);g&&i.shared.updateEntityMaterialParams(g,f)}return u&&(typeof u.x=="number"&&(h.position.x=u.x),typeof u.y=="number"&&(h.position.y=u.y),typeof u.z=="number"&&(h.position.z=u.z)),d&&(typeof d.x=="number"&&(h.rotation.x=d.x*Ft.DEG2RAD),typeof d.y=="number"&&(h.rotation.y=d.y*Ft.DEG2RAD),typeof d.z=="number"&&(h.rotation.z=d.z*Ft.DEG2RAD)),c&&(typeof c.x=="number"&&(h.scale.x=c.x),typeof c.y=="number"&&(h.scale.y=c.y),typeof c.z=="number"&&(h.scale.z=c.z)),typeof p=="boolean"&&(h.visible=p),t.requestRender(),!0},createObject:async(a,o)=>AP(await t.createObject(a,o)),createCustomMaterial:a=>t.createCustomMaterial(a),getTexture:(a,o)=>{if(!i)return null;let l=r(a),h=l?i.findEntity(l.uuid):void 0;if(!h)return null;let u=i.shared.getEntityTexture(h,o??{});return u?{texture:u.texture,width:u.width,height:u.height,layer:u.layerType}:null},setMaterial:(a,o)=>t.setMaterial(a,o),cloneObject:(a,o)=>AP(t.cloneObject(a,o)),removeObject:a=>t.removeObject(a),spawnObject:(a,o)=>{if(!i)return{warning:"spline.spawnObject: not available in this runtime integration."};let l=r(a),h=l?i.findEntity(l.uuid):void 0;if(!h)return{warning:`spline.spawnObject: no object named "${a}" to use as a template.`};if(s.size>=500)return{warning:"spline.spawnObject: spawn budget reached (500 live copies) \u2014 destroyObject old copies (or reuse them) instead of spawning more."};let u=i.shared.spawnRuntimeClone(h,o??{});return u?(s.set(u.uuid,u),t.requestRender(),{object:COt(u)}):{warning:`spline.spawnObject: "${a}" cannot be spawned from.`}},destroyObject:a=>{let o=n(a);return!(!i||!o||(s.delete(o.uuid),i.shared.destroyRuntimeClone(o),t.requestRender(),0))},setInstanceTransforms:(a,o)=>{if(!i)return-1;let l=r(a),h=l?i.findEntity(l.uuid):void 0;if(!h)return-1;let u=i.shared.setEntityInstanceTransforms(h,o);return u>=0&&t.requestRender(),u},...mOt(()=>i?.getAnimationControls(),a=>{let o=r(a);return o?i?.findEntity(o.uuid):void 0}),emitEvent:(a,o,l)=>{let h=r(o);return h?(l?h.emitEventReverse(a):h.emitEvent(a),{ok:!0}):{ok:!1,warning:`spline.emitEvent: no object named "${o}".`}},requestRender:()=>t.requestRender(),addSplineEventListener:(a,o)=>{let l=h=>{o({target:{id:h.target?.id??"",name:h.target?.name??""}})};return t.addEventListener(a,l),()=>t.removeEventListener(a,l)},getCanvas:()=>e}}ht(),ir();var Swt=class{constructor(t,e,i){this.iframe=t,this.bridge=e,this.observer=i}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("iframe");n.setAttribute("sandbox","allow-scripts allow-forms allow-pointer-lock"),n.title="Spline HTML content";let a=n.style;a.position="absolute",a.border="0",a.background="transparent",a.pointerEvents="auto",a.colorScheme="normal";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(s),n.srcdoc=function(u){let d=`<script>${tft}<\/script>`,c=/<head(\s[^>]*)?>/i.exec(u);if(c){let m=c.index+c[0].length;return u.slice(0,m)+d+u.slice(m)}let p=/<html(\s[^>]*)?>/i.exec(u);if(p){let m=p.index+p[0].length;return u.slice(0,m)+`<head>${d}</head>`+u.slice(m)}return d+u}(i),s.insertBefore(n,e.nextSibling);let h=new ift(n,wwt(t,e,r),(u,d)=>{u==="warn"?console.warn(`[spline html] ${d}`):u==="error"&&console.error(`[spline html] ${d}`)});return h.attach(),new Swt(n,h,l)}dispose(){this.bridge.dispose(),this.observer.disconnect(),this.iframe.remove()}};ir();var QR="data-spline-html-content",EOt=`
5188
5188
  [${QR}] { pointer-events: none; }
5189
5189
  [${QR}] > * { pointer-events: auto; }
5190
5190
  [${QR}] [data-spline-passthrough] { pointer-events: none; }
5191
- `,Twt=class{constructor(t,e,i,r,s,n){this.container=t,this.host=e,this.observer=i,this.spline=r,this.previousSplineGlobal=s,this.removeLateLifecycleShim=n}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("div");n.setAttribute(QR,"");let a=n.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(s);let h=document.createElement("style");h.textContent=EOt,n.appendChild(h);let u=new DOMParser().parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(u.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;u.body.firstChild;)n.appendChild(u.body.firstChild);s.insertBefore(n,e.nextSibling);let c=new Map,p=new DG(wwt(t,e,r),(v,b)=>{v==="warn"?console.warn(`[spline html] ${b}`):v==="error"&&console.error(`[spline html] ${b}`)},(v,b)=>{let _=c.get(v);if(_)for(let x of _)try{x(b)}catch(S){console.error(S)}}),m=(v,b)=>{try{return Promise.resolve(p.execute(v,b))}catch(_){return Promise.reject(_)}},f={ready:Promise.resolve(),setVariable:(v,b)=>m("setVariable",[v,b]),setVariables:v=>m("setVariables",[v]),getVariable:v=>m("getVariable",[v]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:v=>m("findObjectByName",[v]),findObjectById:v=>m("findObjectById",[v]),getGeometry:(v,b)=>m("getGeometry",[v,b??{}]),updateObject:(v,b)=>m("updateObject",[v,b]),createObject:(v,b)=>m("createObject",[v,b??{}]),createCustomMaterial:v=>m("createCustomMaterial",[v]),getTexture:(v,b)=>m("getTexture",[v,b??{}]),setMaterial:(v,b)=>m("setMaterial",[v,b]),cloneObject:(v,b)=>m("cloneObject",[v,b??{}]),removeObject:v=>m("removeObject",[v]),spawnObject:(v,b)=>m("spawnObject",[v,b??{}]),destroyObject:v=>m("destroyObject",[v]),setInstanceTransforms:(v,b)=>m("setInstanceTransforms",[v,b??null]),getAnimations:v=>m("getAnimations",[v]),playAnimation:(v,b,_)=>m("playAnimation",[v,b,_]),pauseAnimation:(v,b)=>m("pauseAnimation",[v,b]),stopAnimation:(v,b)=>m("stopAnimation",[v,b]),emitEvent:(v,b)=>m("emitEvent",[v,b]),emitEventReverse:(v,b)=>m("emitEventReverse",[v,b]),requestRender:()=>m("requestRender",[]),addEventListener:(v,b)=>{if(typeof b!="function")return;let _=c.get(v);_||(_=new Set,c.set(v,_),m("listenEvent",[v])),_.add(b)},removeEventListener:(v,b)=>{let _=c.get(v);!_||(_.delete(b),_.size===0&&(c.delete(v),m("unlistenEvent",[v])))}},g=window.spline;window.spline=f;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],b=(x,S)=>{let w=new Set,T=x.addEventListener.bind(x),C=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{if(T(M,A,R),!S.includes(M)||A==null)return;let I={type:M,listener:A};w.add(I),queueMicrotask(()=>{!w.delete(I)||((O,B,V)=>{let z=new Event(V);try{typeof B=="function"?B.call(O,z):B.handleEvent?.(z)}catch(k){console.error(k)}})(x,I.listener,I.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{C(M,A,R);for(let I of w)I.type===M&&I.listener===A&&w.delete(I)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,w.clear()})};b(document,["DOMContentLoaded"]),b(window,["load"]);let _=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(S){console.error(S)}})}}),v.push(()=>{_?Object.defineProperty(window,"onload",_):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of d){let b=document.createElement("script");for(let _ of Array.from(v.attributes))b.setAttribute(_.name,_.value);v.src?b.async=!1:b.textContent=v.textContent,n.appendChild(b)}return new Twt(n,p,l,f,g,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function Mwt(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function $ct(t){if(typeof t.material=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(!Mwt(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=Ij()?.NodeMaterial;if(i!==void 0&&e instanceof i)return{options:{...t,material:void 0},material:e};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => \u2026) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, \u2026).")}if(e.isShaderMaterial===!0)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend \u2014 port the shader to TSL with app.createCustomMaterial((three) => \u2026), or use a built-in material (MeshStandardMaterial, \u2026).");return{options:{...t,material:void 0},material:e}}Be(),Ui(),ht(),syt(),kc(),Ui(),Be(),j3t(),Rm();var POt=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),Xct="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",ROt={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},DOt={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},OOt={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data \u2014 clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime \u2014 clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto \u2014 clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame \u2014 clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor \u2014 clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},IOt={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},NOt={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function sT(t,e){return t===void 0?[e[0],e[1],e[2]]:Array.isArray(t)?[t[0]??e[0],t[1]??e[1],t[2]??e[2]]:[t.x??e[0],t.y??e[1],t.z??e[2]]}function Awt(t){return typeof t=="number"?[t,t,t]:sT(t,[1,1,1])}function mG(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function Yct(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return ls.defaultColorMaterial(Kct(i0),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(e.shared.materials))if(a===i||o.name===i)return a;if(function(a){let o=a.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)||/^(rgb|hsl)a?\(/.test(o)||ae.NAMES[o]!==void 0}(i))return ls.defaultColorMaterial(mG(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(a){let o=Object.entries(a.shared.materials).map(([,l])=>`'${l.name}'`).filter(l=>l!=="'undefined'");return o.length?o.join(", "):"(none)"}(e)}) and is not a valid CSS color.`)}if(typeof i=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(Mwt(i))throw new Error("createObject: a three.js material instance cannot be stored in the document \u2014 this entry point does not support it.");let r=i.color!==void 0?mG(i.color):Kct(i0),s=ls.defaultColorMaterial(r,"physical","layer1","layer2"),n=s.layers.find(a=>a.data.type==="light");if(n){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(n.data,a)}if(i.alpha!==void 0){let a=s.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return s}function Kct(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function BOt(t){let e=dc.defaultData("TextGeometry"),{text:i,...r}=t,s=r.fontSize;return s!==void 0&&r.width===void 0&&(r.width=350*s/16),s!==void 0&&r.height===void 0&&(r.height=50*s/16),Object.assign(e,r),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function CP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function kOt(t,e){return Pgt({userData:{type:t,...Rj[t].normalizeInputs({parameters:e})}})}function VOt(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let h={};for(let[u,d]of Object.entries(l))!POt.has(u)&&d!==void 0&&(h[u]=d);return h}(e),a={states:new ce,events:new ce};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:h}=function(u){let d=CP(u.vertices);if(!d||d.length<9||d.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let c=d.length/3;if(c>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${c}); keep it under 60000.`);let p=CP(u.indices);if(p&&p.length){let b=p.find(_=>!Number.isInteger(_)||_<0||_>=c);if(b!==void 0)throw new Error(`createObject('CustomMesh'): index ${b} is out of range (mesh has ${c} vertices).`)}else p=null;let m=new ye;m.setAttribute("position",new ge(d,3));let f=CP(u.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new ge(f,3));let y=CP(u.uvs);y&&y.length===2*c&&m.setAttribute("uv",new ge(y,2));let v=!1;if(!g){let b=p??Array.from({length:c},(S,w)=>w),{closed:_,inverted:x}=function(S,w){let T=S.length/3,C=new Map,M=new Array(T);for(let O=0;O<T;O++){let B=`${Math.round(1e4*S[3*O])},${Math.round(1e4*S[3*O+1])},${Math.round(1e4*S[3*O+2])}`,V=C.get(B);V===void 0?(C.set(B,O),M[O]=O):M[O]=V}let A=new Map;for(let O=0;O+2<w.length;O+=3){let B=M[w[O]],V=M[w[O+1]],z=M[w[O+2]];for(let[k,L]of[[B,V],[V,z],[z,B]]){if(k===L)continue;let H=k<L?k+"_"+L:L+"_"+k;A.set(H,(A.get(H)??0)+1)}}let R=A.size>0;for(let O of A.values())if(O!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let I=0;for(let O=0;O+2<w.length;O+=3){let B=3*w[O],V=3*w[O+1],z=3*w[O+2],k=S[B],L=S[B+1],H=S[B+2],W=S[V],X=S[V+1],nt=S[V+2],st=S[z],yt=S[z+1],pt=S[z+2];I+=k*(X*pt-nt*yt)+L*(nt*st-W*pt)+H*(W*yt-X*st)}return{closed:!0,inverted:I<0}}(d,b);if(_&&x){for(let S=0;S+2<b.length;S+=3){let w=b[S+1];b[S+1]=b[S+2],b[S+2]=w}p=b}else _||(v=!0)}return p&&m.setIndex(p),g||m.computeVertexNormals(),{geometry:Pgt({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,ku.defaultData,{geometry:l,materials:[Yct(e,i)]}),h&&(a.side=2)}else Object.assign(a,ku.defaultData,{geometry:s==="TextGeometry"?BOt(n):kOt(s,n),material:Yct(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,z4.defaultData):(Object.assign(a,L4.defaultData(r),n),e.color!==void 0&&(a.color=mG(e.color)));a.visible=e.visible??!0,a.position=sT(e.position,[0,0,0]),a.rotation=sT(e.rotation,[0,0,0]),a.scale=Awt(e.scale);let o=(s&&IOt[s])??NOt[r]??r;return a.name=e.name??Cwt(o,i.scene.objects),a}function Cwt(t,e){let i=new Set;if(e.traverse((s,n)=>{i.add(n.name??"")}),!i.has(t))return t;let r=2;for(;i.has(`${t} ${r}`);)r++;return`${t} ${r}`}function Ewt(t,e){let i=Ft.generateUUID();if(t.data.type==="Component")return{data:{..._c.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let r=t.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:x3t(r.animations,Ft.generateUUID,e)}),{...t,id:i,data:r,children:t.children.map(s=>Ewt(s,e))}}function zOt(t){let e={};return function(i,r){return hv(i,r,null)??i}(Ewt(t,e),e)}function LOt(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(FOt)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function FOt(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}Rm(),ts(),hW(),kc();var Vw=new Dr(0,0,0,1),UOt={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};Be(),Be();var jOt=new Z;function Zct(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var Pwt=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:n="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._startOrder=0,this._claimedOrder=0,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<Dgt?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),n0(o)&&(this._renderer?.isWebGPUSplineRenderer!==!0&&o.warnClassicFallbackOnce(),o.isSimulating&&(o.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let o=Math.min(1,1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration);this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=o,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),this._renderer.lastFrameIncomplete===!0&&(this._skipRender=!1),this._renderer.skyAnimationActive===!0&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=jOt.set(this._viewportWidth,this._viewportHeight)),a){let o=this._viewportWidth,l=this._viewportHeight;this._renderer.setSize(o-1,l-1,!1),this._renderer.setSize(o,l,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=LS(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=n,this.renderMode=e?"auto":i,r!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(r)),this._rendererBackend=s??"webgl",s===void 0){let a=null;try{a=new URLSearchParams(window.location.search).get("renderer")}catch{}a==="webgpu"||a==="webgl"||a==="webgl2"?this._rendererBackend=a==="webgl2"?"webgl":a:(this._rendererAuto=!0,this._rendererBackend=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(OEt(),zvt)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",vX,!0),a.addEventListener("pointerdown",EM,!0),a.addEventListener("pointermove",EM,!0),a.addEventListener("pointerup",L0,!0),a.addEventListener("pointercancel",L0,!0),a.addEventListener("pointerleave",L0,!0),window.addEventListener("keydown",bX,!0),window.addEventListener("keyup",_X,!0)}(t)}async _ensureRenderer(){return this._renderer?this._renderer:(this._rendererInit||(this._rendererInit=this._initRenderer().then(t=>(this._rendererInit=void 0,t&&(this._renderer=t),t),t=>{throw this._rendererInit=void 0,t})),this._rendererInit)}async _initRenderer(){if(this.disposed)return null;let t=await this._createRenderer();return this.disposed?(this._disposeRenderer(t),null):t}_disposeRenderer(t){let e=function(r){let s=r.backend;if(s!==void 0)return s.isWebGLBackend===!0?s.gl??null:null;let n=r.getContext,a=typeof n=="function"?n.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(t);if(e&&!function(r,s){return qct.get(r)===s}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(t)||t.dispose());let i=e?function(r,s){let n=s.getExtension("WEBGL_lose_context");if(!n||s.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=Hct(r,"webglcontextlost",h=>{h.preventDefault(),l(n)})});return TP.set(r,{gl:s,lost:o,stopListening:a}),()=>{s.isContextLost()||n.loseContext()}}(this.canvas,e):void 0;try{t.dispose()}finally{i?.()}}async _createRenderer(){if(function(t,e){qct.set(t,e)}(this.canvas,this),await async function(t){let e=TP.get(t);if(e&&(e.restoring??(e.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let s,n=()=>{},a=r.lost.then(l=>new Promise(h=>{n=Hct(i,"webglcontextrestored",()=>h()),l.restoreContext()})),o=new Promise(l=>{s=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(s),n(),r.stopListening()}(t,e).finally(()=>{e.restoring=void 0,!e.gl.isContextLost()&&TP.get(t)===e&&TP.delete(t)})),await e.restoring,e.gl.isContextLost()))throw new Error("[spline] The browser did not restore the WebGL context this canvas had before dispose(); the scene cannot render on it. Use a new canvas.")}(this.canvas),this._rendererBackend==="webgpu"&&this._rendererAuto)try{await navigator.gpu?.requestAdapter()||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if(this._rendererBackend==="webgpu")try{let{createWebGPUSplineRenderer:t,isWebGPUSupported:e}=await Promise.resolve().then(()=>(PF(),$R));e();let i=!0,r=!1;try{let n=new URLSearchParams(window.location.search),a=n.get("bundles");a==="rerecord"?i="rerecord":(a==="off"||a==="0"||a==="false"||a==="no")&&(i=!1),r=n.get("forcegl")==="1"}catch{}let s=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:this._asyncShaderCompilation()});return s.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},s.skyAnimationAllowed=!0,s}catch(t){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",t),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_asyncShaderCompilation(){let t=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let e=new URLSearchParams(window.location.search);if(e.get("forcegl")==="1")return!1;let i=e.get("asynccomp");i==="off"||i==="0"||i==="false"||i==="no"?t=!1:(i==="on"||i==="1"||i==="true"||i==="always")&&(t=!0)}catch{}return t}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let t=window.devicePixelRatio||1,e=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=e*t,this.canvas.height=i*t;let r=this.canvas.getContext("2d");r&&(r.scale(t,t),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText("This scene requires a WebGPU-capable browser.",e/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(t,e,i){(function(s){let n="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";s.endsWith(".spline")?console.warn(n+" The .spline files are only meant to be used by the Editor."):s.endsWith(".splinecode")||console.warn(n)})(t),this.disposed=!1;let r=await(await fetch(t,i)).arrayBuffer();await this.start(r,{variables:e})}async start(t,e={}){if(this.disposed)return;let i,r=++this._startOrder,s=()=>this._claimedOrder>r;return i=this._start(t,e,s,()=>!s()&&(this._claimedOrder=r,this._claimedStart=i,!0)).then(()=>s()?this._claimedStart:void 0,n=>{if(!s())throw n;return this._claimedStart}),i}async _start(t,{interactive:e=!0,variables:i},r,s){Ls.init();let n=await async function(f){let[g,y]=Qw(FS.deserialize(new Uint8Array(f)));if((g.schema??0)!==135){let{updateDocumentSchema:v}=await Promise.resolve().then(()=>(sD(),ygt));v(g)}return y.result().data}(t);if(r())return;let a=function(f){let g=[];return f.scene.objects.traverse((y,v)=>{v.type==="Mesh"&&v.geometry.type==="NonParametricGeometry"&&v.geometry.data.draco!==void 0&&g.push(v)}),g}(n);n.version&&(0,AOt.default)(n.version,"2.0.121")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath!==void 0&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(f){p1t=f}(this._wasmPath));let o=async function(){}();if(await Promise.all([o,a.length&&Gct(this._wasmPath),PZ(n)&&K3t(this._wasmPath),vCt(n)&&yCt(this._wasmPath),GCt(n)&&MCt(this._wasmPath),s0.physicsEnabled(n.scene.objects)&&z4t(this._wasmPath),PK(n)&&Tdt(),JZ(n)&&cEt(),aCt(n)&&nCt(),gdt(n)&&o.then(()=>rj()?.loadHanaUIRUNTIME()),D4t(n)&&e5t(this._wasmPath)].filter(Boolean)),r()||a.length&&(await Wct(a),r())||!s())return;this._data=n,this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let l=n.scene.publish.renderer;if(this._rendererAuto&&l==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&l==="webgpu"){let f=this._rendererBackend==="webgpu"&&await navigator.gpu?.requestAdapter().catch(()=>null);if(r())return;if(!f)return void this._failWebGPURequired();this._rendererAuto=!1}let h=function(f){let g=new Set;return f.scene.objects.traverse((y,v)=>{if(v.type!=="Page")return;let b=v.postprocessing;if(b&&typeof b=="object"&&b.enabled===!0)for(let[_,x]of Object.entries(b))_!=="enabled"&&x&&typeof x=="object"&&x.enabled===!0&&g.add(_)}),[...g]}(n);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(PF(),$R)),MOt(h)]);let f=await this._ensureRenderer();if(r()||!f)return}catch(f){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",f),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(f){gT=f})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let u=new wOt(n,{},!0,{dedupeParametricGeometries:!0});if(u.resetPersonalCameraFromDocumentData(),this._scene=u.scene,this._sharedAssetsManager=u.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:f}=await Promise.resolve().then(()=>(gRt(),cxt));if(r())return;let g=performance.now();f(n,u.scene);let y=performance.now();console.log("Merged geometries in ",y-g," ms")}PZ(n)&&this._scene.traverse(f=>{$u(f)&&f.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(f=>{om(f)&&f.pendingMediaLoad&&f.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(f=>{f.type==="ParticleSystem"&&(f.wakeUp(),f.data.autoPlay?f.start():f.stop()),n0(f)&&f.setPlayMode(!0)});let d=Object.keys(n.shared.fonts).flatMap(f=>{let g=this._sharedAssetsManager.getFont(f);return g?[g.loadingPromise]:[]});if(Promise.all(d).then(()=>{this.disposed||(u.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),PK(n)&&function(f){if(s0.physicsEnabled(f.scene.objects))return!0;let g=!1;return f.scene.objects.traverse((y,v)=>{if(v.events){if(Array.isArray(v.events)){for(let b of v.events)if(b.data.disabled!==!0&&b.data.type==="GameControl"&&b.data.collisionEnabled){g=!0;break}}else for(let b of Object.values(v.events))if(b.disabled!==!0&&b.type==="GameControl"&&b.collisionEnabled){g=!0;break}}}),g}(n)&&(await Promise.all(d),r()))return;if(gdt(n)){let f=[];if(this._scene.traverseEntity(g=>{(Ya(g)||g instanceof Or)&&g.uiCanvas&&f.push(g.uiCanvas)}),await Promise.all(f.map(g=>g.promise)),r())return}this._scene.rewriteEventsBeforeGoToPlayMode(),Vq(this._scene.activePage,this._sharedAssetsManager);let c=await this._ensureRenderer();if(r()||!c)return;if(this._rendererConfigured||(this._rendererConfigured=!0,c.pipeline.enableUIOverlay(),c.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),c.hdTransmission=n.scene.publish.hdTransmission===!0,c.setPixelRatio(this._getPixelRatio(/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?n.scene.publish.settings.web.pixelRatioMobile:n.scene.publish.settings.web.pixelRatioDesktop)),c.setAsyncCompilationPolicy?.(this._asyncShaderCompilation()),n.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");if(await f.loadPromise,r())return;let g=f.getTexture(1001);c.pipeline.setWatermark(g)}else c.pipeline.setWatermark(null);JZ(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&c.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let p=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(p.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=p.size[0],this._viewportHeight=p.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),c.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new ZRt(c,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(p.allowResponsive??!1)&&p.preset==="fullscreen"),e){let f=new RRt(c,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,p);this._scene.updateMatrixWorld(!0),this._controls=new G4t(f),this._animationControls=new pOt(this._scene,this._requestRenderAutoMode),this._eventManager=new qRt(n.scene.publish,this._controls,this._animationControls,f,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),e&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let m=n.scene.publish.htmlContent?.html;if(e&&m&&this._htmlContentMode!=="none"){let f={shared:this._sharedAssetsManager,findEntity:g=>this._scene?.getObjectByProperty("uuid",g)??this._scene?.getObjectByName(g),getAnimationControls:()=>this._animationControls};this._htmlContentOverlay=(this._htmlContentMode==="inline"?Twt.mount(this,this.canvas,m,f):Swt.mount(this,this.canvas,m,f))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,r]of e)this.setVariable(i,r)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){if(e==null)return void console.warn(`Variable ${t} was not updated: received ${e}. Pass a number, boolean or string.`);let r=e;if(typeof i.data.value=="number"){if(r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e),!Number.isFinite(r))return void console.warn(`Variable ${t} is a number variable and ${JSON.stringify(e)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let i=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(i)}}_getVariableValue(t){return typeof t!="string"&&Da.isTextValue(t)?Da.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(i=>i.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(!(e.uuid===l0||this._scene.isInvisibleObjects(e)||e instanceof Or)){let i=this._createProxyObject(e);i&&t.push(i)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ext&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=Zct(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._claimedOrder=++this._startOrder,this._claimedStart=void 0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,oS&&oS.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{RF.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer&&this._disposeRenderer(this._renderer),this._renderer=void 0,this._rendererConfigured=!1,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(t){t.removeEventListener("pointerdown",vX,!0),t.removeEventListener("pointerdown",EM,!0),t.removeEventListener("pointermove",EM,!0),t.removeEventListener("pointerup",L0,!0),t.removeEventListener("pointercancel",L0,!0),t.removeEventListener("pointerleave",L0,!0),window.removeEventListener("keydown",bX,!0),window.removeEventListener("keyup",_X,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Ls.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e,i=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);t.traverseAncestors(u=>{u instanceof Or&&(e=u.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=u=>{if(u===null||u==="Base State")return null;if(u&&t.data.states){let d=t.data.states.find(c=>c.data.name===u);return d?d.id:void 0}},a="material"in t?t.material:void 0,o=t.materialOverride,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,material:o??(a?LOt(a):void 0),parentUuid:t.parent instanceof Or||t instanceof Vg?void 0:t.parent?.uuid,emitEvent(u){t.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){t.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let u=t.stateSelection;if(u!==null)return t.data.states.find(({id:d})=>d===u)?.data.name},set state(u){let d;if(u!==void 0){let c=typeof u=="string"?t.data.states.find(({id:p})=>p===u):t.data.states[u];if(c)d=c.id;else{let p=typeof u=="string"?n(u):void 0;p&&(d=p)}}t.changeSelectedState(d??null,s),t.currentState=d??null,t.dispatchEvent({type:"completeState",state:d??null}),s.shared.requestRender()},transition(u){let d=xwt;if(d===null)return On("transitions","obj.transition()"),{transition(_){return this},play(){return this},pause(){return this},reset(){return this},seek(_){return this}};let c,p,m=this,f=[],g=!1,y=()=>{p=new nwt({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Ls.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let C=n(_);C===void 0&&(C=c);let M=n(x);return c=M,f.push(new d(t,C,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?sm.defaultData:T.easing===5?kv.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&C||_==="Base State"&&!C)&&(m.state=C??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Ls.time),p.isPlaying&&Ls.add(v),this):this},pause(){return p?.stop(),Ls.remove(v),this},reset(){return this.pause(),g=!1,y(),p?.seek(0),this},seek(_){let x=f.reduce((S,w)=>S+w.runner.duration,0);return x>0&&p?.seek(_/1e3/x),this}};return b.transition(u),(u.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(u){let d=Zct(u);if(s5.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof vo))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=t.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(u),s.shared.requestRender()))}let m=Array.isArray(t.material)?t.material[0]:t.material,f=m.data.layers.find(g=>g.data.type==="color")?.id;if(f)m.updateByOp({type:0,path:["layers",f],props:{color:{...c}}},m.data,s);else{let g=m.data,y=g.layers.find(w=>w.data.type==="light");if(!y)return;let v=g.layers.indexOf(y)===0?y:null,b=g.layers.at(v?g.layers.indexOf(v)+1:0),_={type:4,fi:v?v.fi+(b?(b.fi-v.fi)/2:1):b?b.fi/2:1,id:Ft.generateUUID(),data:{...Bs.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(v?.id??null,1),S=g.layers.runOp({..._,fi:x[0]}).data;Object.assign(m.data,{layers:S}),m.updateByOp({..._,path:["layers"]},m.data,s)}}},h=RF(l,(u,d)=>{let c=t[u],p=function(m){return m.split(".")}(u);p[0]==="material"&&a&&o===void 0&&function(m,f,g){let y=Array.isArray(g)?g[0]:g;if(m[0]==="layers"){let v=parseInt(m[1]),b=y.layers[v],_=m[2];b&&_&&function(x,S,w){let T=x[0];try{if(function(C,M){return!!UOt[M]?.includes(C)}(T,w.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let C=parseInt(x[1]),M=w.getValue(T)?.[C];if(!M)throw new Error("Color index out of range");Vw.setStyle(S),M.set(Vw.r,Vw.g,Vw.b,Vw.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let C=w.color;(function(M,A,R,I){let O=M[0];if(O==="repeat"||O==="offset"||O==="rotation"){let B=I.getNode("mat"),V=B&&typeof B.updateMatrix=="function"?B:I.getValue("mat");if(!V)return;if(O==="rotation")V.rotation=parseFloat(A);else{let z=M[1];if(z===void 0)A instanceof Array&&A.length===2&&Object.assign(V,{[O]:A});else{let k=V[O],L=parseInt(z)===0?[parseFloat(A),k[1]]:[k[0],parseFloat(A)];Object.assign(V,{[O]:L})}}V.updateMatrix()}else O==="wrapping"||O==="minFilter"||O==="magFilter"?O==="wrapping"?R.texture.wrap=A:R.texture[O]=A:O==="image"&&M[1]==="data"&&R.texture.image.updateSrc(A)})(x.slice(1),S,C,w)}else{let C=x[1],M=w.getValue(T);M?.isVector3&&C!==void 0||M?.isVector2&&C!==void 0?M.setComponent(parseInt(C),S):w.setValue(T,S)}}catch(C){console.error("Error setting material value",C)}}(m.slice(2),f,b)}else m[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=f,f<1&&(y.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(t,u)?.writable&&(t[u]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,h),h}setUIWasmUrl(t){(function(e){H4=e,lD?.setHanaUIWasmUrl(e)})(t)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let i;if(typeof e=="string"){if(!e.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(e)).arrayBuffer();i=new Uint8Array(l)}}else i=e;let r=FS.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await Gct(this._wasmPath);let n=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!n)return void console.warn(`Object ${t} not found`);if(n.data.type!=="Mesh"||!(n instanceof vo))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await Wct([o]),a.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of a.data.states){let h={...l.data};a.states||(a.states={}),a.states[l.id]=am.patch(o,h)}return i}_applyDocumentTransaction(t){this._data=t.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let e of t.actual){let i=e.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...e,path:[]},this._sharedAssetsManager)}}_findEntity(t){return this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t)}_resolveParentId(t){if(t===void 0)return this._scene.activePage.uuid;let e=typeof t=="string"?t:t.uuid,i=this._findEntity(e);if(!i)throw new Error(`parent '${e}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(t){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof t!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let e=Ij();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(PF(),$R)),e=Ij()),e===void 0))throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=t(e);if(typeof i!="object"||i===null||i.isMaterial!==!0)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives \u2014 e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(t,e){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded \u2014 call load() or start() first.");let r=typeof t=="string"?t:t.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(s instanceof vo))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let n=typeof e=="function"?await this.createCustomMaterial(e):e;if(e5()!=="webgpu")throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let a=$ct({material:n});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let s=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${Xct}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=DOt[y];if(v)return{objectType:v};let b=ROt[y];if(b)return{objectType:"Mesh",geometryType:b};let _=OOt[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${Xct}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let n,a,{options:o,material:l}=$ct(e);if(l!==void 0){if(s.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(e5()!=="webgpu")throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if(s.geometryType==="TextGeometry"){if(!eW.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature \u2014 re-export the scene with a Text object present, or load the full runtime build.");if(await Tdt(),a=e.font??C1,r.shared.fonts[a]===void 0){if(a!==C1){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}n={name:C1,url:Aft}}}let h=this._resolveParentId(e.parent),u=VOt(s,o,r),d=Ft.generateUUID(),[c,p]=Qw(r);n&&(c.shared.fonts[C1]=n),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(C1,n),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(m);let f=i.find(d);return l!==void 0&&f.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(f)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let s=typeof t=="string"?t:t?.uuid,n=s?this._findEntity(s):void 0;if(!n)throw new Error(`cloneObject: '${s}' \u2014 no object with that name or uuid in the scene.`);if(n instanceof Or)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(n.uuid);if(!a)throw new Error(`cloneObject: '${s}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,m,f){let g={...p.data};return m.position!==void 0&&(g.position=sT(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=sT(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=Awt(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??Cwt(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(zOt(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,h=e.parent!==void 0?null:n.uuid,[u,d]=Qw(r);u.scene.objects.insertAfter(l,h,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof Or)throw new Error("removeObject: pages cannot be removed.");if(s.data.type==="PerspectiveCamera"||s.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(s.uuid)===void 0)throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let n=[];s.traverseEntity(l=>{n.push(l.uuid)});let[a,o]=Qw(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let h=this._proxyObjectCache.get(l);h&&(RF.unsubscribe(h),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var UD=window,jD=UD.ShadowRoot&&(UD.ShadyCSS===void 0||UD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zq=Symbol(),Rwt=new WeakMap,AT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==zq)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(jD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=Rwt.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Rwt.set(i,e))}return e}toString(){return this.cssText}},Dwt=t=>new AT(typeof t=="string"?t:t+"",void 0,zq),Lq=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1],t[0]);return new AT(i,t,zq)},Fq=(t,e)=>{jD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=UD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},GD=jD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return Dwt(i)})(t):t;var Uq,WD=window,Owt=WD.trustedTypes,GOt=Owt?Owt.emptyScript:"",Iwt=WD.reactiveElementPolyfillSupport,Gq={toAttribute(t,e){switch(e){case Boolean:t=t?GOt:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},Nwt=(t,e)=>e!==t&&(e==e||t==t),jq={attribute:!0,type:String,converter:Gq,reflect:!1,hasChanged:Nwt},Wq="finalized",Vc=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),e.push(s))}),e}static createProperty(e,i=jq){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,i);s!==void 0&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,i,r){return{get(){return this[i]},set(s){let n=this[e];this[i]=s,this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||jq}static finalize(){if(this.hasOwnProperty(Wq))return!1;this[Wq]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)i.unshift(GD(s))}else e!==void 0&&i.push(GD(e));return i}static _$Ep(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(i=>i(this))}addController(e){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.call(e))}removeController(e){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var e;let i=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return Fq(i,this.constructor.elementStyles),i}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EO(e,i,r=jq){var s;let n=this.constructor._$Ep(e,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Gq).toAttribute(i,r.type);this._$El=e,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(e,i){var r;let s=this.constructor,n=s._$Ev.get(e);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:Gq;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,r){let s=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||Nwt)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(e=this._$ES)===null||e===void 0||e.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Vc[Wq]=!0,Vc.elementProperties=new Map,Vc.elementStyles=[],Vc.shadowRootOptions={mode:"open"},Iwt?.({ReactiveElement:Vc}),((Uq=WD.reactiveElementVersions)!==null&&Uq!==void 0?Uq:WD.reactiveElementVersions=[]).push("1.6.3");var qq,qD=window,cb=qD.trustedTypes,Bwt=cb?cb.createPolicy("lit-html",{createHTML:t=>t}):void 0,$q="$lit$",Om=`lit$${(Math.random()+"").slice(9)}$`,jwt="?"+Om,WOt=`<${jwt}>`,f0=document,ET=()=>f0.createComment(""),PT=t=>t===null||typeof t!="object"&&typeof t!="function",Gwt=Array.isArray,qOt=t=>Gwt(t)||typeof t?.[Symbol.iterator]=="function",Hq=`[
5191
+ `,Twt=class{constructor(t,e,i,r,s,n){this.container=t,this.host=e,this.observer=i,this.spline=r,this.previousSplineGlobal=s,this.removeLateLifecycleShim=n}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("div");n.setAttribute(QR,"");let a=n.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(s);let h=document.createElement("style");h.textContent=EOt,n.appendChild(h);let u=new DOMParser().parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(u.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;u.body.firstChild;)n.appendChild(u.body.firstChild);s.insertBefore(n,e.nextSibling),n.addEventListener("wheel",v=>{v.ctrlKey&&!v.defaultPrevented&&!e.dispatchEvent(new WheelEvent("wheel",v))&&v.preventDefault()},{passive:!1});let c=new Map,p=new DG(wwt(t,e,r),(v,b)=>{v==="warn"?console.warn(`[spline html] ${b}`):v==="error"&&console.error(`[spline html] ${b}`)},(v,b)=>{let _=c.get(v);if(_)for(let x of _)try{x(b)}catch(S){console.error(S)}}),m=(v,b)=>{try{return Promise.resolve(p.execute(v,b))}catch(_){return Promise.reject(_)}},f={ready:Promise.resolve(),setVariable:(v,b)=>m("setVariable",[v,b]),setVariables:v=>m("setVariables",[v]),getVariable:v=>m("getVariable",[v]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:v=>m("findObjectByName",[v]),findObjectById:v=>m("findObjectById",[v]),getGeometry:(v,b)=>m("getGeometry",[v,b??{}]),updateObject:(v,b)=>m("updateObject",[v,b]),createObject:(v,b)=>m("createObject",[v,b??{}]),createCustomMaterial:v=>m("createCustomMaterial",[v]),getTexture:(v,b)=>m("getTexture",[v,b??{}]),setMaterial:(v,b)=>m("setMaterial",[v,b]),cloneObject:(v,b)=>m("cloneObject",[v,b??{}]),removeObject:v=>m("removeObject",[v]),spawnObject:(v,b)=>m("spawnObject",[v,b??{}]),destroyObject:v=>m("destroyObject",[v]),setInstanceTransforms:(v,b)=>m("setInstanceTransforms",[v,b??null]),getAnimations:v=>m("getAnimations",[v]),playAnimation:(v,b,_)=>m("playAnimation",[v,b,_]),pauseAnimation:(v,b)=>m("pauseAnimation",[v,b]),stopAnimation:(v,b)=>m("stopAnimation",[v,b]),emitEvent:(v,b)=>m("emitEvent",[v,b]),emitEventReverse:(v,b)=>m("emitEventReverse",[v,b]),requestRender:()=>m("requestRender",[]),addEventListener:(v,b)=>{if(typeof b!="function")return;let _=c.get(v);_||(_=new Set,c.set(v,_),m("listenEvent",[v])),_.add(b)},removeEventListener:(v,b)=>{let _=c.get(v);!_||(_.delete(b),_.size===0&&(c.delete(v),m("unlistenEvent",[v])))}},g=window.spline;window.spline=f;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],b=(x,S)=>{let w=new Set,T=x.addEventListener.bind(x),C=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{if(T(M,A,R),!S.includes(M)||A==null)return;let I={type:M,listener:A};w.add(I),queueMicrotask(()=>{!w.delete(I)||((O,B,V)=>{let z=new Event(V);try{typeof B=="function"?B.call(O,z):B.handleEvent?.(z)}catch(k){console.error(k)}})(x,I.listener,I.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,A,R)=>{C(M,A,R);for(let I of w)I.type===M&&I.listener===A&&w.delete(I)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,w.clear()})};b(document,["DOMContentLoaded"]),b(window,["load"]);let _=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(S){console.error(S)}})}}),v.push(()=>{_?Object.defineProperty(window,"onload",_):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of d){let b=document.createElement("script");for(let _ of Array.from(v.attributes))b.setAttribute(_.name,_.value);v.src?b.async=!1:b.textContent=v.textContent,n.appendChild(b)}return new Twt(n,p,l,f,g,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function Mwt(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function $ct(t){if(typeof t.material=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(!Mwt(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=Ij()?.NodeMaterial;if(i!==void 0&&e instanceof i)return{options:{...t,material:void 0},material:e};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => \u2026) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, \u2026).")}if(e.isShaderMaterial===!0)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend \u2014 port the shader to TSL with app.createCustomMaterial((three) => \u2026), or use a built-in material (MeshStandardMaterial, \u2026).");return{options:{...t,material:void 0},material:e}}Be(),Ui(),ht(),syt(),kc(),Ui(),Be(),j3t(),Rm();var POt=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),Xct="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",ROt={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},DOt={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},OOt={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data \u2014 clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime \u2014 clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto \u2014 clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame \u2014 clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor \u2014 clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},IOt={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},NOt={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function sT(t,e){return t===void 0?[e[0],e[1],e[2]]:Array.isArray(t)?[t[0]??e[0],t[1]??e[1],t[2]??e[2]]:[t.x??e[0],t.y??e[1],t.z??e[2]]}function Awt(t){return typeof t=="number"?[t,t,t]:sT(t,[1,1,1])}function mG(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function Yct(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return ls.defaultColorMaterial(Kct(i0),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(e.shared.materials))if(a===i||o.name===i)return a;if(function(a){let o=a.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)||/^(rgb|hsl)a?\(/.test(o)||ae.NAMES[o]!==void 0}(i))return ls.defaultColorMaterial(mG(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(a){let o=Object.entries(a.shared.materials).map(([,l])=>`'${l.name}'`).filter(l=>l!=="'undefined'");return o.length?o.join(", "):"(none)"}(e)}) and is not a valid CSS color.`)}if(typeof i=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(Mwt(i))throw new Error("createObject: a three.js material instance cannot be stored in the document \u2014 this entry point does not support it.");let r=i.color!==void 0?mG(i.color):Kct(i0),s=ls.defaultColorMaterial(r,"physical","layer1","layer2"),n=s.layers.find(a=>a.data.type==="light");if(n){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(n.data,a)}if(i.alpha!==void 0){let a=s.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return s}function Kct(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function BOt(t){let e=dc.defaultData("TextGeometry"),{text:i,...r}=t,s=r.fontSize;return s!==void 0&&r.width===void 0&&(r.width=350*s/16),s!==void 0&&r.height===void 0&&(r.height=50*s/16),Object.assign(e,r),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function CP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function kOt(t,e){return Pgt({userData:{type:t,...Rj[t].normalizeInputs({parameters:e})}})}function VOt(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let h={};for(let[u,d]of Object.entries(l))!POt.has(u)&&d!==void 0&&(h[u]=d);return h}(e),a={states:new ce,events:new ce};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:h}=function(u){let d=CP(u.vertices);if(!d||d.length<9||d.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let c=d.length/3;if(c>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${c}); keep it under 60000.`);let p=CP(u.indices);if(p&&p.length){let b=p.find(_=>!Number.isInteger(_)||_<0||_>=c);if(b!==void 0)throw new Error(`createObject('CustomMesh'): index ${b} is out of range (mesh has ${c} vertices).`)}else p=null;let m=new ye;m.setAttribute("position",new ge(d,3));let f=CP(u.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new ge(f,3));let y=CP(u.uvs);y&&y.length===2*c&&m.setAttribute("uv",new ge(y,2));let v=!1;if(!g){let b=p??Array.from({length:c},(S,w)=>w),{closed:_,inverted:x}=function(S,w){let T=S.length/3,C=new Map,M=new Array(T);for(let O=0;O<T;O++){let B=`${Math.round(1e4*S[3*O])},${Math.round(1e4*S[3*O+1])},${Math.round(1e4*S[3*O+2])}`,V=C.get(B);V===void 0?(C.set(B,O),M[O]=O):M[O]=V}let A=new Map;for(let O=0;O+2<w.length;O+=3){let B=M[w[O]],V=M[w[O+1]],z=M[w[O+2]];for(let[k,L]of[[B,V],[V,z],[z,B]]){if(k===L)continue;let H=k<L?k+"_"+L:L+"_"+k;A.set(H,(A.get(H)??0)+1)}}let R=A.size>0;for(let O of A.values())if(O!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let I=0;for(let O=0;O+2<w.length;O+=3){let B=3*w[O],V=3*w[O+1],z=3*w[O+2],k=S[B],L=S[B+1],H=S[B+2],W=S[V],X=S[V+1],nt=S[V+2],st=S[z],yt=S[z+1],pt=S[z+2];I+=k*(X*pt-nt*yt)+L*(nt*st-W*pt)+H*(W*yt-X*st)}return{closed:!0,inverted:I<0}}(d,b);if(_&&x){for(let S=0;S+2<b.length;S+=3){let w=b[S+1];b[S+1]=b[S+2],b[S+2]=w}p=b}else _||(v=!0)}return p&&m.setIndex(p),g||m.computeVertexNormals(),{geometry:Pgt({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,ku.defaultData,{geometry:l,materials:[Yct(e,i)]}),h&&(a.side=2)}else Object.assign(a,ku.defaultData,{geometry:s==="TextGeometry"?BOt(n):kOt(s,n),material:Yct(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,z4.defaultData):(Object.assign(a,L4.defaultData(r),n),e.color!==void 0&&(a.color=mG(e.color)));a.visible=e.visible??!0,a.position=sT(e.position,[0,0,0]),a.rotation=sT(e.rotation,[0,0,0]),a.scale=Awt(e.scale);let o=(s&&IOt[s])??NOt[r]??r;return a.name=e.name??Cwt(o,i.scene.objects),a}function Cwt(t,e){let i=new Set;if(e.traverse((s,n)=>{i.add(n.name??"")}),!i.has(t))return t;let r=2;for(;i.has(`${t} ${r}`);)r++;return`${t} ${r}`}function Ewt(t,e){let i=Ft.generateUUID();if(t.data.type==="Component")return{data:{..._c.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let r=t.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:x3t(r.animations,Ft.generateUUID,e)}),{...t,id:i,data:r,children:t.children.map(s=>Ewt(s,e))}}function zOt(t){let e={};return function(i,r){return hv(i,r,null)??i}(Ewt(t,e),e)}function LOt(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(FOt)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function FOt(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}Rm(),ts(),hW(),kc();var Vw=new Dr(0,0,0,1),UOt={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};Be(),Be();var jOt=new Z;function Zct(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var Pwt=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:n="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._startOrder=0,this._claimedOrder=0,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<Dgt?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),n0(o)&&(this._renderer?.isWebGPUSplineRenderer!==!0&&o.warnClassicFallbackOnce(),o.isSimulating&&(o.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let o=Math.min(1,1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration);this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=o,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),this._renderer.lastFrameIncomplete===!0&&(this._skipRender=!1),this._renderer.skyAnimationActive===!0&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=jOt.set(this._viewportWidth,this._viewportHeight)),a){let o=this._viewportWidth,l=this._viewportHeight;this._renderer.setSize(o-1,l-1,!1),this._renderer.setSize(o,l,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=LS(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=n,this.renderMode=e?"auto":i,r!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(r)),this._rendererBackend=s??"webgl",s===void 0){let a=null;try{a=new URLSearchParams(window.location.search).get("renderer")}catch{}a==="webgpu"||a==="webgl"||a==="webgl2"?this._rendererBackend=a==="webgl2"?"webgl":a:(this._rendererAuto=!0,this._rendererBackend=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(OEt(),zvt)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",vX,!0),a.addEventListener("pointerdown",EM,!0),a.addEventListener("pointermove",EM,!0),a.addEventListener("pointerup",L0,!0),a.addEventListener("pointercancel",L0,!0),a.addEventListener("pointerleave",L0,!0),window.addEventListener("keydown",bX,!0),window.addEventListener("keyup",_X,!0)}(t)}async _ensureRenderer(){return this._renderer?this._renderer:(this._rendererInit||(this._rendererInit=this._initRenderer().then(t=>(this._rendererInit=void 0,t&&(this._renderer=t),t),t=>{throw this._rendererInit=void 0,t})),this._rendererInit)}async _initRenderer(){if(this.disposed)return null;let t=await this._createRenderer();return this.disposed?(this._disposeRenderer(t),null):t}_disposeRenderer(t){let e=function(r){let s=r.backend;if(s!==void 0)return s.isWebGLBackend===!0?s.gl??null:null;let n=r.getContext,a=typeof n=="function"?n.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(t);if(e&&!function(r,s){return qct.get(r)===s}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(t)||t.dispose());let i=e?function(r,s){let n=s.getExtension("WEBGL_lose_context");if(!n||s.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=Hct(r,"webglcontextlost",h=>{h.preventDefault(),l(n)})});return TP.set(r,{gl:s,lost:o,stopListening:a}),()=>{s.isContextLost()||n.loseContext()}}(this.canvas,e):void 0;try{t.dispose()}finally{i?.()}}async _createRenderer(){if(function(t,e){qct.set(t,e)}(this.canvas,this),await async function(t){let e=TP.get(t);if(e&&(e.restoring??(e.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let s,n=()=>{},a=r.lost.then(l=>new Promise(h=>{n=Hct(i,"webglcontextrestored",()=>h()),l.restoreContext()})),o=new Promise(l=>{s=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(s),n(),r.stopListening()}(t,e).finally(()=>{e.restoring=void 0,!e.gl.isContextLost()&&TP.get(t)===e&&TP.delete(t)})),await e.restoring,e.gl.isContextLost()))throw new Error("[spline] The browser did not restore the WebGL context this canvas had before dispose(); the scene cannot render on it. Use a new canvas.")}(this.canvas),this._rendererBackend==="webgpu"&&this._rendererAuto)try{await navigator.gpu?.requestAdapter()||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if(this._rendererBackend==="webgpu")try{let{createWebGPUSplineRenderer:t,isWebGPUSupported:e}=await Promise.resolve().then(()=>(PF(),$R));e();let i=!0,r=!1;try{let n=new URLSearchParams(window.location.search),a=n.get("bundles");a==="rerecord"?i="rerecord":(a==="off"||a==="0"||a==="false"||a==="no")&&(i=!1),r=n.get("forcegl")==="1"}catch{}let s=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:this._asyncShaderCompilation()});return s.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},s.skyAnimationAllowed=!0,s}catch(t){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",t),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_asyncShaderCompilation(){let t=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let e=new URLSearchParams(window.location.search);if(e.get("forcegl")==="1")return!1;let i=e.get("asynccomp");i==="off"||i==="0"||i==="false"||i==="no"?t=!1:(i==="on"||i==="1"||i==="true"||i==="always")&&(t=!0)}catch{}return t}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let t=window.devicePixelRatio||1,e=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=e*t,this.canvas.height=i*t;let r=this.canvas.getContext("2d");r&&(r.scale(t,t),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText("This scene requires a WebGPU-capable browser.",e/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(t,e,i){(function(s){let n="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";s.endsWith(".spline")?console.warn(n+" The .spline files are only meant to be used by the Editor."):s.endsWith(".splinecode")||console.warn(n)})(t),this.disposed=!1;let r=await(await fetch(t,i)).arrayBuffer();await this.start(r,{variables:e})}async start(t,e={}){if(this.disposed)return;let i,r=++this._startOrder,s=()=>this._claimedOrder>r;return i=this._start(t,e,s,()=>!s()&&(this._claimedOrder=r,this._claimedStart=i,!0)).then(()=>s()?this._claimedStart:void 0,n=>{if(!s())throw n;return this._claimedStart}),i}async _start(t,{interactive:e=!0,variables:i},r,s){Ls.init();let n=await async function(f){let[g,y]=Qw(FS.deserialize(new Uint8Array(f)));if((g.schema??0)!==135){let{updateDocumentSchema:v}=await Promise.resolve().then(()=>(sD(),ygt));v(g)}return y.result().data}(t);if(r())return;let a=function(f){let g=[];return f.scene.objects.traverse((y,v)=>{v.type==="Mesh"&&v.geometry.type==="NonParametricGeometry"&&v.geometry.data.draco!==void 0&&g.push(v)}),g}(n);n.version&&(0,AOt.default)(n.version,"2.0.123")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath!==void 0&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(f){p1t=f}(this._wasmPath));let o=async function(){}();if(await Promise.all([o,a.length&&Gct(this._wasmPath),PZ(n)&&K3t(this._wasmPath),vCt(n)&&yCt(this._wasmPath),GCt(n)&&MCt(this._wasmPath),s0.physicsEnabled(n.scene.objects)&&z4t(this._wasmPath),PK(n)&&Tdt(),JZ(n)&&cEt(),aCt(n)&&nCt(),gdt(n)&&o.then(()=>rj()?.loadHanaUIRUNTIME()),D4t(n)&&e5t(this._wasmPath)].filter(Boolean)),r()||a.length&&(await Wct(a),r())||!s())return;this._data=n,this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let l=n.scene.publish.renderer;if(this._rendererAuto&&l==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&l==="webgpu"){let f=this._rendererBackend==="webgpu"&&await navigator.gpu?.requestAdapter().catch(()=>null);if(r())return;if(!f)return void this._failWebGPURequired();this._rendererAuto=!1}let h=function(f){let g=new Set;return f.scene.objects.traverse((y,v)=>{if(v.type!=="Page")return;let b=v.postprocessing;if(b&&typeof b=="object"&&b.enabled===!0)for(let[_,x]of Object.entries(b))_!=="enabled"&&x&&typeof x=="object"&&x.enabled===!0&&g.add(_)}),[...g]}(n);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(PF(),$R)),MOt(h)]);let f=await this._ensureRenderer();if(r()||!f)return}catch(f){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",f),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(f){gT=f})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let u=new wOt(n,{},!0,{dedupeParametricGeometries:!0});if(u.resetPersonalCameraFromDocumentData(),this._scene=u.scene,this._sharedAssetsManager=u.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:f}=await Promise.resolve().then(()=>(gRt(),cxt));if(r())return;let g=performance.now();f(n,u.scene);let y=performance.now();console.log("Merged geometries in ",y-g," ms")}PZ(n)&&this._scene.traverse(f=>{$u(f)&&f.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(f=>{om(f)&&f.pendingMediaLoad&&f.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(f=>{f.type==="ParticleSystem"&&(f.wakeUp(),f.data.autoPlay?f.start():f.stop()),n0(f)&&f.setPlayMode(!0)});let d=Object.keys(n.shared.fonts).flatMap(f=>{let g=this._sharedAssetsManager.getFont(f);return g?[g.loadingPromise]:[]});if(Promise.all(d).then(()=>{this.disposed||(u.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),PK(n)&&function(f){if(s0.physicsEnabled(f.scene.objects))return!0;let g=!1;return f.scene.objects.traverse((y,v)=>{if(v.events){if(Array.isArray(v.events)){for(let b of v.events)if(b.data.disabled!==!0&&b.data.type==="GameControl"&&b.data.collisionEnabled){g=!0;break}}else for(let b of Object.values(v.events))if(b.disabled!==!0&&b.type==="GameControl"&&b.collisionEnabled){g=!0;break}}}),g}(n)&&(await Promise.all(d),r()))return;if(gdt(n)){let f=[];if(this._scene.traverseEntity(g=>{(Ya(g)||g instanceof Or)&&g.uiCanvas&&f.push(g.uiCanvas)}),await Promise.all(f.map(g=>g.promise)),r())return}this._scene.rewriteEventsBeforeGoToPlayMode(),Vq(this._scene.activePage,this._sharedAssetsManager);let c=await this._ensureRenderer();if(r()||!c)return;if(this._rendererConfigured||(this._rendererConfigured=!0,c.pipeline.enableUIOverlay(),c.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),c.hdTransmission=n.scene.publish.hdTransmission===!0,c.setPixelRatio(this._getPixelRatio(/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?n.scene.publish.settings.web.pixelRatioMobile:n.scene.publish.settings.web.pixelRatioDesktop)),c.setAsyncCompilationPolicy?.(this._asyncShaderCompilation()),n.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");if(await f.loadPromise,r())return;let g=f.getTexture(1001);c.pipeline.setWatermark(g)}else c.pipeline.setWatermark(null);JZ(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&c.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let p=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(p.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=p.size[0],this._viewportHeight=p.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),c.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new ZRt(c,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(p.allowResponsive??!1)&&p.preset==="fullscreen"),e){let f=new RRt(c,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,p);this._scene.updateMatrixWorld(!0),this._controls=new G4t(f),this._animationControls=new pOt(this._scene,this._requestRenderAutoMode),this._eventManager=new qRt(n.scene.publish,this._controls,this._animationControls,f,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),e&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let m=n.scene.publish.htmlContent?.html;if(e&&m&&this._htmlContentMode!=="none"){let f={shared:this._sharedAssetsManager,findEntity:g=>this._scene?.getObjectByProperty("uuid",g)??this._scene?.getObjectByName(g),getAnimationControls:()=>this._animationControls};this._htmlContentOverlay=(this._htmlContentMode==="inline"?Twt.mount(this,this.canvas,m,f):Swt.mount(this,this.canvas,m,f))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,r]of e)this.setVariable(i,r)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){if(e==null)return void console.warn(`Variable ${t} was not updated: received ${e}. Pass a number, boolean or string.`);let r=e;if(typeof i.data.value=="number"){if(r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e),!Number.isFinite(r))return void console.warn(`Variable ${t} is a number variable and ${JSON.stringify(e)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let i=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(i)}}_getVariableValue(t){return typeof t!="string"&&Da.isTextValue(t)?Da.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(i=>i.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(!(e.uuid===l0||this._scene.isInvisibleObjects(e)||e instanceof Or)){let i=this._createProxyObject(e);i&&t.push(i)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ext&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=Zct(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._claimedOrder=++this._startOrder,this._claimedStart=void 0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,oS&&oS.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{RF.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer&&this._disposeRenderer(this._renderer),this._renderer=void 0,this._rendererConfigured=!1,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(t){t.removeEventListener("pointerdown",vX,!0),t.removeEventListener("pointerdown",EM,!0),t.removeEventListener("pointermove",EM,!0),t.removeEventListener("pointerup",L0,!0),t.removeEventListener("pointercancel",L0,!0),t.removeEventListener("pointerleave",L0,!0),window.removeEventListener("keydown",bX,!0),window.removeEventListener("keyup",_X,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Ls.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e,i=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);t.traverseAncestors(u=>{u instanceof Or&&(e=u.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=u=>{if(u===null||u==="Base State")return null;if(u&&t.data.states){let d=t.data.states.find(c=>c.data.name===u);return d?d.id:void 0}},a="material"in t?t.material:void 0,o=t.materialOverride,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,material:o??(a?LOt(a):void 0),parentUuid:t.parent instanceof Or||t instanceof Vg?void 0:t.parent?.uuid,emitEvent(u){t.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){t.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let u=t.stateSelection;if(u!==null)return t.data.states.find(({id:d})=>d===u)?.data.name},set state(u){let d;if(u!==void 0){let c=typeof u=="string"?t.data.states.find(({id:p})=>p===u):t.data.states[u];if(c)d=c.id;else{let p=typeof u=="string"?n(u):void 0;p&&(d=p)}}t.changeSelectedState(d??null,s),t.currentState=d??null,t.dispatchEvent({type:"completeState",state:d??null}),s.shared.requestRender()},transition(u){let d=xwt;if(d===null)return On("transitions","obj.transition()"),{transition(_){return this},play(){return this},pause(){return this},reset(){return this},seek(_){return this}};let c,p,m=this,f=[],g=!1,y=()=>{p=new nwt({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Ls.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let C=n(_);C===void 0&&(C=c);let M=n(x);return c=M,f.push(new d(t,C,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?sm.defaultData:T.easing===5?kv.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&C||_==="Base State"&&!C)&&(m.state=C??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Ls.time),p.isPlaying&&Ls.add(v),this):this},pause(){return p?.stop(),Ls.remove(v),this},reset(){return this.pause(),g=!1,y(),p?.seek(0),this},seek(_){let x=f.reduce((S,w)=>S+w.runner.duration,0);return x>0&&p?.seek(_/1e3/x),this}};return b.transition(u),(u.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(u){let d=Zct(u);if(s5.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof vo))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=t.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(u),s.shared.requestRender()))}let m=Array.isArray(t.material)?t.material[0]:t.material,f=m.data.layers.find(g=>g.data.type==="color")?.id;if(f)m.updateByOp({type:0,path:["layers",f],props:{color:{...c}}},m.data,s);else{let g=m.data,y=g.layers.find(w=>w.data.type==="light");if(!y)return;let v=g.layers.indexOf(y)===0?y:null,b=g.layers.at(v?g.layers.indexOf(v)+1:0),_={type:4,fi:v?v.fi+(b?(b.fi-v.fi)/2:1):b?b.fi/2:1,id:Ft.generateUUID(),data:{...Bs.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(v?.id??null,1),S=g.layers.runOp({..._,fi:x[0]}).data;Object.assign(m.data,{layers:S}),m.updateByOp({..._,path:["layers"]},m.data,s)}}},h=RF(l,(u,d)=>{let c=t[u],p=function(m){return m.split(".")}(u);p[0]==="material"&&a&&o===void 0&&function(m,f,g){let y=Array.isArray(g)?g[0]:g;if(m[0]==="layers"){let v=parseInt(m[1]),b=y.layers[v],_=m[2];b&&_&&function(x,S,w){let T=x[0];try{if(function(C,M){return!!UOt[M]?.includes(C)}(T,w.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let C=parseInt(x[1]),M=w.getValue(T)?.[C];if(!M)throw new Error("Color index out of range");Vw.setStyle(S),M.set(Vw.r,Vw.g,Vw.b,Vw.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let C=w.color;(function(M,A,R,I){let O=M[0];if(O==="repeat"||O==="offset"||O==="rotation"){let B=I.getNode("mat"),V=B&&typeof B.updateMatrix=="function"?B:I.getValue("mat");if(!V)return;if(O==="rotation")V.rotation=parseFloat(A);else{let z=M[1];if(z===void 0)A instanceof Array&&A.length===2&&Object.assign(V,{[O]:A});else{let k=V[O],L=parseInt(z)===0?[parseFloat(A),k[1]]:[k[0],parseFloat(A)];Object.assign(V,{[O]:L})}}V.updateMatrix()}else O==="wrapping"||O==="minFilter"||O==="magFilter"?O==="wrapping"?R.texture.wrap=A:R.texture[O]=A:O==="image"&&M[1]==="data"&&R.texture.image.updateSrc(A)})(x.slice(1),S,C,w)}else{let C=x[1],M=w.getValue(T);M?.isVector3&&C!==void 0||M?.isVector2&&C!==void 0?M.setComponent(parseInt(C),S):w.setValue(T,S)}}catch(C){console.error("Error setting material value",C)}}(m.slice(2),f,b)}else m[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=f,f<1&&(y.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(t,u)?.writable&&(t[u]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,h),h}setUIWasmUrl(t){(function(e){H4=e,lD?.setHanaUIWasmUrl(e)})(t)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let i;if(typeof e=="string"){if(!e.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(e)).arrayBuffer();i=new Uint8Array(l)}}else i=e;let r=FS.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await Gct(this._wasmPath);let n=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!n)return void console.warn(`Object ${t} not found`);if(n.data.type!=="Mesh"||!(n instanceof vo))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await Wct([o]),a.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of a.data.states){let h={...l.data};a.states||(a.states={}),a.states[l.id]=am.patch(o,h)}return i}_applyDocumentTransaction(t){this._data=t.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let e of t.actual){let i=e.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...e,path:[]},this._sharedAssetsManager)}}_findEntity(t){return this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t)}_resolveParentId(t){if(t===void 0)return this._scene.activePage.uuid;let e=typeof t=="string"?t:t.uuid,i=this._findEntity(e);if(!i)throw new Error(`parent '${e}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(t){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof t!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let e=Ij();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(PF(),$R)),e=Ij()),e===void 0))throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=t(e);if(typeof i!="object"||i===null||i.isMaterial!==!0)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives \u2014 e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(t,e){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded \u2014 call load() or start() first.");let r=typeof t=="string"?t:t.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(s instanceof vo))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let n=typeof e=="function"?await this.createCustomMaterial(e):e;if(e5()!=="webgpu")throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let a=$ct({material:n});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let s=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${Xct}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=DOt[y];if(v)return{objectType:v};let b=ROt[y];if(b)return{objectType:"Mesh",geometryType:b};let _=OOt[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${Xct}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let n,a,{options:o,material:l}=$ct(e);if(l!==void 0){if(s.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(e5()!=="webgpu")throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if(s.geometryType==="TextGeometry"){if(!eW.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature \u2014 re-export the scene with a Text object present, or load the full runtime build.");if(await Tdt(),a=e.font??C1,r.shared.fonts[a]===void 0){if(a!==C1){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}n={name:C1,url:Aft}}}let h=this._resolveParentId(e.parent),u=VOt(s,o,r),d=Ft.generateUUID(),[c,p]=Qw(r);n&&(c.shared.fonts[C1]=n),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(C1,n),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(m);let f=i.find(d);return l!==void 0&&f.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(f)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let s=typeof t=="string"?t:t?.uuid,n=s?this._findEntity(s):void 0;if(!n)throw new Error(`cloneObject: '${s}' \u2014 no object with that name or uuid in the scene.`);if(n instanceof Or)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(n.uuid);if(!a)throw new Error(`cloneObject: '${s}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,m,f){let g={...p.data};return m.position!==void 0&&(g.position=sT(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=sT(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=Awt(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??Cwt(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(zOt(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,h=e.parent!==void 0?null:n.uuid,[u,d]=Qw(r);u.scene.objects.insertAfter(l,h,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof Or)throw new Error("removeObject: pages cannot be removed.");if(s.data.type==="PerspectiveCamera"||s.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(s.uuid)===void 0)throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let n=[];s.traverseEntity(l=>{n.push(l.uuid)});let[a,o]=Qw(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let h=this._proxyObjectCache.get(l);h&&(RF.unsubscribe(h),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var UD=window,jD=UD.ShadowRoot&&(UD.ShadyCSS===void 0||UD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zq=Symbol(),Rwt=new WeakMap,AT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==zq)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(jD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=Rwt.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Rwt.set(i,e))}return e}toString(){return this.cssText}},Dwt=t=>new AT(typeof t=="string"?t:t+"",void 0,zq),Lq=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1],t[0]);return new AT(i,t,zq)},Fq=(t,e)=>{jD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=UD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},GD=jD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return Dwt(i)})(t):t;var Uq,WD=window,Owt=WD.trustedTypes,GOt=Owt?Owt.emptyScript:"",Iwt=WD.reactiveElementPolyfillSupport,Gq={toAttribute(t,e){switch(e){case Boolean:t=t?GOt:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},Nwt=(t,e)=>e!==t&&(e==e||t==t),jq={attribute:!0,type:String,converter:Gq,reflect:!1,hasChanged:Nwt},Wq="finalized",Vc=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),e.push(s))}),e}static createProperty(e,i=jq){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,i);s!==void 0&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,i,r){return{get(){return this[i]},set(s){let n=this[e];this[i]=s,this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||jq}static finalize(){if(this.hasOwnProperty(Wq))return!1;this[Wq]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)i.unshift(GD(s))}else e!==void 0&&i.push(GD(e));return i}static _$Ep(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(i=>i(this))}addController(e){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.call(e))}removeController(e){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var e;let i=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return Fq(i,this.constructor.elementStyles),i}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EO(e,i,r=jq){var s;let n=this.constructor._$Ep(e,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Gq).toAttribute(i,r.type);this._$El=e,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(e,i){var r;let s=this.constructor,n=s._$Ev.get(e);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:Gq;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,r){let s=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||Nwt)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(e=this._$ES)===null||e===void 0||e.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Vc[Wq]=!0,Vc.elementProperties=new Map,Vc.elementStyles=[],Vc.shadowRootOptions={mode:"open"},Iwt?.({ReactiveElement:Vc}),((Uq=WD.reactiveElementVersions)!==null&&Uq!==void 0?Uq:WD.reactiveElementVersions=[]).push("1.6.3");var qq,qD=window,cb=qD.trustedTypes,Bwt=cb?cb.createPolicy("lit-html",{createHTML:t=>t}):void 0,$q="$lit$",Om=`lit$${(Math.random()+"").slice(9)}$`,jwt="?"+Om,WOt=`<${jwt}>`,f0=document,ET=()=>f0.createComment(""),PT=t=>t===null||typeof t!="object"&&typeof t!="function",Gwt=Array.isArray,qOt=t=>Gwt(t)||typeof t?.[Symbol.iterator]=="function",Hq=`[
5192
5192
  \f\r]`,CT=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,kwt=/-->/g,Vwt=/>/g,p0=RegExp(`>|${Hq}(?:([^\\s"'>=/]+)(${Hq}*=${Hq}*(?:[^
5193
5193
  \f\r"'\`<>=]|("|')|))|$)`,"g"),zwt=/'/g,Lwt=/"/g,Wwt=/^(?:script|style|textarea|title)$/i,qwt=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),Hwt=qwt(1),sGt=qwt(2),g0=Symbol.for("lit-noChange"),la=Symbol.for("lit-nothing"),Fwt=new WeakMap,m0=f0.createTreeWalker(f0,129,null,!1);function $wt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Bwt!==void 0?Bwt.createHTML(e):e}var HOt=(t,e)=>{let i=t.length-1,r=[],s,n=e===2?"<svg>":"",a=CT;for(let o=0;o<i;o++){let l=t[o],h,u,d=-1,c=0;for(;c<l.length&&(a.lastIndex=c,u=a.exec(l),u!==null);)c=a.lastIndex,a===CT?u[1]==="!--"?a=kwt:u[1]!==void 0?a=Vwt:u[2]!==void 0?(Wwt.test(u[2])&&(s=RegExp("</"+u[2],"g")),a=p0):u[3]!==void 0&&(a=p0):a===p0?u[0]===">"?(a=s??CT,d=-1):u[1]===void 0?d=-2:(d=a.lastIndex-u[2].length,h=u[1],a=u[3]===void 0?p0:u[3]==='"'?Lwt:zwt):a===Lwt||a===zwt?a=p0:a===kwt||a===Vwt?a=CT:(a=p0,s=void 0);let p=a===p0&&t[o+1].startsWith("/>")?" ":"";n+=a===CT?l+WOt:d>=0?(r.push(h),l.slice(0,d)+$q+l.slice(d)+Om+p):l+Om+(d===-2?(r.push(void 0),o):p)}return[$wt(t,n+(t[i]||"<?>")+(e===2?"</svg>":"")),r]},y0=class{constructor({strings:e,_$litType$:i},r){let s;this.parts=[];let n=0,a=0,o=e.length-1,l=this.parts,[h,u]=HOt(e,i);if(this.el=y0.createElement(h,r),m0.currentNode=this.el.content,i===2){let d=this.el.content,c=d.firstChild;c.remove(),d.append(...c.childNodes)}for(;(s=m0.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){let d=[];for(let c of s.getAttributeNames())if(c.endsWith($q)||c.startsWith(Om)){let p=u[a++];if(d.push(c),p!==void 0){let m=s.getAttribute(p.toLowerCase()+$q).split(Om),f=/([.?@])?(.*)/.exec(p);l.push({type:1,index:n,name:f[2],strings:m,ctor:f[1]==="."?Yq:f[1]==="?"?Kq:f[1]==="@"?Zq:mb})}else l.push({type:6,index:n})}for(let c of d)s.removeAttribute(c)}if(Wwt.test(s.tagName)){let d=s.textContent.split(Om),c=d.length-1;if(c>0){s.textContent=cb?cb.emptyScript:"";for(let p=0;p<c;p++)s.append(d[p],ET()),m0.nextNode(),l.push({type:2,index:++n});s.append(d[c],ET())}}}else if(s.nodeType===8)if(s.data===jwt)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(Om,d+1))!==-1;)l.push({type:7,index:n}),d+=Om.length-1}n++}}static createElement(e,i){let r=f0.createElement("template");return r.innerHTML=e,r}};function pb(t,e,i=t,r){var s,n,a,o;if(e===g0)return e;let l=r!==void 0?(s=i._$Co)===null||s===void 0?void 0:s[r]:i._$Cl,h=PT(e)?void 0:e._$litDirective$;return l?.constructor!==h&&((n=l?._$AO)===null||n===void 0||n.call(l,!1),h===void 0?l=void 0:(l=new h(t),l._$AT(t,i,r)),r!==void 0?((a=(o=i)._$Co)!==null&&a!==void 0?a:o._$Co=[])[r]=l:i._$Cl=l),l!==void 0&&(e=pb(t,l._$AS(t,e.values),l,r)),e}var Xq=class{constructor(e,i){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var i;let{el:{content:r},parts:s}=this._$AD,n=((i=e?.creationScope)!==null&&i!==void 0?i:f0).importNode(r,!0);m0.currentNode=n;let a=m0.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let u;h.type===2?u=new v0(a,a.nextSibling,this,e):h.type===1?u=new h.ctor(a,h.name,h.strings,this,e):h.type===6&&(u=new Qq(a,this,e)),this._$AV.push(u),h=s[++l]}o!==h?.index&&(a=m0.nextNode(),o++)}return m0.currentNode=f0,n}v(e){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,i),i+=r.strings.length-2):r._$AI(e[i])),i++}},v0=class{constructor(e,i,r,s){var n;this.type=2,this._$AH=la,this._$AN=void 0,this._$AA=e,this._$AB=i,this._$AM=r,this.options=s,this._$Cp=(n=s?.isConnected)===null||n===void 0||n}get _$AU(){var e,i;return(i=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&i!==void 0?i:this._$Cp}get parentNode(){let e=this._$AA.parentNode,i=this._$AM;return i!==void 0&&e?.nodeType===11&&(e=i.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,i=this){e=pb(this,e,i),PT(e)?e===la||e==null||e===""?(this._$AH!==la&&this._$AR(),this._$AH=la):e!==this._$AH&&e!==g0&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):qOt(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==la&&PT(this._$AH)?this._$AA.nextSibling.data=e:this.$(f0.createTextNode(e)),this._$AH=e}g(e){var i;let{values:r,_$litType$:s}=e,n=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=y0.createElement($wt(s.h,s.h[0]),this.options)),s);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===n)this._$AH.v(r);else{let a=new Xq(n,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(e){let i=Fwt.get(e.strings);return i===void 0&&Fwt.set(e.strings,i=new y0(e)),i}T(e){Gwt(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,s=0;for(let n of e)s===i.length?i.push(r=new v0(this.k(ET()),this.k(ET()),this,this.options)):r=i[s],r._$AI(n),s++;s<i.length&&(this._$AR(r&&r._$AB.nextSibling,s),i.length=s)}_$AR(e=this._$AA.nextSibling,i){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,i);e&&e!==this._$AB;){let s=e.nextSibling;e.remove(),e=s}}setConnected(e){var i;this._$AM===void 0&&(this._$Cp=e,(i=this._$AP)===null||i===void 0||i.call(this,e))}},mb=class{constructor(e,i,r,s,n){this.type=1,this._$AH=la,this._$AN=void 0,this.element=e,this.name=i,this._$AM=s,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=la}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,i=this,r,s){let n=this.strings,a=!1;if(n===void 0)e=pb(this,e,i,0),a=!PT(e)||e!==this._$AH&&e!==g0,a&&(this._$AH=e);else{let o=e,l,h;for(e=n[0],l=0;l<n.length-1;l++)h=pb(this,o[r+l],i,l),h===g0&&(h=this._$AH[l]),a||(a=!PT(h)||h!==this._$AH[l]),h===la?e=la:e!==la&&(e+=(h??"")+n[l+1]),this._$AH[l]=h}a&&!s&&this.j(e)}j(e){e===la?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Yq=class extends mb{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===la?void 0:e}},$Ot=cb?cb.emptyScript:"",Kq=class extends mb{constructor(){super(...arguments),this.type=4}j(e){e&&e!==la?this.element.setAttribute(this.name,$Ot):this.element.removeAttribute(this.name)}},Zq=class extends mb{constructor(e,i,r,s,n){super(e,i,r,s,n),this.type=5}_$AI(e,i=this){var r;if((e=(r=pb(this,e,i,0))!==null&&r!==void 0?r:la)===g0)return;let s=this._$AH,n=e===la&&s!==la||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,a=e!==la&&(s===la||n);n&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var i,r;typeof this._$AH=="function"?this._$AH.call((r=(i=this.options)===null||i===void 0?void 0:i.host)!==null&&r!==void 0?r:this.element,e):this._$AH.handleEvent(e)}},Qq=class{constructor(e,i,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){pb(this,e)}};var Uwt=qD.litHtmlPolyfillSupport;Uwt?.(y0,v0),((qq=qD.litHtmlVersions)!==null&&qq!==void 0?qq:qD.litHtmlVersions=[]).push("2.8.0");var RT=(t,e,i)=>{var r,s;let n=(r=i?.renderBefore)!==null&&r!==void 0?r:e,a=n._$litPart$;if(a===void 0){let o=(s=i?.renderBefore)!==null&&s!==void 0?s:null;n._$litPart$=a=new v0(e.insertBefore(ET(),o),o,void 0,i??{})}return a._$AI(t),a};var Jq,tH;var Im=class extends Vc{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,i;let r=super.createRenderRoot();return(e=(i=this.renderOptions).renderBefore)!==null&&e!==void 0||(i.renderBefore=r.firstChild),r}update(e){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=RT(i,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return g0}};Im.finalized=!0,Im._$litElement$=!0,(Jq=globalThis.litElementHydrateSupport)===null||Jq===void 0||Jq.call(globalThis,{LitElement:Im});var Xwt=globalThis.litElementPolyfillSupport;Xwt?.({LitElement:Im});((tH=globalThis.litElementVersions)!==null&&tH!==void 0?tH:globalThis.litElementVersions=[]).push("3.3.3");var Ywt=t=>e=>typeof e=="function"?((i,r)=>(customElements.define(i,r),r))(t,e):((i,r)=>{let{kind:s,elements:n}=r;return{kind:s,elements:n,finisher(a){customElements.define(i,a)}}})(t,e);var XOt=(t,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},YOt=(t,e,i)=>{e.constructor.createProperty(i,t)};function Ml(t){return(e,i)=>i!==void 0?YOt(t,e,i):XOt(t,e)}var eH,DGt=((eH=window.HTMLSlotElement)===null||eH===void 0?void 0:eH.prototype.assignedElements)!=null?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter(i=>i.nodeType===Node.ELEMENT_NODE);var HD=window.IntersectionObserver!=null;var Kwt=(t=32,e=2)=>{let i=t/2;return Hwt` <style>
5194
5194
  :host {