@splinetool/loader 2.0.38 → 2.0.40

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.
@@ -1,4 +1,4 @@
1
- var eL=Object.create;var th=Object.defineProperty;var tL=Object.getOwnPropertyDescriptor;var rL=Object.getOwnPropertyNames;var iL=Object.getPrototypeOf,nL=Object.prototype.hasOwnProperty;var oL=(n,t,e)=>t in n?th(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Me=(n,t)=>()=>(n&&(t=n(n=0)),t);var rh=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),aL=(n,t)=>{for(var e in t)th(n,e,{get:t[e],enumerable:!0})},sL=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rL(t))!nL.call(n,i)&&i!==e&&th(n,i,{get:()=>t[i],enumerable:!(r=tL(t,i))||r.enumerable});return n};var Bd=(n,t,e)=>(e=n!=null?eL(iL(n)):{},sL(t||!n||!n.__esModule?th(e,"default",{value:n,enumerable:!0}):e,n));var Ur=(n,t,e)=>(oL(n,typeof t!="symbol"?t+"":t,e),e);var Gw=Me(()=>{"use strict"});function ih(n){return Array.isArray(n)?n:[n]}function $a(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Uw=Me(()=>{"use strict"});function nr(n,t){return Object.setPrototypeOf(n,t),n}function nh(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function wn(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let o=n;n=t,t=o}let r=[],i=1/(e+1);for(let o=0;o<e;o++){let a=n+(t-n)*(o+.75+Math.random()*.5)*i;r.push(a)}return r}function pi(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function zw(){return typeof process<"u"}var jw=Me(()=>{"use strict"});function Nd(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Nd(r)}return Object.freeze(n)}function oh(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}var Hw=Me(()=>{"use strict"});var Zt=Me(()=>{Gw();Uw();jw();Hw()});var ah,es,Ld,sh=Me(()=>{"use strict";ah=class{},es=class extends ah{constructor(e){super();this.id=e}},Ld=class extends ah{constructor(e){super();this.data=e}}});var Ww=Me(()=>{"use strict"});var Se,_d=Me(()=>{"use strict";Se=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o={...r,[t]:e};return Object.setPrototypeOf(o,Se.prototype),o}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:o,data:a}=t,s={...e,[o]:a};return Object.setPrototypeOf(s,Se.prototype),{data:s,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let o={...e};return Object.setPrototypeOf(o,Se.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:i}}}}return null}}});var nl,lh=Me(()=>{"use strict";nl=class extends Error{}});function qw(n,t){for(let e of n)t(e.id,e.data)!==!0&&qw(e.children,t)}function Xw(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Xw(e,t)}var bt,oa=Me(()=>{"use strict";Zt();lh();Zt();bt=class extends Array{constructor(...e){super(...e);Ur(this,"partialObjectCaches");Ur(this,"objCaches");Ur(this,"parentCaches");Object.setPrototypeOf(this,bt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nd(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);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,r){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let i=this.parent(e);if(i===r)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 r=this.get(e);r!==void 0&&this.partialObjectCaches.set(e,r)}get(e){if(this.partialObjectCaches!==void 0){let r=this.partialObjectCaches.get(e);if(r!==void 0)return r}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let i=this.get(e);i&&Xw(i,r)}}traverse(e){qw(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),a=this.childrenArray(o),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];a=[...a],a[s]={...l,data:r};let c=new Map;return c.set(e,a[s]),this.modifyArrayBy(o,a,c)}}modifyArrayBy(e,r,i=void 0){let o=e,a=r;for(;o!==null;){let l=a,c=o;if(o=this.parent(o),o===void 0)throw new Error;a=this.childrenArray(o);let d=a.findIndex(u=>u.id===c);if(d<0)throw new Error;a=[...a],a[d]={...a[d],children:l},i&&i.set(c,a[d])}Object.setPrototypeOf(a,bt.prototype);let s=a;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[l,c]of i)s.objCaches.set(l,c);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:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:o,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),d={fi:i,id:o,data:a,children:s};return c=[...c,d],c.sort((p,h)=>p.fi-h.fi),e.localIndex=c.indexOf(d),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let o=this.childrenArray(i),a=o.findIndex(c=>c.id===r);e.localIndex=a,o=[...o];let s=o.splice(a,1)[0];return{data:this.modifyArrayBy(i,o),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:r,fi:i,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let h=r;for(;h!==null;){if(h===void 0)throw new Error;if(h===o)throw new nl("cyclic tree");h=this.parent(h)}}let a=this.parent(o);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(h=>h.id===o);l=[...l];let d=l.splice(c,1)[0],u=this.modifyArrayBy(a,l);a=r,l=u.childrenArray(a);let p=d.fi;return d={...d,fi:i},l=[...l,d],l.sort((h,f)=>h.fi-f.fi),e.localIndex=l.indexOf(d),u=u.modifyArrayBy(a,l),{data:u,actual:e,reverse:{type:9,parent:s,fi:p,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let i=null;for(let o of this.childrenArray(e)){if(o.id===r)return i;i=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(a=>a.id===e)+1;if(o<i.length)return i[o].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(a=>a.id===e)-1;return o>=0?this.traverseSortPrevious(i[o].id):r}}getAllSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i.id);o!==void 0&&r.push({...i,...o})}r.sort((i,o)=>$a(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r}getAllIdSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i);o!==void 0&&r.push(o)}r.sort((i,o)=>$a(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r.map(i=>i.id)}getWithSortKey(e){let r=e,i=[],o=this.get(r),a=o;if(o!==void 0){for(;r;)i.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return{...a,sortKey:i}}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let o=this.childrenArray(e);if(r===null){if(o.length===0)return wn(0,i,i);{let a=o[0].fi;return wn(a-i,a,i)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=o.find(l=>l.fi>a.fi);if(s===void 0){let l=o[o.length-1].fi;return wn(l,l+i,i)}else return wn(a.fi,s.fi,i)}}}});var Mv,aa,ch=Me(()=>{"use strict";Zt();Mv=null;(r=>{function n(i){Mv=i}r.setPreservePrototype=n;function t(i,o){return Object.getPrototypeOf(i)===Mv&&Object.setPrototypeOf(o,Mv),o}r.tryPreservePrototype=t;function e(i,o){if(o.type!==0)return null;if(Array.isArray(i)||pi(i)){let a=o.props,s={},l=pi(i)?i.slice():[...i],c=!1;if(a)for(let d of Object.keys(a)){let u=parseInt(d);if(isNaN(u))throw new Error("wrong index");s[d]=l[u],l[u]=a[d],c=!0}return c?{data:l,actual:o,reverse:{type:0,props:s}}:null}else{let a=o.props,s={},l={...i},c=!1;if(a)for(let d of Object.keys(a)){s[d]=l[d];let u=a[d];u===void 0?delete l[d]:l[d]=u,c=!0}return c?{data:r.tryPreservePrototype(i,l),actual:o,reverse:{type:0,props:s}}:null}}r.runOp=e})(aa||(aa={}))});var fe,sa=Me(()=>{"use strict";Zt();Zt();fe=class extends Array{constructor(...e){super(...e);Ur(this,"objCaches");Object.setPrototypeOf(this,fe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nd(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=o[a];return o=[...o],o[a]={...s,data:r},this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,fe.prototype);let r=e;return zw()||r.fillCaches(),r}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:r,id:i,data:o}=e,a=this,s={fi:r,id:i,data:o};return a=[...a,s],a.sort((c,d)=>c.fi-d.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,o=i.findIndex(l=>l.id===r);if(o===-1)return null;e.localIndex=o,i=[...i];let a=i.splice(o,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:i}=e,o=this;o=[...o];let a=o.findIndex(d=>d.id===i);if(a===-1)return null;let s=o[a].fi,l={...o[a],fi:r};return o[a]=l,o.sort((d,u)=>d.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(o),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 r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return wn(0,r,r);{let o=i[0].fi;return wn(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let a=i.find(s=>s.fi>o.fi);if(a===void 0){let s=i[i.length-1].fi;return wn(s,s+r,r)}else return wn(o.fi,a.fi,r)}}}});function Yw(n,t){let e={cur:[],result:[],len:0};return n=Fd(n,t,e)??n,[n,e.result]}function dh(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function uh(n){n&&(n.len-=1)}function lL(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Qw(n,t,e){let r=!1,i=n.map(o=>{let a=o.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Fd(o.data,t,dh(e,a));uh(e),r=r||l!==void 0,l===void 0&&(l=o.data);let c=Qw(o.children,t,e);return c!==void 0?r=!0:c=o.children,{...o,id:a,data:l,children:c}});if(r)return i}function cL(n,t,e){let r=!1,i=n.map(o=>{let a=o.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Fd(o.data,t,dh(e,a));return uh(e),r=r||l!==void 0,l===void 0&&(l=o.data),{...o,id:a,data:l}});if(r)return Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i}function Fd(n,t,e){if(n instanceof bt){let r=Qw(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof fe)return cL(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((o,a)=>{let s=Fd(o,t,dh(e,a));return uh(e),r=r||s!==void 0,s===void 0&&(s=o),s});return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i):void 0}else if(n&&typeof n=="object"&&!pi(n)){let r={},i=!1;for(let[o,a]of Object.entries(n))if(o!=="name"&&o!=="variableId"){let s=t[o];if(typeof s=="string"){if(e!==null)throw new Error("not supported");i=!0,o=s}let l=Fd(a,t,dh(e,o));uh(e),i=i||l!==void 0,l===void 0&&(l=a),r[o]=l}else r[o]=a;return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&lL(e),r}else return}}var Ov=Me(()=>{"use strict";oa();sa();Zt()});function ol(n){return n&&typeof n=="object"&&n instanceof Ct}function Iv(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let o=i.id,a=kd(i.data,t[o]);if(e=e||a!==void 0,a===void 0&&(a=i.data),i.children){let s=Iv(i.children,t);return s!==void 0?e=!0:s=i.children,{...i,id:o,data:a,children:s}}else return{...i,id:o,data:a}});if(e)return r}function dL(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let o=i.id,a=kd(i.data,t[o]);return e=e||a!==void 0,a===void 0&&(a=i.data),{...i,id:o,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function kd(n,t){if(!ol(t))return t;if(n instanceof bt){let e=Iv(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof fe)return dL(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,o)=>{let a=kd(i,t[o]);return e=e||a!==void 0,a===void 0&&(a=i),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof Ct)return Dv(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,o]of Object.entries(n)){let a=kd(o,t[i]);r=r||a!==void 0,a===void 0&&(a=o),e[i]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Dv(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ol(t))return t;if(!ol(n))return An.apply(n,t);let e=new Set;for(let i of Object.keys(n))e.add(i);for(let i of Object.keys(t))e.add(i);let r=new Ct;for(let i of e){let o=Dv(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=o}return r}var Ct,An,ph=Me(()=>{"use strict";oa();sa();Vd();Zt();Ct=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,o={};for(;i<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[i]],r!==void 0&&!ol(r))return null;i+=1}r=r?nh(r):new Ct;for(let[l,c]of Object.entries(t.props)){let d=r[l];o[l]=d,c===void 0?delete r[l]:r[l]=c}for(;i>0;){if(Object.keys(r).length===0){let l=e[i-1];l&&(r=nh(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=nh(l);c[t.path[i-1]]=r,r=c}else{let c=new Ct;c[t.path[i-1]]=r,r=c}}i-=1}let a=Object.setPrototypeOf(r,Ct.prototype),s={...t,props:o};return{data:a,actual:t,reverse:s}}};(r=>{function n(i,o){return kd(i,o)??i}r.apply=n;function t(i,o){return Dv(i,o)}r.merge=t;function e(i,o){let a=0,s=o.path,l=i;for(;a<s.length&&l!==void 0;){if(l=Ot.zoomOnce(l,s[a]),l===void 0)return o;if(!ol(l))return;a+=1}if(l===void 0)return o;if(!!ol(l))if(o.type===0){let c={...o.props};for(let d of Object.keys(l))delete c[d];return{...o,props:c}}else if(o.type===1||o.type===4||o.type===7){let c=Iv([o],l);return c?c[0]:o}else return o}r.filterOp=e})(An||(An={}))});var al,zt,Rv,Kw=Me(()=>{"use strict";Zt();Vd();_d();oa();lh();ch();sa();Ov();ph();(t=>{function n(e,r){let i=Ot.zoom(r,e.path);if(typeof i=="object"){let o={};for(let a of Object.keys(e.props))o[a]=i[a];return{...e,props:o}}else return{...e,props:{}}}t.replaceProps=n})(al||(al={}));(s=>{function n(l,c){return{...l,path:l.path.slice(c)}}s.drop=n;function t(l,c){return e(l,c)?.data??l}s.applySimple=t;function e(l,c){let d=c.path,u=[];for(;;){let p;if(l instanceof Ct&&c.type===0&&(p=l.runOp({...c,path:d.slice(u.length)}),p===null&&(p=void 0)),p===void 0&&u.length===d.length&&(l instanceof bt||l instanceof fe||l instanceof Se?p=l.runOp(c):p=aa.runOp(l,c)),p!==void 0)if(p!==null){let m=p.data;for(let y=u.length-1;y>=0;y--){let g=d[y],b=u[y];if(b instanceof bt){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof fe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Se){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Ct){let x={...b,[g]:m};m=Object.setPrototypeOf(x,Ct.prototype)}else if(typeof b=="object")if(Array.isArray(b)||pi(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let x=m;m=pi(b)?b.slice():[...b],m[g]=x}else m=aa.tryPreservePrototype(b,{...b,[g]:m});else return null}return{data:m,actual:{...p.actual,path:d},reverse:{...p.reverse,path:d}}}else return null;let h=d[u.length],f;if(l instanceof bt){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else if(l instanceof fe){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else l!==null&&(f=l[h]);if(f!==void 0)u.push(l),l=f;else return null}}s.apply=e;function r(l,c){for(let d=0;d<l.length&&d<c.length;d++)if(l[d]!==c[d])return!0;return!1}s.pathDisjoint=r;function i(l,c){if(l.length!==c.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==c[d])return!1;return!0}s.pathEq=i;function o(l,c){return r(l.path,c.path)}s.commutative=o;function a(l,c){return l.type===0&&c.type===0&&i(l.path,c.path)?Object.keys(l.props).every(d=>c.props[d]!==void 0):!1}s.subsumed=a})(zt||(zt={}));(l=>{function n(){return[]}l.empty=n;function t(c,d){let u=[];for(let p of c){let[h,...f]=p.path;h===d&&u.push({...p,path:f})}return u}l.removePrefix=t;function e(c,d){return c.map(u=>({...u,path:[d,...u.path]}))}l.addPrefix=e;function r(c,d){return[...c,...d]}l.concat=r;function i(c,d){return[...c.filter(p=>!d.some(h=>zt.subsumed(p,h))),...d]}l.compress=i;function o(c,d){return c.every(u=>d.every(p=>zt.commutative(u,p)))}l.commutative=o;function a(c,d){for(let u of d){let p=s(c,u);p!==null&&(c=p.data)}return c}l.applyAll=a;function s(c,d){let u=c,p=[],h=[];for(let f of d)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,y,g;if(f.type===3?(m=Ot.zoom(u,[...f.path,f.id]),g=zt.apply(u,{...f,type:2})):(m=Ot.zoom(u,[...f.path,f.id,"value"]),g=zt.apply(u,f)),g!==null){u=g.data;let[b,x]=Yw(u,{[f.id]:m});u=b;for(let S=0;S<x.length;S++){let v=x[S],w=v.pop();if(typeof w=="number"){let A=[w];for(let P=S+1;P<x.length;P++){let M=x[P],R=M[M.length-1];if(typeof R=="number"&&Ot.equal(v,M.slice(0,M.length-1)))A.push(R),x.splice(P,1);else break}let E=Ot.zoom(u,v);y=E.map((P,M)=>A.includes(M)?f.id:P),m=E,w=v.pop()}else{if(w==="alphaOverride"||w==="alpha"){m/=100;let A=m,E=Ot.zoom(u,v.slice(0,v.length-2)),P=E.layers.map(M=>M.id===v[v.length-1]?{...M,data:{...M.data,[w]:A}}:M);Object.setPrototypeOf(P,Object.getPrototypeOf(E.layers)),E.layers=P}y=f.id}p.push({type:0,path:v,props:{[w]:m}}),h.push({type:0,path:v,props:{[w]:y}})}h.push(g.reverse),p.push(g.actual)}}else{let m=zt.apply(u,f);m!==null&&(p.push(m.actual),u=m.data,h.push(m.reverse))}}catch(m){if(m instanceof nl)return null;throw m}return{data:u,actual:p,reverse:h.reverse()}}l.apply=s})(Rv||(Rv={}))});function Bv(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Ot.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}function mh(n,t,e){return e instanceof bt?new sl(n,t,e):e instanceof fe?new ll(n,t,e):e instanceof Se?new Proxy(new Lv(n,t,e),hL):e!==null&&typeof e=="object"?pi(e)?e:new Proxy(new Nv(n,t,e),pL):e}function _v(n){let t=new hh(n);return[mh(t,"",n),t]}function cl(n,t){let[e,r]=_v(n);return t(e),r.result()}function Ht(n){return n instanceof sl||n instanceof ll?n._current:n!==null&&typeof n=="object"?n[Zw]:n}var Zw,uL,fh,ts,Nv,Lv,Jw,pL,hL,sl,ll,hh,Fv=Me(()=>{"use strict";_d();oa();ch();sa();Zt();Vd();Zw=Symbol(),uL=Symbol(),fh=Symbol(),ts=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let o=r;for(;!(i instanceof hh);){let a=i._path,s=i._current;if(a!==""&&o.splice(0,0,a),i=i._parent,i===null)return;i.update(a,s)}i.push(o,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[fh];r&&r(),delete this._children[t]}}}},Nv=class extends ts{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=aa.tryPreservePrototype(this._current,{...this._current,[t]:e})}runOp(t){this.reportOp(t,aa.runOp(this._current,t),t.path)}},Lv=class extends ts{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Se.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Jw={get(n,t){if(t===fh)return()=>{n._parent=null};if(t===Zw)return n._current;if(t===uL)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e[t],a=mh(n,t,o);return a!==o?(r===void 0&&(r={},n._children=r),r[t]=a,a):o},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},pL={...Jw,set(n,t,e){let r={type:0,props:{[t]:Ht(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},hL={...Jw,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},sl=class extends ts{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fh]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e.get(t)?.data,a=mh(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}add(t,e,r,i,o){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,i[o],a.id,a.data,a.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,i[o],a.id,a.data,a.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,i[o],a)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,i[o],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},ll=class extends ts{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fh]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id,o=this._current[r].fi;t(this.data(this._current[r].id),i,o,r)}}find(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:r}=this._current.at(t);return{id:e,fi:r,data:this.data(e)}}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e.get(t)?.data,a=mh(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};hh=class extends ts{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){Bv(this.ts,e,t),Bv(this.actual,r,t),Bv(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}});var Ot,Vd=Me(()=>{"use strict";sh();Fv();sa();oa();Zt();(o=>{function n(a,s){if(s.length===a.length){let l=0;for(;l<a.length;){if(a[l]!==s[l])return!1;l+=1}}else return!1;return!0}o.equal=n;function t(a,s,l){let c=r(l,a);if(c!==void 0&&typeof c=="object"&&c!==null){let d={...s};return Object.keys(c).forEach(u=>{delete d[u]}),d}else return s}o.removeOverridden=t;function e(a,s){if((a instanceof bt||a instanceof sl)&&typeof s=="string")return a.data(s);if((a instanceof fe||a instanceof ll)&&typeof s=="string")return a.data(s);if(typeof s=="number"&&Array.isArray(a))return a[s];if(typeof s=="string"&&typeof a=="object"&&a!==null)return a[s]}o.zoomOnce=e;function r(a,s,l=0){for(;l<s.length&&a!==void 0;)a=e(a,s[l]),l+=1;return a}o.zoom=r;function i(a,s){let l=[];function c(d,u){if(d instanceof es&&d.id===s.id)l.push(u);else if(d instanceof fe)for(let p=0;p<d.length;p++)c(d[p].data,[...u,d[p].id]);else if(d instanceof bt)d.traverse((p,h)=>{c(h,[...u,p])});else if(Array.isArray(d)){if(typeof d[0]=="number")return;for(let p=0;p<d.length;p++)c(d[p],[...u,p])}else{if(pi(d))return;if(typeof d=="object"&&d!==null)for(let p in d)c(d[p],[...u,p])}}return c(a,[]),l}o.findPathes=i})(Ot||(Ot={}))});var $w=Me(()=>{"use strict"});function eA(n,t){let e=[];if(t.length===n.length){let r=0;for(;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}}else return null;return e}function Ye(n,t){let e=[];if(t.length<=n.length){let r=0;for(;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}}else return null;return e}var tA=Me(()=>{"use strict"});function yh(n){try{if(!It.trusted&&!ca){let e=nt.sharedLength||0;e<nt.length&&(nt.length=e)}let t;if(It.randomAccessStructure&&ge[U]<64&&ge[U]>=32&&nA?(t=nA(ge,U,Ni,It),ge=null,!(n&&n.lazy)&&t&&(t=t.toJSON()),U=Ni):t=or(),Pr&&(U=Pr.postBundlePosition,Pr=null),ca&&(nt.restoreStructures=null),U==Ni)nt&&nt.restoreStructures&&sA(),nt=null,ge=null,fo&&(fo=null);else{if(U>Ni)throw new Error("Unexpected end of MessagePack data");if(!ca){let e;try{e=JSON.stringify(t,(r,i)=>typeof i=="bigint"?`${i}n`:i).slice(0,100)}catch(r){e="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+e)}}return t}catch(t){throw nt&&nt.restoreStructures&&sA(),gh(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||U>Ni)&&(t.incomplete=!0),t}}function sA(){for(let n in nt.restoreStructures)nt[n]=nt.restoreStructures[n];nt.restoreStructures=null}function or(){let n=ge[U++];if(n<160)if(n<128){if(n<64)return n;{let t=nt[n&63]||It.getStructures&&yA()[n&63];return t?(t.read||(t.read=Hv(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,It.mapsAsObjects){let t={};for(let e=0;e<n;e++){let r=vA();r==="__proto__"&&(r="__proto_"),t[r]=or()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(or(),or());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=or();return It.freezeData?Object.freeze(t):t}else if(n<192){let t=n-160;if(En>=U)return la.slice(U-Bi,(U+=t)-Bi);if(En==0&&Ni<140){let e=t<16?Wv(t):gA(t);if(e!=null)return e}return zv(t)}else{let t;switch(n){case 192:return null;case 193:return Pr?(t=or(),t>0?Pr[1].slice(Pr.position1,Pr.position1+=t):Pr[0].slice(Pr.position0,Pr.position0-=t)):jv;case 194:return!1;case 195:return!0;case 196:if(t=ge[U++],t===void 0)throw new Error("Unexpected end of buffer");return kv(t);case 197:return t=tt.getUint16(U),U+=2,kv(t);case 198:return t=tt.getUint32(U),U+=4,kv(t);case 199:return rs(ge[U++]);case 200:return t=tt.getUint16(U),U+=2,rs(t);case 201:return t=tt.getUint32(U),U+=4,rs(t);case 202:if(t=tt.getFloat32(U),It.useFloat32>2){let e=bh[(ge[U]&127)<<1|ge[U+1]>>7];return U+=4,(e*t+(t>0?.5:-.5)>>0)/e}return U+=4,t;case 203:return t=tt.getFloat64(U),U+=8,t;case 204:return ge[U++];case 205:return t=tt.getUint16(U),U+=2,t;case 206:return t=tt.getUint32(U),U+=4,t;case 207:return It.int64AsType==="number"?(t=tt.getUint32(U)*4294967296,t+=tt.getUint32(U+4)):It.int64AsType==="string"?t=tt.getBigUint64(U).toString():It.int64AsType==="auto"?(t=tt.getBigUint64(U),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=tt.getBigUint64(U),U+=8,t;case 208:return tt.getInt8(U++);case 209:return t=tt.getInt16(U),U+=2,t;case 210:return t=tt.getInt32(U),U+=4,t;case 211:return It.int64AsType==="number"?(t=tt.getInt32(U)*4294967296,t+=tt.getUint32(U+4)):It.int64AsType==="string"?t=tt.getBigInt64(U).toString():It.int64AsType==="auto"?(t=tt.getBigInt64(U),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=tt.getBigInt64(U),U+=8,t;case 212:if(t=ge[U++],t==114)return hA(ge[U++]&63);{let e=zr[t];if(e)return e.read?(U++,e.read(or())):e.noBuffer?(U++,e()):e(ge.subarray(U,++U));throw new Error("Unknown extension "+t)}case 213:return t=ge[U],t==114?(U++,hA(ge[U++]&63,ge[U++])):rs(2);case 214:return rs(4);case 215:return rs(8);case 216:return rs(16);case 217:return t=ge[U++],En>=U?la.slice(U-Bi,(U+=t)-Bi):mL(t);case 218:return t=tt.getUint16(U),U+=2,En>=U?la.slice(U-Bi,(U+=t)-Bi):yL(t);case 219:return t=tt.getUint32(U),U+=4,En>=U?la.slice(U-Bi,(U+=t)-Bi):gL(t);case 220:return t=tt.getUint16(U),U+=2,cA(t);case 221:return t=tt.getUint32(U),U+=4,cA(t);case 222:return t=tt.getUint16(U),U+=2,dA(t);case 223:return t=tt.getUint32(U),U+=4,dA(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}function Hv(n,t){function e(){if(e.count++>iA){let i;try{i=n.read=new Function("r","return function(){return "+(It.freezeData?"Object.freeze":"")+"({"+n.map(o=>o==="__proto__"?"__proto_:r()":fL.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"})}")(or)}catch{return iA=1/0,e()}return n.read0=i,n.highByte===0&&(n.read=lA(t,n.read)),i()}let r={};for(let i=0,o=n.length;i<o;i++){let a=n[i];a==="__proto__"&&(a="__proto_"),r[a]=or()}return It.freezeData?Object.freeze(r):r}return e.count=0,n.read0=e,n.highByte===0?lA(t,e):e}function yA(){let n=xA(()=>(ge=null,It.getStructures()));return nt=It._mergeStructures(n,nt)}function Ud(n){let t;if(n<16&&(t=Wv(n)))return t;if(n>64&&Vv)return Vv.decode(ge.subarray(U,U+=n));let e=U+n,r=[];for(t="";U<e;){let i=ge[U++];if((i&128)===0)r.push(i);else if((i&224)===192){let o=ge[U++]&63,a=(i&31)<<6|o;a<128?r.push(65533):r.push(a)}else if((i&240)===224){let o=ge[U++]&63,a=ge[U++]&63,s=(i&31)<<12|o<<6|a;s<2048||s>=55296&&s<=57343?r.push(65533):r.push(s)}else if((i&248)===240){let o=ge[U++]&63,a=ge[U++]&63,s=ge[U++]&63,l=(i&7)<<18|o<<12|a<<6|s;l<65536||l>1114111?r.push(65533):(l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l))}else r.push(65533);r.length>=4096&&(t+=Tr.apply(String,r),r.length=0)}return r.length>0&&(t+=Tr.apply(String,r)),t}function cA(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=or();return It.freezeData?Object.freeze(t):t}function dA(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++){let r=vA();r==="__proto__"&&(r="__proto_"),t[r]=or()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(or(),or());return t}}function gA(n){let t=U,e=new Array(n);for(let r=0;r<n;r++){let i=ge[U++];if((i&128)>0){U=t;return}e[r]=i}return Tr.apply(String,e)}function Wv(n){if(n<4)if(n<2){if(n===0)return"";{let t=ge[U++];if((t&128)>1){U-=1;return}return Tr(t)}}else{let t=ge[U++],e=ge[U++];if((t&128)>0||(e&128)>0){U-=2;return}if(n<3)return Tr(t,e);let r=ge[U++];if((r&128)>0){U-=3;return}return Tr(t,e,r)}else{let t=ge[U++],e=ge[U++],r=ge[U++],i=ge[U++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){U-=4;return}if(n<6){if(n===4)return Tr(t,e,r,i);{let o=ge[U++];if((o&128)>0){U-=5;return}return Tr(t,e,r,i,o)}}else if(n<8){let o=ge[U++],a=ge[U++];if((o&128)>0||(a&128)>0){U-=6;return}if(n<7)return Tr(t,e,r,i,o,a);let s=ge[U++];if((s&128)>0){U-=7;return}return Tr(t,e,r,i,o,a,s)}else{let o=ge[U++],a=ge[U++],s=ge[U++],l=ge[U++];if((o&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){U-=8;return}if(n<10){if(n===8)return Tr(t,e,r,i,o,a,s,l);{let c=ge[U++];if((c&128)>0){U-=9;return}return Tr(t,e,r,i,o,a,s,l,c)}}else if(n<12){let c=ge[U++],d=ge[U++];if((c&128)>0||(d&128)>0){U-=10;return}if(n<11)return Tr(t,e,r,i,o,a,s,l,c,d);let u=ge[U++];if((u&128)>0){U-=11;return}return Tr(t,e,r,i,o,a,s,l,c,d,u)}else{let c=ge[U++],d=ge[U++],u=ge[U++],p=ge[U++];if((c&128)>0||(d&128)>0||(u&128)>0||(p&128)>0){U-=12;return}if(n<14){if(n===12)return Tr(t,e,r,i,o,a,s,l,c,d,u,p);{let h=ge[U++];if((h&128)>0){U-=13;return}return Tr(t,e,r,i,o,a,s,l,c,d,u,p,h)}}else{let h=ge[U++],f=ge[U++];if((h&128)>0||(f&128)>0){U-=14;return}if(n<15)return Tr(t,e,r,i,o,a,s,l,c,d,u,p,h,f);let m=ge[U++];if((m&128)>0){U-=15;return}return Tr(t,e,r,i,o,a,s,l,c,d,u,p,h,f,m)}}}}}function uA(){let n=ge[U++],t;if(n<192)t=n-160;else switch(n){case 217:t=ge[U++];break;case 218:t=tt.getUint16(U),U+=2;break;case 219:t=tt.getUint32(U),U+=4;break;default:throw new Error("Expected string")}return Ud(t)}function kv(n){return It.copyBuffers?Uint8Array.prototype.slice.call(ge,U,U+=n):ge.subarray(U,U+=n)}function rs(n){let t=ge[U++];if(zr[t]){let e;return zr[t](ge.subarray(U,e=U+=n),r=>{U=r;try{return or()}finally{U=e}})}else throw new Error("Unknown extension type "+t)}function vA(){let n=ge[U++];if(n>=160&&n<192){if(n=n-160,En>=U)return la.slice(U-Bi,(U+=n)-Bi);if(!(En==0&&Ni<180))return zv(n)}else return U--,bA(or());let t=(n<<5^(n>1?tt.getUint16(U):n>0?ge[U]:0))&4095,e=pA[t],r=U,i=U+n-3,o,a=0;if(e&&e.bytes==n){for(;r<i;){if(o=tt.getUint32(r),o!=e[a++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(o=ge[r++],o!=e[a++]){r=1879048192;break}if(r===i)return U=r,e.string;i-=3,r=U}for(e=[],pA[t]=e,e.bytes=n;r<i;)o=tt.getUint32(r),e.push(o),r+=4;for(i+=3;r<i;)o=ge[r++],e.push(o);let s=n<16?Wv(n):gA(n);return s!=null?e.string=s:e.string=zv(n)}function bA(n){if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return n.toString();if(n==null)return n+"";if(It.allowArraysInMapKeys&&Array.isArray(n)&&n.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return n.flat().toString();throw new Error(`Invalid property type for record: ${typeof n}`)}function xA(n){aA&&aA();let t=Ni,e=U,r=Uv,i=Bi,o=En,a=la,s=Gv,l=fo,c=Pr,d=new Uint8Array(ge.slice(0,Ni)),u=nt,p=nt.slice(0,nt.length),h=It,f=ca,m=n();return Ni=t,U=e,Uv=r,Bi=i,En=o,la=a,Gv=s,fo=l,Pr=c,ge=d,ca=f,nt=u,nt.splice(0,nt.length,...p),It=h,tt=new DataView(ge.buffer,ge.byteOffset,ge.byteLength),m}function gh(){ge=null,fo=null,nt=null}function vh(n){n.unpack?zr[n.type]=n.unpack:zr[n.type]=n}var Vv,ge,Ni,U,mA,Gv,Uv,It,nt,la,Bi,En,Pr,fo,zr,tt,rA,Gd,jv,ca,iA,nA,oA,aA,Li,fL,lA,zv,mL,yL,gL,Tr,pA,hA,fA,qv,vL,bL,bh,xh,xL,SL,wL,Sh,AL,R9,is=Me(()=>{try{Vv=new TextDecoder}catch{}U=0,mA=[],Gv=mA,Uv=0,It={},Bi=0,En=0,zr=[],rA={useRecords:!1,mapsAsObjects:!0},Gd=class{},jv=new Gd;jv.name="MessagePack 0xC1";ca=!1,iA=2,Li=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(ge)return xA(()=>(gh(),this?this.unpack(t,e):Li.prototype.unpack.call(rA,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ni=e.end||t.length,U=e.start||0):(U=0,Ni=e>-1?e:t.length),Uv=0,En=0,la=null,Gv=mA,Pr=null,ge=t;try{tt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ge=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Li){if(It=this,this.structures)return nt=this.structures,yh(e);(!nt||nt.length>0)&&(nt=[])}else It=rA,(!nt||nt.length>0)&&(nt=[]);return yh(e)}unpackMultiple(t,e){let r,i=0;try{ca=!0;let o=t.length,a=this?this.unpack(t,o):xh.unpack(t,o);if(e){if(e(a,i,U)===!1)return;for(;U<o;)if(i=U,e(yh(),i,U)===!1)return}else{for(r=[a];U<o;)i=U,r.push(yh());return r}}catch(o){throw o.lastPosition=i,o.values=r,o}finally{ca=!1,gh()}}_mergeStructures(t,e){oA&&(t=oA.call(this,t)),t=t||[],Object.isFrozen(t)&&(t=t.map(r=>r.slice(0)));for(let r=0,i=t.length;r<i;r++){let o=t[r];o&&(o.isShared=!0,r>=32&&(o.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],o=e[r];o&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};fL=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;lA=(n,t)=>function(){let e=ge[U++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=nt[r]||yA()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=Hv(i,n)),i.read()};zv=Ud,mL=Ud,yL=Ud,gL=Ud;Tr=String.fromCharCode;pA=new Array(4096);hA=(n,t)=>{let e=or().map(bA),r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=nt[n];return i&&(i.isShared||ca)&&((nt.restoreStructures||(nt.restoreStructures=[]))[n]=i),nt[n]=e,e.read=Hv(e,r),(e.read0||e.read)()};zr[0]=()=>{};zr[0].noBuffer=!0;zr[66]=n=>{let t=n.byteLength%8||8,e=BigInt(n[0]&128?n[0]-256:n[0]);for(let r=1;r<t;r++)e<<=BigInt(8),e+=BigInt(n[r]);if(n.byteLength!==t){let r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=(o,a)=>{let s=a-o;if(s<=40){let u=r.getBigUint64(o);for(let p=o+8;p<a;p+=8)u<<=BigInt(64),u|=r.getBigUint64(p);return u}let l=o+(s>>4<<3),c=i(o,l),d=i(l,a);return c<<BigInt((a-l)*8)|d};e=e<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return e};fA={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};zr[101]=()=>{let n=or();if(!fA[n[0]]){let t=Error(n[1],{cause:n[2]});return t.name=n[0],t}return fA[n[0]](n[1],{cause:n[2]})};zr[105]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4);fo||(fo=new Map);let e=ge[U],r;e>=144&&e<160||e==220||e==221?r=[]:e>=128&&e<144||e==222||e==223?r=new Map:(e>=199&&e<=201||e>=212&&e<=216)&&ge[U+1]===115?r=new Set:r={};let i={target:r};fo.set(t,i);let o=or();if(i.used)Object.assign(r,o);else return i.target=o;if(r instanceof Map)for(let[a,s]of o.entries())r.set(a,s);if(r instanceof Set)for(let a of Array.from(o))r.add(a);return r};zr[112]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4),e=fo.get(t);return e.used=!0,e.target};zr[115]=()=>new Set(or());qv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array"),vL=typeof globalThis=="object"?globalThis:window;zr[116]=n=>{let t=n[0],e=Uint8Array.prototype.slice.call(n,1).buffer,r=qv[t];if(!r){if(t===16)return e;if(t===17)return new DataView(e);throw new Error("Could not find typed array for code "+t)}return new vL[r](e)};zr[120]=()=>{let n=or();return new RegExp(n[0],n[1])};bL=[];zr[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=U;return U+=t-n.length,Pr=bL,Pr=[uA(),uA()],Pr.position0=0,Pr.position1=0,Pr.postBundlePosition=U,U=e,or()};zr[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");bh=new Array(147);for(let n=0;n<256;n++)bh[n]=+("1e"+Math.floor(45.15-n*.30103));xh=new Li({useRecords:!1}),xL=xh.unpack,SL=xh.unpackMultiple,wL=xh.unpack,Sh={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},AL=new Float32Array(1),R9=new Uint8Array(AL.buffer,0,4)});function Xv(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:o,position:a}=e(4+i);o[a++]=199,o[a++]=i+1}else if(i+1<65536){var{target:o,position:a}=e(5+i);o[a++]=200,o[a++]=i+1>>8,o[a++]=i+1&255}else{var{target:o,position:a,targetView:s}=e(7+i);o[a++]=201,s.setUint32(a,i+1),a+=4}o[a++]=116,o[a++]=t,n.buffer||(n=new Uint8Array(n)),o.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Yv(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:o}=t(e+5);r[i++]=198,o.setUint32(i,e),i+=4}r.set(n,i)}function wA(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function PL(n,t){let e,r=t.length*6,i=n.length-r;for(;e=t.pop();){let o=e.offset,a=e.id;n.copyWithin(o+r,o,i),r-=6;let s=o+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,i=o}return n}function AA(n,t,e){if(Wt.length>0){Dt.setUint32(Wt.position+n,j+e-Wt.position-n),Wt.stringsPosition=j-n;let r=Wt;Wt=null,t(r[0]),t(r[1])}}function Qv(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ch.unshift(n.Class),Eh.unshift(n)}vh(n)}function ML(n,t){return n.isCompatible=e=>{let r=!e||(t.lastNamedStructuresLength||0)===e.length;return r||t._mergeStructures(e),r},n}var Ah,Eh,Ch,ul,wh,EA,SA,Y,zd,Dt,j,jr,Wt,EL,CL,TL,dl,ns,CA,OL,IL,DL,RL,BL,NL,TA,PA,MA,Kv=Me(()=>{is();is();is();try{Ah=new TextEncoder}catch{}ul=typeof Buffer<"u",wh=ul?function(n){return Buffer.allocUnsafeSlow(n)}:Uint8Array,EA=ul?Buffer:Uint8Array,SA=ul?4294967296:2144337920,j=0,Wt=null,CL=21760,TL=/[\u0080-\uFFFF]/,dl=Symbol("record-id"),ns=class extends Li{constructor(t){super(t),this.offset=0;let e,r,i,o,a,s=EA.prototype.utf8Write?function(C,B){return Y.utf8Write(C,B,Y.byteLength-B)}:Ah&&Ah.encodeInto?function(C,B){return Ah.encodeInto(C,Y.subarray(B)).written}:!1,l=this;t||(t={});let c=t&&t.sequential,d=t.structures||t.saveStructures,u=t.maxSharedStructures;if(u==null&&(u=d?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let p=t.maxOwnStructures;p==null&&(p=d?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let h=u>32||p+u>64,f=u+64,m=u+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],g=0,b=0;this.pack=this.encode=function(C,B){if(Y||(Y=new wh(8192),Dt=Y.dataView||(Y.dataView=new DataView(Y.buffer,0,8192)),j=0),jr=Y.length-10,jr-j<2048?(Y=new wh(Y.length),Dt=Y.dataView||(Y.dataView=new DataView(Y.buffer,0,Y.length)),jr=Y.length-10,j=0):j=j+7&2147483640,r=j,B&MA&&(j+=B&255),a=l.structuredClone?new Map:null,l.bundleStrings&&typeof C!="string"?(Wt=[],Wt.size=1/0):Wt=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let F=o.sharedLength||0;if(F>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let V=0;V<F;V++){let K=o[V];if(!K)continue;let q,G=o.transitions;for(let W=0,H=K.length;W<H;W++){let Z=K[W];q=G[Z],q||(q=G[Z]=Object.create(null)),G=q}G[dl]=V+64}this.lastNamedStructuresLength=F}c||(o.nextId=F+64)}i&&(i=!1);let _;try{l.randomAccessStructure&&!l.readOnlyStructures&&C&&typeof C=="object"?C.constructor===Object?N(C):C.constructor!==Map&&!Array.isArray(C)&&!Ch.some(V=>C instanceof V)?N(C.toJSON?C.toJSON():C):v(C):v(C);let F=Wt;if(Wt&&AA(r,v,0),a&&a.idsToInsert){let V=a.idsToInsert.sort((W,H)=>W.offset>H.offset?1:-1),K=V.length,q=-1;for(;F&&K>0;){let W=V[--K].offset+r;W<F.stringsPosition+r&&q===-1&&(q=0),W>F.position+r?q>=0&&(q+=6):(q>=0&&(Dt.setUint32(F.position+r,Dt.getUint32(F.position+r)+q),q=-1),F=F.previous,K++)}q>=0&&F&&Dt.setUint32(F.position+r,Dt.getUint32(F.position+r)+q),j+=V.length*6,j>jr&&M(j),l.offset=j;let G=PL(Y.subarray(r,j),V);return a=null,G}return l.offset=j,B&TA?(Y.start=r,Y.end=j,Y):Y.subarray(r,j)}catch(F){throw _=F,F}finally{if(o&&(x(),i&&l.saveStructures)){let F=o.sharedLength||0,V=Y.subarray(r,j),K=ML(o,l);if(!_)return l.saveStructures(K,K.isCompatible)===!1?(o.uninitialized=!0,l.pack(C,B)):(l.lastNamedStructuresLength=F,Y.length>1073741824&&(Y=null),V)}Y.length>1073741824&&(Y=null),B&PA&&(j=r)}};let x=()=>{b<10&&b++;let C=o.sharedLength||0;if(o.length>C&&!c&&(o.length=C),g>1e4)o.transitions=null,b=0,g=0,y.length>0&&(y=[]);else if(y.length>0&&!c){for(let B=0,_=y.length;B<_;B++)y[B][dl]=0;y=[]}},S=C=>{var B=C.length;B<16?Y[j++]=144|B:B<65536?(Y[j++]=220,Y[j++]=B>>8,Y[j++]=B&255):(Y[j++]=221,Dt.setUint32(j,B),j+=4);for(let _=0;_<B;_++)v(C[_])},v=C=>{j>jr&&(Y=M(j));var B=typeof C,_;if(B==="string"){let F=C.length;if(Wt&&F>=4&&F<4096){if((Wt.size+=F)>CL){let G,W=(Wt[0]?Wt[0].length*3+Wt[1].length:0)+10;j+W>jr&&(Y=M(j+W));let H;Wt.position?(H=Wt,Y[j]=200,j+=3,Y[j++]=98,G=j-r,j+=4,AA(r,v,0),Dt.setUint16(G+r-3,j-r-G)):(Y[j++]=214,Y[j++]=98,G=j-r,j+=4),Wt=["",""],Wt.previous=H,Wt.size=0,Wt.position=G}let q=TL.test(C);Wt[q?0:1]+=C,Y[j++]=193,v(q?-F:F);return}let V;F<32?V=1:F<256?V=2:F<65536?V=3:V=5;let K=F*3;if(j+K>jr&&(Y=M(j+K)),F<64||!s){let q,G,W,H=j+V;for(q=0;q<F;q++)G=C.charCodeAt(q),G<128?Y[H++]=G:G<2048?(Y[H++]=G>>6|192,Y[H++]=G&63|128):(G&64512)===55296&&((W=C.charCodeAt(q+1))&64512)===56320?(G=65536+((G&1023)<<10)+(W&1023),q++,Y[H++]=G>>18|240,Y[H++]=G>>12&63|128,Y[H++]=G>>6&63|128,Y[H++]=G&63|128):(Y[H++]=G>>12|224,Y[H++]=G>>6&63|128,Y[H++]=G&63|128);_=H-j-V}else _=s(C,j+V);_<32?Y[j++]=160|_:_<256?(V<2&&Y.copyWithin(j+2,j+1,j+1+_),Y[j++]=217,Y[j++]=_):_<65536?(V<3&&Y.copyWithin(j+3,j+2,j+2+_),Y[j++]=218,Y[j++]=_>>8,Y[j++]=_&255):(V<5&&Y.copyWithin(j+5,j+3,j+3+_),Y[j++]=219,Dt.setUint32(j,_),j+=4),j+=_}else if(B==="number")if(C>>>0===C)C<32||C<128&&this.useRecords===!1||C<64&&!this.randomAccessStructure?Y[j++]=C:C<256?(Y[j++]=204,Y[j++]=C):C<65536?(Y[j++]=205,Y[j++]=C>>8,Y[j++]=C&255):(Y[j++]=206,Dt.setUint32(j,C),j+=4);else if(C>>0===C)C>=-32?Y[j++]=256+C:C>=-128?(Y[j++]=208,Y[j++]=C+256):C>=-32768?(Y[j++]=209,Dt.setInt16(j,C),j+=2):(Y[j++]=210,Dt.setInt32(j,C),j+=4);else{let F;if((F=this.useFloat32)>0&&C<4294967296&&C>=-2147483648){Y[j++]=202,Dt.setFloat32(j,C);let V;if(F<4||(V=C*bh[(Y[j]&127)<<1|Y[j+1]>>7])>>0===V){j+=4;return}else j--}Y[j++]=203,Dt.setFloat64(j,C),j+=8}else if(B==="object"||B==="function")if(!C)Y[j++]=192;else{if(a){let V=a.get(C);if(V){if(!V.id){let K=a.idsToInsert||(a.idsToInsert=[]);V.id=K.push(V)}Y[j++]=214,Y[j++]=112,Dt.setUint32(j,V.id),j+=4;return}else a.set(C,{offset:j-r})}let F=C.constructor;if(F===Object)P(C);else if(F===Array)S(C);else if(F===Map)if(this.mapAsEmptyObject)Y[j++]=128;else{_=C.size,_<16?Y[j++]=128|_:_<65536?(Y[j++]=222,Y[j++]=_>>8,Y[j++]=_&255):(Y[j++]=223,Dt.setUint32(j,_),j+=4);for(let[V,K]of C)v(V),v(K)}else{for(let V=0,K=Eh.length;V<K;V++){let q=Ch[V];if(C instanceof q){let G=Eh[V];if(G.write){G.type&&(Y[j++]=212,Y[j++]=G.type,Y[j++]=0);let Q=G.write.call(this,C);Q===C?Array.isArray(C)?S(C):P(C):v(Q);return}let W=Y,H=Dt,Z=j;Y=null;let te;try{te=G.pack.call(this,C,Q=>(Y=W,W=null,j+=Q,j>jr&&M(j),{target:Y,targetView:Dt,position:j-Q}),v)}finally{W&&(Y=W,Dt=H,j=Z,jr=Y.length-10)}te&&(te.length+j>jr&&M(te.length+j),j=wA(te,Y,j,G.type));return}}if(Array.isArray(C))S(C);else{if(C.toJSON){let V=C.toJSON();if(V!==C)return v(V)}if(B==="function")return v(this.writeFunction&&this.writeFunction(C));P(C)}}}else if(B==="boolean")Y[j++]=C?195:194;else if(B==="bigint"){if(C<9223372036854776e3&&C>=-9223372036854776e3)Y[j++]=211,Dt.setBigInt64(j,C);else if(C<18446744073709552e3&&C>0)Y[j++]=207,Dt.setBigUint64(j,C);else if(this.largeBigIntToFloat)Y[j++]=203,Dt.setFloat64(j,Number(C));else{if(this.largeBigIntToString)return v(C.toString());if(this.useBigIntExtension||this.moreTypes){let F=C<0?BigInt(-1):BigInt(0),V;if(C>>BigInt(65536)===F){let K=BigInt(18446744073709552e3)-BigInt(1),q=[];for(;q.push(C&K),C>>BigInt(63)!==F;)C>>=BigInt(64);V=new Uint8Array(new BigUint64Array(q).buffer),V.reverse()}else{let K=C<0,q=(K?~C:C).toString(16);if(q.length%2?q="0"+q:parseInt(q.charAt(0),16)>=8&&(q="00"+q),ul)V=Buffer.from(q,"hex");else{V=new Uint8Array(q.length/2);for(let G=0;G<V.length;G++)V[G]=parseInt(q.slice(G*2,G*2+2),16)}if(K)for(let G=0;G<V.length;G++)V[G]=~V[G]}V.length+j>jr&&M(V.length+j),j=wA(V,Y,j,66);return}else throw new RangeError(C+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}j+=8}else if(B==="undefined")this.encodeUndefinedAsNil?Y[j++]=192:(Y[j++]=212,Y[j++]=0,Y[j++]=0);else throw new Error("Unknown type: "+B)},w=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?C=>{let B;if(this.skipValues){B=[];for(let V in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(V))&&!this.skipValues.includes(C[V])&&B.push(V)}else B=Object.keys(C);let _=B.length;_<16?Y[j++]=128|_:_<65536?(Y[j++]=222,Y[j++]=_>>8,Y[j++]=_&255):(Y[j++]=223,Dt.setUint32(j,_),j+=4);let F;if(this.coercibleKeyAsNumber)for(let V=0;V<_;V++){F=B[V];let K=Number(F);v(isNaN(K)?F:K),v(C[F])}else for(let V=0;V<_;V++)v(F=B[V]),v(C[F])}:C=>{Y[j++]=222;let B=j-r;j+=2;let _=0;for(let F in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(F))&&(v(F),v(C[F]),_++);if(_>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');Y[B+++r]=_>>8,Y[B+r]=_&255},A=this.useRecords===!1?w:t.progressiveRecords&&!h?C=>{let B,_=o.transitions||(o.transitions=Object.create(null)),F=j++-r,V;for(let K in C)if(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(K)){if(B=_[K],B)_=B;else{let q=Object.keys(C),G=_;_=o.transitions;let W=0;for(let H=0,Z=q.length;H<Z;H++){let te=q[H];B=_[te],B||(B=_[te]=Object.create(null),W++),_=B}F+r+1==j?(j--,R(_,q,W)):D(_,q,F,W),V=!0,_=G[K]}v(C[K])}if(!V){let K=_[dl];K?Y[F+r]=K:D(_,Object.keys(C),F,0)}}:C=>{let B,_=o.transitions||(o.transitions=Object.create(null)),F=0;for(let K in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(K))&&(B=_[K],B||(B=_[K]=Object.create(null),F++),_=B);let V=_[dl];V?V>=96&&h?(Y[j++]=((V-=96)&31)+96,Y[j++]=V>>5):Y[j++]=V:R(_,_.__keys__||Object.keys(C),F);for(let K in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(K))&&v(C[K])},E=typeof this.useRecords=="function"&&this.useRecords,P=E?C=>{E(C)?A(C):w(C)}:A,M=C=>{let B;if(C>16777216){if(C-r>SA)throw new Error("Packed buffer would be larger than maximum buffer size");B=Math.min(SA,Math.round(Math.max((C-r)*(C>67108864?1.25:2),4194304)/4096)*4096)}else B=(Math.max(C-r<<2,Y.length-1)>>12)+1<<12;let _=new wh(B);return Dt=_.dataView||(_.dataView=new DataView(_.buffer,0,B)),C=Math.min(C,Y.length),Y.copy?Y.copy(_,0,r,C):_.set(Y.slice(r,C)),j-=r,r=0,jr=_.length-10,Y=_},R=(C,B,_)=>{let F=o.nextId;F||(F=64),F<f&&this.shouldShareStructure&&!this.shouldShareStructure(B)?(F=o.nextOwnId,F<m||(F=f),o.nextOwnId=F+1):(F>=m&&(F=f),o.nextId=F+1);let V=B.highByte=F>=96&&h?F-96>>5:-1;C[dl]=F,C.__keys__=B,o[F-64]=B,F<f?(B.isShared=!0,o.sharedLength=F-63,i=!0,V>=0?(Y[j++]=(F&31)+96,Y[j++]=V):Y[j++]=F):(V>=0?(Y[j++]=213,Y[j++]=114,Y[j++]=(F&31)+96,Y[j++]=V):(Y[j++]=212,Y[j++]=114,Y[j++]=F),_&&(g+=b*_),y.length>=p&&(y.shift()[dl]=0),y.push(C),v(B))},D=(C,B,_,F)=>{let V=Y,K=j,q=jr,G=r;Y=zd,j=0,r=0,Y||(zd=Y=new wh(8192)),jr=Y.length-10,R(C,B,F),zd=Y;let W=j;if(Y=V,j=K,jr=q,r=G,W>1){let H=j+W-1;H>jr&&M(H);let Z=_+r;Y.copyWithin(Z+W,Z+1,j),Y.set(zd.slice(0,W),Z),j=H}else Y[_+r]=zd[0]},N=C=>{let B=EL(C,Y,r,j,o,M,(_,F,V)=>{if(V)return i=!0;j=F;let K=Y;return v(_),x(),K!==Y?{position:j,targetView:Dt,target:Y}:j},this);if(B===0)return P(C);j=B}}useBuffer(t){Y=t,Y.dataView||(Y.dataView=new DataView(Y.buffer,Y.byteOffset,Y.byteLength)),Dt=Y.dataView,j=0}set position(t){j=t}get position(){return j}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Ch=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Gd];Eh=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:o,position:a}=t(6);i[a++]=214,i[a++]=255,o.setUint32(a,r)}else if(r>0&&r<4294967296){let{target:i,targetView:o,position:a}=t(10);i[a++]=215,i[a++]=255,o.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:o,position:a}=t(3);i[a++]=212,i[a++]=255,i[a++]=255}else{let{target:i,targetView:o,position:a}=t(15);i[a++]=199,i[a++]=12,i[a++]=255,o.setUint32(a,n.getMilliseconds()*1e6),o.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){if(this.setAsEmptyObject)return t(0),e({});let r=Array.from(n),{target:i,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(i[o++]=212,i[o++]=115,i[o++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message,n.cause])}},{pack(n,t,e){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.moreTypes?Xv(n,16,t):Yv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==EA&&this.moreTypes?Xv(n,qv.indexOf(e.name),t):Yv(n,t)}},{pack(n,t){this.moreTypes?Xv(n,17,t):Yv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];CA=new ns({useRecords:!1}),OL=CA.pack,IL=CA.pack,{NEVER:DL,ALWAYS:RL,DECIMAL_ROUND:BL,DECIMAL_FIT:NL}=Sh,TA=512,PA=1024,MA=2048});var OA=Me(()=>{Kv();is()});var IA=Me(()=>{Kv();is();OA()});var Zv,LL,Th,DA=Me(()=>{"use strict";is();sh();ph();sa();_d();oa();Zv=[{Class:Se.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Se.prototype),n}},{Class:fe.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,fe.prototype),n}},{Class:bt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,bt.prototype),n}},{Class:es.prototype.constructor,type:4,write(n){return n.id},read(n){return new es(n)}},{Class:Ld.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ld(n)}},{Class:Ct.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ct.prototype),n}}];for(let n of Zv)vh(n);LL=new Li({structuredClone:!0});(t=>{function n(e){return LL.unpack(e)}t.deserialize=n})(Th||(Th={}))});function FL(n){let t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function Jv(n){if(pi(n))return n;if(Array.isArray(n))return n.map(Jv);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Jv(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var _L,os,RA=Me(()=>{"use strict";IA();Zt();DA();_L=new ns({structuredClone:!0});for(let n of Zv)Qv(n);(r=>{function n(i){return _L.pack(i)}r.serialize=n;function t(i){return Th.deserialize(i)}r.deserialize=t;function e(i){return FL(n(Jv(i))).toString()}r.checksum=e})(os||(os={}))});var ut=Me(()=>{Vd();Ww();lh();oa();_d();ch();sa();Kw();$w();Fv();tA();sh();RA();Ov();ph()});import{MathUtils as $v}from"three";function jd(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var BA,tb,NA,Ph,eb,LA,_A,FA,Mh,Oh,kA,VA,GA,UA,zA,Ih,Dh,jA,HA,WA,qA,kL=Me(()=>{"use strict";ut();(e=>{function n(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=n;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(BA||(BA={}));tb={["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"]};(e=>{function n(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=n;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new fe}:{type:r,disabled:!1,name:"",key:void 0,actions:new fe}}e.defaultData=t})(NA||(NA={}));(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(Ph||(Ph={}));(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:Ph.propertyDefaultData(i),rOperand:{...Ph.valueDefaultData}}}r.comparisonDefaultData=n;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}r.distanceDefaultData=t;function e(i,o){return{type:"State",object:i??null,state:o??null}}r.stateDefaultData=e})(eb||(eb={}));(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(LA||(LA={}));(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,name:"",inActions:new fe,outActions:new fe,condition:eb.distanceDefaultData(r)}}e.defaultData=t})(_A||(_A={}));(t=>t.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 fe,drop:new fe}})(FA||(FA={}));(t=>t.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 fe})(Mh||(Mh={}));(t=>t.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})(Oh||(Oh={}));(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,name:"",actions:new fe}}e.defaultData=t})(kA||(kA={}));(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new fe}}e.defaultData=t})(VA||(VA={}));(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,name:"",actions:new fe}}e.defaultData=t})(GA||(GA={}));(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new fe}}e.defaultData=t})(UA||(UA={}));(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new fe,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(zA||(zA={}));(a=>{a.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(s){return s.type==="Resize"}a.is=t;function e(s){return typeof s=="string"?s:"custom"}a.sizeToDevice=e;function r(s){return typeof s=="string"?[...a.defaultSizes[s]]:[...s]}a.deviceToSize=r;function i(){let s={size:"mobile",operator:"<",actions:new fe},l={size:"tablet",operator:"<",actions:new fe},c={size:[...a.defaultSizes.custom],operator:"<>",actions:new fe},d=new fe;return d.push({id:$v.generateUUID(),fi:0,data:s},{id:$v.generateUUID(),fi:1,data:l},{id:$v.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:d}}a.defaultData=i;function o(){return{size:[...a.defaultSizes.custom],operator:"<>",actions:new fe}}a.defaultBreakpointData=o})(Ih||(Ih={}));(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"]};function t(i){return i.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",name:"",actions:new fe,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Dh||(Dh={}));(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",name:"",successActions:new fe,errorActions:new fe,userAPIId:""}}e.defaultData=t})(jA||(jA={}));(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new fe,userWebhookId:""}}e.defaultData=t})(HA||(HA={}));(e=>{function n(r){return r.type==="AIAssistantListener"}e.is=n;function t(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new fe,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=t})(WA||(WA={}));(e=>{function n(r){return r.type==="AIAssistantTrigger"}e.is=n;function t(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new fe}}e.defaultData=t})(qA||(qA={}))});function QA(n){let t=typeof n;return n!==null&&(t==="object"||t==="function")}function rb(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Cn,ua,KA,ar,Si,_i,as,XA,da,Ut,Ue,Rh,mo,ss,YA,wi=Me(()=>{"use strict";Cn="personal camera",ua="a218fcc3-276b-49b9-b485-49037fd14f5f",KA=2500134,ar=5526619;(h=>{function n(f,m){return f[0]===m[0]&&f[1]===m[1]}h.isEqual=n;function t(f,m,y){return[f[0]+(m[0]-f[0])*y,f[1]+(m[1]-f[1])*y]}h.lerp=t;function e(f,m){return[f[0]+m[0],f[1]+m[1]]}h.add=e;function r(f,m){return[f[0]-m[0],f[1]-m[1]]}h.sub=r;function i(f,m){return[f[0]*m[0],f[1]*m[1]]}h.multiply=i;function o(f,m){return[f[0]/m[0],f[1]/m[1]]}h.divide=o;function a(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}h.distanceSquared=a;function s(f,m){return Math.sqrt(a(f,m))}h.distance=s;function l(f,m){return f[0]*m[0]+f[1]*m[1]}h.dot=l;function c(f,m){return[f[0]*m,f[1]*m]}h.scalarMultiply=c;function d(f,m,y){let g=h.sub(m,f),b=h.sub(y,f),x=h.dot(g,b)/h.dot(g,g),S=h.scalarMultiply(g,x);return h.add(f,S)}h.projectionOnto=d;function u(f,m,y){return s(f,d(f,m,y))}h.projectionOntoDistance=u;function p(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}h.center=p})(Si||(Si={}));(s=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=n;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=r;function i(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=i;function o(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=o;function a(l,c,d){return[l[0]+(c[0]-l[0])*d,l[1]+(c[1]-l[1])*d,l[2]+(c[2]-l[2])*d]}s.lerp=a})(_i||(_i={}));(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o,r[2]+(i[2]-r[2])*o,r[3]+(i[3]-r[3])*o]}e.lerp=t})(as||(as={}));(a=>{let n=180/Math.PI,t=Math.PI/180;function e(s){return typeof s=="number"?s*n:s}function r(s){return typeof s=="number"?s*t:s}function i(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=i;function o(s){return[r(s[0]),r(s[1]),r(s[2])]}a.degToRad=o})(XA||(XA={}));(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(o,a){for(let s=0;s<16;s++)if(o[s]!==a[s])return!1;return!0}i.isEqual=t;function e(o){return o??i.identity}i.simplify=e;function r(o,a){let s=a.slice(0);for(let l=0,c=a.length;l<c;l+=3){let d=o[3]*a[l]+o[7]*a[l+1]+o[11]*a[l+2]+o[15];s[l]=(o[0]*a[l]+o[4]*a[l+1]+o[8]*a[l+2]+o[12])/d,s[l+1]=(o[1]*a[l]+o[5]*a[l+1]+o[9]*a[l+2]+o[13])/d,s[l+2]=(o[2]*a[l]+o[6]*a[l+1]+o[10]*a[l+2]+o[14])/d}return s}i.applyMatrix4=r})(da||(da={}));(p=>{function n(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}p.isRGB=n,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}p.toRgb255a1=i;function o(h){return{r:h.r,g:h.g,b:h.b}}p.clone=o;function a(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}p.fromHex=a;function s(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}p.toHex=s;function l(h,f){return h.r===f.r&&h.g===f.g&&h.b===f.b}p.equals=l;function c(h,f){return h.r.toFixed(2)===f.r.toFixed(2)&&h.g.toFixed(2)===f.g.toFixed(2)&&h.b.toFixed(2)===f.b.toFixed(2)}p.equalsFixed=c;function d(h,f,m){return{r:h.r+(f.r-h.r)*m,g:h.g+(f.g-h.g)*m,b:h.b+(f.b-h.b)*m}}p.lerp=d;function u(h){return QA(h)?"r"in h&&"g"in h&&"b"in h&&!("a"in h):!1}p.is=u})(Ut||(Ut={}));(d=>{d.white={...Ut.white,a:1};function t(u){return QA(u)?"r"in u&&"g"in u&&"b"in u&&"a"in u:!1}d.is=t,d.transparent={...Ut.white,a:0};function r(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}d.from0to1=r;function i(u,p){return{...Ut.fromHex(u),a:p}}d.fromHexAndA=i;function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}d.toRgb255a1=o;function a(u,p){return Ut.equals(u,p)&&u.a===p.a}d.equals=a;function s(u,p){return Ut.equalsFixed(u,p)&&u.a.toFixed(2)===p.a.toFixed(2)}d.equalsFixed=s;function l(u,p,h){return{r:u.r+(p.r-u.r)*h,g:u.g+(p.g-u.g)*h,b:u.b+(p.b-u.b)*h,a:u.a+(p.a-u.a)*h}}d.lerp=l;function c({r:u,g:p,b:h,a:f}=d.white){return`rgba(${u*255}, ${p*255}, ${h*255}, ${f})`}d.toStyle=c})(Ue||(Ue={}));(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(Rh||(Rh={}));(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(mo||(mo={}));(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ss||(ss={}));(o=>(o.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]))(YA||(YA={}))});var on,an,ZA=Me(()=>{"use strict";(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(on||(on={}));(h=>{h.DefaultUp=[0,1,0],h.DefaultTargetOffset=1e3,h.MinTargetOffset=.001;function r(f){return f===void 0||!Number.isFinite(f)||f<h.MinTargetOffset?h.DefaultTargetOffset:f}h.sanitizeTargetOffset=r,h.DefaultAzimuth=-24,h.DefaultElevation=15;let a=h.DefaultAzimuth*Math.PI/180,s=h.DefaultElevation*Math.PI/180,l=180/Math.PI;h.DefaultPosition=[h.DefaultTargetOffset*Math.sin(a)*Math.cos(s),h.DefaultTargetOffset*Math.sin(s),h.DefaultTargetOffset*Math.cos(a)*Math.cos(s)],h.DefaultRotation=[Math.atan2(-Math.sin(s),Math.cos(a)*Math.cos(s))*l,Math.asin(Math.sin(a)*Math.cos(s))*l,Math.atan2(Math.sin(a)*Math.sin(s),Math.cos(a))*l],h.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:h.DefaultUp,isUpVectorFlipped:!1,targetOffset:h.DefaultTargetOffset};function p(f){return f.type==="PerspectiveCamera"?f.perspective?.zoom??1:f.orthographic?.zoom??1}h.getZoom=p})(an||(an={}))});var Tn,Bh,ib,Nh,Lh,_h,Fh,kh,JA=Me(()=>{"use strict";(r=>{function n(i,o=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:Math.max(typeof i[0]=="number"?i[0]:1,typeof i[1]=="number"?i[1]:1)*2,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 i[0]=="number"?i[0]+i[0]:1)*o,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:i.map(a=>(typeof a=="number"?a:1)*(1+o)),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"}}}r.defaultData=n;function t(i,o){let a={...i};if(ib.forEach(s=>{Object.assign(a,{[s]:o[s]??i[s]})}),a.radial={...i.radial},o.radial){let s=i.radial,l=o.radial;Nh.forEach(c=>{Object.assign(a.radial,{[c]:l[c]??s[c]})})}if(a.linear={...i.linear},o.linear){let s=i.linear,l=o.linear;Lh.forEach(c=>{Object.assign(a.linear,{[c]:l[c]??s[c]})})}if(a.grid={...i.grid},o.grid){let s=i.grid,l=o.grid;_h.forEach(c=>{Object.assign(a.grid,{[c]:l[c]??s[c]})})}if(a.toObject={...i.toObject},o.toObject){let s=i.toObject,l=o.toObject;Fh.forEach(c=>{Object.assign(a.toObject,{[c]:l[c]??s[c]})})}if(a.randomnessObject={...i.randomnessObject},o.randomnessObject){let s=i.randomnessObject,l=o.randomnessObject;kh.forEach(c=>{Object.assign(a.randomnessObject,{[c]:l[c]??s[c]})})}return a}r.merge=t;function e(i){return!!(i.randomnessObject||i.toObject)}r.isPartial=e})(Tn||(Tn={}));(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,o){let a=[];i.count!==void 0&&a.push({type:0,path:o,props:{count:i.count}});for(let s of t){let l=i[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...o,s],props:l})}return a}r.toOps=e})(Bh||(Bh={}));ib=["count"],Nh=["radius","start","end","position","scale","rotation"],Lh=["position","scale","rotation"],_h=["count","size"],Fh=["count","position","scale","rotation"],kh=["strength","scale","rotation","position","movement","seed","freqScale"]});var Vh,Gh,$A=Me(()=>{"use strict";wi();(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Vh||(Vh={}));(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Ue.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ue.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(r==="DirectionalLight")return{type:r,color:Ue.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Gh||(Gh={}))});var pl,eE=Me(()=>{"use strict";(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(pl||(pl={}))});var Uh,tE=Me(()=>{"use strict";(e=>(e.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"]))(Uh||(Uh={}))});var pa,nb=Me(()=>{"use strict";(t=>t.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]})(pa||(pa={}))});var ob,ab,zh,rE,iE=Me(()=>{"use strict";(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(ob||(ob={}));(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe&&(r.shadowCatcher??!1)===(i.shadowCatcher??!1)}e.equals=t})(ab||(ab={}));(t=>t.defaultData={...ab.defaultData,...ob.defaultData})(zh||(zh={}));(t=>{function n(e,r){let i=[];if("material"in e){let o=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;o&&i.push(o)}else if("materials"in e)for(let o of e.materials){let a=typeof o=="string"?r.materials[o]??r.lib.materials[o]?.asset:o;a&&i.push(a)}return i}t.getMaterialData=n})(rE||(rE={}))});var hl,nE=Me(()=>{"use strict";(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(hl||(hl={}))});function lE(n){return n.type!=="displace"}var oE,aE,Hd,sE,jh,cE,Ft,qt,Hh=Me(()=>{"use strict";ut();wi();nE();wi();(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="cavity"||e==="dust"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="reflection"||e==="matcap"||e==="displace"||e==="pattern"||e==="vertexColor"||e==="light"}t.is=n})(oE||(oE={}));(t=>{function n(e){return e==="luminance"||e==="r"||e==="g"||e==="b"||e==="a"}t.is=n})(aE||(aE={}));(t=>{function n(e){return typeof e=="object"&&e!==null&&e.image!=null}t.is=n})(Hd||(Hd={}));(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(sE||(sE={}));jh=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],cE=["wrapping","image","video","name","minFilter","magFilter"];(o=>{function n(a,s){let{texture:l,...c}=s;if(Object.assign(a,c),l){let d=a.texture;d&&Object.assign(d,l)}}o.patch=n;function t(a){return{...o.defaultData("color"),color:a}}o.defaultColorLayer=t;function e(a,s){return a==="light"&&s?r(s):i(a)}o.defaultData=e;function r(a){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}function i(a){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:hl.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...s,type:"color",color:Ut.fromHex(ar)};case"vertexColor":return{...s,type:"vertexColor"};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ut.fromHex(6710886),a:1},colorB:{...Ut.fromHex(6710886),a:1},colorC:{...Ut.fromHex(16777215),a:1},colorD:{...Ut.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{...s,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...s,type:"fresnel",color:Ue.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...s,type:"dust",color:Ue.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:Ue.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Ue.fromHexAndA(0,1),contourColor:Ue.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...s,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...s,type:"reflection",blur:0,thickness:10/1e4,steps:60,stepSize:5/1e3,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{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ut.fromHex(0),a:1},colorB:{...Ut.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}}}})(Ft||(Ft={}));(d=>{function n(u){return!u.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")}d.isMergable=n;function t(u){let p="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([f,m])=>{p+=`${f}${m}`,Array.isArray(m)?m.forEach(y=>p+=`${y}`):typeof m=="object"?Object.values(m).forEach(y=>{typeof y=="number"?p+=`${y.toFixed(4)}`:p+=`${y}`}):p+=`${m}`})}),p}d.getHash=t;function e(){return{layers:new fe}}d.defaultEmptyData=e;function r(u="layer1",p="layer2"){return o("physical",u,p)}d.defaultData=r;function i(u,p){return{...u,name:p}}d.withName=i;function o(u,p="layer1",h="layer2",f=Ut.fromHex(16777215)){let m=new fe;return m.push({fi:0,data:Ft.defaultData("light",u),id:p}),m.push({fi:1,data:Ft.defaultData("color"),id:h}),{layers:m}}d.defaultTwoLayerData=o;function a(u,p,h="layer1",f="layer2"){let m=new fe;return m.push({fi:0,data:Ft.defaultData("light",p),id:h}),m.push({fi:1,data:Ft.defaultColorLayer(u),id:f}),{layers:m}}d.defaultColorMaterial=a;function s(u){let p=Ft.defaultData("texture");u&&Object.assign(p.texture,{image:u});let h=new fe;return h.push({fi:0,data:p,id:"layer1"}),h.push({fi:1,data:{...Ft.defaultData("transmission"),alpha:1},id:"layer2"}),h.push({fi:2,data:{...Ft.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:h}}d.defaultUIObjectMaterial=s;function l(u,p="physical",h="layer1",f="layer2"){let m=Ft.defaultData("texture");Object.assign(m.texture,{image:u});let y=new fe;return y.push({fi:0,data:m,id:h}),y.push({fi:1,data:Ft.defaultData("light",p),id:f}),{layers:y}}d.defaultTwoLayerTextureData=l;function c(u,p="physical",h="layer1",f="layer2"){let m=Ft.defaultData("video");Object.assign(m.texture,{video:u});let y=new fe;return y.push({fi:0,data:m,id:h}),y.push({fi:1,data:Ft.defaultData("light",p),id:f}),{layers:y}}d.defaultTwoLayerVideoTextureData=c})(qt||(qt={}))});var ls,dE=Me(()=>{"use strict";ut();(t=>{function n(){return{points:new fe,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(ls||(ls={}))});var fl,cs,Wh,qh,Wd,uE=Me(()=>{"use strict";ut();(t=>{function n(){return{points:new fe,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=n})(fl||(fl={}));cs={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};(t=>{function n(e,r){let i={...e};return Wd.forEach(o=>{Object.assign(i,{[o]:r[o]??e[o]})}),i}t.merge=n})(Wh||(Wh={}));qh={shape:cs,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Wd=["depth","offset","angle","twist","startScale","endScale"]});var qd,Xh,Pn,Yh,sb=Me(()=>{"use strict";dE();uE();(r=>{function n(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"}r.is2DParametricMesh=n;function t(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"}r.isParametricMesh=t;function e(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"}r.isSwappableGeometry=e})(qd||(qd={}));(t=>{function n(e,r){let i={...e};return Object.assign(i,r),i.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Wh.merge(i.extrusion,r.extrusion))),i}t.merge=n})(Xh||(Xh={}));(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:fl.defaultData(),extrusion:qh};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ls.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(e==="DecalGeometry")return{type:e,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(e==="TextGeometry")return{type:e,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(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="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")}t.defaultData=n})(Pn||(Pn={}));Yh=["width","height","depth"]});var Fi,pE=Me(()=>{"use strict";wi();(a=>{a.defaultData={enabled:!1,useBackgroundColor:!1,color:Ut.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0};function t(s){return s.mode??"linear"}a.getMode=t;function e(s){let l=t(s);return l==="height"?1:l==="both"?2:0}a.getModeIndex=e;function r(s){return s.density??a.defaultData.density}a.getDensity=r;function i(s){return s.heightFalloff??a.defaultData.heightFalloff}a.getHeightFalloff=i;function o(s){return s.heightBase??a.defaultData.heightBase}a.getHeightBase=o})(Fi||(Fi={}))});var lb,Mn,cb=Me(()=>{"use strict";(t=>t.defaultData={image:null,rotation:0,blur:32,showBackground:!0})(lb||(lb={}));(t=>t.defaultData={enabled:!1,mode:"hdri",hdri:lb.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2})(Mn||(Mn={}))});var Qh,hE=Me(()=>{"use strict";(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(Qh||(Qh={}))});var Xd,db,ub,pb,ha,hb,Kh,fb=Me(()=>{"use strict";pE();cb();hE();wi();(e=>{e.defaultData={type:"normal",softShadowQuality:"low"};function t(r){return r==null?!1:r.type===void 0||r.type==="soft"}e.isSoft=t})(Xd||(Xd={}));(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(db||(db={}));(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(ub||(ub={}));(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1};function t(r){return r===void 0||r.pipeline==="classic"&&(r.toneMapping==="none"||r.toneMapping==="aces")&&r.exposure===1}e.isUntouched=t})(pb||(pb={}));(t=>t.defaultData={usePhysics:!1,gravity:-10})(ha||(ha={}));(t=>t.defaultData={playCamera:Cn,gameControlObject:null})(hb||(hb={}));(t=>t.defaultData={backgroundColor:Ue.fromHexAndA(KA,1),postprocessing:Qh.defaultData,fog:Fi.defaultData,sky:Mn.defaultData,globalPhysics:ha.defaultData,ambient:db.defaultData,ao:ub.defaultData,shadow:Xd.defaultData,publish:hb.defaultData,grading:pb.defaultData})(Kh||(Kh={}))});var Zh,fE=Me(()=>{"use strict";(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Zh||(Zh={}))});var mE,ml,SE,Jt,Jh,yE,gE,vE,bE,yo,ds,$h,yl,On,sn,xE,go,ef=Me(()=>{"use strict";ut();ZA();$A();eE();tE();nb();iE();wi();Hh();sb();JA();Zt();fb();fE();(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(mE||(mE={}));(i=>{i.identity={...Rh.identity,hiddenMatrix:da.identity};function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,pivot:o.pivot,pivotRotation:o.pivotRotation,hiddenMatrix:o.hiddenMatrix}}i.fromObject=t;function e(o,a){return{position:a?.position||o.position,rotation:a?.rotation||o.rotation,pivot:a?.pivot||o.pivot,pivotRotation:a?.pivotRotation||o.pivotRotation,scale:a?.scale||o.scale,hiddenMatrix:a?.hiddenMatrix||o.hiddenMatrix}}i.merge=e;function r(o,a){return oh({position:_i.isEqual(o.position,a.position)?void 0:a.position,rotation:_i.isEqual(o.rotation,a.rotation)?void 0:a.rotation,scale:_i.isEqual(o.scale,a.scale)?null:a.scale,hiddenMatrix:da.isEqual(o.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}i.diff=r})(ml||(ml={}));SE=["slide","offset"];(t=>t.defaultData={states:new fe,events:new fe,visible:!0,raycastLock:!1,physics:pa.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ml.identity,cloner:null})(Jt||(Jt={}));(t=>t.defaultData={type:"Empty",...Jt.defaultData})(Jh||(Jh={}));(t=>t.defaultData={type:"ParticleCollider",...Zh.defaultData,...Jt.defaultData})(yE||(yE={}));(t=>t.defaultData={type:"Component",...Jt.defaultData})(gE||(gE={}));(t=>t.defaultData={type:"Particle",...Jt.defaultData,...pl.defaultData})(vE||(vE={}));(t=>t.defaultData={type:"Hair",...Jt.defaultData,...Uh.defaultData})(bE||(bE={}));(t=>t.defaultData={type:"Mesh",...Jt.defaultData,...zh.defaultData})(yo||(yo={}));(t=>t.defaultData={...Jt.defaultData,...ml.identity,position:an.DefaultPosition,rotation:an.DefaultRotation,...an.defaultData})(ds||(ds={}));(e=>{function n(r){return{...Jt.defaultData,...Gh.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($h||($h={}));(e=>{function n(r,i,o=0){for(;o<i.length;){let a=r?r[i[o]]:void 0;if(i.length===o+1)return a;if(a)r=a.descendants,o+=1;else return}}e.resolveWithDes=n;function t(r,i,o=0){let a=n(r,i,o);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(yl||(yl={}));(o=>{o.rootOverrideProps=["physics","events"],o.compositeNonOptionalOverrideProps=["geometry"],o.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Jt.defaultData,...s,component:a,overrides:new Ct,physics:void 0,events:void 0,type:"Instance"}}o.ofComponent=r;function i(a){let s=ml.fromObject(a.data);return r(a.id,s)}o.fromComponentData=i})(On||(On={}));(e=>{e.defaultData={type:"Page",...Jt.defaultData,physics:{...pa.defaultData,fusedBody:!1},...Kh.defaultData,camera:ds.defaultData,timelines:new Se};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(sn||(sn={}));(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:da.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:pa.defaultData,states:new fe,events:new fe,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...an.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("RectangleGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("BooleanGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("ShapeBlendGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultTextObject={name:"Text",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("TextGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultInputObject={name:"Input",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("InputGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")}))(xE||(xE={}));(i=>{function n(o,a){let s={name:a};return o.type==="Mesh"?(s.geometry={},"material"in o&&(s.material={layers:new Ct}),"materials"in o&&(s.materials=o.materials.map(l=>({layers:new Ct})))):on.is(o.type)&&(s.perspective={},s.orthographic={}),s}i.newEmpty=n;function t(o,a){if(a===void 0)return o;let s={...o};return"material"in s&&"material"in a&&a.material&&(s.material=cl(s.material,l=>{if(typeof l!="string")for(let[c,d]of Object.entries(a.material.layers)){let u=l.layers.data(c);u&&Ft.patch(u,d)}}).data),s.materials&&a.materials&&(s.materials=cl(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let d=a.materials[c];if(typeof d!="string")for(let[u,p]of Object.entries(d.layers)){let h=l[c]?.layers?.data(u);h&&Ft.patch(h,p)}}}).data),s}function e(o,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function d(u,p){for(let[h,f]of Object.entries(p.layers)){let{texture:m,...y}=f;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...u,"layers",h,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...u,"layers",h],props:y,type:0};l.push(g)}}}for(let[u,p]of Object.entries(a)){let h=p;if(u!=="name")if(u==="cloner")l.push(...Bh.toOps(h,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:h.slide,offset:h.offset},type:0});else if(u==="material")d(["material"],h);else if(u==="materials")for(let[f,m]of Object.entries(h))d(["materials",f],m);else if(c[u]===0){if(u==="geometry"&&h.extrusion!==void 0){let f={path:[u,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[u],props:h,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[u]=h}return l}i.toOps=e;function r(o,a){if(a===void 0)return o;let s={...o};if(Object.assign(s,ml.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),on.is(o.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(o.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:Xh.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Tn.merge(s.cloner,a.cloner)});else if(o.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Tn.merge(s.cloner,a.cloner)});else if(Vh.is(o.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=Ut.clone(l.color))}return s}i.patch=r})(go||(go={}))});var gl,mb=Me(()=>{"use strict";(t=>t.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})(gl||(gl={}))});var Vi,tf=Me(()=>{"use strict";mb();wi();(t=>t.defaultData={orbitControls:gl.defaultData,playPage:ua,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let i=0,o=0;return r<5?o=-30:r<10&&(o=30),r===0||r===10||r===5?i=30:(r===4||r===11||r===9)&&(i=-30),[120,[i,o],"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})(Vi||(Vi={}))});var yb,gb,vo,vb=Me(()=>{"use strict";(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(yb||(yb={}));(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(gb||(gb={}));(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...yb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:gb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(vo||(vo={}))});var vl,bo,bb=Me(()=>{"use strict";ef();ut();tf();wi();Zt();vb();(i=>{function n(o){return o.find(a=>a.data.type==="Page"&&a.data.globalPhysics.usePhysics)!==void 0}i.physicsEnabled=n;function t(o,a){let s=o.find(l=>l.data.type==="Page"&&l.data.timelines?.[a]!==void 0);return s&&s.data.timelines?.[a]}i.findTimeline=t;function e(o,a){let s=o.scene.objects.get(a);if(s&&s.data.type==="Component")return s;{let l=o.shared.lib.components[a];if(l)return{...l.asset,id:a}}}i.getComponentData=e;function r(o,a,s){o.scene.objects.traverseFrom(a,(l,c)=>{if(c.type==="Instance"){let d=e(o,c.component)?.data;d&&s(l,c,d.events)}else s(l,c,c.events)})}i.traverseModuleInstances=r})(vl||(vl={}));(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:$h.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(d=!0,u=[]){let p=[];d&&p.push({...c.defaultLight}),p.push(...u);let h=new bt;return h.push({fi:1,id:ua,data:{...sn.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Vi.defaultData,styles:vo.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new bt,publish:Vi.defaultData,styles:vo.defaultData()}},c.emptyDataWithPage=function(d=!0){return{objects:e(d),publish:Vi.defaultData,styles:vo.defaultData()}},c.emptyData=function(){return{objects:new bt,publish:{...Vi.defaultData},styles:vo.defaultData()}};function s(d){return{...c.defaultData,objects:nr(d,bt.prototype)}}c.withObjs=s;function l(d,u){return s([{id:d,data:u,children:[],fi:0}])}c.withObj=l})(bo||(bo={}))});var bl,wE=Me(()=>{"use strict";(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(bl||(bl={}))});var rf,AE,sr,xb,EE,CE,ln,ei,Sb=Me(()=>{"use strict";ut();Zt();(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new fe}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(rf||(rf={}));(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new fe,queries:new fe,autoStart:!0}))(AE||(AE={}));(o=>{function n(a){return a.textValue!==void 0}o.isTextValue=n;function t(a){return typeof a=="number"}o.isNumber=t;function e(a){return typeof a=="boolean"}o.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}o.typeOfVariable=r;function i(a){return o.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():o.isBoolean(a)?a?"True":"False":o.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}o.getDisplayedValue=i})(sr||(sr={}));(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(xb||(xb={}));(t=>t.all=[...xb.all,"components"])(EE||(EE={}));(t=>{function n(){return{images:new Se,videos:new Se,colors:new Se,audios:new Se,particles:new Se,fonts:new Se,materials:new Se,components:new Se,variables:new Se,userAPIs:new Se,userWebhooks:new Se}}t.defaultData=n})(CE||(CE={}));(t=>{function n(){return{images:new Se,videos:new Se,colors:new Se,audios:new Se,particles:new Se,fonts:new Se,materials:new Se,components:new Se,variables:new Se,userAPIs:new Se,userWebhooks:new Se}}t.defaultData=n})(ln||(ln={}));(o=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},nr(a,Se.prototype)}o.defaultColors=n;function t(){return nr({},Se.prototype)}o.defaultImages=t;function e(){return{catelogs:new Se,materials:new Se,images:new Se,videos:new Se,colors:new Se,audios:new Se,particles:new Se,fonts:new Se,variables:new fe,userAPIs:new Se,userWebhooks:new Se,lib:ln.defaultData()}}o.emptyData=e;function r(a){switch(a){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 s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,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",a)}}o.defaultVariables=r;function i(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),d=Math.round(a-l*3600-c*60);return{textValue:[l,c,d]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}o.getFormattedTimerTime=i})(ei||(ei={}))});var TE=Me(()=>{"use strict"});var fa,PE=Me(()=>{"use strict";ut();bb();wE();Sb();(l=>{l.defaultData={schema:131,scene:bo.defaultData,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...ei.emptyData(),colors:ei.defaultColors()}},l.createDefaultData=function(){return os.deserialize(os.serialize(l.defaultData))},l.emptyDataForImports=function(){let c=bo.emptyDataWithPage();return{schema:131,scene:c,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...ei.emptyData(),colors:ei.defaultColors(),images:ei.defaultImages()}}},l.emptyData=function(){return{schema:131,scene:bo.emptyDataWithPage(),frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:ei.emptyData()}},l.clipboard2dData=function(){return{schema:131,scene:bo.emptyData(),frames:new Se,shared:ei.emptyData()}};function o(c){return{...c,shared:{...c.shared,lib:ln.defaultData()}}}l.withoutLib=o;function a(c,d){return vl.getComponentData(c,d)}l.getComponentData=a;function s(c){let d=Object.values(c.shared.userAPIs);for(let u of d){let p=u.headers;for(let h of p)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}l.hasSensitiveData=s})(fa||(fa={}))});function xo(n,t=[0,0]){let e=n&&!isNaN(n[0])?n[0]:t[0],r=n&&!isNaN(n[1])?n[1]:t[1];return[e,r]}function Yd(n,t,e){switch(n){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:i}=t??{...ss.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${i[0]}, ${i[1]} )`}case 6:{let{mass:r,stiffness:i,damping:o,velocity:a}=e??{...mo.defaultData},s=new wb(r,i,o,a),l=s.solve(1);return()=>c=>s.solve(c)/l}case 8:return()=>r=>Math.floor(r)}}var ME,OE,So,xl,wb,Ab=Me(()=>{"use strict";ut();wi();(t=>{function n(e,r){return{id:e,name:r,duration:5,objectTimelines:new Se}}t.defaultData=n})(ME||(ME={}));(t=>{function n(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}t.is=n})(OE||(OE={}));(S=>{function n(v,w){let A=[0,0],E=[1,1];if(v?.cubicControls)A=xo(v.cubicControls.control1,A);else switch(v?.type){case 2:A=[.42,0];break;case 3:A=[0,0];break;case 4:A=[.42,0];break;case 1:A=[.25,.1];break;case 0:A=[0,0];break;case 7:A=[.25,1];break}if(w?.cubicControls)E=xo(w.cubicControls.control2,E);else switch(w?.type){case 2:E=[1,1];break;case 3:E=[.58,1];break;case 4:E=[.58,1];break;case 1:E=[.25,1];break;case 0:E=[1,1];break;case 7:E=[.5,1];break}return{control1:A,control2:E}}S.getControlsWithDefault=n,S.BEZIER_PRESETS=[0,1,2,3,4,7];function e(v){if(!S.BEZIER_PRESETS.includes(v))return;let w={type:v};return{control1:n(w).control1,control2:n(void 0,w).control2}}S.presetHandles=e;let r=.001;function i(v,w){return Math.abs(v[0]-w[0])<r&&Math.abs(v[1]-w[1])<r}function o(v){return S.BEZIER_PRESETS.find(w=>{let A=e(w);return A!==void 0&&i(A.control1,v.control1)&&i(A.control2,v.control2)})}S.presetForHandles=o;function a(v){return{id:v,keyframes:new fe}}S.defaultData=a,S.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"];function l(v){let w=S.ROOT_PROPERTY_ORDER.indexOf(v[0]);return w===-1?S.ROOT_PROPERTY_ORDER.length:w}S.rowOrder=l;function c(v){return v.layerId??v.path.join(".")}S.propertyKey=c;function d(v,w){let A=new Map;for(let E of v){let P=E.data;if(w?.(P))continue;let M=c(P),R=A.get(M);R||(R={id:M,path:P.path,keyframes:[],layerId:P.layerId,index:P.index},A.set(M,R)),P.isPlaceholder?R.placeholder=E.id:R.keyframes.push(E)}return[...A.values()].sort((E,P)=>{let M=l(E.path)-l(P.path);return M!==0?M:(E.index??0)-(P.index??0)})}S.groupKeyframes=d;function u(v){let w=v[v.length-1];return xl.includes(w)?w:void 0}S.rowAxis=u;function p(v){return v.layerId?v.layerId:(u(v.path)?v.path.slice(0,-1):v.path).join(".")}S.drawnRowKey=p;function h(v){let w=new Map;for(let A of v){let E=u(A.path),P=E?A.path.slice(0,-1):A.path,M=p(A),R=w.get(M);R||(R={id:M,path:P,layerId:A.layerId,index:A.index,tracks:[]},w.set(M,R)),R.tracks.push({axis:E,property:A})}return[...w.values()]}S.drawnRows=h;function f(v){return[...v].sort((w,A)=>w.data.time-A.data.time)}S.sortedKeyframes=f;function m(v){return["material",v.type==="light"?`${v.category} lighting`:v.type]}S.materialLayerPath=m;function y(v,w){return v.map(({data:A,id:E},P)=>g(w(),m(A),{layerId:E,index:P}))}S.createMaterialGroup=y;function g(v,w,A){return{id:v,data:{id:v,time:A?.time??0,path:w,value:{},layerId:A?.layerId,index:A?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}S.placeholderKeyframe=g;function b(v){return Object.entries(v).reduce((w,[A,E])=>(typeof E!="string"&&w.push({name:E.name}),w),[])}S.createName=b,S.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:Yd(3),duration:1e3},opacity:{value:[0,1],easing:Yd(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:Yd(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:Yd(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:Yd(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(So||(So={}));xl=["x","y","z"],wb=class{constructor(t=1,e=100,r=10,i=0){this.mass=t,this.stiffness=e,this.damping=r,this.initialVelocity=i,this.m_w0=Math.sqrt(e/t),this.m_zeta=r/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0+-i)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-i+this.m_w0)}solve(t){return this.m_zeta<1?t=Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):t=(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0),1-t}getDuration(){let t=.16666666666666666,e=0,r=0;for(;;)if(e+=t,this.solve(e)===1){if(r++,r>=16)break}else r=0;return e*t*1e3}}});var Sl,wl,Eb=Me(()=>{"use strict";wi();ut();(t=>t.list=["idle","move","jump","run"])(Sl||(Sl={}));(e=>(e.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 fe,move:new fe,jump:new fe,run:new fe},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ue.fromHexAndA(3728051,1)}}))(wl||(wl={}))});import{MathUtils as of}from"three";function us(n,...t){let e={};for(let r of t.flat())n!=null&&r in n&&(e[r]=n[r]);return e}function DE(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,i=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],o=[0,1];for(let s=2;s<10;s++)i.push(i[1]),o.push(1);let a={...us(Ht(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:o,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 e={...Ht(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Dn(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Rn(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,o)=>{i===void 0&&(r.materials[o]=qt.defaultTwoLayerData("phong"),i=r.materials[o]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=qt.defaultTwoLayerData("phong")),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=qt.defaultTwoLayerData("phong")),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==Ct.prototype&&t(i.material)})})}function VL(n){Object.assign(n.scene.publish,{orbitControls:{...gl.defaultData,...Ht(n.scene.publish.orbitControls)}})}function GL(n){Object.assign(n.scene.publish.settings,{video:{...Vi.defaultData.settings.video,...Ht(n.scene.publish.settings.video)}})}function UL(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[i,o]of Object.entries(r))if((jh.includes(i)||typeof o=="boolean")&&delete r[i],i==="texture")for(let[a,s]of Object.entries(o))(cE.includes(a)||typeof s=="boolean")&&delete o[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(i=>{let o=i;o.material?t(o.material):o.materials&&o.materials.forEach(a=>{t(a)})})})}function zL(n){n.scene.publish.withBackground=!0}function jL(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function HL(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(i=>i+1),r.linear.scale=r.linear.scale.map(i=>i+1))})}function WL(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function qL(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=Ht(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ht(e).booleanExclude!==!0)}})}function XL(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function YL(n){function t(r){Object.setPrototypeOf(r,Ct.prototype),r.texture&&Object.setPrototypeOf(r.texture,Ct.prototype)}function e(r){Object.setPrototypeOf(r,Ct.prototype);for(let i in r)t(r[i])}n.scene.objects.traverse((r,i)=>{i.states.forEach(o=>{let a=o;if(a.material){let s=Ht(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=Ht(l).layers;e(c),l.layers=c}})})}function RE(n){n.layers===void 0&&Object.assign(n,qt.defaultTwoLayerData("lambert"))}function Cb(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let i={...Ht(t),colors:e,steps:r};Object.assign(t,i)}})}function QL(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function BE(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Cb(r)}):"material"in e&&typeof e.material!="string"&&Cb(e.material)}),Object.values(n.shared.materials).forEach(t=>Cb(t))}function KL(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function ZL(n){n.shared.audios=nr({},Se.prototype)}function JL(n){n.shared.videos=nr({},Se.prototype)}function $L(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let i={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(t,{[e]:i})}})}function e3(n){Object.entries(Ht(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(Ht(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function t3(n){n.scene.publish.settings.web.preload=!1}function NE(n){n.layers&&n.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 LE(n){n.layers&&n.layers.forEach(t=>{lE(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 r3(n){n.shared.fonts=nr({},Se.prototype)}function i3(n){return n.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function n3(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let o=qt.defaultTwoLayerData("phong"),a=typeof i.color=="string"?n.shared.colors[i.color]:i.color;o.layers[1].data.color={r:a.r,g:a.g,b:a.b},o.layers[1].data.alpha=i.alpha;let s=i3(i.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:i.name,...Jt.defaultData,...yo.defaultData,flatShading:!1,wireframe:!1,geometry:{...Pn.defaultData("TextGeometry"),width:i.width,height:i.height,font:s,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:o,states:Ht(i.states),events:Ht(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=Ht(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function o3(n){let t={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((e,r)=>{r.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new fe,move:new fe,jump:new fe}});else{let o=new fe;Object.assign(i,{actions:o}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&o.push({fi:0,id:of.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(d,us(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(d,{control1:{...a.control1},control2:{...a.control2}});let u={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...u,...d},h={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new fe({fi:0,id:of.generateUUID(),data:c},{fi:1,id:of.generateUUID(),data:p})};o.push({fi:l,id:s,data:h})}),delete i.targets)}})})}function a3(n){n.scene.objects.traverse((t,e)=>{function r(i,o){let a=new fe,s=[];if(e.events.forEach((l,c,d)=>{if(l.type==="Audio"&&l.trigger===o){let u;s.push(c),l.interaction==="play"?u={...us(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(u={...us(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&a.push({fi:d,id:c,data:u})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:of.generateUUID(),data:{type:i,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function _E(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Ft.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function FE(n){Dn(n,_E),Rn(n,_E)}function s3(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function l3(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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"}})})}function c3(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=qt.defaultTwoLayerData("phong"))})}function d3(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function u3(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function p3(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)}function h3(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function f3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function m3(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function y3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=wl.defaultDataThirdPerson.navmesh)})})}function g3(n){n.scene.styles||(n.scene.styles=vo.defaultData())}function kE(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function v3(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}),Rn(n,kE),Dn(n,kE)}function b3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new fe})})})}function x3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function VE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function GE(n,t){if(t<1&&(Rn(n,DE),Dn(n,DE),n.schema=1),t<2&&(VL(n),n.schema=2),t<3&&(UL(n),n.schema=3),t<4&&(zL(n),n.schema=4),t<5&&(jL(n),n.schema=5),t<6&&(HL(n),n.schema=6),t<7&&(WL(n),n.schema=7),t<8&&(n.schema=8),t<9&&(BE(n),n.schema=9),t<10&&(QL(n),n.schema=10),t<11&&(KL(n),n.schema=11),t<12&&(BE(n),n.schema=12),t<13&&(ZL(n),n.schema=13),t<14&&($L(n),n.schema=14),t<15&&(e3(n),n.schema=15),t<16&&(t3(n),n.schema=16),t<17&&(Rn(n,NE),Dn(n,NE),n.schema=17),t<18&&(Rn(n,RE),Dn(n,RE),n.schema=18),t<19&&(GL(n),n.schema=19),t<20&&(r3(n),n3(n),n.schema=20),t<21&&(o3(n),a3(n),n.schema=21),t<22&&(FE(n),n.schema=22),t<23&&(s3(n),n.schema=23),t<24&&(l3(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(JL(n),t<25&&(n.schema=25)),t<26&&(qL(n),n.schema=26),t<27&&(XL(n),n.schema=27),t<28&&(FE(n),n.schema=28),t<29&&(YL(n),n.schema=29),t<30&&(c3(n),n.schema=30),t<31&&(d3(n),n.schema=31),t<33&&(u3(n),n.schema=33),t<34&&(p3(n),n.schema=34),t<35&&(h3(n),n.schema=35),t<36&&(f3(n),n.schema=36),t<37&&(m3(n),n.schema=37),t<38&&(Rn(n,LE),Dn(n,LE),n.schema=38),t<39&&(y3(n),n.schema=39),t<40&&(g3(n),n.schema=40),t<41&&(v3(n),n.schema=41),t<42&&(b3(n),n.schema=42),t<43&&(x3(n),n.schema=43),t<99){Rn(n,VE),Dn(n,VE),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Cn);let e=Ht(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=ua,r.insertBefore(null,null,[{id:ua,data:{...sn.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:us(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:us(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...ha.defaultData,...us(n.scene.environment,"usePhysics","gravity")},camera:Ht(n.scene.ownerCamera)??sn.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==bo.TRASH_CAN_ID&&r.move(ua,a.fi,a.id);let i=0,o=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(i,2)],i+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(o,1)],o+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,pa.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}var UE=Me(()=>{"use strict";Hh();wi();mb();ef();ut();tf();Zt();sb();Eb();vb();bb();nb();fb()});var QE={};aL(QE,{updateAllMaterials:()=>XE,updateDocumentSchema:()=>W3,updateLibSchema:()=>H3,updateMaterialSchema:()=>P3,updateObjectStateRec:()=>El,updateObjectsSchema:()=>qE,updateTextValues:()=>C3});import{MathUtils as S3}from"three";function zE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function w3(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function A3(n){Array.isArray(Ht(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}function jE(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Al)}function WE(n){jE(n),n.type==="Page"&&jE(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Al))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Al),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Al),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Al,t.extrusion.twist*=Al),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(Ht(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function E3(n){n.shared.variables=nr({},Se.prototype)}function C3(n){n.scene.objects.traverse((t,e)=>{})}function T3(n){let t=Ht(n.shared.variables);n.shared.variables=nr(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),fe.prototype)}function P3(n){let t=n.schema??104;t!==131&&t<130&&(af(n.asset),n.schema=130)}function El(n,t){t(n.data);for(let e of n.children)El(e,t)}function qE(n){let t=n.schema??104;t!==131&&(t<105&&(El(n.asset,WE),n.schema=105),t<118&&(El(n.asset,YE),n.schema=118),t<121&&(El(n.asset,Pb),n.schema=121),t<130&&(El(n.asset,M3),n.schema=130))}function XE(n,t){Rn(n,t),Dn(n,t),Object.values(n.shared.lib.materials).forEach(e=>t(e.asset))}function af(n){n.layers===void 0&&Object.assign(n,qt.defaultTwoLayerData("phong"))}function M3(n){"materials"in n?n.materials.forEach(t=>{t!==void 0&&typeof t!="string"&&af(t)}):"material"in n&&n.material!==void 0&&typeof n.material!="string"&&af(n.material)}function O3(n){n.shared.particles=nr({},Se.prototype),n.shared.lib&&(n.shared.lib.particles=ln.defaultData().particles)}function I3(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function D3(n){n.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function R3(n){n.scene.objects.traverse((t,e)=>{Array.isArray(Ht(e.events))!==!1&&e.events?.forEach(r=>{let i=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=i??"Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode=i==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(o=>{o.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}),r.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}function B3(n){n.shared.userAPIs=nr({},Se.prototype),n.shared.userWebhooks=nr({},Se.prototype),n.shared.lib&&(n.shared.lib.userAPIs=ln.defaultData().userAPIs,n.shared.lib.userWebhooks=ln.defaultData().userWebhooks)}function N3(n){n.scene.publish.settings.videoStatic===void 0&&(n.scene.publish.settings.videoStatic=Vi.defaultData.settings.videoStatic)}function YE(n){n.timelineAnimations=nr({},Se.prototype)}function L3(n){let t=[];return n?(n.forEach((e,r)=>{let{path:i,keyframes:o}=e.data,a=i[0]==="material"?e.id:void 0;if(!o?.length){t.push(So.placeholderKeyframe(e.id,i,{layerId:a,index:r}));return}o.forEach(({id:s,data:l})=>{t.push({id:s,data:{...l,path:i,layerId:a,index:r}})})}),t.sort((e,r)=>e.data.time-r.data.time),new fe(...t.map((e,r)=>({...e,fi:r})))):new fe}function _3(n){let t=n.shared,e=t.timelineAnimations;if(!e)return;let r=n.scene.objects,i=r.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,a]of Object.entries(e)){let s=nr({},Se.prototype),l=0,c=Boolean(a.loop);for(let[h,f]of Object.entries(a.mapping??{})){let y=r.data(h)?.timelineAnimations?.[f];!y||(l=Math.max(l,y.to??0),c=c||Boolean(y.loop),s[h]={id:h,keyframes:L3(y.properties?.unproxy())})}let d=a.page??i,u=d?r.data(d):void 0;if(!u||u.type!=="Page")continue;let p=u.timelines??(u.timelines=nr({},Se.prototype));p[o]={id:o,name:a.name,duration:l||5,...c?{loop:c}:{},objectTimelines:s}}delete t.timelineAnimations,r.traverse((o,a)=>{delete a.timelineAnimations})}function F3(n){n.scene.objects.traverse((t,e)=>{let r=e.states;if(!r)return;let i=e.timelineAnimations,o=[];r.forEach((a,s)=>{(a.isAnimation||i?.[s])&&o.push(s)}),o.forEach(a=>r.delete(a))})}function V3(n){for(let{id:t,data:e}of[...n.unproxy()]){let r=e.path?.[0];if(!r||!k3.includes(r))continue;let i=Tb(e.value);if(!i.length)continue;let o=n.data(t);if(!o)continue;let a=e.value,[s,...l]=i;for(let c of l){let d=S3.generateUUID();n.insertBefore(null,[{id:d,data:{...e,id:d,path:[r,c],value:a[c],easing:G3(e.easing)}}])}o.path=[r,s],o.value=a[s]}}function Tb(n){return n===null||typeof n!="object"?[]:xl.filter(t=>t in n)}function G3(n){let t=n?.cubicControls;return{...n,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...n?.springParameters?{springParameters:{...n.springParameters}}:{}}}function U3(n,t){return Math.abs(n[0]-t[0])<1e-6&&Math.abs(n[1]-t[1])<1e-6}function z3(n){let t=[];for(let e of So.groupKeyframes(n)){let r=new Set(e.keyframes.flatMap(o=>Tb(o.data.value))),i=r.size?[...r].map(o=>e.keyframes.filter(a=>Tb(a.data.value).includes(o))):[e.keyframes];for(let o of i){let a=[...o].sort((s,l)=>s.data.time-l.data.time);for(let s=0;s+1<a.length;s++)t.push({left:a[s],right:a[s+1]})}}return t}function j3(n){let t=z3([...n.unproxy()]),e=new Map,r=new Set;for(let{left:o,right:a}of t){let s=o.data.easing?.type,c=(s===void 0?void 0:So.presetHandles(s))?.control2??(s===5?xo(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!c)continue;let d=e.get(a.id);d?U3(d,c)||r.add(a.id):e.set(a.id,c)}let i=new Map;for(let{id:o,data:a}of n.unproxy()){let s=a.easing?.type,l=s===void 0?void 0:So.presetHandles(s);l&&i.set(o,l.control1)}for(let{left:o,right:a}of t)r.has(a.id)&&i.delete(o.id);for(let[o,a]of i){let s=n.data(o);!s?.easing||(s.easing.cubicControls={control1:a,control2:xo(s.easing.cubicControls?.control2,[1,1])},s.easing.type=5)}for(let{left:o,right:a}of t){if(!i.has(o.id))continue;let s=n.data(a.id),l=e.get(a.id);!s?.easing||!l||(s.easing.cubicControls={control1:xo(s.easing.cubicControls?.control1,[0,0]),control2:l})}}function HE(n,t){n.scene.objects.traverse((e,r)=>{let i=r;if(!(i.type!=="Page"||!i.timelines))for(let o of Object.values(i.timelines))for(let a of Object.values(o.objectTimelines??{}))t(a.keyframes)})}function Pb(n){n.pivot=[0,0,0],n.pivotRotation=[0,0,0]}function H3(n){}function W3(n){let t=n.schema??0;if(t!==131){if(t>131){console.error(`This scene was created with a newer version of Spline (file format ${t}, this runtime reads ${131}). Update @splinetool/runtime to the latest version to load it correctly.`);return}console.warn("updating from ",t,"to ",131),GE(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Vi.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Rn(n,zE),Dn(n,zE),n.schema=101),t<102&&(w3(n),n.schema=102),t<104&&(n.shared.catelogs=new Se,n.shared.lib=ln.defaultData(),n.schema=104),t<105&&(E3(n),n.scene.objects.traverse((e,r)=>{WE(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))qE(e);t<106&&(T3(n),n.schema=106),t<107&&(n.shared.lib.variables=ln.defaultData().variables,n.schema=107),t<109&&(O3(n),n.schema=109),t<110&&(I3(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{A3(r)}),n.schema=111),t<112&&(D3(n),n.schema=112),t<113&&(R3(n),n.schema=113),t<114&&(n.scene.publish.settings.web.imageQuality===void 0&&(n.scene.publish.settings.web.imageQuality=70),n.schema=114),t<115&&(B3(n),n.schema=115),t<116&&(N3(n),n.schema=116),t<117&&(n.scene.publish.settings.web.pixelRatioMobile===void 0&&(n.scene.publish.settings.web.pixelRatioMobile=0),n.scene.publish.settings.web.pixelRatioDesktop===void 0&&(n.scene.publish.settings.web.pixelRatioDesktop=0),n.schema=117),t<118&&(n.shared.timelineAnimations=nr({},Se.prototype),n.scene.objects.traverse((e,r)=>{YE(r)}),n.schema=118),t<119&&(n.scene.publish.settings.videoStatic.format=fa.defaultData.scene.publish.settings.videoStatic.format,n.scene.publish.settings.videoStatic.imageFormat=fa.defaultData.scene.publish.settings.videoStatic.imageFormat,n.schema=119),t<120&&(n.scene.publish.settings.image.colorSpace="display-p3",n.scene.publish.settings.videoStatic.colorSpace="display-p3",n.schema=120),t<121&&(n.scene.objects.traverse((e,r)=>{Pb(r),r.type==="Page"&&r.camera!==void 0&&Pb(r.camera)}),n.schema=121),t<122&&(delete n.scene.publish.settings.video,n.scene.publish.orbitControls.rotationSpeed=fa.defaultData.scene.publish.orbitControls.rotationSpeed,n.schema=122),t<123&&(n.scene.objects.traverse((e,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=Mn.defaultData)}),n.schema=123),t<124&&(t>=123&&n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&(typeof i.exposure=="number"&&(i.exposure=Math.round(i.exposure/5e-4*1e4)/1e4),i.lighting===void 0&&(i.lighting=Mn.defaultData.lighting))}),n.schema=124),t<125&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&i.lightingIntensity===void 0&&(i.lightingIntensity=Mn.defaultData.lightingIntensity)}),n.schema=125),t<126&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&(i.mode===void 0&&(i.mode="physical"),i.hdri===void 0?i.hdri={...Mn.defaultData.hdri}:(i.hdri.blur===void 0&&(i.hdri.blur=Mn.defaultData.hdri.blur),Array.isArray(i.hdri.rotation)&&(i.hdri.rotation=i.hdri.rotation[1]??0)))}),n.schema=126),t<127&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i?.hdri!==void 0&&i.hdri.showBackground===void 0&&(i.hdri.showBackground=!0)}),n.schema=127),t<128&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&i.lightingQuality===void 0&&(i.lightingQuality="full")}),n.schema=128),t<129&&(n.scene.objects.traverse((e,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=sn.defaultData.camera);let i=r.camera;i.far=1e5,i.perspective?i.perspective.near=70:i.perspective={near:70,fov:45,zoom:1}}}),n.schema=129),t<130&&(XE(n,af),n.schema=130),t<131&&(F3(n),_3(n),HE(n,V3),HE(n,j3),n.schema=131)}}var Al,k3,Mb=Me(()=>{"use strict";PE();ut();Ab();UE();tf();Hh();Zt();Sb();ef();cb();Al=180/Math.PI;k3=["position","rotation","scale","shape size"]});var uM=rh((g0,dM)=>{(function(n,t){typeof g0=="object"?dM.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(g0,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,i=0,o=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),i=s(" "),o=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),i-=s(e[l]),i<0&&(i+=1),o-=s(e[l]),o<0&&(o+=1);s=null;var c=function(){var d=2091639*r+a*23283064365386963e-26;return r=i,i=o,o=d-(a=d|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[r,i,o,a]},c.importState=function(d){r=+d[0]||0,i=+d[1]||0,o=+d[2]||0,a=+d[3]||0},c}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(i){i=i.toString();for(var o=0;o<i.length;o++){e+=i.charCodeAt(o);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var m2=rh((wce,f2)=>{"use strict";function HG(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ps(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ps)}HG(Ps,Error);Ps.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var d="",u;for(u=0;u<c.parts.length;u++)d+=c.parts[u]instanceof Array?o(c.parts[u][0])+"-"+o(c.parts[u][1]):o(c.parts[u]);return"["+(c.inverted?"^":"")+d+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+r(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+r(d)})}function o(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+r(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+r(d)})}function a(c){return e[c.type](c)}function s(c){var d=new Array(c.length),u,p;for(u=0;u<c.length;u++)d[u]=a(c[u]);if(d.sort(),d.length>0){for(u=1,p=1;u<d.length;u++)d[u-1]!==d[u]&&(d[p]=d[u],p++);d.length=p}switch(d.length){case 1:return d[0];case 2:return d[0]+" or "+d[1];default:return d.slice(0,-1).join(", ")+", or "+d[d.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+s(n)+" but "+l(t)+" found."};function WG(n,t){t=t!==void 0?t:{};var e={},r={svg_path:Br},i=Br,o=function(T){if(!T)return[];for(var I=[],k=0;k<T.length;k++)I=I.concat.apply(I,T[k]);var L=I[0];return L&&L.code=="m"&&(delete L.relative,L.code="M"),I},a=function(T,I){return $N(T,I)},s=/^[Mm]/,l=Ze(["M","m"],!1,!1),c=function(T,I,k){var L=rl(T,[I]);return k&&(L=L.concat(rl(T=="M"?"L":"l",k[1]))),L},d=/^[Zz]/,u=Ze(["Z","z"],!1,!1),p=function(){return rl("Z")},h=/^[Ll]/,f=Ze(["L","l"],!1,!1),m=function(T,I){return rl(T,I)},y=/^[Hh]/,g=Ze(["H","h"],!1,!1),b=function(T,I){return rl(T,I.map(function(k){return{x:k}}))},x=/^[Vv]/,S=Ze(["V","v"],!1,!1),v=function(T,I){return rl(T,I.map(function(k){return{y:k}}))},w=/^[Cc]/,A=Ze(["C","c"],!1,!1),E=function(T,I,k){return{x1:T.x,y1:T.y,x2:I.x,y2:I.y,x:k.x,y:k.y}},P=/^[Ss]/,M=Ze(["S","s"],!1,!1),R=function(T,I){return{x2:T.x,y2:T.y,x:I.x,y:I.y}},D=/^[Qq]/,N=Ze(["Q","q"],!1,!1),C=function(T,I){return{x1:T.x,y1:T.y,x:I.x,y:I.y}},B=/^[Tt]/,_=Ze(["T","t"],!1,!1),F=/^[Aa]/,V=Ze(["A","a"],!1,!1),K=function(T,I,k,L,z,pe){return{rx:T,ry:I,xAxisRotation:k,largeArc:L,sweep:z,x:pe.x,y:pe.y}},q=function(T,I){return{x:T,y:I}},G=function(T){return T*1},W=function(T){return T.join("")*1},H=/^[01]/,Z=Ze(["0","1"],!1,!1),te=function(T){return T=="1"},Q=function(){return""},se=",",oe=ft(",",!1),ne=function(T){return T.join("")},de=".",ve=ft(".",!1),me=/^[eE]/,ce=Ze(["e","E"],!1,!1),X=/^[+\-]/,ee=Ze(["+","-"],!1,!1),re=/^[0-9]/,he=Ze([["0","9"]],!1,!1),xe=function(T){return T.join("")},ae=/^[ \t\n\r]/,ue=Ze([" "," ",`
1
+ var eL=Object.create;var th=Object.defineProperty;var tL=Object.getOwnPropertyDescriptor;var rL=Object.getOwnPropertyNames;var iL=Object.getPrototypeOf,nL=Object.prototype.hasOwnProperty;var oL=(n,t,e)=>t in n?th(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Me=(n,t)=>()=>(n&&(t=n(n=0)),t);var rh=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),aL=(n,t)=>{for(var e in t)th(n,e,{get:t[e],enumerable:!0})},sL=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rL(t))!nL.call(n,i)&&i!==e&&th(n,i,{get:()=>t[i],enumerable:!(r=tL(t,i))||r.enumerable});return n};var Bd=(n,t,e)=>(e=n!=null?eL(iL(n)):{},sL(t||!n||!n.__esModule?th(e,"default",{value:n,enumerable:!0}):e,n));var Ur=(n,t,e)=>(oL(n,typeof t!="symbol"?t+"":t,e),e);var Gw=Me(()=>{"use strict"});function ih(n){return Array.isArray(n)?n:[n]}function $a(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Uw=Me(()=>{"use strict"});function nr(n,t){return Object.setPrototypeOf(n,t),n}function nh(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function wn(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let o=n;n=t,t=o}let r=[],i=1/(e+1);for(let o=0;o<e;o++){let a=n+(t-n)*(o+.75+Math.random()*.5)*i;r.push(a)}return r}function pi(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function zw(){return typeof process<"u"}var jw=Me(()=>{"use strict"});function Nd(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Nd(r)}return Object.freeze(n)}function oh(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}var Hw=Me(()=>{"use strict"});var Zt=Me(()=>{Gw();Uw();jw();Hw()});var ah,es,Ld,sh=Me(()=>{"use strict";ah=class{},es=class extends ah{constructor(e){super();this.id=e}},Ld=class extends ah{constructor(e){super();this.data=e}}});var Ww=Me(()=>{"use strict"});var Se,_d=Me(()=>{"use strict";Se=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o={...r,[t]:e};return Object.setPrototypeOf(o,Se.prototype),o}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:o,data:a}=t,s={...e,[o]:a};return Object.setPrototypeOf(s,Se.prototype),{data:s,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let o={...e};return Object.setPrototypeOf(o,Se.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:i}}}}return null}}});var nl,lh=Me(()=>{"use strict";nl=class extends Error{}});function qw(n,t){for(let e of n)t(e.id,e.data)!==!0&&qw(e.children,t)}function Xw(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Xw(e,t)}var bt,oa=Me(()=>{"use strict";Zt();lh();Zt();bt=class extends Array{constructor(...e){super(...e);Ur(this,"partialObjectCaches");Ur(this,"objCaches");Ur(this,"parentCaches");Object.setPrototypeOf(this,bt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nd(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);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,r){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let i=this.parent(e);if(i===r)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 r=this.get(e);r!==void 0&&this.partialObjectCaches.set(e,r)}get(e){if(this.partialObjectCaches!==void 0){let r=this.partialObjectCaches.get(e);if(r!==void 0)return r}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let i=this.get(e);i&&Xw(i,r)}}traverse(e){qw(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),a=this.childrenArray(o),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];a=[...a],a[s]={...l,data:r};let c=new Map;return c.set(e,a[s]),this.modifyArrayBy(o,a,c)}}modifyArrayBy(e,r,i=void 0){let o=e,a=r;for(;o!==null;){let l=a,c=o;if(o=this.parent(o),o===void 0)throw new Error;a=this.childrenArray(o);let d=a.findIndex(u=>u.id===c);if(d<0)throw new Error;a=[...a],a[d]={...a[d],children:l},i&&i.set(c,a[d])}Object.setPrototypeOf(a,bt.prototype);let s=a;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){s.objCaches=this.objCaches;for(let[l,c]of i)s.objCaches.set(l,c);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:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:o,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),d={fi:i,id:o,data:a,children:s};return c=[...c,d],c.sort((p,h)=>p.fi-h.fi),e.localIndex=c.indexOf(d),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let o=this.childrenArray(i),a=o.findIndex(c=>c.id===r);e.localIndex=a,o=[...o];let s=o.splice(a,1)[0];return{data:this.modifyArrayBy(i,o),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:r,fi:i,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let h=r;for(;h!==null;){if(h===void 0)throw new Error;if(h===o)throw new nl("cyclic tree");h=this.parent(h)}}let a=this.parent(o);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(h=>h.id===o);l=[...l];let d=l.splice(c,1)[0],u=this.modifyArrayBy(a,l);a=r,l=u.childrenArray(a);let p=d.fi;return d={...d,fi:i},l=[...l,d],l.sort((h,f)=>h.fi-f.fi),e.localIndex=l.indexOf(d),u=u.modifyArrayBy(a,l),{data:u,actual:e,reverse:{type:9,parent:s,fi:p,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let i=null;for(let o of this.childrenArray(e)){if(o.id===r)return i;i=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(a=>a.id===e)+1;if(o<i.length)return i[o].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(a=>a.id===e)-1;return o>=0?this.traverseSortPrevious(i[o].id):r}}getAllSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i.id);o!==void 0&&r.push({...i,...o})}r.sort((i,o)=>$a(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r}getAllIdSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i);o!==void 0&&r.push(o)}r.sort((i,o)=>$a(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r.map(i=>i.id)}getWithSortKey(e){let r=e,i=[],o=this.get(r),a=o;if(o!==void 0){for(;r;)i.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return{...a,sortKey:i}}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let o=this.childrenArray(e);if(r===null){if(o.length===0)return wn(0,i,i);{let a=o[0].fi;return wn(a-i,a,i)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=o.find(l=>l.fi>a.fi);if(s===void 0){let l=o[o.length-1].fi;return wn(l,l+i,i)}else return wn(a.fi,s.fi,i)}}}});var Mv,aa,ch=Me(()=>{"use strict";Zt();Mv=null;(r=>{function n(i){Mv=i}r.setPreservePrototype=n;function t(i,o){return Object.getPrototypeOf(i)===Mv&&Object.setPrototypeOf(o,Mv),o}r.tryPreservePrototype=t;function e(i,o){if(o.type!==0)return null;if(Array.isArray(i)||pi(i)){let a=o.props,s={},l=pi(i)?i.slice():[...i],c=!1;if(a)for(let d of Object.keys(a)){let u=parseInt(d);if(isNaN(u))throw new Error("wrong index");s[d]=l[u],l[u]=a[d],c=!0}return c?{data:l,actual:o,reverse:{type:0,props:s}}:null}else{let a=o.props,s={},l={...i},c=!1;if(a)for(let d of Object.keys(a)){s[d]=l[d];let u=a[d];u===void 0?delete l[d]:l[d]=u,c=!0}return c?{data:r.tryPreservePrototype(i,l),actual:o,reverse:{type:0,props:s}}:null}}r.runOp=e})(aa||(aa={}))});var fe,sa=Me(()=>{"use strict";Zt();Zt();fe=class extends Array{constructor(...e){super(...e);Ur(this,"objCaches");Object.setPrototypeOf(this,fe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nd(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=o[a];return o=[...o],o[a]={...s,data:r},this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,fe.prototype);let r=e;return zw()||r.fillCaches(),r}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:r,id:i,data:o}=e,a=this,s={fi:r,id:i,data:o};return a=[...a,s],a.sort((c,d)=>c.fi-d.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,o=i.findIndex(l=>l.id===r);if(o===-1)return null;e.localIndex=o,i=[...i];let a=i.splice(o,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:i}=e,o=this;o=[...o];let a=o.findIndex(d=>d.id===i);if(a===-1)return null;let s=o[a].fi,l={...o[a],fi:r};return o[a]=l,o.sort((d,u)=>d.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(o),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 r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return wn(0,r,r);{let o=i[0].fi;return wn(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let a=i.find(s=>s.fi>o.fi);if(a===void 0){let s=i[i.length-1].fi;return wn(s,s+r,r)}else return wn(o.fi,a.fi,r)}}}});function Yw(n,t){let e={cur:[],result:[],len:0};return n=Fd(n,t,e)??n,[n,e.result]}function dh(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function uh(n){n&&(n.len-=1)}function lL(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Qw(n,t,e){let r=!1,i=n.map(o=>{let a=o.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Fd(o.data,t,dh(e,a));uh(e),r=r||l!==void 0,l===void 0&&(l=o.data);let c=Qw(o.children,t,e);return c!==void 0?r=!0:c=o.children,{...o,id:a,data:l,children:c}});if(r)return i}function cL(n,t,e){let r=!1,i=n.map(o=>{let a=o.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Fd(o.data,t,dh(e,a));return uh(e),r=r||l!==void 0,l===void 0&&(l=o.data),{...o,id:a,data:l}});if(r)return Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i}function Fd(n,t,e){if(n instanceof bt){let r=Qw(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof fe)return cL(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((o,a)=>{let s=Fd(o,t,dh(e,a));return uh(e),r=r||s!==void 0,s===void 0&&(s=o),s});return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i):void 0}else if(n&&typeof n=="object"&&!pi(n)){let r={},i=!1;for(let[o,a]of Object.entries(n))if(o!=="name"&&o!=="variableId"){let s=t[o];if(typeof s=="string"){if(e!==null)throw new Error("not supported");i=!0,o=s}let l=Fd(a,t,dh(e,o));uh(e),i=i||l!==void 0,l===void 0&&(l=a),r[o]=l}else r[o]=a;return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&lL(e),r}else return}}var Ov=Me(()=>{"use strict";oa();sa();Zt()});function ol(n){return n&&typeof n=="object"&&n instanceof Ct}function Iv(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let o=i.id,a=kd(i.data,t[o]);if(e=e||a!==void 0,a===void 0&&(a=i.data),i.children){let s=Iv(i.children,t);return s!==void 0?e=!0:s=i.children,{...i,id:o,data:a,children:s}}else return{...i,id:o,data:a}});if(e)return r}function dL(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let o=i.id,a=kd(i.data,t[o]);return e=e||a!==void 0,a===void 0&&(a=i.data),{...i,id:o,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function kd(n,t){if(!ol(t))return t;if(n instanceof bt){let e=Iv(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof fe)return dL(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,o)=>{let a=kd(i,t[o]);return e=e||a!==void 0,a===void 0&&(a=i),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof Ct)return Dv(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,o]of Object.entries(n)){let a=kd(o,t[i]);r=r||a!==void 0,a===void 0&&(a=o),e[i]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Dv(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ol(t))return t;if(!ol(n))return An.apply(n,t);let e=new Set;for(let i of Object.keys(n))e.add(i);for(let i of Object.keys(t))e.add(i);let r=new Ct;for(let i of e){let o=Dv(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=o}return r}var Ct,An,ph=Me(()=>{"use strict";oa();sa();Vd();Zt();Ct=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,o={};for(;i<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[i]],r!==void 0&&!ol(r))return null;i+=1}r=r?nh(r):new Ct;for(let[l,c]of Object.entries(t.props)){let d=r[l];o[l]=d,c===void 0?delete r[l]:r[l]=c}for(;i>0;){if(Object.keys(r).length===0){let l=e[i-1];l&&(r=nh(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=nh(l);c[t.path[i-1]]=r,r=c}else{let c=new Ct;c[t.path[i-1]]=r,r=c}}i-=1}let a=Object.setPrototypeOf(r,Ct.prototype),s={...t,props:o};return{data:a,actual:t,reverse:s}}};(r=>{function n(i,o){return kd(i,o)??i}r.apply=n;function t(i,o){return Dv(i,o)}r.merge=t;function e(i,o){let a=0,s=o.path,l=i;for(;a<s.length&&l!==void 0;){if(l=Ot.zoomOnce(l,s[a]),l===void 0)return o;if(!ol(l))return;a+=1}if(l===void 0)return o;if(!!ol(l))if(o.type===0){let c={...o.props};for(let d of Object.keys(l))delete c[d];return{...o,props:c}}else if(o.type===1||o.type===4||o.type===7){let c=Iv([o],l);return c?c[0]:o}else return o}r.filterOp=e})(An||(An={}))});var al,zt,Rv,Kw=Me(()=>{"use strict";Zt();Vd();_d();oa();lh();ch();sa();Ov();ph();(t=>{function n(e,r){let i=Ot.zoom(r,e.path);if(typeof i=="object"){let o={};for(let a of Object.keys(e.props))o[a]=i[a];return{...e,props:o}}else return{...e,props:{}}}t.replaceProps=n})(al||(al={}));(s=>{function n(l,c){return{...l,path:l.path.slice(c)}}s.drop=n;function t(l,c){return e(l,c)?.data??l}s.applySimple=t;function e(l,c){let d=c.path,u=[];for(;;){let p;if(l instanceof Ct&&c.type===0&&(p=l.runOp({...c,path:d.slice(u.length)}),p===null&&(p=void 0)),p===void 0&&u.length===d.length&&(l instanceof bt||l instanceof fe||l instanceof Se?p=l.runOp(c):p=aa.runOp(l,c)),p!==void 0)if(p!==null){let m=p.data;for(let y=u.length-1;y>=0;y--){let g=d[y],b=u[y];if(b instanceof bt){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof fe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Se){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Ct){let x={...b,[g]:m};m=Object.setPrototypeOf(x,Ct.prototype)}else if(typeof b=="object")if(Array.isArray(b)||pi(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let x=m;m=pi(b)?b.slice():[...b],m[g]=x}else m=aa.tryPreservePrototype(b,{...b,[g]:m});else return null}return{data:m,actual:{...p.actual,path:d},reverse:{...p.reverse,path:d}}}else return null;let h=d[u.length],f;if(l instanceof bt){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else if(l instanceof fe){if(typeof h=="number")throw new Error("");f=l.get(h)?.data}else l!==null&&(f=l[h]);if(f!==void 0)u.push(l),l=f;else return null}}s.apply=e;function r(l,c){for(let d=0;d<l.length&&d<c.length;d++)if(l[d]!==c[d])return!0;return!1}s.pathDisjoint=r;function i(l,c){if(l.length!==c.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==c[d])return!1;return!0}s.pathEq=i;function o(l,c){return r(l.path,c.path)}s.commutative=o;function a(l,c){return l.type===0&&c.type===0&&i(l.path,c.path)?Object.keys(l.props).every(d=>c.props[d]!==void 0):!1}s.subsumed=a})(zt||(zt={}));(l=>{function n(){return[]}l.empty=n;function t(c,d){let u=[];for(let p of c){let[h,...f]=p.path;h===d&&u.push({...p,path:f})}return u}l.removePrefix=t;function e(c,d){return c.map(u=>({...u,path:[d,...u.path]}))}l.addPrefix=e;function r(c,d){return[...c,...d]}l.concat=r;function i(c,d){return[...c.filter(p=>!d.some(h=>zt.subsumed(p,h))),...d]}l.compress=i;function o(c,d){return c.every(u=>d.every(p=>zt.commutative(u,p)))}l.commutative=o;function a(c,d){for(let u of d){let p=s(c,u);p!==null&&(c=p.data)}return c}l.applyAll=a;function s(c,d){let u=c,p=[],h=[];for(let f of d)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,y,g;if(f.type===3?(m=Ot.zoom(u,[...f.path,f.id]),g=zt.apply(u,{...f,type:2})):(m=Ot.zoom(u,[...f.path,f.id,"value"]),g=zt.apply(u,f)),g!==null){u=g.data;let[b,x]=Yw(u,{[f.id]:m});u=b;for(let S=0;S<x.length;S++){let v=x[S],w=v.pop();if(typeof w=="number"){let A=[w];for(let P=S+1;P<x.length;P++){let M=x[P],R=M[M.length-1];if(typeof R=="number"&&Ot.equal(v,M.slice(0,M.length-1)))A.push(R),x.splice(P,1);else break}let E=Ot.zoom(u,v);y=E.map((P,M)=>A.includes(M)?f.id:P),m=E,w=v.pop()}else{if(w==="alphaOverride"||w==="alpha"){m/=100;let A=m,E=Ot.zoom(u,v.slice(0,v.length-2)),P=E.layers.map(M=>M.id===v[v.length-1]?{...M,data:{...M.data,[w]:A}}:M);Object.setPrototypeOf(P,Object.getPrototypeOf(E.layers)),E.layers=P}y=f.id}p.push({type:0,path:v,props:{[w]:m}}),h.push({type:0,path:v,props:{[w]:y}})}h.push(g.reverse),p.push(g.actual)}}else{let m=zt.apply(u,f);m!==null&&(p.push(m.actual),u=m.data,h.push(m.reverse))}}catch(m){if(m instanceof nl)return null;throw m}return{data:u,actual:p,reverse:h.reverse()}}l.apply=s})(Rv||(Rv={}))});function Bv(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Ot.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}function mh(n,t,e){return e instanceof bt?new sl(n,t,e):e instanceof fe?new ll(n,t,e):e instanceof Se?new Proxy(new Lv(n,t,e),hL):e!==null&&typeof e=="object"?pi(e)?e:new Proxy(new Nv(n,t,e),pL):e}function _v(n){let t=new hh(n);return[mh(t,"",n),t]}function cl(n,t){let[e,r]=_v(n);return t(e),r.result()}function Ht(n){return n instanceof sl||n instanceof ll?n._current:n!==null&&typeof n=="object"?n[Zw]:n}var Zw,uL,fh,ts,Nv,Lv,Jw,pL,hL,sl,ll,hh,Fv=Me(()=>{"use strict";_d();oa();ch();sa();Zt();Vd();Zw=Symbol(),uL=Symbol(),fh=Symbol(),ts=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let o=r;for(;!(i instanceof hh);){let a=i._path,s=i._current;if(a!==""&&o.splice(0,0,a),i=i._parent,i===null)return;i.update(a,s)}i.push(o,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[fh];r&&r(),delete this._children[t]}}}},Nv=class extends ts{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=aa.tryPreservePrototype(this._current,{...this._current,[t]:e})}runOp(t){this.reportOp(t,aa.runOp(this._current,t),t.path)}},Lv=class extends ts{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Se.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Jw={get(n,t){if(t===fh)return()=>{n._parent=null};if(t===Zw)return n._current;if(t===uL)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e[t],a=mh(n,t,o);return a!==o?(r===void 0&&(r={},n._children=r),r[t]=a,a):o},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},pL={...Jw,set(n,t,e){let r={type:0,props:{[t]:Ht(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},hL={...Jw,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},sl=class extends ts{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fh]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e.get(t)?.data,a=mh(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}add(t,e,r,i,o){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,i[o],a.id,a.data,a.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.add(t,i[o],a.id,a.data,a.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,i[o],a)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let a=r[o];this.move(t,i[o],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},ll=class extends ts{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fh]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id,o=this._current[r].fi;t(this.data(this._current[r].id),i,o,r)}}find(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:r}=this._current.at(t);return{id:e,fi:r,data:this.data(e)}}data(t){let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e.get(t)?.data,a=mh(this,t,o);return a!==o?(r===void 0&&(r={},this._children=r),r[t]=a,a):o}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};hh=class extends ts{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){Bv(this.ts,e,t),Bv(this.actual,r,t),Bv(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}});var Ot,Vd=Me(()=>{"use strict";sh();Fv();sa();oa();Zt();(o=>{function n(a,s){if(s.length===a.length){let l=0;for(;l<a.length;){if(a[l]!==s[l])return!1;l+=1}}else return!1;return!0}o.equal=n;function t(a,s,l){let c=r(l,a);if(c!==void 0&&typeof c=="object"&&c!==null){let d={...s};return Object.keys(c).forEach(u=>{delete d[u]}),d}else return s}o.removeOverridden=t;function e(a,s){if((a instanceof bt||a instanceof sl)&&typeof s=="string")return a.data(s);if((a instanceof fe||a instanceof ll)&&typeof s=="string")return a.data(s);if(typeof s=="number"&&Array.isArray(a))return a[s];if(typeof s=="string"&&typeof a=="object"&&a!==null)return a[s]}o.zoomOnce=e;function r(a,s,l=0){for(;l<s.length&&a!==void 0;)a=e(a,s[l]),l+=1;return a}o.zoom=r;function i(a,s){let l=[];function c(d,u){if(d instanceof es&&d.id===s.id)l.push(u);else if(d instanceof fe)for(let p=0;p<d.length;p++)c(d[p].data,[...u,d[p].id]);else if(d instanceof bt)d.traverse((p,h)=>{c(h,[...u,p])});else if(Array.isArray(d)){if(typeof d[0]=="number")return;for(let p=0;p<d.length;p++)c(d[p],[...u,p])}else{if(pi(d))return;if(typeof d=="object"&&d!==null)for(let p in d)c(d[p],[...u,p])}}return c(a,[]),l}o.findPathes=i})(Ot||(Ot={}))});var $w=Me(()=>{"use strict"});function eA(n,t){let e=[];if(t.length===n.length){let r=0;for(;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}}else return null;return e}function Ye(n,t){let e=[];if(t.length<=n.length){let r=0;for(;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}}else return null;return e}var tA=Me(()=>{"use strict"});function yh(n){try{if(!It.trusted&&!ca){let e=nt.sharedLength||0;e<nt.length&&(nt.length=e)}let t;if(It.randomAccessStructure&&ge[U]<64&&ge[U]>=32&&nA?(t=nA(ge,U,Ni,It),ge=null,!(n&&n.lazy)&&t&&(t=t.toJSON()),U=Ni):t=or(),Pr&&(U=Pr.postBundlePosition,Pr=null),ca&&(nt.restoreStructures=null),U==Ni)nt&&nt.restoreStructures&&sA(),nt=null,ge=null,fo&&(fo=null);else{if(U>Ni)throw new Error("Unexpected end of MessagePack data");if(!ca){let e;try{e=JSON.stringify(t,(r,i)=>typeof i=="bigint"?`${i}n`:i).slice(0,100)}catch(r){e="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+e)}}return t}catch(t){throw nt&&nt.restoreStructures&&sA(),gh(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||U>Ni)&&(t.incomplete=!0),t}}function sA(){for(let n in nt.restoreStructures)nt[n]=nt.restoreStructures[n];nt.restoreStructures=null}function or(){let n=ge[U++];if(n<160)if(n<128){if(n<64)return n;{let t=nt[n&63]||It.getStructures&&yA()[n&63];return t?(t.read||(t.read=Hv(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,It.mapsAsObjects){let t={};for(let e=0;e<n;e++){let r=vA();r==="__proto__"&&(r="__proto_"),t[r]=or()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(or(),or());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=or();return It.freezeData?Object.freeze(t):t}else if(n<192){let t=n-160;if(En>=U)return la.slice(U-Bi,(U+=t)-Bi);if(En==0&&Ni<140){let e=t<16?Wv(t):gA(t);if(e!=null)return e}return zv(t)}else{let t;switch(n){case 192:return null;case 193:return Pr?(t=or(),t>0?Pr[1].slice(Pr.position1,Pr.position1+=t):Pr[0].slice(Pr.position0,Pr.position0-=t)):jv;case 194:return!1;case 195:return!0;case 196:if(t=ge[U++],t===void 0)throw new Error("Unexpected end of buffer");return kv(t);case 197:return t=tt.getUint16(U),U+=2,kv(t);case 198:return t=tt.getUint32(U),U+=4,kv(t);case 199:return rs(ge[U++]);case 200:return t=tt.getUint16(U),U+=2,rs(t);case 201:return t=tt.getUint32(U),U+=4,rs(t);case 202:if(t=tt.getFloat32(U),It.useFloat32>2){let e=bh[(ge[U]&127)<<1|ge[U+1]>>7];return U+=4,(e*t+(t>0?.5:-.5)>>0)/e}return U+=4,t;case 203:return t=tt.getFloat64(U),U+=8,t;case 204:return ge[U++];case 205:return t=tt.getUint16(U),U+=2,t;case 206:return t=tt.getUint32(U),U+=4,t;case 207:return It.int64AsType==="number"?(t=tt.getUint32(U)*4294967296,t+=tt.getUint32(U+4)):It.int64AsType==="string"?t=tt.getBigUint64(U).toString():It.int64AsType==="auto"?(t=tt.getBigUint64(U),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=tt.getBigUint64(U),U+=8,t;case 208:return tt.getInt8(U++);case 209:return t=tt.getInt16(U),U+=2,t;case 210:return t=tt.getInt32(U),U+=4,t;case 211:return It.int64AsType==="number"?(t=tt.getInt32(U)*4294967296,t+=tt.getUint32(U+4)):It.int64AsType==="string"?t=tt.getBigInt64(U).toString():It.int64AsType==="auto"?(t=tt.getBigInt64(U),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=tt.getBigInt64(U),U+=8,t;case 212:if(t=ge[U++],t==114)return hA(ge[U++]&63);{let e=zr[t];if(e)return e.read?(U++,e.read(or())):e.noBuffer?(U++,e()):e(ge.subarray(U,++U));throw new Error("Unknown extension "+t)}case 213:return t=ge[U],t==114?(U++,hA(ge[U++]&63,ge[U++])):rs(2);case 214:return rs(4);case 215:return rs(8);case 216:return rs(16);case 217:return t=ge[U++],En>=U?la.slice(U-Bi,(U+=t)-Bi):mL(t);case 218:return t=tt.getUint16(U),U+=2,En>=U?la.slice(U-Bi,(U+=t)-Bi):yL(t);case 219:return t=tt.getUint32(U),U+=4,En>=U?la.slice(U-Bi,(U+=t)-Bi):gL(t);case 220:return t=tt.getUint16(U),U+=2,cA(t);case 221:return t=tt.getUint32(U),U+=4,cA(t);case 222:return t=tt.getUint16(U),U+=2,dA(t);case 223:return t=tt.getUint32(U),U+=4,dA(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}function Hv(n,t){function e(){if(e.count++>iA){let i;try{i=n.read=new Function("r","return function(){return "+(It.freezeData?"Object.freeze":"")+"({"+n.map(o=>o==="__proto__"?"__proto_:r()":fL.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"})}")(or)}catch{return iA=1/0,e()}return n.read0=i,n.highByte===0&&(n.read=lA(t,n.read)),i()}let r={};for(let i=0,o=n.length;i<o;i++){let a=n[i];a==="__proto__"&&(a="__proto_"),r[a]=or()}return It.freezeData?Object.freeze(r):r}return e.count=0,n.read0=e,n.highByte===0?lA(t,e):e}function yA(){let n=xA(()=>(ge=null,It.getStructures()));return nt=It._mergeStructures(n,nt)}function Ud(n){let t;if(n<16&&(t=Wv(n)))return t;if(n>64&&Vv)return Vv.decode(ge.subarray(U,U+=n));let e=U+n,r=[];for(t="";U<e;){let i=ge[U++];if((i&128)===0)r.push(i);else if((i&224)===192){let o=ge[U++]&63,a=(i&31)<<6|o;a<128?r.push(65533):r.push(a)}else if((i&240)===224){let o=ge[U++]&63,a=ge[U++]&63,s=(i&31)<<12|o<<6|a;s<2048||s>=55296&&s<=57343?r.push(65533):r.push(s)}else if((i&248)===240){let o=ge[U++]&63,a=ge[U++]&63,s=ge[U++]&63,l=(i&7)<<18|o<<12|a<<6|s;l<65536||l>1114111?r.push(65533):(l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l))}else r.push(65533);r.length>=4096&&(t+=Tr.apply(String,r),r.length=0)}return r.length>0&&(t+=Tr.apply(String,r)),t}function cA(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=or();return It.freezeData?Object.freeze(t):t}function dA(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++){let r=vA();r==="__proto__"&&(r="__proto_"),t[r]=or()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(or(),or());return t}}function gA(n){let t=U,e=new Array(n);for(let r=0;r<n;r++){let i=ge[U++];if((i&128)>0){U=t;return}e[r]=i}return Tr.apply(String,e)}function Wv(n){if(n<4)if(n<2){if(n===0)return"";{let t=ge[U++];if((t&128)>1){U-=1;return}return Tr(t)}}else{let t=ge[U++],e=ge[U++];if((t&128)>0||(e&128)>0){U-=2;return}if(n<3)return Tr(t,e);let r=ge[U++];if((r&128)>0){U-=3;return}return Tr(t,e,r)}else{let t=ge[U++],e=ge[U++],r=ge[U++],i=ge[U++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){U-=4;return}if(n<6){if(n===4)return Tr(t,e,r,i);{let o=ge[U++];if((o&128)>0){U-=5;return}return Tr(t,e,r,i,o)}}else if(n<8){let o=ge[U++],a=ge[U++];if((o&128)>0||(a&128)>0){U-=6;return}if(n<7)return Tr(t,e,r,i,o,a);let s=ge[U++];if((s&128)>0){U-=7;return}return Tr(t,e,r,i,o,a,s)}else{let o=ge[U++],a=ge[U++],s=ge[U++],l=ge[U++];if((o&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){U-=8;return}if(n<10){if(n===8)return Tr(t,e,r,i,o,a,s,l);{let c=ge[U++];if((c&128)>0){U-=9;return}return Tr(t,e,r,i,o,a,s,l,c)}}else if(n<12){let c=ge[U++],d=ge[U++];if((c&128)>0||(d&128)>0){U-=10;return}if(n<11)return Tr(t,e,r,i,o,a,s,l,c,d);let u=ge[U++];if((u&128)>0){U-=11;return}return Tr(t,e,r,i,o,a,s,l,c,d,u)}else{let c=ge[U++],d=ge[U++],u=ge[U++],p=ge[U++];if((c&128)>0||(d&128)>0||(u&128)>0||(p&128)>0){U-=12;return}if(n<14){if(n===12)return Tr(t,e,r,i,o,a,s,l,c,d,u,p);{let h=ge[U++];if((h&128)>0){U-=13;return}return Tr(t,e,r,i,o,a,s,l,c,d,u,p,h)}}else{let h=ge[U++],f=ge[U++];if((h&128)>0||(f&128)>0){U-=14;return}if(n<15)return Tr(t,e,r,i,o,a,s,l,c,d,u,p,h,f);let m=ge[U++];if((m&128)>0){U-=15;return}return Tr(t,e,r,i,o,a,s,l,c,d,u,p,h,f,m)}}}}}function uA(){let n=ge[U++],t;if(n<192)t=n-160;else switch(n){case 217:t=ge[U++];break;case 218:t=tt.getUint16(U),U+=2;break;case 219:t=tt.getUint32(U),U+=4;break;default:throw new Error("Expected string")}return Ud(t)}function kv(n){return It.copyBuffers?Uint8Array.prototype.slice.call(ge,U,U+=n):ge.subarray(U,U+=n)}function rs(n){let t=ge[U++];if(zr[t]){let e;return zr[t](ge.subarray(U,e=U+=n),r=>{U=r;try{return or()}finally{U=e}})}else throw new Error("Unknown extension type "+t)}function vA(){let n=ge[U++];if(n>=160&&n<192){if(n=n-160,En>=U)return la.slice(U-Bi,(U+=n)-Bi);if(!(En==0&&Ni<180))return zv(n)}else return U--,bA(or());let t=(n<<5^(n>1?tt.getUint16(U):n>0?ge[U]:0))&4095,e=pA[t],r=U,i=U+n-3,o,a=0;if(e&&e.bytes==n){for(;r<i;){if(o=tt.getUint32(r),o!=e[a++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(o=ge[r++],o!=e[a++]){r=1879048192;break}if(r===i)return U=r,e.string;i-=3,r=U}for(e=[],pA[t]=e,e.bytes=n;r<i;)o=tt.getUint32(r),e.push(o),r+=4;for(i+=3;r<i;)o=ge[r++],e.push(o);let s=n<16?Wv(n):gA(n);return s!=null?e.string=s:e.string=zv(n)}function bA(n){if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return n.toString();if(n==null)return n+"";if(It.allowArraysInMapKeys&&Array.isArray(n)&&n.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return n.flat().toString();throw new Error(`Invalid property type for record: ${typeof n}`)}function xA(n){aA&&aA();let t=Ni,e=U,r=Uv,i=Bi,o=En,a=la,s=Gv,l=fo,c=Pr,d=new Uint8Array(ge.slice(0,Ni)),u=nt,p=nt.slice(0,nt.length),h=It,f=ca,m=n();return Ni=t,U=e,Uv=r,Bi=i,En=o,la=a,Gv=s,fo=l,Pr=c,ge=d,ca=f,nt=u,nt.splice(0,nt.length,...p),It=h,tt=new DataView(ge.buffer,ge.byteOffset,ge.byteLength),m}function gh(){ge=null,fo=null,nt=null}function vh(n){n.unpack?zr[n.type]=n.unpack:zr[n.type]=n}var Vv,ge,Ni,U,mA,Gv,Uv,It,nt,la,Bi,En,Pr,fo,zr,tt,rA,Gd,jv,ca,iA,nA,oA,aA,Li,fL,lA,zv,mL,yL,gL,Tr,pA,hA,fA,qv,vL,bL,bh,xh,xL,SL,wL,Sh,AL,R9,is=Me(()=>{try{Vv=new TextDecoder}catch{}U=0,mA=[],Gv=mA,Uv=0,It={},Bi=0,En=0,zr=[],rA={useRecords:!1,mapsAsObjects:!0},Gd=class{},jv=new Gd;jv.name="MessagePack 0xC1";ca=!1,iA=2,Li=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(ge)return xA(()=>(gh(),this?this.unpack(t,e):Li.prototype.unpack.call(rA,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ni=e.end||t.length,U=e.start||0):(U=0,Ni=e>-1?e:t.length),Uv=0,En=0,la=null,Gv=mA,Pr=null,ge=t;try{tt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ge=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Li){if(It=this,this.structures)return nt=this.structures,yh(e);(!nt||nt.length>0)&&(nt=[])}else It=rA,(!nt||nt.length>0)&&(nt=[]);return yh(e)}unpackMultiple(t,e){let r,i=0;try{ca=!0;let o=t.length,a=this?this.unpack(t,o):xh.unpack(t,o);if(e){if(e(a,i,U)===!1)return;for(;U<o;)if(i=U,e(yh(),i,U)===!1)return}else{for(r=[a];U<o;)i=U,r.push(yh());return r}}catch(o){throw o.lastPosition=i,o.values=r,o}finally{ca=!1,gh()}}_mergeStructures(t,e){oA&&(t=oA.call(this,t)),t=t||[],Object.isFrozen(t)&&(t=t.map(r=>r.slice(0)));for(let r=0,i=t.length;r<i;r++){let o=t[r];o&&(o.isShared=!0,r>=32&&(o.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],o=e[r];o&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};fL=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;lA=(n,t)=>function(){let e=ge[U++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=nt[r]||yA()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=Hv(i,n)),i.read()};zv=Ud,mL=Ud,yL=Ud,gL=Ud;Tr=String.fromCharCode;pA=new Array(4096);hA=(n,t)=>{let e=or().map(bA),r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=nt[n];return i&&(i.isShared||ca)&&((nt.restoreStructures||(nt.restoreStructures=[]))[n]=i),nt[n]=e,e.read=Hv(e,r),(e.read0||e.read)()};zr[0]=()=>{};zr[0].noBuffer=!0;zr[66]=n=>{let t=n.byteLength%8||8,e=BigInt(n[0]&128?n[0]-256:n[0]);for(let r=1;r<t;r++)e<<=BigInt(8),e+=BigInt(n[r]);if(n.byteLength!==t){let r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=(o,a)=>{let s=a-o;if(s<=40){let u=r.getBigUint64(o);for(let p=o+8;p<a;p+=8)u<<=BigInt(64),u|=r.getBigUint64(p);return u}let l=o+(s>>4<<3),c=i(o,l),d=i(l,a);return c<<BigInt((a-l)*8)|d};e=e<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return e};fA={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};zr[101]=()=>{let n=or();if(!fA[n[0]]){let t=Error(n[1],{cause:n[2]});return t.name=n[0],t}return fA[n[0]](n[1],{cause:n[2]})};zr[105]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4);fo||(fo=new Map);let e=ge[U],r;e>=144&&e<160||e==220||e==221?r=[]:e>=128&&e<144||e==222||e==223?r=new Map:(e>=199&&e<=201||e>=212&&e<=216)&&ge[U+1]===115?r=new Set:r={};let i={target:r};fo.set(t,i);let o=or();if(i.used)Object.assign(r,o);else return i.target=o;if(r instanceof Map)for(let[a,s]of o.entries())r.set(a,s);if(r instanceof Set)for(let a of Array.from(o))r.add(a);return r};zr[112]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4),e=fo.get(t);return e.used=!0,e.target};zr[115]=()=>new Set(or());qv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array"),vL=typeof globalThis=="object"?globalThis:window;zr[116]=n=>{let t=n[0],e=Uint8Array.prototype.slice.call(n,1).buffer,r=qv[t];if(!r){if(t===16)return e;if(t===17)return new DataView(e);throw new Error("Could not find typed array for code "+t)}return new vL[r](e)};zr[120]=()=>{let n=or();return new RegExp(n[0],n[1])};bL=[];zr[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=U;return U+=t-n.length,Pr=bL,Pr=[uA(),uA()],Pr.position0=0,Pr.position1=0,Pr.postBundlePosition=U,U=e,or()};zr[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");bh=new Array(147);for(let n=0;n<256;n++)bh[n]=+("1e"+Math.floor(45.15-n*.30103));xh=new Li({useRecords:!1}),xL=xh.unpack,SL=xh.unpackMultiple,wL=xh.unpack,Sh={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},AL=new Float32Array(1),R9=new Uint8Array(AL.buffer,0,4)});function Xv(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:o,position:a}=e(4+i);o[a++]=199,o[a++]=i+1}else if(i+1<65536){var{target:o,position:a}=e(5+i);o[a++]=200,o[a++]=i+1>>8,o[a++]=i+1&255}else{var{target:o,position:a,targetView:s}=e(7+i);o[a++]=201,s.setUint32(a,i+1),a+=4}o[a++]=116,o[a++]=t,n.buffer||(n=new Uint8Array(n)),o.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Yv(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:o}=t(e+5);r[i++]=198,o.setUint32(i,e),i+=4}r.set(n,i)}function wA(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function PL(n,t){let e,r=t.length*6,i=n.length-r;for(;e=t.pop();){let o=e.offset,a=e.id;n.copyWithin(o+r,o,i),r-=6;let s=o+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,i=o}return n}function AA(n,t,e){if(Wt.length>0){Dt.setUint32(Wt.position+n,j+e-Wt.position-n),Wt.stringsPosition=j-n;let r=Wt;Wt=null,t(r[0]),t(r[1])}}function Qv(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ch.unshift(n.Class),Eh.unshift(n)}vh(n)}function ML(n,t){return n.isCompatible=e=>{let r=!e||(t.lastNamedStructuresLength||0)===e.length;return r||t._mergeStructures(e),r},n}var Ah,Eh,Ch,ul,wh,EA,SA,Y,zd,Dt,j,jr,Wt,EL,CL,TL,dl,ns,CA,OL,IL,DL,RL,BL,NL,TA,PA,MA,Kv=Me(()=>{is();is();is();try{Ah=new TextEncoder}catch{}ul=typeof Buffer<"u",wh=ul?function(n){return Buffer.allocUnsafeSlow(n)}:Uint8Array,EA=ul?Buffer:Uint8Array,SA=ul?4294967296:2144337920,j=0,Wt=null,CL=21760,TL=/[\u0080-\uFFFF]/,dl=Symbol("record-id"),ns=class extends Li{constructor(t){super(t),this.offset=0;let e,r,i,o,a,s=EA.prototype.utf8Write?function(C,B){return Y.utf8Write(C,B,Y.byteLength-B)}:Ah&&Ah.encodeInto?function(C,B){return Ah.encodeInto(C,Y.subarray(B)).written}:!1,l=this;t||(t={});let c=t&&t.sequential,d=t.structures||t.saveStructures,u=t.maxSharedStructures;if(u==null&&(u=d?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let p=t.maxOwnStructures;p==null&&(p=d?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let h=u>32||p+u>64,f=u+64,m=u+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],g=0,b=0;this.pack=this.encode=function(C,B){if(Y||(Y=new wh(8192),Dt=Y.dataView||(Y.dataView=new DataView(Y.buffer,0,8192)),j=0),jr=Y.length-10,jr-j<2048?(Y=new wh(Y.length),Dt=Y.dataView||(Y.dataView=new DataView(Y.buffer,0,Y.length)),jr=Y.length-10,j=0):j=j+7&2147483640,r=j,B&MA&&(j+=B&255),a=l.structuredClone?new Map:null,l.bundleStrings&&typeof C!="string"?(Wt=[],Wt.size=1/0):Wt=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let F=o.sharedLength||0;if(F>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let V=0;V<F;V++){let K=o[V];if(!K)continue;let q,G=o.transitions;for(let W=0,H=K.length;W<H;W++){let Z=K[W];q=G[Z],q||(q=G[Z]=Object.create(null)),G=q}G[dl]=V+64}this.lastNamedStructuresLength=F}c||(o.nextId=F+64)}i&&(i=!1);let _;try{l.randomAccessStructure&&!l.readOnlyStructures&&C&&typeof C=="object"?C.constructor===Object?N(C):C.constructor!==Map&&!Array.isArray(C)&&!Ch.some(V=>C instanceof V)?N(C.toJSON?C.toJSON():C):v(C):v(C);let F=Wt;if(Wt&&AA(r,v,0),a&&a.idsToInsert){let V=a.idsToInsert.sort((W,H)=>W.offset>H.offset?1:-1),K=V.length,q=-1;for(;F&&K>0;){let W=V[--K].offset+r;W<F.stringsPosition+r&&q===-1&&(q=0),W>F.position+r?q>=0&&(q+=6):(q>=0&&(Dt.setUint32(F.position+r,Dt.getUint32(F.position+r)+q),q=-1),F=F.previous,K++)}q>=0&&F&&Dt.setUint32(F.position+r,Dt.getUint32(F.position+r)+q),j+=V.length*6,j>jr&&M(j),l.offset=j;let G=PL(Y.subarray(r,j),V);return a=null,G}return l.offset=j,B&TA?(Y.start=r,Y.end=j,Y):Y.subarray(r,j)}catch(F){throw _=F,F}finally{if(o&&(x(),i&&l.saveStructures)){let F=o.sharedLength||0,V=Y.subarray(r,j),K=ML(o,l);if(!_)return l.saveStructures(K,K.isCompatible)===!1?(o.uninitialized=!0,l.pack(C,B)):(l.lastNamedStructuresLength=F,Y.length>1073741824&&(Y=null),V)}Y.length>1073741824&&(Y=null),B&PA&&(j=r)}};let x=()=>{b<10&&b++;let C=o.sharedLength||0;if(o.length>C&&!c&&(o.length=C),g>1e4)o.transitions=null,b=0,g=0,y.length>0&&(y=[]);else if(y.length>0&&!c){for(let B=0,_=y.length;B<_;B++)y[B][dl]=0;y=[]}},S=C=>{var B=C.length;B<16?Y[j++]=144|B:B<65536?(Y[j++]=220,Y[j++]=B>>8,Y[j++]=B&255):(Y[j++]=221,Dt.setUint32(j,B),j+=4);for(let _=0;_<B;_++)v(C[_])},v=C=>{j>jr&&(Y=M(j));var B=typeof C,_;if(B==="string"){let F=C.length;if(Wt&&F>=4&&F<4096){if((Wt.size+=F)>CL){let G,W=(Wt[0]?Wt[0].length*3+Wt[1].length:0)+10;j+W>jr&&(Y=M(j+W));let H;Wt.position?(H=Wt,Y[j]=200,j+=3,Y[j++]=98,G=j-r,j+=4,AA(r,v,0),Dt.setUint16(G+r-3,j-r-G)):(Y[j++]=214,Y[j++]=98,G=j-r,j+=4),Wt=["",""],Wt.previous=H,Wt.size=0,Wt.position=G}let q=TL.test(C);Wt[q?0:1]+=C,Y[j++]=193,v(q?-F:F);return}let V;F<32?V=1:F<256?V=2:F<65536?V=3:V=5;let K=F*3;if(j+K>jr&&(Y=M(j+K)),F<64||!s){let q,G,W,H=j+V;for(q=0;q<F;q++)G=C.charCodeAt(q),G<128?Y[H++]=G:G<2048?(Y[H++]=G>>6|192,Y[H++]=G&63|128):(G&64512)===55296&&((W=C.charCodeAt(q+1))&64512)===56320?(G=65536+((G&1023)<<10)+(W&1023),q++,Y[H++]=G>>18|240,Y[H++]=G>>12&63|128,Y[H++]=G>>6&63|128,Y[H++]=G&63|128):(Y[H++]=G>>12|224,Y[H++]=G>>6&63|128,Y[H++]=G&63|128);_=H-j-V}else _=s(C,j+V);_<32?Y[j++]=160|_:_<256?(V<2&&Y.copyWithin(j+2,j+1,j+1+_),Y[j++]=217,Y[j++]=_):_<65536?(V<3&&Y.copyWithin(j+3,j+2,j+2+_),Y[j++]=218,Y[j++]=_>>8,Y[j++]=_&255):(V<5&&Y.copyWithin(j+5,j+3,j+3+_),Y[j++]=219,Dt.setUint32(j,_),j+=4),j+=_}else if(B==="number")if(C>>>0===C)C<32||C<128&&this.useRecords===!1||C<64&&!this.randomAccessStructure?Y[j++]=C:C<256?(Y[j++]=204,Y[j++]=C):C<65536?(Y[j++]=205,Y[j++]=C>>8,Y[j++]=C&255):(Y[j++]=206,Dt.setUint32(j,C),j+=4);else if(C>>0===C)C>=-32?Y[j++]=256+C:C>=-128?(Y[j++]=208,Y[j++]=C+256):C>=-32768?(Y[j++]=209,Dt.setInt16(j,C),j+=2):(Y[j++]=210,Dt.setInt32(j,C),j+=4);else{let F;if((F=this.useFloat32)>0&&C<4294967296&&C>=-2147483648){Y[j++]=202,Dt.setFloat32(j,C);let V;if(F<4||(V=C*bh[(Y[j]&127)<<1|Y[j+1]>>7])>>0===V){j+=4;return}else j--}Y[j++]=203,Dt.setFloat64(j,C),j+=8}else if(B==="object"||B==="function")if(!C)Y[j++]=192;else{if(a){let V=a.get(C);if(V){if(!V.id){let K=a.idsToInsert||(a.idsToInsert=[]);V.id=K.push(V)}Y[j++]=214,Y[j++]=112,Dt.setUint32(j,V.id),j+=4;return}else a.set(C,{offset:j-r})}let F=C.constructor;if(F===Object)P(C);else if(F===Array)S(C);else if(F===Map)if(this.mapAsEmptyObject)Y[j++]=128;else{_=C.size,_<16?Y[j++]=128|_:_<65536?(Y[j++]=222,Y[j++]=_>>8,Y[j++]=_&255):(Y[j++]=223,Dt.setUint32(j,_),j+=4);for(let[V,K]of C)v(V),v(K)}else{for(let V=0,K=Eh.length;V<K;V++){let q=Ch[V];if(C instanceof q){let G=Eh[V];if(G.write){G.type&&(Y[j++]=212,Y[j++]=G.type,Y[j++]=0);let Q=G.write.call(this,C);Q===C?Array.isArray(C)?S(C):P(C):v(Q);return}let W=Y,H=Dt,Z=j;Y=null;let te;try{te=G.pack.call(this,C,Q=>(Y=W,W=null,j+=Q,j>jr&&M(j),{target:Y,targetView:Dt,position:j-Q}),v)}finally{W&&(Y=W,Dt=H,j=Z,jr=Y.length-10)}te&&(te.length+j>jr&&M(te.length+j),j=wA(te,Y,j,G.type));return}}if(Array.isArray(C))S(C);else{if(C.toJSON){let V=C.toJSON();if(V!==C)return v(V)}if(B==="function")return v(this.writeFunction&&this.writeFunction(C));P(C)}}}else if(B==="boolean")Y[j++]=C?195:194;else if(B==="bigint"){if(C<9223372036854776e3&&C>=-9223372036854776e3)Y[j++]=211,Dt.setBigInt64(j,C);else if(C<18446744073709552e3&&C>0)Y[j++]=207,Dt.setBigUint64(j,C);else if(this.largeBigIntToFloat)Y[j++]=203,Dt.setFloat64(j,Number(C));else{if(this.largeBigIntToString)return v(C.toString());if(this.useBigIntExtension||this.moreTypes){let F=C<0?BigInt(-1):BigInt(0),V;if(C>>BigInt(65536)===F){let K=BigInt(18446744073709552e3)-BigInt(1),q=[];for(;q.push(C&K),C>>BigInt(63)!==F;)C>>=BigInt(64);V=new Uint8Array(new BigUint64Array(q).buffer),V.reverse()}else{let K=C<0,q=(K?~C:C).toString(16);if(q.length%2?q="0"+q:parseInt(q.charAt(0),16)>=8&&(q="00"+q),ul)V=Buffer.from(q,"hex");else{V=new Uint8Array(q.length/2);for(let G=0;G<V.length;G++)V[G]=parseInt(q.slice(G*2,G*2+2),16)}if(K)for(let G=0;G<V.length;G++)V[G]=~V[G]}V.length+j>jr&&M(V.length+j),j=wA(V,Y,j,66);return}else throw new RangeError(C+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}j+=8}else if(B==="undefined")this.encodeUndefinedAsNil?Y[j++]=192:(Y[j++]=212,Y[j++]=0,Y[j++]=0);else throw new Error("Unknown type: "+B)},w=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?C=>{let B;if(this.skipValues){B=[];for(let V in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(V))&&!this.skipValues.includes(C[V])&&B.push(V)}else B=Object.keys(C);let _=B.length;_<16?Y[j++]=128|_:_<65536?(Y[j++]=222,Y[j++]=_>>8,Y[j++]=_&255):(Y[j++]=223,Dt.setUint32(j,_),j+=4);let F;if(this.coercibleKeyAsNumber)for(let V=0;V<_;V++){F=B[V];let K=Number(F);v(isNaN(K)?F:K),v(C[F])}else for(let V=0;V<_;V++)v(F=B[V]),v(C[F])}:C=>{Y[j++]=222;let B=j-r;j+=2;let _=0;for(let F in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(F))&&(v(F),v(C[F]),_++);if(_>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');Y[B+++r]=_>>8,Y[B+r]=_&255},A=this.useRecords===!1?w:t.progressiveRecords&&!h?C=>{let B,_=o.transitions||(o.transitions=Object.create(null)),F=j++-r,V;for(let K in C)if(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(K)){if(B=_[K],B)_=B;else{let q=Object.keys(C),G=_;_=o.transitions;let W=0;for(let H=0,Z=q.length;H<Z;H++){let te=q[H];B=_[te],B||(B=_[te]=Object.create(null),W++),_=B}F+r+1==j?(j--,R(_,q,W)):D(_,q,F,W),V=!0,_=G[K]}v(C[K])}if(!V){let K=_[dl];K?Y[F+r]=K:D(_,Object.keys(C),F,0)}}:C=>{let B,_=o.transitions||(o.transitions=Object.create(null)),F=0;for(let K in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(K))&&(B=_[K],B||(B=_[K]=Object.create(null),F++),_=B);let V=_[dl];V?V>=96&&h?(Y[j++]=((V-=96)&31)+96,Y[j++]=V>>5):Y[j++]=V:R(_,_.__keys__||Object.keys(C),F);for(let K in C)(typeof C.hasOwnProperty!="function"||C.hasOwnProperty(K))&&v(C[K])},E=typeof this.useRecords=="function"&&this.useRecords,P=E?C=>{E(C)?A(C):w(C)}:A,M=C=>{let B;if(C>16777216){if(C-r>SA)throw new Error("Packed buffer would be larger than maximum buffer size");B=Math.min(SA,Math.round(Math.max((C-r)*(C>67108864?1.25:2),4194304)/4096)*4096)}else B=(Math.max(C-r<<2,Y.length-1)>>12)+1<<12;let _=new wh(B);return Dt=_.dataView||(_.dataView=new DataView(_.buffer,0,B)),C=Math.min(C,Y.length),Y.copy?Y.copy(_,0,r,C):_.set(Y.slice(r,C)),j-=r,r=0,jr=_.length-10,Y=_},R=(C,B,_)=>{let F=o.nextId;F||(F=64),F<f&&this.shouldShareStructure&&!this.shouldShareStructure(B)?(F=o.nextOwnId,F<m||(F=f),o.nextOwnId=F+1):(F>=m&&(F=f),o.nextId=F+1);let V=B.highByte=F>=96&&h?F-96>>5:-1;C[dl]=F,C.__keys__=B,o[F-64]=B,F<f?(B.isShared=!0,o.sharedLength=F-63,i=!0,V>=0?(Y[j++]=(F&31)+96,Y[j++]=V):Y[j++]=F):(V>=0?(Y[j++]=213,Y[j++]=114,Y[j++]=(F&31)+96,Y[j++]=V):(Y[j++]=212,Y[j++]=114,Y[j++]=F),_&&(g+=b*_),y.length>=p&&(y.shift()[dl]=0),y.push(C),v(B))},D=(C,B,_,F)=>{let V=Y,K=j,q=jr,G=r;Y=zd,j=0,r=0,Y||(zd=Y=new wh(8192)),jr=Y.length-10,R(C,B,F),zd=Y;let W=j;if(Y=V,j=K,jr=q,r=G,W>1){let H=j+W-1;H>jr&&M(H);let Z=_+r;Y.copyWithin(Z+W,Z+1,j),Y.set(zd.slice(0,W),Z),j=H}else Y[_+r]=zd[0]},N=C=>{let B=EL(C,Y,r,j,o,M,(_,F,V)=>{if(V)return i=!0;j=F;let K=Y;return v(_),x(),K!==Y?{position:j,targetView:Dt,target:Y}:j},this);if(B===0)return P(C);j=B}}useBuffer(t){Y=t,Y.dataView||(Y.dataView=new DataView(Y.buffer,Y.byteOffset,Y.byteLength)),Dt=Y.dataView,j=0}set position(t){j=t}get position(){return j}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Ch=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Gd];Eh=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:o,position:a}=t(6);i[a++]=214,i[a++]=255,o.setUint32(a,r)}else if(r>0&&r<4294967296){let{target:i,targetView:o,position:a}=t(10);i[a++]=215,i[a++]=255,o.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:o,position:a}=t(3);i[a++]=212,i[a++]=255,i[a++]=255}else{let{target:i,targetView:o,position:a}=t(15);i[a++]=199,i[a++]=12,i[a++]=255,o.setUint32(a,n.getMilliseconds()*1e6),o.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){if(this.setAsEmptyObject)return t(0),e({});let r=Array.from(n),{target:i,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(i[o++]=212,i[o++]=115,i[o++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message,n.cause])}},{pack(n,t,e){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.moreTypes?Xv(n,16,t):Yv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==EA&&this.moreTypes?Xv(n,qv.indexOf(e.name),t):Yv(n,t)}},{pack(n,t){this.moreTypes?Xv(n,17,t):Yv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];CA=new ns({useRecords:!1}),OL=CA.pack,IL=CA.pack,{NEVER:DL,ALWAYS:RL,DECIMAL_ROUND:BL,DECIMAL_FIT:NL}=Sh,TA=512,PA=1024,MA=2048});var OA=Me(()=>{Kv();is()});var IA=Me(()=>{Kv();is();OA()});var Zv,LL,Th,DA=Me(()=>{"use strict";is();sh();ph();sa();_d();oa();Zv=[{Class:Se.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Se.prototype),n}},{Class:fe.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,fe.prototype),n}},{Class:bt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,bt.prototype),n}},{Class:es.prototype.constructor,type:4,write(n){return n.id},read(n){return new es(n)}},{Class:Ld.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ld(n)}},{Class:Ct.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ct.prototype),n}}];for(let n of Zv)vh(n);LL=new Li({structuredClone:!0});(t=>{function n(e){return LL.unpack(e)}t.deserialize=n})(Th||(Th={}))});function FL(n){let t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function Jv(n){if(pi(n))return n;if(Array.isArray(n))return n.map(Jv);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Jv(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var _L,os,RA=Me(()=>{"use strict";IA();Zt();DA();_L=new ns({structuredClone:!0});for(let n of Zv)Qv(n);(r=>{function n(i){return _L.pack(i)}r.serialize=n;function t(i){return Th.deserialize(i)}r.deserialize=t;function e(i){return FL(n(Jv(i))).toString()}r.checksum=e})(os||(os={}))});var ut=Me(()=>{Vd();Ww();lh();oa();_d();ch();sa();Kw();$w();Fv();tA();sh();RA();Ov();ph()});import{MathUtils as $v}from"three";function jd(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var BA,tb,NA,Ph,eb,LA,_A,FA,Mh,Oh,kA,VA,GA,UA,zA,Ih,Dh,jA,HA,WA,qA,kL=Me(()=>{"use strict";ut();(e=>{function n(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=n;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(BA||(BA={}));tb={["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"]};(e=>{function n(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=n;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new fe}:{type:r,disabled:!1,name:"",key:void 0,actions:new fe}}e.defaultData=t})(NA||(NA={}));(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(Ph||(Ph={}));(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:Ph.propertyDefaultData(i),rOperand:{...Ph.valueDefaultData}}}r.comparisonDefaultData=n;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}r.distanceDefaultData=t;function e(i,o){return{type:"State",object:i??null,state:o??null}}r.stateDefaultData=e})(eb||(eb={}));(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(LA||(LA={}));(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,name:"",inActions:new fe,outActions:new fe,condition:eb.distanceDefaultData(r)}}e.defaultData=t})(_A||(_A={}));(t=>t.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 fe,drop:new fe}})(FA||(FA={}));(t=>t.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 fe})(Mh||(Mh={}));(t=>t.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})(Oh||(Oh={}));(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,name:"",actions:new fe}}e.defaultData=t})(kA||(kA={}));(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new fe}}e.defaultData=t})(VA||(VA={}));(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,name:"",actions:new fe}}e.defaultData=t})(GA||(GA={}));(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new fe}}e.defaultData=t})(UA||(UA={}));(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new fe,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(zA||(zA={}));(a=>{a.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(s){return s.type==="Resize"}a.is=t;function e(s){return typeof s=="string"?s:"custom"}a.sizeToDevice=e;function r(s){return typeof s=="string"?[...a.defaultSizes[s]]:[...s]}a.deviceToSize=r;function i(){let s={size:"mobile",operator:"<",actions:new fe},l={size:"tablet",operator:"<",actions:new fe},c={size:[...a.defaultSizes.custom],operator:"<>",actions:new fe},d=new fe;return d.push({id:$v.generateUUID(),fi:0,data:s},{id:$v.generateUUID(),fi:1,data:l},{id:$v.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:d}}a.defaultData=i;function o(){return{size:[...a.defaultSizes.custom],operator:"<>",actions:new fe}}a.defaultBreakpointData=o})(Ih||(Ih={}));(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"]};function t(i){return i.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",name:"",actions:new fe,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Dh||(Dh={}));(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",name:"",successActions:new fe,errorActions:new fe,userAPIId:""}}e.defaultData=t})(jA||(jA={}));(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new fe,userWebhookId:""}}e.defaultData=t})(HA||(HA={}));(e=>{function n(r){return r.type==="AIAssistantListener"}e.is=n;function t(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new fe,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=t})(WA||(WA={}));(e=>{function n(r){return r.type==="AIAssistantTrigger"}e.is=n;function t(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new fe}}e.defaultData=t})(qA||(qA={}))});function QA(n){let t=typeof n;return n!==null&&(t==="object"||t==="function")}function rb(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Cn,ua,KA,ar,Si,_i,as,XA,da,Ut,Ue,Rh,mo,ss,YA,wi=Me(()=>{"use strict";Cn="personal camera",ua="a218fcc3-276b-49b9-b485-49037fd14f5f",KA=2500134,ar=5526619;(h=>{function n(f,m){return f[0]===m[0]&&f[1]===m[1]}h.isEqual=n;function t(f,m,y){return[f[0]+(m[0]-f[0])*y,f[1]+(m[1]-f[1])*y]}h.lerp=t;function e(f,m){return[f[0]+m[0],f[1]+m[1]]}h.add=e;function r(f,m){return[f[0]-m[0],f[1]-m[1]]}h.sub=r;function i(f,m){return[f[0]*m[0],f[1]*m[1]]}h.multiply=i;function o(f,m){return[f[0]/m[0],f[1]/m[1]]}h.divide=o;function a(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}h.distanceSquared=a;function s(f,m){return Math.sqrt(a(f,m))}h.distance=s;function l(f,m){return f[0]*m[0]+f[1]*m[1]}h.dot=l;function c(f,m){return[f[0]*m,f[1]*m]}h.scalarMultiply=c;function d(f,m,y){let g=h.sub(m,f),b=h.sub(y,f),x=h.dot(g,b)/h.dot(g,g),S=h.scalarMultiply(g,x);return h.add(f,S)}h.projectionOnto=d;function u(f,m,y){return s(f,d(f,m,y))}h.projectionOntoDistance=u;function p(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}h.center=p})(Si||(Si={}));(s=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=n;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=r;function i(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=i;function o(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=o;function a(l,c,d){return[l[0]+(c[0]-l[0])*d,l[1]+(c[1]-l[1])*d,l[2]+(c[2]-l[2])*d]}s.lerp=a})(_i||(_i={}));(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o,r[2]+(i[2]-r[2])*o,r[3]+(i[3]-r[3])*o]}e.lerp=t})(as||(as={}));(a=>{let n=180/Math.PI,t=Math.PI/180;function e(s){return typeof s=="number"?s*n:s}function r(s){return typeof s=="number"?s*t:s}function i(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=i;function o(s){return[r(s[0]),r(s[1]),r(s[2])]}a.degToRad=o})(XA||(XA={}));(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(o,a){for(let s=0;s<16;s++)if(o[s]!==a[s])return!1;return!0}i.isEqual=t;function e(o){return o??i.identity}i.simplify=e;function r(o,a){let s=a.slice(0);for(let l=0,c=a.length;l<c;l+=3){let d=o[3]*a[l]+o[7]*a[l+1]+o[11]*a[l+2]+o[15];s[l]=(o[0]*a[l]+o[4]*a[l+1]+o[8]*a[l+2]+o[12])/d,s[l+1]=(o[1]*a[l]+o[5]*a[l+1]+o[9]*a[l+2]+o[13])/d,s[l+2]=(o[2]*a[l]+o[6]*a[l+1]+o[10]*a[l+2]+o[14])/d}return s}i.applyMatrix4=r})(da||(da={}));(p=>{function n(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}p.isRGB=n,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}p.toRgb255a1=i;function o(h){return{r:h.r,g:h.g,b:h.b}}p.clone=o;function a(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}p.fromHex=a;function s(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}p.toHex=s;function l(h,f){return h.r===f.r&&h.g===f.g&&h.b===f.b}p.equals=l;function c(h,f){return h.r.toFixed(2)===f.r.toFixed(2)&&h.g.toFixed(2)===f.g.toFixed(2)&&h.b.toFixed(2)===f.b.toFixed(2)}p.equalsFixed=c;function d(h,f,m){return{r:h.r+(f.r-h.r)*m,g:h.g+(f.g-h.g)*m,b:h.b+(f.b-h.b)*m}}p.lerp=d;function u(h){return QA(h)?"r"in h&&"g"in h&&"b"in h&&!("a"in h):!1}p.is=u})(Ut||(Ut={}));(d=>{d.white={...Ut.white,a:1};function t(u){return QA(u)?"r"in u&&"g"in u&&"b"in u&&"a"in u:!1}d.is=t,d.transparent={...Ut.white,a:0};function r(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}d.from0to1=r;function i(u,p){return{...Ut.fromHex(u),a:p}}d.fromHexAndA=i;function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}d.toRgb255a1=o;function a(u,p){return Ut.equals(u,p)&&u.a===p.a}d.equals=a;function s(u,p){return Ut.equalsFixed(u,p)&&u.a.toFixed(2)===p.a.toFixed(2)}d.equalsFixed=s;function l(u,p,h){return{r:u.r+(p.r-u.r)*h,g:u.g+(p.g-u.g)*h,b:u.b+(p.b-u.b)*h,a:u.a+(p.a-u.a)*h}}d.lerp=l;function c({r:u,g:p,b:h,a:f}=d.white){return`rgba(${u*255}, ${p*255}, ${h*255}, ${f})`}d.toStyle=c})(Ue||(Ue={}));(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(Rh||(Rh={}));(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(mo||(mo={}));(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ss||(ss={}));(o=>(o.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]))(YA||(YA={}))});var on,an,ZA=Me(()=>{"use strict";(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(on||(on={}));(h=>{h.DefaultUp=[0,1,0],h.DefaultTargetOffset=1e3,h.MinTargetOffset=.001;function r(f){return f===void 0||!Number.isFinite(f)||f<h.MinTargetOffset?h.DefaultTargetOffset:f}h.sanitizeTargetOffset=r,h.DefaultAzimuth=-24,h.DefaultElevation=15;let a=h.DefaultAzimuth*Math.PI/180,s=h.DefaultElevation*Math.PI/180,l=180/Math.PI;h.DefaultPosition=[h.DefaultTargetOffset*Math.sin(a)*Math.cos(s),h.DefaultTargetOffset*Math.sin(s),h.DefaultTargetOffset*Math.cos(a)*Math.cos(s)],h.DefaultRotation=[Math.atan2(-Math.sin(s),Math.cos(a)*Math.cos(s))*l,Math.asin(Math.sin(a)*Math.cos(s))*l,Math.atan2(Math.sin(a)*Math.sin(s),Math.cos(a))*l],h.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:h.DefaultUp,isUpVectorFlipped:!1,targetOffset:h.DefaultTargetOffset};function p(f){return f.type==="PerspectiveCamera"?f.perspective?.zoom??1:f.orthographic?.zoom??1}h.getZoom=p})(an||(an={}))});var Tn,Bh,ib,Nh,Lh,_h,Fh,kh,JA=Me(()=>{"use strict";(r=>{function n(i,o=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:Math.max(typeof i[0]=="number"?i[0]:1,typeof i[1]=="number"?i[1]:1)*2,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 i[0]=="number"?i[0]+i[0]:1)*o,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:i.map(a=>(typeof a=="number"?a:1)*(1+o)),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"}}}r.defaultData=n;function t(i,o){let a={...i};if(ib.forEach(s=>{Object.assign(a,{[s]:o[s]??i[s]})}),a.radial={...i.radial},o.radial){let s=i.radial,l=o.radial;Nh.forEach(c=>{Object.assign(a.radial,{[c]:l[c]??s[c]})})}if(a.linear={...i.linear},o.linear){let s=i.linear,l=o.linear;Lh.forEach(c=>{Object.assign(a.linear,{[c]:l[c]??s[c]})})}if(a.grid={...i.grid},o.grid){let s=i.grid,l=o.grid;_h.forEach(c=>{Object.assign(a.grid,{[c]:l[c]??s[c]})})}if(a.toObject={...i.toObject},o.toObject){let s=i.toObject,l=o.toObject;Fh.forEach(c=>{Object.assign(a.toObject,{[c]:l[c]??s[c]})})}if(a.randomnessObject={...i.randomnessObject},o.randomnessObject){let s=i.randomnessObject,l=o.randomnessObject;kh.forEach(c=>{Object.assign(a.randomnessObject,{[c]:l[c]??s[c]})})}return a}r.merge=t;function e(i){return!!(i.randomnessObject||i.toObject)}r.isPartial=e})(Tn||(Tn={}));(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,o){let a=[];i.count!==void 0&&a.push({type:0,path:o,props:{count:i.count}});for(let s of t){let l=i[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...o,s],props:l})}return a}r.toOps=e})(Bh||(Bh={}));ib=["count"],Nh=["radius","start","end","position","scale","rotation"],Lh=["position","scale","rotation"],_h=["count","size"],Fh=["count","position","scale","rotation"],kh=["strength","scale","rotation","position","movement","seed","freqScale"]});var Vh,Gh,$A=Me(()=>{"use strict";wi();(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Vh||(Vh={}));(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Ue.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ue.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(r==="DirectionalLight")return{type:r,color:Ue.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Gh||(Gh={}))});var pl,eE=Me(()=>{"use strict";(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(pl||(pl={}))});var Uh,tE=Me(()=>{"use strict";(e=>(e.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"]))(Uh||(Uh={}))});var pa,nb=Me(()=>{"use strict";(t=>t.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]})(pa||(pa={}))});var ob,ab,zh,rE,iE=Me(()=>{"use strict";(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(ob||(ob={}));(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe&&(r.shadowCatcher??!1)===(i.shadowCatcher??!1)}e.equals=t})(ab||(ab={}));(t=>t.defaultData={...ab.defaultData,...ob.defaultData})(zh||(zh={}));(t=>{function n(e,r){let i=[];if("material"in e){let o=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;o&&i.push(o)}else if("materials"in e)for(let o of e.materials){let a=typeof o=="string"?r.materials[o]??r.lib.materials[o]?.asset:o;a&&i.push(a)}return i}t.getMaterialData=n})(rE||(rE={}))});var hl,nE=Me(()=>{"use strict";(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(hl||(hl={}))});function lE(n){return n.type!=="displace"}var oE,aE,Hd,sE,jh,cE,Ft,qt,Hh=Me(()=>{"use strict";ut();wi();nE();wi();(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="cavity"||e==="dust"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="reflection"||e==="matcap"||e==="displace"||e==="pattern"||e==="vertexColor"||e==="light"}t.is=n})(oE||(oE={}));(t=>{function n(e){return e==="luminance"||e==="r"||e==="g"||e==="b"||e==="a"}t.is=n})(aE||(aE={}));(t=>{function n(e){return typeof e=="object"&&e!==null&&e.image!=null}t.is=n})(Hd||(Hd={}));(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(sE||(sE={}));jh=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],cE=["wrapping","image","video","name","minFilter","magFilter"];(o=>{function n(a,s){let{texture:l,...c}=s;if(Object.assign(a,c),l){let d=a.texture;d&&Object.assign(d,l)}}o.patch=n;function t(a){return{...o.defaultData("color"),color:a}}o.defaultColorLayer=t;function e(a,s){return a==="light"&&s?r(s):i(a)}o.defaultData=e;function r(a){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}function i(a){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:hl.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...s,type:"color",color:Ut.fromHex(ar)};case"vertexColor":return{...s,type:"vertexColor"};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ut.fromHex(6710886),a:1},colorB:{...Ut.fromHex(6710886),a:1},colorC:{...Ut.fromHex(16777215),a:1},colorD:{...Ut.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{...s,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...s,type:"fresnel",color:Ue.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...s,type:"dust",color:Ue.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:Ue.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Ue.fromHexAndA(0,1),contourColor:Ue.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...s,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...s,type:"reflection",blur:0,thickness:10/1e4,steps:60,stepSize:5/1e3,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{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ut.fromHex(0),a:1},colorB:{...Ut.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}}}})(Ft||(Ft={}));(d=>{function n(u){return!u.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")}d.isMergable=n;function t(u){let p="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([f,m])=>{p+=`${f}${m}`,Array.isArray(m)?m.forEach(y=>p+=`${y}`):typeof m=="object"?Object.values(m).forEach(y=>{typeof y=="number"?p+=`${y.toFixed(4)}`:p+=`${y}`}):p+=`${m}`})}),p}d.getHash=t;function e(){return{layers:new fe}}d.defaultEmptyData=e;function r(u="layer1",p="layer2"){return o("physical",u,p)}d.defaultData=r;function i(u,p){return{...u,name:p}}d.withName=i;function o(u,p="layer1",h="layer2",f=Ut.fromHex(16777215)){let m=new fe;return m.push({fi:0,data:Ft.defaultData("light",u),id:p}),m.push({fi:1,data:Ft.defaultData("color"),id:h}),{layers:m}}d.defaultTwoLayerData=o;function a(u,p,h="layer1",f="layer2"){let m=new fe;return m.push({fi:0,data:Ft.defaultData("light",p),id:h}),m.push({fi:1,data:Ft.defaultColorLayer(u),id:f}),{layers:m}}d.defaultColorMaterial=a;function s(u){let p=Ft.defaultData("texture");u&&Object.assign(p.texture,{image:u});let h=new fe;return h.push({fi:0,data:p,id:"layer1"}),h.push({fi:1,data:{...Ft.defaultData("transmission"),alpha:1},id:"layer2"}),h.push({fi:2,data:{...Ft.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:h}}d.defaultUIObjectMaterial=s;function l(u,p="physical",h="layer1",f="layer2"){let m=Ft.defaultData("texture");Object.assign(m.texture,{image:u});let y=new fe;return y.push({fi:0,data:m,id:h}),y.push({fi:1,data:Ft.defaultData("light",p),id:f}),{layers:y}}d.defaultTwoLayerTextureData=l;function c(u,p="physical",h="layer1",f="layer2"){let m=Ft.defaultData("video");Object.assign(m.texture,{video:u});let y=new fe;return y.push({fi:0,data:m,id:h}),y.push({fi:1,data:Ft.defaultData("light",p),id:f}),{layers:y}}d.defaultTwoLayerVideoTextureData=c})(qt||(qt={}))});var ls,dE=Me(()=>{"use strict";ut();(t=>{function n(){return{points:new fe,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(ls||(ls={}))});var fl,cs,Wh,qh,Wd,uE=Me(()=>{"use strict";ut();(t=>{function n(){return{points:new fe,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=n})(fl||(fl={}));cs={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};(t=>{function n(e,r){let i={...e};return Wd.forEach(o=>{Object.assign(i,{[o]:r[o]??e[o]})}),i}t.merge=n})(Wh||(Wh={}));qh={shape:cs,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Wd=["depth","offset","angle","twist","startScale","endScale"]});var qd,Xh,Pn,Yh,sb=Me(()=>{"use strict";dE();uE();(r=>{function n(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"}r.is2DParametricMesh=n;function t(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"}r.isParametricMesh=t;function e(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"}r.isSwappableGeometry=e})(qd||(qd={}));(t=>{function n(e,r){let i={...e};return Object.assign(i,r),i.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Wh.merge(i.extrusion,r.extrusion))),i}t.merge=n})(Xh||(Xh={}));(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:fl.defaultData(),extrusion:qh};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ls.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(e==="DecalGeometry")return{type:e,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(e==="TextGeometry")return{type:e,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(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="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")}t.defaultData=n})(Pn||(Pn={}));Yh=["width","height","depth"]});var Fi,pE=Me(()=>{"use strict";wi();(a=>{a.defaultData={enabled:!1,useBackgroundColor:!1,color:Ut.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0};function t(s){return s.mode??"linear"}a.getMode=t;function e(s){let l=t(s);return l==="height"?1:l==="both"?2:0}a.getModeIndex=e;function r(s){return s.density??a.defaultData.density}a.getDensity=r;function i(s){return s.heightFalloff??a.defaultData.heightFalloff}a.getHeightFalloff=i;function o(s){return s.heightBase??a.defaultData.heightBase}a.getHeightBase=o})(Fi||(Fi={}))});var lb,Mn,cb=Me(()=>{"use strict";(t=>t.defaultData={image:null,rotation:0,blur:32,showBackground:!0})(lb||(lb={}));(t=>t.defaultData={enabled:!1,mode:"hdri",hdri:lb.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2})(Mn||(Mn={}))});var Qh,hE=Me(()=>{"use strict";(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(Qh||(Qh={}))});var Xd,db,ub,pb,ha,hb,Kh,fb=Me(()=>{"use strict";pE();cb();hE();wi();(e=>{e.defaultData={type:"normal",softShadowQuality:"low"};function t(r){return r==null?!1:r.type===void 0||r.type==="soft"}e.isSoft=t})(Xd||(Xd={}));(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(db||(db={}));(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(ub||(ub={}));(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1};function t(r){return r===void 0||r.pipeline==="classic"&&(r.toneMapping==="none"||r.toneMapping==="aces")&&r.exposure===1}e.isUntouched=t})(pb||(pb={}));(t=>t.defaultData={usePhysics:!1,gravity:-10})(ha||(ha={}));(t=>t.defaultData={playCamera:Cn,gameControlObject:null})(hb||(hb={}));(t=>t.defaultData={backgroundColor:Ue.fromHexAndA(KA,1),postprocessing:Qh.defaultData,fog:Fi.defaultData,sky:Mn.defaultData,globalPhysics:ha.defaultData,ambient:db.defaultData,ao:ub.defaultData,shadow:Xd.defaultData,publish:hb.defaultData,grading:pb.defaultData})(Kh||(Kh={}))});var Zh,fE=Me(()=>{"use strict";(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Zh||(Zh={}))});var mE,ml,SE,Jt,Jh,yE,gE,vE,bE,yo,ds,$h,yl,On,sn,xE,go,ef=Me(()=>{"use strict";ut();ZA();$A();eE();tE();nb();iE();wi();Hh();sb();JA();Zt();fb();fE();(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(mE||(mE={}));(i=>{i.identity={...Rh.identity,hiddenMatrix:da.identity};function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,pivot:o.pivot,pivotRotation:o.pivotRotation,hiddenMatrix:o.hiddenMatrix}}i.fromObject=t;function e(o,a){return{position:a?.position||o.position,rotation:a?.rotation||o.rotation,pivot:a?.pivot||o.pivot,pivotRotation:a?.pivotRotation||o.pivotRotation,scale:a?.scale||o.scale,hiddenMatrix:a?.hiddenMatrix||o.hiddenMatrix}}i.merge=e;function r(o,a){return oh({position:_i.isEqual(o.position,a.position)?void 0:a.position,rotation:_i.isEqual(o.rotation,a.rotation)?void 0:a.rotation,scale:_i.isEqual(o.scale,a.scale)?null:a.scale,hiddenMatrix:da.isEqual(o.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}i.diff=r})(ml||(ml={}));SE=["slide","offset"];(t=>t.defaultData={states:new fe,events:new fe,visible:!0,raycastLock:!1,physics:pa.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ml.identity,cloner:null})(Jt||(Jt={}));(t=>t.defaultData={type:"Empty",...Jt.defaultData})(Jh||(Jh={}));(t=>t.defaultData={type:"ParticleCollider",...Zh.defaultData,...Jt.defaultData})(yE||(yE={}));(t=>t.defaultData={type:"Component",...Jt.defaultData})(gE||(gE={}));(t=>t.defaultData={type:"Particle",...Jt.defaultData,...pl.defaultData})(vE||(vE={}));(t=>t.defaultData={type:"Hair",...Jt.defaultData,...Uh.defaultData})(bE||(bE={}));(t=>t.defaultData={type:"Mesh",...Jt.defaultData,...zh.defaultData})(yo||(yo={}));(t=>t.defaultData={...Jt.defaultData,...ml.identity,position:an.DefaultPosition,rotation:an.DefaultRotation,...an.defaultData})(ds||(ds={}));(e=>{function n(r){return{...Jt.defaultData,...Gh.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($h||($h={}));(e=>{function n(r,i,o=0){for(;o<i.length;){let a=r?r[i[o]]:void 0;if(i.length===o+1)return a;if(a)r=a.descendants,o+=1;else return}}e.resolveWithDes=n;function t(r,i,o=0){let a=n(r,i,o);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(yl||(yl={}));(o=>{o.rootOverrideProps=["physics","events"],o.compositeNonOptionalOverrideProps=["geometry"],o.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Jt.defaultData,...s,component:a,overrides:new Ct,physics:void 0,events:void 0,type:"Instance"}}o.ofComponent=r;function i(a){let s=ml.fromObject(a.data);return r(a.id,s)}o.fromComponentData=i})(On||(On={}));(e=>{e.defaultData={type:"Page",...Jt.defaultData,physics:{...pa.defaultData,fusedBody:!1},...Kh.defaultData,camera:ds.defaultData,timelines:new Se};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(sn||(sn={}));(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:da.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:pa.defaultData,states:new fe,events:new fe,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...an.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("RectangleGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("BooleanGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("ShapeBlendGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultTextObject={name:"Text",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("TextGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultInputObject={name:"Input",...Jt.defaultData,...yo.defaultData,geometry:Pn.defaultData("InputGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")}))(xE||(xE={}));(i=>{function n(o,a){let s={name:a};return o.type==="Mesh"?(s.geometry={},"material"in o&&(s.material={layers:new Ct}),"materials"in o&&(s.materials=o.materials.map(l=>({layers:new Ct})))):on.is(o.type)&&(s.perspective={},s.orthographic={}),s}i.newEmpty=n;function t(o,a){if(a===void 0)return o;let s={...o};return"material"in s&&"material"in a&&a.material&&(s.material=cl(s.material,l=>{if(typeof l!="string")for(let[c,d]of Object.entries(a.material.layers)){let u=l.layers.data(c);u&&Ft.patch(u,d)}}).data),s.materials&&a.materials&&(s.materials=cl(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let d=a.materials[c];if(typeof d!="string")for(let[u,p]of Object.entries(d.layers)){let h=l[c]?.layers?.data(u);h&&Ft.patch(h,p)}}}).data),s}function e(o,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function d(u,p){for(let[h,f]of Object.entries(p.layers)){let{texture:m,...y}=f;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...u,"layers",h,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...u,"layers",h],props:y,type:0};l.push(g)}}}for(let[u,p]of Object.entries(a)){let h=p;if(u!=="name")if(u==="cloner")l.push(...Bh.toOps(h,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:h.slide,offset:h.offset},type:0});else if(u==="material")d(["material"],h);else if(u==="materials")for(let[f,m]of Object.entries(h))d(["materials",f],m);else if(c[u]===0){if(u==="geometry"&&h.extrusion!==void 0){let f={path:[u,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[u],props:h,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[u]=h}return l}i.toOps=e;function r(o,a){if(a===void 0)return o;let s={...o};if(Object.assign(s,ml.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),on.is(o.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(o.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:Xh.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Tn.merge(s.cloner,a.cloner)});else if(o.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Tn.merge(s.cloner,a.cloner)});else if(Vh.is(o.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=Ut.clone(l.color))}return s}i.patch=r})(go||(go={}))});var gl,mb=Me(()=>{"use strict";(t=>t.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})(gl||(gl={}))});var Vi,tf=Me(()=>{"use strict";mb();wi();(t=>t.defaultData={orbitControls:gl.defaultData,playPage:ua,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let i=0,o=0;return r<5?o=-30:r<10&&(o=30),r===0||r===10||r===5?i=30:(r===4||r===11||r===9)&&(i=-30),[120,[i,o],"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})(Vi||(Vi={}))});var yb,gb,vo,vb=Me(()=>{"use strict";(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(yb||(yb={}));(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(gb||(gb={}));(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...yb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:gb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(vo||(vo={}))});var vl,bo,bb=Me(()=>{"use strict";ef();ut();tf();wi();Zt();vb();(i=>{function n(o){return o.find(a=>a.data.type==="Page"&&a.data.globalPhysics.usePhysics)!==void 0}i.physicsEnabled=n;function t(o,a){let s=o.find(l=>l.data.type==="Page"&&l.data.timelines?.[a]!==void 0);return s&&s.data.timelines?.[a]}i.findTimeline=t;function e(o,a){let s=o.scene.objects.get(a);if(s&&s.data.type==="Component")return s;{let l=o.shared.lib.components[a];if(l)return{...l.asset,id:a}}}i.getComponentData=e;function r(o,a,s){o.scene.objects.traverseFrom(a,(l,c)=>{if(c.type==="Instance"){let d=e(o,c.component)?.data;d&&s(l,c,d.events)}else s(l,c,c.events)})}i.traverseModuleInstances=r})(vl||(vl={}));(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:$h.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(d=!0,u=[]){let p=[];d&&p.push({...c.defaultLight}),p.push(...u);let h=new bt;return h.push({fi:1,id:ua,data:{...sn.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Vi.defaultData,styles:vo.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new bt,publish:Vi.defaultData,styles:vo.defaultData()}},c.emptyDataWithPage=function(d=!0){return{objects:e(d),publish:Vi.defaultData,styles:vo.defaultData()}},c.emptyData=function(){return{objects:new bt,publish:{...Vi.defaultData},styles:vo.defaultData()}};function s(d){return{...c.defaultData,objects:nr(d,bt.prototype)}}c.withObjs=s;function l(d,u){return s([{id:d,data:u,children:[],fi:0}])}c.withObj=l})(bo||(bo={}))});var bl,wE=Me(()=>{"use strict";(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(bl||(bl={}))});var rf,AE,sr,xb,EE,CE,ln,ei,Sb=Me(()=>{"use strict";ut();Zt();(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new fe}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(rf||(rf={}));(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new fe,queries:new fe,autoStart:!0}))(AE||(AE={}));(o=>{function n(a){return a.textValue!==void 0}o.isTextValue=n;function t(a){return typeof a=="number"}o.isNumber=t;function e(a){return typeof a=="boolean"}o.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}o.typeOfVariable=r;function i(a){return o.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():o.isBoolean(a)?a?"True":"False":o.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}o.getDisplayedValue=i})(sr||(sr={}));(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(xb||(xb={}));(t=>t.all=[...xb.all,"components"])(EE||(EE={}));(t=>{function n(){return{images:new Se,videos:new Se,colors:new Se,audios:new Se,particles:new Se,fonts:new Se,materials:new Se,components:new Se,variables:new Se,userAPIs:new Se,userWebhooks:new Se}}t.defaultData=n})(CE||(CE={}));(t=>{function n(){return{images:new Se,videos:new Se,colors:new Se,audios:new Se,particles:new Se,fonts:new Se,materials:new Se,components:new Se,variables:new Se,userAPIs:new Se,userWebhooks:new Se}}t.defaultData=n})(ln||(ln={}));(o=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},nr(a,Se.prototype)}o.defaultColors=n;function t(){return nr({},Se.prototype)}o.defaultImages=t;function e(){return{catelogs:new Se,materials:new Se,images:new Se,videos:new Se,colors:new Se,audios:new Se,particles:new Se,fonts:new Se,variables:new fe,userAPIs:new Se,userWebhooks:new Se,lib:ln.defaultData()}}o.emptyData=e;function r(a){switch(a){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 s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,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",a)}}o.defaultVariables=r;function i(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),d=Math.round(a-l*3600-c*60);return{textValue:[l,c,d]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}o.getFormattedTimerTime=i})(ei||(ei={}))});var TE=Me(()=>{"use strict"});var fa,PE=Me(()=>{"use strict";ut();bb();wE();Sb();(l=>{l.defaultData={schema:131,scene:bo.defaultData,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...ei.emptyData(),colors:ei.defaultColors()}},l.createDefaultData=function(){return os.deserialize(os.serialize(l.defaultData))},l.emptyDataForImports=function(){let c=bo.emptyDataWithPage();return{schema:131,scene:c,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...ei.emptyData(),colors:ei.defaultColors(),images:ei.defaultImages()}}},l.emptyData=function(){return{schema:131,scene:bo.emptyDataWithPage(),frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:ei.emptyData()}},l.clipboard2dData=function(){return{schema:131,scene:bo.emptyData(),frames:new Se,shared:ei.emptyData()}};function o(c){return{...c,shared:{...c.shared,lib:ln.defaultData()}}}l.withoutLib=o;function a(c,d){return vl.getComponentData(c,d)}l.getComponentData=a;function s(c){let d=Object.values(c.shared.userAPIs);for(let u of d){let p=u.headers;for(let h of p)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}l.hasSensitiveData=s})(fa||(fa={}))});function xo(n,t=[0,0]){let e=n&&!isNaN(n[0])?n[0]:t[0],r=n&&!isNaN(n[1])?n[1]:t[1];return[e,r]}function Yd(n,t,e){switch(n){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:i}=t??{...ss.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${i[0]}, ${i[1]} )`}case 6:{let{mass:r,stiffness:i,damping:o,velocity:a}=e??{...mo.defaultData},s=new wb(r,i,o,a),l=s.solve(1);return()=>c=>s.solve(c)/l}case 8:return()=>r=>Math.floor(r)}}var ME,OE,So,xl,wb,Ab=Me(()=>{"use strict";ut();wi();(t=>{function n(e,r){return{id:e,name:r,duration:5,objectTimelines:new Se}}t.defaultData=n})(ME||(ME={}));(t=>{function n(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}t.is=n})(OE||(OE={}));(S=>{function n(v,w){let A=[0,0],E=[1,1];if(v?.cubicControls)A=xo(v.cubicControls.control1,A);else switch(v?.type){case 2:A=[.42,0];break;case 3:A=[0,0];break;case 4:A=[.42,0];break;case 1:A=[.25,.1];break;case 0:A=[0,0];break;case 7:A=[.25,1];break}if(w?.cubicControls)E=xo(w.cubicControls.control2,E);else switch(w?.type){case 2:E=[1,1];break;case 3:E=[.58,1];break;case 4:E=[.58,1];break;case 1:E=[.25,1];break;case 0:E=[1,1];break;case 7:E=[.5,1];break}return{control1:A,control2:E}}S.getControlsWithDefault=n,S.BEZIER_PRESETS=[0,1,2,3,4,7];function e(v){if(!S.BEZIER_PRESETS.includes(v))return;let w={type:v};return{control1:n(w).control1,control2:n(void 0,w).control2}}S.presetHandles=e;let r=.001;function i(v,w){return Math.abs(v[0]-w[0])<r&&Math.abs(v[1]-w[1])<r}function o(v){return S.BEZIER_PRESETS.find(w=>{let A=e(w);return A!==void 0&&i(A.control1,v.control1)&&i(A.control2,v.control2)})}S.presetForHandles=o;function a(v){return{id:v,keyframes:new fe}}S.defaultData=a,S.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"];function l(v){let w=S.ROOT_PROPERTY_ORDER.indexOf(v[0]);return w===-1?S.ROOT_PROPERTY_ORDER.length:w}S.rowOrder=l;function c(v){return v.layerId??v.path.join(".")}S.propertyKey=c;function d(v,w){let A=new Map;for(let E of v){let P=E.data;if(w?.(P))continue;let M=c(P),R=A.get(M);R||(R={id:M,path:P.path,keyframes:[],layerId:P.layerId,index:P.index},A.set(M,R)),P.isPlaceholder?R.placeholder=E.id:R.keyframes.push(E)}return[...A.values()].sort((E,P)=>{let M=l(E.path)-l(P.path);return M!==0?M:(E.index??0)-(P.index??0)})}S.groupKeyframes=d;function u(v){let w=v[v.length-1];return xl.includes(w)?w:void 0}S.rowAxis=u;function p(v){return v.layerId?v.layerId:(u(v.path)?v.path.slice(0,-1):v.path).join(".")}S.drawnRowKey=p;function h(v){let w=new Map;for(let A of v){let E=u(A.path),P=E?A.path.slice(0,-1):A.path,M=p(A),R=w.get(M);R||(R={id:M,path:P,layerId:A.layerId,index:A.index,tracks:[]},w.set(M,R)),R.tracks.push({axis:E,property:A})}return[...w.values()]}S.drawnRows=h;function f(v){return[...v].sort((w,A)=>w.data.time-A.data.time)}S.sortedKeyframes=f;function m(v){return["material",v.type==="light"?`${v.category} lighting`:v.type]}S.materialLayerPath=m;function y(v,w){return v.map(({data:A,id:E},P)=>g(w(),m(A),{layerId:E,index:P}))}S.createMaterialGroup=y;function g(v,w,A){return{id:v,data:{id:v,time:A?.time??0,path:w,value:{},layerId:A?.layerId,index:A?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}S.placeholderKeyframe=g;function b(v){return Object.entries(v).reduce((w,[A,E])=>(typeof E!="string"&&w.push({name:E.name}),w),[])}S.createName=b,S.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:Yd(3),duration:1e3},opacity:{value:[0,1],easing:Yd(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:Yd(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:Yd(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:Yd(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(So||(So={}));xl=["x","y","z"],wb=class{constructor(t=1,e=100,r=10,i=0){this.mass=t,this.stiffness=e,this.damping=r,this.initialVelocity=i,this.m_w0=Math.sqrt(e/t),this.m_zeta=r/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0+-i)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-i+this.m_w0)}solve(t){return this.m_zeta<1?t=Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):t=(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0),1-t}getDuration(){let t=.16666666666666666,e=0,r=0;for(;;)if(e+=t,this.solve(e)===1){if(r++,r>=16)break}else r=0;return e*t*1e3}}});var Sl,wl,Eb=Me(()=>{"use strict";wi();ut();(t=>t.list=["idle","move","jump","run"])(Sl||(Sl={}));(e=>(e.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 fe,move:new fe,jump:new fe,run:new fe},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ue.fromHexAndA(3728051,1)}}))(wl||(wl={}))});import{MathUtils as of}from"three";function us(n,...t){let e={};for(let r of t.flat())n!=null&&r in n&&(e[r]=n[r]);return e}function DE(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,i=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],o=[0,1];for(let s=2;s<10;s++)i.push(i[1]),o.push(1);let a={...us(Ht(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:o,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 e={...Ht(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Dn(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Rn(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,o)=>{i===void 0&&(r.materials[o]=qt.defaultTwoLayerData("phong"),i=r.materials[o]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=qt.defaultTwoLayerData("phong")),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=qt.defaultTwoLayerData("phong")),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==Ct.prototype&&t(i.material)})})}function VL(n){Object.assign(n.scene.publish,{orbitControls:{...gl.defaultData,...Ht(n.scene.publish.orbitControls)}})}function GL(n){Object.assign(n.scene.publish.settings,{video:{...Vi.defaultData.settings.video,...Ht(n.scene.publish.settings.video)}})}function UL(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[i,o]of Object.entries(r))if((jh.includes(i)||typeof o=="boolean")&&delete r[i],i==="texture")for(let[a,s]of Object.entries(o))(cE.includes(a)||typeof s=="boolean")&&delete o[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(i=>{let o=i;o.material?t(o.material):o.materials&&o.materials.forEach(a=>{t(a)})})})}function zL(n){n.scene.publish.withBackground=!0}function jL(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function HL(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(i=>i+1),r.linear.scale=r.linear.scale.map(i=>i+1))})}function WL(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function qL(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=Ht(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ht(e).booleanExclude!==!0)}})}function XL(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function YL(n){function t(r){Object.setPrototypeOf(r,Ct.prototype),r.texture&&Object.setPrototypeOf(r.texture,Ct.prototype)}function e(r){Object.setPrototypeOf(r,Ct.prototype);for(let i in r)t(r[i])}n.scene.objects.traverse((r,i)=>{i.states.forEach(o=>{let a=o;if(a.material){let s=Ht(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=Ht(l).layers;e(c),l.layers=c}})})}function RE(n){n.layers===void 0&&Object.assign(n,qt.defaultTwoLayerData("lambert"))}function Cb(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let i={...Ht(t),colors:e,steps:r};Object.assign(t,i)}})}function QL(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function BE(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Cb(r)}):"material"in e&&typeof e.material!="string"&&Cb(e.material)}),Object.values(n.shared.materials).forEach(t=>Cb(t))}function KL(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function ZL(n){n.shared.audios=nr({},Se.prototype)}function JL(n){n.shared.videos=nr({},Se.prototype)}function $L(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let i={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(t,{[e]:i})}})}function e3(n){Object.entries(Ht(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(Ht(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function t3(n){n.scene.publish.settings.web.preload=!1}function NE(n){n.layers&&n.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 LE(n){n.layers&&n.layers.forEach(t=>{lE(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 r3(n){n.shared.fonts=nr({},Se.prototype)}function i3(n){return n.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function n3(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let o=qt.defaultTwoLayerData("phong"),a=typeof i.color=="string"?n.shared.colors[i.color]:i.color;o.layers[1].data.color={r:a.r,g:a.g,b:a.b},o.layers[1].data.alpha=i.alpha;let s=i3(i.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:i.name,...Jt.defaultData,...yo.defaultData,flatShading:!1,wireframe:!1,geometry:{...Pn.defaultData("TextGeometry"),width:i.width,height:i.height,font:s,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:o,states:Ht(i.states),events:Ht(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=Ht(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function o3(n){let t={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((e,r)=>{r.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new fe,move:new fe,jump:new fe}});else{let o=new fe;Object.assign(i,{actions:o}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&o.push({fi:0,id:of.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(d,us(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(d,{control1:{...a.control1},control2:{...a.control2}});let u={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...u,...d},h={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new fe({fi:0,id:of.generateUUID(),data:c},{fi:1,id:of.generateUUID(),data:p})};o.push({fi:l,id:s,data:h})}),delete i.targets)}})})}function a3(n){n.scene.objects.traverse((t,e)=>{function r(i,o){let a=new fe,s=[];if(e.events.forEach((l,c,d)=>{if(l.type==="Audio"&&l.trigger===o){let u;s.push(c),l.interaction==="play"?u={...us(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(u={...us(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&a.push({fi:d,id:c,data:u})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:of.generateUUID(),data:{type:i,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function _E(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Ft.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function FE(n){Dn(n,_E),Rn(n,_E)}function s3(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function l3(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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"}})})}function c3(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=qt.defaultTwoLayerData("phong"))})}function d3(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function u3(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function p3(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)}function h3(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function f3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function m3(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function y3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=wl.defaultDataThirdPerson.navmesh)})})}function g3(n){n.scene.styles||(n.scene.styles=vo.defaultData())}function kE(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function v3(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}),Rn(n,kE),Dn(n,kE)}function b3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new fe})})})}function x3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function VE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function GE(n,t){if(t<1&&(Rn(n,DE),Dn(n,DE),n.schema=1),t<2&&(VL(n),n.schema=2),t<3&&(UL(n),n.schema=3),t<4&&(zL(n),n.schema=4),t<5&&(jL(n),n.schema=5),t<6&&(HL(n),n.schema=6),t<7&&(WL(n),n.schema=7),t<8&&(n.schema=8),t<9&&(BE(n),n.schema=9),t<10&&(QL(n),n.schema=10),t<11&&(KL(n),n.schema=11),t<12&&(BE(n),n.schema=12),t<13&&(ZL(n),n.schema=13),t<14&&($L(n),n.schema=14),t<15&&(e3(n),n.schema=15),t<16&&(t3(n),n.schema=16),t<17&&(Rn(n,NE),Dn(n,NE),n.schema=17),t<18&&(Rn(n,RE),Dn(n,RE),n.schema=18),t<19&&(GL(n),n.schema=19),t<20&&(r3(n),n3(n),n.schema=20),t<21&&(o3(n),a3(n),n.schema=21),t<22&&(FE(n),n.schema=22),t<23&&(s3(n),n.schema=23),t<24&&(l3(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(JL(n),t<25&&(n.schema=25)),t<26&&(qL(n),n.schema=26),t<27&&(XL(n),n.schema=27),t<28&&(FE(n),n.schema=28),t<29&&(YL(n),n.schema=29),t<30&&(c3(n),n.schema=30),t<31&&(d3(n),n.schema=31),t<33&&(u3(n),n.schema=33),t<34&&(p3(n),n.schema=34),t<35&&(h3(n),n.schema=35),t<36&&(f3(n),n.schema=36),t<37&&(m3(n),n.schema=37),t<38&&(Rn(n,LE),Dn(n,LE),n.schema=38),t<39&&(y3(n),n.schema=39),t<40&&(g3(n),n.schema=40),t<41&&(v3(n),n.schema=41),t<42&&(b3(n),n.schema=42),t<43&&(x3(n),n.schema=43),t<99){Rn(n,VE),Dn(n,VE),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Cn);let e=Ht(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=ua,r.insertBefore(null,null,[{id:ua,data:{...sn.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:us(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:us(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...ha.defaultData,...us(n.scene.environment,"usePhysics","gravity")},camera:Ht(n.scene.ownerCamera)??sn.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==bo.TRASH_CAN_ID&&r.move(ua,a.fi,a.id);let i=0,o=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(i,2)],i+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(o,1)],o+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,pa.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}var UE=Me(()=>{"use strict";Hh();wi();mb();ef();ut();tf();Zt();sb();Eb();vb();bb();nb();fb()});var QE={};aL(QE,{updateAllMaterials:()=>XE,updateDocumentSchema:()=>W3,updateLibSchema:()=>H3,updateMaterialSchema:()=>P3,updateObjectStateRec:()=>El,updateObjectsSchema:()=>qE,updateTextValues:()=>C3});import{MathUtils as S3}from"three";function zE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function w3(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function A3(n){Array.isArray(Ht(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}function jE(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Al)}function WE(n){jE(n),n.type==="Page"&&jE(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Al))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Al),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Al),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Al,t.extrusion.twist*=Al),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(Ht(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function E3(n){n.shared.variables=nr({},Se.prototype)}function C3(n){n.scene.objects.traverse((t,e)=>{})}function T3(n){let t=Ht(n.shared.variables);n.shared.variables=nr(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),fe.prototype)}function P3(n){let t=n.schema??104;t!==131&&t<130&&(af(n.asset),n.schema=130)}function El(n,t){t(n.data);for(let e of n.children)El(e,t)}function qE(n){let t=n.schema??104;t!==131&&(t<105&&(El(n.asset,WE),n.schema=105),t<118&&(El(n.asset,YE),n.schema=118),t<121&&(El(n.asset,Pb),n.schema=121),t<130&&(El(n.asset,M3),n.schema=130))}function XE(n,t){Rn(n,t),Dn(n,t),Object.values(n.shared.lib.materials).forEach(e=>t(e.asset))}function af(n){n.layers===void 0&&Object.assign(n,qt.defaultTwoLayerData("phong"))}function M3(n){"materials"in n?n.materials.forEach(t=>{t!==void 0&&typeof t!="string"&&af(t)}):"material"in n&&n.material!==void 0&&typeof n.material!="string"&&af(n.material)}function O3(n){n.shared.particles=nr({},Se.prototype),n.shared.lib&&(n.shared.lib.particles=ln.defaultData().particles)}function I3(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function D3(n){n.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function R3(n){n.scene.objects.traverse((t,e)=>{Array.isArray(Ht(e.events))!==!1&&e.events?.forEach(r=>{let i=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=i??"Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode=i==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(o=>{o.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}),r.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}function B3(n){n.shared.userAPIs=nr({},Se.prototype),n.shared.userWebhooks=nr({},Se.prototype),n.shared.lib&&(n.shared.lib.userAPIs=ln.defaultData().userAPIs,n.shared.lib.userWebhooks=ln.defaultData().userWebhooks)}function N3(n){n.scene.publish.settings.videoStatic===void 0&&(n.scene.publish.settings.videoStatic=Vi.defaultData.settings.videoStatic)}function YE(n){n.timelineAnimations=nr({},Se.prototype)}function L3(n){let t=[];return n?(n.forEach((e,r)=>{let{path:i,keyframes:o}=e.data,a=i[0]==="material"?e.id:void 0;if(!o?.length){t.push(So.placeholderKeyframe(e.id,i,{layerId:a,index:r}));return}o.forEach(({id:s,data:l})=>{t.push({id:s,data:{...l,path:i,layerId:a,index:r}})})}),t.sort((e,r)=>e.data.time-r.data.time),new fe(...t.map((e,r)=>({...e,fi:r})))):new fe}function _3(n){let t=n.shared,e=t.timelineAnimations;if(!e)return;let r=n.scene.objects,i=r.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,a]of Object.entries(e)){let s=nr({},Se.prototype),l=0,c=Boolean(a.loop);for(let[h,f]of Object.entries(a.mapping??{})){let y=r.data(h)?.timelineAnimations?.[f];!y||(l=Math.max(l,y.to??0),c=c||Boolean(y.loop),s[h]={id:h,keyframes:L3(y.properties?.unproxy())})}let d=a.page??i,u=d?r.data(d):void 0;if(!u||u.type!=="Page")continue;let p=u.timelines??(u.timelines=nr({},Se.prototype));p[o]={id:o,name:a.name,duration:l||5,...c?{loop:c}:{},objectTimelines:s}}delete t.timelineAnimations,r.traverse((o,a)=>{delete a.timelineAnimations})}function F3(n){n.scene.objects.traverse((t,e)=>{let r=e.states;if(!r)return;let i=e.timelineAnimations,o=[];r.forEach((a,s)=>{(a.isAnimation||i?.[s])&&o.push(s)}),o.forEach(a=>r.delete(a))})}function V3(n){for(let{id:t,data:e}of[...n.unproxy()]){let r=e.path?.[0];if(!r||!k3.includes(r))continue;let i=Tb(e.value);if(!i.length)continue;let o=n.data(t);if(!o)continue;let a=e.value,[s,...l]=i;for(let c of l){let d=S3.generateUUID();n.insertBefore(null,[{id:d,data:{...e,id:d,path:[r,c],value:a[c],easing:G3(e.easing)}}])}o.path=[r,s],o.value=a[s]}}function Tb(n){return n===null||typeof n!="object"?[]:xl.filter(t=>t in n)}function G3(n){let t=n?.cubicControls;return{...n,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...n?.springParameters?{springParameters:{...n.springParameters}}:{}}}function U3(n,t){return Math.abs(n[0]-t[0])<1e-6&&Math.abs(n[1]-t[1])<1e-6}function z3(n){let t=[];for(let e of So.groupKeyframes(n)){let r=new Set(e.keyframes.flatMap(o=>Tb(o.data.value))),i=r.size?[...r].map(o=>e.keyframes.filter(a=>Tb(a.data.value).includes(o))):[e.keyframes];for(let o of i){let a=[...o].sort((s,l)=>s.data.time-l.data.time);for(let s=0;s+1<a.length;s++)t.push({left:a[s],right:a[s+1]})}}return t}function j3(n){let t=z3([...n.unproxy()]),e=new Map,r=new Set;for(let{left:o,right:a}of t){let s=o.data.easing?.type,c=(s===void 0?void 0:So.presetHandles(s))?.control2??(s===5?xo(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!c)continue;let d=e.get(a.id);d?U3(d,c)||r.add(a.id):e.set(a.id,c)}let i=new Map;for(let{id:o,data:a}of n.unproxy()){let s=a.easing?.type,l=s===void 0?void 0:So.presetHandles(s);l&&i.set(o,l.control1)}for(let{left:o,right:a}of t)r.has(a.id)&&i.delete(o.id);for(let[o,a]of i){let s=n.data(o);!s?.easing||(s.easing.cubicControls={control1:a,control2:xo(s.easing.cubicControls?.control2,[1,1])},s.easing.type=5)}for(let{left:o,right:a}of t){if(!i.has(o.id))continue;let s=n.data(a.id),l=e.get(a.id);!s?.easing||!l||(s.easing.cubicControls={control1:xo(s.easing.cubicControls?.control1,[0,0]),control2:l})}}function HE(n,t){n.scene.objects.traverse((e,r)=>{let i=r;if(!(i.type!=="Page"||!i.timelines))for(let o of Object.values(i.timelines))for(let a of Object.values(o.objectTimelines??{}))t(a.keyframes)})}function Pb(n){n.pivot=[0,0,0],n.pivotRotation=[0,0,0]}function H3(n){}function W3(n){let t=n.schema??0;if(t!==131){if(t>131){console.error(`This scene was created with a newer version of Spline (file format ${t}, this runtime reads ${131}). Update @splinetool/runtime to the latest version to load it correctly.`);return}console.warn("updating from ",t,"to ",131),GE(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Vi.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Rn(n,zE),Dn(n,zE),n.schema=101),t<102&&(w3(n),n.schema=102),t<104&&(n.shared.catelogs=new Se,n.shared.lib=ln.defaultData(),n.schema=104),t<105&&(E3(n),n.scene.objects.traverse((e,r)=>{WE(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))qE(e);t<106&&(T3(n),n.schema=106),t<107&&(n.shared.lib.variables=ln.defaultData().variables,n.schema=107),t<109&&(O3(n),n.schema=109),t<110&&(I3(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{A3(r)}),n.schema=111),t<112&&(D3(n),n.schema=112),t<113&&(R3(n),n.schema=113),t<114&&(n.scene.publish.settings.web.imageQuality===void 0&&(n.scene.publish.settings.web.imageQuality=70),n.schema=114),t<115&&(B3(n),n.schema=115),t<116&&(N3(n),n.schema=116),t<117&&(n.scene.publish.settings.web.pixelRatioMobile===void 0&&(n.scene.publish.settings.web.pixelRatioMobile=0),n.scene.publish.settings.web.pixelRatioDesktop===void 0&&(n.scene.publish.settings.web.pixelRatioDesktop=0),n.schema=117),t<118&&(n.shared.timelineAnimations=nr({},Se.prototype),n.scene.objects.traverse((e,r)=>{YE(r)}),n.schema=118),t<119&&(n.scene.publish.settings.videoStatic.format=fa.defaultData.scene.publish.settings.videoStatic.format,n.scene.publish.settings.videoStatic.imageFormat=fa.defaultData.scene.publish.settings.videoStatic.imageFormat,n.schema=119),t<120&&(n.scene.publish.settings.image.colorSpace="display-p3",n.scene.publish.settings.videoStatic.colorSpace="display-p3",n.schema=120),t<121&&(n.scene.objects.traverse((e,r)=>{Pb(r),r.type==="Page"&&r.camera!==void 0&&Pb(r.camera)}),n.schema=121),t<122&&(delete n.scene.publish.settings.video,n.scene.publish.orbitControls.rotationSpeed=fa.defaultData.scene.publish.orbitControls.rotationSpeed,n.schema=122),t<123&&(n.scene.objects.traverse((e,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=Mn.defaultData)}),n.schema=123),t<124&&(t>=123&&n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&(typeof i.exposure=="number"&&(i.exposure=Math.round(i.exposure/5e-4*1e4)/1e4),i.lighting===void 0&&(i.lighting=Mn.defaultData.lighting))}),n.schema=124),t<125&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&i.lightingIntensity===void 0&&(i.lightingIntensity=Mn.defaultData.lightingIntensity)}),n.schema=125),t<126&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&(i.mode===void 0&&(i.mode="physical"),i.hdri===void 0?i.hdri={...Mn.defaultData.hdri}:(i.hdri.blur===void 0&&(i.hdri.blur=Mn.defaultData.hdri.blur),Array.isArray(i.hdri.rotation)&&(i.hdri.rotation=i.hdri.rotation[1]??0)))}),n.schema=126),t<127&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i?.hdri!==void 0&&i.hdri.showBackground===void 0&&(i.hdri.showBackground=!0)}),n.schema=127),t<128&&(n.scene.objects.traverse((e,r)=>{let i=r.sky;r.type==="Page"&&i!==void 0&&i.lightingQuality===void 0&&(i.lightingQuality="full")}),n.schema=128),t<129&&(n.scene.objects.traverse((e,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=sn.defaultData.camera);let i=r.camera;i.far=1e5,i.perspective?i.perspective.near=70:i.perspective={near:70,fov:45,zoom:1}}}),n.schema=129),t<130&&(XE(n,af),n.schema=130),t<131&&(F3(n),_3(n),HE(n,V3),HE(n,j3),n.schema=131)}}var Al,k3,Mb=Me(()=>{PE();ut();Ab();UE();tf();Hh();Zt();Sb();ef();cb();Al=180/Math.PI;k3=["position","rotation","scale","shape size"]});var uM=rh((g0,dM)=>{(function(n,t){typeof g0=="object"?dM.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(g0,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,i=0,o=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),i=s(" "),o=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),i-=s(e[l]),i<0&&(i+=1),o-=s(e[l]),o<0&&(o+=1);s=null;var c=function(){var d=2091639*r+a*23283064365386963e-26;return r=i,i=o,o=d-(a=d|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[r,i,o,a]},c.importState=function(d){r=+d[0]||0,i=+d[1]||0,o=+d[2]||0,a=+d[3]||0},c}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(i){i=i.toString();for(var o=0;o<i.length;o++){e+=i.charCodeAt(o);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var m2=rh((wce,f2)=>{"use strict";function HG(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ps(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ps)}HG(Ps,Error);Ps.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var d="",u;for(u=0;u<c.parts.length;u++)d+=c.parts[u]instanceof Array?o(c.parts[u][0])+"-"+o(c.parts[u][1]):o(c.parts[u]);return"["+(c.inverted?"^":"")+d+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+r(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+r(d)})}function o(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(d){return"\\x0"+r(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+r(d)})}function a(c){return e[c.type](c)}function s(c){var d=new Array(c.length),u,p;for(u=0;u<c.length;u++)d[u]=a(c[u]);if(d.sort(),d.length>0){for(u=1,p=1;u<d.length;u++)d[u-1]!==d[u]&&(d[p]=d[u],p++);d.length=p}switch(d.length){case 1:return d[0];case 2:return d[0]+" or "+d[1];default:return d.slice(0,-1).join(", ")+", or "+d[d.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+s(n)+" but "+l(t)+" found."};function WG(n,t){t=t!==void 0?t:{};var e={},r={svg_path:Br},i=Br,o=function(T){if(!T)return[];for(var I=[],k=0;k<T.length;k++)I=I.concat.apply(I,T[k]);var L=I[0];return L&&L.code=="m"&&(delete L.relative,L.code="M"),I},a=function(T,I){return $N(T,I)},s=/^[Mm]/,l=Ze(["M","m"],!1,!1),c=function(T,I,k){var L=rl(T,[I]);return k&&(L=L.concat(rl(T=="M"?"L":"l",k[1]))),L},d=/^[Zz]/,u=Ze(["Z","z"],!1,!1),p=function(){return rl("Z")},h=/^[Ll]/,f=Ze(["L","l"],!1,!1),m=function(T,I){return rl(T,I)},y=/^[Hh]/,g=Ze(["H","h"],!1,!1),b=function(T,I){return rl(T,I.map(function(k){return{x:k}}))},x=/^[Vv]/,S=Ze(["V","v"],!1,!1),v=function(T,I){return rl(T,I.map(function(k){return{y:k}}))},w=/^[Cc]/,A=Ze(["C","c"],!1,!1),E=function(T,I,k){return{x1:T.x,y1:T.y,x2:I.x,y2:I.y,x:k.x,y:k.y}},P=/^[Ss]/,M=Ze(["S","s"],!1,!1),R=function(T,I){return{x2:T.x,y2:T.y,x:I.x,y:I.y}},D=/^[Qq]/,N=Ze(["Q","q"],!1,!1),C=function(T,I){return{x1:T.x,y1:T.y,x:I.x,y:I.y}},B=/^[Tt]/,_=Ze(["T","t"],!1,!1),F=/^[Aa]/,V=Ze(["A","a"],!1,!1),K=function(T,I,k,L,z,pe){return{rx:T,ry:I,xAxisRotation:k,largeArc:L,sweep:z,x:pe.x,y:pe.y}},q=function(T,I){return{x:T,y:I}},G=function(T){return T*1},W=function(T){return T.join("")*1},H=/^[01]/,Z=Ze(["0","1"],!1,!1),te=function(T){return T=="1"},Q=function(){return""},se=",",oe=ft(",",!1),ne=function(T){return T.join("")},de=".",ve=ft(".",!1),me=/^[eE]/,ce=Ze(["e","E"],!1,!1),X=/^[+\-]/,ee=Ze(["+","-"],!1,!1),re=/^[0-9]/,he=Ze([["0","9"]],!1,!1),xe=function(T){return T.join("")},ae=/^[ \t\n\r]/,ue=Ze([" "," ",`
2
2
  `,"\r"],!1,!1),O=0,J=0,we=[{line:1,column:1}],Ee=0,Te=[],be=0,Ne;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');i=r[t.startRule]}function Ae(){return n.substring(J,O)}function Re(){return Ka(J,O)}function Xe(T,I){throw I=I!==void 0?I:Ka(J,O),Id([bv(T)],n.substring(J,O),I)}function Be(T,I){throw I=I!==void 0?I:Ka(J,O),nn(T,I)}function ft(T,I){return{type:"literal",text:T,ignoreCase:I}}function Ze(T,I,k){return{type:"class",parts:T,inverted:I,ignoreCase:k}}function Qa(){return{type:"any"}}function Od(){return{type:"end"}}function bv(T){return{type:"other",description:T}}function Zp(T){var I=we[T],k;if(I)return I;for(k=T-1;!we[k];)k--;for(I=we[k],I={line:I.line,column:I.column};k<T;)n.charCodeAt(k)===10?(I.line++,I.column=1):I.column++,k++;return we[T]=I,I}function Ka(T,I){var k=Zp(T),L=Zp(I);return{start:{offset:T,line:k.line,column:k.column},end:{offset:I,line:L.line,column:L.column}}}function Kt(T){O<Ee||(O>Ee&&(Ee=O,Te=[]),Te.push(T))}function nn(T,I){return new Ps(T,null,null,I)}function Id(T,I,k){return new Ps(Ps.buildMessage(T,I),T,I,k)}function Br(){var T,I,k,L,z;for(T=O,I=[],k=et();k!==e;)I.push(k),k=et();if(I!==e)if(k=Dd(),k===e&&(k=null),k!==e){for(L=[],z=et();z!==e;)L.push(z),z=et();L!==e?(J=T,I=o(k),T=I):(O=T,T=e)}else O=T,T=e;else O=T,T=e;return T}function Dd(){var T,I,k,L,z,pe;if(T=O,I=Rd(),I!==e){for(k=[],L=O,z=[],pe=et();pe!==e;)z.push(pe),pe=et();for(z!==e?(pe=Rd(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;){for(k.push(L),L=O,z=[],pe=et();pe!==e;)z.push(pe),pe=et();z!==e?(pe=Rd(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e)}k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function Rd(){var T,I,k,L,z,pe;if(T=O,I=FN(),I!==e){for(k=[],L=O,z=[],pe=et();pe!==e;)z.push(pe),pe=et();for(z!==e?(pe=Za(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;){for(k.push(L),L=O,z=[],pe=et();pe!==e;)z.push(pe),pe=et();z!==e?(pe=Za(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e)}k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function Za(){var T;return T=kN(),T===e&&(T=VN(),T===e&&(T=GN(),T===e&&(T=UN(),T===e&&(T=zN(),T===e&&(T=HN(),T===e&&(T=qN(),T===e&&(T=YN(),T===e&&(T=KN())))))))),T}function FN(){var T,I,k,L,z,pe,il;if(T=O,s.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(l)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=$r(),L!==e?(z=O,pe=Gt(),pe===e&&(pe=null),pe!==e?(il=Rw(),il!==e?(pe=[pe,il],z=pe):(O=z,z=e)):(O=z,z=e),z===e&&(z=null),z!==e?(J=T,I=c(I,L,z),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function kN(){var T,I;return T=O,d.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(u)),I!==e&&(J=T,I=p()),T=I,T}function VN(){var T,I,k,L;if(T=O,h.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(f)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=Rw(),L!==e?(J=T,I=m(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function Rw(){var T,I,k,L,z,pe;if(T=O,I=$r(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=$r(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=$r(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function GN(){var T,I,k,L;if(T=O,y.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(g)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=Bw(),L!==e?(J=T,I=b(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function Bw(){var T,I,k,L,z,pe;if(T=O,I=tl(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=tl(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=tl(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function UN(){var T,I,k,L;if(T=O,x.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(S)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=Bw(),L!==e?(J=T,I=v(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function zN(){var T,I,k,L;if(T=O,w.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(A)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=jN(),L!==e?(J=T,I=m(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function jN(){var T,I,k,L,z,pe;if(T=O,I=xv(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=xv(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=xv(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function xv(){var T,I,k,L,z,pe;return T=O,I=$r(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=$r(),L!==e?(z=Gt(),z===e&&(z=null),z!==e?(pe=$r(),pe!==e?(J=T,I=E(I,L,pe),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function HN(){var T,I,k,L;if(T=O,P.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(M)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=WN(),L!==e?(J=T,I=m(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function WN(){var T,I,k,L,z,pe;if(T=O,I=Sv(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=Sv(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=Sv(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function Sv(){var T,I,k,L;return T=O,I=$r(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=$r(),L!==e?(J=T,I=R(I,L),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function qN(){var T,I,k,L;if(T=O,D.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(N)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=XN(),L!==e?(J=T,I=m(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function XN(){var T,I,k,L,z,pe;if(T=O,I=wv(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=wv(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=wv(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function wv(){var T,I,k,L;return T=O,I=$r(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=$r(),L!==e?(J=T,I=C(I,L),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function YN(){var T,I,k,L;if(T=O,B.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(_)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=QN(),L!==e?(J=T,I=m(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function QN(){var T,I,k,L,z,pe;if(T=O,I=$r(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=$r(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=$r(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function KN(){var T,I,k,L;if(T=O,F.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(V)),I!==e){for(k=[],L=et();L!==e;)k.push(L),L=et();k!==e?(L=ZN(),L!==e?(J=T,I=m(I,L),T=I):(O=T,T=e)):(O=T,T=e)}else O=T,T=e;return T}function ZN(){var T,I,k,L,z,pe;if(T=O,I=Av(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=Av(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);L!==e;)k.push(L),L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=Av(),pe!==e?(z=[z,pe],L=z):(O=L,L=e)):(O=L,L=e);k!==e?(J=T,I=a(I,k),T=I):(O=T,T=e)}else O=T,T=e;return T}function Av(){var T,I,k,L,z,pe,il,Cv,$p,Tv,eh,Pv;return T=O,I=Nw(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=Nw(),L!==e?(z=Gt(),z===e&&(z=null),z!==e?(pe=tl(),pe!==e?(il=Gt(),il!==e?(Cv=Lw(),Cv!==e?($p=Gt(),$p===e&&($p=null),$p!==e?(Tv=Lw(),Tv!==e?(eh=Gt(),eh===e&&(eh=null),eh!==e?(Pv=$r(),Pv!==e?(J=T,I=K(I,L,pe,Cv,Tv,Pv),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function $r(){var T,I,k,L;return T=O,I=tl(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=tl(),L!==e?(J=T,I=q(I,L),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function Nw(){var T,I;return T=O,I=Fw(),I===e&&(I=Ja()),I!==e&&(J=T,I=G(I)),T=I,T}function tl(){var T,I,k,L;return T=O,I=O,k=Ev(),k===e&&(k=null),k!==e?(L=Fw(),L!==e?(k=[k,L],I=k):(O=I,I=e)):(O=I,I=e),I===e&&(I=O,k=Ev(),k===e&&(k=null),k!==e?(L=Ja(),L!==e?(k=[k,L],I=k):(O=I,I=e)):(O=I,I=e)),I!==e&&(J=T,I=W(I)),T=I,T}function Lw(){var T,I;return T=O,H.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(Z)),I!==e&&(J=T,I=te(I)),T=I,T}function Gt(){var T,I,k,L,z;if(T=O,I=[],k=et(),k!==e)for(;k!==e;)I.push(k),k=et();else I=e;if(I!==e)if(k=_w(),k===e&&(k=null),k!==e){for(L=[],z=et();z!==e;)L.push(z),z=et();L!==e?(I=[I,k,L],T=I):(O=T,T=e)}else O=T,T=e;else O=T,T=e;if(T===e){if(T=O,I=O,k=_w(),k!==e){for(L=[],z=et();z!==e;)L.push(z),z=et();L!==e?(k=[k,L],I=k):(O=I,I=e)}else O=I,I=e;I!==e&&(J=T,I=Q()),T=I}return T}function _w(){var T;return n.charCodeAt(O)===44?(T=se,O++):(T=e,be===0&&Kt(oe)),T}function Fw(){var T,I,k,L;return T=O,I=O,k=JN(),k!==e?(L=kw(),L===e&&(L=null),L!==e?(k=[k,L],I=k):(O=I,I=e)):(O=I,I=e),I===e&&(I=O,k=Ja(),k!==e?(L=kw(),L!==e?(k=[k,L],I=k):(O=I,I=e)):(O=I,I=e)),I!==e&&(J=T,I=ne(I)),T=I,T}function JN(){var T,I,k,L,z;return T=O,I=O,k=Ja(),k===e&&(k=null),k!==e?(n.charCodeAt(O)===46?(L=de,O++):(L=e,be===0&&Kt(ve)),L!==e?(z=Ja(),z!==e?(k=[k,L,z],I=k):(O=I,I=e)):(O=I,I=e)):(O=I,I=e),I===e&&(I=O,k=Ja(),k!==e?(n.charCodeAt(O)===46?(L=de,O++):(L=e,be===0&&Kt(ve)),L!==e?(k=[k,L],I=k):(O=I,I=e)):(O=I,I=e)),I!==e&&(J=T,I=ne(I)),T=I,T}function kw(){var T,I,k,L,z;return T=O,I=O,me.test(n.charAt(O))?(k=n.charAt(O),O++):(k=e,be===0&&Kt(ce)),k!==e?(L=Ev(),L===e&&(L=null),L!==e?(z=Ja(),z!==e?(k=[k,L,z],I=k):(O=I,I=e)):(O=I,I=e)):(O=I,I=e),I!==e&&(J=T,I=ne(I)),T=I,T}function Ev(){var T;return X.test(n.charAt(O))?(T=n.charAt(O),O++):(T=e,be===0&&Kt(ee)),T}function Ja(){var T,I,k;if(T=O,I=[],re.test(n.charAt(O))?(k=n.charAt(O),O++):(k=e,be===0&&Kt(he)),k!==e)for(;k!==e;)I.push(k),re.test(n.charAt(O))?(k=n.charAt(O),O++):(k=e,be===0&&Kt(he));else I=e;return I!==e&&(J=T,I=xe(I)),T=I,T}function et(){var T,I;return T=O,ae.test(n.charAt(O))?(I=n.charAt(O),O++):(I=e,be===0&&Kt(ue)),I!==e&&(J=T,I=Q()),T=I,T}function $N(T,I){if(!I)return[T];for(var k=[T],L=0,z=I.length;L<z;L++)k[L+1]=I[L][1];return k}var Jp={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Vw in Jp)Jp[Vw.toUpperCase()]=Jp[Vw];function rl(T,I){I||(I=[{}]);for(var k=I.length;k--;){var L={code:T,command:Jp[T]};T==T.toLowerCase()&&(L.relative=!0);for(var z in I[k])L[z]=I[k][z];I[k]=L}return I}if(Ne=i(),Ne!==e&&O===n.length)return Ne;throw Ne!==e&&O<n.length&&Kt(Od()),Id(Te,Ee<n.length?n.charAt(Ee):null,Ee<n.length?Ka(Ee,Ee+1):Ka(Ee,Ee))}f2.exports={SyntaxError:Ps,parse:WG}});var Fm=rh((Ace,y2)=>{var _m=m2().parse;_m.parseSVG=_m;_m.makeAbsolute=qG;y2.exports=_m;function qG(n){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(i){i.command==="moveto"&&(t=i),i.x0=e.x,i.y0=e.y;for(var o in r)o in i&&(i[o]+=i.relative?i[r[o]]:0);"x"in i||(i.x=e.x),"y"in i||(i.y=e.y),i.relative=!1,i.code=i.code.toUpperCase(),i.command=="closepath"&&(i.x=t.x,i.y=t.y),e=i}),n}});var xN=rh((Tje,bN)=>{bN.exports=function(t,e){for(var r=t.split("."),i=e.split("."),o=0;o<3;o++){var a=Number(r[o]),s=Number(i[o]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as uq,Loader as pq}from"three";import{Box3 as L_,BufferGeometry as __,MeshBasicMaterial as F_}from"three";import{Matrix4 as R_,Mesh as B_}from"three";import{Matrix4 as w_,Vector3 as TC,Euler as A_,MathUtils as _l,Quaternion as E_}from"three";var nf;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(nf||(nf={}));wi();ut();Zt();var KE;(t=>{function n(e){return!0}t.is=n})(KE||(KE={}));var sf;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(i,o){return{position:o?.position??i.position,rotation:o?.rotation??i.rotation,scale:o?.scale??i.scale,shear:o?.shear??i.shear}}r.merge=t;function e(i,o){return oh({position:Si.isEqual(i.position,o.position)?void 0:o.position,rotation:i.rotation===o.rotation?void 0:o.rotation,scale:Si.isEqual(i.scale,o.scale)?void 0:o.scale,shear:i.shear&&o.shear&&Si.isEqual(i.shear,o.shear)?void 0:o.shear})}r.diff=e})(sf||(sf={}));var Ob;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Ob||(Ob={}));var ZE;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(ZE||(ZE={}));var lf;(t=>t.defaultData={opacity:1,fill:{color:Ue.fromHexAndA(ar,1),enabled:!0},stroke:{color:Ue.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:Ue.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ue.from0to1([0,0,0,1]),enabled:!1,spread:0}})(lf||(lf={}));var wo;(o=>{function n(a,s){return{name:s}}o.newEmpty=n;function t(a,s){if(s===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let d of c)d in l&&d in s&&s[d]!==void 0&&Object.assign(l,{[d]:s[d]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,sf.merge(l,s)),l=t(l,s),l=e(l,s),l}o.patch=r;function i(a,s){let l,c=[];for(let[d,u]of Object.entries(s))d!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[d]=u);return c}o.toOps=i})(wo||(wo={}));var Qd;(t=>t.defaultData={...sf.defaultData,...Ob.defaultData,states:new fe,events:new fe,visible:!0,raycastLock:!1})(Qd||(Qd={}));var Cl;(t=>t.defaultData={...Qd.defaultData,...lf.defaultData})(Cl||(Cl={}));var cf;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(cf||(cf={}));var Ib;(t=>t.defaultData={...Cl.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Ib||(Ib={}));var Tl;(t=>t.defaultData={...Cl.defaultData,...cf.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Tl||(Tl={}));var Db;(t=>t.defaultData={...Cl.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"})(Db||(Db={}));var Rb;(t=>t.defaultData={...Cl.defaultData,type:"path2d",path:"",name:"Path"})(Rb||(Rb={}));var JE;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(JE||(JE={}));var Kd;(t=>t.defaultData={...Qd.defaultData,name:"Group",type:"group2d"})(Kd||(Kd={}));var Bb;(t=>t.defaultData=()=>({...Qd.defaultData,...cf.defaultData,...lf.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ue.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ue.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Bb||(Bb={}));var Ao;(o=>{function n(a){switch(a){case"rectangle2d":return{...Tl.defaultData};case"ellipse2d":return{...Ib.defaultData};case"text2d":return{...Db.defaultData};case"vector2d":return{...Tl.defaultData};case"path2d":return{...Rb.defaultData};case"frame2d":return{...Bb.defaultData()};case"group2d":return{...Kd.defaultData}}}o.defaultData=n;function t(a){return"width"in a&&"height"in a?[typeof a.width=="number"?a.width*.5:0,typeof a.height=="number"?a.height*.5:0]:[0,0]}o.getPivot=t;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}o.isResizeable=e;function r(a){return a.type==="frame2d"&&a.autoLayout!==void 0}o.isAutoLayoutable=r;function i(a){return a.type==="rectangle2d"||a.type==="frame2d"}o.hasCorners=i})(Ao||(Ao={}));var df;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new bt},e.emptyData=function(){return{type:"scene2d",objects:new bt}}))(df||(df={}));TE();Mb();Ab();Eb();ut();import{Box3 as q3,Line3 as X3,Matrix4 as Nb,Vector3 as Ai}from"three";var ps=new Ai,hs=new Ai,ma=new Nb,eC=[new Ai(-1,1,1),new Ai(-1,-1,1),new Ai(1,-1,1),new Ai(1,1,1),new Ai(-1,1,-1),new Ai(-1,-1,-1),new Ai(1,-1,-1),new Ai(1,1,-1)],Y3=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Q3=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],$E=(n,t,e)=>{n.updateEntityBoxSize(ps,hs),ma.copy(t).multiply(n.matrixWorld),hs.x===0&&hs.y===0&&hs.z===0?e.push(new Ai(ps.x,ps.y,ps.z).applyMatrix4(ma)):eC.forEach(r=>{e.push(r.clone().multiply(hs).add(ps).applyMatrix4(ma))})},Zd=class extends q3{constructor(){super(...arguments);this.matrix=new Nb;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new Nb().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let o=[];if(i===!0){let a=[];e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){ma.copy(r).multiply(s.matrixWorld),a.push(new Ai().applyMatrix4(ma));return}$E(s,r,o)}}),o.length===0&&o.push(...a)}else $E(e,r,o);return this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ma.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(hs).multiplyScalar(.5),this.getCenter(ps),ma.copy(this.matrix).setPosition(ps),this.vertices=eC.map(e=>e.clone().multiply(hs).applyMatrix4(ma))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Y3.map(([e,r])=>new X3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ai))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Q3.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};ut();var K3=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),Z3=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),J3=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||a_&&"ontouchend"in document,$3=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,e_=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,t_=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},r_=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},i_=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},Lb=K3(),pK=Lb?i_():void 0,n_=()=>{if(!(typeof window>"u"))return window.spline},o_=n_(),hK=!!o_?.isShellTabs,a_=Z3(),Pl=J3(),fK=$3(),hi=e_(),_b=t_(),tC=Number(r_());var lr=[];function rC(){lr.splice(0,lr.length)}function uf(n,t=0,e={}){let r=e.leading===!0,i=e.trailing!==!1,o=e.maxWait!==void 0?Math.max(e.maxWait,t):void 0,a,s,l,c,d,u=0,p=b=>{let x=s,S=l;return s=l=void 0,u=b,c=n.apply(S,x),c},h=b=>{if(d===void 0)return!0;let x=b-d,S=b-u;return x>=t||x<0||o!==void 0&&S>=o},f=b=>{let x=t-(b-d);return o!==void 0?Math.min(x,o-(b-u)):x},m=b=>(a=void 0,i&&s?p(b):(s=l=void 0,c)),y=()=>{let b=Date.now();h(b)?m(b):a=setTimeout(y,f(b))},g=function(...b){let x=Date.now(),S=h(x);if(s=b,l=this,d=x,S){if(a===void 0)return u=x,a=setTimeout(y,t),r?p(x):c;if(o!==void 0)return a=setTimeout(y,t),p(x)}return a===void 0&&(a=setTimeout(y,t)),c};return g.cancel=()=>{a!==void 0&&clearTimeout(a),u=0,s=d=l=a=void 0},g.flush=()=>a===void 0?c:m(Date.now()),g}function iC(n,t=0,e={}){return uf(n,t,{leading:e.leading!==!1,trailing:e.trailing!==!1,maxWait:t})}function ya(n){return Ml(n,new Map)}function Ml(n,t){if(n===null||typeof n!="object")return n;if(t.has(n))return t.get(n);if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp){let r=new RegExp(n.source,n.flags);return r.lastIndex=n.lastIndex,r}if(n instanceof ArrayBuffer)return n.slice(0);if(ArrayBuffer.isView(n))return new n.constructor(n.buffer.slice(0),n.byteOffset,n instanceof DataView?n.byteLength:n.length);if(n instanceof Map){let r=new Map;return t.set(n,r),n.forEach((i,o)=>r.set(Ml(o,t),Ml(i,t))),r}if(n instanceof Set){let r=new Set;return t.set(n,r),n.forEach(i=>r.add(Ml(i,t))),r}if(Array.isArray(n)){let r=new n.constructor(n.length);t.set(n,r);for(let[i,o]of Object.entries(n))r[i]=Ml(o,t);return r}let e=Object.create(Object.getPrototypeOf(n));t.set(n,e);for(let[r,i]of Object.entries(n))e[r]=Ml(i,t);return e}function Eo(n,t){if(Object.is(n,t)||n!==n&&t!==t)return!0;if(n===null||t===null||typeof n!="object"||typeof t!="object")return!1;if(n instanceof Date||t instanceof Date)return n instanceof Date&&t instanceof Date&&n.getTime()===t.getTime();if(n instanceof RegExp||t instanceof RegExp)return n instanceof RegExp&&t instanceof RegExp&&n.source===t.source&&n.flags===t.flags;if(Array.isArray(n)||Array.isArray(t))return!Array.isArray(n)||!Array.isArray(t)||n.length!==t.length?!1:n.every((i,o)=>Eo(i,t[o]));if(ArrayBuffer.isView(n)||ArrayBuffer.isView(t))return!ArrayBuffer.isView(n)||!ArrayBuffer.isView(t)||n.constructor!==t.constructor||n.length!==t.length?!1:n.every((i,o)=>Object.is(i,t[o]));if(n instanceof Map||t instanceof Map){if(!(n instanceof Map)||!(t instanceof Map)||n.size!==t.size)return!1;for(let[i,o]of n)if(!t.has(i)||!Eo(o,t.get(i)))return!1;return!0}if(n instanceof Set||t instanceof Set){if(!(n instanceof Set)||!(t instanceof Set)||n.size!==t.size)return!1;for(let i of n)if(!t.has(i))return!1;return!0}let e=Object.keys(n),r=Object.keys(t);return e.length!==r.length?!1:e.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Eo(n[i],t[i]))}function Jd(n,t){let e={};for(let r of t)r in n&&(e[r]=n[r]);return e}function $d(n,t){let e=new Set(t),r={};for(let[i,o]of Object.entries(n))e.has(i)||(r[i]=o);return r}function nC(n){if(!n||n.length===0)return;let t;for(let e of n)e===e&&(t===void 0||e>t)&&(t=e);return t}var s_=Array.isArray,Fb=s_;var Gi={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}};function eu(n){return n?.isParticleSystem===!0}function Ol(n){return n?.isHairSystem===!0}function Ei(n){return n?.isShapeBlendEntity===!0}function fs(n){return n?.isPathObject===!0}function Nr(n){return n?.isObject2D===!0}function ti(n){return n?.isUIObject===!0}function kb(n){return n?.isCloner===!0}function tu(n){return n?.isClone===!0}function Il(n){return n?.isComponentObject===!0}var l_=new Set;function Oe(n){l_.add(n)}var oC=new Set;function $t(n,t){let e=`${n}:${t}`;oC.has(e)||oC.add(e)}var sC=new Map,lC=new Map;function ms(n,t){sC.set(n,t)}function pf(n){return sC.get(n)}function Ui(n,t){lC.set(n,t)}function hf(n){return lC.get(n)}var cC=new Map;function ru(n,t){cC.set(n,t)}function ff(n){return cC.get(n)}var dC=null,aC=null;function uC(n){dC=n,aC!==null&&n.setHanaUIWasmUrl(aC)}function Vb(){return dC}import{Object3D as h_,Matrix4 as To}from"three";import{Matrix4 as c_,Vector3 as Rl}from"three";var Bn=new Rl,Nn=new Rl,Co=new Rl,zi=new Rl,ji=new Rl,Dl=new Rl,d_=new c_,yf=1e-12,mf=.01;function pC(n){let t=n.elements;Bn.set(t[0],t[1],t[2]),Nn.set(t[4],t[5],t[6]),Co.set(t[8],t[9],t[10])}function u_(n,t){n.set(1,0,0).cross(t),n.lengthSq()<=yf&&n.set(0,1,0).cross(t),n.normalize()}function hC(){let n=Math.max(Bn.lengthSq(),Nn.lengthSq(),Co.lengthSq());Bn.lengthSq()>yf*n?zi.copy(Bn).normalize():zi.set(1,0,0),ji.crossVectors(Co,zi),ji.lengthSq()<=yf*n&&(ji.copy(Nn).addScaledVector(zi,-Nn.dot(zi)),ji.lengthSq()<=yf*n&&u_(ji,zi)),ji.normalize(),Dl.crossVectors(zi,ji)}function p_(){let n=Bn.length(),t=Nn.length(),e=Co.length(),r=Math.max(n,t,e);if(r-n>mf||r-t>mf||r-e>mf)return!0;let i=mf*r*r;return Math.abs(Bn.dot(Nn))>i||Math.abs(Bn.dot(Co))>i||Math.abs(Nn.dot(Co))>i}function fC(n,t,e){return pC(n),hC(),t.makeBasis(zi,ji,Dl),e.set(zi.dot(Bn),zi.dot(Nn),zi.dot(Co),0,ji.dot(Bn),ji.dot(Nn),ji.dot(Co),0,Dl.dot(Bn),Dl.dot(Nn),Dl.dot(Co),0,0,0,0,1),p_()}function Gb(n){return pC(n),hC(),d_.makeBasis(zi,ji,Dl)}var Ub=new To,Po;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Po||(Po={}));var Bl=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new To;this.copyPreviousMatrix=!0;this.hiddenMatrix=new To;this.pivotMatrix=new To;this.matrixWorldRigid=new To;this.shearScale=new To;this.shearScaleInv=new To}get __isSPEObject(){return!0}getPhysicsLocalMatrix(r){return this.rigidBody?.isDynamic()?(r.copy(this.matrixWorld),this.hasNonUniformScale&&r.multiply(this.shearScaleInv),this.parent&&r.premultiply(Ub.copy(this.parent.matrixWorld).invert()),r.premultiply(Ub.copy(this.hiddenMatrix).invert()),r.multiply(Ub.copy(this.pivotMatrix).invert()),!0):!1}isDescendantOf(r){r instanceof h_&&(r=r.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===r)return!0;i=i.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let o=this.parent;if(r&&o!==null&&o.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let o of this.children)Po.is(o)&&o.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let a of this.children)Po.is(a)&&a.traverseObject(r,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=fC(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(r,i){this.updateWorldMatrix(!0,!1);let o=new To().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),o.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof To?r.hiddenMatrix.premultiply(o):r.applyMatrix4(o),r.updateWorldMatrix(!1,!1),this.add(r),i!==void 0&&(this.children.pop(),this.children.splice(i,0,r)),this}copy(r,i=!1){return super.copy(r,i),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,i,o,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};import{CurvePath as f_,CubicBezierCurve3 as zb,Vector3 as Hr}from"three";var Hb=class extends f_{constructor(){super()}getPoints(t=12){let e=[],r,i=this.getCurveLengths(),a=i[i.length-1]/i.length;for(let s=0,l=this.curves;s<l.length;s++){let c=l[s],d=s===0?i[s]:i[s]-i[s-1],u=Math.ceil(t*d/a),p=c.getPoints(u);for(let h=0;h<p.length;h++){let f=p[h];r&&r.equals(f)||(e.push(f),r=f)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var gf=.001,ys=new Hr,vf=new Hr,Nl=new Hr,Ll=new Hr,iu=new Hr,jb=new Hr,nu=new Hr,mC=new Hr,yC=new Hr;function gC(n,t,e){return ys.subVectors(t,n),vf.subVectors(t,e),ys.cross(vf).length()<=gf}var vC=new WeakMap;function bf(n){let t=vC.get(n.points);if(t!==void 0&&t.isClosed===n.isClosed)return t.curve;let e=m_(n);return vC.set(n.points,{isClosed:n.isClosed,curve:e}),e}function m_(n){let t=n.points,e=[t[0]],r=[new Hr(...t[0].data.position)];Nl.copy(r[0]);for(let f=0;f<t.length-1;f++)ys.fromArray(t[f].data.position),vf.fromArray(t[f+1].data.position),iu.subVectors(ys,Nl),nu.subVectors(ys,vf),iu.cross(nu).length()>gf&&(e.push(t[f]),r.push(new Hr().copy(ys)),Nl.copy(ys));let i=t[t.length-1];e.push(i),r.push(new Hr(...i.data.position));let o=n.isClosed,a=e.length-(o?0:1),s=e.length,l=[],c=[];for(let f=0;f<s;f++){let m=e[f].data;l.push(new Hr(...m.controlPrevious.position)),c.push(new Hr(...m.controlNext.position))}let d=[];for(let f=0;f<a;f++){let m=f===s-1?0:f+1;d.push(gC(r[f],c[f],r[m])&&gC(r[f],l[m],r[m]))}let u=[];for(let f=0;f<s;f++){let m=e[f].data,y=r[f],g={position:y,prevDir:void 0,nextDir:void 0,controlPrevious:l[f],controlNext:c[f],tan:void 0,baseRoundness:m.roundness,removedLength:0};if(u.push(g),m.roundness===0||!o&&(f===0||f===s-1))continue;let b=o&&f==0?s-1:f-1,x=o&&f==s-1?0:f+1,S=new Hr().subVectors(r[b],y).normalize(),v=new Hr().subVectors(r[x],y).normalize();g.prevDir=S,g.nextDir=v;let w=d[o&&f===0?s-1:f-1],A=d[f];if(w&&A){Ll.addVectors(S,v).normalize();let E=Nl.crossVectors(Ll,S).length()/S.dot(Ll);g.tan=E,g.removedLength=m.roundness/E}}for(let f=0;f<a;f++){let m=f,y=o&&f===s-1?0:f+1,g=u[m],b=u[y];if(g.removedLength!==0||b.removedLength!==0){let x=g.position.distanceTo(b.position);g.removedLength=Math.min(g.removedLength,x/2),b.removedLength=Math.min(b.removedLength,x/2)}}let p=new Array(2*s).fill(null);for(let f=0;f<a;f++){let m=f,y=o&&f===s-1?0:f+1,g=u[m],b=u[y],x=null;if(!d[f])g.position.distanceTo(b.position)>gf&&(x=new zb(g.position,g.controlNext,b.controlPrevious,b.position));else{let S=g.position.clone(),v=b.position.clone();(g.removedLength!==0||b.removedLength!==0)&&(g.nextDir&&S.add(Nl.copy(g.nextDir).setLength(g.removedLength)),b.prevDir&&v.add(Nl.copy(b.prevDir).setLength(b.removedLength))),S.distanceTo(v)>gf&&(x=new zb(S,S.clone().lerp(v,.3),v.clone().lerp(S,.3),v))}p[2*f+1]=x}for(let f=0;f<s;f++){let m=u[f];if(m.removedLength===0)continue;let y=m.position,g=m.prevDir.clone().multiplyScalar(m.removedLength).add(y),b=m.nextDir.clone().multiplyScalar(m.removedLength).add(y),x=m.tan*m.removedLength;Ll.addVectors(m.prevDir,m.nextDir).normalize(),iu.copy(g).lerp(b,.5);let S=g.distanceTo(b)/2;yC.copy(Ll).multiplyScalar(Math.sqrt(Math.pow(x,2)-Math.pow(S,2))).add(iu),jb.copy(Ll).multiplyScalar(-x).add(yC);let v=y.distanceTo(jb)/y.distanceTo(iu);nu.copy(m.prevDir).multiplyScalar(v*y.distanceTo(g)).add(y),mC.copy(nu).lerp(jb,2);let w=g.clone().lerp(nu,4/3),A=b.clone().lerp(mC,4/3);p[2*f]=new zb(g,w,A,b)}let h=new Hb;for(let f=0;f<p.length;f++){let m=p[f];m&&h.add(m)}return h}import{Euler as y_,MathUtils as g_,Matrix4 as v_,Quaternion as xC,Vector3 as qb}from"three";var ou=new v_,bC=new xC,Wb=new xC,b_=new y_,x_=new qb,S_=new qb(0,1,0);function SC(n){let t=n%1;return t<0?t+1:t===0&&n>0?1:t}function wC(n,t,e,r){bC.setFromRotationMatrix(ou.extractRotation(r));let i=n.clone().applyMatrix4(ou.copy(r).invert().multiply(e));if(t===null)Wb.setFromRotationMatrix(ou.extractRotation(e));else{let a=t.clone().applyMatrix4(ou.extractRotation(e));Wb.setFromRotationMatrix(ou.lookAt(x_.set(0,0,0),a,S_))}let o=new qb().setFromEuler(b_.setFromQuaternion(bC.invert().multiply(Wb))).multiplyScalar(g_.RAD2DEG);return{position:i,rotation:o}}var ke;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(ke||(ke={}));var Ln=n=>ke.is(n),C_={type:"completeState",isfromEntity:!0},T_=["x","y","z"],xf=new TC,AC=new TC(1,1,1),Xb=new E_,EC=new A_,CC=new w_,Fl=n=>class extends Bl(n){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 Zd;this._recursiveBBox=new Zd;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let i=this.children[r];if(ke.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(ke.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let i=r.parent;if(ke.is(i))r=i;else return}return r}forInstancesRec(r){this.instances.forEach(i=>{i.disposed||r(i),i.forInstancesRec(r)})}super_Entity(r,i){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,i,o=!1){if(!(this.data.states.length===0&&!o)){for(let a of this.data.states)go.toOps(this.data,a.data).forEach(l=>{let c=al.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,i)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=go.patch(this.data,a),go.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}o&&this.updateTransformState(this.dataPatched,i),this.stateSelection=r,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(r,i){r.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Ln(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let i;return this.traverseEntity(o=>{o.uuid===r&&(i=o)}),i}traverseSortNextHelper(){let r=this.parent;if(r){let i=r.children,o=i.indexOf(this)+1;if(ke.is(i[o]))return i[o];if(ke.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&ke.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let i=this;for(;r>0&&i!==null;)i=i.parent,r-=1;return i}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let i=this.parent;for(;i;){if(r===i)return!0;i=i.parent}return!1}countToAccestor(r){let i=0,o=this;for(;o!==r;){if(o===null)return-1;o=o.parent,i+=1}return i}forEachEntity(r){for(let i of this.children)Ln(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{ke.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let a of this.children)Ln(a)&&a.isConcreteEntity&&a.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let a of this.children)Ln(a)&&a.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Ln(i)&&i.visible&&i.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,i=!1){return super.copy(r,i),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Ln(r))}isAncestorOf(r){if(this.uuid===r)return!1;let i=!1;return this.traverseEntity(o=>{o.uuid===r&&(i=!0)}),i}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*_l.RAD2DEG,this.rotation.y*_l.RAD2DEG,this.rotation.z*_l.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return $d(i,r)}getTransformValues(r,i,o){return i[r].map((a,s)=>o?.shared.getVariable(a,[this.uuid,r,T_[s]])??a)}updateTransformState(r,i){let o=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),o=!0),r.rotation&&(xf.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(_l.DEG2RAD),this.rotation.setFromVector3(xf),o=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,i)),o=!0),r.hiddenMatrix!==void 0&&(o=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??da.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(o=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(xf.fromArray(r.pivot).negate(),Xb.setFromEuler(EC.fromArray(r.pivotRotation.map(a=>a*_l.DEG2RAD))).invert(),AC);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let a=xf.setFromMatrixPosition(this.pivotMatrix);Xb.setFromEuler(EC.fromArray(r.pivotRotation.map(s=>s*_l.DEG2RAD))).invert(),this.pivotMatrix.compose(a,Xb,AC)}}return o&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),o}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}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 r of this.children)ke.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{ke.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return $d(i,r)}updateByObjUpdateOp(r,i){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},i,!1)}updateByOp(r,i,o,a){let s=this.data;this.data=i;let l=r,c=Ye(r.path,["states","*"]);if(c!==null){if(r.type===0){let[d]=c;if(this?.stateSelection===d){let u={...r.props};if(delete u.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let h=Ot.zoom(p,r.path.slice(2));if(h)for(let f in r.props)r.props[f]===void 0&&f in h&&(u[f]=h[f])}}l={...r,props:u,path:r.path.slice(2)}}}}else if(r.type===0){let d=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(d!==void 0){if(r.props.name!==void 0&&d.name){let{name:p,...h}=d;d=h}if(r.props.material!==void 0&&"material"in d){let{material:p,...h}=d;d=h}let u=Ot.removeOverridden(r.path,r.props,d);l={...r,props:u}}}if(this.updateByPatchedOpBase(l,go.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),o),Ye(r.path,["overrides"])){let d=[],u=[...r.path];for(d.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)d.push(u[1]),u.splice(0,2);if(d[d.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){d[d.length-1]=p;let h=o.scene.findInstance([this.uuid,...d]);h&&(h.overrideData=r.props[p],h.updateState(An.apply(h.component.data,h.overrideData),o))}}else{let p=o.scene.findInstance([this.uuid,...d]);if(p){let h=Ot.zoom(p.component.data,u);if(r={...r,path:u},r.type===0){let f=r.props;if(h)for(let[m,y]of Object.entries(r.props))y===void 0&&(f===r.props&&(f={...r.props}),f[m]=h[m]);r={...r,props:f}}p.overrideData=yl.resolve(i.overrides,d),p.updateByOp(r,zt.applySimple(p.data,r),o,!1)}}}else if(this.instances.length>0){let d;if(r.path.length===0&&r.type===0){let u;for(let p of On.rootOverrideProps)p in r.props&&(u===void 0&&(u={}),u[p]=r.props[p]);u&&(d={...r,props:u})}else for(let u of On.rootOverrideProps)if(Ye(r.path,[u])){d=r;break}d!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let p=An.filterOp(u.overrideData,d);p&&u.updateByOp(p,zt.applySimple(u.data,p),o,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let p=An.filterOp(u.overrideData,r);if(p){let h;s===u.data&&r===p?h=i:h=zt.applySimple(u.data,p),u.updateByOp(p,h,o,!0)}}})}}updateByPatchedOpBase(r,i,o){if(this.dataPatched=i,r.path.length===0&&r.type===0)r.props.type!==void 0&&!on.is(r.props.type)&&Gi.changeEntityProptotype(this,i,o);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Gi.changeEntityProptotype(this,i,o);for(let a of this.children)ke.is(a)&&a.updateVisible(o.scene)}this.updateByPatchedOp(r,i,o)}updateByPatchedOp(r,i,o){if(r.path.length===0&&r.type===0?this.updateState(r.props,o):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(i,o),r.path[0]==="morphTargetInfluences"&&r.type===0){let s=i.morphTargetInfluences.get(r.path[1])?.data.name;s&&this.updateMorphInfluences(s,o.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Ye(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Ye(r.path,["cloner"])!==null){let a=zt.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,o):this.cloner?this.cloner.updateState(i.cloner,o):(this.setFromClonerState(i.cloner,o),this.expandCloner(o)),this.updateVisible(o.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,o=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=r.find(i);if(!l)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let d=bf(c.geometry.path),u=SC(o+a),p=null;try{p=d.curves.length?d.getPointAt(u):null}catch(m){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(m))}if(p===null)return;l.updateMatrixWorld();let h=this.parent?CC.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):CC.copy(this.hiddenMatrix),f=wC(p,s==="tangential"?d.getTangentAt(u):null,l.matrixWorld,h);this.updateTransformState({position:f.position.toArray(),rotation:f.rotation.toArray()}),this.traverseEntity(m=>{m._cameraType&&m.dispatchEvent(C_)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let i=!1;this.traverseEntity(o=>{if(o.data.type==="Splat")return i=!0,!0}),i&&r.reloadSplats()}updateState_Entity(r,i){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(r,i)}get attachedSurfaceCloners(){return this.children.filter(r=>kb(r)&&r.parameters.type==="toObject")}setFromClonerState(r,i){if(!this.disposed)if(r===null||r.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(Gi.Cloner===null){$t("cloners","a cloner");return}this.cloner=new Gi.Cloner(this,r),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(r,i)}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{Float32BufferAttribute as OC,Sphere as O_}from"three";import{BufferGeometry as P_,Float32BufferAttribute as Yb,Uint32BufferAttribute as M_,Vector3 as PC}from"three";var MC=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??r),o=Math.abs(e.depth??r),a=Math.abs(Math.min(r,o))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:o,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:o,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:d,cornerSegments:u}=n.parameters,p=new au(!1,t,e,r,i,o,a,s,l,c,d,u);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Qb=new M_([0,0,0],1);function Sf(n){return n.type==="TorusGeometry"&&n.arc===360}var au=class extends P_{constructor(t=!0,e=1,r=1,i=1,o=1,a=1,s=1,l=1,c=1,d=1,u=1,p=1){if(super(),a===0)return;let h=t&&a===1;h&&(p=0),u>100&&(u=100),u===0&&(p=0);let f=()=>new PC,m=new PC,y=f(),g=f(),b=f(),x,S,v,w,A,E,P,M,R=f(),D=f(),N=f(),C=f(),B=f(),_=f(),F=f(),V=f(),K=r-2*l+.001,q=K/a,G=Math.ceil(s*a),W=G+1,H=K/G,Z=-K/2,te=d+1,Q=2*Math.PI/d,se=Math.PI/2/p,oe=.01,ne=Math.min((1-u/100)*l,l-oe),de=l-ne,ve=0,me=2,ce=p*me+me,X=te*ce/me,ee=X+te*W,re=Math.max(0,te*(W+ce)),[he,xe,ae]=[3,3,2].map(Be=>Array(re*Be).fill(0)),ue=[],O=o-l;function J(Be,ft){let Ze=Math.PI/2;E=ft*H,M=2*Math.PI*(E%q)/q+Ze,E+=Z,P=Math.sin(M)*O,A=Math.cos(M)*O,t?Be.set(A,P,E):Be.set(A,E,P)}J(m,-1e-10),J(y,0),R.copy(m),J(m,1);let we=m.distanceTo(y),Ee=h?0:de+ne,Te=we*G+2*Ee,be=ne,Ne=Te-Ee;for(let Be=0;Be<=G;Be++){J(g,Be),V.subVectors(g,R).normalize(),R.copy(g),_.copy(g).setComponent(+t+1,0).normalize(),F.crossVectors(V,_).normalize();let ft=Be===0,Ze=Be===G,Qa=ft?3*Math.PI/2:se,Od=ft?be:Ne,bv=ft?te:ee,Zp=ft?0:re-te,Ka=V.clone().multiplyScalar(ft?-de:de).add(g),Kt=V.clone().multiplyScalar(ft?-1:1).normalize();for(let nn=0;nn<te;nn++){let Id=nn*Q;if(D.addVectors(m.copy(_).multiplyScalar(l*Math.cos(Id)),y.copy(F).multiplyScalar(l*Math.sin(Id))),N.copy(D).normalize(),ft||Ze){h||(ve=Zp+nn,[0,1,2].forEach(Br=>{he[ve*3+Br]=Ka.getComponent(Br),xe[ve*3+Br]=Kt.getComponent(Br)}),ae[ve*2]=+Ze,ae[ve*2+1]=nn/d),y.copy(N).multiplyScalar(ne),b.addVectors(g,y);for(let Br=0;Br<p;Br++){let Dd=Br*se+Qa;C.addVectors(m.copy(V).multiplyScalar(de*Math.sin(Dd)),y.copy(N).multiplyScalar(de*Math.cos(Dd))),B.copy(C).normalize(),y.addVectors(b,C),C.normalize(),ve=bv+Br*te+nn,[0,1,2].forEach(Za=>{he[ve*3+Za]=y.getComponent(Za),xe[ve*3+Za]=B.getComponent(Za)});let Rd=+ft+Math.sin(Dd);ae[ve*2]=(Od+de*Rd)/Te,ae[ve*2+1]=nn/d}}y.addVectors(g,D),ve=X+Be*te+nn,[0,1,2].forEach(Br=>{he[ve*3+Br]=y.getComponent(Br),xe[ve*3+Br]=N.getComponent(Br)}),ae[ve*2]=(Ee+Be*we)/Te,ae[ve*2+1]=nn/d}}let Ae=W+2*p+me,[Re,Xe]=[+h,Ae-1];for(let Be=Re;Be<=Xe-1;Be++){let ft=h&&Be===Xe-1;for(let Ze=0;Ze<te-1;Ze++)x=Be*te+Ze,S=x+1,v=(ft?Ze:x)+te,w=(ft?Ze+1:S)+te,Be===0?ue.push(S,w,v):Be===Ae-2?ue.push(x,S,v):ue.push(x,S,v,S,w,v)}this.setIndex(ue),this.setAttribute("position",new Yb(he,3)),this.setAttribute("normal",new Yb(xe,3)),this.setAttribute("uv",new Yb(ae,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments,i=r+1,o=[],a,s,l,c;for(let d=1;d<e;d++)for(let u=0;u<r;u++)a=d*i+u,s=a+1,l=a+i,c=s+i,o.push(a,s,l,s,c,l);for(let d=0;d<r;d++)a=e*i+d,s=a+1,l=d+i,c=d+1+i,o.push(a,s,l,s,c,l);return Qb.array=new Uint32Array(o),Qb.count=o.length,Qb}};var wf,Af=new Map,IC=0;function Ef(){if(wf===void 0)throw new Error("boolean-wasm is not loaded");return wf}function Kb(n){let t=Af.get(n);if(t===void 0)throw new Error("Unknown csg mesh set handle "+n);return t}function Zb(n){return Af.set(++IC,n),IC}var I_={[0]:0,[1]:1,[2]:2};function D_(n,t){if(t&&n.userData.positions!==void 0){let s=n.userData,l=[];for(let c=0,d=0;c<s.verticesPerFace.length;c++){let u=s.verticesPerFace[c];for(let p=1;p<u-1;p++)l.push(s.indices[d],s.indices[d+p],s.indices[d+p+1]);d+=u}return{positions:s.positions instanceof Float32Array?s.positions:new Float32Array(s.positions),indices:new Uint32Array(l)}}let e;Sf(n.userData.parameters)?e=n.getClosedTorusIndicesForBooleanOrSubdiv():e=n.getIndex();let r=n.getAttribute("position"),i;if(e===null){i=new Uint32Array(r.count);for(let s=0;s<i.length;s++)i[s]=s}else e.array instanceof Uint32Array?i=e.array:i=new Uint32Array(e.array);let o=n.getAttribute("normal"),a=o!==void 0&&o.itemSize===3&&o.count===r.count&&o.array instanceof Float32Array&&o.isInterleavedBufferAttribute!==!0?o.array:void 0;return{positions:r.array,indices:i,normals:a}}function DC(n,t,e){if(wf===void 0)return-1;let{positions:r,indices:i,normals:o}=D_(n,t);return Zb(new wf.CsgMesh(r,i,o))}function RC(n,t){let e=Ef(),r=I_[t];if(r===void 0)throw new Error("Unknown boolean operation "+t);let i=n.map(Kb);if(i.length===1)return e.clone_mesh(i[0]);let o=[],a;if(t===2&&i.length>2){let s=i[0];for(let l=1;l<i.length-1;l++)s=e.boolean_mesh(s,i[l],0),o.push(s);a=e.boolean_mesh(i[i.length-1],s,2)}else if(t===2)a=e.boolean_mesh(i[1],i[0],2);else{let s=i[i.length-1];for(let l=0;l<i.length-1&&(s=e.boolean_mesh(s,i[l],r),o.push(s),s.tri_count()!==0);l++);a=s,o.pop()}for(let s of o)s.free();return a}function BC(n,t,e,r){let i=Ef(),o=RC(n,t),a=i.mesh_render_data(o,Math.max(r,0));if(e.setAttribute("position",new OC(a.positions(),3)),e.setAttribute("normal",new OC(a.normals(),3)),a.free(),e.boundingSphere===null&&(e.boundingSphere=new O_),o.tri_count()===0)e.boundingSphere.center.set(0,0,0),e.boundingSphere.radius=0,e.userData.parameters={width:0,height:0,depth:0};else{let s=o.bounds();e.boundingSphere.center.set(s[0],s[1],s[2]),e.boundingSphere.radius=(s[3]**2+s[4]**2+s[5]**2)**.5,e.userData.parameters={width:s[3]*2,height:s[4]*2,depth:s[5]*2}}return Zb(o)}function NC(n,t){let e=Ef(),r=RC(n,t),i=e.mesh_topological_data(r),o=i.positions(),a=i.indices();i.free(),r.free();let s=new Uint8Array(a.length/3).fill(3);return{positions:o,indices:a,verticesPerFace:s}}function Cf(n,t){Kb(n).transform(new Float32Array(t.elements))}function Tf(n){let t=Af.get(n);t!==void 0&&(t.free(),Af.delete(n))}function LC(n,t){let e=Ef();return Zb(e.instanced_union(Kb(n),t))}function gs(n){return n!==null&&"booleanOp"in n}var kl=class extends Fl(B_){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new R_}updateVisible(e){super.updateVisible(e),this.visible=!gs(this.parent)&&this.visible,gs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){gs(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Tf(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),gs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof kl&&(e.freeBooleanPointer(),gs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&gs(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),gs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var N_=null;function _C(){return N_}var Pf=new L_;function su(n,t=0,e=n.count,r,i){let o=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,d=-1/0;for(let u=t;u<e;u++){let p=n.getX(u),h=n.getY(u),f=n.getZ(u);p<o&&(o=p),h<a&&(a=h),f<s&&(s=f),p>l&&(l=p),h>c&&(c=h),f>d&&(d=f)}Pf.min.set(o,a,s),Pf.max.set(l,c,d),Pf.getCenter(r),Pf.getSize(i).multiplyScalar(.5)}var k_=new __,V_=new F_,Je=class extends kl{constructor(t,e){super(k_,V_),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){let r=_C();if(r!==null){r(this,t,e);return}super.raycast(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?su(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Object3D as Z_,Vector3 as Hi,InstancedMesh as J_,InstancedBufferAttribute as $_,PlaneGeometry as eF,Vector4 as lu,Quaternion as JC,TextureLoader as tF,Texture as $C,Euler as rF,MathUtils as ax}from"three";import{Vector3 as FC,FloatType as $b,DataTexture as ex,RGBAFormat as tx,Mesh as G_,Euler as kZ,Matrix4 as VZ}from"three";import{MeshSurfaceSampler as U_}from"three/examples/jsm/math/MeshSurfaceSampler.js";function kC(n){let t=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let r=0;r<n;r++){let i=e*n+r;t[i*2+0]=e/(n-1),t[i*2+1]=r/(n-1)}return t}function VC(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function GC(n,t){let e=new G_(n.geometry,n.material),r=[],i=[],o=new FC,a=new FC;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new U_(e).build();for(let d=0;d<t;d++)s.sample(o,a),r.push(o.x,o.y,o.z),i.push(a.x,a.y,a.z);let l=new Float32Array(r),c=new Float32Array(i);return{positions:l,normals:c}}function rx(n,t){let e=n,r=new Float32Array(4*t*t);for(let o=0;o<t*t;o++)r[4*o]=e[3*o],r[4*o+1]=e[3*o+1],r[4*o+2]=e[3*o+2],r[4*o+3]=0;let i=new ex(r,t,t,tx,$b);return i.needsUpdate=!0,i}function UC({size:n}){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new ex(t,n,n,tx,$b);return e.needsUpdate=!0,e}function zC(n){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new ex(t,n,n,tx,$b);return e.needsUpdate=!0,e}var jC=`
3
3
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
4
4
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
@@ -726,7 +726,7 @@ void main() {
726
726
  `;this.pyramidPassMaterial.fragmentShader=t,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new LF(zl,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,i,o){new IF().min.setScalar(0);let s=e.length-1,l=new kF;r.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let u=c;u>=0;u--){let p=u%2===c%2?o[0]:o[1],h=u===c?i:u%2===c%2?o[1]:o[0];this.pyramidPassUniforms.inputTexture.value=h.textures.length>1?h.textures[1]:h.texture,this.pyramidPassUniforms.inputWidth.value="width"in h?h.width:1,this.pyramidPassUniforms.inputHeight.value="height"in h?h.height:1,r.setRenderTarget(p);let f=e[u],m=r.getPixelRatio();r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,f/m,f/m),u===2&&t%2!==0&&r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),r.render(this.pyramidPassScene,uu);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,u<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[u+1])}r.setViewport(l);let d=e.length%2===0?0:1;return r.readRenderTargetPixelsAsync(o[d],o[d].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};ut();import{Color as VF}from"three";var Pt=class extends VF{constructor(e,r,i,o){super(e,r,i);this.isColorA=!0;this.a=o}setRGBA(e,r,i,o){super.setRGB(e,r,i),this.a=o}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,r="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let o,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(o[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(o[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var Oo=class extends Pt{};import{VideoTexture as HF,Texture as WF}from"three";var kf=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.cleanupTimer=null;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let r=e;e=e.next,e.prev=this.head,this.head.next=e,r.next=null,r.prev=null,r.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}};var yx=class extends kf{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},mx;function mT(n){return typeof n=="string"?n:(mx||(mx=new yx),mx.load(n))}var Vf=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Gf=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};import{DataTexture as GF,DataUtils as yT,HalfFloatType as UF,RGBAFormat as zF}from"three";import{HDRLoader as jF}from"three/examples/jsm/loaders/HDRLoader.js";function gx(n){return n.length>2&&n[0]===35&&n[1]===63}function gT(n){try{let t=new jF().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!t||!t.width||!t.height)return null;let{width:e,height:r}=t,i=t.data,o=new Uint16Array(i.length),a=e*4,s=d=>yT.toHalfFloat(Math.pow(Math.max(yT.fromHalfFloat(d),0),1/2.2)),l=new Map,c=d=>{let u=l.get(d);return u===void 0&&(u=s(d),l.set(d,u)),u};for(let d=0;d<r;d++){let u=d*a,p=(r-1-d)*a;for(let h=0;h<a;h+=4)o[p+h]=c(i[u+h]),o[p+h+1]=c(i[u+h+1]),o[p+h+2]=c(i[u+h+2]),o[p+h+3]=i[u+h+3]}return{isSplineHdr:!0,data:o,width:e,height:r}}catch{return null}}function vT(n){let t=new GF(n.data,n.width,n.height,zF,UF);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var qF=0,jl=class extends Vf{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.instanceId=++qF;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 r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let o of Object.values(i))for(let a of Object.values(o))a&&(a.image=this.img,a.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 i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let o;await new Promise(a=>{i.onloadend=s=>{o=s.target?.result,a(null)}}),this.img.src=o}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else if(e instanceof Uint8Array?gx(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let i=e instanceof Uint8Array?e:null;if(i===null)try{i=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{i=null}let o=i!==null&&gx(i)?gT(i):null;o!==null&&(this.isHdr=!0,this.img=o,r())}else this.img=new Image,this.img.src=mT(e),this.img.onload=r,await new Promise(i=>{this.img.onload=()=>{r(),i(null)}})}getTexture(e,r=1008,i=1006){let o=this._cache[e]?.[r]?.[i];if(o)return o;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new HF(this.img,void 0,e,e):this.isHdr?(a=vT(this.img),a.wrapS=e,a.wrapT=e,a.magFilter=i,a.minFilter=r):a=new WF(this.img,void 0,e,e,i,r),this.isBuffer||(a.anisotropy=8,a.generateMipmaps=r===1008),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][i]=a,a}}setNeedsUpdate(e){if(!this.isBuffer)for(let r of Object.values(this._cache))for(let i of Object.values(r))for(let o of Object.values(i))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[i,o]of Object.entries(r))for(let[a,s]of Object.entries(o))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Ci=class extends jl{};var bT=new Map;function xT(n){if(typeof n=="string")return n;let t=bT.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},bT.set(n,t)),t.url}var XF,ST=new Promise(n=>{XF=n});var wT;ST.then(n=>wT=n);var Io=class{constructor({src:t,volume:e,delay:r,loop:i}){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)};let o;typeof t=="string"?o={src:t}:o={src:xT(t),format:"wav"},this.sound=new wT.Howl(o),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),i!==void 0&&(this.loop=i)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var AT=null;function ET(n){AT=n}function CT(){return AT}function vx(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}import{BufferGeometryLoader as MV}from"three";import{BufferGeometry as KF,ConeGeometry as ZF,Float32BufferAttribute as JF,MathUtils as $F}from"three";import{BufferAttribute as Uf,BufferGeometry as MT,CylinderGeometry as YF,Float32BufferAttribute as QF,MathUtils as TT,Vector2 as pu}from"three";var zf=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.parameters?.radiusTop,r=n.parameters?.radiusBottom,i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);i.thetaLength=TT.clamp(i.thetaLength,0,360),i.hollow=TT.clamp(i.hollow??0,0,1);let o=i.width/2,a=i.radiusTop??o,s=i.radiusBottom??o;if(a===s?(a=o,s=o):a>s?(a=o,s=s*o/a):(a=a*o/s,s=o),i.shapeBlendNode){a=e??o,s=r??o;let l=Math.max(a,s)*2;i.width=l,i.depth=l}return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:a,radiusBottom:s})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:u,cornerSegments:p,hollow:h}=n.parameters,f;l===0?(f=new MT,f.setAttribute("position",new QF([],3))):u||h?f=new hu(c,d,r,i,o,a,s,l*Math.PI/180,u,u,p,h):f=new YF(c,d,r,i,o,a,s,l*Math.PI/180);let m=e/t;return m!==1&&f.scale(1,1,m),Object.assign(f,{userData:{...n,type:"CylinderGeometry"}})}};function PT(n){return new pu(n.y,-n.x)}var hu=class extends MT{constructor(t,e,r,i,o,a,s,l,c,d,u,p,h=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,o=Math.floor(o)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,d=0);let f=r/2;h&&t==0&&(t=c),h&&e==0&&(e=d);let m=new pu(t,f),y=new pu(e,-f),g=null,b=null,x=null,S=null,v=m.clone().sub(y),w=0,A=0,E=0;p>0&&(w=Math.min(t,e)*(1-p),A=t-w,E=e-w);let P=m.clone();P.x-=w;let M=Math.PI-v.angle(),R=v.angle(),D=Math.tan(R/2),N=Math.tan(M/2),C=D+N,B=p?C:N,_=p?C:D;if(c=Math.min(c,(t-A)/B,v.length()/C),d=Math.min(d,(e-E)/_,v.length()/C),c>0){let ae=c/D;g=m.clone().sub(new pu(ae,c)),p&&(x=g.clone(),x.x-=w-C*c),m.sub(v.clone().setLength(ae))}if(d>0){let ae=d/N;b=y.clone().sub(new pu(ae,-d)),y.add(v.clone().setLength(ae)),p&&(S=b.clone(),S.x-=w-C*d,P.sub(v.clone().setLength(ae)))}v=m.clone().sub(y);let F=v.length()<.5,V=[],K=[],q=[],G=[],W=[],H=[],Z=(ae,ue,O,J,we)=>{for(let Ee=0;Ee<u+1;Ee++){let Te=Ee/u,be=J<0?Te:1-Te;we&&(be-=1),be*=ae;let Ne=Math.sin(be),Ae=Math.cos(be)*J,Re=Ae*ue+O.y;V.push(Ne*ue+O.x),K.push(Re),q.push(Ne),G.push(Ae),W.push(.5+Re/r),H.push(!1)}},te=(ae,ue,O)=>{let J=[ae,ue];O<0&&J.reverse();for(let we of J)V.push(we),K.push(f*O),q.push(0),G.push(O),W.push(.5),H.push(!0)};if(S&&b?(Z(M,d,S,-1,!0),Z(R,d,b,-1,!1)):b?(te(b.x,0,-1),Z(R,d,b,-1,!1)):a||te(e,E,-1),!F){let ae=PT(v).normalize();for(let ue=0;ue<=o;ue++){let O=ue/o,J=v.y*O+y.y;V.push(v.x*O+y.x),K.push(J),q.push(ae.x),G.push(ae.y),W.push(.5+J/r),H.push(!1)}}if(x&&g?(Z(M,c,g,1,!1),Z(R,c,x,1,!0)):g?(Z(M,c,g,1,!1),te(g.x,0,1)):a||te(t,A,1),p&&!F){let ae=PT(v).multiplyScalar(-1).normalize();for(let ue=0;ue<=o;ue++){let O=ue/o,J=v.y*-O+P.y;V.push(v.x*-O+P.x),K.push(J),q.push(ae.x),G.push(ae.y),W.push(.5+J/r),H.push(!1)}}let Q=V.length,oe=Q+(p&&!a?1:0),ne=(ae,ue)=>ae*Q+(ue===Q?0:ue),de=l<Math.PI*2,ve=(i+1)*Q+(de?2*(1+oe):0),me=new Float32Array(ve*3),ce=new Float32Array(ve*3),X=new Float32Array(ve*2),ee=ve-1>65535?new Uint32Array(i*Math.max(0,oe-1)*6+(de?2*(oe+1)*3:0)):new Uint16Array(i*Math.max(0,oe-1)*6+(de?2*(oe+1)*3:0)),re=0,he=0;for(let ae=0;ae<=i;ae++){let ue=ae/i,O=ue*l+s,J=Math.sin(O),we=Math.cos(O);for(let Ee=0;Ee<Q;Ee++){let Te=he*3,be=he*2,Ne=V[Ee],Ae=q[Ee];me[Te]=Ne*J,me[Te+1]=K[Ee],me[Te+2]=Ne*we,ce[Te]=Ae*J,ce[Te+1]=G[Ee],ce[Te+2]=Ae*we,H[Ee]?(X[be]=.5,X[be+1]=.5):(X[be]=ue,X[be+1]=W[Ee]),he++}}for(let ae=0;ae<i;ae++)for(let ue=0;ue<oe-1;ue++){if(a&&p&&ue==o)continue;let O=ne(ae,ue),J=ne(ae+1,ue),we=ne(ae+1,ue+1),Ee=ne(ae,ue+1),Te=me[we*3+0],be=me[we*3+2];ee[re++]=O,ee[re++]=J,ee[re++]=Ee,(Te!=0||be!=0)&&(ee[re++]=J,ee[re++]=we,ee[re++]=Ee)}de&&(xe(-1,0,s),xe(1,i*Q,s+l)),this.setIndex(new Uf(ee.slice(0,re),1)),this.setAttribute("position",new Uf(me,3)),this.setAttribute("normal",new Uf(ce,3)),this.setAttribute("uv",new Uf(X,2));function xe(ae,ue,O){let J=Math.sin(O),we=Math.cos(O),Ee=-we,Te=J,be=ae<0?(Be,ft,Ze)=>{ee[re++]=Be,ee[re++]=ft,ee[re++]=Ze}:(Be,ft,Ze)=>{ee[re++]=Be,ee[re++]=Ze,ee[re++]=ft},Ne=(t+e+A+E)/4,Ae=he*3,Re=he*2;me[Ae]=Ne*J,me[Ae+1]=0,me[Ae+2]=Ne*we,ce[Ae]=Ee,ce[Ae+1]=0,ce[Ae+2]=Te,X[Re]=.5,X[Re+1]=.5;let Xe=he++;for(let Be=0;Be<oe;Be++){let ft=(ue+(Be===Q?0:Be))*3;Ae=he*3,Re=he*2,me[Ae]=me[ft],me[Ae+1]=me[ft+1],me[Ae+2]=me[ft+2],ce[Ae]=Ee,ce[Ae+1]=0,ce[Ae+2]=Te;let Ze=ft/3*2|0;X[Re]=X[Ze],X[Re+1]=X[Ze+1],he++}for(let Be=Xe+1;Be<he-1;Be++)be(Xe,Be,Be+1);be(Xe,he-1,Xe+1)}}};var OT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=$F.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:u}=n.parameters,p;l===0?(p=new KF,p.setAttribute("position",new JF([],3))):c>0||d>0||l<360?p=new hu(0,t/2,r,i,o,a,s,l*Math.PI/180,c,d,u,0,!0):p=new ZF(t/2,r,i,o,a);let h=e/t;return h!==1&&p.scale(1,1,h),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as ek,BufferAttribute as jf,BufferGeometry as tk,Vector3 as Hf}from"three";var IT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:o,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,c;return s===0?c=new ek(t,e,r,i,o,a):c=new xx(t,e,r,i,o,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},bx=Math.PI/2,xx=class extends tk{constructor(t=1,e=1,r=1,i=1,o=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",i=Math.floor(i),o=Math.floor(o),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=s>0,d=l+1,p=2*((a+1)*(o+1)+(i+1)*(a+1)+(i+1)*(o+1))+(c?d*4*(a+1+(i+1)+(o+1))+8*(d*(d+1)/2):0),h=2*(a*o+i*a+i*o)+(c?l*4*(a+i+o):0),f=c?8*l*l:0,m=new Float32Array(p*3),y=new Float32Array(p*3),g=new Float32Array(p*2),b=p-1>65535?new Uint32Array(h*6+f*3):new Uint16Array(h*6+f*3),x=0,S=0,v=new Float64Array(d),w=new Float64Array(d),A=new Float64Array(d),E=new Float64Array(d);for(let B=0;B<d;B++){let _=B/l*bx;v[B]=Math.sin(_)*s,w[B]=(1-Math.cos(_))*s,A[B]=Math.sin(_),E[B]=Math.cos(_)}let P=d*(d+1)/2,M=new Float64Array(P*3),R=new Float64Array(P*3);{let B=new Hf(t/2,e/2,r/2);B.subScalar(s);let _=0;for(let F=0;F<=l;F++){let V=bx*(1-F/l),K=Math.cos(V),q=Math.sin(V),G=0;for(let W=0;W<=F;W++){let H=Math.cos(G),Z=Math.sin(G),te=K*H,Q=q,se=K*Z;M[_*3]=te,M[_*3+1]=Q,M[_*3+2]=se,R[_*3]=B.x+te*s,R[_*3+1]=B.y+Q*s,R[_*3+2]=B.z+se*s,_++,G+=bx/F}}}D("z","y","x",-1,-1,r,e,t,a,o),D("z","y","x",1,-1,r,e,-t,a,o),D("x","z","y",1,1,t,r,e,i,a),D("x","z","y",1,-1,t,r,-e,i,a),D("x","y","z",1,-1,t,e,r,i,o),D("x","y","z",-1,-1,t,e,-r,i,o),s>0&&(N("z","y","x",-1,-1,1,r,e,t,a),N("z","y","x",1,-1,-1,r,e,t,a),N("z","y","x",-1,1,-1,r,e,t,a),N("z","y","x",1,1,1,r,e,t,a),N("x","y","z",-1,-1,-1,t,e,r,i),N("x","y","z",1,-1,1,t,e,r,i),N("x","y","z",-1,1,1,t,e,r,i),N("x","y","z",1,1,-1,t,e,r,i),N("y","x","z",-1,-1,1,e,t,r,o),N("y","x","z",1,-1,-1,e,t,r,o),N("y","x","z",1,1,1,e,t,r,o),N("y","x","z",-1,1,-1,e,t,r,o),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 jf(b,1)),this.setAttribute("position",new jf(m,3)),this.setAttribute("normal",new jf(y,3)),this.setAttribute("uv",new jf(g,2));function D(B,_,F,V,K,q,G,W,H,Z){let te=(q-2*s)/H,Q=(G-2*s)/Z,se=q/2-s,oe=G/2-s,ne=W/2,de=H+1,ve=Z+1,me=0,ce=new Hf;for(let X=0;X<ve;X++){let ee=X*Q-oe;for(let re=0;re<de;re++){let he=re*te-se,xe=(x+me)*3,ae=(x+me)*2;ce[B]=he*V,ce[_]=ee*K,ce[F]=ne,m[xe]=ce.x,m[xe+1]=ce.y,m[xe+2]=ce.z,ce[B]=0,ce[_]=0,ce[F]=W>0?1:-1,y[xe]=ce.x,y[xe+1]=ce.y,y[xe+2]=ce.z,g[ae]=re/H,g[ae+1]=1-X/Z,me+=1}}for(let X=0;X<Z;X++)for(let ee=0;ee<H;ee++){let re=x+ee+de*X,he=x+ee+de*(X+1),xe=x+(ee+1)+de*(X+1),ae=x+(ee+1)+de*X;b[S++]=re,b[S++]=he,b[S++]=ae,b[S++]=he,b[S++]=xe,b[S++]=ae}x+=me}function N(B,_,F,V,K,q,G,W,H,Z){let te=(G-2*s)/Z,Q=G/2-s,se=W/2-s,oe=H/2,ne=Z+1,de=0,ve=new Hf,me=new Hf;for(let ce=0;ce<l+1;ce++){ve[_]=(se+v[ce])*K,ve[F]=(oe-w[ce])*q,me[B]=0,me[_]=A[ce]*Math.sign(ve[_]),me[F]=E[ce]*Math.sign(ve[F]);for(let X=0;X<ne;X++){let ee=X*te-Q;ve[B]=ee*V;let re=(x+de)*3,he=(x+de)*2;m[re]=ve.x,m[re+1]=ve.y,m[re+2]=ve.z,y[re]=me.x,y[re+1]=me.y,y[re+2]=me.z,g[he]=X/Z,g[he+1]=0,de+=1}}for(let ce=0;ce<l;ce++)for(let X=0;X<Z;X++){let ee=x+X+ne*ce,re=x+X+ne*(ce+1),he=x+(X+1)+ne*(ce+1),xe=x+(X+1)+ne*ce;b[S++]=ee,b[S++]=re,b[S++]=xe,b[S++]=re,b[S++]=he,b[S++]=xe}x+=de}function C(B,_,F){let K=B*_*F>0?(G,W,H)=>{b[S++]=G,b[S++]=W,b[S++]=H}:(G,W,H)=>{b[S++]=G,b[S++]=H,b[S++]=W},q=x;for(let G=0;G<P;G++){let W=G*3,H=x*3,Z=x*2;m[H]=B*R[W],m[H+1]=_*R[W+1],m[H+2]=F*R[W+2],y[H]=B*M[W],y[H+1]=_*M[W+1],y[H+2]=F*M[W+2],g[Z]=0,g[Z+1]=0,x++}for(let G=0;G<l;G++){let W=q+G*(G+1)/2,H=q+(G+1)*(G+2)/2;K(W,H+1,H);for(let Z=1;Z<=G;Z++)K(W+Z-1,W+Z,H+Z),K(W+Z,H+Z+1,H+Z)}}}};import{BufferAttribute as Sx,BufferGeometry as rk,Triangle as ik,Vector3 as Fn,Vector2 as wx}from"three";var va=class extends rk{constructor(t=[],e=[],r="",i=1,o=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s,l,c,d=0;u(),p(),this.setAttribute("position",new Sx(new Float32Array(s.subarray(0,d)),3)),this.setAttribute("normal",new Sx(new Float32Array(l.subarray(0,d)),3)),this.setAttribute("uv",new Sx(new Float32Array(c.subarray(0,d/3*2)),2));return;function u(){o=Math.min(1-1e-5,o),o==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new Fn,y=m.clone(),g=new ik,b=o*i,x=i-b,S=a+1,v=new Fn,w=(X,ee)=>v.subVectors(X,ee).normalize(),A=(X,ee)=>Array(X).fill(void 0).map(ee),E=A(t.length/3,(X,ee)=>new Fn().fromArray(t,ee*3).setLength(i)),P=[],M=1e6;for(let X=0;X<E.length;X++){let ee=E[X],re=[],he,xe,ae,ue=1e10,O=-1;for(;(O=e.indexOf(X,O+1))!=-1;){let Te=O-O%3;he=e[Te+(O+1)%3],xe=e[Te+(O+2)%3],ae=ee.distanceToSquared(E[he]),ue=Math.min(ue,ae),re.push([he,xe,ae])}ue+=1e-6;let J=[],we=0,Ee=re.length;for(let Te=0;Te<Ee;Te++){[he,xe,ae]=re[we];let be=P[he]?.includes(X)==!0;ae<=ue&&J.push(he+ +be*M),we=re.findIndex(Ne=>Ne[0]==xe)}P.push(J)}let R=[];{let X=0,ee=0,re,he,xe=f==3;for(let ae=0;ae<=a;ae++){re=ae*(ae+1)/2,he=(ae+1)*(ae+2)/2;for(let ue=0;ue<a-ae;ue++)[X,ee]=[re+ue+ae+2,he+ue+ae+3],R.push(re,he,...xe?[ee,re]:[X,he],ee,X),[re,he]=[X,ee];R.push(re,he,re+a+2)}}let D=0;for(let X=0;X<P.length;X++)for(let ee=0;ee<f;ee++)P[X][ee]<M&&D++;let N=E.length*f*R.length*3,C=D*S*6*3,B=D*2*3*3,_=N+C+B;s=new Float64Array(_),l=new Float64Array(_),c=new Float64Array(_/3*2);let F=(X,ee,re)=>{let he=d/3*2;c[he]=Math.atan2(re,-X)/2/Math.PI+.5,c[he+1]=1-(Math.atan2(-ee,Math.sqrt(X*X+re*re))/Math.PI+.5)},V=X=>{s[d]=X.x,s[d+1]=X.y,s[d+2]=X.z,l[d]=v.x,l[d+1]=v.y,l[d+2]=v.z,F(X.x,X.y,X.z),d+=3},K=X=>{s[d]=X[0].x,s[d+1]=X[0].y,s[d+2]=X[0].z,l[d]=X[1].x,l[d+1]=X[1].y,l[d+2]=X[1].z,F(X[0].x,X[0].y,X[0].z),d+=3},q=(a+2)*(a+3)/2,G=new Float64Array(q*3),W=new Float64Array(q*3),H=new Float64Array(q*2),Z=A(f*2*S,()=>new Fn),te=A(a*Math.max(0,a-1)/2,()=>new Fn),Q=m.clone(),se=m.clone(),oe=m.clone(),ne=m.clone(),de=m.clone(),ve=[],me=A(E.length,()=>A(f,()=>m.clone()));for(let X=0;X<E.length;X++){m.copy(E[X]).normalize(),Q.copy(m).multiplyScalar(x);let ee=P[X];for(let J=0;J<ee.length;J++){let we=ee[J],Ee=ee[(J+1)%f];g.setFromPointsAndIndices(E,X,we%M,Ee%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(Q,me[X][J])}let re=0,he=[],xe=[],ae=new Fn;a==0&&[...me[X]].reduce((J,we)=>J.add(we),ae).multiplyScalar(1/f);for(let J=0;J<f;J++){let we=[],Ee=(J-1+f)%f,Te=me[X][Ee],be=me[X][J];m.copy(Te).sub(Q),y.copy(be).sub(Q);let Ne=Q.angleTo(m),Ae=m.angleTo(y),Re=Math.cos(Ne)*b;a==0?se.copy(ae):se.copy(Q).setLength(x+Re),he.push(Re);let Xe=[se,Te,be];for(let Be=0;Be<2;Be++){let ft=Xe[Be],Ze=Xe[Be+1];ne.subVectors(ft,Q),de.subVectors(Ze,Q),oe.crossVectors(ne,de).normalize();for(let Qa=0;Qa<S;Qa++){let Od=[Ne,Ae][Be]*Qa/S;m.copy(ne).applyAxisAngle(oe,Od).add(Q),Z[re++].copy(m),Be&&(w(m,Q),we.push([Qa==0?ft:m.clone(),v.clone()]))}Be&&(w(Ze,Q),we.push([Ze,v.clone()]))}xe.push(we)}ve.push(xe);let ue=2*S,O=2;for(let J=0;J<f;J++){let we=ue*J,Ee=ue*((J+1)%f),Te=0,be=[Z[we]];for(let Ne=1;Ne<S;Ne++){let Ae=Z[we+Ne],Re=Z[Ee+Ne];be.push(Ae);for(let Xe=1,Be=Ne-O+1;Xe<=Be;Xe++)m.lerpVectors(Ae,Re,Xe/(Be+1)),m.sub(Q).setLength(he[J]).add(Q),be.push(te[Te++].copy(m));be.push(Re)}for(let Ne=0;Ne<S;Ne++)be.push(Z[Ne+S+we]);be.push(Z[Ee+S]);for(let Ne=0,Ae=be.length;Ne<Ae;Ne++){let Re=be[Ne],Xe=Ne*3,Be=Ne*2;G[Xe]=Re.x,G[Xe+1]=Re.y,G[Xe+2]=Re.z,w(Re,Q),W[Xe]=v.x,W[Xe+1]=v.y,W[Xe+2]=v.z,H[Be]=Math.atan2(Re.z,-Re.x)/2/Math.PI+.5,H[Be+1]=1-(Math.atan2(-Re.y,Math.sqrt(Re.x*Re.x+Re.z*Re.z))/Math.PI+.5)}for(let Ne=0,Ae=R.length;Ne<Ae;Ne++){let Re=R[Ne]*3,Xe=R[Ne]*2,Be=d/3*2;s[d]=G[Re],s[d+1]=G[Re+1],s[d+2]=G[Re+2],l[d]=W[Re],l[d+1]=W[Re+1],l[d+2]=W[Re+2],c[Be]=H[Xe],c[Be+1]=H[Xe+1],d+=3}}}let ce=[];for(let X=0;X<P.length;X++)for(let ee=0;ee<f;ee++){let re=P[X][ee];if(re<M){let he=P[re].findIndex(ue=>ue%M==X),xe=ve[X][ee],ae=ve[re][he];for(let ue=0;ue<S;ue++){let O=xe[ue],J=ae[S-ue],we=xe[ue+1],Ee=ae[S-(ue+1)];K(O),K(J),K(we),K(we),K(J),K(Ee)}ce.push(xe[0][0],ae[S][0],xe[S][0],ae[0][0])}}for(;ce.length;){let X,ee,re,[he,xe]=ce.splice(0,2);X=xe;let ae=[he];for(;he!=X;)ae.push(X),ee=ce.indexOf(X),re=ee%2,X=ce.splice(ee-re,2)[1-re];v.subVectors(ae[0],ae[1]).cross(m.subVectors(ae[0],ae[2])).normalize();let ue=v.dot(ae[0])<0;ue&&v.negate();for(let O=1;O<=ae.length-2;O++)V(ae[O+ +ue]),V(ae[O+1-+ue]),V(ae[0])}}function p(){let h=new Fn,f=new Fn,m=new Fn,y=new Fn,g=new wx,b=new wx,x=new wx,S=(A,E,P,M)=>{M<0&&A.x===1&&(c[E]=A.x-1),P.x===0&&P.z===0&&(c[E]=M/2/Math.PI+.5)};for(let A=0,E=0;A<d;A+=9,E+=6){h.set(s[A+0],s[A+1],s[A+2]),f.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(c[E+0],c[E+1]),b.set(c[E+2],c[E+3]),x.set(c[E+4],c[E+5]),y.copy(h).add(f).add(m).divideScalar(3);let P=w(y);S(g,E+0,h,P),S(b,E+2,f,P),S(x,E+4,m,P)}let v=d/3*2;for(let A=0;A<v;A+=6){let E=c[A+0],P=c[A+2],M=c[A+4],R=Math.max(E,P,M),D=Math.min(E,P,M);R>.9&&D<.1&&(E<.2&&(c[A+0]+=1),P<.2&&(c[A+2]+=1),M<.2&&(c[A+4]+=1))}function w(A){return Math.atan2(A.z,-A.x)}}}static fromJSON(t){return new va(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as nk}from"three";var DT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:a}=n.parameters,s=i===0&&o!==0?new fu(t*.5,o,a):new nk(t*.5,i),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},fu=class extends va{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=1/i,a=[-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,-o,-i,0,-o,i,0,o,-i,0,o,i,-o,-i,0,-o,i,0,o,-i,0,o,i,0,-i,0,-o,i,0,-o,-i,0,o,i,0,o],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new fu(t.radius,t.corner,t.cornerSides)}};import{Plane as mk,Shape as qT,Vector2 as Do,Vector3 as yk,MathUtils as Ox,LineCurve as gu,QuadraticBezierCurve as XT,CubicBezierCurve as Yf}from"three";import{CubicBezierCurve as Wf,EllipseCurve as ok,LineCurve as qf,LineCurve3 as ak,MathUtils as sk,QuadraticBezierCurve as Ex,SplineCurve as lk,Vector2 as Wr,Vector3 as NT}from"three";var mu=1e-12,Hl=class{constructor(t){this.position=new Wr;this.startPosition=new Wr;this.uuid=sk.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Hl(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Wl=class extends Hl{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Wl(this.parent).copy(this)}},cn=class extends Hl{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Wl(this),new Wl(this))}static create(e,r){let i=new cn(e,new Wr(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let i=0,o=this.controls.length;i<o;i++){let a=this.controls[i];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.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 cn(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Wr,r=new Wr){let[i,o]=this.computeTangents();return i&&o&&(RT(i,e),RT(o,r)),[e,r]}computeTangent(e=new Wr){let[r,i]=this.computeTangents();return r&&i&&e.copy(r).add(i).normalize(),e}computeNormal(e=new Wr){let[r,i]=this.computeNormals();return e.copy(r).add(i).normalize(),e}};function RT(n,t=new Wr){let e=n.length();return t.set(-n.y/e,n.x/e)}var Cx=n=>n,ql=new Wr,Xf=new Wr,ck=new Wr,dk=new Wr,uk=new Wr,pk=new Wr,LT=new NT,_T=new NT;function FT(n){let t=new Wr;t.addVectors(n.v0,ql.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Wr;return e.addVectors(n.v2,Xf.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Wf(n.v0,t,e,n.v2)}function yu(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function hk(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function fk(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Tx(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-o*o)/(2*i*r))}function kT(n,t,e){return BT(n,t)&&BT(t,e)&&Ax(n.position,t.position,e.position)}function Ax(n,t,e){return ql.copy(t).sub(n).cross(Xf.copy(e).sub(n))===0}function VT(n,t,e,r,i){let o=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(n.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-n.x)/o;return r.set(s+l,a+c),i.set(s-l,a-c),[r,i]}function GT(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function UT(n,t,e,r,i,o){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,c=e.y-n.y,d=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),u;return Tx(t,n,e)>Math.PI&&(d*=-1),yu(c,s)?u=(s+c)*(r/d-.5)*8/3/(a-l):u=(a+l)*(r/d-.5)*8/3/(c-s),i.set(t.x-u*s,t.y+u*a),o.set(e.x+u*c,e.y-u*l),[i,o]}function Px(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function BT(n,t){return Ax(n.position,n.controls[1].position,t.position)&&Ax(n.position,t.controls[0].position,t.position)}function zT(n,t,e,r,i=.5){let o=ql.subVectors(t,n).multiplyScalar(i).add(n),a=Xf.subVectors(e,t).multiplyScalar(i).add(t),s=ck.subVectors(r,e).multiplyScalar(i).add(e),l=o,c=dk.subVectors(a,o).multiplyScalar(i).add(o),d=uk.subVectors(s,a).multiplyScalar(i).add(a),u=s,p=pk.subVectors(d,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,p.x,p.y,d.x,d.y,u.x,u.y,r.x,r.y]}function jT(n,t,e=12,r=!0){let i=_T.set(0,0,0),o,a=0,s=[];for(let l=0;l<t.length;l++){let c=Cx(t[l]),d=ql,u=ba(c,e);s.push(u);for(let p=0;p<=u;p++)if(c instanceof Wf||c instanceof Ex||c instanceof qf){if(c.getPoint(p/u,d),i.set(d.x,d.y,0),o!==void 0&&fk(o,i))continue;o===void 0&&(o=LT),o.copy(i),n.setXYZ(a,i.x,i.y,i.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function HT(n,t,e,r=12,i=!0){let o=_T.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,d=Cx(t[l]),u=ql,p=ba(d,r);s.push(p);for(let h=0;h<=p;h++)if(d instanceof Wf||d instanceof Ex||d instanceof qf){if(d.getPoint(h/p,u),o.set(u.x,u.y,0),c?.equals(o))continue;c===void 0?c=LT:(n.setXYZ(a,c.x,c.y,c.z),a++,n.setXYZ(a,o.x,o.y,o.z),a++),c.copy(o)}}return i&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Mx(n,t=12,e=!1){let r=[];for(let i=0,o=n.length;i<o;i++){let a=n[i],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=ba(a.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=ba(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=ba(n[0].roundedCurveCorner,t)*.5),r}function ba(n,t=12){return n&&n instanceof ok?t*2:n&&(n instanceof qf||n instanceof ak)?1:n&&n instanceof lk?t*n.points.length:t}function WT(n,t,e=12,r=!0){let i,o=0;for(let a=0;a<t.length;a++){let s=Cx(t[a]),l=ba(s,e),c=ql;for(let d=0;d<=l;d++)if(s instanceof Wf||s instanceof Ex||s instanceof qf){if(s.getPoint(d/l,c),i!==void 0&&hk(i,c,mu))continue;i===void 0&&(i=Xf),i.copy(c),n.push(c.x,c.y),o++}}return yu(n[0],n[n.length-2],mu)&&yu(n[1],n[n.length-1],mu)&&(n.pop(),n.pop()),r&&o>1&&!(yu(n[o-1],n[1],mu)&&yu(n[o-2],n[0],mu))&&(n.push(n[0],n[1]),o++),n}var Ix=new Do,gk=new Do,vk=new Do,bk=new Do,xk=new Do,Sk=new Do,st=class extends qT{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new mk(new yk(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=Ox.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let o=new st;return o.isClosed=e.isClosed,o.points=e.points.map(a=>cn.create(a.id,a.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(a=>st.createFromState(a)),r!==void 0&&i!==void 0&&o.applySize(r,i),o.update(),o}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 r=0,i=this.points.length;r<i;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,i=this.points.findIndex(o=>o.uuid===e);if(i<0){let o=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,d=l.getPointIndexById(e);if(d<0)o+=c;else return d+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 r=this.points.length;for(let i=0,o=this.shapeHoles.length;i<o;i++){let a=this.shapeHoles[i],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,o=this.shapeHoles.length;i<o;i++){let a=this.shapeHoles[i],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let i=Ix.set(e,r);for(let o=0,a=this.points.length;o<a;o++){let s=this.points[o];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let o=0,a=this.shapeHoles.length;o<a;o++)this.shapeHoles[o].applyScale(e,r);this._update()}createPoint(e,r=0,i=Ox.generateUUID()){let o;e instanceof Do?o=e:o=new Do(e,r);let a=new cn(i,o);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,i=this.points.length;r<i;r++){let o=this.points[r];if(o.uuid===e)return o}for(let r=0,i=this.shapeHoles.length;r<i;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(i=>i.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=i?this.roundedCurveDivisions:this.curveDivisions;return jT(e,i?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Mx(this.points,e,!1),this.roundedCurveDivisions=Mx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return HT(e,this.curves,r,i,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),WT(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=ba(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let d=o[l];if(s<i+d)return[l,(s-i+1)/d];i+=d}return[0,1]}getCurveT(e,r,i){let o=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Px(o,a)){let u=o.position.distanceTo(a.position);return o.position.distanceTo(Ix.set(i.x,i.y))/u}let c=0;for(let u=0;u<e;u++)c+=s[u];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){Px(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.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,r.curveAfter=i;let o=i.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,i=this.points.length;r<i;r++){let o=this.points[r];if(r===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(o,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(r,i)}if(this.points.length>2){let r=0;for(let i=0,o=this.points.length;i<o;i++){let a=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],c=a.roundness,d=s&&l&&kT(s,a,l);if(!a.controlsMoved()&&c>0&&!d){let u=a.curveBefore,p=a.curveAfter;if(u===void 0||p===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=u instanceof gu?u.v1.distanceTo(u.v2):u.getLength(),y=p instanceof gu?p.v1.distanceTo(p.v2):p.getLength(),g=Math.min(c,m*.499),b=Math.min(c,y*.499),x=Math.min(g,b),S=1-x/m,v=x/y,w=u.getPointAt(S,Ix),A=p.getPointAt(v,gk);this._subSplitCurve(u,h,S,w,void 0),this._subSplitCurve(p,f,v,void 0,A);let E;if(this.useCubicForRoundedCorners){let P=Tx(w,a.position,A)/2,M=Math.tan(P)*w.distanceTo(a.position),[R,D]=VT(w,A,M,vk,bk),N=GT(R,D,a.position),[C,B]=UT(N,w,A,M,xk,Sk);E=new Yf(w.clone(),C.clone(),B.clone(),A.clone())}else E=new XT(w.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=E,this.roundedCurves.splice(i+r,0,E),r++}}}}_subSplitCurve(e,r,i,o,a){if(e instanceof gu)o!==void 0&&r.v2.copy(o),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(i,0),d=zT(s.v0,s.v1,s.v2,s.v3,c);return o!==void 0&&(l.v0.set(d[0],d[1]),l.v1.set(d[2],d[3]),l.v2.set(d[4],d[5]),l.v3.set(d[6],d[7])),a!==void 0&&(l.v0.set(d[6],d[7]),l.v1.set(d[8],d[9]),l.v2.set(d[10],d[11]),l.v3.set(d[12],d[13])),l}return r}clone(){let e=new st(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let i=0;i<r;i++){let o=i*7,a=e.points[o+0],s=e.points[o+1],l=e.points[o+2],c=e.points[o+3],d=e.points[o+4],u=e.points[o+5],p=e.points[o+6],h=new cn(Ox.generateUUID(),new Do(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(d,u),h.roundness=p,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let o=new st;return o.fromJSON(i),o}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let i=(a,s)=>{s instanceof Yf&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},o=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof XT&&(a[l]=FT(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],h=l>0?a[l-1]:null,f;p instanceof Yf?(f=this.createPoint(p.v0),f.controls[1].position.copy(p.v1)):p instanceof gu&&(f=this.createPoint(p.v1)),f!==void 0&&(h!==null&&i(f,h),s.push(f))}let d=a[a.length-1],u=!1;return d instanceof Yf?d.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(d.v2),u=!0):d instanceof gu&&d.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=o(e.curves),e instanceof qT&&(this.shapeHoles=e.holes.map(a=>{let s=new st;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let i=this.getPointByUuid(e);i&&(r.position!==void 0&&i.position.fromArray(r.position),r.roundness!==void 0&&(i.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let o=this.getPointByUuid(e)?.controls[0];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let o=this.getPointByUuid(e)?.controls[1];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}};var Rx=Math.PI*2;function Dx({x:n,y:t},e,r,i,o){return{x:n*e+i,y:t*r+o}}function wk(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),o=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:o+a*e,y:a-o*e},{x:o,y:a}]}function YT(n,t,e,r){let i=n*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(o)}function Ak(n,t,e,r,i,o,a,s,l,c){let d=Math.pow(i,2),u=Math.pow(o,2),p=Math.pow(a,2),h=Math.pow(s,2),f=d*u-d*h-u*p;f<0&&(f=0),f/=d*h+u*p,f=Math.sqrt(f)*(l===c?-1:1);let m=f*i/o*s,y=f*-o/i*a,g=m+(n+e)/2,b=y+(t+r)/2,x=(a-m)/i,S=(s-y)/o,v=(-a-m)/i,w=(-s-y)/o,A=YT(1,0,x,S),E=YT(x,S,v,w);return!c&&E>0&&(E-=Rx),c&&E<0&&(E+=Rx),{centerx:g,centery:b,ang1:A,ang2:E}}function QT({px:n,py:t,cx:e,cy:r,rx:i,ry:o,largeArcFlag:a,sweepFlag:s}){let l=[];if(i===0||o===0)return[];let c=(n-e)/2,d=(t-r)/2;if(c===0&&d===0)return[];i=Math.abs(i),o=Math.abs(o);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(d,2)/Math.pow(o,2);u>1&&(i*=Math.sqrt(u),o*=Math.sqrt(u));let p=Ak(n,t,e,r,i,o,c,d,a,s),{ang1:h,ang2:f}=p,{centerx:m,centery:y}=p,g=Math.abs(f)/(Rx/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);f/=b;for(let x=0;x<b;x++)l.push(wk(h,f)),h+=f;return l.map(x=>{let{x:S,y:v}=Dx(x[0],i,o,m,y),{x:w,y:A}=Dx(x[1],i,o,m,y),{x:E,y:P}=Dx(x[2],i,o,m,y);return{x1:S,y1:v,x2:w,y2:A,x:E,y:P}})}import{BufferAttribute as $f,BufferGeometry as Nk}from"three";var rt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(rt||(rt={}));var Xt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Xt||(Xt={}));function _e(n,t){if(!n)throw t||"Assertion Failed!"}var Ie=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){_e(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?i<o?e.t-t.t+(t.t-r.t)*(i/(i+o)):e.t-r.t+(r.t-t.t)*(o/(i+o)):0},n.edgeSign=function(t,e,r){_e(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?(e.t-r.t)*i+(e.t-t.t)*o:0},n.transEval=function(t,e,r){_e(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?i<o?e.s-t.s+(t.s-r.s)*(i/(i+o)):e.s-r.s+(r.s-t.s)*(o/(i+o)):0},n.transSign=function(t,e,r){_e(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?(e.s-r.s)*i+(e.s-t.s)*o:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,o){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,i),a+s<0&&(a=-a,s=-s),o.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,i,e),a+s<0&&(a=-a,s=-s),o.s=n.interpolate(a,r.s,s,i.s)):o.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(a=n.transEval(t,r,e),s=n.transEval(r,e,i),a+s<0&&(a=-a,s=-s),o.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,i,e),a+s<0&&(a=-a,s=-s),o.t=n.interpolate(a,r.t,s,i.t)):o.t=(r.t+e.t)/2},n}(),vu=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Qf=function(){function n(t){this.side=t,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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Xl=function(){function n(){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}return n}(),KT=function(){function n(){var t=new Xl,e=new vu,r=new Qf(0),i=new Qf(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Qf(0),r=new Qf(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;_e(i,"Vertex can't be null!");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e;var a=e;do a.Org=i,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;_e(i,"Face can't be null");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var a=e;do a.Lface=i,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},n.prototype.makeEdge=function(){var t=new Xl,e=new Xl,r=new vu,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var o=new Xl;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var a=new vu;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var i=new vu;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Xl;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),o=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(o,e),i.Org=t.Dst,o.Org=e.Org,i.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var a=new vu;this.makeFace_(a,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,o,a,s;i=e.Lnext;do r=i,i=r.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)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,o,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;i=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),s+l-2<=t&&Ie.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&Ie.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(i=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===a);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,o,a,s,l,c;for(o=t,o=t;(i=o.next)!==t;o=i){_e(i.prev===o),l=i.anEdge;do _e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l),_e(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(_e(i.prev===o&&i.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){_e(a.prev===s),l=a.anEdge;do _e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l),_e(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(_e(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)_e(l.Sym.next===c.Sym),_e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Org!==null),_e(l.Dst!==null),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l);_e(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),ZT=function(){function n(){this.handle=null}return n}(),JT=function(){function n(){this.key=null,this.node=0}return n}(),Ek=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new ZT,this.handles[r]=new JT;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,o,a;for(i=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,_e(a<=this.max),o=e[a].handle,a>this.size||this.leq(r[i].key,r[o].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,o,a;for(i=e[t].handle;;){if(a=t>>1,o=e[a].handle,a===0||this.leq(r[o].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,o;for(o=this.nodes.length,this.nodes.length=this.max+1,i=o;i<this.nodes.length;i++)this.nodes[i]=new ZT;for(o=this.handles.length,this.handles.length=this.max+1,i=o;i<this.handles.length;i++)this.handles[i]=new JT}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;_e(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),Bx=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),$T=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),Ck=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new $T,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new $T;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),Tk=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,o=e.eUp,a=r.eUp;if(o.Dst===i)return a.Dst===i?Ie.vertLeq(o.Org,a.Org)?Ie.edgeSign(a.Dst,o.Org,a.Org)<=0:Ie.edgeSign(o.Dst,a.Org,o.Org)>=0:Ie.edgeSign(a.Dst,i,a.Org)<=0;if(a.Dst===i)return Ie.edgeSign(o.Dst,i,o.Org)>=0;var s=Ie.edgeEval(o.Dst,i,o.Org),l=Ie.edgeEval(a.Dst,i,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&_e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){_e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new Bx;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case rt.ODD:return(e&1)!==0;case rt.NONZERO:return e!==0;case rt.POSITIVE:return e>0;case rt.NEGATIVE:return e<0;case rt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,o=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,o=n.regionBelow(a),i=o.eUp,i.Org!=s.Org){if(!o.fixUpperEdge){n.finishRegion(t,a);break}i=t.mesh.connect(s.Lprev,i.Sym),n.fixUpperEdge(t,o,i)}s.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(s,i)),n.finishRegion(t,a),s=o.eUp,a=o}return s},n.addRightEdges=function(t,e,r,i,o,a){var s,l,c,d,u=!0;c=r;do _e(Ie.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(o===null&&(o=n.regionBelow(e).eUp.Rprev),l=e,d=o;s=n.regionBelow(l),c=s.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(d.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!u&&n.checkForRightSplice(t,l)&&(n.addWinding(c,d),n.deleteRegion(t,l),t.mesh.delete(d)),u=!1,l=s,d=c;l.dirty=!0,_e(l.windingNumber-c.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=Ie.vertL1dist(e,t),o=Ie.vertL1dist(r,t),a=.5*o/(i+o),s=.5*i/(i+o);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},n.getIntersectData=function(t,e,r,i,o,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,o,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp;if(Ie.vertLeq(i.Org,o.Org)){if(Ie.edgeSign(o.Dst,i.Org,o.Org)>0)return!1;Ie.vertEq(i.Org,o.Org)?i.Org!==o.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,o.Oprev,i)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(i,o.Oprev),e.dirty=r.dirty=!0)}else{if(Ie.edgeSign(i.Dst,o.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,a;if(_e(!Ie.vertEq(i.Dst,o.Dst)),Ie.vertLeq(i.Dst,o.Dst)){if(Ie.edgeSign(i.Dst,o.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Sym,a),a.Lface.inside=e.inside}else{if(Ie.edgeSign(o.Dst,i.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Lnext,o.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,a=i.Org,s=o.Org,l=i.Dst,c=o.Dst,d,u,p=new Xl,h,f;if(_e(!Ie.vertEq(c,l)),_e(Ie.edgeSign(l,t.event,a)<=0),_e(Ie.edgeSign(c,t.event,s)>=0),_e(a!==t.event&&s!==t.event),_e(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(d=Math.min(a.t,l.t),u=Math.max(s.t,c.t),d>u))return!1;if(Ie.vertLeq(a,s)){if(Ie.edgeSign(c,a,s)>0)return!1}else if(Ie.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),Ie.intersect(l,a,c,s,p),_e(Math.min(a.t,l.t)<=p.t),_e(p.t<=Math.max(s.t,c.t)),_e(Math.min(c.s,l.s)<=p.s),_e(p.s<=Math.max(s.s,a.s)),Ie.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),h=Ie.vertLeq(a,s)?a:s,Ie.vertLeq(h,p)&&(p.s=h.s,p.t=h.t),Ie.vertEq(p,a)||Ie.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!Ie.vertEq(l,t.event)&&Ie.edgeSign(l,t.event,p)>=0||!Ie.vertEq(c,t.event)&&Ie.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Lnext,o.Oprev),r=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,o.Onext,i.Rprev,f,!0),!0):(Ie.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),Ie.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,i),i.Org.s=p.s,i.Org.t=p.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,a,l,s,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,o;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,o=r.eUp,i.Dst!==o.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(o),r=n.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==o.Org)if(i.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||o.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===o.Org&&i.Dst===o.Dst&&(n.addWinding(o,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,o=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),Ie.vertEq(s.Org,t.event)&&(t.mesh.splice(o.Oprev,s),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),c=!0),Ie.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),c=!0),c){n.addRightEdges(t,e,r.Onext,o,o,!0);return}Ie.vertLeq(l.Org,s.Org)?i=l.Oprev:i=s,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,o,a,s,l;if(i=e.eUp,Ie.vertEq(i.Org,r)){_e(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!Ie.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}_e(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,o=s=a.Onext,l.fixUpperEdge&&(_e(o!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=o.Oprev),t.mesh.splice(r.anEdge,a),Ie.edgeGoesLeft(o)||(o=null),n.addRightEdges(t,e,a.Onext,s,o,!0)},n.connectLeftVertex=function(t,e){var r,i,o,a,s,l,c=new Bx;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(a=r.eUp,s=i.eUp,Ie.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(o=Ie.vertLeq(s.Dst,a.Dst)?r:i,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(s.Dnext,e.anEdge);l=d.Sym}o.fixUpperEdge?n.fixUpperEdge(t,o,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);_e(i!==null);var o=n.regionBelow(i),a=o.eUp,s=n.finishLeftRegions(t,o,null);s.Onext===a?n.connectRightVertex(t,i,s):n.addRightEdges(t,i,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,i){var o=new Bx,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=i,a.Dst.s=e,a.Dst.t=i,t.event=a.Dst,o.eUp=a,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},n.initEdgeDict=function(t){t.dict=new Ck(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,o=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,i,o,a),n.addSentinel(t,i,o,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(_e(e.fixUpperEdge),_e(++r===1)),_e(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,i=e.Lnext,Ie.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,o=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)o++;for(o+=8,e=t.pq=new Ek(o,Ie.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,o;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,o=r.anEdge,_e(o.Lnext!==o),o.Lnext.Lnext===o&&(n.addWinding(o.Onext,o),t.mesh.delete(o));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!Ie.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),Pk=function(){function n(){this.mesh=new KT,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=rt.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,i,o,a,s,l=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)o=e.coords[y],c[y]=o,f[y]=e,l[y]=o,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)o=e.coords[g],o<c[g]&&(c[g]=o,f[g]=e),o>l[g]&&(l[g]=o,h[g]=e);var b=0;if(l[1]-c[1]>l[0]-c[0]&&(b=1),l[2]-c[2]>l[b]-c[b]&&(b=2),c[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=f[b],i=h[b],d[0]=r.coords[0]-i.coords[0],d[1]=r.coords[1]-i.coords[1],d[2]=r.coords[2]-i.coords[2],e=m.next;e!==m;e=e.next)u[0]=e.coords[0]-i.coords[0],u[1]=e.coords[1]-i.coords[1],u[2]=e.coords[2]-i.coords[2],p[0]=d[1]*u[2]-d[2]*u[1],p[1]=d[2]*u[0]-d[0]*u[2],p[2]=d[0]*u[1]-d[1]*u[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,o=0,a=t.next;a!==t;a=a.next)if(i=a.anEdge,!(i.winding<=0))do o+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==a.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,o=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),o=!0),r=this.sUnit,i=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,i[a]=0,i[(a+1)%3]=0,i[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,i);o&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ie.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ie.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var o=void 0;r.Lnext!==i;)if(Ie.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(Ie.edgeGoesLeft(i.Lnext)||Ie.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)o=t.connect(i.Lnext,i),i=o.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(Ie.edgeGoesRight(r.Lprev)||Ie.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)o=t.connect(i.Lnext,i),i=o.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,o=t.eHead.next;o!==t.eHead;o=i)i=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var o,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=s,s++),l++,o=o.Lnext}while(o!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,e===Xt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*i,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;this.elements[p++]=c.n,l++,o=o.Lnext}while(o!==d.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1;if(e===Xt.CONNECTED_POLYGONS){o=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==d.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,o=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){i=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;o=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,i=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==i);this.elements[d++]=o,this.elements[d++]=a,o+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new KT),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,o,a){if(t===void 0&&(t=rt.ODD),e===void 0&&(e=Xt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),Tk.computeInterior(this,a);var s=this.mesh;return e===Xt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===Xt.BOUNDARY_CONTOURS?this.outputContours_(s,i):this.outputPolymesh_(s,e,r,i),!0},n}();function dn(n){var t=n.windingRule,e=t===void 0?rt.ODD:t,r=n.elementType,i=r===void 0?Xt.POLYGONS:r,o=n.polySize,a=o===void 0?3:o,s=n.vertexSize,l=s===void 0?2:s,c=n.normal,d=c===void 0?[0,0,1]:c,u=n.contours,p=u===void 0?[]:u,h=n.strict,f=h===void 0?!0:h,m=n.debug,y=m===void 0?!1:m;if(!p&&f)throw new Error("Contours can't be empty");if(!!p){var g=new Pk;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,i,a,l,d,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var Dee=rt.ODD,Ree=rt.NONZERO,Bee=rt.POSITIVE,Nee=rt.NEGATIVE,Lee=rt.ABS_GEQ_TWO,_ee=Xt.POLYGONS,Fee=Xt.CONNECTED_POLYGONS,kee=Xt.BOUNDARY_CONTOURS;import{Box2 as Dk,BufferAttribute as Jf,BufferGeometry as Rk,Vector2 as Bk}from"three";var Kf=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Kf.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Kf.eSize,i=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(i,a*o,3*t);a+=3*t;let l=new Float32Array(i,a*o,3*t);a+=3*t;let c=new Float32Array(i,a*o,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=i,this.positions=s,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},bu=Kf;bu.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var xu=class{constructor(t=[],e=(r,i)=>r<i?-1:r>i?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let o=t-1>>1,a=e[o];if(r(i,a)>=0)break;e[t]=a,t=o}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,o=e[t];for(;t<i;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],o)>=0)break;e[t]=e[a],t=a}e[t]=o}};function Nx(n,t,e=1,r=!1){let i=1/0,o=1/0,a=-1/0,s=-1/0;for(let[b,x]of n[0])b<i&&(i=b),x<o&&(o=x),b>a&&(a=b),x>s&&(s=x);let l=a-i,c=s-o,d=Math.max(e,Math.min(l,c));if(d===e){let b=[i,o];return b.distance=0,b.distance}let u=new xu([],(b,x)=>x.max-b.max),p=Ok(n),h=new Zf(i+l/2,o+c/2,0,n);h.d>p.d&&(p=h);let f=2;function m(b,x,S){let v=new Zf(b,x,S,n);if(f++,v.max>p.d+e&&u.push(v),v.d>p.d&&(p=v,r&&console.log(`found best ${Math.round(1e4*v.d)/1e4} after ${f} probes`),p.d>t))return t}let y=d/2;for(let b=i;b<a;b+=d)for(let x=o;x<s;x+=d)m(b+y,x+y,y);for(;u.length;){let{max:b,x,y:S,h:v}=u.pop();if(b-p.d<=e)break;y=v/2,m(x-y,S-y,y),m(x+y,S-y,y),m(x-y,S+y,y),m(x+y,S+y,y)}r&&console.log(`num probes: ${f}
727
727
  best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}function Zf(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=Mk(n,t,r),this.max=this.d+this.h*Math.SQRT2}function Mk(n,t,e){let r=!1,i=1/0;for(let o of e)for(let a=0,s=o.length,l=s-1;a<s;l=a++){let c=o[a],d=o[l];c[1]>t!=d[1]>t&&n<(d[0]-c[0])*(t-c[1])/(d[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,Ik(n,t,c,d))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function Ok(n){let t=0,e=0,r=0,i=n[0];for(let a=0,s=i.length,l=s-1;a<s;l=a++){let c=i[a],d=i[l],u=c[0]*d[1]-d[0]*c[1];e+=(c[0]+d[0])*u,r+=(c[1]+d[1])*u,t+=u*3}let o=new Zf(e/t,r/t,0,n);return t===0||o.d<0?new Zf(i[0][0],i[0][1],0,n):o}function Ik(n,t,e,r){let i=e[0],o=e[1],a=r[0]-i,s=r[1]-o;if(a!==0||s!==0){let l=((n-i)*a+(t-o)*s)/(a*a+s*s);l>1?(i=r[0],o=r[1]):l>0&&(i+=a*l,o+=s*l)}return a=n-i,s=t-o,a*a+s*s}var Su={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},_x={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Fx={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},Lx=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),xa=class extends Rk{constructor(e,r,i=0,o=12,a=3,s=rt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=o,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],o),d=this._shape.shapeHoles.map(R=>{let D=R.extractShapePointsToFlatArray([],o),N=[];for(let C=D.length-1;C>=1;C-=2){let B=D[C-1],_=D[C-0];N.push(B,_)}return N}),u=[],p=[];for(let R=0;R<c.length;R+=2)p.push([c[R],c[R+1]]);u.push(p);for(let R=0;R<d.length;R++){let D=d[R],N=[];for(let C=0;C<D.length;C+=2)N.push([D[C],D[C+1]]);u.push(N)}let h;e.isText?h=new Dk().setFromPoints(e.points.map(D=>D.position)).getSize(new Bk).length()*.1:u[0].length===0?h=i:i>0?h=Nx(u,i):h=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,h,r/2),this._bevelSegments=Math.floor(a));let f;try{f=dn({windingRule:s,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=Su}let m;try{m=dn({windingRule:rt.ODD,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...d]})}catch{m=_x}if(!f)throw new Error("error generating geometry");let y=f.elementCount;if(m){f.elementCount+=m.elementCount;for(let R=0;R<m.elements.length;R++){let D=m.elements[R],N=R%2===0?f.vertexCount:0;f.elements.push(D+N)}for(let R=0;R<m.vertexIndices.length;R++){let D=m.vertexIndices[R],N=f.vertexCount;f.vertexIndices.push(D+N)}for(let R=0;R<m.vertices.length;R++){let D=m.vertices[R];f.vertices.push(D)}}let g=1/0,b=-1/0,x=1/0,S=-1/0;for(let R=0,D=f.vertexCount;R<D;R++){let N=R*2,C=f.vertices[N+0],B=f.vertices[N+1];C<g&&(g=C),C>b&&(b=C),B<x&&(x=B),B>S&&(S=B)}this._minX=g,this._minY=x,this._width=b-g,this._height=S-x,this._buffer=new bu(this._computeBufferEstimatedSize(f));let v=[],w=[];for(let R=f.elementCount-1;R>=0;R--){let D=R>=y,N=R*2,C=f.elements[N+0],B=f.elements[N+1],_=C+B,F={start:C,count:B,normals:[],continuous:[],concave:[]},V=C,K=_-1,q=C+1,G=this._shape.roundedCurves.length;do{let Q=V-C,se=f.vertices[K*2+0],oe=f.vertices[K*2+1],ne=f.vertices[V*2+0],de=f.vertices[V*2+1],ve=f.vertices[q*2+0],me=f.vertices[q*2+1],ce=ne-se,X=de-oe,ee=Math.sqrt(ce*ce+X*X);ce/=ee,X/=ee;let re=ne-ve,he=de-me,xe=Math.sqrt(re*re+he*he);re/=xe,he/=xe,F.normals[Q*2+0]=-he,F.normals[Q*2+1]=re,F.concave[Q]=ce*he-X*re>0;let ae=f.vertexIndices[V];if(Array.isArray(ae))F.continuous[Q]=!1;else{let[ue,O]=this._shape.getCurveIndexFromVertexId(ae-1,!0);if(O>0&&O<1)F.continuous[Q]=!0;else{let J=O===1?ue+1:ue-1;J=(J+G)%G;let we=O===1?0:1,Ee=this._shape.roundedCurves[ue].getTangent(O),Te=this._shape.roundedCurves[J].getTangent(we);F.continuous[Q]=Ee.dot(Te)>.95}}D&&(F.normals[Q*2+0]*=-1,F.normals[Q*2+1]*=-1),[K,V,q]=[V,q,q+1],q>=_&&(q-=B)}while(q!==C+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(C*2,_*2),vertexCount:B,vertexIndices:new Array(B).fill(!0).map((Q,se)=>[se,se]),elements:[0,B],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(C*2,_*2)});let H=0;for(let Q=1;Q<=this._bevelSegments;Q++){let se=Q/this._bevelSegments*Math.PI/2,oe=(1-Math.cos(se))*this._bevel,ne=[],de=[],ve=[],me=[],ce=0;for(let ee=0;ee<B;ee++){let re=ee*2,he=(ee-1+B)%B*2,xe=f.vertices[F.start*2+re+0],ae=f.vertices[F.start*2+re+1],ue=-F.normals[he+0]*oe,O=-F.normals[he+1]*oe,J=-F.normals[re+0]*oe,we=-F.normals[re+1]*oe;if(F.concave[ee]||!F.concave[ee]&&D){let Ee=Math.atan2(O,ue),Te=Math.atan2(we,J);Te>Ee&&(Te-=Math.PI*2);let be=Te-Ee;if(F.continuous[ee]||D){let Ne=Ee+be/2,Ae=Math.cos(Ne)*oe,Re=Math.sin(Ne)*oe;ne[2*ce+0]=xe+Ae*(D?-1:1),ne[2*ce+1]=ae+Re*(D?-1:1),me[ce]=ee,ce++}else{let Ne=Math.max(1,Math.floor(o/4*Math.abs(be)/Math.PI));for(let Ae=0;Ae<=Ne;Ae++){let Re=Ee+be*(Ae/Ne),Xe=Math.cos(Re)*oe,Be=Math.sin(Re)*oe;ne[2*ce+0]=xe+Xe,ne[2*ce+1]=ae+Be,me[ce]=ee,ce++}}}else ne[2*ce+0]=xe+ue,ne[2*ce+1]=ae+O,me[ce]=ee,de[ee]=ce,ce++,ne[2*ce+0]=xe,ne[2*ce+1]=ae,me[ce]=ee,ce++,ne[2*ce+0]=xe+J,ne[2*ce+1]=ae+we,me[ce]=ee,ve[ee]=ce,ce++}let X=dn({windingRule:rt.POSITIVE,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ne],edgeCreateCallback:ee=>{let he=ee.Org.idx,xe=me[he],ae=me[(he+1)%me.length];ee.idx=[xe,ae],ee.Sym.idx=[ae,xe]},vertexIdCallback:ee=>{let re=ee.Lprev.idx;return[re?re[1]:0,ee.idx?ee.idx[0]:0]}});if(!X)throw console.log("Error"),new Error(`error generating bevel geometry for ${Q}'th loop`);if(!X.vertexCount){let ee=(Q-1)/this._bevelSegments*Math.PI/2;H=(1-Math.sin(ee))*this._bevel;break}for(let ee=0;ee<X.vertexIndices.length;ee++){let[re,he]=X.vertexIndices[ee];if(re===he)continue;let xe=he;he<re&&(xe+=B);for(let ae=re;ae<xe;ae++){let ue=ae%B,O=(ae+1)%B;if(!F.continuous[ue]||!F.continuous[O]){X.vertexIndices[ee]=[re,ue],X.vertexIndices.splice(ee+1,0,[O,he]),X.vertices.splice((ee+1)*2,0,X.vertices[ee*2],X.vertices[ee*2+1]);break}}}W.push({bevelI:Q,angle:se,size:oe,boundary:X,reverseMap:me,insetPoints:ne})}let Z=(Q,se,oe)=>{let ne=0,de=Q.boundary.vertexIndices.length;for(;ne<de&&oe(Q.boundary.vertexIndices[se]);)se=(se+1)%de,ne++;return ne},te=v.length;for(let Q=1;Q<W.length;Q++){let se=W[Q-1],oe=W[Q],ne=se.boundary.vertexIndices.length,de=oe.boundary.vertexIndices.length;if(!ne||!de)break;let ve=F.concave.length,me=0,ce=Lx(me,B);for(;!se.boundary.vertexIndices.filter(ce).length||!oe.boundary.vertexIndices.filter(ce).length;)me++,ce=Lx(me,B);let X=se.boundary.vertexIndices.findIndex(ce),ee=oe.boundary.vertexIndices.findIndex(ce);do X=(X+1)%ne;while(ce(se.boundary.vertexIndices[X]));do ee=(ee+1)%de;while(ce(oe.boundary.vertexIndices[ee]));me=(me+1)%B;let re=me,he=0,xe=this._buildBevelVert(F,se,(X-1+ne)%ne,void 0,he),ae=this._buildBevelVert(F,oe,(ee-1+de)%de,void 0,he),ue=xe,O=ae,J,we,Ee=!1;do{he=(me||ve)/ve,ce=Lx(me,B);let Te=Z(se,X,ce),be=Z(oe,ee,ce),Ne=Ee;if(Ee=!1,Te&&!be){for(let Ae=0;Ae<Te;Ae++)J=this._buildBevelVert(F,se,(X+Ae)%ne,Ae/(Te-1),he),v.push(ue.topN,J.topP,O.topN),l===!1&&v.push(J.bottomP,ue.bottomN,O.bottomN),ue=J;Ee=!0}else if(!Te&&be)for(let Ae=0;Ae<be;Ae++)we=this._buildBevelVert(F,oe,(ee+Ae)%de,Ae/(be-1),he),v.push(O.topN,ue.topP,we.topP),l===!1&&v.push(ue.bottomP,O.bottomN,we.bottomP),O=we;else if(Te&&be)if(J=this._buildBevelVert(F,se,X,0,he),we=this._buildBevelVert(F,oe,ee,0,he),Ne?(v.push(ue.topN,we.topP,O.topN),v.push(ue.topN,J.topP,we.topP),l===!1&&(v.push(we.bottomP,ue.bottomN,O.bottomN),v.push(we.bottomP,J.bottomP,ue.bottomN))):(v.push(O.topN,ue.topN,J.topP),v.push(O.topN,J.topP,we.topP),l===!1&&(v.push(J.bottomP,ue.bottomN,O.bottomN),v.push(J.bottomP,O.bottomN,we.bottomP))),ue=J,O=we,Te===be)for(let Ae=1;Ae<Te;Ae++)J=this._buildBevelVert(F,se,(X+Ae)%ne,Ae/(Te-1),he),we=this._buildBevelVert(F,oe,(ee+Ae)%de,Ae/(be-1),he),v.push(ue.topN,J.topP,O.topN),v.push(O.topN,J.topP,we.topP),l===!1&&(v.push(J.bottomP,ue.bottomN,O.bottomN),v.push(J.bottomP,O.bottomN,we.bottomP)),ue=J,O=we;else if(Te>be){let Ae=Te/be,Re=0;for(let Xe=1;Xe<Te;Xe++)J=this._buildBevelVert(F,se,(X+Xe)%ne,Xe/(Te-1),he),v.push(ue.topN,J.topP,O.topN),l===!1&&v.push(J.bottomP,ue.bottomN,O.bottomN),ue=J,Xe>(Re+1)*Ae&&(Re++,we=this._buildBevelVert(F,oe,(ee+Re)%de,Re/(be-1),he),v.push(O.topN,J.topP,we.topP),l===!1&&v.push(J.bottomP,O.bottomN,we.bottomP),O=we)}else{let Ae=be/Te,Re=0;for(let Xe=1;Xe<be;Xe++)we=this._buildBevelVert(F,oe,(ee+Xe)%de,Xe/(be-1),he),v.push(O.topN,J.topP,we.topP),l===!1&&v.push(J.bottomP,O.bottomN,we.bottomP),O=we,Xe>(Re+1)*Ae&&(Re++,J=this._buildBevelVert(F,se,(X+Re)%ne,Re/(Te-1),he),v.push(ue.topN,J.topP,O.topN),l===!1&&v.push(J.bottomP,ue.bottomN,O.bottomN),ue=J)}X=(X+Te)%ne,ee=(ee+be)%de,me=(me+1)%ve}while(me!==re)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,F,v),D){let Q=[];for(let se=v.length-1;se>=te+2;se-=3){let oe=v[se-2],ne=v[se-1],de=v[se-0];Q.push(de,ne,oe)}v.splice(te,v.length-te,...Q)}if(D){let Q=[];for(let se=W[W.length-1].boundary.vertices.length-1;se>=1;se-=2){let oe=W[W.length-1].boundary.vertices[se-1],ne=W[W.length-1].boundary.vertices[se-0];Q.push(oe,ne)}w.push(Q)}if(!D){let Q=W[W.length-1],se;try{se=dn({windingRule:W.length>1?rt.POSITIVE:rt.ODD,elementType:Xt.POLYGONS,vertexSize:2,strict:!0,contours:[Q.insetPoints,...w]})}catch{se=Fx}if(!se)throw new Error("Error generating geometry for surface");d.length===0&&this._bevel<h&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let oe=0;oe<se.elementCount*3;oe+=3){let ne=this._buildSurfaceVert(se,se.elements[oe+0],H),de=this._buildSurfaceVert(se,se.elements[oe+1],H),ve=this._buildSurfaceVert(se,se.elements[oe+2],H);v.push(ne.top,de.top,ve.top),l===!1&&v.push(ve.bottom,de.bottom,ne.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new Jf(Uint32Array.from(v),1),E=new Jf(this._buffer.positions,3),P=new Jf(this._buffer.normals,3),M=new Jf(this._buffer.uvs,2);E.needsUpdate=!0,P.needsUpdate=!0,M.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",E),this.setAttribute("normal",P),this.setAttribute("uv",M),this.setIndex(A)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let o=e[0];for(let a=0,s=o.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,o,a),c=this._buildBevelVert(r,o,(a+1)%s);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,i){let o=r.toString();if(o in this.vertexCache)return this.vertexCache[o];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let d=this._buffer.get(this.forPathBevel?1:2),u=d*3,p=d*2,h={top:d+0,bottom:d+1};return this._buffer.positions[u+0]=a,this._buffer.positions[u+1]=s,this._buffer.positions[u+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[u+0]=0,this._buffer.normals[u+1]=0,this._buffer.normals[u+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=c,this.forPathBevel===!1&&(this._buffer.positions[u+3]=a,this._buffer.positions[u+4]=s,this._buffer.positions[u+5]=i,this._buffer.normals[u+3]=0,this._buffer.normals[u+4]=0,this._buffer.normals[u+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=c),this.vertexCache[o]=h,h}_buildBevelVert(e,r,i,o=1,a){let s=`${r.bevelI}:${i}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=r.boundary.vertexIndices[i],d,u,p,h;l!==c?(u=l,d=c,h=!1,p=e.continuous[u]&&e.continuous[d]):(d=l,u=(d-1+e.count)%e.count,h=e.concave[d]&&r.bevelI>0,p=e.continuous[d]||h);let f=Math.cos(r.angle),m=Math.sin(r.angle),y=i*2,g=d*2,b=u*2,x=r.boundary.vertices[y+0],S=r.boundary.vertices[y+1],v=(1-m)*this._bevel,w=(x-this._minX)/this._width,A=(S-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(w=a),A=1);let E=e.normals[g+0],P=e.normals[g+1],M=e.normals[b+0],R=e.normals[b+1];if(h){let _=M-E,F=R-P;E=E+_*(1-o),P=P+F*(1-o);let V=Math.sqrt(E*E+P*P);E/=V,P/=V}let D=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),N=D*3,C=D*2,B={i,fi:d,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:a};return this._buffer.positions[N+0]=x,this._buffer.positions[N+1]=S,this._buffer.positions[N+2]=(this.forPathBevel?this._bevel:this._depth)-v,this._buffer.normals[N+0]=E*f,this._buffer.normals[N+1]=P*f,this._buffer.normals[N+2]=m,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this.forPathBevel===!1&&(this._buffer.positions[N+3]=x,this._buffer.positions[N+4]=S,this._buffer.positions[N+5]=v,this._buffer.normals[N+3]=E*f,this._buffer.normals[N+4]=P*f,this._buffer.normals[N+5]=-m,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w),p||(this.forPathBevel?(D+=1,N+=3,C+=2):(D+=2,N+=6,C+=4),B.topP=D+0,B.bottomP=D+1,this._buffer.positions[N+0]=x,this._buffer.positions[N+1]=S,this._buffer.positions[N+2]=(this.forPathBevel?this._bevel:this._depth)-v,this._buffer.normals[N+0]=M*f,this._buffer.normals[N+1]=R*f,this._buffer.normals[N+2]=m,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this.forPathBevel===!1&&(this._buffer.positions[N+3]=x,this._buffer.positions[N+4]=S,this._buffer.positions[N+5]=v,this._buffer.normals[N+3]=M*f,this._buffer.normals[N+4]=R*f,this._buffer.normals[N+5]=-m,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w)),this.vertexCache[s]=B,B}clone(){let e=new xa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ya(this.userData),e}};var Yl=class extends Nk{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=rt.ODD;this.elementType=Xt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:rt.ODD,elementType:Xt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let o=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,d,u;for(let f=0,m=o.length/2;f<m;f++){let y=f*2,g=o[y+0],b=o[y+1];if(d!==void 0&&g!==d&&(l=!1),u!==void 0&&b!==u&&(c=!1),d=g,u=b,!l&&!c)break}if(!l&&!c)try{s=dn({contours:[o,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Su}let p=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new $f(new Float32Array(p*3),3),this._normalAttribute=new $f(new Float32Array(p*3),3),this._uvAttribute=new $f(new Float32Array(p*2),2),this._indexAttribute=new $f(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let S=0,v=p;S<v;S++){let w=S*2,A=s.vertices[w+0],E=s.vertices[w+1];A<f&&(f=A),A>m&&(m=A),E<y&&(y=E),E>g&&(g=E)}let b=m-f,x=g-y;for(let S=0,v=p;S<v;S++){let w=S*2,A=s.vertices[w+0],E=s.vertices[w+1],P=(A-f)/b,M=(E-y)/x;this._positionAttribute.setXYZ(S,A,E,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,P,M)}for(let S=0,v=h;S<v;S++){let w=S*3,A=s.elements[w+0],E=s.elements[w+1],P=s.elements[w+2];this._indexAttribute.setX(w+0,A),this._indexAttribute.setX(w+1,E),this._indexAttribute.setX(w+2,P)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Yl(this._shape,this._curveSegments);return e.userData=ya(this.userData),e}};var Ql=class extends xa{constructor(e,r,i=0,o=12,a=3,s=rt.ODD){super(e,r,i,o,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let o=e[0];for(let a=0,s=o.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,o,a),c=this._buildBevelVert(r,o,(a+1)%s);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Ql(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ya(this.userData),e}};var fi=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:rt.ODD},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness,l;a!==void 0&&(a instanceof st?(l=a,(l.width!==r||l.height!==i)&&l.applySize(r,i)):l=new st(r,i).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&l.update());let c=l??new st(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:o,roundness:s}),shape:c}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:o,windingRule:a}=n.parameters;n.shape.roundness=o;let s;return t<=0?s=new Yl(n.shape,i,{windingRule:a}):s=new Ql(n.shape,t,e,i,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as Lk,Float32BufferAttribute as _k,MathUtils as kx,Vector2 as tP}from"three";var rP=Math.PI*2,Zl=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=kx.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,d=t*.5,u=e*.5,p=Fk(c,d,u,i*Math.PI/180,r,o);c.isClosed=!0,c.update();let h;return i===0?(h=new Lk,h.setAttribute("position",new _k([],3))):h=fi.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function Fk(n,t,e,r,i,o){if(r>=rP)return i>30||i%4===0?(Vk(n,t,e,o),Math.round(i/4)):eP(n,r,i,t,e,o);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=QT({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?kk(n,a.x,a.y,c,i,t,e,o):eP(n,r,i,t,e,o)}function kk(n,t,e,r,i,o,a,s){let l=Math.round(i/r.length);n.addPoint(Kl(t,e));for(let c=0,d=r.length;c<d;c++){let u=r[c],p=n.points[c],h=Kl(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),h.controls[0].position.set(u.x2,u.y2),n.addPoint(h)}return s>0?iP(n,o,a,s):n.addPoint(Kl(0,0)),l}function eP(n,t,e,r,i,o){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,d=Math.cos(l)*i;n.addPoint(Kl(c,d))}return t<rP?o>0?iP(n,r,i,o):n.addPoint(Kl(0,0)):(n.removePoint(n.points[n.points.length-1]),o>0&&nP(n,r,i,o)),1}function Vk(n,t,e,r=0,i=0,o=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(em(i-t,o,i-t,o-l,i-t,o+l)),n.addPoint(em(i,o+e,i-s,o+e,i+s,o+e)),n.addPoint(em(i+t,o,i+t,o+l,i+t,o-l)),n.addPoint(em(i,o-e,i+s,o-e,i-s,o-e)),r>0&&nP(n,t,e,r)}function Kl(n,t){return new cn(kx.generateUUID(),new tP(n,t))}function em(n,t,e,r,i,o){let a=Kl(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(i,o),a}function iP(n,t,e,r){oP(n,t,e,r).forEach(o=>n.addPoint(o))}function nP(n,t,e,r){let i=oP(n,t,e,r),o=new st;i.forEach(a=>o.addPoint(a)),o.isClosed=!0,n.shapeHoles.push(o)}function oP(n,t,e,r){let i=r*t/100,o=i*(Math.abs(e)/Math.abs(t)),a=new tP(i/t,o/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=kx.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),s}import{IcosahedronGeometry as Gk}from"three";var aP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:a}=n.parameters,s=i===0&&o!==0?new wu(t*.5,o,a):new Gk(t*.5,i),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},wu=class extends va{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(o,a,s,t,e,r),this.type=s}static fromJSON(t){return new wu(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as Uk,Shape as zk}from"three";var sP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=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}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new zk;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new Uk(i.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as lP,BufferGeometryLoader as Xk,Vector3 as Yk,BoxGeometry as cP,Box3 as Qk}from"three";import{BufferAttribute as tm,BufferGeometry as jk}from"three";var Vx=1e4;function Jl(n,t){return Math.abs(t-n)/2+Math.min(n,t)}var rm=class{constructor(t=1){this.subdivisions=t}modify(t){let e=Hk(t),r=this.subdivisions;for(;r-- >0;)e=Wk(e);return qk(e,t)}};function Hk(n){let t=n.getAttribute("position");if(t===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let e=n.getAttribute("uv"),r=n.getIndex(),i=t.count,o=new Map,a=new Uint32Array(i),s=[],l=0;for(let m=0;m<i;m++){let y=t.getX(m),g=t.getY(m),b=t.getZ(m),x=Math.round(y*Vx),S=Math.round(g*Vx),v=Math.round(b*Vx),w=o.get(x);w===void 0&&(w=new Map,o.set(x,w));let A=w.get(S);A===void 0&&(A=new Map,w.set(S,A));let E=A.get(v);E===void 0&&(E=l++,A.set(v,E),s.push(y,g,b)),a[m]=E}let c=[],d=[],u=e===void 0?null:[],p=r!==null?r.count:i,h=(m,y)=>{let g=r!==null?r.getX(m):m,b=r!==null?r.getX(m+1):m+1,x=r!==null?r.getX(m+2):m+2;if(!(g<i&&b<i&&x<i))return;let S=a[g],v=a[b],w=a[x];S===v||v===w||w===S||(c.push(S,v,w),d.push(y),u!==null&&u.push(e.getX(g),e.getY(g),e.getX(b),e.getY(b),e.getX(x),e.getY(x)))},f=n.groups;if(f.length>0)for(let m=0;m<f.length;m++){let y=f[m],g=y.materialIndex===void 0?0:y.materialIndex,b=Math.max(y.start,0),x=Math.min(y.start+y.count,p);for(let S=b;S<x&&S+2<p;S+=3)h(S,g)}else for(let m=0;m+2<p;m+=3)h(m,0);return{positions:Float64Array.from(s),faces:Uint32Array.from(c),materialIndices:d,uvs:u===null?null:Float64Array.from(u)}}function Wk(n){let{positions:t,faces:e,materialIndices:r,uvs:i}=n,o=t.length/3,a=e.length/3,s=i!==null&&a>0,l=a*3,c=new Uint32Array(l),d=new Uint32Array(l),u=new Uint32Array(l),p=new Uint32Array(l),h=new Uint32Array(l),f=0,m=8;for(;m<l*2;)m*=2;let y=m-1,g=new Int32Array(m).fill(-1),b=(C,B)=>{let _=(Math.imul(C,2654435761)^B)&y;for(;;){let F=g[_];if(F===-1)return g[_]=f,c[f]=C,d[f]=B,f++;if(c[F]===C&&d[F]===B)return F;_=_+1&y}},x=(C,B)=>{let _=C<B?C:B,F=C<B?B:C,V=(Math.imul(_,2654435761)^F)&y;for(;;){let K=g[V];if(c[K]===_&&d[K]===F)return K;V=V+1&y}},S=new Uint32Array(o),v=new Float64Array(o*3),w=(C,B,_)=>{let F=C<B?b(C,B):b(B,C),V=++u[F];V===1?p[F]=_:V===2&&(h[F]=_),S[C]++,S[B]++,v[C*3]+=t[B*3],v[C*3+1]+=t[B*3+1],v[C*3+2]+=t[B*3+2],v[B*3]+=t[C*3],v[B*3+1]+=t[C*3+1],v[B*3+2]+=t[C*3+2]};for(let C=0;C<a;C++){let B=e[C*3],_=e[C*3+1],F=e[C*3+2];w(B,_,F),w(_,F,B),w(F,B,_)}let A=new Float64Array(f*3);for(let C=0;C<f;C++){let B=c[C]*3,_=d[C]*3;if(u[C]===2){let K=p[C]*3,q=h[C]*3;A[C*3]=(t[B]+t[_])*.375+(t[K]+t[q])*.125,A[C*3+1]=(t[B+1]+t[_+1])*.375+(t[K+1]+t[q+1])*.125,A[C*3+2]=(t[B+2]+t[_+2])*.375+(t[K+2]+t[q+2])*.125}else A[C*3]=(t[B]+t[_])*.5,A[C*3+1]=(t[B+1]+t[_+1])*.5,A[C*3+2]=(t[B+2]+t[_+2])*.5}let E=new Float64Array(o*3),P;for(let C=0;C<o;C++){let B=S[C];B===3?P=3/16:B>3&&(P=3/(8*B));let _=1-B*Number(P),F=Number(P);B===2&&(_=3/4,F=1/8),E[C*3]=t[C*3]*_+v[C*3]*F,E[C*3+1]=t[C*3+1]*_+v[C*3+1]*F,E[C*3+2]=t[C*3+2]*_+v[C*3+2]*F}let M=new Float64Array((o+f)*3);M.set(E),M.set(A,o*3);let R=new Uint32Array(a*12),D=new Array(a*4),N=s?new Float64Array(a*24):null;for(let C=0;C<a;C++){let B=e[C*3],_=e[C*3+1],F=e[C*3+2],V=x(B,_)+o,K=x(_,F)+o,q=x(F,B)+o,G=C*12;R[G++]=V,R[G++]=K,R[G++]=q,R[G++]=B,R[G++]=V,R[G++]=q,R[G++]=_,R[G++]=K,R[G++]=V,R[G++]=F,R[G++]=q,R[G++]=K;let W=r[C];if(D[C*4]=W,D[C*4+1]=W,D[C*4+2]=W,D[C*4+3]=W,N!==null){let H=C*6,Z=i[H],te=i[H+1],Q=i[H+2],se=i[H+3],oe=i[H+4],ne=i[H+5],de=Jl(Z,Q),ve=Jl(te,se),me=Jl(Q,oe),ce=Jl(se,ne),X=Jl(Z,oe),ee=Jl(te,ne),re=C*24;N[re++]=de,N[re++]=ve,N[re++]=me,N[re++]=ce,N[re++]=X,N[re++]=ee,N[re++]=Z,N[re++]=te,N[re++]=de,N[re++]=ve,N[re++]=X,N[re++]=ee,N[re++]=Q,N[re++]=se,N[re++]=me,N[re++]=ce,N[re++]=de,N[re++]=ve,N[re++]=oe,N[re++]=ne,N[re++]=X,N[re++]=ee,N[re++]=me,N[re++]=ce}}return{positions:M,faces:R,materialIndices:D,uvs:N}}function qk(n,t){let{positions:e,faces:r,materialIndices:i,uvs:o}=n,a=e.length/3,s=r.length/3,l=new Float64Array(a*3);for(let f=0;f<s;f++){let m=r[f*3]*3,y=r[f*3+1]*3,g=r[f*3+2]*3,b=e[g]-e[y],x=e[g+1]-e[y+1],S=e[g+2]-e[y+2],v=e[m]-e[y],w=e[m+1]-e[y+1],A=e[m+2]-e[y+2],E=x*A-S*w,P=S*v-b*A,M=b*w-x*v;l[m]+=E,l[m+1]+=P,l[m+2]+=M,l[y]+=E,l[y+1]+=P,l[y+2]+=M,l[g]+=E,l[g+1]+=P,l[g+2]+=M}for(let f=0;f<a;f++){let m=l[f*3],y=l[f*3+1],g=l[f*3+2],b=Math.sqrt(m*m+y*y+g*g)||1;l[f*3]=m/b,l[f*3+1]=y/b,l[f*3+2]=g/b}let c=s*3,d=new Float32Array(c*3),u=new Float32Array(c*3),p=o!==null&&o.length>0?new Float32Array(c*2):null;for(let f=0;f<c;f++){let m=r[f]*3;d[f*3]=e[m],d[f*3+1]=e[m+1],d[f*3+2]=e[m+2],u[f*3]=l[m],u[f*3+1]=l[m+1],u[f*3+2]=l[m+2]}p!==null&&p.set(o.subarray(0,c*2));let h=new jk;h.setAttribute("position",new tm(d,3)),c>0&&(h.setAttribute("normal",new tm(u,3)),h.setAttribute("color",new tm(new Float32Array(c*3).fill(1),3))),p!==null&&h.setAttribute("uv",new tm(p,2));for(let f=0;f<s;){let m=i[f],y=f;do f++;while(f<s&&i[f]===m);h.addGroup(y*3,(f-y)*3,m)}return t.boundingBox!==null&&(h.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(h.boundingSphere=t.boundingSphere.clone()),h}var xr=new Yk,dP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new lP().copy(new cP(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(xr),r={width:xr.x,height:xr.y,depth:xr.z,subdivisions:0}):r=t.parameters;let i={...r,...n.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,o=n.geometry??new lP().copy(new cP(100,100,100)),a=o.userData.parameters;a===void 0?(o.boundingBox=Kk(o),o.boundingBox.getSize(xr)):xr.set(a.width,a.height,a.depth),(t!==xr.x||e!==xr.y||r!==xr.z)&&o.scale(xr.x===0?1:t/xr.x,xr.y===0?1:e/xr.y,xr.z===0?1:r/xr.z);let s=o.originalGeometry;try{i>0?(s===void 0||a?.subdivisions!==i)&&(s===void 0&&(s=o),o=new rm(i).modify(s)):(s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals())}catch{s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()}return s!==void 0&&Object.assign(o,{originalGeometry:s}),delete n.geometry,Object.assign(o,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new Xk(e).load(n,i=>{let o=this.normalizeInputs({geometry:i});i.boundingBox.getSize(xr);let a=100/xr.x;Object.assign(o.parameters,{width:100,height:xr.y*a,depth:xr.z*a}),t(this.build(o))})}};function Kk(n){let t=new Qk,e=n.attributes.position;return e?(t.setFromBufferAttribute(e),t):(t.makeEmpty(),t)}var im=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,c=t*.5,d=e*.5,u=0,p=0,h=2*Math.PI/r;for(let m=0;m<r;m++){let y=h*m,g=u+Math.sin(y)*c,b=p+Math.cos(y)*d;l.addPoint(l.createPoint(g,b))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=i;l.roundness=i,l.update();let f=fi.create({shape:l,parameters:{roundness:i,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as Zk,Float32BufferAttribute as Gx,Vector2 as kn,Vector3 as mr}from"three";var uP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:o,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=new zx(t*.5,e,i,o,a,s,l),d=r/t;return d!==1&&c.scale(1,1,d),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function Au(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}var Jk=new mr,$k=new mr;function Ux(n,t,e,r,i,o){let a=Jk.copy(t).sub(n),s=$k.copy(e).sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===i){let c=a.add(s).normalize();o.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);o.copy(n),o.addScaledVector(a,i/Math.sin(c)),o.addScaledVector(s,r/Math.sin(c))}}function eV(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var zx=class extends Zk{constructor(t=.5,e=1,r=4,i=1,o=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),s=Math.floor(s);let l=[],c=[],d=[],u=[],p=0,h=e/2,f=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,x=new mr(0,-h,0),S=new mr(0,h,0),v=new kn(t,-h),w=new kn(m,-h),A=new kn(0,S.y).sub(w),E=new kn(0,S.y).sub(v),P=new kn(A.y,-A.x).normalize(),M=new kn(E.y,-E.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,D);let N;{let q=new mr(P.x,P.y,0),G=new mr(Math.cos(y)*q.x,q.y,Math.sin(y)*q.x);N=q.angleTo(G)}let C=a/Math.tan((Math.PI-A.angle())/2),B=a/Math.tan((Math.PI-N)/2),_=new mr;if(!o){c.push(x.x,x.y,x.z),d.push(0,-1,0),u.push(0,0);let q=p++,G=[],W=v.clone(),H=C/Math.cos(Math.PI/r);W.x-=H;for(let Z=0;Z<r;Z++){let te=Z/r*Math.PI*2+f,Q=new kn(Math.sin(te),Math.cos(te));Au(W,Q,_),c.push(_.x,_.y,_.z),d.push(0,-1,0),u.push(0,0),G.push(p++)}for(let Z=0;Z<G.length;Z++)l.push(G[Z],q,G[(Z+1)%G.length])}let F=[];{let q=new mr,G=new mr,W=new mr,H=new mr,Z=new mr,te=new mr;for(let Q=0;Q<r;Q++){let se=Q/r*Math.PI*2+f,oe=(Q+.5)/r*Math.PI*2+f,ne=(Q+1)/r*Math.PI*2+f,de=new kn(Math.sin(se),Math.cos(se)),ve=new kn(Math.sin(oe),Math.cos(oe)),me=new kn(Math.sin(ne),Math.cos(ne));Au(v,de,G),Au(v,me,W),Au(P,ve,q),Ux(S,G,W,B,B,H),c.push(H.x,H.y,H.z),Ux(G,S,W,B,C,Z),c.push(Z.x,Z.y,Z.z),Ux(W,G,S,C,B,te),c.push(te.x,te.y,te.z),d.push(q.x,q.y,q.z),d.push(q.x,q.y,q.z),d.push(q.x,q.y,q.z),u.push(0,0),u.push(0,0),u.push(0,0);let ce=p++,X=p++,ee=p++;if(l.push(ce,X,ee),a>0){{let xe=G.clone().add(W).multiplyScalar(.5),ae=S.clone().sub(xe).normalize(),O=x.clone().sub(xe).normalize().add(ae).normalize().multiplyScalar(-1),J=te.clone().sub(Z);V(xe,J,O,A.angle())}let re,he;{let xe=new mr;Au(M,me,xe);let ae=te.clone().add(H).multiplyScalar(.5);ae=eV(ae,W,S);let ue=te.clone().sub(H);[re,he]=V(ae,ue,xe,N,H.y)}{let xe=re,ae=xe.clone().setY(0).normalize(),ue=new mr(0,-1,0),O=ae.clone().cross(ue);K(xe,ae,ue,O)}F.concat(he);{let xe=A.angle(),ae=Math.PI-xe,ue=S.clone();ue.y-=a/Math.sin(xe-Math.PI/2);let O=new mr,J=[];for(let Ee=0;Ee<s;Ee++){let Te=[],be=Math.PI/2-ae*Ee/s,Ne=Math.cos(be),Ae=Math.sin(be),Re=oe;for(let Xe=0;Xe<=Ee;Xe++){let Be=Math.cos(Re),ft=Math.sin(Re);q.x=Ne*ft,q.y=Ae,q.z=Ne*Be,O.copy(ue).addScaledVector(q,a),c.push(O.x,O.y,O.z),d.push(q.x,q.y,q.z),u.push(0,0),Te.push(p++),Re+=Math.PI*2/Ee/r}J.push(Te)}he.reverse(),J.push(he);let we=J.length-1;for(let Ee=0;Ee<we;Ee++){let Te=J[Ee],be=J[Ee+1],Ne=Te.length-1;l.push(be[1],Te[0],be[0]);for(let Ae=1;Ae<=Ne;Ae++)l.push(Te[Ae],Te[Ae-1],be[Ae]),l.push(be[Ae+1],Te[Ae],be[Ae])}}}}}this.setIndex(l),this.setAttribute("position",new Gx(c,3)),this.setAttribute("normal",new Gx(d,3)),this.setAttribute("uv",new Gx(u,2));function V(q,G,W,H,Z){let te=-H/2,Q=(Math.PI-H)/2,se=G.clone().normalize().cross(W);q.addScaledVector(W,-a/Math.sin(Q));let oe=new mr,ne=new mr,de=1,ve=p,me=[];for(let ce=0;ce<=s;ce++){let X=te+ce/s*H;ne.set(0,0,0),ne.addScaledVector(se,Math.sin(X)),ne.addScaledVector(W,Math.cos(X));for(let ee=0;ee<=de;ee++){let re=ee/de-.5;if(oe.copy(q),oe.addScaledVector(G,re),oe.addScaledVector(ne,a),Z!=null){let he=Math.max(0,oe.y-Z);oe.addScaledVector(G,-he/G.y)}c.push(oe.x,oe.y,oe.z),d.push(ne.x,ne.y,ne.z),u.push(0,0),ee===0&&me.push(p),p++}}for(let ce=0;ce<s;ce++)for(let X=0;X<de;X++){let ee=ve+X+(de+1)*ce,re=ee+(de+1),he=re+1,xe=ee+1;l.push(ee,re,xe),l.push(re,he,xe)}return[q.clone().addScaledVector(G,.5),me]}function K(q,G,W,H){let Z=Math.PI/2,te=E.angle()-Z,Q=[],se=new mr,oe=new mr;for(let de=0;de<=s;de++){let ve=[],me=de/s;for(let ce=0;ce<=de;ce++){let ee=((de?ce/de:0)-.5)*b,re=Math.cos(ee),he=Math.sin(ee),xe=Math.atan(Math.tan(te)*re),ae=(Z+xe)*me,ue=Math.cos(ae),O=Math.sin(ae);se.set(0,0,0),se.addScaledVector(G,O*re),se.addScaledVector(W,ue),se.addScaledVector(H,O*he),oe.copy(q).addScaledVector(se,a),c.push(oe.x,oe.y,oe.z),d.push(se.x,se.y,se.z),u.push(0,0),ve.push(p++)}Q.push(ve)}let ne=Q.length-1;for(let de=0;de<ne;de++){let ve=Q[de],me=Q[de+1],ce=ve.length-1;l.push(ve[0],me[1],me[0]);for(let X=1;X<=ce;X++)l.push(ve[X-1],ve[X],me[X]),l.push(ve[X],me[X+1],me[X])}}}};var $l=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:r*.5},d={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function p(S,v,w){return v>e&&w>r?Math.min(S*e/v,S*r/w):v>e?S*e/v:w>r?S*r/w:S}let h=[];h[0]=i[0]===0?0:p(i[0],i[0]+i[3],i[0]+i[1]),h[1]=i[1]===0?0:p(i[1],i[1]+i[2],i[1]+i[0]),h[2]=i[2]===0?0:p(i[2],i[2]+i[1],i[2]+i[3]),h[3]=i[3]===0?0:p(i[3],i[3]+i[0],i[3]+i[2]);let f=d.x,m=u.x,y=u.y,g=d.y;t.addPoint(t.createPoint(f,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(f,g)),t.isClosed=!0;let b=!0;for(let S=0,v=t.points.length;S<v;S++)t.points[S].roundness=h[S],S>0&&h[S]!==h[S-1]&&(b=!1);b&&(t.roundness=h[0]),t.useCubicForRoundedCorners=o!==1,t.update();let x=fi.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as tV,Float32BufferAttribute as rV,MathUtils as pP,SphereGeometry as iV}from"three";var hP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=pP.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:o=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=n.parameters,d;return c===0?(d=new tV,d.setAttribute("position",new rV([],3))):d=new iV(.5*t,i,o,a,s,l,c*pP.DEG2RAD),d.scale(1,e/t,r/t),Object.assign(d,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as nV}from"three";var fP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,o=new nV(t,e,r,i);return o.scale(1,1,1),Object.assign(o,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as oV,Float32BufferAttribute as jx,Vector3 as aV}from"three";var mP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,angle:i,cornerRadius:o,cornerSegments:a}=n.parameters,s=new Hx(t,e,r,i,o,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Hx=class extends oV{constructor(t=1,e=1,r=1,i=90,o=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],d=.001;o==0&&(a=1),a=Math.max(1,Math.floor(a)),o=Math.min(o,100),i=Math.min(180-d,i),i*=Math.PI/180;let u=[],p=Math.PI/2,h=(oe=0,ne=0,de=0)=>new aV(oe,ne,de),f=h(),m=h(),[y,g,b]=[e/2,t/2,r/2],x=-g,S=+g,[v,w,A]=[h(x,-y,+b),h(x,-y,-b),h(x,+y,-b)],E=(oe,ne=!1)=>Math.sin(oe-Math.PI/(1+ +ne)),P=(oe,ne=!1)=>Math.cos(oe-Math.PI/(1+ +ne));A.y=Math.sin(i)*e-y;let M=Math.cos(i)*e-b,R=v.z-d;i<=p?(A.z=Math.min(M,R),A.z==R&&(A.y-=(M-R)/Math.tan(p-i))):w.z=Math.min(w.z-M-b,v.z-d),f.subVectors(v,w),m.subVectors(A,w);let D=Math.min(f.length(),m.length())*o/100,N=D*Math.tan(i/2),C=D/Math.cos(i/2),B=f.clone().normalize().add(m.normalize()).setLength(C).add(w);f.set(0,E(i,!0),P(i,!0)),u.push([A,f.clone()]);let _=(Math.PI-i)/a;for(let oe=0;oe<=a;oe++){let ne=p+i+oe*_;f.set(0,Math.sin(ne)*N,Math.cos(ne)*N),f.add(B),m.set(0,E(ne),P(ne)),u.push([f.clone(),m.clone()])}u.push([v,h(0,1,0)]);let F=Math.sin(_/2)*N*2,V=u.length-1,K=u[0][0].distanceTo(u[1][0]),q=u[V-1][0].distanceTo(u[V][0]),G=K+F*a+q;u[0].push(1);for(let oe=0;oe<=a;oe++)u[oe+1].push(1-(K+oe*F)/G);u[V].push(0);let[W,H,Z]=u[0],te,Q,se;for(let oe=1;oe<u.length;oe++)[te,Q,se]=u[oe],s.push(x,W.y,W.z,x,te.y,te.z,S,W.y,W.z,S,W.y,W.z,x,te.y,te.z,S,te.y,te.z),l.push(0,H.y,H.z,0,Q.y,Q.z,0,H.y,H.z,0,H.y,H.z,0,Q.y,Q.z,0,Q.y,Q.z),c.push(0,Z,0,se,1,Z,1,Z,0,se,1,se),[W,H,Z]=[te,Q,se];this.setAttribute("position",new jx(s,3)),this.setAttribute("normal",new jx(l,3)),this.setAttribute("uv",new jx(c,2))}};var nm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:o,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,d=n.shape,u=t*.5,p=e*.5,h=0,f=0,m=a*Math.PI/360/i,y=Math.PI/2*3*-1,g=u*r/100,b=p*r/100;if(i===3&&r===50){m=2*Math.PI/i;for(let S=0;S<i;S++){let v=m*S,w=h+Math.sin(v)*u,A=f+Math.cos(v)*p;d.addPoint(d.createPoint(w,A))}}else for(let S=0;S<i;S++){let v=h+Math.cos(y)*u,w=f+Math.sin(y)*p;d.addPoint(d.createPoint(v,w)),y+=m,v=h+Math.cos(y)*g,w=f+Math.sin(y)*b,d.addPoint(d.createPoint(v,w)),y+=m}d.isClosed=!0;for(let S=0,v=d.points.length;S<v;S++)d.points[S].roundness=o;d.roundness=o,d.update();let x=fi.create({shape:d,parameters:{roundness:o,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as sV}from"three";var yP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new sV(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as lV,Float32BufferAttribute as cV,MathUtils as dV}from"three";var gP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width);e.shapeBlendNode&&(i=r);let o=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:i,depth:o})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:o,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=uV(t,e,r,t*.5,a,o,0,0,i,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function uV(n,t,e,r,i,o,a,s,l,c,d){[t,e]=[e,t],a=t/2;let u=dV.clamp(i/360,0,1);if(u===0){let p=new lV;return p.setAttribute("position",new cV([],3)),p}return u===1&&(c=0),new au(!0,n,t,e,r,u,o,a,s,l,c,d)}import{TorusKnotGeometry as pV}from"three";var vP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:o,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new pV(s,e,r,i,o,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var bP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,c=t*.5,d=e*.5;s?(l.addPoint(l.createPoint(-c,d)),l.addPoint(l.createPoint(c,-d)),l.addPoint(l.createPoint(-c,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(c,-d)),l.addPoint(l.createPoint(-c,-d))),l.isClosed=!0;for(let p=0,h=l.points.length;p<h;p++)l.points[p].roundness=r;l.roundness=r,l.update();let u=fi.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};Zt();import{BufferAttribute as xP,BufferGeometry as Wx}from"three";import{mergeGeometries as fV}from"three/examples/jsm/utils/BufferGeometryUtils.js";function SP(){let n=new Wx;return n.setAttribute("position",new xP(new Float32Array([]),3)),n.setIndex(new xP(new Uint16Array([]),1)),n}var mV=SP().attributes,yV=12,gV=1,ec=class extends Wx{constructor(e,r){super();this.isTextGeometry=!0;this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,mV),this.userData={parameters:e,type:"TextGeometry"};let i=r.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let i=r.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,r){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:d,textTransform:u}=e,p=sr.getDisplayedValue(d),h=u===2?p.toUpperCase():u===3?p.toLowerCase():p,f=vV(e,i,h,r),{shapes:m,charWidths:y,charCoords:g}=i.generateShapes(f,e,r),b=(typeof o=="number"?o:Number(r.getVariable(o)))*.5,x=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,S=m.map(A=>new st().fromShape(A,!0));this.vectorShapes=S;let v=S.map(A=>fi.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?rt.NONZERO:rt.ODD,subdivisions:this.isLowResolution&&s>0?gV:yV}})),w=v.length?fV(v):SP();w.translate(-b,x,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([A,E])=>{this.setAttribute(A,E)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=nr(new Wx,ec.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,i])=>{this.setAttribute(r,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function vV(n,t,e,r){let i=typeof n.width=="string"?Number(r.getVariable(n.width)):n.width,o=[""],a="";for(let s of e)a+=s,s===" "||s===`
728
728
  `?(o[o.length-1]+=a,a="",s===`
729
- `&&o.push("")):t.getTextWidth(o[o.length-1]+a,n)>i&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,n)>i&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}import{BufferGeometry as qx,BufferAttribute as CP,Uint32BufferAttribute as Xx,Float32BufferAttribute as lm,Matrix4 as SV,Vector3 as Cu,Sphere as wV,Box3 as AV,BoxGeometry as EV}from"three";var AP,am=new Promise(n=>{AP=n}),wP=!1;var om;function EP(n){if(wP)return;if(om)return om;async function t(){let r=n??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.38/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});AP(c),wP=!0}return om=t(),om}import{Matrix4 as bV}from"three";var xV=new bV;function sm(n,t){if(Object.keys(n.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(n.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let s of r){let l=n.attributes[s],c=t.attributes[s];if(l===void 0||l.isInterleavedBufferAttribute===!0||c.isInterleavedBufferAttribute===!0||l.itemSize!==c.itemSize||l.normalized!==c.normalized||l.array.constructor!==c.array.constructor||l.array.length!==c.array.length)return!1}let i=n.index,o=t.index;if(i===null!=(o===null))return!1;let a=!1;if(i!==null&&o!==null){if(i.array.length!==o.array.length)return!1;let s=i.array.constructor,l=o.array.constructor;if(s!==l){if(s!==Uint32Array||l!==Uint16Array)return!1;a=!0}}if(n.groups.length!==t.groups.length)return!1;for(let s=0;s<t.groups.length;s++){let l=n.groups[s],c=t.groups[s];if(l.start!==c.start||l.count!==c.count||l.materialIndex!==c.materialIndex)return!1}for(let s of r){let l=n.attributes[s],c=t.attributes[s];l.array.set(c.array),l.needsUpdate=!0}if(i!==null&&o!==null){if(a){let s=i.array,l=o.array;for(let c=0,d=l.length;c<d;c++){let u=l[c];s[c]=u===65535?4294967295:u}}else i.array.set(o.array);i.needsUpdate=!0}return n.drawRange.start=t.drawRange.start,n.drawRange.count=t.drawRange.count,n.userData=t.userData,n.boundingBox=null,n.boundingSphere=null,!0}function Eu(n,t,e,r){let i=n.position.array,o=n.normal.array,a=xV.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=i.length;d<u;d+=3)i[d]*=t,i[d+1]*=e,i[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var cm=new AV,tc=new Cu,Pe;am.then(n=>{Pe=n});var TP=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),PP=new Uint32Array([0,1,2,3]),MP=new Uint8Array([4]);function Jx(n){let t=Number(n);return Number.isInteger(t)&&t>=0&&String(t)===n?t:-1}function CV(n){let t=Object.keys(n),e=0;for(let i of t){let o=Jx(i);o>=e&&(e=o+1)}if(e===0||e>t.length)return;let r=new Array(e);for(let i=0;i<e;i++){let o=n[i];if(typeof o!="number")return;r[i]=o}return r}function dm(n){if(n!=null){if(Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView))return n;if(typeof n=="object")return CV(n)}}function Yx(n){if(n==null)return"missing";if(Array.isArray(n))return`Array(${n.length})`;if(ArrayBuffer.isView(n)){let l=n;return`${n.constructor.name}(${l.length})`}if(typeof n!="object")return typeof n;let t=Object.keys(n),e=t.filter(l=>Jx(l)===-1),r=0;for(let l of t){let c=Jx(l);c>=r&&(r=c+1)}let i=n,o=-1,a=-1;for(let l=0;l<r;l++)l in i?typeof i[l]!="number"&&a===-1&&(a=l):o===-1&&(o=l);let s=[`${t.length} keys`,`max index ${r-1}`];return o!==-1&&s.push(`first missing index ${o}`),a!==-1&&s.push(`non-number at ${a} (${typeof i[a]})`),e.length&&s.push(`stray keys ${e.slice(0,3).join(",")}`),`Object{${s.join(", ")}}`}var xt=class extends qx{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=_i.div(r.map(l=>typeof l=="number"?l:0),i);if(o.every(l=>l===1))return;this.subdividedGeometry&&Eu(this.subdividedGeometry.attributes,...o),this.originalGeometry&&Eu(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(tc.fromArray(o));let s=tc.set(a.width,a.height,a.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 r=e.phongAngle??35;this.flatShading&&(r=-1);let i=null;if(e.subdivisions>0){let a=0;try{a=xt.allocate(e),i=xt.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&xt.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=xt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new EV(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new wV,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;cm.setFromBufferAttribute(r),cm.getCenter(i),e.boundingSphere.radius=i.distanceTo(cm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),cm.getSize(tc);let o={width:tc.x,height:tc.y,depth:tc.z};return this.userData.parameters=o,o}static build(e,r,i,o){let a,s,l=e?.phongAngle??35;i===!1&&(l=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=xt.allocate(e,o)}catch(d){console.error(d,e),a=xt.allocate({positionWASM:TP,indexWASM:PP,verticesPerFaceWASM:MP},o)}Pe.set_destination_refinement_level(a,0);let c=xt.buildLevel(a,!0,l);return e.subdivisions>0?s=xt.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,i){try{return Pe.set_destination_refinement_level(e,r),xt.buildLevel(e,!1,i)??null}catch{try{return Pe.set_destination_refinement_level(e,r-1),xt.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,r,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 o=e.shape!==void 0||e.path!==void 0?r.geometry:Wi(e,i,!1,r),a;Sf(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=Tu(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=TV(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let i,o,a,s=[],l=[],c=dm(e.positionWASM),d=dm(e.indexWASM),u=dm(e.verticesPerFaceWASM);if(c&&c.length>0){if(!d?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${Yx(e.positionWASM)}, indexWASM ${Yx(e.indexWASM)}, verticesPerFaceWASM ${Yx(e.verticesPerFaceWASM)}`);i=c,o=d,a=u;let P=dm(e.uvWASM);Pe.alloc_subdivision_surface_uvs&&P&&P.length===o.length*2&&(l=P)}else i=TP,o=PP,a=MP;let p=i.length,h=o.length,f=a.length,m=i.length+s.length+l.length,y=o.length+a.length,g=m*Float32Array.BYTES_PER_ELEMENT+y*Uint32Array.BYTES_PER_ELEMENT,b=m*Float32Array.BYTES_PER_ELEMENT,x=Pe._malloc(g);if(!x)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let S=new Float32Array(Pe.HEAPF32.buffer,x,m),v=new Uint32Array(Pe.HEAPU32.buffer,x+b,y);S.set(i,0),S.set(s,i.length),S.set(l,i.length+s.length),v.set(o,0),v.set(a,o.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new SV().makeScale(...e.scaleBaked.map(P=>typeof P=="number"?P:1))),r&&(w?w.premultiply(r):w=r);let A=x+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,E=l.length?w?Pe.alloc_subdivision_surface_uvs2(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length,w.elements):Pe.alloc_subdivision_surface_uvs(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length):w?Pe.alloc_subdivision_surface2(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w.elements):Pe.alloc_subdivision_surface(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f);return Pe._free(x),E}static buildLevel(e,r,i,o,a,s=!1){let l=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,i,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,i),c=10,d=Pe.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=Pe.HEAPU32[d[p]>>2],f=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=Pe.HEAPU32[d[p]>>2],y=Pe.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=Pe.HEAPU32[d[p]>>2],b=Pe.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let x=Pe.HEAPU32[d[p]>>2],S=Pe.HEAPU32.subarray(x>>2,(x>>2)+u[p]);p++;let v;if(Pe.alloc_subdivision_surface_uvs){let A=d[9];if(A>0){let E=Pe.HEAPU32[d[8]>>2];v=Pe.HEAPF32.subarray(E>>2,(E>>2)+A)}}if(o===void 0){let A=new qx;if(A.setIndex(new Xx(S,1)),A.setAttribute("position",new lm(f,3)),A.setAttribute("normal",new lm(y,3)),v&&A.setAttribute("uv",new lm(v,2)),r){A.setAttribute("faceMap",new Xx(b,1));let E=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new CP(E,4))}return Pe.free_mesh_data(l),A.userData.type="SubdivGeometry",A}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let A=o.getIndex();A!==null&&A.array.length===S.length&&(A.copyArray(S),A.needsUpdate=!0)}let w=o.getAttribute("uv");v&&w&&w.array.length===v.length&&(w.copyArray(v),w.needsUpdate=!0),Pe.free_mesh_data(l)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let o=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=Pe.HEAPU32[s[c]>>2],u=Pe.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=Pe.HEAPU32[s[c]>>2],h=Pe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new qx;f.setAttribute("position",new lm(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=i.r,m[y++]=i.g,m[y++]=i.b;return f.setAttribute("color",new CP(m,3)),f.setIndex(new Xx(h,1)),Pe.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,i){let o=r===0;o||Pe.set_destination_refinement_level(e,r);let a=i?Pe.get_topological_data2(e,o?Pe.Level.CONTROL:Pe.Level.REFINED,i.elements):Pe.get_topological_data(e,o?Pe.Level.CONTROL:Pe.Level.REFINED),s=8,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=Pe.HEAPU32[l[d]>>2],p=new Float32Array(Pe.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=Pe.HEAPU32[l[d]>>2],f=new Uint32Array(Pe.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=Pe.HEAPU32[l[d]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(Pe.alloc_subdivision_surface_uvs){let b=l[7];if(b>0){let x=Pe.HEAPU32[l[6]>>2];g=new Float32Array(Pe.HEAPF32.subarray(x>>2,(x>>2)+b))}}return Pe.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function pm(n){let t=Object.keys(n);return t.length===1&&t[0]==="subdivisions"}function Tu(n,t){let e=t?t.count:n.count,r=0,i=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=n.getX(u),h=n.getY(u),f=n.getZ(u),m=Math.round(p*i),y=Math.round(h*i),g=Math.round(f*i),b=o.get(m);b===void 0&&(b=new Map,o.set(m,b));let x=b.get(y);x===void 0&&(x=new Map,b.set(y,x));let S=x.get(g);S===void 0&&(S=r++,x.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var um=new Cu,Qx=new Cu,Kx=new Cu,Zx=new Cu;function TV(n,t,e,r,i){let o=[],a=[],s=i?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=i[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,b)=>Math.floor(b/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);n.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)n.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)n.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((n[t[u]*3+2]===d||n[t[u]*3+2]===0)&&p++,(n[t[u+1]*3+2]===d||n[t[u+1]*3+2]===0)&&p++,(n[t[u+2]*3+2]===d||n[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){um.set(n[t[u]*3],n[t[u]*3+1],n[t[u]*3+2]),Qx.set(n[t[u+1]*3],n[t[u+1]*3+1],n[t[u+1]*3+2]),Kx.set(n[t[u+4]*3],n[t[u+4]*3+1],n[t[u+4]*3+2]),Zx.set(n[t[u+5]*3],n[t[u+5]*3+1],n[t[u+5]*3+2]),Qx.sub(um).normalize(),Kx.sub(um).normalize(),Zx.sub(um).normalize();let p=Qx.cross(Kx).dot(Zx),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<n.length;m+=3,y++)n[m+2]===0&&(p.push(y),f++),n[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var PV={ConeGeometry:OT,CubeGeometry:IT,CylinderGeometry:zf,DodecahedronGeometry:DT,EllipseGeometry:Zl,HelixGeometry:MC,IcosahedronGeometry:aP,LatheGeometry:sP,NonParametricGeometry:dP,PolygonGeometry:im,PyramidGeometry:uP,RectangleGeometry:$l,SphereGeometry:hP,PlaneGeometry:fP,BackdropGeometry:mP,StarGeometry:nm,TextFrameGeometry:yP,TorusGeometry:gP,TorusKnotGeometry:vP,TriangleGeometry:bP,VectorGeometry:fi},hm=n=>{let t=PV[n.type]??ff(n.type);if(t===void 0)throw new Error(`No geometry factory registered for "${n.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(n)};var OV=["font"];function Wi(n,t,e,r){let i,o,a;n.type==="PathGeometry"?(o=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(o={...n},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(i in d){let u=d[i];rb(u)&&!OV.includes(i)&&(d[i]=t.getVariable(u,[r.uuid,"geometry",...c,i]),rb(d[i])&&(d[i]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry")s.path=o.path;else if(o.type==="VectorGeometry"){let c=st.createFromState(o.shape,o.width,o.height);s.shape=c}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new MV().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new xt(o,e);return c.data=n,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=ff(o.type);if(c)return c.create(o,t);$t("text",`a ${o.type}`);let d=st.createFromState(ls.defaultData(),100,100);return hm({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return $l.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=hm(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=st.createFromState(ls.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=hm(s)}return l}var $x=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let i=this.objects.get(t);return i===void 0?(i=this.createObject(t,e,r),this.objects.set(t,i)):i.isShared=!0,i}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Pu=class extends $x{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let o=Wi(e,r,this.flatShading,i);return o.computeBoundingSphere(),o}};var r0="webgl",OP,e0,IP=!1;function i0(){return r0}function RP(n){e0=n}function BP(){if(r0==="webgpu"){if(OP!==void 0)return OP;IP||(IP=!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(e0===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 e0}function fm(n,t){return BP().createRootMaterial(n,t)}function n0(n,t,e){return BP().createSharedMaterial(n,t,e)}function o0(n){return n.getLayersOfType===void 0&&Object.assign(n,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),n}var DP,NP;function LP(n){NP=n}function _P(){let n=r0==="webgpu"&&DP!==void 0?DP:NP;return n===void 0?null:o0(n())}var t0;function FP(n){t0=n}function kP(n,t){return t0===void 0?!1:t0(n,t)}var VP={markNeedsUpdateRendererDirty:()=>{}};function Vn(n,t){let e=0;if(!n.layers||n.layers.length===0)return!1;let r=n.layers?.find(i=>i.data.type==="light");if(r){let i=r.data,o=Number(t.getVariable(i.alphaOverride));if((typeof i.alphaOverride=="string"?o/100:i.alphaOverride)<1)return!0}for(let i of n.layers){if(i.data.type!=="displace"&&i.data.isMask)return!0;if(i.data.type!=="displace"&&"alpha"in i.data&&i.data.type!=="light"&&i.data.type!=="fresnel"&&i.data.type!=="cavity"&&i.data.type!=="dust"&&i.data.type!=="texture"&&i.data.type!=="matcap"&&i.data.type!=="rainbow"&&i.data.type!=="outline"&&i.data.type!=="pattern"){let o=i.data.visible?i.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&i.data.type==="depth"||i.data.type==="gradient"){for(let a of i.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&i.data.type==="noise"){let a=t.color(i.data.colorA).a,s=t.color(i.data.colorB).a,l=t.color(i.data.colorC).a,c=t.color(i.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var qi=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,ye=(n,t,e)=>typeof n=="number"?n:t.getVariable(n,e);function a0(n){let t=typeof n=="string"?n:n.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function un(n){return typeof n=="string"||typeof n=="number"&&n!==0}var rc={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},GP={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};import{Object3D as IV}from"three";var s0=class extends Bl(IV){},DV=n=>n.type==="Mesh",cr=class extends s0{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new cr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix,i.pivotMatrix=r.pivotMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1:this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||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 DV(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){}};ut();import{Euler as BV,MathUtils as c0,Matrix4 as NV,Quaternion as LV,Vector3 as KP}from"three";var UP=null,zP=null;function jP(n){UP=n}function l0(){return UP}function HP(n){zP=n}function WP(){return zP}function mm(n){return"variable_"+n}var qP=new NV,XP=new KP,YP=new LV,_V=new KP,QP=new BV,d0=class extends Gf{constructor(e){super();this.shared=e}create(e){return new jl(e,this.shared)}},u0=class{constructor(t,e={},r=!0,i=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=i;this.geometryCache=new Pu(!0);this.geometryCache2=new Pu(!1);this.imageHolderCache=new d0(this);this.thisContext={scene:VP,shared:this};this.deletedImage=new Ci(nf.emptyImage,this);this.deletedVideo=new Ci(hl.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;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=n0(qt.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:i,data:o}of t.variables)this.addVariableHolder(i,o),e&&this.updateVariableHolder(i,o);for(let[i,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(i,o);for(let[i,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(i,o);if(!r){for(let[i,o]of Object.entries(t.images))this.addImage(i,o);for(let[i,o]of Object.entries(t.videos))this.addVideo(i,o)}for(let[i,o]of Object.entries(t.colors))this.addColor(i,o);for(let[i,o]of Object.entries(t.lib.materials))this.addMaterial(i,o.asset);for(let[i,o]of Object.entries(t.materials))this.addMaterial(i,o);for(let[i,o]of Object.entries(t.audios))this.addAudio(i,o);for(let[i,o]of Object.entries(t.particles))this.addParticle(i,o);for(let[i,o]of Object.entries(t.fonts))this.addFont(i,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:qt.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=n0(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:qt.defaultTwoLayerData("phong").layers}),fm(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Ci(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Ci(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Ci(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Oo(e.r,e.g,e.b,e.a):this.colors[t]=new Oo(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Pt(0,0,0,0))}else return"a"in t?new Pt(t.r,t.g,t.b,t.a):new Pt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Io)return e;{let r=new Io({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Io&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=CT();if(r===null){$t("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Io&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let i=localStorage.getItem(mm(t));r=i!==null?JSON.parse(i):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(mm(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let i=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:i,shared:this},u=s.slice(2);i.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=i.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*c0.DEG2RAD:l[s[s.length-1]]=r}if(l=i.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),ke.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&i.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...i,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(i.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!i||!this.transientGeometryKeys.has(i)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>u0.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let w=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(w.length===0||w.length%3!==0)return!1;for(let A=0;A<w.length;A++)if(w[A]>=l)return!1;u={array:w,itemSize:1,type:w.constructor.name,normalized:!1}}else{let w=o.data,A=w?.index;if(A?.array?.length){let E=(w?.attributes?.position?.array?.length??0)/3;if(l<E){let P=A.array;for(let M=0;M<P.length;M++)if(P[M]>=l)return!1}u=A}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let w=0;w<s.length;w+=3){let A=s[w],E=s[w+1],P=s[w+2];A<p&&(p=A),A>m&&(m=A),E<h&&(h=E),E>y&&(y=E),P<f&&(f=P),P>g&&(g=P)}let b=(w,A)=>({array:w,itemSize:A,type:"Float32Array",normalized:!1}),x={position:b(s,3)};c&&(x.normal=b(c,3)),d&&(x.uv=b(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:x,...u?{index:u}:{}}},v=this.transientGeometryKeys.has(o);return r.dataPatched={...i,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,v),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let i=r.cloner;if(i===void 0)return-1;let o=i.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=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]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?i.update(this.entityOpContext):i.syncInstanceMatrices(),i.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let i=new cr(t);i.playModeVisible=e.visible!==!1,i.expand(),typeof e.name=="string"&&(i.name=e.name);let o=Math.PI/180;return i.position.copy(t.position),i.rotation.copy(t.rotation),i.scale.copy(t.scale),i.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(i.position.x=e.position.x),typeof e.position.y=="number"&&(i.position.y=e.position.y),typeof e.position.z=="number"&&(i.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(i.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(i.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(i.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(i.scale.x=e.scale.x),typeof e.scale.y=="number"&&(i.scale.y=e.scale.y),typeof e.scale.z=="number"&&(i.scale.z=e.scale.z)),i.updateMatrix(),r.add(i),i.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),i}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let i=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!i.includes(u)&&i.push(u)}if(i.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Pt(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Oo?d.setValue(u,new Pt(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of i){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:Vn(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(b=>b.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(b=>b.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=rc[f.data.type]??[],g=Object.keys(f.data);for(let[b,x]of Object.entries(h)){if(b==="id"||b==="index"||b==="type")continue;let S=g.find(w=>w===b)??g.find(w=>a(w)===a(b))??b;if(y.includes(S))continue;let v=s(x);if(v&&l(m,S,v)){c=!0;continue}if(typeof x=="number"&&isFinite(x))d.onVariableUpdate?.(["layer",f.id,S],x,o),c=!0;else if(Array.isArray(x)&&x.length<=3&&x.every(w=>typeof w=="number"&&isFinite(w))){let w=["x","y","z"];x.forEach((A,E)=>{d.onVariableUpdate?.(["layer",f.id,S,w[E]],A,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(qP))return qP.decompose(XP,YP,_V),t[1]==="position"?XP[t[2]]:(QP.setFromQuaternion(YP,r.rotation.order),QP[t[2]]*c0.RAD2DEG);for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=c0.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let i=this.variables[r],o=i.locations?.findIndex(a=>Ot.equal(a,e));o!==void 0&&o!==-1&&i.locations.splice(o,1)}if(typeof t=="string"){let r=t,i=t;do{if(i=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[i]!==void 0&&this.variables[i].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(zt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let i=e.userAPIs[t.path[1]];if(i){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(i):a?.update(i,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let i=e.userWebhooks[t.path[1]];i&&this.getUserWebhook(t.path[1])?.update(i)}}else t.path[0]==="lib"&&this.updateLibByOp(zt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let i=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};i.update(o),i.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=WP();return r===null?($t("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=l0();return r===null?($t("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=l0();return r===null?($t("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},Sa=u0;Sa.MAX_TRANSIENT_VERTICES=6e4;var ZP=new Sa(ei.emptyData());function ws(n){return n?.isClassicNodeMaterial===!0}function JP(n){return n?.isClassicSharedMaterial===!0}function ym(n){return ws(n)||n?.isTSLNodeMaterial===!0}function $P(n){return JP(n)||n?.isTSLSharedMaterial===!0}ut();Zt();var ii=5,ic=3;var tr=class extends Je{setMaterialOverride(e,r){this.materialOverride=o0(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,i){if(super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.syncShadowCatcher(i),eA(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=i.shared.material(a);l!==s&&tr.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(zt.drop(e,1),r.material,i)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(zt.drop(e,2),a,i)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let i=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(i.flatShading,i.side,i.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(i.flatShading,i.side,i.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(i.flatShading,i.side,i.wireframe);else this.material=this.material.getFlavor(i.flatShading,i.side,i.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=_P();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=r.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 r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){ym(e)&&!$P(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&ih(this.material).forEach(e=>{tr.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};import{BufferGeometry as gm,Matrix4 as h0,Vector3 as nM,Vector4 as f0}from"three";var eM=new nM,tM=new f0,rM=new f0,FV=new nM,iM=new h0,Qe=class extends tr{constructor(e,r,i){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new h0().fromArray(r.bindMatrix),this.bindMatrixInverse=new h0)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof gm&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof gm?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Sa){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return qd.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return qd.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(zt.drop(e,1),r.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=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,r){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Wi(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&Eu(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else{let o={...this.data.geometry,...e},a=Wi(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&sm(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,i){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof xt&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&pm(e.props)&&this.geometryCreateDeleyed instanceof xt&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof gm&&!(this.geometryCreateDeleyed instanceof xt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=i.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Wi(d,a,this.data.flatShading,this);sm(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}o||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let i=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof gm&&!(this.geometryCreateDeleyed instanceof xt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Wi(o,i,this.data.flatShading,this);sm(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of i)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=r)}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,r){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),r.set(i.width,i.height,i.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,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new f0,i=this.geometry.attributes.skinWeight;for(let o=0,a=i.count;o<a;o++){r.fromBufferAttribute(i,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),i.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let i=this.skeleton;if(i===void 0)return;let o=this.geometry;tM.fromBufferAttribute(o.attributes.skinIndex,e),rM.fromBufferAttribute(o.attributes.skinWeight,e),eM.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=rM.getComponent(a);if(s!==0){let l=tM.getComponent(a);iM.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(FV.copy(eM).applyMatrix4(iM),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};import{Group as YV}from"three";import{AxesHelper as zV,Group as jV,Quaternion as HV,Vector3 as y0}from"three";import{BoxGeometry as kV}from"three";var Gn=n=>{var t;return t=class extends n{},t.geometryHelper=new kV(30,30,30),t};import{Ray as VV,Sphere as GV,Matrix4 as UV,Vector3 as Ro}from"three";var vm=new VV,m0=new GV,oM=new UV,Un=(n,t,e,r,i=!1,o=n)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),m0.copy(a.boundingSphere),m0.applyMatrix4(s),e.ray.intersectsSphere(m0)===!1||(oM.copy(s).invert(),vm.copy(e.ray).applyMatrix4(oM),a.boundingBox!==null&&vm.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(i===!1){let b=Math.max(0,f.start),x=Math.min(p.count,f.start+f.count);for(m=b,y=x;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(n,e,vm,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let x=a.attributes.position,S=new Ro,v=new Ro,w=new Ro,A=new Ro,E=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),R=M*M,D=Math.max(0,f.start),N=Math.min(x.count,f.start+f.count);for(let C=D,B=N-1;C<B;C+=E){if(S.fromBufferAttribute(x,C),v.fromBufferAttribute(x,C+1),vm.distanceSqToSegment(S,v,A,w)>R)continue;A.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(A);F<e.near||F>e.far||r.push({distance:F,point:w.clone().applyMatrix4(o.matrixWorld),object:n})}}function g(b,x,S,v,w,A,E){let P=new Ro,M=new Ro,R=new Ro,D=new Ro,N=new Ro;if(P.fromBufferAttribute(v,w),M.fromBufferAttribute(v,A),R.fromBufferAttribute(v,E),S.intersectTriangle(P,M,R,!1,D)===null)return null;N.copy(D),N.applyMatrix4(b.matrixWorld);let B=x.ray.origin.distanceTo(N);return B<x.near||B>x.far?null:{faceIndex:1,distance:B,point:N.clone(),object:b}}};var WV=new y0(1,1,1),aM=new y0,qV=new y0,sM=new HV,Xi=class extends Gn(zV){constructor(e,r=15){super(r);this.object=e;this.dummy=new jV;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Un(this.object,Xi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(aM,sM,qV),this.matrix.compose(aM,sM,WV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};import{Box3Helper as lM,BoxGeometry as XV}from"three";var bm;(t=>t.is=e=>"objectHelper"in e)(bm||(bm={}));var Yi=(n,t)=>class extends Fl(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,o){this.objectHelper.raycast(i,o)}showGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof lM&&(o.visible=!0)}}updateEntityBoxSize(i,o){this.objectHelper.visible&&this.geometryHelper instanceof XV?(i.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,o)}hideGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof lM&&(o.visible=!1)}}};var oc=class extends Yi(YV,Xi){constructor(e,r,i){super();this.super_Entity(e,r),this.context=i,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var QV=null;function cM(){return QV}var Om=Bd(uM());import{Object3D as fG,Vector3 as Lr,Euler as Mm,MathUtils as MM,Matrix4 as Xn,Quaternion as mG}from"three";var KV=.5*(Math.sqrt(3)-1),Mu=(3-Math.sqrt(3))/6,ZV=1/3,zn=1/6,Aae=(Math.sqrt(5)-1)/4,Eae=(5-Math.sqrt(5))/20,Ou=n=>Math.floor(n)|0,pM=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),v0=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function hM(n=Math.random){let t=mM(n),e=new Float64Array(t).map(i=>pM[i%12*2]),r=new Float64Array(t).map(i=>pM[i%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*KV,u=Ou(o+d),p=Ou(a+d),h=(u+p)*Mu,f=u-h,m=p-h,y=o-f,g=a-m,b,x;y>g?(b=1,x=0):(b=0,x=1);let S=y-b+Mu,v=g-x+Mu,w=y-1+2*Mu,A=g-1+2*Mu,E=u&255,P=p&255,M=.5-y*y-g*g;if(M>=0){let N=E+t[P],C=e[N],B=r[N];M*=M,s=M*M*(C*y+B*g)}let R=.5-S*S-v*v;if(R>=0){let N=E+b+t[P+x],C=e[N],B=r[N];R*=R,l=R*R*(C*S+B*v)}let D=.5-w*w-A*A;if(D>=0){let N=E+1+t[P+1],C=e[N],B=r[N];D*=D,c=D*D*(C*w+B*A)}return 70*(s+l+c)}}function fM(n=Math.random){let t=mM(n),e=new Float64Array(t).map(o=>v0[o%12*3]),r=new Float64Array(t).map(o=>v0[o%12*3+1]),i=new Float64Array(t).map(o=>v0[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*ZV,f=Ou(a+h),m=Ou(s+h),y=Ou(l+h),g=(f+m+y)*zn,b=f-g,x=m-g,S=y-g,v=a-b,w=s-x,A=l-S,E,P,M,R,D,N;v>=w?w>=A?(E=1,P=0,M=0,R=1,D=1,N=0):v>=A?(E=1,P=0,M=0,R=1,D=0,N=1):(E=0,P=0,M=1,R=1,D=0,N=1):w<A?(E=0,P=0,M=1,R=0,D=1,N=1):v<A?(E=0,P=1,M=0,R=0,D=1,N=1):(E=0,P=1,M=0,R=1,D=1,N=0);let C=v-E+zn,B=w-P+zn,_=A-M+zn,F=v-R+2*zn,V=w-D+2*zn,K=A-N+2*zn,q=v-1+3*zn,G=w-1+3*zn,W=A-1+3*zn,H=f&255,Z=m&255,te=y&255,Q=.6-v*v-w*w-A*A;if(Q<0)c=0;else{let de=H+t[Z+t[te]];Q*=Q,c=Q*Q*(e[de]*v+r[de]*w+i[de]*A)}let se=.6-C*C-B*B-_*_;if(se<0)d=0;else{let de=H+E+t[Z+P+t[te+M]];se*=se,d=se*se*(e[de]*C+r[de]*B+i[de]*_)}let oe=.6-F*F-V*V-K*K;if(oe<0)u=0;else{let de=H+R+t[Z+D+t[te+N]];oe*=oe,u=oe*oe*(e[de]*F+r[de]*V+i[de]*K)}let ne=.6-q*q-G*G-W*W;if(ne<0)p=0;else{let de=H+1+t[Z+1+t[te+1]];ne*=ne,p=ne*ne*(e[de]*q+r[de]*G+i[de]*W)}return 32*(c+d+u+p)}}function mM(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let i=r+~~(n()*(256-r)),o=e[r];e[r]=e[i],e[i]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as JV}from"three";var pn=new JV,xm=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let o=1;pn.a.fromBufferAttribute(t,i),pn.b.fromBufferAttribute(t,i+1),pn.c.fromBufferAttribute(t,i+2),o*=pn.getArea(),e[i/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,o=-1;for(;r<=i;){let a=Math.ceil((r+i)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?i=a-1:r=a+1}return o}sampleFace(t,e,r){let i=this.randomFunction(),o=this.randomFunction();return i+o>1&&(i=1-i,o=1-o),pn.a.fromBufferAttribute(this.positionAttribute,t*3),pn.b.fromBufferAttribute(this.positionAttribute,t*3+1),pn.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(pn.a,i).addScaledVector(pn.b,o).addScaledVector(pn.c,1-(i+o)),pn.getNormal(r),this}};import{Box3 as rG,Matrix4 as iG,Sphere as gM,Vector3 as nG}from"three";import{BufferAttribute as $V,Float32BufferAttribute as yM,MathUtils as b0,Vector3 as S0}from"three";function eG(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,i=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new S0(i[a],i[a+1],i[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new S0})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new yM(o,3))}function tG(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),i=new S0;for(let o=0;o<e.length;o+=3)i.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=i.x,r[o+1]=i.y,r[o+2]=i.z;n.geometry.setAttribute("extrudeNormal",new yM(r,3))}function jn(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!ws(n.material)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?tG(n):eG(n)}function x0(n){return Math.min(2047,Math.max(1,Math.round(n*2048)))/2048}function Hn(n){if(!n.geometry.attributes.position)return;let t=n.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let i=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),a=[x0(b0.seededRandom(o)),x0(b0.seededRandom(o+1e4)),x0(b0.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)i[s]=a[s%3];n.geometry.setAttribute("randomColor",new $V(i,3))}var Wn=new rG,Iu=new nG;function vM(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Bo=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new iG;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:o,subdivPointer:a}=xt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,jn(this),Hn(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(o=>o.getFlavor(!1,o.side,o.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,i=!1){r&&this.subdividedGeometry||xt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&xt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=xt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=xt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,jn(this),Hn(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,Je.prototype.raycast.call(this,e,r),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new gM,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Wn.setFromBufferAttribute(r),Wn.getCenter(i),e.boundingSphere.radius=i.distanceTo(Wn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Wn.getSize(Iu),this.hasNonUniformScale&&Iu.divide(this.scale);let o={width:Iu.x,height:Iu.y,depth:Iu.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;Wn.min.set(e[0],e[2],e[4]),Wn.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Wn.min.applyMatrix4(this.shearScaleInv),Wn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new gM);let i=r.boundingSphere.center;Wn.getCenter(i),r.boundingSphere.radius=i.distanceTo(Wn.max)}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,i=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?xt.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,jn(this),Hn(this),o!==void 0&&(this.localGeometry.userData.parameters=o),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(e,r,i){super.updateByPatchedOpGeometry(e,r,i),this.localGeometry&&(e.type===0&&e.path.length===0&&pm(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};import{Triangle as oG,Vector3 as Es}from"three";var bM=-1,aG=1,xM={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},SM={polygon_center:0,edge:1,vertex:2},Du=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,je=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-bM)*(e-r)/(aG-bM)+r},sG=new Es,Sm=new Es,lG=new Es,cG=new Es;function ac(n,t){let e=lG.fromArray(n),r=cG.fromArray(t);Sm.copy(r).sub(e);let i=Sm.length();return Sm.normalize().multiplyScalar(i*.5),sG.copy(e).add(Sm).toArray()}var Qi=new oG,wm=new Es,Am=new Es,As=new Es;function wM(n){let t=[],e=Math.floor(n.index.count/3);for(let r=0;r<e;r++)if(wm.fromArray(n.index.array,r*3),Qi.setFromAttributeAndIndices(n.attributes.position,wm.x,wm.y,wm.z),Qi.getNormal(Am),Qi.getMidpoint(As),!(isNaN(As.x)||isNaN(As.y)||isNaN(As.z))){let{a:i,b:o,c:a}=Qi,s=i.toArray(),l=o.toArray(),c=a.toArray(),d=i.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(i),h=ac(s,l),f=ac(l,c),m=ac(c,s),y=[d,u,p],g=Math.max(...y),b=y.filter(v=>Math.round(v)===Math.round(g)).length>1,x=[],S=Qi.getMidpoint(As).toArray();g===d&&!b&&(x=[f,m,m],S=h),g===u&&!b&&(x=[h,m,m],S=f),g===p&&!b&&(x=[h,f,f],S=m),b&&(x=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:x,midpoint:S,norm:Qi.getNormal(Am).toArray()})}return t}function AM(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Qi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Qi.getNormal(Am),Qi.getMidpoint(As);let i=Qi.a.toArray(),o=Qi.b.toArray(),a=Qi.c.toArray();t.push({vertices:[i,o,a],faceCenters:[ac(i,o),ac(o,a),ac(a,i)],midpoint:As.toArray(),norm:Am.toArray()})}return t}import{InstancedMesh as dG,Matrix4 as w0}from"three";var A0=class extends dG{},Em=class extends A0{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new w0;this.pivotMatrix=new w0;this.previousModelViewMatrix=new w0;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let i=this.parent;if(e&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,i,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var E0=n=>.5*(1-Math.cos(n*Math.PI)),C0=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let i=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-i,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let b=i+(o<<4)+(a<<8);d=E0(s),u=E0(l),f=this.perlin[b&4095],f+=d*(this.perlin[b+1&4095]-f),m=this.perlin[b+16&4095],m+=d*(this.perlin[b+16+1&4095]-m),f+=u*(m-f),b+=256,m=this.perlin[b&4095],m+=d*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=d*(this.perlin[b+16+1&4095]-y),m+=u*(y-m),f+=E0(c)*(m-f),p+=f*h,h*=.5,i<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(i++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},EM=C0;import{Vector3 as uG,Matrix4 as pG,Ray as hG}from"three";var CM=new uG,TM=new pG,PM=new hG,wa=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(TM.copy(i).invert(),PM.copy(e.ray).applyMatrix4(TM),PM.intersectBox(this.singleBBox,CM))){let o=CM.applyMatrix4(i),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var ni=1e-4,qn,GM,UM,zM,OM=new Lr,IM=new Lr;am.then(n=>{qn=n,GM=[qn.get_face_center,qn.get_edge_midpoint,qn.get_vertex_position],UM=[qn.get_face_normal,qn.get_edge_normal,qn.get_vertex_normal],zM=[qn.face_count,qn.edge_count,qn.vertex_count]});var Fse=new Xn,yG=new Xn,DM=new Xn,RM=new Xn,BM=new Xn,NM=new Xn,LM=new Xn,_M=new Xn,Aa=new Lr,Cm=new Lr,Ru=new Lr,T0=new Lr,gG=new Lr,FM=new Lr,Tm=new Lr,P0=new Lr,kM=new Lr,M0=new Lr,VM=new Lr,hn=new Mm,vG=new mG;function Pm(n){return n?n.version??n.data?.version??0:-1}function jt(n,t){return[typeof n?.[0]=="number"?n[0]:typeof n?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(n[0])??"0")):0,typeof n?.[1]=="number"?n[1]:typeof n?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(n[1])??"0")):0,typeof n?.[2]=="number"?n[2]:typeof n?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(n[2])??"0")):0]}var O0=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new EM;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(i,o,a)=>this.perlin.noise(i,o,a):this.noise=i=>this.perlin.noise(i)):e?this.noise=fM((0,Om.default)(t.seed)):this.noise=hM((0,Om.default)(t.seed??""))}},oi=class extends Bl(fG){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof Je&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof cr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let i=r.transformOverride;i!==void 0&&(r.position.fromArray(i.position),r.rotation.fromArray(i.rotation),r.scale.fromArray(i.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||Ei(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new Em(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let i of this.children)i.playModeVisible!==!1&&(DM.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),e.setMatrixAt(r++,DM));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let i;if(r!==void 0)i=r;else{let o=jt(this.parameters.grid.count,e);i=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)i=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==i)if(this.children.length<i)for(let o=0,a=i-this.children.length;o<a;++o){let s=new cr(this.object);s.expand(),this.add(s)}else for(;this.children.length>i;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new O0(e,r)),this.random}_updateRadial(e,r){let i=e.radial,o=i.start*MM.DEG2RAD,a=i.end*MM.DEG2RAD,s=o-a,l=jt(i.rotation,r),c=new Mm(l[0],l[1],l[2]),d;switch(i.axis){case"z":d=new Lr(0,0,1);break;case"y":d=new Lr(0,1,0);break;default:case"x":d=new Lr(1,0,0);break}let u=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=jt(i.scale,r),m=jt(i.position,r),y=jt(u.scale,r),g=jt(u.position,r),b=jt(u.rotation,r),x=s/e.count,S=Du(u.strength,this.parameters.randomness);for(let[v,w]of this.children.entries()){let A=v*(u.freqScale/10)+u.movement,E=h===null?0:h.noise(A,A,A),P=v+1;w.scale.x=f[0]+S(P,je(E,y[0]))||ni,w.scale.y=f[1]+S(P,je(E,y[1]))||ni,w.scale.z=f[2]+S(P,je(E,y[2]))||ni;let M=x*v-o;switch(i.axis){default:case"x":hn.set(0,M,0);break;case"y":hn.set(0,0,M);break;case"z":hn.set(M,0,0);break}Tm.copy(d).applyQuaternion(vG.setFromEuler(hn)).multiplyScalar(i.radius),w.position.set(Tm.x+(m[0]+S(P,je(E,g[0]))),Tm.y+(m[1]+S(P,je(E,g[1]))),Tm.z+(m[2]+S(P,je(E,g[2]))));let R=S(P,je(E,b[0])),D=S(P,je(E,b[1])),N=S(P,je(E,b[2]));i.alignment===!0?w.rotation.set(hn.x+(c.x+R),hn.y+(c.y+D),hn.z+(c.z+N)):w.rotation.set(c.x+R,c.y+D,c.z+N)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let i=e.linear,o=jt(i.rotation,r),a=jt(i.scale,r),s=jt(i.position,r),l=new Mm(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,d=jt(c.rotation,r),u=jt(c.scale,r),p=jt(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Du(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let b=y*(c.freqScale/10)+c.movement,x=f===null?0:f.noise(b,b,b),S=y+1,v=m(S,je(x,d[0])),w=m(S,je(x,d[1])),A=m(S,je(x,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,je(x,u[0]))||ni,g.scale.y=1+(a[1]-1)*y+m(S,je(x,u[1]))||ni,g.scale.z=1+(a[2]-1)*y+m(S,je(x,u[2]))||ni,g.rotation.set(l.x*y+v,l.y*y+w,l.z*y+A),g.position.x=s[0]*y+m(S,je(x,p[0])),g.position.y=s[1]*y+m(S,je(x,p[1])),g.position.z=s[2]*y+m(S,je(x,p[2]))}}_updateGrid(e,r){let i=0,o=e.grid,a=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,s=jt(a.scale,r),l=jt(a.rotation,r),c=jt(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Du(a.strength,this.parameters.randomness),h=jt(o.count,r),f=jt(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new Lr(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let b=0;b<h[1];b++)for(let x=0;x<h[2];x++){let S=this.children[i++];if(!S)continue;let v=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement,(x+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(i,je(v,s[0]))||ni,S.scale.y=1+p(i,je(v,s[1]))||ni,S.scale.z=1+p(i,je(v,s[2]))||ni;let w=p(i,je(v,l[0])),A=p(i,je(v,l[1])),E=p(i,je(v,l[2]));S.rotation.set(w,A,E),S.position.x=f[0]*g-y.x+p(i,je(v,c[0])),S.position.y=f[1]*b-y.y+p(i,je(v,c[1])),S.position.z=f[2]*x-y.z+p(i,je(v,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let b=this.children[i++];if(!b)continue;let x=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);b.scale.x=1+p(i,je(x,s[0]))||ni,b.scale.y=1+p(i,je(x,s[1]))||ni,b.scale.z=1+p(i,je(x,s[2]))||ni;let S=p(i,je(x,l[0])),v=p(i,je(x,l[1])),w=p(i,je(x,l[2]));b.rotation.set(S,v,w),b.position.x=f[0]*m+p(i,je(x,c[0])),b.position.y=-f[1]*y+p(i,je(x,c[1])),b.position.z=-f[2]*g+p(i,je(x,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:i}=e,o=jt(i.rotation,r),a=jt(i.position,r),s=jt(i.scale,r),l=new Mm(o[0],o[1],o[2]),c=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,d=jt(c.rotation,r),u=jt(c.position,r),p=jt(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Du(c.strength,this.parameters.randomness);if(!i.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof wa)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let w=Math.round(y.length*i.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=i.spreadType==="random",b=null;g&&(b=this.getSurfaceSampler(),b.setRandomGenerator((0,Om.default)(this.object.uuid+i.seed)));let x=xM[i.axis],S=this.children;Aa.fromArray(x),RM.copy(this.object.hiddenMatrix).invert();let v=this.objectForSample instanceof Bo;v&&BM.copy(this.objectForSample.matrixWorld).invert(),i.align!=="normal"&&this.object.getWorldDirection(FM),M0.set(Aa.y,Aa.z,Aa.x).normalize(),VM.copy(M0).cross(Aa).normalize(),LM.makeBasis(M0,Aa,VM).invert();for(let[w,A]of S.entries()){let E=w*(c.freqScale/10)+c.movement,P=f===null?0:f.noise(E,E,E),M=w+1,R=m(M,je(P,d[0])),D=m(M,je(P,d[1])),N=m(M,je(P,d[2]));g?b.sample(Ru,T0):(y.length&&(Ru.fromArray(y[w].pos),T0.fromArray(y[w].norm)),v&&Ru.applyMatrix4(BM)),Ru.applyMatrix4(RM),A.position.copy(Ru);let C=i.align==="normal"?T0:FM,B=Cm.fromArray(a);Cm.x+=m(M,je(P,u[0])),Cm.y+=m(M,je(P,u[1])),Cm.z+=m(M,je(P,u[2]));let _=Math.acos(C.dot(Aa)),F=gG.crossVectors(Aa,C).normalize(),V=yG.makeRotationAxis(F,_);P0.copy(C).cross(this.object.up).normalize(),kM.copy(P0).cross(C).normalize(),NM.makeBasis(P0,C,kM),_M.multiplyMatrices(NM,LM),hn.setFromRotationMatrix(_M),B.applyMatrix4(V),A.position.add(B),A.rotation.set(hn.x+l.x+R,hn.y+l.y+D,hn.z+l.z+N),A.scale.set(1+s[0]+m(M,je(P,p[0]))||ni,1+s[1]+m(M,je(P,p[1]))||ni,1+s[2]+m(M,je(P,p[2]))||ni),A.scale.multiply(this.object.scale),A.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,i=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===i&&a.positionVersion===Pm(i)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new xm(e).build();return this.surfaceSamplerCache={geometry:r,position:i,positionVersion:Pm(i),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Bo,i=this.objectForSample.geometry;if(!r&&i){let l=this.surfacePointsCache,c=i.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===i&&l.position===c&&l.positionVersion===Pm(c)&&l.index===i.index&&l.indexVersion===(i.index===null?-1:i.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=SM[e],d=zM[c],u=GM[c],p=UM[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);OM.fromArray(m).applyMatrix4(l.matrixWorld),IM.fromArray(y),a(OM.toArray(),IM.toArray())}}else(i.index?wM(i):AM(i)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&i){let l=i.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:i,position:l,positionVersion:Pm(l),index:i.index,indexVersion:i.index===null?-1:i.index.version,points:s}}return s}updateState(e,r){if(this.parameters=ya(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let i=r.scene.find(this.parameters.toObject.object);i instanceof Je?this.objectForSample=i:this.objectForSample=void 0,this.matrix=new Xn,this.hiddenMatrix=new Xn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var fn=24,dr=96,Qn=fT(),No=2;var L0=!1,YM=!0;try{let n=new URLSearchParams(window.location.search);L0=n.get("dbgsbstatic")==="0",YM=n.get("sb512")!=="0"}catch{}function xG(n){let t=n.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var _0=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(dr);this._prevReach=new Float32Array(dr);this._fieldDirtyFull=!0;this._fieldDirtyMin=new cc;this._fieldDirtyMax=new cc;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new R0;this.potentialPassScene=new R0;this.voxelPassScene=new R0;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new HM,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new I0(zl,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new N0(Qn.triTable,16,256,D0,Lo);o.needsUpdate=!0;let a=new N0(Qn.numTrisTable,256,1,D0,Lo);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new I0(zl,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new I0(zl,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=CG.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new WM({vertexShader:c.vertexShader,fragmentShader:`
729
+ `&&o.push("")):t.getTextWidth(o[o.length-1]+a,n)>i&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,n)>i&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}import{BufferGeometry as qx,BufferAttribute as CP,Uint32BufferAttribute as Xx,Float32BufferAttribute as lm,Matrix4 as SV,Vector3 as Cu,Sphere as wV,Box3 as AV,BoxGeometry as EV}from"three";var AP,am=new Promise(n=>{AP=n}),wP=!1;var om;function EP(n){if(wP)return;if(om)return om;async function t(){let r=n??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.40/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});AP(c),wP=!0}return om=t(),om}import{Matrix4 as bV}from"three";var xV=new bV;function sm(n,t){if(Object.keys(n.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(n.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let s of r){let l=n.attributes[s],c=t.attributes[s];if(l===void 0||l.isInterleavedBufferAttribute===!0||c.isInterleavedBufferAttribute===!0||l.itemSize!==c.itemSize||l.normalized!==c.normalized||l.array.constructor!==c.array.constructor||l.array.length!==c.array.length)return!1}let i=n.index,o=t.index;if(i===null!=(o===null))return!1;let a=!1;if(i!==null&&o!==null){if(i.array.length!==o.array.length)return!1;let s=i.array.constructor,l=o.array.constructor;if(s!==l){if(s!==Uint32Array||l!==Uint16Array)return!1;a=!0}}if(n.groups.length!==t.groups.length)return!1;for(let s=0;s<t.groups.length;s++){let l=n.groups[s],c=t.groups[s];if(l.start!==c.start||l.count!==c.count||l.materialIndex!==c.materialIndex)return!1}for(let s of r){let l=n.attributes[s],c=t.attributes[s];l.array.set(c.array),l.needsUpdate=!0}if(i!==null&&o!==null){if(a){let s=i.array,l=o.array;for(let c=0,d=l.length;c<d;c++){let u=l[c];s[c]=u===65535?4294967295:u}}else i.array.set(o.array);i.needsUpdate=!0}return n.drawRange.start=t.drawRange.start,n.drawRange.count=t.drawRange.count,n.userData=t.userData,n.boundingBox=null,n.boundingSphere=null,!0}function Eu(n,t,e,r){let i=n.position.array,o=n.normal.array,a=xV.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=i.length;d<u;d+=3)i[d]*=t,i[d+1]*=e,i[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var cm=new AV,tc=new Cu,Pe;am.then(n=>{Pe=n});var TP=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),PP=new Uint32Array([0,1,2,3]),MP=new Uint8Array([4]);function Jx(n){let t=Number(n);return Number.isInteger(t)&&t>=0&&String(t)===n?t:-1}function CV(n){let t=Object.keys(n),e=0;for(let i of t){let o=Jx(i);o>=e&&(e=o+1)}if(e===0||e>t.length)return;let r=new Array(e);for(let i=0;i<e;i++){let o=n[i];if(typeof o!="number")return;r[i]=o}return r}function dm(n){if(n!=null){if(Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView))return n;if(typeof n=="object")return CV(n)}}function Yx(n){if(n==null)return"missing";if(Array.isArray(n))return`Array(${n.length})`;if(ArrayBuffer.isView(n)){let l=n;return`${n.constructor.name}(${l.length})`}if(typeof n!="object")return typeof n;let t=Object.keys(n),e=t.filter(l=>Jx(l)===-1),r=0;for(let l of t){let c=Jx(l);c>=r&&(r=c+1)}let i=n,o=-1,a=-1;for(let l=0;l<r;l++)l in i?typeof i[l]!="number"&&a===-1&&(a=l):o===-1&&(o=l);let s=[`${t.length} keys`,`max index ${r-1}`];return o!==-1&&s.push(`first missing index ${o}`),a!==-1&&s.push(`non-number at ${a} (${typeof i[a]})`),e.length&&s.push(`stray keys ${e.slice(0,3).join(",")}`),`Object{${s.join(", ")}}`}var xt=class extends qx{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=_i.div(r.map(l=>typeof l=="number"?l:0),i);if(o.every(l=>l===1))return;this.subdividedGeometry&&Eu(this.subdividedGeometry.attributes,...o),this.originalGeometry&&Eu(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(tc.fromArray(o));let s=tc.set(a.width,a.height,a.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 r=e.phongAngle??35;this.flatShading&&(r=-1);let i=null;if(e.subdivisions>0){let a=0;try{a=xt.allocate(e),i=xt.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&xt.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=xt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new EV(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new wV,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;cm.setFromBufferAttribute(r),cm.getCenter(i),e.boundingSphere.radius=i.distanceTo(cm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),cm.getSize(tc);let o={width:tc.x,height:tc.y,depth:tc.z};return this.userData.parameters=o,o}static build(e,r,i,o){let a,s,l=e?.phongAngle??35;i===!1&&(l=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=xt.allocate(e,o)}catch(d){console.error(d,e),a=xt.allocate({positionWASM:TP,indexWASM:PP,verticesPerFaceWASM:MP},o)}Pe.set_destination_refinement_level(a,0);let c=xt.buildLevel(a,!0,l);return e.subdivisions>0?s=xt.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,i){try{return Pe.set_destination_refinement_level(e,r),xt.buildLevel(e,!1,i)??null}catch{try{return Pe.set_destination_refinement_level(e,r-1),xt.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,r,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 o=e.shape!==void 0||e.path!==void 0?r.geometry:Wi(e,i,!1,r),a;Sf(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=Tu(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=TV(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let i,o,a,s=[],l=[],c=dm(e.positionWASM),d=dm(e.indexWASM),u=dm(e.verticesPerFaceWASM);if(c&&c.length>0){if(!d?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${Yx(e.positionWASM)}, indexWASM ${Yx(e.indexWASM)}, verticesPerFaceWASM ${Yx(e.verticesPerFaceWASM)}`);i=c,o=d,a=u;let P=dm(e.uvWASM);Pe.alloc_subdivision_surface_uvs&&P&&P.length===o.length*2&&(l=P)}else i=TP,o=PP,a=MP;let p=i.length,h=o.length,f=a.length,m=i.length+s.length+l.length,y=o.length+a.length,g=m*Float32Array.BYTES_PER_ELEMENT+y*Uint32Array.BYTES_PER_ELEMENT,b=m*Float32Array.BYTES_PER_ELEMENT,x=Pe._malloc(g);if(!x)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let S=new Float32Array(Pe.HEAPF32.buffer,x,m),v=new Uint32Array(Pe.HEAPU32.buffer,x+b,y);S.set(i,0),S.set(s,i.length),S.set(l,i.length+s.length),v.set(o,0),v.set(a,o.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new SV().makeScale(...e.scaleBaked.map(P=>typeof P=="number"?P:1))),r&&(w?w.premultiply(r):w=r);let A=x+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,E=l.length?w?Pe.alloc_subdivision_surface_uvs2(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length,w.elements):Pe.alloc_subdivision_surface_uvs(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length):w?Pe.alloc_subdivision_surface2(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w.elements):Pe.alloc_subdivision_surface(x,p,x+b,h,x+b+o.length*Uint32Array.BYTES_PER_ELEMENT,f);return Pe._free(x),E}static buildLevel(e,r,i,o,a,s=!1){let l=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,i,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,i),c=10,d=Pe.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=Pe.HEAPU32[d[p]>>2],f=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=Pe.HEAPU32[d[p]>>2],y=Pe.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=Pe.HEAPU32[d[p]>>2],b=Pe.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let x=Pe.HEAPU32[d[p]>>2],S=Pe.HEAPU32.subarray(x>>2,(x>>2)+u[p]);p++;let v;if(Pe.alloc_subdivision_surface_uvs){let A=d[9];if(A>0){let E=Pe.HEAPU32[d[8]>>2];v=Pe.HEAPF32.subarray(E>>2,(E>>2)+A)}}if(o===void 0){let A=new qx;if(A.setIndex(new Xx(S,1)),A.setAttribute("position",new lm(f,3)),A.setAttribute("normal",new lm(y,3)),v&&A.setAttribute("uv",new lm(v,2)),r){A.setAttribute("faceMap",new Xx(b,1));let E=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new CP(E,4))}return Pe.free_mesh_data(l),A.userData.type="SubdivGeometry",A}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let A=o.getIndex();A!==null&&A.array.length===S.length&&(A.copyArray(S),A.needsUpdate=!0)}let w=o.getAttribute("uv");v&&w&&w.array.length===v.length&&(w.copyArray(v),w.needsUpdate=!0),Pe.free_mesh_data(l)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let o=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=Pe.HEAPU32[s[c]>>2],u=Pe.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=Pe.HEAPU32[s[c]>>2],h=Pe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new qx;f.setAttribute("position",new lm(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=i.r,m[y++]=i.g,m[y++]=i.b;return f.setAttribute("color",new CP(m,3)),f.setIndex(new Xx(h,1)),Pe.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,i){let o=r===0;o||Pe.set_destination_refinement_level(e,r);let a=i?Pe.get_topological_data2(e,o?Pe.Level.CONTROL:Pe.Level.REFINED,i.elements):Pe.get_topological_data(e,o?Pe.Level.CONTROL:Pe.Level.REFINED),s=8,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=Pe.HEAPU32[l[d]>>2],p=new Float32Array(Pe.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=Pe.HEAPU32[l[d]>>2],f=new Uint32Array(Pe.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=Pe.HEAPU32[l[d]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(Pe.alloc_subdivision_surface_uvs){let b=l[7];if(b>0){let x=Pe.HEAPU32[l[6]>>2];g=new Float32Array(Pe.HEAPF32.subarray(x>>2,(x>>2)+b))}}return Pe.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function pm(n){let t=Object.keys(n);return t.length===1&&t[0]==="subdivisions"}function Tu(n,t){let e=t?t.count:n.count,r=0,i=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=n.getX(u),h=n.getY(u),f=n.getZ(u),m=Math.round(p*i),y=Math.round(h*i),g=Math.round(f*i),b=o.get(m);b===void 0&&(b=new Map,o.set(m,b));let x=b.get(y);x===void 0&&(x=new Map,b.set(y,x));let S=x.get(g);S===void 0&&(S=r++,x.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var um=new Cu,Qx=new Cu,Kx=new Cu,Zx=new Cu;function TV(n,t,e,r,i){let o=[],a=[],s=i?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=i[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,b)=>Math.floor(b/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);n.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)n.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)n.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((n[t[u]*3+2]===d||n[t[u]*3+2]===0)&&p++,(n[t[u+1]*3+2]===d||n[t[u+1]*3+2]===0)&&p++,(n[t[u+2]*3+2]===d||n[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){um.set(n[t[u]*3],n[t[u]*3+1],n[t[u]*3+2]),Qx.set(n[t[u+1]*3],n[t[u+1]*3+1],n[t[u+1]*3+2]),Kx.set(n[t[u+4]*3],n[t[u+4]*3+1],n[t[u+4]*3+2]),Zx.set(n[t[u+5]*3],n[t[u+5]*3+1],n[t[u+5]*3+2]),Qx.sub(um).normalize(),Kx.sub(um).normalize(),Zx.sub(um).normalize();let p=Qx.cross(Kx).dot(Zx),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<n.length;m+=3,y++)n[m+2]===0&&(p.push(y),f++),n[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var PV={ConeGeometry:OT,CubeGeometry:IT,CylinderGeometry:zf,DodecahedronGeometry:DT,EllipseGeometry:Zl,HelixGeometry:MC,IcosahedronGeometry:aP,LatheGeometry:sP,NonParametricGeometry:dP,PolygonGeometry:im,PyramidGeometry:uP,RectangleGeometry:$l,SphereGeometry:hP,PlaneGeometry:fP,BackdropGeometry:mP,StarGeometry:nm,TextFrameGeometry:yP,TorusGeometry:gP,TorusKnotGeometry:vP,TriangleGeometry:bP,VectorGeometry:fi},hm=n=>{let t=PV[n.type]??ff(n.type);if(t===void 0)throw new Error(`No geometry factory registered for "${n.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(n)};var OV=["font"];function Wi(n,t,e,r){let i,o,a;n.type==="PathGeometry"?(o=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(o={...n},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(i in d){let u=d[i];rb(u)&&!OV.includes(i)&&(d[i]=t.getVariable(u,[r.uuid,"geometry",...c,i]),rb(d[i])&&(d[i]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry")s.path=o.path;else if(o.type==="VectorGeometry"){let c=st.createFromState(o.shape,o.width,o.height);s.shape=c}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new MV().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new xt(o,e);return c.data=n,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=ff(o.type);if(c)return c.create(o,t);$t("text",`a ${o.type}`);let d=st.createFromState(ls.defaultData(),100,100);return hm({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return $l.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=hm(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=st.createFromState(ls.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=hm(s)}return l}var $x=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let i=this.objects.get(t);return i===void 0?(i=this.createObject(t,e,r),this.objects.set(t,i)):i.isShared=!0,i}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Pu=class extends $x{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let o=Wi(e,r,this.flatShading,i);return o.computeBoundingSphere(),o}};var r0="webgl",OP,e0,IP=!1;function i0(){return r0}function RP(n){e0=n}function BP(){if(r0==="webgpu"){if(OP!==void 0)return OP;IP||(IP=!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(e0===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 e0}function fm(n,t){return BP().createRootMaterial(n,t)}function n0(n,t,e){return BP().createSharedMaterial(n,t,e)}function o0(n){return n.getLayersOfType===void 0&&Object.assign(n,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),n}var DP,NP;function LP(n){NP=n}function _P(){let n=r0==="webgpu"&&DP!==void 0?DP:NP;return n===void 0?null:o0(n())}var t0;function FP(n){t0=n}function kP(n,t){return t0===void 0?!1:t0(n,t)}var VP={markNeedsUpdateRendererDirty:()=>{}};function Vn(n,t){let e=0;if(!n.layers||n.layers.length===0)return!1;let r=n.layers?.find(i=>i.data.type==="light");if(r){let i=r.data,o=Number(t.getVariable(i.alphaOverride));if((typeof i.alphaOverride=="string"?o/100:i.alphaOverride)<1)return!0}for(let i of n.layers){if(i.data.type!=="displace"&&i.data.isMask)return!0;if(i.data.type!=="displace"&&"alpha"in i.data&&i.data.type!=="light"&&i.data.type!=="fresnel"&&i.data.type!=="cavity"&&i.data.type!=="dust"&&i.data.type!=="texture"&&i.data.type!=="matcap"&&i.data.type!=="rainbow"&&i.data.type!=="outline"&&i.data.type!=="pattern"){let o=i.data.visible?i.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&i.data.type==="depth"||i.data.type==="gradient"){for(let a of i.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&i.data.type==="noise"){let a=t.color(i.data.colorA).a,s=t.color(i.data.colorB).a,l=t.color(i.data.colorC).a,c=t.color(i.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var qi=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,ye=(n,t,e)=>typeof n=="number"?n:t.getVariable(n,e);function a0(n){let t=typeof n=="string"?n:n.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function un(n){return typeof n=="string"||typeof n=="number"&&n!==0}var rc={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},GP={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};import{Object3D as IV}from"three";var s0=class extends Bl(IV){},DV=n=>n.type==="Mesh",cr=class extends s0{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new cr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix,i.pivotMatrix=r.pivotMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1:this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||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 DV(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){}};ut();import{Euler as BV,MathUtils as c0,Matrix4 as NV,Quaternion as LV,Vector3 as KP}from"three";var UP=null,zP=null;function jP(n){UP=n}function l0(){return UP}function HP(n){zP=n}function WP(){return zP}function mm(n){return"variable_"+n}var qP=new NV,XP=new KP,YP=new LV,_V=new KP,QP=new BV,d0=class extends Gf{constructor(e){super();this.shared=e}create(e){return new jl(e,this.shared)}},u0=class{constructor(t,e={},r=!0,i=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=i;this.geometryCache=new Pu(!0);this.geometryCache2=new Pu(!1);this.imageHolderCache=new d0(this);this.thisContext={scene:VP,shared:this};this.deletedImage=new Ci(nf.emptyImage,this);this.deletedVideo=new Ci(hl.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;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=n0(qt.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:i,data:o}of t.variables)this.addVariableHolder(i,o),e&&this.updateVariableHolder(i,o);for(let[i,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(i,o);for(let[i,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(i,o);if(!r){for(let[i,o]of Object.entries(t.images))this.addImage(i,o);for(let[i,o]of Object.entries(t.videos))this.addVideo(i,o)}for(let[i,o]of Object.entries(t.colors))this.addColor(i,o);for(let[i,o]of Object.entries(t.lib.materials))this.addMaterial(i,o.asset);for(let[i,o]of Object.entries(t.materials))this.addMaterial(i,o);for(let[i,o]of Object.entries(t.audios))this.addAudio(i,o);for(let[i,o]of Object.entries(t.particles))this.addParticle(i,o);for(let[i,o]of Object.entries(t.fonts))this.addFont(i,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:qt.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=n0(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:qt.defaultTwoLayerData("phong").layers}),fm(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Ci(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Ci(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Ci(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Oo(e.r,e.g,e.b,e.a):this.colors[t]=new Oo(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Pt(0,0,0,0))}else return"a"in t?new Pt(t.r,t.g,t.b,t.a):new Pt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Io)return e;{let r=new Io({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Io&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=CT();if(r===null){$t("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Io&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let i=localStorage.getItem(mm(t));r=i!==null?JSON.parse(i):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(mm(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let i=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:i,shared:this},u=s.slice(2);i.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=i.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*c0.DEG2RAD:l[s[s.length-1]]=r}if(l=i.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),ke.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&i.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...i,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(i.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!i||!this.transientGeometryKeys.has(i)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>u0.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let w=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(w.length===0||w.length%3!==0)return!1;for(let A=0;A<w.length;A++)if(w[A]>=l)return!1;u={array:w,itemSize:1,type:w.constructor.name,normalized:!1}}else{let w=o.data,A=w?.index;if(A?.array?.length){let E=(w?.attributes?.position?.array?.length??0)/3;if(l<E){let P=A.array;for(let M=0;M<P.length;M++)if(P[M]>=l)return!1}u=A}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let w=0;w<s.length;w+=3){let A=s[w],E=s[w+1],P=s[w+2];A<p&&(p=A),A>m&&(m=A),E<h&&(h=E),E>y&&(y=E),P<f&&(f=P),P>g&&(g=P)}let b=(w,A)=>({array:w,itemSize:A,type:"Float32Array",normalized:!1}),x={position:b(s,3)};c&&(x.normal=b(c,3)),d&&(x.uv=b(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:x,...u?{index:u}:{}}},v=this.transientGeometryKeys.has(o);return r.dataPatched={...i,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,v),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let i=r.cloner;if(i===void 0)return-1;let o=i.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=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]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?i.update(this.entityOpContext):i.syncInstanceMatrices(),i.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let i=new cr(t);i.playModeVisible=e.visible!==!1,i.expand(),typeof e.name=="string"&&(i.name=e.name);let o=Math.PI/180;return i.position.copy(t.position),i.rotation.copy(t.rotation),i.scale.copy(t.scale),i.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(i.position.x=e.position.x),typeof e.position.y=="number"&&(i.position.y=e.position.y),typeof e.position.z=="number"&&(i.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(i.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(i.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(i.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(i.scale.x=e.scale.x),typeof e.scale.y=="number"&&(i.scale.y=e.scale.y),typeof e.scale.z=="number"&&(i.scale.z=e.scale.z)),i.updateMatrix(),r.add(i),i.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),i}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let i=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!i.includes(u)&&i.push(u)}if(i.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Pt(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Oo?d.setValue(u,new Pt(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of i){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:Vn(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(b=>b.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(b=>b.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=rc[f.data.type]??[],g=Object.keys(f.data);for(let[b,x]of Object.entries(h)){if(b==="id"||b==="index"||b==="type")continue;let S=g.find(w=>w===b)??g.find(w=>a(w)===a(b))??b;if(y.includes(S))continue;let v=s(x);if(v&&l(m,S,v)){c=!0;continue}if(typeof x=="number"&&isFinite(x))d.onVariableUpdate?.(["layer",f.id,S],x,o),c=!0;else if(Array.isArray(x)&&x.length<=3&&x.every(w=>typeof w=="number"&&isFinite(w))){let w=["x","y","z"];x.forEach((A,E)=>{d.onVariableUpdate?.(["layer",f.id,S,w[E]],A,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(qP))return qP.decompose(XP,YP,_V),t[1]==="position"?XP[t[2]]:(QP.setFromQuaternion(YP,r.rotation.order),QP[t[2]]*c0.RAD2DEG);for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=c0.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let i=this.variables[r],o=i.locations?.findIndex(a=>Ot.equal(a,e));o!==void 0&&o!==-1&&i.locations.splice(o,1)}if(typeof t=="string"){let r=t,i=t;do{if(i=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[i]!==void 0&&this.variables[i].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(zt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let i=e.userAPIs[t.path[1]];if(i){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(i):a?.update(i,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let i=e.userWebhooks[t.path[1]];i&&this.getUserWebhook(t.path[1])?.update(i)}}else t.path[0]==="lib"&&this.updateLibByOp(zt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let i=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};i.update(o),i.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=WP();return r===null?($t("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=l0();return r===null?($t("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=l0();return r===null?($t("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},Sa=u0;Sa.MAX_TRANSIENT_VERTICES=6e4;var ZP=new Sa(ei.emptyData());function ws(n){return n?.isClassicNodeMaterial===!0}function JP(n){return n?.isClassicSharedMaterial===!0}function ym(n){return ws(n)||n?.isTSLNodeMaterial===!0}function $P(n){return JP(n)||n?.isTSLSharedMaterial===!0}ut();Zt();var ii=5,ic=3;var tr=class extends Je{setMaterialOverride(e,r){this.materialOverride=o0(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,i){if(super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.syncShadowCatcher(i),eA(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=i.shared.material(a);l!==s&&tr.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(zt.drop(e,1),r.material,i)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(zt.drop(e,2),a,i)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let i=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(i.flatShading,i.side,i.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(i.flatShading,i.side,i.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(i.flatShading,i.side,i.wireframe);else this.material=this.material.getFlavor(i.flatShading,i.side,i.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=_P();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=r.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 r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){ym(e)&&!$P(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&ih(this.material).forEach(e=>{tr.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};import{BufferGeometry as gm,Matrix4 as h0,Vector3 as nM,Vector4 as f0}from"three";var eM=new nM,tM=new f0,rM=new f0,FV=new nM,iM=new h0,Qe=class extends tr{constructor(e,r,i){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new h0().fromArray(r.bindMatrix),this.bindMatrixInverse=new h0)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof gm&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof gm?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Sa){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return qd.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return qd.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(zt.drop(e,1),r.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=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,r){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Wi(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&Eu(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else{let o={...this.data.geometry,...e},a=Wi(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&sm(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,i){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof xt&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&pm(e.props)&&this.geometryCreateDeleyed instanceof xt&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof gm&&!(this.geometryCreateDeleyed instanceof xt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=i.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Wi(d,a,this.data.flatShading,this);sm(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}o||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let i=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof gm&&!(this.geometryCreateDeleyed instanceof xt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Wi(o,i,this.data.flatShading,this);sm(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of i)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=r)}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,r){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),r.set(i.width,i.height,i.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,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new f0,i=this.geometry.attributes.skinWeight;for(let o=0,a=i.count;o<a;o++){r.fromBufferAttribute(i,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),i.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let i=this.skeleton;if(i===void 0)return;let o=this.geometry;tM.fromBufferAttribute(o.attributes.skinIndex,e),rM.fromBufferAttribute(o.attributes.skinWeight,e),eM.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=rM.getComponent(a);if(s!==0){let l=tM.getComponent(a);iM.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(FV.copy(eM).applyMatrix4(iM),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};import{Group as YV}from"three";import{AxesHelper as zV,Group as jV,Quaternion as HV,Vector3 as y0}from"three";import{BoxGeometry as kV}from"three";var Gn=n=>{var t;return t=class extends n{},t.geometryHelper=new kV(30,30,30),t};import{Ray as VV,Sphere as GV,Matrix4 as UV,Vector3 as Ro}from"three";var vm=new VV,m0=new GV,oM=new UV,Un=(n,t,e,r,i=!1,o=n)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),m0.copy(a.boundingSphere),m0.applyMatrix4(s),e.ray.intersectsSphere(m0)===!1||(oM.copy(s).invert(),vm.copy(e.ray).applyMatrix4(oM),a.boundingBox!==null&&vm.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(i===!1){let b=Math.max(0,f.start),x=Math.min(p.count,f.start+f.count);for(m=b,y=x;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(n,e,vm,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let x=a.attributes.position,S=new Ro,v=new Ro,w=new Ro,A=new Ro,E=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),R=M*M,D=Math.max(0,f.start),N=Math.min(x.count,f.start+f.count);for(let C=D,B=N-1;C<B;C+=E){if(S.fromBufferAttribute(x,C),v.fromBufferAttribute(x,C+1),vm.distanceSqToSegment(S,v,A,w)>R)continue;A.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(A);F<e.near||F>e.far||r.push({distance:F,point:w.clone().applyMatrix4(o.matrixWorld),object:n})}}function g(b,x,S,v,w,A,E){let P=new Ro,M=new Ro,R=new Ro,D=new Ro,N=new Ro;if(P.fromBufferAttribute(v,w),M.fromBufferAttribute(v,A),R.fromBufferAttribute(v,E),S.intersectTriangle(P,M,R,!1,D)===null)return null;N.copy(D),N.applyMatrix4(b.matrixWorld);let B=x.ray.origin.distanceTo(N);return B<x.near||B>x.far?null:{faceIndex:1,distance:B,point:N.clone(),object:b}}};var WV=new y0(1,1,1),aM=new y0,qV=new y0,sM=new HV,Xi=class extends Gn(zV){constructor(e,r=15){super(r);this.object=e;this.dummy=new jV;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Un(this.object,Xi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(aM,sM,qV),this.matrix.compose(aM,sM,WV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};import{Box3Helper as lM,BoxGeometry as XV}from"three";var bm;(t=>t.is=e=>"objectHelper"in e)(bm||(bm={}));var Yi=(n,t)=>class extends Fl(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,o){this.objectHelper.raycast(i,o)}showGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof lM&&(o.visible=!0)}}updateEntityBoxSize(i,o){this.objectHelper.visible&&this.geometryHelper instanceof XV?(i.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,o)}hideGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof lM&&(o.visible=!1)}}};var oc=class extends Yi(YV,Xi){constructor(e,r,i){super();this.super_Entity(e,r),this.context=i,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var QV=null;function cM(){return QV}var Om=Bd(uM());import{Object3D as fG,Vector3 as Lr,Euler as Mm,MathUtils as MM,Matrix4 as Xn,Quaternion as mG}from"three";var KV=.5*(Math.sqrt(3)-1),Mu=(3-Math.sqrt(3))/6,ZV=1/3,zn=1/6,Aae=(Math.sqrt(5)-1)/4,Eae=(5-Math.sqrt(5))/20,Ou=n=>Math.floor(n)|0,pM=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),v0=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function hM(n=Math.random){let t=mM(n),e=new Float64Array(t).map(i=>pM[i%12*2]),r=new Float64Array(t).map(i=>pM[i%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*KV,u=Ou(o+d),p=Ou(a+d),h=(u+p)*Mu,f=u-h,m=p-h,y=o-f,g=a-m,b,x;y>g?(b=1,x=0):(b=0,x=1);let S=y-b+Mu,v=g-x+Mu,w=y-1+2*Mu,A=g-1+2*Mu,E=u&255,P=p&255,M=.5-y*y-g*g;if(M>=0){let N=E+t[P],C=e[N],B=r[N];M*=M,s=M*M*(C*y+B*g)}let R=.5-S*S-v*v;if(R>=0){let N=E+b+t[P+x],C=e[N],B=r[N];R*=R,l=R*R*(C*S+B*v)}let D=.5-w*w-A*A;if(D>=0){let N=E+1+t[P+1],C=e[N],B=r[N];D*=D,c=D*D*(C*w+B*A)}return 70*(s+l+c)}}function fM(n=Math.random){let t=mM(n),e=new Float64Array(t).map(o=>v0[o%12*3]),r=new Float64Array(t).map(o=>v0[o%12*3+1]),i=new Float64Array(t).map(o=>v0[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*ZV,f=Ou(a+h),m=Ou(s+h),y=Ou(l+h),g=(f+m+y)*zn,b=f-g,x=m-g,S=y-g,v=a-b,w=s-x,A=l-S,E,P,M,R,D,N;v>=w?w>=A?(E=1,P=0,M=0,R=1,D=1,N=0):v>=A?(E=1,P=0,M=0,R=1,D=0,N=1):(E=0,P=0,M=1,R=1,D=0,N=1):w<A?(E=0,P=0,M=1,R=0,D=1,N=1):v<A?(E=0,P=1,M=0,R=0,D=1,N=1):(E=0,P=1,M=0,R=1,D=1,N=0);let C=v-E+zn,B=w-P+zn,_=A-M+zn,F=v-R+2*zn,V=w-D+2*zn,K=A-N+2*zn,q=v-1+3*zn,G=w-1+3*zn,W=A-1+3*zn,H=f&255,Z=m&255,te=y&255,Q=.6-v*v-w*w-A*A;if(Q<0)c=0;else{let de=H+t[Z+t[te]];Q*=Q,c=Q*Q*(e[de]*v+r[de]*w+i[de]*A)}let se=.6-C*C-B*B-_*_;if(se<0)d=0;else{let de=H+E+t[Z+P+t[te+M]];se*=se,d=se*se*(e[de]*C+r[de]*B+i[de]*_)}let oe=.6-F*F-V*V-K*K;if(oe<0)u=0;else{let de=H+R+t[Z+D+t[te+N]];oe*=oe,u=oe*oe*(e[de]*F+r[de]*V+i[de]*K)}let ne=.6-q*q-G*G-W*W;if(ne<0)p=0;else{let de=H+1+t[Z+1+t[te+1]];ne*=ne,p=ne*ne*(e[de]*q+r[de]*G+i[de]*W)}return 32*(c+d+u+p)}}function mM(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let i=r+~~(n()*(256-r)),o=e[r];e[r]=e[i],e[i]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as JV}from"three";var pn=new JV,xm=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let o=1;pn.a.fromBufferAttribute(t,i),pn.b.fromBufferAttribute(t,i+1),pn.c.fromBufferAttribute(t,i+2),o*=pn.getArea(),e[i/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,o=-1;for(;r<=i;){let a=Math.ceil((r+i)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?i=a-1:r=a+1}return o}sampleFace(t,e,r){let i=this.randomFunction(),o=this.randomFunction();return i+o>1&&(i=1-i,o=1-o),pn.a.fromBufferAttribute(this.positionAttribute,t*3),pn.b.fromBufferAttribute(this.positionAttribute,t*3+1),pn.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(pn.a,i).addScaledVector(pn.b,o).addScaledVector(pn.c,1-(i+o)),pn.getNormal(r),this}};import{Box3 as rG,Matrix4 as iG,Sphere as gM,Vector3 as nG}from"three";import{BufferAttribute as $V,Float32BufferAttribute as yM,MathUtils as b0,Vector3 as S0}from"three";function eG(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,i=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new S0(i[a],i[a+1],i[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new S0})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new yM(o,3))}function tG(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),i=new S0;for(let o=0;o<e.length;o+=3)i.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=i.x,r[o+1]=i.y,r[o+2]=i.z;n.geometry.setAttribute("extrudeNormal",new yM(r,3))}function jn(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!ws(n.material)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?tG(n):eG(n)}function x0(n){return Math.min(2047,Math.max(1,Math.round(n*2048)))/2048}function Hn(n){if(!n.geometry.attributes.position)return;let t=n.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let i=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),a=[x0(b0.seededRandom(o)),x0(b0.seededRandom(o+1e4)),x0(b0.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)i[s]=a[s%3];n.geometry.setAttribute("randomColor",new $V(i,3))}var Wn=new rG,Iu=new nG;function vM(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Bo=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new iG;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:o,subdivPointer:a}=xt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,jn(this),Hn(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(o=>o.getFlavor(!1,o.side,o.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,i=!1){r&&this.subdividedGeometry||xt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&xt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=xt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=xt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,jn(this),Hn(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,Je.prototype.raycast.call(this,e,r),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new gM,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Wn.setFromBufferAttribute(r),Wn.getCenter(i),e.boundingSphere.radius=i.distanceTo(Wn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Wn.getSize(Iu),this.hasNonUniformScale&&Iu.divide(this.scale);let o={width:Iu.x,height:Iu.y,depth:Iu.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;Wn.min.set(e[0],e[2],e[4]),Wn.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Wn.min.applyMatrix4(this.shearScaleInv),Wn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new gM);let i=r.boundingSphere.center;Wn.getCenter(i),r.boundingSphere.radius=i.distanceTo(Wn.max)}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,i=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?xt.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,jn(this),Hn(this),o!==void 0&&(this.localGeometry.userData.parameters=o),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(e,r,i){super.updateByPatchedOpGeometry(e,r,i),this.localGeometry&&(e.type===0&&e.path.length===0&&pm(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};import{Triangle as oG,Vector3 as Es}from"three";var bM=-1,aG=1,xM={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},SM={polygon_center:0,edge:1,vertex:2},Du=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,je=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-bM)*(e-r)/(aG-bM)+r},sG=new Es,Sm=new Es,lG=new Es,cG=new Es;function ac(n,t){let e=lG.fromArray(n),r=cG.fromArray(t);Sm.copy(r).sub(e);let i=Sm.length();return Sm.normalize().multiplyScalar(i*.5),sG.copy(e).add(Sm).toArray()}var Qi=new oG,wm=new Es,Am=new Es,As=new Es;function wM(n){let t=[],e=Math.floor(n.index.count/3);for(let r=0;r<e;r++)if(wm.fromArray(n.index.array,r*3),Qi.setFromAttributeAndIndices(n.attributes.position,wm.x,wm.y,wm.z),Qi.getNormal(Am),Qi.getMidpoint(As),!(isNaN(As.x)||isNaN(As.y)||isNaN(As.z))){let{a:i,b:o,c:a}=Qi,s=i.toArray(),l=o.toArray(),c=a.toArray(),d=i.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(i),h=ac(s,l),f=ac(l,c),m=ac(c,s),y=[d,u,p],g=Math.max(...y),b=y.filter(v=>Math.round(v)===Math.round(g)).length>1,x=[],S=Qi.getMidpoint(As).toArray();g===d&&!b&&(x=[f,m,m],S=h),g===u&&!b&&(x=[h,m,m],S=f),g===p&&!b&&(x=[h,f,f],S=m),b&&(x=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:x,midpoint:S,norm:Qi.getNormal(Am).toArray()})}return t}function AM(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Qi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Qi.getNormal(Am),Qi.getMidpoint(As);let i=Qi.a.toArray(),o=Qi.b.toArray(),a=Qi.c.toArray();t.push({vertices:[i,o,a],faceCenters:[ac(i,o),ac(o,a),ac(a,i)],midpoint:As.toArray(),norm:Am.toArray()})}return t}import{InstancedMesh as dG,Matrix4 as w0}from"three";var A0=class extends dG{},Em=class extends A0{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new w0;this.pivotMatrix=new w0;this.previousModelViewMatrix=new w0;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let i=this.parent;if(e&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,i,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var E0=n=>.5*(1-Math.cos(n*Math.PI)),C0=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let i=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-i,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let b=i+(o<<4)+(a<<8);d=E0(s),u=E0(l),f=this.perlin[b&4095],f+=d*(this.perlin[b+1&4095]-f),m=this.perlin[b+16&4095],m+=d*(this.perlin[b+16+1&4095]-m),f+=u*(m-f),b+=256,m=this.perlin[b&4095],m+=d*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=d*(this.perlin[b+16+1&4095]-y),m+=u*(y-m),f+=E0(c)*(m-f),p+=f*h,h*=.5,i<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(i++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},EM=C0;import{Vector3 as uG,Matrix4 as pG,Ray as hG}from"three";var CM=new uG,TM=new pG,PM=new hG,wa=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(TM.copy(i).invert(),PM.copy(e.ray).applyMatrix4(TM),PM.intersectBox(this.singleBBox,CM))){let o=CM.applyMatrix4(i),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var ni=1e-4,qn,GM,UM,zM,OM=new Lr,IM=new Lr;am.then(n=>{qn=n,GM=[qn.get_face_center,qn.get_edge_midpoint,qn.get_vertex_position],UM=[qn.get_face_normal,qn.get_edge_normal,qn.get_vertex_normal],zM=[qn.face_count,qn.edge_count,qn.vertex_count]});var Fse=new Xn,yG=new Xn,DM=new Xn,RM=new Xn,BM=new Xn,NM=new Xn,LM=new Xn,_M=new Xn,Aa=new Lr,Cm=new Lr,Ru=new Lr,T0=new Lr,gG=new Lr,FM=new Lr,Tm=new Lr,P0=new Lr,kM=new Lr,M0=new Lr,VM=new Lr,hn=new Mm,vG=new mG;function Pm(n){return n?n.version??n.data?.version??0:-1}function jt(n,t){return[typeof n?.[0]=="number"?n[0]:typeof n?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(n[0])??"0")):0,typeof n?.[1]=="number"?n[1]:typeof n?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(n[1])??"0")):0,typeof n?.[2]=="number"?n[2]:typeof n?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(n[2])??"0")):0]}var O0=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new EM;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(i,o,a)=>this.perlin.noise(i,o,a):this.noise=i=>this.perlin.noise(i)):e?this.noise=fM((0,Om.default)(t.seed)):this.noise=hM((0,Om.default)(t.seed??""))}},oi=class extends Bl(fG){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof Je&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof cr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let i=r.transformOverride;i!==void 0&&(r.position.fromArray(i.position),r.rotation.fromArray(i.rotation),r.scale.fromArray(i.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||Ei(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new Em(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let i of this.children)i.playModeVisible!==!1&&(DM.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),e.setMatrixAt(r++,DM));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let i;if(r!==void 0)i=r;else{let o=jt(this.parameters.grid.count,e);i=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)i=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==i)if(this.children.length<i)for(let o=0,a=i-this.children.length;o<a;++o){let s=new cr(this.object);s.expand(),this.add(s)}else for(;this.children.length>i;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new O0(e,r)),this.random}_updateRadial(e,r){let i=e.radial,o=i.start*MM.DEG2RAD,a=i.end*MM.DEG2RAD,s=o-a,l=jt(i.rotation,r),c=new Mm(l[0],l[1],l[2]),d;switch(i.axis){case"z":d=new Lr(0,0,1);break;case"y":d=new Lr(0,1,0);break;default:case"x":d=new Lr(1,0,0);break}let u=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=jt(i.scale,r),m=jt(i.position,r),y=jt(u.scale,r),g=jt(u.position,r),b=jt(u.rotation,r),x=s/e.count,S=Du(u.strength,this.parameters.randomness);for(let[v,w]of this.children.entries()){let A=v*(u.freqScale/10)+u.movement,E=h===null?0:h.noise(A,A,A),P=v+1;w.scale.x=f[0]+S(P,je(E,y[0]))||ni,w.scale.y=f[1]+S(P,je(E,y[1]))||ni,w.scale.z=f[2]+S(P,je(E,y[2]))||ni;let M=x*v-o;switch(i.axis){default:case"x":hn.set(0,M,0);break;case"y":hn.set(0,0,M);break;case"z":hn.set(M,0,0);break}Tm.copy(d).applyQuaternion(vG.setFromEuler(hn)).multiplyScalar(i.radius),w.position.set(Tm.x+(m[0]+S(P,je(E,g[0]))),Tm.y+(m[1]+S(P,je(E,g[1]))),Tm.z+(m[2]+S(P,je(E,g[2]))));let R=S(P,je(E,b[0])),D=S(P,je(E,b[1])),N=S(P,je(E,b[2]));i.alignment===!0?w.rotation.set(hn.x+(c.x+R),hn.y+(c.y+D),hn.z+(c.z+N)):w.rotation.set(c.x+R,c.y+D,c.z+N)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let i=e.linear,o=jt(i.rotation,r),a=jt(i.scale,r),s=jt(i.position,r),l=new Mm(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,d=jt(c.rotation,r),u=jt(c.scale,r),p=jt(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Du(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let b=y*(c.freqScale/10)+c.movement,x=f===null?0:f.noise(b,b,b),S=y+1,v=m(S,je(x,d[0])),w=m(S,je(x,d[1])),A=m(S,je(x,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,je(x,u[0]))||ni,g.scale.y=1+(a[1]-1)*y+m(S,je(x,u[1]))||ni,g.scale.z=1+(a[2]-1)*y+m(S,je(x,u[2]))||ni,g.rotation.set(l.x*y+v,l.y*y+w,l.z*y+A),g.position.x=s[0]*y+m(S,je(x,p[0])),g.position.y=s[1]*y+m(S,je(x,p[1])),g.position.z=s[2]*y+m(S,je(x,p[2]))}}_updateGrid(e,r){let i=0,o=e.grid,a=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,s=jt(a.scale,r),l=jt(a.rotation,r),c=jt(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Du(a.strength,this.parameters.randomness),h=jt(o.count,r),f=jt(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new Lr(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let b=0;b<h[1];b++)for(let x=0;x<h[2];x++){let S=this.children[i++];if(!S)continue;let v=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement,(x+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(i,je(v,s[0]))||ni,S.scale.y=1+p(i,je(v,s[1]))||ni,S.scale.z=1+p(i,je(v,s[2]))||ni;let w=p(i,je(v,l[0])),A=p(i,je(v,l[1])),E=p(i,je(v,l[2]));S.rotation.set(w,A,E),S.position.x=f[0]*g-y.x+p(i,je(v,c[0])),S.position.y=f[1]*b-y.y+p(i,je(v,c[1])),S.position.z=f[2]*x-y.z+p(i,je(v,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let b=this.children[i++];if(!b)continue;let x=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);b.scale.x=1+p(i,je(x,s[0]))||ni,b.scale.y=1+p(i,je(x,s[1]))||ni,b.scale.z=1+p(i,je(x,s[2]))||ni;let S=p(i,je(x,l[0])),v=p(i,je(x,l[1])),w=p(i,je(x,l[2]));b.rotation.set(S,v,w),b.position.x=f[0]*m+p(i,je(x,c[0])),b.position.y=-f[1]*y+p(i,je(x,c[1])),b.position.z=-f[2]*g+p(i,je(x,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:i}=e,o=jt(i.rotation,r),a=jt(i.position,r),s=jt(i.scale,r),l=new Mm(o[0],o[1],o[2]),c=e.randomnessObject??Tn.defaultData([1,1,1]).randomnessObject,d=jt(c.rotation,r),u=jt(c.position,r),p=jt(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Du(c.strength,this.parameters.randomness);if(!i.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof wa)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let w=Math.round(y.length*i.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=i.spreadType==="random",b=null;g&&(b=this.getSurfaceSampler(),b.setRandomGenerator((0,Om.default)(this.object.uuid+i.seed)));let x=xM[i.axis],S=this.children;Aa.fromArray(x),RM.copy(this.object.hiddenMatrix).invert();let v=this.objectForSample instanceof Bo;v&&BM.copy(this.objectForSample.matrixWorld).invert(),i.align!=="normal"&&this.object.getWorldDirection(FM),M0.set(Aa.y,Aa.z,Aa.x).normalize(),VM.copy(M0).cross(Aa).normalize(),LM.makeBasis(M0,Aa,VM).invert();for(let[w,A]of S.entries()){let E=w*(c.freqScale/10)+c.movement,P=f===null?0:f.noise(E,E,E),M=w+1,R=m(M,je(P,d[0])),D=m(M,je(P,d[1])),N=m(M,je(P,d[2]));g?b.sample(Ru,T0):(y.length&&(Ru.fromArray(y[w].pos),T0.fromArray(y[w].norm)),v&&Ru.applyMatrix4(BM)),Ru.applyMatrix4(RM),A.position.copy(Ru);let C=i.align==="normal"?T0:FM,B=Cm.fromArray(a);Cm.x+=m(M,je(P,u[0])),Cm.y+=m(M,je(P,u[1])),Cm.z+=m(M,je(P,u[2]));let _=Math.acos(C.dot(Aa)),F=gG.crossVectors(Aa,C).normalize(),V=yG.makeRotationAxis(F,_);P0.copy(C).cross(this.object.up).normalize(),kM.copy(P0).cross(C).normalize(),NM.makeBasis(P0,C,kM),_M.multiplyMatrices(NM,LM),hn.setFromRotationMatrix(_M),B.applyMatrix4(V),A.position.add(B),A.rotation.set(hn.x+l.x+R,hn.y+l.y+D,hn.z+l.z+N),A.scale.set(1+s[0]+m(M,je(P,p[0]))||ni,1+s[1]+m(M,je(P,p[1]))||ni,1+s[2]+m(M,je(P,p[2]))||ni),A.scale.multiply(this.object.scale),A.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,i=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===i&&a.positionVersion===Pm(i)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new xm(e).build();return this.surfaceSamplerCache={geometry:r,position:i,positionVersion:Pm(i),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Bo,i=this.objectForSample.geometry;if(!r&&i){let l=this.surfacePointsCache,c=i.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===i&&l.position===c&&l.positionVersion===Pm(c)&&l.index===i.index&&l.indexVersion===(i.index===null?-1:i.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=SM[e],d=zM[c],u=GM[c],p=UM[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);OM.fromArray(m).applyMatrix4(l.matrixWorld),IM.fromArray(y),a(OM.toArray(),IM.toArray())}}else(i.index?wM(i):AM(i)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&i){let l=i.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:i,position:l,positionVersion:Pm(l),index:i.index,indexVersion:i.index===null?-1:i.index.version,points:s}}return s}updateState(e,r){if(this.parameters=ya(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let i=r.scene.find(this.parameters.toObject.object);i instanceof Je?this.objectForSample=i:this.objectForSample=void 0,this.matrix=new Xn,this.hiddenMatrix=new Xn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var fn=24,dr=96,Qn=fT(),No=2;var L0=!1,YM=!0;try{let n=new URLSearchParams(window.location.search);L0=n.get("dbgsbstatic")==="0",YM=n.get("sb512")!=="0"}catch{}function xG(n){let t=n.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var _0=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(dr);this._prevReach=new Float32Array(dr);this._fieldDirtyFull=!0;this._fieldDirtyMin=new cc;this._fieldDirtyMax=new cc;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new R0;this.potentialPassScene=new R0;this.voxelPassScene=new R0;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new HM,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new I0(zl,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new N0(Qn.triTable,16,256,D0,Lo);o.needsUpdate=!0;let a=new N0(Qn.numTrisTable,256,1,D0,Lo);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new I0(zl,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new I0(zl,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=CG.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new WM({vertexShader:c.vertexShader,fragmentShader:`
730
730
  #include <packing>
731
731
  void main()
732
732
  {
@@ -1309,7 +1309,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
1309
1309
  gl_FragColor = texture(inputTexture, vUv);
1310
1310
  gVelocity = vec4(0.0);
1311
1311
  }
1312
- `,r.pyramidTextureSize.value=new B0(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=i,this.material.root.shapeBlendhack=i}dispose(){super.dispose(),cM()?.release(this)}},Nu=_0;Nu.streamCompaction=new Ff;var SG=new qM,wG=new qM,sc=new XM,Cs=new cc,Im=new cc,AG=new XM;function EG(n,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Po.is(r)&&QM.call(r,n,t+1)}}function QM(n,t=0){if(n(this,t)!==!0){let r=this.children.length;for(;r--;){let i=this.children[r];Po.is(i)&&QM.call(i,n,t+1)}}}function CG(){if(this.shapesDataTexture.value===void 0){let y=new N0(new Float32Array(4*dr*Mo),dr,Mo,lc,Lo);this.shapesDataTexture.value=y}let n=this.shapesDataTexture.value,t=n.image.data,e=0,r=0,i=this.data.geometry.blendRange,o=SG.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(EG.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof oi)return;if(y instanceof oc||eu(y))return;y instanceof cr?g=y.object:g=y;let b=y.data?.cloner;if(ke.is(y)&&b&&!b.hideBase&&b.type!=="radial"&&b.disabled!==!0||!(g instanceof Qe))return;let x=g.geometry.userData.parameters,S=x?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(wG.multiplyMatrices(o,y.matrixWorld).decompose(Im,sc,Cs),x?.type==="TorusGeometry"&&x.arc!==360){let C=x.arc*Math.PI/180;C=C/4,sc.multiply(AG.set(0,0,Math.sin(C),Math.cos(C)))}let w=S.overrideGlobalBlend?S.blendRange:i;w=w/this.bboxSize*2,t[s*4]=(Im.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Im.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Im.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[dr*4+s*4]=-sc.x,t[dr*4+s*4+1]=-sc.y,t[dr*4+s*4+2]=-sc.z,t[dr*4+s*4+3]=sc.w;let A=new Float32Array(4),E=0,P=w;if(x?.type==="SphereGeometry")x.width===x.height&&x.width===x.depth?A[0]=0:A[0]=1,A[1]=x.width/this.bboxSize,A[2]=x.height/this.bboxSize,A[3]=x.depth/this.bboxSize,P=Math.max(A[1],A[2],A[3])*Cs.x+w;else if(x?.type==="CubeGeometry"){E=x.cornerRadius;let C=x.width,B=x.height,_=x.depth;A[0]=2,A[1]=(C-2*E)/this.bboxSize,A[2]=(B-2*E)/this.bboxSize,A[3]=(_-2*E)/this.bboxSize,P=Math.sqrt(C**2+B**2+_**2)/this.bboxSize*Cs.x+w}else if(x?.type==="CylinderGeometry"){E=x.cornerRadius;let C=x.height,B=x.radiusBottom,_=x.radiusTop;if(_>=B){let F=Math.atan2(_-B,C),V=(Math.PI/2-F)/2;_-=E/Math.tan(V),B-=E*Math.tan(V)}else if(B>_){let F=Math.atan2(B-_,C),V=(Math.PI/2-F)/2;_-=E*Math.tan(V),B-=E/Math.tan(V)}A[1]=(x.height-2*E)/this.bboxSize,B===_?(A[0]=3,A[2]=B/this.bboxSize*2):(A[0]=4,A[2]=B/this.bboxSize*2,A[3]=_/this.bboxSize*2),P=(Math.hypot(A[1],Math.max(Math.abs(A[2]),Math.abs(A[3])))+E/this.bboxSize*2)*Cs.x+w}else if(x?.type==="TorusGeometry"){if(A[0]=5,A[1]=(x.width-x.depth)/this.bboxSize,A[2]=x.depth/this.bboxSize,x.arc!==360){A[0]=6,A[3]=A[1],t[dr*12+s*4+3]=A[2];let C=2*Math.atan2(A[2]/2,A[1]),B=x.arc*Math.PI/180/2-C;A[1]=Math.sin(B),A[2]=Math.cos(B)}P=x.width*Cs.x/this.bboxSize+w}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=xG(C);if((B===void 0||B.posVersion!==_)&&this._meshSdfWanted.set(C.uuid,C),B===void 0)return;A[0]=7,A[1]=B.slot,A[2]=B.boxHalf.x/this.bboxSize*2,A[3]=B.boxHalf.y/this.bboxSize*2,t[dr*12+s*4+3]=B.boxHalf.z/this.bboxSize*2,P=Math.hypot(B.boxHalf.x,B.boxHalf.y,B.boxHalf.z)/this.bboxSize*2*Cs.x+w}t.set(A,dr*8+s*4),e=Math.max(e,P),r=Math.max(r,w),this._reach[s]=P,t[dr*12+s*4]=w,t[dr*12+s*4+1]=E/this.bboxSize*2,t[dr*12+s*4+2]=Cs.x;let M=Array.isArray(g.material)?g.material[0]:g.material,R=M,D,N;if(R?.getShapeBlendBaseColor){let C=R.getShapeBlendBaseColor();D=C,N=C.a}else M?.uniforms?.nodeU0!==void 0?(D=M.uniforms.nodeU0.node.value,N=M.uniforms.nodeU1?.value??1):(D={r:1,g:1,b:1},N=1);S.operation!==0&&!S.useColor&&(N=-1),t[dr*16+s*4]=D.r,t[dr*16+s*4+1]=D.g,t[dr*16+s*4+2]=D.b,t[dr*16+s*4+3]=N,N<1&&this.material.defines?.SHAPEBLEND_C===1&&(this.material.transparent=!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||L0,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let b=!1;for(let R=0;R<Mo;R++){let D=dr*4*R+g*4;if(t[D]!==d[D]||t[D+1]!==d[D+1]||t[D+2]!==d[D+2]||t[D+3]!==d[D+3]){b=!0;break}}if(!b)continue;if(p=!0,h)break;let x=t[g*4],S=t[g*4+1],v=t[g*4+2],w=d[g*4],A=d[g*4+1],E=d[g*4+2],P=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(x+S+v+P)||!Number.isFinite(w+A+E+M)){h=!0;continue}f.x=Math.min(f.x,x-P,w-M),f.y=Math.min(f.y,S-P,A-M),f.z=Math.min(f.z,v-P,E-M),m.x=Math.max(m.x,x+P,w+M),m.y=Math.max(m.y,S+P,A+M),m.z=Math.max(m.z,v+P,E+M)}}return L0&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,n.needsUpdate=!0),p}Ui("ShapeBlendGeometry",(n,t,e)=>new Nu(n,t,e));Oe("shape-blends");var Dm=class extends Qe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?su(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Ui("VectorGeometry",(n,t,e)=>new Dm(n,t,e));Oe("vector-shapes");var Rm=class extends Qe{constructor(e,r,i){super(e,r,i);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=i}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=$l;break;case"Ellipse":o=Zl;break;case"Polygon":o=im;break;case"Star":o=nm;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let i=this.geometry;r&&i.inputs&&(i.inputs.shapeData=r,i.build())}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let i in e)if(!Object.is(e[i],r[i]))return!1;for(let i in r)if(!(i in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let i=this.geometry.getAttribute("position");i!==void 0&&i.count>0?su(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,r):super.updateEntityBoxSize(e,r)}};import{Vector2 as TG,Vector3 as ur,Matrix3 as PG,Matrix4 as Ts,BufferGeometry as t2,BufferAttribute as Kn,MathUtils as Bm}from"three";function KM(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var MG=new Ts,OG=new Ts,IG=new Ts,ZM=new ur,JM=new ur,F0=new ur,DG=new ur,RG=new ur,BG=new ur,NG=new ur,$M=new WeakMap,k0=new WeakMap,e2=new WeakMap;function LG(n,t,e){let r=[new ur,new ur,new ur],i=[new ur,new ur,new ur];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((o,a)=>{let s=i[a],l=Bm.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new Ts().makeBasis(r[0],r[1],r[2])}function r2(n){n.setIndex(null),n.setAttribute("position",new Kn(new Float32Array(0),3)),n.setAttribute("normal",new Kn(new Float32Array(0),3)),n.setAttribute("uv",new Kn(new Float32Array(0),2)),n.setDrawRange(0,0)}var i2=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=t?.shapeData??Zl.create({parameters:{...cs,width:typeof cs.width=="number"?cs.width:100,height:typeof cs.height=="number"?cs.height:100}}).userData.shape;return{path:n.path??fl.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:o,extrusion:{...qh,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new V0(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else{let e=new t2;return r2(e),Object.assign(e,{userData:{...n,type:"PathGeometry"}})}}},V0=class extends t2{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!KM(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){r2(this);return}let{depth:i,offset:o}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((i+o)*a):Math.ceil(Math.min(1,i+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let H=0;H<c;H++){let Z=this.inputs.path.isClosed?(H+s)%e.length:Math.min(H+s,e.length-1);d.push(e[Z].clone()),u.push(r[Z].clone())}let p=(H,Z,te)=>{d[H]=d[H].clone().lerp(d[Z],te),u[H]=LG(u[H],u[Z],te)},h=0,f=o*a%1;(!this.inputs.path.isClosed||i<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+i)*a%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&o+i<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),i===0){let H=d.length-1;d[H].copy(d[0]),u[H].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,x=g>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:v,infos:w,vertices:A}=this._getShapePoints(S),E=0,P;if(x==="round"){let H=this.inputs.shapeData,Z=e2.get(H);Z!==void 0&&Z.bevel===g&&Z.curveSegments===S&&Z.bevelSides===b?P=Z.geometry:(P=new xa(H,2*g,g,S,b,void 0,!0),e2.set(H,{bevel:g,curveSegments:S,bevelSides:b,geometry:P})),E=P.getAttribute("position").count}let M=0,R=0;w.sort((H,Z)=>H.start-Z.start),w.forEach(H=>{H.verticesStart=M,H.verticesCount=H.continuous.reduce((Z,te,Q)=>Z+(Q===0||!te?2:1),0),R+=H.verticesCount,M=R});let D=R*c,N,C=0;this._isOpenEnded()&&x==="flat"&&(N=this._getSurfaceTesselation(v),C=N.vertexCount);let B=D+2*C+E*2,_=D+2*C,F={positions:new Float32Array(B*3),normals:new Float32Array(B*3),uvs:new Float32Array(B*2)},V=P?P.getIndex().array:null,K=0;w.forEach(H=>{K+=H.count});let q=K*(c-1)*6+(N?2*N.elementCount*3:0)+(V?2*V.length:0),G=new Uint32Array(q),W=0;if(w.forEach(H=>{W=this._extrudeRegion(H,A,u,d,F,G,W,this._isGeometryClosed()&&!this._isOpenEnded())}),N&&(W=this._closeEnd(N,D,G,W,F,u[0],d[0],!1),W=this._closeEnd(N,D+C,G,W,F,u[u.length-1],d[d.length-1],!0)),P){F.positions.set(P.getAttribute("position").array,_*3),F.normals.set(P.getAttribute("normal").array,_*3),F.uvs.set(P.getAttribute("uv").array,_*2);for(let Q=_;Q<_+E;Q++)F.uvs[Q*2+1]=1e-4;let H=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;_+=E,F.positions.set(P.getAttribute("position").array,_*3),F.normals.set(P.getAttribute("normal").array,_*3),F.uvs.set(P.getAttribute("uv").array,_*2);let Z=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;this.setAttribute("position",new Kn(F.positions,3)),this.setAttribute("normal",new Kn(F.normals,3)),this.setAttribute("uv",new Kn(F.uvs,2)),this._setIndexFromUint32(G);let te=MG;te.copy(u[u.length-1]).setPosition(d[d.length-1]),this.applyMatrix4OnRange(te,_,B),te.copy(u[0]).setPosition(d[0]).multiply(OG.makeScale(1,1,-1)),this.applyMatrix4OnRange(te,_-E,_),this.reverseIndicesOnRange(H,Z)}else this.setAttribute("position",new Kn(F.positions,3)),this.setAttribute("normal",new Kn(F.normals,3)),this.setAttribute("uv",new Kn(F.uvs,2)),this._setIndexFromUint32(G)}_setIndexFromUint32(e){let r=!1;for(let i=e.length-1;i>=0;--i)if(e[i]>=65535){r=!0;break}this.setIndex(new Kn(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=bf(e),i=$M.get(r);if(i===void 0||i.subdivisions!==e.subdivisions||i.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);i={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},$M.set(r,i)}return i}_extractPathPoints(e){let r=this.inputs.path.subdivisions,i=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(i.length<2)return[];let o=[i[0]];return i.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],i=e.length,o=this.inputs.path.isClosed,a=new ur,s=new ur,l=new ur,c=new ur,d=new ur(0,1,0);for(let y=0;y<i;y++){let g=e[y],b;y===0?b=o?e[i-1]:ZM.copy(g).multiplyScalar(2).sub(e[1]):b=e[y-1];let x;y===i-1?x=o?e[0]:ZM.copy(g).multiplyScalar(2).sub(e[y-1]):x=e[y+1],JM.subVectors(g,b).normalize(),F0.subVectors(x,g).normalize();let S=DG.addVectors(JM,F0);S.lengthSq()<1e-10&&(S.copy(F0),S.dot(l)<0&&S.negate()),S.normalize(),l.copy(S),y===0&&(S.equals(d)||RG.copy(S).negate().equals(d))&&d.set(0,0,1);let v=BG.crossVectors(d,S).normalize(),w=NG.crossVectors(S,v).normalize();d.copy(w),c.copy(v),y===0&&(a.copy(w),s.copy(S));let A=new Ts().makeBasis(v,w,S);r.push(A)}let u=o?s:l,p=o?a:new ur(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(IG.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,i){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new Ts,u=new Ts;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(i===0?0:1)-(r+(1-i)));d.makeRotationZ(Bm.lerp(a,a+s,f)*Bm.DEG2RAD);let m=Bm.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=rt.ODD){let i=this.inputs.shapeData,o=k0.get(i);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},k0.set(i,o)),o.shapePoints}_getSurfaceTesselation(e){let r=k0.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let i;try{i=dn({windingRule:rt.ODD,elementType:Xt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{i=Fx}return r!==void 0&&(r.surfaceTesselation=i),i}_computeShapePoints(e=12,r=rt.ODD){let i=this.inputs.shapeData,o=i.extractShapePointsToFlatArray([],e),a=i.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let x=y[b-1],S=y[b-0];g.push(x,S)}return g}),s;try{s=dn({windingRule:r,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=Su}let l;try{l=dn({windingRule:rt.ODD,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=_x}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],x=s.vertices[g+1];b<d&&(d=b),b>u&&(u=b),x<p&&(p=x),x>h&&(h=x)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],x=s.elements[g+1],S=b+x,v={start:b,count:x,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(v);let w=b,A=S-1,E=b+1,P=i.roundedCurves.length;do{let M=w-b,R=s.vertices[A*2+0],D=s.vertices[A*2+1],N=s.vertices[w*2+0],C=s.vertices[w*2+1],B=s.vertices[E*2+0],_=s.vertices[E*2+1],F=N-R,V=C-D,K=Math.sqrt(F*F+V*V);F/=K,V/=K;let q=N-B,G=C-_,W=Math.sqrt(q*q+G*G);q/=W,G/=W,v.normals[M*2+0]=-G,v.normals[M*2+1]=q;let H=s.vertexIndices[w];if(Array.isArray(H))v.continuous[M]=!1;else{let[Z,te]=i.getCurveIndexFromVertexId(H-1,!0);if(te>0&&te<1)v.continuous[M]=!0;else{let Q=te===1?Z+1:Z-1;Q=(Q+P)%P;let se=te===1?0:1,oe=i.roundedCurves[Z].getTangent(te),ne=i.roundedCurves[Q].getTangent(se);v.continuous[M]=oe.dot(ne)>.95}}y&&(v.normals[M*2+0]*=-1,v.normals[M*2+1]*=-1),[A,w,E]=[w,E,E+1],E>=S&&(E-=x)}while(E!==b+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,i,o,a){let s=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,i,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let v=(e.start+S)*2,w=r[v+0],A=r[v+1],E,P;if(e.continuous[S])E=e.normals[S*2+0],P=e.normals[S*2+1];else{let R=S===0?(e.start+e.count-1)*2:v-2,D=w-r[R+0];E=-(A-r[R+1]),P=D,e.isHole||(E=-E,P=-P)}let M=S===0?1:S/e.count;if(d.push(w,A,E,P,M,0),!e.continuous[S]||S===0)if(S===0)d.push(w,A,e.normals[0],e.normals[1],0,1);else{let R=S===e.count-1?e.start*2:v+2,D=r[R+0]-w;E=-(r[R+1]-A),P=D,e.isHole||(E=-E,P=-P),d.push(w,A,E,P,M,1)}}e.wallTemplate=d}let u=i.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let v=i[S].elements,w=v[0],A=v[1],E=v[2],P=v[4],M=v[5],R=v[6],D=v[12],N=v[13],C=v[14],B=o[S],_=S/(u-1),F=0,V=0,K=0,q=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let de=d[G+0],ve=d[G+1];F=w*de+P*ve+D+B.x,V=A*de+M*ve+N+B.y,K=E*de+R*ve+C+B.z}let W=d[G+2],H=d[G+3],Z=w*W+P*H+D,te=A*W+M*H+N,Q=E*W+R*H+C,se=1/(Math.sqrt(Z*Z+te*te+Q*Q)||1);Z*=se,te*=se,Q*=se;let oe=q*2,ne=q*3;h[ne+0]=F,h[ne+1]=V,h[ne+2]=K,f[ne+0]=Z,f[ne+1]=te,f[ne+2]=Q,m[oe+0]=d[G+4],m[oe+1]=_,q++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let v=0;v<e.count;v++)(!e.continuous[v]||v===0)&&S++,y.push(S,v===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,b=y.length,x=e.isHole;for(let S=0;S<g;S++){let v=e.verticesStart*u+e.verticesCount*S,w=v+e.verticesCount;for(let A=0;A<b;A+=2){let E=v+y[A],P=v+y[A+1],M=w+y[A+1],R=w+y[A];x?(s[l++]=E,s[l++]=M,s[l++]=P,s[l++]=E,s[l++]=R,s[l++]=M):(s[l++]=E,s[l++]=P,s[l++]=M,s[l++]=E,s[l++]=M,s[l++]=R)}}return l}_closeEnd(e,r,i,o,a,s,l,c){let d=e.vertexCount,u=new ur(0,0,c?-1:1).applyMatrix4(s),p=new ur,h=new TG;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;i[o++]=f[y+0]+r,i[o++]=f[y+(c?1:2)]+r,i[o++]=f[y+(c?2:1)]+r}return o}applyMatrix4OnRange(e,r,i){let o=e.elements,a=new PG().getNormalMatrix(e).elements,s,l,c,d,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let h=u.array,f=p.array,m=u.itemSize;for(let y=r*m,g=i*m;y<g;y+=m)s=h[y+0],l=h[y+1],c=h[y+2],d=1/(o[3]*s+o[7]*l+o[11]*c+o[15]),h[y+0]=(o[0]*s+o[4]*l+o[8]*c+o[12])*d,h[y+1]=(o[1]*s+o[5]*l+o[9]*c+o[13])*d,h[y+2]=(o[2]*s+o[6]*l+o[10]*c+o[14])*d,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c;u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let i=this.index;if(i){for(let o=e;o<r;o+=3){let a=i.getX(o),s=i.getX(o+1),l=i.getX(o+2);i.setXYZ(o,l,s,a)}i.needsUpdate=!0}}};Ui("PathGeometry",(n,t,e)=>new Rm(n,t,e));ru("PathGeometry",i2);Oe("3d-paths");Gi.Cloner=oi;Oe("cloners");ut();import{Group as _G,Matrix4 as FG,Skeleton as kG}from"three";function Lu(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)ke.is(e)&&Lu(e)}}var _u=class extends Yi(_G,Xi){constructor(e,r,i){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,i)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let i=fa.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(i){let o,a;for(let s of On.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=i.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=An.apply(i.data[s],e[s]));return this.overrideData=a,o}else return{...Jt.defaultData,...e,...Jd(Jt.defaultData,On.rootOverrideProps)}}updateByOp(e,r,i,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,i),e.type===0&&e.path.length===0&&this.component)for(let s of On.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&On.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,i,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let i=e.scene.find(r.component)??null,o=!1;if(i!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(ke.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Lu(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(i){let a={};o2(e,[this.uuid],r.overrides,this,i,i,0,o,a);for(let s of this.children)if(ke.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof Qe&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new FG().fromArray(m)),f=new kG(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function n2(n,t,e,r){return n.component===t&&Eo(n.identity,r)?n.overrideData===e?2:1:0}function o2(n,t,e,r,i,o,a,s,l){if(a>50)return!1;if(r.component!==i){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}i.instances.find(d=>d===r)||i.instances.push(r),r.component=i}i instanceof _u&&i.isInstanceRoot&&i.expandInstanceChildren(n);let c=0;for(let d of i.children)if(ke.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=yl.resolve(e,u,1);p!=null&&!(p instanceof Ct)&&(Object.setPrototypeOf(p,Ct.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=ke.is(m)?m:null,h!==null){let y=n2(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(u)??null,h!==null)){let y=n2(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?An.apply(d.data,p):d.data;on.is(m.type)&&(m={...m,type:"Empty"}),h=Gi.createEntity(u,m,n),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,o2(n,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(ke.is(u))n.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var a2=(n,t,e)=>new _u(n,t,e);ms("Component",a2);ms("Instance",a2);Oe("components");var G0=1e-10;function s2(n){let t=n[0][0],e=n[1][0],r=n[0][1],i=n[1][1],o=Math.sqrt(t*t+e*e),a=o>G0?t/o:1,s=o>G0?e/o:0,l=a*t+s*e,c=a*i-s*r,d=a*r+s*i;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>G0?d/c:0,0]}}function l2({rotation:n,scale:t,shear:e}){let r=Math.cos(n),i=Math.sin(n),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-i*a,i*t[0]+r*a,r*o-i*t[1],i*o+r*t[1]]}var De;(v=>{function n(){return[1,0,0,0,1,0,0,0,1]}v.identity=n;function t(w,A=v.identity()){for(let E=0,P=w.length;E<P;E++)A[E]=w[E];return A}v.copy=t;function e(w,A,E,P,M,R){return v.setAbcdef(v.identity(),w,A,E,P,M,R)}v.create=e;function r(w,A,E,P,M,R,D){return w[0]=A,w[1]=P,w[2]=R,w[3]=E,w[4]=M,w[5]=D,w}v.setAbcdef=r;function i(w,A){let[E,P,M,R,D,N]=a(w),[C,B,_,F,V,K]=a(A),q=C*E+B*M,G=C*P+B*R,W=_*E+F*M,H=_*P+F*R,Z=V*E+K*M+D,te=V*P+K*R+N;return v.create(q,G,W,H,Z,te)}v.append=i;function o(w,A){let[E,P,M,R,D,N]=a(w),[C,B,_,F,V,K]=a(A),q=E,G=P,W=M,H=R;(C!==1||B!==0||_!==0||F!==1)&&(q=E*C+P*_,G=E*B+P*F,W=M*C+R*_,H=M*B+R*F);let Z=D*C+N*_+V,te=D*B+N*F+K;return v.create(q,G,W,H,Z,te)}v.prepend=o;function a(w){return[w[0],w[3],w[1],w[4],w[2],w[5]]}v.getAbcdef=a;function s(w){let[A,E,P,M,R,D]=v.getAbcdef(w),N=A*M-E*P,C=M/N,B=-E/N,_=-P/N,F=A/N,V=(P*D-M*R)/N,K=-(A*D-E*R)/N;return v.create(C,B,_,F,V,K)}v.invert=s;function l([w,A],E){let[P,M,R,D,N,C]=v.getAbcdef(E);return[P*w+R*A+N,M*w+D*A+C]}v.apply=l;function c(w,A){let[E,P,M,R,D,N]=v.getAbcdef(A),C=1/(E*R+M*-P),[B,_]=w;return[R*C*B+-M*C*_+(N*M-D*R)*C,E*C*_+-P*C*B+(-N*E+D*P)*C]}v.applyInverse=c;function d(w,A,E=A){let[P,M,R,D,N,C]=v.getAbcdef(w);return v.setAbcdef(w,P*A,M*E,R*A,D*E,N*A,C*E),w}v.scale=d;function u(w,A){let E=Math.cos(A),P=Math.sin(A),[M,R,D,N,C,B]=v.getAbcdef(w);return v.setAbcdef(w,M*E-R*P,M*P+R*E,D*E-N*P,D*P+N*E,C*E-B*P,C*P+B*E),w}v.rotate=u;function p(w,A,E){let[P,M]=E,R=v.translate(w,-P,-M);return R=v.rotate(R,A),R=v.translate(R,P,M),R}v.rotateAround=p;function h(w,A,E){let[P,M,R,D,N,C]=v.getAbcdef(w);return v.setAbcdef(w,P,M,R,D,N+A,C+E),w}v.translate=h;function f(w,A,E){let[P,M,R,D]=v.getAbcdef(w);return v.setAbcdef(w,P,M,R,D,A,E),w}v.setTranslate=f;function m(w,A,E){let[P,M,R,D]=v.getAbcdef(w);return v.setAbcdef(w,P,M,R,D,A,E),w}v.setPosition=m;function y(w){let[A,E,P,M]=v.getAbcdef(w),R=Math.sqrt(A*A+E*E),D=Math.sqrt(P*P+M*M);return[R,D]}v.getScale=y;function g(w){let[,,,,A,E]=v.getAbcdef(w);return[A,E]}v.getPosition=g;function b(w,A){return v.decompose(w,A).rotation}v.getRotation=b;function x(w,A){let[E,P,M,R,D,N]=v.getAbcdef(w),{rotation:C,scale:B,shear:_}=s2([[E,M],[P,R]]);return{position:[D+(A[0]*E+A[1]*M)-A[0],N+(A[0]*P+A[1]*R)-A[1]],scale:B,rotation:C,shear:_,pivot:A}}v.decompose=x;function S(w,A,E,P,M=[0,0]){let[R,D]=w,[N,C]=P,[B,_,F,V]=l2({rotation:E,scale:A,shear:M}),K=R-(N*B+C*F)+N,q=D-(N*_+C*V)+C;return v.create(B,_,F,V,K,q)}v.compose=S})(De||(De={}));function VG(n,t){let[[e,r],[i,o]]=n,[[a,s],[l,c]]=t,d=(e-i)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-i)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var d2=[[-1,1],[-1,-1],[1,-1],[1,1]],c2=(n,t,e)=>{let r=n.getCenter(),i=n.getHalfSize(),o=De.append(t,n.worldMatrix);i[0]===0&&i[1]===0?e.push(De.apply(r,o)):d2.forEach(a=>{let s=[a[0]*i[0]+r[0],a[1]*i[1]+r[1]];e.push(De.apply(s,o))})},Ea=class{constructor(){this.matrix=De.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),De.copy(t.worldMatrix,this.matrix);let r=De.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let i=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&c2(a,e,i)}):c2(t,e,i),this.setFromPoints(i)}setFromSize(t,e,r){this.makeEmpty(),De.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[De.apply([0,0],r),De.apply([0,e],r),De.apply([t,e],r),De.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,i]=this.getHalfSize();return De.apply([t+r,e+i],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[i,o,a,s]=De.getAbcdef(this.matrix),l=De.create(i,o,a,s,r[0],r[1]);this.vertices=d2.map(([c,d])=>De.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=De.append(e.worldMatrix,r)),De.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:i}=this;return t>=r[0]&&t<=i[0]&&e>=r[1]&&e<=i[1]}containsPoint(t){let[e,r]=t,[i,o]=this.min,[a,s]=this.max;return e>=i&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let i=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(VG(i,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let i=t.vertices[e];if(this.containsPoint(i))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],De.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Ea;return t.copy(this),t}};var GG='{"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":{}}',u2=()=>JSON.parse(GG);async function UG(n,t){return await n.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(n.Engine.prototype,"scene")||Object.defineProperty(n.Engine.prototype,"scene",{get:function(){let e=Object.create(n.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>n.Engine.create(e,u2(),!0)}}var Nm,Fu;function zG(n){Nm=n}function U0(){if(!Fu){if(!Nm)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));Fu=Nm(),Fu.catch(()=>{Fu=void 0})}return Fu}var p2;function jG(){let n=typeof process<"u"?"2.0.38":void 0;return`https://cdn.spline.design/@splinetool/runtime${n?`@${n}`:""}/build/hana-ui.wasm`}function h2(n){p2=n}function Lm(){return Nm||zG(async()=>{let t=await import("./hana-ui.js");return UG(t,p2??jG())}),U0().then(()=>{})}var km=Bd(Fm(),1);function g2(n){let t=[],e;try{e=(0,km.makeAbsolute)((0,km.parseSVG)(n))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,i=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,i=a=c.y,t.push({MoveTo:{x:r,y:i}});break;case"L":r=c.x,i=c.y,t.push({LineTo:{x:r,y:i}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:i}});break;case"V":i=c.y,t.push({LineTo:{x:r,y:i}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*i-s.y}:{x:r,y:i},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*i-l.y}:{x:r,y:i};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"A":{let p=r,h=i;r=c.x,i=c.y,XG(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,i);break}case"Z":r=o,i=a,t.push("ClosePath");break}s=d,l=u}return t}function XG(n,t,e,r,i,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),i=Math.abs(i),r===0||i===0){n.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(i*i);if(g>1){let q=Math.sqrt(g);r*=q,i*=q}let b=r*r,x=i*i,S=b*x-b*y*y-x*m*m,v=b*y*y+x*m*m,w=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/v)),A=w*(r*y)/i,E=w*(-i*m)/r,P=u*A-p*E+(t+l)/2,M=p*A+u*E+(e+c)/2,R=Math.atan2((y-E)/i,(m-A)/r),N=Math.atan2((-y-E)/i,(-m-A)/r)-R;!s&&N>0?N-=2*Math.PI:s&&N<0&&(N+=2*Math.PI);let C=Math.max(1,Math.ceil(Math.abs(N)/(Math.PI/2))),B=N/C,_=4/3*Math.tan(B/4),F=R,V=t,K=e;for(let q=0;q<C;q++){let G=F+B,W=Math.cos(F),H=Math.sin(F),Z=Math.cos(G),te=Math.sin(G),Q=P+r*Z*u-i*te*p,se=M+r*Z*p+i*te*u,oe=-r*H*u-i*W*p,ne=-r*H*p+i*W*u,de=-r*te*u-i*Z*p,ve=-r*te*p+i*Z*u;n.push({CurveTo:[{x:V+_*oe,y:K+_*ne},{x:Q-_*de,y:se-_*ve},{x:Q,y:se}]}),F=G,V=Q,K=se}}var Gm=.5522847498307936,KG=150,ZG=5*60*1e3,JG=1536/2816;function E2(n){let t=n.getUint32(0);if(t===65536||t===1330926671||t===1953658213)return 0;if(t===1953784678)return n.getUint32(8)>0?n.getUint32(12):void 0}function $G(n){try{return E2(new DataView(n))!==void 0}catch{return!1}}function eU(n){try{let t=new DataView(n),e=E2(t);if(e===void 0)return;let r=t.getUint16(e+4),i=-1,o=-1;for(let c=0;c<r;c++){let d=e+12+c*16,u=t.getUint32(d);u===1751474532&&(i=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(i<0||o<0)return;let a=t.getUint16(i+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var v2=!1;function b2(){v2||(v2=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var Um=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=De.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=Ue.transparent;this._strokeColor=Ue.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ue.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ue.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._engineFonts=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await U0(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let i=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-i>ZG){clearInterval(o);return}r()&&(clearInterval(o),t())},KG)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let i=await r.arrayBuffer();if(i.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(i,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t),$G(t)&&this._engineFonts.add(e);let r=eU(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))===!1&&this._engineFonts.delete(e)}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:De.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=De.identity();if(this.camera?.enabled&&(r=De.append(r,this.camera.worldMatrix),e)){let i=De.getScale(this.camera.worldMatrix);r=De.scale(r,1/i[0],1/i[1])}this._ctm=De.append(r,t)}transform(t){this._ctm=De.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,i,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:i},{x:o,y:a}]})}quadraticCurveTo(t,e,r,i){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:i}]})}path(t){this._startFreeform(),this._pathEls.push(...g2(t))}rect(t,e,r,i,o=0,a=0,s=0,l=0){if(!w2([t,e,r,i]))return;let c={x:t,y:e,w:r,h:i,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,A2(this._pathEls,c)}ellipse(t,e,r,i,o,a,s,l){if(!!w2([t,e,r,i])){if(r<0||i<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:i}:null,nU(this._pathEls,t,e,r,i)}}clipRect(t,e,r,i,o=0,a=0,s=0,l=0){let c=De.invert(this._ctm);!c||this._clips.push({m:De.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:i,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let i=this._applyClips(r);if(i==="skip")return;if(!t&&i!==r){let a=ku(r);if(a){this._emitClippedRectStroke(a,e);return}}r=i;let o={shape:r,color:t?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,i=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-i,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-i,y:t.y-i,w:t.w+i*2,h:t.h+i*2,radii:s.map(g=>g>0?g+i:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(Vm(l,0));if(p==="skip")return;let h=ku(p)??l,f=null;if(u){let g=this._applyClips(Vm(u,0));f=g==="skip"?null:ku(g)??u}let m=[];A2(m,h),f&&iU(m,f);let y={shape:{Custom:m},color:dc(this._strokeColor),transform:De.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?Vm(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:dc(this._strokeColor),align:tU[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:dc(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[i,o]=De.getScale(this._ctm),a=(i+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[i,o,a,s]=De.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[i*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:dc(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t,e=this._ctm){if(this._clips.length===0)return t;let r=t;for(let i of this._clips){let o=De.append(i.inv,e),[a,s,l,c,d,u]=De.getAbcdef(o),p=Math.abs(s)<=1e-6*(Math.abs(a)+Math.abs(c))&&Math.abs(l)<=1e-6*(Math.abs(a)+Math.abs(c)),h=rU(r);if(!h)return r;if(!p){b2();continue}let f=a*h.minX+d,m=a*h.maxX+d,y=c*h.minY+u,g=c*h.maxY+u,b=Math.min(f,m),x=Math.max(f,m),S=Math.min(y,g),v=Math.max(y,g),w=i.rect,A=Math.max(b,w.x),E=Math.max(S,w.y),P=Math.min(x,w.x+w.w),M=Math.min(v,w.y+w.h);if(A>=P||E>=M)return"skip";if(A===b&&E===S&&P===x&&M===v)continue;let D=ku(r);if(!D||a===0||c===0){b2();continue}let N=(A-d)/a,C=(P-d)/a,B=(E-u)/c,_=(M-u)/c,F=Math.min(N,C),V=Math.min(B,_),K=Math.abs(C-N),q=Math.abs(_-B),[G,W,H,Z]=D.radii,te=F!==D.x,Q=V!==D.y,se=F+K!==D.x+D.w,oe=V+q!==D.y+D.h,ne=Math.min(K,q)/2,de=[te||Q?0:Math.min(G,ne),se||Q?0:Math.min(W,ne),se||oe?0:Math.min(H,ne),te||oe?0:Math.min(Z,ne)];r=Vm({x:F,y:V,w:K,h:q,radii:de},0)}return r}drawText(t,e){let r=this._engineFonts.has(e.font),i=this._fontXPerEm.get(e.font),o=!r&&i?i/JG:1,a={TextSimple:{text:t,font_size:e.fontSize*o,size:[e.width,e.height],horizontal_align:x2[e.horizontalAlign]??"Left",vertical_align:S2[e.verticalAlign]??"Top",line_height:e.lineHeight,letter_spacing:e.letterSpacing,...r?{font_id:e.font}:{}}},s=this._effectChain(!0),l=this._fillColor.a>0,c=this._strokeColor.a>0&&this._lineWidth>0;if(l||c||s){let d=De.append(this._ctm,De.translate(De.identity(),e.x,e.y));if(this._applyClips(a,d)!=="skip"){let u={shape:a,color:l?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(d)};c&&(u.stroke=this._strokeDesc()),s&&(u.effect_chain=s),this._shapes.push(u)}}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,i=this._measureCache.get(r);if(i!==void 0)return i;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:x2[e.horizontalAlign]??"Left",verticalAlign:S2[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
1312
+ `,r.pyramidTextureSize.value=new B0(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=i,this.material.root.shapeBlendhack=i}dispose(){super.dispose(),cM()?.release(this)}},Nu=_0;Nu.streamCompaction=new Ff;var SG=new qM,wG=new qM,sc=new XM,Cs=new cc,Im=new cc,AG=new XM;function EG(n,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Po.is(r)&&QM.call(r,n,t+1)}}function QM(n,t=0){if(n(this,t)!==!0){let r=this.children.length;for(;r--;){let i=this.children[r];Po.is(i)&&QM.call(i,n,t+1)}}}function CG(){if(this.shapesDataTexture.value===void 0){let y=new N0(new Float32Array(4*dr*Mo),dr,Mo,lc,Lo);this.shapesDataTexture.value=y}let n=this.shapesDataTexture.value,t=n.image.data,e=0,r=0,i=this.data.geometry.blendRange,o=SG.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(EG.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof oi)return;if(y instanceof oc||eu(y))return;y instanceof cr?g=y.object:g=y;let b=y.data?.cloner;if(ke.is(y)&&b&&!b.hideBase&&b.type!=="radial"&&b.disabled!==!0||!(g instanceof Qe))return;let x=g.geometry.userData.parameters,S=x?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(wG.multiplyMatrices(o,y.matrixWorld).decompose(Im,sc,Cs),x?.type==="TorusGeometry"&&x.arc!==360){let C=x.arc*Math.PI/180;C=C/4,sc.multiply(AG.set(0,0,Math.sin(C),Math.cos(C)))}let w=S.overrideGlobalBlend?S.blendRange:i;w=w/this.bboxSize*2,t[s*4]=(Im.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Im.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Im.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[dr*4+s*4]=-sc.x,t[dr*4+s*4+1]=-sc.y,t[dr*4+s*4+2]=-sc.z,t[dr*4+s*4+3]=sc.w;let A=new Float32Array(4),E=0,P=w;if(x?.type==="SphereGeometry")x.width===x.height&&x.width===x.depth?A[0]=0:A[0]=1,A[1]=x.width/this.bboxSize,A[2]=x.height/this.bboxSize,A[3]=x.depth/this.bboxSize,P=Math.max(A[1],A[2],A[3])*Cs.x+w;else if(x?.type==="CubeGeometry"){E=x.cornerRadius;let C=x.width,B=x.height,_=x.depth;A[0]=2,A[1]=(C-2*E)/this.bboxSize,A[2]=(B-2*E)/this.bboxSize,A[3]=(_-2*E)/this.bboxSize,P=Math.sqrt(C**2+B**2+_**2)/this.bboxSize*Cs.x+w}else if(x?.type==="CylinderGeometry"){E=x.cornerRadius;let C=x.height,B=x.radiusBottom,_=x.radiusTop;if(_>=B){let F=Math.atan2(_-B,C),V=(Math.PI/2-F)/2;_-=E/Math.tan(V),B-=E*Math.tan(V)}else if(B>_){let F=Math.atan2(B-_,C),V=(Math.PI/2-F)/2;_-=E*Math.tan(V),B-=E/Math.tan(V)}A[1]=(x.height-2*E)/this.bboxSize,B===_?(A[0]=3,A[2]=B/this.bboxSize*2):(A[0]=4,A[2]=B/this.bboxSize*2,A[3]=_/this.bboxSize*2),P=(Math.hypot(A[1],Math.max(Math.abs(A[2]),Math.abs(A[3])))+E/this.bboxSize*2)*Cs.x+w}else if(x?.type==="TorusGeometry"){if(A[0]=5,A[1]=(x.width-x.depth)/this.bboxSize,A[2]=x.depth/this.bboxSize,x.arc!==360){A[0]=6,A[3]=A[1],t[dr*12+s*4+3]=A[2];let C=2*Math.atan2(A[2]/2,A[1]),B=x.arc*Math.PI/180/2-C;A[1]=Math.sin(B),A[2]=Math.cos(B)}P=x.width*Cs.x/this.bboxSize+w}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=xG(C);if((B===void 0||B.posVersion!==_)&&this._meshSdfWanted.set(C.uuid,C),B===void 0)return;A[0]=7,A[1]=B.slot,A[2]=B.boxHalf.x/this.bboxSize*2,A[3]=B.boxHalf.y/this.bboxSize*2,t[dr*12+s*4+3]=B.boxHalf.z/this.bboxSize*2,P=Math.hypot(B.boxHalf.x,B.boxHalf.y,B.boxHalf.z)/this.bboxSize*2*Cs.x+w}t.set(A,dr*8+s*4),e=Math.max(e,P),r=Math.max(r,w),this._reach[s]=P,t[dr*12+s*4]=w,t[dr*12+s*4+1]=E/this.bboxSize*2,t[dr*12+s*4+2]=Cs.x;let M=Array.isArray(g.material)?g.material[0]:g.material,R=M,D,N;if(R?.getShapeBlendBaseColor){let C=R.getShapeBlendBaseColor();D=C,N=C.a}else M?.uniforms?.nodeU0!==void 0?(D=M.uniforms.nodeU0.node.value,N=M.uniforms.nodeU1?.value??1):(D={r:1,g:1,b:1},N=1);S.operation!==0&&!S.useColor&&(N=-1),t[dr*16+s*4]=D.r,t[dr*16+s*4+1]=D.g,t[dr*16+s*4+2]=D.b,t[dr*16+s*4+3]=N,N<1&&this.material.defines?.SHAPEBLEND_C===1&&(this.material.transparent=!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||L0,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let b=!1;for(let R=0;R<Mo;R++){let D=dr*4*R+g*4;if(t[D]!==d[D]||t[D+1]!==d[D+1]||t[D+2]!==d[D+2]||t[D+3]!==d[D+3]){b=!0;break}}if(!b)continue;if(p=!0,h)break;let x=t[g*4],S=t[g*4+1],v=t[g*4+2],w=d[g*4],A=d[g*4+1],E=d[g*4+2],P=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(x+S+v+P)||!Number.isFinite(w+A+E+M)){h=!0;continue}f.x=Math.min(f.x,x-P,w-M),f.y=Math.min(f.y,S-P,A-M),f.z=Math.min(f.z,v-P,E-M),m.x=Math.max(m.x,x+P,w+M),m.y=Math.max(m.y,S+P,A+M),m.z=Math.max(m.z,v+P,E+M)}}return L0&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,n.needsUpdate=!0),p}Ui("ShapeBlendGeometry",(n,t,e)=>new Nu(n,t,e));Oe("shape-blends");var Dm=class extends Qe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?su(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Ui("VectorGeometry",(n,t,e)=>new Dm(n,t,e));Oe("vector-shapes");var Rm=class extends Qe{constructor(e,r,i){super(e,r,i);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=i}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=$l;break;case"Ellipse":o=Zl;break;case"Polygon":o=im;break;case"Star":o=nm;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let i=this.geometry;r&&i.inputs&&(i.inputs.shapeData=r,i.build())}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let i in e)if(!Object.is(e[i],r[i]))return!1;for(let i in r)if(!(i in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let i=this.geometry.getAttribute("position");i!==void 0&&i.count>0?su(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,r):super.updateEntityBoxSize(e,r)}};import{Vector2 as TG,Vector3 as ur,Matrix3 as PG,Matrix4 as Ts,BufferGeometry as t2,BufferAttribute as Kn,MathUtils as Bm}from"three";function KM(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var MG=new Ts,OG=new Ts,IG=new Ts,ZM=new ur,JM=new ur,F0=new ur,DG=new ur,RG=new ur,BG=new ur,NG=new ur,$M=new WeakMap,k0=new WeakMap,e2=new WeakMap;function LG(n,t,e){let r=[new ur,new ur,new ur],i=[new ur,new ur,new ur];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((o,a)=>{let s=i[a],l=Bm.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new Ts().makeBasis(r[0],r[1],r[2])}function r2(n){n.setIndex(null),n.setAttribute("position",new Kn(new Float32Array(0),3)),n.setAttribute("normal",new Kn(new Float32Array(0),3)),n.setAttribute("uv",new Kn(new Float32Array(0),2)),n.setDrawRange(0,0)}var i2=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=t?.shapeData??Zl.create({parameters:{...cs,width:typeof cs.width=="number"?cs.width:100,height:typeof cs.height=="number"?cs.height:100}}).userData.shape;return{path:n.path??fl.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:o,extrusion:{...qh,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new V0(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else{let e=new t2;return r2(e),Object.assign(e,{userData:{...n,type:"PathGeometry"}})}}},V0=class extends t2{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!KM(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){r2(this);return}let{depth:i,offset:o}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((i+o)*a):Math.ceil(Math.min(1,i+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let H=0;H<c;H++){let Z=this.inputs.path.isClosed?(H+s)%e.length:Math.min(H+s,e.length-1);d.push(e[Z].clone()),u.push(r[Z].clone())}let p=(H,Z,te)=>{d[H]=d[H].clone().lerp(d[Z],te),u[H]=LG(u[H],u[Z],te)},h=0,f=o*a%1;(!this.inputs.path.isClosed||i<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+i)*a%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&o+i<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),i===0){let H=d.length-1;d[H].copy(d[0]),u[H].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,x=g>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:v,infos:w,vertices:A}=this._getShapePoints(S),E=0,P;if(x==="round"){let H=this.inputs.shapeData,Z=e2.get(H);Z!==void 0&&Z.bevel===g&&Z.curveSegments===S&&Z.bevelSides===b?P=Z.geometry:(P=new xa(H,2*g,g,S,b,void 0,!0),e2.set(H,{bevel:g,curveSegments:S,bevelSides:b,geometry:P})),E=P.getAttribute("position").count}let M=0,R=0;w.sort((H,Z)=>H.start-Z.start),w.forEach(H=>{H.verticesStart=M,H.verticesCount=H.continuous.reduce((Z,te,Q)=>Z+(Q===0||!te?2:1),0),R+=H.verticesCount,M=R});let D=R*c,N,C=0;this._isOpenEnded()&&x==="flat"&&(N=this._getSurfaceTesselation(v),C=N.vertexCount);let B=D+2*C+E*2,_=D+2*C,F={positions:new Float32Array(B*3),normals:new Float32Array(B*3),uvs:new Float32Array(B*2)},V=P?P.getIndex().array:null,K=0;w.forEach(H=>{K+=H.count});let q=K*(c-1)*6+(N?2*N.elementCount*3:0)+(V?2*V.length:0),G=new Uint32Array(q),W=0;if(w.forEach(H=>{W=this._extrudeRegion(H,A,u,d,F,G,W,this._isGeometryClosed()&&!this._isOpenEnded())}),N&&(W=this._closeEnd(N,D,G,W,F,u[0],d[0],!1),W=this._closeEnd(N,D+C,G,W,F,u[u.length-1],d[d.length-1],!0)),P){F.positions.set(P.getAttribute("position").array,_*3),F.normals.set(P.getAttribute("normal").array,_*3),F.uvs.set(P.getAttribute("uv").array,_*2);for(let Q=_;Q<_+E;Q++)F.uvs[Q*2+1]=1e-4;let H=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;_+=E,F.positions.set(P.getAttribute("position").array,_*3),F.normals.set(P.getAttribute("normal").array,_*3),F.uvs.set(P.getAttribute("uv").array,_*2);let Z=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;this.setAttribute("position",new Kn(F.positions,3)),this.setAttribute("normal",new Kn(F.normals,3)),this.setAttribute("uv",new Kn(F.uvs,2)),this._setIndexFromUint32(G);let te=MG;te.copy(u[u.length-1]).setPosition(d[d.length-1]),this.applyMatrix4OnRange(te,_,B),te.copy(u[0]).setPosition(d[0]).multiply(OG.makeScale(1,1,-1)),this.applyMatrix4OnRange(te,_-E,_),this.reverseIndicesOnRange(H,Z)}else this.setAttribute("position",new Kn(F.positions,3)),this.setAttribute("normal",new Kn(F.normals,3)),this.setAttribute("uv",new Kn(F.uvs,2)),this._setIndexFromUint32(G)}_setIndexFromUint32(e){let r=!1;for(let i=e.length-1;i>=0;--i)if(e[i]>=65535){r=!0;break}this.setIndex(new Kn(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=bf(e),i=$M.get(r);if(i===void 0||i.subdivisions!==e.subdivisions||i.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);i={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},$M.set(r,i)}return i}_extractPathPoints(e){let r=this.inputs.path.subdivisions,i=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(i.length<2)return[];let o=[i[0]];return i.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],i=e.length,o=this.inputs.path.isClosed,a=new ur,s=new ur,l=new ur,c=new ur,d=new ur(0,1,0);for(let y=0;y<i;y++){let g=e[y],b;y===0?b=o?e[i-1]:ZM.copy(g).multiplyScalar(2).sub(e[1]):b=e[y-1];let x;y===i-1?x=o?e[0]:ZM.copy(g).multiplyScalar(2).sub(e[y-1]):x=e[y+1],JM.subVectors(g,b).normalize(),F0.subVectors(x,g).normalize();let S=DG.addVectors(JM,F0);S.lengthSq()<1e-10&&(S.copy(F0),S.dot(l)<0&&S.negate()),S.normalize(),l.copy(S),y===0&&(S.equals(d)||RG.copy(S).negate().equals(d))&&d.set(0,0,1);let v=BG.crossVectors(d,S).normalize(),w=NG.crossVectors(S,v).normalize();d.copy(w),c.copy(v),y===0&&(a.copy(w),s.copy(S));let A=new Ts().makeBasis(v,w,S);r.push(A)}let u=o?s:l,p=o?a:new ur(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(IG.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,i){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new Ts,u=new Ts;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(i===0?0:1)-(r+(1-i)));d.makeRotationZ(Bm.lerp(a,a+s,f)*Bm.DEG2RAD);let m=Bm.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=rt.ODD){let i=this.inputs.shapeData,o=k0.get(i);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},k0.set(i,o)),o.shapePoints}_getSurfaceTesselation(e){let r=k0.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let i;try{i=dn({windingRule:rt.ODD,elementType:Xt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{i=Fx}return r!==void 0&&(r.surfaceTesselation=i),i}_computeShapePoints(e=12,r=rt.ODD){let i=this.inputs.shapeData,o=i.extractShapePointsToFlatArray([],e),a=i.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let x=y[b-1],S=y[b-0];g.push(x,S)}return g}),s;try{s=dn({windingRule:r,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=Su}let l;try{l=dn({windingRule:rt.ODD,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=_x}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],x=s.vertices[g+1];b<d&&(d=b),b>u&&(u=b),x<p&&(p=x),x>h&&(h=x)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],x=s.elements[g+1],S=b+x,v={start:b,count:x,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(v);let w=b,A=S-1,E=b+1,P=i.roundedCurves.length;do{let M=w-b,R=s.vertices[A*2+0],D=s.vertices[A*2+1],N=s.vertices[w*2+0],C=s.vertices[w*2+1],B=s.vertices[E*2+0],_=s.vertices[E*2+1],F=N-R,V=C-D,K=Math.sqrt(F*F+V*V);F/=K,V/=K;let q=N-B,G=C-_,W=Math.sqrt(q*q+G*G);q/=W,G/=W,v.normals[M*2+0]=-G,v.normals[M*2+1]=q;let H=s.vertexIndices[w];if(Array.isArray(H))v.continuous[M]=!1;else{let[Z,te]=i.getCurveIndexFromVertexId(H-1,!0);if(te>0&&te<1)v.continuous[M]=!0;else{let Q=te===1?Z+1:Z-1;Q=(Q+P)%P;let se=te===1?0:1,oe=i.roundedCurves[Z].getTangent(te),ne=i.roundedCurves[Q].getTangent(se);v.continuous[M]=oe.dot(ne)>.95}}y&&(v.normals[M*2+0]*=-1,v.normals[M*2+1]*=-1),[A,w,E]=[w,E,E+1],E>=S&&(E-=x)}while(E!==b+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,i,o,a){let s=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,i,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let v=(e.start+S)*2,w=r[v+0],A=r[v+1],E,P;if(e.continuous[S])E=e.normals[S*2+0],P=e.normals[S*2+1];else{let R=S===0?(e.start+e.count-1)*2:v-2,D=w-r[R+0];E=-(A-r[R+1]),P=D,e.isHole||(E=-E,P=-P)}let M=S===0?1:S/e.count;if(d.push(w,A,E,P,M,0),!e.continuous[S]||S===0)if(S===0)d.push(w,A,e.normals[0],e.normals[1],0,1);else{let R=S===e.count-1?e.start*2:v+2,D=r[R+0]-w;E=-(r[R+1]-A),P=D,e.isHole||(E=-E,P=-P),d.push(w,A,E,P,M,1)}}e.wallTemplate=d}let u=i.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let v=i[S].elements,w=v[0],A=v[1],E=v[2],P=v[4],M=v[5],R=v[6],D=v[12],N=v[13],C=v[14],B=o[S],_=S/(u-1),F=0,V=0,K=0,q=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let de=d[G+0],ve=d[G+1];F=w*de+P*ve+D+B.x,V=A*de+M*ve+N+B.y,K=E*de+R*ve+C+B.z}let W=d[G+2],H=d[G+3],Z=w*W+P*H+D,te=A*W+M*H+N,Q=E*W+R*H+C,se=1/(Math.sqrt(Z*Z+te*te+Q*Q)||1);Z*=se,te*=se,Q*=se;let oe=q*2,ne=q*3;h[ne+0]=F,h[ne+1]=V,h[ne+2]=K,f[ne+0]=Z,f[ne+1]=te,f[ne+2]=Q,m[oe+0]=d[G+4],m[oe+1]=_,q++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let v=0;v<e.count;v++)(!e.continuous[v]||v===0)&&S++,y.push(S,v===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,b=y.length,x=e.isHole;for(let S=0;S<g;S++){let v=e.verticesStart*u+e.verticesCount*S,w=v+e.verticesCount;for(let A=0;A<b;A+=2){let E=v+y[A],P=v+y[A+1],M=w+y[A+1],R=w+y[A];x?(s[l++]=E,s[l++]=M,s[l++]=P,s[l++]=E,s[l++]=R,s[l++]=M):(s[l++]=E,s[l++]=P,s[l++]=M,s[l++]=E,s[l++]=M,s[l++]=R)}}return l}_closeEnd(e,r,i,o,a,s,l,c){let d=e.vertexCount,u=new ur(0,0,c?-1:1).applyMatrix4(s),p=new ur,h=new TG;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;i[o++]=f[y+0]+r,i[o++]=f[y+(c?1:2)]+r,i[o++]=f[y+(c?2:1)]+r}return o}applyMatrix4OnRange(e,r,i){let o=e.elements,a=new PG().getNormalMatrix(e).elements,s,l,c,d,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let h=u.array,f=p.array,m=u.itemSize;for(let y=r*m,g=i*m;y<g;y+=m)s=h[y+0],l=h[y+1],c=h[y+2],d=1/(o[3]*s+o[7]*l+o[11]*c+o[15]),h[y+0]=(o[0]*s+o[4]*l+o[8]*c+o[12])*d,h[y+1]=(o[1]*s+o[5]*l+o[9]*c+o[13])*d,h[y+2]=(o[2]*s+o[6]*l+o[10]*c+o[14])*d,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c;u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let i=this.index;if(i){for(let o=e;o<r;o+=3){let a=i.getX(o),s=i.getX(o+1),l=i.getX(o+2);i.setXYZ(o,l,s,a)}i.needsUpdate=!0}}};Ui("PathGeometry",(n,t,e)=>new Rm(n,t,e));ru("PathGeometry",i2);Oe("3d-paths");Gi.Cloner=oi;Oe("cloners");ut();import{Group as _G,Matrix4 as FG,Skeleton as kG}from"three";function Lu(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)ke.is(e)&&Lu(e)}}var _u=class extends Yi(_G,Xi){constructor(e,r,i){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,i)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let i=fa.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(i){let o,a;for(let s of On.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=i.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=An.apply(i.data[s],e[s]));return this.overrideData=a,o}else return{...Jt.defaultData,...e,...Jd(Jt.defaultData,On.rootOverrideProps)}}updateByOp(e,r,i,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,i),e.type===0&&e.path.length===0&&this.component)for(let s of On.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&On.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,i,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let i=e.scene.find(r.component)??null,o=!1;if(i!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(ke.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Lu(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(i){let a={};o2(e,[this.uuid],r.overrides,this,i,i,0,o,a);for(let s of this.children)if(ke.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof Qe&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new FG().fromArray(m)),f=new kG(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function n2(n,t,e,r){return n.component===t&&Eo(n.identity,r)?n.overrideData===e?2:1:0}function o2(n,t,e,r,i,o,a,s,l){if(a>50)return!1;if(r.component!==i){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}i.instances.find(d=>d===r)||i.instances.push(r),r.component=i}i instanceof _u&&i.isInstanceRoot&&i.expandInstanceChildren(n);let c=0;for(let d of i.children)if(ke.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=yl.resolve(e,u,1);p!=null&&!(p instanceof Ct)&&(Object.setPrototypeOf(p,Ct.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=ke.is(m)?m:null,h!==null){let y=n2(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(u)??null,h!==null)){let y=n2(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?An.apply(d.data,p):d.data;on.is(m.type)&&(m={...m,type:"Empty"}),h=Gi.createEntity(u,m,n),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,o2(n,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(ke.is(u))n.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var a2=(n,t,e)=>new _u(n,t,e);ms("Component",a2);ms("Instance",a2);Oe("components");var G0=1e-10;function s2(n){let t=n[0][0],e=n[1][0],r=n[0][1],i=n[1][1],o=Math.sqrt(t*t+e*e),a=o>G0?t/o:1,s=o>G0?e/o:0,l=a*t+s*e,c=a*i-s*r,d=a*r+s*i;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>G0?d/c:0,0]}}function l2({rotation:n,scale:t,shear:e}){let r=Math.cos(n),i=Math.sin(n),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-i*a,i*t[0]+r*a,r*o-i*t[1],i*o+r*t[1]]}var De;(v=>{function n(){return[1,0,0,0,1,0,0,0,1]}v.identity=n;function t(w,A=v.identity()){for(let E=0,P=w.length;E<P;E++)A[E]=w[E];return A}v.copy=t;function e(w,A,E,P,M,R){return v.setAbcdef(v.identity(),w,A,E,P,M,R)}v.create=e;function r(w,A,E,P,M,R,D){return w[0]=A,w[1]=P,w[2]=R,w[3]=E,w[4]=M,w[5]=D,w}v.setAbcdef=r;function i(w,A){let[E,P,M,R,D,N]=a(w),[C,B,_,F,V,K]=a(A),q=C*E+B*M,G=C*P+B*R,W=_*E+F*M,H=_*P+F*R,Z=V*E+K*M+D,te=V*P+K*R+N;return v.create(q,G,W,H,Z,te)}v.append=i;function o(w,A){let[E,P,M,R,D,N]=a(w),[C,B,_,F,V,K]=a(A),q=E,G=P,W=M,H=R;(C!==1||B!==0||_!==0||F!==1)&&(q=E*C+P*_,G=E*B+P*F,W=M*C+R*_,H=M*B+R*F);let Z=D*C+N*_+V,te=D*B+N*F+K;return v.create(q,G,W,H,Z,te)}v.prepend=o;function a(w){return[w[0],w[3],w[1],w[4],w[2],w[5]]}v.getAbcdef=a;function s(w){let[A,E,P,M,R,D]=v.getAbcdef(w),N=A*M-E*P,C=M/N,B=-E/N,_=-P/N,F=A/N,V=(P*D-M*R)/N,K=-(A*D-E*R)/N;return v.create(C,B,_,F,V,K)}v.invert=s;function l([w,A],E){let[P,M,R,D,N,C]=v.getAbcdef(E);return[P*w+R*A+N,M*w+D*A+C]}v.apply=l;function c(w,A){let[E,P,M,R,D,N]=v.getAbcdef(A),C=1/(E*R+M*-P),[B,_]=w;return[R*C*B+-M*C*_+(N*M-D*R)*C,E*C*_+-P*C*B+(-N*E+D*P)*C]}v.applyInverse=c;function d(w,A,E=A){let[P,M,R,D,N,C]=v.getAbcdef(w);return v.setAbcdef(w,P*A,M*E,R*A,D*E,N*A,C*E),w}v.scale=d;function u(w,A){let E=Math.cos(A),P=Math.sin(A),[M,R,D,N,C,B]=v.getAbcdef(w);return v.setAbcdef(w,M*E-R*P,M*P+R*E,D*E-N*P,D*P+N*E,C*E-B*P,C*P+B*E),w}v.rotate=u;function p(w,A,E){let[P,M]=E,R=v.translate(w,-P,-M);return R=v.rotate(R,A),R=v.translate(R,P,M),R}v.rotateAround=p;function h(w,A,E){let[P,M,R,D,N,C]=v.getAbcdef(w);return v.setAbcdef(w,P,M,R,D,N+A,C+E),w}v.translate=h;function f(w,A,E){let[P,M,R,D]=v.getAbcdef(w);return v.setAbcdef(w,P,M,R,D,A,E),w}v.setTranslate=f;function m(w,A,E){let[P,M,R,D]=v.getAbcdef(w);return v.setAbcdef(w,P,M,R,D,A,E),w}v.setPosition=m;function y(w){let[A,E,P,M]=v.getAbcdef(w),R=Math.sqrt(A*A+E*E),D=Math.sqrt(P*P+M*M);return[R,D]}v.getScale=y;function g(w){let[,,,,A,E]=v.getAbcdef(w);return[A,E]}v.getPosition=g;function b(w,A){return v.decompose(w,A).rotation}v.getRotation=b;function x(w,A){let[E,P,M,R,D,N]=v.getAbcdef(w),{rotation:C,scale:B,shear:_}=s2([[E,M],[P,R]]);return{position:[D+(A[0]*E+A[1]*M)-A[0],N+(A[0]*P+A[1]*R)-A[1]],scale:B,rotation:C,shear:_,pivot:A}}v.decompose=x;function S(w,A,E,P,M=[0,0]){let[R,D]=w,[N,C]=P,[B,_,F,V]=l2({rotation:E,scale:A,shear:M}),K=R-(N*B+C*F)+N,q=D-(N*_+C*V)+C;return v.create(B,_,F,V,K,q)}v.compose=S})(De||(De={}));function VG(n,t){let[[e,r],[i,o]]=n,[[a,s],[l,c]]=t,d=(e-i)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-i)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var d2=[[-1,1],[-1,-1],[1,-1],[1,1]],c2=(n,t,e)=>{let r=n.getCenter(),i=n.getHalfSize(),o=De.append(t,n.worldMatrix);i[0]===0&&i[1]===0?e.push(De.apply(r,o)):d2.forEach(a=>{let s=[a[0]*i[0]+r[0],a[1]*i[1]+r[1]];e.push(De.apply(s,o))})},Ea=class{constructor(){this.matrix=De.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),De.copy(t.worldMatrix,this.matrix);let r=De.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let i=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&c2(a,e,i)}):c2(t,e,i),this.setFromPoints(i)}setFromSize(t,e,r){this.makeEmpty(),De.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[De.apply([0,0],r),De.apply([0,e],r),De.apply([t,e],r),De.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,i]=this.getHalfSize();return De.apply([t+r,e+i],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[i,o,a,s]=De.getAbcdef(this.matrix),l=De.create(i,o,a,s,r[0],r[1]);this.vertices=d2.map(([c,d])=>De.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=De.append(e.worldMatrix,r)),De.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:i}=this;return t>=r[0]&&t<=i[0]&&e>=r[1]&&e<=i[1]}containsPoint(t){let[e,r]=t,[i,o]=this.min,[a,s]=this.max;return e>=i&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let i=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(VG(i,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let i=t.vertices[e];if(this.containsPoint(i))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],De.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Ea;return t.copy(this),t}};var GG='{"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":{}}',u2=()=>JSON.parse(GG);async function UG(n,t){return await n.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(n.Engine.prototype,"scene")||Object.defineProperty(n.Engine.prototype,"scene",{get:function(){let e=Object.create(n.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>n.Engine.create(e,u2(),!0)}}var Nm,Fu;function zG(n){Nm=n}function U0(){if(!Fu){if(!Nm)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));Fu=Nm(),Fu.catch(()=>{Fu=void 0})}return Fu}var p2;function jG(){let n=typeof process<"u"?"2.0.40":void 0;return`https://cdn.spline.design/@splinetool/runtime${n?`@${n}`:""}/build/hana-ui.wasm`}function h2(n){p2=n}function Lm(){return Nm||zG(async()=>{let t=await import("./hana-ui.js");return UG(t,p2??jG())}),U0().then(()=>{})}var km=Bd(Fm(),1);function g2(n){let t=[],e;try{e=(0,km.makeAbsolute)((0,km.parseSVG)(n))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,i=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,i=a=c.y,t.push({MoveTo:{x:r,y:i}});break;case"L":r=c.x,i=c.y,t.push({LineTo:{x:r,y:i}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:i}});break;case"V":i=c.y,t.push({LineTo:{x:r,y:i}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*i-s.y}:{x:r,y:i},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*i-l.y}:{x:r,y:i};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"A":{let p=r,h=i;r=c.x,i=c.y,XG(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,i);break}case"Z":r=o,i=a,t.push("ClosePath");break}s=d,l=u}return t}function XG(n,t,e,r,i,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),i=Math.abs(i),r===0||i===0){n.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(i*i);if(g>1){let q=Math.sqrt(g);r*=q,i*=q}let b=r*r,x=i*i,S=b*x-b*y*y-x*m*m,v=b*y*y+x*m*m,w=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/v)),A=w*(r*y)/i,E=w*(-i*m)/r,P=u*A-p*E+(t+l)/2,M=p*A+u*E+(e+c)/2,R=Math.atan2((y-E)/i,(m-A)/r),N=Math.atan2((-y-E)/i,(-m-A)/r)-R;!s&&N>0?N-=2*Math.PI:s&&N<0&&(N+=2*Math.PI);let C=Math.max(1,Math.ceil(Math.abs(N)/(Math.PI/2))),B=N/C,_=4/3*Math.tan(B/4),F=R,V=t,K=e;for(let q=0;q<C;q++){let G=F+B,W=Math.cos(F),H=Math.sin(F),Z=Math.cos(G),te=Math.sin(G),Q=P+r*Z*u-i*te*p,se=M+r*Z*p+i*te*u,oe=-r*H*u-i*W*p,ne=-r*H*p+i*W*u,de=-r*te*u-i*Z*p,ve=-r*te*p+i*Z*u;n.push({CurveTo:[{x:V+_*oe,y:K+_*ne},{x:Q-_*de,y:se-_*ve},{x:Q,y:se}]}),F=G,V=Q,K=se}}var Gm=.5522847498307936,KG=150,ZG=5*60*1e3,JG=1536/2816;function E2(n){let t=n.getUint32(0);if(t===65536||t===1330926671||t===1953658213)return 0;if(t===1953784678)return n.getUint32(8)>0?n.getUint32(12):void 0}function $G(n){try{return E2(new DataView(n))!==void 0}catch{return!1}}function eU(n){try{let t=new DataView(n),e=E2(t);if(e===void 0)return;let r=t.getUint16(e+4),i=-1,o=-1;for(let c=0;c<r;c++){let d=e+12+c*16,u=t.getUint32(d);u===1751474532&&(i=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(i<0||o<0)return;let a=t.getUint16(i+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var v2=!1;function b2(){v2||(v2=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var Um=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=De.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=Ue.transparent;this._strokeColor=Ue.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ue.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ue.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._engineFonts=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await U0(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let i=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-i>ZG){clearInterval(o);return}r()&&(clearInterval(o),t())},KG)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let i=await r.arrayBuffer();if(i.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(i,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t),$G(t)&&this._engineFonts.add(e);let r=eU(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))===!1&&this._engineFonts.delete(e)}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:De.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=De.identity();if(this.camera?.enabled&&(r=De.append(r,this.camera.worldMatrix),e)){let i=De.getScale(this.camera.worldMatrix);r=De.scale(r,1/i[0],1/i[1])}this._ctm=De.append(r,t)}transform(t){this._ctm=De.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,i,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:i},{x:o,y:a}]})}quadraticCurveTo(t,e,r,i){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:i}]})}path(t){this._startFreeform(),this._pathEls.push(...g2(t))}rect(t,e,r,i,o=0,a=0,s=0,l=0){if(!w2([t,e,r,i]))return;let c={x:t,y:e,w:r,h:i,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,A2(this._pathEls,c)}ellipse(t,e,r,i,o,a,s,l){if(!!w2([t,e,r,i])){if(r<0||i<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:i}:null,nU(this._pathEls,t,e,r,i)}}clipRect(t,e,r,i,o=0,a=0,s=0,l=0){let c=De.invert(this._ctm);!c||this._clips.push({m:De.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:i,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let i=this._applyClips(r);if(i==="skip")return;if(!t&&i!==r){let a=ku(r);if(a){this._emitClippedRectStroke(a,e);return}}r=i;let o={shape:r,color:t?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,i=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-i,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-i,y:t.y-i,w:t.w+i*2,h:t.h+i*2,radii:s.map(g=>g>0?g+i:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(Vm(l,0));if(p==="skip")return;let h=ku(p)??l,f=null;if(u){let g=this._applyClips(Vm(u,0));f=g==="skip"?null:ku(g)??u}let m=[];A2(m,h),f&&iU(m,f);let y={shape:{Custom:m},color:dc(this._strokeColor),transform:De.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?Vm(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:dc(this._strokeColor),align:tU[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:dc(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[i,o]=De.getScale(this._ctm),a=(i+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[i,o,a,s]=De.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[i*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:dc(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t,e=this._ctm){if(this._clips.length===0)return t;let r=t;for(let i of this._clips){let o=De.append(i.inv,e),[a,s,l,c,d,u]=De.getAbcdef(o),p=Math.abs(s)<=1e-6*(Math.abs(a)+Math.abs(c))&&Math.abs(l)<=1e-6*(Math.abs(a)+Math.abs(c)),h=rU(r);if(!h)return r;if(!p){b2();continue}let f=a*h.minX+d,m=a*h.maxX+d,y=c*h.minY+u,g=c*h.maxY+u,b=Math.min(f,m),x=Math.max(f,m),S=Math.min(y,g),v=Math.max(y,g),w=i.rect,A=Math.max(b,w.x),E=Math.max(S,w.y),P=Math.min(x,w.x+w.w),M=Math.min(v,w.y+w.h);if(A>=P||E>=M)return"skip";if(A===b&&E===S&&P===x&&M===v)continue;let D=ku(r);if(!D||a===0||c===0){b2();continue}let N=(A-d)/a,C=(P-d)/a,B=(E-u)/c,_=(M-u)/c,F=Math.min(N,C),V=Math.min(B,_),K=Math.abs(C-N),q=Math.abs(_-B),[G,W,H,Z]=D.radii,te=F!==D.x,Q=V!==D.y,se=F+K!==D.x+D.w,oe=V+q!==D.y+D.h,ne=Math.min(K,q)/2,de=[te||Q?0:Math.min(G,ne),se||Q?0:Math.min(W,ne),se||oe?0:Math.min(H,ne),te||oe?0:Math.min(Z,ne)];r=Vm({x:F,y:V,w:K,h:q,radii:de},0)}return r}drawText(t,e){let r=this._engineFonts.has(e.font),i=this._fontXPerEm.get(e.font),o=!r&&i?i/JG:1,a={TextSimple:{text:t,font_size:e.fontSize*o,size:[e.width,e.height],horizontal_align:x2[e.horizontalAlign]??"Left",vertical_align:S2[e.verticalAlign]??"Top",line_height:e.lineHeight,letter_spacing:e.letterSpacing,...r?{font_id:e.font}:{}}},s=this._effectChain(!0),l=this._fillColor.a>0,c=this._strokeColor.a>0&&this._lineWidth>0;if(l||c||s){let d=De.append(this._ctm,De.translate(De.identity(),e.x,e.y));if(this._applyClips(a,d)!=="skip"){let u={shape:a,color:l?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(d)};c&&(u.stroke=this._strokeDesc()),s&&(u.effect_chain=s),this._shapes.push(u)}}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,i=this._measureCache.get(r);if(i!==void 0)return i;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:x2[e.horizontalAlign]??"Left",verticalAlign:S2[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
1313
1313
  `))c+=Math.max(1,Math.ceil(d.length/l));o=c*e.fontSize*e.lineHeight}return this._measureCache.size>512&&this._measureCache.clear(),this._measureCache.set(r,o),o}clear(){this._shapes=[],this._ctm=De.identity(),this._stack.length=0,this._clips.length=0}render(){let t=this._engine;if(!t||this._crashed)return;let e=JSON.stringify(this._shapes);e!==this._lastPushedJSON&&(this._guard(()=>t.scene.updateUiShapes(this._shapes)),this._lastPushedJSON=e),this._guard(()=>t.onFrame())}},tU={inside:"Inside",outside:"Outside",center:"Center"},x2={[1]:"Left",[2]:"Right",[3]:"Center",[4]:"Justify"},S2={[1]:"Top",[2]:"Center",[3]:"Bottom"};function dc({r:n,g:t,b:e,a:r}){return[n,t,e,r]}function w2(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function Vm(n,t){let[e,r,i,o]=n.radii;return e===0&&r===0&&i===0&&o===0?{Rectangle:{x:n.x,y:n.y,width:n.w,height:n.h}}:{RoundedRectangle:{x:n.x,y:n.y,width:n.w,height:n.h,radius:[e,r,i,o],corner_smoothing:t}}}function ku(n){if("Rectangle"in n){let t=n.Rectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[0,0,0,0]}}if("RoundedRectangle"in n){let t=n.RoundedRectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[t.radius[0],t.radius[1],t.radius[2],t.radius[3]]}}return null}function rU(n){let t=ku(n);if(t)return{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h};if("Ellipse"in n){let e=n.Ellipse;return{minX:e.center_x-e.rx,minY:e.center_y-e.ry,maxX:e.center_x+e.rx,maxY:e.center_y+e.ry}}if("TextSimple"in n){let e=n.TextSimple;return{minX:0,minY:0,maxX:e.size[0],maxY:e.size[1]}}if("Custom"in n){let e=1/0,r=1/0,i=-1/0,o=-1/0,a=s=>{s.x<e&&(e=s.x),s.y<r&&(r=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)};for(let s of n.Custom)s!=="ClosePath"&&("MoveTo"in s?a(s.MoveTo):"LineTo"in s?a(s.LineTo):"QuadTo"in s?s.QuadTo.forEach(a):"CurveTo"in s&&s.CurveTo.forEach(a));return e===1/0?null:{minX:e,minY:r,maxX:i,maxY:o}}return null}function A2(n,t){let{x:e,y:r,w:i,h:o}=t,a=Math.min(i,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){n.push({MoveTo:{x:e,y:r}},{LineTo:{x:e+i,y:r}},{LineTo:{x:e+i,y:r+o}},{LineTo:{x:e,y:r+o}},"ClosePath");return}let u=1-Gm;n.push({MoveTo:{x:e+s,y:r}}),n.push({LineTo:{x:e+i-l,y:r}}),l>0&&n.push({CurveTo:[{x:e+i-l*u,y:r},{x:e+i,y:r+l*u},{x:e+i,y:r+l}]}),n.push({LineTo:{x:e+i,y:r+o-c}}),c>0&&n.push({CurveTo:[{x:e+i,y:r+o-c*u},{x:e+i-c*u,y:r+o},{x:e+i-c,y:r+o}]}),n.push({LineTo:{x:e+d,y:r+o}}),d>0&&n.push({CurveTo:[{x:e+d*u,y:r+o},{x:e,y:r+o-d*u},{x:e,y:r+o-d}]}),n.push({LineTo:{x:e,y:r+s}}),s>0&&n.push({CurveTo:[{x:e,y:r+s*u},{x:e+s*u,y:r},{x:e+s,y:r}]}),n.push("ClosePath")}function iU(n,t){let{x:e,y:r,w:i,h:o}=t,a=Math.min(i,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){n.push({MoveTo:{x:e,y:r}},{LineTo:{x:e,y:r+o}},{LineTo:{x:e+i,y:r+o}},{LineTo:{x:e+i,y:r}},"ClosePath");return}let u=1-Gm;n.push({MoveTo:{x:e+s,y:r}}),s>0&&n.push({CurveTo:[{x:e+s*u,y:r},{x:e,y:r+s*u},{x:e,y:r+s}]}),n.push({LineTo:{x:e,y:r+o-d}}),d>0&&n.push({CurveTo:[{x:e,y:r+o-d*u},{x:e+d*u,y:r+o},{x:e+d,y:r+o}]}),n.push({LineTo:{x:e+i-c,y:r+o}}),c>0&&n.push({CurveTo:[{x:e+i-c*u,y:r+o},{x:e+i,y:r+o-c*u},{x:e+i,y:r+o-c}]}),n.push({LineTo:{x:e+i,y:r+l}}),l>0&&n.push({CurveTo:[{x:e+i,y:r+l*u},{x:e+i-l*u,y:r},{x:e+i-l,y:r}]}),n.push("ClosePath")}function nU(n,t,e,r,i){let o=r*Gm,a=i*Gm;n.push({MoveTo:{x:t+r,y:e}},{CurveTo:[{x:t+r,y:e+a},{x:t+o,y:e+i},{x:t,y:e+i}]},{CurveTo:[{x:t-o,y:e+i},{x:t-r,y:e+a},{x:t-r,y:e}]},{CurveTo:[{x:t-r,y:e-a},{x:t-o,y:e-i},{x:t,y:e-i}]},{CurveTo:[{x:t+o,y:e-i},{x:t+r,y:e-a},{x:t+r,y:e}]},"ClosePath")}function C2(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var oU=Math.PI/180,Gce=180/Math.PI;function T2(n,t,e,r,i,o){let a=n-e,s=t-r;return a*a/(i*i)+s*s/(o*o)<=1}function P2(n){return n*oU}ut();function _o(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(i){i(e)}),(r=n.get("*"))&&r.slice().map(function(i){i(t,e)})}}}var Fo=class{constructor(t,e,r){this.uuid=t;this.data=e;this.isObject2D=!0;this.localMatrix=De.identity();this.worldMatrix=De.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Ea;this._recursiveBBox=new Ea;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=_o();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=De.append(e.worldMatrix,r)),De.applyInverse(t,r)}intersects(t,e,r,i=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),i)}intersectsInLocalSpace(t,e,r=!1){let{min:i,max:o}=r?this.recursiveBBox:this.singleBBox;return t>=i[0]&&t<=o[0]&&e>=i[1]&&e<=o[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=De.compose(this.position,this.scale,P2(this.rotation),Ao.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let i=this.parent;e&&i!==null&&i!==void 0&&i.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=De.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=De.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Ao.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let i=t,o=Ye(t.path,["states","*"]);if(o!==null){if(t.type===0){let[a]=o;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=Ot.zoom(l,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(s[d]=c[d])}}i={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=Ot.removeOverridden(t.path,t.props,a);i={...t,props:s}}}this.updateByPatchedOpBase(i,wo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let i of this.data.states)wo.toOps(this.data,i.data).forEach(a=>{let s=al.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let i=this.data.states.data(t);i&&(this.dataPatched=wo.patch(this.data,i),wo.toOps(this.data,i).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new Fo(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof Fo&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};ut();var Vu=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ue.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var Gu=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var zm=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ue.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var jm=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ue.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var Rt=class extends Fo{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new zm(e+"-fill",r.fill,i),this.stroke=new jm(e+"-stroke",r.stroke,i),this.dropShadow=new Vu(e+"-dropShadow",r.dropShadow,i),this.innerShadow=new Vu(e+"-innerShadow",r.innerShadow,i),this.backgroundBlur=new Gu(e+"-backgroundBlur",r.backgroundBlur,i),this.layerBlur=new Gu(e+"-layerBlur",r.layerBlur,i)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ue.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ue.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ue.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ue.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new Rt(this.uuid,this.data,e);return r.parent=void 0,r}};var Ca=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return T2(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new Ca(this.uuid,this.data,e);return r.parent=void 0,r}};var Ki=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Ki(this.uuid,this.data,e);return r.parent=void 0,r}};var Ta=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ue.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ue.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,i=this.data.text.textValue.toString(),o=r===2?i.toUpperCase():r===3?i.toLowerCase():i,{height:a}=e.drawText(o,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Ta(this.uuid,this.data,e);return r.parent=void 0,r}};var uc=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(o=>Hm.extremas(o)),r=[1/0,1/0],i=[-1/0,-1/0];for(let o=0,a=e.length;o<a;o++){let s=e[o];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>i[0]&&(i[0]=s[1][0]),s[1][1]>i[1]&&(i[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,o=this.data.points.length;i<o;i++){let a=this.data.points[i].data,s=this.data.points[i-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let i={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(i)}}getCenter(){let[e,r]=this.extremasBBox.min,[i,o]=this.getHalfSize();return[e+i,r+o]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let o=0,a=this.data.points.length;o<a;o++){let s=this.data.points[o].data;if(o===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[o-1].data,[c,d]=l.controlNext.position,[u,p]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};Hm.derive(m),e.bezierCurveTo(c,d,u,p,h,f)}}let r=this.data.points[0].data,i=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[o,a]=i.controlNext.position,[s,l]=r.controlPrevious.position,[c,d]=r.position;e.bezierCurveTo(o,a,s,l,c,d)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new uc(this.uuid,this.data,e);return r.parent=void 0,r}},Hm;(o=>{function n(a){let s=a.start,l=a.cp1,c=a.cp2,d=a.end,u=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(d[0]-c[0]),3*(d[1]-c[1])],f={start:u,cp:p,end:h};return a.derivative=f,f.derivative=z0.derive(f),f}o.derive=n;function t(a,s,l,c=!1){let d=a-2*s+l;if(d!==0){let u=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,h=-(u+p)/d,f=-(-u+p)/d;return[h,f]}else if(s!==l&&d===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??o.derive(a),l=s.start,c=s.cp,d=s.end;return[t(l[0],c[0],d[0]),t(l[1],c[1],d[1])]}o.droot=e;function r(a){let[s,l]=o.droot(a),c=[a.start[0],a.end[0]],d=[a.start[1],a.end[1]];for(let u of s)c.push(o.compute(a,Math.min(1,Math.max(0,u)))[0]);for(let u of l)d.push(o.compute(a,Math.min(1,Math.max(0,u)))[1]);return c.sort((u,p)=>u-p),d.sort((u,p)=>u-p),[[c[0],d[0]],[c[c.length-1],d[d.length-1]]]}o.extremas=r;function i(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,d=s*s,u=c*l,p=c*s*3,h=l*d*3,f=s*d;return[u*a.start[0]+p*a.cp1[0]+h*a.cp2[0]+f*a.end[0],u*a.start[1]+p*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}o.compute=i})(Hm||(Hm={}));var z0;(r=>{function n(i){let o=i.start,a=i.cp,s=i.end,l=[2*(a[0]-o[0]),2*(a[1]-o[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],d={start:l,end:c};return d.derivative=j0.derive(d),i.derivative=d,d}r.derive=n;function t(i){let o=i.derivative??r.derive(i),a=o.start,s=o.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(i,o){if(o===0)return[...i.start];if(o===1)return[...i.end];let a=1-o,s=a*a,l=o*o,c=s,d=a*o*2,u=l;return[c*i.start[0]+d*i.cp[0]+u*i.end[0],c*i.start[1]+d*i.cp[1]+u*i.end[1]]}r.compute=e})(z0||(z0={}));var j0;(e=>{function n(r){let i=r.start,o=r.end,a=[o[0]-i[0],o[1]-i[1]];return r.derivative=a,r.derivative}e.derive=n;function t(r,i){if(i===0)return[...r.start];if(i===1)return[...r.end];let o=r.start,a=r.end;return[o[0]+(a[0]-o[0])*i,o[1]+(a[1]-o[1])*i]}e.compute=t})(j0||(j0={}));var ai=class extends Fo{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.context=i;this.isBaseGroup=!0;this.children=[]}add(e){e.parent&&e.parent instanceof ai&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let i of this.children)i instanceof ai?i.traverse(e):r=e(i)}intersectsChildrenHelper(e,r,i,o,a){for(let s of this.children)if(s.intersects(e,r,i,!1)&&(a.push(s),o)||s instanceof ai&&s.intersectsChildrenHelper(e,r,i,o,a))return!0;return!1}intersectsChildren(e,r,i,o=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,r,i,o,a),a}intersectsChildrenHelperReverse(e,r,i,o,a){for(let s of this.children)if(s instanceof ai&&s.intersectsChildrenHelperReverse(e,r,i,o,a)||s.intersects(e,r,i,!1)&&(a.push(s),o))return!0;return!1}intersectsChildrenReverse(e,r,i,o=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,r,i,o,a),a}updateWorldMatrix(e,r,i){if(super.updateWorldMatrix(e,r,i),i&&this.children)for(let o of this.children)o.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(i=>{i.uuid===e&&(r=i)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new ai(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}},mi=class extends ai{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.updateState(r,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new mi(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};ut();var _r=class extends ai{constructor(e,r,i){super(e,r,i);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Ki(e+"-background",Tl.defaultData,i),this.background.parent=this,this.updateState(r,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,i){super.updateWorldMatrix(e,r,i),this.background?.updateWorldMatrix(e,r,i)}draw(e){if(!this.visible)return;e.save();let r=this.width,i=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new _r(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};var M2=Bd(Fm(),1),Wm=new Map,aU=4096,pc=null;function sU(n){let t=Wm.get(n);if(t!==void 0)return t;if(pc===null||!pc.isConnected){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none",pc=document.createElementNS("http://www.w3.org/2000/svg","path"),r.appendChild(pc),document.body.appendChild(r)}pc.setAttribute("d",n);let e=pc.getBBox();return Wm.size>=aU&&Wm.clear(),Wm.set(n,e),e}var ko=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=this.path;O2(this.path)&&(console.warn("Invalid SVG path",this.uuid),e=""),this._pathBBox=sU(e)}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new ko(this.uuid,this.data,e);return r.parent=void 0,r}};function O2(n){return/NaN/.test(n)}function I2(n,t=1,e=1){if(t<=0||e<=0)return n;if(O2(n))return console.warn("Cannot scale invalid path",n),qm([]);if(t===1&&e===1)return n;try{let i=(0,M2.parseSVG)(n).map(o=>{let a={...o};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return qm(i)}catch(r){return console.warn("Error parsing SVG path",r),qm([])}}function qm(n){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(r=>{let i=[];t.forEach(a=>{if(a in r){let s=r[a]*1;i.length&&s>=0&&i.push(","),i.push(s)}});let o=(e===r.code?i[0]<0?"":",":r.code)+i.join("");return e=r.code,o}).join("")}function D2(n,t,e){switch(t.type){case"ellipse2d":return new Ca(n,t,e);case"rectangle2d":return new Ki(n,t,e);case"text2d":return new Ta(n,t,e);case"vector2d":return new uc(n,t,e);case"path2d":return new ko(n,t,e);case"frame2d":return new _r(n,t,e);case"group2d":default:return new mi(n,t,e)}}Zt();var H0=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new mi(H0.GROUP_ID,{...Kd.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,i,o,a){let s=D2(t,e,a);s&&(i.add(s),i.children.splice(o,0,i.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof mi||s instanceof _r)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let i=0;for(let o of t)this.createObject(o.id,o.data,o.children,e,i,r),i+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,i){let o=this.find(t);if(o)try{o.updateByOp(e,r,{shared:i})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof ai&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof ai){let i=r.parent;r.resetBBoxNeedsUpdate(),i?.remove(r),i?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let i=r.parent,o=t.parent===null?this:this.find(t.parent);if(o===void 0&&!1&&console.error("unexpected",o,t),o instanceof ai||o===this){o.add(r);let a=t.localIndex;o.children.splice(a,0,o.children.pop()),r.updateWorldMatrix(!0,!1,!0),i?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,i=!1,o=[]){return this.group.intersectsChildren(t,e,r,i,o,!0)}intersectsChildrenReverse(t,e,r,i=!1,o=[]){return this.group.intersectsChildrenReverse(t,e,r,i,o,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],i=e;for(;i!==this.group;){let o=i;i=i.parent;let a=i.children.indexOf(o);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let i=this.getWithSortKey(r.id);i!==void 0&&e.push(i)}return e.sort((r,i)=>$a(r.sortKey,i.sortKey)),e.map(r=>r.entity)}},Ms=H0;Ms.GROUP_ID="scene2d";function W0({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:i,objectInitialWidth:o,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=n,d=t-r,u=e-i,p=o,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=d;else if(l===3)f+=d/2;else if(l===2)p=Math.max(1,p+d);else if(l===4){let y=t/r;p*=y,f*=y}}if(c!==0){if(c===1)m+=u;else if(c===3)m+=u/2;else if(c===2)h=Math.max(1,h+u);else if(c===4){let y=e/i;h*=y,m*=y}}return{width:p,height:h,position:[f,m]}}var lU=Bd(Fm(),1);var jue={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};ut();import{BufferGeometry as uU,CanvasTexture as pU,Float32BufferAttribute as N2,HalfFloatType as hU,MathUtils as fU,Mesh as mU,OrthographicCamera as yU,ShaderMaterial as gU,Uniform as vU,WebGLRenderTarget as bU}from"three";var cU=new Set;function R2(n){cU.add(n)}function q0(n,t,e,r){return r?e:2048/Math.max(1,n,t)}function B2(n,t,e,r){let i=q0(n,t,e,r),o=Math.max(e,512/Math.min(n,t)),a=Math.min(o,i);return{width:Math.max(1,Math.ceil(n*a)),height:Math.max(1,Math.ceil(t*a))}}var xU=`
1314
1314
  varying vec2 vUv;
1315
1315
  void main() {
@@ -1325,7 +1325,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
1325
1325
  `,e),u=e.horizontalAlign===1?d:0,p=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],d),h=this.getLineInitialOffsetY(a,t.length,c,o,e.verticalAlign),f=[],m=t.map(()=>[]),y=t.map(()=>[]);for(let b=0;b<t.length;b++){let x=t[b],S={features:{liga:!0},letterSpacing:e.letterSpacing},v=[];try{v=i.stringToGlyphs(x,S)}catch(M){this.warnLayoutError(M)}p=this.getLineInitialOffsetX(s[b],l,e.horizontalAlign,x,d);let w=[];try{w=this.reverseLigaturesTable(i,x,v)}catch(M){this.warnLayoutError(M)}let A=this.computeSpaceWidthForLine(t,b,e,r),E=0,P=v[0];P&&e.horizontalAlign===2&&P.leftSideBearing!==void 0&&(p-=P.leftSideBearing*o);try{this.font?.forEachGlyph(x,p,h,e.fontSize,S,(M,R,D,N,C)=>{let B=M.index===0?`
1326
1326
  `:M.unicode?String.fromCharCode(M.unicode):void 0,_=w[E],F=0;if(B===`
1327
1327
  `)F=u;else if(B===" ")F=A;else{let V=this.createPath(M,o,R,D,e);V&&(F=V.offsetX,f.push(V.path))}if(!_||_.replacements.length===1)y[b].push([R,D]),m[b].push(F);else{let V=_.replacements.map(W=>(i.glyphs.get(W).advanceWidth??0)*o),K=V.reduce((W,H)=>W+=H,0),q=V.map(W=>W/K),G=R;for(let W=0;W<q.length;W++){let H=F*q[W];y[b].push([G,D]),m[b].push(H),G+=H}}E++})}catch(M){this.warnLayoutError(M)}h-=a}let g=[];for(let b=0,x=f.length;b<x;b++)g.push(...f[b].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,i,o){return(r===3||r===2)&&i.indexOf(`
1328
- `)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,i,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*i,l=t-s,c=-this.ascender*i-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,i,o){let a=t.getPath(r,-i,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new Ym,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=UU(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,i){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(i.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function UU(n){if(n.length){let t=n[0];if(t instanceof kU)return t.v1;if(t instanceof FU||t instanceof VU)return t.v0}}Ui("TextGeometry",(n,t,e)=>new wa(n,t,e));var z2={create:(n,t)=>new ec(n,t)};ru("TextGeometry",z2);ru("InputGeometry",z2);ET(Km);Oe("text");var j2=200,zU=null;function H2(n){zU=n}var zu=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},W2=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return jU(Math.atan2(r,e))},q2=(n,t,e)=>{let r={x:0,y:0};return e=Jm(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Jm=n=>n*(Math.PI/180),jU=n=>n*(180/Math.PI),X2=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,Zm=new Map,Y2=n=>{Zm.has(n)&&clearTimeout(Zm.get(n)),Zm.set(n,setTimeout(function(){Zm.delete(n),n()},100))},fc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.addEventListener?n.addEventListener(i,e,!1):n.attachEvent&&n.attachEvent(i,e)},mc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.removeEventListener?n.removeEventListener(i,e):n.detachEvent&&n.detachEvent(i,e)};var $m=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),eS=()=>{if(typeof window>"u")return;let n=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:n,y:t}},ey=(n,t)=>{t.top||t.right||t.bottom||t.left?(n.style.top=t.top,n.style.right=t.right,n.style.bottom=t.bottom,n.style.left=t.left):(n.style.left=t.x+"px",n.style.top=t.y+"px")},ty=(n,t,e)=>{let r=K2(n);for(let i in r)if(Object.prototype.hasOwnProperty.call(r,i))if(typeof t=="string")r[i]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[i]=o.slice(0,-2)}return r},Q2=(n,t)=>{let e=K2(n);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},K2=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},ry=(n,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n},Z2=(n,t)=>{let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},ju=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},J2=(n,t,e)=>({x:Math.min(Math.max(n.x,t.x-e),t.x+e),y:Math.min(Math.max(n.y,t.y-e),t.y+e)});typeof window<"u"&&($2="ontouchstart"in window,eO=!!window.PointerEvent,tO=!!window.MSPointerEvent);var $2,eO,tO,Hu={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},yc,Wu={};eO?yc=Hu.pointer:tO?yc=Hu.MSPointer:$2?(yc=Hu.touch,Wu=Hu.mouse):yc=Hu.mouse;function Is(){}Is.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Is.prototype.off=function(n,t){var e=this;return e._handlers_=e._handlers_||{},n===void 0?e._handlers_={}:t===void 0?e._handlers_[n]=null:e._handlers_[n]&&e._handlers_[n].indexOf(t)>=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Is.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(a){a.call(e,{type:i,target:e},t)})};Is.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=Z2(t.options,n))};Is.prototype.bindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},fc(n,yc[t],e._domHandlers_[t]),Wu[t]&&fc(n,Wu[t],e._domHandlers_[t]),e};Is.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},mc(n,yc[t],e._domHandlers_[t]),Wu[t]&&mc(n,Wu[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var gc=Is;function Sr(n,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=n,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=Sr.id,Sr.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}Sr.prototype=new gc;Sr.constructor=Sr;Sr.id=0;Sr.prototype.buildEl=function(n){return this.ui={},this.options.dataOnly?this:(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)};Sr.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=Q2("borderRadius","50%"),e=ty("transition","opacity",n),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)"},ry(r.el,e),this.options.shape==="circle"&&ry(r.back,t),ry(r.front,t),this.applyStyles(r),this};Sr.prototype.applyStyles=function(n){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in n[t])this.ui[t].style[e]=n[t][e];return this};Sr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Sr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Sr.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};Sr.prototype.show=function(n){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 n=="function"&&n.call(this)},t.options.fadeTime)),t};Sr.prototype.hide=function(n){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 e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof n=="function"&&n.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(n,r)}return t};Sr.prototype.setPosition=function(n,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",i={};i.front=ty("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof n=="function"&&n.call(e),e.restCallback()},e.options.fadeTime)};Sr.prototype.restCallback=function(){var n=this,t={};t.front=ty("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};Sr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Sr.prototype.computeDirection=function(n){var t=n.angle.radian,e=Math.PI/4,r=Math.PI/2,i,o,a;if(t>e&&t<e*3&&!n.lockX?i="up":t>-e&&t<=e&&!n.lockY?i="left":t>-e*3&&t<=-e&&!n.lockX?i="down":n.lockY||(i="right"),n.lockY||(t>-r&&t<r?o="left":o="right"),n.lockX||(t>0?a="up":a="down"),n.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:i},n.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return n;(!c.x||!c.y)&&this.trigger("plain",n),c.x||this.trigger("plain:"+o,n),c.y||this.trigger("plain:"+a,n),c.angle||this.trigger("dir dir:"+i,n)}else this.resetDirection();return n};var rO=Sr;function pr(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=pr.id,pr.id+=1,e.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},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}pr.prototype=new gc;pr.constructor=pr;pr.id=0;pr.prototype.prepareNipples=function(){var n=this,t=n.nipples;t.on=n.on.bind(n),t.off=n.off.bind(n),t.options=n.options,t.destroy=n.destroy.bind(n),t.ids=n.ids,t.id=n.id,t.processOnMove=n.processOnMove.bind(n),t.processOnEnd=n.processOnEnd.bind(n),t.get=function(e){if(e===void 0)return t[0];for(var r=0,i=t.length;r<i;r+=1)if(t[r].identifier===e)return t[r];return!1}};pr.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};pr.prototype.begin=function(){var n=this,t=n.options;if(t.mode==="static"){var e=n.createNipple(t.position,n.manager.getIdentifier());e.add(),n.idles.push(e)}};pr.prototype.createNipple=function(n,t){var e=this,r=e.manager.scroll,i={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(n.x&&n.y)i={x:n.x-a.x,y:n.y-a.y};else if(n.top||n.right||n.bottom||n.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=n.top,s.style.right=n.right,s.style.bottom=n.bottom,s.style.left=n.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),i=n,n={x:l.left+r.x,y:l.top+r.y}}var c=new rO(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:n,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(ey(c.ui.el,i),ey(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};pr.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};pr.prototype.bindNipple=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};pr.prototype.pressureFn=function(n,t,e){var r=this,i=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=n.force||n.pressure||n.webkitForce||0;o!==i&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),i=o)}.bind(r),100)};pr.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=$m(n),t.updateBox();var i=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[n[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return ju(n,i),t.manager.bindDocument(),!1};pr.prototype.processOnStart=function(n){var t=this,e=t.options,r,i=t.manager.getIdentifier(n),o=n.force||n.pressure||n.webkitForce||0,a={x:n.pageX,y:n.pageY},s=t.getOrCreate(i,a);s.identifier!==i&&t.manager.removeIdentifier(s.identifier),s.identifier=i;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(n,d,d.identifier),t.processOnMove(n)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=zu(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(n);return}}return s};pr.prototype.getOrCreate=function(n,t){var e=this,r=e.options,i;return/(semi|static)/.test(r.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):r.mode==="semi"?e.createNipple(t,n):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,n),i)};pr.prototype.processOnMove=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.scroll;if(!X2(n)){this.processOnEnd(n);return}if(!i){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=i.el.getBoundingClientRect();i.position={x:o.x+a.left,y:o.y+a.top}}i.identifier=r;var s=i.options.size/2,l={x:n.pageX,y:n.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var c=zu(l,i.position),d=W2(l,i.position),u=Jm(d),p=c/s,h={distance:c,position:l},f,m;if(i.options.shape==="circle"?(f=Math.min(c,s),m=q2(i.position,f,d)):(m=J2(l,i.position,s),f=zu(m,i.position)),e.follow){if(c>s){let x=l.x-m.x,S=l.y-m.y;i.position.x+=x,i.position.y+=S,i.el.style.top=i.position.y-(t.box.top+o.y)+"px",i.el.style.left=i.position.x-(t.box.left+o.x)+"px",c=zu(l,i.position)}}else l=m,c=f;var y=l.x-i.position.x,g=l.y-i.position.y;i.frontPosition={x:y,y:g},e.dataOnly||ey(i.ui.front,i.frontPosition);var b={identifier:i.identifier,position:l,force:p,pressure:n.force||n.pressure||n.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:i,lockX:e.lockX,lockY:e.lockY};b=i.computeDirection(b),b.angle={radian:Jm(180-d),degree:180-d},i.trigger("move",b),t.trigger("move "+i.id+":move",b)};pr.prototype.processOnEnd=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};pr.prototype.onDestroyed=function(n,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};pr.prototype.destroy=function(){var n=this;n.unbindEvt(n.options.zone,"start"),n.nipples.forEach(function(e){e.destroy()});for(var t in n.pressureIntervals)Object.prototype.hasOwnProperty.call(n.pressureIntervals,t)&&clearInterval(n.pressureIntervals[t]);n.trigger("destroyed",n.nipples),n.manager.unbindDocument(),n.off(),n.pressureIntervals={},n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.manager=null};var iO=pr;function yr(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=eS(),t._windowBound=!1,t.config(n),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(i){i.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){Y2(e)},t._onScroll=function(){t.scroll=eS()},t.collections}yr.prototype=new gc;yr.constructor=yr;yr.prototype.prepareCollections=function(){var n=this;n.collections.create=n.create.bind(n),n.collections.on=n.on.bind(n),n.collections.off=n.off.bind(n),n.collections.destroy=n.destroy.bind(n),n.collections.get=function(t){var e;return n.collections.every(function(r){return e=r.get(t),!e}),e}};yr.prototype.create=function(n){return this.createCollection(n)};yr.prototype.bindWindowEvents=function(){var n=this;n._windowBound||typeof window>"u"||(n._windowBound=!0,fc(window,"resize",n._onResize),fc(window,"scroll",n._onScroll))};yr.prototype.unbindWindowEvents=function(){var n=this;!n._windowBound||typeof window>"u"||(n._windowBound=!1,mc(window,"resize",n._onResize),mc(window,"scroll",n._onScroll))};yr.prototype.createCollection=function(n){var t=this,e=new iO(t,n);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};yr.prototype.bindCollection=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};yr.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};yr.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};yr.prototype.getIdentifier=function(n){var t;return n?(t=n.identifier===void 0?n.pointerId:n.identifier,t===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]};yr.prototype.removeIdentifier=function(n){var t={};for(var e in this.ids)if(this.ids[e]===n){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};yr.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};yr.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};yr.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};yr.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=$m(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[i](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),ju(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return ju(t,a),!1};yr.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.unbindWindowEvents(),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.collections=[],n.off()};yr.prototype.onDestroyed=function(n,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var nO=yr;var vc=null;function oO(){return vc||(vc=new nO),vc}var HU={create:function(n){return oO().create(n)},destroy:function(){vc&&(vc.destroy(),vc=null)},get factory(){return oO()}},aO=HU;import{Box3 as lz,Euler as wc,EventDispatcher as cz,Line3 as AO,MathUtils as Pa,Matrix4 as $n,Quaternion as Xr,Vector2 as dz,Vector3 as Fe}from"three";import{Camera as JU,OrthographicCamera as $U,PerspectiveCamera as ez,Vector3 as yn,Object3D as lO,Quaternion as tz,Matrix4 as Ds}from"three";import{Camera as XU,LineSegments as YU,BufferGeometry as QU,LineBasicMaterial as KU,Color as tS,Vector3 as ZU,Float32BufferAttribute as sO}from"three";var ny=new ZU,Zi=new XU,rS=class extends YU{constructor(e){let r=new QU,i=new KU({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new tS(15711266),c=new tS(15711266),d=new tS(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new sO(o,3)),r.setAttribute("color",new sO(a,3));super(r,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,r=this.pointMap,i=!0;Zi.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=i?.8:1e-4;mn("n1",r,e,Zi,-o,-a,s),mn("n2",r,e,Zi,o,-a,s),mn("n3",r,e,Zi,-o,a,s),mn("n4",r,e,Zi,o,a,s);let l=s;mn("f1",r,e,Zi,-o,-a,l),mn("f2",r,e,Zi,o,-a,l),mn("f3",r,e,Zi,-o,a,l),mn("f4",r,e,Zi,o,a,l);let c=l,d=.5;mn("u1",r,e,Zi,o*.7*d,a*1.1,c),mn("u2",r,e,Zi,-o*.7*d,a*1.1,c),mn("u3",r,e,Zi,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mn(n,t,e,r,i,o,a){ny.set(i,o,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],ny.x,ny.y,ny.z)}}var oy=class extends Gn(rS){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,r){Un(this.object,this.geometry,e,r,!0)}};var ay=790;function cO(n){return 1-Math.pow(1-n,3)}var bc=new yn,iS=new yn,nS=new tz,oS=new yn,qu=new yn,aS=new yn,Zn=class extends Yi(JU,oy){constructor(e="",r={...ds.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=an.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=Zn.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new Ds,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,o=this.height;this.orthoCamera=new $U(i*-.5,i*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new ez(45,i/o,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 r=Zn.projectionTransitionsEnabled;Zn.projectionTransitionsEnabled=!1;try{return e()}finally{Zn.projectionTransitionsEnabled=r}}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,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}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,r,i){typeof e=="number"&&(e=new yn(e,r,i)),super.lookAt(e),this.getWorldPosition(bc),this.targetOffset=bc.distanceTo(e)}getTarget(e=new yn){return this.getWorldDirection(iS),this.getWorldPosition(bc),iS.multiplyScalar(this.targetOffset),e.copy(bc).add(iS),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(bc),bc.distanceTo(e)}updateUp(){this.getWorldQuaternion(nS),oS.set(0,0,1).applyQuaternion(nS),qu.copy(lO.DEFAULT_UP),this.isUpVectorFlipped&&qu.negate(),qu.applyQuaternion(nS),aS.copy(lO.DEFAULT_UP).projectOnPlane(oS),this.angleOffsetFromUp=aS.angleTo(qu),this.angleOffsetFromUp*=aS.cross(qu).dot(oS)>=0?1:-1}updateTransformState(e,r){let i=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let r=e.getWorldPosition(new yn),o=e.getWorldDirection(new yn).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new yn).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new yn;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,i=!1){if(this.aspect=e/r,i){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-ay*.5*o,this.right=ay*.5*o,this.top=ay*.5*(1/a),this.bottom=-ay*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;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 r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:cO(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Zn.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Zn.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new Ds,blend:new Ds,blendInverse:new Ds,start:0,duration:Zn.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=Zn.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let i=cO(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=i*c/(i*c+(1-i)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;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 r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let i=this._projectionTransition;i===void 0?(i={from:new Ds,blend:new Ds,blendInverse:new Ds,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(r.from),i.start=r.start,i.duration=r.duration,i.referenceDepth=r.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,r,i,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,a,s):this.orthoCamera.setViewOffset(e,r,i,o,a,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,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),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=an.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={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};return $d(r,e)}updateCameraSubtype(e,r){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(i,r.zoom),r.near!==void 0&&this.setNear(i,r.near),r.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),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(r?.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=an.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,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}}},St=Zn;St.projectionTransitionsEnabled=!1,St.projectionTransitionDuration=350,St.projectionTransitionMinAgeMs=1e3;var rz=null;function dO(n){rz=n}var iz,uO=new Promise(n=>{iz=n});import{Box3 as Fhe,Euler as pO,Matrix4 as hO,Quaternion as lS,Sphere as az,Vector3 as Xu}from"three";import{BufferGeometry as nz,Float32BufferAttribute as sS}from"three";function oz(n){let t=n.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,i=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||i<l||o<l||a<l||s<l}function sy(n,t){let e=new nz;if(t&&oz(t))return e.setAttribute("position",new sS([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new sS([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Tu(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new sS(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}import{mergeGeometries as Uhe}from"three/examples/jsm/utils/BufferGeometryUtils.js";var sz;uO.then(n=>sz=n);var jhe=new Xu,Hhe=new lS,Whe=new Xu,qhe=new pO(0,0,0,"YXZ"),Xhe=new pO(0,0,0,"XYZ"),Yhe=new Xu,Qhe=new Xu,Khe=new Xu(1,1,1),Zhe=new lS,Jhe=new hO,$he=new hO;var efe=new lS,tfe=new az;var cS={type:"beginEvent",eventName:"Collision"};var dS=n=>n.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);import{Mesh as uz}from"three";ut();var fO=4,uS=8;var pS=.02,hS=.3,pz=65,mO=new Fe,yO=new Fe,hz=new Fe,qr=new Fe,Vo=new Fe,xc=new Fe,fS=new $n,gO=new $n,fz=new $n,Ti=new Xr,Rs=new Xr,Sc=new wc(0,0,0,"YXZ"),mz=new Fe(1,0,0),Jn=new Fe(0,1,0),yz=new Fe(0,0,1),vO=new Fe(1,1,1),mS=[],bO=n=>mS[n]??(mS[n]=new Fe),yS=new Fe,gz=new Fe,vz=new Fe,bz=new Fe,xO=new Xr,xz=new Fe,SO=new Xr,Sz=1,wz=.025,Az=16e-6,wO=12,Ez=20,Mr=new AO,Ji=new lz,Cz={type:"requestRender"},Tz={type:"updateMatrix"},ly=class extends cz{constructor(e,r,i,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new $n;this.target0=new Fe;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=j2;this.euler0=new wc(0,0,0,"YXZ");this.position0Cam=new Fe;this.quat0Cam=new Xr;this.scale0Cam=new Fe;this.hiddenMatrix0Cam=new $n;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new AO(new Fe(0,-40,0),new Fe(0,40,0)),matrix:new $n,position:new Fe,rotation:new Xr};this.euler=new wc(0,0,0,"YXZ");this.eulerDelta=new Fe;this.lastPosition=new Fe;this.lastCameraQuaternion=new Xr;this.lastCameraPosition=new Fe;this.PI_2=Math.PI/2;this.prevMouse=new dz;this.velocityTarget=new Fe;this.velocity=new Fe;this.directionXZ=new Fe;this.rotVelocityStick=new Fe;this.rotVelocityTarget=new Fe;this.rotVelocity=new Fe;this.rotDirection=new Fe;this.nonColliderRotOffset=new $n;this.nonColliderPosOffset=new $n;this.firstPointerId=-1;this.rot=new Fe;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 $n;this.objectToTarget=new Fe;this.objectToTarget0=new Fe;this.objectToCamXZ=new Fe;this.objectToCamXZ0=new Fe;this.targetToCamera=new Fe;this.targetToCamera0=new Fe;this.cameraPolarAxis0=new Fe;this.targetPos=new Fe;this.targetQuat=new Xr;this.lerpFactorPos=new Fe().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Xr;this.objXZQuatInv=new Xr;this.objXZRotMat=new $n;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new Fe;this.pushedVelocity=new Fe;this.groundYRotation=0;this.objectRealQuat=new Xr;this.colliderWorldQuat=new Xr;this.groundNormal=new Fe;this.groundTilt=new Xr;this.groundTiltInv=new Xr;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new Fe;this.quaternion=new Xr;this.scale=new Fe;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!hi&&!_b&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(_b&&tC<15.5&&!hi?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?ly.isLocked=!0:ly.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let i=2;i<4;i++){let o=e.axes[i];r===0?i===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let y=new Fe(0,0,-1).applyQuaternion(this.camera.quaternion),g=new Fe().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let b;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,b=g.projectOnVector(y)):g.y/y.y>0?b=y.multiplyScalar(g.y/y.y):b=y.multiplyScalar(g.length()),this.targetToCamera0.copy(b).negate();let x=this.camera.position.clone().add(b);this.objectToTarget0.subVectors(x,this.position);let S=new wc().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof St&&(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=(i.speedTranslate??250)*Sz,this.speedOrbit=(i.speedRotate??100)*wz,this.mouseOrbitSensitivity=(i.speedRotate??100)*Az,this.keyAssignments=i.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??ha.defaultData.gravity)*wO,this.usePhysics=this.gloabalPhysics.usePhysics??ha.defaultData.usePhysics,this.jumpPower=i.jumpPower*Ez,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??wl.defaultDataThirdPerson.orientWith,this.slopeThresh=pz*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*pS/this.pixelsPerMeter,this.stepThresh=i.collider.height*hS/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*pS/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*hS/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*pS/this.pixelsPerMeter,this.stepThresh=i.collider.height*hS/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let h=new Fe().fromArray(i.collider.position.map(y=>typeof y=="number"?y:0)),f=new Xr().setFromEuler(new wc().fromArray([...i.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,vO),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 m=i.navmesh.destinationHelperRadius*2;if(m>0){let y=new fe;y.push({fi:0,data:{...Ft.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Ft.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=fm({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new uz(zf.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new wc().setFromQuaternion(this.quaternion,"YXZ"),i=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,i,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof St?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.hiddenMatrix.copy(this.hiddenMatrix0Cam),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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Sl.list.forEach(i=>{this.actions[i]=Tt({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,r,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"),er(this.actions.idle),er(this.actions.move),er(this.actions.run),er(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return qr.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 r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Vo.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*wO),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,uS,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(qr).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}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 l=qr.subVectors(this.path[1],this.position),c=Vo.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.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 a=hz.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Vo.copy(a);s.y=0,a.set(0,a.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=qr;this.camera.getWorldDirection(s);let l=xc.copy(Jn).multiplyScalar(s.dot(Jn));s.sub(l);let c=Vo.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).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(Sc.setFromVector3(this.rot),this.moveMode==="walk"&&(Sc.x=0),a.applyEuler(Sc),o&&(Rs.setFromUnitVectors(Jn,this.groundNormal),a.applyQuaternion(Rs)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(yS,xO,gz);let c=this.object.getWorldPosition(vz).add(this.collider.position).sub(yS);SO.copy(l.prevQ).invert().premultiply(xO);let d=xc.subVectors(yS,l.prevT).add(bz.copy(c).applyQuaternion(SO).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),qr.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=ke.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof cr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(cS));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),bO(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=bO(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.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(r),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*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Jn,this.euler.y-this.euler0.y);let s=Vo.copy(this.objectToCamXZ).normalize(),l=xc.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(qr.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+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=Pa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Pa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Pa.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Sc.copy(this.euler),Sc.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Sc)),Ti.setFromAxisAngle(mz,this.rot.x),Rs.setFromAxisAngle(Jn,this.rot.y),Rs.multiply(Ti),Ti.setFromAxisAngle(yz,this.rot.z),Rs.multiply(Ti),this.quaternion.copy(Rs),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=Vo.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new Fe;for(let p=0;p<5;p++){let h=s.length(),f=xc.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,uS|fO,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let S of x)if(S.data.target==="character"){let v=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,w;if(m.cloner){for(let A of m.cloner.children)if(A.rigidBody===v){w=A;break}}S.dispatch(w),m.dispatchEvent(cS)}}}let y=mO.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=yO.copy(f).multiplyScalar(l.time_of_impact).dot(y),b=l.time_of_impact;if(b===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(b=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,b)),s.copy(f).multiplyScalar(h-b),Math.acos(-y.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=xc.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let v=x.add(S);v.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(v,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,uS|fO,void 0,void 0,this.object.rigidBody);w!==null&&w.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),qr.copy(this.position).divideScalar(this.pixelsPerMeter),Ti.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&xz.copy(qr).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(qr,!0),d.setRotation(Ti,!0)):(d.setNextKinematicTranslation(qr),d.setNextKinematicRotation(Ti)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);fS.lookAt(l,s,Jn).setPosition(l),fS.decompose(this.targetPos,this.targetQuat,qr),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.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Pa.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Pa.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(Tz),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)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Cz),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ti.setFromAxisAngle(Jn,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Pa.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let r;this.cameraXAxis==="Limit"?r=Pa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Pa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let o=Rs.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){Jn.angleTo(e)*180/Math.PI<15||Jn.angleTo(e)*180/Math.PI>85?Ti.identity():Ti.setFromUnitVectors(Jn,e),this.groundTilt.slerp(Ti,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=yO.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=fS.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qr,Ti,Vo).compose(qr,Ti,vO);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Ji.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=gO.copy(s).invert(),c=fz.copy(gO).multiply(i);Mr.copy(this.collider.segment),Mr.start.applyMatrix4(c),Mr.end.applyMatrix4(c);let d=mO.copy(this.position).applyMatrix4(l);Ji.expandByPoint(Mr.start),Ji.expandByPoint(Mr.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(Mr.end)},intersectsBounds:u=>u.intersectsBox(Ji),intersectsTriangle:u=>{let p=qr,h=Vo,f=u.closestPointToSegment(Mr,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=xc.copy(d);g.addScaledVector(y,m);let b=g.applyMatrix4(s).sub(this.position);r.add(b),Mr.start.addScaledVector(y,m),Mr.end.addScaledVector(y,m)}}})}),Ji.makeEmpty(),Mr.copy(this.collider.segment),Mr.start.applyMatrix4(i),Mr.end.applyMatrix4(i),Ji.expandByPoint(Mr.start),Ji.expandByPoint(Mr.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(Mr.end)},intersectsBounds:a=>a.intersectsBox(Ji),intersectsTriangle:a=>{let s=qr,l=Vo,c=a.closestPointToSegment(Mr,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),Mr.start.addScaledVector(u,d),Mr.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}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()}},Yu=ly;Yu.isLocked=!1;import{BufferAttribute as TO,BufferGeometry as Mz,Vector3 as Qu}from"three";import{mergeGeometries as Oz}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Pz,EO=new Promise(n=>{Pz=n});var CO;var Iz=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.38/build/",Dz=n=>`
1328
+ `)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,i,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*i,l=t-s,c=-this.ascender*i-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,i,o){let a=t.getPath(r,-i,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new Ym,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=UU(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,i){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(i.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function UU(n){if(n.length){let t=n[0];if(t instanceof kU)return t.v1;if(t instanceof FU||t instanceof VU)return t.v0}}Ui("TextGeometry",(n,t,e)=>new wa(n,t,e));var z2={create:(n,t)=>new ec(n,t)};ru("TextGeometry",z2);ru("InputGeometry",z2);ET(Km);Oe("text");var j2=200,zU=null;function H2(n){zU=n}var zu=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},W2=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return jU(Math.atan2(r,e))},q2=(n,t,e)=>{let r={x:0,y:0};return e=Jm(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Jm=n=>n*(Math.PI/180),jU=n=>n*(180/Math.PI),X2=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,Zm=new Map,Y2=n=>{Zm.has(n)&&clearTimeout(Zm.get(n)),Zm.set(n,setTimeout(function(){Zm.delete(n),n()},100))},fc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.addEventListener?n.addEventListener(i,e,!1):n.attachEvent&&n.attachEvent(i,e)},mc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.removeEventListener?n.removeEventListener(i,e):n.detachEvent&&n.detachEvent(i,e)};var $m=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),eS=()=>{if(typeof window>"u")return;let n=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:n,y:t}},ey=(n,t)=>{t.top||t.right||t.bottom||t.left?(n.style.top=t.top,n.style.right=t.right,n.style.bottom=t.bottom,n.style.left=t.left):(n.style.left=t.x+"px",n.style.top=t.y+"px")},ty=(n,t,e)=>{let r=K2(n);for(let i in r)if(Object.prototype.hasOwnProperty.call(r,i))if(typeof t=="string")r[i]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[i]=o.slice(0,-2)}return r},Q2=(n,t)=>{let e=K2(n);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},K2=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},ry=(n,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n},Z2=(n,t)=>{let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},ju=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},J2=(n,t,e)=>({x:Math.min(Math.max(n.x,t.x-e),t.x+e),y:Math.min(Math.max(n.y,t.y-e),t.y+e)});typeof window<"u"&&($2="ontouchstart"in window,eO=!!window.PointerEvent,tO=!!window.MSPointerEvent);var $2,eO,tO,Hu={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},yc,Wu={};eO?yc=Hu.pointer:tO?yc=Hu.MSPointer:$2?(yc=Hu.touch,Wu=Hu.mouse):yc=Hu.mouse;function Is(){}Is.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Is.prototype.off=function(n,t){var e=this;return e._handlers_=e._handlers_||{},n===void 0?e._handlers_={}:t===void 0?e._handlers_[n]=null:e._handlers_[n]&&e._handlers_[n].indexOf(t)>=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Is.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(a){a.call(e,{type:i,target:e},t)})};Is.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=Z2(t.options,n))};Is.prototype.bindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},fc(n,yc[t],e._domHandlers_[t]),Wu[t]&&fc(n,Wu[t],e._domHandlers_[t]),e};Is.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},mc(n,yc[t],e._domHandlers_[t]),Wu[t]&&mc(n,Wu[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var gc=Is;function Sr(n,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=n,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=Sr.id,Sr.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}Sr.prototype=new gc;Sr.constructor=Sr;Sr.id=0;Sr.prototype.buildEl=function(n){return this.ui={},this.options.dataOnly?this:(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)};Sr.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=Q2("borderRadius","50%"),e=ty("transition","opacity",n),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)"},ry(r.el,e),this.options.shape==="circle"&&ry(r.back,t),ry(r.front,t),this.applyStyles(r),this};Sr.prototype.applyStyles=function(n){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in n[t])this.ui[t].style[e]=n[t][e];return this};Sr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Sr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Sr.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};Sr.prototype.show=function(n){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 n=="function"&&n.call(this)},t.options.fadeTime)),t};Sr.prototype.hide=function(n){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 e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof n=="function"&&n.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(n,r)}return t};Sr.prototype.setPosition=function(n,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",i={};i.front=ty("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof n=="function"&&n.call(e),e.restCallback()},e.options.fadeTime)};Sr.prototype.restCallback=function(){var n=this,t={};t.front=ty("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};Sr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Sr.prototype.computeDirection=function(n){var t=n.angle.radian,e=Math.PI/4,r=Math.PI/2,i,o,a;if(t>e&&t<e*3&&!n.lockX?i="up":t>-e&&t<=e&&!n.lockY?i="left":t>-e*3&&t<=-e&&!n.lockX?i="down":n.lockY||(i="right"),n.lockY||(t>-r&&t<r?o="left":o="right"),n.lockX||(t>0?a="up":a="down"),n.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:i},n.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return n;(!c.x||!c.y)&&this.trigger("plain",n),c.x||this.trigger("plain:"+o,n),c.y||this.trigger("plain:"+a,n),c.angle||this.trigger("dir dir:"+i,n)}else this.resetDirection();return n};var rO=Sr;function pr(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=pr.id,pr.id+=1,e.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},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}pr.prototype=new gc;pr.constructor=pr;pr.id=0;pr.prototype.prepareNipples=function(){var n=this,t=n.nipples;t.on=n.on.bind(n),t.off=n.off.bind(n),t.options=n.options,t.destroy=n.destroy.bind(n),t.ids=n.ids,t.id=n.id,t.processOnMove=n.processOnMove.bind(n),t.processOnEnd=n.processOnEnd.bind(n),t.get=function(e){if(e===void 0)return t[0];for(var r=0,i=t.length;r<i;r+=1)if(t[r].identifier===e)return t[r];return!1}};pr.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};pr.prototype.begin=function(){var n=this,t=n.options;if(t.mode==="static"){var e=n.createNipple(t.position,n.manager.getIdentifier());e.add(),n.idles.push(e)}};pr.prototype.createNipple=function(n,t){var e=this,r=e.manager.scroll,i={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(n.x&&n.y)i={x:n.x-a.x,y:n.y-a.y};else if(n.top||n.right||n.bottom||n.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=n.top,s.style.right=n.right,s.style.bottom=n.bottom,s.style.left=n.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),i=n,n={x:l.left+r.x,y:l.top+r.y}}var c=new rO(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:n,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(ey(c.ui.el,i),ey(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};pr.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};pr.prototype.bindNipple=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};pr.prototype.pressureFn=function(n,t,e){var r=this,i=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=n.force||n.pressure||n.webkitForce||0;o!==i&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),i=o)}.bind(r),100)};pr.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=$m(n),t.updateBox();var i=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[n[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return ju(n,i),t.manager.bindDocument(),!1};pr.prototype.processOnStart=function(n){var t=this,e=t.options,r,i=t.manager.getIdentifier(n),o=n.force||n.pressure||n.webkitForce||0,a={x:n.pageX,y:n.pageY},s=t.getOrCreate(i,a);s.identifier!==i&&t.manager.removeIdentifier(s.identifier),s.identifier=i;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(n,d,d.identifier),t.processOnMove(n)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=zu(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(n);return}}return s};pr.prototype.getOrCreate=function(n,t){var e=this,r=e.options,i;return/(semi|static)/.test(r.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):r.mode==="semi"?e.createNipple(t,n):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,n),i)};pr.prototype.processOnMove=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.scroll;if(!X2(n)){this.processOnEnd(n);return}if(!i){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=i.el.getBoundingClientRect();i.position={x:o.x+a.left,y:o.y+a.top}}i.identifier=r;var s=i.options.size/2,l={x:n.pageX,y:n.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var c=zu(l,i.position),d=W2(l,i.position),u=Jm(d),p=c/s,h={distance:c,position:l},f,m;if(i.options.shape==="circle"?(f=Math.min(c,s),m=q2(i.position,f,d)):(m=J2(l,i.position,s),f=zu(m,i.position)),e.follow){if(c>s){let x=l.x-m.x,S=l.y-m.y;i.position.x+=x,i.position.y+=S,i.el.style.top=i.position.y-(t.box.top+o.y)+"px",i.el.style.left=i.position.x-(t.box.left+o.x)+"px",c=zu(l,i.position)}}else l=m,c=f;var y=l.x-i.position.x,g=l.y-i.position.y;i.frontPosition={x:y,y:g},e.dataOnly||ey(i.ui.front,i.frontPosition);var b={identifier:i.identifier,position:l,force:p,pressure:n.force||n.pressure||n.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:i,lockX:e.lockX,lockY:e.lockY};b=i.computeDirection(b),b.angle={radian:Jm(180-d),degree:180-d},i.trigger("move",b),t.trigger("move "+i.id+":move",b)};pr.prototype.processOnEnd=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};pr.prototype.onDestroyed=function(n,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};pr.prototype.destroy=function(){var n=this;n.unbindEvt(n.options.zone,"start"),n.nipples.forEach(function(e){e.destroy()});for(var t in n.pressureIntervals)Object.prototype.hasOwnProperty.call(n.pressureIntervals,t)&&clearInterval(n.pressureIntervals[t]);n.trigger("destroyed",n.nipples),n.manager.unbindDocument(),n.off(),n.pressureIntervals={},n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.manager=null};var iO=pr;function yr(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=eS(),t._windowBound=!1,t.config(n),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(i){i.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){Y2(e)},t._onScroll=function(){t.scroll=eS()},t.collections}yr.prototype=new gc;yr.constructor=yr;yr.prototype.prepareCollections=function(){var n=this;n.collections.create=n.create.bind(n),n.collections.on=n.on.bind(n),n.collections.off=n.off.bind(n),n.collections.destroy=n.destroy.bind(n),n.collections.get=function(t){var e;return n.collections.every(function(r){return e=r.get(t),!e}),e}};yr.prototype.create=function(n){return this.createCollection(n)};yr.prototype.bindWindowEvents=function(){var n=this;n._windowBound||typeof window>"u"||(n._windowBound=!0,fc(window,"resize",n._onResize),fc(window,"scroll",n._onScroll))};yr.prototype.unbindWindowEvents=function(){var n=this;!n._windowBound||typeof window>"u"||(n._windowBound=!1,mc(window,"resize",n._onResize),mc(window,"scroll",n._onScroll))};yr.prototype.createCollection=function(n){var t=this,e=new iO(t,n);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};yr.prototype.bindCollection=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};yr.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};yr.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};yr.prototype.getIdentifier=function(n){var t;return n?(t=n.identifier===void 0?n.pointerId:n.identifier,t===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]};yr.prototype.removeIdentifier=function(n){var t={};for(var e in this.ids)if(this.ids[e]===n){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};yr.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};yr.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};yr.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};yr.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=$m(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[i](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),ju(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return ju(t,a),!1};yr.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.unbindWindowEvents(),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.collections=[],n.off()};yr.prototype.onDestroyed=function(n,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var nO=yr;var vc=null;function oO(){return vc||(vc=new nO),vc}var HU={create:function(n){return oO().create(n)},destroy:function(){vc&&(vc.destroy(),vc=null)},get factory(){return oO()}},aO=HU;import{Box3 as lz,Euler as wc,EventDispatcher as cz,Line3 as AO,MathUtils as Pa,Matrix4 as $n,Quaternion as Xr,Vector2 as dz,Vector3 as Fe}from"three";import{Camera as JU,OrthographicCamera as $U,PerspectiveCamera as ez,Vector3 as yn,Object3D as lO,Quaternion as tz,Matrix4 as Ds}from"three";import{Camera as XU,LineSegments as YU,BufferGeometry as QU,LineBasicMaterial as KU,Color as tS,Vector3 as ZU,Float32BufferAttribute as sO}from"three";var ny=new ZU,Zi=new XU,rS=class extends YU{constructor(e){let r=new QU,i=new KU({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new tS(15711266),c=new tS(15711266),d=new tS(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new sO(o,3)),r.setAttribute("color",new sO(a,3));super(r,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,r=this.pointMap,i=!0;Zi.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=i?.8:1e-4;mn("n1",r,e,Zi,-o,-a,s),mn("n2",r,e,Zi,o,-a,s),mn("n3",r,e,Zi,-o,a,s),mn("n4",r,e,Zi,o,a,s);let l=s;mn("f1",r,e,Zi,-o,-a,l),mn("f2",r,e,Zi,o,-a,l),mn("f3",r,e,Zi,-o,a,l),mn("f4",r,e,Zi,o,a,l);let c=l,d=.5;mn("u1",r,e,Zi,o*.7*d,a*1.1,c),mn("u2",r,e,Zi,-o*.7*d,a*1.1,c),mn("u3",r,e,Zi,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mn(n,t,e,r,i,o,a){ny.set(i,o,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],ny.x,ny.y,ny.z)}}var oy=class extends Gn(rS){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,r){Un(this.object,this.geometry,e,r,!0)}};var ay=790;function cO(n){return 1-Math.pow(1-n,3)}var bc=new yn,iS=new yn,nS=new tz,oS=new yn,qu=new yn,aS=new yn,Zn=class extends Yi(JU,oy){constructor(e="",r={...ds.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=an.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=Zn.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new Ds,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,o=this.height;this.orthoCamera=new $U(i*-.5,i*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new ez(45,i/o,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 r=Zn.projectionTransitionsEnabled;Zn.projectionTransitionsEnabled=!1;try{return e()}finally{Zn.projectionTransitionsEnabled=r}}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,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}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,r,i){typeof e=="number"&&(e=new yn(e,r,i)),super.lookAt(e),this.getWorldPosition(bc),this.targetOffset=bc.distanceTo(e)}getTarget(e=new yn){return this.getWorldDirection(iS),this.getWorldPosition(bc),iS.multiplyScalar(this.targetOffset),e.copy(bc).add(iS),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(bc),bc.distanceTo(e)}updateUp(){this.getWorldQuaternion(nS),oS.set(0,0,1).applyQuaternion(nS),qu.copy(lO.DEFAULT_UP),this.isUpVectorFlipped&&qu.negate(),qu.applyQuaternion(nS),aS.copy(lO.DEFAULT_UP).projectOnPlane(oS),this.angleOffsetFromUp=aS.angleTo(qu),this.angleOffsetFromUp*=aS.cross(qu).dot(oS)>=0?1:-1}updateTransformState(e,r){let i=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let r=e.getWorldPosition(new yn),o=e.getWorldDirection(new yn).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new yn).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new yn;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,i=!1){if(this.aspect=e/r,i){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-ay*.5*o,this.right=ay*.5*o,this.top=ay*.5*(1/a),this.bottom=-ay*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;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 r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:cO(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Zn.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Zn.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new Ds,blend:new Ds,blendInverse:new Ds,start:0,duration:Zn.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=Zn.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let i=cO(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=i*c/(i*c+(1-i)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;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 r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let i=this._projectionTransition;i===void 0?(i={from:new Ds,blend:new Ds,blendInverse:new Ds,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(r.from),i.start=r.start,i.duration=r.duration,i.referenceDepth=r.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,r,i,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,a,s):this.orthoCamera.setViewOffset(e,r,i,o,a,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,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),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=an.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={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};return $d(r,e)}updateCameraSubtype(e,r){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(i,r.zoom),r.near!==void 0&&this.setNear(i,r.near),r.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),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(r?.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=an.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,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}}},St=Zn;St.projectionTransitionsEnabled=!1,St.projectionTransitionDuration=350,St.projectionTransitionMinAgeMs=1e3;var rz=null;function dO(n){rz=n}var iz,uO=new Promise(n=>{iz=n});import{Box3 as Fhe,Euler as pO,Matrix4 as hO,Quaternion as lS,Sphere as az,Vector3 as Xu}from"three";import{BufferGeometry as nz,Float32BufferAttribute as sS}from"three";function oz(n){let t=n.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,i=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||i<l||o<l||a<l||s<l}function sy(n,t){let e=new nz;if(t&&oz(t))return e.setAttribute("position",new sS([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new sS([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Tu(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new sS(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}import{mergeGeometries as Uhe}from"three/examples/jsm/utils/BufferGeometryUtils.js";var sz;uO.then(n=>sz=n);var jhe=new Xu,Hhe=new lS,Whe=new Xu,qhe=new pO(0,0,0,"YXZ"),Xhe=new pO(0,0,0,"XYZ"),Yhe=new Xu,Qhe=new Xu,Khe=new Xu(1,1,1),Zhe=new lS,Jhe=new hO,$he=new hO;var efe=new lS,tfe=new az;var cS={type:"beginEvent",eventName:"Collision"};var dS=n=>n.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);import{Mesh as uz}from"three";ut();var fO=4,uS=8;var pS=.02,hS=.3,pz=65,mO=new Fe,yO=new Fe,hz=new Fe,qr=new Fe,Vo=new Fe,xc=new Fe,fS=new $n,gO=new $n,fz=new $n,Ti=new Xr,Rs=new Xr,Sc=new wc(0,0,0,"YXZ"),mz=new Fe(1,0,0),Jn=new Fe(0,1,0),yz=new Fe(0,0,1),vO=new Fe(1,1,1),mS=[],bO=n=>mS[n]??(mS[n]=new Fe),yS=new Fe,gz=new Fe,vz=new Fe,bz=new Fe,xO=new Xr,xz=new Fe,SO=new Xr,Sz=1,wz=.025,Az=16e-6,wO=12,Ez=20,Mr=new AO,Ji=new lz,Cz={type:"requestRender"},Tz={type:"updateMatrix"},ly=class extends cz{constructor(e,r,i,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new $n;this.target0=new Fe;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=j2;this.euler0=new wc(0,0,0,"YXZ");this.position0Cam=new Fe;this.quat0Cam=new Xr;this.scale0Cam=new Fe;this.hiddenMatrix0Cam=new $n;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new AO(new Fe(0,-40,0),new Fe(0,40,0)),matrix:new $n,position:new Fe,rotation:new Xr};this.euler=new wc(0,0,0,"YXZ");this.eulerDelta=new Fe;this.lastPosition=new Fe;this.lastCameraQuaternion=new Xr;this.lastCameraPosition=new Fe;this.PI_2=Math.PI/2;this.prevMouse=new dz;this.velocityTarget=new Fe;this.velocity=new Fe;this.directionXZ=new Fe;this.rotVelocityStick=new Fe;this.rotVelocityTarget=new Fe;this.rotVelocity=new Fe;this.rotDirection=new Fe;this.nonColliderRotOffset=new $n;this.nonColliderPosOffset=new $n;this.firstPointerId=-1;this.rot=new Fe;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 $n;this.objectToTarget=new Fe;this.objectToTarget0=new Fe;this.objectToCamXZ=new Fe;this.objectToCamXZ0=new Fe;this.targetToCamera=new Fe;this.targetToCamera0=new Fe;this.cameraPolarAxis0=new Fe;this.targetPos=new Fe;this.targetQuat=new Xr;this.lerpFactorPos=new Fe().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Xr;this.objXZQuatInv=new Xr;this.objXZRotMat=new $n;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new Fe;this.pushedVelocity=new Fe;this.groundYRotation=0;this.objectRealQuat=new Xr;this.colliderWorldQuat=new Xr;this.groundNormal=new Fe;this.groundTilt=new Xr;this.groundTiltInv=new Xr;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new Fe;this.quaternion=new Xr;this.scale=new Fe;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!hi&&!_b&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(_b&&tC<15.5&&!hi?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?ly.isLocked=!0:ly.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let i=2;i<4;i++){let o=e.axes[i];r===0?i===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let y=new Fe(0,0,-1).applyQuaternion(this.camera.quaternion),g=new Fe().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let b;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,b=g.projectOnVector(y)):g.y/y.y>0?b=y.multiplyScalar(g.y/y.y):b=y.multiplyScalar(g.length()),this.targetToCamera0.copy(b).negate();let x=this.camera.position.clone().add(b);this.objectToTarget0.subVectors(x,this.position);let S=new wc().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof St&&(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=(i.speedTranslate??250)*Sz,this.speedOrbit=(i.speedRotate??100)*wz,this.mouseOrbitSensitivity=(i.speedRotate??100)*Az,this.keyAssignments=i.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??ha.defaultData.gravity)*wO,this.usePhysics=this.gloabalPhysics.usePhysics??ha.defaultData.usePhysics,this.jumpPower=i.jumpPower*Ez,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??wl.defaultDataThirdPerson.orientWith,this.slopeThresh=pz*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*pS/this.pixelsPerMeter,this.stepThresh=i.collider.height*hS/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*pS/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*hS/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*pS/this.pixelsPerMeter,this.stepThresh=i.collider.height*hS/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let h=new Fe().fromArray(i.collider.position.map(y=>typeof y=="number"?y:0)),f=new Xr().setFromEuler(new wc().fromArray([...i.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,vO),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 m=i.navmesh.destinationHelperRadius*2;if(m>0){let y=new fe;y.push({fi:0,data:{...Ft.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Ft.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=fm({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new uz(zf.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new wc().setFromQuaternion(this.quaternion,"YXZ"),i=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,i,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof St?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.hiddenMatrix.copy(this.hiddenMatrix0Cam),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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Sl.list.forEach(i=>{this.actions[i]=Tt({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,r,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"),er(this.actions.idle),er(this.actions.move),er(this.actions.run),er(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return qr.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 r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Vo.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*wO),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,uS,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(qr).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}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 l=qr.subVectors(this.path[1],this.position),c=Vo.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.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 a=hz.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Vo.copy(a);s.y=0,a.set(0,a.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=qr;this.camera.getWorldDirection(s);let l=xc.copy(Jn).multiplyScalar(s.dot(Jn));s.sub(l);let c=Vo.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).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(Sc.setFromVector3(this.rot),this.moveMode==="walk"&&(Sc.x=0),a.applyEuler(Sc),o&&(Rs.setFromUnitVectors(Jn,this.groundNormal),a.applyQuaternion(Rs)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(yS,xO,gz);let c=this.object.getWorldPosition(vz).add(this.collider.position).sub(yS);SO.copy(l.prevQ).invert().premultiply(xO);let d=xc.subVectors(yS,l.prevT).add(bz.copy(c).applyQuaternion(SO).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),qr.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=ke.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof cr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(cS));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),bO(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=bO(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.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(r),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*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Jn,this.euler.y-this.euler0.y);let s=Vo.copy(this.objectToCamXZ).normalize(),l=xc.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(qr.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+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=Pa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Pa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Pa.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Sc.copy(this.euler),Sc.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Sc)),Ti.setFromAxisAngle(mz,this.rot.x),Rs.setFromAxisAngle(Jn,this.rot.y),Rs.multiply(Ti),Ti.setFromAxisAngle(yz,this.rot.z),Rs.multiply(Ti),this.quaternion.copy(Rs),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=Vo.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new Fe;for(let p=0;p<5;p++){let h=s.length(),f=xc.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,uS|fO,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let S of x)if(S.data.target==="character"){let v=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,w;if(m.cloner){for(let A of m.cloner.children)if(A.rigidBody===v){w=A;break}}S.dispatch(w),m.dispatchEvent(cS)}}}let y=mO.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=yO.copy(f).multiplyScalar(l.time_of_impact).dot(y),b=l.time_of_impact;if(b===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(b=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,b)),s.copy(f).multiplyScalar(h-b),Math.acos(-y.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=xc.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let v=x.add(S);v.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(v,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,uS|fO,void 0,void 0,this.object.rigidBody);w!==null&&w.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),qr.copy(this.position).divideScalar(this.pixelsPerMeter),Ti.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&xz.copy(qr).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(qr,!0),d.setRotation(Ti,!0)):(d.setNextKinematicTranslation(qr),d.setNextKinematicRotation(Ti)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);fS.lookAt(l,s,Jn).setPosition(l),fS.decompose(this.targetPos,this.targetQuat,qr),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.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Pa.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Pa.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(Tz),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)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Cz),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ti.setFromAxisAngle(Jn,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Pa.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let r;this.cameraXAxis==="Limit"?r=Pa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Pa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let o=Rs.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){Jn.angleTo(e)*180/Math.PI<15||Jn.angleTo(e)*180/Math.PI>85?Ti.identity():Ti.setFromUnitVectors(Jn,e),this.groundTilt.slerp(Ti,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=yO.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=fS.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qr,Ti,Vo).compose(qr,Ti,vO);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Ji.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=gO.copy(s).invert(),c=fz.copy(gO).multiply(i);Mr.copy(this.collider.segment),Mr.start.applyMatrix4(c),Mr.end.applyMatrix4(c);let d=mO.copy(this.position).applyMatrix4(l);Ji.expandByPoint(Mr.start),Ji.expandByPoint(Mr.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(Mr.end)},intersectsBounds:u=>u.intersectsBox(Ji),intersectsTriangle:u=>{let p=qr,h=Vo,f=u.closestPointToSegment(Mr,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=xc.copy(d);g.addScaledVector(y,m);let b=g.applyMatrix4(s).sub(this.position);r.add(b),Mr.start.addScaledVector(y,m),Mr.end.addScaledVector(y,m)}}})}),Ji.makeEmpty(),Mr.copy(this.collider.segment),Mr.start.applyMatrix4(i),Mr.end.applyMatrix4(i),Ji.expandByPoint(Mr.start),Ji.expandByPoint(Mr.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(Mr.end)},intersectsBounds:a=>a.intersectsBox(Ji),intersectsTriangle:a=>{let s=qr,l=Vo,c=a.closestPointToSegment(Mr,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),Mr.start.addScaledVector(u,d),Mr.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}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()}},Yu=ly;Yu.isLocked=!1;import{BufferAttribute as TO,BufferGeometry as Mz,Vector3 as Qu}from"three";import{mergeGeometries as Oz}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Pz,EO=new Promise(n=>{Pz=n});var CO;var Iz=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.40/build/",Dz=n=>`
1329
1329
  (async function() {
1330
1330
  const [wasmImport, wasmBinary] = await Promise.all([
1331
1331
  import('${n}' + 'navmesh.js'),
@@ -5236,4 +5236,4 @@ vec3 lab2rgb (in vec3 lab) {
5236
5236
 
5237
5237
  `;var vv=class extends rq{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],dt.startContext(dt.globalContext),this.lightLayer=new ui(0,"",{...Ft.defaultData("light","phong"),visible:!1},new ja,{},r.shared),dt.endContext(dt.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new sd;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(hB),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(fB),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(AN),e.addFragmentParsCode(CN),e.addVertexFinalCode(EN({easeSize:this.easeSize})),e.addFragmentFinalCode(TN({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.nodeExtensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{GPUComputationRenderer as iq}from"three/examples/jsm/misc/GPUComputationRenderer.js";QC({createMaterial:(n,t)=>new vv(n,t),createComputation:(n,t,e)=>new iq(n,t,e)});import{Vector2 as PN}from"three";function MN(n,t,e,r){let i=e,o=i.type==="texture"?i.texture.image!=null?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):r.video(i.texture.video),a=new Jo(o,i.texture.wrapping??(i.type==="texture"?1e3:1001),i.texture.minFilter??1008,i.texture.magFilter??1006),s=new Kg(o),l=new Zg(Zs(i.texture.repeat??[1,1],r),Zs(i.texture.offset??[0,0],r),ye(i.texture.rotation??0,r)),c=new le(i.crop?1:0),d=new Ge(i.projection??0),u=new Ge(["x","y","z"].indexOf(i.axis)??0),p=i.projectionAxis?["x","y","z"].indexOf(i.projectionAxis):-1,h=new Ge(i.side??0),f=new _t(i.size?new PN(...Zs(i.size,r)):new PN(100,100)),m=new le(i.blending??0),y=new le(qi(i.alpha,r)),g=new Ge(i.mode??0),b=new Et(i.isMask??!1),x=new ea(a,s,c,d,u,h,f,m,l,y,g,b,p),S=new Le(x.calpha,"f");return new We(n,t,i,{texture:a,textureSize:s,crop:c,projection:d,axis:u,side:h,size:f,blending:m,mat:l,alpha:y,mode:g,isMask:b},x,g,S,b,r)}ot("texture",MN);ot("video",MN);import{MathUtils as nq}from"three";ot("matcap",(n,t,e,r)=>{let i=e,o=i.texture.image!=null?r.image(i.texture.image):r.getImage(""),a=new Jo(o,i.texture.wrapping??1001,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new le(qi(i.alpha,r)),l=new Ge(i.mode??0),c=new Et(i.isMask??!1),d=new le((ye(i.texture.rotation??0,r)??0)*nq.DEG2RAD),u=new yd(a,s,l,c,d),p=new Le(u.calpha,"f");return new We(n,t,i,{texture:a,alpha:s,mode:l,isMask:c,rotation:d},u,l,p,c,r)});import{Vector3 as oq}from"three";ot("displace",(n,t,e,r)=>{let i=e;if(i.displacementType==="noise"){let o=new Qt(new oq(...i.offset.map(g=>ye(g,r)??0))),a=new le(ye(i.scale,r)??10),s=new le(ye(i.intensity,r)??8),l=new le(ye(i.movement,r)??1),c=new Ge(i.noiseType??0),d=new Ge(i.voronoiStyle??0),u=new le(ye(i.smoothness,r)??.5),p=new le(ye(i.seed,r)??0),h=new le(ye(i.highCut,r)??1),f=new le(ye(i.lowCut,r)??0),m=new Ge(ye(i.quality,r)??1),y=new Ed(s,l,o,d,u,p,h,f,m,a,c);return new Cd(n,t,i,{offset:o,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:d,smoothness:u,seed:p,highCut:h,lowCut:f,quality:m},y,r)}else throw new Error});ot("cavity",(n,t,e,r)=>{let i=gt(e,r),o=new le(ye(i.ridge,r)??1),a=new le(ye(i.valley,r)??1),s=vt(i),l=new hd(o,a,He.normalViewRenderTarget,He.resolution,s.alpha,s.mode,s.isMask),c=new Le(l.calpha,"f");return new We(n,t,e,{ridge:o,valley:a,...s},l,s.mode,c,s.isMask,r)});ot("dust",(n,t,e,r)=>{let i=gt(e,r),o=new $e(i.color??10323813),a=new le(i.coverage??.2),s=new le(i.softness??.2),l=new le(i.noiseStrength??.2),c=new le(i.noiseScale??1),d=vt(i),u=new fd(o,a,s,l,c,d.alpha,d.isMask),p=new Le(u.calpha,"f");return new We(n,t,e,{color:o,coverage:a,softness:s,noiseStrength:l,noiseScale:c,...d},u,d.mode,p,d.isMask,r)});ot("fresnel",(n,t,e,r)=>{let i=gt(e,r),o=new $e(i.color??16777215),a=new le(ye(i.bias,r)??.1),s=new le(ye(i.scale,r)??1),l=new le(ye(i.intensity,r)??2),c=new le(ye(i.factor,r)??1),d=vt(i),u=new Xp(o,a,s,l,c,d.alpha,d.mode,d.isMask),p=new Le(u.calpha,"f");return new We(n,t,e,{color:o,bias:a,scale:s,intensity:l,factor:c,...d},u,d.mode,p,d.isMask,r)});import{Vector2 as ON,Vector4 as IN}from"three";ot("gradient",(n,t,e,r)=>{let i=gt(e,r),o=new Ge(i.gradientType??0),a=new Et(i.smooth??!1),s;i.colors?s=new Di(i.colors.length,i.colors):(s=new Di(10,new IN(0,0,0,1)),s.value[1]=new IN(1,1,1,1));let l;i.steps?l=new Ii(i.steps.length,i.steps):(l=new Ii(10,1),l.value[0]=0);let c=new _t(rn(i.offset??new ON(0,0),r)),d=new _t(rn(i.morph??new ON(0,0),r)),u=new le(ye(i.angle??0,r)),p=vt(i),h=new md(o,a,s,l,c,d,u,p.alpha,p.isMask),f=new Le(h.calpha,"f");return new We(n,t,e,{gradientType:o,smooth:a,colors:s,steps:l,offset:c,morph:d,angle:u,...p},h,p.mode,f,p.isMask,r)});import{Vector4 as DN}from"three";ot("depth",(n,t,e,r)=>{let i=gt(e,r),o=new Ge(i.gradientType??0),a=new Et(i.smooth??!1),s=new le(ye(i.near,r)??50),l=new le(ye(i.far,r)??200),c=new le(i.isVector??1),d=new le(i.isWorldSpace??0),u=new Qt(Ri(i.origin,r)),p=new Qt(Ri(i.direction,r)),h;i.colors?h=new Di(i.colors.length,i.colors):(h=new Di(2,new DN(0,0,0,1)),h.value[1]=new DN(1,1,1,1));let f;i.steps?f=new Ii(i.steps.length,i.steps):(f=new Ii(2,1),f.value[0]=0);let m=vt(i),y=new pd(o,a,s,l,c,d,u,p,h,f,m.alpha,m.isMask),g=new Le(y.calpha,"f");return new We(n,t,e,{gradientType:o,smooth:a,near:s,far:l,isVector:c,isWorldSpace:d,origin:u,direction:p,colors:h,steps:f,...m},y,m.mode,g,m.isMask,r)});import{Vector3 as aq}from"three";ot("normal",(n,t,e,r)=>{let i=gt(e,r),o=new Qt(i.cnormal??new aq(1,1,1)),a=vt(i),s=new dd(o,a.alpha),l=new Le(s.calpha,"f");return new We(n,t,e,{cnormal:o,...a},s,a.mode,l,a.isMask,r)});import{Vector2 as Ow,Vector3 as sq}from"three";ot("noise",(n,t,e,r)=>{let i=gt(e,r),o=new le(ye(i.scale,r)??1),a=new Qt(Ri(i.size??new sq(100,100,100),r)),s=new le(ye(i.move,r)??1),l=new _t(rn(i.fA??new Ow(1.7,9.2),r)),c=new _t(rn(i.fB??new Ow(8.3,2.8),r)),d=new _t(rn(i.distortion??new Ow(1,1),r)),u=new Kr(i.colorA),p=new Kr(i.colorB),h=new Kr(i.colorC),f=new Kr(i.colorD),m=new Ge(i.noiseType??0),y=new Ge(i.voronoiStyle??0),g=new le(ye(i.highCut,r)??1),b=new le(ye(i.lowCut,r)??0),x=new le(ye(i.smoothness,r)??.5),S=new le(ye(i.seed,r)??.5),v=new Ge(i.quality??1),w=vt(i),A=new gd(o,a,s,l,c,d,u,p,h,f,w.alpha,m,w.isMask,y,g,b,x,S,v),E=new Le(A.calpha,"f");return new We(n,t,e,{scale:o,size:a,move:s,fA:l,fB:c,distortion:d,colorA:u,colorB:p,colorC:h,colorD:f,noiseType:m,...w,voronoiStyle:y,highCut:g,lowCut:b,smoothness:x,seed:S,quality:v},A,w.mode,E,w.isMask,r)});ot("rainbow",(n,t,e,r,i)=>{let o=gt(e,r),a=new le(ye(o.filmThickness,r)??30),s=new le(ye(o.movement,r)??0),l=new Qt(Ri(o.wavelengths,r)),c=new le(ye(o.noiseStrength,r)??0),d=new le(ye(o.noiseScale,r)??1),u=new Qt(Ri(o.offset,r)),p=vt(o),h=i?.forceRainbowNoise===!0,f=h||un(o.noiseStrength),m=new xd(a,s,l,c,d,u,p.alpha,p.isMask,f),y=new Le(m.calpha,"f"),g=new We(n,t,e,{filmThickness:a,movement:s,wavelengths:l,noiseStrength:c,noiseScale:d,offset:u,...p},m,p.mode,y,p.isMask,r);return g.noiseCompiledIn=f,g.noiseForced=h,g});import{Vector3 as RN,Vector4 as BN}from"three";ot("toon",(n,t,e,r)=>{let i=gt(e,r),o=new Ge(i.positioning??0),a;i.colors?a=new Di(i.colors.length,i.colors):(a=new Di(10,new BN(0,0,0,1)),a.value[1]=new BN(1,1,1,1));let s;i.steps?s=new Ii(i.steps.length,i.steps):(s=new Ii(10,1),s.value[0]=0);let l=new Qt(Ri(i.source??new RN(0,0,0),r)),c=new Et(i.isWorldSpace??!0),d=new le(ye(i.noiseStrength??0,r)),u=new le(ye(i.noiseScale??1,r)),p=new Kr(i.shadowColor),h=new Qt(Ri(i.offset??new RN(0,0,0),r)),f=vt(i),m=new Sd(o,a,s,l,c,d,u,p,h,f.alpha),y=new Le(m.calpha,"f");return new We(n,t,e,{positioning:o,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:d,noiseScale:u,shadowColor:p,offset:h,...f},m,f.mode,y,f.isMask,r)});import{Vector3 as lq}from"three";ot("outline",(n,t,e,r)=>{let i=gt(e,r),o=new $e(i.outlineColor??16777215),a=new $e(i.contourColor??16777215),s=new le(ye(i.outlineWidth??.1,r)),l=new le(ye(i.contourWidth??.1,r)),c=new le(ye(i.outlineThreshold??.1,r)),d=new le(ye(i.contourThreshold??.1,r)),u=new le(ye(i.outlineSmoothing??.1,r)),p=new le(ye(i.contourFrequency??.1,r)),h=new Qt(Ri(i.contourDirection??new lq(0,1,0),r)),f=new Et(i.positionalLines??!1),m=new Et(i.compensation??!0),y=He.normalRenderTarget,g=He.normalRenderTargetDepth,b=He.pixelRatioNode,x=He.resolution,S=vt(i),v=new vd(o,a,s,l,c,d,u,p,h,f,m,x,y,g,b,S.alpha),w=new Le(v.calpha,"f");return new We(n,t,e,{outlineColor:o,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:d,outlineSmoothing:u,contourFrequency:p,contourDirection:h,positionalLines:f,compensation:m,...S},v,S.mode,w,S.isMask,r)});ot("transmission",(n,t,e,r)=>{let i=gt(e,r),o=new le(ye(i.thickness??10,r)),a=new le(ye(i.ior??1.5,r)),s=new le(ye(i.roughness??.5,r)),l=He.transmissionSize,c=He.transmissionRenderTarget,d=He.transmissionRenderTargetDepth,u=window.innerWidth,p=window.innerHeight,h=u>=p?new _t(p/u,1):new _t(1,u/p),f=vt(i),m=new wd(o,a,s,l,c,d,h,f.alpha),y=new Le(m.calpha,"f");return new We(n,t,e,{thickness:o,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,r)});var NN=!1;function cq(){NN||(NN=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer \u2014 it renders as invisible on the classic WebGL pipeline."))}ot("reflection",(n,t,e,r)=>{cq();let i=gt(e,r),o=new le(i.blur??0),a=new le(i.thickness??10/1e4),s=new Ge(i.steps??60),l=new le(i.stepSize??5/1e3),c=new Ge(i.tracingMode??1),d=vt(i),u=new $e(0,0,0,1),p=new le(0),h=new $o(u,p),f=new Le(h.calpha,"f");return new We(n,t,e,{blur:o,thickness:a,steps:s,stepSize:l,tracingMode:c,...d},h,d.mode,f,d.isMask,r)});import{Vector2 as Iw}from"three";ot("pattern",(n,t,e,r)=>{let i=gt(e,r),o=new Ge(i.style??0),a=new Ge(i.projection??0),s=new Ge(["x","y","z"].indexOf(i.axis)??0),l=new le(ye(i.blending??0,r)),c=new _t(rn(i.offset,r)),d=new Kr(i.colorA),u=new Kr(i.colorB),p=new _t(rn(i.frequency??new Iw(10,10),r)),h=new le(ye(i.size??.5,r)),f=new le(ye(i.variation??0,r)),m=new le(ye(i.smoothness??.5,r)),y=new le(ye(i.zigzag??0,r)),g=new le(ye(i.rotation??0,r)),b=new _t(rn(i.vertical??new Iw(0,1),r)),x=new _t(rn(i.horizontal??new Iw(0,1),r)),S=new Ge(i.sides??6),v=vt(i),w=new bd(o,a,s,l,c,d,u,p,h,f,m,y,g,b,x,S,v.alpha,v.isMask),A=new Le(w.calpha,"f");return new We(n,t,e,{style:o,projection:a,axis:s,blending:l,offset:c,colorA:d,colorB:u,frequency:p,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:x,sides:S,...v},w,v.mode,A,v.isMask,r)});ot("vertexColor",(n,t,e,r)=>{let i=gt(e,r),o=vt(i),a=new Ad(o.alpha),s=new Le(a.calpha,"f");return new We(n,t,e,{...o},a,o.mode,s,o.isMask,r)});RP({createRootMaterial:(n,t)=>new Td(n,t),createSharedMaterial:(n,t,e)=>new gv(n,t,e)});FP((n,t)=>n?FB(t):kB());LP(()=>{let n=new dq;return n.depthWrite=!1,n.opacity=.5,n.onBeforeCompile=t=>{t.fragmentShader=`layout(location = 1) out vec4 gVelocity;
5238
5238
  `+t.fragmentShader.replace("void main() {",`void main() {
5239
- gVelocity = vec4(0.0);`)},n});var LN="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Dw=class extends pq{load(t,e,r,i=console.error){let o=new uq(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(LN+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(LN),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){i(s)}},r,a=>i(a))}async parse(t){let e=await rB(t,vN),r=iB(e);e.version&&"2.0.38"&&(0,_N.default)(e.version,"2.0.38")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&tB(),vM(e)&&EP(),vx(e)&&G2(),C2(e)&&Lm(),hv(e)&&Tw()].filter(Boolean)),r.length&&await nB(r);let i=!1,o=new Sa(e.shared,{},i);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new yv(e.scene,o);hv(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=yN(a),a=hN(a),a=fN(a),a=mN(a),a=gN(a),a}};export{Dw as default};
5239
+ gVelocity = vec4(0.0);`)},n});var LN="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Dw=class extends pq{load(t,e,r,i=console.error){let o=new uq(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(LN+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(LN),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){i(s)}},r,a=>i(a))}async parse(t){let e=await rB(t,vN),r=iB(e);e.version&&"2.0.40"&&(0,_N.default)(e.version,"2.0.40")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&tB(),vM(e)&&EP(),vx(e)&&G2(),C2(e)&&Lm(),hv(e)&&Tw()].filter(Boolean)),r.length&&await nB(r);let i=!1,o=new Sa(e.shared,{},i);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new yv(e.scene,o);hv(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=yN(a),a=hN(a),a=fN(a),a=mN(a),a=gN(a),a}};export{Dw as default};