@splinetool/viewer 2.0.204 → 2.0.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/spline-viewer.cjs
CHANGED
|
@@ -4203,13 +4203,13 @@ void main() {
|
|
|
4203
4203
|
}
|
|
4204
4204
|
post({ kind: 'ready' });
|
|
4205
4205
|
}, 250);
|
|
4206
|
-
})();`});function M3(e){return e==null||e===""?void 0:String(e)}var gY,tbe=F(()=>{gY=class{constructor(e,t,i){this.deps=e,this.onConsole=t,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let e of this.eventUnsubs.values())e();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(e,t){let i=this.deps;switch(e){case"setVariable":{let r=i.setVariable(String(t[0]),t[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=t[0]??{},n=!0;for(let[s,a]of Object.entries(r)){let o=i.setVariable(s,a);o.warning&&this.onConsole("warn",o.warning),n=n&&o.ok}return n}case"getVariable":return i.getVariable(String(t[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(t[0]));case"getGeometry":{let r=i.getGeometry(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(t[0]),t[1]??{});case"createObject":return i.createObject(String(t[0]),t[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(t[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(t[0]),t[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(t[0]),t[1]);case"cloneObject":return i.cloneObject(String(t[0]),t[1]??{});case"removeObject":return i.removeObject(String(t[0]));case"spawnObject":{let r=i.spawnObject(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(t[0]));case"setInstanceTransforms":{let r=t[1]===null||t[1]===void 0?null:t[1],n=i.setInstanceTransforms(String(t[0]),r);return n<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(t[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),n}case"getAnimations":{let r=i.getAnimations(M3(t[0]));return r.warning&&this.onConsole("warn",`spline.${e}: ${r.warning}`),r.clips}case"playAnimation":{let r=typeof t[1]=="object"&&t[1]!==null,n=i.playAnimation(String(t[0]),r?void 0:M3(t[1]),(r?t[1]:t[2])??{});return n.warning&&this.onConsole("warn",`spline.${e}: ${n.warning}`),n.clip}case"pauseAnimation":case"stopAnimation":{let r=M3(t[0]),n=M3(t[1]),s=e==="pauseAnimation"?i.pauseAnimation(r,n):i.stopAnimation(r,n);return s.warning&&this.onConsole("warn",`spline.${e}: ${s.warning}`),s.ok}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(t[0]),String(t[1]),e==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(t[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,n=>{this.onEvent(r,n)})),!0}case"unlistenEvent":{let r=String(t[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${e}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let e=this.deps.getVariables(),t=function(i,r){let n=[];for(let s of Object.keys(r))i[s]!==r[s]&&n.push({name:s,value:r[s]});return n}(this.lastVariables??{},e);this.lastVariables=e;for(let i of t)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function A4e(e,t,i,r){return[e[0]*t+e[4]*i+e[8]*r+e[12],e[1]*t+e[5]*i+e[9]*r+e[13],e[2]*t+e[6]*i+e[10]*r+e[14]]}var C4e=F(()=>{}),ibe,P4e=F(()=>{}),R4e=F(()=>{mY(),tbe(),ibe=class{constructor(e,t,i){this.iframe=e,this.deps=t,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 n=r.data;var s;typeof(s=n)!="object"||s===null||s[fg]!==!0||typeof s.kind!="string"||this.handleMessage(n)},this.host=new gY(t,i,(r,n)=>{this.sendEvent(r,n)})}attach(){window.addEventListener("message",this.onMessage),this.send({[fg]:!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(e){switch(e.kind){case"ready":this.handshakeSeen=!0,this.send({[fg]:!0,kind:"ready-ack"});break;case"console":this.onConsole(e.level,e.text);break;case"call":{let t;try{t=Promise.resolve(this.host.execute(e.method,e.args))}catch(i){t=Promise.reject(i)}t.then(i=>{this.send({[fg]:!0,kind:"result",id:e.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[fg]:!0,kind:"result",id:e.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(e.event)}}send(e){this.iframe.contentWindow?.postMessage(e,"*")}sendEvent(e,t){this.send({[fg]:!0,kind:"event",eventName:e,payload:t})}dispatchInput(e){let t=this.deps.getCanvas();if(!t)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey};switch(e.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":t.dispatchEvent(new PointerEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons,pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,movementX:e.movementX,movementY:e.movementY}));break;case"click":case"dblclick":t.dispatchEvent(new MouseEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons}));break;case"wheel":{let n=new WheelEvent("wheel",{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode});typeof e.wheelDeltaX=="number"&&Object.defineProperty(n,"wheelDeltaX",{value:e.wheelDeltaX}),typeof e.wheelDeltaY=="number"&&Object.defineProperty(n,"wheelDeltaY",{value:e.wheelDeltaY}),t.dispatchEvent(n);break}case"keydown":case"keyup":t.dispatchEvent(new KeyboardEvent(e.type,{...r,key:e.key,code:e.code,repeat:e.repeat}))}}}}),Vr=F(()=>{fY(),c4e(),p4e(),f4e(),g4e(),v4e(),y4e(),_4e(),b4e(),x4e(),w4e(),M4e(),mY(),E4e(),tbe(),C4e(),P4e(),R4e()}),D4e=F(()=>{});function rbe(e){return Array.isArray(e)?e:[e]}function DL(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var N4e=F(()=>{});function Go(e,t){return Object.setPrototypeOf(e,t),e}function HU(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Rg(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],n=1/(i+1);for(let s=0;s<i;s++){let a=e+(t-e)*(s+.75+.5*Math.random())*n;r.push(a)}return r}function s1(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}var I4e=F(()=>{});function vY(e){if(e.deepFreeze!==void 0)return void e.deepFreeze(e);let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&vY(r)}return Object.freeze(e)}function nbe(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}var qU,NL,FW,ri,yY,O4e=F(()=>{}),la=F(()=>{D4e(),N4e(),I4e(),O4e()}),_Y=F(()=>{qU=class{},NL=class extends qU{constructor(e){super(),this.id=e}},FW=class extends qU{constructor(e){super(),this.data=e}}}),L4e=F(()=>{}),xB=F(()=>{ri=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,ri.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i,r=t[e.id];i=r===void 0?{type:2,id:e.id}:{type:1,id:e.id,data:r};let{id:n,data:s}=e,a={...t,[n]:s};return Object.setPrototypeOf(a,ri.prototype),{data:a,actual:e,reverse:i}}if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let n={...t};return Object.setPrototypeOf(n,ri.prototype),delete n[i],{data:n,actual:e,reverse:{type:1,id:i,data:r}}}}return null}}}),bY=F(()=>{yY=class extends Error{}});function sbe(e,t){for(let i of e)t(i.id,i.data)!==!0&&sbe(i.children,t)}function abe(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)abe(i,t)}var Ea,E3,ow,Et,c1=F(()=>{la(),bY(),la(),Ea=class extends Array{constructor(...e){super(...e),Oc(this,"partialObjectCaches"),Oc(this,"objCaches"),Oc(this,"parentCaches"),Object.setPrototypeOf(this,Ea.prototype)}deepFreeze(){let e=0;for(;e<this.length;)vY(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(!t)return e;e=t}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}partialCache(e){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let t=this.get(e);t!==void 0&&this.partialObjectCaches.set(e,t)}get(e){if(this.partialObjectCaches!==void 0){let t=this.partialObjectCaches.get(e);if(t!==void 0)return t}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&abe(i,t)}}traverse(e){sbe(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),n=r.findIndex(o=>o.id===e);if(n<0)throw new Error("not expected");let s=r[n];r=[...r],r[n]={...s,data:t};let a=new Map;return a.set(e,r[n]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(e,t,i=void 0){let r=e,n=t;for(;r!==null;){let a=n,o=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let l=n.findIndex(h=>h.id===o);if(l<0)throw new Error;n=[...n],n[l]={...n[l],children:a},i&&i.set(o,n[l])}Object.setPrototypeOf(n,Ea.prototype);let s=n;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[a,o]of i)s.objCaches.set(a,o);s.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else s.fillCaches();return s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:n,children:s};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),n=r.findIndex(a=>a.id===t);e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new yY("cyclic tree");d=this.parent(d)}}let n=this.parent(r);if(n===void 0)return null;let s=n,a=this.childrenArray(n),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(n,a);n=t,a=h.childrenArray(n);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(n,a),{data:h,actual:e,reverse:{type:9,parent:s,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>DL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getAllIdSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i);r!==void 0&&t.push(r)}t.sort((i,r)=>DL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t.map(i=>i.id)}getWithSortKey(e){let t=e,i=[],r=this.get(t),n=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...n,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Rg(0,i,i);{let n=r[0].fi;return Rg(n-i,n,i)}}{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(a=>a.fi>n.fi);if(s===void 0){let a=r[r.length-1].fi;return Rg(a,a+i,i)}return Rg(n.fi,s.fi,i)}}}}),xY=F(()=>{var e;la(),E3=null,(e=ow||(ow={})).setPreservePrototype=function(t){E3=t},e.tryPreservePrototype=function(t,i){return Object.getPrototypeOf(t)===E3&&Object.setPrototypeOf(i,E3),i},e.runOp=function(t,i){if(i.type!==0)return null;if(Array.isArray(t)||s1(t)){let r=i.props,n={},s=s1(t)?t.slice():[...t],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");n[o]=s[l],s[l]=r[o],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:n}}:null}{let r=i.props,n={},s={...t},a=!1;if(r)for(let o of Object.keys(r)){n[o]=s[o];let l=r[o];l===void 0?delete s[o]:s[o]=l,a=!0}return a?{data:e.tryPreservePrototype(t,s),actual:i,reverse:{type:0,props:n}}:null}}}),p1=F(()=>{la(),la(),Et=class extends Array{constructor(...e){super(...e),Oc(this,"objCaches"),Object.setPrototypeOf(this,Et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)vY(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let n=i[r];return i=[...i],i[r]={...n,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Et.prototype);let t=e;return typeof process<"u"||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,n=this,s={fi:t,id:i,data:r};return n=[...n,s],n.sort((a,o)=>a.fi-o.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let n=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...n}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let n=r.findIndex(o=>o.id===i);if(n===-1)return null;let s=r[n].fi,a={...r[n],fi:t};return r[n]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Rg(0,t,t);{let r=i[0].fi;return Rg(r-t,r,t)}}{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let n=i.find(s=>s.fi>r.fi);if(n===void 0){let s=i[i.length-1].fi;return Rg(s,s+t,t)}return Rg(r.fi,n.fi,t)}}}});function B4e(e,t){let i={cur:[],result:[],len:0};return[e=Cx(e,t,i)??e,i.result]}function $I(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function XI(e){e&&(e.len-=1)}function obe(e,t,i){let r=!1,n=e.map(s=>{let a=s.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Cx(s.data,t,$I(i,a));XI(i),r=r||l!==void 0,l===void 0&&(l=s.data);let h=obe(s.children,t,i);return h!==void 0?r=!0:h=s.children,{...s,id:a,data:l,children:h}});if(r)return n}function Cx(e,t,i){if(e instanceof Ea){let r=obe(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}if(e instanceof Et)return function(r,n,s){let a=!1,o=r.map(l=>{let h=l.id,u=n[h];if(u!==void 0&&typeof u=="string"&&(a=!0,h=u,s!==null))throw new Error("not supported");let d=Cx(l.data,n,$I(s,h));return XI(s),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}(e,t,i);if(Array.isArray(e)){let r=!1,n=e.map((s,a)=>{let o=Cx(s,t,$I(i,a));return XI(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(e)),n):void 0}if(e&&typeof e=="object"&&!s1(e)){let r={},n=!1;for(let[s,a]of Object.entries(e))if(s!=="name"&&s!=="variableId"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");n=!0,s=o}let l=Cx(a,t,$I(i,s));XI(i),n=n||l!==void 0,l===void 0&&(l=a),r[s]=l}else r[s]=a;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(typeof e=="string"){let r=t[e];return r!==void 0&&function(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}(i),r}}var lbe=F(()=>{c1(),p1(),la()});function Px(e){return e&&typeof e=="object"&&e instanceof Ts}function wY(e,t){if(t===void 0)return;let i=!1,r=e.map(n=>{let s=n.id,a=UE(n.data,t[s]);if(i=i||a!==void 0,a===void 0&&(a=n.data),n.children){let o=wY(n.children,t);return o!==void 0?i=!0:o=n.children,{...n,id:s,data:a,children:o}}return{...n,id:s,data:a}});return i?r:void 0}function UE(e,t){if(!Px(t))return t;if(e instanceof Ea){let i=wY(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}if(e instanceof Et)return function(i,r){if(r===void 0)return;let n=!1,s=i.map(a=>{let o=a.id,l=UE(a.data,r[o]);return n=n||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return n?(Object.setPrototypeOf(s,Object.getPrototypeOf(i)),s):void 0}(e,t);if(Array.isArray(e)){let i=!1,r=e.map((n,s)=>{let a=UE(n,t[s]);return i=i||a!==void 0,a===void 0&&(a=n),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(e instanceof Ts)return SY(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[n,s]of Object.entries(e)){let a=UE(s,t[n]);r=r||a!==void 0,a===void 0&&(a=s),i[n]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}function SY(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Px(t))return t;if(!Px(e))return Gg.apply(e,t);let i=new Set;for(let n of Object.keys(e))i.add(n);for(let n of Object.keys(t))i.add(n);let r=new Ts;for(let n of i){let s=SY(e===void 0?void 0:e[n],t===void 0?void 0:t[n]);r[n]=s}return r}var Ts,Gg,IL,Ha,Fee,wB=F(()=>{var e;c1(),p1(),SB(),la(),Ts=class{unusedFunOverridesTable(t){}runOp(t){let i=[],r=this,n=0,s={};for(;n<t.path.length;){if(i.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!Px(r))return null;n+=1}r=r?HU(r):new Ts;for(let[a,o]of Object.entries(t.props)){let l=r[a];s[a]=l,o===void 0?delete r[a]:r[a]=o}for(;n>0;){if(Object.keys(r).length===0){let a=i[n-1];a&&(r=HU(a),delete r[t.path[n-1]])}else{let a=i[n-1];if(a){let o=HU(a);o[t.path[n-1]]=r,r=o}else{let o=new Ts;o[t.path[n-1]]=r,r=o}}n-=1}return{data:Object.setPrototypeOf(r,Ts.prototype),actual:t,reverse:{...t,props:s}}}},(e=Gg||(Gg={})).apply=function(t,i){return UE(t,i)??t},e.merge=function(t,i){return SY(t,i)},e.filterOp=function(t,i){let r=0,n=i.path,s=t;for(;r<n.length&&s!==void 0;){if(s=Sa.zoomOnce(s,n[r]),s===void 0)return i;if(!Px(s))return;r+=1}if(s===void 0)return i;if(Px(s)){if(i.type===0){let a={...i.props};for(let o of Object.keys(s))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=wY([i],s);return a?a[0]:i}return i}}}),F4e=F(()=>{la(),SB(),xB(),c1(),bY(),xY(),p1(),lbe(),wB(),(IL||(IL={})).replaceProps=function(e,t){let i=Sa.zoom(t,e.path);if(typeof i=="object"){let r={};for(let n of Object.keys(e.props))r[n]=i[n];return{...e,props:r}}return{...e,props:{}}},(e=>{function t(n,s){let a=s.path,o=[];for(;;){let l;if(n instanceof Ts&&s.type===0&&(l=n.runOp({...s,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=n instanceof Ea||n instanceof Et||n instanceof ri?n.runOp(s):ow.runOp(n,s)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],f=o[c];if(f instanceof Ea){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof Et){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof ri){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof Ts){let m={...f,[p]:d};d=Object.setPrototypeOf(m,Ts.prototype)}else{if(typeof f!="object")return null;if(Array.isArray(f)||s1(f)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let m=d;d=s1(f)?f.slice():[...f],d[p]=m}else d=ow.tryPreservePrototype(f,{...f,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let h,u=a[o.length];if(n instanceof Ea){if(typeof u=="number")throw new Error("");h=n.get(u)?.data}else if(n instanceof Et){if(typeof u=="number")throw new Error("");h=n.get(u)?.data}else n!==null&&(h=n[u]);if(h===void 0)return null;o.push(n),n=h}}function i(n,s){for(let a=0;a<n.length&&a<s.length;a++)if(n[a]!==s[a])return!0;return!1}function r(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;a++)if(n[a]!==s[a])return!1;return!0}e.drop=function(n,s){return{...n,path:n.path.slice(s)}},e.applySimple=function(n,s){return t(n,s)?.data??n},e.apply=t,e.pathDisjoint=i,e.pathEq=r,e.commutative=function(n,s){return i(n.path,s.path)},e.subsumed=function(n,s){return!(n.type!==0||s.type!==0||!r(n.path,s.path))&&Object.keys(n.props).every(a=>s.props[a]!==void 0)}})(Ha||(Ha={})),(e=>{function t(i,r){let n=i,s=[],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=Sa.zoom(n,[...o.path,o.id]),h=Ha.apply(n,{...o,type:2})):(l=Sa.zoom(n,[...o.path,o.id,"value"]),h=Ha.apply(n,o)),h!==null){n=h.data;let[u,d]=B4e(n,{[o.id]:l});n=u;for(let c=0;c<d.length;c++){let p,f,m=d[c],g=m.pop();if(typeof g=="number"){let v=[g];for(let _=c+1;_<d.length;_++){let b=d[_],x=b[b.length-1];if(typeof x!="number"||!Sa.equal(m,b.slice(0,b.length-1)))break;v.push(x),d.splice(_,1)}let y=Sa.zoom(n,m);f=y.map((_,b)=>v.includes(b)?o.id:_),p=y,g=m.pop()}else p=l,(g==="alphaOverride"||g==="alpha")&&(p=l/100,Sa.zoom(n,m)[g]=p),f=o.id;s.push({type:0,path:m,props:{[g]:p}}),a.push({type:0,path:m,props:{[g]:f}})}a.push(h.reverse),s.push(h.actual)}}else{let l=Ha.apply(n,o);l!==null&&(s.push(l.actual),n=l.data,a.push(l.reverse))}}catch(l){if(l instanceof yY)return null;throw l}return{data:n,actual:s,reverse:a.reverse()}}e.empty=function(){return[]},e.removePrefix=function(i,r){let n=[];for(let s of i){let[a,...o]=s.path;a===r&&n.push({...s,path:o})}return n},e.addPrefix=function(i,r){return i.map(n=>({...n,path:[r,...n.path]}))},e.concat=function(i,r){return[...i,...r]},e.compress=function(i,r){return[...i.filter(n=>!r.some(s=>Ha.subsumed(n,s))),...r]},e.commutative=function(i,r){return i.every(n=>r.every(s=>Ha.commutative(n,s)))},e.applyAll=function(i,r){for(let n of r){let s=t(i,n);s!==null&&(i=s.data)}return i},e.apply=t})(Fee||(Fee={}))});function Uee(e,t){return e instanceof Ts?Object.setPrototypeOf(t,Ts.prototype):ow.tryPreservePrototype(e,t)}function $U(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Sa.equal(r.path,i))return void Object.assign(r.props,t.props)}e.push({...t,path:i})}function YI(e,t,i){return i instanceof Ea?new aC(e,t,i):i instanceof Et?new oC(e,t,i):i instanceof ri?new Proxy(new ube(e,t,i),cbe):i!==null&&typeof i=="object"?s1(i)?i:new Proxy(new hbe(e,t,i),dbe):i}function VM(e){let t=new UW(e);return[YI(t,"",e),t]}function OL(e,t){let[i,r]=VM(e);return t(i),r.result()}function Ds(e){return e instanceof aC||e instanceof oC?e._current:e!==null&&typeof e=="object"?e[LL]:e}function lx(e){if(e instanceof aC||e instanceof oC)return e._current;if(e!==null&&typeof e=="object"){let t=e[LL];return t!==void 0?t:e}return e}var LL,zee,qS,K1,hbe,ube,XU,dbe,cbe,aC,oC,UW,Sa,pbe=F(()=>{xB(),c1(),xY(),p1(),la(),SB(),wB(),LL=Symbol(),zee=Symbol(),qS=Symbol(),K1=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let n=i;for(;!(r instanceof UW);){let s=r._path,a=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,a)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[qS];i&&i(),delete this._children[e]}}}},hbe=class extends K1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=Uee(this._current,{...this._current,[e]:t})}runOp(e){let t=ow.runOp(this._current,e);t!==null&&(t.data=Uee(this._current,t.data)),this.reportOp(e,t,e.path)}},ube=class extends K1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,ri.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},XU={get(e,t){if(t===qS)return()=>{e._parent=null};if(t===LL)return e._current;if(t===zee)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=i[t],a=YI(e,t,s);return a!==s?(r===void 0&&(r={},e._children=r),r[t]=a,a):s},has:(e,t)=>t in e._current,ownKeys:e=>Reflect.ownKeys(e._current),defineProperty(){throw Error("not supported")},getPrototypeOf:e=>Object.getPrototypeOf(e._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},dbe={...XU,set(e,t,i){let r={type:0,props:{[t]:Ds(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},cbe={...XU,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty:(e,t)=>(e.runOp({type:2,id:t}),!0)},aC=class extends K1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[qS]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=YI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}add(e,t,i,r,n){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:n})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},oC=class extends K1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[qS]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,n=this._current[i].fi;e(this.data(this._current[i].id),r,n,i)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}at(e){let{id:t,fi:i}=this._current.at(e);return{id:t,fi:i,data:this.data(t)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=YI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}},UW=class extends K1{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){$U(this.ts,t,e),$U(this.actual,i,e),$U(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),SB=F(()=>{_Y(),pbe(),p1(),c1(),la(),(e=>{function t(r,n){return(r instanceof Ea||r instanceof aC)&&typeof n=="string"||(r instanceof Et||r instanceof oC)&&typeof n=="string"?r.data(n):typeof n=="number"&&Array.isArray(r)||typeof n=="string"&&typeof r=="object"&&r!==null?r[n]:void 0}function i(r,n,s=0){for(;s<n.length&&r!==void 0;)r=t(r,n[s]),s+=1;return r}e.equal=function(r,n){if(n.length!==r.length)return!1;{let s=0;for(;s<r.length;){if(r[s]!==n[s])return!1;s+=1}}return!0},e.removeOverridden=function(r,n,s){let a=i(s,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...n};return Object.keys(a).forEach(l=>{delete o[l]}),o}return n},e.zoomOnce=t,e.zoom=i,e.findPathes=function(r,n){let s=[];return function a(o,l){if(o instanceof NL&&o.id===n.id)s.push(l);else if(o instanceof Et)for(let h=0;h<o.length;h++)a(o[h].data,[...l,o[h].id]);else if(o instanceof Ea)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(s1(o))return;if(typeof o=="object"&&o!==null)for(let h in o)a(o[h],[...l,h])}}(r,[]),s}})(Sa||(Sa={}))}),U4e=F(()=>{});function Zr(e,t){let i=[];if(!(t.length<=e.length))return null;{let r=0;for(;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}}return i}var z4e=F(()=>{});function A3(e){try{if(!An.trusted&&!xf){let i=Fr.sharedLength||0;i<Fr.length&&(Fr.length=i)}let t;if(An.randomAccessStructure&&Ct[Oe]<64&&Ct[Oe]>=32&&Hee?(t=Hee(Ct,Oe,mu,An),Ct=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),Oe=mu):t=Zs(),wo&&(Oe=wo.postBundlePosition,wo=null),xf&&(Fr.restoreStructures=null),Oe==mu)Fr&&Fr.restoreStructures&&kee(),Fr=null,Ct=null,bf&&(bf=null);else{if(Oe>mu)throw new Error("Unexpected end of MessagePack data");if(!xf){let i;try{i=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`${n}n`:n).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return t}catch(t){throw Fr&&Fr.restoreStructures&&kee(),kW(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||Oe>mu)&&(t.incomplete=!0),t}}function kee(){for(let e in Fr.restoreStructures)Fr[e]=Fr.restoreStructures[e];Fr.restoreStructures=null}function Zs(){let e=Ct[Oe++];if(e<160){if(e<128){if(e<64)return e;{let t=Fr[63&e]||An.getStructures&&fbe()[63&e];return t?(t.read||(t.read=zW(t,63&e)),t.read()):e}}if(e<144){if(e-=128,An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=gbe();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(md>=Oe)return Dg.slice(Oe-Sh,(Oe+=t)-Sh);if(md==0&&mu<140){let i=t<16?TY(t):mbe(t);if(i!=null)return i}return UL(t)}{let t;switch(e){case 192:return null;case 193:return wo?(t=Zs(),t>0?wo[1].slice(wo.position1,wo.position1+=t):wo[0].slice(wo.position0,wo.position0-=t)):_be;case 194:return!1;case 195:return!0;case 196:if(t=Ct[Oe++],t===void 0)throw new Error("Unexpected end of buffer");return YU(t);case 197:return t=Er.getUint16(Oe),Oe+=2,YU(t);case 198:return t=Er.getUint32(Oe),Oe+=4,YU(t);case 199:return B0(Ct[Oe++]);case 200:return t=Er.getUint16(Oe),Oe+=2,B0(t);case 201:return t=Er.getUint32(Oe),Oe+=4,B0(t);case 202:if(t=Er.getFloat32(Oe),An.useFloat32>2){let i=qW[(127&Ct[Oe])<<1|Ct[Oe+1]>>7];return Oe+=4,(i*t+(t>0?.5:-.5)|0)/i}return Oe+=4,t;case 203:return t=Er.getFloat64(Oe),Oe+=8,t;case 204:return Ct[Oe++];case 205:return t=Er.getUint16(Oe),Oe+=2,t;case 206:return t=Er.getUint32(Oe),Oe+=4,t;case 207:return An.int64AsType==="number"?(t=4294967296*Er.getUint32(Oe),t+=Er.getUint32(Oe+4)):An.int64AsType==="string"?t=Er.getBigUint64(Oe).toString():An.int64AsType==="auto"?(t=Er.getBigUint64(Oe),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Er.getBigUint64(Oe),Oe+=8,t;case 208:return Er.getInt8(Oe++);case 209:return t=Er.getInt16(Oe),Oe+=2,t;case 210:return t=Er.getInt32(Oe),Oe+=4,t;case 211:return An.int64AsType==="number"?(t=4294967296*Er.getInt32(Oe),t+=Er.getUint32(Oe+4)):An.int64AsType==="string"?t=Er.getBigInt64(Oe).toString():An.int64AsType==="auto"?(t=Er.getBigInt64(Oe),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Er.getBigInt64(Oe),Oe+=8,t;case 212:if(t=Ct[Oe++],t==114)return HW(63&Ct[Oe++]);{let i=go[t];if(i)return i.read?(Oe++,i.read(Zs())):i.noBuffer?(Oe++,i()):i(Ct.subarray(Oe,++Oe));throw new Error("Unknown extension "+t)}case 213:return t=Ct[Oe],t==114?(Oe++,HW(63&Ct[Oe++],Ct[Oe++])):B0(2);case 214:return B0(4);case 215:return B0(8);case 216:return B0(16);case 217:return t=Ct[Oe++],md>=Oe?Dg.slice(Oe-Sh,(Oe+=t)-Sh):xbe(t);case 218:return t=Er.getUint16(Oe),md>=(Oe+=2)?Dg.slice(Oe-Sh,(Oe+=t)-Sh):wbe(t);case 219:return t=Er.getUint32(Oe),md>=(Oe+=4)?Dg.slice(Oe-Sh,(Oe+=t)-Sh):Sbe(t);case 220:return t=Er.getUint16(Oe),Oe+=2,Vee(t);case 221:return t=Er.getUint32(Oe),Oe+=4,Vee(t);case 222:return t=Er.getUint16(Oe),Oe+=2,Gee(t);case 223:return t=Er.getUint32(Oe),Oe+=4,Gee(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}function zW(e,t){function i(){if(i.count++>GW){let n;try{n=e.read=new Function("r","return function(){return "+(An.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":bbe.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(Zs)}catch{return GW=1/0,i()}return e.read0=n,e.highByte===0&&(e.read=jW(t,e.read)),n()}let r={};for(let n=0,s=e.length;n<s;n++){let a=e[n];a==="__proto__"&&(a="__proto_"),r[a]=Zs()}return An.freezeData?Object.freeze(r):r}return i.count=0,e.read0=i,e.highByte===0?jW(t,i):i}function fbe(){let e=ybe(()=>(Ct=null,An.getStructures()));return Fr=An._mergeStructures(e,Fr)}function GM(e){let t;if(e<16&&(t=TY(e)))return t;if(e>64&&VW)return VW.decode(Ct.subarray(Oe,Oe+=e));let i=Oe+e,r=[];for(t="";Oe<i;){let n=Ct[Oe++];if(128&n)if((224&n)==192){let s=(31&n)<<6|63&Ct[Oe++];s<128?r.push(65533):r.push(s)}else if((240&n)==224){let s=(31&n)<<12|(63&Ct[Oe++])<<6|63&Ct[Oe++];s<2048||s>=55296&&s<=57343?r.push(65533):r.push(s)}else if((248&n)==240){let s=(7&n)<<18|(63&Ct[Oe++])<<12|(63&Ct[Oe++])<<6|63&Ct[Oe++];s<65536||s>1114111?r.push(65533):(s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s))}else r.push(65533);else r.push(n);r.length>=4096&&(t+=xa.apply(String,r),r.length=0)}return r.length>0&&(t+=xa.apply(String,r)),t}function Vee(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}function Gee(e){if(An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=gbe();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}function mbe(e){let t=Oe,i=new Array(e);for(let r=0;r<e;r++){let n=Ct[Oe++];if((128&n)>0)return void(Oe=t);i[r]=n}return xa.apply(String,i)}function TY(e){if(e<4){if(e<2){if(e===0)return"";{let t=Ct[Oe++];return(128&t)>1?void(Oe-=1):xa(t)}}{let t=Ct[Oe++],i=Ct[Oe++];if((128&t)>0||(128&i)>0)return void(Oe-=2);if(e<3)return xa(t,i);let r=Ct[Oe++];return(128&r)>0?void(Oe-=3):xa(t,i,r)}}{let t=Ct[Oe++],i=Ct[Oe++],r=Ct[Oe++],n=Ct[Oe++];if((128&t)>0||(128&i)>0||(128&r)>0||(128&n)>0)return void(Oe-=4);if(e<6){if(e===4)return xa(t,i,r,n);{let s=Ct[Oe++];return(128&s)>0?void(Oe-=5):xa(t,i,r,n,s)}}if(e<8){let s=Ct[Oe++],a=Ct[Oe++];if((128&s)>0||(128&a)>0)return void(Oe-=6);if(e<7)return xa(t,i,r,n,s,a);let o=Ct[Oe++];return(128&o)>0?void(Oe-=7):xa(t,i,r,n,s,a,o)}{let s=Ct[Oe++],a=Ct[Oe++],o=Ct[Oe++],l=Ct[Oe++];if((128&s)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(Oe-=8);if(e<10){if(e===8)return xa(t,i,r,n,s,a,o,l);{let h=Ct[Oe++];return(128&h)>0?void(Oe-=9):xa(t,i,r,n,s,a,o,l,h)}}if(e<12){let h=Ct[Oe++],u=Ct[Oe++];if((128&h)>0||(128&u)>0)return void(Oe-=10);if(e<11)return xa(t,i,r,n,s,a,o,l,h,u);let d=Ct[Oe++];return(128&d)>0?void(Oe-=11):xa(t,i,r,n,s,a,o,l,h,u,d)}{let h=Ct[Oe++],u=Ct[Oe++],d=Ct[Oe++],c=Ct[Oe++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(Oe-=12);if(e<14){if(e===12)return xa(t,i,r,n,s,a,o,l,h,u,d,c);{let p=Ct[Oe++];return(128&p)>0?void(Oe-=13):xa(t,i,r,n,s,a,o,l,h,u,d,c,p)}}{let p=Ct[Oe++],f=Ct[Oe++];if((128&p)>0||(128&f)>0)return void(Oe-=14);if(e<15)return xa(t,i,r,n,s,a,o,l,h,u,d,c,p,f);let m=Ct[Oe++];return(128&m)>0?void(Oe-=15):xa(t,i,r,n,s,a,o,l,h,u,d,c,p,f,m)}}}}}function jee(){let e,t=Ct[Oe++];if(t<192)e=t-160;else switch(t){case 217:e=Ct[Oe++];break;case 218:e=Er.getUint16(Oe),Oe+=2;break;case 219:e=Er.getUint32(Oe),Oe+=4;break;default:throw new Error("Expected string")}return GM(e)}function YU(e){return An.copyBuffers?Uint8Array.prototype.slice.call(Ct,Oe,Oe+=e):Ct.subarray(Oe,Oe+=e)}function B0(e){let t=Ct[Oe++];if(go[t]){let i;return go[t](Ct.subarray(Oe,i=Oe+=e),r=>{Oe=r;try{return Zs()}finally{Oe=i}})}throw new Error("Unknown extension type "+t)}function gbe(){let e=Ct[Oe++];if(!(e>=160&&e<192))return Oe--,vbe(Zs());if(e-=160,md>=Oe)return Dg.slice(Oe-Sh,(Oe+=e)-Sh);if(!(md==0&&mu<180))return UL(e);let t,i=4095&(e<<5^(e>1?Er.getUint16(Oe):e>0?Ct[Oe]:0)),r=WW[i],n=Oe,s=Oe+e-3,a=0;if(r&&r.bytes==e){for(;n<s;){if(t=Er.getUint32(n),t!=r[a++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(t=Ct[n++],t!=r[a++]){n=1879048192;break}if(n===s)return Oe=n,r.string;s-=3,n=Oe}for(r=[],WW[i]=r,r.bytes=e;n<s;)t=Er.getUint32(n),r.push(t),n+=4;for(s+=3;n<s;)t=Ct[n++],r.push(t);let o=e<16?TY(e):mbe(e);return r.string=o??UL(e)}function vbe(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(An.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error("Invalid property type for record: "+typeof e)}function ybe(e){qee&&qee();let t=mu,i=Oe,r=FL,n=Sh,s=md,a=Dg,o=BL,l=bf,h=wo,u=new Uint8Array(Ct.slice(0,mu)),d=Fr,c=Fr.slice(0,Fr.length),p=An,f=xf,m=e();return mu=t,Oe=i,FL=r,Sh=n,md=s,Dg=a,BL=o,bf=l,wo=h,Ct=u,xf=f,(Fr=d).splice(0,Fr.length,...c),An=p,Er=new DataView(Ct.buffer,Ct.byteOffset,Ct.byteLength),m}function kW(){Ct=null,bf=null,Fr=null}function k4e(e){e.unpack?go[e.type]=e.unpack:go[e.type]=e}var VW,Ct,mu,Oe,Wee,BL,FL,An,Fr,Dg,Sh,md,wo,bf,go,Er,KU,_be,xf,GW,Hee,qee,jM,bbe,jW,UL,xbe,wbe,Sbe,xa,WW,HW,ZU,$ee,Xee,Yee,qW,C3,Kee,Zee,Qee,$W,QU,LA,V4e=F(()=>{try{VW=new TextDecoder}catch{}Oe=0,BL=Wee=[],FL=0,An={},Sh=0,md=0,go=[],KU={useRecords:!1,mapsAsObjects:!0},(_be=new class{}).name="MessagePack 0xC1",xf=!1,GW=2,jM=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(Ct)return ybe(()=>(kW(),this?this.unpack(e,t):jM.prototype.unpack.call(KU,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(mu=t.end||e.length,Oe=t.start||0):(Oe=0,mu=t>-1?t:e.length),FL=0,md=0,Dg=null,BL=Wee,wo=null,Ct=e;try{Er=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ct=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof jM){if(An=this,this.structures)return Fr=this.structures,A3(t);(!Fr||Fr.length>0)&&(Fr=[])}else An=KU,(!Fr||Fr.length>0)&&(Fr=[]);return A3(t)}unpackMultiple(e,t){let i,r=0;try{xf=!0;let n=e.length,s=this?this.unpack(e,n):C3.unpack(e,n);if(!t){for(i=[s];Oe<n;)r=Oe,i.push(A3());return i}if(t(s,r,Oe)===!1)return;for(;Oe<n;)if(r=Oe,t(A3(),r,Oe)===!1)return}catch(n){throw n.lastPosition=r,n.values=i,n}finally{xf=!1,kW()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(i=>i.slice(0)));for(let i=0,r=e.length;i<r;i++){let n=e[i];n&&(n.isShared=!0,i>=32&&(n.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],n=t[i];n&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}},bbe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,jW=(e,t)=>function(){let i=Ct[Oe++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),n=Fr[r]||fbe()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=zW(n,e)),n.read()},UL=GM,xbe=GM,wbe=GM,Sbe=GM,xa=String.fromCharCode,WW=new Array(4096),HW=(e,t)=>{let i=Zs().map(vbe),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let n=Fr[e];return n&&(n.isShared||xf)&&((Fr.restoreStructures||(Fr.restoreStructures=[]))[e]=n),Fr[e]=i,i.read=zW(i,r),(i.read0||i.read)()},go[0]=()=>{},go[0].noBuffer=!0,go[66]=e=>{let t=e.byteLength%8||8,i=BigInt(128&e[0]?e[0]-256:e[0]);for(let r=1;r<t;r++)i<<=BigInt(8),i+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(s,a)=>{let o=a-s;if(o<=40){let d=r.getBigUint64(s);for(let c=s+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=s+(o>>4<<3),h=n(s,l),u=n(l,a);return h<<BigInt(8*(a-l))|u};i=i<<BigInt(8*(r.byteLength-t))|n(t,r.byteLength)}return i},ZU={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},go[101]=()=>{let e=Zs();if(!ZU[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ZU[e[0]](e[1],{cause:e[2]})},go[105]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Er.getUint32(Oe-4);bf||(bf=new Map);let i,r=Ct[Oe];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)&&Ct[Oe+1]===115?new Set:{};let n={target:i};bf.set(t,n);let s=Zs();if(!n.used)return n.target=s;if(Object.assign(i,s),i instanceof Map)for(let[a,o]of s.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(s))i.add(a);return i},go[112]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Er.getUint32(Oe-4),i=bf.get(t);return i.used=!0,i.target},go[115]=()=>new Set(Zs()),$ee=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),Xee=typeof globalThis=="object"?globalThis:window,go[116]=e=>{let t=e[0],i=Uint8Array.prototype.slice.call(e,1).buffer,r=$ee[t];if(!r){if(t===16)return i;if(t===17)return new DataView(i);throw new Error("Could not find typed array for code "+t)}return new Xee[r](i)},go[120]=()=>{let e=Zs();return new RegExp(e[0],e[1])},Yee=[],go[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Oe;return Oe+=t-e.length,wo=Yee,(wo=[jee(),jee()]).position0=0,wo.position1=0,wo.postBundlePosition=Oe,Oe=i,Zs()},go[255]=e=>e.length==4?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid"),qW=new Array(147);for(let e=0;e<256;e++)qW[e]=+("1e"+Math.floor(45.15-.30103*e));(C3=new jM({useRecords:!1})).unpack,C3.unpackMultiple,C3.unpack,Kee=new Float32Array(1),new Uint8Array(Kee.buffer,0,4)}),G4e=F(()=>{V4e(),_Y(),wB(),p1(),xB(),c1(),Zee=[{Class:ri.prototype.constructor,type:1,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,ri.prototype),e)},{Class:Et.prototype.constructor,type:2,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,Et.prototype),e)},{Class:Ea.prototype.constructor,type:3,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,Ea.prototype),e)},{Class:NL.prototype.constructor,type:4,write:e=>e.id,read:e=>new NL(e)},{Class:FW.prototype.constructor,type:5,write:e=>e.data,read:e=>new FW(e)},{Class:Ts.prototype.constructor,type:6,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,Ts.prototype),e)}];for(let e of Zee)k4e(e);Qee=new jM({structuredClone:!0}),($W||($W={})).deserialize=function(e){return Qee.unpack(e)}}),j4e=F(()=>{G4e(),QU=e=>()=>{throw new Error(e+" is not available in the runtime build (decode-only CollabSerialize)")},LA={deserialize:$W.deserialize,serialize:QU("CollabSerialize.serialize"),checksum:QU("CollabSerialize.checksum")}}),Ir=F(()=>{SB(),L4e(),bY(),c1(),xB(),xY(),p1(),F4e(),U4e(),pbe(),z4e(),_Y(),j4e(),lbe(),wB()});function XW(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var Jee,YW,zE,P3,JU,ete,tte,ite,KW,ZW,rte,nte,ste,ate,ote,QW,JW,lte,hte,ute,dte,Tbe=F(()=>{var e,t,i;Ir(),ne(),(e=Jee||(Jee={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},e.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},YW={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(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"},r.defaultData=function(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,name:"",actions:new Et}:{type:n,disabled:!1,name:"",key:void 0,actions:new Et}}})(zE||(zE={})),(r=>{r.propertyDefaultData=function(n){return{type:"Property",value:[n??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(P3||(P3={})),(t=JU||(JU={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:P3.propertyDefaultData(r),rOperand:{...P3.valueDefaultData}}},t.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},t.stateDefaultData=function(r,n){return{type:"State",object:r??null,state:n??null}},(ete||(ete={})).isConditionalSubActions=function(r){return r.find(n=>n==="ifActions"||n==="elseActions")!==void 0},(r=>{r.is=function(n){return n.type==="Conditional"},r.defaultData=function(n){return{type:"Conditional",disabled:!1,name:"",inActions:new Et,outActions:new Et,condition:JU.distanceDefaultData(n)}}})(tte||(tte={})),(ite||(ite={})).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 Et,drop:new Et}},(KW||(KW={})).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 Et},(ZW||(ZW={})).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(n){return n.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new Et}}})(rte||(rte={})),(r=>{r.is=function(n){return n.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 Et}}})(nte||(nte={})),(r=>{r.is=function(n){return n.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new Et}}})(ste||(ste={})),(r=>{r.is=function(n){return n.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new Et}}})(ate||(ate={})),(r=>{r.is=function(n){return n.type==="Trigger"},r.defaultData=function(n,s){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new Et,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}})(ote||(ote={})),(i=QW||(QW={})).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 Et},n={size:"tablet",operator:"<",actions:new Et},s={size:[...i.defaultSizes.custom],operator:"<>",actions:new Et},a=new Et;return a.push({id:Qe.generateUUID(),fi:0,data:r},{id:Qe.generateUUID(),fi:1,data:n},{id:Qe.generateUUID(),fi:2,data:s}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new Et}},(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(n){return n.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new Et,variableId:"",objectId:null,property:"Position X"}}})(JW||(JW={})),(r=>{r.is=function(n){return n.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new Et,errorActions:new Et,userAPIId:""}}})(lte||(lte={})),(r=>{r.is=function(n){return n.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new Et,userWebhookId:""}}})(hte||(hte={})),(r=>{r.is=function(n){return n.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new Et,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(ute||(ute={})),(r=>{r.is=function(n){return n.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new Et}}})(dte||(dte={}))});function cte(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function eH(e){return typeof e=="string"&&e.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}var f1,Rx,Mbe,Za,pte,Lc,jg,BA,fte,e5,Ph,Ys,kr,tH,mte,Ng,lw,gte,vte,yte,_te,bte,xte,wte,Ste,t5,Tte,Mte,i5,Ete,Ate,Cte,r5,Pte,n5,Rte,Dte,s5,Nte,iH,Ite,Ote,Lte,Bte,Fte,Ute,a1,wf,Ig,rH,nH,zL,kL,VL,GL,jL,sH,aH,WL,oH,Dx,zte,a5,o5,lH,kte,HL,qL,l5,Vte,FA,h5,Gte,jte,Wte,Hte,Jg,qte,$te,Xte,Yte,TB,MY,ts,Un,Fb,Ebe,hw,$L,Qv,hH,EY,XL,YL,KL,cf,KI,Xn,u5,wg,eh=F(()=>{var e,t,i,r,n,s,a,o;f1="personal camera",Rx="a218fcc3-276b-49b9-b485-49037fd14f5f",Mbe=2500134,Za=5526619,(e=pte||{}).x="x",e.y="y",e.z="z",pte=e,(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,f){let m=l.sub(p,c),g=l.sub(f,c),v=l.dot(m,g)/l.dot(m,m),y=l.scalarMultiply(m,v);return l.add(c,y)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,f){return[c[0]+(p[0]-c[0])*f,c[1]+(p[1]-c[1])*f]},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,f){return u(c,d(c,p,f))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Lc||(Lc={})),(t=jg||(jg={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]},t.add=function(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]},t.sub=function(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]},t.div=function(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]},t.mul=function(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]},t.dist=function(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])},t.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=BA||(BA={})).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])]}})(fte||(fte={})),(r=e5||(e5={})).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=[...e5.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]]]}})(Ph||(Ph={})),(n=Ys||(Ys={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},n.white={r:1,g:1,b:1},n.red={r:1,g:0,b:0},n.black={r:0,g:0,b:0},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},n.clone=function(l){return{r:l.r,g:l.g,b:l.b}},n.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},n.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},n.equals=function(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b},n.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)},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}},n.is=function(l){return!!cte(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(s=kr||(kr={})).white={...Ys.white,a:1},s.is=function(l){return!!cte(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},s.transparent={...Ys.white,a:0},s.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},s.fromHexAndA=function(l,h){return{...Ys.fromHex(l),a:h}},s.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}},s.equals=function(l,h){return Ys.equals(l,h)&&l.a===h.a},s.equalsFixed=function(l,h){return Ys.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.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,a:l.a+(h.a-l.a)*u}},s.toStyle=function({r:l,g:h,b:u,a:d}=s.white){return`rgba(${255*l}, ${255*h}, ${255*u}, ${d})`},(tH||(tH={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=mte||{})[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",mte=a,(Ng||(Ng={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(lw||(lw={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=gte||(gte={})).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]}),W4e=F(()=>{var e,t;Ir(),Tbe(),(vte||(vte={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(yte||(yte={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(_te||(_te={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(bte||(bte={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(xte||(xte={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(wte||(wte={})).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"},(Ste||(Ste={})).defaultData={type:"Reset",name:"",delay:0},(t5||(t5={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(e=Tte||(Tte={})).pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0},(t=Mte||(Mte={})).defaultData={type:"Audio",name:"",...t5.defaultData},t.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),t.hasAudioByEvents=i=>t.getAudiosByEvents(i).length>0,t.getAudiosByActions=i=>{let r=[];return i.forEach(n=>{let s=n.data;s.type==="Audio"&&s.interaction==="play"&&s.audio&&r.push(n),s.type==="Conditional"&&(r.push(...t.getAudiosByActions(s.ifActions)),r.push(...t.getAudiosByActions(s.elseActions)))}),r},t.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:n})=>{zE.is(n)||n.type==="Collision"||n.type==="Start"||n.type==="Trigger"||n.type==="VariableChange"||n.type==="WEBHOOK"||n.type==="AIAssistantTrigger"?r.push(...t.getAudiosByActions(n.actions)):n.type==="Conditional"?(r.push(...t.getAudiosByActions(n.inActions)),r.push(...t.getAudiosByActions(n.outActions))):n.type==="GameControl"?Object.values(n.gameActions).forEach(s=>{r.push(...t.getAudiosByActions(s))}):n.type==="DragDrop"?(r.push(...t.getAudiosByActions(n.dragDropActions.drag)),r.push(...t.getAudiosByActions(n.dragDropActions.drop))):n.type==="Resize"?n.breakpoints.forEach(({data:s})=>{r.push(...t.getAudiosByActions(s.actions))}):n.type==="API"&&(r.push(...t.getAudiosByActions(n.successActions)),r.push(...t.getAudiosByActions(n.errorActions)))}),r},(i5||(i5={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(Ete||(Ete={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...i5.defaultData},i.hasVideoByActions=r=>r.some(({data:n})=>n.type==="Video"&&n.interaction==="play"&&n.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:n}of r.events)if((zE.is(n)||n.type==="Start")&&i.hasVideoByActions(n.actions))return!0}},i.getVideosByActions=r=>{let n=[];return r.forEach(s=>{let a=s.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&n.push(s)}),n},i.getVideosByEvents=r=>{let n=[];return r.forEach(({data:s})=>{(zE.is(s)||s.type==="Start")&&n.push(...i.getVideosByActions(s.actions))}),n}})(Ate||(Ate={})),(Cte||(Cte={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(r5||(r5={})).defaultData=function(){return{tweens:new Et,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(Pte||(Pte={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...r5.defaultData()}},(n5||(n5={})).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}})(Rte||(Rte={})),(Dte||(Dte={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...n5.defaultData(i)}},(s5||(s5={})).defaultData=function(i,r,n){return{interaction:"play",object:i,clipId:r,crop:n,crop2:n,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(Nte||(Nte={})),(i=>{i.defaultData=function(r,n,s){return{type:"Animation",name:"",...s5.defaultData(r,n,s)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(iH||(iH={})),(Ite||(Ite={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(Ote||(Ote={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new Et,elseActions:new Et,condition:[]}),(Lte||(Lte={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(Bte||(Bte={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(Fte||(Fte={})).defaultData={name:"",type:"UserAPI"}}),H4e=F(()=>{var e;(e=Ute||(Ute={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),t=>t.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},e.maxSize=2e6}),Abe=F(()=>{var e;(e=a1||(a1={})).all=["PerspectiveCamera","OrthographicCamera"],e.is=function(t){return e.all.includes(t)},(t=>{t.DefaultUp=[0,1,0],t.DefaultTargetOffset=1e3,t.MinTargetOffset=.001,t.sanitizeTargetOffset=function(s){return s===void 0||!Number.isFinite(s)||s<t.MinTargetOffset?t.DefaultTargetOffset:s},t.DefaultAzimuth=-24,t.DefaultElevation=15;let i=t.DefaultAzimuth*Math.PI/180,r=t.DefaultElevation*Math.PI/180,n=180/Math.PI;t.DefaultPosition=[t.DefaultTargetOffset*Math.sin(i)*Math.cos(r),t.DefaultTargetOffset*Math.sin(r),t.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],t.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*n,Math.asin(Math.sin(i)*Math.cos(r))*n,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*n],t.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:t.DefaultUp,isUpVectorFlipped:!1,targetOffset:t.DefaultTargetOffset},t.getZoom=function(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}})(wf||(wf={}))}),Cbe=F(()=>{var e;(e=Ig||(Ig={})).defaultData=function(t,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof t[0]=="number"?t[0]:1,typeof t[1]=="number"?t[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 t[0]=="number"?t[0]+t[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:t.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"}}},e.merge=function(t,i){let r={...t};if(nH.forEach(n=>{Object.assign(r,{[n]:i[n]??t[n]})}),r.radial={...t.radial},i.radial){let n=t.radial,s=i.radial;zL.forEach(a=>{Object.assign(r.radial,{[a]:s[a]??n[a]})})}if(r.linear={...t.linear},i.linear){let n=t.linear,s=i.linear;kL.forEach(a=>{Object.assign(r.linear,{[a]:s[a]??n[a]})})}if(r.grid={...t.grid},i.grid){let n=t.grid,s=i.grid;VL.forEach(a=>{Object.assign(r.grid,{[a]:s[a]??n[a]})})}if(r.toObject={...t.toObject},i.toObject){let n=t.toObject,s=i.toObject;GL.forEach(a=>{Object.assign(r.toObject,{[a]:s[a]??n[a]})})}if(r.randomnessObject={...t.randomnessObject},i.randomnessObject){let n=t.randomnessObject,s=i.randomnessObject;jL.forEach(a=>{Object.assign(r.randomnessObject,{[a]:s[a]??n[a]})})}return r},e.isPartial=function(t){return!(!t.randomnessObject&&!t.toObject)},(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];t.toOps=function(r,n){let s=[];r.count!==void 0&&s.push({type:0,path:n,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&s.push({type:0,path:[...n,a],props:o})}return s}})(rH||(rH={})),nH=["count"],zL=["radius","start","end","position","scale","rotation"],kL=["position","scale","rotation"],VL=["count","size"],GL=["count","position","scale","rotation"],jL=["strength","scale","rotation","position","movement","seed","freqScale"]}),Pbe=F(()=>{var e;eh(),(e=sH||(sH={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],e.is=function(t){return e.all.includes(t)},(aH||(aH={})).defaultData=function(t){return function(i){if(i==="PointLight")return{type:i,color:kr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:kr.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:kr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(t)}}),Rbe=F(()=>{var e;(e=WL||(WL={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.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:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}}),Dbe=F(()=>{var e;(e=oH||(oH={})).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},e.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),AY=F(()=>{(Dx||(Dx={})).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]}}),Nbe=F(()=>{var e,t;(e=zte||{})[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",zte=e,(t=a5||(a5={})).defaultData={castShadow:!0,receiveShadow:!0},t.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,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe&&(r.shadowCatcher??!1)===(n.shadowCatcher??!1)}})(o5||(o5={})),(lH||(lH={})).defaultData={...o5.defaultData,...a5.defaultData},(kte||(kte={})).getMaterialData=function(i,r){let n=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&n.push(s)}else if("materials"in i)for(let s of i.materials){let a=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;a&&n.push(a)}return n}}),Ibe=F(()=>{var e;(e=HL||(HL={})).bytesFromFlattened=function(t){if(typeof t!="object"||t===null||Array.isArray(t)||ArrayBuffer.isView(t)||typeof t[0]!="number")return null;let i=Object.getPrototypeOf(t);if(i!==Object.prototype&&i!==null)return null;let r=Object.keys(t),n=new Uint8Array(r.length),s=t;for(let a=0;a<r.length;a++){let o=s[a];if(r[a]!==String(a)||typeof o!="number"||!Number.isInteger(o)||o<0||o>255)return null;n[a]=o}return n},e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),Obe=F(()=>{var e;(e=qL||(qL={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7}),lC=F(()=>{var e,t,i,r;Ir(),eh(),Ibe(),Obe(),eh(),(l5||(l5={})).is=function(n){return n==="texture"||n==="video"||n==="color"||n==="depth"||n==="normal"||n==="gradient"||n==="noise"||n==="fresnel"||n==="cavity"||n==="dust"||n==="rainbow"||n==="toon"||n==="outline"||n==="particle"||n==="transmission"||n==="reflection"||n==="matcap"||n==="displace"||n==="pattern"||n==="vertexColor"||n==="light"},(Vte||(Vte={})).is=function(n){return n==="luminance"||n==="r"||n==="g"||n==="b"||n==="a"},(FA||(FA={})).is=function(n){return typeof n=="object"&&n!==null&&n.image!=null},(h5||(h5={})).is=function(n){return n==="phong"||n==="toon"||n==="lambert"||n==="physical"},(t=Gte||{})[t.Linear=0]="Linear",t[t.Radial=1]="Radial",t[t.Polar=2]="Polar",Gte=t,jte=(n=>(n[n.RepeatWrapping=1e3]="RepeatWrapping",n[n.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",n[n.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",n))(jte||{}),Wte=(n=>(n[n.NearestFilter=1003]="NearestFilter",n[n.LinearFilter=1006]="LinearFilter",n[n.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",n))(Wte||{}),(e=Hte||{})[e.UV=0]="UV",e[e.Planar=1]="Planar",e[e.Spherical=2]="Spherical",e[e.Cylindrical=3]="Cylindrical",e[e.Triplanar=4]="Triplanar",Hte=e,(n=>{n.MAX=3,n.of=function(s){return typeof s=="number"&&Number.isInteger(s)&&s>=0&&s<=3?s:0},n.attributeName=function(s){return s===0?"uv":`uv${s}`}})(Jg||(Jg={})),(r=qte||{})[r.Simplex=0]="Simplex",r[r.SimplexFractal=1]="SimplexFractal",r[r.Ashima=2]="Ashima",r[r.Fbm=3]="Fbm",r[r.Perlin=4]="Perlin",r[r.Voronoi=5]="Voronoi",qte=r,(i=$te||{})[i.F1=0]="F1",i[i.F2=1]="F2",i[i.F2MinusF1=2]="F2MinusF1",i[i.SmoothBlend=3]="SmoothBlend",i[i.Edge=4]="Edge",i[i.Power=5]="Power",i[i.Lines=6]="Lines",i[i.Cells=7]="Cells",$te=i,Xte=(n=>(n[n.Lights=0]="Lights",n[n.Static=1]="Static",n[n.Camera=2]="Camera",n))(Xte||{}),Yte=(n=>(n[n.Circle=0]="Circle",n[n.Ring=1]="Ring",n[n.Polygon=2]="Polygon",n[n.Cross=3]="Cross",n[n.Diamond=4]="Diamond",n[n.Checkerboard=5]="Checkerboard",n[n.Line=6]="Line",n[n.Wave=7]="Wave",n))(Yte||{}),TB=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],MY=["wrapping","image","video","name","minFilter","magFilter"],(n=>{function s(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:qL.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...h,type:"color",color:Ys.fromHex(Za)};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:{...Ys.fromHex(6710886),a:1},colorB:{...Ys.fromHex(6710886),a:1},colorC:{...Ys.fromHex(16777215),a:1},colorD:{...Ys.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:kr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...h,type:"dust",color:kr.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:kr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...h,type:"outline",outlineColor:kr.fromHexAndA(0,1),contourColor:kr.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:{...Ys.fromHex(0),a:1},colorB:{...Ys.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)}n.patch=function(a,o){let{texture:l,...h}=o;if(Object.assign(a,h),l){let u=a.texture;u&&Object.assign(u,l)}},n.defaultColorLayer=function(a){return{...n.defaultData("color"),color:a}},n.defaultData=s,n.defaultDataFor=function(a,o){return a!=="light"?s(a):s("light",typeof o=="string"&&h5.is(o)?o:"physical")}})(ts||(ts={})),(n=>{function s(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}=Ys.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 f=h;return typeof f?.r!="number"?l:typeof f.a=="number"?{r:u,g:d,b:c,a:p??f.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=Ys.fromHex(16777215)){let c=new Et;return c.push({fi:0,data:ts.defaultData("light",l),id:h}),c.push({fi:1,data:ts.defaultData("color"),id:u}),{layers:c}}n.restoreImageBytes=function(l){let h=[],u=new Map,d=(p,f)=>{let m=lx(p);if(typeof m!="object"||m===null||ArrayBuffer.isView(m))return p;if(u.has(m))return u.get(m)??p;u.set(m,void 0);let g=c(m,f)??p;return u.set(m,g),g},c=(p,f)=>{let m=p;if(!Array.isArray(p)){if(typeof m[0]=="number")return;if(typeof m.name=="string"){let v=HL.bytesFromFlattened(lx(m.data));if(v!==null)return h.push({path:`${f}/data`,bytes:v.byteLength}),Object.setPrototypeOf({...m,data:v},Object.getPrototypeOf(p))}}let g=null;for(let v of Object.keys(p)){let y=m[v],_=d(y,`${f}/${v}`);_!==y&&(g===null&&(g=Array.isArray(p)?[...p]:{...m},Object.setPrototypeOf(g,Object.getPrototypeOf(p))),g[v]=_)}return g??void 0};return{material:d(l,""),restored:h}},n.restoreLayersSeq=function(l){let h=lx(l.layers);if(!Array.isArray(h)||h instanceof Et||!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],Et.prototype),d=lx(l);return{material:Object.setPrototypeOf({...d,layers:u},Object.getPrototypeOf(d)),restored:!0}},n.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")},n.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},n.defaultEmptyData=function(){return{layers:new Et}},n.defaultData=function(l="layer1",h="layer2"){return o("physical",l,h)},n.withName=function(l,h){return{...l,name:h}},n.isLayerEntry=a,n.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 Et;return h.forEach((d,c)=>{if(a(d))return void u.push(d);let{id:p,fi:f,...m}=d??{};if(typeof m.type!="string"||!l5.is(m.type))return;let g=ts.defaultDataFor(m.type,m.category),v={...g,...m};for(let[y,_]of Object.entries(m)){let b=g[y];v[y]=Array.isArray(_)&&Array.isArray(b)&&Array.isArray(b[0])?_.map(x=>s(x,b[0])):s(_,b)}u.push({id:typeof p=="string"&&p?p:`layer${c+1}`,fi:typeof f=="number"?f:c,data:v})}),{...l,layers:u}},n.defaultTwoLayerData=o,n.defaultColorMaterial=function(l,h,u="layer1",d="layer2"){let c=new Et;return c.push({fi:0,data:ts.defaultData("light",h),id:u}),c.push({fi:1,data:ts.defaultColorLayer(l),id:d}),{layers:c}},n.defaultUIObjectMaterial=function(l){let h=ts.defaultData("texture");l&&Object.assign(h.texture,{image:l});let u=new Et;return u.push({fi:0,data:h,id:"layer1"}),u.push({fi:1,data:{...ts.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...ts.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}},n.defaultTwoLayerTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=ts.defaultData("texture");Object.assign(c.texture,{image:l});let p=new Et;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:ts.defaultData("light",h),id:d}),{layers:p}},n.defaultTwoLayerVideoTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=ts.defaultData("video");Object.assign(c.texture,{video:l});let p=new Et;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:ts.defaultData("light",h),id:d}),{layers:p}}})(Un||(Un={}))}),q4e=F(()=>{Fb="Roboto_regular",Ebe="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),$4e=F(()=>{q4e()}),Lbe=F(()=>{var e;Ir(),(e=hw||(hw={})).defaultData=function(){return{points:new Et,roundness:0,shapeHoles:[],isClosed:!1}},e.scaled=function t(i,r,n){let s=a=>[a[0]*r,a[1]*n];return{...i,points:new Et(...i.points.map(({id:a,fi:o,data:l})=>({id:a,fi:o,data:{...l,position:s(l.position),controlPrevious:{position:s(l.controlPrevious.position)},controlNext:{position:s(l.controlNext.position)}}}))),shapeHoles:i.shapeHoles.map(a=>t(a,r,n))}}}),Bbe=F(()=>{Ir(),($L||($L={})).defaultData=function(){return{points:new Et,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},Qv={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(hH||(hH={})).merge=function(e,t){let i={...e};return XL.forEach(r=>{Object.assign(i,{[r]:t[r]??e[r]})}),i},EY={shape:Qv,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},XL=["depth","offset","angle","twist","startScale","endScale"]}),CY=F(()=>{var e,t;Lbe(),Bbe(),(e=YL||(YL={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},e.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"},e.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"},(KL||(KL={})).merge=function(i,r){let n={...i};if(Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...i.extrusion},Object.assign(n.extrusion,hH.merge(n.extrusion,r.extrusion))),i.type==="VectorGeometry"&&n.type==="VectorGeometry"){let s=(l,h)=>typeof l=="number"&&typeof h=="number"&&h!==0?l/h:1,a=s(n.width,i.width),o=s(n.height,i.height);(a!==1||o!==1)&&(n.shape=hw.scaled(i.shape,a,o))}return n},(t=cf||(cf={})).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:$L.defaultData(),extrusion:EY};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:hw.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{...t.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")},KI=["width","height","depth"]}),Fbe=F(()=>{eh(),(e=>{function t(i){return i.mode??"linear"}e.defaultData={enabled:!1,useBackgroundColor:!1,color:Ys.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},e.getMode=t,e.getModeIndex=function(i){let r=t(i);return r==="height"?1:r==="both"?2:0},e.getDensity=function(i){return i.density??e.defaultData.density},e.getHeightFalloff=function(i){return i.heightFalloff??e.defaultData.heightFalloff},e.getHeightBase=function(i){return i.heightBase??e.defaultData.heightBase}})(Xn||(Xn={}))}),PY=F(()=>{(u5||(u5={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(wg||(wg={})).defaultData={enabled:!1,mode:"hdri",hdri:u5.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function X4e(e){let t=typeof e=="string"?Number.parseInt(e,10):e;return typeof t=="number"&&Number.isFinite(t)?Math.min(5,Math.max(0,Math.round(t))):3}var UA,wy,d5,c5,p5,Nx,f5,uH,dH,Kte,Z1,Ube,ra,ZL,Zte,Qte,Jte,eie,yc,kE,QL,JL,Sf,Sy,tie,Og,e4,Tf,m5,g5,ny,o1,sy,VE,cH,iie,So,v5,rie,nie,pf,fu,Ix,zbe=F(()=>{(()=>{let e={opacity:1,blendFunction:13,enabled:!1};(UA||(UA={})).defaultData={enabled:!1,pixelation:{...e,blendFunction:16,granularity:15},bloom:{...e,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...e,offset:[2,2]},vignette:{...e,darkness:1,offset:0},hueSaturation:{...e,hue:3,saturation:0},brightnessContrast:{...e,brightness:.25,contrast:0},depthOfField:{...e,focusDistance:100,focalLength:20,bokehScale:5},noise:{...e,blendFunction:16}}})()}),RY=F(()=>{var e;Fbe(),PY(),zbe(),eh(),(e=wy||(wy={})).defaultData={type:"normal",softShadowQuality:"low"},e.isSoft=function(t){return t!=null&&(t.type===void 0||t.type==="soft")},(d5||(d5={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(c5||(c5={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(t=>{t.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},t.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(p5||(p5={})),(Nx||(Nx={})).defaultData={usePhysics:!1,gravity:-10},(f5||(f5={})).defaultData={playCamera:f1,gameControlObject:null},(uH||(uH={})).defaultData={backgroundColor:kr.fromHexAndA(Mbe,1),postprocessing:UA.defaultData,fog:Xn.defaultData,sky:wg.defaultData,globalPhysics:Nx.defaultData,ambient:d5.defaultData,ao:c5.defaultData,shadow:wy.defaultData,publish:f5.defaultData,grading:p5.defaultData}}),Y4e=F(()=>{(dH||(dH={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),MB=F(()=>{var e,t,i;Ir(),Abe(),Pbe(),Rbe(),Dbe(),AY(),Nbe(),eh(),lC(),CY(),Cbe(),la(),RY(),Y4e(),(e=Kte||(Kte={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},e.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(t=Z1||(Z1={})).identity={...tH.identity,shear:Ph.zero},t.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,shear:r.shear}},t.merge=function(r,n){return{position:n?.position||r.position,rotation:n?.rotation||r.rotation,pivot:n?.pivot||r.pivot,pivotRotation:n?.pivotRotation||r.pivotRotation,scale:n?.scale||r.scale,shear:n?.shear||r.shear}},t.diff=function(r,n){return nbe({position:jg.isEqual(r.position,n.position)?void 0:n.position,rotation:jg.isEqual(r.rotation,n.rotation)?void 0:n.rotation,scale:jg.isEqual(r.scale,n.scale)?null:n.scale,shear:n.shear?.every((s,a)=>s===r.shear?.[a])?void 0:n.shear})},Ube=["slide","offset"],(ra||(ra={})).defaultData={states:new Et,events:new Et,visible:!0,raycastLock:!1,physics:Dx.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Z1.identity,cloner:null},(ZL||(ZL={})).defaultData={type:"Empty",...ra.defaultData},(Zte||(Zte={})).defaultData={type:"ParticleCollider",...dH.defaultData,...ra.defaultData},(Qte||(Qte={})).defaultData={type:"Component",...ra.defaultData},(Jte||(Jte={})).defaultData={type:"Particle",...ra.defaultData,...WL.defaultData},(eie||(eie={})).defaultData={type:"Hair",...ra.defaultData,...oH.defaultData},(yc||(yc={})).defaultData={type:"Mesh",...ra.defaultData,...lH.defaultData},(kE||(kE={})).defaultData={...ra.defaultData,...Z1.identity,position:wf.DefaultPosition,rotation:wf.DefaultRotation,...wf.defaultData},(r=>{r.defaultData=function(n){return{...ra.defaultData,...aH.defaultData(n)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(QL||(QL={})),(r=>{function n(s,a,o=0){for(;o<a.length;){let l=s?s[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;s=l.descendants,o+=1}}r.resolveWithDes=n,r.resolve=function(s,a,o=0){let l=n(s,a,o);if(l){let h=Object.keys(l);if(h.length===1&&h[0]==="descendants")return}return l}})(JL||(JL={})),(r=>{function n(s,a){return{...ra.defaultData,...a,component:s,overrides:new Ts,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=n,r.fromComponentData=function(s){let a=Z1.fromObject(s.data);return n(s.id,a)}})(Sf||(Sf={})),(r=>{r.defaultData={type:"Page",...ra.defaultData,physics:{...Dx.defaultData,fusedBody:!1},...uH.defaultData,camera:kE.defaultData,timelines:new ri},r.isUIPage=function(n){return n.uiScene!==void 0}})(Sy||(Sy={})),(i=tie||(tie={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],shear:Ph.zero,name:"Play Camera",visible:!0,raycastLock:!1,physics:Dx.defaultData,states:new Et,events:new Et,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...wf.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",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("RectangleGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("BooleanGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("ShapeBlendGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("TextGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("InputGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(n,s){let a={name:s};return n.type==="Mesh"?(a.geometry={},"material"in n&&(a.material={layers:new Ts}),"materials"in n&&(a.materials=n.materials.map(o=>({layers:new Ts})))):a1.is(n.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(n,s){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:f,...m}=p;if(f!==void 0&&Object.keys(f).length>0){let g={path:[...u,"layers",c,"texture"],props:f,type:0};o.push(g)}if(Object.keys(m).length>0){let g={path:[...u,"layers",c],props:m,type:0};o.push(g)}}}for(let[u,d]of Object.entries(s)){let c=d;if(u!=="name")if(u==="cloner")o.push(...rH.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,f]of Object.entries(c))h(["materials",p],f);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(n,s){if(s===void 0)return n;let a={...n};if(Object.assign(a,Z1.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),a1.is(n.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=s;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(n.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:KL.merge(a.geometry,s.geometry)}),(s.material||s.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=OL(h.material,u=>{if(typeof u!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=u.layers.data(d);p&&ts.patch(p,c)}}).data),h.materials&&l.materials&&(h.materials=OL(h.materials,u=>{for(let d=0;d<h.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,f]of Object.entries(c.layers)){let m=u[d]?.layers?.data(p);m&&ts.patch(m,f)}}}).data),h}(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Ig.merge(a.cloner,s.cloner)});else if(n.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Ig.merge(a.cloner,s.cloner)});else if(sH.is(n.type)){let o=s;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=Ys.clone(o.color))}return a}})(Og||(Og={}))}),DY=F(()=>{(e4||(e4={})).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}}),EB=F(()=>{DY(),eh(),(Tf||(Tf={})).defaultData={orbitControls:e4.defaultData,playPage:Rx,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let i=0,r=0;return t<5?r=-30:t<10&&(r=30),t===0||t===10||t===5?i=30:(t===4||t===11||t===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}}),kbe=F(()=>{var e;(m5||(m5={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(g5||(g5={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(e=ny||(ny={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...m5.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:g5.defaultData}),e.generateSeed=()=>Math.round(1e5*Math.random())}),NY=F(()=>{MB(),Ir(),EB(),eh(),la(),kbe(),(e=>{function t(i,r){let n=i.scene.objects.get(r);if(n&&n.data.type==="Component")return n;{let s=i.shared.lib.components[r];if(s)return{...s.asset,id:r}}}e.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},e.findTimeline=function(i,r){let n=i.find(s=>s.data.type==="Page"&&s.data.timelines?.[r]!==void 0);return n&&n.data.timelines?.[r]},e.getComponentData=t,e.traverseModuleInstances=function(i,r,n){i.scene.objects.traverseFrom(r,(s,a)=>{if(a.type==="Instance"){let o=t(i,a.component)?.data;o&&n(s,a,o.events)}else n(s,a,a.events)})}})(o1||(o1={})),(e=>{function t(r=!0,n=[]){let s=[];r&&s.push({...e.defaultLight}),s.push(...n);let a=new Ea;return a.push({fi:1,id:Rx,data:{...Sy.defaultData,name:"Scene 1"},children:s}),a}function i(r){return{...e.defaultData,objects:Go(r,Ea.prototype)}}e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:QL.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Tf.defaultData,styles:ny.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new Ea,publish:Tf.defaultData,styles:ny.defaultData()}},e.emptyDataWithPage=function(r=!0){return{objects:t(r),publish:Tf.defaultData,styles:ny.defaultData()}},e.emptyData=function(){return{objects:new Ea,publish:{...Tf.defaultData},styles:ny.defaultData()}},e.withObjs=i,e.withObj=function(r,n){return i([{id:r,data:n,children:[],fi:0}])}})(sy||(sy={}))}),Vbe=F(()=>{(VE||(VE={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),IY=F(()=>{var e,t;Ir(),la(),(e=cH||(cH={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new Et}),e.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(iie||(iie={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new Et,queries:new Et,autoStart:!0}),(i=>{function r(s){return s.textValue!==void 0}function n(s){return typeof s=="boolean"}i.isTextValue=r,i.isNumber=function(s){return typeof s=="number"},i.isBoolean=n,i.typeOfVariable=function(s){return r(s)?"string":n(s)?"boolean":"number"},i.getDisplayedValue=function(s){return i.isTextValue(s)?Array.isArray(s.textValue)?s.textValue.map(a=>a.toString().padStart(s.padding??2,"0")).join(s.deliminator??":")+(s.suffix!==void 0?" "+s.suffix:""):s.textValue.toString():i.isBoolean(s)?s?"True":"False":i.isNumber(s)?parseFloat(s.toFixed(3)).toString():s.toString()}})(So||(So={})),(v5||(v5={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(rie||(rie={})).all=[...v5.all,"components"],(nie||(nie={})).defaultData=function(){return{images:new ri,videos:new ri,colors:new ri,audios:new ri,particles:new ri,fonts:new ri,materials:new ri,components:new ri,variables:new ri,userAPIs:new ri,userWebhooks:new ri}},(pf||(pf={})).defaultData=function(){return{images:new ri,videos:new ri,colors:new ri,audios:new ri,particles:new ri,fonts:new ri,materials:new ri,components:new ri,variables:new ri,userAPIs:new ri,userWebhooks:new ri}},(t=fu||(fu={})).defaultColors=function(){return Go({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},ri.prototype)},t.defaultImages=function(){return Go({},ri.prototype)},t.emptyData=function(){return{catelogs:new ri,materials:new ri,images:new ri,videos:new ri,colors:new ri,audios:new ri,particles:new ri,fonts:new ri,variables:new Et,userAPIs:new ri,userWebhooks:new ri,lib:pf.defaultData()}},t.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)}},t.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let n=Math.floor(i/3600),s=Math.floor((i-3600*n)/60);return{textValue:[n,s,Math.round(i-3600*n-60*s)]}}if(r.format==="mm:ss"){let n=Math.floor(i/60);return{textValue:[n,Math.round(i-60*n)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),K4e=F(()=>{}),Gbe=F(()=>{var e;Ir(),NY(),Vbe(),IY(),(e=Ix||(Ix={})).defaultData={schema:136,scene:sy.defaultData,frames:new ri().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",VE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors()}},e.createDefaultData=function(){return LA.deserialize(LA.serialize(e.defaultData))},e.emptyDataForImports=function(){return{schema:136,scene:sy.emptyDataWithPage(),frames:new ri().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",VE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors(),images:fu.defaultImages()}}},e.emptyData=function(){return{schema:136,scene:sy.emptyDataWithPage(),frames:new ri().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",VE.defaultData),shared:fu.emptyData()}},e.clipboard2dData=function(){return{schema:136,scene:sy.emptyData(),frames:new ri,shared:fu.emptyData()}},e.withoutLib=function(t){return{...t,shared:{...t.shared,lib:pf.defaultData()}}},e.getComponentData=function(t,i){return o1.getComponentData(t,i)},e.hasSensitiveData=function(t){let i=Object.values(t.shared.userAPIs);for(let r of i){let n=r.headers;for(let s of n)if(s.data.key.toLowerCase()==="authorization"&&s.data.value!=="")return!0}return!1}});function Wf(e,t=[0,0]){return[e&&!isNaN(e[0])?e[0]:t[0],e&&!isNaN(e[1])?e[1]:t[1]]}function $S(e,t,i){switch(e){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:n}=t??{...lw.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${n[0]}, ${n[1]} )`}case 6:{let{mass:r,stiffness:n,damping:s,velocity:a}=i??{...Ng.defaultData},o=new jbe(r,n,s,a),l=o.solve(1);return()=>h=>o.solve(h)/l}case 8:return()=>r=>Math.floor(r)}}function Z4e(e){let t=function(r){return r.layers?.find(({data:n})=>n.type==="light")}(e);if(!t)return;let i=t.data.alphaOverride;return typeof i=="number"?i:1}function Q4e(e,t,i){return i>0?e*t/i:e}var sie,aie,Wg,zA,jbe,t4,i4,OY=F(()=>{Ir(),eh(),(sie||(sie={})).defaultData=function(e,t){return{id:e,name:t,duration:5,objectTimelines:new ri}},(aie||(aie={})).is=function(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"},(e=>{function t(u,d){let c=[0,0],p=[1,1];if(u?.cubicControls)c=Wf(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=Wf(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(!e.BEZIER_PRESETS.includes(u))return;let d={type:u};return{control1:t(d).control1,control2:t(void 0,d).control2}}function r(u,d){return Math.abs(u[0]-d[0])<.001&&Math.abs(u[1]-d[1])<.001}function n(u){let d=e.ROOT_PROPERTY_ORDER.indexOf(u[0]);return d===-1?e.ROOT_PROPERTY_ORDER.length:d}function s(u){return u.layerId??u.path.join(".")}function a(u){let d=u[u.length-1];return zA.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]}}}}}e.getControlsWithDefault=t,e.BEZIER_PRESETS=[0,1,2,3,4,7],e.presetHandles=i,e.presetForHandles=function(u){return e.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,u.control1)&&r(c.control2,u.control2)})},e.defaultData=function(u){return{id:u,keyframes:new Et}},e.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],e.rowOrder=n,e.propertyKey=s,e.groupKeyframes=function(u,d){let c=new Map;for(let p of u){let f=p.data;if(d?.(f))continue;let m=s(f),g=c.get(m);g||(g={id:m,path:f.path,keyframes:[],layerId:f.layerId,index:f.index},c.set(m,g)),f.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,f)=>{let m=n(p.path)-n(f.path);return m!==0?m:(p.index??0)-(f.index??0)})},e.rowAxis=a,e.drawnRowKey=o,e.drawnRows=function(u){let d=new Map;for(let c of u){let p=a(c.path),f=p?c.path.slice(0,-1):c.path,m=o(c),g=d.get(m);g||(g={id:m,path:f,layerId:c.layerId,index:c.index,tracks:[]},d.set(m,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},e.sortedKeyframes=function(u){return[...u].sort((d,c)=>d.data.time-c.data.time)},e.materialLayerPath=l,e.createMaterialGroup=function(u,d){return u.map(({data:c,id:p},f)=>h(d(),l(c),{layerId:p,index:f}))},e.placeholderKeyframe=h,e.createName=function(u){return Object.entries(u).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:$S(3),duration:1e3},opacity:{value:[0,1],easing:$S(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:$S(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:$S(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:$S(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Wg||(Wg={})),zA=["x","y","z"],jbe=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),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(e){return 1-(this.m_zeta<1?Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0))}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,this.solve(t)===1){if(i++,i>=16)break}else i=0;return t*e*1e3}}}),LY=F(()=>{var e;eh(),Ir(),(t4||(t4={})).list=["idle","move","jump","run"],(e=i4||(i4={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.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:e.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 Et,move:new Et,jump:new Et,run:new Et},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:kr.fromHexAndA(3728051,1)}}});function Gv(e,...t){let i={};for(let r of t.flat())e!=null&&r in e&&(i[r]=e[r]);return i}function oie(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,n=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)n.push(n[1]),s.push(1);let a={...Gv(Ds(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Ds(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Zp(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Qp(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=Un.defaultTwoLayerData("phong"),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Un.defaultTwoLayerData("phong")),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Un.defaultTwoLayerData("phong")),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&Object.getPrototypeOf(n.material)!==Ts.prototype&&t(n.material)})})}function lie(e){e.layers===void 0&&Object.assign(e,Un.defaultTwoLayerData("lambert"))}function y5(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...Ds(t),colors:i,steps:r};Object.assign(t,n)}})}function hie(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&y5(r)}):"material"in i&&typeof i.material!="string"&&y5(i.material)}),Object.values(e.shared.materials).forEach(t=>y5(t))}function uie(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function die(e){e.layers&&e.layers.forEach(t=>{(function(i){return i.type!=="displace"})(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function cie(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=ts.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function pie(e){Zp(e,cie),Qp(e,cie)}function fie(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function mie(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}var J4e=F(()=>{lC(),eh(),DY(),MB(),Ir(),EB(),la(),ne(),CY(),LY(),kbe(),NY(),AY(),RY()});function Wbe(e){let t=e.elements;ud.set(t[0],t[1],t[2]),dd.set(t[4],t[5],t[6]),Mc.set(t[8],t[9],t[10])}function Hbe(){let e=Math.max(ud.lengthSq(),dd.lengthSq(),Mc.lengthSq());ud.lengthSq()>WM*e?Th.copy(ud).normalize():Th.set(1,0,0),Mh.crossVectors(Mc,Th),Mh.lengthSq()<=WM*e&&(Mh.copy(dd).addScaledVector(Th,-dd.dot(Th)),Mh.lengthSq()<=WM*e&&function(t,i){t.set(1,0,0).cross(i),t.lengthSq()<=WM&&t.set(0,1,0).cross(i),t.normalize()}(Mh,Th)),Mh.normalize(),ay.crossVectors(Th,Mh)}function qbe(e,t,i){return Wbe(e),Hbe(),t.makeBasis(Th,Mh,ay),i.set(Th.dot(ud),Th.dot(dd),Th.dot(Mc),0,Mh.dot(ud),Mh.dot(dd),Mh.dot(Mc),0,ay.dot(ud),ay.dot(dd),ay.dot(Mc),0,0,0,0,1),function(){let r=ud.length(),n=dd.length(),s=Mc.length(),a=Math.max(r,n,s);if(a-r>HM||a-n>HM||a-s>HM)return!0;let o=HM*a*a;return Math.abs(ud.dot(dd))>o||Math.abs(ud.dot(Mc))>o||Math.abs(dd.dot(Mc))>o}()}function $be(e){return Wbe(e),Hbe(),Xbe.makeBasis(Th,Mh,ay)}var ud,dd,Mc,Th,Mh,ay,Xbe,WM,HM,AB=F(()=>{ne(),ud=new P,dd=new P,Mc=new P,Th=new P,Mh=new P,ay=new P,Xbe=new De,WM=1e-12,HM=.01});function Q1(e,t){return t===0?0:e/t}function BY(e){qbe(e,fH,pH),hx.setFromRotationMatrix(fH);let t=function(r,n,s){let a=2*Math.PI,o=d=>d-a*Math.round(d/a),l=o(r+Math.PI),h=o(Math.PI-n),u=o(s+Math.PI);return Math.abs(l)+Math.abs(u)<Math.abs(r)+Math.abs(s)-1e-9?[l,h,u]:[r,n,s]}(hx.x,hx.y,hx.z),i=pH.elements;return{position:[e.elements[12],e.elements[13],e.elements[14]],rotation:[t[0]*Qe.RAD2DEG,t[1]*Qe.RAD2DEG,t[2]*Qe.RAD2DEG],scale:[i[0],i[5],i[10]],shear:[Q1(i[4],i[5]),Q1(i[8],i[10]),Q1(i[1],i[0]),Q1(i[9],i[10]),Q1(i[2],i[0]),Q1(i[6],i[5])]}}function Mf(e,{translation:t,quaternion:i,scale:r,shearMatrix:n}={}){let s=BY(e);if(t!==void 0&&t.fromArray(s.position),i!==void 0){let a=s.rotation;i.setFromEuler(hx.set(a[0]*Qe.DEG2RAD,a[1]*Qe.DEG2RAD,a[2]*Qe.DEG2RAD))}r!==void 0&&r.fromArray(s.scale),n!==void 0&&n.fromArray(Ph.toMatrix(s.shear))}var pH,fH,hx,hC=F(()=>{ne(),AB(),Axe(),pH=new De,fH=new De,hx=new Rr});function Ybe(e){return e.length>=4&&function(t){return typeof t=="object"&&t!==null&&t.v===1&&t.data instanceof Float32Array&&Array.isArray(t.tracks)}(e[3])}function Kbe(e,t,i){let r={name:t,duration:i.duration,tracks:[],uuid:e};return i.blendMode!==void 0&&(r.blendMode=i.blendMode),JSON.stringify(r)}function eBe(e,t,i){for(let r=0;r<i.length;r++)if(!Object.is(e[t+r],i[r]))return!1;return!0}function tBe(e){if(!Array.isArray(e)||e.length>3)return e;let t,[i,r,n]=e;if(typeof i!="string"||typeof n!="string")return e;try{t=JSON.parse(n)}catch{return e}return t&&Array.isArray(t.tracks)&&!t.tracks.some(s=>!s?.type||!s.times||!s.values)?function(s,a,o){let l=[],h=0,u=g=>{let v=[h,g.length];return l.push(g),h+=g.length,v},d=new Map,c=o.tracks.map(g=>{let v=(b=>{let x=Float32Array.from(b),w=x.length+":"+x[0]+":"+x[x.length-1],S=d.get(w)??[];for(let M of S)if(eBe(M.run,0,x))return M.span;let T=u(x);return S.push({span:T,run:x}),d.set(w,S),T})(g.times),y=!Zbe.has(g.type),_={name:g.name,type:g.type,times:v,values:y?u(Float32Array.from(g.values)):[0,0]};return y||(_.list=Array.from(g.values)),g.interpolation!==void 0&&(_.interpolation=g.interpolation),_}),p=new Float32Array(h),f=0;for(let g of l)p.set(g,f),f+=g.length;let m={v:1,duration:o.duration,data:p,tracks:c};return o.blendMode!==void 0&&(m.blendMode=o.blendMode),o.userData!==void 0&&o.userData!=="{}"&&(m.userData=o.userData),[s,a,Kbe(s,a,m),m]}(i,typeof t.name=="string"?t.name:r,t):e}function iBe(e,t,i){return e.map(r=>{let n=t();return i[r[0]]=n,function(s,a){let[o,l,h]=s;if(Ybe(s))return[a,l,Kbe(a,l,s[3]),s[3]];let u=h.indexOf(o);return[a,l,u!==-1?h.slice(0,u)+a+h.slice(u+o.length):h,...s.slice(3)]}(r,n)})}var Zbe,Qbe=F(()=>{Zbe=new Set(["bool","string"])});function R3(e,[t,i]){return Math.min(Math.max(e,t),i)}function Jbe(e,t,i,r,n){e=R3(e,nxe),t=R3(t,sxe),i=R3(i,axe),r=R3(r,oxe);let s=Math.sqrt(t/e),a=i/(2*Math.sqrt(t*e)),o=a<1?s*Math.sqrt(1-a*a):0,l=a<1?(a*s-r)/o:-r+s;return h=>{let u=n!==void 0?n*h:h;return u=a<1?Math.exp(-u*a*s)*(1*Math.cos(o*u)+l*Math.sin(o*u)):(1+l*u)*Math.exp(-u*s),h===0||h===1?h:1-u}}function exe(e,t){return Bi(Bi(1-Bi(3*t))+Bi(3*e))}function txe(e,t){return Bi(Bi(3*t)-Bi(6*e))}function ixe(e){return Bi(3*e)}function D3(e,t,i){return Bi(Bi(Bi(Bi(Bi(exe(t,i)*e)+txe(t,i))*e)+ixe(t))*e)}function gie(e,t,i){let r=Bi(Bi(Bi(3*exe(t,i))*e)*e),n=Bi(Bi(2*txe(t,i))*e);return Bi(Bi(r+n)+ixe(t))}function J1(e,t,i,r){if(e=Bi(e),t=Bi(t),i=Bi(i),r=Bi(r),e<0||e>1||i<0||i>1||e===t&&i===r)return cxe;let n=new Float32Array(ZI);for(let s=0;s<ZI;s++)n[s]=D3(Bi(s*qM),e,i);return s=>(s=Bi(s))===0||s===1?s:D3((a=>{let o=0,l=1,h=ZI-1;for(;l!==h&&n[l]<=a;)o=Bi(o+qM),l+=1;l-=1;let u=Bi(Bi(a-n[l])/Bi(n[l+1]-n[l])),d=Bi(o+Bi(u*qM)),c=gie(d,e,i);return c>=hxe?function(p,f,m,g){for(let v=0;v<lxe;v++){let y=gie(f,m,g);if(y===0)return f;let _=Bi(D3(f,m,g)-p);f=Bi(f-Bi(_/y))}return f}(a,d,e,i):c===0?d:function(p,f,m,g,v){let y,_=0,b=0;do _=Bi(f+Bi(Bi(m-f)/2)),y=Bi(D3(_,g,v)-p),y>0?m=_:f=_,b+=1;while(Math.abs(y)>uxe&&b<dxe);return _}(a,o,Bi(o+qM),e,i)})(s),t,r)}function rxe(e,t,i){switch(e.easing){case 0:default:return i;case 1:return J1(.25,.1,.25,1)(i);case 2:return J1(.42,0,1,1)(i);case 3:return J1(0,0,.58,1)(i);case 4:return J1(.42,0,.58,1)(i);case 7:return J1(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:r,control2:n}=e;return r&&n?J1(r[0],r[1],n[0],n[1])(i):i}case 6:{let{mass:r,stiffness:n,damping:s,velocity:a}=e;return r===void 0||n===void 0||s===void 0||a===void 0?i:Bi(Jbe(r,n,s,a,t)(i))}}}var Bi,nxe,sxe,axe,oxe,lxe,hxe,uxe,dxe,ZI,qM,cxe,vie,rBe=F(()=>{Bi=Math.fround,nxe=[.01,100],sxe=[.01,1e4],axe=[.01,1e3],oxe=[.01,1e3],lxe=4,hxe=Bi(.001),uxe=Bi(1e-7),dxe=10,qM=Bi(1/((ZI=11)-1)),cxe=e=>e,vie=Bi(1.70158),Bi(vie+1)});function pxe(e,t){if(e.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(t<=e[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 f=c+Math.floor(d/2),m=h[f].time;if(m<u)c=f+1;else{if(!(m>u))return{found:!0,index:f};p=f}d=p-c}return{found:!1,index:c}}(e,t);if(i)return{index0:r,index1:r,t:1};if(r>=e.length){let h=e.length-1;return{index0:h,index1:h,t:1}}let n=r-1,s=r,a=e[n].time,o=e[s].time;if(o===a)return{index0:n,index1:s,t:.5};let l=QI(o-a);return{index0:n,index1:s,t:rxe({...e[n].ease,control2:e[s].ease.control2},l,QI(QI(t-a)/l))}}function fxe(e){return[...e].sort((t,i)=>t.time-i.time)}var QI,nBe=F(()=>{rBe(),QI=Math.fround});function sBe(e){if(e?.length!==2)return;let t=`${e[0]}.${e[1]}`;return FY.includes(t)?t:void 0}function mxe(e){return e.slice(0,e.indexOf("."))}function gxe(e){return Hg.indexOf(e.slice(-1))}function aBe(e){return{easing:e?.type,control1:Wf(e?.cubicControls?.control1,[0,0]),control2:Wf(e?.cubicControls?.control2,[1,1]),...e?.springParameters}}function oBe(e){let t=e?.cubicControls;return{...e,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...e?.springParameters?{springParameters:{...e.springParameters}}:{}}}function yie(e,t,i){let r=mxe(e);if(r==="position"){let n=gxe(e);return Hg.flatMap((s,a)=>Math.abs(t.elements[4*a+n])>1e-9?[`position.${s}`]:[])}return(i?[r]:["rotation","scale"]).flatMap(n=>Hg.map(s=>`${n}.${s}`))}function lBe(e,t){let[i,r,n]=e,s=[[i,r,n],[i+180,180-r,n+180]],a=[i,r,n],o=1/0;for(let l of s){let h=l.map((d,c)=>d+360*Math.round((t[c]-d)/360)),u=h.reduce((d,c,p)=>d+Math.abs(c-t[p]),0);u<o-1e-9&&(a=h,o=u)}return a}function hBe(e,t,i){if(e==="rotation"){let r=((t-i)%360+540)%360-180;return Math.abs(r)<1e-6}return Math.abs(t-i)<1e-9*Math.max(1,Math.abs(t),Math.abs(i))}function uBe(e,t,i,r){let n=new Map;for(let{id:p,data:f}of e.unproxy()){if(f.isPlaceholder)continue;let m=sBe(f.path);if(!m){if($M.includes(f.path?.[0]))return;continue}if(typeof f.value!="number"||!Number.isFinite(f.value))return;let g=n.get(m)??{keys:[],sampled:[]};g.keys.push({id:p,time:f.time,value:f.value,keyframe:f}),n.set(m,g)}if(n.size===0)return;for(let p of n.values())p.keys.sort((f,m)=>f.time-m.time),p.sampled=fxe(p.keys.map(f=>({time:f.time,ease:aBe(f.keyframe.easing),value:f.value})));let s=(p,f)=>{let m=n.get(p);return m?function(g,v){let{index0:y,index1:_,t:b}=pxe(g.sampled,v),x=g.sampled[y].value;return x+(g.sampled[_].value-x)*b}(m,f):i[mxe(p)][gxe(p)]},a=new Vt,o=new Rr,l=new De,h=new P,u=new P,d=p=>{let f=(m=>{let g={};for(let v of $M)g[v]=Hg.map((y,_)=>s(FY[3*$M.indexOf(v)+_],m));return g})(p);return o.set(f.rotation[0]*Qe.DEG2RAD,f.rotation[1]*Qe.DEG2RAD,f.rotation[2]*Qe.DEG2RAD),l.compose(h.fromArray(f.position),a.setFromEuler(o),u.fromArray(f.scale)).premultiply(t),{pose:f,out:BY(l)}},c=function(p){let f=p.elements,m=[0,4,8].map(y=>new P(f[y],f[y+1],f[y+2])),g=m[0].lengthSq(),v=1e-9*Math.max(1,g);return Math.abs(m[1].lengthSq()-g)<v&&Math.abs(m[2].lengthSq()-g)<v&&Math.abs(m[0].dot(m[1]))<v&&Math.abs(m[0].dot(m[2]))<v&&Math.abs(m[1].dot(m[2]))<v}(t);for(let p of $M){let f,m=Hg.map(_=>`${p}.${_}`),g=_=>{let b=new Set;for(let x of yie(_,t,c))for(let w of n.get(x)?.keys??[])b.add(w.time);return[...b].sort((x,w)=>x-w)},v=[...new Set(m.flatMap(_=>g(_)))].sort((_,b)=>_-b),y=new Map;for(let _ of v){let{pose:b,out:x}=d(_),w=[...x[p]];p==="rotation"&&(w=lBe(w,f?f.out.map((S,T)=>S+b.rotation[T]-f.in[T]):b.rotation),f={in:b.rotation,out:w}),y.set(_,w)}m.forEach((_,b)=>{let x=n.get(_)?.keys??[],w=g(_),S=new Set(w);if(x.length!==0||!w.every(T=>hBe(p,y.get(T)[b],r[p][b]))){for(let T of x)S.has(T.time)||e.delete(T.id);for(let T of w){let M=y.get(T)[b],E=x.find(D=>D.time===T);if(E){let D=e.data(E.id);D&&(D.value=M);continue}let A=yie(_,t,c).sort((D,R)=>Number(R===_)-Number(D===_)).map(D=>n.get(D)?.keys.find(R=>R.time===T)).find(D=>D!==void 0),C=Qe.generateUUID();e.insertBefore(null,[{id:C,data:{id:C,time:T,path:[p,Hg[b]],value:M,easing:oBe(A.keyframe.easing),index:Wg.rowOrder([p])}}])}}})}}var $M,Hg,FY,dBe=F(()=>{ne(),OY(),nBe(),hC(),Hg=["x","y","z"],FY=($M=["position","rotation","scale"]).flatMap(e=>Hg.map(t=>`${e}.${t}`))}),vxe={};function _ie(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function yxe(e){let t=e.geometry;t!==void 0&&Txe.has(t.type)&&t.extrusionVersion===void 0&&(t.extrusionVersion=1)}function _xe(e){if(e.type!=="Empty")return;let t=Ds(e.animations);if(!Array.isArray(t))return;let i=t.map(tBe);i.some((r,n)=>r!==t[n])&&(e.animations=i)}function bie(e,t){let[i,r,n]=e,s=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(n),u=Math.sin(n),d=[o*h,s*u+a*h*l,a*u-s*h*l],c=Math.hypot(t[0],t[1],t[2])||1;return Math.abs((d[0]*t[0]+d[1]*t[1]+d[2]*t[2])/c)}function bxe(e){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*sg)})(e),e.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(n,s){let a=Array.isArray(s)&&s.length>=3&&s.every(h=>typeof h=="number"&&Number.isFinite(h))?s:[0,1,0],o=bie(n,a),l=bie(n.map(h=>h*Mxe),a);return Math.abs(o-l)<1e-6?n.some(h=>Math.abs(h)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(n=>n*sg)}(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*sg))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*sg),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*sg),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=sg,t.extrusion.twist*=sg),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(Ds(e.events))&&e.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 cBe(e){e.scene.objects.traverse((t,i)=>{})}function pBe(e){let t=e.schema??104;t!==136&&(t<130&&(UY(e.asset),e.schema=130),t<135&&(zY(e.asset),e.schema=135),t<136&&(kY(e.asset),e.schema=136))}function rd(e,t){t(e.data);for(let i of e.children)rd(i,t)}function xxe(e){let t=e.schema??104;t!==136&&(t<105&&(rd(e.asset,bxe),e.schema=105),t<118&&(rd(e.asset,wxe),e.schema=118),t<121&&(rd(e.asset,gH),e.schema=121),t<130&&(rd(e.asset,i=>_5(i,UY)),e.schema=130),t<132&&(rd(e.asset,yxe),e.schema=132),t<133&&(rd(e.asset,i=>Sxe(i,()=>{})),e.schema=133),t<134&&(rd(e.asset,_xe),e.schema=134),t<135&&(rd(e.asset,i=>_5(i,zY)),e.schema=135),t<136&&(rd(e.asset,i=>_5(i,kY)),e.schema=136))}function JI(e,t){Qp(e,t),Zp(e,t),Object.values(e.shared.lib.materials).forEach(i=>t(i.asset))}function UY(e){e.layers===void 0&&Object.assign(e,Un.defaultTwoLayerData("phong"))}function zY(e){let t=lx(e),i=Un.withRepairedLayers(t);i!==t&&(e.layers=i.layers)}function kY(e){let t=lx(e),{material:i,restored:r}=Un.restoreLayersSeq(t);r&&(e.layers=i.layers)}function _5(e,t){"materials"in e?e.materials.forEach(i=>{i!==void 0&&typeof i!="string"&&t(i)}):"material"in e&&e.material!==void 0&&typeof e.material!="string"&&t(e.material)}function wxe(e){e.timelineAnimations=Go({},ri.prototype)}function fBe(e){let t=[];return e?(e.forEach((i,r)=>{let{path:n,keyframes:s}=i.data,a=n[0]==="material"?i.id:void 0;s?.length?s.forEach(({id:o,data:l})=>{t.push({id:o,data:{...l,path:n,layerId:a,index:r}})}):t.push(Wg.placeholderKeyframe(i.id,n,{layerId:a,index:r}))}),t.sort((i,r)=>i.data.time-r.data.time),new Et(...t.map((i,r)=>({...i,fi:r})))):new Et}function mBe(e){for(let{id:t,data:i}of[...e.unproxy()]){let r=i.path?.[0];if(!r||!Exe.includes(r))continue;let n=mH(i.value);if(!n.length)continue;let s=e.data(t);if(!s)continue;let a=i.value,[o,...l]=n;for(let h of l){let u=Qe.generateUUID();e.insertBefore(null,[{id:u,data:{...i,id:u,path:[r,h],value:a[h],easing:gBe(i.easing)}}])}s.path=[r,o],s.value=a[o]}}function mH(e){return e===null||typeof e!="object"?[]:zA.filter(t=>t in e)}function gBe(e){let t=e?.cubicControls;return{...e,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...e?.springParameters?{springParameters:{...e.springParameters}}:{}}}function vBe(e,t){return Math.abs(e[0]-t[0])<1e-6&&Math.abs(e[1]-t[1])<1e-6}function yBe(e){let t=function(s){let a=[];for(let o of Wg.groupKeyframes(s)){let l=new Set(o.keyframes.flatMap(u=>mH(u.data.value))),h=l.size?[...l].map(u=>o.keyframes.filter(d=>mH(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}([...e.unproxy()]),i=new Map,r=new Set;for(let{left:s,right:a}of t){let o=s.data.easing?.type,l=(o===void 0?void 0:Wg.presetHandles(o))?.control2??(o===5?Wf(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let h=i.get(a.id);h?vBe(h,l)||r.add(a.id):i.set(a.id,l)}let n=new Map;for(let{id:s,data:a}of e.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Wg.presetHandles(o);l&&n.set(s,l.control1)}for(let{left:s,right:a}of t)r.has(a.id)&&n.delete(s.id);for(let[s,a]of n){let o=e.data(s);!o?.easing||(o.easing.cubicControls={control1:a,control2:Wf(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:s,right:a}of t){if(!n.has(s.id))continue;let o=e.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Wf(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function xie(e,t){e.scene.objects.traverse((i,r)=>{let n=r;if(n.type==="Page"&&n.timelines)for(let s of Object.values(n.timelines))for(let a of Object.values(s.objectTimelines??{}))t(a.keyframes)})}function gH(e){e.pivot=[0,0,0],e.pivotRotation=[0,0,0]}function Sxe(e,t,i=[]){let r=["position","rotation","scale","shear"];function n(c,p,f){return c?.map(m=>typeof m=="string"?t(m)??f:m)??[...p]}function s(c,p){if(c&&!function(f){return f.every((m,g)=>Math.abs(m-(g%5==0?1:0))<1e-6)}(c))return BY(new De().fromArray(c).multiply(new De().compose(new P().fromArray(p.position),new Vt().setFromEuler(new Rr(p.rotation[0]*Qe.DEG2RAD,p.rotation[1]*Qe.DEG2RAD,p.rotation[2]*Qe.DEG2RAD)),new P().fromArray(p.scale))))}function a(c,p){return c.length===p.length&&c.every((f,m)=>f===p[m])}e.shear=Ph.zero;let o=e,l=o.hiddenMatrix;l!==void 0&&delete o.hiddenMatrix;let h={position:n(o.position,[0,0,0],0),rotation:n(o.rotation,[0,0,0],0),scale:n(o.scale,[1,1,1],1)},u=s(l,h);if(u&&Object.assign(o,u),u){let c=new De().fromArray(l);for(let p of i)uBe(p,c,h,u)}let d=u??{...h,shear:[...Ph.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 f={position:n(c.position,h.position,0),rotation:n(c.rotation,h.rotation,0),scale:n(c.scale,h.scale,1)},m=s(p??l,f);if(!u&&!m)return;let g=m??{...f,shear:[...Ph.zero]};for(let v of r)(c[v]!=null||!a(g[v],d[v]))&&(c[v]=g[v])})}function _Be(e){}function bBe(e){let t=e.schema??0;if(t!==136){if(t>136)return void console.error(`This scene was created with a newer version of Spline (file format ${t}, this runtime reads 136). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",t,"to ",136),function(i,r){if(r<1&&(Qp(i,oie),Zp(i,oie),i.schema=1),r<2&&(function(n){Object.assign(n.scene.publish,{orbitControls:{...e4.defaultData,...Ds(n.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(n){function s(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,h]of Object.entries(o))if((TB.includes(l)||typeof h=="boolean")&&delete o[l],l==="texture")for(let[u,d]of Object.entries(h))(MY.includes(u)||typeof d=="boolean")&&delete h[u]}}}n.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let h=l;h.material?s(h.material):h.materials&&h.materials.forEach(u=>{s(u)})})})}(i),i.schema=3),r<4&&(function(n){n.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(n){n.scene.objects.traverse((s,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(n){n.scene.objects.traverse((s,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&&(hie(i),i.schema=9),r<10&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((s,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(hie(i),i.schema=12),r<13&&(function(n){n.shared.audios=Go({},ri.prototype)}(i),i.schema=13),r<14&&(function(n){let s=n.shared.materials;Object.entries(s).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(s,{[a]:l})}})}(i),i.schema=14),r<15&&(function(n){Object.entries(Ds(n.shared.images)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.images[s]}),Object.entries(Ds(n.shared.audios)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.audios[s]})}(i),i.schema=15),r<16&&(function(n){n.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Qp(i,uie),Zp(i,uie),i.schema=17),r<18&&(Qp(i,lie),Zp(i,lie),i.schema=18),r<19&&(function(n){Object.assign(n.scene.publish.settings,{video:{...Tf.defaultData.settings.video,...Ds(n.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(n){n.shared.fonts=Go({},ri.prototype)}(i),function(n){let s=[];n.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let h=Un.defaultTwoLayerData("phong"),u=typeof l.color=="string"?n.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(f){return f.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(m=>m.charAt(0).toUpperCase()+m.slice(1)).join(" ")}(l.font);n.shared.fonts[d]===void 0&&(n.shared.fonts[d]={name:d});let c={name:l.name,...ra.defaultData,...yc.defaultData,flatShading:!1,wireframe:!1,geometry:{...cf.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:Ds(l.states),events:Ds(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Ds(n.scene.objects).parent(a);n.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),s.push(a)}}),s.forEach(a=>{n.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(n){let s={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(s[Number(l.type)])if(Object.assign(l,{type:s[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 Et,move:new Et,jump:new Et}});else{let h=new Et;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:Qe.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,Gv(u,"mass","stiffness","damping","velocity")):u.easing===5&&Object.assign(p,{control1:{...u.control1},control2:{...u.control2}});let f={repeat:u.repeat?-1:0,delay:u.delay,delayDirection:u.delayDirection,direction:u.cycle&&u.rewind?"pingpong-rewind":u.cycle?"pingpong":"normal"},m={state:u.state,...f,...p},g={allowSlerp:!0,type:"Transition",object:u.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Et({fi:0,id:Qe.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:Qe.generateUUID(),data:m})};h.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(n){n.scene.objects.traverse((s,a)=>{function o(l,h){let u=new Et,d=[];if(a.events.forEach((c,p,f)=>{if(c.type==="Audio"&&c.trigger===h){let m;d.push(p),c.interaction==="play"?m={...Gv(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")&&(m={...Gv(c,"interaction","delay","object","playAudio"),type:"Audio"}),m&&u.push({fi:f,id:p,data:m})}}),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:Qe.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&&(pie(i),i.schema=22),r<23&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(n){n.scene.objects.traverse((s,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(n){n.shared.videos=Go({},ri.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(n){n.scene.objects.traverse((s,a)=>{let o=n.scene.objects.unproxy().parent(s);if(o){let l=Ds(n.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Ds(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(n){n.scene.objects.traverse((s,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&&(pie(i),i.schema=28),r<29&&(function(n){function s(o){Object.setPrototypeOf(o,Ts.prototype),o.texture&&Object.setPrototypeOf(o.texture,Ts.prototype)}function a(o){Object.setPrototypeOf(o,Ts.prototype);for(let l in o)s(o[l])}n.scene.objects.traverse((o,l)=>{l.states.forEach(h=>{let u=h;if(u.material){let d=Ds(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=Ds(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=Un.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((s,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(n){n.scene.objects.traverse((s,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(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(n){let{video:s}=n.scene.publish.settings;s.format==="gif"&&s.fps>48&&(s.fps=15)}(i),i.schema=35),r<36&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(n){let s=n.scene.environment.usePhysics;n.scene.objects.traverse((a,o)=>{s&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Qp(i,die),Zp(i,die),i.schema=38),r<39&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=i4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(n){n.scene.styles||(n.scene.styles=ny.defaultData())}(i),i.schema=40),r<41&&(function(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Qp(n,fie),Zp(n,fie)}(i),i.schema=41),r<42&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new Et})})})}(i),i.schema=42),r<43&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Qp(i,mie),Zp(i,mie),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=f1);let n=Ds(i.scene.objects),s=i.scene.objects;i.scene.publish.playPage=Rx,s.insertBefore(null,null,[{id:Rx,data:{...Sy.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Gv(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Gv(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Nx.defaultData,...Gv(i.scene.environment,"usePhysics","gravity")},camera:Ds(i.scene.ownerCamera)??Sy.defaultData.camera,name:"Scene"},children:[]}]);for(let l of n)l.id!==sy.TRASH_CAN_ID&&s.move(Rx,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,Dx.defaultData)),h.physics!==void 0&&h.physics!==null&&(h.physics.enabled=h.collision??"visibility",delete h.collision)}),i.schema=99}}(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Tf.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Qp(e,_ie),Zp(e,_ie),e.schema=101),t<102&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.geometry;s&&s.type==="PathGeometry"&&(s.extrusion.capType="flat",s.extrusion.bevel=50,s.extrusion.bevelSides=6,s.extrusion.shape.type==="Custom"&&(s.extrusion.shape.shapeQuality="low"))})}(e),e.schema=102),t<104&&(e.shared.catelogs=new ri,e.shared.lib=pf.defaultData(),e.schema=104),t<105&&(function(i){i.shared.variables=Go({},ri.prototype)}(e),e.scene.objects.traverse((i,r)=>{bxe(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))xxe(i);if(t<106&&(function(i){let r=Ds(i.shared.variables);i.shared.variables=Go(Object.entries(r??{}).map(([n,s],a)=>({fi:a,id:n,data:s})),Et.prototype)}(e),e.schema=106),t<107&&(e.shared.lib.variables=pf.defaultData().variables,e.schema=107),t<109&&(function(i){i.shared.particles=Go({},ri.prototype),i.shared.lib&&(i.shared.lib.particles=pf.defaultData().particles)}(e),e.schema=109),t<110&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Particle"&&typeof n.renderMaterial.size=="number"&&Object.assign(n.renderMaterial,{size:[n.renderMaterial.size,n.renderMaterial.size]})})}(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{(function(n){Array.isArray(Ds(n.events))&&n.events?.forEach(s=>{"disabled"in s||(s.disabled=!1),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress")&&(s.mode=s.mode||"Object")})})(r)}),e.schema=111),t<112&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Page"&&(n.postprocessing.depthOfField.focusDistance=100,n.postprocessing.depthOfField.focalLength=20,n.postprocessing.depthOfField.bokehScale=5)})}(e),e.schema=112),t<113&&(function(i){i.scene.objects.traverse((r,n)=>{Array.isArray(Ds(n.events))!==!1&&n.events?.forEach(s=>{let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?s.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")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(o=>{s.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,s.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),s.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,s.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):s.type==="Start"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,s.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),s.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(function(i){i.shared.userAPIs=Go({},ri.prototype),i.shared.userWebhooks=Go({},ri.prototype),i.shared.lib&&(i.shared.lib.userAPIs=pf.defaultData().userAPIs,i.shared.lib.userWebhooks=pf.defaultData().userWebhooks)}(e),e.schema=115),t<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Tf.defaultData.settings.videoStatic)}(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117),t<118&&(e.shared.timelineAnimations=Go({},ri.prototype),e.scene.objects.traverse((i,r)=>{wxe(r)}),e.schema=118),t<119&&(e.scene.publish.settings.videoStatic.format=Ix.defaultData.scene.publish.settings.videoStatic.format,e.scene.publish.settings.videoStatic.imageFormat=Ix.defaultData.scene.publish.settings.videoStatic.imageFormat,e.schema=119),t<120&&(e.scene.publish.settings.image.colorSpace="display-p3",e.scene.publish.settings.videoStatic.colorSpace="display-p3",e.schema=120),t<121&&(e.scene.objects.traverse((i,r)=>{gH(r),r.type==="Page"&&r.camera!==void 0&&gH(r.camera)}),e.schema=121),t<122&&(delete e.scene.publish.settings.video,e.scene.publish.orbitControls.rotationSpeed=Ix.defaultData.scene.publish.orbitControls.rotationSpeed,e.schema=122),t<123&&(e.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=wg.defaultData)}),e.schema=123),t<124&&(t>=123&&e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(typeof n.exposure=="number"&&(n.exposure=Math.round(n.exposure/5e-4*1e4)/1e4),n.lighting===void 0&&(n.lighting=wg.defaultData.lighting))}),e.schema=124),t<125&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingIntensity===void 0&&(n.lightingIntensity=wg.defaultData.lightingIntensity)}),e.schema=125),t<126&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(n.mode===void 0&&(n.mode="physical"),n.hdri===void 0?n.hdri={...wg.defaultData.hdri}:(n.hdri.blur===void 0&&(n.hdri.blur=wg.defaultData.hdri.blur),Array.isArray(n.hdri.rotation)&&(n.hdri.rotation=n.hdri.rotation[1]??0)))}),e.schema=126),t<127&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n?.hdri!==void 0&&n.hdri.showBackground===void 0&&(n.hdri.showBackground=!0)}),e.schema=127),t<128&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingQuality===void 0&&(n.lightingQuality="full")}),e.schema=128),t<129&&(e.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=Sy.defaultData.camera);let n=r.camera;n.far=1e5,n.perspective?n.perspective.near=70:n.perspective={near:70,fov:45,zoom:1}}}),e.schema=129),t<130&&(JI(e,UY),e.schema=130),t<131&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.states;if(!s)return;let a=n.timelineAnimations,o=[];s.forEach((l,h)=>{(l.isAnimation||a?.[h])&&o.push(h)}),o.forEach(l=>s.delete(l))})}(e),function(i){let r=i.shared,n=r.timelineAnimations;if(!n)return;let s=i.scene.objects,a=s.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(n)){let h=Go({},ri.prototype),u=0,d=Boolean(l.loop);for(let[f,m]of Object.entries(l.mapping??{})){let g=s.data(f)?.timelineAnimations?.[m];!g||(u=Math.max(u,g.to??0),d=d||Boolean(g.loop),h[f]={id:f,keyframes:fBe(g.properties?.unproxy())})}let c=l.page??a,p=c?s.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=Go({},ri.prototype)))[o]={id:o,name:l.name,duration:u||5,...d?{loop:d}:{},objectTimelines:h})}delete r.timelineAnimations,s.traverse((o,l)=>{delete l.timelineAnimations})}(e),xie(e,mBe),xie(e,yBe),e.schema=131),t<132&&(e.scene.objects.traverse((i,r)=>yxe(r)),e.schema=132),t<133){let i=function(n){return s=>n.get(s)?.data?.value}(e.shared.variables),r=new Map;e.scene.objects.traverse((n,s)=>{let a=s;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)}}),e.scene.objects.traverse((n,s)=>Sxe(s,i,r.get(n))),e.schema=133}t<134&&(e.scene.objects.traverse((i,r)=>_xe(r)),e.schema=134),t<135&&(JI(e,zY),e.schema=135),t<136&&(JI(e,kY),e.schema=136)}}ww(vxe,{updateAllMaterials:()=>JI,updateDocumentSchema:()=>bBe,updateLibSchema:()=>_Be,updateMaterialSchema:()=>pBe,updateObjectStateRec:()=>rd,updateObjectsSchema:()=>xxe,updateTextValues:()=>cBe});var Txe,sg,Mxe,Exe,wie,N3,b5,Sie,I3,oy,XS,e_,O3,x5,eO,w5,S5,Tie,tO,T5,Ty,vH,CB=F(()=>{ne(),Gbe(),Ir(),OY(),J4e(),EB(),lC(),eh(),la(),IY(),MB(),PY(),hC(),Qbe(),dBe(),Txe=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),sg=180/Math.PI,Mxe=Math.PI/180,Exe=["position","rotation","scale","shape size"]}),xBe=F(()=>{var e,t,i;eh(),Ir(),la(),(wie||(wie={})).is=function(r){return!0},(e=N3||(N3={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},e.merge=function(r,n){return{position:n?.position??r.position,rotation:n?.rotation??r.rotation,scale:n?.scale??r.scale,shear:n?.shear??r.shear}},e.diff=function(r,n){return nbe({position:Lc.isEqual(r.position,n.position)?void 0:n.position,rotation:r.rotation===n.rotation?void 0:n.rotation,scale:Lc.isEqual(r.scale,n.scale)?void 0:n.scale,shear:r.shear&&n.shear&&Lc.isEqual(r.shear,n.shear)?void 0:n.shear})},(b5||(b5={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(Sie||(Sie={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(I3||(I3={})).defaultData={opacity:1,fill:{color:kr.fromHexAndA(Za,1),enabled:!0},stroke:{color:kr.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:kr.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:kr.from0to1([0,0,0,1]),enabled:!1,spread:0}},(t=oy||(oy={})).newEmpty=function(r,n){return{name:n}},t.patch=function(r,n){if(n===void 0)return r;let s={...r};return Object.assign(s,N3.merge(s,n)),s=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}(s,n),s=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}(s,n),s},t.toOps=function(r,n){let s,a=[];for(let[o,l]of Object.entries(n))o!=="name"&&(s===void 0&&(s={path:[],props:{},type:0},a.push(s)),s.props[o]=l);return a},(XS||(XS={})).defaultData={...N3.defaultData,...b5.defaultData,states:new Et,events:new Et,visible:!0,raycastLock:!1},(e_||(e_={})).defaultData={...XS.defaultData,...I3.defaultData},(O3||(O3={})).defaultData={cornerRadius:[0,0,0,0]},(x5||(x5={})).defaultData={...e_.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(eO||(eO={})).defaultData={...e_.defaultData,...O3.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(w5||(w5={})).defaultData={...e_.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"},(S5||(S5={})).defaultData={...e_.defaultData,type:"path2d",path:"",name:"Path"},(Tie||(Tie={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(tO||(tO={})).defaultData={...XS.defaultData,name:"Group",type:"group2d"},(T5||(T5={})).defaultData=()=>({...XS.defaultData,...O3.defaultData,...I3.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:kr.fromHexAndA(4737101,1),enabled:!0},stroke:{color:kr.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(n){switch(n){case"rectangle2d":case"vector2d":return{...eO.defaultData};case"ellipse2d":return{...x5.defaultData};case"text2d":return{...w5.defaultData};case"path2d":return{...S5.defaultData};case"frame2d":return{...T5.defaultData()};case"group2d":return{...tO.defaultData}}},r.getPivot=function(n){return"width"in n&&"height"in n?[typeof n.width=="number"?.5*n.width:0,typeof n.height=="number"?.5*n.height:0]:[0,0]},r.isResizeable=function(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"},r.isAutoLayoutable=function(n){return n.type==="frame2d"&&n.autoLayout!==void 0},r.hasCorners=function(n){return n.type==="rectangle2d"||n.type==="frame2d"}})(Ty||(Ty={})),(i=vH||(vH={})).defaultData={name:"UI",type:"scene2d",objects:new Ea},i.emptyData=function(){return{type:"scene2d",objects:new Ea}}}),Axe=F(()=>{W4e(),H4e(),Abe(),Cbe(),Gbe(),Tbe(),Ibe(),Obe(),Fbe(),PY(),CB(),Vbe(),CY(),AY(),Pbe(),lC(),Nbe(),zbe(),eh(),EB(),MB(),Qbe(),DY(),Bbe(),IY(),NY(),$4e(),Lbe(),LY(),RY(),Rbe(),Dbe(),xBe()});function ly(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),n=new Set(Object.keys(e[0].morphAttributes)),s={},a={},o=e[0].morphTargetsRelative,l=new Mt,h=0;for(let u=0;u<e.length;++u){let d=e[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;s[p]===void 0&&(s[p]=[]),s[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(!n.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(t){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<e.length;++c){let p=e[c].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+u);u+=e[c].attributes.position.count}l.setIndex(d)}for(let u in s){let d=Mie(s[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 m=0;m<a[u].length;++m)p.push(a[u][m][c]);let f=Mie(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}}return l}function Mie(e){let t,i,r,n=-1,s=0;for(let h=0;h<e.length;++h){let u=e[h];if(t===void 0&&(t=u.array.constructor),t!==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(n===-1&&(n=u.gpuType),n!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=u.count*i}let a=new t(s),o=new Pt(a,i,r),l=0;for(let h=0;h<e.length;++h){let u=e[h];if(u.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=u.count;c<p;c++)for(let f=0;f<i;f++){let m=u.getComponent(c,f);o.setComponent(c+d,f,m)}}else a.set(u.array,l);l+=u.count*i}return n!==void 0&&(o.gpuType=n),o}var uC=F(()=>{ne()});function Cxe(e){let t=e.points.length/7,i=new Et;for(let r=0;r<t;r++){let n=7*r,s=e.points[n+0],a=e.points[n+1],o=e.points[n+2],l=e.points[n+3],h=e.points[n+4],u=e.points[n+5],d=e.points[n+6];i.push({fi:r,id:Qe.generateUUID(),data:{roundness:d,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[h,u]}}})}return{points:i,isClosed:e.isClosed,roundness:e.roundness,shapeHoles:e.shapeHoles?.map(r=>Cxe(r))??[]}}function Pxe(e){let{userData:t,uuid:i,...r}=e;if(t===void 0||t.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:h}=a,u=h?.groups,d=h?.attributes??{},c=h?.morphAttributes??{},p=h?.interleavedBuffers,f=h?.arrayBuffers,m=h?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(v){let y=1/0,_=1/0,b=1/0,x=-1/0,w=-1/0,S=-1/0;for(let T=0;T<v.length;T+=3){let M=v[T],E=v[T+1],A=v[T+2];y=Math.min(y,M),_=Math.min(_,E),b=Math.min(b,A),x=Math.max(x,M),w=Math.max(w,E),S=Math.max(S,A)}return{width:x-y,height:w-_,depth:S-b}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:f},...o===void 0?{}:o,type:"NonParametricGeometry"};return m!==void 0&&Object.assign(g.data,{index:m}),u!==void 0&&Object.assign(g.data,{groups:u.map(v=>({...v,materialIndex:v.materialIndex??0}))}),g}(e);if(t.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let h=new Mt;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 Tt(u,3)),h.setIndex(new Gf(c,1));let p=function(v,y=1e-4){y=Math.max(y,Number.EPSILON);let _={},b=v.getIndex(),x=v.getAttribute("position"),w=b?b.count:x.count,S=0,T=Object.keys(v.attributes),M={},E={},A=[],C=["getX","getY","getZ","getW"],D=["setX","setY","setZ","setW"];for(let G=0,K=T.length;G<K;G++){let q=T[G],Y=v.attributes[q];M[q]=new Y.constructor(new Y.array.constructor(Y.count*Y.itemSize),Y.itemSize,Y.normalized);let ue=v.morphAttributes[q];ue&&(E[q]||(E[q]=[]),ue.forEach((de,ge)=>{let be=new de.array.constructor(de.count*de.itemSize);E[q][ge]=new de.constructor(be,de.itemSize,de.normalized)}))}let R=.5*y,I=Math.log10(1/y),U=Math.pow(10,I),O=R*U;for(let G=0;G<w;G++){let K=b?b.getX(G):G,q="";for(let Y=0,ue=T.length;Y<ue;Y++){let de=T[Y],ge=v.getAttribute(de),be=ge.itemSize;for(let re=0;re<be;re++)q+=~~(ge[C[re]](K)*U+O)+","}if(q in _)A.push(_[q]);else{for(let Y=0,ue=T.length;Y<ue;Y++){let de=T[Y],ge=v.getAttribute(de),be=v.morphAttributes[de],re=ge.itemSize,xe=M[de],j=E[de];for(let z=0;z<re;z++){let X=C[z],te=D[z];if(xe[te](S,ge[X](K)),be)for(let V=0,ae=be.length;V<ae;V++)j[V][te](S,be[V][X](K))}}_[q]=S,A.push(S),S++}}let k=v.clone();for(let G in v.attributes){let K=M[G];if(k.setAttribute(G,new K.constructor(K.array.slice(0,S*K.itemSize),K.itemSize,K.normalized)),G in E)for(let q=0;q<E[G].length;q++){let Y=E[G][q];k.morphAttributes[G][q]=new Y.constructor(Y.array.slice(0,S*Y.itemSize),Y.itemSize,Y.normalized)}}return k.setIndex(A),k}(h),f=[],m=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let v=0,y=d.length;v<y;)d[v]===d[v+1]?(m[d[v]]++,f.push(...new Set(g.slice(3*v,3*v+6))),v+=2):(f.push(...g.slice(3*v,3*v+3)),v++);o.indexWASM={array:f},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:m}}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,...wBe(o.positionWASM.array)};l.subdivisions=t.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 n=t.type,s=t.parameters;return n==="VectorGeometry"?(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,width:100,height:100,shape:Cxe(t.shape),type:n}):n==="LatheGeometry"?{...t.parameters,type:n,points:(t?.parameters.points??[]).map(a=>[a.x,a.y])}:(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,type:n})}function wBe(e){return yH.setFromArray(e),yH.getSize(XM),{width:XM.x,height:XM.y,depth:XM.z}}var yH,XM,M5,SBe=F(()=>{Ir(),ne(),uC(),new De,new Vt,new Rr,new P,new P,yH=new cn,XM=new P}),TBe=F(()=>{var e;(e=M5||{}).view="view",e.edit="edit",((M5=e)||(M5={})).canWrite=function(t){return t!=="view"},class extends Error{constructor(t,i){super(`This is a ${t.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=t,this.expected=i,this.name="DocumentKindMismatchError"}}}),Rxe,Xf,GE,Dxe,VY,Ew,YS,L3,E5,Aw,Eie,A5,Aie,C5,uw,pm,fm,lp,P5,Cie,Pie,R5,_H,Ef,Nxe=F(()=>{TBe()}),MBe=F(()=>{}),EBe=F(()=>{Ir(),CB(),Nxe()}),ABe=F(()=>{lC(),[...TB],new Set(MY)}),Ot=F(()=>{Axe(),MBe(),K4e(),CB(),EBe(),Nxe(),OY(),ABe(),LY(),Ir()}),Ad=F(()=>{Rxe=[3,4,8,9],Xf=5,GE=3,Dxe=32,VY=.98}),dC=F(()=>{ne(),Ew=e=>{var t;return(t=class extends e{}).geometryHelper=new Dh(30,30,30),t}}),cC=F(()=>{ne(),YS=new _f,L3=new ja,E5=new De,Aw=(e,t,i,r,n=!1,s=e)=>{let a=t,o=s.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),L3.copy(a.boundingSphere),L3.applyMatrix4(o),i.ray.intersectsSphere(L3)===!1||(E5.copy(o).invert(),YS.copy(i.ray).applyMatrix4(E5),a.boundingBox!==null&&YS.intersectsBox(a.boundingBox)===!1))return;let l,h,u,d,c,p,f=a.index,m=a.attributes.position,g=a.drawRange;if(n===!1){for(c=Math.max(0,g.start),p=Math.min(f.count,g.start+g.count);c<p;c+=3)if(h=f.getX(c),u=f.getX(c+1),d=f.getX(c+2),l=v(e,i,YS,m,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let y=a.attributes.position,_=new P,b=new P,x=new P,w=new P,S=2,T=1/((s.scale.x+s.scale.y+s.scale.z)/3),M=T*T;for(let E=Math.max(0,g.start),A=Math.min(y.count,g.start+g.count)-1;E<A;E+=S){if(_.fromBufferAttribute(y,E),b.fromBufferAttribute(y,E+1),YS.distanceSqToSegment(_,b,w,x)>M)continue;w.applyMatrix4(s.matrixWorld);let C=i.ray.origin.distanceTo(w);C<i.near||C>i.far||r.push({distance:C,point:x.clone().applyMatrix4(s.matrixWorld),object:e})}}function v(y,_,b,x,w,S,T){let M=new P,E=new P,A=new P,C=new P,D=new P;if(M.fromBufferAttribute(x,w),E.fromBufferAttribute(x,S),A.fromBufferAttribute(x,T),b.intersectTriangle(M,E,A,!1,C)===null)return null;D.copy(C),D.applyMatrix4(y.matrixWorld);let R=_.ray.origin.distanceTo(D);return R<_.near||R>_.far?null:{faceIndex:1,distance:R,point:D.clone(),object:y}}}}),PB=F(()=>{ne(),dC(),cC(),Eie=new P(1,1,1),A5=new P,Aie=new P,C5=new Vt,uw=class extends Ew(M_e){constructor(e,t=15){super(t),this.object=e,this.dummy=new Tw,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){Aw(this.object,uw.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(A5,C5,Aie),this.matrix.compose(A5,C5,Eie),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}}}),CBe=F(()=>{ne(),pm=new P,fm=new P,lp=new De,P5=[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)],Cie=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Pie=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],R5=(e,t,i)=>{e.updateEntityBoxSize(pm,fm),lp.copy(t).multiply(e.matrixWorld),fm.x===0&&fm.y===0&&fm.z===0?i.push(new P(pm.x,pm.y,pm.z).applyMatrix4(lp)):P5.forEach(r=>{i.push(r.clone().multiply(fm).add(pm).applyMatrix4(lp))})},_H=class extends cn{constructor(){super(...arguments),this.matrix=new De,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new De().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];if(i===!0){let n=[];e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s))return lp.copy(t).multiply(s.matrixWorld),void n.push(new P().applyMatrix4(lp));R5(s,t,r)}}),r.length===0&&r.push(...n)}else R5(e,t,r);return this.setFromPoints(r)}getCenter(e){return(e=super.getCenter(e)).applyMatrix4(this.matrix),e}getPositionToCenter(e){return(e=super.getCenter(e)).applyMatrix4(lp.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(fm).multiplyScalar(.5),this.getCenter(pm),lp.copy(this.matrix).setPosition(pm),this.vertices=P5.map(e=>e.clone().multiply(fm).applyMatrix4(lp))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Cie.map(([e,t])=>new Eh(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Pie.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}}}),r4=F(()=>{Ef={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function jE(e){return e?.isParticleSystem===!0}function l1(e){return e?.isHairSystem===!0}function Yf(e){return e?.isShapeBlendEntity===!0}function RB(e){return e?.isPathObject===!0}function Ql(e){return e?.isObject2D===!0}function qo(e){return e?.isUIObject===!0}function Lg(e){return e?.isCloner===!0}function Bg(e){return e?.isClone===!0}function iO(e){return e?.isComponentObject===!0}var Yn=F(()=>{});function In(e){GY.add(e)}function Ta(e,t){let i=`${e}:${t}`;wH.has(i)||wH.add(i)}function n4(e,t){jY.set(e,t)}function D5(e){return jY.get(e)}function Cw(e,t){WY.set(e,t)}function N5(e){return WY.get(e)}function bH(e,t){HY.set(e,t)}function Ixe(e){return HY.get(e)}function xH(){return DB}var GY,wH,jY,WY,HY,DB,s4,vr=F(()=>{GY=new Set,wH=new Set,jY=new Map,WY=new Map,HY=new Map,DB=null,s4=null});function Oxe(e,t,i,r,n=new De){return n.compose(e,t,Lxe).multiply(i).scale(r)}var Lxe,I5,hy,NB,Pw=F(()=>{ne(),AB(),Lxe=new P(1,1,1),I5=new De,(hy||(hy={})).is=function(e){return e&&e.__isSPEObject},NB=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new De,this.copyPreviousMatrix=!0,this.pivotMatrix=new De,this.matrixWorldRigid=new De,this.shearScale=new De,this.shearScaleInv=new De,this.shearMatrix=new De}get __isSPEObject(){return!0}getPhysicsLocalMatrix(t){return!!this.rigidBody?.isDynamic()&&(t.copy(this.matrixWorld),this.hasNonUniformScale&&t.multiply(this.shearScaleInv),this.parent&&t.premultiply(I5.copy(this.parent.matrixWorld).invert()),t.multiply(I5.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(t){t instanceof ln&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrix(){!this.shearMatrix||(Oxe(this.position,this.quaternion,this.shearMatrix,this.scale,this.matrix),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&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 n of this.children)n.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)hy.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)hy.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=qbe(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new De().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this}onAfterRender(t,i,r,n,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function Rie(e,t,i){return Sg.subVectors(t,e),kA.subVectors(t,i),Sg.cross(kA).length()<=WE}function Bxe(e){let t=MH.get(e.points);if(t!==void 0&&t.isClosed===e.isClosed)return t.curve;let i=function(r){let n=r.points,s=[n[0]],a=[new P(...n[0].data.position)];jv.copy(a[0]);for(let v=0;v<n.length-1;v++)Sg.fromArray(n[v].data.position),kA.fromArray(n[v+1].data.position),Ub.subVectors(Sg,jv),zb.subVectors(Sg,kA),Ub.cross(zb).length()>WE&&(s.push(n[v]),a.push(new P().copy(Sg)),jv.copy(Sg));let o=n[n.length-1];s.push(o),a.push(new P(...o.data.position));let l=r.isClosed,h=s.length-(l?0:1),u=s.length,d=[],c=[];for(let v=0;v<u;v++){let y=s[v].data;d.push(new P(...y.controlPrevious.position)),c.push(new P(...y.controlNext.position))}let p=[];for(let v=0;v<h;v++){let y=v===u-1?0:v+1;p.push(Rie(a[v],c[v],a[y])&&Rie(a[v],d[y],a[y]))}let f=[];for(let v=0;v<u;v++){let y=s[v].data,_=a[v],b={position:_,prevDir:void 0,nextDir:void 0,controlPrevious:d[v],controlNext:c[v],tan:void 0,baseRoundness:y.roundness,removedLength:0};if(f.push(b),y.roundness===0||!l&&(v===0||v===u-1))continue;let x=l&&v==0?u-1:v-1,w=l&&v==u-1?0:v+1,S=new P().subVectors(a[x],_).normalize(),T=new P().subVectors(a[w],_).normalize();b.prevDir=S,b.nextDir=T;let M=p[l&&v===0?u-1:v-1],E=p[v];if(M&&E){Wv.addVectors(S,T).normalize();let A=jv.crossVectors(Wv,S).length()/S.dot(Wv);b.tan=A,b.removedLength=y.roundness/A}}for(let v=0;v<h;v++){let y=l&&v===u-1?0:v+1,_=f[v],b=f[y];if(_.removedLength!==0||b.removedLength!==0){let x=_.position.distanceTo(b.position);_.removedLength=Math.min(_.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let m=new Array(2*u).fill(null);for(let v=0;v<h;v++){let y=l&&v===u-1?0:v+1,_=f[v],b=f[y],x=null;if(p[v]){let w=_.position.clone(),S=b.position.clone();(_.removedLength!==0||b.removedLength!==0)&&(_.nextDir&&w.add(jv.copy(_.nextDir).setLength(_.removedLength)),b.prevDir&&S.add(jv.copy(b.prevDir).setLength(b.removedLength))),w.distanceTo(S)>WE&&(x=new OE(w,w.clone().lerp(S,.3),S.clone().lerp(w,.3),S))}else _.position.distanceTo(b.position)>WE&&(x=new OE(_.position,_.controlNext,b.controlPrevious,b.position));m[2*v+1]=x}for(let v=0;v<u;v++){let y=f[v];if(y.removedLength===0)continue;let _=y.position,b=y.prevDir.clone().multiplyScalar(y.removedLength).add(_),x=y.nextDir.clone().multiplyScalar(y.removedLength).add(_),w=y.tan*y.removedLength;Wv.addVectors(y.prevDir,y.nextDir).normalize(),Ub.copy(b).lerp(x,.5);let S=b.distanceTo(x)/2;TH.copy(Wv).multiplyScalar(Math.sqrt(Math.pow(w,2)-Math.pow(S,2))).add(Ub),rO.copy(Wv).multiplyScalar(-w).add(TH);let T=_.distanceTo(rO)/_.distanceTo(Ub);zb.copy(y.prevDir).multiplyScalar(T*_.distanceTo(b)).add(_),SH.copy(zb).lerp(rO,2);let M=b.clone().lerp(zb,4/3),E=x.clone().lerp(SH,4/3);m[2*v]=new OE(b,M,E,x)}let g=new Fxe;for(let v=0;v<m.length;v++){let y=m[v];y&&g.add(y)}return g}(e);return MH.set(e.points,{isClosed:e.isClosed,curve:i}),i}var Fxe,WE,Sg,kA,jv,Wv,Ub,rO,zb,SH,TH,MH,kb,EH,nO,Uxe,zxe,kxe,tr,_c,Die,Nie,KS,O5,B3,L5,B5,IB,AH,m1,Ec,Vxe=F(()=>{ne(),Fxe=class extends pW{constructor(){super()}getPoints(e=12){let t,i=[],r=this.getCurveLengths(),n=r[r.length-1]/r.length;for(let s=0,a=this.curves;s<a.length;s++){let o=a[s],l=s===0?r[s]:r[s]-r[s-1],h=Math.ceil(e*l/n),u=o.getPoints(h);for(let d=0;d<u.length;d++){let c=u[d];t&&t.equals(c)||(i.push(c),t=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},WE=.001,Sg=new P,kA=new P,jv=new P,Wv=new P,Ub=new P,rO=new P,zb=new P,SH=new P,TH=new P,MH=new WeakMap}),PBe=F(()=>{ne(),kb=new De,EH=new Vt,nO=new Vt,Uxe=new Rr,zxe=new P,kxe=new P(0,1,0)}),bl=F(()=>{ne(),Ot(),CBe(),Ir(),r4(),Yn(),vr(),Pw(),Vxe(),PBe(),Vr(),(tr||(tr={})).is=function(e){return e&&e.__isEntity},_c=e=>tr.is(e),Die={type:"completeState",isfromEntity:!0},Nie=["x","y","z"],KS=new P,O5=new P(1,1,1),B3=new Vt,L5=new Rr,B5=new De,IB=e=>class extends NB(e){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 _H,this._recursiveBBox=new _H,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(tr.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(tr.is(this.children[t]))return t+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 t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(!tr.is(i))return;t=i}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(this.data.states.length!==0||r){for(let n of this.data.states)Og.toOps(this.data,n.data).forEach(s=>{let a=IL.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let n=this.data.states.data(t);n&&(this.dataPatched=Og.patch(this.data,n),Og.toOps(this.data,n).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,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(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{_c(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(tr.is(i[r]))return i[r];if(tr.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&tr.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)_c(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{tr.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)_c(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)_c(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)_c(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this}hasEntityChild(){return this.children.some(t=>_c(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){return this.updateWorldMatrix(!0,!1),BW({position:this.position.toArray(),rotation:[this.rotation.x*Qe.RAD2DEG,this.rotation.y*Qe.RAD2DEG,this.rotation.z*Qe.RAD2DEG],scale:this.scale.toArray(),shear:Ph.fromMatrix(this.shearMatrix.toArray()),pivot:[0,0,0],pivotRotation:[0,0,0]},t)}getTransformValues(t,i,r){return i[t].map((n,s)=>r?.shared.getVariable(n,[this.uuid,t,Nie[s]])??n)}updateTransformState(t,i){let r=!1;if(t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(KS.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Qe.DEG2RAD),this.rotation.setFromVector3(KS),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.shear&&(this.shearMatrix.fromArray(Ph.toMatrix(t.shear)),r=!0),t.pivot!==void 0||t.pivotRotation!==void 0){if(r=!0,t.pivot!==void 0&&t.pivotRotation!==void 0)this.pivotMatrix.compose(KS.fromArray(t.pivot).negate(),B3.setFromEuler(L5.fromArray(t.pivotRotation.map(n=>n*Qe.DEG2RAD))).invert(),O5);else if(t.pivot!==void 0)this.pivotMatrix.setPosition(-t.pivot[0],-t.pivot[1],-t.pivot[2]);else if(t.pivotRotation!==void 0){let n=KS.setFromMatrixPosition(this.pivotMatrix);B3.setFromEuler(L5.fromArray(t.pivotRotation.map(s=>s*Qe.DEG2RAD))).invert(),this.pivotMatrix.compose(n,B3,O5)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){t?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 t of this.children)tr.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{tr.is(t)&&t.disposeRecursively()})}toState(t=[]){return BW({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)},t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,n){let s=this.data;this.data=i;let a=t,o=Zr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let d=Sa.zoom(u,t.path.slice(2));if(d)for(let c in t.props)t.props[c]===void 0&&c in d&&(h[c]=d[c])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:u,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:u,...d}=l;l=d}let h=Sa.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Og.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Zr(t.path,["overrides"])){let l=[],h=[...t.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(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[u],d.updateState(Gg.apply(d.component.data,d.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let d=Sa.zoom(u.component.data,h);if((t={...t,path:h}).type===0){let c=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(c===t.props&&(c={...t.props}),c[p]=d[p]);t={...t,props:c}}u.overrideData=JL.resolve(i.overrides,l),u.updateByOp(t,Ha.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Sf.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Sf.rootOverrideProps)if(Zr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=Gg.filterOp(h.overrideData,l);u&&h.updateByOp(u,Ha.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=Gg.filterOp(h.overrideData,t);if(u){let d;d=s===h.data&&t===u?i:Ha.applySimple(h.data,u),h.updateByOp(u,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!a1.is(t.props.type)&&Ef.changeEntityProptotype(this,this.data,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Ef.changeEntityProptotype(this,this.data,r);for(let n of this.children)tr.is(n)&&n.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let n=i.morphTargetInfluences.get(t.path[1])?.data.name;n&&this.updateMorphInfluences(n,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",n]))}if(Zr(t.path,["pathSnapping"])!==null&&(this.updatePathSnapping(i.pathSnapping),this.isVirtualEntity&&r.scene?.syncInstancePathConstraint(this)),Zr(t.path,["cloner"])!==null){let n=Ha.drop(t,1);n.path.length===0&&n.type===0&&n.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(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,n=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(this.isVirtualEntity&&t.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=Bxe(o.geometry.path),h=function(p){let f=p%1;return f<0?f+1:f===0&&p>0?1:f}(r+n),u=null;try{u=l.curves.length?l.getPointAt(h):null}catch{}if(u===null)return;a.updateMatrixWorld();let d=this.parent?B5.copy(this.parent.matrixWorld):B5.identity(),c=function(p,f,m,g){EH.setFromRotationMatrix(kb.extractRotation(g));let v=p.clone().applyMatrix4(kb.copy(g).invert().multiply(m));if(f===null)nO.setFromRotationMatrix(kb.extractRotation(m));else{let y=f.clone().applyMatrix4(kb.extractRotation(m));nO.setFromRotationMatrix(kb.lookAt(zxe.set(0,0,0),y,kxe))}return{position:v,rotation:new P().setFromEuler(Uxe.setFromQuaternion(EH.invert().multiply(nO))).multiplyScalar(Qe.RAD2DEG)}}(u,s==="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(Die)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>Lg(t)&&t.parameters.type==="toObject")}setFromClonerState(t,i){if(!this.disposed)if(t===null||t.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Ef.Cloner===null)return void Ta("cloners","a cloner");this.cloner=new Ef.Cloner(this,t),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(t,i)}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),g1=F(()=>{ne(),bl(),(AH||(AH={})).is=e=>"objectHelper"in e,m1=(e,t)=>class extends IB(e){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof DA&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Dh?(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 DA&&(r.visible=!1)}}}}),OB=F(()=>{ne(),PB(),g1(),Ec=class extends m1(Tw,uw){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&Object.keys(e).length===1&&t.scene.reloadSplats()}}});function Ru(e,t,i,r,n,s,a){YM.set(n,s,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],YM.x,YM.y,YM.z)}}var YM,nh,Iie,Gxe,RBe=F(()=>{ne(),dC(),cC(),YM=new P,nh=new Pg,Iie=class extends Nb{constructor(e){let t=new Mt,i=new ad({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],s={},a=new at(15711266),o=new at(15711266),l=new at(2857471);function h(d,c,p){u(d,p),u(c,p)}function u(d,c){r.push(0,0,0),n.push(c.r,c.g,c.b),s[d]===void 0&&(s[d]=[]),s[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),t.setAttribute("position",new Tt(r,3)),t.setAttribute("color",new Tt(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap;nh.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;Ru("n1",t,e,nh,-1,-1,i),Ru("n2",t,e,nh,1,-1,i),Ru("n3",t,e,nh,-1,1,i),Ru("n4",t,e,nh,1,1,i);let r=i;Ru("f1",t,e,nh,-1,-1,r),Ru("f2",t,e,nh,1,-1,r),Ru("f3",t,e,nh,-1,1,r),Ru("f4",t,e,nh,1,1,r);let n=r;Ru("u1",t,e,nh,.35,1.1,n),Ru("u2",t,e,nh,-.35,1.1,n),Ru("u3",t,e,nh,0,1.55,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},Gxe=class extends Ew(Iie){constructor(e){super(e),this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Aw(this.object,this.geometry,e,t,!0)}}});function Oie(e){return 1-Math.pow(1-e,3)}var F0,F3,U3,z3,t_,k3,Wd,Kn,Nh=F(()=>{ne(),RBe(),Ot(),g1(),Vr(),F0=new P,F3=new P,U3=new Vt,z3=new P,t_=new P,k3=new P,Wd=class extends m1(Pg,Gxe){constructor(e="",t={...kE.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=wf.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let n=this._projectionTransition;if(n===void 0)return;if(this.disposed)return void this._endProjectionTransition();n.raf=requestAnimationFrame(this._tickProjectionTransition);let s=Wd.projectionTransitionRequestRender??n.requestRender;this.updateProjectionMatrix(),s?.()},this.super_Entity(e,t),this.previousProjectionMatrix=new De,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Qg(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new bh(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(e){let t=Wd.projectionTransitionsEnabled;Wd.projectionTransitionsEnabled=!1;try{return e()}finally{Wd.projectionTransitionsEnabled=t}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){typeof e=="number"&&(e=new P(e,t,i)),super.lookAt(e),this.getWorldPosition(F0),this.targetOffset=F0.distanceTo(e)}getTarget(e=new P){return this.getWorldDirection(F3),this.getWorldPosition(F0),F3.multiplyScalar(this.targetOffset),e.copy(F0).add(F3),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(F0),F0.distanceTo(e)}updateUp(){this.getWorldQuaternion(U3),z3.set(0,0,1).applyQuaternion(U3),t_.copy(ln.DEFAULT_UP),this.isUpVectorFlipped&&t_.negate(),t_.applyQuaternion(U3),k3.copy(ln.DEFAULT_UP).projectOnPlane(z3),this.angleOffsetFromUp=k3.angleTo(t_),this.angleOffsetFromUp*=k3.cross(t_).dot(z3)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new P),i=e.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new P;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let r=e>t?this.aspect:1,n=e>t?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/n*395,this.bottom=1/n*-395}else this.left=.5*-e,this.right=.5*e,this.top=.5*t,this.bottom=.5*-t;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.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 e=this._projectionTransition;if(e===void 0)return 1;let t=(performance.now()-e.start)/e.duration;return t>=1?1:t<=0?0:Oie(t)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Wd.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Wd.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let t=this._projectionTransition;t===void 0&&(t={from:new De,blend:new De,blendInverse:new De,start:0,duration:Wd.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=t),t.from.copy(this.projectionMatrix),t.start=performance.now(),t.duration=Wd.projectionTransitionDuration,t.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(t.requestRender=e),t.raf!==0&&cancelAnimationFrame(t.raf),t.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let t=(performance.now()-e.start)/e.duration;if(t>=1)return void this._endProjectionTransition();let i=Oie(t),r=e.from.elements,n=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,a=e.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,n[15]-n[11]*a));for(let h=0;h<16;h++)s[h]=r[h]+(n[h]-r[h])*l;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let t=this._activeSubCamera;this.projectionMatrix=t.projectionMatrix,this.projectionMatrixInverse=t.projectionMatrixInverse}_syncProjectionTransition(e){let t=e._projectionTransition;if(t===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new De,blend:new De,blendInverse:new De,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(t.from),i.start=t.start,i.duration=t.duration,i.referenceDepth=t.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,i,r,n,s):this.orthoCamera.setViewOffset(e,t,i,r,n,s),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(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=wf.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){return BW({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},e)}updateCameraSubtype(e,t){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(i,t.zoom),t.near!==void 0&&this.setNear(i,t.near),t.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(t?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(i=>typeof i=="number"?i:0)),e.targetOffset!==void 0&&(this.targetOffset=wf.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},(Kn=Wd).projectionTransitionsEnabled=!1,Kn.projectionTransitionDuration=350,Kn.projectionTransitionMinAgeMs=1e3});function jxe(e){return e.type==="TorusGeometry"&&e.arc===360}var Wxe,V3,CH,VA=F(()=>{ne(),Wxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??r),s=Math.abs(i.depth??r),a=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:n,depth:s,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:n,revolutions:s,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:d}=e.parameters,c=new CH(!1,t,i,r,n,s,a,o,l,h,u,d);return Object.assign(c,{userData:{...e,type:"HelixGeometry"}})}},V3=new Gf([0,0,0],1),CH=class extends Mt{constructor(e=!0,t=1,i=1,r=1,n=1,s=1,a=1,o=1,l=1,h=1,u=1,d=1){if(super(),s===0)return;let c=e&&s===1;c&&(d=0),u>100&&(u=100),u===0&&(d=0);let p,f,m,g,v,y,_,b,x=()=>new P,w=new P,S=x(),T=x(),M=x(),E=x(),A=x(),C=x(),D=x(),R=x(),I=x(),U=x(),O=x(),k=i-2*o+.001,G=k/s,K=Math.ceil(a*s),q=K+1,Y=k/K,ue=-k/2,de=h+1,ge=2*Math.PI/h,be=Math.PI/2/d,re=Math.min((1-u/100)*o,o-.01),xe=o-re,j=0,z=2*d+2,X=de*z/2,te=X+de*q,V=Math.max(0,de*(q+z)),[ae,se,W]=[3,3,2].map(dt=>Array(V*dt).fill(0)),pe=[],_e=n-o;function Ue(dt,et){let $t=Math.PI/2;y=et*Y,b=2*Math.PI*(y%G)/G+$t,y+=ue,_=Math.sin(b)*_e,v=Math.cos(b)*_e,e?dt.set(v,_,y):dt.set(v,y,_)}Ue(w,-1e-10),Ue(S,0),E.copy(w),Ue(w,1);let we=w.distanceTo(S),Ye=c?0:xe+re,Fe=we*K+2*Ye,We=re,Re=Fe-Ye;for(let dt=0;dt<=K;dt++){Ue(T,dt),O.subVectors(T,E).normalize(),E.copy(T),I.copy(T).setComponent(+e+1,0).normalize(),U.crossVectors(O,I).normalize();let et=dt===0,$t=dt===K,ii=et?3*Math.PI/2:be,nr=et?We:Re,xt=et?de:te,Dt=et?0:V-de,Kt=O.clone().multiplyScalar(et?-xe:xe).add(T),Mi=O.clone().multiplyScalar(et?-1:1).normalize();for(let _i=0;_i<de;_i++){let ci=_i*ge;if(A.addVectors(w.copy(I).multiplyScalar(o*Math.cos(ci)),S.copy(U).multiplyScalar(o*Math.sin(ci))),C.copy(A).normalize(),et||$t){c||(j=Dt+_i,[0,1,2].forEach(Ei=>{ae[3*j+Ei]=Kt.getComponent(Ei),se[3*j+Ei]=Mi.getComponent(Ei)}),W[2*j]=+$t,W[2*j+1]=_i/h),S.copy(C).multiplyScalar(re),M.addVectors(T,S);for(let Ei=0;Ei<d;Ei++){let Or=Ei*be+ii;D.addVectors(w.copy(O).multiplyScalar(xe*Math.sin(Or)),S.copy(C).multiplyScalar(xe*Math.cos(Or))),R.copy(D).normalize(),S.addVectors(M,D),D.normalize(),j=xt+Ei*de+_i,[0,1,2].forEach(Ji=>{ae[3*j+Ji]=S.getComponent(Ji),se[3*j+Ji]=R.getComponent(Ji)});let Wr=+et+Math.sin(Or);W[2*j]=(nr+xe*Wr)/Fe,W[2*j+1]=_i/h}}S.addVectors(T,A),j=X+dt*de+_i,[0,1,2].forEach(Ei=>{ae[3*j+Ei]=S.getComponent(Ei),se[3*j+Ei]=C.getComponent(Ei)}),W[2*j]=(Ye+dt*we)/Fe,W[2*j+1]=_i/h}}let ee=q+2*d+2,[Ee,je]=[+c,ee-1];for(let dt=Ee;dt<=je-1;dt++){let et=c&&dt===je-1;for(let $t=0;$t<de-1;$t++)p=dt*de+$t,f=p+1,m=(et?$t:p)+de,g=(et?$t+1:f)+de,dt===0?pe.push(f,g,m):dt===ee-2?pe.push(p,f,m):pe.push(p,f,m,f,g,m)}this.setIndex(pe),this.setAttribute("position",new Tt(ae,3)),this.setAttribute("normal",new Tt(se,3)),this.setAttribute("uv",new Tt(W,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e,t,i,r,n=this.userData.parameters,s=Math.ceil(n.tubularSegments),a=n.radialSegments,o=a+1,l=[];for(let h=1;h<s;h++)for(let u=0;u<a;u++)e=h*o+u,t=e+1,i=e+o,r=t+o,l.push(e,t,i,t,r,i);for(let h=0;h<a;h++)e=s*o+h,t=e+1,i=h+o,r=h+1+o,l.push(e,t,i,t,r,i);return V3.array=new Uint32Array(l),V3.count=l.length,V3}}});function DBe(e){return Bie||(Bie=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.204/build",i=import("./boolean.js"),[r,n]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),GA=r}())}function a4(){if(GA===void 0)throw new Error("boolean-wasm is not loaded");return GA}function qY(e){let t=jA.get(e);if(t===void 0)throw new Error("Unknown csg mesh set handle "+e);return t}function $Y(e){return jA.set(++PH,e),PH}function NBe(e,t,i){if(GA===void 0)return-1;let{positions:r,indices:n,normals:s}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,f=[];for(let m=0,g=0;m<p.verticesPerFace.length;m++){let v=p.verticesPerFace[m];for(let y=1;y<v-1;y++)f.push(p.indices[g],p.indices[g+y],p.indices[g+y+1]);g+=v}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(f)}}let l;l=jxe(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}}(e,t);return $Y(new GA.CsgMesh(r,n,s))}function Lie(e,t){let i=a4(),r=qxe[t];if(r===void 0)throw new Error("Unknown boolean operation "+t);let n=e.map(qY);if(n.length===1)return i.clone_mesh(n[0]);let s,a=[];if(t===2&&n.length>2){let o=n[0];for(let l=1;l<n.length-1;l++)o=i.boolean_mesh(o,n[l],0),a.push(o);s=i.boolean_mesh(n[n.length-1],o,2)}else if(t===2)s=i.boolean_mesh(n[1],n[0],2);else{let o=n[n.length-1];for(let l=0;l<n.length-1&&(o=i.boolean_mesh(o,n[l],r),a.push(o),o.tri_count()!==0);l++);s=o,a.pop()}for(let o of a)o.free();return s}function F5(e,t){qY(e).transform(new Float32Array(t.elements))}function Hxe(e){let t=jA.get(e);t!==void 0&&(t.free(),jA.delete(e))}var GA,jA,PH,Bie,qxe,LB=F(()=>{ne(),VA(),jA=new Map,PH=0,qxe={0:0,1:1,2:2}});function U0(e){return e!==null&&"booleanOp"in e}var RH,$xe,IBe=F(()=>{ne(),bl(),LB(),RH=class extends IB(Sr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new De}updateVisible(e){super.updateVisible(e),this.visible=!U0(this.parent)&&this.visible,U0(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){U0(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hxe(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}dispose(){super.dispose(),this.freeBooleanPointer()}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),U0(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof RH&&(e.freeBooleanPointer(),U0(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&U0(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),U0(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),OBe=F(()=>{$xe=null});function XY(e,t=0,i=e.count,r,n){let s=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let d=t;d<i;d++){let c=e.getX(d),p=e.getY(d),f=e.getZ(d);c<s&&(s=c),p<a&&(a=p),f<o&&(o=f),c>l&&(l=c),p>h&&(h=p),f>u&&(u=f)}KM.min.set(s,a,o),KM.max.set(l,h,u),KM.getCenter(r),KM.getSize(n).multiplyScalar(.5)}var KM,Fie,Uie,Fs,Da=F(()=>{ne(),IBe(),OBe(),KM=new cn,Fie=new Mt,Uie=new Zl,Fs=class extends RH{constructor(e,t){super(Fie,Uie),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}raycast(e,t){if(this.raycastDeformed(e,t))return;let i=$xe;i===null?super.raycast(e,t):i(this,e,t)}raycastDeformed(e,t){return!1}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?XY(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}}});function Xxe(e){return e?.isClassicNodeMaterial===!0}var Ur,WA,Yxe,Kxe,HE,Zxe,Qxe,Jxe,ewe=F(()=>{}),xu=F(()=>{ne(),Ur=class extends at{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t)}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}}}),twe=F(()=>{xu(),WA=class extends Ur{}}),LBe=F(()=>{Yxe=class{constructor(e=1e4){this.timeout=e,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(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.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 e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let i=t;t=t.next,t.prev=this.head,this.head.next=t,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(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,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((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),iwe=F(()=>{LBe(),Kxe=class extends Yxe{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}}}),rwe=F(()=>{Zxe=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Qxe=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}}}),BBe=F(()=>{ne(),Jxe=class extends m_e{constructor(e){super(e),this.type=li}parse(e){let t=function(p,f){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(p,f,m){f=f||1024;let g=p.pos,v=-1,y=0,_="",b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(v=b.indexOf(`
|
|
4206
|
+
})();`});function M3(e){return e==null||e===""?void 0:String(e)}var gY,tbe=F(()=>{gY=class{constructor(e,t,i){this.deps=e,this.onConsole=t,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let e of this.eventUnsubs.values())e();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(e,t){let i=this.deps;switch(e){case"setVariable":{let r=i.setVariable(String(t[0]),t[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=t[0]??{},n=!0;for(let[s,a]of Object.entries(r)){let o=i.setVariable(s,a);o.warning&&this.onConsole("warn",o.warning),n=n&&o.ok}return n}case"getVariable":return i.getVariable(String(t[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(t[0]));case"getGeometry":{let r=i.getGeometry(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(t[0]),t[1]??{});case"createObject":return i.createObject(String(t[0]),t[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(t[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(t[0]),t[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(t[0]),t[1]);case"cloneObject":return i.cloneObject(String(t[0]),t[1]??{});case"removeObject":return i.removeObject(String(t[0]));case"spawnObject":{let r=i.spawnObject(String(t[0]),t[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(t[0]));case"setInstanceTransforms":{let r=t[1]===null||t[1]===void 0?null:t[1],n=i.setInstanceTransforms(String(t[0]),r);return n<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(t[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),n}case"getAnimations":{let r=i.getAnimations(M3(t[0]));return r.warning&&this.onConsole("warn",`spline.${e}: ${r.warning}`),r.clips}case"playAnimation":{let r=typeof t[1]=="object"&&t[1]!==null,n=i.playAnimation(String(t[0]),r?void 0:M3(t[1]),(r?t[1]:t[2])??{});return n.warning&&this.onConsole("warn",`spline.${e}: ${n.warning}`),n.clip}case"pauseAnimation":case"stopAnimation":{let r=M3(t[0]),n=M3(t[1]),s=e==="pauseAnimation"?i.pauseAnimation(r,n):i.stopAnimation(r,n);return s.warning&&this.onConsole("warn",`spline.${e}: ${s.warning}`),s.ok}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(t[0]),String(t[1]),e==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(t[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,n=>{this.onEvent(r,n)})),!0}case"unlistenEvent":{let r=String(t[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${e}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let e=this.deps.getVariables(),t=function(i,r){let n=[];for(let s of Object.keys(r))i[s]!==r[s]&&n.push({name:s,value:r[s]});return n}(this.lastVariables??{},e);this.lastVariables=e;for(let i of t)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function A4e(e,t,i,r){return[e[0]*t+e[4]*i+e[8]*r+e[12],e[1]*t+e[5]*i+e[9]*r+e[13],e[2]*t+e[6]*i+e[10]*r+e[14]]}var C4e=F(()=>{}),ibe,P4e=F(()=>{}),R4e=F(()=>{mY(),tbe(),ibe=class{constructor(e,t,i){this.iframe=e,this.deps=t,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 n=r.data;var s;typeof(s=n)!="object"||s===null||s[fg]!==!0||typeof s.kind!="string"||this.handleMessage(n)},this.host=new gY(t,i,(r,n)=>{this.sendEvent(r,n)})}attach(){window.addEventListener("message",this.onMessage),this.send({[fg]:!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(e){switch(e.kind){case"ready":this.handshakeSeen=!0,this.send({[fg]:!0,kind:"ready-ack"});break;case"console":this.onConsole(e.level,e.text);break;case"call":{let t;try{t=Promise.resolve(this.host.execute(e.method,e.args))}catch(i){t=Promise.reject(i)}t.then(i=>{this.send({[fg]:!0,kind:"result",id:e.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[fg]:!0,kind:"result",id:e.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(e.event)}}send(e){this.iframe.contentWindow?.postMessage(e,"*")}sendEvent(e,t){this.send({[fg]:!0,kind:"event",eventName:e,payload:t})}dispatchInput(e){let t=this.deps.getCanvas();if(!t)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey};switch(e.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":t.dispatchEvent(new PointerEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons,pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,movementX:e.movementX,movementY:e.movementY}));break;case"click":case"dblclick":t.dispatchEvent(new MouseEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons}));break;case"wheel":{let n=new WheelEvent("wheel",{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode});typeof e.wheelDeltaX=="number"&&Object.defineProperty(n,"wheelDeltaX",{value:e.wheelDeltaX}),typeof e.wheelDeltaY=="number"&&Object.defineProperty(n,"wheelDeltaY",{value:e.wheelDeltaY}),t.dispatchEvent(n);break}case"keydown":case"keyup":t.dispatchEvent(new KeyboardEvent(e.type,{...r,key:e.key,code:e.code,repeat:e.repeat}))}}}}),Vr=F(()=>{fY(),c4e(),p4e(),f4e(),g4e(),v4e(),y4e(),_4e(),b4e(),x4e(),w4e(),M4e(),mY(),E4e(),tbe(),C4e(),P4e(),R4e()}),D4e=F(()=>{});function rbe(e){return Array.isArray(e)?e:[e]}function DL(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var N4e=F(()=>{});function Go(e,t){return Object.setPrototypeOf(e,t),e}function HU(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Rg(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],n=1/(i+1);for(let s=0;s<i;s++){let a=e+(t-e)*(s+.75+.5*Math.random())*n;r.push(a)}return r}function s1(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}var I4e=F(()=>{});function vY(e){if(e.deepFreeze!==void 0)return void e.deepFreeze(e);let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&vY(r)}return Object.freeze(e)}function nbe(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}var qU,NL,FW,ri,yY,O4e=F(()=>{}),la=F(()=>{D4e(),N4e(),I4e(),O4e()}),_Y=F(()=>{qU=class{},NL=class extends qU{constructor(e){super(),this.id=e}},FW=class extends qU{constructor(e){super(),this.data=e}}}),L4e=F(()=>{}),xB=F(()=>{ri=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,ri.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i,r=t[e.id];i=r===void 0?{type:2,id:e.id}:{type:1,id:e.id,data:r};let{id:n,data:s}=e,a={...t,[n]:s};return Object.setPrototypeOf(a,ri.prototype),{data:a,actual:e,reverse:i}}if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let n={...t};return Object.setPrototypeOf(n,ri.prototype),delete n[i],{data:n,actual:e,reverse:{type:1,id:i,data:r}}}}return null}}}),bY=F(()=>{yY=class extends Error{}});function sbe(e,t){for(let i of e)t(i.id,i.data)!==!0&&sbe(i.children,t)}function abe(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)abe(i,t)}var Ea,E3,ow,Et,c1=F(()=>{la(),bY(),la(),Ea=class extends Array{constructor(...e){super(...e),Oc(this,"partialObjectCaches"),Oc(this,"objCaches"),Oc(this,"parentCaches"),Object.setPrototypeOf(this,Ea.prototype)}deepFreeze(){let e=0;for(;e<this.length;)vY(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(!t)return e;e=t}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}partialCache(e){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let t=this.get(e);t!==void 0&&this.partialObjectCaches.set(e,t)}get(e){if(this.partialObjectCaches!==void 0){let t=this.partialObjectCaches.get(e);if(t!==void 0)return t}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&abe(i,t)}}traverse(e){sbe(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),n=r.findIndex(o=>o.id===e);if(n<0)throw new Error("not expected");let s=r[n];r=[...r],r[n]={...s,data:t};let a=new Map;return a.set(e,r[n]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(e,t,i=void 0){let r=e,n=t;for(;r!==null;){let a=n,o=r;if(r=this.parent(r),r===void 0)throw new Error;n=this.childrenArray(r);let l=n.findIndex(h=>h.id===o);if(l<0)throw new Error;n=[...n],n[l]={...n[l],children:a},i&&i.set(o,n[l])}Object.setPrototypeOf(n,Ea.prototype);let s=n;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[a,o]of i)s.objCaches.set(a,o);s.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else s.fillCaches();return s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:n,children:s};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),n=r.findIndex(a=>a.id===t);e.localIndex=n,r=[...r];let s=r.splice(n,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new yY("cyclic tree");d=this.parent(d)}}let n=this.parent(r);if(n===void 0)return null;let s=n,a=this.childrenArray(n),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(n,a);n=t,a=h.childrenArray(n);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(n,a),{data:h,actual:e,reverse:{type:9,parent:s,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(n=>n.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>DL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getAllIdSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i);r!==void 0&&t.push(r)}t.sort((i,r)=>DL(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t.map(i=>i.id)}getWithSortKey(e){let t=e,i=[],r=this.get(t),n=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...n,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Rg(0,i,i);{let n=r[0].fi;return Rg(n-i,n,i)}}{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(a=>a.fi>n.fi);if(s===void 0){let a=r[r.length-1].fi;return Rg(a,a+i,i)}return Rg(n.fi,s.fi,i)}}}}),xY=F(()=>{var e;la(),E3=null,(e=ow||(ow={})).setPreservePrototype=function(t){E3=t},e.tryPreservePrototype=function(t,i){return Object.getPrototypeOf(t)===E3&&Object.setPrototypeOf(i,E3),i},e.runOp=function(t,i){if(i.type!==0)return null;if(Array.isArray(t)||s1(t)){let r=i.props,n={},s=s1(t)?t.slice():[...t],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");n[o]=s[l],s[l]=r[o],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:n}}:null}{let r=i.props,n={},s={...t},a=!1;if(r)for(let o of Object.keys(r)){n[o]=s[o];let l=r[o];l===void 0?delete s[o]:s[o]=l,a=!0}return a?{data:e.tryPreservePrototype(t,s),actual:i,reverse:{type:0,props:n}}:null}}}),p1=F(()=>{la(),la(),Et=class extends Array{constructor(...e){super(...e),Oc(this,"objCaches"),Object.setPrototypeOf(this,Et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)vY(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let n=i[r];return i=[...i],i[r]={...n,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Et.prototype);let t=e;return typeof process<"u"||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,n=this,s={fi:t,id:i,data:r};return n=[...n,s],n.sort((a,o)=>a.fi-o.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let n=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...n}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let n=r.findIndex(o=>o.id===i);if(n===-1)return null;let s=r[n].fi,a={...r[n],fi:t};return r[n]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Rg(0,t,t);{let r=i[0].fi;return Rg(r-t,r,t)}}{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let n=i.find(s=>s.fi>r.fi);if(n===void 0){let s=i[i.length-1].fi;return Rg(s,s+t,t)}return Rg(r.fi,n.fi,t)}}}});function B4e(e,t){let i={cur:[],result:[],len:0};return[e=Cx(e,t,i)??e,i.result]}function $I(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function XI(e){e&&(e.len-=1)}function obe(e,t,i){let r=!1,n=e.map(s=>{let a=s.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Cx(s.data,t,$I(i,a));XI(i),r=r||l!==void 0,l===void 0&&(l=s.data);let h=obe(s.children,t,i);return h!==void 0?r=!0:h=s.children,{...s,id:a,data:l,children:h}});if(r)return n}function Cx(e,t,i){if(e instanceof Ea){let r=obe(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}if(e instanceof Et)return function(r,n,s){let a=!1,o=r.map(l=>{let h=l.id,u=n[h];if(u!==void 0&&typeof u=="string"&&(a=!0,h=u,s!==null))throw new Error("not supported");let d=Cx(l.data,n,$I(s,h));return XI(s),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}(e,t,i);if(Array.isArray(e)){let r=!1,n=e.map((s,a)=>{let o=Cx(s,t,$I(i,a));return XI(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(e)),n):void 0}if(e&&typeof e=="object"&&!s1(e)){let r={},n=!1;for(let[s,a]of Object.entries(e))if(s!=="name"&&s!=="variableId"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");n=!0,s=o}let l=Cx(a,t,$I(i,s));XI(i),n=n||l!==void 0,l===void 0&&(l=a),r[s]=l}else r[s]=a;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(typeof e=="string"){let r=t[e];return r!==void 0&&function(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}(i),r}}var lbe=F(()=>{c1(),p1(),la()});function Px(e){return e&&typeof e=="object"&&e instanceof Ts}function wY(e,t){if(t===void 0)return;let i=!1,r=e.map(n=>{let s=n.id,a=UE(n.data,t[s]);if(i=i||a!==void 0,a===void 0&&(a=n.data),n.children){let o=wY(n.children,t);return o!==void 0?i=!0:o=n.children,{...n,id:s,data:a,children:o}}return{...n,id:s,data:a}});return i?r:void 0}function UE(e,t){if(!Px(t))return t;if(e instanceof Ea){let i=wY(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}if(e instanceof Et)return function(i,r){if(r===void 0)return;let n=!1,s=i.map(a=>{let o=a.id,l=UE(a.data,r[o]);return n=n||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return n?(Object.setPrototypeOf(s,Object.getPrototypeOf(i)),s):void 0}(e,t);if(Array.isArray(e)){let i=!1,r=e.map((n,s)=>{let a=UE(n,t[s]);return i=i||a!==void 0,a===void 0&&(a=n),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(e instanceof Ts)return SY(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[n,s]of Object.entries(e)){let a=UE(s,t[n]);r=r||a!==void 0,a===void 0&&(a=s),i[n]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}function SY(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Px(t))return t;if(!Px(e))return Gg.apply(e,t);let i=new Set;for(let n of Object.keys(e))i.add(n);for(let n of Object.keys(t))i.add(n);let r=new Ts;for(let n of i){let s=SY(e===void 0?void 0:e[n],t===void 0?void 0:t[n]);r[n]=s}return r}var Ts,Gg,IL,Ha,Fee,wB=F(()=>{var e;c1(),p1(),SB(),la(),Ts=class{unusedFunOverridesTable(t){}runOp(t){let i=[],r=this,n=0,s={};for(;n<t.path.length;){if(i.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!Px(r))return null;n+=1}r=r?HU(r):new Ts;for(let[a,o]of Object.entries(t.props)){let l=r[a];s[a]=l,o===void 0?delete r[a]:r[a]=o}for(;n>0;){if(Object.keys(r).length===0){let a=i[n-1];a&&(r=HU(a),delete r[t.path[n-1]])}else{let a=i[n-1];if(a){let o=HU(a);o[t.path[n-1]]=r,r=o}else{let o=new Ts;o[t.path[n-1]]=r,r=o}}n-=1}return{data:Object.setPrototypeOf(r,Ts.prototype),actual:t,reverse:{...t,props:s}}}},(e=Gg||(Gg={})).apply=function(t,i){return UE(t,i)??t},e.merge=function(t,i){return SY(t,i)},e.filterOp=function(t,i){let r=0,n=i.path,s=t;for(;r<n.length&&s!==void 0;){if(s=Sa.zoomOnce(s,n[r]),s===void 0)return i;if(!Px(s))return;r+=1}if(s===void 0)return i;if(Px(s)){if(i.type===0){let a={...i.props};for(let o of Object.keys(s))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=wY([i],s);return a?a[0]:i}return i}}}),F4e=F(()=>{la(),SB(),xB(),c1(),bY(),xY(),p1(),lbe(),wB(),(IL||(IL={})).replaceProps=function(e,t){let i=Sa.zoom(t,e.path);if(typeof i=="object"){let r={};for(let n of Object.keys(e.props))r[n]=i[n];return{...e,props:r}}return{...e,props:{}}},(e=>{function t(n,s){let a=s.path,o=[];for(;;){let l;if(n instanceof Ts&&s.type===0&&(l=n.runOp({...s,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=n instanceof Ea||n instanceof Et||n instanceof ri?n.runOp(s):ow.runOp(n,s)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],f=o[c];if(f instanceof Ea){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof Et){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof ri){if(typeof p=="number")throw new Error("illegal arg");d=f.modifyById(p,d)}else if(f instanceof Ts){let m={...f,[p]:d};d=Object.setPrototypeOf(m,Ts.prototype)}else{if(typeof f!="object")return null;if(Array.isArray(f)||s1(f)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let m=d;d=s1(f)?f.slice():[...f],d[p]=m}else d=ow.tryPreservePrototype(f,{...f,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let h,u=a[o.length];if(n instanceof Ea){if(typeof u=="number")throw new Error("");h=n.get(u)?.data}else if(n instanceof Et){if(typeof u=="number")throw new Error("");h=n.get(u)?.data}else n!==null&&(h=n[u]);if(h===void 0)return null;o.push(n),n=h}}function i(n,s){for(let a=0;a<n.length&&a<s.length;a++)if(n[a]!==s[a])return!0;return!1}function r(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;a++)if(n[a]!==s[a])return!1;return!0}e.drop=function(n,s){return{...n,path:n.path.slice(s)}},e.applySimple=function(n,s){return t(n,s)?.data??n},e.apply=t,e.pathDisjoint=i,e.pathEq=r,e.commutative=function(n,s){return i(n.path,s.path)},e.subsumed=function(n,s){return!(n.type!==0||s.type!==0||!r(n.path,s.path))&&Object.keys(n.props).every(a=>s.props[a]!==void 0)}})(Ha||(Ha={})),(e=>{function t(i,r){let n=i,s=[],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=Sa.zoom(n,[...o.path,o.id]),h=Ha.apply(n,{...o,type:2})):(l=Sa.zoom(n,[...o.path,o.id,"value"]),h=Ha.apply(n,o)),h!==null){n=h.data;let[u,d]=B4e(n,{[o.id]:l});n=u;for(let c=0;c<d.length;c++){let p,f,m=d[c],g=m.pop();if(typeof g=="number"){let v=[g];for(let _=c+1;_<d.length;_++){let b=d[_],x=b[b.length-1];if(typeof x!="number"||!Sa.equal(m,b.slice(0,b.length-1)))break;v.push(x),d.splice(_,1)}let y=Sa.zoom(n,m);f=y.map((_,b)=>v.includes(b)?o.id:_),p=y,g=m.pop()}else p=l,(g==="alphaOverride"||g==="alpha")&&(p=l/100,Sa.zoom(n,m)[g]=p),f=o.id;s.push({type:0,path:m,props:{[g]:p}}),a.push({type:0,path:m,props:{[g]:f}})}a.push(h.reverse),s.push(h.actual)}}else{let l=Ha.apply(n,o);l!==null&&(s.push(l.actual),n=l.data,a.push(l.reverse))}}catch(l){if(l instanceof yY)return null;throw l}return{data:n,actual:s,reverse:a.reverse()}}e.empty=function(){return[]},e.removePrefix=function(i,r){let n=[];for(let s of i){let[a,...o]=s.path;a===r&&n.push({...s,path:o})}return n},e.addPrefix=function(i,r){return i.map(n=>({...n,path:[r,...n.path]}))},e.concat=function(i,r){return[...i,...r]},e.compress=function(i,r){return[...i.filter(n=>!r.some(s=>Ha.subsumed(n,s))),...r]},e.commutative=function(i,r){return i.every(n=>r.every(s=>Ha.commutative(n,s)))},e.applyAll=function(i,r){for(let n of r){let s=t(i,n);s!==null&&(i=s.data)}return i},e.apply=t})(Fee||(Fee={}))});function Uee(e,t){return e instanceof Ts?Object.setPrototypeOf(t,Ts.prototype):ow.tryPreservePrototype(e,t)}function $U(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Sa.equal(r.path,i))return void Object.assign(r.props,t.props)}e.push({...t,path:i})}function YI(e,t,i){return i instanceof Ea?new aC(e,t,i):i instanceof Et?new oC(e,t,i):i instanceof ri?new Proxy(new ube(e,t,i),cbe):i!==null&&typeof i=="object"?s1(i)?i:new Proxy(new hbe(e,t,i),dbe):i}function VM(e){let t=new UW(e);return[YI(t,"",e),t]}function OL(e,t){let[i,r]=VM(e);return t(i),r.result()}function Ds(e){return e instanceof aC||e instanceof oC?e._current:e!==null&&typeof e=="object"?e[LL]:e}function lx(e){if(e instanceof aC||e instanceof oC)return e._current;if(e!==null&&typeof e=="object"){let t=e[LL];return t!==void 0?t:e}return e}var LL,zee,qS,K1,hbe,ube,XU,dbe,cbe,aC,oC,UW,Sa,pbe=F(()=>{xB(),c1(),xY(),p1(),la(),SB(),wB(),LL=Symbol(),zee=Symbol(),qS=Symbol(),K1=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let n=i;for(;!(r instanceof UW);){let s=r._path,a=r._current;if(s!==""&&n.splice(0,0,s),r=r._parent,r===null)return;r.update(s,a)}r.push(n,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[qS];i&&i(),delete this._children[e]}}}},hbe=class extends K1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=Uee(this._current,{...this._current,[e]:t})}runOp(e){let t=ow.runOp(this._current,e);t!==null&&(t.data=Uee(this._current,t.data)),this.reportOp(e,t,e.path)}},ube=class extends K1{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,ri.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},XU={get(e,t){if(t===qS)return()=>{e._parent=null};if(t===LL)return e._current;if(t===zee)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=i[t],a=YI(e,t,s);return a!==s?(r===void 0&&(r={},e._children=r),r[t]=a,a):s},has:(e,t)=>t in e._current,ownKeys:e=>Reflect.ownKeys(e._current),defineProperty(){throw Error("not supported")},getPrototypeOf:e=>Object.getPrototypeOf(e._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},dbe={...XU,set(e,t,i){let r={type:0,props:{[t]:Ds(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},cbe={...XU,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty:(e,t)=>(e.runOp({type:2,id:t}),!0)},aC=class extends K1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[qS]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=YI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}add(e,t,i,r,n){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:n})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.add(e,r[n],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let n=0;n<i.length;n++){let s=i[n];this.move(e,r[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},oC=class extends K1{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[qS]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,n=this._current[i].fi;e(this.data(this._current[i].id),r,n,i)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}at(e){let{id:t,fi:i}=this._current.at(e);return{id:t,fi:i,data:this.data(t)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let n=t.get(e)?.data,s=YI(this,e,n);return s!==n?(i===void 0&&(i={},this._children=i),i[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.add(i[r],n.id,n.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let n=t[r];this.move(i[r],n)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}},UW=class extends K1{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){$U(this.ts,t,e),$U(this.actual,i,e),$U(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),SB=F(()=>{_Y(),pbe(),p1(),c1(),la(),(e=>{function t(r,n){return(r instanceof Ea||r instanceof aC)&&typeof n=="string"||(r instanceof Et||r instanceof oC)&&typeof n=="string"?r.data(n):typeof n=="number"&&Array.isArray(r)||typeof n=="string"&&typeof r=="object"&&r!==null?r[n]:void 0}function i(r,n,s=0){for(;s<n.length&&r!==void 0;)r=t(r,n[s]),s+=1;return r}e.equal=function(r,n){if(n.length!==r.length)return!1;{let s=0;for(;s<r.length;){if(r[s]!==n[s])return!1;s+=1}}return!0},e.removeOverridden=function(r,n,s){let a=i(s,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...n};return Object.keys(a).forEach(l=>{delete o[l]}),o}return n},e.zoomOnce=t,e.zoom=i,e.findPathes=function(r,n){let s=[];return function a(o,l){if(o instanceof NL&&o.id===n.id)s.push(l);else if(o instanceof Et)for(let h=0;h<o.length;h++)a(o[h].data,[...l,o[h].id]);else if(o instanceof Ea)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(s1(o))return;if(typeof o=="object"&&o!==null)for(let h in o)a(o[h],[...l,h])}}(r,[]),s}})(Sa||(Sa={}))}),U4e=F(()=>{});function Zr(e,t){let i=[];if(!(t.length<=e.length))return null;{let r=0;for(;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}}return i}var z4e=F(()=>{});function A3(e){try{if(!An.trusted&&!xf){let i=Fr.sharedLength||0;i<Fr.length&&(Fr.length=i)}let t;if(An.randomAccessStructure&&Ct[Oe]<64&&Ct[Oe]>=32&&Hee?(t=Hee(Ct,Oe,mu,An),Ct=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),Oe=mu):t=Zs(),wo&&(Oe=wo.postBundlePosition,wo=null),xf&&(Fr.restoreStructures=null),Oe==mu)Fr&&Fr.restoreStructures&&kee(),Fr=null,Ct=null,bf&&(bf=null);else{if(Oe>mu)throw new Error("Unexpected end of MessagePack data");if(!xf){let i;try{i=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`${n}n`:n).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return t}catch(t){throw Fr&&Fr.restoreStructures&&kee(),kW(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||Oe>mu)&&(t.incomplete=!0),t}}function kee(){for(let e in Fr.restoreStructures)Fr[e]=Fr.restoreStructures[e];Fr.restoreStructures=null}function Zs(){let e=Ct[Oe++];if(e<160){if(e<128){if(e<64)return e;{let t=Fr[63&e]||An.getStructures&&fbe()[63&e];return t?(t.read||(t.read=zW(t,63&e)),t.read()):e}}if(e<144){if(e-=128,An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=gbe();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(md>=Oe)return Dg.slice(Oe-Sh,(Oe+=t)-Sh);if(md==0&&mu<140){let i=t<16?TY(t):mbe(t);if(i!=null)return i}return UL(t)}{let t;switch(e){case 192:return null;case 193:return wo?(t=Zs(),t>0?wo[1].slice(wo.position1,wo.position1+=t):wo[0].slice(wo.position0,wo.position0-=t)):_be;case 194:return!1;case 195:return!0;case 196:if(t=Ct[Oe++],t===void 0)throw new Error("Unexpected end of buffer");return YU(t);case 197:return t=Er.getUint16(Oe),Oe+=2,YU(t);case 198:return t=Er.getUint32(Oe),Oe+=4,YU(t);case 199:return B0(Ct[Oe++]);case 200:return t=Er.getUint16(Oe),Oe+=2,B0(t);case 201:return t=Er.getUint32(Oe),Oe+=4,B0(t);case 202:if(t=Er.getFloat32(Oe),An.useFloat32>2){let i=qW[(127&Ct[Oe])<<1|Ct[Oe+1]>>7];return Oe+=4,(i*t+(t>0?.5:-.5)|0)/i}return Oe+=4,t;case 203:return t=Er.getFloat64(Oe),Oe+=8,t;case 204:return Ct[Oe++];case 205:return t=Er.getUint16(Oe),Oe+=2,t;case 206:return t=Er.getUint32(Oe),Oe+=4,t;case 207:return An.int64AsType==="number"?(t=4294967296*Er.getUint32(Oe),t+=Er.getUint32(Oe+4)):An.int64AsType==="string"?t=Er.getBigUint64(Oe).toString():An.int64AsType==="auto"?(t=Er.getBigUint64(Oe),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Er.getBigUint64(Oe),Oe+=8,t;case 208:return Er.getInt8(Oe++);case 209:return t=Er.getInt16(Oe),Oe+=2,t;case 210:return t=Er.getInt32(Oe),Oe+=4,t;case 211:return An.int64AsType==="number"?(t=4294967296*Er.getInt32(Oe),t+=Er.getUint32(Oe+4)):An.int64AsType==="string"?t=Er.getBigInt64(Oe).toString():An.int64AsType==="auto"?(t=Er.getBigInt64(Oe),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Er.getBigInt64(Oe),Oe+=8,t;case 212:if(t=Ct[Oe++],t==114)return HW(63&Ct[Oe++]);{let i=go[t];if(i)return i.read?(Oe++,i.read(Zs())):i.noBuffer?(Oe++,i()):i(Ct.subarray(Oe,++Oe));throw new Error("Unknown extension "+t)}case 213:return t=Ct[Oe],t==114?(Oe++,HW(63&Ct[Oe++],Ct[Oe++])):B0(2);case 214:return B0(4);case 215:return B0(8);case 216:return B0(16);case 217:return t=Ct[Oe++],md>=Oe?Dg.slice(Oe-Sh,(Oe+=t)-Sh):xbe(t);case 218:return t=Er.getUint16(Oe),md>=(Oe+=2)?Dg.slice(Oe-Sh,(Oe+=t)-Sh):wbe(t);case 219:return t=Er.getUint32(Oe),md>=(Oe+=4)?Dg.slice(Oe-Sh,(Oe+=t)-Sh):Sbe(t);case 220:return t=Er.getUint16(Oe),Oe+=2,Vee(t);case 221:return t=Er.getUint32(Oe),Oe+=4,Vee(t);case 222:return t=Er.getUint16(Oe),Oe+=2,Gee(t);case 223:return t=Er.getUint32(Oe),Oe+=4,Gee(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}function zW(e,t){function i(){if(i.count++>GW){let n;try{n=e.read=new Function("r","return function(){return "+(An.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":bbe.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(Zs)}catch{return GW=1/0,i()}return e.read0=n,e.highByte===0&&(e.read=jW(t,e.read)),n()}let r={};for(let n=0,s=e.length;n<s;n++){let a=e[n];a==="__proto__"&&(a="__proto_"),r[a]=Zs()}return An.freezeData?Object.freeze(r):r}return i.count=0,e.read0=i,e.highByte===0?jW(t,i):i}function fbe(){let e=ybe(()=>(Ct=null,An.getStructures()));return Fr=An._mergeStructures(e,Fr)}function GM(e){let t;if(e<16&&(t=TY(e)))return t;if(e>64&&VW)return VW.decode(Ct.subarray(Oe,Oe+=e));let i=Oe+e,r=[];for(t="";Oe<i;){let n=Ct[Oe++];if(128&n)if((224&n)==192){let s=(31&n)<<6|63&Ct[Oe++];s<128?r.push(65533):r.push(s)}else if((240&n)==224){let s=(31&n)<<12|(63&Ct[Oe++])<<6|63&Ct[Oe++];s<2048||s>=55296&&s<=57343?r.push(65533):r.push(s)}else if((248&n)==240){let s=(7&n)<<18|(63&Ct[Oe++])<<12|(63&Ct[Oe++])<<6|63&Ct[Oe++];s<65536||s>1114111?r.push(65533):(s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s))}else r.push(65533);else r.push(n);r.length>=4096&&(t+=xa.apply(String,r),r.length=0)}return r.length>0&&(t+=xa.apply(String,r)),t}function Vee(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Zs();return An.freezeData?Object.freeze(t):t}function Gee(e){if(An.mapsAsObjects){let t={};for(let i=0;i<e;i++){let r=gbe();r==="__proto__"&&(r="__proto_"),t[r]=Zs()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Zs(),Zs());return t}}function mbe(e){let t=Oe,i=new Array(e);for(let r=0;r<e;r++){let n=Ct[Oe++];if((128&n)>0)return void(Oe=t);i[r]=n}return xa.apply(String,i)}function TY(e){if(e<4){if(e<2){if(e===0)return"";{let t=Ct[Oe++];return(128&t)>1?void(Oe-=1):xa(t)}}{let t=Ct[Oe++],i=Ct[Oe++];if((128&t)>0||(128&i)>0)return void(Oe-=2);if(e<3)return xa(t,i);let r=Ct[Oe++];return(128&r)>0?void(Oe-=3):xa(t,i,r)}}{let t=Ct[Oe++],i=Ct[Oe++],r=Ct[Oe++],n=Ct[Oe++];if((128&t)>0||(128&i)>0||(128&r)>0||(128&n)>0)return void(Oe-=4);if(e<6){if(e===4)return xa(t,i,r,n);{let s=Ct[Oe++];return(128&s)>0?void(Oe-=5):xa(t,i,r,n,s)}}if(e<8){let s=Ct[Oe++],a=Ct[Oe++];if((128&s)>0||(128&a)>0)return void(Oe-=6);if(e<7)return xa(t,i,r,n,s,a);let o=Ct[Oe++];return(128&o)>0?void(Oe-=7):xa(t,i,r,n,s,a,o)}{let s=Ct[Oe++],a=Ct[Oe++],o=Ct[Oe++],l=Ct[Oe++];if((128&s)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(Oe-=8);if(e<10){if(e===8)return xa(t,i,r,n,s,a,o,l);{let h=Ct[Oe++];return(128&h)>0?void(Oe-=9):xa(t,i,r,n,s,a,o,l,h)}}if(e<12){let h=Ct[Oe++],u=Ct[Oe++];if((128&h)>0||(128&u)>0)return void(Oe-=10);if(e<11)return xa(t,i,r,n,s,a,o,l,h,u);let d=Ct[Oe++];return(128&d)>0?void(Oe-=11):xa(t,i,r,n,s,a,o,l,h,u,d)}{let h=Ct[Oe++],u=Ct[Oe++],d=Ct[Oe++],c=Ct[Oe++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(Oe-=12);if(e<14){if(e===12)return xa(t,i,r,n,s,a,o,l,h,u,d,c);{let p=Ct[Oe++];return(128&p)>0?void(Oe-=13):xa(t,i,r,n,s,a,o,l,h,u,d,c,p)}}{let p=Ct[Oe++],f=Ct[Oe++];if((128&p)>0||(128&f)>0)return void(Oe-=14);if(e<15)return xa(t,i,r,n,s,a,o,l,h,u,d,c,p,f);let m=Ct[Oe++];return(128&m)>0?void(Oe-=15):xa(t,i,r,n,s,a,o,l,h,u,d,c,p,f,m)}}}}}function jee(){let e,t=Ct[Oe++];if(t<192)e=t-160;else switch(t){case 217:e=Ct[Oe++];break;case 218:e=Er.getUint16(Oe),Oe+=2;break;case 219:e=Er.getUint32(Oe),Oe+=4;break;default:throw new Error("Expected string")}return GM(e)}function YU(e){return An.copyBuffers?Uint8Array.prototype.slice.call(Ct,Oe,Oe+=e):Ct.subarray(Oe,Oe+=e)}function B0(e){let t=Ct[Oe++];if(go[t]){let i;return go[t](Ct.subarray(Oe,i=Oe+=e),r=>{Oe=r;try{return Zs()}finally{Oe=i}})}throw new Error("Unknown extension type "+t)}function gbe(){let e=Ct[Oe++];if(!(e>=160&&e<192))return Oe--,vbe(Zs());if(e-=160,md>=Oe)return Dg.slice(Oe-Sh,(Oe+=e)-Sh);if(!(md==0&&mu<180))return UL(e);let t,i=4095&(e<<5^(e>1?Er.getUint16(Oe):e>0?Ct[Oe]:0)),r=WW[i],n=Oe,s=Oe+e-3,a=0;if(r&&r.bytes==e){for(;n<s;){if(t=Er.getUint32(n),t!=r[a++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(t=Ct[n++],t!=r[a++]){n=1879048192;break}if(n===s)return Oe=n,r.string;s-=3,n=Oe}for(r=[],WW[i]=r,r.bytes=e;n<s;)t=Er.getUint32(n),r.push(t),n+=4;for(s+=3;n<s;)t=Ct[n++],r.push(t);let o=e<16?TY(e):mbe(e);return r.string=o??UL(e)}function vbe(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(An.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error("Invalid property type for record: "+typeof e)}function ybe(e){qee&&qee();let t=mu,i=Oe,r=FL,n=Sh,s=md,a=Dg,o=BL,l=bf,h=wo,u=new Uint8Array(Ct.slice(0,mu)),d=Fr,c=Fr.slice(0,Fr.length),p=An,f=xf,m=e();return mu=t,Oe=i,FL=r,Sh=n,md=s,Dg=a,BL=o,bf=l,wo=h,Ct=u,xf=f,(Fr=d).splice(0,Fr.length,...c),An=p,Er=new DataView(Ct.buffer,Ct.byteOffset,Ct.byteLength),m}function kW(){Ct=null,bf=null,Fr=null}function k4e(e){e.unpack?go[e.type]=e.unpack:go[e.type]=e}var VW,Ct,mu,Oe,Wee,BL,FL,An,Fr,Dg,Sh,md,wo,bf,go,Er,KU,_be,xf,GW,Hee,qee,jM,bbe,jW,UL,xbe,wbe,Sbe,xa,WW,HW,ZU,$ee,Xee,Yee,qW,C3,Kee,Zee,Qee,$W,QU,LA,V4e=F(()=>{try{VW=new TextDecoder}catch{}Oe=0,BL=Wee=[],FL=0,An={},Sh=0,md=0,go=[],KU={useRecords:!1,mapsAsObjects:!0},(_be=new class{}).name="MessagePack 0xC1",xf=!1,GW=2,jM=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(Ct)return ybe(()=>(kW(),this?this.unpack(e,t):jM.prototype.unpack.call(KU,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(mu=t.end||e.length,Oe=t.start||0):(Oe=0,mu=t>-1?t:e.length),FL=0,md=0,Dg=null,BL=Wee,wo=null,Ct=e;try{Er=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ct=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof jM){if(An=this,this.structures)return Fr=this.structures,A3(t);(!Fr||Fr.length>0)&&(Fr=[])}else An=KU,(!Fr||Fr.length>0)&&(Fr=[]);return A3(t)}unpackMultiple(e,t){let i,r=0;try{xf=!0;let n=e.length,s=this?this.unpack(e,n):C3.unpack(e,n);if(!t){for(i=[s];Oe<n;)r=Oe,i.push(A3());return i}if(t(s,r,Oe)===!1)return;for(;Oe<n;)if(r=Oe,t(A3(),r,Oe)===!1)return}catch(n){throw n.lastPosition=r,n.values=i,n}finally{xf=!1,kW()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(i=>i.slice(0)));for(let i=0,r=e.length;i<r;i++){let n=e[i];n&&(n.isShared=!0,i>=32&&(n.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],n=t[i];n&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}},bbe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,jW=(e,t)=>function(){let i=Ct[Oe++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),n=Fr[r]||fbe()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=zW(n,e)),n.read()},UL=GM,xbe=GM,wbe=GM,Sbe=GM,xa=String.fromCharCode,WW=new Array(4096),HW=(e,t)=>{let i=Zs().map(vbe),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let n=Fr[e];return n&&(n.isShared||xf)&&((Fr.restoreStructures||(Fr.restoreStructures=[]))[e]=n),Fr[e]=i,i.read=zW(i,r),(i.read0||i.read)()},go[0]=()=>{},go[0].noBuffer=!0,go[66]=e=>{let t=e.byteLength%8||8,i=BigInt(128&e[0]?e[0]-256:e[0]);for(let r=1;r<t;r++)i<<=BigInt(8),i+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(s,a)=>{let o=a-s;if(o<=40){let d=r.getBigUint64(s);for(let c=s+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=s+(o>>4<<3),h=n(s,l),u=n(l,a);return h<<BigInt(8*(a-l))|u};i=i<<BigInt(8*(r.byteLength-t))|n(t,r.byteLength)}return i},ZU={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},go[101]=()=>{let e=Zs();if(!ZU[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ZU[e[0]](e[1],{cause:e[2]})},go[105]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Er.getUint32(Oe-4);bf||(bf=new Map);let i,r=Ct[Oe];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)&&Ct[Oe+1]===115?new Set:{};let n={target:i};bf.set(t,n);let s=Zs();if(!n.used)return n.target=s;if(Object.assign(i,s),i instanceof Map)for(let[a,o]of s.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(s))i.add(a);return i},go[112]=e=>{if(An.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=Er.getUint32(Oe-4),i=bf.get(t);return i.used=!0,i.target},go[115]=()=>new Set(Zs()),$ee=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),Xee=typeof globalThis=="object"?globalThis:window,go[116]=e=>{let t=e[0],i=Uint8Array.prototype.slice.call(e,1).buffer,r=$ee[t];if(!r){if(t===16)return i;if(t===17)return new DataView(i);throw new Error("Could not find typed array for code "+t)}return new Xee[r](i)},go[120]=()=>{let e=Zs();return new RegExp(e[0],e[1])},Yee=[],go[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Oe;return Oe+=t-e.length,wo=Yee,(wo=[jee(),jee()]).position0=0,wo.position1=0,wo.postBundlePosition=Oe,Oe=i,Zs()},go[255]=e=>e.length==4?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid"),qW=new Array(147);for(let e=0;e<256;e++)qW[e]=+("1e"+Math.floor(45.15-.30103*e));(C3=new jM({useRecords:!1})).unpack,C3.unpackMultiple,C3.unpack,Kee=new Float32Array(1),new Uint8Array(Kee.buffer,0,4)}),G4e=F(()=>{V4e(),_Y(),wB(),p1(),xB(),c1(),Zee=[{Class:ri.prototype.constructor,type:1,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,ri.prototype),e)},{Class:Et.prototype.constructor,type:2,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,Et.prototype),e)},{Class:Ea.prototype.constructor,type:3,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,Ea.prototype),e)},{Class:NL.prototype.constructor,type:4,write:e=>e.id,read:e=>new NL(e)},{Class:FW.prototype.constructor,type:5,write:e=>e.data,read:e=>new FW(e)},{Class:Ts.prototype.constructor,type:6,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,Ts.prototype),e)}];for(let e of Zee)k4e(e);Qee=new jM({structuredClone:!0}),($W||($W={})).deserialize=function(e){return Qee.unpack(e)}}),j4e=F(()=>{G4e(),QU=e=>()=>{throw new Error(e+" is not available in the runtime build (decode-only CollabSerialize)")},LA={deserialize:$W.deserialize,serialize:QU("CollabSerialize.serialize"),checksum:QU("CollabSerialize.checksum")}}),Ir=F(()=>{SB(),L4e(),bY(),c1(),xB(),xY(),p1(),F4e(),U4e(),pbe(),z4e(),_Y(),j4e(),lbe(),wB()});function XW(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var Jee,YW,zE,P3,JU,ete,tte,ite,KW,ZW,rte,nte,ste,ate,ote,QW,JW,lte,hte,ute,dte,Tbe=F(()=>{var e,t,i;Ir(),ne(),(e=Jee||(Jee={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},e.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},YW={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(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"},r.defaultData=function(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,name:"",actions:new Et}:{type:n,disabled:!1,name:"",key:void 0,actions:new Et}}})(zE||(zE={})),(r=>{r.propertyDefaultData=function(n){return{type:"Property",value:[n??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(P3||(P3={})),(t=JU||(JU={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:P3.propertyDefaultData(r),rOperand:{...P3.valueDefaultData}}},t.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},t.stateDefaultData=function(r,n){return{type:"State",object:r??null,state:n??null}},(ete||(ete={})).isConditionalSubActions=function(r){return r.find(n=>n==="ifActions"||n==="elseActions")!==void 0},(r=>{r.is=function(n){return n.type==="Conditional"},r.defaultData=function(n){return{type:"Conditional",disabled:!1,name:"",inActions:new Et,outActions:new Et,condition:JU.distanceDefaultData(n)}}})(tte||(tte={})),(ite||(ite={})).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 Et,drop:new Et}},(KW||(KW={})).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 Et},(ZW||(ZW={})).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(n){return n.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new Et}}})(rte||(rte={})),(r=>{r.is=function(n){return n.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 Et}}})(nte||(nte={})),(r=>{r.is=function(n){return n.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new Et}}})(ste||(ste={})),(r=>{r.is=function(n){return n.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new Et}}})(ate||(ate={})),(r=>{r.is=function(n){return n.type==="Trigger"},r.defaultData=function(n,s){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new Et,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}})(ote||(ote={})),(i=QW||(QW={})).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 Et},n={size:"tablet",operator:"<",actions:new Et},s={size:[...i.defaultSizes.custom],operator:"<>",actions:new Et},a=new Et;return a.push({id:Qe.generateUUID(),fi:0,data:r},{id:Qe.generateUUID(),fi:1,data:n},{id:Qe.generateUUID(),fi:2,data:s}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new Et}},(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(n){return n.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new Et,variableId:"",objectId:null,property:"Position X"}}})(JW||(JW={})),(r=>{r.is=function(n){return n.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new Et,errorActions:new Et,userAPIId:""}}})(lte||(lte={})),(r=>{r.is=function(n){return n.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new Et,userWebhookId:""}}})(hte||(hte={})),(r=>{r.is=function(n){return n.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new Et,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(ute||(ute={})),(r=>{r.is=function(n){return n.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new Et}}})(dte||(dte={}))});function cte(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function eH(e){return typeof e=="string"&&e.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}var f1,Rx,Mbe,Za,pte,Lc,jg,BA,fte,e5,Ph,Ys,kr,tH,mte,Ng,lw,gte,vte,yte,_te,bte,xte,wte,Ste,t5,Tte,Mte,i5,Ete,Ate,Cte,r5,Pte,n5,Rte,Dte,s5,Nte,iH,Ite,Ote,Lte,Bte,Fte,Ute,a1,wf,Ig,rH,nH,zL,kL,VL,GL,jL,sH,aH,WL,oH,Dx,zte,a5,o5,lH,kte,HL,qL,l5,Vte,FA,h5,Gte,jte,Wte,Hte,Jg,qte,$te,Xte,Yte,TB,MY,ts,Un,Fb,Ebe,hw,$L,Qv,hH,EY,XL,YL,KL,cf,KI,Xn,u5,wg,eh=F(()=>{var e,t,i,r,n,s,a,o;f1="personal camera",Rx="a218fcc3-276b-49b9-b485-49037fd14f5f",Mbe=2500134,Za=5526619,(e=pte||{}).x="x",e.y="y",e.z="z",pte=e,(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,f){let m=l.sub(p,c),g=l.sub(f,c),v=l.dot(m,g)/l.dot(m,m),y=l.scalarMultiply(m,v);return l.add(c,y)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,f){return[c[0]+(p[0]-c[0])*f,c[1]+(p[1]-c[1])*f]},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,f){return u(c,d(c,p,f))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Lc||(Lc={})),(t=jg||(jg={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]},t.add=function(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]},t.sub=function(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]},t.div=function(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]},t.mul=function(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]},t.dist=function(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])},t.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=BA||(BA={})).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])]}})(fte||(fte={})),(r=e5||(e5={})).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=[...e5.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]]]}})(Ph||(Ph={})),(n=Ys||(Ys={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},n.white={r:1,g:1,b:1},n.red={r:1,g:0,b:0},n.black={r:0,g:0,b:0},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},n.clone=function(l){return{r:l.r,g:l.g,b:l.b}},n.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},n.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},n.equals=function(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b},n.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)},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}},n.is=function(l){return!!cte(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(s=kr||(kr={})).white={...Ys.white,a:1},s.is=function(l){return!!cte(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},s.transparent={...Ys.white,a:0},s.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},s.fromHexAndA=function(l,h){return{...Ys.fromHex(l),a:h}},s.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}},s.equals=function(l,h){return Ys.equals(l,h)&&l.a===h.a},s.equalsFixed=function(l,h){return Ys.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.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,a:l.a+(h.a-l.a)*u}},s.toStyle=function({r:l,g:h,b:u,a:d}=s.white){return`rgba(${255*l}, ${255*h}, ${255*u}, ${d})`},(tH||(tH={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=mte||{})[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",mte=a,(Ng||(Ng={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(lw||(lw={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=gte||(gte={})).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]}),W4e=F(()=>{var e,t;Ir(),Tbe(),(vte||(vte={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(yte||(yte={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(_te||(_te={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(bte||(bte={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(xte||(xte={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(wte||(wte={})).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"},(Ste||(Ste={})).defaultData={type:"Reset",name:"",delay:0},(t5||(t5={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(e=Tte||(Tte={})).pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0},(t=Mte||(Mte={})).defaultData={type:"Audio",name:"",...t5.defaultData},t.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),t.hasAudioByEvents=i=>t.getAudiosByEvents(i).length>0,t.getAudiosByActions=i=>{let r=[];return i.forEach(n=>{let s=n.data;s.type==="Audio"&&s.interaction==="play"&&s.audio&&r.push(n),s.type==="Conditional"&&(r.push(...t.getAudiosByActions(s.ifActions)),r.push(...t.getAudiosByActions(s.elseActions)))}),r},t.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:n})=>{zE.is(n)||n.type==="Collision"||n.type==="Start"||n.type==="Trigger"||n.type==="VariableChange"||n.type==="WEBHOOK"||n.type==="AIAssistantTrigger"?r.push(...t.getAudiosByActions(n.actions)):n.type==="Conditional"?(r.push(...t.getAudiosByActions(n.inActions)),r.push(...t.getAudiosByActions(n.outActions))):n.type==="GameControl"?Object.values(n.gameActions).forEach(s=>{r.push(...t.getAudiosByActions(s))}):n.type==="DragDrop"?(r.push(...t.getAudiosByActions(n.dragDropActions.drag)),r.push(...t.getAudiosByActions(n.dragDropActions.drop))):n.type==="Resize"?n.breakpoints.forEach(({data:s})=>{r.push(...t.getAudiosByActions(s.actions))}):n.type==="API"&&(r.push(...t.getAudiosByActions(n.successActions)),r.push(...t.getAudiosByActions(n.errorActions)))}),r},(i5||(i5={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(Ete||(Ete={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...i5.defaultData},i.hasVideoByActions=r=>r.some(({data:n})=>n.type==="Video"&&n.interaction==="play"&&n.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:n}of r.events)if((zE.is(n)||n.type==="Start")&&i.hasVideoByActions(n.actions))return!0}},i.getVideosByActions=r=>{let n=[];return r.forEach(s=>{let a=s.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&n.push(s)}),n},i.getVideosByEvents=r=>{let n=[];return r.forEach(({data:s})=>{(zE.is(s)||s.type==="Start")&&n.push(...i.getVideosByActions(s.actions))}),n}})(Ate||(Ate={})),(Cte||(Cte={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(r5||(r5={})).defaultData=function(){return{tweens:new Et,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(Pte||(Pte={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...r5.defaultData()}},(n5||(n5={})).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}})(Rte||(Rte={})),(Dte||(Dte={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...n5.defaultData(i)}},(s5||(s5={})).defaultData=function(i,r,n){return{interaction:"play",object:i,clipId:r,crop:n,crop2:n,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(Nte||(Nte={})),(i=>{i.defaultData=function(r,n,s){return{type:"Animation",name:"",...s5.defaultData(r,n,s)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(iH||(iH={})),(Ite||(Ite={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(Ote||(Ote={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new Et,elseActions:new Et,condition:[]}),(Lte||(Lte={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(Bte||(Bte={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(Fte||(Fte={})).defaultData={name:"",type:"UserAPI"}}),H4e=F(()=>{var e;(e=Ute||(Ute={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),t=>t.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},e.maxSize=2e6}),Abe=F(()=>{var e;(e=a1||(a1={})).all=["PerspectiveCamera","OrthographicCamera"],e.is=function(t){return e.all.includes(t)},(t=>{t.DefaultUp=[0,1,0],t.DefaultTargetOffset=1e3,t.MinTargetOffset=.001,t.sanitizeTargetOffset=function(s){return s===void 0||!Number.isFinite(s)||s<t.MinTargetOffset?t.DefaultTargetOffset:s},t.DefaultAzimuth=-24,t.DefaultElevation=15;let i=t.DefaultAzimuth*Math.PI/180,r=t.DefaultElevation*Math.PI/180,n=180/Math.PI;t.DefaultPosition=[t.DefaultTargetOffset*Math.sin(i)*Math.cos(r),t.DefaultTargetOffset*Math.sin(r),t.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],t.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*n,Math.asin(Math.sin(i)*Math.cos(r))*n,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*n],t.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:t.DefaultUp,isUpVectorFlipped:!1,targetOffset:t.DefaultTargetOffset},t.getZoom=function(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}})(wf||(wf={}))}),Cbe=F(()=>{var e;(e=Ig||(Ig={})).defaultData=function(t,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof t[0]=="number"?t[0]:1,typeof t[1]=="number"?t[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 t[0]=="number"?t[0]+t[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:t.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"}}},e.merge=function(t,i){let r={...t};if(nH.forEach(n=>{Object.assign(r,{[n]:i[n]??t[n]})}),r.radial={...t.radial},i.radial){let n=t.radial,s=i.radial;zL.forEach(a=>{Object.assign(r.radial,{[a]:s[a]??n[a]})})}if(r.linear={...t.linear},i.linear){let n=t.linear,s=i.linear;kL.forEach(a=>{Object.assign(r.linear,{[a]:s[a]??n[a]})})}if(r.grid={...t.grid},i.grid){let n=t.grid,s=i.grid;VL.forEach(a=>{Object.assign(r.grid,{[a]:s[a]??n[a]})})}if(r.toObject={...t.toObject},i.toObject){let n=t.toObject,s=i.toObject;GL.forEach(a=>{Object.assign(r.toObject,{[a]:s[a]??n[a]})})}if(r.randomnessObject={...t.randomnessObject},i.randomnessObject){let n=t.randomnessObject,s=i.randomnessObject;jL.forEach(a=>{Object.assign(r.randomnessObject,{[a]:s[a]??n[a]})})}return r},e.isPartial=function(t){return!(!t.randomnessObject&&!t.toObject)},(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];t.toOps=function(r,n){let s=[];r.count!==void 0&&s.push({type:0,path:n,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&s.push({type:0,path:[...n,a],props:o})}return s}})(rH||(rH={})),nH=["count"],zL=["radius","start","end","position","scale","rotation"],kL=["position","scale","rotation"],VL=["count","size"],GL=["count","position","scale","rotation"],jL=["strength","scale","rotation","position","movement","seed","freqScale"]}),Pbe=F(()=>{var e;eh(),(e=sH||(sH={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],e.is=function(t){return e.all.includes(t)},(aH||(aH={})).defaultData=function(t){return function(i){if(i==="PointLight")return{type:i,color:kr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:kr.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:kr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(t)}}),Rbe=F(()=>{var e;(e=WL||(WL={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.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:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}}),Dbe=F(()=>{var e;(e=oH||(oH={})).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},e.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),AY=F(()=>{(Dx||(Dx={})).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]}}),Nbe=F(()=>{var e,t;(e=zte||{})[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",zte=e,(t=a5||(a5={})).defaultData={castShadow:!0,receiveShadow:!0},t.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,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe&&(r.shadowCatcher??!1)===(n.shadowCatcher??!1)}})(o5||(o5={})),(lH||(lH={})).defaultData={...o5.defaultData,...a5.defaultData},(kte||(kte={})).getMaterialData=function(i,r){let n=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&n.push(s)}else if("materials"in i)for(let s of i.materials){let a=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;a&&n.push(a)}return n}}),Ibe=F(()=>{var e;(e=HL||(HL={})).bytesFromFlattened=function(t){if(typeof t!="object"||t===null||Array.isArray(t)||ArrayBuffer.isView(t)||typeof t[0]!="number")return null;let i=Object.getPrototypeOf(t);if(i!==Object.prototype&&i!==null)return null;let r=Object.keys(t),n=new Uint8Array(r.length),s=t;for(let a=0;a<r.length;a++){let o=s[a];if(r[a]!==String(a)||typeof o!="number"||!Number.isInteger(o)||o<0||o>255)return null;n[a]=o}return n},e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),Obe=F(()=>{var e;(e=qL||(qL={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7}),lC=F(()=>{var e,t,i,r;Ir(),eh(),Ibe(),Obe(),eh(),(l5||(l5={})).is=function(n){return n==="texture"||n==="video"||n==="color"||n==="depth"||n==="normal"||n==="gradient"||n==="noise"||n==="fresnel"||n==="cavity"||n==="dust"||n==="rainbow"||n==="toon"||n==="outline"||n==="particle"||n==="transmission"||n==="reflection"||n==="matcap"||n==="displace"||n==="pattern"||n==="vertexColor"||n==="light"},(Vte||(Vte={})).is=function(n){return n==="luminance"||n==="r"||n==="g"||n==="b"||n==="a"},(FA||(FA={})).is=function(n){return typeof n=="object"&&n!==null&&n.image!=null},(h5||(h5={})).is=function(n){return n==="phong"||n==="toon"||n==="lambert"||n==="physical"},(t=Gte||{})[t.Linear=0]="Linear",t[t.Radial=1]="Radial",t[t.Polar=2]="Polar",Gte=t,jte=(n=>(n[n.RepeatWrapping=1e3]="RepeatWrapping",n[n.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",n[n.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",n))(jte||{}),Wte=(n=>(n[n.NearestFilter=1003]="NearestFilter",n[n.LinearFilter=1006]="LinearFilter",n[n.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",n))(Wte||{}),(e=Hte||{})[e.UV=0]="UV",e[e.Planar=1]="Planar",e[e.Spherical=2]="Spherical",e[e.Cylindrical=3]="Cylindrical",e[e.Triplanar=4]="Triplanar",Hte=e,(n=>{n.MAX=3,n.of=function(s){return typeof s=="number"&&Number.isInteger(s)&&s>=0&&s<=3?s:0},n.attributeName=function(s){return s===0?"uv":`uv${s}`}})(Jg||(Jg={})),(r=qte||{})[r.Simplex=0]="Simplex",r[r.SimplexFractal=1]="SimplexFractal",r[r.Ashima=2]="Ashima",r[r.Fbm=3]="Fbm",r[r.Perlin=4]="Perlin",r[r.Voronoi=5]="Voronoi",qte=r,(i=$te||{})[i.F1=0]="F1",i[i.F2=1]="F2",i[i.F2MinusF1=2]="F2MinusF1",i[i.SmoothBlend=3]="SmoothBlend",i[i.Edge=4]="Edge",i[i.Power=5]="Power",i[i.Lines=6]="Lines",i[i.Cells=7]="Cells",$te=i,Xte=(n=>(n[n.Lights=0]="Lights",n[n.Static=1]="Static",n[n.Camera=2]="Camera",n))(Xte||{}),Yte=(n=>(n[n.Circle=0]="Circle",n[n.Ring=1]="Ring",n[n.Polygon=2]="Polygon",n[n.Cross=3]="Cross",n[n.Diamond=4]="Diamond",n[n.Checkerboard=5]="Checkerboard",n[n.Line=6]="Line",n[n.Wave=7]="Wave",n))(Yte||{}),TB=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],MY=["wrapping","image","video","name","minFilter","magFilter"],(n=>{function s(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:qL.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...h,type:"color",color:Ys.fromHex(Za)};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:{...Ys.fromHex(6710886),a:1},colorB:{...Ys.fromHex(6710886),a:1},colorC:{...Ys.fromHex(16777215),a:1},colorD:{...Ys.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:kr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...h,type:"dust",color:kr.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:kr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...h,type:"outline",outlineColor:kr.fromHexAndA(0,1),contourColor:kr.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:{...Ys.fromHex(0),a:1},colorB:{...Ys.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)}n.patch=function(a,o){let{texture:l,...h}=o;if(Object.assign(a,h),l){let u=a.texture;u&&Object.assign(u,l)}},n.defaultColorLayer=function(a){return{...n.defaultData("color"),color:a}},n.defaultData=s,n.defaultDataFor=function(a,o){return a!=="light"?s(a):s("light",typeof o=="string"&&h5.is(o)?o:"physical")}})(ts||(ts={})),(n=>{function s(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}=Ys.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 f=h;return typeof f?.r!="number"?l:typeof f.a=="number"?{r:u,g:d,b:c,a:p??f.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=Ys.fromHex(16777215)){let c=new Et;return c.push({fi:0,data:ts.defaultData("light",l),id:h}),c.push({fi:1,data:ts.defaultData("color"),id:u}),{layers:c}}n.restoreImageBytes=function(l){let h=[],u=new Map,d=(p,f)=>{let m=lx(p);if(typeof m!="object"||m===null||ArrayBuffer.isView(m))return p;if(u.has(m))return u.get(m)??p;u.set(m,void 0);let g=c(m,f)??p;return u.set(m,g),g},c=(p,f)=>{let m=p;if(!Array.isArray(p)){if(typeof m[0]=="number")return;if(typeof m.name=="string"){let v=HL.bytesFromFlattened(lx(m.data));if(v!==null)return h.push({path:`${f}/data`,bytes:v.byteLength}),Object.setPrototypeOf({...m,data:v},Object.getPrototypeOf(p))}}let g=null;for(let v of Object.keys(p)){let y=m[v],_=d(y,`${f}/${v}`);_!==y&&(g===null&&(g=Array.isArray(p)?[...p]:{...m},Object.setPrototypeOf(g,Object.getPrototypeOf(p))),g[v]=_)}return g??void 0};return{material:d(l,""),restored:h}},n.restoreLayersSeq=function(l){let h=lx(l.layers);if(!Array.isArray(h)||h instanceof Et||!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],Et.prototype),d=lx(l);return{material:Object.setPrototypeOf({...d,layers:u},Object.getPrototypeOf(d)),restored:!0}},n.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")},n.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},n.defaultEmptyData=function(){return{layers:new Et}},n.defaultData=function(l="layer1",h="layer2"){return o("physical",l,h)},n.withName=function(l,h){return{...l,name:h}},n.isLayerEntry=a,n.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 Et;return h.forEach((d,c)=>{if(a(d))return void u.push(d);let{id:p,fi:f,...m}=d??{};if(typeof m.type!="string"||!l5.is(m.type))return;let g=ts.defaultDataFor(m.type,m.category),v={...g,...m};for(let[y,_]of Object.entries(m)){let b=g[y];v[y]=Array.isArray(_)&&Array.isArray(b)&&Array.isArray(b[0])?_.map(x=>s(x,b[0])):s(_,b)}u.push({id:typeof p=="string"&&p?p:`layer${c+1}`,fi:typeof f=="number"?f:c,data:v})}),{...l,layers:u}},n.defaultTwoLayerData=o,n.defaultColorMaterial=function(l,h,u="layer1",d="layer2"){let c=new Et;return c.push({fi:0,data:ts.defaultData("light",h),id:u}),c.push({fi:1,data:ts.defaultColorLayer(l),id:d}),{layers:c}},n.defaultUIObjectMaterial=function(l){let h=ts.defaultData("texture");l&&Object.assign(h.texture,{image:l});let u=new Et;return u.push({fi:0,data:h,id:"layer1"}),u.push({fi:1,data:{...ts.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...ts.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}},n.defaultTwoLayerTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=ts.defaultData("texture");Object.assign(c.texture,{image:l});let p=new Et;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:ts.defaultData("light",h),id:d}),{layers:p}},n.defaultTwoLayerVideoTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=ts.defaultData("video");Object.assign(c.texture,{video:l});let p=new Et;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:ts.defaultData("light",h),id:d}),{layers:p}}})(Un||(Un={}))}),q4e=F(()=>{Fb="Roboto_regular",Ebe="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),$4e=F(()=>{q4e()}),Lbe=F(()=>{var e;Ir(),(e=hw||(hw={})).defaultData=function(){return{points:new Et,roundness:0,shapeHoles:[],isClosed:!1}},e.scaled=function t(i,r,n){let s=a=>[a[0]*r,a[1]*n];return{...i,points:new Et(...i.points.map(({id:a,fi:o,data:l})=>({id:a,fi:o,data:{...l,position:s(l.position),controlPrevious:{position:s(l.controlPrevious.position)},controlNext:{position:s(l.controlNext.position)}}}))),shapeHoles:i.shapeHoles.map(a=>t(a,r,n))}}}),Bbe=F(()=>{Ir(),($L||($L={})).defaultData=function(){return{points:new Et,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},Qv={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(hH||(hH={})).merge=function(e,t){let i={...e};return XL.forEach(r=>{Object.assign(i,{[r]:t[r]??e[r]})}),i},EY={shape:Qv,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},XL=["depth","offset","angle","twist","startScale","endScale"]}),CY=F(()=>{var e,t;Lbe(),Bbe(),(e=YL||(YL={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},e.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"},e.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"},(KL||(KL={})).merge=function(i,r){let n={...i};if(Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...i.extrusion},Object.assign(n.extrusion,hH.merge(n.extrusion,r.extrusion))),i.type==="VectorGeometry"&&n.type==="VectorGeometry"){let s=(l,h)=>typeof l=="number"&&typeof h=="number"&&h!==0?l/h:1,a=s(n.width,i.width),o=s(n.height,i.height);(a!==1||o!==1)&&(n.shape=hw.scaled(i.shape,a,o))}return n},(t=cf||(cf={})).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:$L.defaultData(),extrusion:EY};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:hw.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{...t.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")},KI=["width","height","depth"]}),Fbe=F(()=>{eh(),(e=>{function t(i){return i.mode??"linear"}e.defaultData={enabled:!1,useBackgroundColor:!1,color:Ys.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},e.getMode=t,e.getModeIndex=function(i){let r=t(i);return r==="height"?1:r==="both"?2:0},e.getDensity=function(i){return i.density??e.defaultData.density},e.getHeightFalloff=function(i){return i.heightFalloff??e.defaultData.heightFalloff},e.getHeightBase=function(i){return i.heightBase??e.defaultData.heightBase}})(Xn||(Xn={}))}),PY=F(()=>{(u5||(u5={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(wg||(wg={})).defaultData={enabled:!1,mode:"hdri",hdri:u5.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function X4e(e){let t=typeof e=="string"?Number.parseInt(e,10):e;return typeof t=="number"&&Number.isFinite(t)?Math.min(5,Math.max(0,Math.round(t))):3}var UA,wy,d5,c5,p5,Nx,f5,uH,dH,Kte,Z1,Ube,ra,ZL,Zte,Qte,Jte,eie,yc,kE,QL,JL,Sf,Sy,tie,Og,e4,Tf,m5,g5,ny,o1,sy,VE,cH,iie,So,v5,rie,nie,pf,fu,Ix,zbe=F(()=>{(()=>{let e={opacity:1,blendFunction:13,enabled:!1};(UA||(UA={})).defaultData={enabled:!1,pixelation:{...e,blendFunction:16,granularity:15},bloom:{...e,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...e,offset:[2,2]},vignette:{...e,darkness:1,offset:0},hueSaturation:{...e,hue:3,saturation:0},brightnessContrast:{...e,brightness:.25,contrast:0},depthOfField:{...e,focusDistance:100,focalLength:20,bokehScale:5},noise:{...e,blendFunction:16}}})()}),RY=F(()=>{var e;Fbe(),PY(),zbe(),eh(),(e=wy||(wy={})).defaultData={type:"normal",softShadowQuality:"low"},e.isSoft=function(t){return t!=null&&(t.type===void 0||t.type==="soft")},(d5||(d5={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(c5||(c5={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(t=>{t.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},t.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(p5||(p5={})),(Nx||(Nx={})).defaultData={usePhysics:!1,gravity:-10},(f5||(f5={})).defaultData={playCamera:f1,gameControlObject:null},(uH||(uH={})).defaultData={backgroundColor:kr.fromHexAndA(Mbe,1),postprocessing:UA.defaultData,fog:Xn.defaultData,sky:wg.defaultData,globalPhysics:Nx.defaultData,ambient:d5.defaultData,ao:c5.defaultData,shadow:wy.defaultData,publish:f5.defaultData,grading:p5.defaultData}}),Y4e=F(()=>{(dH||(dH={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),MB=F(()=>{var e,t,i;Ir(),Abe(),Pbe(),Rbe(),Dbe(),AY(),Nbe(),eh(),lC(),CY(),Cbe(),la(),RY(),Y4e(),(e=Kte||(Kte={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},e.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(t=Z1||(Z1={})).identity={...tH.identity,shear:Ph.zero},t.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,shear:r.shear}},t.merge=function(r,n){return{position:n?.position||r.position,rotation:n?.rotation||r.rotation,pivot:n?.pivot||r.pivot,pivotRotation:n?.pivotRotation||r.pivotRotation,scale:n?.scale||r.scale,shear:n?.shear||r.shear}},t.diff=function(r,n){return nbe({position:jg.isEqual(r.position,n.position)?void 0:n.position,rotation:jg.isEqual(r.rotation,n.rotation)?void 0:n.rotation,scale:jg.isEqual(r.scale,n.scale)?null:n.scale,shear:n.shear?.every((s,a)=>s===r.shear?.[a])?void 0:n.shear})},Ube=["slide","offset"],(ra||(ra={})).defaultData={states:new Et,events:new Et,visible:!0,raycastLock:!1,physics:Dx.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Z1.identity,cloner:null},(ZL||(ZL={})).defaultData={type:"Empty",...ra.defaultData},(Zte||(Zte={})).defaultData={type:"ParticleCollider",...dH.defaultData,...ra.defaultData},(Qte||(Qte={})).defaultData={type:"Component",...ra.defaultData},(Jte||(Jte={})).defaultData={type:"Particle",...ra.defaultData,...WL.defaultData},(eie||(eie={})).defaultData={type:"Hair",...ra.defaultData,...oH.defaultData},(yc||(yc={})).defaultData={type:"Mesh",...ra.defaultData,...lH.defaultData},(kE||(kE={})).defaultData={...ra.defaultData,...Z1.identity,position:wf.DefaultPosition,rotation:wf.DefaultRotation,...wf.defaultData},(r=>{r.defaultData=function(n){return{...ra.defaultData,...aH.defaultData(n)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(QL||(QL={})),(r=>{function n(s,a,o=0){for(;o<a.length;){let l=s?s[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;s=l.descendants,o+=1}}r.resolveWithDes=n,r.resolve=function(s,a,o=0){let l=n(s,a,o);if(l){let h=Object.keys(l);if(h.length===1&&h[0]==="descendants")return}return l}})(JL||(JL={})),(r=>{function n(s,a){return{...ra.defaultData,...a,component:s,overrides:new Ts,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=n,r.fromComponentData=function(s){let a=Z1.fromObject(s.data);return n(s.id,a)}})(Sf||(Sf={})),(r=>{r.defaultData={type:"Page",...ra.defaultData,physics:{...Dx.defaultData,fusedBody:!1},...uH.defaultData,camera:kE.defaultData,timelines:new ri},r.isUIPage=function(n){return n.uiScene!==void 0}})(Sy||(Sy={})),(i=tie||(tie={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],shear:Ph.zero,name:"Play Camera",visible:!0,raycastLock:!1,physics:Dx.defaultData,states:new Et,events:new Et,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...wf.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",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("RectangleGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("BooleanGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("ShapeBlendGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("TextGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...ra.defaultData,...yc.defaultData,geometry:cf.defaultData("InputGeometry"),material:Un.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(n,s){let a={name:s};return n.type==="Mesh"?(a.geometry={},"material"in n&&(a.material={layers:new Ts}),"materials"in n&&(a.materials=n.materials.map(o=>({layers:new Ts})))):a1.is(n.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(n,s){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:f,...m}=p;if(f!==void 0&&Object.keys(f).length>0){let g={path:[...u,"layers",c,"texture"],props:f,type:0};o.push(g)}if(Object.keys(m).length>0){let g={path:[...u,"layers",c],props:m,type:0};o.push(g)}}}for(let[u,d]of Object.entries(s)){let c=d;if(u!=="name")if(u==="cloner")o.push(...rH.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,f]of Object.entries(c))h(["materials",p],f);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(n,s){if(s===void 0)return n;let a={...n};if(Object.assign(a,Z1.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),a1.is(n.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=s;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(n.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:KL.merge(a.geometry,s.geometry)}),(s.material||s.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=OL(h.material,u=>{if(typeof u!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=u.layers.data(d);p&&ts.patch(p,c)}}).data),h.materials&&l.materials&&(h.materials=OL(h.materials,u=>{for(let d=0;d<h.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,f]of Object.entries(c.layers)){let m=u[d]?.layers?.data(p);m&&ts.patch(m,f)}}}).data),h}(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Ig.merge(a.cloner,s.cloner)});else if(n.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Ig.merge(a.cloner,s.cloner)});else if(sH.is(n.type)){let o=s;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=Ys.clone(o.color))}return a}})(Og||(Og={}))}),DY=F(()=>{(e4||(e4={})).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}}),EB=F(()=>{DY(),eh(),(Tf||(Tf={})).defaultData={orbitControls:e4.defaultData,playPage:Rx,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let i=0,r=0;return t<5?r=-30:t<10&&(r=30),t===0||t===10||t===5?i=30:(t===4||t===11||t===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}}),kbe=F(()=>{var e;(m5||(m5={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(g5||(g5={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(e=ny||(ny={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...m5.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:g5.defaultData}),e.generateSeed=()=>Math.round(1e5*Math.random())}),NY=F(()=>{MB(),Ir(),EB(),eh(),la(),kbe(),(e=>{function t(i,r){let n=i.scene.objects.get(r);if(n&&n.data.type==="Component")return n;{let s=i.shared.lib.components[r];if(s)return{...s.asset,id:r}}}e.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},e.findTimeline=function(i,r){let n=i.find(s=>s.data.type==="Page"&&s.data.timelines?.[r]!==void 0);return n&&n.data.timelines?.[r]},e.getComponentData=t,e.traverseModuleInstances=function(i,r,n){i.scene.objects.traverseFrom(r,(s,a)=>{if(a.type==="Instance"){let o=t(i,a.component)?.data;o&&n(s,a,o.events)}else n(s,a,a.events)})}})(o1||(o1={})),(e=>{function t(r=!0,n=[]){let s=[];r&&s.push({...e.defaultLight}),s.push(...n);let a=new Ea;return a.push({fi:1,id:Rx,data:{...Sy.defaultData,name:"Scene 1"},children:s}),a}function i(r){return{...e.defaultData,objects:Go(r,Ea.prototype)}}e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:QL.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Tf.defaultData,styles:ny.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new Ea,publish:Tf.defaultData,styles:ny.defaultData()}},e.emptyDataWithPage=function(r=!0){return{objects:t(r),publish:Tf.defaultData,styles:ny.defaultData()}},e.emptyData=function(){return{objects:new Ea,publish:{...Tf.defaultData},styles:ny.defaultData()}},e.withObjs=i,e.withObj=function(r,n){return i([{id:r,data:n,children:[],fi:0}])}})(sy||(sy={}))}),Vbe=F(()=>{(VE||(VE={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),IY=F(()=>{var e,t;Ir(),la(),(e=cH||(cH={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new Et}),e.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(iie||(iie={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new Et,queries:new Et,autoStart:!0}),(i=>{function r(s){return s.textValue!==void 0}function n(s){return typeof s=="boolean"}i.isTextValue=r,i.isNumber=function(s){return typeof s=="number"},i.isBoolean=n,i.typeOfVariable=function(s){return r(s)?"string":n(s)?"boolean":"number"},i.getDisplayedValue=function(s){return i.isTextValue(s)?Array.isArray(s.textValue)?s.textValue.map(a=>a.toString().padStart(s.padding??2,"0")).join(s.deliminator??":")+(s.suffix!==void 0?" "+s.suffix:""):s.textValue.toString():i.isBoolean(s)?s?"True":"False":i.isNumber(s)?parseFloat(s.toFixed(3)).toString():s.toString()}})(So||(So={})),(v5||(v5={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(rie||(rie={})).all=[...v5.all,"components"],(nie||(nie={})).defaultData=function(){return{images:new ri,videos:new ri,colors:new ri,audios:new ri,particles:new ri,fonts:new ri,materials:new ri,components:new ri,variables:new ri,userAPIs:new ri,userWebhooks:new ri}},(pf||(pf={})).defaultData=function(){return{images:new ri,videos:new ri,colors:new ri,audios:new ri,particles:new ri,fonts:new ri,materials:new ri,components:new ri,variables:new ri,userAPIs:new ri,userWebhooks:new ri}},(t=fu||(fu={})).defaultColors=function(){return Go({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},ri.prototype)},t.defaultImages=function(){return Go({},ri.prototype)},t.emptyData=function(){return{catelogs:new ri,materials:new ri,images:new ri,videos:new ri,colors:new ri,audios:new ri,particles:new ri,fonts:new ri,variables:new Et,userAPIs:new ri,userWebhooks:new ri,lib:pf.defaultData()}},t.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)}},t.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let n=Math.floor(i/3600),s=Math.floor((i-3600*n)/60);return{textValue:[n,s,Math.round(i-3600*n-60*s)]}}if(r.format==="mm:ss"){let n=Math.floor(i/60);return{textValue:[n,Math.round(i-60*n)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),K4e=F(()=>{}),Gbe=F(()=>{var e;Ir(),NY(),Vbe(),IY(),(e=Ix||(Ix={})).defaultData={schema:136,scene:sy.defaultData,frames:new ri().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",VE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors()}},e.createDefaultData=function(){return LA.deserialize(LA.serialize(e.defaultData))},e.emptyDataForImports=function(){return{schema:136,scene:sy.emptyDataWithPage(),frames:new ri().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",VE.defaultData),shared:{...fu.emptyData(),colors:fu.defaultColors(),images:fu.defaultImages()}}},e.emptyData=function(){return{schema:136,scene:sy.emptyDataWithPage(),frames:new ri().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",VE.defaultData),shared:fu.emptyData()}},e.clipboard2dData=function(){return{schema:136,scene:sy.emptyData(),frames:new ri,shared:fu.emptyData()}},e.withoutLib=function(t){return{...t,shared:{...t.shared,lib:pf.defaultData()}}},e.getComponentData=function(t,i){return o1.getComponentData(t,i)},e.hasSensitiveData=function(t){let i=Object.values(t.shared.userAPIs);for(let r of i){let n=r.headers;for(let s of n)if(s.data.key.toLowerCase()==="authorization"&&s.data.value!=="")return!0}return!1}});function Wf(e,t=[0,0]){return[e&&!isNaN(e[0])?e[0]:t[0],e&&!isNaN(e[1])?e[1]:t[1]]}function $S(e,t,i){switch(e){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:n}=t??{...lw.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${n[0]}, ${n[1]} )`}case 6:{let{mass:r,stiffness:n,damping:s,velocity:a}=i??{...Ng.defaultData},o=new jbe(r,n,s,a),l=o.solve(1);return()=>h=>o.solve(h)/l}case 8:return()=>r=>Math.floor(r)}}function Z4e(e){let t=function(r){return r.layers?.find(({data:n})=>n.type==="light")}(e);if(!t)return;let i=t.data.alphaOverride;return typeof i=="number"?i:1}function Q4e(e,t,i){return i>0?e*t/i:e}var sie,aie,Wg,zA,jbe,t4,i4,OY=F(()=>{Ir(),eh(),(sie||(sie={})).defaultData=function(e,t){return{id:e,name:t,duration:5,objectTimelines:new ri}},(aie||(aie={})).is=function(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"},(e=>{function t(u,d){let c=[0,0],p=[1,1];if(u?.cubicControls)c=Wf(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=Wf(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(!e.BEZIER_PRESETS.includes(u))return;let d={type:u};return{control1:t(d).control1,control2:t(void 0,d).control2}}function r(u,d){return Math.abs(u[0]-d[0])<.001&&Math.abs(u[1]-d[1])<.001}function n(u){let d=e.ROOT_PROPERTY_ORDER.indexOf(u[0]);return d===-1?e.ROOT_PROPERTY_ORDER.length:d}function s(u){return u.layerId??u.path.join(".")}function a(u){let d=u[u.length-1];return zA.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]}}}}}e.getControlsWithDefault=t,e.BEZIER_PRESETS=[0,1,2,3,4,7],e.presetHandles=i,e.presetForHandles=function(u){return e.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,u.control1)&&r(c.control2,u.control2)})},e.defaultData=function(u){return{id:u,keyframes:new Et}},e.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],e.rowOrder=n,e.propertyKey=s,e.groupKeyframes=function(u,d){let c=new Map;for(let p of u){let f=p.data;if(d?.(f))continue;let m=s(f),g=c.get(m);g||(g={id:m,path:f.path,keyframes:[],layerId:f.layerId,index:f.index},c.set(m,g)),f.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,f)=>{let m=n(p.path)-n(f.path);return m!==0?m:(p.index??0)-(f.index??0)})},e.rowAxis=a,e.drawnRowKey=o,e.drawnRows=function(u){let d=new Map;for(let c of u){let p=a(c.path),f=p?c.path.slice(0,-1):c.path,m=o(c),g=d.get(m);g||(g={id:m,path:f,layerId:c.layerId,index:c.index,tracks:[]},d.set(m,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},e.sortedKeyframes=function(u){return[...u].sort((d,c)=>d.data.time-c.data.time)},e.materialLayerPath=l,e.createMaterialGroup=function(u,d){return u.map(({data:c,id:p},f)=>h(d(),l(c),{layerId:p,index:f}))},e.placeholderKeyframe=h,e.createName=function(u){return Object.entries(u).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:$S(3),duration:1e3},opacity:{value:[0,1],easing:$S(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:$S(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:$S(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:$S(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Wg||(Wg={})),zA=["x","y","z"],jbe=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),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(e){return 1-(this.m_zeta<1?Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0))}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,this.solve(t)===1){if(i++,i>=16)break}else i=0;return t*e*1e3}}}),LY=F(()=>{var e;eh(),Ir(),(t4||(t4={})).list=["idle","move","jump","run"],(e=i4||(i4={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.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:e.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 Et,move:new Et,jump:new Et,run:new Et},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:kr.fromHexAndA(3728051,1)}}});function Gv(e,...t){let i={};for(let r of t.flat())e!=null&&r in e&&(i[r]=e[r]);return i}function oie(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,n=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)n.push(n[1]),s.push(1);let a={...Gv(Ds(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Ds(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Zp(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Qp(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=Un.defaultTwoLayerData("phong"),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Un.defaultTwoLayerData("phong")),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Un.defaultTwoLayerData("phong")),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&Object.getPrototypeOf(n.material)!==Ts.prototype&&t(n.material)})})}function lie(e){e.layers===void 0&&Object.assign(e,Un.defaultTwoLayerData("lambert"))}function y5(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...Ds(t),colors:i,steps:r};Object.assign(t,n)}})}function hie(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&y5(r)}):"material"in i&&typeof i.material!="string"&&y5(i.material)}),Object.values(e.shared.materials).forEach(t=>y5(t))}function uie(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function die(e){e.layers&&e.layers.forEach(t=>{(function(i){return i.type!=="displace"})(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function cie(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=ts.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function pie(e){Zp(e,cie),Qp(e,cie)}function fie(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function mie(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}var J4e=F(()=>{lC(),eh(),DY(),MB(),Ir(),EB(),la(),ne(),CY(),LY(),kbe(),NY(),AY(),RY()});function Wbe(e){let t=e.elements;ud.set(t[0],t[1],t[2]),dd.set(t[4],t[5],t[6]),Mc.set(t[8],t[9],t[10])}function Hbe(){let e=Math.max(ud.lengthSq(),dd.lengthSq(),Mc.lengthSq());ud.lengthSq()>WM*e?Th.copy(ud).normalize():Th.set(1,0,0),Mh.crossVectors(Mc,Th),Mh.lengthSq()<=WM*e&&(Mh.copy(dd).addScaledVector(Th,-dd.dot(Th)),Mh.lengthSq()<=WM*e&&function(t,i){t.set(1,0,0).cross(i),t.lengthSq()<=WM&&t.set(0,1,0).cross(i),t.normalize()}(Mh,Th)),Mh.normalize(),ay.crossVectors(Th,Mh)}function qbe(e,t,i){return Wbe(e),Hbe(),t.makeBasis(Th,Mh,ay),i.set(Th.dot(ud),Th.dot(dd),Th.dot(Mc),0,Mh.dot(ud),Mh.dot(dd),Mh.dot(Mc),0,ay.dot(ud),ay.dot(dd),ay.dot(Mc),0,0,0,0,1),function(){let r=ud.length(),n=dd.length(),s=Mc.length(),a=Math.max(r,n,s);if(a-r>HM||a-n>HM||a-s>HM)return!0;let o=HM*a*a;return Math.abs(ud.dot(dd))>o||Math.abs(ud.dot(Mc))>o||Math.abs(dd.dot(Mc))>o}()}function $be(e){return Wbe(e),Hbe(),Xbe.makeBasis(Th,Mh,ay)}var ud,dd,Mc,Th,Mh,ay,Xbe,WM,HM,AB=F(()=>{ne(),ud=new P,dd=new P,Mc=new P,Th=new P,Mh=new P,ay=new P,Xbe=new De,WM=1e-12,HM=.01});function Q1(e,t){return t===0?0:e/t}function BY(e){qbe(e,fH,pH),hx.setFromRotationMatrix(fH);let t=function(r,n,s){let a=2*Math.PI,o=d=>d-a*Math.round(d/a),l=o(r+Math.PI),h=o(Math.PI-n),u=o(s+Math.PI);return Math.abs(l)+Math.abs(u)<Math.abs(r)+Math.abs(s)-1e-9?[l,h,u]:[r,n,s]}(hx.x,hx.y,hx.z),i=pH.elements;return{position:[e.elements[12],e.elements[13],e.elements[14]],rotation:[t[0]*Qe.RAD2DEG,t[1]*Qe.RAD2DEG,t[2]*Qe.RAD2DEG],scale:[i[0],i[5],i[10]],shear:[Q1(i[4],i[5]),Q1(i[8],i[10]),Q1(i[1],i[0]),Q1(i[9],i[10]),Q1(i[2],i[0]),Q1(i[6],i[5])]}}function Mf(e,{translation:t,quaternion:i,scale:r,shearMatrix:n}={}){let s=BY(e);if(t!==void 0&&t.fromArray(s.position),i!==void 0){let a=s.rotation;i.setFromEuler(hx.set(a[0]*Qe.DEG2RAD,a[1]*Qe.DEG2RAD,a[2]*Qe.DEG2RAD))}r!==void 0&&r.fromArray(s.scale),n!==void 0&&n.fromArray(Ph.toMatrix(s.shear))}var pH,fH,hx,hC=F(()=>{ne(),AB(),Axe(),pH=new De,fH=new De,hx=new Rr});function Ybe(e){return e.length>=4&&function(t){return typeof t=="object"&&t!==null&&t.v===1&&t.data instanceof Float32Array&&Array.isArray(t.tracks)}(e[3])}function Kbe(e,t,i){let r={name:t,duration:i.duration,tracks:[],uuid:e};return i.blendMode!==void 0&&(r.blendMode=i.blendMode),JSON.stringify(r)}function eBe(e,t,i){for(let r=0;r<i.length;r++)if(!Object.is(e[t+r],i[r]))return!1;return!0}function tBe(e){if(!Array.isArray(e)||e.length>3)return e;let t,[i,r,n]=e;if(typeof i!="string"||typeof n!="string")return e;try{t=JSON.parse(n)}catch{return e}return t&&Array.isArray(t.tracks)&&!t.tracks.some(s=>!s?.type||!s.times||!s.values)?function(s,a,o){let l=[],h=0,u=g=>{let v=[h,g.length];return l.push(g),h+=g.length,v},d=new Map,c=o.tracks.map(g=>{let v=(b=>{let x=Float32Array.from(b),w=x.length+":"+x[0]+":"+x[x.length-1],S=d.get(w)??[];for(let M of S)if(eBe(M.run,0,x))return M.span;let T=u(x);return S.push({span:T,run:x}),d.set(w,S),T})(g.times),y=!Zbe.has(g.type),_={name:g.name,type:g.type,times:v,values:y?u(Float32Array.from(g.values)):[0,0]};return y||(_.list=Array.from(g.values)),g.interpolation!==void 0&&(_.interpolation=g.interpolation),_}),p=new Float32Array(h),f=0;for(let g of l)p.set(g,f),f+=g.length;let m={v:1,duration:o.duration,data:p,tracks:c};return o.blendMode!==void 0&&(m.blendMode=o.blendMode),o.userData!==void 0&&o.userData!=="{}"&&(m.userData=o.userData),[s,a,Kbe(s,a,m),m]}(i,typeof t.name=="string"?t.name:r,t):e}function iBe(e,t,i){return e.map(r=>{let n=t();return i[r[0]]=n,function(s,a){let[o,l,h]=s;if(Ybe(s))return[a,l,Kbe(a,l,s[3]),s[3]];let u=h.indexOf(o);return[a,l,u!==-1?h.slice(0,u)+a+h.slice(u+o.length):h,...s.slice(3)]}(r,n)})}var Zbe,Qbe=F(()=>{Zbe=new Set(["bool","string"])});function R3(e,[t,i]){return Math.min(Math.max(e,t),i)}function Jbe(e,t,i,r,n){e=R3(e,nxe),t=R3(t,sxe),i=R3(i,axe),r=R3(r,oxe);let s=Math.sqrt(t/e),a=i/(2*Math.sqrt(t*e)),o=a<1?s*Math.sqrt(1-a*a):0,l=a<1?(a*s-r)/o:-r+s;return h=>{let u=n!==void 0?n*h:h;return u=a<1?Math.exp(-u*a*s)*(1*Math.cos(o*u)+l*Math.sin(o*u)):(1+l*u)*Math.exp(-u*s),h===0||h===1?h:1-u}}function exe(e,t){return Bi(Bi(1-Bi(3*t))+Bi(3*e))}function txe(e,t){return Bi(Bi(3*t)-Bi(6*e))}function ixe(e){return Bi(3*e)}function D3(e,t,i){return Bi(Bi(Bi(Bi(Bi(exe(t,i)*e)+txe(t,i))*e)+ixe(t))*e)}function gie(e,t,i){let r=Bi(Bi(Bi(3*exe(t,i))*e)*e),n=Bi(Bi(2*txe(t,i))*e);return Bi(Bi(r+n)+ixe(t))}function J1(e,t,i,r){if(e=Bi(e),t=Bi(t),i=Bi(i),r=Bi(r),e<0||e>1||i<0||i>1||e===t&&i===r)return cxe;let n=new Float32Array(ZI);for(let s=0;s<ZI;s++)n[s]=D3(Bi(s*qM),e,i);return s=>(s=Bi(s))===0||s===1?s:D3((a=>{let o=0,l=1,h=ZI-1;for(;l!==h&&n[l]<=a;)o=Bi(o+qM),l+=1;l-=1;let u=Bi(Bi(a-n[l])/Bi(n[l+1]-n[l])),d=Bi(o+Bi(u*qM)),c=gie(d,e,i);return c>=hxe?function(p,f,m,g){for(let v=0;v<lxe;v++){let y=gie(f,m,g);if(y===0)return f;let _=Bi(D3(f,m,g)-p);f=Bi(f-Bi(_/y))}return f}(a,d,e,i):c===0?d:function(p,f,m,g,v){let y,_=0,b=0;do _=Bi(f+Bi(Bi(m-f)/2)),y=Bi(D3(_,g,v)-p),y>0?m=_:f=_,b+=1;while(Math.abs(y)>uxe&&b<dxe);return _}(a,o,Bi(o+qM),e,i)})(s),t,r)}function rxe(e,t,i){switch(e.easing){case 0:default:return i;case 1:return J1(.25,.1,.25,1)(i);case 2:return J1(.42,0,1,1)(i);case 3:return J1(0,0,.58,1)(i);case 4:return J1(.42,0,.58,1)(i);case 7:return J1(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:r,control2:n}=e;return r&&n?J1(r[0],r[1],n[0],n[1])(i):i}case 6:{let{mass:r,stiffness:n,damping:s,velocity:a}=e;return r===void 0||n===void 0||s===void 0||a===void 0?i:Bi(Jbe(r,n,s,a,t)(i))}}}var Bi,nxe,sxe,axe,oxe,lxe,hxe,uxe,dxe,ZI,qM,cxe,vie,rBe=F(()=>{Bi=Math.fround,nxe=[.01,100],sxe=[.01,1e4],axe=[.01,1e3],oxe=[.01,1e3],lxe=4,hxe=Bi(.001),uxe=Bi(1e-7),dxe=10,qM=Bi(1/((ZI=11)-1)),cxe=e=>e,vie=Bi(1.70158),Bi(vie+1)});function pxe(e,t){if(e.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(t<=e[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 f=c+Math.floor(d/2),m=h[f].time;if(m<u)c=f+1;else{if(!(m>u))return{found:!0,index:f};p=f}d=p-c}return{found:!1,index:c}}(e,t);if(i)return{index0:r,index1:r,t:1};if(r>=e.length){let h=e.length-1;return{index0:h,index1:h,t:1}}let n=r-1,s=r,a=e[n].time,o=e[s].time;if(o===a)return{index0:n,index1:s,t:.5};let l=QI(o-a);return{index0:n,index1:s,t:rxe({...e[n].ease,control2:e[s].ease.control2},l,QI(QI(t-a)/l))}}function fxe(e){return[...e].sort((t,i)=>t.time-i.time)}var QI,nBe=F(()=>{rBe(),QI=Math.fround});function sBe(e){if(e?.length!==2)return;let t=`${e[0]}.${e[1]}`;return FY.includes(t)?t:void 0}function mxe(e){return e.slice(0,e.indexOf("."))}function gxe(e){return Hg.indexOf(e.slice(-1))}function aBe(e){return{easing:e?.type,control1:Wf(e?.cubicControls?.control1,[0,0]),control2:Wf(e?.cubicControls?.control2,[1,1]),...e?.springParameters}}function oBe(e){let t=e?.cubicControls;return{...e,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...e?.springParameters?{springParameters:{...e.springParameters}}:{}}}function yie(e,t,i){let r=mxe(e);if(r==="position"){let n=gxe(e);return Hg.flatMap((s,a)=>Math.abs(t.elements[4*a+n])>1e-9?[`position.${s}`]:[])}return(i?[r]:["rotation","scale"]).flatMap(n=>Hg.map(s=>`${n}.${s}`))}function lBe(e,t){let[i,r,n]=e,s=[[i,r,n],[i+180,180-r,n+180]],a=[i,r,n],o=1/0;for(let l of s){let h=l.map((d,c)=>d+360*Math.round((t[c]-d)/360)),u=h.reduce((d,c,p)=>d+Math.abs(c-t[p]),0);u<o-1e-9&&(a=h,o=u)}return a}function hBe(e,t,i){if(e==="rotation"){let r=((t-i)%360+540)%360-180;return Math.abs(r)<1e-6}return Math.abs(t-i)<1e-9*Math.max(1,Math.abs(t),Math.abs(i))}function uBe(e,t,i,r){let n=new Map;for(let{id:p,data:f}of e.unproxy()){if(f.isPlaceholder)continue;let m=sBe(f.path);if(!m){if($M.includes(f.path?.[0]))return;continue}if(typeof f.value!="number"||!Number.isFinite(f.value))return;let g=n.get(m)??{keys:[],sampled:[]};g.keys.push({id:p,time:f.time,value:f.value,keyframe:f}),n.set(m,g)}if(n.size===0)return;for(let p of n.values())p.keys.sort((f,m)=>f.time-m.time),p.sampled=fxe(p.keys.map(f=>({time:f.time,ease:aBe(f.keyframe.easing),value:f.value})));let s=(p,f)=>{let m=n.get(p);return m?function(g,v){let{index0:y,index1:_,t:b}=pxe(g.sampled,v),x=g.sampled[y].value;return x+(g.sampled[_].value-x)*b}(m,f):i[mxe(p)][gxe(p)]},a=new Vt,o=new Rr,l=new De,h=new P,u=new P,d=p=>{let f=(m=>{let g={};for(let v of $M)g[v]=Hg.map((y,_)=>s(FY[3*$M.indexOf(v)+_],m));return g})(p);return o.set(f.rotation[0]*Qe.DEG2RAD,f.rotation[1]*Qe.DEG2RAD,f.rotation[2]*Qe.DEG2RAD),l.compose(h.fromArray(f.position),a.setFromEuler(o),u.fromArray(f.scale)).premultiply(t),{pose:f,out:BY(l)}},c=function(p){let f=p.elements,m=[0,4,8].map(y=>new P(f[y],f[y+1],f[y+2])),g=m[0].lengthSq(),v=1e-9*Math.max(1,g);return Math.abs(m[1].lengthSq()-g)<v&&Math.abs(m[2].lengthSq()-g)<v&&Math.abs(m[0].dot(m[1]))<v&&Math.abs(m[0].dot(m[2]))<v&&Math.abs(m[1].dot(m[2]))<v}(t);for(let p of $M){let f,m=Hg.map(_=>`${p}.${_}`),g=_=>{let b=new Set;for(let x of yie(_,t,c))for(let w of n.get(x)?.keys??[])b.add(w.time);return[...b].sort((x,w)=>x-w)},v=[...new Set(m.flatMap(_=>g(_)))].sort((_,b)=>_-b),y=new Map;for(let _ of v){let{pose:b,out:x}=d(_),w=[...x[p]];p==="rotation"&&(w=lBe(w,f?f.out.map((S,T)=>S+b.rotation[T]-f.in[T]):b.rotation),f={in:b.rotation,out:w}),y.set(_,w)}m.forEach((_,b)=>{let x=n.get(_)?.keys??[],w=g(_),S=new Set(w);if(x.length!==0||!w.every(T=>hBe(p,y.get(T)[b],r[p][b]))){for(let T of x)S.has(T.time)||e.delete(T.id);for(let T of w){let M=y.get(T)[b],E=x.find(D=>D.time===T);if(E){let D=e.data(E.id);D&&(D.value=M);continue}let A=yie(_,t,c).sort((D,R)=>Number(R===_)-Number(D===_)).map(D=>n.get(D)?.keys.find(R=>R.time===T)).find(D=>D!==void 0),C=Qe.generateUUID();e.insertBefore(null,[{id:C,data:{id:C,time:T,path:[p,Hg[b]],value:M,easing:oBe(A.keyframe.easing),index:Wg.rowOrder([p])}}])}}})}}var $M,Hg,FY,dBe=F(()=>{ne(),OY(),nBe(),hC(),Hg=["x","y","z"],FY=($M=["position","rotation","scale"]).flatMap(e=>Hg.map(t=>`${e}.${t}`))}),vxe={};function _ie(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function yxe(e){let t=e.geometry;t!==void 0&&Txe.has(t.type)&&t.extrusionVersion===void 0&&(t.extrusionVersion=1)}function _xe(e){if(e.type!=="Empty")return;let t=Ds(e.animations);if(!Array.isArray(t))return;let i=t.map(tBe);i.some((r,n)=>r!==t[n])&&(e.animations=i)}function bie(e,t){let[i,r,n]=e,s=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(n),u=Math.sin(n),d=[o*h,s*u+a*h*l,a*u-s*h*l],c=Math.hypot(t[0],t[1],t[2])||1;return Math.abs((d[0]*t[0]+d[1]*t[1]+d[2]*t[2])/c)}function bxe(e){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*sg)})(e),e.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(n,s){let a=Array.isArray(s)&&s.length>=3&&s.every(h=>typeof h=="number"&&Number.isFinite(h))?s:[0,1,0],o=bie(n,a),l=bie(n.map(h=>h*Mxe),a);return Math.abs(o-l)<1e-6?n.some(h=>Math.abs(h)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(n=>n*sg)}(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*sg))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*sg),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*sg),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=sg,t.extrusion.twist*=sg),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(Ds(e.events))&&e.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 cBe(e){e.scene.objects.traverse((t,i)=>{})}function pBe(e){let t=e.schema??104;t!==136&&(t<130&&(UY(e.asset),e.schema=130),t<135&&(zY(e.asset),e.schema=135),t<136&&(kY(e.asset),e.schema=136))}function rd(e,t){t(e.data);for(let i of e.children)rd(i,t)}function xxe(e){let t=e.schema??104;t!==136&&(t<105&&(rd(e.asset,bxe),e.schema=105),t<118&&(rd(e.asset,wxe),e.schema=118),t<121&&(rd(e.asset,gH),e.schema=121),t<130&&(rd(e.asset,i=>_5(i,UY)),e.schema=130),t<132&&(rd(e.asset,yxe),e.schema=132),t<133&&(rd(e.asset,i=>Sxe(i,()=>{})),e.schema=133),t<134&&(rd(e.asset,_xe),e.schema=134),t<135&&(rd(e.asset,i=>_5(i,zY)),e.schema=135),t<136&&(rd(e.asset,i=>_5(i,kY)),e.schema=136))}function JI(e,t){Qp(e,t),Zp(e,t),Object.values(e.shared.lib.materials).forEach(i=>t(i.asset))}function UY(e){e.layers===void 0&&Object.assign(e,Un.defaultTwoLayerData("phong"))}function zY(e){let t=lx(e),i=Un.withRepairedLayers(t);i!==t&&(e.layers=i.layers)}function kY(e){let t=lx(e),{material:i,restored:r}=Un.restoreLayersSeq(t);r&&(e.layers=i.layers)}function _5(e,t){"materials"in e?e.materials.forEach(i=>{i!==void 0&&typeof i!="string"&&t(i)}):"material"in e&&e.material!==void 0&&typeof e.material!="string"&&t(e.material)}function wxe(e){e.timelineAnimations=Go({},ri.prototype)}function fBe(e){let t=[];return e?(e.forEach((i,r)=>{let{path:n,keyframes:s}=i.data,a=n[0]==="material"?i.id:void 0;s?.length?s.forEach(({id:o,data:l})=>{t.push({id:o,data:{...l,path:n,layerId:a,index:r}})}):t.push(Wg.placeholderKeyframe(i.id,n,{layerId:a,index:r}))}),t.sort((i,r)=>i.data.time-r.data.time),new Et(...t.map((i,r)=>({...i,fi:r})))):new Et}function mBe(e){for(let{id:t,data:i}of[...e.unproxy()]){let r=i.path?.[0];if(!r||!Exe.includes(r))continue;let n=mH(i.value);if(!n.length)continue;let s=e.data(t);if(!s)continue;let a=i.value,[o,...l]=n;for(let h of l){let u=Qe.generateUUID();e.insertBefore(null,[{id:u,data:{...i,id:u,path:[r,h],value:a[h],easing:gBe(i.easing)}}])}s.path=[r,o],s.value=a[o]}}function mH(e){return e===null||typeof e!="object"?[]:zA.filter(t=>t in e)}function gBe(e){let t=e?.cubicControls;return{...e,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...e?.springParameters?{springParameters:{...e.springParameters}}:{}}}function vBe(e,t){return Math.abs(e[0]-t[0])<1e-6&&Math.abs(e[1]-t[1])<1e-6}function yBe(e){let t=function(s){let a=[];for(let o of Wg.groupKeyframes(s)){let l=new Set(o.keyframes.flatMap(u=>mH(u.data.value))),h=l.size?[...l].map(u=>o.keyframes.filter(d=>mH(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}([...e.unproxy()]),i=new Map,r=new Set;for(let{left:s,right:a}of t){let o=s.data.easing?.type,l=(o===void 0?void 0:Wg.presetHandles(o))?.control2??(o===5?Wf(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let h=i.get(a.id);h?vBe(h,l)||r.add(a.id):i.set(a.id,l)}let n=new Map;for(let{id:s,data:a}of e.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Wg.presetHandles(o);l&&n.set(s,l.control1)}for(let{left:s,right:a}of t)r.has(a.id)&&n.delete(s.id);for(let[s,a]of n){let o=e.data(s);!o?.easing||(o.easing.cubicControls={control1:a,control2:Wf(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:s,right:a}of t){if(!n.has(s.id))continue;let o=e.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Wf(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function xie(e,t){e.scene.objects.traverse((i,r)=>{let n=r;if(n.type==="Page"&&n.timelines)for(let s of Object.values(n.timelines))for(let a of Object.values(s.objectTimelines??{}))t(a.keyframes)})}function gH(e){e.pivot=[0,0,0],e.pivotRotation=[0,0,0]}function Sxe(e,t,i=[]){let r=["position","rotation","scale","shear"];function n(c,p,f){return c?.map(m=>typeof m=="string"?t(m)??f:m)??[...p]}function s(c,p){if(c&&!function(f){return f.every((m,g)=>Math.abs(m-(g%5==0?1:0))<1e-6)}(c))return BY(new De().fromArray(c).multiply(new De().compose(new P().fromArray(p.position),new Vt().setFromEuler(new Rr(p.rotation[0]*Qe.DEG2RAD,p.rotation[1]*Qe.DEG2RAD,p.rotation[2]*Qe.DEG2RAD)),new P().fromArray(p.scale))))}function a(c,p){return c.length===p.length&&c.every((f,m)=>f===p[m])}e.shear=Ph.zero;let o=e,l=o.hiddenMatrix;l!==void 0&&delete o.hiddenMatrix;let h={position:n(o.position,[0,0,0],0),rotation:n(o.rotation,[0,0,0],0),scale:n(o.scale,[1,1,1],1)},u=s(l,h);if(u&&Object.assign(o,u),u){let c=new De().fromArray(l);for(let p of i)uBe(p,c,h,u)}let d=u??{...h,shear:[...Ph.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 f={position:n(c.position,h.position,0),rotation:n(c.rotation,h.rotation,0),scale:n(c.scale,h.scale,1)},m=s(p??l,f);if(!u&&!m)return;let g=m??{...f,shear:[...Ph.zero]};for(let v of r)(c[v]!=null||!a(g[v],d[v]))&&(c[v]=g[v])})}function _Be(e){}function bBe(e){let t=e.schema??0;if(t!==136){if(t>136)return void console.error(`This scene was created with a newer version of Spline (file format ${t}, this runtime reads 136). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",t,"to ",136),function(i,r){if(r<1&&(Qp(i,oie),Zp(i,oie),i.schema=1),r<2&&(function(n){Object.assign(n.scene.publish,{orbitControls:{...e4.defaultData,...Ds(n.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(n){function s(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,h]of Object.entries(o))if((TB.includes(l)||typeof h=="boolean")&&delete o[l],l==="texture")for(let[u,d]of Object.entries(h))(MY.includes(u)||typeof d=="boolean")&&delete h[u]}}}n.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let h=l;h.material?s(h.material):h.materials&&h.materials.forEach(u=>{s(u)})})})}(i),i.schema=3),r<4&&(function(n){n.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(n){n.scene.objects.traverse((s,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(n){n.scene.objects.traverse((s,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&&(hie(i),i.schema=9),r<10&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((s,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(hie(i),i.schema=12),r<13&&(function(n){n.shared.audios=Go({},ri.prototype)}(i),i.schema=13),r<14&&(function(n){let s=n.shared.materials;Object.entries(s).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(s,{[a]:l})}})}(i),i.schema=14),r<15&&(function(n){Object.entries(Ds(n.shared.images)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.images[s]}),Object.entries(Ds(n.shared.audios)).filter(s=>s[1].asset===!1).map(s=>s[0]).forEach(s=>{delete n.shared.audios[s]})}(i),i.schema=15),r<16&&(function(n){n.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Qp(i,uie),Zp(i,uie),i.schema=17),r<18&&(Qp(i,lie),Zp(i,lie),i.schema=18),r<19&&(function(n){Object.assign(n.scene.publish.settings,{video:{...Tf.defaultData.settings.video,...Ds(n.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(n){n.shared.fonts=Go({},ri.prototype)}(i),function(n){let s=[];n.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let h=Un.defaultTwoLayerData("phong"),u=typeof l.color=="string"?n.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(f){return f.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(m=>m.charAt(0).toUpperCase()+m.slice(1)).join(" ")}(l.font);n.shared.fonts[d]===void 0&&(n.shared.fonts[d]={name:d});let c={name:l.name,...ra.defaultData,...yc.defaultData,flatShading:!1,wireframe:!1,geometry:{...cf.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:Ds(l.states),events:Ds(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Ds(n.scene.objects).parent(a);n.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),s.push(a)}}),s.forEach(a=>{n.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(n){let s={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(s[Number(l.type)])if(Object.assign(l,{type:s[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 Et,move:new Et,jump:new Et}});else{let h=new Et;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:Qe.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,Gv(u,"mass","stiffness","damping","velocity")):u.easing===5&&Object.assign(p,{control1:{...u.control1},control2:{...u.control2}});let f={repeat:u.repeat?-1:0,delay:u.delay,delayDirection:u.delayDirection,direction:u.cycle&&u.rewind?"pingpong-rewind":u.cycle?"pingpong":"normal"},m={state:u.state,...f,...p},g={allowSlerp:!0,type:"Transition",object:u.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Et({fi:0,id:Qe.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:Qe.generateUUID(),data:m})};h.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(n){n.scene.objects.traverse((s,a)=>{function o(l,h){let u=new Et,d=[];if(a.events.forEach((c,p,f)=>{if(c.type==="Audio"&&c.trigger===h){let m;d.push(p),c.interaction==="play"?m={...Gv(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")&&(m={...Gv(c,"interaction","delay","object","playAudio"),type:"Audio"}),m&&u.push({fi:f,id:p,data:m})}}),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:Qe.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&&(pie(i),i.schema=22),r<23&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(n){n.scene.objects.traverse((s,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(n){n.shared.videos=Go({},ri.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(n){n.scene.objects.traverse((s,a)=>{let o=n.scene.objects.unproxy().parent(s);if(o){let l=Ds(n.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Ds(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(n){n.scene.objects.traverse((s,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&&(pie(i),i.schema=28),r<29&&(function(n){function s(o){Object.setPrototypeOf(o,Ts.prototype),o.texture&&Object.setPrototypeOf(o.texture,Ts.prototype)}function a(o){Object.setPrototypeOf(o,Ts.prototype);for(let l in o)s(o[l])}n.scene.objects.traverse((o,l)=>{l.states.forEach(h=>{let u=h;if(u.material){let d=Ds(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=Ds(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(n){n.scene.objects.traverse((s,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=Un.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((s,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(n){n.scene.objects.traverse((s,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(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(n){let{video:s}=n.scene.publish.settings;s.format==="gif"&&s.fps>48&&(s.fps=15)}(i),i.schema=35),r<36&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(n){let s=n.scene.environment.usePhysics;n.scene.objects.traverse((a,o)=>{s&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Qp(i,die),Zp(i,die),i.schema=38),r<39&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=i4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(n){n.scene.styles||(n.scene.styles=ny.defaultData())}(i),i.schema=40),r<41&&(function(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Qp(n,fie),Zp(n,fie)}(i),i.schema=41),r<42&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new Et})})})}(i),i.schema=42),r<43&&(function(n){n.scene.objects.traverse((s,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Qp(i,mie),Zp(i,mie),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=f1);let n=Ds(i.scene.objects),s=i.scene.objects;i.scene.publish.playPage=Rx,s.insertBefore(null,null,[{id:Rx,data:{...Sy.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Gv(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Gv(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Nx.defaultData,...Gv(i.scene.environment,"usePhysics","gravity")},camera:Ds(i.scene.ownerCamera)??Sy.defaultData.camera,name:"Scene"},children:[]}]);for(let l of n)l.id!==sy.TRASH_CAN_ID&&s.move(Rx,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,Dx.defaultData)),h.physics!==void 0&&h.physics!==null&&(h.physics.enabled=h.collision??"visibility",delete h.collision)}),i.schema=99}}(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Tf.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Qp(e,_ie),Zp(e,_ie),e.schema=101),t<102&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.geometry;s&&s.type==="PathGeometry"&&(s.extrusion.capType="flat",s.extrusion.bevel=50,s.extrusion.bevelSides=6,s.extrusion.shape.type==="Custom"&&(s.extrusion.shape.shapeQuality="low"))})}(e),e.schema=102),t<104&&(e.shared.catelogs=new ri,e.shared.lib=pf.defaultData(),e.schema=104),t<105&&(function(i){i.shared.variables=Go({},ri.prototype)}(e),e.scene.objects.traverse((i,r)=>{bxe(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))xxe(i);if(t<106&&(function(i){let r=Ds(i.shared.variables);i.shared.variables=Go(Object.entries(r??{}).map(([n,s],a)=>({fi:a,id:n,data:s})),Et.prototype)}(e),e.schema=106),t<107&&(e.shared.lib.variables=pf.defaultData().variables,e.schema=107),t<109&&(function(i){i.shared.particles=Go({},ri.prototype),i.shared.lib&&(i.shared.lib.particles=pf.defaultData().particles)}(e),e.schema=109),t<110&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Particle"&&typeof n.renderMaterial.size=="number"&&Object.assign(n.renderMaterial,{size:[n.renderMaterial.size,n.renderMaterial.size]})})}(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{(function(n){Array.isArray(Ds(n.events))&&n.events?.forEach(s=>{"disabled"in s||(s.disabled=!1),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress")&&(s.mode=s.mode||"Object")})})(r)}),e.schema=111),t<112&&(function(i){i.scene.objects.traverse((r,n)=>{n.type==="Page"&&(n.postprocessing.depthOfField.focusDistance=100,n.postprocessing.depthOfField.focalLength=20,n.postprocessing.depthOfField.bokehScale=5)})}(e),e.schema=112),t<113&&(function(i){i.scene.objects.traverse((r,n)=>{Array.isArray(Ds(n.events))!==!1&&n.events?.forEach(s=>{let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?s.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")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(o=>{s.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,s.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),s.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,s.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):s.type==="Start"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?s.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,s.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),s.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(function(i){i.shared.userAPIs=Go({},ri.prototype),i.shared.userWebhooks=Go({},ri.prototype),i.shared.lib&&(i.shared.lib.userAPIs=pf.defaultData().userAPIs,i.shared.lib.userWebhooks=pf.defaultData().userWebhooks)}(e),e.schema=115),t<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Tf.defaultData.settings.videoStatic)}(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117),t<118&&(e.shared.timelineAnimations=Go({},ri.prototype),e.scene.objects.traverse((i,r)=>{wxe(r)}),e.schema=118),t<119&&(e.scene.publish.settings.videoStatic.format=Ix.defaultData.scene.publish.settings.videoStatic.format,e.scene.publish.settings.videoStatic.imageFormat=Ix.defaultData.scene.publish.settings.videoStatic.imageFormat,e.schema=119),t<120&&(e.scene.publish.settings.image.colorSpace="display-p3",e.scene.publish.settings.videoStatic.colorSpace="display-p3",e.schema=120),t<121&&(e.scene.objects.traverse((i,r)=>{gH(r),r.type==="Page"&&r.camera!==void 0&&gH(r.camera)}),e.schema=121),t<122&&(delete e.scene.publish.settings.video,e.scene.publish.orbitControls.rotationSpeed=Ix.defaultData.scene.publish.orbitControls.rotationSpeed,e.schema=122),t<123&&(e.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=wg.defaultData)}),e.schema=123),t<124&&(t>=123&&e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(typeof n.exposure=="number"&&(n.exposure=Math.round(n.exposure/5e-4*1e4)/1e4),n.lighting===void 0&&(n.lighting=wg.defaultData.lighting))}),e.schema=124),t<125&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingIntensity===void 0&&(n.lightingIntensity=wg.defaultData.lightingIntensity)}),e.schema=125),t<126&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&(n.mode===void 0&&(n.mode="physical"),n.hdri===void 0?n.hdri={...wg.defaultData.hdri}:(n.hdri.blur===void 0&&(n.hdri.blur=wg.defaultData.hdri.blur),Array.isArray(n.hdri.rotation)&&(n.hdri.rotation=n.hdri.rotation[1]??0)))}),e.schema=126),t<127&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n?.hdri!==void 0&&n.hdri.showBackground===void 0&&(n.hdri.showBackground=!0)}),e.schema=127),t<128&&(e.scene.objects.traverse((i,r)=>{let n=r.sky;r.type==="Page"&&n!==void 0&&n.lightingQuality===void 0&&(n.lightingQuality="full")}),e.schema=128),t<129&&(e.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=Sy.defaultData.camera);let n=r.camera;n.far=1e5,n.perspective?n.perspective.near=70:n.perspective={near:70,fov:45,zoom:1}}}),e.schema=129),t<130&&(JI(e,UY),e.schema=130),t<131&&(function(i){i.scene.objects.traverse((r,n)=>{let s=n.states;if(!s)return;let a=n.timelineAnimations,o=[];s.forEach((l,h)=>{(l.isAnimation||a?.[h])&&o.push(h)}),o.forEach(l=>s.delete(l))})}(e),function(i){let r=i.shared,n=r.timelineAnimations;if(!n)return;let s=i.scene.objects,a=s.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(n)){let h=Go({},ri.prototype),u=0,d=Boolean(l.loop);for(let[f,m]of Object.entries(l.mapping??{})){let g=s.data(f)?.timelineAnimations?.[m];!g||(u=Math.max(u,g.to??0),d=d||Boolean(g.loop),h[f]={id:f,keyframes:fBe(g.properties?.unproxy())})}let c=l.page??a,p=c?s.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=Go({},ri.prototype)))[o]={id:o,name:l.name,duration:u||5,...d?{loop:d}:{},objectTimelines:h})}delete r.timelineAnimations,s.traverse((o,l)=>{delete l.timelineAnimations})}(e),xie(e,mBe),xie(e,yBe),e.schema=131),t<132&&(e.scene.objects.traverse((i,r)=>yxe(r)),e.schema=132),t<133){let i=function(n){return s=>n.get(s)?.data?.value}(e.shared.variables),r=new Map;e.scene.objects.traverse((n,s)=>{let a=s;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)}}),e.scene.objects.traverse((n,s)=>Sxe(s,i,r.get(n))),e.schema=133}t<134&&(e.scene.objects.traverse((i,r)=>_xe(r)),e.schema=134),t<135&&(JI(e,zY),e.schema=135),t<136&&(JI(e,kY),e.schema=136)}}ww(vxe,{updateAllMaterials:()=>JI,updateDocumentSchema:()=>bBe,updateLibSchema:()=>_Be,updateMaterialSchema:()=>pBe,updateObjectStateRec:()=>rd,updateObjectsSchema:()=>xxe,updateTextValues:()=>cBe});var Txe,sg,Mxe,Exe,wie,N3,b5,Sie,I3,oy,XS,e_,O3,x5,eO,w5,S5,Tie,tO,T5,Ty,vH,CB=F(()=>{ne(),Gbe(),Ir(),OY(),J4e(),EB(),lC(),eh(),la(),IY(),MB(),PY(),hC(),Qbe(),dBe(),Txe=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),sg=180/Math.PI,Mxe=Math.PI/180,Exe=["position","rotation","scale","shape size"]}),xBe=F(()=>{var e,t,i;eh(),Ir(),la(),(wie||(wie={})).is=function(r){return!0},(e=N3||(N3={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},e.merge=function(r,n){return{position:n?.position??r.position,rotation:n?.rotation??r.rotation,scale:n?.scale??r.scale,shear:n?.shear??r.shear}},e.diff=function(r,n){return nbe({position:Lc.isEqual(r.position,n.position)?void 0:n.position,rotation:r.rotation===n.rotation?void 0:n.rotation,scale:Lc.isEqual(r.scale,n.scale)?void 0:n.scale,shear:r.shear&&n.shear&&Lc.isEqual(r.shear,n.shear)?void 0:n.shear})},(b5||(b5={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(Sie||(Sie={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(I3||(I3={})).defaultData={opacity:1,fill:{color:kr.fromHexAndA(Za,1),enabled:!0},stroke:{color:kr.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:kr.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:kr.from0to1([0,0,0,1]),enabled:!1,spread:0}},(t=oy||(oy={})).newEmpty=function(r,n){return{name:n}},t.patch=function(r,n){if(n===void 0)return r;let s={...r};return Object.assign(s,N3.merge(s,n)),s=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}(s,n),s=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}(s,n),s},t.toOps=function(r,n){let s,a=[];for(let[o,l]of Object.entries(n))o!=="name"&&(s===void 0&&(s={path:[],props:{},type:0},a.push(s)),s.props[o]=l);return a},(XS||(XS={})).defaultData={...N3.defaultData,...b5.defaultData,states:new Et,events:new Et,visible:!0,raycastLock:!1},(e_||(e_={})).defaultData={...XS.defaultData,...I3.defaultData},(O3||(O3={})).defaultData={cornerRadius:[0,0,0,0]},(x5||(x5={})).defaultData={...e_.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(eO||(eO={})).defaultData={...e_.defaultData,...O3.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(w5||(w5={})).defaultData={...e_.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"},(S5||(S5={})).defaultData={...e_.defaultData,type:"path2d",path:"",name:"Path"},(Tie||(Tie={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(tO||(tO={})).defaultData={...XS.defaultData,name:"Group",type:"group2d"},(T5||(T5={})).defaultData=()=>({...XS.defaultData,...O3.defaultData,...I3.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:kr.fromHexAndA(4737101,1),enabled:!0},stroke:{color:kr.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(n){switch(n){case"rectangle2d":case"vector2d":return{...eO.defaultData};case"ellipse2d":return{...x5.defaultData};case"text2d":return{...w5.defaultData};case"path2d":return{...S5.defaultData};case"frame2d":return{...T5.defaultData()};case"group2d":return{...tO.defaultData}}},r.getPivot=function(n){return"width"in n&&"height"in n?[typeof n.width=="number"?.5*n.width:0,typeof n.height=="number"?.5*n.height:0]:[0,0]},r.isResizeable=function(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"},r.isAutoLayoutable=function(n){return n.type==="frame2d"&&n.autoLayout!==void 0},r.hasCorners=function(n){return n.type==="rectangle2d"||n.type==="frame2d"}})(Ty||(Ty={})),(i=vH||(vH={})).defaultData={name:"UI",type:"scene2d",objects:new Ea},i.emptyData=function(){return{type:"scene2d",objects:new Ea}}}),Axe=F(()=>{W4e(),H4e(),Abe(),Cbe(),Gbe(),Tbe(),Ibe(),Obe(),Fbe(),PY(),CB(),Vbe(),CY(),AY(),Pbe(),lC(),Nbe(),zbe(),eh(),EB(),MB(),Qbe(),DY(),Bbe(),IY(),NY(),$4e(),Lbe(),LY(),RY(),Rbe(),Dbe(),xBe()});function ly(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),n=new Set(Object.keys(e[0].morphAttributes)),s={},a={},o=e[0].morphTargetsRelative,l=new Mt,h=0;for(let u=0;u<e.length;++u){let d=e[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;s[p]===void 0&&(s[p]=[]),s[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(!n.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(t){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<e.length;++c){let p=e[c].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+u);u+=e[c].attributes.position.count}l.setIndex(d)}for(let u in s){let d=Mie(s[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 m=0;m<a[u].length;++m)p.push(a[u][m][c]);let f=Mie(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}}return l}function Mie(e){let t,i,r,n=-1,s=0;for(let h=0;h<e.length;++h){let u=e[h];if(t===void 0&&(t=u.array.constructor),t!==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(n===-1&&(n=u.gpuType),n!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=u.count*i}let a=new t(s),o=new Pt(a,i,r),l=0;for(let h=0;h<e.length;++h){let u=e[h];if(u.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=u.count;c<p;c++)for(let f=0;f<i;f++){let m=u.getComponent(c,f);o.setComponent(c+d,f,m)}}else a.set(u.array,l);l+=u.count*i}return n!==void 0&&(o.gpuType=n),o}var uC=F(()=>{ne()});function Cxe(e){let t=e.points.length/7,i=new Et;for(let r=0;r<t;r++){let n=7*r,s=e.points[n+0],a=e.points[n+1],o=e.points[n+2],l=e.points[n+3],h=e.points[n+4],u=e.points[n+5],d=e.points[n+6];i.push({fi:r,id:Qe.generateUUID(),data:{roundness:d,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[h,u]}}})}return{points:i,isClosed:e.isClosed,roundness:e.roundness,shapeHoles:e.shapeHoles?.map(r=>Cxe(r))??[]}}function Pxe(e){let{userData:t,uuid:i,...r}=e;if(t===void 0||t.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:h}=a,u=h?.groups,d=h?.attributes??{},c=h?.morphAttributes??{},p=h?.interleavedBuffers,f=h?.arrayBuffers,m=h?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(v){let y=1/0,_=1/0,b=1/0,x=-1/0,w=-1/0,S=-1/0;for(let T=0;T<v.length;T+=3){let M=v[T],E=v[T+1],A=v[T+2];y=Math.min(y,M),_=Math.min(_,E),b=Math.min(b,A),x=Math.max(x,M),w=Math.max(w,E),S=Math.max(S,A)}return{width:x-y,height:w-_,depth:S-b}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:f},...o===void 0?{}:o,type:"NonParametricGeometry"};return m!==void 0&&Object.assign(g.data,{index:m}),u!==void 0&&Object.assign(g.data,{groups:u.map(v=>({...v,materialIndex:v.materialIndex??0}))}),g}(e);if(t.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let h=new Mt;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 Tt(u,3)),h.setIndex(new Gf(c,1));let p=function(v,y=1e-4){y=Math.max(y,Number.EPSILON);let _={},b=v.getIndex(),x=v.getAttribute("position"),w=b?b.count:x.count,S=0,T=Object.keys(v.attributes),M={},E={},A=[],C=["getX","getY","getZ","getW"],D=["setX","setY","setZ","setW"];for(let G=0,K=T.length;G<K;G++){let q=T[G],Y=v.attributes[q];M[q]=new Y.constructor(new Y.array.constructor(Y.count*Y.itemSize),Y.itemSize,Y.normalized);let ue=v.morphAttributes[q];ue&&(E[q]||(E[q]=[]),ue.forEach((de,ge)=>{let be=new de.array.constructor(de.count*de.itemSize);E[q][ge]=new de.constructor(be,de.itemSize,de.normalized)}))}let R=.5*y,I=Math.log10(1/y),U=Math.pow(10,I),O=R*U;for(let G=0;G<w;G++){let K=b?b.getX(G):G,q="";for(let Y=0,ue=T.length;Y<ue;Y++){let de=T[Y],ge=v.getAttribute(de),be=ge.itemSize;for(let re=0;re<be;re++)q+=~~(ge[C[re]](K)*U+O)+","}if(q in _)A.push(_[q]);else{for(let Y=0,ue=T.length;Y<ue;Y++){let de=T[Y],ge=v.getAttribute(de),be=v.morphAttributes[de],re=ge.itemSize,xe=M[de],j=E[de];for(let z=0;z<re;z++){let X=C[z],te=D[z];if(xe[te](S,ge[X](K)),be)for(let V=0,ae=be.length;V<ae;V++)j[V][te](S,be[V][X](K))}}_[q]=S,A.push(S),S++}}let k=v.clone();for(let G in v.attributes){let K=M[G];if(k.setAttribute(G,new K.constructor(K.array.slice(0,S*K.itemSize),K.itemSize,K.normalized)),G in E)for(let q=0;q<E[G].length;q++){let Y=E[G][q];k.morphAttributes[G][q]=new Y.constructor(Y.array.slice(0,S*Y.itemSize),Y.itemSize,Y.normalized)}}return k.setIndex(A),k}(h),f=[],m=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let v=0,y=d.length;v<y;)d[v]===d[v+1]?(m[d[v]]++,f.push(...new Set(g.slice(3*v,3*v+6))),v+=2):(f.push(...g.slice(3*v,3*v+3)),v++);o.indexWASM={array:f},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:m}}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,...wBe(o.positionWASM.array)};l.subdivisions=t.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 n=t.type,s=t.parameters;return n==="VectorGeometry"?(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,width:100,height:100,shape:Cxe(t.shape),type:n}):n==="LatheGeometry"?{...t.parameters,type:n,points:(t?.parameters.points??[]).map(a=>[a.x,a.y])}:(s.extrudeDepth&&(s.depth=s.extrudeDepth),{...s,type:n})}function wBe(e){return yH.setFromArray(e),yH.getSize(XM),{width:XM.x,height:XM.y,depth:XM.z}}var yH,XM,M5,SBe=F(()=>{Ir(),ne(),uC(),new De,new Vt,new Rr,new P,new P,yH=new cn,XM=new P}),TBe=F(()=>{var e;(e=M5||{}).view="view",e.edit="edit",((M5=e)||(M5={})).canWrite=function(t){return t!=="view"},class extends Error{constructor(t,i){super(`This is a ${t.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=t,this.expected=i,this.name="DocumentKindMismatchError"}}}),Rxe,Xf,GE,Dxe,VY,Ew,YS,L3,E5,Aw,Eie,A5,Aie,C5,uw,pm,fm,lp,P5,Cie,Pie,R5,_H,Ef,Nxe=F(()=>{TBe()}),MBe=F(()=>{}),EBe=F(()=>{Ir(),CB(),Nxe()}),ABe=F(()=>{lC(),[...TB],new Set(MY)}),Ot=F(()=>{Axe(),MBe(),K4e(),CB(),EBe(),Nxe(),OY(),ABe(),LY(),Ir()}),Ad=F(()=>{Rxe=[3,4,8,9],Xf=5,GE=3,Dxe=32,VY=.98}),dC=F(()=>{ne(),Ew=e=>{var t;return(t=class extends e{}).geometryHelper=new Dh(30,30,30),t}}),cC=F(()=>{ne(),YS=new _f,L3=new ja,E5=new De,Aw=(e,t,i,r,n=!1,s=e)=>{let a=t,o=s.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),L3.copy(a.boundingSphere),L3.applyMatrix4(o),i.ray.intersectsSphere(L3)===!1||(E5.copy(o).invert(),YS.copy(i.ray).applyMatrix4(E5),a.boundingBox!==null&&YS.intersectsBox(a.boundingBox)===!1))return;let l,h,u,d,c,p,f=a.index,m=a.attributes.position,g=a.drawRange;if(n===!1){for(c=Math.max(0,g.start),p=Math.min(f.count,g.start+g.count);c<p;c+=3)if(h=f.getX(c),u=f.getX(c+1),d=f.getX(c+2),l=v(e,i,YS,m,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let y=a.attributes.position,_=new P,b=new P,x=new P,w=new P,S=2,T=1/((s.scale.x+s.scale.y+s.scale.z)/3),M=T*T;for(let E=Math.max(0,g.start),A=Math.min(y.count,g.start+g.count)-1;E<A;E+=S){if(_.fromBufferAttribute(y,E),b.fromBufferAttribute(y,E+1),YS.distanceSqToSegment(_,b,w,x)>M)continue;w.applyMatrix4(s.matrixWorld);let C=i.ray.origin.distanceTo(w);C<i.near||C>i.far||r.push({distance:C,point:x.clone().applyMatrix4(s.matrixWorld),object:e})}}function v(y,_,b,x,w,S,T){let M=new P,E=new P,A=new P,C=new P,D=new P;if(M.fromBufferAttribute(x,w),E.fromBufferAttribute(x,S),A.fromBufferAttribute(x,T),b.intersectTriangle(M,E,A,!1,C)===null)return null;D.copy(C),D.applyMatrix4(y.matrixWorld);let R=_.ray.origin.distanceTo(D);return R<_.near||R>_.far?null:{faceIndex:1,distance:R,point:D.clone(),object:y}}}}),PB=F(()=>{ne(),dC(),cC(),Eie=new P(1,1,1),A5=new P,Aie=new P,C5=new Vt,uw=class extends Ew(M_e){constructor(e,t=15){super(t),this.object=e,this.dummy=new Tw,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){Aw(this.object,uw.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(A5,C5,Aie),this.matrix.compose(A5,C5,Eie),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}}}),CBe=F(()=>{ne(),pm=new P,fm=new P,lp=new De,P5=[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)],Cie=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Pie=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],R5=(e,t,i)=>{e.updateEntityBoxSize(pm,fm),lp.copy(t).multiply(e.matrixWorld),fm.x===0&&fm.y===0&&fm.z===0?i.push(new P(pm.x,pm.y,pm.z).applyMatrix4(lp)):P5.forEach(r=>{i.push(r.clone().multiply(fm).add(pm).applyMatrix4(lp))})},_H=class extends cn{constructor(){super(...arguments),this.matrix=new De,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new De().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];if(i===!0){let n=[];e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s))return lp.copy(t).multiply(s.matrixWorld),void n.push(new P().applyMatrix4(lp));R5(s,t,r)}}),r.length===0&&r.push(...n)}else R5(e,t,r);return this.setFromPoints(r)}getCenter(e){return(e=super.getCenter(e)).applyMatrix4(this.matrix),e}getPositionToCenter(e){return(e=super.getCenter(e)).applyMatrix4(lp.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(fm).multiplyScalar(.5),this.getCenter(pm),lp.copy(this.matrix).setPosition(pm),this.vertices=P5.map(e=>e.clone().multiply(fm).applyMatrix4(lp))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Cie.map(([e,t])=>new Eh(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Pie.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}}}),r4=F(()=>{Ef={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function jE(e){return e?.isParticleSystem===!0}function l1(e){return e?.isHairSystem===!0}function Yf(e){return e?.isShapeBlendEntity===!0}function RB(e){return e?.isPathObject===!0}function Ql(e){return e?.isObject2D===!0}function qo(e){return e?.isUIObject===!0}function Lg(e){return e?.isCloner===!0}function Bg(e){return e?.isClone===!0}function iO(e){return e?.isComponentObject===!0}var Yn=F(()=>{});function In(e){GY.add(e)}function Ta(e,t){let i=`${e}:${t}`;wH.has(i)||wH.add(i)}function n4(e,t){jY.set(e,t)}function D5(e){return jY.get(e)}function Cw(e,t){WY.set(e,t)}function N5(e){return WY.get(e)}function bH(e,t){HY.set(e,t)}function Ixe(e){return HY.get(e)}function xH(){return DB}var GY,wH,jY,WY,HY,DB,s4,vr=F(()=>{GY=new Set,wH=new Set,jY=new Map,WY=new Map,HY=new Map,DB=null,s4=null});function Oxe(e,t,i,r,n=new De){return n.compose(e,t,Lxe).multiply(i).scale(r)}var Lxe,I5,hy,NB,Pw=F(()=>{ne(),AB(),Lxe=new P(1,1,1),I5=new De,(hy||(hy={})).is=function(e){return e&&e.__isSPEObject},NB=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new De,this.copyPreviousMatrix=!0,this.pivotMatrix=new De,this.matrixWorldRigid=new De,this.shearScale=new De,this.shearScaleInv=new De,this.shearMatrix=new De}get __isSPEObject(){return!0}getPhysicsLocalMatrix(t){return!!this.rigidBody?.isDynamic()&&(t.copy(this.matrixWorld),this.hasNonUniformScale&&t.multiply(this.shearScaleInv),this.parent&&t.premultiply(I5.copy(this.parent.matrixWorld).invert()),t.multiply(I5.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(t){t instanceof ln&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrix(){!this.shearMatrix||(Oxe(this.position,this.quaternion,this.shearMatrix,this.scale,this.matrix),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&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 n of this.children)n.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)hy.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)hy.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=qbe(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new De().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this}onAfterRender(t,i,r,n,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function Rie(e,t,i){return Sg.subVectors(t,e),kA.subVectors(t,i),Sg.cross(kA).length()<=WE}function Bxe(e){let t=MH.get(e.points);if(t!==void 0&&t.isClosed===e.isClosed)return t.curve;let i=function(r){let n=r.points,s=[n[0]],a=[new P(...n[0].data.position)];jv.copy(a[0]);for(let v=0;v<n.length-1;v++)Sg.fromArray(n[v].data.position),kA.fromArray(n[v+1].data.position),Ub.subVectors(Sg,jv),zb.subVectors(Sg,kA),Ub.cross(zb).length()>WE&&(s.push(n[v]),a.push(new P().copy(Sg)),jv.copy(Sg));let o=n[n.length-1];s.push(o),a.push(new P(...o.data.position));let l=r.isClosed,h=s.length-(l?0:1),u=s.length,d=[],c=[];for(let v=0;v<u;v++){let y=s[v].data;d.push(new P(...y.controlPrevious.position)),c.push(new P(...y.controlNext.position))}let p=[];for(let v=0;v<h;v++){let y=v===u-1?0:v+1;p.push(Rie(a[v],c[v],a[y])&&Rie(a[v],d[y],a[y]))}let f=[];for(let v=0;v<u;v++){let y=s[v].data,_=a[v],b={position:_,prevDir:void 0,nextDir:void 0,controlPrevious:d[v],controlNext:c[v],tan:void 0,baseRoundness:y.roundness,removedLength:0};if(f.push(b),y.roundness===0||!l&&(v===0||v===u-1))continue;let x=l&&v==0?u-1:v-1,w=l&&v==u-1?0:v+1,S=new P().subVectors(a[x],_).normalize(),T=new P().subVectors(a[w],_).normalize();b.prevDir=S,b.nextDir=T;let M=p[l&&v===0?u-1:v-1],E=p[v];if(M&&E){Wv.addVectors(S,T).normalize();let A=jv.crossVectors(Wv,S).length()/S.dot(Wv);b.tan=A,b.removedLength=y.roundness/A}}for(let v=0;v<h;v++){let y=l&&v===u-1?0:v+1,_=f[v],b=f[y];if(_.removedLength!==0||b.removedLength!==0){let x=_.position.distanceTo(b.position);_.removedLength=Math.min(_.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let m=new Array(2*u).fill(null);for(let v=0;v<h;v++){let y=l&&v===u-1?0:v+1,_=f[v],b=f[y],x=null;if(p[v]){let w=_.position.clone(),S=b.position.clone();(_.removedLength!==0||b.removedLength!==0)&&(_.nextDir&&w.add(jv.copy(_.nextDir).setLength(_.removedLength)),b.prevDir&&S.add(jv.copy(b.prevDir).setLength(b.removedLength))),w.distanceTo(S)>WE&&(x=new OE(w,w.clone().lerp(S,.3),S.clone().lerp(w,.3),S))}else _.position.distanceTo(b.position)>WE&&(x=new OE(_.position,_.controlNext,b.controlPrevious,b.position));m[2*v+1]=x}for(let v=0;v<u;v++){let y=f[v];if(y.removedLength===0)continue;let _=y.position,b=y.prevDir.clone().multiplyScalar(y.removedLength).add(_),x=y.nextDir.clone().multiplyScalar(y.removedLength).add(_),w=y.tan*y.removedLength;Wv.addVectors(y.prevDir,y.nextDir).normalize(),Ub.copy(b).lerp(x,.5);let S=b.distanceTo(x)/2;TH.copy(Wv).multiplyScalar(Math.sqrt(Math.pow(w,2)-Math.pow(S,2))).add(Ub),rO.copy(Wv).multiplyScalar(-w).add(TH);let T=_.distanceTo(rO)/_.distanceTo(Ub);zb.copy(y.prevDir).multiplyScalar(T*_.distanceTo(b)).add(_),SH.copy(zb).lerp(rO,2);let M=b.clone().lerp(zb,4/3),E=x.clone().lerp(SH,4/3);m[2*v]=new OE(b,M,E,x)}let g=new Fxe;for(let v=0;v<m.length;v++){let y=m[v];y&&g.add(y)}return g}(e);return MH.set(e.points,{isClosed:e.isClosed,curve:i}),i}var Fxe,WE,Sg,kA,jv,Wv,Ub,rO,zb,SH,TH,MH,kb,EH,nO,Uxe,zxe,kxe,tr,_c,Die,Nie,KS,O5,B3,L5,B5,IB,AH,m1,Ec,Vxe=F(()=>{ne(),Fxe=class extends pW{constructor(){super()}getPoints(e=12){let t,i=[],r=this.getCurveLengths(),n=r[r.length-1]/r.length;for(let s=0,a=this.curves;s<a.length;s++){let o=a[s],l=s===0?r[s]:r[s]-r[s-1],h=Math.ceil(e*l/n),u=o.getPoints(h);for(let d=0;d<u.length;d++){let c=u[d];t&&t.equals(c)||(i.push(c),t=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},WE=.001,Sg=new P,kA=new P,jv=new P,Wv=new P,Ub=new P,rO=new P,zb=new P,SH=new P,TH=new P,MH=new WeakMap}),PBe=F(()=>{ne(),kb=new De,EH=new Vt,nO=new Vt,Uxe=new Rr,zxe=new P,kxe=new P(0,1,0)}),bl=F(()=>{ne(),Ot(),CBe(),Ir(),r4(),Yn(),vr(),Pw(),Vxe(),PBe(),Vr(),(tr||(tr={})).is=function(e){return e&&e.__isEntity},_c=e=>tr.is(e),Die={type:"completeState",isfromEntity:!0},Nie=["x","y","z"],KS=new P,O5=new P(1,1,1),B3=new Vt,L5=new Rr,B5=new De,IB=e=>class extends NB(e){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 _H,this._recursiveBBox=new _H,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(tr.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(tr.is(this.children[t]))return t+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 t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(!tr.is(i))return;t=i}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(this.data.states.length!==0||r){for(let n of this.data.states)Og.toOps(this.data,n.data).forEach(s=>{let a=IL.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let n=this.data.states.data(t);n&&(this.dataPatched=Og.patch(this.data,n),Og.toOps(this.data,n).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,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(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{_c(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(tr.is(i[r]))return i[r];if(tr.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&tr.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)_c(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{tr.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)_c(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)_c(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)_c(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this}hasEntityChild(){return this.children.some(t=>_c(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){return this.updateWorldMatrix(!0,!1),BW({position:this.position.toArray(),rotation:[this.rotation.x*Qe.RAD2DEG,this.rotation.y*Qe.RAD2DEG,this.rotation.z*Qe.RAD2DEG],scale:this.scale.toArray(),shear:Ph.fromMatrix(this.shearMatrix.toArray()),pivot:[0,0,0],pivotRotation:[0,0,0]},t)}getTransformValues(t,i,r){return i[t].map((n,s)=>r?.shared.getVariable(n,[this.uuid,t,Nie[s]])??n)}updateTransformState(t,i){let r=!1;if(t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(KS.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Qe.DEG2RAD),this.rotation.setFromVector3(KS),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.shear&&(this.shearMatrix.fromArray(Ph.toMatrix(t.shear)),r=!0),t.pivot!==void 0||t.pivotRotation!==void 0){if(r=!0,t.pivot!==void 0&&t.pivotRotation!==void 0)this.pivotMatrix.compose(KS.fromArray(t.pivot).negate(),B3.setFromEuler(L5.fromArray(t.pivotRotation.map(n=>n*Qe.DEG2RAD))).invert(),O5);else if(t.pivot!==void 0)this.pivotMatrix.setPosition(-t.pivot[0],-t.pivot[1],-t.pivot[2]);else if(t.pivotRotation!==void 0){let n=KS.setFromMatrixPosition(this.pivotMatrix);B3.setFromEuler(L5.fromArray(t.pivotRotation.map(s=>s*Qe.DEG2RAD))).invert(),this.pivotMatrix.compose(n,B3,O5)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){t?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 t of this.children)tr.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{tr.is(t)&&t.disposeRecursively()})}toState(t=[]){return BW({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)},t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,n){let s=this.data;this.data=i;let a=t,o=Zr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let d=Sa.zoom(u,t.path.slice(2));if(d)for(let c in t.props)t.props[c]===void 0&&c in d&&(h[c]=d[c])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:u,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:u,...d}=l;l=d}let h=Sa.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Og.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Zr(t.path,["overrides"])){let l=[],h=[...t.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(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[u],d.updateState(Gg.apply(d.component.data,d.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let d=Sa.zoom(u.component.data,h);if((t={...t,path:h}).type===0){let c=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(c===t.props&&(c={...t.props}),c[p]=d[p]);t={...t,props:c}}u.overrideData=JL.resolve(i.overrides,l),u.updateByOp(t,Ha.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Sf.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Sf.rootOverrideProps)if(Zr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=Gg.filterOp(h.overrideData,l);u&&h.updateByOp(u,Ha.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=Gg.filterOp(h.overrideData,t);if(u){let d;d=s===h.data&&t===u?i:Ha.applySimple(h.data,u),h.updateByOp(u,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!a1.is(t.props.type)&&Ef.changeEntityProptotype(this,this.data,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Ef.changeEntityProptotype(this,this.data,r);for(let n of this.children)tr.is(n)&&n.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let n=i.morphTargetInfluences.get(t.path[1])?.data.name;n&&this.updateMorphInfluences(n,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",n]))}if(Zr(t.path,["pathSnapping"])!==null&&(this.updatePathSnapping(i.pathSnapping),this.isVirtualEntity&&r.scene?.syncInstancePathConstraint(this)),Zr(t.path,["cloner"])!==null){let n=Ha.drop(t,1);n.path.length===0&&n.type===0&&n.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(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,n=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(this.isVirtualEntity&&t.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=Bxe(o.geometry.path),h=function(p){let f=p%1;return f<0?f+1:f===0&&p>0?1:f}(r+n),u=null;try{u=l.curves.length?l.getPointAt(h):null}catch{}if(u===null)return;a.updateMatrixWorld();let d=this.parent?B5.copy(this.parent.matrixWorld):B5.identity(),c=function(p,f,m,g){EH.setFromRotationMatrix(kb.extractRotation(g));let v=p.clone().applyMatrix4(kb.copy(g).invert().multiply(m));if(f===null)nO.setFromRotationMatrix(kb.extractRotation(m));else{let y=f.clone().applyMatrix4(kb.extractRotation(m));nO.setFromRotationMatrix(kb.lookAt(zxe.set(0,0,0),y,kxe))}return{position:v,rotation:new P().setFromEuler(Uxe.setFromQuaternion(EH.invert().multiply(nO))).multiplyScalar(Qe.RAD2DEG)}}(u,s==="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(Die)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>Lg(t)&&t.parameters.type==="toObject")}setFromClonerState(t,i){if(!this.disposed)if(t===null||t.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Ef.Cloner===null)return void Ta("cloners","a cloner");this.cloner=new Ef.Cloner(this,t),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(t,i)}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),g1=F(()=>{ne(),bl(),(AH||(AH={})).is=e=>"objectHelper"in e,m1=(e,t)=>class extends IB(e){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof DA&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Dh?(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 DA&&(r.visible=!1)}}}}),OB=F(()=>{ne(),PB(),g1(),Ec=class extends m1(Tw,uw){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&Object.keys(e).length===1&&t.scene.reloadSplats()}}});function Ru(e,t,i,r,n,s,a){YM.set(n,s,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],YM.x,YM.y,YM.z)}}var YM,nh,Iie,Gxe,RBe=F(()=>{ne(),dC(),cC(),YM=new P,nh=new Pg,Iie=class extends Nb{constructor(e){let t=new Mt,i=new ad({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],s={},a=new at(15711266),o=new at(15711266),l=new at(2857471);function h(d,c,p){u(d,p),u(c,p)}function u(d,c){r.push(0,0,0),n.push(c.r,c.g,c.b),s[d]===void 0&&(s[d]=[]),s[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),t.setAttribute("position",new Tt(r,3)),t.setAttribute("color",new Tt(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap;nh.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;Ru("n1",t,e,nh,-1,-1,i),Ru("n2",t,e,nh,1,-1,i),Ru("n3",t,e,nh,-1,1,i),Ru("n4",t,e,nh,1,1,i);let r=i;Ru("f1",t,e,nh,-1,-1,r),Ru("f2",t,e,nh,1,-1,r),Ru("f3",t,e,nh,-1,1,r),Ru("f4",t,e,nh,1,1,r);let n=r;Ru("u1",t,e,nh,.35,1.1,n),Ru("u2",t,e,nh,-.35,1.1,n),Ru("u3",t,e,nh,0,1.55,n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},Gxe=class extends Ew(Iie){constructor(e){super(e),this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Aw(this.object,this.geometry,e,t,!0)}}});function Oie(e){return 1-Math.pow(1-e,3)}var F0,F3,U3,z3,t_,k3,Wd,Kn,Nh=F(()=>{ne(),RBe(),Ot(),g1(),Vr(),F0=new P,F3=new P,U3=new Vt,z3=new P,t_=new P,k3=new P,Wd=class extends m1(Pg,Gxe){constructor(e="",t={...kE.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=wf.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let n=this._projectionTransition;if(n===void 0)return;if(this.disposed)return void this._endProjectionTransition();n.raf=requestAnimationFrame(this._tickProjectionTransition);let s=Wd.projectionTransitionRequestRender??n.requestRender;this.updateProjectionMatrix(),s?.()},this.super_Entity(e,t),this.previousProjectionMatrix=new De,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Qg(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new bh(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(e){let t=Wd.projectionTransitionsEnabled;Wd.projectionTransitionsEnabled=!1;try{return e()}finally{Wd.projectionTransitionsEnabled=t}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){typeof e=="number"&&(e=new P(e,t,i)),super.lookAt(e),this.getWorldPosition(F0),this.targetOffset=F0.distanceTo(e)}getTarget(e=new P){return this.getWorldDirection(F3),this.getWorldPosition(F0),F3.multiplyScalar(this.targetOffset),e.copy(F0).add(F3),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(F0),F0.distanceTo(e)}updateUp(){this.getWorldQuaternion(U3),z3.set(0,0,1).applyQuaternion(U3),t_.copy(ln.DEFAULT_UP),this.isUpVectorFlipped&&t_.negate(),t_.applyQuaternion(U3),k3.copy(ln.DEFAULT_UP).projectOnPlane(z3),this.angleOffsetFromUp=k3.angleTo(t_),this.angleOffsetFromUp*=k3.cross(t_).dot(z3)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new P),i=e.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new P;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let r=e>t?this.aspect:1,n=e>t?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/n*395,this.bottom=1/n*-395}else this.left=.5*-e,this.right=.5*e,this.top=.5*t,this.bottom=.5*-t;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.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 e=this._projectionTransition;if(e===void 0)return 1;let t=(performance.now()-e.start)/e.duration;return t>=1?1:t<=0?0:Oie(t)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Wd.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Wd.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let t=this._projectionTransition;t===void 0&&(t={from:new De,blend:new De,blendInverse:new De,start:0,duration:Wd.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=t),t.from.copy(this.projectionMatrix),t.start=performance.now(),t.duration=Wd.projectionTransitionDuration,t.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(t.requestRender=e),t.raf!==0&&cancelAnimationFrame(t.raf),t.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let t=(performance.now()-e.start)/e.duration;if(t>=1)return void this._endProjectionTransition();let i=Oie(t),r=e.from.elements,n=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,a=e.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,n[15]-n[11]*a));for(let h=0;h<16;h++)s[h]=r[h]+(n[h]-r[h])*l;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let t=this._activeSubCamera;this.projectionMatrix=t.projectionMatrix,this.projectionMatrixInverse=t.projectionMatrixInverse}_syncProjectionTransition(e){let t=e._projectionTransition;if(t===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new De,blend:new De,blendInverse:new De,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(t.from),i.start=t.start,i.duration=t.duration,i.referenceDepth=t.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,i,r,n,s):this.orthoCamera.setViewOffset(e,t,i,r,n,s),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(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=wf.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){return BW({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},e)}updateCameraSubtype(e,t){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(i,t.zoom),t.near!==void 0&&this.setNear(i,t.near),t.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(t?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(i=>typeof i=="number"?i:0)),e.targetOffset!==void 0&&(this.targetOffset=wf.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},(Kn=Wd).projectionTransitionsEnabled=!1,Kn.projectionTransitionDuration=350,Kn.projectionTransitionMinAgeMs=1e3});function jxe(e){return e.type==="TorusGeometry"&&e.arc===360}var Wxe,V3,CH,VA=F(()=>{ne(),Wxe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??r),s=Math.abs(i.depth??r),a=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:n,depth:s,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:n,revolutions:s,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:d}=e.parameters,c=new CH(!1,t,i,r,n,s,a,o,l,h,u,d);return Object.assign(c,{userData:{...e,type:"HelixGeometry"}})}},V3=new Gf([0,0,0],1),CH=class extends Mt{constructor(e=!0,t=1,i=1,r=1,n=1,s=1,a=1,o=1,l=1,h=1,u=1,d=1){if(super(),s===0)return;let c=e&&s===1;c&&(d=0),u>100&&(u=100),u===0&&(d=0);let p,f,m,g,v,y,_,b,x=()=>new P,w=new P,S=x(),T=x(),M=x(),E=x(),A=x(),C=x(),D=x(),R=x(),I=x(),U=x(),O=x(),k=i-2*o+.001,G=k/s,K=Math.ceil(a*s),q=K+1,Y=k/K,ue=-k/2,de=h+1,ge=2*Math.PI/h,be=Math.PI/2/d,re=Math.min((1-u/100)*o,o-.01),xe=o-re,j=0,z=2*d+2,X=de*z/2,te=X+de*q,V=Math.max(0,de*(q+z)),[ae,se,W]=[3,3,2].map(dt=>Array(V*dt).fill(0)),pe=[],_e=n-o;function Ue(dt,et){let $t=Math.PI/2;y=et*Y,b=2*Math.PI*(y%G)/G+$t,y+=ue,_=Math.sin(b)*_e,v=Math.cos(b)*_e,e?dt.set(v,_,y):dt.set(v,y,_)}Ue(w,-1e-10),Ue(S,0),E.copy(w),Ue(w,1);let we=w.distanceTo(S),Ye=c?0:xe+re,Fe=we*K+2*Ye,We=re,Re=Fe-Ye;for(let dt=0;dt<=K;dt++){Ue(T,dt),O.subVectors(T,E).normalize(),E.copy(T),I.copy(T).setComponent(+e+1,0).normalize(),U.crossVectors(O,I).normalize();let et=dt===0,$t=dt===K,ii=et?3*Math.PI/2:be,nr=et?We:Re,xt=et?de:te,Dt=et?0:V-de,Kt=O.clone().multiplyScalar(et?-xe:xe).add(T),Mi=O.clone().multiplyScalar(et?-1:1).normalize();for(let _i=0;_i<de;_i++){let ci=_i*ge;if(A.addVectors(w.copy(I).multiplyScalar(o*Math.cos(ci)),S.copy(U).multiplyScalar(o*Math.sin(ci))),C.copy(A).normalize(),et||$t){c||(j=Dt+_i,[0,1,2].forEach(Ei=>{ae[3*j+Ei]=Kt.getComponent(Ei),se[3*j+Ei]=Mi.getComponent(Ei)}),W[2*j]=+$t,W[2*j+1]=_i/h),S.copy(C).multiplyScalar(re),M.addVectors(T,S);for(let Ei=0;Ei<d;Ei++){let Or=Ei*be+ii;D.addVectors(w.copy(O).multiplyScalar(xe*Math.sin(Or)),S.copy(C).multiplyScalar(xe*Math.cos(Or))),R.copy(D).normalize(),S.addVectors(M,D),D.normalize(),j=xt+Ei*de+_i,[0,1,2].forEach(Ji=>{ae[3*j+Ji]=S.getComponent(Ji),se[3*j+Ji]=R.getComponent(Ji)});let Wr=+et+Math.sin(Or);W[2*j]=(nr+xe*Wr)/Fe,W[2*j+1]=_i/h}}S.addVectors(T,A),j=X+dt*de+_i,[0,1,2].forEach(Ei=>{ae[3*j+Ei]=S.getComponent(Ei),se[3*j+Ei]=C.getComponent(Ei)}),W[2*j]=(Ye+dt*we)/Fe,W[2*j+1]=_i/h}}let ee=q+2*d+2,[Ee,je]=[+c,ee-1];for(let dt=Ee;dt<=je-1;dt++){let et=c&&dt===je-1;for(let $t=0;$t<de-1;$t++)p=dt*de+$t,f=p+1,m=(et?$t:p)+de,g=(et?$t+1:f)+de,dt===0?pe.push(f,g,m):dt===ee-2?pe.push(p,f,m):pe.push(p,f,m,f,g,m)}this.setIndex(pe),this.setAttribute("position",new Tt(ae,3)),this.setAttribute("normal",new Tt(se,3)),this.setAttribute("uv",new Tt(W,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e,t,i,r,n=this.userData.parameters,s=Math.ceil(n.tubularSegments),a=n.radialSegments,o=a+1,l=[];for(let h=1;h<s;h++)for(let u=0;u<a;u++)e=h*o+u,t=e+1,i=e+o,r=t+o,l.push(e,t,i,t,r,i);for(let h=0;h<a;h++)e=s*o+h,t=e+1,i=h+o,r=h+1+o,l.push(e,t,i,t,r,i);return V3.array=new Uint32Array(l),V3.count=l.length,V3}}});function DBe(e){return Bie||(Bie=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.205/build",i=import("./boolean.js"),[r,n]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),GA=r}())}function a4(){if(GA===void 0)throw new Error("boolean-wasm is not loaded");return GA}function qY(e){let t=jA.get(e);if(t===void 0)throw new Error("Unknown csg mesh set handle "+e);return t}function $Y(e){return jA.set(++PH,e),PH}function NBe(e,t,i){if(GA===void 0)return-1;let{positions:r,indices:n,normals:s}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,f=[];for(let m=0,g=0;m<p.verticesPerFace.length;m++){let v=p.verticesPerFace[m];for(let y=1;y<v-1;y++)f.push(p.indices[g],p.indices[g+y],p.indices[g+y+1]);g+=v}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(f)}}let l;l=jxe(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}}(e,t);return $Y(new GA.CsgMesh(r,n,s))}function Lie(e,t){let i=a4(),r=qxe[t];if(r===void 0)throw new Error("Unknown boolean operation "+t);let n=e.map(qY);if(n.length===1)return i.clone_mesh(n[0]);let s,a=[];if(t===2&&n.length>2){let o=n[0];for(let l=1;l<n.length-1;l++)o=i.boolean_mesh(o,n[l],0),a.push(o);s=i.boolean_mesh(n[n.length-1],o,2)}else if(t===2)s=i.boolean_mesh(n[1],n[0],2);else{let o=n[n.length-1];for(let l=0;l<n.length-1&&(o=i.boolean_mesh(o,n[l],r),a.push(o),o.tri_count()!==0);l++);s=o,a.pop()}for(let o of a)o.free();return s}function F5(e,t){qY(e).transform(new Float32Array(t.elements))}function Hxe(e){let t=jA.get(e);t!==void 0&&(t.free(),jA.delete(e))}var GA,jA,PH,Bie,qxe,LB=F(()=>{ne(),VA(),jA=new Map,PH=0,qxe={0:0,1:1,2:2}});function U0(e){return e!==null&&"booleanOp"in e}var RH,$xe,IBe=F(()=>{ne(),bl(),LB(),RH=class extends IB(Sr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new De}updateVisible(e){super.updateVisible(e),this.visible=!U0(this.parent)&&this.visible,U0(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){U0(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hxe(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}dispose(){super.dispose(),this.freeBooleanPointer()}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),U0(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof RH&&(e.freeBooleanPointer(),U0(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&U0(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),U0(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),OBe=F(()=>{$xe=null});function XY(e,t=0,i=e.count,r,n){let s=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let d=t;d<i;d++){let c=e.getX(d),p=e.getY(d),f=e.getZ(d);c<s&&(s=c),p<a&&(a=p),f<o&&(o=f),c>l&&(l=c),p>h&&(h=p),f>u&&(u=f)}KM.min.set(s,a,o),KM.max.set(l,h,u),KM.getCenter(r),KM.getSize(n).multiplyScalar(.5)}var KM,Fie,Uie,Fs,Da=F(()=>{ne(),IBe(),OBe(),KM=new cn,Fie=new Mt,Uie=new Zl,Fs=class extends RH{constructor(e,t){super(Fie,Uie),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}raycast(e,t){if(this.raycastDeformed(e,t))return;let i=$xe;i===null?super.raycast(e,t):i(this,e,t)}raycastDeformed(e,t){return!1}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?XY(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}}});function Xxe(e){return e?.isClassicNodeMaterial===!0}var Ur,WA,Yxe,Kxe,HE,Zxe,Qxe,Jxe,ewe=F(()=>{}),xu=F(()=>{ne(),Ur=class extends at{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=n==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t)}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}}}),twe=F(()=>{xu(),WA=class extends Ur{}}),LBe=F(()=>{Yxe=class{constructor(e=1e4){this.timeout=e,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(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.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 e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let i=t;t=t.next,t.prev=this.head,this.head.next=t,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(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,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((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),iwe=F(()=>{LBe(),Kxe=class extends Yxe{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}}}),rwe=F(()=>{Zxe=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Qxe=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}}}),BBe=F(()=>{ne(),Jxe=class extends m_e{constructor(e){super(e),this.type=li}parse(e){let t=function(p,f){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(p,f,m){f=f||1024;let g=p.pos,v=-1,y=0,_="",b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(v=b.indexOf(`
|
|
4207
4207
|
`))&&y<f&&g<p.byteLength;)_+=b,y+=b.length,g+=128,b=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));return-1<v&&(m!==!1&&(p.pos+=y+v+1),_+b.slice(0,v))},r=function(p,f,m,g){let v=p[f+3],y=Math.pow(2,v-128)/255;m[g+0]=p[f+0]*y,m[g+1]=p[f+1]*y,m[g+2]=p[f+2]*y,m[g+3]=1},n=function(p,f,m,g){let v=p[f+3],y=Math.pow(2,v-128)/255;m[g+0]=xd.toHalfFloat(Math.min(p[f+0]*y,65504)),m[g+1]=xd.toHalfFloat(Math.min(p[f+1]*y,65504)),m[g+2]=xd.toHalfFloat(Math.min(p[f+2]*y,65504)),m[g+3]=xd.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let a,o,l,h=function(p){let f,m,g=/^#\?(\S+)/,v=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,b=/^\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||!(f=i(p)))&&t(1,"no header found"),(m=f.match(g))||t(3,"bad initial token"),x.valid|=1,x.programtype=m[1],x.string+=f+`
|
|
4208
4208
|
`;f=i(p),f!==!1;)if(x.string+=f+`
|
|
4209
4209
|
`,f.charAt(0)!=="#"){if((m=f.match(v))&&(x.gamma=parseFloat(m[1])),(m=f.match(y))&&(x.exposure=parseFloat(m[1])),(m=f.match(_))&&(x.valid|=2,x.format=m[1]),(m=f.match(b))&&(x.valid|=4,x.height=parseInt(m[1],10),x.width=parseInt(m[2],10)),2&x.valid&&4&x.valid)break}else x.comments+=f+`
|
|
4210
|
-
`;return 2&x.valid||t(3,"missing format specifier"),4&x.valid||t(3,"missing image size specifier"),x}(s),u=h.width,d=h.height,c=function(p,f,m){let g=f;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&t(3,"wrong scanline width");let v=new Uint8Array(4*f*m);v.length||t(4,"unable to allocate buffer space");let y=0,_=0,b=4*g,x=new Uint8Array(4),w=new Uint8Array(b),S=m;for(;S>0&&_<p.byteLength;){_+4>p.byteLength&&t(1),x[0]=p[_++],x[1]=p[_++],x[2]=p[_++],x[3]=p[_++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&t(3,"bad rgbe scanline format");let T,M=0;for(;M<b&&_<p.byteLength;){T=p[_++];let A=T>128;if(A&&(T-=128),(T===0||M+T>b)&&t(3,"bad scanline data"),A){let C=p[_++];for(let D=0;D<T;D++)w[M++]=C}else w.set(p.subarray(_,_+T),M),M+=T,_+=T}let E=g;for(let A=0;A<E;A++){let C=0;v[y]=w[A+C],C+=g,v[y+1]=w[A+C],C+=g,v[y+2]=w[A+C],C+=g,v[y+3]=w[A+C],y+=4}S--}return v}(s.subarray(s.pos),u,d);switch(this.type){case Gt:l=c.length/4;let p=new Float32Array(4*l);for(let m=0;m<l;m++)r(c,4*m,p,4*m);a=p,o=Gt;break;case li:l=c.length/4;let f=new Uint16Array(4*l);for(let m=0;m<l;m++)n(c,4*m,f,4*m);a=f,o=li;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:Td,minFilter:it,magFilter:it,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}});function zie(e){return e.length>2&&e[0]===35&&e[1]===63}function U5(e){return typeof e=="object"&&e!==null&&e.isSplineHdr===!0}function nwe(e){let t=new Nr(e.data,e.width,e.height,pn,li);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var kie,YY,Pc,swe=F(()=>{ne(),BBe()}),awe=F(()=>{ne(),iwe(),rwe(),swe(),kie=0,YY=class extends Zxe{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.instanceId=++kie,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let s of Object.values(n))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,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 e!="string"){let r,n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"})),await new Promise(s=>{n.onloadend=a=>{r=a.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else if(e instanceof Uint8Array?zie(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let r=e instanceof Uint8Array?e:null;if(r===null)try{r=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{r=null}let n=r!==null&&zie(r)?function(s){try{let a=new Jxe().parse(s.buffer.slice(s.byteOffset,s.byteOffset+s.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=m=>xd.toHalfFloat(Math.pow(Math.max(xd.fromHalfFloat(m),0),1/2.2)),p=new Map,f=m=>{let g=p.get(m);return g===void 0&&(g=c(m),p.set(m,g)),g};for(let m=0;m<l;m++){let g=m*d,v=(l-1-m)*d;for(let y=0;y<d;y+=4)u[v+y]=f(h[g+y]),u[v+y+1]=f(h[g+y+1]),u[v+y+2]=f(h[g+y+2]),u[v+y+3]=h[g+y+3]}return{isSplineHdr:!0,data:u,width:o,height:l}}catch{return null}}(r):null;n!==null&&(this.isHdr=!0,this.img=n,t())}else this.img=new Image,this.img.src=typeof(i=e)=="string"?i:(HE||(HE=new Kxe),HE.load(i)),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}});var i}getTexture(e,t=1008,i=1006){let r=this._cache[e]?.[t]?.[i];if(r)return r;{let n;return this.isBuffer?n=this.img.texture:this.isVideo?n=new JX(this.img,void 0,e,e):this.isHdr?(n=nwe(this.img),n.wrapS=e,n.wrapT=e,n.magFilter=i,n.minFilter=t):n=new Ci(this.img,void 0,e,e,i,t),this.isBuffer||(n.anisotropy=8,n.generateMipmaps=t===1008),this.loaded&&(n.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=n,n}}setNeedsUpdate(e){if(!this.isBuffer)for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[n,s]of Object.entries(r))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][n]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),BB=F(()=>{awe(),Pc=class extends YY{}});function FBe(e){if(typeof e=="string")return e;let t=DH.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},DH.set(e,t)),t.url}var DH,UBe=F(()=>{DH=new Map});function zBe(){if(!NH)return Vie||(Vie=async function(){await Promise.resolve().then(()=>(hQ(),hRe)),owe(window!==void 0?window:global),NH=!0}())}var owe,lwe,NH,Vie,hwe=F(()=>{lwe=new Promise(e=>{owe=e}),NH=!1});function Gie(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function kBe(e){let t=!1,i=[];return e.scene.objects.traverse((r,n)=>{if(n.type==="Page"&&n.uiScene!==void 0&&n.uiScene.objects.traverse((s,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;Gie(a.events,i),t=t||i.some(o=>o.data.type==="Audio")}),n.events===void 0||Array.isArray(n.events)===!1)return!0;Gie(n.events,i),t=t||i.some(s=>s.data.type==="Audio")}),t}var jie,ux,KY=F(()=>{UBe(),hwe(),lwe.then(e=>jie=e),ux=class{constructor({src:e,volume:t,delay:i,loop:r}){let n;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)},n=typeof e=="string"?{src:e}:{src:FBe(e),format:"wav"},this.sound=new jie.Howl(n),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,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(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function Wie(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var ZY,QY=F(()=>{ZY=null});function Hie(e){return new Z(e.y,-e.x)}var JY,IH,uwe,dwe,G3,qie,o4,cwe,z5,l4=F(()=>{ne(),JY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,n=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);n.thetaLength=Qe.clamp(n.thetaLength,0,360),n.hollow=Qe.clamp(n.hollow??0,0,1);let s=n.width/2,a=n.radiusTop??s,o=n.radiusBottom??s;if(a===o?(a=s,o=s):a>o?(a=s,o=o*s/a):(a=a*s/o,o=s),n.shapeBlendNode){a=i??s,o=r??s;let l=2*Math.max(a,o);n.width=l,n.depth=l}return{parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(n.height??n.width),depth:Math.abs(n.depth??n.width),radiusTop:a,radiusBottom:o})}}static build(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:f}=e.parameters;h===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=c||f?new IH(u,d,n,s,a,o,l,h*Math.PI/180,c,c,p,f):new IE(u,d,n,s,a,o,l,h*Math.PI/180);let m=r/i;return m!==1&&t.scale(1,1,m),Object.assign(t,{userData:{...e,type:"CylinderGeometry"}})}},IH=class extends Mt{constructor(e,t,i,r,n,s,a,o,l,h,u,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,n=Math.floor(n)||1,s=s!==void 0&&s,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,s&&(l=0,h=0);let p=i/2;c&&e==0&&(e=l),c&&t==0&&(t=h);let f=new Z(e,p),m=new Z(t,-p),g=null,v=null,y=null,_=null,b=f.clone().sub(m),x=0,w=0,S=0;d>0&&(x=Math.min(e,t)*(1-d),w=e-x,S=t-x);let T=f.clone();T.x-=x;let M=Math.PI-b.angle(),E=b.angle(),A=Math.tan(E/2),C=Math.tan(M/2),D=A+C,R=d?D:C,I=d?D:A;if(l=Math.min(l,(e-w)/R,b.length()/D),h=Math.min(h,(t-S)/I,b.length()/D),l>0){let pe=l/A;g=f.clone().sub(new Z(pe,l)),d&&(y=g.clone(),y.x-=x-D*l),f.sub(b.clone().setLength(pe))}if(h>0){let pe=h/C;v=m.clone().sub(new Z(pe,-h)),m.add(b.clone().setLength(pe)),d&&(_=v.clone(),_.x-=x-D*h,T.sub(b.clone().setLength(pe)))}b=f.clone().sub(m);let U=b.length()<.5,O=[],k=[],G=[],K=[],q=[],Y=[],ue=(pe,_e,Ue,we,Ye)=>{for(let Fe=0;Fe<u+1;Fe++){let We=Fe/u,Re=we<0?We:1-We;Ye&&(Re-=1),Re*=pe;let ee=Math.sin(Re),Ee=Math.cos(Re)*we,je=Ee*_e+Ue.y;O.push(ee*_e+Ue.x),k.push(je),G.push(ee),K.push(Ee),q.push(.5+je/i),Y.push(!1)}},de=(pe,_e,Ue)=>{let we=[pe,_e];Ue<0&&we.reverse();for(let Ye of we)O.push(Ye),k.push(p*Ue),G.push(0),K.push(Ue),q.push(.5),Y.push(!0)};if(_&&v?(ue(M,h,_,-1,!0),ue(E,h,v,-1,!1)):v?(de(v.x,0,-1),ue(E,h,v,-1,!1)):s||de(t,S,-1),!U){let pe=Hie(b).normalize();for(let _e=0;_e<=n;_e++){let Ue=_e/n,we=b.y*Ue+m.y;O.push(b.x*Ue+m.x),k.push(we),G.push(pe.x),K.push(pe.y),q.push(.5+we/i),Y.push(!1)}}if(y&&g?(ue(M,l,g,1,!1),ue(E,l,y,1,!0)):g?(ue(M,l,g,1,!1),de(g.x,0,1)):s||de(e,w,1),d&&!U){let pe=Hie(b).multiplyScalar(-1).normalize();for(let _e=0;_e<=n;_e++){let Ue=_e/n,we=b.y*-Ue+T.y;O.push(b.x*-Ue+T.x),k.push(we),G.push(pe.x),K.push(pe.y),q.push(.5+we/i),Y.push(!1)}}let ge=O.length,be=ge+(d&&!s?1:0),re=(pe,_e)=>pe*ge+(_e===ge?0:_e),xe=o<2*Math.PI,j=(r+1)*ge+(xe?2*(1+be):0),z=new Float32Array(3*j),X=new Float32Array(3*j),te=new Float32Array(2*j),V=j-1>65535?new Uint32Array(r*Math.max(0,be-1)*6+(xe?2*(be+1)*3:0)):new Uint16Array(r*Math.max(0,be-1)*6+(xe?2*(be+1)*3:0)),ae=0,se=0;for(let pe=0;pe<=r;pe++){let _e=pe/r,Ue=_e*o+a,we=Math.sin(Ue),Ye=Math.cos(Ue);for(let Fe=0;Fe<ge;Fe++){let We=3*se,Re=2*se,ee=O[Fe],Ee=G[Fe];z[We]=ee*we,z[We+1]=k[Fe],z[We+2]=ee*Ye,X[We]=Ee*we,X[We+1]=K[Fe],X[We+2]=Ee*Ye,Y[Fe]?(te[Re]=.5,te[Re+1]=.5):(te[Re]=_e,te[Re+1]=q[Fe]),se++}}for(let pe=0;pe<r;pe++)for(let _e=0;_e<be-1;_e++){if(s&&d&&_e==n)continue;let Ue=re(pe,_e),we=re(pe+1,_e),Ye=re(pe+1,_e+1),Fe=re(pe,_e+1),We=z[3*Ye+0],Re=z[3*Ye+2];V[ae++]=Ue,V[ae++]=we,V[ae++]=Fe,(We!=0||Re!=0)&&(V[ae++]=we,V[ae++]=Ye,V[ae++]=Fe)}function W(pe,_e,Ue){let we=Math.sin(Ue),Ye=Math.cos(Ue),Fe=-Ye,We=we,Re=pe<0?(et,$t,ii)=>{V[ae++]=et,V[ae++]=$t,V[ae++]=ii}:(et,$t,ii)=>{V[ae++]=et,V[ae++]=ii,V[ae++]=$t},ee=(e+t+w+S)/4,Ee=3*se,je=2*se;z[Ee]=ee*we,z[Ee+1]=0,z[Ee+2]=ee*Ye,X[Ee]=Fe,X[Ee+1]=0,X[Ee+2]=We,te[je]=.5,te[je+1]=.5;let dt=se++;for(let et=0;et<be;et++){let $t=3*(_e+(et===ge?0:et));Ee=3*se,je=2*se,z[Ee]=z[$t],z[Ee+1]=z[$t+1],z[Ee+2]=z[$t+2],X[Ee]=Fe,X[Ee+1]=0,X[Ee+2]=We;let ii=$t/3*2|0;te[je]=te[ii],te[je+1]=te[ii+1],se++}for(let et=dt+1;et<se-1;et++)Re(dt,et,et+1);Re(dt,se-1,dt+1)}xe&&(W(-1,0,a),W(1,r*ge,a+o)),this.setIndex(new Pt(V.slice(0,ae),1)),this.setAttribute("position",new Pt(z,3)),this.setAttribute("normal",new Pt(X,3)),this.setAttribute("uv",new Pt(te,2))}}}),$ie=F(()=>{ne(),l4(),uwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=Qe.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(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=e.parameters;h===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=u>0||d>0||h<360?new IH(0,i/2,n,s,a,o,l,h*Math.PI/180,u,d,c,0,!0):new AL(i/2,n,s,a,o);let p=r/i;return p!==1&&t.scale(1,1,p),Object.assign(t,{userData:{...e,type:"ConeGeometry"}})}}}),Xie=F(()=>{ne(),dwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.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(e){let t,{width:i,height:r,depth:n,widthSegments:s,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:h}=e.parameters;return t=l===0?new Dh(i,r,n,s,a,o):new qie(i,r,n,s,a,o,l,h),Object.assign(t,{userData:{...e,type:"CubeGeometry"}})}},G3=Math.PI/2,qie=class extends Mt{constructor(e=1,t=1,i=1,r=1,n=1,s=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=(a=Math.min(a,e/2,t/2,i/2))>0,h=o+1,u=2*((s+1)*(n+1)+(r+1)*(s+1)+(r+1)*(n+1))+(l?4*h*(s+1+(r+1)+(n+1))+h*(h+1)/2*8:0),d=2*(s*n+r*s+r*n)+(l?4*o*(s+r+n):0),c=l?8*o*o:0,p=new Float32Array(3*u),f=new Float32Array(3*u),m=new Float32Array(2*u),g=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),v=0,y=0,_=new Float64Array(h),b=new Float64Array(h),x=new Float64Array(h),w=new Float64Array(h);for(let D=0;D<h;D++){let R=D/o*G3;_[D]=Math.sin(R)*a,b[D]=(1-Math.cos(R))*a,x[D]=Math.sin(R),w[D]=Math.cos(R)}let S=h*(h+1)/2,T=new Float64Array(3*S),M=new Float64Array(3*S);{let D=new P(e/2,t/2,i/2);D.subScalar(a);let R=0;for(let I=0;I<=o;I++){let U=G3*(1-I/o),O=Math.cos(U),k=Math.sin(U),G=0;for(let K=0;K<=I;K++){let q=O*Math.cos(G),Y=k,ue=O*Math.sin(G);T[3*R]=q,T[3*R+1]=Y,T[3*R+2]=ue,M[3*R]=D.x+q*a,M[3*R+1]=D.y+Y*a,M[3*R+2]=D.z+ue*a,R++,G+=G3/I}}}function E(D,R,I,U,O,k,G,K,q,Y){let ue=(k-2*a)/q,de=(G-2*a)/Y,ge=k/2-a,be=G/2-a,re=K/2,xe=q+1,j=Y+1,z=0,X=new P;for(let te=0;te<j;te++){let V=te*de-be;for(let ae=0;ae<xe;ae++){let se=ae*ue-ge,W=3*(v+z),pe=2*(v+z);X[D]=se*U,X[R]=V*O,X[I]=re,p[W]=X.x,p[W+1]=X.y,p[W+2]=X.z,X[D]=0,X[R]=0,X[I]=K>0?1:-1,f[W]=X.x,f[W+1]=X.y,f[W+2]=X.z,m[pe]=ae/q,m[pe+1]=1-te/Y,z+=1}}for(let te=0;te<Y;te++)for(let V=0;V<q;V++){let ae=v+V+xe*te,se=v+V+xe*(te+1),W=v+(V+1)+xe*(te+1),pe=v+(V+1)+xe*te;g[y++]=ae,g[y++]=se,g[y++]=pe,g[y++]=se,g[y++]=W,g[y++]=pe}v+=z}function A(D,R,I,U,O,k,G,K,q,Y){let ue=(G-2*a)/Y,de=G/2-a,ge=K/2-a,be=q/2,re=Y+1,xe=0,j=new P,z=new P;for(let X=0;X<o+1;X++){j[R]=(ge+_[X])*O,j[I]=(be-b[X])*k,z[D]=0,z[R]=x[X]*Math.sign(j[R]),z[I]=w[X]*Math.sign(j[I]);for(let te=0;te<re;te++){let V=te*ue-de;j[D]=V*U;let ae=3*(v+xe),se=2*(v+xe);p[ae]=j.x,p[ae+1]=j.y,p[ae+2]=j.z,f[ae]=z.x,f[ae+1]=z.y,f[ae+2]=z.z,m[se]=te/Y,m[se+1]=0,xe+=1}}for(let X=0;X<o;X++)for(let te=0;te<Y;te++){let V=v+te+re*X,ae=v+te+re*(X+1),se=v+(te+1)+re*(X+1),W=v+(te+1)+re*X;g[y++]=V,g[y++]=ae,g[y++]=W,g[y++]=ae,g[y++]=se,g[y++]=W}v+=xe}function C(D,R,I){let U=D*R*I>0?(k,G,K)=>{g[y++]=k,g[y++]=G,g[y++]=K}:(k,G,K)=>{g[y++]=k,g[y++]=K,g[y++]=G},O=v;for(let k=0;k<S;k++){let G=3*k,K=3*v,q=2*v;p[K]=D*M[G],p[K+1]=R*M[G+1],p[K+2]=I*M[G+2],f[K]=D*T[G],f[K+1]=R*T[G+1],f[K+2]=I*T[G+2],m[q]=0,m[q+1]=0,v++}for(let k=0;k<o;k++){let G=O+k*(k+1)/2,K=O+(k+1)*(k+2)/2;U(G,K+1,K);for(let q=1;q<=k;q++)U(G+q-1,G+q,K+q),U(G+q,K+q+1,K+q)}}E("z","y","x",-1,-1,i,t,e,s,n),E("z","y","x",1,-1,i,t,-e,s,n),E("x","z","y",1,1,e,i,t,r,s),E("x","z","y",1,-1,e,i,-t,r,s),E("x","y","z",1,-1,e,t,i,r,n),E("x","y","z",-1,-1,e,t,-i,r,n),a>0&&(A("z","y","x",-1,-1,1,i,t,e,s),A("z","y","x",1,-1,-1,i,t,e,s),A("z","y","x",-1,1,-1,i,t,e,s),A("z","y","x",1,1,1,i,t,e,s),A("x","y","z",-1,-1,-1,e,t,i,r),A("x","y","z",1,-1,1,e,t,i,r),A("x","y","z",-1,1,1,e,t,i,r),A("x","y","z",1,1,-1,e,t,i,r),A("y","x","z",-1,-1,1,t,e,i,n),A("y","x","z",1,-1,-1,t,e,i,n),A("y","x","z",1,1,1,t,e,i,n),A("y","x","z",-1,1,-1,t,e,i,n),C(1,1,1),C(-1,1,1),C(1,-1,1),C(-1,-1,1),C(1,1,-1),C(-1,1,-1),C(1,-1,-1),C(-1,-1,-1)),this.setIndex(new Pt(g,1)),this.setAttribute("position",new Pt(p,3)),this.setAttribute("normal",new Pt(f,3)),this.setAttribute("uv",new Pt(m,2))}}}),pwe=F(()=>{ne(),o4=class extends Mt{constructor(e=[],t=[],i="",r=1,n=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,h=0;return function(){(n=Math.min(.99999,n))==0&&(s=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new Ls,f=n*r,m=r-f,g=s+1,v=new P,y=(re,xe)=>v.subVectors(re,xe).normalize(),_=(re,xe)=>Array(re).fill(void 0).map(xe),b=_(e.length/3,(re,xe)=>new P().fromArray(e,3*xe).setLength(r)),x=[],w=1e6;for(let re=0;re<b.length;re++){let xe,j,z,X=b[re],te=[],V=1e10,ae=-1;for(;(ae=t.indexOf(re,ae+1))!=-1;){let _e=ae-ae%3;xe=t[_e+(ae+1)%3],j=t[_e+(ae+2)%3],z=X.distanceToSquared(b[xe]),V=Math.min(V,z),te.push([xe,j,z])}V+=1e-6;let se=[],W=0,pe=te.length;for(let _e=0;_e<pe;_e++){[xe,j,z]=te[W];let Ue=x[xe]?.includes(re)==1;z<=V&&se.push(xe+ +Ue*w),W=te.findIndex(we=>we[0]==j)}x.push(se)}let S=[];{let re,xe,j=0,z=0,X=u==3;for(let te=0;te<=s;te++){re=te*(te+1)/2,xe=(te+1)*(te+2)/2;for(let V=0;V<s-te;V++)[j,z]=[re+V+te+2,xe+V+te+3],S.push(re,xe,...X?[z,re]:[j,xe],z,j),[re,xe]=[j,z];S.push(re,xe,re+s+2)}}let T=0;for(let re=0;re<x.length;re++)for(let xe=0;xe<u;xe++)x[re][xe]<w&&T++;let M=b.length*u*S.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(M),o=new Float64Array(M),l=new Float64Array(M/3*2);let E=(re,xe,j)=>{let z=h/3*2;l[z]=Math.atan2(j,-re)/2/Math.PI+.5,l[z+1]=1-(Math.atan2(-xe,Math.sqrt(re*re+j*j))/Math.PI+.5)},A=re=>{a[h]=re.x,a[h+1]=re.y,a[h+2]=re.z,o[h]=v.x,o[h+1]=v.y,o[h+2]=v.z,E(re.x,re.y,re.z),h+=3},C=re=>{a[h]=re[0].x,a[h+1]=re[0].y,a[h+2]=re[0].z,o[h]=re[1].x,o[h+1]=re[1].y,o[h+2]=re[1].z,E(re[0].x,re[0].y,re[0].z),h+=3},D=(s+2)*(s+3)/2,R=new Float64Array(3*D),I=new Float64Array(3*D),U=new Float64Array(2*D),O=_(2*u*g,()=>new P),k=_(s*Math.max(0,s-1)/2,()=>new P),G=d.clone(),K=d.clone(),q=d.clone(),Y=d.clone(),ue=d.clone(),de=[],ge=_(b.length,()=>_(u,()=>d.clone()));for(let re=0;re<b.length;re++){d.copy(b[re]).normalize(),G.copy(d).multiplyScalar(m);let xe=x[re];for(let se=0;se<xe.length;se++){let W=xe[se],pe=xe[(se+1)%u];p.setFromPointsAndIndices(b,re,W%w,pe%w),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(G,ge[re][se])}let j=0,z=[],X=[],te=new P;s==0&&[...ge[re]].reduce((se,W)=>se.add(W),te).multiplyScalar(1/u);for(let se=0;se<u;se++){let W=[],pe=(se-1+u)%u,_e=ge[re][pe],Ue=ge[re][se];d.copy(_e).sub(G),c.copy(Ue).sub(G);let we=G.angleTo(d),Ye=d.angleTo(c),Fe=Math.cos(we)*f;s==0?K.copy(te):K.copy(G).setLength(m+Fe),z.push(Fe);let We=[K,_e,Ue];for(let Re=0;Re<2;Re++){let ee=We[Re],Ee=We[Re+1];Y.subVectors(ee,G),ue.subVectors(Ee,G),q.crossVectors(Y,ue).normalize();for(let je=0;je<g;je++){let dt=[we,Ye][Re]*je/g;d.copy(Y).applyAxisAngle(q,dt).add(G),O[j++].copy(d),Re&&(y(d,G),W.push([je==0?ee:d.clone(),v.clone()]))}Re&&(y(Ee,G),W.push([Ee,v.clone()]))}X.push(W)}de.push(X);let V=2*g,ae=2;for(let se=0;se<u;se++){let W=V*se,pe=V*((se+1)%u),_e=0,Ue=[O[W]];for(let we=1;we<g;we++){let Ye=O[W+we],Fe=O[pe+we];Ue.push(Ye);for(let We=1,Re=we-ae+1;We<=Re;We++)d.lerpVectors(Ye,Fe,We/(Re+1)),d.sub(G).setLength(z[se]).add(G),Ue.push(k[_e++].copy(d));Ue.push(Fe)}for(let we=0;we<g;we++)Ue.push(O[we+g+W]);Ue.push(O[pe+g]);for(let we=0,Ye=Ue.length;we<Ye;we++){let Fe=Ue[we],We=3*we,Re=2*we;R[We]=Fe.x,R[We+1]=Fe.y,R[We+2]=Fe.z,y(Fe,G),I[We]=v.x,I[We+1]=v.y,I[We+2]=v.z,U[Re]=Math.atan2(Fe.z,-Fe.x)/2/Math.PI+.5,U[Re+1]=1-(Math.atan2(-Fe.y,Math.sqrt(Fe.x*Fe.x+Fe.z*Fe.z))/Math.PI+.5)}for(let we=0,Ye=S.length;we<Ye;we++){let Fe=3*S[we],We=2*S[we],Re=h/3*2;a[h]=R[Fe],a[h+1]=R[Fe+1],a[h+2]=R[Fe+2],o[h]=I[Fe],o[h+1]=I[Fe+1],o[h+2]=I[Fe+2],l[Re]=U[We],l[Re+1]=U[We+1],h+=3}}}let be=[];for(let re=0;re<x.length;re++)for(let xe=0;xe<u;xe++){let j=x[re][xe];if(j<w){let z=x[j].findIndex(V=>V%w==re),X=de[re][xe],te=de[j][z];for(let V=0;V<g;V++){let ae=X[V],se=te[g-V],W=X[V+1],pe=te[g-(V+1)];C(ae),C(se),C(W),C(W),C(se),C(pe)}be.push(X[0][0],te[g][0],X[g][0],te[0][0])}}for(;be.length;){let re,xe,j,[z,X]=be.splice(0,2);re=X;let te=[z];for(;z!=re;)te.push(re),xe=be.indexOf(re),j=xe%2,re=be.splice(xe-j,2)[1-j];v.subVectors(te[0],te[1]).cross(d.subVectors(te[0],te[2])).normalize();let V=v.dot(te[0])<0;V&&v.negate();for(let ae=1;ae<=te.length-2;ae++)A(te[ae+ +V]),A(te[ae+1-+V]),A(te[0])}}(),function(){let u=new P,d=new P,c=new P,p=new P,f=new Z,m=new Z,g=new Z,v=(b,x,w,S)=>{S<0&&b.x===1&&(l[x]=b.x-1),w.x===0&&w.z===0&&(l[x]=S/2/Math.PI+.5)};for(let b=0,x=0;b<h;b+=9,x+=6){u.set(a[b+0],a[b+1],a[b+2]),d.set(a[b+3],a[b+4],a[b+5]),c.set(a[b+6],a[b+7],a[b+8]),f.set(l[x+0],l[x+1]),m.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 w=_(p);v(f,x+0,u,w),v(m,x+2,d,w),v(g,x+4,c,w)}let y=h/3*2;for(let b=0;b<y;b+=6){let x=l[b+0],w=l[b+2],S=l[b+4],T=Math.max(x,w,S),M=Math.min(x,w,S);T>.9&&M<.1&&(x<.2&&(l[b+0]+=1),w<.2&&(l[b+2]+=1),S<.2&&(l[b+4]+=1))}function _(b){return Math.atan2(b.z,-b.x)}}(),this.setAttribute("position",new Pt(new Float32Array(a.subarray(0,h)),3)),this.setAttribute("normal",new Pt(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new Pt(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(e){return new o4(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}}}),Yie=F(()=>{pwe(),ne(),cwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new z5(.5*t,s,a):new dW(.5*t,n),l=i/t,h=r/t;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},z5=class extends o4{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n=1/r,s="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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],[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],s,e,t,i),this.type=s}static fromJSON(e){return new z5(e.radius,e.corner,e.cornerSides)}}});function Kie(e,t=new Z){let i=e.length();return t.set(-e.y/i,e.x/i)}function VBe(e){let t=new Z;t.addVectors(e.v0,dy.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(e.v2,HA.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new pu(e.v0,t,i,e.v2)}function ZM(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function GBe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function jBe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function fwe(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function WBe(e,t,i){return Qie(e,t)&&Qie(t,i)&&OH(e.position,t.position,i.position)}function OH(e,t,i){return dy.copy(t).sub(e).cross(HA.copy(i).sub(e))===0}function HBe(e,t,i,r,n){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,h=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,a+h),n.set(o-l,a-h),[r,n]}function qBe(e,t,i){return e.distanceTo(i)<t.distanceTo(i)?t:e}function $Be(e,t,i,r,n,s){let a,o=t.x-e.x,l=t.y-e.y,h=i.x-e.x,u=i.y-e.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return fwe(t,e,i)>Math.PI&&(d*=-1),a=ZM(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),n.set(t.x-a*l,t.y+a*o),s.set(i.x+a*u,i.y-a*h),[n,s]}function Zie(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Qie(e,t){return OH(e.position,e.controls[1].position,t.position)&&OH(e.position,t.controls[0].position,t.position)}function Jie(e,t=12,i=!1){let r=[];for(let n=0,s=e.length;n<s;n++){let a=e[n],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*uy(a.roundedCurveCorner,t);n>0&&(r[n-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=uy(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=.5*uy(e[0].roundedCurveCorner,t)),r}function uy(e,t=12){return e&&e instanceof BM?2*t:e&&(e instanceof wh||e instanceof cW)?1:e&&e instanceof GI?t*e.points.length:t}var Vb,j3,W3,My,sO,dy,HA,mwe,gwe,vwe,ywe,LH,BH,H3,ere,tre,ire,rre,nre,cs,_we=F(()=>{ne(),Vb=1e-12,j3=class{constructor(e){this.position=new Z,this.startPosition=new Z,this.uuid=Qe.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new j3(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},W3=class extends j3{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new W3(this.parent).copy(this)}},My=class extends j3{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new W3(this),new W3(this))}static create(e,t){let i=new My(e,new Z(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let n=this.controls[i];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new My(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Z,t=new Z){let[i,r]=this.computeTangents();return i&&r&&(Kie(i,e),Kie(r,t)),[e,t]}computeTangent(e=new Z){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new Z){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}},sO=e=>e,dy=new Z,HA=new Z,mwe=new Z,gwe=new Z,vwe=new Z,ywe=new Z,LH=new P,BH=new P}),o0=F(()=>{ne(),_we(),H3=new Z,ere=new Z,tre=new Z,ire=new Z,rre=new Z,nre=new Z,cs=class extends AA{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Wa(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=Qe.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new cs;return r.isClosed=e.isClosed,r.points=e.points.map(n=>My.create(n.id,n.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(n=>cs.createFromState(n)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let n=0,s=this.shapeHoles.length;n<s;n++){let a=this.shapeHoles[n],o=a.points.length,l=a.getPointIndexById(e);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=e-t;if(s<=n.points.length-1)return n.points[s];t+=n.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=H3.set(e,t);for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,n=this.shapeHoles.length;r<n;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=Qe.generateUUID()){let r;r=e instanceof Z?e:new Z(e,t);let n=new My(i,r);return n.roundness=this.roundness,n}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(n,s,a=12,o=!0){let l,h=BH.set(0,0,0),u=0,d=[];for(let c=0;c<s.length;c++){let p=sO(s[c]),f=dy,m=uy(p,a);d.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof df||p instanceof wh){if(p.getPoint(g/m,f),h.set(f.x,f.y,0),l!==void 0&&jBe(l,h))continue;l===void 0&&(l=LH),l.copy(h),n.setXYZ(u,h.x,h.y,h.z),u++}}o&&u>1&&(n.getX(u-1)!==n.getX(0)||n.getY(u-1)!==n.getY(0)||n.getZ(u-1)!==n.getZ(0))&&(n.setXYZ(u,n.getX(0),n.getY(0),n.getZ(0)),u++)}(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Jie(this.points,e,!1),this.roundedCurveDivisions=Jie(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return 2*function(r,n,s,a=12,o=!0){let l=BH.set(0,0,0),h=0,u=[];for(let d=0;d<n.length;d++){if(s[d]===!1)continue;let c,p=sO(n[d]),f=dy,m=uy(p,a);u.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof df||p instanceof wh){if(p.getPoint(g/m,f),l.set(f.x,f.y,0),c?.equals(l))continue;c===void 0?c=LH:(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}(e,this.curves,t,i,this.autoClose).reduce((r,n)=>r+n,0)}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),function(i,r,n=12,s=!0){let a,o=0;for(let l=0;l<r.length;l++){let h=sO(r[l]),u=uy(h,n),d=dy;for(let c=0;c<=u;c++)if(h instanceof pu||h instanceof df||h instanceof wh){if(h.getPoint(c/u,d),a!==void 0&&GBe(a,d,Vb))continue;a===void 0&&(a=HA),a.copy(d),i.push(d.x,d.y),o++}}return ZM(i[0],i[i.length-2],Vb)&&ZM(i[1],i[i.length-1],Vb)&&(i.pop(),i.pop()),s&&o>1&&!(ZM(i[o-1],i[1],Vb)&&ZM(i[o-2],i[0],Vb))&&(i.push(i[0],i[1]),o++),i}(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=.5*uy(this.points[0].roundedCurveCorner,this.subdivision));let s=e-n;s<0&&(s+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(s<i+l)return[a,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(Zie(r,n)){let l=r.position.distanceTo(n.position);return r.position.distanceTo(H3.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){Zie(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let n=this.points[t-1];this._applyCurveForPoint(r,n)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let n=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=n.roundness,l=s&&a&&WBe(s,n,a);if(!n.controlsMoved()&&o>0&&!l){let h=n.curveBefore,u=n.curveAfter;if(h===void 0||u===void 0)continue;let d,c=n.roundedCurveBefore,p=n.roundedCurveAfter,f=h instanceof wh?h.v1.distanceTo(h.v2):h.getLength(),m=u instanceof wh?u.v1.distanceTo(u.v2):u.getLength(),g=Math.min(o,.499*f),v=Math.min(o,.499*m),y=Math.min(g,v),_=1-y/f,b=y/m,x=h.getPointAt(_,H3),w=u.getPointAt(b,ere);if(this._subSplitCurve(h,c,_,x,void 0),this._subSplitCurve(u,p,b,void 0,w),this.useCubicForRoundedCorners){let S=fwe(x,n.position,w)/2,T=Math.tan(S)*x.distanceTo(n.position),[M,E]=HBe(x,w,T,tre,ire),A=qBe(M,E,n.position),[C,D]=$Be(A,x,w,T,rre,nre);d=new pu(x.clone(),C.clone(),D.clone(),w.clone())}else d=new df(x.clone(),n.position.clone(),w.clone());n.roundedCurveCorner=d,this.roundedCurves.splice(i+t,0,d),t++}}}}_subSplitCurve(e,t,i,r,n){if(!(e instanceof wh)){let s=e,a=t,o=s.getUtoTmapping(i,0),l=function(h,u,d,c,p=.5){let f=dy.subVectors(u,h).multiplyScalar(p).add(h),m=HA.subVectors(d,u).multiplyScalar(p).add(u),g=mwe.subVectors(c,d).multiplyScalar(p).add(d),v=f,y=gwe.subVectors(m,f).multiplyScalar(p).add(f),_=vwe.subVectors(g,m).multiplyScalar(p).add(m),b=g,x=ywe.subVectors(_,y).multiplyScalar(p).add(y);return[h.x,h.y,v.x,v.y,y.x,y.y,x.x,x.y,_.x,_.y,b.x,b.y,c.x,c.y]}(s.v0,s.v1,s.v2,s.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])),n!==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&&t.v2.copy(r),n!==void 0&&t.v1.copy(n),t}clone(){let e=new cs(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=7*i,n=e.points[r+0],s=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],u=e.points[r+6],d=new My(Qe.generateUUID(),new Z(n,s));d.controls[0].position.set(a,o),d.controls[1].position.set(l,h),d.roundness=u,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new cs;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(r,n)=>{n instanceof pu&&n.v3.equals(r.position)&&r.controls[0].position.copy(n.v2)};return this.points=(r=>{let n,s,a=[];for(n=0,s=r.length;n<s;n++)r[n]instanceof df&&(r[n]=VBe(r[n]));for(n=0,s=r.length;n<s;n++){let h,u=r[n],d=n>0?r[n-1]:null;u instanceof pu?(h=this.createPoint(u.v0),h.controls[1].position.copy(u.v1)):u instanceof wh&&(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 pu?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof wh&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(e.curves),e instanceof AA&&(this.shapeHoles=e.holes.map(r=>{let n=new cs;return n.fromShape(r),n})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}}});function k5({x:e,y:t},i,r,n,s){return{x:e*i+n,y:t*r+s}}function XBe(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),n=Math.sin(e),s=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-n*i,y:n+r*i},{x:s+a*i,y:a-s*i},{x:s,y:a}]}function sre(e,t,i,r){let n=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return n*Math.acos(s)}var aO,YBe=F(()=>{aO=2*Math.PI});function wi(e,t){if(!e)throw t||"Assertion Failed!"}function qE(e){var t=e.windingRule,i=t===void 0?is.ODD:t,r=e.elementType,n=r===void 0?bo.POLYGONS:r,s=e.polySize,a=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,d=e.contours,c=d===void 0?[]:d,p=e.strict,f=p===void 0||p,m=e.debug,g=m!==void 0&&m;if(!c&&f)throw new Error("Contours can't be empty");if(c){var v=new bwe;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<c.length;y++)v.addContour(l||2,c[y]);return v.tesselate(i,n,a,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var is,bo,di,i_,ZS,z0,V5,G5,j5,are,q3,W5,ore,lre,bwe,pC=F(()=>{var e;(e=is||(is={}))[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(t){t[t.POLYGONS=0]="POLYGONS",t[t.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",t[t.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(bo||(bo={})),di=function(){function t(){}return t.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},t.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},t.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},t.edgeGoesLeft=function(i){return t.vertLeq(i.Dst,i.Org)},t.edgeGoesRight=function(i){return t.vertLeq(i.Org,i.Dst)},t.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},t.edgeEval=function(i,r,n){wi(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?s<a?r.t-i.t+(i.t-n.t)*(s/(s+a)):r.t-n.t+(n.t-i.t)*(a/(s+a)):0},t.edgeSign=function(i,r,n){wi(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?(r.t-n.t)*s+(r.t-i.t)*a:0},t.transEval=function(i,r,n){wi(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?s<a?r.s-i.s+(i.s-n.s)*(s/(s+a)):r.s-n.s+(n.s-i.s)*(a/(s+a)):0},t.transSign=function(i,r,n){wi(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?(r.s-n.s)*s+(r.s-i.s)*a:0},t.vertCCW=function(i,r,n){return i.s*(r.t-n.t)+r.s*(n.t-i.t)+n.s*(i.t-r.t)>=0},t.interpolate=function(i,r,n,s){return(i=i<0?0:i)<=(n=n<0?0:n)?n===0?(r+s)/2:r+i/(i+n)*(s-r):s+n/(i+n)*(r-s)},t.intersect=function(i,r,n,s,a){var o,l,h;t.vertLeq(i,r)||(h=i,i=r,r=h),t.vertLeq(n,s)||(h=n,n=s,s=h),t.vertLeq(i,n)||(h=i,i=n,n=h,h=r,r=s,s=h),t.vertLeq(n,r)?t.vertLeq(r,s)?((o=t.edgeEval(i,n,r))+(l=t.edgeEval(n,r,s))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,r.s)):((o=t.edgeSign(i,n,r))+(l=-t.edgeSign(i,s,r))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,s.s)):a.s=(n.s+r.s)/2,t.transLeq(i,r)||(h=i,i=r,r=h),t.transLeq(n,s)||(h=n,n=s,s=h),t.transLeq(i,n)||(h=i,i=n,n=h,h=r,r=s,s=h),t.transLeq(n,r)?t.transLeq(r,s)?((o=t.transEval(i,n,r))+(l=t.transEval(n,r,s))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,r.t)):((o=t.transSign(i,n,r))+(l=-t.transSign(i,s,r))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,s.t)):a.t=(n.t+r.t)/2},t}(),i_=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},ZS=function(){function t(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(t.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),t}(),z0=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},V5=function(){function t(){var i=new z0,r=new i_,n=new ZS(0),s=new ZS(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,n.next=n,n.Sym=s,s.next=s,s.Sym=n,this.vHead=i,this.fHead=r,this.eHead=n,this.eHeadSym=s}return t.prototype.makeEdge_=function(i){var r=new ZS(0),n=new ZS(1);i.Sym.side<i.side&&(i=i.Sym);var s=i.Sym.next;return n.next=s,s.Sym.next=r,r.next=i,i.Sym.next=n,r.Sym=n,r.Onext=r,r.Lnext=n,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,n.Sym=r,n.Onext=n,n.Lnext=r,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,r},t.prototype.splice_=function(i,r){var n=i.Onext,s=r.Onext;n.Sym.Lnext=r,s.Sym.Lnext=i,i.Onext=s,r.Onext=n},t.prototype.makeVertex_=function(i,r,n){var s=i;wi(s,"Vertex can't be null!");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r;var o=r;do o.Org=s,o=o.Onext;while(o!==r)},t.prototype.makeFace_=function(i,r,n){var s=i;wi(s,"Face can't be null");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r,s.trail=null,s.marked=!1,s.inside=n.inside;var o=r;do o.Lface=s,o=o.Lnext;while(o!==r)},t.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,n=i.Sym.next;r.Sym.next=n,n.Sym.next=r},t.prototype.killVertex_=function(i,r){var n=i.anEdge,s=n;do s.Org=r,s=s.Onext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.killFace_=function(i,r){var n=i.anEdge,s=n;do s.Lface=r,s=s.Lnext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.makeEdge=function(){var i=new z0,r=new z0,n=new i_,s=this.makeEdge_(this.eHead);return this.makeVertex_(i,s,this.vHead),this.makeVertex_(r,s.Sym,this.vHead),this.makeFace_(n,s,this.fHead),s},t.prototype.splice=function(i,r){var n=!1,s=!1;if(i!==r){if(r.Org!==i.Org&&(s=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!s){var a=new z0;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!n){var o=new i_;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},t.prototype.delete=function(i){var r=i.Sym,n=!1;if(i.Lface!==i.Rface&&(n=!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),!n){var s=new i_;this.makeFace_(s,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)},t.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),n=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var s=new z0;return this.makeVertex_(s,n,r.Org),r.Lface=n.Lface=i.Lface,r},t.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},t.prototype.connect=function(i,r){var n=!1,s=this.makeEdge_(i),a=s.Sym;if(r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(s,i.Lnext),this.splice_(a,r),s.Org=i.Dst,a.Org=r.Org,s.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!n){var o=new i_;this.makeFace_(o,s,i.Lface)}return s},t.prototype.zapFace=function(i){var r,n,s,a,o,l=i.anEdge;n=l.Lnext;do n=(r=n).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)),(s=r.Sym).Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},t.prototype.countFaceVerts_=function(i){var r=i.anEdge,n=0;do n++,r=r.Lnext;while(r!==i.anEdge);return n},t.prototype.mergeConvexFaces=function(i){var r,n,s,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(n=r.anEdge).Org;s=n.Lnext,(a=n.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&di.vertCCW(n.Lprev.Org,n.Org,a.Lnext.Lnext.Org)&&di.vertCCW(a.Lprev.Org,a.Org,n.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),n=null,a=null),!n||n.Lnext.Org!==o;)n=s;return!0},t.prototype.check=function(){var i,r,n,s,a,o,l=this.fHead,h=this.vHead,u=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){wi(i.prev===r),a=i.anEdge;do wi(a.Sym!==a),wi(a.Sym.Sym===a),wi(a.Lnext.Onext.Sym===a),wi(a.Onext.Sym.Lnext===a),wi(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(wi(i.prev===r&&i.anEdge===null),s=h,s=h;(n=s.next)!==h;s=n){wi(n.prev===s),a=n.anEdge;do wi(a.Sym!==a),wi(a.Sym.Sym===a),wi(a.Lnext.Onext.Sym===a),wi(a.Onext.Sym.Lnext===a),wi(a.Org===n),a=a.Onext;while(a!==n.anEdge)}for(wi(n.prev===s&&n.anEdge===null),o=u,o=u;(a=o.next)!==u;o=a)wi(a.Sym.next===o.Sym),wi(a.Sym!==a),wi(a.Sym.Sym===a),wi(a.Org!==null),wi(a.Dst!==null),wi(a.Lnext.Onext.Sym===a),wi(a.Onext.Sym.Lnext===a);wi(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)},t}(),G5=function(){this.handle=null},j5=function(){this.key=null,this.node=0},are=function(){function t(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 n=0;n<i+1;n++)this.nodes[n]=new G5,this.handles[n]=new j5;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return t.prototype.floatDown_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((s=i<<1)<this.size&&this.leq(o[a[s+1].handle].key,o[a[s].handle].key)&&++s,wi(s<=this.max),n=a[s].handle,s>this.size||this.leq(o[r].key,o[n].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.floatUp_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(n=a[s=i>>1].handle,s===0||this.leq(o[n].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},t.prototype.min=function(){return this.handles[this.nodes[1].handle].key},t.prototype.insert=function(i){var r,n;if(2*(r=++this.size)>this.max){var s,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new G5;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new j5}return this.freeList===0?n=r:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[r].handle=n,this.handles[n].node=r,this.handles[n].key=i,this.initialized&&this.floatUp_(r),n},t.prototype.extractMin=function(){var i=this.nodes,r=this.handles,n=i[1].handle,s=r[n].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[n].key=null,r[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),s},t.prototype.delete=function(i){var r,n=this.nodes,s=this.handles;wi(i>=1&&i<=this.max&&s[i].key!==null),n[r=s[i].node].handle=n[this.size].handle,s[n[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(s[n[r>>1].handle].key,s[n[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),s[i].key=null,s[i].node=this.freeList,this.freeList=i},t}(),q3=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},W5=function(){this.key=null,this.next=null,this.prev=null},ore=function(){function t(i,r){this.frame=i,this.leq=r,this.head=new W5,this.head.next=this.head,this.head.prev=this.head}return t.prototype.min=function(){return this.head.next},t.prototype.max=function(){return this.head.prev},t.prototype.insert=function(i){return this.insertBefore(this.head,i)},t.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},t.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var n=new W5;return n.key=r,n.next=i.next,i.next.prev=n,n.prev=i,i.next=n,n},t.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},t}(),lre=function(){function t(){}return t.regionBelow=function(i){return i.nodeUp.prev.key},t.regionAbove=function(i){return i.nodeUp.next.key},t.debugEvent=function(i){},t.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.edgeLeq=function(i,r,n){var s=i.event,a=r.eUp,o=n.eUp;return a.Dst===s?o.Dst===s?di.vertLeq(a.Org,o.Org)?di.edgeSign(o.Dst,a.Org,o.Org)<=0:di.edgeSign(a.Dst,o.Org,a.Org)>=0:di.edgeSign(o.Dst,s,o.Org)<=0:o.Dst===s?di.edgeSign(a.Dst,s,a.Org)>=0:di.edgeEval(a.Dst,s,a.Org)>=di.edgeEval(o.Dst,s,o.Org)},t.deleteRegion=function(i,r){r.fixUpperEdge&&wi(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},t.fixUpperEdge=function(i,r,n){wi(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=n,n.activeRegion=r},t.topLeftRegion=function(i,r){var n,s=r.eUp.Org;do r=t.regionAbove(r);while(r.eUp.Org===s);if(r.fixUpperEdge){if((n=i.mesh.connect(t.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;t.fixUpperEdge(i,r,n),r=t.regionAbove(r)}return r},t.topRightRegion=function(i){var r=i.eUp.Dst;do i=t.regionAbove(i);while(i.eUp.Dst===r);return i},t.addRegionBelow=function(i,r,n){var s=new q3;return s.eUp=n,s.nodeUp=i.dict.insertBefore(r.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,n.activeRegion=s,s},t.isWindingInside=function(i,r){switch(i.windingRule){case is.ODD:return!!(1&r);case is.NONZERO:return r!==0;case is.POSITIVE:return r>0;case is.NEGATIVE:return r<0;case is.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},t.computeWinding=function(i,r){r.windingNumber=t.regionAbove(r).windingNumber+r.eUp.winding,r.inside=t.isWindingInside(i,r.windingNumber)},t.finishRegion=function(i,r){var n=r.eUp,s=n.Lface;s.inside=r.inside,s.anEdge=n,t.deleteRegion(i,r)},t.finishLeftRegions=function(i,r,n){for(var s,a=null,o=r,l=r.eUp;o!==n;){if(o.fixUpperEdge=!1,(s=(a=t.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){t.finishRegion(i,o);break}s=i.mesh.connect(l.Lprev,s.Sym),t.fixUpperEdge(i,a,s)}l.Onext!==s&&(i.mesh.splice(s.Oprev,s),i.mesh.splice(l,s)),t.finishRegion(i,o),l=a.eUp,o=a}return l},t.addRightEdges=function(i,r,n,s,a,o){var l,h,u,d,c=!0;u=n;do wi(di.vertLeq(u.Org,u.Dst)),t.addRegionBelow(i,r,u.Sym),u=u.Onext;while(u!==s);for(a===null&&(a=t.regionBelow(r).eUp.Rprev),h=r,d=a;(u=(l=t.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=t.isWindingInside(i,l.windingNumber),h.dirty=!0,!c&&t.checkForRightSplice(i,h)&&(t.addWinding(u,d),t.deleteRegion(i,h),i.mesh.delete(d)),c=!1,h=l,d=u;h.dirty=!0,wi(h.windingNumber-u.winding===l.windingNumber),o&&t.walkDirtyRegions(i,h)},t.spliceMergeVertices=function(i,r,n){i.mesh.splice(r,n)},t.vertexWeights=function(i,r,n){var s=di.vertL1dist(r,i),a=di.vertL1dist(n,i),o=.5*a/(s+a),l=.5*s/(s+a);i.coords[0]+=o*r.coords[0]+l*n.coords[0],i.coords[1]+=o*r.coords[1]+l*n.coords[1],i.coords[2]+=o*r.coords[2]+l*n.coords[2]},t.getIntersectData=function(i,r,n,s,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,t.vertexWeights(r,n,s),t.vertexWeights(r,a,o)},t.checkForRightSplice=function(i,r){var n=t.regionBelow(r),s=r.eUp,a=n.eUp;if(di.vertLeq(s.Org,a.Org)){if(di.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;di.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(i.pq.delete(s.Org.pqHandle),t.spliceMergeVertices(i,a.Oprev,s)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(s,a.Oprev),r.dirty=n.dirty=!0)}else{if(di.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(s.Sym),i.mesh.splice(a.Oprev,s)}return!0},t.checkForLeftSplice=function(i,r){var n,s=t.regionBelow(r),a=r.eUp,o=s.eUp;if(wi(!di.vertEq(a.Dst,o.Dst)),di.vertLeq(a.Dst,o.Dst)){if(di.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,n=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,n),n.Lface.inside=r.inside}else{if(di.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=s.dirty=!0,n=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),n.Rface.inside=r.inside}return!0},t.checkForIntersect=function(i,r){var n,s,a=t.regionBelow(r),o=r.eUp,l=a.eUp,h=o.Org,u=l.Org,d=o.Dst,c=l.Dst,p=new z0;if(wi(!di.vertEq(c,d)),wi(di.edgeSign(d,i.event,h)<=0),wi(di.edgeSign(c,i.event,u)>=0),wi(h!==i.event&&u!==i.event),wi(!r.fixUpperEdge&&!a.fixUpperEdge),h===u||Math.min(h.t,d.t)>Math.max(u.t,c.t))return!1;if(di.vertLeq(h,u)){if(di.edgeSign(c,h,u)>0)return!1}else if(di.edgeSign(d,u,h)<0)return!1;return t.debugEvent(i),di.intersect(d,h,c,u,p),wi(Math.min(h.t,d.t)<=p.t),wi(p.t<=Math.max(u.t,c.t)),wi(Math.min(c.s,d.s)<=p.s),wi(p.s<=Math.max(u.s,h.s)),di.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),n=di.vertLeq(h,u)?h:u,di.vertLeq(n,p)&&(p.s=n.s,p.t=n.t),di.vertEq(p,h)||di.vertEq(p,u)?(t.checkForRightSplice(i,r),!1):!di.vertEq(d,i.event)&&di.edgeSign(d,i.event,p)>=0||!di.vertEq(c,i.event)&&di.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=t.topLeftRegion(i,r),o=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),a),t.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=t.topRightRegion(r),s=t.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=t.finishLeftRegions(i,a,null),t.addRightEdges(i,r,l.Onext,o.Rprev,s,!0),!0):(di.edgeSign(d,i.event,p)>=0&&(t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),di.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),t.getIntersectData(i,o.Org,h,d,u,c),t.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},t.walkDirtyRegions=function(i,r){for(var n,s,a=t.regionBelow(r);;){for(;a.dirty;)r=a,a=t.regionBelow(a);if(!r.dirty&&(a=r,(r=t.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,n=r.eUp,s=a.eUp,n.Dst!==s.Dst&&t.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(t.deleteRegion(i,a),i.mesh.delete(s),s=(a=t.regionBelow(r)).eUp):r.fixUpperEdge&&(t.deleteRegion(i,r),i.mesh.delete(n),n=(r=t.regionAbove(a)).eUp)),n.Org!==s.Org){if(n.Dst===s.Dst||r.fixUpperEdge||a.fixUpperEdge||n.Dst!==i.event&&s.Dst!==i.event)t.checkForRightSplice(i,r);else if(t.checkForIntersect(i,r))return}n.Org===s.Org&&n.Dst===s.Dst&&(t.addWinding(s,n),t.deleteRegion(i,r),i.mesh.delete(n),r=t.regionAbove(a))}},t.connectRightVertex=function(i,r,n){var s,a=n.Onext,o=t.regionBelow(r),l=r.eUp,h=o.eUp,u=!1;l.Dst!==h.Dst&&t.checkForIntersect(i,r),di.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=t.topLeftRegion(i,r),a=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),o),u=!0),di.vertEq(h.Org,i.event)&&(i.mesh.splice(n,h.Oprev),n=t.finishLeftRegions(i,o,null),u=!0),u?t.addRightEdges(i,r,n.Onext,a,a,!0):(s=di.vertLeq(h.Org,l.Org)?h.Oprev:l,s=i.mesh.connect(n.Lprev,s),t.addRightEdges(i,r,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,t.walkDirtyRegions(i,r))},t.connectLeftDegenerate=function(i,r,n){var s,a,o,l,h;return s=r.eUp,di.vertEq(s.Org,n)?(wi(!1),void t.spliceMergeVertices(i,s,n.anEdge)):di.vertEq(s.Dst,n)?(wi(!1),r=t.topRightRegion(r),a=l=(o=(h=t.regionBelow(r)).eUp.Sym).Onext,h.fixUpperEdge&&(wi(a!==o),t.deleteRegion(i,h),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(n.anEdge,o),di.edgeGoesLeft(a)||(a=null),void t.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(s.Sym),r.fixUpperEdge&&(i.mesh.delete(s.Onext),r.fixUpperEdge=!1),i.mesh.splice(n.anEdge,s),void t.sweepEvent(i,n))},t.connectLeftVertex=function(i,r){var n,s,a,o,l,h,u=new q3;if(u.eUp=r.anEdge.Sym,n=i.dict.search(u).key,s=t.regionBelow(n)){if(o=n.eUp,l=s.eUp,di.edgeSign(o.Dst,r,o.Org)===0)return void t.connectLeftDegenerate(i,n,r);a=di.vertLeq(l.Dst,o.Dst)?n:s,n.inside||a.fixUpperEdge?(h=a===n?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?t.fixUpperEdge(i,a,h):t.computeWinding(i,t.addRegionBelow(i,n,h)),t.sweepEvent(i,r)):t.addRightEdges(i,n,r.anEdge,r.anEdge,null,!0)}},t.sweepEvent=function(i,r){i.event=r,t.debugEvent(i);for(var n=r.anEdge;n.activeRegion===null;)if((n=n.Onext)===r.anEdge)return void t.connectLeftVertex(i,r);var s=t.topLeftRegion(i,n.activeRegion);wi(s!==null);var a=t.regionBelow(s),o=a.eUp,l=t.finishLeftRegions(i,a,null);l.Onext===o?t.connectRightVertex(i,s,l):t.addRightEdges(i,s,l.Onext,o,o,!0)},t.addSentinel=function(i,r,n,s){var a=new q3,o=i.mesh.makeEdge();o.Org.s=n,o.Org.t=s,o.Dst.s=r,o.Dst.t=s,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)},t.initEdgeDict=function(i){i.dict=new ore(i,t.edgeLeq);var r=i.bmax[0]-i.bmin[0],n=i.bmax[1]-i.bmin[1],s=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-n,l=i.bmax[1]+n;t.addSentinel(i,s,a,o),t.addSentinel(i,s,a,l)},t.doneEdgeDict=function(i){for(var r,n=0;(r=i.dict.min().key)!==null;)r.sentinel||(wi(r.fixUpperEdge),wi(++n===1)),wi(r.windingNumber===0),t.deleteRegion(i,r)},t.removeDegenerateEdges=function(i){var r,n,s,a=i.mesh.eHead;for(r=a.next;r!==a;r=n)n=r.next,s=r.Lnext,di.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(t.spliceMergeVertices(i,s,r),i.mesh.delete(r),s=(r=s).Lnext),s.Lnext===r&&(s!==r&&((s===n||s===n.Sym)&&(n=n.next),i.mesh.delete(s)),(r===n||r===n.Sym)&&(n=n.next),i.mesh.delete(r))},t.initPriorityQ=function(i){var r,n,s,a=0;for(n=(s=i.mesh.vHead).next;n!==s;n=n.next)a++;for(a+=8,r=i.pq=new are(a,di.vertLeq),n=(s=i.mesh.vHead).next;n!==s;n=n.next)n.pqHandle=r.insert(n);return n===s&&(r.init(),!0)},t.donePriorityQ=function(i){i.pq=null},t.removeDegenerateFaces=function(i,r){var n,s,a;for(n=r.fHead.next;n!==r.fHead;n=s)s=n.next,wi((a=n.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(t.addWinding(a.Onext,a),i.mesh.delete(a));return!0},t.computeInterior=function(i,r){var n,s;if(r===void 0&&(r=!0),t.removeDegenerateEdges(i),!t.initPriorityQ(i))return!1;for(t.initEdgeDict(i);(n=i.pq.extractMin())!==null;){for(;(s=i.pq.min())!==null&&di.vertEq(s,n);)s=i.pq.extractMin(),t.spliceMergeVertices(i,n.anEdge,s.anEdge);t.sweepEvent(i,n)}return i.event=i.dict.min().key.eUp.Org,t.debugEvent(i),t.doneEdgeDict(i),t.donePriorityQ(i),!!t.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},t}(),bwe=function(){function t(){this.mesh=new V5,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=is.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 t.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},t.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},t.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},t.prototype.computeNormal_=function(i){var r,n,s,a,o,l,h=[0,0,0],u=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],g=this.mesh.vHead;r=g.next;for(var v=0;v<3;++v)a=r.coords[v],u[v]=a,m[v]=r,h[v]=a,f[v]=r;for(r=g.next;r!==g;r=r.next)for(var y=0;y<3;++y)(a=r.coords[y])<u[y]&&(u[y]=a,m[y]=r),a>h[y]&&(h[y]=a,f[y]=r);var _=0;if(h[1]-u[1]>h[0]-u[0]&&(_=1),h[2]-u[2]>h[_]-u[_]&&(_=2),u[_]>=h[_])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,n=m[_],s=f[_],d[0]=n.coords[0]-s.coords[0],d[1]=n.coords[1]-s.coords[1],d[2]=n.coords[2]-s.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.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)},t.prototype.checkOrientation_=function(){for(var i,r,n=this.mesh.fHead,s=this.mesh.vHead,a=0,o=n.next;o!==n;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=s.next;i!==s;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]}},t.prototype.projectPolygon_=function(){var i,r,n=this.mesh.vHead,s=[0,0,0],a=!1;s[0]=this.normal[0],s[1]=this.normal[1],s[2]=this.normal[2],!s[0]&&!s[1]&&!s[2]&&(this.computeNormal_(s),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(s);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]=s[o]>0?1:-1;for(var l=n.next;l!==n;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=n.next;u!==n;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))},t.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.prototype.tessellateMonoRegion_=function(i,r){var n,s;if((n=r.anEdge).Lnext===n||n.Lnext.Lnext===n)throw"Mono region invalid";for(;di.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;di.vertLeq(n.Org,n.Dst);n=n.Lnext);for(s=n.Lprev;n.Lnext!==s;)if(di.vertLeq(n.Dst,s.Org)){for(;s.Lnext!==n&&(di.edgeGoesLeft(s.Lnext)||di.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)s=i.connect(s.Lnext,s).Sym;s=s.Lprev}else{for(;s.Lnext!==n&&(di.edgeGoesRight(n.Lprev)||di.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)n=i.connect(n,n.Lprev).Sym;n=n.Lnext}if(s.Lnext===n)throw"Mono region invalid";for(;s.Lnext.Lnext!==n;)s=i.connect(s.Lnext,s).Sym;return!0},t.prototype.tessellateInterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)if(r=n.next,n.inside&&!this.tessellateMonoRegion_(i,n))return!1;return!0},t.prototype.discardExterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)r=n.next,n.inside||i.zapFace(n)},t.prototype.setWindingNumber_=function(i,r,n){for(var s,a=i.eHead.next;a!==i.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:n?i.delete(a):a.winding=0},t.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},t.prototype.outputPolymesh_=function(i,r,n,s){var a,o,l=0,h=0;n>3&&i.mergeConvexFaces(n);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>n)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===bo.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*n,this.vertexCount=h,this.vertices=[],this.vertices.length=h*s,this.vertexIndices=[],this.vertexIndices.length=h,u=i.vHead.next;u!==i.vHead;u=u.next)if(u.n!==-1){var c=u.n*s;this.vertices[c+0]=u.coords[0],this.vertices[c+1]=u.coords[1],s>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 f=o;f<n;++f)this.elements[p++]=-1;if(r===bo.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<n;++m)this.elements[p++]=-1}}},t.prototype.outputContours_=function(i,r){var n,s,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){s=n=l.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==s);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,s=n=l.anEdge;do this.vertices[h++]=n.Org.coords[0],this.vertices[h++]=n.Org.coords[1],r>2&&(this.vertices[h++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==s);this.elements[d++]=a,this.elements[d++]=o,a+=o}},t.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new V5),i<2&&(i=2),i>3&&(i=3);for(var n=null,s=0;s<r.length;s+=i)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=r[s+0],n.Org.coords[1]=r[s+1],n.Org.coords[2]=i>2?r[s+2]:0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},t.prototype.tesselate=function(i,r,n,s,a,o){if(i===void 0&&(i=is.ODD),r===void 0&&(r=bo.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,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),lre.computeInterior(this,o);var l=this.mesh;return r===bo.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===bo.BOUNDARY_CONTOURS?this.outputContours_(l,s):this.outputPolymesh_(l,r,n,s),!0},t}(),is.ODD,is.NONZERO,is.POSITIVE,is.NEGATIVE,is.ABS_GEQ_TWO,bo.POLYGONS,bo.CONNECTED_POLYGONS,bo.BOUNDARY_CONTOURS});function xwe(e,t){let i=e.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let h=(l+1)%i;r+=e[2*l]*e[2*h+1]-e[2*h]*e[2*l+1]}let n=r>0!==t?1:-1,s=[];for(let l=0;l<i;l++){let h=(l+1)%i,u=e[2*h]-e[2*l],d=e[2*h+1]-e[2*l+1],c=Math.hypot(u,d);s.push(c>0?[n*d/c,-n*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 s.map((l,h)=>[o(l,s[(h+i-1)%i]),o(l,s[(h+1)%i])])}function wwe(e,t,i){let r=e.length/2,n=new Float32Array(r+1);if(!(t>0)||!(i>0)||r<2)return{u:n,vScale:0};let s=0;for(let a=0;a<r;a++){let o=(a+1)%r;s+=Math.hypot((e[2*o]-e[2*a])/t,(e[2*o+1]-e[2*a+1])/i),n[a+1]=s}return{u:n,vScale:Math.sqrt(t*i)}}function Swe(e,t,i){for(let r=0;r<i.length;r+=3){let n=3*i[r],s=3*i[r+1],a=3*i[r+2],o=e[s]-e[n],l=e[s+1]-e[n+1],h=e[s+2]-e[n+2],u=e[a]-e[n],d=e[a+1]-e[n+1],c=e[a+2]-e[n+2],p=h*u-o*c,f=o*d-l*u;if((l*c-h*d)*(t[n]+t[s]+t[a])+p*(t[n+1]+t[s+1]+t[a+1])+f*(t[n+2]+t[s+2]+t[a+2])<0){let m=i[r+1];i[r+1]=i[r+2],i[r+2]=m}}}var eK,Twe,tK,Mwe=F(()=>{}),iK=F(()=>{eK={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Twe={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},tK={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 Ewe(e,t){return e.normals[3*t+2]<.9999}function Awe(e){let t=FH.get(e);if(t!==void 0)return t;if(!(e.rise>0))return e;let i=new Float32Array(e.normals),r=e.positions.length/3;for(let s=0;s<r;s++){if(!Ewe(e,s))continue;let a=i[3*s],o=i[3*s+1],l=Math.hypot(a,o);if(l===0)continue;let h=e.rise-e.positions[3*s+2],u=Math.min(1,Math.max(0,1-h/e.rise)),d=Math.sqrt(1-u*u);i[3*s]=a/l*d,i[3*s+1]=o/l*d,i[3*s+2]=u}let n={...e,normals:i};return FH.set(e,n),n}function Cwe(e,t,i,r){let n=(t-e.minX)/e.spanX,s=(i-e.minY)/e.spanY;return r?[s,n]:[n,s]}var FH,h4,UH,rK=F(()=>{FH=new WeakMap}),KBe=F(()=>{ne(),pC(),Vr(),Mwe(),iK(),rK(),h4=class extends Mt{constructor(e,t,i=12,r=is.ODD,n,s=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=e,this._depth=t,this._curveSegments=i,this._windingRule=r,this._uvPitch=s?void 0:n,this._legacy=s;let a,o=[e.extractShapePointsToFlatArray([],i),...e.shapeHoles.map(O=>O.extractShapePointsToFlatArray([],i))];try{a=qE({contours:o,windingRule:r,elementType:bo.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=tK}let l=a?.vertexCount??0,h=a?.elementCount??0,u=1/0,d=1/0,c=-1/0,p=-1/0;for(let O of o)for(let k=0;k<O.length;k+=2)O[k]<u&&(u=O[k]),O[k]>c&&(c=O[k]),O[k+1]<d&&(d=O[k+1]),O[k+1]>p&&(p=O[k+1]);let f=this._uvPitch,m=f??(c-u||1),g=f??(p-d||1),v=f===void 0?u:0,y=f===void 0?d:0,_=o.map((O,k)=>xwe(O,k>0)),b=0;for(let O of _)b+=O.length;let x=2*l+4*b,w=3*h*2+6*b,S=new Float32Array(3*x),T=new Float32Array(3*x),M=new Float32Array(2*x),E=new Uint32Array(w),A=new Uint8Array(x),C=0,D=0,R=0,I=!1,U=(O,k,G,K,q,Y,ue=(O-v)/m,de=(k-y)/g)=>{let ge=3*D;S[ge]=O,S[ge+1]=k,S[ge+2]=G,T[ge]=K,T[ge+1]=q,T[ge+2]=Y,A[D]=G===t?I?2:1:0,M[2*D]=ue,M[2*D+1]=de,D++};if(a!==void 0)for(let[O,k]of[[t,1],[0,-1]]){let G=D;for(let K=0;K<l;K++)U(a.vertices[2*K],a.vertices[2*K+1],O,0,0,k);for(let K=0;K<h;K++){let[q,Y,ue]=[a.elements[3*K],a.elements[3*K+1],a.elements[3*K+2]];E[R++]=G+q,E[R++]=G+(k>0?Y:ue),E[R++]=G+(k>0?ue:Y)}}I=!0;for(let O=0;O<o.length;O++){let k=o[O],G=_[O],K=k.length/2,{u:q,vScale:Y}=s?{u:new Float32Array(K+1),vScale:0}:wwe(k,m,g);C=Y;let ue=Y===0?0:t/Y,de={minX:v,minY:y,spanX:m,spanY:g},ge=(be,[re,xe],j,z)=>{let X=k[2*be],te=k[2*be+1],[V,ae]=s?Cwe(de,X,te,j):[z,j?0:ue];U(X,te,j?0:t,re,xe,0,V,ae)};for(let be=0;be<G.length;be++){let re=(be+1)%K,[xe,j]=G[be],[z,X]=[q[be],q[be+1]],te=D;ge(be,xe,!1,z),ge(be,xe,!0,z),ge(re,j,!1,X),ge(re,j,!0,X),E[R++]=te,E[R++]=te+1,E[R++]=te+2,E[R++]=te+3,E[R++]=te+2,E[R++]=te+1}}Swe(S,T,E),this.setAttribute("position",new Pt(S,3)),this.setAttribute("normal",new Pt(T,3)),this.setAttribute("uv",new Pt(M,2)),this.setIndex(new Pt(E,1)),this._nearSide=A,this._vScale=C}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale)}canShiftDepthTo(e){return this._nearSide.length>0&&this._depth>0&&e>0}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=t,h===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=new h4(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return e.userData=bB(this.userData),e}}}),Pwe=F(()=>{ne(),pC(),Vr(),iK(),UH=class extends Mt{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=is.ODD,this.elementType=bo.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:is.ODD,elementType:bo.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,n,s,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 f=2*c,m=a[f+0],g=a[f+1];if(n!==void 0&&m!==n&&(l=!1),s!==void 0&&g!==s&&(h=!1),n=m,s=g,!l&&!h)break}if(!l&&!h)try{r=qE({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=eK}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new Pt(new Float32Array(3*u),3),this._normalAttribute=new Pt(new Float32Array(3*u),3),this._uvAttribute=new Pt(new Float32Array(2*u),2),this._indexAttribute=new Pt(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,_=u;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1];x<c&&(c=x),x>p&&(p=x),w<f&&(f=w),w>m&&(m=w)}let g=p-c,v=m-f;for(let y=0,_=u;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1],S=(x-c)/g,T=(w-f)/v;this._positionAttribute.setXYZ(y,x,w,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,T)}for(let y=0,_=d;y<_;y++){let b=3*y,x=r.elements[b+0],w=r.elements[b+1],S=r.elements[b+2];this._indexAttribute.setX(b+0,x),this._indexAttribute.setX(b+1,w),this._indexAttribute.setX(b+2,S)}}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 e=new UH(this._shape,this._curveSegments);return e.userData=bB(this.userData),e}}});function ZBe(e){return hre||(hre=async function(){let t=e??"https://unpkg.com/@splinetool/runtime@2.0.204/build",i=Promise.resolve().then(()=>(mQ(),fQ)),[r,n]=await Promise.all([i,fetch(`${t}/bevel.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),fC=r}())}function QBe(e){let t=!1;return e.scene.objects.traverse((i,r)=>{let n=r.geometry;if(n!==void 0&&(Iwe.has(n.type)&&n.depth!==void 0&&n.depth>0&&(n.extrudeBevelSize??0)>0&&(t=!0),n.type==="PathGeometry")){let s=n.extrusion;s!==void 0&&s.capType==="round"&&(s.bevel??0)>0&&(t=!0)}}),t}function Rwe(e,t){let i=[e.extractShapePointsToFlatArray([],t)];for(let o of e.shapeHoles)i.push(o.extractShapePointsToFlatArray([],t));let r=0;for(let o of i)r+=o.length>>1;let n=new Float64Array(2*r),s=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)n.set(i[o],2*a),a+=i[o].length>>1,s[o]=a;return{points:n,ends:s}}function u4(e,t,i,r,n,s){let a=e.positions.length/3,o=n.elements,l=Owe.getNormalMatrix(n).elements;for(let u=0;u<a;u++){let d=3*u,c=3*(i+u),p=e.positions[d],f=e.positions[d+1],m=e.positions[d+2];t.positions[c]=o[0]*p+o[4]*f+o[8]*m+o[12],t.positions[c+1]=o[1]*p+o[5]*f+o[9]*m+o[13],t.positions[c+2]=o[2]*p+o[6]*f+o[10]*m+o[14];let g=e.normals[d],v=e.normals[d+1],y=e.normals[d+2];t.normals[c]=l[0]*g+l[3]*v+l[6]*y,t.normals[c+1]=l[1]*g+l[4]*v+l[7]*y,t.normals[c+2]=l[2]*g+l[5]*v+l[8]*y;let _=2*(i+u);if(s===void 0)t.uvs[_]=e.uvs[2*u],t.uvs[_+1]=e.uvs[2*u+1];else{let[b,x]=s(p,f,e.uvs[2*u],e.uvs[2*u+1],u);t.uvs[_]=b,t.uvs[_+1]=x}}let h=n.determinant()<0;for(let u=0;u<e.indices.length;u+=3)t.indices[r+u]=e.indices[u]+i,t.indices[r+u+1]=e.indices[u+(h?2:1)]+i,t.indices[r+u+2]=e.indices[u+(h?1:2)]+i}function Dwe(e){let{owner:t,shape:i,curveSegments:r,assembledAt:n,bevel:s,bevelSegments:a}=e,o=function(c,p){let f=[p],m=g=>{f.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let v of g.points){f.push(v.roundness??0,v.position.x,v.position.y);for(let y of v.controls)f.push(y.position.x,y.position.y)}f.push(g.shapeHoles.length);for(let v of g.shapeHoles)m(v)};return m(c),function(g){let v=2166136261;for(let y=0;y<g.length;y++)v^=g[y],v=Math.imul(v,16777619)>>>0;return v}(new Uint8Array(new Float64Array(f).buffer))}(i,r),l=t??`outline:${o}`,h=`${s}/${a}`,u=d4.get(l);if(u!==void 0&&u.outlineVersion===o&&u.capKey===h&&(e.stillServes?.(u)??1))return zH.placements++,u.cap;let d=function(c,p,f,m,g){let{points:v,ends:y}=Rwe(c,p);return fC.assemble_cap(v,y,f,m,0,Math.max(1,Math.floor(g)),Nwe,40)}(i,r,n,s,a);zH.assemblies++;try{let c=function(p,f){return function(m,g,v,y,_){let b=1/0;for(let x=2;x<m.length;x+=3)m[x]<b&&(b=m[x]);if(b===1/0&&(b=0),b!==0)for(let x=2;x<m.length;x+=3)m[x]-=b;return{positions:m,normals:g,uvs:v,indices:y,rise:_-b}}(p.positions(),p.normals(),p.uvs(),p.indices(),f)}(d,n);return d4.set(l,{outlineVersion:o,capKey:h,assembledAt:n,cap:c}),c}finally{d.free()}}function dx(e,t){return .5*t>1.001*e}var fC,Nwe,hre,Iwe,Owe,ure,dre,cre,d4,zH,kH,l0,Rw=F(()=>{ne(),Vr(),Mwe(),rK(),Nwe=.4,Iwe=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),Owe=new si,ure=new De,dre=new De,cre=new De().makeScale(1,1,-1),d4=new Map,zH={assemblies:0,placements:0},kH=class extends Mt{constructor(e,t,i=0,r=12,n=3,s,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,fC===void 0)throw new Error("bevel-wasm is not loaded");this._shape=e,this._uvPitch=a,this._legacy=o,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegments=n,this._ownerId=s,this.rebuild()}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length>0&&dx(this._effectiveBevel,e)&&dx(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=t,h===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}setDepth(e){e!==this._depth&&(this._depth=e,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let e=Dwe({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>dx(a.cap.rise,this._depth)&&dx(a.cap.rise,a.assembledAt)}),t=function(a,o,l,h,u,d=!1){let c=h.positions.length/3,p=l-h.rise,f=h.rise,{points:m,ends:g}=Rwe(a,o),v=1/0,y=1/0,_=-1/0,b=-1/0;for(let de=0;de<m.length;de+=2)m[de]<v&&(v=m[de]),m[de]>_&&(_=m[de]),m[de+1]<y&&(y=m[de+1]),m[de+1]>b&&(b=m[de+1]);d&&(u=void 0);let x=u??_-v,w=u??b-y,S={minX:v,minY:y,spanX:_-v||1,spanY:b-y||1},T=[],M=0;for(let de of g)T.push({at:M,count:de-M}),M=de;let E=0;for(let de of T)E+=de.count;let A=2*c+4*E,C=new Float32Array(3*A),D=new Float32Array(3*A),R=new Float32Array(2*A),I=new Uint32Array(2*h.indices.length+6*E),U=new Uint8Array(A),O=0,k=u===void 0?void 0:(de,ge)=>[de/u,ge/u],G=d?(de,ge,be,re,xe)=>Ewe(h,xe)?[re,be]:[be,re]:k,K=d?Awe(h):h,q={positions:C,normals:D,uvs:R,indices:I};u4(K,q,0,0,ure.makeTranslation(0,0,p),k),u4(K,q,c,h.indices.length,dre.makeTranslation(0,0,f).multiply(cre),G),U.fill(1,0,c);let Y=2*c,ue=2*h.indices.length;for(let de=0;de<T.length;de++){let{at:ge,count:be}=T[de],re=m.subarray(2*ge,2*(ge+be)),xe=xwe(re,de>0),j=d?{u:new Float32Array(be+1),vScale:0}:wwe(re,x,w),z=j.u;O=j.vScale;for(let X=0;X<be;X++){let te=(X+1)%be,[V,ae]=xe[X],se=Y;for(let[W,pe,_e,Ue,we,Ye]of[[re[2*X],re[2*X+1],V,p,z[X],2],[re[2*te],re[2*te+1],ae,p,z[X+1],2],[re[2*te],re[2*te+1],ae,f,z[X+1],0],[re[2*X],re[2*X+1],V,f,z[X],0]]){let Fe=3*Y;if(C[Fe]=W,C[Fe+1]=pe,C[Fe+2]=Ue,D[Fe]=_e[0],D[Fe+1]=_e[1],D[Fe+2]=0,d){let[We,Re]=Cwe(S,W,pe,Ye===0);R[2*Y]=We,R[2*Y+1]=Re}else R[2*Y]=we,R[2*Y+1]=O===0?0:(Ue-f)/O;U[Y]=Ye,Y++}I[ue++]=se,I[ue++]=se+1,I[ue++]=se+2,I[ue++]=se,I[ue++]=se+2,I[ue++]=se+3}}return Swe(C,D,I),{positions:C,normals:D,uvs:R,indices:I,nearSide:U,vScale:O}}(this._shape,this._curveSegments,this._depth,e,this._uvPitch,this._legacy);this._nearSide=t.nearSide,this._vScale=t.vScale,this._effectiveBevel=e.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),n=this.getAttribute("uv"),s=this.getIndex();if(i!==void 0&&r!==void 0&&n!==void 0&&s!==null&&i.array.length===t.positions.length&&r.array.length===t.normals.length&&n.array.length===t.uvs.length&&s.array.length===t.indices.length)return i.array.set(t.positions),r.array.set(t.normals),n.array.set(t.uvs),s.array.set(t.indices),i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0,void(s.needsUpdate=!0);this.setAttribute("position",new Pt(t.positions,3)),this.setAttribute("normal",new Pt(t.normals,3)),this.setAttribute("uv",new Pt(t.uvs,2)),this.setIndex(new Pt(t.indices,1))}clone(){let e=new kH(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return e.userData=bB(this.userData),e}}}),e0=F(()=>{o0(),KBe(),Pwe(),Rw(),pC(),l0=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:is.ODD},e.parameters),n=Math.abs(r.width),s=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=e.shape??t?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof cs?(i=o,(i.width!==n||i.height!==s)&&i.applySize(n,s)):i=new cs(n,s).fromJSON(o),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&i.update());let h=i??new cs(n,s);return{parameters:Object.assign(r,{width:n,height:s,depth:a,roundness:l}),shape:h,ownerId:e.ownerId??t?.ownerId}}static build(e){let t,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:n,subdivisions:s,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:h}=e.parameters,u=h===1;return e.shape.roundness=a,i<=0?t=new UH(e.shape,s,{windingRule:o}):r<=0?t=new h4(e.shape,i,s,o,l,u):fC!==void 0?t=new kH(e.shape,i,r,s,n,e.ownerId,l,u):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),t=new h4(e.shape,i,s,o,l,u)),Object.assign(t,{userData:{...e,type:"VectorGeometry"}})}}});function JBe(e,t,i,r,n,s){if(r>=nK)return n>30||n%4==0?(function(u,d,c,p=0,f=0,m=0){let g=.5522847498,v=d*g,y=c*g;u.addPoint($3(f-d,m,f-d,m-y,f-d,m+y)),u.addPoint($3(f,m+c,f-v,m+c,f+v,m+c)),u.addPoint($3(f+d,m,f+d,m+y,f+d,m-y)),u.addPoint($3(f,m-c,f+v,m-c,f-v,m-c)),p>0&&Bwe(u,d,c,p)}(e,t,i,s),Math.round(n/4)):pre(e,r,n,t,i,s);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=function({px:u,py:d,cx:c,cy:p,rx:f,ry:m,largeArcFlag:g,sweepFlag:v}){let y=[];if(f===0||m===0)return[];let _=(u-c)/2,b=(d-p)/2;if(_===0&&b===0)return[];f=Math.abs(f),m=Math.abs(m);let x=Math.pow(_,2)/Math.pow(f,2)+Math.pow(b,2)/Math.pow(m,2);x>1&&(f*=Math.sqrt(x),m*=Math.sqrt(x));let w=function(D,R,I,U,O,k,G,K,q,Y){let ue=Math.pow(O,2),de=Math.pow(k,2),ge=Math.pow(G,2),be=Math.pow(K,2),re=ue*de-ue*be-de*ge;re<0&&(re=0),re/=ue*be+de*ge,re=Math.sqrt(re)*(q===Y?-1:1);let xe=re*O/k*K,j=re*-k/O*G,z=xe+(D+I)/2,X=j+(R+U)/2,te=(G-xe)/O,V=(K-j)/k,ae=(-G-xe)/O,se=(-K-j)/k,W=sre(1,0,te,V),pe=sre(te,V,ae,se);return!Y&&pe>0&&(pe-=aO),Y&&pe<0&&(pe+=aO),{centerx:z,centery:X,ang1:W,ang2:pe}}(u,d,c,p,f,m,_,b,g,v),{ang1:S,ang2:T}=w,{centerx:M,centery:E}=w,A=Math.abs(T)/(aO/4);Math.abs(1-A)<1e-7&&(A=1);let C=Math.max(Math.ceil(A),1);T/=C;for(let D=0;D<C;D++)y.push(XBe(S,T)),S+=T;return y.map(D=>{let{x:R,y:I}=k5(D[0],f,m,M,E),{x:U,y:O}=k5(D[1],f,m,M,E),{x:k,y:G}=k5(D[2],f,m,M,E);return{x1:R,y1:I,x2:U,y2:O,x:k,y:G}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length===0?function(u,d,c,p,f,m,g,v){let y=Math.round(f/p.length);u.addPoint(Ox(d,c));for(let _=0,b=p.length;_<b;_++){let x=p[_],w=u.points[_],S=Ox(x.x,x.y);w.controls[1].position.set(x.x1,x.y1),S.controls[0].position.set(x.x2,x.y2),u.addPoint(S)}return v>0?Lwe(u,m,g,v):u.addPoint(Ox(0,0)),y}(e,a.x,a.y,h,n,t,i,s):pre(e,r,n,t,i,s)}function pre(e,t,i,r,n,s){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*n;e.addPoint(Ox(h,u))}return t<nK?s>0?Lwe(e,r,n,s):e.addPoint(Ox(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&Bwe(e,r,n,s)),1}function Ox(e,t){return new My(Qe.generateUUID(),new Z(e,t))}function $3(e,t,i,r,n,s){let a=Ox(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(n,s),a}function Lwe(e,t,i,r){Fwe(e,t,i,r).forEach(n=>e.addPoint(n))}function Bwe(e,t,i,r){let n=Fwe(e,t,i,r),s=new cs;n.forEach(a=>s.addPoint(a)),s.isClosed=!0,e.shapeHoles.push(s)}function Fwe(e,t,i,r){let n=r*t/100,s=n*(Math.abs(i)/Math.abs(t)),a=new Z(n/t,s/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Qe.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 nK,FB,Uwe,H5,zwe,c4=F(()=>{o0(),_we(),YBe(),e0(),ne(),nK=2*Math.PI,FB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=Qe.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let t,{width:i,height:r,spikes:n,angle:s,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=e.parameters,d=e.shape,c=JBe(d,.5*i,.5*r,s*Math.PI/180,n,a);return d.isClosed=!0,d.update(),s===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=l0.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}}),Object.assign(t,{userData:{...e,type:"EllipseGeometry"}})}}}),fre=F(()=>{ne(),pwe(),Uwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new H5(.5*t,s,a):new mW(.5*t,n),l=i/t,h=r/t;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},H5=class extends o4{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n="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],n,e,t,i),this.type=n}static fromJSON(e){return new H5(e.radius,e.corner,e.cornerSides)}}}),mre=F(()=>{ne(),zwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.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}]},e.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(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,n=new AA;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new gW(n.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}}});function r_(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function eFe(e){let{positions:t,faces:i,materialIndices:r,uvs:n}=e,s=t.length/3,a=i.length/3,o=n!==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),f=0,m=8;for(;m<2*l;)m*=2;let g=m-1,v=new Int32Array(m).fill(-1),y=(R,I)=>{let U=(Math.imul(R,2654435761)^I)&g;for(;;){let O=v[U];if(O===-1)return v[U]=f,h[f]=R,u[f]=I,f++;if(h[O]===R&&u[O]===I)return O;U=U+1&g}},_=(R,I)=>{let U=R<I?R:I,O=R<I?I:R,k=(Math.imul(U,2654435761)^O)&g;for(;;){let G=v[k];if(h[G]===U&&u[G]===O)return G;k=k+1&g}},b=new Uint32Array(s),x=new Float64Array(3*s),w=(R,I,U)=>{let O=R<I?y(R,I):y(I,R),k=++d[O];k===1?c[O]=U:k===2&&(p[O]=U),b[R]++,b[I]++,x[3*R]+=t[3*I],x[3*R+1]+=t[3*I+1],x[3*R+2]+=t[3*I+2],x[3*I]+=t[3*R],x[3*I+1]+=t[3*R+1],x[3*I+2]+=t[3*R+2]};for(let R=0;R<a;R++){let I=i[3*R],U=i[3*R+1],O=i[3*R+2];w(I,U,O),w(U,O,I),w(O,I,U)}let S=new Float64Array(3*f);for(let R=0;R<f;R++){let I=3*h[R],U=3*u[R];if(d[R]===2){let O=3*c[R],k=3*p[R];S[3*R]=.375*(t[I]+t[U])+.125*(t[O]+t[k]),S[3*R+1]=.375*(t[I+1]+t[U+1])+.125*(t[O+1]+t[k+1]),S[3*R+2]=.375*(t[I+2]+t[U+2])+.125*(t[O+2]+t[k+2])}else S[3*R]=.5*(t[I]+t[U]),S[3*R+1]=.5*(t[I+1]+t[U+1]),S[3*R+2]=.5*(t[I+2]+t[U+2])}let T,M=new Float64Array(3*s);for(let R=0;R<s;R++){let I=b[R];I===3?T=3/16:I>3&&(T=3/(8*I));let U=1-I*Number(T),O=Number(T);I===2&&(U=3/4,O=1/8),M[3*R]=t[3*R]*U+x[3*R]*O,M[3*R+1]=t[3*R+1]*U+x[3*R+1]*O,M[3*R+2]=t[3*R+2]*U+x[3*R+2]*O}let E=new Float64Array(3*(s+f));E.set(M),E.set(S,3*s);let A=new Uint32Array(12*a),C=new Array(4*a),D=o?new Float64Array(24*a):null;for(let R=0;R<a;R++){let I=i[3*R],U=i[3*R+1],O=i[3*R+2],k=_(I,U)+s,G=_(U,O)+s,K=_(O,I)+s,q=12*R;A[q++]=k,A[q++]=G,A[q++]=K,A[q++]=I,A[q++]=k,A[q++]=K,A[q++]=U,A[q++]=G,A[q++]=k,A[q++]=O,A[q++]=K,A[q++]=G;let Y=r[R];if(C[4*R]=Y,C[4*R+1]=Y,C[4*R+2]=Y,C[4*R+3]=Y,D!==null){let ue=6*R,de=n[ue],ge=n[ue+1],be=n[ue+2],re=n[ue+3],xe=n[ue+4],j=n[ue+5],z=r_(de,be),X=r_(ge,re),te=r_(be,xe),V=r_(re,j),ae=r_(de,xe),se=r_(ge,j),W=24*R;D[W++]=z,D[W++]=X,D[W++]=te,D[W++]=V,D[W++]=ae,D[W++]=se,D[W++]=de,D[W++]=ge,D[W++]=z,D[W++]=X,D[W++]=ae,D[W++]=se,D[W++]=be,D[W++]=re,D[W++]=te,D[W++]=V,D[W++]=z,D[W++]=X,D[W++]=xe,D[W++]=j,D[W++]=ae,D[W++]=se,D[W++]=te,D[W++]=V}}return{positions:E,faces:A,materialIndices:C,uvs:D}}var X3,kwe,ea,Vwe,sK,tFe=F(()=>{ne(),X3=1e4,kwe=class{constructor(e=1){this.subdivisions=e}modify(e){let t=function(r){let n=r.getAttribute("position");if(n===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let s=r.getAttribute("uv"),a=r.getIndex(),o=n.count,l=new Map,h=new Uint32Array(o),u=[],d=0;for(let y=0;y<o;y++){let _=n.getX(y),b=n.getY(y),x=n.getZ(y),w=Math.round(_*X3),S=Math.round(b*X3),T=Math.round(x*X3),M=l.get(w);M===void 0&&(M=new Map,l.set(w,M));let E=M.get(S);E===void 0&&(E=new Map,M.set(S,E));let A=E.get(T);A===void 0&&(A=d++,E.set(T,A),u.push(_,b,x)),h[y]=A}let c=[],p=[],f=s===void 0?null:[],m=a!==null?a.count:o,g=(y,_)=>{let b=a!==null?a.getX(y):y,x=a!==null?a.getX(y+1):y+1,w=a!==null?a.getX(y+2):y+2;if(!(b<o&&x<o&&w<o))return;let S=h[b],T=h[x],M=h[w];S===T||T===M||M===S||(c.push(S,T,M),p.push(_),f!==null&&f.push(s.getX(b),s.getY(b),s.getX(x),s.getY(x),s.getX(w),s.getY(w)))},v=r.groups;if(v.length>0)for(let y=0;y<v.length;y++){let _=v[y],b=_.materialIndex===void 0?0:_.materialIndex,x=Math.max(_.start,0),w=Math.min(_.start+_.count,m);for(let S=x;S<w&&S+2<m;S+=3)g(S,b)}else for(let y=0;y+2<m;y+=3)g(y,0);return{positions:Float64Array.from(u),faces:Uint32Array.from(c),materialIndices:p,uvs:f===null?null:Float64Array.from(f)}}(e),i=this.subdivisions;for(;i-- >0;)t=eFe(t);return function(r,n){let{positions:s,faces:a,materialIndices:o,uvs:l}=r,h=s.length/3,u=a.length/3,d=new Float64Array(3*h);for(let v=0;v<u;v++){let y=3*a[3*v],_=3*a[3*v+1],b=3*a[3*v+2],x=s[b]-s[_],w=s[b+1]-s[_+1],S=s[b+2]-s[_+2],T=s[y]-s[_],M=s[y+1]-s[_+1],E=s[y+2]-s[_+2],A=w*E-S*M,C=S*T-x*E,D=x*M-w*T;d[y]+=A,d[y+1]+=C,d[y+2]+=D,d[_]+=A,d[_+1]+=C,d[_+2]+=D,d[b]+=A,d[b+1]+=C,d[b+2]+=D}for(let v=0;v<h;v++){let y=d[3*v],_=d[3*v+1],b=d[3*v+2],x=Math.sqrt(y*y+_*_+b*b)||1;d[3*v]=y/x,d[3*v+1]=_/x,d[3*v+2]=b/x}let c=3*u,p=new Float32Array(3*c),f=new Float32Array(3*c),m=l!==null&&l.length>0?new Float32Array(2*c):null;for(let v=0;v<c;v++){let y=3*a[v];p[3*v]=s[y],p[3*v+1]=s[y+1],p[3*v+2]=s[y+2],f[3*v]=d[y],f[3*v+1]=d[y+1],f[3*v+2]=d[y+2]}m!==null&&m.set(l.subarray(0,2*c));let g=new Mt;g.setAttribute("position",new Pt(p,3)),c>0&&(g.setAttribute("normal",new Pt(f,3)),g.setAttribute("color",new Pt(new Float32Array(3*c).fill(1),3))),m!==null&&g.setAttribute("uv",new Pt(m,2));for(let v=0;v<u;){let y=o[v],_=v;do v++;while(v<u&&o[v]===y);g.addGroup(3*_,3*(v-_),y)}return n.boundingBox!==null&&(g.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(g.boundingSphere=n.boundingSphere.clone()),g}(t,e)}}}),gre=F(()=>{ne(),tFe(),ea=new P,Vwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=e.geometry??t?.geometry??new Mt().copy(new Dh(100,100,100));t===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(ea),i={width:ea.x,height:ea.y,depth:ea.z,subdivisions:0}):i=t.parameters;let n={...i,...e.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:r}}static build(e){let{width:t,height:i,depth:r,subdivisions:n}=e.parameters,s=e.geometry??new Mt().copy(new Dh(100,100,100)),a=s.userData.parameters;a===void 0?(s.boundingBox=function(l){let h=new cn,u=l.attributes.position;return u?(h.setFromBufferAttribute(u),h):(h.makeEmpty(),h)}(s),s.boundingBox.getSize(ea)):ea.set(a.width,a.height,a.depth),(t!==ea.x||i!==ea.y||r!==ea.z)&&s.scale(ea.x===0?1:t/ea.x,ea.y===0?1:i/ea.y,ea.z===0?1:r/ea.z);let o=s.originalGeometry;try{n>0?(o===void 0||a?.subdivisions!==n)&&(o===void 0&&(o=s),s=new kwe(n).modify(o)):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new sY(i).load(e,r=>{let n=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ea);let s=100/ea.x;Object.assign(n.parameters,{width:100,height:ea.y*s,depth:ea.z*s}),t(this.build(n))})}}}),VH=F(()=>{o0(),e0(),sK=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=e.parameters,h=e.shape,u=.5*t,d=.5*i,c=2*Math.PI/r;for(let f=0;f<r;f++){let m=c*f,g=0+Math.sin(m)*u,v=0+Math.cos(m)*d;h.addPoint(h.createPoint(g,v))}h.isClosed=!0;for(let f=0,m=h.points.length;f<m;f++)h.points[f].roundness=n;h.roundness=n,h.update();let p=l0.create({shape:h,parameters:{roundness:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...e,type:"PolygonGeometry"}})}}});function QS(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function q5(e,t,i,r,n,s){let a=jwe.copy(t).sub(e),o=Wwe.copy(i).sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===n){let h=a.add(o).normalize();s.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);s.copy(e),s.addScaledVector(a,n/Math.sin(h)),s.addScaledVector(o,r/Math.sin(h))}}function iFe(e,t,i){let r=e.clone().sub(t),n=i.clone().sub(t);return r.projectOnVector(n),r.add(t)}var Gwe,jwe,Wwe,vre,UB,Hwe,qwe,$we,yre,aK,Xwe,Ywe,Kwe,Zwe,_re=F(()=>{ne(),Gwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.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(e){let{width:t,height:i,depth:r,radialSegments:n,heightSegments:s,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new vre(.5*t,i,n,s,a,o,l),u=r/t;return u!==1&&h.scale(1,1,u),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}},jwe=new P,Wwe=new P,vre=class extends Mt{constructor(e=.5,t=1,i=4,r=1,n=!1,s=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=t/2,f=Math.PI/i,m=e*Math.cos(Math.PI/i),g=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,_=new P(0,-p,0),b=new P(0,p,0),x=new Z(e,-p),w=new Z(m,-p),S=new Z(0,b.y).sub(w),T=new Z(0,b.y).sub(x),M=new Z(S.y,-S.x).normalize(),E=new Z(T.y,-T.x).normalize(),A=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;s=Math.min(s,A);{let k=new P(M.x,M.y,0),G=new P(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);o=k.angleTo(G)}let C=s/Math.tan((Math.PI-S.angle())/2),D=s/Math.tan((Math.PI-o)/2),R=new P;if(!n){h.push(_.x,_.y,_.z),u.push(0,-1,0),d.push(0,0);let k=c++,G=[],K=x.clone(),q=C/Math.cos(Math.PI/i);K.x-=q;for(let Y=0;Y<i;Y++){let ue=Y/i*Math.PI*2+f;QS(K,new Z(Math.sin(ue),Math.cos(ue)),R),h.push(R.x,R.y,R.z),u.push(0,-1,0),d.push(0,0),G.push(c++)}for(let Y=0;Y<G.length;Y++)l.push(G[Y],k,G[(Y+1)%G.length])}let I=[];{let k=new P,G=new P,K=new P,q=new P,Y=new P,ue=new P;for(let de=0;de<i;de++){let ge=de/i*Math.PI*2+f,be=(de+.5)/i*Math.PI*2+f,re=(de+1)/i*Math.PI*2+f,xe=new Z(Math.sin(ge),Math.cos(ge)),j=new Z(Math.sin(be),Math.cos(be)),z=new Z(Math.sin(re),Math.cos(re));QS(x,xe,G),QS(x,z,K),QS(M,j,k),q5(b,G,K,D,D,q),h.push(q.x,q.y,q.z),q5(G,b,K,D,C,Y),h.push(Y.x,Y.y,Y.z),q5(K,G,b,C,D,ue),h.push(ue.x,ue.y,ue.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 X=c++,te=c++,V=c++;if(l.push(X,te,V),s>0){{let W=G.clone().add(K).multiplyScalar(.5),pe=b.clone().sub(W).normalize(),_e=_.clone().sub(W).normalize().add(pe).normalize().multiplyScalar(-1);U(W,ue.clone().sub(Y),_e,S.angle())}let ae,se;{let W=new P;QS(E,z,W);let pe=ue.clone().add(q).multiplyScalar(.5);pe=iFe(pe,K,b);let _e=ue.clone().sub(q);[ae,se]=U(pe,_e,W,o,q.y)}{let W=ae,pe=W.clone().setY(0).normalize(),_e=new P(0,-1,0),Ue=pe.clone().cross(_e);O(W,pe,_e,Ue)}I.concat(se);{let W=S.angle(),pe=Math.PI-W,_e=b.clone();_e.y-=s/Math.sin(W-Math.PI/2);let Ue=new P,we=[];for(let Fe=0;Fe<a;Fe++){let We=[],Re=Math.PI/2-pe*Fe/a,ee=Math.cos(Re),Ee=Math.sin(Re),je=be;for(let dt=0;dt<=Fe;dt++){let et=Math.cos(je),$t=Math.sin(je);k.x=ee*$t,k.y=Ee,k.z=ee*et,Ue.copy(_e).addScaledVector(k,s),h.push(Ue.x,Ue.y,Ue.z),u.push(k.x,k.y,k.z),d.push(0,0),We.push(c++),je+=2*Math.PI/Fe/i}we.push(We)}se.reverse(),we.push(se);let Ye=we.length-1;for(let Fe=0;Fe<Ye;Fe++){let We=we[Fe],Re=we[Fe+1],ee=We.length-1;l.push(Re[1],We[0],Re[0]);for(let Ee=1;Ee<=ee;Ee++)l.push(We[Ee],We[Ee-1],Re[Ee]),l.push(Re[Ee+1],We[Ee],Re[Ee])}}}}}function U(k,G,K,q,Y){let ue=-q/2,de=(Math.PI-q)/2,ge=G.clone().normalize().cross(K);k.addScaledVector(K,-s/Math.sin(de));let be=new P,re=new P,xe=c,j=[];for(let z=0;z<=a;z++){let X=ue+z/a*q;re.set(0,0,0),re.addScaledVector(ge,Math.sin(X)),re.addScaledVector(K,Math.cos(X));for(let te=0;te<=1;te++){let V=te/1-.5;if(be.copy(k),be.addScaledVector(G,V),be.addScaledVector(re,s),Y!=null){let ae=Math.max(0,be.y-Y);be.addScaledVector(G,-ae/G.y)}h.push(be.x,be.y,be.z),u.push(re.x,re.y,re.z),d.push(0,0),te===0&&j.push(c),c++}}for(let z=0;z<a;z++)for(let X=0;X<1;X++){let te=xe+X+2*z,V=te+2,ae=V+1,se=te+1;l.push(te,V,se),l.push(V,ae,se)}return[k.clone().addScaledVector(G,.5),j]}function O(k,G,K,q){let Y=Math.PI/2,ue=T.angle()-Y,de=[],ge=new P,be=new P;for(let xe=0;xe<=a;xe++){let j=[],z=xe/a;for(let X=0;X<=xe;X++){let te=((xe?X/xe:0)-.5)*y,V=Math.cos(te),ae=Math.sin(te),se=(Y+Math.atan(Math.tan(ue)*V))*z,W=Math.cos(se),pe=Math.sin(se);ge.set(0,0,0),ge.addScaledVector(G,pe*V),ge.addScaledVector(K,W),ge.addScaledVector(q,pe*ae),be.copy(k).addScaledVector(ge,s),h.push(be.x,be.y,be.z),u.push(ge.x,ge.y,ge.z),d.push(0,0),j.push(c++)}de.push(j)}let re=de.length-1;for(let xe=0;xe<re;xe++){let j=de[xe],z=de[xe+1],X=j.length-1;l.push(j[0],z[1],z[0]);for(let te=1;te<=X;te++)l.push(j[te-1],j[te],z[te]),l.push(j[te],z[te+1],z[te])}}this.setIndex(l),this.setAttribute("position",new Tt(h,3)),this.setAttribute("normal",new Tt(u,3)),this.setAttribute("uv",new Tt(d,2))}}}),p4=F(()=>{o0(),e0(),UB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,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(e){let t=e.shape,{width:i,height:r,cornerRadius:n,cornerType:s,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}=e.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,w,S){return w>i&&S>r?Math.min(x*i/w,x*r/S):w>i?x*i/w:S>r?x*r/S:x}let f=[];f[0]=n[0]===0?0:p(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:p(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:p(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:p(n[3],n[3]+n[0],n[3]+n[2]);let m=d.x,g=c.x,v=c.y,y=d.y;t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let _=!0;for(let x=0,w=t.points.length;x<w;x++)t.points[x].roundness=f[x],x>0&&f[x]!==f[x-1]&&(_=!1);_&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=l0.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}}}),bre=F(()=>{ne(),Hwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=Qe.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(e){let t,{width:i=100,height:r=i,depth:n=i,widthSegments:s=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:h,thetaLength:u}=e.parameters;return u===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=new jf(.5*i,s,a,o,l,h,u*Qe.DEG2RAD),t.scale(1,r/i,n/i),Object.assign(t,{userData:{...e,type:"SphereGeometry"}})}}}),xre=F(()=>{ne(),qwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:n=8}=e.parameters,s=new Wc(t,i,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}}}),wre=F(()=>{ne(),$we=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.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(e){let{width:t,height:i,depth:r,angle:n,cornerRadius:s,cornerSegments:a}=e.parameters,o=new yre(t,i,r,n,s,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},yre=class extends Mt{constructor(e=1,t=1,i=1,r=90,n=10,s=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;n==0&&(s=1),s=Math.max(1,Math.floor(s)),n=Math.min(n,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(be=0,re=0,xe=0)=>new P(be,re,xe),p=c(),f=c(),[m,g,v]=[t/2,e/2,i/2],y=-g,_=+g,[b,x,w]=[c(y,-m,+v),c(y,-m,-v),c(y,+m,-v)],S=(be,re=!1)=>Math.sin(be-Math.PI/(+re+1)),T=(be,re=!1)=>Math.cos(be-Math.PI/(+re+1));w.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,E=b.z-h;r<=d?(w.z=Math.min(M,E),w.z==E&&(w.y-=(M-E)/Math.tan(d-r))):x.z=Math.min(x.z-M-v,b.z-h),p.subVectors(b,x),f.subVectors(w,x);let A=Math.min(p.length(),f.length())*n/100,C=A*Math.tan(r/2),D=A/Math.cos(r/2),R=p.clone().normalize().add(f.normalize()).setLength(D).add(x);p.set(0,S(r,!0),T(r,!0)),u.push([w,p.clone()]);let I=(Math.PI-r)/s;for(let be=0;be<=s;be++){let re=d+r+be*I;p.set(0,Math.sin(re)*C,Math.cos(re)*C),p.add(R),f.set(0,S(re),T(re)),u.push([p.clone(),f.clone()])}u.push([b,c(0,1,0)]);let U=Math.sin(I/2)*C*2,O=u.length-1,k=u[0][0].distanceTo(u[1][0]),G=k+U*s+u[O-1][0].distanceTo(u[O][0]);u[0].push(1);for(let be=0;be<=s;be++)u[be+1].push(1-(k+be*U)/G);u[O].push(0);let K,q,Y,[ue,de,ge]=u[0];for(let be=1;be<u.length;be++)[K,q,Y]=u[be],a.push(y,ue.y,ue.z,y,K.y,K.z,_,ue.y,ue.z,_,ue.y,ue.z,y,K.y,K.z,_,K.y,K.z),o.push(0,de.y,de.z,0,q.y,q.z,0,de.y,de.z,0,de.y,de.z,0,q.y,q.z,0,q.y,q.z),l.push(0,ge,0,Y,1,ge,1,ge,0,Y,1,Y),[ue,de,ge]=[K,q,Y];this.setAttribute("position",new Tt(a,3)),this.setAttribute("normal",new Tt(o,3)),this.setAttribute("uv",new Tt(l,2))}}}),GH=F(()=>{o0(),e0(),aK=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=e.parameters,d=e.shape,c=.5*t,p=.5*i,f=a*Math.PI/360/n,m=Math.PI/2*3*-1,g=c*r/100,v=p*r/100;if(n===3&&r===50){f=2*Math.PI/n;for(let _=0;_<n;_++){let b=f*_,x=0+Math.sin(b)*c,w=0+Math.cos(b)*p;d.addPoint(d.createPoint(x,w))}}else for(let _=0;_<n;_++){let b=0+Math.cos(m)*c,x=0+Math.sin(m)*p;d.addPoint(d.createPoint(b,x)),m+=f,b=0+Math.cos(m)*g,x=0+Math.sin(m)*v,d.addPoint(d.createPoint(b,x)),m+=f}d.isClosed=!0;for(let _=0,b=d.points.length;_<b;_++)d.points[_].roundness=s;d.roundness=s,d.update();let y=l0.create({shape:d,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}});return Object.assign(y,{userData:{...e,type:"StarGeometry"}})}}}),Sre=F(()=>{ne(),Xwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.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(e){let{width:t,height:i}=e.parameters,r=new Wc(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}}}),Tre=F(()=>{ne(),VA(),Ywe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??i.width);i.shapeBlendNode&&(n=r);let s=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:n,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:n,tubularSegments:s,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=function(u,d,c,p,f,m,g,v,y,_,b){[d,c]=[c,d],g=d/2;let x=Qe.clamp(f/360,0,1);if(x===0){let w=new Mt;return w.setAttribute("position",new Tt([],3)),w}return x===1&&(_=0),new CH(!0,u,d,c,p,x,m,g,0,y,_,b)}(t,i,r,.5*t,a,s,0,0,n,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}}}),Mre=F(()=>{ne(),Kwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.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(e){let{width:t,tube:i,tubularSegments:r,radialSegments:n,p:s,q:a}=e.parameters,o=.5*t;o!==i&&(o-=i);let l=new vW(o,i,r,n,s,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}}}),Ere=F(()=>{o0(),e0(),Zwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,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(e){let{width:t=100,height:i,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=e.parameters,h=e.shape,u=.5*t,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,f=h.points.length;p<f;p++)h.points[p].roundness=r;h.roundness=r,h.update();let c=l0.create({shape:h,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}}}),rFe=F(()=>{}),nFe=F(()=>{ne(),new ja,new De,new _f,new P,new P,new P,new P});function Are(){let e=new Mt;return e.setAttribute("position",new Pt(new Float32Array([]),3)),e.setIndex(new Pt(new Uint16Array([]),1)),e}var Cre,jH,Qwe=F(()=>{la(),Ot(),pC(),ne(),uC(),o0(),e0(),Rw(),Cre=Are().attributes,jH=class extends Mt{constructor(e,t){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,Cre),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:h,fontSize:u,extrusionVersion:d}=e,c=So.getDisplayedValue(l),p=function(w,S,T,M){let E=typeof w.width=="string"?Number(M.getVariable(w.width)):w.width,A=[""],C="";for(let D of T)C+=D,D===" "||D===`
|
|
4210
|
+
`;return 2&x.valid||t(3,"missing format specifier"),4&x.valid||t(3,"missing image size specifier"),x}(s),u=h.width,d=h.height,c=function(p,f,m){let g=f;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&t(3,"wrong scanline width");let v=new Uint8Array(4*f*m);v.length||t(4,"unable to allocate buffer space");let y=0,_=0,b=4*g,x=new Uint8Array(4),w=new Uint8Array(b),S=m;for(;S>0&&_<p.byteLength;){_+4>p.byteLength&&t(1),x[0]=p[_++],x[1]=p[_++],x[2]=p[_++],x[3]=p[_++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&t(3,"bad rgbe scanline format");let T,M=0;for(;M<b&&_<p.byteLength;){T=p[_++];let A=T>128;if(A&&(T-=128),(T===0||M+T>b)&&t(3,"bad scanline data"),A){let C=p[_++];for(let D=0;D<T;D++)w[M++]=C}else w.set(p.subarray(_,_+T),M),M+=T,_+=T}let E=g;for(let A=0;A<E;A++){let C=0;v[y]=w[A+C],C+=g,v[y+1]=w[A+C],C+=g,v[y+2]=w[A+C],C+=g,v[y+3]=w[A+C],y+=4}S--}return v}(s.subarray(s.pos),u,d);switch(this.type){case Gt:l=c.length/4;let p=new Float32Array(4*l);for(let m=0;m<l;m++)r(c,4*m,p,4*m);a=p,o=Gt;break;case li:l=c.length/4;let f=new Uint16Array(4*l);for(let m=0;m<l;m++)n(c,4*m,f,4*m);a=f,o=li;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:Td,minFilter:it,magFilter:it,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}});function zie(e){return e.length>2&&e[0]===35&&e[1]===63}function U5(e){return typeof e=="object"&&e!==null&&e.isSplineHdr===!0}function nwe(e){let t=new Nr(e.data,e.width,e.height,pn,li);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var kie,YY,Pc,swe=F(()=>{ne(),BBe()}),awe=F(()=>{ne(),iwe(),rwe(),swe(),kie=0,YY=class extends Zxe{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.instanceId=++kie,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let s of Object.values(n))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,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 e!="string"){let r,n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"})),await new Promise(s=>{n.onloadend=a=>{r=a.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else if(e instanceof Uint8Array?zie(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let r=e instanceof Uint8Array?e:null;if(r===null)try{r=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{r=null}let n=r!==null&&zie(r)?function(s){try{let a=new Jxe().parse(s.buffer.slice(s.byteOffset,s.byteOffset+s.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=m=>xd.toHalfFloat(Math.pow(Math.max(xd.fromHalfFloat(m),0),1/2.2)),p=new Map,f=m=>{let g=p.get(m);return g===void 0&&(g=c(m),p.set(m,g)),g};for(let m=0;m<l;m++){let g=m*d,v=(l-1-m)*d;for(let y=0;y<d;y+=4)u[v+y]=f(h[g+y]),u[v+y+1]=f(h[g+y+1]),u[v+y+2]=f(h[g+y+2]),u[v+y+3]=h[g+y+3]}return{isSplineHdr:!0,data:u,width:o,height:l}}catch{return null}}(r):null;n!==null&&(this.isHdr=!0,this.img=n,t())}else this.img=new Image,this.img.src=typeof(i=e)=="string"?i:(HE||(HE=new Kxe),HE.load(i)),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}});var i}getTexture(e,t=1008,i=1006){let r=this._cache[e]?.[t]?.[i];if(r)return r;{let n;return this.isBuffer?n=this.img.texture:this.isVideo?n=new JX(this.img,void 0,e,e):this.isHdr?(n=nwe(this.img),n.wrapS=e,n.wrapT=e,n.magFilter=i,n.minFilter=t):n=new Ci(this.img,void 0,e,e,i,t),this.isBuffer||(n.anisotropy=8,n.generateMipmaps=t===1008),this.loaded&&(n.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=n,n}}setNeedsUpdate(e){if(!this.isBuffer)for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[n,s]of Object.entries(r))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][n]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),BB=F(()=>{awe(),Pc=class extends YY{}});function FBe(e){if(typeof e=="string")return e;let t=DH.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},DH.set(e,t)),t.url}var DH,UBe=F(()=>{DH=new Map});function zBe(){if(!NH)return Vie||(Vie=async function(){await Promise.resolve().then(()=>(hQ(),hRe)),owe(window!==void 0?window:global),NH=!0}())}var owe,lwe,NH,Vie,hwe=F(()=>{lwe=new Promise(e=>{owe=e}),NH=!1});function Gie(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function kBe(e){let t=!1,i=[];return e.scene.objects.traverse((r,n)=>{if(n.type==="Page"&&n.uiScene!==void 0&&n.uiScene.objects.traverse((s,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;Gie(a.events,i),t=t||i.some(o=>o.data.type==="Audio")}),n.events===void 0||Array.isArray(n.events)===!1)return!0;Gie(n.events,i),t=t||i.some(s=>s.data.type==="Audio")}),t}var jie,ux,KY=F(()=>{UBe(),hwe(),lwe.then(e=>jie=e),ux=class{constructor({src:e,volume:t,delay:i,loop:r}){let n;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)},n=typeof e=="string"?{src:e}:{src:FBe(e),format:"wav"},this.sound=new jie.Howl(n),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,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(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function Wie(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var ZY,QY=F(()=>{ZY=null});function Hie(e){return new Z(e.y,-e.x)}var JY,IH,uwe,dwe,G3,qie,o4,cwe,z5,l4=F(()=>{ne(),JY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,n=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);n.thetaLength=Qe.clamp(n.thetaLength,0,360),n.hollow=Qe.clamp(n.hollow??0,0,1);let s=n.width/2,a=n.radiusTop??s,o=n.radiusBottom??s;if(a===o?(a=s,o=s):a>o?(a=s,o=o*s/a):(a=a*s/o,o=s),n.shapeBlendNode){a=i??s,o=r??s;let l=2*Math.max(a,o);n.width=l,n.depth=l}return{parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(n.height??n.width),depth:Math.abs(n.depth??n.width),radiusTop:a,radiusBottom:o})}}static build(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:f}=e.parameters;h===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=c||f?new IH(u,d,n,s,a,o,l,h*Math.PI/180,c,c,p,f):new IE(u,d,n,s,a,o,l,h*Math.PI/180);let m=r/i;return m!==1&&t.scale(1,1,m),Object.assign(t,{userData:{...e,type:"CylinderGeometry"}})}},IH=class extends Mt{constructor(e,t,i,r,n,s,a,o,l,h,u,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,n=Math.floor(n)||1,s=s!==void 0&&s,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,s&&(l=0,h=0);let p=i/2;c&&e==0&&(e=l),c&&t==0&&(t=h);let f=new Z(e,p),m=new Z(t,-p),g=null,v=null,y=null,_=null,b=f.clone().sub(m),x=0,w=0,S=0;d>0&&(x=Math.min(e,t)*(1-d),w=e-x,S=t-x);let T=f.clone();T.x-=x;let M=Math.PI-b.angle(),E=b.angle(),A=Math.tan(E/2),C=Math.tan(M/2),D=A+C,R=d?D:C,I=d?D:A;if(l=Math.min(l,(e-w)/R,b.length()/D),h=Math.min(h,(t-S)/I,b.length()/D),l>0){let pe=l/A;g=f.clone().sub(new Z(pe,l)),d&&(y=g.clone(),y.x-=x-D*l),f.sub(b.clone().setLength(pe))}if(h>0){let pe=h/C;v=m.clone().sub(new Z(pe,-h)),m.add(b.clone().setLength(pe)),d&&(_=v.clone(),_.x-=x-D*h,T.sub(b.clone().setLength(pe)))}b=f.clone().sub(m);let U=b.length()<.5,O=[],k=[],G=[],K=[],q=[],Y=[],ue=(pe,_e,Ue,we,Ye)=>{for(let Fe=0;Fe<u+1;Fe++){let We=Fe/u,Re=we<0?We:1-We;Ye&&(Re-=1),Re*=pe;let ee=Math.sin(Re),Ee=Math.cos(Re)*we,je=Ee*_e+Ue.y;O.push(ee*_e+Ue.x),k.push(je),G.push(ee),K.push(Ee),q.push(.5+je/i),Y.push(!1)}},de=(pe,_e,Ue)=>{let we=[pe,_e];Ue<0&&we.reverse();for(let Ye of we)O.push(Ye),k.push(p*Ue),G.push(0),K.push(Ue),q.push(.5),Y.push(!0)};if(_&&v?(ue(M,h,_,-1,!0),ue(E,h,v,-1,!1)):v?(de(v.x,0,-1),ue(E,h,v,-1,!1)):s||de(t,S,-1),!U){let pe=Hie(b).normalize();for(let _e=0;_e<=n;_e++){let Ue=_e/n,we=b.y*Ue+m.y;O.push(b.x*Ue+m.x),k.push(we),G.push(pe.x),K.push(pe.y),q.push(.5+we/i),Y.push(!1)}}if(y&&g?(ue(M,l,g,1,!1),ue(E,l,y,1,!0)):g?(ue(M,l,g,1,!1),de(g.x,0,1)):s||de(e,w,1),d&&!U){let pe=Hie(b).multiplyScalar(-1).normalize();for(let _e=0;_e<=n;_e++){let Ue=_e/n,we=b.y*-Ue+T.y;O.push(b.x*-Ue+T.x),k.push(we),G.push(pe.x),K.push(pe.y),q.push(.5+we/i),Y.push(!1)}}let ge=O.length,be=ge+(d&&!s?1:0),re=(pe,_e)=>pe*ge+(_e===ge?0:_e),xe=o<2*Math.PI,j=(r+1)*ge+(xe?2*(1+be):0),z=new Float32Array(3*j),X=new Float32Array(3*j),te=new Float32Array(2*j),V=j-1>65535?new Uint32Array(r*Math.max(0,be-1)*6+(xe?2*(be+1)*3:0)):new Uint16Array(r*Math.max(0,be-1)*6+(xe?2*(be+1)*3:0)),ae=0,se=0;for(let pe=0;pe<=r;pe++){let _e=pe/r,Ue=_e*o+a,we=Math.sin(Ue),Ye=Math.cos(Ue);for(let Fe=0;Fe<ge;Fe++){let We=3*se,Re=2*se,ee=O[Fe],Ee=G[Fe];z[We]=ee*we,z[We+1]=k[Fe],z[We+2]=ee*Ye,X[We]=Ee*we,X[We+1]=K[Fe],X[We+2]=Ee*Ye,Y[Fe]?(te[Re]=.5,te[Re+1]=.5):(te[Re]=_e,te[Re+1]=q[Fe]),se++}}for(let pe=0;pe<r;pe++)for(let _e=0;_e<be-1;_e++){if(s&&d&&_e==n)continue;let Ue=re(pe,_e),we=re(pe+1,_e),Ye=re(pe+1,_e+1),Fe=re(pe,_e+1),We=z[3*Ye+0],Re=z[3*Ye+2];V[ae++]=Ue,V[ae++]=we,V[ae++]=Fe,(We!=0||Re!=0)&&(V[ae++]=we,V[ae++]=Ye,V[ae++]=Fe)}function W(pe,_e,Ue){let we=Math.sin(Ue),Ye=Math.cos(Ue),Fe=-Ye,We=we,Re=pe<0?(et,$t,ii)=>{V[ae++]=et,V[ae++]=$t,V[ae++]=ii}:(et,$t,ii)=>{V[ae++]=et,V[ae++]=ii,V[ae++]=$t},ee=(e+t+w+S)/4,Ee=3*se,je=2*se;z[Ee]=ee*we,z[Ee+1]=0,z[Ee+2]=ee*Ye,X[Ee]=Fe,X[Ee+1]=0,X[Ee+2]=We,te[je]=.5,te[je+1]=.5;let dt=se++;for(let et=0;et<be;et++){let $t=3*(_e+(et===ge?0:et));Ee=3*se,je=2*se,z[Ee]=z[$t],z[Ee+1]=z[$t+1],z[Ee+2]=z[$t+2],X[Ee]=Fe,X[Ee+1]=0,X[Ee+2]=We;let ii=$t/3*2|0;te[je]=te[ii],te[je+1]=te[ii+1],se++}for(let et=dt+1;et<se-1;et++)Re(dt,et,et+1);Re(dt,se-1,dt+1)}xe&&(W(-1,0,a),W(1,r*ge,a+o)),this.setIndex(new Pt(V.slice(0,ae),1)),this.setAttribute("position",new Pt(z,3)),this.setAttribute("normal",new Pt(X,3)),this.setAttribute("uv",new Pt(te,2))}}}),$ie=F(()=>{ne(),l4(),uwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=Qe.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(e){let t,{width:i,depth:r,height:n,radialSegments:s,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=e.parameters;h===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=u>0||d>0||h<360?new IH(0,i/2,n,s,a,o,l,h*Math.PI/180,u,d,c,0,!0):new AL(i/2,n,s,a,o);let p=r/i;return p!==1&&t.scale(1,1,p),Object.assign(t,{userData:{...e,type:"ConeGeometry"}})}}}),Xie=F(()=>{ne(),dwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.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(e){let t,{width:i,height:r,depth:n,widthSegments:s,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:h}=e.parameters;return t=l===0?new Dh(i,r,n,s,a,o):new qie(i,r,n,s,a,o,l,h),Object.assign(t,{userData:{...e,type:"CubeGeometry"}})}},G3=Math.PI/2,qie=class extends Mt{constructor(e=1,t=1,i=1,r=1,n=1,s=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=(a=Math.min(a,e/2,t/2,i/2))>0,h=o+1,u=2*((s+1)*(n+1)+(r+1)*(s+1)+(r+1)*(n+1))+(l?4*h*(s+1+(r+1)+(n+1))+h*(h+1)/2*8:0),d=2*(s*n+r*s+r*n)+(l?4*o*(s+r+n):0),c=l?8*o*o:0,p=new Float32Array(3*u),f=new Float32Array(3*u),m=new Float32Array(2*u),g=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),v=0,y=0,_=new Float64Array(h),b=new Float64Array(h),x=new Float64Array(h),w=new Float64Array(h);for(let D=0;D<h;D++){let R=D/o*G3;_[D]=Math.sin(R)*a,b[D]=(1-Math.cos(R))*a,x[D]=Math.sin(R),w[D]=Math.cos(R)}let S=h*(h+1)/2,T=new Float64Array(3*S),M=new Float64Array(3*S);{let D=new P(e/2,t/2,i/2);D.subScalar(a);let R=0;for(let I=0;I<=o;I++){let U=G3*(1-I/o),O=Math.cos(U),k=Math.sin(U),G=0;for(let K=0;K<=I;K++){let q=O*Math.cos(G),Y=k,ue=O*Math.sin(G);T[3*R]=q,T[3*R+1]=Y,T[3*R+2]=ue,M[3*R]=D.x+q*a,M[3*R+1]=D.y+Y*a,M[3*R+2]=D.z+ue*a,R++,G+=G3/I}}}function E(D,R,I,U,O,k,G,K,q,Y){let ue=(k-2*a)/q,de=(G-2*a)/Y,ge=k/2-a,be=G/2-a,re=K/2,xe=q+1,j=Y+1,z=0,X=new P;for(let te=0;te<j;te++){let V=te*de-be;for(let ae=0;ae<xe;ae++){let se=ae*ue-ge,W=3*(v+z),pe=2*(v+z);X[D]=se*U,X[R]=V*O,X[I]=re,p[W]=X.x,p[W+1]=X.y,p[W+2]=X.z,X[D]=0,X[R]=0,X[I]=K>0?1:-1,f[W]=X.x,f[W+1]=X.y,f[W+2]=X.z,m[pe]=ae/q,m[pe+1]=1-te/Y,z+=1}}for(let te=0;te<Y;te++)for(let V=0;V<q;V++){let ae=v+V+xe*te,se=v+V+xe*(te+1),W=v+(V+1)+xe*(te+1),pe=v+(V+1)+xe*te;g[y++]=ae,g[y++]=se,g[y++]=pe,g[y++]=se,g[y++]=W,g[y++]=pe}v+=z}function A(D,R,I,U,O,k,G,K,q,Y){let ue=(G-2*a)/Y,de=G/2-a,ge=K/2-a,be=q/2,re=Y+1,xe=0,j=new P,z=new P;for(let X=0;X<o+1;X++){j[R]=(ge+_[X])*O,j[I]=(be-b[X])*k,z[D]=0,z[R]=x[X]*Math.sign(j[R]),z[I]=w[X]*Math.sign(j[I]);for(let te=0;te<re;te++){let V=te*ue-de;j[D]=V*U;let ae=3*(v+xe),se=2*(v+xe);p[ae]=j.x,p[ae+1]=j.y,p[ae+2]=j.z,f[ae]=z.x,f[ae+1]=z.y,f[ae+2]=z.z,m[se]=te/Y,m[se+1]=0,xe+=1}}for(let X=0;X<o;X++)for(let te=0;te<Y;te++){let V=v+te+re*X,ae=v+te+re*(X+1),se=v+(te+1)+re*(X+1),W=v+(te+1)+re*X;g[y++]=V,g[y++]=ae,g[y++]=W,g[y++]=ae,g[y++]=se,g[y++]=W}v+=xe}function C(D,R,I){let U=D*R*I>0?(k,G,K)=>{g[y++]=k,g[y++]=G,g[y++]=K}:(k,G,K)=>{g[y++]=k,g[y++]=K,g[y++]=G},O=v;for(let k=0;k<S;k++){let G=3*k,K=3*v,q=2*v;p[K]=D*M[G],p[K+1]=R*M[G+1],p[K+2]=I*M[G+2],f[K]=D*T[G],f[K+1]=R*T[G+1],f[K+2]=I*T[G+2],m[q]=0,m[q+1]=0,v++}for(let k=0;k<o;k++){let G=O+k*(k+1)/2,K=O+(k+1)*(k+2)/2;U(G,K+1,K);for(let q=1;q<=k;q++)U(G+q-1,G+q,K+q),U(G+q,K+q+1,K+q)}}E("z","y","x",-1,-1,i,t,e,s,n),E("z","y","x",1,-1,i,t,-e,s,n),E("x","z","y",1,1,e,i,t,r,s),E("x","z","y",1,-1,e,i,-t,r,s),E("x","y","z",1,-1,e,t,i,r,n),E("x","y","z",-1,-1,e,t,-i,r,n),a>0&&(A("z","y","x",-1,-1,1,i,t,e,s),A("z","y","x",1,-1,-1,i,t,e,s),A("z","y","x",-1,1,-1,i,t,e,s),A("z","y","x",1,1,1,i,t,e,s),A("x","y","z",-1,-1,-1,e,t,i,r),A("x","y","z",1,-1,1,e,t,i,r),A("x","y","z",-1,1,1,e,t,i,r),A("x","y","z",1,1,-1,e,t,i,r),A("y","x","z",-1,-1,1,t,e,i,n),A("y","x","z",1,-1,-1,t,e,i,n),A("y","x","z",1,1,1,t,e,i,n),A("y","x","z",-1,1,-1,t,e,i,n),C(1,1,1),C(-1,1,1),C(1,-1,1),C(-1,-1,1),C(1,1,-1),C(-1,1,-1),C(1,-1,-1),C(-1,-1,-1)),this.setIndex(new Pt(g,1)),this.setAttribute("position",new Pt(p,3)),this.setAttribute("normal",new Pt(f,3)),this.setAttribute("uv",new Pt(m,2))}}}),pwe=F(()=>{ne(),o4=class extends Mt{constructor(e=[],t=[],i="",r=1,n=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,h=0;return function(){(n=Math.min(.99999,n))==0&&(s=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new Ls,f=n*r,m=r-f,g=s+1,v=new P,y=(re,xe)=>v.subVectors(re,xe).normalize(),_=(re,xe)=>Array(re).fill(void 0).map(xe),b=_(e.length/3,(re,xe)=>new P().fromArray(e,3*xe).setLength(r)),x=[],w=1e6;for(let re=0;re<b.length;re++){let xe,j,z,X=b[re],te=[],V=1e10,ae=-1;for(;(ae=t.indexOf(re,ae+1))!=-1;){let _e=ae-ae%3;xe=t[_e+(ae+1)%3],j=t[_e+(ae+2)%3],z=X.distanceToSquared(b[xe]),V=Math.min(V,z),te.push([xe,j,z])}V+=1e-6;let se=[],W=0,pe=te.length;for(let _e=0;_e<pe;_e++){[xe,j,z]=te[W];let Ue=x[xe]?.includes(re)==1;z<=V&&se.push(xe+ +Ue*w),W=te.findIndex(we=>we[0]==j)}x.push(se)}let S=[];{let re,xe,j=0,z=0,X=u==3;for(let te=0;te<=s;te++){re=te*(te+1)/2,xe=(te+1)*(te+2)/2;for(let V=0;V<s-te;V++)[j,z]=[re+V+te+2,xe+V+te+3],S.push(re,xe,...X?[z,re]:[j,xe],z,j),[re,xe]=[j,z];S.push(re,xe,re+s+2)}}let T=0;for(let re=0;re<x.length;re++)for(let xe=0;xe<u;xe++)x[re][xe]<w&&T++;let M=b.length*u*S.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(M),o=new Float64Array(M),l=new Float64Array(M/3*2);let E=(re,xe,j)=>{let z=h/3*2;l[z]=Math.atan2(j,-re)/2/Math.PI+.5,l[z+1]=1-(Math.atan2(-xe,Math.sqrt(re*re+j*j))/Math.PI+.5)},A=re=>{a[h]=re.x,a[h+1]=re.y,a[h+2]=re.z,o[h]=v.x,o[h+1]=v.y,o[h+2]=v.z,E(re.x,re.y,re.z),h+=3},C=re=>{a[h]=re[0].x,a[h+1]=re[0].y,a[h+2]=re[0].z,o[h]=re[1].x,o[h+1]=re[1].y,o[h+2]=re[1].z,E(re[0].x,re[0].y,re[0].z),h+=3},D=(s+2)*(s+3)/2,R=new Float64Array(3*D),I=new Float64Array(3*D),U=new Float64Array(2*D),O=_(2*u*g,()=>new P),k=_(s*Math.max(0,s-1)/2,()=>new P),G=d.clone(),K=d.clone(),q=d.clone(),Y=d.clone(),ue=d.clone(),de=[],ge=_(b.length,()=>_(u,()=>d.clone()));for(let re=0;re<b.length;re++){d.copy(b[re]).normalize(),G.copy(d).multiplyScalar(m);let xe=x[re];for(let se=0;se<xe.length;se++){let W=xe[se],pe=xe[(se+1)%u];p.setFromPointsAndIndices(b,re,W%w,pe%w),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(G,ge[re][se])}let j=0,z=[],X=[],te=new P;s==0&&[...ge[re]].reduce((se,W)=>se.add(W),te).multiplyScalar(1/u);for(let se=0;se<u;se++){let W=[],pe=(se-1+u)%u,_e=ge[re][pe],Ue=ge[re][se];d.copy(_e).sub(G),c.copy(Ue).sub(G);let we=G.angleTo(d),Ye=d.angleTo(c),Fe=Math.cos(we)*f;s==0?K.copy(te):K.copy(G).setLength(m+Fe),z.push(Fe);let We=[K,_e,Ue];for(let Re=0;Re<2;Re++){let ee=We[Re],Ee=We[Re+1];Y.subVectors(ee,G),ue.subVectors(Ee,G),q.crossVectors(Y,ue).normalize();for(let je=0;je<g;je++){let dt=[we,Ye][Re]*je/g;d.copy(Y).applyAxisAngle(q,dt).add(G),O[j++].copy(d),Re&&(y(d,G),W.push([je==0?ee:d.clone(),v.clone()]))}Re&&(y(Ee,G),W.push([Ee,v.clone()]))}X.push(W)}de.push(X);let V=2*g,ae=2;for(let se=0;se<u;se++){let W=V*se,pe=V*((se+1)%u),_e=0,Ue=[O[W]];for(let we=1;we<g;we++){let Ye=O[W+we],Fe=O[pe+we];Ue.push(Ye);for(let We=1,Re=we-ae+1;We<=Re;We++)d.lerpVectors(Ye,Fe,We/(Re+1)),d.sub(G).setLength(z[se]).add(G),Ue.push(k[_e++].copy(d));Ue.push(Fe)}for(let we=0;we<g;we++)Ue.push(O[we+g+W]);Ue.push(O[pe+g]);for(let we=0,Ye=Ue.length;we<Ye;we++){let Fe=Ue[we],We=3*we,Re=2*we;R[We]=Fe.x,R[We+1]=Fe.y,R[We+2]=Fe.z,y(Fe,G),I[We]=v.x,I[We+1]=v.y,I[We+2]=v.z,U[Re]=Math.atan2(Fe.z,-Fe.x)/2/Math.PI+.5,U[Re+1]=1-(Math.atan2(-Fe.y,Math.sqrt(Fe.x*Fe.x+Fe.z*Fe.z))/Math.PI+.5)}for(let we=0,Ye=S.length;we<Ye;we++){let Fe=3*S[we],We=2*S[we],Re=h/3*2;a[h]=R[Fe],a[h+1]=R[Fe+1],a[h+2]=R[Fe+2],o[h]=I[Fe],o[h+1]=I[Fe+1],o[h+2]=I[Fe+2],l[Re]=U[We],l[Re+1]=U[We+1],h+=3}}}let be=[];for(let re=0;re<x.length;re++)for(let xe=0;xe<u;xe++){let j=x[re][xe];if(j<w){let z=x[j].findIndex(V=>V%w==re),X=de[re][xe],te=de[j][z];for(let V=0;V<g;V++){let ae=X[V],se=te[g-V],W=X[V+1],pe=te[g-(V+1)];C(ae),C(se),C(W),C(W),C(se),C(pe)}be.push(X[0][0],te[g][0],X[g][0],te[0][0])}}for(;be.length;){let re,xe,j,[z,X]=be.splice(0,2);re=X;let te=[z];for(;z!=re;)te.push(re),xe=be.indexOf(re),j=xe%2,re=be.splice(xe-j,2)[1-j];v.subVectors(te[0],te[1]).cross(d.subVectors(te[0],te[2])).normalize();let V=v.dot(te[0])<0;V&&v.negate();for(let ae=1;ae<=te.length-2;ae++)A(te[ae+ +V]),A(te[ae+1-+V]),A(te[0])}}(),function(){let u=new P,d=new P,c=new P,p=new P,f=new Z,m=new Z,g=new Z,v=(b,x,w,S)=>{S<0&&b.x===1&&(l[x]=b.x-1),w.x===0&&w.z===0&&(l[x]=S/2/Math.PI+.5)};for(let b=0,x=0;b<h;b+=9,x+=6){u.set(a[b+0],a[b+1],a[b+2]),d.set(a[b+3],a[b+4],a[b+5]),c.set(a[b+6],a[b+7],a[b+8]),f.set(l[x+0],l[x+1]),m.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 w=_(p);v(f,x+0,u,w),v(m,x+2,d,w),v(g,x+4,c,w)}let y=h/3*2;for(let b=0;b<y;b+=6){let x=l[b+0],w=l[b+2],S=l[b+4],T=Math.max(x,w,S),M=Math.min(x,w,S);T>.9&&M<.1&&(x<.2&&(l[b+0]+=1),w<.2&&(l[b+2]+=1),S<.2&&(l[b+4]+=1))}function _(b){return Math.atan2(b.z,-b.x)}}(),this.setAttribute("position",new Pt(new Float32Array(a.subarray(0,h)),3)),this.setAttribute("normal",new Pt(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new Pt(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(e){return new o4(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}}}),Yie=F(()=>{pwe(),ne(),cwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new z5(.5*t,s,a):new dW(.5*t,n),l=i/t,h=r/t;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},z5=class extends o4{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n=1/r,s="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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],[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],s,e,t,i),this.type=s}static fromJSON(e){return new z5(e.radius,e.corner,e.cornerSides)}}});function Kie(e,t=new Z){let i=e.length();return t.set(-e.y/i,e.x/i)}function VBe(e){let t=new Z;t.addVectors(e.v0,dy.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(e.v2,HA.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new pu(e.v0,t,i,e.v2)}function ZM(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function GBe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function jBe(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function fwe(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function WBe(e,t,i){return Qie(e,t)&&Qie(t,i)&&OH(e.position,t.position,i.position)}function OH(e,t,i){return dy.copy(t).sub(e).cross(HA.copy(i).sub(e))===0}function HBe(e,t,i,r,n){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,h=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,a+h),n.set(o-l,a-h),[r,n]}function qBe(e,t,i){return e.distanceTo(i)<t.distanceTo(i)?t:e}function $Be(e,t,i,r,n,s){let a,o=t.x-e.x,l=t.y-e.y,h=i.x-e.x,u=i.y-e.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return fwe(t,e,i)>Math.PI&&(d*=-1),a=ZM(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),n.set(t.x-a*l,t.y+a*o),s.set(i.x+a*u,i.y-a*h),[n,s]}function Zie(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Qie(e,t){return OH(e.position,e.controls[1].position,t.position)&&OH(e.position,t.controls[0].position,t.position)}function Jie(e,t=12,i=!1){let r=[];for(let n=0,s=e.length;n<s;n++){let a=e[n],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*uy(a.roundedCurveCorner,t);n>0&&(r[n-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=uy(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=.5*uy(e[0].roundedCurveCorner,t)),r}function uy(e,t=12){return e&&e instanceof BM?2*t:e&&(e instanceof wh||e instanceof cW)?1:e&&e instanceof GI?t*e.points.length:t}var Vb,j3,W3,My,sO,dy,HA,mwe,gwe,vwe,ywe,LH,BH,H3,ere,tre,ire,rre,nre,cs,_we=F(()=>{ne(),Vb=1e-12,j3=class{constructor(e){this.position=new Z,this.startPosition=new Z,this.uuid=Qe.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new j3(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},W3=class extends j3{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new W3(this.parent).copy(this)}},My=class extends j3{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new W3(this),new W3(this))}static create(e,t){let i=new My(e,new Z(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let n=this.controls[i];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new My(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new Z,t=new Z){let[i,r]=this.computeTangents();return i&&r&&(Kie(i,e),Kie(r,t)),[e,t]}computeTangent(e=new Z){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new Z){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}},sO=e=>e,dy=new Z,HA=new Z,mwe=new Z,gwe=new Z,vwe=new Z,ywe=new Z,LH=new P,BH=new P}),o0=F(()=>{ne(),_we(),H3=new Z,ere=new Z,tre=new Z,ire=new Z,rre=new Z,nre=new Z,cs=class extends AA{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Wa(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=Qe.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new cs;return r.isClosed=e.isClosed,r.points=e.points.map(n=>My.create(n.id,n.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(n=>cs.createFromState(n)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let n=0,s=this.shapeHoles.length;n<s;n++){let a=this.shapeHoles[n],o=a.points.length,l=a.getPointIndexById(e);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=e-t;if(s<=n.points.length-1)return n.points[s];t+=n.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let n=this.shapeHoles[i],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=H3.set(e,t);for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,n=this.shapeHoles.length;r<n;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=Qe.generateUUID()){let r;r=e instanceof Z?e:new Z(e,t);let n=new My(i,r);return n.roundness=this.roundness,n}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(n,s,a=12,o=!0){let l,h=BH.set(0,0,0),u=0,d=[];for(let c=0;c<s.length;c++){let p=sO(s[c]),f=dy,m=uy(p,a);d.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof df||p instanceof wh){if(p.getPoint(g/m,f),h.set(f.x,f.y,0),l!==void 0&&jBe(l,h))continue;l===void 0&&(l=LH),l.copy(h),n.setXYZ(u,h.x,h.y,h.z),u++}}o&&u>1&&(n.getX(u-1)!==n.getX(0)||n.getY(u-1)!==n.getY(0)||n.getZ(u-1)!==n.getZ(0))&&(n.setXYZ(u,n.getX(0),n.getY(0),n.getZ(0)),u++)}(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Jie(this.points,e,!1),this.roundedCurveDivisions=Jie(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return 2*function(r,n,s,a=12,o=!0){let l=BH.set(0,0,0),h=0,u=[];for(let d=0;d<n.length;d++){if(s[d]===!1)continue;let c,p=sO(n[d]),f=dy,m=uy(p,a);u.push(m);for(let g=0;g<=m;g++)if(p instanceof pu||p instanceof df||p instanceof wh){if(p.getPoint(g/m,f),l.set(f.x,f.y,0),c?.equals(l))continue;c===void 0?c=LH:(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}(e,this.curves,t,i,this.autoClose).reduce((r,n)=>r+n,0)}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),function(i,r,n=12,s=!0){let a,o=0;for(let l=0;l<r.length;l++){let h=sO(r[l]),u=uy(h,n),d=dy;for(let c=0;c<=u;c++)if(h instanceof pu||h instanceof df||h instanceof wh){if(h.getPoint(c/u,d),a!==void 0&&GBe(a,d,Vb))continue;a===void 0&&(a=HA),a.copy(d),i.push(d.x,d.y),o++}}return ZM(i[0],i[i.length-2],Vb)&&ZM(i[1],i[i.length-1],Vb)&&(i.pop(),i.pop()),s&&o>1&&!(ZM(i[o-1],i[1],Vb)&&ZM(i[o-2],i[0],Vb))&&(i.push(i[0],i[1]),o++),i}(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=.5*uy(this.points[0].roundedCurveCorner,this.subdivision));let s=e-n;s<0&&(s+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(s<i+l)return[a,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(Zie(r,n)){let l=r.position.distanceTo(n.position);return r.position.distanceTo(H3.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){Zie(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let n=this.points[t-1];this._applyCurveForPoint(r,n)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let n=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=n.roundness,l=s&&a&&WBe(s,n,a);if(!n.controlsMoved()&&o>0&&!l){let h=n.curveBefore,u=n.curveAfter;if(h===void 0||u===void 0)continue;let d,c=n.roundedCurveBefore,p=n.roundedCurveAfter,f=h instanceof wh?h.v1.distanceTo(h.v2):h.getLength(),m=u instanceof wh?u.v1.distanceTo(u.v2):u.getLength(),g=Math.min(o,.499*f),v=Math.min(o,.499*m),y=Math.min(g,v),_=1-y/f,b=y/m,x=h.getPointAt(_,H3),w=u.getPointAt(b,ere);if(this._subSplitCurve(h,c,_,x,void 0),this._subSplitCurve(u,p,b,void 0,w),this.useCubicForRoundedCorners){let S=fwe(x,n.position,w)/2,T=Math.tan(S)*x.distanceTo(n.position),[M,E]=HBe(x,w,T,tre,ire),A=qBe(M,E,n.position),[C,D]=$Be(A,x,w,T,rre,nre);d=new pu(x.clone(),C.clone(),D.clone(),w.clone())}else d=new df(x.clone(),n.position.clone(),w.clone());n.roundedCurveCorner=d,this.roundedCurves.splice(i+t,0,d),t++}}}}_subSplitCurve(e,t,i,r,n){if(!(e instanceof wh)){let s=e,a=t,o=s.getUtoTmapping(i,0),l=function(h,u,d,c,p=.5){let f=dy.subVectors(u,h).multiplyScalar(p).add(h),m=HA.subVectors(d,u).multiplyScalar(p).add(u),g=mwe.subVectors(c,d).multiplyScalar(p).add(d),v=f,y=gwe.subVectors(m,f).multiplyScalar(p).add(f),_=vwe.subVectors(g,m).multiplyScalar(p).add(m),b=g,x=ywe.subVectors(_,y).multiplyScalar(p).add(y);return[h.x,h.y,v.x,v.y,y.x,y.y,x.x,x.y,_.x,_.y,b.x,b.y,c.x,c.y]}(s.v0,s.v1,s.v2,s.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])),n!==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&&t.v2.copy(r),n!==void 0&&t.v1.copy(n),t}clone(){let e=new cs(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=7*i,n=e.points[r+0],s=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],u=e.points[r+6],d=new My(Qe.generateUUID(),new Z(n,s));d.controls[0].position.set(a,o),d.controls[1].position.set(l,h),d.roundness=u,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new cs;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(r,n)=>{n instanceof pu&&n.v3.equals(r.position)&&r.controls[0].position.copy(n.v2)};return this.points=(r=>{let n,s,a=[];for(n=0,s=r.length;n<s;n++)r[n]instanceof df&&(r[n]=VBe(r[n]));for(n=0,s=r.length;n<s;n++){let h,u=r[n],d=n>0?r[n-1]:null;u instanceof pu?(h=this.createPoint(u.v0),h.controls[1].position.copy(u.v1)):u instanceof wh&&(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 pu?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof wh&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(e.curves),e instanceof AA&&(this.shapeHoles=e.holes.map(r=>{let n=new cs;return n.fromShape(r),n})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}}});function k5({x:e,y:t},i,r,n,s){return{x:e*i+n,y:t*r+s}}function XBe(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),n=Math.sin(e),s=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-n*i,y:n+r*i},{x:s+a*i,y:a-s*i},{x:s,y:a}]}function sre(e,t,i,r){let n=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return n*Math.acos(s)}var aO,YBe=F(()=>{aO=2*Math.PI});function wi(e,t){if(!e)throw t||"Assertion Failed!"}function qE(e){var t=e.windingRule,i=t===void 0?is.ODD:t,r=e.elementType,n=r===void 0?bo.POLYGONS:r,s=e.polySize,a=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,d=e.contours,c=d===void 0?[]:d,p=e.strict,f=p===void 0||p,m=e.debug,g=m!==void 0&&m;if(!c&&f)throw new Error("Contours can't be empty");if(c){var v=new bwe;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<c.length;y++)v.addContour(l||2,c[y]);return v.tesselate(i,n,a,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var is,bo,di,i_,ZS,z0,V5,G5,j5,are,q3,W5,ore,lre,bwe,pC=F(()=>{var e;(e=is||(is={}))[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(t){t[t.POLYGONS=0]="POLYGONS",t[t.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",t[t.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(bo||(bo={})),di=function(){function t(){}return t.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},t.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},t.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},t.edgeGoesLeft=function(i){return t.vertLeq(i.Dst,i.Org)},t.edgeGoesRight=function(i){return t.vertLeq(i.Org,i.Dst)},t.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},t.edgeEval=function(i,r,n){wi(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?s<a?r.t-i.t+(i.t-n.t)*(s/(s+a)):r.t-n.t+(n.t-i.t)*(a/(s+a)):0},t.edgeSign=function(i,r,n){wi(t.vertLeq(i,r)&&t.vertLeq(r,n));var s=r.s-i.s,a=n.s-r.s;return s+a>0?(r.t-n.t)*s+(r.t-i.t)*a:0},t.transEval=function(i,r,n){wi(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?s<a?r.s-i.s+(i.s-n.s)*(s/(s+a)):r.s-n.s+(n.s-i.s)*(a/(s+a)):0},t.transSign=function(i,r,n){wi(t.transLeq(i,r)&&t.transLeq(r,n));var s=r.t-i.t,a=n.t-r.t;return s+a>0?(r.s-n.s)*s+(r.s-i.s)*a:0},t.vertCCW=function(i,r,n){return i.s*(r.t-n.t)+r.s*(n.t-i.t)+n.s*(i.t-r.t)>=0},t.interpolate=function(i,r,n,s){return(i=i<0?0:i)<=(n=n<0?0:n)?n===0?(r+s)/2:r+i/(i+n)*(s-r):s+n/(i+n)*(r-s)},t.intersect=function(i,r,n,s,a){var o,l,h;t.vertLeq(i,r)||(h=i,i=r,r=h),t.vertLeq(n,s)||(h=n,n=s,s=h),t.vertLeq(i,n)||(h=i,i=n,n=h,h=r,r=s,s=h),t.vertLeq(n,r)?t.vertLeq(r,s)?((o=t.edgeEval(i,n,r))+(l=t.edgeEval(n,r,s))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,r.s)):((o=t.edgeSign(i,n,r))+(l=-t.edgeSign(i,s,r))<0&&(o=-o,l=-l),a.s=t.interpolate(o,n.s,l,s.s)):a.s=(n.s+r.s)/2,t.transLeq(i,r)||(h=i,i=r,r=h),t.transLeq(n,s)||(h=n,n=s,s=h),t.transLeq(i,n)||(h=i,i=n,n=h,h=r,r=s,s=h),t.transLeq(n,r)?t.transLeq(r,s)?((o=t.transEval(i,n,r))+(l=t.transEval(n,r,s))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,r.t)):((o=t.transSign(i,n,r))+(l=-t.transSign(i,s,r))<0&&(o=-o,l=-l),a.t=t.interpolate(o,n.t,l,s.t)):a.t=(n.t+r.t)/2},t}(),i_=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},ZS=function(){function t(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(t.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),t}(),z0=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},V5=function(){function t(){var i=new z0,r=new i_,n=new ZS(0),s=new ZS(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,n.next=n,n.Sym=s,s.next=s,s.Sym=n,this.vHead=i,this.fHead=r,this.eHead=n,this.eHeadSym=s}return t.prototype.makeEdge_=function(i){var r=new ZS(0),n=new ZS(1);i.Sym.side<i.side&&(i=i.Sym);var s=i.Sym.next;return n.next=s,s.Sym.next=r,r.next=i,i.Sym.next=n,r.Sym=n,r.Onext=r,r.Lnext=n,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,n.Sym=r,n.Onext=n,n.Lnext=r,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,r},t.prototype.splice_=function(i,r){var n=i.Onext,s=r.Onext;n.Sym.Lnext=r,s.Sym.Lnext=i,i.Onext=s,r.Onext=n},t.prototype.makeVertex_=function(i,r,n){var s=i;wi(s,"Vertex can't be null!");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r;var o=r;do o.Org=s,o=o.Onext;while(o!==r)},t.prototype.makeFace_=function(i,r,n){var s=i;wi(s,"Face can't be null");var a=n.prev;s.prev=a,a.next=s,s.next=n,n.prev=s,s.anEdge=r,s.trail=null,s.marked=!1,s.inside=n.inside;var o=r;do o.Lface=s,o=o.Lnext;while(o!==r)},t.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,n=i.Sym.next;r.Sym.next=n,n.Sym.next=r},t.prototype.killVertex_=function(i,r){var n=i.anEdge,s=n;do s.Org=r,s=s.Onext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.killFace_=function(i,r){var n=i.anEdge,s=n;do s.Lface=r,s=s.Lnext;while(s!==n);var a=i.prev,o=i.next;o.prev=a,a.next=o},t.prototype.makeEdge=function(){var i=new z0,r=new z0,n=new i_,s=this.makeEdge_(this.eHead);return this.makeVertex_(i,s,this.vHead),this.makeVertex_(r,s.Sym,this.vHead),this.makeFace_(n,s,this.fHead),s},t.prototype.splice=function(i,r){var n=!1,s=!1;if(i!==r){if(r.Org!==i.Org&&(s=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!s){var a=new z0;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!n){var o=new i_;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},t.prototype.delete=function(i){var r=i.Sym,n=!1;if(i.Lface!==i.Rface&&(n=!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),!n){var s=new i_;this.makeFace_(s,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)},t.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),n=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var s=new z0;return this.makeVertex_(s,n,r.Org),r.Lface=n.Lface=i.Lface,r},t.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},t.prototype.connect=function(i,r){var n=!1,s=this.makeEdge_(i),a=s.Sym;if(r.Lface!==i.Lface&&(n=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(s,i.Lnext),this.splice_(a,r),s.Org=i.Dst,a.Org=r.Org,s.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!n){var o=new i_;this.makeFace_(o,s,i.Lface)}return s},t.prototype.zapFace=function(i){var r,n,s,a,o,l=i.anEdge;n=l.Lnext;do n=(r=n).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)),(s=r.Sym).Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},t.prototype.countFaceVerts_=function(i){var r=i.anEdge,n=0;do n++,r=r.Lnext;while(r!==i.anEdge);return n},t.prototype.mergeConvexFaces=function(i){var r,n,s,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(n=r.anEdge).Org;s=n.Lnext,(a=n.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&di.vertCCW(n.Lprev.Org,n.Org,a.Lnext.Lnext.Org)&&di.vertCCW(a.Lprev.Org,a.Org,n.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),n=null,a=null),!n||n.Lnext.Org!==o;)n=s;return!0},t.prototype.check=function(){var i,r,n,s,a,o,l=this.fHead,h=this.vHead,u=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){wi(i.prev===r),a=i.anEdge;do wi(a.Sym!==a),wi(a.Sym.Sym===a),wi(a.Lnext.Onext.Sym===a),wi(a.Onext.Sym.Lnext===a),wi(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(wi(i.prev===r&&i.anEdge===null),s=h,s=h;(n=s.next)!==h;s=n){wi(n.prev===s),a=n.anEdge;do wi(a.Sym!==a),wi(a.Sym.Sym===a),wi(a.Lnext.Onext.Sym===a),wi(a.Onext.Sym.Lnext===a),wi(a.Org===n),a=a.Onext;while(a!==n.anEdge)}for(wi(n.prev===s&&n.anEdge===null),o=u,o=u;(a=o.next)!==u;o=a)wi(a.Sym.next===o.Sym),wi(a.Sym!==a),wi(a.Sym.Sym===a),wi(a.Org!==null),wi(a.Dst!==null),wi(a.Lnext.Onext.Sym===a),wi(a.Onext.Sym.Lnext===a);wi(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)},t}(),G5=function(){this.handle=null},j5=function(){this.key=null,this.node=0},are=function(){function t(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 n=0;n<i+1;n++)this.nodes[n]=new G5,this.handles[n]=new j5;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return t.prototype.floatDown_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((s=i<<1)<this.size&&this.leq(o[a[s+1].handle].key,o[a[s].handle].key)&&++s,wi(s<=this.max),n=a[s].handle,s>this.size||this.leq(o[r].key,o[n].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.floatUp_=function(i){var r,n,s,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(n=a[s=i>>1].handle,s===0||this.leq(o[n].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=n,o[n].node=i,i=s}},t.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},t.prototype.min=function(){return this.handles[this.nodes[1].handle].key},t.prototype.insert=function(i){var r,n;if(2*(r=++this.size)>this.max){var s,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new G5;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new j5}return this.freeList===0?n=r:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[r].handle=n,this.handles[n].node=r,this.handles[n].key=i,this.initialized&&this.floatUp_(r),n},t.prototype.extractMin=function(){var i=this.nodes,r=this.handles,n=i[1].handle,s=r[n].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[n].key=null,r[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),s},t.prototype.delete=function(i){var r,n=this.nodes,s=this.handles;wi(i>=1&&i<=this.max&&s[i].key!==null),n[r=s[i].node].handle=n[this.size].handle,s[n[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(s[n[r>>1].handle].key,s[n[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),s[i].key=null,s[i].node=this.freeList,this.freeList=i},t}(),q3=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},W5=function(){this.key=null,this.next=null,this.prev=null},ore=function(){function t(i,r){this.frame=i,this.leq=r,this.head=new W5,this.head.next=this.head,this.head.prev=this.head}return t.prototype.min=function(){return this.head.next},t.prototype.max=function(){return this.head.prev},t.prototype.insert=function(i){return this.insertBefore(this.head,i)},t.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},t.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var n=new W5;return n.key=r,n.next=i.next,i.next.prev=n,n.prev=i,i.next=n,n},t.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},t}(),lre=function(){function t(){}return t.regionBelow=function(i){return i.nodeUp.prev.key},t.regionAbove=function(i){return i.nodeUp.next.key},t.debugEvent=function(i){},t.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.edgeLeq=function(i,r,n){var s=i.event,a=r.eUp,o=n.eUp;return a.Dst===s?o.Dst===s?di.vertLeq(a.Org,o.Org)?di.edgeSign(o.Dst,a.Org,o.Org)<=0:di.edgeSign(a.Dst,o.Org,a.Org)>=0:di.edgeSign(o.Dst,s,o.Org)<=0:o.Dst===s?di.edgeSign(a.Dst,s,a.Org)>=0:di.edgeEval(a.Dst,s,a.Org)>=di.edgeEval(o.Dst,s,o.Org)},t.deleteRegion=function(i,r){r.fixUpperEdge&&wi(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},t.fixUpperEdge=function(i,r,n){wi(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=n,n.activeRegion=r},t.topLeftRegion=function(i,r){var n,s=r.eUp.Org;do r=t.regionAbove(r);while(r.eUp.Org===s);if(r.fixUpperEdge){if((n=i.mesh.connect(t.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;t.fixUpperEdge(i,r,n),r=t.regionAbove(r)}return r},t.topRightRegion=function(i){var r=i.eUp.Dst;do i=t.regionAbove(i);while(i.eUp.Dst===r);return i},t.addRegionBelow=function(i,r,n){var s=new q3;return s.eUp=n,s.nodeUp=i.dict.insertBefore(r.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,n.activeRegion=s,s},t.isWindingInside=function(i,r){switch(i.windingRule){case is.ODD:return!!(1&r);case is.NONZERO:return r!==0;case is.POSITIVE:return r>0;case is.NEGATIVE:return r<0;case is.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},t.computeWinding=function(i,r){r.windingNumber=t.regionAbove(r).windingNumber+r.eUp.winding,r.inside=t.isWindingInside(i,r.windingNumber)},t.finishRegion=function(i,r){var n=r.eUp,s=n.Lface;s.inside=r.inside,s.anEdge=n,t.deleteRegion(i,r)},t.finishLeftRegions=function(i,r,n){for(var s,a=null,o=r,l=r.eUp;o!==n;){if(o.fixUpperEdge=!1,(s=(a=t.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){t.finishRegion(i,o);break}s=i.mesh.connect(l.Lprev,s.Sym),t.fixUpperEdge(i,a,s)}l.Onext!==s&&(i.mesh.splice(s.Oprev,s),i.mesh.splice(l,s)),t.finishRegion(i,o),l=a.eUp,o=a}return l},t.addRightEdges=function(i,r,n,s,a,o){var l,h,u,d,c=!0;u=n;do wi(di.vertLeq(u.Org,u.Dst)),t.addRegionBelow(i,r,u.Sym),u=u.Onext;while(u!==s);for(a===null&&(a=t.regionBelow(r).eUp.Rprev),h=r,d=a;(u=(l=t.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=t.isWindingInside(i,l.windingNumber),h.dirty=!0,!c&&t.checkForRightSplice(i,h)&&(t.addWinding(u,d),t.deleteRegion(i,h),i.mesh.delete(d)),c=!1,h=l,d=u;h.dirty=!0,wi(h.windingNumber-u.winding===l.windingNumber),o&&t.walkDirtyRegions(i,h)},t.spliceMergeVertices=function(i,r,n){i.mesh.splice(r,n)},t.vertexWeights=function(i,r,n){var s=di.vertL1dist(r,i),a=di.vertL1dist(n,i),o=.5*a/(s+a),l=.5*s/(s+a);i.coords[0]+=o*r.coords[0]+l*n.coords[0],i.coords[1]+=o*r.coords[1]+l*n.coords[1],i.coords[2]+=o*r.coords[2]+l*n.coords[2]},t.getIntersectData=function(i,r,n,s,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,t.vertexWeights(r,n,s),t.vertexWeights(r,a,o)},t.checkForRightSplice=function(i,r){var n=t.regionBelow(r),s=r.eUp,a=n.eUp;if(di.vertLeq(s.Org,a.Org)){if(di.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;di.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(i.pq.delete(s.Org.pqHandle),t.spliceMergeVertices(i,a.Oprev,s)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(s,a.Oprev),r.dirty=n.dirty=!0)}else{if(di.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(s.Sym),i.mesh.splice(a.Oprev,s)}return!0},t.checkForLeftSplice=function(i,r){var n,s=t.regionBelow(r),a=r.eUp,o=s.eUp;if(wi(!di.vertEq(a.Dst,o.Dst)),di.vertLeq(a.Dst,o.Dst)){if(di.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;t.regionAbove(r).dirty=r.dirty=!0,n=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,n),n.Lface.inside=r.inside}else{if(di.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=s.dirty=!0,n=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),n.Rface.inside=r.inside}return!0},t.checkForIntersect=function(i,r){var n,s,a=t.regionBelow(r),o=r.eUp,l=a.eUp,h=o.Org,u=l.Org,d=o.Dst,c=l.Dst,p=new z0;if(wi(!di.vertEq(c,d)),wi(di.edgeSign(d,i.event,h)<=0),wi(di.edgeSign(c,i.event,u)>=0),wi(h!==i.event&&u!==i.event),wi(!r.fixUpperEdge&&!a.fixUpperEdge),h===u||Math.min(h.t,d.t)>Math.max(u.t,c.t))return!1;if(di.vertLeq(h,u)){if(di.edgeSign(c,h,u)>0)return!1}else if(di.edgeSign(d,u,h)<0)return!1;return t.debugEvent(i),di.intersect(d,h,c,u,p),wi(Math.min(h.t,d.t)<=p.t),wi(p.t<=Math.max(u.t,c.t)),wi(Math.min(c.s,d.s)<=p.s),wi(p.s<=Math.max(u.s,h.s)),di.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),n=di.vertLeq(h,u)?h:u,di.vertLeq(n,p)&&(p.s=n.s,p.t=n.t),di.vertEq(p,h)||di.vertEq(p,u)?(t.checkForRightSplice(i,r),!1):!di.vertEq(d,i.event)&&di.edgeSign(d,i.event,p)>=0||!di.vertEq(c,i.event)&&di.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=t.topLeftRegion(i,r),o=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),a),t.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=t.topRightRegion(r),s=t.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=t.finishLeftRegions(i,a,null),t.addRightEdges(i,r,l.Onext,o.Rprev,s,!0),!0):(di.edgeSign(d,i.event,p)>=0&&(t.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),di.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),t.getIntersectData(i,o.Org,h,d,u,c),t.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},t.walkDirtyRegions=function(i,r){for(var n,s,a=t.regionBelow(r);;){for(;a.dirty;)r=a,a=t.regionBelow(a);if(!r.dirty&&(a=r,(r=t.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,n=r.eUp,s=a.eUp,n.Dst!==s.Dst&&t.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(t.deleteRegion(i,a),i.mesh.delete(s),s=(a=t.regionBelow(r)).eUp):r.fixUpperEdge&&(t.deleteRegion(i,r),i.mesh.delete(n),n=(r=t.regionAbove(a)).eUp)),n.Org!==s.Org){if(n.Dst===s.Dst||r.fixUpperEdge||a.fixUpperEdge||n.Dst!==i.event&&s.Dst!==i.event)t.checkForRightSplice(i,r);else if(t.checkForIntersect(i,r))return}n.Org===s.Org&&n.Dst===s.Dst&&(t.addWinding(s,n),t.deleteRegion(i,r),i.mesh.delete(n),r=t.regionAbove(a))}},t.connectRightVertex=function(i,r,n){var s,a=n.Onext,o=t.regionBelow(r),l=r.eUp,h=o.eUp,u=!1;l.Dst!==h.Dst&&t.checkForIntersect(i,r),di.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=t.topLeftRegion(i,r),a=t.regionBelow(r).eUp,t.finishLeftRegions(i,t.regionBelow(r),o),u=!0),di.vertEq(h.Org,i.event)&&(i.mesh.splice(n,h.Oprev),n=t.finishLeftRegions(i,o,null),u=!0),u?t.addRightEdges(i,r,n.Onext,a,a,!0):(s=di.vertLeq(h.Org,l.Org)?h.Oprev:l,s=i.mesh.connect(n.Lprev,s),t.addRightEdges(i,r,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,t.walkDirtyRegions(i,r))},t.connectLeftDegenerate=function(i,r,n){var s,a,o,l,h;return s=r.eUp,di.vertEq(s.Org,n)?(wi(!1),void t.spliceMergeVertices(i,s,n.anEdge)):di.vertEq(s.Dst,n)?(wi(!1),r=t.topRightRegion(r),a=l=(o=(h=t.regionBelow(r)).eUp.Sym).Onext,h.fixUpperEdge&&(wi(a!==o),t.deleteRegion(i,h),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(n.anEdge,o),di.edgeGoesLeft(a)||(a=null),void t.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(s.Sym),r.fixUpperEdge&&(i.mesh.delete(s.Onext),r.fixUpperEdge=!1),i.mesh.splice(n.anEdge,s),void t.sweepEvent(i,n))},t.connectLeftVertex=function(i,r){var n,s,a,o,l,h,u=new q3;if(u.eUp=r.anEdge.Sym,n=i.dict.search(u).key,s=t.regionBelow(n)){if(o=n.eUp,l=s.eUp,di.edgeSign(o.Dst,r,o.Org)===0)return void t.connectLeftDegenerate(i,n,r);a=di.vertLeq(l.Dst,o.Dst)?n:s,n.inside||a.fixUpperEdge?(h=a===n?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?t.fixUpperEdge(i,a,h):t.computeWinding(i,t.addRegionBelow(i,n,h)),t.sweepEvent(i,r)):t.addRightEdges(i,n,r.anEdge,r.anEdge,null,!0)}},t.sweepEvent=function(i,r){i.event=r,t.debugEvent(i);for(var n=r.anEdge;n.activeRegion===null;)if((n=n.Onext)===r.anEdge)return void t.connectLeftVertex(i,r);var s=t.topLeftRegion(i,n.activeRegion);wi(s!==null);var a=t.regionBelow(s),o=a.eUp,l=t.finishLeftRegions(i,a,null);l.Onext===o?t.connectRightVertex(i,s,l):t.addRightEdges(i,s,l.Onext,o,o,!0)},t.addSentinel=function(i,r,n,s){var a=new q3,o=i.mesh.makeEdge();o.Org.s=n,o.Org.t=s,o.Dst.s=r,o.Dst.t=s,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)},t.initEdgeDict=function(i){i.dict=new ore(i,t.edgeLeq);var r=i.bmax[0]-i.bmin[0],n=i.bmax[1]-i.bmin[1],s=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-n,l=i.bmax[1]+n;t.addSentinel(i,s,a,o),t.addSentinel(i,s,a,l)},t.doneEdgeDict=function(i){for(var r,n=0;(r=i.dict.min().key)!==null;)r.sentinel||(wi(r.fixUpperEdge),wi(++n===1)),wi(r.windingNumber===0),t.deleteRegion(i,r)},t.removeDegenerateEdges=function(i){var r,n,s,a=i.mesh.eHead;for(r=a.next;r!==a;r=n)n=r.next,s=r.Lnext,di.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(t.spliceMergeVertices(i,s,r),i.mesh.delete(r),s=(r=s).Lnext),s.Lnext===r&&(s!==r&&((s===n||s===n.Sym)&&(n=n.next),i.mesh.delete(s)),(r===n||r===n.Sym)&&(n=n.next),i.mesh.delete(r))},t.initPriorityQ=function(i){var r,n,s,a=0;for(n=(s=i.mesh.vHead).next;n!==s;n=n.next)a++;for(a+=8,r=i.pq=new are(a,di.vertLeq),n=(s=i.mesh.vHead).next;n!==s;n=n.next)n.pqHandle=r.insert(n);return n===s&&(r.init(),!0)},t.donePriorityQ=function(i){i.pq=null},t.removeDegenerateFaces=function(i,r){var n,s,a;for(n=r.fHead.next;n!==r.fHead;n=s)s=n.next,wi((a=n.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(t.addWinding(a.Onext,a),i.mesh.delete(a));return!0},t.computeInterior=function(i,r){var n,s;if(r===void 0&&(r=!0),t.removeDegenerateEdges(i),!t.initPriorityQ(i))return!1;for(t.initEdgeDict(i);(n=i.pq.extractMin())!==null;){for(;(s=i.pq.min())!==null&&di.vertEq(s,n);)s=i.pq.extractMin(),t.spliceMergeVertices(i,n.anEdge,s.anEdge);t.sweepEvent(i,n)}return i.event=i.dict.min().key.eUp.Org,t.debugEvent(i),t.doneEdgeDict(i),t.donePriorityQ(i),!!t.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},t}(),bwe=function(){function t(){this.mesh=new V5,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=is.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 t.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},t.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},t.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},t.prototype.computeNormal_=function(i){var r,n,s,a,o,l,h=[0,0,0],u=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],g=this.mesh.vHead;r=g.next;for(var v=0;v<3;++v)a=r.coords[v],u[v]=a,m[v]=r,h[v]=a,f[v]=r;for(r=g.next;r!==g;r=r.next)for(var y=0;y<3;++y)(a=r.coords[y])<u[y]&&(u[y]=a,m[y]=r),a>h[y]&&(h[y]=a,f[y]=r);var _=0;if(h[1]-u[1]>h[0]-u[0]&&(_=1),h[2]-u[2]>h[_]-u[_]&&(_=2),u[_]>=h[_])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,n=m[_],s=f[_],d[0]=n.coords[0]-s.coords[0],d[1]=n.coords[1]-s.coords[1],d[2]=n.coords[2]-s.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.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)},t.prototype.checkOrientation_=function(){for(var i,r,n=this.mesh.fHead,s=this.mesh.vHead,a=0,o=n.next;o!==n;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=s.next;i!==s;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]}},t.prototype.projectPolygon_=function(){var i,r,n=this.mesh.vHead,s=[0,0,0],a=!1;s[0]=this.normal[0],s[1]=this.normal[1],s[2]=this.normal[2],!s[0]&&!s[1]&&!s[2]&&(this.computeNormal_(s),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(s);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]=s[o]>0?1:-1;for(var l=n.next;l!==n;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=n.next;u!==n;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))},t.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},t.prototype.tessellateMonoRegion_=function(i,r){var n,s;if((n=r.anEdge).Lnext===n||n.Lnext.Lnext===n)throw"Mono region invalid";for(;di.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;di.vertLeq(n.Org,n.Dst);n=n.Lnext);for(s=n.Lprev;n.Lnext!==s;)if(di.vertLeq(n.Dst,s.Org)){for(;s.Lnext!==n&&(di.edgeGoesLeft(s.Lnext)||di.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)s=i.connect(s.Lnext,s).Sym;s=s.Lprev}else{for(;s.Lnext!==n&&(di.edgeGoesRight(n.Lprev)||di.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)n=i.connect(n,n.Lprev).Sym;n=n.Lnext}if(s.Lnext===n)throw"Mono region invalid";for(;s.Lnext.Lnext!==n;)s=i.connect(s.Lnext,s).Sym;return!0},t.prototype.tessellateInterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)if(r=n.next,n.inside&&!this.tessellateMonoRegion_(i,n))return!1;return!0},t.prototype.discardExterior_=function(i){for(var r,n=i.fHead.next;n!==i.fHead;n=r)r=n.next,n.inside||i.zapFace(n)},t.prototype.setWindingNumber_=function(i,r,n){for(var s,a=i.eHead.next;a!==i.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:n?i.delete(a):a.winding=0},t.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},t.prototype.outputPolymesh_=function(i,r,n,s){var a,o,l=0,h=0;n>3&&i.mergeConvexFaces(n);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>n)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===bo.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*n,this.vertexCount=h,this.vertices=[],this.vertices.length=h*s,this.vertexIndices=[],this.vertexIndices.length=h,u=i.vHead.next;u!==i.vHead;u=u.next)if(u.n!==-1){var c=u.n*s;this.vertices[c+0]=u.coords[0],this.vertices[c+1]=u.coords[1],s>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 f=o;f<n;++f)this.elements[p++]=-1;if(r===bo.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<n;++m)this.elements[p++]=-1}}},t.prototype.outputContours_=function(i,r){var n,s,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){s=n=l.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==s);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,s=n=l.anEdge;do this.vertices[h++]=n.Org.coords[0],this.vertices[h++]=n.Org.coords[1],r>2&&(this.vertices[h++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==s);this.elements[d++]=a,this.elements[d++]=o,a+=o}},t.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new V5),i<2&&(i=2),i>3&&(i=3);for(var n=null,s=0;s<r.length;s+=i)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=r[s+0],n.Org.coords[1]=r[s+1],n.Org.coords[2]=i>2?r[s+2]:0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},t.prototype.tesselate=function(i,r,n,s,a,o){if(i===void 0&&(i=is.ODD),r===void 0&&(r=bo.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,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),lre.computeInterior(this,o);var l=this.mesh;return r===bo.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===bo.BOUNDARY_CONTOURS?this.outputContours_(l,s):this.outputPolymesh_(l,r,n,s),!0},t}(),is.ODD,is.NONZERO,is.POSITIVE,is.NEGATIVE,is.ABS_GEQ_TWO,bo.POLYGONS,bo.CONNECTED_POLYGONS,bo.BOUNDARY_CONTOURS});function xwe(e,t){let i=e.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let h=(l+1)%i;r+=e[2*l]*e[2*h+1]-e[2*h]*e[2*l+1]}let n=r>0!==t?1:-1,s=[];for(let l=0;l<i;l++){let h=(l+1)%i,u=e[2*h]-e[2*l],d=e[2*h+1]-e[2*l+1],c=Math.hypot(u,d);s.push(c>0?[n*d/c,-n*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 s.map((l,h)=>[o(l,s[(h+i-1)%i]),o(l,s[(h+1)%i])])}function wwe(e,t,i){let r=e.length/2,n=new Float32Array(r+1);if(!(t>0)||!(i>0)||r<2)return{u:n,vScale:0};let s=0;for(let a=0;a<r;a++){let o=(a+1)%r;s+=Math.hypot((e[2*o]-e[2*a])/t,(e[2*o+1]-e[2*a+1])/i),n[a+1]=s}return{u:n,vScale:Math.sqrt(t*i)}}function Swe(e,t,i){for(let r=0;r<i.length;r+=3){let n=3*i[r],s=3*i[r+1],a=3*i[r+2],o=e[s]-e[n],l=e[s+1]-e[n+1],h=e[s+2]-e[n+2],u=e[a]-e[n],d=e[a+1]-e[n+1],c=e[a+2]-e[n+2],p=h*u-o*c,f=o*d-l*u;if((l*c-h*d)*(t[n]+t[s]+t[a])+p*(t[n+1]+t[s+1]+t[a+1])+f*(t[n+2]+t[s+2]+t[a+2])<0){let m=i[r+1];i[r+1]=i[r+2],i[r+2]=m}}}var eK,Twe,tK,Mwe=F(()=>{}),iK=F(()=>{eK={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Twe={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},tK={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 Ewe(e,t){return e.normals[3*t+2]<.9999}function Awe(e){let t=FH.get(e);if(t!==void 0)return t;if(!(e.rise>0))return e;let i=new Float32Array(e.normals),r=e.positions.length/3;for(let s=0;s<r;s++){if(!Ewe(e,s))continue;let a=i[3*s],o=i[3*s+1],l=Math.hypot(a,o);if(l===0)continue;let h=e.rise-e.positions[3*s+2],u=Math.min(1,Math.max(0,1-h/e.rise)),d=Math.sqrt(1-u*u);i[3*s]=a/l*d,i[3*s+1]=o/l*d,i[3*s+2]=u}let n={...e,normals:i};return FH.set(e,n),n}function Cwe(e,t,i,r){let n=(t-e.minX)/e.spanX,s=(i-e.minY)/e.spanY;return r?[s,n]:[n,s]}var FH,h4,UH,rK=F(()=>{FH=new WeakMap}),KBe=F(()=>{ne(),pC(),Vr(),Mwe(),iK(),rK(),h4=class extends Mt{constructor(e,t,i=12,r=is.ODD,n,s=!1){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=e,this._depth=t,this._curveSegments=i,this._windingRule=r,this._uvPitch=s?void 0:n,this._legacy=s;let a,o=[e.extractShapePointsToFlatArray([],i),...e.shapeHoles.map(O=>O.extractShapePointsToFlatArray([],i))];try{a=qE({contours:o,windingRule:r,elementType:bo.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=tK}let l=a?.vertexCount??0,h=a?.elementCount??0,u=1/0,d=1/0,c=-1/0,p=-1/0;for(let O of o)for(let k=0;k<O.length;k+=2)O[k]<u&&(u=O[k]),O[k]>c&&(c=O[k]),O[k+1]<d&&(d=O[k+1]),O[k+1]>p&&(p=O[k+1]);let f=this._uvPitch,m=f??(c-u||1),g=f??(p-d||1),v=f===void 0?u:0,y=f===void 0?d:0,_=o.map((O,k)=>xwe(O,k>0)),b=0;for(let O of _)b+=O.length;let x=2*l+4*b,w=3*h*2+6*b,S=new Float32Array(3*x),T=new Float32Array(3*x),M=new Float32Array(2*x),E=new Uint32Array(w),A=new Uint8Array(x),C=0,D=0,R=0,I=!1,U=(O,k,G,K,q,Y,ue=(O-v)/m,de=(k-y)/g)=>{let ge=3*D;S[ge]=O,S[ge+1]=k,S[ge+2]=G,T[ge]=K,T[ge+1]=q,T[ge+2]=Y,A[D]=G===t?I?2:1:0,M[2*D]=ue,M[2*D+1]=de,D++};if(a!==void 0)for(let[O,k]of[[t,1],[0,-1]]){let G=D;for(let K=0;K<l;K++)U(a.vertices[2*K],a.vertices[2*K+1],O,0,0,k);for(let K=0;K<h;K++){let[q,Y,ue]=[a.elements[3*K],a.elements[3*K+1],a.elements[3*K+2]];E[R++]=G+q,E[R++]=G+(k>0?Y:ue),E[R++]=G+(k>0?ue:Y)}}I=!0;for(let O=0;O<o.length;O++){let k=o[O],G=_[O],K=k.length/2,{u:q,vScale:Y}=s?{u:new Float32Array(K+1),vScale:0}:wwe(k,m,g);C=Y;let ue=Y===0?0:t/Y,de={minX:v,minY:y,spanX:m,spanY:g},ge=(be,[re,xe],j,z)=>{let X=k[2*be],te=k[2*be+1],[V,ae]=s?Cwe(de,X,te,j):[z,j?0:ue];U(X,te,j?0:t,re,xe,0,V,ae)};for(let be=0;be<G.length;be++){let re=(be+1)%K,[xe,j]=G[be],[z,X]=[q[be],q[be+1]],te=D;ge(be,xe,!1,z),ge(be,xe,!0,z),ge(re,j,!1,X),ge(re,j,!0,X),E[R++]=te,E[R++]=te+1,E[R++]=te+2,E[R++]=te+3,E[R++]=te+2,E[R++]=te+1}}Swe(S,T,E),this.setAttribute("position",new Pt(S,3)),this.setAttribute("normal",new Pt(T,3)),this.setAttribute("uv",new Pt(M,2)),this.setIndex(new Pt(E,1)),this._nearSide=A,this._vScale=C}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale)}canShiftDepthTo(e){return this._nearSide.length>0&&this._depth>0&&e>0}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=t,h===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=new h4(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return e.userData=bB(this.userData),e}}}),Pwe=F(()=>{ne(),pC(),Vr(),iK(),UH=class extends Mt{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=is.ODD,this.elementType=bo.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:is.ODD,elementType:bo.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,n,s,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 f=2*c,m=a[f+0],g=a[f+1];if(n!==void 0&&m!==n&&(l=!1),s!==void 0&&g!==s&&(h=!1),n=m,s=g,!l&&!h)break}if(!l&&!h)try{r=qE({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=eK}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new Pt(new Float32Array(3*u),3),this._normalAttribute=new Pt(new Float32Array(3*u),3),this._uvAttribute=new Pt(new Float32Array(2*u),2),this._indexAttribute=new Pt(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,_=u;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1];x<c&&(c=x),x>p&&(p=x),w<f&&(f=w),w>m&&(m=w)}let g=p-c,v=m-f;for(let y=0,_=u;y<_;y++){let b=2*y,x=r.vertices[b+0],w=r.vertices[b+1],S=(x-c)/g,T=(w-f)/v;this._positionAttribute.setXYZ(y,x,w,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,T)}for(let y=0,_=d;y<_;y++){let b=3*y,x=r.elements[b+0],w=r.elements[b+1],S=r.elements[b+2];this._indexAttribute.setX(b+0,x),this._indexAttribute.setX(b+1,w),this._indexAttribute.setX(b+2,S)}}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 e=new UH(this._shape,this._curveSegments);return e.userData=bB(this.userData),e}}});function ZBe(e){return hre||(hre=async function(){let t=e??"https://unpkg.com/@splinetool/runtime@2.0.205/build",i=Promise.resolve().then(()=>(mQ(),fQ)),[r,n]=await Promise.all([i,fetch(`${t}/bevel.wasm`).then(s=>s.arrayBuffer())]);await r.default({module_or_path:n}),fC=r}())}function QBe(e){let t=!1;return e.scene.objects.traverse((i,r)=>{let n=r.geometry;if(n!==void 0&&(Iwe.has(n.type)&&n.depth!==void 0&&n.depth>0&&(n.extrudeBevelSize??0)>0&&(t=!0),n.type==="PathGeometry")){let s=n.extrusion;s!==void 0&&s.capType==="round"&&(s.bevel??0)>0&&(t=!0)}}),t}function Rwe(e,t){let i=[e.extractShapePointsToFlatArray([],t)];for(let o of e.shapeHoles)i.push(o.extractShapePointsToFlatArray([],t));let r=0;for(let o of i)r+=o.length>>1;let n=new Float64Array(2*r),s=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)n.set(i[o],2*a),a+=i[o].length>>1,s[o]=a;return{points:n,ends:s}}function u4(e,t,i,r,n,s){let a=e.positions.length/3,o=n.elements,l=Owe.getNormalMatrix(n).elements;for(let u=0;u<a;u++){let d=3*u,c=3*(i+u),p=e.positions[d],f=e.positions[d+1],m=e.positions[d+2];t.positions[c]=o[0]*p+o[4]*f+o[8]*m+o[12],t.positions[c+1]=o[1]*p+o[5]*f+o[9]*m+o[13],t.positions[c+2]=o[2]*p+o[6]*f+o[10]*m+o[14];let g=e.normals[d],v=e.normals[d+1],y=e.normals[d+2];t.normals[c]=l[0]*g+l[3]*v+l[6]*y,t.normals[c+1]=l[1]*g+l[4]*v+l[7]*y,t.normals[c+2]=l[2]*g+l[5]*v+l[8]*y;let _=2*(i+u);if(s===void 0)t.uvs[_]=e.uvs[2*u],t.uvs[_+1]=e.uvs[2*u+1];else{let[b,x]=s(p,f,e.uvs[2*u],e.uvs[2*u+1],u);t.uvs[_]=b,t.uvs[_+1]=x}}let h=n.determinant()<0;for(let u=0;u<e.indices.length;u+=3)t.indices[r+u]=e.indices[u]+i,t.indices[r+u+1]=e.indices[u+(h?2:1)]+i,t.indices[r+u+2]=e.indices[u+(h?1:2)]+i}function Dwe(e){let{owner:t,shape:i,curveSegments:r,assembledAt:n,bevel:s,bevelSegments:a}=e,o=function(c,p){let f=[p],m=g=>{f.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let v of g.points){f.push(v.roundness??0,v.position.x,v.position.y);for(let y of v.controls)f.push(y.position.x,y.position.y)}f.push(g.shapeHoles.length);for(let v of g.shapeHoles)m(v)};return m(c),function(g){let v=2166136261;for(let y=0;y<g.length;y++)v^=g[y],v=Math.imul(v,16777619)>>>0;return v}(new Uint8Array(new Float64Array(f).buffer))}(i,r),l=t??`outline:${o}`,h=`${s}/${a}`,u=d4.get(l);if(u!==void 0&&u.outlineVersion===o&&u.capKey===h&&(e.stillServes?.(u)??1))return zH.placements++,u.cap;let d=function(c,p,f,m,g){let{points:v,ends:y}=Rwe(c,p);return fC.assemble_cap(v,y,f,m,0,Math.max(1,Math.floor(g)),Nwe,40)}(i,r,n,s,a);zH.assemblies++;try{let c=function(p,f){return function(m,g,v,y,_){let b=1/0;for(let x=2;x<m.length;x+=3)m[x]<b&&(b=m[x]);if(b===1/0&&(b=0),b!==0)for(let x=2;x<m.length;x+=3)m[x]-=b;return{positions:m,normals:g,uvs:v,indices:y,rise:_-b}}(p.positions(),p.normals(),p.uvs(),p.indices(),f)}(d,n);return d4.set(l,{outlineVersion:o,capKey:h,assembledAt:n,cap:c}),c}finally{d.free()}}function dx(e,t){return .5*t>1.001*e}var fC,Nwe,hre,Iwe,Owe,ure,dre,cre,d4,zH,kH,l0,Rw=F(()=>{ne(),Vr(),Mwe(),rK(),Nwe=.4,Iwe=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),Owe=new si,ure=new De,dre=new De,cre=new De().makeScale(1,1,-1),d4=new Map,zH={assemblies:0,placements:0},kH=class extends Mt{constructor(e,t,i=0,r=12,n=3,s,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,fC===void 0)throw new Error("bevel-wasm is not loaded");this._shape=e,this._uvPitch=a,this._legacy=o,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegments=n,this._ownerId=s,this.rebuild()}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length>0&&dx(this._effectiveBevel,e)&&dx(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=t,h===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}setDepth(e){e!==this._depth&&(this._depth=e,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let e=Dwe({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>dx(a.cap.rise,this._depth)&&dx(a.cap.rise,a.assembledAt)}),t=function(a,o,l,h,u,d=!1){let c=h.positions.length/3,p=l-h.rise,f=h.rise,{points:m,ends:g}=Rwe(a,o),v=1/0,y=1/0,_=-1/0,b=-1/0;for(let de=0;de<m.length;de+=2)m[de]<v&&(v=m[de]),m[de]>_&&(_=m[de]),m[de+1]<y&&(y=m[de+1]),m[de+1]>b&&(b=m[de+1]);d&&(u=void 0);let x=u??_-v,w=u??b-y,S={minX:v,minY:y,spanX:_-v||1,spanY:b-y||1},T=[],M=0;for(let de of g)T.push({at:M,count:de-M}),M=de;let E=0;for(let de of T)E+=de.count;let A=2*c+4*E,C=new Float32Array(3*A),D=new Float32Array(3*A),R=new Float32Array(2*A),I=new Uint32Array(2*h.indices.length+6*E),U=new Uint8Array(A),O=0,k=u===void 0?void 0:(de,ge)=>[de/u,ge/u],G=d?(de,ge,be,re,xe)=>Ewe(h,xe)?[re,be]:[be,re]:k,K=d?Awe(h):h,q={positions:C,normals:D,uvs:R,indices:I};u4(K,q,0,0,ure.makeTranslation(0,0,p),k),u4(K,q,c,h.indices.length,dre.makeTranslation(0,0,f).multiply(cre),G),U.fill(1,0,c);let Y=2*c,ue=2*h.indices.length;for(let de=0;de<T.length;de++){let{at:ge,count:be}=T[de],re=m.subarray(2*ge,2*(ge+be)),xe=xwe(re,de>0),j=d?{u:new Float32Array(be+1),vScale:0}:wwe(re,x,w),z=j.u;O=j.vScale;for(let X=0;X<be;X++){let te=(X+1)%be,[V,ae]=xe[X],se=Y;for(let[W,pe,_e,Ue,we,Ye]of[[re[2*X],re[2*X+1],V,p,z[X],2],[re[2*te],re[2*te+1],ae,p,z[X+1],2],[re[2*te],re[2*te+1],ae,f,z[X+1],0],[re[2*X],re[2*X+1],V,f,z[X],0]]){let Fe=3*Y;if(C[Fe]=W,C[Fe+1]=pe,C[Fe+2]=Ue,D[Fe]=_e[0],D[Fe+1]=_e[1],D[Fe+2]=0,d){let[We,Re]=Cwe(S,W,pe,Ye===0);R[2*Y]=We,R[2*Y+1]=Re}else R[2*Y]=we,R[2*Y+1]=O===0?0:(Ue-f)/O;U[Y]=Ye,Y++}I[ue++]=se,I[ue++]=se+1,I[ue++]=se+2,I[ue++]=se,I[ue++]=se+2,I[ue++]=se+3}}return Swe(C,D,I),{positions:C,normals:D,uvs:R,indices:I,nearSide:U,vScale:O}}(this._shape,this._curveSegments,this._depth,e,this._uvPitch,this._legacy);this._nearSide=t.nearSide,this._vScale=t.vScale,this._effectiveBevel=e.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),n=this.getAttribute("uv"),s=this.getIndex();if(i!==void 0&&r!==void 0&&n!==void 0&&s!==null&&i.array.length===t.positions.length&&r.array.length===t.normals.length&&n.array.length===t.uvs.length&&s.array.length===t.indices.length)return i.array.set(t.positions),r.array.set(t.normals),n.array.set(t.uvs),s.array.set(t.indices),i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0,void(s.needsUpdate=!0);this.setAttribute("position",new Pt(t.positions,3)),this.setAttribute("normal",new Pt(t.normals,3)),this.setAttribute("uv",new Pt(t.uvs,2)),this.setIndex(new Pt(t.indices,1))}clone(){let e=new kH(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return e.userData=bB(this.userData),e}}}),e0=F(()=>{o0(),KBe(),Pwe(),Rw(),pC(),l0=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:is.ODD},e.parameters),n=Math.abs(r.width),s=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=e.shape??t?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof cs?(i=o,(i.width!==n||i.height!==s)&&i.applySize(n,s)):i=new cs(n,s).fromJSON(o),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&i.update());let h=i??new cs(n,s);return{parameters:Object.assign(r,{width:n,height:s,depth:a,roundness:l}),shape:h,ownerId:e.ownerId??t?.ownerId}}static build(e){let t,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:n,subdivisions:s,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:h}=e.parameters,u=h===1;return e.shape.roundness=a,i<=0?t=new UH(e.shape,s,{windingRule:o}):r<=0?t=new h4(e.shape,i,s,o,l,u):fC!==void 0?t=new kH(e.shape,i,r,s,n,e.ownerId,l,u):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),t=new h4(e.shape,i,s,o,l,u)),Object.assign(t,{userData:{...e,type:"VectorGeometry"}})}}});function JBe(e,t,i,r,n,s){if(r>=nK)return n>30||n%4==0?(function(u,d,c,p=0,f=0,m=0){let g=.5522847498,v=d*g,y=c*g;u.addPoint($3(f-d,m,f-d,m-y,f-d,m+y)),u.addPoint($3(f,m+c,f-v,m+c,f+v,m+c)),u.addPoint($3(f+d,m,f+d,m+y,f+d,m-y)),u.addPoint($3(f,m-c,f+v,m-c,f-v,m-c)),p>0&&Bwe(u,d,c,p)}(e,t,i,s),Math.round(n/4)):pre(e,r,n,t,i,s);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=function({px:u,py:d,cx:c,cy:p,rx:f,ry:m,largeArcFlag:g,sweepFlag:v}){let y=[];if(f===0||m===0)return[];let _=(u-c)/2,b=(d-p)/2;if(_===0&&b===0)return[];f=Math.abs(f),m=Math.abs(m);let x=Math.pow(_,2)/Math.pow(f,2)+Math.pow(b,2)/Math.pow(m,2);x>1&&(f*=Math.sqrt(x),m*=Math.sqrt(x));let w=function(D,R,I,U,O,k,G,K,q,Y){let ue=Math.pow(O,2),de=Math.pow(k,2),ge=Math.pow(G,2),be=Math.pow(K,2),re=ue*de-ue*be-de*ge;re<0&&(re=0),re/=ue*be+de*ge,re=Math.sqrt(re)*(q===Y?-1:1);let xe=re*O/k*K,j=re*-k/O*G,z=xe+(D+I)/2,X=j+(R+U)/2,te=(G-xe)/O,V=(K-j)/k,ae=(-G-xe)/O,se=(-K-j)/k,W=sre(1,0,te,V),pe=sre(te,V,ae,se);return!Y&&pe>0&&(pe-=aO),Y&&pe<0&&(pe+=aO),{centerx:z,centery:X,ang1:W,ang2:pe}}(u,d,c,p,f,m,_,b,g,v),{ang1:S,ang2:T}=w,{centerx:M,centery:E}=w,A=Math.abs(T)/(aO/4);Math.abs(1-A)<1e-7&&(A=1);let C=Math.max(Math.ceil(A),1);T/=C;for(let D=0;D<C;D++)y.push(XBe(S,T)),S+=T;return y.map(D=>{let{x:R,y:I}=k5(D[0],f,m,M,E),{x:U,y:O}=k5(D[1],f,m,M,E),{x:k,y:G}=k5(D[2],f,m,M,E);return{x1:R,y1:I,x2:U,y2:O,x:k,y:G}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%h.length===0?function(u,d,c,p,f,m,g,v){let y=Math.round(f/p.length);u.addPoint(Ox(d,c));for(let _=0,b=p.length;_<b;_++){let x=p[_],w=u.points[_],S=Ox(x.x,x.y);w.controls[1].position.set(x.x1,x.y1),S.controls[0].position.set(x.x2,x.y2),u.addPoint(S)}return v>0?Lwe(u,m,g,v):u.addPoint(Ox(0,0)),y}(e,a.x,a.y,h,n,t,i,s):pre(e,r,n,t,i,s)}function pre(e,t,i,r,n,s){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*n;e.addPoint(Ox(h,u))}return t<nK?s>0?Lwe(e,r,n,s):e.addPoint(Ox(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&Bwe(e,r,n,s)),1}function Ox(e,t){return new My(Qe.generateUUID(),new Z(e,t))}function $3(e,t,i,r,n,s){let a=Ox(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(n,s),a}function Lwe(e,t,i,r){Fwe(e,t,i,r).forEach(n=>e.addPoint(n))}function Bwe(e,t,i,r){let n=Fwe(e,t,i,r),s=new cs;n.forEach(a=>s.addPoint(a)),s.isClosed=!0,e.shapeHoles.push(s)}function Fwe(e,t,i,r){let n=r*t/100,s=n*(Math.abs(i)/Math.abs(t)),a=new Z(n/t,s/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Qe.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 nK,FB,Uwe,H5,zwe,c4=F(()=>{o0(),_we(),YBe(),e0(),ne(),nK=2*Math.PI,FB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=Qe.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let t,{width:i,height:r,spikes:n,angle:s,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=e.parameters,d=e.shape,c=JBe(d,.5*i,.5*r,s*Math.PI/180,n,a);return d.isClosed=!0,d.update(),s===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=l0.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}}),Object.assign(t,{userData:{...e,type:"EllipseGeometry"}})}}}),fre=F(()=>{ne(),pwe(),Uwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.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(e){let{width:t,height:i,depth:r,detail:n,corner:s,cornerSides:a}=e.parameters,o=n===0&&s!==0?new H5(.5*t,s,a):new mW(.5*t,n),l=i/t,h=r/t;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},H5=class extends o4{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,n="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],n,e,t,i),this.type=n}static fromJSON(e){return new H5(e.radius,e.corner,e.cornerSides)}}}),mre=F(()=>{ne(),zwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.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}]},e.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(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,n=new AA;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new gW(n.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}}});function r_(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function eFe(e){let{positions:t,faces:i,materialIndices:r,uvs:n}=e,s=t.length/3,a=i.length/3,o=n!==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),f=0,m=8;for(;m<2*l;)m*=2;let g=m-1,v=new Int32Array(m).fill(-1),y=(R,I)=>{let U=(Math.imul(R,2654435761)^I)&g;for(;;){let O=v[U];if(O===-1)return v[U]=f,h[f]=R,u[f]=I,f++;if(h[O]===R&&u[O]===I)return O;U=U+1&g}},_=(R,I)=>{let U=R<I?R:I,O=R<I?I:R,k=(Math.imul(U,2654435761)^O)&g;for(;;){let G=v[k];if(h[G]===U&&u[G]===O)return G;k=k+1&g}},b=new Uint32Array(s),x=new Float64Array(3*s),w=(R,I,U)=>{let O=R<I?y(R,I):y(I,R),k=++d[O];k===1?c[O]=U:k===2&&(p[O]=U),b[R]++,b[I]++,x[3*R]+=t[3*I],x[3*R+1]+=t[3*I+1],x[3*R+2]+=t[3*I+2],x[3*I]+=t[3*R],x[3*I+1]+=t[3*R+1],x[3*I+2]+=t[3*R+2]};for(let R=0;R<a;R++){let I=i[3*R],U=i[3*R+1],O=i[3*R+2];w(I,U,O),w(U,O,I),w(O,I,U)}let S=new Float64Array(3*f);for(let R=0;R<f;R++){let I=3*h[R],U=3*u[R];if(d[R]===2){let O=3*c[R],k=3*p[R];S[3*R]=.375*(t[I]+t[U])+.125*(t[O]+t[k]),S[3*R+1]=.375*(t[I+1]+t[U+1])+.125*(t[O+1]+t[k+1]),S[3*R+2]=.375*(t[I+2]+t[U+2])+.125*(t[O+2]+t[k+2])}else S[3*R]=.5*(t[I]+t[U]),S[3*R+1]=.5*(t[I+1]+t[U+1]),S[3*R+2]=.5*(t[I+2]+t[U+2])}let T,M=new Float64Array(3*s);for(let R=0;R<s;R++){let I=b[R];I===3?T=3/16:I>3&&(T=3/(8*I));let U=1-I*Number(T),O=Number(T);I===2&&(U=3/4,O=1/8),M[3*R]=t[3*R]*U+x[3*R]*O,M[3*R+1]=t[3*R+1]*U+x[3*R+1]*O,M[3*R+2]=t[3*R+2]*U+x[3*R+2]*O}let E=new Float64Array(3*(s+f));E.set(M),E.set(S,3*s);let A=new Uint32Array(12*a),C=new Array(4*a),D=o?new Float64Array(24*a):null;for(let R=0;R<a;R++){let I=i[3*R],U=i[3*R+1],O=i[3*R+2],k=_(I,U)+s,G=_(U,O)+s,K=_(O,I)+s,q=12*R;A[q++]=k,A[q++]=G,A[q++]=K,A[q++]=I,A[q++]=k,A[q++]=K,A[q++]=U,A[q++]=G,A[q++]=k,A[q++]=O,A[q++]=K,A[q++]=G;let Y=r[R];if(C[4*R]=Y,C[4*R+1]=Y,C[4*R+2]=Y,C[4*R+3]=Y,D!==null){let ue=6*R,de=n[ue],ge=n[ue+1],be=n[ue+2],re=n[ue+3],xe=n[ue+4],j=n[ue+5],z=r_(de,be),X=r_(ge,re),te=r_(be,xe),V=r_(re,j),ae=r_(de,xe),se=r_(ge,j),W=24*R;D[W++]=z,D[W++]=X,D[W++]=te,D[W++]=V,D[W++]=ae,D[W++]=se,D[W++]=de,D[W++]=ge,D[W++]=z,D[W++]=X,D[W++]=ae,D[W++]=se,D[W++]=be,D[W++]=re,D[W++]=te,D[W++]=V,D[W++]=z,D[W++]=X,D[W++]=xe,D[W++]=j,D[W++]=ae,D[W++]=se,D[W++]=te,D[W++]=V}}return{positions:E,faces:A,materialIndices:C,uvs:D}}var X3,kwe,ea,Vwe,sK,tFe=F(()=>{ne(),X3=1e4,kwe=class{constructor(e=1){this.subdivisions=e}modify(e){let t=function(r){let n=r.getAttribute("position");if(n===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let s=r.getAttribute("uv"),a=r.getIndex(),o=n.count,l=new Map,h=new Uint32Array(o),u=[],d=0;for(let y=0;y<o;y++){let _=n.getX(y),b=n.getY(y),x=n.getZ(y),w=Math.round(_*X3),S=Math.round(b*X3),T=Math.round(x*X3),M=l.get(w);M===void 0&&(M=new Map,l.set(w,M));let E=M.get(S);E===void 0&&(E=new Map,M.set(S,E));let A=E.get(T);A===void 0&&(A=d++,E.set(T,A),u.push(_,b,x)),h[y]=A}let c=[],p=[],f=s===void 0?null:[],m=a!==null?a.count:o,g=(y,_)=>{let b=a!==null?a.getX(y):y,x=a!==null?a.getX(y+1):y+1,w=a!==null?a.getX(y+2):y+2;if(!(b<o&&x<o&&w<o))return;let S=h[b],T=h[x],M=h[w];S===T||T===M||M===S||(c.push(S,T,M),p.push(_),f!==null&&f.push(s.getX(b),s.getY(b),s.getX(x),s.getY(x),s.getX(w),s.getY(w)))},v=r.groups;if(v.length>0)for(let y=0;y<v.length;y++){let _=v[y],b=_.materialIndex===void 0?0:_.materialIndex,x=Math.max(_.start,0),w=Math.min(_.start+_.count,m);for(let S=x;S<w&&S+2<m;S+=3)g(S,b)}else for(let y=0;y+2<m;y+=3)g(y,0);return{positions:Float64Array.from(u),faces:Uint32Array.from(c),materialIndices:p,uvs:f===null?null:Float64Array.from(f)}}(e),i=this.subdivisions;for(;i-- >0;)t=eFe(t);return function(r,n){let{positions:s,faces:a,materialIndices:o,uvs:l}=r,h=s.length/3,u=a.length/3,d=new Float64Array(3*h);for(let v=0;v<u;v++){let y=3*a[3*v],_=3*a[3*v+1],b=3*a[3*v+2],x=s[b]-s[_],w=s[b+1]-s[_+1],S=s[b+2]-s[_+2],T=s[y]-s[_],M=s[y+1]-s[_+1],E=s[y+2]-s[_+2],A=w*E-S*M,C=S*T-x*E,D=x*M-w*T;d[y]+=A,d[y+1]+=C,d[y+2]+=D,d[_]+=A,d[_+1]+=C,d[_+2]+=D,d[b]+=A,d[b+1]+=C,d[b+2]+=D}for(let v=0;v<h;v++){let y=d[3*v],_=d[3*v+1],b=d[3*v+2],x=Math.sqrt(y*y+_*_+b*b)||1;d[3*v]=y/x,d[3*v+1]=_/x,d[3*v+2]=b/x}let c=3*u,p=new Float32Array(3*c),f=new Float32Array(3*c),m=l!==null&&l.length>0?new Float32Array(2*c):null;for(let v=0;v<c;v++){let y=3*a[v];p[3*v]=s[y],p[3*v+1]=s[y+1],p[3*v+2]=s[y+2],f[3*v]=d[y],f[3*v+1]=d[y+1],f[3*v+2]=d[y+2]}m!==null&&m.set(l.subarray(0,2*c));let g=new Mt;g.setAttribute("position",new Pt(p,3)),c>0&&(g.setAttribute("normal",new Pt(f,3)),g.setAttribute("color",new Pt(new Float32Array(3*c).fill(1),3))),m!==null&&g.setAttribute("uv",new Pt(m,2));for(let v=0;v<u;){let y=o[v],_=v;do v++;while(v<u&&o[v]===y);g.addGroup(3*_,3*(v-_),y)}return n.boundingBox!==null&&(g.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(g.boundingSphere=n.boundingSphere.clone()),g}(t,e)}}}),gre=F(()=>{ne(),tFe(),ea=new P,Vwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=e.geometry??t?.geometry??new Mt().copy(new Dh(100,100,100));t===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(ea),i={width:ea.x,height:ea.y,depth:ea.z,subdivisions:0}):i=t.parameters;let n={...i,...e.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:r}}static build(e){let{width:t,height:i,depth:r,subdivisions:n}=e.parameters,s=e.geometry??new Mt().copy(new Dh(100,100,100)),a=s.userData.parameters;a===void 0?(s.boundingBox=function(l){let h=new cn,u=l.attributes.position;return u?(h.setFromBufferAttribute(u),h):(h.makeEmpty(),h)}(s),s.boundingBox.getSize(ea)):ea.set(a.width,a.height,a.depth),(t!==ea.x||i!==ea.y||r!==ea.z)&&s.scale(ea.x===0?1:t/ea.x,ea.y===0?1:i/ea.y,ea.z===0?1:r/ea.z);let o=s.originalGeometry;try{n>0?(o===void 0||a?.subdivisions!==n)&&(o===void 0&&(o=s),s=new kwe(n).modify(o)):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new sY(i).load(e,r=>{let n=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ea);let s=100/ea.x;Object.assign(n.parameters,{width:100,height:ea.y*s,depth:ea.z*s}),t(this.build(n))})}}}),VH=F(()=>{o0(),e0(),sK=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}=e.parameters,h=e.shape,u=.5*t,d=.5*i,c=2*Math.PI/r;for(let f=0;f<r;f++){let m=c*f,g=0+Math.sin(m)*u,v=0+Math.cos(m)*d;h.addPoint(h.createPoint(g,v))}h.isClosed=!0;for(let f=0,m=h.points.length;f<m;f++)h.points[f].roundness=n;h.roundness=n,h.update();let p=l0.create({shape:h,parameters:{roundness:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...e,type:"PolygonGeometry"}})}}});function QS(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function q5(e,t,i,r,n,s){let a=jwe.copy(t).sub(e),o=Wwe.copy(i).sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===n){let h=a.add(o).normalize();s.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);s.copy(e),s.addScaledVector(a,n/Math.sin(h)),s.addScaledVector(o,r/Math.sin(h))}}function iFe(e,t,i){let r=e.clone().sub(t),n=i.clone().sub(t);return r.projectOnVector(n),r.add(t)}var Gwe,jwe,Wwe,vre,UB,Hwe,qwe,$we,yre,aK,Xwe,Ywe,Kwe,Zwe,_re=F(()=>{ne(),Gwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.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(e){let{width:t,height:i,depth:r,radialSegments:n,heightSegments:s,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new vre(.5*t,i,n,s,a,o,l),u=r/t;return u!==1&&h.scale(1,1,u),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}},jwe=new P,Wwe=new P,vre=class extends Mt{constructor(e=.5,t=1,i=4,r=1,n=!1,s=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=t/2,f=Math.PI/i,m=e*Math.cos(Math.PI/i),g=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,_=new P(0,-p,0),b=new P(0,p,0),x=new Z(e,-p),w=new Z(m,-p),S=new Z(0,b.y).sub(w),T=new Z(0,b.y).sub(x),M=new Z(S.y,-S.x).normalize(),E=new Z(T.y,-T.x).normalize(),A=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;s=Math.min(s,A);{let k=new P(M.x,M.y,0),G=new P(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);o=k.angleTo(G)}let C=s/Math.tan((Math.PI-S.angle())/2),D=s/Math.tan((Math.PI-o)/2),R=new P;if(!n){h.push(_.x,_.y,_.z),u.push(0,-1,0),d.push(0,0);let k=c++,G=[],K=x.clone(),q=C/Math.cos(Math.PI/i);K.x-=q;for(let Y=0;Y<i;Y++){let ue=Y/i*Math.PI*2+f;QS(K,new Z(Math.sin(ue),Math.cos(ue)),R),h.push(R.x,R.y,R.z),u.push(0,-1,0),d.push(0,0),G.push(c++)}for(let Y=0;Y<G.length;Y++)l.push(G[Y],k,G[(Y+1)%G.length])}let I=[];{let k=new P,G=new P,K=new P,q=new P,Y=new P,ue=new P;for(let de=0;de<i;de++){let ge=de/i*Math.PI*2+f,be=(de+.5)/i*Math.PI*2+f,re=(de+1)/i*Math.PI*2+f,xe=new Z(Math.sin(ge),Math.cos(ge)),j=new Z(Math.sin(be),Math.cos(be)),z=new Z(Math.sin(re),Math.cos(re));QS(x,xe,G),QS(x,z,K),QS(M,j,k),q5(b,G,K,D,D,q),h.push(q.x,q.y,q.z),q5(G,b,K,D,C,Y),h.push(Y.x,Y.y,Y.z),q5(K,G,b,C,D,ue),h.push(ue.x,ue.y,ue.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 X=c++,te=c++,V=c++;if(l.push(X,te,V),s>0){{let W=G.clone().add(K).multiplyScalar(.5),pe=b.clone().sub(W).normalize(),_e=_.clone().sub(W).normalize().add(pe).normalize().multiplyScalar(-1);U(W,ue.clone().sub(Y),_e,S.angle())}let ae,se;{let W=new P;QS(E,z,W);let pe=ue.clone().add(q).multiplyScalar(.5);pe=iFe(pe,K,b);let _e=ue.clone().sub(q);[ae,se]=U(pe,_e,W,o,q.y)}{let W=ae,pe=W.clone().setY(0).normalize(),_e=new P(0,-1,0),Ue=pe.clone().cross(_e);O(W,pe,_e,Ue)}I.concat(se);{let W=S.angle(),pe=Math.PI-W,_e=b.clone();_e.y-=s/Math.sin(W-Math.PI/2);let Ue=new P,we=[];for(let Fe=0;Fe<a;Fe++){let We=[],Re=Math.PI/2-pe*Fe/a,ee=Math.cos(Re),Ee=Math.sin(Re),je=be;for(let dt=0;dt<=Fe;dt++){let et=Math.cos(je),$t=Math.sin(je);k.x=ee*$t,k.y=Ee,k.z=ee*et,Ue.copy(_e).addScaledVector(k,s),h.push(Ue.x,Ue.y,Ue.z),u.push(k.x,k.y,k.z),d.push(0,0),We.push(c++),je+=2*Math.PI/Fe/i}we.push(We)}se.reverse(),we.push(se);let Ye=we.length-1;for(let Fe=0;Fe<Ye;Fe++){let We=we[Fe],Re=we[Fe+1],ee=We.length-1;l.push(Re[1],We[0],Re[0]);for(let Ee=1;Ee<=ee;Ee++)l.push(We[Ee],We[Ee-1],Re[Ee]),l.push(Re[Ee+1],We[Ee],Re[Ee])}}}}}function U(k,G,K,q,Y){let ue=-q/2,de=(Math.PI-q)/2,ge=G.clone().normalize().cross(K);k.addScaledVector(K,-s/Math.sin(de));let be=new P,re=new P,xe=c,j=[];for(let z=0;z<=a;z++){let X=ue+z/a*q;re.set(0,0,0),re.addScaledVector(ge,Math.sin(X)),re.addScaledVector(K,Math.cos(X));for(let te=0;te<=1;te++){let V=te/1-.5;if(be.copy(k),be.addScaledVector(G,V),be.addScaledVector(re,s),Y!=null){let ae=Math.max(0,be.y-Y);be.addScaledVector(G,-ae/G.y)}h.push(be.x,be.y,be.z),u.push(re.x,re.y,re.z),d.push(0,0),te===0&&j.push(c),c++}}for(let z=0;z<a;z++)for(let X=0;X<1;X++){let te=xe+X+2*z,V=te+2,ae=V+1,se=te+1;l.push(te,V,se),l.push(V,ae,se)}return[k.clone().addScaledVector(G,.5),j]}function O(k,G,K,q){let Y=Math.PI/2,ue=T.angle()-Y,de=[],ge=new P,be=new P;for(let xe=0;xe<=a;xe++){let j=[],z=xe/a;for(let X=0;X<=xe;X++){let te=((xe?X/xe:0)-.5)*y,V=Math.cos(te),ae=Math.sin(te),se=(Y+Math.atan(Math.tan(ue)*V))*z,W=Math.cos(se),pe=Math.sin(se);ge.set(0,0,0),ge.addScaledVector(G,pe*V),ge.addScaledVector(K,W),ge.addScaledVector(q,pe*ae),be.copy(k).addScaledVector(ge,s),h.push(be.x,be.y,be.z),u.push(ge.x,ge.y,ge.z),d.push(0,0),j.push(c++)}de.push(j)}let re=de.length-1;for(let xe=0;xe<re;xe++){let j=de[xe],z=de[xe+1],X=j.length-1;l.push(j[0],z[1],z[0]);for(let te=1;te<=X;te++)l.push(j[te-1],j[te],z[te]),l.push(j[te],z[te+1],z[te])}}this.setIndex(l),this.setAttribute("position",new Tt(h,3)),this.setAttribute("normal",new Tt(u,3)),this.setAttribute("uv",new Tt(d,2))}}}),p4=F(()=>{o0(),e0(),UB=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,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(e){let t=e.shape,{width:i,height:r,cornerRadius:n,cornerType:s,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}=e.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,w,S){return w>i&&S>r?Math.min(x*i/w,x*r/S):w>i?x*i/w:S>r?x*r/S:x}let f=[];f[0]=n[0]===0?0:p(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:p(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:p(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:p(n[3],n[3]+n[0],n[3]+n[2]);let m=d.x,g=c.x,v=c.y,y=d.y;t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let _=!0;for(let x=0,w=t.points.length;x<w;x++)t.points[x].roundness=f[x],x>0&&f[x]!==f[x-1]&&(_=!1);_&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=l0.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}}}),bre=F(()=>{ne(),Hwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=Qe.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(e){let t,{width:i=100,height:r=i,depth:n=i,widthSegments:s=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:h,thetaLength:u}=e.parameters;return u===0?(t=new Mt,t.setAttribute("position",new Tt([],3))):t=new jf(.5*i,s,a,o,l,h,u*Qe.DEG2RAD),t.scale(1,r/i,n/i),Object.assign(t,{userData:{...e,type:"SphereGeometry"}})}}}),xre=F(()=>{ne(),qwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:n=8}=e.parameters,s=new Wc(t,i,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}}}),wre=F(()=>{ne(),$we=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.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(e){let{width:t,height:i,depth:r,angle:n,cornerRadius:s,cornerSegments:a}=e.parameters,o=new yre(t,i,r,n,s,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},yre=class extends Mt{constructor(e=1,t=1,i=1,r=90,n=10,s=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;n==0&&(s=1),s=Math.max(1,Math.floor(s)),n=Math.min(n,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(be=0,re=0,xe=0)=>new P(be,re,xe),p=c(),f=c(),[m,g,v]=[t/2,e/2,i/2],y=-g,_=+g,[b,x,w]=[c(y,-m,+v),c(y,-m,-v),c(y,+m,-v)],S=(be,re=!1)=>Math.sin(be-Math.PI/(+re+1)),T=(be,re=!1)=>Math.cos(be-Math.PI/(+re+1));w.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,E=b.z-h;r<=d?(w.z=Math.min(M,E),w.z==E&&(w.y-=(M-E)/Math.tan(d-r))):x.z=Math.min(x.z-M-v,b.z-h),p.subVectors(b,x),f.subVectors(w,x);let A=Math.min(p.length(),f.length())*n/100,C=A*Math.tan(r/2),D=A/Math.cos(r/2),R=p.clone().normalize().add(f.normalize()).setLength(D).add(x);p.set(0,S(r,!0),T(r,!0)),u.push([w,p.clone()]);let I=(Math.PI-r)/s;for(let be=0;be<=s;be++){let re=d+r+be*I;p.set(0,Math.sin(re)*C,Math.cos(re)*C),p.add(R),f.set(0,S(re),T(re)),u.push([p.clone(),f.clone()])}u.push([b,c(0,1,0)]);let U=Math.sin(I/2)*C*2,O=u.length-1,k=u[0][0].distanceTo(u[1][0]),G=k+U*s+u[O-1][0].distanceTo(u[O][0]);u[0].push(1);for(let be=0;be<=s;be++)u[be+1].push(1-(k+be*U)/G);u[O].push(0);let K,q,Y,[ue,de,ge]=u[0];for(let be=1;be<u.length;be++)[K,q,Y]=u[be],a.push(y,ue.y,ue.z,y,K.y,K.z,_,ue.y,ue.z,_,ue.y,ue.z,y,K.y,K.z,_,K.y,K.z),o.push(0,de.y,de.z,0,q.y,q.z,0,de.y,de.z,0,de.y,de.z,0,q.y,q.z,0,q.y,q.z),l.push(0,ge,0,Y,1,ge,1,ge,0,Y,1,Y),[ue,de,ge]=[K,q,Y];this.setAttribute("position",new Tt(a,3)),this.setAttribute("normal",new Tt(o,3)),this.setAttribute("uv",new Tt(l,2))}}}),GH=F(()=>{o0(),e0(),aK=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}=e.parameters,d=e.shape,c=.5*t,p=.5*i,f=a*Math.PI/360/n,m=Math.PI/2*3*-1,g=c*r/100,v=p*r/100;if(n===3&&r===50){f=2*Math.PI/n;for(let _=0;_<n;_++){let b=f*_,x=0+Math.sin(b)*c,w=0+Math.cos(b)*p;d.addPoint(d.createPoint(x,w))}}else for(let _=0;_<n;_++){let b=0+Math.cos(m)*c,x=0+Math.sin(m)*p;d.addPoint(d.createPoint(b,x)),m+=f,b=0+Math.cos(m)*g,x=0+Math.sin(m)*v,d.addPoint(d.createPoint(b,x)),m+=f}d.isClosed=!0;for(let _=0,b=d.points.length;_<b;_++)d.points[_].roundness=s;d.roundness=s,d.update();let y=l0.create({shape:d,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}});return Object.assign(y,{userData:{...e,type:"StarGeometry"}})}}}),Sre=F(()=>{ne(),Xwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.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(e){let{width:t,height:i}=e.parameters,r=new Wc(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}}}),Tre=F(()=>{ne(),VA(),Ywe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),n=Math.abs(i.height??i.width);i.shapeBlendNode&&(n=r);let s=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:n,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:n,tubularSegments:s,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=function(u,d,c,p,f,m,g,v,y,_,b){[d,c]=[c,d],g=d/2;let x=Qe.clamp(f/360,0,1);if(x===0){let w=new Mt;return w.setAttribute("position",new Tt([],3)),w}return x===1&&(_=0),new CH(!0,u,d,c,p,x,m,g,0,y,_,b)}(t,i,r,.5*t,a,s,0,0,n,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}}}),Mre=F(()=>{ne(),Kwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.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(e){let{width:t,tube:i,tubularSegments:r,radialSegments:n,p:s,q:a}=e.parameters,o=.5*t;o!==i&&(o-=i);let l=new vW(o,i,r,n,s,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}}}),Ere=F(()=>{o0(),e0(),Zwe=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof cs?e.shape:new cs,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(e){let{width:t=100,height:i,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,isRect:o,extrusionVersion:l}=e.parameters,h=e.shape,u=.5*t,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,f=h.points.length;p<f;p++)h.points[p].roundness=r;h.roundness=r,h.update();let c=l0.create({shape:h,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}}}),rFe=F(()=>{}),nFe=F(()=>{ne(),new ja,new De,new _f,new P,new P,new P,new P});function Are(){let e=new Mt;return e.setAttribute("position",new Pt(new Float32Array([]),3)),e.setIndex(new Pt(new Uint16Array([]),1)),e}var Cre,jH,Qwe=F(()=>{la(),Ot(),pC(),ne(),uC(),o0(),e0(),Rw(),Cre=Are().attributes,jH=class extends Mt{constructor(e,t){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,Cre),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:h,fontSize:u,extrusionVersion:d}=e,c=So.getDisplayedValue(l),p=function(w,S,T,M){let E=typeof w.width=="string"?Number(M.getVariable(w.width)):w.width,A=[""],C="";for(let D of T)C+=D,D===" "||D===`
|
|
4211
4211
|
`?(A[A.length-1]+=C,C="",D===`
|
|
4212
|
-
`&&A.push("")):S.getTextWidth(A[A.length-1]+C,w)>E&&(A[A.length-1].length&&A.push(""),S.getTextWidth(A[A.length-1]+C,w)>E&&(C.length===1?(A[A.length-1]+=C,C=""):(A[A.length-1]+=C.slice(0,-1),C=C[C.length-1],A.push(""))));return A[A.length-1]+=C,A}(e,i,h===2?c.toUpperCase():h===3?c.toLowerCase():c,t),{shapes:f,charWidths:m,charCoords:g}=i.generateShapes(p,e,t),v=.5*(typeof r=="number"?r:Number(t.getVariable(r))),y=.5*(typeof n=="number"?n:Number(t.getVariable(n))),_=f.map(w=>new cs().fromShape(w,!0));this.vectorShapes=_;let b=_.map(w=>l0.create({shape:w,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:u,extrusionVersion:d,windingRule:s<=0?is.NONZERO:is.ODD,subdivisions:this.isLowResolution&&s>0?1:12}})),x=b.length?ly(b):Are();x.translate(-v,y,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([w,S])=>{this.setAttribute(w,S)}),this.setIndex(x.index),this.adoptNearSide(b,s),this.computeBoundingSphere()}adoptNearSide(e,t){this._depth=t;let i=0,r=0,n=0;for(let o of e){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),n=l._vScale??n}this._effectiveBevel=r,this._vScale=n;let s=new Uint8Array(i),a=0;for(let o of e){let l=o._nearSide;s.set(l,a),a+=l.length}this._nearSide=s}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length===this.getAttribute("position")?.count&&dx(this._effectiveBevel,e)&&dx(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position"),r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=t,h===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=Go(new Mt,jH.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}}});function sFe(e){if(!WH)return Pre||(Pre=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.204/build",i=import("./process.js"),[r,n]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});Jwe(a),WH=!0}())}var Jwe,oK,WH,Pre,zB=F(()=>{oK=new Promise(e=>{Jwe=e}),WH=!1});function $5(e,t){if(Object.keys(e.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let i=Object.keys(e.attributes),r=Object.keys(t.attributes);if(i.length!==r.length)return!1;for(let l of r){let h=e.attributes[l],u=t.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 n=e.index,s=t.index;if(n===null!=(s===null))return!1;let a=!1;if(n!==null&&s!==null){if(n.array.length!==s.array.length)return!1;let l=n.array.constructor,h=s.array.constructor;if(l!==h){if(l!==Uint32Array||h!==Uint16Array)return!1;a=!0}}if(e.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let h=e.groups[l],u=t.groups[l];if(h.start!==u.start||h.count!==u.count||h.materialIndex!==u.materialIndex)return!1}for(let l of r){let h=e.attributes[l],u=t.attributes[l];h.array.set(u.array),h.needsUpdate=!0}let o=e.takeDepthStateFrom;if(typeof o=="function"&&o.call(e,t),n!==null&&s!==null){if(a){let l=n.array,h=s.array;for(let u=0,d=h.length;u<d;u++){let c=h[u];l[u]=c===65535?4294967295:c}}else n.array.set(s.array);n.needsUpdate=!0}return e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e.boundingBox=null,e.boundingSphere=null,!0}function HH(e,t,i,r){let n,s,a,o=e.position.array,l=e.normal.array,h=eSe.makeScale(t,i,r).invert().elements;for(let u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=i,o[u+2]*=r,n=l[u],s=l[u+1],a=l[u+2],l[u]=h[0]*n+h[4]*s+h[8]*a,l[u+1]=h[1]*n+h[5]*s+h[9]*a,l[u+2]=h[2]*n+h[6]*s+h[10]*a;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var eSe,tSe=F(()=>{ne(),eSe=new De});function qH(e){let t=Number(e);return Number.isInteger(t)&&t>=0&&String(t)===e?t:-1}function Y3(e){if(e!=null){if(Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView))return e;if(typeof e=="object")return function(t){let i=Object.keys(t),r=0;for(let s of i){let a=qH(s);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let n=new Array(r);for(let s=0;s<r;s++){let a=t[s];if(typeof a!="number")return;n[s]=a}return n}(e)}}function X5(e){if(e==null)return"missing";if(Array.isArray(e))return`Array(${e.length})`;if(ArrayBuffer.isView(e)){let l=e;return`${e.constructor.name}(${l.length})`}if(typeof e!="object")return typeof e;let t=Object.keys(e),i=t.filter(l=>qH(l)===-1),r=0;for(let l of t){let h=qH(l);h>=r&&(r=h+1)}let n=e,s=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):s===-1&&(s=l);let o=[`${t.length} keys`,"max index "+(r-1)];return s!==-1&&o.push(`first missing index ${s}`),a!==-1&&o.push(`non-number at ${a} (${typeof n[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function iSe(e){let t=Object.keys(e);return t.length===1&&t[0]==="subdivisions"}function lK(e,t){let i=t?t.count:e.count,r=0,n=1e4,s=new Map,a=new Uint32Array(i),o=[];for(let u=0;u<i;u++){let d=t?t.getX(u):u,c=e.getX(d),p=e.getY(d),f=e.getZ(d),m=Math.round(c*n),g=Math.round(p*n),v=Math.round(f*n),y=s.get(m);y===void 0&&(y=new Map,s.set(m,y));let _=y.get(g);_===void 0&&(_=new Map,y.set(g,_));let b=_.get(v);b===void 0&&(b=r++,_.set(v,b),o.push(c,p,f)),a[u]=b}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(t?t.getX(u):u,t?t.getX(u+1):u+1,t?t.getX(u+2):u+2));return{positions:o,triIndices:l,triOriginals:h}}var JS,k0,ti,Y5,K5,Z5,us,eT,K3,Z3,Q3,$H,oO,Dw=F(()=>{ne(),zB(),Ot(),kB(),tSe(),VA(),JS=new cn,k0=new P,oK.then(e=>{ti=e}),Y5=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),K5=new Uint32Array([0,1,2,3]),Z5=new Uint8Array([4]),us=class extends Mt{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=jg.div(t.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&HH(this.subdividedGeometry.attributes,...r),this.originalGeometry&&HH(this.originalGeometry.attributes,...r),this.data=e;let n=this.userData.parameters;this.userData.parameters={width:n.width*r[0],height:n.height*r[1],depth:n.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(k0.fromArray(r));let s=k0.set(n.width,n.height,n.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let t=e.phongAngle??35;this.flatShading&&(t=-1);let i=null;if(e.subdivisions>0){let n=0;try{n=us.allocate(e),i=us.buildRefined(n,e.subdivisions,t)}catch(s){console.error(s,e)}finally{n&&us.freeSubdivPointer(n)}}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 e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Dh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(us.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ja,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;JS.setFromBufferAttribute(t),JS.getCenter(i),e.boundingSphere.radius=i.distanceTo(JS.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),JS.getSize(k0);let r={width:k0.x,height:k0.y,depth:k0.z};return this.userData.parameters=r,r}static build(e,t,i,r){let n,s,a=e?.phongAngle??35;i===!1&&(a=-1),t&&(ti.free_bvh(t),ti.free_subdivision_surface(t));try{n=us.allocate(e,r)}catch(l){console.error(l,e),n=us.allocate({positionWASM:Y5,indexWASM:K5,verticesPerFaceWASM:Z5},r)}ti.set_destination_refinement_level(n,0);let o=us.buildLevel(n,!0,a);return s=e.subdivisions>0?us.buildRefined(n,e.subdivisions,a):null,{subdivPointer:n,originalGeometry:o,subdividedGeometry:s}}static buildRefined(e,t,i){try{return ti.set_destination_refinement_level(e,t),us.buildLevel(e,!1,i)??null}catch{try{return ti.set_destination_refinement_level(e,t-1),us.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r,n=e.shape!==void 0||e.path!==void 0?t.geometry:Fg(e,i,!1,t);r=jxe(e)?n.getClosedTorusIndicesForBooleanOrSubdiv():n.getIndex();let s,{positions:a,triIndices:o,triOriginals:l}=lK(n.getAttribute("position"),r);if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2;s=[c,c+3*e.radialSegments]}let{indices:h,verticesPerFace:u,uvs:d}=function(c,p,f,m,g){let v=[],y=[],_=g?f.getAttribute("uv"):void 0,b=_&&_.itemSize===2?[]:void 0,x=T=>{if(b){let M=g[T];b.push(_.getX(M),_.getY(M))}};if(f.userData.shape!==void 0&&f.userData.parameters.depth===0&&f.userData.shape.shapeHoles.length===0){let T=f.userData.shape.extractShapePointsToFlatArray([]),M=f.userData.parameters.spikes;if(f.userData.type==="EllipseGeometry"&&M<=24&&M%4==0&&f.userData.parameters.angle>=360){let C=T.length/2/M;T=T.filter((D,R)=>Math.floor(R/2)%C===0)}let E=0;for(let C=0;C<T.length;C+=2)E+=(T[C]-T[(C===0?T.length:C)-2])*(T[C+1]+T[(C===0?T.length:C)-1]);c.length=0;let A=0;if(E<0)for(let C=0;C<T.length;C+=2)c.push(T[C],T[C+1],0),v.push(A++);else for(let C=T.length-2;C>=0;C-=2)c.push(T[C],T[C+1],0),v.push(A++);return y.push(A),{indices:v,verticesPerFace:y}}let w=new Float32Array([f.userData.parameters.depth])[0],S=0;for(;S<p.length;){if(f.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[S]+2]===w||c[3*p[S]+2]===0)&&T++,(c[3*p[S+1]+2]===w||c[3*p[S+1]+2]===0)&&T++,(c[3*p[S+2]+2]===w||c[3*p[S+2]+2]===0)&&T++,T===3)break}if(p[S+1]===p[S+3]&&p[S+2]===p[S+5]||p[S+0]===p[S+3]&&p[S+2]===p[S+4]){eT.set(c[3*p[S]],c[3*p[S]+1],c[3*p[S]+2]),K3.set(c[3*p[S+1]],c[3*p[S+1]+1],c[3*p[S+1]+2]),Z3.set(c[3*p[S+4]],c[3*p[S+4]+1],c[3*p[S+4]+2]),Q3.set(c[3*p[S+5]],c[3*p[S+5]+1],c[3*p[S+5]+2]),K3.sub(eT).normalize(),Z3.sub(eT).normalize(),Q3.sub(eT).normalize();let T=K3.cross(Z3).dot(Q3),M=S;Math.abs(T)>.005||m&&m.some((E,A)=>A%2!=1&&M>=m[A]&&M<m[A+1])?(v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3):(v.push(p[S],p[S+1],p[S+4],p[S+5]),x(S),x(S+1),x(S+4),x(S+5),y.push(4),S+=6)}else v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3}if(f.useNgonForTopBottomFaceDuringBake){let T=[],M=[],E=0;for(let A=0,C=0;A<c.length;A+=3,C++)c[A+2]===0&&(T.push(C),E++),c[A+2]===w&&M.push(C);if(f.userData.parameters.extrudeBevelSize===0){let A=M[0];M[0]=M[1],M[1]=A}T.reverse(),v.push(...T,...M),y.push(E,E),b=void 0}return{indices:v,verticesPerFace:y,uvs:b}}(a,o,n,s,l);return{positions:a,indices:h,verticesPerFace:u,uvs:d}}static allocate(e,t){let i,r,n,s=[],a=[],o=Y3(e.positionWASM),l=Y3(e.indexWASM),h=Y3(e.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!h?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${X5(e.positionWASM)}, indexWASM ${X5(e.indexWASM)}, verticesPerFaceWASM ${X5(e.verticesPerFaceWASM)}`);i=o,r=l,n=h;let S=Y3(e.uvWASM);ti.alloc_subdivision_surface_uvs&&S&&S.length===2*r.length&&(a=S)}else i=Y5,r=K5,n=Z5;let u=i.length,d=r.length,c=n.length,p=i.length+s.length+a.length,f=r.length+n.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,v=ti._malloc(m);if(!v)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${m}) failed`);let y,_=new Float32Array(ti.HEAPF32.buffer,v,p),b=new Uint32Array(ti.HEAPU32.buffer,v+g,f);_.set(i,0),_.set(s,i.length),_.set(a,i.length+s.length),b.set(r,0),b.set(n,r.length),e?.scaleBaked?.some(S=>S!==1)&&(y=new De().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),t&&(y?y.premultiply(t):y=t);let x=v+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,w=a.length?y?ti.alloc_subdivision_surface_uvs2(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,y.elements):ti.alloc_subdivision_surface_uvs(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):y?ti.alloc_subdivision_surface2(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,y.elements):ti.alloc_subdivision_surface(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return ti._free(v),w}static buildLevel(e,t,i,r,n,s=!1){let a=n?ti.get_mesh_data2(e,t?ti.Level.CONTROL:ti.Level.REFINED,i,n.elements):ti.get_mesh_data(e,t?ti.Level.CONTROL:ti.Level.REFINED,i),o=ti.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),h=0,u=ti.HEAPU32[o[h]>>2],d=ti.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=ti.HEAPU32[o[h]>>2],p=ti.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let f=ti.HEAPU32[o[h]>>2],m=ti.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g,v=ti.HEAPU32[o[h]>>2],y=ti.HEAPU32.subarray(v>>2,(v>>2)+l[h]);if(h++,ti.alloc_subdivision_surface_uvs){let b=o[9];if(b>0){let x=ti.HEAPU32[o[8]>>2];g=ti.HEAPF32.subarray(x>>2,(x>>2)+b)}}if(r===void 0){let b=new Mt;if(b.setIndex(new Gf(y,1)),b.setAttribute("position",new Tt(d,3)),b.setAttribute("normal",new Tt(p,3)),g&&b.setAttribute("uv",new Tt(g,2)),t){b.setAttribute("faceMap",new Gf(m,1));let x=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Pt(x,4))}return ti.free_mesh_data(a),b.userData.type="SubdivGeometry",b}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,s){let b=r.getIndex();b!==null&&b.array.length===y.length&&(b.copyArray(y),b.needsUpdate=!0)}let _=r.getAttribute("uv");g&&_&&_.array.length===g.length&&(_.copyArray(g),_.needsUpdate=!0),ti.free_mesh_data(a)}static freeSubdivPointer(e){ti.free_bvh(e),ti.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ti.get_wireframe_data_for_base_level(e),n=ti.HEAPU32.subarray(r>>2,4+(r>>2)),s=n.subarray(2,4),a=0,o=ti.HEAPU32[n[a]>>2],l=ti.HEAPF32.subarray(o>>2,(o>>2)+s[a]);a++;let h=ti.HEAPU32[n[a]>>2],u=ti.HEAPU32.subarray(h>>2,(h>>2)+s[a]);if(t===void 0){let d=new Mt;d.setAttribute("position",new Tt(l,3));let c=new Float32Array(l.length);for(let p=0,f=l.length;p<f;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new Pt(c,3)),d.setIndex(new Gf(u,1)),ti.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(l),t.attributes.position.needsUpdate=!0,ti.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ti.set_destination_refinement_level(e,t);let n=i?ti.get_topological_data2(e,r?ti.Level.CONTROL:ti.Level.REFINED,i.elements):ti.get_topological_data(e,r?ti.Level.CONTROL:ti.Level.REFINED),s=ti.HEAPU32.subarray(n>>2,8+(n>>2)),a=s.subarray(3,6),o=0,l=ti.HEAPU32[s[o]>>2],h=new Float32Array(ti.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=ti.HEAPU32[s[o]>>2],d=new Uint32Array(ti.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let c,p=ti.HEAPU32[s[o]>>2],f=new Uint8Array(ti.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(ti.alloc_subdivision_surface_uvs){let m=s[7];if(m>0){let g=ti.HEAPU32[s[6]>>2];c=new Float32Array(ti.HEAPF32.subarray(g>>2,(g>>2)+m))}}return ti.free_topological_data(n),{positions:h,indices:d,verticesPerFace:f,uvs:c}}},eT=new P,K3=new P,Z3=new P,Q3=new P}),rSe=F(()=>{$ie(),Xie(),l4(),Yie(),c4(),VA(),fre(),mre(),gre(),VH(),_re(),p4(),bre(),xre(),wre(),GH(),Sre(),Tre(),Mre(),Ere(),e0(),vr(),$ie(),Xie(),l4(),Yie(),c4(),rFe(),VA(),fre(),mre(),gre(),VH(),_re(),p4(),bre(),xre(),wre(),GH(),Sre(),Tre(),Mre(),Ere(),e0(),nFe(),Pwe(),Qwe(),Dw(),zB(),LB(),Rw(),$H={ConeGeometry:uwe,CubeGeometry:dwe,CylinderGeometry:JY,DodecahedronGeometry:cwe,EllipseGeometry:FB,HelixGeometry:Wxe,IcosahedronGeometry:Uwe,LatheGeometry:zwe,NonParametricGeometry:Vwe,PolygonGeometry:sK,PyramidGeometry:Gwe,RectangleGeometry:UB,SphereGeometry:Hwe,PlaneGeometry:qwe,BackdropGeometry:$we,StarGeometry:aK,TextFrameGeometry:Xwe,TorusGeometry:Ywe,TorusKnotGeometry:Kwe,TriangleGeometry:Zwe,VectorGeometry:l0},oO=e=>{let t=$H[e.type]??Ixe(e.type);if(t===void 0)throw new Error(`No geometry factory registered for "${e.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(e)}});function Fg(e,t,i,r){let n,s,a;e.type==="PathGeometry"?(s={...e,extrusion:{...e.extrusion}},a=[[],["extrusion"]]):(s={...e},a=[[]]);for(let h of a){let u=s;for(let d of h)u=u[d];for(n in u){let d=u[n];eH(d)&&!nSe.includes(n)&&(u[n]=t.getVariable(d,[r.uuid,"geometry",...h,n]),eH(u[n])&&(u[n]=1))}}let o,l={parameters:s,type:s.type};if(s.type==="PathGeometry"){l.path=s.path;let h=r.profileShape;h!==void 0&&(l.shapeData=h),l.ownerId=r.uuid}else if(s.type==="VectorGeometry"){let h=cs.createFromState(s.shape,s.width,s.height);l.shape=h,l.ownerId=r.uuid}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),l.geometry=new sY().parse(s),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(s.type==="SubdivGeometry"){let h=new us(s,i);return h.data=e,h}if(s.type==="TextGeometry"||s.type==="InputGeometry"){let h=Ixe(s.type);if(h)return h.create(s,t);Ta("text",`a ${s.type}`);let u=cs.createFromState(hw.defaultData(),100,100);return oO({...s,shape:u,type:"VectorGeometry"})}if(s.type==="UIGeometry")return UB.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}try{o=oO(l)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${l}`);let u=cs.createFromState(hw.defaultData(),100,100);l.shape=u,l.type="VectorGeometry",o=oO(l)}return o}var nSe,kB=F(()=>{Ot(),ne(),rSe(),vr(),p4(),o0(),Dw(),nSe=["font"]});function XH(e){switch(typeof e){case"number":return Number.isFinite(e)?JSON.stringify(e):void 0;case"boolean":return JSON.stringify(e);case"string":return eH(e)?void 0:JSON.stringify(e);case"object":{if(e===null)return"null";if(Array.isArray(e)){let n="[";for(let s=0;s<e.length;s++){let a=XH(e[s]);if(a===void 0)return;n+=(s>0?",":"")+a}return n+"]"}let t=e,i="{",r=!0;for(let n of Object.keys(t).sort()){if(t[n]===void 0)continue;let s=XH(t[n]);if(s===void 0)return;i+=`${r?"":","}${JSON.stringify(n)}:${s}`,r=!1}return i+"}"}default:return}}var sSe,Rre,YH,aFe=F(()=>{Ot(),sSe=new Set(["CubeGeometry","SphereGeometry","CylinderGeometry","ConeGeometry","TorusGeometry","TorusKnotGeometry","IcosahedronGeometry","DodecahedronGeometry","PyramidGeometry","PlaneGeometry","BackdropGeometry","HelixGeometry"])}),oFe=F(()=>{kB(),aFe(),Rre=class{constructor(){this.objects=new Map,this.refs=new Map,this.sharedByKey=new WeakSet,this.unreachable=new Set}resolveObject(e,t,i){return this.createObject(e,t,i)}onObjectDisposed(e){}getCached(e){return this.objects.get(e)}get size(){return this.objects.size}get(e,t,i){let r=this.objects.get(e);return r===void 0?(r=this.resolveObject(e,t,i),this.objects.set(e,r),this.retain(r)):(this.sharedByKey.add(r),r.isShared=!0),r}forceDelete(e){let t=this.objects.get(e);t&&(this.objects.delete(e),this.release(t))}adopt(e,t){this.replace(e,t),this.retain(t)}mutateIfUnique(e,t){let i=this.objects.get(e);if(i&&i.isShared!==!0)return this.objects.delete(e),this.replace(t,i),i}replace(e,t){let i=this.objects.get(e);this.objects.set(e,t),i!==void 0&&i!==t&&this.release(i)}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(e,t){t===this.objects.get(e)&&this.unreachable.delete(e)}endGc(){this.unreachable.forEach(e=>{let t=this.objects.get(e);this.objects.delete(e),this.release(t)}),this.unreachable.clear()}dispose(){new Set(this.objects.values()).forEach(e=>{this.disposeObject(e),this.onObjectDisposed(e)}),this.objects.clear(),this.refs.clear()}retain(e){let t=(this.refs.get(e)??0)+1;this.refs.set(e,t),t>1&&(e.isShared=!0)}release(e){let t=(this.refs.get(e)??1)-1;if(t>0)return this.refs.set(e,t),void(t===1&&!this.sharedByKey.has(e)&&(e.isShared=!1));this.refs.delete(e),this.disposeObject(e),this.onObjectDisposed(e)}},YH=class extends Rre{constructor(e){super(),this.flatShading=e,this.dedupeByValue=!1,this.byValue=new Map,this.valueKeyOf=new Map}disposeObject(e){e.dispose()}createObject(e,t,i){let r=Fg(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}resolveObject(e,t,i){let r=this.dedupeByValue?function(s,a,o){if(!sSe.has(s.type))return;let l=s;if(l.shapeBlendNode!=null||o.isTransientGeometryKey(s))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=s.type;for(let c of Object.keys(l).sort()){let p=l[c];if(p===void 0||c==="type")continue;let f=XH(p);if(f===void 0)return;d+=`|${c}=${f}`}return d}(e,i,t):void 0;if(r!==void 0){let s=this.byValue.get(r);if(s!==void 0)return s}let n=this.createObject(e,t,i);return r!==void 0&&(this.byValue.set(r,n),this.valueKeyOf.set(n,r)),n}mutateIfUnique(e,t){let i=super.mutateIfUnique(e,t);return i!==void 0&&this.forgetValue(i),i}onObjectDisposed(e){this.forgetValue(e)}forgetValue(e){let t=this.valueKeyOf.get(e);t!==void 0&&(this.valueKeyOf.delete(e),this.byValue.get(t)===e&&this.byValue.delete(t))}}});function f4(){return mC}function aSe(){if(mC==="webgpu"){if(ZH!==void 0)return ZH;JH||(JH=!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(QH===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 QH}function oSe(e,t){return aSe().createRootMaterial(e,t)}function Dre(e,t,i){return aSe().createSharedMaterial(e,t,i)}function Nre(e){return e.getLayersOfType===void 0&&Object.assign(e,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),e}function KH(){return hSe}var mC,ZH,QH,JH,eq,lSe,hSe,tq,uSe,Qf=F(()=>{mC="webgl",JH=!1}),lFe=F(()=>{uSe={markNeedsUpdateRendererDirty:()=>{}}});function Ire(e){return e.data.type!=="displace"&&!!e.data.isMask}function vu(e,t){let i=0;if(!e.layers||e.layers.length===0)return!1;let r=e.layers?.find(s=>s.data.type==="light");if(r){let s=r.data,a=Number(t.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?a/100:s.alphaOverride)<1)return!0}let n=e.layers;for(let s=0;s<n.length;s++){let a=n[s];if(!Ire(a)){if(s>0&&Ire(n[s-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(t.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=t.color(a.data.colorA).a,h=t.color(a.data.colorB).a,u=t.color(a.data.colorC).a,d=t.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 gC=F(()=>{});function dSe(e,t){return e==="displace"?t==="intensity":t==="alpha"}function cSe(e,t,i){let r=e==="alpha"?Math.max(0,Math.min(Number(t)/100,1)):Number(t);return i?r:0}function Hf(e){return typeof e=="string"||typeof e=="number"&&e!==0}var Ih,Nt,Hc,wd,Nw,hK,Ore,Lre,Ko,Md=F(()=>{ne(),Ih=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?100*e:e,i)??100)/100))??1,Nt=(e,t,i)=>typeof e=="number"?e:t.getVariable(e,i),Hc=(e,t)=>(e||(e=new P),e.x=Nt(e.x,t)??0,e.y=Nt(e.y,t)??0,e.z=Nt(e.z,t)??0,e),wd=(e,t)=>(e||(e=new Z),e.x=Nt(e.x,t)??0,e.y=Nt(e.y,t)??0,e),Nw={noise:["noiseType"],texture:["projection","axis","projectionAxis","uvChannel","side"],video:["projection","axis","projectionAxis","uvChannel","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"]},hK={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),Iw=F(()=>{ne(),Pw(),Yn(),Ore=class extends NB(ln){},Lre=e=>e.type==="Mesh",Ko=class extends Ore{constructor(e){super(),this.object=e,this.isClone=!0,this.matrixAutoUpdate=!1}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];(!(i instanceof Ko)||i.object!==t)&&(i=new Ko(t),this._replaceChildAt(e,i),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.shearMatrix=t.shearMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(let i of this.object.children){if(!Lg(i)||i.object.parent!==this.object)continue;let r=this.children[e];r?.source!==i&&(r=i.createCopy(),this._replaceChildAt(e,r)),r.expand(),e+=1}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}_replaceChildAt(e,t){let i=this.children[e];i&&this.remove(i),this.add(t),this.children.splice(e,0,this.children.pop())}get visible(){let e=this.parent,t=Lg(e)&&e.object===this.object;return(!t||!e.instancingActive&&!e.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||t&&this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return Lre(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}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(e){}}});function Bre(){return uK}var uK,dK,cK=F(()=>{uK=null,dK=null});function iq(e){return"variable_"+e}var Q5,J5,ez,Fre,tz,Ure,iz,zre,m4,pK=F(()=>{Ot(),twe(),awe(),BB(),xu(),KY(),QY(),oFe(),Qf(),rwe(),lFe(),gC(),Md(),bl(),Iw(),Ir(),ne(),cK(),vr(),Q5=new De,J5=new P,ez=new Vt,Fre=new P,tz=new Rr,Ure=class extends Qxe{constructor(e){super(),this.shared=e}create(e){return new YY(e,this.shared)}},iz=new Set,(m4=zre=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new YH(!0),this.geometryCache2=new YH(!1),this.imageHolderCache=new Ure(this),this.thisContext={scene:uSe,shared:this},this.deletedImage=new Pc(HL.emptyImage,this),this.deletedVideo=new Pc(qL.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,t.images)for(let[n,s]of Object.entries(t.images))this.addImage(n,s);if(t.videos)for(let[n,s]of Object.entries(t.videos))this.addVideo(n,s);if(t.audios)for(let[n,s]of Object.entries(t.audios))this.addAudio(n,s);if(t.particles)for(let[n,s]of Object.entries(t.particles))this.addParticle(n,s);this.reset(e)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=Dre(Un.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:r,data:n}of e.variables)this.addVariableHolder(r,n),t&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(e.userAPIs??{}))this.addUserAPI(r,n);for(let[r,n]of Object.entries(e.userWebhooks??{}))this.addUserWebhook(r,n);if(!i){for(let[r,n]of Object.entries(e.images))this.addImage(r,n);for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n)}for(let[r,n]of Object.entries(e.colors))this.addColor(r,n);for(let[r,n]of Object.entries(e.lib.materials))this.addMaterial(r,n.asset);for(let[r,n]of Object.entries(e.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(e.particles))this.addParticle(r,n);for(let[r,n]of Object.entries(e.fonts))this.addFont(r,n)}addMaterial(e,t){if(t=Un.withRepairedLayers(t),this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=Dre(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):e==null?(console.error("material is undefined or null"),this.deletedMaterial):oSe(Un.withRepairedLayers(e),this.thisContext)}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new Pc(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new Pc(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}getEntityTexture(e,t={}){let i=e.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let n=r.root??r;for(let s of n?.data?.layers??[]){let a=s?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||t.layer!==void 0&&s.id!==t.layer&&a.type!==t.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:s.id,layerType:a.type}}}return null}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new Pc(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return typeof e=="string"?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):(this.colors[e]=new WA(t.r,t.g,t.b,"a"in t?t.a:1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if(typeof e!="string")return new Ur(e.r,e.g,e.b,"a"in e?e.a:1);{let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Ur(0,0,0,0))}return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof ux)return t;{let i=new ux({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof ux&&t.dispose(),delete this.audios[e])}addFont(e,t){let i=ZY;i!==null?(this.fonts[e]=new i(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())):Ta("text","a font asset")}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof ux&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(this.variables[e]===void 0){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(iq(e));i=r!==null?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)this.variables[e].dynamicVariablePlayState!==void 0&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(this.variables[e]===void 0)return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(iq(e),JSON.stringify(t));let i=t;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,n=!1;for(let s=this.variables[e].locations.length-1;s>=0;s--){let a=this.variables[e].locations[s];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[e].locations.splice(s,1);continue}if(n=!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*Qe.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),tr.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 n&&r.markShadowsDirty(),this.requestRender(),!0}isTransientGeometryKey(e){return this.transientGeometryKeys.has(e)}updateEntityGeometryParams(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||typeof n.type!="string"||n.type==="VectorGeometry"||n.type==="PathGeometry")return!1;let s=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let h of Object.keys(n))a.set(s(h),h);let o={};for(let[h,u]of Object.entries(t??{})){let d=a.get(s(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=n[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={...n,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(n)&&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(e){let t=e;if(t.component&&(t=t.component),typeof t.chooseGeoemtryCache!="function")return!1;let i=t.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(t.dataPatched=t.data,t.chooseGeoemtryCache(this).forceDelete(i),t.createGeometryDelayed(this.entityOpContext),t.onVariableUpdate(!0),t.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||n.type!=="NonParametricGeometry")return!1;let s=t?.vertices;if(s===void 0||typeof s.length!="number"||s.length<9||s.length%3!=0||s.length/3>zre.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,h=s instanceof Float32Array?s:Float32Array.from(s),u=h.length/3;if(t.normals!==void 0){if(t.normals.length!==h.length)return!1;a=t.normals instanceof Float32Array?t.normals:Float32Array.from(t.normals)}if(t.uvs!==void 0){if(t.uvs.length!==2*u)return!1;o=t.uvs instanceof Float32Array?t.uvs:Float32Array.from(t.uvs)}if(t.indices!==void 0){let x=u>65535?Uint32Array.from(t.indices):Uint16Array.from(t.indices);if(x.length===0||x.length%3!=0)return!1;for(let w=0;w<x.length;w++)if(x[w]>=u)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=n.data,w=x?.index;if(w?.array?.length){let S=(x?.attributes?.position?.array?.length??0)/3;if(u!==S)return function(T,M){let E=`${T}/${M}`;iz.has(E)||(iz.add(E),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${M}. 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,S),!1;l=w}}let d=1/0,c=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;for(let x=0;x<h.length;x+=3){let w=h[x],S=h[x+1],T=h[x+2];w<d&&(d=w),w>f&&(f=w),S<c&&(c=S),S>m&&(m=S),T<p&&(p=T),T>g&&(g=T)}let v=(x,w)=>({array:x,itemSize:w,type:"Float32Array",normalized:!1}),y={position:v(h,3)};a&&(y.normal=v(a,3)),o&&(y.uv=v(o,2));let _={...n,width:f-d,height:m-c,depth:g-p,data:{attributes:y,...l?{index:l}:{}}},b=this.transientGeometryKeys.has(n);return i.dataPatched={...r,geometry:_},this.transientGeometryKeys.add(_),i.applyTransientGeometryData(this.entityOpContext,b),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(e,t){let i=e;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let n=r.children,s=Math.PI/180,a=!1;if(t===null)for(let o of n)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(t))return n.length;{let o=Math.min(t.length,n.length);for(let l=0;l<o;l++){let h=t[l],u=n[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*s),typeof h.rotation.y=="number"&&(d.rotation[1]=h.rotation.y*s),typeof h.rotation.z=="number"&&(d.rotation[2]=h.rotation.z*s)),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(),n.length}spawnRuntimeClone(e,t={}){if(typeof e.entityChildren!="function")return;let i=e.parent;if(i===null)return;let r=new Ko(e);r.playModeVisible=t.visible!==!1,r.expand(),typeof t.name=="string"&&(r.name=t.name);let n=Math.PI/180;return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),r.shearMatrix.copy(e.shearMatrix),t.position&&(typeof t.position.x=="number"&&(r.position.x=t.position.x),typeof t.position.y=="number"&&(r.position.y=t.position.y),typeof t.position.z=="number"&&(r.position.z=t.position.z)),t.rotation&&(typeof t.rotation.x=="number"&&(r.rotation.x=t.rotation.x*n),typeof t.rotation.y=="number"&&(r.rotation.y=t.rotation.y*n),typeof t.rotation.z=="number"&&(r.rotation.z=t.rotation.z*n)),t.scale&&(typeof t.scale.x=="number"&&(r.scale.x=t.scale.x),typeof t.scale.y=="number"&&(r.scale.y=t.scale.y),typeof t.scale.z=="number"&&(r.scale.z=t.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(e){e.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(e,t){let i=e.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 n={scene:this.entityOpContext.scene,shared:this},s=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=h=>{if(typeof h=="string"){let u=new Ur(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 WA?h.setValue(u,new Ur(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(t.color!==void 0){let c=a(t.color),p=u.find(m=>m.data.type==="color"),f=p&&d(p.id);if(c&&f&&o(f,"color",c)&&(l=!0,c.a!==void 0)){let m=c.a<1||vu(h.data,this);h.setTransparent?h.setTransparent(m,n.scene):h.transparent=m}}typeof t.alpha=="number"&&isFinite(t.alpha)&&(h.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(t.alpha,100)),n),l=!0);for(let c of t.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?u.find(v=>v.id===c.id):typeof c.index=="number"?u[c.index]:typeof c.type=="string"?u.find(v=>v.data.type===c.type):void 0,f=p&&d(p.id);if(!p||!f)continue;let m=Nw[p.data.type]??[],g=Object.keys(p.data);for(let[v,y]of Object.entries(c)){if(v==="id"||v==="index"||v==="type")continue;let _=g.find(x=>x===v)??g.find(x=>s(x)===s(v))??v;if(m.includes(_))continue;let b=a(y);if(b&&o(f,_,b))l=!0;else if(typeof y=="number"&&isFinite(y))h.onVariableUpdate?.(["layer",p.id,_],y,n),l=!0;else if(Array.isArray(y)&&y.length<=3&&y.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];y.forEach((w,S)=>{h.onVariableUpdate?.(["layer",p.id,_,x[S]],w,n)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(e){this.variables[e]&&delete this.variables[e]}referencesMissingObject(e){return Array.isArray(e)&&e[0]!=="mouse"&&e[0]!=="raycast"&&this.entityOpContext.scene.find(e[0])===void 0}getVariable(e,t){if(Array.isArray(e)){if(e[0]==="mouse")return this.mouseProperty?.[e[1]]??0;if(e[0]==="raycast")return this.raycastProperty?.[e[1]]??0;let i=this.entityOpContext.scene.find(e[0]);if(i===void 0)return;if(e[1]==="width"||e[1]==="height"||e[1]==="depth")return i.geometry.userData.parameters[e[1]];if((e[1]==="position"||e[1]==="rotation")&&e.length>2&&i?.getPhysicsLocalMatrix?.(Q5))return Q5.decompose(J5,ez,Fre),e[1]==="position"?J5[e[2]]:(tz.setFromQuaternion(ez,i.rotation.order),tz[e[2]]*Qe.RAD2DEG);for(let r=1;r<e.length;r++)i=i[e[r]];return e[1]==="rotation"&&(i*=Qe.RAD2DEG),i}for(let i in this.variables){if(t===void 0)break;let r=this.variables[i],n=r.locations?.findIndex(s=>Sa.equal(s,t));n!==void 0&&n!==-1&&r.locations.splice(n,1)}if(typeof e=="string"){let i=e,r=e;do{if(r=i,this.variables[i]===void 0)break;let n=this.variables[i].value;t&&this.variables[r]!==void 0&&this.variables[r].locations.push(t),i=n}while(typeof i=="string");return i}return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){return this.variables[e]?.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){return this.variables[e]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){e.path[0]==="images"?e.path.length===1&&e.type===1?this.addImage(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteImage(e.id):e.path[0]==="videos"?e.path.length===1&&e.type===1?this.addVideo(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVideo(e.id):e.path[0]==="audios"?e.path.length===1&&e.type===1?this.addAudio(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteAudio(e.id):e.path[0]==="particles"?e.path.length===1&&e.type===1?this.addParticle(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteParticle(e.id):e.path[0]==="colors"?e.path.length===1&&e.type===1?this.addColor(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteColor(e.id):e.path[0]==="materials"?e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteMaterial(e.id):e.path[0]==="fonts"?e.path.length===1&&e.type===1?this.addFont(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteFont(e.id):e.path[0]==="variables"?e.path.length===1&&e.type===1?this.addVariableHolder(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVariable(e.id):e.path[0]==="components"&&t.updateByLibOp(e,this)}updateByOp(e,t,i){if(this.data=t,e.path[0]==="images")e.path.length===2&&e.type===0?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addImage(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteImage(e.id);else if(e.path[0]==="videos")e.path.length===2&&e.type===0?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addVideo(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteVideo(e.id);else if(e.path[0]==="audios")e.path.length===2&&e.type===0?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):e.path.length===1&&e.type===1?this.addAudio(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteAudio(e.id);else if(e.path[0]==="particles")e.path.length===2&&e.type===0?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):e.path.length===1&&e.type===1?this.addParticle(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteParticle(e.id);else if(e.path[0]==="colors")e.path.length===2&&e.type===0?this.updateColor(e.path[1],e.props):e.path.length===1&&e.type===1?this.addColor(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteColor(e.id);else if(e.path[0]==="materials")e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data):e.path.length===1&&e.type===2?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(Ha.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if(e.path[0]==="fonts")e.path.length===2&&e.type===0?this.updateFont(e.path[1],e,i):e.path.length===1&&e.type===1?this.addFont(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteFont(e.id);else if(e.path[0]==="variables")e.path.length===2&&e.type===0?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):e.path.length===1&&e.type===4?this.addVariableHolder(e.id,e.data):e.path.length===1&&e.type===5&&this.deleteVariable(e.id);else if(e.path[0]==="userAPIs"){if(e.path.length===1&&e.type===1)this.addUserAPI(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserAPI(e.id);else if(typeof e.path[1]=="string"){let r=t.userAPIs[e.path[1]];if(r){let n=e.type===0&&e.props.debounce===void 0,s=this.getUserAPI(e.path[1]);s!==void 0&&s===this.openAIRealtime?s.update(r):s?.update(r,this,n)}}}else if(e.path[0]==="userWebhooks"){if(e.path.length===1&&e.type===1)this.addUserWebhook(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserWebhook(e.id);else if(typeof e.path[1]=="string"){let r=t.userWebhooks[e.path[1]];r&&this.getUserWebhook(e.path[1])?.update(r)}}else e.path[0]==="lib"&&this.updateLibByOp(Ha.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),n={...this.data.fonts[e],url:t.props.url};r.update(n),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){if(this.userAPIs[e])return this.userAPIs[e].update(t,this),!0;if(this.openAIRealtime?.id===e)return this.openAIRealtime.update(t),!0;if(t.integration?.type==="VoiceAssistant"){let i=dK;return i===null?(Ta("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(t,e,this),!1)}{let i=Bre();return i===null?(Ta("api-services","a user API integration"),!1):(this.userAPIs[e]=i.createUserAPI(e,t,this),!1)}}getUserAPI(e){return this.openAIRealtime?.id===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){if(this.userWebhooks[e])return this.userWebhooks[e].update(t),!0;{let i=Bre();return i===null?(Ta("api-services","a user webhook"),!1):(this.userWebhooks[e]=i.createUserWebhook(e,t),!1)}}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new m4(fu.emptyData())});function g4(e){return Xxe(e)||e?.isTSLNodeMaterial===!0}function kre(e){return function(t){return t?.isClassicSharedMaterial===!0}(e)||e?.isTSLSharedMaterial===!0}function pSe(e){let t=e?.root;return kre(e)||t!==void 0&&kre(t)}var _l,rz,nz,sz,Vre,az,hp,Gre,jre,tT,wn,fK=F(()=>{ewe()}),v1=F(()=>{Ot(),Da(),Qf(),fK(),Ir(),la(),_l=class extends Fs{setMaterialOverride(e,t){this.materialOverride=Nre(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),t.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),Zr(e.path,["geometry"])&&this.syncShadowCatcher(i),function(r,n){let s=[];if(n.length!==r.length)return null;{let a=0;for(;a<r.length;){if(n[a]==="*")s.push(r[a]);else if(r[a]!==n[a])return null;a+=1}}return s}(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[r,n]of Object.entries(e.props)){let s=this.material[Number(r)],a=i.shared.material(n);a!==s&&_l.disposeOneMaterial(s),this.material[Number(r)]=a}else if(Zr(e.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in t&&typeof t.material!="string"&&r.updateByOp(Ha.drop(e,1),t.material,i)}else if(Zr(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&r<this.material.length){let n=t.materials[r];typeof n!="string"&&this.material[r].updateByOp(Ha.drop(e,2),n,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(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.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 n=this.materialOverride!==void 0;!n&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe,i),t.scene.markNeedsUpdateRendererDirty()),!n&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(a=>t.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe)],t.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!n&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(s.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!n&&(e.flatShading!==void 0||e.wireframe!==void 0||e.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(t)}shadowCatcherActive(){let e=this.dataPatched,t=e.geometry?.type;return e.shadowCatcher===!0&&(t==="RectangleGeometry"||t==="PlaneGeometry")}syncShadowCatcher(e){let t=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=mC==="webgpu"&&eq!==void 0?eq:lSe;return r===void 0?null:Nre(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=t.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.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,e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.material=e.shared.material(t.material).getFlavor(t.flatShading,t.side,t.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow)}static disposeOneMaterial(e){g4(e)&&!pSe(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&rbe(this.material).forEach(e=>{_l.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),xl=F(()=>{Ot(),Ir(),pK(),v1(),ne(),kB(),Rw(),Dw(),tSe(),rz=new P,nz=new ut,sz=new ut,Vre=new P,az=new De,hp=new Sr,Gre=hp.geometry,jre=hp.material,tT=new P,wn=class extends _l{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new De().fromArray(t.bindMatrix),this.bindMatrixInverse=new De)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Mt&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof Mt?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof m4){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=t.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return YL.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return YL.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Zr(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Ha.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var e;super.dispose(),e=this.uuid,d4.delete(e),this._posed=void 0}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(e!==void 0&&e.sxPrev!==void 0)return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,n,s,a=e;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=Fg(d,t,this.data.flatShading,this)}a.scaleBaked?[r,n,s]=a.scaleBaked:{width:r,height:n,depth:s}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,h=typeof n=="number"?n:1,u=typeof s=="number"?s:1;o.sxPrev!==void 0&&HH(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(e)){let r=Fg(i==="VectorGeometry"?KL.merge(this.data.geometry,e):{...this.data.geometry,...e},t,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&$5(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(e){let t=this.localGeometry;if(t?.shiftDepthTo===void 0)return!1;let i=e;if(typeof i.depth!="number")return!1;let r=t.userData?.parameters;if(r===void 0)return!1;for(let n of Object.keys(i))if(n!=="depth"&&i[n]!==r[n])return!1;return!!t.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(e){for(let t of this.attachedSurfaceCloners)t.update(e)}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){let r=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&iSe(e.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(t),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof Mt&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=i.shared,s=this.chooseGeoemtryCache(n),a=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=Fg(o,n,this.data.flatShading,this);$5(a,l)?(l.dispose(),a.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.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(e,t){this.createGeometryDelayed(t)}applyTransientGeometryData(e,t){let i=e.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof Mt&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let a=Fg(r,i,this.data.flatShading,this);return $5(s,a)?(a.dispose(),s.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(e),void this.refreshAttachedPaths(e)}}t&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:n}}of i)this.updateMorphInfluences(r,t.shared.getVariable(n,[this.uuid,"morphTargetInfluences",r]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=t)}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(e,t){let i=this.posedGeometry()?.boundingBox;if(i)return i.getCenter(e),void i.getSize(t).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,.5*r.depth):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?e.fromArray(r.centerOffset):e.setScalar(0),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}rebindSkeleton(e){let t=this.dataPatched,i=t.bones?.map(e),r=this.isSkinnedMesh;if(!i?.length||i.some(n=>!n)||t.boneInverses?.length!==i.length?this.isSkinnedMesh=!1:(this.bindMatrix||(this.bindMatrix=new De,this.bindMatrixInverse=new De),this.bindMode=t.bindMode??"attached",t.bindMatrix&&this.bindMatrix.fromArray(t.bindMatrix),this.bind(new EA(i,t.boneInverses.map(n=>new De().fromArray(n))),this.bindMatrix)),r!==this.isSkinnedMesh)for(let n of Array.isArray(this.material)?this.material:[this.material])n.needsUpdate=!0}normalizeSkinWeights(e){let t=new ut,i=this.geometry.attributes.skinWeight;for(let r=0,n=i.count;r<n;r++){t.fromBufferAttribute(i,r);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),i.setXYZW(r,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;nz.fromBufferAttribute(r.attributes.skinIndex,e),sz.fromBufferAttribute(r.attributes.skinWeight,e),rz.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){let s=sz.getComponent(n);if(s!==0){let a=nz.getComponent(n);az.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(Vre.copy(rz).applyMatrix4(az),s)}}return t.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(e,t){let i=this.posedGeometry();if(i===void 0)return!1;hp.geometry=i,hp.material=this.material,hp.matrixWorld.copy(this.matrixWorld);let r=t.length;hp.raycast(e,t);for(let n=r;n<t.length;n++)t[n].object=this;return hp.geometry=Gre,hp.material=jre,!0}posedGeometry(){let e=this.skeleton;if(!this.isSkinnedMesh||e===void 0)return;let t=this.geometry,{position:i,skinIndex:r,skinWeight:n}=t.attributes;if(!i||!r||!n)return;let s=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<e.bones.length;d++){let c=e.bones[d];if(!c||!e.boneInverses[d])return;s.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===t&&a.version===i.version&&a.pose.length===s.length&&a.pose.every((d,c)=>d===s[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,h=l?.count===o?l:new Pt(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,tT)),h.setXYZ(d,tT.x,tT.y,tT.z);let u=new Mt;u.setAttribute("position",h);for(let d of["normal","uv","uv1"]){let c=t.attributes[d];c&&u.setAttribute(d,c)}return u.setIndex(t.index),u.groups=t.groups,u.drawRange=t.drawRange,u.computeBoundingSphere(),u.computeBoundingBox(),this._posed={source:t,version:i.version,pose:s,geometry:u},u}}});function Lx(e){if(Array.isArray(e.material)){for(let t of e.material)if(t.getLayersOfType("outline").length===0)return}else if(!Xxe(e.material)||e.material.getLayersOfType("outline").length===0)return;e instanceof wn&&e.is2DAndNoDepth?function(t){if(t.geometry.attributes.extrudeNormals||!t.geometry.attributes.position)return;let i=t.geometry.attributes.position.array,r=new Float32Array(i.length),n=new P;for(let s=0;s<i.length;s+=3)n.set(i[s],i[s+1],i[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;t.geometry.setAttribute("extrudeNormal",new Tt(r,3))}(e):function(t){if(t.geometry.attributes.extrudeNormal||!t.geometry.attributes.position||!t.geometry.attributes.normal)return;let i=new Map,r=t.geometry.attributes,n=r.position.array,s=r.normal.array,a=new Float32Array(n.length);for(let o=0;o<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,h=new P(s[o],s[o+1],s[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<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,h=i.get(l)?.result;h&&(a[o]=h.x,a[o+1]=h.y,a[o+2]=h.z)}t.geometry.setAttribute("extrudeNormal",new Tt(a,3))}(e)}function oz(e){return Math.min(2047,Math.max(1,Math.round(2048*e)))/2048}function Bx(e){if(!e.geometry.attributes.position)return;let t=e.geometry.attributes,i=t.position.array,r=t.randomColor;if(r!==void 0&&3*r.count===i.length)return;let n=new Float32Array(i.length),s=parseInt(e.uuid.replace(/\D/g,"")),a=[oz(Qe.seededRandom(s)),oz(Qe.seededRandom(s+1e4)),oz(Qe.seededRandom(s+2e4))];for(let o=0;o<i.length;o++)n[o]=a[o%3];e.geometry.setAttribute("randomColor",new Pt(n,3))}var VB=F(()=>{ne(),ewe(),xl()});function Wre(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}function hFe(e,t){let i=e.cloner;return i!==void 0&&i.parent===t?i:void 0}function Hre(e,t,i,r){let n=16*(t.children.length+1);QM.length<n&&(QM=new Float32Array(n));let s=0,a=l=>{l.toArray(QM,16*s),s++},o=t.parameters.hideBase!==!0;o&&a(r),rq.copy(e.matrix);for(let l of t.children)!Bg(l)||l.playModeVisible===!1||(nq.copy(l.matrix).multiply(l.pivotMatrix),lO.multiplyMatrices(rq,nq),(!o||!lO.equals(r))&&a(lO));try{return s===0?0:function(l,h){return $Y(a4().instanced_union(qY(l),h))}(i,QM.subarray(0,16*s))}finally{Hxe(i)}}var up,qre,rq,nq,lO,QM,qg,vC=F(()=>{Da(),ne(),LB(),VB(),v1(),Yn(),up=new De,qre=new De,rq=new De,nq=new De,lO=new De,QM=new Float32Array(0),qg=class extends _l{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new Mt,this.onAfterRender=(r,n,s,a,o,l)=>{super.onAfterRender(r,n,s,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(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let r=0;r<this.children.length;r++){let n=this.children[r];n instanceof qg&&n.dataPatched.visible===!0&&n.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let n=this.children[r];if(n instanceof Fs&&n.dataPatched.visible===!0&&n.geometry.attributes.position?.count>0&&n.geometry.drawRange.count>0&&n.booleanMeshSetAddress!==0){up.copy(n.matrix).multiply(n.pivotMatrix);try{let s=hFe(n,this);if(n.booleanMeshSetAddress===-1){if((n.geometry.index??n.geometry.getAttribute("position")).count/3<15e5){let a=NBe(n.geometry,e===!0);n.booleanMeshSetAddress=s===void 0||a===-1?a:Hre(n,s,a,up)}if(n.booleanMeshSetAddress===-1)return;s===void 0&&F5(n.booleanMeshSetAddress,up),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1}else n instanceof qg&&n.needsTransformForDownstream===!0?(s===void 0?F5(n.booleanMeshSetAddress,up):n.booleanMeshSetAddress=Hre(n,s,n.booleanMeshSetAddress,up),n.needsTransformForDownstream=!1):n.booleanWasTransformed===!0&&(F5(n.booleanMeshSetAddress,qre.multiplyMatrices(up,n.booleanMatrixInvOld)),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1)}catch(s){console.error(s),n.booleanMeshSetAddress=0,n.geometry.userData.booleanOperationDidFail=!0;continue}if(n.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(n.booleanMeshSetAddress),n.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 Mt,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new Tt([],3))}return void this.geometry.setDrawRange(0,0)}if(e===!0)return function(r,n){let s=a4(),a=Lie(r,n),o=s.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 Mt,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,n,s,a){let o=a4(),l=Lie(r,n),h=o.mesh_render_data(l,Math.max(a,0));if(s.setAttribute("position",new Tt(h.positions(),3)),s.setAttribute("normal",new Tt(h.normals(),3)),h.free(),s.boundingSphere===null&&(s.boundingSphere=new ja),l.tri_count()===0)s.boundingSphere.center.set(0,0,0),s.boundingSphere.radius=0,s.userData.parameters={width:0,height:0,depth:0};else{let u=l.bounds();s.boundingSphere.center.set(u[0],u[1],u[2]),s.boundingSphere.radius=(u[3]**2+u[4]**2+u[5]**2)**.5,s.userData.parameters={width:2*u[3],height:2*u[4],depth:2*u[5]}}return $Y(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,Lx(this),Bx(this)}dispose(){super.dispose(),this.geometry.dispose()}}});function uFe(e){return e.isPointLight?hO.PointLight:e.isSpotLight?hO.SpotLight:hO.DirectionalLight}function $re(e){return e.isDirectionalLight?0:e.isSpotLight?1:2}function fSe(e){Hv.length=0,e.traverseVisible(r=>{(function(n){let s=n;return s.isPointLight===!0||s.isSpotLight===!0||s.isDirectionalLight===!0})(r)&&(r.castShadow===!0||$E.has(r))&&Hv.push(r)});let t=!1;if(Hv.length===0)return t;Hv.sort((r,n)=>$re(r)-$re(n)||r.id-n.id);let i=12;for(let r of Hv){let n=uFe(r);n<=i?(i-=n,$E.delete(r)&&(r.castShadow=!0,t=!0)):r.castShadow===!0&&(r.castShadow=!1,$E.add(r))}return Hv.length=0,t}var hO,$E,Hv,v4,GB,gd,Bc,y4,mK=F(()=>{hO={PointLight:1,SpotLight:3,DirectionalLight:3},$E=new WeakSet,Hv=[]}),yC=F(()=>{ne(),mK(),bl(),g1(),(v4||(v4={})).is=function(e){return tr.is(e)&&e instanceof qp},GB=(e,t)=>class extends m1(e,t){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 n=this.shadow;n.camera.far=i.depth,n.needsUpdate=!0}i.shadows!==void 0&&(function(n){$E.delete(n)}(this),this.castShadow=i.shadows)}}}),h0=F(()=>{vC(),Da(),g1(),gd=e=>e instanceof Fs,Bc=e=>e!==null&&e instanceof qg,y4=e=>AH.is(e)});function fo(e,t){return t.color(e)}function Xre(e=new Date,t){let i=t.format,r=e.getSeconds(),n=e;t&&t.timeZone!==null&&(n=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),f=m=>Number(p.find(g=>g.type===m)?.value);return new Date(f("year"),f("month")-1,f("day"),f("hour"),f("minute"),f("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,t.timeZone));let s,a=n.getHours(),o=n.getMinutes();t.format12h24h==="12ampm"&&(s=a>=12?"PM":"AM");let l,h,u=a;switch(t.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],s=void 0;break;case"mm":l=[o],s=void 0;break;case"ss":l=[r],s=void 0;break;case"year":h=n.getFullYear();break;case"month":h=n.getMonth()+1;break;case"dayOfYear":h=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":h=n.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:s}:h}var sq,Ow,gK=F(()=>{}),dFe=F(()=>{ne(),dC(),cC(),sq=class extends Ew(T_e){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Aw(this.object,sq.geometryHelper,e,t)}}}),jB=F(()=>{ne(),dFe(),yC(),Ow=class extends GB(PA,sq){constructor(e,t,i){super(),this.super_Entity(e,t),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 n=new RA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof RA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&function(r,n){r.shadow.camera.right=n/2,r.shadow.camera.left=-n/2,r.shadow.camera.top=n/2,r.shadow.camera.bottom=-n/2,r.shadow.needsUpdate=!0}(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}}});function vK(e){return e instanceof _l&&e.needsAO&&!Yf(e)&&e.isDecalObject!==!0}function yK(e){let t=e.cloner;if(t&&Array.isArray(t.children))for(let i of t.children)i?.layers&&(i.layers.mask=e.layers.mask)}function _K(e){return e.getLayersOfType("reflection").filter(t=>t.data.visible).length}function cFe(e){let t=1/0,i=-1/0;for(let r of e.getLayersOfType("reflection")){let n=r.data;if(!n.visible||n.mirror===1)continue;let s=typeof n.blur=="number"?n.blur:null;t=Math.min(t,s??0),i=Math.max(i,s??10)}return t===1/0?null:{min:t,max:i}}function pFe(e){for(let t of e.getLayersOfType("reflection")){let i=t.data;if(!i.visible)continue;let{blur:r,thickness:n,steps:s,stepSize:a}=i;return typeof r!="number"||typeof n!="number"||typeof s!="number"||typeof a!="number"?"variable":{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function Yre(e,t){let i={outline:!1,cavity:!1},r=e.layers.mask&WB,n=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline"),a=_K(t),o=t.getLayersOfType("cavity");return(s.length>0||o.length>0)&&(e.layers.set(8),n.length>0&&e.layers.enable(3),a>0&&e.layers.enable(4),i.outline=s.length>0,i.cavity=o.length>0,Bx(e),Lx(e)),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),r&&e.layers.set(9),!r&&vK(e)&&e.layers.enable(5),yK(e),i}function Kre(e,t){if(!t.layers)return!1;let i=e.layers.mask&WB,r=!1,n=t.getLayersOfType("transmission").filter(l=>l.data.visible),s=t.getLayersOfType("outline").filter(l=>l.data.visible),a=_K(t),o=t.getLayersOfType("cavity").filter(l=>l.data.visible);return n.length>0&&(e.layers.set(3),(s.length>0||o.length>0)&&e.layers.enable(8),a>0&&e.layers.enable(4),r=!0),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),i&&e.layers.set(9),!i&&vK(e)&&e.layers.enable(5),yK(e),r}function Zre(e,t){var i;if(!t.layers)return!1;let r=e.layers.mask&WB,n=!1,s=_K(t),a=t.getLayersOfType("transmission").filter(h=>h.data.visible),o=t.getLayersOfType("outline").filter(h=>h.data.visible),l=t.getLayersOfType("cavity").filter(h=>h.data.visible);return s>0&&((i=e.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),e.layers.set(4),a.length>0&&e.layers.enable(3),(o.length>0||l.length>0)&&e.layers.enable(8),n=!0),s===0&&a.length===0&&o.length===0&&l.length===0&&e.layers.set(0),r&&e.layers.set(9),!r&&vK(e)&&e.layers.enable(5),yK(e),n}function aq(e,t,i,r=!1){let n=e.cloner;if(n){let s=null;if((e.raycast===Sr.prototype.raycast||e.raycast===Fs.prototype.raycast)&&e.isSkinnedMesh!==!0){let a=e.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),s=a.boundingSphere)}for(let a of n.children){if(s!==null&&(oq.copy(s).applyMatrix4(a.matrixWorld),!t.ray.intersectsSphere(oq)))continue;let o=gSe.copy(a.matrixWorld).invert(),l=vSe.copy(t.ray).applyMatrix4(o),h=e.matrixWorld;l.applyMatrix4(h);let u=mSe;u.set(l.origin,l.direction),u.near=t.near,u.far=t.far,u.layers.mask=t.layers.mask;let d=u.intersectObject(e,!1);d.length>0&&i.push({...d[0],object:r?a:e})}}}var WB,mSe,gSe,vSe,oq,J3,ySe,lz,hz,uz,Lw,Dn,bK=F(()=>{Yn(),VB(),Da(),v1(),ne(),WB=512,mSe=new yB,gSe=new De,vSe=new _f,oq=new ja}),fFe=F(()=>{ne(),dC(),cC(),J3=class extends Ew(w_e){constructor(e,t=6710886){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Aw(this.object,J3.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=J3._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(r);else this.cone.material.color.set(r)}}},(ySe=J3)._vector=new P}),HB=F(()=>{ne(),fFe(),yC(),lz=new P,hz=new P,uz=new Vt,Lw=class extends GB(by,ySe){constructor(e,t,i){super(),this.super_Entity(e,t),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*Qe.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new RA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof RA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),hz.setFromMatrixPosition(this.matrixWorld),uz.setFromRotationMatrix(this.matrixWorld),lz.copy(this.up).applyQuaternion(uz).negate().multiplyScalar(this.distance),this.target.position.copy(hz).add(lz),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),wu=F(()=>{Ot(),Nh(),ne(),bl(),xu(),gK(),Ad(),jB(),Ir(),Qf(),ne(),v1(),h0(),bK(),HB(),vr(),vC(),Dn=class extends IB(Yo){constructor(e,t,i){if(super(),this.data=t,this.bgColor=new Ur(1,1,1,1),this.fog=null,this.backupFog=new iW(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Xn.getDensity({}),this.fogHeightFalloff=Xn.getHeightFalloff({}),this.fogHeightBase=Xn.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new at,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Kn(f1,{...kE.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new vB(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene){let r=xH();r===null?Ta("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else t.uiFrame&&this.createUICanvas(t.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(e,t){let i=xH();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})):Ta("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=fo(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity*Math.PI),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof qg&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof _l)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){if(e.softShadowQuality===void 0&&e.type===void 0||!this.isActive)return;let t=this.data.shadow;var i,r;i=wy.isSoft(t),r=t?.softShadowQuality,tq!==void 0&&tq(i,r)&&this.forceMaterialsUpdate()}updateFog(e,t){e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=fo(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far,this.fogMode=Xn.getMode(e),this.fogDensity=Xn.getDensity(e),this.fogHeightFalloff=Xn.getHeightFalloff(e),this.fogHeightBase=Xn.getHeightBase(e)}updateSky(e,t){this.skyState=e??null,this.skyStateVersion++;let i=e?.hdri?.image;this.skyHdriHolder=i!=null?t.image(i):null}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=fo(e.aoColor,t))}updateByOp(e,t,i,r){let n=this.data.uiFrame;super.updateByOp(e,t,i,r);let s=t;Zr(e.path,["fog"])?this.updateFog(s.fog,i.shared):Zr(e.path,["sky"])?this.updateSky(s.sky,i.shared):Zr(e.path,["grading"])?this.gradingState=s.grading??null:Zr(e.path,["ao"])?this.updateAo(s.ao,i.shared):Zr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Zr(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||n!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(fo(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.sky!==void 0&&this.updateSky(e.sky,t.shared),e.grading!==void 0&&(this.gradingState=e.grading),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e instanceof Kn&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){let e=this.scene?.find(this.data.publish.playCamera);return e instanceof Kn?e:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(Xf).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof Ow&&i.visible&&e<GE&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof Lw&&i.visible&&e<Xf-GE&&(this.penumbraSizeArrayCache[GE+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let n of r.children){let s=n.cloner;tr.is(n)&&(n.visible||s?.object.data.visible)&&((gd(n)||y4(n)&&this.scene.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),aq(n,e,t,!0)),i(n))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}}});function Qre(){return xK}function dz(){if(_4===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 _4}function cz(e){return e?.isWebGPUSplineRenderer===!0}var xK,_4,wK=F(()=>{xK=null,_4=null});function lq(){return TK}var SK,TK,MK=F(()=>{SK=null,TK=null});function Jre(e,t,i){return JM.setRGB(e,t,i,qi),{r:JM.r,g:JM.g,b:JM.b}}function mFe(e,t,i){let r,n=qA(e.angle,0),[s,a]=hq(e.offset),[o,l]=hq(e.morph),h=e.colors??[],u=e.steps??[],d=Math.min(10,h.length,u.length);if(d===0)return[1,1,1,1];if(e.gradientType===1){let g=3*(t+o)-(t+s)-1,v=3*(i+l)-(i+a)-1;r=Math.hypot(g,v)+n}else if(e.gradientType===2){let g=-1*Math.atan2(t+o-.5+s,i+l-.5+a),v=n/Math.PI/-2+.5*g/Math.PI;r=v-Math.floor(v)}else{let g=.5+o/(t!==0?t:1e-6),v=l/(i!==0?i:1e-6),y=Math.cos(n)*g-Math.sin(n)*v,_=Math.sin(n)*g+Math.cos(n)*v,b=y*y+_*_;r=b>1e-12?(((t-.5+s)/2+y/2)*y+((i-.5+a)/2+_/2)*_)/b:0}let c=h[0][0],p=h[0][1],f=h[0][2],m=h[0][3];for(let g=1;g<d;g++){let v=u[g-1],y=u[g]-v,_=y!==0?Math.min(1,Math.max(0,(r-v)/y)):r>=v?1:0;e.smooth&&(_=_*_*(3-2*_)),c+=(h[g][0]-c)*_,p+=(h[g][1]-p)*_,f+=(h[g][2]-f)*_,m+=(h[g][3]-m)*_}return[c,p,f,m]}function gFe(e,t){let i=e,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let n=t,s=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=qA(o.alpha,1);if(!(l<=0))if(o.type==="color"){let h,u=o.color;typeof u=="string"?h=typeof n?.color=="function"?n.color(u):void 0:u&&typeof u.r=="number"&&(h=u),h&&s.push({kind:"color",layer:o,rgb:{...Jre(h.r,h.g,h.b),a:h.a??1},alpha:l})}else o.type==="gradient"&&s.push({kind:"gradient",layer:o,alpha:l})}),s.length===0?null:(a,o)=>{let l=1,h=1,u=1,d=!0;for(let c of s){let p,f,m,g;if(c.kind==="color")({r:p,g:f,b:m}=c.rgb),g=c.rgb.a;else{let[y,_,b,x]=mFe(c.layer,a,o);({r:p,g:f,b:m}=Jre(y,_,b)),g=x}let v=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*v,h+=(f-h)*v,u+=(m-u)*v,d=!1}return{r:l,g:h,b:u}}}if(i?.color&&i.color.isColor===!0){let{r:n,g:s,b:a}=i.color;return()=>({r:n,g:s,b:a})}return null}var JM,qA,hq,vFe=F(()=>{ne(),JM=new at,qA=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t,hq=e=>Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"?[e[0],e[1]]:[0,0]});function yFe(e,t){if(e==="torus"){let l=t()*Math.PI*2,h=t()*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(e==="cylinder"){let l=t()*Math.PI*2,h=Math.cos(l),u=Math.sin(l);return{x:.8*h,y:1.6*(t()-.5),z:.8*u,nx:h,ny:0,nz:u,cr:1,cg:1,cb:1}}let i=t()*Math.PI*2,r=2*t()-1,n=Math.acos(r),s=Math.sin(n)*Math.cos(i),a=Math.cos(n),o=Math.sin(n)*Math.sin(i);return{x:s,y:a,z:o,nx:s,ny:a,nz:o,cr:1,cg:1,cb:1}}function _Fe(e){let{geometry:t,matrix:i}=e,r=t.getAttribute("position");if(!r||r.count<3)return null;let n=t.getAttribute("normal"),s=t.getAttribute("uv"),a=t.getAttribute("color"),o=t.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let h=(v,y)=>o?o.getX(3*v+y):3*v+y,u=i?i.elements:null,d=i?new si().getNormalMatrix(i).elements:null,c=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return u?u[0]*y+u[4]*_+u[8]*b+u[12]:y},p=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return u?u[1]*y+u[5]*_+u[9]*b+u[13]:_},f=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return u?u[2]*y+u[6]*_+u[10]*b+u[14]:b},m=new Float64Array(l),g=0;for(let v=0;v<l;v++){let y=h(v,0),_=h(v,1),b=h(v,2),x=c(y),w=p(y),S=f(y),T=c(_)-x,M=p(_)-w,E=f(_)-S,A=c(b)-x,C=p(b)-w,D=f(b)-S,R=M*D-E*C,I=E*A-T*D,U=T*C-M*A;g+=.5*Math.sqrt(R*R+I*I+U*U),m[v]=g}return g<=0?null:{total:g,sample:(v,y)=>{let _=0,b=l-1;for(;_<b;){let Y=_+b>>1;m[Y]<v?_=Y+1:b=Y}let x=_,w=h(x,0),S=h(x,1),T=h(x,2),M=y(),E=y();M+E>1&&(M=1-M,E=1-E);let A,C,D,R=1-M-E,I=c(w)*R+c(S)*M+c(T)*E,U=p(w)*R+p(S)*M+p(T)*E,O=f(w)*R+f(S)*M+f(T)*E;if(n){if(A=n.getX(w)*R+n.getX(S)*M+n.getX(T)*E,C=n.getY(w)*R+n.getY(S)*M+n.getY(T)*E,D=n.getZ(w)*R+n.getZ(S)*M+n.getZ(T)*E,d){let Y=d[0]*A+d[3]*C+d[6]*D,ue=d[1]*A+d[4]*C+d[7]*D,de=d[2]*A+d[5]*C+d[8]*D;A=Y,C=ue,D=de}}else{let Y=c(w),ue=p(w),de=f(w),ge=c(S)-Y,be=p(S)-ue,re=f(S)-de,xe=c(T)-Y,j=p(T)-ue,z=f(T)-de;A=be*z-re*j,C=re*xe-ge*z,D=ge*j-be*xe}let k=Math.sqrt(A*A+C*C+D*D)||1,G=1,K=1,q=1;if(a)G=a.getX(w)*R+a.getX(S)*M+a.getX(T)*E,K=a.getY(w)*R+a.getY(S)*M+a.getY(T)*E,q=a.getZ(w)*R+a.getZ(S)*M+a.getZ(T)*E;else if(e.sampleColor){let Y=s?s.getX(w)*R+s.getX(S)*M+s.getX(T)*E:.5,ue=s?s.getY(w)*R+s.getY(S)*M+s.getY(T)*E:.5,de=e.sampleColor(Y,ue);de&&(G=de.r,K=de.g,q=de.b)}return{x:I,y:U,z:O,nx:A/k,ny:C/k,nz:D/k,cr:G,cg:K,cb:q}}}}function ene(e){let t=Math.min(Math.max(1,Math.floor(e.guideStrands)),Fx),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}}(e.seed??1337),r=e.shape==="object"&&e.sampler,n=r?e.samplerRadius??od:od,s=new Float32Array(4*rf),a=new Float32Array(rf),o=new Float32Array(4*Fx).fill(1);for(let l=0;l<t;l++){let h=r?e.sampler(i):yFe(e.shape,i),u=r?h.x:h.x*n,d=r?h.y:h.y*n,c=r?h.z:h.z*n,{nx:p,ny:f,nz:m}=h;o[4*l+0]=h.cr,o[4*l+1]=h.cg,o[4*l+2]=h.cb;let g,v,y,_=l*Jv,b=(1.8+.8*i())*e.hairLength*n/(Jv-1),x=.5+1.5*i(),w=(.02+.06*i())*n;Math.abs(f)<.99?(g=-m,v=0,y=p):(g=1,v=0,y=0);let S=Math.sqrt(g*g+v*v+y*y)||1;for(let T=0;T<Jv;T++){let M=T/(Jv-1),E=M*M*.4*n,A=w*Math.sin(M*x*Math.PI*2),C=4*(_+T);s[C+0]=u+p*b*T+A*g/S,s[C+1]=d+f*b*T-E+A*v/S,s[C+2]=c+m*b*T+A*y/S,s[C+3]=T===0?0:1,T<Jv-1&&(a[_+T]=b)}}return{initialPositions:s,restLengths:a,unitScale:n,rootColors:o}}var Jv,Fx,rf,od,mg,iT,n_,V0,s_,uO,_Se=F(()=>{ne(),rf=(Fx=16384)*(Jv=32),od=100}),bSe=F(()=>{ne(),Da(),MK(),vFe(),_Se(),mg=1/60,iT=new De,n_=new Vt,V0=new P,s_=new P,uO=class extends Fs{constructor(e,t,i){super(e,t),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 Vt,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=t,this.geometry.setAttribute("position",new Pt(new Float32Array(0),3)),this.material=new Zl({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new Sr(new jf(od,48,32),new Zl({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new PL;r.setAttribute("position",new Pt(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new Sr(r,new Zl({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=t.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:t.guideStrands,hairLength:t.hairLength,spreadRadius:t.spreadRadius,headShape:t.headShape,baseObjectId:t.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,4*mg*2),this.trackMotionRest(e/1e3))}trackMotionRest(e){this.boneTransform(n_,V0);let t=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(n_))<.9999995||this.lastBonePos.distanceToSquared(V0)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||t||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(n_),this.lastBonePos.copy(V0),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+e}motionFingerprint(){let e=this.data;return e.gravity+2*e.damping+3*e.localStiffness+4*e.globalStiffness+5*e.globalRange+6*e.stiffnessFalloff+7*e.windStrength+8*e.vspCoefficient+9*e.kink+10*e.kinkFrequency+11*e.clumpStrength+12*e.clumpSize+13*e.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(e){this.playModeActive=e,e&&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(e,t){super.updateState(e,t),this.updateHairState(e)}updateHairState(e){if((e.guideStrands!==void 0||e.hairLength!==void 0||e.spreadRadius!==void 0||e.headShape!==void 0||e.baseObjectId!==void 0)&&this.regenerate(),(e.headShape!==void 0||e.baseObjectId!==void 0)&&this.applyScalpState(),e.headColor!==void 0){let t=this.scalpMesh.material;t.isMeshBasicMaterial===!0&&t.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,qi)}(e.castShadow!==void 0||e.receiveShadow!==void 0)&&this.applyShadowState(),e.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,t=this.data.receiveShadow??!0;this.castShadow=e,this.receiveShadow=t,this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=t,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=t}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 e=this.data,t=this.regenSnapshot;if(t===null||t.guideStrands!==e.guideStrands||t.hairLength!==e.hairLength||t.spreadRadius!==e.spreadRadius||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId){let i=t===null||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:t,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,e==="object"&&t){let n=this.context.scene.find(t);if(n){this.baseFoundAtRegen=!0,n.updateWorldMatrix(!0,!0);let s=this.collectBaseSources(n),a=s?function(o){let l=[];for(let d of o){let c=_Fe(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,f=l.length-1;for(;p<f;){let g=p+f>>1;h[g]<c?p=g+1:f=g}let m=p===0?c:c-h[p-1];return l[p].sample(m,d)}}(s.sources):null;if(this.baseSourceGeomsAtRegen=s?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=s?.hashes??[],this.baseColorHashAtRegen=s?.colorHash??0,s&&a){let o=this.baseWorldScale(n),l=Math.max(s.radius*o,.001);this.baseScaleAtRegen=o;let h=o;return ene({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 ene({shape:e==="object"?"sphere":e,guideStrands:i,hairLength:r})}collectBaseSources(e){let t=[],i=[],r=0,n=0;iT.copy(e.matrixWorld).invert();let s=iT.clone(),a=o=>{if(o.isHairSystem===!0||o!==e&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let h=o===e?void 0:new De().multiplyMatrices(s,o.matrixWorld),u=Array.isArray(o.material)?o.material[0]:o.material;t.push({geometry:l,matrix:h,sampleColor:gFe(u,this.context.shared)??void 0}),i.push(uO.matrixHash(h)),n+=function(c,p){let f=c,m=0,g=1,v=_=>{m+=_*g,g+=1},y=f?.data?.layers;if(y&&typeof y.forEach=="function"){let _=p;y.forEach(b=>{let x=b.data;if(x.visible!==!1){if(x.type==="color"){let w=x.color,S=typeof w=="string"?typeof _?.color=="function"?_.color(w):void 0:w;S&&typeof S.r=="number"&&(v(S.r),v(S.g),v(S.b)),v(qA(x.alpha,1))}else if(x.type==="gradient"){let w=x;for(let S of w.colors??[])v(S[0]),v(S[1]),v(S[2]),v(S[3]);for(let S of w.steps??[])v(S);v(qA(w.angle,0)),v(w.gradientType),v(w.smooth?1:0)}}})}else f?.color&&f.color.isColor===!0&&(v(f.color.r),v(f.color.g),v(f.color.b));return m}(u,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;h?(V0.copy(d.center).applyMatrix4(h),c=V0.length(),p=uO.matrixMaxScale(h)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let h of o.children)a(h)};return a(e),t.length===0?null:{sources:t,hashes:i,radius:Math.max(r,.001),colorHash:n}}static matrixHash(e){if(!e)return 0;let t=e.elements,i=0;for(let r=0;r<16;r++)i+=t[r]*(r+1);return i}static matrixMaxScale(e){let t=e.elements,i=Math.hypot(t[0],t[1],t[2]),r=Math.hypot(t[4],t[5],t[6]),n=Math.hypot(t[8],t[9],t[10]);return Math.max(i,r,n,1e-6)}baseWorldScale(e){return iT.copy(e.matrixWorld).decompose(V0,n_,s_),Math.max(Math.abs(s_.x),Math.abs(s_.y),Math.abs(s_.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 e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen)return void this.regenerate();e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),i=t?.sources??[],r=t?.hashes??[],n=this.baseSourceGeomsAtRegen,s=this.baseSourceHashesAtRegen,a=i.length!==n.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==n[o]||Math.abs(r[o]-s[o])>1e-4*Math.max(Math.abs(s[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(t?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(e);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let e=this.data.headShape,t=e==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!t,!t&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=e==="torus"?new CL(1.4*od,.7*od,24,48):e==="cylinder"?new IE(.8*od,.8*od,1.6*od,48,1):new jf(od,48,32))}boneTransform(e,t){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)}iT.copy(i).decompose(t,e,s_)}raycast(e,t){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(e,i);for(let r of i)r.object=this,t.push(r)}get shadowBoundsRadius(){let e=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(e+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(e){return this.boneTransform(n_,e),e}updateEntityBoxSize(e,t){let i=this.shadowBoundsRadius;e.set(0,0,0),t.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),lq()?.release(this)}}});function dO(){return{shapeInput:()=>`
|
|
4212
|
+
`&&A.push("")):S.getTextWidth(A[A.length-1]+C,w)>E&&(A[A.length-1].length&&A.push(""),S.getTextWidth(A[A.length-1]+C,w)>E&&(C.length===1?(A[A.length-1]+=C,C=""):(A[A.length-1]+=C.slice(0,-1),C=C[C.length-1],A.push(""))));return A[A.length-1]+=C,A}(e,i,h===2?c.toUpperCase():h===3?c.toLowerCase():c,t),{shapes:f,charWidths:m,charCoords:g}=i.generateShapes(p,e,t),v=.5*(typeof r=="number"?r:Number(t.getVariable(r))),y=.5*(typeof n=="number"?n:Number(t.getVariable(n))),_=f.map(w=>new cs().fromShape(w,!0));this.vectorShapes=_;let b=_.map(w=>l0.create({shape:w,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:u,extrusionVersion:d,windingRule:s<=0?is.NONZERO:is.ODD,subdivisions:this.isLowResolution&&s>0?1:12}})),x=b.length?ly(b):Are();x.translate(-v,y,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([w,S])=>{this.setAttribute(w,S)}),this.setIndex(x.index),this.adoptNearSide(b,s),this.computeBoundingSphere()}adoptNearSide(e,t){this._depth=t;let i=0,r=0,n=0;for(let o of e){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),n=l._vScale??n}this._effectiveBevel=r,this._vScale=n;let s=new Uint8Array(i),a=0;for(let o of e){let l=o._nearSide;s.set(l,a),a+=l.length}this._nearSide=s}takeDepthStateFrom(e){let t=e;t._nearSide!==void 0&&(this._depth=t._depth??this._depth,this._nearSide=t._nearSide,this._vScale=t._vScale??this._vScale,this._effectiveBevel=t._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length===this.getAttribute("position")?.count&&dx(this._effectiveBevel,e)&&dx(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let t=e-this._depth;if(this._depth=e,t===0)return!0;let i=this.getAttribute("position"),r=i.array,n=this.getAttribute("uv"),s=n?.array,a=this._vScale>0?t/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let h=o[l];h!==0&&(r[3*l+2]+=t,h===2&&s!==void 0&&(s[2*l+1]+=a))}return i.needsUpdate=!0,n!==void 0&&a!==0&&(n.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let t=this.boundingBox;t.min.z=Math.min(0,e),t.max.z=Math.max(0,e),this.boundingSphere!==null&&t.getBoundingSphere(this.boundingSphere)}clone(){let e=Go(new Mt,jH.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}}});function sFe(e){if(!WH)return Pre||(Pre=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.205/build",i=import("./process.js"),[r,n]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});Jwe(a),WH=!0}())}var Jwe,oK,WH,Pre,zB=F(()=>{oK=new Promise(e=>{Jwe=e}),WH=!1});function $5(e,t){if(Object.keys(e.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let i=Object.keys(e.attributes),r=Object.keys(t.attributes);if(i.length!==r.length)return!1;for(let l of r){let h=e.attributes[l],u=t.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 n=e.index,s=t.index;if(n===null!=(s===null))return!1;let a=!1;if(n!==null&&s!==null){if(n.array.length!==s.array.length)return!1;let l=n.array.constructor,h=s.array.constructor;if(l!==h){if(l!==Uint32Array||h!==Uint16Array)return!1;a=!0}}if(e.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let h=e.groups[l],u=t.groups[l];if(h.start!==u.start||h.count!==u.count||h.materialIndex!==u.materialIndex)return!1}for(let l of r){let h=e.attributes[l],u=t.attributes[l];h.array.set(u.array),h.needsUpdate=!0}let o=e.takeDepthStateFrom;if(typeof o=="function"&&o.call(e,t),n!==null&&s!==null){if(a){let l=n.array,h=s.array;for(let u=0,d=h.length;u<d;u++){let c=h[u];l[u]=c===65535?4294967295:c}}else n.array.set(s.array);n.needsUpdate=!0}return e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e.boundingBox=null,e.boundingSphere=null,!0}function HH(e,t,i,r){let n,s,a,o=e.position.array,l=e.normal.array,h=eSe.makeScale(t,i,r).invert().elements;for(let u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=i,o[u+2]*=r,n=l[u],s=l[u+1],a=l[u+2],l[u]=h[0]*n+h[4]*s+h[8]*a,l[u+1]=h[1]*n+h[5]*s+h[9]*a,l[u+2]=h[2]*n+h[6]*s+h[10]*a;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var eSe,tSe=F(()=>{ne(),eSe=new De});function qH(e){let t=Number(e);return Number.isInteger(t)&&t>=0&&String(t)===e?t:-1}function Y3(e){if(e!=null){if(Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView))return e;if(typeof e=="object")return function(t){let i=Object.keys(t),r=0;for(let s of i){let a=qH(s);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let n=new Array(r);for(let s=0;s<r;s++){let a=t[s];if(typeof a!="number")return;n[s]=a}return n}(e)}}function X5(e){if(e==null)return"missing";if(Array.isArray(e))return`Array(${e.length})`;if(ArrayBuffer.isView(e)){let l=e;return`${e.constructor.name}(${l.length})`}if(typeof e!="object")return typeof e;let t=Object.keys(e),i=t.filter(l=>qH(l)===-1),r=0;for(let l of t){let h=qH(l);h>=r&&(r=h+1)}let n=e,s=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):s===-1&&(s=l);let o=[`${t.length} keys`,"max index "+(r-1)];return s!==-1&&o.push(`first missing index ${s}`),a!==-1&&o.push(`non-number at ${a} (${typeof n[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function iSe(e){let t=Object.keys(e);return t.length===1&&t[0]==="subdivisions"}function lK(e,t){let i=t?t.count:e.count,r=0,n=1e4,s=new Map,a=new Uint32Array(i),o=[];for(let u=0;u<i;u++){let d=t?t.getX(u):u,c=e.getX(d),p=e.getY(d),f=e.getZ(d),m=Math.round(c*n),g=Math.round(p*n),v=Math.round(f*n),y=s.get(m);y===void 0&&(y=new Map,s.set(m,y));let _=y.get(g);_===void 0&&(_=new Map,y.set(g,_));let b=_.get(v);b===void 0&&(b=r++,_.set(v,b),o.push(c,p,f)),a[u]=b}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(t?t.getX(u):u,t?t.getX(u+1):u+1,t?t.getX(u+2):u+2));return{positions:o,triIndices:l,triOriginals:h}}var JS,k0,ti,Y5,K5,Z5,us,eT,K3,Z3,Q3,$H,oO,Dw=F(()=>{ne(),zB(),Ot(),kB(),tSe(),VA(),JS=new cn,k0=new P,oK.then(e=>{ti=e}),Y5=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),K5=new Uint32Array([0,1,2,3]),Z5=new Uint8Array([4]),us=class extends Mt{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=jg.div(t.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&HH(this.subdividedGeometry.attributes,...r),this.originalGeometry&&HH(this.originalGeometry.attributes,...r),this.data=e;let n=this.userData.parameters;this.userData.parameters={width:n.width*r[0],height:n.height*r[1],depth:n.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(k0.fromArray(r));let s=k0.set(n.width,n.height,n.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let t=e.phongAngle??35;this.flatShading&&(t=-1);let i=null;if(e.subdivisions>0){let n=0;try{n=us.allocate(e),i=us.buildRefined(n,e.subdivisions,t)}catch(s){console.error(s,e)}finally{n&&us.freeSubdivPointer(n)}}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 e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Dh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(us.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ja,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;JS.setFromBufferAttribute(t),JS.getCenter(i),e.boundingSphere.radius=i.distanceTo(JS.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),JS.getSize(k0);let r={width:k0.x,height:k0.y,depth:k0.z};return this.userData.parameters=r,r}static build(e,t,i,r){let n,s,a=e?.phongAngle??35;i===!1&&(a=-1),t&&(ti.free_bvh(t),ti.free_subdivision_surface(t));try{n=us.allocate(e,r)}catch(l){console.error(l,e),n=us.allocate({positionWASM:Y5,indexWASM:K5,verticesPerFaceWASM:Z5},r)}ti.set_destination_refinement_level(n,0);let o=us.buildLevel(n,!0,a);return s=e.subdivisions>0?us.buildRefined(n,e.subdivisions,a):null,{subdivPointer:n,originalGeometry:o,subdividedGeometry:s}}static buildRefined(e,t,i){try{return ti.set_destination_refinement_level(e,t),us.buildLevel(e,!1,i)??null}catch{try{return ti.set_destination_refinement_level(e,t-1),us.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r,n=e.shape!==void 0||e.path!==void 0?t.geometry:Fg(e,i,!1,t);r=jxe(e)?n.getClosedTorusIndicesForBooleanOrSubdiv():n.getIndex();let s,{positions:a,triIndices:o,triOriginals:l}=lK(n.getAttribute("position"),r);if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2;s=[c,c+3*e.radialSegments]}let{indices:h,verticesPerFace:u,uvs:d}=function(c,p,f,m,g){let v=[],y=[],_=g?f.getAttribute("uv"):void 0,b=_&&_.itemSize===2?[]:void 0,x=T=>{if(b){let M=g[T];b.push(_.getX(M),_.getY(M))}};if(f.userData.shape!==void 0&&f.userData.parameters.depth===0&&f.userData.shape.shapeHoles.length===0){let T=f.userData.shape.extractShapePointsToFlatArray([]),M=f.userData.parameters.spikes;if(f.userData.type==="EllipseGeometry"&&M<=24&&M%4==0&&f.userData.parameters.angle>=360){let C=T.length/2/M;T=T.filter((D,R)=>Math.floor(R/2)%C===0)}let E=0;for(let C=0;C<T.length;C+=2)E+=(T[C]-T[(C===0?T.length:C)-2])*(T[C+1]+T[(C===0?T.length:C)-1]);c.length=0;let A=0;if(E<0)for(let C=0;C<T.length;C+=2)c.push(T[C],T[C+1],0),v.push(A++);else for(let C=T.length-2;C>=0;C-=2)c.push(T[C],T[C+1],0),v.push(A++);return y.push(A),{indices:v,verticesPerFace:y}}let w=new Float32Array([f.userData.parameters.depth])[0],S=0;for(;S<p.length;){if(f.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[S]+2]===w||c[3*p[S]+2]===0)&&T++,(c[3*p[S+1]+2]===w||c[3*p[S+1]+2]===0)&&T++,(c[3*p[S+2]+2]===w||c[3*p[S+2]+2]===0)&&T++,T===3)break}if(p[S+1]===p[S+3]&&p[S+2]===p[S+5]||p[S+0]===p[S+3]&&p[S+2]===p[S+4]){eT.set(c[3*p[S]],c[3*p[S]+1],c[3*p[S]+2]),K3.set(c[3*p[S+1]],c[3*p[S+1]+1],c[3*p[S+1]+2]),Z3.set(c[3*p[S+4]],c[3*p[S+4]+1],c[3*p[S+4]+2]),Q3.set(c[3*p[S+5]],c[3*p[S+5]+1],c[3*p[S+5]+2]),K3.sub(eT).normalize(),Z3.sub(eT).normalize(),Q3.sub(eT).normalize();let T=K3.cross(Z3).dot(Q3),M=S;Math.abs(T)>.005||m&&m.some((E,A)=>A%2!=1&&M>=m[A]&&M<m[A+1])?(v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3):(v.push(p[S],p[S+1],p[S+4],p[S+5]),x(S),x(S+1),x(S+4),x(S+5),y.push(4),S+=6)}else v.push(p[S],p[S+1],p[S+2]),x(S),x(S+1),x(S+2),y.push(3),S+=3}if(f.useNgonForTopBottomFaceDuringBake){let T=[],M=[],E=0;for(let A=0,C=0;A<c.length;A+=3,C++)c[A+2]===0&&(T.push(C),E++),c[A+2]===w&&M.push(C);if(f.userData.parameters.extrudeBevelSize===0){let A=M[0];M[0]=M[1],M[1]=A}T.reverse(),v.push(...T,...M),y.push(E,E),b=void 0}return{indices:v,verticesPerFace:y,uvs:b}}(a,o,n,s,l);return{positions:a,indices:h,verticesPerFace:u,uvs:d}}static allocate(e,t){let i,r,n,s=[],a=[],o=Y3(e.positionWASM),l=Y3(e.indexWASM),h=Y3(e.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!h?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${X5(e.positionWASM)}, indexWASM ${X5(e.indexWASM)}, verticesPerFaceWASM ${X5(e.verticesPerFaceWASM)}`);i=o,r=l,n=h;let S=Y3(e.uvWASM);ti.alloc_subdivision_surface_uvs&&S&&S.length===2*r.length&&(a=S)}else i=Y5,r=K5,n=Z5;let u=i.length,d=r.length,c=n.length,p=i.length+s.length+a.length,f=r.length+n.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,v=ti._malloc(m);if(!v)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${m}) failed`);let y,_=new Float32Array(ti.HEAPF32.buffer,v,p),b=new Uint32Array(ti.HEAPU32.buffer,v+g,f);_.set(i,0),_.set(s,i.length),_.set(a,i.length+s.length),b.set(r,0),b.set(n,r.length),e?.scaleBaked?.some(S=>S!==1)&&(y=new De().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),t&&(y?y.premultiply(t):y=t);let x=v+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,w=a.length?y?ti.alloc_subdivision_surface_uvs2(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,y.elements):ti.alloc_subdivision_surface_uvs(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):y?ti.alloc_subdivision_surface2(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,y.elements):ti.alloc_subdivision_surface(v,u,v+g,d,v+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return ti._free(v),w}static buildLevel(e,t,i,r,n,s=!1){let a=n?ti.get_mesh_data2(e,t?ti.Level.CONTROL:ti.Level.REFINED,i,n.elements):ti.get_mesh_data(e,t?ti.Level.CONTROL:ti.Level.REFINED,i),o=ti.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),h=0,u=ti.HEAPU32[o[h]>>2],d=ti.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=ti.HEAPU32[o[h]>>2],p=ti.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let f=ti.HEAPU32[o[h]>>2],m=ti.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g,v=ti.HEAPU32[o[h]>>2],y=ti.HEAPU32.subarray(v>>2,(v>>2)+l[h]);if(h++,ti.alloc_subdivision_surface_uvs){let b=o[9];if(b>0){let x=ti.HEAPU32[o[8]>>2];g=ti.HEAPF32.subarray(x>>2,(x>>2)+b)}}if(r===void 0){let b=new Mt;if(b.setIndex(new Gf(y,1)),b.setAttribute("position",new Tt(d,3)),b.setAttribute("normal",new Tt(p,3)),g&&b.setAttribute("uv",new Tt(g,2)),t){b.setAttribute("faceMap",new Gf(m,1));let x=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Pt(x,4))}return ti.free_mesh_data(a),b.userData.type="SubdivGeometry",b}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,s){let b=r.getIndex();b!==null&&b.array.length===y.length&&(b.copyArray(y),b.needsUpdate=!0)}let _=r.getAttribute("uv");g&&_&&_.array.length===g.length&&(_.copyArray(g),_.needsUpdate=!0),ti.free_mesh_data(a)}static freeSubdivPointer(e){ti.free_bvh(e),ti.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ti.get_wireframe_data_for_base_level(e),n=ti.HEAPU32.subarray(r>>2,4+(r>>2)),s=n.subarray(2,4),a=0,o=ti.HEAPU32[n[a]>>2],l=ti.HEAPF32.subarray(o>>2,(o>>2)+s[a]);a++;let h=ti.HEAPU32[n[a]>>2],u=ti.HEAPU32.subarray(h>>2,(h>>2)+s[a]);if(t===void 0){let d=new Mt;d.setAttribute("position",new Tt(l,3));let c=new Float32Array(l.length);for(let p=0,f=l.length;p<f;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new Pt(c,3)),d.setIndex(new Gf(u,1)),ti.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(l),t.attributes.position.needsUpdate=!0,ti.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ti.set_destination_refinement_level(e,t);let n=i?ti.get_topological_data2(e,r?ti.Level.CONTROL:ti.Level.REFINED,i.elements):ti.get_topological_data(e,r?ti.Level.CONTROL:ti.Level.REFINED),s=ti.HEAPU32.subarray(n>>2,8+(n>>2)),a=s.subarray(3,6),o=0,l=ti.HEAPU32[s[o]>>2],h=new Float32Array(ti.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=ti.HEAPU32[s[o]>>2],d=new Uint32Array(ti.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let c,p=ti.HEAPU32[s[o]>>2],f=new Uint8Array(ti.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(ti.alloc_subdivision_surface_uvs){let m=s[7];if(m>0){let g=ti.HEAPU32[s[6]>>2];c=new Float32Array(ti.HEAPF32.subarray(g>>2,(g>>2)+m))}}return ti.free_topological_data(n),{positions:h,indices:d,verticesPerFace:f,uvs:c}}},eT=new P,K3=new P,Z3=new P,Q3=new P}),rSe=F(()=>{$ie(),Xie(),l4(),Yie(),c4(),VA(),fre(),mre(),gre(),VH(),_re(),p4(),bre(),xre(),wre(),GH(),Sre(),Tre(),Mre(),Ere(),e0(),vr(),$ie(),Xie(),l4(),Yie(),c4(),rFe(),VA(),fre(),mre(),gre(),VH(),_re(),p4(),bre(),xre(),wre(),GH(),Sre(),Tre(),Mre(),Ere(),e0(),nFe(),Pwe(),Qwe(),Dw(),zB(),LB(),Rw(),$H={ConeGeometry:uwe,CubeGeometry:dwe,CylinderGeometry:JY,DodecahedronGeometry:cwe,EllipseGeometry:FB,HelixGeometry:Wxe,IcosahedronGeometry:Uwe,LatheGeometry:zwe,NonParametricGeometry:Vwe,PolygonGeometry:sK,PyramidGeometry:Gwe,RectangleGeometry:UB,SphereGeometry:Hwe,PlaneGeometry:qwe,BackdropGeometry:$we,StarGeometry:aK,TextFrameGeometry:Xwe,TorusGeometry:Ywe,TorusKnotGeometry:Kwe,TriangleGeometry:Zwe,VectorGeometry:l0},oO=e=>{let t=$H[e.type]??Ixe(e.type);if(t===void 0)throw new Error(`No geometry factory registered for "${e.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(e)}});function Fg(e,t,i,r){let n,s,a;e.type==="PathGeometry"?(s={...e,extrusion:{...e.extrusion}},a=[[],["extrusion"]]):(s={...e},a=[[]]);for(let h of a){let u=s;for(let d of h)u=u[d];for(n in u){let d=u[n];eH(d)&&!nSe.includes(n)&&(u[n]=t.getVariable(d,[r.uuid,"geometry",...h,n]),eH(u[n])&&(u[n]=1))}}let o,l={parameters:s,type:s.type};if(s.type==="PathGeometry"){l.path=s.path;let h=r.profileShape;h!==void 0&&(l.shapeData=h),l.ownerId=r.uuid}else if(s.type==="VectorGeometry"){let h=cs.createFromState(s.shape,s.width,s.height);l.shape=h,l.ownerId=r.uuid}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),l.geometry=new sY().parse(s),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(s.type==="SubdivGeometry"){let h=new us(s,i);return h.data=e,h}if(s.type==="TextGeometry"||s.type==="InputGeometry"){let h=Ixe(s.type);if(h)return h.create(s,t);Ta("text",`a ${s.type}`);let u=cs.createFromState(hw.defaultData(),100,100);return oO({...s,shape:u,type:"VectorGeometry"})}if(s.type==="UIGeometry")return UB.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}try{o=oO(l)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${l}`);let u=cs.createFromState(hw.defaultData(),100,100);l.shape=u,l.type="VectorGeometry",o=oO(l)}return o}var nSe,kB=F(()=>{Ot(),ne(),rSe(),vr(),p4(),o0(),Dw(),nSe=["font"]});function XH(e){switch(typeof e){case"number":return Number.isFinite(e)?JSON.stringify(e):void 0;case"boolean":return JSON.stringify(e);case"string":return eH(e)?void 0:JSON.stringify(e);case"object":{if(e===null)return"null";if(Array.isArray(e)){let n="[";for(let s=0;s<e.length;s++){let a=XH(e[s]);if(a===void 0)return;n+=(s>0?",":"")+a}return n+"]"}let t=e,i="{",r=!0;for(let n of Object.keys(t).sort()){if(t[n]===void 0)continue;let s=XH(t[n]);if(s===void 0)return;i+=`${r?"":","}${JSON.stringify(n)}:${s}`,r=!1}return i+"}"}default:return}}var sSe,Rre,YH,aFe=F(()=>{Ot(),sSe=new Set(["CubeGeometry","SphereGeometry","CylinderGeometry","ConeGeometry","TorusGeometry","TorusKnotGeometry","IcosahedronGeometry","DodecahedronGeometry","PyramidGeometry","PlaneGeometry","BackdropGeometry","HelixGeometry"])}),oFe=F(()=>{kB(),aFe(),Rre=class{constructor(){this.objects=new Map,this.refs=new Map,this.sharedByKey=new WeakSet,this.unreachable=new Set}resolveObject(e,t,i){return this.createObject(e,t,i)}onObjectDisposed(e){}getCached(e){return this.objects.get(e)}get size(){return this.objects.size}get(e,t,i){let r=this.objects.get(e);return r===void 0?(r=this.resolveObject(e,t,i),this.objects.set(e,r),this.retain(r)):(this.sharedByKey.add(r),r.isShared=!0),r}forceDelete(e){let t=this.objects.get(e);t&&(this.objects.delete(e),this.release(t))}adopt(e,t){this.replace(e,t),this.retain(t)}mutateIfUnique(e,t){let i=this.objects.get(e);if(i&&i.isShared!==!0)return this.objects.delete(e),this.replace(t,i),i}replace(e,t){let i=this.objects.get(e);this.objects.set(e,t),i!==void 0&&i!==t&&this.release(i)}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(e,t){t===this.objects.get(e)&&this.unreachable.delete(e)}endGc(){this.unreachable.forEach(e=>{let t=this.objects.get(e);this.objects.delete(e),this.release(t)}),this.unreachable.clear()}dispose(){new Set(this.objects.values()).forEach(e=>{this.disposeObject(e),this.onObjectDisposed(e)}),this.objects.clear(),this.refs.clear()}retain(e){let t=(this.refs.get(e)??0)+1;this.refs.set(e,t),t>1&&(e.isShared=!0)}release(e){let t=(this.refs.get(e)??1)-1;if(t>0)return this.refs.set(e,t),void(t===1&&!this.sharedByKey.has(e)&&(e.isShared=!1));this.refs.delete(e),this.disposeObject(e),this.onObjectDisposed(e)}},YH=class extends Rre{constructor(e){super(),this.flatShading=e,this.dedupeByValue=!1,this.byValue=new Map,this.valueKeyOf=new Map}disposeObject(e){e.dispose()}createObject(e,t,i){let r=Fg(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}resolveObject(e,t,i){let r=this.dedupeByValue?function(s,a,o){if(!sSe.has(s.type))return;let l=s;if(l.shapeBlendNode!=null||o.isTransientGeometryKey(s))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=s.type;for(let c of Object.keys(l).sort()){let p=l[c];if(p===void 0||c==="type")continue;let f=XH(p);if(f===void 0)return;d+=`|${c}=${f}`}return d}(e,i,t):void 0;if(r!==void 0){let s=this.byValue.get(r);if(s!==void 0)return s}let n=this.createObject(e,t,i);return r!==void 0&&(this.byValue.set(r,n),this.valueKeyOf.set(n,r)),n}mutateIfUnique(e,t){let i=super.mutateIfUnique(e,t);return i!==void 0&&this.forgetValue(i),i}onObjectDisposed(e){this.forgetValue(e)}forgetValue(e){let t=this.valueKeyOf.get(e);t!==void 0&&(this.valueKeyOf.delete(e),this.byValue.get(t)===e&&this.byValue.delete(t))}}});function f4(){return mC}function aSe(){if(mC==="webgpu"){if(ZH!==void 0)return ZH;JH||(JH=!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(QH===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 QH}function oSe(e,t){return aSe().createRootMaterial(e,t)}function Dre(e,t,i){return aSe().createSharedMaterial(e,t,i)}function Nre(e){return e.getLayersOfType===void 0&&Object.assign(e,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),e}function KH(){return hSe}var mC,ZH,QH,JH,eq,lSe,hSe,tq,uSe,Qf=F(()=>{mC="webgl",JH=!1}),lFe=F(()=>{uSe={markNeedsUpdateRendererDirty:()=>{}}});function Ire(e){return e.data.type!=="displace"&&!!e.data.isMask}function vu(e,t){let i=0;if(!e.layers||e.layers.length===0)return!1;let r=e.layers?.find(s=>s.data.type==="light");if(r){let s=r.data,a=Number(t.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?a/100:s.alphaOverride)<1)return!0}let n=e.layers;for(let s=0;s<n.length;s++){let a=n[s];if(!Ire(a)){if(s>0&&Ire(n[s-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(t.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=t.color(a.data.colorA).a,h=t.color(a.data.colorB).a,u=t.color(a.data.colorC).a,d=t.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 gC=F(()=>{});function dSe(e,t){return e==="displace"?t==="intensity":t==="alpha"}function cSe(e,t,i){let r=e==="alpha"?Math.max(0,Math.min(Number(t)/100,1)):Number(t);return i?r:0}function Hf(e){return typeof e=="string"||typeof e=="number"&&e!==0}var Ih,Nt,Hc,wd,Nw,hK,Ore,Lre,Ko,Md=F(()=>{ne(),Ih=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?100*e:e,i)??100)/100))??1,Nt=(e,t,i)=>typeof e=="number"?e:t.getVariable(e,i),Hc=(e,t)=>(e||(e=new P),e.x=Nt(e.x,t)??0,e.y=Nt(e.y,t)??0,e.z=Nt(e.z,t)??0,e),wd=(e,t)=>(e||(e=new Z),e.x=Nt(e.x,t)??0,e.y=Nt(e.y,t)??0,e),Nw={noise:["noiseType"],texture:["projection","axis","projectionAxis","uvChannel","side"],video:["projection","axis","projectionAxis","uvChannel","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"]},hK={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),Iw=F(()=>{ne(),Pw(),Yn(),Ore=class extends NB(ln){},Lre=e=>e.type==="Mesh",Ko=class extends Ore{constructor(e){super(),this.object=e,this.isClone=!0,this.matrixAutoUpdate=!1}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];(!(i instanceof Ko)||i.object!==t)&&(i=new Ko(t),this._replaceChildAt(e,i),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.shearMatrix=t.shearMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(let i of this.object.children){if(!Lg(i)||i.object.parent!==this.object)continue;let r=this.children[e];r?.source!==i&&(r=i.createCopy(),this._replaceChildAt(e,r)),r.expand(),e+=1}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}_replaceChildAt(e,t){let i=this.children[e];i&&this.remove(i),this.add(t),this.children.splice(e,0,this.children.pop())}get visible(){let e=this.parent,t=Lg(e)&&e.object===this.object;return(!t||!e.instancingActive&&!e.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||t&&this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return Lre(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}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(e){}}});function Bre(){return uK}var uK,dK,cK=F(()=>{uK=null,dK=null});function iq(e){return"variable_"+e}var Q5,J5,ez,Fre,tz,Ure,iz,zre,m4,pK=F(()=>{Ot(),twe(),awe(),BB(),xu(),KY(),QY(),oFe(),Qf(),rwe(),lFe(),gC(),Md(),bl(),Iw(),Ir(),ne(),cK(),vr(),Q5=new De,J5=new P,ez=new Vt,Fre=new P,tz=new Rr,Ure=class extends Qxe{constructor(e){super(),this.shared=e}create(e){return new YY(e,this.shared)}},iz=new Set,(m4=zre=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new YH(!0),this.geometryCache2=new YH(!1),this.imageHolderCache=new Ure(this),this.thisContext={scene:uSe,shared:this},this.deletedImage=new Pc(HL.emptyImage,this),this.deletedVideo=new Pc(qL.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,t.images)for(let[n,s]of Object.entries(t.images))this.addImage(n,s);if(t.videos)for(let[n,s]of Object.entries(t.videos))this.addVideo(n,s);if(t.audios)for(let[n,s]of Object.entries(t.audios))this.addAudio(n,s);if(t.particles)for(let[n,s]of Object.entries(t.particles))this.addParticle(n,s);this.reset(e)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=Dre(Un.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:r,data:n}of e.variables)this.addVariableHolder(r,n),t&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(e.userAPIs??{}))this.addUserAPI(r,n);for(let[r,n]of Object.entries(e.userWebhooks??{}))this.addUserWebhook(r,n);if(!i){for(let[r,n]of Object.entries(e.images))this.addImage(r,n);for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n)}for(let[r,n]of Object.entries(e.colors))this.addColor(r,n);for(let[r,n]of Object.entries(e.lib.materials))this.addMaterial(r,n.asset);for(let[r,n]of Object.entries(e.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(e.particles))this.addParticle(r,n);for(let[r,n]of Object.entries(e.fonts))this.addFont(r,n)}addMaterial(e,t){if(t=Un.withRepairedLayers(t),this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=Dre(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):e==null?(console.error("material is undefined or null"),this.deletedMaterial):oSe(Un.withRepairedLayers(e),this.thisContext)}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new Pc(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new Pc(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}getEntityTexture(e,t={}){let i=e.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let n=r.root??r;for(let s of n?.data?.layers??[]){let a=s?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||t.layer!==void 0&&s.id!==t.layer&&a.type!==t.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:s.id,layerType:a.type}}}return null}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new Pc(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return typeof e=="string"?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):(this.colors[e]=new WA(t.r,t.g,t.b,"a"in t?t.a:1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if(typeof e!="string")return new Ur(e.r,e.g,e.b,"a"in e?e.a:1);{let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Ur(0,0,0,0))}return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof ux)return t;{let i=new ux({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof ux&&t.dispose(),delete this.audios[e])}addFont(e,t){let i=ZY;i!==null?(this.fonts[e]=new i(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())):Ta("text","a font asset")}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof ux&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(this.variables[e]===void 0){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(iq(e));i=r!==null?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)this.variables[e].dynamicVariablePlayState!==void 0&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(this.variables[e]===void 0)return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(iq(e),JSON.stringify(t));let i=t;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,n=!1;for(let s=this.variables[e].locations.length-1;s>=0;s--){let a=this.variables[e].locations[s];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[e].locations.splice(s,1);continue}if(n=!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*Qe.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),tr.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 n&&r.markShadowsDirty(),this.requestRender(),!0}isTransientGeometryKey(e){return this.transientGeometryKeys.has(e)}updateEntityGeometryParams(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||typeof n.type!="string"||n.type==="VectorGeometry"||n.type==="PathGeometry")return!1;let s=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let h of Object.keys(n))a.set(s(h),h);let o={};for(let[h,u]of Object.entries(t??{})){let d=a.get(s(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=n[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={...n,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(n)&&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(e){let t=e;if(t.component&&(t=t.component),typeof t.chooseGeoemtryCache!="function")return!1;let i=t.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(t.dataPatched=t.data,t.chooseGeoemtryCache(this).forceDelete(i),t.createGeometryDelayed(this.entityOpContext),t.onVariableUpdate(!0),t.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(e,t){let i=e;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,n=r?.geometry;if(!n||n.type!=="NonParametricGeometry")return!1;let s=t?.vertices;if(s===void 0||typeof s.length!="number"||s.length<9||s.length%3!=0||s.length/3>zre.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,h=s instanceof Float32Array?s:Float32Array.from(s),u=h.length/3;if(t.normals!==void 0){if(t.normals.length!==h.length)return!1;a=t.normals instanceof Float32Array?t.normals:Float32Array.from(t.normals)}if(t.uvs!==void 0){if(t.uvs.length!==2*u)return!1;o=t.uvs instanceof Float32Array?t.uvs:Float32Array.from(t.uvs)}if(t.indices!==void 0){let x=u>65535?Uint32Array.from(t.indices):Uint16Array.from(t.indices);if(x.length===0||x.length%3!=0)return!1;for(let w=0;w<x.length;w++)if(x[w]>=u)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=n.data,w=x?.index;if(w?.array?.length){let S=(x?.attributes?.position?.array?.length??0)/3;if(u!==S)return function(T,M){let E=`${T}/${M}`;iz.has(E)||(iz.add(E),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${M}. 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,S),!1;l=w}}let d=1/0,c=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;for(let x=0;x<h.length;x+=3){let w=h[x],S=h[x+1],T=h[x+2];w<d&&(d=w),w>f&&(f=w),S<c&&(c=S),S>m&&(m=S),T<p&&(p=T),T>g&&(g=T)}let v=(x,w)=>({array:x,itemSize:w,type:"Float32Array",normalized:!1}),y={position:v(h,3)};a&&(y.normal=v(a,3)),o&&(y.uv=v(o,2));let _={...n,width:f-d,height:m-c,depth:g-p,data:{attributes:y,...l?{index:l}:{}}},b=this.transientGeometryKeys.has(n);return i.dataPatched={...r,geometry:_},this.transientGeometryKeys.add(_),i.applyTransientGeometryData(this.entityOpContext,b),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(e,t){let i=e;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let n=r.children,s=Math.PI/180,a=!1;if(t===null)for(let o of n)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(t))return n.length;{let o=Math.min(t.length,n.length);for(let l=0;l<o;l++){let h=t[l],u=n[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*s),typeof h.rotation.y=="number"&&(d.rotation[1]=h.rotation.y*s),typeof h.rotation.z=="number"&&(d.rotation[2]=h.rotation.z*s)),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(),n.length}spawnRuntimeClone(e,t={}){if(typeof e.entityChildren!="function")return;let i=e.parent;if(i===null)return;let r=new Ko(e);r.playModeVisible=t.visible!==!1,r.expand(),typeof t.name=="string"&&(r.name=t.name);let n=Math.PI/180;return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),r.shearMatrix.copy(e.shearMatrix),t.position&&(typeof t.position.x=="number"&&(r.position.x=t.position.x),typeof t.position.y=="number"&&(r.position.y=t.position.y),typeof t.position.z=="number"&&(r.position.z=t.position.z)),t.rotation&&(typeof t.rotation.x=="number"&&(r.rotation.x=t.rotation.x*n),typeof t.rotation.y=="number"&&(r.rotation.y=t.rotation.y*n),typeof t.rotation.z=="number"&&(r.rotation.z=t.rotation.z*n)),t.scale&&(typeof t.scale.x=="number"&&(r.scale.x=t.scale.x),typeof t.scale.y=="number"&&(r.scale.y=t.scale.y),typeof t.scale.z=="number"&&(r.scale.z=t.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(e){e.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(e,t){let i=e.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 n={scene:this.entityOpContext.scene,shared:this},s=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=h=>{if(typeof h=="string"){let u=new Ur(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 WA?h.setValue(u,new Ur(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(t.color!==void 0){let c=a(t.color),p=u.find(m=>m.data.type==="color"),f=p&&d(p.id);if(c&&f&&o(f,"color",c)&&(l=!0,c.a!==void 0)){let m=c.a<1||vu(h.data,this);h.setTransparent?h.setTransparent(m,n.scene):h.transparent=m}}typeof t.alpha=="number"&&isFinite(t.alpha)&&(h.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(t.alpha,100)),n),l=!0);for(let c of t.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?u.find(v=>v.id===c.id):typeof c.index=="number"?u[c.index]:typeof c.type=="string"?u.find(v=>v.data.type===c.type):void 0,f=p&&d(p.id);if(!p||!f)continue;let m=Nw[p.data.type]??[],g=Object.keys(p.data);for(let[v,y]of Object.entries(c)){if(v==="id"||v==="index"||v==="type")continue;let _=g.find(x=>x===v)??g.find(x=>s(x)===s(v))??v;if(m.includes(_))continue;let b=a(y);if(b&&o(f,_,b))l=!0;else if(typeof y=="number"&&isFinite(y))h.onVariableUpdate?.(["layer",p.id,_],y,n),l=!0;else if(Array.isArray(y)&&y.length<=3&&y.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];y.forEach((w,S)=>{h.onVariableUpdate?.(["layer",p.id,_,x[S]],w,n)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(e){this.variables[e]&&delete this.variables[e]}referencesMissingObject(e){return Array.isArray(e)&&e[0]!=="mouse"&&e[0]!=="raycast"&&this.entityOpContext.scene.find(e[0])===void 0}getVariable(e,t){if(Array.isArray(e)){if(e[0]==="mouse")return this.mouseProperty?.[e[1]]??0;if(e[0]==="raycast")return this.raycastProperty?.[e[1]]??0;let i=this.entityOpContext.scene.find(e[0]);if(i===void 0)return;if(e[1]==="width"||e[1]==="height"||e[1]==="depth")return i.geometry.userData.parameters[e[1]];if((e[1]==="position"||e[1]==="rotation")&&e.length>2&&i?.getPhysicsLocalMatrix?.(Q5))return Q5.decompose(J5,ez,Fre),e[1]==="position"?J5[e[2]]:(tz.setFromQuaternion(ez,i.rotation.order),tz[e[2]]*Qe.RAD2DEG);for(let r=1;r<e.length;r++)i=i[e[r]];return e[1]==="rotation"&&(i*=Qe.RAD2DEG),i}for(let i in this.variables){if(t===void 0)break;let r=this.variables[i],n=r.locations?.findIndex(s=>Sa.equal(s,t));n!==void 0&&n!==-1&&r.locations.splice(n,1)}if(typeof e=="string"){let i=e,r=e;do{if(r=i,this.variables[i]===void 0)break;let n=this.variables[i].value;t&&this.variables[r]!==void 0&&this.variables[r].locations.push(t),i=n}while(typeof i=="string");return i}return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){return this.variables[e]?.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){return this.variables[e]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){e.path[0]==="images"?e.path.length===1&&e.type===1?this.addImage(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteImage(e.id):e.path[0]==="videos"?e.path.length===1&&e.type===1?this.addVideo(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVideo(e.id):e.path[0]==="audios"?e.path.length===1&&e.type===1?this.addAudio(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteAudio(e.id):e.path[0]==="particles"?e.path.length===1&&e.type===1?this.addParticle(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteParticle(e.id):e.path[0]==="colors"?e.path.length===1&&e.type===1?this.addColor(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteColor(e.id):e.path[0]==="materials"?e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteMaterial(e.id):e.path[0]==="fonts"?e.path.length===1&&e.type===1?this.addFont(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteFont(e.id):e.path[0]==="variables"?e.path.length===1&&e.type===1?this.addVariableHolder(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVariable(e.id):e.path[0]==="components"&&t.updateByLibOp(e,this)}updateByOp(e,t,i){if(this.data=t,e.path[0]==="images")e.path.length===2&&e.type===0?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addImage(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteImage(e.id);else if(e.path[0]==="videos")e.path.length===2&&e.type===0?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addVideo(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteVideo(e.id);else if(e.path[0]==="audios")e.path.length===2&&e.type===0?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):e.path.length===1&&e.type===1?this.addAudio(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteAudio(e.id);else if(e.path[0]==="particles")e.path.length===2&&e.type===0?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):e.path.length===1&&e.type===1?this.addParticle(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteParticle(e.id);else if(e.path[0]==="colors")e.path.length===2&&e.type===0?this.updateColor(e.path[1],e.props):e.path.length===1&&e.type===1?this.addColor(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteColor(e.id);else if(e.path[0]==="materials")e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data):e.path.length===1&&e.type===2?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(Ha.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if(e.path[0]==="fonts")e.path.length===2&&e.type===0?this.updateFont(e.path[1],e,i):e.path.length===1&&e.type===1?this.addFont(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteFont(e.id);else if(e.path[0]==="variables")e.path.length===2&&e.type===0?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):e.path.length===1&&e.type===4?this.addVariableHolder(e.id,e.data):e.path.length===1&&e.type===5&&this.deleteVariable(e.id);else if(e.path[0]==="userAPIs"){if(e.path.length===1&&e.type===1)this.addUserAPI(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserAPI(e.id);else if(typeof e.path[1]=="string"){let r=t.userAPIs[e.path[1]];if(r){let n=e.type===0&&e.props.debounce===void 0,s=this.getUserAPI(e.path[1]);s!==void 0&&s===this.openAIRealtime?s.update(r):s?.update(r,this,n)}}}else if(e.path[0]==="userWebhooks"){if(e.path.length===1&&e.type===1)this.addUserWebhook(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserWebhook(e.id);else if(typeof e.path[1]=="string"){let r=t.userWebhooks[e.path[1]];r&&this.getUserWebhook(e.path[1])?.update(r)}}else e.path[0]==="lib"&&this.updateLibByOp(Ha.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),n={...this.data.fonts[e],url:t.props.url};r.update(n),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){if(this.userAPIs[e])return this.userAPIs[e].update(t,this),!0;if(this.openAIRealtime?.id===e)return this.openAIRealtime.update(t),!0;if(t.integration?.type==="VoiceAssistant"){let i=dK;return i===null?(Ta("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(t,e,this),!1)}{let i=Bre();return i===null?(Ta("api-services","a user API integration"),!1):(this.userAPIs[e]=i.createUserAPI(e,t,this),!1)}}getUserAPI(e){return this.openAIRealtime?.id===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){if(this.userWebhooks[e])return this.userWebhooks[e].update(t),!0;{let i=Bre();return i===null?(Ta("api-services","a user webhook"),!1):(this.userWebhooks[e]=i.createUserWebhook(e,t),!1)}}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new m4(fu.emptyData())});function g4(e){return Xxe(e)||e?.isTSLNodeMaterial===!0}function kre(e){return function(t){return t?.isClassicSharedMaterial===!0}(e)||e?.isTSLSharedMaterial===!0}function pSe(e){let t=e?.root;return kre(e)||t!==void 0&&kre(t)}var _l,rz,nz,sz,Vre,az,hp,Gre,jre,tT,wn,fK=F(()=>{ewe()}),v1=F(()=>{Ot(),Da(),Qf(),fK(),Ir(),la(),_l=class extends Fs{setMaterialOverride(e,t){this.materialOverride=Nre(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),t.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),Zr(e.path,["geometry"])&&this.syncShadowCatcher(i),function(r,n){let s=[];if(n.length!==r.length)return null;{let a=0;for(;a<r.length;){if(n[a]==="*")s.push(r[a]);else if(r[a]!==n[a])return null;a+=1}}return s}(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[r,n]of Object.entries(e.props)){let s=this.material[Number(r)],a=i.shared.material(n);a!==s&&_l.disposeOneMaterial(s),this.material[Number(r)]=a}else if(Zr(e.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in t&&typeof t.material!="string"&&r.updateByOp(Ha.drop(e,1),t.material,i)}else if(Zr(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&r<this.material.length){let n=t.materials[r];typeof n!="string"&&this.material[r].updateByOp(Ha.drop(e,2),n,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(e,t){super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.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 n=this.materialOverride!==void 0;!n&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe,i),t.scene.markNeedsUpdateRendererDirty()),!n&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(a=>t.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe)],t.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!n&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(s.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!n&&(e.flatShading!==void 0||e.wireframe!==void 0||e.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(t)}shadowCatcherActive(){let e=this.dataPatched,t=e.geometry?.type;return e.shadowCatcher===!0&&(t==="RectangleGeometry"||t==="PlaneGeometry")}syncShadowCatcher(e){let t=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=mC==="webgpu"&&eq!==void 0?eq:lSe;return r===void 0?null:Nre(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=t.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.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,e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.material=e.shared.material(t.material).getFlavor(t.flatShading,t.side,t.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow)}static disposeOneMaterial(e){g4(e)&&!pSe(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&rbe(this.material).forEach(e=>{_l.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),xl=F(()=>{Ot(),Ir(),pK(),v1(),ne(),kB(),Rw(),Dw(),tSe(),rz=new P,nz=new ut,sz=new ut,Vre=new P,az=new De,hp=new Sr,Gre=hp.geometry,jre=hp.material,tT=new P,wn=class extends _l{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new De().fromArray(t.bindMatrix),this.bindMatrixInverse=new De)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Mt&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof Mt?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof m4){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=t.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return YL.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return YL.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Zr(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Ha.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var e;super.dispose(),e=this.uuid,d4.delete(e),this._posed=void 0}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(e!==void 0&&e.sxPrev!==void 0)return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,n,s,a=e;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=Fg(d,t,this.data.flatShading,this)}a.scaleBaked?[r,n,s]=a.scaleBaked:{width:r,height:n,depth:s}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,h=typeof n=="number"?n:1,u=typeof s=="number"?s:1;o.sxPrev!==void 0&&HH(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(e)){let r=Fg(i==="VectorGeometry"?KL.merge(this.data.geometry,e):{...this.data.geometry,...e},t,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&$5(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(e){let t=this.localGeometry;if(t?.shiftDepthTo===void 0)return!1;let i=e;if(typeof i.depth!="number")return!1;let r=t.userData?.parameters;if(r===void 0)return!1;for(let n of Object.keys(i))if(n!=="depth"&&i[n]!==r[n])return!1;return!!t.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(e){for(let t of this.attachedSurfaceCloners)t.update(e)}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){let r=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&iSe(e.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(t),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof Mt&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=i.shared,s=this.chooseGeoemtryCache(n),a=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=Fg(o,n,this.data.flatShading,this);$5(a,l)?(l.dispose(),a.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.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(e,t){this.createGeometryDelayed(t)}applyTransientGeometryData(e,t){let i=e.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof Mt&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let n=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let a=Fg(r,i,this.data.flatShading,this);return $5(s,a)?(a.dispose(),s.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(e),void this.refreshAttachedPaths(e)}}t&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:n}}of i)this.updateMorphInfluences(r,t.shared.getVariable(n,[this.uuid,"morphTargetInfluences",r]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=t)}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(e,t){let i=this.posedGeometry()?.boundingBox;if(i)return i.getCenter(e),void i.getSize(t).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,.5*r.depth):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?e.fromArray(r.centerOffset):e.setScalar(0),t.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}rebindSkeleton(e){let t=this.dataPatched,i=t.bones?.map(e),r=this.isSkinnedMesh;if(!i?.length||i.some(n=>!n)||t.boneInverses?.length!==i.length?this.isSkinnedMesh=!1:(this.bindMatrix||(this.bindMatrix=new De,this.bindMatrixInverse=new De),this.bindMode=t.bindMode??"attached",t.bindMatrix&&this.bindMatrix.fromArray(t.bindMatrix),this.bind(new EA(i,t.boneInverses.map(n=>new De().fromArray(n))),this.bindMatrix)),r!==this.isSkinnedMesh)for(let n of Array.isArray(this.material)?this.material:[this.material])n.needsUpdate=!0}normalizeSkinWeights(e){let t=new ut,i=this.geometry.attributes.skinWeight;for(let r=0,n=i.count;r<n;r++){t.fromBufferAttribute(i,r);let s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),i.setXYZW(r,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;nz.fromBufferAttribute(r.attributes.skinIndex,e),sz.fromBufferAttribute(r.attributes.skinWeight,e),rz.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){let s=sz.getComponent(n);if(s!==0){let a=nz.getComponent(n);az.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(Vre.copy(rz).applyMatrix4(az),s)}}return t.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(e,t){let i=this.posedGeometry();if(i===void 0)return!1;hp.geometry=i,hp.material=this.material,hp.matrixWorld.copy(this.matrixWorld);let r=t.length;hp.raycast(e,t);for(let n=r;n<t.length;n++)t[n].object=this;return hp.geometry=Gre,hp.material=jre,!0}posedGeometry(){let e=this.skeleton;if(!this.isSkinnedMesh||e===void 0)return;let t=this.geometry,{position:i,skinIndex:r,skinWeight:n}=t.attributes;if(!i||!r||!n)return;let s=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<e.bones.length;d++){let c=e.bones[d];if(!c||!e.boneInverses[d])return;s.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===t&&a.version===i.version&&a.pose.length===s.length&&a.pose.every((d,c)=>d===s[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,h=l?.count===o?l:new Pt(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,tT)),h.setXYZ(d,tT.x,tT.y,tT.z);let u=new Mt;u.setAttribute("position",h);for(let d of["normal","uv","uv1"]){let c=t.attributes[d];c&&u.setAttribute(d,c)}return u.setIndex(t.index),u.groups=t.groups,u.drawRange=t.drawRange,u.computeBoundingSphere(),u.computeBoundingBox(),this._posed={source:t,version:i.version,pose:s,geometry:u},u}}});function Lx(e){if(Array.isArray(e.material)){for(let t of e.material)if(t.getLayersOfType("outline").length===0)return}else if(!Xxe(e.material)||e.material.getLayersOfType("outline").length===0)return;e instanceof wn&&e.is2DAndNoDepth?function(t){if(t.geometry.attributes.extrudeNormals||!t.geometry.attributes.position)return;let i=t.geometry.attributes.position.array,r=new Float32Array(i.length),n=new P;for(let s=0;s<i.length;s+=3)n.set(i[s],i[s+1],i[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;t.geometry.setAttribute("extrudeNormal",new Tt(r,3))}(e):function(t){if(t.geometry.attributes.extrudeNormal||!t.geometry.attributes.position||!t.geometry.attributes.normal)return;let i=new Map,r=t.geometry.attributes,n=r.position.array,s=r.normal.array,a=new Float32Array(n.length);for(let o=0;o<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,h=new P(s[o],s[o+1],s[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<n.length;o+=3){let l=`${n[o]}_${n[o+1]}_${n[o+2]}`,h=i.get(l)?.result;h&&(a[o]=h.x,a[o+1]=h.y,a[o+2]=h.z)}t.geometry.setAttribute("extrudeNormal",new Tt(a,3))}(e)}function oz(e){return Math.min(2047,Math.max(1,Math.round(2048*e)))/2048}function Bx(e){if(!e.geometry.attributes.position)return;let t=e.geometry.attributes,i=t.position.array,r=t.randomColor;if(r!==void 0&&3*r.count===i.length)return;let n=new Float32Array(i.length),s=parseInt(e.uuid.replace(/\D/g,"")),a=[oz(Qe.seededRandom(s)),oz(Qe.seededRandom(s+1e4)),oz(Qe.seededRandom(s+2e4))];for(let o=0;o<i.length;o++)n[o]=a[o%3];e.geometry.setAttribute("randomColor",new Pt(n,3))}var VB=F(()=>{ne(),ewe(),xl()});function Wre(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}function hFe(e,t){let i=e.cloner;return i!==void 0&&i.parent===t?i:void 0}function Hre(e,t,i,r){let n=16*(t.children.length+1);QM.length<n&&(QM=new Float32Array(n));let s=0,a=l=>{l.toArray(QM,16*s),s++},o=t.parameters.hideBase!==!0;o&&a(r),rq.copy(e.matrix);for(let l of t.children)!Bg(l)||l.playModeVisible===!1||(nq.copy(l.matrix).multiply(l.pivotMatrix),lO.multiplyMatrices(rq,nq),(!o||!lO.equals(r))&&a(lO));try{return s===0?0:function(l,h){return $Y(a4().instanced_union(qY(l),h))}(i,QM.subarray(0,16*s))}finally{Hxe(i)}}var up,qre,rq,nq,lO,QM,qg,vC=F(()=>{Da(),ne(),LB(),VB(),v1(),Yn(),up=new De,qre=new De,rq=new De,nq=new De,lO=new De,QM=new Float32Array(0),qg=class extends _l{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new Mt,this.onAfterRender=(r,n,s,a,o,l)=>{super.onAfterRender(r,n,s,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(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let r=0;r<this.children.length;r++){let n=this.children[r];n instanceof qg&&n.dataPatched.visible===!0&&n.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let n=this.children[r];if(n instanceof Fs&&n.dataPatched.visible===!0&&n.geometry.attributes.position?.count>0&&n.geometry.drawRange.count>0&&n.booleanMeshSetAddress!==0){up.copy(n.matrix).multiply(n.pivotMatrix);try{let s=hFe(n,this);if(n.booleanMeshSetAddress===-1){if((n.geometry.index??n.geometry.getAttribute("position")).count/3<15e5){let a=NBe(n.geometry,e===!0);n.booleanMeshSetAddress=s===void 0||a===-1?a:Hre(n,s,a,up)}if(n.booleanMeshSetAddress===-1)return;s===void 0&&F5(n.booleanMeshSetAddress,up),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1}else n instanceof qg&&n.needsTransformForDownstream===!0?(s===void 0?F5(n.booleanMeshSetAddress,up):n.booleanMeshSetAddress=Hre(n,s,n.booleanMeshSetAddress,up),n.needsTransformForDownstream=!1):n.booleanWasTransformed===!0&&(F5(n.booleanMeshSetAddress,qre.multiplyMatrices(up,n.booleanMatrixInvOld)),n.booleanMatrixInvOld.copy(up).invert(),n.booleanWasTransformed=!1)}catch(s){console.error(s),n.booleanMeshSetAddress=0,n.geometry.userData.booleanOperationDidFail=!0;continue}if(n.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(n.booleanMeshSetAddress),n.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 Mt,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new Tt([],3))}return void this.geometry.setDrawRange(0,0)}if(e===!0)return function(r,n){let s=a4(),a=Lie(r,n),o=s.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 Mt,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,n,s,a){let o=a4(),l=Lie(r,n),h=o.mesh_render_data(l,Math.max(a,0));if(s.setAttribute("position",new Tt(h.positions(),3)),s.setAttribute("normal",new Tt(h.normals(),3)),h.free(),s.boundingSphere===null&&(s.boundingSphere=new ja),l.tri_count()===0)s.boundingSphere.center.set(0,0,0),s.boundingSphere.radius=0,s.userData.parameters={width:0,height:0,depth:0};else{let u=l.bounds();s.boundingSphere.center.set(u[0],u[1],u[2]),s.boundingSphere.radius=(u[3]**2+u[4]**2+u[5]**2)**.5,s.userData.parameters={width:2*u[3],height:2*u[4],depth:2*u[5]}}return $Y(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,Lx(this),Bx(this)}dispose(){super.dispose(),this.geometry.dispose()}}});function uFe(e){return e.isPointLight?hO.PointLight:e.isSpotLight?hO.SpotLight:hO.DirectionalLight}function $re(e){return e.isDirectionalLight?0:e.isSpotLight?1:2}function fSe(e){Hv.length=0,e.traverseVisible(r=>{(function(n){let s=n;return s.isPointLight===!0||s.isSpotLight===!0||s.isDirectionalLight===!0})(r)&&(r.castShadow===!0||$E.has(r))&&Hv.push(r)});let t=!1;if(Hv.length===0)return t;Hv.sort((r,n)=>$re(r)-$re(n)||r.id-n.id);let i=12;for(let r of Hv){let n=uFe(r);n<=i?(i-=n,$E.delete(r)&&(r.castShadow=!0,t=!0)):r.castShadow===!0&&(r.castShadow=!1,$E.add(r))}return Hv.length=0,t}var hO,$E,Hv,v4,GB,gd,Bc,y4,mK=F(()=>{hO={PointLight:1,SpotLight:3,DirectionalLight:3},$E=new WeakSet,Hv=[]}),yC=F(()=>{ne(),mK(),bl(),g1(),(v4||(v4={})).is=function(e){return tr.is(e)&&e instanceof qp},GB=(e,t)=>class extends m1(e,t){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 n=this.shadow;n.camera.far=i.depth,n.needsUpdate=!0}i.shadows!==void 0&&(function(n){$E.delete(n)}(this),this.castShadow=i.shadows)}}}),h0=F(()=>{vC(),Da(),g1(),gd=e=>e instanceof Fs,Bc=e=>e!==null&&e instanceof qg,y4=e=>AH.is(e)});function fo(e,t){return t.color(e)}function Xre(e=new Date,t){let i=t.format,r=e.getSeconds(),n=e;t&&t.timeZone!==null&&(n=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),f=m=>Number(p.find(g=>g.type===m)?.value);return new Date(f("year"),f("month")-1,f("day"),f("hour"),f("minute"),f("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,t.timeZone));let s,a=n.getHours(),o=n.getMinutes();t.format12h24h==="12ampm"&&(s=a>=12?"PM":"AM");let l,h,u=a;switch(t.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],s=void 0;break;case"mm":l=[o],s=void 0;break;case"ss":l=[r],s=void 0;break;case"year":h=n.getFullYear();break;case"month":h=n.getMonth()+1;break;case"dayOfYear":h=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":h=n.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:s}:h}var sq,Ow,gK=F(()=>{}),dFe=F(()=>{ne(),dC(),cC(),sq=class extends Ew(T_e){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Aw(this.object,sq.geometryHelper,e,t)}}}),jB=F(()=>{ne(),dFe(),yC(),Ow=class extends GB(PA,sq){constructor(e,t,i){super(),this.super_Entity(e,t),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 n=new RA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof RA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&function(r,n){r.shadow.camera.right=n/2,r.shadow.camera.left=-n/2,r.shadow.camera.top=n/2,r.shadow.camera.bottom=-n/2,r.shadow.needsUpdate=!0}(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}}});function vK(e){return e instanceof _l&&e.needsAO&&!Yf(e)&&e.isDecalObject!==!0}function yK(e){let t=e.cloner;if(t&&Array.isArray(t.children))for(let i of t.children)i?.layers&&(i.layers.mask=e.layers.mask)}function _K(e){return e.getLayersOfType("reflection").filter(t=>t.data.visible).length}function cFe(e){let t=1/0,i=-1/0;for(let r of e.getLayersOfType("reflection")){let n=r.data;if(!n.visible||n.mirror===1)continue;let s=typeof n.blur=="number"?n.blur:null;t=Math.min(t,s??0),i=Math.max(i,s??10)}return t===1/0?null:{min:t,max:i}}function pFe(e){for(let t of e.getLayersOfType("reflection")){let i=t.data;if(!i.visible)continue;let{blur:r,thickness:n,steps:s,stepSize:a}=i;return typeof r!="number"||typeof n!="number"||typeof s!="number"||typeof a!="number"?"variable":{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function Yre(e,t){let i={outline:!1,cavity:!1},r=e.layers.mask&WB,n=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline"),a=_K(t),o=t.getLayersOfType("cavity");return(s.length>0||o.length>0)&&(e.layers.set(8),n.length>0&&e.layers.enable(3),a>0&&e.layers.enable(4),i.outline=s.length>0,i.cavity=o.length>0,Bx(e),Lx(e)),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),r&&e.layers.set(9),!r&&vK(e)&&e.layers.enable(5),yK(e),i}function Kre(e,t){if(!t.layers)return!1;let i=e.layers.mask&WB,r=!1,n=t.getLayersOfType("transmission").filter(l=>l.data.visible),s=t.getLayersOfType("outline").filter(l=>l.data.visible),a=_K(t),o=t.getLayersOfType("cavity").filter(l=>l.data.visible);return n.length>0&&(e.layers.set(3),(s.length>0||o.length>0)&&e.layers.enable(8),a>0&&e.layers.enable(4),r=!0),n.length===0&&s.length===0&&o.length===0&&a===0&&e.layers.set(0),i&&e.layers.set(9),!i&&vK(e)&&e.layers.enable(5),yK(e),r}function Zre(e,t){var i;if(!t.layers)return!1;let r=e.layers.mask&WB,n=!1,s=_K(t),a=t.getLayersOfType("transmission").filter(h=>h.data.visible),o=t.getLayersOfType("outline").filter(h=>h.data.visible),l=t.getLayersOfType("cavity").filter(h=>h.data.visible);return s>0&&((i=e.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),e.layers.set(4),a.length>0&&e.layers.enable(3),(o.length>0||l.length>0)&&e.layers.enable(8),n=!0),s===0&&a.length===0&&o.length===0&&l.length===0&&e.layers.set(0),r&&e.layers.set(9),!r&&vK(e)&&e.layers.enable(5),yK(e),n}function aq(e,t,i,r=!1){let n=e.cloner;if(n){let s=null;if((e.raycast===Sr.prototype.raycast||e.raycast===Fs.prototype.raycast)&&e.isSkinnedMesh!==!0){let a=e.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),s=a.boundingSphere)}for(let a of n.children){if(s!==null&&(oq.copy(s).applyMatrix4(a.matrixWorld),!t.ray.intersectsSphere(oq)))continue;let o=gSe.copy(a.matrixWorld).invert(),l=vSe.copy(t.ray).applyMatrix4(o),h=e.matrixWorld;l.applyMatrix4(h);let u=mSe;u.set(l.origin,l.direction),u.near=t.near,u.far=t.far,u.layers.mask=t.layers.mask;let d=u.intersectObject(e,!1);d.length>0&&i.push({...d[0],object:r?a:e})}}}var WB,mSe,gSe,vSe,oq,J3,ySe,lz,hz,uz,Lw,Dn,bK=F(()=>{Yn(),VB(),Da(),v1(),ne(),WB=512,mSe=new yB,gSe=new De,vSe=new _f,oq=new ja}),fFe=F(()=>{ne(),dC(),cC(),J3=class extends Ew(w_e){constructor(e,t=6710886){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Aw(this.object,J3.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=J3._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(r);else this.cone.material.color.set(r)}}},(ySe=J3)._vector=new P}),HB=F(()=>{ne(),fFe(),yC(),lz=new P,hz=new P,uz=new Vt,Lw=class extends GB(by,ySe){constructor(e,t,i){super(),this.super_Entity(e,t),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*Qe.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new RA(this.shadow.camera);n.visible=!1,this.gizmos.shadowmap=n,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof RA&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),hz.setFromMatrixPosition(this.matrixWorld),uz.setFromRotationMatrix(this.matrixWorld),lz.copy(this.up).applyQuaternion(uz).negate().multiplyScalar(this.distance),this.target.position.copy(hz).add(lz),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),wu=F(()=>{Ot(),Nh(),ne(),bl(),xu(),gK(),Ad(),jB(),Ir(),Qf(),ne(),v1(),h0(),bK(),HB(),vr(),vC(),Dn=class extends IB(Yo){constructor(e,t,i){if(super(),this.data=t,this.bgColor=new Ur(1,1,1,1),this.fog=null,this.backupFog=new iW(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Xn.getDensity({}),this.fogHeightFalloff=Xn.getHeightFalloff({}),this.fogHeightBase=Xn.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new at,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Kn(f1,{...kE.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new vB(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene){let r=xH();r===null?Ta("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else t.uiFrame&&this.createUICanvas(t.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(e,t){let i=xH();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})):Ta("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=fo(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity*Math.PI),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof qg&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof _l)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){if(e.softShadowQuality===void 0&&e.type===void 0||!this.isActive)return;let t=this.data.shadow;var i,r;i=wy.isSoft(t),r=t?.softShadowQuality,tq!==void 0&&tq(i,r)&&this.forceMaterialsUpdate()}updateFog(e,t){e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=fo(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far,this.fogMode=Xn.getMode(e),this.fogDensity=Xn.getDensity(e),this.fogHeightFalloff=Xn.getHeightFalloff(e),this.fogHeightBase=Xn.getHeightBase(e)}updateSky(e,t){this.skyState=e??null,this.skyStateVersion++;let i=e?.hdri?.image;this.skyHdriHolder=i!=null?t.image(i):null}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=fo(e.aoColor,t))}updateByOp(e,t,i,r){let n=this.data.uiFrame;super.updateByOp(e,t,i,r);let s=t;Zr(e.path,["fog"])?this.updateFog(s.fog,i.shared):Zr(e.path,["sky"])?this.updateSky(s.sky,i.shared):Zr(e.path,["grading"])?this.gradingState=s.grading??null:Zr(e.path,["ao"])?this.updateAo(s.ao,i.shared):Zr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Zr(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||n!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(fo(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.sky!==void 0&&this.updateSky(e.sky,t.shared),e.grading!==void 0&&(this.gradingState=e.grading),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e instanceof Kn&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){let e=this.scene?.find(this.data.publish.playCamera);return e instanceof Kn?e:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(Xf).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof Ow&&i.visible&&e<GE&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof Lw&&i.visible&&e<Xf-GE&&(this.penumbraSizeArrayCache[GE+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let n of r.children){let s=n.cloner;tr.is(n)&&(n.visible||s?.object.data.visible)&&((gd(n)||y4(n)&&this.scene.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),aq(n,e,t,!0)),i(n))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}}});function Qre(){return xK}function dz(){if(_4===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 _4}function cz(e){return e?.isWebGPUSplineRenderer===!0}var xK,_4,wK=F(()=>{xK=null,_4=null});function lq(){return TK}var SK,TK,MK=F(()=>{SK=null,TK=null});function Jre(e,t,i){return JM.setRGB(e,t,i,qi),{r:JM.r,g:JM.g,b:JM.b}}function mFe(e,t,i){let r,n=qA(e.angle,0),[s,a]=hq(e.offset),[o,l]=hq(e.morph),h=e.colors??[],u=e.steps??[],d=Math.min(10,h.length,u.length);if(d===0)return[1,1,1,1];if(e.gradientType===1){let g=3*(t+o)-(t+s)-1,v=3*(i+l)-(i+a)-1;r=Math.hypot(g,v)+n}else if(e.gradientType===2){let g=-1*Math.atan2(t+o-.5+s,i+l-.5+a),v=n/Math.PI/-2+.5*g/Math.PI;r=v-Math.floor(v)}else{let g=.5+o/(t!==0?t:1e-6),v=l/(i!==0?i:1e-6),y=Math.cos(n)*g-Math.sin(n)*v,_=Math.sin(n)*g+Math.cos(n)*v,b=y*y+_*_;r=b>1e-12?(((t-.5+s)/2+y/2)*y+((i-.5+a)/2+_/2)*_)/b:0}let c=h[0][0],p=h[0][1],f=h[0][2],m=h[0][3];for(let g=1;g<d;g++){let v=u[g-1],y=u[g]-v,_=y!==0?Math.min(1,Math.max(0,(r-v)/y)):r>=v?1:0;e.smooth&&(_=_*_*(3-2*_)),c+=(h[g][0]-c)*_,p+=(h[g][1]-p)*_,f+=(h[g][2]-f)*_,m+=(h[g][3]-m)*_}return[c,p,f,m]}function gFe(e,t){let i=e,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let n=t,s=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=qA(o.alpha,1);if(!(l<=0))if(o.type==="color"){let h,u=o.color;typeof u=="string"?h=typeof n?.color=="function"?n.color(u):void 0:u&&typeof u.r=="number"&&(h=u),h&&s.push({kind:"color",layer:o,rgb:{...Jre(h.r,h.g,h.b),a:h.a??1},alpha:l})}else o.type==="gradient"&&s.push({kind:"gradient",layer:o,alpha:l})}),s.length===0?null:(a,o)=>{let l=1,h=1,u=1,d=!0;for(let c of s){let p,f,m,g;if(c.kind==="color")({r:p,g:f,b:m}=c.rgb),g=c.rgb.a;else{let[y,_,b,x]=mFe(c.layer,a,o);({r:p,g:f,b:m}=Jre(y,_,b)),g=x}let v=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*v,h+=(f-h)*v,u+=(m-u)*v,d=!1}return{r:l,g:h,b:u}}}if(i?.color&&i.color.isColor===!0){let{r:n,g:s,b:a}=i.color;return()=>({r:n,g:s,b:a})}return null}var JM,qA,hq,vFe=F(()=>{ne(),JM=new at,qA=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t,hq=e=>Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"?[e[0],e[1]]:[0,0]});function yFe(e,t){if(e==="torus"){let l=t()*Math.PI*2,h=t()*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(e==="cylinder"){let l=t()*Math.PI*2,h=Math.cos(l),u=Math.sin(l);return{x:.8*h,y:1.6*(t()-.5),z:.8*u,nx:h,ny:0,nz:u,cr:1,cg:1,cb:1}}let i=t()*Math.PI*2,r=2*t()-1,n=Math.acos(r),s=Math.sin(n)*Math.cos(i),a=Math.cos(n),o=Math.sin(n)*Math.sin(i);return{x:s,y:a,z:o,nx:s,ny:a,nz:o,cr:1,cg:1,cb:1}}function _Fe(e){let{geometry:t,matrix:i}=e,r=t.getAttribute("position");if(!r||r.count<3)return null;let n=t.getAttribute("normal"),s=t.getAttribute("uv"),a=t.getAttribute("color"),o=t.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let h=(v,y)=>o?o.getX(3*v+y):3*v+y,u=i?i.elements:null,d=i?new si().getNormalMatrix(i).elements:null,c=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return u?u[0]*y+u[4]*_+u[8]*b+u[12]:y},p=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return u?u[1]*y+u[5]*_+u[9]*b+u[13]:_},f=v=>{let y=r.getX(v),_=r.getY(v),b=r.getZ(v);return u?u[2]*y+u[6]*_+u[10]*b+u[14]:b},m=new Float64Array(l),g=0;for(let v=0;v<l;v++){let y=h(v,0),_=h(v,1),b=h(v,2),x=c(y),w=p(y),S=f(y),T=c(_)-x,M=p(_)-w,E=f(_)-S,A=c(b)-x,C=p(b)-w,D=f(b)-S,R=M*D-E*C,I=E*A-T*D,U=T*C-M*A;g+=.5*Math.sqrt(R*R+I*I+U*U),m[v]=g}return g<=0?null:{total:g,sample:(v,y)=>{let _=0,b=l-1;for(;_<b;){let Y=_+b>>1;m[Y]<v?_=Y+1:b=Y}let x=_,w=h(x,0),S=h(x,1),T=h(x,2),M=y(),E=y();M+E>1&&(M=1-M,E=1-E);let A,C,D,R=1-M-E,I=c(w)*R+c(S)*M+c(T)*E,U=p(w)*R+p(S)*M+p(T)*E,O=f(w)*R+f(S)*M+f(T)*E;if(n){if(A=n.getX(w)*R+n.getX(S)*M+n.getX(T)*E,C=n.getY(w)*R+n.getY(S)*M+n.getY(T)*E,D=n.getZ(w)*R+n.getZ(S)*M+n.getZ(T)*E,d){let Y=d[0]*A+d[3]*C+d[6]*D,ue=d[1]*A+d[4]*C+d[7]*D,de=d[2]*A+d[5]*C+d[8]*D;A=Y,C=ue,D=de}}else{let Y=c(w),ue=p(w),de=f(w),ge=c(S)-Y,be=p(S)-ue,re=f(S)-de,xe=c(T)-Y,j=p(T)-ue,z=f(T)-de;A=be*z-re*j,C=re*xe-ge*z,D=ge*j-be*xe}let k=Math.sqrt(A*A+C*C+D*D)||1,G=1,K=1,q=1;if(a)G=a.getX(w)*R+a.getX(S)*M+a.getX(T)*E,K=a.getY(w)*R+a.getY(S)*M+a.getY(T)*E,q=a.getZ(w)*R+a.getZ(S)*M+a.getZ(T)*E;else if(e.sampleColor){let Y=s?s.getX(w)*R+s.getX(S)*M+s.getX(T)*E:.5,ue=s?s.getY(w)*R+s.getY(S)*M+s.getY(T)*E:.5,de=e.sampleColor(Y,ue);de&&(G=de.r,K=de.g,q=de.b)}return{x:I,y:U,z:O,nx:A/k,ny:C/k,nz:D/k,cr:G,cg:K,cb:q}}}}function ene(e){let t=Math.min(Math.max(1,Math.floor(e.guideStrands)),Fx),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}}(e.seed??1337),r=e.shape==="object"&&e.sampler,n=r?e.samplerRadius??od:od,s=new Float32Array(4*rf),a=new Float32Array(rf),o=new Float32Array(4*Fx).fill(1);for(let l=0;l<t;l++){let h=r?e.sampler(i):yFe(e.shape,i),u=r?h.x:h.x*n,d=r?h.y:h.y*n,c=r?h.z:h.z*n,{nx:p,ny:f,nz:m}=h;o[4*l+0]=h.cr,o[4*l+1]=h.cg,o[4*l+2]=h.cb;let g,v,y,_=l*Jv,b=(1.8+.8*i())*e.hairLength*n/(Jv-1),x=.5+1.5*i(),w=(.02+.06*i())*n;Math.abs(f)<.99?(g=-m,v=0,y=p):(g=1,v=0,y=0);let S=Math.sqrt(g*g+v*v+y*y)||1;for(let T=0;T<Jv;T++){let M=T/(Jv-1),E=M*M*.4*n,A=w*Math.sin(M*x*Math.PI*2),C=4*(_+T);s[C+0]=u+p*b*T+A*g/S,s[C+1]=d+f*b*T-E+A*v/S,s[C+2]=c+m*b*T+A*y/S,s[C+3]=T===0?0:1,T<Jv-1&&(a[_+T]=b)}}return{initialPositions:s,restLengths:a,unitScale:n,rootColors:o}}var Jv,Fx,rf,od,mg,iT,n_,V0,s_,uO,_Se=F(()=>{ne(),rf=(Fx=16384)*(Jv=32),od=100}),bSe=F(()=>{ne(),Da(),MK(),vFe(),_Se(),mg=1/60,iT=new De,n_=new Vt,V0=new P,s_=new P,uO=class extends Fs{constructor(e,t,i){super(e,t),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 Vt,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=t,this.geometry.setAttribute("position",new Pt(new Float32Array(0),3)),this.material=new Zl({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new Sr(new jf(od,48,32),new Zl({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new PL;r.setAttribute("position",new Pt(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new Sr(r,new Zl({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=t.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:t.guideStrands,hairLength:t.hairLength,spreadRadius:t.spreadRadius,headShape:t.headShape,baseObjectId:t.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,4*mg*2),this.trackMotionRest(e/1e3))}trackMotionRest(e){this.boneTransform(n_,V0);let t=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(n_))<.9999995||this.lastBonePos.distanceToSquared(V0)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||t||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(n_),this.lastBonePos.copy(V0),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+e}motionFingerprint(){let e=this.data;return e.gravity+2*e.damping+3*e.localStiffness+4*e.globalStiffness+5*e.globalRange+6*e.stiffnessFalloff+7*e.windStrength+8*e.vspCoefficient+9*e.kink+10*e.kinkFrequency+11*e.clumpStrength+12*e.clumpSize+13*e.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(e){this.playModeActive=e,e&&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(e,t){super.updateState(e,t),this.updateHairState(e)}updateHairState(e){if((e.guideStrands!==void 0||e.hairLength!==void 0||e.spreadRadius!==void 0||e.headShape!==void 0||e.baseObjectId!==void 0)&&this.regenerate(),(e.headShape!==void 0||e.baseObjectId!==void 0)&&this.applyScalpState(),e.headColor!==void 0){let t=this.scalpMesh.material;t.isMeshBasicMaterial===!0&&t.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,qi)}(e.castShadow!==void 0||e.receiveShadow!==void 0)&&this.applyShadowState(),e.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,t=this.data.receiveShadow??!0;this.castShadow=e,this.receiveShadow=t,this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=t,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=t}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 e=this.data,t=this.regenSnapshot;if(t===null||t.guideStrands!==e.guideStrands||t.hairLength!==e.hairLength||t.spreadRadius!==e.spreadRadius||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId){let i=t===null||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:t,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,e==="object"&&t){let n=this.context.scene.find(t);if(n){this.baseFoundAtRegen=!0,n.updateWorldMatrix(!0,!0);let s=this.collectBaseSources(n),a=s?function(o){let l=[];for(let d of o){let c=_Fe(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,f=l.length-1;for(;p<f;){let g=p+f>>1;h[g]<c?p=g+1:f=g}let m=p===0?c:c-h[p-1];return l[p].sample(m,d)}}(s.sources):null;if(this.baseSourceGeomsAtRegen=s?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=s?.hashes??[],this.baseColorHashAtRegen=s?.colorHash??0,s&&a){let o=this.baseWorldScale(n),l=Math.max(s.radius*o,.001);this.baseScaleAtRegen=o;let h=o;return ene({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 ene({shape:e==="object"?"sphere":e,guideStrands:i,hairLength:r})}collectBaseSources(e){let t=[],i=[],r=0,n=0;iT.copy(e.matrixWorld).invert();let s=iT.clone(),a=o=>{if(o.isHairSystem===!0||o!==e&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let h=o===e?void 0:new De().multiplyMatrices(s,o.matrixWorld),u=Array.isArray(o.material)?o.material[0]:o.material;t.push({geometry:l,matrix:h,sampleColor:gFe(u,this.context.shared)??void 0}),i.push(uO.matrixHash(h)),n+=function(c,p){let f=c,m=0,g=1,v=_=>{m+=_*g,g+=1},y=f?.data?.layers;if(y&&typeof y.forEach=="function"){let _=p;y.forEach(b=>{let x=b.data;if(x.visible!==!1){if(x.type==="color"){let w=x.color,S=typeof w=="string"?typeof _?.color=="function"?_.color(w):void 0:w;S&&typeof S.r=="number"&&(v(S.r),v(S.g),v(S.b)),v(qA(x.alpha,1))}else if(x.type==="gradient"){let w=x;for(let S of w.colors??[])v(S[0]),v(S[1]),v(S[2]),v(S[3]);for(let S of w.steps??[])v(S);v(qA(w.angle,0)),v(w.gradientType),v(w.smooth?1:0)}}})}else f?.color&&f.color.isColor===!0&&(v(f.color.r),v(f.color.g),v(f.color.b));return m}(u,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;h?(V0.copy(d.center).applyMatrix4(h),c=V0.length(),p=uO.matrixMaxScale(h)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let h of o.children)a(h)};return a(e),t.length===0?null:{sources:t,hashes:i,radius:Math.max(r,.001),colorHash:n}}static matrixHash(e){if(!e)return 0;let t=e.elements,i=0;for(let r=0;r<16;r++)i+=t[r]*(r+1);return i}static matrixMaxScale(e){let t=e.elements,i=Math.hypot(t[0],t[1],t[2]),r=Math.hypot(t[4],t[5],t[6]),n=Math.hypot(t[8],t[9],t[10]);return Math.max(i,r,n,1e-6)}baseWorldScale(e){return iT.copy(e.matrixWorld).decompose(V0,n_,s_),Math.max(Math.abs(s_.x),Math.abs(s_.y),Math.abs(s_.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 e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen)return void this.regenerate();e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),i=t?.sources??[],r=t?.hashes??[],n=this.baseSourceGeomsAtRegen,s=this.baseSourceHashesAtRegen,a=i.length!==n.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==n[o]||Math.abs(r[o]-s[o])>1e-4*Math.max(Math.abs(s[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(t?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(e);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let e=this.data.headShape,t=e==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!t,!t&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=e==="torus"?new CL(1.4*od,.7*od,24,48):e==="cylinder"?new IE(.8*od,.8*od,1.6*od,48,1):new jf(od,48,32))}boneTransform(e,t){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)}iT.copy(i).decompose(t,e,s_)}raycast(e,t){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(e,i);for(let r of i)r.object=this,t.push(r)}get shadowBoundsRadius(){let e=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(e+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(e){return this.boneTransform(n_,e),e}updateEntityBoxSize(e,t){let i=this.shadowBoundsRadius;e.set(0,0,0),t.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),lq()?.release(this)}}});function dO(){return{shapeInput:()=>`
|
|
4213
4213
|
const float posRowCoord = ${.5/ff};
|
|
4214
4214
|
const float quatRowCoord = ${1.5/ff};
|
|
4215
4215
|
const float param1RowCoord = ${2.5/ff};
|
|
@@ -5406,7 +5406,7 @@ function sortWorker(self) {
|
|
|
5406
5406
|
gl_FragColor = vec4(color.rgb, A);
|
|
5407
5407
|
gVelocity = vec4(0.0);
|
|
5408
5408
|
}`,transparent:!0,alphaTest:1,blending:Xs,depthTest:!0,depthWrite:!1,side:Cr})}static buildGeomtery(e){let t=new Mt;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(12),r=new Pt(i,3);t.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 n=new PL().copy(t),s=new Uint32Array(e),a=new fl(s,1,!1);return a.setUsage(bd),n.setAttribute("splatIndex",a),n.instanceCount=e,n}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 e=0,t=0,i=0;for(let r of this.splatBuffers){let n=r.nsplats;this.colors.subarray(e,e+4*n).set(r.colorsA),e+=4*n,this.centers.subarray(t,t+3*n).set(r.decoded.xyz.denormDequant().data),t+=3*n,this.covariances.subarray(i,i+6*n).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=6*n}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new Z(4096,1024);for(;t.x*t.y*2<6*e;)t.y*=2;let i,r,n=new Z(4096,1024);for(;n.x*n.y*4<4*e;)n.y*=2;if(this.halfPrecisionCovariancesOnGPU){r=new Uint16Array(t.x*t.y*2);for(let h=0;h<this.covariances.length;h++)r[h]=xd.toHalfFloat(this.covariances[h]);i=new Nr(r,t.x,t.y,ws,li)}else r=new Float32Array(t.x*t.y*2),r.set(this.covariances),i=new Nr(r,t.x,t.y,ws,Gt);i.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=i,this.material.uniforms.covariancesTextureSize.value.copy(t);let s=new Uint32Array(n.x*n.y*4);for(let h=0;h<e;h++){let u=4*h,d=3*h,c=4*h;s[c]=eTe(this.colors[u],this.colors[u+1],this.colors[u+2],this.colors[u+3]),s[c+1]=mO(this.centers[d]),s[c+2]=mO(this.centers[d+1]),s[c+3]=mO(this.centers[d+2])}let a=new Nr(s,n.x,n.y,Zg,un);f4()!=="webgpu"&&(a.internalFormat="RGBA32UI"),a.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=a,this.material.uniforms.centersColorsTextureSize.value.copy(n);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 Nr(o,1024,1,pn,Gt);l.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=l,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:r,texture:i,size:t},centerColors:{data:s,texture:a,size:n},meshMatrixWorlds:{data:o,texture:l}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(aT.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(aT),this.material.uniforms.basisViewport.value.set(2/aT.x,2/aT.y),this.material.uniforms.focal.value.set(t,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 qFe(){if(!yq)return mne||(mne=async function(){let e=await Promise.resolve().then(()=>(WQ(),jQ));rTe(e),yq=!0}())}var rTe,nTe,yq,mne,gne,sTe,M4,Rz,zg,aTe=F(()=>{nTe=new Promise(e=>{rTe=e}),yq=!1}),$Fe=F(()=>{WFe(),ne(),iTe(),aTe(),nTe.then(e=>gne=e),sTe=class{constructor(e={}){Oc(this,"updateView",function(){let t=new De,i=[],r=new P(0,0,-1),n=new P(0,0,-1),s=new P,a=new P;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!o){n.set(0,0,-1).applyQuaternion(l.quaternion);let c=!1,p=!1;if(n.dot(r)<=.95&&(c=!0),a.copy(l.position).sub(s).length()>=1&&(p=!0),!(c||p||h||u||this.needsInitialRender))return}this.needsInitialRender=!1,s.copy(l.position),r.copy(n),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:t.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=e.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 De().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new Z;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new P().fromArray(e.position)),e.orientation&&(e.orientation=new Vt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(s=>{s.data.type==="Splat"&&t.push(s)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(s=>s.matrixWorld),this.meshMatrixWorldsOld=t.map(s=>s.matrixWorld.clone()),this.cropsArray=t.map(s=>s.data.crops.map(a=>a.data)),this._splatBufferCache??(this._splatBufferCache=new WeakMap);let i=t.map(s=>{let a=this._splatBufferCache.get(s.data.buffer);return a===void 0&&(a=new gne.GSplineBuffer(new Uint8Array(s.data.buffer).buffer),this._splatBufferCache.set(s.data.buffer,a)),a}),r=0,n=[0];for(let s of i)r+=s.getSplatCount(),n.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,16*t);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,!this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))&&(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,n)=>{this.cropsArray[i][n]===void 0?(e=!0,this.cropsArray[i][n]=r.data):Object.entries(r.data).forEach(([s,a])=>{(Array.isArray(a)&&a.some((o,l)=>o!==this.cropsArray[i][n][s][l])||a!==this.cropsArray[i][n]?.[s])&&(e=!0,this.cropsArray[i][n][s]=a)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new P,r=new Vt,n=!1,s=1,a,o){this.splatMesh=aE.buildMesh(e,t,n,s,a,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,h,u)=>this.update(l,u),this.splatMesh.runBeforeRenderWhenBundled=!0}setupSortWorker(e){this.sortWorker=function(t){let i=new Worker(URL.createObjectURL(new Blob(["(",JSe,")(self)"],{type:"application/javascript"}))),r=atob(QSe),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return i.postMessage({init:{sorterWasmBytes:n.buffer,splatCount:t,Constants:{BytesPerFloat:Ug.BytesPerFloat,BytesPerInt:Ug.BytesPerInt,DepthMapRange:Ug.DepthMapRange,MemoryPageSize:Ug.MemoryPageSize}}}),i}(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}}}),YB=F(()=>{ne(),Nh(),bl(),h0(),Ot(),qSe(),Ir(),bK(),fK(),Da(),vC(),kFe(),OB(),xl(),Yn(),wu(),kSe(),Yn(),la(),Pw(),VFe(),$Fe(),(M4=new Zl).wireframe=!0,Rz=new P,zg=class extends Yo{constructor(e,t){super(),this.data=e,this.sharedAssets=t,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 ZSe,this.invisibleObjects=new Ec("jflkdsafjasdifjaslk",{...ZL.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Dn("fdasfa",{...Sy.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markShadowsDirty(){this.shadowsDirty=!0}markInstanceGroupsDirty(){this.instanceGroupsDirty=!0}get autoInstancing(){return this._autoInstancing}updateInstanceGroups(e,t){let i=this._autoInstancing;(i===null||i.minGroupSize!==t)&&(i?.dispose(),i=new HSe(t),this._autoInstancing=i);let r=this.instanceGroupsDirty;return this.instanceGroupsDirty=!1,i.update(e,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(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof _l)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)Kre(i,i.material[r])&&(t=!0);else Kre(i,i.material)&&(t=!0)}),t}(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._normalPassNeeds=function(e){let t={outline:!1,cavity:!1},i=r=>{t.outline=t.outline||r.outline,t.cavity=t.cavity||r.cavity};return e.traverseEntity(r=>{if(r instanceof _l)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)i(Yre(r,r.material[n]));else i(Yre(r,r.material))}),t}(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(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof _l)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)Zre(i,i.material[r])&&(t=!0);else Zre(i,i.material)&&(t=!0)}),t}(this),this.needsReflectionDirty=!1),this._needsReflection}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Dn&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}findInInstance(e,t){let i=t??null;if(!tr.is(i))return;let r=i.data.type==="Instance";if(!r&&!i.isVirtualEntity)return;let n=typeof i.identity=="string"?[i.identity]:i.identity;for(let s=n.length-(r?0:1);s>=1;s--){let a=this.findInstance([...n.slice(0,s),e]);if(a)return a}for(let s=i;tr.is(s);s=s.parent)if(s.data.type==="Instance"&&s.data.component===e)return s}findFrom(e,t){return this.findInInstance(e,t)??this.find(e)}syncInstancePathConstraint(e){let t=e.data.pathSnapping?.pathId;if(t){let i=this.findFrom(t,e);this.pathConstraints.setConstraint(e.uuid,i?.uuid??t)}else this.pathConstraints.removeDependencies(e.uuid)}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let n=r;r=r.parent;let s=r.children.indexOf(n);i.splice(0,0,s)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>DL(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===f1)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Dn&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Dn&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&qo(i)&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Dn&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);t?Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0&&console.error("not found instance"):console.error("not found")}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(t=>{t.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(t=>{t.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error(`scene tree add: parent ${e.parent} not found for object ${e.id}`);let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(this),r.resetBBoxNeedsUpdate(),gd(r)&&Bc(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error(`scene tree delete: object ${e.id} not found`);i.traverseEntity(n=>{Yf(n)&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==n)),l1(n)&&(this.hairInstances=this.hairInstances.filter(s=>s!==n))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Bc(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),gd(i)&&(i.freeBooleanPointer(),r instanceof qg&&r.invalidateDownstreamBooleanData().recomputeBoolean()),RB(i)&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error(`scene tree move: object ${e.id} not found`);this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let n=e.parent===null?this:this.find(e.parent);if(n===void 0)throw new Error(`scene tree move: new parent ${e.parent} not found for object ${e.id}`);n.add(i),this.markNeedsRecomputeInstancesForAncessors(n),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;n.children.splice(s,0,n.children.pop()),gd(i)&&(i.invalidateUpstreamBooleanData(),Bc(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof qg&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.shadowsDirty=!0,this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Dn&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(this.shadowsDirty=!0,t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let n=this.find(e);if(n)try{(function(s,a,o,l){s.updateByOp(a,o,l,!1)})(n,t,i,{scene:this,shared:r}),n instanceof wn&&n.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,i,r,n,s=[]){e.updateEntityByOp(t,i,r,n),this.traverseEntity(a=>{(qo(a)||a instanceof Dn)&&(s.includes(a.frameId??"")||a.frameId===t)&&a.updateEntity2DByOp(t,i,r,n)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,n)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:n}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof Kn&&r.updateUp()}),this.doPendingExpandCloner({scene:this,shared:t}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){tr.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{tr.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,n,s,a){if(e){let o=r.find(e);o&&o!==r&&n.forInstancesRec(l=>{l.data=OL(l.data,h=>{let u=h.events.data(a.id),d=l.goUp(s);if(d){let c=[...rbe(d.identity),e].join("-"),p=this.entityIdentityToEntity[c];if(p){let f=p.uuid;Sa.zoom(u,t)[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,n,s){e.forEach(a=>{a.data.type==="Transition"||a.data.type==="Animation"&&a.data.object?this.relativeizeInner(a.data.object,[...t,a.id],"object",i,r,n,s):a.data.type==="Conditional"&&(this.rewriteActions(a.data.ifActions,[...t,a.id,"ifActions"],i,r,n,s),this.rewriteActions(a.data.elseActions,[...t,a.id,"elseActions"],i,r,n,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(iO(e)&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let n=!1;if(t.forInstancesRec(s=>{s.data=OL(s.data,a=>{s.isInstanceRoot||(a.events.delete(r.id),n=!0)}).data}),n===!1)for(let s of t4.list)this.rewriteActions(r.data.gameActions[s],["gameActions",s],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,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,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(n=>{if(iO(n)&&n.isInstanceRoot)return n.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||n.resetBBoxNeedsUpdate(),i&&n.traverseEntity(s=>{i.addClip(s)}),!0});for(let n of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),NK(n)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{iO(i)&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i],this.pathConstraints.removeDependencies(t.uuid)),t.dispose()})}clearScene(){this._autoInstancing?.dispose(),this._autoInstancing=null,this.instanceGroupsDirty=!0;for(let e of this.children)tr.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=n=>{for(let s of n.children){let a=s.cloner;if(tr.is(s)&&!s.raycastLock&&(s.visible||a?.object.data.visible))if(t===!0&&s.isInstanceRoot){let o=[];if(e.intersectObject(s,!0,o),o.length){let l=o[0];l.object=s,l.point.applyMatrix4(l.object.matrixWorld);let h=s.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(gd(s)||y4(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,i),aq(s,e,i)),r(s)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let n of r.children){let s=n.cloner;tr.is(n)&&(n.visible||s?.object.data.visible)&&((gd(n)||y4(n)&&this.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),aq(n,e,t,!0)),i(n))}};return i(this),t}forEachEntity(e){for(let t of this.children)tr.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)tr.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)tr.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof wn&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let r=i.geometry,n=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(n,t);let s=i.invalidateDownstreamBooleanData();Bc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)hy.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)tr.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let n of e)this.createObject(n.id,n.data,n.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,n,s){let a={scene:this,shared:s},o=BK(e,t,a);return Yf(o)&&this.shapeBlendIntances.push(o),l1(o)&&this.hairInstances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(n,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,s)),o.updateState(t,a),o instanceof wn&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{let h=l.dataPatched;if(l instanceof wn&&h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),d=h.boneInverses.map(p=>new De().fromArray(p)),c=new EA(u,d);l.bind(c,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,n=e.length;r<n;++r){let{id:s,recursive:a}=e[r],o=this.find(s),l=a?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new cn;return i.setFromPoints(t),i.getCenter(Rz),Rz}copyMatrixWorld(e,t){if(e===null)return void t.identity();let i=this.find(e);i?(i.updateWorldMatrix(!0,!1),t.copy(i.matrixWorld)):t.identity()}copyParentMatrixWorld(e,t){if(e===null)return void t.identity();let i=this.find(e)?.parent;i?(i.updateWorldMatrix(!0,!1),t.copy(i.matrixWorld)):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Fs)if(Array.isArray(t.material))for(let i of t.material)g4(i)&&e(i);else g4(t.material)&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Kn&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new sTe({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}}}),oTe={};function XFe(){let e,t;function i(r,n,s,a,o,l){let h=s.num_points(),u=l.num_components(),d=function(b,x){switch(x){case Float32Array:return b.DT_FLOAT32;case Int8Array:return b.DT_INT8;case Int16Array:return b.DT_INT16;case Int32Array:return b.DT_INT32;case Uint8Array:return b.DT_UINT8;case Uint16Array:return b.DT_UINT16;case Uint32Array:return b.DT_UINT32}}(r,o),c=u*o.BYTES_PER_ELEMENT,p=4*Math.ceil(c/4),f=p/o.BYTES_PER_ELEMENT,m=h*c,g=h*p,v=r._malloc(m);n.GetAttributeDataArrayForAllPoints(s,l,d,m,v);let y,_=new o(r.HEAPF32.buffer,v,m/o.BYTES_PER_ELEMENT);if(c===p)y=_.slice();else{y=new o(g/o.BYTES_PER_ELEMENT);let b=0;for(let x=0,w=_.length;x<w;x++){for(let S=0;S<u;S++)y[b+S]=_[x*u+S];b+=f}}return r._free(v),{name:a,count:h,itemSize:u,array:y,stride:f}}onmessage=function(r){let n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise(function(o){e.onModuleLoaded=function(l){o({draco:l})},DracoDecoderModule(e)});break;case"decode":let s=n.buffer,a=n.taskConfig;t.then(o=>{let l=o.draco,h=new l.Decoder;try{let u=function(c,p,f,m){let g,v,y=m.attributeIDs,_=m.attributeTypes,b=p.GetEncodedGeometryType(f);if(b===c.TRIANGULAR_MESH)g=new c.Mesh,v=p.DecodeArrayToMesh(f,f.byteLength,g);else{if(b!==c.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");g=new c.PointCloud,v=p.DecodeArrayToPointCloud(f,f.byteLength,g)}if(!v.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+v.error_msg());let x={index:null,attributes:[]};for(let w in y){let S,T,M=self[_[w]];if(m.useUniqueIDs)T=y[w],S=p.GetAttributeByUniqueId(g,T);else{if(T=p.GetAttributeId(g,c[y[w]]),T===-1)continue;S=p.GetAttribute(g,T)}let E=i(c,p,g,w,M,S);w==="color"&&(E.vertexColorSpace=m.vertexColorSpace),x.attributes.push(E)}return b===c.TRIANGULAR_MESH&&(x.index=function(w,S,T){let M=3*T.num_faces(),E=4*M,A=w._malloc(E);S.GetTrianglesUInt32Array(T,E,A);let C=new Uint32Array(w.HEAPF32.buffer,A,M).slice();return w._free(A),{array:C,itemSize:1}}(c,p,g)),c.destroy(g),x}(l,h,new Int8Array(s),a),d=u.attributes.map(c=>c.array.buffer);u.index&&d.push(u.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:u},d)}catch(u){console.error(u),self.postMessage({type:"error",id:n.id,error:u.message})}finally{l.destroy(h)}})}}}ww(oTe,{DRACOLoader:()=>hTe,DRACO_GLTF_CONFIG:()=>lTe});var lP,lTe,hTe,YFe=F(()=>{ne(),lP=new WeakMap,lTe={js:"",wasm:""},hTe=class extends Vv{constructor(e){super(e),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(e){let{decoderPaths:t}=this;return typeof e=="object"?(t.js=e.js,t.wasm=e.wasm,t.dep_js=null):(t.js=WI.resolveURL("draco_wasm_wrapper.js",e),t.wasm=WI.resolveURL("draco_decoder.wasm",e),t.dep_js=WI.resolveURL("draco_decoder.js",e)),this}setDecoderConfig(e){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let n=new BE(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,s=>{this.parse(s,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,qi,i).catch(i)}decodeDracoFile(e,t,i,r,n=Td,s=()=>{}){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:n};return this.decodeGeometry(e,a).then(t).catch(s)}decodeGeometry(e,t){let i=JSON.stringify(t);if(lP.has(e)){let o=lP.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,n=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(n,s).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[n]={resolve:l,reject:h},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),lP.set(e,{key:i,promise:a}),a}_createGeometry(e){let t=new Mt;e.index&&t.setIndex(new Pt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r,{name:n,array:s,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[i];if(a===o)r=new Pt(s,a);else{let h=new ax(s,o);r=new pg(h,a,0)}n==="color"&&(this._assignVertexColorSpace(r,l),r.normalized=!(s instanceof Float32Array)),t.setAttribute(n,r)}return t}_assignVertexColorSpace(e,t){if(t!==qi)return;let i=new at;for(let r=0,n=e.count;r<n;r++)i.fromBufferAttribute(e,r),ni.colorSpaceToWorking(i,qi),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){let i=new BE(this.manager);return i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,n)=>{i.load(e,r,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[],{decoderPaths:i}=this;if(e){if(i.dep_js===null)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");t.push(this._loadLibrary(i.dep_js,"text"))}else t.push(this._loadLibrary(i.js,"text")),t.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(t).then(r=>{let n=r[0];e||(this.decoderConfig.wasmBinary=r[1]);let s=XFe.toString(),a=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
5409
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){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(n){let s=n.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,n){return r._taskLoad>n._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),KFe=F(()=>{});function uTe(e){return function(t,{basePath:i,moduleUrl:r,cdnBuild:n}){if(i!==void 0)return{url:`${i}/${t}`};let s=`${n}/${t}`;if(r===void 0||r.startsWith("file:"))return{url:s};let a=r.slice(0,r.lastIndexOf("/")+1)+t;return a===s?{url:a}:{url:a,fallback:s}}(e,{basePath:dTe,moduleUrl:typeof M1e.url=="string"?M1e.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
5409
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){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(n){let s=n.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,n){return r._taskLoad>n._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),KFe=F(()=>{});function uTe(e){return function(t,{basePath:i,moduleUrl:r,cdnBuild:n}){if(i!==void 0)return{url:`${i}/${t}`};let s=`${n}/${t}`;if(r===void 0||r.startsWith("file:"))return{url:s};let a=r.slice(0,r.lastIndexOf("/")+1)+t;return a===s?{url:a}:{url:a,fallback:s}}(e,{basePath:dTe,moduleUrl:typeof M1e.url=="string"?M1e.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.205/build"})}function E4(e,t){let{url:i,fallback:r}=uTe(t);r!==void 0&&e.addEventListener("error",()=>{e.src=r},{once:!0}),e.src=i}var dTe,KB=F(()=>{KFe()});function u0(e,t){ZB.set(e,t)}function ZFe(e){return ZB.get(e)}function cTe(e,t){FK.set(e,t)}function vne(e){return FK.get(e)}function _q(e,t){let i=`${t}:${e}`;bq.has(i)||bq.add(i)}var ZB,FK,bq,Su=F(()=>{ZB=new Map,FK=new Map,bq=new Set});function yne(e,t,i){return e*(t-i)-t}function Dz(e,t,i){return Math.min(Math.max((e+t)/(t-i),0),1)}function _ne(e,t,i){for(let r of t){let n="$1"+e+r.charAt(0).toUpperCase()+r.slice(1),s=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(let a of i.entries())a[1]!==null&&i.set(a[0],a[1].replace(s,n))}}function QFe(e,t,i,r,n,s,a){let o=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=o.get("fragment")!==void 0&&/mainImage/.test(o.get("fragment")),h=o.get("fragment")!==void 0&&/mainUv/.test(o.get("fragment")),u=[],d=[],c=!1,p=!1;if(o.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(h&&(a&nd.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(l||h){let f=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,m=gO.Section;if(h){let v=` ${e}MainUv(UV);
|
|
5410
5410
|
`;i.set(m.FRAGMENT_MAIN_UV,i.get(m.FRAGMENT_MAIN_UV)+v),c=!0}if(o.get("vertex")!==null&&/mainSupport/.test(o.get("vertex"))){let v=` ${e}MainSupport(`;v+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get("vertex"))?`vUv);
|
|
5411
5411
|
`:`);
|
|
5412
5412
|
`,i.set(m.VERTEX_MAIN_SUPPORT,i.get(m.VERTEX_MAIN_SUPPORT)+v),u=u.concat([...o.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(y=>y[1])),d=d.concat(u).concat([...o.get("vertex").matchAll(f)].map(y=>y[1]))}d=d.concat([...o.get("fragment").matchAll(f)].map(v=>v[1])),d=d.concat([...t.defines.keys()].map(v=>v.replace(/\([\w\s,]*\)/g,""))),d=d.concat([...t.uniforms.keys()]),t.uniforms.forEach((v,y)=>s.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),t.defines.forEach((v,y)=>n.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),_ne(e,d,n),_ne(e,d,o);let g=t.blendMode;if(r.set(g.blendFunction,g),l){let v=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,y=`${e}MainImage(color0, UV, `;(a&nd.DEPTH)!==0&&v.test(o.get("fragment"))&&(y+="depth, ",p=!0),y+=`color1);
|
|
@@ -6256,7 +6256,7 @@ var<${i}> ${e} : ${s};`}},ao=new dv,JD=new B_,wj=new Map([[Int8Array,["sint8","s
|
|
|
6256
6256
|
${s[a.lineNum-1]}`,a.linePos>0&&(h+=`
|
|
6257
6257
|
${" ".repeat(a.linePos-1)}^`)),(a.type==="error"?qe:rt)(l+h)}}}_getBlending(e){let t,i,r=e.blending,n=e.blendSrc,s=e.blendDst,a=e.blendEquation;if(r===Mg){let o=e.blendSrcAlpha!==null?e.blendSrcAlpha:n,l=e.blendDstAlpha!==null?e.blendDstAlpha:s,h=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(n),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(a)},i={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=(l,h,u,d)=>{t={srcFactor:l,dstFactor:h,operation:jm.Add},i={srcFactor:u,dstFactor:d,operation:jm.Add}};if(e.premultipliedAlpha)switch(r){case Xs:o(dr.One,dr.OneMinusSrcAlpha,dr.One,dr.OneMinusSrcAlpha);break;case bc:o(dr.One,dr.One,dr.One,dr.One);break;case xc:o(dr.Zero,dr.OneMinusSrc,dr.Zero,dr.One);break;case wc:o(dr.Dst,dr.OneMinusSrcAlpha,dr.Zero,dr.One)}else switch(r){case Xs:o(dr.SrcAlpha,dr.OneMinusSrcAlpha,dr.One,dr.OneMinusSrcAlpha);break;case bc:o(dr.SrcAlpha,dr.One,dr.One,dr.One);break;case xc:qe(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case wc:qe(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(t!==void 0&&i!==void 0)return{color:t,alpha:i};qe("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case Eg:t=dr.Zero;break;case Kg:t=dr.One;break;case hL:t=dr.Src;break;case uL:t=dr.OneMinusSrc;break;case my:t=dr.SrcAlpha;break;case Nf:t=dr.OneMinusSrcAlpha;break;case dL:t=dr.Dst;break;case cL:t=dr.OneMinusDst;break;case bA:t=dr.DstAlpha;break;case xA:t=dr.OneMinusDstAlpha;break;case pL:t=dr.SrcAlphaSaturated;break;case 211:t=dr.Constant;break;case 212:t=dr.OneMinusConstant;break;default:qe("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,i=e.stencilFunc;switch(i){case q1e:t=Ba.Never;break;case UI:t=Ba.Always;break;case $1e:t=Ba.Less;break;case Y1e:t=Ba.LessEqual;break;case X1e:t=Ba.Equal;break;case Q1e:t=Ba.GreaterEqual;break;case K1e:t=Ba.Greater;break;case Z1e:t=Ba.NotEqual;break;default:qe("WebGPURenderer: Invalid stencil function.",i)}return t}_getStencilOperation(e){let t;switch(e){case ig:t=Pp.Keep;break;case z1e:t=Pp.Zero;break;case k1e:t=Pp.Replace;break;case H1e:t=Pp.Invert;break;case V1e:t=Pp.IncrementClamp;break;case G1e:t=Pp.DecrementClamp;break;case j1e:t=Pp.IncrementWrap;break;case W1e:t=Pp.DecrementWrap;break;default:qe("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Wo:t=jm.Add;break;case oL:t=jm.Subtract;break;case lL:t=jm.ReverseSubtract;break;case XX:t=jm.Min;break;case YX:t=jm.Max;break;default:qe("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,i){let r={},n=this.backend.utils;r.topology=n.getPrimitiveTopology(e,i),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=HD.Uint32);let s=i.side===wr;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(s=!s),r.frontFace=s===!0?aj.CW:aj.CCW,r.cullMode=i.side===Cr?oj.None:oj.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?D2.All:D2.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Ba.Always;else{let i=this.backend.parameters.reversedDepthBuffer?ML[e.depthFunc]:e.depthFunc;switch(i){case xx:t=Ba.Never;break;case wx:t=Ba.Always;break;case Sx:t=Ba.Less;break;case hf:t=Ba.LessEqual;break;case Tx:t=Ba.Equal;break;case Mx:t=Ba.GreaterEqual;break;case Ex:t=Ba.Greater;break;case Ax:t=Ba.NotEqual;break;default:qe("WebGPUPipelineUtils: Invalid depth function.",i)}}return t}},Sj=class{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}},$u=new dv,bme=new B_,j_=new Sj,xme=class extends nj{constructor(e,t,i=2048){super(i),this.device=e,this.type=t,j_.label=`queryset_global_timestamp_${t}`,j_.type="timestamp",j_.count=this.maxQueries,this.querySet=this.device.createQuerySet(j_),j_.reset();let r=8*this.maxQueries;$u.label=`buffer_timestamp_resolve_${t}`,$u.size=r,$u.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer($u),$u.reset(),$u.label=`buffer_timestamp_result_${t}`,$u.size=r,$u.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer($u),$u.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return xr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,i=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(bme);r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,i);let n=r.finish();if(qd(this.device,n),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,i),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let s=new BigUint64Array(this.resultBuffer.getMappedRange(0,i)),a={},o=[];for(let[h,u]of e){let d=h.match(/^(.*):f(\d+)$/),c=parseInt(d[2]);o.includes(c)===!1&&o.push(c),a[c]===void 0&&(a[c]=0);let p=s[u],f=s[u+1],m=Number(f-p)/1e6;this.timestamps.set(h,m),a[c]+=m}let l=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=o,l}catch(e){return qe("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){qe("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){qe("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},wme=class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},z2=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},Sme=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},tu={r:0,g:0,b:0,a:1},zl=new dv,Fo=new B_,k2=new wme,W_=new Sj,V2=new mj,G2=new Sme,fh=new L2,Xu=new L2,Hn=new YD,nc=new gj,Tme=class extends ej{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0||e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new jfe(this),this.attributeUtils=new pme(this),this.bindingUtils=new mme(this),this.capabilities=new gme(this),this.pipelineUtils=new _me(this),this.textureUtils=new eme(this),this.occludedResolveCache=new Map;let t=typeof navigator>"u"||/Android/.test(navigator.userAgent)===!1;this._compatibility={[rg.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t,i=this.parameters;if(i.device===void 0){let r={powerPreference:i.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},n=typeof navigator<"u"?await navigator.gpu.requestAdapter(r):null;if(n===null)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");let s=Object.values(iA),a=[];for(let l of s)n.features.has(l)&&a.push(l);let o={requiredFeatures:a,requiredLimits:i.requiredLimits};this.adapter=n,t=await n.requestDevice(o)}else t=i.device;this.compatibilityMode=!t.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),t.lost.then(r=>{if(r.reason==="destroyed")return;let n={api:"WebGPU",message:r.message||"Unknown reason",reason:r.reason||null,originalEvent:r};e.onDeviceLost(n)}),t.onuncapturederror=r=>{let n=r.error,s=n&&n.constructor?n.constructor.name:"GPUError",a=n&&n.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:s,message:a,originalEvent:r})},this.device=t,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(iA.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,i=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:i,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),i=t.context;if(i===void 0){let r=this.parameters;i=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${_u} webgpu`);let n=r.alpha?"premultiplied":"opaque",s=r.outputType===li?"extended":"standard";i.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:n,colorSpace:r.canvasColorSpace||"srgb",toneMapping:{mode:s}}),t.context=i}return i}get coordinateSystem(){return $l}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,i=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,i,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),i=this.get(t),r=e.currentSamples,n=i.descriptor;if(n===void 0||i.samples!==r){if(n=new U_,n.colorAttachments.push(new F_),e.depth===!0||e.stencil===!0){let o=new z2;o.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),n.depthStencilAttachment=o}let a=n.colorAttachments[0];r>0?a.view=this.textureUtils.getColorBuffer().createView():a.resolveTarget=void 0,i.descriptor=n,i.samples=r}let s=n.colorAttachments[0];return r>0?s.resolveTarget=this.context.getCurrentTexture().createView():s.view=this.context.getCurrentTexture().createView(),n}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){let t=e.textures;if(t===null)return!1;for(let i=0;i<t.length;i++)if(this.get(t[i]).externalTexture===!0)return!0;return!1}_createExternalTextureViews(e,t){let i=[],r=e.camera;if(t.xrViewDescriptors&&r!==null&&r.isArrayCamera===!0)for(let n=0;n<t.xrViewDescriptors.length;n++)i.push({view:t.texture.createView(t.xrViewDescriptors[n]),resolveTarget:void 0,depthSlice:void 0});else i.push({view:t.texture.createView({dimension:Fa.TwoD,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return i}_getRenderPassDescriptor(e,t={}){let i=e.renderTarget,r=this.get(i),n=this._hasExternalTexture(e),s=r.descriptors;(s===void 0||r.width!==i.width||r.height!==i.height||r.samples!==i.samples||n)&&(s={},r.descriptors=s);let a=e.getCacheKey(),o=s[a];if(o===void 0||n){let h,u=e.textures,d=[],c=this._isRenderCameraDepthArray(e);for(let f=0;f<u.length;f++){let m=this.get(u[f]);if(m.externalTexture!==!0){if(Hn.label=`colorAttachment_${f}`,Hn.baseMipLevel=e.activeMipmapLevel,Hn.mipLevelCount=1,Hn.baseArrayLayer=e.activeCubeFace,Hn.arrayLayerCount=1,Hn.dimension=Fa.TwoD,i.isRenderTarget3D)h=e.activeCubeFace,Hn.baseArrayLayer=0,Hn.dimension=Fa.ThreeD;else if(i.isRenderTarget&&u[f].image.depth>1)if(c===!0){let g=e.camera.cameras;for(let v=0;v<g.length;v++){Hn.baseArrayLayer=v,Hn.arrayLayerCount=1,Hn.dimension=Fa.TwoD;let y=m.texture.createView(Hn);d.push({view:y,resolveTarget:void 0,depthSlice:void 0})}}else Hn.dimension=Fa.TwoDArray;if(c!==!0){let g,v,y=m.texture.createView(Hn);m.msaaTexture!==void 0?(g=m.msaaTexture.createView(),v=y):(g=y,v=void 0),d.push({view:g,resolveTarget:v,depthSlice:h})}Hn.reset()}else d.push(...this._createExternalTextureViews(e,m))}let p=[];for(let f=0;f<d.length;f++){let m=d[f],g=new F_;g.view=m.view,g.depthSlice=m.depthSlice,g.resolveTarget=m.resolveTarget,p.push(g)}if(o={textureViews:d,colorAttachments:p,descriptor:new U_},e.depth){let f=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(Hn.dimension=Fa.TwoD,Hn.arrayLayerCount=1,Hn.baseArrayLayer=e.activeCubeFace);let m=new z2;m.view=f.texture.createView(Hn),o.depthStencilAttachment=m,Hn.reset()}s[a]=o,r.width=i.width,r.height=i.height,r.samples=i.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}let l=o.descriptor;l.reset();for(let h=0;h<o.colorAttachments.length;h++){let u=o.colorAttachments[h],d={r:0,g:0,b:0,a:1};h===0&&t.clearValue&&(d=t.clearValue),u.loadOp=t.loadOp||Xr.Load,u.storeOp=t.storeOp||Lo.Store,u.clearValue=d,l.colorAttachments.push(u)}return o.depthStencilAttachment&&(l.depthStencilAttachment=o.depthStencilAttachment),l}beginRender(e){let t,i,r=this.get(e),n=this.device,s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQuerySet&&r.currentOcclusionQuerySet.destroy(),r.currentOcclusionQueryBuffer&&r.currentOcclusionQueryBuffer.destroy(),r.currentOcclusionQuerySet=r.occlusionQuerySet,r.currentOcclusionQueryBuffer=r.occlusionQueryBuffer,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,W_.label=`occlusionQuerySet_${e.id}`,W_.type="occlusion",W_.count=s,t=n.createQuerySet(W_),W_.reset(),r.occlusionQuerySet=t,r.occlusionQueryIndex=0,r.occlusionQueryObjects=new Array(s),r.lastOcclusionObject=null),i=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:Xr.Load}),this.initTimestampQuery(Ku.RENDER,this.getTimestampUID(e),i),i.occlusionQuerySet=t;let a=i.depthStencilAttachment;if(e.textures!==null){let l=i.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];e.clearColor?(h===0?u.clearValue=e.clearColorValue:(tu.r=0,tu.g=0,tu.b=0,tu.a=1,u.clearValue=tu),u.loadOp=Xr.Clear):u.loadOp=Xr.Load,u.storeOp=Lo.Store}}else{let l=i.colorAttachments[0];e.clearColor?(l.clearValue=e.clearColorValue,l.loadOp=Xr.Clear):l.loadOp=Xr.Load,l.storeOp=Lo.Store}e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=Xr.Clear):a.depthLoadOp=Xr.Load,a.depthStoreOp=Lo.Store),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=Xr.Clear):a.stencilLoadOp=Xr.Load,a.stencilStoreOp=Lo.Store),Fo.label="renderContext_"+e.id;let o=n.createCommandEncoder(Fo);if(Fo.reset(),this._isRenderCameraDepthArray(e)===!0){let l=e.camera.cameras;r.layerDescriptors&&r.layerDescriptors.length===l.length?this._updateArrayCameraLayerDescriptors(e,r,l):this._createArrayCameraLayerDescriptors(e,r,i,l),r.bundleEncoders=[],r.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+h),d={attributes:{},bindingGroups:[],pipeline:null,index:null};r.bundleEncoders.push(u),r.bundleSets.push(d)}r.currentPass=null}else{let l=o.beginRenderPass(i);r.currentPass=l,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}r.descriptor=i,r.encoder=o,r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},r.renderBundles=[]}_createArrayCameraLayerDescriptors(e,t,i,r){let n=i.depthStencilAttachment;t.layerDescriptors=[];let s=this.get(e.depthTexture);s.viewCache||(s.viewCache=[]);for(let a=0;a<r.length;a++){let o=i.colorAttachments[0],l=new F_;l.view=i.colorAttachments[a].view,l.depthSlice=o.depthSlice,l.resolveTarget=o.resolveTarget,l.loadOp=o.loadOp,l.storeOp=o.storeOp,l.clearValue=o.clearValue;let h=new U_;if(h.label=i.label,h.occlusionQuerySet=i.occlusionQuerySet,h.timestampWrites=i.timestampWrites,h.colorAttachments.push(l),i.depthStencilAttachment){let u=a;s.viewCache[u]||(Hn.dimension=Fa.TwoD,Hn.baseArrayLayer=a,Hn.arrayLayerCount=1,s.viewCache[u]=s.texture.createView(Hn),Hn.reset());let d=new z2;d.view=s.viewCache[u],d.depthLoadOp=n.depthLoadOp||Xr.Clear,d.depthStoreOp=n.depthStoreOp||Lo.Store,d.depthClearValue=n.depthClearValue||1,e.stencil&&(d.stencilLoadOp=n.stencilLoadOp,d.stencilStoreOp=n.stencilStoreOp,d.stencilClearValue=n.stencilClearValue),h.depthStencilAttachment=d}else{let u=new z2;u.view=n.view,u.depthLoadOp=n.depthLoadOp,u.depthStoreOp=n.depthStoreOp,u.depthClearValue=n.depthClearValue,u.depthReadOnly=n.depthReadOnly,u.stencilLoadOp=n.stencilLoadOp,u.stencilStoreOp=n.stencilStoreOp,u.stencilClearValue=n.stencilClearValue,u.stencilReadOnly=n.stencilReadOnly,h.depthStencilAttachment=u}t.layerDescriptors.push(h)}}_updateArrayCameraLayerDescriptors(e,t,i){for(let r=0;r<i.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let s=n.depthStencilAttachment;e.depth&&(e.clearDepth?(s.depthClearValue=e.clearDepthValue,s.depthLoadOp=Xr.Clear):s.depthLoadOp=Xr.Load),e.stencil&&(e.clearStencil?(s.stencilClearValue=e.clearStencilValue,s.stencilLoadOp=Xr.Clear):s.stencilLoadOp=Xr.Load)}}}finishRender(e){let t=this.get(e),i=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),i>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let s=0;s<t.bundleEncoders.length;s++){let a=t.bundleEncoders[s];n.push(a.finish())}for(let s=0;s<t.layerDescriptors.length;s++)if(s<n.length){let a=t.layerDescriptors[s],o=r.beginRenderPass(a);if(e.viewport){let{x:l,y:h,width:u,height:d,minDepth:c,maxDepth:p}=e.viewportValue;o.setViewport(l,h,u,d,c,p)}if(e.scissor){let{x:l,y:h,width:u,height:d}=e.scissorValue;o.setScissorRect(l,h,u,d)}o.executeBundles([n[s]]),o.end()}}else t.currentPass&&t.currentPass.end();if(i>0){let n=8*i,s=this.occludedResolveCache.get(n);s===void 0&&(zl.size=n,zl.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,s=this.device.createBuffer(zl),zl.reset(),this.occludedResolveCache.set(n,s)),zl.size=n,zl.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(zl);zl.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,i,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,n),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(qd(this.device,t.encoder.finish()),e.textures!==null){let n=e.textures;for(let s=0;s<n.length;s++){let a=n[s];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(e,t){let i=this.get(e);return i.occluded&&i.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:i,currentOcclusionQueryObjects:r}=t;if(i&&r){let n=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await i.mapAsync(GPUMapMode.READ);let s=i.getMappedRange(),a=new BigUint64Array(s);for(let o=0;o<r.length;o++)a[o]===BigInt(0)&&n.add(r[o]);i.destroy(),t.occluded=n}}updateViewport(e){let{currentPass:t}=this.get(e),{x:i,y:r,width:n,height:s,minDepth:a,maxDepth:o}=e.viewportValue;t.setViewport(i,r,n,s,a,o)}updateScissor(e){let{currentPass:t}=this.get(e),{x:i,y:r,width:n,height:s}=e.scissorValue;t.setScissorRect(i,r,n,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,i,r=null){let n,s,a,o=this.device,l=this.renderer,h=[];if(e){let d=this.getClearColor();tu.r=d.r,tu.g=d.g,tu.b=d.b,tu.a=d.a}if(r===null){s=l.depth,a=l.stencil;let d=this._getDefaultRenderPassDescriptor();if(e){h=d.colorAttachments;let c=h[0];c.clearValue=tu,c.loadOp=Xr.Clear,c.storeOp=Lo.Store}(s||a)&&(n=d.depthStencilAttachment)}else{s=r.depth,a=r.stencil;let d={loadOp:e?Xr.Clear:Xr.Load,clearValue:e?tu:void 0};s&&(d.depthLoadOp=t?Xr.Clear:Xr.Load,d.depthClearValue=t?l.getClearDepth():void 0,d.depthStoreOp=Lo.Store),a&&(d.stencilLoadOp=i?Xr.Clear:Xr.Load,d.stencilClearValue=i?l.getClearStencil():void 0,d.stencilStoreOp=Lo.Store);let c=this._getRenderPassDescriptor(r,d);h=c.colorAttachments,n=c.depthStencilAttachment}s&&n&&(t?(n.depthLoadOp=Xr.Clear,n.depthClearValue=l.getClearDepth(),n.depthStoreOp=Lo.Store):(n.depthLoadOp=Xr.Load,n.depthStoreOp=Lo.Store)),a&&n&&(i?(n.stencilLoadOp=Xr.Clear,n.stencilClearValue=l.getClearStencil(),n.stencilStoreOp=Lo.Store):(n.stencilLoadOp=Xr.Load,n.stencilStoreOp=Lo.Store)),Fo.label="clear";let u=o.createCommandEncoder(Fo);Fo.reset(),u.beginRenderPass({colorAttachments:h,depthStencilAttachment:n}).end(),qd(o,u.finish())}beginCompute(e){let t=this.get(e),i="computeGroup_"+e.id;k2.label=i,Fo.label=i,this.initTimestampQuery(Ku.COMPUTE,this.getTimestampUID(e),k2),t.cmdEncoderGPU=this.device.createCommandEncoder(Fo),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(k2),t.currentPipeline=null,Fo.reset(),k2.reset()}compute(e,t,i,r,n=null){let s=this.get(t),a=this.get(e),{passEncoderGPU:o}=a,l=this.get(r).pipeline;a.currentPipeline!==l&&(o.setPipeline(l),a.currentPipeline=l);for(let h=0,u=i.length;h<u;h++){let d=i[h],c=this.get(d);o.setBindGroup(h,c.group)}if(n===null&&(n=t.dispatchSize||t.count),n&&n.isIndirectStorageBufferAttribute){let h=this.get(n).buffer;return void o.dispatchWorkgroupsIndirect(h,0)}if(typeof n=="number"){let h=n;if(s.dispatchSize===void 0||s.count!==h){s.dispatchSize=[0,1,1],s.count=h;let u=t.workgroupSize,d=u[0];for(let f=1;f<u.length;f++)d*=u[f];let c=Math.ceil(h/d),p=this.device.limits.maxComputeWorkgroupsPerDimension;n=[c,1,1],c>p&&(n[0]=Math.min(c,p),n[1]=Math.ceil(c/p)),s.dispatchSize=n}n=s.dispatchSize}o.dispatchWorkgroups(n[0],n[1]||1,n[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),qd(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,i,r,n,s,a,o,l){let{object:h,context:u}=e,d=e.drawMaterial,c=e.getIndex(),p=c!==null;l.pipeline!==r&&(o.setPipeline(r),l.pipeline=r);let f=l.bindingGroups;for(let m=0,g=n.length;m<g;m++){let v=n[m];if(f[m]!==v.id){let y=this.get(v);o.setBindGroup(m,y.group),f[m]=v.id}}if(p===!0&&l.index!==c){let m=this.get(c).buffer,g=c.array instanceof Uint16Array?HD.Uint16:HD.Uint32;o.setIndexBuffer(m,g),l.index=c}for(let m=0,g=s.length;m<g;m++){let v=s[m];if(l.attributes[m]!==v){let y=this.get(v).buffer;o.setVertexBuffer(m,y),l.attributes[m]=v}}if(u.stencil===!0&&d.stencilWrite===!0&&i.currentStencilRef!==d.stencilRef&&(o.setStencilReference(d.stencilRef),i.currentStencilRef=d.stencilRef),h.isBatchedMesh===!0){let m=h._multiDrawStarts,g=h._multiDrawCounts,v=h._multiDrawCount,y=p===!0?c.array.BYTES_PER_ELEMENT:1;d.wireframe&&(y=h.geometry.attributes.position.count>65535?4:2);for(let _=0;_<v;_++)p===!0?o.drawIndexed(g[_],1,m[_]/y,0,_):o.draw(g[_],1,m[_],_),t.update(h,g[_],1)}else if(p===!0){let{vertexCount:m,instanceCount:g,firstVertex:v}=a,y=e.getIndirect();if(y!==null){let _=this.get(y).buffer,b=e.getIndirectOffset(),x=Array.isArray(b)?b:[b];for(let w=0;w<x.length;w++)o.drawIndexedIndirect(_,x[w])}else o.drawIndexed(m,g,v,0,0);t.update(h,m,g)}else{let{vertexCount:m,instanceCount:g,firstVertex:v}=a,y=e.getIndirect();if(y!==null){let _=this.get(y).buffer,b=e.getIndirectOffset(),x=Array.isArray(b)?b:[b];for(let w=0;w<x.length;w++)o.drawIndirect(_,x[w])}else o.draw(m,g,v,0);t.update(h,m,g)}}draw(e,t){let{object:i,context:r,pipeline:n}=e,s=this.get(r),a=this.get(n),o=a.pipeline;if(a.error===!0)return;let l=e.getDrawParameters();if(l===null)return;let h=e.getBindings(),u=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let d=this.get(e.camera),c=e.camera.cameras,p=e.getBindingGroup("cameraIndex");if(d.indexesGPU===void 0||d.indexesGPU.length!==c.length){let m=this.get(p),g=[],v=new Uint32Array([0,0,0,0]);for(let y=0,_=c.length;y<_;y++){v[0]=y;let{layoutGPU:b}=m.layout,x=this.bindingUtils.createBindGroupIndex(v,b);g.push(x)}d.indexesGPU=g}let f=this.renderer.getPixelRatio();for(let m=0,g=c.length;m<g;m++){let v=c[m];if(i.layers.test(v.layers)){let y=v.viewport,_=s.currentPass,b=s.currentSets,x=s.bundleEncoders!==void 0;if(x&&(_=s.bundleEncoders[m],b=s.bundleSets[m]),y&&!x&&_.setViewport(Math.floor(y.x*f),Math.floor(y.y*f),Math.floor(y.width*f),Math.floor(y.height*f),r.viewportValue.minDepth,r.viewportValue.maxDepth),p&&d.indexesGPU){let w=h.indexOf(p);_.setBindGroup(w,d.indexesGPU[m]),b.bindingGroups[w]=p.id}this._draw(e,t,s,o,h,u,l,_,b)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let d=s.lastOcclusionObject;d!==i&&(d!==null&&d.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),i.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=i),s.lastOcclusionObject=i)}this._draw(e,t,s,o,h,u,l,s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),i=e.material,r=!1;return(t.material!==i||t.materialVersion!==i.version)&&(t.material=i,t.materialVersion=i.version,r=!0),this._syncStructuralState(t,e,i)||r}_syncStructuralState(e,t,i){let{object:r}=t,n=this.utils,s=n.getSampleCountRenderContext(t.context),a=n.getCurrentColorSpace(t.context),o=n.getCurrentColorFormat(t.context),l=n.getCurrentDepthStencilFormat(t.context),h=n.getPrimitiveTopology(r,i),u=r.isMesh&&r.matrixWorld.determinantAffine()<0,d=!1;return(e.transparent!==i.transparent||e.blending!==i.blending||e.premultipliedAlpha!==i.premultipliedAlpha||e.blendSrc!==i.blendSrc||e.blendDst!==i.blendDst||e.blendEquation!==i.blendEquation||e.blendSrcAlpha!==i.blendSrcAlpha||e.blendDstAlpha!==i.blendDstAlpha||e.blendEquationAlpha!==i.blendEquationAlpha||e.colorWrite!==i.colorWrite||e.depthWrite!==i.depthWrite||e.depthTest!==i.depthTest||e.depthFunc!==i.depthFunc||e.stencilWrite!==i.stencilWrite||e.stencilFunc!==i.stencilFunc||e.stencilFail!==i.stencilFail||e.stencilZFail!==i.stencilZFail||e.stencilZPass!==i.stencilZPass||e.stencilFuncMask!==i.stencilFuncMask||e.stencilWriteMask!==i.stencilWriteMask||e.side!==i.side||e.alphaToCoverage!==i.alphaToCoverage||e.polygonOffset!==i.polygonOffset||e.polygonOffsetFactor!==i.polygonOffsetFactor||e.polygonOffsetUnits!==i.polygonOffsetUnits||e.sampleCount!==s||e.colorSpace!==a||e.colorFormat!==o||e.depthStencilFormat!==l||e.primitiveTopology!==h||e.frontFaceCW!==u||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.transparent=i.transparent,e.blending=i.blending,e.premultipliedAlpha=i.premultipliedAlpha,e.blendSrc=i.blendSrc,e.blendDst=i.blendDst,e.blendEquation=i.blendEquation,e.blendSrcAlpha=i.blendSrcAlpha,e.blendDstAlpha=i.blendDstAlpha,e.blendEquationAlpha=i.blendEquationAlpha,e.colorWrite=i.colorWrite,e.depthWrite=i.depthWrite,e.depthTest=i.depthTest,e.depthFunc=i.depthFunc,e.stencilWrite=i.stencilWrite,e.stencilFunc=i.stencilFunc,e.stencilFail=i.stencilFail,e.stencilZFail=i.stencilZFail,e.stencilZPass=i.stencilZPass,e.stencilFuncMask=i.stencilFuncMask,e.stencilWriteMask=i.stencilWriteMask,e.side=i.side,e.alphaToCoverage=i.alphaToCoverage,e.polygonOffset=i.polygonOffset,e.polygonOffsetFactor=i.polygonOffsetFactor,e.polygonOffsetUnits=i.polygonOffsetUnits,e.sampleCount=s,e.colorSpace=a,e.colorFormat=o,e.depthStencilFormat=l,e.primitiveTopology=h,e.frontFaceCW=u,e.clippingContextCacheKey=t.clippingContextCacheKey,d=!0),d}detectStructuralChange(e){return this._syncStructuralState(this.get(e),e,e.material)}getAttachmentStateKey(e){let t=this.utils,i=e.context;return t.getSampleCountRenderContext(i)+","+t.getCurrentColorSpace(i)+","+t.getCurrentColorFormat(i)+","+t.getCurrentDepthStencilFormat(i)}syncRenderUpdateState(e,t){let i=this.get(e);i.material=e.material,i.materialVersion=e.material.version,this._syncStructuralState(i,e,t)}getVertexLayoutCacheKey(e){let{object:t,geometry:i}=e,r="";for(let n of this.attributeUtils.createShaderVertexBuffers(e)){r+=n.stepMode+":"+n.arrayStride+":";for(let s of n.attributes)r+=s.shaderLocation+"-"+s.offset+"-"+s.format+",";r+=";"}return i.index!==null&&t.isLine===!0&&t.isLineSegments!==!0&&(r+=i.index.array instanceof Uint16Array?"index-u16":"index-u32"),r}getRenderCacheKey(e){let{object:t}=e,i=e.drawMaterial,r=this.utils,n=e.context,s=t.isMesh&&t.matrixWorld.determinantAffine()<0,a=r.getSampleCountRenderContext(n),o=i.blending!==yi&&(i.blending!==Xs||i.transparent!==!1),l=o&&i.blending===Mg,h=n.depth===!0,u=n.stencil===!0,d=u&&i.stencilWrite===!0,c=r.getPrimitiveTopology(t,i),p=(h||u)&&i.polygonOffset===!0&&c===uv.TriangleList;return[o?i.blending:-1,o&&l===!1?i.premultipliedAlpha:-1,l?i.blendSrc:-1,l?i.blendDst:-1,l?i.blendEquation:-1,l?i.blendSrcAlpha!==null?i.blendSrcAlpha:i.blendSrc:-1,l?i.blendDstAlpha!==null?i.blendDstAlpha:i.blendDst:-1,l?i.blendEquationAlpha!==null?i.blendEquationAlpha:i.blendEquation:-1,i.colorWrite,h?i.depthWrite:-1,h&&i.depthTest===!0?i.depthFunc:-1,d?i.stencilFunc:-1,d?i.stencilFail:-1,d?i.stencilZFail:-1,d?i.stencilZPass:-1,u?i.stencilFuncMask:-1,u?i.stencilWriteMask:-1,p?i.polygonOffsetUnits:0,p?i.polygonOffsetFactor:0,i.alphaToCoverage===!0&&a>1,i.side,s,a,r.getCurrentColorSpace(n),r.getCurrentColorFormat(n),r.getCurrentDepthStencilFormat(n),c,this.getVertexLayoutCacheKey(e),e.clippingContextCacheKey,n.mrt!==null&&i.mrtWriteMask?JSON.stringify(i.mrtWriteMask):""].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,i,r,n,s){return this.textureUtils.copyTextureToBuffer(e,t,i,r,n,s)}initTimestampQuery(e,t,i){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new xme(this.device,e,2048));let r=this.timestampQueryPool[e],n=r.allocateQueriesForContext(t);G2.querySet=r.querySet,G2.beginningOfPassWriteIndex=n,G2.endOfPassWriteIndex=n+1,i.timestampWrites=G2}createNodeBuilder(e,t){return new ume(e,t)}createProgram(e){let t=this.get(e);V2.label=e.stage+(e.name!==""?`_${e.name}`:""),V2.code=e.code,t.module={module:this.device.createShaderModule(V2),entryPoint:"main"},V2.reset()}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let i=this.get(e),r=i.currentPass.finish();this.get(t).bundleGPU=r,i.currentSets=i._currentSets,i.currentPass=i._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createUniformBuffer(e){let t=this.get(e);if(t.buffer===void 0){let i=e.byteLength,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=[];e.visibility&qu.VERTEX&&n.push("vertex"),e.visibility&qu.FRAGMENT&&n.push("fragment"),e.visibility&qu.COMPUTE&&n.push("compute");let s=`(${n.join(",")})`;zl.label=`bindingBuffer${e.id}_${e.name}_${s}`,zl.size=i,zl.usage=r;let a=this.device.createBuffer(zl);zl.reset(),t.buffer=a}}destroyUniformBuffer(e){this.get(e).buffer.destroy(),this.delete(e)}createBindings(e,t,i,r){this.bindingUtils.createBindings(e,t,i,r)}updateBindings(e,t,i,r){this.bindingUtils.createBindings(e,t,i,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(e){return dj[e]!==void 0&&(e=dj[e]),this.device.features.has(e)}copyTextureToTexture(e,t,i=null,r=null,n=0,s=0){let a=0,o=0,l=0,h=0,u=0,d=0,c=e.image.width,p=e.image.height,f=1;i!==null&&(i.isBox3===!0?(h=i.min.x,u=i.min.y,d=i.min.z,c=i.max.x-i.min.x,p=i.max.y-i.min.y,f=i.max.z-i.min.z):(h=i.min.x,u=i.min.y,c=i.max.x-i.min.x,p=i.max.y-i.min.y,f=1)),r!==null&&(a=r.x,o=r.y,l=r.z||0),Fo.label="copyTextureToTexture_"+e.id+"_"+t.id;let m=this.device.createCommandEncoder(Fo);Fo.reset();let g=this.get(e).texture,v=this.get(t).texture;fh.texture=g,fh.mipLevel=n,fh.origin.x=h,fh.origin.y=u,fh.origin.z=d,Xu.texture=v,Xu.mipLevel=s,Xu.origin.x=a,Xu.origin.y=o,Xu.origin.z=l,nc.width=c,nc.height=p,nc.depthOrArrayLayers=f,m.copyTextureToTexture(fh,Xu,nc),fh.reset(),Xu.reset(),nc.reset(),qd(this.device,m.finish()),s===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,i){let r=this.get(t),n=null;n=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let s,a=this.get(e).texture;if(n.format===a.format)if(r.currentPass?(r.currentPass.end(),s=r.encoder):(Fo.label="copyFramebufferToTexture_"+e.id,s=this.device.createCommandEncoder(Fo),Fo.reset()),fh.texture=n,fh.origin.x=i.x,fh.origin.y=i.y,Xu.texture=a,nc.width=i.z,nc.height=i.w,s.copyTextureToTexture(fh,Xu,nc),fh.reset(),Xu.reset(),nc.reset(),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,s),r.currentPass){let{descriptor:o}=r;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=Xr.Load;t.depth&&(o.depthStencilAttachment.depthLoadOp=Xr.Load),t.stencil&&(o.depthStencilAttachment.stencilLoadOp=Xr.Load),r.currentPass=s.beginRenderPass(o),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else qd(this.device,s.finish());else qe("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",n.format,a.format)}hasCompatibility(e){return this._compatibility[e]!==void 0?this._compatibility[e]:super.hasCompatibility(e)}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},Mme=class extends by{constructor(e,t,i,r,n,s){super(e,t,i,r,n,s),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},Eme=class extends by{constructor(e,t,i,r,n,s){super(e,t,i,r,n,s),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},Ame=class extends UG{constructor(){super(),this.addMaterial(Iq,"MeshPhongMaterial"),this.addMaterial(SO,"MeshStandardMaterial"),this.addMaterial(Lq,"MeshPhysicalMaterial"),this.addMaterial(Bq,"MeshToonMaterial"),this.addMaterial(Dq,"MeshBasicMaterial"),this.addMaterial(Nq,"MeshLambertMaterial"),this.addMaterial(Rq,"MeshNormalMaterial"),this.addMaterial(Fq,"MeshMatcapMaterial"),this.addMaterial(Cq,"LineBasicMaterial"),this.addMaterial(Pq,"LineDashedMaterial"),this.addMaterial(XA,"PointsMaterial"),this.addMaterial(TO,"SpriteMaterial"),this.addMaterial(Uq,"ShadowMaterial"),this.addLight(Vq,CA),this.addLight(Gq,PA),this.addLight(afe,y_e),this.addLight(hE,by),this.addLight(tfe,v_e),this.addLight(jq,vB),this.addLight(rfe,__e),this.addLight(ife,Mme),this.addLight(sfe,Eme),this.addToneMapping(H8,fL),this.addToneMapping(q8,mL),this.addToneMapping($8,gL),this.addToneMapping(X8,wA),this.addToneMapping(Y8,SA),this.addToneMapping(K8,TA)}},AO=class extends _fe{constructor(e={}){let t;e.forceWebGL?t=sj:(t=Tme,e.getFallback=()=>(rt("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new sj(e))),super(new t(e),e),this.library=new Ame,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},XTe=class{constructor(e,t=wt(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;let i=new Jt;i.name="RenderPipeline",this._quadMesh=new Cn(i),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){let e=this.renderer;this._update(),this._context.onBeforeRenderPipeline!==null&&this._context.onBeforeRenderPipeline();let t=e.toneMapping,i=e.outputColorSpace;e.toneMapping=Os,e.outputColorSpace=ni.workingColorSpace;let r=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=r,e.toneMapping=t,e.outputColorSpace=i,this._context.onAfterRenderPipeline!==null&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),this.needsUpdate===!0){let e=this._toneMapping,t=this._outputColorSpace,i={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null},r=this.outputNode;this.outputColorTransform===!0?(r=r.context(i),r=vV(r,e,t)):(i.toneMapping=e,i.outputColorSpace=t,r=r.context(i)),this._context=i,this._quadMesh.material.fragmentNode=r,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){xr('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}},YTe=class extends Ci{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=it,this.minFilter=it,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}},Ey=class extends Ci{constructor(e=1,t=1,i=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:i},this.magFilter=it,this.minFilter=it,this.wrapR=mr,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,i){(this.image.width!==e||this.image.height!==t||this.image.depth!==i)&&(this.image.width=e,this.image.height=t,this.image.depth=i,this.dispose())}}}),gi=F(()=>{mn(),N.BRDF_GGX,N.BRDF_Lambert,N.BasicPointShadowFilter,N.BasicShadowFilter,qa=N.Break,N.Const,N.Continue,N.DFGLUT,N.D_GGX,CO=N.Discard,N.EPSILON,N.F_Schlick,He=N.Fn,N.INFINITY,ze=N.If,Yr=N.Loop,N.NodeAccess,N.NodeShaderStage,N.NodeType,KTe=N.NodeUpdateType,N.PCFShadowFilter,N.PCFSoftShadowFilter,Wq=N.PI,N.PI2,N.TWO_PI,N.HALF_PI,ZTe=N.PointShadowFilter,yn=N.Return,N.Schlick_to_F0,N.ShaderNode,N.Stack,N.Switch,N.TBNViewMatrix,N.VSMShadowFilter,N.V_GGX_SmithCorrelated,N.Var,N.VarIntent,oi=N.abs,N.acesFilmicToneMapping,PO=N.acos,N.acosh,N.add,N.addMethodChaining,N.addNodeElement,N.agxToneMapping,N.all,N.alphaT,N.ambientOcclusion,N.and,N.anisotropy,N.anisotropyB,N.anisotropyT,GK=N.any,N.append,N.array,jK=N.asin,N.asinh,N.assign,Af=N.atan,N.atanh,yh=N.atomicAdd,N.atomicAnd,N.atomicFunc,Xv=N.atomicLoad,N.atomicMax,N.atomicMin,N.atomicOr,kl=N.atomicStore,RO=N.atomicSub,N.atomicXor,N.attenuationColor,N.attenuationDistance,cw=N.attribute,N.attributeArray,N.backgroundBlurriness,N.backgroundIntensity,N.backgroundRotation,N.batch,N.bentNormalView,N.billboarding,N.bitAnd,N.bitNot,N.bitOr,N.bitXor,N.bitangentGeometry,N.bitangentLocal,N.bitangentView,N.bitangentWorld,QTe=N.bitcast,N.blendBurn,N.blendColor,N.blendDodge,N.blendOverlay,N.blendScreen,N.blur,JTe=N.bool,e2e=N.buffer,N.bufferAttribute,N.bumpMap,N.builtin,N.builtinAOContext,N.builtinShadowContext,N.bvec2,N.bvec3,N.bvec4,N.bypass,N.cache,N.call,N.cameraFar,N.cameraIndex,t2e=N.cameraNear,N.cameraNormalMatrix,Kf=N.cameraPosition,Bw=N.cameraProjectionMatrix,i2e=N.cameraProjectionMatrixInverse,bu=N.cameraViewMatrix,N.cameraViewport,D4=N.cameraWorldMatrix,N.cbrt,N.cdl,N.ceil,N.checker,N.cineonToneMapping,qt=N.clamp,r2e=N.clearcoat,n2e=N.clearcoatNormalView,WK=N.clearcoatRoughness,N.clipSpace,N.code,s2e=N.color,N.colorSpaceToWorking,N.colorToDirection,N.compute,N.computeKernel,N.computeSkinning,N.context,N.convert,N.convertColorSpace,a2e=N.convertToTexture,N.countLeadingZeros,N.countOneBits,N.countTrailingZeros,$o=N.cos,N.cosh,qn=N.cross,o2e=N.cubeTexture,N.cubeTextureBase,pw=N.dFdx,fw=N.dFdy,N.dashSize,N.debug,N.decrement,N.decrementBefore,N.defaultBuildStages,N.defaultShaderStages,N.defined,N.degrees,N.deltaTime,N.densityFog,N.densityFogFactor,JB=N.depth,N.depthPass,N.determinant,N.difference,Wl=N.diffuseColor,N.directPointLight,N.directionToColor,N.directionToFaceDirection,N.dispersion,l2e=N.distance,N.div,Je=N.dot,N.drawIndex,N.dynamicBufferAttribute,N.element,Hq=N.emissive,N.equal,N.equirectDirection,N.equirectUV,eF=N.exp,qb=N.exp2,N.exponentialHeightFogFactor,N.expression,tF=N.faceDirection,N.faceForward,N.faceforward,L=N.float,N.floatBitsToInt,N.floatBitsToUint,At=N.floor,h2e=N.fog,fr=N.fract,N.frameGroup,N.frameId,u2e=N.frontFacing,qq=N.fwidth,N.gain,N.gapSize,N.getConstNodeType,N.getCurrentStack,N.getDirection,N.getDistanceAttenuation,N.getGeometryRoughness,N.getNormalFromDepth,$f=N.interleavedGradientNoise,t0=N.vogelDiskSample,N.getParallaxCorrectNormal,N.getRoughness,N.getScreenPosition,N.getShIrradianceAt,N.getShadowMaterial,N.getShadowRenderObjectFunction,N.getTextureIndex,HK=N.getViewPosition,dl=N.globalId,N.glsl,N.glslFn,N.grayscale,N.greaterThan,N.greaterThanEqual,N.hash,N.highpModelNormalViewMatrix,N.highpModelViewMatrix,N.hue,N.increment,N.incrementBefore,N.instance,wa=N.instanceIndex,$n=N.instancedArray,vg=N.instancedBufferAttribute,d2e=N.instancedDynamicBufferAttribute,N.instancedMesh,Pe=N.int,N.intBitsToFloat,N.inverse,qK=N.inverseSqrt,N.inversesqrt,N.invocationLocalIndex,N.invocationSubgroupIndex,DO=N.ior,c2e=N.iridescence,p2e=N.iridescenceIOR,f2e=N.iridescenceThickness,Va=N.ivec2,Ga=N.ivec3,N.ivec4,N.js,N.label,$i=N.length,N.lengthSq,N.lessThan,N.lessThanEqual,N.lightPosition,N.lightProjectionUV,N.lightShadowMatrix,m2e=N.lightTargetDirection,N.lightTargetPosition,N.lightViewPosition,g2e=N.lightingContext,N.lights,N.linearDepth,N.linearToneMapping,NO=N.localId,N.log,mw=N.log2,N.logarithmicDepthToViewZ,iF=N.luminance,N.mat2,$g=N.mat3,$K=N.mat4,N.matcapUV,N.materialAO,N.materialAlphaTest,N.materialAnisotropy,N.materialAnisotropyVector,N.materialAttenuationColor,N.materialAttenuationDistance,N.materialClearcoat,N.materialClearcoatNormal,N.materialClearcoatRoughness,v2e=N.materialColor,N.materialDispersion,N.materialEmissive,IO=N.materialEnvIntensity,N.materialEnvRotation,N.materialIOR,N.materialIridescence,N.materialIridescenceIOR,N.materialIridescenceThickness,N.materialLightMap,N.materialLineDashOffset,N.materialLineDashSize,N.materialLineGapSize,N.materialLineScale,N.materialLineWidth,N.materialMetalness,N.materialNormal,N.materialOpacity,N.materialPointSize,y2e=N.materialReference,N.materialReflectivity,N.materialRefractionRatio,N.materialRotation,N.materialRoughness,N.materialSheen,N.materialSheenRoughness,N.materialShininess,N.materialSpecular,N.materialSpecularColor,N.materialSpecularIntensity,N.materialSpecularStrength,N.materialThickness,N.materialTransmission,pt=N.max,N.maxMipLevel,N.mediumpModelViewMatrix,_2e=N.metalness,Li=N.min,lt=N.mix,N.mixElement,vd=N.mod,N.modelDirection,b2e=N.modelNormalMatrix,N.modelPosition,N.modelRadius,x2e=N.modelScale,w2e=N.modelViewMatrix,N.modelViewPosition,OO=N.modelViewProjection,rF=N.modelWorldMatrix,S2e=N.modelWorldMatrixInverse,N.morphReference,gw=N.mrt,T2e=N.mul,N.mx_aastep,N.mx_add,N.mx_atan2,N.mx_cell_noise_float,N.mx_contrast,N.mx_divide,N.mx_fractal_noise_float,N.mx_fractal_noise_vec2,N.mx_fractal_noise_vec3,N.mx_fractal_noise_vec4,N.mx_frame,N.mx_heighttonormal,N.mx_hsvtorgb,N.mx_ifequal,N.mx_ifgreater,N.mx_ifgreatereq,N.mx_invert,N.mx_modulo,N.mx_multiply,N.mx_noise_float,N.mx_noise_vec3,N.mx_noise_vec4,N.mx_place2d,N.mx_power,N.mx_ramp4,N.mx_ramplr,N.mx_ramptb,N.mx_rgbtohsv,N.mx_rotate2d,N.mx_rotate3d,N.mx_safepower,N.mx_separate,N.mx_splitlr,N.mx_splittb,N.mx_srgb_texture_to_lin_rec709,N.mx_subtract,N.mx_timer,N.mx_transform_uv,N.mx_unifiednoise2d,N.mx_unifiednoise3d,N.mx_worley_noise_float,N.mx_worley_noise_vec2,N.mx_worley_noise_vec3,N.negate,$q=N.negateOnBackSide,N.neutralToneMapping,N.nodeArray,M2e=N.nodeImmutable,N.nodeObject,N.nodeObjectIntent,N.nodeObjects,N.nodeProxy,N.nodeProxyIntent,N.normalFlat,E2e=N.normalGeometry,XK=N.normalLocal,N.normalMap,To=N.normalView,N.normalViewGeometry,KA=N.normalWorld,A2e=N.normalWorldGeometry,Ft=N.normalize,N.not,YK=N.notEqual,N.numWorkgroups,N.objectDirection,N.objectGroup,N.objectPosition,N.objectRadius,N.objectScale,N.objectViewPosition,N.objectWorldMatrix,N.OnBeforeObjectUpdate,N.OnBeforeMaterialUpdate,N.OnObjectUpdate,N.OnMaterialUpdate,Pn=N.oneMinus,N.or,C2e=N.orthographicDepthToViewZ,N.oscSawtooth,N.oscSine,N.oscSquare,N.oscTriangle,P2e=N.output,N.outputStruct,N.overloadingFn,N.overrideNode,N.overrideNodes,N.packHalf2x16,N.packSnorm2x16,N.packUnorm2x16,R2e=N.packNormalToRGB,N.parabola,N.parallaxDirection,N.parallaxUV,N.parameter,D2e=N.pass,N2e=N.passTexture,N.pcurve,I2e=N.perspectiveDepthToViewZ,O2e=N.pmremTexture,N.pointShadow,N.pointUV,N.pointWidth,nF=N.positionGeometry,vw=N.positionLocal,sF=N.positionPrevious,Zf=N.positionView,yw=N.positionViewDirection,Jl=N.positionWorld,N.positionWorldDirection,N.posterize,Xl=N.pow,L2e=N.pow2,N.pow3,B2e=N.pow4,N.premultiplyAlpha,N.property,N.radians,KK=N.rand,N.range,N.rangeFog,F2e=N.rangeFogFactor,N.reciprocal,N.reference,N.referenceBuffer,ZA=N.reflect,N.reflectVector,N.reflectView,N.reflector,U2e=N.refract,N.refractVector,N.refractView,N.reinhardToneMapping,N.remap,N.remapClamp,$b=N.renderGroup,N.renderOutput,N.rendererReference,N.replaceDefaultUV,N.rotate,N.rotateUV,ZK=N.roughness,z2e=N.round,N.rtt,N.sRGBTransferEOTF,N.sRGBTransferOETF,N.sample,cy=N.sampler,N.samplerComparison,N.saturate,N.saturation,N.screen,Zo=N.screenCoordinate,N.screenDPR,N.screenSize,gu=N.screenUV,Xi=N.select,N.setCurrentStack,N.setName,N.shaderStages,N.shadow,N.shadowPositionWorld,N.shapeCircle,N.sharedUniformGroup,k2e=N.sheen,V2e=N.sheenRoughness,N.shiftLeft,N.shiftRight,N4=N.shininess,Vc=N.sign,Aa=N.sin,N.sinh,N.sinc,N.skinning,Kr=N.smoothstep,N.smoothstepElement,px=N.specularColor,Xq=N.specularF90,N.spherizeUV,N.split,N.spritesheetUV,Rh=N.sqrt,N.stack,ar=N.step,N.stepElement,G2e=N.storage,N.storageBarrier,N.storageTexture,yg=N.storageTexture3D,N.struct,uE=N.sub,N.subgroupAdd,N.subgroupAll,N.subgroupAnd,N.subgroupAny,N.subgroupBallot,N.subgroupBroadcast,N.subgroupBroadcastFirst,j2e=N.subBuild,N.subgroupElect,N.subgroupExclusiveAdd,N.subgroupExclusiveMul,N.subgroupInclusiveAdd,N.subgroupInclusiveMul,N.subgroupIndex,N.subgroupMax,N.subgroupMin,N.subgroupMul,N.subgroupOr,N.subgroupShuffle,N.subgroupShuffleDown,N.subgroupShuffleUp,N.subgroupShuffleXor,N.subgroupSize,N.subgroupXor,W2e=N.tan,N.tanh,N.tangentGeometry,N.tangentLocal,N.tangentView,N.tangentWorld,mt=N.texture,Cf=N.texture3D,N.textureBarrier,N.textureBicubic,N.textureBicubicLevel,N.textureCubeUV,N.textureLoad,H2e=N.textureSize,N.textureLevel,N.textureStore,N.thickness,q2e=N.time,N.toneMapping,N.toneMappingExposure,N.toonOutlinePass,QK=N.transformDirection,N.transformNormal,N.transformNormalByInverseViewMatrix,N.transformNormalByViewMatrix,I4=N.transformNormalToView,N.transformedClearcoatNormalView,N.transformedNormalView,N.transformedNormalWorld,N.transmission,N.transpose,N.triNoise3D,N.triplanarTexture,N.triplanarTextures,N.trunc,Ar=N.uint,N.uintBitsToFloat,Be=N.uniform,QA=N.uniformArray,N.uniformCubeTexture,N.uniformGroup,N.uniformFlow,N.uniformTexture,N.unpackHalf2x16,N.unpackSnorm2x16,N.unpackUnorm2x16,N.unpackRGBToNormal,N.unpremultiplyAlpha,_g=N.userData,Hi=N.uv,N.uvec2,$2e=N.uvec3,N.uvec4,X2e=N.varying,Bn=N.varyingProperty,Se=N.vec2,Q=N.vec3,Ae=N.vec4,N.vectorComponents,N.velocity,Y2e=N.vertexColor,rA=N.vertexIndex,Yq=N.vertexStage,N.vibrance,N.viewZToLogarithmicDepth,Kq=N.viewZToOrthographicDepth,N.viewZToPerspectiveDepth,N.viewZToReversedOrthographicDepth,N.viewZToReversedPerspectiveDepth,N.viewport,N.viewportCoordinate,N.viewportDepthTexture,N.viewportLinearDepth,N.viewportMipTexture,N.viewportOpaqueMipTexture,N.viewportResolution,N.viewportSafeUV,N.viewportSharedTexture,N.viewportSize,N.viewportTexture,N.viewportUV,py=N.wgsl,mf=N.wgslFn,K2e=N.workgroupArray,Xb=N.workgroupBarrier,LO=N.workgroupId,N.workingToColorSpace,N.xor});function aF(){try{return new URLSearchParams(window.location.search).get("dbgsrgb8")!=="0"}catch{return!0}}var Zq,Hl,Dc,Qq,Cme,Pme,Si,tt,ua=F(()=>{ne(),gi(),Zq=8,Hl=new Ci,Dc=(()=>{let e=new Nr(new Uint8Array([0,0,0,255]),1,1);return e.minFilter=it,e.magFilter=it,e.needsUpdate=!0,e})(),Qq=(()=>{let e=new Nr(new Uint8Array([0,0,0,255]),1,1);return e.minFilter=it,e.magFilter=it,e.needsUpdate=!0,e})(),Cme=(()=>{let e=new Nr(new Uint8Array([255,255,255,255]),1,1);return e.minFilter=it,e.magFilter=it,e.needsUpdate=!0,e})(),Pme=(()=>{let e=new Nr(new Uint8Array([0,0,0,0]),1,1);return e.minFilter=it,e.magFilter=it,e.needsUpdate=!0,e})(),Si={chainBuilds:0,lastChainBuildReason:"",taaResolves:0,taaJitterIndex:0,taaJitterApplies:0,taaHistoryValid:!1,taaResolveSize:"",helperOverlayMode:"",deviceLost:"",outputInterpositions:0,bundleChecks:0,bundleRebuilds:0,bundleDisabled:!1,bundleResourceRebuilds:0,bundleIncompleteRecords:0,bundleRecords:0,bundleReplays:0,instancingGroups:0,instancedDrawsSaved:0,instancingRegroups:0,instancingParks:0,instancingIneligible:{},skippedAsyncDraws:0,stalledSkipFrames:0,compilationBurst:!1,pcssLights:0,pcssInstalled:0,pcssForeignFilter:0,pcssPyramidBuilds:0,pcssPyramidActive:0,shadowMaskResolves:0,shadowMaskActive:0,pcssHookServes:0,pcssRadius0:0,pcssPenumbra0:0,nodeResurrections:0,shadowTypeSoft:!0,depthPrepassDraws:0,depthOfFieldTwinDraws:0},typeof window<"u"&&(window.__SPLINE_WEBGPU_STATS=Si),tt={resolution:Be(new Z(1,1)),pixelRatio:Be(1),frameIndex:Be(0),aspectRatio:Be(new Z(1,1)),transmissionRenderTarget:mt(Hl),normalRenderTarget:mt(Hl),normalRenderTargetDepth:mt(Hl),normalViewRenderTarget:mt(Hl),aoRenderTarget:mt(Hl),reflectionRenderTarget:mt(Dc),reflectionDepthPyramid:mt(Dc),reflectionDepthSize:Be(new Z(1,1)),reflectionDepthLevels:Be(1,"int"),reflectionEnvMap:mt(Dc),reflectionEnvEnabled:Be(0),reflectionPlanarTarget:mt(Dc),reflectionPlanarEnabled:Be(0),reflectionMissColor:Be(new P(0,0,0)),reflectionResolveTarget:mt(Qq),reflectionResolveEnabled:Be(0),shadowMaskTexture:mt(Cme),shadowMaskGBuffer:mt(Pme),shadowMaskEnabled:Be(0),shadowMaskResolution:Be(new Z(1,1)),shadowMaskFullResolution:Be(new Z(1,1)),transmissionSamplerSize:Be(new Z(2048,2048)),transmissionActualSize:Be(new Z(1,1)),orthographicUniform:Be(0),unjitteredProjection:Be(new De),aoEnabledUniform:Be(0),pcssHalton:Be(new Z(0,-.333334)),tapAngle:Be(0),tapAngle2:Be(0),cameraJitterPx:Be(new Z(0,0)),toonLightData:QA(Array.from({length:Zq},()=>new ut),"vec4"),toonLightCount:Be(0,"int"),taaEnabled:{value:!1},aoEnabled:{value:!1},transmissionLod:{value:2}}});function PUe(e,t){return new Z2e(e,t)}var yv,eN,j2,tN,Z2e,BO,RUe=F(()=>{ne(),mn(),gi(),ua(),yv=new Cn,eN=new Z,j2=[[0,0],[0,1,1],[0,1,1,2],[0,1,2,2,3],[0,1,2,3,4,4,5],[0,1,2,3,4,5,7,8,9,10]],tN=[.2126729,.7151522,.072175],Z2e=class extends En{constructor(e,t){super("vec4"),this._width=0,this._height=0,this._materials=[],this._input=e,this._opts=t,this._rtL=this._makeRT(1,1,"SplineBloom.L"),this._rtA=this._makeRT(1,1,"SplineBloom.A"),this._rtB=this._makeRT(1,1,"SplineBloom.B"),this._outputTexNode=mt(this._rtL.texture),this._buildMaterials()}static get type(){return"SplineBloomNode"}_makeRT(e,t,i){let r=new Fi(e,t,{minFilter:it,magFilter:it,depthBuffer:!1});return aF()&&(r.texture.internalFormat="rgba8unorm-srgb"),r.texture.name=i,r}_buildMaterials(){for(let h of this._materials)h.dispose();this._materials=[];let e=(h,u)=>{let d=new Jt;return d.name=h,d.colorNode=u,d.depthTest=!1,d.depthWrite=!1,d.blending=yi,d.needsUpdate=!0,d},t=this._opts.luminanceThreshold,i=Math.max(this._opts.luminanceSmoothing,1e-4),r=this._input,n=He(()=>{let h=r.sample(Hi()),u=Kr(L(t),L(t+i),Je(h.rgb,Q(tN[0],tN[1],tN[2])));return Ae(h.rgb.mul(u),u)});this._materials.push(e("SplineBloom.luminance",n()));let s=j2[this._opts.kernelSize]??j2[3],a=1/Math.max(1,this._width),o=1/Math.max(1,this._height),l=this._passSequence(s.length);for(let h=0;h<s.length;h++){let u=a*(s[h]+.5)*this._opts.blurScale,d=o*(s[h]+.5)*this._opts.blurScale,c=mt(l[h].from.texture),p=He(()=>{let f=Hi();return c.sample(f.add(Se(-u,d))).add(c.sample(f.add(Se(u,d)))).add(c.sample(f.add(Se(u,-d)))).add(c.sample(f.add(Se(-u,-d)))).mul(.25)});this._materials.push(e(`SplineBloom.blur${h}`,p()))}}_passSequence(e){let t=[],i=this._rtL;for(let r=0;r<e-1;r++){let n=1&r?this._rtB:this._rtA;t.push({from:i,to:n}),i=n}return t.push({from:i,to:this._rtL}),t}renderBloom(e){e.getDrawingBufferSize(eN);let t=Math.max(1,Math.round(.5*eN.x)),i=Math.max(1,Math.round(.5*eN.y));(t!==this._width||i!==this._height)&&(this._width=t,this._height=i,this._rtL.dispose(),this._rtA.dispose(),this._rtB.dispose(),this._rtL=this._makeRT(t,i,"SplineBloom.L"),this._rtA=this._makeRT(t,i,"SplineBloom.A"),this._rtB=this._makeRT(t,i,"SplineBloom.B"),this._outputTexNode.value=this._rtL.texture,this._buildMaterials());let r=j2[this._opts.kernelSize]??j2[3],n=this._passSequence(r.length),s=e.getRenderTarget(),a=e.getMRT();e.setMRT(null),e.setRenderTarget(this._rtL),yv.material=this._materials[0],yv.name="SplineBloom.luminance",yv.render(e);for(let o=0;o<n.length;o++)e.setRenderTarget(n[o].to),yv.material=this._materials[o+1],yv.name=`SplineBloom.blur${o}`,yv.render(e);e.setRenderTarget(s),e.setMRT(a)}setup(){return this._outputTexNode}dispose(){for(let e of this._materials)e.dispose();this._materials=[],this._rtL.dispose(),this._rtA.dispose(),this._rtB.dispose()}}}),DUe={},NUe=F(()=>{Su(),RUe(),cTe("bloom",PUe)}),Q2e=F(()=>{BO={focusDistance:0,focalLength:200,bokehScale:1}});function IUe(e,t,i,r,n){return new J2e(e,t,i,r,n)}var iN,rN,W2,J2e,OUe=F(()=>{ne(),mn(),gi(),ua(),Q2e(),iN=new Cn,rN=new Z,W2=[0,1,1,2],J2e=class extends En{constructor(e,t,i,r,n){super("vec4"),this._width=0,this._height=0,this._halfWidth=0,this._halfHeight=0,this._materials=[],this._inputColor=e,this._input=t,this._depth=i,this._params=r,this._opts=n,this._rtCoC=this._makeRT(1,1,"DoF.CoC","coc"),this._rtMasked=this._makeRT(1,1,"DoF.Masked.Far","color"),this._rtCoCBlurred=this._makeRT(1,1,"DoF.CoC.Blurred","coc"),this._rtBlurA=this._makeRT(1,1,"DoF.Blur.Target.A","blur"),this._rtBlurB=this._makeRT(1,1,"DoF.Blur.Target.B","blur"),this._rtIntermediate=this._makeRT(1,1,"DoF.Intermediate","color"),this._rtNear=this._makeRT(1,1,"DoF.Bokeh.Near","color"),this._rtFar=this._makeRT(1,1,"DoF.Bokeh.Far","color"),this._nearTexNode=mt(this._rtNear.texture),this._farTexNode=mt(this._rtFar.texture),this._cocBlurredTexNode=mt(this._rtCoCBlurred.texture),this._buildMaterials()}static get type(){return"SplineDepthOfFieldNode"}_makeRT(e,t,i,r){let n=new Fi(e,t,{minFilter:it,magFilter:it,depthBuffer:!1,type:r==="color"&&this._opts.halfFloat?li:void 0});return r!=="coc"&&n.texture.type!==li&&aF()&&(n.texture.internalFormat="rgba8unorm-srgb"),n.texture.name=i,n}_buildMaterials(){for(let x of this._materials)x.dispose();this._materials=[];let e=(x,w)=>{let S=new Jt;return S.name=x,S.colorNode=w,S.depthTest=!1,S.depthWrite=!1,S.blending=yi,S.needsUpdate=!0,S},{focusDistance:t,focusRange:i,bokehScale:r,cameraNear:n,cameraFar:s}=this._params,a=this._params.orthographic,o=this._input,l=this._depth,h=this._opts.inputUv??(x=>x),u=x=>x,d=1/Math.max(1,this._halfWidth),c=1/Math.max(1,this._halfHeight),p=He(()=>{let x=Hi().toVar(),w=l.sample(x).toVar(),S=Kq(I2e(w,n,s),n,s),T=Kq(C2e(w,n,s),n,s),M=Xi(a.greaterThan(.5),T,S).sub(t).toVar(),E=Kr(L(0),i,oi(M)).toVar();return Ae(E.mul(ar(M,L(0))),E.mul(ar(L(0),M)),0,1)});this._materials.push(e("SplineDoF.coc",p()));let f=this._cocBlurSequence();for(let x=0;x<W2.length;x++){let w=d*W2[x]+.5*d,S=c*W2[x]+.5*c,T=mt(f[x].from.texture),M=He(()=>{let E=Hi();return T.sample(E.add(Se(-w,S))).add(T.sample(E.add(Se(w,S)))).add(T.sample(E.add(Se(w,-S)))).add(T.sample(E.add(Se(-w,-S)))).mul(.25)});this._materials.push(e(`SplineDoF.cocBlur${x}`,M()))}let m=mt(this._rtCoC.texture),g=He(()=>{let x=Hi().toVar(),w=qt(m.sample(x).g.mul(r),0,1);return o.sample(h(x)).mul(w)});this._materials.push(e("SplineDoF.mask",g()));let v=function(){let x=new Float32Array(128),w=0;for(let S=0;S<80;++S){if(S%5==0)continue;let T=2.39996323*S,M=Math.sqrt(S)/Math.sqrt(80);x[w++]=M*Math.cos(T),x[w++]=M*Math.sin(T)}return x}(),y=(x,w,S,T,M)=>{let E=He(()=>{let A=Hi().toVar(),C=S.sample(A).toVar(),D=(T?C.r:C.g).mul(r).toVar(),R=Ae(0).toVar();return ze(D.equal(0),()=>{R.assign(w.sample(M(A)))}).Else(()=>{let I=T?pt(D,C.g.mul(r)):D,U=Se(d,c).mul(I).toVar(),O=Ae(0).toVar();for(let k=0;k<v.length;k+=2)O.addAssign(w.sample(M(A.add(U.mul(Se(v[k],v[k+1]))))));R.assign(O.div(64))}),R});return e(x,E())},_=mt(this._rtCoCBlurred.texture),b=mt(this._rtIntermediate.texture);this._materials.push(y("SplineDoF.farBase",mt(this._rtMasked.texture),m,!1,u),y("SplineDoF.farFill",b,m,!1,u),y("SplineDoF.nearBase",o,_,!0,h),y("SplineDoF.nearFill",b,_,!0,u))}_cocBlurSequence(){let e=[],t=this._rtCoC;for(let i=0;i<W2.length-1;i++){let r=1&i?this._rtBlurB:this._rtBlurA;e.push({from:t,to:r}),t=r}return e.push({from:t,to:this._rtCoCBlurred}),e}renderDoF(e){e.getDrawingBufferSize(rN);let t=Math.max(1,Math.round(rN.x)),i=Math.max(1,Math.round(rN.y));if(t!==this._width||i!==this._height){this._width=t,this._height=i,this._halfWidth=Math.max(1,Math.round(.5*t)),this._halfHeight=Math.max(1,Math.round(.5*i)),this._disposeTargets();let o=this._halfWidth,l=this._halfHeight;this._rtCoC=this._makeRT(t,i,"DoF.CoC","coc"),this._rtMasked=this._makeRT(t,i,"DoF.Masked.Far","color"),this._rtCoCBlurred=this._makeRT(o,l,"DoF.CoC.Blurred","coc"),this._rtBlurA=this._makeRT(o,l,"DoF.Blur.Target.A","blur"),this._rtBlurB=this._makeRT(o,l,"DoF.Blur.Target.B","blur"),this._rtIntermediate=this._makeRT(o,l,"DoF.Intermediate","color"),this._rtNear=this._makeRT(o,l,"DoF.Bokeh.Near","color"),this._rtFar=this._makeRT(o,l,"DoF.Bokeh.Far","color"),this._nearTexNode.value=this._rtNear.texture,this._farTexNode.value=this._rtFar.texture,this._cocBlurredTexNode.value=this._rtCoCBlurred.texture,this._buildMaterials()}let r=this._cocBlurSequence(),n=[this._rtCoC,...r.map(o=>o.to),this._rtMasked,this._rtIntermediate,this._rtFar,this._rtIntermediate,this._rtNear],s=e.getRenderTarget(),a=e.getMRT();e.setMRT(null);for(let o=0;o<n.length;o++)e.setRenderTarget(n[o]),iN.material=this._materials[o],iN.name=this._materials[o].name,iN.render(e);e.setRenderTarget(s),e.setMRT(a)}setup(){let e=this._nearTexNode,t=this._farTexNode,i=Li(this._cocBlurredTexNode.r.mul(this._params.bokehScale),1),r=this._inputColor.mul(t.a.oneMinus()).add(t);return lt(r,e,i)}_disposeTargets(){this._rtCoC.dispose(),this._rtMasked.dispose(),this._rtCoCBlurred.dispose(),this._rtBlurA.dispose(),this._rtBlurB.dispose(),this._rtIntermediate.dispose(),this._rtNear.dispose(),this._rtFar.dispose()}dispose(){for(let e of this._materials)e.dispose();this._materials=[],this._disposeTargets()}}}),LUe={},BUe=F(()=>{Su(),OUe(),cTe("depthOfField",IUe)}),FUe=xw((e,t)=>{t.exports=function(i,r){for(var n=i.split("."),s=r.split("."),a=0;a<3;a++){var o=Number(n[a]),l=Number(s[a]);if(o>l)return 1;if(l>o)return-1;if(!isNaN(o)&&isNaN(l))return 1;if(isNaN(o)&&!isNaN(l))return-1}return 0}}),eMe={};ww(eMe,{Perfs:()=>tMe});var tMe,iMe,UUe=F(()=>{tMe=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}}}),zUe=F(()=>{iMe=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]]});function Rme(e){let{fog:t,backupFog:i}=e,r=[e,e.scene!==e?e.scene:void 0];if(t!=null&&i!==void 0){for(let n of r)n&&(n.fogNode=rMe);Jq.value.copy(i.color),e$.value=i.near,t$.value=i.far,dE.value=Xn.getModeIndex({mode:e.fogMode}),i$.value.set(e.fogDensity??Xn.getDensity({}),e.fogHeightFalloff??Xn.getHeightFalloff({}),e.fogHeightBase??Xn.getHeightBase({}))}else if(t===null)for(let n of r)n?.fogNode&&(n.fogNode=null)}var Jq,e$,t$,dE,i$,r$,Dme,rMe,Tj,Nme,Mj,nN,_v,Ime,nMe,sMe=F(()=>{ne(),Ot(),gi(),Jq=Be(new at(1,1,1)).setGroup($b),e$=Be(.1).setGroup($b),t$=Be(2e3).setGroup($b),dE=Be(0).setGroup($b),i$=Be(new P(.005,.01,0)).setGroup($b),r$=He(([e,t,i,r])=>{let n=r.x,s=r.y,a=i.y.sub(r.z),o=n.mul(s.mul(a).negate().clamp(-60,60).exp()),l=s.mul(e.y).clamp(-60,60).toVar(),h=Xi(l.greaterThanEqual(0),L(1),L(-1)).mul(l.abs().max(1e-4));return o.mul(t).mul(L(1).sub(h.negate().exp())).div(h).max(0).negate().exp().oneMinus()}),Dme=He(()=>{let e=Jl.sub(Kf).toVar(),t=e.length().max(1e-6);return r$(e,t,Kf,i$)}),rMe=(()=>{let e=L(1).sub(ar(.5,dE)).add(ar(1.5,dE)),t=ar(.5,dE),i=L(1).sub(L(1).sub(F2e(e$,t$).mul(e)).mul(L(1).sub(Dme().mul(t))));return h2e(Jq,i)})()}),kUe=F(()=>{ne(),mn(),gi(),zUe(),sMe(),Tj=e=>e,Nme=e=>e,Mj=e=>e,nN=(e,t,i)=>At(e.add(.5).mul(t)).add(.5).div(i),_v=new Cn,Ime=new at,nMe=class{constructor(){this._gBuffer=null,this._aoBuffer=null,this._hbaoMaterial=null,this._resolveMaterial=null,this._boundBlueNoise=null,this._frameIndex=0,this._projectionMatrixInverse=Be(new De),this._isOrtho=Be(0),this._resolution=Be(new Z(1,1)),this._fullResolution=Be(new Z(1,1)),this._radiusOfInfluence=Be(128),this._radiusInScreenSpace=Be(1),this._exponent=Be(1),this._aoColor=Be(new at(0,0,0)),this._bias=Be(.5),this._frame=Be(0),this._fogEnabled=Be(0),this._fogNear=Be(1),this._fogFar=Be(1e3),this._fogMode=Be(0),this._fogHeightParams=Be(new P(.005,.01,0)),this._cameraWorldMatrix=Be(new De);let e=new Jt;e.name="SplineHBAO.gbuffer",e.side=Cr,e.fragmentNode=Ae(To.mul(tF),1),e.lights=!1,e.blending=yi,e.needsUpdate=!0,this._normalMaterial=e}_ensureTarget(e,t,i,r){return e&&e.width===t&&e.height===i?{target:e,changed:!1}:(e?.dispose(),{target:r(),changed:!0})}_buildHBAOMaterial(e,t){let i=mt(this._gBuffer.depthTexture),r=mt(this._gBuffer.texture),n=mt(t),s=this._projectionMatrixInverse,a=this._isOrtho,o=this._resolution,l=this._fullResolution,h=this._radiusOfInfluence,u=this._radiusInScreenSpace,d=this._exponent,c=this._aoColor,p=this._bias,f=this._frame,m=this._fogEnabled,g=this._fogNear,v=this._fogFar,y=this._fogMode,_=this._fogHeightParams,b=this._cameraWorldMatrix,x=e.reversedDepthBuffer===!0,w=A=>i.sample(A),S=(A,C)=>HK(A,C,s),T=A=>S(A,w(A)),M=He(()=>{let A=Hi().toVar(),C=o,D=l,R=At(A.mul(C)).toVar(),I=D.div(C).toVar(),U=nN(R,I,D).toVar(),O=w(U).toVar(),k=S(U,O).toVar(),G=Ft(r.sample(U).xyz).toVar(),K=pt(u.div(lt(k.z.negate(),L(1),a)),L(5)).toVar(),q=Va(Pe(Zo.xy.x).bitAnd(Pe(127)),Pe(Zo.xy.y).bitAnd(Pe(127))),Y=n.load(q).xyz.x,ue=fr(Y.add(L(.61803398875).mul(f))).mul(6.283),de=$o(ue).toVar(),ge=Aa(ue).toVar(),be=K.div(5).toVar(),re=L(0).toVar();for(let Fe=0;Fe<4;Fe++){let We=be.add(1).toVar();for(let Re=0;Re<4;Re++){let[ee,Ee]=iMe[4*Fe+Re],je=Se(de.mul(ee).sub(ge.mul(Ee)),ge.mul(ee).add(de.mul(Ee))),dt=Nme(R.add(z2e(je.mul(We)))).toVar(),et=Mj(T(nN(dt,I,D))).toVar();We.addAssign(be);let $t=Mj(et.sub(k)).toVar(),ii=Tj($t.dot($t)).toVar(),nr=Rh(ii),xt=Tj(G.dot($t)).div(pt(nr,L(1e-4))),Dt=ii.mul(L(-1).div(h.mul(h))).add(1);re.addAssign(qt(xt.sub(p),0,1).mul(qt(Dt,0,1)))}}let xe=L(1).div(L(1).sub(p));re.mulAssign(xe.div(16));let j=qt(L(1).sub(re.mul(2)),0,1),z=Xl(j,d).toVar(),X=x?O.lessThanEqual(0):O.greaterThanEqual(1);z.assign(X.select(L(1),z));let te=Q(lt(c,Q(1),z)).toVar(),V=Kr(g,v,k.z.negate()),ae=b.mul(Ae(k,1)).xyz,se=b.mul(Ae(0,0,0,1)).xyz,W=ae.sub(se).toVar(),pe=r$(W,W.length().max(1e-6),se,_),_e=y,Ue=L(1).sub(ar(.5,_e)).add(ar(1.5,_e)),we=ar(.5,_e),Ye=L(1).sub(L(1).sub(V.mul(Ue)).mul(L(1).sub(pe.mul(we)))).mul(m);return te.assign(lt(te,Q(1),Ye)),Ae(te,1)}),E=new Jt;return E.name="SplineHBAO.hbao",E.colorNode=M(),E.depthTest=!1,E.depthWrite=!1,E.blending=yi,E.needsUpdate=!0,E}_buildResolveMaterial(){let e=mt(this._aoBuffer.texture),t=mt(this._gBuffer.depthTexture),i=this._resolution,r=this._fullResolution,n=He(()=>{let a=Hi().toVar(),o=i,l=r,h=Se(L(1).div(o.x),L(1).div(o.y)).toVar(),u=a.sub(h.mul(.5)).toVar(),d=u.add(Se(h.x,0)).toVar(),c=u.add(Se(0,h.y)).toVar(),p=u.add(h).toVar(),f=t.sample(a).toVar(),m=l.div(o).toVar(),g=T=>t.sample(nN(T,m,l)),v=At(u.mul(o)).toVar(),y=f.sub(g(v)).abs().toVar(),_=f.sub(g(v.add(Se(1,0)))).abs().toVar(),b=f.sub(g(v.add(Se(0,1)))).abs().toVar(),x=f.sub(g(v.add(Se(1,1)))).abs().toVar(),w=y.min(_).min(b).min(x).toVar(),S=p.toVar();return S.assign(w.equal(b).select(c,S)),S.assign(w.equal(_).select(d,S)),S.assign(w.equal(y).select(u,S)),e.sample(S)}),s=new Jt;return s.name="SplineHBAO.resolve",s.colorNode=n(),s.depthTest=!1,s.depthWrite=!1,s.blending=yi,s.needsUpdate=!0,s}render(e,t,i,r,n,s){let a=s.width,o=s.height,l=r.aoFullRes!==!0,h=l?.5:1,u=Math.max(1,Math.round(a*h)),d=Math.max(1,Math.round(o*h)),c=this._hbaoMaterial===null,p=this._ensureTarget(this._gBuffer,a,o,()=>new Fi(a,o,{type:li,depthTexture:new ns(a,o),minFilter:it,magFilter:it}));if(this._gBuffer=p.target,c=c||p.changed,l){let E=this._ensureTarget(this._aoBuffer,u,d,()=>new Fi(u,d,{minFilter:it,magFilter:it,depthBuffer:!1}));this._aoBuffer=E.target,c=c||E.changed}c=c||this._boundBlueNoise!==n;let f=l;(c||f&&this._resolveMaterial===null)&&(this._hbaoMaterial?.dispose(),this._resolveMaterial?.dispose(),this._hbaoMaterial=this._buildHBAOMaterial(e,n),this._resolveMaterial=f?this._buildResolveMaterial():null,this._boundBlueNoise=n);let m=i,g=m.projectionMatrix.elements,v=g[11]===0;if(this._projectionMatrixInverse.value.copy(m.projectionMatrixInverse),this._isOrtho.value=v?1:0,this._resolution.value.set(u,d),this._fullResolution.value.set(a,o),this._radiusOfInfluence.value=r.radius,v){let E=2/g[5];this._radiusInScreenSpace.value=r.radius*(d/E*.5)}else{let E=d*g[5]/2;this._radiusInScreenSpace.value=.5*r.radius*E}this._bias.value=r.bias,this._aoColor.value.setRGB(r.aoColor.r,r.aoColor.g,r.aoColor.b),this._fogEnabled.value=r.fogEnabled?1:0,this._fogNear.value=r.fogNear,this._fogFar.value=r.fogFar,this._fogMode.value=r.fogMode,this._fogHeightParams.value.set(r.fogDensity,r.fogHeightFalloff,r.fogHeightBase),this._cameraWorldMatrix.value.copy(i.matrixWorld),this._frame.value=this._frameIndex,this._frameIndex++;let y=e,_=t,b=_.overrideMaterial,x=y.getRenderTarget(),w=y.getMRT(),S=y.getClearColor(Ime),T=y.getClearAlpha(),M=i.layers.mask;i.layers.set(5),_.overrideMaterial=this._normalMaterial,y.setMRT(null),y.setClearColor(0,0),y.setRenderTarget(this._gBuffer),y.render(t,i),_.overrideMaterial=b,i.layers.mask=M,_v.material=this._hbaoMaterial,_v.name="SplineHBAO.hbao",y.setRenderTarget(l?this._aoBuffer:s),_v.render(e),l&&(_v.material=this._resolveMaterial,_v.name="SplineHBAO.resolve",y.setRenderTarget(s),_v.render(e)),y.setRenderTarget(x),y.setMRT(w),y.setClearColor(S,T)}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._aoBuffer?.dispose(),this._aoBuffer=null,this._normalMaterial.dispose(),this._hbaoMaterial?.dispose(),this._hbaoMaterial=null,this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._boundBlueNoise=null}}});function Vx(e){let t=n$.get(e);return t||(t={texture:null,version:0,rotation:new Rr,quality:"full"},n$.set(e,t)),t}function FO(e){let t=Vx(e.environmentScope),i=t.texture,r=e.lights&&e.category==="physical"&&i!==null&&(t.quality==="full"||e.envReflectiveInLow?.()!==!1),n=e.envNode instanceof _w;r?(!n||e.envNode.sourceTexture!==i)&&(e.envNode=new _w(i),e.needsUpdate=!0):n&&(e.envNode=null,e.needsUpdate=!0)}function Ej(e){for(let t of JA){let i=t.deref();i===void 0?JA.delete(t):i.environmentScope===e&&FO(i)}}function Ome(e,t){let i=null;return{getUV:()=>{if(i===null){let r=cE(yw.negate().reflect(t));r=B2e(e).mix(cE(r),t),r=cE(r).normalize(),i=cE(r).transformDirection(D4)}return i},getTextureLevel:()=>e}}var cE,n$,aMe,JK,JA,pE,Aj,_w,O4,oMe,eZ=F(()=>{ne(),mn(),gi(),cE=e=>e,n$=new WeakMap,aMe={},JK=0,JA=new Set,pE=new WeakMap,Aj=new WeakMap,_w=class extends Oq{constructor(e){super(null),this.sourceTexture=e}static get type(){return"SplineEnvironmentNode"}setup(e){let t=function(a){let o=Aj.get(a);return o===void 0&&(o=O2e(a),Aj.set(a,o)),o}(this.sourceTexture),i=e.context,r=t.context(Ome(ZK,To)).mul(IO);i.radiance.addAssign(new JE(r));let n=t.context({getUV:()=>KA,getTextureLevel:()=>L(1)}).mul(Math.PI).mul(IO);i.iblIrradiance.addAssign(new JE(n));let s=i.lightingModel?.clearcoatRadiance;if(s){let a=t.context(Ome(WK,n2e)).mul(IO);s.addAssign(new JE(a))}return null}},O4=class extends vB{},oMe=class extends jq{static get type(){return"SplineSkyHemisphereLightNode"}setup(e){return e.material?.envNode instanceof _w?null:super.setup(e)}}});function tZ(){return X2e(cw("randomColor","vec3")).setInterpolation(J1e.FLAT,e_e.EITHER)}var iZ=F(()=>{ne(),gi()}),VUe=F(()=>{qSe()});function s$(e){return e?.depthPrepass===!0}function lMe(e){return a$&&e.transparent&&e.depthTest&&!e.wireframe&&!e.shapeBlend&&!function(t){let i=t?.layers;if(!i)return!1;for(let r of i)if(r.data.type==="transmission"&&r.data.visible)return!0;return!1}(e.data)}var a$,H2,Cj,Lme,Bme,sN,Fme,o$,l$,Yv,h$,rZ,bv,Pj,nZ,oF=F(()=>{a$=!0;try{a$=new URLSearchParams(window.location.search).get("dbgdepthprepass")!=="0"}catch{}}),hMe=F(()=>{gi(),ua(),H2=e=>e,Cj=e=>e,Lme=e=>e,Bme=e=>e,sN=.25,Fme=256/(2*Math.PI),o$=.075,l$=(e,t,i,r,n)=>{let s=Q(0).toVar();return ze(r.lessThan(.5),()=>{s.assign(e.sample(t).level(n).rgb)}).Else(()=>{let a=Q(0).toVar(),o=L(0).toVar();for(let l=0;l<12;l++){let h=Math.sqrt((l+.5)/12),u=2.399963229728653*l,d=h*Math.cos(u),c=h*Math.sin(u),p=Math.exp(-2.5*h*h),f=Lme(Bme(e.sample(Se(H2(t.x).add(i.mul(d)),H2(t.y).add(i.mul(c)))).level(n)).rgb);a.addAssign(f.mul(p)),o.addAssign(L(p))}s.assign(a.div(o))}),s},Yv=(e,t,i,r)=>{let n=Ae(t.mul(2).sub(1),L(1).sub(i).mul(2).sub(1),r,1),s=e.mul(n).toVar();return s.xyz.div(s.w)},h$=(e,t,i,r)=>{let n=tt.reflectionEnvEnabled,s=tt.reflectionMissColor,a=i.greaterThan(.05),o=r??Xi(a,L(.6),L(1)),l=Af(t.z,t.x).div(2*Math.PI).add(.5),h=jK(qt(t.y,L(-1),L(1))).div(Math.PI).add(.5),u=Li(mw(i.mul(o).mul(sN*Fme).add(1)),L(8)),d=e.sample(Se(l,h)).level(u).rgb;return Xi(n.greaterThan(.5),d,s)},rZ=e=>{let{dials:t,surface:i,camera:r,resources:n}=e,{blur:s,thickness:a,steps:o,stepSize:l,tracingMode:h}=t,{colorMap:u,depthPyramid:d,depthPyramidNode:c,envMap:p}=n,f=e.usePlanar,m=tt.reflectionDepthSize,g=tt.reflectionDepthLevels,v=(q,Y)=>d.load(q).level(Y).r.add(1e-6),y=tt.orthographicUniform.greaterThan(.5),_=Xi(y,Q(0,0,-1),Ft(i.originView)).toVar(),b=i.normalV.toVar(),x=ZA(_,b).toVar(),w=qt(s.mul(.1),L(0),L(1)).toVar(),S=tt.resolution,T=w.greaterThan(.05),M=e.singleRay?L(1):Xi(T,L(.6),L(1)),E=(q,Y,ue,de)=>{let ge=Ft(QK(q,r.worldMatrix)).toVar(),be=L(1).sub(Kr(L(.85),L(.99),q.z)).toVar(),re=i.originView.toVar(),xe=re.z.negate().max(r.near).toVar(),j=L(xe.mul(10)).toVar();ze(q.z.greaterThan(1e-5),()=>{let We=r.near.negate().sub(re.z).div(q.z);j.assign(Li(j,We.mul(.95).max(1e-4)))});let z,X=re.add(q.mul(j)).toVar(),te=Q(i.screenUv,i.fragWindowZ).toVar(),V=(We=>{let Re=r.projectionMatrix.mul(Ae(We,1)).toVar(),ee=Re.xyz.div(Re.w);return Q(ee.x.mul(.5).add(.5),ee.y.mul(-.5).add(.5),ee.z)})(X).toVar(),ae=w.mul(S.y).mul(o$).toVar();if(de){let We=ae.mul(m.y.div(S.y)).toVar(),Re=Li(L(.8),L(12).div(We.max(.001))).toVar();de.assign(We.mul(Re)),z=L(1).sub(Re.mul(Re)).max(0).sqrt().toVar()}let se=V.sub(te).toVar(),W=pt(se.xy.length(),L(1e-5)).toVar(),pe=L(0).toVar(),_e=Q(0).toVar(),Ue=()=>{let We=g.sub(1).toVar(),Re=Pe(1).toVar(),ee=Pe(0).toVar(),Ee=(ci,Ei)=>Li(ci,Ei),je=se,dt=je.div(je.z).toVar(),et=Q(te).toVar(),$t=Se(Xi(je.x.greaterThanEqual(0),L(1),L(-1)),Xi(je.y.greaterThanEqual(0),L(1),L(-1))).toVar(),ii=$t.mul(1e-5).toVar();$t.assign(qt($t,Se(0),Se(1)));let nr=ci=>Se(H2e(c,ci)),xt=(ci,Ei)=>ci.mul(Ei).floor(),Dt=(ci,Ei,Or)=>{let Wr=Se(1).div(Or),Ji=Ei.div(Or).add(Wr.mul($t)).sub(ci.xy).div(je.xy).toVar(),Yi=ci.add(je.mul(Li(Ji.x,Ji.y))).toVar();return Yi.xy.addAssign(Xi(Ji.x.lessThan(Ji.y),Se(ii.x,0),Se(0,ii.y))),Yi},Kt=nr(Re),Mi=xt(et.xy,Kt);et.assign(Dt(et,Mi,Kt)),Yr(256,()=>{ze(Re.lessThan(Pe(0)).or(ee.greaterThanEqual(Y)),()=>{qa()});let ci=nr(Re).toVar(),Ei=xt(et.xy,ci).toVar(),Or=v(Va(Pe(Ei.x),Pe(Ei.y)),Re).toVar(),Wr=Q(et).toVar();ze(je.z.greaterThan(0),()=>{let Ji=Or.sub(et.z).toVar();ze(Ji.greaterThan(0),()=>{Wr.assign(et.add(dt.mul(Ji)))});let Yi=xt(Wr.xy,ci).toVar();ze(((Hr,Ie)=>Pe(Hr.x).notEqual(Pe(Ie.x)).or(Pe(Hr.y).notEqual(Pe(Ie.y))))(Ei,Yi),()=>{Wr.assign(Dt(et,Ei,ci)),Re.assign(Ee(We,Re.add(Pe(2))))}).Else(()=>{ze(Re.equal(Pe(1)).and(Ji.abs().greaterThan(a)),()=>{Wr.assign(Dt(et,Ei,ci)),Re.assign(Pe(2))})})}).Else(()=>{ze(et.z.lessThan(Or),()=>{Wr.assign(Dt(et,Ei,ci)),Re.assign(Ee(We,Re.add(Pe(2))))})}),et.assign(Wr),Re.subAssign(Pe(1)),ee.addAssign(Pe(1))});let _i=et.x.greaterThan(0).and(et.x.lessThan(1)).and(et.y.greaterThan(0)).and(et.y.lessThan(1)).and(et.z.greaterThan(0)).and(et.z.lessThan(1));ze(Re.lessThan(Pe(0)).and(ee.lessThan(Y)).and(_i),()=>{pe.assign(1),_e.assign(et);let ci=et.xy.sub(te.xy).length().div(W).clamp(0,1),Ei=ci.sub(L(2).div(m.y).div(W)).max(0),Or=Q(te.add(se.mul(Ei))).toVar(),Wr=Q(te.add(se.mul(ci))).toVar(),Ji=Q(Wr).toVar();for(let Yi=0;Yi<4;Yi++){Ji.assign(lt(Or,Wr,.5));let Hr=H2(v(Va(Cj(Ji.xy).mul(m)),Pe(0)));ze(Ji.z.sub(Hr).greaterThan(0),()=>{Wr.assign(Ji)}).Else(()=>{Or.assign(Ji)})}_e.assign(Ji)})},we=()=>{let We=pt(l,L(1e-4)),Re=L(We).toVar(),ee=Q(te).toVar(),Ee=Q(te).toVar(),je=L(-1).toVar();Yr(256,({i:dt})=>{ze(dt.greaterThanEqual(Y),()=>{qa()});let et=L(dt).mul(Re).div(W).toVar();ze(et.greaterThan(1),()=>{qa()}),Ee.assign(se.mul(et).add(te));let $t=Ee.x.lessThan(0).or(Ee.x.greaterThan(1)).or(Ee.y.lessThan(0)).or(Ee.y.greaterThan(1)).or(Ee.z.lessThan(0)).or(Ee.z.greaterThan(1));ze($t,()=>{qa()});let ii=v(Va(Ee.xy.mul(m)),Pe(0)).toVar(),nr=Ee.z.sub(ii).toVar();ze(je.lessThanEqual(0).and(nr.greaterThan(0)),()=>{let xt=Q(ee).toVar(),Dt=Q(Ee).toVar(),Kt=Q(Ee).toVar(),Mi=L(nr).toVar();for(let _i=0;_i<4;_i++){Kt.assign(lt(xt,Dt,.5));let ci=H2(v(Va(Cj(Kt.xy).mul(m)),Pe(0)));Mi.assign(Kt.z.sub(ci)),ze(Mi.greaterThan(0),()=>{Dt.assign(Kt)}).Else(()=>{xt.assign(Kt)})}ze(Mi.abs().lessThan(a),()=>{pe.assign(1),_e.assign(Kt),qa()})}),je.assign(nr),ee.assign(Ee),Re.addAssign(We.div(2))})};ze(be.greaterThan(0).and(f.not()),()=>{typeof h=="number"?h===1?Ue():we():ze(h.greaterThan(.5),()=>{Ue()}).Else(()=>{we()})});let Ye=h$(p,ge,w,z).toVar(),Fe=Q(Ye).toVar();return ze(pe.greaterThan(.5),()=>{let We=_e.xy.sub(te.xy).length().div(W).clamp(0,1).toVar(),Re=re.z.negate().max(1e-4).toVar(),ee=X.z.negate().max(1e-4).toVar(),Ee=lt(L(1).div(Re),L(1).div(ee),We).toVar(),je=lt(re.div(Re),X.div(ee),We).div(Ee),dt=lt(re,X,We),et=Xi(y,dt,je).toVar(),$t=et.sub(re).length().toVar(),ii=r.projectionMatrix.element(1).y.mul(S.y).mul(.5),nr=Xi(y,L(1),et.z.abs().max(1e-4)),xt=w.mul(M).mul(sN).mul($t).mul(ii).div(nr),Dt=pt(xt,ae).toVar(),Kt=Dt.mul(m.y.div(S.y)).toVar(),Mi=Kt.toVar(),_i=Dt.toVar();if(de){let Ve=Li(L(.8),L(12).div(Kt.max(.001))).toVar();de.assign(Kt.mul(Ve)),Mi.assign(Kt.mul(L(1).sub(Ve.mul(Ve)).max(0).sqrt())),_i.assign(Mi.mul(S.y.div(m.y)))}let ci=L(g.sub(1)),Ei=Li(mw(Mi.add(1)),ci),Or=ue?l$(u,_e.xy,_i.mul(.75).div(S.y),Mi.mul(.75),Ei.sub(1).max(0).floor()).toVar():u.sample(_e.xy).level(Ei).rgb.toVar(),Wr=Ve=>Kr(L(0),L(.07),Ve).mul(Kr(L(0),L(.07),L(1).sub(Ve))),Ji=Wr(_e.x).mul(Wr(_e.y)),Yi=_e.xy.mul(m),Hr=v(Va(Yi),Pe(0)),Ie=Yv(r.projectionMatrixInverse,_e.x,_e.y,Hr).toVar(),th=Je(Ie.sub(re),b),Pd=Kr(xe.mul(-.05),xe.mul(-.005),th),bi=L(1).div(m.x),Tl=L(1).div(m.y),Yc=v(Va(Yi.sub(Se(1,0))),Pe(0)),Rd=v(Va(Yi.add(Se(1,0))),Pe(0)),Dd=v(Va(Yi.sub(Se(0,1))),Pe(0)),Ml=v(Va(Yi.add(Se(0,1))),Pe(0)),Vi=Yv(r.projectionMatrixInverse,_e.x.sub(bi),_e.y,Yc),Nd=Yv(r.projectionMatrixInverse,_e.x.add(bi),_e.y,Rd),Id=Yv(r.projectionMatrixInverse,_e.x,_e.y.sub(Tl),Dd),El=Yv(r.projectionMatrixInverse,_e.x,_e.y.add(Tl),Ml),Es=Ft(qn(Nd.sub(Vi),El.sub(Id))).toVar(),Tu=Xi(Es.z.lessThan(0),Es.negate(),Es),gn=Kr(L(.02),L(.12),Je(Tu,q).negate()),oe=be.mul(Ji).mul(Pd).mul(gn);Fe.assign(lt(Ye,Or,oe))}),Fe};if(e.singleRay)return E(x,o,!0,e.singleRay.footprintOut).toVar();let A=e.noisePixel,C=fr(L(52.9829189).mul(fr(A.x.mul(.06711056).add(A.y.mul(.00583715))))).mul(2*Math.PI).toVar(),D=Xi(x.y.abs().greaterThan(.99),Q(1,0,0),Q(0,1,0)),R=Ft(qn(D,x)).toVar(),I=qn(x,R).toVar(),U=(q,Y=4)=>{let ue=w.mul(sN*Math.sqrt((q+.5)/Y)),de=C.add(2.399963229728653*q);return Ft(x.mul($o(ue)).add(R.mul($o(de)).add(I.mul(Aa(de))).mul(Aa(ue)))).toVar()},O=T.and(f.not()),k=Xi(O,U(0),x).toVar(),G=Q(0).toVar();G.addAssign(E(k,o,!0));let K=L(1).toVar();return ze(O,()=>{G.addAssign(E(U(2),o,!1)),K.assign(2),ze(w.greaterThan(.35),()=>{G.addAssign(E(U(1),o,!1)),G.addAssign(E(U(3),o,!1)),K.assign(4)})}),G.div(K).toVar()}}),uMe=F(()=>{ne(),gi(),Ot(),ua(),bv=new Z,(nZ=Pj=class extends ds{constructor(e){super(),this.postprocessingState=UA.defaultData,this.sceneTransitionPass={uniforms:{mixRatio:Be(0),uDPR:{value:1},uResolution:{value:new Z}}},this.sceneTransitionFromTexture=null,this.watermarkTexture=null,this.uiCanvasTexture=null,this.uiOverlayEnabled=!1,this._isUIOverlayEnabled=!1,this._helpersEnabled=!0,this._renderToScreen=!0,this._rt=null,this._effectChain=null,this._effectChainDirty=!1,this.blueNoiseTexture=new Nr,this._rebuildCount=0,this._rebuildLogAt=0,this._chainUiTexture=null,this._chainWatermark=null,this._chainTransitionTexture=null,this._chainHdr=!1,this.lastOutputTarget=null,this._renderer=e}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){this._renderToScreen=e}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}get depthOfFieldDepthTexture(){let e=this._effectChain;return e?.renderDoFPasses?e.sceneDepthTexture():null}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableHelpers(){this._helpersEnabled=!0}disableHelpers(){this._helpersEnabled=!1}get helpersEnabled(){return this._helpersEnabled}setWatermark(e){this.watermarkTexture=e,this._effectChainDirty=!0}updateBlueNoiseTexture(e){this.blueNoiseTexture.dispose();let t=new Nr(e,128,128);t.wrapS=rs,t.wrapT=rs,t.minFilter=gt,t.magFilter=gt,t.needsUpdate=!0,this.blueNoiseTexture=t}static _topologyJSON(e){let t=e,i={};for(let r of Object.keys(t)){let n=t[r],s=Pj.UNIFORM_BACKED_FIELDS[r];if(s&&n&&typeof n=="object"){let a={...n};for(let o of s)delete a[o];i[r]=a}else i[r]=n}return JSON.stringify(i)}updatePostprocessing(e){this.postprocessingState=e;let t=Pj._topologyJSON(e);this._postprocessingJSON!==t&&(this._postprocessingJSON=t,this._effectChainDirty=!0)}_needsEffectChain(){if(this._renderer.temporalAAEnabled||this.uiOverlayEnabled&&this.uiCanvasTexture||this.watermarkTexture||this.sceneTransitionFromTexture)return!0;if(this.postprocessingState.enabled!==!0)return!1;let e=this.postprocessingState;for(let t of Object.keys(e)){let i=e[t];if(i&&typeof i=="object"&&i.enabled===!0)return!0}return!1}render(){let{scene:e,camera:t}=this;if(!e||!t)return;let i=this._renderer;if(i.warmupInFlight)return;let r=!1;if(!this._renderToScreen&&i.getRenderTarget()===null){i.getDrawingBufferSize(bv);let n=Math.max(1,Math.round(bv.x)),s=Math.max(1,Math.round(bv.y));this._rt===null?this._rt=new Fi(n,s,{depthBuffer:!0}):(this._rt.width!==n||this._rt.height!==s)&&(this._rt.dispose(),this._rt=new Fi(n,s,{depthBuffer:!0})),i.setRenderTarget(this._rt),r=!0}this.lastOutputTarget=r?this._rt:i.getRenderTarget();try{this._renderFrame(e,t)}finally{r&&i.setRenderTarget(null)}}_renderFrame(e,t){let i=this._renderer;i.renderStarted=!0,i.normalizeCameraCoordinateSystem(t);let r=this._needsEffectChain(),n=null;this._effectChainDirty?n="postprocessing/watermark":r!==(this._effectChain!==null)?n="chain presence":this._effectChain!==null&&(this._chainUiTexture!==(this.uiOverlayEnabled?this.uiCanvasTexture:null)?n="ui overlay texture":this._chainWatermark!==this.watermarkTexture?n="watermark texture":this.sceneTransitionFromTexture!==null&&this._chainTransitionTexture!==this.sceneTransitionFromTexture?n="transition texture":this._chainHdr!==i.hdrChainActive&&(n="grading pipeline"));let s=n!==null;if(s&&this._effectChain!==null){this._rebuildCount++;let a=Date.now();a-this._rebuildLogAt>1e3&&(this._rebuildLogAt=a,this._rebuildCount=0)}if(s&&(this._effectChain,this._effectChain?.dispose(),this._effectChain=null,this._effectChainDirty=!1,r&&(this._effectChain=i.createEffectChain(),Si.chainBuilds++,Si.lastChainBuildReason=n??"initial",this._chainUiTexture=this.uiOverlayEnabled?this.uiCanvasTexture:null,this._chainWatermark=this.watermarkTexture,this._chainTransitionTexture=this.sceneTransitionFromTexture,this._chainHdr=i.hdrChainActive)),this._effectChain){this._effectChain.syncValues(this.postprocessingState,i),this._chainTransitionTexture!==null&&this.sceneTransitionFromTexture===null&&(this.sceneTransitionPass.uniforms.mixRatio.value=1);let a=i.temporalAAEnabled?i.taaHistory:null;a&&(i.getDrawingBufferSize(bv),a.beginJitter(t,bv.x,bv.y)),this._effectChain.renderTAAResolve?.(i),this._effectChain.renderBloomPasses?.(i),this._effectChain.renderDoFPasses?.(i),this._effectChain.render(),a?.endJitter()}else i.renderScenePass(e,t);this._helpersEnabled&&(this.sceneHelpers||this.sceneHelpersOnTop)&&i.renderHelperOverlay(this.sceneHelpers,this.sceneHelpersOnTop,t,this._effectChain?this._effectChain.sceneDepthTexture():null)}resize(e,t,i){this._effectChain?.resize()}setViewport(e,t,i,r){e instanceof ut?this._renderer.setViewport(e.x,e.y,e.z,e.w):this._renderer.setViewport(e,t,i,r)}setScissor(e,t,i,r){e instanceof ut?this._renderer.setScissor(e.x,e.y,e.z,e.w):this._renderer.setScissor(e,t,i,r)}setScissorTest(e){this._renderer.setScissorTest(e)}dispose(){this._effectChain?.dispose(),this._effectChain=null,this._rt?.dispose(),this._rt=null,this.blueNoiseTexture.dispose()}}).UNIFORM_BACKED_FIELDS={bloom:["intensity","opacity"],chromaticAberration:["offset","opacity"],vignette:["offset","darkness","opacity"],noise:["opacity"],hueSaturation:["hue","saturation","opacity"],brightnessContrast:["brightness","contrast","opacity"],depthOfField:["focusDistance","focalLength","bokehScale","opacity"],pixelation:["granularity","opacity"]}});function Ume(e,t,i){Gx.push({t:Math.round(performance.now()),frame:L4(),kind:e,label:t||"(unlabeled)",size:i,stack:(new Error().stack??"").split(`
|
|
6258
6258
|
`).slice(2,9).join(`
|
|
6259
|
-
`)}),Gx.length>dMe&&Gx.shift()}var u$,dMe,Gx,d$,L4,c$,p$,GUe=F(()=>{u$=(()=>{try{return new URLSearchParams(window.location.search).get("dbgdestroys")==="1"}catch{return!1}})(),dMe=32,Gx=[],d$=6,L4=()=>-1,c$=!1,p$=null}),jUe=F(()=>{});function zme(e,t,i,r=sZ){if(t===void 0||!(i>0))return!1;let{image:n,width:s,height:a}=t;if(n==null||s===void 0||a===void 0||s<=i&&a<=i||!function(d){return!(d.isRenderTargetTexture||d.isDepthTexture||d.isFramebufferTexture||d.isStorageTexture||d.isExternalTexture||d.isHTMLTexture||d.isDataTexture||d.isCompressedTexture||d.isCompressedArrayTexture||d.isCubeTexture||d.isArrayTexture||d.isDataArrayTexture||d.isData3DTexture||d.is3DTexture||d.mipmaps!==void 0&&d.mipmaps.length>0)}(e))return!1;let o=i/Math.max(s,a),l=Math.max(1,Math.min(i,Math.floor(s*o))),h=Math.max(1,Math.min(i,Math.floor(a*o))),u=null;try{u=r(n,l,h)}catch{u=null}return u!==null&&(t.image=u,t.width=l,t.height=h,t.needsMipmaps===!0&&(t.levels=Math.floor(Math.log2(Math.max(l,h)))+1),!0)}var sZ,WUe=F(()=>{sZ=(e,t,i)=>{let r;if(typeof OffscreenCanvas<"u")r=new OffscreenCanvas(t,i);else{if(!(typeof document<"u"))return null;r=document.createElement("canvas"),r.width=t,r.height=i}let n=r.getContext("2d");return n?(n.imageSmoothingEnabled=!0,n.imageSmoothingQuality="high",n.drawImage(e,0,0,t,i),r):null}});function f$(e,t){let i=new Fi(e,t,{depthBuffer:!1,type:Gt,format:ws});return i.texture.generateMipmaps=!1,i.texture.minFilter=gt,i.texture.magFilter=gt,i}function m$(){return Ay===null&&((Ay=f$(Pf*B4,Pf)).texture.name="SplinePCSSPyramidAtlas"),Ay.texture}function kme(e,t,i,r,n,s){let a=new Jt,o=mt(t),l=He(()=>{let h=Zo,u=s!==0?fE(h.x).sub(s):fE(h.x),d=Pe(u).mul(i).toVar(),c=Pe(h.y).mul(i).toVar(),p=L(1e9).toVar(),f=L(-1e9).toVar();return Yr(v$("ly",i),v$("lx",i),m=>{let{lx:g,ly:v}=m,y=g$(y$(d.add(g),Pe(0),Pe(r))),_=g$(y$(c.add(v),Pe(0),Pe(r))),b=o.load(Va(y,_));p.assign(Li(p,fE(b.x))),f.assign(pt(f,fE(n?b.y:b.x)))}),Ae(p,f,0,1)})();return a.fragmentNode=l,a.name=e,a.lights=!1,a.blending=yi,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,a}function Vme(e){let t=e;if(!t.__spePcssPyramid){t.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null};for(let i of jx)i.deref()===void 0&&jx.delete(i);jx.add(new WeakRef(t.__spePcssPyramid))}return t.__spePcssPyramid}function Gme(e){return e.__spePcssPyramid?.fresh===!0}function HUe(e){return e.__spePcssPyramid?.slot??-1}var Pf,B4,Yb,fE,g$,v$,y$,Ay,jx,UO,zO,_$,cMe=F(()=>{ne(),mn(),gi(),ua(),Pf=8,B4=8,Yb=64,fE=e=>e,g$=e=>e,v$=(e,t)=>({start:Pe(0),end:Pe(t),type:"int",condition:"<",name:e}),y$=qt,Ay=null,jx=new Set,UO=new Array(B4).fill(null),zO=!1,_$=new P});function Wx(e){let t=e;return t.__spePcssKnobs||(t.__spePcssKnobs={mapSize:Be(2048),radius:Be(1),penumbraSize:Be(.5),depthEps:Be(1e-4),penumbraFrameScale:Be(1),penumbraFrameOffset:Be(0),pyramidEnabled:Be(0),pyramidSlot:Be(0),maskChannel:Be(new ut(0,0,0,0)),planeNormalMat:Be(new si().set(0,0,0,0,0,0,0,0,0))}),t.__spePcssKnobs}function pMe(e,t){Wx(e).maskChannel.value.set(t===0?1:0,t===1?1:0,t===2?1:0,t===3?1:0)}function jme(e,t,i){let r=e,n=Wx(e);n.mapSize.value=r.mapSize?.x??2048,n.radius.value=r.radius??1,n.penumbraSize.value=t??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?n.planeNormalMat.value.getNormalMatrix(r.matrix):n.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let s=typeof r.camera?.far=="number"&&typeof r.camera?.near=="number"?r.camera.far-r.camera.near:0;n.depthEps.value=s>.001?yMe/s:1e-4;let a=e.__speRangeEnvelope,o=a?a.far-a.near:0;a&&o>.001&&s>.001&&r.camera?(n.penumbraFrameScale.value=s/o,n.penumbraFrameOffset.value=(r.camera.near-a.near)/o):(n.penumbraFrameScale.value=1,n.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&F4()){let h=n.mapSize.value;aZ/1024+(2*n.radius.value+2)/Math.max(1,h)<=1/Pf&&(l=1)}return n.pyramidEnabled.value=_Me??l,n.pyramidSlot.value=Math.max(0,i?.slot??0),n.pyramidEnabled.value===1}function fMe(e,t){let i=Kb(e.planeNormalMat.mul(t)).toVar(),r=Ti(i.z),n=Ti(Vc(r).add(ar(oi(r),L(0))).mul(pt(oi(r),L(1e-4))));return Ln(Se(Ti(i.x).negate().div(n),Ti(i.y).div(n))).toVar()}function b$(e,t,i,r,n,s,a){let o=gMe(),l=vMe(),h=x$(),u=Wx(t),d=Ti(u.mapSize),c=Ln(Se(d,d)),p=Ti(u.radius),f=Ti(u.penumbraSize),m=mt(e),g=w=>Ti(m.load(Va(qt(w,Se(0),Se(1)).mul(c))).x),v=L(1).div(c.x).toVar(),y=L(aZ).div(v.mul(1024)).toVar(),_=Ti(u.depthEps),b=fMe(u,a),x=()=>{let w=L(0).toVar(),S=L(0).toVar();for(let E=0;E<l;E++){let A=Ln(t0(Pe(E),Pe(l),n)).mul(v).mul(y),C=g(Ln(i.add(A))).toVar();ze(C.lessThan(r.add(U4(b,A)).add(_)),()=>{w.addAssign(C),S.addAssign(1)})}let T=L(0).toVar();ze(S.greaterThan(0),()=>{let E=w.div(S).toVar(),A=Ti(u.penumbraFrameScale),C=Ti(u.penumbraFrameOffset),D=r.sub(E).mul(A).div(E.mul(A).add(C)).toVar();T.assign(qt(D.mul(D).mul(200).mul(f),L(0),L(1)))});let M=L(0).toVar();for(let E=0;E<o;E++){let A=Ln(t0(Pe(E),Pe(o),n)).mul(v),C=Ln(A.mul(p.mul(2)).add(A.mul(T.mul(y)))),D=Ti(r.add(U4(b,C)));h?M.addAssign(Ti(mt(e,Ln(i.add(C))).compare(D))):M.addAssign(ar(D,g(Ln(i.add(C)))))}s.assign(M.div(o))};if(F4()){let w=mt(m$()),S=Ti(u.pyramidEnabled),T=Ti(u.pyramidSlot),M=L(Pf),E=L(0).toVar();ze(S.greaterThan(.5),()=>{let A=Ln(qt(i,Se(0),Se(1))),C=Ti(A.x.mul(M)).toVar(),D=Ti(A.y.mul(M)).toVar(),R=T.mul(M),I=L(1e9).toVar(),U=L(-1e9).toVar();for(let G=-1;G<=1;G++)for(let K=-1;K<=1;K++){let q=qt(C.add(L(K)),L(0),M.sub(1)),Y=qt(D.add(L(G)),L(0),M.sub(1)),ue=Ln(Se(q.add(R),Y)),de=w.load(Va(ue));I.assign(Li(I,Ti(de.x))),U.assign(pt(U,Ti(de.y)))}let O=Ti(v.mul(p.mul(2).add(y))),k=Ti(Li($i(b).mul(O),L(.05))).toVar();ze(I.greaterThanEqual(r.add(_).add(k)),()=>{E.assign(1)}).ElseIf(U.lessThan(r.sub(k)),()=>{E.assign(2)})}),ze(E.equal(1),()=>{s.assign(1)}).ElseIf(E.equal(2),()=>{s.assign(0)}).Else(x)}else x()}function qUe(e,t){let i=t;return i.isPointLight?(Si.pcssHookServes++,k4):i.isSpotLight||i.isDirectionalLight?(Si.pcssHookServes++,z4):null}function Wme(e){oZ.value=e?1:0}function Hme(e,t){return i=>{let r=function(a){let o=a,l={};if(o==null)return l;for(let h of bMe){let u=o[h];u!==void 0&&(l[h]=u)}return l}(i),n=Ti(T$(e,r)),s=Ti(T$(t,r));return He(()=>{let a=L(1).toVar();return ze(Ti(oZ).greaterThan(.5),()=>{a.assign(n)}).Else(()=>{a.assign(s)}),a})()}}var Ti,Ln,Kb,aN,oN,lN,hN,mE,x$,F4,Rj,w$,S$,mMe,aZ,af,gMe,vMe,yMe,_Me,U4,qme,$me,Xme,oZ,T$,bMe,z4,k4,uN,Yme,Kme,xMe,wMe,SMe,TMe,MMe=F(()=>{gi(),ne(),ua(),cMe(),Ti=e=>e,Ln=e=>e,Kb=e=>e,aN=!0,oN=!0,lN=!0,hN=!0;try{let e=new URLSearchParams(window.location.search),t=e.get("dbgpcss");t==="classic"||t==="0"?(aN=!1,oN=!1,lN=!1,hN=!1):(aN=e.get("dbgpcsssplit")!=="0",oN=e.get("dbgpcsshw")!=="0",lN=e.get("dbgpcsshiz")!=="0",hN=e.get("dbgshadowmask")!=="0")}catch{}mE=!1,x$=()=>oN&&mE,F4=()=>lN&&mE,Rj=()=>hN&&mE,w$=()=>F4(),S$=()=>Rj(),mMe=[[0,-.333334],[-.5,.333334],[.5,-.777778],[-.75,-.111112],[.25,.555556],[-.25,-.555556],[.75,.111112],[-.875,.777778],[.125,-.925926],[-.375,-.25926],[.625,.407408],[-.625,-.703704],[.375,-.037038],[-.125,.62963],[.875,-.481482],[-.9375,.185186]],aZ=80,af=16,gMe=()=>x$()?Math.max(4,af>>1):af,vMe=()=>aN?Math.max(4,af>>1):af,yMe=1.25,_Me=null,U4=(e,t)=>Ti(qt(Je(e,t),L(-.05),L(.05))),qme=He(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,n=Wx(r),s=Ln(i.xy).toVar(),a=Ti(i.z).toVar(),o=Kb(KA).toVar(),l=Ln(tt.pcssHalton),h=Ti($f(Zo.xy.add(l))).mul(6.28318530718).toVar(),u=L(1).toVar();if(Rj()){let d=n.maskChannel,c=Ti(tt.shadowMaskEnabled),p=tt.shadowMaskGBuffer,f=tt.shadowMaskTexture,m=L(0).toVar(),g=L(1).toVar();ze(c.greaterThan(.5).and(Ti(Je(d,Ae(1,1,1,1))).greaterThan(.5)),()=>{let v=Ln(gu),y=Ln(tt.shadowMaskResolution),_=Ln(tt.shadowMaskFullResolution),b=Ti(Zf.z),x=Ln(v.mul(y).sub(Se(.5,.5))).toVar(),w=Ln(At(x)).toVar(),S=Ln(x.sub(w)).toVar(),T=Ti(pt(oi(b).mul(.02),L(.05))),M=L(0).toVar(),E=L(0).toVar();for(let A=0;A<=1;A++)for(let C=0;C<=1;C++){let D=Ln(qt(w.add(Se(C,A)),Se(0,0),y.sub(Se(1,1)))),R=Ln(D.add(Se(.5,.5)).div(y)),I=Ln(At(R.mul(_)).add(Se(.5,.5)).div(_)),U=Ti(p.sample(I).w),O=Ti(Je(f.sample(R),d)),k=Ti(C===0?L(1).sub(S.x):Ti(S.x)),G=Ti(A===0?L(1).sub(S.y):Ti(S.y)),K=Ti(ar(oi(U.sub(b)),T)),q=Ti(k.mul(G).mul(K)).toVar();M.addAssign(q),E.addAssign(O.mul(q))}ze(M.greaterThan(.001),()=>{m.assign(1),g.assign(E.div(M))})}),ze(m.greaterThan(.5),()=>{u.assign(g)}).Else(()=>{b$(t,r,s,a,h,u,o)})}else b$(t,r,s,a,h,u,o);return u}),$me=He(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,n=Wx(r),s=Ln(i.xy).toVar(),a=Ti(i.z).toVar(),o=fMe(n,Kb(KA).toVar()),l=Ti(n.mapSize),h=Ti(n.radius),u=Ti(h.mul(L(1).div(l))).toVar(),d=Ti($f(Zo.xy)).mul(6.28318530718).toVar(),c=L(0).toVar();for(let p=0;p<5;p++){let f=Ln(t0(Pe(p),Pe(5),d)).mul(u).toVar();c.addAssign(Ti(mt(t,Ln(s.add(f))).compare(a.add(U4(o,f)))))}return c.mul(.2)}),Xme=He(e=>{let{depthTexture:t,bd3D:i,dp:r,shadow:n}=e,s=af,a=Wx(n),o=Ti(a.mapSize),l=Ti(a.radius),h=L(1).div(o).toVar(),u=Ln(tt.pcssHalton),d=Ti($f(Zo.xy.add(u))).mul(6.28318530718).toVar(),c=Ti(l.add(5)).toVar(),p=L(0).toVar();for(let f=0;f<s;f++){let m=Ln(t0(Pe(f),Pe(s),d)).mul(h).toVar(),g=Kb(Q(m.x,m.y,Ti(m.x).negate()).mul(c)),v=Kb(i.add(g));p.addAssign(Ti(o2e(t,v).compare(r)))}return p.div(s)}),oZ=Be(1),T$=(e,t)=>e(t),bMe=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],z4=Hme(qme,$me),k4=Hme(Xme,ZTe)}),$Ue=F(()=>{ne(),mn(),gi(),ua(),MMe(),uN=new Cn,Yme=new at,Kme=new Z,xMe=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=Be(new De),this._projInv=Be(new De),this._lightRows=[];let e=new Jt;e.name="SplineShadowMask.gbuffer",e.fragmentNode=Ae(To,Zf.z),e.lights=!1,e.blending=yi,e.needsUpdate=!0,this._gBufferMaterial=e}_ensureTarget(e,t,i,r){return e&&e.width===t&&e.height===i?{target:e,changed:!1}:(e?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(e){let t=new Jt;t.name="SplineShadowMask.resolve";let i=mt(this._gBuffer.depthTexture),r=mt(this._gBuffer.texture),n=this._cameraWorld,s=this._projInv,a=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=e.map(()=>({matrix:Be(new De),bias:Be(0),normalBias:Be(0)}));let l=this._lightRows,h=He(()=>{let u=Hi(),d=At(u.mul(Se(a,o))).add(Se(.5,.5)).div(Se(a,o)).toVar(),c=i.sample(d),p=HK(d,c,s).toVar(),f=r.sample(d).toVar(),m=n,g=m.mul(Ae(p,1)).xyz.toVar(),v=Ft(m.mul(Ae(f.xyz,0)).xyz).toVar(),y=tt.pcssHalton,_=$f(Zo.xy.add(y)).mul(6.28318530718).toVar(),b=[L(1).toVar(),L(1).toVar(),L(1).toVar(),L(1).toVar()];return e.forEach((x,w)=>{let S=l[w],T=g.add(v.mul(S.normalBias)),M=S.matrix.mul(Ae(T,1)).toVar(),E=M.xyz.div(M.w),A=Q(E.x,L(1).sub(E.y),E.z).toVar(),C=A.z.add(S.bias).toVar(),D=A.x.greaterThanEqual(0).and(A.x.lessThanEqual(1)).and(A.y.greaterThanEqual(0)).and(A.y.lessThanEqual(1)).and(C.lessThanEqual(1));ze(D,()=>{b$(x.shadow.map.depthTexture,x.shadow,A.xy,C,_,b[w],v)})}),Ae(b[0],b[1],b[2],b[3])})();return t.fragmentNode=h,t.lights=!1,t.blending=yi,t.depthTest=!1,t.depthWrite=!1,t.needsUpdate=!0,t}render(e,t,i,r,n){let s=n??e.getDrawingBufferSize(Kme),a=Math.max(1,Math.round(s.x)),o=Math.max(1,Math.round(s.y)),l=Math.max(1,Math.round(a/2)),h=Math.max(1,Math.round(o/2)),u=!1,d=this._ensureTarget(this._gBuffer,a,o,()=>{let M=new Fi(a,o,{type:li,depthTexture:new ns(a,o),minFilter:it,magFilter:it});return M.texture.name="SplineShadowMask.gbuffer",M});this._gBuffer=d.target,u=u||d.changed;let c=this._ensureTarget(this._maskTarget,l,h,()=>{let M=new Fi(l,h,{depthBuffer:!1,minFilter:it,magFilter:it});return M.texture.name="SplineShadowMask.mask",M});this._maskTarget=c.target,u=u||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(M=>M.shadow.map?.depthTexture?.uuid??"none").join(",")}`;(this._resolveMaterial===null||this._resolveKey!==p)&&(this._resolveMaterial?.dispose(),this._resolveMaterial=this._buildResolveMaterial(r),this._resolveKey=p),this._cameraWorld.value.copy(i.matrixWorld),this._projInv.value.copy(i.projectionMatrix).invert(),r.forEach((M,E)=>{M.shadow.updateMatrices?.(M.light);let A=this._lightRows[E];M.shadow.matrix&&A.matrix.value.copy(M.shadow.matrix),A.bias.value=M.shadow.bias??0,A.normalBias.value=M.shadow.normalBias??0});let f=t,m=f.isScene===!0,g=[],v=[];f.traverse(M=>{let E=M;if(E.isMesh===!0&&E.visible!==!1){if((Array.isArray(E.material)?E.material:[E.material]).some(A=>A?.transparent===!0))g.push(E),E.visible=!1;else if(!m){let A=E;v.push({obj:A,material:A.material}),A.material=this._gBufferMaterial}}});let y=f.overrideMaterial,_=e.getRenderTarget(),b=e.getMRT(),x=e.getClearColor(Yme),w=e.getClearAlpha(),S=i.layers,T=S.mask;S.disable(3),f.overrideMaterial=this._gBufferMaterial,e.setMRT(null),e.setClearColor(0,0),e.setRenderTarget(this._gBuffer),e.render(t,i),f.overrideMaterial=y,S.mask=T;for(let M of g)M.visible=!0;for(let M of v)M.obj.material=M.material;return uN.material=this._resolveMaterial,uN.name="SplineShadowMask.resolve",e.setRenderTarget(this._maskTarget),uN.render(e),e.setRenderTarget(_),e.setMRT(b),e.setClearColor(x,w),tt.shadowMaskTexture.value=this._maskTarget.texture,tt.shadowMaskGBuffer.value=this._gBuffer.texture,tt.shadowMaskResolution.value.set(l,h),tt.shadowMaskFullResolution.value.set(a,o),r.forEach((M,E)=>{pMe(M.shadow,E)}),Si.shadowMaskResolves++,{targetsChanged:u}}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._maskTarget?.dispose(),this._maskTarget=null,this._gBufferMaterial.dispose(),this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._resolveKey=""}}}),XUe=F(()=>{ne(),wMe=1,SMe={src:Kg,dst:Eg,srcAlpha:Eg,dstAlpha:Eg},TMe={src:bA,dst:xA,srcAlpha:Eg,dstAlpha:Kg}});function Zme(e){let t=e;return t.isSkinnedMesh===!0&&t.bindMatrixInverse?t.bindMatrixInverse:null}function Qme(e){let t=new YA(Mg);return t.blendSrc=e.src,t.blendDst=e.dst,t.blendSrcAlpha=e.srcAlpha,t.blendDstAlpha=e.dstAlpha,t}var dN,Jme,V4,EMe,ege,tge,ige,AMe,CMe=F(()=>{ne(),gi(),mn(),XUe(),dN=new WeakMap,Jme=new De,V4=M2e(class extends $Te{update(e){super.update(e);let{frameId:t,object:i}=e,r=Zme(i),n=dN.get(i);n===void 0?(n={frameId:t,prev:i.matrixWorld.clone(),last:i.matrixWorld.clone(),prevBind:r?.clone()??null,lastBind:r?.clone()??null},dN.set(i,n)):n.frameId!==t&&(n.frameId=t,n.prev.copy(n.last),n.prevBind&&n.lastBind&&n.prevBind.copy(n.lastBind));let s=this.previousModelWorldMatrix.value.copy(n.prev);r!==null&&(n.prevBind===null&&(n.prevBind=r.clone(),n.lastBind=r.clone()),s.multiply(n.prevBind).multiply(Jme.copy(r).invert()))}updateAfter(e){let{object:t}=e,i=dN.get(t);if(i===void 0)return;i.last.copy(t.matrixWorld);let r=Zme(t);r!==null&&i.lastBind?.copy(r)}}),EMe=Ae(V4,0,wMe),ege=Qme(SMe),tge=new YA(yi),ige=Qme(TMe),AMe=new class extends YA{resolveForMaterial(e){return e.depthWrite?ege:function(t){return!t.depthWrite&&t.blending!==yi&&(t.blending!==Xs||t.transparent)}(e)?ige:tge}}(yi)});function G4(e,t){let i=0,r=1,n=e;for(;n>0;)r/=t,i+=r*(n%t),n=Math.floor(n/t);return i}function Dj(e){return Q(e.x.div(4).add(e.y.div(2)).add(e.z.div(4)),e.x.div(2).sub(e.z.div(2)),e.x.div(-4).add(e.y.div(2)).sub(e.z.div(4)))}function rge(e,t=!0){let i=Q(e.x.add(e.y).sub(e.z),e.x.add(e.z),e.x.sub(e.y).sub(e.z));return t?qt(i,Q(0),Q(1)):pt(i,Q(0))}function PMe(){let e=!1;try{let c=new URLSearchParams(window.location.search).get("dbgfp16");e=c==="1"||c==="hist"||c==="st"}catch{}let t=!1,i=()=>e||t,r=(c,p,f)=>{let m=new Fi(c,p,{minFilter:it,magFilter:it,depthBuffer:!1});return i()?m.texture.type=li:aF()&&(m.texture.internalFormat="rgba8unorm-srgb"),m.texture.name=f,m},n=r(1,1,"SplineTAA.A"),s=r(1,1,"SplineTAA.B"),a=null,o=!1,l=0,h=0,u=0,d=0;return{rtA:n,rtB:s,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new De,jitterOffsetUV:new Z(0,0),beginJitter(c,p,f){if(o)return;let m,g;if(o=!0,(a===null||a.cam!==c)&&(a?.clearViewOffset(),a=new RMe(c)),this.unjitteredProjection.copy(c.projectionMatrix),tt.unjitteredProjection.value.copy(c.projectionMatrix),fx==="r2"){let v=++this.jitterIndex;m=(.5+DMe*v)%1,g=(.5+NMe*v)%1}else if(fx==="white")this.jitterIndex++,m=Math.random(),g=Math.random();else if(fx==="h64")m=G4(this.jitterIndex%64+1,2),g=G4(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if(fx==="half"){let[v,y]=gE[this.jitterIndex];m=.5+.5*(v-.5),g=.5+.5*(y-.5),this.jitterIndex=(this.jitterIndex+1)%gE.length}else[m,g]=gE[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%gE.length;l=p,h=f,u=m-.5,d=g-.5,tt.cameraJitterPx.value.set(2*u,2*d),a.setViewOffset(p,f,u,d),this.jitterOffsetUV.set(-(m-.5)/p,-(g-.5)/f),Si.taaJitterIndex=this.jitterIndex,Si.taaJitterApplies++},suspendJitter(){o&&a?.clearViewOffset()},resumeJitter(){o&&a!==null&&a.setViewOffset(l,h,u,d)},endJitter(){o=!1,this.jitterOffsetUV.set(0,0),a?.clearViewOffset()},resize(c,p){this.rtA.dispose(),this.rtB.dispose(),this.rtA=r(c,p,"SplineTAA.A"),this.rtB=r(c,p,"SplineTAA.B"),this.valid=!1},setHdr(c){if(t===c)return;let p=i();t=c,i()!==p&&this.resize(this.rtA.width,this.rtA.height)},dispose(){this.rtA.dispose(),this.rtB.dispose(),this.valid=!1,o=!1,a?.clearViewOffset(),a=null}}}var nge,sge,cN,RMe,gE,fx,DMe,NMe,IMe,OMe,xv,age,Nj,oge,LMe,pN,Ij,BMe,FMe=F(()=>{ne(),CMe(),ua(),mn(),gi(),nge=e=>e,sge=e=>e,cN=new Cn,RMe=class{constructor(e){this.cam=e,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(e,t,i,r){this.clearViewOffset();let n=this.cam.projectionMatrix.elements,s=-2*i/e,a=2*r/t;this._savedSkewX=n[8],this._savedSkewY=n[9],this._savedShiftX=n[12],this._savedShiftY=n[13],n[8]+=s*n[11],n[9]+=a*n[11],n[12]+=s*n[15],n[13]+=a*n[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let e=this.cam.projectionMatrix.elements;e[8]=this._savedSkewX,e[9]=this._savedSkewY,e[12]=this._savedShiftX,e[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},gE=Array.from({length:16},(e,t)=>[G4(t+1,2),G4(t+1,3)]),fx="h16";try{let e=new URLSearchParams(window.location.search).get("dbgjitseq");(e==="r2"||e==="h64"||e==="white"||e==="half")&&(fx=e)}catch{}DMe=.7548776662466927,NMe=.5698402909980532,IMe=class extends En{constructor(e,t,i,r,n=!1){super("vec4"),this._resolution=Be(new Z(1,1)),this._historyValid=Be(0),this._jitterUV=Be(new Z(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=e,this.depthNode=t,this.velocityNode=i,this._hdr=n,this._history=r??PMe(),this._ownsHistory=r===void 0,this._outputTexNode=mt(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(e){V4.setProjectionMatrix(this._history.unjitteredProjection);let t=this.beautyNode.passNode.renderTarget,i=t.texture.width,r=t.texture.height,n=this._history;(n.rtA.width!==i||n.rtA.height!==r)&&(n.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=n.valid?1:0,this._jitterUV.value.copy(n.jitterOffsetUV);let s=n.flip?n.rtB:n.rtA,a=this._resolveMaterials?this._resolveMaterials[n.flip?1:0]:null,o=e.getRenderTarget(),l=e.getMRT();e.setMRT(null),n.valid||(e.setRenderTarget(n.rtA),e.clear(!0,!1,!1),e.setRenderTarget(n.rtB),e.clear(!0,!1,!1)),e.setRenderTarget(s),a&&(cN.material=a,cN.name="SplineTAA.resolve",cN.render(e)),e.setRenderTarget(o),e.setMRT(l),this._outputTexNode.value=s.texture,n.valid=!0,n.flip=!n.flip,Si.taaResolves++,Si.taaJitterIndex=n.jitterIndex,Si.taaHistoryValid=!0,Si.taaResolveSize=`${i}x${r}`}setup(e){let t=e.renderer.reversedDepthBuffer===!0,i=e.renderer.backend?.isWebGLBackend===!0,r=!1,n=!1,s=!1,a=!1,o=!1,l=!1,h=!1,u=!1,d=!1,c=!1;try{let x=new URLSearchParams(window.location.search).get("dbgtaa");r=x==="1",n=x==="zv",s=x==="nc",a=x==="err",o=x==="hist",l=x==="red",h=x==="ns",u=x==="fb90",d=new URLSearchParams(window.location.search).get("dbgjit")==="mark",c=x==="hold"}catch{}let p=this.beautyNode,f=this.velocityNode,m=this.depthNode,g=this._resolution,v=this._historyValid,y=this._jitterUV,_=x=>{let w=p.sample(x);return Ae(Dj(w.rgb),w.a)},b=x=>{let w=He(()=>{let T=Hi().toVar();if(d)return Ae(y.x.mul(400).add(.5),y.y.mul(400).add(.5),L(.5),L(1));let M=T,E=Se(L(1).div(g.x),L(1).div(g.y)).toVar(),A=[[-1,1],[0,1],[1,1],[-1,0],[0,0],[1,0],[-1,-1],[0,-1],[1,-1]].map(([xt,Dt])=>T.add(Se(E.x.mul(xt),E.y.mul(Dt))).toVar()),C=A,D=L(t?-1e3:1e3).toVar(),R=Se(A[4]).toVar();for(let xt=0;xt<9;xt++){let Dt=nge(m.load(Va(A[xt].mul(sge(g)))).r).toVar(),Kt=t?Dt.greaterThan(D):Dt.lessThan(D);D.assign(Kt.select(Dt,D)),R.assign(Kt.select(A[xt],R))}let I=f.load(Va(R.mul(g))).xy.mul(Se(.5,-.5)).toVar();n&&I.assign(Se(0,0));let U=T.sub(I).toVar(),O=i?Se(U.x,L(1).sub(U.y)).toVar():U,k=_(M).toVar();if(r)return Ae(I.x.mul(20).add(.5),I.y.mul(20).add(.5),v,L(1));if(l){let xt=new Nr(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return xt.needsUpdate=!0,mt(xt).sample(T)}if(o){let xt=i?Se(T.x,L(1).sub(T.y)):T;return x.sample(xt)}if(a){let xt=i?Se(T.x,L(1).sub(T.y)):T,Dt=x.sample(O),Kt=x.sample(xt),Mi=k.x,_i=ci=>Dj(ci.rgb).x;return Ae(_i(Dt).sub(Mi).abs().mul(8),_i(Kt).sub(Mi).abs().mul(8),L(0),L(1))}let G=O.mul(g).toVar(),K=At(G.sub(.5)).add(.5).toVar(),q=G.sub(K).toVar(),Y=q.mul(q.mul(q.mul(-.5).add(1)).add(-.5)).toVar(),ue=q.mul(q).mul(q.mul(1.5).add(-2.5)).add(1).toVar(),de=q.mul(q.mul(q.mul(-1.5).add(2)).add(.5)).toVar(),ge=q.mul(q).mul(q.mul(.5).add(-.5)).toVar(),be=ue.add(de).toVar(),re=de.div(be).toVar(),xe=K.sub(1).div(g).toVar(),j=K.add(2).div(g).toVar(),z=K.add(re).div(g).toVar(),X=Ae(0).toVar();X.addAssign(x.sample(Se(z.x,xe.y)).mul(be.x.mul(Y.y))),X.addAssign(x.sample(Se(xe.x,z.y)).mul(Y.x.mul(be.y))),X.addAssign(x.sample(Se(z.x,z.y)).mul(be.x.mul(be.y))),X.addAssign(x.sample(Se(j.x,z.y)).mul(ge.x.mul(be.y))),X.addAssign(x.sample(Se(z.x,j.y)).mul(be.x.mul(ge.y)));let te=Ae(Dj(X.rgb),X.a).toVar();if(c)return Ae(rge(te.rgb).mul(Q(1,.55,.55)),X.a);let V=_(C[0]).toVar(),ae=_(C[1]).toVar(),se=_(C[2]).toVar(),W=_(C[3]).toVar(),pe=_(C[4]).toVar(),_e=_(C[5]).toVar(),Ue=_(C[6]).toVar(),we=_(C[7]).toVar(),Ye=_(C[8]).toVar(),Fe=Ae(Li(V,Li(ae,Li(se,Li(W,Li(pe,Li(_e,Li(Ue,Li(we,Ye))))))))).toVar(),We=Ae(pt(V,pt(ae,pt(se,pt(W,pt(pe,pt(_e,pt(Ue,pt(we,Ye))))))))).toVar(),Re=Ae(Li(ae,Li(W,Li(pe,Li(_e,we))))).toVar(),ee=Ae(pt(ae,pt(W,pt(pe,pt(_e,we))))).toVar();Fe.assign(Fe.add(Re).mul(.5)),We.assign(We.add(ee).mul(.5));let Ee=We.r.sub(Fe.r).mul(.25).mul(.5).toVar(),je=k.gb.toVar();h||(Fe.y.assign(je.x.sub(Ee)),Fe.z.assign(je.y.sub(Ee)),We.y.assign(je.x.add(Ee)),We.z.assign(je.y.add(Ee)));let dt=Ae(s?te:qt(te,Fe,We)).toVar(),et=u||s?L(.9):L(.9).mul(v),$t=Ae(lt(k,dt,et)).toVar(),ii=tt.tapAngle,nr=KK(T.mul(g).add(Se(ii.mul(127.1),ii.mul(311.7)))).sub(.5).mul(1/255);return Ae(rge($t.rgb,!this._hdr).add(Q(nr)),$t.a)}),S=new Jt;return S.name="SplineTAA.resolve",S.colorNode=w(),S.depthTest=!1,S.depthWrite=!1,S.blending=yi,S.needsUpdate=!0,S};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[b(mt(this._history.rtB.texture)),b(mt(this._history.rtA.texture))]},this._rebuildResolveMaterials(),this._outputTexNode}dispose(){this._ownsHistory&&this._history.dispose(),this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose(),this._resolveMaterials=null),V4.setProjectionMatrix(null)}}}),YUe=F(()=>{OMe=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(e,t){this._frames=e>0&&!t?this._frames+1:0}}}),KUe=F(()=>{}),ZUe=F(()=>{KB(),mn(),gi(),xv=new Cn,age=new Z,oge=class extends En{static get type(){return"SMAANode"}constructor(e){super("vec4"),this.textureNode=e,this.updateBeforeType=KTe.FRAME,this._renderTargetEdges=new Fi(1,1,{depthBuffer:!1,type:li}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new Fi(1,1,{depthBuffer:!1,type:li}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new Fi(1,1,{depthBuffer:!1,type:li}),this._renderTargetBlend.texture.name="SMAANode.blend";let t=this,i=new Image;i.crossOrigin="anonymous",E4(i,"smaa-node-area.png"),i.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Ci,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=it,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",E4(r,"smaa-node-search.png"),r.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Ci,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=gt,this._searchTexture.minFilter=gt,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=Be(new Z),this._areaTextureUniform=mt(this._areaTexture),this._searchTextureUniform=mt(this._searchTexture),this._edgesTextureUniform=mt(this._renderTargetEdges.texture),this._weightsTextureUniform=mt(this._renderTargetWeights.texture),this._materialEdges=new Jt,this._materialEdges.name="SMAANode.edges",this._materialWeights=new Jt,this._materialWeights.name="SMAANode.weights",this._materialBlend=new Jt,this._materialBlend.name="SMAANode.blend",this._textureNode=N2e(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),this._renderTargetEdges.setSize(e,t),this._renderTargetWeights.setSize(e,t),this._renderTargetBlend.setSize(e,t)}updateBefore(e){let{renderer:t}=e;Nj=kq.resetRendererState(t,Nj);let i=t.getDrawingBufferSize(age);this.setSize(i.width,i.height),t.setRenderTarget(this._renderTargetEdges),xv.material=this._materialEdges,xv.render(t),t.setRenderTarget(this._renderTargetWeights),xv.material=this._materialWeights,xv.render(t),t.setRenderTarget(this._renderTargetBlend),xv.material=this._materialBlend,xv.render(t),kq.restoreRendererState(t,Nj)}setup(e){let t=Se(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||Hi(),n=He(()=>{let g=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-1,0,0,-1))),v=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(1,0,0,1))),y=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-2,0,0,-2)));return Bn("vec4","vOffset0").assign(g),Bn("vec4","vOffset1").assign(v),Bn("vec4","vOffset2").assign(y),OO}),s=He(()=>{let g=Bn("vec4","vOffset0"),v=Bn("vec4","vOffset1"),y=Bn("vec4","vOffset2"),_=Se(.1,.1),b=Ae().toVar(),x=this.textureNode.sample(r).rgb.toVar(),w=this.textureNode.sample(g.xy).rgb.toVar(),S=oi(x.sub(w));b.x=pt(S.r,S.g,S.b);let T=this.textureNode.sample(g.zw).rgb.toVar();S=oi(x.sub(T)),b.y=pt(S.r,S.g,S.b);let M=ar(_,b.xy).toVar();Je(M,Se(1,1)).equal(0).discard();let E=this.textureNode.sample(v.xy).rgb.toVar();S=oi(x.sub(E)),b.z=pt(S.r,S.g,S.b);let A=this.textureNode.sample(v.zw).rgb.toVar();S=oi(x.sub(A)),b.w=pt(S.r,S.g,S.b);let C=pt(b.x,b.y,b.z,b.w).toVar(),D=this.textureNode.sample(y.xy).rgb.toVar();S=oi(x.sub(D)),b.z=pt(S.r,S.g,S.b);let R=this.textureNode.sample(y.zw).rgb.toVar();return S=oi(x.sub(R)),b.w=pt(S.r,S.g,S.b),C=pt(C,b.z,b.w),M.xy.mulAssign(Se(ar(L(.5).mul(C),b.xy))),Ae(M,0,0)}),a=He(([g,v,y,_])=>{let b=Se(v).toVar();return b.r=y.add(b.r.mul(_)),L(255).mul(g.sample(b)).r}),o=He(([g,v,y,_,b])=>{let x=L(16).mul(L(4).mul(Se(y,_)).round()).add(v);return x=t.mul(x).add(L(.5).mul(t)),x.y.addAssign(L(i).mul(b)),g.sample(x).rg}),l=He(([g,v,y,_])=>{let b=Se(0,1).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.subAssign(Se(2,0).mul(this._invSize)),ze(x.x.lessThanEqual(_).or(b.g.lessThanEqual(L(.8281)).or(b.r.notEqual(L(0)))),()=>{qa()})}),x.x.addAssign(L(.25).mul(this._invSize.x)),x.x.addAssign(this._invSize.x),x.x.addAssign(L(2).mul(this._invSize.x)),x.x.subAssign(this._invSize.x.mul(a(v,b,0,.5))),x.x}),h=He(([g,v,y,_])=>{let b=Se(0,1).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.addAssign(Se(2,0).mul(this._invSize)),ze(x.x.greaterThanEqual(_).or(b.g.lessThanEqual(L(.8281)).or(b.r.notEqual(L(0)))),()=>{qa()})}),x.x.subAssign(L(.25).mul(this._invSize.x)),x.x.subAssign(this._invSize.x),x.x.subAssign(L(2).mul(this._invSize.x)),x.x.addAssign(this._invSize.x.mul(a(v,b,.5,.5))),x.x}),u=He(([g,v,y,_])=>{let b=Se(1,0).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.addAssign(Se(0,-2).mul(this._invSize)),ze(x.y.lessThanEqual(_).or(b.r.lessThanEqual(L(.8281)).or(b.g.notEqual(L(0)))),()=>{qa()})}),x.y.addAssign(L(.25).mul(this._invSize.y)),x.y.addAssign(this._invSize.y),x.y.addAssign(L(2).mul(this._invSize.y)),x.y.subAssign(this._invSize.y.mul(a(v,b.gr,0,.5))),x.y}),d=He(([g,v,y,_])=>{let b=Se(1,0).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.subAssign(Se(0,-2).mul(this._invSize)),ze(x.y.greaterThanEqual(_).or(b.r.lessThanEqual(L(.8281)).or(b.g.notEqual(L(0)))),()=>{qa()})}),x.y.subAssign(L(.25).mul(this._invSize.y)),x.y.subAssign(this._invSize.y),x.y.subAssign(L(2).mul(this._invSize.y)),x.y.addAssign(this._invSize.y.mul(a(v,b.gr,.5,.5))),x.y}),c=He(()=>{let g=r.xy.div(this._invSize),v=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-.25,-.125,1.25,-.125))).toVar(),y=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-.125,-.25,-.125,1.25))).toVar(),_=Ae(v.xz,y.yw).add(Ae(-2,2,-2,2).mul(Ae(this._invSize.xx,this._invSize.yy)).mul(L(8))).toVar();return Bn("vec2","vPixcoord").assign(g),Bn("vec4","vOffset0").assign(v),Bn("vec4","vOffset1").assign(y),Bn("vec4","vOffset2").assign(_),OO}),p=He(()=>{let g=Bn("vec2","vPixcoord"),v=Bn("vec4","vOffset0"),y=Bn("vec4","vOffset1"),_=Bn("vec4","vOffset2"),b=Ae(0,0,0,0).toVar(),x=Ae(0,0,0,0).toVar(),w=this._edgesTextureUniform.sample(r).rg.toVar();return ze(w.g.greaterThan(L(0)),()=>{let S=Se().toVar(),T=Se().toVar();T.x=l(this._edgesTextureUniform,this._searchTextureUniform,v.xy,_.x),T.y=y.y,S.x=T.x;let M=this._edgesTextureUniform.sample(T).r.toVar(),E=Se().toVar();E.x=h(this._edgesTextureUniform,this._searchTextureUniform,v.zw,_.y),E.y=y.y,S.y=E.x,S=S.div(this._invSize.x).sub(g.x);let A=Rh(oi(S)),C=this._edgesTextureUniform.sample(E.add(Se(1,0).mul(this._invSize))).r.toVar();b.r=C,b.rg=o(this._areaTextureUniform,A,M,C,L(x.y))}),ze(w.r.greaterThan(L(0)),()=>{let S=Se().toVar(),T=Se().toVar();T.y=u(this._edgesTextureUniform,this._searchTextureUniform,y.xy,_.z),T.x=v.x,S.x=T.y;let M=this._edgesTextureUniform.sample(T).g.toVar(),E=Se().toVar();E.y=d(this._edgesTextureUniform,this._searchTextureUniform,y.zw,_.w),E.x=v.x,S.y=E.y,S=S.div(this._invSize.y).sub(g.y);let A=Rh(oi(S)),C=this._edgesTextureUniform.sample(E.add(Se(0,1).mul(this._invSize))).g.toVar();b.ba=o(this._areaTextureUniform,A,M,C,L(x.x))}),b}),f=He(()=>{let g=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(1,0,0,1)));return Bn("vec4","vOffset1").assign(g),OO}),m=He(()=>{let g=Bn("vec4","vOffset1"),v=Ae().toVar(),y=Ae().toVar();return y.xz=this._weightsTextureUniform.sample(r).xz,y.y=this._weightsTextureUniform.sample(g.zw).g,y.w=this._weightsTextureUniform.sample(g.xy).a,ze(Je(y,Ae(1)).lessThan(1e-5),()=>{v.assign(this.textureNode.sample(r))}).Else(()=>{let _=Se().toVar();_.x=y.a.greaterThan(y.b).select(y.a,y.b.negate()),_.y=y.g.greaterThan(y.r).select(y.g,y.r.negate()),ze(oi(_.x).greaterThan(oi(_.y)),()=>{_.y.assign(0)}).Else(()=>{_.x.assign(0)});let b=this.textureNode.sample(r).toVar(),x=Se(r).toVar();x.addAssign(Vc(_).mul(this._invSize));let w=this.textureNode.sample(x).toVar(),S=oi(_.x).greaterThan(oi(_.y)).select(oi(_.x),oi(_.y)).toVar(),T=lt(b,w,S);v.assign(T)}),v});return this._materialEdges.vertexNode=n().context(e.getSharedContext()),this._materialEdges.fragmentNode=s().context(e.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(e.getSharedContext()),this._materialWeights.fragmentNode=p().context(e.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=f().context(e.getSharedContext()),this._materialBlend.fragmentNode=m().context(e.getSharedContext()),this._materialBlend.needsUpdate=!0,this._textureNode}dispose(){this._renderTargetEdges.dispose(),this._renderTargetWeights.dispose(),this._renderTargetBlend.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose()}_getAreaTexture(){return""}_getSearchTexture(){return""}},LMe=e=>new oge(a2e(e))}),QUe=F(()=>{ne(),mn(),gi(),ZUe(),ua(),pN=new Z,Ij=new at,BMe=class{constructor(){this._rt=null,this._texNode=null,this._smaaNode=null,this._material=null,this._quad=null,this._depthTexNode=null,this._seedMaterial=null,this._seedQuad=null}_ensureTarget(e,t,i){if(this._rt===null||this._rt.width!==e||this._rt.height!==t){this._rt?.dispose();let r=new Fi(e,t,{depthBuffer:!0,stencilBuffer:!1,samples:0});r.texture.name="SplineHelperOverlay.color",this._rt=r}if(this._texNode===null){this._texNode=mt(this._rt.texture),this._smaaNode=LMe(this._texNode);let r=new Jt;r.name="SplineHelperOverlayComposite",r.fragmentNode=this._smaaNode,r.transparent=!0,r.blending=Mg,r.blendEquation=Wo,r.blendSrc=Kg,r.blendDst=Nf,r.blendSrcAlpha=Kg,r.blendDstAlpha=Nf,r.depthTest=!1,r.depthWrite=!1,this._material=r,this._quad=new Cn(r);let n=new Jt;n.name="SplineHelperOverlayDepthSeed",this._depthTexNode=mt(i),n.depthNode=this._depthTexNode.x,n.fragmentNode=Ae(0),n.colorWrite=!1,n.depthTest=!1,n.depthWrite=!0,this._seedMaterial=n,this._seedQuad=new Cn(n)}else this._texNode.value!==this._rt.texture&&(this._texNode.value=this._rt.texture),this._depthTexNode.value!==i&&(this._depthTexNode.value=i);return this._rt}render(e,t,i,r,n){e.getDrawingBufferSize(pN);let s=this._ensureTarget(pN.x,pN.y,n),a=e.getRenderTarget(),o=e.autoClear;e.getClearColor(Ij);let l=e.getClearAlpha();if(e.autoClear=!1,e.setRenderTarget(s),e.setClearColor(0,0),e.clear(!0,!0,!1),this._seedQuad.render(e),t&&e.render(t,r),e.clear(!1,!0,!1),i&&e.render(i,r),e.setRenderTarget(a),e.setClearColor(Ij,l),function(){try{return new URLSearchParams(window.location.search).get("dbgoutguard")!=="0"}catch{return!0}}()){let h=e.toneMapping,u=e.outputColorSpace;e.toneMapping=Os,e.outputColorSpace=ni.workingColorSpace,this._quad.render(e),e.toneMapping=h,e.outputColorSpace=u}else this._quad.render(e);e.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}}),M$,kO,VO,JUe=F(()=>{mn(),M$=new WeakMap,kO=new Set,VO=0});function lge(e){let t=e.parent?.selectedTexture;return t&&t.isTexture===!0?t:null}function fN(e){let t=e.src.array,i=e.attr.array;for(let r=0,n=Math.min(t.length,i.length);r<n;r++)i[r]=t[r];e.attr.needsUpdate=!0}var E$,vE,Zb,A$,e5e=F(()=>{ne(),mn(),gi(),E$=new WeakMap,vE=new Set,Zb=0,A$=new WeakMap});function t5e(e,t){(function(){if(C$)return;C$=!0;let r=ds.prototype,n=r.addEventListener;r.addEventListener=function(s,a){return s==="dispose"&&Qb!==null&&typeof a=="function"&&Qb.record(this,a),n.call(this,s,a)}})();let i=Qb;Qb=e;try{return t()}finally{Qb=i}}var UMe,mN,Qb,C$,i5e=F(()=>{ne(),UMe=class{constructor(){this._entries=[],this._pruneAt=mN}record(e,t){this._entries.push({target:new WeakRef(e),listener:new WeakRef(t)}),this._entries.length>=this._pruneAt&&(this._entries=this._entries.filter(i=>i.target.deref()!==void 0),this._pruneAt=Math.max(mN,2*this._entries.length))}release(){for(let{target:e,listener:t}of this._entries){let i=e.deref(),r=t.deref();i&&r&&i.removeEventListener("dispose",r)}this._entries=[],this._pruneAt=mN}},mN=1024,Qb=null,C$=!1}),r5e=F(()=>{});function zMe(e,t,i,r){let n=e.num(0),s=e.num(1),a=e.num(.5),o=e.num(2),l=e.num(kMe),h=u=>e.sub(s,u);switch(t){case 0:return i;case 1:return e.min(e.add(i,r),s);case 3:return e.mul(e.add(i,r),a);case 4:{let u=e.max(h(e.div(h(i),e.max(r,l))),n);return e.mix(r,u,e.step(l,r))}case 5:{let u=e.min(e.div(i,e.max(h(r),l)),s);return e.mix(u,r,e.step(s,r))}case 6:return e.min(i,r);case 7:return e.abs(e.sub(i,r));case 8:return e.sub(e.add(i,r),e.mul(o,e.mul(i,r)));case 9:return e.max(i,r);case 10:return e.mul(i,r);case 11:{let u=e.min(e.div(i,e.max(r,l)),s);return e.mix(s,u,e.step(l,r))}case 12:return h(e.abs(e.sub(h(i),r)));case 14:{let u=e.mul(o,e.mul(i,r)),d=h(e.mul(o,e.mul(h(i),h(r))));return e.mix(u,d,e.step(a,i))}case 15:{let u=e.min(e.div(e.mul(i,i),e.max(h(r),l)),s);return e.mix(u,r,e.step(s,r))}case 16:return h(e.mul(h(i),h(r)));case 17:{let u=e.mul(o,r),d=e.add(e.mul(i,u),e.mul(e.mul(i,i),h(u))),c=e.add(e.mul(e.sqrt(e.max(i,n)),e.sub(u,s)),e.mul(e.mul(o,i),h(r)));return e.mix(d,c,e.step(a,r))}case 18:return e.max(e.sub(e.add(i,r),s),n);default:return r}}var kMe,n5e=F(()=>{kMe=1e-6});function wv(e,t,i,r,n){if(i===0)return e;if(i===2)return lt(e,t,Li(n,r));let s=zMe(VMe,i,e,t);return lt(e,s,r)}function Oj(e,t,i,r){if(i===0)return e;if(i===2)return pt(e,Li(t,r));let n=zMe(GMe,i,e,t);return lt(e,n,r)}function Lj(){return jO===null&&(jO=gw({output:P2e,velocity:EMe})).setBlendMode("velocity",AMe),jO}var Ju,GO,VMe,GMe,jO,s5e=F(()=>{ne(),mn(),gi(),FMe(),CMe(),Q2e(),r5e(),Su(),ua(),n5e(),Ot(),Ju=e=>e,GO=e=>e,GMe=VMe={num:e=>L(e),add:(e,t)=>e.add(t),sub:(e,t)=>e.sub(t),mul:(e,t)=>e.mul(t),div:(e,t)=>e.div(t),min:(e,t)=>Li(e,t),max:(e,t)=>pt(e,t),abs:e=>oi(e),sqrt:e=>Rh(e),step:(e,t)=>ar(e,t),mix:(e,t,i)=>lt(e,t,i)},jO=null});function jMe(e){if(!Cy.enabled)return e;let t=P$.get(e);return t||(t={...e,bloom:{...e.bloom,kernelSize:0},depthOfField:{...e.depthOfField,enabled:!1}},P$.set(e,t)),t}var Cy,P$,WO,Bj,R$,D$,lZ,WMe=F(()=>{Cy={enabled:!1},P$=new WeakMap,WO=new WeakSet}),a5e=F(()=>{ne(),mn(),gi(),LK(),HB(),jB(),Bj=He(e=>{let t=e.lightDistance,i=e.cutoffDistance,r=e.decayExponent,n=i.greaterThan(0).and(r.greaterThan(0));return Xi(n,t.div(i).oneMinus().clamp().pow(r),L(1))}),R$=class extends Vq{static get type(){return"SplinePointLightNode"}setupDirect(e){let t=this.getLightVector(e),i=t.normalize(),r=Bj({lightDistance:t.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},D$=class extends hE{static get type(){return"SplineSpotLightNode"}setupDirect(e){let t,i,r=this.light,n=this.getLightVector(e),s=n.normalize(),a=s.dot(m2e(r)),o=this.getSpotAttenuation(e,a),l=Bj({lightDistance:n.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),h=this.colorNode.mul(o).mul(l),u=r;if(u.colorNode?(i=this.getLightCoord(e),t=u.colorNode(i)):u.map&&(i=this.getLightCoord(e),t=mt(u.map,i.xy).onRenderUpdate(()=>u.map)),t&&i){let d=i.mul(2).sub(1).abs().lessThan(1).all();h=Xi(d,h.mul(t),h)}return{lightColor:h,lightDirection:s}}}}),HMe=F(()=>{lZ=null});function qMe(){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.hidden===!0}function o5e(){return qMe()?Promise.resolve():new Promise(e=>{let t=!1,i=()=>{t||(t=!0,clearTimeout(r),e())},r=setTimeout(i,250);requestAnimationFrame(i)})}var hge,H_,uge,dge,cge,Fj,Uj,pge,fge,mge,gge,Ip,Hm,q2,qm,gN,zj,$2,Sv,sc,q_,vge,Tv,ac,X2,$_,vN,Mv,oc,kj,yN,Vj,_N,Gj,jj,bN,xN,$m,Wj,Hj,qj,$j,Xj,Yj,Kj,Ev,yge,Zj,j4,_ge=F(()=>{ne(),mn(),gi(),kUe(),sMe(),YB(),qB(),eZ(),iZ(),MK(),Nh(),VUe(),Ot(),oF(),OK(),bK(),hMe(),uMe(),GUe(),jUe(),WUe(),ua(),MMe(),cMe(),$Ue(),FMe(),YUe(),KUe(),QUe(),JUe(),e5e(),i5e(),s5e(),WMe(),mK(),a5e(),HMe(),hge=new P,H_=new P,uge=new at,dge=new at,cge=new at,Fj=new P,Uj=new P,pge=new Z,fge=new P(1,0,0),mge=new P(0,1,0),gge=new P(0,0,1),Ip=new P,Hm=new P,q2=new P,qm=new P,gN=new De,zj=new P,$2=new P,Sv=new Wa,sc=new ut,q_=new ut,vge=new Z,Tv=new Z,ac=new P,X2=new P,$_=new P,vN=new P,Mv=new P,oc=[],kj=!1,yN=!1,Vj=!1,_N="full",Gj="g16",jj=!1,bN=!1,xN=!1,$m="default",Wj=!1,Hj=!0,qj=!0,$j=!0,Xj=!0,Yj=!0,Kj=gq;try{let e=new URLSearchParams(window.location.search),t=e.get("instancing");if(t!==null)if(t==="off"||t==="0"||t==="false"||t==="no")Yj=!1;else{let n=Number.parseInt(t,10);Number.isFinite(n)&&n>1&&(Kj=n)}kj=e.get("dbgao")==="0",yN=e.get("dbgshadow")==="0",Vj=e.get("dbgfp16")==="1",jj=e.get("dbgsky")==="0",bN=e.get("dbgssr")==="0",xN=e.get("dbgibl")==="0";let i=e.get("pbrcolor");i==="0"?$m="off":(i==="linear"||i==="aces"||i==="agx"||i==="neutral")&&($m=i),Wj=e.get("dbgplanar")==="0",Hj=e.get("dbgplanarpyr")!=="0",qj=e.get("dbgssrpyr")!=="0",$j=e.get("dbgssrhalf")!=="0",Xj=e.get("dbgssrresolve")!=="0";let r=e.get("dbgprefilter");r==="0"?_N="off":r==="base"?_N="base":r==="k4"&&(Gj="k4")}catch{}Ev=[null,null,null,null],yge=AO.prototype._projectObject,(j4=Zj=class extends AO{constructor(e={}){var t;super({canvas:e.canvas,alpha:e.alpha??!0,antialias:e.antialias??!1,forceWebGL:e.forceWebGL??!1,powerPreference:e.powerPreference,trackTimestamp:e.trackTimestamp??globalThis.__SPLINE_TRACK_TIMESTAMP__===!0,stencil:!1,requiredLimits:e.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:Vj?li:zr,asyncCompilation:e.asyncCompilation===!0||e.asyncCompilation==="load"}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new Z,this.dummyCamera=new Kn,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this._shadowMapMissingAtSync=!1,this._shadowSyncPromotions=-1,this._lightShadowStateDirty=!1,this._lightShadowSignatures=new WeakMap,this._shadowMapIds=new WeakMap,this._shadowMapIdSeq=0,this.temporalAAEnabled=!0,this.hdrChainActive=!1,this.isWebGPUSplineRenderer=!0,this.shadowFilterHook=qUe,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new OMe,this._stallWarned=!1,this._asyncCompilationMode=!1,this._asyncLoadWarmupsInFlight=0,this.sceneBundlesEnabled=!1,this.sceneBundlesForceRerecord=!1,this.disposeListenerLedger=new UMe,this._appliedWidth=-1,this._appliedHeight=-1,this._appliedRatio=-1,this._bundleLists=null,this._bundleStates=new WeakMap,this._skySystem=null,this._envClaimScope=null,this._envClaimEpoch=-1,this._skyFeatureWarned=!1,this.skyAnimationAllowed=!1,this.skyEnvironmentNeeded=!0,this._bundledPages=new Set,this._bundleValveArmed=!1,this._destroyedSubmitErrors=0,this._destroyedSubmitLastFrame=-10,this._warmupTarget=null,this.renderStarted=!1,this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._grabWarmupTarget=null,this._warnedHelperIncompat=new WeakSet,this._maskLights=[],this._maskBlocked=!1,this.suppressShadowMask=!1,this._grabTargetEpoch=0,this._retiredGrabTargets=[],this._retiredGpuBuffers=[],this._bundleEpochDirty=!1,this._encodeMaterials={},this._transmissionChain=[],this._reflectionColorChain=[],this._reflectionDepthChain=[],this._reflectionPassesKey="",this._reflectionResolveMarchKey="",this._planarChain=[],this._frameSerial=0,this._asyncCompilationMode=e.asyncCompilation??!1,this._updateCompilationBurst(),u$&&function(){if(!c$){if(c$=!0,L4=()=>tt.frameIndex.value,typeof GPUBuffer<"u"){let i=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return Ume("buffer",this.label,this.size),i.call(this)}}if(typeof GPUTexture<"u"){let i=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return Ume("texture",this.label,`${this.width}x${this.height}`),i.call(this)}}console.info("[spline/webgpu] ?dbgdestroys=1 \u2014 GPU resource destroy logging armed; reproduce the error and read the [dbgdestroys] dumps")}}(),this.pipeline=new nZ(this),this.library.addLight(oMe,O4),this.shadowMap.enabled=!0,this.shadowMap.type=Df,t=this.backend?.isWebGPUBackend===!0,mE=t,this._deferGpuBufferDestruction(),function(i){let r=i;if(r==null||typeof r._draw!="function"||r.__splineDrawGuardInstalled===!0)return;r.__splineDrawGuardInstalled=!0;let n=r._draw.bind(r);r._draw=function(s,a,o,l,h,u,d,c,p){if(d.vertexCount>0&&s.getIndex()===null&&s.getIndirect()===null&&s.object.isBatchedMesh!==!0){let f=d.firstVertex+d.vertexCount;for(let m=0;m<u.length;m++){let g=u[m];if(g.isInstancedBufferAttribute!==!0&&g.isInstancedInterleavedBuffer!==!0&&g.count!==void 0&&g.count<f)return}}return n(s,a,o,l,h,u,d,c,p)}}(this.backend),this.outputColorSpace=Td,this.toneMapping=Os,function(i){let r=i.library;r.addLight(R$,bC),r.addLight(D$,Lw),r.addLight(Gq,Ow),r.lightNodes.delete(CA),r.lightNodes.delete(by),r.addLight(R$,CA),r.addLight(D$,by)}(this),this.sceneBundlesEnabled=e.sceneBundles===!0||e.sceneBundles==="rerecord",this.sceneBundlesForceRerecord=e.sceneBundles==="rerecord",this.auxiliary=e.auxiliary===!0,this.domElement.removeAttribute?.("data-engine")}advanceFrame(){let e=this._nodes,t=this.info;t.autoReset===!0&&t.reset(),e.nodeFrame.update(),t.frame=e.nodeFrame.frameId}get lastFrameIncomplete(){return!!(this._warmupInFlight||this._compilationHasWork&&!this._gaugesStalled)||(this._skippedAsyncDraws??0)!==0&&!this._skipStalls.stalled}get _gaugesStalled(){return this._gaugeChangedAt>0&&performance.now()-this._gaugeChangedAt>Zj._GAUGE_STALL_MS}_trackGaugeStall(){let e=this._asyncCompilationGauges,t=e!==void 0&&(e.queued>0||e.pipelines>0),i=t?`${e.queued}/${e.pipelines}`:"";return t?i!==this._gaugeSnapshot?(this._gaugeSnapshot=i,void(this._gaugeChangedAt=performance.now())):void(this._gaugesStalled&&!this._gaugeStallWarned&&(this._gaugeStallWarned=!0,console.warn(`[spline/webgpu] async pipeline driver stalled (${i} in flight, no movement for ${Zj._GAUGE_STALL_MS}ms) \u2014 treating frames as final so screenshots, thumbnails and the on-demand render loop keep working.`))):(this._gaugeSnapshot="",void(this._gaugeChangedAt=0))}_trackStalledSkips(e){let t=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(e,t),Si.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${e} draw(s) are permanently skipped \u2014 their render pipelines never became ready (look for "pipeline creation failed" above). Those objects will not appear; the frame is treated as final so screenshots, thumbnails and the on-demand render loop keep working.`))}get _asyncCompilationGauges(){return this.info.asyncCompilation}get _compilationHasWork(){let e=this._asyncCompilationGauges;return e!==void 0&&(e.queued>0||e.pipelines>0)}get asyncCompilationEnabled(){return this._asyncCompilation===!0}setAsyncCompilationPolicy(e){this._asyncCompilationMode!==e&&(this._asyncCompilationMode=e,this._setThreeAsyncCompilation(e),this._updateCompilationBurst())}get taaHistory(){return this._taaHistory||(this._taaHistory=PMe()),this._taaHistory}async init(){await super.init(),function(t,i=sZ){if(!function(a){return a.isWebGPUBackend===!0}(t)||t.__splineTextureClampInstalled===!0)return;t.__splineTextureClampInstalled=!0;let r=t.createTexture.bind(t),n=t.updateTexture.bind(t),s=()=>t.device?.limits.maxTextureDimension2D??0;t.createTexture=(a,o)=>{zme(a,o,s(),i),r(a,o)},t.updateTexture=(a,o)=>{zme(a,o,s(),i),n(a,o)}}(this.backend);let e=this.backend.gl;if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(t){console.warn(t)}return this.backend.device?.lost?.then(t=>{Si.deviceLost=`${t?.reason??"unknown"}: ${t?.message??""}`.trim()}),this}setSize(e,t,i=!0){if(this._appliedWidth!==e||this._appliedHeight!==t||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=e,this._appliedHeight=t,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==e||this.viewportHeight!==t;this.viewportWidth=e,this.viewportHeight=t,super.setSize(e,t,i),r&&this.pipeline.resize(e,t,i)}return this}setPixelRatio(e=1){return this.getPixelRatio()!==e&&super.setPixelRatio(e),this}get hdTransmission(){return tt.transmissionLod.value===1}set hdTransmission(e){tt.transmissionLod.value=e===!0?1:2}renderScenePass(e,t){this.render(e,t)}_projectObject(e,t,i,r,n){let s=this,a=s._renderLists;e.isBundleGroup===!0&&r===a.get(e,t)&&(s._renderLists=this._bundleLists??(this._bundleLists=new a.constructor(a.lighting,a.objects)));try{yge.call(this,e,t,i,r,n)}finally{s._renderLists=a}}_renderObjects(e,t,i,r,n=null){let s=this,a=n===null&&i.overrideMaterial===null;for(let o=0,l=e.length;o<l;o++){let{object:h,geometry:u,material:d,group:c,clippingContext:p}=e[o];if(a&&s$(d))this._renderWithDepthPrepass(h,i,t,u,d,c,r,p);else{if(a&&this._drawsStalePrepass(h,d,r,n)){let f=d,m=(g,v)=>s._handleObjectFunction(h,g,i,t,r,c,p,v);d.side!==Cr||d.forceSinglePass?m(f.getDepthPrepassTwin(d.side),null):(m(f.getDepthPrepassTwin(wr),null),d.side=wr,m(d,"backSide"),d.side=Cr,m(f.getDepthPrepassTwin(sa),null))}s._currentRenderObjectFunction(h,i,t,u,d,c,r,p,n)}}}_renderTransparents(e,t,i,r,n){AO.prototype._renderTransparents.call(this,e,t,i,r,n);let s=this.pipeline.depthOfFieldDepthTexture;if(s===null||this.getRenderTarget()?.depthTexture!==s)return;let a=this;for(let{object:o,material:l,group:h,clippingContext:u}of e)!s$(l)||l.getDepthOfFieldTwin===void 0||(a._handleObjectFunction(o,l.getDepthOfFieldTwin(l.side),r,i,n,h,u,null),Si.depthOfFieldTwinDraws++)}_drawsStalePrepass(e,t,i,r){if(t.transparent||!this.asyncCompilationEnabled||!("getDepthPrepassTwin"in t))return!1;Ev[0]=e,Ev[1]=t,Ev[2]=this._currentRenderContext,Ev[3]=i;let n=this._objects.getChainMap(r).get(Ev)?.drawMaterial;return Ev.fill(null),n?.transparent===!0&&n.depthWrite===!1}_renderWithDepthPrepass(e,t,i,r,n,s,a,o){let l=this,h=(d,c)=>l._handleObjectFunction(e,d,t,i,a,s,o,c),u=s;e.onBeforeRender(this,t,i,r,n,u),n.side===Cr&&n.forceSinglePass===!1?(h(n.getDepthPrepassTwin(wr),null),n.side=wr,h(n,"backSide"),h(n.getDepthPrepassTwin(sa),null),n.side=sa,h(n,null),n.side=Cr,Si.depthPrepassDraws+=2):(h(n.getDepthPrepassTwin(n.side),null),h(n,null),Si.depthPrepassDraws++),e.onAfterRender(this,t,i,r,n,u)}get skySystem(){return this._skySystem}get skyAnimationActive(){return this._skySystem?.animationActive===!0}*_liveBundledPages(){for(let e of this._bundledPages){let t=e.deref();t===void 0?this._bundledPages.delete(e):yield t}}_armBundleValve(){if(this._bundleValveArmed)return;let e=this.backend.device;typeof e?.addEventListener=="function"&&(this._bundleValveArmed=!0,e.addEventListener("uncapturederror",t=>{if(!this.sceneBundlesEnabled||!(t?.error?.message??"").toLowerCase().includes("destroyed"))return;let i=tt.frameIndex.value,r=(i-this._destroyedSubmitLastFrame+16)%16;if(this._destroyedSubmitErrors=r<=2?this._destroyedSubmitErrors+1:1,this._destroyedSubmitLastFrame=i,!(this._destroyedSubmitErrors<4)){this.sceneBundlesEnabled=!1,Si.bundleDisabled=!0;for(let n of this._liveBundledPages()){let s=this._bundleStates.get(n);s&&(s.disabled=!0),n.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(e,t){if(this.backend.beginBundle===void 0)return;let i=this._bundleStates.get(e);if(i===void 0){let d={signature:-1,rebuilds:0,resourceRebuilds:0,checks:0,disabled:!1,camHash:0,prevCamHash:0,epoch:0,lastEpoch:0,bufferIds:new WeakMap,bufferIdSeq:0,watched:new WeakSet,onResourceDispose:()=>{d.epoch++}};i=d,this._bundleStates.set(e,i),this._bundledPages.add(new WeakRef(e)),this._armBundleValve()}let r=e;if(i.disabled)return;{let d=t.matrixWorld.elements,c=t.projectionMatrix.elements,p=-2128831035;for(let f=0;f<16;f++)p^=1e4*d[f]|0,p=Math.imul(p,16777619),p^=1e4*c[f]|0,p=Math.imul(p,16777619);i.camHash=p}let n=-2128831035,s=d=>{n^=0|d,n=Math.imul(n,16777619)};s(this._grabTargetEpoch),s(e.fog!==null?1:0),s(this.pipeline.depthOfFieldDepthTexture!==null?1:0);let a=i,o=d=>{let c=d;!c||typeof c.addEventListener!="function"||a.watched.has(c)||(a.watched.add(c),c.addEventListener("dispose",a.onResourceDispose))},l=d=>{if(!d)return 0;let c=a.bufferIds.get(d);return c===void 0&&(c=++a.bufferIdSeq,a.bufferIds.set(d,c)),c},h=d=>{o(d),s(d.id),s(d.version),s(d.transparent===!0?1:0),typeof d.assetsLoaded=="function"&&s(d.assetsLoaded()?1:0)},u=!1;if(e.traverse(d=>{let c=d;if(c.isMesh===!0||c.isLine===!0||c.isPoints===!0||c.isSprite===!0){let p=c;p.isDecalObject===!0&&typeof p.updateDecal=="function"&&p.updateDecal()&&(u=!0),c.runBeforeRenderWhenBundled===!0&&c.onBeforeRender(this,e,t,c.geometry,c.material,null),c.frustumCulled&&(c.frustumCulled=!1),s(c.id),s(c.visible?1:0),s(c.layers.mask),s(c.renderOrder),s(c.matrixWorld.determinantAffine()<0?1:0);let f=c.geometry;o(f),s(f.id),s(f.drawRange.start),s(f.drawRange.count===1/0?-1:f.drawRange.count),s(l(f.index)),s(l(f.attributes.position)),s(f.instanceCount??-1),s(c.count===void 0?-1:c.count);let m=c;s(m.isSkinnedMesh===!0&&m.skeleton?m.skeleton.bones.length:-1);let g=c.material;if(Array.isArray(g))for(let v of g)h(v);else g&&h(g)}else d.isLight===!0?(s(d.id),s(d.visible?1:0),s(d.castShadow?1:0)):(s(d.id),s(d.visible?1:0))}),s(i.epoch),i.checks++,Si.bundleChecks=i.checks,i.checks%600==0){let d=this._bundleDebug;Si.bundleIncompleteRecords=d?.incompleteRecords??0,Si.bundleRecords=d?.records??0,Si.bundleReplays=d?.replays??0,i.prevCamHash=i.camHash}if(r.isBundleGroup!==!0)return function(d){let c=d;Object.getOwnPropertyDescriptor(c,"needsUpdate")?.set||Object.defineProperty(c,"needsUpdate",{configurable:!0,enumerable:!1,get:()=>!1,set(p){p===!0&&(this.version=(this.version??0)+1)}}),c.isBundleGroup=!0,c.static=!0,typeof c.version!="number"&&(c.version=0)}(e),void(i.signature=n);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=n);if(n!==i.signature){if(i.signature=n,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch||u)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(Si.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,Si.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,Si.bundleDisabled=!0)}}_ensureWarmupTarget(){if(this._warmupTarget===null){let e=new Fi(2,2,{count:2});e.textures[0].name="output",e.textures[0].type=zr,e.textures[1].name="velocity",e.textures[1].type=li;let t=new ns(2,2);t.isRenderTargetTexture=!0,e.depthTexture=t,this._warmupTarget=e}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(e,t=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[e,t,i]:super.setRenderTarget(e,t,i)}setMRT(e){return this._warmupInFlight?(this._warmupPendingMRT=[e],this):(super.setMRT(e),this)}async compileSceneAsync(e,t){if(!t)return;{let n=e instanceof zg?e.activePage:e;Wme(wy.isSoft(n?.data?.shadow)),n&&Rme(n)}if(this._asyncCompilationMode!==!1)return this._asyncCompilationMode==="load"&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(e,t);if(this.renderStarted||this._warmupInFlight)return;let i=this.getRenderTarget(),r=this.getMRT();this._warmupInFlight=!0,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst();try{this.normalizeCameraCoordinateSystem(t),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(Lj())),await this.compileAsync(e,t)}catch(n){console.warn("[spline/webgpu] pipeline warm-up failed:",n)}finally{let n=this._warmupPendingTarget,s=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),n!==null?super.setRenderTarget(n[0],n[1],n[2]):super.setRenderTarget(i),s!==null?super.setMRT(s[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(e,t){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(t);let i,r=this.getRenderTarget(),n=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(Lj())),i=this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(n)}let s=this._warmupGrabContext(e,t);await i,await s}catch(i){console.warn("[spline/webgpu] pipeline warm-up failed:",i)}finally{this._asyncLoadWarmupsInFlight--,this._updateCompilationBurst(),this._maybeCloseAsyncLoadWindow()}}_disposeWarmupTargets(){this._warmupTarget?.depthTexture?.dispose(),this._warmupTarget?.dispose(),this._warmupTarget=null,this._grabWarmupTarget?.depthTexture?.dispose(),this._grabWarmupTarget?.dispose(),this._grabWarmupTarget=null}_warmupGrabContext(e,t){let i=e instanceof zg?e:e.scene;if(i.needsTransmission?.()!==!0&&i.needsReflection?.()!==!0)return null;if(this._grabWarmupTarget===null){let s=new Fi(2,2);s.texture.type=zr;let a=new ns(2,2);a.isRenderTargetTexture=!0,s.depthTexture=a,this._grabWarmupTarget=s}let r=this.getRenderTarget(),n=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(n)}}_setThreeAsyncCompilation(e){this.setAsyncCompilation(e)}_updateCompilationBurst(){let e=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||this._asyncCompilationMode==="load"&&this.asyncCompilationEnabled;this.setCompilationBurst(e),Si.compilationBurst=e}_maybeCloseAsyncLoadWindow(){this._asyncCompilationMode==="load"&&(!this.asyncCompilationEnabled||this._asyncLoadWarmupsInFlight>0||this._frameSerial!==0&&((this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled||this._compilationHasWork||(this._setThreeAsyncCompilation(!1),this._updateCompilationBurst())))}normalizeCameraCoordinateSystem(e){let t=e;(t.coordinateSystem!==this.coordinateSystem||t.perspCamera!==void 0&&t.perspCamera.coordinateSystem!==this.coordinateSystem||t.orthoCamera!==void 0&&t.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(t.coordinateSystem=this.coordinateSystem,t.perspCamera!==void 0&&(t.perspCamera.coordinateSystem=this.coordinateSystem),t.orthoCamera!==void 0&&(t.orthoCamera.coordinateSystem=this.coordinateSystem),e.updateProjectionMatrix?.())}_prepareHelpers(e,t,i){e.traverse(r=>{let n=r;if(r.isPoints===!0){let l=function(h){if(Array.isArray(h.material)||h.parent===null||h.geometry.getAttribute("position")===void 0)return null;let u=h.material;return u.isNodeMaterial===!0?null:u.isPointsMaterial===!0?function(d,c){if(c.size<=1)return null;let p=E$.get(d);return p&&(p.epoch!==Zb||p.srcMaterial!==c||p.geometry!==d.geometry||p.position.src!==d.geometry.getAttribute("position")||p.map!==c.map||p.selectedMap!==lge(d))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(f,m){let g=f.geometry,v=g.getAttribute("position"),y=g.getAttribute("aSelection"),_=g.getAttribute("aVisibility"),b=m.map,x=lge(f),w=new fl(v.array,3);w.setUsage(bd);let S={src:v,attr:w,version:v.version},T=[],M=O=>{let k=new fl(new Float32Array(O.count),1);k.setUsage(bd);let G={src:O,attr:k,version:O.version};return fN(G),T.push(G),G},E=y?M(y):null,A=_?M(_):null,C=new XA;C.name=`SplinePointsTwin(${m.name||m.type})`,C.positionNode=vg(S.attr,"vec3"),C.size=m.size,C.sizeAttenuation=m.sizeAttenuation,C.transparent=m.transparent,C.depthTest=m.depthTest,C.depthWrite=m.depthWrite,C.blending=m.blending,C.fog=!1;let D=E?vg(E.attr,"float"):null,R=A?vg(A.attr,"float"):null;C.colorNode=He(()=>{R!==null?CO(R.lessThan(.5)):D!==null&&CO(D.greaterThan(.5));let O=b!==null?mt(b,Hi()):Ae(1);return(D!==null&&b!==null&&x!==null?lt(O,mt(x,Hi()),D):O).mul(Ae(v2e,1))})();let I=new aW(C);I.name=`SplinePointsTwin(${f.name||f.type})`,I.frustumCulled=!1,I.raycast=()=>{};let U={sprite:I,material:C,srcMaterial:m,geometry:g,map:b,selectedMap:x,position:S,mirrors:T,epoch:Zb};return vE.add(new WeakRef(U)),U}(d,c),E$.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(f,m){let{sprite:g,position:v,srcMaterial:y}=m;v.version!==v.src.version&&(m.position.attr.needsUpdate=!0,v.version=v.src.version);for(let b of m.mirrors)b.version!==b.src.version&&(fN(b),b.version=b.src.version);let _=Math.max(0,Math.min(m.geometry.drawRange.count,v.src.count));g.count=_,m.material.size=y.size,m.material.opacity=y.opacity,m.material.color.copy(y.color),g.layers.mask=f.layers.mask,g.renderOrder=f.renderOrder}(d,p),p.sprite}(h,u):function(d,c){if(c.isShaderMaterial!==!0)return!1;let p=c.uniforms,f=p?.pointSize?.value,m=p?.color?.value;return typeof f=="number"&&f>1&&Array.isArray(m)&&m.length>=3&&d.geometry.getAttribute("hover")!==void 0&&d.geometry.getAttribute("selected")!==void 0}(h,u)?function(d,c){let p=A$.get(d);return p&&(p.epoch!==Zb||p.srcMaterial!==c||p.geometry!==d.geometry||!function(f,m){let g=[[f.position,"position"],[f.hover,"hover"],[f.selected,"selected"]];for(let[v,y]of g){let _=m.getAttribute(y);if(_===void 0)return!1;if(v.src!==_){if(_.count!==v.attr.count)return!1;v.src=_,v.version=-1}}return!0}(p,d.geometry))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(f,m){let g=f.geometry,v=m.uniforms,y=(D,R)=>{let I=new fl(new Float32Array(D.count*R),R);I.setUsage(bd);let U={src:D,attr:I,version:D.version};return fN(U),U},_=y(g.getAttribute("position"),3),b=y(g.getAttribute("hover"),1),x=y(g.getAttribute("selected"),1),w=Be(v.pointSize.value),S=Be(new at().fromArray(v.color.value)),T=new XA;T.name=`SplinePointsTwin(${m.name||m.type})`,T.positionNode=vg(_.attr,"vec3");let M=vg(b.attr,"float"),E=vg(x.attr,"float");T.sizeNode=w.add(M.mul(4)),T.sizeAttenuation=!1,T.transparent=m.transparent,T.depthTest=m.depthTest,T.depthWrite=m.depthWrite,T.blending=m.blending,T.fog=!1,T.colorNode=He(()=>{let D=$i(Hi().mul(2).sub(1)).toVar();CO(D.greaterThan(1));let R=Xi(E.equal(1),Q(.22,.9,.7),S.add(M.mul(.25)));return Ae(Xi(D.greaterThan(.75),Q(1),R),1)})();let A=new aW(T);A.name=`SplinePointsTwin(${f.name||f.type})`,A.frustumCulled=!1,A.raycast=()=>{};let C={sprite:A,material:T,srcMaterial:m,geometry:g,pointSize:w,color:S,position:_,hover:b,selected:x,epoch:Zb};return vE.add(new WeakRef(C)),C}(d,c),A$.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(f,m){for(let y of[m.position,m.hover,m.selected])y.version!==y.src.version&&(fN(y),y.version=y.src.version);let g=m.srcMaterial.uniforms;m.pointSize.value=g.pointSize.value,m.color.value.fromArray(g.color.value);let v=Math.max(0,Math.min(m.geometry.drawRange.count,m.position.src.count));m.sprite.count=v,m.material.opacity=m.srcMaterial.opacity,m.sprite.layers.mask=f.layers.mask,m.sprite.renderOrder=f.renderOrder}(d,p),p.sprite}(h,u):null}(r);if(l!==null)return l.visible=n.visible,void(n.visible&&(t.push(n),n.visible=!1))}let s=!1,a="",o=Array.isArray(n.material)?n.material:n.material?[n.material]:[];for(let l of o){let h=l;if(h.isShaderMaterial===!0&&h.isNodeMaterial!==!0){s=!0,a=`WebGL-only material "${h.type}"`;break}}if(s&&!Array.isArray(n.material)){let l=function(h){return h.isLineMaterial===!0?function(u){let d=M$.get(u);if(!d||d.epoch!==VO){let g=new qTe;g.name=`SplineHelperTwin(${u.name||u.type})`,g.worldUnits=!1,d={twin:g,epoch:VO},M$.set(u,d),kO.add(new WeakRef(g))}let c=d.twin,p=u;c.color.copy(p.color),c.linewidth=p.linewidth,c.opacity=p.opacity,c.transparent=p.transparent,c.depthTest=p.depthTest,c.depthWrite=p.depthWrite,c.side=p.side;let f=p.dashed===!0;if(c.dashed!==f&&(c.dashed=f,c.needsUpdate=!0),f){let g=c;g.dashScale=p.dashScale??1,g.dashSize=p.dashSize??1,g.gapSize=p.gapSize??1}let m=p.vertexColors===!0||p.vertexColors===2;return c.vertexColors!==m&&(c.vertexColors=m,c.needsUpdate=!0),c}(h):null}(n.material);if(l)return i.push({object:n,original:n.material}),void(n.material=l)}!s&&n.geometry?.isInstancedBufferGeometry===!0&&!Number.isFinite(n.geometry.instanceCount??0)&&(s=!0,a="infinite instanceCount geometry"),s&&n.visible&&(this._warnedHelperIncompat.has(r)||this._warnedHelperIncompat.add(r),t.push(n),n.visible=!1)})}renderHelperOverlay(e,t,i,r){let n=[],s=[];if(e&&this._prepareHelpers(e,n,s),t&&this._prepareHelpers(t,n,s),r)this._helperOverlay??(this._helperOverlay=new BMe),this._helperOverlay.render(this,e,t,i,r),Si.helperOverlayMode="smaa";else{let a=this.autoClear;this.autoClear=!1,e&&this.render(e,i),t&&(this.clearDepth(),this.render(t,i)),this.autoClear=a,Si.helperOverlayMode="direct"}for(let a of s)a.object.material=a.original;for(let a of n)a.visible=!0}createEffectChain(){return function(e){let t=e.pipeline,i=t.postprocessingState,r=i.enabled===!0,n=D2e(t.scene,t.camera),s=e.hdrChainActive;try{let E=new URLSearchParams(window.location.search).get("dbgfp16");(E==="scene"||E==="st")&&(s=!0)}catch{}let a=n.getTextureNode(),o=a,l=null;if(e.temporalAAEnabled){n.setMRT(Lj()),l=function(E,A,C,D,R=!1){return new IMe(E,A,C,D,R)}(a,n.getTextureNode("depth"),n.getTextureNode("velocity"),e.taaHistory,s),o=l,n.getTexture("velocity").type=li;try{if(new URLSearchParams(window.location.search).get("dbgvel")==="1"){let E=Ju(n.getTextureNode("velocity"));o=Ae(GO(E.x).mul(20).add(.5),GO(E.y).mul(20).add(.5),L(.5),L(1))}}catch{}}s?n.getTexture("output").type=li:aF()&&(n.getTexture("output").internalFormat="rgba8unorm-srgb");let h=(E,A)=>typeof E=="number"&&Number.isFinite(E)?E:A,u={bloomIntensity:Be(1),caOffset:Be(new Z(0,0)),caAspect:Be(1),vignetteOffset:Be(0),vignetteDarkness:Be(0),hueVector:Be(new P(1,0,0)),saturationFactor:Be(0),brightness:Be(0),bcContrastScale:Be(1),dofFocusDistance:Be(0),dofFocalLength:Be(0),dofBokehScale:Be(1),dofCameraNear:Be(50),dofCameraFar:Be(1e4),dofOrtho:Be(0),pixelCells:Be(new Z(1,1)),bloomOpacity:Be(1),caOpacity:Be(1),vignetteOpacity:Be(1),noiseOpacity:Be(1),hueSaturationOpacity:Be(1),brightnessContrastOpacity:Be(1),dofOpacity:Be(1)},d=E=>GO(E),c=(E,A)=>{u.bloomIntensity.value=h(E.bloom.intensity,1),u.bloomOpacity.value=h(E.bloom.opacity,1),u.caOffset.value.set(h(E.chromaticAberration.offset?.[0],10),h(E.chromaticAberration.offset?.[1],10)),u.caOpacity.value=h(E.chromaticAberration.opacity,1),u.vignetteOffset.value=h(E.vignette.offset,.5),u.vignetteDarkness.value=h(E.vignette.darkness,.5),u.vignetteOpacity.value=h(E.vignette.opacity,1),u.noiseOpacity.value=h(E.noise.opacity,1),u.hueVector.value.fromArray(function(G){let K=Math.sin(G),q=Math.cos(G);return[(2*q+1)/3,(-Math.sqrt(3)*K-q+1)/3,(Math.sqrt(3)*K-q+1)/3]}(h(E.hueSaturation.hue,0))),u.saturationFactor.value=function(G){return G>0?1-1/(1.001-G):-G}(h(E.hueSaturation.saturation,0)),u.hueSaturationOpacity.value=h(E.hueSaturation.opacity,1),u.brightness.value=h(E.brightnessContrast.brightness,0);let C=Math.min(h(E.brightnessContrast.contrast,0),.9999);u.bcContrastScale.value=C>0?1/(1-C):1+C,u.brightnessContrastOpacity.value=h(E.brightnessContrast.opacity,1);let D=t.camera,R=D?.isPerspectiveCamera===!0,I=function(G,K,q){return{focusDistance:q?G/2e3:(G+992)/2e3,focusRange:Math.max(K/2e3,1e-6)}}(h(E.depthOfField.focusDistance,BO.focusDistance),h(E.depthOfField.focalLength,BO.focalLength),R);u.dofFocusDistance.value=I.focusDistance,u.dofFocalLength.value=I.focusRange,u.dofBokehScale.value=h(E.depthOfField.bokehScale,BO.bokehScale),u.dofOpacity.value=h(E.depthOfField.opacity,1),u.dofCameraNear.value=h(D?.near,50),u.dofCameraFar.value=h(D?.far,1e4),u.dofOrtho.value=R?0:1;let U=A.resolution.x?A.resolution:new Z(A.viewportWidth*A.getPixelRatio(),A.viewportHeight*A.getPixelRatio());u.caAspect.value=U.y>0?U.x/U.y:1;let O=Math.floor(h(E.pixelation.granularity,30));O%2>0&&(O+=1);let k=O>0;u.pixelCells.value.set(k?U.x/O:U.x,k?U.y/O:U.y)};c(i,e);let p=Ju(o),f=p.rgb,m=p.a,g=r&&i.pixelation.enabled,v=u.pixelCells,y=E=>E.mul(v).floor().add(.5).div(v),_=l?l.outputTextureNode:a;if(g){let E=Ju(_.sample(y(Hi())));f=lt(f,E.rgb,1),m=lt(m,E.a,1)}if(r&&i.chromaticAberration.enabled){let E=i.chromaticAberration,A=u.caOffset.mul(.001).mul(Se(1,d(u.caAspect))),C=U=>g?y(U):U,D=Ju(_.sample(C(Hi().add(A)))),R=Ju(_.sample(C(Hi().sub(A)))),I=pt(pt(D.a,R.a),m);f=wv(f,Q(D.r,f.g,R.b),E.blendFunction,d(u.caOpacity),I),m=Oj(m,I,E.blendFunction,d(u.caOpacity))}let b=null;if(r&&i.depthOfField.enabled){let E=vne("depthOfField");if(E){let A=i.depthOfField;b=E(Ae(f,m),_,n.getTextureNode("depth"),{focusDistance:d(u.dofFocusDistance),focusRange:d(u.dofFocalLength),bokehScale:d(u.dofBokehScale),cameraNear:d(u.dofCameraNear),cameraFar:d(u.dofCameraFar),orthographic:d(u.dofOrtho)},{halfFloat:s,inputUv:g?y:void 0});let C=Ju(b);f=wv(f,C.rgb,A.blendFunction,d(u.dofOpacity),C.a),m=Oj(m,C.a,A.blendFunction,d(u.dofOpacity))}else _q("depthOfField","webgpu")}let x=null;if(r&&i.bloom.enabled){let E=vne("bloom");if(E){let A=i.bloom;x=E(l?l.outputTextureNode:a,{kernelSize:X4e(A.kernelSize),blurScale:h(A.blurScale,1),luminanceThreshold:h(A.luminanceThreshold,.9),luminanceSmoothing:h(A.luminanceSmoothing,.025)});let C=qt(Ju(x).mul(d(u.bloomIntensity)),0,1);f=wv(f,C.rgb,A.blendFunction,d(u.bloomOpacity),C.a),m=Oj(m,C.a,A.blendFunction,d(u.bloomOpacity))}else _q("bloom","webgpu")}if(r&&i.hueSaturation.enabled){let E=i.hueSaturation,A=u.hueVector,C=Q(Je(f,A),Je(f,A.zxy),Je(f,A.yzx)),D=C.r.add(C.g).add(C.b).div(3);f=wv(f,C.add(Q(D).sub(C).mul(d(u.saturationFactor))).min(1),E.blendFunction,d(u.hueSaturationOpacity),m)}if(r&&i.brightnessContrast.enabled){let E=i.brightnessContrast,A=f.add(Q(d(u.brightness)));A=A.sub(.5).mul(d(u.bcContrastScale)).add(.5),f=wv(f,A.min(1),E.blendFunction,d(u.brightnessContrastOpacity),m)}if(r&&i.vignette.enabled){let E=i.vignette,A=$i(Hi().sub(.5)).mul(d(u.vignetteDarkness).add(d(u.vignetteOffset))),C=Kr(d(u.vignetteOffset).mul(.799),L(.8),A).oneMinus();f=wv(f,f.mul(C),E.blendFunction,d(u.vignetteOpacity),m)}if(r&&i.noise.enabled){let E=i.noise,A=fr(Aa(vd(Je(Hi().mul(q2e),Se(12.9898,78.233)),Math.PI)).mul(43758.5453));f=wv(f,Q(A),E.blendFunction,d(u.noiseOpacity),m)}r&&(s?f=f.max(0):(f=qt(f,0,1),m=qt(m,0,1)));let w=Ae(f,m);if(t.uiOverlayEnabled&&t.uiCanvasTexture){let E=Ju(mt(t.uiCanvasTexture,Hi().flipY())),A=lt(w.rgb,E.rgb,E.a),C=qt(w.a.add(E.a),0,1);w=Ae(A,C)}let S=t.sceneTransitionFromTexture;if(S){let E=Ju(mt(S,Hi())),A=t.sceneTransitionPass.uniforms.mixRatio;w=lt(E,w,A)}let T=t.watermarkTexture;if(T){let E=T.image,A=E?.width||128,C=E?.height||32,D=new Z(e.viewportWidth*e.getPixelRatio(),e.viewportHeight*e.getPixelRatio()),R=12*e.getPixelRatio(),I=.5*A*e.getPixelRatio(),U=.5*C*e.getPixelRatio(),O=Se((D.x-I-R)/D.x,R/D.y),k=Se(I/D.x,U/D.y),G=Hi().flipY().sub(O).div(k),K=G.x.greaterThanEqual(0).and(G.x.lessThanEqual(1)).and(G.y.greaterThanEqual(0)).and(G.y.lessThanEqual(1)),q=qt(G,0,1),Y=Ju(mt(T,q)),ue=Y.a.mul(K.select(L(1),L(0)));w=Ae(lt(w.rgb,Y.rgb,ue),qt(w.a.add(ue),0,1))}let M=new XTe(e,w);return{syncValues:c,render(){n.scene=t.scene,n.camera=t.camera,M.render()},renderTAAResolve:l?E=>{n.scene=t.scene,n.camera=t.camera,l.renderResolve(E)}:null,renderBloomPasses:x?E=>{n.scene=t.scene,n.camera=t.camera,x.renderBloom(E)}:null,renderDoFPasses:b?E=>{n.scene=t.scene,n.camera=t.camera,b.renderDoF(E)}:null,resize(){},sceneDepthTexture:()=>n.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),b?.dispose(),n.dispose(),M.dispose()}}}(this)}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,n=t.width,s=this.viewportWidth/this.viewportHeight;n<r?n=r*s:r=n/s,this.dummyCamera.setViewplaneSize(n,r);for(let a=0;a<i;a++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(lq()?.drainRetired()??0)+(uq()?.drainRetired()??0)>0&&this._retireBundleRecords(),u$&&function(v){if(v==null||v===p$)return;let y=v;typeof y.addEventListener=="function"&&(p$=v,y.addEventListener("uncapturederror",_=>{let b=_?.error?.message??"";!b.toLowerCase().includes("destroyed")||d$<=0||(d$--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${L4()} (t=${Math.round(performance.now())}ms):
|
|
6259
|
+
`)}),Gx.length>dMe&&Gx.shift()}var u$,dMe,Gx,d$,L4,c$,p$,GUe=F(()=>{u$=(()=>{try{return new URLSearchParams(window.location.search).get("dbgdestroys")==="1"}catch{return!1}})(),dMe=32,Gx=[],d$=6,L4=()=>-1,c$=!1,p$=null}),jUe=F(()=>{});function zme(e,t,i,r=sZ){if(t===void 0||!(i>0))return!1;let{image:n,width:s,height:a}=t;if(n==null||s===void 0||a===void 0||s<=i&&a<=i||!function(d){return!(d.isRenderTargetTexture||d.isDepthTexture||d.isFramebufferTexture||d.isStorageTexture||d.isExternalTexture||d.isHTMLTexture||d.isDataTexture||d.isCompressedTexture||d.isCompressedArrayTexture||d.isCubeTexture||d.isArrayTexture||d.isDataArrayTexture||d.isData3DTexture||d.is3DTexture||d.mipmaps!==void 0&&d.mipmaps.length>0)}(e))return!1;let o=i/Math.max(s,a),l=Math.max(1,Math.min(i,Math.floor(s*o))),h=Math.max(1,Math.min(i,Math.floor(a*o))),u=null;try{u=r(n,l,h)}catch{u=null}return u!==null&&(t.image=u,t.width=l,t.height=h,t.needsMipmaps===!0&&(t.levels=Math.floor(Math.log2(Math.max(l,h)))+1),!0)}var sZ,WUe=F(()=>{sZ=(e,t,i)=>{let r;if(typeof OffscreenCanvas<"u")r=new OffscreenCanvas(t,i);else{if(!(typeof document<"u"))return null;r=document.createElement("canvas"),r.width=t,r.height=i}let n=r.getContext("2d");return n?(n.imageSmoothingEnabled=!0,n.imageSmoothingQuality="high",n.drawImage(e,0,0,t,i),r):null}});function f$(e,t){let i=new Fi(e,t,{depthBuffer:!1,type:Gt,format:ws});return i.texture.generateMipmaps=!1,i.texture.minFilter=gt,i.texture.magFilter=gt,i}function m$(){return Ay===null&&((Ay=f$(Pf*B4,Pf)).texture.name="SplinePCSSPyramidAtlas"),Ay.texture}function kme(e,t,i,r,n,s){let a=new Jt,o=mt(t),l=He(()=>{let h=Zo,u=s!==0?fE(h.x).sub(s):fE(h.x),d=Pe(u).mul(i).toVar(),c=Pe(h.y).mul(i).toVar(),p=L(1e9).toVar(),f=L(-1e9).toVar();return Yr(v$("ly",i),v$("lx",i),m=>{let{lx:g,ly:v}=m,y=g$(y$(d.add(g),Pe(0),Pe(r))),_=g$(y$(c.add(v),Pe(0),Pe(r))),b=o.load(Va(y,_));p.assign(Li(p,fE(b.x))),f.assign(pt(f,fE(n?b.y:b.x)))}),Ae(p,f,0,1)})();return a.fragmentNode=l,a.name=e,a.lights=!1,a.blending=yi,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,a}function Vme(e){let t=e;if(!t.__spePcssPyramid){t.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null};for(let i of jx)i.deref()===void 0&&jx.delete(i);jx.add(new WeakRef(t.__spePcssPyramid))}return t.__spePcssPyramid}function Gme(e){return e.__spePcssPyramid?.fresh===!0}function HUe(e){return e.__spePcssPyramid?.slot??-1}var Pf,B4,Yb,fE,g$,v$,y$,Ay,jx,UO,zO,_$,cMe=F(()=>{ne(),mn(),gi(),ua(),Pf=8,B4=8,Yb=64,fE=e=>e,g$=e=>e,v$=(e,t)=>({start:Pe(0),end:Pe(t),type:"int",condition:"<",name:e}),y$=qt,Ay=null,jx=new Set,UO=new Array(B4).fill(null),zO=!1,_$=new P});function Wx(e){let t=e;return t.__spePcssKnobs||(t.__spePcssKnobs={mapSize:Be(2048),radius:Be(1),penumbraSize:Be(.5),depthEps:Be(1e-4),penumbraFrameScale:Be(1),penumbraFrameOffset:Be(0),pyramidEnabled:Be(0),pyramidSlot:Be(0),maskChannel:Be(new ut(0,0,0,0)),planeNormalMat:Be(new si().set(0,0,0,0,0,0,0,0,0))}),t.__spePcssKnobs}function pMe(e,t){Wx(e).maskChannel.value.set(t===0?1:0,t===1?1:0,t===2?1:0,t===3?1:0)}function jme(e,t,i){let r=e,n=Wx(e);n.mapSize.value=r.mapSize?.x??2048,n.radius.value=r.radius??1,n.penumbraSize.value=t??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?n.planeNormalMat.value.getNormalMatrix(r.matrix):n.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let s=typeof r.camera?.far=="number"&&typeof r.camera?.near=="number"?r.camera.far-r.camera.near:0;n.depthEps.value=s>.001?yMe/s:1e-4;let a=e.__speRangeEnvelope,o=a?a.far-a.near:0;a&&o>.001&&s>.001&&r.camera?(n.penumbraFrameScale.value=s/o,n.penumbraFrameOffset.value=(r.camera.near-a.near)/o):(n.penumbraFrameScale.value=1,n.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&F4()){let h=n.mapSize.value;aZ/1024+(2*n.radius.value+2)/Math.max(1,h)<=1/Pf&&(l=1)}return n.pyramidEnabled.value=_Me??l,n.pyramidSlot.value=Math.max(0,i?.slot??0),n.pyramidEnabled.value===1}function fMe(e,t){let i=Kb(e.planeNormalMat.mul(t)).toVar(),r=Ti(i.z),n=Ti(Vc(r).add(ar(oi(r),L(0))).mul(pt(oi(r),L(1e-4))));return Ln(Se(Ti(i.x).negate().div(n),Ti(i.y).div(n))).toVar()}function b$(e,t,i,r,n,s,a){let o=gMe(),l=vMe(),h=x$(),u=Wx(t),d=Ti(u.mapSize),c=Ln(Se(d,d)),p=Ti(u.radius),f=Ti(u.penumbraSize),m=mt(e),g=w=>Ti(m.load(Va(qt(w,Se(0),Se(1)).mul(c))).x),v=L(1).div(c.x).toVar(),y=L(aZ).div(v.mul(1024)).toVar(),_=Ti(u.depthEps),b=fMe(u,a),x=()=>{let w=L(0).toVar(),S=L(0).toVar();for(let E=0;E<l;E++){let A=Ln(t0(Pe(E),Pe(l),n)).mul(v).mul(y),C=g(Ln(i.add(A))).toVar();ze(C.lessThan(r.add(U4(b,A)).add(_)),()=>{w.addAssign(C),S.addAssign(1)})}let T=L(0).toVar();ze(S.greaterThan(0),()=>{let E=w.div(S).toVar(),A=Ti(u.penumbraFrameScale),C=Ti(u.penumbraFrameOffset),D=r.sub(E).mul(A).div(E.mul(A).add(C)).toVar();T.assign(qt(D.mul(D).mul(200).mul(f),L(0),L(1)))});let M=L(0).toVar();for(let E=0;E<o;E++){let A=Ln(t0(Pe(E),Pe(o),n)).mul(v),C=Ln(A.mul(p.mul(2)).add(A.mul(T.mul(y)))),D=Ti(r.add(U4(b,C)));h?M.addAssign(Ti(mt(e,Ln(i.add(C))).compare(D))):M.addAssign(ar(D,g(Ln(i.add(C)))))}s.assign(M.div(o))};if(F4()){let w=mt(m$()),S=Ti(u.pyramidEnabled),T=Ti(u.pyramidSlot),M=L(Pf),E=L(0).toVar();ze(S.greaterThan(.5),()=>{let A=Ln(qt(i,Se(0),Se(1))),C=Ti(A.x.mul(M)).toVar(),D=Ti(A.y.mul(M)).toVar(),R=T.mul(M),I=L(1e9).toVar(),U=L(-1e9).toVar();for(let G=-1;G<=1;G++)for(let K=-1;K<=1;K++){let q=qt(C.add(L(K)),L(0),M.sub(1)),Y=qt(D.add(L(G)),L(0),M.sub(1)),ue=Ln(Se(q.add(R),Y)),de=w.load(Va(ue));I.assign(Li(I,Ti(de.x))),U.assign(pt(U,Ti(de.y)))}let O=Ti(v.mul(p.mul(2).add(y))),k=Ti(Li($i(b).mul(O),L(.05))).toVar();ze(I.greaterThanEqual(r.add(_).add(k)),()=>{E.assign(1)}).ElseIf(U.lessThan(r.sub(k)),()=>{E.assign(2)})}),ze(E.equal(1),()=>{s.assign(1)}).ElseIf(E.equal(2),()=>{s.assign(0)}).Else(x)}else x()}function qUe(e,t){let i=t;return i.isPointLight?(Si.pcssHookServes++,k4):i.isSpotLight||i.isDirectionalLight?(Si.pcssHookServes++,z4):null}function Wme(e){oZ.value=e?1:0}function Hme(e,t){return i=>{let r=function(a){let o=a,l={};if(o==null)return l;for(let h of bMe){let u=o[h];u!==void 0&&(l[h]=u)}return l}(i),n=Ti(T$(e,r)),s=Ti(T$(t,r));return He(()=>{let a=L(1).toVar();return ze(Ti(oZ).greaterThan(.5),()=>{a.assign(n)}).Else(()=>{a.assign(s)}),a})()}}var Ti,Ln,Kb,aN,oN,lN,hN,mE,x$,F4,Rj,w$,S$,mMe,aZ,af,gMe,vMe,yMe,_Me,U4,qme,$me,Xme,oZ,T$,bMe,z4,k4,uN,Yme,Kme,xMe,wMe,SMe,TMe,MMe=F(()=>{gi(),ne(),ua(),cMe(),Ti=e=>e,Ln=e=>e,Kb=e=>e,aN=!0,oN=!0,lN=!0,hN=!0;try{let e=new URLSearchParams(window.location.search),t=e.get("dbgpcss");t==="classic"||t==="0"?(aN=!1,oN=!1,lN=!1,hN=!1):(aN=e.get("dbgpcsssplit")!=="0",oN=e.get("dbgpcsshw")!=="0",lN=e.get("dbgpcsshiz")!=="0",hN=e.get("dbgshadowmask")!=="0")}catch{}mE=!1,x$=()=>oN&&mE,F4=()=>lN&&mE,Rj=()=>hN&&mE,w$=()=>F4(),S$=()=>Rj(),mMe=[[0,-.333334],[-.5,.333334],[.5,-.777778],[-.75,-.111112],[.25,.555556],[-.25,-.555556],[.75,.111112],[-.875,.777778],[.125,-.925926],[-.375,-.25926],[.625,.407408],[-.625,-.703704],[.375,-.037038],[-.125,.62963],[.875,-.481482],[-.9375,.185186]],aZ=80,af=16,gMe=()=>x$()?Math.max(4,af>>1):af,vMe=()=>aN?Math.max(4,af>>1):af,yMe=1.25,_Me=null,U4=(e,t)=>Ti(qt(Je(e,t),L(-.05),L(.05))),qme=He(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,n=Wx(r),s=Ln(i.xy).toVar(),a=Ti(i.z).toVar(),o=Kb(KA).toVar(),l=Ln(tt.pcssHalton),h=Ti($f(Zo.xy.add(l))).mul(6.28318530718).toVar(),u=L(1).toVar();if(Rj()){let d=n.maskChannel,c=Ti(tt.shadowMaskEnabled),p=tt.shadowMaskGBuffer,f=tt.shadowMaskTexture,m=L(0).toVar(),g=L(1).toVar();ze(c.greaterThan(.5).and(Ti(Je(d,Ae(1,1,1,1))).greaterThan(.5)),()=>{let v=Ln(gu),y=Ln(tt.shadowMaskResolution),_=Ln(tt.shadowMaskFullResolution),b=Ti(Zf.z),x=Ln(v.mul(y).sub(Se(.5,.5))).toVar(),w=Ln(At(x)).toVar(),S=Ln(x.sub(w)).toVar(),T=Ti(pt(oi(b).mul(.02),L(.05))),M=L(0).toVar(),E=L(0).toVar();for(let A=0;A<=1;A++)for(let C=0;C<=1;C++){let D=Ln(qt(w.add(Se(C,A)),Se(0,0),y.sub(Se(1,1)))),R=Ln(D.add(Se(.5,.5)).div(y)),I=Ln(At(R.mul(_)).add(Se(.5,.5)).div(_)),U=Ti(p.sample(I).w),O=Ti(Je(f.sample(R),d)),k=Ti(C===0?L(1).sub(S.x):Ti(S.x)),G=Ti(A===0?L(1).sub(S.y):Ti(S.y)),K=Ti(ar(oi(U.sub(b)),T)),q=Ti(k.mul(G).mul(K)).toVar();M.addAssign(q),E.addAssign(O.mul(q))}ze(M.greaterThan(.001),()=>{m.assign(1),g.assign(E.div(M))})}),ze(m.greaterThan(.5),()=>{u.assign(g)}).Else(()=>{b$(t,r,s,a,h,u,o)})}else b$(t,r,s,a,h,u,o);return u}),$me=He(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,n=Wx(r),s=Ln(i.xy).toVar(),a=Ti(i.z).toVar(),o=fMe(n,Kb(KA).toVar()),l=Ti(n.mapSize),h=Ti(n.radius),u=Ti(h.mul(L(1).div(l))).toVar(),d=Ti($f(Zo.xy)).mul(6.28318530718).toVar(),c=L(0).toVar();for(let p=0;p<5;p++){let f=Ln(t0(Pe(p),Pe(5),d)).mul(u).toVar();c.addAssign(Ti(mt(t,Ln(s.add(f))).compare(a.add(U4(o,f)))))}return c.mul(.2)}),Xme=He(e=>{let{depthTexture:t,bd3D:i,dp:r,shadow:n}=e,s=af,a=Wx(n),o=Ti(a.mapSize),l=Ti(a.radius),h=L(1).div(o).toVar(),u=Ln(tt.pcssHalton),d=Ti($f(Zo.xy.add(u))).mul(6.28318530718).toVar(),c=Ti(l.add(5)).toVar(),p=L(0).toVar();for(let f=0;f<s;f++){let m=Ln(t0(Pe(f),Pe(s),d)).mul(h).toVar(),g=Kb(Q(m.x,m.y,Ti(m.x).negate()).mul(c)),v=Kb(i.add(g));p.addAssign(Ti(o2e(t,v).compare(r)))}return p.div(s)}),oZ=Be(1),T$=(e,t)=>e(t),bMe=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],z4=Hme(qme,$me),k4=Hme(Xme,ZTe)}),$Ue=F(()=>{ne(),mn(),gi(),ua(),MMe(),uN=new Cn,Yme=new at,Kme=new Z,xMe=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=Be(new De),this._projInv=Be(new De),this._lightRows=[];let e=new Jt;e.name="SplineShadowMask.gbuffer",e.fragmentNode=Ae(To,Zf.z),e.lights=!1,e.blending=yi,e.needsUpdate=!0,this._gBufferMaterial=e}_ensureTarget(e,t,i,r){return e&&e.width===t&&e.height===i?{target:e,changed:!1}:(e?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(e){let t=new Jt;t.name="SplineShadowMask.resolve";let i=mt(this._gBuffer.depthTexture),r=mt(this._gBuffer.texture),n=this._cameraWorld,s=this._projInv,a=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=e.map(()=>({matrix:Be(new De),bias:Be(0),normalBias:Be(0)}));let l=this._lightRows,h=He(()=>{let u=Hi(),d=At(u.mul(Se(a,o))).add(Se(.5,.5)).div(Se(a,o)).toVar(),c=i.sample(d),p=HK(d,c,s).toVar(),f=r.sample(d).toVar(),m=n,g=m.mul(Ae(p,1)).xyz.toVar(),v=Ft(m.mul(Ae(f.xyz,0)).xyz).toVar(),y=tt.pcssHalton,_=$f(Zo.xy.add(y)).mul(6.28318530718).toVar(),b=[L(1).toVar(),L(1).toVar(),L(1).toVar(),L(1).toVar()];return e.forEach((x,w)=>{let S=l[w],T=g.add(v.mul(S.normalBias)),M=S.matrix.mul(Ae(T,1)).toVar(),E=M.xyz.div(M.w),A=Q(E.x,L(1).sub(E.y),E.z).toVar(),C=A.z.add(S.bias).toVar(),D=A.x.greaterThanEqual(0).and(A.x.lessThanEqual(1)).and(A.y.greaterThanEqual(0)).and(A.y.lessThanEqual(1)).and(C.lessThanEqual(1));ze(D,()=>{b$(x.shadow.map.depthTexture,x.shadow,A.xy,C,_,b[w],v)})}),Ae(b[0],b[1],b[2],b[3])})();return t.fragmentNode=h,t.lights=!1,t.blending=yi,t.depthTest=!1,t.depthWrite=!1,t.needsUpdate=!0,t}render(e,t,i,r,n){let s=n??e.getDrawingBufferSize(Kme),a=Math.max(1,Math.round(s.x)),o=Math.max(1,Math.round(s.y)),l=Math.max(1,Math.round(a/2)),h=Math.max(1,Math.round(o/2)),u=!1,d=this._ensureTarget(this._gBuffer,a,o,()=>{let M=new Fi(a,o,{type:li,depthTexture:new ns(a,o),minFilter:it,magFilter:it});return M.texture.name="SplineShadowMask.gbuffer",M});this._gBuffer=d.target,u=u||d.changed;let c=this._ensureTarget(this._maskTarget,l,h,()=>{let M=new Fi(l,h,{depthBuffer:!1,minFilter:it,magFilter:it});return M.texture.name="SplineShadowMask.mask",M});this._maskTarget=c.target,u=u||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(M=>M.shadow.map?.depthTexture?.uuid??"none").join(",")}`;(this._resolveMaterial===null||this._resolveKey!==p)&&(this._resolveMaterial?.dispose(),this._resolveMaterial=this._buildResolveMaterial(r),this._resolveKey=p),this._cameraWorld.value.copy(i.matrixWorld),this._projInv.value.copy(i.projectionMatrix).invert(),r.forEach((M,E)=>{M.shadow.updateMatrices?.(M.light);let A=this._lightRows[E];M.shadow.matrix&&A.matrix.value.copy(M.shadow.matrix),A.bias.value=M.shadow.bias??0,A.normalBias.value=M.shadow.normalBias??0});let f=t,m=f.isScene===!0,g=[],v=[];f.traverse(M=>{let E=M;if(E.isMesh===!0&&E.visible!==!1){if((Array.isArray(E.material)?E.material:[E.material]).some(A=>A?.transparent===!0))g.push(E),E.visible=!1;else if(!m){let A=E;v.push({obj:A,material:A.material}),A.material=this._gBufferMaterial}}});let y=f.overrideMaterial,_=e.getRenderTarget(),b=e.getMRT(),x=e.getClearColor(Yme),w=e.getClearAlpha(),S=i.layers,T=S.mask;S.disable(3),f.overrideMaterial=this._gBufferMaterial,e.setMRT(null),e.setClearColor(0,0),e.setRenderTarget(this._gBuffer),e.render(t,i),f.overrideMaterial=y,S.mask=T;for(let M of g)M.visible=!0;for(let M of v)M.obj.material=M.material;return uN.material=this._resolveMaterial,uN.name="SplineShadowMask.resolve",e.setRenderTarget(this._maskTarget),uN.render(e),e.setRenderTarget(_),e.setMRT(b),e.setClearColor(x,w),tt.shadowMaskTexture.value=this._maskTarget.texture,tt.shadowMaskGBuffer.value=this._gBuffer.texture,tt.shadowMaskResolution.value.set(l,h),tt.shadowMaskFullResolution.value.set(a,o),r.forEach((M,E)=>{pMe(M.shadow,E)}),Si.shadowMaskResolves++,{targetsChanged:u}}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._maskTarget?.dispose(),this._maskTarget=null,this._gBufferMaterial.dispose(),this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._resolveKey=""}}}),XUe=F(()=>{ne(),wMe=1,SMe={src:Kg,dst:Eg,srcAlpha:Eg,dstAlpha:Eg},TMe={src:bA,dst:xA,srcAlpha:Eg,dstAlpha:Kg}});function Zme(e){let t=e;return t.isSkinnedMesh===!0&&t.bindMatrixInverse?t.bindMatrixInverse:null}function Qme(e){let t=new YA(Mg);return t.blendSrc=e.src,t.blendDst=e.dst,t.blendSrcAlpha=e.srcAlpha,t.blendDstAlpha=e.dstAlpha,t}var dN,Jme,V4,EMe,ege,tge,ige,AMe,CMe=F(()=>{ne(),gi(),mn(),XUe(),dN=new WeakMap,Jme=new De,V4=M2e(class extends $Te{update(e){super.update(e);let{frameId:t,object:i}=e,r=Zme(i),n=dN.get(i);n===void 0?(n={frameId:t,prev:i.matrixWorld.clone(),last:i.matrixWorld.clone(),prevBind:r?.clone()??null,lastBind:r?.clone()??null},dN.set(i,n)):n.frameId!==t&&(n.frameId=t,n.prev.copy(n.last),n.prevBind&&n.lastBind&&n.prevBind.copy(n.lastBind));let s=this.previousModelWorldMatrix.value.copy(n.prev);r!==null&&(n.prevBind===null&&(n.prevBind=r.clone(),n.lastBind=r.clone()),s.multiply(n.prevBind).multiply(Jme.copy(r).invert()))}updateAfter(e){let{object:t}=e,i=dN.get(t);if(i===void 0)return;i.last.copy(t.matrixWorld);let r=Zme(t);r!==null&&i.lastBind?.copy(r)}}),EMe=Ae(V4,0,wMe),ege=Qme(SMe),tge=new YA(yi),ige=Qme(TMe),AMe=new class extends YA{resolveForMaterial(e){return e.depthWrite?ege:function(t){return!t.depthWrite&&t.blending!==yi&&(t.blending!==Xs||t.transparent)}(e)?ige:tge}}(yi)});function G4(e,t){let i=0,r=1,n=e;for(;n>0;)r/=t,i+=r*(n%t),n=Math.floor(n/t);return i}function Dj(e){return Q(e.x.div(4).add(e.y.div(2)).add(e.z.div(4)),e.x.div(2).sub(e.z.div(2)),e.x.div(-4).add(e.y.div(2)).sub(e.z.div(4)))}function rge(e,t=!0){let i=Q(e.x.add(e.y).sub(e.z),e.x.add(e.z),e.x.sub(e.y).sub(e.z));return t?qt(i,Q(0),Q(1)):pt(i,Q(0))}function PMe(){let e=!1;try{let c=new URLSearchParams(window.location.search).get("dbgfp16");e=c==="1"||c==="hist"||c==="st"}catch{}let t=!1,i=()=>e||t,r=(c,p,f)=>{let m=new Fi(c,p,{minFilter:it,magFilter:it,depthBuffer:!1});return i()?m.texture.type=li:aF()&&(m.texture.internalFormat="rgba8unorm-srgb"),m.texture.name=f,m},n=r(1,1,"SplineTAA.A"),s=r(1,1,"SplineTAA.B"),a=null,o=!1,l=0,h=0,u=0,d=0;return{rtA:n,rtB:s,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new De,jitterOffsetUV:new Z(0,0),beginJitter(c,p,f){if(o)return;let m,g;if(o=!0,(a===null||a.cam!==c)&&(a?.clearViewOffset(),a=new RMe(c)),this.unjitteredProjection.copy(c.projectionMatrix),tt.unjitteredProjection.value.copy(c.projectionMatrix),fx==="r2"){let v=++this.jitterIndex;m=(.5+DMe*v)%1,g=(.5+NMe*v)%1}else if(fx==="white")this.jitterIndex++,m=Math.random(),g=Math.random();else if(fx==="h64")m=G4(this.jitterIndex%64+1,2),g=G4(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if(fx==="half"){let[v,y]=gE[this.jitterIndex];m=.5+.5*(v-.5),g=.5+.5*(y-.5),this.jitterIndex=(this.jitterIndex+1)%gE.length}else[m,g]=gE[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%gE.length;l=p,h=f,u=m-.5,d=g-.5,tt.cameraJitterPx.value.set(2*u,2*d),a.setViewOffset(p,f,u,d),this.jitterOffsetUV.set(-(m-.5)/p,-(g-.5)/f),Si.taaJitterIndex=this.jitterIndex,Si.taaJitterApplies++},suspendJitter(){o&&a?.clearViewOffset()},resumeJitter(){o&&a!==null&&a.setViewOffset(l,h,u,d)},endJitter(){o=!1,this.jitterOffsetUV.set(0,0),a?.clearViewOffset()},resize(c,p){this.rtA.dispose(),this.rtB.dispose(),this.rtA=r(c,p,"SplineTAA.A"),this.rtB=r(c,p,"SplineTAA.B"),this.valid=!1},setHdr(c){if(t===c)return;let p=i();t=c,i()!==p&&this.resize(this.rtA.width,this.rtA.height)},dispose(){this.rtA.dispose(),this.rtB.dispose(),this.valid=!1,o=!1,a?.clearViewOffset(),a=null}}}var nge,sge,cN,RMe,gE,fx,DMe,NMe,IMe,OMe,xv,age,Nj,oge,LMe,pN,Ij,BMe,FMe=F(()=>{ne(),CMe(),ua(),mn(),gi(),nge=e=>e,sge=e=>e,cN=new Cn,RMe=class{constructor(e){this.cam=e,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(e,t,i,r){this.clearViewOffset();let n=this.cam.projectionMatrix.elements,s=-2*i/e,a=2*r/t;this._savedSkewX=n[8],this._savedSkewY=n[9],this._savedShiftX=n[12],this._savedShiftY=n[13],n[8]+=s*n[11],n[9]+=a*n[11],n[12]+=s*n[15],n[13]+=a*n[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let e=this.cam.projectionMatrix.elements;e[8]=this._savedSkewX,e[9]=this._savedSkewY,e[12]=this._savedShiftX,e[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},gE=Array.from({length:16},(e,t)=>[G4(t+1,2),G4(t+1,3)]),fx="h16";try{let e=new URLSearchParams(window.location.search).get("dbgjitseq");(e==="r2"||e==="h64"||e==="white"||e==="half")&&(fx=e)}catch{}DMe=.7548776662466927,NMe=.5698402909980532,IMe=class extends En{constructor(e,t,i,r,n=!1){super("vec4"),this._resolution=Be(new Z(1,1)),this._historyValid=Be(0),this._jitterUV=Be(new Z(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=e,this.depthNode=t,this.velocityNode=i,this._hdr=n,this._history=r??PMe(),this._ownsHistory=r===void 0,this._outputTexNode=mt(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(e){V4.setProjectionMatrix(this._history.unjitteredProjection);let t=this.beautyNode.passNode.renderTarget,i=t.texture.width,r=t.texture.height,n=this._history;(n.rtA.width!==i||n.rtA.height!==r)&&(n.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=n.valid?1:0,this._jitterUV.value.copy(n.jitterOffsetUV);let s=n.flip?n.rtB:n.rtA,a=this._resolveMaterials?this._resolveMaterials[n.flip?1:0]:null,o=e.getRenderTarget(),l=e.getMRT();e.setMRT(null),n.valid||(e.setRenderTarget(n.rtA),e.clear(!0,!1,!1),e.setRenderTarget(n.rtB),e.clear(!0,!1,!1)),e.setRenderTarget(s),a&&(cN.material=a,cN.name="SplineTAA.resolve",cN.render(e)),e.setRenderTarget(o),e.setMRT(l),this._outputTexNode.value=s.texture,n.valid=!0,n.flip=!n.flip,Si.taaResolves++,Si.taaJitterIndex=n.jitterIndex,Si.taaHistoryValid=!0,Si.taaResolveSize=`${i}x${r}`}setup(e){let t=e.renderer.reversedDepthBuffer===!0,i=e.renderer.backend?.isWebGLBackend===!0,r=!1,n=!1,s=!1,a=!1,o=!1,l=!1,h=!1,u=!1,d=!1,c=!1;try{let x=new URLSearchParams(window.location.search).get("dbgtaa");r=x==="1",n=x==="zv",s=x==="nc",a=x==="err",o=x==="hist",l=x==="red",h=x==="ns",u=x==="fb90",d=new URLSearchParams(window.location.search).get("dbgjit")==="mark",c=x==="hold"}catch{}let p=this.beautyNode,f=this.velocityNode,m=this.depthNode,g=this._resolution,v=this._historyValid,y=this._jitterUV,_=x=>{let w=p.sample(x);return Ae(Dj(w.rgb),w.a)},b=x=>{let w=He(()=>{let T=Hi().toVar();if(d)return Ae(y.x.mul(400).add(.5),y.y.mul(400).add(.5),L(.5),L(1));let M=T,E=Se(L(1).div(g.x),L(1).div(g.y)).toVar(),A=[[-1,1],[0,1],[1,1],[-1,0],[0,0],[1,0],[-1,-1],[0,-1],[1,-1]].map(([xt,Dt])=>T.add(Se(E.x.mul(xt),E.y.mul(Dt))).toVar()),C=A,D=L(t?-1e3:1e3).toVar(),R=Se(A[4]).toVar();for(let xt=0;xt<9;xt++){let Dt=nge(m.load(Va(A[xt].mul(sge(g)))).r).toVar(),Kt=t?Dt.greaterThan(D):Dt.lessThan(D);D.assign(Kt.select(Dt,D)),R.assign(Kt.select(A[xt],R))}let I=f.load(Va(R.mul(g))).xy.mul(Se(.5,-.5)).toVar();n&&I.assign(Se(0,0));let U=T.sub(I).toVar(),O=i?Se(U.x,L(1).sub(U.y)).toVar():U,k=_(M).toVar();if(r)return Ae(I.x.mul(20).add(.5),I.y.mul(20).add(.5),v,L(1));if(l){let xt=new Nr(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return xt.needsUpdate=!0,mt(xt).sample(T)}if(o){let xt=i?Se(T.x,L(1).sub(T.y)):T;return x.sample(xt)}if(a){let xt=i?Se(T.x,L(1).sub(T.y)):T,Dt=x.sample(O),Kt=x.sample(xt),Mi=k.x,_i=ci=>Dj(ci.rgb).x;return Ae(_i(Dt).sub(Mi).abs().mul(8),_i(Kt).sub(Mi).abs().mul(8),L(0),L(1))}let G=O.mul(g).toVar(),K=At(G.sub(.5)).add(.5).toVar(),q=G.sub(K).toVar(),Y=q.mul(q.mul(q.mul(-.5).add(1)).add(-.5)).toVar(),ue=q.mul(q).mul(q.mul(1.5).add(-2.5)).add(1).toVar(),de=q.mul(q.mul(q.mul(-1.5).add(2)).add(.5)).toVar(),ge=q.mul(q).mul(q.mul(.5).add(-.5)).toVar(),be=ue.add(de).toVar(),re=de.div(be).toVar(),xe=K.sub(1).div(g).toVar(),j=K.add(2).div(g).toVar(),z=K.add(re).div(g).toVar(),X=Ae(0).toVar();X.addAssign(x.sample(Se(z.x,xe.y)).mul(be.x.mul(Y.y))),X.addAssign(x.sample(Se(xe.x,z.y)).mul(Y.x.mul(be.y))),X.addAssign(x.sample(Se(z.x,z.y)).mul(be.x.mul(be.y))),X.addAssign(x.sample(Se(j.x,z.y)).mul(ge.x.mul(be.y))),X.addAssign(x.sample(Se(z.x,j.y)).mul(be.x.mul(ge.y)));let te=Ae(Dj(X.rgb),X.a).toVar();if(c)return Ae(rge(te.rgb).mul(Q(1,.55,.55)),X.a);let V=_(C[0]).toVar(),ae=_(C[1]).toVar(),se=_(C[2]).toVar(),W=_(C[3]).toVar(),pe=_(C[4]).toVar(),_e=_(C[5]).toVar(),Ue=_(C[6]).toVar(),we=_(C[7]).toVar(),Ye=_(C[8]).toVar(),Fe=Ae(Li(V,Li(ae,Li(se,Li(W,Li(pe,Li(_e,Li(Ue,Li(we,Ye))))))))).toVar(),We=Ae(pt(V,pt(ae,pt(se,pt(W,pt(pe,pt(_e,pt(Ue,pt(we,Ye))))))))).toVar(),Re=Ae(Li(ae,Li(W,Li(pe,Li(_e,we))))).toVar(),ee=Ae(pt(ae,pt(W,pt(pe,pt(_e,we))))).toVar();Fe.assign(Fe.add(Re).mul(.5)),We.assign(We.add(ee).mul(.5));let Ee=We.r.sub(Fe.r).mul(.25).mul(.5).toVar(),je=k.gb.toVar();h||(Fe.y.assign(je.x.sub(Ee)),Fe.z.assign(je.y.sub(Ee)),We.y.assign(je.x.add(Ee)),We.z.assign(je.y.add(Ee)));let dt=Ae(s?te:qt(te,Fe,We)).toVar(),et=u||s?L(.9):L(.9).mul(v),$t=Ae(lt(k,dt,et)).toVar(),ii=tt.tapAngle,nr=KK(T.mul(g).add(Se(ii.mul(127.1),ii.mul(311.7)))).sub(.5).mul(1/255);return Ae(rge($t.rgb,!this._hdr).add(Q(nr)),$t.a)}),S=new Jt;return S.name="SplineTAA.resolve",S.colorNode=w(),S.depthTest=!1,S.depthWrite=!1,S.blending=yi,S.needsUpdate=!0,S};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[b(mt(this._history.rtB.texture)),b(mt(this._history.rtA.texture))]},this._rebuildResolveMaterials(),this._outputTexNode}dispose(){this._ownsHistory&&this._history.dispose(),this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose(),this._resolveMaterials=null),V4.setProjectionMatrix(null)}}}),YUe=F(()=>{OMe=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(e,t){this._frames=e>0&&!t?this._frames+1:0}}}),KUe=F(()=>{}),ZUe=F(()=>{KB(),mn(),gi(),xv=new Cn,age=new Z,oge=class extends En{static get type(){return"SMAANode"}constructor(e){super("vec4"),this.textureNode=e,this.updateBeforeType=KTe.FRAME,this._renderTargetEdges=new Fi(1,1,{depthBuffer:!1,type:li}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new Fi(1,1,{depthBuffer:!1,type:li}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new Fi(1,1,{depthBuffer:!1,type:li}),this._renderTargetBlend.texture.name="SMAANode.blend";let t=this,i=new Image;i.crossOrigin="anonymous",E4(i,"smaa-node-area.png"),i.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Ci,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=it,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",E4(r,"smaa-node-search.png"),r.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Ci,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=gt,this._searchTexture.minFilter=gt,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=Be(new Z),this._areaTextureUniform=mt(this._areaTexture),this._searchTextureUniform=mt(this._searchTexture),this._edgesTextureUniform=mt(this._renderTargetEdges.texture),this._weightsTextureUniform=mt(this._renderTargetWeights.texture),this._materialEdges=new Jt,this._materialEdges.name="SMAANode.edges",this._materialWeights=new Jt,this._materialWeights.name="SMAANode.weights",this._materialBlend=new Jt,this._materialBlend.name="SMAANode.blend",this._textureNode=N2e(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),this._renderTargetEdges.setSize(e,t),this._renderTargetWeights.setSize(e,t),this._renderTargetBlend.setSize(e,t)}updateBefore(e){let{renderer:t}=e;Nj=kq.resetRendererState(t,Nj);let i=t.getDrawingBufferSize(age);this.setSize(i.width,i.height),t.setRenderTarget(this._renderTargetEdges),xv.material=this._materialEdges,xv.render(t),t.setRenderTarget(this._renderTargetWeights),xv.material=this._materialWeights,xv.render(t),t.setRenderTarget(this._renderTargetBlend),xv.material=this._materialBlend,xv.render(t),kq.restoreRendererState(t,Nj)}setup(e){let t=Se(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||Hi(),n=He(()=>{let g=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-1,0,0,-1))),v=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(1,0,0,1))),y=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-2,0,0,-2)));return Bn("vec4","vOffset0").assign(g),Bn("vec4","vOffset1").assign(v),Bn("vec4","vOffset2").assign(y),OO}),s=He(()=>{let g=Bn("vec4","vOffset0"),v=Bn("vec4","vOffset1"),y=Bn("vec4","vOffset2"),_=Se(.1,.1),b=Ae().toVar(),x=this.textureNode.sample(r).rgb.toVar(),w=this.textureNode.sample(g.xy).rgb.toVar(),S=oi(x.sub(w));b.x=pt(S.r,S.g,S.b);let T=this.textureNode.sample(g.zw).rgb.toVar();S=oi(x.sub(T)),b.y=pt(S.r,S.g,S.b);let M=ar(_,b.xy).toVar();Je(M,Se(1,1)).equal(0).discard();let E=this.textureNode.sample(v.xy).rgb.toVar();S=oi(x.sub(E)),b.z=pt(S.r,S.g,S.b);let A=this.textureNode.sample(v.zw).rgb.toVar();S=oi(x.sub(A)),b.w=pt(S.r,S.g,S.b);let C=pt(b.x,b.y,b.z,b.w).toVar(),D=this.textureNode.sample(y.xy).rgb.toVar();S=oi(x.sub(D)),b.z=pt(S.r,S.g,S.b);let R=this.textureNode.sample(y.zw).rgb.toVar();return S=oi(x.sub(R)),b.w=pt(S.r,S.g,S.b),C=pt(C,b.z,b.w),M.xy.mulAssign(Se(ar(L(.5).mul(C),b.xy))),Ae(M,0,0)}),a=He(([g,v,y,_])=>{let b=Se(v).toVar();return b.r=y.add(b.r.mul(_)),L(255).mul(g.sample(b)).r}),o=He(([g,v,y,_,b])=>{let x=L(16).mul(L(4).mul(Se(y,_)).round()).add(v);return x=t.mul(x).add(L(.5).mul(t)),x.y.addAssign(L(i).mul(b)),g.sample(x).rg}),l=He(([g,v,y,_])=>{let b=Se(0,1).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.subAssign(Se(2,0).mul(this._invSize)),ze(x.x.lessThanEqual(_).or(b.g.lessThanEqual(L(.8281)).or(b.r.notEqual(L(0)))),()=>{qa()})}),x.x.addAssign(L(.25).mul(this._invSize.x)),x.x.addAssign(this._invSize.x),x.x.addAssign(L(2).mul(this._invSize.x)),x.x.subAssign(this._invSize.x.mul(a(v,b,0,.5))),x.x}),h=He(([g,v,y,_])=>{let b=Se(0,1).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.addAssign(Se(2,0).mul(this._invSize)),ze(x.x.greaterThanEqual(_).or(b.g.lessThanEqual(L(.8281)).or(b.r.notEqual(L(0)))),()=>{qa()})}),x.x.subAssign(L(.25).mul(this._invSize.x)),x.x.subAssign(this._invSize.x),x.x.subAssign(L(2).mul(this._invSize.x)),x.x.addAssign(this._invSize.x.mul(a(v,b,.5,.5))),x.x}),u=He(([g,v,y,_])=>{let b=Se(1,0).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.addAssign(Se(0,-2).mul(this._invSize)),ze(x.y.lessThanEqual(_).or(b.r.lessThanEqual(L(.8281)).or(b.g.notEqual(L(0)))),()=>{qa()})}),x.y.addAssign(L(.25).mul(this._invSize.y)),x.y.addAssign(this._invSize.y),x.y.addAssign(L(2).mul(this._invSize.y)),x.y.subAssign(this._invSize.y.mul(a(v,b.gr,0,.5))),x.y}),d=He(([g,v,y,_])=>{let b=Se(1,0).toVar(),x=Se(y).toVar();return Yr({start:Pe(0),end:Pe(8),type:"int",condition:"<"},()=>{b.assign(g.sample(x).rg),x.subAssign(Se(0,-2).mul(this._invSize)),ze(x.y.greaterThanEqual(_).or(b.r.lessThanEqual(L(.8281)).or(b.g.notEqual(L(0)))),()=>{qa()})}),x.y.subAssign(L(.25).mul(this._invSize.y)),x.y.subAssign(this._invSize.y),x.y.subAssign(L(2).mul(this._invSize.y)),x.y.addAssign(this._invSize.y.mul(a(v,b.gr,.5,.5))),x.y}),c=He(()=>{let g=r.xy.div(this._invSize),v=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-.25,-.125,1.25,-.125))).toVar(),y=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(-.125,-.25,-.125,1.25))).toVar(),_=Ae(v.xz,y.yw).add(Ae(-2,2,-2,2).mul(Ae(this._invSize.xx,this._invSize.yy)).mul(L(8))).toVar();return Bn("vec2","vPixcoord").assign(g),Bn("vec4","vOffset0").assign(v),Bn("vec4","vOffset1").assign(y),Bn("vec4","vOffset2").assign(_),OO}),p=He(()=>{let g=Bn("vec2","vPixcoord"),v=Bn("vec4","vOffset0"),y=Bn("vec4","vOffset1"),_=Bn("vec4","vOffset2"),b=Ae(0,0,0,0).toVar(),x=Ae(0,0,0,0).toVar(),w=this._edgesTextureUniform.sample(r).rg.toVar();return ze(w.g.greaterThan(L(0)),()=>{let S=Se().toVar(),T=Se().toVar();T.x=l(this._edgesTextureUniform,this._searchTextureUniform,v.xy,_.x),T.y=y.y,S.x=T.x;let M=this._edgesTextureUniform.sample(T).r.toVar(),E=Se().toVar();E.x=h(this._edgesTextureUniform,this._searchTextureUniform,v.zw,_.y),E.y=y.y,S.y=E.x,S=S.div(this._invSize.x).sub(g.x);let A=Rh(oi(S)),C=this._edgesTextureUniform.sample(E.add(Se(1,0).mul(this._invSize))).r.toVar();b.r=C,b.rg=o(this._areaTextureUniform,A,M,C,L(x.y))}),ze(w.r.greaterThan(L(0)),()=>{let S=Se().toVar(),T=Se().toVar();T.y=u(this._edgesTextureUniform,this._searchTextureUniform,y.xy,_.z),T.x=v.x,S.x=T.y;let M=this._edgesTextureUniform.sample(T).g.toVar(),E=Se().toVar();E.y=d(this._edgesTextureUniform,this._searchTextureUniform,y.zw,_.w),E.x=v.x,S.y=E.y,S=S.div(this._invSize.y).sub(g.y);let A=Rh(oi(S)),C=this._edgesTextureUniform.sample(E.add(Se(0,1).mul(this._invSize))).g.toVar();b.ba=o(this._areaTextureUniform,A,M,C,L(x.x))}),b}),f=He(()=>{let g=Ae(r.xy,r.xy).add(Ae(this._invSize.xy,this._invSize.xy).mul(Ae(1,0,0,1)));return Bn("vec4","vOffset1").assign(g),OO}),m=He(()=>{let g=Bn("vec4","vOffset1"),v=Ae().toVar(),y=Ae().toVar();return y.xz=this._weightsTextureUniform.sample(r).xz,y.y=this._weightsTextureUniform.sample(g.zw).g,y.w=this._weightsTextureUniform.sample(g.xy).a,ze(Je(y,Ae(1)).lessThan(1e-5),()=>{v.assign(this.textureNode.sample(r))}).Else(()=>{let _=Se().toVar();_.x=y.a.greaterThan(y.b).select(y.a,y.b.negate()),_.y=y.g.greaterThan(y.r).select(y.g,y.r.negate()),ze(oi(_.x).greaterThan(oi(_.y)),()=>{_.y.assign(0)}).Else(()=>{_.x.assign(0)});let b=this.textureNode.sample(r).toVar(),x=Se(r).toVar();x.addAssign(Vc(_).mul(this._invSize));let w=this.textureNode.sample(x).toVar(),S=oi(_.x).greaterThan(oi(_.y)).select(oi(_.x),oi(_.y)).toVar(),T=lt(b,w,S);v.assign(T)}),v});return this._materialEdges.vertexNode=n().context(e.getSharedContext()),this._materialEdges.fragmentNode=s().context(e.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(e.getSharedContext()),this._materialWeights.fragmentNode=p().context(e.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=f().context(e.getSharedContext()),this._materialBlend.fragmentNode=m().context(e.getSharedContext()),this._materialBlend.needsUpdate=!0,this._textureNode}dispose(){this._renderTargetEdges.dispose(),this._renderTargetWeights.dispose(),this._renderTargetBlend.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose()}_getAreaTexture(){return""}_getSearchTexture(){return""}},LMe=e=>new oge(a2e(e))}),QUe=F(()=>{ne(),mn(),gi(),ZUe(),ua(),pN=new Z,Ij=new at,BMe=class{constructor(){this._rt=null,this._texNode=null,this._smaaNode=null,this._material=null,this._quad=null,this._depthTexNode=null,this._seedMaterial=null,this._seedQuad=null}_ensureTarget(e,t,i){if(this._rt===null||this._rt.width!==e||this._rt.height!==t){this._rt?.dispose();let r=new Fi(e,t,{depthBuffer:!0,stencilBuffer:!1,samples:0});r.texture.name="SplineHelperOverlay.color",this._rt=r}if(this._texNode===null){this._texNode=mt(this._rt.texture),this._smaaNode=LMe(this._texNode);let r=new Jt;r.name="SplineHelperOverlayComposite",r.fragmentNode=this._smaaNode,r.transparent=!0,r.blending=Mg,r.blendEquation=Wo,r.blendSrc=Kg,r.blendDst=Nf,r.blendSrcAlpha=Kg,r.blendDstAlpha=Nf,r.depthTest=!1,r.depthWrite=!1,this._material=r,this._quad=new Cn(r);let n=new Jt;n.name="SplineHelperOverlayDepthSeed",this._depthTexNode=mt(i),n.depthNode=this._depthTexNode.x,n.fragmentNode=Ae(0),n.colorWrite=!1,n.depthTest=!1,n.depthWrite=!0,this._seedMaterial=n,this._seedQuad=new Cn(n)}else this._texNode.value!==this._rt.texture&&(this._texNode.value=this._rt.texture),this._depthTexNode.value!==i&&(this._depthTexNode.value=i);return this._rt}render(e,t,i,r,n){e.getDrawingBufferSize(pN);let s=this._ensureTarget(pN.x,pN.y,n),a=e.getRenderTarget(),o=e.autoClear;e.getClearColor(Ij);let l=e.getClearAlpha();if(e.autoClear=!1,e.setRenderTarget(s),e.setClearColor(0,0),e.clear(!0,!0,!1),this._seedQuad.render(e),t&&e.render(t,r),e.clear(!1,!0,!1),i&&e.render(i,r),e.setRenderTarget(a),e.setClearColor(Ij,l),function(){try{return new URLSearchParams(window.location.search).get("dbgoutguard")!=="0"}catch{return!0}}()){let h=e.toneMapping,u=e.outputColorSpace;e.toneMapping=Os,e.outputColorSpace=ni.workingColorSpace,this._quad.render(e),e.toneMapping=h,e.outputColorSpace=u}else this._quad.render(e);e.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}}),M$,kO,VO,JUe=F(()=>{mn(),M$=new WeakMap,kO=new Set,VO=0});function lge(e){let t=e.parent?.selectedTexture;return t&&t.isTexture===!0?t:null}function fN(e){let t=e.src.array,i=e.attr.array;for(let r=0,n=Math.min(t.length,i.length);r<n;r++)i[r]=t[r];e.attr.needsUpdate=!0}var E$,vE,Zb,A$,e5e=F(()=>{ne(),mn(),gi(),E$=new WeakMap,vE=new Set,Zb=0,A$=new WeakMap});function t5e(e,t){(function(){if(C$)return;C$=!0;let r=ds.prototype,n=r.addEventListener;r.addEventListener=function(s,a){return s==="dispose"&&Qb!==null&&typeof a=="function"&&Qb.record(this,a),n.call(this,s,a)}})();let i=Qb;Qb=e;try{return t()}finally{Qb=i}}var UMe,mN,Qb,C$,i5e=F(()=>{ne(),UMe=class{constructor(){this._entries=[],this._pruneAt=mN}record(e,t){this._entries.push({target:new WeakRef(e),listener:new WeakRef(t)}),this._entries.length>=this._pruneAt&&(this._entries=this._entries.filter(i=>i.target.deref()!==void 0),this._pruneAt=Math.max(mN,2*this._entries.length))}release(){for(let{target:e,listener:t}of this._entries){let i=e.deref(),r=t.deref();i&&r&&i.removeEventListener("dispose",r)}this._entries=[],this._pruneAt=mN}},mN=1024,Qb=null,C$=!1}),r5e=F(()=>{});function zMe(e,t,i,r){let n=e.num(0),s=e.num(1),a=e.num(.5),o=e.num(2),l=e.num(kMe),h=u=>e.sub(s,u);switch(t){case 0:return i;case 1:return e.min(e.add(i,r),s);case 3:return e.mul(e.add(i,r),a);case 4:{let u=e.max(h(e.div(h(i),e.max(r,l))),n);return e.mix(r,u,e.step(l,r))}case 5:{let u=e.min(e.div(i,e.max(h(r),l)),s);return e.mix(u,r,e.step(s,r))}case 6:return e.min(i,r);case 7:return e.abs(e.sub(i,r));case 8:return e.sub(e.add(i,r),e.mul(o,e.mul(i,r)));case 9:return e.max(i,r);case 10:return e.mul(i,r);case 11:{let u=e.min(e.div(i,e.max(r,l)),s);return e.mix(s,u,e.step(l,r))}case 12:return h(e.abs(e.sub(h(i),r)));case 14:{let u=e.mul(o,e.mul(i,r)),d=h(e.mul(o,e.mul(h(i),h(r))));return e.mix(u,d,e.step(a,i))}case 15:{let u=e.min(e.div(e.mul(i,i),e.max(h(r),l)),s);return e.mix(u,r,e.step(s,r))}case 16:return h(e.mul(h(i),h(r)));case 17:{let u=e.mul(o,r),d=e.add(e.mul(i,u),e.mul(e.mul(i,i),h(u))),c=e.add(e.mul(e.sqrt(e.max(i,n)),e.sub(u,s)),e.mul(e.mul(o,i),h(r)));return e.mix(d,c,e.step(a,r))}case 18:return e.max(e.sub(e.add(i,r),s),n);default:return r}}var kMe,n5e=F(()=>{kMe=1e-6});function wv(e,t,i,r,n){if(i===0)return e;if(i===2)return lt(e,t,Li(n,r));let s=zMe(VMe,i,e,t);return lt(e,s,r)}function Oj(e,t,i,r){if(i===0)return e;if(i===2)return pt(e,Li(t,r));let n=zMe(GMe,i,e,t);return lt(e,n,r)}function Lj(){return jO===null&&(jO=gw({output:P2e,velocity:EMe})).setBlendMode("velocity",AMe),jO}var Ju,GO,VMe,GMe,jO,s5e=F(()=>{ne(),mn(),gi(),FMe(),CMe(),Q2e(),r5e(),Su(),ua(),n5e(),Ot(),Ju=e=>e,GO=e=>e,GMe=VMe={num:e=>L(e),add:(e,t)=>e.add(t),sub:(e,t)=>e.sub(t),mul:(e,t)=>e.mul(t),div:(e,t)=>e.div(t),min:(e,t)=>Li(e,t),max:(e,t)=>pt(e,t),abs:e=>oi(e),sqrt:e=>Rh(e),step:(e,t)=>ar(e,t),mix:(e,t,i)=>lt(e,t,i)},jO=null});function jMe(e){if(!Cy.enabled)return e;let t=P$.get(e);return t||(t={...e,bloom:{...e.bloom,kernelSize:0},depthOfField:{...e.depthOfField,enabled:!1}},P$.set(e,t)),t}var Cy,P$,WO,Bj,R$,D$,lZ,WMe=F(()=>{Cy={enabled:!1},P$=new WeakMap,WO=new WeakSet}),a5e=F(()=>{ne(),mn(),gi(),LK(),HB(),jB(),Bj=He(e=>{let t=e.lightDistance,i=e.cutoffDistance,r=e.decayExponent,n=i.greaterThan(0).and(r.greaterThan(0));return Xi(n,t.div(i).oneMinus().clamp().pow(r),L(1))}),R$=class extends Vq{static get type(){return"SplinePointLightNode"}setupDirect(e){let t=this.getLightVector(e),i=t.normalize(),r=Bj({lightDistance:t.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},D$=class extends hE{static get type(){return"SplineSpotLightNode"}setupDirect(e){let t,i,r=this.light,n=this.getLightVector(e),s=n.normalize(),a=s.dot(m2e(r)),o=this.getSpotAttenuation(e,a),l=Bj({lightDistance:n.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),h=this.colorNode.mul(o).mul(l),u=r;if(u.colorNode?(i=this.getLightCoord(e),t=u.colorNode(i)):u.map&&(i=this.getLightCoord(e),t=mt(u.map,i.xy).onRenderUpdate(()=>u.map)),t&&i){let d=i.mul(2).sub(1).abs().lessThan(1).all();h=Xi(d,h.mul(t),h)}return{lightColor:h,lightDirection:s}}}}),HMe=F(()=>{lZ=null});function qMe(){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.hidden===!0}function o5e(){return qMe()?Promise.resolve():new Promise(e=>{let t=!1,i=()=>{t||(t=!0,clearTimeout(r),e())},r=setTimeout(i,250);requestAnimationFrame(i)})}var hge,H_,uge,dge,cge,Fj,Uj,pge,fge,mge,gge,Ip,Hm,q2,qm,gN,zj,$2,Sv,sc,q_,vge,Tv,ac,X2,$_,vN,Mv,oc,kj,yN,Vj,_N,Gj,jj,bN,xN,$m,Wj,Hj,qj,$j,Xj,Yj,Kj,Ev,yge,Zj,j4,_ge=F(()=>{ne(),mn(),gi(),kUe(),sMe(),YB(),qB(),eZ(),iZ(),MK(),Nh(),VUe(),Ot(),oF(),OK(),bK(),hMe(),uMe(),GUe(),jUe(),WUe(),ua(),MMe(),cMe(),$Ue(),FMe(),YUe(),KUe(),QUe(),JUe(),e5e(),i5e(),s5e(),WMe(),mK(),a5e(),HMe(),hge=new P,H_=new P,uge=new at,dge=new at,cge=new at,Fj=new P,Uj=new P,pge=new Z,fge=new P(1,0,0),mge=new P(0,1,0),gge=new P(0,0,1),Ip=new P,Hm=new P,q2=new P,qm=new P,gN=new De,zj=new P,$2=new P,Sv=new Wa,sc=new ut,q_=new ut,vge=new Z,Tv=new Z,ac=new P,X2=new P,$_=new P,vN=new P,Mv=new P,oc=[],kj=!1,yN=!1,Vj=!1,_N="full",Gj="g16",jj=!1,bN=!1,xN=!1,$m="default",Wj=!1,Hj=!0,qj=!0,$j=!0,Xj=!0,Yj=!0,Kj=gq;try{let e=new URLSearchParams(window.location.search),t=e.get("instancing");if(t!==null)if(t==="off"||t==="0"||t==="false"||t==="no")Yj=!1;else{let n=Number.parseInt(t,10);Number.isFinite(n)&&n>1&&(Kj=n)}kj=e.get("dbgao")==="0",yN=e.get("dbgshadow")==="0",Vj=e.get("dbgfp16")==="1",jj=e.get("dbgsky")==="0",bN=e.get("dbgssr")==="0",xN=e.get("dbgibl")==="0";let i=e.get("pbrcolor");i==="0"?$m="off":(i==="linear"||i==="aces"||i==="agx"||i==="neutral")&&($m=i),Wj=e.get("dbgplanar")==="0",Hj=e.get("dbgplanarpyr")!=="0",qj=e.get("dbgssrpyr")!=="0",$j=e.get("dbgssrhalf")!=="0",Xj=e.get("dbgssrresolve")!=="0";let r=e.get("dbgprefilter");r==="0"?_N="off":r==="base"?_N="base":r==="k4"&&(Gj="k4")}catch{}Ev=[null,null,null,null],yge=AO.prototype._projectObject,(j4=Zj=class extends AO{constructor(e={}){var t;super({canvas:e.canvas,alpha:e.alpha??!0,antialias:e.antialias??!1,forceWebGL:e.forceWebGL??!1,powerPreference:e.powerPreference,trackTimestamp:e.trackTimestamp??globalThis.__SPLINE_TRACK_TIMESTAMP__===!0,stencil:!1,requiredLimits:e.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:Vj?li:zr,asyncCompilation:e.asyncCompilation===!0||e.asyncCompilation==="load"}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new Z,this.dummyCamera=new Kn,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this._shadowMapMissingAtSync=!1,this._shadowSyncPromotions=-1,this._lightShadowStateDirty=!1,this._lightShadowSignatures=new WeakMap,this._shadowMapIds=new WeakMap,this._shadowMapIdSeq=0,this.temporalAAEnabled=!0,this.hdrChainActive=!1,this.isWebGPUSplineRenderer=!0,this.shadowFilterHook=qUe,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new OMe,this._stallWarned=!1,this._asyncCompilationMode=!1,this._asyncLoadWarmupsInFlight=0,this.sceneBundlesEnabled=!1,this.sceneBundlesForceRerecord=!1,this.disposeListenerLedger=new UMe,this._appliedWidth=-1,this._appliedHeight=-1,this._appliedRatio=-1,this._bundleLists=null,this._bundleStates=new WeakMap,this._skySystem=null,this._envClaimScope=null,this._envClaimEpoch=-1,this._skyFeatureWarned=!1,this.skyAnimationAllowed=!1,this.skyEnvironmentNeeded=!0,this._bundledPages=new Set,this._bundleValveArmed=!1,this._destroyedSubmitErrors=0,this._destroyedSubmitLastFrame=-10,this._warmupTarget=null,this.renderStarted=!1,this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._grabWarmupTarget=null,this._warnedHelperIncompat=new WeakSet,this._maskLights=[],this._maskBlocked=!1,this.suppressShadowMask=!1,this._grabTargetEpoch=0,this._retiredGrabTargets=[],this._retiredGpuBuffers=[],this._bundleEpochDirty=!1,this._encodeMaterials={},this._transmissionChain=[],this._reflectionColorChain=[],this._reflectionDepthChain=[],this._reflectionPassesKey="",this._reflectionResolveMarchKey="",this._planarChain=[],this._frameSerial=0,this._asyncCompilationMode=e.asyncCompilation??!1,this._updateCompilationBurst(),u$&&function(){if(!c$){if(c$=!0,L4=()=>tt.frameIndex.value,typeof GPUBuffer<"u"){let i=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return Ume("buffer",this.label,this.size),i.call(this)}}if(typeof GPUTexture<"u"){let i=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return Ume("texture",this.label,`${this.width}x${this.height}`),i.call(this)}}console.info("[spline/webgpu] ?dbgdestroys=1 \u2014 GPU resource destroy logging armed; reproduce the error and read the [dbgdestroys] dumps")}}(),this.pipeline=new nZ(this),this.library.addLight(oMe,O4),this.shadowMap.enabled=!0,this.shadowMap.type=Df,t=this.backend?.isWebGPUBackend===!0,mE=t,this._deferGpuBufferDestruction(),function(i){let r=i;if(r==null||typeof r._draw!="function"||r.__splineDrawGuardInstalled===!0)return;r.__splineDrawGuardInstalled=!0;let n=r._draw.bind(r);r._draw=function(s,a,o,l,h,u,d,c,p){if(d.vertexCount>0&&s.getIndex()===null&&s.getIndirect()===null&&s.object.isBatchedMesh!==!0){let f=d.firstVertex+d.vertexCount;for(let m=0;m<u.length;m++){let g=u[m];if(g.isInstancedBufferAttribute!==!0&&g.isInstancedInterleavedBuffer!==!0&&g.count!==void 0&&g.count<f)return}}return n(s,a,o,l,h,u,d,c,p)}}(this.backend),this.outputColorSpace=Td,this.toneMapping=Os,function(i){let r=i.library;r.addLight(R$,bC),r.addLight(D$,Lw),r.addLight(Gq,Ow),r.lightNodes.delete(CA),r.lightNodes.delete(by),r.addLight(R$,CA),r.addLight(D$,by)}(this),this.sceneBundlesEnabled=e.sceneBundles===!0||e.sceneBundles==="rerecord",this.sceneBundlesForceRerecord=e.sceneBundles==="rerecord",this.auxiliary=e.auxiliary===!0,this.domElement.removeAttribute?.("data-engine")}advanceFrame(){let e=this._nodes,t=this.info;t.autoReset===!0&&t.reset(),e.nodeFrame.update(),t.frame=e.nodeFrame.frameId}get lastFrameIncomplete(){return!!(this._warmupInFlight||this._compilationHasWork&&!this._gaugesStalled)||(this._skippedAsyncDraws??0)!==0&&!this._skipStalls.stalled}get _gaugesStalled(){return this._gaugeChangedAt>0&&performance.now()-this._gaugeChangedAt>Zj._GAUGE_STALL_MS}_trackGaugeStall(){let e=this._asyncCompilationGauges,t=e!==void 0&&(e.queued>0||e.pipelines>0),i=t?`${e.queued}/${e.pipelines}`:"";return t?i!==this._gaugeSnapshot?(this._gaugeSnapshot=i,void(this._gaugeChangedAt=performance.now())):void(this._gaugesStalled&&!this._gaugeStallWarned&&(this._gaugeStallWarned=!0,console.warn(`[spline/webgpu] async pipeline driver stalled (${i} in flight, no movement for ${Zj._GAUGE_STALL_MS}ms) \u2014 treating frames as final so screenshots, thumbnails and the on-demand render loop keep working.`))):(this._gaugeSnapshot="",void(this._gaugeChangedAt=0))}_trackStalledSkips(e){let t=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(e,t),Si.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${e} draw(s) are permanently skipped \u2014 their render pipelines never became ready (look for "pipeline creation failed" above). Those objects will not appear; the frame is treated as final so screenshots, thumbnails and the on-demand render loop keep working.`))}get _asyncCompilationGauges(){return this.info.asyncCompilation}get _compilationHasWork(){let e=this._asyncCompilationGauges;return e!==void 0&&(e.queued>0||e.pipelines>0)}get asyncCompilationEnabled(){return this._asyncCompilation===!0}setAsyncCompilationPolicy(e){this._asyncCompilationMode!==e&&(this._asyncCompilationMode=e,this._setThreeAsyncCompilation(e),this._updateCompilationBurst())}get taaHistory(){return this._taaHistory||(this._taaHistory=PMe()),this._taaHistory}async init(){await super.init(),function(t,i=sZ){if(!function(a){return a.isWebGPUBackend===!0}(t)||t.__splineTextureClampInstalled===!0)return;t.__splineTextureClampInstalled=!0;let r=t.createTexture.bind(t),n=t.updateTexture.bind(t),s=()=>t.device?.limits.maxTextureDimension2D??0;t.createTexture=(a,o)=>{zme(a,o,s(),i),r(a,o)},t.updateTexture=(a,o)=>{zme(a,o,s(),i),n(a,o)}}(this.backend);let e=this.backend.gl;if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(t){console.warn(t)}return this.backend.device?.lost?.then(t=>{Si.deviceLost=`${t?.reason??"unknown"}: ${t?.message??""}`.trim()}),this}setSize(e,t,i=!0){if(this._appliedWidth!==e||this._appliedHeight!==t||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=e,this._appliedHeight=t,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==e||this.viewportHeight!==t;this.viewportWidth=e,this.viewportHeight=t,super.setSize(e,t,i),r&&this.pipeline.resize(e,t,i)}return this}setPixelRatio(e=1){return this.getPixelRatio()!==e&&super.setPixelRatio(e),this}get hdTransmission(){return tt.transmissionLod.value===1}set hdTransmission(e){tt.transmissionLod.value=e===!0?1:2}renderScenePass(e,t){this.render(e,t)}_projectObject(e,t,i,r,n){let s=this,a=s._renderLists,o=null;if(e.isBundleGroup===!0&&r===a.get(e,t)){let l=this._bundleLists??(this._bundleLists=new a.constructor(a.lighting,a.objects));s._renderLists=l;let h=this.backend.get(s._bundles.get(e,t,s._currentRenderContext));s.sortObjects&&s._bundleNeedsUpdate(e,h)&&(o=l.get(e,t))}try{yge.call(this,e,t,i,r,n)}finally{s._renderLists=a}o?.sort(s._opaqueSort,s._transparentSort,t.reversedDepth)}_renderObjects(e,t,i,r,n=null){let s=this,a=n===null&&i.overrideMaterial===null;for(let o=0,l=e.length;o<l;o++){let{object:h,geometry:u,material:d,group:c,clippingContext:p}=e[o];if(a&&s$(d))this._renderWithDepthPrepass(h,i,t,u,d,c,r,p);else{if(a&&this._drawsStalePrepass(h,d,r,n)){let f=d,m=(g,v)=>s._handleObjectFunction(h,g,i,t,r,c,p,v);d.side!==Cr||d.forceSinglePass?m(f.getDepthPrepassTwin(d.side),null):(m(f.getDepthPrepassTwin(wr),null),d.side=wr,m(d,"backSide"),d.side=Cr,m(f.getDepthPrepassTwin(sa),null))}s._currentRenderObjectFunction(h,i,t,u,d,c,r,p,n)}}}_renderTransparents(e,t,i,r,n){AO.prototype._renderTransparents.call(this,e,t,i,r,n);let s=this.pipeline.depthOfFieldDepthTexture;if(s===null||this.getRenderTarget()?.depthTexture!==s)return;let a=this;for(let{object:o,material:l,group:h,clippingContext:u}of e)!s$(l)||l.getDepthOfFieldTwin===void 0||(a._handleObjectFunction(o,l.getDepthOfFieldTwin(l.side),r,i,n,h,u,null),Si.depthOfFieldTwinDraws++)}_drawsStalePrepass(e,t,i,r){if(t.transparent||!this.asyncCompilationEnabled||!("getDepthPrepassTwin"in t))return!1;Ev[0]=e,Ev[1]=t,Ev[2]=this._currentRenderContext,Ev[3]=i;let n=this._objects.getChainMap(r).get(Ev)?.drawMaterial;return Ev.fill(null),n?.transparent===!0&&n.depthWrite===!1}_renderWithDepthPrepass(e,t,i,r,n,s,a,o){let l=this,h=(d,c)=>l._handleObjectFunction(e,d,t,i,a,s,o,c),u=s;e.onBeforeRender(this,t,i,r,n,u),n.side===Cr&&n.forceSinglePass===!1?(h(n.getDepthPrepassTwin(wr),null),n.side=wr,h(n,"backSide"),h(n.getDepthPrepassTwin(sa),null),n.side=sa,h(n,null),n.side=Cr,Si.depthPrepassDraws+=2):(h(n.getDepthPrepassTwin(n.side),null),h(n,null),Si.depthPrepassDraws++),e.onAfterRender(this,t,i,r,n,u)}get skySystem(){return this._skySystem}get skyAnimationActive(){return this._skySystem?.animationActive===!0}*_liveBundledPages(){for(let e of this._bundledPages){let t=e.deref();t===void 0?this._bundledPages.delete(e):yield t}}_armBundleValve(){if(this._bundleValveArmed)return;let e=this.backend.device;typeof e?.addEventListener=="function"&&(this._bundleValveArmed=!0,e.addEventListener("uncapturederror",t=>{if(!this.sceneBundlesEnabled||!(t?.error?.message??"").toLowerCase().includes("destroyed"))return;let i=tt.frameIndex.value,r=(i-this._destroyedSubmitLastFrame+16)%16;if(this._destroyedSubmitErrors=r<=2?this._destroyedSubmitErrors+1:1,this._destroyedSubmitLastFrame=i,!(this._destroyedSubmitErrors<4)){this.sceneBundlesEnabled=!1,Si.bundleDisabled=!0;for(let n of this._liveBundledPages()){let s=this._bundleStates.get(n);s&&(s.disabled=!0),n.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(e,t){if(this.backend.beginBundle===void 0)return;let i=this._bundleStates.get(e);if(i===void 0){let d={signature:-1,rebuilds:0,resourceRebuilds:0,checks:0,disabled:!1,camHash:0,prevCamHash:0,epoch:0,lastEpoch:0,bufferIds:new WeakMap,bufferIdSeq:0,watched:new WeakSet,onResourceDispose:()=>{d.epoch++}};i=d,this._bundleStates.set(e,i),this._bundledPages.add(new WeakRef(e)),this._armBundleValve()}let r=e;if(i.disabled)return;{let d=t.matrixWorld.elements,c=t.projectionMatrix.elements,p=-2128831035;for(let f=0;f<16;f++)p^=1e4*d[f]|0,p=Math.imul(p,16777619),p^=1e4*c[f]|0,p=Math.imul(p,16777619);i.camHash=p}let n=-2128831035,s=d=>{n^=0|d,n=Math.imul(n,16777619)};s(this._grabTargetEpoch),s(e.fog!==null?1:0),s(this.pipeline.depthOfFieldDepthTexture!==null?1:0);let a=i,o=d=>{let c=d;!c||typeof c.addEventListener!="function"||a.watched.has(c)||(a.watched.add(c),c.addEventListener("dispose",a.onResourceDispose))},l=d=>{if(!d)return 0;let c=a.bufferIds.get(d);return c===void 0&&(c=++a.bufferIdSeq,a.bufferIds.set(d,c)),c},h=d=>{o(d),s(d.id),s(d.version),s(d.transparent===!0?1:0),typeof d.assetsLoaded=="function"&&s(d.assetsLoaded()?1:0)},u=!1;if(e.traverse(d=>{let c=d;if(c.isMesh===!0||c.isLine===!0||c.isPoints===!0||c.isSprite===!0){let p=c;p.isDecalObject===!0&&typeof p.updateDecal=="function"&&p.updateDecal()&&(u=!0),c.runBeforeRenderWhenBundled===!0&&c.onBeforeRender(this,e,t,c.geometry,c.material,null),c.frustumCulled&&(c.frustumCulled=!1),s(c.id),s(c.visible?1:0),s(c.layers.mask),s(c.renderOrder),s(c.matrixWorld.determinantAffine()<0?1:0);let f=c.geometry;o(f),s(f.id),s(f.drawRange.start),s(f.drawRange.count===1/0?-1:f.drawRange.count),s(l(f.index)),s(l(f.attributes.position)),s(f.instanceCount??-1),s(c.count===void 0?-1:c.count);let m=c;s(m.isSkinnedMesh===!0&&m.skeleton?m.skeleton.bones.length:-1);let g=c.material;if(Array.isArray(g))for(let v of g)h(v);else g&&h(g)}else d.isLight===!0?(s(d.id),s(d.visible?1:0),s(d.castShadow?1:0)):(s(d.id),s(d.visible?1:0))}),s(i.epoch),i.checks++,Si.bundleChecks=i.checks,i.checks%600==0){let d=this._bundleDebug;Si.bundleIncompleteRecords=d?.incompleteRecords??0,Si.bundleRecords=d?.records??0,Si.bundleReplays=d?.replays??0,i.prevCamHash=i.camHash}if(r.isBundleGroup!==!0)return function(d){let c=d;Object.getOwnPropertyDescriptor(c,"needsUpdate")?.set||Object.defineProperty(c,"needsUpdate",{configurable:!0,enumerable:!1,get:()=>!1,set(p){p===!0&&(this.version=(this.version??0)+1)}}),c.isBundleGroup=!0,c.static=!0,typeof c.version!="number"&&(c.version=0)}(e),void(i.signature=n);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=n);if(n!==i.signature){if(i.signature=n,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch||u)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(Si.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,Si.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,Si.bundleDisabled=!0)}}_ensureWarmupTarget(){if(this._warmupTarget===null){let e=new Fi(2,2,{count:2});e.textures[0].name="output",e.textures[0].type=zr,e.textures[1].name="velocity",e.textures[1].type=li;let t=new ns(2,2);t.isRenderTargetTexture=!0,e.depthTexture=t,this._warmupTarget=e}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(e,t=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[e,t,i]:super.setRenderTarget(e,t,i)}setMRT(e){return this._warmupInFlight?(this._warmupPendingMRT=[e],this):(super.setMRT(e),this)}async compileSceneAsync(e,t){if(!t)return;{let n=e instanceof zg?e.activePage:e;Wme(wy.isSoft(n?.data?.shadow)),n&&Rme(n)}if(this._asyncCompilationMode!==!1)return this._asyncCompilationMode==="load"&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(e,t);if(this.renderStarted||this._warmupInFlight)return;let i=this.getRenderTarget(),r=this.getMRT();this._warmupInFlight=!0,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst();try{this.normalizeCameraCoordinateSystem(t),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(Lj())),await this.compileAsync(e,t)}catch(n){console.warn("[spline/webgpu] pipeline warm-up failed:",n)}finally{let n=this._warmupPendingTarget,s=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),n!==null?super.setRenderTarget(n[0],n[1],n[2]):super.setRenderTarget(i),s!==null?super.setMRT(s[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(e,t){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(t);let i,r=this.getRenderTarget(),n=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(Lj())),i=this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(n)}let s=this._warmupGrabContext(e,t);await i,await s}catch(i){console.warn("[spline/webgpu] pipeline warm-up failed:",i)}finally{this._asyncLoadWarmupsInFlight--,this._updateCompilationBurst(),this._maybeCloseAsyncLoadWindow()}}_disposeWarmupTargets(){this._warmupTarget?.depthTexture?.dispose(),this._warmupTarget?.dispose(),this._warmupTarget=null,this._grabWarmupTarget?.depthTexture?.dispose(),this._grabWarmupTarget?.dispose(),this._grabWarmupTarget=null}_warmupGrabContext(e,t){let i=e instanceof zg?e:e.scene;if(i.needsTransmission?.()!==!0&&i.needsReflection?.()!==!0)return null;if(this._grabWarmupTarget===null){let s=new Fi(2,2);s.texture.type=zr;let a=new ns(2,2);a.isRenderTargetTexture=!0,s.depthTexture=a,this._grabWarmupTarget=s}let r=this.getRenderTarget(),n=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(n)}}_setThreeAsyncCompilation(e){this.setAsyncCompilation(e)}_updateCompilationBurst(){let e=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||this._asyncCompilationMode==="load"&&this.asyncCompilationEnabled;this.setCompilationBurst(e),Si.compilationBurst=e}_maybeCloseAsyncLoadWindow(){this._asyncCompilationMode==="load"&&(!this.asyncCompilationEnabled||this._asyncLoadWarmupsInFlight>0||this._frameSerial!==0&&((this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled||this._compilationHasWork||(this._setThreeAsyncCompilation(!1),this._updateCompilationBurst())))}normalizeCameraCoordinateSystem(e){let t=e;(t.coordinateSystem!==this.coordinateSystem||t.perspCamera!==void 0&&t.perspCamera.coordinateSystem!==this.coordinateSystem||t.orthoCamera!==void 0&&t.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(t.coordinateSystem=this.coordinateSystem,t.perspCamera!==void 0&&(t.perspCamera.coordinateSystem=this.coordinateSystem),t.orthoCamera!==void 0&&(t.orthoCamera.coordinateSystem=this.coordinateSystem),e.updateProjectionMatrix?.())}_prepareHelpers(e,t,i){e.traverse(r=>{let n=r;if(r.isPoints===!0){let l=function(h){if(Array.isArray(h.material)||h.parent===null||h.geometry.getAttribute("position")===void 0)return null;let u=h.material;return u.isNodeMaterial===!0?null:u.isPointsMaterial===!0?function(d,c){if(c.size<=1)return null;let p=E$.get(d);return p&&(p.epoch!==Zb||p.srcMaterial!==c||p.geometry!==d.geometry||p.position.src!==d.geometry.getAttribute("position")||p.map!==c.map||p.selectedMap!==lge(d))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(f,m){let g=f.geometry,v=g.getAttribute("position"),y=g.getAttribute("aSelection"),_=g.getAttribute("aVisibility"),b=m.map,x=lge(f),w=new fl(v.array,3);w.setUsage(bd);let S={src:v,attr:w,version:v.version},T=[],M=O=>{let k=new fl(new Float32Array(O.count),1);k.setUsage(bd);let G={src:O,attr:k,version:O.version};return fN(G),T.push(G),G},E=y?M(y):null,A=_?M(_):null,C=new XA;C.name=`SplinePointsTwin(${m.name||m.type})`,C.positionNode=vg(S.attr,"vec3"),C.size=m.size,C.sizeAttenuation=m.sizeAttenuation,C.transparent=m.transparent,C.depthTest=m.depthTest,C.depthWrite=m.depthWrite,C.blending=m.blending,C.fog=!1;let D=E?vg(E.attr,"float"):null,R=A?vg(A.attr,"float"):null;C.colorNode=He(()=>{R!==null?CO(R.lessThan(.5)):D!==null&&CO(D.greaterThan(.5));let O=b!==null?mt(b,Hi()):Ae(1);return(D!==null&&b!==null&&x!==null?lt(O,mt(x,Hi()),D):O).mul(Ae(v2e,1))})();let I=new aW(C);I.name=`SplinePointsTwin(${f.name||f.type})`,I.frustumCulled=!1,I.raycast=()=>{};let U={sprite:I,material:C,srcMaterial:m,geometry:g,map:b,selectedMap:x,position:S,mirrors:T,epoch:Zb};return vE.add(new WeakRef(U)),U}(d,c),E$.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(f,m){let{sprite:g,position:v,srcMaterial:y}=m;v.version!==v.src.version&&(m.position.attr.needsUpdate=!0,v.version=v.src.version);for(let b of m.mirrors)b.version!==b.src.version&&(fN(b),b.version=b.src.version);let _=Math.max(0,Math.min(m.geometry.drawRange.count,v.src.count));g.count=_,m.material.size=y.size,m.material.opacity=y.opacity,m.material.color.copy(y.color),g.layers.mask=f.layers.mask,g.renderOrder=f.renderOrder}(d,p),p.sprite}(h,u):function(d,c){if(c.isShaderMaterial!==!0)return!1;let p=c.uniforms,f=p?.pointSize?.value,m=p?.color?.value;return typeof f=="number"&&f>1&&Array.isArray(m)&&m.length>=3&&d.geometry.getAttribute("hover")!==void 0&&d.geometry.getAttribute("selected")!==void 0}(h,u)?function(d,c){let p=A$.get(d);return p&&(p.epoch!==Zb||p.srcMaterial!==c||p.geometry!==d.geometry||!function(f,m){let g=[[f.position,"position"],[f.hover,"hover"],[f.selected,"selected"]];for(let[v,y]of g){let _=m.getAttribute(y);if(_===void 0)return!1;if(v.src!==_){if(_.count!==v.attr.count)return!1;v.src=_,v.version=-1}}return!0}(p,d.geometry))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(f,m){let g=f.geometry,v=m.uniforms,y=(D,R)=>{let I=new fl(new Float32Array(D.count*R),R);I.setUsage(bd);let U={src:D,attr:I,version:D.version};return fN(U),U},_=y(g.getAttribute("position"),3),b=y(g.getAttribute("hover"),1),x=y(g.getAttribute("selected"),1),w=Be(v.pointSize.value),S=Be(new at().fromArray(v.color.value)),T=new XA;T.name=`SplinePointsTwin(${m.name||m.type})`,T.positionNode=vg(_.attr,"vec3");let M=vg(b.attr,"float"),E=vg(x.attr,"float");T.sizeNode=w.add(M.mul(4)),T.sizeAttenuation=!1,T.transparent=m.transparent,T.depthTest=m.depthTest,T.depthWrite=m.depthWrite,T.blending=m.blending,T.fog=!1,T.colorNode=He(()=>{let D=$i(Hi().mul(2).sub(1)).toVar();CO(D.greaterThan(1));let R=Xi(E.equal(1),Q(.22,.9,.7),S.add(M.mul(.25)));return Ae(Xi(D.greaterThan(.75),Q(1),R),1)})();let A=new aW(T);A.name=`SplinePointsTwin(${f.name||f.type})`,A.frustumCulled=!1,A.raycast=()=>{};let C={sprite:A,material:T,srcMaterial:m,geometry:g,pointSize:w,color:S,position:_,hover:b,selected:x,epoch:Zb};return vE.add(new WeakRef(C)),C}(d,c),A$.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(f,m){for(let y of[m.position,m.hover,m.selected])y.version!==y.src.version&&(fN(y),y.version=y.src.version);let g=m.srcMaterial.uniforms;m.pointSize.value=g.pointSize.value,m.color.value.fromArray(g.color.value);let v=Math.max(0,Math.min(m.geometry.drawRange.count,m.position.src.count));m.sprite.count=v,m.material.opacity=m.srcMaterial.opacity,m.sprite.layers.mask=f.layers.mask,m.sprite.renderOrder=f.renderOrder}(d,p),p.sprite}(h,u):null}(r);if(l!==null)return l.visible=n.visible,void(n.visible&&(t.push(n),n.visible=!1))}let s=!1,a="",o=Array.isArray(n.material)?n.material:n.material?[n.material]:[];for(let l of o){let h=l;if(h.isShaderMaterial===!0&&h.isNodeMaterial!==!0){s=!0,a=`WebGL-only material "${h.type}"`;break}}if(s&&!Array.isArray(n.material)){let l=function(h){return h.isLineMaterial===!0?function(u){let d=M$.get(u);if(!d||d.epoch!==VO){let g=new qTe;g.name=`SplineHelperTwin(${u.name||u.type})`,g.worldUnits=!1,d={twin:g,epoch:VO},M$.set(u,d),kO.add(new WeakRef(g))}let c=d.twin,p=u;c.color.copy(p.color),c.linewidth=p.linewidth,c.opacity=p.opacity,c.transparent=p.transparent,c.depthTest=p.depthTest,c.depthWrite=p.depthWrite,c.side=p.side;let f=p.dashed===!0;if(c.dashed!==f&&(c.dashed=f,c.needsUpdate=!0),f){let g=c;g.dashScale=p.dashScale??1,g.dashSize=p.dashSize??1,g.gapSize=p.gapSize??1}let m=p.vertexColors===!0||p.vertexColors===2;return c.vertexColors!==m&&(c.vertexColors=m,c.needsUpdate=!0),c}(h):null}(n.material);if(l)return i.push({object:n,original:n.material}),void(n.material=l)}!s&&n.geometry?.isInstancedBufferGeometry===!0&&!Number.isFinite(n.geometry.instanceCount??0)&&(s=!0,a="infinite instanceCount geometry"),s&&n.visible&&(this._warnedHelperIncompat.has(r)||this._warnedHelperIncompat.add(r),t.push(n),n.visible=!1)})}renderHelperOverlay(e,t,i,r){let n=[],s=[];if(e&&this._prepareHelpers(e,n,s),t&&this._prepareHelpers(t,n,s),r)this._helperOverlay??(this._helperOverlay=new BMe),this._helperOverlay.render(this,e,t,i,r),Si.helperOverlayMode="smaa";else{let a=this.autoClear;this.autoClear=!1,e&&this.render(e,i),t&&(this.clearDepth(),this.render(t,i)),this.autoClear=a,Si.helperOverlayMode="direct"}for(let a of s)a.object.material=a.original;for(let a of n)a.visible=!0}createEffectChain(){return function(e){let t=e.pipeline,i=t.postprocessingState,r=i.enabled===!0,n=D2e(t.scene,t.camera),s=e.hdrChainActive;try{let E=new URLSearchParams(window.location.search).get("dbgfp16");(E==="scene"||E==="st")&&(s=!0)}catch{}let a=n.getTextureNode(),o=a,l=null;if(e.temporalAAEnabled){n.setMRT(Lj()),l=function(E,A,C,D,R=!1){return new IMe(E,A,C,D,R)}(a,n.getTextureNode("depth"),n.getTextureNode("velocity"),e.taaHistory,s),o=l,n.getTexture("velocity").type=li;try{if(new URLSearchParams(window.location.search).get("dbgvel")==="1"){let E=Ju(n.getTextureNode("velocity"));o=Ae(GO(E.x).mul(20).add(.5),GO(E.y).mul(20).add(.5),L(.5),L(1))}}catch{}}s?n.getTexture("output").type=li:aF()&&(n.getTexture("output").internalFormat="rgba8unorm-srgb");let h=(E,A)=>typeof E=="number"&&Number.isFinite(E)?E:A,u={bloomIntensity:Be(1),caOffset:Be(new Z(0,0)),caAspect:Be(1),vignetteOffset:Be(0),vignetteDarkness:Be(0),hueVector:Be(new P(1,0,0)),saturationFactor:Be(0),brightness:Be(0),bcContrastScale:Be(1),dofFocusDistance:Be(0),dofFocalLength:Be(0),dofBokehScale:Be(1),dofCameraNear:Be(50),dofCameraFar:Be(1e4),dofOrtho:Be(0),pixelCells:Be(new Z(1,1)),bloomOpacity:Be(1),caOpacity:Be(1),vignetteOpacity:Be(1),noiseOpacity:Be(1),hueSaturationOpacity:Be(1),brightnessContrastOpacity:Be(1),dofOpacity:Be(1)},d=E=>GO(E),c=(E,A)=>{u.bloomIntensity.value=h(E.bloom.intensity,1),u.bloomOpacity.value=h(E.bloom.opacity,1),u.caOffset.value.set(h(E.chromaticAberration.offset?.[0],10),h(E.chromaticAberration.offset?.[1],10)),u.caOpacity.value=h(E.chromaticAberration.opacity,1),u.vignetteOffset.value=h(E.vignette.offset,.5),u.vignetteDarkness.value=h(E.vignette.darkness,.5),u.vignetteOpacity.value=h(E.vignette.opacity,1),u.noiseOpacity.value=h(E.noise.opacity,1),u.hueVector.value.fromArray(function(G){let K=Math.sin(G),q=Math.cos(G);return[(2*q+1)/3,(-Math.sqrt(3)*K-q+1)/3,(Math.sqrt(3)*K-q+1)/3]}(h(E.hueSaturation.hue,0))),u.saturationFactor.value=function(G){return G>0?1-1/(1.001-G):-G}(h(E.hueSaturation.saturation,0)),u.hueSaturationOpacity.value=h(E.hueSaturation.opacity,1),u.brightness.value=h(E.brightnessContrast.brightness,0);let C=Math.min(h(E.brightnessContrast.contrast,0),.9999);u.bcContrastScale.value=C>0?1/(1-C):1+C,u.brightnessContrastOpacity.value=h(E.brightnessContrast.opacity,1);let D=t.camera,R=D?.isPerspectiveCamera===!0,I=function(G,K,q){return{focusDistance:q?G/2e3:(G+992)/2e3,focusRange:Math.max(K/2e3,1e-6)}}(h(E.depthOfField.focusDistance,BO.focusDistance),h(E.depthOfField.focalLength,BO.focalLength),R);u.dofFocusDistance.value=I.focusDistance,u.dofFocalLength.value=I.focusRange,u.dofBokehScale.value=h(E.depthOfField.bokehScale,BO.bokehScale),u.dofOpacity.value=h(E.depthOfField.opacity,1),u.dofCameraNear.value=h(D?.near,50),u.dofCameraFar.value=h(D?.far,1e4),u.dofOrtho.value=R?0:1;let U=A.resolution.x?A.resolution:new Z(A.viewportWidth*A.getPixelRatio(),A.viewportHeight*A.getPixelRatio());u.caAspect.value=U.y>0?U.x/U.y:1;let O=Math.floor(h(E.pixelation.granularity,30));O%2>0&&(O+=1);let k=O>0;u.pixelCells.value.set(k?U.x/O:U.x,k?U.y/O:U.y)};c(i,e);let p=Ju(o),f=p.rgb,m=p.a,g=r&&i.pixelation.enabled,v=u.pixelCells,y=E=>E.mul(v).floor().add(.5).div(v),_=l?l.outputTextureNode:a;if(g){let E=Ju(_.sample(y(Hi())));f=lt(f,E.rgb,1),m=lt(m,E.a,1)}if(r&&i.chromaticAberration.enabled){let E=i.chromaticAberration,A=u.caOffset.mul(.001).mul(Se(1,d(u.caAspect))),C=U=>g?y(U):U,D=Ju(_.sample(C(Hi().add(A)))),R=Ju(_.sample(C(Hi().sub(A)))),I=pt(pt(D.a,R.a),m);f=wv(f,Q(D.r,f.g,R.b),E.blendFunction,d(u.caOpacity),I),m=Oj(m,I,E.blendFunction,d(u.caOpacity))}let b=null;if(r&&i.depthOfField.enabled){let E=vne("depthOfField");if(E){let A=i.depthOfField;b=E(Ae(f,m),_,n.getTextureNode("depth"),{focusDistance:d(u.dofFocusDistance),focusRange:d(u.dofFocalLength),bokehScale:d(u.dofBokehScale),cameraNear:d(u.dofCameraNear),cameraFar:d(u.dofCameraFar),orthographic:d(u.dofOrtho)},{halfFloat:s,inputUv:g?y:void 0});let C=Ju(b);f=wv(f,C.rgb,A.blendFunction,d(u.dofOpacity),C.a),m=Oj(m,C.a,A.blendFunction,d(u.dofOpacity))}else _q("depthOfField","webgpu")}let x=null;if(r&&i.bloom.enabled){let E=vne("bloom");if(E){let A=i.bloom;x=E(l?l.outputTextureNode:a,{kernelSize:X4e(A.kernelSize),blurScale:h(A.blurScale,1),luminanceThreshold:h(A.luminanceThreshold,.9),luminanceSmoothing:h(A.luminanceSmoothing,.025)});let C=qt(Ju(x).mul(d(u.bloomIntensity)),0,1);f=wv(f,C.rgb,A.blendFunction,d(u.bloomOpacity),C.a),m=Oj(m,C.a,A.blendFunction,d(u.bloomOpacity))}else _q("bloom","webgpu")}if(r&&i.hueSaturation.enabled){let E=i.hueSaturation,A=u.hueVector,C=Q(Je(f,A),Je(f,A.zxy),Je(f,A.yzx)),D=C.r.add(C.g).add(C.b).div(3);f=wv(f,C.add(Q(D).sub(C).mul(d(u.saturationFactor))).min(1),E.blendFunction,d(u.hueSaturationOpacity),m)}if(r&&i.brightnessContrast.enabled){let E=i.brightnessContrast,A=f.add(Q(d(u.brightness)));A=A.sub(.5).mul(d(u.bcContrastScale)).add(.5),f=wv(f,A.min(1),E.blendFunction,d(u.brightnessContrastOpacity),m)}if(r&&i.vignette.enabled){let E=i.vignette,A=$i(Hi().sub(.5)).mul(d(u.vignetteDarkness).add(d(u.vignetteOffset))),C=Kr(d(u.vignetteOffset).mul(.799),L(.8),A).oneMinus();f=wv(f,f.mul(C),E.blendFunction,d(u.vignetteOpacity),m)}if(r&&i.noise.enabled){let E=i.noise,A=fr(Aa(vd(Je(Hi().mul(q2e),Se(12.9898,78.233)),Math.PI)).mul(43758.5453));f=wv(f,Q(A),E.blendFunction,d(u.noiseOpacity),m)}r&&(s?f=f.max(0):(f=qt(f,0,1),m=qt(m,0,1)));let w=Ae(f,m);if(t.uiOverlayEnabled&&t.uiCanvasTexture){let E=Ju(mt(t.uiCanvasTexture,Hi().flipY())),A=lt(w.rgb,E.rgb,E.a),C=qt(w.a.add(E.a),0,1);w=Ae(A,C)}let S=t.sceneTransitionFromTexture;if(S){let E=Ju(mt(S,Hi())),A=t.sceneTransitionPass.uniforms.mixRatio;w=lt(E,w,A)}let T=t.watermarkTexture;if(T){let E=T.image,A=E?.width||128,C=E?.height||32,D=new Z(e.viewportWidth*e.getPixelRatio(),e.viewportHeight*e.getPixelRatio()),R=12*e.getPixelRatio(),I=.5*A*e.getPixelRatio(),U=.5*C*e.getPixelRatio(),O=Se((D.x-I-R)/D.x,R/D.y),k=Se(I/D.x,U/D.y),G=Hi().flipY().sub(O).div(k),K=G.x.greaterThanEqual(0).and(G.x.lessThanEqual(1)).and(G.y.greaterThanEqual(0)).and(G.y.lessThanEqual(1)),q=qt(G,0,1),Y=Ju(mt(T,q)),ue=Y.a.mul(K.select(L(1),L(0)));w=Ae(lt(w.rgb,Y.rgb,ue),qt(w.a.add(ue),0,1))}let M=new XTe(e,w);return{syncValues:c,render(){n.scene=t.scene,n.camera=t.camera,M.render()},renderTAAResolve:l?E=>{n.scene=t.scene,n.camera=t.camera,l.renderResolve(E)}:null,renderBloomPasses:x?E=>{n.scene=t.scene,n.camera=t.camera,x.renderBloom(E)}:null,renderDoFPasses:b?E=>{n.scene=t.scene,n.camera=t.camera,b.renderDoF(E)}:null,resize(){},sceneDepthTexture:()=>n.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),b?.dispose(),n.dispose(),M.dispose()}}}(this)}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,n=t.width,s=this.viewportWidth/this.viewportHeight;n<r?n=r*s:r=n/s,this.dummyCamera.setViewplaneSize(n,r);for(let a=0;a<i;a++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(lq()?.drainRetired()??0)+(uq()?.drainRetired()??0)>0&&this._retireBundleRecords(),u$&&function(v){if(v==null||v===p$)return;let y=v;typeof y.addEventListener=="function"&&(p$=v,y.addEventListener("uncapturederror",_=>{let b=_?.error?.message??"";!b.toLowerCase().includes("destroyed")||d$<=0||(d$--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${L4()} (t=${Math.round(performance.now())}ms):
|
|
6260
6260
|
${b.slice(0,400)}
|
|
6261
6261
|
\u2014 last ${Gx.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,Gx.map(x=>({...x}))))}))}(this.backend.device);let n=this._skippedAsyncDraws??0;Si.skippedAsyncDraws=n,this._skippedAsyncDraws=0,this._trackStalledSkips(n),this._trackGaugeStall(),VSe(this);let s=e instanceof zg?e.activePage:e,a=s.visible;s.visible=!0;let o=s.scene;if(Rme(s),this.renderStarted=!0,Yj&&e instanceof zg){let v=e.updateInstanceGroups(s,Kj);Si.instancingGroups=v.instancingGroups,Si.instancedDrawsSaved=v.instancedDrawsSaved,Si.instancingRegroups=v.instancingRegroups,Si.instancingParks=v.instancingParks,Si.instancingIneligible=v.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(s,t)),this.normalizeCameraCoordinateSystem(t),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(s.bgColor,s.bgColor.a),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride);let l=jj?null:s.skyState;if(l?.enabled===!0){if(this.skyEnvironmentNeeded=!this.auxiliary&&(!bN&&(o.needsReflectionDirty||o.needsReflection())||!xN&&l.lighting===!0),this._skySystem===null){let v=lZ;v===null?this._skyFeatureWarned||(this._skyFeatureWarned=!0,console.warn("[spline] scene uses the atmospheric sky, but the sky feature is compiled out of this build")):this._skySystem=v(this)}this._skySystem?.update(s,t)}else this._skySystem?.attached&&this._skySystem.detach();if(!this.auxiliary){let v=null,y=0;!xN&&l?.enabled===!0&&this._skySystem&&(v=this._skySystem.iblTexture??null,y=this._skySystem.iblRotationY??0);let _=s.scene??s,b=JK;if(this._envClaimScope!==_||this._envClaimEpoch!==b){this._envClaimScope=_,this._envClaimEpoch=b;let x=!1;_.traverse(w=>{let S=w.material,T=Array.isArray(S)?S:[S];for(let M of T)M?.claimEnvironmentScope?.(_)&&(x=!0)}),x&&Ej(_)}(function(x,w){let S=Vx(x);S.quality!==w&&(S.quality=w,Ej(x))})(_,l?.lightingQuality==="low"?"low":"full"),function(x,w){let S=Vx(x);S.texture!==w&&(S.texture=w,S.version++,Ej(x))}(_,v),Vx(_).rotation.set(0,-y,0),s.environmentIntensity=l?.enabled===!0?l.lightingIntensity??1:1}{let v=$m==="off"?null:s.gradingState,y=$m!=="default"&&$m!=="off",_=y||v?.pipeline==="linear",b=y?$m==="linear"?"none":$m:v?.toneMapping??"aces";this.toneMapping=_?b==="aces"?wA:b==="agx"?SA:b==="neutral"?TA:Os:Os,this.toneMappingExposure=_?v?.exposure??1:1,this.outputColorSpace=_?qi:Td,this.hdrChainActive=_,this.temporalAAEnabled&&this.taaHistory.setHdr(_)}tt.pixelRatio.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?tt.resolution.value.set(this.resolution.x,this.resolution.y):tt.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let h=(tt.frameIndex.value+1)%16;tt.frameIndex.value=h;let u=mMe[h];tt.pcssHalton.value.set(u[0],u[1]),tt.tapAngle.value=Math.random()*Math.PI*2,tt.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(s),this.sceneBundlesEnabled&&this._lightShadowStateDirty&&(this._lightShadowStateDirty=!1,this._updateSceneBundle(s,t)),tt.unjitteredProjection.value.copy(t.projectionMatrix);let d=this.temporalAAEnabled?this.taaHistory:null;if(d){let v=this.getDrawingBufferSize(Tv);d.beginJitter(t,v.x,v.y)}this._renderShadowMaskPass(s,t),tt.orthographicUniform.value=t.projectionMatrix.elements[11]===0?1:0;let c=o.shapeBlendIntances.length>0?AK:null;if(c!==null)for(let v of o.shapeBlendIntances)c(v).update(v,this,t);let p=o.hairInstances.length>0?SK:null;if(p!==null)for(let v of o.hairInstances)p(v).update(v,this);o.needsTransmission()&&this._renderTransmissionPass(s,t),o.needsNormal()&&this._renderNormalPass(s,t,o.normalPassNeeds()),s.overrideMaterial=o.wireframeState?M4:null,t.layers.enable(3),t.layers.enable(8),t.layers.enable(4);let f=s.data.ao,m=f.occlusion&&!kj&&!Cy.enabled;if(tt.aoEnabled.value=m,tt.aoEnabledUniform.value=m?1:0,m){let v=this,y=v._skippedAsyncDraws??0;this._renderAOPass(s,t,f),(v._skippedAsyncDraws??0)>y&&(tt.aoEnabledUniform.value=0)}if(!bN&&o.needsReflection()?(this._renderReflectionPass(s,t),Wj?tt.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(s,t),this._renderReflectionResolvePass(s,t)):tt.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(s,t),this.pipeline.isUIOverlayEnabled&&s.uiCanvas?.enabled&&s.uiCanvas.texture&&s.uiCanvas.texture.image.width>0){let v=this.getPixelRatio();(s.uiCanvas.width!==this.viewportWidth||s.uiCanvas.height!==this.viewportHeight||s.uiCanvas.dpr!==v)&&s.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},v),s.uiCanvas.render(this),this.pipeline.uiCanvasTexture=s.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=s,this.pipeline.camera=t;let g=jMe(s.postprocessing);if(this.pipeline.postprocessingState!==g&&this.pipeline.updatePostprocessing(g),this.pipeline.render(),d?.endJitter(),this._skySystem?.endFrame?.(),Si.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates){let v=(this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled,y=this.info.asyncCompilation?.promotions??0,_=y!==this._shadowSyncPromotions;this._shadowSyncPromotions=y,o.shadowsDirty=this._shadowMapMissingAtSync||this._warmupInFlight||v||_}t instanceof Kn&&t.copyHistory(),s.visible=a}_fitDirectionalShadowRange(e,t,i){if(i===0)return;let r=e.shadow.camera,n=e.shadow;n.__speRangeEnvelope||(n.__speRangeEnvelope={near:r.near,far:r.far});let s=n.__speRangeEnvelope.near,a=e.data?.depth??n.__speRangeEnvelope.far;if(n.__speRangeEnvelope.far=a,$_.setFromMatrixPosition(e.matrixWorld),e.target?(e.target.updateMatrixWorld(),vN.setFromMatrixPosition(e.target.matrixWorld)):vN.set(0,0,0),Mv.subVectors(vN,$_),Mv.lengthSq()<1e-10)return;Mv.normalize();let o=1/0,l=-1/0;for(let c=0;c<i;c++){let p=4*c,f=(t[p]-$_.x)*Mv.x+(t[p+1]-$_.y)*Mv.y+(t[p+2]-$_.z)*Mv.z,m=t[p+3];f-m<o&&(o=f-m),f+m>l&&(l=f+m)}let h=Math.max(10,.05*(l-o)),u=25*Math.floor((o-h)/25),d=25*Math.ceil((l+h)/25);u=Math.max(u,s),d=Math.min(d,a),d-u>=1&&(r.near!==u||r.far!==d)&&(r.near=u,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(e){let t=0;return e.traverseVisible(i=>{let r=i;if(r.castShadow!==!0&&r.receiveShadow!==!0)return;if(r.isHairSystem===!0){let l=r.shadowBoundsRadius??0;if(l>0){r.getShadowBoundsCenter?r.getShadowBoundsCenter(ac):ac.setFromMatrixPosition(r.matrixWorld);let h=4*t;oc[h]=ac.x,oc[h+1]=ac.y,oc[h+2]=ac.z,oc[h+3]=l,t++}return}if(r.isMesh!==!0||!r.geometry||r.isInstanceGroup===!0)return;let n=r.geometry.boundingSphere;n===null&&(r.geometry.computeBoundingSphere(),n=r.geometry.boundingSphere);let s=r;if(s.isInstancedMesh===!0&&(s.boundingSphere===null&&s.computeBoundingSphere(),n=s.boundingSphere??n),!n||!Number.isFinite(n.radius)||n.radius<=0)return;ac.copy(n.center).applyMatrix4(r.matrixWorld),X2.setFromMatrixScale(r.matrixWorld);let a=n.radius*Math.max(Math.abs(X2.x),Math.abs(X2.y),Math.abs(X2.z)),o=4*t;oc[o]=ac.x,oc[o+1]=ac.y,oc[o+2]=ac.z,oc[o+3]=a,t++}),t}_syncLightState(e){let t=wy.isSoft(e.data.shadow);Wme(t),Si.shadowTypeSoft=t,function(d){switch(d){case"low":af=8;break;case"high":af=32;break;default:af=16}}(e.data.shadow?.softShadowQuality),t&&w$()&&(zO||(this.initTexture?.(m$()),zO=!0));let i=-1;Si.pcssLights=0,Si.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,Si.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,n=tt.toonLightData.array,s=0;!Cy.enabled&&!yN&&fSe(e)&&(e.scene.shadowsDirty=!0);let a=this.manageShadowUpdates,o=e.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1;let l=-2128831035,h=d=>{l^=0|d,l=Math.imul(l,16777619)};e.traverseVisible(d=>{let c=d;if(function(p){if(!p.isPointLight&&!p.isSpotLight&&!p.isDirectionalLight)return!1;if(Cy.enabled){if(p.castShadow===!0)return p.castShadow=!1,WO.add(p),!0}else if(WO.has(p)&&(WO.delete(p),p.castShadow===!1))return p.castShadow=!0,!0;return!1}(c)&&(e.scene.shadowsDirty=!0),a&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.shadow&&(c.shadow.autoUpdate=o,o&&c.castShadow===!0&&!this._shadowMapRendered(c.shadow)&&(this._shadowMapMissingAtSync=!0)),yN&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&(c.castShadow=!1),(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&(h(d.id),h(c.castShadow===!0?1:0),h(this._shadowMapId(c.shadow?.map))),c.isPointLight&&c.castShadow&&c.shadow&&(function(p){p.filterNode!==void 0&&p.filterNode!==null?p.filterNode!==k4&&Si.pcssForeignFilter++:(p.filterNode=k4,Si.pcssInstalled++)}(c.shadow),jme(c.shadow),Si.pcssLights++),(c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&c.shadow){c.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(e)),this._fitDirectionalShadowRange(c,oc,i)),function(m){m.filterNode!==void 0&&m.filterNode!==null?m.filterNode!==z4&&Si.pcssForeignFilter++:(Object.defineProperty(m,"penumbraSize",{get:()=>c.data?.penumbraSize??.5,configurable:!0}),m.filterNode=z4,Si.pcssInstalled++)}(c.shadow);let p,f=!a||o||c.shadow.needsUpdate===!0;if(t&&w$()&&(f?function(m){let g=m;g.__spePcssPyramid&&(g.__spePcssPyramid.fresh=!1)}(c.shadow):Gme(c.shadow)||function(m,g){let v=g,y=v.map?.depthTexture??null;if(y==null)return!1;let _=Vme(g);if(function(T){let M=Vme(T);if(M.slot>=0)return M.slot;for(let E=0;E<B4;E++){let A=UO[E];if(A===null||A.deref()===void 0)return UO[E]=new WeakRef(T),M.slot=E,E}return-1}(g)<0)return!1;let b=Math.max(1,Math.round(v.mapSize?.x??2048)),x=_.slot*Pf,w=`${y.uuid}:${b}`;_.passKey!==w&&(_.toMid?.material?.dispose(),_.toSmall?.material?.dispose(),_.mid===null&&(_.mid=f$(Yb,Yb),_.mid.texture.name="SplinePCSSPyramidMid"),_.small===null&&(_.small=f$(Pf,Pf),_.small.texture.name="SplinePCSSPyramidSmall"),_.toMid=new Cn(kme(`SplinePCSSPyramidToMid${b}`,y,Math.ceil(b/Yb),b-1,!1,0)),_.toSmall=new Cn(kme("SplinePCSSPyramidToSmall",_.mid.texture,Yb/Pf,Yb-1,!0,0)),_.passKey=w),m$();let S=m.getRenderTarget();m.setRenderTarget(_.mid),_.toMid.render(m),m.setRenderTarget(_.small),_.toSmall.render(m),m.setRenderTarget(S),_$.set(x,0,0),m.copyTextureToTexture(_.small.texture,Ay.texture,null,_$),_.fresh=!0,Si.pcssPyramidBuilds++}(this,c.shadow),p={slot:HUe(c.shadow),fresh:Gme(c.shadow)}),t&&S$()&&(pMe(c.shadow,-1),this._maskLights.push({light:c,shadow:c.shadow}),(f||c.shadow.map==null)&&(this._maskBlocked=!0)),jme(c.shadow,c.data?.penumbraSize??.5,p)&&Si.pcssPyramidActive++,!r){r=!0;let m=c.shadow;Si.pcssRadius0=m.radius??-1,Si.pcssPenumbra0=m.penumbraSize??-1}Si.pcssLights++}if(!(s>=Zq)){if(c.isPointLight||c.isSpotLight)H_.setFromMatrixPosition(c.matrixWorld),n[s].set(H_.x,H_.y,H_.z,0),s++;else if(c.isDirectionalLight&&c.target){c.target.updateMatrixWorld();let p=H_;p.setFromMatrixPosition(c.matrixWorld),p.sub(hge.setFromMatrixPosition(c.target.matrixWorld)).normalize(),n[s].set(p.x,p.y,p.z,1),s++}}}),tt.toonLightCount.value=s;let u=this._lightShadowSignatures.get(e);this._lightShadowSignatures.set(e,l),this._lightShadowStateDirty=u!==void 0&&u!==l}_shadowMapId(e){if(e==null)return 0;let t=this._shadowMapIds.get(e);return t===void 0&&(t=++this._shadowMapIdSeq,this._shadowMapIds.set(e,t)),t}_renderShadowMaskPass(e,t){let i=0;if(S$()&&!this.suppressShadowMask&&this.manageShadowUpdates&&!this._maskBlocked&&this._maskLights.length>=1&&this._maskLights.length<=4&&this._maskLights.every(r=>r.shadow.map?.depthTexture!=null)){this._shadowMask??(this._shadowMask=new xMe);let{targetsChanged:r}=this._shadowMask.render(this,e,t,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}tt.shadowMaskEnabled.value=i>0?1:0,Si.shadowMaskActive=i}retireRenderTarget(e){e&&this._retiredGrabTargets.push(e),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let e of this._retiredGrabTargets)e.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let e of this._retiredGpuBuffers)try{e.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let e of this._liveBundledPages())this._bundleStates.get(e)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let e=this.backend,t=this._retiredGpuBuffers;e.destroyUniformBuffer=r=>{let n=e.get(r);n?.buffer&&t.push(n.buffer),e.delete(r),this._retireBundleRecords()};let i=e.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=n=>{let s=e.get(r(n));s?.buffer&&t.push(s.buffer),e.delete(n),this._retireBundleRecords()}}}_reallocGrabTarget(e,t,i,r){return e&&e.width===t&&e.height===i?e:(this.retireRenderTarget(e),r())}_shadowMapRendered(e){return e.map!=null&&this._textures.get(e.map).initialized===!0}_withShadowUpdatesSuspended(e,t){let i=[];e.traverse(r=>{let n=r;if(n.isLight&&n.shadow){if(!this._shadowMapRendered(n.shadow))return;i.push({shadow:n.shadow,auto:n.shadow.autoUpdate,needs:n.shadow.needsUpdate}),n.shadow.autoUpdate=!1,n.shadow.needsUpdate=!1}});try{t()}finally{for(let r of i)r.shadow.autoUpdate=r.auto,r.shadow.needsUpdate=r.needs}}_renderPrepass(e,t){this._withShadowUpdatesSuspended(e,()=>{this.render(e,t)})}_renderAOPass(e,t,i){let r=this.getDrawingBufferSize(Tv),n=Math.max(1,Math.round(r.x)),s=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,n,s,()=>new Fi(n,s,{depthBuffer:!1})),tt.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new nMe);let a=e;this._hbao.render(this,e,t,{radius:i.radius,bias:i.bias??.5,aoFullRes:i.aoFullRes===!0,aoColor:a.aoColor??{r:0,g:0,b:0},fogEnabled:(a.fog??null)!==null,fogNear:a.backupFog?.near??1,fogFar:a.backupFog?.far??1e3,fogMode:Xn.getModeIndex({mode:e.fogMode}),fogDensity:e.fogDensity??Xn.getDensity({}),fogHeightFalloff:e.fogHeightFalloff??Xn.getHeightFalloff({}),fogHeightBase:e.fogHeightBase??Xn.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(e,t,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",n=this.getDrawingBufferSize(Tv),s=Math.max(1,Math.round(n.x)),a=Math.max(1,Math.round(n.y));this._normalTarget!==void 0&&this._normalTargetFlavor!==r&&(this.retireRenderTarget(this._normalTarget),this._normalTarget=void 0),this._normalTargetFlavor=r,this._normalTarget=this._reallocGrabTarget(this._normalTarget,s,a,()=>{let p=new Fi(s,a,{count:r==="both"?2:1,type:r==="normals"?li:Gt,depthTexture:new ns(s,a)});r==="both"&&(p.textures[0].name="g0",p.textures[1].name="g1",p.textures[1].type=li);for(let f of p.textures)f.minFilter=gt,f.magFilter=gt;return p});let o=this._encodeMaterials[r];if(o===void 0){this._depthContrastUniform??(this._depthContrastUniform=Be(1));let p=new Jt;p.name=`SplineNormalPassEncode_${r}`;let f=tZ(),m=()=>{let v=Ft(KA),y=JB.sub(.5).mul(this._depthContrastUniform).add(.5),_=lt(lt(f,v,.2),Q(y),.4);return Ae(_,f.x)},g=()=>{let v=Ft(To),y=Xi(u2e,v,v.negate());return Ae(y,f.x)};p.fragmentNode=r==="both"?gw({g0:m(),g1:g()}):r==="normals"?g():m(),p.lights=!1,p.blending=yi,p.needsUpdate=!0,this._encodeMaterials[r]=p,o=p}this._depthContrastUniform.value=t instanceof Kn?(t.far-t.near)/1e4:1;let l=e.overrideMaterial,h=this.getRenderTarget(),u=this.getClearColor(uge),d=this.getClearAlpha();t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),e.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(e,t),this.setRenderTarget(h),this.setClearColor(u,d),e.overrideMaterial=l,t.layers.enable(0),t.layers.enable(3);let c=this._normalTarget.textures;tt.normalRenderTarget.value=r==="normals"?Hl:c[0],tt.normalRenderTargetDepth.value=this._normalTarget.depthTexture,tt.normalViewRenderTarget.value=r==="both"?c[1]:r==="normals"?c[0]:Hl}blitTextureToTarget(e,t){let i=this._uiBlitPass;if(!i){let s=mt(Hl),a=new Jt;a.name="SplineUICanvasBlit",a.fragmentNode=s.sample(Hi()),a.lights=!1,a.blending=yi,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,i={quad:new Cn(a),input:s},this._uiBlitPass=i}let r=this.getRenderTarget(),n=this.getMRT();i.input.value=e,this.setMRT(null),this.setRenderTarget(t),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(n)}_getPrefilterPass(e){this._prefilterPasses||(this._prefilterPasses=[]);let t=this._prefilterPasses[e];if(t)return t;let i=mt(Hl),r=Be(new Z(1,0)),n=new Jt;n.name="SplineTransmissionPrefilter";let s=Hi(),a=r,o=h=>i.sample(s.add(a.mul(h))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return n.fragmentNode=Ae(l,1),n.lights=!1,n.blending=yi,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,t={quad:new Cn(n),input:i,step:r},this._prefilterPasses[e]=t,t}_getDownsamplePass(e){this._downsamplePasses||(this._downsamplePasses=[]);let t=this._downsamplePasses[e];return t||(t=this._buildDownsamplePassEntry(Gj,"SplineTransmissionDownsample"),this._downsamplePasses[e]=t,t)}_buildDownsamplePassEntry(e,t){let i=mt(Hl),r=Be(new Z(1,1)),n=new Jt;n.name=t;let s=Hi(),a=r,o=(h,u)=>i.sample(s.add(Se(h,u).mul(a))).rgb,l=null;if(e==="k4")for(let h=-1;h<=1;h++)for(let u=-1;u<=1;u++){let d=(u===0?2:1)*(h===0?2:1)/16,c=o(u,h).mul(d);l=l?l.add(c):c}else{let h=[-1.5,-.5,.5,1.5],u=[.1665,.3335,.3335,.1665];for(let d=0;d<4;d++)for(let c=0;c<4;c++){let p=u[c]*u[d],f=o(h[c],h[d]).mul(p);l=l?l.add(f):f}}return n.fragmentNode=Ae(l,1),n.lights=!1,n.blending=yi,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,{quad:new Cn(n),input:i,step:r}}_getPlanarDownsamplePass(e){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let t=this._planarDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[e]=t,t)}_batchedMipCopies(e){let t=this.backend,i=t?.device;if(!i||typeof t?.get!="function"){for(let s of e)this.copyTextureToTexture(s.src,s.dst,null,null,0,s.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),n=0;for(let s of e){let a=t.get(s.src)?.texture,o=t.get(s.dst)?.texture;a&&o?(r.copyTextureToTexture({texture:a,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:o,mipLevel:s.dstLevel,origin:{x:0,y:0,z:0}},{width:s.width,height:s.height,depthOrArrayLayers:1}),n++):this.copyTextureToTexture(s.src,s.dst,null,null,0,s.dstLevel)}n>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(e){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let t=this._reflectionDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[e]=t,t)}_renderTransmissionPass(e,t){let i=this.getDrawingBufferSize(Tv),r=this.hdTransmission?1:2,n=Math.max(1,Math.round(i.x/r)),s=Math.max(1,Math.round(i.y/r)),a=this.backend?.isWebGPUBackend===!0?_N:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,n,s,()=>{let u=new Fi(n,s,{depthBuffer:!0}),d=u.texture;return a==="off"?(d.generateMipmaps=!0,d.minFilter=Rn):(d.generateMipmaps=!1,d.minFilter=it),d.magFilter=it,u});let o=[];e.traverse(u=>{let d=u;if(!(d.isMesh||d.isLine||d.isPoints||d.isSprite))return;let c=d.layers;c&&8&c.mask&&c.mask!==8&&(o.push({layers:c,mask:c.mask}),c.mask=8)});let l=this.getRenderTarget();t.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(e,t),this.setRenderTarget(l),t.layers.enable(3);for(let u of o)u.layers.mask=u.mask;let h=this._transmissionTarget.texture;if(a!=="off"){let u=(m,g)=>{let v=new Fi(m,g,{depthBuffer:!1});return v.texture.generateMipmaps=!1,v.texture.minFilter=it,v.texture.magFilter=it,v};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,n,s,()=>u(n,s));let d=Math.floor(Math.log2(Math.max(n,s)))+1,c=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,n,s,()=>{let m=new Fi(n,s,{depthBuffer:!1}),g=m.texture;return g.minFilter=Rn,g.magFilter=it,a==="base"?g.generateMipmaps=!0:(g.generateMipmaps=!1,g.mipmaps=Array.from({length:d},(v,y)=>({width:Math.max(1,n>>y),height:Math.max(1,s>>y)}))),m}),a==="full"&&this._transmissionBlurTarget!==c&&this.initTexture(this._transmissionBlurTarget.texture);let p=this._getPrefilterPass(0);p.input.value=this._transmissionTarget.texture,p.step.value.set(1/n,0),this.setRenderTarget(this._transmissionBlurTmp),p.quad.render(this);let f=this._getPrefilterPass(1);if(f.input.value=this._transmissionBlurTmp.texture,f.step.value.set(0,1/s),a==="base")this.setRenderTarget(this._transmissionBlurTarget),f.quad.render(this);else{for(let m=0;m<d;m++)this._transmissionChain[m]=this._reallocGrabTarget(this._transmissionChain[m],Math.max(1,n>>m),Math.max(1,s>>m),()=>u(Math.max(1,n>>m),Math.max(1,s>>m)));for(let m=d;m<this._transmissionChain.length;m++)this._transmissionChain[m]?.dispose(),this._transmissionChain[m]=void 0;this._transmissionChain.length=d,this.setRenderTarget(this._transmissionChain[0]),f.quad.render(this);for(let m=1;m<d;m++){let g=this._transmissionChain[m-1],v=this._getDownsamplePass(m-1);v.input.value=g.texture,v.step.value.set(1/g.width,1/g.height),this.setRenderTarget(this._transmissionChain[m]),v.quad.render(this)}for(let m=0;m<d;m++)this.copyTextureToTexture(this._transmissionChain[m].texture,this._transmissionBlurTarget.texture,null,null,0,m)}this.setRenderTarget(l),h=this._transmissionBlurTarget.texture}tt.transmissionRenderTarget.value=h,tt.transmissionActualSize.value.set(n,s),tt.aspectRatio.value=i.x>=i.y?tt.aspectRatio.value.set(i.y/i.x,1):tt.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(e,t,i){if(this._reflectionDepthPasses)for(let n of this._reflectionDepthPasses)n?.quad.material?.dispose();let r=[];{let n=new Jt;n.name="SplineReflectionDepthBlit";let s=mt(this._reflectionTarget.depthTexture);n.fragmentNode=Ae(Q(s.sample(Hi())),1),n.lights=!1,n.blending=yi,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,r.push({quad:new Cn(n)})}for(let n=1;n<i;n++){let s=Math.max(1,e>>n-1),a=Math.max(1,t>>n-1),o=new Jt;o.name=`SplineReflectionDepthMin${n}`;let l=mt(this._reflectionDepthChain[n-1].texture),h=Zo,u=Pe(h.x).mul(2),d=Pe(h.y).mul(2),c=(v,y)=>l.load(Va(u.add(v),d.add(y))).x,p=(v,y)=>Li(v,y),f=p(p(c(0,0),c(1,0)),p(c(1,1),c(0,1))),m=!!(1&s),g=!!(1&a);m&&(f=p(f,p(c(2,0),c(2,1)))),g&&(f=p(f,p(c(0,2),c(1,2)))),m&&g&&(f=p(f,c(2,2))),o.fragmentNode=Ae(Q(f),1),o.lights=!1,o.blending=yi,o.depthTest=!1,o.depthWrite=!1,o.needsUpdate=!0,r.push({quad:new Cn(o)})}this._reflectionDepthPasses=r}_renderReflectionPass(e,t){let i=this.getDrawingBufferSize(Tv),r=1/0,n=0,s=0;e.traverse(x=>{let w=x;if(!(w.isMesh&&16&w.layers.mask))return;let S=this._reflectiveMeshCoverage(w,t,i.y),T=Array.isArray(w.material)?w.material:[w.material];for(let M of T){if(!M?.layers)continue;let E=cFe(M);!E||(r=Math.min(r,E.min*S.scale),n=Math.max(n,E.max*S.scale),E.max*S.scale>.45&&(s=Math.max(s,S.diameterPx)))}});let a=1;if($j&&r!==1/0)for(r>=6?a=4:r>=2&&(a=2);a>1&&s>0&&s/a<128;)a>>=1;let o=Math.max(1,Math.round(i.x/a)),l=Math.max(1,Math.round(i.y/a)),h=Math.floor(Math.log2(Math.max(o,l)))+1,u=this.backend?.isWebGPUBackend===!0&&qj;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let x=new Fi(o,l,{depthTexture:new ns(o,l)});return u?(x.texture.generateMipmaps=!1,x.texture.minFilter=it):(x.texture.generateMipmaps=!0,x.texture.minFilter=Rn),x.texture.magFilter=it,x});let d=(x,w)=>{let S=new Fi(x,w,{depthBuffer:!1,type:Gt,format:aa});return S.texture.generateMipmaps=!1,S.texture.minFilter=gt,S.texture.magFilter=gt,S},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let x=d(o,l);return x.texture.mipmaps=Array.from({length:h},(w,S)=>({width:Math.max(1,o>>S),height:Math.max(1,l>>S)})),x}),this._reflectionDepthPyramid!==c&&this.initTexture(this._reflectionDepthPyramid.texture);for(let x=0;x<h;x++)this._reflectionDepthChain[x]=this._reallocGrabTarget(this._reflectionDepthChain[x],Math.max(1,o>>x),Math.max(1,l>>x),()=>d(Math.max(1,o>>x),Math.max(1,l>>x)));for(let x=h;x<this._reflectionDepthChain.length;x++)this._reflectionDepthChain[x]?.dispose(),this._reflectionDepthChain[x]=void 0;this._reflectionDepthChain.length=h;let p=this.auxiliary||this._skySystem?.attached!==!0?null:this._skySystem.environmentTexture??null,f=tt.reflectionEnvMap,m=p??Dc;!this.auxiliary&&f.value!==m&&(f.value=m,this._grabTargetEpoch++),tt.reflectionEnvEnabled.value=p!==null?1:0;let g=this.getClearColor(dge);tt.reflectionMissColor.value.set(g.r,g.g,g.b);let v=[];e.traverse(x=>{let w=x;if(!(w.isMesh||w.isLine||w.isPoints||w.isSprite))return;let S=w.layers;S&&16&S.mask&&S.mask!==16&&(v.push({layers:S,mask:S.mask}),S.mask=16)});let y=this.getRenderTarget();t.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(e,t),t.layers.enable(4);for(let x of v)x.layers.mask=x.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,h),this._reflectionPassesKey=`${o}x${l}`);let _=this._reflectionDepthPasses;for(let x=0;x<h;x++)this.setRenderTarget(this._reflectionDepthChain[x]),_[x].quad.render(this);this._batchedMipCopies(Array.from({length:h},(x,w)=>({src:this._reflectionDepthChain[w].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:w,width:Math.max(1,o>>w),height:Math.max(1,l>>w)})));let b=this._reflectionTarget.texture;if(u){let x=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let T=new Fi(o,l,{depthBuffer:!1}),M=T.texture;return M.minFilter=Rn,M.magFilter=it,M.generateMipmaps=!1,M.mipmaps=Array.from({length:h},(E,A)=>({width:Math.max(1,o>>A),height:Math.max(1,l>>A)})),T}),this._reflectionColorPyramid!==x&&this.initTexture(this._reflectionColorPyramid.texture);let w=n>0?h:1,S=(T,M)=>{let E=new Fi(T,M,{depthBuffer:!1});return E.texture.generateMipmaps=!1,E.texture.minFilter=it,E.texture.magFilter=it,E};for(let T=1;T<w;T++)this._reflectionColorChain[T]=this._reallocGrabTarget(this._reflectionColorChain[T],Math.max(1,o>>T),Math.max(1,l>>T),()=>S(Math.max(1,o>>T),Math.max(1,l>>T)));for(let T=w;T<this._reflectionColorChain.length;T++)this._reflectionColorChain[T]?.dispose(),this._reflectionColorChain[T]=void 0;this._reflectionColorChain.length=w;for(let T=1;T<w;T++){let M=T===1?this._reflectionTarget:this._reflectionColorChain[T-1],E=this._getReflectionDownsamplePass(T-1);E.input.value=M.texture,E.step.value.set(1/M.width,1/M.height),this.setRenderTarget(this._reflectionColorChain[T]),E.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:w-1},(T,M)=>({src:this._reflectionColorChain[M+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:M+1,width:Math.max(1,o>>M+1),height:Math.max(1,l>>M+1)}))]),b=this._reflectionColorPyramid.texture}this.setRenderTarget(y),tt.reflectionRenderTarget.value=b,tt.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,tt.reflectionDepthSize.value.set(o,l),tt.reflectionDepthLevels.value=h,this._reflectionGrabInfo={div:a,w:o,h:l,minBlur:r,maxBlur:n}}_reflectiveMeshCoverage(e,t,i){let r=e.geometry;if(!r)return{diameterPx:i,scale:1};r.boundingSphere===null&&r.computeBoundingSphere();let n=r.boundingSphere;if(!n)return{diameterPx:i,scale:1};let s=e.matrixWorld.elements,a=Math.sqrt(Math.max(s[0]*s[0]+s[1]*s[1]+s[2]*s[2],s[4]*s[4]+s[5]*s[5]+s[6]*s[6],s[8]*s[8]+s[9]*s[9]+s[10]*s[10])),o=n.radius*a;Fj.copy(n.center).applyMatrix4(e.matrixWorld);let l=t.projectionMatrix.elements[5]*i/2,h=1;t.isPerspectiveCamera===!0&&(Uj.setFromMatrixPosition(t.matrixWorld),h=Math.max(Fj.distanceTo(Uj),t.near??.1));let u=2*o*l/h;return{diameterPx:u,scale:Math.min(1,u/(.66*i))}}_renderReflectionResolvePass(e,t){let i=this._reflectionGrabInfo,r=this.backend?.isWebGPUBackend===!0&&Xj&&i!==void 0&&i.maxBlur>.45;if(r){let b=!0;e.traverse(x=>{let w=x;if(!(w.isMesh&&16&w.layers.mask))return;let S=Array.isArray(w.material)?w.material:[w.material],T=null;for(let M of S)if(M?.layers&&(T=pFe(M),T!==null))break;T!=="variable"?T!==null?(w.userData.__srMode=T.blur>.45?1+T.tracingMode:0,w.userData.__srBlur=T.blur*this._reflectiveMeshCoverage(w,t,this.getDrawingBufferSize(pge).y).scale,w.userData.__srThickness=T.thickness,w.userData.__srStepSize=T.stepSize,w.userData.__srSteps=T.steps):w.userData.__srMode=0:b=!1}),r=b}let n=r?i.w:4,s=r?i.h:4,a=(b,x)=>()=>{let w=new Fi(b,x,{type:li,depthBuffer:!1});return w.texture.generateMipmaps=!1,w.texture.minFilter=it,w.texture.magFilter=it,w};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,n,s,a(n,s)),tt.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(tt.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let b=new Fi(o,l,{count:2,type:li,depthTexture:new ns(o,l)});for(let x of b.textures)x.generateMipmaps=!1,x.minFilter=gt,x.magFilter=gt;return b.textures[0].name="g0",b.textures[1].name="g1",b}),this._reflectionResolveMarchTarget=this._reallocGrabTarget(this._reflectionResolveMarchTarget,o,l,a(o,l)),this._reflectionResolveBlurTmp=this._reallocGrabTarget(this._reflectionResolveBlurTmp,o,l,a(o,l)),!this._reflectionGBufferMaterial){let b=new Jt;b.name="SplineReflectionGBuffer";let x=_g("__splinePlanarMirror","float"),w=tt.reflectionPlanarEnabled.greaterThan(.5),S=_g("__srMode","float"),T=Xi(x.greaterThan(.5).and(w),L(0),S);b.fragmentNode=gw({g0:Ae(Ft(To),T),g1:Ae(_g("__srBlur","float"),_g("__srThickness","float"),_g("__srStepSize","float"),_g("__srSteps","float"))}),b.lights=!1,b.blending=yi,b.needsUpdate=!0,this._reflectionGBufferMaterial=b}let h=this._skippedAsyncDraws??0,u=e.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(cge),p=this.getClearAlpha(),f=t.layers.mask;e.overrideMaterial=this._reflectionGBufferMaterial,t.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(e,t),e.overrideMaterial=u,t.layers.mask=f,this.setClearColor(c,p);let m=tt.reflectionRenderTarget.value,g=tt.reflectionEnvMap.value,v=this._reflectionGBufferTarget,y=`${o}x${l}|${v.textures[0].uuid}|${m.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${g.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;y!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(m,g,o,l),this._reflectionResolveMarchKey=y);let _=this._reflectionResolveMarch;_.proj.value.copy(t.projectionMatrix),_.projInv.value.copy(t.projectionMatrix).invert(),_.camWorld.value.copy(t.matrixWorld),_.near.value=t.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),_.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),tt.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>h&&(tt.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(e,t,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let n=Be(new De),s=Be(new De),a=Be(new De),o=Be(.1),l=this._reflectionGBufferTarget,h=mt(l.textures[0]),u=mt(l.textures[1]),d=mt(l.depthTexture),c=mt(e),p=mt(this._reflectionDepthPyramid.texture),f=mt(t),m=new Jt;m.name="SplineReflectionResolve";let g=He(()=>{let b=Zo,x=Va(Pe(b.x),Pe(b.y)),w=Hi(),S=h.load(x).toVar(),T=d.sample(w).toVar(),M=Ae(0).toVar(),E=L(0).toVar();return ze(S.w.greaterThan(.5),()=>{let A=u.load(x).toVar(),C=Yv(s,w.x,w.y,T),D=rZ({dials:{blur:A.x,thickness:A.y,stepSize:A.z,steps:Pe(A.w),tracingMode:S.w.sub(1)},surface:{originView:C,normalV:Ft(S.xyz),screenUv:w,fragWindowZ:T},camera:{projectionMatrix:n,projectionMatrixInverse:s,worldMatrix:a,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:f},usePlanar:JTe(!1),noisePixel:Se(x),singleRay:{footprintOut:E}});M.assign(Ae(D,E.add(1)))}),M});m.fragmentNode=g(),m.lights=!1,m.blending=yi,m.depthTest=!1,m.depthWrite=!1,m.needsUpdate=!0,this._reflectionResolveMarch={quad:new Cn(m),proj:n,projInv:s,camWorld:a,near:o};let v=mt(this._reflectionResolveMarchTarget.texture),y=mt(this._reflectionResolveBlurTmp.texture),_=b=>{let x=new Jt;x.name=`SplineReflectionResolveBlur${b.toUpperCase()}`;let w=b==="x"?v:y,S=b==="x"?1/i:1/r,T=He(()=>{let M=Hi(),E=v.sample(M).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),A=Ae(0).toVar(),C=0;for(let D=-6;D<=6;D++){let R=Math.exp(D/3*-.5*(D/3));C+=R;let I=b==="x"?Se(E.mul(D/6*S),0):Se(0,E.mul(D/6*S)),U=w.sample(M.add(I)).toVar(),O=b==="x"?U.w.min(1):U.w;A.addAssign(Ae(U.rgb,O).mul(R))}return A.div(C)});return x.fragmentNode=T(),x.lights=!1,x.blending=yi,x.depthTest=!1,x.depthWrite=!1,x.needsUpdate=!0,new Cn(x)};this._reflectionResolveBlur={h:_("x"),v:_("y")}}_renderPlanarReflectionPass(e,t){let i=null;if(e.traverse(f=>{let m=f;if(!(m.isMesh&&16&m.layers.mask&&(m.userData.__splinePlanarMirror=0,(Array.isArray(m.material)?m.material:[m.material]).some(A=>A?.layers&&A.getLayersOfType("reflection").some(C=>C.data.visible&&C.data.mirror===1)))))return;let g=m.geometry;if(!g)return;g.boundingBox===null&&g.computeBoundingBox();let v,y,_=g.boundingBox,b=_.max.x-_.min.x,x=_.max.y-_.min.y,w=_.max.z-_.min.z,S=m.matrixWorld.elements,T=Math.hypot(S[0],S[1],S[2]),M=Math.hypot(S[4],S[5],S[6]),E=Math.hypot(S[8],S[9],S[10]);b<=x&&b<=w?(v=fge,y=x*M*(w*E)):x<=b&&x<=w?(v=mge,y=b*T*(w*E)):(v=gge,y=b*T*(x*M)),(!i||y>i.area)&&(i={mesh:m,normalAxis:v,area:y})}),!i)return void(tt.reflectionPlanarEnabled.value=0);let r=i.mesh,n=i.mesh.matrixWorld;if(Ip.copy(i.normalAxis).transformDirection(n),Hm.setFromMatrixPosition(n),q2.setFromMatrixPosition(t.matrixWorld),qm.subVectors(Hm,q2),qm.dot(Ip)>0&&Ip.negate(),qm.dot(Ip)>0)return void(tt.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==t.type)&&(this._planarVirtualCamera=t.clone());let s=this._planarVirtualCamera;if(qm.subVectors(Hm,q2),qm.reflect(Ip).negate(),qm.add(Hm),gN.extractRotation(t.matrixWorld),zj.set(0,0,-1).applyMatrix4(gN).add(q2),$2.subVectors(Hm,zj),$2.reflect(Ip).negate(),$2.add(Hm),s.position.copy(qm),s.up.set(0,1,0).applyMatrix4(gN),s.up.reflect(Ip),s.lookAt($2),s.updateMatrixWorld(),s.projectionMatrix.copy(t.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),t.isPerspectiveCamera===!0){Sv.setFromNormalAndCoplanarPoint(Ip,Hm),Sv.applyMatrix4(s.matrixWorldInverse),sc.set(Sv.normal.x,Sv.normal.y,Sv.normal.z,Sv.constant);let f=s.projectionMatrix.elements;q_.x=(Math.sign(sc.x)+f[8])/f[0],q_.y=(Math.sign(sc.y)+f[9])/f[5],q_.z=-1,q_.w=(1+f[10])/f[14],sc.multiplyScalar(1/sc.dot(q_)),f[2]=sc.x,f[6]=sc.y,f[10]=sc.z,f[14]=sc.w}let a=this.getDrawingBufferSize(vge),o=Math.max(1,Math.round(a.x)),l=Math.max(1,Math.round(a.y)),h=this.backend?.isWebGPUBackend===!0&&Hj;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let f=new Fi(o,l);return h?(f.texture.generateMipmaps=!1,f.texture.minFilter=it):(f.texture.generateMipmaps=!0,f.texture.minFilter=Rn),f.texture.magFilter=it,f});let u=[];e.traverse(f=>{let m=f;if(!(m.isMesh||m.isLine||m.isPoints||m.isSprite))return;let g=m.layers;g&&16&g.mask&&g.mask!==16&&(u.push({layers:g,mask:g.mask}),g.mask=16)}),s.layers.mask=-17&t.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(e,s),this.setRenderTarget(d);for(let f of u)f.layers.mask=f.mask;let c=this._planarTarget.texture;if(h){let f=Math.floor(Math.log2(Math.max(o,l)))+1,m=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let v=new Fi(o,l,{depthBuffer:!1}),y=v.texture;return y.minFilter=Rn,y.magFilter=it,y.generateMipmaps=!1,y.mipmaps=Array.from({length:f},(_,b)=>({width:Math.max(1,o>>b),height:Math.max(1,l>>b)})),v}),this._planarPyramid!==m&&this.initTexture(this._planarPyramid.texture);let g=(v,y)=>{let _=new Fi(v,y,{depthBuffer:!1});return _.texture.generateMipmaps=!1,_.texture.minFilter=it,_.texture.magFilter=it,_};for(let v=1;v<f;v++)this._planarChain[v]=this._reallocGrabTarget(this._planarChain[v],Math.max(1,o>>v),Math.max(1,l>>v),()=>g(Math.max(1,o>>v),Math.max(1,l>>v)));for(let v=f;v<this._planarChain.length;v++)this._planarChain[v]?.dispose(),this._planarChain[v]=void 0;this._planarChain.length=f;for(let v=1;v<f;v++){let y=v===1?this._planarTarget:this._planarChain[v-1],_=this._getPlanarDownsamplePass(v-1);_.input.value=y.texture,_.step.value.set(1/y.width,1/y.height),this.setRenderTarget(this._planarChain[v]),_.quad.render(this)}this.setRenderTarget(d),this._batchedMipCopies([{src:this._planarTarget.texture,dst:this._planarPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:f-1},(v,y)=>({src:this._planarChain[y+1].texture,dst:this._planarPyramid.texture,dstLevel:y+1,width:Math.max(1,o>>y+1),height:Math.max(1,l>>y+1)}))]),c=this._planarPyramid.texture}let p=tt.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),tt.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(e,t,i){let r=this.getDrawingBufferSize(Tv),n=Math.max(1,Math.round(r.x)),s=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,n,s,()=>new Fi(n,s,{depthBuffer:!0}));let a=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget);try{this.renderSplineScene(e,t)}finally{this.setRenderTarget(a)}this.pipeline.sceneTransitionFromTexture=this._transitionCaptureTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i;let o=this.pipeline.sceneTransitionPass.uniforms;o.uDPR.value=this.getPixelRatio(),o.uResolution.value.set(r.x,r.y).divideScalar(this.getPixelRatio())}async captureFrame(e,{includeHelpers:t=!1,settleFrames:i=0}={}){if(this.xr?.isPresenting===!0)return null;let r=this._frameSerial,n=this.getRenderTarget(),s=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled,o=this.suppressShadowMask;this.suppressShadowMask=!0,t||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{let g=qMe();for(let v=0;v<i;v++)g&&this.advanceFrame(),e(),await o5e();g&&this.advanceFrame(),e()}finally{this.suppressShadowMask=o,this.pipeline.renderToScreen=s,this.setRenderTarget(n),a&&this.pipeline.enableHelpers()}if(this._frameSerial===r||this.lastFrameIncomplete)return null;let l=this.pipeline.lastOutputTarget;if(!l||!this.backend.get(l.textures[0])?.textureDescriptorGPU)return null;let h=l.width,u=l.height,d=this,c=new Uint8Array(h*u*4),p=4*h,f=256*Math.ceil(p/256),m=Math.max(1,Math.min(u,Math.floor((1<<20)/f)));for(let g=0;g<u;g+=m){let v=Math.min(m,u-g),y=await d.readRenderTargetPixelsAsync(l,0,g,h,v);if(f===p)c.set(y.subarray(0,v*p),g*p);else for(let _=0;_<v;_++){let b=_*f;c.set(y.subarray(b,b+p),(g+_)*p)}}return{pixels:c,width:h,height:u}}_applyCIOffscreenTargetIfRequested(){if(globalThis.__SPLINE_RENDER_OFFSCREEN__!==!0)return;let e=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),t=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==e||this._ciOffscreenTarget.height!==t)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new Fi(e,t,{depthBuffer:!0})):(this._ciOffscreenTarget=new Fi(e,t,{depthBuffer:!0}),globalThis.__splineReadOffscreenPixels=async()=>{let i=this._ciOffscreenTarget,r=await this.readRenderTargetPixelsAsync(i,0,0,i.width,i.height);return{width:i.width,height:i.height,pixels:Array.from(r)}}),this.getRenderTarget()===null&&this.setRenderTarget(this._ciOffscreenTarget)}dispose(){this._disposeRetiredGrabTargets(),this._disposeWarmupTargets(),lq()?.drainRetired(),uq()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let e of jx){let t=e.deref();t!==void 0&&(t.mid?.dispose(),t.mid=null,t.small?.dispose(),t.small=null,t.toMid?.material?.dispose(),t.toSmall?.material?.dispose(),t.toMid=null,t.toSmall=null,t.passKey="",t.fresh=!1,t.slot=-1)}jx.clear(),UO.fill(null),Ay?.dispose(),Ay=null,zO=!1}(),this._aoRenderTarget?.dispose(),this._aoRenderTarget=void 0,this._normalTarget?.dispose(),this._normalTarget=void 0,this._ciOffscreenTarget?.dispose(),this._ciOffscreenTarget=void 0,this._transitionCaptureTarget?.dispose(),this._transitionCaptureTarget=void 0,this._transmissionTarget?.dispose(),this._transmissionTarget=void 0,this._transmissionBlurTmp?.dispose(),this._transmissionBlurTmp=void 0,this._transmissionBlurTarget?.dispose(),this._transmissionBlurTarget=void 0;for(let e of this._transmissionChain)e?.dispose();this._transmissionChain.length=0,this._reflectionTarget?.depthTexture?.dispose(),this._reflectionTarget?.dispose(),this._reflectionTarget=void 0,this._reflectionColorPyramid?.dispose(),this._reflectionColorPyramid=void 0;for(let e of this._reflectionColorChain)e?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let e of this._reflectionDownsamplePasses)e?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let e of this._planarChain)e?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let e of this._planarDownsamplePasses)e?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let e of this._reflectionDepthChain)e?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let e of this._reflectionDepthPasses)e?.quad.material?.dispose();this._reflectionDepthPasses=void 0}if(this._reflectionPassesKey="",this._reflectionGBufferTarget?.depthTexture?.dispose(),this._reflectionGBufferTarget?.dispose(),this._reflectionGBufferTarget=void 0,this._reflectionResolveMarchTarget?.dispose(),this._reflectionResolveMarchTarget=void 0,this._reflectionResolveBlurTmp?.dispose(),this._reflectionResolveBlurTmp=void 0,this._reflectionResolveTarget?.dispose(),this._reflectionResolveTarget=void 0,this._reflectionGBufferMaterial?.dispose(),this._reflectionGBufferMaterial=void 0,this._reflectionResolveMarch&&(this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveMarch=void 0),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose(),this._reflectionResolveBlur=void 0),this._reflectionResolveMarchKey="",this._reflectionGrabInfo=void 0,this._prefilterPasses){for(let e of this._prefilterPasses)e?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let e of this._downsamplePasses)e?.quad.material?.dispose();this._downsamplePasses=void 0}this._uiBlitPass&&(this._uiBlitPass.quad.material.dispose(),this._uiBlitPass=void 0),this._helperOverlay?.dispose(),this._helperOverlay=void 0,function(){for(let e of kO)e.deref()?.dispose();kO.clear(),VO++}(),function(){for(let e of vE){let t=e.deref();t!==void 0&&(t.sprite.removeFromParent(),t.material.dispose())}vE.clear(),Zb++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let e of Object.values(this._encodeMaterials))e?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),tt.transmissionRenderTarget.value=Hl,tt.normalRenderTarget.value=Hl,tt.aoRenderTarget.value=Hl,tt.reflectionRenderTarget.value=Dc,tt.reflectionDepthPyramid.value=Dc,tt.reflectionEnvMap.value=Dc,tt.reflectionPlanarTarget.value=Dc,tt.reflectionPlanarEnabled.value=0,tt.reflectionResolveTarget.value=Qq,tt.reflectionResolveEnabled.value=0,this.disposeListenerLedger.release(),this.onBackgroundWorkReady=null}})._GAUGE_STALL_MS=3e3,function(){let e=j4.prototype;for(let t of["init","render","compute","compileAsync","clear","initTexture","initRenderTarget","copyFramebufferToTexture","copyTextureToTexture","getArrayBufferAsync","readRenderTargetPixelsAsync"]){let i=e[t];if(typeof i!="function")throw new Error(`recordDisposeListenersIn: no method ${t}`);e[t]=function(...r){return t5e(this.disposeListenerLedger,()=>i.apply(this,r))}}}()});function tl(e,t){switch(e.type){case"cavity":return function(i,r){return{...ol(i,r),ridge:i.ridge,valley:i.valley}}(e,t);case"dust":return function(i,r){return{...ol(i,r),color:fo(i.color,r),coverage:Nt(i.coverage,r)??.2,softness:Nt(i.softness,r)??.2,noiseStrength:Nt(i.noiseStrength,r)??.2,noiseScale:Nt(i.noiseScale,r)??1}}(e,t);case"fresnel":return function(i,r){let{bias:n,scale:s,intensity:a,factor:o,color:l}=i;return{...ol(i,r),color:fo(l,r),bias:n,scale:s,intensity:a,factor:o}}(e,t);case"gradient":return function(i,r){let{gradientType:n,smooth:s,colors:a,steps:o,angle:l,offset:h,morph:u}=i;return{...ol(i,r),gradientType:n,smooth:s,colors:a.map(d=>new ut(d[0],d[1],d[2],d[3])),num:a.length,steps:o,offset:new Z(...h.map(d=>typeof d=="number"?d:0)),morph:new Z(...u.map(d=>typeof d=="number"?d:0)),angle:l}}(e,t);case"depth":return function(i,r){let{gradientType:n,near:s,far:a,isVector:o,isWorldSpace:l,origin:h,direction:u,colors:d,steps:c,smooth:p}=i;return{...ol(i,r),gradientType:n,near:s,far:a,isVector:o,isWorldSpace:l,origin:new P(...h),direction:u?new P(...u):new P(1,0,0),colors:d.map(f=>f!==void 0?new ut(f[0],f[1],f[2],f[3]):new ut(0,0,0,0)),steps:c.slice(0,d.length),smooth:p}}(e,t);case"normal":return function(i,r){let{cnormal:n}=i;return{...ol(i,r),cnormal:new P(n[0],n[1],n[2])}}(e,t);case"noise":return function(i,r){return{...ol(i,r),scale:i.scale,move:i.move,fA:new Z(...i.fA.map(n=>typeof n=="number"?n:0)),fB:new Z(...i.fB.map(n=>typeof n=="number"?n:0)),size:new P(...i.size),distortion:new Z(...i.distortion.map(n=>typeof n=="number"?n:0)),colorA:fo(i.colorA,r),colorB:fo(i.colorB,r),colorC:fo(i.colorC,r),colorD:fo(i.colorD,r),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}(e,t);case"rainbow":return function(i,r){return{...ol(i,r),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new P(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new P(...i.offset)}}(e,t);case"toon":return function(i,r){return{...ol(i,r),positioning:i.positioning,colors:i.colors.map(n=>new ut(n[0],n[1],n[2],n[3])),num:i.colors.length,steps:i.steps,source:new P(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:fo(i.shadowColor,r),offset:new P(...i.offset)}}(e,t);case"outline":return function(i,r){return{...ol(i,r),outlineColor:fo(i.outlineColor,r),contourColor:fo(i.contourColor,r),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new P(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}(e,t);case"transmission":return function(i,r){return{...ol(i,r),thickness:i.thickness,ior:i.ior,roughness:i.roughness,attenuationColor:i.attenuationColor!==void 0?fo(i.attenuationColor,r):{r:1,g:1,b:1,a:1},attenuationDistance:i.attenuationDistance??0}}(e,t);case"reflection":return function(i,r){return{...ol(i,r),blur:Nt(i.blur,r)??0,thickness:Nt(i.thickness,r)??.001,steps:Nt(i.steps,r)??60,stepSize:Nt(i.stepSize,r)??.005,tracingMode:i.tracingMode,mirror:i.mirror??0}}(e,t);case"pattern":return function(i,r){return{...ol(i,r),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new Z(...i.offset.map(n=>typeof n=="number"?n:0)),colorA:fo(i.colorA,r),colorB:fo(i.colorB,r),frequency:new Z(...i.frequency.map(n=>typeof n=="number"?n:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new Z(...i.vertical.map(n=>typeof n=="number"?n:0)),horizontal:new Z(...i.horizontal.map(n=>typeof n=="number"?n:0)),sides:i.sides}}(e,t);case"vertexColor":return ol(e,t);default:return function(i,r){return{...ol(i,r),color:fo(i.color,r)}}(e,t)}}function l5e(e){return{type:e.type}}function ol(e,t){let{alpha:i,mode:r,isMask:n}=e,s=typeof i=="string"?Number(t.getVariable(i)??100)/100:i;return{...l5e(e),alpha:s,mode:r,isMask:n}}var il=F(()=>{ne(),gK(),Md()});function X_(e){let t=e;return t!=null&&t.isInstancedMesh===!0&&t.instanceMatrix!=null&&t.instanceMatrix.isInstancedBufferAttribute===!0}function wN(e){return cd(cd(rF).mul(function(t){let i=t.spInstanceMatrixNode;if(i!==void 0)return cd(i);let r=t.object,n=r.instanceMatrix,s=Math.max(r.count??1,1);if(n.isStorageInstancedBufferAttribute===!0)return cd(W4(G2e(n,"mat4",s),wa));if(16*s*4<=t.getUniformBufferLimit())return cd(W4(e2e(n.array,"mat4",s),wa));let a=N$.get(n);a===void 0&&(a=new aY(n.array,16,1),N$.set(n,a));let o=n.usage===bd?d2e:vg;return cd($K(o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)))}(e)))}var cd,W4,N$,Xo,xC,$Me,XMe=F(()=>{ne(),gi(),cd=e=>e,W4=(e,t)=>e.element(t),N$=new WeakMap,Xo=He(e=>X_(e.object)?nF:vw).once()().toVar("speObjectPosition"),xC=He(e=>e.material?.shapeBlendObjectNormal||(X_(e.object)?e.geometry.hasAttribute("normal")?E2e:Q(0,1,0):XK)).once()().toVar("speObjectNormal"),cd(He(e=>cd(X_(e.object)?wN(e):rF)).once()()),$Me=He(e=>{if(!X_(e.object))return x2e;let t=wN(e),i=r=>W4(t,r).xyz;return Q(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),He(e=>X_(e.object)?$g(wN(e)).inverse().transpose():b2e).once()(),cd(He(e=>cd(X_(e.object)?wN(e).inverse():S2e)).once()())});function hZ(e){if(eC.has(e))return;let t={own:e.value,render:e.value};eC.set(e,t),Object.defineProperty(e,"value",{configurable:!0,enumerable:!0,get:()=>t.render,set:i=>{t.render=i,t.own=i}})}function I$(e){let t=eC.get(e);return t!==void 0?t.own:e.value}function uZ(e,t){let i=eC.get(e);i!==void 0?i.render=t:e.value=t}var eC,dZ,YMe=F(()=>{eC=new WeakMap}),h5e=F(()=>{YMe(),dZ=class{constructor(e){this.layerId=e,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(e,t,i){return this.byName.set(e,t),this.uniforms[`f${this.layerId}_${e}`]=t,i!==void 0&&this.liveValues.set(e,i),this}has(e){return this.byName.has(e)}names(){return[...this.byName.keys()]}get(e){let t=this.byName.get(e);if(t===void 0)throw new Error(`TSLLayerParams: unknown param "${e}" (layer f${this.layerId})`);return t}getFloat(e){return this.get(e)}getInt(e){return this.get(e)}getBool(e){return this.get(e)}getVec2(e){return this.get(e)}getVec3(e){return this.get(e)}getVec4(e){return this.get(e)}getColor(e){return this.get(e)}getValue(e){if(this.liveValues.has(e))return this.liveValues.get(e);let t=this.byName.get(e);return t===void 0?void 0:I$(t)}getLiveValue(e){return this.liveValues.get(e)}getNodeValue(e){let t=this.byName.get(e);return t===void 0?void 0:I$(t)}setValue(e,t){let i=this.byName.get(e);i===void 0||t===void 0||(this.liveValues.has(e)&&this.liveValues.set(e,t),i.value=t)}}});function qc(e,t,i){let r=L(e).toVar(),n=L(lt(r.div(qt(r.add(t.accumAlpha),L(1e-5),L(1))),r,i)).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(r).mul(Pn(i))),n}function Fw(e,t){let i=L(e).toVar(),r=L(i.div(qt(i.add(t.accumAlpha),L(1e-5),L(1)))).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(i)),r}function HO(e,t,i,r){return ZMe({a:e,b:t,alpha:i,mode:r})}function Ra(e,t){lF.set(e,t)}function KMe(e){let t=lF.get(e);return t!==void 0?t:(U$.has(e)||(U$.add(e),console.warn(`[spe] Material layer type "${e}" is not available in this runtime build (no WebGPU port, or compiled out) \u2014 rendering flat red.`)),cZ)}function u5e(e){return lF.has(e)}var O$,L$,B$,F$,ZMe,lF,U$,cZ,da=F(()=>{gi(),XMe(),h5e(),YMe(),O$=0,L$=1,B$=2,F$=3,ZMe=He(e=>{let t=e.a.toVar(),i=e.b.toVar(),r=e.alpha.toVar(),n=e.mode,s=Q(1).toVar();return ze(n.equal(Pe(O$)),()=>{s.assign(lt(t,i,r))}).ElseIf(n.equal(Pe(L$)),()=>{s.assign(lt(t,t.mul(i),r))}).ElseIf(n.equal(Pe(B$)),()=>{s.assign(lt(t,Pn(Pn(t).mul(Pn(i))),r))}).ElseIf(n.equal(Pe(F$)),()=>{let a=ar(t,Q(.5)),o=lt(Pn(Pn(t).mul(Pn(i)).mul(2)),t.mul(i).mul(2),a);s.assign(lt(t,o,r).clamp(0,1))}),s}),lF=new Map,U$=new Set,cZ=(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:Q(1,0,0),calpha:Fw(r,i)}}});function QMe(e){let t=cl(tt.aoRenderTarget.sample(gu).rgb),i=bw(tt.aoEnabledUniform);return e!==null&&(i=bw(i.mul(Xi(e,L(1),L(0))))),cl(lt(Q(1),t,i))}var z$,k$,cl,bw,bge,xge,JMe,eEe,tEe=F(()=>{var e;mn(),gi(),ua(),da(),{diffuseContribution:z$,specularColorBlended:k$}=N,cl=t=>t,bw=t=>t,bge=He(t=>{let i=To.dot(cl(t.lightDirection)),r=Se(i.mul(.5).add(.5),0),n=r.fwidth().mul(.5);return lt(Q(.7),Q(1),Kr(L(.7).sub(n.x),L(.7).add(n.x),r.x))}),xge=He(t=>{let i=cl(t.lightDirection).add(yw).normalize(),r=To.dot(i).clamp(),n=yw.dot(i).clamp(),s=n.mul(-5.55473).sub(6.98316).mul(n).exp2(),a=px.mul(s.oneMinus()).add(s),o=L(.25),l=N4.mul(.5).add(1).mul(1/Math.PI).mul(r.pow(N4));return a.mul(o).mul(l)}),e=class extends kx{direct(t){let{lightDirection:i,lightColor:r,reflectedLight:n}=t,s=cl(bge({lightDirection:i})).mul(r);n.directDiffuse.addAssign(s.mul(cl(Wl.rgb).mul(1/Math.PI))),n.directSpecular.addAssign(s.mul(bw(xge({lightDirection:i}))))}},JMe=class extends e{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(t,...i){super.finish?.call(this,t,...i);let{reflectedLight:r,outgoingLight:n}=t.context,s=QMe(this.aoOcclusionGate),a=cl(r.directDiffuse.add(r.indirectDiffuse));n.subAssign(a.mul(Pn(s)))}},eEe=class extends wO{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(t,i){let r=t;if(r.lightNode?.light?.userData?.splineDiffuseOnly===!0){if(this.envIrradianceActive)return;let n=cl(To).dot(r.lightDirection).clamp().mul(r.lightColor),s=N.BRDF_Lambert({diffuseColor:z$});return void r.reflectedLight.directDiffuse.addAssign(n.mul(s))}super.direct(t,i)}}});function Y_(e,t){return Fc(t==="x"?e.x:t==="y"?e.y:e.z)}function Y2(e,t){return na(T2e(e,Q(t,1)).div(2).add(.5).xy)}function d5e(e,t,i){let r=L(e.div(qt(e.add(t.accumAlpha),L(1e-5),L(1)))).toVar();return t.accumAlpha.addAssign(Pn(t.accumAlpha).mul(e).mul(Pn(i))),r}function nA(e){let t=e.getValue("projection")??0,i=e.getValue("axis")??0,r=i>=0&&i<=2?i:0,n=e.getValue("projectionAxis")??-1,s=n>=0&&n<=2?n:1,a=iEe(e.get("mat")),o=e.getVec2("size");if(t===1){let u=Xo,d=r===0?u.zy:r===1?u.xz:u.xy,c=Se(d.add(1).div(2)).toVar(),p=Se(Y2(a,na(c.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[na(p)],weights:null}}if(t===2){let u=Q(Ft(Xo)).toVar(),{a:d,b:c,pole:p}=V$[s],f=L(Af(Y_(u,d),Y_(u,c)).div(6.283).add(.5)).toVar(),m=L(jK(Y_(u,p)).div(3.1415).add(.5)).toVar(),g=Se(f,m).toVar(),v=Se(Y2(a,na(g.mul(2).sub(1)))).toVar();return{uvs:[na(v)],weights:null}}if(t===3){let u=Q(Ft(Xo)).toVar(),{a:d,b:c,pole:p}=V$[s],f=L(Af(Y_(u,d),Y_(u,c)).div(6.283).add(.5)).toVar(),m=L(Y_(on(Xo),p).div(o.y.mul(.5))).toVar(),g=L(m.div(2).add(.5)).toVar(),v=Se(f,g).toVar(),y=Se(Y2(a,na(v.mul(2).sub(1)))).toVar();return{uvs:[na(y)],weights:null}}if(t===4){let u=e.getFloat("blending"),d=Q(Xo).toVar(),c=Se(d.xy.add(1).div(2)).toVar(),p=Se(d.zy.add(1).div(2)).toVar(),f=Se(d.xz.add(1).div(2)).toVar();for(let y of[c,p,f])y.assign(Y2(a,na(y.mul(2).sub(1).div(o.mul(.5)))));let m=L(Pn(u).mul(125).add(3)).toVar(),g=Q(xC).toVar(),v=Q(oi(Ft(g))).toVar();return v.assign(Xl(v,Q(m))),v.divAssign(Je(v,Q(1))),{uvs:[na(c),na(p),na(f)],weights:on(v)}}let l=Jg.of(e.getValue("uvChannel")),h=Se(Y2(a,na(function(u){if(u===0)return na(Hi());let d=Jg.attributeName(u);return na(He(c=>c.geometry?.getAttribute(d)!==void 0?Hi(u):Hi())())}(l).mul(2).sub(1)))).toVar();return{uvs:[na(h)],weights:null}}function SN(e,t,i){let r=Se(t).toVar(),n=Se(pw(r)).toVar(),s=Se(fw(r)).toVar(),a=u=>Fc(i.mul(iF(xo(e.sample(u)).rgb))),o=L(a(na(r))).toVar(),l=L(a(na(r.add(n))).sub(o)).toVar(),h=L(a(na(r.add(s))).sub(o)).toVar();return na(Se(l,h))}function TN(e,t,i){let r=Q(pw(e)).toVar(),n=Q(fw(e)).toVar(),s=Q(Ft(t)).toVar(),a=Q(Ft(qn(n,s))).toVar(),o=Q(Ft(qn(s,r))).toVar(),l=L(Je(r,a).mul(tF)).toVar(),h=Q(Vc(l).mul(i.x.mul(a).add(i.y.mul(o)))).toVar();return on(Ft(oi(l).mul(s).sub(h)))}function Qj(e,t){let i,r=e.get("texture"),n=e.has("loaded")?e.getFloat("loaded"):L(1),s=l=>{let h=xo(r.sample(l)),u=t==="luminance"?iF(h.rgb):h[t];return L(u).toVar()},{uvs:a,weights:o}=nA(e);if(o!==null){let l=s(a[0]),h=s(a[1]),u=s(a[2]);i=Fc(l.mul(o.z).add(h.mul(o.x)).add(u.mul(o.y)))}else i=Fc(s(a[0]));return Fc(lt(L(1),i,n))}var Fc,na,on,xo,iEe,V$,wge,rEe=F(()=>{mn(),gi(),Ot(),da(),Fc=e=>e,na=e=>e,on=e=>e,xo=e=>e,iEe=e=>e,V$=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],Ra("texture",wge=(e,t,i)=>{let r,n=e.getValue("projection")??0,s=e.getValue("axis")??0,a=s>=0&&s<=2?s:0,o=e.getValue("side")??0,l=e.get("texture"),h=e.getFloat("crop"),{uvs:u,weights:d}=nA(e),c=[...u],p=null;if(n===1){if(r=xo(l.sample(u[0])),o!==2){let y=a===0?Q(1,0,0):a===1?Q(0,1,0):Q(0,0,1),_=Je(xC,y);p=Fc(ar(L(0),o===1?_.mul(-1):_))}}else if(n===2||n===3)r=function(y,_){if(y.value.minFilter===gt&&y.value.magFilter===gt)return xo(y.sample(_));let b=Se(pw(_)).toVar(),x=Se(fw(_)).toVar();return b.x.subAssign(At(b.x.add(.5))),x.x.subAssign(At(x.x.add(.5))),xo(y.sample(_).grad(b,x))}(l,u[0]);else if(n===4){let y=d,_=xo(l.sample(u[0])),b=xo(l.sample(u[1])),x=xo(l.sample(u[2]));r=xo(_.mul(y.z).add(b.mul(y.x)).add(x.mul(y.y)))}else r=xo(l.sample(u[0]));let f=e.has("loaded")?e.getFloat("loaded"):L(1),m=Ae(lt(Ae(0,0,0,1),xo(r),f)).toVar(),g=Q(m.rgb).toVar(),v=L(t.alpha.mul(m.a)).toVar();return p!==null&&v.mulAssign(p),function(y,_,b){ze(y.greaterThan(.5),()=>{for(let x of b)ze(x.x.lessThan(0).or(x.x.greaterThan(1)).or(x.y.lessThan(0)).or(x.y.greaterThan(1)),()=>{_.assign(0)})})}(h,Fc(v),c),v.mulAssign(t.mask),{color:on(g),calpha:d5e(Fc(v),i,t.isMask)}}),Ra("video",wge)});function MN(e){return oEe({c:e})}function Tg(e){return lEe({p:e})}function c5e(e){return hEe({m:e})}function Av(e){return uEe({x:e})}function Jj(e){return dEe({r:e})}function Hx(e){return cEe({v:e})}function EN(e){return pEe({x:e})}function p5e(e){return fEe({x:e})}function qO(e){return mEe({P:e})}function e9(e){return gEe({p3:e})}function sA(e,t,i){return vEe({a:e,b:t,k:i})}function nEe(e,t,i){return yEe({a:e,b:t,k:i})}function sEe(e,t,i,r,n){return _Ee({value:e,input_min:t,input_max:i,output_min:r,output_max:n})}function aEe(e,t,i,r,n){return bEe({x:e,style:t,smoothness:i,seed:r,quality:n})}var Sge,t9,K2,oEe,lEe,hEe,uEe,dEe,cEe,Tge,pEe,Mge,fEe,Ege,mEe,Age,gEe,vEe,yEe,_Ee,bEe,tC,wC=F(()=>{gi(),Sge=YK,t9=Yr,K2=.1666667,oEe=He(e=>{let t=e.c,i=Aa(Je(t,Q(17,59.4,15))).mul(4096),r=fr(i.mul(512)),n=i.mul(.125),s=fr(n.mul(512)),a=n.mul(.125),o=fr(a.mul(512));return Q(s,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),lEe=He(e=>{let t=e.p,i=At(t.add(Je(t,Q(.3333333)))).toVar(),r=t.sub(i).add(Je(i,Q(K2))).toVar(),n=ar(Q(0),r.sub(r.yzx)).toVar(),s=n.mul(Pn(n.zxy)).toVar(),a=Pn(n.zxy.mul(Pn(n))).toVar(),o=r.sub(s).add(K2).toVar(),l=r.sub(a).add(2*K2).toVar(),h=r.sub(1).add(3*K2).toVar(),u=Ae(Je(r,r),Je(o,o),Je(l,l),Je(h,h)).toVar();u.assign(Ae(.6).sub(u).max(0));let d=Ae(Je(MN(i),r),Je(MN(i.add(s)),o),Je(MN(i.add(a)),l),Je(MN(i.add(1)),h)).toVar();return u.mulAssign(u),u.mulAssign(u),d.mulAssign(u),Je(d,Ae(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),hEe=He(e=>{let t=e.m,i=$g(Q(-.37,.36,.85),Q(-.14,-.93,.34),Q(.92,.01,.4)),r=$g(Q(-.55,-.39,.74),Q(.33,-.91,-.24),Q(.77,.12,.63)),n=$g(Q(-.71,.52,-.47),Q(-.08,-.72,-.68),Q(-.7,-.45,.56));return Tg(t.mul(i)).mul(.5333333).add(Tg(t.mul(2).mul(r)).mul(.2666667)).add(Tg(t.mul(4).mul(n)).mul(.1333333)).add(Tg(t.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),uEe=He(e=>{let t=e.x;return vd(t.mul(34).add(1).mul(t),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),dEe=He(e=>uE(1.79284291400159,e.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),cEe=He(e=>{let t=e.v,i=Se(1/6,1/3),r=Ae(0,.5,1,2),n=At(t.add(Je(t,i.yyy))).toVar(),s=t.sub(n).add(Je(n,i.xxx)).toVar(),a=ar(s.yzx,s.xyz).toVar(),o=Pn(a).toVar(),l=Li(a.xyz,o.zxy).toVar(),h=pt(a.xyz,o.zxy).toVar(),u=s.sub(l).add(i.xxx.mul(1)).toVar(),d=s.sub(h).add(i.xxx.mul(2)).toVar(),c=s.sub(1).add(i.xxx.mul(3)).toVar();n.assign(vd(n,289));let p=Av(Av(Av(n.z.add(Ae(0,l.z,h.z,1))).add(n.y).add(Ae(0,l.y,h.y,1))).add(n.x).add(Ae(0,l.x,h.x,1))).toVar(),f=r.wyz.mul(1/7).sub(r.xzx).toVar(),m=p.sub(At(p.mul(f.z).mul(f.z)).mul(49)).toVar(),g=At(m.mul(f.z)).toVar(),v=At(m.sub(g.mul(7))).toVar(),y=g.mul(f.x).add(f.yyyy).toVar(),_=v.mul(f.x).add(f.yyyy).toVar(),b=uE(1,oi(y)).sub(oi(_)).toVar(),x=Ae(y.xy,_.xy).toVar(),w=Ae(y.zw,_.zw).toVar(),S=At(x).mul(2).add(1).toVar(),T=At(w).mul(2).add(1).toVar(),M=ar(b,Ae(0)).negate().toVar(),E=x.xzyw.add(S.xzyw.mul(M.xxyy)).toVar(),A=w.xzyw.add(T.xzyw.mul(M.zzww)).toVar(),C=Q(E.xy,b.x).toVar(),D=Q(E.zw,b.y).toVar(),R=Q(A.xy,b.z).toVar(),I=Q(A.zw,b.w).toVar(),U=Jj(Ae(Je(C,C),Je(D,D),Je(R,R),Je(I,I))).toVar();C.mulAssign(U.x),D.mulAssign(U.y),R.mulAssign(U.z),I.mulAssign(U.w);let O=pt(uE(.6,Ae(Je(s,s),Je(u,u),Je(d,d),Je(c,c))),0).toVar();return O.mulAssign(O),Je(O.mul(O),Ae(Je(C,s),Je(D,u),Je(R,d),Je(I,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Tge=He(e=>{let t=e.x;return t.sub(At(t.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),pEe=He(e=>{let t=e.x;return Tge({x:t.mul(34).add(1).mul(t)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),Mge=He(e=>{let t=e.p,i=At(t).toVar(),r=t.sub(i).toVar();r.assign(r.mul(r).mul(uE(3,r.mul(2))));let n=i.xxyy.add(Ae(0,1,0,1)).toVar(),s=EN(n.xyxy).toVar(),a=EN(s.xyxy.add(n.zzww)).toVar().add(i.zzzz).toVar(),o=EN(a).toVar(),l=EN(a.add(1)).toVar(),h=fr(o.mul(1/41)).toVar(),u=fr(l.mul(1/41)).toVar().mul(r.z).add(h.mul(Pn(r.z))).toVar(),d=u.yw.mul(r.x).add(u.xz.mul(Pn(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(Pn(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),fEe=He(e=>{let t=Q(e.x).toVar(),i=L(0).toVar(),r=L(.5).toVar(),n=Q(100).toVar();return Yr(5,()=>{i.addAssign(r.mul(function(s){return Mge({p:s})}(t))),t.assign(t.mul(2).add(n)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),Ege=He(e=>{let t=e.t;return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),mEe=He(e=>{let t=e.P,i=At(t).toVar(),r=i.add(Q(1)).toVar();i.assign(vd(i,289)),r.assign(vd(r,289));let n=fr(t).toVar(),s=n.sub(Q(1)).toVar(),a=Ae(i.x,r.x,i.x,r.x).toVar(),o=Ae(i.yy,r.yy).toVar(),l=Ae(i.zzzz).toVar(),h=Ae(r.zzzz).toVar(),u=Av(Av(a).add(o)).toVar(),d=Av(u.add(l)).toVar(),c=Av(u.add(h)).toVar(),p=d.div(7).toVar(),f=fr(At(p).div(7)).sub(.5).toVar();p.assign(fr(p));let m=Ae(.5).sub(oi(p)).sub(oi(f)).toVar(),g=ar(m,Ae(0)).toVar();p.subAssign(g.mul(ar(0,p).sub(.5))),f.subAssign(g.mul(ar(0,f).sub(.5)));let v=c.div(7).toVar(),y=fr(At(v).div(7)).sub(.5).toVar();v.assign(fr(v));let _=Ae(.5).sub(oi(v)).sub(oi(y)).toVar(),b=ar(_,Ae(0)).toVar();v.subAssign(b.mul(ar(0,v).sub(.5))),y.subAssign(b.mul(ar(0,y).sub(.5)));let x=Q(p.x,f.x,m.x).toVar(),w=Q(p.y,f.y,m.y).toVar(),S=Q(p.z,f.z,m.z).toVar(),T=Q(p.w,f.w,m.w).toVar(),M=Q(v.x,y.x,_.x).toVar(),E=Q(v.y,y.y,_.y).toVar(),A=Q(v.z,y.z,_.z).toVar(),C=Q(v.w,y.w,_.w).toVar(),D=Jj(Ae(Je(x,x),Je(S,S),Je(w,w),Je(T,T))).toVar();x.mulAssign(D.x),S.mulAssign(D.y),w.mulAssign(D.z),T.mulAssign(D.w);let R=Jj(Ae(Je(M,M),Je(A,A),Je(E,E),Je(C,C))).toVar();M.mulAssign(R.x),A.mulAssign(R.y),E.mulAssign(R.z),C.mulAssign(R.w);let I=Je(x,n).toVar(),U=Je(w,Q(s.x,n.yz)).toVar(),O=Je(S,Q(n.x,s.y,n.z)).toVar(),k=Je(T,Q(s.xy,n.z)).toVar(),G=Je(M,Q(n.xy,s.z)).toVar(),K=Je(E,Q(s.x,n.y,s.z)).toVar(),q=Je(A,Q(n.x,s.yz)).toVar(),Y=Je(C,s).toVar(),ue=function(be){return Ege({t:be})}(n).toVar(),de=lt(Ae(I,U,O,k),Ae(G,K,q,Y),ue.z).toVar(),ge=lt(de.xy,de.zw,ue.y).toVar();return lt(ge.x,ge.y,ue.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Age=He(e=>{let t=fr(e.p3.mul(.1031)).toVar();return t.addAssign(Je(t,t.yzx.add(33.33))),fr(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),gEe=He(e=>{let t=fr(e.p3.mul(Q(.1031,.103,.0973))).toVar();return t.addAssign(Je(t,t.yxz.add(33.33))),fr(t.xxy.add(t.yxx).mul(t.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),vEe=He(e=>{let{a:t,b:i,k:r}=e,n=Kr(0,1,i.sub(t).mul(.5).div(r).add(.5)).toVar(),s=r.mul(n).mul(Pn(n)).toVar();return lt(i,t,n).sub(s)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),yEe=He(e=>{let{a:t,b:i,k:r}=e,n=Kr(1,0,t.sub(i).mul(.5).div(r).add(.5)).toVar(),s=r.mul(n).mul(Pn(n)).toVar();return lt(t,i,n).add(s)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),_Ee=He(e=>{let{value:t,input_min:i,input_max:r,output_min:n,output_max:s}=e,a=r.sub(i).toVar(),o=s.sub(n).toVar(),l=t.sub(i).div(a).toVar();return n.add(l.mul(o))}).setLayout({name:"spe_remap",type:"float",inputs:[{name:"value",type:"float"},{name:"input_min",type:"float"},{name:"input_max",type:"float"},{name:"output_min",type:"float"},{name:"output_max",type:"float"}]}),bEe=He(e=>{let{x:t,style:i,smoothness:r,seed:n,quality:s}=e,a=Ga(At(t)).toVar(),o=fr(t).toVar(),l=L(8).toVar(),h=L(8).toVar(),u=L(8).toVar(),d=L(8).toVar(),c=L(8).toVar(),p=L(8).toVar(),f=Ga(0).toVar(),m=Q(0).toVar(),g=Pe(s).toVar(),v=()=>({start:g.negate(),end:g,condition:"<=",type:"int"});t9(v(),v(),v(),({i:_,j:b,k:x})=>{let w=Ga(_,b,x).toVar(),S=Q(w).add(e9(Q(a.add(w)).add(n))).sub(o).toVar(),T=$i(S).toVar();l.assign(sA(T,l,r)),ze(T.lessThan(h),()=>{d.assign(h),h.assign(T),f.assign(Ga(_,b,x)),m.assign(S)}).ElseIf(T.lessThan(d),()=>{d.assign(T)})}),ze(i.notEqual(Pe(0)).and(i.notEqual(Pe(5))).and(i.notEqual(Pe(7))),()=>{t9(v(),v(),v(),({i:_,j:b,k:x})=>{let w=f.add(Ga(_,b,x)).toVar(),S=Q(w).add(e9(Q(a.add(w)).add(n))).sub(o).toVar(),T=Je(m.add(S).mul(.5),S.sub(m)).toVar(),M=Je(m.add(S).mul(.5),Ft(S.sub(m))).toVar();c.assign(sA(T,c,r)),p.assign(Li(p,M));let E=Ga(_,b,x).toVar();ze(GK(Sge(E,f)),()=>{let A=Q(E).add(e9(Q(a.add(E)).add(n))).sub(o).toVar(),C=$i(A).toVar();u.assign(sA(C,u,r))})})});let y=L(0).toVar();return ze(i.equal(Pe(0)),()=>{y.assign(l)}).ElseIf(i.equal(Pe(1)),()=>{y.assign(u)}).ElseIf(i.equal(Pe(2)),()=>{y.assign(u.sub(l))}).ElseIf(i.equal(Pe(3)),()=>{let _=L(3).toVar(),b=pt(_.sub(oi(h.sub(d))),0).div(_).toVar();y.assign(Li(h,d).sub(b.mul(b).mul(_).mul(1/4)))}).ElseIf(i.equal(Pe(4)),()=>{y.assign(eF(c.mul(5)))}).ElseIf(i.equal(Pe(5)),()=>{y.assign(Xl(l,3))}).ElseIf(i.equal(Pe(6)),()=>{let _=r.mul(.25).add(.0125).toVar(),b=Xl(r,3).mul(.25).add(.0125).toVar();y.assign(Kr(_.sub(_.mul(b)),_.add(_.mul(b)),p))}).ElseIf(i.equal(Pe(7)),()=>{y.assign(function(_){return Age({p3:_})}(Q(a.add(f)).add(n)))}),y}).setLayout({name:"spe_voronoi",type:"float",inputs:[{name:"x",type:"vec3"},{name:"style",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"quality",type:"int"}]}),tC=[Tg,c5e,Hx,p5e,qO]});function xEe(e,t,i,r){return ml(e.add(t).mul(i).mul(.001).add(wEe).add(r.mul(.1)))}function f5e(e,t,i){let r=function(h,u){let d=Math.trunc(h.getValue("noiseType")??0),c={n:u,scale:h.getFloat("scale"),intensity:h.getFloat("intensity"),offset:h.getVec3("offset"),movement:h.getFloat("movement")};if(d===5)return f=>ml(TEe({...c,p:f,voronoiStyle:h.getInt("voronoiStyle"),smoothness:h.getFloat("smoothness"),seed:h.getFloat("seed"),highCut:h.getFloat("highCut"),lowCut:h.getFloat("lowCut"),quality:h.getInt("quality")}));let p=function(f){let m=G$.get(f);if(m===void 0){let g=tC[f]??tC[0];m=He(v=>{let{n:y,scale:_,intensity:b,offset:x,movement:w}=v,S=ml(v.p);return S.add(y.mul(g(xEe(S,x,_,w))).mul(b))}).setLayout({name:`spe_displaceScalar${f}`,type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"}]}),G$.set(f,m)}return m}(d);return f=>ml(p({...c,p:f}))}(e,i),n=Q(r(t)).toVar(),s=Q(function(h){return SEe({v:h})}(i)).toVar(),a=Ft(qn(i,s)).toVar(),o=Q(r(ml(t.add(s)))).toVar(),l=Q(r(ml(t.add(a)))).toVar();return{position:n,normal:ml(Ft(qn(o.sub(n),l.sub(n))))}}var ml,wEe,SEe,G$,TEe,i9,Cge,y1,Z2,AN,Pge,m5e=F(()=>{gi(),wC(),ml=e=>e,wEe=1e-4,SEe=He(e=>{let t=ml(e.v);return Ft(ml(Xi(oi(t.x).greaterThan(oi(t.z)),Q(t.y.negate(),t.x,0),Q(0,t.z.negate(),t.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),G$=new Map,TEe=He(e=>{let{n:t,scale:i,intensity:r,offset:n,movement:s,smoothness:a}=e,o=ml(e.p),l=L(aEe(xEe(o,n,i,s),e.voronoiStyle,a,e.seed,e.quality)).toVar();return l.assign(sEe(l,e.lowCut,e.highCut,L(0),L(1))),l.assign(nEe(l,L(0),a.mul(.25))),l.assign(sA(l,L(1),a.mul(.25))),o.add(t.mul(l).mul(r))}).setLayout({name:"spe_displaceVoronoi",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"},{name:"voronoiStyle",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"highCut",type:"float"},{name:"lowCut",type:"float"},{name:"quality",type:"int"}]})}),g5e=F(()=>{da(),Ra("color",(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:e.getColor("color"),calpha:Fw(r,i)}})}),v5e=F(()=>{gi(),da(),i9=e=>e,Cge=e=>e,Ra("depth",(e,t,i)=>{let r,n=e.get("colors"),s=e.get("steps"),a=(e.getValue("colors")??n.array).length,o=e.getValue("smooth")===!0,l=(e.getValue("isVector")??1)>.5,h=(e.getValue("gradientType")??0)===0,u=(e.getValue("isWorldSpace")??0)>.5,d=e.getFloat("near"),c=e.getFloat("far");if(l){let g=e.getVec3("origin"),v=u?Jl:Xo;if(h){let y=Ft(e.getVec3("direction"));r=Je(y,v.sub(g))}else r=$i(v.sub(g))}else r=$i(Jl.sub(Kf));let p=r.sub(d).div(c.sub(d)).toVar(),f=Ae(n.element(0)).toVar();for(let g=1;g<a;g++){let v=i9(s.element(g-1)),y=i9(s.element(g)),_=qt(p.sub(v).div(y.sub(v)),L(0),L(1)),b=o?Kr(L(0),L(1),_):_;f.assign(lt(f,Cge(n.element(g)),b))}let m=t.alpha.mul(f.a).mul(t.mask);return{color:f.rgb,calpha:qc(m,i,t.isMask)}})}),y5e=F(()=>{gi(),da(),iZ(),ua(),Ra("cavity",(e,t,i)=>{let r=qt(e.getFloat("ridge"),0,2),n=qt(e.getFloat("valley"),0,2),s=tt.normalViewRenderTarget,a=tt.resolution,o=tZ().x.toVar(),l=gu.toVar(),h=Se(L(1).div(a.x),L(1).div(a.y)).toVar(),u=(E,A)=>s.sample(l.add(Se(E,A)).toVar()).toVar(),d=u(L(0),h.y.negate()),c=u(L(0),h.y),p=u(h.x.negate(),L(0)),f=u(h.x,L(0)),m=E=>E.a.equal(o).and(Je(E.xyz,E.xyz).greaterThan(.5)),g=m(d).and(m(c)).and(m(p)).and(m(f)),v=d.y.sub(c.y).add(f.x.sub(p.x)).toVar(),y=L(.5).div(pt(r.mul(r),L(1e-4))).toVar(),_=L(.7).div(pt(n.mul(n),L(1e-4))).toVar(),b=(E,A)=>Xi(E.lessThan(L(.5).div(A)),E.mul(L(1).sub(E.mul(A))),L(.25).div(A)),x=Xi(g,Xi(v.greaterThan(0),b(v,y).mul(2),b(v.negate(),_).mul(-2)),L(0)).toVar(),w=Xi(x.abs().lessThan(.001),L(0),x).toVar(),S=Q(qt(w.mul(.5).add(.5),0,1)),T=Xi(w.notEqual(0),L(1),L(0)),M=Xi(t.isMask,L(1),T);return{color:S,calpha:qc(t.alpha.mul(t.mask).mul(M),i,t.isMask)}})}),Uw=F(()=>{gi(),y1=He(e=>{let t=e.material?.vertexObjectNormal??null;return t?I4(t).transformNormalByInverseViewMatrix(bu).normalize():A2e}).once()().toVar("speVertexNormalWorld")}),_5e=F(()=>{gi(),Uw(),da(),wC(),Ra("dust",(e,t,i)=>{let r=e.getFloat("coverage"),n=e.getFloat("softness"),s=e.getFloat("noiseStrength"),a=e.getFloat("noiseScale"),o=Je(Ft(y1),Q(0,1,0)),l=L(0).toVar();ze(s.notEqual(0),()=>{let c=Tg(Xo.div(a).toVar().add(Q(1.7,9.2,1)));l.assign(c.mul(s))});let h=pt(n,1e-4).toVar(),u=lt(h.add(1),h.add(1).negate(),qt(r,0,1)).toVar(),d=Kr(u.sub(h),u.add(h),o.add(l)).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:qc(d,i,t.isMask)}})}),b5e=F(()=>{gi(),Uw(),da(),Z2=(e,t)=>e.element(t),Ra("fresnel",(e,t,i)=>{let r=Z2(Bw,2).w.equal(-1),n=Q(Z2(bu,0).z,Z2(bu,1).z,Z2(bu,2).z).negate(),s=Jl.sub(Kf),a=Xi(r,s,n),o=e.getFloat("bias").add(e.getFloat("scale").mul(Xl(oi(e.getFloat("factor").add(Je(Ft(a),Ft(y1)))),e.getFloat("intensity")))),l=qt(o,0,1).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:qc(l,i,t.isMask)}})}),x5e=F(()=>{gi(),da(),AN=e=>e,Pge=e=>e,Ra("gradient",(e,t,i)=>{let r=e.get("colors"),n=e.get("steps"),s=(e.getValue("colors")??r.array).length,a=(e.getValue("steps")??n.array).length,o=Math.min(10,s,a),l=e.getInt("gradientType"),h=e.getBool("smooth"),u=e.getVec2("offset"),d=e.getVec2("morph"),c=e.getFloat("angle"),p=Hi(),f=Ae(r.element(0)).toVar(),m=Se(d.div(p)).toVar(),g=Se(L(.5).add(m.x),m.y).toVar(),v=Se($o(c).mul(g.x).sub(Aa(c).mul(g.y)),Aa(c).mul(g.x).add($o(c).mul(g.y))).toVar(),y=Se(p.sub(.5).add(u).div(2).add(v.div(2))),_=L(Je(y,v).div(Je(v,v))).toVar();ze(l.equal(Pe(1)),()=>{_.assign(l2e(p.add(d).mul(3),p.add(u).add(1)).add(c))}).ElseIf(l.equal(Pe(2)),()=>{let x=Af(p.x.add(d.x).sub(.5).add(u.x),p.y.add(d.y).sub(.5).add(u.y)).mul(-1);_.assign(fr(c.div(Wq).div(-2).add(x.div(Wq).mul(.5))))});for(let x=1;x<o;x++){let w=AN(n.element(x-1)),S=AN(n.element(x)),T=qt(_.sub(w).div(S.sub(w)),L(0),L(1)),M=AN(Xi(h,Kr(L(0),L(1),T),T));f.assign(lt(f,Pge(r.element(x)),M))}let b=t.alpha.mul(f.a).mul(t.mask);return{color:f.rgb,calpha:qc(b,i,t.isMask)}})}),w5e=F(()=>{gi(),da(),Ra("matcap",(e,t,i)=>{let r=e.getFloat("rotation"),n=Ft(Zf.negate()),s=Ft(Q(n.z,0,n.x.negate())),a=qn(n,s),o=Se(Je(s,To),Je(a,To)),l=$o(r),h=Aa(r),u=Se(l.mul(o.x).sub(h.mul(o.y)),h.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=e.get("texture").sample(u),c=t.alpha.mul(t.mask);return{color:d.rgb,calpha:qc(c,i,t.isMask)}})}),S5e=F(()=>{gi(),da(),wC(),Ra("noise",(e,t,i)=>{try{if(new URLSearchParams(window.location.search).get("dbgnoise")==="0")return{color:Q(0),calpha:L(0)}}catch{}let r=Math.trunc(e.getValue("noiseType")??0),n=L(pt(oi(e.getFloat("scale")),.001)).toVar(),s=Q(Xo.div(e.getVec3("size"))).toVar();s.divAssign(n);let a=e.getFloat("move"),o=e.getVec4("colorA"),l=e.getVec4("colorC"),h=Ae(0).toVar();if(r===5){let d=e.getFloat("smoothness"),c=L(aEe(s.add(a),e.getInt("voronoiStyle"),d,e.getFloat("seed"),e.getInt("quality"))).toVar();c.assign(sEe(c,e.getFloat("lowCut"),e.getFloat("highCut"),L(0),L(1))),c.assign(nEe(c,L(0),d.mul(.25))),c.assign(sA(c,L(1),d.mul(.25))),h.assign(lt(o,l,c))}else{let d=tC[r]??tC[0],c=e.getVec4("colorB"),p=e.getVec4("colorD"),f=Q(e.getVec2("distortion"),1).toVar(),m=Q(e.getVec2("fA"),1).toVar(),g=Q(e.getVec2("fB"),1).toVar(),v=Q(d(s),d(s.add(Q(1))),d(s.add(Q(1)))).toVar(),y=Q(d(s.add(f.mul(v)).add(m).add(a)),d(s.add(f.mul(v)).add(g).add(a)),d(s.mul(v))).toVar(),_=L(d(s.add(y))).toVar();h.assign(lt(o,c,qt(_.mul(_).mul(4),L(0),L(1)))),h.assign(lt(h,l,qt($i(v),L(0),L(1)))),h.assign(lt(h,p,qt($i(y.x),L(0),L(1))))}let u=t.alpha.mul(h.a).mul(t.mask);return{color:qt(h,L(0),L(1)).rgb,calpha:qc(u,i,t.isMask)}})}),T5e=F(()=>{gi(),da(),Ra("normal",(e,t,i)=>({color:R2e(Ft(To)).mul(ar(Q(.5),e.getVec3("cnormal"))),calpha:Fw(t.alpha.mul(t.mask),i)}))});function r9(e){return MEe({p:e})}function CN(e,t){return EEe({uv:e,a:t})}function K_(e,t,i,r,n){return AEe({uv:e,frequency:t,variation:i,zigzag:r,rotation:n})}function PN(e,t){let i={uv:t.uv,frequency:t.frequency,size:t.size,variation:t.variation,smoothness:t.smoothness,zigzag:t.zigzag,rotation:t.rotation};switch(e){case 1:return PEe(i);case 2:return REe({...i,sides:t.sides});case 3:return DEe(i);case 4:return NEe(i);case 5:return IEe(i);case 6:return OEe(i);case 7:return LEe(i);default:return CEe(i)}}var Z_,Rge,MEe,EEe,AEe,CEe,PEe,Dge,REe,Nge,DEe,Ige,NEe,IEe,OEe,Oge,LEe,Q2,n9,Lge,Bge,Fge,Uge,zge,s9,kge,Cv,Vge,Gge,a9,jge,M5e=F(()=>{gi(),da(),Z_=2*Math.PI,Rge=Math.PI/180,MEe=He(e=>{let t=fr(e.p.xyx.mul(.1031)).toVar();return t.addAssign(Je(t,t.yzx.add(33.33))),fr(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),EEe=He(e=>{let t=e.uv,i=.5,r=L(e.a.mul(Rge)).toVar(),n=Se($o(r).mul(t.x.sub(i)).add(Aa(r).mul(t.y.sub(i))).add(i),$o(r).mul(t.y.sub(i)).sub(Aa(r).mul(t.x.sub(i))).add(i));return fr(n)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),AEe=He(e=>{let t=Se(e.uv.mul(e.frequency)).toVar(),i=Se(At(t)).toVar(),r=L(vd(i.y,2)).toVar();t.x.addAssign(r.mul(e.zigzag));let n=Se(fr(t)).toVar();n.assign(n.mul(2).sub(1)),i.assign(At(t));let s=L(r9(i).mul(5).add(1)).toVar(),a=L(lt(L(1),s,e.variation)).toVar();return n.mulAssign(a),n}).setLayout({name:"spe_pattern_tile_and_center",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"variation",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),CEe=He(e=>{let t=Se(K_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Kr(e.smoothness.negate(),e.smoothness,$i(t).sub(e.size))}).setLayout({name:"spe_pattern_circle",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),PEe=He(e=>{let t=Se(K_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar(),i=L($i(t)).toVar(),r=L(Kr(e.smoothness.negate(),e.smoothness,i.sub(e.size))).toVar(),n=L(Kr(e.smoothness.negate(),e.smoothness,i.sub(e.size.mul(.5)))).toVar();return r.add(Pn(n))}).setLayout({name:"spe_pattern_ring",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Dge=He(e=>{let t=L(L(Z_).div(L(e.n))).toVar(),i=L(e.r.mul(W2e(t.mul(.5)))).toVar(),r=Se(e.p.yx.negate()).toVar(),n=L(t.mul(At(Af(r.y,r.x).add(t.mul(.5)).div(t)))).toVar(),s=Se($o(n),Aa(n)).toVar();return r.assign(Se(s.x.mul(r.x).add(s.y.mul(r.y)),s.y.negate().mul(r.x).add(s.x.mul(r.y)))),$i(r.sub(Se(e.r,qt(r.y,i.negate(),i)))).mul(Vc(r.x.sub(e.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),REe=He(e=>{let t=Se(K_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Kr(e.smoothness.negate(),e.smoothness,Dge({p:t,r:e.size,n:e.sides}))}).setLayout({name:"spe_pattern_polygon",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"},{name:"sides",type:"int"}]}),Nge=He(e=>{let t=e.b,i=Se(oi(e.p)).toVar();i.assign(Xi(i.y.greaterThan(i.x),i.yx,i.xy));let r=Se(i.sub(t)).toVar(),n=L(pt(r.y,r.x)).toVar(),s=Se(Xi(n.greaterThan(0),r,Se(t.y.sub(i.x),n.negate()))).toVar();return Vc(n).mul($i(pt(s,Se(0)))).add(e.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),DEe=He(e=>{let t=Se(K_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Kr(e.smoothness.negate(),e.smoothness,Nge({p:t,b:Se(e.size,e.size.mul(.25)),r:e.smoothness}))}).setLayout({name:"spe_pattern_xcross",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ige=He(e=>{let t=e.b,i=Se(oi(e.p)).toVar(),r=Se(t.sub(i.mul(2))).toVar(),n=r.x.mul(t.x).sub(r.y.mul(t.y)),s=L(qt(n.div(Je(t,t)),L(-1),L(1))).toVar();return L($i(i.sub(t.mul(.5).mul(Se(Pn(s),s.add(1)))))).toVar().mul(Vc(i.x.mul(t.y).add(i.y.mul(t.x)).sub(t.x.mul(t.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),NEe=He(e=>{let t=Se(K_(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return Kr(e.smoothness.negate(),e.smoothness,Ige({p:t,b:Se(e.size)}))}).setLayout({name:"spe_pattern_diamond",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),IEe=He(e=>{let t=Se(e.uv.mul(e.frequency)).toVar(),i=Se(At(t)).toVar(),r=L(vd(i.y,2)).toVar();t.x.addAssign(r.add(e.zigzag.mul(r)));let n=L(At(t.x)).toVar();return vd(n,2)}).setLayout({name:"spe_pattern_checkerboard",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),OEe=He(e=>{let t=Se(K_(e.uv,e.frequency,L(0),e.zigzag,e.rotation)).toVar(),i=L(At(e.uv.mul(e.frequency)).y).toVar(),r=L(r9(Se(i))).toVar(),n=L(lt(e.size,e.size.mul(r),e.variation)).toVar();return Kr(n.sub(e.smoothness),n.add(e.smoothness),oi(t.y))}).setLayout({name:"spe_pattern_line",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Oge=He(e=>{let{a:t,b:i,c:r,d:n}=e,s=Se(e.p.sub(Se(n,t)).mul(r)).toVar();s.x.assign(vd(s.x,Z_)),ze(s.x.greaterThan(Math.PI),()=>{s.x.assign(L(Z_).sub(s.x))});let a=L(0).toVar(),o=L(Z_).toVar();Yr(24,()=>{let u=L(a.add(o).mul(.5)).toVar(),d=L(u.sub(s.x).add(i.mul(r).mul(Aa(u)).mul(s.y.sub(i.mul(r).mul($o(u)))))).toVar();ze(d.lessThan(0),()=>{a.assign(u)}).Else(()=>{o.assign(u)})});let l=L(a.add(o).mul(.5)).toVar(),h=Se(l,i.mul(r).mul($o(l))).toVar();return $i(s.sub(h)).div(r)}).setLayout({name:"spe_pattern_udf_cos",type:"float",inputs:[{name:"p",type:"vec2"},{name:"a",type:"float"},{name:"b",type:"float"},{name:"c",type:"float"},{name:"d",type:"float"}]}),LEe=He(e=>{let t=L(e.frequency.x).toVar(),i=Se(e.uv.mul(t)).toVar(),r=Se(At(i)).toVar(),n=L(vd(r.y,2)).toVar();i.x.addAssign(n.mul(e.zigzag));let s=Se(i.x,fr(i.y)).toVar(),a=L(e.frequency.y.mul(.1)).toVar(),o=L(Oge({p:s,a:L(.5),b:L(.125),c:a.mul(Z_),d:L(0)})).toVar(),l=L(r9(Se(r.y))).toVar(),h=L(lt(e.size,e.size.mul(l),e.variation)).toVar();return Kr(e.smoothness.negate(),e.smoothness,o.sub(h.mul(.5)))}).setLayout({name:"spe_pattern_wave",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ra("pattern",(e,t,i)=>{let r,n,s=e.getValue("style")??0,a=e.getValue("projection")??0,o=e.getValue("axis")??0,l=e.getFloat("blending"),h=e.getVec2("offset"),u=e.getVec4("colorA"),d=e.getVec4("colorB"),c=e.getVec2("frequency"),p=e.getFloat("size"),f=e.getFloat("variation"),m=e.getFloat("smoothness"),g=e.getFloat("zigzag"),v=e.getFloat("rotation"),y=e.getVec2("vertical"),_=e.getVec2("horizontal"),b=e.getInt("sides"),x={frequency:c,size:p,variation:f,smoothness:L(Xl(m,5)).toVar(),zigzag:g,rotation:v,sides:b};if(a===4){let T=Q(Xo).toVar(),M=L(.0125).toVar(),E=Se(fr(T.xy.mul(M))).toVar(),A=Se(fr(T.zy.mul(M))).toVar(),C=Se(fr(T.xz.mul(M))).toVar();E.assign(CN(E.add(h),v)),A.assign(CN(A.add(h),v)),C.assign(CN(C.add(h),v));let D=L(PN(s,{uv:E,...x})).toVar(),R=L(PN(s,{uv:A,...x})).toVar(),I=L(PN(s,{uv:C,...x})).toVar(),U=L(Pn(l).mul(125).add(3)).toVar(),O=Q(xC).toVar(),k=Q(oi(Ft(O))).toVar();k.assign(Xl(k,Q(U))),k.divAssign(Je(k,Q(1))),D.mulAssign(k.z),R.mulAssign(k.x),I.mulAssign(k.y),r=L(D.add(R).add(I)).toVar(),n=Se(E.mul(k.z).add(A.mul(k.x)).add(C.mul(k.y))).toVar()}else{let T=Se(0).toVar();if(a===0)T.assign(Hi());else if(a===2){let M,E,A=Q(Xo).toVar(),C=L($i(A)).toVar();o===0?(M=L(Af(A.y,A.z)).toVar(),E=L(PO(A.x.div(C))).toVar()):o===1?(M=L(Af(A.x,A.z)).toVar(),E=L(PO(A.y.div(C))).toVar()):(M=L(Af(A.y,A.x)).toVar(),E=L(PO(A.z.div(C))).toVar()),T.assign(Se(M,E).div(Math.PI))}T.addAssign(h),T.assign(fr(T)),T.assign(CN(T,v)),r=PN(s,{uv:T,...x}),n=T}let w=Ae(lt(u,d,r)).toVar();w.a.assign(qt(w.a,L(0),L(1))),w.a.mulAssign(ar(y.x,n.y).mul(ar(n.y,y.y))),w.a.mulAssign(ar(_.x,oi(n.x)).mul(ar(oi(n.x),_.y)));let S=t.alpha.mul(qt(w.a,L(0),L(1))).mul(t.mask);return{color:qt(w,Ae(0),Ae(1)).rgb,calpha:qc(S,i,t.isMask)}})}),E5e=F(()=>{gi(),Uw(),da(),wC(),Q2=(e,t)=>e.element(t),Ra("rainbow",(e,t,i)=>{let r=e.getFloat("filmThickness"),n=e.getFloat("movement"),s=e.getVec3("wavelengths"),a=e.getFloat("noiseStrength"),o=e.getFloat("noiseScale"),l=e.getVec3("offset"),h=L(0).toVar();t.noiseCompiledIn!==!1&&ze(a.notEqual(0),()=>{let _=Xo.div(o).toVar(),b=Tg(_.mul(1.6).add(Q(1.8,1.5,1.9).mul(Tg(_))).add(Q(1.7,9.2,1)));h.assign(b.mul(a))});let u=s.mul(Q(1,.8,.6)).add(1),d=Q2(Bw,2).w.equal(-1),c=Q(Q2(bu,0).z,Q2(bu,1).z,Q2(bu,2).z).negate(),p=Jl.sub(Kf),f=Xi(d,p,c),m=Je(Ft(f.add(l.mul(-.001))),Ft(y1)),g=$o(r.add(h).div(u).mul(m).add(n)).mul(.5).add(.5),v=Q(qt(g,0,2)).toVar(),y=qt(v.r.add(v.g).add(v.b),0,1);return{color:v,calpha:qc(t.alpha.mul(y).mul(t.mask),i,t.isMask)}})}),A5e=F(()=>{gi(),Uw(),da(),ua(),n9=e=>e,Lge=e=>e,Bge=Yr,Fge=Yr,Uge=He(e=>{let t=e.x,i=Q(Je(t,Q(127.1,311.7,74.7)),Je(t,Q(269.5,183.3,246.1)),Je(t,Q(113.5,271.9,124.6)));return fr(Aa(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),zge=He(e=>{let t=e.x,i=At(t).toVar(),r=fr(t).toVar(),n=L(100).toVar(),s=()=>({start:Pe(-1),end:Pe(1),condition:"<=",type:"int"});return Fge(s(),s(),s(),({i:a,j:o,k:l})=>{let h=Q(a,o,l).toVar(),u=h.sub(r).add(function(c){return Uge({x:c})}(i.add(h))).toVar(),d=Je(u,u).toVar();ze(d.lessThan(n),()=>{n.assign(d)})}),n.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),Ra("toon",(e,t,i)=>{let r=e.getInt("positioning"),n=e.get("colors"),s=e.get("steps"),a=e.getVec3("source"),o=e.getBool("isWorldSpace"),l=e.getFloat("noiseStrength"),h=e.getFloat("noiseScale"),u=e.getVec4("shadowColor"),d=e.getVec3("offset"),c=Ft(y1).toVar(),p=L(0).toVar();i.lightsAvailable===!0&&ze(r.equal(Pe(0)),()=>{Bge({start:Pe(0),end:tt.toonLightCount,condition:"<",type:"int"},({i:_})=>{let b=tt.toonLightData.element(_).toVar(),x=b.xyz,w=b.w,S=Xi(w.greaterThan(.5),Ft(x),Ft(x.sub(Jl))),T=Je(S,c).mul(.5).add(.5);p.assign(pt(p,T))}),p.assign(qt(p,0,1))}),ze(r.equal(Pe(1)),()=>{let _=lt(Xo,Jl,Xi(o,L(1),L(0))),b=Ft(a.sub(_));p.assign(Je(b,c).mul(.5).add(.5))}).ElseIf(r.equal(Pe(2)),()=>{let _=Kf.sub(d),b=Ft(_.sub(Jl));p.assign(Je(b,c).mul(.5).add(.5))}),ze(l.greaterThan(0),()=>{let _=Xo.div(h),b=L(1).sub(zge({x:_}));p.addAssign(b.mul(l))}),p.assign(qt(p,0,1));let f=(e.getValue("colors")??n.array).length,m=(e.getValue("steps")??s.array).length,g=Math.min(10,f,m),v=Ae(n.element(0)).toVar();for(let _=1;_<g;_++){let b=n9(s.element(_-1)),x=n9(s.element(_)),w=qt(p.sub(b).div(x.sub(b)),L(0),L(1));v.assign(lt(v,Lge(n.element(_)),Kr(0,1,w)))}i.lightsAvailable===!0&&ze(r.equal(Pe(0)),()=>{let _=L(1),b=lt(v.rgb,u.rgb,u.a);v.rgb.assign(lt(b,v.rgb,_))});let y=t.alpha.mul(v.a).mul(t.mask);return{color:v.rgb,calpha:Fw(y,i)}})}),C5e=F(()=>{gi(),Uw(),da(),XMe(),ua(),s9=e=>e,kge=(e,t)=>e.element(t),Cv=e=>e,Vge=e=>e,Gge=e=>e,Ra("transmission",(e,t,i)=>{let r=e.getFloat("thickness"),n=e.getFloat("ior"),s=e.getFloat("roughness"),a=tt.transmissionRenderTarget,o=tt.transmissionSamplerSize,l=G=>kge(bu,G),h=Ft(Q(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),u=Ft(Jl.sub(Kf)),d=tt.orthographicUniform,c=Xi(d.greaterThan(.5),h,u).toVar(),p=Ft(y1).toVar(),f=U2e(c,p,L(1).div(n)).toVar(),m=Ft(f).mul(r).mul($Me).toVar(),g=G=>{let K=tt.unjitteredProjection.mul(bu).mul(Ae(G,1)),q=K.xy.div(K.w);return Se(q.x.mul(.5).add(.5),q.y.mul(-.5).add(.5))},v=g(Jl.add(m).toVar()).toVar(),y=(g(Jl).toVar(),s.mul(qt(n.mul(2).sub(2),L(0),L(1))).toVar()),_=mw(o.x).mul(y).toVar(),b=y,x=Li(_.div(5.5),L(8.5)).toVar(),w=null,S="fit",T=!0,M=!1,E=12,A="white",C=1;try{let G=new URLSearchParams(window.location.search),K=G.get("dbglod");K!==null&&(w=Number(K));let q=G.get("dbgtap");q==="ring"&&(S="ring"),(q==="single"||q==="1")&&(S="single"),(q==="r50"||q==="r75"||q==="full")&&(S=q),q==="singlewide"&&(S="singlewide"),(q==="fit"||q==="singlefit")&&(S="fit");let Y=G.get("dbgwidth");Y!==null&&Number.isFinite(Number(Y))&&(C=Math.max(0,Number(Y))),q==="6"&&(S="ring",E=6),G.get("dbgwarp")==="0"&&(T=!1),G.get("dbgdither")==="1"&&(M=!0);let ue=G.get("dbgangle");(ue==="classic"||ue==="0")&&(A=ue)}catch{}w!==null&&Number.isFinite(w)&&x.assign(L(w));let D,R=(()=>{if(S==="singlewide")return Li(x.add(1),L(8.5)).toVar();if(S!=="fit")return x;let G=tt.transmissionActualSize.x.div(tt.resolution.x),K=b.mul(x).mul(5*C).mul(G).toVar();return Li(mw(qb(x.mul(2)).add(K.mul(K).mul(3))).mul(.5),L(8.5)).toVar()})(),I=G=>a.sample(T?(K=>{let q=tt.transmissionActualSize.div(qb(At(R))),Y=K.mul(q).sub(.5),ue=At(Y),de=Y.sub(ue),ge=de.mul(de).mul(Se(3,3).sub(de.mul(2)));return ue.add(.5).add(ge).div(q)})(G):G).level(R).rgb,U=S==="r50"?.5:S==="r75"?.75:1;if(S==="single"||S==="singlewide"||S==="fit")if(S==="fit"){let G=At(R).toVar(),K=R.sub(G).toVar(),q=Rh(qb(K.mul(2)).sub(1)).mul(1.1547).toVar(),Y=Se(qb(G)).div(tt.transmissionActualSize).mul(q).toVar(),ue=Q(0).toVar(),de=12;for(let ge=0;ge<de;ge++){let be=Cv(t0(ge,de,L(0))),re=Cv(v.add(be.mul(Y)));ue.addAssign(Vge(Gge(a.sample(re).level(G)).rgb))}D=ue.div(de).toVar()}else D=I(v).toVar();else{let G=Se(L(1).div(tt.resolution.x),L(1).div(tt.resolution.y)).toVar(),K=$f(A==="classic"?Zo.xy.add(tt.cameraJitterPx):Zo.xy).mul(6.28318530718);A==="white"&&(K=K.add(tt.tapAngle));let q=K.toVar(),Y=tt.tapAngle.mul(13.7).toVar(),ue=tt.tapAngle2.mul(5.3).toVar(),de=Se(qb(At(R).add(1))).div(tt.transmissionActualSize).toVar(),ge=$f(Zo.xy.add(Se(Y,ue))).toVar(),be=$f(Zo.xy.add(Se(ue.mul(1.71),Y.mul(2.39)))).toVar(),re=Q(0).toVar();for(let xe=0;xe<E;xe++){let j=Cv(t0(xe,E,q)).mul(G).mul(b).mul(x.mul(10)).mul(U),z=Cv(v.add(j));if(M){let X=s9(fr(ge.add(.7548776662*xe))),te=s9(fr(be.add(.5698402911*xe))),V=Cv(Se(X.sub(.5),te.sub(.5)).mul(de));z=Cv(z.add(V))}re.addAssign(I(z))}D=re.div(E).toVar()}if(e.has("attenuationDistance")){let G=e.getFloat("attenuationDistance"),K=Q(e.getColor("attenuationColor")).toVar();ze(G.greaterThan(0),()=>{let q=Xl(pt(K,Q(1e-4)),Q(r.div(G)));D.mulAssign(q)})}let O=t.alpha.mul(t.mask).toVar(),k=O.div(qt(O.add(i.accumAlpha),L(1e-5),L(1))).toVar();return i.accumAlpha.addAssign(L(1).sub(i.accumAlpha).mul(t.alpha)),{color:D,calpha:k}})}),P5e=F(()=>{gi(),da(),ua(),hMe(),Ra("reflection",(e,t,i)=>{let r=e.getFloat("blur"),n=e.getFloat("thickness"),s=e.getInt("steps"),a=e.getFloat("stepSize"),o=e.getValue("tracingMode")??0,l=tt.reflectionRenderTarget,h=tt.reflectionDepthPyramid,u=tt.reflectionDepthPyramid,d=tt.reflectionDepthLevels,c=tt.reflectionEnvMap,p=tt.reflectionPlanarTarget,f=tt.reflectionPlanarEnabled,m=_g("__splinePlanarMirror","float"),g=f.greaterThan(.5).and(m.greaterThan(.5)),v=tt.reflectionResolveTarget,y=tt.reflectionResolveEnabled,_=tt.orthographicUniform.greaterThan(.5),b=Xi(_,Q(0,0,-1),Ft(Zf)).toVar(),x=Ft(To).toVar(),w=ZA(b,x).toVar(),S=qt(r.mul(.1),L(0),L(1)).toVar(),T=tt.resolution,M=Q(0).toVar(),E=y.greaterThan(.5).and(S.greaterThan(.05)).and(g.not()),A=Ft(QK(w,D4)).toVar(),C=h$(c,A,S).toVar(),D=v.sample(gu).level(L(0)).toVar();ze(E,()=>{let U=D.a.toVar();M.assign(lt(C,D.rgb.div(U.max(1e-4)),qt(U.mul(2),L(0),L(1))))}).Else(()=>{M.assign(rZ({dials:{blur:r,thickness:n,steps:s,stepSize:a,tracingMode:o},surface:{originView:Zf,normalV:x,screenUv:gu,fragWindowZ:JB},camera:{projectionMatrix:Bw,projectionMatrixInverse:i2e,worldMatrix:D4,near:t2e},resources:{colorMap:l,depthPyramid:h,depthPyramidNode:u,envMap:c},usePlanar:g,noisePixel:gu.mul(T).floor()}))}),ze(g,()=>{let U=Se(L(1).sub(gu.x),gu.y).toVar(),O=L(d.sub(1)),k=Li(mw(S.mul(T.y).mul(o$).add(1)),O).toVar(),G=k.sub(1).max(0).floor().toVar(),K=L(2).pow(k).sub(1).max(0).toVar(),q=K.mul(.75).div(T.y).toVar();M.assign(l$(p,U,q,K.mul(.75),G))});let R=t.alpha.mul(t.mask).toVar(),I=R.div(qt(R.add(i.accumAlpha),L(1e-5),L(1))).toVar();return i.accumAlpha.addAssign(L(1).sub(i.accumAlpha).mul(R)),{color:M,calpha:I}})}),R5e=F(()=>{gi(),Uw(),da(),iZ(),ua(),a9=e=>e,jge=e=>e,Ra("outline",(e,t,i)=>{let r=e.getColor("outlineColor"),n=e.getColor("contourColor"),s=e.getFloat("outlineWidth"),a=e.getFloat("contourWidth"),o=e.getFloat("outlineThreshold"),l=e.getFloat("contourThreshold"),h=e.getFloat("outlineSmoothing"),u=e.getFloat("contourFrequency"),d=e.getVec3("contourDirection"),c=e.getBool("positionalLines"),p=e.getBool("compensation"),f=tt.normalRenderTarget,m=tt.normalRenderTargetDepth,g=tt.resolution,v=tt.pixelRatio,y=tZ().x.toVar(),_=JB.toVar(),b=gu.toVar(),x=Se(L(1).div(g.x),L(1).div(g.y)).toVar(),w=tt.pcssHalton,S=$f(Zo.xy.add(w)).mul(6.28318530718).toVar(),T=p.select(s.div(2),s),M=x.mul(T).mul(v).toVar(),E=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=ge=>t0(ge,9,S).mul(x),C=[],D=L(0).toVar();for(let ge=0;ge<9;ge++){let[be,re]=E[ge],xe=ge===4?b:a9(b.add(Se(M.x.mul(be),M.y.mul(re))).add(A(ge))),j=a9(xe).toVar(),z=jge(f.sample(j)).toVar();C.push(z),ze(z.a.notEqual(y).and(z.a.notEqual(0)),()=>{let X=m.sample(j).r.add(1e-4);ze(_.greaterThan(X),()=>{D.assign(1)})})}let R=C[2].rgb.add(C[5].rgb.mul(2)).add(C[8].rgb).sub(C[0].rgb.add(C[3].rgb.mul(2)).add(C[6].rgb)),I=C[0].rgb.add(C[1].rgb.mul(2)).add(C[2].rgb).sub(C[6].rgb.add(C[7].rgb.mul(2)).add(C[8].rgb)),U=Rh(Je(R,R).add(Je(I,I))).mul(D.oneMinus()).toVar(),O=Q(r).toVar(),k=o.sub(h).toVar(),G=o.add(h).toVar(),K=G.greaterThan(k).select(Kr(k,G,U),U.greaterThan(o).select(L(1),L(0))).toVar(),q=Ft(y1).toVar(),Y=L(1).sub(l).toVar();ze(c,()=>{let ge=Xo.mul(d),be=ge.x.add(ge.y).add(ge.z).toVar(),re=fr(be.mul(u).mul(.01)),xe=qq(be.mul(u)),j=Kr(xe.mul(a.mul(.01)),xe.mul(a.mul(.02)),re).toVar();ze(j.lessThan(1).and(K.equal(0)),()=>{O.assign(n),K.assign(1)})}).Else(()=>{let ge=q.mul(d),be=ge.x.add(ge.y).add(ge.z).toVar(),re=qq(be.mul(l)).toVar(),xe=Aa(be.mul(u)).toVar(),j=Kr(L(0),re.mul(a),L(1).sub(xe)).toVar();ze(re.greaterThan(Y.mul(.5)).and(j.lessThan(1)).and(K.equal(0)),()=>{O.assign(n),K.assign(L(1).sub(j))})});let ue=t.alpha.mul(K).mul(t.mask).toVar(),de=ue.div(qt(ue.add(i.accumAlpha),L(1e-5),L(1))).toVar();return i.accumAlpha.addAssign(L(1).sub(i.accumAlpha).mul(ue)),{color:O,calpha:de}})}),D5e=F(()=>{gi(),da(),Ra("vertexColor",(e,t,i)=>{let r=Y2e(),n=t.alpha.mul(t.mask).mul(r.a);return{color:r.rgb,calpha:Fw(n,i)}})}),BEe=F(()=>{g5e(),v5e(),y5e(),_5e(),b5e(),x5e(),w5e(),S5e(),T5e(),M5e(),E5e(),rEe(),A5e(),C5e(),P5e(),R5e(),D5e(),tEe()});function Wge(e){let t=e.data,i=[e.kind,e.type,`v=${!!t.visible}`,`m=${!!t.isMask}`,`p=${e.params.names().join(",")}`];if(e.type!=="light"){let r=Nw[e.type];if(r!==void 0)for(let n of r)i.push(`${n}=${String(t[n])}`)}for(let[r,n]of e.uniformKinds)(n==="vec4array"||n==="floatArray")&&i.push(`${r}#${(e.params.getValue(r)??[]).length}`);if(e.type==="rainbow"&&i.push(`noise=${e.noiseCompiledIn!==!1}`,`forced=${e.noiseForced===!0}`),e.type==="displace"&&i.push(`dt=${String(t.displacementType)}`),e.type==="texture"||e.type==="video"||e.type==="matcap"){if(e.holders.length===0)throw new Error(`structuralKey: ${e.type} layer has no holder`);let r=t.texture??{};i.push(`holder=${e.holders.map(n=>n.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var N5e=F(()=>{Md()});function ka(e,t=1){let i=new at(e);return new Ur(i.r,i.g,i.b,t)}function j$(e,t){if(e instanceof Ur)return e;if(e instanceof at)return new Ur(e.r,e.g,e.b,1);if(typeof e=="number")return ka(e);if(typeof e=="object"&&e!==null&&"r"in e&&"g"in e&&"b"in e){let i=e;return new Ur(i.r,i.g,i.b,i.a??1)}return t()}function Hge(){let e=new Array(10).fill(new ut(0,0,0,1)).map(t=>t.clone());return e[1]=new ut(1,1,1,1),e}function qge(){let e=new Array(10).fill(1);return e[0]=0,e}function yE(e,t){let i=e.material;if((i==null||i.isTSLNodeMaterial!==!0)&&(i=e.object?.material,i==null||i.isTSLNodeMaterial!==!0))return t;if(t.kind==="light"){let n=i.lightLayer;if(n==null)return t;let s=n.data?.category,a=t.data?.category;return s===a?n:t}let r=i.layers?.[t.structIndex];return r!==void 0&&r.type===t.type?r:t}function $ge(e,t){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new Error(`[spe] ${e}.element() needs a build-time constant index (got ${String(t)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return t}function fi(e,t,i,r){let n,s,a=e.params;switch(i){case"float":n=Be(Number(r??0));break;case"int":n=Be(Number(r??0),"int");break;case"axis":n=Be(["x","y","z"].indexOf(String(r)),"int");break;case"bool":n=Be(!!r);break;case"vec2":n=Be(r instanceof Z?r:new Z);break;case"vec3":n=Be(r instanceof P?r:new P);break;case"vec4":n=Be(r instanceof ut?r:new ut);break;case"color":{let o=j$(r,()=>ka(16777215));n=Be(o),s=o;break}case"colorVec4":{let o=j$(r,()=>new Ur(1,1,1,1)),l=new ut(o.r,o.g,o.b,o.a),h=Be(l);h.onObjectUpdate(u=>{let d=yE(u,e).params.getLiveValue(t)??o;l.set(d.r,d.g,d.b,d.a)}),n=h,s=o;break}case"vec4array":{let o=Array.isArray(r)?r:[];n=function(l,h,u){let d=new Map;return{element(c){let p=$ge(h,c),f=d.get(p);if(f===void 0){let m=Be(u[p]??new ut);m.onObjectUpdate(g=>(yE(g,l).params.getValue(h)??u)[p]??kEe),f=m,d.set(p,f)}return f},array:u,get value(){return u},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(u.length,c.length);p++){let f=c[p];Array.isArray(f)?u[p].set(f[0]??0,f[1]??0,f[2]??0,f[3]??1):f&&typeof f=="object"&&u[p].set(f.x??0,f.y??0,f.z??0,f.w??1)}}}}(e,t,o.length>0?o:[new ut]),s=o;break}case"floatArray":{let o=Array.isArray(r)?r:[0];n=function(l,h,u){let d=new Map;return{element(c){let p=$ge(h,c),f=d.get(p);if(f===void 0){let m=Be(u[p]??0);m.onObjectUpdate(g=>{let v=yE(g,l).params.getValue(h);return Number((v??u)[p]??0)}),f=m,d.set(p,f)}return f},array:u,get value(){return u},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(u.length,c.length);p++)u[p]=Number(c[p])}}}(e,t,o.length>0?o:[0]),s=o;break}}i!=="vec4array"&&i!=="floatArray"&&i!=="colorVec4"&&(hZ(n),n.onObjectUpdate(o=>{let l=yE(o,e).params.getValue(t);l!==void 0&&uZ(n,l)})),a.set(t,n,s),e.uniformKinds.set(t,i)}function iC(e,t){let i=e.data;i.type!=="displace"?("alpha"in i&&e.params.has("alpha")&&e.params.setValue("alpha",Ih(i.alpha,t)*(i.visible?1:0)),i.type==="outline"&&e.params.has("compensation")&&e.params.setValue("compensation",!!i.compensation&&!!i.visible)):e.params.has("intensity")&&e.params.setValue("intensity",(Nt(i.intensity,t)??1)*(i.visible?1:0))}function FEe(e,t){fi(e,"alpha","float",t.alpha??1),fi(e,"mode","int",t.mode??0),fi(e,"isMask","float",t.isMask?1:0)}function UEe(e,t,i,r){let n=new _E(e,t,i),s=i;if(fi(n,"alpha","float",Ih(s.alpha,r)),fi(n,"mode","int",s.mode??0),fi(n,"bumpMapIntensity","float",s.bumpMapIntensity??5),fi(n,"alphaOverride","float",Ih(s.alphaOverride,r)),i.visible)if(s.category==="lambert")fi(n,"emissive","color",r.color(s.emissive)??ka(0)),fi(n,"occlusion","bool",s.occlusion??!0);else if(s.category==="toon")fi(n,"shininess","float",s.shininess??30),fi(n,"specular","color",r.color(s.specular)??ka(1118481));else if(s.category==="physical"){fi(n,"roughness","float",s.roughness??.3),fi(n,"metalness","float",s.metalness??0),fi(n,"reflectivity","float",s.reflectivity??.5),fi(n,"occlusion","bool",s.occlusion??!0),fi(n,"normalScale","float",s.normalScale??1),fi(n,"aoMapIntensity","float",s.aoMapIntensity??1),fi(n,"emissive","color",s.emissive!==void 0?r.color(s.emissive)??ka(0):ka(0)),fi(n,"emissiveIntensity","float",s.emissiveIntensity??1);let a=s;a.clearcoat!==void 0&&(fi(n,"clearcoat","float",a.clearcoat),fi(n,"clearcoatRoughness","float",a.clearcoatRoughness??.1)),a.sheen!==void 0&&(fi(n,"sheen","float",a.sheen),fi(n,"sheenColor","color",a.sheenColor!==void 0?r.color(a.sheenColor)??ka(16777215):ka(16777215)),fi(n,"sheenRoughness","float",a.sheenRoughness??.5)),a.ior!==void 0&&(fi(n,"ior","float",a.ior),fi(n,"specularIntensity","float",a.specularIntensity??1),fi(n,"specularColor","color",a.specularColor!==void 0?r.color(a.specularColor)??ka(16777215):ka(16777215))),a.iridescence!==void 0&&(fi(n,"iridescence","float",a.iridescence),fi(n,"iridescenceIOR","float",a.iridescenceIOR??1.3),fi(n,"iridescenceThickness","float",a.iridescenceThickness??400))}else fi(n,"shininess","float",s.shininess??30),fi(n,"specular","color",s.specular!==void 0?r.color(s.specular)??ka(1118481):ka(1118481)),fi(n,"occlusion","bool",s.occlusion??!0);return n.node.alphaOverride=n.params.get("alphaOverride"),iC(n,r),n}function zEe(e,t,i,r){let n=new rC("fragment",e,t,i),s=i.type==="texture"?i.texture.image!=null?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):i.type==="video"?r.video(i.texture.video):i.texture.image!=null?r.image(i.texture.image):r.getImage("");n.holders.push(s);let a=i.texture.wrapping??(i.type==="texture"?1e3:1001),o=function(h,u,d,c){let p=mt(h.getTexture(u,d,c));return p.onRenderUpdate(()=>h.getTexture(u,d,c)),p}(s,a,i.texture.minFilter??1008,i.texture.magFilter??1006);n.params.set("texture",o);let l=Nt(i.texture.rotation??0,r)??0;if(i.type==="matcap")fi(n,"rotation","float",l*Qe.DEG2RAD);else{let h=Be(new Z(1,1));h.onRenderUpdate(()=>{let m=s.getTexture(a,i.texture.minFilter??1008,i.texture.magFilter??1006).image;h.value.set(m?.width??1,m?.height??1)}),n.params.set("textureSize",h),n.uniformKinds.set("textureSize","vec2");let u=Be(s.loaded||s.isBuffer?1:0);u.onRenderUpdate(()=>s.loaded||s.isBuffer?1:0),n.params.set("loaded",u),n.uniformKinds.set("loaded","float"),fi(n,"crop","float",i.crop?1:0),fi(n,"projection","int",i.projection??0),fi(n,"axis","axis",i.axis),fi(n,"projectionAxis","axis",i.projectionAxis),fi(n,"uvChannel","int",Jg.of(i.uvChannel)),fi(n,"side","int",i.side??0);let d=i.size?new Z(Nt(i.size[0],r)??0,Nt(i.size[1],r)??0):new Z(100,100);fi(n,"size","vec2",d),fi(n,"blending","float",i.blending??0);let c=new si,p=new VEe([Nt(i.texture.repeat?.[0]??1,r)??1,Nt(i.texture.repeat?.[1]??1,r)??1],[Nt(i.texture.offset?.[0]??0,r)??0,Nt(i.texture.offset?.[1]??0,r)??0],l,c),f=Be(c);hZ(f),f.onObjectUpdate(m=>{let g=yE(m,n).params.getNodeValue("mat");g!==void 0&&uZ(f,g)}),n.params.set("mat",f,p)}return FEe(n,{alpha:Ih(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),iC(n,r),n}function I5e(e,t,i){return typeof e!="string"||t!=="float"&&t!=="int"?e instanceof P?Hc(e,i):e instanceof Z?wd(e,i):e:Nt(e,i)}function O5e(e,t,i,r){if(i.type==="light")return UEe(e,t,i,r);if(i.type==="texture"||i.type==="video"||i.type==="matcap")return zEe(e,t,i,r);if(i.type==="displace")return function(o,l,h,u){if(h.displacementType!=="noise")throw new Error;let d=new rC("vertex",o,l,h),c=(p,f)=>Nt(p,u)??f;return fi(d,"offset","vec3",new P(...h.offset.map(p=>c(p,0)))),fi(d,"scale","float",c(h.scale,10)),fi(d,"intensity","float",c(h.intensity,8)),fi(d,"movement","float",c(h.movement,1)),fi(d,"noiseType","int",h.noiseType??0),fi(d,"voronoiStyle","int",h.voronoiStyle??0),fi(d,"smoothness","float",c(h.smoothness,.5)),fi(d,"seed","float",c(h.seed,0)),fi(d,"highCut","float",c(h.highCut,1)),fi(d,"lowCut","float",c(h.lowCut,0)),fi(d,"quality","int",Nt(h.quality,u)??1),iC(d,u),d}(e,t,i,r);let n=new rC("fragment",e,t,i),s=tl(i,r),a=W$[i.type]??W$.color;for(let[o,l]of Object.entries(a))fi(n,o,l.kind,I5e(s[o],l.kind,r)??l.def());if(i.type==="transmission"){let o=typeof window<"u"?window.innerWidth:1,l=typeof window<"u"?window.innerHeight:1;fi(n,"aspectRatio","vec2",o>=l?new Z(l/o,1):new Z(1,o/l))}return FEe(n,s),iC(n,r),n}var Xge,o9,W$,kEe,VEe,rC,_E,Yge,bg,pZ,L5e=F(()=>{ne(),mn(),Ad(),oF(),gi(),Ot(),gC(),il(),Md(),xu(),BB(),da(),tEe(),eZ(),rEe(),m5e(),BEe(),qB(),N5e(),Xge=e=>e,o9=e=>e,W$={color:{color:{kind:"color",def:()=>ka(Za)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>ka(16777215)},bias:{kind:"float",def:()=>.1},scale:{kind:"float",def:()=>1},intensity:{kind:"float",def:()=>2},factor:{kind:"float",def:()=>1}},dust:{color:{kind:"color",def:()=>ka(10323813)},coverage:{kind:"float",def:()=>.2},softness:{kind:"float",def:()=>.2},noiseStrength:{kind:"float",def:()=>.2},noiseScale:{kind:"float",def:()=>1}},rainbow:{filmThickness:{kind:"float",def:()=>30},movement:{kind:"float",def:()=>0},wavelengths:{kind:"vec3",def:()=>new P},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new P}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>ka(16777215)},attenuationDistance:{kind:"float",def:()=>0}},reflection:{blur:{kind:"float",def:()=>0},thickness:{kind:"float",def:()=>.001},steps:{kind:"int",def:()=>60},stepSize:{kind:"float",def:()=>.005},tracingMode:{kind:"int",def:()=>1}},toon:{positioning:{kind:"int",def:()=>0},colors:{kind:"vec4array",def:Hge},steps:{kind:"floatArray",def:qge},source:{kind:"vec3",def:()=>new P},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new Ur(0,0,0,0)},offset:{kind:"vec3",def:()=>new P}},outline:{outlineColor:{kind:"color",def:()=>ka(16777215)},contourColor:{kind:"color",def:()=>ka(16777215)},outlineWidth:{kind:"float",def:()=>.1},contourWidth:{kind:"float",def:()=>.1},outlineThreshold:{kind:"float",def:()=>.1},contourThreshold:{kind:"float",def:()=>.1},outlineSmoothing:{kind:"float",def:()=>.1},contourFrequency:{kind:"float",def:()=>.1},contourDirection:{kind:"vec3",def:()=>new P(0,1,0)},positionalLines:{kind:"bool",def:()=>!1},compensation:{kind:"bool",def:()=>!0}},depth:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},near:{kind:"float",def:()=>50},far:{kind:"float",def:()=>200},isVector:{kind:"float",def:()=>1},isWorldSpace:{kind:"float",def:()=>0},origin:{kind:"vec3",def:()=>new P},direction:{kind:"vec3",def:()=>new P(1,0,0)},colors:{kind:"vec4array",def:()=>[new ut(0,0,0,1),new ut(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new P(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new Z(1.7,9.2)},fB:{kind:"vec2",def:()=>new Z(8.3,2.8)},distortion:{kind:"vec2",def:()=>new Z(1,1)},colorA:{kind:"colorVec4",def:()=>new Ur(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new Ur(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new Ur(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new Ur(1,1,1,1)},noiseType:{kind:"int",def:()=>0},voronoiStyle:{kind:"int",def:()=>0},highCut:{kind:"float",def:()=>1},lowCut:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},seed:{kind:"float",def:()=>.5},quality:{kind:"int",def:()=>1}},normal:{cnormal:{kind:"vec3",def:()=>new P(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:Hge},steps:{kind:"floatArray",def:qge},offset:{kind:"vec2",def:()=>new Z},morph:{kind:"vec2",def:()=>new Z},angle:{kind:"float",def:()=>0}},pattern:{style:{kind:"int",def:()=>0},projection:{kind:"int",def:()=>0},axis:{kind:"axis",def:()=>"x"},blending:{kind:"float",def:()=>0},offset:{kind:"vec2",def:()=>new Z},colorA:{kind:"colorVec4",def:()=>new Ur(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new Ur(1,1,1,1)},frequency:{kind:"vec2",def:()=>new Z(10,10)},size:{kind:"float",def:()=>.5},variation:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},zigzag:{kind:"float",def:()=>0},rotation:{kind:"float",def:()=>0},vertical:{kind:"vec2",def:()=>new Z(0,1)},horizontal:{kind:"vec2",def:()=>new Z(0,1)},sides:{kind:"int",def:()=>6}}},kEe=new ut,VEe=class{constructor(e,t,i,r){this.repeat=e,this.offset=t,this.rotation=i,this.target=r,this.updateMatrix()}updateMatrix(){this.target.setUvTransform(this.offset[0],this.offset[1],this.repeat[0],this.repeat[1],0,0,0).premultiply(new si().makeRotation(this.rotation*Qe.DEG2RAD))}},rC=class{constructor(e,t,i,r){this.kind=e,this.id=t,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new dZ(t)}get type(){return this.data.type}get uniforms(){return this.params.uniforms}get alphaNode(){return this.params.getFloat("alpha")}get modeNode(){return this.params.getInt("mode")}get isMaskNode(){return this.params.getFloat("isMask")}get isMaskEnabled(){return"isMask"in this.data&&!!this.data.isMask}hasValue(e){return this.params.has(e)}setValue(e,t){if(e==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof t=="number"&&t!==0&&this.onNoiseMismatch!==void 0){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(e,t),void(i(t)&&(this.noiseCompiledIn=!0))}this.params.setValue(e,t)}getNode(e){return this.params.has(e)?this.params.get(e):void 0}getValue(e){return this.params.getValue(e)}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(e=>e.loaded)}dispose(){for(let e of this.holders)e instanceof Pc||e.deref();this.holders.length=0}},_E=class extends rC{constructor(e,t,i){super("light",e,t,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},Yge={displace_noise:[{nums:["intensity","scale","movement","smoothness","seed","highCut","lowCut"],vecs:["offset"]}],displace_map:[{nums:["intensity"],vecs:[]}],depth:[{nums:["near","far"],vecs:["origin","direction"]}],cavity:[{nums:["ridge","valley"],vecs:[]}],fresnel:[{nums:["bias","scale","intensity","factor"],vecs:[]}],dust:[{nums:["coverage","softness","noiseStrength","noiseScale"],vecs:[]}],rainbow:[{nums:["filmThickness","movement","noiseStrength","noiseScale"],vecs:["offset","wavelengths"]}],noise:[{nums:["scale","move","seed","highCut","lowCut","smoothness"],vecs:["size","distortion","fA","fB"]}],pattern:[{nums:["blending","size","variation","smoothness","zigzag","rotation"],vecs:["offset","frequency","vertical","horizontal"]}],outline:[{nums:["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],vecs:["contourDirection"]}],toon:[{nums:["noiseStrength","noiseScale"],vecs:["offset","source"]}],transmission:[{nums:["roughness","thickness","ior"],vecs:[]}],reflection:[{nums:["blur","thickness","steps","stepSize"],vecs:[]}],texture:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],video:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],gradient:[{nums:["angle"],vecs:["offset","morph"]}],matcap:[{nums:["rotation"],vecs:[],path:["texture"]}]},bg=class extends Jt{constructor(e,t,i=!0,r,n=!1){super(),this.allowVariableSaves=i,this.isTSLNodeMaterial=!0,this.layerIdGen=0,this.layers=[],this.flavors=[],this.depthTwins=[],this.depthPrepass=!1,this.depthPrepassCutoff=0,this.depthPrepassTwins=[],this.depthOfFieldTwins=[],this.mrtWriteMask=void 0,this.flatShading=!1,this.wireframe=!1,this.emissiveNode=null,this.shapeBlendOptions=null,this._environmentScope=aMe,this._shapeBlendResources=null,this._shapeBlendColorNode=null,this.shapeBlendObjectNormal=null,this.displacedObjectNormal=null,this.syntheticMapLayers=new Map,this._structuralKey=null,this._structuralKeyVersion=-1,this.forceRainbowNoise=new Set,this.root=r??this,this.isDepthPrepassTwin=n,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(e,t),function(s){if(!pE.has(s)){let a=new WeakRef(s);pE.set(s,a),JA.add(a)}JK++}(this),this.addEventListener("dispose",()=>function(s){let a=pE.get(s);a&&(JA.delete(a),pE.delete(s))}(this))}get envMapRotation(){return Vx(this.environmentScope).rotation}get environmentRoot(){return this.root===this?this:this.root.environmentRoot}get environmentScope(){return this.environmentRoot._environmentScope}claimEnvironmentScope(e){let t=this.environmentRoot;return t._environmentScope!==e&&(t._environmentScope=e,!0)}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let e=this._structuralKey;if(e===null||this._structuralKeyVersion!==this.version){try{e=function(r){let n=r.lightLayer,s=n.data,a=h=>{if(!h)return-1;if(typeof h!="string"){let c=r.syntheticMapLayers?.get(h);return c!==void 0?`img(${Wge(c)};o=${JSON.stringify(h.offset??null)};r=${JSON.stringify(h.repeat??null)};rot=${JSON.stringify(h.rotation??null)})`:"img"}let u=r.layers.findIndex(c=>c.uuid===h);if(u===-1||r.layers[u].kind!=="fragment")return-1;let d=r.layers[u].type;return d==="texture"||d==="video"?u:-1},o=r.category==="physical",l=["spe-tsl-v1",`lights=${r.lights}`,`cat=${r.category}`,`lvis=${s.visible===!0}`,`lidx=${r.layers.indexOf(n)}`,`bump=${a(s.bumpMap)}`,`rough=${o?a(s.roughnessMap):-1}`,`metal=${o?a(s.metalnessMap):-1}`,`nrm=${o?a(s.normalMap):-1}`,`ao=${o?a(s.aoMap):-1}`,`emis=${o?a(s.emissiveMap):-1}`,`rch=${o?s.roughnessMapChannel??"luminance":""}`,`mch=${o?s.metalnessMapChannel??"b":""}`,`ach=${o?s.aoMapChannel??"r":""}`];for(let h of r.layers)l.push(Wge(h));return l.join("|")}(this),this.shapeBlendOptions!==null&&(e+=`|sb:${this.uuid}:${this._shapeBlendResources!==null?1:0}`)}catch{e=super.customProgramCacheKey()}this._structuralKey=e,this._structuralKeyVersion=this.version}let t=this.envNode instanceof _w?Vx(this.environmentScope).version:0,i=this.physicalLobes();return`${e}|env${t}|lobes${(i.clearcoat?1:0)|(i.sheen?2:0)|(i.iridescence?4:0)}`}get isRoot(){return this.root===this}applyDepthPrepassPolicy(){if(this.isDepthPrepassTwin)return this.depthPrepass=!1,this.colorWrite=!1,void(this.depthWrite=!0);let e=lMe({transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.shapeBlendOptions!==null,data:this.root.data});this.depthPrepass=e,this.depthWrite=!e}getDepthPrepassTwin(e){var t;return(t=this.depthPrepassTwins)[e]??(t[e]=this.createDepthTwin(e,!1))}getDepthOfFieldTwin(e){var t;return(t=this.depthOfFieldTwins)[e]??(t[e]=this.createDepthTwin(e,!0))}createDepthTwin(e,t){let i=this.root,r=new bg(i.data,i.lastContext,i.allowVariableSaves,i,!0);return r.flatShading=this.flatShading,r.side=e,r.wireframe=!1,r.depthPrepassCutoff=VY,t||(r.mrtWriteMask={velocity:!0}),r.applyDepthPrepassPolicy(),i.depthTwins.push(r),r}get vertexObjectNormal(){return this.shapeBlendObjectNormal??this.root.displacedObjectNormal}get category(){return this.lightLayer.category}envReflectiveInLow(){let e=!1;for(let t of this.layers){let i=t.data;if(i?.category==="physical"&&(e=!0,i.roughnessMap!==void 0||i.metalnessMap!==void 0||typeof i.roughness!="number"||typeof i.metalness!="number"||i.clearcoat!==void 0||i.sheen!==void 0||i.iridescence!==void 0||i.ior!==void 0||i.metalness>.3||i.roughness<.4))return!0}return!e}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(e,t,i=!1){(this.data!==e||i)&&this.reset0(e,t)}reset0(e,t){this.lastContext=t,this.data=e;let i=e.layers??Un.defaultTwoLayerData("phong").layers;for(let s of this.layers)s.dispose();for(let s of this.syntheticMapLayers.values())s.dispose();this.syntheticMapLayers.clear();let r=[];for(let s of i)try{let a=O5e(this.layerIdGen++,s.id,s.data,t.shared);a.type==="rainbow"&&this.armRainbowNoiseSpecialization(a),r.push(a)}catch(a){console.warn(`[spe] material layer '${s?.data?.type}' (${s?.id}) failed to build \u2014 skipping this layer`,a)}this.layers=r,this.layers.reverse();for(let s=0;s<this.layers.length;s++)this.layers[s].structIndex=s;this.name=e.name??"Untitled Material";let n=this.layers.find(s=>s instanceof _E);if(n===void 0&&(n=UEe(0,"",{...ts.defaultData("light","phong"),visible:!1},t.shared)),this.lightLayer=n,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:L(0).toVar("accumAlpha"),lightsAvailable:this.lights&&(this.category==="phong"||this.category==="lambert"||this.category==="physical")},this.colorNode=He(()=>this.buildColorStack())(),this.buildVertexStack(),this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=this.lights&&this.category==="lambert"&&this.lightLayer.params.has("emissive")?this.lightLayer.params.get("emissive"):null,this.aoNode=null,this.lights&&this.category==="physical"){let s=this.lightLayer.params,a=this.lightLayer.lightData;if(s.has("emissive")){let l=this.findTextureMapLayer(a.emissiveMap);this.emissiveNode=He(()=>{let h=Q(s.getColor("emissive")).mul(s.getFloat("emissiveIntensity"));return l!==null&&(h=h.mul(function(u){let d,c=u.get("texture"),p=u.has("loaded")?u.getFloat("loaded"):L(1),{uvs:f,weights:m}=nA(u);if(m!==null){let g=Q(xo(c.sample(f[0])).rgb).toVar(),v=Q(xo(c.sample(f[1])).rgb).toVar(),y=Q(xo(c.sample(f[2])).rgb).toVar();d=on(g.mul(m.z).add(v.mul(m.x)).add(y.mul(m.y)))}else d=on(Q(xo(c.sample(f[0])).rgb));return on(lt(Q(0),d,p))}(l.params))),h})()}let o=this.findTextureMapLayer(a.aoMap);o!==null&&(this.aoNode=He(()=>lt(L(1),Qj(o.params,a.aoMapChannel??"r"),s.getFloat("aoMapIntensity")))())}this.transparent=vu(e,t.shared),this.applyDepthPrepassPolicy(),FO(this),this.needsUpdate=!0;for(let s of this.flavors)s?.syncFromRoot();for(let s of this.depthTwins)s.syncFromRoot();this.saveVariableLocations(t)}setTransparent(e,t){if(!this.isRoot)return void this.root.setTransparent(e,t);let i=this.transparent!==e;if(i){this.transparent=e,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=e,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=e,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||t?.markNeedsUpdateRendererDirty()}syncFromRoot(){let e=this.root;this.data=e.data,this.layers=e.layers,this.lightLayer=e.lightLayer,this.ctx=e.ctx,this.name=e.name,this.lights=e.lights,this.colorNode=e.colorNode,this.positionNode=e.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=e.emissiveNode,this.aoNode=e.aoNode,this.transparent=e.transparent,this.applyDepthPrepassPolicy(),this._applyShapeBlendGraph(),FO(this),this.needsUpdate=!0}getFlavor(e,t,i,r){if(!this.isRoot)return this.root.getFlavor(e,t,i,r);let n=i?6:(e?3:0)+t;if(n+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),n===0)return this;n-=1;let s=this.flavors[n];return s===void 0&&(s=new bg(this.data,this.lastContext,this.allowVariableSaves,this),s.flatShading=e,s.side=t,s.wireframe=i,r&&(s.shapeBlendOptions={...r},s.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},s._invalidateStructuralKey()),s.applyDepthPrepassPolicy(),this.flavors[n]=s),s}getShapeBlendBaseColor(){let e=this.layers.find(r=>r.kind==="fragment"&&r.type==="color"),t=e?.getValue("color"),i=e?.getValue("alpha");return{r:t?.r??1,g:t?.g??1,b:t?.b??1,a:i??1}}setShapeBlendResources(e){this._shapeBlendResources=e,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources||b4===null)return;let e=b4(this._shapeBlendResources);this.positionNode=e.position,this.shapeBlendObjectNormal=e.normal,this.normalNode=this.buildNormalNode($q(I4(e.normal))),this.castShadowPositionNode=e.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=e.color,this.colorNode=He(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(e=>e instanceof _E)}findTextureMapLayer(e){if(!e)return null;if(typeof e!="string")return FA.is(e)?this.syntheticMapLayer(e):null;let t=this.layers.find(i=>i.uuid===e);return t===void 0||t.kind!=="fragment"?null:t.type==="texture"||t.type==="video"?t:null}syntheticMapLayer(e){if(!this.isRoot)return this.root.syntheticMapLayer(e);let t=this.syntheticMapLayers.get(e);if(t!==void 0)return t;try{let i=ts.defaultData("texture"),r={...i,visible:!1,texture:{...i.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],rotation:e.rotation??0,minFilter:e.minFilter??1008,magFilter:e.magFilter??1006},uvChannel:Jg.of(e.uvChannel)},n=zEe(this.layerIdGen++,`mapImage${this.layerIdGen}`,r,this.lastContext.shared);return this.syntheticMapLayers.set(e,n),n}catch(i){return console.warn("[spe] light-layer map image failed to build \u2014 skipped",i),null}}buildNormalNode(e){if(this.lights&&this.category==="physical"&&!this.wireframe){let n=this.lightLayer.lightData,s=this.findTextureMapLayer(n.normalMap);if(s!==null){let a=this.lightLayer.params.getFloat("normalScale");return He(()=>function(o,l,h){let u=Q(h??To).toVar(),d=on(Zf),c=o.get("texture"),p=o.has("loaded")?o.getFloat("loaded"):L(1),f=v=>{let y=Se(v).toVar(),_=Q(xo(c.sample(y)).rgb.mul(2).sub(1)).toVar(),b=Q(lt(Q(0,0,1),on(_),p)).toVar();b.xy.mulAssign(l);let x=Q(pw(d)).toVar(),w=Q(fw(d)).toVar(),S=Se(pw(y)).toVar(),T=Se(fw(y)).toVar(),M=Q(Ft(on(u))).toVar(),E=Q(qn(on(w),M)).toVar(),A=Q(qn(M,on(x))).toVar(),C=Q(on(E).mul(S.x).add(on(A).mul(T.x))).toVar(),D=Q(on(E).mul(S.y).add(on(A).mul(T.y))).toVar(),R=L(pt(Je(on(C),on(C)),Je(on(D),on(D)))).toVar(),I=L(Xi(R.equal(0),L(0),Fc(tF).mul(qK(R)))).toVar();return on(Ft(on(C).mul(b.x.mul(I)).add(on(D).mul(b.y.mul(I))).add(M.mul(b.z))))},{uvs:m,weights:g}=nA(o);if(g!==null){let v=f(m[0]),y=f(m[1]),_=f(m[2]);return on(Ft(v.mul(g.z).add(y.mul(g.x)).add(_.mul(g.y))))}return f(m[0])}(s.params,a,e))()}}let t=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&this.category!=="lambert";if(t===null||!i||this.wireframe)return e;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return He(()=>function(n,s,a){let o=Q(a??To).toVar(),l=on(Zf),h=n.get("texture"),{uvs:u,weights:d}=nA(n);if(d!==null){let c=TN(l,on(o),SN(h,u[0],s)),p=TN(l,on(o),SN(h,u[1],s)),f=TN(l,on(o),SN(h,u[2],s));return on(Ft(c.mul(d.z).add(p.mul(d.x)).add(f.mul(d.y))))}return TN(l,on(o),SN(h,u[0],s))}(t.params,r,e))()}buildVertexStack(){let e=this.layers.filter(i=>i.kind==="vertex");if(e.length===0)return this.positionNode=null,void(this.displacedObjectNormal=null);let t=function(i){let r=Bn("vec3","vDisplacedNormal");return{position:He(n=>{let s=ml(vw),a=ml(XK);for(let l=0;l<i.length;l++){let h=f5e(i[l],ml(vw),a);s=l===0?h.position:ml(s.add(h.position).mul(.5)),a=h.normal}let o=Q(s).toVar();return r.assign(a),n.needsPreviousData?.()===!0&&sF.assign(o),o})(),normal:r}}(e.map(i=>i.params));this.positionNode=t.position,this.displacedObjectNormal=t.normal}displacedNormalView(){let e=this.root.displacedObjectNormal;return e===null?null:$q(I4(e))}maskSourceFor(e){let t=this.layers[e];if(t.kind==="fragment"&&t.isMaskEnabled)return null;let i=this.layers[e+1];return i!==void 0&&i.kind==="fragment"&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(e,t,i){let r=L(1);t!==null&&(r=this.evaluateMask(t));let n={alpha:i?.alpha??e.alphaNode,isMask:e.isMaskNode,mask:r,mode:e.modeNode,noiseCompiledIn:e.noiseCompiledIn},s=KMe(e.type)(e.params,n,this.ctx);return i?.color?{...s,color:i.color}:s}evaluateMask(e){let t=this.runLayerBuilder(e,null);return iF(t.color.mul(t.calpha))}buildColorStack(){let e=this.lightLayerIndex(),t=e===-1?0:e,i=null;for(let r=0;r<t;r++){let n=this.layers[r];if(n.kind!=="fragment")continue;if(i===null){let a=this._shapeBlendColorNode;i=o9(this.runLayerBuilder(n,this.maskSourceFor(r),a?{color:o9(a.rgb),alpha:Xge(a.w)}:void 0).color);continue}if(n.isMaskEnabled)continue;let s=this.runLayerBuilder(n,this.maskSourceFor(r));i=HO(i,s.color,s.calpha,n.modeNode)}return i??s2e(Za)}setup(e){e.context.setupClearcoatNormal=()=>j2e(To,"NORMAL","vec3"),super.setup(e)}setupLightingModel(){let e=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(t,i=null,r=null,n=!1){switch(t){case"physical":{let s=new eEe(r?.clearcoat===!0,r?.sheen===!0,r?.iridescence===!0,!1,!1,!1);return s.envIrradianceActive=n,s}case"lambert":return new kx(!1);case"toon":{let s=new JMe;return s.aoOcclusionGate=i,s}default:return new kx}}(this.category,e,this.physicalLobes(),this.envNode instanceof _w)}physicalLobes(){let e=this.lightLayer.params;return{clearcoat:e.has("clearcoat"),sheen:e.has("sheen"),iridescence:e.has("iridescence")}}setupVariants(e){if(!this.lights)return;let t=null,i=null;if(this.category==="physical"){let r=this.lightLayer.lightData,n=this.findTextureMapLayer(r.roughnessMap);n!==null&&(t=He(()=>Qj(n.params,r.roughnessMapChannel??"luminance"))());let s=this.findTextureMapLayer(r.metalnessMap);s!==null&&(i=He(()=>Qj(s.params,r.metalnessMapChannel??"b"))())}(function(r,n,s=null,a=null){if(r==="phong"||r==="toon")N4.assign(n.getFloat("shininess").max(1e-4)),px.assign(n.getColor("specular"));else if(r==="physical"){let o=n.getFloat("metalness"),l=n.getFloat("roughness"),h=n.getFloat("reflectivity");if(s!==null&&(l=bw(s.mul(l))),a!==null&&(o=bw(qt(a.mul(o),L(0),L(1)))),_2e.assign(o),ZK.assign(qt(l,L(.0525),L(1))),n.has("ior")){let u=n.getFloat("ior"),d=n.has("specularColor")?Q(n.getColor("specularColor")):Q(1),c=n.has("specularIntensity")?n.getFloat("specularIntensity"):L(1);DO.assign(u),px.assign(Li(L2e(DO.sub(1).div(DO.add(1))).mul(d),Q(1)).mul(c)),k$.assign(lt(cl(px),cl(Wl.rgb),o)),Xq.assign(lt(c,L(1),o))}else{let u=Q(h.pow(2).mul(.16));px.assign(u),k$.assign(lt(u,cl(Wl.rgb),o)),Xq.assign(L(1))}if(z$.assign(cl(Wl.rgb).mul(Pn(o))),n.has("clearcoat")&&(r2e.assign(n.getFloat("clearcoat")),WK.assign(qt(n.getFloat("clearcoatRoughness"),L(.0525),L(1)))),n.has("sheen")){let u=n.has("sheenColor")?Q(n.getColor("sheenColor")):Q(1);k2e.assign(u.mul(n.getFloat("sheen"))),V2e.assign(qt(n.getFloat("sheenRoughness"),L(.07),L(1)))}n.has("iridescence")&&(c2e.assign(n.getFloat("iridescence")),p2e.assign(n.getFloat("iridescenceIOR")),f2e.assign(n.getFloat("iridescenceThickness")))}})(this.category,this.lightLayer.params,t,i)}setupLighting(e){let t=this.lights===!0||this.lightsNode!==null,i=this.lights===!0?this.setupMaterialLightings(e):[],r=t?this.lightsNode??e.lightsNode:null,n=this.lights===!0?Q(0):Wl.rgb,s=Q(0),a=Q(0);if(r&&(i.length>0||r.getScope().hasLights)){let o=this.setupLightingModel()||null,l=g2e(r,o,i,this.backdropNode,this.backdropAlphaNode),h=l,u=h._value??(h._value=h.getContext());s=u.reflectedLight.directSpecular,a=u.reflectedLight.indirectSpecular,n=l}return this.emissiveNode!==null&&this.emissiveNode!==void 0&&(Hq.assign(Q(this.emissiveNode)),n=n.add(Hq)),He(()=>this.applyPostLighting(n,s,a))()}applyPostLighting(e,t,i){let r,n=this.ctx.accumAlpha,s=this.lights===!0,a=this.lightLayerIndex(),o=a===-1?0:a+1,l=L(1);if(s){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p)),r=function(f){let{outgoing:m,directSpecular:g,indirectSpecular:v,shadingAlpha:y,shadingBlend:_,mask:b,occlusion:x=null,ctx:w}=f,S=Q(m).toVar();return ze(GK(YK(S,cl(Wl.rgb))),()=>{let T=qt($i(g.add(v)),L(0),L(1));w.accumAlpha.addAssign(Pn(w.accumAlpha).mul(y).mul(b).mul(T)),S.assign(HO(cl(Wl.rgb),S,y.mul(b),_)),S.mulAssign(QMe(x))}),S}({outgoing:e,directSpecular:t,indirectSpecular:i,shadingAlpha:this.lightLayer.alphaNode,shadingBlend:this.lightLayer.modeNode,mask:l,occlusion:this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null,ctx:this.ctx})}else r=Q(e).toVar();let h=r,u=!1;for(let p=o;p<this.layers.length;p++){let f=this.layers[p];if(f.kind!=="fragment"||f.isMaskEnabled)continue;let m=this.runLayerBuilder(f,this.maskSourceFor(p));h=HO(h,m.color,m.calpha,f.modeNode),u=!0}if(u&&r.assign(h),!s){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p))}let d=this.lightLayer.params.has("alphaOverride")?this.lightLayer.params.getFloat("alphaOverride"):L(1),c=s?n:n.mul(l);if(Wl.a.assign(c.mul(d)),Wl.a.lessThanEqual(0).or(c.lessThanEqual(y2e("depthPrepassCutoff","float"))).discard(),this.dithering){let p=KK(Zo.xy),f=Q(.25/255,-.25/255,.25/255),m=lt(f.mul(2),f.mul(-2),p);r.assign(r.add(m))}return r}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}armRainbowNoiseSpecialization(e){let t=this.root.forceRainbowNoise.has(e.uuid),i=e.data;if(e.noiseForced=t,e.noiseCompiledIn=t||Hf(i.noiseStrength),e.noiseCompiledIn===!1){let r=e.uuid;e.onNoiseMismatch=n=>this.root.ensureRainbowNoiseCompiled(r,n)}}ensureRainbowNoiseCompiled(e,t){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(e,t);let i=this.data.layers?.data(e);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(e)&&!Hf(i.noiseStrength)||this.getLayerByUuid(e)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(e),this.reset0(this.data,this.lastContext),t!==void 0&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}updateByOp(e,t,i){if(this.isRoot)if(t!==void 0?this.data=t:t=this.data,this.setTransparent(vu(t,i.shared),i.scene),e.path[0]==="layers"){let r=e.path[1];if(r===void 0)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(t,i);e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===r);if(!n)return;let s=t.layers.data(r);if(!s)return;this.updateLayerByOp(n,{...e,path:e.path.slice(2)},s,i)?this.reset0(t,i):FO(this)}else this.reset0(t,i);else this.root.updateByOp(e,t,i)}static hasVariableString(e){return typeof e=="string"||Array.isArray(e)&&e.some(t=>typeof t=="string")}updateLayerTextureByOp(e,t,i){if(t.path.length!==1||t.type!==0)return!0;let r=t.props,n=i.texture;if(!n)return!0;let s=e.data.texture;for(let o of Object.keys(r))if(o!=="repeat"&&o!=="offset"&&o!=="rotation"||bg.hasVariableString(n[o])||bg.hasVariableString(s?.[o]))return!0;if(e.type==="matcap")return"repeat"in r||"offset"in r||(e.data=i,e.setValue("rotation",(n.rotation??0)*Qe.DEG2RAD),!1);let a=e.getValue("mat");if(!a)return!0;if(e.data=i,"repeat"in r){let o=n.repeat;a.repeat=[o?.[0]??1,o?.[1]??1]}if("offset"in r){let o=n.offset;a.offset=[o?.[0]??0,o?.[1]??0]}return"rotation"in r&&(a.rotation=n.rotation??0),a.updateMatrix(),!1}updateLayerByOp(e,t,i,r){if(t.path[0]==="texture")return this.updateLayerTextureByOp(e,t,i);if(t.path[0]!==void 0||t.type!==0)return!0;let n=t.props;if("type"in n||"category"in n||"visible"in n||"noiseType"in n)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let s of Object.keys(n)){if(s==="isMask")return!0;if(e.type==="rainbow"&&s==="noiseStrength"&&e.noiseCompiledIn!==void 0){let u=i[s];if((e.noiseForced===!0||Hf(u))!==e.noiseCompiledIn)return!0}let a=Nw[e.type];if(a!==void 0&&a.includes(s))return!0;let o=hK[e.type];if(o!==void 0&&o.includes(s)){let u=e.getValue(s),d=n[s];if(Array.isArray(u)&&Array.isArray(d)&&u.length!==d.length)return!0}let l=i[s],h=e.data[s];if(s!=="axis"&&(typeof l=="string"||typeof h=="string")||Array.isArray(l)&&l.some(u=>typeof u=="string")||Array.isArray(h)&&h.some(u=>typeof u=="string"))return!0}e.data=i;for(let s of Object.keys(n))this.applyLayerValue(e,s,i,r.shared);return!1}applyLayerValue(e,t,i,r){let n=i;if((t==="alpha"||t==="visible"||t==="intensity")&&(iC(e,r),t!=="intensity"||e.type==="displace"))return;if(t==="alphaOverride"&&e instanceof _E)return void e.setValue("alphaOverride",Ih(n[t],r));if(!e.hasValue(t))return;let s=e.uniformKinds.get(t),a=n[t];switch(s){case"color":case"colorVec4":{let o=e.getValue(t),l=typeof a=="string"?r.color(a):j$(a,()=>o??new Ur(1,1,1,1));o&&l&&o.setRGBA(l.r,l.g,l.b,"a"in l?l.a:1);break}case"vec2":{let o=e.getValue(t);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y));break}case"vec3":{let o=e.getValue(t);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y),Number(a[2]??o.z));break}case"vec4array":{let o=e.getValue(t);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++){let h=a[l];o[l].set(h[0],h[1],h[2],h[3])}break}case"floatArray":{let o=e.getValue(t);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++)o[l]=Number(a[l]);break}case"axis":e.setValue(t,["x","y","z"].indexOf(String(a)));break;case"bool":e.setValue(t,!!a);break;default:(typeof a=="number"||typeof a=="boolean")&&e.setValue(t,a)}}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")return this.setTransparent(vu(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));if(e[0]!=="layer")return;let r=e[1],n=e[2];if(!r||!n)return;let s=this.layers.find(l=>l.uuid===r);if(!s?.hasValue(n))return;if(dSe(s.type,n))return n==="alpha"&&this.setTransparent(vu(this.data,i.shared),i.scene),void s.setValue(n,cSe(n,t,s.data.visible));let a=s.getValue(n),o=e[3];(o==="x"||o==="y"||o==="z")&&a?.isVector3||(o==="x"||o==="y")&&a?.isVector2?a[o]=Number(t):a instanceof Ci||s.setValue(n,t)}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{let r=i.data;"alpha"in r&&typeof r.alpha=="string"&&e.shared.getVariable(r.alpha,["material",this.uuid,"layer",i.id,"alpha"]);let n=i.data.type==="displace"?r.displacementType==="noise"?"displace_noise":"displace_map":i.data.type,s=Yge[n];if(s)for(let a of s){let o=r;for(let l of a.path??[])l in o&&(o=o[l]);for(let l of a.nums)l in o&&e.shared.getVariable(o[l],["material",this.uuid,"layer",i.id,...a.path??[],l]);for(let l of a.vecs)Array.isArray(o[l])&&o[l].forEach((h,u)=>{e.shared.getVariable(h,["material",this.uuid,"layer",i.id,...a.path??[],l,u===0?"x":u===1?"y":"z"])})}})}clampUniformsForPreview(e,t){let i=(r,n,s)=>Math.min(Math.max(r,n),s);for(let r of this.layers)if(r.type==="displace"){let n=r.uniforms[`f${r.id}_intensity`];n.value=i(n.value,e,t)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(e=>e.assetsLoaded))return!1;for(let e of this.root.syntheticMapLayers.values())if(!e.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let e of this.layers)e.dispose();for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let e of this.flavors)e?.dispose();for(let e of this.depthTwins)e.dispose()}},pZ=class extends bg{constructor(e,t,i){super(e,t,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}}});function iu(e,t){let i=Wi(e.xyz);return Wi(t.add(qn(i,qn(i,t).add(t.mul(e.w))).mul(2)))}function Q_(e){let t=Hx(e),i=Hx(Q(e.y.sub(19.1),e.z.add(33.4),e.x.add(47.2))),r=Hx(Q(e.z.add(74.2),e.x.sub(124.5),e.y.add(99.4)));return Q(t,i,r)}function Kge(e,t){return GEe({p:e,seed:t})}function Zge(e,t,i){return Q(qO(Wi(e.add(Q(i)).mul(t))),qO(Wi(e.add(Q(i.add(20))).mul(t))),qO(Wi(e.add(Q(i.sub(30))).mul(t))))}function l9(e){return{f:(t,i=0)=>_h(e.node(t)??e.getUniform(t,i)),v3:t=>Wi(e.node(t)??e.getUniform(t,null)),v4:t=>Vl(e.node(t)??e.getUniform(t,null)),tex:t=>e.node(t)??e.getTexture(t,null)}}function B5e(e,t){switch(e){case"position":return function(i){let r=l9(i.registry);return He(()=>{let n=Hi(),s=i.depTexture("uCurrentPosition"),a=i.depTexture("uCurrentVelocity"),o=i.depTexture("uCurrentEmissionRate"),l=Vl(s.sample(n)).toVar(),h=Wi(l.xyz).toVar(),u=Vl(o.sample(n)).toVar(),d=_h(u.x).toVar(),c=_h(u.y).toVar(),p=_h(u.z).toVar(),f=Wi(Vl(r.tex("uOriginalPosition").sample(n)).xyz.mul(r.v3("uEmitterSize"))).toVar(),m=Vl(a.sample(n)).toVar(),g=Wi(m.xyz).toVar(),v=_h(m.w).toVar(),y=r.f("uMaxLifeTime",1),_=ar(.5,v),b=L(3).mul(_),x=g.mul(L(1).add(b)),w=g.mul(Li(r.f("uFPSRatio",1),L(5)));h.addAssign(lt(w,x,_));let S=iu(r.v4("uWorldQuaternion"),f).add(r.v3("uWorldOffset"));h.assign(lt(h,S,d)),p.assign(lt(p,r.f("uTime"),d));let T=pt(y.sub(r.f("uTime").sub(p)),L(0)).div(y);return lt(Ae(0),Ae(h,T),c)})()}(t);case"velocity":return function(i){let r=l9(i.registry),n=i.features;return He(()=>{let s=Hi(),a=i.depTexture("uCurrentPosition"),o=i.depTexture("uCurrentVelocity"),l=i.depTexture("uCurrentEmissionRate"),h=Wi(Vl(a.sample(s)).xyz).toVar(),u=Wi(Vl(r.tex("uOriginalPosition").sample(s)).xyz).toVar(),d=Wi(Vl(r.tex("uDirections").sample(s)).xyz).toVar(),c=Wi(Vl(o.sample(s)).xyz).toVar(),p=Vl(l.sample(s)).toVar(),f=_h(p.x).toVar(),m=_h(p.y).toVar(),g=_h(Vl(o.sample(s)).w).toVar(),v=L(1).sub(r.f("uRandomMassFactor").mul(function(S){return _h(S.dot(Se(12.9898,78.233)).sin().mul(43758.5453).fract())}(function(S){return S.xy}(u)).mul(.5).add(.5))).toVar(),y=r.f("uSpeed",1),_=r.f("uNoiseStrength"),b=r.f("uNoiseScale"),x=r.f("uNoiseSeed");ze(m.equal(1),()=>{n.USE_CURL_NOISE&&(ze(b.greaterThan(0),()=>{c.assign(Kge(Wi(h.mul(b).mul(.002)),x).mul(_.add(1)).mul(.05).mul(y))}),ze(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Kge(h,x).mul(_).mul(.05).mul(y))})),n.USE_SIMPLEX_NOISE&&(ze(b.greaterThan(0),()=>{c.assign(Q(Hx(Wi(h.mul(b).mul(.001))).mul(_.add(1)).mul(.1)).mul(y))}),ze(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Q(Hx(Wi(h.mul(_).mul(.001))).mul(.05)).mul(y))})),n.USE_FBM_NOISE&&(ze(b.greaterThan(0),()=>{c.assign(Zge(Wi(h.mul(b).mul(.001)),_.add(1),x).mul(y))}),ze(_.greaterThan(0).and(b.equal(0)),()=>{c.addAssign(Zge(Wi(h.mul(_).mul(.001)),_.add(1),x).mul(.1).mul(y))})),function(S,T,M,E,A){if(!S.features.USE_COLLIDER)return;let C=pt(T.f("uBounce").mul(2),L(.01)).toVar(),D=T.f("particleSize");if(S.features.USE_SPHERE_COLLIDER){let R=T.v3("uColliderSize"),I=iu(T.v4("uColliderQuaternionInvert"),Wi(M.sub(T.v3("uColliderPos")))).toVar(),U=Wi(I.div(R)).toVar(),O=$i(U).toVar();ze(O.lessThanEqual(L(1).add(D.div($i(R)))).and(A.equal(0)),()=>{let k=U.mul(L(1).add(D.div($i(R)))),G=Ft(Wi(k.div(R.mul(R))));G=iu(T.v4("uColliderQuaternion"),G),E.assign(ZA(E,G).mul(C)),A.assign(1)}).Else(()=>{A.assign(0)})}if(S.features.USE_BOX_COLLIDER){let R=Wi(T.v3("uColliderSize").div(2)),I=iu(T.v4("uColliderQuaternionInvert"),Wi(M.sub(T.v3("uColliderPos")))).toVar(),U=Wi(oi(I).sub(R)).toVar(),O=pt(U.x,pt(U.y,U.z)).toVar();ze(O.lessThanEqual(D.mul(.5)).and(A.equal(0)),()=>{let k=Q(0).toVar();ze(U.x.greaterThan(U.y).and(U.x.greaterThan(U.z)),()=>{k.assign(Q(Vc(I.x),0,0))}).ElseIf(U.y.greaterThan(U.z),()=>{k.assign(Q(0,Vc(I.y),0))}).Else(()=>{k.assign(Q(0,0,Vc(I.z)))});let G=iu(T.v4("uColliderQuaternion"),Wi(k));E.assign(ZA(E,G).mul(C)),A.assign(1)}).Else(()=>{A.assign(0)})}}(i,r,h,c,g),function(S,T,M,E){if(!S.features.USE_ATTRACTOR)return;let A=T.f("uForceIntensity"),C=T.f("uForceDamping");if(S.features.USE_FORCE_LOCAL_SPACE){let D,R,I=T.f("particleSize");if(S.features.USE_SPHERE_COLLIDER){let U=T.v3("uColliderSize"),O=iu(T.v4("uColliderQuaternionInvert"),Wi(M.sub(T.v3("uColliderPos"))));D=$i(Wi(O.div(U))).toVar(),R=L(1)}else{let U=Wi(T.v3("uColliderSize").div(2)),O=iu(T.v4("uColliderQuaternionInvert"),Wi(M.sub(T.v3("uColliderPos")))),k=Wi(oi(O).sub(U));D=pt(k.x,pt(k.y,k.z)).toVar(),R=I}ze(D.lessThanEqual(R),()=>{let U=S.features.USE_SPHERE_COLLIDER?L(1).sub(D).mul(A):pt(L(1).sub(R.div(D)),L(0)).mul(A),O=Wi(M.sub(T.v3("uColliderPos"))),k=Ft(O).mul(U);E.subAssign(k),E.mulAssign(C)})}else{let D=Wi(M.sub(T.v3("uColliderPos"))),R=Ft(D).mul(A);E.subAssign(R),E.mulAssign(C)}}(i,r,h,c),function(S,T,M,E,A,C,D){if(!S.features.USE_VORTEX)return;let R=T.f("particleSize"),I=Wi(T.v3("uColliderSize").div(2)),U=iu(T.v4("uColliderQuaternionInvert"),Wi(M.sub(T.v3("uColliderPos")))).toVar(),O=Wi(oi(U).sub(I)).toVar(),k=pt(O.x,pt(O.y,O.z)).toVar();ze(k.lessThanEqual(R),()=>{let G=T.f("uForceIntensity"),K=T.v3("uColliderPos").add(iu(T.v4("uColliderQuaternion"),Q(0))),q=Wi(K.sub(M)).toVar(),Y=Q(0,1,.01),ue=Ft(qn(Y,iu(T.v4("uColliderQuaternion"),q))).toVar(),de=$i(q.mul(G).mul(3)).toVar();E.assign(ue.mul(de).mul(.005));let ge=iu(T.v4("uWorldQuaternion"),A);E.addAssign(ge.mul(D).mul(L(1).sub(T.f("uForceDamping"))).div(C.mul(.5)))})}(i,r,h,c,d,v,y)});let w=n.USE_NORMALS?d:r.v3("uDirectionsAxis");return c.assign(lt(c,iu(r.v4("uWorldQuaternion"),w).mul(y),f)),c.addAssign(r.v3("uGravity").div(v.mul(.5)).mul(L(1).sub(g))),Ae(c,g)})()}(t);case"emissionRate":return function(i){let r=l9(i.registry);return He(()=>{let n=Hi(),s=i.depTexture("uCurrentEmissionRate"),a=_h(Vl(r.tex("uIndex").sample(n)).x).toVar(),o=Vl(s.sample(n)).toVar(),l=_h(o.y).toVar(),h=_h(o.z).toVar(),u=r.f("uLastIndexEmitted"),d=r.f("uParticlesToEmit"),c=ar(u,a),p=ar(a,u.add(d).sub(1)),f=c.mul(p);return h.assign(lt(h,r.f("uTime"),f)),Ae(f,lt(l,L(1),f),h,1)})()}(t)}}var _h,Wi,Vl,GEe,Qge,Jge,h9,jEe,F5e=F(()=>{gi(),wC(),_h=e=>e,Wi=e=>e,Vl=e=>e,GEe=He(e=>{let t=Wi(e.p.add(e.seed)).toVar(),i=Q(.1,0,0),r=Q(0,.1,0),n=Q(0,0,.1),s=Q_(Wi(t.sub(i))).toVar(),a=Q_(Wi(t.add(i))).toVar(),o=Q_(Wi(t.sub(r))).toVar(),l=Q_(Wi(t.add(r))).toVar(),h=Q_(Wi(t.sub(n))).toVar(),u=Q_(Wi(t.add(n))).toVar(),d=l.z.sub(o.z).sub(u.y).add(h.y),c=u.x.sub(h.x).sub(a.z).add(s.z),p=a.y.sub(s.y).sub(l.x).add(o.x);return Ft(Q(d,c,p).mul(5))})}),U5e=F(()=>{ne(),mn(),gi(),F5e(),Qge=class{constructor(){this.nodes=new Map,this.textureNodes=new Map}getUniform(e,t){let i=this.nodes.get(e);return i||(i=Be(t),this.nodes.set(e,i)),i}getTexture(e,t){let i=this.textureNodes.get(e);return i||(i=mt(t??new Ci),this.textureNodes.set(e,i)),i}node(e){return this.nodes.get(e)??this.textureNodes.get(e)}adopt(e){for(let t of Object.keys(e)){let i=e[t].value;if(i instanceof Ci||i&&typeof i=="object"&&i.isTexture){let r=this.getTexture(t,i);r.value=i,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(n){r.value=n}}})}else{let r=this.getUniform(t,i);r.value=i,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(n){r.value=n}}})}}}},Jge=class{constructor(e,t,i,r){this.name=e,this.kind=t,this.initialTexture=i,this.currentIndex=0,this.registry=new Qge,this.depTextureNodes=new Map,this.dependencies=[],this.nodeMaterial=null,this._uniformsStore={};let n=()=>new Fi(r,r,{type:Gt,minFilter:gt,magFilter:gt,wrapS:mr,wrapT:mr,depthBuffer:!1});this.renderTargets=[n(),n()],this.material=Object.defineProperty({},"uniforms",{get:()=>this._uniformsStore,set:s=>{this.registry.adopt(s),this._uniformsStore=s}})}get currentRenderTarget(){return this.renderTargets[this.currentIndex]}get nextRenderTarget(){return this.renderTargets[1-this.currentIndex]}advance(){this.currentIndex=1-this.currentIndex}dispose(){this.renderTargets[0].dispose(),this.renderTargets[1].dispose(),this.nodeMaterial?.dispose()}},h9=new Cn,jEe=class{constructor(e,t,i,r){this.sizeX=e,this.sizeY=t,this.renderer=i,this.features=r,this.variables=[],this._copyMaterial=null,this._copyTextureNode=mt(new Ci)}addVariable(e,t,i){let r=new Jge(e,e==="uCurrentPosition"?"position":e==="uCurrentVelocity"?"velocity":"emissionRate",i,this.sizeX);return this.variables.push(r),r}setVariableDependencies(e,t){e.dependencies=t;for(let i of t)e.depTextureNodes.has(i.name)||e.depTextureNodes.set(i.name,mt(i.currentRenderTarget.texture))}init(){if(!this._copyMaterial){let e=new Jt;e.name="WebGPUComputation.copy",e.fragmentNode=Ae(this._copyTextureNode),e.depthTest=!1,e.depthWrite=!1,e.blending=yi,this._copyMaterial=e}for(let e of this.variables){this._copyTextureNode.value=e.initialTexture;for(let i of e.renderTargets)this._renderQuad(this._copyMaterial,i);let t=new Jt;t.name=`WebGPUComputation.${e.kind}`,t.fragmentNode=B5e(e.kind,{features:this.features,registry:e.registry,depTexture:i=>{let r=e.depTextureNodes.get(i);if(!r)throw new Error(`WebGPUComputationRenderer: variable "${e.name}" reads undeclared dependency "${i}"`);return r},resolution:new Z(this.sizeX,this.sizeY)}),t.depthTest=!1,t.depthWrite=!1,t.blending=yi,t.needsUpdate=!0,e.nodeMaterial=t}}compute(){for(let e of this.variables)if(e.nodeMaterial){for(let t of e.dependencies)e.depTextureNodes.get(t.name).value=t.currentRenderTarget.texture;this._renderQuad(e.nodeMaterial,e.nextRenderTarget)}for(let e of this.variables)e.advance()}getCurrentRenderTarget(e){return e.currentRenderTarget}_renderQuad(e,t){let i=this.renderer,r=i.getRenderTarget(),n=i.getMRT();i.setMRT(null),i.setRenderTarget(t),h9.material=e,h9.render(i),i.setRenderTarget(r),i.setMRT(n)}dispose(){for(let e of this.variables)e.dispose();this._copyMaterial?.dispose()}}});function e0e(e,t){switch(e){case"linearFadeOut":return xh(L(1).sub(t));case"linearInOut":return xh(t.lessThan(.5).select(t,L(1).sub(t)));case"exponentialInOut":return xh(t.lessThan(.4).select(t.div(.4),t.greaterThan(.6).select(L(1).sub(t.sub(.6).div(.4)),L(1))));case"constant":return L(1);default:return t}}function t0e(e){return xh(e.dot(Se(12.9898,78.233)).sin().mul(43758.5453).fract())}var xh,WEe,z5e=F(()=>{ne(),mn(),gi(),xh=e=>e,WEe=class extends Jt{constructor(e,t){super(),this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this._uniformsStore={},this._uPosition=mt(new Ci),this._uTexture=mt(new Ci),this._uColor=Be(new ut(1,1,1,1)),this._uColor2=Be(new ut(1,1,1,1)),this._uSize=Be(1),this._uSizeEnd=Be(1),this._uWorldOffset=Be(new P),this._uWorldQuaternion=Be(new ut(0,0,0,1)),this._uRotation=Be(0),this._uRotationEnd=Be(0),this._center=Be(new Z(.5,.5)),this._uRandScaleFactor=Be(0),this._uRandRotationFactor=Be(0),this.context=t,this.name="WebGPUParticleMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.lights=!1;let i=s=>({get value(){return s.value},set value(a){s.value=a}}),r=s=>({get value(){return s.value},set value(a){((o,l)=>{if(Array.isArray(o))l.set(Number(o[0]??1),Number(o[1]??1),Number(o[2]??1),Number(o[3]??1));else if(o&&typeof o=="object"&&"r"in o){let h=o;l.set(h.r,h.g,h.b,h.a??1)}})(a,s.value)}}),n=s=>({get value(){return s.value},set value(a){a&&a.isTexture&&(s.value=a)}});this._binders={uPosition:n(this._uPosition),uTexture:n(this._uTexture),uColor:r(this._uColor),uColor2:r(this._uColor2),uSize:i(this._uSize),uSizeEnd:i(this._uSizeEnd),uWorldOffset:i(this._uWorldOffset),uWorldQuaternion:i(this._uWorldQuaternion),uRotation:i(this._uRotation),uRotationEnd:i(this._uRotationEnd),center:i(this._center),uRandScaleFactor:i(this._uRandScaleFactor),uRandRotationFactor:i(this._uRandRotationFactor)},this._uniformsStore={...this._binders},this.updateState(e),this._rebuildGraph()}get uniforms(){return this._uniformsStore}set uniforms(e){for(let t of Object.keys(e)){let i=this._binders[t];if(!i)continue;let r=e[t]?.value;Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i}),r!==void 0&&(i.value=r)}this._uniformsStore=e}updateState(e){let t=!1;if(e.coloring!==void 0){let i=e.coloring==="random";t||(t=i!==this.isColoringRandom),this.isColoringRandom=i}if(e.color!==void 0&&(this.uniforms.uColor.value=Array.isArray(e.color)?e.color:this.context.shared.color(e.color)),e.color2!==void 0&&(this.uniforms.uColor2.value=Array.isArray(e.color2)?e.color2:this.context.shared.color(e.color2)),e.size!==void 0){this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1];let i=e.size[0]!==e.size[1];t||(t=i!==this.useSizeEnd),this.useSizeEnd=i}e.ease!==void 0&&e.ease!==this.easeOpacity&&(this.easeOpacity=e.ease,t=!0),e.easeSize!==void 0&&e.easeSize!==this.easeSize&&(this.easeSize=e.easeSize,t=!0),t&&this._rebuildGraph(),this.needsUpdate=!0}_rebuildGraph(){let e=cw("particleRef","vec2"),t=this._uPosition,i=He(()=>{let n=t.sample(e).toVar(),s=xh(n.w).toVar(),a=n.xyz.sub(this._uWorldOffset);a=function(M,E){let A=M.xyz;return E.add(A.cross(A.cross(E).add(E.mul(M.w))).mul(2))}(this._uWorldQuaternion,a);let o=cw("position","vec3"),l=L(1).sub(s),h=this.useSizeEnd?o.mul(Q(lt(this._uSize,this._uSizeEnd,l))):o.mul(Q(xh(this._uSize).mul(e0e(this.easeSize,l)))),u=rF,d=u.element(0).xyz.length(),c=u.element(1).xyz.length(),p=t0e(e).toVar(),f=L(1).sub(xh(this._uRandScaleFactor).mul(p)),m=Se(d,c).mul(f).toVar(),g=2*Math.PI,v=p.mul(xh(this._uRandRotationFactor)).mul(g),y=L(1).sub(xh(this._uRotation)).mul(g),_=L(1).sub(xh(this._uRotationEnd)).mul(g),b=lt(y.add(v),_.add(v),s).toVar(),x=this._center,w=h.xy.sub(x.sub(Se(.5))).mul(m).toVar(),S=Se($o(b).mul(w.x).sub(Aa(b).mul(w.y)),Aa(b).mul(w.x).add($o(b).mul(w.y))).toVar(),T=w2e.mul(Ae(a,1)).toVar();return T.xy.addAssign(S),Bw.mul(T)}),r=He(()=>{let n=t.sample(e),s=xh(n.w).toVar();s.lessThanEqual(.005).discard();let a=L(1).sub(s),o=this.isColoringRandom?t0e(e):a,l=lt(this._uColor,this._uColor2,o).toVar(),h=e0e(this.easeOpacity,a).toVar(),u=this._uTexture.sample(Hi()).toVar();return Ae(u.rgb.mul(l.rgb),xh(l.a).mul(u.a).mul(h))});this.vertexNode=i(),this.colorNode=r(),this.needsUpdate=!0}nodeMaterialDispose(){this.dispose()}}}),k5e=F(()=>{wK(),U5e(),z5e(),xK={createComputation:(e,t,i,r)=>new jEe(e,t,i,r),createMaterial:(e,t)=>new WEe(e,t)}});function HEe(e,t){return(i,r,n,s)=>{let a=n.mod(t).add(i.add(.5).div(e)).div(t),o=At(n.div(t)).add(r.add(.5).div(e)).div(t);return mx(s.sample(Se(a,o)))}}function i0e(e){let t=Ar(an(e.x).mul(65535).add(.5)),i=t.bitAnd(Ar(255)).toFloat().mul(.00392156862),r=t.shiftRight(Ar(8)).bitAnd(Ar(255)).toFloat().mul(.00392156862);return Ae(r,i,e.y,e.z)}function qEe(e){let{levelShiftX:t,scale:i,originOffset:r}=function(m){switch(m){case 5:return{levelShiftX:[4,6,12,24,48,96,192],scale:8*bE,originOffset:16};case 7:return{levelShiftX:[4,6,12,24,48,96,192,384,768,1536],scale:2*bE,originOffset:64};case 8:return{levelShiftX:[4,8,16,32,64,128,256,512,1024,2048,4096],scale:bE,originOffset:128};default:return{levelShiftX:[4,8,16,32,64,128,256,512],scale:4*bE,originOffset:32}}}(e.resolutionLevel),n=e.pyramidLevelSizes.length,s=n%2==0?n-3:n-2,a=n%2==0,o=Math.pow(2,e.resolutionLevel),l=e.pyramidLevelSizes[n-1]/o,h=HEe(o,l),u=e.pyramid1Size.width,d=e.pyramid1Size.height,c=e.pyramid2Size.width,p=e.pyramid2Size.height,f=QA(fZ.map(([m,g,v])=>new P(m,g,v)));return m=>{let g=Q(0).toVar(),v=Q(0,0,1).toVar(),y=Ae(0).toVar(),_=m.toVar(),b=At(_.div(3)).toVar(),x=(A,C)=>Se(an(A.x).add(C).add(.5).div(u),an(A.y).add(.5).div(d)),w=(A,C)=>Se(an(A.x).add(C).add(.5).div(c),an(A.y).add(.5).div(p)),S=u-2,T=c-1,M=Se(0,0).toVar(),E=mx(e.pyramid2.sample(w($O(M),T))).toVar();return ze(b.lessThan(an(E.x)),()=>{let A=L(0).toVar(),C=re=>{let xe=mx(E.add(Ae(A))).toVar(),j=Ae(tf(xe.yzw),A),z=mx(Ae(Ae(b).greaterThanEqual(j)).mul(Ae(Ae(b).lessThan(xe)))).toVar();M.mulAssign(2),M.addAssign(Se(0,1).mul(an(z.x)).add(Se(1,1).mul(an(z.y))).add(Se(1,0).mul(an(z.z)))),A.assign(z.dot(j)),re?.()};for(let re=0;re<s;){let xe=t[re];C(()=>{T-=xe,E.assign(e.pyramid1.sample(x($O(M),S)))}),re++;let j=t[re];C(()=>{S-=j,E.assign(e.pyramid2.sample(w($O(M),T)))}),re++}a&&C(null);let D=an(M.x).mod(o).toVar(),R=an(M.y).mod(o).toVar(),I=At(an(M.x).div(o)).add(At(an(M.y).div(o)).mul(l)).toVar(),U=_.sub(A.mul(3)).mul(.0625).add(.03125),O=h(D,R,I,e.voxel).toVar(),k=an(O.w).add(.5).mul(.00390625),G=an(mx(e.triTable.sample(Se(U,k))).x).mul(2).toInt().toVar(),K=Q(D,R,I).add(tf(f.element(G))).toVar(),q=Q(D,R,I).add(tf(f.element(G.add(1)))).toVar(),Y=h(an(K.x),an(K.y),an(K.z),e.potential).toVar(),ue=h(an(q.x),an(q.y),an(q.z),e.potential).toVar(),de=an(Y.x).div(an(Y.x).sub(an(ue.x)));y.assign(lt(i0e(tf(Y.yzw)),i0e(tf(ue.yzw)),de)),g.assign(K.add(q.sub(K).mul(de)).sub(Q(r)).mul(i));let ge=h(an(K.x),an(K.y),an(K.z),e.voxel),be=h(an(q.x),an(q.y),an(q.z),e.voxel);v.assign(Ft(lt(tf(ge.xyz),tf(be.xyz),de)))}),{position:g,normal:v,color:y}}}function r0e(e,t){e.needsPreviousData?.()===!0&&sF.assign(t)}function V5e(e){if(e.cached)return function(n){let s=()=>n.drawIndex?n.drawIndex.element(rA):rA;return{position:He(a=>{let o=tf(n.positions.element(s()).xyz).toVar();return r0e(a,o),o})(),normal:Yq(n.normals.element(s()).xyz),color:Yq(n.colors.element(s()))}}(e.cached);let t=qEe(e),i=Bn("vec3","vShapeBlendNormal"),r=Bn("vec4","vShapeBlendColor");return{position:He(n=>{let{position:s,normal:a,color:o}=t(rA.toFloat());return i.assign(a),r.assign(o),r0e(n,s),s})(),normal:i,color:r}}var an,$O,tf,mx,bE,fZ,mZ=F(()=>{ne(),gi(),an=e=>e,$O=e=>e,tf=e=>e,mx=e=>e,bE=2,fZ=[[0,0,0],[1,0,0],[1,0,0],[1,1,0],[0,1,0],[1,1,0],[0,0,0],[0,1,0],[0,0,1],[1,0,1],[1,0,1],[1,1,1],[0,1,1],[1,1,1],[0,0,1],[0,1,1],[0,0,0],[0,0,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1],[0,1,0],[0,1,1]]});function $Ee(e,t){let i=St(e.xyz);return St(t.add(i.cross(i.cross(t).add(t.mul(Me(e.w)))).mul(2)))}function XEe(e,t,i,r){let n=qt(e,-1,1),s=e.sub(n).mul(2).add(1),a=qt(L(.5).add(n.mul(.5).mul(t.sub(n.mul(s).mul(i))).div(r)),0,1);return Me(lt(t,n.mul(s).mul(i),a).sub(n.mul(r).mul(a).mul(L(1).sub(a))))}function YEe(e,t,i,r,n){let s=L(0).toVar(),a=Me(i.y),o=Me(i.z),l=Me(i.w),h=ze(e.lessThan(.5),()=>{s.assign($i(t).sub(a))}).ElseIf(e.lessThan(1.5),()=>{let d=Q(a,o,l),c=$i(t.div(d)),p=$i(t.div(d.mul(d)));s.assign(c.mul(c.sub(1)).div(p))}).ElseIf(e.lessThan(2.5),()=>{let d=Q(a,o,l),c=oi(t).sub(d).toVar();s.assign($i(pt(c,Q(0))).add(Li(pt(Me(c.x),pt(Me(c.y),Me(c.z))),0)))}).ElseIf(e.lessThan(3.5),()=>{let d=oi(Se($i(XO(t.xz)),Me(t.y))).sub(Se(o,a)).toVar();s.assign(Li(pt(Me(d.x),Me(d.y)),0).add($i(pt(d,Se(0)))))}).ElseIf(e.lessThan(4.5),()=>{let d=a,c=o,p=l,f=Se($i(XO(t.xz)),Me(t.y)).toVar(),m=Se(p,d),g=Se(p.sub(c),d.mul(2)),v=Se(Me(f.x).sub(Li(Me(f.x),Me(f.y).lessThan(0).select(c,p))),oi(Me(f.y)).sub(d)).toVar(),y=f.sub(m).add(g.mul(qt(Je(m.sub(f),g).div(Je(g,g)),0,1))).toVar(),_=Me(y.x).lessThan(0).and(Me(v.y).lessThan(0)).select(L(-1),L(1));s.assign(_.mul(Rh(Li(Je(v,v),Je(y,y)))))}).ElseIf(e.lessThan(5.5),()=>{let d=Se($i(XO(t.xy)).sub(a),Me(t.z));s.assign($i(d).sub(o))}),u=()=>{let d=oi(Me(t.x)).toVar(),c=Se(a,o),p=l,f=Me(r.w),m=Me(c.y).mul(d).greaterThan(Me(c.x).mul(Me(t.y))).select(Je(Se(d,Me(t.y)),c),$i(Se(d,Me(t.y)))),g=Q(d,Me(t.y),Me(t.z));s.assign(Rh(Je(g,g).add(p.mul(p)).sub(p.mul(m).mul(2))).sub(f))};return n?h.ElseIf(e.lessThan(6.5),u).Else(()=>{s.assign(n(t,i,r))}):h.Else(u),s}function H$(e,t=!0){let i=e.spatialDivisions,r=e.spatialn;return(n,s)=>{let a=t?Ae(0).toVar():Ae(0),o=L(1e3).toVar(),l=t?L(0).toVar():L(0),h=t?L(0).toVar():L(0),u=Me(s.y).add(Me(s.z).mul(i)).add(.5).div(i*i),d=(f,m)=>{let g=m.toVar();Yr(Jb,({i:v})=>{ze(g.lessThan(1),()=>{qa()}),g.mulAssign(.5),ze(fr(g).greaterThanEqual(.5),()=>{let y=L(v).add(f).add(.5).mul(1/H4),_=e.shapeRow(y,0).toVar(),b=e.shapeRow(y,1).toVar(),x=e.shapeRow(y,2).toVar(),w=e.shapeRow(y,3).toVar(),S=$Ee(_o(b),St(n.sub(St(_.xyz)))).div(Me(w.z)).toVar(),T=YEe(Me(x.x),St(S),_o(x),_o(w),e.meshSdf).sub(Me(w.y)).mul(Me(w.z)).toVar(),M=Me(w.x).toVar(),E=Me(_.w);if(o.assign(XEe(E,o,T,M)),t){let A=ar(-1.5,E).mul(ar(E,-.5)),C=Kr(h,0,T.negate()),D=lt(L(1),C,A);a.mulAssign(D),l.mulAssign(D),h.assign(pt(h,M)),M.addAssign(e.colorKBump);let R=e.shapeRow(y,4).toVar(),I=Kr(M,0,T).mul(Me(R.a).greaterThanEqual(0).toFloat()).toVar();l.addAssign(I),a.addAssign(R.mul(I))}})})},c=f=>{let m=f.mul(4*Jb).toVar(),g=_o(e.spatialTex.sample(Se(Me(s.x).mul(r).add(f).add(.5).div(r*i),u))).toVar();d(Me(m),Me(g.x)),d(Me(m.add(Jb)),Me(g.y)),d(Me(m.add(2*Jb)),Me(g.z)),d(Me(m.add(3*Jb)),Me(g.w))};r===1?c(L(0)):Yr(r,({i:f})=>{c(L(f).toVar())}),t&&a.divAssign(l);let p=lt(o,L(0),ar(1e20,o)).toVar();return{sdf:Me(p),color:_o(a),colorDivisor:Me(l)}}}function n0e(e){let t=e.resolution,i=t-1,r=e.colorResolution,n=e.capacity,s=t/4,a=s-1,o=Be(e.bboxHalf),l=Be(e.bboxOffset),h=Be(1e30),u=Be(new P(0,0,0)),d=Be(new P(s,s,s)),c=e.env.spatialDivisions,p=L(e.buildSeq).mul(0),f=e.sparseStorage??null,m=f?f.poolBricks:0,g=f?Math.ceil(m/4096):0,v=f?.meshlet??null,y=v?v.drawIndex:null,_=v?Math.floor(n/24):0,b=v?v.vertexBlocks:0,x=(H,ce,Le,B)=>{let ie=new Ey(H,ce,Le);return ie.format=aa,ie.type=Gt,ie.minFilter=gt,ie.magFilter=gt,ie.name=B,ie},w=f?x(256,256,4*Math.max(g,1),"SplineShapeBlend.ultraSdfPool"):e.reuseTextures?.sdfTexture??x(t,t,t,"SplineShapeBlend.ultraSdf");w.format=aa,w.type=Gt,w.minFilter=gt,w.magFilter=gt;let S=e.reuseTextures?.colorTexture??new Ey(r,r,r);S.name="SplineShapeBlend.ultraColor";let T=e.reuseTextures?.coarseTexture??new Ey(s,s,s);T.format=aa,T.type=Gt,T.minFilter=gt,T.magFilter=gt,T.name="SplineShapeBlend.ultraCoarse";let M=$n(8,"uint").toAtomic(),E=(H=0)=>M.element(H),A=f?$n(v?12:4,"int").toAtomic():null,C=H=>A.element(H),D=f?$n(Math.max(m,1),"float"):null,R=s*s*s,I=f?$n(R*(v?4:1),"float"):null,U=H=>Pe(Me(H.x).add(Me(H.y).mul(s)).add(Me(H.z).mul(s*s))),O=H=>I.element(U(H)),k=H=>I.element(U(H).add(Pe(R))),G=H=>I.element(U(H).add(Pe(2*R))),K=H=>I.element(U(H).add(Pe(3*R))),q=H=>I.element(H.add(Pe(3*R))),Y=f?$n(Math.max(m,1),"float"):null,ue=v?$n(3*Math.max(_,1),"float"):null,de=H=>ue.element(H),ge=H=>de(Pe(H)),be=H=>de(Pe(H.add(_))),re=H=>de(H.add(Pe(2*_))),xe=v?$n(Math.max(b,1),"float"):null,j=H=>xe.element(H),z=v?$n(24*Math.max(_,1),"uint"):null,X=H=>z.element(H),te=v?Be(0):null,V=v?Be(new De):null,ae=v?Be(2):null,se=QA(Array.from(e.numTrisTable)),W=QA(fZ.map(([H,ce,Le])=>new P(H,ce,Le))),pe=H$(e.env,!1),_e=H$(e.env),Ue=(H,ce)=>St(H.div(ce).mul(2).sub(1)),we=(H,ce)=>St(H.div(ce).mul(c-1).floor()),Ye=He(()=>{for(let H=0;H<8;H++)kl(E(H),Ar(0))})(),Fe=He(()=>{ze(Pe(wa).greaterThanEqual(Pe(n)),()=>{yn()}),e.buffers.positions.element(Pe(wa)).assign(Ae(0))})(),We=v?He(()=>{ze(Pe(wa).greaterThanEqual(Pe(n)),()=>{yn()}),y.element(Pe(wa)).assign(Ar(p))})():null,Re=Cf(T),ee=H=>Me(_o(Re.load(Ga(qt(H,Q(0),Q(a))))).x),Ee=H=>Me(O(St(qt(H,Q(0),Q(a))))),je=(H,ce)=>{let Le=pt(H,0),B=At(Le.div(4096)),ie=Le.sub(B.mul(4096)),Te=At(ie.div(64)),Ne=ie.sub(Te.mul(64));return St(Q(Ne,Te,B).mul(4).add(ce))},dt=He(()=>{let H=Q(dl).add(u).toVar();ze(Me(H.x).greaterThan(a).or(Me(H.y).greaterThan(a)).or(Me(H.z).greaterThan(a)),()=>{yn()});let ce=St(H.mul(4).add(Q(1.5))),Le=(B=>{let ie=L(1e3).toVar();return Yr(H4,({i:Te})=>{ze(L(Te).greaterThanEqual(Me(e.npart)),()=>{qa()});let Ne=L(Te).add(.5).mul(1/H4),ye=e.env.shapeRow(Ne,0).toVar(),ve=e.env.shapeRow(Ne,1).toVar(),ke=e.env.shapeRow(Ne,2).toVar(),st=e.env.shapeRow(Ne,3).toVar(),yt=$Ee(_o(ve),St(B.sub(St(ye.xyz)))).div(Me(st.z)).toVar(),Lt=YEe(Me(ke.x),St(yt),_o(ke),_o(st),e.env.meshSdf).sub(Me(st.y)).mul(Me(st.z)).toVar();ie.assign(XEe(Me(ye.w),ie,Lt,Me(st.x)))}),Me(ie)})(Ue(ce,i));yg(T,Ga(H),Ae(Me(Le.add(p)),0,0,0)).toStack()})(),et=H=>{ze(Me(H.x).greaterThan(a).or(Me(H.y).greaterThan(a)).or(Me(H.z).greaterThan(a)),()=>{yn()})},$t=f?He(()=>{let H=Q(dl).toVar();et(St(H)),O(St(H)).assign(Me(L(-1).add(p))),v&&(k(St(H)).assign(Me(L(-1).add(p))),G(St(H)).assign(Me(L(-1).add(p))))})():null,ii=f?He(()=>{let H=Q(dl).add(u).toVar();et(St(H));let ce=ee(St(H)).toVar(),Le=Ee(St(H)).toVar();ze(oi(ce).greaterThan(h).and(Le.greaterThan(-.5)),()=>{let B=yh(C(1),Pe(1)).toVar();D.element(B).assign(Le),O(St(H)).assign(Me(L(-1).add(p)))})})():null,nr=f?He(()=>{let H=Q(dl).add(u).toVar();et(St(H));let ce=ee(St(H)).toVar(),Le=Ee(St(H)).toVar();ze(oi(ce).lessThanEqual(h).and(Le.lessThan(-.5)),()=>{let B=L(-1).toVar(),ie=RO(C(1),Pe(1)).toVar();ze(ie.greaterThanEqual(1),()=>{B.assign(Me(D.element(ie.sub(1))))}).Else(()=>{yh(C(1),Pe(1));let Te=yh(C(0),Pe(1)).toVar();ze(Te.lessThan(Pe(m)),()=>{B.assign(Te.toFloat())}).Else(()=>{kl(C(2),Pe(1))})}),ze(B.greaterThan(-.5),()=>{Y.element(Pe(B)).assign((Te=>Me(Me(Te.x).add(Me(Te.y).mul(256)).add(Me(Te.z).mul(65536))))(St(H))),O(St(H)).assign(Me(B.add(p)))})})})():null,xt=f?He(()=>{let H=Xv(C(0)).toVar(),ce=Xv(C(2)).toVar();if(kl(E(1),Ar(H)),kl(E(2),Ar(ce)),kl(C(2),Pe(0)),v){let Le=Xv(C(3)).toVar(),B=Xv(C(5)).toVar();kl(E(4),Ar(Le)),kl(E(5),Ar(B)),kl(C(5),Pe(0));let ie=Xv(C(6)).toVar(),Te=Xv(C(8)).toVar();kl(E(6),Ar(ie)),kl(E(7),Ar(Te)),kl(C(8),Pe(0))}})():null,Dt=v?He(()=>{let H=Q(dl).toVar();ze(Me(H.x).greaterThanEqual(Me(d.x)).or(Me(H.y).greaterThanEqual(Me(d.y))).or(Me(H.z).greaterThanEqual(Me(d.z))),()=>{yn()});let ce=St(H.add(u)).toVar();et(St(ce));let Le=Me(G(St(ce))).toVar();ze(Le.greaterThan(-.5),()=>{let ie=yh(C(7),Pe(1)).toVar();j(ie).assign(Le),G(St(ce)).assign(Me(L(-1).add(p)))});let B=Me(k(St(ce))).toVar();ze(B.lessThan(-.5),()=>{yn()}),k(St(ce)).assign(Me(L(-1).add(p))),Yr(48,()=>{ze(B.lessThan(-.5),()=>{qa()});let ie=yh(C(4),Pe(1)).toVar();re(ie).assign(B),B.assign(Me(ge(B)))})})():null,Kt=v?He(()=>{let H=Q(dl).add(u).toVar();et(St(H));let ce=L(0).toVar();ze(Ee(St(H)).greaterThan(-.5),()=>{let Le=St(H.mul(4)).toVar(),B=Tl.map(([ye,ve,ke])=>Hr(St(Q(Me(Le.x).add(4*ye),Me(Le.y).add(4*ve),Me(Le.z).add(4*ke)))).toVar()),ie=B[0];for(let ye=1;ye<8;ye++)ie=ie.add(B[ye]);let Te=Ft(ie).toVar(),Ne=Je(B[0],Te);for(let ye=1;ye<8;ye++)Ne=Li(Ne,Je(B[ye],Te));ze(Me(Ne).greaterThan(Me(ae)),()=>{ce.assign(L(1))})}),K(St(H)).assign(Me(ce.add(p)))})():null,Mi=Math.min(4096,Math.max(m,1)),_i=()=>{let H=Q(dl).toVar(),ce=At(Me(H.x).mul(.25)).toVar(),Le=At(Me(H.y).mul(.25)).toVar(),B=Le.mul(Mi).add(ce).toVar(),ie=Q(Me(H.x).sub(ce.mul(4)),Me(H.y).sub(Le.mul(4)),Me(H.z)).toVar();return{slot:Me(B),local:St(ie)}},ci=H=>(ce=>{let Le=At(ce.div(65536)),B=ce.sub(Le.mul(65536)),ie=At(B.div(256)),Te=B.sub(ie.mul(256));return St(Q(Te,ie,Le))})(Me(Y.element(Pe(H)))),Ei=f?He(()=>{let H=Q(dl).add(u.mul(4)).toVar(),ce=St(H.mul(.25).floor()).toVar(),Le=Ee(ce).toVar();ze(Le.lessThan(-.5),()=>{yn()});let{sdf:B}=pe(Ue(St(H),i),we(St(H),i));yg(w,Ga(je(Le,St(H.sub(ce.mul(4))))),Ae(Me(B.add(p)),0,0,0)).toStack()})():null,Or=f?He(()=>{let{slot:H,local:ce}=_i();ze(H.greaterThanEqual(m),()=>{yn()});let Le=ci(H).toVar();ze(Ee(St(Le)).notEqual(H),()=>{yn()});let B=St(Le.mul(4).add(ce)).toVar(),{sdf:ie}=pe(Ue(St(B),i),we(St(B),i));yg(w,Ga(je(H,St(ce))),Ae(Me(ie.add(p)),0,0,0)).toStack()})():He(()=>{let H=Q(dl).add(u.mul(4)).toVar(),ce=ee(St(H.mul(.25).floor())).toVar();ze(oi(ce).greaterThan(h),()=>{yg(w,Ga(H),Ae(Me(ce.add(p)),0,0,0)).toStack(),yn()});let{sdf:Le}=pe(Ue(St(H),i),we(St(H),i));yg(w,Ga(H),Ae(Me(Le.add(p)),0,0,0)).toStack()})(),Wr=He(()=>{let H=Q(dl).add(u.mul(2)).toVar();ze(Me(H.x).greaterThan(r-1).or(Me(H.y).greaterThan(r-1)).or(Me(H.z).greaterThan(r-1)),()=>{yn()}),ze(oi(ee(St(H.mul(.5).floor()))).greaterThan(h),()=>{yn()});let{color:ce,colorDivisor:Le}=_e(Ue(St(H),r-1),we(St(H),r-1)),B=_o(Le.greaterThan(0).select(ce,Ae(0)));yg(S,Ga(H),qt(_o(B.add(p)),Ae(0),Ae(1))).toStack()})(),Ji=Cf(w),Yi=f?(H,ce,Le)=>{let B=qt(Q(H,ce,Le),Q(0),Q(i)),ie=B.mul(.25).floor(),Te=Ee(St(ie)),Ne=Me(_o(Ji.load(Ga(je(Te,St(B.sub(ie.mul(4))))))).x);return Me(Te.lessThan(-.5).select(ee(St(ie)),Ne))}:(H,ce,Le)=>Me(_o(Ji.load(Ga(qt(Q(H,ce,Le),Q(0),Q(i))))).x),Hr=H=>{let ce=Me(H.x),Le=Me(H.y),B=Me(H.z),ie=Yi(ce.add(1),Le,B).sub(Yi(ce.sub(1),Le,B)),Te=Yi(ce,Le.add(1),B).sub(Yi(ce,Le.sub(1),B)),Ne=Yi(ce,Le,B.add(1)).sub(Yi(ce,Le,B.sub(1))),ye=ie.equal(0).and(Te.equal(0)).and(Ne.equal(0));return St(ye.select(Q(.199,.299,.399),Ft(Q(ie,Te,Ne))))},Ie=(H,ce,Le)=>{let B=((Ne,ye,ve)=>{let ke=(st,yt,Lt,Zt)=>Yi(Ne.add(st),ye.add(yt),ve.add(Lt)).lessThan(0).toFloat().mul(Zt);return ke(0,0,0,1).add(ke(1,0,0,2)).add(ke(0,1,0,8)).add(ke(1,1,0,4)).add(ke(0,0,1,16)).add(ke(1,0,1,32)).add(ke(0,1,1,128)).add(ke(1,1,1,64))})(H,ce,Le).toVar(),ie=Me(se.element(Pe(B))).toVar();ze(ie.lessThan(.5),()=>{yn()});let Te=yh(E(),Ar(ie)).toVar();ze(L(Te).add(ie).mul(3).lessThanEqual(n),()=>{let Ne=Me(B).add(.5).mul(.00390625);Yr(5,({i:ye})=>{ze(L(ye).greaterThanEqual(ie),()=>{qa()});let ve=L(ye).toVar();Yr(3,({i:ke})=>{let st=L(ke).toVar();((yt,Lt,Zt,ai,jt,Ui)=>{let or=jt.mul(.0625).add(.03125),Ai=Me(_o(e.triTable.sample(Se(or,ai))).x).mul(2).toInt().toVar(),xi=Q(yt,Lt,Zt).add(St(W.element(Ai))).toVar(),zt=Q(yt,Lt,Zt).add(St(W.element(Ai.add(1)))).toVar(),er=Yi(Me(xi.x),Me(xi.y),Me(xi.z)).toVar(),yr=Yi(Me(zt.x),Me(zt.y),Me(zt.z)).toVar(),Rt=er.div(er.sub(yr)).toVar(),Wt=xi.add(zt.sub(xi).mul(Rt)).toVar(),Qr=St(Wt.div(i).mul(2).sub(1)).toVar(),zs=Qr.mul(o).add(Q(l)),Jr=Ft(lt(Hr(St(xi)),Hr(St(zt)),Rt)),Zn=Qr.add(1).mul(.5),_r=_o(Cf(S,Zn,Pe(0))),On=Ui.toVar();e.buffers.positions.element(On).assign(Ae(zs,1)),e.buffers.normals.element(On).assign(Ae(Jr,0)),e.buffers.colors.element(On).assign(_r)})(H,ce,Le,Ne,ve.mul(3).add(st),Pe(Te).add(Pe(ve)).mul(3).add(Pe(st)))})})})},th=f?He(()=>{let{slot:H,local:ce}=_i();ze(H.greaterThanEqual(m),()=>{yn()});let Le=ci(H).toVar();ze(Ee(St(Le)).notEqual(H),()=>{yn()});let B=Me(Le.x).mul(4).add(Me(ce.x)).toVar(),ie=Me(Le.y).mul(4).add(Me(ce.y)).toVar(),Te=Me(Le.z).mul(4).add(Me(ce.z)).toVar();ze(B.greaterThanEqual(i).or(ie.greaterThanEqual(i)).or(Te.greaterThanEqual(i)),()=>{yn()}),Ie(B,ie,Te)})():He(()=>{let H=Me(Q(dl).x).toVar(),ce=Me(Q(dl).y).toVar(),Le=Me(Q(dl).z).toVar();ze(H.greaterThanEqual(i).or(ce.greaterThanEqual(i)).or(Le.greaterThanEqual(i)),()=>{yn()}),ze(oi(ee(St(Q(H,ce,Le).mul(.25).floor()))).greaterThan(h),()=>{yn()}),Ie(H,ce,Le)})(),Pd=()=>{let H=Q(LO).toVar(),ce=Me(H.y).mul(Mi).add(Me(H.x)).toVar(),Le=Q(0).toVar(),B=L(0).toVar();return ze(ce.lessThan(m),()=>{Le.assign(ci(ce)),ze(Ee(St(Le)).equal(ce),()=>{B.assign(L(1))})}),{brick:St(Le),valid:Me(B)}},bi=()=>{let H=Q(LO).add(u).toVar(),ce=L(0).toVar();return ze(Me(H.x).lessThanEqual(a).and(Me(H.y).lessThanEqual(a)).and(Me(H.z).lessThanEqual(a)),()=>{ze(Ee(St(H)).greaterThan(-.5),()=>{ce.assign(L(1))})}),{brick:St(H),valid:Me(ce)}},Tl=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],Yc=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Rd=H=>He(()=>{let ce=ug("float",64),Le=ug("float",1),B=Q(NO).toVar(),ie=Pe(Me(B.x).add(Me(B.y).mul(4)).add(Me(B.z).mul(16))).toVar(),{brick:Te,valid:Ne}=H(),ye=Me(K(St(Te))).toVar(),ve=L(1).add(ye).toVar(),ke=ye.greaterThan(.5),st=ke.and(Me(B.x).lessThan(2).and(Me(B.y).lessThan(2)).and(Me(B.z).lessThan(2))).or(ke.not()),yt=Me(Te.x).mul(4).add(Me(B.x).mul(ve)).toVar(),Lt=Me(Te.y).mul(4).add(Me(B.y).mul(ve)).toVar(),Zt=Me(Te.z).mul(4).add(Me(B.z).mul(ve)).toVar(),ai=Tl.map(([zt,er,yr])=>Yi(yt.add(ve.mul(zt)),Lt.add(ve.mul(er)),Zt.add(ve.mul(yr))).toVar()),jt=ai[0].lessThan(0).toFloat();for(let zt=1;zt<8;zt++)jt=jt.add(ai[zt].lessThan(0).toFloat());let Ui=jt.toVar(),or=L(0).toVar();ze(Ne.greaterThan(.5).and(st).and(yt.add(ve).lessThanEqual(i)).and(Lt.add(ve).lessThanEqual(i)).and(Zt.add(ve).lessThanEqual(i)).and(Ui.greaterThan(.5)).and(Ui.lessThan(7.5)),()=>{or.assign(L(1))}),ce.element(ie).assign(or.add(p)),Xb(),ze(ie.equal(Pe(0)).and(Ne.greaterThan(.5)),()=>{let zt=L(0).toVar();Yr(64,({i:yr})=>{zt.addAssign(Me(ce.element(yr)))});let er=L(-1).toVar();ze(zt.greaterThan(.5),()=>{let yr=RO(C(7),Pe(1)).toVar();ze(yr.greaterThanEqual(1),()=>{er.assign(Me(j(yr.sub(1))))}).Else(()=>{yh(C(7),Pe(1));let Rt=yh(C(6),Pe(1)).toVar();ze(Rt.lessThan(Pe(b)),()=>{er.assign(Rt.toFloat())}).Else(()=>{kl(C(8),Pe(1))})}),ze(er.greaterThan(-.5),()=>{G(St(Te)).assign(Me(er.add(p)))})}),Le.element(Pe(0)).assign(er)}),Xb();let Ai=Me(Le.element(Pe(0))).toVar(),xi=or.greaterThan(.5).or(ke.and(st).and(Ne.greaterThan(.5)).and(yt.add(ve).lessThanEqual(i)).and(Lt.add(ve).lessThanEqual(i)).and(Zt.add(ve).lessThanEqual(i)));ze(xi.and(Ai.greaterThan(-.5)),()=>{let zt=Q(0).toVar(),er=L(0).toVar();for(let[pa,Fh]of Yc)ze(ai[pa].lessThan(0).toFloat().notEqual(ai[Fh].lessThan(0).toFloat()),()=>{let f0=ai[pa].div(ai[pa].sub(ai[Fh])),[tm,E1,Pi]=Tl[pa],[Mu,Xw,Od]=Tl[Fh];zt.addAssign(Q(tm,E1,Pi).add(Q(Mu-tm,Xw-E1,Od-Pi).mul(f0)).mul(ve)),er.addAssign(1)});let yr=St(zt.div(pt(er,1))).toVar();ze(er.lessThan(.5),()=>{yr.assign(Q(ve.mul(.5)))});let Rt=Q(yt,Lt,Zt).add(yr).toVar(),Wt=St(Rt.div(i).mul(2).sub(1)).toVar(),Qr=Wt.mul(o).add(Q(l)),zs=Q(0).toVar(),Jr=St(yr.div(ve)).toVar();for(let pa=0;pa<8;pa++){let[Fh,f0,tm]=Tl[pa],E1=Fh?Me(Jr.x):L(1).sub(Me(Jr.x)),Pi=f0?Me(Jr.y):L(1).sub(Me(Jr.y)),Mu=tm?Me(Jr.z):L(1).sub(Me(Jr.z));zs.addAssign(Hr(St(Q(yt.add(ve.mul(Fh)),Lt.add(ve.mul(f0)),Zt.add(ve.mul(tm))))).mul(E1.mul(Pi).mul(Mu)))}let Zn=Ft(zs),_r=Wt.add(1).mul(.5),On=_o(Cf(S,_r,Pe(0))),_n=Pe(ke.select(Me(B.x).add(Me(B.y).mul(2)).add(Me(B.z).mul(4)),L(ie))).toVar(),Qs=Pe(Ai.mul(64)).add(_n).toVar();e.buffers.positions.element(Qs).assign(Ae(Qr,1)),e.buffers.normals.element(Qs).assign(Ae(Zn,0)),e.buffers.colors.element(Qs).assign(On)})})(),Dd=v?Rd(Pd):null,Ml=v?Rd(bi):null,Vi=H=>He(()=>{let ce=ug("float",64),Le=ug("float",64),B=ug("float",48),ie=Q(NO).toVar(),Te=Pe(Me(ie.x).add(Me(ie.y).mul(4)).add(Me(ie.z).mul(16))).toVar(),{brick:Ne,valid:ye}=H(),ve=Me(Ne.x).mul(4).add(Me(ie.x)).toVar(),ke=Me(Ne.y).mul(4).add(Me(ie.y)).toVar(),st=Me(Ne.z).mul(4).add(Me(ie.z)).toVar(),yt=Yi(ve,ke,st).lessThan(0).toFloat().toVar(),Lt=(Rt,Wt,Qr)=>Me(q(Pe(At(Rt.mul(.25))).add(Pe(At(Wt.mul(.25))).mul(s)).add(Pe(At(Qr.mul(.25))).mul(s*s)))),Zt=Rt=>Rt.mul(.5).fract().lessThan(.25),ai=(Rt,Wt)=>Rt.greaterThanEqual(Wt).and(Rt.add(Wt).lessThanEqual(i)),jt=L(0).toVar(),Ui=L(0).toVar(),or=L(0).toVar(),Ai=L(1).toVar(),xi=L(1).toVar(),zt=L(1).toVar(),er=(Rt,Wt,Qr,zs,Jr,Zn,_r,On,_n)=>{let Qs=Lt(..._n[0]).add(Lt(..._n[1])).add(Lt(..._n[2])).add(Lt(..._n[3])).greaterThan(3.5).toVar(),pa=Yi(ve.add(Qr),ke.add(zs),st.add(Jr)).lessThan(0).toFloat(),Fh=Yi(ve.add(2*Qr),ke.add(2*zs),st.add(2*Jr)).lessThan(0).toFloat();ze(ye.greaterThan(.5).and(Qs.not()).and(On.add(1).lessThanEqual(i)).and(ai(Zn,L(1))).and(ai(_r,L(1))).and(yt.notEqual(pa)),()=>{Rt.assign(L(1)),Wt.assign(L(1))}),ze(ye.greaterThan(.5).and(Qs).and(Zt(ve)).and(Zt(ke)).and(Zt(st)).and(On.add(2).lessThanEqual(i)).and(ai(Zn,L(2))).and(ai(_r,L(2))).and(yt.notEqual(Fh)),()=>{Rt.assign(L(1)),Wt.assign(L(2))})};er(jt,Ai,1,0,0,ke,st,ve,[[ve,ke.sub(1),st.sub(1)],[ve,ke,st.sub(1)],[ve,ke,st],[ve,ke.sub(1),st]]),er(Ui,xi,0,1,0,st,ve,ke,[[ve.sub(1),ke,st.sub(1)],[ve.sub(1),ke,st],[ve,ke,st],[ve,ke,st.sub(1)]]),er(or,zt,0,0,1,ve,ke,st,[[ve.sub(1),ke.sub(1),st],[ve,ke.sub(1),st],[ve,ke,st],[ve.sub(1),ke,st]]);let yr=jt.add(Ui).add(or).mul(2).toVar();ce.element(Te).assign(yr.add(p)),Xb(),ze(Te.equal(Pe(0)).and(ye.greaterThan(.5)),()=>{let Rt=L(0).toVar();Yr(64,({i:Jr})=>{Le.element(Jr).assign(Rt),Rt.addAssign(Me(ce.element(Jr)))}),yh(E(0),Ar(Rt));let Wt=At(Rt.add(7).mul(1/8)).toVar(),Qr=L(-1).toVar(),zs=L(-1).toVar();Yr(48,({i:Jr})=>{ze(L(Jr).greaterThanEqual(Wt),()=>{qa()});let Zn=L(Jr).toVar(),_r=L(-1).toVar(),On=RO(C(4),Pe(1)).toVar();ze(On.greaterThanEqual(1),()=>{_r.assign(Me(re(On.sub(1))))}).Else(()=>{yh(C(4),Pe(1));let _n=yh(C(3),Pe(1)).toVar();ze(_n.lessThan(Pe(_)),()=>{_r.assign(_n.toFloat())}).Else(()=>{kl(C(5),Pe(1))})}),B.element(Pe(Zn)).assign(_r),ze(_r.greaterThan(-.5),()=>{be(_r).assign(Li(Rt.sub(Zn.mul(8)),8)),ge(_r).assign(L(-1)),ze(zs.greaterThan(-.5),()=>{ge(zs).assign(_r)}).Else(()=>{Qr.assign(_r)}),zs.assign(_r)})}),k(St(Ne)).assign(Qr)}),Xb(),ze(yr.greaterThan(.5),()=>{let Rt=(Jr,Zn,_r)=>{let On=At(Jr.mul(.25)),_n=At(Zn.mul(.25)),Qs=At(_r.mul(.25)),pa=Pe(On).add(Pe(_n).mul(s)).add(Pe(Qs).mul(s*s)),Fh=Pe(Jr.sub(On.mul(4))).add(Pe(Zn.sub(_n.mul(4))).mul(4)).add(Pe(_r.sub(Qs.mul(4))).mul(16));return Ar(pa.mul(64).add(Fh))},Wt=Me(Le.element(Te)).toVar(),Qr=(Jr,Zn,_r)=>{let On=Me(B.element(Pe(At(Wt.mul(.125))))).toVar();ze(On.greaterThan(-.5),()=>{let _n=Wt.sub(At(Wt.mul(.125)).mul(8)),Qs=Pe(On.mul(24).add(_n.mul(3))).toVar();X(Qs).assign(Jr),X(Qs.add(Pe(1))).assign(Zn),X(Qs.add(Pe(2))).assign(_r)}),Wt.addAssign(1)},zs=(Jr,Zn)=>{ze(Jr.greaterThan(.5),()=>{let _r=Rt(...Zn[0]).toVar(),On=Rt(...Zn[1]).toVar(),_n=Rt(...Zn[2]).toVar(),Qs=Rt(...Zn[3]).toVar();ze(yt.greaterThan(.5),()=>{Qr(_r,On,_n),Qr(_r,_n,Qs)}).Else(()=>{Qr(_r,Qs,_n),Qr(_r,_n,On)})})};zs(jt,[[ve,ke.sub(Ai),st.sub(Ai)],[ve,ke,st.sub(Ai)],[ve,ke,st],[ve,ke.sub(Ai),st]]),zs(Ui,[[ve.sub(xi),ke,st.sub(xi)],[ve.sub(xi),ke,st],[ve,ke,st],[ve,ke,st.sub(xi)]]),zs(or,[[ve.sub(zt),ke.sub(zt),st],[ve,ke.sub(zt),st],[ve,ke,st],[ve.sub(zt),ke,st]])})})(),Nd=v?Vi(Pd):null,Id=v?Vi(bi):null,El=v?He(()=>{let H=ug("float",48),ce=ug("float",2),Le=Q(NO).toVar(),B=Pe(Me(Le.x).add(Me(Le.y).mul(4)).add(Me(Le.z).mul(16))).toVar(),ie=Q(LO).toVar(),Te=Me(ie.y).mul(Mi).add(Me(ie.x)).toVar();ze(B.equal(Pe(0)),()=>{let ke=L(0).toVar();ze(Te.lessThan(m),()=>{let yt=ci(Te).toVar();ze(Ee(St(yt)).equal(Te),()=>{let Lt=L(0).toVar();ze(Me(te).greaterThan(.5),()=>{let Zt=Q(0).toVar(),ai=Q(0).toVar();for(let jt=0;jt<8;jt++){let Ui=St(yt.mul(4).add(Q(4*(1&jt),4*(jt>>1&1),4*(jt>>2&1)))),or=St(Ui.div(i).mul(2).sub(1)).mul(o).add(Q(l)),Ai=V.mul(Ae(or,1)).toVar(),xi=Me(Ai.w);Zt.addAssign(Q(Me(Ai.x).lessThan(xi.negate()).toFloat(),Me(Ai.y).lessThan(xi.negate()).toFloat(),Me(Ai.z).lessThan(0).toFloat())),ai.addAssign(Q(Me(Ai.x).greaterThan(xi).toFloat(),Me(Ai.y).greaterThan(xi).toFloat(),Me(Ai.z).greaterThan(xi).toFloat()))}ze(pt(pt(Me(Zt.x),pt(Me(Zt.y),Me(Zt.z))),pt(Me(ai.x),pt(Me(ai.y),Me(ai.z)))).greaterThan(7.5),()=>{Lt.assign(L(1))})}),ze(Lt.lessThan(.5),()=>{let Zt=Me(k(St(yt))).toVar();Yr(48,({i:ai})=>{ze(Zt.lessThan(-.5),()=>{qa()}),H.element(ai).assign(Zt),ke.addAssign(Me(be(Zt))),Zt.assign(Me(ge(Zt)))})})})});let st=L(0).toVar();ze(ke.greaterThan(.5),()=>{let yt=yh(E(3),Ar(ke.mul(3))).toVar();st.assign(L(yt))}),ce.element(Pe(0)).assign(st.add(p)),ce.element(Pe(1)).assign(ke)}),Xb();let Ne=Me(ce.element(Pe(1))).toVar(),ye=Me(ce.element(Pe(0))).toVar(),ve=L(B).toVar();Yr(6,()=>{ze(ve.greaterThanEqual(Ne),()=>{qa()});let ke=Me(H.element(Pe(At(ve.mul(1/8))))).toVar(),st=ve.sub(At(ve.mul(1/8)).mul(8)),yt=Pe(ke.mul(24).add(st.mul(3))).toVar(),Lt=Pe(ye.add(ve.mul(3))).toVar(),Zt=or=>{let Ai=X(or===0?yt:yt.add(Pe(or))).toVar(),xi=Pe(Ai.shiftRight(Ar(6))).toVar(),zt=Pe(Ai.bitAnd(Ar(63))).toVar(),er=Me((Jr=>I.element(Jr.add(Pe(2*R))))(xi)).toVar(),yr=Me(q(xi)),Rt=zt.bitAnd(Pe(3)),Wt=zt.shiftRight(Pe(2)).bitAnd(Pe(3)),Qr=zt.shiftRight(Pe(4)).bitAnd(Pe(3)),zs=Rt.shiftRight(Pe(1)).add(Wt.shiftRight(Pe(1)).mul(Pe(2))).add(Qr.shiftRight(Pe(1)).mul(Pe(4)));return{blockF:er,li:Pe(yr.greaterThan(.5).select(zs,zt)).toVar()}},ai=Zt(0),jt=Zt(1),Ui=Zt(2);ze(ai.blockF.greaterThan(-.5).and(jt.blockF.greaterThan(-.5)).and(Ui.blockF.greaterThan(-.5)),()=>{let or=Ai=>Ar(Pe(Ai.blockF.mul(64)).add(Ai.li));y.element(Lt).assign(or(ai)),y.element(Lt.add(Pe(1))).assign(or(jt)),y.element(Lt.add(Pe(2))).assign(or(Ui))}).Else(()=>{y.element(Lt).assign(Ar(0)),y.element(Lt.add(Pe(1))).assign(Ar(0)),y.element(Lt.add(Pe(2))).assign(Ar(0))}),ve.addAssign(64)})})():null,Es=Math.ceil(t/xE[0]),Tu=Math.ceil(r/xE[0]),gn=Math.ceil(s/xE[0]),oe=(H,ce)=>H.compute(ce,Array.isArray(ce)?xE:void 0),Ve=[Mi,Math.max(1,Math.ceil(m/Mi)),1];return{resolution:t,sparse:f!==null,poolBricks:m,meshlet:v!==null,vertexBlocks:b,needsInit:f!==null,sdfTexture:w,colorTexture:S,coarseTexture:T,counterAttribute:M.value,storageAttributes:[M,A,D,I,Y,ue,xe,z].filter(H=>H!==null).map(H=>H.value),uniforms:{bboxHalf:o,bboxOffset:l,activeThreshold:h,windowOrigin:u,...v?{windowSize:d,cullEnabled:te,cullMVP:V,adaptCos:ae}:{}},kernels:{zero:oe(Ye,1),clear:Fe.compute([Math.ceil(n/256),1,1],[256,1,1]),coarse:oe(dt,[gn,gn,gn]),...$t?{init:oe($t,[gn,gn,gn])}:{},...ii?{release:oe(ii,[gn,gn,gn])}:{},...nr?{alloc:oe(nr,[gn,gn,gn])}:{},...xt?{stats:oe(xt,1)}:{},sdf:oe(Or,f?Ve:[Es,Es,Es]),...Ei?{sdfWindow:oe(Ei,[Es,Es,Es])}:{},color:oe(Wr,[Tu,Tu,Tu]),extract:v?oe(Nd,Ve):oe(th,f?Ve:[Es,Es,Es]),...v?{clearDraw:We.compute([Math.ceil(n/256),1,1],[256,1,1]),meshRelease:oe(Dt,[gn,gn,gn]),verts:oe(Dd,Ve),vertsWindow:oe(Ml,[s,s,s]),extractWindow:oe(Id,[s,s,s]),classify:oe(Kt,[gn,gn,gn]),gather:oe(El,Ve)}:{}}}}var Me,XO,St,_o,Jb,H4,xE,ug,G5e=F(()=>{ne(),mn(),gi(),DK(),mZ(),Me=e=>e,XO=e=>e,St=e=>e,_o=e=>e,Jb=24,H4=RK,xE=[4,4,4],ug=(e,t)=>K2e(e,t)});function j5e(e){let t=e.getAttribute("position");if(!t||t.count<3)return null;let i=e.getIndex(),r=Math.floor((i?i.count:t.count)/3);if(r===0)return null;let n=Math.max(1,Math.ceil(r/q4));n>1&&console.warn(`Spline shape blend: mesh child has ${r} triangles \u2014 baking every ${n}th (SDF detail reduced).`);let s=Math.floor(r/n),a=new Float32Array(12*s),o=new P(0,0,0),l=new P,h=0;for(let d=0;d<s;d++){let c=d*n*3;for(let p=0;p<3;p++){let f=i?i.getX(c+p):c+p;l.fromBufferAttribute(t,f),a[h++]=l.x,a[h++]=l.y,a[h++]=l.z,a[h++]=0,o.x=Math.max(o.x,Math.abs(l.x)),o.y=Math.max(o.y,Math.abs(l.y)),o.z=Math.max(o.z,Math.abs(l.z))}}if(o.x===0&&o.y===0&&o.z===0)return null;let u=Math.max(o.x,o.y,o.z);return o.x=Math.max(o.x,.05*u)*(1+YO),o.y=Math.max(o.y,.05*u)*(1+YO),o.z=Math.max(o.z,.05*u)*(1+YO),{data:a,triCount:s,boxHalf:o}}function W5e(e){let t=Cf(e),i=hF;return(r,n,s)=>{let a=pt(Q($s(n.z),$s(n.w),$s(s.w)),Q(1e-5)).toVar(),o=$s(n.y),l=Q(o.mod(Rf).mul(i),At(o.div(Rf)).mul(i),0).toVar(),h=qt(aA(r.div(a).mul(.5).add(.5)),Q(0),Q(1)).mul(i-1).toVar(),u=Li(At(h),Q(i-2)).toVar(),d=h.sub(u).toVar(),c=l.add(u).toVar(),p=(M,E,A)=>$s(KEe(t.load(Ga(c.add(Q(M,E,A))))).x),f=$s(d.x),m=$s(d.y),g=$s(d.z),v=lt(p(0,0,0),p(1,0,0),f),y=lt(p(0,1,0),p(1,1,0),f),_=lt(p(0,0,1),p(1,0,1),f),b=lt(p(0,1,1),p(1,1,1),f),x=lt(lt(v,y,m),lt(_,b,m),g),w=pt($s(a.x),pt($s(a.y),$s(a.z))),S=oi(r).sub(a),T=$i(pt(S,Q(0)));return $s(x.mul(w).add(T))}}function H5e(e){let t=hF;return new P(e%Rf*t,Math.floor(e/Rf)*t,0)}var $s,aA,KEe,hF,Rf,YO,q4,q5e=F(()=>{ne(),ne(),mn(),gi(),$s=e=>e,aA=e=>e,KEe=e=>e,hF=48,Rf=4,YO=.08,q4=24576});function $5e(){if(KO!==null)return KO;let e=He(()=>{let i=Se(Ri(q$),Ri($$)),r=Se(1).div(i),n=Hi().mul(Ri(X$)).sub(Se(.5)).mul(2).add(Se(.5)).toVar();n.x.addAssign(Ri(wE));let s=n.div(i).toVar(),a=Ri(gx.sample(s).x).toVar();s.x.addAssign(Ri(r.x));let o=Ri(gx.sample(s).x).toVar();s.y.addAssign(Ri(r.y));let l=Ri(gx.sample(s).x).toVar();s.x.subAssign(Ri(r.x));let h=Ri(gx.sample(s).x).toVar(),u=a,d=u.add(o),c=d.add(l),p=c.add(h);return Ae(p,c,d,u)})(),t=new Jt;return t.name="SplineShapeBlend.pyramid",t.fragmentNode=e,t.depthTest=!1,t.depthWrite=!1,t.blending=yi,t.needsUpdate=!0,KO=t,t}function J2(e,t,i=1){return new Fi(e,t,{count:i,format:pn,type:Gt,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:gt,magFilter:gt,wrapS:mr,wrapT:mr})}function X5e(){let e=qx.length;if(e>0){for(let t of qx)t.dispose();qx.length=0}return e}var Ri,s0e,Op,gx,q$,$$,wE,J_,X$,KO,u9,d9,Xm,RN,c9,p9,f9,m9,g9,v9,y9,DN,nn,eM,a0e,Y$,ex,SE,qx,Y5e=F(()=>{ne(),mn(),gi(),DK(),wSe(),mZ(),G5e(),q5e(),ua(),Ri=e=>e,s0e=e=>e,Op=new Cn,gx=mt(new Ci),q$=Be(1),$$=Be(1),wE=Be(0),J_=Be(0),X$=Be(1),KO=null,u9=!1,d9=!1,Xm="",RN=!1,c9=!1,p9=!1,f9=!1,m9=!1,g9=!1,v9=!1,y9=!1,DN=!1;try{let e=new URLSearchParams(window.location.search);u9=e.get("dbgsbmarch")==="vertex",d9=e.get("dbgsbultra")==="0",Xm=e.get("dbgsbchain")??"",RN=e.get("dbgsbnoclear")==="1",c9=e.get("dbgsbsparse")==="0",p9=e.get("dbgsbincr")==="0",f9=e.get("dbgsblod")==="1",m9=e.get("dbgsbpool")==="1",g9=e.get("dbgsbpool")==="0",v9=e.get("dbgsbmesh")==="0",y9=e.get("dbgsbadapt")==="0",DN=e.get("dbgsbcull")==="1"}catch{}nn={updates:0,skips:0,computes:0,readbacksResolved:0,readbackErrors:0,fieldsFull:0,fieldsWindowed:0,lastWindowBricks:0,refines:0,lastDispatchRes:0,regathers:0,readbackPending:!1,lastTotal:-1,lastPass:"",staleConfigSkips:0,marchPositions:null},eM=24576,a0e=Math.cos(8*Math.PI/180),Y$=class{constructor(e=0,t=0,i=0){this.wantsReplacement=!1,this.capacityHint=0,this._builtOnce=!1,this.level=-1,this.spatialnAtBuild=-1,this._passesRenderer=null,this._marchCapacity=0,this._marchBuffers=null,this._computeNode=null,this._computeNodeKey="",this._legacyMaterialsLevel=-1,this._computeDirty=!1,this._cachedAtBuild=!1,this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,this._lastFieldChangeMs=0,this._ultraResAtBuild=0,this._ultraReadbackPending=!1,this._ultraReadbackQueued=!1,this._ultraWantedCapacity=0,this._poolAtBuild=0,this._ultraWantedPoolBricks=0,this.poolHint=0,this._drawIndex=null,this._vertexBuffers=null,this._vertBlocksAtBuild=0,this._ultraWantedVertexBlocks=0,this.vertHint=0,this._cullCamera=null,this._lastGatherMVP=new De,this._hasGatherMVP=!1,this._ultraRetired=[],this._retiredStorage=[],this._ultraBuildSeq=0,this._lastRenderer=null,this._meshBaker=null,this._meshAtBuild=!1,this._meshSlots=new Map,this._meshBakeFailed=new Map,this._meshWarnedFull=!1,this.shapesTex=mt(new Ci),this.spatialTexNode=mt(new Ci),this.potentialTexNode=mt(new Ci),this.voxelTexNode=mt(new Ci),this.pyramid1TexNode=mt(new Ci),this.pyramid2TexNode=mt(new Ci),this.npartUniform=Be(0),this.spatialnUniform=Be(1),this.spanUniform=Be(0),this.spatialMaterial=null,this.potentialMaterial=null,this.voxelMaterial=null,this.spatialTargets=[],this.potentialTargets=[],this.voxelTargets=[],this.pyramidTargets=[],this.retired=!1,this._onSettled=[],this.capacityHint=e,this.poolHint=t,this.vertHint=i;let r=dO(),n=new Nr(r.triTable,16,256,aa,Gt);n.needsUpdate=!0;let s=new Nr(r.numTrisTable,256,1,aa,Gt);s.needsUpdate=!0,this.triTableTexNode=mt(n),this.numTrisTableTexNode=mt(s)}shapeRow(e,t){return this.shapesTex.sample(Se(e,(t+.5)/5))}_quadMaterial(e,t){let i=new Jt;return i.name=e,i.fragmentNode=t,i.depthTest=!1,i.depthWrite=!1,i.blending=yi,i.needsUpdate=!0,i}_buildSpatialMaterial(e){let t=e.spatialDivisions,i=RK,r=this.npartUniform,n=this.spatialnUniform,s=this.spanUniform,a=e.spatialn,o=He(()=>{let l=Se(t*a,t**2),h=At(Hi().mul(l)).toVar(),u=Ri(h.y).toVar(),d=u.sub(At(u.div(t)).mul(t)).toVar();u.assign(At(u.div(t)));let c=u,p=Ri(h.x).toVar(),f=p.sub(At(p.div(n)).mul(Ri(n))).toVar().mul(96).toVar();p.assign(At(p.div(n)));let m=Q(p,d,c),g=m.div(t).mul(2).sub(1).sub(Ri(s)).toVar(),v=m.add(1).div(t).mul(2).sub(1).add(Ri(s)).toVar(),y=_=>{let b=L(0).toVar();for(let x=23;x>=0;x--){let w=_.add(x),S=w.add(.5).div(i),T=this.shapeRow(S,0),M=s0e(T.xyz),E=Ri(T.w);b.mulAssign(2);let A=Ri(g.x).lessThan(Ri(M.x)).and(Ri(M.x).lessThan(Ri(v.x))).and(Ri(g.y).lessThan(Ri(M.y))).and(Ri(M.y).lessThan(Ri(v.y))).and(Ri(g.z).lessThan(Ri(M.z))).and(Ri(M.z).lessThan(Ri(v.z))).and(w.lessThan(Ri(r))).or(E.equal(-2));b.addAssign(A.select(L(1),L(0)))}return b};return Ae(y(f),y(f.add(24)),y(f.add(48)),y(f.add(72)))})();return this._quadMaterial("SplineShapeBlend.spatial",o)}_fieldEnv(e,t){return{shapeRow:(i,r)=>this.shapeRow(i,r),spatialTex:this.spatialTexNode,spatialDivisions:e.spatialDivisions,spatialn:e.spatialn,colorKBump:t,meshSdf:this._meshBaker?W5e(this._meshBaker.atlas):void 0}}_buildPotentialMaterial(e){let t=e.spatialDivisions,i=e.resolution,r=i-1,n=1/i,s=e.zLayersPerRow,a=e.basePyramidSize,o=H$(this._fieldEnv(e,2*n)),l=He(()=>{let h=At(Hi().mul(Se(a,a))).toVar(),u=Ri(h.x).mod(i),d=Ri(h.y).mod(i),c=At(Ri(h.x).mul(n)).add(At(Ri(h.y).mul(n)).mul(s)),p=Q(u,d,c),f=p.div(r).mul(2).sub(1).toVar(),m=At(p.div(r).mul(t-1)).toVar(),{sdf:g,color:v}=o(f,m),y=Ar(Ri(v.x).mul(255)),_=Ar(Ri(v.y).mul(255)),b=y.shiftLeft(Ar(8)).bitOr(_);return Ae(g,b.toFloat().mul(1525902e-11),Ri(v.z),Ri(v.w))})();return this._quadMaterial("SplineShapeBlend.potential",l)}_buildVoxelMaterial(e){let t=e.resolution,i=t-1,r=1/t,n=e.zLayersPerRow,s=e.basePyramidSize,a=HEe(t,n),o=this.potentialTexNode,l=()=>{let c=At(Hi().mul(Se(s,s))).toVar();return{xi:Ri(c.x).mod(t).toVar(),yi:Ri(c.y).mod(t).toVar(),zi:At(Ri(c.x).mul(r)).add(At(Ri(c.y).mul(r)).mul(n)).toVar()}},h=(c,p,f)=>{let m=(g,v,y,_)=>Ri(a(c.add(g),p.add(v),f.add(y),o).x).lessThan(0).toFloat().mul(_);return m(0,0,0,1).add(m(1,0,0,2)).add(m(0,1,0,8)).add(m(1,1,0,4)).add(m(0,0,1,16)).add(m(1,0,1,32)).add(m(0,1,1,128)).add(m(1,1,1,64))},u=He(()=>{let{xi:c,yi:p,zi:f}=l(),m=((y,_,b)=>{let x=Ri(a(y.add(1),_,b,o).x).sub(Ri(a(y.sub(1),_,b,o).x)),w=Ri(a(y,_.add(1),b,o).x).sub(Ri(a(y,_.sub(1),b,o).x)),S=Ri(a(y,_,b.add(1),o).x).sub(Ri(a(y,_,b.sub(1),o).x));return x.equal(0).and(w.equal(0)).and(S.equal(0)).select(Q(.199,.299,.399),Ft(Q(x,w,S)))})(c,p,f).toVar(),g=Ae(m,0).toVar(),v=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(f.greaterThanEqual(i));return ze(v.not(),()=>{g.assign(Ae(m,h(c,p,f)))}),g})(),d=He(()=>{let{xi:c,yi:p,zi:f}=l(),m=Ae(0).toVar(),g=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(f.greaterThanEqual(i));return ze(g.not(),()=>{let v=h(c,p,f);m.assign(this.numTrisTableTexNode.sample(Se(v.add(.5).div(256),.5)))}),m})();return this._quadMaterial("SplineShapeBlend.voxel",gw({output:u,numTris:d}))}_spatialTargetFor(e){let t=e.resolutionLevel,i=this.spatialTargets[t];return i||(i=J2(e.spatialDivisions*e.spatialn,e.spatialDivisions**2),this.spatialTargets[t]=i),i}_targetsFor(e){let t=e.resolutionLevel,i=this._spatialTargetFor(e),r=this.potentialTargets[t];r||(r=J2(e.basePyramidSize,e.basePyramidSize),this.potentialTargets[t]=r);let n=this.voxelTargets[t];n||(n=J2(e.basePyramidSize,e.basePyramidSize,2),n.textures[0].name="output",n.textures[1].name="numTris",n.textures[1].format=aa,this.voxelTargets[t]=n);let s=this.pyramidTargets[t];return s||(s=[J2(e.pyramidTexture1Width,e.pyramidTexture1Height),J2(e.pyramidTexture2Width,e.pyramidTexture2Height)],this.pyramidTargets[t]=s),{spatial:i,potential:r,voxel:n,pyramid:s}}_marchResources(e){let t=this._targetsFor(e),i=e.pyramidLevelSizes.length%2==0?0:1,r=1-i;return{resolutionLevel:e.resolutionLevel,pyramidLevelSizes:e.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:t.pyramid[r].width,height:t.pyramid[r].height},pyramid2Size:{width:t.pyramid[i].width,height:t.pyramid[i].height}}}_maxMarchSlots(e){let t=e.backend?.device?.limits,i=Math.min(t?.maxStorageBufferBindingSize??134217728,t?.maxBufferSize??268435456);return 192*Math.floor(i/16/192)}_ensureMarchCapacity(e,t){if(this._marchBuffers!==null&&e<=this._marchCapacity)return!1;let i=Math.min(Math.max(t,eM),192*Math.ceil(1.5*e/192));if(this._marchBuffers!==null&&i<=this._marchCapacity)return!1;if(this._marchBuffers!==null)for(let r of[this._marchBuffers.positions,this._marchBuffers.normals,this._marchBuffers.colors]){let n=r.value;n&&this._retiredStorage.push(n)}return this._marchBuffers={positions:$n(i,"vec4"),normals:$n(i,"vec4"),colors:$n(i,"vec4")},this._marchCapacity=i,this._computeNode=null,!0}update(e,t,i){if(nn.updates++,this._lastRenderer=t,i!==void 0&&(this._cullCamera=i),e._meshSdfBaked.size>0)for(let[T,M]of e._meshSdfBaked)M.owner!==this&&e._meshSdfBaked.delete(T);let r=(s=e,LSe.call(s)),n=t.backend?.isWebGPUBackend===!0;var s;if(n&&e._meshSdfWanted.size>0&&this._meshBaker===null&&(this._meshBaker=function(T,M){let E=hF,A=new Ey(Rf*E,Math.ceil(T/Rf)*E,E);A.format=aa,A.type=Gt,A.minFilter=gt,A.magFilter=gt,A.name="SplineShapeBlend.meshSdfAtlas";let C=L(M).mul(0),D=Be(new P(0,0,0)),R=Be(0),I=Be(new P(1,1,1)),U=$n(3*q4,"vec4"),O=q=>U.element(q),k=He(()=>{let q=Q(dl).toVar();ze($s(q.x).greaterThanEqual(E).or($s(q.y).greaterThanEqual(E)).or($s(q.z).greaterThanEqual(E)),()=>{yn()});let Y=q.div(E-1).mul(2).sub(1).mul(I).toVar(),ue=L(1e30).toVar(),de=L(1e15).toVar();Yr(q4,({i:be})=>{ze(L(be).greaterThanEqual($s(R)),()=>{qa()});let re=Pe(L(be).toVar()).mul(3).toVar(),xe=aA(O(re).xyz).toVar(),j=aA(O(re.add(Pe(1))).xyz).toVar(),z=aA(O(re.add(Pe(2))).xyz).toVar(),X=j.sub(xe).toVar(),te=z.sub(xe).toVar(),V=Y.sub(xe).toVar(),ae=Je(X,V).toVar(),se=Je(te,V).toVar(),W=Y.sub(j).toVar(),pe=Je(X,W).toVar(),_e=Je(te,W).toVar(),Ue=Y.sub(z).toVar(),we=Je(X,Ue).toVar(),Ye=Je(te,Ue).toVar(),Fe=Q(0).toVar(),We=pe.mul(Ye).sub(we.mul(_e)).toVar(),Re=we.mul(se).sub(ae.mul(Ye)).toVar(),ee=ae.mul(_e).sub(pe.mul(se)).toVar();ze(ae.lessThanEqual(0).and(se.lessThanEqual(0)),()=>{Fe.assign(xe)}).ElseIf(pe.greaterThanEqual(0).and(_e.lessThanEqual(pe)),()=>{Fe.assign(j)}).ElseIf(Ye.greaterThanEqual(0).and(we.lessThanEqual(Ye)),()=>{Fe.assign(z)}).ElseIf(ee.lessThanEqual(0).and(ae.greaterThanEqual(0)).and(pe.lessThanEqual(0)),()=>{let dt=ae.div(ae.sub(pe));Fe.assign(xe.add(X.mul(dt)))}).ElseIf(Re.lessThanEqual(0).and(se.greaterThanEqual(0)).and(Ye.lessThanEqual(0)),()=>{let dt=se.div(se.sub(Ye));Fe.assign(xe.add(te.mul(dt)))}).ElseIf(We.lessThanEqual(0).and(_e.sub(pe).greaterThanEqual(0)).and(we.sub(Ye).greaterThanEqual(0)),()=>{let dt=_e.sub(pe).div(_e.sub(pe).add(we.sub(Ye)));Fe.assign(j.add(z.sub(j).mul(dt)))}).Else(()=>{let dt=L(1).div(We.add(Re).add(ee)),et=Re.mul(dt),$t=ee.mul(dt);Fe.assign(xe.add(X.mul(et)).add(te.mul($t)))});let Ee=Y.sub(Fe).toVar(),je=Je(Ee,Ee).toVar();ze(je.lessThan(ue),()=>{ue.assign(je);let dt=qn(X,te),et=Je(Ee,dt).greaterThanEqual(0).select(L(1),L(-1));de.assign(Rh(je).mul(et))})});let ge=pt($s(I.x),pt($s(I.y),$s(I.z)));yg(A,Ga(q.add(D)),Ae($s(de.div(ge).add(C)),0,0,0)).toStack()})(),G=Math.ceil(E/4),K=k.compute([G,G,G],[4,4,4]);return{atlas:A,slots:T,kernel:K,uniforms:{slotOrigin:D,triCount:R,boxHalf:I},setTriangles(q,Y){let ue=U.value;ue.array.set(q.subarray(0,12*Y)),ue.needsUpdate=!0}}}(Rf*Rf,++this._ultraBuildSeq)),e.npart===0)return this._meshBaker!==null&&e._meshSdfWanted.size>0&&this._bakeNextMeshChild(e,t),void(e.geometry.drawRange.count=0);this.npartUniform.value=e.npart,this.spatialnUniform.value=e.spatialn,this.spanUniform.value=e.spatialPassUniforms.span.value,e.shapesDataTexture.value&&(this.shapesTex.value=e.shapesDataTexture.value);let a=!u9&&n,o=a&&!d9&&e.ultraFieldResolution>0,l=o&&!g9&&(m9||e.ultraFieldResolution>=512)?Math.min(Math.pow(e.ultraFieldResolution/4,3),Math.max(function(T){let M=T/4;return Math.min(M*M*M,Math.max(8192,16*M*M))}(e.ultraFieldResolution),this._ultraWantedPoolBricks,this.poolHint)):0,h=l>0&&!v9,u=this._maxMarchSlots(t),d=h?Math.min(Math.floor(u/64),Math.max(function(T){let M=T/4;return Math.min(262144,Math.max(2048,2*M*M))}(e.ultraFieldResolution),this._ultraWantedVertexBlocks,this.vertHint)):0,c=this._meshBaker!==null,p=e.needsRebuild||this.level!==e.resolutionLevel||this.spatialnAtBuild!==e.spatialn||this._cachedAtBuild!==a||this._ultraResAtBuild!==(o?e.ultraFieldResolution:0)||this._poolAtBuild!==l||this._vertBlocksAtBuild!==d||this._meshAtBuild!==c;if(p&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let f=a&&this._ensureMarchCapacity(Math.min(Math.max(u,eM),Math.max(e.geometry.drawRange.count,this.capacityHint,o?Math.max(function(T){return Math.max(eM,192*Math.ceil(16*T*T/192))}(e.ultraFieldResolution),this._ultraWantedCapacity):eM)),u);if(f&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let m=this._spatialTargetFor(e),g=o?null:this._targetsFor(e),v=p||f,y=o&&this._ultra!==null&&this._ultraResAtBuild===e.ultraFieldResolution&&!f&&this.level===e.resolutionLevel&&this.spatialnAtBuild===e.spatialn&&this._cachedAtBuild===a;if(v&&y)e.needsRebuild=!1,this._ultra.uniforms.bboxHalf.value=e.bboxSize/2,this._ultra.uniforms.bboxOffset.value=e.bboxOffset,this._ultraDrag&&(this._ultraDrag.uniforms.bboxHalf.value=e.bboxSize/2,this._ultraDrag.uniforms.bboxOffset.value=e.bboxOffset);else if(v){e.needsRebuild=!1;let T=this.spatialnAtBuild!==e.spatialn;this.level=e.resolutionLevel,this.spatialnAtBuild=e.spatialn,this._meshAtBuild=c,(T||this.spatialMaterial===null)&&(this.spatialMaterial?.dispose(),this.spatialMaterial=this._buildSpatialMaterial(e)),this.spatialTexNode.value=m.texture;let M=this._ultra,E=this._ultraDrag;if(this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,o){let D=e.ultraFieldResolution,R=M!==null&&this._ultraResAtBuild===D;if(R&&!f)this._ultra=M,M.uniforms.bboxHalf.value=e.bboxSize/2,M.uniforms.bboxOffset.value=e.bboxOffset,this._ultraDrag=E,E&&(E.uniforms.bboxHalf.value=e.bboxSize/2,E.uniforms.bboxOffset.value=e.bboxOffset);else{let I=R&&l===0&&!M.sparse;M&&!I&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),h&&this._drawIndex===null&&(this._drawIndex=$n(this._marchCapacity,"uint")),h&&this._vertexBuffers===null&&(this._vertexBuffers={positions:$n(64*d,"vec4"),normals:$n(64*d,"vec4"),colors:$n(64*d,"vec4")}),this._ultra=n0e({resolution:D,colorResolution:D/2,bboxHalf:e.bboxSize/2,bboxOffset:e.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(e,2/(D/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:dO().numTrisTable,buffers:h?this._vertexBuffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,sparseStorage:l>0?{poolBricks:l,meshlet:h?{drawIndex:this._drawIndex,vertexBlocks:d}:void 0}:void 0,reuseTextures:I?{sdfTexture:M.sdfTexture,colorTexture:M.colorTexture,coarseTexture:M.coarseTexture}:void 0}),this._poolAtBuild=l,this._vertBlocksAtBuild=d;let U=f9&&D>=128&&!h?D/2:0;E&&(!R||U===0)&&this._ultraRetired.push(E.sdfTexture,E.colorTexture,E.coarseTexture),U>0&&(this._ultraDrag=n0e({resolution:U,colorResolution:U/2,bboxHalf:e.bboxSize/2,bboxOffset:e.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(e,2/(U/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:dO().numTrisTable,buffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,reuseTextures:R&&E?{sdfTexture:E.sdfTexture,colorTexture:E.colorTexture,coarseTexture:E.coarseTexture}:void 0}))}this._ultraResAtBuild=D}else{M&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),E&&this._ultraRetired.push(E.sdfTexture,E.colorTexture,E.coarseTexture),(this._legacyMaterialsLevel!==e.resolutionLevel||T||this.potentialMaterial===null||this.voxelMaterial===null)&&(this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose(),this.potentialMaterial=this._buildPotentialMaterial(e),this.voxelMaterial=this._buildVoxelMaterial(e),this._legacyMaterialsLevel=e.resolutionLevel),this.potentialTexNode.value=g.potential.texture,this.voxelTexNode.value=g.voxel.textures[0];let D=e.pyramidLevelSizes.length%2==0?0:1,R=1-D;this.pyramid1TexNode.value=g.pyramid[R].texture,this.pyramid2TexNode.value=g.pyramid[D].texture,this._ultraResAtBuild=0}let A=e.material;A.defines===void 0&&(A.defines={}),Xm.includes("nomat")||(A.defines.SHAPEBLEND=e.resolutionLevel),Xm.includes("nomat")||A.setShapeBlendResources?.(o?{resolutionLevel:e.resolutionLevel,pyramidLevelSizes:e.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:1,height:1},pyramid2Size:{width:1,height:1},cached:h?{...this._vertexBuffers,drawIndex:this._drawIndex}:this._marchBuffers}:{...this._marchResources(e),cached:a?this._marchBuffers:void 0}),this._cachedAtBuild=a;let C=`${e.resolutionLevel}:${this._marchCapacity}`;this._computeNodeKey!==C&&(this._computeNode=null,this._computeNodeKey=C)}if(v)return this._builtOnce=!0,void(this._computeDirty=!0);this._meshBaker!==null&&e._meshSdfWanted.size>0&&this._bakeNextMeshChild(e,t);let _=this._passesRenderer!==t,b=r&&!p9&&!this._computeDirty&&!_&&!e._fieldDirtyFull;if(!(r||this._computeDirty||_)){if(o&&this._refinePending&&this._ultra!==null&&performance.now()-this._lastFieldChangeMs>250)return this._refinePending=!1,this._passesRenderer=t,nn.refines++,void this._runUltra(e,t,!1,this._ultra);if(o&&DN&&this._ultra!==null&&this._ultra.meshlet&&this._lastDispatched===this._ultra&&!this._ultraReadbackPending&&this._updateCullUniforms(e,this._ultra)&&(!this._hasGatherMVP||!this._lastGatherMVP.equals(this._ultra.uniforms.cullMVP.value))){this._lastGatherMVP.copy(this._ultra.uniforms.cullMVP.value),this._hasGatherMVP=!0,nn.regathers++;let T=t;return T.compute(this._ultra.kernels.zero),RN||T.compute(this._ultra.kernels.clearDraw),T.compute(this._ultra.kernels.gather),this._ultra.kernels.stats&&T.compute(this._ultra.kernels.stats),void this._runUltraReadback(e,t)}if(!e.drawRangeNeedsForceUpdate)return void nn.skips++;if(o)return void(this._ultraReadbackPending||this._runUltraReadback(e,t))}if(this._passesRenderer=t,Xm.includes("none")&&nn.readbacksResolved>0)return void(this._computeDirty=!1);let x=t.getRenderTarget(),w=t.getMRT(),S=t.autoClear;if(t.setMRT(null),t.autoClear=!1,nn.lastPass="spatial",t.setRenderTarget(m),Op.material=this.spatialMaterial,Op.render(t),o){t.autoClear=S,t.setRenderTarget(x),t.setMRT(w);let T=this._ultraDrag!==null&&r&&!this._computeDirty;return this._refinePending=T,this._lastFieldChangeMs=performance.now(),this._runUltra(e,t,b,T?this._ultraDrag:this._ultra),void(this._computeDirty=!1)}return Xm==="spatial"&&nn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(nn.lastPass="potential",t.setRenderTarget(g.potential),Op.material=this.potentialMaterial,Op.render(t),Xm==="potential"&&nn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(nn.lastPass="voxel",t.setRenderTarget(g.voxel),Op.material=this.voxelMaterial,Op.render(t),Xm==="voxel"&&nn.readbacksResolved>0?(t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),void(this._computeDirty=!1)):(nn.lastPass="pyramid",this._renderPyramid(e,t,g.voxel,g.pyramid),t.autoClear=S,t.setRenderTarget(x),t.setMRT(w),nn.lastPass="march",a&&(this._computeNode===null&&(this._computeNode=function(T,M,E){let A=qEe(T);return He(()=>{let{position:C,normal:D,color:R}=A(wa.toFloat());M.positions.element(wa).assign(Ae(C,1)),M.normals.element(wa).assign(Ae(D,0)),M.colors.element(wa).assign(R)})().compute(E)}(this._marchResources(e),this._marchBuffers,this._marchCapacity)),t.compute(this._computeNode),nn.computes++),void(this._computeDirty=!1))))}_bakeNextMeshChild(e,t){let i=this._meshBaker;for(let[r,n]of e._meshSdfWanted){let s=ISe(n);if(this._meshBakeFailed.get(r)===s)continue;let a=this._meshSlots.get(r);if(a===void 0){if(this._meshSlots.size>=i.slots)for(let h of this._meshSlots.keys())!e._meshSdfBaked.has(h)&&!e._meshSdfWanted.has(h)&&(this._meshSlots.delete(h),this._meshBakeFailed.delete(h));if(this._meshSlots.size>=i.slots){this._meshWarnedFull||(this._meshWarnedFull=!0,console.warn(`Spline shape blend: more than ${i.slots} distinct mesh children \u2014 the extra meshes are left out of the blend.`));continue}let l=new Set(this._meshSlots.values());for(a=0;l.has(a);)a++;this._meshSlots.set(r,a)}let o=j5e(n);if(o!==null)return i.setTriangles(o.data,o.triCount),i.uniforms.slotOrigin.value.copy(H5e(a)),i.uniforms.triCount.value=o.triCount,i.uniforms.boxHalf.value.copy(o.boxHalf),t.compute(i.kernel),e._meshSdfBaked.set(r,{slot:a,boxHalf:o.boxHalf.clone(),posVersion:s,owner:this}),void e._meshSdfWanted.delete(r);this._meshBakeFailed.set(r,s)}}_updateCullUniforms(e,t){if(!t.meshlet)return!1;let i=this._cullCamera;return DN&&i&&i.projectionMatrix!==void 0&&i.matrixWorldInverse!==void 0?(t.uniforms.cullMVP.value.multiplyMatrices(tt.unjitteredProjection.value,i.matrixWorldInverse).multiply(e.matrixWorld),t.uniforms.cullEnabled.value=1,!0):(t.uniforms.cullEnabled.value=0,!1)}_runUltra(e,t,i,r){let n=t;nn.lastPass="ultra-kernels",nn.lastDispatchRes=r.resolution,nn.marchPositions=(r.meshlet?this._vertexBuffers:this._marchBuffers).positions.value,this._lastDispatched=r;let s=r.resolution,a=s/4,o=2/(s-1);r.uniforms.activeThreshold.value=c9?1e30:(3*Math.sqrt(3)+4)*o+.25*e._maxBlendK;let l=r.meshlet&&!y9;r.meshlet&&(r.uniforms.adaptCos.value=l?a0e:2);let h=0,u=0,d=0,c=a,p=a,f=a;if(i){let v=r.uniforms.activeThreshold.value+2/(e.spatialDivisions-1)+4/(s-1),y=x=>Math.floor(.5*(x+1)*(s-1)/4),_=x=>Math.min(a-1,Math.max(0,y(x))),b=x=>Math.min(a,Math.max(1,y(x)+1));if(h=_(e._fieldDirtyMin.x-v),u=_(e._fieldDirtyMin.y-v),d=_(e._fieldDirtyMin.z-v),c=b(e._fieldDirtyMax.x+v)-h,p=b(e._fieldDirtyMax.y+v)-u,f=b(e._fieldDirtyMax.z+v)-d,nn.fieldsWindowed++,l){let x=Math.min(a,h+c+1),w=Math.min(a,u+p+1),S=Math.min(a,d+f+1);h=Math.max(0,h-1),u=Math.max(0,u-1),d=Math.max(0,d-1),c=x-h,p=w-u,f=S-d}}else nn.fieldsFull++;nn.lastWindowBricks=c*p*f,r.uniforms.windowOrigin.value.set(h,u,d),r.uniforms.windowSize?.value.set(c,p,f);let m=h===0&&u===0&&d===0&&c===a&&p===a&&f===a,g=[Math.ceil(c/4),Math.ceil(p/4),Math.ceil(f/4)];r.meshlet&&this._updateCullUniforms(e,r)&&(this._lastGatherMVP.copy(r.uniforms.cullMVP.value),this._hasGatherMVP=!0),n.compute(r.kernels.zero),RN||n.compute(r.meshlet?r.kernels.clearDraw:r.kernels.clear),r.needsInit&&r.kernels.init&&(n.compute(r.kernels.init),r.needsInit=!1),n.compute(r.kernels.coarse,g),r.kernels.release&&n.compute(r.kernels.release,g),r.kernels.alloc&&n.compute(r.kernels.alloc,g),r.kernels.meshRelease&&n.compute(r.kernels.meshRelease,g),r.sparse?m?n.compute(r.kernels.sdf):n.compute(r.kernels.sdfWindow,[c,p,f]):n.compute(r.kernels.sdf,[c,p,f]),r.kernels.classify&&n.compute(r.kernels.classify,g),n.compute(r.kernels.color,[Math.ceil(c/2),Math.ceil(p/2),Math.ceil(f/2)]),r.meshlet?(m?(n.compute(r.kernels.verts),n.compute(r.kernels.extract)):(n.compute(r.kernels.vertsWindow,[c,p,f]),n.compute(r.kernels.extractWindow,[c,p,f])),n.compute(r.kernels.gather)):n.compute(r.kernels.extract),r.kernels.stats&&n.compute(r.kernels.stats),nn.computes++,this._ultraReadbackPending?this._ultraReadbackQueued=!0:this._runUltraReadback(e,t)}_disposeRetired(){for(let e of this._ultraRetired)e.dispose();if(this._ultraRetired.length=0,this._retiredStorage.length>0){let e=this._lastRenderer?.backend?.attributeUtils;if(e)for(let t of this._retiredStorage)e.destroyAttribute(t);this._retiredStorage.length=0}for(let e of this._onSettled)e();this._onSettled.length=0}runWhenSettled(e){this._onSettled.push(e)}transferSettleQueue(e){e._onSettled.push(...this._onSettled),this._onSettled.length=0}_runUltraReadback(e,t){let i=this._lastDispatched??this._ultra,r=t;this._ultraReadbackPending=!0,nn.readbackPending=!0,r.getArrayBufferAsync(i.counterAttribute).then(n=>{if(this._ultraReadbackPending=!1,nn.readbackPending=!1,this.retired)return;this._disposeRetired();let s=new Uint32Array(n),a=i.meshlet?Math.floor(s[3]/3):s[0];if(nn.readbacksResolved++,nn.lastTotal=a,i.sparse&&s.length>2&&s[2]>0&&(this._ultraWantedPoolBricks=Math.ceil(1.5*Math.max(s[1],i.poolBricks)),this._computeDirty=!0),i.meshlet&&s.length>5&&s[5]>0){let l=Math.min(24*s[4],this._maxMarchSlots(t));l>this._marchCapacity&&(this._ultraWantedCapacity=Math.max(this._ultraWantedCapacity,l),this._computeDirty=!0)}if(i.meshlet&&s.length>7&&s[7]>0){let l=Math.min(Math.ceil(1.5*s[6]),Math.floor(this._maxMarchSlots(t)/64));l>i.vertexBlocks&&(this._ultraWantedVertexBlocks=Math.max(this._ultraWantedVertexBlocks,l),this._computeDirty=!0)}let o=Math.floor(this._marchCapacity/3);if(e.geometry.drawRange.count=3*Math.min(Math.ceil(1.25*a),o),e.markSceneShadowsDirty(),e.drawRangeNeedsForceUpdate=!1,this._ultraReadbackQueued&&(this._ultraReadbackQueued=!1,this._runUltraReadback(e,t)),a>o){let l=Math.min(3*a,this._maxMarchSlots(t));l>this._marchCapacity&&(this._ultraWantedCapacity=l,this._computeDirty=!0)}}).catch(()=>{nn.readbackErrors++,this._ultraReadbackPending=!1,nn.readbackPending=!1})}_renderPyramid(e,t,i,r){let n=e.pyramidLevelSizes,s=n.length-1-1;wE.value=0,J_.value=0;for(let o=s;o>=0;o--){let l=o%2==s%2?r[0]:r[1],h=o===s?i:o%2==s%2?r[1]:r[0];gx.value=h.textures.length>1?h.textures[1]:h.texture,q$.value=h.width,$$.value=h.height;let u=n[o];o===2&&e.resolutionLevel%2!=0&&(u=3),X$.value=u,l.viewport.set(J_.value,0,u,u),t.setRenderTarget(l),Op.material=$5e(),Op.render(t),l.viewport.set(0,0,l.width,l.height);let d=wE.value;wE.value=J_.value,J_.value=d,o<s&&(J_.value+=n[o+1])}nn.lastPass="pyramid-readback";let a=n.length%2==0?0:1;t.readRenderTargetPixelsAsync(r[a],r[a].width-1,0,1,1).then(o=>{let l=o[0];nn.readbacksResolved++,nn.lastTotal=l,!this.retired&&(this._disposeRetired(),(3*l>e.geometry.drawRange.count||e.drawRangeNeedsForceUpdate)&&(e.geometry.drawRange.count=3*Math.floor(1.2*l)),e.drawRangeNeedsForceUpdate=!1,this._marchBuffers!==null&&e.geometry.drawRange.count>this._marchCapacity&&(this._computeDirty=!0))}).catch(()=>{})}dispose(){for(let n of[...this.spatialTargets,...this.potentialTargets,...this.voxelTargets,...this.pyramidTargets.flat()])n?.dispose();this.spatialMaterial?.dispose(),this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose();let e=this._lastRenderer?.backend?.attributeUtils,t=n=>{if(e&&n!==null)for(let s of[n.positions,n.normals,n.colors]){let a=s.value;a&&e.destroyAttribute(a)}},i=n=>{if(n!==null){for(let s of Object.values(n.kernels))s?.dispose?.();if(e)for(let s of n.storageAttributes)e.destroyAttribute(s)}};t(this._marchBuffers),t(this._vertexBuffers);let r=this._drawIndex?.value;e&&r&&e.destroyAttribute(r),this._drawIndex=null,this._computeNode?.dispose?.(),this._marchBuffers=null,this._vertexBuffers=null,this._computeNode=null,this._computeNodeKey="",this._marchCapacity=0,i(this._ultra),this._ultra?.sdfTexture.dispose(),this._ultra?.colorTexture.dispose(),this._ultra?.coarseTexture.dispose(),this._ultra=null,i(this._ultraDrag),this._ultraDrag?.sdfTexture.dispose(),this._ultraDrag?.colorTexture.dispose(),this._ultraDrag?.coarseTexture.dispose(),this._ultraDrag=null,this._meshBaker?.atlas.dispose(),this._meshBaker=null,this._lastDispatched=null,this._disposeRetired(),this._lastRenderer=null}},ex=new WeakMap,SE=new WeakMap,qx=[]}),K5e=F(()=>{qB(),mZ(),Y5e(),b4=V5e,AK=e=>function(t){let i=ex.get(t);if(i?.wantsReplacement){let r=SE.get(t);SE.set(t,i),i.retired=!0;let n=new Y$(i.capacityHint,i.poolHint,i.vertHint);i.transferSettleQueue(n),r&&n.runWhenSettled(()=>r.dispose()),i=n,ex.set(t,i)}return i||(i=new Y$,ex.set(t,i)),i}(e),function(e){CK=e}({release:e=>function(t){let i=ex.get(t),r=SE.get(t);ex.delete(t),SE.delete(t),r&&qx.push(r),i&&(i.retired=!0,qx.push(i))}(e),drainRetired:X5e})});function Z5e(){let e=oA.length;if(e>0){for(let t of oA)t.dispose();oA.length=0}return e}var ll,oo,ru,Ni,Yu,o0e,_9,l0e,h0e,NN,u0e,IN,d0e,c0e,b9,Lp,eb,tM,ZEe,TE,oA,$4,tb,QEe,JEe,eAe,tAe,iAe,rAe,Q5e=F(()=>{ne(),mn(),gi(),bSe(),_Se(),ll=[64,1,1],ru=(oo=Jv)-1,Ni=(e,t)=>t!==void 0?Be(e,t):Be(e),Yu=(e,t)=>{let i=e.xyz,r=qn(i,t),n=qn(i,r);return t.add(r.mul(e.w).mul(2)).add(n.mul(2))},o0e=e=>{let t=Je(e,e);return t.lessThan(1e-10).select(Ae(0,0,0,1),e.mul(qK(pt(t,1e-20))))},_9=He(([e,t])=>{let i=e,r=t,n=Je(i,r).add(1).toVar(),s=Q(0).toVar();return ze(n.lessThan(1e-7),()=>{n.assign(0),ze(oi(i.x).greaterThan(oi(i.z)),()=>{s.assign(Q(i.y.negate(),i.x,0))}).Else(()=>{s.assign(Q(0,i.z.negate(),i.y))})}).Else(()=>{s.assign(qn(i,r))}),o0e(Ae(s,n))}),l0e=e=>e.sub(At(e.mul(1/289)).mul(289)),h0e=e=>e.sub(At(e.mul(1/289)).mul(289)),NN=e=>h0e(e.mul(34).add(10).mul(e)),u0e=e=>Ae(1.79284291400159).sub(e.mul(.85373472095314)),IN=He(([e])=>{let t=e,i=1/6,r=1/3,n=At(t.add(Je(t,Q(r)))).toVar(),s=t.sub(n).add(Je(n,Q(i))).toVar(),a=ar(s.yzx,s.xyz).toVar(),o=Q(1).sub(a).toVar(),l=Li(a,o.zxy).toVar(),h=pt(a,o.zxy).toVar(),u=s.sub(l).add(i).toVar(),d=s.sub(h).add(r).toVar(),c=s.sub(.5).toVar();n.assign(l0e(n));let p=NN(NN(NN(Ae(0,l.z,h.z,1).add(n.z)).add(n.y).add(Ae(0,l.y,h.y,1))).add(n.x).add(Ae(0,l.x,h.x,1))).toVar(),f=.142857142857,m=2*f,g=.5*f-1,v=f,y=p.sub(At(p.mul(v*v)).mul(49)).toVar(),_=At(y.mul(v)).toVar(),b=At(y.sub(_.mul(7))).toVar(),x=_.mul(m).add(g).toVar(),w=b.mul(m).add(g).toVar(),S=Ae(1).sub(oi(x)).sub(oi(w)).toVar(),T=Ae(x.xy,w.xy).toVar(),M=Ae(x.zw,w.zw).toVar(),E=At(T).mul(2).add(1).toVar(),A=At(M).mul(2).add(1).toVar(),C=ar(S,Ae(0)).negate().toVar(),D=T.xzyw.add(E.xzyw.mul(C.xxyy)).toVar(),R=M.xzyw.add(A.xzyw.mul(C.zzww)).toVar(),I=Q(D.xy,S.x).toVar(),U=Q(D.zw,S.y).toVar(),O=Q(R.xy,S.z).toVar(),k=Q(R.zw,S.w).toVar(),G=u0e(Ae(Je(I,I),Je(U,U),Je(O,O),Je(k,k))).toVar();I.assign(I.mul(G.x)),U.assign(U.mul(G.y)),O.assign(O.mul(G.z)),k.assign(k.mul(G.w));let K=pt(Ae(.5).sub(Ae(Je(s,s),Je(u,u),Je(d,d),Je(c,c))),Ae(0)).toVar();return K.assign(K.mul(K)),Je(K.mul(K),Ae(Je(I,s),Je(U,u),Je(O,d),Je(k,c))).mul(105)}),d0e=class extends ty{constructor(e,t,i,r,n){super(),this.tangentWorld=e,this.specularPower=t,this.specularIntensity=i,this.diffuseIntensity=r,this.ambientFloor=n}direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,n=Ft(bu.mul(Ae(this.tangentWorld,0)).xyz),s=t,a=yw,o=Ft(s.add(a)),l=pt($i(qn(n,s)),0),h=pt($i(qn(n,o)),0);r.directDiffuse.addAssign(i.mul(l).mul(this.diffuseIntensity).mul(Wl.rgb)),r.directSpecular.addAssign(i.mul(Xl(h,this.specularPower)).mul(this.specularIntensity).mul(Q(1,.95,.9)))}indirect(e){let{irradiance:t,ambientOcclusion:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(1/Math.PI).add(this.ambientFloor).mul(Wl.rgb)),r.indirectDiffuse.mulAssign(i)}},c0e=class extends ty{direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,n=t,s=To,a=yw,o=Ft(n.add(a)),l=Je(s,n).clamp(),h=Je(s,o).clamp();r.directDiffuse.addAssign(i.mul(l).mul(.85).mul(Wl.rgb)),r.directSpecular.addAssign(i.mul(Xl(h,60)).mul(.3).mul(Q(.3,.28,.25)))}indirect(e){let{irradiance:t,ambientOcclusion:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(1/Math.PI).add(.15).mul(Wl.rgb)),r.indirectDiffuse.mulAssign(i)}},b9=class extends Jt{constructor(e){super(),this.model=e,this.lights=!0}setupLightingModel(){return this.model}},Lp=new Vt,eb=new Vt,tM=new P,ZEe=class{constructor(){this.uNumStrands=Ni(0,"int"),this.uNumVerts=Ni(0,"int"),this.uDamping=Ni(.03),this.uLocalStiffness=Ni(.67),this.uGlobalStiffness=Ni(.5),this.uGlobalRange=Ni(.15),this.uStiffnessFalloff=Ni(.1),this.uGravity=Ni(0),this.uVspCoeff=Ni(.01),this.uVspThreshold=Ni(50),this.uKink=Ni(0),this.uKinkFreq=Ni(0),this.uUnitScale=Ni(100),this.uClumpStrength=Ni(0),this.uClumpSize=Ni(32,"int"),this.uClumpTipScale=Ni(1.5),this.uReset=Ni(1),this.uHasWind=Ni(0),this.uWind0=Ni(new P),this.uWind1=Ni(new P),this.uWind2=Ni(new P),this.uWind3=Ni(new P),this.uBoneQuat=Ni(new ut(0,0,0,1)),this.uBoneTrans=Ni(new P),this.uDeltaQuat=Ni(new ut(0,0,0,1)),this.uPrevBoneTrans=Ni(new P),this.uHairRoot=Ni(new at),this.uHairMid=Ni(new at),this.uHairTip=Ni(new at),this.uHeadColor=Ni(new at),this.uNoiseA=Ni(new at),this.uNoiseB=Ni(new at),this.uNoiseC=Ni(new at),this.uNoiseD=Ni(new at),this.uNoiseScale=Ni(.018),this.uNoiseMixHair=Ni(0),this.uNoiseMixHead=Ni(0),this.uWidth=Ni(.525),this.uSpecPow=Ni(40),this.uSpecInt=Ni(.4),this.uDiffInt=Ni(.6),this.uAmbInt=Ni(.25),this.uOpacity=Ni(1),this.uTipFade=Ni(.4),this.uColorSource=Ni(0),this.uShadeRoot=Ni(.6),this.uShadeTip=Ni(1.15),this.uShadowTexelWorld=Ni(0),this._armed=!1,this._uploadedGeneration=-1,this._prevBoneQuat=new Vt,this._prevBonePos=new P,this._hasPrevBone=!1,this._renderer=null,this.initialPos=$n(rf,"vec4"),this.rootColors=$n(Fx,"vec4"),this.positions=$n(rf,"vec4"),this.positionsPrev=$n(rf,"vec4"),this.positionsPrevPrev=$n(rf,"vec4"),this.tangents=$n(rf,"vec4"),this.restLengths=$n(rf,"float"),this.vspQuats=$n(Fx,"vec4"),this.vspTrans=$n(Fx,"vec4"),this.kIntegrate=this._buildIntegrate(),this.kStrandLevel=this._buildStrandLevel(),this.kVsp=this._buildVsp(),this.kLocalShape=this._buildLocalShape(),this.kLengthWind=this._buildLengthWind(),this.kClump=this._buildClump(),this.kRigidFollow=this._buildRigidFollow(),this.ribbonMaterial=this._buildRibbonMaterial(),this.scalpMaterial=this._buildScalpMaterial()}boneQuatNode(){return this.uBoneQuat}boneTransNode(){return this.uBoneTrans}_buildIntegrate(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumVerts),()=>{yn()});let t=e.div(oo).toVar(),i=e.sub(t.mul(oo)).toVar(),r=this.boneQuatNode(),n=this.boneTransNode(),s=this.initialPos.element(e).toVar(),a=Ae(Yu(r,s.xyz).add(n),s.w).toVar(),o=this.positions.element(e).toVar(),l=this.positionsPrev.element(e).toVar(),h=l.toVar();ze(this.uReset.greaterThan(.5),()=>{o.assign(a),h.assign(a)});let u=a.toVar();ze(o.w.greaterThan(0),()=>{let d=L(mg),c=eF(this.uDamping.negate().mul(d).mul(60)),p=o.xyz.add(o.xyz.sub(h.xyz).mul(c)).add(Q(0,-1,0).mul(this.uGravity).mul(d).mul(d));u.assign(Ae(p,o.w))}),ze(this.uGlobalStiffness.greaterThan(0).and(this.uGlobalRange.greaterThan(0)).and(u.w.greaterThan(0)).and(i.toFloat().lessThan(this.uGlobalRange.mul(oo))),()=>{let d=e.sub(i),c=this.initialPos.element(d),p=Ft(Yu(r,c.xyz)).y.mul(.5).add(.5),f=this.uGlobalStiffness.mul(Xl(pt(p,0),this.uStiffnessFalloff)),m=a.xyz.sub(u.xyz).mul(f);u.assign(Ae(u.xyz.add(m),u.w))}),ze(this.uKink.greaterThan(0).and(u.w.greaterThan(0)),()=>{let d=i.toFloat().div(oo),c=t.sub(t.div(256).mul(256)).toFloat().mul(.0245),p=d.mul(this.uKinkFreq).mul(6.2831853).add(c),f=this.uKink.mul(d).mul(.15).mul(this.uUnitScale),m=Ft(a.xyz.sub(n)).toVar(),g=Q(0).toVar();ze(oi(m.y).lessThan(.99),()=>{g.assign(Ft(qn(m,Q(0,1,0))))}).Else(()=>{g.assign(Ft(qn(m,Q(1,0,0))))});let v=Ft(qn(m,g)),y=g.mul(Aa(p)).mul(f).add(v.mul($o(p.mul(1.3).add(c))).mul(f).mul(.7));u.assign(Ae(u.xyz.add(y),u.w))}),this.positionsPrevPrev.element(e).assign(l),this.positionsPrev.element(e).assign(o),this.positions.element(e).assign(u)})().compute(ll[0],ll)}_buildStrandLevel(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumStrands),()=>{yn()});let t=e.mul(oo).toVar(),i=this.positionsPrevPrev.element(t.add(1)),r=this.positionsPrev.element(t),n=this.positionsPrev.element(t.add(1)),s=this.positions.element(t),a=this.positions.element(t.add(1)),o=n.xyz.sub(r.xyz),l=a.xyz.sub(s.xyz),h=o.div(pt($i(o),1e-7)),u=l.div(pt($i(l),1e-7)),d=_9(h,u).toVar(),c=s.xyz.sub(Yu(d,r.xyz)),p=this.uVspCoeff.toVar(),f=$i(a.xyz.sub(n.xyz.mul(2)).add(i.xyz));ze(f.greaterThan(this.uVspThreshold),()=>{p.assign(1)}),this.vspQuats.element(e).assign(d),this.vspTrans.element(e).assign(Ae(c,p))})().compute(ll[0],ll)}_buildVsp(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumVerts),()=>{yn()});let t=e.div(oo).toVar(),i=e.sub(t.mul(oo)).toVar();ze(i.lessThan(2),()=>{yn()});let r=this.vspQuats.element(t),n=this.vspTrans.element(t),s=n.w,a=this.positions.element(e).toVar(),o=this.positionsPrev.element(e).toVar(),l=h=>Ae(h.xyz.mul(L(1).sub(s)).add(Yu(r,h.xyz).add(n.xyz).mul(s)),h.w);this.positions.element(e).assign(l(a)),this.positionsPrev.element(e).assign(l(o))})().compute(ll[0],ll)}_buildLocalShape(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumStrands),()=>{yn()});let t=e.mul(oo).toVar(),i=Li(this.uLocalStiffness,.95).mul(.5),r=this.boneQuatNode();Yr(ru-1,({i:n})=>{let s=t.add(n).add(1).toVar(),a=this.positions.element(s).toVar(),o=this.positions.element(s.add(1)).toVar(),l=this.positions.element(s.sub(1)),h=Yu(r,this.initialPos.element(s).xyz),u=Yu(r,this.initialPos.element(s.add(1)).xyz),d=Yu(r,this.initialPos.element(s.sub(1)).xyz),c=a.xyz.sub(l.xyz),p=u.sub(h),f=h.sub(d),m=_9(f.div(pt($i(f),1e-7)),c.div(pt($i(c),1e-7))),g=Yu(m,p).add(a.xyz).sub(o.xyz).mul(i);ze(a.w.greaterThan(0),()=>{a.assign(Ae(a.xyz.sub(g),a.w))}),ze(o.w.greaterThan(0),()=>{o.assign(Ae(o.xyz.add(g),o.w))}),this.positions.element(s).assign(a),this.positions.element(s.add(1)).assign(o)})})().compute(ll[0],ll)}_buildLengthWind(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumStrands),()=>{yn()});let t=e.mul(oo).toVar();ze(this.uHasWind.greaterThan(.5),()=>{let i=e.sub(e.div(20).mul(20)).toFloat().div(20),r=this.uWind0.mul(i).add(this.uWind1.mul(L(1).sub(i))).add(this.uWind2.mul(i)).add(this.uWind3.mul(L(1).sub(i))).toVar();Yr(ru-2,({i:n})=>{let s=t.add(n).add(2).toVar(),a=this.positions.element(s).toVar(),o=this.positions.element(s.add(1)),l=a.xyz.sub(o.xyz),h=qn(qn(l,r),l).negate();a.assign(Ae(a.xyz.add(h.mul(mg).mul(.1)),a.w)),this.positions.element(s).assign(a)})}),Yr(5,()=>{Yr(ru,({i})=>{let r=t.add(i).toVar(),n=this.positions.element(r).toVar(),s=this.positions.element(r.add(1)).toVar(),a=this.restLengths.element(r),o=s.xyz.sub(n.xyz),l=pt($i(o),1e-7),h=L(1).sub(a.div(l)),u=o.mul(h),d=n.w.greaterThan(0),c=s.w.greaterThan(0),p=d.select(c.select(L(.5),L(1)),L(0)),f=c.select(d.select(L(.5),L(1)),L(0));n.assign(Ae(n.xyz.add(u.mul(p)),n.w)),s.assign(Ae(s.xyz.sub(u.mul(f)),s.w)),this.positions.element(r).assign(n),this.positions.element(r.add(1)).assign(s)})}),Yr(ru,({i})=>{let r=t.add(i).add(1).toVar(),n=this.positions.element(r.sub(1)),s=this.positions.element(r).toVar(),a=s.xyz.sub(n.xyz),o=pt($i(a),1e-7),l=this.restLengths.element(r.sub(1));ze(o.greaterThan(l),()=>{s.assign(Ae(n.xyz.add(a.div(o).mul(l)),s.w)),this.positions.element(r).assign(s)})}),Yr(oo,({i})=>{let r=t.add(i).toVar(),n=i.equal(oo-1).select(r.sub(1),r).toVar(),s=Ft(this.positions.element(n.add(1)).xyz.sub(this.positions.element(n).xyz));this.tangents.element(r).assign(Ae(s,0))})})().compute(ll[0],ll)}_buildClump(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumStrands),()=>{yn()});let t=this.uClumpSize.toVar(),i=e.div(t).mul(t).toVar();ze(e.equal(i),()=>{yn()}),ze(i.greaterThanEqual(this.uNumStrands),()=>{yn()});let r=e.mul(oo).toVar(),n=i.mul(oo).toVar();Yr(ru,({i:s})=>{let a=s.add(1).toVar(),o=a.toFloat().div(ru),l=this.uClumpStrength.mul(Xl(o,L(1).div(pt(this.uClumpTipScale,.5)))),h=r.add(a).toVar(),u=this.positions.element(h).toVar(),d=this.positions.element(n.add(a));u.assign(Ae(lt(u.xyz,d.xyz,l),u.w)),this.positions.element(h).assign(u)})})().compute(ll[0],ll)}_buildRigidFollow(){return He(()=>{let e=Pe(wa).toVar();ze(e.greaterThanEqual(this.uNumVerts),()=>{yn()});let t=this.uDeltaQuat,i=this.uPrevBoneTrans,r=this.boneTransNode(),n=a=>{let o=a.element(e).toVar();o.assign(Ae(Yu(t,o.xyz.sub(i)).add(r),o.w)),a.element(e).assign(o)};n(this.positions),n(this.positionsPrev),n(this.positionsPrevPrev);let s=this.tangents.element(e).toVar();s.assign(Ae(Yu(t,s.xyz),0)),this.tangents.element(e).assign(s)})().compute(ll[0],ll)}pastelNoise(e){let t=e.sub(this.boneTransNode()).mul(this.uNoiseScale),i=IN(t).mul(.5).add(.5),r=IN(t.add(Q(31.7,17.3,53.1))).mul(.5).add(.5),n=IN(t.mul(.7).add(Q(71.9,11.2,43.8))).mul(.5).add(.5),s=lt(this.uNoiseA,this.uNoiseB,i);return s=lt(s,this.uNoiseC,r.mul(.6)),s=lt(s,this.uNoiseD,n.mul(.25)),s}_buildRibbonMaterial(){let e=Bn("vec3","vHairTangent"),t=Bn("vec3","vHairNormal"),i=Bn("vec2","vHairUv"),r=Bn("float","vHairRand"),n=Bn("vec3","vHairInherit"),s=new b9(new d0e(e,this.uSpecPow,this.uSpecInt,this.uDiffInt,this.uAmbInt));s.name="SplineHairRibbons",s.userData.hairShadowVariant="texel-floor-v6",s.transparent=!1,s.depthTest=!0,s.depthWrite=!0,s.side=Cr;let a=l=>He(()=>{let h=Pe(wa).toVar(),u=h.div(ru).toVar(),d=h.sub(u.mul(ru)).toVar(),c=u.mul(oo).add(d).toVar(),p=Pe(rA).toVar(),f=p.bitAnd(1).toFloat().toVar(),m=p.shiftRight(1).bitAnd(1).toFloat().toVar(),g=this.positions.element(c).xyz.toVar(),v=this.positions.element(c.add(1)).xyz.toVar(),y=this.tangents.element(c).xyz,_=this.tangents.element(c.add(1)).xyz,b=lt(g,v,m).toVar(),x=lt(y,_,m).toVar(),w=Ft(Kf.sub(b)),S=qn(x,w).toVar(),T=$i(S).toVar();S.assign(T.greaterThan(1e-7).select(S.div(T),Q(1,0,0)));let M=d.toFloat().div(ru),E=d.add(1).toFloat().div(ru),A=lt(M,E,m).toVar(),C=this.uWidth.mul(L(1).sub(A.mul(this.uTipFade))).toVar(),D=l?(()=>{let G=this.uShadowTexelWorld,K=G.greaterThan(0).select(G.mul(1.5).clamp(L(2),L(8)),L(0));return pt(K.sub(C),0).toVar()})():null;D&&C.addAssign(D);let R=f.mul(2).sub(1),I=b.add(S.mul(C).mul(R)).toVar();D&&I.assign(I.sub(w.mul(D)));let U=this.positionsPrev.element(c).xyz,O=this.positionsPrev.element(c.add(1)).xyz;sF.assign(lt(U,O,m).add(S.mul(C).mul(R)));let k=fr(Aa(u.toFloat().mul(12.9898)).mul(43758.5453));return r.assign(k),n.assign(this.rootColors.element(u).xyz),e.assign(x),t.assign(Ft(w.sub(x.mul(Je(x,w))))),i.assign(Se(f,A)),I}),o=He(()=>{let l=i.y,h=lt(this.uHairRoot,this.uHairMid,Li(l.mul(2),1)),u=l.lessThan(.5).select(h,lt(this.uHairMid,this.uHairTip,l.sub(.5).mul(2))).toVar(),d=n.mul(lt(this.uShadeRoot,this.uShadeTip,l));u.assign(this.uColorSource.greaterThan(.5).select(d,u)),u.assign(lt(u,this.pastelNoise(Jl),this.uNoiseMixHair));let c=L(1).sub(oi(i.x.sub(.5)).mul(2));return L(1).sub(l.mul(this.uTipFade)).mul(Xl(pt(c,0),.5)).toVar().lessThan(.25).discard(),r.greaterThanEqual(this.uOpacity).discard(),Ae(u,1)});return s.positionNode=a(!1)(),s.castShadowPositionNode=a(!0)(),s.normalNode=t,s.colorNode=o(),s.needsUpdate=!0,s}_buildScalpMaterial(){let e=new b9(new c0e);e.name="SplineHairScalp";let t=He(()=>{let i=lt(this.uHeadColor,this.pastelNoise(Jl),this.uNoiseMixHead);return Ae(i,1)});return e.colorNode=t(),e.needsUpdate=!0,e}update(e,t){let i=t;if(i.backend?.isWebGPUBackend!==!0||(this._renderer=i,e.visible===!1))return;if(!this._armed){this._armed=!0;let o=e.ribbonMesh.material;e.ribbonMesh.material=this.ribbonMaterial,o.dispose?.();let l=e.scalpMesh.material;e.scalpMesh.material=this.scalpMaterial,l.dispose?.(),e.ribbonMesh.visible=!0}e.checkDataDrift();let r=e.activeGuideStrands,n=r*oo;e.generation!==this._uploadedGeneration&&(this._uploadedGeneration=e.generation,this.initialPos.value.array.set(e.roots.initialPositions),this.initialPos.value.needsUpdate=!0,this.restLengths.value.array.set(e.roots.restLengths),this.restLengths.value.needsUpdate=!0,this.rootColors.value.array.set(e.roots.rootColors),this.rootColors.value.needsUpdate=!0,e.ribbonMesh.geometry.instanceCount=r*ru,e.resetRequested=!0),this._syncUniforms(e),e.boneTransform(Lp,tM),this.uBoneQuat.value.set(Lp.x,Lp.y,Lp.z,Lp.w),this.uBoneTrans.value.copy(tM);let s=this._hasPrevBone&&(Math.abs(this._prevBoneQuat.dot(Lp))<.9999995||this._prevBonePos.distanceToSquared(tM)>1e-8),a=Math.floor(e.pendingSimSeconds/mg);a>4&&(a=4),e.pendingSimSeconds=Math.max(0,Math.min(e.pendingSimSeconds-a*mg,mg)),e.resetRequested&&a<1&&(a=1),a<1&&s&&(eb.copy(this._prevBoneQuat).invert().premultiply(Lp),this.uDeltaQuat.value.set(eb.x,eb.y,eb.z,eb.w),this.uPrevBoneTrans.value.copy(this._prevBonePos),this._dispatch(i,this.kRigidFollow,n));for(let o=0;o<a;o++){this.uReset.value=e.resetRequested&&o===0?1:0,e.simTime+=mg,this._updateWind(e),this._dispatch(i,this.kIntegrate,n),this._dispatch(i,this.kStrandLevel,r),this._dispatch(i,this.kVsp,n);for(let l=0;l<2;l++)this._dispatch(i,this.kLocalShape,r);this._dispatch(i,this.kLengthWind,r),e.data.clumpStrength>.001&&this._dispatch(i,this.kClump,r)}a>0&&(e.resetRequested=!1),this._prevBoneQuat.copy(Lp),this._prevBonePos.copy(tM),this._hasPrevBone=!0}_dispatch(e,t,i){t.count=i,e.compute(t)}_updateWind(e){let t=e.data,i=Math.max(e.roots.unitScale,.001),r=t.windStrength/i;this.uHasWind.value=t.windStrength>.001?1:0;let n=.7*e.simTime,s=Math.sin(n)*r,a=Math.cos(n)*r*.5;this.uWind0.value.set(s,0,a),this.uWind1.value.set(.7*s,.5*r,1.2*a),this.uWind2.value.set(.3*-s,0,.5*a),this.uWind3.value.set(.5*s,-.3*r,.8*-a)}_shadowTexelWorld(e){let t=e;for(;t.parent;)t=t.parent;let i=t;if(!i?.traverse)return 0;let r=0;return i.traverse(n=>{let s=n;if(s.isDirectionalLight!==!0||s.castShadow!==!0||s.visible===!1)return;let a=s.shadow?.camera,o=s.shadow?.mapSize?.x??0;typeof a?.right!="number"||typeof a?.left!="number"||o<=0||(r=Math.max(r,(a.right-a.left)/o))}),r}_syncUniforms(e){let t=e.data,i=e.roots.unitScale;this.uNumStrands.value=e.activeGuideStrands,this.uNumVerts.value=e.activeGuideStrands*oo,this.uDamping.value=t.damping,this.uLocalStiffness.value=t.localStiffness,this.uGlobalStiffness.value=t.globalStiffness,this.uGlobalRange.value=t.globalRange,this.uStiffnessFalloff.value=t.stiffnessFalloff,this.uGravity.value=t.gravity*i,this.uVspCoeff.value=t.vspCoefficient,this.uVspThreshold.value=.5*i,this.uKink.value=t.kink,this.uKinkFreq.value=t.kinkFrequency,this.uUnitScale.value=i,this.uClumpStrength.value=t.clumpStrength,this.uClumpSize.value=Math.max(1,Math.round(t.clumpSize)),this.uClumpTipScale.value=t.clumpTipScale;let r=(s,a)=>{s.value.setRGB(a.r,a.g,a.b,qi)};r(this.uHairRoot,t.hairRootColor),r(this.uHairMid,t.hairMidColor),r(this.uHairTip,t.hairTipColor),r(this.uHeadColor,t.headColor),r(this.uNoiseA,t.noiseColorA),r(this.uNoiseB,t.noiseColorB),r(this.uNoiseC,t.noiseColorC),r(this.uNoiseD,t.noiseColorD);let n=t.noiseEnabled?1:0;this.uNoiseScale.value=t.noiseScale/Math.max(i,.001),this.uNoiseMixHair.value=t.noiseMixHair*n,this.uNoiseMixHead.value=t.noiseMixHead*n,this.uWidth.value=.003*t.hairWidth*od*e.widthWorldScale,this.uShadowTexelWorld.value=this._shadowTexelWorld(e),this.uColorSource.value=t.hairColorSource==="object"&&t.headShape==="object"&&t.baseObjectId?1:0,this.uShadeRoot.value=t.hairShadeRoot??.6,this.uShadeTip.value=t.hairShadeTip??1.15,this.uSpecPow.value=t.specularPower,this.uSpecInt.value=t.specularIntensity,this.uDiffInt.value=t.diffuseIntensity,this.uAmbInt.value=t.ambientIntensity,this.uOpacity.value=t.opacity,this.uTipFade.value=t.tipFade}dispose(){for(let t of[this.kIntegrate,this.kStrandLevel,this.kVsp,this.kLocalShape,this.kLengthWind,this.kClump,this.kRigidFollow])t.dispose();this.ribbonMaterial.dispose(),this.scalpMaterial.dispose();let e=this._renderer?.backend?.attributeUtils;if(e)for(let t of[this.initialPos,this.rootColors,this.positions,this.positionsPrev,this.positionsPrevPrev,this.tangents,this.restLengths,this.vspQuats,this.vspTrans])e.destroyAttribute(t.value);this._renderer=null}},TE=new WeakMap,oA=[]}),J5e=F(()=>{MK(),Q5e(),SK=e=>function(t){let i=TE.get(t);return i===void 0&&(i=new ZEe,TE.set(t,i)),i}(e),function(e){TK=e}({release:e=>function(t){let i=TE.get(t);i!==void 0&&(TE.delete(t),oA.push(i))}(e),drainRetired:Z5e})}),nAe=F(()=>{$4=`
|
|
6262
6262
|
const PI: f32 = 3.14159265358979323846;
|
|
@@ -12953,11 +12953,11 @@ void main() {
|
|
|
12953
12953
|
void main() {
|
|
12954
12954
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
12955
12955
|
gl_FragColor = texel;
|
|
12956
|
-
}`}),n6e=new class{constructor(e){this._mesh=new Sr(r6e,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,i6e)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}(j3e),s7=null,a7=null,s6e=Oi.identity(),W3e=class{constructor(e,t,i,r){var n;this.uuid=e,this.width=t,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||ZE.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height;this.renderer.dpr=$ve(s,a,this.dpr,this.isScreenSpace),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{if(s.target?.uuid!==void 0){let a=this.frameRoot?.find(s.target.uuid);a&&a.dispatchEvent({...s,target:a})}},this.scene2d=new OZ(Qe.generateUUID(),vH.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(s7===null&&(s7=document.createElement("canvas")),s7),this.renderer=(n=this.canvas,a7===null&&(a7=new YVe(n)),a7),this.promise=this.init(),this.renderTarget=new gr(1,1,{type:li,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 eY(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(e){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,e.blitTextureToTarget)e.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{j3e.uniforms.tDiffuse.value=this.canvasTexture;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.clear(),n6e.render(e),e.setRenderTarget(t)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=e?.width??this.width,i=e?.height??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=s6e,this.isScreenSpace&&(this.frameOverride.fill.color=kr.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},H3e({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(e,t=window.devicePixelRatio){let i=Math.max(1,e?.width??this.width),r=Math.max(1,e?.height??this.height);this.dpr=t,this.width=i,this.height=r,this._innerApplySize();let n=function(s,a,o,l){let h=$ve(s,a,o,l),u=Math.max(o,512/Math.min(s,a)),d=Math.min(u,h);return{width:Math.max(1,Math.ceil(s*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,t,this.isScreenSpace);this.renderTarget.setSize(n.width,n.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(e),this.frameOverride?.requestRender()}applyFrame(e){let t=this.context.scene.find2D(e);if(t&&t instanceof Gc)return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.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(),t}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(e){return this.scene2d.find(e)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(e=>{e.removeEventListener("beginState",this.onFrameOverrideObjectEvent),e.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function H3e({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){if(e instanceof Gc&&t instanceof Gc||e instanceof Xg&&t instanceof Xg)for(let a=0,o=e.children.length;a<o;a++){let l=e.children[a],h=t.children[a];l&&h&&l.uuid===h.uuid&&a6e({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s})}}function a6e({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){let[a,o]=function(d){if(o7(d))return[d.width,d.height];if(d instanceof lB){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof Xg){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(t),{width:l,height:h,position:u}=G3e({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=u,e.data={...e.data,position:u},e.states)for(let d in e.states)o6e({stateId:d,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s});if(o7(e)||e instanceof Xg)o7(e)&&(e.width=l,e.height=h,e.data={...e.data,width:l,height:h}),H3e({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:h,initialParentWidth:a,initialParentHeight:o});else if(e instanceof lB){let d=t,c=a!==0?l/a:1,p=o!==0?h/o:1;e.path=function(f,m=1,g=1){if(m<=0||g<=0)return f;if(k3e(f))return console.warn("Cannot scale invalid path",f),n7([]);if(m===1&&g===1)return f;try{return n7((0,t6e.parseSVG)(f).map(v=>{let y={...v};return"x"in y&&(y.x=y.x*m),"y"in y&&(y.y=y.y*g),"x1"in y&&(y.x1=y.x1*m),"x2"in y&&(y.x2=y.x2*m),"y1"in y&&(y.y1=y.y1*g),"y2"in y&&(y.y2=y.y2*g),"rx"in y&&(y.rx=y.rx*m),"ry"in y&&(y.ry=y.ry*g),y}))}catch(v){return console.warn("Error parsing SVG path",v),n7([])}}(d.path,c,p),e.data={...e.data,path:e.path}}}function o6e({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a}){let o=t.states?.[e],l=i.states?.[e];if(o&&l){let{width:h,height:u,position:d}=G3e({constraints:t.data,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:Ty.isResizeable(l)?l.width:0,objectInitialHeight:Ty.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:d}),Ty.isResizeable(o)&&Object.assign(t.states[e],{width:h,height:u})}}function o7(e){return e instanceof MC||e instanceof Gc||e instanceof NZ||e instanceof IZ}kB();var Xve,l6e=class extends wn{constructor(e,t,i){super(e,t,i),this.isUIObject=!0,this.uiCanvas=new W3e(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=e?.width??this.dataPatched.geometry.width,r=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Fg(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.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,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Zr(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t);let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Fg(i,t,this.data.flatShading,this)}};vr(),Cw("UIGeometry",(e,t,i)=>new l6e(e,t,i)),DB=Xve={Scene2D:OZ,UICanvas:W3e,loadHanaUIRUNTIME:function(){return sB||(sB=async()=>async function(e,t){return await e.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(e.Engine.prototype,"scene")||Object.defineProperty(e.Engine.prototype,"scene",{get:function(){let i=Object.create(e.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>e.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(()=>(hJ(),lJ)),Ive??function(){let e=typeof process<"u"?"2.0.204":void 0;return`https://cdn.spline.design/@splinetool/runtime${e?`@${e}`:""}/build/hana-ui.wasm`}())),U3e().then(()=>{})},setHanaUIWasmUrl:function(e){Ive=e}},s4!==null&&Xve.setHanaUIWasmUrl(s4),In("ui-2d"),PK(),Qwe(),ne();var q3e,l7,h6e=class{constructor(){this.type="ShapePath",this.color=new at,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new LE,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,s){return this.currentPath?.bezierCurveTo(e,t,i,r,n,s),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={loc:0,t:0};function t(h,u,d,c){let p=h.x,f=u.x,m=d.x,g=c.x,v=h.y,y=u.y,_=d.y,b=c.y,x=(g-m)*(v-_)-(b-_)*(p-m),w=(b-_)*(f-p)-(g-m)*(y-v),S=x/w,T=((f-p)*(v-_)-(y-v)*(p-m))/w;if(w===0&&x!==0||S<=0||S>=1||T<0||T>1)return null;if(x===0&&w===0){for(let M=0;M<2;M++){if(i(M===0?d:c,h,u),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}if(e.loc===2)return{x:+(p+e.t*(f-p)).toPrecision(10),y:+(v+e.t*(y-v)).toPrecision(10),t:e.t}}return null}for(let M=0;M<2;M++)if(i(M===0?d:c,h,u),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}return{x:+(p+S*(f-p)).toPrecision(10),y:+(v+S*(y-v)).toPrecision(10),t:S}}function i(h,u,d){let c,p=d.x-u.x,f=d.y-u.y,m=h.x-u.x,g=h.y-u.y,v=p*g-m*f;return h.x===u.x&&h.y===u.y?(e.loc=0,void(e.t=0)):h.x===d.x&&h.y===d.y?(e.loc=1,void(e.t=1)):void(v<-Number.EPSILON?e.loc=3:v>Number.EPSILON?e.loc=4:p*m<0||f*g<0?e.loc=5:Math.sqrt(p*p+f*f)<Math.sqrt(m*m+g*g)?e.loc=6:(c=p!==0?m/p:g/f,e.loc=2,e.t=c))}let r=0,n=999999999,s=-999999999,a=[];this.subPaths.forEach(h=>{let u=h.getPoints(),d=-999999999,c=999999999,p=-999999999,f=999999999;for(let m=0;m<u.length;m++){let g=u[m];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<f&&(f=g.x)}s<=p&&(s=p+1),n>=f&&(n=f-1),u.length&&a.push({curves:h.curves,points:u,isCW:fW.isClockWise(u),identifier:r++,boundingBox:new lY(new Z(f,c),new Z(p,d))})});let o=a.map(h=>function(u,d,c,p,f){(f==null||f==="")&&(f="nonzero");let m=new Z;u.boundingBox.getCenter(m);let g=function(w,S,T){let M=new Z;S.getCenter(M);let E=[];return T.forEach(A=>{A.boundingBox.containsPoint(M)&&function(C,D){let R=[],I=[];for(let U=1;U<C.length;U++){let O=C[U-1],k=C[U];for(let G=1;G<D.length;G++){let K=t(O,k,D[G-1],D[G]);K!==null&&R.find(q=>q.t<=K.t+Number.EPSILON&&q.t>=K.t-Number.EPSILON)===void 0&&(R.push(K),I.push(new Z(K.x,K.y)))}}return I}(w,A.points).forEach(C=>{E.push({identifier:A.identifier,isCW:A.isCW,point:C})})}),E.sort((A,C)=>A.point.x-C.point.x),E}([new Z(c,m.y),new Z(p,m.y)],u.boundingBox,d);g.sort((w,S)=>w.point.x-S.point.x);let v=[],y=[];g.forEach(w=>{w.identifier===u.identifier?v.push(w):y.push(w)});let _=v[0].point.x,b=[],x=0;for(;x<y.length&&y[x].point.x<_;)b.length>0&&b[b.length-1]===y[x].identifier?b.pop():b.push(y[x].identifier),x++;if(b.push(u.identifier),f==="evenodd"){let w=b.length%2==0,S=b[b.length-2];return{identifier:u.identifier,isHole:w,for:S}}if(f==="nonzero"){let w=!0,S=null,T=null;for(let M=0;M<b.length;M++){let E=b[M];d[E]&&(w?(T=d[E].isCW,w=!1,S=E):T!==d[E].isCW&&(T=d[E].isCW,w=!0))}return{identifier:u.identifier,isHole:w,for:S}}console.warn('fill-rule: "'+f+'" is currently not implemented.')}(h,a,n,s,this.userData?.style.fillRule)),l=[];return a.forEach(h=>{let u=o[h.identifier];if(u&&!u.isHole){let d=new AA;d.curves=h.curves,o.filter(c=>c?.isHole&&c.for===h.identifier).forEach(c=>{if(c){let p=a[c.identifier],f=new LE;f.curves=p.curves,d.holes.push(f)}}),l.push(d)}}),l}},$3e=!1,Yve=new Promise(e=>{q3e=e}),Kve=!1;function Zve(){if($3e=!0,!Kve)return l7||(l7=async function(){let e=await import("./opentype.js");q3e(e),Kve=!0}(),l7)}var u6e=new class{async load(e,t,i=()=>{}){let{load:r}=await Yve;r(e,(n,s)=>{n||!s?i(n??"Something went wrong"):t(s)})}async parse(e){let{parse:t,Bidi:i}=await Yve;try{let r=t(e),n=new i,s=a=>r.charToGlyphIndex(a.char);return n.registerModifier("glyphIndex",null,s),n.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:n}}catch(r){console.error(r)}}};function d6e(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}ne(),QY(),vr(),Cw("TextGeometry",(e,t,i)=>new $B(e,t,i));var Qve={create:(e,t)=>new jH(e,t)};bH("TextGeometry",Qve),bH("InputGeometry",Qve),ZY=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}async load(e){try{this._layoutErrorWarned=!1;let t=await async function(i){let r,n,s=!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),n=i.url,s=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!$3e)return{font:void 0,url:n,intercepted:s,arr:r,bidi:null};{let a=await u6e.parse(r);if(a)return{font:a.font,url:n,intercepted:s,arr:r,bidi:a.bidi}}}}(e);t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)}catch(t){console.warn(`Could not load the font "${e.url??"(inline data)"}"`,t)}}warnLayoutError(e){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,e))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let n=r.tokenizer.tokens,s=[],a=0,o=i.length===n.length;for(let l=0;l<i.length;l++){let h=i[l].index,u=String.fromCharCode(i[l].unicode),d=n[a];if(d6e(h,d)||o)s.push({char:u,index:h,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",f=[d.state.glyphIndex],m=[],g=!1;for(;!g;)a++,p=t.charAt(a),c+=p,f.push(e.charToGlyphIndex(p)),m=e.stringToGlyphs(c),m.length===1&&m[0].index===h&&(g=!0),a>t.length&&(g=!0);s.push({char:u,index:h,replacements:f,replacementChars:Array.from(c)}),a++}}return s}generateShapes(e,t,i){if(!this._isLoaded)return;let r=this.font,n=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,a=e.map(v=>this.getTextWidth(v,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,h=this.getCharWidth(`
|
|
12956
|
+
}`}),n6e=new class{constructor(e){this._mesh=new Sr(r6e,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,i6e)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}(j3e),s7=null,a7=null,s6e=Oi.identity(),W3e=class{constructor(e,t,i,r){var n;this.uuid=e,this.width=t,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||ZE.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height;this.renderer.dpr=$ve(s,a,this.dpr,this.isScreenSpace),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{if(s.target?.uuid!==void 0){let a=this.frameRoot?.find(s.target.uuid);a&&a.dispatchEvent({...s,target:a})}},this.scene2d=new OZ(Qe.generateUUID(),vH.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(s7===null&&(s7=document.createElement("canvas")),s7),this.renderer=(n=this.canvas,a7===null&&(a7=new YVe(n)),a7),this.promise=this.init(),this.renderTarget=new gr(1,1,{type:li,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 eY(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(e){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,e.blitTextureToTarget)e.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{j3e.uniforms.tDiffuse.value=this.canvasTexture;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.clear(),n6e.render(e),e.setRenderTarget(t)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=e?.width??this.width,i=e?.height??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=s6e,this.isScreenSpace&&(this.frameOverride.fill.color=kr.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},H3e({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(e,t=window.devicePixelRatio){let i=Math.max(1,e?.width??this.width),r=Math.max(1,e?.height??this.height);this.dpr=t,this.width=i,this.height=r,this._innerApplySize();let n=function(s,a,o,l){let h=$ve(s,a,o,l),u=Math.max(o,512/Math.min(s,a)),d=Math.min(u,h);return{width:Math.max(1,Math.ceil(s*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,t,this.isScreenSpace);this.renderTarget.setSize(n.width,n.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(e),this.frameOverride?.requestRender()}applyFrame(e){let t=this.context.scene.find2D(e);if(t&&t instanceof Gc)return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.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(),t}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(e){return this.scene2d.find(e)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(e=>{e.removeEventListener("beginState",this.onFrameOverrideObjectEvent),e.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function H3e({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){if(e instanceof Gc&&t instanceof Gc||e instanceof Xg&&t instanceof Xg)for(let a=0,o=e.children.length;a<o;a++){let l=e.children[a],h=t.children[a];l&&h&&l.uuid===h.uuid&&a6e({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s})}}function a6e({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s}){let[a,o]=function(d){if(o7(d))return[d.width,d.height];if(d instanceof lB){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof Xg){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(t),{width:l,height:h,position:u}=G3e({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=u,e.data={...e.data,position:u},e.states)for(let d in e.states)o6e({stateId:d,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:n,initialParentHeight:s});if(o7(e)||e instanceof Xg)o7(e)&&(e.width=l,e.height=h,e.data={...e.data,width:l,height:h}),H3e({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:h,initialParentWidth:a,initialParentHeight:o});else if(e instanceof lB){let d=t,c=a!==0?l/a:1,p=o!==0?h/o:1;e.path=function(f,m=1,g=1){if(m<=0||g<=0)return f;if(k3e(f))return console.warn("Cannot scale invalid path",f),n7([]);if(m===1&&g===1)return f;try{return n7((0,t6e.parseSVG)(f).map(v=>{let y={...v};return"x"in y&&(y.x=y.x*m),"y"in y&&(y.y=y.y*g),"x1"in y&&(y.x1=y.x1*m),"x2"in y&&(y.x2=y.x2*m),"y1"in y&&(y.y1=y.y1*g),"y2"in y&&(y.y2=y.y2*g),"rx"in y&&(y.rx=y.rx*m),"ry"in y&&(y.ry=y.ry*g),y}))}catch(v){return console.warn("Error parsing SVG path",v),n7([])}}(d.path,c,p),e.data={...e.data,path:e.path}}}function o6e({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a}){let o=t.states?.[e],l=i.states?.[e];if(o&&l){let{width:h,height:u,position:d}=G3e({constraints:t.data,newParentWidth:r,newParentHeight:n,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:Ty.isResizeable(l)?l.width:0,objectInitialHeight:Ty.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:d}),Ty.isResizeable(o)&&Object.assign(t.states[e],{width:h,height:u})}}function o7(e){return e instanceof MC||e instanceof Gc||e instanceof NZ||e instanceof IZ}kB();var Xve,l6e=class extends wn{constructor(e,t,i){super(e,t,i),this.isUIObject=!0,this.uiCanvas=new W3e(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=e?.width??this.dataPatched.geometry.width,r=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Fg(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.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,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Zr(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t);let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Fg(i,t,this.data.flatShading,this)}};vr(),Cw("UIGeometry",(e,t,i)=>new l6e(e,t,i)),DB=Xve={Scene2D:OZ,UICanvas:W3e,loadHanaUIRUNTIME:function(){return sB||(sB=async()=>async function(e,t){return await e.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(e.Engine.prototype,"scene")||Object.defineProperty(e.Engine.prototype,"scene",{get:function(){let i=Object.create(e.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>e.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(()=>(hJ(),lJ)),Ive??function(){let e=typeof process<"u"?"2.0.205":void 0;return`https://cdn.spline.design/@splinetool/runtime${e?`@${e}`:""}/build/hana-ui.wasm`}())),U3e().then(()=>{})},setHanaUIWasmUrl:function(e){Ive=e}},s4!==null&&Xve.setHanaUIWasmUrl(s4),In("ui-2d"),PK(),Qwe(),ne();var q3e,l7,h6e=class{constructor(){this.type="ShapePath",this.color=new at,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new LE,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,s){return this.currentPath?.bezierCurveTo(e,t,i,r,n,s),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={loc:0,t:0};function t(h,u,d,c){let p=h.x,f=u.x,m=d.x,g=c.x,v=h.y,y=u.y,_=d.y,b=c.y,x=(g-m)*(v-_)-(b-_)*(p-m),w=(b-_)*(f-p)-(g-m)*(y-v),S=x/w,T=((f-p)*(v-_)-(y-v)*(p-m))/w;if(w===0&&x!==0||S<=0||S>=1||T<0||T>1)return null;if(x===0&&w===0){for(let M=0;M<2;M++){if(i(M===0?d:c,h,u),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}if(e.loc===2)return{x:+(p+e.t*(f-p)).toPrecision(10),y:+(v+e.t*(y-v)).toPrecision(10),t:e.t}}return null}for(let M=0;M<2;M++)if(i(M===0?d:c,h,u),e.loc===0){let E=M===0?d:c;return{x:E.x,y:E.y,t:e.t}}return{x:+(p+S*(f-p)).toPrecision(10),y:+(v+S*(y-v)).toPrecision(10),t:S}}function i(h,u,d){let c,p=d.x-u.x,f=d.y-u.y,m=h.x-u.x,g=h.y-u.y,v=p*g-m*f;return h.x===u.x&&h.y===u.y?(e.loc=0,void(e.t=0)):h.x===d.x&&h.y===d.y?(e.loc=1,void(e.t=1)):void(v<-Number.EPSILON?e.loc=3:v>Number.EPSILON?e.loc=4:p*m<0||f*g<0?e.loc=5:Math.sqrt(p*p+f*f)<Math.sqrt(m*m+g*g)?e.loc=6:(c=p!==0?m/p:g/f,e.loc=2,e.t=c))}let r=0,n=999999999,s=-999999999,a=[];this.subPaths.forEach(h=>{let u=h.getPoints(),d=-999999999,c=999999999,p=-999999999,f=999999999;for(let m=0;m<u.length;m++){let g=u[m];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<f&&(f=g.x)}s<=p&&(s=p+1),n>=f&&(n=f-1),u.length&&a.push({curves:h.curves,points:u,isCW:fW.isClockWise(u),identifier:r++,boundingBox:new lY(new Z(f,c),new Z(p,d))})});let o=a.map(h=>function(u,d,c,p,f){(f==null||f==="")&&(f="nonzero");let m=new Z;u.boundingBox.getCenter(m);let g=function(w,S,T){let M=new Z;S.getCenter(M);let E=[];return T.forEach(A=>{A.boundingBox.containsPoint(M)&&function(C,D){let R=[],I=[];for(let U=1;U<C.length;U++){let O=C[U-1],k=C[U];for(let G=1;G<D.length;G++){let K=t(O,k,D[G-1],D[G]);K!==null&&R.find(q=>q.t<=K.t+Number.EPSILON&&q.t>=K.t-Number.EPSILON)===void 0&&(R.push(K),I.push(new Z(K.x,K.y)))}}return I}(w,A.points).forEach(C=>{E.push({identifier:A.identifier,isCW:A.isCW,point:C})})}),E.sort((A,C)=>A.point.x-C.point.x),E}([new Z(c,m.y),new Z(p,m.y)],u.boundingBox,d);g.sort((w,S)=>w.point.x-S.point.x);let v=[],y=[];g.forEach(w=>{w.identifier===u.identifier?v.push(w):y.push(w)});let _=v[0].point.x,b=[],x=0;for(;x<y.length&&y[x].point.x<_;)b.length>0&&b[b.length-1]===y[x].identifier?b.pop():b.push(y[x].identifier),x++;if(b.push(u.identifier),f==="evenodd"){let w=b.length%2==0,S=b[b.length-2];return{identifier:u.identifier,isHole:w,for:S}}if(f==="nonzero"){let w=!0,S=null,T=null;for(let M=0;M<b.length;M++){let E=b[M];d[E]&&(w?(T=d[E].isCW,w=!1,S=E):T!==d[E].isCW&&(T=d[E].isCW,w=!0))}return{identifier:u.identifier,isHole:w,for:S}}console.warn('fill-rule: "'+f+'" is currently not implemented.')}(h,a,n,s,this.userData?.style.fillRule)),l=[];return a.forEach(h=>{let u=o[h.identifier];if(u&&!u.isHole){let d=new AA;d.curves=h.curves,o.filter(c=>c?.isHole&&c.for===h.identifier).forEach(c=>{if(c){let p=a[c.identifier],f=new LE;f.curves=p.curves,d.holes.push(f)}}),l.push(d)}}),l}},$3e=!1,Yve=new Promise(e=>{q3e=e}),Kve=!1;function Zve(){if($3e=!0,!Kve)return l7||(l7=async function(){let e=await import("./opentype.js");q3e(e),Kve=!0}(),l7)}var u6e=new class{async load(e,t,i=()=>{}){let{load:r}=await Yve;r(e,(n,s)=>{n||!s?i(n??"Something went wrong"):t(s)})}async parse(e){let{parse:t,Bidi:i}=await Yve;try{let r=t(e),n=new i,s=a=>r.charToGlyphIndex(a.char);return n.registerModifier("glyphIndex",null,s),n.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:n}}catch(r){console.error(r)}}};function d6e(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}ne(),QY(),vr(),Cw("TextGeometry",(e,t,i)=>new $B(e,t,i));var Qve={create:(e,t)=>new jH(e,t)};bH("TextGeometry",Qve),bH("InputGeometry",Qve),ZY=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}async load(e){try{this._layoutErrorWarned=!1;let t=await async function(i){let r,n,s=!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),n=i.url,s=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!$3e)return{font:void 0,url:n,intercepted:s,arr:r,bidi:null};{let a=await u6e.parse(r);if(a)return{font:a.font,url:n,intercepted:s,arr:r,bidi:a.bidi}}}}(e);t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)}catch(t){console.warn(`Could not load the font "${e.url??"(inline data)"}"`,t)}}warnLayoutError(e){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,e))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let n=r.tokenizer.tokens,s=[],a=0,o=i.length===n.length;for(let l=0;l<i.length;l++){let h=i[l].index,u=String.fromCharCode(i[l].unicode),d=n[a];if(d6e(h,d)||o)s.push({char:u,index:h,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",f=[d.state.glyphIndex],m=[],g=!1;for(;!g;)a++,p=t.charAt(a),c+=p,f.push(e.charToGlyphIndex(p)),m=e.stringToGlyphs(c),m.length===1&&m[0].index===h&&(g=!0),a>t.length&&(g=!0);s.push({char:u,index:h,replacements:f,replacementChars:Array.from(c)}),a++}}return s}generateShapes(e,t,i){if(!this._isLoaded)return;let r=this.font,n=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,a=e.map(v=>this.getTextWidth(v,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,h=this.getCharWidth(`
|
|
12957
12957
|
`,t),u=t.horizontalAlign===1?h:0,d=this.getLineInitialOffsetX(a[0],o,t.horizontalAlign,e[0],h),c=this.getLineInitialOffsetY(s,e.length,l,n,t.verticalAlign),p=[],f=e.map(()=>[]),m=e.map(()=>[]);for(let v=0;v<e.length;v++){let y=e[v],_={features:{liga:!0},letterSpacing:t.letterSpacing},b=[];try{b=r.stringToGlyphs(y,_)}catch(M){this.warnLayoutError(M)}d=this.getLineInitialOffsetX(a[v],o,t.horizontalAlign,y,h);let x=[];try{x=this.reverseLigaturesTable(r,y,b)}catch(M){this.warnLayoutError(M)}let w=this.computeSpaceWidthForLine(e,v,t,i),S=0,T=b[0];T&&t.horizontalAlign===2&&T.leftSideBearing!==void 0&&(d-=T.leftSideBearing*n);try{this.font?.forEachGlyph(y,d,c,t.fontSize,_,(M,E,A,C,D)=>{let R=M.index===0?`
|
|
12958
12958
|
`:M.unicode?String.fromCharCode(M.unicode):void 0,I=x[S],U=0;if(R===`
|
|
12959
12959
|
`)U=u;else if(R===" ")U=w;else{let O=this.createPath(M,n,E,A,t);O&&(U=O.offsetX,p.push(O.path))}if(I&&I.replacements.length!==1){let O=I.replacements.map(q=>(r.glyphs.get(q).advanceWidth??0)*n),k=O.reduce((q,Y)=>q+Y,0),G=O.map(q=>q/k),K=E;for(let q=0;q<G.length;q++){let Y=U*G[q];m[v].push([K,A]),f[v].push(Y),K+=Y}}else m[v].push([E,A]),f[v].push(U);S++})}catch(M){this.warnLayoutError(M)}c-=s}let g=[];for(let v=0,y=p.length;v<y;v++)g.push(...p[v].toShapes());return{shapes:g,charWidths:f,lineWidths:a,charCoords:m}}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(e,t,i,r,n){return(i===3||i===2)&&r.indexOf(`
|
|
12960
|
-
`)>=0&&(e-=n),i===3?.5*t-.5*e:i===2?t-e:0}getLineInitialOffsetY(e,t,i,r,n){let s=t*e,a=e-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return n===3?-(i-s-o):n===2?-(.5*i-.5*s-o):o}createPath(e,t,i,r,n){let s=e.getPath(i,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");let a=new h6e,o=(e.advanceWidth??1)*t;if(e)for(let l of s.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 wh)return d.v1;if(d instanceof pu||d instanceof df)return d.v0}}(l.curves);h!==void 0&&l.currentPoint.distanceTo(h)>0&&l.lineTo(h.x,h.y)}),{offsetX:o,path:a}}getCharWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(e,t,i,r){let n=this.getCharWidth(" ",i),s=e[t];if(s){let a=this.countSpaces(s.trimEnd());if(i.horizontalAlign===4&&t<e.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-a*n))/a}return n}countSpaces(e){return(e.match(/ /g)||[]).length}},In("text"),Ot();var X3e=null;function Jve(){return X3e}function c6e(e){let t=!1;return e.scene.objects.forEach(i=>{i.data.type==="Page"&&!t&&i.data.publish.gameControlObject&&o1.traverseModuleInstances(e,i.id,(r,n,s)=>{for(let a of s)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(t=!0)})}),t}Vr();var eI=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},h7=e=>e*(Math.PI/180),tI=new Map,hB=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.addEventListener?e.addEventListener(r,i,!1):e.attachEvent&&e.attachEvent(r,i)},uB=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.removeEventListener?e.removeEventListener(r,i):e.detachEvent&&e.detachEvent(r,i)},Y3e=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),eye=()=>{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}},u7=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},d7=(e,t,i)=>{let r=K3e(e);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+i;else{let s="";for(let a=0,o=t.length;a<o;a+=1)s+=t[a]+" "+i+", ";r[n]=s.slice(0,-2)}return r},K3e=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},c7=(e,t)=>{for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xX=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)};typeof window<"u"&&(Z3e="ontouchstart"in window,Q3e=!!window.PointerEvent,J3e=!!window.MSPointerEvent);var Z3e,Q3e,J3e,pb,tye={start:"mousedown",move:"mousemove",end:"mouseup"},pM={};function Kv(){}Q3e?pb={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:J3e?pb={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Z3e?(pb={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},pM=tye):pb=tye,Kv.prototype.on=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(t);return r},Kv.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i},Kv.prototype.trigger=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},t)})},Kv.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=((i,r)=>{let n={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&Object.prototype.hasOwnProperty.call(r,s)?n[s]=r[s]:Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s]);return n})(t.options,e))},Kv.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},hB(e,pb[t],i._domHandlers_[t]),pM[t]&&hB(e,pM[t],i._domHandlers_[t]),i},Kv.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},uB(e,pb[t],i._domHandlers_[t]),pM[t]&&uB(e,pM[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var LZ=Kv;function ba(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,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(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=ba.id,ba.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}ba.prototype=new LZ,ba.constructor=ba,ba.id=0,ba.prototype.buildEl=function(e){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},ba.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=(()=>{let n=K3e("borderRadius");for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]="50%");return n})(),i=d7("transition","opacity",e),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)"},c7(r.el,i),this.options.shape==="circle"&&c7(r.back,t),c7(r.front,t),this.applyStyles(r),this},ba.prototype.applyStyles=function(e){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this},ba.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},ba.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},ba.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},ba.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t},ba.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t},ba.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",n={};n.front=d7("transition",["top","left"],r);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(n),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)},ba.prototype.restCallback=function(){var e=this,t={};t.front=d7("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)},ba.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},ba.prototype.computeDirection=function(e){var t,i,r,n=e.angle.radian,s=Math.PI/4,a=Math.PI/2;if(n>s&&n<3*s&&!e.lockX?t="up":n>-s&&n<=s&&!e.lockY?t="left":n>3*-s&&n<=-s&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(i=n>-a&&n<a?"left":"right"),e.lockX||(r=n>0?"up":"down"),e.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:t},e.direction=this.direction,l)l[o]===this.direction[o]&&(h[o]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+i,e),h.y||this.trigger("plain:"+r,e),h.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var p6e=ba;function qs(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=qs.id,qs.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(t),(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}qs.prototype=new LZ,qs.constructor=qs,qs.id=0,qs.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===i)return t[r];return!1}},qs.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"},qs.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}},qs.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,n={},s=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(e.x&&e.y)n={x:e.x-a,y:e.y-o};else if(e.top||e.right||e.bottom||e.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=e.top,l.style.right=e.right,l.style.bottom=e.bottom,l.style.left=e.left,l.style.position="absolute",s.zone.appendChild(l);var h=l.getBoundingClientRect();s.zone.removeChild(l),n=e,e={x:h.left+r.x,y:h.top+r.y}}var u=new p6e(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:e,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(u7(u.ui.el,n),u7(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},qs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},qs.prototype.bindNipple=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},qs.prototype.pressureFn=function(e,t,i){var r=this,n=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var s=e.force||e.pressure||e.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)},qs.prototype.onstart=function(e){var t=this,i=t.options,r=e;return e=Y3e(e),t.updateBox(),xX(e,function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(s){if(Object.values(r.touches).findIndex(function(o){return o.identifier===s})<0){var a=[e[0]];a.identifier=s,t.processOnEnd(a)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))}),t.manager.bindDocument(),!1},qs.prototype.processOnStart=function(e){var t,i=this,r=i.options,n=i.manager.getIdentifier(e),s=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=i.getOrCreate(n,a);o.identifier!==n&&i.manager.removeIdentifier(o.identifier),o.identifier=n;var l=function(h){h.trigger("start",h),i.trigger("start "+h.id+":start",h),h.show(),s>0&&i.pressureFn(e,h,h.identifier),i.processOnMove(e)};if((t=i.idles.indexOf(o))>=0&&i.idles.splice(t,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(eI(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(e);l(o)}return o},qs.prototype.getOrCreate=function(e,t){var i,r=this,n=r.options;return/(semi|static)/.test(n.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):n.mode==="semi"?r.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(t,e)},qs.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.scroll;if((_=>isNaN(_.buttons)?_.pressure!==0:_.buttons!==0)(e)){if(!n)return console.error("Found zombie joystick with ID "+r),void t.manager.removeIdentifier(r);if(i.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:s.x+a.left,y:s.y+a.top}}n.identifier=r;var o=n.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=n.position.y),i.lockY&&(l.x=n.position.x);var h,u,d=eI(l,n.position),c=((_,b)=>{let x=b.x-_.x,w=b.y-_.y;return(S=>S*(180/Math.PI))(Math.atan2(w,x))})(l,n.position),p=h7(c),f=d/o,m={distance:d,position:l};if(n.options.shape==="circle"?(h=Math.min(d,o),u=((_,b,x)=>{let w={x:0,y:0};return x=h7(x),w.x=_.x-b*Math.cos(x),w.y=_.y-b*Math.sin(x),w})(n.position,h,c)):(u=((_,b,x)=>({x:Math.min(Math.max(_.x,b.x-x),b.x+x),y:Math.min(Math.max(_.y,b.y-x),b.y+x)}))(l,n.position,o),h=eI(u,n.position)),i.follow){if(d>o){let _=l.x-u.x,b=l.y-u.y;n.position.x+=_,n.position.y+=b,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",d=eI(l,n.position)}}else l=u,d=h;var g=l.x-n.position.x,v=l.y-n.position.y;n.frontPosition={x:g,y:v},i.dataOnly||u7(n.ui.front,n.frontPosition);var y={identifier:n.identifier,position:l,force:f,pressure:e.force||e.pressure||e.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-v/o},raw:m,instance:n,lockX:i.lockX,lockY:i.lockY};(y=n.computeDirection(y)).angle={radian:h7(180-c),degree:180-c},n.trigger("move",y),t.trigger("move "+n.id+":move",y)}else this.processOnEnd(e)},qs.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(i.dataOnly||n.hide(function(){i.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(i.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[s.id]=s.identifier))},qs.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()},qs.prototype.destroy=function(){var e=this;for(var t in e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()}),e.pressureIntervals)Object.prototype.hasOwnProperty.call(e.pressureIntervals,t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off(),e.pressureIntervals={},e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.manager=null};var f6e=qs;function ia(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=eye(),t._windowBound=!1,t.config(e),t.prepareCollections();var i=function(){var r;t.collections.forEach(function(n){n.forEach(function(s){r=s.el.getBoundingClientRect(),s.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){(r=>{tI.has(r)&&clearTimeout(tI.get(r)),tI.set(r,setTimeout(function(){tI.delete(r),r()},100))})(i)},t._onScroll=function(){t.scroll=eye()},t.collections}ia.prototype=new LZ,ia.constructor=ia,ia.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return!(i=r.get(t))}),i}},ia.prototype.create=function(e){return this.createCollection(e)},ia.prototype.bindWindowEvents=function(){var e=this;e._windowBound||typeof window>"u"||(e._windowBound=!0,hB(window,"resize",e._onResize),hB(window,"scroll",e._onScroll))},ia.prototype.unbindWindowEvents=function(){var e=this;!e._windowBound||typeof window>"u"||(e._windowBound=!1,uB(window,"resize",e._onResize),uB(window,"scroll",e._onScroll))},ia.prototype.createCollection=function(e){var t=this,i=new f6e(t,e);return t.bindCollection(i),t.collections.push(i),t.bindWindowEvents(),i},ia.prototype.bindCollection=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},ia.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)},ia.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)},ia.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier)===void 0&&(t=this.latest||0):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},ia.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t},ia.prototype.onmove=function(e){return this.onAny("move",e),!1},ia.prototype.onend=function(e){return this.onAny("end",e),!1},ia.prototype.oncancel=function(e){return this.onAny("end",e),!1},ia.prototype.onAny=function(e,t){var i,r=this,n="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=Y3e(t);var s=function(a,o,l){l.ids.indexOf(o)>=0&&(l[n](a),a._found_=!0)};return xX(t,function(a){i=r.getIdentifier(a),xX(r.collections,s.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},ia.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.unbindWindowEvents(),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.collections=[],e.off()},ia.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1),i.collections.length===0&&i.unbindWindowEvents()};var m6e=ia,Kx=null;function iye(){return Kx||(Kx=new m6e),Kx}var g6e={create:function(e){return iye().create(e)},destroy:function(){Kx&&(Kx.destroy(),Kx=null)},get factory(){return iye()}},v6e=g6e;Vr(),Ot(),ne(),Nh(),Pw(),wu(),bl(),Ot();var ePe=null;function p7(){return ePe}var tPe,f7,y6e=new Promise(e=>{tPe=e});function _6e(e){return f7||(f7=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.204/build",i=import("./physics.js"),[r,n]=await Promise.all([i,fetch(`${t}/physics.wasm`).then(s=>s.arrayBuffer())]);await r.init(n),tPe(r)}(),f7)}function iPe(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||n<l||s<l||a<l||o<l}function lf(e,t){let i=new Mt;if(t&&iPe(t))return i.setAttribute("position",new Tt([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new Tt([],3)),i.setIndex([]),i;let{positions:r,triIndices:n}=lK(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Tt(r,3)),i.setIndex(n),t&&i.applyMatrix4(t),i}Yn(),bl(),vr(),EK(),ne(),ne(),Dw(),uC();var Mr,b6e=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target}disconnect(){Xa(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>t.play()),this.actions.Animation.forEach(t=>{"runMode"in t.data&&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.Reset.forEach(t=>{t.dispatch()}),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(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},rye=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target,this.triggeringObjects=[];for(let a of t.triggeringObjects){let o=r.scene.findFrom(a,i);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(e){return this.target==="all"||this.triggeringObjects.some(t=>t===e||t.isAncestorOf(e.uuid)||e.isAncestorOf(t.uuid))}disconnect(){Xa(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>{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.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SceneTransition.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()))}};Yn(),hC(),AB(),y6e.then(e=>Mr=e);var ta=new P,su=new Vt,m7=new P,x6e=new P(1,1,1),g7=(new Rr(0,0,0,"YXZ"),new Rr(0,0,0,"XYZ")),zp=new P,nye=new P,fM=new Vt,iI=new De,sye=new De,w6e={type:"updateMatrix"},v7=(new Vt,new ja),y7=.01,wX={type:"beginEvent",eventName:"Collision"},S6e={type:"beginEvent",eventName:"Trigger"},dB=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.shear!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);function fb(e){return function(t){return typeof t=="object"&&t!==null&&"booleanOp"in t}(Bg(e)?e.object:e)}var T6e=class{constructor(e){this.eventContext=e,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=t=>{if(t.bodyType()!==Mr.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[i,r]=this.rigidBodyToMesh.get(t.handle);if(ta.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),su.copy(t.rotation()),i.matrixWorld.makeRotationFromQuaternion(su).setPosition(ta),i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(w6e),r){let n=i.cloner;if(n&&n.objectForSample===void 0){n.matrixWorld.copy(i.matrixWorld);for(let s of n.children)s.updateMatrixWorld(!0)}for(let s of i.children)s.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,i,r)=>{if(r===!1)return;let n,s;if(this.sensorToTriggerEvent[t]?(n=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(n=this.sensorToTriggerEvent[i],s=this.sharedGameControlGlobals.colliderToEntity.get(t)),n&&s&&n.isValidTriggeringObject(s))n.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===t||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(t)){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(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,t)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let u of o)u.data.target==="scene"&&this.dispatchCollisionEvent(u,a,t);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=e.isExport,this.sharedAssets=e.sharedAssets,this.renderer=e.renderer,this.requestRender=e.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(e=>{let t=e.dataPatched;for(let i of t.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(n=>n.data.type==="Destroy")?.data;if(r)for(let n of r.objects){let s=this.page.scene.find(n);s&&(s.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let i of t.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let n=this.page.scene.find(r);n&&(n.userData.hasDrag=!0)}})}_staticBVHIdOf(e){let t=this._staticBVHAttrIds.get(e);return t===void 0&&(t=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(e,t)),t}initBVH(){if(p7()===null)return void Ta("collision-bvh","trigger/collision detection");let e=[],t=[];if(this.page.traverseChildren(i=>{let r,n=i instanceof Ux,s=jE(i);if(Lg(i)||n||s)return;r=Bg(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(dB(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){e.push({geometry:o,matrixWorld:i.matrixWorld}),t.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)t.push(d)}}return!!fb(i)||void 0}),e.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===t.length&&i.signature.every((s,a)=>s===t[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=ly(e.map(s=>lf(s.geometry,s.matrixWorld)),!1),n=new(p7())(r);this._staticBVHCache={signature:t,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(e,t,i){if(iPe(e.matrixWorld))return;let r=[],n="geometry"in e?e.geometry:void 0,s=t.dataPatched;if(n?.getAttribute("position")!==void 0&&r.push(lf(n,e.shearScale)),s.physics.fusedBody){let a=this.gatherChildrenGeom(e,r);e.traverseObject(a),e.children.forEach(l=>l.updateMatrixWorld(!0));let o=e.cloner;o&&o.objectForSample===void 0&&s.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&s.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Mr.RigidBodyDesc.dynamic(),a.setLinearDamping(s.physics.damping).setAngularDamping(s.physics.damping).setAdditionalMass(1e-9).setGravityScale(s.physics.gravityScale).enabledRotations(...s.physics.enabledRotation).enabledTranslations(...s.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Mr.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Mr.RigidBodyDesc.fixed();let h=ly(r);ta.setFromMatrixPosition(e.matrixWorld),su.setFromRotationMatrix(e.matrixWorldRigid),e.position0=ta.clone().divideScalar(this.pixelsPerMeter),e.rotation0=su.clone(),ta.divideScalar(this.pixelsPerMeter),a.setTranslation(ta.x,ta.y,ta.z).setRotation(su),h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let u=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(s.geometry===void 0||s.geometry.type==="SubdivGeometry"||s.geometry.type==="NonParametricGeometry"||s.geometry.type==="BooleanGeometry"||s.geometry.type==="VectorGeometry"||s.geometry.type==="StarGeometry"||s.geometry.type==="RectangleGeometry"||s.geometry.type==="EllipseGeometry"||s.geometry.type==="TriangleGeometry"||s.geometry.type==="TorusGeometry"||s.geometry.type==="HelixGeometry");try{this.addCollider(u,s.physics,h,t,d)}catch{try{this.addCollider(u,s.physics,h,t,!1)}catch(c){console.error(c)}}if(u.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(u);l?this.rigidBodyToMesh.set(u.handle,[e,s.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e)):this.fixedBodiesToWatch.push([e,u,(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).clone()]),e.rigidBody=u}}addBoundsTree(e){let t=[];if(e.geometry?.getAttribute("position")!==void 0&&e.geometry?.getAttribute("position").count>0&&t.push(lf(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,t)),e.children.forEach(i=>i.updateMatrixWorld(!0)),t.length>0){let i=ly(t,!1);e.bvhGeometry=i,i.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(p7())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(e,t,i,r,n=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let s;i&&(s=t.colliderType==="trimesh"?Mr.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Mr.ColliderDesc.convexMesh(i.getAttribute("position").array,n?i.getIndex().array:void 0)),s.setFrictionCombineRule(Mr.CoefficientCombineRule.Average).setRestitutionCombineRule(Mr.CoefficientCombineRule.Average).setDensity(t.density).setFriction(t.friction).setRestitution(t.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(s,e);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Mr.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){let i=fb(e);return(r,n)=>{if(n===0)return;if(i&&r.parent===e)return!0;let s;if(Lg(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;s=r.object}else if(Bg(r))s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;n===1?r.matrixWorld.copy(e.shearScale):r.matrixWorld.copy(r.parent.matrixWorld),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&t.push(lf(o,r.matrixWorld)),!!fb(r)||void 0}}activate(e){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=e,this.usePhysics=this.page.data.globalPhysics.usePhysics;let t=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=Jve();if(r!==null?i=r.setup({manager:this,camera:t,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Ta("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 I3e(t,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 n=this.renderer.domElement.width/this.renderer.getPixelRatio(),s=this.renderer.domElement.height/this.renderer.getPixelRatio();Jve()?.createJoysticks(this,n,s),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 Mr.World(new Mr.Vector3(0,this.gravity,0)),this.events=new Mr.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(a=>{let o;if(Lg(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(Bg(a))o=a.object;else{if(jE(a)||l1(a)||a instanceof Ux)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=dB(h),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of h.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let v=new b6e(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.initialDisabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;a.traverseVisible(y=>{y.userData.isFollowingObj=v})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let m=a.geometry;if(l!==void 0){let g=Mr.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(ta,su,m7),a.position0=ta.clone().divideScalar(this.pixelsPerMeter),a.rotation0=su.clone(),ta.divideScalar(this.pixelsPerMeter),g.setTranslation(ta.x,ta.y,ta.z).setRotation(su);let v,y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=y,v=l.collider.type==="sphere"?Mr.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Mr.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Mr.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),v.setFrictionCombineRule(Mr.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(0).setRestitutionCombineRule(Mr.CoefficientCombineRule.Min);let _=this.sharedGameControlGlobals.rapierWorld.createCollider(v,y);this.sharedGameControlGlobals.colliderToEntity.set(_.handle,o),ta.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(m7.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),_.setTranslationWrtParent(ta);let b=new Vt().setFromEuler(new Rr().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));_.setRotationWrtParent(b),_.setActiveEvents(Mr.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else h.physics.rigidBody==="dynamic"||u||f||c||p||d?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,h.physics.fusedBody)):(m&&e.push(lf(m,a.matrixWorld)),h.physics.fusedBody&&!fb(a)&&a.traverseObject((g,v)=>{if(v===0)return;let y;if(Lg(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;y=g.object}else{if(jE(g)||l1(g)||g instanceof Ux)return;if(Bg(g))y=g.object;else if(y=g,y.dataPatched.cloner?.hideBase)return!0}let _=y.dataPatched;if(_.physics.enabled==="visibility"?!_.visible:!_.physics.enabled)return!0;let b=g.geometry;return b?.getAttribute("position")!==void 0&&e.push(lf(b,g.matrixWorld)),!!fb(g)||void 0}),this.generateSensorColliderDescs(o,h.physics.fusedBody,t));return!(h.physics?.fusedBody!==!0&&!l&&!fb(a))||void 0}),e.length===0)return;let i=ly(e),r=i.getIndex().count>0;if(!r&&t.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=Mr.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);if(r){let a=Mr.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Mr.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Mr.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s)}for(let[a,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);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(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new rye(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new De().compose(zp.fromArray(t.data.position.map(n=>typeof n=="number"?n:0)),fM.setFromEuler(g7.fromArray(t.data.rotation.map(n=>typeof n=="number"?n:0))),x6e);if(t.data.triggerZone==="box"){let n=new cn;n.min.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),n.max.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([n,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.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(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e){if(!this.isEnabled)return!0;let t=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),t=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,t=!1):this.initializationCounter===2&&this.gameControl&&(t=!this.gameControl.update(e)&&t),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(e===0)t=this.stepPhysics()&&t;else{let r=e/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let n=performance.now(),s=0,a=6;for(;this.accumulator>=i&&s<a&&(t=this.stepPhysics()&&t,this.accumulator-=i,s++,!(performance.now()-n>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=t}recordPhysicsPose(e){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ta,su,m7);let t=e;t.prevQ===void 0?(t.prevQ=su.clone(),t.prevT=ta.clone()):(t.prevQ.copy(su),t.prevT.copy(ta))}promoteMovedFixedBodies(){for(let e=this.fixedBodiesToWatch.length-1;e>=0;e--){let[t,i,r]=this.fixedBodiesToWatch[e];t.rigidBody===i?(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).equals(r)||(i.setBodyType(Mr.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),this.fixedBodiesToWatch.splice(e,1)):this.fixedBodiesToWatch.splice(e,1)}}clampPushedBodies(){let e=this.gameControl?.object.rigidBody;if(e===void 0)return;let t=this.sharedGameControlGlobals.rapierWorld,i=e.linvel(),r=e.translation(),n=Math.hypot(i.x,i.z);for(let s=0;s<e.numColliders();s++){let a=e.collider(s);t.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(t.contactPair(a,o,v=>{let y=v.normal(),_=y.x*(h.x-r.x)+y.y*(h.y-r.y)+y.z*(h.z-r.z)<0?-1:1;if(Math.abs(y.y)>.7)return;let b=_*y.x,x=_*y.z,w=Math.hypot(b,x);if(w<1e-4)return;let S=(i.x*b+i.z*x)/w;S>u&&(u=S,d=b/w,c=x/w)}),u===-1/0)return;let p=i.x*d+i.z*c;if(p<-y7)return;let f=l.linvel();if(n>y7&&p>y7){let v=f.x*d+f.z*c;if(v<=0)return;let y=Math.min(v,p);return void l.setLinvel({x:d*y,y:f.y,z:c*y},!0)}let m=f.x*d+f.z*c-Math.max(0,p);if(m<=0)return;let g=.5*m;l.setLinvel({x:f.x-d*g,y:f.y,z:f.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let e=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[t,i]of e)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(ta.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(su)):e.delete(t);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)t.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r,n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(t.cloner){for(let s of t.cloner.children)if(s.rigidBody===n){r=s;break}}e.dispatch(r),t.dispatchEvent(wX)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=sye.copy(e.matrixWorld).invert();e.traverseEntity((n,s)=>{if(t===!1&&s===1)return!0;for(let a of n.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new rye(a.id,a.data,n,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Mr.ColliderDesc.cuboid(...a.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):Mr.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Mr.ActiveEvents.COLLISION_EVENTS),zp.fromArray(a.data.position.map(h=>typeof h=="number"?h:0)),fM.setFromEuler(g7.fromArray(a.data.rotation.map(h=>typeof h=="number"?h:0))),iI.makeRotationFromEuler(g7).setPosition(zp).premultiply(n.matrixWorld),i?(Mf(iI,{translation:zp,quaternion:fM,scale:nye}),o.setActiveCollisionTypes(Mr.ActiveCollisionTypes.KINEMATIC_FIXED|Mr.ActiveCollisionTypes.DYNAMIC_FIXED)):(Mf(iI.premultiply(r),{translation:zp,quaternion:fM,scale:nye}),e.rigidBody.bodyType()===Mr.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===Mr.RigidBodyType.Fixed?o.setActiveCollisionTypes(Mr.ActiveCollisionTypes.KINEMATIC_FIXED|Mr.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Mr.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Mr.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),zp.divideScalar(this.pixelsPerMeter),o.setTranslation(zp.x,zp.y,zp.z),o.setRotation(fM),i)i.push([o,l]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,e.rigidBody);this.sensorToTriggerEvent[h.handle]=l}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,n,s]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(n===o||s.isValidTriggeringObject(tr.is(o)?o:o.object)===!1)continue;let l=sye.copy($be(n.matrixWorld)).copyPosition(n.matrixWorld).multiply(r),h=iI.copy(o.matrixWorld).invert().multiply(l),u=o.bvhGeometry.boundsTree;i instanceof cn?e=u.intersectsBox(i,h):(v7.radius=i,v7.center.setFromMatrixPosition(h),e=u.intersectsSphere(v7)),e?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),n.dispatchEvent(S6e)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(d=>d!==o)}}}};Iw(),ne(),l4(),Ir(),hC(),Qf();var _7=.02,aye=new P,oye=new P,M6e=new P,zo=new P,kp=new P,mb=new P,b7=new De,lye=new De,E6e=new De,mh=new Vt,Iv=new Vt,gb=new Rr(0,0,0,"YXZ"),A6e=new P(1,0,0),dc=new P(0,1,0),C6e=new P(0,0,1),hye=new P(1,1,1),uye=[],dye=e=>uye[e]??(uye[e]=new P),x7=new P,P6e=new P,R6e=new P,D6e=new P,cye=new Vt,N6e=new P,pye=new Vt,Ua=new Eh,au=new cn,I6e={type:"requestRender"},O6e={type:"updateMatrix"},SX=class extends ds{constructor(e,t,i,r,n,s,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=n,this.cameraFollow=s,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 Rr(0,0,0,"YXZ"),this.shearMatrix0=new De,this.cameraShearMatrix0=new De,this.position0Cam=new P,this.quat0Cam=new Vt,this.scale0Cam=new P,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Eh(new P(0,-40,0),new P(0,40,0)),matrix:new De,position:new P,rotation:new Vt},this.euler=new Rr(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Vt,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 De,this.nonColliderPosOffset=new De,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 De,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 Vt,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 Vt,this.objXZQuatInv=new Vt,this.objXZRotMat=new De,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Vt,this.colliderWorldQuat=new Vt,this.groundNormal=new P,this.groundTilt=new Vt,this.groundTiltInv=new Vt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Vt,this.scale=new P,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Kl&&!IW&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(IW&&J_e<15.5&&!Kl?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?SX.isLocked=!0:SX.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=v:this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=n.sharedGameControlGlobals,e===a&&(this.isFirstPerson=!0),this.object.parent instanceof Dn||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),this.shearMatrix0.copy(this.object.shearMatrix),Mf(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 Dn||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),this.cameraShearMatrix0.copy(this.camera.shearMatrix),Mf(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 f,m=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(m.y)<1e-6?(g.y=0,m.y=0,f=g.projectOnVector(m)):f=g.y/m.y>0?m.multiplyScalar(g.y/m.y):m.multiplyScalar(g.length()),this.targetToCamera0.copy(f).negate();let v=this.camera.position.clone().add(f);this.objectToTarget0.subVectors(v,this.position);let y=new Rr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Kn&&(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(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][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??Nx.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??Nx.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??i4.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*_7/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*_7/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*_7/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(f=>typeof f=="number"?f:0)),c=new Vt().setFromEuler(new Rr().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,hye),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 f=new Et;f.push({fi:0,data:{...ts.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...ts.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=oSe({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Sr(JY.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.matrixWorldAutoUpdate=!0,this.camera.matrixWorldAutoUpdate=!0,this.object.shearMatrix.copy(this.shearMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent instanceof Dn||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),Mf(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix});let t=new Rr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Kn?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),e?(this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.camera.parent instanceof Dn||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),Mf(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 e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},t4.list.forEach(i=>{this.actions[i]=ha({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,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"),Xa(this.actions.idle),Xa(this.actions.move),Xa(this.actions.run),Xa(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(t=>{t.play()}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(t=>{t.stop()}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return zo.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){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 t=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*t,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=kp.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*t,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,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(zo).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*t}}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 s=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=zo.subVectors(this.path[1],this.position),o=kp.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.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 n=M6e.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=kp.copy(n);s.y=0,n.set(0,n.y,s.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 s=zo;this.camera.getWorldDirection(s);let a=mb.copy(dc).multiplyScalar(s.dot(dc));s.sub(a);let o=kp.copy(this.directionXZ);o.x*=-1,this.rot.y=s.angleTo(o)*(s.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(gb.setFromVector3(this.rot),this.moveMode==="walk"&&(gb.x=0),n.applyEuler(gb),r&&(Iv.setFromUnitVectors(dc,this.groundNormal),n.applyQuaternion(Iv)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=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(x7,cye,P6e);let o=this.object.getWorldPosition(R6e).add(this.collider.position).sub(x7);pye.copy(a.prevQ).invert().premultiply(cye);let l=mb.subVectors(x7,a.prevT).add(D6e.copy(o).applyQuaternion(pye).sub(o)).divideScalar(t).divideScalar(this.pixelsPerMeter),h=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),zo.copy(n).divideScalar(this.pixelsPerMeter),0,t,!1);l.multiplyScalar(this.pixelsPerMeter);let u=tr.is(a)?a:a.object;if(h!==null&&this.lastHitObj!==u){let d;a instanceof Ko&&(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(wX));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),dye(s++).copy(h.normal1).applyQuaternion(a.quaternion))}if(s>0){for(let a=0;a<s;a++){let o=dye(a),l=o.dot(n);l<0&&n.addScaledVector(o,-l)}n.add(this.pushedVelocity)}else n.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(t),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*t,this.euler.y+=this.rotVelocity.y*t+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*t),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(dc,this.euler.y-this.euler0.y);let s=kp.copy(this.objectToCamXZ).normalize(),a=mb.copy(n).multiplyScalar(t);a.y=0;let o=a.sub(zo.copy(s).multiplyScalar(a.dot(s))).cross(s).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*t+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=Qe.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Qe.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Qe.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(gb.copy(this.euler),gb.y=0,this.nonColliderRotOffset.makeRotationFromEuler(gb)),mh.setFromAxisAngle(A6e,this.rot.x),Iv.setFromAxisAngle(dc,this.rot.y),Iv.multiply(mh),mh.setFromAxisAngle(C6e,this.rot.z),Iv.multiply(mh),this.quaternion.copy(Iv),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 s=kp.copy(n).multiplyScalar(t/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let u=0;u<5;u++){let d=s.length(),c=mb.copy(s).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(s);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.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}}y.dispatch(_),p.dispatchEvent(wX)}}}let f=aye.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),m=oye.copy(c).multiplyScalar(a.time_of_impact).dot(f),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=a.time_of_impact*(m-this.offset)/m,o.addScaledVector(c,g)),s.copy(c).multiplyScalar(d-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),y=mb.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let _=v.add(y);_.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(_,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);b!==null&&b.time_of_impact===0&&(f.y=0,f.normalize())}s.addScaledVector(f,-s.dot(f))}}this.position.addScaledVector(o,this.pixelsPerMeter),zo.copy(this.position).divideScalar(this.pixelsPerMeter),mh.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,h=l!==void 0&&N6e.copy(zo).sub(l.translation()).lengthSq()>1;l!==void 0&&(h?(l.setTranslation(zo,!0),l.setRotation(mh,!0)):(l.setNextKinematicTranslation(zo),l.setNextKinematicRotation(mh)))}else{let s=this.onObject?1:5,a=n.multiplyScalar(t/s);for(let o=0;o<s;o++)this.position.add(a),this.collisionAdjustment(t/s)}else this.position.addScaledVector(n,t);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),Oxe(this.position,this.quaternion,this.object.shearMatrix,this.scale,this.object.matrix).multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.parent instanceof Dn?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(s=>{s.updateMatrixWorld(!0)}),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),a=this.targetToCamera.add(s);b7.lookAt(a,s,dc).setPosition(a),b7.decompose(this.targetPos,this.targetQuat,zo),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=Qe.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Qe.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(O6e),!(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(I6e),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e,t=mh.setFromAxisAngle(dc,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Qe.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(t),e=this.cameraXAxis==="Limit"?Qe.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):Qe.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=zo.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let r=Iv.setFromAxisAngle(i,e);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){180*dc.angleTo(e)/Math.PI<15||180*dc.angleTo(e)/Math.PI>85?mh.identity():mh.setFromUnitVectors(dc,e),this.groundTilt.slerp(mh,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=oye.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=b7.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(zo,mh,kp).compose(zo,mh,hye);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(n=>{if(n===this.object||n.isDescendantOf(this.object)||!n.bvhGeometry||!n.bvhGeometry.boundsTree)return;au.makeEmpty(),n.updateMatrixWorldRigid();let s=n.matrixWorldRigid,a=lye.copy(s).invert(),o=E6e.copy(lye).multiply(i);Ua.copy(this.collider.segment),Ua.start.applyMatrix4(o),Ua.end.applyMatrix4(o);let l=aye.copy(this.position).applyMatrix4(a);au.expandByPoint(Ua.start),au.expandByPoint(Ua.end),au.min.addScalar(-this.collider.radius),au.max.addScalar(this.collider.radius),n.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:h=>h.distanceToPoint(Ua.end),intersectsBounds:h=>h.intersectsBox(au),intersectsTriangle:h=>{let u=zo,d=kp,c=h.closestPointToSegment(Ua,u,d);if(c<this.collider.radius){let p=this.collider.radius-c,f=d.sub(u).normalize(),m=mb.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),Ua.start.addScaledVector(f,p),Ua.end.addScaledVector(f,p)}}})}),au.makeEmpty(),Ua.copy(this.collider.segment),Ua.start.applyMatrix4(i),Ua.end.applyMatrix4(i),au.expandByPoint(Ua.start),au.expandByPoint(Ua.end),au.min.addScalar(-this.collider.radius),au.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:n=>n.distanceToPoint(Ua.end),intersectsBounds:n=>n.intersectsBox(au),intersectsTriangle:n=>{let s=zo,a=kp,o=n.closestPointToSegment(Ua,s,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),Ua.start.addScaledVector(h,l),Ua.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}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()}},rPe=SX;rPe.isLocked=!1,ne(),uC(),XB(),Iw(),Dw();var nPe,sPe,w7,L6e=new Promise(e=>{nPe=e});function B6e(e){return w7||(w7=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.204/build";typeof window<"u"&&(sPe=new URL(t.endsWith("/")?t:`${t}/`,window.location.href).href);let i=import("./navmesh.js"),[r,n]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});nPe(a)}(),w7)}Vr();var aPe,pr,ho,F6e=e=>`
|
|
12960
|
+
`)>=0&&(e-=n),i===3?.5*t-.5*e:i===2?t-e:0}getLineInitialOffsetY(e,t,i,r,n){let s=t*e,a=e-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return n===3?-(i-s-o):n===2?-(.5*i-.5*s-o):o}createPath(e,t,i,r,n){let s=e.getPath(i,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");let a=new h6e,o=(e.advanceWidth??1)*t;if(e)for(let l of s.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 wh)return d.v1;if(d instanceof pu||d instanceof df)return d.v0}}(l.curves);h!==void 0&&l.currentPoint.distanceTo(h)>0&&l.lineTo(h.x,h.y)}),{offsetX:o,path:a}}getCharWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(e,t){try{return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(e,t,i,r){let n=this.getCharWidth(" ",i),s=e[t];if(s){let a=this.countSpaces(s.trimEnd());if(i.horizontalAlign===4&&t<e.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-a*n))/a}return n}countSpaces(e){return(e.match(/ /g)||[]).length}},In("text"),Ot();var X3e=null;function Jve(){return X3e}function c6e(e){let t=!1;return e.scene.objects.forEach(i=>{i.data.type==="Page"&&!t&&i.data.publish.gameControlObject&&o1.traverseModuleInstances(e,i.id,(r,n,s)=>{for(let a of s)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(t=!0)})}),t}Vr();var eI=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},h7=e=>e*(Math.PI/180),tI=new Map,hB=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.addEventListener?e.addEventListener(r,i,!1):e.attachEvent&&e.attachEvent(r,i)},uB=(e,t,i)=>{let r,n=t.split(/[ ,]+/g);for(let s=0;s<n.length;s+=1)r=n[s],e.removeEventListener?e.removeEventListener(r,i):e.detachEvent&&e.detachEvent(r,i)},Y3e=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),eye=()=>{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}},u7=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},d7=(e,t,i)=>{let r=K3e(e);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+i;else{let s="";for(let a=0,o=t.length;a<o;a+=1)s+=t[a]+" "+i+", ";r[n]=s.slice(0,-2)}return r},K3e=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},c7=(e,t)=>{for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xX=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)};typeof window<"u"&&(Z3e="ontouchstart"in window,Q3e=!!window.PointerEvent,J3e=!!window.MSPointerEvent);var Z3e,Q3e,J3e,pb,tye={start:"mousedown",move:"mousemove",end:"mouseup"},pM={};function Kv(){}Q3e?pb={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:J3e?pb={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Z3e?(pb={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},pM=tye):pb=tye,Kv.prototype.on=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(t);return r},Kv.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i},Kv.prototype.trigger=function(e,t){var i,r=this,n=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},t)})},Kv.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=((i,r)=>{let n={};for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&Object.prototype.hasOwnProperty.call(r,s)?n[s]=r[s]:Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s]);return n})(t.options,e))},Kv.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},hB(e,pb[t],i._domHandlers_[t]),pM[t]&&hB(e,pM[t],i._domHandlers_[t]),i},Kv.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},uB(e,pb[t],i._domHandlers_[t]),pM[t]&&uB(e,pM[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var LZ=Kv;function ba(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,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(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=ba.id,ba.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}ba.prototype=new LZ,ba.constructor=ba,ba.id=0,ba.prototype.buildEl=function(e){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},ba.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=(()=>{let n=K3e("borderRadius");for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]="50%");return n})(),i=d7("transition","opacity",e),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)"},c7(r.el,i),this.options.shape==="circle"&&c7(r.back,t),c7(r.front,t),this.applyStyles(r),this},ba.prototype.applyStyles=function(e){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this},ba.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},ba.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},ba.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},ba.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t},ba.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t},ba.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",n={};n.front=d7("transition",["top","left"],r);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(n),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)},ba.prototype.restCallback=function(){var e=this,t={};t.front=d7("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)},ba.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},ba.prototype.computeDirection=function(e){var t,i,r,n=e.angle.radian,s=Math.PI/4,a=Math.PI/2;if(n>s&&n<3*s&&!e.lockX?t="up":n>-s&&n<=s&&!e.lockY?t="left":n>3*-s&&n<=-s&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(i=n>-a&&n<a?"left":"right"),e.lockX||(r=n>0?"up":"down"),e.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:t},e.direction=this.direction,l)l[o]===this.direction[o]&&(h[o]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+i,e),h.y||this.trigger("plain:"+r,e),h.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var p6e=ba;function qs(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=qs.id,qs.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(t),(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}qs.prototype=new LZ,qs.constructor=qs,qs.id=0,qs.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===i)return t[r];return!1}},qs.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"},qs.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}},qs.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,n={},s=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(e.x&&e.y)n={x:e.x-a,y:e.y-o};else if(e.top||e.right||e.bottom||e.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=e.top,l.style.right=e.right,l.style.bottom=e.bottom,l.style.left=e.left,l.style.position="absolute",s.zone.appendChild(l);var h=l.getBoundingClientRect();s.zone.removeChild(l),n=e,e={x:h.left+r.x,y:h.top+r.y}}var u=new p6e(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:e,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(u7(u.ui.el,n),u7(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},qs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},qs.prototype.bindNipple=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},qs.prototype.pressureFn=function(e,t,i){var r=this,n=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var s=e.force||e.pressure||e.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)},qs.prototype.onstart=function(e){var t=this,i=t.options,r=e;return e=Y3e(e),t.updateBox(),xX(e,function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(s){if(Object.values(r.touches).findIndex(function(o){return o.identifier===s})<0){var a=[e[0]];a.identifier=s,t.processOnEnd(a)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))}),t.manager.bindDocument(),!1},qs.prototype.processOnStart=function(e){var t,i=this,r=i.options,n=i.manager.getIdentifier(e),s=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=i.getOrCreate(n,a);o.identifier!==n&&i.manager.removeIdentifier(o.identifier),o.identifier=n;var l=function(h){h.trigger("start",h),i.trigger("start "+h.id+":start",h),h.show(),s>0&&i.pressureFn(e,h,h.identifier),i.processOnMove(e)};if((t=i.idles.indexOf(o))>=0&&i.idles.splice(t,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(eI(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(e);l(o)}return o},qs.prototype.getOrCreate=function(e,t){var i,r=this,n=r.options;return/(semi|static)/.test(n.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):n.mode==="semi"?r.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(t,e)},qs.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.scroll;if((_=>isNaN(_.buttons)?_.pressure!==0:_.buttons!==0)(e)){if(!n)return console.error("Found zombie joystick with ID "+r),void t.manager.removeIdentifier(r);if(i.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:s.x+a.left,y:s.y+a.top}}n.identifier=r;var o=n.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=n.position.y),i.lockY&&(l.x=n.position.x);var h,u,d=eI(l,n.position),c=((_,b)=>{let x=b.x-_.x,w=b.y-_.y;return(S=>S*(180/Math.PI))(Math.atan2(w,x))})(l,n.position),p=h7(c),f=d/o,m={distance:d,position:l};if(n.options.shape==="circle"?(h=Math.min(d,o),u=((_,b,x)=>{let w={x:0,y:0};return x=h7(x),w.x=_.x-b*Math.cos(x),w.y=_.y-b*Math.sin(x),w})(n.position,h,c)):(u=((_,b,x)=>({x:Math.min(Math.max(_.x,b.x-x),b.x+x),y:Math.min(Math.max(_.y,b.y-x),b.y+x)}))(l,n.position,o),h=eI(u,n.position)),i.follow){if(d>o){let _=l.x-u.x,b=l.y-u.y;n.position.x+=_,n.position.y+=b,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",d=eI(l,n.position)}}else l=u,d=h;var g=l.x-n.position.x,v=l.y-n.position.y;n.frontPosition={x:g,y:v},i.dataOnly||u7(n.ui.front,n.frontPosition);var y={identifier:n.identifier,position:l,force:f,pressure:e.force||e.pressure||e.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-v/o},raw:m,instance:n,lockX:i.lockX,lockY:i.lockY};(y=n.computeDirection(y)).angle={radian:h7(180-c),degree:180-c},n.trigger("move",y),t.trigger("move "+n.id+":move",y)}else this.processOnEnd(e)},qs.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(i.dataOnly||n.hide(function(){i.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(i.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[s.id]=s.identifier))},qs.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()},qs.prototype.destroy=function(){var e=this;for(var t in e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()}),e.pressureIntervals)Object.prototype.hasOwnProperty.call(e.pressureIntervals,t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off(),e.pressureIntervals={},e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.manager=null};var f6e=qs;function ia(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=eye(),t._windowBound=!1,t.config(e),t.prepareCollections();var i=function(){var r;t.collections.forEach(function(n){n.forEach(function(s){r=s.el.getBoundingClientRect(),s.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){(r=>{tI.has(r)&&clearTimeout(tI.get(r)),tI.set(r,setTimeout(function(){tI.delete(r),r()},100))})(i)},t._onScroll=function(){t.scroll=eye()},t.collections}ia.prototype=new LZ,ia.constructor=ia,ia.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return!(i=r.get(t))}),i}},ia.prototype.create=function(e){return this.createCollection(e)},ia.prototype.bindWindowEvents=function(){var e=this;e._windowBound||typeof window>"u"||(e._windowBound=!0,hB(window,"resize",e._onResize),hB(window,"scroll",e._onScroll))},ia.prototype.unbindWindowEvents=function(){var e=this;!e._windowBound||typeof window>"u"||(e._windowBound=!1,uB(window,"resize",e._onResize),uB(window,"scroll",e._onScroll))},ia.prototype.createCollection=function(e){var t=this,i=new f6e(t,e);return t.bindCollection(i),t.collections.push(i),t.bindWindowEvents(),i},ia.prototype.bindCollection=function(e){var t,i=this,r=function(n,s){t=n.type+" "+s.id+":"+n.type,i.trigger(t,s)};e.on("destroyed",i.onDestroyed.bind(i)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},ia.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)},ia.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)},ia.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier)===void 0&&(t=this.latest||0):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},ia.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t},ia.prototype.onmove=function(e){return this.onAny("move",e),!1},ia.prototype.onend=function(e){return this.onAny("end",e),!1},ia.prototype.oncancel=function(e){return this.onAny("end",e),!1},ia.prototype.onAny=function(e,t){var i,r=this,n="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=Y3e(t);var s=function(a,o,l){l.ids.indexOf(o)>=0&&(l[n](a),a._found_=!0)};return xX(t,function(a){i=r.getIdentifier(a),xX(r.collections,s.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},ia.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.unbindWindowEvents(),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.collections=[],e.off()},ia.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1),i.collections.length===0&&i.unbindWindowEvents()};var m6e=ia,Kx=null;function iye(){return Kx||(Kx=new m6e),Kx}var g6e={create:function(e){return iye().create(e)},destroy:function(){Kx&&(Kx.destroy(),Kx=null)},get factory(){return iye()}},v6e=g6e;Vr(),Ot(),ne(),Nh(),Pw(),wu(),bl(),Ot();var ePe=null;function p7(){return ePe}var tPe,f7,y6e=new Promise(e=>{tPe=e});function _6e(e){return f7||(f7=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.205/build",i=import("./physics.js"),[r,n]=await Promise.all([i,fetch(`${t}/physics.wasm`).then(s=>s.arrayBuffer())]);await r.init(n),tPe(r)}(),f7)}function iPe(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||n<l||s<l||a<l||o<l}function lf(e,t){let i=new Mt;if(t&&iPe(t))return i.setAttribute("position",new Tt([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new Tt([],3)),i.setIndex([]),i;let{positions:r,triIndices:n}=lK(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Tt(r,3)),i.setIndex(n),t&&i.applyMatrix4(t),i}Yn(),bl(),vr(),EK(),ne(),ne(),Dw(),uC();var Mr,b6e=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target}disconnect(){Xa(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>t.play()),this.actions.Animation.forEach(t=>{"runMode"in t.data&&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.Reset.forEach(t=>{t.dispatch()}),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(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},rye=class{constructor(e,t,i,r,n,s){this.id=e,this.data=t,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=ha(t,t.actions,r,n,s,i),this.target=t.target,this.triggeringObjects=[];for(let a of t.triggeringObjects){let o=r.scene.findFrom(a,i);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(e){return this.target==="all"||this.triggeringObjects.some(t=>t===e||t.isAncestorOf(e.uuid)||e.isAncestorOf(t.uuid))}disconnect(){Xa(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>{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.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SceneTransition.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()))}};Yn(),hC(),AB(),y6e.then(e=>Mr=e);var ta=new P,su=new Vt,m7=new P,x6e=new P(1,1,1),g7=(new Rr(0,0,0,"YXZ"),new Rr(0,0,0,"XYZ")),zp=new P,nye=new P,fM=new Vt,iI=new De,sye=new De,w6e={type:"updateMatrix"},v7=(new Vt,new ja),y7=.01,wX={type:"beginEvent",eventName:"Collision"},S6e={type:"beginEvent",eventName:"Trigger"},dB=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.shear!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);function fb(e){return function(t){return typeof t=="object"&&t!==null&&"booleanOp"in t}(Bg(e)?e.object:e)}var T6e=class{constructor(e){this.eventContext=e,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=t=>{if(t.bodyType()!==Mr.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[i,r]=this.rigidBodyToMesh.get(t.handle);if(ta.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),su.copy(t.rotation()),i.matrixWorld.makeRotationFromQuaternion(su).setPosition(ta),i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(w6e),r){let n=i.cloner;if(n&&n.objectForSample===void 0){n.matrixWorld.copy(i.matrixWorld);for(let s of n.children)s.updateMatrixWorld(!0)}for(let s of i.children)s.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,i,r)=>{if(r===!1)return;let n,s;if(this.sensorToTriggerEvent[t]?(n=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(n=this.sensorToTriggerEvent[i],s=this.sharedGameControlGlobals.colliderToEntity.get(t)),n&&s&&n.isValidTriggeringObject(s))n.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===t||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(t)){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(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,t)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(t),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let u of o)u.data.target==="scene"&&this.dispatchCollisionEvent(u,a,t);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=e.isExport,this.sharedAssets=e.sharedAssets,this.renderer=e.renderer,this.requestRender=e.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(e=>{let t=e.dataPatched;for(let i of t.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(n=>n.data.type==="Destroy")?.data;if(r)for(let n of r.objects){let s=this.page.scene.find(n);s&&(s.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let i of t.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let n=this.page.scene.find(r);n&&(n.userData.hasDrag=!0)}})}_staticBVHIdOf(e){let t=this._staticBVHAttrIds.get(e);return t===void 0&&(t=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(e,t)),t}initBVH(){if(p7()===null)return void Ta("collision-bvh","trigger/collision detection");let e=[],t=[];if(this.page.traverseChildren(i=>{let r,n=i instanceof Ux,s=jE(i);if(Lg(i)||n||s)return;r=Bg(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(dB(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){e.push({geometry:o,matrixWorld:i.matrixWorld}),t.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)t.push(d)}}return!!fb(i)||void 0}),e.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===t.length&&i.signature.every((s,a)=>s===t[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=ly(e.map(s=>lf(s.geometry,s.matrixWorld)),!1),n=new(p7())(r);this._staticBVHCache={signature:t,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(e,t,i){if(iPe(e.matrixWorld))return;let r=[],n="geometry"in e?e.geometry:void 0,s=t.dataPatched;if(n?.getAttribute("position")!==void 0&&r.push(lf(n,e.shearScale)),s.physics.fusedBody){let a=this.gatherChildrenGeom(e,r);e.traverseObject(a),e.children.forEach(l=>l.updateMatrixWorld(!0));let o=e.cloner;o&&o.objectForSample===void 0&&s.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&s.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=Mr.RigidBodyDesc.dynamic(),a.setLinearDamping(s.physics.damping).setAngularDamping(s.physics.damping).setAdditionalMass(1e-9).setGravityScale(s.physics.gravityScale).enabledRotations(...s.physics.enabledRotation).enabledTranslations(...s.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=Mr.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Mr.RigidBodyDesc.fixed();let h=ly(r);ta.setFromMatrixPosition(e.matrixWorld),su.setFromRotationMatrix(e.matrixWorldRigid),e.position0=ta.clone().divideScalar(this.pixelsPerMeter),e.rotation0=su.clone(),ta.divideScalar(this.pixelsPerMeter),a.setTranslation(ta.x,ta.y,ta.z).setRotation(su),h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let u=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(s.geometry===void 0||s.geometry.type==="SubdivGeometry"||s.geometry.type==="NonParametricGeometry"||s.geometry.type==="BooleanGeometry"||s.geometry.type==="VectorGeometry"||s.geometry.type==="StarGeometry"||s.geometry.type==="RectangleGeometry"||s.geometry.type==="EllipseGeometry"||s.geometry.type==="TriangleGeometry"||s.geometry.type==="TorusGeometry"||s.geometry.type==="HelixGeometry");try{this.addCollider(u,s.physics,h,t,d)}catch{try{this.addCollider(u,s.physics,h,t,!1)}catch(c){console.error(c)}}if(u.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(u);l?this.rigidBodyToMesh.set(u.handle,[e,s.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e)):this.fixedBodiesToWatch.push([e,u,(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).clone()]),e.rigidBody=u}}addBoundsTree(e){let t=[];if(e.geometry?.getAttribute("position")!==void 0&&e.geometry?.getAttribute("position").count>0&&t.push(lf(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,t)),e.children.forEach(i=>i.updateMatrixWorld(!0)),t.length>0){let i=ly(t,!1);e.bvhGeometry=i,i.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(p7())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(e,t,i,r,n=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let s;i&&(s=t.colliderType==="trimesh"?Mr.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Mr.ColliderDesc.convexMesh(i.getAttribute("position").array,n?i.getIndex().array:void 0)),s.setFrictionCombineRule(Mr.CoefficientCombineRule.Average).setRestitutionCombineRule(Mr.CoefficientCombineRule.Average).setDensity(t.density).setFriction(t.friction).setRestitution(t.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(s,e);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(Mr.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){let i=fb(e);return(r,n)=>{if(n===0)return;if(i&&r.parent===e)return!0;let s;if(Lg(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;s=r.object}else if(Bg(r))s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;n===1?r.matrixWorld.copy(e.shearScale):r.matrixWorld.copy(r.parent.matrixWorld),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&t.push(lf(o,r.matrixWorld)),!!fb(r)||void 0}}activate(e){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=e,this.usePhysics=this.page.data.globalPhysics.usePhysics;let t=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=Jve();if(r!==null?i=r.setup({manager:this,camera:t,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Ta("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 I3e(t,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 n=this.renderer.domElement.width/this.renderer.getPixelRatio(),s=this.renderer.domElement.height/this.renderer.getPixelRatio();Jve()?.createJoysticks(this,n,s),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 Mr.World(new Mr.Vector3(0,this.gravity,0)),this.events=new Mr.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(a=>{let o;if(Lg(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(Bg(a))o=a.object;else{if(jE(a)||l1(a)||a instanceof Ux)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=dB(h),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of h.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let v=new b6e(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.initialDisabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;a.traverseVisible(y=>{y.userData.isFollowingObj=v})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let m=a.geometry;if(l!==void 0){let g=Mr.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(ta,su,m7),a.position0=ta.clone().divideScalar(this.pixelsPerMeter),a.rotation0=su.clone(),ta.divideScalar(this.pixelsPerMeter),g.setTranslation(ta.x,ta.y,ta.z).setRotation(su);let v,y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=y,v=l.collider.type==="sphere"?Mr.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Mr.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Mr.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),v.setFrictionCombineRule(Mr.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(0).setRestitutionCombineRule(Mr.CoefficientCombineRule.Min);let _=this.sharedGameControlGlobals.rapierWorld.createCollider(v,y);this.sharedGameControlGlobals.colliderToEntity.set(_.handle,o),ta.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(m7.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),_.setTranslationWrtParent(ta);let b=new Vt().setFromEuler(new Rr().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));_.setRotationWrtParent(b),_.setActiveEvents(Mr.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else h.physics.rigidBody==="dynamic"||u||f||c||p||d?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,h.physics.fusedBody)):(m&&e.push(lf(m,a.matrixWorld)),h.physics.fusedBody&&!fb(a)&&a.traverseObject((g,v)=>{if(v===0)return;let y;if(Lg(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;y=g.object}else{if(jE(g)||l1(g)||g instanceof Ux)return;if(Bg(g))y=g.object;else if(y=g,y.dataPatched.cloner?.hideBase)return!0}let _=y.dataPatched;if(_.physics.enabled==="visibility"?!_.visible:!_.physics.enabled)return!0;let b=g.geometry;return b?.getAttribute("position")!==void 0&&e.push(lf(b,g.matrixWorld)),!!fb(g)||void 0}),this.generateSensorColliderDescs(o,h.physics.fusedBody,t));return!(h.physics?.fusedBody!==!0&&!l&&!fb(a))||void 0}),e.length===0)return;let i=ly(e),r=i.getIndex().count>0;if(!r&&t.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=Mr.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);if(r){let a=Mr.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Mr.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Mr.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s)}for(let[a,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);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(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new rye(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new De().compose(zp.fromArray(t.data.position.map(n=>typeof n=="number"?n:0)),fM.setFromEuler(g7.fromArray(t.data.rotation.map(n=>typeof n=="number"?n:0))),x6e);if(t.data.triggerZone==="box"){let n=new cn;n.min.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),n.max.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([n,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.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(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e){if(!this.isEnabled)return!0;let t=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),t=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,t=!1):this.initializationCounter===2&&this.gameControl&&(t=!this.gameControl.update(e)&&t),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(e===0)t=this.stepPhysics()&&t;else{let r=e/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let n=performance.now(),s=0,a=6;for(;this.accumulator>=i&&s<a&&(t=this.stepPhysics()&&t,this.accumulator-=i,s++,!(performance.now()-n>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=t}recordPhysicsPose(e){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ta,su,m7);let t=e;t.prevQ===void 0?(t.prevQ=su.clone(),t.prevT=ta.clone()):(t.prevQ.copy(su),t.prevT.copy(ta))}promoteMovedFixedBodies(){for(let e=this.fixedBodiesToWatch.length-1;e>=0;e--){let[t,i,r]=this.fixedBodiesToWatch[e];t.rigidBody===i?(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).equals(r)||(i.setBodyType(Mr.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),this.fixedBodiesToWatch.splice(e,1)):this.fixedBodiesToWatch.splice(e,1)}}clampPushedBodies(){let e=this.gameControl?.object.rigidBody;if(e===void 0)return;let t=this.sharedGameControlGlobals.rapierWorld,i=e.linvel(),r=e.translation(),n=Math.hypot(i.x,i.z);for(let s=0;s<e.numColliders();s++){let a=e.collider(s);t.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(t.contactPair(a,o,v=>{let y=v.normal(),_=y.x*(h.x-r.x)+y.y*(h.y-r.y)+y.z*(h.z-r.z)<0?-1:1;if(Math.abs(y.y)>.7)return;let b=_*y.x,x=_*y.z,w=Math.hypot(b,x);if(w<1e-4)return;let S=(i.x*b+i.z*x)/w;S>u&&(u=S,d=b/w,c=x/w)}),u===-1/0)return;let p=i.x*d+i.z*c;if(p<-y7)return;let f=l.linvel();if(n>y7&&p>y7){let v=f.x*d+f.z*c;if(v<=0)return;let y=Math.min(v,p);return void l.setLinvel({x:d*y,y:f.y,z:c*y},!0)}let m=f.x*d+f.z*c-Math.max(0,p);if(m<=0)return;let g=.5*m;l.setLinvel({x:f.x-d*g,y:f.y,z:f.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let e=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[t,i]of e)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(ta.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(su)):e.delete(t);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)t.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r,n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(t.cloner){for(let s of t.cloner.children)if(s.rigidBody===n){r=s;break}}e.dispatch(r),t.dispatchEvent(wX)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=sye.copy(e.matrixWorld).invert();e.traverseEntity((n,s)=>{if(t===!1&&s===1)return!0;for(let a of n.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new rye(a.id,a.data,n,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Mr.ColliderDesc.cuboid(...a.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):Mr.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Mr.ActiveEvents.COLLISION_EVENTS),zp.fromArray(a.data.position.map(h=>typeof h=="number"?h:0)),fM.setFromEuler(g7.fromArray(a.data.rotation.map(h=>typeof h=="number"?h:0))),iI.makeRotationFromEuler(g7).setPosition(zp).premultiply(n.matrixWorld),i?(Mf(iI,{translation:zp,quaternion:fM,scale:nye}),o.setActiveCollisionTypes(Mr.ActiveCollisionTypes.KINEMATIC_FIXED|Mr.ActiveCollisionTypes.DYNAMIC_FIXED)):(Mf(iI.premultiply(r),{translation:zp,quaternion:fM,scale:nye}),e.rigidBody.bodyType()===Mr.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===Mr.RigidBodyType.Fixed?o.setActiveCollisionTypes(Mr.ActiveCollisionTypes.KINEMATIC_FIXED|Mr.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Mr.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Mr.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),zp.divideScalar(this.pixelsPerMeter),o.setTranslation(zp.x,zp.y,zp.z),o.setRotation(fM),i)i.push([o,l]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,e.rigidBody);this.sensorToTriggerEvent[h.handle]=l}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,n,s]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(n===o||s.isValidTriggeringObject(tr.is(o)?o:o.object)===!1)continue;let l=sye.copy($be(n.matrixWorld)).copyPosition(n.matrixWorld).multiply(r),h=iI.copy(o.matrixWorld).invert().multiply(l),u=o.bvhGeometry.boundsTree;i instanceof cn?e=u.intersectsBox(i,h):(v7.radius=i,v7.center.setFromMatrixPosition(h),e=u.intersectsSphere(v7)),e?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),n.dispatchEvent(S6e)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(d=>d!==o)}}}};Iw(),ne(),l4(),Ir(),hC(),Qf();var _7=.02,aye=new P,oye=new P,M6e=new P,zo=new P,kp=new P,mb=new P,b7=new De,lye=new De,E6e=new De,mh=new Vt,Iv=new Vt,gb=new Rr(0,0,0,"YXZ"),A6e=new P(1,0,0),dc=new P(0,1,0),C6e=new P(0,0,1),hye=new P(1,1,1),uye=[],dye=e=>uye[e]??(uye[e]=new P),x7=new P,P6e=new P,R6e=new P,D6e=new P,cye=new Vt,N6e=new P,pye=new Vt,Ua=new Eh,au=new cn,I6e={type:"requestRender"},O6e={type:"updateMatrix"},SX=class extends ds{constructor(e,t,i,r,n,s,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=n,this.cameraFollow=s,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 Rr(0,0,0,"YXZ"),this.shearMatrix0=new De,this.cameraShearMatrix0=new De,this.position0Cam=new P,this.quat0Cam=new Vt,this.scale0Cam=new P,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Eh(new P(0,-40,0),new P(0,40,0)),matrix:new De,position:new P,rotation:new Vt},this.euler=new Rr(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Vt,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 De,this.nonColliderPosOffset=new De,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 De,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 Vt,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 Vt,this.objXZQuatInv=new Vt,this.objXZRotMat=new De,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Vt,this.colliderWorldQuat=new Vt,this.groundNormal=new P,this.groundTilt=new Vt,this.groundTiltInv=new Vt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Vt,this.scale=new P,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Kl&&!IW&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(IW&&J_e<15.5&&!Kl?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?SX.isLocked=!0:SX.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=v:this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=n.sharedGameControlGlobals,e===a&&(this.isFirstPerson=!0),this.object.parent instanceof Dn||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),this.shearMatrix0.copy(this.object.shearMatrix),Mf(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 Dn||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),this.cameraShearMatrix0.copy(this.camera.shearMatrix),Mf(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 f,m=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(m.y)<1e-6?(g.y=0,m.y=0,f=g.projectOnVector(m)):f=g.y/m.y>0?m.multiplyScalar(g.y/m.y):m.multiplyScalar(g.length()),this.targetToCamera0.copy(f).negate();let v=this.camera.position.clone().add(f);this.objectToTarget0.subVectors(v,this.position);let y=new Rr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Kn&&(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(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][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??Nx.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??Nx.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??i4.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*_7/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*_7/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*_7/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(f=>typeof f=="number"?f:0)),c=new Vt().setFromEuler(new Rr().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,hye),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 f=new Et;f.push({fi:0,data:{...ts.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...ts.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=oSe({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Sr(JY.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.matrixWorldAutoUpdate=!0,this.camera.matrixWorldAutoUpdate=!0,this.object.shearMatrix.copy(this.shearMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent instanceof Dn||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),Mf(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix});let t=new Rr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Kn?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),e?(this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.camera.parent instanceof Dn||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),Mf(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 e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},t4.list.forEach(i=>{this.actions[i]=ha({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,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"),Xa(this.actions.idle),Xa(this.actions.move),Xa(this.actions.run),Xa(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(t=>{t.play()}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(t=>{t.stop()}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return zo.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){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 t=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*t,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=kp.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*t,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,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(zo).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*t}}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 s=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=zo.subVectors(this.path[1],this.position),o=kp.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.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 n=M6e.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=kp.copy(n);s.y=0,n.set(0,n.y,s.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 s=zo;this.camera.getWorldDirection(s);let a=mb.copy(dc).multiplyScalar(s.dot(dc));s.sub(a);let o=kp.copy(this.directionXZ);o.x*=-1,this.rot.y=s.angleTo(o)*(s.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(gb.setFromVector3(this.rot),this.moveMode==="walk"&&(gb.x=0),n.applyEuler(gb),r&&(Iv.setFromUnitVectors(dc,this.groundNormal),n.applyQuaternion(Iv)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=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(x7,cye,P6e);let o=this.object.getWorldPosition(R6e).add(this.collider.position).sub(x7);pye.copy(a.prevQ).invert().premultiply(cye);let l=mb.subVectors(x7,a.prevT).add(D6e.copy(o).applyQuaternion(pye).sub(o)).divideScalar(t).divideScalar(this.pixelsPerMeter),h=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),zo.copy(n).divideScalar(this.pixelsPerMeter),0,t,!1);l.multiplyScalar(this.pixelsPerMeter);let u=tr.is(a)?a:a.object;if(h!==null&&this.lastHitObj!==u){let d;a instanceof Ko&&(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(wX));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),dye(s++).copy(h.normal1).applyQuaternion(a.quaternion))}if(s>0){for(let a=0;a<s;a++){let o=dye(a),l=o.dot(n);l<0&&n.addScaledVector(o,-l)}n.add(this.pushedVelocity)}else n.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(t),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*t,this.euler.y+=this.rotVelocity.y*t+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*t),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(dc,this.euler.y-this.euler0.y);let s=kp.copy(this.objectToCamXZ).normalize(),a=mb.copy(n).multiplyScalar(t);a.y=0;let o=a.sub(zo.copy(s).multiplyScalar(a.dot(s))).cross(s).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*t+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=Qe.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Qe.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Qe.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(gb.copy(this.euler),gb.y=0,this.nonColliderRotOffset.makeRotationFromEuler(gb)),mh.setFromAxisAngle(A6e,this.rot.x),Iv.setFromAxisAngle(dc,this.rot.y),Iv.multiply(mh),mh.setFromAxisAngle(C6e,this.rot.z),Iv.multiply(mh),this.quaternion.copy(Iv),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 s=kp.copy(n).multiplyScalar(t/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let u=0;u<5;u++){let d=s.length(),c=mb.copy(s).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(s);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.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}}y.dispatch(_),p.dispatchEvent(wX)}}}let f=aye.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),m=oye.copy(c).multiplyScalar(a.time_of_impact).dot(f),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=a.time_of_impact*(m-this.offset)/m,o.addScaledVector(c,g)),s.copy(c).multiplyScalar(d-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),y=mb.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let _=v.add(y);_.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(_,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);b!==null&&b.time_of_impact===0&&(f.y=0,f.normalize())}s.addScaledVector(f,-s.dot(f))}}this.position.addScaledVector(o,this.pixelsPerMeter),zo.copy(this.position).divideScalar(this.pixelsPerMeter),mh.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,h=l!==void 0&&N6e.copy(zo).sub(l.translation()).lengthSq()>1;l!==void 0&&(h?(l.setTranslation(zo,!0),l.setRotation(mh,!0)):(l.setNextKinematicTranslation(zo),l.setNextKinematicRotation(mh)))}else{let s=this.onObject?1:5,a=n.multiplyScalar(t/s);for(let o=0;o<s;o++)this.position.add(a),this.collisionAdjustment(t/s)}else this.position.addScaledVector(n,t);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),Oxe(this.position,this.quaternion,this.object.shearMatrix,this.scale,this.object.matrix).multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.parent instanceof Dn?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(s=>{s.updateMatrixWorld(!0)}),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),a=this.targetToCamera.add(s);b7.lookAt(a,s,dc).setPosition(a),b7.decompose(this.targetPos,this.targetQuat,zo),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=Qe.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Qe.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(O6e),!(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(I6e),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e,t=mh.setFromAxisAngle(dc,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Qe.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(t),e=this.cameraXAxis==="Limit"?Qe.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):Qe.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=zo.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let r=Iv.setFromAxisAngle(i,e);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){180*dc.angleTo(e)/Math.PI<15||180*dc.angleTo(e)/Math.PI>85?mh.identity():mh.setFromUnitVectors(dc,e),this.groundTilt.slerp(mh,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=oye.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=b7.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(zo,mh,kp).compose(zo,mh,hye);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(n=>{if(n===this.object||n.isDescendantOf(this.object)||!n.bvhGeometry||!n.bvhGeometry.boundsTree)return;au.makeEmpty(),n.updateMatrixWorldRigid();let s=n.matrixWorldRigid,a=lye.copy(s).invert(),o=E6e.copy(lye).multiply(i);Ua.copy(this.collider.segment),Ua.start.applyMatrix4(o),Ua.end.applyMatrix4(o);let l=aye.copy(this.position).applyMatrix4(a);au.expandByPoint(Ua.start),au.expandByPoint(Ua.end),au.min.addScalar(-this.collider.radius),au.max.addScalar(this.collider.radius),n.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:h=>h.distanceToPoint(Ua.end),intersectsBounds:h=>h.intersectsBox(au),intersectsTriangle:h=>{let u=zo,d=kp,c=h.closestPointToSegment(Ua,u,d);if(c<this.collider.radius){let p=this.collider.radius-c,f=d.sub(u).normalize(),m=mb.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),Ua.start.addScaledVector(f,p),Ua.end.addScaledVector(f,p)}}})}),au.makeEmpty(),Ua.copy(this.collider.segment),Ua.start.applyMatrix4(i),Ua.end.applyMatrix4(i),au.expandByPoint(Ua.start),au.expandByPoint(Ua.end),au.min.addScalar(-this.collider.radius),au.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:n=>n.distanceToPoint(Ua.end),intersectsBounds:n=>n.intersectsBox(au),intersectsTriangle:n=>{let s=zo,a=kp,o=n.closestPointToSegment(Ua,s,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),Ua.start.addScaledVector(h,l),Ua.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}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()}},rPe=SX;rPe.isLocked=!1,ne(),uC(),XB(),Iw(),Dw();var nPe,sPe,w7,L6e=new Promise(e=>{nPe=e});function B6e(e){return w7||(w7=async function(){let t=e??"https://cdn.spline.design/@splinetool/runtime@2.0.205/build";typeof window<"u"&&(sPe=new URL(t.endsWith("/")?t:`${t}/`,window.location.href).href);let i=import("./navmesh.js"),[r,n]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=r.default,a=await s({wasmBinary:n});nPe(a)}(),w7)}Vr();var aPe,pr,ho,F6e=e=>`
|
|
12961
12961
|
(async function() {
|
|
12962
12962
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
12963
12963
|
import('${e}' + 'navmesh.js'),
|
|
@@ -12967,7 +12967,7 @@ void main() {
|
|
|
12967
12967
|
self.module = await wasmModule({ wasmBinary });
|
|
12968
12968
|
postMessage('ready');
|
|
12969
12969
|
})();
|
|
12970
|
-
`,U6e={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};L6e.then(e=>{aPe=e,pr=new e.Vec3,ho=new e.Vec3});var z6e=new P,k6e=class{constructor(e=!1,t=!1){this.usePhysics=e,this.isExport=t,this.onPointerDown=i=>{if(mi.length!==1)return;let{raycaster:r,page:n}=this.eventContext;this.eventContext.updateRaycaster(i);let s=n.raycastWithClones(r);if(s.length!==0){if(this.gameControl){let a=z6e.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,s[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>n=>{let s;if(n instanceof qf){if(!n.objectForSample)return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(n.objectForSample.dataPatched.physics.fusedBody)return;s=n.object}else if(n instanceof Ko)s=n.object;else if(s=n,s.dataPatched.cloner?.disabled===!1&&s.dataPatched.cloner?.hideBase&&s.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!s.userData.navmesh)return;let a=s.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;n.updateMatrixWorldRigid();let o=dB(a),l=s.userData.hasDestroy,h=s.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 n&&n.geometry&&i.push(lf(n.geometry,n.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return n.traverseObject((c,p)=>{if(p===0)return;let f;if(c instanceof qf){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;f=c.object}else if(c instanceof Ko)f=c.object;else if(f=c,c.dataPatched.cloner?.hideBase)return!0;let m=f.dataPatched;if(!m.visible&&m.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(lf(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>n=>{let s;if(n instanceof qf)return;s=n instanceof Ko?n.object:n;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!s.userData.navmesh)return;let o=n.geometry,l=s.userData.hasDestroy===!0,h=s.userData.hasDrag===!0;if(dB(a)||l||h||s.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&i.push(lf(o,n.matrixWorld))},this.navmeshWasm=aPe,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(t?F6e(sPe??"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
12970
|
+
`,U6e={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};L6e.then(e=>{aPe=e,pr=new e.Vec3,ho=new e.Vec3});var z6e=new P,k6e=class{constructor(e=!1,t=!1){this.usePhysics=e,this.isExport=t,this.onPointerDown=i=>{if(mi.length!==1)return;let{raycaster:r,page:n}=this.eventContext;this.eventContext.updateRaycaster(i);let s=n.raycastWithClones(r);if(s.length!==0){if(this.gameControl){let a=z6e.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,s[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>n=>{let s;if(n instanceof qf){if(!n.objectForSample)return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(n.objectForSample.dataPatched.physics.fusedBody)return;s=n.object}else if(n instanceof Ko)s=n.object;else if(s=n,s.dataPatched.cloner?.disabled===!1&&s.dataPatched.cloner?.hideBase&&s.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!s.userData.navmesh)return;let a=s.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;n.updateMatrixWorldRigid();let o=dB(a),l=s.userData.hasDestroy,h=s.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 n&&n.geometry&&i.push(lf(n.geometry,n.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return n.traverseObject((c,p)=>{if(p===0)return;let f;if(c instanceof qf){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;f=c.object}else if(c instanceof Ko)f=c.object;else if(f=c,c.dataPatched.cloner?.hideBase)return!0;let m=f.dataPatched;if(!m.visible&&m.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(lf(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>n=>{let s;if(n instanceof qf)return;s=n instanceof Ko?n.object:n;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!s.userData.navmesh)return;let o=n.geometry,l=s.userData.hasDestroy===!0,h=s.userData.hasDrag===!0;if(dB(a)||l||h||s.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&i.push(lf(o,n.matrixWorld))},this.navmeshWasm=aPe,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(t?F6e(sPe??"https://cdn.spline.design/@splinetool/runtime@2.0.205/build/"):`
|
|
12971
12971
|
(async function() {
|
|
12972
12972
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
12973
12973
|
import(self.location.origin + '/_libraries/navmesh.js'),
|
|
@@ -13042,7 +13042,7 @@ onmessage = function(messageEvent) {
|
|
|
13042
13042
|
[${nL}] { pointer-events: none; }
|
|
13043
13043
|
[${nL}] > * { pointer-events: auto; }
|
|
13044
13044
|
[${nL}] [data-spline-passthrough] { pointer-events: none; }
|
|
13045
|
-
`,RPe=class{constructor(e,t,i,r,n,s){this.container=e,this.host=t,this.observer=i,this.spline=r,this.previousSplineGlobal=n,this.removeLateLifecycleShim=s}static mount(e,t,i,r){if(typeof document>"u")return null;let n=t.parentElement;if(!n)return null;getComputedStyle(n).position==="static"&&(n.style.position="relative");let s=document.createElement("div");s.setAttribute(nL,"");let a=s.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${t.offsetLeft}px`,a.top=`${t.offsetTop}px`,a.width=`${t.offsetWidth}px`,a.height=`${t.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(t),l.observe(n);let h=document.createElement("style");h.textContent=dje,s.appendChild(h);let u=new DOMParser().parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let y of d)y.remove();for(let y of Array.from(u.head.children))(y.tagName==="STYLE"||y.tagName==="LINK"&&y.rel==="stylesheet")&&s.appendChild(y);for(;u.body.firstChild;)s.appendChild(u.body.firstChild);n.insertBefore(s,t.nextSibling),s.addEventListener("wheel",y=>{y.ctrlKey&&!y.defaultPrevented&&!t.dispatchEvent(new WheelEvent("wheel",y))&&y.preventDefault()},{passive:!1});let c=new Map,p=new gY(CPe(e,t,r),(y,_)=>{y==="warn"?console.warn(`[spline html] ${_}`):y==="error"&&console.error(`[spline html] ${_}`)},(y,_)=>{let b=c.get(y);if(b)for(let x of b)try{x(_)}catch(w){console.error(w)}}),f=(y,_)=>{try{return Promise.resolve(p.execute(y,_))}catch(b){return Promise.reject(b)}},m={ready:Promise.resolve(),setVariable:(y,_)=>f("setVariable",[y,_]),setVariables:y=>f("setVariables",[y]),getVariable:y=>f("getVariable",[y]),getVariables:()=>f("getVariables",[]),getAllObjects:()=>f("getAllObjects",[]),findObjectByName:y=>f("findObjectByName",[y]),findObjectById:y=>f("findObjectById",[y]),getGeometry:(y,_)=>f("getGeometry",[y,_??{}]),updateObject:(y,_)=>f("updateObject",[y,_]),createObject:(y,_)=>f("createObject",[y,_??{}]),createCustomMaterial:y=>f("createCustomMaterial",[y]),getTexture:(y,_)=>f("getTexture",[y,_??{}]),setMaterial:(y,_)=>f("setMaterial",[y,_]),cloneObject:(y,_)=>f("cloneObject",[y,_??{}]),removeObject:y=>f("removeObject",[y]),spawnObject:(y,_)=>f("spawnObject",[y,_??{}]),destroyObject:y=>f("destroyObject",[y]),setInstanceTransforms:(y,_)=>f("setInstanceTransforms",[y,_??null]),getAnimations:y=>f("getAnimations",[y]),playAnimation:(y,_,b)=>f("playAnimation",[y,_,b]),pauseAnimation:(y,_)=>f("pauseAnimation",[y,_]),stopAnimation:(y,_)=>f("stopAnimation",[y,_]),emitEvent:(y,_)=>f("emitEvent",[y,_]),emitEventReverse:(y,_)=>f("emitEventReverse",[y,_]),requestRender:()=>f("requestRender",[]),addEventListener:(y,_)=>{if(typeof _!="function")return;let b=c.get(y);b||(b=new Set,c.set(y,b),f("listenEvent",[y])),b.add(_)},removeEventListener:(y,_)=>{let b=c.get(y);!b||(b.delete(_),b.size===0&&(c.delete(y),f("unlistenEvent",[y])))}},g=window.spline;window.spline=m;let v=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let y=[],_=(x,w)=>{let S=new Set,T=x.addEventListener.bind(x),M=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(E,A,C)=>{if(T(E,A,C),!w.includes(E)||A==null)return;let D={type:E,listener:A};S.add(D),queueMicrotask(()=>{!S.delete(D)||((R,I,U)=>{let O=new Event(U);try{typeof I=="function"?I.call(R,O):I.handleEvent?.(O)}catch(k){console.error(k)}})(x,D.listener,D.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(E,A,C)=>{M(E,A,C);for(let D of S)D.type===E&&D.listener===A&&S.delete(D)}}),y.push(()=>{delete x.addEventListener,delete x.removeEventListener,S.clear()})};_(document,["DOMContentLoaded"]),_(window,["load"]);let b=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(w){console.error(w)}})}}),y.push(()=>{b?Object.defineProperty(window,"onload",b):delete window.onload}),()=>{for(let x of y)x()}}();for(let y of d){let _=document.createElement("script");for(let b of Array.from(y.attributes))_.setAttribute(b.name,b.value);y.src?_.async=!1:_.textContent=y.textContent,s.appendChild(_)}return new RPe(s,p,l,m,g,v)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function DPe(e){return typeof e=="object"&&e!==null&&e.isMaterial===!0}function b1e(e){if(typeof e.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(!DPe(e.material))return{options:e};let t=e.material;if(t.isNodeMaterial===!0){let i=KH()?.NodeMaterial;if(i!==void 0&&t instanceof i)return{options:{...e,material:void 0},material:t};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(t.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:{...e,material:void 0},material:t}}Ot(),Ir(),ne(),rSe(),xu(),Ir(),Ot(),SBe(),Qf();var cje=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),x1e="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",pje={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"},fje={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},mje={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')."},gje={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"},vje={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function sC(e,t){return e===void 0?[t[0],t[1],t[2]]:Array.isArray(e)?[e[0]??t[0],e[1]??t[1],e[2]??t[2]]:[e.x??t[0],e.y??t[1],e.z??t[2]]}function NPe(e){return typeof e=="number"?[e,e,e]:sC(e,[1,1,1])}function WX(e){let t=new Ur(0,0,0,1);return t.setStyle(e),{r:t.r,g:t.g,b:t.b}}function w1e(e,t){let i=e.material??(e.color!==void 0?{color:e.color}:void 0);if(i===void 0)return Un.defaultColorMaterial(S1e(Za),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(t.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)||at.NAMES[o]!==void 0}(i))return Un.defaultColorMaterial(WX(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)"}(t)}) 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(DPe(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?WX(i.color):S1e(Za),n=Un.defaultColorMaterial(r,"physical","layer1","layer2"),s=n.layers.find(a=>a.data.type==="light");if(s){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(s.data,a)}if(i.alpha!==void 0){let a=n.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return n}function S1e(e){return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}}function yje(e){let t=cf.defaultData("TextGeometry"),{text:i,...r}=e,n=r.fontSize;return n!==void 0&&r.width===void 0&&(r.width=350*n/16),n!==void 0&&r.height===void 0&&(r.height=50*n/16),Object.assign(t,r),i!==void 0&&Object.assign(t,{text:{textValue:String(i)}}),t}function II(e){return Array.isArray(e)?e:!ArrayBuffer.isView(e)||e instanceof DataView?null:Array.from(e)}function _je(e,t){return Pxe({userData:{type:e,...$H[e].normalizeInputs({parameters:t})}})}function bje(e,t,i){let{objectType:r,geometryType:n}=e,s=function(l){let h={};for(let[u,d]of Object.entries(l))!cje.has(u)&&d!==void 0&&(h[u]=d);return h}(t),a={states:new Et,events:new Et};if(r==="Mesh"&&n){if(n==="NonParametricGeometry"){let{geometry:l,doubleSide:h}=function(u){let d=II(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=II(u.indices);if(p&&p.length){let _=p.find(b=>!Number.isInteger(b)||b<0||b>=c);if(_!==void 0)throw new Error(`createObject('CustomMesh'): index ${_} is out of range (mesh has ${c} vertices).`)}else p=null;let f=new Mt;f.setAttribute("position",new Tt(d,3));let m=II(u.normals),g=m!==null&&m.length===d.length;g&&f.setAttribute("normal",new Tt(m,3));let v=II(u.uvs);v&&v.length===2*c&&f.setAttribute("uv",new Tt(v,2));let y=!1;if(!g){let _=p??Array.from({length:c},(w,S)=>S),{closed:b,inverted:x}=function(w,S){let T=w.length/3,M=new Map,E=new Array(T);for(let R=0;R<T;R++){let I=`${Math.round(1e4*w[3*R])},${Math.round(1e4*w[3*R+1])},${Math.round(1e4*w[3*R+2])}`,U=M.get(I);U===void 0?(M.set(I,R),E[R]=R):E[R]=U}let A=new Map;for(let R=0;R+2<S.length;R+=3){let I=E[S[R]],U=E[S[R+1]],O=E[S[R+2]];for(let[k,G]of[[I,U],[U,O],[O,I]]){if(k===G)continue;let K=k<G?k+"_"+G:G+"_"+k;A.set(K,(A.get(K)??0)+1)}}let C=A.size>0;for(let R of A.values())if(R!==2){C=!1;break}if(!C)return{closed:!1,inverted:!1};let D=0;for(let R=0;R+2<S.length;R+=3){let I=3*S[R],U=3*S[R+1],O=3*S[R+2],k=w[I],G=w[I+1],K=w[I+2],q=w[U],Y=w[U+1],ue=w[U+2],de=w[O],ge=w[O+1],be=w[O+2];D+=k*(Y*be-ue*ge)+G*(ue*de-q*be)+K*(q*ge-Y*de)}return{closed:!0,inverted:D<0}}(d,_);if(b&&x){for(let w=0;w+2<_.length;w+=3){let S=_[w+1];_[w+1]=_[w+2],_[w+2]=S}p=_}else b||(y=!0)}return p&&f.setIndex(p),g||f.computeVertexNormals(),{geometry:Pxe({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:f.toJSON().data}),doubleSide:y}}(s);Object.assign(a,yc.defaultData,{geometry:l,materials:[w1e(t,i)]}),h&&(a.side=2)}else Object.assign(a,yc.defaultData,{geometry:n==="TextGeometry"?yje(s):_je(n,s),material:w1e(t,i)});t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow)}else r==="Empty"?Object.assign(a,ZL.defaultData):(Object.assign(a,QL.defaultData(r),s),t.color!==void 0&&(a.color=WX(t.color)));a.visible=t.visible??!0,a.position=sC(t.position,[0,0,0]),a.rotation=sC(t.rotation,[0,0,0]),a.scale=NPe(t.scale);let o=(n&&gje[n])??vje[r]??r;return a.name=t.name??IPe(o,i.scene.objects),a}function IPe(e,t){let i=new Set;if(t.traverse((n,s)=>{i.add(s.name??"")}),!i.has(e))return e;let r=2;for(;i.has(`${e} ${r}`);)r++;return`${e} ${r}`}function OPe(e,t){let i=Qe.generateUUID();if(e.data.type==="Component")return{data:{...Sf.fromComponentData(e),name:e.data.name+" Instance"},id:i,fi:e.fi,children:[]};t[e.id]=i;let r=e.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:iBe(r.animations,Qe.generateUUID,t)}),{...e,id:i,data:r,children:e.children.map(n=>OPe(n,t))}}function xje(e){let t={};return function(i,r){return Cx(i,r,null)??i}(OPe(e,t),t)}function wje(e){let t=Array.isArray(e)?e[0]:e,i=t.layers?.map(Sje)??[],r=t.layers?.find(n=>n.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function Sje(e){return e.type==="texture"||e.type==="video"||e.type==="matcap"?{...e.data,updateTexture:t=>e.color.texture.image.updateSrc(t)}:{...e.data}}Qf(),Yn(),KY(),xu();var AM=new Ur(0,0,0,1),Tje={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:[]};Ot(),Ot();var Mje=new Z;function T1e(e){let t=new Ur(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}return t}var LPe=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r,renderer:n,htmlContentMode:s="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<Dxe?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),l1(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=Mje.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=OA(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this._htmlContentMode=s,this.renderMode=t?"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=n??"webgl",n===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(()=>(UUe(),eMe)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",Oee,!0),a.addEventListener("pointerdown",T3,!0),a.addEventListener("pointermove",T3,!0),a.addEventListener("pointerup",Y1,!0),a.addEventListener("pointercancel",Y1,!0),a.addEventListener("pointerleave",Y1,!0),window.addEventListener("keydown",Lee,!0),window.addEventListener("keyup",Bee,!0)}(e)}async _ensureRenderer(){return this._renderer?this._renderer:(this._rendererInit||(this._rendererInit=this._initRenderer().then(e=>(this._rendererInit=void 0,e&&(this._renderer=e),e),e=>{throw this._rendererInit=void 0,e})),this._rendererInit)}async _initRenderer(){if(this.disposed)return null;let e=await this._createRenderer();return this.disposed?(this._disposeRenderer(e),null):e}_disposeRenderer(e){let t=function(r){let n=r.backend;if(n!==void 0)return n.isWebGLBackend===!0?n.gl??null:null;let s=r.getContext,a=typeof s=="function"?s.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(e);if(t&&!function(r,n){return y1e.get(r)===n}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(e)||e.dispose());let i=t?function(r,n){let s=n.getExtension("WEBGL_lose_context");if(!s||n.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=_1e(r,"webglcontextlost",h=>{h.preventDefault(),l(s)})});return RI.set(r,{gl:n,lost:o,stopListening:a}),()=>{n.isContextLost()||s.loseContext()}}(this.canvas,t):void 0;try{e.dispose()}finally{i?.()}}async _createRenderer(){if(function(e,t){y1e.set(e,t)}(this.canvas,this),await async function(e){let t=RI.get(e);if(t&&(t.restoring??(t.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let n,s=()=>{},a=r.lost.then(l=>new Promise(h=>{s=_1e(i,"webglcontextrestored",()=>h()),l.restoreContext()})),o=new Promise(l=>{n=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(n),s(),r.stopListening()}(e,t).finally(()=>{t.restoring=void 0,!t.gl.isContextLost()&&RI.get(e)===t&&RI.delete(e)})),await t.restoring,t.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:e,isWebGPUSupported:t}=await Promise.resolve().then(()=>(N9(),QO));t();let i=!0,r=!1;try{let s=new URLSearchParams(window.location.search),a=s.get("bundles");a==="rerecord"?i="rerecord":(a==="off"||a==="0"||a==="false"||a==="no")&&(i=!1),r=s.get("forcegl")==="1"}catch{}let n=await e({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:this._asyncShaderCompilation()});return n.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},n.skyAnimationAllowed=!0,n}catch(e){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",e),this._rendererBackend="webgl"}{let{SplineRenderer:e,rendererGlobals:t}=await Promise.resolve().then(()=>(cve(),pX));try{new URLSearchParams(window.location.search).get("taa")==="off"&&(t.taaEnabled.value=!1)}catch{}return new e({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"})}}_asyncShaderCompilation(){let e=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let t=new URLSearchParams(window.location.search);if(t.get("forcegl")==="1")return!1;let i=t.get("asynccomp");i==="off"||i==="0"||i==="false"||i==="no"?e=!1:(i==="on"||i==="1"||i==="true"||i==="always")&&(e=!0)}catch{}return e}_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 e=window.devicePixelRatio||1,t=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=t*e,this.canvas.height=i*e;let r=this.canvas.getContext("2d");r&&(r.scale(e,e),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.",t/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(e,t,i){(function(n){let s="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(s+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(s)})(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,t={}){if(this.disposed)return;let i,r=++this._startOrder,n=()=>this._claimedOrder>r;return i=this._start(e,t,n,()=>!n()&&(this._claimedOrder=r,this._claimedStart=i,!0)).then(()=>n()?this._claimedStart:void 0,s=>{if(!n())throw s;return this._claimedStart}),i}async _start(e,{interactive:t=!0,variables:i},r,n){Bs.init();let s=await async function(m){let[g,v]=VM(LA.deserialize(new Uint8Array(m)));if((g.schema??0)!==136){let{updateDocumentSchema:y}=await Promise.resolve().then(()=>(CB(),vxe));y(g)}return v.result().data}(e);if(r())return;let a=function(m){let g=[];return m.scene.objects.traverse((v,y)=>{y.type==="Mesh"&&y.geometry.type==="NonParametricGeometry"&&y.geometry.data.draco!==void 0&&g.push(y)}),g}(s);s.version&&(0,hje.default)(s.version,"2.0.204")>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(m){dTe=m}(this._wasmPath));let o=async function(){}();if(await Promise.all([o,a.length&&g1e(this._wasmPath),Wre(s)&&DBe(this._wasmPath),QBe(s)&&ZBe(this._wasmPath),SFe(s)&&sFe(this._wasmPath),o1.physicsEnabled(s.scene.objects)&&_6e(this._wasmPath),Wie(s)&&Zve(),fne(s)&&qFe(),kBe(s)&&zBe(),jve(s)&&o.then(()=>xH()?.loadHanaUIRUNTIME()),c6e(s)&&B6e(this._wasmPath)].filter(Boolean)),r()||a.length&&(await v1e(a),r())||!n())return;this._data=s,this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let l=s.scene.publish.renderer;if(this._rendererAuto&&l==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&l==="webgpu"){let m=this._rendererBackend==="webgpu"&&await navigator.gpu?.requestAdapter().catch(()=>null);if(r())return;if(!m)return void this._failWebGPURequired();this._rendererAuto=!1}let h=function(m){let g=new Set;return m.scene.objects.traverse((v,y)=>{if(y.type!=="Page")return;let _=y.postprocessing;if(_&&typeof _=="object"&&_.enabled===!0)for(let[b,x]of Object.entries(_))b!=="enabled"&&x&&typeof x=="object"&&x.enabled===!0&&g.add(b)}),[...g]}(s);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(N9(),QO)),lje(h)]);let m=await this._ensureRenderer();if(r()||!m)return}catch(m){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",m),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu"&&(await Promise.all([Promise.resolve().then(()=>(cve(),pX)),oje(h)]),r()))return;(function(m){mC=m})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let u=new rje(s,{},!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:m}=await Promise.resolve().then(()=>(Zke(),v3e));if(r())return;let g=performance.now();m(s,u.scene);let v=performance.now();console.log("Merged geometries in ",v-g," ms")}Wre(s)&&this._scene.traverse(m=>{Bc(m)&&m.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(m=>{Lg(m)&&m.pendingMediaLoad&&m.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(m=>{m.type==="ParticleSystem"&&(m.wakeUp(),m.data.autoPlay?m.start():m.stop()),l1(m)&&m.setPlayMode(!0)});let d=Object.keys(s.shared.fonts).flatMap(m=>{let g=this._sharedAssetsManager.getFont(m);return g?[g.loadingPromise]:[]});if(Promise.all(d).then(()=>{this.disposed||(u.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),Wie(s)&&function(m){if(o1.physicsEnabled(m.scene.objects))return!0;let g=!1;return m.scene.objects.traverse((v,y)=>{if(y.events){if(Array.isArray(y.events)){for(let _ of y.events)if(_.data.disabled!==!0&&_.data.type==="GameControl"&&_.data.collisionEnabled){g=!0;break}}else for(let _ of Object.values(y.events))if(_.disabled!==!0&&_.type==="GameControl"&&_.collisionEnabled){g=!0;break}}}),g}(s)&&(await Promise.all(d),r()))return;if(jve(s)){let m=[];if(this._scene.traverseEntity(g=>{(qo(g)||g instanceof Dn)&&g.uiCanvas&&m.push(g.uiCanvas)}),await Promise.all(m.map(g=>g.promise)),r())return}this._scene.rewriteEventsBeforeGoToPlayMode(),VZ(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=s.scene.publish.hdTransmission===!0,c.setPixelRatio(this._getPixelRatio(/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?s.scene.publish.settings.web.pixelRatioMobile:s.scene.publish.settings.web.pixelRatioDesktop)),c.setAsyncCompilationPolicy?.(this._asyncShaderCompilation()),s.shared.images.SplineWatermark){let m=this._sharedAssetsManager.getImage("SplineWatermark");if(await m.loadPromise,r())return;let g=m.getTexture(1001);c.pipeline.setWatermark(g)}else c.pipeline.setWatermark(null);fne(s)&&this._scene.initializeSplatViewer(),s.scene.blueNoiseTextureData!==void 0&&c.pipeline.updateBlueNoiseTexture(s.scene.blueNoiseTextureData);let p=Object.values(s.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 NVe(c,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(p.allowResponsive??!1)&&p.preset==="fullscreen"),t){let m=new dVe(c,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,p);this._scene.updateMatrixWorld(!0),this._controls=new T6e(m),this._animationControls=new XGe(this._scene,this._requestRenderAutoMode),this._eventManager=new EVe(s.scene.publish,this._controls,this._animationControls,m,s.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),t&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let f=s.scene.publish.htmlContent?.html;if(t&&f&&this._htmlContentMode!=="none"){let m={shared:this._sharedAssetsManager,findEntity:g=>this._scene?.getObjectByProperty("uuid",g)??this._scene?.getObjectByName(g),getAnimationControls:()=>this._animationControls};this._htmlContentOverlay=(this._htmlContentMode==="inline"?RPe.mount(this,this.canvas,f,m):PPe.mount(this,this.canvas,f,m))??void 0}}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){if(t==null)return void console.warn(`Variable ${e} was not updated: received ${t}. Pass a number, boolean or string.`);let r=t;if(typeof i.data.value=="number"){if(r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t),!Number.isFinite(r))return void console.warn(`Variable ${e} is a number variable and ${JSON.stringify(t)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()!=="false"&&!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let n=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,n),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&So.isTextValue(e)?So.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(!(t.uuid===f1||this._scene.isInvisibleObjects(t)||t instanceof Dn)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof I3e&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=T1e(e);this._scene?.activePage.setBackgroundColor(t),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,HE&&HE.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{Y9.unsubscribe(e)}),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(e){e.removeEventListener("pointerdown",Oee,!0),e.removeEventListener("pointerdown",T3,!0),e.removeEventListener("pointermove",T3,!0),e.removeEventListener("pointerup",Y1,!0),e.removeEventListener("pointercancel",Y1,!0),e.removeEventListener("pointerleave",Y1,!0),window.removeEventListener("keydown",Lee,!0),window.removeEventListener("keyup",Bee,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Bs.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(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t,i=this._scene;if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);e.traverseAncestors(u=>{u instanceof Dn&&(t=u.name)});let r=this._sharedAssetsManager,n={shared:r,scene:this._scene},s=u=>{if(u===null||u==="Base State")return null;if(u&&e.data.states){let d=e.data.states.find(c=>c.data.name===u);return d?d.id:void 0}},a="material"in e?e.material:void 0,o=e.materialOverride,l={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,material:o??(a?wje(a):void 0),parentUuid:e.parent instanceof Dn||e instanceof zg?void 0:e.parent?.uuid,emitEvent(u){e.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){e.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){e.visible&&(e.visible=!1,n.shared.requestRender())},show(){e.visible||(e.visible=!0,n.shared.requestRender())},get state(){let u=e.stateSelection;if(u!==null)return e.data.states.find(({id:d})=>d===u)?.data.name},set state(u){let d;if(u!==void 0){let c=typeof u=="string"?e.data.states.find(({id:p})=>p===u):e.data.states[u];if(c)d=c.id;else{let p=typeof u=="string"?s(u):void 0;p&&(d=p)}}e.changeSelectedState(d??null,n),e.currentState=d??null,e.dispatchEvent({type:"completeState",state:d??null}),n.shared.requestRender()},transition(u){let d=EPe;if(d===null)return Ta("transitions","obj.transition()"),{transition(b){return this},play(){return this},pause(){return this},reset(){return this},seek(b){return this}};let c,p,f=this,m=[],g=!1,v=()=>{p=new uPe({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},m.map(b=>b.runner))},y={update(b){p?.update(b),p?.isPlaying!==!0&&Bs.remove(y)}},_={transition({from:b,to:x,duration:w,delay:S,...T}){let M=s(b);M===void 0&&(M=c);let E=s(x);return c=E,m.push(new d(e,M,E,{state:E,repeat:0,delay:S??0,delayDirection:"start-once",direction:"normal",duration:w??1e3,...T,...T.easing===6?Ng.defaultData:T.easing===5?lw.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(b&&M||b==="Base State"&&!M)&&(f.state=M??void 0)},onComplete:()=>{f.state=E??void 0}})),v(),this},play(){return p?(g=!0,p.play(Bs.time),p.isPlaying&&Bs.add(y),this):this},pause(){return p?.stop(),Bs.remove(y),this},reset(){return this.pause(),g=!1,v(),p?.seek(0),this},seek(b){let x=m.reduce((w,S)=>w+S.runner.duration,0);return x>0&&p?.seek(b/1e3/x),this}};return _.transition(u),(u.autoPlay??!0)&&queueMicrotask(()=>{g||_.play()}),_},set color(u){let d=T1e(u);if(v4.is(e))return void(e.color=d);if(!(e.type==="Mesh"&&"material"in e&&e instanceof _l))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=e.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(u),n.shared.requestRender()))}let f=Array.isArray(e.material)?e.material[0]:e.material,m=f.data.layers.find(g=>g.data.type==="color")?.id;if(m)f.updateByOp({type:0,path:["layers",m],props:{color:{...c}}},f.data,n);else{let g=f.data,v=g.layers.find(S=>S.data.type==="light");if(!v)return;let y=g.layers.indexOf(v)===0?v:null,_=g.layers.at(y?g.layers.indexOf(y)+1:0),b={type:4,fi:y?y.fi+(_?(_.fi-y.fi)/2:1):_?_.fi/2:1,id:Qe.generateUUID(),data:{...ts.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(y?.id??null,1),w=g.layers.runOp({...b,fi:x[0]}).data;Object.assign(f.data,{layers:w}),f.updateByOp({...b,path:["layers"]},f.data,n)}}},h=Y9(l,(u,d)=>{let c=e[u],p=function(f){return f.split(".")}(u);p[0]==="material"&&a&&o===void 0&&function(f,m,g){let v=Array.isArray(g)?g[0]:g;if(f[0]==="layers"){let y=parseInt(f[1]),_=v.layers[y],b=f[2];_&&b&&function(x,w,S){let T=x[0];try{if(function(M,E){return!!Tje[E]?.includes(M)}(T,S.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let M=parseInt(x[1]),E=S.getValue(T)?.[M];if(!E)throw new Error("Color index out of range");AM.setStyle(w),E.set(AM.r,AM.g,AM.b,AM.a)}else S.getValue(T)?.setStyle(w);else if(T==="texture"||T==="video"){let M=S.color;(function(E,A,C,D){let R=E[0];if(R==="repeat"||R==="offset"||R==="rotation"){let I=D.getNode("mat"),U=I&&typeof I.updateMatrix=="function"?I:D.getValue("mat");if(!U)return;if(R==="rotation")U.rotation=parseFloat(A);else{let O=E[1];if(O===void 0)A instanceof Array&&A.length===2&&Object.assign(U,{[R]:A});else{let k=U[R],G=parseInt(O)===0?[parseFloat(A),k[1]]:[k[0],parseFloat(A)];Object.assign(U,{[R]:G})}}U.updateMatrix()}else R==="wrapping"||R==="minFilter"||R==="magFilter"?R==="wrapping"?C.texture.wrap=A:C.texture[R]=A:R==="image"&&E[1]==="data"&&C.texture.image.updateSrc(A)})(x.slice(1),w,M,S)}else{let M=x[1],E=S.getValue(T);E?.isVector3&&M!==void 0||E?.isVector2&&M!==void 0?E.setComponent(parseInt(M),w):S.setValue(T,w)}}catch(M){console.error("Error setting material value",M)}}(f.slice(2),m,_)}else f[0]==="alpha"&&v.layers.forEach(y=>{y.type==="light"&&y.node.alphaOverride!==void 0&&(y.node.alphaOverride.value=m,m<1&&(v.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(e,u)?.writable&&(e[u]=d),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,h),h}setUIWasmUrl(e){(function(t){s4=t,DB?.setHanaUIWasmUrl(t)})(e)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if(typeof t=="string"){if(!t.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(t)).arrayBuffer();i=new Uint8Array(l)}}else i=t;let r=LA.deserialize(i),n="data"in r&&r.data.draco!==void 0;n&&await g1e(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!s)return void console.warn(`Object ${e} not found`);if(s.data.type!=="Mesh"||!(s instanceof _l))return void console.warn(`Object ${e} is not a mesh`);let a=s,o={...a.data,geometry:r};n&&await v1e([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]=Og.patch(o,h)}return i}_applyDocumentTransaction(e){this._data=e.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let t of e.actual){let i=t.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...t,path:[]},this._sharedAssetsManager)}}_findEntity(e){return this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e)}_resolveParentId(e){if(e===void 0)return this._scene.activePage.uuid;let t=typeof e=="string"?e:e.uuid,i=this._findEntity(t);if(!i)throw new Error(`parent '${t}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(e){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof e!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let t=KH();if(t===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(N9(),QO)),t=KH()),t===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=e(t);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(e,t){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 e=="string"?e:e.uuid,n=this._findEntity(r);if(!n)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(n instanceof _l))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let s=typeof t=="function"?await this.createCustomMaterial(t):t;if(f4()!=="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=b1e({material:s});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return n.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(n.uuid),this._requestRenderAutoMode(),a.material}async createObject(e,t={}){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 n=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${x1e}.`);let v=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),y=fje[v];if(y)return{objectType:y};let _=pje[v];if(_)return{objectType:"Mesh",geometryType:_};let b=mje[v];throw b?new Error(`createObject: '${g}' is not supported \u2014 ${b}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${x1e}, e.g. createObject('Cube', { width: 200 }).`)}(e);typeof t.material=="function"&&(t={...t,material:await this.createCustomMaterial(t.material)});let s,a,{options:o,material:l}=b1e(t);if(l!==void 0){if(n.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(f4()!=="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(n.geometryType==="TextGeometry"){if(!GY.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 Zve(),a=t.font??Fb,r.shared.fonts[a]===void 0){if(a!==Fb){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}s={name:Fb,url:Ebe}}}let h=this._resolveParentId(t.parent),u=bje(n,o,r),d=Qe.generateUUID(),[c,p]=VM(r);s&&(c.shared.fonts[Fb]=s),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let f=p.result();if(s&&this._sharedAssetsManager.addFont(Fb,s),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(f);let m=i.find(d);return l!==void 0&&m.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(m)}cloneObject(e,t={}){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 n=typeof e=="string"?e:e?.uuid,s=n?this._findEntity(n):void 0;if(!s)throw new Error(`cloneObject: '${n}' \u2014 no object with that name or uuid in the scene.`);if(s instanceof Dn)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(s.uuid);if(!a)throw new Error(`cloneObject: '${n}' 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,f,m){let g={...p.data};return f.position!==void 0&&(g.position=sC(f.position,[0,0,0])),f.rotation!==void 0&&(g.rotation=sC(f.rotation,[0,0,0])),f.scale!==void 0&&(g.scale=NPe(f.scale)),f.visible!==void 0&&(g.visible=f.visible),g.name=f.name??IPe(`${p.data.name??"Object"} Copy`,m),{...p,data:g}}(xje(a),t,r.scene.objects),l=t.parent!==void 0?this._resolveParentId(t.parent):r.scene.objects.parent(s.uuid)??null,h=t.parent!==void 0?null:s.uuid,[u,d]=VM(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(e){let t=this._scene,i=this._data;if(this.disposed||!t||!i)return!1;let r=typeof e=="string"?e:e?.uuid,n=r?this._findEntity(r):void 0;if(!n)return!1;if(n instanceof Dn)throw new Error("removeObject: pages cannot be removed.");if(n.data.type==="PerspectiveCamera"||n.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(n.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 s=[];n.traverseEntity(l=>{s.push(l.uuid)});let[a,o]=VM(i);a.scene.objects.delete(n.uuid),this._applyDocumentTransaction(o.result());for(let l of s){let h=this._proxyObjectCache.get(l);h&&(Y9.unsubscribe(h),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var yF=window,_F=yF.ShadowRoot&&(yF.ShadyCSS===void 0||yF.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,GZ=Symbol(),BPe=new WeakMap,EC=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==GZ)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(_F&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=BPe.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&BPe.set(i,t))}return t}toString(){return this.cssText}},FPe=e=>new EC(typeof e=="string"?e:e+"",void 0,GZ),jZ=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,n,s)=>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.")})(n)+e[s+1],e[0]);return new EC(i,e,GZ)},WZ=(e,t)=>{_F?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),n=yF.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=i.cssText,e.appendChild(r)})},bF=_F?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return FPe(i)})(e):e;var HZ,xF=window,UPe=xF.trustedTypes,Eje=UPe?UPe.emptyScript:"",zPe=xF.reactiveElementPolyfillSupport,$Z={toAttribute(e,t){switch(t){case Boolean:e=e?Eje:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},kPe=(e,t)=>t!==e&&(t==t||e==e),qZ={attribute:!0,type:String,converter:$Z,reflect:!1,hasChanged:kPe},XZ="finalized",em=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let n=this._$Ep(r,i);n!==void 0&&(this._$Ev.set(n,r),t.push(n))}),t}static createProperty(t,i=qZ){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,n=this.getPropertyDescriptor(t,r,i);n!==void 0&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(n){let s=this[t];this[i]=n,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||qZ}static finalize(){if(this.hasOwnProperty(XZ))return!1;this[XZ]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let n of r)this.createProperty(n,i[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let n of r)i.unshift(bF(n))}else t!==void 0&&i.push(bF(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return WZ(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=qZ){var n;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let a=(((n=r.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?r.converter:$Z).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(t,i){var r;let n=this.constructor,s=n._$Ev.get(t);if(s!==void 0&&this._$El!==s){let a=n.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:$Z;this._$El=s,this[s]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let n=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||kPe)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((n,s)=>this[s]=n),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(n=>{var s;return(s=n.hostUpdate)===null||s===void 0?void 0:s.call(n)}),this.update(r)):this._$Ek()}catch(n){throw i=!1,this._$Ek(),n}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var n;return(n=r.hostUpdated)===null||n===void 0?void 0:n.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};em[XZ]=!0,em.elementProperties=new Map,em.elementStyles=[],em.shadowRootOptions={mode:"open"},zPe?.({ReactiveElement:em}),((HZ=xF.reactiveElementVersions)!==null&&HZ!==void 0?HZ:xF.reactiveElementVersions=[]).push("1.6.3");var YZ,wF=window,Hw=wF.trustedTypes,VPe=Hw?Hw.createPolicy("lit-html",{createHTML:e=>e}):void 0,ZZ="$lit$",c0=`lit$${(Math.random()+"").slice(9)}$`,XPe="?"+c0,Aje=`<${XPe}>`,w1=document,CC=()=>w1.createComment(""),PC=e=>e===null||typeof e!="object"&&typeof e!="function",YPe=Array.isArray,Cje=e=>YPe(e)||typeof e?.[Symbol.iterator]=="function",KZ=`[
|
|
13045
|
+
`,RPe=class{constructor(e,t,i,r,n,s){this.container=e,this.host=t,this.observer=i,this.spline=r,this.previousSplineGlobal=n,this.removeLateLifecycleShim=s}static mount(e,t,i,r){if(typeof document>"u")return null;let n=t.parentElement;if(!n)return null;getComputedStyle(n).position==="static"&&(n.style.position="relative");let s=document.createElement("div");s.setAttribute(nL,"");let a=s.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${t.offsetLeft}px`,a.top=`${t.offsetTop}px`,a.width=`${t.offsetWidth}px`,a.height=`${t.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(t),l.observe(n);let h=document.createElement("style");h.textContent=dje,s.appendChild(h);let u=new DOMParser().parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let y of d)y.remove();for(let y of Array.from(u.head.children))(y.tagName==="STYLE"||y.tagName==="LINK"&&y.rel==="stylesheet")&&s.appendChild(y);for(;u.body.firstChild;)s.appendChild(u.body.firstChild);n.insertBefore(s,t.nextSibling),s.addEventListener("wheel",y=>{y.ctrlKey&&!y.defaultPrevented&&!t.dispatchEvent(new WheelEvent("wheel",y))&&y.preventDefault()},{passive:!1});let c=new Map,p=new gY(CPe(e,t,r),(y,_)=>{y==="warn"?console.warn(`[spline html] ${_}`):y==="error"&&console.error(`[spline html] ${_}`)},(y,_)=>{let b=c.get(y);if(b)for(let x of b)try{x(_)}catch(w){console.error(w)}}),f=(y,_)=>{try{return Promise.resolve(p.execute(y,_))}catch(b){return Promise.reject(b)}},m={ready:Promise.resolve(),setVariable:(y,_)=>f("setVariable",[y,_]),setVariables:y=>f("setVariables",[y]),getVariable:y=>f("getVariable",[y]),getVariables:()=>f("getVariables",[]),getAllObjects:()=>f("getAllObjects",[]),findObjectByName:y=>f("findObjectByName",[y]),findObjectById:y=>f("findObjectById",[y]),getGeometry:(y,_)=>f("getGeometry",[y,_??{}]),updateObject:(y,_)=>f("updateObject",[y,_]),createObject:(y,_)=>f("createObject",[y,_??{}]),createCustomMaterial:y=>f("createCustomMaterial",[y]),getTexture:(y,_)=>f("getTexture",[y,_??{}]),setMaterial:(y,_)=>f("setMaterial",[y,_]),cloneObject:(y,_)=>f("cloneObject",[y,_??{}]),removeObject:y=>f("removeObject",[y]),spawnObject:(y,_)=>f("spawnObject",[y,_??{}]),destroyObject:y=>f("destroyObject",[y]),setInstanceTransforms:(y,_)=>f("setInstanceTransforms",[y,_??null]),getAnimations:y=>f("getAnimations",[y]),playAnimation:(y,_,b)=>f("playAnimation",[y,_,b]),pauseAnimation:(y,_)=>f("pauseAnimation",[y,_]),stopAnimation:(y,_)=>f("stopAnimation",[y,_]),emitEvent:(y,_)=>f("emitEvent",[y,_]),emitEventReverse:(y,_)=>f("emitEventReverse",[y,_]),requestRender:()=>f("requestRender",[]),addEventListener:(y,_)=>{if(typeof _!="function")return;let b=c.get(y);b||(b=new Set,c.set(y,b),f("listenEvent",[y])),b.add(_)},removeEventListener:(y,_)=>{let b=c.get(y);!b||(b.delete(_),b.size===0&&(c.delete(y),f("unlistenEvent",[y])))}},g=window.spline;window.spline=m;let v=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let y=[],_=(x,w)=>{let S=new Set,T=x.addEventListener.bind(x),M=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(E,A,C)=>{if(T(E,A,C),!w.includes(E)||A==null)return;let D={type:E,listener:A};S.add(D),queueMicrotask(()=>{!S.delete(D)||((R,I,U)=>{let O=new Event(U);try{typeof I=="function"?I.call(R,O):I.handleEvent?.(O)}catch(k){console.error(k)}})(x,D.listener,D.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(E,A,C)=>{M(E,A,C);for(let D of S)D.type===E&&D.listener===A&&S.delete(D)}}),y.push(()=>{delete x.addEventListener,delete x.removeEventListener,S.clear()})};_(document,["DOMContentLoaded"]),_(window,["load"]);let b=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(w){console.error(w)}})}}),y.push(()=>{b?Object.defineProperty(window,"onload",b):delete window.onload}),()=>{for(let x of y)x()}}();for(let y of d){let _=document.createElement("script");for(let b of Array.from(y.attributes))_.setAttribute(b.name,b.value);y.src?_.async=!1:_.textContent=y.textContent,s.appendChild(_)}return new RPe(s,p,l,m,g,v)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function DPe(e){return typeof e=="object"&&e!==null&&e.isMaterial===!0}function b1e(e){if(typeof e.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(!DPe(e.material))return{options:e};let t=e.material;if(t.isNodeMaterial===!0){let i=KH()?.NodeMaterial;if(i!==void 0&&t instanceof i)return{options:{...e,material:void 0},material:t};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(t.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:{...e,material:void 0},material:t}}Ot(),Ir(),ne(),rSe(),xu(),Ir(),Ot(),SBe(),Qf();var cje=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),x1e="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",pje={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"},fje={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},mje={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')."},gje={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"},vje={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function sC(e,t){return e===void 0?[t[0],t[1],t[2]]:Array.isArray(e)?[e[0]??t[0],e[1]??t[1],e[2]??t[2]]:[e.x??t[0],e.y??t[1],e.z??t[2]]}function NPe(e){return typeof e=="number"?[e,e,e]:sC(e,[1,1,1])}function WX(e){let t=new Ur(0,0,0,1);return t.setStyle(e),{r:t.r,g:t.g,b:t.b}}function w1e(e,t){let i=e.material??(e.color!==void 0?{color:e.color}:void 0);if(i===void 0)return Un.defaultColorMaterial(S1e(Za),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(t.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)||at.NAMES[o]!==void 0}(i))return Un.defaultColorMaterial(WX(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)"}(t)}) 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(DPe(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?WX(i.color):S1e(Za),n=Un.defaultColorMaterial(r,"physical","layer1","layer2"),s=n.layers.find(a=>a.data.type==="light");if(s){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(s.data,a)}if(i.alpha!==void 0){let a=n.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return n}function S1e(e){return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}}function yje(e){let t=cf.defaultData("TextGeometry"),{text:i,...r}=e,n=r.fontSize;return n!==void 0&&r.width===void 0&&(r.width=350*n/16),n!==void 0&&r.height===void 0&&(r.height=50*n/16),Object.assign(t,r),i!==void 0&&Object.assign(t,{text:{textValue:String(i)}}),t}function II(e){return Array.isArray(e)?e:!ArrayBuffer.isView(e)||e instanceof DataView?null:Array.from(e)}function _je(e,t){return Pxe({userData:{type:e,...$H[e].normalizeInputs({parameters:t})}})}function bje(e,t,i){let{objectType:r,geometryType:n}=e,s=function(l){let h={};for(let[u,d]of Object.entries(l))!cje.has(u)&&d!==void 0&&(h[u]=d);return h}(t),a={states:new Et,events:new Et};if(r==="Mesh"&&n){if(n==="NonParametricGeometry"){let{geometry:l,doubleSide:h}=function(u){let d=II(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=II(u.indices);if(p&&p.length){let _=p.find(b=>!Number.isInteger(b)||b<0||b>=c);if(_!==void 0)throw new Error(`createObject('CustomMesh'): index ${_} is out of range (mesh has ${c} vertices).`)}else p=null;let f=new Mt;f.setAttribute("position",new Tt(d,3));let m=II(u.normals),g=m!==null&&m.length===d.length;g&&f.setAttribute("normal",new Tt(m,3));let v=II(u.uvs);v&&v.length===2*c&&f.setAttribute("uv",new Tt(v,2));let y=!1;if(!g){let _=p??Array.from({length:c},(w,S)=>S),{closed:b,inverted:x}=function(w,S){let T=w.length/3,M=new Map,E=new Array(T);for(let R=0;R<T;R++){let I=`${Math.round(1e4*w[3*R])},${Math.round(1e4*w[3*R+1])},${Math.round(1e4*w[3*R+2])}`,U=M.get(I);U===void 0?(M.set(I,R),E[R]=R):E[R]=U}let A=new Map;for(let R=0;R+2<S.length;R+=3){let I=E[S[R]],U=E[S[R+1]],O=E[S[R+2]];for(let[k,G]of[[I,U],[U,O],[O,I]]){if(k===G)continue;let K=k<G?k+"_"+G:G+"_"+k;A.set(K,(A.get(K)??0)+1)}}let C=A.size>0;for(let R of A.values())if(R!==2){C=!1;break}if(!C)return{closed:!1,inverted:!1};let D=0;for(let R=0;R+2<S.length;R+=3){let I=3*S[R],U=3*S[R+1],O=3*S[R+2],k=w[I],G=w[I+1],K=w[I+2],q=w[U],Y=w[U+1],ue=w[U+2],de=w[O],ge=w[O+1],be=w[O+2];D+=k*(Y*be-ue*ge)+G*(ue*de-q*be)+K*(q*ge-Y*de)}return{closed:!0,inverted:D<0}}(d,_);if(b&&x){for(let w=0;w+2<_.length;w+=3){let S=_[w+1];_[w+1]=_[w+2],_[w+2]=S}p=_}else b||(y=!0)}return p&&f.setIndex(p),g||f.computeVertexNormals(),{geometry:Pxe({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:f.toJSON().data}),doubleSide:y}}(s);Object.assign(a,yc.defaultData,{geometry:l,materials:[w1e(t,i)]}),h&&(a.side=2)}else Object.assign(a,yc.defaultData,{geometry:n==="TextGeometry"?yje(s):_je(n,s),material:w1e(t,i)});t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow)}else r==="Empty"?Object.assign(a,ZL.defaultData):(Object.assign(a,QL.defaultData(r),s),t.color!==void 0&&(a.color=WX(t.color)));a.visible=t.visible??!0,a.position=sC(t.position,[0,0,0]),a.rotation=sC(t.rotation,[0,0,0]),a.scale=NPe(t.scale);let o=(n&&gje[n])??vje[r]??r;return a.name=t.name??IPe(o,i.scene.objects),a}function IPe(e,t){let i=new Set;if(t.traverse((n,s)=>{i.add(s.name??"")}),!i.has(e))return e;let r=2;for(;i.has(`${e} ${r}`);)r++;return`${e} ${r}`}function OPe(e,t){let i=Qe.generateUUID();if(e.data.type==="Component")return{data:{...Sf.fromComponentData(e),name:e.data.name+" Instance"},id:i,fi:e.fi,children:[]};t[e.id]=i;let r=e.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:iBe(r.animations,Qe.generateUUID,t)}),{...e,id:i,data:r,children:e.children.map(n=>OPe(n,t))}}function xje(e){let t={};return function(i,r){return Cx(i,r,null)??i}(OPe(e,t),t)}function wje(e){let t=Array.isArray(e)?e[0]:e,i=t.layers?.map(Sje)??[],r=t.layers?.find(n=>n.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function Sje(e){return e.type==="texture"||e.type==="video"||e.type==="matcap"?{...e.data,updateTexture:t=>e.color.texture.image.updateSrc(t)}:{...e.data}}Qf(),Yn(),KY(),xu();var AM=new Ur(0,0,0,1),Tje={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:[]};Ot(),Ot();var Mje=new Z;function T1e(e){let t=new Ur(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}return t}var LPe=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r,renderer:n,htmlContentMode:s="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<Dxe?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),l1(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=Mje.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=OA(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this._htmlContentMode=s,this.renderMode=t?"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=n??"webgl",n===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(()=>(UUe(),eMe)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",Oee,!0),a.addEventListener("pointerdown",T3,!0),a.addEventListener("pointermove",T3,!0),a.addEventListener("pointerup",Y1,!0),a.addEventListener("pointercancel",Y1,!0),a.addEventListener("pointerleave",Y1,!0),window.addEventListener("keydown",Lee,!0),window.addEventListener("keyup",Bee,!0)}(e)}async _ensureRenderer(){return this._renderer?this._renderer:(this._rendererInit||(this._rendererInit=this._initRenderer().then(e=>(this._rendererInit=void 0,e&&(this._renderer=e),e),e=>{throw this._rendererInit=void 0,e})),this._rendererInit)}async _initRenderer(){if(this.disposed)return null;let e=await this._createRenderer();return this.disposed?(this._disposeRenderer(e),null):e}_disposeRenderer(e){let t=function(r){let n=r.backend;if(n!==void 0)return n.isWebGLBackend===!0?n.gl??null:null;let s=r.getContext,a=typeof s=="function"?s.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(e);if(t&&!function(r,n){return y1e.get(r)===n}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(e)||e.dispose());let i=t?function(r,n){let s=n.getExtension("WEBGL_lose_context");if(!s||n.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=_1e(r,"webglcontextlost",h=>{h.preventDefault(),l(s)})});return RI.set(r,{gl:n,lost:o,stopListening:a}),()=>{n.isContextLost()||s.loseContext()}}(this.canvas,t):void 0;try{e.dispose()}finally{i?.()}}async _createRenderer(){if(function(e,t){y1e.set(e,t)}(this.canvas,this),await async function(e){let t=RI.get(e);if(t&&(t.restoring??(t.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let n,s=()=>{},a=r.lost.then(l=>new Promise(h=>{s=_1e(i,"webglcontextrestored",()=>h()),l.restoreContext()})),o=new Promise(l=>{n=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(n),s(),r.stopListening()}(e,t).finally(()=>{t.restoring=void 0,!t.gl.isContextLost()&&RI.get(e)===t&&RI.delete(e)})),await t.restoring,t.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:e,isWebGPUSupported:t}=await Promise.resolve().then(()=>(N9(),QO));t();let i=!0,r=!1;try{let s=new URLSearchParams(window.location.search),a=s.get("bundles");a==="rerecord"?i="rerecord":(a==="off"||a==="0"||a==="false"||a==="no")&&(i=!1),r=s.get("forcegl")==="1"}catch{}let n=await e({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:this._asyncShaderCompilation()});return n.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},n.skyAnimationAllowed=!0,n}catch(e){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",e),this._rendererBackend="webgl"}{let{SplineRenderer:e,rendererGlobals:t}=await Promise.resolve().then(()=>(cve(),pX));try{new URLSearchParams(window.location.search).get("taa")==="off"&&(t.taaEnabled.value=!1)}catch{}return new e({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"})}}_asyncShaderCompilation(){let e=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let t=new URLSearchParams(window.location.search);if(t.get("forcegl")==="1")return!1;let i=t.get("asynccomp");i==="off"||i==="0"||i==="false"||i==="no"?e=!1:(i==="on"||i==="1"||i==="true"||i==="always")&&(e=!0)}catch{}return e}_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 e=window.devicePixelRatio||1,t=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=t*e,this.canvas.height=i*e;let r=this.canvas.getContext("2d");r&&(r.scale(e,e),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.",t/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(e,t,i){(function(n){let s="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(s+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(s)})(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,t={}){if(this.disposed)return;let i,r=++this._startOrder,n=()=>this._claimedOrder>r;return i=this._start(e,t,n,()=>!n()&&(this._claimedOrder=r,this._claimedStart=i,!0)).then(()=>n()?this._claimedStart:void 0,s=>{if(!n())throw s;return this._claimedStart}),i}async _start(e,{interactive:t=!0,variables:i},r,n){Bs.init();let s=await async function(m){let[g,v]=VM(LA.deserialize(new Uint8Array(m)));if((g.schema??0)!==136){let{updateDocumentSchema:y}=await Promise.resolve().then(()=>(CB(),vxe));y(g)}return v.result().data}(e);if(r())return;let a=function(m){let g=[];return m.scene.objects.traverse((v,y)=>{y.type==="Mesh"&&y.geometry.type==="NonParametricGeometry"&&y.geometry.data.draco!==void 0&&g.push(y)}),g}(s);s.version&&(0,hje.default)(s.version,"2.0.205")>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(m){dTe=m}(this._wasmPath));let o=async function(){}();if(await Promise.all([o,a.length&&g1e(this._wasmPath),Wre(s)&&DBe(this._wasmPath),QBe(s)&&ZBe(this._wasmPath),SFe(s)&&sFe(this._wasmPath),o1.physicsEnabled(s.scene.objects)&&_6e(this._wasmPath),Wie(s)&&Zve(),fne(s)&&qFe(),kBe(s)&&zBe(),jve(s)&&o.then(()=>xH()?.loadHanaUIRUNTIME()),c6e(s)&&B6e(this._wasmPath)].filter(Boolean)),r()||a.length&&(await v1e(a),r())||!n())return;this._data=s,this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let l=s.scene.publish.renderer;if(this._rendererAuto&&l==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&l==="webgpu"){let m=this._rendererBackend==="webgpu"&&await navigator.gpu?.requestAdapter().catch(()=>null);if(r())return;if(!m)return void this._failWebGPURequired();this._rendererAuto=!1}let h=function(m){let g=new Set;return m.scene.objects.traverse((v,y)=>{if(y.type!=="Page")return;let _=y.postprocessing;if(_&&typeof _=="object"&&_.enabled===!0)for(let[b,x]of Object.entries(_))b!=="enabled"&&x&&typeof x=="object"&&x.enabled===!0&&g.add(b)}),[...g]}(s);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(N9(),QO)),lje(h)]);let m=await this._ensureRenderer();if(r()||!m)return}catch(m){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",m),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu"&&(await Promise.all([Promise.resolve().then(()=>(cve(),pX)),oje(h)]),r()))return;(function(m){mC=m})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let u=new rje(s,{},!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:m}=await Promise.resolve().then(()=>(Zke(),v3e));if(r())return;let g=performance.now();m(s,u.scene);let v=performance.now();console.log("Merged geometries in ",v-g," ms")}Wre(s)&&this._scene.traverse(m=>{Bc(m)&&m.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(m=>{Lg(m)&&m.pendingMediaLoad&&m.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(m=>{m.type==="ParticleSystem"&&(m.wakeUp(),m.data.autoPlay?m.start():m.stop()),l1(m)&&m.setPlayMode(!0)});let d=Object.keys(s.shared.fonts).flatMap(m=>{let g=this._sharedAssetsManager.getFont(m);return g?[g.loadingPromise]:[]});if(Promise.all(d).then(()=>{this.disposed||(u.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),Wie(s)&&function(m){if(o1.physicsEnabled(m.scene.objects))return!0;let g=!1;return m.scene.objects.traverse((v,y)=>{if(y.events){if(Array.isArray(y.events)){for(let _ of y.events)if(_.data.disabled!==!0&&_.data.type==="GameControl"&&_.data.collisionEnabled){g=!0;break}}else for(let _ of Object.values(y.events))if(_.disabled!==!0&&_.type==="GameControl"&&_.collisionEnabled){g=!0;break}}}),g}(s)&&(await Promise.all(d),r()))return;if(jve(s)){let m=[];if(this._scene.traverseEntity(g=>{(qo(g)||g instanceof Dn)&&g.uiCanvas&&m.push(g.uiCanvas)}),await Promise.all(m.map(g=>g.promise)),r())return}this._scene.rewriteEventsBeforeGoToPlayMode(),VZ(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=s.scene.publish.hdTransmission===!0,c.setPixelRatio(this._getPixelRatio(/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?s.scene.publish.settings.web.pixelRatioMobile:s.scene.publish.settings.web.pixelRatioDesktop)),c.setAsyncCompilationPolicy?.(this._asyncShaderCompilation()),s.shared.images.SplineWatermark){let m=this._sharedAssetsManager.getImage("SplineWatermark");if(await m.loadPromise,r())return;let g=m.getTexture(1001);c.pipeline.setWatermark(g)}else c.pipeline.setWatermark(null);fne(s)&&this._scene.initializeSplatViewer(),s.scene.blueNoiseTextureData!==void 0&&c.pipeline.updateBlueNoiseTexture(s.scene.blueNoiseTextureData);let p=Object.values(s.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 NVe(c,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(p.allowResponsive??!1)&&p.preset==="fullscreen"),t){let m=new dVe(c,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,p);this._scene.updateMatrixWorld(!0),this._controls=new T6e(m),this._animationControls=new XGe(this._scene,this._requestRenderAutoMode),this._eventManager=new EVe(s.scene.publish,this._controls,this._animationControls,m,s.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),t&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let f=s.scene.publish.htmlContent?.html;if(t&&f&&this._htmlContentMode!=="none"){let m={shared:this._sharedAssetsManager,findEntity:g=>this._scene?.getObjectByProperty("uuid",g)??this._scene?.getObjectByName(g),getAnimationControls:()=>this._animationControls};this._htmlContentOverlay=(this._htmlContentMode==="inline"?RPe.mount(this,this.canvas,f,m):PPe.mount(this,this.canvas,f,m))??void 0}}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){if(t==null)return void console.warn(`Variable ${e} was not updated: received ${t}. Pass a number, boolean or string.`);let r=t;if(typeof i.data.value=="number"){if(r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t),!Number.isFinite(r))return void console.warn(`Variable ${e} is a number variable and ${JSON.stringify(t)} cannot be converted to a number. The variable was not updated.`)}else typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()!=="false"&&!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let n=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,n),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&So.isTextValue(e)?So.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(!(t.uuid===f1||this._scene.isInvisibleObjects(t)||t instanceof Dn)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof I3e&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=T1e(e);this._scene?.activePage.setBackgroundColor(t),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,HE&&HE.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{Y9.unsubscribe(e)}),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(e){e.removeEventListener("pointerdown",Oee,!0),e.removeEventListener("pointerdown",T3,!0),e.removeEventListener("pointermove",T3,!0),e.removeEventListener("pointerup",Y1,!0),e.removeEventListener("pointercancel",Y1,!0),e.removeEventListener("pointerleave",Y1,!0),window.removeEventListener("keydown",Lee,!0),window.removeEventListener("keyup",Bee,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Bs.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(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t,i=this._scene;if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);e.traverseAncestors(u=>{u instanceof Dn&&(t=u.name)});let r=this._sharedAssetsManager,n={shared:r,scene:this._scene},s=u=>{if(u===null||u==="Base State")return null;if(u&&e.data.states){let d=e.data.states.find(c=>c.data.name===u);return d?d.id:void 0}},a="material"in e?e.material:void 0,o=e.materialOverride,l={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,material:o??(a?wje(a):void 0),parentUuid:e.parent instanceof Dn||e instanceof zg?void 0:e.parent?.uuid,emitEvent(u){e.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){e.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){e.visible&&(e.visible=!1,n.shared.requestRender())},show(){e.visible||(e.visible=!0,n.shared.requestRender())},get state(){let u=e.stateSelection;if(u!==null)return e.data.states.find(({id:d})=>d===u)?.data.name},set state(u){let d;if(u!==void 0){let c=typeof u=="string"?e.data.states.find(({id:p})=>p===u):e.data.states[u];if(c)d=c.id;else{let p=typeof u=="string"?s(u):void 0;p&&(d=p)}}e.changeSelectedState(d??null,n),e.currentState=d??null,e.dispatchEvent({type:"completeState",state:d??null}),n.shared.requestRender()},transition(u){let d=EPe;if(d===null)return Ta("transitions","obj.transition()"),{transition(b){return this},play(){return this},pause(){return this},reset(){return this},seek(b){return this}};let c,p,f=this,m=[],g=!1,v=()=>{p=new uPe({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},m.map(b=>b.runner))},y={update(b){p?.update(b),p?.isPlaying!==!0&&Bs.remove(y)}},_={transition({from:b,to:x,duration:w,delay:S,...T}){let M=s(b);M===void 0&&(M=c);let E=s(x);return c=E,m.push(new d(e,M,E,{state:E,repeat:0,delay:S??0,delayDirection:"start-once",direction:"normal",duration:w??1e3,...T,...T.easing===6?Ng.defaultData:T.easing===5?lw.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(b&&M||b==="Base State"&&!M)&&(f.state=M??void 0)},onComplete:()=>{f.state=E??void 0}})),v(),this},play(){return p?(g=!0,p.play(Bs.time),p.isPlaying&&Bs.add(y),this):this},pause(){return p?.stop(),Bs.remove(y),this},reset(){return this.pause(),g=!1,v(),p?.seek(0),this},seek(b){let x=m.reduce((w,S)=>w+S.runner.duration,0);return x>0&&p?.seek(b/1e3/x),this}};return _.transition(u),(u.autoPlay??!0)&&queueMicrotask(()=>{g||_.play()}),_},set color(u){let d=T1e(u);if(v4.is(e))return void(e.color=d);if(!(e.type==="Mesh"&&"material"in e&&e instanceof _l))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=e.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(u),n.shared.requestRender()))}let f=Array.isArray(e.material)?e.material[0]:e.material,m=f.data.layers.find(g=>g.data.type==="color")?.id;if(m)f.updateByOp({type:0,path:["layers",m],props:{color:{...c}}},f.data,n);else{let g=f.data,v=g.layers.find(S=>S.data.type==="light");if(!v)return;let y=g.layers.indexOf(v)===0?v:null,_=g.layers.at(y?g.layers.indexOf(y)+1:0),b={type:4,fi:y?y.fi+(_?(_.fi-y.fi)/2:1):_?_.fi/2:1,id:Qe.generateUUID(),data:{...ts.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(y?.id??null,1),w=g.layers.runOp({...b,fi:x[0]}).data;Object.assign(f.data,{layers:w}),f.updateByOp({...b,path:["layers"]},f.data,n)}}},h=Y9(l,(u,d)=>{let c=e[u],p=function(f){return f.split(".")}(u);p[0]==="material"&&a&&o===void 0&&function(f,m,g){let v=Array.isArray(g)?g[0]:g;if(f[0]==="layers"){let y=parseInt(f[1]),_=v.layers[y],b=f[2];_&&b&&function(x,w,S){let T=x[0];try{if(function(M,E){return!!Tje[E]?.includes(M)}(T,S.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let M=parseInt(x[1]),E=S.getValue(T)?.[M];if(!E)throw new Error("Color index out of range");AM.setStyle(w),E.set(AM.r,AM.g,AM.b,AM.a)}else S.getValue(T)?.setStyle(w);else if(T==="texture"||T==="video"){let M=S.color;(function(E,A,C,D){let R=E[0];if(R==="repeat"||R==="offset"||R==="rotation"){let I=D.getNode("mat"),U=I&&typeof I.updateMatrix=="function"?I:D.getValue("mat");if(!U)return;if(R==="rotation")U.rotation=parseFloat(A);else{let O=E[1];if(O===void 0)A instanceof Array&&A.length===2&&Object.assign(U,{[R]:A});else{let k=U[R],G=parseInt(O)===0?[parseFloat(A),k[1]]:[k[0],parseFloat(A)];Object.assign(U,{[R]:G})}}U.updateMatrix()}else R==="wrapping"||R==="minFilter"||R==="magFilter"?R==="wrapping"?C.texture.wrap=A:C.texture[R]=A:R==="image"&&E[1]==="data"&&C.texture.image.updateSrc(A)})(x.slice(1),w,M,S)}else{let M=x[1],E=S.getValue(T);E?.isVector3&&M!==void 0||E?.isVector2&&M!==void 0?E.setComponent(parseInt(M),w):S.setValue(T,w)}}catch(M){console.error("Error setting material value",M)}}(f.slice(2),m,_)}else f[0]==="alpha"&&v.layers.forEach(y=>{y.type==="light"&&y.node.alphaOverride!==void 0&&(y.node.alphaOverride.value=m,m<1&&(v.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(e,u)?.writable&&(e[u]=d),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,h),h}setUIWasmUrl(e){(function(t){s4=t,DB?.setHanaUIWasmUrl(t)})(e)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if(typeof t=="string"){if(!t.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(t)).arrayBuffer();i=new Uint8Array(l)}}else i=t;let r=LA.deserialize(i),n="data"in r&&r.data.draco!==void 0;n&&await g1e(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!s)return void console.warn(`Object ${e} not found`);if(s.data.type!=="Mesh"||!(s instanceof _l))return void console.warn(`Object ${e} is not a mesh`);let a=s,o={...a.data,geometry:r};n&&await v1e([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]=Og.patch(o,h)}return i}_applyDocumentTransaction(e){this._data=e.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let t of e.actual){let i=t.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...t,path:[]},this._sharedAssetsManager)}}_findEntity(e){return this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e)}_resolveParentId(e){if(e===void 0)return this._scene.activePage.uuid;let t=typeof e=="string"?e:e.uuid,i=this._findEntity(t);if(!i)throw new Error(`parent '${t}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(e){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof e!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let t=KH();if(t===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(N9(),QO)),t=KH()),t===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=e(t);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(e,t){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 e=="string"?e:e.uuid,n=this._findEntity(r);if(!n)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(n instanceof _l))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let s=typeof t=="function"?await this.createCustomMaterial(t):t;if(f4()!=="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=b1e({material:s});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return n.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(n.uuid),this._requestRenderAutoMode(),a.material}async createObject(e,t={}){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 n=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${x1e}.`);let v=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),y=fje[v];if(y)return{objectType:y};let _=pje[v];if(_)return{objectType:"Mesh",geometryType:_};let b=mje[v];throw b?new Error(`createObject: '${g}' is not supported \u2014 ${b}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${x1e}, e.g. createObject('Cube', { width: 200 }).`)}(e);typeof t.material=="function"&&(t={...t,material:await this.createCustomMaterial(t.material)});let s,a,{options:o,material:l}=b1e(t);if(l!==void 0){if(n.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(f4()!=="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(n.geometryType==="TextGeometry"){if(!GY.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 Zve(),a=t.font??Fb,r.shared.fonts[a]===void 0){if(a!==Fb){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}s={name:Fb,url:Ebe}}}let h=this._resolveParentId(t.parent),u=bje(n,o,r),d=Qe.generateUUID(),[c,p]=VM(r);s&&(c.shared.fonts[Fb]=s),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let f=p.result();if(s&&this._sharedAssetsManager.addFont(Fb,s),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(f);let m=i.find(d);return l!==void 0&&m.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(m)}cloneObject(e,t={}){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 n=typeof e=="string"?e:e?.uuid,s=n?this._findEntity(n):void 0;if(!s)throw new Error(`cloneObject: '${n}' \u2014 no object with that name or uuid in the scene.`);if(s instanceof Dn)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(s.uuid);if(!a)throw new Error(`cloneObject: '${n}' 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,f,m){let g={...p.data};return f.position!==void 0&&(g.position=sC(f.position,[0,0,0])),f.rotation!==void 0&&(g.rotation=sC(f.rotation,[0,0,0])),f.scale!==void 0&&(g.scale=NPe(f.scale)),f.visible!==void 0&&(g.visible=f.visible),g.name=f.name??IPe(`${p.data.name??"Object"} Copy`,m),{...p,data:g}}(xje(a),t,r.scene.objects),l=t.parent!==void 0?this._resolveParentId(t.parent):r.scene.objects.parent(s.uuid)??null,h=t.parent!==void 0?null:s.uuid,[u,d]=VM(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(e){let t=this._scene,i=this._data;if(this.disposed||!t||!i)return!1;let r=typeof e=="string"?e:e?.uuid,n=r?this._findEntity(r):void 0;if(!n)return!1;if(n instanceof Dn)throw new Error("removeObject: pages cannot be removed.");if(n.data.type==="PerspectiveCamera"||n.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(n.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 s=[];n.traverseEntity(l=>{s.push(l.uuid)});let[a,o]=VM(i);a.scene.objects.delete(n.uuid),this._applyDocumentTransaction(o.result());for(let l of s){let h=this._proxyObjectCache.get(l);h&&(Y9.unsubscribe(h),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var yF=window,_F=yF.ShadowRoot&&(yF.ShadyCSS===void 0||yF.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,GZ=Symbol(),BPe=new WeakMap,EC=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==GZ)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(_F&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=BPe.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&BPe.set(i,t))}return t}toString(){return this.cssText}},FPe=e=>new EC(typeof e=="string"?e:e+"",void 0,GZ),jZ=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,n,s)=>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.")})(n)+e[s+1],e[0]);return new EC(i,e,GZ)},WZ=(e,t)=>{_F?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),n=yF.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=i.cssText,e.appendChild(r)})},bF=_F?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return FPe(i)})(e):e;var HZ,xF=window,UPe=xF.trustedTypes,Eje=UPe?UPe.emptyScript:"",zPe=xF.reactiveElementPolyfillSupport,$Z={toAttribute(e,t){switch(t){case Boolean:e=e?Eje:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},kPe=(e,t)=>t!==e&&(t==t||e==e),qZ={attribute:!0,type:String,converter:$Z,reflect:!1,hasChanged:kPe},XZ="finalized",em=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let n=this._$Ep(r,i);n!==void 0&&(this._$Ev.set(n,r),t.push(n))}),t}static createProperty(t,i=qZ){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,n=this.getPropertyDescriptor(t,r,i);n!==void 0&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(n){let s=this[t];this[i]=n,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||qZ}static finalize(){if(this.hasOwnProperty(XZ))return!1;this[XZ]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let n of r)this.createProperty(n,i[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let n of r)i.unshift(bF(n))}else t!==void 0&&i.push(bF(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return WZ(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=qZ){var n;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let a=(((n=r.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?r.converter:$Z).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(t,i){var r;let n=this.constructor,s=n._$Ev.get(t);if(s!==void 0&&this._$El!==s){let a=n.getPropertyOptions(s),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:$Z;this._$El=s,this[s]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let n=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||kPe)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((n,s)=>this[s]=n),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(n=>{var s;return(s=n.hostUpdate)===null||s===void 0?void 0:s.call(n)}),this.update(r)):this._$Ek()}catch(n){throw i=!1,this._$Ek(),n}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var n;return(n=r.hostUpdated)===null||n===void 0?void 0:n.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};em[XZ]=!0,em.elementProperties=new Map,em.elementStyles=[],em.shadowRootOptions={mode:"open"},zPe?.({ReactiveElement:em}),((HZ=xF.reactiveElementVersions)!==null&&HZ!==void 0?HZ:xF.reactiveElementVersions=[]).push("1.6.3");var YZ,wF=window,Hw=wF.trustedTypes,VPe=Hw?Hw.createPolicy("lit-html",{createHTML:e=>e}):void 0,ZZ="$lit$",c0=`lit$${(Math.random()+"").slice(9)}$`,XPe="?"+c0,Aje=`<${XPe}>`,w1=document,CC=()=>w1.createComment(""),PC=e=>e===null||typeof e!="object"&&typeof e!="function",YPe=Array.isArray,Cje=e=>YPe(e)||typeof e?.[Symbol.iterator]=="function",KZ=`[
|
|
13046
13046
|
\f\r]`,AC=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,GPe=/-->/g,jPe=/>/g,b1=RegExp(`>|${KZ}(?:([^\\s"'>=/]+)(${KZ}*=${KZ}*(?:[^
|
|
13047
13047
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),WPe=/'/g,HPe=/"/g,KPe=/^(?:script|style|textarea|title)$/i,ZPe=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),QPe=ZPe(1),Unt=ZPe(2),S1=Symbol.for("lit-noChange"),eo=Symbol.for("lit-nothing"),qPe=new WeakMap,x1=w1.createTreeWalker(w1,129,null,!1);function JPe(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return VPe!==void 0?VPe.createHTML(t):t}var Pje=(e,t)=>{let i=e.length-1,r=[],n,s=t===2?"<svg>":"",a=AC;for(let o=0;o<i;o++){let l=e[o],h,u,d=-1,c=0;for(;c<l.length&&(a.lastIndex=c,u=a.exec(l),u!==null);)c=a.lastIndex,a===AC?u[1]==="!--"?a=GPe:u[1]!==void 0?a=jPe:u[2]!==void 0?(KPe.test(u[2])&&(n=RegExp("</"+u[2],"g")),a=b1):u[3]!==void 0&&(a=b1):a===b1?u[0]===">"?(a=n??AC,d=-1):u[1]===void 0?d=-2:(d=a.lastIndex-u[2].length,h=u[1],a=u[3]===void 0?b1:u[3]==='"'?HPe:WPe):a===HPe||a===WPe?a=b1:a===GPe||a===jPe?a=AC:(a=b1,n=void 0);let p=a===b1&&e[o+1].startsWith("/>")?" ":"";s+=a===AC?l+Aje:d>=0?(r.push(h),l.slice(0,d)+ZZ+l.slice(d)+c0+p):l+c0+(d===-2?(r.push(void 0),o):p)}return[JPe(e,s+(e[i]||"<?>")+(t===2?"</svg>":"")),r]},T1=class{constructor({strings:t,_$litType$:i},r){let n;this.parts=[];let s=0,a=0,o=t.length-1,l=this.parts,[h,u]=Pje(t,i);if(this.el=T1.createElement(h,r),x1.currentNode=this.el.content,i===2){let d=this.el.content,c=d.firstChild;c.remove(),d.append(...c.childNodes)}for(;(n=x1.nextNode())!==null&&l.length<o;){if(n.nodeType===1){if(n.hasAttributes()){let d=[];for(let c of n.getAttributeNames())if(c.endsWith(ZZ)||c.startsWith(c0)){let p=u[a++];if(d.push(c),p!==void 0){let f=n.getAttribute(p.toLowerCase()+ZZ).split(c0),m=/([.?@])?(.*)/.exec(p);l.push({type:1,index:s,name:m[2],strings:f,ctor:m[1]==="."?JZ:m[1]==="?"?eQ:m[1]==="@"?tQ:$w})}else l.push({type:6,index:s})}for(let c of d)n.removeAttribute(c)}if(KPe.test(n.tagName)){let d=n.textContent.split(c0),c=d.length-1;if(c>0){n.textContent=Hw?Hw.emptyScript:"";for(let p=0;p<c;p++)n.append(d[p],CC()),x1.nextNode(),l.push({type:2,index:++s});n.append(d[c],CC())}}}else if(n.nodeType===8)if(n.data===XPe)l.push({type:2,index:s});else{let d=-1;for(;(d=n.data.indexOf(c0,d+1))!==-1;)l.push({type:7,index:s}),d+=c0.length-1}s++}}static createElement(t,i){let r=w1.createElement("template");return r.innerHTML=t,r}};function qw(e,t,i=e,r){var n,s,a,o;if(t===S1)return t;let l=r!==void 0?(n=i._$Co)===null||n===void 0?void 0:n[r]:i._$Cl,h=PC(t)?void 0:t._$litDirective$;return l?.constructor!==h&&((s=l?._$AO)===null||s===void 0||s.call(l,!1),h===void 0?l=void 0:(l=new h(e),l._$AT(e,i,r)),r!==void 0?((a=(o=i)._$Co)!==null&&a!==void 0?a:o._$Co=[])[r]=l:i._$Cl=l),l!==void 0&&(t=qw(e,l._$AS(e,t.values),l,r)),t}var QZ=class{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;let{el:{content:r},parts:n}=this._$AD,s=((i=t?.creationScope)!==null&&i!==void 0?i:w1).importNode(r,!0);x1.currentNode=s;let a=x1.nextNode(),o=0,l=0,h=n[0];for(;h!==void 0;){if(o===h.index){let u;h.type===2?u=new M1(a,a.nextSibling,this,t):h.type===1?u=new h.ctor(a,h.name,h.strings,this,t):h.type===6&&(u=new iQ(a,this,t)),this._$AV.push(u),h=n[++l]}o!==h?.index&&(a=x1.nextNode(),o++)}return x1.currentNode=w1,s}v(t){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,i),i+=r.strings.length-2):r._$AI(t[i])),i++}},M1=class{constructor(t,i,r,n){var s;this.type=2,this._$AH=eo,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=r,this.options=n,this._$Cp=(s=n?.isConnected)===null||s===void 0||s}get _$AU(){var t,i;return(i=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&i!==void 0?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode,i=this._$AM;return i!==void 0&&t?.nodeType===11&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=qw(this,t,i),PC(t)?t===eo||t==null||t===""?(this._$AH!==eo&&this._$AR(),this._$AH=eo):t!==this._$AH&&t!==S1&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Cje(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==eo&&PC(this._$AH)?this._$AA.nextSibling.data=t:this.$(w1.createTextNode(t)),this._$AH=t}g(t){var i;let{values:r,_$litType$:n}=t,s=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=T1.createElement(JPe(n.h,n.h[0]),this.options)),n);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===s)this._$AH.v(r);else{let a=new QZ(s,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(t){let i=qPe.get(t.strings);return i===void 0&&qPe.set(t.strings,i=new T1(t)),i}T(t){YPe(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,n=0;for(let s of t)n===i.length?i.push(r=new M1(this.k(CC()),this.k(CC()),this,this.options)):r=i[n],r._$AI(s),n++;n<i.length&&(this._$AR(r&&r._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,i);t&&t!==this._$AB;){let n=t.nextSibling;t.remove(),t=n}}setConnected(t){var i;this._$AM===void 0&&(this._$Cp=t,(i=this._$AP)===null||i===void 0||i.call(this,t))}},$w=class{constructor(t,i,r,n,s){this.type=1,this._$AH=eo,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=eo}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,r,n){let s=this.strings,a=!1;if(s===void 0)t=qw(this,t,i,0),a=!PC(t)||t!==this._$AH&&t!==S1,a&&(this._$AH=t);else{let o=t,l,h;for(t=s[0],l=0;l<s.length-1;l++)h=qw(this,o[r+l],i,l),h===S1&&(h=this._$AH[l]),a||(a=!PC(h)||h!==this._$AH[l]),h===eo?t=eo:t!==eo&&(t+=(h??"")+s[l+1]),this._$AH[l]=h}a&&!n&&this.j(t)}j(t){t===eo?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},JZ=class extends $w{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===eo?void 0:t}},Rje=Hw?Hw.emptyScript:"",eQ=class extends $w{constructor(){super(...arguments),this.type=4}j(t){t&&t!==eo?this.element.setAttribute(this.name,Rje):this.element.removeAttribute(this.name)}},tQ=class extends $w{constructor(t,i,r,n,s){super(t,i,r,n,s),this.type=5}_$AI(t,i=this){var r;if((t=(r=qw(this,t,i,0))!==null&&r!==void 0?r:eo)===S1)return;let n=this._$AH,s=t===eo&&n!==eo||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,a=t!==eo&&(n===eo||s);s&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){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,t):this._$AH.handleEvent(t)}},iQ=class{constructor(t,i,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){qw(this,t)}};var $Pe=wF.litHtmlPolyfillSupport;$Pe?.(T1,M1),((YZ=wF.litHtmlVersions)!==null&&YZ!==void 0?YZ:wF.litHtmlVersions=[]).push("2.8.0");var RC=(e,t,i)=>{var r,n;let s=(r=i?.renderBefore)!==null&&r!==void 0?r:t,a=s._$litPart$;if(a===void 0){let o=(n=i?.renderBefore)!==null&&n!==void 0?n:null;s._$litPart$=a=new M1(t.insertBefore(CC(),o),o,void 0,i??{})}return a._$AI(e),a};var rQ,nQ;var p0=class extends em{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;let r=super.createRenderRoot();return(t=(i=this.renderOptions).renderBefore)!==null&&t!==void 0||(i.renderBefore=r.firstChild),r}update(t){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=RC(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return S1}};p0.finalized=!0,p0._$litElement$=!0,(rQ=globalThis.litElementHydrateSupport)===null||rQ===void 0||rQ.call(globalThis,{LitElement:p0});var eRe=globalThis.litElementPolyfillSupport;eRe?.({LitElement:p0});((nQ=globalThis.litElementVersions)!==null&&nQ!==void 0?nQ:globalThis.litElementVersions=[]).push("3.3.3");var tRe=e=>t=>typeof t=="function"?((i,r)=>(customElements.define(i,r),r))(e,t):((i,r)=>{let{kind:n,elements:s}=r;return{kind:n,elements:s,finisher(a){customElements.define(i,a)}}})(e,t);var Dje=(e,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}},Nje=(e,t,i)=>{t.constructor.createProperty(i,e)};function Bh(e){return(t,i)=>i!==void 0?Nje(e,t,i):Dje(e,t)}var sQ,dst=((sQ=window.HTMLSlotElement)===null||sQ===void 0?void 0:sQ.prototype.assignedElements)!=null?(e,t)=>e.assignedElements(t):(e,t)=>e.assignedNodes(t).filter(i=>i.nodeType===Node.ELEMENT_NODE);var SF=window.IntersectionObserver!=null;var iRe=(e=32,t=2)=>{let i=e/2;return QPe` <style>
|
|
13048
13048
|
:host {
|