@splinetool/loader 2.0.29 → 2.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.cjs +5 -5
- package/build/SplineLoader.js +6 -6
- package/package.json +1 -1
package/build/SplineLoader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var WN=Object.create;var th=Object.defineProperty;var qN=Object.getOwnPropertyDescriptor;var XN=Object.getOwnPropertyNames;var YN=Object.getPrototypeOf,QN=Object.prototype.hasOwnProperty;var KN=(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),ZN=(n,t)=>{for(var e in t)th(n,e,{get:t[e],enumerable:!0})},JN=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of XN(t))!QN.call(n,i)&&i!==e&&th(n,i,{get:()=>t[i],enumerable:!(r=qN(t,i))||r.enumerable});return n};var Bd=(n,t,e)=>(e=n!=null?WN(YN(n)):{},JN(t||!n||!n.__esModule?th(e,"default",{value:n,enumerable:!0}):e,n));var Gr=(n,t,e)=>(KN(n,typeof t!="symbol"?t+"":t,e),e);var Lw=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 _w=Me(()=>{"use strict"});function ir(n,t){return Object.setPrototypeOf(n,t),n}function nh(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Sn(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 na(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 Fw(){return typeof process<"u"}var kw=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 Vw=Me(()=>{"use strict"});var fr=Me(()=>{Lw();_w();kw();Vw()});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 Gw=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 Uw(n,t){for(let e of n)t(e.id,e.data)!==!0&&Uw(e.children,t)}function zw(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)zw(e,t)}var bt,oa=Me(()=>{"use strict";fr();lh();fr();bt=class extends Array{constructor(...e){super(...e);Gr(this,"partialObjectCaches");Gr(this,"objCaches");Gr(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&&zw(i,r)}}traverse(e){Uw(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 Sn(0,i,i);{let a=o[0].fi;return Sn(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 Sn(l,l+i,i)}else return Sn(a.fi,s.fi,i)}}}});var Tv,aa,ch=Me(()=>{"use strict";Tv=null;(r=>{function n(i){Tv=i}r.setPreservePrototype=n;function t(i,o){return Object.getPrototypeOf(i)===Tv&&Object.setPrototypeOf(o,Tv),o}r.tryPreservePrototype=t;function e(i,o){if(o.type!==0)return null;if(Array.isArray(i)){let a=o.props,s={},l=[...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";fr();fr();fe=class extends Array{constructor(...e){super(...e);Gr(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 Fw()||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 Sn(0,r,r);{let o=i[0].fi;return Sn(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 Sn(s,s+r,r)}else return Sn(o.fi,a.fi,r)}}}});function jw(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 $N(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Hw(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=Hw(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 eL(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=Hw(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof fe)return eL(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"&&!na(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&&$N(e),r}else return}}var Pv=Me(()=>{"use strict";oa();sa();fr()});function ol(n){return n&&typeof n=="object"&&n instanceof Ct}function Mv(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=Mv(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 tL(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=Mv(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof fe)return tL(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 Ov(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 Ov(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ol(t))return t;if(!ol(n))return wn.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=Ov(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=o}return r}var Ct,wn,ph=Me(()=>{"use strict";oa();sa();Vd();fr();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 Ov(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=Mv([o],l);return c?c[0]:o}else return o}r.filterOp=e})(wn||(wn={}))});var al,zt,Iv,Ww=Me(()=>{"use strict";Vd();_d();oa();lh();ch();sa();Pv();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)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let x=m;m=[...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]=jw(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})(Iv||(Iv={}))});function Dv(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 Bv(n,t,e),nL):e!==null&&typeof e=="object"?na(e)?e:new Proxy(new Rv(n,t,e),iL):e}function Nv(n){let t=new hh(n);return[mh(t,"",n),t]}function cl(n,t){let[e,r]=Nv(n);return t(e),r.result()}function Ht(n){return n instanceof sl||n instanceof ll?n._current:n!==null&&typeof n=="object"?n[qw]:n}var qw,rL,fh,ts,Rv,Bv,Xw,iL,nL,sl,ll,hh,Lv=Me(()=>{"use strict";_d();oa();ch();sa();fr();Vd();qw=Symbol(),rL=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]}}}},Rv=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)}},Bv=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))}},Xw={get(n,t){if(t===fh)return()=>{n._parent=null};if(t===qw)return n._current;if(t===rL)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]}}},iL={...Xw,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}},nL={...Xw,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){Dv(this.ts,e,t),Dv(this.actual,r,t),Dv(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();Lv();sa();oa();fr();(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(p,[...u,h])});else if(Array.isArray(d))for(let p=0;p<d.length;p++)c(d[p],[...u,p]);else{if(na(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 Yw=Me(()=>{"use strict"});function Qw(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 Kw=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&&$w?(t=$w(ge,U,Ri,It),ge=null,!(n&&n.lazy)&&t&&(t=t.toJSON()),U=Ri):t=nr(),Tr&&(U=Tr.postBundlePosition,Tr=null),ca&&(nt.restoreStructures=null),U==Ri)nt&&nt.restoreStructures&&rA(),nt=null,ge=null,ho&&(ho=null);else{if(U>Ri)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&&rA(),gh(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||U>Ri)&&(t.incomplete=!0),t}}function rA(){for(let n in nt.restoreStructures)nt[n]=nt.restoreStructures[n];nt.restoreStructures=null}function nr(){let n=ge[U++];if(n<160)if(n<128){if(n<64)return n;{let t=nt[n&63]||It.getStructures&&uA()[n&63];return t?(t.read||(t.read=zv(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=hA();r==="__proto__"&&(r="__proto_"),t[r]=nr()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(nr(),nr());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=nr();return It.freezeData?Object.freeze(t):t}else if(n<192){let t=n-160;if(An>=U)return la.slice(U-Di,(U+=t)-Di);if(An==0&&Ri<140){let e=t<16?jv(t):pA(t);if(e!=null)return e}return Gv(t)}else{let t;switch(n){case 192:return null;case 193:return Tr?(t=nr(),t>0?Tr[1].slice(Tr.position1,Tr.position1+=t):Tr[0].slice(Tr.position0,Tr.position0-=t)):Uv;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 _v(t);case 197:return t=tt.getUint16(U),U+=2,_v(t);case 198:return t=tt.getUint32(U),U+=4,_v(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 lA(ge[U++]&63);{let e=Ur[t];if(e)return e.read?(U++,e.read(nr())):e.noBuffer?(U++,e()):e(ge.subarray(U,++U));throw new Error("Unknown extension "+t)}case 213:return t=ge[U],t==114?(U++,lA(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++],An>=U?la.slice(U-Di,(U+=t)-Di):aL(t);case 218:return t=tt.getUint16(U),U+=2,An>=U?la.slice(U-Di,(U+=t)-Di):sL(t);case 219:return t=tt.getUint32(U),U+=4,An>=U?la.slice(U-Di,(U+=t)-Di):lL(t);case 220:return t=tt.getUint16(U),U+=2,nA(t);case 221:return t=tt.getUint32(U),U+=4,nA(t);case 222:return t=tt.getUint16(U),U+=2,oA(t);case 223:return t=tt.getUint32(U),U+=4,oA(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 zv(n,t){function e(){if(e.count++>Jw){let i;try{i=n.read=new Function("r","return function(){return "+(It.freezeData?"Object.freeze":"")+"({"+n.map(o=>o==="__proto__"?"__proto_:r()":oL.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"})}")(nr)}catch{return Jw=1/0,e()}return n.read0=i,n.highByte===0&&(n.read=iA(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]=nr()}return It.freezeData?Object.freeze(r):r}return e.count=0,n.read0=e,n.highByte===0?iA(t,e):e}function uA(){let n=mA(()=>(ge=null,It.getStructures()));return nt=It._mergeStructures(n,nt)}function Ud(n){let t;if(n<16&&(t=jv(n)))return t;if(n>64&&Fv)return Fv.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+=Cr.apply(String,r),r.length=0)}return r.length>0&&(t+=Cr.apply(String,r)),t}function nA(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=nr();return It.freezeData?Object.freeze(t):t}function oA(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++){let r=hA();r==="__proto__"&&(r="__proto_"),t[r]=nr()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(nr(),nr());return t}}function pA(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 Cr.apply(String,e)}function jv(n){if(n<4)if(n<2){if(n===0)return"";{let t=ge[U++];if((t&128)>1){U-=1;return}return Cr(t)}}else{let t=ge[U++],e=ge[U++];if((t&128)>0||(e&128)>0){U-=2;return}if(n<3)return Cr(t,e);let r=ge[U++];if((r&128)>0){U-=3;return}return Cr(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 Cr(t,e,r,i);{let o=ge[U++];if((o&128)>0){U-=5;return}return Cr(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 Cr(t,e,r,i,o,a);let s=ge[U++];if((s&128)>0){U-=7;return}return Cr(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 Cr(t,e,r,i,o,a,s,l);{let c=ge[U++];if((c&128)>0){U-=9;return}return Cr(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 Cr(t,e,r,i,o,a,s,l,c,d);let u=ge[U++];if((u&128)>0){U-=11;return}return Cr(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 Cr(t,e,r,i,o,a,s,l,c,d,u,p);{let h=ge[U++];if((h&128)>0){U-=13;return}return Cr(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 Cr(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 Cr(t,e,r,i,o,a,s,l,c,d,u,p,h,f,m)}}}}}function aA(){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 _v(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(Ur[t]){let e;return Ur[t](ge.subarray(U,e=U+=n),r=>{U=r;try{return nr()}finally{U=e}})}else throw new Error("Unknown extension type "+t)}function hA(){let n=ge[U++];if(n>=160&&n<192){if(n=n-160,An>=U)return la.slice(U-Di,(U+=n)-Di);if(!(An==0&&Ri<180))return Gv(n)}else return U--,fA(nr());let t=(n<<5^(n>1?tt.getUint16(U):n>0?ge[U]:0))&4095,e=sA[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=[],sA[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?jv(n):pA(n);return s!=null?e.string=s:e.string=Gv(n)}function fA(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 mA(n){tA&&tA();let t=Ri,e=U,r=Vv,i=Di,o=An,a=la,s=kv,l=ho,c=Tr,d=new Uint8Array(ge.slice(0,Ri)),u=nt,p=nt.slice(0,nt.length),h=It,f=ca,m=n();return Ri=t,U=e,Vv=r,Di=i,An=o,la=a,kv=s,ho=l,Tr=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,ho=null,nt=null}function vh(n){n.unpack?Ur[n.type]=n.unpack:Ur[n.type]=n}var Fv,ge,Ri,U,dA,kv,Vv,It,nt,la,Di,An,Tr,ho,Ur,tt,Zw,Gd,Uv,ca,Jw,$w,eA,tA,Bi,oL,iA,Gv,aL,sL,lL,Cr,sA,lA,cA,Hv,cL,dL,bh,xh,uL,pL,hL,Sh,fL,f9,is=Me(()=>{try{Fv=new TextDecoder}catch{}U=0,dA=[],kv=dA,Vv=0,It={},Di=0,An=0,Ur=[],Zw={useRecords:!1,mapsAsObjects:!0},Gd=class{},Uv=new Gd;Uv.name="MessagePack 0xC1";ca=!1,Jw=2,Bi=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 mA(()=>(gh(),this?this.unpack(t,e):Bi.prototype.unpack.call(Zw,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ri=e.end||t.length,U=e.start||0):(U=0,Ri=e>-1?e:t.length),Vv=0,An=0,la=null,kv=dA,Tr=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 Bi){if(It=this,this.structures)return nt=this.structures,yh(e);(!nt||nt.length>0)&&(nt=[])}else It=Zw,(!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){eA&&(t=eA.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)}};oL=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;iA=(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]||uA()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=zv(i,n)),i.read()};Gv=Ud,aL=Ud,sL=Ud,lL=Ud;Cr=String.fromCharCode;sA=new Array(4096);lA=(n,t)=>{let e=nr().map(fA),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=zv(e,r),(e.read0||e.read)()};Ur[0]=()=>{};Ur[0].noBuffer=!0;Ur[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};cA={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};Ur[101]=()=>{let n=nr();if(!cA[n[0]]){let t=Error(n[1],{cause:n[2]});return t.name=n[0],t}return cA[n[0]](n[1],{cause:n[2]})};Ur[105]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4);ho||(ho=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};ho.set(t,i);let o=nr();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};Ur[112]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4),e=ho.get(t);return e.used=!0,e.target};Ur[115]=()=>new Set(nr());Hv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array"),cL=typeof globalThis=="object"?globalThis:window;Ur[116]=n=>{let t=n[0],e=Uint8Array.prototype.slice.call(n,1).buffer,r=Hv[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 cL[r](e)};Ur[120]=()=>{let n=nr();return new RegExp(n[0],n[1])};dL=[];Ur[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=U;return U+=t-n.length,Tr=dL,Tr=[aA(),aA()],Tr.position0=0,Tr.position1=0,Tr.postBundlePosition=U,U=e,nr()};Ur[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 Bi({useRecords:!1}),uL=xh.unpack,pL=xh.unpackMultiple,hL=xh.unpack,Sh={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fL=new Float32Array(1),f9=new Uint8Array(fL.buffer,0,4)});function Wv(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 qv(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 gA(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 vL(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 vA(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 Xv(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 bL(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,bA,yA,Y,zd,Dt,j,zr,Wt,mL,yL,gL,dl,ns,xA,xL,SL,wL,AL,EL,CL,SA,wA,AA,Yv=Me(()=>{is();is();is();try{Ah=new TextEncoder}catch{}ul=typeof Buffer<"u",wh=ul?function(n){return Buffer.allocUnsafeSlow(n)}:Uint8Array,bA=ul?Buffer:Uint8Array,yA=ul?4294967296:2144337920,j=0,Wt=null,yL=21760,gL=/[\u0080-\uFFFF]/,dl=Symbol("record-id"),ns=class extends Bi{constructor(t){super(t),this.offset=0;let e,r,i,o,a,s=bA.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),zr=Y.length-10,zr-j<2048?(Y=new wh(Y.length),Dt=Y.dataView||(Y.dataView=new DataView(Y.buffer,0,Y.length)),zr=Y.length-10,j=0):j=j+7&2147483640,r=j,B&AA&&(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&&vA(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>zr&&M(j),l.offset=j;let G=vL(Y.subarray(r,j),V);return a=null,G}return l.offset=j,B&SA?(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=bL(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&wA&&(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>zr&&(Y=M(j));var B=typeof C,_;if(B==="string"){let F=C.length;if(Wt&&F>=4&&F<4096){if((Wt.size+=F)>yL){let G,W=(Wt[0]?Wt[0].length*3+Wt[1].length:0)+10;j+W>zr&&(Y=M(j+W));let H;Wt.position?(H=Wt,Y[j]=200,j+=3,Y[j++]=98,G=j-r,j+=4,vA(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=gL.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>zr&&(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>zr&&M(j),{target:Y,targetView:Dt,position:j-Q}),v)}finally{W&&(Y=W,Dt=H,j=Z,zr=Y.length-10)}te&&(te.length+j>zr&&M(te.length+j),j=gA(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>zr&&M(V.length+j),j=gA(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>yA)throw new Error("Packed buffer would be larger than maximum buffer size");B=Math.min(yA,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,zr=_.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=zr,G=r;Y=zd,j=0,r=0,Y||(zd=Y=new wh(8192)),zr=Y.length-10,R(C,B,F),zd=Y;let W=j;if(Y=V,j=K,zr=q,r=G,W>1){let H=j+W-1;H>zr&&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=mL(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?Wv(n,16,t):qv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==bA&&this.moreTypes?Wv(n,Hv.indexOf(e.name),t):qv(n,t)}},{pack(n,t){this.moreTypes?Wv(n,17,t):qv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];xA=new ns({useRecords:!1}),xL=xA.pack,SL=xA.pack,{NEVER:wL,ALWAYS:AL,DECIMAL_ROUND:EL,DECIMAL_FIT:CL}=Sh,SA=512,wA=1024,AA=2048});var EA=Me(()=>{Yv();is()});var CA=Me(()=>{Yv();is();EA()});var Qv,TL,Th,TA=Me(()=>{"use strict";is();sh();ph();sa();_d();oa();Qv=[{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 Qv)vh(n);TL=new Bi({structuredClone:!0});(t=>{function n(e){return TL.unpack(e)}t.deserialize=n})(Th||(Th={}))});function ML(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 Kv(n){if(na(n))return n;if(Array.isArray(n))return n.map(Kv);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Kv(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var PL,os,PA=Me(()=>{"use strict";CA();fr();TA();PL=new ns({structuredClone:!0});for(let n of Qv)Xv(n);(r=>{function n(i){return PL.pack(i)}r.serialize=n;function t(i){return Th.deserialize(i)}r.deserialize=t;function e(i){return ML(n(Kv(i))).toString()}r.checksum=e})(os||(os={}))});var ut=Me(()=>{Vd();Gw();lh();oa();_d();ch();sa();Ww();Yw();Lv();Kw();sh();PA();Pv();ph()});import{MathUtils as Zv}from"three";function jd(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var MA,$v,OA,Ph,Jv,IA,DA,RA,Mh,Oh,BA,NA,LA,_A,FA,Ih,Dh,kA,VA,GA,UA,OL=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})(MA||(MA={}));$v={["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})(OA||(OA={}));(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})(Jv||(Jv={}));(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(IA||(IA={}));(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:Jv.distanceDefaultData(r)}}e.defaultData=t})(DA||(DA={}));(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}})(RA||(RA={}));(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})(BA||(BA={}));(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})(NA||(NA={}));(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})(LA||(LA={}));(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})(_A||(_A={}));(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})(FA||(FA={}));(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:Zv.generateUUID(),fi:0,data:s},{id:Zv.generateUUID(),fi:1,data:l},{id:Zv.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})(kA||(kA={}));(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})(VA||(VA={}));(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})(GA||(GA={}));(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})(UA||(UA={}))});function HA(n){let t=typeof n;return n!==null&&(t==="object"||t==="function")}function eb(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 En,ua,WA,or,xi,Ni,as,zA,da,Ut,Ue,Rh,fo,ss,jA,Si=Me(()=>{"use strict";En="personal camera",ua="a218fcc3-276b-49b9-b485-49037fd14f5f",WA=2500134,or=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})(xi||(xi={}));(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})(Ni||(Ni={}));(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})(zA||(zA={}));(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 HA(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 HA(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})(fo||(fo={}));(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]))(jA||(jA={}))});var rn,nn,qA=Me(()=>{"use strict";(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(rn||(rn={}));(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})(nn||(nn={}))});var Cn,Bh,tb,Nh,Lh,_h,Fh,kh,XA=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(tb.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})(Cn||(Cn={}));(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={}));tb=["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,YA=Me(()=>{"use strict";Si();(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,QA=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,KA=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,rb=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 ib,nb,zh,ZA,JA=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})(ib||(ib={}));(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})(nb||(nb={}));(t=>t.defaultData={...nb.defaultData,...ib.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})(ZA||(ZA={}))});var hl,$A=Me(()=>{"use strict";(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(hl||(hl={}))});function iE(n){return n.type!=="displace"}var eE,tE,Hd,rE,jh,nE,Ft,qt,Hh=Me(()=>{"use strict";ut();Si();$A();Si();(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})(eE||(eE={}));(t=>{function n(e){return e==="luminance"||e==="r"||e==="g"||e==="b"||e==="a"}t.is=n})(tE||(tE={}));(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})(rE||(rE={}));jh=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],nE=["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(or)};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,oE=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,aE=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,Tn,Yh,ob=Me(()=>{"use strict";oE();aE();(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};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})(Tn||(Tn={}));Yh=["width","height","depth"]});var Li,sE=Me(()=>{"use strict";Si();(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})(Li||(Li={}))});var ab,Pn,sb=Me(()=>{"use strict";(t=>t.defaultData={image:null,rotation:0,blur:32,showBackground:!0})(ab||(ab={}));(t=>t.defaultData={enabled:!1,mode:"hdri",hdri:ab.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2})(Pn||(Pn={}))});var Qh,lE=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,lb,cb,db,ha,ub,Kh,pb=Me(()=>{"use strict";sE();sb();lE();Si();(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})(lb||(lb={}));(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(cb||(cb={}));(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})(db||(db={}));(t=>t.defaultData={usePhysics:!1,gravity:-10})(ha||(ha={}));(t=>t.defaultData={playCamera:En,gameControlObject:null})(ub||(ub={}));(t=>t.defaultData={backgroundColor:Ue.fromHexAndA(WA,1),postprocessing:Qh.defaultData,fog:Li.defaultData,sky:Pn.defaultData,globalPhysics:ha.defaultData,ambient:lb.defaultData,ao:cb.defaultData,shadow:Xd.defaultData,publish:ub.defaultData,grading:db.defaultData})(Kh||(Kh={}))});var Zh,cE=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 dE,ml,yE,Zt,Jh,uE,pE,hE,fE,mo,ds,$h,yl,Mn,on,mE,yo,ef=Me(()=>{"use strict";ut();qA();YA();QA();KA();rb();JA();Si();Hh();ob();XA();fr();pb();cE();(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(dE||(dE={}));(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:Ni.isEqual(o.position,a.position)?void 0:a.position,rotation:Ni.isEqual(o.rotation,a.rotation)?void 0:a.rotation,scale:Ni.isEqual(o.scale,a.scale)?null:a.scale,hiddenMatrix:da.isEqual(o.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}i.diff=r})(ml||(ml={}));yE=["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})(Zt||(Zt={}));(t=>t.defaultData={type:"Empty",...Zt.defaultData})(Jh||(Jh={}));(t=>t.defaultData={type:"ParticleCollider",...Zh.defaultData,...Zt.defaultData})(uE||(uE={}));(t=>t.defaultData={type:"Component",...Zt.defaultData})(pE||(pE={}));(t=>t.defaultData={type:"Particle",...Zt.defaultData,...pl.defaultData})(hE||(hE={}));(t=>t.defaultData={type:"Hair",...Zt.defaultData,...Uh.defaultData})(fE||(fE={}));(t=>t.defaultData={type:"Mesh",...Zt.defaultData,...zh.defaultData})(mo||(mo={}));(t=>t.defaultData={...Zt.defaultData,...ml.identity,position:nn.DefaultPosition,rotation:nn.DefaultRotation,...nn.defaultData})(ds||(ds={}));(e=>{function n(r){return{...Zt.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{...Zt.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})(Mn||(Mn={}));(e=>{e.defaultData={type:"Page",...Zt.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})(on||(on={}));(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},...nn.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",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("RectangleGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("BooleanGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("ShapeBlendGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultTextObject={name:"Text",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("TextGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultInputObject={name:"Input",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("InputGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")}))(mE||(mE={}));(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})))):rn.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})}),rn.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:Cn.merge(s.cloner,a.cloner)});else if(o.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Cn.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})(yo||(yo={}))});var gl,hb=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 Fi,tf=Me(()=>{"use strict";hb();Si();(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})(Fi||(Fi={}))});var fb,mb,go,yb=Me(()=>{"use strict";(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(fb||(fb={}));(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(mb||(mb={}));(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...fb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:mb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(go||(go={}))});var vl,vo,gb=Me(()=>{"use strict";ef();ut();tf();Si();fr();yb();(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:{...on.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Fi.defaultData,styles:go.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new bt,publish:Fi.defaultData,styles:go.defaultData()}},c.emptyDataWithPage=function(d=!0){return{objects:e(d),publish:Fi.defaultData,styles:go.defaultData()}},c.emptyData=function(){return{objects:new bt,publish:{...Fi.defaultData},styles:go.defaultData()}};function s(d){return{...c.defaultData,objects:ir(d,bt.prototype)}}c.withObjs=s;function l(d,u){return s([{id:d,data:u,children:[],fi:0}])}c.withObj=l})(vo||(vo={}))});var bl,gE=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,vE,ar,vb,bE,xE,an,$r,bb=Me(()=>{"use strict";ut();fr();(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}))(vE||(vE={}));(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})(ar||(ar={}));(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(vb||(vb={}));(t=>t.all=[...vb.all,"components"])(bE||(bE={}));(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})(xE||(xE={}));(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})(an||(an={}));(o=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ir(a,Se.prototype)}o.defaultColors=n;function t(){return ir({},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:an.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})($r||($r={}))});var SE=Me(()=>{"use strict"});var fa,wE=Me(()=>{"use strict";ut();gb();gE();bb();(l=>{l.defaultData={schema:131,scene:vo.defaultData,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors()}},l.createDefaultData=function(){return os.deserialize(os.serialize(l.defaultData))},l.emptyDataForImports=function(){let c=vo.emptyDataWithPage();return{schema:131,scene:c,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors(),images:$r.defaultImages()}}},l.emptyData=function(){return{schema:131,scene:vo.emptyDataWithPage(),frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:$r.emptyData()}},l.clipboard2dData=function(){return{schema:131,scene:vo.emptyData(),frames:new Se,shared:$r.emptyData()}};function o(c){return{...c,shared:{...c.shared,lib:an.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 bo(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??{...fo.defaultData},s=new xb(r,i,o,a),l=s.solve(1);return()=>c=>s.solve(c)/l}case 8:return()=>r=>Math.floor(r)}}var AE,EE,xo,xl,xb,Sb=Me(()=>{"use strict";ut();Si();(t=>{function n(e,r){return{id:e,name:r,duration:5,objectTimelines:new Se}}t.defaultData=n})(AE||(AE={}));(t=>{function n(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}t.is=n})(EE||(EE={}));(S=>{function n(v,w){let A=[0,0],E=[1,1];if(v?.cubicControls)A=bo(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=bo(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}}]})(xo||(xo={}));xl=["x","y","z"],xb=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,wb=Me(()=>{"use strict";Si();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 TE(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 In(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Dn(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 IL(n){Object.assign(n.scene.publish,{orbitControls:{...gl.defaultData,...Ht(n.scene.publish.orbitControls)}})}function DL(n){Object.assign(n.scene.publish.settings,{video:{...Fi.defaultData.settings.video,...Ht(n.scene.publish.settings.video)}})}function RL(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))(nE.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 BL(n){n.scene.publish.withBackground=!0}function NL(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function LL(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 _L(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 FL(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 kL(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 VL(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 PE(n){n.layers===void 0&&Object.assign(n,qt.defaultTwoLayerData("lambert"))}function Ab(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 GL(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function ME(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Ab(r)}):"material"in e&&typeof e.material!="string"&&Ab(e.material)}),Object.values(n.shared.materials).forEach(t=>Ab(t))}function UL(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=ir({},Se.prototype)}function jL(n){n.shared.videos=ir({},Se.prototype)}function HL(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 WL(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 qL(n){n.scene.publish.settings.web.preload=!1}function OE(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 IE(n){n.layers&&n.layers.forEach(t=>{iE(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 XL(n){n.shared.fonts=ir({},Se.prototype)}function YL(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 QL(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=YL(i.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:i.name,...Zt.defaultData,...mo.defaultData,flatShading:!1,wireframe:!1,geometry:{...Tn.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 KL(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 ZL(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 DE(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 RE(n){In(n,DE),Dn(n,DE)}function JL(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function $L(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 e3(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 t3(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 r3(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 i3(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 n3(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function o3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function a3(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function s3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=wl.defaultDataThirdPerson.navmesh)})})}function l3(n){n.scene.styles||(n.scene.styles=go.defaultData())}function BE(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function c3(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}),Dn(n,BE),In(n,BE)}function d3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new fe})})})}function u3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function NE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function LE(n,t){if(t<1&&(Dn(n,TE),In(n,TE),n.schema=1),t<2&&(IL(n),n.schema=2),t<3&&(RL(n),n.schema=3),t<4&&(BL(n),n.schema=4),t<5&&(NL(n),n.schema=5),t<6&&(LL(n),n.schema=6),t<7&&(_L(n),n.schema=7),t<8&&(n.schema=8),t<9&&(ME(n),n.schema=9),t<10&&(GL(n),n.schema=10),t<11&&(UL(n),n.schema=11),t<12&&(ME(n),n.schema=12),t<13&&(zL(n),n.schema=13),t<14&&(HL(n),n.schema=14),t<15&&(WL(n),n.schema=15),t<16&&(qL(n),n.schema=16),t<17&&(Dn(n,OE),In(n,OE),n.schema=17),t<18&&(Dn(n,PE),In(n,PE),n.schema=18),t<19&&(DL(n),n.schema=19),t<20&&(XL(n),QL(n),n.schema=20),t<21&&(KL(n),ZL(n),n.schema=21),t<22&&(RE(n),n.schema=22),t<23&&(JL(n),n.schema=23),t<24&&($L(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(jL(n),t<25&&(n.schema=25)),t<26&&(FL(n),n.schema=26),t<27&&(kL(n),n.schema=27),t<28&&(RE(n),n.schema=28),t<29&&(VL(n),n.schema=29),t<30&&(e3(n),n.schema=30),t<31&&(t3(n),n.schema=31),t<33&&(r3(n),n.schema=33),t<34&&(i3(n),n.schema=34),t<35&&(n3(n),n.schema=35),t<36&&(o3(n),n.schema=36),t<37&&(a3(n),n.schema=37),t<38&&(Dn(n,IE),In(n,IE),n.schema=38),t<39&&(s3(n),n.schema=39),t<40&&(l3(n),n.schema=40),t<41&&(c3(n),n.schema=41),t<42&&(d3(n),n.schema=42),t<43&&(u3(n),n.schema=43),t<99){Dn(n,NE),In(n,NE),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=En);let e=Ht(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=ua,r.insertBefore(null,null,[{id:ua,data:{...on.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)??on.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==vo.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 _E=Me(()=>{"use strict";Hh();Si();hb();ef();ut();tf();fr();ob();wb();yb();gb();rb();pb()});var HE={};ZN(HE,{updateAllMaterials:()=>zE,updateDocumentSchema:()=>_3,updateLibSchema:()=>L3,updateMaterialSchema:()=>v3,updateObjectStateRec:()=>El,updateObjectsSchema:()=>UE,updateTextValues:()=>y3});import{MathUtils as p3}from"three";function FE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function h3(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 f3(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 kE(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Al)}function GE(n){kE(n),n.type==="Page"&&kE(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 m3(n){n.shared.variables=ir({},Se.prototype)}function y3(n){n.scene.objects.traverse((t,e)=>{})}function g3(n){let t=Ht(n.shared.variables);n.shared.variables=ir(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),fe.prototype)}function v3(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 UE(n){let t=n.schema??104;t!==131&&(t<105&&(El(n.asset,GE),n.schema=105),t<118&&(El(n.asset,jE),n.schema=118),t<121&&(El(n.asset,Cb),n.schema=121),t<130&&(El(n.asset,b3),n.schema=130))}function zE(n,t){Dn(n,t),In(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 b3(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 x3(n){n.shared.particles=ir({},Se.prototype),n.shared.lib&&(n.shared.lib.particles=an.defaultData().particles)}function S3(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 w3(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 A3(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 E3(n){n.shared.userAPIs=ir({},Se.prototype),n.shared.userWebhooks=ir({},Se.prototype),n.shared.lib&&(n.shared.lib.userAPIs=an.defaultData().userAPIs,n.shared.lib.userWebhooks=an.defaultData().userWebhooks)}function C3(n){n.scene.publish.settings.videoStatic===void 0&&(n.scene.publish.settings.videoStatic=Fi.defaultData.settings.videoStatic)}function jE(n){n.timelineAnimations=ir({},Se.prototype)}function T3(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(xo.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 P3(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=ir({},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:T3(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=ir({},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 M3(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 I3(n){for(let{id:t,data:e}of[...n.unproxy()]){let r=e.path?.[0];if(!r||!O3.includes(r))continue;let i=Eb(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=p3.generateUUID();n.insertBefore(null,[{id:d,data:{...e,id:d,path:[r,c],value:a[c],easing:D3(e.easing)}}])}o.path=[r,s],o.value=a[s]}}function Eb(n){return n===null||typeof n!="object"?[]:xl.filter(t=>t in n)}function D3(n){let t=n?.cubicControls;return{...n,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...n?.springParameters?{springParameters:{...n.springParameters}}:{}}}function R3(n,t){return Math.abs(n[0]-t[0])<1e-6&&Math.abs(n[1]-t[1])<1e-6}function B3(n){let t=[];for(let e of xo.groupKeyframes(n)){let r=new Set(e.keyframes.flatMap(o=>Eb(o.data.value))),i=r.size?[...r].map(o=>e.keyframes.filter(a=>Eb(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 N3(n){let t=B3([...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:xo.presetHandles(s))?.control2??(s===5?bo(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!c)continue;let d=e.get(a.id);d?R3(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:xo.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:bo(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:bo(s.easing.cubicControls?.control1,[0,0]),control2:l})}}function VE(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 Cb(n){n.pivot=[0,0,0],n.pivotRotation=[0,0,0]}function L3(n){}function _3(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),LE(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Fi.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Dn(n,FE),In(n,FE),n.schema=101),t<102&&(h3(n),n.schema=102),t<104&&(n.shared.catelogs=new Se,n.shared.lib=an.defaultData(),n.schema=104),t<105&&(m3(n),n.scene.objects.traverse((e,r)=>{GE(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))UE(e);t<106&&(g3(n),n.schema=106),t<107&&(n.shared.lib.variables=an.defaultData().variables,n.schema=107),t<109&&(x3(n),n.schema=109),t<110&&(S3(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{f3(r)}),n.schema=111),t<112&&(w3(n),n.schema=112),t<113&&(A3(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&&(E3(n),n.schema=115),t<116&&(C3(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=ir({},Se.prototype),n.scene.objects.traverse((e,r)=>{jE(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)=>{Cb(r),r.type==="Page"&&r.camera!==void 0&&Cb(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=Pn.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=Pn.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=Pn.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={...Pn.defaultData.hdri}:(i.hdri.blur===void 0&&(i.hdri.blur=Pn.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=on.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&&(zE(n,af),n.schema=130),t<131&&(M3(n),P3(n),VE(n,I3),VE(n,N3),n.schema=131)}}var Al,O3,Tb=Me(()=>{"use strict";wE();ut();Sb();_E();tf();Hh();fr();bb();ef();sb();Al=180/Math.PI;O3=["position","rotation","scale","shape size"]});var rM=rh((h0,tM)=>{(function(n,t){typeof h0=="object"?tM.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(h0,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 s2=rh((tce,a2)=>{"use strict";function MG(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ms(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,Ms)}MG(Ms,Error);Ms.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 OG(n,t){t=t!==void 0?t:{};var e={},r={svg_path:Rr},i=Rr,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 HN(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 WN=Object.create;var th=Object.defineProperty;var qN=Object.getOwnPropertyDescriptor;var XN=Object.getOwnPropertyNames;var YN=Object.getPrototypeOf,QN=Object.prototype.hasOwnProperty;var KN=(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),ZN=(n,t)=>{for(var e in t)th(n,e,{get:t[e],enumerable:!0})},JN=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of XN(t))!QN.call(n,i)&&i!==e&&th(n,i,{get:()=>t[i],enumerable:!(r=qN(t,i))||r.enumerable});return n};var Bd=(n,t,e)=>(e=n!=null?WN(YN(n)):{},JN(t||!n||!n.__esModule?th(e,"default",{value:n,enumerable:!0}):e,n));var Gr=(n,t,e)=>(KN(n,typeof t!="symbol"?t+"":t,e),e);var Lw=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 _w=Me(()=>{"use strict"});function ir(n,t){return Object.setPrototypeOf(n,t),n}function nh(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Sn(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 na(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 Fw(){return typeof process<"u"}var kw=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 Vw=Me(()=>{"use strict"});var fr=Me(()=>{Lw();_w();kw();Vw()});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 Gw=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 Uw(n,t){for(let e of n)t(e.id,e.data)!==!0&&Uw(e.children,t)}function zw(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)zw(e,t)}var bt,oa=Me(()=>{"use strict";fr();lh();fr();bt=class extends Array{constructor(...e){super(...e);Gr(this,"partialObjectCaches");Gr(this,"objCaches");Gr(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&&zw(i,r)}}traverse(e){Uw(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 Sn(0,i,i);{let a=o[0].fi;return Sn(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 Sn(l,l+i,i)}else return Sn(a.fi,s.fi,i)}}}});var Tv,aa,ch=Me(()=>{"use strict";Tv=null;(r=>{function n(i){Tv=i}r.setPreservePrototype=n;function t(i,o){return Object.getPrototypeOf(i)===Tv&&Object.setPrototypeOf(o,Tv),o}r.tryPreservePrototype=t;function e(i,o){if(o.type!==0)return null;if(Array.isArray(i)){let a=o.props,s={},l=[...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";fr();fr();fe=class extends Array{constructor(...e){super(...e);Gr(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 Fw()||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 Sn(0,r,r);{let o=i[0].fi;return Sn(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 Sn(s,s+r,r)}else return Sn(o.fi,a.fi,r)}}}});function jw(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 $N(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Hw(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=Hw(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 eL(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=Hw(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof fe)return eL(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"&&!na(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&&$N(e),r}else return}}var Pv=Me(()=>{"use strict";oa();sa();fr()});function ol(n){return n&&typeof n=="object"&&n instanceof Ct}function Mv(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=Mv(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 tL(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=Mv(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof fe)return tL(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 Ov(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 Ov(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ol(t))return t;if(!ol(n))return wn.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=Ov(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=o}return r}var Ct,wn,ph=Me(()=>{"use strict";oa();sa();Vd();fr();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 Ov(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=Mv([o],l);return c?c[0]:o}else return o}r.filterOp=e})(wn||(wn={}))});var al,zt,Iv,Ww=Me(()=>{"use strict";Vd();_d();oa();lh();ch();sa();Pv();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)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let x=m;m=[...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]=jw(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})(Iv||(Iv={}))});function Dv(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 Bv(n,t,e),nL):e!==null&&typeof e=="object"?na(e)?e:new Proxy(new Rv(n,t,e),iL):e}function Nv(n){let t=new hh(n);return[mh(t,"",n),t]}function cl(n,t){let[e,r]=Nv(n);return t(e),r.result()}function Ht(n){return n instanceof sl||n instanceof ll?n._current:n!==null&&typeof n=="object"?n[qw]:n}var qw,rL,fh,ts,Rv,Bv,Xw,iL,nL,sl,ll,hh,Lv=Me(()=>{"use strict";_d();oa();ch();sa();fr();Vd();qw=Symbol(),rL=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]}}}},Rv=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)}},Bv=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))}},Xw={get(n,t){if(t===fh)return()=>{n._parent=null};if(t===qw)return n._current;if(t===rL)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]}}},iL={...Xw,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}},nL={...Xw,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){Dv(this.ts,e,t),Dv(this.actual,r,t),Dv(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();Lv();sa();oa();fr();(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(p,[...u,h])});else if(Array.isArray(d))for(let p=0;p<d.length;p++)c(d[p],[...u,p]);else{if(na(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 Yw=Me(()=>{"use strict"});function Qw(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 Kw=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&&$w?(t=$w(ge,U,Ri,It),ge=null,!(n&&n.lazy)&&t&&(t=t.toJSON()),U=Ri):t=nr(),Tr&&(U=Tr.postBundlePosition,Tr=null),ca&&(nt.restoreStructures=null),U==Ri)nt&&nt.restoreStructures&&rA(),nt=null,ge=null,ho&&(ho=null);else{if(U>Ri)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&&rA(),gh(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||U>Ri)&&(t.incomplete=!0),t}}function rA(){for(let n in nt.restoreStructures)nt[n]=nt.restoreStructures[n];nt.restoreStructures=null}function nr(){let n=ge[U++];if(n<160)if(n<128){if(n<64)return n;{let t=nt[n&63]||It.getStructures&&uA()[n&63];return t?(t.read||(t.read=zv(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=hA();r==="__proto__"&&(r="__proto_"),t[r]=nr()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(nr(),nr());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=nr();return It.freezeData?Object.freeze(t):t}else if(n<192){let t=n-160;if(An>=U)return la.slice(U-Di,(U+=t)-Di);if(An==0&&Ri<140){let e=t<16?jv(t):pA(t);if(e!=null)return e}return Gv(t)}else{let t;switch(n){case 192:return null;case 193:return Tr?(t=nr(),t>0?Tr[1].slice(Tr.position1,Tr.position1+=t):Tr[0].slice(Tr.position0,Tr.position0-=t)):Uv;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 _v(t);case 197:return t=tt.getUint16(U),U+=2,_v(t);case 198:return t=tt.getUint32(U),U+=4,_v(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 lA(ge[U++]&63);{let e=Ur[t];if(e)return e.read?(U++,e.read(nr())):e.noBuffer?(U++,e()):e(ge.subarray(U,++U));throw new Error("Unknown extension "+t)}case 213:return t=ge[U],t==114?(U++,lA(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++],An>=U?la.slice(U-Di,(U+=t)-Di):aL(t);case 218:return t=tt.getUint16(U),U+=2,An>=U?la.slice(U-Di,(U+=t)-Di):sL(t);case 219:return t=tt.getUint32(U),U+=4,An>=U?la.slice(U-Di,(U+=t)-Di):lL(t);case 220:return t=tt.getUint16(U),U+=2,nA(t);case 221:return t=tt.getUint32(U),U+=4,nA(t);case 222:return t=tt.getUint16(U),U+=2,oA(t);case 223:return t=tt.getUint32(U),U+=4,oA(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 zv(n,t){function e(){if(e.count++>Jw){let i;try{i=n.read=new Function("r","return function(){return "+(It.freezeData?"Object.freeze":"")+"({"+n.map(o=>o==="__proto__"?"__proto_:r()":oL.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"})}")(nr)}catch{return Jw=1/0,e()}return n.read0=i,n.highByte===0&&(n.read=iA(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]=nr()}return It.freezeData?Object.freeze(r):r}return e.count=0,n.read0=e,n.highByte===0?iA(t,e):e}function uA(){let n=mA(()=>(ge=null,It.getStructures()));return nt=It._mergeStructures(n,nt)}function Ud(n){let t;if(n<16&&(t=jv(n)))return t;if(n>64&&Fv)return Fv.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+=Cr.apply(String,r),r.length=0)}return r.length>0&&(t+=Cr.apply(String,r)),t}function nA(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=nr();return It.freezeData?Object.freeze(t):t}function oA(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++){let r=hA();r==="__proto__"&&(r="__proto_"),t[r]=nr()}return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(nr(),nr());return t}}function pA(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 Cr.apply(String,e)}function jv(n){if(n<4)if(n<2){if(n===0)return"";{let t=ge[U++];if((t&128)>1){U-=1;return}return Cr(t)}}else{let t=ge[U++],e=ge[U++];if((t&128)>0||(e&128)>0){U-=2;return}if(n<3)return Cr(t,e);let r=ge[U++];if((r&128)>0){U-=3;return}return Cr(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 Cr(t,e,r,i);{let o=ge[U++];if((o&128)>0){U-=5;return}return Cr(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 Cr(t,e,r,i,o,a);let s=ge[U++];if((s&128)>0){U-=7;return}return Cr(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 Cr(t,e,r,i,o,a,s,l);{let c=ge[U++];if((c&128)>0){U-=9;return}return Cr(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 Cr(t,e,r,i,o,a,s,l,c,d);let u=ge[U++];if((u&128)>0){U-=11;return}return Cr(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 Cr(t,e,r,i,o,a,s,l,c,d,u,p);{let h=ge[U++];if((h&128)>0){U-=13;return}return Cr(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 Cr(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 Cr(t,e,r,i,o,a,s,l,c,d,u,p,h,f,m)}}}}}function aA(){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 _v(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(Ur[t]){let e;return Ur[t](ge.subarray(U,e=U+=n),r=>{U=r;try{return nr()}finally{U=e}})}else throw new Error("Unknown extension type "+t)}function hA(){let n=ge[U++];if(n>=160&&n<192){if(n=n-160,An>=U)return la.slice(U-Di,(U+=n)-Di);if(!(An==0&&Ri<180))return Gv(n)}else return U--,fA(nr());let t=(n<<5^(n>1?tt.getUint16(U):n>0?ge[U]:0))&4095,e=sA[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=[],sA[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?jv(n):pA(n);return s!=null?e.string=s:e.string=Gv(n)}function fA(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 mA(n){tA&&tA();let t=Ri,e=U,r=Vv,i=Di,o=An,a=la,s=kv,l=ho,c=Tr,d=new Uint8Array(ge.slice(0,Ri)),u=nt,p=nt.slice(0,nt.length),h=It,f=ca,m=n();return Ri=t,U=e,Vv=r,Di=i,An=o,la=a,kv=s,ho=l,Tr=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,ho=null,nt=null}function vh(n){n.unpack?Ur[n.type]=n.unpack:Ur[n.type]=n}var Fv,ge,Ri,U,dA,kv,Vv,It,nt,la,Di,An,Tr,ho,Ur,tt,Zw,Gd,Uv,ca,Jw,$w,eA,tA,Bi,oL,iA,Gv,aL,sL,lL,Cr,sA,lA,cA,Hv,cL,dL,bh,xh,uL,pL,hL,Sh,fL,f9,is=Me(()=>{try{Fv=new TextDecoder}catch{}U=0,dA=[],kv=dA,Vv=0,It={},Di=0,An=0,Ur=[],Zw={useRecords:!1,mapsAsObjects:!0},Gd=class{},Uv=new Gd;Uv.name="MessagePack 0xC1";ca=!1,Jw=2,Bi=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 mA(()=>(gh(),this?this.unpack(t,e):Bi.prototype.unpack.call(Zw,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ri=e.end||t.length,U=e.start||0):(U=0,Ri=e>-1?e:t.length),Vv=0,An=0,la=null,kv=dA,Tr=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 Bi){if(It=this,this.structures)return nt=this.structures,yh(e);(!nt||nt.length>0)&&(nt=[])}else It=Zw,(!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){eA&&(t=eA.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)}};oL=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;iA=(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]||uA()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=zv(i,n)),i.read()};Gv=Ud,aL=Ud,sL=Ud,lL=Ud;Cr=String.fromCharCode;sA=new Array(4096);lA=(n,t)=>{let e=nr().map(fA),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=zv(e,r),(e.read0||e.read)()};Ur[0]=()=>{};Ur[0].noBuffer=!0;Ur[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};cA={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};Ur[101]=()=>{let n=nr();if(!cA[n[0]]){let t=Error(n[1],{cause:n[2]});return t.name=n[0],t}return cA[n[0]](n[1],{cause:n[2]})};Ur[105]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4);ho||(ho=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};ho.set(t,i);let o=nr();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};Ur[112]=n=>{if(It.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=tt.getUint32(U-4),e=ho.get(t);return e.used=!0,e.target};Ur[115]=()=>new Set(nr());Hv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array"),cL=typeof globalThis=="object"?globalThis:window;Ur[116]=n=>{let t=n[0],e=Uint8Array.prototype.slice.call(n,1).buffer,r=Hv[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 cL[r](e)};Ur[120]=()=>{let n=nr();return new RegExp(n[0],n[1])};dL=[];Ur[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=U;return U+=t-n.length,Tr=dL,Tr=[aA(),aA()],Tr.position0=0,Tr.position1=0,Tr.postBundlePosition=U,U=e,nr()};Ur[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 Bi({useRecords:!1}),uL=xh.unpack,pL=xh.unpackMultiple,hL=xh.unpack,Sh={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fL=new Float32Array(1),f9=new Uint8Array(fL.buffer,0,4)});function Wv(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 qv(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 gA(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 vL(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 vA(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 Xv(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 bL(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,bA,yA,Y,zd,Dt,j,zr,Wt,mL,yL,gL,dl,ns,xA,xL,SL,wL,AL,EL,CL,SA,wA,AA,Yv=Me(()=>{is();is();is();try{Ah=new TextEncoder}catch{}ul=typeof Buffer<"u",wh=ul?function(n){return Buffer.allocUnsafeSlow(n)}:Uint8Array,bA=ul?Buffer:Uint8Array,yA=ul?4294967296:2144337920,j=0,Wt=null,yL=21760,gL=/[\u0080-\uFFFF]/,dl=Symbol("record-id"),ns=class extends Bi{constructor(t){super(t),this.offset=0;let e,r,i,o,a,s=bA.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),zr=Y.length-10,zr-j<2048?(Y=new wh(Y.length),Dt=Y.dataView||(Y.dataView=new DataView(Y.buffer,0,Y.length)),zr=Y.length-10,j=0):j=j+7&2147483640,r=j,B&AA&&(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&&vA(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>zr&&M(j),l.offset=j;let G=vL(Y.subarray(r,j),V);return a=null,G}return l.offset=j,B&SA?(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=bL(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&wA&&(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>zr&&(Y=M(j));var B=typeof C,_;if(B==="string"){let F=C.length;if(Wt&&F>=4&&F<4096){if((Wt.size+=F)>yL){let G,W=(Wt[0]?Wt[0].length*3+Wt[1].length:0)+10;j+W>zr&&(Y=M(j+W));let H;Wt.position?(H=Wt,Y[j]=200,j+=3,Y[j++]=98,G=j-r,j+=4,vA(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=gL.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>zr&&(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>zr&&M(j),{target:Y,targetView:Dt,position:j-Q}),v)}finally{W&&(Y=W,Dt=H,j=Z,zr=Y.length-10)}te&&(te.length+j>zr&&M(te.length+j),j=gA(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>zr&&M(V.length+j),j=gA(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>yA)throw new Error("Packed buffer would be larger than maximum buffer size");B=Math.min(yA,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,zr=_.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=zr,G=r;Y=zd,j=0,r=0,Y||(zd=Y=new wh(8192)),zr=Y.length-10,R(C,B,F),zd=Y;let W=j;if(Y=V,j=K,zr=q,r=G,W>1){let H=j+W-1;H>zr&&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=mL(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?Wv(n,16,t):qv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==bA&&this.moreTypes?Wv(n,Hv.indexOf(e.name),t):qv(n,t)}},{pack(n,t){this.moreTypes?Wv(n,17,t):qv(ul?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];xA=new ns({useRecords:!1}),xL=xA.pack,SL=xA.pack,{NEVER:wL,ALWAYS:AL,DECIMAL_ROUND:EL,DECIMAL_FIT:CL}=Sh,SA=512,wA=1024,AA=2048});var EA=Me(()=>{Yv();is()});var CA=Me(()=>{Yv();is();EA()});var Qv,TL,Th,TA=Me(()=>{"use strict";is();sh();ph();sa();_d();oa();Qv=[{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 Qv)vh(n);TL=new Bi({structuredClone:!0});(t=>{function n(e){return TL.unpack(e)}t.deserialize=n})(Th||(Th={}))});function ML(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 Kv(n){if(na(n))return n;if(Array.isArray(n))return n.map(Kv);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Kv(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var PL,os,PA=Me(()=>{"use strict";CA();fr();TA();PL=new ns({structuredClone:!0});for(let n of Qv)Xv(n);(r=>{function n(i){return PL.pack(i)}r.serialize=n;function t(i){return Th.deserialize(i)}r.deserialize=t;function e(i){return ML(n(Kv(i))).toString()}r.checksum=e})(os||(os={}))});var ut=Me(()=>{Vd();Gw();lh();oa();_d();ch();sa();Ww();Yw();Lv();Kw();sh();PA();Pv();ph()});import{MathUtils as Zv}from"three";function jd(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var MA,$v,OA,Ph,Jv,IA,DA,RA,Mh,Oh,BA,NA,LA,_A,FA,Ih,Dh,kA,VA,GA,UA,OL=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})(MA||(MA={}));$v={["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})(OA||(OA={}));(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})(Jv||(Jv={}));(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(IA||(IA={}));(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:Jv.distanceDefaultData(r)}}e.defaultData=t})(DA||(DA={}));(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}})(RA||(RA={}));(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})(BA||(BA={}));(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})(NA||(NA={}));(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})(LA||(LA={}));(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})(_A||(_A={}));(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})(FA||(FA={}));(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:Zv.generateUUID(),fi:0,data:s},{id:Zv.generateUUID(),fi:1,data:l},{id:Zv.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})(kA||(kA={}));(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})(VA||(VA={}));(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})(GA||(GA={}));(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})(UA||(UA={}))});function HA(n){let t=typeof n;return n!==null&&(t==="object"||t==="function")}function eb(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 En,ua,WA,or,xi,Ni,as,zA,da,Ut,Ue,Rh,fo,ss,jA,Si=Me(()=>{"use strict";En="personal camera",ua="a218fcc3-276b-49b9-b485-49037fd14f5f",WA=2500134,or=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})(xi||(xi={}));(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})(Ni||(Ni={}));(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})(zA||(zA={}));(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 HA(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 HA(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})(fo||(fo={}));(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]))(jA||(jA={}))});var rn,nn,qA=Me(()=>{"use strict";(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(rn||(rn={}));(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})(nn||(nn={}))});var Cn,Bh,tb,Nh,Lh,_h,Fh,kh,XA=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(tb.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})(Cn||(Cn={}));(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={}));tb=["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,YA=Me(()=>{"use strict";Si();(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,QA=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,KA=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,rb=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 ib,nb,zh,ZA,JA=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})(ib||(ib={}));(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})(nb||(nb={}));(t=>t.defaultData={...nb.defaultData,...ib.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})(ZA||(ZA={}))});var hl,$A=Me(()=>{"use strict";(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(hl||(hl={}))});function iE(n){return n.type!=="displace"}var eE,tE,Hd,rE,jh,nE,Ft,qt,Hh=Me(()=>{"use strict";ut();Si();$A();Si();(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})(eE||(eE={}));(t=>{function n(e){return e==="luminance"||e==="r"||e==="g"||e==="b"||e==="a"}t.is=n})(tE||(tE={}));(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})(rE||(rE={}));jh=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],nE=["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(or)};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,oE=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,aE=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,Tn,Yh,ob=Me(()=>{"use strict";oE();aE();(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};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})(Tn||(Tn={}));Yh=["width","height","depth"]});var Li,sE=Me(()=>{"use strict";Si();(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})(Li||(Li={}))});var ab,Pn,sb=Me(()=>{"use strict";(t=>t.defaultData={image:null,rotation:0,blur:32,showBackground:!0})(ab||(ab={}));(t=>t.defaultData={enabled:!1,mode:"hdri",hdri:ab.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2})(Pn||(Pn={}))});var Qh,lE=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,lb,cb,db,ha,ub,Kh,pb=Me(()=>{"use strict";sE();sb();lE();Si();(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})(lb||(lb={}));(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(cb||(cb={}));(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})(db||(db={}));(t=>t.defaultData={usePhysics:!1,gravity:-10})(ha||(ha={}));(t=>t.defaultData={playCamera:En,gameControlObject:null})(ub||(ub={}));(t=>t.defaultData={backgroundColor:Ue.fromHexAndA(WA,1),postprocessing:Qh.defaultData,fog:Li.defaultData,sky:Pn.defaultData,globalPhysics:ha.defaultData,ambient:lb.defaultData,ao:cb.defaultData,shadow:Xd.defaultData,publish:ub.defaultData,grading:db.defaultData})(Kh||(Kh={}))});var Zh,cE=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 dE,ml,yE,Zt,Jh,uE,pE,hE,fE,mo,ds,$h,yl,Mn,on,mE,yo,ef=Me(()=>{"use strict";ut();qA();YA();QA();KA();rb();JA();Si();Hh();ob();XA();fr();pb();cE();(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(dE||(dE={}));(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:Ni.isEqual(o.position,a.position)?void 0:a.position,rotation:Ni.isEqual(o.rotation,a.rotation)?void 0:a.rotation,scale:Ni.isEqual(o.scale,a.scale)?null:a.scale,hiddenMatrix:da.isEqual(o.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}i.diff=r})(ml||(ml={}));yE=["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})(Zt||(Zt={}));(t=>t.defaultData={type:"Empty",...Zt.defaultData})(Jh||(Jh={}));(t=>t.defaultData={type:"ParticleCollider",...Zh.defaultData,...Zt.defaultData})(uE||(uE={}));(t=>t.defaultData={type:"Component",...Zt.defaultData})(pE||(pE={}));(t=>t.defaultData={type:"Particle",...Zt.defaultData,...pl.defaultData})(hE||(hE={}));(t=>t.defaultData={type:"Hair",...Zt.defaultData,...Uh.defaultData})(fE||(fE={}));(t=>t.defaultData={type:"Mesh",...Zt.defaultData,...zh.defaultData})(mo||(mo={}));(t=>t.defaultData={...Zt.defaultData,...ml.identity,position:nn.DefaultPosition,rotation:nn.DefaultRotation,...nn.defaultData})(ds||(ds={}));(e=>{function n(r){return{...Zt.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{...Zt.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})(Mn||(Mn={}));(e=>{e.defaultData={type:"Page",...Zt.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})(on||(on={}));(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},...nn.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",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("RectangleGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("BooleanGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("ShapeBlendGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultTextObject={name:"Text",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("TextGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")},s.defaultInputObject={name:"Input",...Zt.defaultData,...mo.defaultData,geometry:Tn.defaultData("InputGeometry"),material:qt.defaultTwoLayerData("physical","layer1","layer2")}))(mE||(mE={}));(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})))):rn.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})}),rn.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:Cn.merge(s.cloner,a.cloner)});else if(o.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Cn.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})(yo||(yo={}))});var gl,hb=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 Fi,tf=Me(()=>{"use strict";hb();Si();(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})(Fi||(Fi={}))});var fb,mb,go,yb=Me(()=>{"use strict";(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(fb||(fb={}));(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(mb||(mb={}));(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...fb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:mb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(go||(go={}))});var vl,vo,gb=Me(()=>{"use strict";ef();ut();tf();Si();fr();yb();(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:{...on.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Fi.defaultData,styles:go.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new bt,publish:Fi.defaultData,styles:go.defaultData()}},c.emptyDataWithPage=function(d=!0){return{objects:e(d),publish:Fi.defaultData,styles:go.defaultData()}},c.emptyData=function(){return{objects:new bt,publish:{...Fi.defaultData},styles:go.defaultData()}};function s(d){return{...c.defaultData,objects:ir(d,bt.prototype)}}c.withObjs=s;function l(d,u){return s([{id:d,data:u,children:[],fi:0}])}c.withObj=l})(vo||(vo={}))});var bl,gE=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,vE,ar,vb,bE,xE,an,$r,bb=Me(()=>{"use strict";ut();fr();(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}))(vE||(vE={}));(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})(ar||(ar={}));(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(vb||(vb={}));(t=>t.all=[...vb.all,"components"])(bE||(bE={}));(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})(xE||(xE={}));(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})(an||(an={}));(o=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ir(a,Se.prototype)}o.defaultColors=n;function t(){return ir({},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:an.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})($r||($r={}))});var SE=Me(()=>{"use strict"});var fa,wE=Me(()=>{"use strict";ut();gb();gE();bb();(l=>{l.defaultData={schema:131,scene:vo.defaultData,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors()}},l.createDefaultData=function(){return os.deserialize(os.serialize(l.defaultData))},l.emptyDataForImports=function(){let c=vo.emptyDataWithPage();return{schema:131,scene:c,frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors(),images:$r.defaultImages()}}},l.emptyData=function(){return{schema:131,scene:vo.emptyDataWithPage(),frames:new Se().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",bl.defaultData),shared:$r.emptyData()}},l.clipboard2dData=function(){return{schema:131,scene:vo.emptyData(),frames:new Se,shared:$r.emptyData()}};function o(c){return{...c,shared:{...c.shared,lib:an.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 bo(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??{...fo.defaultData},s=new xb(r,i,o,a),l=s.solve(1);return()=>c=>s.solve(c)/l}case 8:return()=>r=>Math.floor(r)}}var AE,EE,xo,xl,xb,Sb=Me(()=>{"use strict";ut();Si();(t=>{function n(e,r){return{id:e,name:r,duration:5,objectTimelines:new Se}}t.defaultData=n})(AE||(AE={}));(t=>{function n(e){return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}t.is=n})(EE||(EE={}));(S=>{function n(v,w){let A=[0,0],E=[1,1];if(v?.cubicControls)A=bo(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=bo(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}}]})(xo||(xo={}));xl=["x","y","z"],xb=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,wb=Me(()=>{"use strict";Si();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 TE(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 In(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Dn(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 IL(n){Object.assign(n.scene.publish,{orbitControls:{...gl.defaultData,...Ht(n.scene.publish.orbitControls)}})}function DL(n){Object.assign(n.scene.publish.settings,{video:{...Fi.defaultData.settings.video,...Ht(n.scene.publish.settings.video)}})}function RL(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))(nE.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 BL(n){n.scene.publish.withBackground=!0}function NL(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function LL(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 _L(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 FL(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 kL(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 VL(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 PE(n){n.layers===void 0&&Object.assign(n,qt.defaultTwoLayerData("lambert"))}function Ab(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 GL(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function ME(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Ab(r)}):"material"in e&&typeof e.material!="string"&&Ab(e.material)}),Object.values(n.shared.materials).forEach(t=>Ab(t))}function UL(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=ir({},Se.prototype)}function jL(n){n.shared.videos=ir({},Se.prototype)}function HL(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 WL(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 qL(n){n.scene.publish.settings.web.preload=!1}function OE(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 IE(n){n.layers&&n.layers.forEach(t=>{iE(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 XL(n){n.shared.fonts=ir({},Se.prototype)}function YL(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 QL(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=YL(i.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:i.name,...Zt.defaultData,...mo.defaultData,flatShading:!1,wireframe:!1,geometry:{...Tn.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 KL(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 ZL(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 DE(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 RE(n){In(n,DE),Dn(n,DE)}function JL(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function $L(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 e3(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 t3(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 r3(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 i3(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 n3(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function o3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function a3(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function s3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=wl.defaultDataThirdPerson.navmesh)})})}function l3(n){n.scene.styles||(n.scene.styles=go.defaultData())}function BE(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function c3(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}),Dn(n,BE),In(n,BE)}function d3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new fe})})})}function u3(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function NE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function LE(n,t){if(t<1&&(Dn(n,TE),In(n,TE),n.schema=1),t<2&&(IL(n),n.schema=2),t<3&&(RL(n),n.schema=3),t<4&&(BL(n),n.schema=4),t<5&&(NL(n),n.schema=5),t<6&&(LL(n),n.schema=6),t<7&&(_L(n),n.schema=7),t<8&&(n.schema=8),t<9&&(ME(n),n.schema=9),t<10&&(GL(n),n.schema=10),t<11&&(UL(n),n.schema=11),t<12&&(ME(n),n.schema=12),t<13&&(zL(n),n.schema=13),t<14&&(HL(n),n.schema=14),t<15&&(WL(n),n.schema=15),t<16&&(qL(n),n.schema=16),t<17&&(Dn(n,OE),In(n,OE),n.schema=17),t<18&&(Dn(n,PE),In(n,PE),n.schema=18),t<19&&(DL(n),n.schema=19),t<20&&(XL(n),QL(n),n.schema=20),t<21&&(KL(n),ZL(n),n.schema=21),t<22&&(RE(n),n.schema=22),t<23&&(JL(n),n.schema=23),t<24&&($L(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(jL(n),t<25&&(n.schema=25)),t<26&&(FL(n),n.schema=26),t<27&&(kL(n),n.schema=27),t<28&&(RE(n),n.schema=28),t<29&&(VL(n),n.schema=29),t<30&&(e3(n),n.schema=30),t<31&&(t3(n),n.schema=31),t<33&&(r3(n),n.schema=33),t<34&&(i3(n),n.schema=34),t<35&&(n3(n),n.schema=35),t<36&&(o3(n),n.schema=36),t<37&&(a3(n),n.schema=37),t<38&&(Dn(n,IE),In(n,IE),n.schema=38),t<39&&(s3(n),n.schema=39),t<40&&(l3(n),n.schema=40),t<41&&(c3(n),n.schema=41),t<42&&(d3(n),n.schema=42),t<43&&(u3(n),n.schema=43),t<99){Dn(n,NE),In(n,NE),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=En);let e=Ht(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=ua,r.insertBefore(null,null,[{id:ua,data:{...on.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)??on.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==vo.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 _E=Me(()=>{"use strict";Hh();Si();hb();ef();ut();tf();fr();ob();wb();yb();gb();rb();pb()});var HE={};ZN(HE,{updateAllMaterials:()=>zE,updateDocumentSchema:()=>_3,updateLibSchema:()=>L3,updateMaterialSchema:()=>v3,updateObjectStateRec:()=>El,updateObjectsSchema:()=>UE,updateTextValues:()=>y3});import{MathUtils as p3}from"three";function FE(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function h3(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 f3(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 kE(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Al)}function GE(n){kE(n),n.type==="Page"&&kE(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 m3(n){n.shared.variables=ir({},Se.prototype)}function y3(n){n.scene.objects.traverse((t,e)=>{})}function g3(n){let t=Ht(n.shared.variables);n.shared.variables=ir(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),fe.prototype)}function v3(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 UE(n){let t=n.schema??104;t!==131&&(t<105&&(El(n.asset,GE),n.schema=105),t<118&&(El(n.asset,jE),n.schema=118),t<121&&(El(n.asset,Cb),n.schema=121),t<130&&(El(n.asset,b3),n.schema=130))}function zE(n,t){Dn(n,t),In(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 b3(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 x3(n){n.shared.particles=ir({},Se.prototype),n.shared.lib&&(n.shared.lib.particles=an.defaultData().particles)}function S3(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 w3(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 A3(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 E3(n){n.shared.userAPIs=ir({},Se.prototype),n.shared.userWebhooks=ir({},Se.prototype),n.shared.lib&&(n.shared.lib.userAPIs=an.defaultData().userAPIs,n.shared.lib.userWebhooks=an.defaultData().userWebhooks)}function C3(n){n.scene.publish.settings.videoStatic===void 0&&(n.scene.publish.settings.videoStatic=Fi.defaultData.settings.videoStatic)}function jE(n){n.timelineAnimations=ir({},Se.prototype)}function T3(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(xo.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 P3(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=ir({},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:T3(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=ir({},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 M3(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 I3(n){for(let{id:t,data:e}of[...n.unproxy()]){let r=e.path?.[0];if(!r||!O3.includes(r))continue;let i=Eb(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=p3.generateUUID();n.insertBefore(null,[{id:d,data:{...e,id:d,path:[r,c],value:a[c],easing:D3(e.easing)}}])}o.path=[r,s],o.value=a[s]}}function Eb(n){return n===null||typeof n!="object"?[]:xl.filter(t=>t in n)}function D3(n){let t=n?.cubicControls;return{...n,cubicControls:{control1:[...t?.control1??[0,0]],control2:[...t?.control2??[1,1]]},...n?.springParameters?{springParameters:{...n.springParameters}}:{}}}function R3(n,t){return Math.abs(n[0]-t[0])<1e-6&&Math.abs(n[1]-t[1])<1e-6}function B3(n){let t=[];for(let e of xo.groupKeyframes(n)){let r=new Set(e.keyframes.flatMap(o=>Eb(o.data.value))),i=r.size?[...r].map(o=>e.keyframes.filter(a=>Eb(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 N3(n){let t=B3([...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:xo.presetHandles(s))?.control2??(s===5?bo(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!c)continue;let d=e.get(a.id);d?R3(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:xo.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:bo(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:bo(s.easing.cubicControls?.control1,[0,0]),control2:l})}}function VE(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 Cb(n){n.pivot=[0,0,0],n.pivotRotation=[0,0,0]}function L3(n){}function _3(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),LE(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Fi.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Dn(n,FE),In(n,FE),n.schema=101),t<102&&(h3(n),n.schema=102),t<104&&(n.shared.catelogs=new Se,n.shared.lib=an.defaultData(),n.schema=104),t<105&&(m3(n),n.scene.objects.traverse((e,r)=>{GE(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))UE(e);t<106&&(g3(n),n.schema=106),t<107&&(n.shared.lib.variables=an.defaultData().variables,n.schema=107),t<109&&(x3(n),n.schema=109),t<110&&(S3(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{f3(r)}),n.schema=111),t<112&&(w3(n),n.schema=112),t<113&&(A3(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&&(E3(n),n.schema=115),t<116&&(C3(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=ir({},Se.prototype),n.scene.objects.traverse((e,r)=>{jE(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)=>{Cb(r),r.type==="Page"&&r.camera!==void 0&&Cb(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=Pn.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=Pn.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=Pn.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={...Pn.defaultData.hdri}:(i.hdri.blur===void 0&&(i.hdri.blur=Pn.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=on.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&&(zE(n,af),n.schema=130),t<131&&(M3(n),P3(n),VE(n,I3),VE(n,N3),n.schema=131)}}var Al,O3,Tb=Me(()=>{wE();ut();Sb();_E();tf();Hh();fr();bb();ef();sb();Al=180/Math.PI;O3=["position","rotation","scale","shape size"]});var rM=rh((h0,tM)=>{(function(n,t){typeof h0=="object"?tM.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(h0,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 s2=rh((tce,a2)=>{"use strict";function MG(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ms(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,Ms)}MG(Ms,Error);Ms.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 OG(n,t){t=t!==void 0?t:{};var e={},r={svg_path:Rr},i=Rr,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 HN(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([gv(T)],n.substring(J,O),I)}function Be(T,I){throw I=I!==void 0?I:Ka(J,O),tn(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 gv(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 tn(T,I){return new Ms(T,null,null,I)}function Id(T,I,k){return new Ms(Ms.buildMessage(T,I),T,I,k)}function Rr(){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=MN(),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=ON(),T===e&&(T=IN(),T===e&&(T=DN(),T===e&&(T=RN(),T===e&&(T=BN(),T===e&&(T=LN(),T===e&&(T=FN(),T===e&&(T=VN(),T===e&&(T=UN())))))))),T}function MN(){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=Jr(),L!==e?(z=O,pe=Gt(),pe===e&&(pe=null),pe!==e?(il=Pw(),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 ON(){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 IN(){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=Pw(),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 Pw(){var T,I,k,L,z,pe;if(T=O,I=Jr(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=Jr(),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=Jr(),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 DN(){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=Mw(),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 Mw(){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 RN(){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=Mw(),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 BN(){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=NN(),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 NN(){var T,I,k,L,z,pe;if(T=O,I=vv(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=vv(),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=vv(),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 vv(){var T,I,k,L,z,pe;return T=O,I=Jr(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=Jr(),L!==e?(z=Gt(),z===e&&(z=null),z!==e?(pe=Jr(),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 LN(){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=_N(),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 _N(){var T,I,k,L,z,pe;if(T=O,I=bv(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=bv(),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=bv(),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 bv(){var T,I,k,L;return T=O,I=Jr(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=Jr(),L!==e?(J=T,I=R(I,L),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function FN(){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=kN(),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 kN(){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;return T=O,I=Jr(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=Jr(),L!==e?(J=T,I=C(I,L),T=I):(O=T,T=e)):(O=T,T=e)):(O=T,T=e),T}function VN(){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=GN(),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 GN(){var T,I,k,L,z,pe;if(T=O,I=Jr(),I!==e){for(k=[],L=O,z=Gt(),z===e&&(z=null),z!==e?(pe=Jr(),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=Jr(),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,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=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,z,pe,il,Av,$p,Ev,eh,Cv;return T=O,I=Ow(),I!==e?(k=Gt(),k===e&&(k=null),k!==e?(L=Ow(),L!==e?(z=Gt(),z===e&&(z=null),z!==e?(pe=tl(),pe!==e?(il=Gt(),il!==e?(Av=Iw(),Av!==e?($p=Gt(),$p===e&&($p=null),$p!==e?(Ev=Iw(),Ev!==e?(eh=Gt(),eh===e&&(eh=null),eh!==e?(Cv=Jr(),Cv!==e?(J=T,I=K(I,L,pe,Av,Ev,Cv),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 Jr(){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 Ow(){var T,I;return T=O,I=Rw(),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=wv(),k===e&&(k=null),k!==e?(L=Rw(),L!==e?(k=[k,L],I=k):(O=I,I=e)):(O=I,I=e),I===e&&(I=O,k=wv(),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 Iw(){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=Dw(),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=Dw(),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 Dw(){var T;return n.charCodeAt(O)===44?(T=se,O++):(T=e,be===0&&Kt(oe)),T}function Rw(){var T,I,k,L;return T=O,I=O,k=jN(),k!==e?(L=Bw(),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=Bw(),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 Bw(){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=wv(),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 wv(){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 HN(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 Nw in Jp)Jp[Nw.toUpperCase()]=Jp[Nw];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))}a2.exports={SyntaxError:Ms,parse:OG}});var Lm=rh((rce,l2)=>{var Nm=s2().parse;Nm.parseSVG=Nm;Nm.makeAbsolute=IG;l2.exports=Nm;function IG(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 uN=rh((ije,dN)=>{dN.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 Q8,Loader as K8}from"three";import{Box3 as x_,BufferGeometry as S_,MeshBasicMaterial as w_}from"three";import{Matrix4 as g_,Mesh as v_}from"three";import{Matrix4 as gC,Vector3 as Wb,Euler as s_,MathUtils as gs,Quaternion as l_}from"three";var nf;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(nf||(nf={}));Si();ut();fr();var WE;(t=>{function n(e){return!0}t.is=n})(WE||(WE={}));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:xi.isEqual(i.position,o.position)?void 0:o.position,rotation:i.rotation===o.rotation?void 0:o.rotation,scale:xi.isEqual(i.scale,o.scale)?void 0:o.scale,shear:i.shear&&o.shear&&xi.isEqual(i.shear,o.shear)?void 0:o.shear})}r.diff=e})(sf||(sf={}));var Pb;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Pb||(Pb={}));var qE;(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})(qE||(qE={}));var lf;(t=>t.defaultData={opacity:1,fill:{color:Ue.fromHexAndA(or,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 So;(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})(So||(So={}));var Qd;(t=>t.defaultData={...sf.defaultData,...Pb.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 Mb;(t=>t.defaultData={...Cl.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Mb||(Mb={}));var Tl;(t=>t.defaultData={...Cl.defaultData,...cf.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Tl||(Tl={}));var Ob;(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"})(Ob||(Ob={}));var Ib;(t=>t.defaultData={...Cl.defaultData,type:"path2d",path:"",name:"Path"})(Ib||(Ib={}));var XE;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(XE||(XE={}));var Kd;(t=>t.defaultData={...Qd.defaultData,name:"Group",type:"group2d"})(Kd||(Kd={}));var Db;(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}}))(Db||(Db={}));var wo;(o=>{function n(a){switch(a){case"rectangle2d":return{...Tl.defaultData};case"ellipse2d":return{...Mb.defaultData};case"text2d":return{...Ob.defaultData};case"vector2d":return{...Tl.defaultData};case"path2d":return{...Ib.defaultData};case"frame2d":return{...Db.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})(wo||(wo={}));var df;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new bt},e.emptyData=function(){return{type:"scene2d",objects:new bt}}))(df||(df={}));SE();Tb();Sb();wb();ut();import{Box3 as F3,Line3 as k3,Matrix4 as Rb,Vector3 as wi}from"three";var ps=new wi,hs=new wi,ma=new Rb,QE=[new wi(-1,1,1),new wi(-1,-1,1),new wi(1,-1,1),new wi(1,1,1),new wi(-1,1,-1),new wi(-1,-1,-1),new wi(1,-1,-1),new wi(1,1,-1)],V3=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],G3=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],YE=(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 wi(ps.x,ps.y,ps.z).applyMatrix4(ma)):QE.forEach(r=>{e.push(r.clone().multiply(hs).add(ps).applyMatrix4(ma))})},Zd=class extends F3{constructor(){super(...arguments);this.matrix=new Rb;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 Rb().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 wi().applyMatrix4(ma));return}YE(s,r,o)}}),o.length===0&&o.push(...a)}else YE(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=QE.map(e=>e.clone().multiply(hs).applyMatrix4(ma))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=V3.map(([e,r])=>new k3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new wi))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=G3.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};ut();var U3=()=>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)||Z3&&"ontouchend"in document,H3=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,W3=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,q3=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},X3=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},Y3=()=>{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"},Bb=U3(),YQ=Bb?Y3():void 0,Q3=()=>{if(!(typeof window>"u"))return window.spline},K3=Q3(),QQ=!!K3?.isShellTabs,Z3=z3(),Pl=j3(),KQ=H3(),pi=W3(),Nb=q3(),KE=Number(X3());var sr=[];function ZE(){sr.splice(0,sr.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 JE(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 Ao(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)=>Ao(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)||!Ao(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)&&Ao(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 $E(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 J3=Array.isArray,Lb=J3;var ki={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}};function eu(n){return n?.isParticleSystem===!0}function Ol(n){return n?.isHairSystem===!0}function sn(n){return n?.isShapeBlendEntity===!0}function fs(n){return n?.isPathObject===!0}function Br(n){return n?.isObject2D===!0}function ei(n){return n?.isUIObject===!0}function _b(n){return n?.isCloner===!0}function tu(n){return n?.isClone===!0}function Il(n){return n?.isComponentObject===!0}var $3=new Set;function Oe(n){$3.add(n)}var eC=new Set;function Jt(n,t){let e=`${n}:${t}`;eC.has(e)||eC.add(e)}var rC=new Map,iC=new Map;function ms(n,t){rC.set(n,t)}function pf(n){return rC.get(n)}function Vi(n,t){iC.set(n,t)}function hf(n){return iC.get(n)}var nC=new Map;function ru(n,t){nC.set(n,t)}function ff(n){return nC.get(n)}var oC=null,tC=null;function aC(n){oC=n,tC!==null&&n.setHanaUIWasmUrl(tC)}function Fb(){return oC}import{Object3D as n_,Matrix4 as Co}from"three";import{Matrix4 as e_,Vector3 as Rl}from"three";var Rn=new Rl,Bn=new Rl,Eo=new Rl,Gi=new Rl,Ui=new Rl,Dl=new Rl,t_=new e_,yf=1e-12,mf=.01;function sC(n){let t=n.elements;Rn.set(t[0],t[1],t[2]),Bn.set(t[4],t[5],t[6]),Eo.set(t[8],t[9],t[10])}function r_(n,t){n.set(1,0,0).cross(t),n.lengthSq()<=yf&&n.set(0,1,0).cross(t),n.normalize()}function lC(){let n=Math.max(Rn.lengthSq(),Bn.lengthSq(),Eo.lengthSq());Rn.lengthSq()>yf*n?Gi.copy(Rn).normalize():Gi.set(1,0,0),Ui.crossVectors(Eo,Gi),Ui.lengthSq()<=yf*n&&(Ui.copy(Bn).addScaledVector(Gi,-Bn.dot(Gi)),Ui.lengthSq()<=yf*n&&r_(Ui,Gi)),Ui.normalize(),Dl.crossVectors(Gi,Ui)}function i_(){let n=Rn.length(),t=Bn.length(),e=Eo.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(Rn.dot(Bn))>i||Math.abs(Rn.dot(Eo))>i||Math.abs(Bn.dot(Eo))>i}function cC(n,t,e){return sC(n),lC(),t.makeBasis(Gi,Ui,Dl),e.set(Gi.dot(Rn),Gi.dot(Bn),Gi.dot(Eo),0,Ui.dot(Rn),Ui.dot(Bn),Ui.dot(Eo),0,Dl.dot(Rn),Dl.dot(Bn),Dl.dot(Eo),0,0,0,0,1),i_()}function kb(n){return sC(n),lC(),t_.makeBasis(Gi,Ui,Dl)}var Vb=new Co,To;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(To||(To={}));var Bl=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Co;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Co;this.pivotMatrix=new Co;this.matrixWorldRigid=new Co;this.shearScale=new Co;this.shearScaleInv=new Co}get __isSPEObject(){return!0}getPhysicsLocalMatrix(r){return this.rigidBody?.isDynamic()?(r.copy(this.matrixWorld),this.hasNonUniformScale&&r.multiply(this.shearScaleInv),this.parent&&r.premultiply(Vb.copy(this.parent.matrixWorld).invert()),r.premultiply(Vb.copy(this.hiddenMatrix).invert()),r.multiply(Vb.copy(this.pivotMatrix).invert()),!0):!1}isDescendantOf(r){r instanceof n_&&(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)To.is(o)&&o.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let a of this.children)To.is(a)&&a.traverseObject(r,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=cC(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 Co().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),o.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof Co?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 o_,CubicBezierCurve3 as Gb,Vector3 as jr}from"three";var zb=class extends o_{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 jr,vf=new jr,Nl=new jr,Ll=new jr,iu=new jr,Ub=new jr,nu=new jr,dC=new jr,uC=new jr;function pC(n,t,e){return ys.subVectors(t,n),vf.subVectors(t,e),ys.cross(vf).length()<=gf}var hC=new WeakMap;function bf(n){let t=hC.get(n.points);if(t!==void 0&&t.isClosed===n.isClosed)return t.curve;let e=a_(n);return hC.set(n.points,{isClosed:n.isClosed,curve:e}),e}function a_(n){let t=n.points,e=[t[0]],r=[new jr(...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 jr().copy(ys)),Nl.copy(ys));let i=t[t.length-1];e.push(i),r.push(new jr(...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 jr(...m.controlPrevious.position)),c.push(new jr(...m.controlNext.position))}let d=[];for(let f=0;f<a;f++){let m=f===s-1?0:f+1;d.push(pC(r[f],c[f],r[m])&&pC(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 jr().subVectors(r[b],y).normalize(),v=new jr().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 Gb(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 Gb(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;uC.copy(Ll).multiplyScalar(Math.sqrt(Math.pow(x,2)-Math.pow(S,2))).add(iu),Ub.copy(Ll).multiplyScalar(-x).add(uC);let v=y.distanceTo(Ub)/y.distanceTo(iu);nu.copy(m.prevDir).multiplyScalar(v*y.distanceTo(g)).add(y),dC.copy(nu).lerp(Ub,2);let w=g.clone().lerp(nu,4/3),A=b.clone().lerp(dC,4/3);p[2*f]=new Gb(g,w,A,b)}let h=new zb;for(let f=0;f<p.length;f++){let m=p[f];m&&h.add(m)}return h}var ke;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(ke||(ke={}));var Nn=n=>ke.is(n),c_={type:"completeState",isfromEntity:!0},d_=["x","y","z"],ou=new Wb,fC=new Wb(1,1,1),jb=new l_,Hb=new s_,u_=new Wb().set(0,1,0),mC=new gC,yC=new gC,_l=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)yo.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=yo.patch(this.data,a),yo.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=>{Nn(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)Nn(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)Nn(a)&&a.isConcreteEntity&&a.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let a of this.children)Nn(a)&&a.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Nn(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=>Nn(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*gs.RAD2DEG,this.rotation.y*gs.RAD2DEG,this.rotation.z*gs.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,d_[s]])??a)}updateTransformState(r,i){let o=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),o=!0),r.rotation&&(ou.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(gs.DEG2RAD),this.rotation.setFromVector3(ou),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(ou.fromArray(r.pivot).negate(),jb.setFromEuler(Hb.fromArray(r.pivotRotation.map(a=>a*gs.DEG2RAD))).invert(),fC);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=ou.setFromMatrixPosition(this.pivotMatrix);jb.setFromEuler(Hb.fromArray(r.pivotRotation.map(s=>s*gs.DEG2RAD))).invert(),this.pivotMatrix.compose(a,jb,fC)}}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,yo.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(wn.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 Mn.rootOverrideProps)p in r.props&&(u===void 0&&(u={}),u[p]=r.props[p]);u&&(d={...r,props:u})}else for(let u of Mn.rootOverrideProps)if(Ye(r.path,[u])){d=r;break}d!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let p=wn.filterOp(u.overrideData,d);p&&u.updateByOp(p,zt.applySimple(u.data,p),o,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let p=wn.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&&!rn.is(r.props.type)&&ki.changeEntityProptotype(this,i,o);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){ki.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=(o+a)%1;o+a===1&&u===0&&(u=1);let 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?mC.copy(this.parent.matrixWorld).invert():mC.identity();h.multiply(l.matrixWorld),p.applyMatrix4(h);let f={position:p.toArray(),rotation:c.rotation};if(s==="tangential"){let m=yC.extractRotation(l.matrixWorld),y=d.getTangentAt(u).applyMatrix4(m).add(p),g=yC.lookAt(p,y,u_),b=ou.setFromEuler(Hb.setFromRotationMatrix(g)).multiplyScalar(gs.RAD2DEG);f={...f,rotation:b.toArray()}}this.updateTransformState(f),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=>_b(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(ki.Cloner===null){Jt("cloners","a cloner");return}this.cloner=new ki.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 xC,Sphere as f_}from"three";import{BufferGeometry as p_,Float32BufferAttribute as qb,Uint32BufferAttribute as h_,Vector3 as vC}from"three";var bC=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"}})}},Xb=new h_([0,0,0],1);function xf(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 vC,m=new vC,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,gv=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 tn=0;tn<te;tn++){let Id=tn*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+tn,[0,1,2].forEach(Rr=>{he[ve*3+Rr]=Ka.getComponent(Rr),xe[ve*3+Rr]=Kt.getComponent(Rr)}),ae[ve*2]=+Ze,ae[ve*2+1]=tn/d),y.copy(N).multiplyScalar(ne),b.addVectors(g,y);for(let Rr=0;Rr<p;Rr++){let Dd=Rr*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=gv+Rr*te+tn,[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]=tn/d}}y.addVectors(g,D),ve=X+Be*te+tn,[0,1,2].forEach(Rr=>{he[ve*3+Rr]=y.getComponent(Rr),xe[ve*3+Rr]=N.getComponent(Rr)}),ae[ve*2]=(Ee+Be*we)/Te,ae[ve*2+1]=tn/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 qb(he,3)),this.setAttribute("normal",new qb(xe,3)),this.setAttribute("uv",new qb(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 Xb.array=new Uint32Array(o),Xb.count=o.length,Xb}};var Sf,wf=new Map,SC=0;function Af(){if(Sf===void 0)throw new Error("boolean-wasm is not loaded");return Sf}function Yb(n){let t=wf.get(n);if(t===void 0)throw new Error("Unknown csg mesh set handle "+n);return t}function Qb(n){return wf.set(++SC,n),SC}var m_={[0]:0,[1]:1,[2]:2};function y_(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;xf(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 wC(n,t,e){if(Sf===void 0)return-1;let{positions:r,indices:i,normals:o}=y_(n,t);return Qb(new Sf.CsgMesh(r,i,o))}function AC(n,t){let e=Af(),r=m_[t];if(r===void 0)throw new Error("Unknown boolean operation "+t);let i=n.map(Yb);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 EC(n,t,e,r){let i=Af(),o=AC(n,t),a=i.mesh_render_data(o,Math.max(r,0));if(e.setAttribute("position",new xC(a.positions(),3)),e.setAttribute("normal",new xC(a.normals(),3)),a.free(),e.boundingSphere===null&&(e.boundingSphere=new f_),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 Qb(o)}function CC(n,t){let e=Af(),r=AC(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 Ef(n,t){Yb(n).transform(new Float32Array(t.elements))}function Cf(n){let t=wf.get(n);t!==void 0&&(t.free(),wf.delete(n))}function TC(n,t){let e=Af();return Qb(e.instanced_union(Yb(n),t))}function vs(n){return n!==null&&"booleanOp"in n}var Fl=class extends _l(v_){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new g_}updateVisible(e){super.updateVisible(e),this.visible=!vs(this.parent)&&this.visible,vs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){vs(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Cf(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),vs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Fl&&(e.freeBooleanPointer(),vs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&vs(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),vs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var b_=null;function PC(){return b_}var Tf=new x_;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)}Tf.min.set(o,a,s),Tf.max.set(l,c,d),Tf.getCenter(r),Tf.getSize(i).multiplyScalar(.5)}var A_=new S_,E_=new w_,Je=class extends Fl{constructor(t,e){super(A_,E_),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){let r=PC();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 __,Vector3 as zi,InstancedMesh as F_,InstancedBufferAttribute as k_,PlaneGeometry as V_,Vector4 as lu,Quaternion as jC,TextureLoader as G_,Texture as HC,Euler as U_,MathUtils as nx}from"three";import{Vector3 as MC,FloatType as Zb,DataTexture as Jb,RGBAFormat as $b,Mesh as C_,Euler as gZ,Matrix4 as vZ}from"three";import{MeshSurfaceSampler as T_}from"three/examples/jsm/math/MeshSurfaceSampler.js";function OC(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 IC(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function DC(n,t){let e=new C_(n.geometry,n.material),r=[],i=[],o=new MC,a=new MC;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new T_(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 ex(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 Jb(r,t,t,$b,Zb);return i.needsUpdate=!0,i}function RC({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 Jb(t,n,n,$b,Zb);return e.needsUpdate=!0,e}function BC(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 Jb(t,n,n,$b,Zb);return e.needsUpdate=!0,e}var NC=`
|
|
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 xF(Ul,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,i,o){new mF().min.setScalar(0);let s=e.length-1,l=new AF;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 EF}from"three";var Pt=class extends EF{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 Mo=class extends Pt{};import{VideoTexture as OF,Texture as IF}from"three";var Ff=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 fx=class extends Ff{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},hx;function aT(n){return typeof n=="string"?n:(hx||(hx=new fx),hx.load(n))}var kf=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")}},Vf=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 CF,DataUtils as sT,HalfFloatType as TF,RGBAFormat as PF}from"three";import{HDRLoader as MF}from"three/examples/jsm/loaders/HDRLoader.js";function mx(n){return n.length>2&&n[0]===35&&n[1]===63}function lT(n){try{let t=new MF().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=>sT.toHalfFloat(Math.pow(Math.max(sT.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 cT(n){let t=new CF(n.data,n.width,n.height,PF,TF);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var DF=0,zl=class extends kf{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.instanceId=++DF;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?mx(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&&mx(i)?lT(i):null;o!==null&&(this.isHdr=!0,this.img=o,r())}else this.img=new Image,this.img.src=aT(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 OF(this.img,void 0,e,e):this.isHdr?(a=cT(this.img),a.wrapS=e,a.wrapT=e,a.magFilter=i,a.minFilter=r):a=new IF(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 Ai=class extends zl{};var dT=new Map;function uT(n){if(typeof n=="string")return n;let t=dT.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},dT.set(n,t)),t.url}var RF,pT=new Promise(n=>{RF=n});var hT;pT.then(n=>hT=n);var Oo=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:uT(t),format:"wav"},this.sound=new hT.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 fT=null;function mT(n){fT=n}function yT(){return fT}function yx(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 pV}from"three";import{BufferGeometry as LF,ConeGeometry as _F,Float32BufferAttribute as FF,MathUtils as kF}from"three";import{BufferAttribute as Gf,BufferGeometry as bT,CylinderGeometry as BF,Float32BufferAttribute as NF,MathUtils as gT,Vector2 as pu}from"three";var Uf=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=gT.clamp(i.thetaLength,0,360),i.hollow=gT.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 bT,f.setAttribute("position",new NF([],3))):u||h?f=new hu(c,d,r,i,o,a,s,l*Math.PI/180,u,u,p,h):f=new BF(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 vT(n){return new pu(n.y,-n.x)}var hu=class extends bT{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=vT(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=vT(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 Gf(ee.slice(0,re),1)),this.setAttribute("position",new Gf(me,3)),this.setAttribute("normal",new Gf(ce,3)),this.setAttribute("uv",new Gf(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 xT=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=kF.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 LF,p.setAttribute("position",new FF([],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 _F(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 VF,BufferAttribute as zf,BufferGeometry as GF,Vector3 as jf}from"three";var ST=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 VF(t,e,r,i,o,a):c=new vx(t,e,r,i,o,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},gx=Math.PI/2,vx=class extends GF{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*gx;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 jf(t/2,e/2,r/2);B.subScalar(s);let _=0;for(let F=0;F<=l;F++){let V=gx*(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+=gx/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 zf(b,1)),this.setAttribute("position",new zf(m,3)),this.setAttribute("normal",new zf(y,3)),this.setAttribute("uv",new zf(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 jf;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 jf,me=new jf;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 bx,BufferGeometry as UF,Triangle as zF,Vector3 as _n,Vector2 as xx}from"three";var va=class extends UF{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 bx(new Float32Array(s.subarray(0,d)),3)),this.setAttribute("normal",new bx(new Float32Array(l.subarray(0,d)),3)),this.setAttribute("uv",new bx(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 _n,y=m.clone(),g=new zF,b=o*i,x=i-b,S=a+1,v=new _n,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 _n().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 _n),te=A(a*Math.max(0,a-1)/2,()=>new _n),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 _n;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 _n,f=new _n,m=new _n,y=new _n,g=new xx,b=new xx,x=new xx,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 jF}from"three";var wT=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 jF(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 ek,Shape as FT,Vector2 as Io,Vector3 as tk,MathUtils as Px,LineCurve as gu,QuadraticBezierCurve as kT,CubicBezierCurve as Xf}from"three";import{CubicBezierCurve as Hf,EllipseCurve as HF,LineCurve as Wf,LineCurve3 as WF,MathUtils as qF,QuadraticBezierCurve as wx,SplineCurve as XF,Vector2 as Hr,Vector3 as CT}from"three";var mu=1e-12,jl=class{constructor(t){this.position=new Hr;this.startPosition=new Hr;this.uuid=qF.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 jl(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Hl=class extends jl{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Hl(this.parent).copy(this)}},ln=class extends jl{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Hl(this),new Hl(this))}static create(e,r){let i=new ln(e,new Hr(...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 ln(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 Hr,r=new Hr){let[i,o]=this.computeTangents();return i&&o&&(AT(i,e),AT(o,r)),[e,r]}computeTangent(e=new Hr){let[r,i]=this.computeTangents();return r&&i&&e.copy(r).add(i).normalize(),e}computeNormal(e=new Hr){let[r,i]=this.computeNormals();return e.copy(r).add(i).normalize(),e}};function AT(n,t=new Hr){let e=n.length();return t.set(-n.y/e,n.x/e)}var Ax=n=>n,Wl=new Hr,qf=new Hr,YF=new Hr,QF=new Hr,KF=new Hr,ZF=new Hr,TT=new CT,PT=new CT;function MT(n){let t=new Hr;t.addVectors(n.v0,Wl.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Hr;return e.addVectors(n.v2,qf.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Hf(n.v0,t,e,n.v2)}function yu(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function JF(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function $F(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Ex(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 OT(n,t,e){return ET(n,t)&&ET(t,e)&&Sx(n.position,t.position,e.position)}function Sx(n,t,e){return Wl.copy(t).sub(n).cross(qf.copy(e).sub(n))===0}function IT(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 DT(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function RT(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 Ex(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 Cx(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function ET(n,t){return Sx(n.position,n.controls[1].position,t.position)&&Sx(n.position,t.controls[0].position,t.position)}function BT(n,t,e,r,i=.5){let o=Wl.subVectors(t,n).multiplyScalar(i).add(n),a=qf.subVectors(e,t).multiplyScalar(i).add(t),s=YF.subVectors(r,e).multiplyScalar(i).add(e),l=o,c=QF.subVectors(a,o).multiplyScalar(i).add(o),d=KF.subVectors(s,a).multiplyScalar(i).add(a),u=s,p=ZF.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 NT(n,t,e=12,r=!0){let i=PT.set(0,0,0),o,a=0,s=[];for(let l=0;l<t.length;l++){let c=Ax(t[l]),d=Wl,u=ba(c,e);s.push(u);for(let p=0;p<=u;p++)if(c instanceof Hf||c instanceof wx||c instanceof Wf){if(c.getPoint(p/u,d),i.set(d.x,d.y,0),o!==void 0&&$F(o,i))continue;o===void 0&&(o=TT),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 LT(n,t,e,r=12,i=!0){let o=PT.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,d=Ax(t[l]),u=Wl,p=ba(d,r);s.push(p);for(let h=0;h<=p;h++)if(d instanceof Hf||d instanceof wx||d instanceof Wf){if(d.getPoint(h/p,u),o.set(u.x,u.y,0),c?.equals(o))continue;c===void 0?c=TT:(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 Tx(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 HF?t*2:n&&(n instanceof Wf||n instanceof WF)?1:n&&n instanceof XF?t*n.points.length:t}function _T(n,t,e=12,r=!0){let i,o=0;for(let a=0;a<t.length;a++){let s=Ax(t[a]),l=ba(s,e),c=Wl;for(let d=0;d<=l;d++)if(s instanceof Hf||s instanceof wx||s instanceof Wf){if(s.getPoint(d/l,c),i!==void 0&&JF(i,c,mu))continue;i===void 0&&(i=qf),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 Mx=new Io,rk=new Io,ik=new Io,nk=new Io,ok=new Io,ak=new Io,st=class extends FT{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new ek(new tk(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=Px.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=>ln.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=Mx.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=Px.generateUUID()){let o;e instanceof Io?o=e:o=new Io(e,r);let a=new ln(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 NT(e,i?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Tx(this.points,e,!1),this.roundedCurveDivisions=Tx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return LT(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),_T(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(Cx(o,a)){let u=o.position.distanceTo(a.position);return o.position.distanceTo(Mx.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){Cx(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&&OT(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,Mx),A=p.getPointAt(v,rk);this._subSplitCurve(u,h,S,w,void 0),this._subSplitCurve(p,f,v,void 0,A);let E;if(this.useCubicForRoundedCorners){let P=Ex(w,a.position,A)/2,M=Math.tan(P)*w.distanceTo(a.position),[R,D]=IT(w,A,M,ik,nk),N=DT(R,D,a.position),[C,B]=RT(N,w,A,M,ok,ak);E=new Xf(w.clone(),C.clone(),B.clone(),A.clone())}else E=new kT(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=BT(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 ln(Px.generateUUID(),new Io(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 Xf&&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 kT&&(a[l]=MT(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 Xf?(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 Xf?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 FT&&(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 Ix=Math.PI*2;function Ox({x:n,y:t},e,r,i,o){return{x:n*e+i,y:t*r+o}}function sk(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 VT(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 lk(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=VT(1,0,x,S),E=VT(x,S,v,w);return!c&&E>0&&(E-=Ix),c&&E<0&&(E+=Ix),{centerx:g,centery:b,ang1:A,ang2:E}}function GT({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=lk(n,t,e,r,i,o,c,d,a,s),{ang1:h,ang2:f}=p,{centerx:m,centery:y}=p,g=Math.abs(f)/(Ix/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(sk(h,f)),h+=f;return l.map(x=>{let{x:S,y:v}=Ox(x[0],i,o,m,y),{x:w,y:A}=Ox(x[1],i,o,m,y),{x:E,y:P}=Ox(x[2],i,o,m,y);return{x1:S,y1:v,x2:w,y2:A,x:E,y:P}})}import{BufferAttribute as Jf,BufferGeometry as bk}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}(),Yf=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}(),ql=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}(),UT=function(){function n(){var t=new ql,e=new vu,r=new Yf(0),i=new Yf(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 Yf(0),r=new Yf(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 ql,e=new ql,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 ql;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 ql;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}(),ck=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}(),Dx=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}(),HT=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),dk=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new HT,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 HT;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}(),uk=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 Dx;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 ql,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 Dx;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 Dx,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 dk(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 ck(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 UT,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 UT),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_(),uk.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 cn(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,uee=rt.NONZERO,pee=rt.POSITIVE,hee=rt.NEGATIVE,fee=rt.ABS_GEQ_TWO,mee=Xt.POLYGONS,yee=Xt.CONNECTED_POLYGONS,gee=Xt.BOUNDARY_CONTOURS;import{Box2 as yk,BufferAttribute as Zf,BufferGeometry as gk,Vector2 as vk}from"three";var Qf=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*Qf.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*Qf.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=Qf;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 Rx(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=fk(n),h=new Kf(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 Kf(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 Kf(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=hk(n,t,r),this.max=this.d+this.h*Math.SQRT2}function hk(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,mk(n,t,c,d))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function fk(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 Kf(e/t,r/t,0,n);return t===0||o.d<0?new Kf(i[0][0],i[0][1],0,n):o}function mk(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},Nx={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Lx={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},Bx=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),xa=class extends gk{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 yk().setFromPoints(e.points.map(D=>D.position)).getSize(new vk).length()*.1:u[0].length===0?h=i:i>0?h=Rx(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=cn({windingRule:s,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=Su}let m;try{m=cn({windingRule:rt.ODD,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...d]})}catch{m=Nx}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=cn({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=Bx(me,B);for(;!se.boundary.vertexIndices.filter(ce).length||!oe.boundary.vertexIndices.filter(ce).length;)me++,ce=Bx(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=Bx(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=cn({windingRule:W.length>1?rt.POSITIVE:rt.ODD,elementType:Xt.POLYGONS,vertexSize:2,strict:!0,contours:[Q.insetPoints,...w]})}catch{se=Lx}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 Zf(Uint32Array.from(v),1),E=new Zf(this._buffer.positions,3),P=new Zf(this._buffer.normals,3),M=new Zf(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 Xl=class extends bk{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=cn({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 Jf(new Float32Array(p*3),3),this._normalAttribute=new Jf(new Float32Array(p*3),3),this._uvAttribute=new Jf(new Float32Array(p*2),2),this._indexAttribute=new Jf(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 Xl(this._shape,this._curveSegments);return e.userData=ya(this.userData),e}};var Yl=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 Yl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ya(this.userData),e}};var hi=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 Xl(n.shape,i,{windingRule:a}):s=new Yl(n.shape,t,e,i,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as xk,Float32BufferAttribute as Sk,MathUtils as _x,Vector2 as qT}from"three";var XT=Math.PI*2,Kl=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=_x.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=wk(c,d,u,i*Math.PI/180,r,o);c.isClosed=!0,c.update();let h;return i===0?(h=new xk,h.setAttribute("position",new Sk([],3))):h=hi.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function wk(n,t,e,r,i,o){if(r>=XT)return i>30||i%4===0?(Ek(n,t,e,o),Math.round(i/4)):WT(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=GT({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?Ak(n,a.x,a.y,c,i,t,e,o):WT(n,r,i,t,e,o)}function Ak(n,t,e,r,i,o,a,s){let l=Math.round(i/r.length);n.addPoint(Ql(t,e));for(let c=0,d=r.length;c<d;c++){let u=r[c],p=n.points[c],h=Ql(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?YT(n,o,a,s):n.addPoint(Ql(0,0)),l}function WT(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(Ql(c,d))}return t<XT?o>0?YT(n,r,i,o):n.addPoint(Ql(0,0)):(n.removePoint(n.points[n.points.length-1]),o>0&&QT(n,r,i,o)),1}function Ek(n,t,e,r=0,i=0,o=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint($f(i-t,o,i-t,o-l,i-t,o+l)),n.addPoint($f(i,o+e,i-s,o+e,i+s,o+e)),n.addPoint($f(i+t,o,i+t,o+l,i+t,o-l)),n.addPoint($f(i,o-e,i+s,o-e,i-s,o-e)),r>0&&QT(n,t,e,r)}function Ql(n,t){return new ln(_x.generateUUID(),new qT(n,t))}function $f(n,t,e,r,i,o){let a=Ql(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(i,o),a}function YT(n,t,e,r){KT(n,t,e,r).forEach(o=>n.addPoint(o))}function QT(n,t,e,r){let i=KT(n,t,e,r),o=new st;i.forEach(a=>o.addPoint(a)),o.isClosed=!0,n.shapeHoles.push(o)}function KT(n,t,e,r){let i=r*t/100,o=i*(Math.abs(e)/Math.abs(t)),a=new qT(i/t,o/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=_x.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 Ck}from"three";var ZT=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 Ck(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 Tk,Shape as Pk}from"three";var JT=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 Pk;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 Tk(i.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as $T,BufferGeometryLoader as Rk,Vector3 as Bk,BoxGeometry as eP,Box3 as Nk}from"three";import{BufferAttribute as em,BufferGeometry as Mk}from"three";var Fx=1e4;function Zl(n,t){return Math.abs(t-n)/2+Math.min(n,t)}var tm=class{constructor(t=1){this.subdivisions=t}modify(t){let e=Ok(t),r=this.subdivisions;for(;r-- >0;)e=Ik(e);return Dk(e,t)}};function Ok(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*Fx),S=Math.round(g*Fx),v=Math.round(b*Fx),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 Ik(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=Zl(Z,Q),ve=Zl(te,se),me=Zl(Q,oe),ce=Zl(se,ne),X=Zl(Z,oe),ee=Zl(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 Dk(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 Mk;h.setAttribute("position",new em(d,3)),c>0&&(h.setAttribute("normal",new em(u,3)),h.setAttribute("color",new em(new Float32Array(c*3).fill(1),3))),p!==null&&h.setAttribute("uv",new em(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 br=new Bk,tP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new $T().copy(new eP(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(br),r={width:br.x,height:br.y,depth:br.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 $T().copy(new eP(100,100,100)),a=o.userData.parameters;a===void 0?(o.boundingBox=Lk(o),o.boundingBox.getSize(br)):br.set(a.width,a.height,a.depth),(t!==br.x||e!==br.y||r!==br.z)&&o.scale(br.x===0?1:t/br.x,br.y===0?1:e/br.y,br.z===0?1:r/br.z);let s=o.originalGeometry;try{i>0?(s===void 0||a?.subdivisions!==i)&&(s===void 0&&(s=o),o=new tm(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 Rk(e).load(n,i=>{let o=this.normalizeInputs({geometry:i});i.boundingBox.getSize(br);let a=100/br.x;Object.assign(o.parameters,{width:100,height:br.y*a,depth:br.z*a}),t(this.build(o))})}};function Lk(n){let t=new Nk,e=n.attributes.position;return e?(t.setFromBufferAttribute(e),t):(t.makeEmpty(),t)}var rm=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=hi.create({shape:l,parameters:{roundness:i,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as _k,Float32BufferAttribute as kx,Vector2 as Fn,Vector3 as mr}from"three";var rP=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 Gx(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 Fk=new mr,kk=new mr;function Vx(n,t,e,r,i,o){let a=Fk.copy(t).sub(n),s=kk.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 Vk(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var Gx=class extends _k{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 Fn(t,-h),w=new Fn(m,-h),A=new Fn(0,S.y).sub(w),E=new Fn(0,S.y).sub(v),P=new Fn(A.y,-A.x).normalize(),M=new Fn(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 Fn(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 Fn(Math.sin(se),Math.cos(se)),ve=new Fn(Math.sin(oe),Math.cos(oe)),me=new Fn(Math.sin(ne),Math.cos(ne));Au(v,de,G),Au(v,me,W),Au(P,ve,q),Vx(S,G,W,B,B,H),c.push(H.x,H.y,H.z),Vx(G,S,W,B,C,Z),c.push(Z.x,Z.y,Z.z),Vx(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=Vk(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 kx(c,3)),this.setAttribute("normal",new kx(d,3)),this.setAttribute("uv",new kx(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 Jl=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=hi.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as Gk,Float32BufferAttribute as Uk,MathUtils as iP,SphereGeometry as zk}from"three";var nP=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=iP.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 Gk,d.setAttribute("position",new Uk([],3))):d=new zk(.5*t,i,o,a,s,l,c*iP.DEG2RAD),d.scale(1,e/t,r/t),Object.assign(d,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as jk}from"three";var oP=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 jk(t,e,r,i);return o.scale(1,1,1),Object.assign(o,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as Hk,Float32BufferAttribute as Ux,Vector3 as Wk}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,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 zx(t,e,r,i,o,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},zx=class extends Hk{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 Wk(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 Ux(s,3)),this.setAttribute("normal",new Ux(l,3)),this.setAttribute("uv",new Ux(c,2))}};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,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=hi.create({shape:d,parameters:{roundness:o,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as qk}from"three";var sP=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 qk(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as Xk,Float32BufferAttribute as Yk,MathUtils as Qk}from"three";var lP=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=Kk(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 Kk(n,t,e,r,i,o,a,s,l,c,d){[t,e]=[e,t],a=t/2;let u=Qk.clamp(i/360,0,1);if(u===0){let p=new Xk;return p.setAttribute("position",new Yk([],3)),p}return u===1&&(c=0),new au(!0,n,t,e,r,u,o,a,s,l,c,d)}import{TorusKnotGeometry as Zk}from"three";var cP=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 Zk(s,e,r,i,o,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var dP=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=hi.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};fr();import{BufferAttribute as uP,BufferGeometry as jx}from"three";import{mergeGeometries as $k}from"three/examples/jsm/utils/BufferGeometryUtils.js";function pP(){let n=new jx;return n.setAttribute("position",new uP(new Float32Array([]),3)),n.setIndex(new uP(new Uint16Array([]),1)),n}var eV=pP().attributes,tV=12,rV=1,$l=class extends jx{constructor(e,r){super();this.isTextGeometry=!0;this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eV),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=ar.getDisplayedValue(d),h=u===2?p.toUpperCase():u===3?p.toLowerCase():p,f=iV(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=>hi.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?rt.NONZERO:rt.ODD,subdivisions:this.isLowResolution&&s>0?rV:tV}})),w=v.length?$k(v):pP();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=ir(new jx,$l.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 iV(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 Hx,BufferAttribute as yP,Uint32BufferAttribute as Wx,Float32BufferAttribute as sm,Matrix4 as aV,Vector3 as Cu,Sphere as sV,Box3 as lV,BoxGeometry as cV}from"three";var fP,om=new Promise(n=>{fP=n}),hP=!1;var nm;function mP(n){if(hP)return;if(nm)return nm;async function t(){let r=n??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.29/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});fP(c),hP=!0}return nm=t(),nm}import{Matrix4 as nV}from"three";var oV=new nV;function am(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=oV.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 lm=new lV,ec=new Cu,Pe;om.then(n=>{Pe=n});var gP=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),vP=new Uint32Array([0,1,2,3]),bP=new Uint8Array([4]),xt=class extends Hx{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=Ni.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(ec.fromArray(o));let s=ec.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 cV(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 sV,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;lm.setFromBufferAttribute(r),lm.getCenter(i),e.boundingSphere.radius=i.distanceTo(lm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),lm.getSize(ec);let o={width:ec.x,height:ec.y,depth:ec.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:gP,indexWASM:vP,verticesPerFaceWASM:bP},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:ji(e,i,!1,r),a;xf(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}=dV(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let i,o,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,o=e.indexWASM,a=e.verticesPerFaceWASM,Pe.alloc_subdivision_surface_uvs&&e.uvWASM&&e.uvWASM.length===o.length*2&&(l=e.uvWASM)):(i=gP,o=vP,a=bP);let c=i.length,d=o.length,u=a.length,p=i.length+s.length+l.length,h=o.length+a.length,f=p*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Pe._malloc(f),g=new Float32Array(Pe.HEAPF32.buffer,y,p),b=new Uint32Array(Pe.HEAPU32.buffer,y+m,h);g.set(i,0),g.set(s,i.length),g.set(l,i.length+s.length),b.set(o,0),b.set(a,o.length);let x;e?.scaleBaked?.some(w=>w!==1)&&(x=new aV().makeScale(...e.scaleBaked.map(w=>typeof w=="number"?w:1))),r&&(x?x.premultiply(r):x=r);let S=y+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,v=l.length?x?Pe.alloc_subdivision_surface_uvs2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length,x.elements):Pe.alloc_subdivision_surface_uvs(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length):x?Pe.alloc_subdivision_surface2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,x.elements):Pe.alloc_subdivision_surface(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u);return Pe._free(y),v}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 Hx;if(A.setIndex(new Wx(S,1)),A.setAttribute("position",new sm(f,3)),A.setAttribute("normal",new sm(y,3)),v&&A.setAttribute("uv",new sm(v,2)),r){A.setAttribute("faceMap",new Wx(b,1));let E=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new yP(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 Hx;f.setAttribute("position",new sm(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 yP(m,3)),f.setIndex(new Wx(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 dm(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 cm=new Cu,qx=new Cu,Xx=new Cu,Yx=new Cu;function dV(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]){cm.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]),Xx.set(n[t[u+4]*3],n[t[u+4]*3+1],n[t[u+4]*3+2]),Yx.set(n[t[u+5]*3],n[t[u+5]*3+1],n[t[u+5]*3+2]),qx.sub(cm).normalize(),Xx.sub(cm).normalize(),Yx.sub(cm).normalize();let p=qx.cross(Xx).dot(Yx),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 uV={ConeGeometry:xT,CubeGeometry:ST,CylinderGeometry:Uf,DodecahedronGeometry:wT,EllipseGeometry:Kl,HelixGeometry:bC,IcosahedronGeometry:ZT,LatheGeometry:JT,NonParametricGeometry:tP,PolygonGeometry:rm,PyramidGeometry:rP,RectangleGeometry:Jl,SphereGeometry:nP,PlaneGeometry:oP,BackdropGeometry:aP,StarGeometry:im,TextFrameGeometry:sP,TorusGeometry:lP,TorusKnotGeometry:cP,TriangleGeometry:dP,VectorGeometry:hi},um=n=>{let t=uV[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 hV=["font"];function ji(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];eb(u)&&!hV.includes(i)&&(d[i]=t.getVariable(u,[r.uuid,"geometry",...c,i]),eb(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 pV().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);Jt("text",`a ${o.type}`);let d=st.createFromState(ls.defaultData(),100,100);return um({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return Jl.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=um(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=um(s)}return l}var Qx=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 Qx{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let o=ji(e,r,this.flatShading,i);return o.computeBoundingSphere(),o}};var Jx="webgl",xP,Kx,SP=!1;function $x(){return Jx}function AP(n){Kx=n}function EP(){if(Jx==="webgpu"){if(xP!==void 0)return xP;SP||(SP=!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(Kx===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 Kx}function pm(n,t){return EP().createRootMaterial(n,t)}function e0(n,t,e){return EP().createSharedMaterial(n,t,e)}function t0(n){return n.getLayersOfType===void 0&&Object.assign(n,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),n}var wP,CP;function TP(n){CP=n}function PP(){let n=Jx==="webgpu"&&wP!==void 0?wP:CP;return n===void 0?null:t0(n())}var Zx;function MP(n){Zx=n}function OP(n,t){return Zx===void 0?!1:Zx(n,t)}var IP={markNeedsUpdateRendererDirty:()=>{}};function kn(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 Hi=(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 r0(n){let t=typeof n=="string"?n:n.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function dn(n){return typeof n=="string"||typeof n=="number"&&n!==0}var tc={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"]},DP={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};import{Object3D as fV}from"three";var i0=class extends Bl(fV){},mV=n=>n.type==="Mesh",lr=class extends i0{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 lr(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 mV(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 gV,MathUtils as o0,Matrix4 as vV,Quaternion as bV,Vector3 as UP}from"three";var RP=null,BP=null;function NP(n){RP=n}function n0(){return RP}function LP(n){BP=n}function _P(){return BP}function hm(n){return"variable_"+n}var FP=new vV,kP=new UP,VP=new bV,xV=new UP,GP=new gV,a0=class extends Vf{constructor(e){super();this.shared=e}create(e){return new zl(e,this.shared)}},s0=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 a0(this);this.thisContext={scene:IP,shared:this};this.deletedImage=new Ai(nf.emptyImage,this);this.deletedVideo=new Ai(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=e0(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=e0(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}),pm(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 Ai(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 Ai(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 Ai(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 Mo(e.r,e.g,e.b,e.a):this.colors[t]=new Mo(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 Oo)return e;{let r=new Oo({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 Oo&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=yT();if(r===null){Jt("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 Oo&&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(hm(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(hm(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*o0.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>s0.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 lr(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 Mo?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:kn(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=tc[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?.(FP))return FP.decompose(kP,VP,xV),t[1]==="position"?kP[t[2]]:(GP.setFromQuaternion(VP,r.rotation.order),GP[t[2]]*o0.RAD2DEG);for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=o0.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=_P();return r===null?(Jt("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=n0();return r===null?(Jt("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=n0();return r===null?(Jt("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=s0;Sa.MAX_TRANSIENT_VERTICES=6e4;var zP=new Sa($r.emptyData());function As(n){return n?.isClassicNodeMaterial===!0}function jP(n){return n?.isClassicSharedMaterial===!0}function fm(n){return As(n)||n?.isTSLNodeMaterial===!0}function HP(n){return jP(n)||n?.isTSLSharedMaterial===!0}ut();fr();var ri=5,rc=3;var er=class extends Je{setMaterialOverride(e,r){this.materialOverride=t0(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),Qw(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&&er.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=PP();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){fm(e)&&!HP(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&ih(this.material).forEach(e=>{er.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};import{BufferGeometry as mm,Matrix4 as c0,Vector3 as QP,Vector4 as d0}from"three";var WP=new QP,qP=new d0,XP=new d0,SV=new QP,YP=new c0,Qe=class extends er{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 c0().fromArray(r.bindMatrix),this.bindMatrixInverse=new c0)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof mm&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof mm?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}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=ji(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=ji(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&am(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&&dm(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 mm&&!(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=ji(d,a,this.data.flatShading,this);am(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 mm&&!(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=ji(o,i,this.data.flatShading,this);am(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 d0,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;qP.fromBufferAttribute(o.attributes.skinIndex,e),XP.fromBufferAttribute(o.attributes.skinWeight,e),WP.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=XP.getComponent(a);if(s!==0){let l=qP.getComponent(a);YP.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(SV.copy(WP).applyMatrix4(YP),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};import{Group as RV}from"three";import{AxesHelper as TV,Group as PV,Quaternion as MV,Vector3 as p0}from"three";import{BoxGeometry as wV}from"three";var Vn=n=>{var t;return t=class extends n{},t.geometryHelper=new wV(30,30,30),t};import{Ray as AV,Sphere as EV,Matrix4 as CV,Vector3 as Do}from"three";var ym=new AV,u0=new EV,KP=new CV,Gn=(n,t,e,r,i=!1,o=n)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),u0.copy(a.boundingSphere),u0.applyMatrix4(s),e.ray.intersectsSphere(u0)===!1||(KP.copy(s).invert(),ym.copy(e.ray).applyMatrix4(KP),a.boundingBox!==null&&ym.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,ym,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let x=a.attributes.position,S=new Do,v=new Do,w=new Do,A=new Do,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),ym.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 Do,M=new Do,R=new Do,D=new Do,N=new Do;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 OV=new p0(1,1,1),ZP=new p0,IV=new p0,JP=new MV,Wi=class extends Vn(TV){constructor(e,r=15){super(r);this.object=e;this.dummy=new PV;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){Gn(this.object,Wi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(ZP,JP,IV),this.matrix.compose(ZP,JP,OV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};import{Box3Helper as $P,BoxGeometry as DV}from"three";var gm;(t=>t.is=e=>"objectHelper"in e)(gm||(gm={}));var qi=(n,t)=>class extends _l(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 $P&&(o.visible=!0)}}updateEntityBoxSize(i,o){this.objectHelper.visible&&this.geometryHelper instanceof DV?(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 $P&&(o.visible=!1)}}};var nc=class extends qi(RV,Wi){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 BV=null;function eM(){return BV}var Pm=Bd(rM());import{Object3D as JV,Vector3 as Nr,Euler as Tm,MathUtils as bM,Matrix4 as qn,Quaternion as $V}from"three";var NV=.5*(Math.sqrt(3)-1),Mu=(3-Math.sqrt(3))/6,LV=1/3,Un=1/6,rae=(Math.sqrt(5)-1)/4,iae=(5-Math.sqrt(5))/20,Ou=n=>Math.floor(n)|0,iM=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]),f0=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 nM(n=Math.random){let t=aM(n),e=new Float64Array(t).map(i=>iM[i%12*2]),r=new Float64Array(t).map(i=>iM[i%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*NV,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 oM(n=Math.random){let t=aM(n),e=new Float64Array(t).map(o=>f0[o%12*3]),r=new Float64Array(t).map(o=>f0[o%12*3+1]),i=new Float64Array(t).map(o=>f0[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*LV,f=Ou(a+h),m=Ou(s+h),y=Ou(l+h),g=(f+m+y)*Un,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+Un,B=w-P+Un,_=A-M+Un,F=v-R+2*Un,V=w-D+2*Un,K=A-N+2*Un,q=v-1+3*Un,G=w-1+3*Un,W=A-1+3*Un,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 aM(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 _V}from"three";var un=new _V,vm=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;un.a.fromBufferAttribute(t,i),un.b.fromBufferAttribute(t,i+1),un.c.fromBufferAttribute(t,i+2),o*=un.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),un.a.fromBufferAttribute(this.positionAttribute,t*3),un.b.fromBufferAttribute(this.positionAttribute,t*3+1),un.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(un.a,i).addScaledVector(un.b,o).addScaledVector(un.c,1-(i+o)),un.getNormal(r),this}};import{Box3 as GV,Matrix4 as UV,Sphere as lM,Vector3 as zV}from"three";import{BufferAttribute as FV,Float32BufferAttribute as sM,MathUtils as m0,Vector3 as g0}from"three";function kV(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 g0(i[a],i[a+1],i[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new g0})}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 sM(o,3))}function VV(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 g0;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 sM(r,3))}function zn(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!As(n.material)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?VV(n):kV(n)}function y0(n){return Math.min(2047,Math.max(1,Math.round(n*2048)))/2048}function jn(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=[y0(m0.seededRandom(o)),y0(m0.seededRandom(o+1e4)),y0(m0.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)i[s]=a[s%3];n.geometry.setAttribute("randomColor",new FV(i,3))}var Hn=new GV,Iu=new zV;function cM(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Ro=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new UV;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,zn(this),jn(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,zn(this),jn(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 lM,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Hn.setFromBufferAttribute(r),Hn.getCenter(i),e.boundingSphere.radius=i.distanceTo(Hn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Hn.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;Hn.min.set(e[0],e[2],e[4]),Hn.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Hn.min.applyMatrix4(this.shearScaleInv),Hn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new lM);let i=r.boundingSphere.center;Hn.getCenter(i),r.boundingSphere.radius=i.distanceTo(Hn.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,zn(this),jn(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&&dm(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};import{Triangle as jV,Vector3 as Cs}from"three";var dM=-1,HV=1,uM={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},pM={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-dM)*(e-r)/(HV-dM)+r},WV=new Cs,bm=new Cs,qV=new Cs,XV=new Cs;function oc(n,t){let e=qV.fromArray(n),r=XV.fromArray(t);bm.copy(r).sub(e);let i=bm.length();return bm.normalize().multiplyScalar(i*.5),WV.copy(e).add(bm).toArray()}var Xi=new jV,xm=new Cs,Sm=new Cs,Es=new Cs;function hM(n){let t=[],e=Math.floor(n.index.count/3);for(let r=0;r<e;r++)if(xm.fromArray(n.index.array,r*3),Xi.setFromAttributeAndIndices(n.attributes.position,xm.x,xm.y,xm.z),Xi.getNormal(Sm),Xi.getMidpoint(Es),!(isNaN(Es.x)||isNaN(Es.y)||isNaN(Es.z))){let{a:i,b:o,c:a}=Xi,s=i.toArray(),l=o.toArray(),c=a.toArray(),d=i.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(i),h=oc(s,l),f=oc(l,c),m=oc(c,s),y=[d,u,p],g=Math.max(...y),b=y.filter(v=>Math.round(v)===Math.round(g)).length>1,x=[],S=Xi.getMidpoint(Es).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:Xi.getNormal(Sm).toArray()})}return t}function fM(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Xi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Xi.getNormal(Sm),Xi.getMidpoint(Es);let i=Xi.a.toArray(),o=Xi.b.toArray(),a=Xi.c.toArray();t.push({vertices:[i,o,a],faceCenters:[oc(i,o),oc(o,a),oc(a,i)],midpoint:Es.toArray(),norm:Sm.toArray()})}return t}import{InstancedMesh as YV,Matrix4 as v0}from"three";var b0=class extends YV{},wm=class extends b0{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new v0;this.pivotMatrix=new v0;this.previousModelViewMatrix=new v0;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 x0=n=>.5*(1-Math.cos(n*Math.PI)),S0=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=x0(s),u=x0(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+=x0(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()}},mM=S0;import{Vector3 as QV,Matrix4 as KV,Ray as ZV}from"three";var yM=new QV,gM=new KV,vM=new ZV,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)&&(gM.copy(i).invert(),vM.copy(e.ray).applyMatrix4(gM),vM.intersectBox(this.singleBBox,yM))){let o=yM.applyMatrix4(i),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var ii=1e-4,Wn,DM,RM,BM,xM=new Nr,SM=new Nr;om.then(n=>{Wn=n,DM=[Wn.get_face_center,Wn.get_edge_midpoint,Wn.get_vertex_position],RM=[Wn.get_face_normal,Wn.get_edge_normal,Wn.get_vertex_normal],BM=[Wn.face_count,Wn.edge_count,Wn.vertex_count]});var yse=new qn,eG=new qn,wM=new qn,AM=new qn,EM=new qn,CM=new qn,TM=new qn,PM=new qn,Aa=new Nr,Am=new Nr,Ru=new Nr,w0=new Nr,tG=new Nr,MM=new Nr,Em=new Nr,A0=new Nr,OM=new Nr,E0=new Nr,IM=new Nr,pn=new Tm,rG=new $V;function Cm(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 C0=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new mM;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=oM((0,Pm.default)(t.seed)):this.noise=nM((0,Pm.default)(t.seed??""))}},ni=class extends Bl(JV){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 lr&&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||sn(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 wm(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&&(wM.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),e.setMatrixAt(r++,wM));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 lr(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 C0(e,r)),this.random}_updateRadial(e,r){let i=e.radial,o=i.start*bM.DEG2RAD,a=i.end*bM.DEG2RAD,s=o-a,l=jt(i.rotation,r),c=new Tm(l[0],l[1],l[2]),d;switch(i.axis){case"z":d=new Nr(0,0,1);break;case"y":d=new Nr(0,1,0);break;default:case"x":d=new Nr(1,0,0);break}let u=e.randomnessObject??Cn.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]))||ii,w.scale.y=f[1]+S(P,je(E,y[1]))||ii,w.scale.z=f[2]+S(P,je(E,y[2]))||ii;let M=x*v-o;switch(i.axis){default:case"x":pn.set(0,M,0);break;case"y":pn.set(0,0,M);break;case"z":pn.set(M,0,0);break}Em.copy(d).applyQuaternion(rG.setFromEuler(pn)).multiplyScalar(i.radius),w.position.set(Em.x+(m[0]+S(P,je(E,g[0]))),Em.y+(m[1]+S(P,je(E,g[1]))),Em.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(pn.x+(c.x+R),pn.y+(c.y+D),pn.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 Tm(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Cn.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]))||ii,g.scale.y=1+(a[1]-1)*y+m(S,je(x,u[1]))||ii,g.scale.z=1+(a[2]-1)*y+m(S,je(x,u[2]))||ii,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??Cn.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 Nr(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]))||ii,S.scale.y=1+p(i,je(v,s[1]))||ii,S.scale.z=1+p(i,je(v,s[2]))||ii;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]))||ii,b.scale.y=1+p(i,je(x,s[1]))||ii,b.scale.z=1+p(i,je(x,s[2]))||ii;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 Tm(o[0],o[1],o[2]),c=e.randomnessObject??Cn.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,Pm.default)(this.object.uuid+i.seed)));let x=uM[i.axis],S=this.children;Aa.fromArray(x),AM.copy(this.object.hiddenMatrix).invert();let v=this.objectForSample instanceof Ro;v&&EM.copy(this.objectForSample.matrixWorld).invert(),i.align!=="normal"&&this.object.getWorldDirection(MM),E0.set(Aa.y,Aa.z,Aa.x).normalize(),IM.copy(E0).cross(Aa).normalize(),TM.makeBasis(E0,Aa,IM).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,w0):(y.length&&(Ru.fromArray(y[w].pos),w0.fromArray(y[w].norm)),v&&Ru.applyMatrix4(EM)),Ru.applyMatrix4(AM),A.position.copy(Ru);let C=i.align==="normal"?w0:MM,B=Am.fromArray(a);Am.x+=m(M,je(P,u[0])),Am.y+=m(M,je(P,u[1])),Am.z+=m(M,je(P,u[2]));let _=Math.acos(C.dot(Aa)),F=tG.crossVectors(Aa,C).normalize(),V=eG.makeRotationAxis(F,_);A0.copy(C).cross(this.object.up).normalize(),OM.copy(A0).cross(C).normalize(),CM.makeBasis(A0,C,OM),PM.multiplyMatrices(CM,TM),pn.setFromRotationMatrix(PM),B.applyMatrix4(V),A.position.add(B),A.rotation.set(pn.x+l.x+R,pn.y+l.y+D,pn.z+l.z+N),A.scale.set(1+s[0]+m(M,je(P,p[0]))||ii,1+s[1]+m(M,je(P,p[1]))||ii,1+s[2]+m(M,je(P,p[2]))||ii),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===Cm(i)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new vm(e).build();return this.surfaceSamplerCache={geometry:r,position:i,positionVersion:Cm(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 Ro,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===Cm(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=pM[e],d=BM[c],u=DM[c],p=RM[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);xM.fromArray(m).applyMatrix4(l.matrixWorld),SM.fromArray(y),a(xM.toArray(),SM.toArray())}}else(i.index?hM(i):fM(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:Cm(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 qn,this.hiddenMatrix=new qn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var hn=24,cr=96,Yn=oT(),Bo=2;var D0=!1,VM=!0;try{let n=new URLSearchParams(window.location.search);D0=n.get("dbgsbstatic")==="0",VM=n.get("sb512")!=="0"}catch{}function nG(n){let t=n.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var R0=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(cr);this._prevReach=new Float32Array(cr);this._fieldDirtyFull=!0;this._fieldDirtyMin=new lc;this._fieldDirtyMax=new lc;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 M0;this.potentialPassScene=new M0;this.voxelPassScene=new M0;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new LM,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new T0(Ul,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new I0(Yn.triTable,16,256,P0,No);o.needsUpdate=!0;let a=new I0(Yn.numTrisTable,256,1,P0,No);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new T0(Ul,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 T0(Ul,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 _M({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 Hx,BufferAttribute as yP,Uint32BufferAttribute as Wx,Float32BufferAttribute as sm,Matrix4 as aV,Vector3 as Cu,Sphere as sV,Box3 as lV,BoxGeometry as cV}from"three";var fP,om=new Promise(n=>{fP=n}),hP=!1;var nm;function mP(n){if(hP)return;if(nm)return nm;async function t(){let r=n??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.31/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});fP(c),hP=!0}return nm=t(),nm}import{Matrix4 as nV}from"three";var oV=new nV;function am(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=oV.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 lm=new lV,ec=new Cu,Pe;om.then(n=>{Pe=n});var gP=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),vP=new Uint32Array([0,1,2,3]),bP=new Uint8Array([4]),xt=class extends Hx{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=Ni.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(ec.fromArray(o));let s=ec.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 cV(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 sV,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;lm.setFromBufferAttribute(r),lm.getCenter(i),e.boundingSphere.radius=i.distanceTo(lm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),lm.getSize(ec);let o={width:ec.x,height:ec.y,depth:ec.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:gP,indexWASM:vP,verticesPerFaceWASM:bP},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:ji(e,i,!1,r),a;xf(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}=dV(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let i,o,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,o=e.indexWASM,a=e.verticesPerFaceWASM,Pe.alloc_subdivision_surface_uvs&&e.uvWASM&&e.uvWASM.length===o.length*2&&(l=e.uvWASM)):(i=gP,o=vP,a=bP);let c=i.length,d=o.length,u=a.length,p=i.length+s.length+l.length,h=o.length+a.length,f=p*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Pe._malloc(f),g=new Float32Array(Pe.HEAPF32.buffer,y,p),b=new Uint32Array(Pe.HEAPU32.buffer,y+m,h);g.set(i,0),g.set(s,i.length),g.set(l,i.length+s.length),b.set(o,0),b.set(a,o.length);let x;e?.scaleBaked?.some(w=>w!==1)&&(x=new aV().makeScale(...e.scaleBaked.map(w=>typeof w=="number"?w:1))),r&&(x?x.premultiply(r):x=r);let S=y+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,v=l.length?x?Pe.alloc_subdivision_surface_uvs2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length,x.elements):Pe.alloc_subdivision_surface_uvs(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length):x?Pe.alloc_subdivision_surface2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,x.elements):Pe.alloc_subdivision_surface(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u);return Pe._free(y),v}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 Hx;if(A.setIndex(new Wx(S,1)),A.setAttribute("position",new sm(f,3)),A.setAttribute("normal",new sm(y,3)),v&&A.setAttribute("uv",new sm(v,2)),r){A.setAttribute("faceMap",new Wx(b,1));let E=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new yP(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 Hx;f.setAttribute("position",new sm(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 yP(m,3)),f.setIndex(new Wx(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 dm(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 cm=new Cu,qx=new Cu,Xx=new Cu,Yx=new Cu;function dV(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]){cm.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]),Xx.set(n[t[u+4]*3],n[t[u+4]*3+1],n[t[u+4]*3+2]),Yx.set(n[t[u+5]*3],n[t[u+5]*3+1],n[t[u+5]*3+2]),qx.sub(cm).normalize(),Xx.sub(cm).normalize(),Yx.sub(cm).normalize();let p=qx.cross(Xx).dot(Yx),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 uV={ConeGeometry:xT,CubeGeometry:ST,CylinderGeometry:Uf,DodecahedronGeometry:wT,EllipseGeometry:Kl,HelixGeometry:bC,IcosahedronGeometry:ZT,LatheGeometry:JT,NonParametricGeometry:tP,PolygonGeometry:rm,PyramidGeometry:rP,RectangleGeometry:Jl,SphereGeometry:nP,PlaneGeometry:oP,BackdropGeometry:aP,StarGeometry:im,TextFrameGeometry:sP,TorusGeometry:lP,TorusKnotGeometry:cP,TriangleGeometry:dP,VectorGeometry:hi},um=n=>{let t=uV[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 hV=["font"];function ji(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];eb(u)&&!hV.includes(i)&&(d[i]=t.getVariable(u,[r.uuid,"geometry",...c,i]),eb(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 pV().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);Jt("text",`a ${o.type}`);let d=st.createFromState(ls.defaultData(),100,100);return um({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return Jl.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=um(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=um(s)}return l}var Qx=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 Qx{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let o=ji(e,r,this.flatShading,i);return o.computeBoundingSphere(),o}};var Jx="webgl",xP,Kx,SP=!1;function $x(){return Jx}function AP(n){Kx=n}function EP(){if(Jx==="webgpu"){if(xP!==void 0)return xP;SP||(SP=!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(Kx===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 Kx}function pm(n,t){return EP().createRootMaterial(n,t)}function e0(n,t,e){return EP().createSharedMaterial(n,t,e)}function t0(n){return n.getLayersOfType===void 0&&Object.assign(n,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),n}var wP,CP;function TP(n){CP=n}function PP(){let n=Jx==="webgpu"&&wP!==void 0?wP:CP;return n===void 0?null:t0(n())}var Zx;function MP(n){Zx=n}function OP(n,t){return Zx===void 0?!1:Zx(n,t)}var IP={markNeedsUpdateRendererDirty:()=>{}};function kn(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 Hi=(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 r0(n){let t=typeof n=="string"?n:n.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function dn(n){return typeof n=="string"||typeof n=="number"&&n!==0}var tc={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"]},DP={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};import{Object3D as fV}from"three";var i0=class extends Bl(fV){},mV=n=>n.type==="Mesh",lr=class extends i0{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 lr(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 mV(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 gV,MathUtils as o0,Matrix4 as vV,Quaternion as bV,Vector3 as UP}from"three";var RP=null,BP=null;function NP(n){RP=n}function n0(){return RP}function LP(n){BP=n}function _P(){return BP}function hm(n){return"variable_"+n}var FP=new vV,kP=new UP,VP=new bV,xV=new UP,GP=new gV,a0=class extends Vf{constructor(e){super();this.shared=e}create(e){return new zl(e,this.shared)}},s0=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 a0(this);this.thisContext={scene:IP,shared:this};this.deletedImage=new Ai(nf.emptyImage,this);this.deletedVideo=new Ai(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=e0(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=e0(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}),pm(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 Ai(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 Ai(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 Ai(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 Mo(e.r,e.g,e.b,e.a):this.colors[t]=new Mo(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 Oo)return e;{let r=new Oo({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 Oo&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=yT();if(r===null){Jt("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 Oo&&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(hm(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(hm(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*o0.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>s0.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 lr(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 Mo?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:kn(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=tc[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?.(FP))return FP.decompose(kP,VP,xV),t[1]==="position"?kP[t[2]]:(GP.setFromQuaternion(VP,r.rotation.order),GP[t[2]]*o0.RAD2DEG);for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=o0.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=_P();return r===null?(Jt("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=n0();return r===null?(Jt("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=n0();return r===null?(Jt("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=s0;Sa.MAX_TRANSIENT_VERTICES=6e4;var zP=new Sa($r.emptyData());function As(n){return n?.isClassicNodeMaterial===!0}function jP(n){return n?.isClassicSharedMaterial===!0}function fm(n){return As(n)||n?.isTSLNodeMaterial===!0}function HP(n){return jP(n)||n?.isTSLSharedMaterial===!0}ut();fr();var ri=5,rc=3;var er=class extends Je{setMaterialOverride(e,r){this.materialOverride=t0(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),Qw(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&&er.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=PP();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){fm(e)&&!HP(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&ih(this.material).forEach(e=>{er.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};import{BufferGeometry as mm,Matrix4 as c0,Vector3 as QP,Vector4 as d0}from"three";var WP=new QP,qP=new d0,XP=new d0,SV=new QP,YP=new c0,Qe=class extends er{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 c0().fromArray(r.bindMatrix),this.bindMatrixInverse=new c0)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof mm&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof mm?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=ji(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=ji(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&am(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&&dm(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 mm&&!(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=ji(d,a,this.data.flatShading,this);am(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 mm&&!(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=ji(o,i,this.data.flatShading,this);am(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 d0,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;qP.fromBufferAttribute(o.attributes.skinIndex,e),XP.fromBufferAttribute(o.attributes.skinWeight,e),WP.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=XP.getComponent(a);if(s!==0){let l=qP.getComponent(a);YP.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(SV.copy(WP).applyMatrix4(YP),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};import{Group as RV}from"three";import{AxesHelper as TV,Group as PV,Quaternion as MV,Vector3 as p0}from"three";import{BoxGeometry as wV}from"three";var Vn=n=>{var t;return t=class extends n{},t.geometryHelper=new wV(30,30,30),t};import{Ray as AV,Sphere as EV,Matrix4 as CV,Vector3 as Do}from"three";var ym=new AV,u0=new EV,KP=new CV,Gn=(n,t,e,r,i=!1,o=n)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),u0.copy(a.boundingSphere),u0.applyMatrix4(s),e.ray.intersectsSphere(u0)===!1||(KP.copy(s).invert(),ym.copy(e.ray).applyMatrix4(KP),a.boundingBox!==null&&ym.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,ym,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let x=a.attributes.position,S=new Do,v=new Do,w=new Do,A=new Do,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),ym.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 Do,M=new Do,R=new Do,D=new Do,N=new Do;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 OV=new p0(1,1,1),ZP=new p0,IV=new p0,JP=new MV,Wi=class extends Vn(TV){constructor(e,r=15){super(r);this.object=e;this.dummy=new PV;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){Gn(this.object,Wi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(ZP,JP,IV),this.matrix.compose(ZP,JP,OV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};import{Box3Helper as $P,BoxGeometry as DV}from"three";var gm;(t=>t.is=e=>"objectHelper"in e)(gm||(gm={}));var qi=(n,t)=>class extends _l(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 $P&&(o.visible=!0)}}updateEntityBoxSize(i,o){this.objectHelper.visible&&this.geometryHelper instanceof DV?(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 $P&&(o.visible=!1)}}};var nc=class extends qi(RV,Wi){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 BV=null;function eM(){return BV}var Pm=Bd(rM());import{Object3D as JV,Vector3 as Nr,Euler as Tm,MathUtils as bM,Matrix4 as qn,Quaternion as $V}from"three";var NV=.5*(Math.sqrt(3)-1),Mu=(3-Math.sqrt(3))/6,LV=1/3,Un=1/6,rae=(Math.sqrt(5)-1)/4,iae=(5-Math.sqrt(5))/20,Ou=n=>Math.floor(n)|0,iM=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]),f0=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 nM(n=Math.random){let t=aM(n),e=new Float64Array(t).map(i=>iM[i%12*2]),r=new Float64Array(t).map(i=>iM[i%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*NV,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 oM(n=Math.random){let t=aM(n),e=new Float64Array(t).map(o=>f0[o%12*3]),r=new Float64Array(t).map(o=>f0[o%12*3+1]),i=new Float64Array(t).map(o=>f0[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*LV,f=Ou(a+h),m=Ou(s+h),y=Ou(l+h),g=(f+m+y)*Un,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+Un,B=w-P+Un,_=A-M+Un,F=v-R+2*Un,V=w-D+2*Un,K=A-N+2*Un,q=v-1+3*Un,G=w-1+3*Un,W=A-1+3*Un,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 aM(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 _V}from"three";var un=new _V,vm=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;un.a.fromBufferAttribute(t,i),un.b.fromBufferAttribute(t,i+1),un.c.fromBufferAttribute(t,i+2),o*=un.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),un.a.fromBufferAttribute(this.positionAttribute,t*3),un.b.fromBufferAttribute(this.positionAttribute,t*3+1),un.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(un.a,i).addScaledVector(un.b,o).addScaledVector(un.c,1-(i+o)),un.getNormal(r),this}};import{Box3 as GV,Matrix4 as UV,Sphere as lM,Vector3 as zV}from"three";import{BufferAttribute as FV,Float32BufferAttribute as sM,MathUtils as m0,Vector3 as g0}from"three";function kV(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 g0(i[a],i[a+1],i[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new g0})}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 sM(o,3))}function VV(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 g0;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 sM(r,3))}function zn(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!As(n.material)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?VV(n):kV(n)}function y0(n){return Math.min(2047,Math.max(1,Math.round(n*2048)))/2048}function jn(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=[y0(m0.seededRandom(o)),y0(m0.seededRandom(o+1e4)),y0(m0.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)i[s]=a[s%3];n.geometry.setAttribute("randomColor",new FV(i,3))}var Hn=new GV,Iu=new zV;function cM(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Ro=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new UV;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,zn(this),jn(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,zn(this),jn(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 lM,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Hn.setFromBufferAttribute(r),Hn.getCenter(i),e.boundingSphere.radius=i.distanceTo(Hn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Hn.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;Hn.min.set(e[0],e[2],e[4]),Hn.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Hn.min.applyMatrix4(this.shearScaleInv),Hn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new lM);let i=r.boundingSphere.center;Hn.getCenter(i),r.boundingSphere.radius=i.distanceTo(Hn.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,zn(this),jn(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&&dm(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};import{Triangle as jV,Vector3 as Cs}from"three";var dM=-1,HV=1,uM={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},pM={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-dM)*(e-r)/(HV-dM)+r},WV=new Cs,bm=new Cs,qV=new Cs,XV=new Cs;function oc(n,t){let e=qV.fromArray(n),r=XV.fromArray(t);bm.copy(r).sub(e);let i=bm.length();return bm.normalize().multiplyScalar(i*.5),WV.copy(e).add(bm).toArray()}var Xi=new jV,xm=new Cs,Sm=new Cs,Es=new Cs;function hM(n){let t=[],e=Math.floor(n.index.count/3);for(let r=0;r<e;r++)if(xm.fromArray(n.index.array,r*3),Xi.setFromAttributeAndIndices(n.attributes.position,xm.x,xm.y,xm.z),Xi.getNormal(Sm),Xi.getMidpoint(Es),!(isNaN(Es.x)||isNaN(Es.y)||isNaN(Es.z))){let{a:i,b:o,c:a}=Xi,s=i.toArray(),l=o.toArray(),c=a.toArray(),d=i.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(i),h=oc(s,l),f=oc(l,c),m=oc(c,s),y=[d,u,p],g=Math.max(...y),b=y.filter(v=>Math.round(v)===Math.round(g)).length>1,x=[],S=Xi.getMidpoint(Es).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:Xi.getNormal(Sm).toArray()})}return t}function fM(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Xi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Xi.getNormal(Sm),Xi.getMidpoint(Es);let i=Xi.a.toArray(),o=Xi.b.toArray(),a=Xi.c.toArray();t.push({vertices:[i,o,a],faceCenters:[oc(i,o),oc(o,a),oc(a,i)],midpoint:Es.toArray(),norm:Sm.toArray()})}return t}import{InstancedMesh as YV,Matrix4 as v0}from"three";var b0=class extends YV{},wm=class extends b0{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new v0;this.pivotMatrix=new v0;this.previousModelViewMatrix=new v0;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 x0=n=>.5*(1-Math.cos(n*Math.PI)),S0=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=x0(s),u=x0(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+=x0(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()}},mM=S0;import{Vector3 as QV,Matrix4 as KV,Ray as ZV}from"three";var yM=new QV,gM=new KV,vM=new ZV,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)&&(gM.copy(i).invert(),vM.copy(e.ray).applyMatrix4(gM),vM.intersectBox(this.singleBBox,yM))){let o=yM.applyMatrix4(i),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var ii=1e-4,Wn,DM,RM,BM,xM=new Nr,SM=new Nr;om.then(n=>{Wn=n,DM=[Wn.get_face_center,Wn.get_edge_midpoint,Wn.get_vertex_position],RM=[Wn.get_face_normal,Wn.get_edge_normal,Wn.get_vertex_normal],BM=[Wn.face_count,Wn.edge_count,Wn.vertex_count]});var yse=new qn,eG=new qn,wM=new qn,AM=new qn,EM=new qn,CM=new qn,TM=new qn,PM=new qn,Aa=new Nr,Am=new Nr,Ru=new Nr,w0=new Nr,tG=new Nr,MM=new Nr,Em=new Nr,A0=new Nr,OM=new Nr,E0=new Nr,IM=new Nr,pn=new Tm,rG=new $V;function Cm(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 C0=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new mM;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=oM((0,Pm.default)(t.seed)):this.noise=nM((0,Pm.default)(t.seed??""))}},ni=class extends Bl(JV){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 lr&&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||sn(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 wm(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&&(wM.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),e.setMatrixAt(r++,wM));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 lr(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 C0(e,r)),this.random}_updateRadial(e,r){let i=e.radial,o=i.start*bM.DEG2RAD,a=i.end*bM.DEG2RAD,s=o-a,l=jt(i.rotation,r),c=new Tm(l[0],l[1],l[2]),d;switch(i.axis){case"z":d=new Nr(0,0,1);break;case"y":d=new Nr(0,1,0);break;default:case"x":d=new Nr(1,0,0);break}let u=e.randomnessObject??Cn.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]))||ii,w.scale.y=f[1]+S(P,je(E,y[1]))||ii,w.scale.z=f[2]+S(P,je(E,y[2]))||ii;let M=x*v-o;switch(i.axis){default:case"x":pn.set(0,M,0);break;case"y":pn.set(0,0,M);break;case"z":pn.set(M,0,0);break}Em.copy(d).applyQuaternion(rG.setFromEuler(pn)).multiplyScalar(i.radius),w.position.set(Em.x+(m[0]+S(P,je(E,g[0]))),Em.y+(m[1]+S(P,je(E,g[1]))),Em.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(pn.x+(c.x+R),pn.y+(c.y+D),pn.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 Tm(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Cn.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]))||ii,g.scale.y=1+(a[1]-1)*y+m(S,je(x,u[1]))||ii,g.scale.z=1+(a[2]-1)*y+m(S,je(x,u[2]))||ii,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??Cn.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 Nr(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]))||ii,S.scale.y=1+p(i,je(v,s[1]))||ii,S.scale.z=1+p(i,je(v,s[2]))||ii;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]))||ii,b.scale.y=1+p(i,je(x,s[1]))||ii,b.scale.z=1+p(i,je(x,s[2]))||ii;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 Tm(o[0],o[1],o[2]),c=e.randomnessObject??Cn.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,Pm.default)(this.object.uuid+i.seed)));let x=uM[i.axis],S=this.children;Aa.fromArray(x),AM.copy(this.object.hiddenMatrix).invert();let v=this.objectForSample instanceof Ro;v&&EM.copy(this.objectForSample.matrixWorld).invert(),i.align!=="normal"&&this.object.getWorldDirection(MM),E0.set(Aa.y,Aa.z,Aa.x).normalize(),IM.copy(E0).cross(Aa).normalize(),TM.makeBasis(E0,Aa,IM).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,w0):(y.length&&(Ru.fromArray(y[w].pos),w0.fromArray(y[w].norm)),v&&Ru.applyMatrix4(EM)),Ru.applyMatrix4(AM),A.position.copy(Ru);let C=i.align==="normal"?w0:MM,B=Am.fromArray(a);Am.x+=m(M,je(P,u[0])),Am.y+=m(M,je(P,u[1])),Am.z+=m(M,je(P,u[2]));let _=Math.acos(C.dot(Aa)),F=tG.crossVectors(Aa,C).normalize(),V=eG.makeRotationAxis(F,_);A0.copy(C).cross(this.object.up).normalize(),OM.copy(A0).cross(C).normalize(),CM.makeBasis(A0,C,OM),PM.multiplyMatrices(CM,TM),pn.setFromRotationMatrix(PM),B.applyMatrix4(V),A.position.add(B),A.rotation.set(pn.x+l.x+R,pn.y+l.y+D,pn.z+l.z+N),A.scale.set(1+s[0]+m(M,je(P,p[0]))||ii,1+s[1]+m(M,je(P,p[1]))||ii,1+s[2]+m(M,je(P,p[2]))||ii),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===Cm(i)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new vm(e).build();return this.surfaceSamplerCache={geometry:r,position:i,positionVersion:Cm(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 Ro,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===Cm(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=pM[e],d=BM[c],u=DM[c],p=RM[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);xM.fromArray(m).applyMatrix4(l.matrixWorld),SM.fromArray(y),a(xM.toArray(),SM.toArray())}}else(i.index?hM(i):fM(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:Cm(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 qn,this.hiddenMatrix=new qn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var hn=24,cr=96,Yn=oT(),Bo=2;var D0=!1,VM=!0;try{let n=new URLSearchParams(window.location.search);D0=n.get("dbgsbstatic")==="0",VM=n.get("sb512")!=="0"}catch{}function nG(n){let t=n.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var R0=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(cr);this._prevReach=new Float32Array(cr);this._fieldDirtyFull=!0;this._fieldDirtyMin=new lc;this._fieldDirtyMax=new lc;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 M0;this.potentialPassScene=new M0;this.voxelPassScene=new M0;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new LM,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new T0(Ul,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new I0(Yn.triTable,16,256,P0,No);o.needsUpdate=!0;let a=new I0(Yn.numTrisTable,256,1,P0,No);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new T0(Ul,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 T0(Ul,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 _M({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 O0(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(),eM()?.release(this)}},Nu=R0;Nu.streamCompaction=new _f;var oG=new FM,aG=new FM,ac=new kM,Ts=new lc,Mm=new lc,sG=new kM;function lG(n,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];To.is(r)&&GM.call(r,n,t+1)}}function GM(n,t=0){if(n(this,t)!==!0){let r=this.children.length;for(;r--;){let i=this.children[r];To.is(i)&&GM.call(i,n,t+1)}}}function cG(){if(this.shapesDataTexture.value===void 0){let y=new I0(new Float32Array(4*cr*Po),cr,Po,sc,No);this.shapesDataTexture.value=y}let n=this.shapesDataTexture.value,t=n.image.data,e=0,r=0,i=this.data.geometry.blendRange,o=oG.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(lG.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof ni)return;if(y instanceof nc||eu(y))return;y instanceof lr?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(aG.multiplyMatrices(o,y.matrixWorld).decompose(Mm,ac,Ts),x?.type==="TorusGeometry"&&x.arc!==360){let C=x.arc*Math.PI/180;C=C/4,ac.multiply(sG.set(0,0,Math.sin(C),Math.cos(C)))}let w=S.overrideGlobalBlend?S.blendRange:i;w=w/this.bboxSize*2,t[s*4]=(Mm.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Mm.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Mm.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[cr*4+s*4]=-ac.x,t[cr*4+s*4+1]=-ac.y,t[cr*4+s*4+2]=-ac.z,t[cr*4+s*4+3]=ac.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])*Ts.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*Ts.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)*Ts.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[cr*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*Ts.x/this.bboxSize+w}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=nG(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[cr*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*Ts.x+w}t.set(A,cr*8+s*4),e=Math.max(e,P),r=Math.max(r,w),this._reach[s]=P,t[cr*12+s*4]=w,t[cr*12+s*4+1]=E/this.bboxSize*2,t[cr*12+s*4+2]=Ts.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[cr*16+s*4]=D.r,t[cr*16+s*4+1]=D.g,t[cr*16+s*4+2]=D.b,t[cr*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||D0,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<Po;R++){let D=cr*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 D0&&(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}Vi("ShapeBlendGeometry",(n,t,e)=>new Nu(n,t,e));Oe("shape-blends");var Om=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)}};Vi("VectorGeometry",(n,t,e)=>new Om(n,t,e));Oe("vector-shapes");var Im=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=Jl;break;case"Ellipse":o=Kl;break;case"Polygon":o=rm;break;case"Star":o=im;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 dG,Vector3 as dr,Matrix3 as uG,Matrix4 as Ps,BufferGeometry as XM,BufferAttribute as Qn,MathUtils as Dm}from"three";function UM(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var pG=new Ps,hG=new Ps,fG=new Ps,zM=new dr,jM=new dr,HM=new dr,mG=new dr,yG=new dr,gG=new dr,vG=new dr,WM=new WeakMap,B0=new WeakMap,qM=new WeakMap;function bG(n,t,e){let r=[new dr,new dr,new dr],i=[new dr,new dr,new dr];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=Dm.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new Ps().makeBasis(r[0],r[1],r[2])}function YM(n){n.setIndex(null),n.setAttribute("position",new Qn(new Float32Array(0),3)),n.setAttribute("normal",new Qn(new Float32Array(0),3)),n.setAttribute("uv",new Qn(new Float32Array(0),2)),n.setDrawRange(0,0)}var QM=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??Kl.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 N0(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else{let e=new XM;return YM(e),Object.assign(e,{userData:{...n,type:"PathGeometry"}})}}},N0=class extends XM{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)||!UM(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){YM(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]=bG(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=qM.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),qM.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 Qn(F.positions,3)),this.setAttribute("normal",new Qn(F.normals,3)),this.setAttribute("uv",new Qn(F.uvs,2)),this._setIndexFromUint32(G);let te=pG;te.copy(u[u.length-1]).setPosition(d[d.length-1]),this.applyMatrix4OnRange(te,_,B),te.copy(u[0]).setPosition(d[0]).multiply(hG.makeScale(1,1,-1)),this.applyMatrix4OnRange(te,_-E,_),this.reverseIndicesOnRange(H,Z)}else this.setAttribute("position",new Qn(F.positions,3)),this.setAttribute("normal",new Qn(F.normals,3)),this.setAttribute("uv",new Qn(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 Qn(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=bf(e),i=WM.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},WM.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 dr,s=new dr,l=new dr,c=new dr,d=new dr(0,1,0);for(let y=0;y<i;y++){let g=e[y],b;y===0?b=o?e[e.length-2]:zM.copy(g).multiplyScalar(2).sub(e[1]):b=e[y-1];let x;y===i-1?x=o?e[1]:zM.copy(g).multiplyScalar(2).sub(e[y-1]):x=e[y+1],jM.subVectors(g,b).normalize(),HM.subVectors(x,g).normalize();let S=mG.addVectors(jM,HM).normalize();l.copy(S),y===0&&(S.equals(d)||yG.copy(S).negate().equals(d))&&d.set(0,0,1);let v=gG.crossVectors(d,S).normalize(),w=vG.crossVectors(S,v).normalize();d.copy(w),c.copy(v),y===0&&(a.copy(w),s.copy(S));let A=new Ps().makeBasis(v,w,S);r.push(A)}let u=o?s:l,p=o?a:new dr(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(fG.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 Ps,u=new Ps;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(Dm.lerp(a,a+s,f)*Dm.DEG2RAD);let m=Dm.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=B0.get(i);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},B0.set(i,o)),o.shapePoints}_getSurfaceTesselation(e){let r=B0.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let i;try{i=cn({windingRule:rt.ODD,elementType:Xt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{i=Lx}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=cn({windingRule:r,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=Su}let l;try{l=cn({windingRule:rt.ODD,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Nx}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 dr(0,0,c?-1:1).applyMatrix4(s),p=new dr,h=new dG;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 uG().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}}};Vi("PathGeometry",(n,t,e)=>new Im(n,t,e));ru("PathGeometry",QM);Oe("3d-paths");ki.Cloner=ni;Oe("cloners");ut();import{Group as xG,Matrix4 as SG,Skeleton as wG}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 qi(xG,Wi){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 Mn.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]=wn.apply(i.data[s],e[s]));return this.overrideData=a,o}else return{...Zt.defaultData,...e,...Jd(Zt.defaultData,Mn.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 Mn.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&&Mn.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={};ZM(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 SG().fromArray(m)),f=new wG(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function KM(n,t,e,r){return n.component===t&&Ao(n.identity,r)?n.overrideData===e?2:1:0}function ZM(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=KM(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=KM(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?wn.apply(d.data,p):d.data;rn.is(m.type)&&(m={...m,type:"Empty"}),h=ki.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,ZM(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 JM=(n,t,e)=>new _u(n,t,e);ms("Component",JM);ms("Instance",JM);Oe("components");var L0=1e-10;function $M(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>L0?t/o:1,s=o>L0?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)>L0?d/c:0,0]}}function e2({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:_}=$M([[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]=e2({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 AG(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 r2=[[-1,1],[-1,-1],[1,-1],[1,1]],t2=(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)):r2.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&&t2(a,e,i)}):t2(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=r2.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(AG(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 EG='{"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":{}}',i2=()=>JSON.parse(EG);async function CG(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,i2(),!0)}}var Rm,Fu;function TG(n){Rm=n}function _0(){if(!Fu){if(!Rm)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));Fu=Rm(),Fu.catch(()=>{Fu=void 0})}return Fu}var n2;function PG(){let n=typeof process<"u"?"2.0.29":void 0;return`https://cdn.spline.design/@splinetool/runtime${n?`@${n}`:""}/build/hana-ui.wasm`}function o2(n){n2=n}function Bm(){return Rm||TG(async()=>{let t=await import("./hana-ui.js");return CG(t,n2??PG())}),_0().then(()=>{})}var _m=Bd(Lm(),1);function c2(n){let t=[],e;try{e=(0,_m.makeAbsolute)((0,_m.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,DG(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 DG(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 km=.5522847498307936,NG=150,LG=5*60*1e3,_G=(2728+680)/2816,FG=1536/2816;function kG(n){try{let t=new DataView(n),e=t.getUint32(0);if(e!==65536&&e!==1330926671&&e!==1953658213)return;let r=t.getUint16(4),i=-1,o=-1;for(let c=0;c<r;c++){let d=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 d2=!1;function u2(){d2||(d2=!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 Vm=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._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 _0(),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>LG){clearInterval(o);return}r()&&(clearInterval(o),t())},NG)})}_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);let r=kG(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))}))}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(...c2(t))}rect(t,e,r,i,o=0,a=0,s=0,l=0){if(!f2([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,m2(this._pathEls,c)}ellipse(t,e,r,i,o,a,s,l){if(!!f2([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,zG(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?cc(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(Fm(l,0));if(p==="skip")return;let h=ku(p)??l,f=null;if(u){let g=this._applyClips(Fm(u,0));f=g==="skip"?null:ku(g)??u}let m=[];m2(m,h),f&&UG(m,f);let y={shape:{Custom:m},color:cc(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"?Fm(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:cc(this._strokeColor),align:VG[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:cc(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:cc(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=GG(r);if(!h)return r;if(!p){u2();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){u2();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=Fm({x:F,y:V,w:K,h:q,radii:de},0)}return r}drawText(t,e){let r=this._fontXPerEm.get(e.font),i=r?r/FG:1,o={TextSimple:{text:t,font_size:e.fontSize*_G*i,size:[e.width,e.height],horizontal_align:p2[e.horizontalAlign]??"Left",vertical_align:h2[e.verticalAlign]??"Top"}},a=this._effectChain(!0),s=this._fillColor.a>0,l=this._strokeColor.a>0&&this._lineWidth>0;if(s||l||a){let c=De.append(this._ctm,De.translate(De.identity(),e.x,e.y));if(this._applyClips(o,c)!=="skip"){let d={shape:o,color:s?cc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(c)};l&&(d.stroke=this._strokeDesc()),a&&(d.effect_chain=a),this._shapes.push(d)}}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:p2[e.horizontalAlign]??"Left",verticalAlign:h2[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 O0(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(),eM()?.release(this)}},Nu=R0;Nu.streamCompaction=new _f;var oG=new FM,aG=new FM,ac=new kM,Ts=new lc,Mm=new lc,sG=new kM;function lG(n,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];To.is(r)&&GM.call(r,n,t+1)}}function GM(n,t=0){if(n(this,t)!==!0){let r=this.children.length;for(;r--;){let i=this.children[r];To.is(i)&&GM.call(i,n,t+1)}}}function cG(){if(this.shapesDataTexture.value===void 0){let y=new I0(new Float32Array(4*cr*Po),cr,Po,sc,No);this.shapesDataTexture.value=y}let n=this.shapesDataTexture.value,t=n.image.data,e=0,r=0,i=this.data.geometry.blendRange,o=oG.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(lG.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof ni)return;if(y instanceof nc||eu(y))return;y instanceof lr?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(aG.multiplyMatrices(o,y.matrixWorld).decompose(Mm,ac,Ts),x?.type==="TorusGeometry"&&x.arc!==360){let C=x.arc*Math.PI/180;C=C/4,ac.multiply(sG.set(0,0,Math.sin(C),Math.cos(C)))}let w=S.overrideGlobalBlend?S.blendRange:i;w=w/this.bboxSize*2,t[s*4]=(Mm.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Mm.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Mm.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[cr*4+s*4]=-ac.x,t[cr*4+s*4+1]=-ac.y,t[cr*4+s*4+2]=-ac.z,t[cr*4+s*4+3]=ac.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])*Ts.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*Ts.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)*Ts.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[cr*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*Ts.x/this.bboxSize+w}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=nG(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[cr*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*Ts.x+w}t.set(A,cr*8+s*4),e=Math.max(e,P),r=Math.max(r,w),this._reach[s]=P,t[cr*12+s*4]=w,t[cr*12+s*4+1]=E/this.bboxSize*2,t[cr*12+s*4+2]=Ts.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[cr*16+s*4]=D.r,t[cr*16+s*4+1]=D.g,t[cr*16+s*4+2]=D.b,t[cr*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||D0,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<Po;R++){let D=cr*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 D0&&(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}Vi("ShapeBlendGeometry",(n,t,e)=>new Nu(n,t,e));Oe("shape-blends");var Om=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)}};Vi("VectorGeometry",(n,t,e)=>new Om(n,t,e));Oe("vector-shapes");var Im=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=Jl;break;case"Ellipse":o=Kl;break;case"Polygon":o=rm;break;case"Star":o=im;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 dG,Vector3 as dr,Matrix3 as uG,Matrix4 as Ps,BufferGeometry as XM,BufferAttribute as Qn,MathUtils as Dm}from"three";function UM(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var pG=new Ps,hG=new Ps,fG=new Ps,zM=new dr,jM=new dr,HM=new dr,mG=new dr,yG=new dr,gG=new dr,vG=new dr,WM=new WeakMap,B0=new WeakMap,qM=new WeakMap;function bG(n,t,e){let r=[new dr,new dr,new dr],i=[new dr,new dr,new dr];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=Dm.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new Ps().makeBasis(r[0],r[1],r[2])}function YM(n){n.setIndex(null),n.setAttribute("position",new Qn(new Float32Array(0),3)),n.setAttribute("normal",new Qn(new Float32Array(0),3)),n.setAttribute("uv",new Qn(new Float32Array(0),2)),n.setDrawRange(0,0)}var QM=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??Kl.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 N0(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else{let e=new XM;return YM(e),Object.assign(e,{userData:{...n,type:"PathGeometry"}})}}},N0=class extends XM{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)||!UM(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){YM(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]=bG(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=qM.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),qM.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 Qn(F.positions,3)),this.setAttribute("normal",new Qn(F.normals,3)),this.setAttribute("uv",new Qn(F.uvs,2)),this._setIndexFromUint32(G);let te=pG;te.copy(u[u.length-1]).setPosition(d[d.length-1]),this.applyMatrix4OnRange(te,_,B),te.copy(u[0]).setPosition(d[0]).multiply(hG.makeScale(1,1,-1)),this.applyMatrix4OnRange(te,_-E,_),this.reverseIndicesOnRange(H,Z)}else this.setAttribute("position",new Qn(F.positions,3)),this.setAttribute("normal",new Qn(F.normals,3)),this.setAttribute("uv",new Qn(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 Qn(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=bf(e),i=WM.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},WM.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 dr,s=new dr,l=new dr,c=new dr,d=new dr(0,1,0);for(let y=0;y<i;y++){let g=e[y],b;y===0?b=o?e[e.length-2]:zM.copy(g).multiplyScalar(2).sub(e[1]):b=e[y-1];let x;y===i-1?x=o?e[1]:zM.copy(g).multiplyScalar(2).sub(e[y-1]):x=e[y+1],jM.subVectors(g,b).normalize(),HM.subVectors(x,g).normalize();let S=mG.addVectors(jM,HM).normalize();l.copy(S),y===0&&(S.equals(d)||yG.copy(S).negate().equals(d))&&d.set(0,0,1);let v=gG.crossVectors(d,S).normalize(),w=vG.crossVectors(S,v).normalize();d.copy(w),c.copy(v),y===0&&(a.copy(w),s.copy(S));let A=new Ps().makeBasis(v,w,S);r.push(A)}let u=o?s:l,p=o?a:new dr(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(fG.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 Ps,u=new Ps;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(Dm.lerp(a,a+s,f)*Dm.DEG2RAD);let m=Dm.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=B0.get(i);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},B0.set(i,o)),o.shapePoints}_getSurfaceTesselation(e){let r=B0.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let i;try{i=cn({windingRule:rt.ODD,elementType:Xt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{i=Lx}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=cn({windingRule:r,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=Su}let l;try{l=cn({windingRule:rt.ODD,elementType:Xt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Nx}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 dr(0,0,c?-1:1).applyMatrix4(s),p=new dr,h=new dG;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 uG().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}}};Vi("PathGeometry",(n,t,e)=>new Im(n,t,e));ru("PathGeometry",QM);Oe("3d-paths");ki.Cloner=ni;Oe("cloners");ut();import{Group as xG,Matrix4 as SG,Skeleton as wG}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 qi(xG,Wi){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 Mn.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]=wn.apply(i.data[s],e[s]));return this.overrideData=a,o}else return{...Zt.defaultData,...e,...Jd(Zt.defaultData,Mn.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 Mn.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&&Mn.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={};ZM(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 SG().fromArray(m)),f=new wG(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function KM(n,t,e,r){return n.component===t&&Ao(n.identity,r)?n.overrideData===e?2:1:0}function ZM(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=KM(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=KM(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?wn.apply(d.data,p):d.data;rn.is(m.type)&&(m={...m,type:"Empty"}),h=ki.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,ZM(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 JM=(n,t,e)=>new _u(n,t,e);ms("Component",JM);ms("Instance",JM);Oe("components");var L0=1e-10;function $M(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>L0?t/o:1,s=o>L0?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)>L0?d/c:0,0]}}function e2({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:_}=$M([[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]=e2({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 AG(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 r2=[[-1,1],[-1,-1],[1,-1],[1,1]],t2=(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)):r2.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&&t2(a,e,i)}):t2(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=r2.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(AG(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 EG='{"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":{}}',i2=()=>JSON.parse(EG);async function CG(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,i2(),!0)}}var Rm,Fu;function TG(n){Rm=n}function _0(){if(!Fu){if(!Rm)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));Fu=Rm(),Fu.catch(()=>{Fu=void 0})}return Fu}var n2;function PG(){let n=typeof process<"u"?"2.0.31":void 0;return`https://cdn.spline.design/@splinetool/runtime${n?`@${n}`:""}/build/hana-ui.wasm`}function o2(n){n2=n}function Bm(){return Rm||TG(async()=>{let t=await import("./hana-ui.js");return CG(t,n2??PG())}),_0().then(()=>{})}var _m=Bd(Lm(),1);function c2(n){let t=[],e;try{e=(0,_m.makeAbsolute)((0,_m.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,DG(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 DG(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 km=.5522847498307936,NG=150,LG=5*60*1e3,_G=(2728+680)/2816,FG=1536/2816;function kG(n){try{let t=new DataView(n),e=t.getUint32(0);if(e!==65536&&e!==1330926671&&e!==1953658213)return;let r=t.getUint16(4),i=-1,o=-1;for(let c=0;c<r;c++){let d=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 d2=!1;function u2(){d2||(d2=!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 Vm=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._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 _0(),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>LG){clearInterval(o);return}r()&&(clearInterval(o),t())},NG)})}_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);let r=kG(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))}))}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(...c2(t))}rect(t,e,r,i,o=0,a=0,s=0,l=0){if(!f2([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,m2(this._pathEls,c)}ellipse(t,e,r,i,o,a,s,l){if(!!f2([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,zG(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?cc(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(Fm(l,0));if(p==="skip")return;let h=ku(p)??l,f=null;if(u){let g=this._applyClips(Fm(u,0));f=g==="skip"?null:ku(g)??u}let m=[];m2(m,h),f&&UG(m,f);let y={shape:{Custom:m},color:cc(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"?Fm(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:cc(this._strokeColor),align:VG[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:cc(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:cc(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=GG(r);if(!h)return r;if(!p){u2();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){u2();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=Fm({x:F,y:V,w:K,h:q,radii:de},0)}return r}drawText(t,e){let r=this._fontXPerEm.get(e.font),i=r?r/FG:1,o={TextSimple:{text:t,font_size:e.fontSize*_G*i,size:[e.width,e.height],horizontal_align:p2[e.horizontalAlign]??"Left",vertical_align:h2[e.verticalAlign]??"Top"}},a=this._effectChain(!0),s=this._fillColor.a>0,l=this._strokeColor.a>0&&this._lineWidth>0;if(s||l||a){let c=De.append(this._ctm,De.translate(De.identity(),e.x,e.y));if(this._applyClips(o,c)!=="skip"){let d={shape:o,color:s?cc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(c)};l&&(d.stroke=this._strokeDesc()),a&&(d.effect_chain=a),this._shapes.push(d)}}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:p2[e.horizontalAlign]??"Left",verticalAlign:h2[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())}},VG={inside:"Inside",outside:"Outside",center:"Center"},p2={[1]:"Left",[2]:"Right",[3]:"Center",[4]:"Justify"},h2={[1]:"Top",[2]:"Center",[3]:"Bottom"};function cc({r:n,g:t,b:e,a:r}){return[n,t,e,r]}function f2(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function Fm(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 GG(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 m2(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-km;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 UG(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-km;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 zG(n,t,e,r,i){let o=r*km,a=i*km;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 y2(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 jG=Math.PI/180,bce=180/Math.PI;function g2(n,t,e,r,i,o){let a=n-e,s=t-r;return a*a/(i*i)+s*s/(o*o)<=1}function v2(n){return n*jG}ut();function Lo(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 _o=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=Lo();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,v2(this.rotation),wo.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 wo.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,So.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)So.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=So.patch(this.data,i),So.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 _o(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 _o&&(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 Gm=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 Um=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 _o{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Gm(e+"-fill",r.fill,i),this.stroke=new Um(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 g2(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 Yi=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 Yi(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 dc=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=>zm.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};zm.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 dc(this.uuid,this.data,e);return r.parent=void 0,r}},zm;(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=F0.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})(zm||(zm={}));var F0;(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=k0.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})(F0||(F0={}));var k0;(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})(k0||(k0={}));var oi=class extends _o{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 oi&&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 oi?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 oi&&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 oi&&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 oi(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}},fi=class extends oi{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 fi(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};ut();var Lr=class extends oi{constructor(e,r,i){super(e,r,i);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Yi(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 Lr(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};var b2=Bd(Lm(),1),jm=new Map,HG=4096,uc=null;function WG(n){let t=jm.get(n);if(t!==void 0)return t;if(uc===null||!uc.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",uc=document.createElementNS("http://www.w3.org/2000/svg","path"),r.appendChild(uc),document.body.appendChild(r)}uc.setAttribute("d",n);let e=uc.getBBox();return jm.size>=HG&&jm.clear(),jm.set(n,e),e}var Fo=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;x2(this.path)&&(console.warn("Invalid SVG path",this.uuid),e=""),this._pathBBox=WG(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 Fo(this.uuid,this.data,e);return r.parent=void 0,r}};function x2(n){return/NaN/.test(n)}function S2(n,t=1,e=1){if(t<=0||e<=0)return n;if(x2(n))return console.warn("Cannot scale invalid path",n),Hm([]);if(t===1&&e===1)return n;try{let i=(0,b2.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 Hm(i)}catch(r){return console.warn("Error parsing SVG path",r),Hm([])}}function Hm(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 w2(n,t,e){switch(t.type){case"ellipse2d":return new Ca(n,t,e);case"rectangle2d":return new Yi(n,t,e);case"text2d":return new Ta(n,t,e);case"vector2d":return new dc(n,t,e);case"path2d":return new Fo(n,t,e);case"frame2d":return new Lr(n,t,e);case"group2d":default:return new fi(n,t,e)}}fr();var V0=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new fi(V0.GROUP_ID,{...Kd.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,i,o,a){let s=w2(t,e,a);s&&(i.add(s),i.children.splice(o,0,i.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof fi||s instanceof Lr)&&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 oi&&(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 oi){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 oi||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)}},Os=V0;Os.GROUP_ID="scene2d";function G0({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 qG=Bd(Lm(),1);var wue={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 QG,CanvasTexture as KG,Float32BufferAttribute as C2,HalfFloatType as ZG,MathUtils as JG,Mesh as $G,OrthographicCamera as eU,ShaderMaterial as tU,Uniform as rU,WebGLRenderTarget as iU}from"three";var XG=new Set;function A2(n){XG.add(n)}function U0(n,t,e,r){return r?e:2048/Math.max(1,n,t)}function E2(n,t,e,r){let i=U0(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 nU=`
|
|
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 qm,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=CU(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 CU(n){if(n.length){let t=n[0];if(t instanceof wU)return t.v1;if(t instanceof SU||t instanceof AU)return t.v0}}Vi("TextGeometry",(n,t,e)=>new wa(n,t,e));var B2={create:(n,t)=>new $l(n,t)};ru("TextGeometry",B2);ru("InputGeometry",B2);mT(Ym);Oe("text");var N2=200,TU=null;function L2(n){TU=n}var zu=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},_2=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return PU(Math.atan2(r,e))},F2=(n,t,e)=>{let r={x:0,y:0};return e=Km(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Km=n=>n*(Math.PI/180),PU=n=>n*(180/Math.PI),k2=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,Qm=new Map,V2=n=>{Qm.has(n)&&clearTimeout(Qm.get(n)),Qm.set(n,setTimeout(function(){Qm.delete(n),n()},100))},hc=(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)},fc=(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 Zm=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),Q0=()=>{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}},Jm=(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")},$m=(n,t,e)=>{let r=U2(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},G2=(n,t)=>{let e=U2(n);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},U2=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},ey=(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"&&(H2="ontouchstart"in window,W2=!!window.PointerEvent,q2=!!window.MSPointerEvent);var H2,W2,q2,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"}},mc,Wu={};W2?mc=Hu.pointer:q2?mc=Hu.MSPointer:H2?(mc=Hu.touch,Wu=Hu.mouse):mc=Hu.mouse;function Ds(){}Ds.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};Ds.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};Ds.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)})};Ds.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=z2(t.options,n))};Ds.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.')},hc(n,mc[t],e._domHandlers_[t]),Wu[t]&&hc(n,Wu[t],e._domHandlers_[t]),e};Ds.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},fc(n,mc[t],e._domHandlers_[t]),Wu[t]&&fc(n,Wu[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var yc=Ds;function xr(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=xr.id,xr.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}xr.prototype=new yc;xr.constructor=xr;xr.id=0;xr.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)};xr.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=G2("borderRadius","50%"),e=$m("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)"},ey(r.el,e),this.options.shape==="circle"&&ey(r.back,t),ey(r.front,t),this.applyStyles(r),this};xr.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};xr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};xr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};xr.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};xr.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};xr.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};xr.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=$m("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)};xr.prototype.restCallback=function(){var n=this,t={};t.front=$m("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};xr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};xr.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 X2=xr;function ur(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=ur.id,ur.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}ur.prototype=new yc;ur.constructor=ur;ur.id=0;ur.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}};ur.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};ur.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)}};ur.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 X2(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||(Jm(c.ui.el,i),Jm(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};ur.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};ur.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)};ur.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)};ur.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=Zm(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};ur.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};ur.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)};ur.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(!k2(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=_2(l,i.position),u=Km(d),p=c/s,h={distance:c,position:l},f,m;if(i.options.shape==="circle"?(f=Math.min(c,s),m=F2(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||Jm(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:Km(180-d),degree:180-d},i.trigger("move",b),t.trigger("move "+i.id+":move",b)};ur.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))};ur.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()};ur.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 Y2=ur;function yr(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Q0(),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(){V2(e)},t._onScroll=function(){t.scroll=Q0()},t.collections}yr.prototype=new yc;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,hc(window,"resize",n._onResize),hc(window,"scroll",n._onScroll))};yr.prototype.unbindWindowEvents=function(){var n=this;!n._windowBound||typeof window>"u"||(n._windowBound=!1,fc(window,"resize",n._onResize),fc(window,"scroll",n._onScroll))};yr.prototype.createCollection=function(n){var t=this,e=new Y2(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=Zm(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 Q2=yr;var gc=null;function K2(){return gc||(gc=new Q2),gc}var MU={create:function(n){return K2().create(n)},destroy:function(){gc&&(gc.destroy(),gc=null)},get factory(){return K2()}},Z2=MU;import{Box3 as qU,Euler as Sc,EventDispatcher as XU,Line3 as fO,MathUtils as Pa,Matrix4 as Jn,Quaternion as qr,Vector2 as YU,Vector3 as Fe}from"three";import{Camera as _U,OrthographicCamera as FU,PerspectiveCamera as kU,Vector3 as mn,Object3D as $2,Quaternion as VU,Matrix4 as Rs}from"three";import{Camera as DU,LineSegments as RU,BufferGeometry as BU,LineBasicMaterial as NU,Color as K0,Vector3 as LU,Float32BufferAttribute as J2}from"three";var ry=new LU,Qi=new DU,Z0=class extends RU{constructor(e){let r=new BU,i=new NU({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new K0(15711266),c=new K0(15711266),d=new K0(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 J2(o,3)),r.setAttribute("color",new J2(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;Qi.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;fn("n1",r,e,Qi,-o,-a,s),fn("n2",r,e,Qi,o,-a,s),fn("n3",r,e,Qi,-o,a,s),fn("n4",r,e,Qi,o,a,s);let l=s;fn("f1",r,e,Qi,-o,-a,l),fn("f2",r,e,Qi,o,-a,l),fn("f3",r,e,Qi,-o,a,l),fn("f4",r,e,Qi,o,a,l);let c=l,d=.5;fn("u1",r,e,Qi,o*.7*d,a*1.1,c),fn("u2",r,e,Qi,-o*.7*d,a*1.1,c),fn("u3",r,e,Qi,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function fn(n,t,e,r,i,o,a){ry.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],ry.x,ry.y,ry.z)}}var iy=class extends Vn(Z0){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){Gn(this.object,this.geometry,e,r,!0)}};var ny=790;function eO(n){return 1-Math.pow(1-n,3)}var vc=new mn,J0=new mn,$0=new VU,eS=new mn,qu=new mn,tS=new mn,Kn=class extends qi(_U,iy){constructor(e="",r={...ds.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=nn.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=Kn.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new Rs,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,o=this.height;this.orthoCamera=new FU(i*-.5,i*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new kU(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=Kn.projectionTransitionsEnabled;Kn.projectionTransitionsEnabled=!1;try{return e()}finally{Kn.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 mn(e,r,i)),super.lookAt(e),this.getWorldPosition(vc),this.targetOffset=vc.distanceTo(e)}getTarget(e=new mn){return this.getWorldDirection(J0),this.getWorldPosition(vc),J0.multiplyScalar(this.targetOffset),e.copy(vc).add(J0),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(vc),vc.distanceTo(e)}updateUp(){this.getWorldQuaternion($0),eS.set(0,0,1).applyQuaternion($0),qu.copy($2.DEFAULT_UP),this.isUpVectorFlipped&&qu.negate(),qu.applyQuaternion($0),tS.copy($2.DEFAULT_UP).projectOnPlane(eS),this.angleOffsetFromUp=tS.angleTo(qu),this.angleOffsetFromUp*=tS.cross(qu).dot(eS)>=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 mn),o=e.getWorldDirection(new mn).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new mn).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new mn;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=-ny*.5*o,this.right=ny*.5*o,this.top=ny*.5*(1/a),this.bottom=-ny*.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:eO(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Kn.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Kn.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new Rs,blend:new Rs,blendInverse:new Rs,start:0,duration:Kn.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=Kn.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=eO(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 Rs,blend:new Rs,blendInverse:new Rs,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=nn.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=nn.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=Kn;St.projectionTransitionsEnabled=!1,St.projectionTransitionDuration=350,St.projectionTransitionMinAgeMs=1e3;var GU=null;function tO(n){GU=n}var UU,rO=new Promise(n=>{UU=n});import{Box3 as yhe,Euler as iO,Matrix4 as nO,Quaternion as iS,Sphere as HU,Vector3 as Xu}from"three";import{BufferGeometry as zU,Float32BufferAttribute as rS}from"three";function jU(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 oy(n,t){let e=new zU;if(t&&jU(t))return e.setAttribute("position",new rS([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new rS([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Tu(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new rS(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}import{mergeGeometries as xhe}from"three/examples/jsm/utils/BufferGeometryUtils.js";var WU;rO.then(n=>WU=n);var whe=new Xu,Ahe=new iS,Ehe=new Xu,Che=new iO(0,0,0,"YXZ"),The=new iO(0,0,0,"XYZ"),Phe=new Xu,Mhe=new Xu,Ohe=new Xu(1,1,1),Ihe=new iS,Dhe=new nO,Rhe=new nO;var Bhe=new iS,Nhe=new HU;var nS={type:"beginEvent",eventName:"Collision"};var oS=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 QU}from"three";ut();var oO=4,aS=8;var sS=.02,lS=.3,KU=65,aO=new Fe,sO=new Fe,ZU=new Fe,Wr=new Fe,ko=new Fe,bc=new Fe,cS=new Jn,lO=new Jn,JU=new Jn,Ei=new qr,Bs=new qr,xc=new Sc(0,0,0,"YXZ"),$U=new Fe(1,0,0),Zn=new Fe(0,1,0),ez=new Fe(0,0,1),cO=new Fe(1,1,1),dS=[],dO=n=>dS[n]??(dS[n]=new Fe),uS=new Fe,tz=new Fe,rz=new Fe,iz=new Fe,uO=new qr,nz=new Fe,pO=new qr,oz=1,az=.025,sz=16e-6,hO=12,lz=20,Pr=new fO,Ki=new qU,cz={type:"requestRender"},dz={type:"updateMatrix"},ay=class extends XU{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 Jn;this.target0=new Fe;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=N2;this.euler0=new Sc(0,0,0,"YXZ");this.position0Cam=new Fe;this.quat0Cam=new qr;this.scale0Cam=new Fe;this.hiddenMatrix0Cam=new Jn;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new fO(new Fe(0,-40,0),new Fe(0,40,0)),matrix:new Jn,position:new Fe,rotation:new qr};this.euler=new Sc(0,0,0,"YXZ");this.eulerDelta=new Fe;this.lastPosition=new Fe;this.lastCameraQuaternion=new qr;this.lastCameraPosition=new Fe;this.PI_2=Math.PI/2;this.prevMouse=new YU;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 Jn;this.nonColliderPosOffset=new Jn;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 Jn;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 qr;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 qr;this.objXZQuatInv=new qr;this.objXZRotMat=new Jn;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new Fe;this.pushedVelocity=new Fe;this.groundYRotation=0;this.objectRealQuat=new qr;this.colliderWorldQuat=new qr;this.groundNormal=new Fe;this.groundTilt=new qr;this.groundTiltInv=new qr;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new Fe;this.quaternion=new qr;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"&&!pi&&!Nb&&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"&&(Nb&&KE<15.5&&!pi?(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?ay.isLocked=!0:ay.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 Sc().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)*oz,this.speedOrbit=(i.speedRotate??100)*az,this.mouseOrbitSensitivity=(i.speedRotate??100)*sz,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)*hO,this.usePhysics=this.gloabalPhysics.usePhysics??ha.defaultData.usePhysics,this.jumpPower=i.jumpPower*lz,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=KU*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*sS/this.pixelsPerMeter,this.stepThresh=i.collider.height*lS/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*sS/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*lS/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*sS/this.pixelsPerMeter,this.stepThresh=i.collider.height*lS/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 qr().setFromEuler(new Sc().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,cO),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=pm({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new QU(Uf.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 Sc().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"),$t(this.actions.idle),$t(this.actions.move),$t(this.actions.run),$t(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 Wr.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=ko.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*hO),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,aS,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(Wr).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=Wr.subVectors(this.path[1],this.position),c=ko.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=ZU.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=ko.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=Wr;this.camera.getWorldDirection(s);let l=bc.copy(Zn).multiplyScalar(s.dot(Zn));s.sub(l);let c=ko.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(xc.setFromVector3(this.rot),this.moveMode==="walk"&&(xc.x=0),a.applyEuler(xc),o&&(Bs.setFromUnitVectors(Zn,this.groundNormal),a.applyQuaternion(Bs)),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(uS,uO,tz);let c=this.object.getWorldPosition(rz).add(this.collider.position).sub(uS);pO.copy(l.prevQ).invert().premultiply(uO);let d=bc.subVectors(uS,l.prevT).add(iz.copy(c).applyQuaternion(pO).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Wr.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 lr&&(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(nS));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),dO(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=dO(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(Zn,this.euler.y-this.euler0.y);let s=ko.copy(this.objectToCamXZ).normalize(),l=bc.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(Wr.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&&(xc.copy(this.euler),xc.y=0,this.nonColliderRotOffset.makeRotationFromEuler(xc)),Ei.setFromAxisAngle($U,this.rot.x),Bs.setFromAxisAngle(Zn,this.rot.y),Bs.multiply(Ei),Ei.setFromAxisAngle(ez,this.rot.z),Bs.multiply(Ei),this.quaternion.copy(Bs),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=ko.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=bc.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,aS|oO,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(nS)}}}let y=aO.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=sO.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=bc.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,aS|oO,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),Wr.copy(this.position).divideScalar(this.pixelsPerMeter),Ei.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&nz.copy(Wr).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(Wr,!0),d.setRotation(Ei,!0)):(d.setNextKinematicTranslation(Wr),d.setNextKinematicRotation(Ei)))}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);cS.lookAt(l,s,Zn).setPosition(l),cS.decompose(this.targetPos,this.targetQuat,Wr),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(dz),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=Ei.setFromAxisAngle(Zn,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=Wr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let o=Bs.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){Zn.angleTo(e)*180/Math.PI<15||Zn.angleTo(e)*180/Math.PI>85?Ei.identity():Ei.setFromUnitVectors(Zn,e),this.groundTilt.slerp(Ei,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=sO.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=cS.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Wr,Ei,ko).compose(Wr,Ei,cO);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Ki.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=lO.copy(s).invert(),c=JU.copy(lO).multiply(i);Pr.copy(this.collider.segment),Pr.start.applyMatrix4(c),Pr.end.applyMatrix4(c);let d=aO.copy(this.position).applyMatrix4(l);Ki.expandByPoint(Pr.start),Ki.expandByPoint(Pr.end),Ki.min.addScalar(-this.collider.radius),Ki.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(Pr.end)},intersectsBounds:u=>u.intersectsBox(Ki),intersectsTriangle:u=>{let p=Wr,h=ko,f=u.closestPointToSegment(Pr,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=bc.copy(d);g.addScaledVector(y,m);let b=g.applyMatrix4(s).sub(this.position);r.add(b),Pr.start.addScaledVector(y,m),Pr.end.addScaledVector(y,m)}}})}),Ki.makeEmpty(),Pr.copy(this.collider.segment),Pr.start.applyMatrix4(i),Pr.end.applyMatrix4(i),Ki.expandByPoint(Pr.start),Ki.expandByPoint(Pr.end),Ki.min.addScalar(-this.collider.radius),Ki.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(Pr.end)},intersectsBounds:a=>a.intersectsBox(Ki),intersectsTriangle:a=>{let s=Wr,l=ko,c=a.closestPointToSegment(Pr,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),Pr.start.addScaledVector(u,d),Pr.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=ay;Yu.isLocked=!1;import{BufferAttribute as gO,BufferGeometry as pz,Vector3 as Qu}from"three";import{mergeGeometries as hz}from"three/examples/jsm/utils/BufferGeometryUtils.js";var uz,mO=new Promise(n=>{uz=n});var yO;var fz=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.29/build/",mz=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 qm,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=CU(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 CU(n){if(n.length){let t=n[0];if(t instanceof wU)return t.v1;if(t instanceof SU||t instanceof AU)return t.v0}}Vi("TextGeometry",(n,t,e)=>new wa(n,t,e));var B2={create:(n,t)=>new $l(n,t)};ru("TextGeometry",B2);ru("InputGeometry",B2);mT(Ym);Oe("text");var N2=200,TU=null;function L2(n){TU=n}var zu=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},_2=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return PU(Math.atan2(r,e))},F2=(n,t,e)=>{let r={x:0,y:0};return e=Km(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Km=n=>n*(Math.PI/180),PU=n=>n*(180/Math.PI),k2=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,Qm=new Map,V2=n=>{Qm.has(n)&&clearTimeout(Qm.get(n)),Qm.set(n,setTimeout(function(){Qm.delete(n),n()},100))},hc=(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)},fc=(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 Zm=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),Q0=()=>{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}},Jm=(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")},$m=(n,t,e)=>{let r=U2(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},G2=(n,t)=>{let e=U2(n);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},U2=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},ey=(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"&&(H2="ontouchstart"in window,W2=!!window.PointerEvent,q2=!!window.MSPointerEvent);var H2,W2,q2,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"}},mc,Wu={};W2?mc=Hu.pointer:q2?mc=Hu.MSPointer:H2?(mc=Hu.touch,Wu=Hu.mouse):mc=Hu.mouse;function Ds(){}Ds.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};Ds.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};Ds.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)})};Ds.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=z2(t.options,n))};Ds.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.')},hc(n,mc[t],e._domHandlers_[t]),Wu[t]&&hc(n,Wu[t],e._domHandlers_[t]),e};Ds.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},fc(n,mc[t],e._domHandlers_[t]),Wu[t]&&fc(n,Wu[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var yc=Ds;function xr(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=xr.id,xr.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}xr.prototype=new yc;xr.constructor=xr;xr.id=0;xr.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)};xr.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=G2("borderRadius","50%"),e=$m("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)"},ey(r.el,e),this.options.shape==="circle"&&ey(r.back,t),ey(r.front,t),this.applyStyles(r),this};xr.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};xr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};xr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};xr.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};xr.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};xr.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};xr.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=$m("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)};xr.prototype.restCallback=function(){var n=this,t={};t.front=$m("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};xr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};xr.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 X2=xr;function ur(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=ur.id,ur.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}ur.prototype=new yc;ur.constructor=ur;ur.id=0;ur.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}};ur.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};ur.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)}};ur.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 X2(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||(Jm(c.ui.el,i),Jm(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};ur.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};ur.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)};ur.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)};ur.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=Zm(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};ur.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};ur.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)};ur.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(!k2(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=_2(l,i.position),u=Km(d),p=c/s,h={distance:c,position:l},f,m;if(i.options.shape==="circle"?(f=Math.min(c,s),m=F2(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||Jm(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:Km(180-d),degree:180-d},i.trigger("move",b),t.trigger("move "+i.id+":move",b)};ur.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))};ur.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()};ur.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 Y2=ur;function yr(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Q0(),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(){V2(e)},t._onScroll=function(){t.scroll=Q0()},t.collections}yr.prototype=new yc;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,hc(window,"resize",n._onResize),hc(window,"scroll",n._onScroll))};yr.prototype.unbindWindowEvents=function(){var n=this;!n._windowBound||typeof window>"u"||(n._windowBound=!1,fc(window,"resize",n._onResize),fc(window,"scroll",n._onScroll))};yr.prototype.createCollection=function(n){var t=this,e=new Y2(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=Zm(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 Q2=yr;var gc=null;function K2(){return gc||(gc=new Q2),gc}var MU={create:function(n){return K2().create(n)},destroy:function(){gc&&(gc.destroy(),gc=null)},get factory(){return K2()}},Z2=MU;import{Box3 as qU,Euler as Sc,EventDispatcher as XU,Line3 as fO,MathUtils as Pa,Matrix4 as Jn,Quaternion as qr,Vector2 as YU,Vector3 as Fe}from"three";import{Camera as _U,OrthographicCamera as FU,PerspectiveCamera as kU,Vector3 as mn,Object3D as $2,Quaternion as VU,Matrix4 as Rs}from"three";import{Camera as DU,LineSegments as RU,BufferGeometry as BU,LineBasicMaterial as NU,Color as K0,Vector3 as LU,Float32BufferAttribute as J2}from"three";var ry=new LU,Qi=new DU,Z0=class extends RU{constructor(e){let r=new BU,i=new NU({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new K0(15711266),c=new K0(15711266),d=new K0(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 J2(o,3)),r.setAttribute("color",new J2(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;Qi.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;fn("n1",r,e,Qi,-o,-a,s),fn("n2",r,e,Qi,o,-a,s),fn("n3",r,e,Qi,-o,a,s),fn("n4",r,e,Qi,o,a,s);let l=s;fn("f1",r,e,Qi,-o,-a,l),fn("f2",r,e,Qi,o,-a,l),fn("f3",r,e,Qi,-o,a,l),fn("f4",r,e,Qi,o,a,l);let c=l,d=.5;fn("u1",r,e,Qi,o*.7*d,a*1.1,c),fn("u2",r,e,Qi,-o*.7*d,a*1.1,c),fn("u3",r,e,Qi,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function fn(n,t,e,r,i,o,a){ry.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],ry.x,ry.y,ry.z)}}var iy=class extends Vn(Z0){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){Gn(this.object,this.geometry,e,r,!0)}};var ny=790;function eO(n){return 1-Math.pow(1-n,3)}var vc=new mn,J0=new mn,$0=new VU,eS=new mn,qu=new mn,tS=new mn,Kn=class extends qi(_U,iy){constructor(e="",r={...ds.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=nn.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=Kn.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new Rs,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,o=this.height;this.orthoCamera=new FU(i*-.5,i*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new kU(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=Kn.projectionTransitionsEnabled;Kn.projectionTransitionsEnabled=!1;try{return e()}finally{Kn.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 mn(e,r,i)),super.lookAt(e),this.getWorldPosition(vc),this.targetOffset=vc.distanceTo(e)}getTarget(e=new mn){return this.getWorldDirection(J0),this.getWorldPosition(vc),J0.multiplyScalar(this.targetOffset),e.copy(vc).add(J0),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(vc),vc.distanceTo(e)}updateUp(){this.getWorldQuaternion($0),eS.set(0,0,1).applyQuaternion($0),qu.copy($2.DEFAULT_UP),this.isUpVectorFlipped&&qu.negate(),qu.applyQuaternion($0),tS.copy($2.DEFAULT_UP).projectOnPlane(eS),this.angleOffsetFromUp=tS.angleTo(qu),this.angleOffsetFromUp*=tS.cross(qu).dot(eS)>=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 mn),o=e.getWorldDirection(new mn).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new mn).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new mn;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=-ny*.5*o,this.right=ny*.5*o,this.top=ny*.5*(1/a),this.bottom=-ny*.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:eO(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Kn.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Kn.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new Rs,blend:new Rs,blendInverse:new Rs,start:0,duration:Kn.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=Kn.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=eO(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 Rs,blend:new Rs,blendInverse:new Rs,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=nn.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=nn.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=Kn;St.projectionTransitionsEnabled=!1,St.projectionTransitionDuration=350,St.projectionTransitionMinAgeMs=1e3;var GU=null;function tO(n){GU=n}var UU,rO=new Promise(n=>{UU=n});import{Box3 as yhe,Euler as iO,Matrix4 as nO,Quaternion as iS,Sphere as HU,Vector3 as Xu}from"three";import{BufferGeometry as zU,Float32BufferAttribute as rS}from"three";function jU(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 oy(n,t){let e=new zU;if(t&&jU(t))return e.setAttribute("position",new rS([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new rS([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Tu(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new rS(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}import{mergeGeometries as xhe}from"three/examples/jsm/utils/BufferGeometryUtils.js";var WU;rO.then(n=>WU=n);var whe=new Xu,Ahe=new iS,Ehe=new Xu,Che=new iO(0,0,0,"YXZ"),The=new iO(0,0,0,"XYZ"),Phe=new Xu,Mhe=new Xu,Ohe=new Xu(1,1,1),Ihe=new iS,Dhe=new nO,Rhe=new nO;var Bhe=new iS,Nhe=new HU;var nS={type:"beginEvent",eventName:"Collision"};var oS=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 QU}from"three";ut();var oO=4,aS=8;var sS=.02,lS=.3,KU=65,aO=new Fe,sO=new Fe,ZU=new Fe,Wr=new Fe,ko=new Fe,bc=new Fe,cS=new Jn,lO=new Jn,JU=new Jn,Ei=new qr,Bs=new qr,xc=new Sc(0,0,0,"YXZ"),$U=new Fe(1,0,0),Zn=new Fe(0,1,0),ez=new Fe(0,0,1),cO=new Fe(1,1,1),dS=[],dO=n=>dS[n]??(dS[n]=new Fe),uS=new Fe,tz=new Fe,rz=new Fe,iz=new Fe,uO=new qr,nz=new Fe,pO=new qr,oz=1,az=.025,sz=16e-6,hO=12,lz=20,Pr=new fO,Ki=new qU,cz={type:"requestRender"},dz={type:"updateMatrix"},ay=class extends XU{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 Jn;this.target0=new Fe;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=N2;this.euler0=new Sc(0,0,0,"YXZ");this.position0Cam=new Fe;this.quat0Cam=new qr;this.scale0Cam=new Fe;this.hiddenMatrix0Cam=new Jn;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new fO(new Fe(0,-40,0),new Fe(0,40,0)),matrix:new Jn,position:new Fe,rotation:new qr};this.euler=new Sc(0,0,0,"YXZ");this.eulerDelta=new Fe;this.lastPosition=new Fe;this.lastCameraQuaternion=new qr;this.lastCameraPosition=new Fe;this.PI_2=Math.PI/2;this.prevMouse=new YU;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 Jn;this.nonColliderPosOffset=new Jn;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 Jn;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 qr;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 qr;this.objXZQuatInv=new qr;this.objXZRotMat=new Jn;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new Fe;this.pushedVelocity=new Fe;this.groundYRotation=0;this.objectRealQuat=new qr;this.colliderWorldQuat=new qr;this.groundNormal=new Fe;this.groundTilt=new qr;this.groundTiltInv=new qr;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new Fe;this.quaternion=new qr;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"&&!pi&&!Nb&&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"&&(Nb&&KE<15.5&&!pi?(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?ay.isLocked=!0:ay.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 Sc().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)*oz,this.speedOrbit=(i.speedRotate??100)*az,this.mouseOrbitSensitivity=(i.speedRotate??100)*sz,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)*hO,this.usePhysics=this.gloabalPhysics.usePhysics??ha.defaultData.usePhysics,this.jumpPower=i.jumpPower*lz,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=KU*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*sS/this.pixelsPerMeter,this.stepThresh=i.collider.height*lS/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*sS/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*lS/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*sS/this.pixelsPerMeter,this.stepThresh=i.collider.height*lS/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 qr().setFromEuler(new Sc().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,cO),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=pm({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new QU(Uf.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 Sc().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"),$t(this.actions.idle),$t(this.actions.move),$t(this.actions.run),$t(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 Wr.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=ko.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*hO),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,aS,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(Wr).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=Wr.subVectors(this.path[1],this.position),c=ko.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=ZU.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=ko.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=Wr;this.camera.getWorldDirection(s);let l=bc.copy(Zn).multiplyScalar(s.dot(Zn));s.sub(l);let c=ko.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(xc.setFromVector3(this.rot),this.moveMode==="walk"&&(xc.x=0),a.applyEuler(xc),o&&(Bs.setFromUnitVectors(Zn,this.groundNormal),a.applyQuaternion(Bs)),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(uS,uO,tz);let c=this.object.getWorldPosition(rz).add(this.collider.position).sub(uS);pO.copy(l.prevQ).invert().premultiply(uO);let d=bc.subVectors(uS,l.prevT).add(iz.copy(c).applyQuaternion(pO).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Wr.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 lr&&(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(nS));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),dO(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=dO(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(Zn,this.euler.y-this.euler0.y);let s=ko.copy(this.objectToCamXZ).normalize(),l=bc.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(Wr.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&&(xc.copy(this.euler),xc.y=0,this.nonColliderRotOffset.makeRotationFromEuler(xc)),Ei.setFromAxisAngle($U,this.rot.x),Bs.setFromAxisAngle(Zn,this.rot.y),Bs.multiply(Ei),Ei.setFromAxisAngle(ez,this.rot.z),Bs.multiply(Ei),this.quaternion.copy(Bs),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=ko.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=bc.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,aS|oO,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(nS)}}}let y=aO.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=sO.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=bc.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,aS|oO,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),Wr.copy(this.position).divideScalar(this.pixelsPerMeter),Ei.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&nz.copy(Wr).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(Wr,!0),d.setRotation(Ei,!0)):(d.setNextKinematicTranslation(Wr),d.setNextKinematicRotation(Ei)))}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);cS.lookAt(l,s,Zn).setPosition(l),cS.decompose(this.targetPos,this.targetQuat,Wr),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(dz),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=Ei.setFromAxisAngle(Zn,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=Wr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let o=Bs.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){Zn.angleTo(e)*180/Math.PI<15||Zn.angleTo(e)*180/Math.PI>85?Ei.identity():Ei.setFromUnitVectors(Zn,e),this.groundTilt.slerp(Ei,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=sO.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=cS.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Wr,Ei,ko).compose(Wr,Ei,cO);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Ki.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=lO.copy(s).invert(),c=JU.copy(lO).multiply(i);Pr.copy(this.collider.segment),Pr.start.applyMatrix4(c),Pr.end.applyMatrix4(c);let d=aO.copy(this.position).applyMatrix4(l);Ki.expandByPoint(Pr.start),Ki.expandByPoint(Pr.end),Ki.min.addScalar(-this.collider.radius),Ki.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(Pr.end)},intersectsBounds:u=>u.intersectsBox(Ki),intersectsTriangle:u=>{let p=Wr,h=ko,f=u.closestPointToSegment(Pr,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=bc.copy(d);g.addScaledVector(y,m);let b=g.applyMatrix4(s).sub(this.position);r.add(b),Pr.start.addScaledVector(y,m),Pr.end.addScaledVector(y,m)}}})}),Ki.makeEmpty(),Pr.copy(this.collider.segment),Pr.start.applyMatrix4(i),Pr.end.applyMatrix4(i),Ki.expandByPoint(Pr.start),Ki.expandByPoint(Pr.end),Ki.min.addScalar(-this.collider.radius),Ki.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(Pr.end)},intersectsBounds:a=>a.intersectsBox(Ki),intersectsTriangle:a=>{let s=Wr,l=ko,c=a.closestPointToSegment(Pr,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),Pr.start.addScaledVector(u,d),Pr.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=ay;Yu.isLocked=!1;import{BufferAttribute as gO,BufferGeometry as pz,Vector3 as Qu}from"three";import{mergeGeometries as hz}from"three/examples/jsm/utils/BufferGeometryUtils.js";var uz,mO=new Promise(n=>{uz=n});var yO;var fz=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.31/build/",mz=n=>`
|
|
1329
1329
|
(async function() {
|
|
1330
1330
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
1331
1331
|
import('${n}' + 'navmesh.js'),
|
|
@@ -1406,7 +1406,7 @@ onmessage = function(messageEvent) {
|
|
|
1406
1406
|
`:"")+bp(e.children,t);if(e.type==="variable"){let i=t.getVariable(e.variableId);if(i!==void 0)return KI(i,t)}}return""}).join("");var $y=1e3,ZI=512*$y;function b4(n,t){let e=typeof n;return!!((t==="string"||t==="number")&&e===t||t==="boolean"&&(n==="true"||n==="false"||n===!0||n===!1)||t==="image"&&e==="string"&&n.startsWith("http"))}var JI="https://hooks.spline.design",x4=`${JI}/events?hashFile=`,q0e=`${JI}/`,eg=class{constructor(t,e){this.id=t;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=Lo();this.reconnectWaitFor=$y;this._onError=t=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=t=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=$y,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=$y,this._connected=!1};this._onMessage=t=>{let e=t.data,r;try{r=JSON.parse(e)}catch(i){console.error("Error parsing webhook message",i)}if(r){let i=!1;this.userWebhook.parametersSchemas.forEach(({data:o})=>{r[o.name]!==void 0&&b4(r[o.name],o.type)&&(this.result===void 0&&(this.result={}),this.result[o.name]=r[o.name],i=!0)}),i&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(x4+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>ZI&&(this.reconnectWaitFor=ZI),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let r of this.userWebhook.parametersSchemas)if(r.data.name===t)return rf.defaultParameterValueByType(r.data.type)}}};Yt("API",({eventContext:n,eventManager:t})=>new Qy(n,t));Yt("WEBHOOK",({eventContext:n,eventManager:t})=>new Ky(n,t));kt("UserAPI",({data:n,page:t,shared:e,actionCondition:r})=>new Zy(n,t,e,r));NP({createUserAPI:(n,t,e)=>new Jy(n,t,e),createUserWebhook:(n,t)=>new eg(n,t)});Oe("api-services");var tg=class extends Mt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onVoice=({value:e,frequencies:r})=>{this.events.forEach(i=>{i.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantListener"&&!r.data.disabled).forEach(r=>{this.events.push(new u1(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},u1=class{constructor(t,e,r,i,o,a){this.id=t;this.data=e;this.object=r;this.actions=Tt(e,e.actions,i,o,a,r)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};var rg=class extends Mt{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onTriggerEvent=({description:e,direction:r})=>{let i=this.events.find(o=>o.data.description===e);i&&(r==="backward"?i.dispatchReverse():i.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantTrigger"&&!r.data.disabled).forEach(r=>{this.events.push(new p1(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},p1=class{constructor(t,e,r,i,o,a){this.id=t;this.data=e;this.object=r;this.actions=Tt(e,e.actions,i,o,a,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};function S4(n){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(n.toLowerCase())}function w4(n,t,e){let r,i,o,a=Math.floor(n*6),s=n*6-a,l=e*(1-t),c=e*(1-s*t),d=e*(1-(1-s)*t);switch(a%6){case 0:r=e,i=d,o=l;break;case 1:r=c,i=e,o=l;break;case 2:r=l,i=e,o=d;break;case 3:r=l,i=c,o=e;break;case 4:r=d,i=l,o=e;break;case 5:default:r=e,i=l,o=c;break}return{r:r*255,g:i*255,b:o*255}}function A4(n,t,e){n/=255,t/=255,e/=255;let r=Math.max(n,t,e),i=Math.min(n,t,e),o=r,a=r-i,s=r==0?0:a/r,l;if(r==i)l=0;else{switch(r){case n:l=(t-e)/a+(t<e?6:0);break;case t:l=(e-n)/a+2;break;case e:default:l=(n-t)/a+4;break}l/=6}return{h:l,s,v:o}}function E4(n){return n=Math.floor(n),{r:n>>16&255,g:n>>8&255,b:n&255}}function C4(n,t,e){return(n<<16)+(t<<8)+e}function T4(n,t,e){return n=Math.round(n),t=Math.round(t),e=Math.round(e),"#"+[n,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function P4(n){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(r,i,o,a)=>String(i+i+o+o+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var $I={parseRgba:S4,hsvToRgb:w4,rgbToHsv:A4,hexToRgb:E4,rgbToHex:C4,rgbToHexString:T4,hexStringToRgb:P4};var eD=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],M4=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Xo=[],ng=[];for(let n=1;n<=8;n++)for(let t=0;t<eD.length;t++){let e=eD[t];Xo.push(e/Math.pow(2,8-n)),ng.push(M4[t]+n)}var ig=[32,2e3],h1=Xo.filter((n,t)=>Xo[t]>ig[0]&&Xo[t]<ig[1]),tD=ng.filter((n,t)=>Xo[t]>ig[0]&&Xo[t]<ig[1]);var og=class{static getFrequencies(t,e,r,i="frequency",o=-100,a=-30){r||(r=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(r));let s=e/2,l=1/r.length*s,c,d,u;if(i==="music"||i==="voice"){let f=i==="voice"?h1:Xo,m=Array(f.length).fill(o);for(let y=0;y<r.length;y++){let g=y*l,b=r[y];for(let x=f.length-1;x>=0;x--)if(g>f[x]){m[x]=Math.max(m[x],b);break}}c=m,d=i==="voice"?h1:Xo,u=i==="voice"?tD:ng}else c=Array.from(r),d=c.map((f,m)=>l*m),u=d.map(f=>`${f.toFixed(2)} Hz`);let p=c.map(f=>Math.max(0,Math.min((f-o)/(a-o),1)));return{values:new Float32Array(p),frequencies:d,labels:u}}};var O4="gpt-realtime",I4=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function D4(n){try{return(await(await fetch(I4()+"session?uuidfile="+n)).json()).token}catch(t){console.error("Token generation error:",t)}}var f1=class{constructor(t){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return og.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((r,i)=>r+i,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},ag=class{constructor(t){this.callbacks=t;this.rafId=0;this.isOpen=!1;this.onMessage=t=>{this.callbacks.onMessage(t.data)};this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()};this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(t){let e=await D4(t);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=c=>{let d=c.streams[0];this.audioElement.srcObject=d,this.analyser=new f1(d)};let r=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(r.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let i=await this.pc.createOffer();await this.pc.setLocalDescription(i);let l={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime/calls?model=${O4}`,{method:"POST",body:i.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(l),this.animate()}send(t){return this.dc?(this.dc.send(t),!0):!1}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}};function R4(){try{return window.__SPLINE_PLAY_VOICE_HOST__===!0&&window.parent!==window}catch{return!1}}function rD(n,t,e){if(!R4())return null;let r=!1,i=a=>{window.parent.postMessage({__splinePlayFrame:!0,...a},"*")},o=a=>{if(a.source!==window.parent)return;let s=a.data;!s||s.__splinePlayFrameHost!==!0||s.id!==n||(s.type==="voice-open"?(r=!0,e.onOpen()):s.type==="voice-message"&&typeof s.data=="string"?e.onMessage(s.data):s.type==="voice-level"&&typeof s.value=="number"?e.onVoice(s.value,s.frequencies instanceof Float32Array?s.frequencies:new Float32Array(0)):s.type==="voice-error"&&console.error("Voice assistant host error:",s.message))};return window.addEventListener("message",o),i({type:"voice-connect",id:n,hash:t}),{send:a=>r?(i({type:"voice-send",id:n,message:a}),!0):!1,disconnect:()=>{r=!1,window.removeEventListener("message",o),i({type:"voice-disconnect",id:n})}}}var sg=class{constructor(t,e,r){this.data=t;this.id=e;this.shared=r;this.emitter=Lo();this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onServerEvent=t=>{let e=JSON.parse(t);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let r of e.response.output)if(r.type==="function_call")for(let[i,o]of this.tools)r.name===i.name&&(o(JSON.parse(r.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(t){this.data=t}setColorByName(t,e){let r=this.shared.getColorByName(t);if(r){let{id:i}=r,{r:o,g:a,b:s}=$I.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(i,{r:o/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let t={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,r)=>{this.voice=e,this.frequencies=r,this.emitter.emit("voice",{value:e,frequencies:r})}};this.hosted=rD(this.id,this.data.integration.hash,t),!this.hosted&&(this.session=new ag(t),await this.session.connect(this.data.integration.hash))}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){t.event_id=t.event_id||crypto.randomUUID();let e=JSON.stringify(t);(this.hosted?this.hosted.send(e):this.session?.send(e)??!1)?this.appendEvent(t):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:o})=>{this.setColorByName("Voice Assistant Color",o)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:o,value:a})=>{let s=this.shared.getVariableByName(o);if(s){let l=this.shared.getVariable(s.id),c;typeof l=="number"?c=parseFloat(a):typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a},this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:o,value:a})=>{this.setColorByName(o,a)});let r=this.shared.scene,i=[];r.traverseEntity(o=>{o.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;i.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(i)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:o,direction:a})=>{this.emitter.emit("trigger_event",{description:o,direction:a})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([o])=>o)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((r,i)=>r+i,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};Yt("AIAssistantListener",({eventContext:n,eventManager:t})=>new tg(n,t));Yt("AIAssistantTrigger",({eventContext:n,eventManager:t})=>new rg(n,t));LP((n,t,e)=>new sg(n,t,e));Oe("ai-assistant");var ka=class extends wa{constructor(e,r,i){super(e,r,i);this.data=r}};import{Scene as W4}from"three";import{Group as B4,MeshBasicMaterial as iD,PlaneGeometry as nD,Mesh as oD,BufferGeometry as N4,Float32BufferAttribute as L4,DoubleSide as aD}from"three";var Hc=class extends B4{constructor(){super();this.caretIndex=0;this._caretVisibleAlpha=1;this._selectionVisibleAlpha=.3;this.current={start:0,end:void 0};this.matrixAutoUpdate=!1,this.caretMesh=new oD(new nD(1,1),new iD({transparent:!0,opacity:0,side:aD})),this.add(this.caretMesh),this.selectionMesh=new oD(new nD(1,1),new iD({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:aD})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(e){this.visible=!0,this.object=e,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=-this.caretHeight*.5,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(this.object===void 0)return;this.updateHelperMatrix();let{depth:e}=this.object.geometry.userData.parameters;this.caretMesh.position.z=e,this.selectionMesh.position.z=e}updateHelperMatrix(){if(this.object===void 0)return;let e=this.object,r=e.parent;r!==null&&r.updateWorldMatrix(!0,!1),e.matrixAutoUpdate&&e.updateMatrix(),r!==null?(this.matrixWorld.multiplyMatrices(r.matrixWorld,e.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,e.matrix)):this.matrixWorld.multiplyMatrices(e.hiddenMatrix,e.matrix),this.matrix.copy(this.matrixWorld);for(let i of this.children)i.matrixWorld.copy(this.matrixWorld);e.updateWorldMatrix(!0,!0)}setCaretColor(e){let r=this.caretMesh.material;r.color.setRGB(e.r,e.g,e.b);let i=this._caretVisibleAlpha===r.opacity;this._caretVisibleAlpha=e.a,i&&(r.opacity=this._caretVisibleAlpha)}setSelectionColor(e){this.selectionMesh.material.color.setRGB(e.r,e.g,e.b)}setCaretPosition(e,r={}){if(this.object===void 0)return;this.caretIndex=e;let i=this.object.wrappedText,[o,a]=lg(i,e),[s,l]=e>0?lg(i,e-1):[null,null];(e>0&&i.length?i[s].charAt(l):null)===`
|
|
1407
1407
|
`&&(o++,a=0),this.current.start=e,this.current.end=void 0;let[d,u]=m1(this.object,o,a),{AD:p,descender:h}=this.object,f=h+p*.5,{width:m,height:y,depth:g}=this.object.geometry.userData.parameters,b=typeof m=="string"?0:m,x=typeof y=="string"?0:y;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(d-b*.5,u+f+x*.5,g),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(e,r){if(this.object===void 0)return;let i=this.object.wrappedText;this.current.start=e,this.current.end=r;let o=[],a=[],s=_4(i,e,r),{lineHeight:l,AD:c,descender:d}=this.object,u=d+c*.5-l*.5;for(let[b,x,S]of s)if(x!==S){let[v,w]=m1(this.object,b,x),[A,E]=m1(this.object,b,S),P=w,M=E;P+=u,M+=u,M+=l;let R=o.length/3;o.push(v,P,0),o.push(A,P,0),o.push(A,M,0),o.push(v,M,0),a.push(R+0,R+1,R+2),a.push(R+2,R+3,R+0)}let p=new N4;p.setIndex(a),p.setAttribute("position",new L4(o,3));let{width:h,height:f,depth:m}=this.object.geometry.userData.parameters,y=typeof h=="string"?0:h,g=typeof f=="string"?0:f;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=p,this.selectionMesh.position.x=-y*.5,this.selectionMesh.position.y=g*.5,this.selectionMesh.position.z=m,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(e,r,i="previous"){if(this.object===void 0||this.object.font===void 0)return;let o=this.object.wrappedText,a=o.length,s=this.object.lineHeight,l=a*s,{height:c,verticalAlign:d}=this.object.geometry.userData.parameters,u=typeof c=="string"?0:c,p=0;d===3?p=u-l:d===2&&(p=u*.5-l*.5);let h=Math.min(Math.floor(Math.max(Math.min(-r-p,l),0)/s),a-1),f=this.object.charCoords[h],m=this.object.charWidths[h],y=0,g=!1;if(i==="previous"){for(let x=0;x<f.length;x++)if(f[x][0]+m[x]*.5-e>0){y=x,g=!0;break}}else if(i==="closest"){let x=1/0;for(let S=0;S<f.length;S++){let v=f[S][0]+m[S]*.5,w=Math.abs(v-e);w<x&&(x=w,y=S,g=!0)}}else for(let x=0;x<f.length;x++){let S=f[x][0],v=f[x][0]+m[x];if(e>=S&&e<v){y=x,g=!0;break}}return g||(y=f.length),{index:this.getGlobalIndexFromLineAndCharIndexes(o,h,y),lineIndex:h,characterIndex:y}}getGlobalIndexFromLineAndCharIndexes(e,r,i){return e.slice(0,r).reduce((o,a)=>o+=a.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function m1(n,t,e){let{charCoords:r,charWidths:i,initialOffsetY:o,lineHeight:a}=n;if(r[t]&&r[t].length===0||r.length===0){let u=0,{horizontalAlign:p}=n.data.geometry,h=n.wrappedText,{width:f}=n.geometry.userData.parameters;return h.length===1&&h[0].length===0&&(p===3?u=f*.5:p===2&&(u=f)),[u,o-a*t]}let s=r[t];if(s===void 0||s.length===0)return[0,0];let[l,c]=s[Math.min(e,s.length-1)],d=l;return e>=s.length&&(d+=i[t][e-1]),[d,c]}function lg(n,t){let e=0;for(let r=0;r<n.length;r++){let i=n[r],o=t-e;if(o<=i.length)return[r,o];e+=i.length}return[Math.max(0,n.length-1),n[n.length-1]?.length??0]}function _4(n,t,e){let[r,i]=lg(n,t),[o,a]=lg(n,e),s=[];i>=n[r].length&&(r++,i=0);for(let l=r;l<=o;l++){let c=n[l],d=l===r?i:0,u=l===o?a:c.length;s.push([l,d,u])}return s}function sD(n,t){let e=Ut.fromHex(3223857),r=.8;for(let i of n.layers){if(i.data.type==="light"||i.data.type==="displace"||i.data.type==="fresnel"||i.data.type==="dust"||i.data.type==="matcap"||i.data.type==="texture"||i.data.type==="toon"||i.data.type==="outline"||i.data.type==="transmission"||i.data.type==="noise"||i.data.type==="vertexColor")continue;let o=typeof i.data.alpha=="string"?Number(t.getVariable(i.data.alpha)):i.data.alpha;if(i.data.type==="color"&&o>.3){e=F4(i.data.color,t),r=o;break}else if((i.data.type==="depth"||i.data.type==="gradient")&&o>.3){let a=k4(i.data);e={r:a[0],g:a[1],b:a[2]},r=typeof i.data.alpha=="string"?1:i.data.alpha;break}}return{...e,a:r}}function F4(n,t){return typeof n=="string"?t.data.colors[n]:n}function k4(n){return n.colors[0]}import{Matrix3 as V4,Plane as G4,Vector2 as U4,Vector3 as xp}from"three";var cg=class{constructor(){this._clickCount=0;this._lastTime=0;this._lastPosition=[0,0];this._delay=500;this._distance=2;this._onMouseDown=t=>{let e=[t.clientX,t.clientY],r=new Date().getTime();if(this._clickCount>0){let i=e[0]-this._lastPosition[0],o=e[1]-this._lastPosition[1];Math.sqrt(i*i+o*o)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=r-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=r};this._onMouseUp=t=>{}}start(t,e=500,r=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=r,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}};function z4(){let n=document.createElement("textarea");return n.style.position="fixed",n.style.top="200px",n.style.left="400px",n.style.zIndex="-1",n.style.border="1px solid rgba(255,0,0,0.5)",n.style.width="10px",n.style.height="500px",n.style.color="white",n.style.opacity="0.5",n.style.background="transparent",n.style.display="none",n.style.margin="0px",n.style.padding="0px",n.style.boxSizing="content-box",n.style.pointerEvents="none",n}var j4=new xp(0,0,1),lD=new xp,cD=new xp,dD=new V4,dg=class{constructor(t,e,r,i,o){this.containerScene=t;this.raycaster=e;this.sharedAssets=r;this.requestRender=i;this.onExit=o;this.htmlInput=null;this.virtualInput=null;this.helper=new Hc;this.doubleClickHandler=new cg;this.isDragging=!1;this.plane=new G4;this.caretInterval=0;this.planeIntersection=new xp;this.projected=new U4;this._lastIndex=0;this._isFirstDragMove=!1;this.selectionOnDragStart=0;this.onTextMaterialChanged=()=>{let t=this.virtualInput?.data;if(this.virtualInput!==void 0&&t){let e=t.material,r=typeof e=="string"?this.sharedAssets.data.materials[e]:e,i=sD(r,this.sharedAssets);this.helper.setCaretColor(i)}};this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)};this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))};this.handleCaretUpdate=t=>{if(!this.htmlInput||!this.virtualInput)return;let e=this.helper,r=t?.key==="ArrowLeft"||t?.key==="ArrowRight",i=t?.key==="ArrowUp"||t?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(e.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:r,verticalKeyMove:i}),this.startAnimateTextCursor()):e.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()};this.containerScene.add(this.helper)}createInput(){return this.htmlInput=z4(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,e=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0},{lineIndex:r}=e,{index:i,characterIndex:o}=e;this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[r][Math.max(0,o-1)]===`
|
|
1408
1408
|
`&&(i--,o--),this._lastIndex=i,this._isFirstDragMove=!0;let a=this.checkClickedObject();if(t===1){if(a===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=i,this.isDragging=!0,this.setInputSelection(i)}else a===this.virtualInput&&(t===2?this.selectClosestWord(r,o):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let e=this.data?.geometry.text;this.htmlInput.value=typeof e=="string"?"":e?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:r,characterIndex:i}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0},o=e;r!==void 0&&i!==void 0&&this.virtualInput?.wrappedText[r][i-1]===`
|
|
1409
|
-
`&&o--,this.htmlInput.setSelectionRange(Math.min(t,o),Math.max(t,o))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof ka)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let r=this.virtualInput.wrappedText,i=r[t],o=e+1,a=e;i[e]!==" "&&(o=this.findNextCharOccurence(i,e,"forward"," "),a=this.findNextCharOccurence(i,e,"backward"," "),a>0&&a++,o>=i.length-1&&t===r.length-1&&o++);let s=this.helper,l=s.getGlobalIndexFromLineAndCharIndexes(r,t,a),c=s.getGlobalIndexFromLineAndCharIndexes(r,t,o);this.setInputSelection(l,c)}findNextCharOccurence(t,e,r,i=" "){let o=Math.max(0,t.length-1),a=r==="forward"?o:0,s=r==="forward"?1:-1,l=Math.max(Math.min(e,o),0);for(;l!==a;)if(l+=s,t.charAt(l)===i)return l;return a}getPointOnPlane(){let t=this.virtualInput?.data;if(!(!this.virtualInput||!t)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new xp);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let r=typeof t.geometry.width=="number"?t.geometry.width:1,i=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+r*.5,e.y-i*.5)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(dD.getNormalMatrix(this.virtualInput.matrixWorld),lD.copy(j4).applyMatrix3(dD).normalize(),this.virtualInput.localToWorld(cD.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(lD,cD))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),Pl&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=H4(t.geometry.horizontalAlign))}};function H4(n){return n===4?"justify":n===2?"right":n===3?"center":"left"}var pD=(n,t)=>{if(typeof n=="string"){let e=t.data(n);if(e)return pD(e.value,t)}return ar.getDisplayedValue(n)};function uD(n,t){let e=n.text,r="";if(typeof e=="string"){let i=t.variables.data(r);i&&(r=pD(i.value,t.variables))}else r=e.textValue.toString();return r}var ug=class extends Mt{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new W4;this.helper=new Hc;this._onMouseDownFocusIn=e=>{if(sr.length>1)return;this.eventContext.updateRaycaster(e);let r=null;if(this.eventContext.raycaster){for(let i of this._textInputs)if(this.eventContext.raycaster.intersectObject(i,!0).length>0){r=i;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(e),this._onMouseDown(e)};this.onExit=()=>{let{virtualInput:e}=this.textInputManager;if(e===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:i}=this.eventContext;i.removeEventListener("pointerdown",this._onMouseDown,!1),i.removeEventListener("pointerup",this._onMouseUp,!1),i.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),i.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()};this._onMouseDown=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)};this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)};this._onMouseMove=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseMove()};this._onTextEdit=e=>{let{htmlInput:r,virtualInput:i,helper:o}=this.textInputManager;if(!r||!i)return;let a=r.value;i.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let s=i.data;o.update();let l=s.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()};this._onCaretUpdate=e=>{this.textInputManager.handleCaretUpdate(e)};this._onKeyPress=e=>{e.key==="Escape"&&this.onExit()};this.textInputManager=new dg(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(o=>{o instanceof ka&&e.push(o)}),this._textInputs=e,e.length===0)return;let{domElement:r}=this.eventContext;r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:r,sharedAssets:i}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(o=>{let a=uD(o.data.geometry,this.eventContext.sharedAssets.data);o.textGeometry.setText(a,i)}),r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let r=this.textInputManager.htmlInput;if(!r||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=uD(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);r.value=i,r.setSelectionRange(0,0),this.textInputManager.helper.show(e),r.style.display="block",r.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:o}=this.eventContext;o.removeEventListener("pointerdown",this._onMouseDownFocusIn),o.addEventListener("pointerdown",this._onMouseDown,!1),o.addEventListener("pointerup",this._onMouseUp,!1),o.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};Yt("Textfields",({eventContext:n,eventManager:t})=>new ug(n,t));Vi("InputGeometry",(n,t,e)=>new ka(n,t,e));Oe("textinputs");var hD=new Map,Sp=new Map,Wc=class{constructor(t,e,r,i){this.data=e;this.isPlayAudioAction=!0;let{audio:o,volume:a,delay:s,loop:l}=e;if(!o)throw new Error("Missing property");try{let c=typeof o=="string"?i.getAudio(o).src:o.data;this.audioPlayer=new Oo({src:c,volume:a,delay:s,loop:l})}catch{console.warn(`Could not create an audio player for this object: "${r.name}" and this audio: "${o}"`)}Sp.has(r.uuid)?Sp.get(r.uuid).push(this):Sp.set(r.uuid,[this]),hD.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},y1=class{constructor(t){this.data=t;this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=hD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Sp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...Sp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},pg=class{constructor(t,e,r,i,o){this.data=e;this.shared=i;this.condition=o;if(e.interaction==="play")this.interaction=new Wc(t,e,r,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new y1(e);else throw new Error("Missing property")}dispatchBasic(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Wc?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Wc?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Wc&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};kt("Audio",({id:n,data:t,object:e,shared:r,actionCondition:i})=>new pg(n,t,e,r,i));Oe("audio");function fD(n,t){let e;if("material"in n){let i=n.material;Array.isArray(i)?e=n.material[0].layers.find(o=>o.uuid===t):e=n.material.layers.find(o=>o.uuid===t)}if(!e)return;let r=e.color?.texture?.image?.img??e.holders?.find(i=>i.isVideo)?.img;return r instanceof HTMLVideoElement?r:void 0}var mD=new Map,wp=new Map,Ap=class{constructor(t,e,r){this.data=e;this.isPlayVideoAction=!0;this.delay=0;this.status="stopped";let{layerId:i,loop:o,volume:a,delay:s}=e;if(this.object=r,i===void 0)throw new Error("Missing property");let l=fD(r,i);l&&(this.videoElement=l,this.videoElement.loop=o===1/0,Pl&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),s!==void 0&&(this.delay=s),wp.has(r.uuid)?wp.get(r.uuid).push(this):wp.set(r.uuid,[this]),mD.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(i=>{}).catch(i=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let r=this.videoElement.duration;if(r>0){let i=t%r;this.videoElement.currentTime=i}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},g1=class{constructor(t){this.data=t;this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=mD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=wp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...wp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},hg=class{constructor(t,e,r,i,o){this.data=e;this.shared=i;this.condition=o;if(e.interaction==="play")this.interaction=new Ap(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new g1(e);else throw new Error("Missing property")}dispatchBasic(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ap?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ap?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};kt("Video",({id:n,data:t,object:e,shared:r,actionCondition:i})=>Br(e)?null:new hg(n,t,e,r,i));Oe("video");import{MathUtils as q4,Quaternion as X4,Vector3 as b1}from"three";var v1=(()=>{let n,t,e,r,i=!1;function o(c){!n&&!yD()&&(t?.sharedGameControlGlobals.createdObjects.length??0)>0&&(n=requestAnimationFrame(a)),c&&(t=c,r=c.requestRender,!i&&typeof document<"u"&&(document.addEventListener("visibilitychange",s),i=!0))}function a(c){if(!t||!r){n=void 0,e=void 0;return}let d=e?c-e:0,u=t.sharedGameControlGlobals.createdObjects,p=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,f=0;for(;f<h;){let m=u[f];m.userData.createdTime===void 0&&(m.userData.createdTime=c),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&c-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&p[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,d/1e3),m.updateMatrix(),r()),f++):(p[m.userData.actionId]>m.userData.quantity&&p[m.userData.actionId]--,u.splice(f,1),m.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(y=>y.bvhGeometry!==void 0)),h--,r())}n=f>0?requestAnimationFrame(a):void 0,e=f>0?c:void 0}function s(){yD()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):o()}function l(){n&&(cancelAnimationFrame(n),n=void 0),i&&typeof document<"u"&&(document.removeEventListener("visibilitychange",s),i=!1),t=void 0,r=void 0,e=void 0}return{play:o,dispose:l}})();function yD(){return!!document&&document.hidden}var gD=new X4,Y4=new b1,Q4=new b1,fg=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=o;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=q4.generateUUID();this.dispatch=()=>{if(qe(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{if(qe(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=JE(this.dispatch,1e3/this.data.creationSpeed);this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))};this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)};this.dispatchInner=()=>{this.timeoutIdQueue.shift();let t=new lr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,i=this.page.scene.find(r);i&&(i.updateMatrixWorldRigid(),t.hiddenMatrix.copy(i.matrixWorldRigid))}t.scale.copy(this.object.scale),t.position.fromArray(this.data.position.map(r=>typeof r=="number"?r:0)),t.rotation.fromArray(this.data.rotation.map(r=>typeof r=="number"?r:0)),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),v1.play(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldRigid();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof ni)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof lr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof ni)return;t instanceof lr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new b1().fromArray(this.data.velocity.map(o=>typeof o=="number"?o:0)),i=e.dataPatched;if(!(i.physics.enabled==="visibility"?!i.visible:!i.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(Y4,gD,Q4),r.applyQuaternion(gD),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");v1.play(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],v1.dispose()}};var mg=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=o;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,i=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let o of e.cloner.children)i?(o.playModeVisible=!1,o.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),r.removeRigidBody(o.rigidBody),o.rigidBody=void 0),o.bvhGeometry&&(o.bvhGeometry=void 0)):this.clone===void 0||this.clone===o?(o.playModeVisible=!1,o.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),r.removeRigidBody(o.rigidBody),o.rigidBody=void 0)):o.playModeVisible===void 0&&(o.playModeVisible=!0);e.cloner.syncInstanceMatrices(),(i||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(qe(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(qe(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};kt("Create",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new fg(n,t,e.controlsManager,r,i));kt("Destroy",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new mg(n,t,e.controlsManager,r,i));Oe("create-destroy");import{Vector3 as K4}from"three";var vD=new K4;function yg(n,t,e=!1){let r=[],i=o=>{let a=o.data;delete o.states,o.currentState=null,o.reversibleToState=null,o.currentTransitionEvent=null;for(let s of a.states){let l={...s.data};o.states||(o.states={}),o.states[s.id]=So.patch(a,l)}xD(n.scene,o,null,t,a.events.find(s=>s.data.type==="Follow"||s.data.type==="LookAt")!==void 0),bD(n)};n.scene.traverse2D(i),n.traverseChildren(o=>{if(e&&(o.rigidBody?.setTranslation(o.position0,!0),o.rigidBody?.setRotation(o.rotation0,!0),o.rigidBody?.setLinvel(vD,!0),o.rigidBody?.setAngvel(vD,!0)),!ke.is(o))return;let a=o.uuid,s=o.data;if(delete o.states,o.uuid===En)return;let l=!1;r.some(c=>n.scene.find(a)?.isDescendantOf(c))?l=!0:s.physics?.fusedBody===!0&&s.physics.rigidBody==="dynamic"&&r.push(a),o.data=s,o.currentState=null,o.reversibleToState=null,o.currentTransitionEvent=null,o.transitionState={settled:!0,state:null};for(let c of s.states){let d={...c.data};n.data.globalPhysics.usePhysics===!0&&s.physics&&(s.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete d.position,c.data.rotation!==void 0&&delete d.rotation,c.data.hiddenMatrix!==void 0&&delete d.hiddenMatrix),o.states||(o.states={}),o.states[c.id]=yo.patch(s,d)}xD(n.scene,o,null,t,s.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),ei(o)&&o.frame&&(o.frame.traverse(c=>i(c)),o.uiCanvas?.applySize())}),bD(n),n.frame&&(n.frame.traverse(o=>i(o)),n.uiCanvas?.applySize())}function bD(n){n.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let i of Object.values(e.data.gameActions))r.push(...i);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let i of r)if(i.data.type==="Create"&&i.data.hideBase==="Yes"){let o=n.scene.find(i.data.object);o&&(o.visible=!1)}}})}function xD(n,t,e,r,i=!1){if(n.markShadowsDirty(),t instanceof Qe&&!sn(t)&&t.removeInteractionGeometry(r),Br(t)?t.changeSelectedState(e,{shared:r},i):t.changeSelectedState(e,{scene:n,shared:r},i),t instanceof Qe&&t.updateGeometryGroupsIfNeeded(),t instanceof St&&t.updateCameraState(t.dataPatched,{scene:n,shared:r}),!Br(t)){if(t.cloner){let o=!1;for(let a of t.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,o=!0);o&&n.addPendingUpdateCloner(t),t.cloner.syncInstanceMatrices()}t.updateVisible()}}var gg=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.eventManager=r;this.shared=i;this.condition=o;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(r=>r.uuid!==this.data.target||r.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),yg(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};kt("SceneTransition",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new gg(n,t,e,r,i));Oe("scene-transition");var vg=class{constructor(){this.elapsed=0;this.lastRealTimeMs=null;this.paused=!1}get time(){return this.elapsed}tick(t){let e=0;return this.lastRealTimeMs!==null&&(e=Math.min((t-this.lastRealTimeMs)/1e3,.25),e<0&&(e=0)),this.lastRealTimeMs=t,this.paused||(this.elapsed+=e),this.elapsed}step(t){return this.paused||(this.elapsed+=t),this.elapsed}resync(t){this.lastRealTimeMs=t}seek(t){this.elapsed=t}reset(){this.elapsed=0,this.lastRealTimeMs=null,this.paused=!1}};var ze=Math.fround,Z4=[.01,100],J4=[.01,1e4],$4=[.01,1e3],eH=[.01,1e3];function bg(n,[t,e]){return Math.min(Math.max(n,t),e)}function wD(n,t,e,r,i){n=bg(n,Z4),t=bg(t,J4),e=bg(e,$4),r=bg(r,eH);let o=Math.sqrt(t/n),a=e/(2*Math.sqrt(t*n)),s=a<1?o*Math.sqrt(1-a*a):0,l=1,c=a<1?(a*o+-r)/s:-r+o;return d=>{let u=i!==void 0?i*d:d;return a<1?u=Math.exp(-u*a*o)*(l*Math.cos(s*u)+c*Math.sin(s*u)):u=(l+c*u)*Math.exp(-u*o),d===0||d===1?d:1-u}}function tH(n,t,e,r){let i=.16666666666666666,o=0,a=0,s=wD(n,t,e,r),l=1e5;for(let c=0;c<l;c++)if(o+=i,s(o)===1){if(a+=1,a>=16)break}else a=0;return ze(o*i)}var rH=4,iH=ze(.001),nH=ze(1e-7),oH=10,Sg=11,xg=ze(1/(Sg-1));function AD(n,t){return ze(ze(1-ze(3*t))+ze(3*n))}function ED(n,t){return ze(ze(3*t)-ze(6*n))}function CD(n){return ze(3*n)}function wg(n,t,e){return ze(ze(ze(ze(ze(AD(t,e)*n)+ED(t,e))*n)+CD(t))*n)}function TD(n,t,e){let r=ze(ze(ze(3*AD(t,e))*n)*n),i=ze(ze(2*ED(t,e))*n);return ze(ze(r+i)+CD(t))}function aH(n,t,e,r,i){let o,a=0,s=0;do a=ze(t+ze(ze(e-t)/2)),o=ze(wg(a,r,i)-n),o>0?e=a:t=a,s+=1;while(Math.abs(o)>nH&&s<oH);return a}function sH(n,t,e,r){for(let i=0;i<rH;i++){let o=TD(t,e,r);if(o===0)return t;let a=ze(wg(t,e,r)-n);t=ze(t-ze(a/o))}return t}var SD=n=>n;function qc(n,t,e,r){if(n=ze(n),t=ze(t),e=ze(e),r=ze(r),n<0||n>1||e<0||e>1||n===t&&e===r)return SD;let i=new Float32Array(Sg);for(let a=0;a<Sg;a++)i[a]=wg(ze(a*xg),n,e);let o=a=>{let s=0,l=1,c=Sg-1;for(;l!==c&&i[l]<=a;)s=ze(s+xg),l+=1;l-=1;let d=ze(ze(a-i[l])/ze(i[l+1]-i[l])),u=ze(s+ze(d*xg)),p=TD(u,n,e);return p>=iH?sH(a,u,n,e):p===0?u:aH(a,s,ze(s+xg),n,e)};return a=>(a=ze(a),a===0||a===1?a:wg(o(a),t,r))}var lH=ze(1.70158),uwe=ze(lH+1);function Ag(n,t,e){switch(n.easing){case 0:return e;case 1:return qc(.25,.1,.25,1)(e);case 2:return qc(.42,0,1,1)(e);case 3:return qc(0,0,.58,1)(e);case 4:return qc(.42,0,.58,1)(e);case 7:return qc(.25,1,.5,1)(e);case 8:return Math.floor(e);case 5:{let{control1:r,control2:i}=n;return!r||!i?e:qc(r[0],r[1],i[0],i[1])(e)}case 6:{let{mass:r,stiffness:i,damping:o,velocity:a}=n;return r===void 0||i===void 0||o===void 0||a===void 0?e:ze(wD(r,i,o,a,t)(e))}default:return e}}function x1(n,t){if(n.easing!==6)return t;let{mass:e,stiffness:r,damping:i,velocity:o}=n;return e===void 0||r===void 0||i===void 0||o===void 0?t:tH(e,r,i,o)}var kr=Math.fround;function S1(n){return n==="pingpong"||n==="pingpong-rewind"}var Eg=class{constructor(t){this.config=t,this.effectiveCycleDuration=this.cycleDuration(0)}layout(t){let{config:e}=this;if(S1(e.direction)&&t%2===1)return{startDelay:0,endDelay:0};switch(e.delayDirection){case"start-once":return t===0?{startDelay:e.delay,endDelay:0}:{startDelay:0,endDelay:0};case"start":return{startDelay:e.delay,endDelay:0};case"end":return{startDelay:0,endDelay:e.delay};default:return{startDelay:e.delay,endDelay:e.delay}}}cycleDuration(t){let{config:e}=this,{startDelay:r,endDelay:i}=this.layout(t);return kr(e.duration+r+i)}get totalDuration(){let{config:t}=this;if(t.repeat===-1)return 1/0;let e=0;for(let r=0;r<=t.repeat;r++)e=kr(e+this.cycleDuration(r));return e}isFinished(t){return t>=this.totalDuration}resolve(t){let{config:e}=this,r=kr(t),i,o;if(e.delayDirection==="start-once"){let u=kr(e.delay+e.duration);if(r<u)i=0,o=r;else{let p=kr(r-u);i=1+Math.floor(kr(p/e.duration)),o=kr(p%e.duration)}}else if(S1(e.direction)){let u=this.cycleDuration(0),p=kr(u+e.duration),h=Math.floor(kr(r/p)),f=kr(r%p);f<u?(i=h*2,o=f):(i=h*2+1,o=kr(f-u))}else{let u=this.cycleDuration(0);i=Math.floor(kr(r/u)),o=kr(r%u)}if(e.repeat!==-1&&i>=e.repeat+1)return null;let{startDelay:a}=this.layout(i),s=S1(e.direction)&&i%2===1,l=a,c=kr(l+e.duration),d;if(o<l)d=s?e.duration:0;else if(o>=c)d=s?0:e.duration;else{let u=kr(o-l);d=s?kr(e.duration-u):u}return{cycleIndex:i,localTime:d,isReverse:s}}};function PD(n,t){return{duration:t,delay:kr(n.delay/1e3),delayDirection:n.delayDirection??"start-end",direction:n.direction??"normal",repeat:n.repeat}}var w1=Math.fround;function cH(n,t){let e=n.length,r=0,i=e;for(;r<i;){let o=r+Math.floor(e/2),a=n[o].time;if(a<t)r=o+1;else if(a>t)i=o;else return{found:!0,index:o};e=i-r}return{found:!1,index:r}}function MD(n,t){if(n.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(t<=n[0].time)return{index0:0,index1:0,t:1};let{found:e,index:r}=cH(n,t);if(e)return{index0:r,index1:r,t:1};if(r>=n.length){let u=n.length-1;return{index0:u,index1:u,t:1}}let i=r-1,o=r,a=n[i].time,s=n[o].time;if(s===a)return{index0:i,index1:o,t:.5};let l=w1(s-a),c={...n[i].ease,control2:n[o].ease.control2},d=Ag(c,l,w1(w1(t-a)/l));return{index0:i,index1:o,t:d}}function OD(n){return[...n].sort((t,e)=>t.time-e.time)}var Ep=Math.fround;function js(n){return Math.round(n*1e9)}function dH(n){let t=Math.trunc(n/1e9),e=n-t*1e9;return Ep(Ep(t)+Ep(Ep(e)/Ep(1e9)))}function ID(n,t){return dH(js(n)-js(t))}function Xc(n,t){return(js(n)+js(t))/1e9}function Cg(n,t,e){return js(n)-js(t)<js(e)}var uH=Math.fround;function DD(n){return n==="pingpong"||n==="pingpong-rewind"}function RD(n,t){return t?n==="start"?"end":n==="end"?"start":n:n}var Tg=class{constructor(t,e,r={}){this.hooks=r;this.isPlaying=!1;this.playingIndex=0;this.seekIndex=-1;this.currentRepeat=0;this.isReversed=!1;this.startTime=0;this.isToggledForward=!1;this.hasPlayedOnce=!1;this.isFirstTweenAfterStart=!1;this.hasClaimed=!1;this.config=t,this.tweens=e,this.delay=uH(t.delay/1e3)}get currentTween(){return this.tweens[this.playingIndex]}play(t){if(this.tweens.length===0||this.isPlaying&&this.config.runMode!=="Toggle"||this.hasPlayedOnce&&this.config.runMode==="Once")return;let e=this.isPlaying;this.isPlaying=!0,this.hasPlayedOnce=!0,this.currentRepeat=this.config.repeat,this.startTime=t,this.seekIndex=-1,this.hooks.isOwner?.()===!1&&(this.isToggledForward=!1,!e&&!this.isReversed&&this.hooks.assignCurrentState?.()),this.hasClaimed=!1,this.config.runMode==="Toggle"?(this.toggleDirection(),e?this.openPass():this.startChain()):this.startChain()}stop(){this.currentTween?.stop(),this.isPlaying=!1,this.isReversed=!1,this.hasClaimed=!1}playDirected(t,e){if(this.tweens.length===0)return;let r=this.isPlaying;if(r&&this.isForward===e)return;this.isPlaying=!0,this.hasPlayedOnce=!0,this.currentRepeat=this.config.repeat,this.startTime=t,this.seekIndex=-1,this.isToggledForward=e,this.isReversed=!e,this.hooks.isOwner?.()===!1&&!r&&!this.isReversed&&this.hooks.assignCurrentState?.(),this.hasClaimed=!1,r?this.openPass():this.startChain()}get isAnimating(){return this.isPlaying&&this.hasClaimed}get isForward(){return!this.isReversed}seek(t){if(this.tweens.length===0)return;let r=this.tweens.reduce((s,l)=>s+l.duration,0)*t,i=this.tweens.length-1,o=1,a=0;for(let s=0;s<this.tweens.length;s++){let l=this.tweens[s];if(a+l.duration>r){i=s,o=(r-a)/l.duration;break}a+=l.duration}for(this.seekIndex===-1&&(this.seekIndex=0);this.seekIndex<i;)this.tweens[this.seekIndex].seek(1),this.seekIndex+=1,this.tweens[this.seekIndex].rearm();for(;this.seekIndex>i;)this.tweens[this.seekIndex].seek(0),this.seekIndex-=1;this.tweens[i].seek(o)}update(t){if(!this.isPlaying)return;if(this.claimWhenDue(t),this.hasClaimed&&this.hooks.isOwner?.()===!1){this.stop();return}let e=RD(this.config.delayDirection,this.isReversed);if(Cg(t,this.startTime,this.leadingDelay)||(this.currentTween.update(t),!this.isPlaying)||this.currentTween.isPlaying)return;if(this.isFirstTweenAfterStart=!1,this.isReversed?this.playingIndex>0:this.playingIndex<this.tweens.length-1){this.advanceToNextTween();return}let i=0;if(e==="end"||e==="start-end"){if(Cg(t,this.currentTween.endTime,this.delay))return;i=this.delay}if(this.currentRepeat===0){this.stop();return}this.currentRepeat>0&&(this.currentRepeat-=1),DD(this.config.direction)&&(this.config.runMode==="Toggle"?this.toggleDirection():this.isReversed=!this.isReversed),this.startTime=Xc(this.currentTween.endTime,i),this.playingIndex=this.isReversed?this.tweens.length-1:0,this.config.direction==="normal"&&this.currentTween.seek(this.currentTween.isReversed?1:0),this.openPass()}advanceToNextTween(){let t=this.currentTween;t.isPingpong&&t.config.repeat%2===1&&t.seek(t.isReversed?0:1);let e=t.endTime,r=this.isReversed;this.playingIndex+=r?-1:1;let i=this.currentTween;r&&i.isPingpong&&i.config.repeat%2===1&&i.seek(1),this.resume(e)}startChain(){this.playingIndex=this.isReversed?this.tweens.length-1:0,this.isFirstTweenAfterStart=!0,this.openPass()}openPass(){this.claimWhenDue(this.startTime);let t=this.tweens[0];this.hasClaimed&&!this.isReversed&&t&&t.duration===0&&(t.seek(1),!this.isPlaying)||this.resume(Xc(this.startTime,this.leadingDelay))}claimWhenDue(t){this.hasClaimed||Cg(t,this.startTime,this.leadingDelay)||(this.hasClaimed=!0,this.hooks.claim?.())}get leadingDelay(){let t=RD(this.config.delayDirection,this.isReversed);return t==="start-once"?this.isFirstTweenAfterStart?this.delay:0:t!=="start"&&t!=="start-end"||this.isReversed||this.playingIndex!==0||DD(this.config.direction)&&!this.isFirstTweenAfterStart?0:this.delay}resume(t){let e=this.currentTween;this.isReversed&&this.config.direction==="pingpong-rewind"&&(e.overrideDirection="pingpong-rewind"),e.isReversed=this.isReversed?!(e.repeatDirection!=="normal"&&e.config.repeat%2===1):!1,e.start(t)}toggleDirection(){this.isToggledForward=!this.isToggledForward,this.isReversed=!this.isToggledForward}};var to=Math.fround,Yc=class{constructor(t,e,r){this.apply=e;this.onStart=r;this.isPlaying=!1;this.isReversed=!1;this.endTime=0;this.startTime=0;this.isFirstLerpAfterStart=!1;this.config=t,this.duration=x1(t.ease,to(t.duration/1e3)),this.delay=to(t.delay/1e3),this.currentRepeat=t.repeat}get repeatDirection(){return this.overrideDirection??this.config.direction}get isPingpong(){let t=this.repeatDirection;return t==="pingpong"||t==="pingpong-rewind"}get actualDelayDirection(){return this.isReversed?this.config.delayDirection==="start"?"end":this.config.delayDirection==="end"?"start":this.config.delayDirection:this.config.delayDirection}start(t){this.isPlaying=!0,this.currentRepeat=this.config.repeat,this.isFirstLerpAfterStart=!0,this.startTime=t,this.onStart?.()}stop(){this.isPlaying=!1}rearm(){this.onStart?.()}seek(t){this.lerp(t)}update(t){if(!this.isPlaying)return;let e=ID(t,this.startTime),r=0;if(this.isFirstLerpAfterStart||!this.isPingpong){let a=this.actualDelayDirection;if(this.config.delayDirection==="start-once"&&this.isFirstLerpAfterStart||a==="start"||a==="start-end"){if(e<this.delay)return;r=this.delay}}e=to(e-r);let i=this.duration===0?1:Math.min(Math.max(to(e/this.duration),0),1);if(this.lerp(i),!this.isPlaying||i!==1)return;let o=this.actualDelayDirection;if(o==="end"||o==="start-end"){if(e<to(this.duration+this.delay))return;this.endTime=Xc(this.startTime,to(to(r+this.duration)+this.delay))}else this.endTime=Xc(this.startTime,to(r+this.duration));if(this.isFirstLerpAfterStart=!1,this.currentRepeat===0){this.stop();return}this.currentRepeat>0&&(this.currentRepeat-=1),this.isPingpong?this.isReversed=!this.isReversed:this.lerp(0),this.startTime=t,this.onStart?.()}lerp(t){this.repeatDirection==="pingpong-rewind"&&this.isReversed?(t=to(1-t),t=this.ease(t),t=to(1-t)):t=this.ease(t),this.apply(t)}ease(t){return Ag(this.config.ease,this.duration,t)}};import{EventDispatcher as ZH}from"three";var A1=class{constructor(){this.clock=new vg;this.tickables=new Set;this.pendingRemovals=new Set;this.rafId=null;this.isFlushing=!1;this.useInternalRaf=!0;this.step=t=>{this.rafId=null,this.clock.tick(t),this.flush(),this.tickables.size>0&&this.requestFrame()}}get isUsingInternalRaf(){return this.useInternalRaf}set isUsingInternalRaf(t){this.useInternalRaf=t,t?(this.clock.resync(Pg()),this.requestFrame()):this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}get time(){return this.clock.time}get running(){return this.tickables.size>0}add(t){this.pendingRemovals.delete(t),this.tickables.size===0&&this.rafId===null&&this.clock.resync(Pg()),this.tickables.add(t),this.requestFrame()}remove(t){if(this.isFlushing){this.pendingRemovals.add(t);return}this.tickables.delete(t)}init(){this.clock.resync(Pg())}dispose(){this.removeAll(),this.clock.reset()}removeAll(){this.tickables.clear(),this.pendingRemovals.clear(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}update(t){this.clock.step(t/1e3),this.flush()}pause(){this.clock.paused=!0}resume(){this.clock.paused=!1,this.clock.resync(Pg()),this.requestFrame()}requestFrame(){this.rafId!==null||!this.useInternalRaf||this.tickables.size!==0&&(typeof requestAnimationFrame>"u"||(this.rafId=requestAnimationFrame(this.step)))}flush(){let t=this.clock.time;this.isFlushing=!0;try{for(let e of this.tickables)this.pendingRemovals.has(e)||e.update(t)}finally{this.isFlushing=!1;for(let e of this.pendingRemovals)this.tickables.delete(e);this.pendingRemovals.clear()}}};function Pg(){return typeof performance<"u"?performance.now():Date.now()}var li=new A1;function pH(n){return{easing:n.type,control1:bo(n.cubicControls?.control1,[0,0]),control2:bo(n.cubicControls?.control2,[1,1]),...n.springParameters}}function Hs(n,t){let e=[];for(let r of n??[]){let i=t(r.data);i!==void 0&&e.push({time:r.data.time,ease:pH(r.data.easing),value:i})}return{keyframes:OD(e)}}function vn(n,t){if(n.keyframes.length===0)return;let{index0:e,index1:r,t:i}=MD(n.keyframes,t),o=n.read;if(o&&o.index0===e&&o.index1===r&&o.t===i)return;let a={index0:e,index1:r,from:n.keyframes[e].value,to:n.keyframes[r].value,t:i};return n.read=a,a}function BD(n){n.read=void 0}function Cp(n,t,e){return n+(t-n)*e}import{MathUtils as Ig}from"three";import{PointLight as fH,Vector3 as Mg,Box3 as mH,Box3Helper as ND,Color as yH}from"three";import{PointLightHelper as hH}from"three";var Qc=class extends Vn(hH){constructor(e,r=15,i=6710886){super(e,r,i);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Gn(this.object,Qc.geometryHelper,e,r)}};var Ws=class extends Fc(fH,Qc){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let a=new Mg(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new Mg(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),l=new mH(a,s),c=new ND(l,new yH(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ND){let r=this.shadow.camera,i=new Mg(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),o=new Mg(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(i,o),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};import{Color as LD,Euler as gH,MathUtils as Kc,Matrix4 as _D,Quaternion as E1,Vector2 as Tp,Vector3 as Va}from"three";var{degToRad:Hwe,radToDeg:Wwe}=Kc,FD=new Va,kD=new Va,VD=new E1;function UD(n,t,e,r){if(r===0)return e.copy(n);if(r===1)return e.copy(t);let i=n.w*t.w+n.x*t.x+n.y*t.y+n.z*t.z;if(i>=1)return e.copy(n);let o=1-i*i;if(o<=Number.EPSILON){let d=1-r;return e.w=d*n.w+r*t.w,e.x=d*n.x+r*t.x,e.y=d*n.y+r*t.y,e.z=d*n.z+r*t.z,e.normalize(),e}let a=Math.sqrt(o),s=Math.atan2(a,i),l=Math.sin((1-r)*s)/a,c=Math.sin(r*s)/a;return e.w=n.w*l+t.w*c,e.x=n.x*l+t.x*c,e.y=n.y*l+t.y*c,e.z=n.z*l+t.z*c,e}function rr(n,t,e,r,i,o){let a=e[n]!==void 0?e[n]:void 0,s=r[n];if(s==null)return;let l=a!=null?typeof a=="string"?Number(i.getVariable(a)??0):a:t[n],c=typeof s=="string"?Number(i.getVariable(s)??0):s;if(l!==c)return{update:d=>{let u=Kc.lerp(l,c,d);o?t[n]=Math.trunc(u):t[n]=u},start:()=>{t[n]=l},end:()=>{t[n]=c}}}function Mp(n,t,e,r,i,o){let a=e[n]?e[n]:void 0,s=r[n];if(!s)return;let l=t[n],c=[...a??l].map(u=>typeof u=="string"?Number(i.getVariable(u)??0):u),d=[...s].map(u=>typeof u=="string"?Number(i.getVariable(u)??0):u);if(!(c.length!==d.length||Ao(c,d)))return{update:u=>{c.forEach((p,h)=>{let f=Kc.lerp(p,d[h],u);t[n][h]=o?Math.trunc(f):f})},start:()=>{Object.assign(t[n],c)},end:()=>{Object.assign(t[n],d)}}}function Pp(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function C1(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=o?Pp(new Va,o,i):s.clone(),c=Pp(new Va,a,i);if(!l.equals(c))return{update:d=>{s.lerpVectors(l,c,d)},start:()=>{s.copy(l)},end:()=>{s.copy(c)}}}function GD(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function Zc(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=!(s instanceof Tp),c=s instanceof Tp?s:new Tp().fromArray(s),d=o?GD(new Tp,o,i):c.clone(),u=GD(new Tp,a,i);if(!d.equals(u))return{update:p=>{c.lerpVectors(d,u,p),l&&(t[n]=c.toArray())},start:()=>{c.copy(d),l&&(t[n]=c.toArray())},end:()=>{c.copy(u),l&&(t[n]=c.toArray())}}}function zD(n,t,e,r){let i=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],s=i?new _D().fromArray(i):a.clone(),l=new Va,c=new E1,d=new Va;s.decompose(l,c,d);let u=new _D().fromArray(o),p=new Va,h=new E1,f=new Va;if(u.decompose(p,h,f),!s.equals(u))return{update:m=>{VD.slerpQuaternions(c,h,m),FD.lerpVectors(l,p,m),kD.lerpVectors(d,f,m),a.compose(FD,VD,kD)},start:()=>{a.compose(l,c,d)},end:()=>{a.compose(p,h,f)}}}function jD(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=o?typeof o=="string"?i.getColor(o).clone():new LD().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?i.getColor(a).clone():new LD().setRGB(a.r,a.g,a.b);if(l.equals(c))return;let d=s.clone();return{update:u=>{d.lerpColors(l,c,u),t[n]?.copy?.(d)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function Op(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=new Pt(s.r,s.g,s.b,s.a),c=o?typeof o=="string"?i.getColor(o).clone():new Pt(o.r,o.g,o.b,o.a):l.clone(),d=typeof a=="string"?i.getColor(a).clone():new Pt(a.r,a.g,a.b,a.a);if(!c.equals(d))return{update:u=>{l.lerpColors(c,d,u);let p=Kc.lerp(c.a,d.a,u);l.a=p,t[n]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(d)}}}function ro(n,t,e,r,i){if(typeof t[n]=="number")return rr(n,t,e??{},r,i);if(Array.isArray(t[n]))return Mp(n,t,e??{},r,i)}var qwe=new gH;function HD(n,t){if(!!n)for(let[e,r]of Object.entries(t)){let i=n[e];if(Array.isArray(i)&&Array.isArray(r)){let o=Math.min(i.length,r.length);for(let a=0;a<o;a++)i[a]=r[a]}else n[e]=r}}function Jc(n,t,e,r){let i={};if(!t||!e)return i;for(let o of n){let a=t[o],s=e[o];if(typeof a=="number"&&typeof s=="number")i[o]=Kc.lerp(a,s,r);else if(Array.isArray(a)&&Array.isArray(s)){let l=Math.min(a.length,s.length);i[o]=Array.from({length:l},(c,d)=>Kc.lerp(a[d],s[d],r))}}return i}function WD(n,t,e,r){let i=[];if(!("cloner"in e)||!n.cloner)return i;let o=n.cloner,a="cloner"in t?t.cloner:{},s=e.cloner;tb.forEach(h=>{let f;h==="count"?f=rr("count",o.parameters,a,s,r.shared,!0):f=ro(h,o.parameters,a??{},s,r.shared),f&&i.push(f)});let l=vH(o,a,s,r.shared);l?.length&&i.push(...l);let c=bH(o,a,s,r.shared);c?.length&&i.push(...c);let d=xH(o,a,s,r.shared);d?.length&&i.push(...d);let u=SH(o,a,s,r.shared);u?.length&&i.push(...u);let p=wH(o,a,s,r.shared);return p?.length&&i.push(...p),i.length&&i.push({update:()=>{o.update(r)}}),i}function vH(n,t,e,r){if(n.parameters.type!=="radial")return;let i=t.radial,o=e.radial;if(!o)return;let a=n.parameters.radial,s=[];return Nh.forEach(l=>{let c=ro(l,a,i??{},o,r);c&&s.push(c)}),s}function bH(n,t,e,r){if(n.parameters.type!=="linear")return;let i=t.linear,o=e.linear;if(!o)return;let a=[],s=n.parameters.linear;return Lh.forEach(l=>{let c=ro(l,s,i??{},o,r);c&&a.push(c)}),a}function xH(n,t,e,r){if(n.parameters.type!=="grid")return;let i=t.grid,o=e.grid;if(!o)return;let a=[],s=n.parameters.grid;return _h.forEach(l=>{let c;l==="count"?c=Mp(l,s,i??{},o,r,!0):c=ro(l,s,i??{},o,r),c&&a.push(c)}),a}function SH(n,t,e,r){if(n.parameters.type!=="toObject")return;let i=t.toObject,o=e.toObject;if(!o)return;let a=[],s=n.parameters.toObject;return Fh.forEach(l=>{let c;l==="count"?c=rr(l,s,i??{},o,r,!0):c=ro(l,s,i??{},o,r),c&&a.push(c)}),a}function wH(n,t,e,r){if(!n.parameters.randomness)return;let i=t.randomnessObject,o=e.randomnessObject;if(!o)return;let a=[],s=n.parameters.randomnessObject;return kh.forEach(l=>{let c=ro(l,s,i??{},o,r);c&&a.push(c)}),a}var qD=[["radial",Nh],["linear",Lh],["grid",_h],["toObject",Fh],["randomnessObject",kh]];function XD(n,t,e,r){if(!n)return{};let i=Jc(["count"],t,e,r);i.count!==void 0&&(i.count=Math.trunc(i.count));for(let[o,a]of qD){if(!n[o])continue;let s=Jc(a,t[o],e[o],r);Object.keys(s).length&&(i[o]=s)}return i}function YD(n,t){if(!!n){t.count!==void 0&&(n.count=t.count);for(let[e]of qD){let r=t[e];r&&HD(n[e],r)}}}import{Color as Og,Vector2 as T1,Vector3 as P1,MathUtils as qs}from"three";function KD(n,t,e,r){let i=[];if(Array.isArray(n.material)){if(!("materials"in e&&e.materials))return i;let o="materials"in t&&t.materials?t.materials:[],a=e.materials;n.material.forEach((s,l)=>{if(!a[l])return;let c=o[l]??{},d=a[l];typeof c=="string"||typeof d=="string"||i.push(...QD(s,c,d,r))})}else{if(!("material"in e&&e.material))return i;let o="material"in t&&t.material?t.material:{},a=e.material;if(typeof o=="string"||typeof a=="string")return i;i.push(...QD(n.material,o,a,r))}return i}function AH(n,t,e){let r=n.ensureRainbowNoiseCompiled;if(typeof r=="function")for(let i of[...n.layers]){if(i.type!=="rainbow")continue;let o=t.layers?.data(i.uuid),a=e.layers.data(i.uuid);(dn(o?.noiseStrength)||dn(a?.noiseStrength))&&r.call(n,i.uuid)}}function ZD(n,t,e,r,i){let o=n.getValue(r);if(o!==void 0){if(r==="colors")return IH(n,t,e,r);if(Array.isArray(o))return r==="steps"?OH(n,t,e,r):void 0;if(typeof o=="number")return EH(n,t,e,r,i);if(typeof o!="boolean"){if(o instanceof T1)return CH(n,t,e,r);if(o instanceof P1)return TH(n,t,e,r,i);if(o instanceof Pt)return MH(n,t,e,r,i);if(o instanceof Og)return PH(n,t,e,r,i);if("isTexture"in o)return RH(n,t,e,r)}}}function QD(n,t,e,r){let i=[],o=kn(e,r)||!!t.layers&&kn(t,r);i.push(BH(n,o)),AH(n,t,e);for(let a of n.layers){let s=t.layers?.data(a.uuid),l=e.layers.data(a.uuid);if(!l||a.type!=="light"&&(!(a.visible??!0)||!(l.visible??!0)))continue;let c=tc[a.type]??[],d=a.getNames().filter(u=>!c.includes(u)&&!jh.some(p=>u.includes(p)));for(let u of d)try{let p=ZD(a,s,l,u,r);p&&(Array.isArray(p)?i.push(...p):i.push(p))}catch(p){console.error(`lerpMaterial: unexpected material layer for ${u}`,p)}}return i}function EH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=t?t[r]:n.getValue(r),a=e[r],s=typeof o=="string"?Number(i.getVariable(o)??0):o,l=typeof a=="string"?Number(i.getVariable(a)??0):a;return{update:c=>{n.setValue(r,qs.lerp(s,l,c))},start:()=>{n.setValue(r,s)},end:()=>{n.setValue(r,l)}}}function CH(n,t,e,r){if(!n.hasValue(r)||!(r in e))return;let i=n.getValue(r),o=t?new T1().fromArray(t[r]):i.clone(),a=new T1().fromArray(e[r]);if(!o.equals(a))return{update:s=>{i.lerpVectors(o,a,s)},start:()=>{i.copy(o)},end:()=>{i.copy(a)}}}function TH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=n.getValue(r),a=t?t[r]:void 0,s=e[r],l=a?Pp(new P1,a,i):o.clone(),c=Pp(new P1,s,i);if(!l.equals(c))return{update:d=>{o.lerpVectors(l,c,d)},start:()=>{o.copy(l)},end:()=>{o.copy(c)}}}function PH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=t?t[r]:void 0,a=e[r],s=n.getValue(r),l=o?typeof o=="string"?i.color(o).clone():new Og().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?i.color(a).clone():new Og().setRGB(a.r,a.g,a.b);if(l.equals(c))return;let d=s.clone();return{update:u=>{n.getValue(r)!==d&&n.setValue(r,d),d.lerpColors(l,c,u)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function MH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=t?t[r]:void 0,a=e[r],s=n.getValue(r),l=o?typeof o=="string"?i.color(o).clone():new Og().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?i.color(a).clone():new Pt(a.r,a.g,a.b,a.a);if(l.equals(c))return;let d=s.clone();return{update:u=>{n.getValue(r)!==d&&n.setValue(r,d),d.lerpColors(l,c,u)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function OH(n,t,e,r="steps"){if(!n.hasValue(r)||!(r in e))return;let i=[],o=n.getValue(r),a=t?t[r]:o,s=e[r];return Ao(a,s)||i.push({update:l=>{let c=[...o];for(let d=0;d<o.length;++d){let u=a[d],p=s[d];c[d]=qs.lerp(u,p,l)}n.setValue(r,c)},start:()=>{n.setValue(r,a)},end:()=>{n.setValue(r,s)}}),i.length?i:void 0}function IH(n,t,e,r="colors"){if(!n.hasValue(r)||!(r in e))return;let i=[],o=n.getValue(r),a=t?t[r]:o.map(l=>l.toArray()),s=e[r];for(let l=0;l<o.length;++l){let c=[...a[l]],d=[...s[l]];as.isEqual(c,d)||i.push({update:u=>{o[l].fromArray(as.lerp(c,d,u))},start:()=>{o[l].fromArray(c)},end:()=>{o[l].fromArray(d)}})}return i.length?i:void 0}function DH(n){let t=n.getNode("mat");if(typeof t?.updateMatrix=="function")return t;let e=n.getValue("mat");return typeof e?.updateMatrix=="function"?e:void 0}function RH(n,t,e,r="texture"){if(!n.hasValue(r)||!(r in e))return;let i=n.getNode("rotation"),o=t?.[r]?.rotation??0,a=e[r]?.rotation??0;if(i&&o!==a)return{update:y=>{i.value=qs.lerp(o,a,y)*qs.DEG2RAD},start:()=>{i.value=o*qs.DEG2RAD},end:()=>{i.value=a*qs.DEG2RAD}};let s=DH(n);if(!s)return;let l=t?t[r]:s,c=e[r],d=[...l.repeat],u=[...l.offset],p=[...c.repeat],h=[...c.offset],f=l.rotation??0,m=c.rotation??0;if(!xi.isEqual(d,p)||!xi.isEqual(u,h)||f!==m)return{update:y=>{s.repeat=xi.lerp(d,p,y),s.offset=xi.lerp(u,h,y),s.rotation=qs.lerp(f,m,y),s.updateMatrix()},start:()=>{s.repeat=[...d],s.offset=[...u],s.rotation=f,s.updateMatrix()},end:()=>{s.repeat=[...p],s.offset=[...h],s.rotation=m,s.updateMatrix()}}}function M1(n,t,e,r,i,o){let a=ZD(t,e,r,n,o);!a||(Array.isArray(a)?a.forEach(s=>s.update(i)):a.update(i))}function BH(n,t){return{update:()=>{n.transparent=t}}}function JD(n,t,e,r,i){let o=NH(n,t);return{duration:e,evaluate(a,s){n.resetBBoxNeedsUpdate();let l=_H();for(let c of o)kH(c,n,a,r,i,s,l);FH(n,l,r)},invalidate(){for(let a of o)BD(a.track)}}}function NH(n,t){let e=[];return xo.groupKeyframes(t.keyframes).forEach(r=>{let i=r.path?.[0],o=r.path[1],a=()=>Hs(r.keyframes,s=>s.value);switch(i){case"position":case"rotation":case"scale":o&&xl.includes(o)&&e.push({on:i,axis:o,track:a()});return;case"shape size":o&&xl.includes(o)&&"geometry"in n&&e.push({on:"shapeSize",axis:o,track:a()});return;case"path extrusion":fs(n)&&e.push({on:"pathExtrusion",track:Hs(r.keyframes,s=>s.value)});return;case"path snapping":n.data.pathSnapping&&e.push({on:"pathSnapping",track:Hs(r.keyframes,s=>s.value)});return;case"material":n.type==="Mesh"&&"material"in n&&LH(n,r).forEach(s=>e.push(s));return;case"opacity":n.type==="Mesh"&&"material"in n&&e.push({on:"opacity",track:a()});return;case"cloner":e.push({on:"cloner",track:Hs(r.keyframes,s=>s.value)});return;case"camera":n instanceof St&&e.push({on:"camera",field:"zoom",track:a()});return;case"light":(n instanceof Uo||n instanceof Ws||n instanceof zo)&&e.push({on:"light",field:r.path[1],track:Hs(r.keyframes,s=>s.value)});return}}),e}function LH(n,t){let e=fm(n.material)?n.material:void 0,r=t.layerId;if(!e||!r)return[];let i=t.keyframes.some(d=>dn(d.data.value?.noiseStrength)),o=e.ensureRainbowNoiseCompiled,a=d=>{i&&typeof o=="function"&&o.call(e,d)},s=d=>"data"in d?[{on:"material",layer:d,track:Hs(t.keyframes,u=>u.value)}]:[];a(r);let l=e.getLayerByUuid(r);if(l)return s(l);let c=t.path[1];for(let d of e.getLayersOfType(c))a(d.uuid);return(e.getLayersOfType(c)??[]).flatMap(s)}function _H(){return{transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1}}function FH(n,t,e){if(t.size&&n instanceof Qe){let{x:r,y:i,z:o}=n.userData.value;n.updateGeometryInteractions({width:r,height:i,depth:o},e.shared)}t.cloner&&n.cloner?.update(e),t.transform&&n.updateMatrix(),t.bounds&&n.resetBBoxNeedsUpdate(),t.boolean&&n instanceof Qe&&n.invalidateDownstreamBooleanData(),t.render&&n.dispatchEvent({type:"requestRender"})}function Yo(n,t,e){!n||(n[t]={...n[t],...e})}function kH(n,t,e,r,i,o,a){let s=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(n.on){case"position":case"scale":{let l=vn(n.track,e);if(!l)return;let c=Cp(l.from,l.to,l.t);t[n.on][n.axis]=c,Yo(o,n.on,{[n.axis]:c}),s();return}case"rotation":{let l=vn(n.track,e);if(!l)return;let c=Cp(l.from,l.to,l.t);t.rotation[n.axis]=c*Ig.DEG2RAD,Yo(o,"rotation",{[n.axis]:c}),s();return}case"shapeSize":{let l=vn(n.track,e);if(!l||!(t instanceof Qe))return;let c=Cp(l.from,l.to,l.t);t.userData.value={...t.userData.value,[n.axis]:c},Yo(o,"shapeSize",{[n.axis]:c}),a.size=!0,a.bounds=!0,a.boolean=!0,a.render=!0;return}case"opacity":{let l=vn(n.track,e);if(!l||!(t instanceof Je)||Array.isArray(t.material))return;let c=t.material.getLayersOfType("light")[0];if(c===void 0)return;let d=Ig.lerp(l.from,l.to,l.t);t.material.transparent=!0,M1("alphaOverride",c,{alphaOverride:d},{alphaOverride:d+1},0,r.shared),o&&(o.opacity=d),a.render=!0;return}case"material":{let l=vn(n.track,e);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:c}=n,d={};for(let u in c.data){if(!(u in l.from)||!(u in l.to))continue;let p=O1(l.from[u],l.to[u],l.t,i);if(p===void 0)continue;d[u]=p;let h=c.getValue(u);h!==void 0&&(u==="alpha"&&typeof h=="number"&&h>0&&t instanceof Je&&!Array.isArray(t.material)&&(t.material.transparent=!0),M1(u,c,l.from,l.to,l.t,r.shared))}Yo(o,"material",{[c.uuid]:d}),a.render=!0;return}case"light":{let l=vn(n.track,e);if(!l||!(t instanceof Uo||t instanceof Ws||t instanceof zo))return;let c=O1(l.from,l.to,l.t,i);t[n.field]=c,Yo(o,"light",{[n.field]:c}),a.render=!0;return}case"camera":{let l=vn(n.track,e);if(!l||!(t instanceof St))return;let c=Cp(l.from,l.to,l.t);t[n.field]=c,Yo(o,"camera",{[n.field]:c});return}case"cloner":{let l=vn(n.track,e);if(!l)return;let d=t.cloner?.parameters,u=XD(d,l.from,l.to,l.t);YD(d,u),Yo(o,"cloner",u),a.cloner=!0,a.boolean=!0,a.render=!0;return}case"pathExtrusion":{let l=vn(n.track,e);if(!l||!fs(t))return;let c=Jc(Wd,l.from,l.to,l.t),d=t.geometry.userData.parameters;d.extrusion={...d.extrusion,...c},Yo(o,"pathExtrusion",c),t.updateGeometryInteractions({extrusion:{...d.extrusion}},r.shared),a.bounds=!0,a.boolean=!0,a.render=!0;return}case"pathSnapping":{let l=vn(n.track,e);if(!l)return;let c=t,d=Jc(yE,l.from,l.to,l.t);c.userData.pathSnapping={...c.userData.pathSnapping,...d},Yo(o,"pathSnapping",d),c.updatePathSnapping(c.userData.pathSnapping),a.render=!0;return}}}function O1(n,t,e,r){if(typeof n=="string"&&r&&(n=r.color(n)),typeof t=="string"&&r&&(t=r.color(t)),typeof n=="number")return Ig.lerp(n,t,e);if(Ue.is(n))return Ue.lerp(n,t,e);if(Ut.is(n))return Ut.lerp(n,t,e);if(Array.isArray(n))return(n.length>t.length?t:n).map((o,a)=>{if(Array.isArray(o)){let s=n[a].length>t[a].length?t[a].length:n[a].length;return(s===4?as:s===3?Ni:xi).lerp(n[a],t[a],e)}return Ig.lerp(n[a],t[a],e)});if(typeof n=="object"&&n!==null){let i={};for(let o in n){let a=O1(n[o],t[o],e,r);a!==void 0&&(i[o]=a)}return i}}import{MathUtils as VH}from"three";function $D(n,t,e,r){let i=[],o=n.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,a=n.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(a!==void 0){let s=o??n.zoom,l=a;s!==l&&i.push({update:c=>{n.zoom=VH.lerp(s,l,c),n.updateProjectionMatrix()},start:()=>{n.zoom=s,n.updateProjectionMatrix()},end:()=>{n.zoom=l,n.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let s=rr("targetOffset",n,t,e,r);s&&i.push(s)}return i}import{MathUtils as I1}from"three";function GH(n,t,e,r){if(e.scaleBaked===void 0)return;let i=(t.scaleBaked??n.data.geometry.scaleBaked).map(s=>typeof s=="string"?Number(r.shared.getVariable(s)??0):s),o=e.scaleBaked.map(s=>typeof s=="string"?Number(r.shared.getVariable(s)??0):s);if(Ni.isEqual(i,o))return;let a=[];return a.push({update:s=>{n.updateGeometryInteractions({scaleBaked:[I1.lerp(i[0],o[0],s),I1.lerp(i[1],o[1],s),I1.lerp(i[2],o[2],s)]},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)},start:()=>{n.updateGeometryInteractions({scaleBaked:i},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)},end:()=>{n.updateGeometryInteractions({scaleBaked:o},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)}}),a}function UH(n,t,e,r){if(!e.extrusion)return;let i=n.extrusion,o=t.extrusion??{},a=e.extrusion,s=[];return Wd.forEach(l=>{let c=ro(l,i,o,a,r);c&&s.push(c)}),s}function eR(n,t,e,r){let i=[];if(!("geometry"in e))return i;let o=n.geometry.userData.parameters,a="geometry"in t?t.geometry:{},s=e.geometry;if(n instanceof Ro){let l=GH(n,a,s,r);l&&i.push(...l)}else{let l={};if(Object.assign(l,Jd(o,Yh),Jd(a,Yh)),Yh.forEach(c=>{let d=ro(c,l,a,s,r.shared);d&&i.push(d)}),fs(n)){Object.assign(l,{extrusion:{...o.extrusion}});let c=UH(l,a,s,r.shared);c&&i.push(...c)}i.length&&i.push({update:c=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)},start:c=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)},end:c=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)}})}return i}function tR(n,t,e,r){let i=[];if(e.intensity!==void 0){let o=rr("intensity",n,t,e,r);o&&i.push(o)}if(e.color!==void 0){let o=jD("color",n,t,e,r);o&&i.push(o)}return i}import{Euler as zH,Vector3 as Dg,MathUtils as rR}from"three";import{Quaternion as iR}from"three";var D1=new Dg,nR=new zH;function oR(n,t,e,r,i){let o=[],a,s,l,c,d,u,p,h;if(Br(n)?(a=Zc("position",n,t,e,i),a&&o.push(a),l=rr("rotation",n,t,e,i),l&&o.push(l),c=Zc("shear",n,t,e,i),c&&o.push(c)):(h={slide:t.pathSnapping?.slide??n.updatedPathSnapping?.slide??n.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??n.updatedPathSnapping?.offset??n.dataPatched.pathSnapping?.offset??0},u=rr("slide",h,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),u&&o.push(u),p=rr("offset",h,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),p&&o.push(p),!u&&!p&&(a=C1("position",n,t,e,i),a&&o.push(a),s=C1("scale",n,t,e,i),s&&o.push(s),l=jH(n,t,e,r,i),l&&o.push(l),d=zD("hiddenMatrix",n,t,e),d&&o.push(d))),a||s||l||d||u||p){let f=Br(n)?()=>{n.updateWorldMatrix(!0,!1,!0),n.resetBBoxNeedsUpdate()}:()=>{n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldRigid()),n.parent?.matrixWorldFusedFalse&&(n.matrixWorld.multiplyMatrices(n.parent.matrixWorldFusedFalse,n.matrix),n.matrixWorldNeedsUpdate=!1),gi(n)&&Ci(n.parent)&&n.invalidateDownstreamBooleanData(!0),n.updatePathSnapping(Object.assign({},t.pathSnapping,h))};o.push({update:f,start:f,end:f})}return o}function jH(n,t,e,r,i){let o=t?.rotation?t.rotation.map(d=>(typeof d=="string"?Number(i.getVariable(d)??0):d)*rR.DEG2RAD):void 0,a=e.rotation?.map(d=>(typeof d=="string"?Number(i.getVariable(d)??0):d)*rR.DEG2RAD);if(!a)return;let s=o?new Dg().fromArray(o):new Dg().setFromEuler(n.rotation),l=new Dg().fromArray(a);if(s.equals(l))return;let c=D1.subVectors(l,s);if(r&&c.toArray().every(d=>Math.abs(d)<2*Math.PI)){let d=new iR().setFromEuler(nR.setFromVector3(s)),u=new iR().setFromEuler(nR.setFromVector3(l));return{update:p=>{UD(d,u,n.quaternion,p)},start:()=>{n.rotation.setFromVector3(s)},end:()=>{n.rotation.setFromVector3(l)}}}else return{update:d=>{D1.lerpVectors(s,l,d),n.rotation.setFromVector3(D1)},start:()=>{n.rotation.setFromVector3(s)},end:()=>{n.rotation.setFromVector3(l)}}}function HH(n,t){return{update:()=>{n instanceof Rt&&(n.fill.enabled=t)}}}function WH(n,t){return{update:()=>{n instanceof Rt&&(n.stroke.enabled=t)}}}function qH(n,t){return{update:()=>{n instanceof Rt&&(n.dropShadow.enabled=t)}}}function XH(n,t){return{update:()=>{n instanceof Rt&&(n.innerShadow.enabled=t)}}}function YH(n,t){return{update:()=>{n instanceof Rt&&(n.backgroundBlur.enabled=t)}}}function QH(n,t){return{update:()=>{n instanceof Rt&&(n.layerBlur.enabled=t)}}}function aR(n,t,e,r,i){let o=[],a,s,l,c,d,u,p,h,f,m,y,g,b,x,S;if("width"in n&&(a=rr("width",n,t,e,i),a&&o.push(a)),"height"in n&&(s=rr("height",n,t,e,i),s&&o.push(s)),n instanceof Rt||n instanceof Lr){let v={...t.fill},w={...e.fill};v.enabled!==void 0&&v.enabled!==w.enabled&&(o.push(HH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),l=Op("color",n.fill,v,w,i),l&&o.push(l)}if(n instanceof Rt){let v={...t.stroke},w={...e.stroke};(v.enabled||w.enabled)&&(o.push(WH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),c=Op("color",n.stroke,v,w,i),c&&o.push(c),d=rr("thickness",n.stroke,v,w,i),d&&o.push(d)}if(n instanceof Rt){let v={...t.dropShadow},w={...e.dropShadow};(v.enabled||w.enabled)&&(o.push(qH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),u=Op("color",n.dropShadow,v,w,i),u&&o.push(u),p=rr("blurRadius",n.dropShadow,v,w,i),p&&o.push(p),f=rr("spread",n.dropShadow,v,w,i),f&&o.push(f),h=Zc("offset",n.dropShadow,v,w,i),h&&o.push(h)}if(n instanceof Rt){let v={...t.innerShadow},w={...e.innerShadow};(v.enabled||w.enabled)&&(o.push(XH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),m=Op("color",n.innerShadow,v,w,i),m&&o.push(m),y=rr("blurRadius",n.innerShadow,v,w,i),y&&o.push(y),b=rr("spread",n.innerShadow,v,w,i),b&&o.push(b),g=Zc("offset",n.innerShadow,v,w,i),g&&o.push(g)}if(n instanceof Rt||n instanceof Lr){let v={...t.backgroundBlur},w={...e.backgroundBlur};(v.enabled||w.enabled)&&(o.push(YH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,radius:0}),w.enabled||Object.assign(w,{enabled:!0,radius:0})),x=rr("radius",n.backgroundBlur,v,w,i),x&&o.push(x)}if(n instanceof Rt){let v={...t.layerBlur},w={...e.layerBlur};(v.enabled||w.enabled)&&(o.push(QH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,radius:0}),w.enabled||Object.assign(w,{enabled:!0,radius:0})),S=rr("radius",n.layerBlur,v,w,i),S&&o.push(S)}if(n instanceof Lr||n instanceof Yi){let v=Mp("cornerRadius",n,t,e,i);v&&o.push(v)}return o}function sR(n,t,e,r,i){let o=[];return n.data.visible&&o.push(...oR(n,t,e,i,r.shared)),Br(n)?o.push(...aR(n,t,e,i,r.shared)):(n.data.visible&&o.push(...WD(n,t,e,r)),n instanceof Je?(n instanceof Qe&&n.data.visible&&o.push(...eR(n,t,e,r)),n.data.visible&&!(n instanceof er&&n.materialOverride)&&o.push(...KD(n,t,e,r.shared))):Ry.is(n)?n.data.visible&&o.push(...tR(n,t,e,r.shared)):n instanceof St&&o.push(...$D(n,t,e,r.shared))),o.length?{update:a=>{o.forEach(s=>s.update(a))},start:a=>{o.forEach(s=>s.start?.(a))},end:a=>{o.forEach(s=>s.end?.(a))}}:void 0}var R1={type:"beginState"};function B1(n){if(n.easing===5){let{control1:t,control2:e}=n;return{easing:5,control1:t??ss.defaultData.control1,control2:e??ss.defaultData.control2}}if(n.easing===6){let{mass:t,stiffness:e,damping:r,velocity:i}=n;return{easing:6,mass:t??fo.defaultData.mass,stiffness:e??fo.defaultData.stiffness,damping:r??fo.defaultData.damping,velocity:i??fo.defaultData.velocity}}return{easing:n.easing}}function N1(n){return{delay:n.delay,delayDirection:n.delayDirection??"start-end",direction:n.direction??"normal",repeat:n.repeat}}function KH(n){return{duration:n.duration,ease:B1(n),...N1(n)}}var L1={type:"completeState",isfromEntity:!1};function Ip(n,t){let e,r;if(typeof t=="string"?(e=t,r=n.states?.[e]):t===null&&(e=null,r=n.data),!(e===void 0||r===void 0))return{id:e,data:r}}var Xs=class{constructor(t,e,r,i,o,a,s,l={}){this.object=t;this.fromRef=e;this.toRef=r;this.data=i;this.sharedAssets=o;this.allowSlerp=a;this.page=s;this.hooks=l;this.builtReversed=!1;this.startStateId=null;this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=Br(this.object)?null:this.object.transitionState.state,this.callback=sR(this.object,{},this.end.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)};this.onChange=t=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(t),this.object.requestRender()),this.writeState(t)};this.runner=new Yc(KH(i),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let i=Ip(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!i)throw new Error("Missing property");this.from=i}else{let i=Ip(this.object,t);if(!i)throw new Error("Missing property");this.from=i}if(e===void 0)throw new Error("Missing property");let r=Ip(this.object,e);if(!r)throw new Error("Missing property");this.to=r,this.buildCallback()}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||Br(this.object))return;let e=t===1,r=t>.5?this.targetStateId:this.startStateId,i=this.object.transitionState;i.settled===e&&i.state===r||(this.object.transitionState={settled:e,state:r},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=r,this.object.dispatchEvent({type:"transitionState",settled:e,state:r}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:r}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof St&&o.dispatchEvent(e?L1:R1)}),e?this.hooks.onComplete?.(r):this.hooks.onBegin?.(r))}};var _1=new Map,Dp=new Map,Pi=class extends ZH{constructor(e,r,i,o,a,s,l){super();this.id=e;this.data=r;this.scene=i;this.sharedAssets=o;this.object=a;this.eventType=s;this.actionCondition=l;this.evaluators=[];this.elapsed=0;this.lastTime=null;this.direction=1;this._playing=!1;this._finished=!1;this.hasPlayedOnce=!1;this.pauseOnNextCycleEnd=!1;this.lastCycleIndex=0;try{let c=vl.findTimeline(this.scene.data.objects,this.data.timeline),d=c.duration;this.animatedObjectIds=Object.keys(c.objectTimelines),this.animatedObjectIds.forEach(u=>{let p=this.scene.find(u);if(!p)return;let h=c.objectTimelines[u];!h||this.evaluators.push(JD(p,{...h},d,{scene:i,shared:o},this.sharedAssets))}),this.schedule=new Eg(PD(this.data,d))}catch(c){throw!1&&console.error(c),new Error("Missing property")}a&&(Dp.has(a.uuid)?Dp.get(a.uuid).push(this):Dp.set(a.uuid,[this])),_1.set(e,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(e){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(e-this.lastTime)*this.direction)),this.lastTime=e,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0){this.pause();return}let e=this.schedule.resolve(this.elapsed);if(e){if(e.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=e.cycleIndex,this.pauseOnNextCycleEnd)){this.pauseOnNextCycleEnd=!1,this.pause();return}for(let r of this.evaluators)r.evaluate(e.localTime);return}this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(e=>{let r=this.scene.find(e);r instanceof St&&r.dispatchEvent(L1)})}startTicking(){this._playing=!0,this.lastTime=null;for(let e of this.evaluators)e.invalidate();li.add(this)}play(){let e=this.eventType!==void 0&&jd(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&jd(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!e||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(r=>{let i=this.scene.find(r);i instanceof St&&i.dispatchEvent(R1)}),!e&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,li.remove(this)}stop(){this.pause(),this.elapsed=0,this.lastCycleIndex=0,this.applyAtElapsed(),this._finished=!1}seek(e){let r=this.schedule.totalDuration;this.elapsed=e*(Number.isFinite(r)?r:this.schedule.effectiveCycleDuration);for(let i of this.evaluators)i.invalidate();this.applyAtElapsed()}toggle(e){let r=e??this.direction===-1;this._playing&&this.direction===(r?1:-1)||(r&&this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=r?1:-1,this.pauseOnNextCycleEnd=!1,this.startTicking())}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},F1=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>{r[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(r=>{r[this.data.interaction]()}))}getTimelineActions(t){let e=_1.get(t);return e?[e]:[..._1.values()].filter(r=>r.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=Dp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllTimelines(){let t=[...Dp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Rg=class{constructor(t,e,r,i,o,a,s){this.data=e;let l="interaction"in e?e.interaction:"play";if(l==="play"||l===void 0)this.interaction=new Pi(t,e,r,i,o,a,s);else if(l==="pause"||l==="stop")this.interaction=new F1(e);else throw new Error("Missing property")}get playing(){return this.interaction instanceof Pi?this.interaction.playing:!1}get finished(){return this.interaction instanceof Pi?this.interaction.finished:!0}get paused(){return this.interaction instanceof Pi?this.interaction.paused:!0}play(){if(this.interaction instanceof Pi)return this.interaction.play();this.interaction.dispatch()}stop(){this.interaction instanceof Pi&&this.interaction.stop()}seek(t){this.interaction instanceof Pi&&this.interaction.seek(t)}toggle(t){this.interaction instanceof Pi?this.interaction.toggle(t):this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof Pi?this.interaction.playFromCurrent():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Pi?qe(this.interaction.sharedAssets,this.interaction.actionCondition)&&this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof Pi&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};kt("TimelineAnimation",({id:n,data:t,page:e,shared:r,object:i,eventType:o,actionCondition:a})=>new Rg(n,t,e.scene,r,i,o,a));Oe("timeline");import{EventDispatcher as JH}from"three";function $H(n){let t=n.tweens[0]?.data;return{delay:t?.delay??n.delay,delayDirection:t?.delayDirection??"start-once",direction:t?.direction??n.direction,repeat:t?.repeat??n.repeat}}var e5={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},Bg=class extends JH{constructor(e,r,i,o,a,s){super();this.eventType=e;this.data=r;this.page=i;this.shared=o;this.condition=a;this.runModeOverride=s;this.tweens=[];this.hasPlayedOnce=!1;if(!r.object)throw new Error("Missing property");let l=this.page.scene.find(r.object)??this.page.uiCanvas?.find(r.object)??this.page.scene.find2DInUIObjects(r.object);if(!l)throw new Error("Missing property");if(!l.states)throw new Error("Missing property");if(this.object=l,r.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}init(){this.initialCurrentState=Ip(this.object,this.object.currentState).id,this.build()}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:jd(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}build(){let e=this.data.tweens,r=[];try{let i=e[0].data.state;i!==void 0&&r.push(new Xs(this.object,i,i,e5,this.shared,this.data.allowSlerp??!1,this.page));for(let o=1;o<e.length;o++){let a=e[o-1],s=e[o];r.push(new Xs(this.object,a.data.state===void 0?this.currentState:a.data.state,s.data.state===void 0?this.currentState:s.data.state,s.data,this.shared,this.data.allowSlerp??!1,this.page))}}catch(i){i instanceof Error&&console.error(i.message);return}this.tweens=r,this.runner=new Tg({...N1($H(this.data)),runMode:this.runMode},r.map(i=>i.runner),{claim:()=>this.claimObject(),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(){return this.object.previousAction===this?!1:(this.object.previousAction?.animating===!0&&this.object.previousAction.pause(),this.object.previousAction=this,!0)}rebindTweens(){for(let e of this.tweens)try{e.rebind()}catch(r){r instanceof Error&&console.error(r.message)}this.object instanceof St&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}update(e){this.runner?.update(e),this.runner?.isPlaying!==!0&&li.remove(this)}play(){if(qe(this.shared,this.condition)===!1||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(li.time),this.runner.isPlaying&&li.add(this))}pause(){this.runner?.stop(),li.remove(this)}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;Br(this.object)?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(qe(this.shared,this.condition)===!1)return!1;this.runner?.seek(e)}playDirected(e){if(qe(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(li.time,e),this.runner.isPlaying&&li.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};import{EventDispatcher as t5,MathUtils as r5}from"three";function lR(n){let t=n?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=$E(t);return e&&e>2?e:2}return 2}var Ng=class extends t5{constructor(e,r,i,o,a){super();this.data=e;this.page=r;this.animationControls=i;this.shared=o;this.condition=a;this.startOnceDelay=0;this.toggleIsForward=!1;let s=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(s=l.identity[0]),this.data={...e,object:s};let c=this.animationControls.clipIdToAction[e.clipId+"/"+s];if(this.duration=c?.getClip()?.duration??1,this.data.crop2){let d=lR(c?.getClip());this.leftFrameTime=this.data.crop2[0]/(d-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(d-1)*this.duration}else{let d=c?.getClip()?.tracks[0]?.times.length;d&&d>1?(this.leftFrameTime=this.data.crop[0]/d*this.duration,this.rightFrameTime=this.data.crop[1]/d*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(qe(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,o])=>{let a=i.split("/")[1];this.threeAnimAction!==o&&a===r&&(e?o.fadeOut(.2):o.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=r5.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(qe(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([o,a])=>{let s=o.split("/")[1];this.threeAnimAction!==a&&s===i&&a.isRunning()&&(r?a.fadeOut(.2):a.stop())}),r&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var i5=null;function cR(n){i5=n}cR(Xs);kt("Transition",({eventType:n,data:t,page:e,shared:r,actionCondition:i,runModeOverride:o})=>new Bg(n,t,e,r,i,o));kt("Animation",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new Ng(n,t,e.animationControls,r,i));Oe("transitions");var n5="text/plain",o5="us-ascii",dR=(n,t)=>t.some(e=>e instanceof RegExp?e.test(n):e===n),a5=(n,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(n);if(!e)throw new Error(`Invalid URL: ${n}`);let{type:r,data:i,hash:o}=e.groups,a=r.split(";");o=t?"":o;let s=!1;a[a.length-1]==="base64"&&(a.pop(),s=!0);let l=(a.shift()||"").toLowerCase(),d=[...a.map(u=>{let[p,h=""]=u.split("=").map(f=>f.trim());return p==="charset"&&(h=h.toLowerCase(),h===o5)?"":`${p}${h?`=${h}`:""}`}).filter(Boolean)];return s&&d.push("base64"),(d.length>0||l&&l!==n5)&&d.unshift(l),`data:${d.join(";")},${s?i.trim():i}${o?`#${o}`:""}`};function k1(n,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},n=n.trim(),/^data:/i.test(n))return a5(n,t);if(/^view-source:/i.test(n))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=n.startsWith("//");!e&&/^\.*\//.test(n)||(n=n.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(n);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,s=0,l="";for(;;){let d=a.exec(i.pathname);if(!d)break;let u=d[0],p=d.index,h=i.pathname.slice(s,p);l+=h.replace(/\/{2,}/g,"/"),l+=u,s=p+u.length}let c=i.pathname.slice(s,i.pathname.length);l+=c.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=i.pathname.split("/"),s=a[a.length-1];dR(s,t.removeDirectoryIndex)&&(a=a.slice(0,-1),i.pathname=a.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...i.searchParams.keys()])dR(a,t.removeQueryParameters)&&i.searchParams.delete(a);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let o=n;return n=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!o.endsWith("/")&&i.hash===""&&(n=n.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(n=n.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(n=n.replace(/^http:\/\//,"//")),t.stripProtocol&&(n=n.replace(/^(?:https?:)?\/\//,"")),n}var Lg=class{constructor({url:t,context:e},r,i,o){this.controlsManager=r;this.shared=i;this.condition=o;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:k1(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;Pl?window.location.assign(this.url):(this.context==="tab"||Bb&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(sr[0]),ZE())}};var _g=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.shared=r;this.eventManager=i;this.condition=o}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),yg(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};import{EventDispatcher as s5,Quaternion as uR,Vector3 as pR}from"three";var l5={type:"beginState"},hR={type:"completeState",isfromEntity:!1},fR={type:"requestRender"},Fg=class extends s5{constructor(e,r,i,o){super();this.data=e;this.page=r;this.shared=i;this.condition=o;this.toggleIsForward=!1;this.posStart=new pR;this.posEnd=new pR;this.qStart=new uR;this.qEnd=new uR;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(e=!1){if(!this.data.animate)return;let r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let i={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:B1(this.data)},o=a=>{let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,a),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,a),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*a,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(fR),a===1&&s.dispatchEvent(hR)};this.runner=new Yc(i,o,()=>{this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(l5),o(0)})}update(e){this.runner?.update(e),this.runner?.isPlaying!==!0&&li.remove(this)}start(){!this.runner||(this.runner.start(li.time),li.add(this))}switchCamera(e){let r=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),r.dispatchEvent({type:"cameraChange",camera:i})}play(){if(qe(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.start()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.runner?.stop(),li.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(qe(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(),this.start()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(hR),this.page.activeCamera.dispatchEvent(fR))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var kg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let r=this.shared.data.variables.data(e)?.value;r!==void 0&&this.shared.updateVariable(e,r),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(hm(e))})}dispose(){}};kt("Link",({data:n,eventManager:t,shared:e,actionCondition:r})=>new Lg(n,t.controlsManager,e,r));kt("Reset",({data:n,page:t,shared:e,eventManager:r,actionCondition:i})=>new _g(n,t,e,r,i));kt("SwitchCamera",({data:n,page:t,shared:e,actionCondition:r})=>new Fg(n,t,e,r));kt("ClearLocalStorage",({data:n,page:t,shared:e,actionCondition:r})=>new kg(n,t,e,r));Oe("misc-actions");var c5=new Map;function Or(n,t){c5.set(n,t)}import{DepthStencilFormat as HTe,DepthTexture as WTe,LinearFilter as qTe,SRGBColorSpace as YTe,UnsignedByteType as QTe,UnsignedIntType as KTe,UnsignedInt248Type as ZTe,Vector2 as JTe,WebGLRenderTarget as $Te}from"three";import{NearestFilter as tPe,WebGLRenderTarget as rPe}from"three";import{NoBlending as nPe,REVISION as oPe,ShaderMaterial as aPe,Uniform as sPe}from"three";import{NoBlending as d5,ShaderMaterial as u5,Uniform as $c,Vector2 as p5,Vector4 as mR}from"three";import{BasicDepthPacking as f5,NoBlending as m5,PerspectiveCamera as y5,ShaderMaterial as g5,Uniform as Rp}from"three";import{LinearSRGBColorSpace as uPe,REVISION as pPe,RGBAFormat as hPe,SRGBColorSpace as fPe,UnsignedByteType as mPe}from"three";import{NoBlending as x5,ShaderMaterial as S5,Uniform as Bp,Vector2 as V1}from"three";import{NoBlending as vPe,ShaderMaterial as bPe,Uniform as xPe}from"three";import{NoBlending as wPe,PerspectiveCamera as APe,RGBADepthPacking as EPe,ShaderMaterial as CPe,Uniform as TPe}from"three";import{BasicDepthPacking as MPe,NoBlending as OPe,ShaderMaterial as IPe,Uniform as DPe,Vector2 as RPe}from"three";import{BasicDepthPacking as NPe,NoBlending as LPe,ShaderMaterial as _Pe,Uniform as FPe,Vector2 as kPe}from"three";import{AlwaysDepth as GPe,BasicDepthPacking as UPe,EqualDepth as zPe,GreaterDepth as jPe,GreaterEqualDepth as HPe,LessDepth as WPe,LessEqualDepth as qPe,NeverDepth as XPe,NoBlending as YPe,NotEqualDepth as QPe,ShaderMaterial as KPe,Uniform as ZPe}from"three";import{BasicDepthPacking as $Pe,NoBlending as eMe,REVISION as tMe,ShaderMaterial as rMe,Uniform as iMe,Vector2 as nMe}from"three";import{BasicDepthPacking as aMe,NoBlending as sMe,PerspectiveCamera as lMe,REVISION as cMe,ShaderMaterial as dMe,Uniform as uMe,Vector2 as pMe}from"three";import{NoBlending as fMe,ShaderMaterial as mMe,Uniform as yMe}from"three";import{NoBlending as E5,REVISION as C5,ShaderMaterial as T5,Uniform as Gg}from"three";import{NoBlending as O5,ShaderMaterial as I5,Uniform as G1,UnsignedByteType as D5}from"three";import{NoBlending as xMe,ShaderMaterial as SMe,Uniform as wMe,Vector2 as AMe}from"three";import{NoBlending as CMe,ShaderMaterial as TMe,Uniform as PMe,Vector2 as MMe}from"three";import{BasicDepthPacking as IMe,Matrix4 as DMe,NoBlending as RMe,PerspectiveCamera as BMe,ShaderMaterial as NMe,Uniform as LMe,Vector2 as _Me}from"three";import{LinearFilter as kMe,SRGBColorSpace as VMe,UnsignedByteType as GMe,WebGLRenderTarget as UMe}from"three";import{BasicDepthPacking as N5,BufferAttribute as Ug,BufferGeometry as L5,Camera as _5,Mesh as F5,Scene as U1}from"three";import{Color as G5}from"three";import{Color as qMe,MeshDepthMaterial as XMe,NearestFilter as YMe,RGBADepthPacking as QMe,WebGLRenderTarget as KMe}from"three";import{EventDispatcher as U5,Vector2 as vR}from"three";import{BackSide as $Me,DoubleSide as e2e,FrontSide as t2e}from"three";import{BasicDepthPacking as i2e,FloatType as n2e,NearestFilter as o2e,WebGLRenderTarget as a2e}from"three";import{FloatType as l2e,RGBADepthPacking as c2e}from"three";import{BasicDepthPacking as u2e,FloatType as p2e,NearestFilter as h2e,RGBADepthPacking as f2e,UnsignedByteType as m2e,WebGLRenderTarget as y2e}from"three";import{BasicDepthPacking as b2e,UnsignedByteType as x2e}from"three";import{EventDispatcher as z5,Uniform as j5}from"three";import{BasicDepthPacking as dW,EventDispatcher as uW,Scene as pW}from"three";import{LinearFilter as bR,SRGBColorSpace as z1,UnsignedByteType as hW,WebGLRenderTarget as fW}from"three";import{LinearFilter as xR,UnsignedByteType as yW,WebGLRenderTarget as gW}from"three";import{Color as T2e,MeshNormalMaterial as P2e,NearestFilter as M2e,WebGLRenderTarget as O2e}from"three";import{UnsignedByteType as bW}from"three";import{LinearFilter as SR,SRGBColorSpace as wR,Uniform as AR,WebGLRenderTarget as xW}from"three";import{Uniform as N2e}from"three";import{Uniform as ER}from"three";import{Uniform as F2e}from"three";import{Uniform as EW,Vector2 as CW}from"three";import{BasicDepthPacking as MW,LinearFilter as CR,SRGBColorSpace as Np,Uniform as zg,UnsignedByteType as OW,WebGLRenderTarget as IW,Vector3 as DW}from"three";import{Uniform as U2e,Vector2 as z2e}from"three";import{Uniform as H2e}from"three";import{NearestFilter as q2e,RepeatWrapping as X2e,RGBAFormat as Y2e,Uniform as Q2e,Vector2 as K2e}from"three";import{DataTexture as J2e,RedFormat as $2e,RGFormat as eOe,RGBAFormat as tOe,UnsignedByteType as rOe}from"three";import{BasicDepthPacking as nOe,Color as oOe,DepthTexture as aOe,LinearFilter as sOe,Matrix4 as BW,Scene as lOe,SRGBColorSpace as cOe,Uniform as dOe,Vector2 as uOe,Vector3 as NW,WebGLRenderTarget as pOe}from"three";import{Uniform as yOe,Vector2 as gOe}from"three";import{Uniform as TR,Vector3 as LW}from"three";import{Data3DTexture as xOe,FloatType as SOe,HalfFloatType as wOe,LinearSRGBColorSpace as AOe,LinearFilter as EOe,NearestFilter as COe,SRGBColorSpace as TOe,Uniform as POe,Vector3 as MOe}from"three";import{Color as FW,ClampToEdgeWrapping as IOe,DataTexture as DOe,Data3DTexture as ROe,FloatType as BOe,LinearFilter as NOe,LinearSRGBColorSpace as LOe,RGBAFormat as _Oe,SRGBColorSpace as FOe,UnsignedByteType as kOe,Vector3 as VOe}from"three";import{Color as zOe,LinearFilter as jOe,RepeatWrapping as HOe,Uniform as WOe,UnsignedByteType as qOe,WebGLRenderTarget as XOe}from"three";import{Uniform as PR,Vector2 as MR}from"three";import{Uniform as KOe,Vector4 as ZOe}from"three";import{Uniform as $Oe,Vector2 as eIe}from"three";import{Uniform as rIe,Vector2 as iIe,Vector3 as UR}from"three";import{BasicDepthPacking as lIe,Color as cIe,LinearFilter as dIe,NotEqualDepth as uIe,EqualDepth as pIe,RGBADepthPacking as hIe,SRGBColorSpace as fIe,WebGLRenderTarget as mIe}from"three";import{Uniform as gIe}from"three";import{BasicDepthPacking as bIe,Color as xIe,LinearFilter as SIe,LoadingManager as wIe,NearestFilter as AIe,Texture as EIe,Uniform as CIe,WebGLRenderTarget as TIe}from"three";import{BasicDepthPacking as MIe,Color as OIe,LinearFilter as IIe,RepeatWrapping as DIe,RGBAFormat as RIe,Uniform as BIe,WebGLRenderTarget as NIe}from"three";import{Uniform as _Ie,UnsignedByteType as FIe}from"three";import{LinearFilter as VIe,LinearMipmapLinearFilter as GIe,Uniform as UIe,WebGLRenderTarget as zIe}from"three";import{Uniform as OR}from"three";import{LoadingManager as $Ie}from"three";import{FileLoader as rDe,Loader as iDe,LoadingManager as nDe}from"three";import{FileLoader as aDe,Loader as sDe,LoadingManager as lDe,Vector3 as cDe}from"three";import{Loader as uDe,LoadingManager as pDe}from"three";var IR={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Hg="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var h5=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
1409
|
+
`&&o--,this.htmlInput.setSelectionRange(Math.min(t,o),Math.max(t,o))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof ka)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let r=this.virtualInput.wrappedText,i=r[t],o=e+1,a=e;i[e]!==" "&&(o=this.findNextCharOccurence(i,e,"forward"," "),a=this.findNextCharOccurence(i,e,"backward"," "),a>0&&a++,o>=i.length-1&&t===r.length-1&&o++);let s=this.helper,l=s.getGlobalIndexFromLineAndCharIndexes(r,t,a),c=s.getGlobalIndexFromLineAndCharIndexes(r,t,o);this.setInputSelection(l,c)}findNextCharOccurence(t,e,r,i=" "){let o=Math.max(0,t.length-1),a=r==="forward"?o:0,s=r==="forward"?1:-1,l=Math.max(Math.min(e,o),0);for(;l!==a;)if(l+=s,t.charAt(l)===i)return l;return a}getPointOnPlane(){let t=this.virtualInput?.data;if(!(!this.virtualInput||!t)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new xp);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let r=typeof t.geometry.width=="number"?t.geometry.width:1,i=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+r*.5,e.y-i*.5)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(dD.getNormalMatrix(this.virtualInput.matrixWorld),lD.copy(j4).applyMatrix3(dD).normalize(),this.virtualInput.localToWorld(cD.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(lD,cD))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),Pl&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=H4(t.geometry.horizontalAlign))}};function H4(n){return n===4?"justify":n===2?"right":n===3?"center":"left"}var pD=(n,t)=>{if(typeof n=="string"){let e=t.data(n);if(e)return pD(e.value,t)}return ar.getDisplayedValue(n)};function uD(n,t){let e=n.text,r="";if(typeof e=="string"){let i=t.variables.data(r);i&&(r=pD(i.value,t.variables))}else r=e.textValue.toString();return r}var ug=class extends Mt{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new W4;this.helper=new Hc;this._onMouseDownFocusIn=e=>{if(sr.length>1)return;this.eventContext.updateRaycaster(e);let r=null;if(this.eventContext.raycaster){for(let i of this._textInputs)if(this.eventContext.raycaster.intersectObject(i,!0).length>0){r=i;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(e),this._onMouseDown(e)};this.onExit=()=>{let{virtualInput:e}=this.textInputManager;if(e===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:i}=this.eventContext;i.removeEventListener("pointerdown",this._onMouseDown,!1),i.removeEventListener("pointerup",this._onMouseUp,!1),i.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),i.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()};this._onMouseDown=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)};this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)};this._onMouseMove=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseMove()};this._onTextEdit=e=>{let{htmlInput:r,virtualInput:i,helper:o}=this.textInputManager;if(!r||!i)return;let a=r.value;i.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let s=i.data;o.update();let l=s.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()};this._onCaretUpdate=e=>{this.textInputManager.handleCaretUpdate(e)};this._onKeyPress=e=>{e.key==="Escape"&&this.onExit()};this.textInputManager=new dg(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(o=>{o instanceof ka&&e.push(o)}),this._textInputs=e,e.length===0)return;let{domElement:r}=this.eventContext;r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:r,sharedAssets:i}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(o=>{let a=uD(o.data.geometry,this.eventContext.sharedAssets.data);o.textGeometry.setText(a,i)}),r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let r=this.textInputManager.htmlInput;if(!r||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=uD(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);r.value=i,r.setSelectionRange(0,0),this.textInputManager.helper.show(e),r.style.display="block",r.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:o}=this.eventContext;o.removeEventListener("pointerdown",this._onMouseDownFocusIn),o.addEventListener("pointerdown",this._onMouseDown,!1),o.addEventListener("pointerup",this._onMouseUp,!1),o.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};Yt("Textfields",({eventContext:n,eventManager:t})=>new ug(n,t));Vi("InputGeometry",(n,t,e)=>new ka(n,t,e));Oe("textinputs");var hD=new Map,Sp=new Map,Wc=class{constructor(t,e,r,i){this.data=e;this.isPlayAudioAction=!0;let{audio:o,volume:a,delay:s,loop:l}=e;if(!o)throw new Error("Missing property");try{let c=typeof o=="string"?i.getAudio(o).src:o.data;this.audioPlayer=new Oo({src:c,volume:a,delay:s,loop:l})}catch{console.warn(`Could not create an audio player for this object: "${r.name}" and this audio: "${o}"`)}Sp.has(r.uuid)?Sp.get(r.uuid).push(this):Sp.set(r.uuid,[this]),hD.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},y1=class{constructor(t){this.data=t;this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=hD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Sp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...Sp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},pg=class{constructor(t,e,r,i,o){this.data=e;this.shared=i;this.condition=o;if(e.interaction==="play")this.interaction=new Wc(t,e,r,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new y1(e);else throw new Error("Missing property")}dispatchBasic(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Wc?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Wc?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Wc&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};kt("Audio",({id:n,data:t,object:e,shared:r,actionCondition:i})=>new pg(n,t,e,r,i));Oe("audio");function fD(n,t){let e;if("material"in n){let i=n.material;Array.isArray(i)?e=n.material[0].layers.find(o=>o.uuid===t):e=n.material.layers.find(o=>o.uuid===t)}if(!e)return;let r=e.color?.texture?.image?.img??e.holders?.find(i=>i.isVideo)?.img;return r instanceof HTMLVideoElement?r:void 0}var mD=new Map,wp=new Map,Ap=class{constructor(t,e,r){this.data=e;this.isPlayVideoAction=!0;this.delay=0;this.status="stopped";let{layerId:i,loop:o,volume:a,delay:s}=e;if(this.object=r,i===void 0)throw new Error("Missing property");let l=fD(r,i);l&&(this.videoElement=l,this.videoElement.loop=o===1/0,Pl&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),s!==void 0&&(this.delay=s),wp.has(r.uuid)?wp.get(r.uuid).push(this):wp.set(r.uuid,[this]),mD.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(i=>{}).catch(i=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let r=this.videoElement.duration;if(r>0){let i=t%r;this.videoElement.currentTime=i}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},g1=class{constructor(t){this.data=t;this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=mD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=wp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...wp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},hg=class{constructor(t,e,r,i,o){this.data=e;this.shared=i;this.condition=o;if(e.interaction==="play")this.interaction=new Ap(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new g1(e);else throw new Error("Missing property")}dispatchBasic(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ap?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(qe(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ap?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};kt("Video",({id:n,data:t,object:e,shared:r,actionCondition:i})=>Br(e)?null:new hg(n,t,e,r,i));Oe("video");import{MathUtils as q4,Quaternion as X4,Vector3 as b1}from"three";var v1=(()=>{let n,t,e,r,i=!1;function o(c){!n&&!yD()&&(t?.sharedGameControlGlobals.createdObjects.length??0)>0&&(n=requestAnimationFrame(a)),c&&(t=c,r=c.requestRender,!i&&typeof document<"u"&&(document.addEventListener("visibilitychange",s),i=!0))}function a(c){if(!t||!r){n=void 0,e=void 0;return}let d=e?c-e:0,u=t.sharedGameControlGlobals.createdObjects,p=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,f=0;for(;f<h;){let m=u[f];m.userData.createdTime===void 0&&(m.userData.createdTime=c),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&c-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&p[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,d/1e3),m.updateMatrix(),r()),f++):(p[m.userData.actionId]>m.userData.quantity&&p[m.userData.actionId]--,u.splice(f,1),m.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(y=>y.bvhGeometry!==void 0)),h--,r())}n=f>0?requestAnimationFrame(a):void 0,e=f>0?c:void 0}function s(){yD()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):o()}function l(){n&&(cancelAnimationFrame(n),n=void 0),i&&typeof document<"u"&&(document.removeEventListener("visibilitychange",s),i=!1),t=void 0,r=void 0,e=void 0}return{play:o,dispose:l}})();function yD(){return!!document&&document.hidden}var gD=new X4,Y4=new b1,Q4=new b1,fg=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=o;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=q4.generateUUID();this.dispatch=()=>{if(qe(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{if(qe(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=JE(this.dispatch,1e3/this.data.creationSpeed);this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))};this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)};this.dispatchInner=()=>{this.timeoutIdQueue.shift();let t=new lr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,i=this.page.scene.find(r);i&&(i.updateMatrixWorldRigid(),t.hiddenMatrix.copy(i.matrixWorldRigid))}t.scale.copy(this.object.scale),t.position.fromArray(this.data.position.map(r=>typeof r=="number"?r:0)),t.rotation.fromArray(this.data.rotation.map(r=>typeof r=="number"?r:0)),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),v1.play(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldRigid();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof ni)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof lr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof ni)return;t instanceof lr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new b1().fromArray(this.data.velocity.map(o=>typeof o=="number"?o:0)),i=e.dataPatched;if(!(i.physics.enabled==="visibility"?!i.visible:!i.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(Y4,gD,Q4),r.applyQuaternion(gD),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");v1.play(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],v1.dispose()}};var mg=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=o;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,i=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let o of e.cloner.children)i?(o.playModeVisible=!1,o.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),r.removeRigidBody(o.rigidBody),o.rigidBody=void 0),o.bvhGeometry&&(o.bvhGeometry=void 0)):this.clone===void 0||this.clone===o?(o.playModeVisible=!1,o.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),r.removeRigidBody(o.rigidBody),o.rigidBody=void 0)):o.playModeVisible===void 0&&(o.playModeVisible=!0);e.cloner.syncInstanceMatrices(),(i||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(qe(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(qe(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};kt("Create",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new fg(n,t,e.controlsManager,r,i));kt("Destroy",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new mg(n,t,e.controlsManager,r,i));Oe("create-destroy");import{Vector3 as K4}from"three";var vD=new K4;function yg(n,t,e=!1){let r=[],i=o=>{let a=o.data;delete o.states,o.currentState=null,o.reversibleToState=null,o.currentTransitionEvent=null;for(let s of a.states){let l={...s.data};o.states||(o.states={}),o.states[s.id]=So.patch(a,l)}xD(n.scene,o,null,t,a.events.find(s=>s.data.type==="Follow"||s.data.type==="LookAt")!==void 0),bD(n)};n.scene.traverse2D(i),n.traverseChildren(o=>{if(e&&(o.rigidBody?.setTranslation(o.position0,!0),o.rigidBody?.setRotation(o.rotation0,!0),o.rigidBody?.setLinvel(vD,!0),o.rigidBody?.setAngvel(vD,!0)),!ke.is(o))return;let a=o.uuid,s=o.data;if(delete o.states,o.uuid===En)return;let l=!1;r.some(c=>n.scene.find(a)?.isDescendantOf(c))?l=!0:s.physics?.fusedBody===!0&&s.physics.rigidBody==="dynamic"&&r.push(a),o.data=s,o.currentState=null,o.reversibleToState=null,o.currentTransitionEvent=null,o.transitionState={settled:!0,state:null};for(let c of s.states){let d={...c.data};n.data.globalPhysics.usePhysics===!0&&s.physics&&(s.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete d.position,c.data.rotation!==void 0&&delete d.rotation,c.data.hiddenMatrix!==void 0&&delete d.hiddenMatrix),o.states||(o.states={}),o.states[c.id]=yo.patch(s,d)}xD(n.scene,o,null,t,s.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),ei(o)&&o.frame&&(o.frame.traverse(c=>i(c)),o.uiCanvas?.applySize())}),bD(n),n.frame&&(n.frame.traverse(o=>i(o)),n.uiCanvas?.applySize())}function bD(n){n.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let i of Object.values(e.data.gameActions))r.push(...i);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let i of r)if(i.data.type==="Create"&&i.data.hideBase==="Yes"){let o=n.scene.find(i.data.object);o&&(o.visible=!1)}}})}function xD(n,t,e,r,i=!1){if(n.markShadowsDirty(),t instanceof Qe&&!sn(t)&&t.removeInteractionGeometry(r),Br(t)?t.changeSelectedState(e,{shared:r},i):t.changeSelectedState(e,{scene:n,shared:r},i),t instanceof Qe&&t.updateGeometryGroupsIfNeeded(),t instanceof St&&t.updateCameraState(t.dataPatched,{scene:n,shared:r}),!Br(t)){if(t.cloner){let o=!1;for(let a of t.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,o=!0);o&&n.addPendingUpdateCloner(t),t.cloner.syncInstanceMatrices()}t.updateVisible()}}var gg=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.eventManager=r;this.shared=i;this.condition=o;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(r=>r.uuid!==this.data.target||r.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),yg(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};kt("SceneTransition",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new gg(n,t,e,r,i));Oe("scene-transition");var vg=class{constructor(){this.elapsed=0;this.lastRealTimeMs=null;this.paused=!1}get time(){return this.elapsed}tick(t){let e=0;return this.lastRealTimeMs!==null&&(e=Math.min((t-this.lastRealTimeMs)/1e3,.25),e<0&&(e=0)),this.lastRealTimeMs=t,this.paused||(this.elapsed+=e),this.elapsed}step(t){return this.paused||(this.elapsed+=t),this.elapsed}resync(t){this.lastRealTimeMs=t}seek(t){this.elapsed=t}reset(){this.elapsed=0,this.lastRealTimeMs=null,this.paused=!1}};var ze=Math.fround,Z4=[.01,100],J4=[.01,1e4],$4=[.01,1e3],eH=[.01,1e3];function bg(n,[t,e]){return Math.min(Math.max(n,t),e)}function wD(n,t,e,r,i){n=bg(n,Z4),t=bg(t,J4),e=bg(e,$4),r=bg(r,eH);let o=Math.sqrt(t/n),a=e/(2*Math.sqrt(t*n)),s=a<1?o*Math.sqrt(1-a*a):0,l=1,c=a<1?(a*o+-r)/s:-r+o;return d=>{let u=i!==void 0?i*d:d;return a<1?u=Math.exp(-u*a*o)*(l*Math.cos(s*u)+c*Math.sin(s*u)):u=(l+c*u)*Math.exp(-u*o),d===0||d===1?d:1-u}}function tH(n,t,e,r){let i=.16666666666666666,o=0,a=0,s=wD(n,t,e,r),l=1e5;for(let c=0;c<l;c++)if(o+=i,s(o)===1){if(a+=1,a>=16)break}else a=0;return ze(o*i)}var rH=4,iH=ze(.001),nH=ze(1e-7),oH=10,Sg=11,xg=ze(1/(Sg-1));function AD(n,t){return ze(ze(1-ze(3*t))+ze(3*n))}function ED(n,t){return ze(ze(3*t)-ze(6*n))}function CD(n){return ze(3*n)}function wg(n,t,e){return ze(ze(ze(ze(ze(AD(t,e)*n)+ED(t,e))*n)+CD(t))*n)}function TD(n,t,e){let r=ze(ze(ze(3*AD(t,e))*n)*n),i=ze(ze(2*ED(t,e))*n);return ze(ze(r+i)+CD(t))}function aH(n,t,e,r,i){let o,a=0,s=0;do a=ze(t+ze(ze(e-t)/2)),o=ze(wg(a,r,i)-n),o>0?e=a:t=a,s+=1;while(Math.abs(o)>nH&&s<oH);return a}function sH(n,t,e,r){for(let i=0;i<rH;i++){let o=TD(t,e,r);if(o===0)return t;let a=ze(wg(t,e,r)-n);t=ze(t-ze(a/o))}return t}var SD=n=>n;function qc(n,t,e,r){if(n=ze(n),t=ze(t),e=ze(e),r=ze(r),n<0||n>1||e<0||e>1||n===t&&e===r)return SD;let i=new Float32Array(Sg);for(let a=0;a<Sg;a++)i[a]=wg(ze(a*xg),n,e);let o=a=>{let s=0,l=1,c=Sg-1;for(;l!==c&&i[l]<=a;)s=ze(s+xg),l+=1;l-=1;let d=ze(ze(a-i[l])/ze(i[l+1]-i[l])),u=ze(s+ze(d*xg)),p=TD(u,n,e);return p>=iH?sH(a,u,n,e):p===0?u:aH(a,s,ze(s+xg),n,e)};return a=>(a=ze(a),a===0||a===1?a:wg(o(a),t,r))}var lH=ze(1.70158),uwe=ze(lH+1);function Ag(n,t,e){switch(n.easing){case 0:return e;case 1:return qc(.25,.1,.25,1)(e);case 2:return qc(.42,0,1,1)(e);case 3:return qc(0,0,.58,1)(e);case 4:return qc(.42,0,.58,1)(e);case 7:return qc(.25,1,.5,1)(e);case 8:return Math.floor(e);case 5:{let{control1:r,control2:i}=n;return!r||!i?e:qc(r[0],r[1],i[0],i[1])(e)}case 6:{let{mass:r,stiffness:i,damping:o,velocity:a}=n;return r===void 0||i===void 0||o===void 0||a===void 0?e:ze(wD(r,i,o,a,t)(e))}default:return e}}function x1(n,t){if(n.easing!==6)return t;let{mass:e,stiffness:r,damping:i,velocity:o}=n;return e===void 0||r===void 0||i===void 0||o===void 0?t:tH(e,r,i,o)}var kr=Math.fround;function S1(n){return n==="pingpong"||n==="pingpong-rewind"}var Eg=class{constructor(t){this.config=t,this.effectiveCycleDuration=this.cycleDuration(0)}layout(t){let{config:e}=this;if(S1(e.direction)&&t%2===1)return{startDelay:0,endDelay:0};switch(e.delayDirection){case"start-once":return t===0?{startDelay:e.delay,endDelay:0}:{startDelay:0,endDelay:0};case"start":return{startDelay:e.delay,endDelay:0};case"end":return{startDelay:0,endDelay:e.delay};default:return{startDelay:e.delay,endDelay:e.delay}}}cycleDuration(t){let{config:e}=this,{startDelay:r,endDelay:i}=this.layout(t);return kr(e.duration+r+i)}get totalDuration(){let{config:t}=this;if(t.repeat===-1)return 1/0;let e=0;for(let r=0;r<=t.repeat;r++)e=kr(e+this.cycleDuration(r));return e}isFinished(t){return t>=this.totalDuration}resolve(t){let{config:e}=this,r=kr(t),i,o;if(e.delayDirection==="start-once"){let u=kr(e.delay+e.duration);if(r<u)i=0,o=r;else{let p=kr(r-u);i=1+Math.floor(kr(p/e.duration)),o=kr(p%e.duration)}}else if(S1(e.direction)){let u=this.cycleDuration(0),p=kr(u+e.duration),h=Math.floor(kr(r/p)),f=kr(r%p);f<u?(i=h*2,o=f):(i=h*2+1,o=kr(f-u))}else{let u=this.cycleDuration(0);i=Math.floor(kr(r/u)),o=kr(r%u)}if(e.repeat!==-1&&i>=e.repeat+1)return null;let{startDelay:a}=this.layout(i),s=S1(e.direction)&&i%2===1,l=a,c=kr(l+e.duration),d;if(o<l)d=s?e.duration:0;else if(o>=c)d=s?0:e.duration;else{let u=kr(o-l);d=s?kr(e.duration-u):u}return{cycleIndex:i,localTime:d,isReverse:s}}};function PD(n,t){return{duration:t,delay:kr(n.delay/1e3),delayDirection:n.delayDirection??"start-end",direction:n.direction??"normal",repeat:n.repeat}}var w1=Math.fround;function cH(n,t){let e=n.length,r=0,i=e;for(;r<i;){let o=r+Math.floor(e/2),a=n[o].time;if(a<t)r=o+1;else if(a>t)i=o;else return{found:!0,index:o};e=i-r}return{found:!1,index:r}}function MD(n,t){if(n.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(t<=n[0].time)return{index0:0,index1:0,t:1};let{found:e,index:r}=cH(n,t);if(e)return{index0:r,index1:r,t:1};if(r>=n.length){let u=n.length-1;return{index0:u,index1:u,t:1}}let i=r-1,o=r,a=n[i].time,s=n[o].time;if(s===a)return{index0:i,index1:o,t:.5};let l=w1(s-a),c={...n[i].ease,control2:n[o].ease.control2},d=Ag(c,l,w1(w1(t-a)/l));return{index0:i,index1:o,t:d}}function OD(n){return[...n].sort((t,e)=>t.time-e.time)}var Ep=Math.fround;function js(n){return Math.round(n*1e9)}function dH(n){let t=Math.trunc(n/1e9),e=n-t*1e9;return Ep(Ep(t)+Ep(Ep(e)/Ep(1e9)))}function ID(n,t){return dH(js(n)-js(t))}function Xc(n,t){return(js(n)+js(t))/1e9}function Cg(n,t,e){return js(n)-js(t)<js(e)}var uH=Math.fround;function DD(n){return n==="pingpong"||n==="pingpong-rewind"}function RD(n,t){return t?n==="start"?"end":n==="end"?"start":n:n}var Tg=class{constructor(t,e,r={}){this.hooks=r;this.isPlaying=!1;this.playingIndex=0;this.seekIndex=-1;this.currentRepeat=0;this.isReversed=!1;this.startTime=0;this.isToggledForward=!1;this.hasPlayedOnce=!1;this.isFirstTweenAfterStart=!1;this.hasClaimed=!1;this.config=t,this.tweens=e,this.delay=uH(t.delay/1e3)}get currentTween(){return this.tweens[this.playingIndex]}play(t){if(this.tweens.length===0||this.isPlaying&&this.config.runMode!=="Toggle"||this.hasPlayedOnce&&this.config.runMode==="Once")return;let e=this.isPlaying;this.isPlaying=!0,this.hasPlayedOnce=!0,this.currentRepeat=this.config.repeat,this.startTime=t,this.seekIndex=-1,this.hooks.isOwner?.()===!1&&(this.isToggledForward=!1,!e&&!this.isReversed&&this.hooks.assignCurrentState?.()),this.hasClaimed=!1,this.config.runMode==="Toggle"?(this.toggleDirection(),e?this.openPass():this.startChain()):this.startChain()}stop(){this.currentTween?.stop(),this.isPlaying=!1,this.isReversed=!1,this.hasClaimed=!1}playDirected(t,e){if(this.tweens.length===0)return;let r=this.isPlaying;if(r&&this.isForward===e)return;this.isPlaying=!0,this.hasPlayedOnce=!0,this.currentRepeat=this.config.repeat,this.startTime=t,this.seekIndex=-1,this.isToggledForward=e,this.isReversed=!e,this.hooks.isOwner?.()===!1&&!r&&!this.isReversed&&this.hooks.assignCurrentState?.(),this.hasClaimed=!1,r?this.openPass():this.startChain()}get isAnimating(){return this.isPlaying&&this.hasClaimed}get isForward(){return!this.isReversed}seek(t){if(this.tweens.length===0)return;let r=this.tweens.reduce((s,l)=>s+l.duration,0)*t,i=this.tweens.length-1,o=1,a=0;for(let s=0;s<this.tweens.length;s++){let l=this.tweens[s];if(a+l.duration>r){i=s,o=(r-a)/l.duration;break}a+=l.duration}for(this.seekIndex===-1&&(this.seekIndex=0);this.seekIndex<i;)this.tweens[this.seekIndex].seek(1),this.seekIndex+=1,this.tweens[this.seekIndex].rearm();for(;this.seekIndex>i;)this.tweens[this.seekIndex].seek(0),this.seekIndex-=1;this.tweens[i].seek(o)}update(t){if(!this.isPlaying)return;if(this.claimWhenDue(t),this.hasClaimed&&this.hooks.isOwner?.()===!1){this.stop();return}let e=RD(this.config.delayDirection,this.isReversed);if(Cg(t,this.startTime,this.leadingDelay)||(this.currentTween.update(t),!this.isPlaying)||this.currentTween.isPlaying)return;if(this.isFirstTweenAfterStart=!1,this.isReversed?this.playingIndex>0:this.playingIndex<this.tweens.length-1){this.advanceToNextTween();return}let i=0;if(e==="end"||e==="start-end"){if(Cg(t,this.currentTween.endTime,this.delay))return;i=this.delay}if(this.currentRepeat===0){this.stop();return}this.currentRepeat>0&&(this.currentRepeat-=1),DD(this.config.direction)&&(this.config.runMode==="Toggle"?this.toggleDirection():this.isReversed=!this.isReversed),this.startTime=Xc(this.currentTween.endTime,i),this.playingIndex=this.isReversed?this.tweens.length-1:0,this.config.direction==="normal"&&this.currentTween.seek(this.currentTween.isReversed?1:0),this.openPass()}advanceToNextTween(){let t=this.currentTween;t.isPingpong&&t.config.repeat%2===1&&t.seek(t.isReversed?0:1);let e=t.endTime,r=this.isReversed;this.playingIndex+=r?-1:1;let i=this.currentTween;r&&i.isPingpong&&i.config.repeat%2===1&&i.seek(1),this.resume(e)}startChain(){this.playingIndex=this.isReversed?this.tweens.length-1:0,this.isFirstTweenAfterStart=!0,this.openPass()}openPass(){this.claimWhenDue(this.startTime);let t=this.tweens[0];this.hasClaimed&&!this.isReversed&&t&&t.duration===0&&(t.seek(1),!this.isPlaying)||this.resume(Xc(this.startTime,this.leadingDelay))}claimWhenDue(t){this.hasClaimed||Cg(t,this.startTime,this.leadingDelay)||(this.hasClaimed=!0,this.hooks.claim?.())}get leadingDelay(){let t=RD(this.config.delayDirection,this.isReversed);return t==="start-once"?this.isFirstTweenAfterStart?this.delay:0:t!=="start"&&t!=="start-end"||this.isReversed||this.playingIndex!==0||DD(this.config.direction)&&!this.isFirstTweenAfterStart?0:this.delay}resume(t){let e=this.currentTween;this.isReversed&&this.config.direction==="pingpong-rewind"&&(e.overrideDirection="pingpong-rewind"),e.isReversed=this.isReversed?!(e.repeatDirection!=="normal"&&e.config.repeat%2===1):!1,e.start(t)}toggleDirection(){this.isToggledForward=!this.isToggledForward,this.isReversed=!this.isToggledForward}};var to=Math.fround,Yc=class{constructor(t,e,r){this.apply=e;this.onStart=r;this.isPlaying=!1;this.isReversed=!1;this.endTime=0;this.startTime=0;this.isFirstLerpAfterStart=!1;this.config=t,this.duration=x1(t.ease,to(t.duration/1e3)),this.delay=to(t.delay/1e3),this.currentRepeat=t.repeat}get repeatDirection(){return this.overrideDirection??this.config.direction}get isPingpong(){let t=this.repeatDirection;return t==="pingpong"||t==="pingpong-rewind"}get actualDelayDirection(){return this.isReversed?this.config.delayDirection==="start"?"end":this.config.delayDirection==="end"?"start":this.config.delayDirection:this.config.delayDirection}start(t){this.isPlaying=!0,this.currentRepeat=this.config.repeat,this.isFirstLerpAfterStart=!0,this.startTime=t,this.onStart?.()}stop(){this.isPlaying=!1}rearm(){this.onStart?.()}seek(t){this.lerp(t)}update(t){if(!this.isPlaying)return;let e=ID(t,this.startTime),r=0;if(this.isFirstLerpAfterStart||!this.isPingpong){let a=this.actualDelayDirection;if(this.config.delayDirection==="start-once"&&this.isFirstLerpAfterStart||a==="start"||a==="start-end"){if(e<this.delay)return;r=this.delay}}e=to(e-r);let i=this.duration===0?1:Math.min(Math.max(to(e/this.duration),0),1);if(this.lerp(i),!this.isPlaying||i!==1)return;let o=this.actualDelayDirection;if(o==="end"||o==="start-end"){if(e<to(this.duration+this.delay))return;this.endTime=Xc(this.startTime,to(to(r+this.duration)+this.delay))}else this.endTime=Xc(this.startTime,to(r+this.duration));if(this.isFirstLerpAfterStart=!1,this.currentRepeat===0){this.stop();return}this.currentRepeat>0&&(this.currentRepeat-=1),this.isPingpong?this.isReversed=!this.isReversed:this.lerp(0),this.startTime=t,this.onStart?.()}lerp(t){this.repeatDirection==="pingpong-rewind"&&this.isReversed?(t=to(1-t),t=this.ease(t),t=to(1-t)):t=this.ease(t),this.apply(t)}ease(t){return Ag(this.config.ease,this.duration,t)}};import{EventDispatcher as ZH}from"three";var A1=class{constructor(){this.clock=new vg;this.tickables=new Set;this.pendingRemovals=new Set;this.rafId=null;this.isFlushing=!1;this.useInternalRaf=!0;this.step=t=>{this.rafId=null,this.clock.tick(t),this.flush(),this.tickables.size>0&&this.requestFrame()}}get isUsingInternalRaf(){return this.useInternalRaf}set isUsingInternalRaf(t){this.useInternalRaf=t,t?(this.clock.resync(Pg()),this.requestFrame()):this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}get time(){return this.clock.time}get running(){return this.tickables.size>0}add(t){this.pendingRemovals.delete(t),this.tickables.size===0&&this.rafId===null&&this.clock.resync(Pg()),this.tickables.add(t),this.requestFrame()}remove(t){if(this.isFlushing){this.pendingRemovals.add(t);return}this.tickables.delete(t)}init(){this.clock.resync(Pg())}dispose(){this.removeAll(),this.clock.reset()}removeAll(){this.tickables.clear(),this.pendingRemovals.clear(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}update(t){this.clock.step(t/1e3),this.flush()}pause(){this.clock.paused=!0}resume(){this.clock.paused=!1,this.clock.resync(Pg()),this.requestFrame()}requestFrame(){this.rafId!==null||!this.useInternalRaf||this.tickables.size!==0&&(typeof requestAnimationFrame>"u"||(this.rafId=requestAnimationFrame(this.step)))}flush(){let t=this.clock.time;this.isFlushing=!0;try{for(let e of this.tickables)this.pendingRemovals.has(e)||e.update(t)}finally{this.isFlushing=!1;for(let e of this.pendingRemovals)this.tickables.delete(e);this.pendingRemovals.clear()}}};function Pg(){return typeof performance<"u"?performance.now():Date.now()}var li=new A1;function pH(n){return{easing:n.type,control1:bo(n.cubicControls?.control1,[0,0]),control2:bo(n.cubicControls?.control2,[1,1]),...n.springParameters}}function Hs(n,t){let e=[];for(let r of n??[]){let i=t(r.data);i!==void 0&&e.push({time:r.data.time,ease:pH(r.data.easing),value:i})}return{keyframes:OD(e)}}function vn(n,t){if(n.keyframes.length===0)return;let{index0:e,index1:r,t:i}=MD(n.keyframes,t),o=n.read;if(o&&o.index0===e&&o.index1===r&&o.t===i)return;let a={index0:e,index1:r,from:n.keyframes[e].value,to:n.keyframes[r].value,t:i};return n.read=a,a}function BD(n){n.read=void 0}function Cp(n,t,e){return n+(t-n)*e}import{MathUtils as Ig}from"three";import{PointLight as fH,Vector3 as Mg,Box3 as mH,Box3Helper as ND,Color as yH}from"three";import{PointLightHelper as hH}from"three";var Qc=class extends Vn(hH){constructor(e,r=15,i=6710886){super(e,r,i);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Gn(this.object,Qc.geometryHelper,e,r)}};var Ws=class extends Fc(fH,Qc){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let a=new Mg(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new Mg(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),l=new mH(a,s),c=new ND(l,new yH(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ND){let r=this.shadow.camera,i=new Mg(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),o=new Mg(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(i,o),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};import{Color as LD,Euler as gH,MathUtils as Kc,Matrix4 as _D,Quaternion as E1,Vector2 as Tp,Vector3 as Va}from"three";var{degToRad:Hwe,radToDeg:Wwe}=Kc,FD=new Va,kD=new Va,VD=new E1;function UD(n,t,e,r){if(r===0)return e.copy(n);if(r===1)return e.copy(t);let i=n.w*t.w+n.x*t.x+n.y*t.y+n.z*t.z;if(i>=1)return e.copy(n);let o=1-i*i;if(o<=Number.EPSILON){let d=1-r;return e.w=d*n.w+r*t.w,e.x=d*n.x+r*t.x,e.y=d*n.y+r*t.y,e.z=d*n.z+r*t.z,e.normalize(),e}let a=Math.sqrt(o),s=Math.atan2(a,i),l=Math.sin((1-r)*s)/a,c=Math.sin(r*s)/a;return e.w=n.w*l+t.w*c,e.x=n.x*l+t.x*c,e.y=n.y*l+t.y*c,e.z=n.z*l+t.z*c,e}function rr(n,t,e,r,i,o){let a=e[n]!==void 0?e[n]:void 0,s=r[n];if(s==null)return;let l=a!=null?typeof a=="string"?Number(i.getVariable(a)??0):a:t[n],c=typeof s=="string"?Number(i.getVariable(s)??0):s;if(l!==c)return{update:d=>{let u=Kc.lerp(l,c,d);o?t[n]=Math.trunc(u):t[n]=u},start:()=>{t[n]=l},end:()=>{t[n]=c}}}function Mp(n,t,e,r,i,o){let a=e[n]?e[n]:void 0,s=r[n];if(!s)return;let l=t[n],c=[...a??l].map(u=>typeof u=="string"?Number(i.getVariable(u)??0):u),d=[...s].map(u=>typeof u=="string"?Number(i.getVariable(u)??0):u);if(!(c.length!==d.length||Ao(c,d)))return{update:u=>{c.forEach((p,h)=>{let f=Kc.lerp(p,d[h],u);t[n][h]=o?Math.trunc(f):f})},start:()=>{Object.assign(t[n],c)},end:()=>{Object.assign(t[n],d)}}}function Pp(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function C1(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=o?Pp(new Va,o,i):s.clone(),c=Pp(new Va,a,i);if(!l.equals(c))return{update:d=>{s.lerpVectors(l,c,d)},start:()=>{s.copy(l)},end:()=>{s.copy(c)}}}function GD(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function Zc(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=!(s instanceof Tp),c=s instanceof Tp?s:new Tp().fromArray(s),d=o?GD(new Tp,o,i):c.clone(),u=GD(new Tp,a,i);if(!d.equals(u))return{update:p=>{c.lerpVectors(d,u,p),l&&(t[n]=c.toArray())},start:()=>{c.copy(d),l&&(t[n]=c.toArray())},end:()=>{c.copy(u),l&&(t[n]=c.toArray())}}}function zD(n,t,e,r){let i=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],s=i?new _D().fromArray(i):a.clone(),l=new Va,c=new E1,d=new Va;s.decompose(l,c,d);let u=new _D().fromArray(o),p=new Va,h=new E1,f=new Va;if(u.decompose(p,h,f),!s.equals(u))return{update:m=>{VD.slerpQuaternions(c,h,m),FD.lerpVectors(l,p,m),kD.lerpVectors(d,f,m),a.compose(FD,VD,kD)},start:()=>{a.compose(l,c,d)},end:()=>{a.compose(p,h,f)}}}function jD(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=o?typeof o=="string"?i.getColor(o).clone():new LD().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?i.getColor(a).clone():new LD().setRGB(a.r,a.g,a.b);if(l.equals(c))return;let d=s.clone();return{update:u=>{d.lerpColors(l,c,u),t[n]?.copy?.(d)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function Op(n,t,e,r,i){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let s=t[n],l=new Pt(s.r,s.g,s.b,s.a),c=o?typeof o=="string"?i.getColor(o).clone():new Pt(o.r,o.g,o.b,o.a):l.clone(),d=typeof a=="string"?i.getColor(a).clone():new Pt(a.r,a.g,a.b,a.a);if(!c.equals(d))return{update:u=>{l.lerpColors(c,d,u);let p=Kc.lerp(c.a,d.a,u);l.a=p,t[n]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(d)}}}function ro(n,t,e,r,i){if(typeof t[n]=="number")return rr(n,t,e??{},r,i);if(Array.isArray(t[n]))return Mp(n,t,e??{},r,i)}var qwe=new gH;function HD(n,t){if(!!n)for(let[e,r]of Object.entries(t)){let i=n[e];if(Array.isArray(i)&&Array.isArray(r)){let o=Math.min(i.length,r.length);for(let a=0;a<o;a++)i[a]=r[a]}else n[e]=r}}function Jc(n,t,e,r){let i={};if(!t||!e)return i;for(let o of n){let a=t[o],s=e[o];if(typeof a=="number"&&typeof s=="number")i[o]=Kc.lerp(a,s,r);else if(Array.isArray(a)&&Array.isArray(s)){let l=Math.min(a.length,s.length);i[o]=Array.from({length:l},(c,d)=>Kc.lerp(a[d],s[d],r))}}return i}function WD(n,t,e,r){let i=[];if(!("cloner"in e)||!n.cloner)return i;let o=n.cloner,a="cloner"in t?t.cloner:{},s=e.cloner;tb.forEach(h=>{let f;h==="count"?f=rr("count",o.parameters,a,s,r.shared,!0):f=ro(h,o.parameters,a??{},s,r.shared),f&&i.push(f)});let l=vH(o,a,s,r.shared);l?.length&&i.push(...l);let c=bH(o,a,s,r.shared);c?.length&&i.push(...c);let d=xH(o,a,s,r.shared);d?.length&&i.push(...d);let u=SH(o,a,s,r.shared);u?.length&&i.push(...u);let p=wH(o,a,s,r.shared);return p?.length&&i.push(...p),i.length&&i.push({update:()=>{o.update(r)}}),i}function vH(n,t,e,r){if(n.parameters.type!=="radial")return;let i=t.radial,o=e.radial;if(!o)return;let a=n.parameters.radial,s=[];return Nh.forEach(l=>{let c=ro(l,a,i??{},o,r);c&&s.push(c)}),s}function bH(n,t,e,r){if(n.parameters.type!=="linear")return;let i=t.linear,o=e.linear;if(!o)return;let a=[],s=n.parameters.linear;return Lh.forEach(l=>{let c=ro(l,s,i??{},o,r);c&&a.push(c)}),a}function xH(n,t,e,r){if(n.parameters.type!=="grid")return;let i=t.grid,o=e.grid;if(!o)return;let a=[],s=n.parameters.grid;return _h.forEach(l=>{let c;l==="count"?c=Mp(l,s,i??{},o,r,!0):c=ro(l,s,i??{},o,r),c&&a.push(c)}),a}function SH(n,t,e,r){if(n.parameters.type!=="toObject")return;let i=t.toObject,o=e.toObject;if(!o)return;let a=[],s=n.parameters.toObject;return Fh.forEach(l=>{let c;l==="count"?c=rr(l,s,i??{},o,r,!0):c=ro(l,s,i??{},o,r),c&&a.push(c)}),a}function wH(n,t,e,r){if(!n.parameters.randomness)return;let i=t.randomnessObject,o=e.randomnessObject;if(!o)return;let a=[],s=n.parameters.randomnessObject;return kh.forEach(l=>{let c=ro(l,s,i??{},o,r);c&&a.push(c)}),a}var qD=[["radial",Nh],["linear",Lh],["grid",_h],["toObject",Fh],["randomnessObject",kh]];function XD(n,t,e,r){if(!n)return{};let i=Jc(["count"],t,e,r);i.count!==void 0&&(i.count=Math.trunc(i.count));for(let[o,a]of qD){if(!n[o])continue;let s=Jc(a,t[o],e[o],r);Object.keys(s).length&&(i[o]=s)}return i}function YD(n,t){if(!!n){t.count!==void 0&&(n.count=t.count);for(let[e]of qD){let r=t[e];r&&HD(n[e],r)}}}import{Color as Og,Vector2 as T1,Vector3 as P1,MathUtils as qs}from"three";function KD(n,t,e,r){let i=[];if(Array.isArray(n.material)){if(!("materials"in e&&e.materials))return i;let o="materials"in t&&t.materials?t.materials:[],a=e.materials;n.material.forEach((s,l)=>{if(!a[l])return;let c=o[l]??{},d=a[l];typeof c=="string"||typeof d=="string"||i.push(...QD(s,c,d,r))})}else{if(!("material"in e&&e.material))return i;let o="material"in t&&t.material?t.material:{},a=e.material;if(typeof o=="string"||typeof a=="string")return i;i.push(...QD(n.material,o,a,r))}return i}function AH(n,t,e){let r=n.ensureRainbowNoiseCompiled;if(typeof r=="function")for(let i of[...n.layers]){if(i.type!=="rainbow")continue;let o=t.layers?.data(i.uuid),a=e.layers.data(i.uuid);(dn(o?.noiseStrength)||dn(a?.noiseStrength))&&r.call(n,i.uuid)}}function ZD(n,t,e,r,i){let o=n.getValue(r);if(o!==void 0){if(r==="colors")return IH(n,t,e,r);if(Array.isArray(o))return r==="steps"?OH(n,t,e,r):void 0;if(typeof o=="number")return EH(n,t,e,r,i);if(typeof o!="boolean"){if(o instanceof T1)return CH(n,t,e,r);if(o instanceof P1)return TH(n,t,e,r,i);if(o instanceof Pt)return MH(n,t,e,r,i);if(o instanceof Og)return PH(n,t,e,r,i);if("isTexture"in o)return RH(n,t,e,r)}}}function QD(n,t,e,r){let i=[],o=kn(e,r)||!!t.layers&&kn(t,r);i.push(BH(n,o)),AH(n,t,e);for(let a of n.layers){let s=t.layers?.data(a.uuid),l=e.layers.data(a.uuid);if(!l||a.type!=="light"&&(!(a.visible??!0)||!(l.visible??!0)))continue;let c=tc[a.type]??[],d=a.getNames().filter(u=>!c.includes(u)&&!jh.some(p=>u.includes(p)));for(let u of d)try{let p=ZD(a,s,l,u,r);p&&(Array.isArray(p)?i.push(...p):i.push(p))}catch(p){console.error(`lerpMaterial: unexpected material layer for ${u}`,p)}}return i}function EH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=t?t[r]:n.getValue(r),a=e[r],s=typeof o=="string"?Number(i.getVariable(o)??0):o,l=typeof a=="string"?Number(i.getVariable(a)??0):a;return{update:c=>{n.setValue(r,qs.lerp(s,l,c))},start:()=>{n.setValue(r,s)},end:()=>{n.setValue(r,l)}}}function CH(n,t,e,r){if(!n.hasValue(r)||!(r in e))return;let i=n.getValue(r),o=t?new T1().fromArray(t[r]):i.clone(),a=new T1().fromArray(e[r]);if(!o.equals(a))return{update:s=>{i.lerpVectors(o,a,s)},start:()=>{i.copy(o)},end:()=>{i.copy(a)}}}function TH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=n.getValue(r),a=t?t[r]:void 0,s=e[r],l=a?Pp(new P1,a,i):o.clone(),c=Pp(new P1,s,i);if(!l.equals(c))return{update:d=>{o.lerpVectors(l,c,d)},start:()=>{o.copy(l)},end:()=>{o.copy(c)}}}function PH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=t?t[r]:void 0,a=e[r],s=n.getValue(r),l=o?typeof o=="string"?i.color(o).clone():new Og().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?i.color(a).clone():new Og().setRGB(a.r,a.g,a.b);if(l.equals(c))return;let d=s.clone();return{update:u=>{n.getValue(r)!==d&&n.setValue(r,d),d.lerpColors(l,c,u)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function MH(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let o=t?t[r]:void 0,a=e[r],s=n.getValue(r),l=o?typeof o=="string"?i.color(o).clone():new Og().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?i.color(a).clone():new Pt(a.r,a.g,a.b,a.a);if(l.equals(c))return;let d=s.clone();return{update:u=>{n.getValue(r)!==d&&n.setValue(r,d),d.lerpColors(l,c,u)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function OH(n,t,e,r="steps"){if(!n.hasValue(r)||!(r in e))return;let i=[],o=n.getValue(r),a=t?t[r]:o,s=e[r];return Ao(a,s)||i.push({update:l=>{let c=[...o];for(let d=0;d<o.length;++d){let u=a[d],p=s[d];c[d]=qs.lerp(u,p,l)}n.setValue(r,c)},start:()=>{n.setValue(r,a)},end:()=>{n.setValue(r,s)}}),i.length?i:void 0}function IH(n,t,e,r="colors"){if(!n.hasValue(r)||!(r in e))return;let i=[],o=n.getValue(r),a=t?t[r]:o.map(l=>l.toArray()),s=e[r];for(let l=0;l<o.length;++l){let c=[...a[l]],d=[...s[l]];as.isEqual(c,d)||i.push({update:u=>{o[l].fromArray(as.lerp(c,d,u))},start:()=>{o[l].fromArray(c)},end:()=>{o[l].fromArray(d)}})}return i.length?i:void 0}function DH(n){let t=n.getNode("mat");if(typeof t?.updateMatrix=="function")return t;let e=n.getValue("mat");return typeof e?.updateMatrix=="function"?e:void 0}function RH(n,t,e,r="texture"){if(!n.hasValue(r)||!(r in e))return;let i=n.getNode("rotation"),o=t?.[r]?.rotation??0,a=e[r]?.rotation??0;if(i&&o!==a)return{update:y=>{i.value=qs.lerp(o,a,y)*qs.DEG2RAD},start:()=>{i.value=o*qs.DEG2RAD},end:()=>{i.value=a*qs.DEG2RAD}};let s=DH(n);if(!s)return;let l=t?t[r]:s,c=e[r],d=[...l.repeat],u=[...l.offset],p=[...c.repeat],h=[...c.offset],f=l.rotation??0,m=c.rotation??0;if(!xi.isEqual(d,p)||!xi.isEqual(u,h)||f!==m)return{update:y=>{s.repeat=xi.lerp(d,p,y),s.offset=xi.lerp(u,h,y),s.rotation=qs.lerp(f,m,y),s.updateMatrix()},start:()=>{s.repeat=[...d],s.offset=[...u],s.rotation=f,s.updateMatrix()},end:()=>{s.repeat=[...p],s.offset=[...h],s.rotation=m,s.updateMatrix()}}}function M1(n,t,e,r,i,o){let a=ZD(t,e,r,n,o);!a||(Array.isArray(a)?a.forEach(s=>s.update(i)):a.update(i))}function BH(n,t){return{update:()=>{n.transparent=t}}}function JD(n,t,e,r,i){let o=NH(n,t);return{duration:e,evaluate(a,s){n.resetBBoxNeedsUpdate();let l=_H();for(let c of o)kH(c,n,a,r,i,s,l);FH(n,l,r)},invalidate(){for(let a of o)BD(a.track)}}}function NH(n,t){let e=[];return xo.groupKeyframes(t.keyframes).forEach(r=>{let i=r.path?.[0],o=r.path[1],a=()=>Hs(r.keyframes,s=>s.value);switch(i){case"position":case"rotation":case"scale":o&&xl.includes(o)&&e.push({on:i,axis:o,track:a()});return;case"shape size":o&&xl.includes(o)&&"geometry"in n&&e.push({on:"shapeSize",axis:o,track:a()});return;case"path extrusion":fs(n)&&e.push({on:"pathExtrusion",track:Hs(r.keyframes,s=>s.value)});return;case"path snapping":n.data.pathSnapping&&e.push({on:"pathSnapping",track:Hs(r.keyframes,s=>s.value)});return;case"material":n.type==="Mesh"&&"material"in n&&LH(n,r).forEach(s=>e.push(s));return;case"opacity":n.type==="Mesh"&&"material"in n&&e.push({on:"opacity",track:a()});return;case"cloner":e.push({on:"cloner",track:Hs(r.keyframes,s=>s.value)});return;case"camera":n instanceof St&&e.push({on:"camera",field:"zoom",track:a()});return;case"light":(n instanceof Uo||n instanceof Ws||n instanceof zo)&&e.push({on:"light",field:r.path[1],track:Hs(r.keyframes,s=>s.value)});return}}),e}function LH(n,t){let e=fm(n.material)?n.material:void 0,r=t.layerId;if(!e||!r)return[];let i=t.keyframes.some(d=>dn(d.data.value?.noiseStrength)),o=e.ensureRainbowNoiseCompiled,a=d=>{i&&typeof o=="function"&&o.call(e,d)},s=d=>"data"in d?[{on:"material",layer:d,track:Hs(t.keyframes,u=>u.value)}]:[];a(r);let l=e.getLayerByUuid(r);if(l)return s(l);let c=t.path[1];for(let d of e.getLayersOfType(c))a(d.uuid);return(e.getLayersOfType(c)??[]).flatMap(s)}function _H(){return{transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1}}function FH(n,t,e){if(t.size&&n instanceof Qe){let{x:r,y:i,z:o}=n.userData.value;n.updateGeometryInteractions({width:r,height:i,depth:o},e.shared)}t.cloner&&n.cloner?.update(e),t.transform&&n.updateMatrix(),t.bounds&&n.resetBBoxNeedsUpdate(),t.boolean&&n instanceof Qe&&n.invalidateDownstreamBooleanData(),t.render&&n.dispatchEvent({type:"requestRender"})}function Yo(n,t,e){!n||(n[t]={...n[t],...e})}function kH(n,t,e,r,i,o,a){let s=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(n.on){case"position":case"scale":{let l=vn(n.track,e);if(!l)return;let c=Cp(l.from,l.to,l.t);t[n.on][n.axis]=c,Yo(o,n.on,{[n.axis]:c}),s();return}case"rotation":{let l=vn(n.track,e);if(!l)return;let c=Cp(l.from,l.to,l.t);t.rotation[n.axis]=c*Ig.DEG2RAD,Yo(o,"rotation",{[n.axis]:c}),s();return}case"shapeSize":{let l=vn(n.track,e);if(!l||!(t instanceof Qe))return;let c=Cp(l.from,l.to,l.t);t.userData.value={...t.userData.value,[n.axis]:c},Yo(o,"shapeSize",{[n.axis]:c}),a.size=!0,a.bounds=!0,a.boolean=!0,a.render=!0;return}case"opacity":{let l=vn(n.track,e);if(!l||!(t instanceof Je)||Array.isArray(t.material))return;let c=t.material.getLayersOfType("light")[0];if(c===void 0)return;let d=Ig.lerp(l.from,l.to,l.t);t.material.transparent=!0,M1("alphaOverride",c,{alphaOverride:d},{alphaOverride:d+1},0,r.shared),o&&(o.opacity=d),a.render=!0;return}case"material":{let l=vn(n.track,e);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:c}=n,d={};for(let u in c.data){if(!(u in l.from)||!(u in l.to))continue;let p=O1(l.from[u],l.to[u],l.t,i);if(p===void 0)continue;d[u]=p;let h=c.getValue(u);h!==void 0&&(u==="alpha"&&typeof h=="number"&&h>0&&t instanceof Je&&!Array.isArray(t.material)&&(t.material.transparent=!0),M1(u,c,l.from,l.to,l.t,r.shared))}Yo(o,"material",{[c.uuid]:d}),a.render=!0;return}case"light":{let l=vn(n.track,e);if(!l||!(t instanceof Uo||t instanceof Ws||t instanceof zo))return;let c=O1(l.from,l.to,l.t,i);t[n.field]=c,Yo(o,"light",{[n.field]:c}),a.render=!0;return}case"camera":{let l=vn(n.track,e);if(!l||!(t instanceof St))return;let c=Cp(l.from,l.to,l.t);t[n.field]=c,Yo(o,"camera",{[n.field]:c});return}case"cloner":{let l=vn(n.track,e);if(!l)return;let d=t.cloner?.parameters,u=XD(d,l.from,l.to,l.t);YD(d,u),Yo(o,"cloner",u),a.cloner=!0,a.boolean=!0,a.render=!0;return}case"pathExtrusion":{let l=vn(n.track,e);if(!l||!fs(t))return;let c=Jc(Wd,l.from,l.to,l.t),d=t.geometry.userData.parameters;d.extrusion={...d.extrusion,...c},Yo(o,"pathExtrusion",c),t.updateGeometryInteractions({extrusion:{...d.extrusion}},r.shared),a.bounds=!0,a.boolean=!0,a.render=!0;return}case"pathSnapping":{let l=vn(n.track,e);if(!l)return;let c=t,d=Jc(yE,l.from,l.to,l.t);c.userData.pathSnapping={...c.userData.pathSnapping,...d},Yo(o,"pathSnapping",d),c.updatePathSnapping(c.userData.pathSnapping),a.render=!0;return}}}function O1(n,t,e,r){if(typeof n=="string"&&r&&(n=r.color(n)),typeof t=="string"&&r&&(t=r.color(t)),typeof n=="number")return Ig.lerp(n,t,e);if(Ue.is(n))return Ue.lerp(n,t,e);if(Ut.is(n))return Ut.lerp(n,t,e);if(Array.isArray(n))return(n.length>t.length?t:n).map((o,a)=>{if(Array.isArray(o)){let s=n[a].length>t[a].length?t[a].length:n[a].length;return(s===4?as:s===3?Ni:xi).lerp(n[a],t[a],e)}return Ig.lerp(n[a],t[a],e)});if(typeof n=="object"&&n!==null){let i={};for(let o in n){let a=O1(n[o],t[o],e,r);a!==void 0&&(i[o]=a)}return i}}import{MathUtils as VH}from"three";function $D(n,t,e,r){let i=[],o=n.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,a=n.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(a!==void 0){let s=o??n.zoom,l=a;s!==l&&i.push({update:c=>{n.zoom=VH.lerp(s,l,c),n.updateProjectionMatrix()},start:()=>{n.zoom=s,n.updateProjectionMatrix()},end:()=>{n.zoom=l,n.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let s=rr("targetOffset",n,t,e,r);s&&i.push(s)}return i}import{MathUtils as I1}from"three";function GH(n,t,e,r){if(e.scaleBaked===void 0)return;let i=(t.scaleBaked??n.appliedGeometrySize??n.data.geometry.scaleBaked).map(s=>typeof s=="string"?Number(r.shared.getVariable(s)??0):s),o=e.scaleBaked.map(s=>typeof s=="string"?Number(r.shared.getVariable(s)??0):s);if(Ni.isEqual(i,o))return;let a=[];return a.push({update:s=>{n.updateGeometryInteractions({scaleBaked:[I1.lerp(i[0],o[0],s),I1.lerp(i[1],o[1],s),I1.lerp(i[2],o[2],s)]},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)},start:()=>{n.updateGeometryInteractions({scaleBaked:i},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)},end:()=>{n.updateGeometryInteractions({scaleBaked:o},r.shared),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions(r)}}),a}function UH(n,t,e,r){if(!e.extrusion)return;let i=n.extrusion,o=t.extrusion??{},a=e.extrusion,s=[];return Wd.forEach(l=>{let c=ro(l,i,o,a,r);c&&s.push(c)}),s}function eR(n,t,e,r){let i=[];if(!("geometry"in e))return i;let o=n.geometry.userData.parameters,a="geometry"in t?t.geometry:{},s=e.geometry;if(n instanceof Ro){let l=GH(n,a,s,r);l&&i.push(...l)}else{let l={},c=n.appliedGeometrySize;if(Object.assign(l,Jd(o,Yh),c?{width:c[0],height:c[1],depth:c[2]}:{},Jd(a,Yh)),Yh.forEach(d=>{let u=ro(d,l,a,s,r.shared);u&&i.push(u)}),fs(n)){Object.assign(l,{extrusion:{...o.extrusion}});let d=UH(l,a,s,r.shared);d&&i.push(...d)}i.length&&i.push({update:d=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)},start:d=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)},end:d=>{n.updateGeometryInteractions(l,r.shared),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions(r)}})}return i}function tR(n,t,e,r){let i=[];if(e.intensity!==void 0){let o=rr("intensity",n,t,e,r);o&&i.push(o)}if(e.color!==void 0){let o=jD("color",n,t,e,r);o&&i.push(o)}return i}import{Euler as zH,Vector3 as Dg,MathUtils as rR}from"three";import{Quaternion as iR}from"three";var D1=new Dg,nR=new zH;function oR(n,t,e,r,i){let o=[],a,s,l,c,d,u,p,h;if(Br(n)?(a=Zc("position",n,t,e,i),a&&o.push(a),l=rr("rotation",n,t,e,i),l&&o.push(l),c=Zc("shear",n,t,e,i),c&&o.push(c)):(h={slide:t.pathSnapping?.slide??n.updatedPathSnapping?.slide??n.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??n.updatedPathSnapping?.offset??n.dataPatched.pathSnapping?.offset??0},u=rr("slide",h,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),u&&o.push(u),p=rr("offset",h,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),p&&o.push(p),!u&&!p&&(a=C1("position",n,t,e,i),a&&o.push(a),s=C1("scale",n,t,e,i),s&&o.push(s),l=jH(n,t,e,r,i),l&&o.push(l),d=zD("hiddenMatrix",n,t,e),d&&o.push(d))),a||s||l||d||u||p){let f=Br(n)?()=>{n.updateWorldMatrix(!0,!1,!0),n.resetBBoxNeedsUpdate()}:()=>{n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldRigid()),n.parent?.matrixWorldFusedFalse&&(n.matrixWorld.multiplyMatrices(n.parent.matrixWorldFusedFalse,n.matrix),n.matrixWorldNeedsUpdate=!1),gi(n)&&Ci(n.parent)&&n.invalidateDownstreamBooleanData(!0),n.updatePathSnapping(Object.assign({},t.pathSnapping,h))};o.push({update:f,start:f,end:f})}return o}function jH(n,t,e,r,i){let o=t?.rotation?t.rotation.map(d=>(typeof d=="string"?Number(i.getVariable(d)??0):d)*rR.DEG2RAD):void 0,a=e.rotation?.map(d=>(typeof d=="string"?Number(i.getVariable(d)??0):d)*rR.DEG2RAD);if(!a)return;let s=o?new Dg().fromArray(o):new Dg().setFromEuler(n.rotation),l=new Dg().fromArray(a);if(s.equals(l))return;let c=D1.subVectors(l,s);if(r&&c.toArray().every(d=>Math.abs(d)<2*Math.PI)){let d=new iR().setFromEuler(nR.setFromVector3(s)),u=new iR().setFromEuler(nR.setFromVector3(l));return{update:p=>{UD(d,u,n.quaternion,p)},start:()=>{n.rotation.setFromVector3(s)},end:()=>{n.rotation.setFromVector3(l)}}}else return{update:d=>{D1.lerpVectors(s,l,d),n.rotation.setFromVector3(D1)},start:()=>{n.rotation.setFromVector3(s)},end:()=>{n.rotation.setFromVector3(l)}}}function HH(n,t){return{update:()=>{n instanceof Rt&&(n.fill.enabled=t)}}}function WH(n,t){return{update:()=>{n instanceof Rt&&(n.stroke.enabled=t)}}}function qH(n,t){return{update:()=>{n instanceof Rt&&(n.dropShadow.enabled=t)}}}function XH(n,t){return{update:()=>{n instanceof Rt&&(n.innerShadow.enabled=t)}}}function YH(n,t){return{update:()=>{n instanceof Rt&&(n.backgroundBlur.enabled=t)}}}function QH(n,t){return{update:()=>{n instanceof Rt&&(n.layerBlur.enabled=t)}}}function aR(n,t,e,r,i){let o=[],a,s,l,c,d,u,p,h,f,m,y,g,b,x,S;if("width"in n&&(a=rr("width",n,t,e,i),a&&o.push(a)),"height"in n&&(s=rr("height",n,t,e,i),s&&o.push(s)),n instanceof Rt||n instanceof Lr){let v={...t.fill},w={...e.fill};v.enabled!==void 0&&v.enabled!==w.enabled&&(o.push(HH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),l=Op("color",n.fill,v,w,i),l&&o.push(l)}if(n instanceof Rt){let v={...t.stroke},w={...e.stroke};(v.enabled||w.enabled)&&(o.push(WH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),c=Op("color",n.stroke,v,w,i),c&&o.push(c),d=rr("thickness",n.stroke,v,w,i),d&&o.push(d)}if(n instanceof Rt){let v={...t.dropShadow},w={...e.dropShadow};(v.enabled||w.enabled)&&(o.push(qH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),u=Op("color",n.dropShadow,v,w,i),u&&o.push(u),p=rr("blurRadius",n.dropShadow,v,w,i),p&&o.push(p),f=rr("spread",n.dropShadow,v,w,i),f&&o.push(f),h=Zc("offset",n.dropShadow,v,w,i),h&&o.push(h)}if(n instanceof Rt){let v={...t.innerShadow},w={...e.innerShadow};(v.enabled||w.enabled)&&(o.push(XH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,color:{...v.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),m=Op("color",n.innerShadow,v,w,i),m&&o.push(m),y=rr("blurRadius",n.innerShadow,v,w,i),y&&o.push(y),b=rr("spread",n.innerShadow,v,w,i),b&&o.push(b),g=Zc("offset",n.innerShadow,v,w,i),g&&o.push(g)}if(n instanceof Rt||n instanceof Lr){let v={...t.backgroundBlur},w={...e.backgroundBlur};(v.enabled||w.enabled)&&(o.push(YH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,radius:0}),w.enabled||Object.assign(w,{enabled:!0,radius:0})),x=rr("radius",n.backgroundBlur,v,w,i),x&&o.push(x)}if(n instanceof Rt){let v={...t.layerBlur},w={...e.layerBlur};(v.enabled||w.enabled)&&(o.push(QH(n,!0)),v.enabled||Object.assign(v,{enabled:!0,radius:0}),w.enabled||Object.assign(w,{enabled:!0,radius:0})),S=rr("radius",n.layerBlur,v,w,i),S&&o.push(S)}if(n instanceof Lr||n instanceof Yi){let v=Mp("cornerRadius",n,t,e,i);v&&o.push(v)}return o}function sR(n,t,e,r,i){let o=[];return n.data.visible&&o.push(...oR(n,t,e,i,r.shared)),Br(n)?o.push(...aR(n,t,e,i,r.shared)):(n.data.visible&&o.push(...WD(n,t,e,r)),n instanceof Je?(n instanceof Qe&&n.data.visible&&o.push(...eR(n,t,e,r)),n.data.visible&&!(n instanceof er&&n.materialOverride)&&o.push(...KD(n,t,e,r.shared))):Ry.is(n)?n.data.visible&&o.push(...tR(n,t,e,r.shared)):n instanceof St&&o.push(...$D(n,t,e,r.shared))),o.length?{update:a=>{o.forEach(s=>s.update(a))},start:a=>{o.forEach(s=>s.start?.(a))},end:a=>{o.forEach(s=>s.end?.(a))}}:void 0}var R1={type:"beginState"};function B1(n){if(n.easing===5){let{control1:t,control2:e}=n;return{easing:5,control1:t??ss.defaultData.control1,control2:e??ss.defaultData.control2}}if(n.easing===6){let{mass:t,stiffness:e,damping:r,velocity:i}=n;return{easing:6,mass:t??fo.defaultData.mass,stiffness:e??fo.defaultData.stiffness,damping:r??fo.defaultData.damping,velocity:i??fo.defaultData.velocity}}return{easing:n.easing}}function N1(n){return{delay:n.delay,delayDirection:n.delayDirection??"start-end",direction:n.direction??"normal",repeat:n.repeat}}function KH(n){return{duration:n.duration,ease:B1(n),...N1(n)}}var L1={type:"completeState",isfromEntity:!1};function Ip(n,t){let e,r;if(typeof t=="string"?(e=t,r=n.states?.[e]):t===null&&(e=null,r=n.data),!(e===void 0||r===void 0))return{id:e,data:r}}var Xs=class{constructor(t,e,r,i,o,a,s,l={}){this.object=t;this.fromRef=e;this.toRef=r;this.data=i;this.sharedAssets=o;this.allowSlerp=a;this.page=s;this.hooks=l;this.builtReversed=!1;this.startStateId=null;this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=Br(this.object)?null:this.object.transitionState.state,this.callback=sR(this.object,{},this.end.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)};this.onChange=t=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(t),this.object.requestRender()),this.writeState(t)};this.runner=new Yc(KH(i),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let i=Ip(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!i)throw new Error("Missing property");this.from=i}else{let i=Ip(this.object,t);if(!i)throw new Error("Missing property");this.from=i}if(e===void 0)throw new Error("Missing property");let r=Ip(this.object,e);if(!r)throw new Error("Missing property");this.to=r,this.buildCallback()}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||Br(this.object))return;let e=t===1,r=t>.5?this.targetStateId:this.startStateId,i=this.object.transitionState;i.settled===e&&i.state===r||(this.object.transitionState={settled:e,state:r},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=r,this.object.dispatchEvent({type:"transitionState",settled:e,state:r}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:r}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof St&&o.dispatchEvent(e?L1:R1)}),e?this.hooks.onComplete?.(r):this.hooks.onBegin?.(r))}};var _1=new Map,Dp=new Map,Pi=class extends ZH{constructor(e,r,i,o,a,s,l){super();this.id=e;this.data=r;this.scene=i;this.sharedAssets=o;this.object=a;this.eventType=s;this.actionCondition=l;this.evaluators=[];this.elapsed=0;this.lastTime=null;this.direction=1;this._playing=!1;this._finished=!1;this.hasPlayedOnce=!1;this.pauseOnNextCycleEnd=!1;this.lastCycleIndex=0;try{let c=vl.findTimeline(this.scene.data.objects,this.data.timeline),d=c.duration;this.animatedObjectIds=Object.keys(c.objectTimelines),this.animatedObjectIds.forEach(u=>{let p=this.scene.find(u);if(!p)return;let h=c.objectTimelines[u];!h||this.evaluators.push(JD(p,{...h},d,{scene:i,shared:o},this.sharedAssets))}),this.schedule=new Eg(PD(this.data,d))}catch(c){throw!1&&console.error(c),new Error("Missing property")}a&&(Dp.has(a.uuid)?Dp.get(a.uuid).push(this):Dp.set(a.uuid,[this])),_1.set(e,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(e){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(e-this.lastTime)*this.direction)),this.lastTime=e,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0){this.pause();return}let e=this.schedule.resolve(this.elapsed);if(e){if(e.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=e.cycleIndex,this.pauseOnNextCycleEnd)){this.pauseOnNextCycleEnd=!1,this.pause();return}for(let r of this.evaluators)r.evaluate(e.localTime);return}this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(e=>{let r=this.scene.find(e);r instanceof St&&r.dispatchEvent(L1)})}startTicking(){this._playing=!0,this.lastTime=null;for(let e of this.evaluators)e.invalidate();li.add(this)}play(){let e=this.eventType!==void 0&&jd(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&jd(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!e||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(r=>{let i=this.scene.find(r);i instanceof St&&i.dispatchEvent(R1)}),!e&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,li.remove(this)}stop(){this.pause(),this.elapsed=0,this.lastCycleIndex=0,this.applyAtElapsed(),this._finished=!1}seek(e){let r=this.schedule.totalDuration;this.elapsed=e*(Number.isFinite(r)?r:this.schedule.effectiveCycleDuration);for(let i of this.evaluators)i.invalidate();this.applyAtElapsed()}toggle(e){let r=e??this.direction===-1;this._playing&&this.direction===(r?1:-1)||(r&&this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=r?1:-1,this.pauseOnNextCycleEnd=!1,this.startTicking())}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},F1=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>{r[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(r=>{r[this.data.interaction]()}))}getTimelineActions(t){let e=_1.get(t);return e?[e]:[..._1.values()].filter(r=>r.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=Dp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllTimelines(){let t=[...Dp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Rg=class{constructor(t,e,r,i,o,a,s){this.data=e;let l="interaction"in e?e.interaction:"play";if(l==="play"||l===void 0)this.interaction=new Pi(t,e,r,i,o,a,s);else if(l==="pause"||l==="stop")this.interaction=new F1(e);else throw new Error("Missing property")}get playing(){return this.interaction instanceof Pi?this.interaction.playing:!1}get finished(){return this.interaction instanceof Pi?this.interaction.finished:!0}get paused(){return this.interaction instanceof Pi?this.interaction.paused:!0}play(){if(this.interaction instanceof Pi)return this.interaction.play();this.interaction.dispatch()}stop(){this.interaction instanceof Pi&&this.interaction.stop()}seek(t){this.interaction instanceof Pi&&this.interaction.seek(t)}toggle(t){this.interaction instanceof Pi?this.interaction.toggle(t):this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof Pi?this.interaction.playFromCurrent():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Pi?qe(this.interaction.sharedAssets,this.interaction.actionCondition)&&this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof Pi&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};kt("TimelineAnimation",({id:n,data:t,page:e,shared:r,object:i,eventType:o,actionCondition:a})=>new Rg(n,t,e.scene,r,i,o,a));Oe("timeline");import{EventDispatcher as JH}from"three";function $H(n){let t=n.tweens[0]?.data;return{delay:t?.delay??n.delay,delayDirection:t?.delayDirection??"start-once",direction:t?.direction??n.direction,repeat:t?.repeat??n.repeat}}var e5={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},Bg=class extends JH{constructor(e,r,i,o,a,s){super();this.eventType=e;this.data=r;this.page=i;this.shared=o;this.condition=a;this.runModeOverride=s;this.tweens=[];this.hasPlayedOnce=!1;if(!r.object)throw new Error("Missing property");let l=this.page.scene.find(r.object)??this.page.uiCanvas?.find(r.object)??this.page.scene.find2DInUIObjects(r.object);if(!l)throw new Error("Missing property");if(!l.states)throw new Error("Missing property");if(this.object=l,r.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}init(){this.initialCurrentState=Ip(this.object,this.object.currentState).id,this.build()}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:jd(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}build(){let e=this.data.tweens,r=[];try{let i=e[0].data.state;i!==void 0&&r.push(new Xs(this.object,i,i,e5,this.shared,this.data.allowSlerp??!1,this.page));for(let o=1;o<e.length;o++){let a=e[o-1],s=e[o];r.push(new Xs(this.object,a.data.state===void 0?this.currentState:a.data.state,s.data.state===void 0?this.currentState:s.data.state,s.data,this.shared,this.data.allowSlerp??!1,this.page))}}catch(i){i instanceof Error&&console.error(i.message);return}this.tweens=r,this.runner=new Tg({...N1($H(this.data)),runMode:this.runMode},r.map(i=>i.runner),{claim:()=>this.claimObject(),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(){return this.object.previousAction===this?!1:(this.object.previousAction?.animating===!0&&this.object.previousAction.pause(),this.object.previousAction=this,!0)}rebindTweens(){for(let e of this.tweens)try{e.rebind()}catch(r){r instanceof Error&&console.error(r.message)}this.object instanceof St&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}update(e){this.runner?.update(e),this.runner?.isPlaying!==!0&&li.remove(this)}play(){if(qe(this.shared,this.condition)===!1||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(li.time),this.runner.isPlaying&&li.add(this))}pause(){this.runner?.stop(),li.remove(this)}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;Br(this.object)?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(qe(this.shared,this.condition)===!1)return!1;this.runner?.seek(e)}playDirected(e){if(qe(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(li.time,e),this.runner.isPlaying&&li.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};import{EventDispatcher as t5,MathUtils as r5}from"three";function lR(n){let t=n?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=$E(t);return e&&e>2?e:2}return 2}var Ng=class extends t5{constructor(e,r,i,o,a){super();this.data=e;this.page=r;this.animationControls=i;this.shared=o;this.condition=a;this.startOnceDelay=0;this.toggleIsForward=!1;let s=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(s=l.identity[0]),this.data={...e,object:s};let c=this.animationControls.clipIdToAction[e.clipId+"/"+s];if(this.duration=c?.getClip()?.duration??1,this.data.crop2){let d=lR(c?.getClip());this.leftFrameTime=this.data.crop2[0]/(d-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(d-1)*this.duration}else{let d=c?.getClip()?.tracks[0]?.times.length;d&&d>1?(this.leftFrameTime=this.data.crop[0]/d*this.duration,this.rightFrameTime=this.data.crop[1]/d*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(qe(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,o])=>{let a=i.split("/")[1];this.threeAnimAction!==o&&a===r&&(e?o.fadeOut(.2):o.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=r5.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(qe(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([o,a])=>{let s=o.split("/")[1];this.threeAnimAction!==a&&s===i&&a.isRunning()&&(r?a.fadeOut(.2):a.stop())}),r&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var i5=null;function cR(n){i5=n}cR(Xs);kt("Transition",({eventType:n,data:t,page:e,shared:r,actionCondition:i,runModeOverride:o})=>new Bg(n,t,e,r,i,o));kt("Animation",({data:n,page:t,eventManager:e,shared:r,actionCondition:i})=>new Ng(n,t,e.animationControls,r,i));Oe("transitions");var n5="text/plain",o5="us-ascii",dR=(n,t)=>t.some(e=>e instanceof RegExp?e.test(n):e===n),a5=(n,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(n);if(!e)throw new Error(`Invalid URL: ${n}`);let{type:r,data:i,hash:o}=e.groups,a=r.split(";");o=t?"":o;let s=!1;a[a.length-1]==="base64"&&(a.pop(),s=!0);let l=(a.shift()||"").toLowerCase(),d=[...a.map(u=>{let[p,h=""]=u.split("=").map(f=>f.trim());return p==="charset"&&(h=h.toLowerCase(),h===o5)?"":`${p}${h?`=${h}`:""}`}).filter(Boolean)];return s&&d.push("base64"),(d.length>0||l&&l!==n5)&&d.unshift(l),`data:${d.join(";")},${s?i.trim():i}${o?`#${o}`:""}`};function k1(n,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},n=n.trim(),/^data:/i.test(n))return a5(n,t);if(/^view-source:/i.test(n))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=n.startsWith("//");!e&&/^\.*\//.test(n)||(n=n.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(n);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,s=0,l="";for(;;){let d=a.exec(i.pathname);if(!d)break;let u=d[0],p=d.index,h=i.pathname.slice(s,p);l+=h.replace(/\/{2,}/g,"/"),l+=u,s=p+u.length}let c=i.pathname.slice(s,i.pathname.length);l+=c.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=i.pathname.split("/"),s=a[a.length-1];dR(s,t.removeDirectoryIndex)&&(a=a.slice(0,-1),i.pathname=a.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...i.searchParams.keys()])dR(a,t.removeQueryParameters)&&i.searchParams.delete(a);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let o=n;return n=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!o.endsWith("/")&&i.hash===""&&(n=n.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(n=n.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(n=n.replace(/^http:\/\//,"//")),t.stripProtocol&&(n=n.replace(/^(?:https?:)?\/\//,"")),n}var Lg=class{constructor({url:t,context:e},r,i,o){this.controlsManager=r;this.shared=i;this.condition=o;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:k1(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;Pl?window.location.assign(this.url):(this.context==="tab"||Bb&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(sr[0]),ZE())}};var _g=class{constructor(t,e,r,i,o){this.data=t;this.page=e;this.shared=r;this.eventManager=i;this.condition=o}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),yg(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};import{EventDispatcher as s5,Quaternion as uR,Vector3 as pR}from"three";var l5={type:"beginState"},hR={type:"completeState",isfromEntity:!1},fR={type:"requestRender"},Fg=class extends s5{constructor(e,r,i,o){super();this.data=e;this.page=r;this.shared=i;this.condition=o;this.toggleIsForward=!1;this.posStart=new pR;this.posEnd=new pR;this.qStart=new uR;this.qEnd=new uR;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(e=!1){if(!this.data.animate)return;let r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let i={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:B1(this.data)},o=a=>{let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,a),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,a),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*a,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(fR),a===1&&s.dispatchEvent(hR)};this.runner=new Yc(i,o,()=>{this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(l5),o(0)})}update(e){this.runner?.update(e),this.runner?.isPlaying!==!0&&li.remove(this)}start(){!this.runner||(this.runner.start(li.time),li.add(this))}switchCamera(e){let r=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),r.dispatchEvent({type:"cameraChange",camera:i})}play(){if(qe(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.start()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.runner?.stop(),li.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(qe(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(),this.start()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(hR),this.page.activeCamera.dispatchEvent(fR))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var kg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(qe(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let r=this.shared.data.variables.data(e)?.value;r!==void 0&&this.shared.updateVariable(e,r),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(hm(e))})}dispose(){}};kt("Link",({data:n,eventManager:t,shared:e,actionCondition:r})=>new Lg(n,t.controlsManager,e,r));kt("Reset",({data:n,page:t,shared:e,eventManager:r,actionCondition:i})=>new _g(n,t,e,r,i));kt("SwitchCamera",({data:n,page:t,shared:e,actionCondition:r})=>new Fg(n,t,e,r));kt("ClearLocalStorage",({data:n,page:t,shared:e,actionCondition:r})=>new kg(n,t,e,r));Oe("misc-actions");var c5=new Map;function Or(n,t){c5.set(n,t)}import{DepthStencilFormat as HTe,DepthTexture as WTe,LinearFilter as qTe,SRGBColorSpace as YTe,UnsignedByteType as QTe,UnsignedIntType as KTe,UnsignedInt248Type as ZTe,Vector2 as JTe,WebGLRenderTarget as $Te}from"three";import{NearestFilter as tPe,WebGLRenderTarget as rPe}from"three";import{NoBlending as nPe,REVISION as oPe,ShaderMaterial as aPe,Uniform as sPe}from"three";import{NoBlending as d5,ShaderMaterial as u5,Uniform as $c,Vector2 as p5,Vector4 as mR}from"three";import{BasicDepthPacking as f5,NoBlending as m5,PerspectiveCamera as y5,ShaderMaterial as g5,Uniform as Rp}from"three";import{LinearSRGBColorSpace as uPe,REVISION as pPe,RGBAFormat as hPe,SRGBColorSpace as fPe,UnsignedByteType as mPe}from"three";import{NoBlending as x5,ShaderMaterial as S5,Uniform as Bp,Vector2 as V1}from"three";import{NoBlending as vPe,ShaderMaterial as bPe,Uniform as xPe}from"three";import{NoBlending as wPe,PerspectiveCamera as APe,RGBADepthPacking as EPe,ShaderMaterial as CPe,Uniform as TPe}from"three";import{BasicDepthPacking as MPe,NoBlending as OPe,ShaderMaterial as IPe,Uniform as DPe,Vector2 as RPe}from"three";import{BasicDepthPacking as NPe,NoBlending as LPe,ShaderMaterial as _Pe,Uniform as FPe,Vector2 as kPe}from"three";import{AlwaysDepth as GPe,BasicDepthPacking as UPe,EqualDepth as zPe,GreaterDepth as jPe,GreaterEqualDepth as HPe,LessDepth as WPe,LessEqualDepth as qPe,NeverDepth as XPe,NoBlending as YPe,NotEqualDepth as QPe,ShaderMaterial as KPe,Uniform as ZPe}from"three";import{BasicDepthPacking as $Pe,NoBlending as eMe,REVISION as tMe,ShaderMaterial as rMe,Uniform as iMe,Vector2 as nMe}from"three";import{BasicDepthPacking as aMe,NoBlending as sMe,PerspectiveCamera as lMe,REVISION as cMe,ShaderMaterial as dMe,Uniform as uMe,Vector2 as pMe}from"three";import{NoBlending as fMe,ShaderMaterial as mMe,Uniform as yMe}from"three";import{NoBlending as E5,REVISION as C5,ShaderMaterial as T5,Uniform as Gg}from"three";import{NoBlending as O5,ShaderMaterial as I5,Uniform as G1,UnsignedByteType as D5}from"three";import{NoBlending as xMe,ShaderMaterial as SMe,Uniform as wMe,Vector2 as AMe}from"three";import{NoBlending as CMe,ShaderMaterial as TMe,Uniform as PMe,Vector2 as MMe}from"three";import{BasicDepthPacking as IMe,Matrix4 as DMe,NoBlending as RMe,PerspectiveCamera as BMe,ShaderMaterial as NMe,Uniform as LMe,Vector2 as _Me}from"three";import{LinearFilter as kMe,SRGBColorSpace as VMe,UnsignedByteType as GMe,WebGLRenderTarget as UMe}from"three";import{BasicDepthPacking as N5,BufferAttribute as Ug,BufferGeometry as L5,Camera as _5,Mesh as F5,Scene as U1}from"three";import{Color as G5}from"three";import{Color as qMe,MeshDepthMaterial as XMe,NearestFilter as YMe,RGBADepthPacking as QMe,WebGLRenderTarget as KMe}from"three";import{EventDispatcher as U5,Vector2 as vR}from"three";import{BackSide as $Me,DoubleSide as e2e,FrontSide as t2e}from"three";import{BasicDepthPacking as i2e,FloatType as n2e,NearestFilter as o2e,WebGLRenderTarget as a2e}from"three";import{FloatType as l2e,RGBADepthPacking as c2e}from"three";import{BasicDepthPacking as u2e,FloatType as p2e,NearestFilter as h2e,RGBADepthPacking as f2e,UnsignedByteType as m2e,WebGLRenderTarget as y2e}from"three";import{BasicDepthPacking as b2e,UnsignedByteType as x2e}from"three";import{EventDispatcher as z5,Uniform as j5}from"three";import{BasicDepthPacking as dW,EventDispatcher as uW,Scene as pW}from"three";import{LinearFilter as bR,SRGBColorSpace as z1,UnsignedByteType as hW,WebGLRenderTarget as fW}from"three";import{LinearFilter as xR,UnsignedByteType as yW,WebGLRenderTarget as gW}from"three";import{Color as T2e,MeshNormalMaterial as P2e,NearestFilter as M2e,WebGLRenderTarget as O2e}from"three";import{UnsignedByteType as bW}from"three";import{LinearFilter as SR,SRGBColorSpace as wR,Uniform as AR,WebGLRenderTarget as xW}from"three";import{Uniform as N2e}from"three";import{Uniform as ER}from"three";import{Uniform as F2e}from"three";import{Uniform as EW,Vector2 as CW}from"three";import{BasicDepthPacking as MW,LinearFilter as CR,SRGBColorSpace as Np,Uniform as zg,UnsignedByteType as OW,WebGLRenderTarget as IW,Vector3 as DW}from"three";import{Uniform as U2e,Vector2 as z2e}from"three";import{Uniform as H2e}from"three";import{NearestFilter as q2e,RepeatWrapping as X2e,RGBAFormat as Y2e,Uniform as Q2e,Vector2 as K2e}from"three";import{DataTexture as J2e,RedFormat as $2e,RGFormat as eOe,RGBAFormat as tOe,UnsignedByteType as rOe}from"three";import{BasicDepthPacking as nOe,Color as oOe,DepthTexture as aOe,LinearFilter as sOe,Matrix4 as BW,Scene as lOe,SRGBColorSpace as cOe,Uniform as dOe,Vector2 as uOe,Vector3 as NW,WebGLRenderTarget as pOe}from"three";import{Uniform as yOe,Vector2 as gOe}from"three";import{Uniform as TR,Vector3 as LW}from"three";import{Data3DTexture as xOe,FloatType as SOe,HalfFloatType as wOe,LinearSRGBColorSpace as AOe,LinearFilter as EOe,NearestFilter as COe,SRGBColorSpace as TOe,Uniform as POe,Vector3 as MOe}from"three";import{Color as FW,ClampToEdgeWrapping as IOe,DataTexture as DOe,Data3DTexture as ROe,FloatType as BOe,LinearFilter as NOe,LinearSRGBColorSpace as LOe,RGBAFormat as _Oe,SRGBColorSpace as FOe,UnsignedByteType as kOe,Vector3 as VOe}from"three";import{Color as zOe,LinearFilter as jOe,RepeatWrapping as HOe,Uniform as WOe,UnsignedByteType as qOe,WebGLRenderTarget as XOe}from"three";import{Uniform as PR,Vector2 as MR}from"three";import{Uniform as KOe,Vector4 as ZOe}from"three";import{Uniform as $Oe,Vector2 as eIe}from"three";import{Uniform as rIe,Vector2 as iIe,Vector3 as UR}from"three";import{BasicDepthPacking as lIe,Color as cIe,LinearFilter as dIe,NotEqualDepth as uIe,EqualDepth as pIe,RGBADepthPacking as hIe,SRGBColorSpace as fIe,WebGLRenderTarget as mIe}from"three";import{Uniform as gIe}from"three";import{BasicDepthPacking as bIe,Color as xIe,LinearFilter as SIe,LoadingManager as wIe,NearestFilter as AIe,Texture as EIe,Uniform as CIe,WebGLRenderTarget as TIe}from"three";import{BasicDepthPacking as MIe,Color as OIe,LinearFilter as IIe,RepeatWrapping as DIe,RGBAFormat as RIe,Uniform as BIe,WebGLRenderTarget as NIe}from"three";import{Uniform as _Ie,UnsignedByteType as FIe}from"three";import{LinearFilter as VIe,LinearMipmapLinearFilter as GIe,Uniform as UIe,WebGLRenderTarget as zIe}from"three";import{Uniform as OR}from"three";import{LoadingManager as $Ie}from"three";import{FileLoader as rDe,Loader as iDe,LoadingManager as nDe}from"three";import{FileLoader as aDe,Loader as sDe,LoadingManager as lDe,Vector3 as cDe}from"three";import{Loader as uDe,LoadingManager as pDe}from"three";var IR={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Hg="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var h5=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
1410
1410
|
uniform mediump sampler2D inputBuffer;
|
|
1411
1411
|
#else
|
|
1412
1412
|
uniform lowp sampler2D inputBuffer;
|
|
@@ -5236,4 +5236,4 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
5236
5236
|
|
|
5237
5237
|
`;var yv=class extends G8{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 ad;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(nB),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(oB),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(fN),e.addFragmentParsCode(yN),e.addVertexFinalCode(mN({easeSize:this.easeSize})),e.addFragmentFinalCode(gN({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 U8}from"three/examples/jsm/misc/GPUComputationRenderer.js";GC({createMaterial:(n,t)=>new yv(n,t),createComputation:(n,t,e)=>new U8(n,t,e)});import{Vector2 as vN}from"three";function bN(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 Zo(o,i.texture.wrapping??(i.type==="texture"?1e3:1001),i.texture.minFilter??1008,i.texture.magFilter??1006),s=new Yg(o),l=new Qg(Js(i.texture.repeat??[1,1],r),Js(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 vN(...Js(i.size,r)):new vN(100,100)),m=new le(i.blending??0),y=new le(Hi(i.alpha,r)),g=new Ge(i.mode??0),b=new Et(i.isMask??!1),x=new $o(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",bN);ot("video",bN);import{MathUtils as z8}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 Zo(o,i.texture.wrapping??1001,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new le(Hi(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)*z8.DEG2RAD),u=new md(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 j8}from"three";ot("displace",(n,t,e,r)=>{let i=e;if(i.displacementType==="noise"){let o=new Qt(new j8(...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 Ad(s,l,o,d,u,p,h,f,m,a,c);return new Ed(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 pd(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 hd(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 xN,Vector4 as SN}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 Oi(i.colors.length,i.colors):(s=new Oi(10,new SN(0,0,0,1)),s.value[1]=new SN(1,1,1,1));let l;i.steps?l=new Mi(i.steps.length,i.steps):(l=new Mi(10,1),l.value[0]=0);let c=new _t(en(i.offset??new xN(0,0),r)),d=new _t(en(i.morph??new xN(0,0),r)),u=new le(ye(i.angle??0,r)),p=vt(i),h=new fd(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 wN}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(Ii(i.origin,r)),p=new Qt(Ii(i.direction,r)),h;i.colors?h=new Oi(i.colors.length,i.colors):(h=new Oi(2,new wN(0,0,0,1)),h.value[1]=new wN(1,1,1,1));let f;i.steps?f=new Mi(i.steps.length,i.steps):(f=new Mi(2,1),f.value[0]=0);let m=vt(i),y=new ud(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 H8}from"three";ot("normal",(n,t,e,r)=>{let i=gt(e,r),o=new Qt(i.cnormal??new H8(1,1,1)),a=vt(i),s=new cd(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 Ew,Vector3 as W8}from"three";ot("noise",(n,t,e,r)=>{let i=gt(e,r),o=new le(ye(i.scale,r)??1),a=new Qt(Ii(i.size??new W8(100,100,100),r)),s=new le(ye(i.move,r)??1),l=new _t(en(i.fA??new Ew(1.7,9.2),r)),c=new _t(en(i.fB??new Ew(8.3,2.8),r)),d=new _t(en(i.distortion??new Ew(1,1),r)),u=new Qr(i.colorA),p=new Qr(i.colorB),h=new Qr(i.colorC),f=new Qr(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 yd(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(Ii(o.wavelengths,r)),c=new le(ye(o.noiseStrength,r)??0),d=new le(ye(o.noiseScale,r)??1),u=new Qt(Ii(o.offset,r)),p=vt(o),h=i?.forceRainbowNoise===!0,f=h||dn(o.noiseStrength),m=new bd(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 AN,Vector4 as EN}from"three";ot("toon",(n,t,e,r)=>{let i=gt(e,r),o=new Ge(i.positioning??0),a;i.colors?a=new Oi(i.colors.length,i.colors):(a=new Oi(10,new EN(0,0,0,1)),a.value[1]=new EN(1,1,1,1));let s;i.steps?s=new Mi(i.steps.length,i.steps):(s=new Mi(10,1),s.value[0]=0);let l=new Qt(Ii(i.source??new AN(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 Qr(i.shadowColor),h=new Qt(Ii(i.offset??new AN(0,0,0),r)),f=vt(i),m=new xd(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 q8}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(Ii(i.contourDirection??new q8(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 gd(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 Sd(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 CN=!1;function X8(){CN||(CN=!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)=>{X8();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 Jo(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 Cw}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(en(i.offset,r)),d=new Qr(i.colorA),u=new Qr(i.colorB),p=new _t(en(i.frequency??new Cw(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(en(i.vertical??new Cw(0,1),r)),x=new _t(en(i.horizontal??new Cw(0,1),r)),S=new Ge(i.sides??6),v=vt(i),w=new vd(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 wd(o.alpha),s=new Le(a.calpha,"f");return new We(n,t,e,{...o},a,o.mode,s,o.isMask,r)});AP({createRootMaterial:(n,t)=>new Cd(n,t),createSharedMaterial:(n,t,e)=>new mv(n,t,e)});MP((n,t)=>n?MB(t):OB());TP(()=>{let n=new Y8;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 TN="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Tw=class extends K8{load(t,e,r,i=console.error){let o=new Q8(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(TN+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(TN),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 XR(t,cN),r=YR(e);e.version&&"2.0.
|
|
5239
|
+
gVelocity = vec4(0.0);`)},n});var TN="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Tw=class extends K8{load(t,e,r,i=console.error){let o=new Q8(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(TN+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(TN),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 XR(t,cN),r=YR(e);e.version&&"2.0.31"&&(0,PN.default)(e.version,"2.0.31")>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&&qR(),cM(e)&&mP(),yx(e)&&D2(),y2(e)&&Bm(),uv(e)&&Sw()].filter(Boolean)),r.length&&await QR(r);let i=!1,o=new Sa(e.shared,{},i);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new fv(e.scene,o);uv(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=sN(a),a=nN(a),a=oN(a),a=aN(a),a=lN(a),a}};export{Tw as default};
|