@hatiolab/things-scene 10.1.103 → 10.1.105

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.
@@ -3,5 +3,5 @@ function t(...t){return e=>{const n=Object.getPrototypeOf(e),i=Array.isArray(n?.
3
3
  * @license
4
4
  * Copyright 2010-2026 Three.js Authors
5
5
  * SPDX-License-Identifier: MIT
6
- */const y=1e3,g=1001,b="srgb",v="srgb-linear",x="linear",w="srgb",_=7680,M=2e3;function S(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const k={};function A(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function z(...t){const e="THREE."+(t=A(t)).shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function T(...t){const e="THREE."+(t=A(t)).shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function I(...t){const e=t.join(" ");e in k||(k[e]=!0,z(...t))}class O{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return void 0!==n&&(void 0!==n[t]&&-1!==n[t].indexOf(e))}removeEventListener(t,e){const n=this._listeners;if(void 0===n)return;const i=n[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const n=e[t.type];if(void 0!==n){t.target=this;const e=n.slice(0);for(let n=0,i=e.length;n<i;n++)e[n].call(this,t);t.target=null}}}const E=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function j(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(E[255&t]+E[t>>8&255]+E[t>>16&255]+E[t>>24&255]+"-"+E[255&e]+E[e>>8&255]+"-"+E[e>>16&15|64]+E[e>>24&255]+"-"+E[63&n|128]+E[n>>8&255]+"-"+E[n>>16&255]+E[n>>24&255]+E[255&i]+E[i>>8&255]+E[i>>16&255]+E[i>>24&255]).toLowerCase()}function P(t,e,n){return Math.max(e,Math.min(n,t))}function C(t,e,n){return(1-n)*t+n*e}function R(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function F(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("THREE.MathUtils: Invalid component type.")}}class D{static{D.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=P(this.x,t.x,e.x),this.y=P(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=P(this.x,t,e),this.y=P(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(P(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(P(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class N{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,o){let a=n[i+0],c=n[i+1],h=n[i+2],l=n[i+3],u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(l!==f||a!==u||c!==d||h!==p){let t=a*u+c*d+h*p+l*f;t<0&&(u=-u,d=-d,p=-p,f=-f,t=-t);let e=1-o;if(t<.9995){const n=Math.acos(t),i=Math.sin(n);e=Math.sin(e*n)/i,a=a*e+u*(o=Math.sin(o*n)/i),c=c*e+d*o,h=h*e+p*o,l=l*e+f*o}else{a=a*e+u*o,c=c*e+d*o,h=h*e+p*o,l=l*e+f*o;const t=1/Math.sqrt(a*a+c*c+h*h+l*l);a*=t,c*=t,h*=t,l*=t}}t[e]=a,t[e+1]=c,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,n,i,r,s){const o=n[i],a=n[i+1],c=n[i+2],h=n[i+3],l=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=o*p+h*l+a*d-c*u,t[e+1]=a*p+h*u+c*l-o*d,t[e+2]=c*p+h*d+o*u-a*l,t[e+3]=h*p-o*l-a*u-c*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,o=Math.cos,a=Math.sin,c=o(n/2),h=o(i/2),l=o(r/2),u=a(n/2),d=a(i/2),p=a(r/2);switch(s){case"XYZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"YXZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"ZXY":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"ZYX":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"YZX":this._x=u*h*l+c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l-u*d*p;break;case"XZY":this._x=u*h*l-c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l+u*d*p;break;default:z("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],o=e[5],a=e[9],c=e[2],h=e[6],l=e[10],u=n+o+l;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-a)*t,this._y=(r-c)*t,this._z=(s-i)*t}else if(n>o&&n>l){const t=2*Math.sqrt(1+n-o-l);this._w=(h-a)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+c)/t}else if(o>l){const t=2*Math.sqrt(1+o-n-l);this._w=(r-c)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(a+h)/t}else{const t=2*Math.sqrt(1+l-n-o);this._w=(s-i)/t,this._x=(r+c)/t,this._y=(a+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(P(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,o=e._x,a=e._y,c=e._z,h=e._w;return this._x=n*h+s*o+i*c-r*a,this._y=i*h+s*a+r*o-n*c,this._z=r*h+s*c+n*a-i*o,this._w=s*h-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,s=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,r=-r,s=-s,o=-o);let a=1-e;if(o<.9995){const t=Math.acos(o),c=Math.sin(t);a=Math.sin(a*t)/c,e=Math.sin(e*t)/c,this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+r*e,this._w=this._w*a+s*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+r*e,this._w=this._w*a+s*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{static{L.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(U.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(U.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z,a=t.w,c=2*(s*i-o*n),h=2*(o*e-r*i),l=2*(r*n-s*e);return this.x=e+a*c+s*l-o*h,this.y=n+a*h+o*c-r*l,this.z=i+a*l+r*h-s*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=P(this.x,t.x,e.x),this.y=P(this.y,t.y,e.y),this.z=P(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=P(this.x,t,e),this.y=P(this.y,t,e),this.z=P(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(P(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return B.copy(this).projectOnVector(t),this.sub(B)}reflect(t){return this.sub(B.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(P(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const B=new L,U=new N;class W{static{W.prototype.isMatrix3=!0}constructor(t,e,n,i,r,s,o,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,o,a,c)}set(t,e,n,i,r,s,o,a,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=a,h[6]=n,h[7]=s,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],h=n[4],l=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],y=i[6],g=i[1],b=i[4],v=i[7],x=i[2],w=i[5],_=i[8];return r[0]=s*f+o*g+a*x,r[3]=s*m+o*b+a*w,r[6]=s*y+o*v+a*_,r[1]=c*f+h*g+l*x,r[4]=c*m+h*b+l*w,r[7]=c*y+h*v+l*_,r[2]=u*f+d*g+p*x,r[5]=u*m+d*b+p*w,r[8]=u*y+d*v+p*_,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return e*s*h-e*o*c-n*r*h+n*o*a+i*r*c-i*s*a}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=h*s-o*c,u=o*a-h*r,d=c*r-s*a,p=e*l+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=l*f,t[1]=(i*c-h*n)*f,t[2]=(o*n-i*s)*f,t[3]=u*f,t[4]=(h*e-i*a)*f,t[5]=(i*r-o*e)*f,t[6]=d*f,t[7]=(n*a-c*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,o){const a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+t,-i*c,i*a,-i*(-c*s+a*o)+o+e,0,0,1),this}scale(t,e){return I("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(q.makeScale(t,e)),this}rotate(t){return I("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(q.makeRotation(-t)),this}translate(t,e){return I("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(q.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const q=new W,$=(new W).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),V=(new W).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Y(){const t={enabled:!0,workingColorSpace:v,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===w&&(t.r=G(t.r),t.g=G(t.g),t.b=G(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===w&&(t.r=X(t.r),t.g=X(t.g),t.b=X(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?x:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,n){return I("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,n)},toWorkingColorSpace:function(e,n){return I("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,n)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[v]:{primaries:e,whitePoint:i,transfer:x,toXYZ:$,fromXYZ:V,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:b},outputColorSpaceConfig:{drawingBufferColorSpace:b}},[b]:{primaries:e,whitePoint:i,transfer:w,toXYZ:$,fromXYZ:V,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:b}}}),t}const H=Y();function G(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function X(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Z;class J{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{void 0===Z&&(Z=S("canvas")),Z.width=t.width,Z.height=t.height;const e=Z.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),n=Z}return n.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=S("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*G(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*G(e[t]/255)):e[t]=G(e[t]);return{data:e,width:t.width,height:t.height}}return z("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Q=0;class K{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Q++}),this.uuid=j(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(tt(i[e].image)):t.push(tt(i[e]))}else t=tt(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function tt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?J.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(z("Texture: Unable to serialize Texture."),{})}let et=0;const nt=new L;class it extends O{constructor(t=it.DEFAULT_IMAGE,e=it.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=it.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:et++}),this.uuid=j(),this.name="",this.source=new K(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new D(0,0),this.repeat=new D(1,1),this.center=new D(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new W,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(nt).x}get height(){return this.source.getSize(nt).y}get depth(){return this.source.getSize(nt).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(void 0===n){z(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n:z(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case y:t.x=t.x-Math.floor(t.x);break;case g:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case y:t.y=t.y-Math.floor(t.y);break;case g:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}it.DEFAULT_IMAGE=null,it.DEFAULT_MAPPING=300,it.DEFAULT_ANISOTROPY=1;class rt{static{rt.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,o=.1,a=t.elements,c=a[0],h=a[4],l=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],y=a[10];if(Math.abs(h-u)<s&&Math.abs(l-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+u)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(c+d+y-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(d+1)/2,g=(y+1)/2,b=(h+u)/4,v=(l+f)/4,x=(p+m)/4;return t>a&&t>g?t<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=b/n,r=v/n):a>g?a<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),n=b/i,r=x/i):g<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(g),n=v/r,i=x/r),this.set(n,i,r,e),this}let g=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-h)*(u-h));return Math.abs(g)<.001&&(g=1),this.x=(m-p)/g,this.y=(l-f)/g,this.z=(u-h)/g,this.w=Math.acos((c+d+y-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=P(this.x,t.x,e.x),this.y=P(this.y,t.y,e.y),this.z=P(this.z,t.z,e.z),this.w=P(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=P(this.x,t,e),this.y=P(this.y,t,e),this.z=P(this.z,t,e),this.w=P(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(P(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class st{static{st.prototype.isMatrix4=!0}constructor(t,e,n,i,r,s,o,a,c,h,l,u,d,p,f,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,o,a,c,h,l,u,d,p,f,m)}set(t,e,n,i,r,s,o,a,c,h,l,u,d,p,f,m){const y=this.elements;return y[0]=t,y[4]=e,y[8]=n,y[12]=i,y[1]=r,y[5]=s,y[9]=o,y[13]=a,y[2]=c,y[6]=h,y[10]=l,y[14]=u,y[3]=d,y[7]=p,y[11]=f,y[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new st).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,n=t.elements,i=1/ot.setFromMatrixColumn(t,0).length(),r=1/ot.setFromMatrixColumn(t,1).length(),s=1/ot.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),h=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){const t=s*h,n=s*l,i=o*h,r=o*l;e[0]=a*h,e[4]=-a*l,e[8]=c,e[1]=n+i*c,e[5]=t-r*c,e[9]=-o*a,e[2]=r-t*c,e[6]=i+n*c,e[10]=s*a}else if("YXZ"===t.order){const t=a*h,n=a*l,i=c*h,r=c*l;e[0]=t+r*o,e[4]=i*o-n,e[8]=s*c,e[1]=s*l,e[5]=s*h,e[9]=-o,e[2]=n*o-i,e[6]=r+t*o,e[10]=s*a}else if("ZXY"===t.order){const t=a*h,n=a*l,i=c*h,r=c*l;e[0]=t-r*o,e[4]=-s*l,e[8]=i+n*o,e[1]=n+i*o,e[5]=s*h,e[9]=r-t*o,e[2]=-s*c,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){const t=s*h,n=s*l,i=o*h,r=o*l;e[0]=a*h,e[4]=i*c-n,e[8]=t*c+r,e[1]=a*l,e[5]=r*c+t,e[9]=n*c-i,e[2]=-c,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){const t=s*a,n=s*c,i=o*a,r=o*c;e[0]=a*h,e[4]=r-t*l,e[8]=i*l+n,e[1]=l,e[5]=s*h,e[9]=-o*h,e[2]=-c*h,e[6]=n*l+i,e[10]=t-r*l}else if("XZY"===t.order){const t=s*a,n=s*c,i=o*a,r=o*c;e[0]=a*h,e[4]=-l,e[8]=c*h,e[1]=t*l+r,e[5]=s*h,e[9]=n*l-i,e[2]=i*l-n,e[6]=o*h,e[10]=r*l+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ct,t,ht)}lookAt(t,e,n){const i=this.elements;return dt.subVectors(t,e),0===dt.lengthSq()&&(dt.z=1),dt.normalize(),lt.crossVectors(n,dt),0===lt.lengthSq()&&(1===Math.abs(n.z)?dt.x+=1e-4:dt.z+=1e-4,dt.normalize(),lt.crossVectors(n,dt)),lt.normalize(),ut.crossVectors(dt,lt),i[0]=lt.x,i[4]=ut.x,i[8]=dt.x,i[1]=lt.y,i[5]=ut.y,i[9]=dt.y,i[2]=lt.z,i[6]=ut.z,i[10]=dt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],h=n[1],l=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],y=n[14],g=n[3],b=n[7],v=n[11],x=n[15],w=i[0],_=i[4],M=i[8],S=i[12],k=i[1],A=i[5],z=i[9],T=i[13],I=i[2],O=i[6],E=i[10],j=i[14],P=i[3],C=i[7],R=i[11],F=i[15];return r[0]=s*w+o*k+a*I+c*P,r[4]=s*_+o*A+a*O+c*C,r[8]=s*M+o*z+a*E+c*R,r[12]=s*S+o*T+a*j+c*F,r[1]=h*w+l*k+u*I+d*P,r[5]=h*_+l*A+u*O+d*C,r[9]=h*M+l*z+u*E+d*R,r[13]=h*S+l*T+u*j+d*F,r[2]=p*w+f*k+m*I+y*P,r[6]=p*_+f*A+m*O+y*C,r[10]=p*M+f*z+m*E+y*R,r[14]=p*S+f*T+m*j+y*F,r[3]=g*w+b*k+v*I+x*P,r[7]=g*_+b*A+v*O+x*C,r[11]=g*M+b*z+v*E+x*R,r[15]=g*S+b*T+v*j+x*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],o=t[5],a=t[9],c=t[13],h=t[2],l=t[6],u=t[10],d=t[14],p=t[3],f=t[7],m=t[11],y=t[15],g=a*d-c*u,b=o*d-c*l,v=o*u-a*l,x=s*d-c*h,w=s*u-a*h,_=s*l-o*h;return e*(f*g-m*b+y*v)-n*(p*g-m*x+y*w)+i*(p*b-f*x+y*_)-r*(p*v-f*w+m*_)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[1],s=t[5],o=t[9],a=t[2],c=t[6],h=t[10];return e*(s*h-o*c)-n*(r*h-o*a)+i*(r*c-s*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],y=t[15],g=e*o-n*s,b=e*a-i*s,v=e*c-r*s,x=n*a-i*o,w=n*c-r*o,_=i*c-r*a,M=h*f-l*p,S=h*m-u*p,k=h*y-d*p,A=l*m-u*f,z=l*y-d*f,T=u*y-d*m,I=g*T-b*z+v*A+x*k-w*S+_*M;if(0===I)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/I;return t[0]=(o*T-a*z+c*A)*O,t[1]=(i*z-n*T-r*A)*O,t[2]=(f*_-m*w+y*x)*O,t[3]=(u*w-l*_-d*x)*O,t[4]=(a*k-s*T-c*S)*O,t[5]=(e*T-i*k+r*S)*O,t[6]=(m*v-p*_-y*b)*O,t[7]=(h*_-u*v+d*b)*O,t[8]=(s*z-o*k+c*M)*O,t[9]=(n*k-e*z-r*M)*O,t[10]=(p*w-f*v+y*g)*O,t[11]=(l*v-h*w-d*g)*O,t[12]=(o*S-s*A-a*M)*O,t[13]=(e*A-n*S+i*M)*O,t[14]=(f*b-p*x-m*g)*O,t[15]=(h*x-l*b+u*g)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,o=t.y,a=t.z,c=r*s,h=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,h*o+n,h*a-i*s,0,c*a-i*o,h*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,c=r+r,h=s+s,l=o+o,u=r*c,d=r*h,p=r*l,f=s*h,m=s*l,y=o*l,g=a*c,b=a*h,v=a*l,x=n.x,w=n.y,_=n.z;return i[0]=(1-(f+y))*x,i[1]=(d+v)*x,i[2]=(p-b)*x,i[3]=0,i[4]=(d-v)*w,i[5]=(1-(u+y))*w,i[6]=(m+g)*w,i[7]=0,i[8]=(p+b)*_,i[9]=(m-g)*_,i[10]=(1-(u+f))*_,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(0===r)return n.set(1,1,1),e.identity(),this;let s=ot.set(i[0],i[1],i[2]).length();const o=ot.set(i[4],i[5],i[6]).length(),a=ot.set(i[8],i[9],i[10]).length();r<0&&(s=-s),at.copy(this);const c=1/s,h=1/o,l=1/a;return at.elements[0]*=c,at.elements[1]*=c,at.elements[2]*=c,at.elements[4]*=h,at.elements[5]*=h,at.elements[6]*=h,at.elements[8]*=l,at.elements[9]*=l,at.elements[10]*=l,e.setFromRotationMatrix(at),n.x=s,n.y=o,n.z=a,this}makePerspective(t,e,n,i,r,s,o=2e3,a=!1){const c=this.elements,h=2*r/(e-t),l=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let p,f;if(a)p=r/(s-r),f=s*r/(s-r);else if(o===M)p=-(s+r)/(s-r),f=-2*s*r/(s-r);else{if(2001!==o)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);p=-s/(s-r),f=-s*r/(s-r)}return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=l,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,r,s,o=2e3,a=!1){const c=this.elements,h=2/(e-t),l=2/(n-i),u=-(e+t)/(e-t),d=-(n+i)/(n-i);let p,f;if(a)p=1/(s-r),f=s/(s-r);else if(o===M)p=-2/(s-r),f=-(s+r)/(s-r);else{if(2001!==o)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);p=-1/(s-r),f=-r/(s-r)}return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=l,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const ot=new L,at=new st,ct=new L(0,0,0),ht=new L(1,1,1),lt=new L,ut=new L,dt=new L,pt=new st,ft=new N;class mt{constructor(t=0,e=0,n=0,i=mt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],h=i[9],l=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(P(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-P(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-l,r),this._z=0);break;case"ZXY":this._x=Math.asin(P(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-P(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(P(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-l,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-P(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:z("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return pt.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pt,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ft.setFromEuler(this),this.setFromQuaternion(ft,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}mt.DEFAULT_ORDER="XYZ";class yt{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let gt=0;const bt=new L,vt=new N,xt=new st,wt=new L,_t=new L,Mt=new L,St=new N,kt=new L(1,0,0),At=new L(0,1,0),zt=new L(0,0,1),Tt={type:"added"},It={type:"removed"},Ot={type:"childadded",child:null},Et={type:"childremoved",child:null};class jt extends O{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gt++}),this.uuid=j(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=jt.DEFAULT_UP.clone();const t=new L,e=new mt,n=new N,i=new L(1,1,1);e._onChange(function(){n.setFromEuler(e,!1)}),n._onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new st},normalMatrix:{value:new W}}),this.matrix=new st,this.matrixWorld=new st,this.matrixAutoUpdate=jt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return vt.setFromAxisAngle(t,e),this.quaternion.multiply(vt),this}rotateOnWorldAxis(t,e){return vt.setFromAxisAngle(t,e),this.quaternion.premultiply(vt),this}rotateX(t){return this.rotateOnAxis(kt,t)}rotateY(t){return this.rotateOnAxis(At,t)}rotateZ(t){return this.rotateOnAxis(zt,t)}translateOnAxis(t,e){return bt.copy(t).applyQuaternion(this.quaternion),this.position.add(bt.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(kt,t)}translateY(t){return this.translateOnAxis(At,t)}translateZ(t){return this.translateOnAxis(zt,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(xt.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?wt.copy(t):wt.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),_t.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xt.lookAt(_t,wt,this.up):xt.lookAt(wt,_t,this.up),this.quaternion.setFromRotationMatrix(xt),i&&(xt.extractRotation(i.matrixWorld),vt.setFromRotationMatrix(xt),this.quaternion.premultiply(vt.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(T("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Tt),Ot.child=t,this.dispatchEvent(Ot),Ot.child=null):T("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(It),Et.child=t,this.dispatchEvent(Et),Et.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),xt.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),xt.multiply(t.parent.matrixWorld)),t.applyMatrix4(xt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Tt),Ot.child=t,this.dispatchEvent(Ot),Ot.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_t,t,Mt),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_t,St,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(null!==t){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e,n=!1){const i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){t[e].updateWorldMatrix(!1,!0,n)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),!1!==this.static&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(t=>({...t})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),o=s(t.images),a=s(t.shapes),c=s(t.skeletons),h=s(t.animations),l=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),a.length>0&&(n.shapes=a),c.length>0&&(n.skeletons=c),h.length>0&&(n.animations=h),l.length>0&&(n.nodes=l)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=null!==t.pivot?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}jt.DEFAULT_UP=new L(0,1,0),jt.DEFAULT_MATRIX_AUTO_UPDATE=!0,jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Pt extends jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ct={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Rt={h:0,s:0,l:0},Ft={h:0,s:0,l:0};function Dt(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Nt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=b){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,H.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=H.workingColorSpace){return this.r=t,this.g=e,this.b=n,H.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=H.workingColorSpace){var r;if(t=(t%(r=1)+r)%r,e=P(e,0,1),n=P(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Dt(r,i,t+1/3),this.g=Dt(r,i,t),this.b=Dt(r,i,t-1/3)}return H.colorSpaceToWorking(this,i),this}setStyle(t,e=b){function n(e){void 0!==e&&parseFloat(e)<1&&z("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:z("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);z("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=b){const n=Ct[t.toLowerCase()];return void 0!==n?this.setHex(n,e):z("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=G(t.r),this.g=G(t.g),this.b=G(t.b),this}copyLinearToSRGB(t){return this.r=X(t.r),this.g=X(t.g),this.b=X(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=b){return H.workingToColorSpace(Lt.copy(this),t),65536*Math.round(P(255*Lt.r,0,255))+256*Math.round(P(255*Lt.g,0,255))+Math.round(P(255*Lt.b,0,255))}getHexString(t=b){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=H.workingColorSpace){H.workingToColorSpace(Lt.copy(this),e);const n=Lt.r,i=Lt.g,r=Lt.b,s=Math.max(n,i,r),o=Math.min(n,i,r);let a,c;const h=(o+s)/2;if(o===s)a=0,c=0;else{const t=s-o;switch(c=h<=.5?t/(s+o):t/(2-s-o),s){case n:a=(i-r)/t+(i<r?6:0);break;case i:a=(r-n)/t+2;break;case r:a=(n-i)/t+4}a/=6}return t.h=a,t.s=c,t.l=h,t}getRGB(t,e=H.workingColorSpace){return H.workingToColorSpace(Lt.copy(this),e),t.r=Lt.r,t.g=Lt.g,t.b=Lt.b,t}getStyle(t=b){H.workingToColorSpace(Lt.copy(this),t);const e=Lt.r,n=Lt.g,i=Lt.b;return t!==b?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(Rt),this.setHSL(Rt.h+t,Rt.s+e,Rt.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Rt),t.getHSL(Ft);const n=C(Rt.h,Ft.h,e),i=C(Rt.s,Ft.s,e),r=C(Rt.l,Ft.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Lt=new Nt;Nt.NAMES=Ct;const Bt=new L,Ut=new L,Wt=new L,qt=new L,$t=new L,Vt=new L,Yt=new L,Ht=new L,Gt=new L,Xt=new L,Zt=new rt,Jt=new rt,Qt=new rt;class Kt{constructor(t=new L,e=new L,n=new L){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Bt.subVectors(t,e),i.cross(Bt);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Bt.subVectors(i,e),Ut.subVectors(n,e),Wt.subVectors(t,e);const s=Bt.dot(Bt),o=Bt.dot(Ut),a=Bt.dot(Wt),c=Ut.dot(Ut),h=Ut.dot(Wt),l=s*c-o*o;if(0===l)return r.set(0,0,0),null;const u=1/l,d=(c*a-o*h)*u,p=(s*h-o*a)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,qt)&&(qt.x>=0&&qt.y>=0&&qt.x+qt.y<=1)}static getInterpolation(t,e,n,i,r,s,o,a){return null===this.getBarycoord(t,e,n,i,qt)?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(r,qt.x),a.addScaledVector(s,qt.y),a.addScaledVector(o,qt.z),a)}static getInterpolatedAttribute(t,e,n,i,r,s){return Zt.setScalar(0),Jt.setScalar(0),Qt.setScalar(0),Zt.fromBufferAttribute(t,e),Jt.fromBufferAttribute(t,n),Qt.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(Zt,r.x),s.addScaledVector(Jt,r.y),s.addScaledVector(Qt,r.z),s}static isFrontFacing(t,e,n,i){return Bt.subVectors(n,e),Ut.subVectors(t,e),Bt.cross(Ut).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Bt.subVectors(this.c,this.b),Ut.subVectors(this.a,this.b),.5*Bt.cross(Ut).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Kt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Kt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Kt.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Kt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Kt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,o;$t.subVectors(i,n),Vt.subVectors(r,n),Ht.subVectors(t,n);const a=$t.dot(Ht),c=Vt.dot(Ht);if(a<=0&&c<=0)return e.copy(n);Gt.subVectors(t,i);const h=$t.dot(Gt),l=Vt.dot(Gt);if(h>=0&&l<=h)return e.copy(i);const u=a*l-h*c;if(u<=0&&a>=0&&h<=0)return s=a/(a-h),e.copy(n).addScaledVector($t,s);Xt.subVectors(t,r);const d=$t.dot(Xt),p=Vt.dot(Xt);if(p>=0&&d<=p)return e.copy(r);const f=d*c-a*p;if(f<=0&&c>=0&&p<=0)return o=c/(c-p),e.copy(n).addScaledVector(Vt,o);const m=h*p-d*l;if(m<=0&&l-h>=0&&d-p>=0)return Yt.subVectors(r,i),o=(l-h)/(l-h+(d-p)),e.copy(i).addScaledVector(Yt,o);const y=1/(m+f+u);return s=f*y,o=u*y,e.copy(n).addScaledVector($t,s).addScaledVector(Vt,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class te{constructor(t=new L(1/0,1/0,1/0),e=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(ne.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(ne.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ne.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,ne):ne.fromBufferAttribute(i,e),ne.applyMatrix4(t.matrixWorld),this.expandByPoint(ne);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),ie.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),ie.copy(n.boundingBox)),ie.applyMatrix4(t.matrixWorld),this.union(ie)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ne),ne.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(le),ue.subVectors(this.max,le),re.subVectors(t.a,le),se.subVectors(t.b,le),oe.subVectors(t.c,le),ae.subVectors(se,re),ce.subVectors(oe,se),he.subVectors(re,oe);let e=[0,-ae.z,ae.y,0,-ce.z,ce.y,0,-he.z,he.y,ae.z,0,-ae.x,ce.z,0,-ce.x,he.z,0,-he.x,-ae.y,ae.x,0,-ce.y,ce.x,0,-he.y,he.x,0];return!!fe(e,re,se,oe,ue)&&(e=[1,0,0,0,1,0,0,0,1],!!fe(e,re,se,oe,ue)&&(de.crossVectors(ae,ce),e=[de.x,de.y,de.z],fe(e,re,se,oe,ue)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ne).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ne).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(ee[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ee[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ee[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ee[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ee[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ee[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ee[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ee[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ee)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const ee=[new L,new L,new L,new L,new L,new L,new L,new L],ne=new L,ie=new te,re=new L,se=new L,oe=new L,ae=new L,ce=new L,he=new L,le=new L,ue=new L,de=new L,pe=new L;function fe(t,e,n,i,r){for(let s=0,o=t.length-3;s<=o;s+=3){pe.fromArray(t,s);const o=r.x*Math.abs(pe.x)+r.y*Math.abs(pe.y)+r.z*Math.abs(pe.z),a=e.dot(pe),c=n.dot(pe),h=i.dot(pe);if(Math.max(-Math.max(a,c,h),Math.min(a,c,h))>o)return!1}return!0}const me=new L,ye=new D;let ge=0;class be extends O{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ge++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)ye.fromBufferAttribute(this,e),ye.applyMatrix3(t),this.setXY(e,ye.x,ye.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix3(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix4(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyNormalMatrix(t),this.setXYZ(e,me.x,me.y,me.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.transformDirection(t),this.setXYZ(e,me.x,me.y,me.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=R(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=F(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=R(e,this.array)),e}setX(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=R(e,this.array)),e}setY(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=R(e,this.array)),e}setZ(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=R(e,this.array)),e}setW(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),n=F(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),n=F(n,this.array),i=F(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),n=F(n,this.array),i=F(i,this.array),r=F(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),35044!==this.usage&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class ve extends be{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class xe extends be{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class we extends be{constructor(t,e,n){super(new Float32Array(t),e,n)}}const _e=new te,Me=new L,Se=new L;class ke{constructor(t=new L,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):_e.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Me.subVectors(t,this.center);const e=Me.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(Me,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Se.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Me.copy(t.center).add(Se)),this.expandByPoint(Me.copy(t.center).sub(Se))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Ae=0;const ze=new st,Te=new jt,Ie=new L,Oe=new te,Ee=new te,je=new L;class Pe extends O{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ae++}),this.uuid=j(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?xe:ve)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new W).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return ze.makeRotationFromQuaternion(t),this.applyMatrix4(ze),this}rotateX(t){return ze.makeRotationX(t),this.applyMatrix4(ze),this}rotateY(t){return ze.makeRotationY(t),this.applyMatrix4(ze),this}rotateZ(t){return ze.makeRotationZ(t),this.applyMatrix4(ze),this}translate(t,e,n){return ze.makeTranslation(t,e,n),this.applyMatrix4(ze),this}scale(t,e,n){return ze.makeScale(t,e,n),this.applyMatrix4(ze),this}lookAt(t){return Te.lookAt(t),Te.updateMatrix(),this.applyMatrix4(Te.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ie).negate(),this.translate(Ie.x,Ie.y,Ie.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new we(e,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&z("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new te);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return T("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Oe.setFromBufferAttribute(n),this.morphTargetsRelative?(je.addVectors(this.boundingBox.min,Oe.min),this.boundingBox.expandByPoint(je),je.addVectors(this.boundingBox.max,Oe.max),this.boundingBox.expandByPoint(je)):(this.boundingBox.expandByPoint(Oe.min),this.boundingBox.expandByPoint(Oe.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&T('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ke);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return T("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new L,1/0);if(t){const n=this.boundingSphere.center;if(Oe.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ee.setFromBufferAttribute(n),this.morphTargetsRelative?(je.addVectors(Oe.min,Ee.min),Oe.expandByPoint(je),je.addVectors(Oe.max,Ee.max),Oe.expandByPoint(je)):(Oe.expandByPoint(Ee.min),Oe.expandByPoint(Ee.max))}Oe.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)je.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(je));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],o=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)je.fromBufferAttribute(s,e),o&&(Ie.fromBufferAttribute(t,e),je.add(Ie)),i=Math.max(i,n.distanceToSquared(je))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&T('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void T("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;let s=this.getAttribute("tangent");void 0!==s&&s.count===n.count||(s=new be(new Float32Array(4*n.count),4),this.setAttribute("tangent",s));const o=[],a=[];for(let t=0;t<n.count;t++)o[t]=new L,a[t]=new L;const c=new L,h=new L,l=new L,u=new D,d=new D,p=new D,f=new L,m=new L;function y(t,e,i){c.fromBufferAttribute(n,t),h.fromBufferAttribute(n,e),l.fromBufferAttribute(n,i),u.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),h.sub(c),l.sub(c),d.sub(u),p.sub(u);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(h).multiplyScalar(p.y).addScaledVector(l,-d.y).multiplyScalar(s),m.copy(l).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(s),o[t].add(f),o[e].add(f),o[i].add(f),a[t].add(m),a[e].add(m),a[i].add(m))}let g=this.groups;0===g.length&&(g=[{start:0,count:t.count}]);for(let e=0,n=g.length;e<n;++e){const n=g[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)y(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const b=new L,v=new L,x=new L,w=new L;function _(t){x.fromBufferAttribute(i,t),w.copy(x);const e=o[t];b.copy(e),b.sub(x.multiplyScalar(x.dot(e))).normalize(),v.crossVectors(w,e);const n=v.dot(a[t])<0?-1:1;s.setXYZW(t,b.x,b.y,b.z,n)}for(let e=0,n=g.length;e<n;++e){const n=g[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)_(t.getX(e+0)),_(t.getX(e+1)),_(t.getX(e+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n||n.count!==e.count)n=new be(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new L,r=new L,s=new L,o=new L,a=new L,c=new L,h=new L,l=new L;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),l.subVectors(i,r),h.cross(l),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,p),c.fromBufferAttribute(n,f),o.add(h),a.add(h),c.add(h),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(f,c.x,c.y,c.z)}else for(let t=0,o=e.count;t<o;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),l.subVectors(i,r),h.cross(l),n.setXYZ(t+0,h.x,h.y,h.z),n.setXYZ(t+1,h.x,h.y,h.z),n.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)je.fromBufferAttribute(t,e),je.normalize(),t.setXYZ(e,je.x,je.y,je.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let o=0,a=0;for(let r=0,c=e.length;r<c;r++){o=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)s[a++]=n[o++]}return new be(s,i,r)}if(null===this.index)return z("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Pe,n=this.index.array,i=this.attributes;for(const r in i){const s=t(i[r],n);e.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],o=r[i];for(let e=0,i=o.length;e<i;e++){const i=t(o[e],n);s.push(i)}e.morphAttributes[i]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=void 0!==this.parameters&&!0===this._transformed?"BufferGeometry":this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters&&!0!==this._transformed){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];s.push(i.toJSON(t.data))}s.length>0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere=o.toJSON()),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone());const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Ce=0;class Re extends O{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ce++}),this.uuid=j(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nt(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=_,this.stencilZFail=_,this.stencilZPass=_,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){z(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:z(`Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_&&(n.stencilFail=this.stencilFail),this.stencilZFail!==_&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==_&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}fromJSON(t,e){if(void 0!==t.uuid&&(this.uuid=t.uuid),void 0!==t.name&&(this.name=t.name),void 0!==t.color&&void 0!==this.color&&this.color.setHex(t.color),void 0!==t.roughness&&(this.roughness=t.roughness),void 0!==t.metalness&&(this.metalness=t.metalness),void 0!==t.sheen&&(this.sheen=t.sheen),void 0!==t.sheenColor&&(this.sheenColor=(new Nt).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(this.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==this.emissive&&this.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==this.specular&&this.specular.setHex(t.specular),void 0!==t.specularIntensity&&(this.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==this.specularColor&&this.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(this.shininess=t.shininess),void 0!==t.clearcoat&&(this.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(this.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(this.dispersion=t.dispersion),void 0!==t.iridescence&&(this.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(this.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(this.transmission=t.transmission),void 0!==t.thickness&&(this.thickness=t.thickness),void 0!==t.attenuationDistance&&(this.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==this.attenuationColor&&this.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(this.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(this.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(this.fog=t.fog),void 0!==t.flatShading&&(this.flatShading=t.flatShading),void 0!==t.blending&&(this.blending=t.blending),void 0!==t.combine&&(this.combine=t.combine),void 0!==t.side&&(this.side=t.side),void 0!==t.shadowSide&&(this.shadowSide=t.shadowSide),void 0!==t.opacity&&(this.opacity=t.opacity),void 0!==t.transparent&&(this.transparent=t.transparent),void 0!==t.alphaTest&&(this.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(this.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(this.depthFunc=t.depthFunc),void 0!==t.depthTest&&(this.depthTest=t.depthTest),void 0!==t.depthWrite&&(this.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(this.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(this.blendSrc=t.blendSrc),void 0!==t.blendDst&&(this.blendDst=t.blendDst),void 0!==t.blendEquation&&(this.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(this.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(this.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(this.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==this.blendColor&&this.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(this.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(this.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(this.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(this.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(this.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(this.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(this.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(this.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(this.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(this.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(this.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(this.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(this.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.linewidth&&(this.linewidth=t.linewidth),void 0!==t.dashSize&&(this.dashSize=t.dashSize),void 0!==t.gapSize&&(this.gapSize=t.gapSize),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.polygonOffset&&(this.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(this.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(this.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(this.dithering=t.dithering),void 0!==t.alphaToCoverage&&(this.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(this.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(this.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(this.allowOverride=t.allowOverride),void 0!==t.visible&&(this.visible=t.visible),void 0!==t.toneMapped&&(this.toneMapped=t.toneMapped),void 0!==t.userData&&(this.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),void 0!==t.size&&(this.size=t.size),void 0!==t.sizeAttenuation&&(this.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(this.map=e[t.map]||null),void 0!==t.matcap&&(this.matcap=e[t.matcap]||null),void 0!==t.alphaMap&&(this.alphaMap=e[t.alphaMap]||null),void 0!==t.bumpMap&&(this.bumpMap=e[t.bumpMap]||null),void 0!==t.bumpScale&&(this.bumpScale=t.bumpScale),void 0!==t.normalMap&&(this.normalMap=e[t.normalMap]||null),void 0!==t.normalMapType&&(this.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),this.normalScale=(new D).fromArray(e)}return void 0!==t.displacementMap&&(this.displacementMap=e[t.displacementMap]||null),void 0!==t.displacementScale&&(this.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(this.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(this.roughnessMap=e[t.roughnessMap]||null),void 0!==t.metalnessMap&&(this.metalnessMap=e[t.metalnessMap]||null),void 0!==t.emissiveMap&&(this.emissiveMap=e[t.emissiveMap]||null),void 0!==t.emissiveIntensity&&(this.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(this.specularMap=e[t.specularMap]||null),void 0!==t.specularIntensityMap&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),void 0!==t.specularColorMap&&(this.specularColorMap=e[t.specularColorMap]||null),void 0!==t.envMap&&(this.envMap=e[t.envMap]||null),void 0!==t.envMapRotation&&this.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(this.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(this.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(this.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(this.lightMap=e[t.lightMap]||null),void 0!==t.lightMapIntensity&&(this.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(this.aoMap=e[t.aoMap]||null),void 0!==t.aoMapIntensity&&(this.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(this.gradientMap=e[t.gradientMap]||null),void 0!==t.clearcoatMap&&(this.clearcoatMap=e[t.clearcoatMap]||null),void 0!==t.clearcoatRoughnessMap&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),void 0!==t.clearcoatNormalMap&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),void 0!==t.clearcoatNormalScale&&(this.clearcoatNormalScale=(new D).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(this.iridescenceMap=e[t.iridescenceMap]||null),void 0!==t.iridescenceThicknessMap&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),void 0!==t.transmissionMap&&(this.transmissionMap=e[t.transmissionMap]||null),void 0!==t.thicknessMap&&(this.thicknessMap=e[t.thicknessMap]||null),void 0!==t.anisotropyMap&&(this.anisotropyMap=e[t.anisotropyMap]||null),void 0!==t.sheenColorMap&&(this.sheenColorMap=e[t.sheenColorMap]||null),void 0!==t.sheenRoughnessMap&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}const Fe=new L,De=new L,Ne=new L,Le=new L,Be=new L,Ue=new L,We=new L;class qe{constructor(t=new L,e=new L(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Fe)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Fe.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Fe.copy(this.origin).addScaledVector(this.direction,e),Fe.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){De.copy(t).add(e).multiplyScalar(.5),Ne.copy(e).sub(t).normalize(),Le.copy(this.origin).sub(De);const r=.5*t.distanceTo(e),s=-this.direction.dot(Ne),o=Le.dot(this.direction),a=-Le.dot(Ne),c=Le.lengthSq(),h=Math.abs(1-s*s);let l,u,d,p;if(h>0)if(l=s*a-o,u=s*o-a,p=r*h,l>=0)if(u>=-p)if(u<=p){const t=1/h;l*=t,u*=t,d=l*(l+s*u+2*o)+u*(s*l+u+2*a)+c}else u=r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u=-r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u<=-p?(l=Math.max(0,-(-s*r+o)),u=l>0?-r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c):u<=p?(l=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+c):(l=Math.max(0,-(s*r+o)),u=l>0?r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c);else u=s>0?-r:r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,l),i&&i.copy(De).addScaledVector(Ne,u),d}intersectSphere(t,e){Fe.subVectors(t.center,this.origin);const n=Fe.dot(this.direction),i=Fe.dot(Fe)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),o=n-s,a=n+s;return a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,o,a;const c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,i=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,i=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),n>a||o>i?null:((o>n||n!=n)&&(n=o),(a<i||i!=i)&&(i=a),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Fe)}intersectTriangle(t,e,n,i,r){Be.subVectors(e,t),Ue.subVectors(n,t),We.crossVectors(Be,Ue);let s,o=this.direction.dot(We);if(o>0){if(i)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}Le.subVectors(this.origin,t);const a=s*this.direction.dot(Ue.crossVectors(Le,Ue));if(a<0)return null;const c=s*this.direction.dot(Be.cross(Le));if(c<0)return null;if(a+c>o)return null;const h=-s*Le.dot(We);return h<0?null:this.at(h/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class $e extends Re{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Nt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ve=new st,Ye=new qe,He=new ke,Ge=new L,Xe=new L,Ze=new L,Je=new L,Qe=new L,Ke=new L,tn=new L,en=new L;class nn extends jt{constructor(t=new Pe,e=new $e){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){Ke.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=o[n],a=r[n];0!==i&&(Qe.fromBufferAttribute(a,t),s?Ke.addScaledVector(Qe,i):Ke.addScaledVector(Qe.sub(e),i))}e.add(Ke)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),He.copy(n.boundingSphere),He.applyMatrix4(r),Ye.copy(t.ray).recast(t.near),!1===He.containsPoint(Ye.origin)){if(null===Ye.intersectSphere(He,Ge))return;if(Ye.origin.distanceToSquared(Ge)>(t.far-t.near)**2)return}Ve.copy(r).invert(),Ye.copy(t.ray).applyMatrix4(Ve),null!==n.boundingBox&&!1===Ye.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,Ye)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,l=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==o)if(Array.isArray(s))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){i=rn(this,p,t,n,c,h,l,o.getX(r),o.getX(r+1),o.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=rn(this,s,t,n,c,h,l,o.getX(r),o.getX(r+1),o.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==a)if(Array.isArray(s))for(let r=0,o=u.length;r<o;r++){const o=u[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){i=rn(this,p,t,n,c,h,l,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=rn(this,s,t,n,c,h,l,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function rn(t,e,n,i,r,s,o,a,c,h){t.getVertexPosition(a,Xe),t.getVertexPosition(c,Ze),t.getVertexPosition(h,Je);const l=function(t,e,n,i,r,s,o,a){let c;if(c=1===e.side?i.intersectTriangle(o,s,r,!0,a):i.intersectTriangle(r,s,o,0===e.side,a),null===c)return null;en.copy(a),en.applyMatrix4(t.matrixWorld);const h=n.ray.origin.distanceTo(en);return h<n.near||h>n.far?null:{distance:h,point:en.clone(),object:t}}(t,e,n,i,Xe,Ze,Je,tn);if(l){const t=new L;Kt.getBarycoord(tn,Xe,Ze,Je,t),r&&(l.uv=Kt.getInterpolatedAttribute(r,a,c,h,t,new D)),s&&(l.uv1=Kt.getInterpolatedAttribute(s,a,c,h,t,new D)),o&&(l.normal=Kt.getInterpolatedAttribute(o,a,c,h,t,new L),l.normal.dot(i.direction)>0&&l.normal.multiplyScalar(-1));const e={a:a,b:c,c:h,normal:new L,materialIndex:0};Kt.getNormal(Xe,Ze,Je,e.normal),l.face=e,l.barycoord=t}return l}class sn extends it{constructor(t,e,n,i,r,s,o,a,c){super(t,e,n,i,r,s,o,a,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class on extends Pe{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const a=[],c=[],h=[],l=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,y,g){const b=s/m,v=p/y,x=s/2,w=p/2,_=f/2,M=m+1,S=y+1;let k=0,A=0;const z=new L;for(let s=0;s<S;s++){const o=s*v-w;for(let a=0;a<M;a++){const u=a*b-x;z[t]=u*i,z[e]=o*r,z[n]=_,c.push(z.x,z.y,z.z),z[t]=0,z[e]=0,z[n]=f>0?1:-1,h.push(z.x,z.y,z.z),l.push(a/m),l.push(1-s/y),k+=1}}for(let t=0;t<y;t++)for(let e=0;e<m;e++){const n=u+e+M*t,i=u+e+M*(t+1),r=u+(e+1)+M*(t+1),s=u+(e+1)+M*t;a.push(n,i,s),a.push(i,r,s),A+=6}o.addGroup(d,A,g),d+=A,u+=k}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new we(c,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new on(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class an extends Pe{constructor(t=1,e=1,n=1,i=32,r=1,s=!1,o=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a};const c=this;i=Math.floor(i),r=Math.floor(r);const h=[],l=[],u=[],d=[];let p=0;const f=[],m=n/2;let y=0;function g(n){const r=p,s=new D,f=new L;let g=0;const b=!0===n?t:e,v=!0===n?1:-1;for(let t=1;t<=i;t++)l.push(0,m*v,0),u.push(0,v,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*a+o,n=Math.cos(e),r=Math.sin(e);f.x=b*r,f.y=m*v,f.z=b*n,l.push(f.x,f.y,f.z),u.push(0,v,0),s.x=.5*n+.5,s.y=.5*r*v+.5,d.push(s.x,s.y),p++}for(let t=0;t<i;t++){const e=r+t,i=x+t;!0===n?h.push(i,i+1,e):h.push(i+1,i,e),g+=3}c.addGroup(y,g,!0===n?1:2),y+=g}!function(){const s=new L,g=new L;let b=0;const v=(e-t)/n;for(let c=0;c<=r;c++){const h=[],y=c/r,b=y*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*a+o,c=Math.sin(r),f=Math.cos(r);g.x=b*c,g.y=-y*n+m,g.z=b*f,l.push(g.x,g.y,g.z),s.set(c,v,f).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-y),h.push(p++)}f.push(h)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const s=f[i][n],o=f[i+1][n],a=f[i+1][n+1],c=f[i][n+1];(t>0||0!==i)&&(h.push(s,o,c),b+=3),(e>0||i!==r-1)&&(h.push(o,a,c),b+=3)}c.addGroup(y,b,0),y+=b}(),!1===s&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(h),this.setAttribute("position",new we(l,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new an(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class cn extends Pe{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,o=Math.floor(n),a=Math.floor(i),c=o+1,h=a+1,l=t/o,u=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*u-s;for(let n=0;n<c;n++){const i=n*l-r;p.push(i,-e,0),f.push(0,0,1),m.push(n/o),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<o;e++){const n=e+c*t,i=e+c*(t+1),r=e+1+c*(t+1),s=e+1+c*t;d.push(n,i,s),d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(f,3)),this.setAttribute("uv",new we(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cn(t.width,t.height,t.widthSegments,t.heightSegments)}}class hn extends Pe{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const a=Math.min(s+o,Math.PI);let c=0;const h=[],l=new L,u=new L,d=[],p=[],f=[],m=[];for(let d=0;d<=n;d++){const y=[],g=d/n,b=s+g*o,v=t*Math.cos(b),x=Math.sqrt(t*t-v*v);let w=0;0===d&&0===s?w=.5/e:d===n&&a===Math.PI&&(w=-.5/e);for(let t=0;t<=e;t++){const n=t/e,s=i+n*r;l.x=-x*Math.cos(s),l.y=v,l.z=x*Math.sin(s),p.push(l.x,l.y,l.z),u.copy(l).normalize(),f.push(u.x,u.y,u.z),m.push(n+w,1-g),y.push(c++)}h.push(y)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=h[t][i+1],r=h[t][i],o=h[t+1][i],c=h[t+1][i+1];(0!==t||s>0)&&d.push(e,r,c),(t!==n-1||a<Math.PI)&&d.push(r,o,c)}this.setIndex(d),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(f,3)),this.setAttribute("uv",new we(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class ln extends Re{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Nt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new D(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class un{static{un.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function dn(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?z("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const pn=new mt;function fn(t,e){pn.setFromQuaternion(new N(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=pn.x,t.rotation=-pn.y,t.rotationY=pn.z}const mn="_transferSlotId";const yn=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=yn);const gn=new class{constructor(){this.enabled=!1,this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}enable(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._frameCount=0,this._lastSnapshotTime=0,this.enabled=!0}disable(){this.enabled=!1}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){this.enabled||this.enable();const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,i=this._getResidents?.()??null;let r=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(r=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const s={fps:r,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...i??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,s}};function bn(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const vn=new class{constructor(){this._realTime=0,this._totalTicks=0,this._subs=new Set,this._nextId=1,this._externals=new Set,this._externalNextId=1,this._rafId=null,this._lastWallTime=null,this._emaDt=16.67,this._ticking=!1,this._hasPendingRemoval=!1}get realTime(){return this._realTime}get simTime(){return yn.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const n=e?.component,i=n?.app??n?.root?.app;if(i&&"boolean"==typeof i.isViewMode&&!i.isViewMode)return()=>{};const r={id:this._nextId++,handler:t,description:e?.description??`<anonymous#${this._nextId-1}>`,componentRef:null!=e?.component&&"undefined"!=typeof WeakRef?new WeakRef(e.component):void 0,targetsGetter:e?.getTargets,metadata:e?.metadata,registeredAt:this._realTime,tickCount:0,totalDurationMs:0,lastDt:0,lastDurationMs:0};return this._subs.add(r),this.isRunning||this.start(),()=>{this._ticking?(r._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(r),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,gn.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const n=yn.tick(e),i=yn.now;if(this._ticking=!0,gn.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(n,i)}finally{const i=performance.now()-e;t.tickCount++,t.totalDurationMs+=i,t.lastDt=n,t.lastDurationMs=i}}else for(const t of this._subs)t._removed||t.handler(n,i);if(this._ticking=!1,this._hasPendingRemoval){this._hasPendingRemoval=!1;for(const t of this._subs)t._removed&&this._subs.delete(t);0===this._subs.size&&this.stop()}}start(){if(null!==this._rafId)return;if("undefined"==typeof requestAnimationFrame)return;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),n=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(n),null!==this._rafId&&(this._rafId=requestAnimationFrame(t))};this._rafId=requestAnimationFrame(t)}stop(){null!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._lastWallTime=null}registerExternalAnimation(t,e,n){const i={id:this._externalNextId++,description:t,source:e,metadata:n,registeredAt:this._realTime};return this._externals.add(i),{update:t=>{i.metadata={...i.metadata??{},...t}},unregister:()=>{this._externals.delete(i)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let n;const i=e.componentRef?.deref();let r;if(i&&(n=bn(i)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(bn(t));n.length>0&&(r=n)}}catch{}t.push({id:e.id,description:e.description,componentInfo:n,targetInfos:r,metadata:e.metadata,registeredAt:e.registeredAt,tickCount:e.tickCount,totalDurationMs:Math.round(100*e.totalDurationMs)/100,avgDurationMs:e.tickCount>0?Math.round(e.totalDurationMs/e.tickCount*100)/100:0,lastDt:Math.round(100*e.lastDt)/100,lastDurationMs:Math.round(100*e.lastDurationMs)/100})}const e=[];for(const t of this._externals)e.push({id:t.id,description:t.description,source:t.source,metadata:t.metadata,registeredAt:t.registeredAt,liveDurationMs:Math.round(this._realTime-t.registeredAt)});return{realTime:Math.round(this._realTime),simTime:Math.round(yn.now),isRunning:this.isRunning,speed:yn.speed,paused:yn.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let xn=null;const wn=[],_n=new Set;function Mn(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const Sn={beginContext(t){xn=t},endContext(){xn=null},current:()=>xn,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??Mn(t.component),componentType:t.componentType??(n=t.component,n?.state?.type??n?.type),atSimMs:yn.now,args:t.args,result:t.result,error:t.error};var n;xn?xn.pushTrace(e):(wn.push(e),wn.length>500&&wn.shift(),_n.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...wn],onStandalone:t=>(_n.add(t),()=>{_n.delete(t)}),clearStandalone(){wn.length=0}};function kn(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const n=String(e);return n.length>0?n:void 0}function An(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},n=t.sourceId??kn(t.source),i=t.targetId??kn(t.target),r=t.carrierId??kn(t.carrier);return void 0!==n&&(e.sourceId=n),void 0!==i&&(e.targetId=i),void 0!==r&&(e.carrierId=r),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let zn=1;class Tn{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+zn++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:yn.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??yn.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return In.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=yn.now;const t=this.options?.slotId,e=void 0!==t?{slotId:t}:void 0,n=this.target.canAccept?.(this.carrier,e);if(n&&n.ok)this._slot=n.slot;else{if(n&&!n.ok&&"no-slots-defined"!==n.reason)return this._rejectReason=n.reason,this._rollback();if(n||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier,e))return this._rejectReason="cannot-receive",this._rollback();this._slot=void 0!==t?this.target.slotById?.(t)??null:"function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}return null===this._slot||"function"!=typeof this.target.reserve||"function"!=typeof this.target.commit||(this._reservation=this.target.reserve(this.carrier,{source:this.source,...e}),this._reservation)?(this._timeline.planEndAt=yn.now,null):(this._rejectReason="cannot-reserve",this._rollback())}_physicalFailed(t){return this._reservation&&this.target.release?.(this._reservation),this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._rollback()}_handoffFailed(t){throw this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back",In.append(this._buildReceipt()),t}_commitReserved(){if(this._reservation&&"function"==typeof this.target.commit){try{this.target.commit(this._reservation,this.carrier,this.options)}catch(t){this.target.release?.(this._reservation),this._handoffFailed(t)}return!0}return!1}_finishCommitted(){this._phase="committed",this._timeline.committedAt=yn.now;const t=this._buildReceipt();return In.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=yn.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=yn.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=yn.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=yn.now,null}_runReceiveSync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{const e=t.call(this.target,this.carrier,this.options);e instanceof Promise&&e.catch(()=>{})}catch(t){this._handoffFailed(t)}else Sn.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async _runReceiveAsync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{await t.call(this.target,this.carrier,this.options)}catch(t){this._handoffFailed(t)}else Sn.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){Sn.beginContext(this),Sn.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:kn(this.source),target:kn(this.target),carrier:kn(this.carrier)}});try{return await this._executeImpl()}finally{Sn.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),Sn.endContext()}}executeSync(){Sn.beginContext(this),Sn.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:kn(this.source),target:kn(this.target),carrier:kn(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=yn.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{Sn.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),Sn.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=yn.now,this._commitReserved()||await this._runReceiveAsync(),this._finishCommitted())}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",In.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:kn(this.source),targetId:kn(this.target),carrierId:kn(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason,traceEvents:[...this._traceEvents],meta:Object.keys(this.meta).length>0?{...this.meta}:void 0}}}const In=new class{constructor(){this._flows=new Map,this._targetCount=new Map,this._byPhase=new Map,this._byRejectReason=new Map,this._total=0,this._committedDurationSum=0,this._committedCount=0,this._listeners=new Set}append(t){this._total++,this._byPhase.set(t.phase,(this._byPhase.get(t.phase)??0)+1);const e=t.sourceId??kn(t.source),n=t.targetId??kn(t.target);if("committed"===t.phase){if(e&&n){const t=e+">"+n;this._flows.set(t,(this._flows.get(t)??0)+1)}n&&this._targetCount.set(n,(this._targetCount.get(n)??0)+1),void 0!==t.timeline.committedAt&&(this._committedDurationSum+=t.timeline.committedAt-t.timeline.initiatedAt,this._committedCount++)}else if("rolled-back"===t.phase&&t.rejectReason){this._byRejectReason.set(t.rejectReason,(this._byRejectReason.get(t.rejectReason)??0)+1);try{t.source?._bumpRejected?.(t.carrier,t.rejectReason)}catch{}}this._listeners.forEach(e=>e(t))}flows(){return this._flows}targetCounts(){return this._targetCount}stats(){const t={};this._byPhase.forEach((e,n)=>{t[n]=e});const e=t["rolled-back"]??0;return{total:this._total,byPhase:t,committed:t.committed??0,rolledBack:e,rejectionRate:this._total>0?e/this._total:0,avgTransferDurationMs:this._committedCount>0?this._committedDurationSum/this._committedCount:0}}rejectReasonCounts(){return this._byRejectReason}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}clear(){this._flows.clear(),this._targetCount.clear(),this._byPhase.clear(),this._byRejectReason.clear(),this._total=0,this._committedDurationSum=0,this._committedCount=0}entries(){return[]}forCarrier(t){return[]}forCarrierId(t){return[]}forSourceId(t){return[]}forTargetId(t){return[]}forPhase(t){return[]}inTimeRange(t,e,n){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=In);let On=1;function En(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const jn={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class Pn{constructor(t=jn){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+On++},n=(this._byResource.get(e.resource)??[]).filter(t=>En(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const i=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(i.every(t=>"b-yields"===t.decision)){const i=n.slice();for(const t of i)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:i,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:i}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:i}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>En(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let i=this._byReserver.get(t.reserverId);i||(i=[],this._byReserver.set(t.reserverId,i)),i.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const i=this._byReserver.get(t.reserverId);if(i){const e=i.findIndex(e=>e.id===t.id);e>=0&&i.splice(e,1),0===i.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const Cn=new Pn;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=Cn);class Rn{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const i of this.nodes.values()){const r=Fn(i.position,t);r<n&&(n=r,e=i)}return e}}function Fn(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}function Dn(t,e){return Math.sqrt(Fn(t,e))}function Nn(t,e,n={}){const i=new Rn,r=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,s=`${e.id}:end`;i.addNode({id:n,position:t[0],type:"lane-start"}),i.addNode({id:s,position:t[t.length-1],type:"lane-end"}),i.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:s});let o=0;for(let e=1;e<t.length;e++)o+=Dn(t[e-1],t[e]);const a=o/(e.speedLimit??r)*1e3;i.addEdge({fromNode:n,toNode:s,resource:e.id,distance:o,durationMs:a,forward:!0}),"twoway"===e.direction&&i.addEdge({fromNode:s,toNode:n,resource:e.id,distance:o,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const r=i.laneEndpoints.get(n);if(!r)continue;const s=i.nodes.get(r.startNodeId).position,o=i.nodes.get(r.endNodeId).position;let a=0,c=0,h=0;for(const e of t.lanes){if(e===n)continue;const t=i.laneEndpoints.get(e);if(!t)continue;const r=i.nodes.get(t.startNodeId).position,l=i.nodes.get(t.endNodeId).position;a+=Math.min(Fn(s,r),Fn(s,l)),c+=Math.min(Fn(o,r),Fn(o,l)),h++}if(0===h)continue;const l=a<c?r.startNodeId:r.endNodeId;e.push({laneId:n,nodeId:l,pos:i.nodes.get(l).position})}for(let n=0;n<e.length;n++)for(let r=0;r<e.length;r++){if(n===r)continue;const s=e[n],o=e[r],a=Dn(s.pos,o.pos);i.addEdge({fromNode:s.nodeId,toNode:o.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return i}function Ln(t,e,n,i={}){const r=t.nodes.get(e),s=t.nodes.get(n);if(!r||!s)return null;const o=i.speed?.max??100,a=e=>{const n=t.nodes.get(e);var i,r;return(i=n.position,r=s.position,Math.sqrt(function(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}(i,r)))/o*1e3},c=new Map,h=new Set,l=new Set,u={nodeId:e,gScore:0,fScore:a(e)};c.set(e,u),h.add(e);const d=i.startSimMs??0,p=i.deadlineSimMs;for(;h.size>0;){let e=null,i=null;for(const t of h){const n=c.get(t);(!i||n.fScore<i.fScore||n.fScore===i.fScore&&t<e)&&(i=n,e=t)}if(!i||!e)return null;if(e===n){const t=[];let e=i,n=0;for(;e&&e.cameFromEdge;){const i=e.cameFromEdge,r=d+(e.gScore-i.durationMs);t.unshift({resource:i.resource,timeWindow:{startSimMs:r,endSimMs:r+i.durationMs},fromPos:i.fromPos,toPos:i.toPos}),n+=i.distance,e=c.get(i.fromNodeId)}const r=i.gScore;return void 0!==p&&d+r>p?null:{segments:t,totalDurationMs:r,totalDistance:n}}h.delete(e),l.add(e);for(const n of t.edgesFrom(e)){if(l.has(n.toNode))continue;const e=i.gScore+n.durationMs,r=c.get(n.toNode);if(!r||e<r.gScore){const i=t.nodes.get(n.fromNode),r=t.nodes.get(n.toNode),s={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:i.position,toPos:r.position}};c.set(n.toNode,s),h.add(n.toNode)}}}return null}function Bn(t,e,n=0,i){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:i}))}const Un=.5;function Wn(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function qn(t,e,n){const i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(i*i+r*r);if(0===s||!Number.isFinite(n)||Math.abs(n)<1e-9)return null;const o=Math.abs(n),a=(s*s+4*o*o)/(8*o),c=n>0?1:-1,h=a-o,l=(t.x+e.x)/2-c*(r/s)*h,u=(t.y+e.y)/2-c*-(i/s)*h;return{cx:l,cy:u,radius:a,startAngle:Math.atan2(t.y-u,t.x-l),endAngle:Math.atan2(e.y-u,e.x-l),clockwise:n<0}}function $n(t,e,n=0,i=16){const r=e.x-t.x,s=e.y-t.y,o=Math.sqrt(r*r+s*s);if(0===o)return null;const a=s/o,c=-(r/o),h=Number.isFinite(n)?n:0,l=Math.abs(h)>=1e-6?h:i;return{x:(t.x+e.x)/2+a*l,y:(t.y+e.y)/2+c*l,perpX:a,perpY:c}}function Vn(t,e,n){const i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(i*i+r*r);if(0===s)return 0;const o=r/s,a=-(i/s),c=(t.x+e.x)/2,h=(t.y+e.y)/2;let l=(n.x-c)*o+(n.y-h)*a;if(Math.abs(l)<.5)return 0;return l>s&&(l=s),l<-s&&(l=-s),l}function Yn(t,e){const n=t.radius,i=Number.isFinite(e)?e:0;return null!=n&&Number.isFinite(n)?Math.max(0,n):Math.max(0,i)}function Hn(t,e,n,i,r=16){const s=t.x-e.x,o=t.y-e.y,a=Math.sqrt(s*s+o*o);if(0===a)return null;const c=n.x-e.x,h=n.y-e.y,l=Math.sqrt(c*c+h*h);if(0===l)return null;const u=s/a+c/l,d=o/a+h/l,p=Math.sqrt(u*u+d*d);if(p<1e-9)return null;const f=u/p,m=d/p,y=Math.max(i,r);return{x:e.x+f*y,y:e.y+m*y,bisectorX:f,bisectorY:m}}function Gn(t,e,n,i){const r=t.x-e.x,s=t.y-e.y,o=Math.sqrt(r*r+s*s),a=n.x-e.x,c=n.y-e.y,h=Math.sqrt(a*a+c*c);if(0===o||0===h)return 0;const l=r/o+a/h,u=s/o+c/h,d=Math.sqrt(l*l+u*u);if(d<1e-9)return 0;const p=l/d,f=u/d,m=(i.x-e.x)*p+(i.y-e.y)*f,y=Math.min(o,h)/2;return Math.max(0,Math.min(m,y))}function Xn(t){if(0===t.length)return 0;let e;for(const n of t){const t=n.z??0;if(!Number.isFinite(t))return null;if(void 0===e)e=t;else if(Math.abs(t-e)>1e-9)return null}return e??0}const Zn={closed:!0,round:0,divisions:24};class Jn{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const i=t[e].x-t[e-1].x,r=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(i*i+r*r))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const i=this.cumulative;let r=0,s=i.length-2;for(;r<s;){const t=r+s>>1;i[t+1]<=n?r=t+1:s=t}const o=i[r+1]-i[r],a=o>0?(n-i[r])/o:0,c=this.points[r],h=this.points[r+1],l=h.x-c.x,u=h.y-c.y;return{x:c.x+l*a,y:c.y+u*a,theta:0===l&&0===u?0:Math.atan2(u,l)}}}function Qn(t,e={}){const n={...Zn,...e},i=t.length;if(0===i)return new Jn([],n.closed);if(1===i)return new Jn([{x:t[0].x,y:t[0].y}],n.closed);const r=[],s=(t,e)=>{if(r.length>0){const n=r[r.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}r.push({x:t,y:e})},o=(n.closed,i);for(let e=0;e<o;e++){const r=0===e?n.closed?i-1:-1:e-1,o=e===i-1?n.closed?0:-1:e+1,a=r>=0?t[r]:null,c=t[e],h=o>=0?t[o]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const l=a&&h?Yn(c,n.round):0;let u,d,p,f;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(l,t/2);u=Math.sin(e)*n+c.x,d=Math.cos(e)*n+c.y}else u=c.x,d=c.y;if(h){const t=Math.sqrt((h.x-c.x)**2+(h.y-c.y)**2),e=0!==t?Math.atan2(h.x-c.x,h.y-c.y):0,n=Math.min(l,t/2);p=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else p=c.x,f=c.y;if(s(u,d),l>0&&a&&h)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,i=1-e;s(i*i*u+2*i*e*c.x+e*e*p,i*i*d+2*i*e*c.y+e*e*f)}else u===p&&d===f||s(p,f);if(h&&Wn(c)){const t=Yn(h,n.round),e=Math.sqrt((c.x-h.x)**2+(c.y-h.y)**2),i=0!==e?Math.atan2(c.x-h.x,c.y-h.y):0,r=Math.min(t,e/2),o=qn({x:p,y:f},{x:Math.sin(i)*r+h.x,y:Math.cos(i)*r+h.y},c.bulge);if(o){let t=o.endAngle-o.startAngle;if(o.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const i=e/n.divisions,r=o.startAngle+t*i;s(o.cx+o.radius*Math.cos(r),o.cy+o.radius*Math.sin(r))}}}}if(n.closed&&r.length>0){const t=r[0],e=r[r.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&r.push({x:t.x,y:t.y})}return new Jn(r,n.closed)}function Kn(t,e){return Qn(t,e).length}function ti(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function ei(t){if(ti(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class ni{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function ii(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),i=e.onAvailable(()=>t.resumeEmit());return ei(e).isFull&&t.pauseEmit(),()=>{n?.(),i?.()}}class ri{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,i){const r=e.maxCount??1/0;if(t<0||t>=r)return null;const s=this.owner?.state?.width??0,o=this.owner?.state?.height??0,a=i?.state?.width??0,c=i?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(o-c)/2),z:0}:{x:Math.max(0,(s-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function si(t,e,n,i,r,s,o){const a=n.w,c=n.h,h=i.w,l=i.h,u=i.d,d=[],p=h+r,f=l+r,m=Math.max(1,Math.floor((a+r)/p)),y=Math.max(1,Math.floor((c+r)/f)),g=m*y,b=s&&s>0?Math.floor(s):4;if("row"===t||"column"===t){const n=o?.advanceAlongX??!1,i=o?.reverse??!1,r=n?m:y,s=n?y:m,h=(t,e,i)=>((t,e,n)=>d.push({x:-a/2+(t+.5)*p,y:n*u+u/2,z:-c/2+(e+.5)*f}))(n?t:e,n?e:t,i);let l=0;for(let n=0;n<r&&l<e;n++){const o=i?r-1-n:n;if("column"===t)for(let t=0;t<s&&l<e;t++)for(let n=0;n<b&&l<e;n++)h(o,t,n),l++;else for(let t=0;t<b&&l<e;t++)for(let n=0;n<s&&l<e;n++)h(o,n,t),l++}return d}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,m-n),i=Math.max(1,y-n),r=e*i,o=Math.min(t,r);for(let t=0;t<o;t++){const r=t%e,s=Math.floor(t/e),o=-a/2+(r+(m-e)/2+.5)*p,h=-c/2+(s+(y-i)/2+.5)*f;d.push({x:o,y:n*u+u/2,z:h})}if(t-=o,n++,1===e&&1===i){for(let e=0;e<t;e++)d.push({x:0,y:(n+e)*u+u/2,z:0});break}if(s&&n>=s)break}return d}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/g),i=n%g,r=i%m,o=Math.floor(i/m),y=(t(2*n)-.5)*h*.2,b=(t(2*n+1)-.5)*l*.2,v=-a/2+(r+.5)*p+y,x=-c/2+(o+.5)*f+b;if(d.push({x:v,y:e*u+u/2,z:x}),s&&e>=s-1&&i===g-1)break}return d}for(let n=0;n<e;n++){const e=Math.floor(n/g);if(s&&e>=s)break;const i=n%g,r=i%m,o=Math.floor(i/m);let h=-a/2+(r+.5)*p;const l=-c/2+(o+.5)*f;"staggered"===t&&e%2==1&&(h+=p/2),d.push({x:h,y:e*u+u/2,z:l})}return d}class oi{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,i={}){const r=i.gap??this.defaults.gap??0,s=i.heightLimit??this.defaults.heightLimit,o=i.fill??this.defaults.fill;return si(this.pattern,t,e,n,r,s,o).map(t=>({position:t}))}}class ai{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,i={}){const r=Math.max(1,this.cols),s=Math.max(1,this.rows),o=r*s,a=i.gap??this.defaults.gap??0,c=n.w+a,h=n.h+a,l=[];for(let e=0;e<t;e++){const t=Math.floor(e/o),i=e%o,a=i%r,u=Math.floor(i/r);l.push({position:{x:(a-(r-1)/2)*c,z:(u-(s-1)/2)*h,y:t*n.d+n.d/2}})}return l}}class ci{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,i=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-i)/(e.h+i))),pitchX:e.w+n,pitchZ:e.h+i}}capacity(t,e,n){const{cols:i,rows:r}=this.grid(t,e);return i*r*Math.max(1,Math.floor(n))}layout(t,e,n,i={}){const{cols:r,rows:s,pitchX:o,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,h=null!=i.heightLimit?Math.max(1,Math.floor(i.heightLimit)):1/0,l=Number.isFinite(h),u=this.sliceFirst&&l,d=r*s,p=r*(l?h:1),f=r*s*(l?h:t),m=Math.min(t,f),y=[];for(let t=0;t<m;t++){let e,i,h;if(u){const n=Math.floor(t/p),s=t%p;e=s%r,h=Math.floor(s/r),i=n}else{h=Math.floor(t/d);const n=t%d;e=n%r,i=Math.floor(n/r)}this.fillFromFar&&(i=s-1-i),y.push({position:{x:(e-(r-1)/2)*o,z:(i-(s-1)/2)*a,y:h*c+n.d/2}})}return y}}function hi(t,e,n,i=0){for(let r=0;r<e.length;r++){const s=e[r],o=n[r];s&&o&&(s.parent!==t&&t.attach(s),s.position.set(o.position.x,i+o.position.y,o.position.z),o.rotation?s.quaternion.set(o.rotation.x,o.rotation.y,o.rotation.z,o.rotation.w):s.quaternion.identity())}}function li(t,e,n,i=.12){const r=e.left+e.width/2,s=e.top+e.height/2,o=Math.min(n.w,n.h)*i,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let i=a.get(t);i||(i={x:r+e.position.x-n.w/2+o,y:s+e.position.z-n.h/2+o,w:n.w-2*o,h:n.h-2*o,count:0},a.set(t,i)),i.count++}return[...a.values()]}function ui(t,e){return t===e||t!=t&&e!=e}function di(t,e){for(var n=t.length;n--;)if(ui(t[n][0],e))return n;return-1}var pi=Array.prototype.splice;function fi(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}fi.prototype.clear=function(){this.__data__=[],this.size=0},fi.prototype.delete=function(t){var e=this.__data__,n=di(e,t);return!(n<0)&&(n==e.length-1?e.pop():pi.call(e,n,1),--this.size,!0)},fi.prototype.get=function(t){var e=this.__data__,n=di(e,t);return n<0?void 0:e[n][1]},fi.prototype.has=function(t){return di(this.__data__,t)>-1},fi.prototype.set=function(t,e){var n=this.__data__,i=di(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var mi="object"==typeof global&&global&&global.Object===Object&&global,yi="object"==typeof self&&self&&self.Object===Object&&self,gi=mi||yi||Function("return this")(),bi=gi.Symbol,vi=Object.prototype,xi=vi.hasOwnProperty,wi=vi.toString,_i=bi?bi.toStringTag:void 0;var Mi=Object.prototype.toString;var Si=bi?bi.toStringTag:void 0;function ki(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Si&&Si in Object(t)?function(t){var e=xi.call(t,_i),n=t[_i];try{t[_i]=void 0;var i=!0}catch(t){}var r=wi.call(t);return i&&(e?t[_i]=n:delete t[_i]),r}(t):function(t){return Mi.call(t)}(t)}function Ai(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function zi(t){if(!Ai(t))return!1;var e=ki(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var Ti,Ii=gi["__core-js_shared__"],Oi=(Ti=/[^.]+$/.exec(Ii&&Ii.keys&&Ii.keys.IE_PROTO||""))?"Symbol(src)_1."+Ti:"";var Ei=Function.prototype.toString;function ji(t){if(null!=t){try{return Ei.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Pi=/^\[object .+?Constructor\]$/,Ci=Function.prototype,Ri=Object.prototype,Fi=Ci.toString,Di=Ri.hasOwnProperty,Ni=RegExp("^"+Fi.call(Di).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Li(t){return!(!Ai(t)||(e=t,Oi&&Oi in e))&&(zi(t)?Ni:Pi).test(ji(t));var e}function Bi(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Li(n)?n:void 0}var Ui=Bi(gi,"Map"),Wi=Bi(Object,"create");var qi=Object.prototype.hasOwnProperty;var $i=Object.prototype.hasOwnProperty;function Vi(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Yi(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function Hi(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Vi.prototype.clear=function(){this.__data__=Wi?Wi(null):{},this.size=0},Vi.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vi.prototype.get=function(t){var e=this.__data__;if(Wi){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return qi.call(e,t)?e[t]:void 0},Vi.prototype.has=function(t){var e=this.__data__;return Wi?void 0!==e[t]:$i.call(e,t)},Vi.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Wi&&void 0===e?"__lodash_hash_undefined__":e,this},Hi.prototype.clear=function(){this.size=0,this.__data__={hash:new Vi,map:new(Ui||fi),string:new Vi}},Hi.prototype.delete=function(t){var e=Yi(this,t).delete(t);return this.size-=e?1:0,e},Hi.prototype.get=function(t){return Yi(this,t).get(t)},Hi.prototype.has=function(t){return Yi(this,t).has(t)},Hi.prototype.set=function(t,e){var n=Yi(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};function Gi(t){var e=this.__data__=new fi(t);this.size=e.size}Gi.prototype.clear=function(){this.__data__=new fi,this.size=0},Gi.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Gi.prototype.get=function(t){return this.__data__.get(t)},Gi.prototype.has=function(t){return this.__data__.has(t)},Gi.prototype.set=function(t,e){var n=this.__data__;if(n instanceof fi){var i=n.__data__;if(!Ui||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Hi(i)}return n.set(t,e),this.size=n.size,this};function Xi(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Hi;++e<n;)this.add(t[e])}function Zi(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}Xi.prototype.add=Xi.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Xi.prototype.has=function(t){return this.__data__.has(t)};function Ji(t,e,n,i,r,s){var o=1&n,a=t.length,c=e.length;if(a!=c&&!(o&&c>a))return!1;var h=s.get(t),l=s.get(e);if(h&&l)return h==e&&l==t;var u=-1,d=!0,p=2&n?new Xi:void 0;for(s.set(t,e),s.set(e,t);++u<a;){var f=t[u],m=e[u];if(i)var y=o?i(m,f,u,e,t,s):i(f,m,u,t,e,s);if(void 0!==y){if(y)continue;d=!1;break}if(p){if(!Zi(e,function(t,e){if(o=e,!p.has(o)&&(f===t||r(f,t,n,i,s)))return p.push(e);var o})){d=!1;break}}else if(f!==m&&!r(f,m,n,i,s)){d=!1;break}}return s.delete(t),s.delete(e),d}var Qi=gi.Uint8Array;function Ki(t){var e=-1,n=Array(t.size);return t.forEach(function(t,i){n[++e]=[i,t]}),n}function tr(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var er=bi?bi.prototype:void 0,nr=er?er.valueOf:void 0;function ir(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var rr=Array.isArray;function sr(){return[]}var or=Object.prototype.propertyIsEnumerable,ar=Object.getOwnPropertySymbols,cr=ar?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,i=null==t?0:t.length,r=0,s=[];++n<i;){var o=t[n];e(o,n,t)&&(s[r++]=o)}return s}(ar(t),function(e){return or.call(t,e)}))}:sr;function hr(t){return null!=t&&"object"==typeof t}function lr(t){return hr(t)&&"[object Arguments]"==ki(t)}var ur=Object.prototype,dr=ur.hasOwnProperty,pr=ur.propertyIsEnumerable,fr=lr(function(){return arguments}())?lr:function(t){return hr(t)&&dr.call(t,"callee")&&!pr.call(t,"callee")};var mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,yr=mr&&"object"==typeof module&&module&&!module.nodeType&&module,gr=yr&&yr.exports===mr?gi.Buffer:void 0,br=(gr?gr.isBuffer:void 0)||function(){return!1},vr=/^(?:0|[1-9]\d*)$/;function xr(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&vr.test(t))&&t>-1&&t%1==0&&t<e}function wr(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var _r={};function Mr(t){return function(e){return t(e)}}_r["[object Float32Array]"]=_r["[object Float64Array]"]=_r["[object Int8Array]"]=_r["[object Int16Array]"]=_r["[object Int32Array]"]=_r["[object Uint8Array]"]=_r["[object Uint8ClampedArray]"]=_r["[object Uint16Array]"]=_r["[object Uint32Array]"]=!0,_r["[object Arguments]"]=_r["[object Array]"]=_r["[object ArrayBuffer]"]=_r["[object Boolean]"]=_r["[object DataView]"]=_r["[object Date]"]=_r["[object Error]"]=_r["[object Function]"]=_r["[object Map]"]=_r["[object Number]"]=_r["[object Object]"]=_r["[object RegExp]"]=_r["[object Set]"]=_r["[object String]"]=_r["[object WeakMap]"]=!1;var Sr="object"==typeof exports&&exports&&!exports.nodeType&&exports,kr=Sr&&"object"==typeof module&&module&&!module.nodeType&&module,Ar=kr&&kr.exports===Sr&&mi.process,zr=function(){try{var t=kr&&kr.require&&kr.require("util").types;return t||Ar&&Ar.binding&&Ar.binding("util")}catch(t){}}(),Tr=zr&&zr.isTypedArray,Ir=Tr?Mr(Tr):function(t){return hr(t)&&wr(t.length)&&!!_r[ki(t)]},Or=Object.prototype.hasOwnProperty;function Er(t,e){var n=rr(t),i=!n&&fr(t),r=!n&&!i&&br(t),s=!n&&!i&&!r&&Ir(t),o=n||i||r||s,a=o?function(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!Or.call(t,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||xr(h,c))||a.push(h);return a}var jr=Object.prototype;function Pr(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||jr)}function Cr(t,e){return function(n){return t(e(n))}}var Rr=Cr(Object.keys,Object),Fr=Object.prototype.hasOwnProperty;function Dr(t){if(!Pr(t))return Rr(t);var e=[];for(var n in Object(t))Fr.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Nr(t){return null!=t&&wr(t.length)&&!zi(t)}function Lr(t){return Nr(t)?Er(t):Dr(t)}function Br(t){return function(t,e,n){var i=e(t);return rr(t)?i:ir(i,n(t))}(t,Lr,cr)}var Ur=Object.prototype.hasOwnProperty;var Wr=Bi(gi,"DataView"),qr=Bi(gi,"Promise"),$r=Bi(gi,"Set"),Vr=Bi(gi,"WeakMap"),Yr="[object Map]",Hr="[object Promise]",Gr="[object Set]",Xr="[object WeakMap]",Zr="[object DataView]",Jr=ji(Wr),Qr=ji(Ui),Kr=ji(qr),ts=ji($r),es=ji(Vr),ns=ki;(Wr&&ns(new Wr(new ArrayBuffer(1)))!=Zr||Ui&&ns(new Ui)!=Yr||qr&&ns(qr.resolve())!=Hr||$r&&ns(new $r)!=Gr||Vr&&ns(new Vr)!=Xr)&&(ns=function(t){var e=ki(t),n="[object Object]"==e?t.constructor:void 0,i=n?ji(n):"";if(i)switch(i){case Jr:return Zr;case Qr:return Yr;case Kr:return Hr;case ts:return Gr;case es:return Xr}return e});var is="[object Arguments]",rs="[object Array]",ss="[object Object]",os=Object.prototype.hasOwnProperty;function as(t,e,n,i,r,s){var o=rr(t),a=rr(e),c=o?rs:ns(t),h=a?rs:ns(e),l=(c=c==is?ss:c)==ss,u=(h=h==is?ss:h)==ss,d=c==h;if(d&&br(t)){if(!br(e))return!1;o=!0,l=!1}if(d&&!l)return s||(s=new Gi),o||Ir(t)?Ji(t,e,n,i,r,s):function(t,e,n,i,r,s,o){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new Qi(t),new Qi(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ui(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ki;case"[object Set]":var c=1&i;if(a||(a=tr),t.size!=e.size&&!c)return!1;var h=o.get(t);if(h)return h==e;i|=2,o.set(t,e);var l=Ji(a(t),a(e),i,r,s,o);return o.delete(t),l;case"[object Symbol]":if(nr)return nr.call(t)==nr.call(e)}return!1}(t,e,c,n,i,r,s);if(!(1&n)){var p=l&&os.call(t,"__wrapped__"),f=u&&os.call(e,"__wrapped__");if(p||f){var m=p?t.value():t,y=f?e.value():e;return s||(s=new Gi),r(m,y,n,i,s)}}return!!d&&(s||(s=new Gi),function(t,e,n,i,r,s){var o=1&n,a=Br(t),c=a.length;if(c!=Br(e).length&&!o)return!1;for(var h=c;h--;){var l=a[h];if(!(o?l in e:Ur.call(e,l)))return!1}var u=s.get(t),d=s.get(e);if(u&&d)return u==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++h<c;){var m=t[l=a[h]],y=e[l];if(i)var g=o?i(y,m,l,e,t,s):i(m,y,l,t,e,s);if(!(void 0===g?m===y||r(m,y,n,i,s):g)){p=!1;break}f||(f="constructor"==l)}if(p&&!f){var b=t.constructor,v=e.constructor;b==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof v&&v instanceof v||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,i,r,s))}function cs(t,e,n,i,r){return t===e||(null==t||null==e||!hr(t)&&!hr(e)?t!=t&&e!=e:as(t,e,n,i,cs,r))}function hs(t,e){for(var n=-1,i=null==t?0:t.length;++n<i&&!1!==e(t[n],n,t););return t}var ls=function(){try{var t=Bi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function us(t,e,n){"__proto__"==e&&ls?ls(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var ds=Object.prototype.hasOwnProperty;function ps(t,e,n){var i=t[e];ds.call(t,e)&&ui(i,n)&&(void 0!==n||e in t)||us(t,e,n)}function fs(t,e,n,i){var r=!n;n||(n={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=i?i(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),r?us(n,a,c):ps(n,a,c)}return n}function ms(t){return t}function ys(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var gs=Math.max;function bs(t){return function(){return t}}var vs=ls?function(t,e){return ls(t,"toString",{configurable:!0,enumerable:!1,value:bs(e),writable:!0})}:ms,xs=Date.now;var ws,_s,Ms,Ss=(ws=vs,_s=0,Ms=0,function(){var t=xs(),e=16-(t-Ms);if(Ms=t,e>0){if(++_s>=800)return arguments[0]}else _s=0;return ws.apply(void 0,arguments)});function ks(t,e){return Ss(function(t,e,n){return e=gs(void 0===e?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=gs(i.length-e,0),o=Array(s);++r<s;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=n(o),ys(t,this,a)}}(t,e,ms),t+"")}function As(t,e,n){if(!Ai(n))return!1;var i=typeof e;return!!("number"==i?Nr(n)&&xr(e,n.length):"string"==i&&e in n)&&ui(n[e],t)}var zs,Ts=(zs=function(t,e,n,i){fs(e,Lr(e),t,i)},ks(function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(r=zs.length>3&&"function"==typeof r?(i--,r):void 0,s&&As(e[0],e[1],s)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var o=e[n];o&&zs(t,o,n,r)}return t})),Is=Cr(Object.getPrototypeOf,Object),Os=Function.prototype,Es=Object.prototype,js=Os.toString,Ps=Es.hasOwnProperty,Cs=js.call(Object);function Rs(t){if(!hr(t))return!1;var e=ki(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!hr(t)||"[object Object]"!=ki(t))return!1;var e=Is(t);if(null===e)return!0;var n=Ps.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&js.call(n)==Cs}(t)}var Fs=ks(function(t,e){try{return ys(t,void 0,e)}catch(t){return Rs(t)?t:new Error(t)}});function Ds(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r}var Ns=Object.prototype,Ls=Ns.hasOwnProperty;function Bs(t,e,n,i){return void 0===t||ui(t,Ns[n])&&!Ls.call(i,n)?e:t}var Us={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function Ws(t){return"\\"+Us[t]}var qs=/<%=([\s\S]+?)%>/g;var $s,Vs=($s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},function(t){return null==$s?void 0:$s[t]});function Ys(t){return"symbol"==typeof t||hr(t)&&"[object Symbol]"==ki(t)}var Hs=bi?bi.prototype:void 0,Gs=Hs?Hs.toString:void 0;function Xs(t){if("string"==typeof t)return t;if(rr(t))return Ds(t,Xs)+"";if(Ys(t))return Gs?Gs.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Zs(t){return null==t?"":Xs(t)}var Js=/[&<>"']/g,Qs=RegExp(Js.source);var Ks={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:qs,variable:"",imports:{_:{escape:function(t){return(t=Zs(t))&&Qs.test(t)?t.replace(Js,Vs):t}}}},to=/\b__p \+= '';/g,eo=/\b(__p \+=) '' \+/g,no=/(__e\(.*?\)|\b__t\)) \+\n'';/g,io=/[()=,{}\[\]\/\s]/,ro=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,so=/($^)/,oo=/['\n\r\u2028\u2029\\]/g,ao=Object.prototype.hasOwnProperty;var co=Object.prototype.hasOwnProperty;function ho(t){if(!Ai(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=Pr(t),n=[];for(var i in t)("constructor"!=i||!e&&co.call(t,i))&&n.push(i);return n}function lo(t,e){return t&&fs(e,function(t){return Nr(t)?Er(t,!0):ho(t)}(e),t)}var uo="object"==typeof exports&&exports&&!exports.nodeType&&exports,po=uo&&"object"==typeof module&&module&&!module.nodeType&&module,fo=po&&po.exports===uo?gi.Buffer:void 0,mo=fo?fo.allocUnsafe:void 0;var yo=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ir(e,cr(t)),t=Is(t);return e}:sr;var go=Object.prototype.hasOwnProperty;var bo=/\w*$/;var vo=bi?bi.prototype:void 0,xo=vo?vo.valueOf:void 0;function wo(t,e,n){var i,r,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new Qi(a).set(new Qi(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(r=t).buffer,new r.constructor(s,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,bo.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return i=t,xo?Object(xo.call(i)):{}}}var _o=Object.create,Mo=function(){function t(){}return function(e){if(!Ai(e))return{};if(_o)return _o(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var So=zr&&zr.isMap,ko=So?Mr(So):function(t){return hr(t)&&"[object Map]"==ns(t)};var Ao=zr&&zr.isSet,zo=Ao?Mr(Ao):function(t){return hr(t)&&"[object Set]"==ns(t)},To="[object Arguments]",Io="[object Function]",Oo="[object Object]",Eo={};function jo(t,e,n,i,r,s){var o,a=2&e;if(void 0!==o)return o;if(!Ai(t))return t;var c=rr(t);if(c)return o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&go.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}(t,o);var h=ns(t),l=h==Io||"[object GeneratorFunction]"==h;if(br(t))return function(t){var e=t.length,n=mo?mo(e):new t.constructor(e);return t.copy(n),n}(t);if(h==Oo||h==To||l&&!r)return o=l?{}:function(t){return"function"!=typeof t.constructor||Pr(t)?{}:Mo(Is(t))}(t),a?function(t,e){return fs(t,yo(t),e)}(t,lo(o,t)):function(t,e){return fs(t,cr(t),e)}(t,function(t,e){return t&&fs(e,Lr(e),t)}(o,t));if(!Eo[h])return r?t:{};o=wo(t,h),s||(s=new Gi);var u=s.get(t);if(u)return u;s.set(t,o),zo(t)?t.forEach(function(i){o.add(jo(i,e,n,i,t,s))}):ko(t)&&t.forEach(function(i,r){o.set(r,jo(i,e,n,r,t,s))});var d=c?void 0:Br(t);return hs(d||t,function(i,r){d&&(i=t[r=i]),ps(o,r,jo(i,e,n,r,t,s))}),o}Eo[To]=Eo["[object Array]"]=Eo["[object ArrayBuffer]"]=Eo["[object DataView]"]=Eo["[object Boolean]"]=Eo["[object Date]"]=Eo["[object Float32Array]"]=Eo["[object Float64Array]"]=Eo["[object Int8Array]"]=Eo["[object Int16Array]"]=Eo["[object Int32Array]"]=Eo["[object Map]"]=Eo["[object Number]"]=Eo[Oo]=Eo["[object RegExp]"]=Eo["[object Set]"]=Eo["[object String]"]=Eo["[object Symbol]"]=Eo["[object Uint8Array]"]=Eo["[object Uint8ClampedArray]"]=Eo["[object Uint16Array]"]=Eo["[object Uint32Array]"]=!0,Eo["[object Error]"]=Eo[Io]=Eo["[object WeakMap]"]=!1;function Po(t){return jo(t,4)}var Co=/\s/;var Ro=/^\s+/;function Fo(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&Co.test(t.charAt(e)););return e}(t)+1).replace(Ro,""):t}var Do=/^[-+]0x[0-9a-f]+$/i,No=/^0b[01]+$/i,Lo=/^0o[0-7]+$/i,Bo=parseInt;var Uo=1/0;function Wo(t){return t?(t=function(t){if("number"==typeof t)return t;if(Ys(t))return NaN;if(Ai(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ai(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Fo(t);var n=No.test(t);return n||Lo.test(t)?Bo(t.slice(2),n?2:8):Do.test(t)?NaN:+t}(t))===Uo||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function qo(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=Wo(t),n=e%1;return e==e?n?e-n:e:0}(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}var $o=Object.prototype.hasOwnProperty;function Vo(t){if(null==t)return!0;if(Nr(t)&&(rr(t)||"string"==typeof t||"function"==typeof t.splice||br(t)||Ir(t)||fr(t)))return!t.length;var e=ns(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Pr(t))return!Dr(t).length;for(var n in t)if($o.call(t,n))return!1;return!0}let Yo=0;function Ho(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function Go(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function Xo(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Zo(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function Jo(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Qo(t){if(this.__collection__)return this.__collection__[t]}function Ko(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function ta(t){return this.__collection__?this.__collection__.indexOf(t):-1}function ea(){return this.__collection__?this.__collection__.length:0}function na(){this.__collection__=[]}function ia(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function ra(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function sa(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,i)}function oa(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=n.concat(i,this.__collection__)}class aa{constructor(){this.__collection__=[],this.insertAt=Go,this.append=Xo,this.prepend=Zo,this.remove=Jo,this.getAt=Qo,this.forEach=Ko,this.indexOf=ta,this.size=ea,this.clear=na,this.moveForward=ia,this.moveBackward=ra,this.moveToHead=sa,this.moveToTail=oa}}const ca=/\s+/;function ha(t,e,n,i){if(!n)return!0;if("object"==typeof n){for(const i in n){const r=n[i];t[e].apply(t,[i,r])}return!1}if(ca.test(n)){return n.split(ca).forEach(n=>t[e].apply(t,[n].concat(i))),!1}return!0}const la=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],ua={withEvent(){la.forEach(t=>this[t]=ua[t])},on(t,e,n){if(!ha(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!ha(this,"once",t,[e,n])||!e)return this;const i=this,r=function(t){return qo(2,t)}(function(){i.off(t,r,n),e.apply(i,arguments)});return r._callback=e,this.on(t,r,n),this},off(t,e,n){if(!this._listeners||!ha(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let i;i=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<i.length;t++){const r=i[t],s=this._listeners?.[r];if(s){const t=[];if(this._listeners[r]=t,e||n)for(let i=0;i<s.length;i++){const r=s[i];(e&&e!==r.callback&&e!==r.callback._callback||n&&n!==r.context)&&t.push(r)}t.length||delete this._listeners[r]}}return this},delegate_on(t){return this._delegators||(this._delegators=new aa),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&pa(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],i=this._listeners["(all)"];return n&&da(n,arguments),i&&da(i,arguments),this},trigger(t){gn.enabled&&gn.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&pa(this._delegators,e),!this._listeners)return this;if(!ha(this,"trigger",t,e))return this;const n=this._listeners[t],i=this._listeners["(all)"];return n&&da(n,e),i&&da(i,e),this},stopListening(t,e,n){let i=this._listeningTo;if(!i)return this;const r=!e&&!n;n||"object"!=typeof e||(n=this),t&&(i={},i[t._listenId]=t);for(const t in i){const s=i[t];s.off(e,n,this),(r||Vo(s._events))&&delete this._listeningTo[t]}return this}};function da(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function pa(t,e){t.forEach(t=>ua.delegate.apply(t,e))}const fa={listenTo:"on",listenToOnce:"once"};for(const t in fa){const e=fa[t];ua[t]=function(t,n,i){this._listeningTo||(this._listeningTo={});const r=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++Yo}`);return r[t._listenId]=t,i||"object"!=typeof n||(i=this),t[e](n,i,this),this}}const ma=ua.on,ya=ua.off,ga=ua.once,ba=ua.trigger,va=ua.delegate_on,xa=ua.delegate_off;const wa=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))},_a=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))};function Ma(t,e,n){const i=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!i?.get)return void wa(`${String(e)} is not defined in ${t.constructor.name}`);const r=i.get,s={get:n?function(){return e in this.__cache__?gn.enabled&&gn.cacheHit++:(gn.enabled&&gn.cacheMiss++,this.__cache__[e]=Object.freeze(r.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?gn.enabled&&gn.cacheHit++:(gn.enabled&&gn.cacheMiss++,this.__cache__[e]=r.call(this)),this.__cache__[e]},configurable:!0};i.set&&(s.set=i.set),Object.defineProperty(t,e,s)}var Sa="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ka(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Aa(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var za,Ta={exports:{}};var Ia=(za||(za=1,function(t){var e=function(t){var e,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function h(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,n){return t[e]=n}}function l(t,e,n,i){var s=e&&e.prototype instanceof g?e:g,o=Object.create(s.prototype),a=new O(i||[]);return r(o,"_invoke",{value:A(t,n,a)}),o}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",y={};function g(){}function b(){}function v(){}var x={};h(x,o,function(){return this});var w=Object.getPrototypeOf,_=w&&w(w(E([])));_&&_!==n&&i.call(_,o)&&(x=_);var M=v.prototype=g.prototype=Object.create(x);function S(t){["next","throw","return"].forEach(function(e){h(t,e,function(t){return this._invoke(e,t)})})}function k(t,e){function n(r,s,o,a){var c=u(t[r],t,s);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==typeof l&&i.call(l,"__await")?e.resolve(l.__await).then(function(t){n("next",t,o,a)},function(t){n("throw",t,o,a)}):e.resolve(l).then(function(t){h.value=t,o(h)},function(t){return n("throw",t,o,a)})}a(c.arg)}var s;r(this,"_invoke",{value:function(t,i){function r(){return new e(function(e,r){n(t,i,e,r)})}return s=s?s.then(r,r):r()}})}function A(t,n,i){var r=d;return function(s,o){if(r===f)throw new Error("Generator is already running");if(r===m){if("throw"===s)throw o;return{value:e,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=z(a,i);if(c){if(c===y)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===d)throw r=m,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=f;var h=u(t,n,i);if("normal"===h.type){if(r=i.done?m:p,h.arg===y)continue;return{value:h.arg,done:i.done}}"throw"===h.type&&(r=m,i.method="throw",i.arg=h.arg)}}}function z(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,z(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),y;var s=u(r,t.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,y;var o=s.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function E(t){if(null!=t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,s=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=v,r(M,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:b,configurable:!0}),b.displayName=h(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,h(t,c,"GeneratorFunction")),t.prototype=Object.create(M),t},t.awrap=function(t){return{__await:t}},S(k.prototype),h(k.prototype,a,function(){return this}),t.AsyncIterator=k,t.async=function(e,n,i,r,s){void 0===s&&(s=Promise);var o=new k(l(e,n,i,r),s);return t.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},S(M),h(M,c,"Generator"),h(M,o,function(){return this}),h(M,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},t.values=E,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=i.call(o,"catchLoc"),h=i.call(o,"finallyLoc");if(c&&h){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,y):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),I(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;I(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:E(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],i=0,r="",s=0,o=arguments.length;s!==o;++s){var a=+arguments[s];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?i=n.push(a):(a-=65536,i=n.push(55296+(a>>10),a%1024+56320)),i>=16383&&(r+=t.apply(null,n),n.length=0)}return r+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
7
- /*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,s=e.charCodeAt(i);return s>=55296&&s<=56319&&n>i+1&&(r=e.charCodeAt(i+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,i){function r(o,a){if(!n[o]){if(!e[o]){if(!a&&Aa)return Aa(o);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[o]={exports:{}};e[o][0].call(h.exports,function(t){return r(e[o][1][t]||t)},h,h.exports,t,e,n,i)}return n[o].exports}for(var s=Aa,o=0;o<i.length;o++)r(i[o]);return r}return t}()({1:[function(t,e,n){var i=t("./utils"),r=function(){var t=i.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],r=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],s=["Thousand","Million","Billion","Trillion"];function o(t,i){var o=function(t,i,a){var c="";if(t<=19)c=(i?" and ":"")+(a?n[t]:e[t]);else if(t<100){var h=Math.floor(t/10),l=t%10;c=(i?" and ":"")+r[h-2],l>0?c+="-"+o(l,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(t<1e3){var u=Math.floor(t/100),d=t%100;c=(i?", ":"")+e[u]+" Hundred",d>0?c+=o(d,!0,a):a&&(c+="th")}else{var p=Math.floor(Math.log10(t)/3);p>s.length&&(p=s.length);var f=Math.pow(10,3*p),m=Math.floor(t/f),y=t-m*f;c=(i?", ":"")+o(m,!1,!1)+" "+s[p-1],y>0?c+=o(y,!0,a):a&&(c+="th")}return c};return o(t,!1,i)}var a=Object.create(null);function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];return e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)}),n.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,s.forEach(function(t,e){var n=t.toLowerCase(),i=Math.pow(10,3*(e+1));a[n]=i,a[n+"th"]=i});var h=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],l={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function u(t){for(var e=0;e<h.length;e++){var n=h[e];if(t>=n[0])return n[1]+u(t-n[0])}return""}function d(t){for(var e=0,n=1,i=t.length-1;i>=0;i--){var r=t[i],s=l[r];s<n?e-=s:(n=s,e+=s)}return e}function p(t,e){for(var n=[],i=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+i)),t=Math.floor((t-1)/26);return n.join("")}function f(t,e){for(var n=e.charCodeAt(0),i=0,r=0;r<t.length;r++)i+=(t.charCodeAt(t.length-r-1)-n+1)*Math.pow(26,r);return i}function m(t,e){if(void 0!==t)return b(t=Math.floor(t),x(e))}var y={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},g={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var i,r=e<0;switch(e=Math.abs(e),n.primary){case y.LETTERS:i=p(e,n.case===g.UPPER?"A":"a");break;case y.ROMAN:i=u(e),n.case===g.UPPER&&(i=i.toUpperCase());break;case y.WORDS:i=o(e,n.ordinal),n.case===g.UPPER?i=i.toUpperCase():n.case===g.LOWER&&(i=i.toLowerCase());break;case y.DECIMAL:i=""+e;var s=n.mandatoryDigits-i.length;if(s>0){var a=new Array(s+1).join("0");i=a+i}if(48!==n.zeroCode&&(i=t(i).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((i.length-1)/n.groupingSeparators.position);c>0;c--){var h=i.length-c*n.groupingSeparators.position;i=i.substr(0,h)+n.groupingSeparators.character+i.substr(h)}else n.groupingSeparators.reverse().forEach(function(t){var e=i.length-t.position;i=i.substr(0,e)+t.character+i.substr(e)});if(n.ordinal){var l={1:"st",2:"nd",3:"rd"}[i[i.length-1]];(!l||i.length>1&&"1"===i[i.length-2])&&(l="th"),i+=l}break;case y.SEQUENCE:throw{code:"D3130",value:n.token}}return r&&(i="-"+i),i}var v=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function x(e){var n,i={type:"integer",primary:y.DECIMAL,case:g.LOWER,ordinal:!1},r=e.lastIndexOf(";");switch(-1===r?n=e:(n=e.substring(0,r),"o"===e.substring(r+1)[0]&&(i.ordinal=!0)),n){case"A":i.case=g.UPPER;case"a":i.primary=y.LETTERS;break;case"I":i.case=g.UPPER;case"i":i.primary=y.ROMAN;break;case"W":i.case=g.UPPER,i.primary=y.WORDS;break;case"Ww":i.case=g.TITLE,i.primary=y.WORDS;break;case"w":i.primary=y.WORDS;break;default:var s=null,o=0,a=0,c=[],h=0;if(t(n).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,n=0;n<v.length;n++){var i=v[n];if(t>=i&&t<=i+9){if(e=!0,o++,h++,null===s)s=i;else if(i!==s)throw{code:"D3131"};break}}e||(35===t?(h++,a++):c.push({position:h,character:String.fromCodePoint(t)}))}),o>0){i.primary=y.DECIMAL,i.zeroCode=s,i.mandatoryDigits=o,i.optionalDigits=a;var l=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var i=t.map(function(t){return t.position}),r=function(t,e){return 0===e?t:r(e,t%e)},s=i.reduce(r),o=1;o<=i.length;o++)if(-1===i.indexOf(o*s))return 0;return s}(c);l>0?(i.regular=!0,i.groupingSeparators={position:l,character:c[0].character}):(i.regular=!1,i.groupingSeparators=c)}else i.primary=y.SEQUENCE,i.token=n}return i}var w={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function _(t){for(var e=[],n={type:"datetime",parts:e},i=function(n,i){if(i>n){var r=t.substring(n,i);r=r.split("]]").join("]"),e.push({type:"literal",value:r})}},r=0,s=0;s<t.length;){if("["===t.charAt(s)){if("["===t.charAt(s+1)){i(r,s),e.push({type:"literal",value:"["}),r=s+=2;continue}if(i(r,s),r=s,-1===(s=t.indexOf("]",r)))throw{code:"D3135"};var o,a=t.substring(r+1,s),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},h=a.lastIndexOf(",");if(-1!==h){var l=a.substring(h+1),u=l.indexOf("-"),d=void 0,p=void 0,f=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===u?d=l:(d=l.substring(0,u),p=l.substring(u+1));var m={min:f(d),max:f(p)};c.width=m,o=a.substring(1,h)}else o=a.substring(1);if(1===o.length)c.presentation1=o;else if(o.length>1){var y=o.charAt(o.length-1);-1!=="atco".indexOf(y)?(c.presentation2=y,"o"===y&&(c.ordinal=!0),c.presentation1=o.substring(0,o.length-1)):c.presentation1=o}else c.presentation1=w[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=g.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=g.TITLE:c.names=g.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=x(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var v=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;v>=2&&(c.n=v)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=x(c.presentation1)),e.push(c),r=s+1}s++}return i(r,s),n}var M=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],k=864e5,A=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*k:e-(n-1)*k},z=function(t,e){return{year:t,month:e,nextMonth:function(){return 11===e?z(t+1,0):z(t,e+1)},previousMonth:function(){return 0===e?z(t-1,11):z(t,e-1)},nextYear:function(){return z(t+1,e)},previousYear:function(){return z(t-1,e)}}},T=function(t,e){return(e-t)/(7*k)+1},I=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/k+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var i=z(t.getUTCFullYear(),0),r=A(i),s=Date.UTC(i.year,t.getUTCMonth(),t.getUTCDate()),o=T(r,s);if(o>52)s>=A(i.nextYear())&&(o=1);else if(o<1){var a=A(i.previousYear());o=T(a,s)}n=Math.floor(o);break;case"w":var c=z(t.getUTCFullYear(),t.getUTCMonth()),h=A(c),l=Date.UTC(c.year,c.month,t.getUTCDate()),u=T(h,l);if(u>4)l>=A(c.nextMonth())&&(u=1);else if(u<1){var d=A(c.previousMonth());u=T(d,l)}n=Math.floor(u);break;case"X":var p=z(t.getUTCFullYear(),0),f=A(p),m=A(p.nextYear()),y=t.getTime();n=y<f?p.year-1:y>=m?p.year+1:p.year;break;case"x":var g=z(t.getUTCFullYear(),t.getUTCMonth()),b=A(g),v=g.nextMonth(),x=A(v),w=t.getTime();n=w<b?g.previousMonth().month+1:w>=x?v.month+1:g.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},O=null;function E(t,e,n){var i=0,r=0;if(void 0!==n){var s=parseInt(n);i=Math.floor(s/100),r=s%100}var o,a=function(t,e){var n=I(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=S[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=M[n]}e.names===g.UPPER?n=n.toUpperCase():e.names===g.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var s=100*i+r;if(e.integerFormat.regular)n=b(s,e.integerFormat);else{var o=e.integerFormat.mandatoryDigits;if(1===o||2===o)n=b(i,e.integerFormat),0!==r&&(n+=":"+m(r,"00"));else{if(3!==o&&4!==o)throw{code:"D3134",value:o};n=b(s,e.integerFormat)}}s>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===s&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===O&&(O=_("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),o=O):o=_(e);var c=new Date(t+60*(60*i+r)*1e3),h="";return o.parts.forEach(function(t){"literal"===t.type?h+=t.value:h+=a(c,t)}),h}function j(t){var e=Object.create(null);if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e=Object.create(null);if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var i=0,r=0;return n?(i=Number.parseInt(e.substring(0,e.indexOf(n.character))),r=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?i=Number.parseInt(e):(i=Number.parseInt(e.substring(0,3)),r=Number.parseInt(e.substring(3))),60*i+r}}else if("f"===t.component)e.regex="[0-9]+",e.parse=function(t){return 1e3*parseFloat("0."+t.substring(0,3))};else if(t.integerFormat)t.integerFormat.n=t.n,e=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var i=Object.create(null);if("M"===t.component||"x"===t.component)S.forEach(function(e,n){t.width&&t.width.max?i[e.substring(0,t.width.max)]=n+1:i[e]=n+1});else if("F"===t.component)M.forEach(function(e,n){n>0&&(t.width&&t.width.max?i[e.substring(0,t.width.max)]=n:i[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};i={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return i[t]}}return e.component=t.component,e});else{e.type="integer";var n,r=t.case===g.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case y.LETTERS:e.regex=r?"[A-Z]+":"[a-z]+",e.parse=function(t){return f(t,r?"A":"a")};break;case y.ROMAN:e.regex=r?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return d(r?t:t.toUpperCase())};break;case y.WORDS:e.regex="(?:"+i.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case y.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case y.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function P(t,e){if(void 0!==t)return j(x(e)).parse(t)}function C(t,e){var n=j(_(e)),i="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",r=new RegExp(i,"i").exec(t);if(null!==r){for(var s=161,o=130,a=84,c=72,h=23,l=47,u=Object.create(null),d=1;d<r.length;d++){var p=n.parts[d-1];p.parse&&(u[p.component]=p.parse(r[d]))}if(0===Object.getOwnPropertyNames(u).length)return;var f=0,m=function(t){f<<=1,f+=t?1:0},y=function(t){return!(~t&f||!(t&f))};"YXMxWwdD".split("").forEach(function(t){return m(u[t])});var g=!y(s)&&y(o),b=y(a),v=!b&&y(c);f=0,"PHhmsf".split("").forEach(function(t){return m(u[t])});var x=!y(h)&&y(l),w=(g?"YD":b?"XxwF":v?"XWF":"YMD")+(x?"Phmsf":"Hmsf"),M=this.environment.timestamp,S=!1,k=!1;if(w.split("").forEach(function(t){if(void 0===u[t])S?(u[t]=-1!=="MDd".indexOf(t)?1:0,k=!0):u[t]=I(M,t);else if(S=!0,k)throw{code:"D3136"}}),u.M>0?u.M-=1:u.M=0,g){var A=Date.UTC(u.Y,0),z=1e3*(u.d-1)*60*60*24,T=new Date(A+z);u.M=T.getUTCMonth(),u.D=T.getUTCDate()}if(b)throw{code:"D3136"};if(v)throw{code:"D3136"};x&&(u.H=12===u.h?0:u.h,1===u.P&&(u.H+=12));var O=Date.UTC(u.Y,u.M,u.D,u.H,u.m,u.s,u.f);return(u.Z||u.z)&&(O-=60*(u.Z||u.z)*1e3),O}}var R=new RegExp("^\\d{4}(-[01]\\d)?(-[0-3]\\d)?(T[0-2]\\d:[0-5]\\d:[0-5]\\d)?(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function F(t,e){if(void 0!==t){if(void 0===e){if(!R.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return C.call(this,t,e)}}function D(t,e,n){if(void 0!==t)return E.call(this,t,e,n)}return{formatInteger:m,parseInteger:P,fromMillis:D,toMillis:F}}();e.exports=r},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function a(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(o(t)+" is not iterable")}function c(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,i,r,s){var c=i&&i.prototype instanceof a?i:a,l=Object.create(c.prototype);return h(l,"_invoke",function(n,i,r){var s,a,c,h=0,l=r||[],u=!1,d={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return s=e,a=0,c=t,d.n=n,o}};function p(n,i){for(a=n,c=i,e=0;!u&&h&&!r&&e<l.length;e++){var r,s=l[e],p=d.p,f=s[2];n>3?(r=f===i)&&(c=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=t):s[0]<=p&&((r=n<2&&p<s[1])?(a=0,d.v=i,d.n=s[1]):p<f&&(r=n<3||s[0]>i||i>f)&&(s[4]=n,s[5]=i,d.n=f,a=0))}if(r||n>1)return o;throw u=!0,i}return function(r,l,f){if(h>1)throw TypeError("Generator is already running");for(u&&1===l&&p(l,f),a=l,c=f;(e=a<2?t:c)||!u;){s||(a?a<3?(a>1&&(d.n=-1),p(a,c)):d.n=c:d.v=c);try{if(h=2,s){if(a||(r="next"),e=s[r]){if(!(e=e.call(s,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=s.return)&&e.call(s),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);s=t}else if((e=(u=d.n<0)?c:n.call(i,d))!==o)break}catch(e){s=t,a=1,c=e}finally{h=1}}return{value:e,done:u}}}(n,r,s),!0),l}var o={};function a(){}function l(){}function u(){}e=Object.getPrototypeOf;var d=[][i]?e(e([][i]())):(h(e={},i,function(){return this}),e),p=u.prototype=a.prototype=Object.create(d);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,h(t,r,"GeneratorFunction")),t.prototype=Object.create(p),t}return l.prototype=u,h(p,"constructor",u),h(u,"constructor",l),l.displayName="GeneratorFunction",h(u,r,"GeneratorFunction"),h(p),h(p,r,"Generator"),h(p,i,function(){return this}),h(p,"toString",function(){return"[object Generator]"}),(c=function(){return{w:s,m:f}})()}function h(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}h=function(t,e,n,i){function s(e,n){h(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(s("next",0),s("throw",1),s("return",2))},h(t,e,n,i)}var l=t("./utils"),u=function(){var t=c().m(q),e=c().m($),r=c().m(V),s=c().m(Y),h=c().m(K),u=c().m(ft),d=c().m(mt),p=c().m(yt),f=c().m(bt),m=c().m(At),y=c().m(Ot),g=c().m(Pt),b=l.isNumeric,v=l.isArrayOfStrings,x=l.isArrayOfNumbers,w=l.createSequence,_=l.isSequence,M=l.isFunction,S=l.isLambda,k=l.isIterable,A=l.getFunctionArity,z=l.isDeepEqual,T=l.stringToArray;function I(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function O(t){return void 0===t?0:t.length}function E(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function j(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function P(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function C(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(M(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var i=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&b(e)?Number(e.toPrecision(15)):e&&M(e)?"":e},i)}return n}}function R(t,e,n){if(void 0!==t){var i=T(t),r=i.length;if(r+e<0&&(e=0),void 0!==n){if(n<=0)return"";var s=e>=0?e+n:r+e+n;return i.slice(e,s).join("")}return i.slice(e).join("")}}function F(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function D(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function N(t){if(void 0!==t)return t.toLowerCase()}function L(t){if(void 0!==t)return t.toUpperCase()}function B(t){if(void 0!==t)return T(t).length}function U(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function W(t,e,n){if(void 0!==t){var i;void 0!==n&&0!==n.length||(n=" ");var r=Math.abs(e)-B(t);if(r>0){var s=new Array(r+1).join(n);n.length>1&&(s=R(s,0,r)),i=e>0?t+s:s+t}else i=t;return i}}function q(e,n){var i;return c().w(function(t){for(;;)switch(t.n){case 0:if(i=e.apply(this,[n]),!k(i)){t.n=2;break}return t.d(a(i),1);case 1:i=t.v;case 2:if(!i||"number"==typeof i.start||"number"===i.end||Array.isArray(i.groups)||M(i.next)){t.n=3;break}throw{code:"T1010",stack:(new Error).stack};case 3:return t.a(2,i)}},t,this)}function $(t,n){var i,r;return c().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof n){e.n=2;break}i=-1!==t.indexOf(n),e.n=4;break;case 2:return e.d(a(q(n,t)),3);case 3:r=e.v,i=void 0!==r;case 4:return e.a(2,i)}},e)}function V(t,e,n){var i,s,o;return c().w(function(r){for(;;)switch(r.n){case 0:if(void 0!==t){r.n=1;break}return r.a(2,void 0);case 1:if(!(n<0)){r.n=2;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 2:if(i=w(),!(void 0===n||n>0)){r.n=6;break}return s=0,r.d(a(q(e,t)),3);case 3:if(void 0===(o=r.v)){r.n=6;break}case 4:if(void 0===o||!(void 0===n||s<n)){r.n=6;break}return i.push({match:o.match,index:o.start,groups:o.groups}),r.d(a(q(o.next)),5);case 5:o=r.v,s++,r.n=4;break;case 6:return r.a(2,i)}},r)}function Y(t,e,n,i){var r,o,h,l,u,d,p,f;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:if(r=this,""!==e){s.n=2;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 2:if(!(i<0)){s.n=3;break}throw{code:"D3011",stack:(new Error).stack,value:i,index:4};case 3:if(o="string"==typeof n?function(t){for(var e="",i=0,r=n.indexOf("$",i);-1!==r&&i<n.length;){e+=n.substring(i,r),i=r+1;var s=n.charAt(i);if("$"===s)e+="$",i++;else if("0"===s)e+=t.match,i++;else{var o;if(o=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,r=parseInt(n.substring(i,i+o),10),o>1&&r>t.groups.length&&(r=parseInt(n.substring(i,i+o-1),10)),isNaN(r))e+="$";else{if(t.groups.length>0){var a=t.groups[r-1];void 0!==a&&(e+=a)}i+=r.toString().length}}r=n.indexOf("$",i)}return e+=n.substring(i)}:n,h="",l=0,!(void 0===i||i>0)){s.n=15;break}if(u=0,"string"!=typeof e){s.n=4;break}for(d=t.indexOf(e,l);-1!==d&&(void 0===i||u<i);)h+=t.substring(l,d),h+=n,l=d+e.length,u++,d=t.indexOf(e,l);h+=t.substring(l),s.n=14;break;case 4:return s.d(a(q(e,t)),5);case 5:if(void 0===(p=s.v)){s.n=13;break}case 6:if(void 0===p||!(void 0===i||u<i)){s.n=12;break}if(h+=t.substring(l,p.start),f=o.apply(r,[p]),!k(f)){s.n=8;break}return s.d(a(f),7);case 7:f=s.v;case 8:if("string"!=typeof f){s.n=9;break}h+=f,s.n=10;break;case 9:throw{code:"D3012",stack:(new Error).stack,value:f};case 10:return l=p.start+p.match.length,u++,s.d(a(q(p.next)),11);case 11:p=s.v,s.n=6;break;case 12:h+=t.substring(l),s.n=14;break;case 13:h=t;case 14:s.n=16;break;case 15:h=t;case 16:return s.a(2,h)}},s,this)}function H(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function G(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function X(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function Z(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function J(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function Q(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function K(t,e,n){var i,r,s,o;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!(n<0)){c.n=2;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 2:if(i=[],!(void 0===n||n>0)){c.n=9;break}if("string"!=typeof e){c.n=3;break}i=t.split(e,n),c.n=9;break;case 3:return r=0,c.d(a(q(e,t)),4);case 4:if(void 0===(s=c.v)){c.n=8;break}o=0;case 5:if(void 0===s||!(void 0===n||r<n)){c.n=7;break}return i.push(t.substring(o,s.start)),o=s.end,c.d(a(q(s.next)),6);case 6:s=c.v,r++,c.n=5;break;case 7:(void 0===n||r<n)&&i.push(t.substring(o)),c.n=9;break;case 8:i.push(t);case 9:return c.a(2,i)}},h)}function tt(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function et(t,e,n){if(void 0!==t){var i={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&l.keys(n).forEach(function(t){i[t]=n[t]});for(var r=[],s=i["zero-digit"].charCodeAt(0),o=s;o<s+10;o++)r.push(String.fromCharCode(o));var a=r.concat([i["decimal-separator"],i["exponent-separator"],i["grouping-separator"],i.digit,i["pattern-separator"]]),c=e.split(i["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var h=function(t){var e,n,r,s,o=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(n+1)}(),h=t.substring(o.length,t.length-c.length),l=t.indexOf(i["exponent-separator"],o.length);-1===l||l>t.length-c.length?(e=h,n=void 0):(e=h.substring(0,l),n=h.substring(l+1));var u=e.indexOf(i["decimal-separator"]);return-1===u?(r=e,s=c):(r=e.substring(0,u),s=e.substring(u+1)),{prefix:o,suffix:c,activePart:h,mantissaPart:e,exponentPart:n,integerPart:r,fractionalPart:s,subpicture:t}},u=function(t){var e,n,s=t.subpicture,o=s.indexOf(i["decimal-separator"]);o!==s.lastIndexOf(i["decimal-separator"])&&(e="D3081"),s.indexOf(i.percent)!==s.lastIndexOf(i.percent)&&(e="D3082"),s.indexOf(i["per-mille"])!==s.lastIndexOf(i["per-mille"])&&(e="D3083"),-1!==s.indexOf(i.percent)&&-1!==s.indexOf(i["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var h=t.mantissaPart.charAt(n);if(-1!==r.indexOf(h)||h===i.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==o?s.charAt(o-1)!==i["grouping-separator"]&&s.charAt(o+1)!==i["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===i["grouping-separator"]&&(e="D3088"),-1!==s.indexOf(i["grouping-separator"]+i["grouping-separator"])&&(e="D3089");var l=t.integerPart.indexOf(i.digit);-1!==l&&t.integerPart.substring(0,l).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(l=t.fractionalPart.lastIndexOf(i.digit))&&t.fractionalPart.substring(l).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3091");var u="string"==typeof t.exponentPart;if(u&&t.exponentPart.length>0&&(-1!==s.indexOf(i.percent)||-1!==s.indexOf(i["per-mille"]))&&(e="D3092"),u&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===r.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},d=function(t){var e=function(e,n){for(var s=[],o=e.indexOf(i["grouping-separator"]);-1!==o;){var a=(n?e.substring(0,o):e.substring(o)).split("").filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length;s.push(a),o=t.integerPart.indexOf(i["grouping-separator"],o+1)}return s},n=e(t.integerPart),s=function(t){if(0===t.length)return 0;for(var e=function(t,n){return 0===n?t:e(n,t%n)},n=t.reduce(e),i=1;i<=t.length;i++)if(-1===t.indexOf(i*n))return 0;return n}(n),o=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length,c=a,h=t.fractionalPart.split(""),l=h.filter(function(t){return-1!==r.indexOf(t)}).length,u=h.filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length,d="string"==typeof t.exponentPart;0===a&&0===u&&(d?(l=1,u=1):a=1),d&&0===a&&-1!==t.integerPart.indexOf(i.digit)&&(a=1),0===a&&0===l&&(l=1);var p=0;return d&&(p=t.exponentPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:s,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:o,minimumFactionalPartSize:l,maximumFactionalPartSize:u,minimumExponentSize:p,suffix:t.suffix,picture:t.subpicture}},p=c.map(h);p.forEach(u);var f,m,y,g,b=p.map(d),v=i["minus-sign"],x=i["zero-digit"],w=i["decimal-separator"],_=i["grouping-separator"];if(1===b.length&&(b.push(JSON.parse(JSON.stringify(b[0]))),b[1].prefix=v+b[1].prefix),m=-1!==(f=t>=0?b[0]:b[1]).picture.indexOf(i.percent)?100*t:-1!==f.picture.indexOf(i["per-mille"])?1e3*t:t,0===f.minimumExponentSize)y=m;else{var M=Math.pow(10,f.scalingFactor),S=Math.pow(10,f.scalingFactor-1);for(y=m,g=0;y<S;)y*=10,g-=1;for(;y>M;)y/=10,g+=1}var k=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==x&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?r[t.charCodeAt(0)-48]:t}).join("")),n},A=k(at(y,f.maximumFactionalPartSize),f.maximumFactionalPartSize),z=A.indexOf(".");for(-1===z?A+=w:A=A.replace(".",w);A.charAt(0)===x;)A=A.substring(1);for(;A.charAt(A.length-1)===x;)A=A.substring(0,A.length-1);z=A.indexOf(w);var T=f.minimumIntegerPartSize-z,I=f.minimumFactionalPartSize-(A.length-z-1);if(A=(T>0?new Array(T+1).join(x):"")+A,A+=I>0?new Array(I+1).join(x):"",z=A.indexOf(w),f.regularGrouping>0)for(var O=Math.floor((z-1)/f.regularGrouping),E=1;E<=O;E++)A=[A.slice(0,z-E*f.regularGrouping),_,A.slice(z-E*f.regularGrouping)].join("");else f.integerPartGroupingPositions.forEach(function(t){A=[A.slice(0,z-t),_,A.slice(z-t)].join(""),z++});if(z=A.indexOf(w),f.fractionalPartGroupingPositions.forEach(function(t){A=[A.slice(0,t+z+1),_,A.slice(t+z+1)].join("")}),z=A.indexOf(w),-1!==f.picture.indexOf(w)&&z!==A.length-1||(A=A.substring(0,A.length-1)),void 0!==g){var j=k(g,0);(T=f.minimumExponentSize-j.length)>0&&(j=new Array(T+1).join(x)+j),A=A+i["exponent-separator"]+(g<0?v:"")+j}return A=f.prefix+A+f.suffix}}function nt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function it(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function rt(t){if(void 0!==t)return Math.abs(t)}function st(t){if(void 0!==t)return Math.floor(t)}function ot(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var n;if(void 0!==t){if(e){var i=t.toString().split("e");t=+(i[0]+"e"+(i[1]?+i[1]+e:e))}var r=(n=Math.round(t))-t;return.5===Math.abs(r)&&1===Math.abs(n%2)&&(n-=1),e&&(i=n.toString().split("e"),n=+(i[0]+"e"+(i[1]?+i[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ct(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ht(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function lt(){return Math.random()}function ut(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ut(t[0]):t.length>1&&(e=t.filter(function(t){return ut(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):b(t)?0!==t&&(e=!0):null!==t&&"object"===o(t)?l.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function dt(t){if(void 0!==t)return!ut(t)}function pt(t,e,n,i){var r=[e],s=A(t);return s>=2&&r.push(n),s>=3&&r.push(i),r}function ft(t,e){var n,i,r,s;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:n=w(),i=0;case 2:if(!(i<t.length)){o.n=5;break}return r=pt(e,t[i],i,t),o.d(a(e.apply(this,r)),3);case 3:void 0!==(s=o.v)&&n.push(s);case 4:i++,o.n=2;break;case 5:return o.a(2,n)}},u,this)}function mt(t,e){var n,i,r,s;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:n=w(),i=0;case 2:if(!(i<t.length)){o.n=5;break}return r=t[i],s=pt(e,r,i,t),o.d(a(e.apply(this,s)),3);case 3:ut(o.v)&&n.push(r);case 4:i++,o.n=2;break;case 5:return o.a(2,n)}},d,this)}function yt(t,e){var n,i,r,s,o,h,l;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:n=!1,r=0;case 2:if(!(r<t.length)){c.n=7;break}if(s=t[r],o=!0,void 0===e){c.n=4;break}return h=pt(e,s,r,t),c.d(a(e.apply(this,h)),3);case 3:l=c.v,o=ut(l);case 4:if(!o){c.n=6;break}if(n){c.n=5;break}i=s,n=!0,c.n=6;break;case 5:throw{stack:(new Error).stack,code:"D3138",index:r};case 6:r++,c.n=2;break;case 7:if(n){c.n=8;break}throw{stack:(new Error).stack,code:"D3139"};case 8:return c.a(2,i)}},p,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),i=0;i<n;i++){var r=e.map(function(t){return t[i]});t.push(r)}return t}function bt(t,e,n){var i,r,s,o;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!((r=A(e))<2)){c.n=2;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 2:void 0===n&&t.length>0?(i=t[0],s=1):(i=n,s=0);case 3:if(!(s<t.length)){c.n=5;break}return o=[i,t[s]],r>=3&&o.push(s),r>=4&&o.push(t),c.d(a(e.apply(this,o)),4);case 4:i=c.v,s++,c.n=3;break;case 5:return c.a(2,i)}},f,this)}function vt(t){var e=w();if(Array.isArray(t)){var n=Object.create(null);t.forEach(function(t){vt(t).forEach(function(t){n[t]=!0})}),e=vt(n)}else null===t||"object"!==o(t)||S(t)||l.keys(t).forEach(function(t){return e.push(t)});return e}function xt(t,e){var n;if(Array.isArray(t)){n=w();for(var i=0;i<t.length;i++){var r=xt(t[i],e);void 0!==r&&(Array.isArray(r)?r.forEach(function(t){return n.push(t)}):n.push(r))}}else null!==t&&"object"===o(t)&&Object.prototype.hasOwnProperty.call(t,e)&&!M(t)&&(n=t[e]);return n}function wt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=w(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function _t(t){return void 0!==t}function Mt(t){var e=w();if(Array.isArray(t))t.forEach(function(t){e=wt(e,Mt(t))});else if(null===t||"object"!==o(t)||S(t))e=t;else{var n,r=i(l.keys(t));try{for(r.s();!(n=r.n()).done;){var s=n.value,a=Object.create(null);a[s]=t[s],e.push(a)}}catch(t){r.e(t)}finally{r.f()}}return e}function St(t){if(void 0!==t){var e=Object.create(null);return t.forEach(function(t){var n,r=i(l.keys(t));try{for(r.s();!(n=r.n()).done;){var s=n.value;e[s]=t[s]}}catch(t){r.e(t)}finally{r.f()}}),e}}function kt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),i=0;i<e;i++)n[e-i-1]=t[i];return n}}function At(t,e){var n,r,s,o,h,u,d;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=w(),r=i(l.keys(t)),c.p=1,r.s();case 2:if((s=r.n()).done){c.n=5;break}return o=s.value,h=pt(e,t[o],o,t),c.d(a(e.apply(this,h)),3);case 3:void 0!==(u=c.v)&&n.push(u);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,d=c.v,r.e(d);case 7:return c.p=7,r.f(),c.f(7);case 8:return c.a(2,n)}},m,this,[[1,6,7,8]])}function zt(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function Tt(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function It(t){if(void 0!==t)return null===t?"null":b(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":M(t)?"function":"object"}function Ot(t,e){var n,i,r,s;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:if(!(t.length<=1)){o.n=2;break}return o.a(2,t);case 2:if(void 0!==e){o.n=4;break}if(x(t)||v(t)){o.n=3;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 3:n=c().m(function t(e,n){return c().w(function(t){for(;;)if(0===t.n)return t.a(2,e>n)},t)}),o.n=5;break;case 4:n=e;case 5:return i=c().m(function t(e,i){var r,s;return c().w(function(t){for(;;)switch(t.n){case 0:return r=c().m(function t(e,i,s){return c().w(function(t){for(;;)switch(t.n){case 0:if(0!==i.length){t.n=1;break}Array.prototype.push.apply(e,s),t.n=6;break;case 1:if(0!==s.length){t.n=2;break}Array.prototype.push.apply(e,i),t.n=6;break;case 2:return t.d(a(n(i[0],s[0])),3);case 3:if(!t.v){t.n=5;break}return e.push(s[0]),t.d(a(r(e,i,s.slice(1))),4);case 4:t.n=6;break;case 5:return e.push(i[0]),t.d(a(r(e,i.slice(1),s)),6);case 6:return t.a(2)}},t)}),s=[],t.d(a(r(s,e,i)),1);case 1:return t.a(2,s)}},t)}),r=c().m(function t(e){var n,s,o;return c().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(e)&&!(e.length<=1)){t.n=1;break}return t.a(2,e);case 1:return n=Math.floor(e.length/2),s=e.slice(0,n),o=e.slice(n),t.d(a(r(s)),2);case 2:return s=t.v,t.d(a(r(o)),3);case 3:return o=t.v,t.d(a(i(s,o)),4);case 4:return t.a(2,t.v);case 5:return t.a(2)}},t)}),o.d(a(r(t)),6);case 6:return s=o.v,o.a(2,s)}},y)}function Et(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var i=Math.floor(Math.random()*(n+1));n!==i&&(e[n]=e[i]),e[i]=t[n]}return e}}function jt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=_(t)?w():[],n=0;n<t.length;n++){for(var i=t[n],r=!1,s=0;s<e.length;s++)if(z(i,e[s])){r=!0;break}r||e.push(i)}return e}}function Pt(t,e){var n,r,s,o,h,u,d;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=Object.create(null),r=i(l.keys(t)),c.p=1,r.s();case 2:if((s=r.n()).done){c.n=5;break}return o=s.value,h=t[o],u=pt(e,h,o,t),c.d(a(e.apply(this,u)),3);case 3:ut(c.v)&&(n[o]=h);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,d=c.v,r.e(d);case 7:return c.p=7,r.f(),c.f(7);case 8:return 0===l.keys(n).length&&(n=void 0),c.a(2,n)}},g,this,[[1,6,7,8]])}return{sum:I,count:O,max:E,min:j,average:P,string:C,substring:R,substringBefore:F,substringAfter:D,lowercase:N,uppercase:L,length:B,trim:U,pad:W,match:V,contains:$,replace:Y,split:K,join:tt,formatNumber:et,formatBase:nt,number:it,floor:st,ceil:ot,round:at,abs:rt,sqrt:ct,power:ht,random:lt,boolean:ut,not:dt,map:ft,zip:gt,filter:mt,single:yt,foldLeft:bt,sift:Pt,keys:vt,lookup:xt,append:wt,exists:_t,spread:Mt,merge:St,reverse:kt,each:At,error:zt,assert:Tt,type:It,sort:Ot,shuffle:Et,distinct:jt,base64encode:H,base64decode:G,encodeUrlComponent:X,encodeUrl:Z,decodeUrlComponent:J,decodeUrl:Q}}();e.exports=u}).call(this)}).call(this,void 0!==Sa?Sa:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function i(t){var e=Object(t),n=[];for(var i in e)n.unshift(i);return function t(){for(;n.length;)if((i=n.pop())in e)return t.value=i,t.done=!1,t;return t.done=!0,t}}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function s(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=o(t))||e){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function c(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(r(t)+" is not iterable")}function h(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,i,r,s){var c=i&&i.prototype instanceof a?i:a,h=Object.create(c.prototype);return l(h,"_invoke",function(n,i,r){var s,a,c,h=0,l=r||[],u=!1,d={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return s=e,a=0,c=t,d.n=n,o}};function p(n,i){for(a=n,c=i,e=0;!u&&h&&!r&&e<l.length;e++){var r,s=l[e],p=d.p,f=s[2];n>3?(r=f===i)&&(c=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=t):s[0]<=p&&((r=n<2&&p<s[1])?(a=0,d.v=i,d.n=s[1]):p<f&&(r=n<3||s[0]>i||i>f)&&(s[4]=n,s[5]=i,d.n=f,a=0))}if(r||n>1)return o;throw u=!0,i}return function(r,l,f){if(h>1)throw TypeError("Generator is already running");for(u&&1===l&&p(l,f),a=l,c=f;(e=a<2?t:c)||!u;){s||(a?a<3?(a>1&&(d.n=-1),p(a,c)):d.n=c:d.v=c);try{if(h=2,s){if(a||(r="next"),e=s[r]){if(!(e=e.call(s,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=s.return)&&e.call(s),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);s=t}else if((e=(u=d.n<0)?c:n.call(i,d))!==o)break}catch(e){s=t,a=1,c=e}finally{h=1}}return{value:e,done:u}}}(n,r,s),!0),h}var o={};function a(){}function c(){}function u(){}e=Object.getPrototypeOf;var d=[][i]?e(e([][i]())):(l(e={},i,function(){return this}),e),p=u.prototype=a.prototype=Object.create(d);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,l(t,r,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=u,l(p,"constructor",u),l(u,"constructor",c),c.displayName="GeneratorFunction",l(u,r,"GeneratorFunction"),l(p),l(p,r,"Generator"),l(p,i,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(h=function(){return{w:s,m:f}})()}function l(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}l=function(t,e,n,i){function s(e,n){l(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(s("next",0),s("throw",1),s("return",2))},l(t,e,n,i)}var u=t("./datetime"),d=t("./functions"),p=t("./utils"),f=t("./parser"),m=t("./signature"),y=function(){var t=h().m(q),e=h().m($),n=h().m(Y),o=h().m(H),a=h().m(G),l=h().m(X),y=h().m(Z),g=h().m(J),b=h().m(ct),v=h().m(ut),x=h().m(ft),w=h().m(mt),_=h().m(yt),M=h().m(vt),S=h().m(_t),k=h().m(Mt),A=h().m(St),z=h().m(kt),T=h().m(zt),I=h().m(It),O=h().m(jt),E=h().m(Rt),j=p.isNumeric,P=p.isArrayOfStrings,C=p.isArrayOfNumbers,R=p.createSequence,F=p.isSequence,D=p.isFunction,N=p.isLambda,L=p.isIterable,B=p.getFunctionArity,U=p.isDeepEqual,W=Dt(null);function q(e,n,i){var r,s,o,a,l;return h().w(function(t){for(;;)switch(t.n){case 0:(s=i.lookup("__evaluate_entry"))&&s(e,n,i),l=e.type,t.n="path"===l?1:"binary"===l?3:"unary"===l?5:"name"===l?7:"string"===l||"number"===l||"value"===l?8:"wildcard"===l?9:"descendant"===l?10:"parent"===l?11:"condition"===l?12:"block"===l?14:"bind"===l?16:"regex"===l?18:"function"===l?19:"variable"===l?21:"lambda"===l?22:"partial"===l?23:"apply"===l?25:"transform"===l?27:28;break;case 1:return t.d(c($(e,n,i)),2);case 2:return r=t.v,t.a(3,28);case 3:return t.d(c(Z(e,n,i)),4);case 4:return r=t.v,t.a(3,28);case 5:return t.d(c(J(e,n,i)),6);case 6:return r=t.v,t.a(3,28);case 7:return r=Q(e,n),t.a(3,28);case 8:return r=K(e),t.a(3,28);case 9:return r=tt(e,n),t.a(3,28);case 10:return r=nt(e,n),t.a(3,28);case 11:return r=i.lookup(e.slot.label),t.a(3,28);case 12:return t.d(c(mt(e,n,i)),13);case 13:return r=t.v,t.a(3,28);case 14:return t.d(c(yt(e,n,i)),15);case 15:return r=t.v,t.a(3,28);case 16:return t.d(c(ft(e,n,i)),17);case 17:return r=t.v,t.a(3,28);case 18:return r=gt(e),t.a(3,28);case 19:return t.d(c(Mt(e,n,i)),20);case 20:return r=t.v,t.a(3,28);case 21:return r=bt(e,n,i),t.a(3,28);case 22:return r=At(e,n,i),t.a(3,28);case 23:return t.d(c(zt(e,n,i)),24);case 24:return r=t.v,t.a(3,28);case 25:return t.d(c(_t(e,n,i)),26);case 26:return r=t.v,t.a(3,28);case 27:return r=xt(e,n,i),t.a(3,28);case 28:if(!i.async||null!=r&&"function"==typeof r.then||(r=Promise.resolve(r)),!i.async||"function"!=typeof r.then||!e.nextFunction||"function"!=typeof r[e.nextFunction]){t.n=29;break}t.n=31;break;case 29:return t.n=30,r;case 30:r=t.v;case 31:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.n=35;break}o=0;case 32:if(!(o<e.predicate.length)){t.n=35;break}return t.d(c(X(e.predicate[o].expr,r,i)),33);case 33:r=t.v;case 34:o++,t.n=32;break;case 35:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.n=37;break}return t.d(c(ut(e.group,r,i)),36);case 36:r=t.v;case 37:return(a=i.lookup("__evaluate_exit"))&&a(e,n,i,r),r&&F(r)&&!r.tupleStream&&(e.keepArray&&(r.keepSingleton=!0),0===r.length?r=void 0:1===r.length&&(r=r.keepSingleton?r:r[0])),t.a(2,r)}},t)}function $(t,n,i){var r,s,o,a,l,u;return h().w(function(e){for(;;)switch(e.n){case 0:r=Array.isArray(n)&&"variable"!==t.steps[0].type?n:R(n),o=!1,a=void 0,l=0;case 1:if(!(l<t.steps.length)){e.n=10;break}if((u=t.steps[l]).tuple&&(o=!0),0!==l||!u.consarray){e.n=3;break}return e.d(c(q(u,r,i)),2);case 2:s=e.v,e.n=7;break;case 3:if(!o){e.n=5;break}return e.d(c(G(u,r,a,i)),4);case 4:a=e.v,e.n=7;break;case 5:return e.d(c(Y(u,r,i,l===t.steps.length-1)),6);case 6:s=e.v;case 7:if(o||void 0!==s&&0!==s.length){e.n=8;break}return e.a(3,10);case 8:void 0===u.focus&&(r=s);case 9:l++,e.n=1;break;case 10:if(o)if(t.tuple)s=a;else for(s=R(),l=0;l<a.length;l++)s.push(a[l]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=R(s)),s.keepSingleton=!0),!Object.prototype.hasOwnProperty.call(t,"group")){e.n=12;break}return e.d(c(ut(t.group,o?a:s,i)),11);case 11:s=e.v;case 12:return e.a(2,s)}},e)}function V(t,e){var n,i=Dt(t),r=s(p.keys(e));try{for(r.s();!(n=r.n()).done;){var o=n.value;i.bind(o,e[o])}}catch(t){r.e(t)}finally{r.f()}return i}function Y(t,e,i,r){var s,o,a,l,u;return h().w(function(n){for(;;)switch(n.n){case 0:if("sort"!==t.type){n.n=4;break}return n.d(c(vt(t,e,i)),1);case 1:if(s=n.v,!t.stages){n.n=3;break}return n.d(c(H(t.stages,s,i)),2);case 2:s=n.v;case 3:return n.a(2,s);case 4:s=R(),o=0;case 5:if(!(o<e.length)){n.n=12;break}return n.d(c(q(t,e[o],i)),6);case 6:if(a=n.v,!t.stages){n.n=10;break}l=0;case 7:if(!(l<t.stages.length)){n.n=10;break}return n.d(c(X(t.stages[l].expr,a,i)),8);case 8:a=n.v;case 9:l++,n.n=7;break;case 10:void 0!==a&&s.push(a);case 11:o++,n.n=5;break;case 12:return u=R(),r&&1===s.length&&Array.isArray(s[0])&&!F(s[0])?u=s[0]:Array.prototype.forEach.call(s,function(t){!Array.isArray(t)||t.cons?u.push(t):Array.prototype.forEach.call(t,function(t){return u.push(t)})}),n.a(2,u)}},n)}function H(t,e,n){var i,r,s,a,l;return h().w(function(o){for(;;)switch(o.n){case 0:i=e,r=0;case 1:if(!(r<t.length)){o.n=6;break}s=t[r],l=s.type,o.n="filter"===l?2:"index"===l?4:5;break;case 2:return o.d(c(X(s.expr,i,n)),3);case 3:return i=o.v,o.a(3,5);case 4:for(a=0;a<i.length;a++)i[a][s.value]=a;return o.a(3,5);case 5:r++,o.n=1;break;case 6:return o.a(2,i)}},o)}function G(t,e,n,i){var r,s,o,l,u,d,p,f;return h().w(function(a){for(;;)switch(a.n){case 0:if("sort"!==t.type){a.n=7;break}if(!n){a.n=2;break}return a.d(c(vt(t,n,i)),1);case 1:r=a.v,a.n=4;break;case 2:return a.d(c(vt(t,e,i)),3);case 3:for(s=a.v,(r=R()).tupleStream=!0,o=0;o<s.length;o++)(l={"@":s[o]})[t.index]=o,r.push(l);case 4:if(!t.stages){a.n=6;break}return a.d(c(H(t.stages,r,i)),5);case 5:r=a.v;case 6:return a.a(2,r);case 7:(r=R()).tupleStream=!0,u=i,void 0===n&&(n=e.map(function(t){return{"@":t}})),d=0;case 8:if(!(d<n.length)){a.n=11;break}return u=V(i,n[d]),a.d(c(q(t,n[d]["@"],u)),9);case 9:if(void 0!==(p=a.v))for(Array.isArray(p)||(p=[p]),f=0;f<p.length;f++)l=Object.create(null),Object.assign(l,n[d]),p.tupleStream?Object.assign(l,p[f]):(t.focus?(l[t.focus]=p[f],l["@"]=n[d]["@"]):l["@"]=p[f],t.index&&(l[t.index]=f),t.ancestor&&(l[t.ancestor.label]=n[d]["@"])),r.push(l);case 10:d++,a.n=8;break;case 11:if(!t.stages){a.n=13;break}return a.d(c(H(t.stages,r,i)),12);case 12:r=a.v;case 13:return a.a(2,r)}},a)}function X(t,e,n){var i,r,s,o,a,u;return h().w(function(h){for(;;)switch(h.n){case 0:if(i=R(),e&&e.tupleStream&&(i.tupleStream=!0),Array.isArray(e)||(e=R(e)),"number"!==t.type){h.n=1;break}(r=Math.floor(t.value))<0&&(r=e.length+r),void 0!==(s=e[r])&&(Array.isArray(s)?i=s:i.push(s)),h.n=5;break;case 1:r=0;case 2:if(!(r<e.length)){h.n=5;break}return s=e[r],o=s,a=n,e.tupleStream&&(o=s["@"],a=V(n,s)),h.d(c(q(t,o,a)),3);case 3:u=h.v,j(u)&&(u=[u]),C(u)?Array.prototype.forEach.call(u,function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===r&&i.push(s)}):d.boolean(u)&&i.push(s);case 4:r++,h.n=2;break;case 5:return h.a(2,i)}},l)}function Z(t,e,n){var i,r,s,o,a,l,u,d;return h().w(function(p){for(;;)switch(p.p=p.n){case 0:return p.d(c(q(t.lhs,e,n)),1);case 1:if(r=p.v,s=t.value,o=h().m(function i(){return h().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(q(t.rhs,e,n)),1);case 1:return i.a(2,i.v)}},i)}),"and"!==s&&"or"!==s){p.n=5;break}return p.p=2,p.d(c(ct(r,o,s)),3);case 3:return p.a(2,p.v);case 4:throw p.p=4,(l=p.v).position=t.position,l.token=s,l;case 5:return p.d(c(o()),6);case 6:a=p.v,p.p=7,u=s,p.n="+"===u||"-"===u||"*"===u||"/"===u||"%"===u?8:"="===u||"!="===u?9:"<"===u||"<="===u||">"===u||">="===u?10:"&"===u?11:".."===u?12:"in"===u?13:14;break;case 8:return i=rt(r,a,s),p.a(3,14);case 9:return i=st(r,a,s),p.a(3,14);case 10:return i=ot(r,a,s),p.a(3,14);case 11:return i=lt(r,a),p.a(3,14);case 12:return i=pt(r,a),p.a(3,14);case 13:return i=at(r,a),p.a(3,14);case 14:p.n=16;break;case 15:throw p.p=15,(d=p.v).position=t.position,d.token=s,d;case 16:return p.a(2,i)}},y,null,[[7,15],[2,4]])}function J(t,e,n){var i,r,s,o,a;return h().w(function(h){for(;;)switch(h.n){case 0:a=t.value,h.n="-"===a?1:"["===a?6:"{"===a?11:13;break;case 1:return h.d(c(q(t.expression,e,n)),2);case 2:if(void 0!==(i=h.v)){h.n=3;break}i=void 0,h.n=5;break;case 3:if(!j(i)){h.n=4;break}i=-i,h.n=5;break;case 4:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:i};case 5:return h.a(3,13);case 6:i=[],r=0;case 7:if(!(r<t.expressions.length)){h.n=10;break}return s=t.expressions[r],h.d(c(q(s,e,n)),8);case 8:void 0!==(o=h.v)&&("["===s.value?i.push(o):i=d.append(i,o));case 9:r++,h.n=7;break;case 10:return t.consarray&&Object.defineProperty(i,"cons",{enumerable:!1,configurable:!1,value:!0}),h.a(3,13);case 11:return h.d(c(ut(t,e,n)),12);case 12:return i=h.v,h.a(3,13);case 13:return h.a(2,i)}},g)}function Q(t,e,n){return d.lookup(e,t.value)}function K(t){return t.value}function tt(t,e){var n=R();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null===e||"object"!==r(e)||D(e)||p.keys(e).forEach(function(t){var i=e[t];Array.isArray(i)?(i=et(i),n=d.append(n,i)):n.push(i)}),n}function et(t,e){return void 0===e&&(e=[]),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){et(t,e)}):e.push(t),e}function nt(t,e){var n,i=R();return void 0!==e&&(it(e,i),n=1===i.length?i[0]:i),n}function it(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){it(t,e)}):null===t||"object"!==r(t)||D(t)||p.keys(t).forEach(function(n){it(t[n],e)})}function rt(t,e,n){var i;if(void 0!==t&&!j(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!j(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return i;switch(n){case"+":i=t+e;break;case"-":i=t-e;break;case"*":i=t*e;break;case"/":i=t/e;break;case"%":i=t%e}return i}function st(t,e,n){var i,s=r(t),o=r(e);if("undefined"===s||"undefined"===o)return!1;switch(n){case"=":i=U(t,e);break;case"!=":i=!U(t,e)}return i}function ot(t,e,n){var i,s=r(t),o=r(e);if("undefined"!==s&&"string"!==s&&"number"!==s||"undefined"!==o&&"string"!==o&&"number"!==o)throw{code:"T2010",stack:(new Error).stack,value:"string"!==s&&"number"!==s?t:e};if("undefined"!==s&&"undefined"!==o){if(s!==o)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function at(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var i=0;i<e.length;i++)if(e[i]===t){n=!0;break}return n}function ct(t,e,n){var i,r,s,o,a,l,u;return h().w(function(h){for(;;)switch(h.n){case 0:r=ht(t),s=n,h.n="and"===s?1:"or"===s?4:7;break;case 1:if(!(o=r)){h.n=3;break}return a=ht,h.d(c(e()),2);case 2:o=a(h.v);case 3:return i=o,h.a(3,7);case 4:if(l=r){h.n=6;break}return u=ht,h.d(c(e()),5);case 5:l=u(h.v);case 6:return i=l,h.a(3,7);case 7:return h.a(2,i)}},b)}function ht(t){var e=d.boolean(t);return void 0!==e&&e}function lt(t,e){var n="",i="";return void 0!==t&&(n=d.string(t)),void 0!==e&&(i=d.string(e)),n.concat(i)}function ut(t,e,n){var r,s,o,a,l,u,p,f,m,y,g,b,x,w,_;return h().w(function(h){for(;;)switch(h.n){case 0:r=Object.create(null),s=Object.create(null),o=!(!e||!e.tupleStream),Array.isArray(e)||(e=R(e)),0===e.length&&e.push(void 0),a=0;case 1:if(!(a<e.length)){h.n=10;break}l=e[a],u=o?V(n,l):n,p=0;case 2:if(!(p<t.lhs.length)){h.n=9;break}return f=t.lhs[p],h.d(c(q(f[0],o?l["@"]:l,u)),3);case 3:if("string"==typeof(m=h.v)||void 0===m){h.n=4;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:m};case 4:if(void 0===m){h.n=8;break}if("_jsonata_lambda"!==m&&"_jsonata_function"!==m){h.n=5;break}throw{code:"D1013",stack:(new Error).stack,position:t.position,value:m};case 5:if(y={data:l,exprIndex:p},!Object.prototype.hasOwnProperty.call(s,m)){h.n=7;break}if(s[m].exprIndex===p){h.n=6;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:m};case 6:s[m].data=d.append(s[m].data,l),h.n=8;break;case 7:s[m]=y;case 8:p++,h.n=2;break;case 9:a++,h.n=1;break;case 10:w=i(s);case 11:if((_=w()).done){h.n=13;break}return m=_.value,y=s[m],g=y.data,u=n,o&&(b=dt(y.data),g=b["@"],delete b["@"],u=V(n,b)),h.d(c(q(t.lhs[y.exprIndex][1],g,u)),12);case 12:void 0!==(x=h.v)&&(r[m]=x),h.n=11;break;case 13:return h.a(2,r)}},v)}function dt(t){if(!Array.isArray(t))return t;var e=Object.create(null);Object.assign(e,t[0]);for(var n=1;n<t.length;n++){var i,r=s(p.keys(t[n]));try{for(r.s();!(i=r.n()).done;){var o=i.value;e[o]=d.append(e[o],t[n][o])}}catch(t){r.e(t)}finally{r.f()}}return e}function pt(t,e){var n;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;if(t>e)return n;var i=e-t+1;if(i>1e7)throw{code:"D2014",stack:(new Error).stack,value:i};n=new Array(i);for(var r=t,s=0;r<=e;r++,s++)n[s]=r;return n.sequence=!0,n}function ft(t,e,n){var i;return h().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(q(t.rhs,e,n)),1);case 1:return i=r.v,n.bind(t.lhs.value,i),r.a(2,i)}},x)}function mt(t,e,n){var i,r;return h().w(function(s){for(;;)switch(s.n){case 0:return s.d(c(q(t.condition,e,n)),1);case 1:if(r=s.v,!d.boolean(r)){s.n=3;break}return s.d(c(q(t.then,e,n)),2);case 2:i=s.v,s.n=5;break;case 3:if(void 0===t.else){s.n=5;break}return s.d(c(q(t.else,e,n)),4);case 4:i=s.v;case 5:return s.a(2,i)}},w)}function yt(t,e,n){var i,r,s;return h().w(function(o){for(;;)switch(o.n){case 0:r=Dt(n),s=0;case 1:if(!(s<t.expressions.length)){o.n=4;break}return o.d(c(q(t.expressions[s],e,r)),2);case 2:i=o.v;case 3:s++,o.n=1;break;case 4:return o.a(2,i)}},_)}function gt(t){var e=new Bt.RegexEngine(t.value),n=function(i,r){var s;e.lastIndex=r||0;var o=e.exec(i);if(null!==o){if(s={match:o[0],start:o.index,end:o.index+o[0].length,groups:[]},o.length>1)for(var a=1;a<o.length;a++)s.groups.push(o[a]);s.next=function(){if(!(e.lastIndex>=i.length)){var r=n(i,e.lastIndex);if(r&&""===r.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return r}}}return s};return n}function bt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function vt(t,e,n){var i,s,o,a,l;return h().w(function(u){for(;;)switch(u.n){case 0:return s=e,o=!!e.tupleStream,a=h().m(function e(i,s){var a,l,u,d,p,f,m,y,g;return h().w(function(e){for(;;)switch(e.n){case 0:a=0,l=0;case 1:if(!(0===a&&l<t.terms.length)){e.n=11;break}return u=t.terms[l],d=i,p=n,o&&(d=i["@"],p=V(n,i)),e.d(c(q(u.expression,d,p)),2);case 2:return f=e.v,d=s,p=n,o&&(d=s["@"],p=V(n,s)),e.d(c(q(u.expression,d,p)),3);case 3:if(m=e.v,y=r(f),g=r(m),"undefined"!==y){e.n=4;break}return a="undefined"===g?0:1,e.a(3,10);case 4:if("undefined"!==g){e.n=5;break}return a=-1,e.a(3,10);case 5:if(!("string"!==y&&"number"!==y||"string"!==g&&"number"!==g)){e.n=6;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==y&&"number"!==y?f:m};case 6:if(y===g){e.n=7;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:f,value2:m};case 7:if(f!==m){e.n=8;break}return e.a(3,10);case 8:a=f<m?-1:1;case 9:!0===u.descending&&(a=-a);case 10:l++,e.n=1;break;case 11:return e.a(2,1===a)}},e)}),l={environment:n,input:e},u.d(c(d.sort.apply(l,[s,a])),1);case 1:return i=u.v,u.a(2,i)}},M)}function xt(t,e,n){return Ct(h().m(function e(i){var o,a,l,u,d,f,m,y,g,b,v,x,w;return h().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==i){e.n=1;break}return e.a(2,void 0);case 1:if(o=n.lookup("clone"),D(o)){e.n=2;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 2:return e.d(c(St(o,[i],null,n)),3);case 3:return a=e.v,e.d(c(q(t.pattern,a,n)),4);case 4:if(void 0===(l=e.v)){e.n=12;break}Array.isArray(l)||(l=[l]),u=0;case 5:if(!(u<l.length)){e.n=12;break}return d=l[u],e.d(c(q(t.update,d,n)),6);case 6:if(f=e.v,"undefined"===(m=r(f))){e.n=8;break}if("object"===m&&null!==f&&!Array.isArray(f)){e.n=7;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:f};case 7:y=s(p.keys(f));try{for(y.s();!(g=y.n()).done;)b=g.value,d[b]=f[b]}catch(t){y.e(t)}finally{y.f()}case 8:if(void 0===t.delete){e.n=11;break}return e.d(c(q(t.delete,d,n)),9);case 9:if(void 0===(v=e.v)){e.n=11;break}if(x=v,Array.isArray(v)||(v=[v]),P(v)){e.n=10;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:x};case 10:for(w=0;w<v.length;w++)"object"===r(d)&&null!==d&&delete d[v[w]];case 11:u++,e.n=5;break;case 12:return e.a(2,a)}},e)}),"<(oa):o>")}var wt=f("function($f, $g) { function($x){ $g($f($x)) } }");function _t(t,e,n){var i,r,s,o;return h().w(function(a){for(;;)switch(a.n){case 0:return a.d(c(q(t.lhs,e,n)),1);case 1:if(r=a.v,"function"!==t.rhs.type){a.n=3;break}return a.d(c(Mt(t.rhs,e,n,{context:r})),2);case 2:i=a.v,a.n=10;break;case 3:return a.d(c(q(t.rhs,e,n)),4);case 4:if(s=a.v,D(s)){a.n=5;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 5:if(!D(r)){a.n=8;break}return a.d(c(q(wt,null,n)),6);case 6:return o=a.v,a.d(c(St(o,[r,s],null,n)),7);case 7:i=a.v,a.n=10;break;case 8:return a.d(c(St(s,[r],null,n)),9);case 9:i=a.v;case 10:return a.a(2,i)}},S)}function Mt(t,e,n,i){var s,o,a,l,u,d,p;return h().w(function(f){for(;;)switch(f.p=f.n){case 0:return f.d(c(q(t.procedure,e,n)),1);case 1:if(void 0!==(o=f.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){f.n=2;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 2:a=[],void 0!==i&&a.push(i.context),l=h().m(function i(){var r,s;return h().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(q(t.arguments[u],e,n)),1);case 1:r=i.v,D(r)?(s=h().m(function t(){var e,i,s,o=arguments;return h().w(function(t){for(;;)switch(t.n){case 0:for(e=o.length,i=new Array(e),s=0;s<e;s++)i[s]=o[s];return t.d(c(St(r,i,null,n)),1);case 1:return t.a(2,t.v)}},t)}),s.arity=B(r),a.push(s)):a.push(r);case 2:return i.a(2)}},i)}),u=0;case 3:if(!(u<t.arguments.length)){f.n=5;break}return f.d(c(l()),4);case 4:u++,f.n=3;break;case 5:return d="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.p=6,"object"===r(o)&&(o.token=d,o.position=t.position),f.d(c(St(o,a,e,n)),7);case 7:s=f.v,f.n=9;break;case 8:throw f.p=8,(p=f.v).position||(p.position=t.position),p.token||(p.token=d),p;case 9:return f.a(2,s)}},k,null,[[6,8]])}function St(t,e,n,i){var r,s,o,a,l;return h().w(function(h){for(;;)switch(h.n){case 0:return h.d(c(kt(t,e,n,i)),1);case 1:r=h.v;case 2:if(!N(r)||!0!==r.thunk){h.n=9;break}return h.d(c(q(r.body.procedure,r.input,r.environment)),3);case 3:s=h.v,"variable"===r.body.procedure.type&&(s.token=r.body.procedure.value),s.position=r.body.procedure.position,o=[],a=0;case 4:if(!(a<r.body.arguments.length)){h.n=7;break}return l=o,h.d(c(q(r.body.arguments[a],r.input,r.environment)),5);case 5:l.push.call(l,h.v);case 6:a++,h.n=4;break;case 7:return h.d(c(kt(s,o,n,i)),8);case 8:r=h.v,h.n=2;break;case 9:return h.a(2,r)}},A)}function kt(t,e,n,i){var r,s,o,a;return h().w(function(h){for(;;)switch(h.p=h.n){case 0:if(h.p=0,s=e,t&&(s=Tt(t.signature,e,n)),!N(t)){h.n=2;break}return h.d(c(It(t,s)),1);case 1:r=h.v,h.n=9;break;case 2:if(!t||!0!==t._jsonata_function){h.n=5;break}if(o={environment:i,input:n},r=t.implementation.apply(o,s),!L(r)){h.n=4;break}return h.d(c(r),3);case 3:r=h.v;case 4:h.n=9;break;case 5:if("function"!=typeof t){h.n=8;break}if(r=t.apply(n,s),!L(r)){h.n=7;break}return h.d(c(r),6);case 6:r=h.v;case 7:h.n=9;break;case 8:throw{code:"T1006",stack:(new Error).stack};case 9:h.n=11;break;case 10:throw h.p=10,a=h.v,t&&(void 0===a.token&&void 0!==t.token&&(a.token=t.token),a.position=t.position||a.position),a;case 11:return h.a(2,r)}},z,null,[[0,10]])}function At(t,e,n){var i={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(i.thunk=!0),i.apply=h().m(function t(n,r){return h().w(function(t){for(;;)switch(t.n){case 0:return t.d(c(St(i,r,e,n.environment)),1);case 1:return t.a(2,t.v)}},t)}),i}function zt(t,e,n){var i,r,s,o,a,l;return h().w(function(h){for(;;)switch(h.n){case 0:r=[],s=0;case 1:if(!(s<t.arguments.length)){h.n=5;break}if("operator"!==(o=t.arguments[s]).type||"?"!==o.value){h.n=2;break}r.push(o),h.n=4;break;case 2:return l=r,h.d(c(q(o,e,n)),3);case 3:l.push.call(l,h.v);case 4:s++,h.n=1;break;case 5:return h.d(c(q(t.procedure,e,n)),6);case 6:if(void 0!==(a=h.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){h.n=7;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 7:if(!N(a)){h.n=8;break}i=Ot(a,r),h.n=11;break;case 8:if(!a||!0!==a._jsonata_function){h.n=9;break}i=Et(a.implementation,r),h.n=11;break;case 9:if("function"!=typeof a){h.n=10;break}i=Et(a,r),h.n=11;break;case 10:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 11:return h.a(2,i)}},T)}function Tt(t,e,n){return void 0===t?e:t.validate(e,n)}function It(t,e){var n,i;return h().w(function(r){for(;;)switch(r.n){case 0:if(i=Dt(t.environment),Array.prototype.forEach.call(t.arguments,function(t,n){i.bind(t.value,e[n])}),"function"!=typeof t.body){r.n=2;break}return r.d(c(jt(t.body,i)),1);case 1:n=r.v,r.n=4;break;case 2:return r.d(c(q(t.body,t.input,i)),3);case 3:n=r.v;case 4:return r.a(2,n)}},I)}function Ot(t,e){var n=Dt(t.environment),i=[];return Array.prototype.forEach.call(t.arguments,function(t,r){var s=e[r];s&&"operator"===s.type&&"?"===s.value?i.push(t):n.bind(t.value,s)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:i,body:t.body}}function Et(t,e){var n=Pt(t),i="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",r=f(i);return r.body=t,Ot(r,e)}function jt(t,e){var n,i,r,s;return h().w(function(o){for(;;)switch(o.n){case 0:if(n=Pt(t),i=n.map(function(t){return e.lookup(t.trim())}),r={environment:e},s=t.apply(r,i),!L(s)){o.n=2;break}return o.d(c(s),1);case 1:s=o.v;case 2:return o.a(2,s)}},O)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Ct(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=m(e)),n}function Rt(t,e){var n,i,r,s,o;return h().w(function(a){for(;;)switch(a.p=a.n){case 0:if(void 0!==t){a.n=1;break}return a.a(2,void 0);case 1:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!F(n)&&((n=R(n)).outerWrapper=!0)),a.p=2,i=f(t,!1),a.n=4;break;case 3:throw a.p=3,Lt(s=a.v),{stack:(new Error).stack,code:"D3120",value:s.message,error:s};case 4:return a.p=4,a.d(c(q(i,n,this.environment)),5);case 5:r=a.v,a.n=7;break;case 6:throw a.p=6,Lt(o=a.v),{stack:(new Error).stack,code:"D3121",value:o.message,error:o};case 7:return a.a(2,r)}},E,this,[[4,6],[2,3]])}function Ft(t){if(void 0!==t)return JSON.parse(d.string(t))}function Dt(t){var e=Object.create(null);return{bind:function(t,n){e[t]=n},lookup:function(n){var i;return Object.prototype.hasOwnProperty.call(e,n)?i=e[n]:t&&(i=t.lookup(n)),i},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}W.bind("sum",Ct(d.sum,"<a<n>:n>")),W.bind("count",Ct(d.count,"<a:n>")),W.bind("max",Ct(d.max,"<a<n>:n>")),W.bind("min",Ct(d.min,"<a<n>:n>")),W.bind("average",Ct(d.average,"<a<n>:n>")),W.bind("string",Ct(d.string,"<x-b?:s>")),W.bind("substring",Ct(d.substring,"<s-nn?:s>")),W.bind("substringBefore",Ct(d.substringBefore,"<s-s:s>")),W.bind("substringAfter",Ct(d.substringAfter,"<s-s:s>")),W.bind("lowercase",Ct(d.lowercase,"<s-:s>")),W.bind("uppercase",Ct(d.uppercase,"<s-:s>")),W.bind("length",Ct(d.length,"<s-:n>")),W.bind("trim",Ct(d.trim,"<s-:s>")),W.bind("pad",Ct(d.pad,"<s-ns?:s>")),W.bind("match",Ct(d.match,"<s-f<s:o>n?:a<o>>")),W.bind("contains",Ct(d.contains,"<s-(sf):b>")),W.bind("replace",Ct(d.replace,"<s-(sf)(sf)n?:s>")),W.bind("split",Ct(d.split,"<s-(sf)n?:a<s>>")),W.bind("join",Ct(d.join,"<a<s>s?:s>")),W.bind("formatNumber",Ct(d.formatNumber,"<n-so?:s>")),W.bind("formatBase",Ct(d.formatBase,"<n-n?:s>")),W.bind("formatInteger",Ct(u.formatInteger,"<n-s:s>")),W.bind("parseInteger",Ct(u.parseInteger,"<s-s:n>")),W.bind("number",Ct(d.number,"<(nsb)-:n>")),W.bind("floor",Ct(d.floor,"<n-:n>")),W.bind("ceil",Ct(d.ceil,"<n-:n>")),W.bind("round",Ct(d.round,"<n-n?:n>")),W.bind("abs",Ct(d.abs,"<n-:n>")),W.bind("sqrt",Ct(d.sqrt,"<n-:n>")),W.bind("power",Ct(d.power,"<n-n:n>")),W.bind("random",Ct(d.random,"<:n>")),W.bind("boolean",Ct(d.boolean,"<x-:b>")),W.bind("not",Ct(d.not,"<x-:b>")),W.bind("map",Ct(d.map,"<af>")),W.bind("zip",Ct(d.zip,"<a+>")),W.bind("filter",Ct(d.filter,"<af>")),W.bind("single",Ct(d.single,"<af?>")),W.bind("reduce",Ct(d.foldLeft,"<afj?:j>")),W.bind("sift",Ct(d.sift,"<o-f?:o>")),W.bind("keys",Ct(d.keys,"<x-:a<s>>")),W.bind("lookup",Ct(d.lookup,"<x-s:x>")),W.bind("append",Ct(d.append,"<xx:a>")),W.bind("exists",Ct(d.exists,"<x:b>")),W.bind("spread",Ct(d.spread,"<x-:a<o>>")),W.bind("merge",Ct(d.merge,"<a<o>:o>")),W.bind("reverse",Ct(d.reverse,"<a:a>")),W.bind("each",Ct(d.each,"<o-f:a>")),W.bind("error",Ct(d.error,"<s?:x>")),W.bind("assert",Ct(d.assert,"<bs?:x>")),W.bind("type",Ct(d.type,"<x:s>")),W.bind("sort",Ct(d.sort,"<af?:a>")),W.bind("shuffle",Ct(d.shuffle,"<a:a>")),W.bind("distinct",Ct(d.distinct,"<x:x>")),W.bind("base64encode",Ct(d.base64encode,"<s-:s>")),W.bind("base64decode",Ct(d.base64decode,"<s-:s>")),W.bind("encodeUrlComponent",Ct(d.encodeUrlComponent,"<s-:s>")),W.bind("encodeUrl",Ct(d.encodeUrl,"<s-:s>")),W.bind("decodeUrlComponent",Ct(d.decodeUrlComponent,"<s-:s>")),W.bind("decodeUrl",Ct(d.decodeUrl,"<s-:s>")),W.bind("eval",Ct(Rt,"<sx?:x>")),W.bind("toMillis",Ct(u.toMillis,"<s-s?:n>")),W.bind("fromMillis",Ct(u.fromMillis,"<n-s?s?:s>")),W.bind("clone",Ct(Ft,"<(oa)-:o>"));var Nt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1013:"Object property names starting with _jsonata_ are reserved for internal use: {{value}}",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Lt(t){var e=Nt[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function Bt(t,e){var n,i;try{n=f(t,e&&e.recover),i=n.errors,delete n.errors}catch(t){throw Lt(t),t}var r=Dt(W),o=new Date;return r.bind("now",Ct(function(t,e){return u.fromMillis(o.getTime(),t,e)},"<s?s?:s>")),r.bind("millis",Ct(function(){return o.getTime()},"<:n>")),e&&e.RegexEngine?Bt.RegexEngine=e.RegexEngine:Bt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==i){var c={code:"S0500",position:0};throw Lt(c),c}if(void 0!==e){var h;h=Dt(r);var l,u=s(p.keys(e));try{for(u.s();!(l=u.n()).done;){var d=l.value;h.bind(d,e[d])}}catch(c){u.e(c)}finally{u.f()}}else h=r;var f,m;if(h.bind("$",t),o=new Date,h.timestamp=o,Array.isArray(t)&&!F(t)&&((t=R(t)).outerWrapper=!0),"function"==typeof a){h.async=!0;var y=function(t){Lt(t),a(t,null)},g=function(t){(f=m.next(t)).done?a(null,f.value):f.value.then(g).catch(y)};m=q(n,t,h),(f=m.next()).value.then(g).catch(y)}else try{for(m=q(n,t,h),f=m.next();!f.done;)f=m.next(f.value);return f.value}catch(c){throw Lt(c),c}},assign:function(t,e){r.bind(t,e)},registerFunction:function(t,e,n){var i=Ct(e,n);r.bind(t,i)},ast:function(){return n},errors:function(){return i}}}return Bt.parser=f,Bt}();e.exports=y},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var i=t("./signature"),r=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},n=function(n){var i=0,r=n.length,s=function(t,e){return{type:t,value:e,position:i}},o=function(){for(var t,e,s=i,o=0;i<r;){var a=n.charAt(i);if("/"===a&&"\\"!==n.charAt(i-1)&&0===o){if(""===(t=n.substring(s,i)))throw{code:"S0301",stack:(new Error).stack,position:i};for(i++,a=n.charAt(i),s=i;"i"===a||"m"===a;)i++,a=n.charAt(i);return e=n.substring(s,i)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(i-1)||o++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(i-1)||o--,i++}throw{code:"S0302",stack:(new Error).stack,position:i}},a=function(c){if(i>=r)return null;for(var h=n.charAt(i);i<r&&" \t\n\r\v".indexOf(h)>-1;)i++,h=n.charAt(i);if("/"===h&&"*"===n.charAt(i+1)){var l=i;for(i+=2,h=n.charAt(i);"*"!==h||"/"!==n.charAt(i+1);)if(h=n.charAt(++i),i>=r)throw{code:"S0106",stack:(new Error).stack,position:l};return i+=2,h=n.charAt(i),a(c)}if(!0!==c&&"/"===h)return i++,s("regex",o());if("."===h&&"."===n.charAt(i+1))return i+=2,s("operator","..");if(":"===h&&"="===n.charAt(i+1))return i+=2,s("operator",":=");if("!"===h&&"="===n.charAt(i+1))return i+=2,s("operator","!=");if(">"===h&&"="===n.charAt(i+1))return i+=2,s("operator",">=");if("<"===h&&"="===n.charAt(i+1))return i+=2,s("operator","<=");if("*"===h&&"*"===n.charAt(i+1))return i+=2,s("operator","**");if("~"===h&&">"===n.charAt(i+1))return i+=2,s("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return i++,s("operator",h);if('"'===h||"'"===h){var u=h;i++;for(var d="";i<r;){if("\\"===(h=n.charAt(i)))if(i++,h=n.charAt(i),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:i,token:h};var p=n.substr(i+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:i};var f=parseInt(p,16);d+=String.fromCharCode(f),i+=4}else{if(h===u)return i++,s("string",d);d+=h}i++}throw{code:"S0101",stack:(new Error).stack,position:i}}var m,y=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(i));if(null!==y){var g=parseFloat(y[0]);if(!isNaN(g)&&isFinite(g))return i+=y[0].length,s("number",g);throw{code:"S0102",stack:(new Error).stack,position:i,token:y[0]}}if("`"===h){i++;var b=n.indexOf("`",i);if(-1!==b)return m=n.substring(i,b),i=b+1,s("name",m);throw i=r,{code:"S0105",stack:(new Error).stack,position:i}}for(var v,x=i;;)if(v=n.charAt(x),x===r||" \t\n\r\v".indexOf(v)>-1||Object.prototype.hasOwnProperty.call(t,v)){if("$"===n.charAt(i))return m=n.substring(i+1,x),i=x,s("variable",m);switch(m=n.substring(i,x),i=x,m){case"or":case"in":case"and":return s("operator",m);case"true":return s("value",!0);case"false":return s("value",!1);case"null":return s("value",null);default:return i===r&&""===m?null:s("name",m)}}else x++};return a},r=function(e,r){var s,o,a=Object.create(null),c=[],h=function(){var t=[];"(end)"!==s.id&&t.push({type:s.type,value:s.value,position:s.position});for(var e=o();null!==e;)t.push(e),e=o();return t},l={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(r)return t.remaining=h(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(l)).id=n.value=t,n.lbp=e,a[t]=n),n},d=function(t){if(r){t.remaining=h(),c.push(t);var e=a["(error)"];return(s=Object.create(e)).error=t,s.type="(error)",s}throw t.stack=(new Error).stack,t},p=function(t,n){if(t&&s.id!==t){var i={code:"(end)"===s.id?"S0203":"S0202",position:s.position,token:s.value,value:t};return d(i)}var r=o(n);if(null===r)return(s=a["(end)"]).position=e.length,s;var c,h=r.value,l=r.type;switch(l){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[h]))return d({code:"S0204",stack:(new Error).stack,position:r.position,token:h});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":l="regex",c=a["(regex)"];break;default:return d({code:"S0205",stack:(new Error).stack,position:r.position,token:h})}return(s=Object.create(c)).value=h,s.type=l,s.position=r.position,s},f=function(t){var e,n=s;for(p(null,!0),e=n.nud();t<s.lbp;)n=s,p(),e=n.led(e);return e},m=function(t){u(t,0).nud=function(){return this}},y=function(e,n,i){var r=n||t[e],s=u(e,r);return s.led=i||function(t){return this.lhs=t,this.rhs=f(r),this.type="binary",this},s},g=function(t,e,n){var i=u(t,e);return i.led=n,i},b=function(t,e){var n=u(t);return n.nud=e||function(){return this.expression=f(70),this.type="unary",this},n};m("(end)"),m("(name)"),m("(literal)"),m("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),y("."),y("+"),y("-"),y("*"),y("/"),y("%"),y("="),y("<"),y(">"),y("!="),y("<="),y(">="),y("&"),y("and"),y("or"),y("in"),m("and"),m("or"),m("in"),b("-"),y("~>"),g("(error)",10,function(t){return this.lhs=t,this.error=s.error,this.remaining=h(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),y("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==s.id)for(;"operator"===s.type&&"?"===s.id?(this.type="partial",this.arguments.push(s),p("?")):this.arguments.push(f(0)),","===s.id;)p(",");if(p(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach(function(t,e){if("variable"!==t.type)return d({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===s.id){for(var e=s.position,n=1,r="<";n>0&&"{"!==s.id&&"(end)"!==s.id;){var o=p();">"===o.id?n--:"<"===o.id&&n++,r+=o.value}p(">");try{this.signature=i(r)}catch(t){return t.position=e+t.offset,d(t)}}p("{"),this.body=f(0),p("}")}return this}),b("(",function(){for(var t=[];")"!==s.id&&(t.push(f(0)),";"===s.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==s.id)for(;;){var e=f(0);if(".."===s.id){var n={type:"binary",value:"..",position:s.position,lhs:e};p(".."),n.rhs=f(0),e=n}if(t.push(e),","!==s.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this}),y("[",t["["],function(e){if("]"===s.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this}),y("^",t["^"],function(t){p("(");for(var e=[];;){var n={descending:!1};if("<"===s.id?p("<"):">"===s.id&&(n.descending=!0,p(">")),n.expression=f(0),e.push(n),","!==s.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var v=function(t){var e=[];if("}"!==s.id)for(;;){var n=f(0);p(":");var i=f(0);if(e.push([n,i]),","!==s.id)break;p(",")}return p("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};b("{",v),y("{",t["{"],v),g(":=",t[":="],function(e){return"variable"!==e.type?d({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)}),y("@",t["@"],function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),y("#",t["#"],function(e){return this.lhs=e,this.rhs=f(t["#"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),y("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=f(0),":"===s.id&&(p(":"),this.else=f(0)),this}),b("|",function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===s.id&&(p(","),this.delete=f(0)),p("|"),this});var x=function(t){var e;if("function"!==t.type||t.predicate)if("condition"===t.type)t.then=x(t.then),void 0!==t.else&&(t.else=x(t.else)),e=t;else if("block"===t.type){var n=t.expressions.length;n>0&&(t.expressions[n-1]=x(t.expressions[n-1])),e=t}else e=t;else{var i={type:"lambda",thunk:!0,arguments:[],position:t.position};i.body=t,e=i}return e},w=0,_=0,M=[],S=function(t,e){switch(t.type){case"name":case"wildcard":e.level--,0===e.level&&(void 0===t.ancestor||(M[e.index].slot.label=t.ancestor.label),t.ancestor=e,t.tuple=!0);break;case"parent":e.level++;break;case"block":t.expressions.length>0&&(t.tuple=!0,e=S(t.expressions[t.expressions.length-1],e));break;case"path":t.tuple=!0;var n=t.steps.length-1;for(e=S(t.steps[n--],e);e.level>0&&n>=0;)e=S(t.steps[n--],e);break;default:throw{code:"S0217",token:t.type,position:t.position}}return e},k=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},A=function(t){var e=t.steps.length-1,n=t.steps[e],i=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&i.push(n.slot);for(var r=0;r<i.length;r++){var s=i[r];for(e=t.steps.length-2;s.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[s]:t.seekingParent.push(s);break}for(var o=t.steps[e--];e>=0&&o.focus&&t.steps[e].focus;)o=t.steps[e--];s=S(o,s)}}},z=function(t){var e;switch(t.type){case"binary":switch(t.value){case".":var n=z(t.lhs);e="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(e.seekingParent=[n.slot]);var i=z(t.rhs);"function"===i.type&&"path"===i.procedure.type&&1===i.procedure.steps.length&&"name"===i.procedure.steps[0].type&&"function"===e.steps[e.steps.length-1].type&&(e.steps[e.steps.length-1].nextFunction=i.procedure.steps[0].value),"path"===i.type?Array.prototype.push.apply(e.steps,i.steps):(void 0!==i.predicate&&(i.stages=i.predicate,delete i.predicate),e.steps.push(i)),e.steps.filter(function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type}).forEach(function(t){t.type="name"}),e.steps.filter(function(t){return!0===t.keepArray}).length>0&&(e.keepSingletonArray=!0);var s=e.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var o=e.steps[e.steps.length-1];"unary"===o.type&&"["===o.value&&(o.consarray=!0),A(e);break;case"[":var a=e=z(t.lhs),h="predicate";if("path"===e.type&&(a=e.steps[e.steps.length-1],h="stages"),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:t.position};void 0===a[h]&&(a[h]=[]);var l=z(t.rhs);void 0!==l.seekingParent&&(l.seekingParent.forEach(function(t){1===t.level?S(a,t):t.level--}),k(a,l)),a[h].push({type:"filter",expr:l,position:t.position});break;case"{":if(void 0!==(e=z(t.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:t.position};e.group={lhs:t.rhs.map(function(t){return[z(t[0]),z(t[1])]}),position:t.position};break;case"^":"path"!==(e=z(t.lhs)).type&&(e={type:"path",steps:[e]});var u={type:"sort",position:t.position};u.terms=t.rhs.map(function(t){var e=z(t.expression);return k(u,e),{descending:t.descending,expression:e}}),e.steps.push(u),A(e);break;case":=":(e={type:"bind",value:t.value,position:t.position}).lhs=z(t.lhs),e.rhs=z(t.rhs),k(e,e.rhs);break;case"@":if(e=z(t.lhs),a=e,"path"===e.type&&(a=e.steps[e.steps.length-1]),void 0!==a.stages||void 0!==a.predicate)throw{code:"S0215",stack:(new Error).stack,position:t.position};if("sort"===a.type)throw{code:"S0216",stack:(new Error).stack,position:t.position};t.keepArray&&(a.keepArray=!0),a.focus=t.rhs.value,a.tuple=!0;break;case"#":e=z(t.lhs),a=e,"path"===e.type?a=e.steps[e.steps.length-1]:(e={type:"path",steps:[e]},void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate)),void 0===a.stages?a.index=t.rhs.value:a.stages.push({type:"index",value:t.rhs.value,position:t.position}),a.tuple=!0;break;case"~>":(e={type:"apply",value:t.value,position:t.position}).lhs=z(t.lhs),e.rhs=z(t.rhs);break;default:(e={type:t.type,value:t.value,position:t.position}).lhs=z(t.lhs),e.rhs=z(t.rhs),k(e,e.lhs),k(e,e.rhs)}break;case"unary":e={type:t.type,value:t.value,position:t.position},"["===t.value?e.expressions=t.expressions.map(function(t){var n=z(t);return k(e,n),n}):"{"===t.value?e.lhs=t.lhs.map(function(t){var n=z(t[0]);k(e,n);var i=z(t[1]);return k(e,i),[n,i]}):(e.expression=z(t.expression),"-"===t.value&&"number"===e.expression.type?(e=e.expression).value=-e.value:k(e,e.expression));break;case"function":case"partial":(e={type:t.type,name:t.name,value:t.value,position:t.position}).arguments=t.arguments.map(function(t){var n=z(t);return k(e,n),n}),e.procedure=z(t.procedure);break;case"lambda":e={type:t.type,arguments:t.arguments,signature:t.signature,position:t.position};var d=z(t.body);e.body=x(d);break;case"condition":(e={type:t.type,position:t.position}).condition=z(t.condition),k(e,e.condition),e.then=z(t.then),k(e,e.then),void 0!==t.else&&(e.else=z(t.else),k(e,e.else));break;case"transform":(e={type:t.type,position:t.position}).pattern=z(t.pattern),e.update=z(t.update),void 0!==t.delete&&(e.delete=z(t.delete));break;case"block":(e={type:t.type,position:t.position}).expressions=t.expressions.map(function(t){var n=z(t);return k(e,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(e.consarray=!0),n});break;case"name":e={type:"path",steps:[t]},t.keepArray&&(e.keepSingletonArray=!0);break;case"parent":e={type:"parent",slot:{label:"!"+w++,level:1,index:_++}},M.push(e);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":e=t;break;case"operator":if("and"===t.value||"or"===t.value||"in"===t.value)t.type="name",e=z(t);else{if("?"!==t.value)throw{code:"S0201",stack:(new Error).stack,position:t.position,token:t.value};e=t}break;case"error":e=t,t.lhs&&(e=z(t.lhs));break;default:var p="S0206";"(end)"===t.id&&(p="S0207");var f={code:p,position:t.position,token:t.value};if(r)return c.push(f),{type:"error",error:f};throw f.stack=(new Error).stack,f}return t.keepArray&&(e.keepArray=!0),e};o=n(e),p();var T=f(0);if("(end)"!==s.id){var I={code:"S0201",position:s.position,token:s.value};d(I)}if("parent"===(T=z(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return c.length>0&&(T.errors=c),T};return r}();e.exports=r},{"./signature":5}],5:[function(t,e,n){function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}var r=t("./utils"),s=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,s=[],o=Object.create(null),a=o;n<e.length;){var c=e.charAt(n);if(":"===c)break;var h=function(){s.push(o),a=o,o=Object.create(null)},l=function(t,e,n,i){for(var r=1,s=e;s<t.length;)if(s++,(c=t.charAt(s))===i){if(0===--r)break}else c===n&&r++;return s};switch(c){case"s":case"n":case"b":case"l":case"o":o.regex="["+c+"m]",o.type=c,h();break;case"a":o.regex="[asnblfom]",o.type=c,o.array=!0,h();break;case"f":o.regex="f",o.type=c,h();break;case"j":o.regex="[asnblom]",o.type=c,h();break;case"x":o.regex="[asnblfom]",o.type=c,h();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var u=l(e,n,"(",")"),d=e.substring(n+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:n};o.regex="["+d+"m]",o.type="("+d+")",n=u,h();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var p=l(e,n,"<",">");a.subtype=e.substring(n+1,p),n=p}n++}var f="^"+s.map(function(t){return"("+t.regex+")"}).join("")+"$",m=new RegExp(f),y=function(t){var e;if(r.isFunction(t))e="f";else switch(i(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},g=function(t,e){for(var n="^",i=0,r=0;r<s.length;r++){n+=s[r].regex;var o=e.match(n);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1};i=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1}};return{definition:e,validate:function(e,n){var i="";e.forEach(function(t){i+=y(t)});var r=m.exec(i);if(r){var o=[],a=0;return s.forEach(function(i,s){var c=e[a],h=r[s+1];if(""===h)if(i.context&&i.contextRegex){var l=y(n);if(!i.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};o.push(n)}else o.push(c),a++;else h.split("").forEach(function(n){if("a"===i.type){if("m"===n)c=void 0;else{c=e[a];var r=!0;if(void 0!==i.subtype)if("a"!==n&&h!==i.subtype)r=!1;else if("a"===n&&c.length>0){var s=y(c[0]);r=s===i.subtype.charAt(0)&&0===c.filter(function(t){return y(t)!==s}).length}if(!r)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[i.subtype]};"a"!==n&&(c=[c])}o.push(c),a++}else o.push(c),a++})}),o}g(e,i)}}}return e}();e.exports=s},{"./utils":6}],6:[function(t,e,n){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter(function(t){return"string"!=typeof t}).length),e}function n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function r(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function s(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function h(t){return t&&!0===t._jsonata_lambda}var l=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function u(t){return"object"===o(t)&&null!==t&&l in t&&"next"in t&&"function"==typeof t.next}function d(t,e){if(t===e)return!0;if("object"===o(t)&&"object"===o(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!d(t[n],e[n]))return!1;return!0}var i=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(i.length!==r.length)return!1;for(i=i.sort(),r=r.sort(),n=0;n<i.length;n++)if(i[n]!==r[n])return!1;for(n=0;n<i.length;n++){var s=i[n];if(!d(t[s],e[s]))return!1}return!0}return!1}function p(t){var e,n=[],r=i(t);try{for(r.s();!(e=r.n()).done;){var s=e.value;n.push(s)}}catch(t){r.e(t)}finally{r.f()}return n}function f(t){return"object"===o(t)&&null!==t?Object.keys(t):[]}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:r,isSequence:s,isFunction:a,isLambda:h,isIterable:u,getFunctionArity:c,isDeepEqual:d,stringToArray:p,keys:f}}();e.exports=a},{}]},{},[3])(3)}(Ta)),Ta.exports),Oa=ka(Ia);const Ea=function(t){return t};function ja(t){if(!t)return Ea;try{const e=Oa(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return wa(t),Ea}}function Pa(t,e){if(!e)return;const n=Ho(t),i=null==n?"":String(n);return Object.prototype.hasOwnProperty.call(e,i)?e[i]:e.default}const Ca=t=>null==t||""===t?void 0:parseFloat(String(t));function Ra(t,e,n){for(const n of e)if(void 0!==n.value&&n.value===t)return n.result;const i=Ho(t);if(null==i)return n;const r=Number(i);if(Number.isNaN(r))return n;for(const t of e){const e=Ca(t.min),n=Ca(t.max);if((void 0!==e||void 0!==n)&&(r>=(e??-1/0)&&r<(n??1/0)))return t.result}return n}function Fa(t){return Number(Ho(t))}function Da(t){return t}function Na(t){return function(t){const e=Ho(t);return null==e?"":String(e)}(t)}function La(t){return Fa(t)}function Ba(t){return Pa(t,this.param)}function Ua(t){const{param:e}=this;if(!e)return;return Ra(t,Object.keys(e).filter(t=>"default"!==t).map(t=>{const[n,i]=t.split("~");return{min:""===n?null:n,max:void 0===i||""===i?null:i,result:e[t]}}),e.default)}function Wa(t){const{param:e}=this;if(!e)return;const n=Number(e.scale??1),i=Number(e.offset??0);return Fa(t)*n+i}function qa(t){return Fa(t)*Math.PI/180}function $a(){}const Va=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const Ya=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],Ha=new Array(Ya.length).fill(void 0),Ga=Object.getPrototypeOf(async function(){}).constructor;function Xa(t,e){!function(t){for(const e of Va)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const n=function(t){return/\bawait\b/.test(t)}(t),i=new(n?Ga:Function)(...e,...Ya,t);return function(t,...e){return i.call(t,...e,...Ha)}}function Za(t,e,n,i,r){switch(n){case"value":return"text"===r||"string"===r?Na.bind(t):"number"===r?La.bind(t):Da.bind(e);case"map":return Ba.bind(t);case"range":return Ua.bind(t);case"scale":return Wa.bind(t);case"radian":return qa.bind(t);case"eval":return function(t){try{const e=Xa(t,["value","targets","scene"]);return function(t,n){try{const i=e(this,t,n,globalThis.scene);return i&&"function"==typeof i.then?i.catch(t=>{wa(t)}):i}catch(t){return void wa(t)}}}catch(t){return wa(t),$a}}(i).bind(e);default:return Da.bind(e)}}class Ja{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:i,param:r,accessor:s}=t;this._model=t,this.evaluator=Za(this,this.owner,i,r,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=ja(s);const o=e.match(/\[(.*?)\]/);if(o){const[t,e]=o[1].split(":");this.propAccessor=ja(t),this.partAccessor=ja(e)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function Qa(t,e,n,i){const r=e.split(".");if(1===r.length)return void(t[e]=i?{...t[e],...n}:n);const s=r[0],o=void 0!==t[s]?t[s]:"function"==typeof t.get?t.get(s):void 0,a=o?{...o}:{};let c=a;for(let t=1;t<r.length-1;t++)c[r[t]]=c[r[t]]?{...c[r[t]]}:{},c=c[r[t]];const h=r[r.length-1];c[h]=i?{...c[h],...n}:n,t[s]=a}function Ka(t,e,n,i){t.forEach(t=>Qa(t,e,n,i))}function tc(t,e,n,i){t&&"function"==typeof t.then?t.then(t=>{void 0!==n&&void 0!==i&&n._dataGeneration!==i||e(t)}).catch(t=>wa(t)):e(t)}function ec(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,n=this;this.mappings&&this.mappings.forEach(t=>{try{let i,{source:r,target:s,property:o,accessor:a,propAccessor:c,partAccessor:h,ndnsp:l=!1,partial:u=!1}=t;s=(s||"(self)").trim(),t.rule||(t.rule="value"),r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),i=this.root.findById(r)?.data||{}):i=this.data;const d=a(i);if("(root)"==s||"(key)"==s){if(null==d)return;const i=Object.keys(d||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();i.length>0&&i.forEach(i=>{tc(t.evaluator(d[i.get("id")],[i]),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Qa(i,o,t,u)},n,e)})}else if(s.startsWith("[")){if(null==d)return;if(d instanceof Array)d.forEach(i=>{const r=c(i);if(r){const s=this.root.findOrCreate(r);s&&tc(t.evaluator(h(i),s),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ka(s,o,t,u)},n,e)}});else{if(!(d instanceof Object))throw String("mapping data should be an object to target property-id.("+d+")");{const i=c(d);if(i){const r=this.root.findOrCreate(i);r&&tc(t.evaluator(h(d),r),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ka(r,o,t,u)},n,e)}}}}else{const i=this.root.findAll(s,this);i.length>0&&tc(t.evaluator(d,i),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ka(i,o,t,u)},n,e)}}catch(e){wa(e,this,t)}})}function nc(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),ec.call(this,!0)}function ic(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new Ja({target:"(self)",rule:"value",...t},this))):(wa("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function rc(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function sc(t,e){this.disposeMappings(),ec.call(this)}function oc(t,e,n,i,r,s){e.complete?t.drawImage(e,n,i,r,s):e.addEventListener("load",()=>{this.invalidate()})}function ac(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const cc="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),hc={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},lc=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";hc.FONT_FAMILY=e||n};let uc;function dc(t,e,n,i,r){const{alpha:s=1}=i,o=r.fillStyle;if(t.globalAlpha*=s,o)if("string"==typeof o)t.fillStyle=o,t.fill();else if("object"==typeof o)if("gradient"==o.type){t.translate(n.x,n.y);let i,{width:r,height:s}=e;if("linear"==o.gradientType){const e=3.141592653589793,n="number"==typeof o.rotation&&Number.isFinite(o.rotation)?o.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let o=Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));o-=o-(r+s)/3,i=t.createLinearGradient(o*Math.cos(n+e),o*Math.sin(n+e),o*Math.cos(n),o*Math.sin(n))}else i=t.createLinearGradient((r-4)/2*Math.cos(n+e),(s-4)/2*Math.sin(n+e),(r-4)/2*Math.cos(n),(s-4)/2*Math.sin(n))}else if("radial"==o.gradientType){const e=.95*Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));switch(o.center){case"center":default:i=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":i=t.createRadialGradient(-r/2,-s/2,0,-r/2,-s/2,2*e);break;case"right-top":i=t.createRadialGradient(r/2,-s/2,0,r/2,-s/2,2*e);break;case"left-bottom":i=t.createRadialGradient(-r/2,s/2,0,-r/2,s/2,2*e);break;case"right-bottom":i=t.createRadialGradient(r/2,s/2,0,r/2,s/2,2*e)}}(Array.isArray(o.colorStops)?o.colorStops:Array.isArray(o.gradientStops)?o.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{i.addColorStop(t.position,t.color)}catch(e){_a("Invalid Color for colorstop : ",t.color),i.addColorStop(t.position,"#fff")}}),t.fillStyle=i,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==o.type&&o.image)if(o.guideOnly&&1!=r.app.mode)o.color&&(t.fillStyle=o.color,t.fill());else{r.prepareFillIf(!r._pattern_image_origin);const n=r._pattern_image;if(!n||!n.width||!n.height)return;let i=0,s=0,a=0,c=0,h=e.left,l=e.top;if(!o.fitPattern){i=o.offsetX,s=o.offsetY;const t=o.width?o.width:n.width,r=o.height?o.height:n.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-r/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-r;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-r;break;case"left":a=0,c=e.height/2-r/2;break;case"right":a=e.width-t,c=e.height/2-r/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-r}h+=i+a,l+=s+c}t.translate(h,l),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete r._pattern_image,delete r._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-l)}}function pc(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const i=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return i._pattern_image=i._pattern_image_origin,void t(this);let e=n.width||this.width,r=n.height||this.height;n.fitPattern&&(e=i.bounds.width,r=i.bounds.height);const s=uc(e,r);s.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,r),i._pattern_image=s,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(n.image)}catch(t){e(t)}}function fc(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{wa(t)})}function mc(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function yc(t,e,n){let{strokeStyle:i,lineDash:r,lineWidth:s,lineCap:o,lineJoin:a,alpha:c}=e;if(i&&0!=s){if(o&&(t.lineCap=o),r){const e="round"==o;switch(r){case"solid":r=[0,0];break;case"round-dot":r=e?[0,2*s]:[s,s];break;case"square-dot":r=e?[s,2*s]:[2*s,s];break;case"dash":r=e?[3*s,2.5*s]:[4*s,1.5*s];break;case"dash-dot":r=e?[3*s,3*s,0,3*s]:[4*s,2*s,s,2*s];break;case"long-dash":r=e?[5*s,4*s]:[6*s,3*s];break;case"long-dash-dot":r=e?[5*s,3*s,0,3*s]:[6*s,2*s,s,2*s];break;case"long-dash-dot-dot":r=e?[5*s,2*s,0,2*s,0,2*s]:[6*s,s,s,s,s,s]}Array.isArray(r)||(r=[]),t.setLineDash(r)}t.globalAlpha*=c,t.strokeStyle=i,t.lineWidth=s,t.lineJoin=a,t.stroke()}}function gc(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let i;for(;null!==(i=e.exec(t));)i[1]?n.push({text:i[2],bold:!0,italic:!1}):i[3]?n.push({text:i[4],bold:!1,italic:!0}):i[5]&&n.push({text:i[5],bold:!1,italic:!1});return n}function bc(t,e,n,i=0){if(e.text.length<2)return e;let r=2;for(;r<e.text.length;r++){const s=e.text.substring(0,r);if(!(t.measureText(s).width+(r-1)*i<n))break}return{...e,text:e.text.substring(0,r-1)}}function vc(t,e,n,i,r,s=0){const o=String(e).split("\n");return i?[].concat(...o.map(e=>function(t,e,n,i=0){const r=[];let s=[],o=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-o,h=t.measureText(a).width+(a.length-1)*i;if(h<=c)s.push({...e,text:a}),o+=h,a="";else{const n=bc(t,{...e,text:a},c,i);s.push(n),r.push(s),s=[],o=0,a=a.substring(n.text.length)}}}),s.length>0&&r.push(s),r}(t,r?gc(e):[{text:e,bold:!1,italic:!1}],n,s))):o.map(t=>r?gc(t):[{text:t,bold:!1,italic:!1}])}function xc(t,e,n,i,r,s,o=0){if(!i)return[];t.save(),t.font=n;const a=vc(t,i,e,!!r,s,o);return t.restore(),a}function wc(t){const{fontFamily:e=hc.FONT_FAMILY,bold:n=hc.BOLD,italic:i=hc.ITALIC,fontSize:r=hc.FONT_SIZE}=t,s=[];return n&&s.push("bold"),i&&s.push("italic"),s.push(r+"px"),s.push(e),s.join(" ")}function _c(t,e){const n=t.bold||e.bold,i=t.italic||e.italic;return wc({...t,bold:n,italic:i})}function Mc(t,e,n,i){let{alpha:r,rotation:s,keepTextAngle:o=!1,fontColor:a=hc.FONT_COLOR,textAlign:c=hc.TEXT_ALIGN,textBaseline:h=hc.TEXT_BASELINE,textBackgroundStyle:l,fontSize:u,lineHeight:d,textWrap:p,textOverflow:f,letterSpacing:m=0}=i;r=void 0!==r?r:1,u||=hc.FONT_SIZE,d||=1.2*u,t.save();const{left:y,top:g,width:b,height:v}=e;if(s&&o&&(t.translate(y+b/2,g+v/2),t.rotate(-s),t.translate(-(y+b/2),-(g+v/2))),t.beginPath(),t.font=wc(i),!p&&f){const e=function(t,e,n,i){const r="ellipsis"===t?"…":"",s=e.measureText(r).width,o=[];let a=0;for(const r of n){const n=[];for(const c of r){const r=e.measureText(c.text).width;if(!(a+r<=i-("ellipsis"===t?s:0))){const r=Sc(e,c,i-a-("ellipsis"===t?s:0),t);return n.push(r),o.push(n),o}n.push(c),a+=r}o.push(n),a=0}return o}(f,t,n,b);n=e}const x=n.length*d;let w;switch(h){case"top":w=g,t.textBaseline="top";break;case"bottom":w=g+v-x+d,t.textBaseline="bottom";break;default:w=g+v/2-x/2+d/2,t.textBaseline="middle"}t.globalAlpha*=r,t.fillStyle=a,n.forEach((e,r)=>{const s=w+r*d,o=function(t,e,n,i=0){return e.reduce((e,r)=>(t.font=_c(n,r),e+t.measureText(r.text).width+i*(r.text.length-1)),0)}(t,e,i,m);let h=y;switch(c){case"left":case"justify":h=y;break;case"right":h=y+b-o;break;case"center":h=y+(b-o)/2}if(l&&(t.fillStyle=l,function(t,e,n,i,r,s=0,o=!1,a=!0){s="number"==typeof s?{tl:s,tr:s,br:s,bl:s}:{tl:0,tr:0,br:0,bl:0,...s},t.beginPath(),t.moveTo(e+s.tl,n),t.lineTo(e+i-s.tr,n),t.quadraticCurveTo(e+i,n,e+i,n+s.tr),t.lineTo(e+i,n+r-s.br),t.quadraticCurveTo(e+i,n+r,e+i-s.br,n+r),t.lineTo(e+s.bl,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s.bl),t.lineTo(e,n+s.tl),t.quadraticCurveTo(e,n,e+s.tl,n),t.closePath(),o&&t.fill(),a&&t.stroke()}(t,h-4,s-u/2-4,o+8,u+8,4,!0,!1),t.fillStyle=a),"justify"===c&&r<n.length-1&&e.length>1){const n=b-o,r=e.length-1,a=n/r;e.forEach((e,n)=>{t.font=_c(i,e),t.fillText(e.text,h,s),h+=t.measureText(e.text).width+(n<r?a:0)})}else e.forEach(e=>{t.font=_c(i,e),[...e.text].forEach(e=>{t.fillText(e,h,s),h+=t.measureText(e).width+m})})}),t.restore()}function Sc(t,e,n,i){let r="";for(let i=0;i<e.text.length;i++){const s=r+e.text[i];if(t.measureText(s).width>n)break;r=s}return{...e,text:r+("ellipsis"===i?"…":"")}}function kc(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{lc()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(lc),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{lc()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),lc(),uc="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const Ac=[];function zc(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(1!==r.x||1!==r.y?(t=(t-n.x)/r.x,e=(e-n.y)/r.y):(t-=n.x,e-=n.y),0!==i){const n=Math.cos(-i),r=Math.sin(-i),s=t*r+e*n;t=t*n-e*r,e=s}return{x:t+n.x,y:e+n.y}}function Tc(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(t-=n.x,e-=n.y,0!==i){const n=Math.cos(i),r=Math.sin(i),s=t*r+e*n;t=t*n-e*r,e=s}return 1!==r.x||1!==r.y?{x:t*r.x+n.x,y:e*r.y+n.y}:{x:t+n.x,y:e+n.y}}function Ic(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=zc(t,e,n,i,r);return n&&(s.x-=n.x,s.y-=n.y),s}return zc(t,e,n=n||this.rotatePoint,i,r)}function Oc(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=Tc(t,e,void 0,i+(this._delta?.theta??0),r);return n&&(s.x+=n.x,s.y+=n.y),s}n=n||this.rotatePoint;const{theta:s=0,tx:o=0,ty:a=0,sx:c=1,sy:h=1}=this._delta||{};if(0===s&&0===o&&0===a&&1===c&&1===h)return Tc(t,e,n,i,r);return Tc(t+o,e+a,{x:n.x+o,y:n.y+a},i+s,{x:r.x*c,y:r.y*h})}function Ec(t,e,n){n=n||this.rootModel;const i=this.transcoordS2T(t,e,n);return Tc(i.x,i.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function jc(t,e,n){n=n||this.rootModel,Ac.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Ac.push(t);let i=this.transcoordS2P(t,e);for(let t=0;t<Ac.length;t++){const e=Ac[t],n=e.bounds;i.x+=n.left,i.y+=n.top,i=e.transcoordS2P(i.x,i.y)}return i}function Pc(t,e,n){n=n||this.rootModel,Ac.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Ac.push(t);let i={x:t,y:e};for(let t=Ac.length-1;t>=0;t--){const e=Ac[t];i=e.transcoordP2S(i.x,i.y);const n=e.bounds;i.x-=n.left,i.y-=n.top}return i}function Cc(t,e,n){const i=this.transcoordT2P(t,e,n);return this.transcoordP2S(i.x,i.y)}function Rc(t,e,n){const i=this.rootModel,r=this.transcoordS2T(t,e,i);return n.transcoordT2S(r.x,r.y,i)}function Fc(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:i={x:0,y:0},scale:r={x:1,y:1},rotation:s=0}=n.model,o=zc(t,e,i,s,r);return i&&(o.x-=i.x,o.y-=i.y),n===this?o:this.transcoordT2S(o.x,o.y,n)}function Dc(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let i;if(i=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return i;const{translate:r={x:0,y:0},rotation:s=0,scale:o={x:1,y:1}}=n.model;return i=Tc(i.x,i.y,void 0,s+n._delta.theta,o),r&&(i.x+=r.x,i.y+=r.y),i}function Nc(t){const e=t.element,n=t.fillStyle,i=e.style;if(n)if("string"==typeof n)i.backgroundColor=n;else switch(n.type){case"pattern":if(i.backgroundImage="url("+n.image+")",i.backgroundColor="transparent",n.fitPattern?i.backgroundSize="100% 100%":n.width||n.height?i.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:i.backgroundSize="contain",n.fitPattern)i.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:r,align:s,color:o}=n;if(r&&(i.backgroundRepeat="no-repeat"),o&&(i.backgroundColor=o),s)switch(s){case"center":i.backgroundPosition="center center";break;case"left-top":i.backgroundPosition="left top";break;case"left-bottom":i.backgroundPosition="left bottom";break;case"right-top":i.backgroundPosition="right top";break;case"right-bottom":i.backgroundPosition="right bottom";break;case"left":i.backgroundPosition="left center";break;case"right":i.backgroundPosition="right center";break;case"top":i.backgroundPosition="center top";break;case"bottom":i.backgroundPosition="center bottom"}else t||e?i.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete i.backgroundPosition}break;case"gradient":i.background=function(t,e){const n=e.colorStops,i=e.gradientType;if(n instanceof Array&&n.length>0)switch(i){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:i}=t.bounds;switch(e){case"center":return[n/2,i/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,i];default:return[n,i]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else i.background="transparent"}const Lc={x:1,y:1},Bc={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function Uc(t,e){let n=this.bounds,i=this.rotatePoint;const r=this.get("rotation"),s=this.get("scale");if(t){const i=t.call(e,n);i&&(n=i)}const{left:o,top:a,width:c,height:h}=n;let l=[{x:o,y:a},{x:o+c,y:a+h}];l=l.map(t=>Tc(t.x,t.y,i,r,s));let u=l[0],d=l[1];i={x:(u.x+d.x)/2,y:(u.y+d.y)/2},l=l.map(t=>zc(t.x,t.y,i,r,s)),u=l[0],d=l[1],this.bounds={left:u.x,top:u.y,width:d.x-u.x,height:d.y-u.y}}function Wc(t,e,n){let i=this.path,r=this.rotatePoint;t&&(i=t.call(n,i));let s=i.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(n,s);t&&(s=t)}const o={x:0,y:0};let a,c,h,l;i=s.map(t=>this.fromParent(t.x,t.y,o)),a=c=i[0].x,h=l=i[0].y;for(let t=1;t<i.length;t++){const e=i[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<h?h=e.y:e.y>l&&(l=e.y)}r={x:(a+c)/2,y:(h+l)/2},r=this.toParent(r.x,r.y,o),this.path=s.map(t=>{const e=this.fromParent(t.x,t.y,r);return{...t,x:e.x,y:e.y}})}const qc=new Map;let $c=null;function Vc(){$c&&($c(),$c=null)}function Yc(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var Hc=new class{add(t){var e;Yc(t)&&!qc.has(t)&&(qc.set(t,0),e=t?.root,$c||($c=vn.subscribe(t=>{if(0===t)return;const e=[];for(const[n,i]of qc){if(!Yc(n)){e.push(n);continue}const r=i+t;r>=n.retention?e.push(n):qc.set(n,r)}for(const t of e){qc.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){wa("RetentionManager removeSelf failed:",t)}}0===qc.size&&Vc()},{description:"retention timer",component:e,getTargets:()=>Array.from(qc.keys()),metadata:{get count(){return qc.size},get preview(){return Array.from(qc.entries()).slice(0,3).map(([t,e])=>({type:t?.state?.type,id:t?.state?.id??"-",retentionMs:t?.retention,remainingMs:Math.max(0,Math.round(t?.retention-e))}))}}})))}remove(t){qc.delete(t)&&0===qc.size&&Vc()}touch(t){t&&qc.has(t)&&qc.set(t,0)}dispose(){Vc(),qc.clear()}get length(){return qc.size}};const Gc=function(t){return t};function Xc(t){const e=t.indexOf("||");let n="",i="";-1!=e&&(n=t,i=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const r=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),s=r.slice(1);return{defaultValue:i,match:t,originText:n||t,target:r[0],accessor:s.length>0?function(t){return s.reduce((t,e)=>t?t[e]:void 0,t)}:Gc}}function Zc(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>Xc(t))[0];if(n)return n.accessor(this.getState(n.target));const i=(e.match(/\${[^}]*}/)||[]).map(t=>Xc(t))[0];if(i){const t=this.root.findById(i.target);return i.accessor(this.getState(t))}return t}function Jc(t,e){if(!t)return;const n=String(t),i=e||Ho,r=(n.match(/#{(\S*)}/gi)||[]).map(t=>Xc(t)),s=(n.match(/\${[^}]*}/gi)||[]).map(t=>Xc(t));if(0==r.length&&0==s.length)return n;let o=n;return r.forEach(t=>{const e=i(t.accessor(this.getState(t.target)));o=o.replace(t.match,void 0===e?"":e)}),s.forEach(t=>{const e=this.root.findById(t.target),n=i(t.accessor(e&&e.data));o=o.replace(t.match,void 0===n?"":n)}),o}function Qc(t,e,n){if(!t)return;const i=n||Ho,r=String(t),s=(r.match(/#{[^}]*}/gi)||[]).map(t=>Xc(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>Xc(t));return 0!=s.length||0!=o.length?function(){let t=r;return s.forEach(n=>{const r=i(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===r?n.defaultValue||"":r)}),o.forEach(n=>{const r=e.root.findById(n.target),s=i(n.accessor(r&&r.data));t=t.replace(n.originText,void 0===s?n.defaultValue||"":s)}),t}:void 0}class Kc{constructor(){}static registerDecorator(t,e){Kc.constructors.set(t,e)}static create(t,e,n={},i){const r=Kc.constructors.get(t);if(!r)throw new Error(`unknown decorator type: ${t}`);return new r(i,e,n)}}function th(t,e){const n=e.x-t.x,i=e.y-t.y,r=Math.sqrt(n*n+i*i);if(!Wn(t))return r;const s=qn(t,e,t.bulge);if(!s)return r;const o=Math.min(s.radius,r/2),a=2*Math.asin(o/s.radius);return s.radius*a}function eh(t,e){const n=t.path.slice();if(!n||!n.length)return void wa("path should not be empty");let i=1;const r=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[i];)r.push(th(n[i-1],n[i])),i++;const s=r.reduce(function(t,e){return t+e},0);i=0;let o=0;do{o+=r[i++]}while(o/s<e);o-=r[--i];e=(e-o/s)*(s/r[i]);const a=n[i%n.length],c=n[(i+1)%n.length],{x:h,y:l}=function(t,e,n){if(Wn(t)){const i=qn(t,e,t.bulge);if(i){let t=i.endAngle-i.startAngle;i.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=i.startAngle+n*t;return{x:i.cx+i.radius*Math.cos(e),y:i.cy+i.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*n),y:t.y+Math.round((e.y-t.y)*n)}}(a,c,e);return t.toScene(h,l)}function nh(t,e){return!1}function ih({x:t,y:e},...n){const i=this.path,r=t,s=e;this.path=i.map(t=>({...t,x:t.x+r,y:t.y+s}))}function rh(t){const e=t??this.center.x,{rotation:n}=this.state,i=this.fillStyle;if(this.set("rotation",2*Math.PI-n),i&&"gradient"===i.type&&"linear"===i.gradientType){const t=Po(i);t.rotation=(Math.PI-parseFloat(i.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({...t,x:2*e-t.x,y:t.y}))}function sh(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}function oh(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let i=t.width-e.width,r=t.height-e.height;i*n>r?r=i*n:i=r/n;let s=t.left-e.left,o=t.top-e.top;return 0!=s&&0!=o?(o=-r,s=-i):0!=s?s=-i:0!=o&&(o=-r),{left:e.left+s,top:e.top+o,width:e.width+i,height:e.height+r}}return t}function ah(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function ch(t){return eh(this,t||0)}function hh(){const t=this.path;let e,n,i,r;e=n=t[0].x,i=r=t[0].y;for(let s=1;s<t.length;s++){const o=t[s];o.x<e?e=o.x:o.x>n&&(n=o.x),o.y<i?i=o.y:o.y>r&&(r=o.y)}return{left:e,top:i,width:n-e,height:r-i}}function lh(t){const e=this.bounds;if(Math.round(100*t.width)/100==Math.round(100*e.width)/100&&Math.round(100*t.height)/100==Math.round(100*e.height)/100&&Math.round(100*t.left)/100==Math.round(100*e.left)/100&&Math.round(100*t.top)/100==Math.round(100*e.top)/100)return;const n=0==e.width?1:t.width/e.width,i=0==e.height?1:t.height/e.height;this.path=this.path.map(r=>({...r,x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i}))}function uh(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function dh(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const e=this.center;if(Math.round(100*t.x)/100==Math.round(100*e.x)/100&&Math.round(100*t.y)/100==Math.round(100*e.y)/100)return;const n=t.x-e.x,i=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+n,y:t.y+i}))}function ph(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function fh(t){const{x:e,y:n,z:i}=t||{};this.center={x:e,y:n},isNaN(i)||this.setState("zPos",Number(i))}function mh(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function yh(t){const{x:e,y:n,z:i}=t;this.setState({rotationX:e,rotationY:n,rotation:-i})}function gh(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function bh(t){const{width:e,height:n,depth:i}=t,{top:r,left:s}=this.bounds;this.bounds={top:r,left:s,width:e,height:n},this.setState("depth",i)}function vh(){return wa("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function xh(t){wa("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function wh(){return this.path}function _h(){return this.center}function Mh(){return this.nature.mutable}function Sh(){return this.nature.resizable&&!this.stuck}function kh(){return this.nature.rotatable&&!this.stuck}Kc.constructors=new Map;const Ah={x:1,y:1};function zh(t,e,n){const{offsetX:i,offsetY:r,blur:s,color:o}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??Ah;t.shadowOffsetX=i*a.x*cc,t.shadowOffsetY=r*a.y*cc,t.shadowBlur=s*a.x*cc,t.shadowColor=o}function Th(t){const e=t?.app;if(!e?.isEditMode)return!1;const n=e.focusFilter;return!!(t.hidden||n&&!n(t))}function Ih(t){t.save(),this.prerender(t);const e=this.app,n=!0===t.__inHiddenSubtree;e?.isEditMode&&((Th(this)||n)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=n,t.restore()}function Oh(t){const e=this.rotatePoint,{scale:n,rotation:i,shadow:r,alpha:s}=this.state,o=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(i||0)+this._delta.theta,{tx:h=0,ty:l=0}=this._delta,u=(s||1)-this._delta.fade;(h||l)&&t.translate(h,l),(1!=o||1!=a||c)&&(t.translate(e.x,e.y),1==o&&1==a||t.scale(o,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),u&&(t.globalAlpha=u),r&&zh(t,r,this)}function Eh(t){}function jh(t){this.drawText(t)}function Ph(t,e){t(this)}function Ch(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{wa(t)})}function Rh(t){!this.textHidden&&this.text&&this.hasTextProperty&&Mc(t,this.textBounds,this.textLines(t),this.state)}function Fh(t,e){yc(t,e?{...this.state,...e}:this.state)}function Dh(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(dc(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function Nh(){return this.get("strokeStyle")}function Lh(t){this.set("strokeStyle",t)}function Bh(){return this.getState("fillStyle")}function Uh(t){this.setState("fillStyle",t)}function Wh(){return this.get("fontColor")}function qh(t){this.set("fontColor",String(Ho(t)))}function $h(){return this.getState("rotation")}function Vh(t){this.setState("rotation",Number(Ho(t)))}function Yh(){return this.app.isEditMode?["decotag","data-spread"]:[]}function Hh(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function Gh(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function Xh(t){this.setState("hidden",t)}function Zh(){return this.state.tag}function Jh(t){this.setState("tag",t)}function Qh(){}function Kh(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function tl(){const t=this.getState("text");return null==t?"":String(t)}function el(t){const{textWrap:e,supportMarkdown:n}=this.state;return xc(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function nl(){return wc(this.model)}function il(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function rl(){return this._text_substitutor||(this._text_substitutor=Qc(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function sl(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,i,r,s,o,a,c,h,l,u,d,p=t.length,f=t.search(/[0-9\-\+#]/),m=f>0?t.substring(0,f):"",y=t.split("").reverse().join(""),g=y.search(/[0-9\-\+#]/),b=p-g,v=t.substring(b,b+1),x=b+("."===v||","===v?1:0),w=g>0?t.substring(x,p):"";if(n=(e="-"===(t=t.substring(f,x)).charAt(0)?-e:+e)<0?e=-e:0,i=t.match(/[^\d\-\+#]/g),r=".",s=i&&i[1]&&i[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),h=e.split("."),(!h[1]||h[1]&&h[1].length<=a)&&(e=(+e).toFixed(a+1)),l=t[0].split(s),t[0]=l.join(""),o=t[0]&&t[0].indexOf("0"),o>-1)for(;h[0].length<t[0].length-o;)h[0]="0"+h[0];else 0===+h[0]&&(h[0]="");if((e=e.split("."))[0]=h[0],c=l[1]&&l[l.length-1].length,c){for(u=e[0],y="",b=u.length%c,p=u.length,x=0;x<p;x++)y+=u.charAt(x),!((x-b+1)%c)&&x<p-c&&(y+=s);e[0]=y}return e[1]=t[1]&&e[1]?"."+e[1]:"",i=e.join(""),"0"!==i&&""!==i||(n=!1),d="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",m+(d+i)+w}(t,this.textSubstitutor()):this.textSubstitutor()}function ol(t){delete this._text_substitutor;const e=Ho(t);this.setState("text",null==e?"":String(e))}function al(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:i}=this.state;i||=0,t||=0,e||=0,n||=0;const{left:r,top:s,width:o,height:a}=this.bounds;return{left:r+e,top:s+t,width:Math.max(o-e-n,0),height:Math.max(a-t-i,0)}}function cl(){return 0}function hl(){return!!this._textHidden}function ll(t){this._textHidden=!!t,this.invalidate()}function ul(){return!0}function dl(t){return t}function pl(t){return Math.pow(t,2)}function fl(t){return 1-Math.sin(Math.acos(t))}function ml(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function yl(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function gl(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var bl={linear:dl,quad:pl,circ:fl,back:ml,bounce:yl,elastic:gl},vl=Object.freeze({__proto__:null,back:ml,bounce:yl,circ:fl,default:bl,elastic:gl,linear:dl,quad:pl});class xl{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:i,ease:r}=this.config;let s;s="string"==typeof n?bl[n]:n,this.delta="out"===r?function(t,e){return function(n){return 1-t(1-n,e)}}(s,i):"inout"===r?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(s,i):s,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:i=0,onComplete:r}=this.config;this._started=!0;const s=this.config?.type??"animation";let o=0,a=0;const c=()=>vn.simTime,h=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(r);0==o&&(o=c(),this.client?.touch?.());const l=c()-o,u=Math.max((l-e)%(t+i),0)/t,d=i<=0&&a>u;if(a=u,u>=1||d){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(r),void(o=0);if(i>0)return this._unsub?.(),this._unsub=null,void(this._timeout=setTimeout(()=>{this._timeout=null,this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(()=>{this._timeout=null,this._started&&(this._unsub=vn.subscribe(h,{description:`animation: ${s}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:i}}))},i/2)},i/2))}else this.step(this.delta(u)),this.client&&this.client.invalidate?.()};this._unsub=vn.subscribe(h,{description:`animation: ${s}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:i}})}stop(t){this._unsub&&(this._unsub(),this._unsub=null),this._timeout&&clearTimeout(this._timeout),this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const wl={rotation:class extends xl{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends xl{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let i=t*n;t<1/4?i*=-1:t<3/4?i-=2*e:i=n-i,this.client.delta?.("theta",i)}},heartbeat:class extends xl{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let i;i=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:i,sy:i,sz:i})}},moving:class extends xl{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends xl{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let i={tx:0,ty:0};const r=this.client.delta("");r&&"object"==typeof r&&"tx"in r&&"ty"in r&&(i=r);const{tx:s,ty:o}=i,a=n.outline(t),{x:c,y:h}=this.client.center,l=this.client.toScene(c,h);this.client.delta({tx:a.x-l.x+s,ty:a.y-l.y+o})}},fade:class extends xl{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,i=Math.max(Math.min(e,n,1),0),r=2*(Math.min(Math.max(e,n,1),1)-i);let s;s=t<.5?r*t:(1-t)*r,this.client.delta?.("fade",s)}},waypoint:class extends xl{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,i=t.center,{x:r,y:s}=e.toScene(n.x,n.y),{x:o,y:a}=t.toScene(i.x,i.y);this._startX=r,this._startY=s,this._endX=o,this._endY=a;const c=this.config.yawOffset??Math.PI/2,h=Math.atan2(a-s,o-r)+c;this.client.location={x:r,y:s},this.client.setState("rotation",h),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};const _l={gradation:function(t,e,n){const{subType:i,from:r,to:s,colors:o}=n;let a;switch(i){case"linear":default:a=e.createLinearGradient(r.x,r.y,s.x,s.y);break;case"radial":a=e.createRadialGradient(r.x,r.y,r.r,s.x,s.y,s.r)}o&&(o.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:zh};function Ml(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:n,component:i,step:r=()=>{},onStart:s,onProgress:o,onComplete:a,options:c,repeat:h=!1,delta:l}=t;let u;u="string"==typeof l?vl[l]:l||dl,"out"===n?u=function(t,e){return function(n){return 1-t(1-n,e)}}(u,c):"inout"===n&&(u=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(u,c));let d=!1,p=null;return{start:function(){if(d)return this;if(i?.root?.app?.suppressAnimations)return this;d=!0,s&&s();let t=0;const n=()=>vn.simTime;return p=vn.subscribe(()=>{if(!d)return;if(i?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=n());const s=(n()-t)/e,a=h?s%1:Math.min(s,1);r(u(a,c)),o&&o(a),!(s>=1)||h&&d||(this.stop(),t=0)},{description:"animate()",component:i,metadata:{duration:e,repeat:h}}),this},stop:function(){return d=!1,p&&(p(),p=null),a&&a(),this}}}({component:this,...t}),this._animate}function Sl(t,e){return function(t,e,n){const i=_l[n.type];i&&i(t,e,n)}(this,t,e)}const kl=100;function Al(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*kl)/kl}return e}}function zl(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*kl)/kl):delete t[e]:"object"==typeof n&&zl(n)}return t}function Tl(...t){return JSON.stringify(this.hierarchy,Al,...t)}function Il(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Ol(t){this.rootModel.closeScene(t)}function El(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function jl(){this.parent&&this.parent.invalidate()}function Pl(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function Cl(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function Rl(){return this.getState("data")}function Fl(t){this.setState("data",t),this.touch()}function Dl(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function Nl(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function Ll(){return Number(this.get("retention"))||0}function Bl(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const n=e.type?wl[e.type]:void 0;return n?new n(t,e):null}(this,t.oncreate))}return this._animation}}function Ul(){return!!this.animation?.started}function Wl(t){this.animation&&(this.animation.started=t)}function ql(){}function $l(t,e,n,i){const r=e.get("class");if(!r)return!1;return(r.split(" ")||[]).indexOf(t.substr(1))>=0}function Vl(t,e,n,i){return t==e.get("type")}function Yl(t,e,n,i,r,s){return t(e,n,i,r)&&s.push(n),n.components&&n.components.forEach(n=>{Yl(t,e,n,i,r,s)}),s}function Hl(t,e,n,i){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function Gl(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let i;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":i=$l;break;case"(":i=Hl;break;default:i=Vl}return Yl(i,t,e,n,e,[])}function Xl(t,...e){if(t(this,...e))return this}function Zl(t,...e){return"string"==typeof t?Gl(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function Jl(t,e,n){if(!this.capturable||n?.(this))return!1;const i=this.fromParent(t,e);return this.contains(i.x,i.y)?this:void 0}function Ql(t){return this.anchors.find(e=>e.name===t)}function Kl(t){return!0}function tu(t){return this._parent.getContext(t??this)}function eu(){return this.isRoot()?this:this.parent&&this.parent.root}function nu(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function iu(){return this._parent}function ru(t){this._parent=t}function su(){return this.nature.anchors||[]}function ou(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function au(){if(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))return!0;const t=this.app?.focusFilter;return!(!this.app?.isEditMode||!t||t(this))}function cu(){if(!1===this.get("capturable"))return!1;const t=this.app?.isEditMode;if(!t&&this.hidden)return!1;if(t){if(this.get("locked"))return!1;const t=this.app.focusFilter;if(t&&!t(this))return!1}return!0}function hu(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function lu(){return this.app&&this.app.isViewMode&&this.state.origin||""}function uu(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function du(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const pu={},fu={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},mu=[],yu=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),gu={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let bu=0;const vu={};const xu=new FinalizationRegistry(t=>{!function(t){bu--;let e=vu[t];e||(e=vu[t]={up:0,down:0}),e.down++}(t)});class wu{static get nature(){return fu}static register(t,e){if(!e)return pu[t];pu[t]=e}static types(){return Object.keys(pu)}static get residents(){return vu}static get residentsCount(){return bu}static registerDecorator(t,e){Kc.registerDecorator(t,e)}constructor(t,e){if(this._readyInvoked=!1,this._app=e,this._model=t||{},this._model.event&&"object"==typeof this._model.event&&!Array.isArray(this._model.event)&&!Array.isArray(this._model.eventHandlers)){const t=function(t){if(!t||"object"!=typeof t||Array.isArray(t))return[];const e={tap:"click",hover:"mouseenter",dblclick:"dblclick",longpress:"longpress"},n=[];for(const i of Object.keys(t)){const r=e[i];if(!r)continue;const s=t[i];if(s&&"object"==typeof s){if("script"===s.action){const t="string"==typeof s.value?s.value:s.value&&"object"==typeof s.value?s.value.script:"";t&&n.push({trigger:r,action:"script",code:t,target:s.target});continue}n.push({trigger:r,action:s.action,target:s.target,value:s.value,options:{emphasize:s.emphasize,restore:s.restore,pressed:s.pressed,...s.options??{}}})}}return n}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=Po(gu),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??!0))&&(this.animation.started=!0),this.clearCache(),Hc.add(this),function(t){bu++;let e=vu[t];e||(e=vu[t]={up:0,down:0}),e.up++}(this._model.type),xu.register(this,this._model.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}invokeReady(){if(!this._readyInvoked)return this._readyInvoked=!0,this.ready()}touch(){this.updatedAt=performance.now(),Hc.touch(this)}clearCache(...t){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=Po(gu))}dispose(){this.resetAnimation(),this.disposeMappings();const t=this.parent;t&&"function"==typeof t.removeItem&&-1!==t._items?.indexOf?.(this)&&t.removeItem(this),t?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&Hc.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&Hc.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get refid(){return this.get("refid")}get hierarchy(){const t=Po(this._model);return this.volatile.forEach(e=>{delete t[e]}),zl(t)}get volatile(){return mu}_applyProps(t,e,n){const i={},r={};let s=!1;const o=Po(e),a=this;if(Object.getOwnPropertyNames(o).forEach(function(e){const c=n.getBeforeVal(e),h=o[e];!n.sensitive&&function(t,e){return cs(t,e)}(c,h)||(r[e]=c,i[e]=h,t[e]=h,n.clearState&&delete a._state[e],s=!0)}),s){this._cachedState=null;Object.keys(i).some(t=>!yu.has(t))&&this.clearCache(),i.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(i,r),i.hasOwnProperty("fillStyle")&&this.onchangeFill(i,r),n.afterFillStyle&&n.afterFillStyle(i,r),i.hasOwnProperty("data")&&this.onchangeData(i,r),this.onchange&&this.onchange(i,r),this.trigger("change",i,r)}return this}contains(t,e){return nh.call(this,t,e)}move(t,...e){ih.call(this,t,...e)}symmetryX(t){rh.call(this,t)}symmetryY(t){sh.call(this,t)}adjustResize(t,e,n){return oh.call(this,t,e,n)}adjustRotation(t,e){return ah.call(this,t,e)}outline(t){return ch.call(this,t)}get bounds(){return hh.call(this)}set bounds(t){lh.call(this,t)}get center(){return uh.call(this)}set center(t){dh.call(this,t)}get location(){return ph.call(this)}set location(t){fh.call(this,t)}get rotate(){return mh.call(this)}set rotate(t){yh.call(this,t)}get dimension(){return gh.call(this)}set dimension(t){bh.call(this,t)}get path(){return vh.call(this)}set path(t){xh.call(this,t)}get drawPath(){return wh.call(this)}get rotatePoint(){return _h.call(this)}get mutable(){return Mh.call(this)}get resizable(){return Sh.call(this)}get rotatable(){return kh.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&Ih.call(this,t)}prerender(t){Oh.call(this,t)}render(t){Eh.call(this,t)}postrender(t){jh.call(this,t)}prepare(t,e){Ph.call(this,t,e)}prepareIf(t){Ch.call(this,t)}drawText(t){Rh.call(this,t)}drawStroke(t,e){Fh.call(this,t,e)}drawFill(t,e){Dh.call(this,t,e)}get strokeStyle(){return Nh.call(this)}set strokeStyle(t){Lh.call(this,t)}get fillStyle(){return Bh.call(this)}set fillStyle(t){Uh.call(this,t)}get fontColor(){return Wh.call(this)}set fontColor(t){qh.call(this,t)}get rotation(){return $h.call(this)}set rotation(t){Vh.call(this,t)}get decorators(){return Yh.call(this)}get decotag(){return Hh.call(this)}get hidden(){return Gh.call(this)}set hidden(t){Xh.call(this,t)}get tag(){return Zh.call(this)}set tag(t){Jh.call(this,t)}get appendum(){return Qh.call(this)}set appendum(t){Kh.call(this,t)}defaultTextSubstitutor(){return tl.call(this)}textLines(t){return el.call(this,t)}get font(){return nl.call(this)}get lineHeight(){return il.call(this)}get textSubstitutor(){return rl.call(this)}get text(){return sl.call(this)}set text(t){ol.call(this,t)}get textBounds(){return al.call(this)}get textRotation(){return cl.call(this)}get textHidden(){return hl.call(this)}set textHidden(t){ll.call(this,t)}get hasTextProperty(){return ul.call(this)}animate(t){return Ml.call(this,t)}effect(t,e){return Sl.call(this,t,e)}serialize(...t){return Tl.call(this,...t)}trim(){Il.call(this)}closeScene(t){Ol.call(this,t)}delta(t,e){return El.call(this,t,e)}invalidate(){jl.call(this)}get value(){return Pl.call(this)}set value(t){Cl.call(this,t)}get data(){return Rl.call(this)}set data(t){Fl.call(this,t)}set tap(t){Dl.call(this,t)}get mappings(){return Nl.call(this)}get retention(){return Ll.call(this)}get animation(){return Bl.call(this)}get started(){return Ul.call(this)}set started(t){Wl.call(this,t)}get controls(){return ql.call(this)}findFirst(t,...e){return Xl.call(this,t,...e)}findAll(t,...e){return Zl.call(this,t,...e)}capture(t,e,n){return Jl.call(this,t,e,n)}findAnchor(t){return Ql.call(this,t)}isDescendible(t){return Kl.call(this,t)}getContext(t){return tu.call(this,t)}get root(){return eu.call(this)}get rootModel(){return nu.call(this)}get parent(){return iu.call(this)}set parent(t){ru.call(this,t)}get anchors(){return su.call(this)}get scalable(){return ou.call(this)}get stuck(){return au.call(this)}get capturable(){return cu.call(this)}get position(){return hu.call(this)}get origin(){return lu.call(this)}get offset(){return uu.call(this)}get app(){return du.call(this)}drawEffect(t){ac.call(this,t)}prepareFill(t,e){pc.call(this,t,e)}prepareFillIf(t){fc.call(this,t)}onchangeFill(t,e){mc.call(this,t,e)}drawImage(t,e,n,i,r,s){oc.call(this,t,e,n,i,r,s)}mutateBounds(t,e){Uc.call(this,t,e)}mutatePath(t,e,n){Wc.call(this,t,e,n)}access(t){return Zc.call(this,t)}substitute(t,e){return Jc.call(this,t,e)}onchangeMappings(t,e){sc.call(this,t,e)}onchangeData(t,e){nc.call(this,t,e)}buildMappings(){ic.call(this)}executeMappings(t){ec.call(this,t)}disposeMappings(){rc.call(this)}ondropfile(t,e){kc.call(this,t,e)}transcoordS2P(t,e,n){return Oc.call(this,t,e,n)}transcoordP2S(t,e,n){return Ic.call(this,t,e,n)}transcoordS2T(t,e,n){return jc.call(this,t,e,n)}transcoordT2P(t,e,n){return Pc.call(this,t,e,n)}transcoordT2S(t,e,n){return Cc.call(this,t,e,n)}transcoordS2TR(t,e,n){return Ec.call(this,t,e,n)}transcoordS2O(t,e,n){return Rc.call(this,t,e,n)}transcoordC2S(t,e,n){return Fc.call(this,t,e,n)}transcoordS2C(t,e,n){return Dc.call(this,t,e,n)}toParent(t,e,n){return Oc.call(this,t,e,n)}fromParent(t,e,n){return Ic.call(this,t,e,n)}toScene(t,e,n){return jc.call(this,t,e,n)}fromScene(t,e,n){return Cc.call(this,t,e,n)}toLocal(t,e,n){return Fc.call(this,t,e,n)}toGlobal(t,e,n){return Dc.call(this,t,e,n)}toOther(t,e,n){return Rc.call(this,t,e,n)}on(t,e,n){return ma.call(this,t,e,n)}off(t,e,n){return ya.call(this,t,e,n)}once(t,e,n){return ga.call(this,t,e,n)}trigger(t,...e){return ba.call(this,t,...e)}delegate_on(t){return va.call(this,t)}delegate_off(t){return xa.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}wu.capabilities=[],wu.requires3d=!1,wu.union=function(t){let e=0,n=0,i=0,r=0,s=!1;return t.forEach(t=>{s?(e=Math.min(t.left,e),n=Math.min(t.top,n),i=Math.max(t.left+t.width,i),r=Math.max(t.top+t.height,r)):(e=t.left,n=t.top,i=t.left+t.width,r=t.top+t.height,s=!0)}),{left:e,top:n,width:i-e,height:r-n}},wu.transcoordR=zc,wu.transcoordRR=Tc,wu.createCanvas=uc,wu.memoize=Ma,wu.mixin=function t(e,n){if(n instanceof Array)n.forEach(n=>t(e,n));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(n)>=0)return e;if(e.mixingIn.indexOf(n)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(n),n.call(e),e.mixingIn.pop(),e.mixedIn.push(n)}return e},wu.drawText=Mc,wu.font=wc,wu.textLines=xc,wu.drawStroke=yc,wu.drawFill=dc,wu.reposition=function(t){let{id:e,scale:n=Lc,bold:i,italic:r,fontFamily:s="",textAlign:o,textBaseline:a,textOverflow:c,paddingTop:h,paddingBottom:l,paddingLeft:u,paddingRight:d,fontSize:p=hc.FONT_SIZE,lineWidth:f=0,lineHeight:m,lineDash:y}=t.state;l||=0,h||=0,u||=0,d||=0;const g=t.state.class,{strokeStyle:b,rotation:v=0,fontColor:x,hidden:w}=t,{left:_,top:M,width:S,height:k}=t.bounds,A=t.element;if(A.hidden=!t.app?.isEditMode&&w,e&&(A.id=e),g&&(A.className=g),Object.assign(A.style,Bc,{fontFamily:s,fontSize:p+"px",width:S+"px",height:k+"px",paddingTop:h+"px",paddingRight:d+"px",paddingBottom:l+"px",paddingLeft:u+"px",border:f+"px",borderColor:b,borderStyle:f>0?y||hc.LINE_DASH:"",color:x,fontWeight:i?"bold":"",fontStyle:r?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:a,lineHeight:void 0===m?"":m+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:_+"px",top:M+"px"}),Nc(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,i=e.offsetY??e.top??0,r=e.blur??e.blurSize??0,s=e.color??"transparent";t.element.style.boxShadow=`${n}px ${i}px ${r}px ${s}`}(t),t.isIn3DSpace())return;const z=t.delta(),T=(n&&n.x||1)*z.sx,I=(n&&n.y||1)*z.sy,O=(v||0)+z.theta,E=z.tx||0,j=z.ty||0;A.style.transform=`rotate(${O}rad) translate(${E}px, ${j}px) scale(${T}, ${I}) perspective(1px)`},wu.RetentionManager=Hc,wu.template=function(t,e,n){var i=Ks.imports._.templateSettings||Ks;n&&As(t,e,n)&&(e=void 0),t=Zs(t),e=Ts({},e,i,Bs);var r=Ts({},e.imports,i.imports,Bs),s=Lr(r),o=function(t,e){return Ds(e,function(e){return t[e]})}(r,s);hs(s,function(t){if(io.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,h=0,l=e.interpolate||so,u="__p += '",d=RegExp((e.escape||so).source+"|"+l.source+"|"+(l===qs?ro:so).source+"|"+(e.evaluate||so).source+"|$","g"),p=ao.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,function(e,n,i,r,s,o){return i||(i=r),u+=t.slice(h,o).replace(oo,Ws),n&&(a=!0,u+="' +\n__e("+n+") +\n'"),s&&(c=!0,u+="';\n"+s+";\n__p += '"),i&&(u+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),h=o+e.length,e}),u+="';\n";var f=ao.call(e,"variable")&&e.variable;if(f){if(io.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(c?u.replace(to,""):u).replace(eo,"$1").replace(no,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var m=Fs(function(){return Function(s,p+"return "+u).apply(void 0,o)});if(m.source=u,Rs(m))throw m;return m},wu.buildSubstitutor=Qc,["rotatePoint","font","lineHeight","retention"].forEach(t=>wu.memoize(wu.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>wu.memoize(wu.prototype,t,!0));const _u=new WeakMap,Mu=new WeakMap;function Su(t){const e=t?.state?.id;return null==e||""===e?null:String(e)}function ku(t,e){if(!t||null==e)return null;const n=_u.get(t),i=n?.get(String(e));return i?function(t,e){const n=e?.parent;return!!n&&Array.isArray(n._items)&&n._items.includes(e)&&n.root===t}(t,i)?i:(n.delete(String(e)),null):null}function Au(t,e){zu(e);const n=t?.root,i=Su(e);if(!n||!i||n===t)return;const r=_u.get(n)??new Map;_u.set(n,r),r.set(i,e),Mu.set(e,{root:n,id:i})}function zu(t){const e=t&&Mu.get(t);if(!e)return;Mu.delete(t);const n=_u.get(e.root);n&&n.get(e.id)===t&&n.delete(e.id)}const Tu=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]);function Iu(t){return class extends t{constructor(){super(...arguments),this._itemIssues=[],this._itemsStale=!1,this._lastItemIds=new Set}_itemsFromData(){return!0}_currentKeyOf(t){const e=this._keyedById()?t?.state?.id:t?.[mn];return null!=e?String(e):null}get itemIssues(){return this._itemIssues}get itemsStale(){return this._itemsStale}_sayItemIssues(t,e){const n=this._itemIssues.length>0||this._itemsStale;this._itemIssues=t,this._itemsStale=e,(n||t.length>0||e)&&this.trigger?.("item-issues",this,t,e)}_keyedById(){return!1}async ready(){if(await super.ready(),!this._itemsFromData())return;const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)&&this._itemsFromData()){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(!this._itemsFromData())return this.state?.data;if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){if(this._keyedById())return this._reconcileItemsById(t);const e=new Map;for(const n of t){const t=this._recordKey(n);t&&e.set(t,n)}const n=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&n.set(e,t)}for(const[t,i]of n)if(!e.has(t)){try{this.removeItem(i,!0)}catch{}zu(i);try{i?.dispose?.()}catch{}}for(const[t,i]of e){if(n.has(t))continue;if(null==i.itemId)continue;const e=this._createItemFromRecord(i);if(e){e[mn]=t;try{this.handoverIn(e)}catch{}}}for(const[t,i]of e){const e=n.get(t);if(e&&i.itemState&&"function"==typeof e.setState)try{e.setState(i.itemState)}catch{}}}_reconcileItemsById(t){const e=new Map;t.forEach((t,n)=>{const i=this._recordKey(t);i&&(e.get(i)??e.set(i,[]).get(i)).push(n)});const n=[...e].filter(([,t])=>t.length>1);if(n.length>0)return void this._sayItemIssues(n.map(([t,e])=>({code:"item-duplicate",id:t,at:e})),!0);const i=new Map;for(const e of t)i.set(this._recordKey(e),e);const r=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&r.set(e,t)}const s=this._lastItemIds,o=this.root,a=[];for(const[t,e]of r)i.has(t)||setTimeout(()=>{if(e.parent===this){try{this.removeItem(e,!0)}catch{}zu(e);try{e?.dispose?.()}catch{}}},0);for(const[t,e]of i){if(r.has(t))continue;const n=ku(o,t);let i,c=!1;if(n&&n.parent!==this){if(s.has(t)){const e=n.parent?.state?.id;a.push({code:"item-repeat-report",id:t,holder:null!=e?String(e):null});continue}i=n,c=!!n.parent}else i=this._createItemFromRecord(e);if(!i)continue;i[mn]=e.slotId;const h=c?this.itemMoveAnimation():null,l={...e.slotId?{slotId:e.slotId}:{},...h?{animated:!0,...h}:{}};try{this.handoverIn(i,Object.keys(l).length?l:void 0)}catch{}}for(const[t,e]of i){const n=r.get(t);if(n){if(e.itemState&&"function"==typeof n.setState)try{n.setState(e.itemState)}catch{}if(e.itemType&&n.state?.type!==e.itemType&&"function"==typeof n.setState)try{n.setState({type:e.itemType})}catch{}if(n[mn]!==e.slotId){n[mn]=e.slotId;try{this.handoverIn(n,e.slotId?{slotId:e.slotId}:void 0)}catch{}}}}this._orderItemsAs([...i.keys()]),this._lastItemIds=new Set(i.keys()),this._sayItemIssues(a,!1)}itemMoveAnimation(){return null}_orderItemsAs(t){const e=new Map(t.map((t,e)=>[t,e])),n=this._items.filter(t=>e.has(this._currentKeyOf(t)??"")),i=[...n].sort((t,n)=>e.get(this._currentKeyOf(t))-e.get(this._currentKeyOf(n)));if(i.every((t,e)=>t===n[e]))return;let r=0;for(let t=0;t<this._items.length;t++)e.has(this._currentKeyOf(this._items[t])??"")&&(this._items[t]=i[r++]);const s=this.seatHeldItem;if("function"==typeof s)for(const t of i)s.call(this,t,{slotId:t[mn]})}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,i=[];for(const t of this._items){const e=t[mn];null!=e?n.set(String(e),t):i.push(t)}for(const i of t){const t=n.get(i)??null;e.push(this._slotRecordOf(i,t))}for(const t of i)e.push(this._slotRecordOf("",t));for(const[i,r]of n)t.includes(i)||e.push(this._slotRecordOf(i,r));return e}_recordKey(t){return this._keyedById()?null!=t.itemId?String(t.itemId):"":t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const i of n)i in e&&void 0!==e[i]&&(t[i]=e[i]);return Object.keys(t).length>0?t:void 0}const i={};for(const t of Object.keys(e))Tu.has(t)||t.startsWith("_")||(i[t]=e[t]);return Object.keys(i).length>0?i:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=wu.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}class Ou extends wu{set rotationX(t){this.setState("rotationX",t)}get rotationX(){return this.getState("rotationX")}set rotationY(t){this.setState("rotationY",t)}get rotationY(){return this.getState("rotationY")}set rotationZ(t){this.setState("rotation",t)}get rotationZ(){return this.getState("rotation")}set zPos(t){this.setState("zPos",t)}get zPos(){return this.getState("zPos")}set depth(t){this.setState("depth",t)}get depth(){return this.getState("depth")}postrender(t){this.drawFill(t,void 0),this.drawStroke(t,void 0),super.postrender(t)}render(t){const e=this.drawPath,{round:n=0}=this.state;if(!(e.length<=1)){t.beginPath();for(let i=0;i<e.length;i++){const r=e[(i-1+e.length)%e.length],s=e[(i+e.length)%e.length],o=e[(i+1)%e.length];if(r.x===s.x&&r.y===s.y)continue;const a=Yn(s,n);let c=Math.sqrt((r.x-s.x)*(r.x-s.x)+(r.y-s.y)*(r.y-s.y)),h=0!==c?Math.atan2(r.x-s.x,r.y-s.y):0,l=Math.sin(h)*Math.min(a,c/2)+s.x,u=Math.cos(h)*Math.min(a,c/2)+s.y;const d=a>0||0!==c?{x:l,y:u}:s;c=Math.sqrt((o.x-s.x)*(o.x-s.x)+(o.y-s.y)*(o.y-s.y)),h=0!==c?Math.atan2(o.x-s.x,o.y-s.y):0,l=Math.sin(h)*Math.min(a,c/2)+s.x,u=Math.cos(h)*Math.min(a,c/2)+s.y;const p=a>0||0!==c?{x:l,y:u}:s;if(0==i?t.moveTo(d.x,d.y):t.lineTo(d.x,d.y),a>0&&t.quadraticCurveTo(s.x,s.y,p.x,p.y),Wn(s)){const e=Yn(o,n),i=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),r=0!==i?Math.atan2(s.x-o.x,s.y-o.y):0,a=Math.sin(r)*Math.min(e,i/2)+o.x,c=Math.cos(r)*Math.min(e,i/2)+o.y,h=qn({x:p.x,y:p.y},{x:a,y:c},s.bulge);h&&t.arc(h.cx,h.cy,h.radius,h.startAngle,h.endAngle,h.clockwise)}}t.closePath()}}}function Eu(t){const e=class extends t{contains(t,e){const{left:n,top:i,width:r,height:s,lineWidth:o=0}=this.state,a=o/2;return t<Math.max(n+r,n)+a&&t>Math.min(n+r,n)-a&&e<Math.max(i+s,i)+a&&e>Math.min(i+s,i)-a}set path(t){const e=t[0],n=t[2];this.set({left:e.x,top:e.y,width:n.x-e.x,height:n.y-e.y})}get path(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return{left:t,top:e,width:n,height:i}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){let{round:e=0}=this.model;const{left:n,top:i,width:r,height:s}=this.bounds;t.translate(n,i),t.beginPath(),e=function(t,e,n){return Math.max(0,Math.min(t,Math.min(n,e)/2))}(e,r,s),e>0?t.roundRect(0,0,r,s,e):t.rect(0,0,r,s),t.translate(-n,-i)}};return Ma(e.prototype,"path",!1),Ma(e.prototype,"bounds",!0),e}const ju=new WeakMap,Pu="__canonicalMaterial",Cu="base";function Ru(t){return Math.max(0,Math.round(100*t)/100)}function Fu(t){const e=[];var n;return null!=t.color&&e.push("c:"+(n=t.color,new Nt(n).getHexString())),null!=t.opacityFactor&&Ru(t.opacityFactor)<1&&e.push("o:"+Ru(t.opacityFactor)),e.join("|")}function Du(t,e){const n=Fu(e);if(""===n)return t;let i=ju.get(t);i||ju.set(t,i=new Map);let r=i.get(n);return r||(r=t.clone(),r.userData={__isVariant:!0,[Cu]:t},i.set(n,r)),function(t,e,n){if(null!=n.color&&t.color&&t.color.set(n.color),null!=n.opacityFactor){t.opacity=e.opacity*Ru(n.opacityFactor);const i=t.opacity<1||!!e.transparent;t.transparent!==i&&(t.transparent=i,t.needsUpdate=!0)}}(r,t,e),r}function Nu(t){t.traverse?.(t=>{const e=t.userData?.[Pu];e&&(t.material=e,delete t.userData[Pu])})}!function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n)}({aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"});const Lu=.001,Bu={default:{metalness:0,roughness:.4},metal:{metalness:1,roughness:.3,envMapIntensity:1},glass:{metalness:0,roughness:.1,opacity:.3,envMapIntensity:1.5},plastic:{metalness:0,roughness:.4},wood:{metalness:0,roughness:.8,envMapIntensity:.3},ceramic:{metalness:.1,roughness:.2,envMapIntensity:.3},rubber:{metalness:0,roughness:.9,envMapIntensity:.3}};function Uu(t){if(!t)return{metalness:0,roughness:.4,emissive:"#000000",emissiveIntensity:0,opacity:1,envMapIntensity:.5,side:"double",flatShading:!1,castShadow:!0,receiveShadow:!1};const e=Bu[t.preset??"default"]??Bu.default;return{metalness:t.metalness??e.metalness,roughness:t.roughness??e.roughness,emissive:t.emissive??"#000000",emissiveIntensity:t.emissiveIntensity??0,opacity:t.opacity??e.opacity??1,envMapIntensity:t.envMapIntensity??e.envMapIntensity??.5,side:t.side??"double",flatShading:t.flatShading??!1,castShadow:t.castShadow??!0,receiveShadow:t.receiveShadow??!1}}const Wu=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap"];function qu(t){const e=t.userData;if(!e?.__bankOwned&&!e?.__isVariant){for(const e of Wu){const n=t[e];n?.dispose()}!function(t){const e=ju.get(t);if(e){for(const t of e.values())t.dispose();ju.delete(t)}}(t),t.dispose()}}function $u(t){t.traverse(t=>{const e=t.userData?.dispose;if("function"==typeof e)try{e()}catch{}if(t.geometry&&!0!==t.geometry.userData?.__bankOwned&&t.geometry.dispose(),t.material){const e=Array.isArray(t.material)?t.material:[t.material];for(const t of e)qu(t)}})}function Vu(t,e){e&&(!0===e.mirror&&(t.wrapS=y,t.repeat.x=-t.repeat.x,t.offset.x=1-t.offset.x),e.rotation&&(t.center.set(.5,.5),t.rotation=e.rotation*Math.PI/180))}function Yu(t){const e=function(t,e,n){const i=document.createElement("canvas");i.width=e,i.height=n;const r=i.getContext("2d");if(!r)return null;let s;if("radial"===t.gradientType){const i=e/2,o=n/2,a=Math.max(e,n)/2;switch(t.center){case"left-top":s=r.createRadialGradient(0,0,0,0,0,2*a);break;case"right-top":s=r.createRadialGradient(e,0,0,e,0,2*a);break;case"left-bottom":s=r.createRadialGradient(0,n,0,0,n,2*a);break;case"right-bottom":s=r.createRadialGradient(e,n,0,e,n,2*a);break;default:s=r.createRadialGradient(i,o,0,i,o,a)}}else{const i=t.rotation??0,o=e/2,a=n/2,c=Math.cos(i)*o,h=Math.sin(i)*a;s=r.createLinearGradient(o-c,a-h,o+c,a+h)}const o=Array.isArray(t.colorStops)?t.colorStops:Array.isArray(t.gradientStops)?t.gradientStops:[];for(const t of o)if(t.position>=0&&t.position<=1)try{s.addColorStop(t.position,t.color)}catch{s.addColorStop(t.position,"#fff")}return r.fillStyle=s,r.fillRect(0,0,e,n),i}(t,256,256);if(!e)return;const n=new sn(e);return n.colorSpace=b,n.needsUpdate=!0,n}function Hu(t,e,n){const i=void 0!==e?e:t.state.fillStyle;if(!i||"object"!=typeof i)return;const r=i;if("pattern"===r.type&&r.image)return function(t,e,n){const{width:i,height:r}=t.bounds,s=Math.abs(i)||1,o=Math.abs(r)||1,a=new it;a.colorSpace=b;const c=new Image;"data"!==String(e.image).substring(0,4)&&(c.crossOrigin="anonymous"),c.onload=()=>{if(e.fitPattern){const t=2*s,n=2*o,i=document.createElement("canvas");i.width=t,i.height=n;const r=i.getContext("2d");if(!r)return;e.color&&(r.fillStyle=e.color,r.fillRect(0,0,t,n)),r.drawImage(c,0,0,t,n),a.image=i,a.wrapS=g,a.wrapT=g,a.repeat.set(1,1),a.offset.set(0,0)}else if(e.noRepeat){const t=2*s,n=2*o,i=2*(e.width||c.naturalWidth),r=2*(e.height||c.naturalHeight),h=2*(e.offsetX||0),l=2*(e.offsetY||0);let u=0,d=0;switch(e.align){case"center":u=(t-i)/2,d=(n-r)/2;break;case"left-top":break;case"left-bottom":d=n-r;break;case"right-top":u=t-i;break;case"right-bottom":u=t-i,d=n-r;break;case"left":d=(n-r)/2;break;case"right":u=t-i,d=(n-r)/2;break;case"top":u=(t-i)/2;break;case"bottom":u=(t-i)/2,d=n-r}const p=document.createElement("canvas");p.width=t,p.height=n;const f=p.getContext("2d");if(!f)return;e.color&&(f.fillStyle=e.color,f.fillRect(0,0,t,n)),f.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,h+u,l+d,i,r),a.image=p,a.wrapS=g,a.wrapT=g,a.repeat.set(1,1),a.offset.set(0,0)}else{const t=e.width||c.naturalWidth,n=e.height||c.naturalHeight,i=2*t,r=2*n,h=document.createElement("canvas");h.width=i,h.height=r;const l=h.getContext("2d");if(!l)return;e.color&&(l.fillStyle=e.color,l.fillRect(0,0,i,r)),l.drawImage(c,0,0,i,r);let u=0,d=0;switch(e.align){case"center":u=(s-t)/2,d=(o-n)/2;break;case"left-top":break;case"left-bottom":d=o-n;break;case"right-top":u=s-t;break;case"right-bottom":u=s-t,d=o-n;break;case"left":d=(o-n)/2;break;case"right":u=s-t,d=(o-n)/2;break;case"top":u=(s-t)/2;break;case"bottom":u=(s-t)/2,d=o-n}const p=(e.offsetX||0)+u,f=(e.offsetY||0)+d;a.image=h,a.wrapS=y,a.wrapT=y,a.repeat.set(s/t,o/n),a.offset.set(-p/t,f/n)}a.minFilter=1006,Vu(a,n),a.needsUpdate=!0,t.invalidate()},c.onerror=t=>{wa("Pattern texture load error:",t)};const h=e.image;c.src=t.app.url(h);const l=t.root?.app?.loadTracker;if(l){const t=new Promise((t,e)=>{c.addEventListener("load",()=>t(),{once:!0}),c.addEventListener("error",()=>e(),{once:!0})});l.track(`pattern:${h}`,"pattern",h,t)}return a}(t,r,n);if("gradient"===r.type){if(Array.isArray(r.colorStops)&&r.colorStops.length>0||Array.isArray(r.gradientStops)&&r.gradientStops.length>0){const t=Yu(r);return t&&Vu(t,n),t}}}const Gu={policy:"state-driven"};function Xu(t){return"state-driven"===t.policy}const Zu=0;function Ju(t,e){const n=function(t){return t&&Number.isFinite(t)?{enabled:!0,factor:t,units:t}:{enabled:!1,factor:0,units:0}}(e);t.traverse(t=>{const e=t;if(!e.isMesh&&!t.isLine&&!t.isPoints)return;const i=e.material;if(i)if(Array.isArray(i))for(const t of i)Qu(t,n);else Qu(i,n)})}function Qu(t,e){t.polygonOffset=e.enabled,t.polygonOffsetFactor=e.factor,t.polygonOffsetUnits=e.units,t.needsUpdate=!0}const Ku=Object.freeze(["mm","cm","m","in"]);function td(t){const e=(n=t?.mmPerUnit,"number"==typeof n&&Number.isFinite(n)&&n>0);var n;const i=t?.displayUnit;return{mmPerUnit:e?t.mmPerUnit:1,known:e,displayUnit:Ku.includes(i)?i:"mm"}}const ed=(t,e)=>t/e.mmPerUnit;function nd(t){return td(t?.rootModel?.state)}function id(t,e){for(let n=t.parent;n;n=n.parent)if(n===e)return!0;return!1}function rd(t,e){return-1!==t.findIndex(t=>t in e)}const sd=()=>{};class od{static buildFillStyleTexture(t,e,n){return Hu(t,e,n)}constructor(t){this._focused=!1,this._suppressOnchange=!1,this._onchangeWrapper=(t,e,n)=>{this._suppressOnchange||n&&n.origin&&n.origin!==this._component||this.onchange(t,e)},this.suppressTransform=!1,this._dimensionScale={x:1,y:1,z:1},this._component=t,this.object3d=this.getObject3dInstance(),this.component.on("change",this._onchangeWrapper)}update(){this.clear(),this.build(),this.layoutHeldItems(),this.updateTransform(),this.updateFillStyle(),this.updateStrokeStyle(),this.updateAlpha(),this.applyFocusDim(),this.updateHidden(),this.updateText(),this._applyZPriority(),this._applyRaycastTarget()}_applyZPriority(){const t=this.component.state?.zPriority,e="number"==typeof t&&Number.isFinite(t)?t:this.zPriority;0!==e&&Ju(this.object3d,e)}get zPriority(){return Zu}getObject3dInstance(){return new jt}build(){this.object3d.userData.context=this;const t=Uu(this.component.state.material3d),{cast:e,receive:n}=this.resolveShadow(t.castShadow,t.receiveShadow);this._applyShadow(e,n),this.object3d.name=this.component.state.id}updateMaterial3d(){const t=Uu(this.component.state.material3d),{cast:e,receive:n}=this.resolveShadow(t.castShadow,t.receiveShadow);this._applyShadow(e,n)}resolveShadow(t=!0,e=!1){return{cast:t,receive:e}}_applyShadow(t,e){const n=i=>{i.castShadow=t,i.receiveShadow=e;for(const t of i.children){const e=t.userData?.context;e&&e!==this||n(t)}};n(this.object3d)}get gizmoTransformable(){return!0}get allowedGizmoModes(){return null}get component(){return this._component}get threeContainer(){let t=this.component;for(;t;){if("is3dContainer"in t&&t.is3dContainer())return t;t=t.parent}}get focused(){return this._focused}set focused(t){this._focused=t,t&&(this._focusedAt=performance.now())}dispose(){this.component.off("change",this._onchangeWrapper),this.clear()}clear(){for(const t of this.component?._items??[]){const e=t?._realObject?.object3d;e?.parent&&e.parent!==this.object3d&&id(e,this.object3d)&&e.removeFromParent()}const t=[];for(const e of this.object3d.children){const n=e.userData?.context;n&&n!==this&&n instanceof od?t.push(e):(Nu(e),$u(e))}this._components3D=void 0,this.object3d.userData={},this.object3d.clear();for(const e of t)this.object3d.add(e);return this.object3d}get placement(){return this._transientPlacement??Gu}setTransientPlacement(t){this._transientPlacement=t}clearTransientPlacement(){this._transientPlacement=void 0}layoutHeldItems(){const t=this.component,e=t?._items??[];if(0===e.length||"function"!=typeof t.placementFor)return;const n=new Set((t.slots??[]).map(t=>t?.id)),i=new Set((t.outsideSlots?.()??[]).map(t=>t?.id));let r=0;for(const s of e){const e=s?._transferSlotId;if(null!=e&&i.has(e)){s?._realObject?.object3d&&t.seatHeldItem?.(s,{slotId:e});continue}if(null!=e&&n.has(e)){s?._realObject?.object3d&&t.seatHeldItem?.(s,{slotId:e});continue}const o=s?._realObject?.object3d;if(!o){r++;continue}const a=t.placementFor(s,{index:r,occupantCount:r});r++,a?.position&&(o.parent!==this.object3d&&this.object3d.attach(o),o.position.set(a.position.x,a.position.y,a.position.z),a.rotation?o.quaternion.set(a.rotation.x,a.rotation.y,a.rotation.z,a.rotation.w):o.quaternion.identity())}}updateTransform(){if(this.suppressTransform)return;if(!Xu(this.placement))return;if(this.component.state.screenFixed&&this.component.isHTMLElement()){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{};return this.object3d.position.set(t-n/2,-(e-i/2),0),void this.object3d.rotation.set(0,0,0)}const{x:t,y:e,z:n}=this.position,{x:i,y:r,z:s}=this.rotation,{x:o,y:a,z:c}=this.scale;this.object3d.position.set(t,e,n),this.object3d.rotation.set(i,r,s),this.applyScale(o,a,c)}get position(){const{x:t,y:e,z:n}=this.center;return{x:t,y:n,z:e}}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:n=0}=this.component.state;return{x:t,y:-n,z:e}}get scale(){const{scale:t}=this.component.state,e="number"==typeof t?t:t?.x??1;return{x:e,y:e,z:e}}get cx(){const{x:t=0}=this.component.center,{width:e=0}=this.component.parent?.bounds??{},{tx:n=0}=this.component.delta();return t+n-e/2}get cy(){const{y:t=0}=this.component.center,{height:e=0}=this.component.parent?.bounds??{},{ty:n=0}=this.component.delta();return t+n-e/2}get cz(){const t=this.effectiveZPos,{tz:e=0}=this.component.delta(),n=this.component.parent?._realObject,i=n?.geometricOffsetY??0,r=n?.receivingSurfaceY??0;return t+e+this.syncZPosOffset-i+r}get receivingSurfaceY(){return 0}surfaceAtLocalY(t){return t+this.geometricOffsetY}placementSurfaceY(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return this.surfaceAtLocalY(0);case"inverted":return this.surfaceAtLocalY(-t);default:return this.surfaceAtLocalY(t)}}get effectiveZPos(){const t=this.component.state.zPos;if("number"==typeof t&&Number.isFinite(t))return t;const e=this.component.effectiveZPos;return"number"==typeof e&&Number.isFinite(e)?e:0}get geometricOffsetY(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get scenePlacement(){const t=this.component.rootModel??this.component,e=t?.state?.placement;return"space"===e||"inverted"===e?e:"floor"}get sceneHeights(){const t=this.component.rootModel??this.component,e=t?.state?.heights,n="number"==typeof e?.floor&&Number.isFinite(e.floor)?e.floor:0,i="number"==typeof e?.ceiling&&Number.isFinite(e.ceiling)?e.ceiling:3e3,r=td(t?.state);return{floor:ed(n,r),ceiling:ed(i,r)}}get placementMode(){return this.scenePlacement}get components3D(){return this._components3D&&this._components3D.parent===this.object3d||(this._components3D=new Pt,this.object3d.add(this._components3D)),this._components3D.position.y=-this.geometricOffsetY,this._components3D}get center(){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{},{tx:r=0,ty:s=0}=this.component.delta();return{x:t+r-n/2,y:e+s-i/2,z:this.cz}}freezeDimension(){this._frozenDimension={...this.dimension}}unfreezeDimension(){delete this._frozenDimension}get dimension(){if(this._frozenDimension)return this._frozenDimension;const{width:t,height:e}=this.component.bounds;return{width:Math.abs(t)||1,height:Math.abs(e)||1,depth:this.effectiveDepth}}get effectiveDepth(){const t=this.component.state.depth;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const e=this.component.effectiveDepth;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:1}updatePosition(){const{x:t=0,y:e=0,z:n=0}=this.position;this.object3d.position.set(t,e,n)}updateRotate(){const{x:t=0,y:e=0,z:n=0}=this.rotation;this.object3d.rotation.set(t,e,n)}get dimensionScale(){return this._dimensionScale}setDimensionScale(t,e,n){Number.isFinite(t)&&Number.isFinite(e)&&Number.isFinite(n)&&(this._dimensionScale={x:t,y:e,z:n},this.updateScale())}applyScale(t,e,n){const i=this.restingScale();this.object3d.scale.set(Math.max(t*i.x,Lu),Math.max(e*i.y,Lu),Math.max(n*i.z,Lu))}restingScale(){const t=this._dimensionScale,e=this.displayScale,n=this._nodeScale??{x:1,y:1,z:1};return{x:t.x*e/n.x,y:t.y*e/n.y,z:t.z*e/n.z}}get displayScale(){return this._displayScale??1}setTransientDisplayScale(t,e){if(!(Number.isFinite(t)&&t>0))return;const n=e&&[e.x,e.y,e.z].every(t=>Number.isFinite(t)&&t>0)?{...e}:this._nodeScale;var i,r;t===this.displayScale&&(i=n,r=this._nodeScale,(i?.x??1)===(r?.x??1)&&(i?.y??1)===(r?.y??1)&&(i?.z??1)===(r?.z??1))||(this._displayScale=t,this._nodeScale=n,this.updateScale())}updateScale(){const{x:t=1,y:e=1,z:n=1}=this.scale;this.applyScale(t,e,n)}syncAnimationDelta(){if(this.suppressTransform)return;const t=this.component.delta();this.updatePosition();const{rotationX:e=0,rotationY:n=0,rotation:i=0}=this.component.state,r=t.theta||0,s=t.rx||0,o=t.ry||0,a=t.rz||0;this.object3d.rotation.set(e+s,-(i+r)+o,n+a);const{scale:c}=this.component.state,h="number"==typeof c?c:c?.x??1,l=t.sx??1,u=t.sy??1,d=t.sz??1;this.applyScale(h*l,h*u,h*d);const p=t.fade||0;if(0!==p){const t=(this.component.state.alpha??1)*(1-p);this.object3d.traverse(e=>{if(e.isMesh&&e.material){const n=Array.isArray(e.material)?e.material:[e.material];for(const e of n)e.opacity=t,e.transparent=e.opacity<1}})}}updateDimension(){this.clear(),this.build()}updateAlpha(){this.applyMaterialOpacity()}isModelingFaint(){return Th(this.component)}applyMaterialOpacity(){const t=this.component.state.alpha,e=null==t?1:t,n=this.isModelingFaint(),i=t=>{t.material&&function(t,e,n){if(!t.material)return;let i=t.userData[Pu];i||(i=t.material,t.userData[Pu]=i);const r=t=>{const i=t?.userData?.[Cu]??t;return n?Du(i,{opacityFactor:.5}):e<1?Du(i,{color:t.color,opacityFactor:e}):t};t.material=Array.isArray(i)?i.map(r):r(i)}(t,e,n);for(const e of t.children){const t=e.userData?.context;t&&t!==this&&t instanceof od||i(e)}};i(this.object3d)}applyFocusDim(){this.applyMaterialOpacity()}updateHidden(){const t=this.component.app;if(t?.isEditMode)return this.object3d.visible=!0,void this.applyFocusDim();this.object3d.visible=!this.component.state.hidden}updateStrokeStyle(){}updateFillStyle(){}updateText(){}topOutline(){return null}_applyRaycastTarget(){const t=this.component.state.raycastTarget;let e;if("boolean"==typeof t)e=t;else{const t=this.component.constructor;e=!1!==t.raycastTargetDefault}const n=t=>{const i=t.userData?.context;if(t===this.object3d||!i||i===this){t.userData?.alwaysRaycast||(e?delete t.raycast:t.raycast=sd);for(const e of t.children)n(e)}};n(this.object3d)}get syncZPosOffset(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get textSurfaceYOffset(){return this.effectiveDepth-this.syncZPosOffset}syncFromObject3D(){const t=this.object3d,e=this._component,{width:n=0,height:i=0}=e.parent?.bounds??{},r=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0,e.bounds={left:t.position.x-s+n/2-r.width/2,top:t.position.z-o+i/2-r.height/2,width:r.width,height:r.height};const c=this.component.parent?._realObject,h=c?.geometricOffsetY??0;e.set({zPos:t.position.y-a-this.syncZPosOffset+h,rotationX:t.rotation.x,rotation:-t.rotation.y,rotationY:t.rotation.z}),this._suppressOnchange=!1}onGizmoDragEnd(t){}applyDimensionFromGizmo(t){this._suppressOnchange=!0,this._component.set(t),this._suppressOnchange=!1}onchange(t,e){if("screenFixed"in t&&this.updateTransform(),rd(["cx","cy","cz","zPos","left","top"],t)&&!this.suppressTransform&&Xu(this.placement)&&this.updatePosition(),rd(["width","height","depth","lineWidth","round","rx","ry","rz"],t)&&(this.updateDimension(),"depth"in t)){this.updatePosition();const t=this.component.components;if(t)for(const e of t){const t=e?._realObject;t?.updateTransform&&t.updateTransform()}}if(rd(["segments","heightSegments"],t)&&this.update(),rd(["rotationX","rotationY","rotation"],t)&&this.updateRotate(),"scale"in t&&this.updateScale(),"hidden"in t&&this.updateHidden(),"alpha"in t&&this.updateAlpha(),"strokeStyle"in t&&this.updateStrokeStyle(),"fillStyle"in t&&this.updateFillStyle(),rd(["text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline"],t))this._lastText=this.component.hasTextProperty?this.component.text:"",this.updateText();else if(rd(["value","data"],t)){const t=this.component.hasTextProperty?this.component.text:"";t!==this._lastText&&(this._lastText=t,this.updateText())}"material3d"in t&&this.updateMaterial3d(),"raycastTarget"in t&&this._applyRaycastTarget()}}const ad=new Map;function cd(t){return t.userData.__bankOwned=!0,t}const hd={primitive(t){const e="primitive::"+function(t){switch(t.kind){case"cylinder":return`cylinder|${t.segments??0}`;case"sphere":return`sphere|${t.segments??0}|${t.heightSegments??0}`;default:return t.kind}}(t);let n=ad.get(e);return n||ad.set(e,n=cd(function(t){switch(t.kind){case"box":return new on(1,1,1);case"plane":return new cn(1,1);case"cylinder":return new an(.5,.5,1,t.segments??16);case"sphere":return new hn(.5,t.segments??16,t.heightSegments??Math.max(2,Math.round((t.segments??16)/2)))}}(t))),n},shaped(t,e){const n="shaped::"+t;let i=ad.get(n);return i||ad.set(n,i=cd(e())),i},owns:t=>!0===t.userData?.__bankOwned,get size(){return ad.size},has:t=>ad.has("primitive::"+t)||ad.has("shaped::"+t),dispose(){for(const t of ad.values())t.dispose();ad.clear()}};let ld=null;const ud=new Set;let dd=null;function pd(){for(const t of[...ud]){const e=t.deref();e?e.refreshLook():ud.delete(t)}}function fd(t){dd?.(),ld=t,dd=t?t.subscribe(pd):null,pd()}function md(t){return ld?.dimsOf(t)??null}const yd=t=>Number(t.component.state.depth)||t.depth,gd="#9e9e9e";class bd extends(Eu(Ou)){constructor(){super(...arguments),this._look=null,this._lookKey=null,this._seatDims=null}get itemTypeCode(){return this.state.type}get drawnAsItem(){return!0}get isItem(){return!0}is3dish(){return!0}get lookNow(){return this._look}get look(){this._lookRef||ud.add(this._lookRef=new WeakRef(this));const t=ld?.keyFor(this)??null;return(t!==this._lookKey||t&&!this._look)&&(this._look?.dispose(),this._look=t?ld?.lookFor(this)??null:null,this._lookKey=this._look?t:null,this.fitLook()),this._look}get seatDims(){return this._seatDims}takeSeatDims(t){var e,n;(e=t,n=this._seatDims,e===n||e&&n&&e.width===n.width&&e.depth===n.depth&&e.height===n.height)||(this._seatDims=t?{...t}:null,this.sized||(this.fitLook(),this._realObject?.rebuildLook?.(),this.invalidate?.()))}fitLook(){this._look&&!this.sized&&this._seatDims&&this._look.fitTo(this._seatDims)}refreshLook(){const t=ld?.keyFor(this)??null;if(t===this._lookKey&&(!t||this._look))return;this._look?.dispose(),this._look=null,this._lookKey=null;const e=this._realObject;if(e&&e instanceof vd!==this.drawnAsItem){const t=this.parent;t?.trigger?.("item-remake",t,this),t?._reseatSlot?.(this[mn])}else e?.rebuildLook?.();this.invalidate?.()}onchange(t,e){super.onchange?.(t,e),"type"in t&&(this.refreshLook(),this.parent?._reseatSlot?.(this[mn])),"data"in t&&this._look&&this._look.component.set("data",t.data)}get sized(){const{width:t=0,height:e=0,depth:n=0}=this.state;return t>0&&e>0&&n>0}get shownSize(){if(this.sized){const{width:t,height:e,depth:n}=this.state;return{width:t,height:e,depth:n}}const t=nd(this).mmPerUnit;if(this._seatDims)return{width:this._seatDims.width/t,height:this._seatDims.depth/t,depth:this._seatDims.height/t};const e=this.look;if(e)return{width:Number(e.component.state.width)||0,height:Number(e.component.state.height)||0,depth:yd(e)};const n=200/t;return{width:n,height:n,depth:n}}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;if(n>0&&i>0)return super.bounds;const r=this.shownSize;return{left:t,top:e,width:r.width,height:r.height}}render(t){const{left:e,top:n,width:i,height:r}=this.bounds,s=this.look;if(s){const o=s.component,a={left:e+(i-(Number(o.state.width)||0))/2,top:n+(r-(Number(o.state.height)||0))/2};return o.state.left===a.left&&o.state.top===a.top||o.set(a),void o.render(t)}t.save(),t.fillStyle=this.state.fillStyle||gd,t.strokeStyle=this.state.strokeStyle||"#616161",t.lineWidth=1,this.sized||t.setLineDash([4,3]),t.beginPath(),t.rect(e,n,i,r),this.sized&&t.fill(),t.stroke(),t.restore()}buildRealObject(){return this.drawnAsItem?new vd(this):void 0}dispose(){this._lookRef&&ud.delete(this._lookRef),this._look?.dispose(),this._look=null,super.dispose()}}class vd extends od{constructor(){super(...arguments),this.box=null,this.shown=null}getObject3dInstance(){return new Pt}build(){super.build(),this.rebuildLook()}rebuildLook(){this.box&&(this.object3d.remove(this.box),this.box.material.dispose(),this.box=null),this.shown&&(this.object3d.remove(this.shown),this.shown=null);const t=this.component,e=t.look,n=t.shownSize;if(e){const t=e.component.realObject,i=t?.object3d;if(!t||!i)return;return t.suppressTransform=!0,i.position.set(0,(yd(e)-n.depth)/2,0),i.quaternion.identity(),this.object3d.add(i),void(this.shown=i)}const i=new nn(hd.primitive({kind:"box"}),new ln({color:t.state.fillStyle||gd,wireframe:!t.sized&&!t.seatDims}));i.scale.set(n.width,n.depth,n.height),this.object3d.add(i),this.box=i}dispose(){const t=this.component.lookNow,e=t?.component._realObject;e&&(e.dispose(),t.component._realObject=void 0),super.dispose(),this.component._realObject===this&&(this.component._realObject=void 0)}clear(){return this.box=null,this.shown=null,super.clear()}}const xd="item-types",wd=64,_d=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function Md(t){if(!_d(t)||!Array.isArray(t.types))return{types:new Map,issues:[{code:"item-types-shape"}]};const e=[],n=new Map;t.types.forEach((t,i)=>{const r=_d(t)?t:{},s=r.code;if("string"!=typeof s||!s||s!==s.trim()||s.length>64)return e.push({code:"item-type-code",at:i});const o=r.figure;if(null!=o&&("string"!=typeof o||!o))return e.push({code:"item-type-figure",at:i});const a="string"==typeof r.name&&r.name?r.name:s,c=n.get(s);c?c.at.push(i):n.set(s,{type:{code:s,name:a,figure:o??null},at:[i]})});const i=new Map;for(const[t,{type:r,at:s}]of n)s.length>1?e.push({code:"item-type-duplicate",id:t,at:s}):i.set(t,r);return{types:i,issues:e}}function Sd(t,e=xd){const n=(t??[]).filter(t=>t?.type===e&&t.active);if(0===n.length)return{types:new Map,issues:[]};if(n.length>1)return{types:new Map,issues:[{code:"item-types-active-many",names:n.map(t=>String(t.name??""))}]};let i=n[0].value;if("string"==typeof i)try{i=JSON.parse(i)}catch{return{types:new Map,issues:[{code:"item-types-shape"}]}}return Md(i)}function kd(t){return _d(t)&&t.types instanceof Map&&Array.isArray(t.issues)}function Ad(t){const e=t?.root;return e&&e!==t?e.itemTypes:t?.itemTypes}function zd(t,e){const n=e?.itemTypeCode??e?.state?.type??e?.type;return"string"==typeof n?t.types.get(n)??null:null}class Td extends Error{code;path;details;constructor(t,e,n,i){super(`${t}: ${e}: ${n}`),this.name="FigureContractError",this.code=t,this.path=e,void 0!==i&&(this.details=i)}}function Id(t,e,n){return n?{code:t,path:e,params:n}:{code:t,path:e}}const Od="holder",Ed=t=>"number"==typeof t&&Number.isFinite(t),jd=t=>Ed(t)&&t>0,Pd=t=>Number.isSafeInteger(t)&&t>0;function Cd(t,e,n){const i=t?.allowed;if(i&&"object"==typeof i)for(const t of["width","depth","height"])jd(i[t])||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else n.push(Id("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||Pd(t.stackLimit)||t.stackLimit===1/0||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||Ed(t.rotation)||n.push(Id("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||n.push(Id("ARRAY_REQUIRED",`${e}.accepts`))}function Rd(t,e={}){const n=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Id("TIERS_REQUIRED","tiers")];const i=e.anchors?new Set(e.anchors):null,r=new Set;return t.tiers.forEach((t,e)=>{const s=`tiers[${e}]`;if(!t||"object"!=typeof t)return void n.push(Id("OBJECT_REQUIRED",s));if(Pd(t.tierNo)?r.has(t.tierNo)?n.push(Id("TIER_NUMBER_DUPLICATE",`${s}.tierNo`,{tierNo:t.tierNo})):r.add(t.tierNo):n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?i&&!i.has(t.anchorId)&&n.push(Id("ANCHOR_UNKNOWN",`${s}.anchorId`,{anchorId:t.anchorId})):n.push(Id("ANCHOR_REQUIRED",`${s}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||n.push(Id("MOUNT_INVALID",`${s}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])Ed(t.position[e])||n.push(Id("FINITE_NUMBER_REQUIRED",`${s}.position.${e}`));else n.push(Id("OBJECT_REQUIRED",`${s}.position`));Ed(t.rotation)||n.push(Id("FINITE_NUMBER_REQUIRED",`${s}.rotation`));const o=t.layout;switch(o?.pattern){case"SINGLE":Cd(o.slot,`${s}.layout.slot`,n);break;case"ROW":Pd(o.count)||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.layout.count`)),jd(o.pitch)||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch`)),"X"!==o.axis&&"Z"!==o.axis&&n.push(Id("AXIS_INVALID",`${s}.layout.axis`)),Cd(o.slot,`${s}.layout.slot`,n);break;case"GRID":Pd(o.rows)||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.layout.rows`)),Pd(o.cols)||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.layout.cols`)),jd(o.pitch?.x)||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch.x`)),jd(o.pitch?.z)||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch.z`)),Cd(o.slot,`${s}.layout.slot`,n);break;case"CUSTOM":{if(!Array.isArray(o.slots)){n.push(Id("ARRAY_REQUIRED",`${s}.layout.slots`));break}o.slots.length||n.push(Id("SLOTS_REQUIRED",`${s}.layout.slots`));const t=new Set;o.slots.forEach((e,i)=>{const r=`${s}.layout.slots[${i}]`;Pd(e?.slotNo)?t.has(e.slotNo)?n.push(Id("SLOT_NUMBER_DUPLICATE",`${r}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):n.push(Id("POSITIVE_INTEGER_REQUIRED",`${r}.slotNo`)),Ed(e?.offset?.x)&&Ed(e?.offset?.z)||n.push(Id("FINITE_NUMBER_REQUIRED",`${r}.offset`)),Cd(e,r,n)});break}default:n.push(Id("PATTERN_INVALID",`${s}.layout.pattern`))}}),n}function Fd(t,e=""){const n=[],i=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,n)=>i(t,`${e}[${n}]`));else if(t&&"object"==typeof t)for(const[n,r]of Object.entries(t))i(r,e?`${e}.${n}`:n)}else n.push(Id("NOT_PERSISTABLE",e,{value:String(t)}))};return i(t,e),n}function Dd(t){switch(t.pattern){case"SINGLE":return 1;case"ROW":return t.count;case"GRID":return t.rows*t.cols;case"CUSTOM":return t.slots.length}}function Nd(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:Dd(t)},(t,e)=>e+1)}function Ld(t,e,n,i,r="ROW_MAJOR"){switch(r){case"ROW_MAJOR":return(n-1)*e+i;case"COL_MAJOR":return(i-1)*t+n;case"SERPENTINE_ROW":return(n-1)*e+(n%2==1?i:e-i+1);case"SERPENTINE_COL":return(i-1)*t+(i%2==1?n:t-n+1)}}function Bd(t,e,n,i="ROW_MAJOR"){const r=n-1;switch(i){case"ROW_MAJOR":return{r:Math.floor(r/e)+1,c:r%e+1};case"COL_MAJOR":return{r:r%t+1,c:Math.floor(r/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(r/e)+1,n=r%e+1;return{r:t,c:t%2==1?n:e-n+1}}case"SERPENTINE_COL":{const e=Math.floor(r/t)+1,n=r%t+1;return{r:e%2==1?n:t-n+1,c:e}}}}const Ud=(t,e)=>e&&0!==t?-t:t;function Wd(t,e,n={}){const i=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!i||!Pd(e.slot))return null;const r=i.layout;let s,o,a;switch(r.pattern){case"SINGLE":if(1!==e.slot)return null;s=r.slot,o={x:0,z:0};break;case"ROW":{if(e.slot>r.count)return null;const t=Ud((e.slot-1-(r.count-1)/2)*r.pitch,"MAX"===r.origin);s=r.slot,o="X"===r.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>r.rows*r.cols)return null;const{r:t,c:n}=Bd(r.rows,r.cols,e.slot,r.order),i=r.origin??{x:"MIN",z:"MIN"};s=r.slot,o={x:Ud((n-1-(r.cols-1)/2)*r.pitch.x,"MAX"===i.x),z:Ud((t-1-(r.rows-1)/2)*r.pitch.z,"MAX"===i.z)};break}case"CUSTOM":{const t=r.slots.find(t=>t.slotNo===e.slot);if(!t)return null;s=t,o={...t.offset},a=t.name;break}}return{tier:i.tierNo,slotNo:e.slot,name:a,anchorId:i.anchorId,mount:i.mount,tierPosition:{...i.position},tierRotation:i.rotation,offset:o,allowed:{...s.allowed},accepts:s.accepts?[...s.accepts]:void 0,stackLimit:s.stackLimit??n.defaultStackLimit??1,rotation:s.rotation??0}}function qd(t){return`t${t.tier}_s${t.slot}`}function $d(t){const e="string"==typeof t?/^t(\d+)_s(\d+)$/.exec(t):null;return e?{tier:Number(e[1]),slot:Number(e[2])}:null}function*Vd(t){for(const e of t?.tiers??[])for(const t of Nd(e.layout))yield{tier:e.tierNo,slot:t}}function Yd(t,e,n){if(!n)return{x:t,z:e};const i=n*Math.PI/180,r=Math.cos(i),s=Math.sin(i),o=t=>Math.round(1e9*t)/1e9;return{x:o(t*r+e*s),z:o(-t*s+e*r)}}function Hd(t){const e=Yd(t.offset.x,t.offset.z,t.tierRotation);return{position:{x:t.tierPosition.x+e.x,y:t.tierPosition.y,z:t.tierPosition.z+e.z},rotation:t.tierRotation+t.rotation}}const Gd=.05,Xd=t=>!!t&&jd(t.width)&&jd(t.depth)&&jd(t.height);function Zd(t,e){const n=e*Math.PI/180,i=Math.abs(Math.cos(n)),r=Math.abs(Math.sin(n)),s=t=>Math.round(1e9*t)/1e9;return{width:s(t.width*i+t.depth*r),depth:s(t.width*r+t.depth*i)}}function Jd(t,e,n=0,i=.05){if(!Xd(t))return null;if(!Ed(n)||!Ed(i)||i<0||i>=1)return null;const r=Zd(t,e.rotation),s=Math.min(1,Math.min(e.allowed.width/r.width,e.allowed.depth/r.depth)*(1-i)),o=t.height*s;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(n+o/2),z:0},rotation:0,scale:s}}function Qd(t,e,n=0,i=.05){const r=Jd(t,e,n,i);if(!r)return null;const s=Hd(e);return{position:{x:s.position.x,y:s.position.y+r.position.y,z:s.position.z},rotation:s.rotation,scale:r.scale}}function Kd(t,e,n=.05){let i=0;return t.map(t=>{const r=t?Qd(t,e,i,n):null;return r&&(i+=t.height*r.scale),r})}const tp=1e-6;function ep(t,e){const n=Hd(t),i=t.allowed.width/2,r=t.allowed.depth/2,s=[[-i,-r],[i,-r],[i,r],[-i,r]].map(([t,e])=>{const i=Yd(t,e,n.rotation);return{x:n.position.x+i.x,z:n.position.z+i.z}}),o=Yd(1,0,n.rotation),a=Yd(0,1,n.rotation),c="HANG"===t.mount?-1:1,h=[n.position.y,n.position.y+c*t.allowed.height],l=s.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:s,axes:[o,a],y0:Math.min(...h),y1:Math.max(...h),minX:Math.min(...l),maxX:Math.max(...l)}}function np(t,e){for(const n of[...t.axes,...e.axes]){const i=t.corners.map(t=>t.x*n.x+t.z*n.z),r=e.corners.map(t=>t.x*n.x+t.z*n.z);if(Math.min(Math.max(...i),Math.max(...r))-Math.max(Math.min(...i),Math.min(...r))<=tp)return!1}return!0}function ip(t,e={}){const n=[],i=new Map;t.tiers.forEach((e,n)=>{const r=i.get(e.anchorId)??[];i.set(e.anchorId,r);for(const i of Nd(e.layout))r.push(ep(Wd(t,{tier:e.tierNo,slot:i}),n))});for(const[t,r]of i){const i=e.anchorFaces?.[t];if(i)for(const t of r)t.corners.some(t=>Math.abs(t.x)-i.width/2>tp||Math.abs(t.z)-i.depth/2>tp)&&n.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else n.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const s=[...r].sort((t,e)=>t.minX-e.minX);for(let t=0;t<s.length;t++){const e=s[t];for(let i=t+1;i<s.length&&s[i].minX<e.maxX-tp;i++){const t=s[i];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=tp)continue;if(!np(e,t))continue;const[r,o]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];n.push({code:"SLOT_OVERLAP",path:`tiers[${o.tierIndex}]`,params:{tier:o.tier,slot:o.slot,otherTier:r.tier,otherSlot:r.slot}})}}}return n}function rp(t,e,n=[],i={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const r=i.normalizeType??(t=>null==t?"":String(t)),s=[];let o=!1;if(t.accepts){const n=r(e.type);n?t.accepts.map(r).includes(n)||s.push("TYPE_NOT_ACCEPTED"):o=!0}if(n.length+1>t.stackLimit&&s.push("STACK_LIMIT_EXCEEDED"),Xd(e.dims)){const i=Zd(e.dims,t.rotation);if(i.width>t.allowed.width&&s.push("WIDTH_EXCEEDED"),i.depth>t.allowed.depth&&s.push("DEPTH_EXCEEDED"),n.every(t=>Xd(t.dims))){n.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&s.push("HEIGHT_EXCEEDED")}else o=!0}else o=!0;return s.length?{verdict:"NG",reasons:o?[...s,"SPEC_UNKNOWN"]:s}:o?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}function sp(t){const e=(t,e,n)=>{throw new Td("ITEM_SNAPSHOT",t,e,n)},n=t;n&&"object"==typeof n&&"string"==typeof n.revision&&Array.isArray(n.items)||e("snapshot","a revision and a list of items",{reason:"item-snapshot-shape"});const i=new Set,r=new Map;n.items.forEach((t,n)=>{const s=`items[${n}]`;t&&"string"==typeof t.itemId&&t.itemId&&"string"==typeof t.slotId&&t.slotId||e(s,"an item id and a slot id",{reason:"item-snapshot-shape"}),(!Number.isSafeInteger(t.stackIndex)||t.stackIndex<0)&&e(`${s}.stackIndex`,"a whole number from 0",{reason:"item-snapshot-shape"}),void 0!==t.type&&"string"!=typeof t.type&&e(`${s}.type`,"a type name",{reason:"item-snapshot-shape"}),void 0===t.dims||t.dims&&["width","depth","height"].every(e=>{return"number"==typeof(n=t.dims[e])&&Number.isFinite(n)&&t.dims[e]>0;var n})||e(`${s}.dims`,"three positive numbers in mm",{reason:"item-invalid-dimensions",item:t.itemId}),i.has(t.itemId)&&e(s,`${t.itemId} is in the snapshot twice`,{reason:"item-duplicate",item:t.itemId}),i.add(t.itemId),r.set(t.slotId,[...r.get(t.slotId)??[],t.stackIndex])});for(const[t,n]of r){const i=[...n].sort((t,e)=>t-e);i.forEach((n,r)=>{n!==r&&e("items",`the stack in ${t} has ${i.join(", ")}; each height once, from 0`,{reason:"item-stack-index",slot:t,heights:i})})}}function op(t,e,n){const i=null!=e?{source:"override",raw:e}:t?{source:"figure",raw:t}:void 0;if(!i)return{source:"none",status:"none",issues:[]};const r=function(t,e){const n=Rd(t,{anchors:[...e]});if(n.length)return n;const i=Fd(t);if(i.length)return i;const r=[],s=t=>Array.isArray(t)&&0===t.length;return t.tiers.forEach((t,e)=>{const n=t.layout;"CUSTOM"===n.pattern?n.slots.forEach((t,n)=>s(t.accepts)&&r.push(Id("ACCEPTS_EMPTY",`tiers[${e}].layout.slots[${n}].accepts`))):s(n.slot.accepts)&&r.push(Id("ACCEPTS_EMPTY",`tiers[${e}].layout.slot.accepts`))}),r}(i.raw,n);return r.length?{source:i.source,status:"invalid",issues:r,refusal:{code:"SLOT_LAYOUT",details:{reason:"slot-layout-issues",issues:r}}}:{source:i.source,status:"valid",layout:i.raw,issues:[]}}function ap(t,e){const n=new Map;for(const i of t._items??[]){if(e&&i===e.item)continue;const t=i?.[mn];"string"==typeof t&&t&&(n.get(t)??n.set(t,[]).get(t)).push(i)}return e&&(n.get(e.slotId)??n.set(e.slotId,[]).get(e.slotId)).push(e.item),n}function cp(t,e=""){return hp(t,ap(t),e).snapshot}function hp(t,e,n){const i=new Map,r=new Set,s=[];let o=0;for(const[n,a]of e)a.forEach((e,a)=>{let c=Su(e);c&&!r.has(c)||(c=`#${o}`),o++,r.add(c),i.set(e,c);const h=t.itemTypeOf?.(e)??null,l=t.itemDimsOf?.(e)??null;s.push({itemId:c,slotId:n,stackIndex:a,...h?{type:h}:{},...l?{dims:l}:{}})});return{snapshot:{revision:n,items:s},ids:i}}function lp(t){return{tier:0,slotNo:0,anchorId:t.anchorId,mount:t.mount??"ON",tierPosition:{...t.frame.position},tierRotation:t.frame.rotation,offset:{x:0,z:0},allowed:{width:1/0,depth:1/0,height:1/0},stackLimit:1/0,rotation:0}}function up(t,e){const n=Hd(t),i=e?.position.y??0;return{position:{x:n.position.x,y:n.position.y+i,z:n.position.z},rotation:n.rotation,scale:e?.scale??1}}function dp(t,e,n,i,r,s){if(!t.itemShownDimsOf)return;let o=0;for(const a of i){const i=r.get(a),c=t.itemDimsOf?.(a)??("seated"===i.status?null:t.itemShownDimsOf(a,n,e)),h="seated"===i.status?i.inSlot:c?Jd(c,n,o,s):null;if(!h||!c)return;o+=c.height*h.scale,"seated"!==i.status&&r.set(a,{...i,inSlot:h,inAnchor:up(n,h),shrunk:h.scale<1,dims:c})}}function pp(t,e){const n=t.effectiveLayout?.layout,i=new Map((t.outsideSlots?.()??[]).map(t=>[t.id,t])),r=ap(t,e),s=new Map,o=new Map;for(const[e,n]of r){const r=i.get(e);if(!r){o.set(e,n);continue}const a=lp(r);let c=0,h=!0;n.forEach((n,i)=>{const o=t.itemDimsOf?.(n)??null,l={slotId:e,stackIndex:i,outside:!0,anchorId:r.anchorId,shrunk:!1,dims:o},u=h&&o?Jd(o,a,c,0):null;if(!u){const t=h?"size-unknown":"below-unknown";return h=!1,s.set(n,{...l,status:"unconfirmed",why:t,inSlot:null,inAnchor:up(a,null)})}c+=o.height,s.set(n,{...l,status:"seated",inSlot:u,inAnchor:up(a,u)})}),dp(t,e,a,n,s,0)}const{snapshot:a,ids:c}=hp(t,o,""),h=new Map(function(t,e,n={}){sp(e);const i=n.margin??Gd,r=new Map;for(const t of e.items)r.set(t.slotId,[...r.get(t.slotId)??[],t]);const s=new Map;for(const[e,o]of r){const r=[...o].sort((t,e)=>t.stackIndex-e.stackIndex),a=t?$d(e):null,c=a?Wd(t,a):null;let h=0,l=!0;r.forEach((t,o)=>{const a=rp(c,{type:t.type,dims:t.dims??null},r.slice(0,o).map(t=>({type:t.type,dims:t.dims??null})),n.normalizeType?{normalizeType:n.normalizeType}:{}),u={itemId:t.itemId,slotId:e,stackIndex:t.stackIndex,fit:a};if(!c)return s.set(t.itemId,{...u,status:"unplaced",why:"slot-absent",seat:null,shrunk:!1});if(!l)return s.set(t.itemId,{...u,status:"unconfirmed",why:"below-unknown",seat:null,shrunk:!1});const d=t.dims?Jd(t.dims,c,h,i):null;if(!d)return l=!1,s.set(t.itemId,{...u,status:"unconfirmed",why:"size-unknown",seat:null,shrunk:!1});h+=t.dims.height*d.scale,s.set(t.itemId,{...u,status:"seated",seat:d,shrunk:d.scale<1})})}return e.items.map(t=>s.get(t.itemId))}(n,a).map(t=>[t.itemId,t]));for(const[e,i]of c){const r=h.get(i),o=n?$d(r.slotId):null,a=o?Wd(n,o):null;s.set(e,{slotId:r.slotId,stackIndex:r.stackIndex,status:r.status,...r.why?{why:r.why}:{},fit:r.fit,outside:!1,anchorId:a?.anchorId??null,inSlot:r.seat,inAnchor:a&&"unplaced"!==r.status?up(a,r.seat):null,shrunk:r.shrunk,dims:t.itemDimsOf?.(e)??null})}for(const[e,i]of o){const r=n?$d(e):null,o=r?Wd(n,r):null;o&&dp(t,e,o,i,s,Gd)}return s}const fp=[{id:"__default__",maxCount:1/0}];function mp(t){const e={id:qd({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function yp(t,e,n){const i=t.itemTypeOf?t.itemTypeOf(n):n?.state?.type??n?.type;return e.accepts?!!i&&e.accepts.includes(i):!e.allowedTypes?.length||!!i&&e.allowedTypes.includes(i)}function gp(t){var e;return e=class extends t{get slotLayout(){}get effectiveLayout(){const t=this.slotLayout,e=this.state?.slotLayout,n=this.slotAnchors(),i=n.join("\n"),r=this.__effectiveLayout;if(r&&r.declared===t&&r.override===e&&r.anchors===i)return r.value;const s=op(t,e,n);return this.__effectiveLayout={declared:t,override:e,anchors:i,value:s},s}slotAnchors(){return[Od]}anchorObject3D(t){const e=this._realObject?.object3d;return t===Od&&e?function(t){let e=t.userData.itemAnchor;if(!e||e.parent!==t){const n=new Pt;n.name="item-anchor";const i=n.updateMatrix.bind(n);n.updateMatrix=()=>{const t=n.parent?.scale;t&&n.scale.set(1/(t.x||1),1/(t.y||1),1/(t.z||1)),i()},t.add(n),t.userData.itemAnchor=n,e=n}return e.updateMatrix(),e}(e):null}outsideSlots(){return[]}itemTypeOf(t){const e=Ad(this);if(e)return zd(e,t)?.code??null;const n=t?.state?.type??t?.type;return"string"==typeof n&&n?n:null}get mmPerSceneUnit(){return nd(this).mmPerUnit}itemDimsOf(t){const e=function(t,e){const[n,i,r]=[Number(t?.state?.width),Number(t?.state?.height),Number(t?.state?.depth)];return[n,i,r].every(t=>Number.isFinite(t)&&t>0)?{width:n*e,depth:i*e,height:r*e}:null}(t,this.mmPerSceneUnit);return e||(Ad(this)?null:md(t))}itemShownDimsOf(t,e,n){if(!Ad(this))return null;const{width:i,depth:r,height:s}=e.allowed;if(![i,r,s].every(t=>Number.isFinite(t)&&t>0))return md(t);return{width:i,depth:r,height:s/(Number.isFinite(e.stackLimit)&&e.stackLimit>0?e.stackLimit:1)}}itemSeatOf(t,e){const n=e??t?.[mn];if("string"!=typeof n||!n)return null;return pp(this,t?.[mn]===n&&this._items?.includes(t)?void 0:{item:t,slotId:n}).get(t)??null}get slots(){const t=this.effectiveLayout.layout;if(!t)return[];const e=[];for(const n of Vd(t)){const i=Wd(t,n);i&&e.push(mp(i))}return e}slotById(t){const e=this.outsideSlots().find(e=>e.id===t);if(e)return{id:e.id,maxCount:1/0};const n=this.effectiveLayout.layout;if(n){const e=$d(t),i=e?Wd(n,e):null;return i?mp(i):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,n=0,i){const r=this.effectiveLayout.layout,s=r?$d(t):null,o=s?Wd(r,s):null,a=o?Qd(e,o,n,i):null;return a?{...a,anchorId:o.anchorId}:null}get arrangementStrategy(){return f}canReceive(t,e){const n=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return Sn.log({role:"target",contract:"canReceive",component:this,args:{carrier:dn(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:fp;for(const n of e){if(!yp(this,n,t))continue;const e=n.maxCount??this.arrangementStrategy.capacity(n),i=this._countOccupied(n.id);if(!(i>=e))return Sn.log({role:"target",contract:"findSlot",component:this,args:{carrier:dn(t)},result:{slotId:n.id,occupied:i,max:e}}),n}return Sn.log({role:"target",contract:"findSlot",component:this,args:{carrier:dn(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const n=this._realObject?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const i=new N;n.getWorldQuaternion(i);const r=new N(e.x,e.y,e.z,e.w);return i.clone().multiply(r)}deliveryWorldPosition(t){const e=this._realObject,n=e?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const i=new L;n.getWorldPosition(i);const r=this._receivingSurfaceLocalY();if(null!==r){const t=new L(0,r,0);return n.localToWorld(t),{x:i.x,y:t.y,z:i.z}}return{x:i.x,y:i.y,z:i.z}}attachPointFor(t,e){const n=e?.slotId??t?.[mn];if(!n)return null;if("none"!==this.effectiveLayout.status||this.outsideSlots().length){const e=this.itemSeatOf(t,n),i=e?.anchorId&&e.inAnchor?this.anchorObject3D(e.anchorId):null;if(!e||!i)return null;const r=this.mmPerSceneUnit,s=e.inAnchor;return{attach:i,localPosition:{x:s.position.x/r,y:s.position.y/r,z:s.position.z/r},localRotation:{x:0,y:s.rotation*Math.PI/180,z:0},carryPolicy:"slot",displayScale:s.scale,slotId:n,seat:e}}const i=this.slots.find(t=>t.id===n);return i?{position:i.localPosition??{x:0,y:0,z:0},rotation:i.localRotation??{x:0,y:0,z:0},slotId:i.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,i=n?n.state??{}:t??{},r={width:Number(i.width)||0,height:Number(i.height)||0,depth:Number(i.depth)||0},s=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!s)return null;const o=e.index??this._countOccupied(s.id),a=e.occupantCount??o,c=this.arrangementStrategy.positionAt(o,s,a,n??{state:{...r}});if(!c)return null;const h=Number(this.state?.width)||0,l=Number(this.state?.height)||0,u=c.x+r.width/2-h/2,d=c.y+r.height/2-l/2,p=this._realObject,f=p?.placementMode??"floor",m="space"===f?0:"inverted"===f?-r.depth/2:r.depth/2,y=this._receivingSurfaceLocalY();let g;g=null!==y?y+m:s.localPosition&&Number.isFinite(s.localPosition.z)?s.localPosition.z+m:m-(p?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??r,s)??void 0;return b?{position:{x:u,y:g,z:d},rotation:b}:{position:{x:u,y:g,z:d}}}_zPosFromSeatY(t,e,n){const i=this._realObject,r=i?.receivingSurfaceY??0,s=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===r&&!s)return null;const o=Number(e)||0,a=i?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-o/2:o/2)+(i?.geometricOffsetY??0)-r}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!yp(this,t,e))return null;const n=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<n?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[mn]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[mn]===t).length:0}},e.__hasCapacity=!0,e}function bp(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return[];const o="number"==typeof t.rotation?t.rotation:0,a=Math.cos(o),c=Math.sin(o),h=n+r/2,l=i+s/2,u="inbound"===e?-1:1;return[{lx:-r/2,lz:0,odx:-1,odz:0},{lx:r/2,lz:0,odx:1,odz:0},{lx:0,lz:-s/2,odx:0,odz:-1},{lx:0,lz:s/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:h+e*a-n*c,z:l+e*c+n*a}),direction:{x:u*(t.odx*a-t.odz*c),z:u*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?s/2:r/2}})}function vp(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return{inbounds:[],outbounds:[]};const o="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&r<s,h=n+r/2,l=i+s/2,u=c?s/2:r/2,d=c?0:1,p=c?1:0,f=Math.cos(o),m=Math.sin(o),y=(t,e)=>({x:h+t*f-e*m,z:l+t*m+e*f}),g=c?{lx:0,lz:-u}:{lx:-u,lz:0},b=c?{lx:0,lz:u}:{lx:u,lz:0},v=y(g.lx,g.lz),x=y(b.lx,b.lz),w={x:d*f-p*m,z:d*m+p*f},_=Math.hypot(w.x,w.z)||1,M={x:w.x/_,z:w.z/_},S={x:-M.x,z:-M.z},k=(c?r:s)/2;return a?{inbounds:[{worldPos:x,direction:S,halfSpan:k}],outbounds:[{worldPos:v,direction:S,halfSpan:k}]}:{inbounds:[{worldPos:v,direction:M,halfSpan:k}],outbounds:[{worldPos:x,direction:M,halfSpan:k}]}}function xp(t){const e=t.left??0,n=t.top??0,i=t.width??0,r=t.height??0;if(i<=0||r<=0)return null;const s="number"==typeof t.rotation?t.rotation:0,o="vertical"===t.orientation||"horizontal"!==t.orientation&&i<r,a=e+i/2,c=n+r/2,h=o?r/2:i/2,l=Math.cos(s),u=Math.sin(s),d=(t,e)=>({x:a+t*l-e*u,z:c+t*u+e*l});return{start:o?d(0,-h):d(-h,0),end:o?d(0,h):d(h,0)}}function wp(t){const e=t.cx??0,n=t.cy??0,i=Math.abs(t.rx??100),r=Math.abs(t.ry??100),s=t.ratio??50,o=(i+i*s/100)/2,a=(r+r*s/100)/2,c=t.startAngle??0,h=t.endAngle??Math.PI/2,l="reverse"===t.status;if(i<=0||r<=0)return{inbounds:[],outbounds:[]};const u={x:e+o*Math.sin(c),z:n-a*Math.cos(c)},d={x:e+o*Math.sin(h),z:n-a*Math.cos(h)},p={x:Math.cos(c),z:Math.sin(c)},f={x:Math.cos(h),z:Math.sin(h)};return l?{inbounds:[{worldPos:d,direction:{x:-f.x,z:-f.z}}],outbounds:[{worldPos:u,direction:{x:-p.x,z:-p.z}}]}:{inbounds:[{worldPos:u,direction:p}],outbounds:[{worldPos:d,direction:f}]}}function _p(t){const e=vp(t),n=e.outbounds[0];if(!n)return{inbounds:bp(t,"inbound"),outbounds:[]};const i=bp(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,i=t.worldPos.z-n.worldPos.z;return Math.hypot(e,i)>1}),r=n.direction,s=[];for(const t of i){const e=t.direction.x*r.x+t.direction.z*r.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+r.x,i=t.direction.z+r.z,o=Math.hypot(n,i)||1;s.push({worldPos:t.worldPos,direction:{x:n/o,z:i/o},halfSpan:t.halfSpan})}return{inbounds:[...i,...s],outbounds:e.outbounds}}function Mp(t,e,n={}){const i=n.distance??5,r=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<r)return!1;const s=t.worldPos.x-e.worldPos.x,o=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,r=t.direction.z;if(Math.abs(s*n+o*r)>i)return!1;const a=Math.abs(s*-r+o*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(s,o)<=i}function Sp(t,e,n,i=0){const r=n.width??0,s=n.height??0;if(r<=0||s<=0)return!1;const o=(n.left??0)+r/2,a=(n.top??0)+s/2,c="number"==typeof n.rotation?n.rotation:0,h=Math.cos(-c),l=Math.sin(-c),u=t-o,d=e-a,p=u*h-d*l,f=u*l+d*h;return Math.abs(p)<=r/2+i&&Math.abs(f)<=s/2+i}function kp(t,e,n){const i=n.width??0,r=n.height??0;if(i<=0||r<=0)return 1/0;const s=(n.left??0)+i/2,o=(n.top??0)+r/2;let a=t.x-s,c=t.z-o,h=e.x,l=e.z;const u="number"==typeof n.rotation?n.rotation:0;if(0!==u){const t=Math.cos(-u),e=Math.sin(-u),n=a*e+c*t,i=h*e+l*t;a=a*t-c*e,c=n,h=h*t-l*e,l=i}const d=i/2,p=r/2;let f=-1/0,m=1/0;if(Math.abs(h)<1e-9){if(a<-d||a>d)return 1/0}else{const t=(-d-a)/h,e=(d-a)/h;f=Math.max(f,Math.min(t,e)),m=Math.min(m,Math.max(t,e))}if(Math.abs(l)<1e-9){if(c<-p||c>p)return 1/0}else{const t=(-p-c)/l,e=(p-c)/l;f=Math.max(f,Math.min(t,e)),m=Math.min(m,Math.max(t,e))}return m<f?1/0:f>=0?f:m>=0?Math.min(-f,m):-m}function Ap(t,e,n,i=6){return!!Sp(t.worldPos.x,t.worldPos.z,e,i)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function zp(t,e,n){return t.outbounds.map(t=>{const i=[];for(const r of e){let e=null;for(const i of r.topology.inbounds){if(!Mp(t,i,n))continue;const r=t.worldPos.x-i.worldPos.x,s=t.worldPos.z-i.worldPos.z,o=Math.hypot(r,s);(null===e||o<e)&&(e=o)}if(null===e&&r.bounds){const i=r.topology.outbounds[0]?.direction,s=!(r.topology.outbounds&&r.topology.outbounds.length)?n?.sinkMargin??30:6;if(Ap(t,r.bounds,i,s)){const n=kp(t.worldPos,t.direction,r.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(r.bounds.left??0)+(r.bounds.width??0)/2,i=(r.bounds.top??0)+(r.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-i)+1e3}}}null!==e&&i.push({id:r.id,dist:e})}return 0===i.length?null:(i.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),i[0].id)})}function Tp(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const i=new Map,r=new Set;for(const n of t){const s=t.filter(t=>t.id!==n.id),o=zp(n.topology,s,e);i.set(n.id,o);for(const t of o)null!=t&&r.add(t)}const s=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const s=i.get(t)??[];s.includes(e)||(s.push(e),i.set(t,s),r.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])s(e.id,t);for(const t of e.links.upstream??[])s(t,e.id)}const o=new Set,a=new Set;for(const e of t){(i.get(e.id)??[]).some(t=>null!=t)||o.add(e.id),r.has(e.id)||a.add(e.id)}return{nodes:n,out:i,sinks:o,sources:a}}function Ip(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const i=new Set([e]);for(const r of function(t,e,n){const i=n.get(e);if(i)return i;const r=new Set,s=[e],o=new Set([e]);for(;s.length;){const e=s.shift();for(const n of t.out.get(e)??[])null!=n&&(r.add(n),o.has(n)||(o.add(n),s.push(n)))}return n.set(e,r),r}(t,e,n))i.add(r);return i})}function Op(t,e,n,i){return e===n?0:function(t,e,n){const i=n.get(e);if(i)return i;const r=new Map([[e,0]]),s=[e];for(;s.length;){const e=s.shift(),n=r.get(e);for(const i of t.out.get(e)??[])null==i||r.has(i)||(r.set(i,n+1),s.push(i))}return n.set(e,r),r}(t,e,i).get(n)??1/0}function Ep(t,e,n){const i=t.out.get(e)??[],r=new Map,s=[];for(let e=0;e<i.length;e++){const o=i[e];if(null==o)continue;const a=o===n?0:Op(t,o,n,r);a!==1/0&&s.push({i:e,hops:1+a})}return s.sort((t,e)=>t.hops-e.hops||t.i-e.i),s.map(t=>t.i)}function jp(t,e,n){const i=Ep(t,e,n);return i.length?i[0]:-1}function Pp(t,e,n){return e===n||Ep(t,e,n).length>0}function Cp(t,e){const n=new Set;for(const i of Ip(t,e))for(const e of i)t.sinks.has(e)&&n.add(e);return n}function Rp(t,e,n){return Fp(t,e,n).map(t=>t.index)}function Fp(t,e,n){const i=n instanceof Set?n:new Set(n);if(0===i.size)return[];const r=t.out.get(e)??[],s=new Map,o=[...i].sort(),a=[];for(let e=0;e<r.length;e++){const n=r[e];if(null==n)continue;let i=1/0,c="";for(const e of o){const r=1+(n===e?0:Op(t,n,e,s));r<i&&(i=r,c=e)}i!==1/0&&a.push({index:e,hops:i,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Dp(t,e={}){const n=[],i=e.loopCapableIds??new Set,r=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const i=t.nodes.get(e);if(!i||!i.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(r.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const s=function(t){const e=[],n=[...t.nodes.keys()].sort(),i=new Set,r=[],s=new Set,o=n=>{i.add(n),r.push(n),s.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(s.has(a)){const t=r.indexOf(a),n=r.slice(t),i=n.indexOf([...n].sort()[0]),s=[...n.slice(i),...n.slice(0,i)],o=s.join("→");e.some(t=>t.join("→")===o)||e.push(s)}else i.has(a)||o(a);r.pop(),s.delete(n)};for(const t of n)i.has(t)||o(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of s){t.some(t=>i.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const o=e.routingWeights;if(o)for(const[t,e]of[...o].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...r].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Np(t,e){if(!t)return[];const n=[],i=new Set,r=t=>{if(!t||i.has(t))return;if(i.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,i=t.refid??t.state?.refid,r="string"==typeof e&&e.length>0?e:null!=i?String(i):void 0;if(r)try{const e=t.getSegmentTopology(),i=t.state??{},s={left:i.left,top:i.top,width:i.width,height:i.height,rotation:i.rotation};e&&n.push({id:r,topology:e,bounds:s})}catch{}}const s=t?.components;if(Array.isArray(s))for(const t of s)r(t)};return r(t),n}function Lp(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const i=t.getSegmentTopology();if(!i||0===i.outbounds.length)return null;const r=zp(i,Np(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of r)if(t)return t;return null}function Bp(t){return!!t&&"function"==typeof t.routingConstraints}function Up(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Wp(t,e=16){const n=[],i=t.parent??t.rootModel??t.root;if(!i)return n;const r=Lp(t);if(!r)return n;const s=Vp(i,r);if(!s)return n;const o=[{segment:s,accumulated:{},pathIds:[r],visited:new Set([r])}];for(;o.length>0;){const t=o.shift();if(t.pathIds.length>e)continue;const r=Bp(t.segment)?t.segment.routingConstraints():null;if(r&&r.length>0)for(const e of r)for(const r of e.candidates){const s=qp(t.accumulated,r);if(!s)continue;const a=$p(t.segment,e.portId,i);a&&!t.visited.has(a.state?.id??"")?o.push({segment:a,accumulated:s,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:s,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Up(t.segment)){const e=t.segment.acceptedCarrierData(),i=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:i});else for(const r of e){const e=qp(t.accumulated,r);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:i})}continue}const e=Lp(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const r=Vp(i,e);if(!r)continue;o.push({segment:r,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function qp(t,e){const n={...t};for(const[t,i]of Object.entries(e)){if(t in n&&n[t]!==i)return null;n[t]=i}return n}function $p(t,e,n){if("straight"===e&&t.state?.downstreamRef)return Vp(n,t.state.downstreamRef);const i=Vp(n,e);if(i)return i;const r=Lp(t);return r?Vp(n,r):null}function Vp(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,i=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const r=t.components;if(Array.isArray(r))for(const t of r){const e=i(t);if(e)return e}return null};return i(t)}function Yp(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function Hp(t,e,n=5,i=[],r=n){const s=t.length,o=new Array(s).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,h=[],l=new Map,u=[],d=new Map;for(const t of i){const e=Array.isArray(t),n=e?t:t.positions,i=e?void 0:t.kind;if(!n.length)continue;const r=h.length;h.push({pos:n[0],members:[]});for(const t of n)u.push({pos:t,pt:r});i&&d.set(r,i)}const p=(t,e)=>{const i=c(t,e),r=l.get(`${t}:${"end"===e?"start":"end"}`),s=[];for(const t of u)Yp(t.pos,i)<=n&&!s.includes(t.pt)&&s.push(t.pt);for(let t=0;t<h.length;t++)Yp(h[t].pos,i)<=n&&!s.includes(t)&&s.push(t);let o=s.find(t=>t!==r)??-1;o<0&&(o=h.length,h.push({pos:i,members:[]})),h[o].members.push({seg:t,end:e}),l.set(`${t}:${e}`,o)};for(let t=0;t<s;t++)p(t,"start"),p(t,"end");const f=new Set,m=new Set,y=new Set;{const t=t=>{let e=-1,n=1/0;for(let i=0;i<h.length;i++){const r=Yp(h[i].pos,t);r<n&&(n=r,e=i)}for(const i of u){const r=Yp(i.pos,t);r<n&&(n=r,e=i.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:i}=t(n.pos);e>=0&&i<=r&&(f.add(e),("source"===n.kind?m:y).add(e))}}for(const[t,e]of d)f.add(t),("source"===e?m:y).add(t);const g=(t,e)=>"end"===e!==o[t],b=[],v=(e,n)=>{if(void 0===o[e])return o[e]=n,void b.push(e);o[e]!==n&&a.add(t[e].id)},x=t=>{for(const e of["start","end"]){const n=l.get(`${t}:${e}`);if(void 0===n)continue;const i=h[n];if(2!==i.members.length||f.has(n))continue;const r=i.members[0],s=r.seg===t&&r.end===e?i.members[1]:r;if(s.seg===t)continue;const a="end"===e!==o[t],c="end"===s.end!==!a;v(s.seg,c)}},w=()=>{for(;b.length;)x(b.shift())},_=t=>{let e=-1,n="start",i=1/0;for(let r=0;r<s;r++)for(const s of["start","end"]){const o=Yp(c(r,s),t.pos);o<i&&(i=o,e=r,n=s)}if(e<0||i>r)return;const o="source"===t.kind?"end"===n:"start"===n;v(e,o)};for(const t of e)"source"===t.kind&&_(t);w();for(const t of e)"sink"===t.kind&&_(t);w();let M=!0;for(;M;){M=!1;for(const t of h){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===o[t.seg]);if(1!==e.length)continue;let n=0,i=0;for(const e of t.members)void 0!==o[e.seg]&&(g(e.seg,e.end)?n++:i++);const r=e[0];let s;0===i&&n>0?s="end"===r.end:0===n&&i>0&&(s="start"===r.end),void 0!==s&&(o[r.seg]=s,b.push(r.seg),w(),M=!0)}}if(o.some(t=>void 0===t)&&m.size>0&&y.size>0){const t=t=>{const e=new Array(h.length).fill(1/0),n=[];for(const i of t)e[i]=0,n.push(i);for(;n.length;){const t=n.shift();for(const i of h[t].members){const r=l.get(`${i.seg}:${"start"===i.end?"end":"start"}`);void 0!==r&&e[r]>e[t]+1&&(e[r]=e[t]+1,n.push(r))}}return e},e=t(m),n=t(y);for(let t=0;t<s;t++){if(void 0!==o[t])continue;const i=l.get(`${t}:start`),r=l.get(`${t}:end`);if(void 0===i||void 0===r)continue;if(h[i].members.length<2||h[r].members.length<2)continue;if(e[i]===1/0||e[r]===1/0||n[i]===1/0||n[r]===1/0)continue;let s;e[i]!==e[r]?s=e[i]<e[r]:n[i]!==n[r]&&(s=n[r]<n[i]),void 0!==s&&(o[t]=!s,b.push(t))}w()}const S=new Map;for(let e=0;e<s;e++)S.set(t[e].id,void 0===o[e]?"unknown":o[e]?"reverse":"forward");return{directions:S,conflicts:[...a]}}function Gp(...t){}function Xp(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function Zp(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*Jp(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*Jp(t)}function Qp(t,e,n){const i=e.width??0,r=e.height??0;if(i<=0||r<=0)return!1;const s=(e.left??0)+i/2,o=(e.top??0)+r/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-s,h=t.z-o,l=Math.cos(-a),u=Math.sin(-a),d=c*l-h*u,p=c*u+h*l;return Math.abs(d)<=i/2+n&&Math.abs(p)<=r/2+n}function Kp(t){const e=[],n=[],i=[],r=[];for(const s of Jp(t)){const t=Zp(s);if(!t)continue;if(s.flowOrientable){const n=xp(s.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof s.openings){const t=s.state??{};(t.width??0)>0&&(t.height??0)>0&&r.push(t);continue}let o;try{o=s.getSegmentTopology()}catch{continue}if(!o)continue;const a=o.inbounds??[],c=o.outbounds??[],h="function"==typeof s.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||h))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&i.push({positions:t})}}for(const t of r){const r=[];for(const n of e)for(const e of[n.start,n.end])Qp(e,t,16)&&r.push(e);let s=!1,o=!1;for(const e of n)Qp(e.pos,t,16)&&("sink"===e.kind?s=!0:o=!0);const a=s&&!o?"sink":o&&!s?"source":void 0;(r.length>=2||a&&r.length>=1)&&i.push({positions:r,kind:a})}if(0===e.length||0===n.length)return e.length,n.length,new Map;const s=Hp(e,n,8,i,60).directions;return e.length,n.length,i.length,[...s].map(([t,e])=>`#${t}:${e}`).join(" "),s}function tf(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:Kp(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const i=Zp(t),r=i?n.map.get(i):void 0;return"reverse"===r||"forward"!==r&&void 0}function ef(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function nf(t,e,n,i){if(!t||!e)return null;const r=[],s=t=>{if(!t||t===i)return;if(function(t,e){const n=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(n)&&n.includes(e)}(t,e)&&ef(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(t);e&&r.push({id:e,component:t,distance:t.distanceToBoardPoint(n.x,n.y)})}const o=t.components;if(Array.isArray(o))for(const t of o)s(t)};return s(t),0===r.length?null:(r.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),r[0])}function rf(t){return!!t&&"function"==typeof t.routingDestination}function sf(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*of(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*of(t)}function af(t){const e=[],n=new Map,i=new Map,r=new Set,s=[];for(const o of of(t)){"function"==typeof o?.registerWithHost&&s.push(o);const t="function"==typeof o?.getSegmentTopology,a="function"==typeof o?.routingLinks?o.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||rf(o)||c||ef(o)))continue;const h=sf(o);if(!h)continue;let l={inbounds:[],outbounds:[]};if(t){try{l=o.getSegmentTopology()}catch{continue}if(!l)continue}const u=o.state??{},d={left:u.left,top:u.top,width:u.width,height:u.height,rotation:u.rotation};if(e.push({id:h,topology:l,bounds:d,links:a}),i.set(h,o),rf(o)){r.add(h);const t=o.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(h),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:i,routingTargetIds:r,stationClients:s}}function cf(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:i,components:r,routingTargetIds:s,stationClients:o}=af(t),a=Tp(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const i=[...e].sort((t,e)=>{const n=sf(t)??"",i=sf(e)??"";return n.localeCompare(i)});for(const e of i){const n=e.declaredHostRef?.();let i=null;if(n&&(i=t.findById?.(n)??null),!i){const n=e.hostCapability?.(),r=e.hostFacingPoint?.();n&&r&&(i=nf(t,n,r,e)?.component??null)}i&&"function"==typeof e.registerWithHost&&e.registerWithHost(i)}const r=e=>{if(!e)return;if(ef(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const i=t.findById?.(n);i&&e.registerDivertStation(n,i)}const n=e.components;if(Array.isArray(n))for(const t of n)r(t)};r(t)}(t,o);const c=new Set;for(const[t,e]of r){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const h=new Map;for(const t of s){const e=r.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&h.set(t,n)}}const l=Dp(a,{routingTargetIds:s,loopCapableIds:c,routingWeights:h});if(l.length>0&&"undefined"!=typeof console){const t=l.filter(t=>"error"===t.severity),e=l.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,l):console.info(`[FlowGraph] ${e.length} warning(s):`,l)}e={graph:a,destToSinks:i,components:r,issues:l},t.__flowGraph=e}return e}function hf(t){return cf(t)?.issues??[]}function lf(t){const e=cf(t);return e&&e.graph.nodes.size>0?e.graph:null}function uf(t,e){return cf(t)?.destToSinks.get(e)??[]}function df(t,e){return cf(t)?.components.get(e)}function pf(t){const e=cf(t);return e?[...e.destToSinks.keys()]:[]}function ff(t){return sf(t)}function mf(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function yf(t,e,n,i,r){if(1===i.length)return i[0];switch(t){case"index":default:return i[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),i[t%i.length]}case"weight":{const t=i.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(r.get(t.target))),s=t.reduce((t,e)=>t+e,0);if(s<=0)return i[0];const o=n.counters.get(e)??0;n.counters.set(e,o+1);let a=o%s;for(let e=0;e<i.length;e++){if(a<t[e])return i[e];a-=t[e]}return i[i.length-1]}case"utilization":{let t=1/0,e=i[0];for(const n of i){const i=mf(r.get(n.target));i<t&&(t=i,e=n)}return e}}}function gf(t,e,n){const i=t?.root;if(!i)return null;const r=e?.state?.meta?.destination;if("string"!=typeof r||0===r.length)return null;const s=cf(i);if(!s||0===s.graph.nodes.size)return null;const o=sf(t);if(!o)return null;let a=s.destToSinks.get(r)??[];0===a.length&&(a=[r]);const c=Fp(s.graph,o,a);if(0===c.length)return null;const h=s.graph.out.get(o)??[],l=c.filter(t=>{const n=h[t.index],i=n?s.components.get(n):null;return!i||"function"!=typeof i.canReceive||i.canReceive(e)});if(0===l.length)return h[c[0].index]??null;const u=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const i=e?.state?.routingBalancingPolicy;return i||"round-robin"}(t,i),d=yf(u,o,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(i),l,s.components);return h[d.index]??null}n({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slotLayout","get slots","slotById","slotSeatTransform","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),n({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,lf(t)}catch{return null}}}catch{}function bf(t,e,n){const i=gf(t,e,n);if(null==i)return null;const r=t?.root,s=df(r,i)??r?.findById?.(i)??null;return s?{targetId:i,component:s,origin:"explicit"}:null}function vf(t){const e=t?.root,n=lf(e),i=ff(t);if(!n||!i)return null;const r=(n.out.get(i)??[]).find(Boolean);if(!r)return null;const s=df(e,r)??e?.findById?.(r)??null;return s?{id:r,component:s}:null}function xf(t){const e=ff(t);return e?wf(t?.root,e):[]}function wf(t,e){if(!t||!e)return[];const n=lf(t);if(!n)return[];const i=new Set;for(const r of Cp(n,e)){const e=df(t,r);if(rf(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&i.add(t)}}return[...i]}function _f(t,e){if(!t||!e)return[];const n=lf(t);if(!n)return[];const i=new Map;for(const t of n.out.values())for(const e of t)null!=e&&i.set(e,(i.get(e)??0)+1);const r=new Map;for(const s of Cp(n,e)){const e=df(t,s);if(!rf(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let o=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(o=t)}null===o&&(o=i.get(s)??0,0===o&&(o=1)),r.set(n,(r.get(n)??0)+o)}return[...r].map(([t,e])=>({value:t,weight:e}))}function Mf(t){return lf(t)}function Sf(t){const e=lf(t);if(!e)return[];const n=new Set,i=new Set,r=t=>{if(!t)return;const s=ff(t);if(s&&e.nodes.has(s)){rf(t)&&n.add(s);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&i.add(s)}const o=t.components;if(Array.isArray(o))for(const t of o)r(t)};return r(t),Dp(e,{routingTargetIds:n,loopCapableIds:i})}function kf(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let i=0;for(const e of t)if(i+=e.weight,n<i)return e.value;return t[t.length-1].value}const Af={next:bf,downstream:vf,reachableDestinations:xf,reachableDestinationsFrom:wf,reachableDestinationsWeightedFrom:_f,pickWeightedDestination:kf,graphFor:Mf,validate:Sf};function zf(t){try{t()}catch(t){_a("[holdable] a listener of a handover failed; the handover stands",t)}}function Tf(t){let e=0;for(let n=t;n&&!n.isRootModel?.();n=n.parent)e+=n.state?.rotation||0;return e}function If(t,e){if("function"!=typeof t?.toScene)return null;try{const n=t.bounds,i=t.center,r=t.toScene(i.x,i.y),s={x:r.x,y:r.y,rotation:Tf(e),width:n.width,height:n.height};return Object.values(s).every(Number.isFinite)?s:null}catch{return null}}function Of(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const i=t.prototype?.attachPointFor;return"function"==typeof i?i.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,Au(this,t),!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n)if(this._items.splice(n,1),t.parent=null,this._reseatSlot(t[mn]),e)t._realObject?.setTransientDisplayScale?.(1);else{if(zu(t),function(t){const e=t?._realObject?.object3d;if(!e?.parent)return;let n=e.parent;for(;n.parent;)n=n.parent;n!==e.parent&&(n.updateWorldMatrix?.(!0,!1),e.updateWorldMatrix?.(!0,!1),n.attach(e))}(t),t._realObject?.setTransientDisplayScale?.(1,{x:1,y:1,z:1}),"function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=e?.slotId,i=e?.toParent3D,r=i?null:this.attachPointFor?.(t,{slotId:n}),s=e?.animated?function(t){const e=t?._realObject?.object3d;let n=null;if(e?.parent){e.updateWorldMatrix(!0,!1);const t=e.position.clone(),i=e.quaternion.clone(),r=e.scale.clone();e.matrixWorld.decompose(t,i,r),n={position:t,quaternion:i,scale:r}}return{world3D:n,world2D:t?.parent?If(t,t.parent):null}}(t):null,o=t.parent,a=o===this?t[mn]:void 0;o&&("function"==typeof o.removeComponent&&-1!==o._components?.indexOf?.(t)&&o.removeComponent(t,!0),o!==this&&"function"==typeof o.removeItem&&-1!==o._items?.indexOf?.(t)&&o.removeItem(t,!0));const c=-1===this._items.indexOf(t);c&&this._items.push(t),t.parent=this,void 0!==n&&(t[mn]=n),Au(this,t);const h=!!t._realObject?.object3d;h&&this.seatHeldItem(t,{toParent3D:i,slotId:n,point:r}),void 0!==a&&a!==t[mn]&&this._reseatSlot(a),c&&zf(()=>this.trigger?.("hold",this,t,this._items.length-1)),h||this.seatHeldItem(t,{toParent3D:i,slotId:n,point:r}),s&&function(t,e,n,i){const r=t.root?.transitionEffect;if(!r)return;const s=i.duration??2e3,o=i.ease??"inout",a=e._realObject?.object3d;if(n.world3D&&a?.parent){const t={pos:a.position.clone(),quat:a.quaternion.clone()},i={x:a.scale.x,y:a.scale.y,z:a.scale.z},c=a.parent;c.updateWorldMatrix(!0,!1);const h=c.matrixWorld.clone().invert(),l=a.matrixWorld.clone().compose(n.world3D.position,n.world3D.quaternion,n.world3D.scale).premultiply(h),u=a.position.clone(),d=a.quaternion.clone();return l.decompose(u,d,a.scale.clone()),void r.begin(e,{from3D:{pos:u,quat:d,fromScale:i,toScale:i},to3D:t,duration:s,ease:o,keepSuppressed:!0,placementAfter:e._realObject.placement})}const c=n.world2D?If(e,t):null;n.world2D&&c&&r.begin(e,{fromWorld:n.world2D,toWorld:c,duration:s,ease:o})}(this,t,s,e),zf(()=>t.held?.(this)),zf(()=>this._bumpReceived?.(t))}seatHeldItem(t,e={}){t.realObject;const n=t._realObject,i=n?.object3d;if(i){let r,s,o=e.toParent3D,a="world-preserve",c=1,h=null;if(!o){const n=void 0!==e.point?e.point:this.attachPointFor?.(t,{slotId:e.slotId});n?.attach&&(o=n.attach,r=n.localPosition,s=n.localRotation,a=n.carryPolicy??"world-preserve",c=n.displayScale??1,h=n.seat?.dims??null)}o&&i.parent!==o&&(o.updateWorldMatrix?.(!0,!1),i.updateWorldMatrix?.(!0,!1),o.attach(i),n.suppressTransform=!0),o&&(r&&i.position.set(r.x,r.y,r.z),"world-preserve"!==a?s?i.rotation.set(s.x,s.y,s.z):i.quaternion.identity():s&&i.rotation.set(s.x,s.y,s.z),n?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),n?.setTransientDisplayScale?.(c,function(t){if(!t?.matrixWorld)return;let e=t;for(;e.parent;)e=e.parent;t.updateWorldMatrix?.(!0,!1);const n=t.matrixWorld.elements,i=t=>Math.hypot(n[t],n[t+1],n[t+2]),r=e.scale??{x:1,y:1,z:1};return{x:i(0)/(r.x||1),y:i(4)/(r.y||1),z:i(8)/(r.z||1)}}(o)),t.takeSeatDims?.(h))}}_reseatSlot(t){if(null!=t)for(const e of this._items.slice())e?.[mn]===t&&e._realObject?.object3d&&this.seatHeldItem(e,{slotId:t})}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t){zu(e);try{e.dispose?.()}catch{}}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,i,r){for(let s=this._items.length-1;s>=0;s--){const o=this._items[s],a="static"===o.position?o.capture?.(t,e,r):o.capture?.(n,i,r);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const i=e.bounds;!e.showOverflow&&i&&(t.beginPath(),t.rect(i.left,i.top,i.width,i.height),t.clip(),t.closePath());const{left:r=0,top:s=0}=e.state??{};t.translate(r,s),this._drawItems(t),t.translate(-r,-s),t.restore()}capture(t,e,n){const i=this,r=this._items;if(r&&r.length>0&&(!i.app||i.app.isEditMode||!i.hidden)){const r=i.fromParent?.(t,e);if(r&&i.contains?.(r.x,r.y)){const s=i.bounds,o=this._captureItems(r.x-s.left,r.y-s.top,t,e,n);if(o)return o}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Ef(t,e,n){return void 0!==n?t._slotIfAvailable(t.slotById(n),e):t.findSlot(e)}function jf(t){var e;return(e=class extends t{reserve(t,e){const n=Ef(this,t,e?.slotId);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){Sn.log({role:"target",contract:"receive:enter",component:this,args:{carrier:dn(t),options:e}});const n=this.reserve(t,e);if(!n){Sn.log({role:"target",contract:"receive:reject",component:this,args:{carrier:dn(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,e,n={}){const i=t.slot,r=this._countOccupied(i.id),s=this.arrangementStrategy.positionAt(r,i,r,e);Sn.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:r,slotId:i.id,occupantCount:r,carrier:dn(e)},result:s});const o=function(t,e,n,i,r){const s={},o=t.placementFor?.(e,{slot:n,index:i,occupantCount:i})??null;if(Sn.log({role:"target",contract:"placementFor",component:t,args:{carrier:dn(e),slotId:n.id,index:i},result:o}),o){const i=e.state??{},r=t.state??{};s.left=o.position.x-(Number(i.width)||0)/2+(Number(r.width)||0)/2,s.top=o.position.z-(Number(i.height)||0)/2+(Number(r.height)||0)/2;const a=t._zPosFromSeatY(o.position.y,i.depth,n);null!==a&&(s.zPos=a),o.rotation&&fn(s,o.rotation)}else{if(r&&(s.left=r.x,s.top=r.y),0!==(t._realObject?.receivingSurfaceY??0))s.zPos=0;else if(n.localPosition&&Number.isFinite(n.localPosition.z)){const e=t._realObject?.geometricOffsetY??0;s.zPos=n.localPosition.z+e}const i=t.acceptanceRotation?.(e,n);Sn.log({role:"target",contract:"acceptanceRotation",component:t,args:{carrier:dn(e),slotId:n.id},result:i}),i&&fn(s,i)}const a=t.normalizePose?.(e,n);return"function"==typeof t.normalizePose&&Sn.log({role:"target",contract:"normalizePose",component:t,args:{carrier:dn(e),slotId:n.id},result:a}),a&&Object.assign(s,a),s}(this,e,i,r,s),a=e._realObject;let c,h;a?.object3d&&(a.object3d.updateWorldMatrix(!0,!1),c=new L,h=new N,a.object3d.getWorldPosition(c),a.object3d.getWorldQuaternion(h));const{animated:l=!1,duration:u,ease:d}=n;if("function"==typeof this.handoverIn?this.handoverIn(e,{slotId:i.id}):(e[mn]=i.id,this.reparent?.(e,{animated:l,duration:u,ease:d})),!l&&e._realObject&&(e._realObject.suppressTransform=!1),Object.keys(o).length){try{e.setState?.(o)}catch(t){_a("[transferable] the received item's state could not be set; the handover stands",t)}Sn.log({role:"target",contract:"receive:setState",component:this,args:{carrier:dn(e),keys:Object.keys(o)}})}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:i.id,preReceiveWorldPos:c,preReceiveWorldQuat:h}),Sn.log({role:"target",contract:"receive:done",component:this,args:{carrier:dn(e),slotId:i.id}})}async dispatch(t,e,n={}){const i=new Tn({source:this,target:e,carrier:t,options:n}),r=await i.execute();"rolled-back"!==r.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:r.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t,e){const n=(()=>{const n=this.slots;if(!n.length)return{ok:!1,reason:"no-slots-defined"};if(void 0!==e?.slotId){if(!this.slotById(e.slotId))return{ok:!1,reason:"slot-absent"};const n=Ef(this,t,e.slotId);return n?{ok:!0,slot:n}:{ok:!1,reason:"slot-unavailable"}}const i=this.findSlot(t);if(!i){const e=t?.state?.type??t?.type;for(const t of n)if(!t.allowedTypes?.length||!e||t.allowedTypes.includes(e))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:i}})();return Sn.log({role:"target",contract:"canAccept",component:this,args:{carrier:dn(t)},result:n.ok?{ok:!0,slotId:n.slot.id}:{ok:!1,reason:n.reason}}),n}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}function Pf(t){var e;const n=!!t.__hasCapacity,i=!!t.__hasTransferable,r=n?t:gp(t),s=i?r:jf(r),o=[...t.capabilities??[]];n||o.push("Capacity","PlacementSurface"),i||o.push("Transferable"),o.push("Holdable","FlowNode");var a,c,h;return Iu((e=class extends(Of(s)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},a=e,"symbol"==typeof(c="FlowNodeMixed")&&(c=c.description?"[".concat(c.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:h?"".concat(h," ",c):c}),e.capabilities=Object.freeze(o),e.isFlowNode=!0,e))}function Cf(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,n({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),n({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),n({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});export{Un as BULGE_EPSILON,gp as Capacity,ni as CapacityEventTracker,ri as CenteringQueueStrategy,m as CenteringSlotStrategy,Gd as DEFAULT_SEAT_MARGIN,p as FixedSlotStrategy,Af as FlowEngine,Pf as FlowNode,ai as GridStacking,Od as HOLDER_ANCHOR,Of as Holdable,xd as ITEM_TYPES_THEME,wd as ITEM_TYPE_CODE_MAX,bd as Item,vd as ItemRealObject,Iu as ItemsDataBinding,Rn as NavGraph,oi as PatternStacking,Jn as PolygonPathPolyline,Pn as ReservationTable,mn as TRANSFER_SLOT_KEY,Tn as Transfer,ci as VolumeStacking,$d as addressOfSlotId,pf as allDestinations,Mp as anchorsConnect,yf as applyPolicy,fn as applySeatingRotation,hi as applyStackLayout,wp as arcSegmentTopology,ii as autoWireBackPressure,Tp as buildFlowGraph,Nn as buildNavGraph,Vn as bulgeFromDrag,$n as bulgeHandlePosition,Pp as canReach,t as capability,d as chooseNearestPickupFrame,Np as collectAdjacentSegments,df as componentForNode,qn as computeArcParams,Kp as computeFlowMap,si as computeStackPositions,Hn as cornerHandlePosition,Gn as cornerRadiusFromDrag,Ap as deliversInto,vf as downstream,Yn as effectiveCornerRadius,Wp as enumerateDataScenarios,u as filterByToolType,nf as findNearestWithCapability,f as fixedSlotStrategy,Qn as flattenPolygonPath,lf as flowGraphFor,hf as flowGraphIssues,tf as flowReverseFor,li as footprint2D,vn as frameClock,Xp as ftId,Gp as ftrace,r as getAllCapabilityMeta,i as getCapabilityMeta,yn as globalSimClock,Mf as graphFor,Bd as gridCellOf,Ld as gridSlotNo,Wn as hasArc,ti as hasCapacity,ei as inferCapacity,Lp as inferDownstreamId,Hp as inferFlowDirections,Cf as isFlowNode,ef as isGeometricHost,kd as isItemTypeTable,rf as isRoutingTarget,ku as itemById,Su as itemIdOf,md as itemLookDimsOf,pp as itemSeatsOf,zd as itemTypeEntryOf,Ad as itemTypeTableOf,Sd as itemTypesFromThemes,rp as judgeItemFit,Id as layoutIssue,zp as matchOutbounds,bf as next,jp as nextHop,Ep as nextHops,Rp as nextHopsToAny,Fp as nextHopsToAnyDetailed,ff as nodeIdOf,cp as occupancySnapshotOf,Fd as persistenceIssues,kf as pickWeightedDestination,Ln as planPathAStar,Bn as planToReservations,Sp as pointInRotatedRect,Kn as polygonPathLength,o as quatFromYaw,kp as rayAbsDistanceToRect,Ip as reachableByOutbound,xf as reachableDestinations,wf as reachableDestinationsFrom,_f as reachableDestinationsWeightedFrom,Cp as reachableSinks,Md as readItemTypes,An as receiptToJSON,bp as rectFaceAnchors,h as rectangularFootprintFrames,n as registerCapabilityMeta,Cn as reservationTable,Pa as resolveLegend,Ra as resolveLegendEntries,gf as resolveNextHop,Wd as resolveSlot,Zd as rotatedFootprint,Jd as seatInSlot,Qd as seatTransform,fd as setItemLookProvider,uf as sinksForDestination,Vd as slotAddresses,Dd as slotCount,Hd as slotFrame,qd as slotIdOf,Nd as slotNumbers,ip as slotSpaceWarnings,Kd as stackSeatTransforms,jn as standardYieldPolicy,xp as straightSegmentEndpoints,_p as straightSegmentMultiInbound,vp as straightSegmentTopology,l as topApproachFrame,In as transferLog,Sn as transferTracer,Xn as uniformZ,Sf as validate,Dp as validateFlowGraph,Rd as validateSlotLayout};
6
+ */const y=1e3,g=1001,b="srgb",x="srgb-linear",v="linear",w="srgb",_=7680,M=2e3;function S(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const k={};function A(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function z(...t){const e="THREE."+(t=A(t)).shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function T(...t){const e="THREE."+(t=A(t)).shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function I(...t){const e=t.join(" ");e in k||(k[e]=!0,z(...t))}class O{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return void 0!==n&&(void 0!==n[t]&&-1!==n[t].indexOf(e))}removeEventListener(t,e){const n=this._listeners;if(void 0===n)return;const i=n[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const n=e[t.type];if(void 0!==n){t.target=this;const e=n.slice(0);for(let n=0,i=e.length;n<i;n++)e[n].call(this,t);t.target=null}}}const E=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function j(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(E[255&t]+E[t>>8&255]+E[t>>16&255]+E[t>>24&255]+"-"+E[255&e]+E[e>>8&255]+"-"+E[e>>16&15|64]+E[e>>24&255]+"-"+E[63&n|128]+E[n>>8&255]+"-"+E[n>>16&255]+E[n>>24&255]+E[255&i]+E[i>>8&255]+E[i>>16&255]+E[i>>24&255]).toLowerCase()}function P(t,e,n){return Math.max(e,Math.min(n,t))}function C(t,e,n){return(1-n)*t+n*e}function R(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function F(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("THREE.MathUtils: Invalid component type.")}}class D{static{D.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=P(this.x,t.x,e.x),this.y=P(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=P(this.x,t,e),this.y=P(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(P(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(P(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class N{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,o){let a=n[i+0],c=n[i+1],h=n[i+2],l=n[i+3],u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(l!==f||a!==u||c!==d||h!==p){let t=a*u+c*d+h*p+l*f;t<0&&(u=-u,d=-d,p=-p,f=-f,t=-t);let e=1-o;if(t<.9995){const n=Math.acos(t),i=Math.sin(n);e=Math.sin(e*n)/i,a=a*e+u*(o=Math.sin(o*n)/i),c=c*e+d*o,h=h*e+p*o,l=l*e+f*o}else{a=a*e+u*o,c=c*e+d*o,h=h*e+p*o,l=l*e+f*o;const t=1/Math.sqrt(a*a+c*c+h*h+l*l);a*=t,c*=t,h*=t,l*=t}}t[e]=a,t[e+1]=c,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,n,i,r,s){const o=n[i],a=n[i+1],c=n[i+2],h=n[i+3],l=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=o*p+h*l+a*d-c*u,t[e+1]=a*p+h*u+c*l-o*d,t[e+2]=c*p+h*d+o*u-a*l,t[e+3]=h*p-o*l-a*u-c*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,o=Math.cos,a=Math.sin,c=o(n/2),h=o(i/2),l=o(r/2),u=a(n/2),d=a(i/2),p=a(r/2);switch(s){case"XYZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"YXZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"ZXY":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"ZYX":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"YZX":this._x=u*h*l+c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l-u*d*p;break;case"XZY":this._x=u*h*l-c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l+u*d*p;break;default:z("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],o=e[5],a=e[9],c=e[2],h=e[6],l=e[10],u=n+o+l;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-a)*t,this._y=(r-c)*t,this._z=(s-i)*t}else if(n>o&&n>l){const t=2*Math.sqrt(1+n-o-l);this._w=(h-a)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+c)/t}else if(o>l){const t=2*Math.sqrt(1+o-n-l);this._w=(r-c)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(a+h)/t}else{const t=2*Math.sqrt(1+l-n-o);this._w=(s-i)/t,this._x=(r+c)/t,this._y=(a+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(P(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,o=e._x,a=e._y,c=e._z,h=e._w;return this._x=n*h+s*o+i*c-r*a,this._y=i*h+s*a+r*o-n*c,this._z=r*h+s*c+n*a-i*o,this._w=s*h-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,s=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,r=-r,s=-s,o=-o);let a=1-e;if(o<.9995){const t=Math.acos(o),c=Math.sin(t);a=Math.sin(a*t)/c,e=Math.sin(e*t)/c,this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+r*e,this._w=this._w*a+s*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+r*e,this._w=this._w*a+s*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{static{L.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(U.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(U.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z,a=t.w,c=2*(s*i-o*n),h=2*(o*e-r*i),l=2*(r*n-s*e);return this.x=e+a*c+s*l-o*h,this.y=n+a*h+o*c-r*l,this.z=i+a*l+r*h-s*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=P(this.x,t.x,e.x),this.y=P(this.y,t.y,e.y),this.z=P(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=P(this.x,t,e),this.y=P(this.y,t,e),this.z=P(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(P(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return B.copy(this).projectOnVector(t),this.sub(B)}reflect(t){return this.sub(B.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(P(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const B=new L,U=new N;class W{static{W.prototype.isMatrix3=!0}constructor(t,e,n,i,r,s,o,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,o,a,c)}set(t,e,n,i,r,s,o,a,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=a,h[6]=n,h[7]=s,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],h=n[4],l=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],y=i[6],g=i[1],b=i[4],x=i[7],v=i[2],w=i[5],_=i[8];return r[0]=s*f+o*g+a*v,r[3]=s*m+o*b+a*w,r[6]=s*y+o*x+a*_,r[1]=c*f+h*g+l*v,r[4]=c*m+h*b+l*w,r[7]=c*y+h*x+l*_,r[2]=u*f+d*g+p*v,r[5]=u*m+d*b+p*w,r[8]=u*y+d*x+p*_,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return e*s*h-e*o*c-n*r*h+n*o*a+i*r*c-i*s*a}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=h*s-o*c,u=o*a-h*r,d=c*r-s*a,p=e*l+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=l*f,t[1]=(i*c-h*n)*f,t[2]=(o*n-i*s)*f,t[3]=u*f,t[4]=(h*e-i*a)*f,t[5]=(i*r-o*e)*f,t[6]=d*f,t[7]=(n*a-c*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,o){const a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+t,-i*c,i*a,-i*(-c*s+a*o)+o+e,0,0,1),this}scale(t,e){return I("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(q.makeScale(t,e)),this}rotate(t){return I("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(q.makeRotation(-t)),this}translate(t,e){return I("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(q.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const q=new W,$=(new W).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),V=(new W).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Y(){const t={enabled:!0,workingColorSpace:x,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===w&&(t.r=G(t.r),t.g=G(t.g),t.b=G(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===w&&(t.r=X(t.r),t.g=X(t.g),t.b=X(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?v:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,n){return I("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,n)},toWorkingColorSpace:function(e,n){return I("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,n)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[x]:{primaries:e,whitePoint:i,transfer:v,toXYZ:$,fromXYZ:V,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:b},outputColorSpaceConfig:{drawingBufferColorSpace:b}},[b]:{primaries:e,whitePoint:i,transfer:w,toXYZ:$,fromXYZ:V,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:b}}}),t}const H=Y();function G(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function X(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Z;class J{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{void 0===Z&&(Z=S("canvas")),Z.width=t.width,Z.height=t.height;const e=Z.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),n=Z}return n.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=S("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*G(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*G(e[t]/255)):e[t]=G(e[t]);return{data:e,width:t.width,height:t.height}}return z("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Q=0;class K{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Q++}),this.uuid=j(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(tt(i[e].image)):t.push(tt(i[e]))}else t=tt(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function tt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?J.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(z("Texture: Unable to serialize Texture."),{})}let et=0;const nt=new L;class it extends O{constructor(t=it.DEFAULT_IMAGE,e=it.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=it.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:et++}),this.uuid=j(),this.name="",this.source=new K(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new D(0,0),this.repeat=new D(1,1),this.center=new D(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new W,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(nt).x}get height(){return this.source.getSize(nt).y}get depth(){return this.source.getSize(nt).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(void 0===n){z(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n:z(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case y:t.x=t.x-Math.floor(t.x);break;case g:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case y:t.y=t.y-Math.floor(t.y);break;case g:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}it.DEFAULT_IMAGE=null,it.DEFAULT_MAPPING=300,it.DEFAULT_ANISOTROPY=1;class rt{static{rt.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,o=.1,a=t.elements,c=a[0],h=a[4],l=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],y=a[10];if(Math.abs(h-u)<s&&Math.abs(l-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+u)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(c+d+y-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(d+1)/2,g=(y+1)/2,b=(h+u)/4,x=(l+f)/4,v=(p+m)/4;return t>a&&t>g?t<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=b/n,r=x/n):a>g?a<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),n=b/i,r=v/i):g<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(g),n=x/r,i=v/r),this.set(n,i,r,e),this}let g=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-h)*(u-h));return Math.abs(g)<.001&&(g=1),this.x=(m-p)/g,this.y=(l-f)/g,this.z=(u-h)/g,this.w=Math.acos((c+d+y-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=P(this.x,t.x,e.x),this.y=P(this.y,t.y,e.y),this.z=P(this.z,t.z,e.z),this.w=P(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=P(this.x,t,e),this.y=P(this.y,t,e),this.z=P(this.z,t,e),this.w=P(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(P(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class st{static{st.prototype.isMatrix4=!0}constructor(t,e,n,i,r,s,o,a,c,h,l,u,d,p,f,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,o,a,c,h,l,u,d,p,f,m)}set(t,e,n,i,r,s,o,a,c,h,l,u,d,p,f,m){const y=this.elements;return y[0]=t,y[4]=e,y[8]=n,y[12]=i,y[1]=r,y[5]=s,y[9]=o,y[13]=a,y[2]=c,y[6]=h,y[10]=l,y[14]=u,y[3]=d,y[7]=p,y[11]=f,y[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new st).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,n=t.elements,i=1/ot.setFromMatrixColumn(t,0).length(),r=1/ot.setFromMatrixColumn(t,1).length(),s=1/ot.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),h=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){const t=s*h,n=s*l,i=o*h,r=o*l;e[0]=a*h,e[4]=-a*l,e[8]=c,e[1]=n+i*c,e[5]=t-r*c,e[9]=-o*a,e[2]=r-t*c,e[6]=i+n*c,e[10]=s*a}else if("YXZ"===t.order){const t=a*h,n=a*l,i=c*h,r=c*l;e[0]=t+r*o,e[4]=i*o-n,e[8]=s*c,e[1]=s*l,e[5]=s*h,e[9]=-o,e[2]=n*o-i,e[6]=r+t*o,e[10]=s*a}else if("ZXY"===t.order){const t=a*h,n=a*l,i=c*h,r=c*l;e[0]=t-r*o,e[4]=-s*l,e[8]=i+n*o,e[1]=n+i*o,e[5]=s*h,e[9]=r-t*o,e[2]=-s*c,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){const t=s*h,n=s*l,i=o*h,r=o*l;e[0]=a*h,e[4]=i*c-n,e[8]=t*c+r,e[1]=a*l,e[5]=r*c+t,e[9]=n*c-i,e[2]=-c,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){const t=s*a,n=s*c,i=o*a,r=o*c;e[0]=a*h,e[4]=r-t*l,e[8]=i*l+n,e[1]=l,e[5]=s*h,e[9]=-o*h,e[2]=-c*h,e[6]=n*l+i,e[10]=t-r*l}else if("XZY"===t.order){const t=s*a,n=s*c,i=o*a,r=o*c;e[0]=a*h,e[4]=-l,e[8]=c*h,e[1]=t*l+r,e[5]=s*h,e[9]=n*l-i,e[2]=i*l-n,e[6]=o*h,e[10]=r*l+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ct,t,ht)}lookAt(t,e,n){const i=this.elements;return dt.subVectors(t,e),0===dt.lengthSq()&&(dt.z=1),dt.normalize(),lt.crossVectors(n,dt),0===lt.lengthSq()&&(1===Math.abs(n.z)?dt.x+=1e-4:dt.z+=1e-4,dt.normalize(),lt.crossVectors(n,dt)),lt.normalize(),ut.crossVectors(dt,lt),i[0]=lt.x,i[4]=ut.x,i[8]=dt.x,i[1]=lt.y,i[5]=ut.y,i[9]=dt.y,i[2]=lt.z,i[6]=ut.z,i[10]=dt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],h=n[1],l=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],y=n[14],g=n[3],b=n[7],x=n[11],v=n[15],w=i[0],_=i[4],M=i[8],S=i[12],k=i[1],A=i[5],z=i[9],T=i[13],I=i[2],O=i[6],E=i[10],j=i[14],P=i[3],C=i[7],R=i[11],F=i[15];return r[0]=s*w+o*k+a*I+c*P,r[4]=s*_+o*A+a*O+c*C,r[8]=s*M+o*z+a*E+c*R,r[12]=s*S+o*T+a*j+c*F,r[1]=h*w+l*k+u*I+d*P,r[5]=h*_+l*A+u*O+d*C,r[9]=h*M+l*z+u*E+d*R,r[13]=h*S+l*T+u*j+d*F,r[2]=p*w+f*k+m*I+y*P,r[6]=p*_+f*A+m*O+y*C,r[10]=p*M+f*z+m*E+y*R,r[14]=p*S+f*T+m*j+y*F,r[3]=g*w+b*k+x*I+v*P,r[7]=g*_+b*A+x*O+v*C,r[11]=g*M+b*z+x*E+v*R,r[15]=g*S+b*T+x*j+v*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],o=t[5],a=t[9],c=t[13],h=t[2],l=t[6],u=t[10],d=t[14],p=t[3],f=t[7],m=t[11],y=t[15],g=a*d-c*u,b=o*d-c*l,x=o*u-a*l,v=s*d-c*h,w=s*u-a*h,_=s*l-o*h;return e*(f*g-m*b+y*x)-n*(p*g-m*v+y*w)+i*(p*b-f*v+y*_)-r*(p*x-f*w+m*_)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[1],s=t[5],o=t[9],a=t[2],c=t[6],h=t[10];return e*(s*h-o*c)-n*(r*h-o*a)+i*(r*c-s*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],y=t[15],g=e*o-n*s,b=e*a-i*s,x=e*c-r*s,v=n*a-i*o,w=n*c-r*o,_=i*c-r*a,M=h*f-l*p,S=h*m-u*p,k=h*y-d*p,A=l*m-u*f,z=l*y-d*f,T=u*y-d*m,I=g*T-b*z+x*A+v*k-w*S+_*M;if(0===I)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/I;return t[0]=(o*T-a*z+c*A)*O,t[1]=(i*z-n*T-r*A)*O,t[2]=(f*_-m*w+y*v)*O,t[3]=(u*w-l*_-d*v)*O,t[4]=(a*k-s*T-c*S)*O,t[5]=(e*T-i*k+r*S)*O,t[6]=(m*x-p*_-y*b)*O,t[7]=(h*_-u*x+d*b)*O,t[8]=(s*z-o*k+c*M)*O,t[9]=(n*k-e*z-r*M)*O,t[10]=(p*w-f*x+y*g)*O,t[11]=(l*x-h*w-d*g)*O,t[12]=(o*S-s*A-a*M)*O,t[13]=(e*A-n*S+i*M)*O,t[14]=(f*b-p*v-m*g)*O,t[15]=(h*v-l*b+u*g)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,o=t.y,a=t.z,c=r*s,h=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,h*o+n,h*a-i*s,0,c*a-i*o,h*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,c=r+r,h=s+s,l=o+o,u=r*c,d=r*h,p=r*l,f=s*h,m=s*l,y=o*l,g=a*c,b=a*h,x=a*l,v=n.x,w=n.y,_=n.z;return i[0]=(1-(f+y))*v,i[1]=(d+x)*v,i[2]=(p-b)*v,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(u+y))*w,i[6]=(m+g)*w,i[7]=0,i[8]=(p+b)*_,i[9]=(m-g)*_,i[10]=(1-(u+f))*_,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(0===r)return n.set(1,1,1),e.identity(),this;let s=ot.set(i[0],i[1],i[2]).length();const o=ot.set(i[4],i[5],i[6]).length(),a=ot.set(i[8],i[9],i[10]).length();r<0&&(s=-s),at.copy(this);const c=1/s,h=1/o,l=1/a;return at.elements[0]*=c,at.elements[1]*=c,at.elements[2]*=c,at.elements[4]*=h,at.elements[5]*=h,at.elements[6]*=h,at.elements[8]*=l,at.elements[9]*=l,at.elements[10]*=l,e.setFromRotationMatrix(at),n.x=s,n.y=o,n.z=a,this}makePerspective(t,e,n,i,r,s,o=2e3,a=!1){const c=this.elements,h=2*r/(e-t),l=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let p,f;if(a)p=r/(s-r),f=s*r/(s-r);else if(o===M)p=-(s+r)/(s-r),f=-2*s*r/(s-r);else{if(2001!==o)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);p=-s/(s-r),f=-s*r/(s-r)}return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=l,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,r,s,o=2e3,a=!1){const c=this.elements,h=2/(e-t),l=2/(n-i),u=-(e+t)/(e-t),d=-(n+i)/(n-i);let p,f;if(a)p=1/(s-r),f=s/(s-r);else if(o===M)p=-2/(s-r),f=-(s+r)/(s-r);else{if(2001!==o)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);p=-1/(s-r),f=-r/(s-r)}return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=l,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const ot=new L,at=new st,ct=new L(0,0,0),ht=new L(1,1,1),lt=new L,ut=new L,dt=new L,pt=new st,ft=new N;class mt{constructor(t=0,e=0,n=0,i=mt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],h=i[9],l=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(P(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-P(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-l,r),this._z=0);break;case"ZXY":this._x=Math.asin(P(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-P(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(P(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-l,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-P(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:z("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return pt.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pt,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ft.setFromEuler(this),this.setFromQuaternion(ft,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}mt.DEFAULT_ORDER="XYZ";class yt{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let gt=0;const bt=new L,xt=new N,vt=new st,wt=new L,_t=new L,Mt=new L,St=new N,kt=new L(1,0,0),At=new L(0,1,0),zt=new L(0,0,1),Tt={type:"added"},It={type:"removed"},Ot={type:"childadded",child:null},Et={type:"childremoved",child:null};class jt extends O{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gt++}),this.uuid=j(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=jt.DEFAULT_UP.clone();const t=new L,e=new mt,n=new N,i=new L(1,1,1);e._onChange(function(){n.setFromEuler(e,!1)}),n._onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new st},normalMatrix:{value:new W}}),this.matrix=new st,this.matrixWorld=new st,this.matrixAutoUpdate=jt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return xt.setFromAxisAngle(t,e),this.quaternion.multiply(xt),this}rotateOnWorldAxis(t,e){return xt.setFromAxisAngle(t,e),this.quaternion.premultiply(xt),this}rotateX(t){return this.rotateOnAxis(kt,t)}rotateY(t){return this.rotateOnAxis(At,t)}rotateZ(t){return this.rotateOnAxis(zt,t)}translateOnAxis(t,e){return bt.copy(t).applyQuaternion(this.quaternion),this.position.add(bt.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(kt,t)}translateY(t){return this.translateOnAxis(At,t)}translateZ(t){return this.translateOnAxis(zt,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(vt.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?wt.copy(t):wt.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),_t.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vt.lookAt(_t,wt,this.up):vt.lookAt(wt,_t,this.up),this.quaternion.setFromRotationMatrix(vt),i&&(vt.extractRotation(i.matrixWorld),xt.setFromRotationMatrix(vt),this.quaternion.premultiply(xt.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(T("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Tt),Ot.child=t,this.dispatchEvent(Ot),Ot.child=null):T("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(It),Et.child=t,this.dispatchEvent(Et),Et.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),vt.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),vt.multiply(t.parent.matrixWorld)),t.applyMatrix4(vt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Tt),Ot.child=t,this.dispatchEvent(Ot),Ot.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_t,t,Mt),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_t,St,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(null!==t){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e,n=!1){const i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){t[e].updateWorldMatrix(!1,!0,n)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),!1!==this.static&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(t=>({...t})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),o=s(t.images),a=s(t.shapes),c=s(t.skeletons),h=s(t.animations),l=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),a.length>0&&(n.shapes=a),c.length>0&&(n.skeletons=c),h.length>0&&(n.animations=h),l.length>0&&(n.nodes=l)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=null!==t.pivot?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}jt.DEFAULT_UP=new L(0,1,0),jt.DEFAULT_MATRIX_AUTO_UPDATE=!0,jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Pt extends jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ct={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Rt={h:0,s:0,l:0},Ft={h:0,s:0,l:0};function Dt(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Nt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=b){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,H.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=H.workingColorSpace){return this.r=t,this.g=e,this.b=n,H.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=H.workingColorSpace){var r;if(t=(t%(r=1)+r)%r,e=P(e,0,1),n=P(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Dt(r,i,t+1/3),this.g=Dt(r,i,t),this.b=Dt(r,i,t-1/3)}return H.colorSpaceToWorking(this,i),this}setStyle(t,e=b){function n(e){void 0!==e&&parseFloat(e)<1&&z("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:z("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);z("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=b){const n=Ct[t.toLowerCase()];return void 0!==n?this.setHex(n,e):z("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=G(t.r),this.g=G(t.g),this.b=G(t.b),this}copyLinearToSRGB(t){return this.r=X(t.r),this.g=X(t.g),this.b=X(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=b){return H.workingToColorSpace(Lt.copy(this),t),65536*Math.round(P(255*Lt.r,0,255))+256*Math.round(P(255*Lt.g,0,255))+Math.round(P(255*Lt.b,0,255))}getHexString(t=b){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=H.workingColorSpace){H.workingToColorSpace(Lt.copy(this),e);const n=Lt.r,i=Lt.g,r=Lt.b,s=Math.max(n,i,r),o=Math.min(n,i,r);let a,c;const h=(o+s)/2;if(o===s)a=0,c=0;else{const t=s-o;switch(c=h<=.5?t/(s+o):t/(2-s-o),s){case n:a=(i-r)/t+(i<r?6:0);break;case i:a=(r-n)/t+2;break;case r:a=(n-i)/t+4}a/=6}return t.h=a,t.s=c,t.l=h,t}getRGB(t,e=H.workingColorSpace){return H.workingToColorSpace(Lt.copy(this),e),t.r=Lt.r,t.g=Lt.g,t.b=Lt.b,t}getStyle(t=b){H.workingToColorSpace(Lt.copy(this),t);const e=Lt.r,n=Lt.g,i=Lt.b;return t!==b?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(Rt),this.setHSL(Rt.h+t,Rt.s+e,Rt.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Rt),t.getHSL(Ft);const n=C(Rt.h,Ft.h,e),i=C(Rt.s,Ft.s,e),r=C(Rt.l,Ft.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Lt=new Nt;Nt.NAMES=Ct;const Bt=new L,Ut=new L,Wt=new L,qt=new L,$t=new L,Vt=new L,Yt=new L,Ht=new L,Gt=new L,Xt=new L,Zt=new rt,Jt=new rt,Qt=new rt;class Kt{constructor(t=new L,e=new L,n=new L){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Bt.subVectors(t,e),i.cross(Bt);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Bt.subVectors(i,e),Ut.subVectors(n,e),Wt.subVectors(t,e);const s=Bt.dot(Bt),o=Bt.dot(Ut),a=Bt.dot(Wt),c=Ut.dot(Ut),h=Ut.dot(Wt),l=s*c-o*o;if(0===l)return r.set(0,0,0),null;const u=1/l,d=(c*a-o*h)*u,p=(s*h-o*a)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,qt)&&(qt.x>=0&&qt.y>=0&&qt.x+qt.y<=1)}static getInterpolation(t,e,n,i,r,s,o,a){return null===this.getBarycoord(t,e,n,i,qt)?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(r,qt.x),a.addScaledVector(s,qt.y),a.addScaledVector(o,qt.z),a)}static getInterpolatedAttribute(t,e,n,i,r,s){return Zt.setScalar(0),Jt.setScalar(0),Qt.setScalar(0),Zt.fromBufferAttribute(t,e),Jt.fromBufferAttribute(t,n),Qt.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(Zt,r.x),s.addScaledVector(Jt,r.y),s.addScaledVector(Qt,r.z),s}static isFrontFacing(t,e,n,i){return Bt.subVectors(n,e),Ut.subVectors(t,e),Bt.cross(Ut).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Bt.subVectors(this.c,this.b),Ut.subVectors(this.a,this.b),.5*Bt.cross(Ut).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Kt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Kt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Kt.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Kt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Kt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,o;$t.subVectors(i,n),Vt.subVectors(r,n),Ht.subVectors(t,n);const a=$t.dot(Ht),c=Vt.dot(Ht);if(a<=0&&c<=0)return e.copy(n);Gt.subVectors(t,i);const h=$t.dot(Gt),l=Vt.dot(Gt);if(h>=0&&l<=h)return e.copy(i);const u=a*l-h*c;if(u<=0&&a>=0&&h<=0)return s=a/(a-h),e.copy(n).addScaledVector($t,s);Xt.subVectors(t,r);const d=$t.dot(Xt),p=Vt.dot(Xt);if(p>=0&&d<=p)return e.copy(r);const f=d*c-a*p;if(f<=0&&c>=0&&p<=0)return o=c/(c-p),e.copy(n).addScaledVector(Vt,o);const m=h*p-d*l;if(m<=0&&l-h>=0&&d-p>=0)return Yt.subVectors(r,i),o=(l-h)/(l-h+(d-p)),e.copy(i).addScaledVector(Yt,o);const y=1/(m+f+u);return s=f*y,o=u*y,e.copy(n).addScaledVector($t,s).addScaledVector(Vt,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class te{constructor(t=new L(1/0,1/0,1/0),e=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(ne.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(ne.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ne.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,ne):ne.fromBufferAttribute(i,e),ne.applyMatrix4(t.matrixWorld),this.expandByPoint(ne);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),ie.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),ie.copy(n.boundingBox)),ie.applyMatrix4(t.matrixWorld),this.union(ie)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ne),ne.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(le),ue.subVectors(this.max,le),re.subVectors(t.a,le),se.subVectors(t.b,le),oe.subVectors(t.c,le),ae.subVectors(se,re),ce.subVectors(oe,se),he.subVectors(re,oe);let e=[0,-ae.z,ae.y,0,-ce.z,ce.y,0,-he.z,he.y,ae.z,0,-ae.x,ce.z,0,-ce.x,he.z,0,-he.x,-ae.y,ae.x,0,-ce.y,ce.x,0,-he.y,he.x,0];return!!fe(e,re,se,oe,ue)&&(e=[1,0,0,0,1,0,0,0,1],!!fe(e,re,se,oe,ue)&&(de.crossVectors(ae,ce),e=[de.x,de.y,de.z],fe(e,re,se,oe,ue)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ne).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ne).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(ee[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ee[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ee[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ee[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ee[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ee[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ee[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ee[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ee)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const ee=[new L,new L,new L,new L,new L,new L,new L,new L],ne=new L,ie=new te,re=new L,se=new L,oe=new L,ae=new L,ce=new L,he=new L,le=new L,ue=new L,de=new L,pe=new L;function fe(t,e,n,i,r){for(let s=0,o=t.length-3;s<=o;s+=3){pe.fromArray(t,s);const o=r.x*Math.abs(pe.x)+r.y*Math.abs(pe.y)+r.z*Math.abs(pe.z),a=e.dot(pe),c=n.dot(pe),h=i.dot(pe);if(Math.max(-Math.max(a,c,h),Math.min(a,c,h))>o)return!1}return!0}const me=new L,ye=new D;let ge=0;class be extends O{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ge++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)ye.fromBufferAttribute(this,e),ye.applyMatrix3(t),this.setXY(e,ye.x,ye.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix3(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix4(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyNormalMatrix(t),this.setXYZ(e,me.x,me.y,me.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.transformDirection(t),this.setXYZ(e,me.x,me.y,me.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=R(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=F(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=R(e,this.array)),e}setX(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=R(e,this.array)),e}setY(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=R(e,this.array)),e}setZ(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=R(e,this.array)),e}setW(t,e){return this.normalized&&(e=F(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),n=F(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),n=F(n,this.array),i=F(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),n=F(n,this.array),i=F(i,this.array),r=F(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),35044!==this.usage&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class xe extends be{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ve extends be{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class we extends be{constructor(t,e,n){super(new Float32Array(t),e,n)}}const _e=new te,Me=new L,Se=new L;class ke{constructor(t=new L,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):_e.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Me.subVectors(t,this.center);const e=Me.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(Me,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Se.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Me.copy(t.center).add(Se)),this.expandByPoint(Me.copy(t.center).sub(Se))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Ae=0;const ze=new st,Te=new jt,Ie=new L,Oe=new te,Ee=new te,je=new L;class Pe extends O{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ae++}),this.uuid=j(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?ve:xe)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new W).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return ze.makeRotationFromQuaternion(t),this.applyMatrix4(ze),this}rotateX(t){return ze.makeRotationX(t),this.applyMatrix4(ze),this}rotateY(t){return ze.makeRotationY(t),this.applyMatrix4(ze),this}rotateZ(t){return ze.makeRotationZ(t),this.applyMatrix4(ze),this}translate(t,e,n){return ze.makeTranslation(t,e,n),this.applyMatrix4(ze),this}scale(t,e,n){return ze.makeScale(t,e,n),this.applyMatrix4(ze),this}lookAt(t){return Te.lookAt(t),Te.updateMatrix(),this.applyMatrix4(Te.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ie).negate(),this.translate(Ie.x,Ie.y,Ie.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new we(e,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&z("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new te);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return T("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Oe.setFromBufferAttribute(n),this.morphTargetsRelative?(je.addVectors(this.boundingBox.min,Oe.min),this.boundingBox.expandByPoint(je),je.addVectors(this.boundingBox.max,Oe.max),this.boundingBox.expandByPoint(je)):(this.boundingBox.expandByPoint(Oe.min),this.boundingBox.expandByPoint(Oe.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&T('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ke);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return T("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new L,1/0);if(t){const n=this.boundingSphere.center;if(Oe.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ee.setFromBufferAttribute(n),this.morphTargetsRelative?(je.addVectors(Oe.min,Ee.min),Oe.expandByPoint(je),je.addVectors(Oe.max,Ee.max),Oe.expandByPoint(je)):(Oe.expandByPoint(Ee.min),Oe.expandByPoint(Ee.max))}Oe.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)je.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(je));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],o=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)je.fromBufferAttribute(s,e),o&&(Ie.fromBufferAttribute(t,e),je.add(Ie)),i=Math.max(i,n.distanceToSquared(je))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&T('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void T("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;let s=this.getAttribute("tangent");void 0!==s&&s.count===n.count||(s=new be(new Float32Array(4*n.count),4),this.setAttribute("tangent",s));const o=[],a=[];for(let t=0;t<n.count;t++)o[t]=new L,a[t]=new L;const c=new L,h=new L,l=new L,u=new D,d=new D,p=new D,f=new L,m=new L;function y(t,e,i){c.fromBufferAttribute(n,t),h.fromBufferAttribute(n,e),l.fromBufferAttribute(n,i),u.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),h.sub(c),l.sub(c),d.sub(u),p.sub(u);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(h).multiplyScalar(p.y).addScaledVector(l,-d.y).multiplyScalar(s),m.copy(l).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(s),o[t].add(f),o[e].add(f),o[i].add(f),a[t].add(m),a[e].add(m),a[i].add(m))}let g=this.groups;0===g.length&&(g=[{start:0,count:t.count}]);for(let e=0,n=g.length;e<n;++e){const n=g[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)y(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const b=new L,x=new L,v=new L,w=new L;function _(t){v.fromBufferAttribute(i,t),w.copy(v);const e=o[t];b.copy(e),b.sub(v.multiplyScalar(v.dot(e))).normalize(),x.crossVectors(w,e);const n=x.dot(a[t])<0?-1:1;s.setXYZW(t,b.x,b.y,b.z,n)}for(let e=0,n=g.length;e<n;++e){const n=g[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)_(t.getX(e+0)),_(t.getX(e+1)),_(t.getX(e+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n||n.count!==e.count)n=new be(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new L,r=new L,s=new L,o=new L,a=new L,c=new L,h=new L,l=new L;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),l.subVectors(i,r),h.cross(l),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,p),c.fromBufferAttribute(n,f),o.add(h),a.add(h),c.add(h),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(f,c.x,c.y,c.z)}else for(let t=0,o=e.count;t<o;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),l.subVectors(i,r),h.cross(l),n.setXYZ(t+0,h.x,h.y,h.z),n.setXYZ(t+1,h.x,h.y,h.z),n.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)je.fromBufferAttribute(t,e),je.normalize(),t.setXYZ(e,je.x,je.y,je.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let o=0,a=0;for(let r=0,c=e.length;r<c;r++){o=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)s[a++]=n[o++]}return new be(s,i,r)}if(null===this.index)return z("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Pe,n=this.index.array,i=this.attributes;for(const r in i){const s=t(i[r],n);e.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],o=r[i];for(let e=0,i=o.length;e<i;e++){const i=t(o[e],n);s.push(i)}e.morphAttributes[i]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=void 0!==this.parameters&&!0===this._transformed?"BufferGeometry":this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters&&!0!==this._transformed){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];s.push(i.toJSON(t.data))}s.length>0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere=o.toJSON()),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone());const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Ce=0;class Re extends O{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ce++}),this.uuid=j(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nt(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=_,this.stencilZFail=_,this.stencilZPass=_,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){z(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:z(`Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_&&(n.stencilFail=this.stencilFail),this.stencilZFail!==_&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==_&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}fromJSON(t,e){if(void 0!==t.uuid&&(this.uuid=t.uuid),void 0!==t.name&&(this.name=t.name),void 0!==t.color&&void 0!==this.color&&this.color.setHex(t.color),void 0!==t.roughness&&(this.roughness=t.roughness),void 0!==t.metalness&&(this.metalness=t.metalness),void 0!==t.sheen&&(this.sheen=t.sheen),void 0!==t.sheenColor&&(this.sheenColor=(new Nt).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(this.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==this.emissive&&this.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==this.specular&&this.specular.setHex(t.specular),void 0!==t.specularIntensity&&(this.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==this.specularColor&&this.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(this.shininess=t.shininess),void 0!==t.clearcoat&&(this.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(this.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(this.dispersion=t.dispersion),void 0!==t.iridescence&&(this.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(this.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(this.transmission=t.transmission),void 0!==t.thickness&&(this.thickness=t.thickness),void 0!==t.attenuationDistance&&(this.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==this.attenuationColor&&this.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(this.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(this.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(this.fog=t.fog),void 0!==t.flatShading&&(this.flatShading=t.flatShading),void 0!==t.blending&&(this.blending=t.blending),void 0!==t.combine&&(this.combine=t.combine),void 0!==t.side&&(this.side=t.side),void 0!==t.shadowSide&&(this.shadowSide=t.shadowSide),void 0!==t.opacity&&(this.opacity=t.opacity),void 0!==t.transparent&&(this.transparent=t.transparent),void 0!==t.alphaTest&&(this.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(this.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(this.depthFunc=t.depthFunc),void 0!==t.depthTest&&(this.depthTest=t.depthTest),void 0!==t.depthWrite&&(this.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(this.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(this.blendSrc=t.blendSrc),void 0!==t.blendDst&&(this.blendDst=t.blendDst),void 0!==t.blendEquation&&(this.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(this.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(this.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(this.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==this.blendColor&&this.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(this.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(this.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(this.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(this.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(this.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(this.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(this.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(this.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(this.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(this.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(this.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(this.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(this.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.linewidth&&(this.linewidth=t.linewidth),void 0!==t.dashSize&&(this.dashSize=t.dashSize),void 0!==t.gapSize&&(this.gapSize=t.gapSize),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.polygonOffset&&(this.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(this.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(this.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(this.dithering=t.dithering),void 0!==t.alphaToCoverage&&(this.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(this.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(this.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(this.allowOverride=t.allowOverride),void 0!==t.visible&&(this.visible=t.visible),void 0!==t.toneMapped&&(this.toneMapped=t.toneMapped),void 0!==t.userData&&(this.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),void 0!==t.size&&(this.size=t.size),void 0!==t.sizeAttenuation&&(this.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(this.map=e[t.map]||null),void 0!==t.matcap&&(this.matcap=e[t.matcap]||null),void 0!==t.alphaMap&&(this.alphaMap=e[t.alphaMap]||null),void 0!==t.bumpMap&&(this.bumpMap=e[t.bumpMap]||null),void 0!==t.bumpScale&&(this.bumpScale=t.bumpScale),void 0!==t.normalMap&&(this.normalMap=e[t.normalMap]||null),void 0!==t.normalMapType&&(this.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),this.normalScale=(new D).fromArray(e)}return void 0!==t.displacementMap&&(this.displacementMap=e[t.displacementMap]||null),void 0!==t.displacementScale&&(this.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(this.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(this.roughnessMap=e[t.roughnessMap]||null),void 0!==t.metalnessMap&&(this.metalnessMap=e[t.metalnessMap]||null),void 0!==t.emissiveMap&&(this.emissiveMap=e[t.emissiveMap]||null),void 0!==t.emissiveIntensity&&(this.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(this.specularMap=e[t.specularMap]||null),void 0!==t.specularIntensityMap&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),void 0!==t.specularColorMap&&(this.specularColorMap=e[t.specularColorMap]||null),void 0!==t.envMap&&(this.envMap=e[t.envMap]||null),void 0!==t.envMapRotation&&this.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(this.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(this.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(this.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(this.lightMap=e[t.lightMap]||null),void 0!==t.lightMapIntensity&&(this.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(this.aoMap=e[t.aoMap]||null),void 0!==t.aoMapIntensity&&(this.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(this.gradientMap=e[t.gradientMap]||null),void 0!==t.clearcoatMap&&(this.clearcoatMap=e[t.clearcoatMap]||null),void 0!==t.clearcoatRoughnessMap&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),void 0!==t.clearcoatNormalMap&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),void 0!==t.clearcoatNormalScale&&(this.clearcoatNormalScale=(new D).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(this.iridescenceMap=e[t.iridescenceMap]||null),void 0!==t.iridescenceThicknessMap&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),void 0!==t.transmissionMap&&(this.transmissionMap=e[t.transmissionMap]||null),void 0!==t.thicknessMap&&(this.thicknessMap=e[t.thicknessMap]||null),void 0!==t.anisotropyMap&&(this.anisotropyMap=e[t.anisotropyMap]||null),void 0!==t.sheenColorMap&&(this.sheenColorMap=e[t.sheenColorMap]||null),void 0!==t.sheenRoughnessMap&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}const Fe=new L,De=new L,Ne=new L,Le=new L,Be=new L,Ue=new L,We=new L;class qe{constructor(t=new L,e=new L(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Fe)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Fe.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Fe.copy(this.origin).addScaledVector(this.direction,e),Fe.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){De.copy(t).add(e).multiplyScalar(.5),Ne.copy(e).sub(t).normalize(),Le.copy(this.origin).sub(De);const r=.5*t.distanceTo(e),s=-this.direction.dot(Ne),o=Le.dot(this.direction),a=-Le.dot(Ne),c=Le.lengthSq(),h=Math.abs(1-s*s);let l,u,d,p;if(h>0)if(l=s*a-o,u=s*o-a,p=r*h,l>=0)if(u>=-p)if(u<=p){const t=1/h;l*=t,u*=t,d=l*(l+s*u+2*o)+u*(s*l+u+2*a)+c}else u=r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u=-r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u<=-p?(l=Math.max(0,-(-s*r+o)),u=l>0?-r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c):u<=p?(l=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+c):(l=Math.max(0,-(s*r+o)),u=l>0?r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c);else u=s>0?-r:r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,l),i&&i.copy(De).addScaledVector(Ne,u),d}intersectSphere(t,e){Fe.subVectors(t.center,this.origin);const n=Fe.dot(this.direction),i=Fe.dot(Fe)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),o=n-s,a=n+s;return a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,o,a;const c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,i=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,i=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),n>a||o>i?null:((o>n||n!=n)&&(n=o),(a<i||i!=i)&&(i=a),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Fe)}intersectTriangle(t,e,n,i,r){Be.subVectors(e,t),Ue.subVectors(n,t),We.crossVectors(Be,Ue);let s,o=this.direction.dot(We);if(o>0){if(i)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}Le.subVectors(this.origin,t);const a=s*this.direction.dot(Ue.crossVectors(Le,Ue));if(a<0)return null;const c=s*this.direction.dot(Be.cross(Le));if(c<0)return null;if(a+c>o)return null;const h=-s*Le.dot(We);return h<0?null:this.at(h/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class $e extends Re{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Nt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ve=new st,Ye=new qe,He=new ke,Ge=new L,Xe=new L,Ze=new L,Je=new L,Qe=new L,Ke=new L,tn=new L,en=new L;class nn extends jt{constructor(t=new Pe,e=new $e){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){Ke.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=o[n],a=r[n];0!==i&&(Qe.fromBufferAttribute(a,t),s?Ke.addScaledVector(Qe,i):Ke.addScaledVector(Qe.sub(e),i))}e.add(Ke)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),He.copy(n.boundingSphere),He.applyMatrix4(r),Ye.copy(t.ray).recast(t.near),!1===He.containsPoint(Ye.origin)){if(null===Ye.intersectSphere(He,Ge))return;if(Ye.origin.distanceToSquared(Ge)>(t.far-t.near)**2)return}Ve.copy(r).invert(),Ye.copy(t.ray).applyMatrix4(Ve),null!==n.boundingBox&&!1===Ye.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,Ye)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,l=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==o)if(Array.isArray(s))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){i=rn(this,p,t,n,c,h,l,o.getX(r),o.getX(r+1),o.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=rn(this,s,t,n,c,h,l,o.getX(r),o.getX(r+1),o.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==a)if(Array.isArray(s))for(let r=0,o=u.length;r<o;r++){const o=u[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){i=rn(this,p,t,n,c,h,l,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=rn(this,s,t,n,c,h,l,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function rn(t,e,n,i,r,s,o,a,c,h){t.getVertexPosition(a,Xe),t.getVertexPosition(c,Ze),t.getVertexPosition(h,Je);const l=function(t,e,n,i,r,s,o,a){let c;if(c=1===e.side?i.intersectTriangle(o,s,r,!0,a):i.intersectTriangle(r,s,o,0===e.side,a),null===c)return null;en.copy(a),en.applyMatrix4(t.matrixWorld);const h=n.ray.origin.distanceTo(en);return h<n.near||h>n.far?null:{distance:h,point:en.clone(),object:t}}(t,e,n,i,Xe,Ze,Je,tn);if(l){const t=new L;Kt.getBarycoord(tn,Xe,Ze,Je,t),r&&(l.uv=Kt.getInterpolatedAttribute(r,a,c,h,t,new D)),s&&(l.uv1=Kt.getInterpolatedAttribute(s,a,c,h,t,new D)),o&&(l.normal=Kt.getInterpolatedAttribute(o,a,c,h,t,new L),l.normal.dot(i.direction)>0&&l.normal.multiplyScalar(-1));const e={a:a,b:c,c:h,normal:new L,materialIndex:0};Kt.getNormal(Xe,Ze,Je,e.normal),l.face=e,l.barycoord=t}return l}class sn extends it{constructor(t,e,n,i,r,s,o,a,c){super(t,e,n,i,r,s,o,a,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class on extends Pe{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const a=[],c=[],h=[],l=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,y,g){const b=s/m,x=p/y,v=s/2,w=p/2,_=f/2,M=m+1,S=y+1;let k=0,A=0;const z=new L;for(let s=0;s<S;s++){const o=s*x-w;for(let a=0;a<M;a++){const u=a*b-v;z[t]=u*i,z[e]=o*r,z[n]=_,c.push(z.x,z.y,z.z),z[t]=0,z[e]=0,z[n]=f>0?1:-1,h.push(z.x,z.y,z.z),l.push(a/m),l.push(1-s/y),k+=1}}for(let t=0;t<y;t++)for(let e=0;e<m;e++){const n=u+e+M*t,i=u+e+M*(t+1),r=u+(e+1)+M*(t+1),s=u+(e+1)+M*t;a.push(n,i,s),a.push(i,r,s),A+=6}o.addGroup(d,A,g),d+=A,u+=k}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new we(c,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new on(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class an extends Pe{constructor(t=1,e=1,n=1,i=32,r=1,s=!1,o=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a};const c=this;i=Math.floor(i),r=Math.floor(r);const h=[],l=[],u=[],d=[];let p=0;const f=[],m=n/2;let y=0;function g(n){const r=p,s=new D,f=new L;let g=0;const b=!0===n?t:e,x=!0===n?1:-1;for(let t=1;t<=i;t++)l.push(0,m*x,0),u.push(0,x,0),d.push(.5,.5),p++;const v=p;for(let t=0;t<=i;t++){const e=t/i*a+o,n=Math.cos(e),r=Math.sin(e);f.x=b*r,f.y=m*x,f.z=b*n,l.push(f.x,f.y,f.z),u.push(0,x,0),s.x=.5*n+.5,s.y=.5*r*x+.5,d.push(s.x,s.y),p++}for(let t=0;t<i;t++){const e=r+t,i=v+t;!0===n?h.push(i,i+1,e):h.push(i+1,i,e),g+=3}c.addGroup(y,g,!0===n?1:2),y+=g}!function(){const s=new L,g=new L;let b=0;const x=(e-t)/n;for(let c=0;c<=r;c++){const h=[],y=c/r,b=y*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*a+o,c=Math.sin(r),f=Math.cos(r);g.x=b*c,g.y=-y*n+m,g.z=b*f,l.push(g.x,g.y,g.z),s.set(c,x,f).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-y),h.push(p++)}f.push(h)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const s=f[i][n],o=f[i+1][n],a=f[i+1][n+1],c=f[i][n+1];(t>0||0!==i)&&(h.push(s,o,c),b+=3),(e>0||i!==r-1)&&(h.push(o,a,c),b+=3)}c.addGroup(y,b,0),y+=b}(),!1===s&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(h),this.setAttribute("position",new we(l,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new an(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class cn extends Pe{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,o=Math.floor(n),a=Math.floor(i),c=o+1,h=a+1,l=t/o,u=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*u-s;for(let n=0;n<c;n++){const i=n*l-r;p.push(i,-e,0),f.push(0,0,1),m.push(n/o),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<o;e++){const n=e+c*t,i=e+c*(t+1),r=e+1+c*(t+1),s=e+1+c*t;d.push(n,i,s),d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(f,3)),this.setAttribute("uv",new we(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cn(t.width,t.height,t.widthSegments,t.heightSegments)}}class hn extends Pe{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const a=Math.min(s+o,Math.PI);let c=0;const h=[],l=new L,u=new L,d=[],p=[],f=[],m=[];for(let d=0;d<=n;d++){const y=[],g=d/n,b=s+g*o,x=t*Math.cos(b),v=Math.sqrt(t*t-x*x);let w=0;0===d&&0===s?w=.5/e:d===n&&a===Math.PI&&(w=-.5/e);for(let t=0;t<=e;t++){const n=t/e,s=i+n*r;l.x=-v*Math.cos(s),l.y=x,l.z=v*Math.sin(s),p.push(l.x,l.y,l.z),u.copy(l).normalize(),f.push(u.x,u.y,u.z),m.push(n+w,1-g),y.push(c++)}h.push(y)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=h[t][i+1],r=h[t][i],o=h[t+1][i],c=h[t+1][i+1];(0!==t||s>0)&&d.push(e,r,c),(t!==n-1||a<Math.PI)&&d.push(r,o,c)}this.setIndex(d),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(f,3)),this.setAttribute("uv",new we(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class ln extends Re{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Nt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new D(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class un{static{un.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function dn(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?z("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const pn=new mt;function fn(t,e){pn.setFromQuaternion(new N(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=pn.x,t.rotation=-pn.y,t.rotationY=pn.z}const mn="_transferSlotId";const yn=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=yn);const gn=new class{constructor(){this.enabled=!1,this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}enable(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._frameCount=0,this._lastSnapshotTime=0,this.enabled=!0}disable(){this.enabled=!1}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){this.enabled||this.enable();const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,i=this._getResidents?.()??null;let r=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(r=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const s={fps:r,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...i??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,s}};function bn(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const xn=new class{constructor(){this._realTime=0,this._totalTicks=0,this._subs=new Set,this._nextId=1,this._externals=new Set,this._externalNextId=1,this._rafId=null,this._lastWallTime=null,this._emaDt=16.67,this._ticking=!1,this._hasPendingRemoval=!1}get realTime(){return this._realTime}get simTime(){return yn.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const n=e?.component,i=n?.app??n?.root?.app;if(i&&"boolean"==typeof i.isViewMode&&!i.isViewMode)return()=>{};const r={id:this._nextId++,handler:t,description:e?.description??`<anonymous#${this._nextId-1}>`,componentRef:null!=e?.component&&"undefined"!=typeof WeakRef?new WeakRef(e.component):void 0,targetsGetter:e?.getTargets,metadata:e?.metadata,registeredAt:this._realTime,tickCount:0,totalDurationMs:0,lastDt:0,lastDurationMs:0};return this._subs.add(r),this.isRunning||this.start(),()=>{this._ticking?(r._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(r),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,gn.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const n=yn.tick(e),i=yn.now;if(this._ticking=!0,gn.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(n,i)}finally{const i=performance.now()-e;t.tickCount++,t.totalDurationMs+=i,t.lastDt=n,t.lastDurationMs=i}}else for(const t of this._subs)t._removed||t.handler(n,i);if(this._ticking=!1,this._hasPendingRemoval){this._hasPendingRemoval=!1;for(const t of this._subs)t._removed&&this._subs.delete(t);0===this._subs.size&&this.stop()}}start(){if(null!==this._rafId)return;if("undefined"==typeof requestAnimationFrame)return;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),n=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(n),null!==this._rafId&&(this._rafId=requestAnimationFrame(t))};this._rafId=requestAnimationFrame(t)}stop(){null!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._lastWallTime=null}registerExternalAnimation(t,e,n){const i={id:this._externalNextId++,description:t,source:e,metadata:n,registeredAt:this._realTime};return this._externals.add(i),{update:t=>{i.metadata={...i.metadata??{},...t}},unregister:()=>{this._externals.delete(i)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let n;const i=e.componentRef?.deref();let r;if(i&&(n=bn(i)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(bn(t));n.length>0&&(r=n)}}catch{}t.push({id:e.id,description:e.description,componentInfo:n,targetInfos:r,metadata:e.metadata,registeredAt:e.registeredAt,tickCount:e.tickCount,totalDurationMs:Math.round(100*e.totalDurationMs)/100,avgDurationMs:e.tickCount>0?Math.round(e.totalDurationMs/e.tickCount*100)/100:0,lastDt:Math.round(100*e.lastDt)/100,lastDurationMs:Math.round(100*e.lastDurationMs)/100})}const e=[];for(const t of this._externals)e.push({id:t.id,description:t.description,source:t.source,metadata:t.metadata,registeredAt:t.registeredAt,liveDurationMs:Math.round(this._realTime-t.registeredAt)});return{realTime:Math.round(this._realTime),simTime:Math.round(yn.now),isRunning:this.isRunning,speed:yn.speed,paused:yn.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let vn=null;const wn=[],_n=new Set;function Mn(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const Sn={beginContext(t){vn=t},endContext(){vn=null},current:()=>vn,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??Mn(t.component),componentType:t.componentType??(n=t.component,n?.state?.type??n?.type),atSimMs:yn.now,args:t.args,result:t.result,error:t.error};var n;vn?vn.pushTrace(e):(wn.push(e),wn.length>500&&wn.shift(),_n.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...wn],onStandalone:t=>(_n.add(t),()=>{_n.delete(t)}),clearStandalone(){wn.length=0}};function kn(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const n=String(e);return n.length>0?n:void 0}function An(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},n=t.sourceId??kn(t.source),i=t.targetId??kn(t.target),r=t.carrierId??kn(t.carrier);return void 0!==n&&(e.sourceId=n),void 0!==i&&(e.targetId=i),void 0!==r&&(e.carrierId=r),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let zn=1;class Tn{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+zn++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:yn.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??yn.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return In.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=yn.now;const t=this.options?.slotId,e=void 0!==t?{slotId:t}:void 0,n=this.target.canAccept?.(this.carrier,e);if(n&&n.ok)this._slot=n.slot;else{if(n&&!n.ok&&"no-slots-defined"!==n.reason)return this._rejectReason=n.reason,this._rollback();if(n||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier,e))return this._rejectReason="cannot-receive",this._rollback();this._slot=void 0!==t?this.target.slotById?.(t)??null:"function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}return null===this._slot||"function"!=typeof this.target.reserve||"function"!=typeof this.target.commit||(this._reservation=this.target.reserve(this.carrier,{source:this.source,...e}),this._reservation)?(this._timeline.planEndAt=yn.now,null):(this._rejectReason="cannot-reserve",this._rollback())}_physicalFailed(t){return this._reservation&&this.target.release?.(this._reservation),this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._rollback()}_handoffFailed(t){throw this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back",In.append(this._buildReceipt()),t}_commitReserved(){if(this._reservation&&"function"==typeof this.target.commit){try{this.target.commit(this._reservation,this.carrier,this.options)}catch(t){this.target.release?.(this._reservation),this._handoffFailed(t)}return!0}return!1}_finishCommitted(){this._phase="committed",this._timeline.committedAt=yn.now;const t=this._buildReceipt();return In.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=yn.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=yn.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=yn.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=yn.now,null}_runReceiveSync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{const e=t.call(this.target,this.carrier,this.options);e instanceof Promise&&e.catch(()=>{})}catch(t){this._handoffFailed(t)}else Sn.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async _runReceiveAsync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{await t.call(this.target,this.carrier,this.options)}catch(t){this._handoffFailed(t)}else Sn.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){Sn.beginContext(this),Sn.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:kn(this.source),target:kn(this.target),carrier:kn(this.carrier)}});try{return await this._executeImpl()}finally{Sn.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),Sn.endContext()}}executeSync(){Sn.beginContext(this),Sn.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:kn(this.source),target:kn(this.target),carrier:kn(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=yn.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{Sn.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),Sn.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=yn.now,this._commitReserved()||await this._runReceiveAsync(),this._finishCommitted())}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",In.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:kn(this.source),targetId:kn(this.target),carrierId:kn(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason,traceEvents:[...this._traceEvents],meta:Object.keys(this.meta).length>0?{...this.meta}:void 0}}}const In=new class{constructor(){this._flows=new Map,this._targetCount=new Map,this._byPhase=new Map,this._byRejectReason=new Map,this._total=0,this._committedDurationSum=0,this._committedCount=0,this._listeners=new Set}append(t){this._total++,this._byPhase.set(t.phase,(this._byPhase.get(t.phase)??0)+1);const e=t.sourceId??kn(t.source),n=t.targetId??kn(t.target);if("committed"===t.phase){if(e&&n){const t=e+">"+n;this._flows.set(t,(this._flows.get(t)??0)+1)}n&&this._targetCount.set(n,(this._targetCount.get(n)??0)+1),void 0!==t.timeline.committedAt&&(this._committedDurationSum+=t.timeline.committedAt-t.timeline.initiatedAt,this._committedCount++)}else if("rolled-back"===t.phase&&t.rejectReason){this._byRejectReason.set(t.rejectReason,(this._byRejectReason.get(t.rejectReason)??0)+1);try{t.source?._bumpRejected?.(t.carrier,t.rejectReason)}catch{}}this._listeners.forEach(e=>e(t))}flows(){return this._flows}targetCounts(){return this._targetCount}stats(){const t={};this._byPhase.forEach((e,n)=>{t[n]=e});const e=t["rolled-back"]??0;return{total:this._total,byPhase:t,committed:t.committed??0,rolledBack:e,rejectionRate:this._total>0?e/this._total:0,avgTransferDurationMs:this._committedCount>0?this._committedDurationSum/this._committedCount:0}}rejectReasonCounts(){return this._byRejectReason}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}clear(){this._flows.clear(),this._targetCount.clear(),this._byPhase.clear(),this._byRejectReason.clear(),this._total=0,this._committedDurationSum=0,this._committedCount=0}entries(){return[]}forCarrier(t){return[]}forCarrierId(t){return[]}forSourceId(t){return[]}forTargetId(t){return[]}forPhase(t){return[]}inTimeRange(t,e,n){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=In);let On=1;function En(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const jn={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class Pn{constructor(t=jn){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+On++},n=(this._byResource.get(e.resource)??[]).filter(t=>En(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const i=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(i.every(t=>"b-yields"===t.decision)){const i=n.slice();for(const t of i)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:i,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:i}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:i}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>En(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let i=this._byReserver.get(t.reserverId);i||(i=[],this._byReserver.set(t.reserverId,i)),i.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const i=this._byReserver.get(t.reserverId);if(i){const e=i.findIndex(e=>e.id===t.id);e>=0&&i.splice(e,1),0===i.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const Cn=new Pn;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=Cn);class Rn{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const i of this.nodes.values()){const r=Fn(i.position,t);r<n&&(n=r,e=i)}return e}}function Fn(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}function Dn(t,e){return Math.sqrt(Fn(t,e))}function Nn(t,e,n={}){const i=new Rn,r=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,s=`${e.id}:end`;i.addNode({id:n,position:t[0],type:"lane-start"}),i.addNode({id:s,position:t[t.length-1],type:"lane-end"}),i.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:s});let o=0;for(let e=1;e<t.length;e++)o+=Dn(t[e-1],t[e]);const a=o/(e.speedLimit??r)*1e3;i.addEdge({fromNode:n,toNode:s,resource:e.id,distance:o,durationMs:a,forward:!0}),"twoway"===e.direction&&i.addEdge({fromNode:s,toNode:n,resource:e.id,distance:o,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const r=i.laneEndpoints.get(n);if(!r)continue;const s=i.nodes.get(r.startNodeId).position,o=i.nodes.get(r.endNodeId).position;let a=0,c=0,h=0;for(const e of t.lanes){if(e===n)continue;const t=i.laneEndpoints.get(e);if(!t)continue;const r=i.nodes.get(t.startNodeId).position,l=i.nodes.get(t.endNodeId).position;a+=Math.min(Fn(s,r),Fn(s,l)),c+=Math.min(Fn(o,r),Fn(o,l)),h++}if(0===h)continue;const l=a<c?r.startNodeId:r.endNodeId;e.push({laneId:n,nodeId:l,pos:i.nodes.get(l).position})}for(let n=0;n<e.length;n++)for(let r=0;r<e.length;r++){if(n===r)continue;const s=e[n],o=e[r],a=Dn(s.pos,o.pos);i.addEdge({fromNode:s.nodeId,toNode:o.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return i}function Ln(t,e,n,i={}){const r=t.nodes.get(e),s=t.nodes.get(n);if(!r||!s)return null;const o=i.speed?.max??100,a=e=>{const n=t.nodes.get(e);var i,r;return(i=n.position,r=s.position,Math.sqrt(function(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}(i,r)))/o*1e3},c=new Map,h=new Set,l=new Set,u={nodeId:e,gScore:0,fScore:a(e)};c.set(e,u),h.add(e);const d=i.startSimMs??0,p=i.deadlineSimMs;for(;h.size>0;){let e=null,i=null;for(const t of h){const n=c.get(t);(!i||n.fScore<i.fScore||n.fScore===i.fScore&&t<e)&&(i=n,e=t)}if(!i||!e)return null;if(e===n){const t=[];let e=i,n=0;for(;e&&e.cameFromEdge;){const i=e.cameFromEdge,r=d+(e.gScore-i.durationMs);t.unshift({resource:i.resource,timeWindow:{startSimMs:r,endSimMs:r+i.durationMs},fromPos:i.fromPos,toPos:i.toPos}),n+=i.distance,e=c.get(i.fromNodeId)}const r=i.gScore;return void 0!==p&&d+r>p?null:{segments:t,totalDurationMs:r,totalDistance:n}}h.delete(e),l.add(e);for(const n of t.edgesFrom(e)){if(l.has(n.toNode))continue;const e=i.gScore+n.durationMs,r=c.get(n.toNode);if(!r||e<r.gScore){const i=t.nodes.get(n.fromNode),r=t.nodes.get(n.toNode),s={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:i.position,toPos:r.position}};c.set(n.toNode,s),h.add(n.toNode)}}}return null}function Bn(t,e,n=0,i){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:i}))}const Un=.5;function Wn(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function qn(t,e,n){const i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(i*i+r*r);if(0===s||!Number.isFinite(n)||Math.abs(n)<1e-9)return null;const o=Math.abs(n),a=(s*s+4*o*o)/(8*o),c=n>0?1:-1,h=a-o,l=(t.x+e.x)/2-c*(r/s)*h,u=(t.y+e.y)/2-c*-(i/s)*h;return{cx:l,cy:u,radius:a,startAngle:Math.atan2(t.y-u,t.x-l),endAngle:Math.atan2(e.y-u,e.x-l),clockwise:n<0}}function $n(t,e,n=0,i=16){const r=e.x-t.x,s=e.y-t.y,o=Math.sqrt(r*r+s*s);if(0===o)return null;const a=s/o,c=-(r/o),h=Number.isFinite(n)?n:0,l=Math.abs(h)>=1e-6?h:i;return{x:(t.x+e.x)/2+a*l,y:(t.y+e.y)/2+c*l,perpX:a,perpY:c}}function Vn(t,e,n){const i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(i*i+r*r);if(0===s)return 0;const o=r/s,a=-(i/s),c=(t.x+e.x)/2,h=(t.y+e.y)/2;let l=(n.x-c)*o+(n.y-h)*a;if(Math.abs(l)<.5)return 0;return l>s&&(l=s),l<-s&&(l=-s),l}function Yn(t,e){const n=t.radius,i=Number.isFinite(e)?e:0;return null!=n&&Number.isFinite(n)?Math.max(0,n):Math.max(0,i)}function Hn(t,e,n,i,r=16){const s=t.x-e.x,o=t.y-e.y,a=Math.sqrt(s*s+o*o);if(0===a)return null;const c=n.x-e.x,h=n.y-e.y,l=Math.sqrt(c*c+h*h);if(0===l)return null;const u=s/a+c/l,d=o/a+h/l,p=Math.sqrt(u*u+d*d);if(p<1e-9)return null;const f=u/p,m=d/p,y=Math.max(i,r);return{x:e.x+f*y,y:e.y+m*y,bisectorX:f,bisectorY:m}}function Gn(t,e,n,i){const r=t.x-e.x,s=t.y-e.y,o=Math.sqrt(r*r+s*s),a=n.x-e.x,c=n.y-e.y,h=Math.sqrt(a*a+c*c);if(0===o||0===h)return 0;const l=r/o+a/h,u=s/o+c/h,d=Math.sqrt(l*l+u*u);if(d<1e-9)return 0;const p=l/d,f=u/d,m=(i.x-e.x)*p+(i.y-e.y)*f,y=Math.min(o,h)/2;return Math.max(0,Math.min(m,y))}function Xn(t){if(0===t.length)return 0;let e;for(const n of t){const t=n.z??0;if(!Number.isFinite(t))return null;if(void 0===e)e=t;else if(Math.abs(t-e)>1e-9)return null}return e??0}const Zn={closed:!0,round:0,divisions:24};class Jn{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const i=t[e].x-t[e-1].x,r=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(i*i+r*r))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const i=this.cumulative;let r=0,s=i.length-2;for(;r<s;){const t=r+s>>1;i[t+1]<=n?r=t+1:s=t}const o=i[r+1]-i[r],a=o>0?(n-i[r])/o:0,c=this.points[r],h=this.points[r+1],l=h.x-c.x,u=h.y-c.y;return{x:c.x+l*a,y:c.y+u*a,theta:0===l&&0===u?0:Math.atan2(u,l)}}}function Qn(t,e={}){const n={...Zn,...e},i=t.length;if(0===i)return new Jn([],n.closed);if(1===i)return new Jn([{x:t[0].x,y:t[0].y}],n.closed);const r=[],s=(t,e)=>{if(r.length>0){const n=r[r.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}r.push({x:t,y:e})},o=(n.closed,i);for(let e=0;e<o;e++){const r=0===e?n.closed?i-1:-1:e-1,o=e===i-1?n.closed?0:-1:e+1,a=r>=0?t[r]:null,c=t[e],h=o>=0?t[o]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const l=a&&h?Yn(c,n.round):0;let u,d,p,f;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(l,t/2);u=Math.sin(e)*n+c.x,d=Math.cos(e)*n+c.y}else u=c.x,d=c.y;if(h){const t=Math.sqrt((h.x-c.x)**2+(h.y-c.y)**2),e=0!==t?Math.atan2(h.x-c.x,h.y-c.y):0,n=Math.min(l,t/2);p=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else p=c.x,f=c.y;if(s(u,d),l>0&&a&&h)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,i=1-e;s(i*i*u+2*i*e*c.x+e*e*p,i*i*d+2*i*e*c.y+e*e*f)}else u===p&&d===f||s(p,f);if(h&&Wn(c)){const t=Yn(h,n.round),e=Math.sqrt((c.x-h.x)**2+(c.y-h.y)**2),i=0!==e?Math.atan2(c.x-h.x,c.y-h.y):0,r=Math.min(t,e/2),o=qn({x:p,y:f},{x:Math.sin(i)*r+h.x,y:Math.cos(i)*r+h.y},c.bulge);if(o){let t=o.endAngle-o.startAngle;if(o.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const i=e/n.divisions,r=o.startAngle+t*i;s(o.cx+o.radius*Math.cos(r),o.cy+o.radius*Math.sin(r))}}}}if(n.closed&&r.length>0){const t=r[0],e=r[r.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&r.push({x:t.x,y:t.y})}return new Jn(r,n.closed)}function Kn(t,e){return Qn(t,e).length}function ti(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function ei(t){if(ti(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class ni{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function ii(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),i=e.onAvailable(()=>t.resumeEmit());return ei(e).isFull&&t.pauseEmit(),()=>{n?.(),i?.()}}class ri{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,i){const r=e.maxCount??1/0;if(t<0||t>=r)return null;const s=this.owner?.state?.width??0,o=this.owner?.state?.height??0,a=i?.state?.width??0,c=i?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(o-c)/2),z:0}:{x:Math.max(0,(s-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function si(t,e,n,i,r,s,o){const a=n.w,c=n.h,h=i.w,l=i.h,u=i.d,d=[],p=h+r,f=l+r,m=Math.max(1,Math.floor((a+r)/p)),y=Math.max(1,Math.floor((c+r)/f)),g=m*y,b=s&&s>0?Math.floor(s):4;if("row"===t||"column"===t){const n=o?.advanceAlongX??!1,i=o?.reverse??!1,r=n?m:y,s=n?y:m,h=(t,e,i)=>((t,e,n)=>d.push({x:-a/2+(t+.5)*p,y:n*u+u/2,z:-c/2+(e+.5)*f}))(n?t:e,n?e:t,i);let l=0;for(let n=0;n<r&&l<e;n++){const o=i?r-1-n:n;if("column"===t)for(let t=0;t<s&&l<e;t++)for(let n=0;n<b&&l<e;n++)h(o,t,n),l++;else for(let t=0;t<b&&l<e;t++)for(let n=0;n<s&&l<e;n++)h(o,n,t),l++}return d}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,m-n),i=Math.max(1,y-n),r=e*i,o=Math.min(t,r);for(let t=0;t<o;t++){const r=t%e,s=Math.floor(t/e),o=-a/2+(r+(m-e)/2+.5)*p,h=-c/2+(s+(y-i)/2+.5)*f;d.push({x:o,y:n*u+u/2,z:h})}if(t-=o,n++,1===e&&1===i){for(let e=0;e<t;e++)d.push({x:0,y:(n+e)*u+u/2,z:0});break}if(s&&n>=s)break}return d}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/g),i=n%g,r=i%m,o=Math.floor(i/m),y=(t(2*n)-.5)*h*.2,b=(t(2*n+1)-.5)*l*.2,x=-a/2+(r+.5)*p+y,v=-c/2+(o+.5)*f+b;if(d.push({x:x,y:e*u+u/2,z:v}),s&&e>=s-1&&i===g-1)break}return d}for(let n=0;n<e;n++){const e=Math.floor(n/g);if(s&&e>=s)break;const i=n%g,r=i%m,o=Math.floor(i/m);let h=-a/2+(r+.5)*p;const l=-c/2+(o+.5)*f;"staggered"===t&&e%2==1&&(h+=p/2),d.push({x:h,y:e*u+u/2,z:l})}return d}class oi{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,i={}){const r=i.gap??this.defaults.gap??0,s=i.heightLimit??this.defaults.heightLimit,o=i.fill??this.defaults.fill;return si(this.pattern,t,e,n,r,s,o).map(t=>({position:t}))}}class ai{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,i={}){const r=Math.max(1,this.cols),s=Math.max(1,this.rows),o=r*s,a=i.gap??this.defaults.gap??0,c=n.w+a,h=n.h+a,l=[];for(let e=0;e<t;e++){const t=Math.floor(e/o),i=e%o,a=i%r,u=Math.floor(i/r);l.push({position:{x:(a-(r-1)/2)*c,z:(u-(s-1)/2)*h,y:t*n.d+n.d/2}})}return l}}class ci{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,i=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-i)/(e.h+i))),pitchX:e.w+n,pitchZ:e.h+i}}capacity(t,e,n){const{cols:i,rows:r}=this.grid(t,e);return i*r*Math.max(1,Math.floor(n))}layout(t,e,n,i={}){const{cols:r,rows:s,pitchX:o,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,h=null!=i.heightLimit?Math.max(1,Math.floor(i.heightLimit)):1/0,l=Number.isFinite(h),u=this.sliceFirst&&l,d=r*s,p=r*(l?h:1),f=r*s*(l?h:t),m=Math.min(t,f),y=[];for(let t=0;t<m;t++){let e,i,h;if(u){const n=Math.floor(t/p),s=t%p;e=s%r,h=Math.floor(s/r),i=n}else{h=Math.floor(t/d);const n=t%d;e=n%r,i=Math.floor(n/r)}this.fillFromFar&&(i=s-1-i),y.push({position:{x:(e-(r-1)/2)*o,z:(i-(s-1)/2)*a,y:h*c+n.d/2}})}return y}}function hi(t,e,n,i=0){for(let r=0;r<e.length;r++){const s=e[r],o=n[r];s&&o&&(s.parent!==t&&t.attach(s),s.position.set(o.position.x,i+o.position.y,o.position.z),o.rotation?s.quaternion.set(o.rotation.x,o.rotation.y,o.rotation.z,o.rotation.w):s.quaternion.identity())}}function li(t,e,n,i=.12){const r=e.left+e.width/2,s=e.top+e.height/2,o=Math.min(n.w,n.h)*i,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let i=a.get(t);i||(i={x:r+e.position.x-n.w/2+o,y:s+e.position.z-n.h/2+o,w:n.w-2*o,h:n.h-2*o,count:0},a.set(t,i)),i.count++}return[...a.values()]}function ui(t,e){return t===e||t!=t&&e!=e}function di(t,e){for(var n=t.length;n--;)if(ui(t[n][0],e))return n;return-1}var pi=Array.prototype.splice;function fi(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}fi.prototype.clear=function(){this.__data__=[],this.size=0},fi.prototype.delete=function(t){var e=this.__data__,n=di(e,t);return!(n<0)&&(n==e.length-1?e.pop():pi.call(e,n,1),--this.size,!0)},fi.prototype.get=function(t){var e=this.__data__,n=di(e,t);return n<0?void 0:e[n][1]},fi.prototype.has=function(t){return di(this.__data__,t)>-1},fi.prototype.set=function(t,e){var n=this.__data__,i=di(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var mi="object"==typeof global&&global&&global.Object===Object&&global,yi="object"==typeof self&&self&&self.Object===Object&&self,gi=mi||yi||Function("return this")(),bi=gi.Symbol,xi=Object.prototype,vi=xi.hasOwnProperty,wi=xi.toString,_i=bi?bi.toStringTag:void 0;var Mi=Object.prototype.toString;var Si=bi?bi.toStringTag:void 0;function ki(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Si&&Si in Object(t)?function(t){var e=vi.call(t,_i),n=t[_i];try{t[_i]=void 0;var i=!0}catch(t){}var r=wi.call(t);return i&&(e?t[_i]=n:delete t[_i]),r}(t):function(t){return Mi.call(t)}(t)}function Ai(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function zi(t){if(!Ai(t))return!1;var e=ki(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var Ti,Ii=gi["__core-js_shared__"],Oi=(Ti=/[^.]+$/.exec(Ii&&Ii.keys&&Ii.keys.IE_PROTO||""))?"Symbol(src)_1."+Ti:"";var Ei=Function.prototype.toString;function ji(t){if(null!=t){try{return Ei.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Pi=/^\[object .+?Constructor\]$/,Ci=Function.prototype,Ri=Object.prototype,Fi=Ci.toString,Di=Ri.hasOwnProperty,Ni=RegExp("^"+Fi.call(Di).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Li(t){return!(!Ai(t)||(e=t,Oi&&Oi in e))&&(zi(t)?Ni:Pi).test(ji(t));var e}function Bi(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Li(n)?n:void 0}var Ui=Bi(gi,"Map"),Wi=Bi(Object,"create");var qi=Object.prototype.hasOwnProperty;var $i=Object.prototype.hasOwnProperty;function Vi(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Yi(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function Hi(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Vi.prototype.clear=function(){this.__data__=Wi?Wi(null):{},this.size=0},Vi.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vi.prototype.get=function(t){var e=this.__data__;if(Wi){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return qi.call(e,t)?e[t]:void 0},Vi.prototype.has=function(t){var e=this.__data__;return Wi?void 0!==e[t]:$i.call(e,t)},Vi.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Wi&&void 0===e?"__lodash_hash_undefined__":e,this},Hi.prototype.clear=function(){this.size=0,this.__data__={hash:new Vi,map:new(Ui||fi),string:new Vi}},Hi.prototype.delete=function(t){var e=Yi(this,t).delete(t);return this.size-=e?1:0,e},Hi.prototype.get=function(t){return Yi(this,t).get(t)},Hi.prototype.has=function(t){return Yi(this,t).has(t)},Hi.prototype.set=function(t,e){var n=Yi(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};function Gi(t){var e=this.__data__=new fi(t);this.size=e.size}Gi.prototype.clear=function(){this.__data__=new fi,this.size=0},Gi.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Gi.prototype.get=function(t){return this.__data__.get(t)},Gi.prototype.has=function(t){return this.__data__.has(t)},Gi.prototype.set=function(t,e){var n=this.__data__;if(n instanceof fi){var i=n.__data__;if(!Ui||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Hi(i)}return n.set(t,e),this.size=n.size,this};function Xi(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Hi;++e<n;)this.add(t[e])}function Zi(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}Xi.prototype.add=Xi.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Xi.prototype.has=function(t){return this.__data__.has(t)};function Ji(t,e,n,i,r,s){var o=1&n,a=t.length,c=e.length;if(a!=c&&!(o&&c>a))return!1;var h=s.get(t),l=s.get(e);if(h&&l)return h==e&&l==t;var u=-1,d=!0,p=2&n?new Xi:void 0;for(s.set(t,e),s.set(e,t);++u<a;){var f=t[u],m=e[u];if(i)var y=o?i(m,f,u,e,t,s):i(f,m,u,t,e,s);if(void 0!==y){if(y)continue;d=!1;break}if(p){if(!Zi(e,function(t,e){if(o=e,!p.has(o)&&(f===t||r(f,t,n,i,s)))return p.push(e);var o})){d=!1;break}}else if(f!==m&&!r(f,m,n,i,s)){d=!1;break}}return s.delete(t),s.delete(e),d}var Qi=gi.Uint8Array;function Ki(t){var e=-1,n=Array(t.size);return t.forEach(function(t,i){n[++e]=[i,t]}),n}function tr(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var er=bi?bi.prototype:void 0,nr=er?er.valueOf:void 0;function ir(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var rr=Array.isArray;function sr(){return[]}var or=Object.prototype.propertyIsEnumerable,ar=Object.getOwnPropertySymbols,cr=ar?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,i=null==t?0:t.length,r=0,s=[];++n<i;){var o=t[n];e(o,n,t)&&(s[r++]=o)}return s}(ar(t),function(e){return or.call(t,e)}))}:sr;function hr(t){return null!=t&&"object"==typeof t}function lr(t){return hr(t)&&"[object Arguments]"==ki(t)}var ur=Object.prototype,dr=ur.hasOwnProperty,pr=ur.propertyIsEnumerable,fr=lr(function(){return arguments}())?lr:function(t){return hr(t)&&dr.call(t,"callee")&&!pr.call(t,"callee")};var mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,yr=mr&&"object"==typeof module&&module&&!module.nodeType&&module,gr=yr&&yr.exports===mr?gi.Buffer:void 0,br=(gr?gr.isBuffer:void 0)||function(){return!1},xr=/^(?:0|[1-9]\d*)$/;function vr(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&xr.test(t))&&t>-1&&t%1==0&&t<e}function wr(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var _r={};function Mr(t){return function(e){return t(e)}}_r["[object Float32Array]"]=_r["[object Float64Array]"]=_r["[object Int8Array]"]=_r["[object Int16Array]"]=_r["[object Int32Array]"]=_r["[object Uint8Array]"]=_r["[object Uint8ClampedArray]"]=_r["[object Uint16Array]"]=_r["[object Uint32Array]"]=!0,_r["[object Arguments]"]=_r["[object Array]"]=_r["[object ArrayBuffer]"]=_r["[object Boolean]"]=_r["[object DataView]"]=_r["[object Date]"]=_r["[object Error]"]=_r["[object Function]"]=_r["[object Map]"]=_r["[object Number]"]=_r["[object Object]"]=_r["[object RegExp]"]=_r["[object Set]"]=_r["[object String]"]=_r["[object WeakMap]"]=!1;var Sr="object"==typeof exports&&exports&&!exports.nodeType&&exports,kr=Sr&&"object"==typeof module&&module&&!module.nodeType&&module,Ar=kr&&kr.exports===Sr&&mi.process,zr=function(){try{var t=kr&&kr.require&&kr.require("util").types;return t||Ar&&Ar.binding&&Ar.binding("util")}catch(t){}}(),Tr=zr&&zr.isTypedArray,Ir=Tr?Mr(Tr):function(t){return hr(t)&&wr(t.length)&&!!_r[ki(t)]},Or=Object.prototype.hasOwnProperty;function Er(t,e){var n=rr(t),i=!n&&fr(t),r=!n&&!i&&br(t),s=!n&&!i&&!r&&Ir(t),o=n||i||r||s,a=o?function(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!Or.call(t,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||vr(h,c))||a.push(h);return a}var jr=Object.prototype;function Pr(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||jr)}function Cr(t,e){return function(n){return t(e(n))}}var Rr=Cr(Object.keys,Object),Fr=Object.prototype.hasOwnProperty;function Dr(t){if(!Pr(t))return Rr(t);var e=[];for(var n in Object(t))Fr.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Nr(t){return null!=t&&wr(t.length)&&!zi(t)}function Lr(t){return Nr(t)?Er(t):Dr(t)}function Br(t){return function(t,e,n){var i=e(t);return rr(t)?i:ir(i,n(t))}(t,Lr,cr)}var Ur=Object.prototype.hasOwnProperty;var Wr=Bi(gi,"DataView"),qr=Bi(gi,"Promise"),$r=Bi(gi,"Set"),Vr=Bi(gi,"WeakMap"),Yr="[object Map]",Hr="[object Promise]",Gr="[object Set]",Xr="[object WeakMap]",Zr="[object DataView]",Jr=ji(Wr),Qr=ji(Ui),Kr=ji(qr),ts=ji($r),es=ji(Vr),ns=ki;(Wr&&ns(new Wr(new ArrayBuffer(1)))!=Zr||Ui&&ns(new Ui)!=Yr||qr&&ns(qr.resolve())!=Hr||$r&&ns(new $r)!=Gr||Vr&&ns(new Vr)!=Xr)&&(ns=function(t){var e=ki(t),n="[object Object]"==e?t.constructor:void 0,i=n?ji(n):"";if(i)switch(i){case Jr:return Zr;case Qr:return Yr;case Kr:return Hr;case ts:return Gr;case es:return Xr}return e});var is="[object Arguments]",rs="[object Array]",ss="[object Object]",os=Object.prototype.hasOwnProperty;function as(t,e,n,i,r,s){var o=rr(t),a=rr(e),c=o?rs:ns(t),h=a?rs:ns(e),l=(c=c==is?ss:c)==ss,u=(h=h==is?ss:h)==ss,d=c==h;if(d&&br(t)){if(!br(e))return!1;o=!0,l=!1}if(d&&!l)return s||(s=new Gi),o||Ir(t)?Ji(t,e,n,i,r,s):function(t,e,n,i,r,s,o){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new Qi(t),new Qi(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ui(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ki;case"[object Set]":var c=1&i;if(a||(a=tr),t.size!=e.size&&!c)return!1;var h=o.get(t);if(h)return h==e;i|=2,o.set(t,e);var l=Ji(a(t),a(e),i,r,s,o);return o.delete(t),l;case"[object Symbol]":if(nr)return nr.call(t)==nr.call(e)}return!1}(t,e,c,n,i,r,s);if(!(1&n)){var p=l&&os.call(t,"__wrapped__"),f=u&&os.call(e,"__wrapped__");if(p||f){var m=p?t.value():t,y=f?e.value():e;return s||(s=new Gi),r(m,y,n,i,s)}}return!!d&&(s||(s=new Gi),function(t,e,n,i,r,s){var o=1&n,a=Br(t),c=a.length;if(c!=Br(e).length&&!o)return!1;for(var h=c;h--;){var l=a[h];if(!(o?l in e:Ur.call(e,l)))return!1}var u=s.get(t),d=s.get(e);if(u&&d)return u==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++h<c;){var m=t[l=a[h]],y=e[l];if(i)var g=o?i(y,m,l,e,t,s):i(m,y,l,t,e,s);if(!(void 0===g?m===y||r(m,y,n,i,s):g)){p=!1;break}f||(f="constructor"==l)}if(p&&!f){var b=t.constructor,x=e.constructor;b==x||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof x&&x instanceof x||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,i,r,s))}function cs(t,e,n,i,r){return t===e||(null==t||null==e||!hr(t)&&!hr(e)?t!=t&&e!=e:as(t,e,n,i,cs,r))}function hs(t,e){for(var n=-1,i=null==t?0:t.length;++n<i&&!1!==e(t[n],n,t););return t}var ls=function(){try{var t=Bi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function us(t,e,n){"__proto__"==e&&ls?ls(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var ds=Object.prototype.hasOwnProperty;function ps(t,e,n){var i=t[e];ds.call(t,e)&&ui(i,n)&&(void 0!==n||e in t)||us(t,e,n)}function fs(t,e,n,i){var r=!n;n||(n={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=i?i(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),r?us(n,a,c):ps(n,a,c)}return n}function ms(t){return t}function ys(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var gs=Math.max;function bs(t){return function(){return t}}var xs=ls?function(t,e){return ls(t,"toString",{configurable:!0,enumerable:!1,value:bs(e),writable:!0})}:ms,vs=Date.now;var ws,_s,Ms,Ss=(ws=xs,_s=0,Ms=0,function(){var t=vs(),e=16-(t-Ms);if(Ms=t,e>0){if(++_s>=800)return arguments[0]}else _s=0;return ws.apply(void 0,arguments)});function ks(t,e){return Ss(function(t,e,n){return e=gs(void 0===e?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=gs(i.length-e,0),o=Array(s);++r<s;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=n(o),ys(t,this,a)}}(t,e,ms),t+"")}function As(t,e,n){if(!Ai(n))return!1;var i=typeof e;return!!("number"==i?Nr(n)&&vr(e,n.length):"string"==i&&e in n)&&ui(n[e],t)}var zs,Ts=(zs=function(t,e,n,i){fs(e,Lr(e),t,i)},ks(function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(r=zs.length>3&&"function"==typeof r?(i--,r):void 0,s&&As(e[0],e[1],s)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var o=e[n];o&&zs(t,o,n,r)}return t})),Is=Cr(Object.getPrototypeOf,Object),Os=Function.prototype,Es=Object.prototype,js=Os.toString,Ps=Es.hasOwnProperty,Cs=js.call(Object);function Rs(t){if(!hr(t))return!1;var e=ki(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!hr(t)||"[object Object]"!=ki(t))return!1;var e=Is(t);if(null===e)return!0;var n=Ps.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&js.call(n)==Cs}(t)}var Fs=ks(function(t,e){try{return ys(t,void 0,e)}catch(t){return Rs(t)?t:new Error(t)}});function Ds(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r}var Ns=Object.prototype,Ls=Ns.hasOwnProperty;function Bs(t,e,n,i){return void 0===t||ui(t,Ns[n])&&!Ls.call(i,n)?e:t}var Us={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function Ws(t){return"\\"+Us[t]}var qs=/<%=([\s\S]+?)%>/g;var $s,Vs=($s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},function(t){return null==$s?void 0:$s[t]});function Ys(t){return"symbol"==typeof t||hr(t)&&"[object Symbol]"==ki(t)}var Hs=bi?bi.prototype:void 0,Gs=Hs?Hs.toString:void 0;function Xs(t){if("string"==typeof t)return t;if(rr(t))return Ds(t,Xs)+"";if(Ys(t))return Gs?Gs.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Zs(t){return null==t?"":Xs(t)}var Js=/[&<>"']/g,Qs=RegExp(Js.source);var Ks={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:qs,variable:"",imports:{_:{escape:function(t){return(t=Zs(t))&&Qs.test(t)?t.replace(Js,Vs):t}}}},to=/\b__p \+= '';/g,eo=/\b(__p \+=) '' \+/g,no=/(__e\(.*?\)|\b__t\)) \+\n'';/g,io=/[()=,{}\[\]\/\s]/,ro=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,so=/($^)/,oo=/['\n\r\u2028\u2029\\]/g,ao=Object.prototype.hasOwnProperty;var co=Object.prototype.hasOwnProperty;function ho(t){if(!Ai(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=Pr(t),n=[];for(var i in t)("constructor"!=i||!e&&co.call(t,i))&&n.push(i);return n}function lo(t,e){return t&&fs(e,function(t){return Nr(t)?Er(t,!0):ho(t)}(e),t)}var uo="object"==typeof exports&&exports&&!exports.nodeType&&exports,po=uo&&"object"==typeof module&&module&&!module.nodeType&&module,fo=po&&po.exports===uo?gi.Buffer:void 0,mo=fo?fo.allocUnsafe:void 0;var yo=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ir(e,cr(t)),t=Is(t);return e}:sr;var go=Object.prototype.hasOwnProperty;var bo=/\w*$/;var xo=bi?bi.prototype:void 0,vo=xo?xo.valueOf:void 0;function wo(t,e,n){var i,r,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new Qi(a).set(new Qi(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(r=t).buffer,new r.constructor(s,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,bo.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return i=t,vo?Object(vo.call(i)):{}}}var _o=Object.create,Mo=function(){function t(){}return function(e){if(!Ai(e))return{};if(_o)return _o(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var So=zr&&zr.isMap,ko=So?Mr(So):function(t){return hr(t)&&"[object Map]"==ns(t)};var Ao=zr&&zr.isSet,zo=Ao?Mr(Ao):function(t){return hr(t)&&"[object Set]"==ns(t)},To="[object Arguments]",Io="[object Function]",Oo="[object Object]",Eo={};function jo(t,e,n,i,r,s){var o,a=2&e;if(void 0!==o)return o;if(!Ai(t))return t;var c=rr(t);if(c)return o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&go.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}(t,o);var h=ns(t),l=h==Io||"[object GeneratorFunction]"==h;if(br(t))return function(t){var e=t.length,n=mo?mo(e):new t.constructor(e);return t.copy(n),n}(t);if(h==Oo||h==To||l&&!r)return o=l?{}:function(t){return"function"!=typeof t.constructor||Pr(t)?{}:Mo(Is(t))}(t),a?function(t,e){return fs(t,yo(t),e)}(t,lo(o,t)):function(t,e){return fs(t,cr(t),e)}(t,function(t,e){return t&&fs(e,Lr(e),t)}(o,t));if(!Eo[h])return r?t:{};o=wo(t,h),s||(s=new Gi);var u=s.get(t);if(u)return u;s.set(t,o),zo(t)?t.forEach(function(i){o.add(jo(i,e,n,i,t,s))}):ko(t)&&t.forEach(function(i,r){o.set(r,jo(i,e,n,r,t,s))});var d=c?void 0:Br(t);return hs(d||t,function(i,r){d&&(i=t[r=i]),ps(o,r,jo(i,e,n,r,t,s))}),o}Eo[To]=Eo["[object Array]"]=Eo["[object ArrayBuffer]"]=Eo["[object DataView]"]=Eo["[object Boolean]"]=Eo["[object Date]"]=Eo["[object Float32Array]"]=Eo["[object Float64Array]"]=Eo["[object Int8Array]"]=Eo["[object Int16Array]"]=Eo["[object Int32Array]"]=Eo["[object Map]"]=Eo["[object Number]"]=Eo[Oo]=Eo["[object RegExp]"]=Eo["[object Set]"]=Eo["[object String]"]=Eo["[object Symbol]"]=Eo["[object Uint8Array]"]=Eo["[object Uint8ClampedArray]"]=Eo["[object Uint16Array]"]=Eo["[object Uint32Array]"]=!0,Eo["[object Error]"]=Eo[Io]=Eo["[object WeakMap]"]=!1;function Po(t){return jo(t,4)}var Co=/\s/;var Ro=/^\s+/;function Fo(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&Co.test(t.charAt(e)););return e}(t)+1).replace(Ro,""):t}var Do=/^[-+]0x[0-9a-f]+$/i,No=/^0b[01]+$/i,Lo=/^0o[0-7]+$/i,Bo=parseInt;var Uo=1/0;function Wo(t){return t?(t=function(t){if("number"==typeof t)return t;if(Ys(t))return NaN;if(Ai(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ai(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Fo(t);var n=No.test(t);return n||Lo.test(t)?Bo(t.slice(2),n?2:8):Do.test(t)?NaN:+t}(t))===Uo||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function qo(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=Wo(t),n=e%1;return e==e?n?e-n:e:0}(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}var $o=Object.prototype.hasOwnProperty;function Vo(t){if(null==t)return!0;if(Nr(t)&&(rr(t)||"string"==typeof t||"function"==typeof t.splice||br(t)||Ir(t)||fr(t)))return!t.length;var e=ns(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Pr(t))return!Dr(t).length;for(var n in t)if($o.call(t,n))return!1;return!0}let Yo=0;function Ho(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function Go(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function Xo(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Zo(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function Jo(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Qo(t){if(this.__collection__)return this.__collection__[t]}function Ko(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function ta(t){return this.__collection__?this.__collection__.indexOf(t):-1}function ea(){return this.__collection__?this.__collection__.length:0}function na(){this.__collection__=[]}function ia(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function ra(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function sa(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,i)}function oa(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=n.concat(i,this.__collection__)}class aa{constructor(){this.__collection__=[],this.insertAt=Go,this.append=Xo,this.prepend=Zo,this.remove=Jo,this.getAt=Qo,this.forEach=Ko,this.indexOf=ta,this.size=ea,this.clear=na,this.moveForward=ia,this.moveBackward=ra,this.moveToHead=sa,this.moveToTail=oa}}const ca=/\s+/;function ha(t,e,n,i){if(!n)return!0;if("object"==typeof n){for(const i in n){const r=n[i];t[e].apply(t,[i,r])}return!1}if(ca.test(n)){return n.split(ca).forEach(n=>t[e].apply(t,[n].concat(i))),!1}return!0}const la=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],ua={withEvent(){la.forEach(t=>this[t]=ua[t])},on(t,e,n){if(!ha(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!ha(this,"once",t,[e,n])||!e)return this;const i=this,r=function(t){return qo(2,t)}(function(){i.off(t,r,n),e.apply(i,arguments)});return r._callback=e,this.on(t,r,n),this},off(t,e,n){if(!this._listeners||!ha(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let i;i=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<i.length;t++){const r=i[t],s=this._listeners?.[r];if(s){const t=[];if(this._listeners[r]=t,e||n)for(let i=0;i<s.length;i++){const r=s[i];(e&&e!==r.callback&&e!==r.callback._callback||n&&n!==r.context)&&t.push(r)}t.length||delete this._listeners[r]}}return this},delegate_on(t){return this._delegators||(this._delegators=new aa),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&pa(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],i=this._listeners["(all)"];return n&&da(n,arguments),i&&da(i,arguments),this},trigger(t){gn.enabled&&gn.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&pa(this._delegators,e),!this._listeners)return this;if(!ha(this,"trigger",t,e))return this;const n=this._listeners[t],i=this._listeners["(all)"];return n&&da(n,e),i&&da(i,e),this},stopListening(t,e,n){let i=this._listeningTo;if(!i)return this;const r=!e&&!n;n||"object"!=typeof e||(n=this),t&&(i={},i[t._listenId]=t);for(const t in i){const s=i[t];s.off(e,n,this),(r||Vo(s._events))&&delete this._listeningTo[t]}return this}};function da(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function pa(t,e){t.forEach(t=>ua.delegate.apply(t,e))}const fa={listenTo:"on",listenToOnce:"once"};for(const t in fa){const e=fa[t];ua[t]=function(t,n,i){this._listeningTo||(this._listeningTo={});const r=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++Yo}`);return r[t._listenId]=t,i||"object"!=typeof n||(i=this),t[e](n,i,this),this}}const ma=ua.on,ya=ua.off,ga=ua.once,ba=ua.trigger,xa=ua.delegate_on,va=ua.delegate_off;const wa=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))},_a=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))};function Ma(t,e,n){const i=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!i?.get)return void wa(`${String(e)} is not defined in ${t.constructor.name}`);const r=i.get,s={get:n?function(){return e in this.__cache__?gn.enabled&&gn.cacheHit++:(gn.enabled&&gn.cacheMiss++,this.__cache__[e]=Object.freeze(r.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?gn.enabled&&gn.cacheHit++:(gn.enabled&&gn.cacheMiss++,this.__cache__[e]=r.call(this)),this.__cache__[e]},configurable:!0};i.set&&(s.set=i.set),Object.defineProperty(t,e,s)}var Sa="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ka(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Aa(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var za,Ta={exports:{}};var Ia=(za||(za=1,function(t){var e=function(t){var e,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function h(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,n){return t[e]=n}}function l(t,e,n,i){var s=e&&e.prototype instanceof g?e:g,o=Object.create(s.prototype),a=new O(i||[]);return r(o,"_invoke",{value:A(t,n,a)}),o}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",y={};function g(){}function b(){}function x(){}var v={};h(v,o,function(){return this});var w=Object.getPrototypeOf,_=w&&w(w(E([])));_&&_!==n&&i.call(_,o)&&(v=_);var M=x.prototype=g.prototype=Object.create(v);function S(t){["next","throw","return"].forEach(function(e){h(t,e,function(t){return this._invoke(e,t)})})}function k(t,e){function n(r,s,o,a){var c=u(t[r],t,s);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==typeof l&&i.call(l,"__await")?e.resolve(l.__await).then(function(t){n("next",t,o,a)},function(t){n("throw",t,o,a)}):e.resolve(l).then(function(t){h.value=t,o(h)},function(t){return n("throw",t,o,a)})}a(c.arg)}var s;r(this,"_invoke",{value:function(t,i){function r(){return new e(function(e,r){n(t,i,e,r)})}return s=s?s.then(r,r):r()}})}function A(t,n,i){var r=d;return function(s,o){if(r===f)throw new Error("Generator is already running");if(r===m){if("throw"===s)throw o;return{value:e,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=z(a,i);if(c){if(c===y)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===d)throw r=m,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=f;var h=u(t,n,i);if("normal"===h.type){if(r=i.done?m:p,h.arg===y)continue;return{value:h.arg,done:i.done}}"throw"===h.type&&(r=m,i.method="throw",i.arg=h.arg)}}}function z(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,z(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),y;var s=u(r,t.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,y;var o=s.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function E(t){if(null!=t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,s=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=x,r(M,"constructor",{value:x,configurable:!0}),r(x,"constructor",{value:b,configurable:!0}),b.displayName=h(x,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,h(t,c,"GeneratorFunction")),t.prototype=Object.create(M),t},t.awrap=function(t){return{__await:t}},S(k.prototype),h(k.prototype,a,function(){return this}),t.AsyncIterator=k,t.async=function(e,n,i,r,s){void 0===s&&(s=Promise);var o=new k(l(e,n,i,r),s);return t.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},S(M),h(M,c,"Generator"),h(M,o,function(){return this}),h(M,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},t.values=E,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=i.call(o,"catchLoc"),h=i.call(o,"finallyLoc");if(c&&h){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,y):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),I(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;I(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:E(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],i=0,r="",s=0,o=arguments.length;s!==o;++s){var a=+arguments[s];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?i=n.push(a):(a-=65536,i=n.push(55296+(a>>10),a%1024+56320)),i>=16383&&(r+=t.apply(null,n),n.length=0)}return r+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
7
+ /*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,s=e.charCodeAt(i);return s>=55296&&s<=56319&&n>i+1&&(r=e.charCodeAt(i+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,i){function r(o,a){if(!n[o]){if(!e[o]){if(!a&&Aa)return Aa(o);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[o]={exports:{}};e[o][0].call(h.exports,function(t){return r(e[o][1][t]||t)},h,h.exports,t,e,n,i)}return n[o].exports}for(var s=Aa,o=0;o<i.length;o++)r(i[o]);return r}return t}()({1:[function(t,e,n){var i=t("./utils"),r=function(){var t=i.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],r=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],s=["Thousand","Million","Billion","Trillion"];function o(t,i){var o=function(t,i,a){var c="";if(t<=19)c=(i?" and ":"")+(a?n[t]:e[t]);else if(t<100){var h=Math.floor(t/10),l=t%10;c=(i?" and ":"")+r[h-2],l>0?c+="-"+o(l,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(t<1e3){var u=Math.floor(t/100),d=t%100;c=(i?", ":"")+e[u]+" Hundred",d>0?c+=o(d,!0,a):a&&(c+="th")}else{var p=Math.floor(Math.log10(t)/3);p>s.length&&(p=s.length);var f=Math.pow(10,3*p),m=Math.floor(t/f),y=t-m*f;c=(i?", ":"")+o(m,!1,!1)+" "+s[p-1],y>0?c+=o(y,!0,a):a&&(c+="th")}return c};return o(t,!1,i)}var a=Object.create(null);function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];return e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)}),n.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,s.forEach(function(t,e){var n=t.toLowerCase(),i=Math.pow(10,3*(e+1));a[n]=i,a[n+"th"]=i});var h=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],l={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function u(t){for(var e=0;e<h.length;e++){var n=h[e];if(t>=n[0])return n[1]+u(t-n[0])}return""}function d(t){for(var e=0,n=1,i=t.length-1;i>=0;i--){var r=t[i],s=l[r];s<n?e-=s:(n=s,e+=s)}return e}function p(t,e){for(var n=[],i=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+i)),t=Math.floor((t-1)/26);return n.join("")}function f(t,e){for(var n=e.charCodeAt(0),i=0,r=0;r<t.length;r++)i+=(t.charCodeAt(t.length-r-1)-n+1)*Math.pow(26,r);return i}function m(t,e){if(void 0!==t)return b(t=Math.floor(t),v(e))}var y={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},g={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var i,r=e<0;switch(e=Math.abs(e),n.primary){case y.LETTERS:i=p(e,n.case===g.UPPER?"A":"a");break;case y.ROMAN:i=u(e),n.case===g.UPPER&&(i=i.toUpperCase());break;case y.WORDS:i=o(e,n.ordinal),n.case===g.UPPER?i=i.toUpperCase():n.case===g.LOWER&&(i=i.toLowerCase());break;case y.DECIMAL:i=""+e;var s=n.mandatoryDigits-i.length;if(s>0){var a=new Array(s+1).join("0");i=a+i}if(48!==n.zeroCode&&(i=t(i).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((i.length-1)/n.groupingSeparators.position);c>0;c--){var h=i.length-c*n.groupingSeparators.position;i=i.substr(0,h)+n.groupingSeparators.character+i.substr(h)}else n.groupingSeparators.reverse().forEach(function(t){var e=i.length-t.position;i=i.substr(0,e)+t.character+i.substr(e)});if(n.ordinal){var l={1:"st",2:"nd",3:"rd"}[i[i.length-1]];(!l||i.length>1&&"1"===i[i.length-2])&&(l="th"),i+=l}break;case y.SEQUENCE:throw{code:"D3130",value:n.token}}return r&&(i="-"+i),i}var x=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function v(e){var n,i={type:"integer",primary:y.DECIMAL,case:g.LOWER,ordinal:!1},r=e.lastIndexOf(";");switch(-1===r?n=e:(n=e.substring(0,r),"o"===e.substring(r+1)[0]&&(i.ordinal=!0)),n){case"A":i.case=g.UPPER;case"a":i.primary=y.LETTERS;break;case"I":i.case=g.UPPER;case"i":i.primary=y.ROMAN;break;case"W":i.case=g.UPPER,i.primary=y.WORDS;break;case"Ww":i.case=g.TITLE,i.primary=y.WORDS;break;case"w":i.primary=y.WORDS;break;default:var s=null,o=0,a=0,c=[],h=0;if(t(n).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,n=0;n<x.length;n++){var i=x[n];if(t>=i&&t<=i+9){if(e=!0,o++,h++,null===s)s=i;else if(i!==s)throw{code:"D3131"};break}}e||(35===t?(h++,a++):c.push({position:h,character:String.fromCodePoint(t)}))}),o>0){i.primary=y.DECIMAL,i.zeroCode=s,i.mandatoryDigits=o,i.optionalDigits=a;var l=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var i=t.map(function(t){return t.position}),r=function(t,e){return 0===e?t:r(e,t%e)},s=i.reduce(r),o=1;o<=i.length;o++)if(-1===i.indexOf(o*s))return 0;return s}(c);l>0?(i.regular=!0,i.groupingSeparators={position:l,character:c[0].character}):(i.regular=!1,i.groupingSeparators=c)}else i.primary=y.SEQUENCE,i.token=n}return i}var w={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function _(t){for(var e=[],n={type:"datetime",parts:e},i=function(n,i){if(i>n){var r=t.substring(n,i);r=r.split("]]").join("]"),e.push({type:"literal",value:r})}},r=0,s=0;s<t.length;){if("["===t.charAt(s)){if("["===t.charAt(s+1)){i(r,s),e.push({type:"literal",value:"["}),r=s+=2;continue}if(i(r,s),r=s,-1===(s=t.indexOf("]",r)))throw{code:"D3135"};var o,a=t.substring(r+1,s),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},h=a.lastIndexOf(",");if(-1!==h){var l=a.substring(h+1),u=l.indexOf("-"),d=void 0,p=void 0,f=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===u?d=l:(d=l.substring(0,u),p=l.substring(u+1));var m={min:f(d),max:f(p)};c.width=m,o=a.substring(1,h)}else o=a.substring(1);if(1===o.length)c.presentation1=o;else if(o.length>1){var y=o.charAt(o.length-1);-1!=="atco".indexOf(y)?(c.presentation2=y,"o"===y&&(c.ordinal=!0),c.presentation1=o.substring(0,o.length-1)):c.presentation1=o}else c.presentation1=w[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=g.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=g.TITLE:c.names=g.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=v(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var x=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;x>=2&&(c.n=x)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=v(c.presentation1)),e.push(c),r=s+1}s++}return i(r,s),n}var M=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],k=864e5,A=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*k:e-(n-1)*k},z=function(t,e){return{year:t,month:e,nextMonth:function(){return 11===e?z(t+1,0):z(t,e+1)},previousMonth:function(){return 0===e?z(t-1,11):z(t,e-1)},nextYear:function(){return z(t+1,e)},previousYear:function(){return z(t-1,e)}}},T=function(t,e){return(e-t)/(7*k)+1},I=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/k+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var i=z(t.getUTCFullYear(),0),r=A(i),s=Date.UTC(i.year,t.getUTCMonth(),t.getUTCDate()),o=T(r,s);if(o>52)s>=A(i.nextYear())&&(o=1);else if(o<1){var a=A(i.previousYear());o=T(a,s)}n=Math.floor(o);break;case"w":var c=z(t.getUTCFullYear(),t.getUTCMonth()),h=A(c),l=Date.UTC(c.year,c.month,t.getUTCDate()),u=T(h,l);if(u>4)l>=A(c.nextMonth())&&(u=1);else if(u<1){var d=A(c.previousMonth());u=T(d,l)}n=Math.floor(u);break;case"X":var p=z(t.getUTCFullYear(),0),f=A(p),m=A(p.nextYear()),y=t.getTime();n=y<f?p.year-1:y>=m?p.year+1:p.year;break;case"x":var g=z(t.getUTCFullYear(),t.getUTCMonth()),b=A(g),x=g.nextMonth(),v=A(x),w=t.getTime();n=w<b?g.previousMonth().month+1:w>=v?x.month+1:g.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},O=null;function E(t,e,n){var i=0,r=0;if(void 0!==n){var s=parseInt(n);i=Math.floor(s/100),r=s%100}var o,a=function(t,e){var n=I(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=S[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=M[n]}e.names===g.UPPER?n=n.toUpperCase():e.names===g.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var s=100*i+r;if(e.integerFormat.regular)n=b(s,e.integerFormat);else{var o=e.integerFormat.mandatoryDigits;if(1===o||2===o)n=b(i,e.integerFormat),0!==r&&(n+=":"+m(r,"00"));else{if(3!==o&&4!==o)throw{code:"D3134",value:o};n=b(s,e.integerFormat)}}s>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===s&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===O&&(O=_("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),o=O):o=_(e);var c=new Date(t+60*(60*i+r)*1e3),h="";return o.parts.forEach(function(t){"literal"===t.type?h+=t.value:h+=a(c,t)}),h}function j(t){var e=Object.create(null);if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e=Object.create(null);if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var i=0,r=0;return n?(i=Number.parseInt(e.substring(0,e.indexOf(n.character))),r=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?i=Number.parseInt(e):(i=Number.parseInt(e.substring(0,3)),r=Number.parseInt(e.substring(3))),60*i+r}}else if("f"===t.component)e.regex="[0-9]+",e.parse=function(t){return 1e3*parseFloat("0."+t.substring(0,3))};else if(t.integerFormat)t.integerFormat.n=t.n,e=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var i=Object.create(null);if("M"===t.component||"x"===t.component)S.forEach(function(e,n){t.width&&t.width.max?i[e.substring(0,t.width.max)]=n+1:i[e]=n+1});else if("F"===t.component)M.forEach(function(e,n){n>0&&(t.width&&t.width.max?i[e.substring(0,t.width.max)]=n:i[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};i={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return i[t]}}return e.component=t.component,e});else{e.type="integer";var n,r=t.case===g.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case y.LETTERS:e.regex=r?"[A-Z]+":"[a-z]+",e.parse=function(t){return f(t,r?"A":"a")};break;case y.ROMAN:e.regex=r?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return d(r?t:t.toUpperCase())};break;case y.WORDS:e.regex="(?:"+i.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case y.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case y.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function P(t,e){if(void 0!==t)return j(v(e)).parse(t)}function C(t,e){var n=j(_(e)),i="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",r=new RegExp(i,"i").exec(t);if(null!==r){for(var s=161,o=130,a=84,c=72,h=23,l=47,u=Object.create(null),d=1;d<r.length;d++){var p=n.parts[d-1];p.parse&&(u[p.component]=p.parse(r[d]))}if(0===Object.getOwnPropertyNames(u).length)return;var f=0,m=function(t){f<<=1,f+=t?1:0},y=function(t){return!(~t&f||!(t&f))};"YXMxWwdD".split("").forEach(function(t){return m(u[t])});var g=!y(s)&&y(o),b=y(a),x=!b&&y(c);f=0,"PHhmsf".split("").forEach(function(t){return m(u[t])});var v=!y(h)&&y(l),w=(g?"YD":b?"XxwF":x?"XWF":"YMD")+(v?"Phmsf":"Hmsf"),M=this.environment.timestamp,S=!1,k=!1;if(w.split("").forEach(function(t){if(void 0===u[t])S?(u[t]=-1!=="MDd".indexOf(t)?1:0,k=!0):u[t]=I(M,t);else if(S=!0,k)throw{code:"D3136"}}),u.M>0?u.M-=1:u.M=0,g){var A=Date.UTC(u.Y,0),z=1e3*(u.d-1)*60*60*24,T=new Date(A+z);u.M=T.getUTCMonth(),u.D=T.getUTCDate()}if(b)throw{code:"D3136"};if(x)throw{code:"D3136"};v&&(u.H=12===u.h?0:u.h,1===u.P&&(u.H+=12));var O=Date.UTC(u.Y,u.M,u.D,u.H,u.m,u.s,u.f);return(u.Z||u.z)&&(O-=60*(u.Z||u.z)*1e3),O}}var R=new RegExp("^\\d{4}(-[01]\\d)?(-[0-3]\\d)?(T[0-2]\\d:[0-5]\\d:[0-5]\\d)?(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function F(t,e){if(void 0!==t){if(void 0===e){if(!R.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return C.call(this,t,e)}}function D(t,e,n){if(void 0!==t)return E.call(this,t,e,n)}return{formatInteger:m,parseInteger:P,fromMillis:D,toMillis:F}}();e.exports=r},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function a(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(o(t)+" is not iterable")}function c(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,i,r,s){var c=i&&i.prototype instanceof a?i:a,l=Object.create(c.prototype);return h(l,"_invoke",function(n,i,r){var s,a,c,h=0,l=r||[],u=!1,d={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return s=e,a=0,c=t,d.n=n,o}};function p(n,i){for(a=n,c=i,e=0;!u&&h&&!r&&e<l.length;e++){var r,s=l[e],p=d.p,f=s[2];n>3?(r=f===i)&&(c=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=t):s[0]<=p&&((r=n<2&&p<s[1])?(a=0,d.v=i,d.n=s[1]):p<f&&(r=n<3||s[0]>i||i>f)&&(s[4]=n,s[5]=i,d.n=f,a=0))}if(r||n>1)return o;throw u=!0,i}return function(r,l,f){if(h>1)throw TypeError("Generator is already running");for(u&&1===l&&p(l,f),a=l,c=f;(e=a<2?t:c)||!u;){s||(a?a<3?(a>1&&(d.n=-1),p(a,c)):d.n=c:d.v=c);try{if(h=2,s){if(a||(r="next"),e=s[r]){if(!(e=e.call(s,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=s.return)&&e.call(s),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);s=t}else if((e=(u=d.n<0)?c:n.call(i,d))!==o)break}catch(e){s=t,a=1,c=e}finally{h=1}}return{value:e,done:u}}}(n,r,s),!0),l}var o={};function a(){}function l(){}function u(){}e=Object.getPrototypeOf;var d=[][i]?e(e([][i]())):(h(e={},i,function(){return this}),e),p=u.prototype=a.prototype=Object.create(d);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,h(t,r,"GeneratorFunction")),t.prototype=Object.create(p),t}return l.prototype=u,h(p,"constructor",u),h(u,"constructor",l),l.displayName="GeneratorFunction",h(u,r,"GeneratorFunction"),h(p),h(p,r,"Generator"),h(p,i,function(){return this}),h(p,"toString",function(){return"[object Generator]"}),(c=function(){return{w:s,m:f}})()}function h(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}h=function(t,e,n,i){function s(e,n){h(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(s("next",0),s("throw",1),s("return",2))},h(t,e,n,i)}var l=t("./utils"),u=function(){var t=c().m(q),e=c().m($),r=c().m(V),s=c().m(Y),h=c().m(K),u=c().m(ft),d=c().m(mt),p=c().m(yt),f=c().m(bt),m=c().m(At),y=c().m(Ot),g=c().m(Pt),b=l.isNumeric,x=l.isArrayOfStrings,v=l.isArrayOfNumbers,w=l.createSequence,_=l.isSequence,M=l.isFunction,S=l.isLambda,k=l.isIterable,A=l.getFunctionArity,z=l.isDeepEqual,T=l.stringToArray;function I(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function O(t){return void 0===t?0:t.length}function E(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function j(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function P(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function C(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(M(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var i=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&b(e)?Number(e.toPrecision(15)):e&&M(e)?"":e},i)}return n}}function R(t,e,n){if(void 0!==t){var i=T(t),r=i.length;if(r+e<0&&(e=0),void 0!==n){if(n<=0)return"";var s=e>=0?e+n:r+e+n;return i.slice(e,s).join("")}return i.slice(e).join("")}}function F(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function D(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function N(t){if(void 0!==t)return t.toLowerCase()}function L(t){if(void 0!==t)return t.toUpperCase()}function B(t){if(void 0!==t)return T(t).length}function U(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function W(t,e,n){if(void 0!==t){var i;void 0!==n&&0!==n.length||(n=" ");var r=Math.abs(e)-B(t);if(r>0){var s=new Array(r+1).join(n);n.length>1&&(s=R(s,0,r)),i=e>0?t+s:s+t}else i=t;return i}}function q(e,n){var i;return c().w(function(t){for(;;)switch(t.n){case 0:if(i=e.apply(this,[n]),!k(i)){t.n=2;break}return t.d(a(i),1);case 1:i=t.v;case 2:if(!i||"number"==typeof i.start||"number"===i.end||Array.isArray(i.groups)||M(i.next)){t.n=3;break}throw{code:"T1010",stack:(new Error).stack};case 3:return t.a(2,i)}},t,this)}function $(t,n){var i,r;return c().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof n){e.n=2;break}i=-1!==t.indexOf(n),e.n=4;break;case 2:return e.d(a(q(n,t)),3);case 3:r=e.v,i=void 0!==r;case 4:return e.a(2,i)}},e)}function V(t,e,n){var i,s,o;return c().w(function(r){for(;;)switch(r.n){case 0:if(void 0!==t){r.n=1;break}return r.a(2,void 0);case 1:if(!(n<0)){r.n=2;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 2:if(i=w(),!(void 0===n||n>0)){r.n=6;break}return s=0,r.d(a(q(e,t)),3);case 3:if(void 0===(o=r.v)){r.n=6;break}case 4:if(void 0===o||!(void 0===n||s<n)){r.n=6;break}return i.push({match:o.match,index:o.start,groups:o.groups}),r.d(a(q(o.next)),5);case 5:o=r.v,s++,r.n=4;break;case 6:return r.a(2,i)}},r)}function Y(t,e,n,i){var r,o,h,l,u,d,p,f;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:if(r=this,""!==e){s.n=2;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 2:if(!(i<0)){s.n=3;break}throw{code:"D3011",stack:(new Error).stack,value:i,index:4};case 3:if(o="string"==typeof n?function(t){for(var e="",i=0,r=n.indexOf("$",i);-1!==r&&i<n.length;){e+=n.substring(i,r),i=r+1;var s=n.charAt(i);if("$"===s)e+="$",i++;else if("0"===s)e+=t.match,i++;else{var o;if(o=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,r=parseInt(n.substring(i,i+o),10),o>1&&r>t.groups.length&&(r=parseInt(n.substring(i,i+o-1),10)),isNaN(r))e+="$";else{if(t.groups.length>0){var a=t.groups[r-1];void 0!==a&&(e+=a)}i+=r.toString().length}}r=n.indexOf("$",i)}return e+=n.substring(i)}:n,h="",l=0,!(void 0===i||i>0)){s.n=15;break}if(u=0,"string"!=typeof e){s.n=4;break}for(d=t.indexOf(e,l);-1!==d&&(void 0===i||u<i);)h+=t.substring(l,d),h+=n,l=d+e.length,u++,d=t.indexOf(e,l);h+=t.substring(l),s.n=14;break;case 4:return s.d(a(q(e,t)),5);case 5:if(void 0===(p=s.v)){s.n=13;break}case 6:if(void 0===p||!(void 0===i||u<i)){s.n=12;break}if(h+=t.substring(l,p.start),f=o.apply(r,[p]),!k(f)){s.n=8;break}return s.d(a(f),7);case 7:f=s.v;case 8:if("string"!=typeof f){s.n=9;break}h+=f,s.n=10;break;case 9:throw{code:"D3012",stack:(new Error).stack,value:f};case 10:return l=p.start+p.match.length,u++,s.d(a(q(p.next)),11);case 11:p=s.v,s.n=6;break;case 12:h+=t.substring(l),s.n=14;break;case 13:h=t;case 14:s.n=16;break;case 15:h=t;case 16:return s.a(2,h)}},s,this)}function H(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function G(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function X(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function Z(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function J(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function Q(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function K(t,e,n){var i,r,s,o;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!(n<0)){c.n=2;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 2:if(i=[],!(void 0===n||n>0)){c.n=9;break}if("string"!=typeof e){c.n=3;break}i=t.split(e,n),c.n=9;break;case 3:return r=0,c.d(a(q(e,t)),4);case 4:if(void 0===(s=c.v)){c.n=8;break}o=0;case 5:if(void 0===s||!(void 0===n||r<n)){c.n=7;break}return i.push(t.substring(o,s.start)),o=s.end,c.d(a(q(s.next)),6);case 6:s=c.v,r++,c.n=5;break;case 7:(void 0===n||r<n)&&i.push(t.substring(o)),c.n=9;break;case 8:i.push(t);case 9:return c.a(2,i)}},h)}function tt(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function et(t,e,n){if(void 0!==t){var i={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&l.keys(n).forEach(function(t){i[t]=n[t]});for(var r=[],s=i["zero-digit"].charCodeAt(0),o=s;o<s+10;o++)r.push(String.fromCharCode(o));var a=r.concat([i["decimal-separator"],i["exponent-separator"],i["grouping-separator"],i.digit,i["pattern-separator"]]),c=e.split(i["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var h=function(t){var e,n,r,s,o=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(n+1)}(),h=t.substring(o.length,t.length-c.length),l=t.indexOf(i["exponent-separator"],o.length);-1===l||l>t.length-c.length?(e=h,n=void 0):(e=h.substring(0,l),n=h.substring(l+1));var u=e.indexOf(i["decimal-separator"]);return-1===u?(r=e,s=c):(r=e.substring(0,u),s=e.substring(u+1)),{prefix:o,suffix:c,activePart:h,mantissaPart:e,exponentPart:n,integerPart:r,fractionalPart:s,subpicture:t}},u=function(t){var e,n,s=t.subpicture,o=s.indexOf(i["decimal-separator"]);o!==s.lastIndexOf(i["decimal-separator"])&&(e="D3081"),s.indexOf(i.percent)!==s.lastIndexOf(i.percent)&&(e="D3082"),s.indexOf(i["per-mille"])!==s.lastIndexOf(i["per-mille"])&&(e="D3083"),-1!==s.indexOf(i.percent)&&-1!==s.indexOf(i["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var h=t.mantissaPart.charAt(n);if(-1!==r.indexOf(h)||h===i.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==o?s.charAt(o-1)!==i["grouping-separator"]&&s.charAt(o+1)!==i["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===i["grouping-separator"]&&(e="D3088"),-1!==s.indexOf(i["grouping-separator"]+i["grouping-separator"])&&(e="D3089");var l=t.integerPart.indexOf(i.digit);-1!==l&&t.integerPart.substring(0,l).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(l=t.fractionalPart.lastIndexOf(i.digit))&&t.fractionalPart.substring(l).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3091");var u="string"==typeof t.exponentPart;if(u&&t.exponentPart.length>0&&(-1!==s.indexOf(i.percent)||-1!==s.indexOf(i["per-mille"]))&&(e="D3092"),u&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===r.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},d=function(t){var e=function(e,n){for(var s=[],o=e.indexOf(i["grouping-separator"]);-1!==o;){var a=(n?e.substring(0,o):e.substring(o)).split("").filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length;s.push(a),o=t.integerPart.indexOf(i["grouping-separator"],o+1)}return s},n=e(t.integerPart),s=function(t){if(0===t.length)return 0;for(var e=function(t,n){return 0===n?t:e(n,t%n)},n=t.reduce(e),i=1;i<=t.length;i++)if(-1===t.indexOf(i*n))return 0;return n}(n),o=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length,c=a,h=t.fractionalPart.split(""),l=h.filter(function(t){return-1!==r.indexOf(t)}).length,u=h.filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length,d="string"==typeof t.exponentPart;0===a&&0===u&&(d?(l=1,u=1):a=1),d&&0===a&&-1!==t.integerPart.indexOf(i.digit)&&(a=1),0===a&&0===l&&(l=1);var p=0;return d&&(p=t.exponentPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:s,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:o,minimumFactionalPartSize:l,maximumFactionalPartSize:u,minimumExponentSize:p,suffix:t.suffix,picture:t.subpicture}},p=c.map(h);p.forEach(u);var f,m,y,g,b=p.map(d),x=i["minus-sign"],v=i["zero-digit"],w=i["decimal-separator"],_=i["grouping-separator"];if(1===b.length&&(b.push(JSON.parse(JSON.stringify(b[0]))),b[1].prefix=x+b[1].prefix),m=-1!==(f=t>=0?b[0]:b[1]).picture.indexOf(i.percent)?100*t:-1!==f.picture.indexOf(i["per-mille"])?1e3*t:t,0===f.minimumExponentSize)y=m;else{var M=Math.pow(10,f.scalingFactor),S=Math.pow(10,f.scalingFactor-1);for(y=m,g=0;y<S;)y*=10,g-=1;for(;y>M;)y/=10,g+=1}var k=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==v&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?r[t.charCodeAt(0)-48]:t}).join("")),n},A=k(at(y,f.maximumFactionalPartSize),f.maximumFactionalPartSize),z=A.indexOf(".");for(-1===z?A+=w:A=A.replace(".",w);A.charAt(0)===v;)A=A.substring(1);for(;A.charAt(A.length-1)===v;)A=A.substring(0,A.length-1);z=A.indexOf(w);var T=f.minimumIntegerPartSize-z,I=f.minimumFactionalPartSize-(A.length-z-1);if(A=(T>0?new Array(T+1).join(v):"")+A,A+=I>0?new Array(I+1).join(v):"",z=A.indexOf(w),f.regularGrouping>0)for(var O=Math.floor((z-1)/f.regularGrouping),E=1;E<=O;E++)A=[A.slice(0,z-E*f.regularGrouping),_,A.slice(z-E*f.regularGrouping)].join("");else f.integerPartGroupingPositions.forEach(function(t){A=[A.slice(0,z-t),_,A.slice(z-t)].join(""),z++});if(z=A.indexOf(w),f.fractionalPartGroupingPositions.forEach(function(t){A=[A.slice(0,t+z+1),_,A.slice(t+z+1)].join("")}),z=A.indexOf(w),-1!==f.picture.indexOf(w)&&z!==A.length-1||(A=A.substring(0,A.length-1)),void 0!==g){var j=k(g,0);(T=f.minimumExponentSize-j.length)>0&&(j=new Array(T+1).join(v)+j),A=A+i["exponent-separator"]+(g<0?x:"")+j}return A=f.prefix+A+f.suffix}}function nt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function it(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function rt(t){if(void 0!==t)return Math.abs(t)}function st(t){if(void 0!==t)return Math.floor(t)}function ot(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var n;if(void 0!==t){if(e){var i=t.toString().split("e");t=+(i[0]+"e"+(i[1]?+i[1]+e:e))}var r=(n=Math.round(t))-t;return.5===Math.abs(r)&&1===Math.abs(n%2)&&(n-=1),e&&(i=n.toString().split("e"),n=+(i[0]+"e"+(i[1]?+i[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ct(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ht(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function lt(){return Math.random()}function ut(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ut(t[0]):t.length>1&&(e=t.filter(function(t){return ut(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):b(t)?0!==t&&(e=!0):null!==t&&"object"===o(t)?l.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function dt(t){if(void 0!==t)return!ut(t)}function pt(t,e,n,i){var r=[e],s=A(t);return s>=2&&r.push(n),s>=3&&r.push(i),r}function ft(t,e){var n,i,r,s;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:n=w(),i=0;case 2:if(!(i<t.length)){o.n=5;break}return r=pt(e,t[i],i,t),o.d(a(e.apply(this,r)),3);case 3:void 0!==(s=o.v)&&n.push(s);case 4:i++,o.n=2;break;case 5:return o.a(2,n)}},u,this)}function mt(t,e){var n,i,r,s;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:n=w(),i=0;case 2:if(!(i<t.length)){o.n=5;break}return r=t[i],s=pt(e,r,i,t),o.d(a(e.apply(this,s)),3);case 3:ut(o.v)&&n.push(r);case 4:i++,o.n=2;break;case 5:return o.a(2,n)}},d,this)}function yt(t,e){var n,i,r,s,o,h,l;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:n=!1,r=0;case 2:if(!(r<t.length)){c.n=7;break}if(s=t[r],o=!0,void 0===e){c.n=4;break}return h=pt(e,s,r,t),c.d(a(e.apply(this,h)),3);case 3:l=c.v,o=ut(l);case 4:if(!o){c.n=6;break}if(n){c.n=5;break}i=s,n=!0,c.n=6;break;case 5:throw{stack:(new Error).stack,code:"D3138",index:r};case 6:r++,c.n=2;break;case 7:if(n){c.n=8;break}throw{stack:(new Error).stack,code:"D3139"};case 8:return c.a(2,i)}},p,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),i=0;i<n;i++){var r=e.map(function(t){return t[i]});t.push(r)}return t}function bt(t,e,n){var i,r,s,o;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!((r=A(e))<2)){c.n=2;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 2:void 0===n&&t.length>0?(i=t[0],s=1):(i=n,s=0);case 3:if(!(s<t.length)){c.n=5;break}return o=[i,t[s]],r>=3&&o.push(s),r>=4&&o.push(t),c.d(a(e.apply(this,o)),4);case 4:i=c.v,s++,c.n=3;break;case 5:return c.a(2,i)}},f,this)}function xt(t){var e=w();if(Array.isArray(t)){var n=Object.create(null);t.forEach(function(t){xt(t).forEach(function(t){n[t]=!0})}),e=xt(n)}else null===t||"object"!==o(t)||S(t)||l.keys(t).forEach(function(t){return e.push(t)});return e}function vt(t,e){var n;if(Array.isArray(t)){n=w();for(var i=0;i<t.length;i++){var r=vt(t[i],e);void 0!==r&&(Array.isArray(r)?r.forEach(function(t){return n.push(t)}):n.push(r))}}else null!==t&&"object"===o(t)&&Object.prototype.hasOwnProperty.call(t,e)&&!M(t)&&(n=t[e]);return n}function wt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=w(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function _t(t){return void 0!==t}function Mt(t){var e=w();if(Array.isArray(t))t.forEach(function(t){e=wt(e,Mt(t))});else if(null===t||"object"!==o(t)||S(t))e=t;else{var n,r=i(l.keys(t));try{for(r.s();!(n=r.n()).done;){var s=n.value,a=Object.create(null);a[s]=t[s],e.push(a)}}catch(t){r.e(t)}finally{r.f()}}return e}function St(t){if(void 0!==t){var e=Object.create(null);return t.forEach(function(t){var n,r=i(l.keys(t));try{for(r.s();!(n=r.n()).done;){var s=n.value;e[s]=t[s]}}catch(t){r.e(t)}finally{r.f()}}),e}}function kt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),i=0;i<e;i++)n[e-i-1]=t[i];return n}}function At(t,e){var n,r,s,o,h,u,d;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=w(),r=i(l.keys(t)),c.p=1,r.s();case 2:if((s=r.n()).done){c.n=5;break}return o=s.value,h=pt(e,t[o],o,t),c.d(a(e.apply(this,h)),3);case 3:void 0!==(u=c.v)&&n.push(u);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,d=c.v,r.e(d);case 7:return c.p=7,r.f(),c.f(7);case 8:return c.a(2,n)}},m,this,[[1,6,7,8]])}function zt(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function Tt(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function It(t){if(void 0!==t)return null===t?"null":b(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":M(t)?"function":"object"}function Ot(t,e){var n,i,r,s;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:if(!(t.length<=1)){o.n=2;break}return o.a(2,t);case 2:if(void 0!==e){o.n=4;break}if(v(t)||x(t)){o.n=3;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 3:n=c().m(function t(e,n){return c().w(function(t){for(;;)if(0===t.n)return t.a(2,e>n)},t)}),o.n=5;break;case 4:n=e;case 5:return i=c().m(function t(e,i){var r,s;return c().w(function(t){for(;;)switch(t.n){case 0:return r=c().m(function t(e,i,s){return c().w(function(t){for(;;)switch(t.n){case 0:if(0!==i.length){t.n=1;break}Array.prototype.push.apply(e,s),t.n=6;break;case 1:if(0!==s.length){t.n=2;break}Array.prototype.push.apply(e,i),t.n=6;break;case 2:return t.d(a(n(i[0],s[0])),3);case 3:if(!t.v){t.n=5;break}return e.push(s[0]),t.d(a(r(e,i,s.slice(1))),4);case 4:t.n=6;break;case 5:return e.push(i[0]),t.d(a(r(e,i.slice(1),s)),6);case 6:return t.a(2)}},t)}),s=[],t.d(a(r(s,e,i)),1);case 1:return t.a(2,s)}},t)}),r=c().m(function t(e){var n,s,o;return c().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(e)&&!(e.length<=1)){t.n=1;break}return t.a(2,e);case 1:return n=Math.floor(e.length/2),s=e.slice(0,n),o=e.slice(n),t.d(a(r(s)),2);case 2:return s=t.v,t.d(a(r(o)),3);case 3:return o=t.v,t.d(a(i(s,o)),4);case 4:return t.a(2,t.v);case 5:return t.a(2)}},t)}),o.d(a(r(t)),6);case 6:return s=o.v,o.a(2,s)}},y)}function Et(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var i=Math.floor(Math.random()*(n+1));n!==i&&(e[n]=e[i]),e[i]=t[n]}return e}}function jt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=_(t)?w():[],n=0;n<t.length;n++){for(var i=t[n],r=!1,s=0;s<e.length;s++)if(z(i,e[s])){r=!0;break}r||e.push(i)}return e}}function Pt(t,e){var n,r,s,o,h,u,d;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=Object.create(null),r=i(l.keys(t)),c.p=1,r.s();case 2:if((s=r.n()).done){c.n=5;break}return o=s.value,h=t[o],u=pt(e,h,o,t),c.d(a(e.apply(this,u)),3);case 3:ut(c.v)&&(n[o]=h);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,d=c.v,r.e(d);case 7:return c.p=7,r.f(),c.f(7);case 8:return 0===l.keys(n).length&&(n=void 0),c.a(2,n)}},g,this,[[1,6,7,8]])}return{sum:I,count:O,max:E,min:j,average:P,string:C,substring:R,substringBefore:F,substringAfter:D,lowercase:N,uppercase:L,length:B,trim:U,pad:W,match:V,contains:$,replace:Y,split:K,join:tt,formatNumber:et,formatBase:nt,number:it,floor:st,ceil:ot,round:at,abs:rt,sqrt:ct,power:ht,random:lt,boolean:ut,not:dt,map:ft,zip:gt,filter:mt,single:yt,foldLeft:bt,sift:Pt,keys:xt,lookup:vt,append:wt,exists:_t,spread:Mt,merge:St,reverse:kt,each:At,error:zt,assert:Tt,type:It,sort:Ot,shuffle:Et,distinct:jt,base64encode:H,base64decode:G,encodeUrlComponent:X,encodeUrl:Z,decodeUrlComponent:J,decodeUrl:Q}}();e.exports=u}).call(this)}).call(this,void 0!==Sa?Sa:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function i(t){var e=Object(t),n=[];for(var i in e)n.unshift(i);return function t(){for(;n.length;)if((i=n.pop())in e)return t.value=i,t.done=!1,t;return t.done=!0,t}}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function s(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=o(t))||e){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function c(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(r(t)+" is not iterable")}function h(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,i,r,s){var c=i&&i.prototype instanceof a?i:a,h=Object.create(c.prototype);return l(h,"_invoke",function(n,i,r){var s,a,c,h=0,l=r||[],u=!1,d={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return s=e,a=0,c=t,d.n=n,o}};function p(n,i){for(a=n,c=i,e=0;!u&&h&&!r&&e<l.length;e++){var r,s=l[e],p=d.p,f=s[2];n>3?(r=f===i)&&(c=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=t):s[0]<=p&&((r=n<2&&p<s[1])?(a=0,d.v=i,d.n=s[1]):p<f&&(r=n<3||s[0]>i||i>f)&&(s[4]=n,s[5]=i,d.n=f,a=0))}if(r||n>1)return o;throw u=!0,i}return function(r,l,f){if(h>1)throw TypeError("Generator is already running");for(u&&1===l&&p(l,f),a=l,c=f;(e=a<2?t:c)||!u;){s||(a?a<3?(a>1&&(d.n=-1),p(a,c)):d.n=c:d.v=c);try{if(h=2,s){if(a||(r="next"),e=s[r]){if(!(e=e.call(s,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=s.return)&&e.call(s),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);s=t}else if((e=(u=d.n<0)?c:n.call(i,d))!==o)break}catch(e){s=t,a=1,c=e}finally{h=1}}return{value:e,done:u}}}(n,r,s),!0),h}var o={};function a(){}function c(){}function u(){}e=Object.getPrototypeOf;var d=[][i]?e(e([][i]())):(l(e={},i,function(){return this}),e),p=u.prototype=a.prototype=Object.create(d);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,l(t,r,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=u,l(p,"constructor",u),l(u,"constructor",c),c.displayName="GeneratorFunction",l(u,r,"GeneratorFunction"),l(p),l(p,r,"Generator"),l(p,i,function(){return this}),l(p,"toString",function(){return"[object Generator]"}),(h=function(){return{w:s,m:f}})()}function l(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}l=function(t,e,n,i){function s(e,n){l(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(s("next",0),s("throw",1),s("return",2))},l(t,e,n,i)}var u=t("./datetime"),d=t("./functions"),p=t("./utils"),f=t("./parser"),m=t("./signature"),y=function(){var t=h().m(q),e=h().m($),n=h().m(Y),o=h().m(H),a=h().m(G),l=h().m(X),y=h().m(Z),g=h().m(J),b=h().m(ct),x=h().m(ut),v=h().m(ft),w=h().m(mt),_=h().m(yt),M=h().m(xt),S=h().m(_t),k=h().m(Mt),A=h().m(St),z=h().m(kt),T=h().m(zt),I=h().m(It),O=h().m(jt),E=h().m(Rt),j=p.isNumeric,P=p.isArrayOfStrings,C=p.isArrayOfNumbers,R=p.createSequence,F=p.isSequence,D=p.isFunction,N=p.isLambda,L=p.isIterable,B=p.getFunctionArity,U=p.isDeepEqual,W=Dt(null);function q(e,n,i){var r,s,o,a,l;return h().w(function(t){for(;;)switch(t.n){case 0:(s=i.lookup("__evaluate_entry"))&&s(e,n,i),l=e.type,t.n="path"===l?1:"binary"===l?3:"unary"===l?5:"name"===l?7:"string"===l||"number"===l||"value"===l?8:"wildcard"===l?9:"descendant"===l?10:"parent"===l?11:"condition"===l?12:"block"===l?14:"bind"===l?16:"regex"===l?18:"function"===l?19:"variable"===l?21:"lambda"===l?22:"partial"===l?23:"apply"===l?25:"transform"===l?27:28;break;case 1:return t.d(c($(e,n,i)),2);case 2:return r=t.v,t.a(3,28);case 3:return t.d(c(Z(e,n,i)),4);case 4:return r=t.v,t.a(3,28);case 5:return t.d(c(J(e,n,i)),6);case 6:return r=t.v,t.a(3,28);case 7:return r=Q(e,n),t.a(3,28);case 8:return r=K(e),t.a(3,28);case 9:return r=tt(e,n),t.a(3,28);case 10:return r=nt(e,n),t.a(3,28);case 11:return r=i.lookup(e.slot.label),t.a(3,28);case 12:return t.d(c(mt(e,n,i)),13);case 13:return r=t.v,t.a(3,28);case 14:return t.d(c(yt(e,n,i)),15);case 15:return r=t.v,t.a(3,28);case 16:return t.d(c(ft(e,n,i)),17);case 17:return r=t.v,t.a(3,28);case 18:return r=gt(e),t.a(3,28);case 19:return t.d(c(Mt(e,n,i)),20);case 20:return r=t.v,t.a(3,28);case 21:return r=bt(e,n,i),t.a(3,28);case 22:return r=At(e,n,i),t.a(3,28);case 23:return t.d(c(zt(e,n,i)),24);case 24:return r=t.v,t.a(3,28);case 25:return t.d(c(_t(e,n,i)),26);case 26:return r=t.v,t.a(3,28);case 27:return r=vt(e,n,i),t.a(3,28);case 28:if(!i.async||null!=r&&"function"==typeof r.then||(r=Promise.resolve(r)),!i.async||"function"!=typeof r.then||!e.nextFunction||"function"!=typeof r[e.nextFunction]){t.n=29;break}t.n=31;break;case 29:return t.n=30,r;case 30:r=t.v;case 31:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.n=35;break}o=0;case 32:if(!(o<e.predicate.length)){t.n=35;break}return t.d(c(X(e.predicate[o].expr,r,i)),33);case 33:r=t.v;case 34:o++,t.n=32;break;case 35:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.n=37;break}return t.d(c(ut(e.group,r,i)),36);case 36:r=t.v;case 37:return(a=i.lookup("__evaluate_exit"))&&a(e,n,i,r),r&&F(r)&&!r.tupleStream&&(e.keepArray&&(r.keepSingleton=!0),0===r.length?r=void 0:1===r.length&&(r=r.keepSingleton?r:r[0])),t.a(2,r)}},t)}function $(t,n,i){var r,s,o,a,l,u;return h().w(function(e){for(;;)switch(e.n){case 0:r=Array.isArray(n)&&"variable"!==t.steps[0].type?n:R(n),o=!1,a=void 0,l=0;case 1:if(!(l<t.steps.length)){e.n=10;break}if((u=t.steps[l]).tuple&&(o=!0),0!==l||!u.consarray){e.n=3;break}return e.d(c(q(u,r,i)),2);case 2:s=e.v,e.n=7;break;case 3:if(!o){e.n=5;break}return e.d(c(G(u,r,a,i)),4);case 4:a=e.v,e.n=7;break;case 5:return e.d(c(Y(u,r,i,l===t.steps.length-1)),6);case 6:s=e.v;case 7:if(o||void 0!==s&&0!==s.length){e.n=8;break}return e.a(3,10);case 8:void 0===u.focus&&(r=s);case 9:l++,e.n=1;break;case 10:if(o)if(t.tuple)s=a;else for(s=R(),l=0;l<a.length;l++)s.push(a[l]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=R(s)),s.keepSingleton=!0),!Object.prototype.hasOwnProperty.call(t,"group")){e.n=12;break}return e.d(c(ut(t.group,o?a:s,i)),11);case 11:s=e.v;case 12:return e.a(2,s)}},e)}function V(t,e){var n,i=Dt(t),r=s(p.keys(e));try{for(r.s();!(n=r.n()).done;){var o=n.value;i.bind(o,e[o])}}catch(t){r.e(t)}finally{r.f()}return i}function Y(t,e,i,r){var s,o,a,l,u;return h().w(function(n){for(;;)switch(n.n){case 0:if("sort"!==t.type){n.n=4;break}return n.d(c(xt(t,e,i)),1);case 1:if(s=n.v,!t.stages){n.n=3;break}return n.d(c(H(t.stages,s,i)),2);case 2:s=n.v;case 3:return n.a(2,s);case 4:s=R(),o=0;case 5:if(!(o<e.length)){n.n=12;break}return n.d(c(q(t,e[o],i)),6);case 6:if(a=n.v,!t.stages){n.n=10;break}l=0;case 7:if(!(l<t.stages.length)){n.n=10;break}return n.d(c(X(t.stages[l].expr,a,i)),8);case 8:a=n.v;case 9:l++,n.n=7;break;case 10:void 0!==a&&s.push(a);case 11:o++,n.n=5;break;case 12:return u=R(),r&&1===s.length&&Array.isArray(s[0])&&!F(s[0])?u=s[0]:Array.prototype.forEach.call(s,function(t){!Array.isArray(t)||t.cons?u.push(t):Array.prototype.forEach.call(t,function(t){return u.push(t)})}),n.a(2,u)}},n)}function H(t,e,n){var i,r,s,a,l;return h().w(function(o){for(;;)switch(o.n){case 0:i=e,r=0;case 1:if(!(r<t.length)){o.n=6;break}s=t[r],l=s.type,o.n="filter"===l?2:"index"===l?4:5;break;case 2:return o.d(c(X(s.expr,i,n)),3);case 3:return i=o.v,o.a(3,5);case 4:for(a=0;a<i.length;a++)i[a][s.value]=a;return o.a(3,5);case 5:r++,o.n=1;break;case 6:return o.a(2,i)}},o)}function G(t,e,n,i){var r,s,o,l,u,d,p,f;return h().w(function(a){for(;;)switch(a.n){case 0:if("sort"!==t.type){a.n=7;break}if(!n){a.n=2;break}return a.d(c(xt(t,n,i)),1);case 1:r=a.v,a.n=4;break;case 2:return a.d(c(xt(t,e,i)),3);case 3:for(s=a.v,(r=R()).tupleStream=!0,o=0;o<s.length;o++)(l={"@":s[o]})[t.index]=o,r.push(l);case 4:if(!t.stages){a.n=6;break}return a.d(c(H(t.stages,r,i)),5);case 5:r=a.v;case 6:return a.a(2,r);case 7:(r=R()).tupleStream=!0,u=i,void 0===n&&(n=e.map(function(t){return{"@":t}})),d=0;case 8:if(!(d<n.length)){a.n=11;break}return u=V(i,n[d]),a.d(c(q(t,n[d]["@"],u)),9);case 9:if(void 0!==(p=a.v))for(Array.isArray(p)||(p=[p]),f=0;f<p.length;f++)l=Object.create(null),Object.assign(l,n[d]),p.tupleStream?Object.assign(l,p[f]):(t.focus?(l[t.focus]=p[f],l["@"]=n[d]["@"]):l["@"]=p[f],t.index&&(l[t.index]=f),t.ancestor&&(l[t.ancestor.label]=n[d]["@"])),r.push(l);case 10:d++,a.n=8;break;case 11:if(!t.stages){a.n=13;break}return a.d(c(H(t.stages,r,i)),12);case 12:r=a.v;case 13:return a.a(2,r)}},a)}function X(t,e,n){var i,r,s,o,a,u;return h().w(function(h){for(;;)switch(h.n){case 0:if(i=R(),e&&e.tupleStream&&(i.tupleStream=!0),Array.isArray(e)||(e=R(e)),"number"!==t.type){h.n=1;break}(r=Math.floor(t.value))<0&&(r=e.length+r),void 0!==(s=e[r])&&(Array.isArray(s)?i=s:i.push(s)),h.n=5;break;case 1:r=0;case 2:if(!(r<e.length)){h.n=5;break}return s=e[r],o=s,a=n,e.tupleStream&&(o=s["@"],a=V(n,s)),h.d(c(q(t,o,a)),3);case 3:u=h.v,j(u)&&(u=[u]),C(u)?Array.prototype.forEach.call(u,function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===r&&i.push(s)}):d.boolean(u)&&i.push(s);case 4:r++,h.n=2;break;case 5:return h.a(2,i)}},l)}function Z(t,e,n){var i,r,s,o,a,l,u,d;return h().w(function(p){for(;;)switch(p.p=p.n){case 0:return p.d(c(q(t.lhs,e,n)),1);case 1:if(r=p.v,s=t.value,o=h().m(function i(){return h().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(q(t.rhs,e,n)),1);case 1:return i.a(2,i.v)}},i)}),"and"!==s&&"or"!==s){p.n=5;break}return p.p=2,p.d(c(ct(r,o,s)),3);case 3:return p.a(2,p.v);case 4:throw p.p=4,(l=p.v).position=t.position,l.token=s,l;case 5:return p.d(c(o()),6);case 6:a=p.v,p.p=7,u=s,p.n="+"===u||"-"===u||"*"===u||"/"===u||"%"===u?8:"="===u||"!="===u?9:"<"===u||"<="===u||">"===u||">="===u?10:"&"===u?11:".."===u?12:"in"===u?13:14;break;case 8:return i=rt(r,a,s),p.a(3,14);case 9:return i=st(r,a,s),p.a(3,14);case 10:return i=ot(r,a,s),p.a(3,14);case 11:return i=lt(r,a),p.a(3,14);case 12:return i=pt(r,a),p.a(3,14);case 13:return i=at(r,a),p.a(3,14);case 14:p.n=16;break;case 15:throw p.p=15,(d=p.v).position=t.position,d.token=s,d;case 16:return p.a(2,i)}},y,null,[[7,15],[2,4]])}function J(t,e,n){var i,r,s,o,a;return h().w(function(h){for(;;)switch(h.n){case 0:a=t.value,h.n="-"===a?1:"["===a?6:"{"===a?11:13;break;case 1:return h.d(c(q(t.expression,e,n)),2);case 2:if(void 0!==(i=h.v)){h.n=3;break}i=void 0,h.n=5;break;case 3:if(!j(i)){h.n=4;break}i=-i,h.n=5;break;case 4:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:i};case 5:return h.a(3,13);case 6:i=[],r=0;case 7:if(!(r<t.expressions.length)){h.n=10;break}return s=t.expressions[r],h.d(c(q(s,e,n)),8);case 8:void 0!==(o=h.v)&&("["===s.value?i.push(o):i=d.append(i,o));case 9:r++,h.n=7;break;case 10:return t.consarray&&Object.defineProperty(i,"cons",{enumerable:!1,configurable:!1,value:!0}),h.a(3,13);case 11:return h.d(c(ut(t,e,n)),12);case 12:return i=h.v,h.a(3,13);case 13:return h.a(2,i)}},g)}function Q(t,e,n){return d.lookup(e,t.value)}function K(t){return t.value}function tt(t,e){var n=R();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null===e||"object"!==r(e)||D(e)||p.keys(e).forEach(function(t){var i=e[t];Array.isArray(i)?(i=et(i),n=d.append(n,i)):n.push(i)}),n}function et(t,e){return void 0===e&&(e=[]),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){et(t,e)}):e.push(t),e}function nt(t,e){var n,i=R();return void 0!==e&&(it(e,i),n=1===i.length?i[0]:i),n}function it(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){it(t,e)}):null===t||"object"!==r(t)||D(t)||p.keys(t).forEach(function(n){it(t[n],e)})}function rt(t,e,n){var i;if(void 0!==t&&!j(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!j(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return i;switch(n){case"+":i=t+e;break;case"-":i=t-e;break;case"*":i=t*e;break;case"/":i=t/e;break;case"%":i=t%e}return i}function st(t,e,n){var i,s=r(t),o=r(e);if("undefined"===s||"undefined"===o)return!1;switch(n){case"=":i=U(t,e);break;case"!=":i=!U(t,e)}return i}function ot(t,e,n){var i,s=r(t),o=r(e);if("undefined"!==s&&"string"!==s&&"number"!==s||"undefined"!==o&&"string"!==o&&"number"!==o)throw{code:"T2010",stack:(new Error).stack,value:"string"!==s&&"number"!==s?t:e};if("undefined"!==s&&"undefined"!==o){if(s!==o)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function at(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var i=0;i<e.length;i++)if(e[i]===t){n=!0;break}return n}function ct(t,e,n){var i,r,s,o,a,l,u;return h().w(function(h){for(;;)switch(h.n){case 0:r=ht(t),s=n,h.n="and"===s?1:"or"===s?4:7;break;case 1:if(!(o=r)){h.n=3;break}return a=ht,h.d(c(e()),2);case 2:o=a(h.v);case 3:return i=o,h.a(3,7);case 4:if(l=r){h.n=6;break}return u=ht,h.d(c(e()),5);case 5:l=u(h.v);case 6:return i=l,h.a(3,7);case 7:return h.a(2,i)}},b)}function ht(t){var e=d.boolean(t);return void 0!==e&&e}function lt(t,e){var n="",i="";return void 0!==t&&(n=d.string(t)),void 0!==e&&(i=d.string(e)),n.concat(i)}function ut(t,e,n){var r,s,o,a,l,u,p,f,m,y,g,b,v,w,_;return h().w(function(h){for(;;)switch(h.n){case 0:r=Object.create(null),s=Object.create(null),o=!(!e||!e.tupleStream),Array.isArray(e)||(e=R(e)),0===e.length&&e.push(void 0),a=0;case 1:if(!(a<e.length)){h.n=10;break}l=e[a],u=o?V(n,l):n,p=0;case 2:if(!(p<t.lhs.length)){h.n=9;break}return f=t.lhs[p],h.d(c(q(f[0],o?l["@"]:l,u)),3);case 3:if("string"==typeof(m=h.v)||void 0===m){h.n=4;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:m};case 4:if(void 0===m){h.n=8;break}if("_jsonata_lambda"!==m&&"_jsonata_function"!==m){h.n=5;break}throw{code:"D1013",stack:(new Error).stack,position:t.position,value:m};case 5:if(y={data:l,exprIndex:p},!Object.prototype.hasOwnProperty.call(s,m)){h.n=7;break}if(s[m].exprIndex===p){h.n=6;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:m};case 6:s[m].data=d.append(s[m].data,l),h.n=8;break;case 7:s[m]=y;case 8:p++,h.n=2;break;case 9:a++,h.n=1;break;case 10:w=i(s);case 11:if((_=w()).done){h.n=13;break}return m=_.value,y=s[m],g=y.data,u=n,o&&(b=dt(y.data),g=b["@"],delete b["@"],u=V(n,b)),h.d(c(q(t.lhs[y.exprIndex][1],g,u)),12);case 12:void 0!==(v=h.v)&&(r[m]=v),h.n=11;break;case 13:return h.a(2,r)}},x)}function dt(t){if(!Array.isArray(t))return t;var e=Object.create(null);Object.assign(e,t[0]);for(var n=1;n<t.length;n++){var i,r=s(p.keys(t[n]));try{for(r.s();!(i=r.n()).done;){var o=i.value;e[o]=d.append(e[o],t[n][o])}}catch(t){r.e(t)}finally{r.f()}}return e}function pt(t,e){var n;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;if(t>e)return n;var i=e-t+1;if(i>1e7)throw{code:"D2014",stack:(new Error).stack,value:i};n=new Array(i);for(var r=t,s=0;r<=e;r++,s++)n[s]=r;return n.sequence=!0,n}function ft(t,e,n){var i;return h().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(q(t.rhs,e,n)),1);case 1:return i=r.v,n.bind(t.lhs.value,i),r.a(2,i)}},v)}function mt(t,e,n){var i,r;return h().w(function(s){for(;;)switch(s.n){case 0:return s.d(c(q(t.condition,e,n)),1);case 1:if(r=s.v,!d.boolean(r)){s.n=3;break}return s.d(c(q(t.then,e,n)),2);case 2:i=s.v,s.n=5;break;case 3:if(void 0===t.else){s.n=5;break}return s.d(c(q(t.else,e,n)),4);case 4:i=s.v;case 5:return s.a(2,i)}},w)}function yt(t,e,n){var i,r,s;return h().w(function(o){for(;;)switch(o.n){case 0:r=Dt(n),s=0;case 1:if(!(s<t.expressions.length)){o.n=4;break}return o.d(c(q(t.expressions[s],e,r)),2);case 2:i=o.v;case 3:s++,o.n=1;break;case 4:return o.a(2,i)}},_)}function gt(t){var e=new Bt.RegexEngine(t.value),n=function(i,r){var s;e.lastIndex=r||0;var o=e.exec(i);if(null!==o){if(s={match:o[0],start:o.index,end:o.index+o[0].length,groups:[]},o.length>1)for(var a=1;a<o.length;a++)s.groups.push(o[a]);s.next=function(){if(!(e.lastIndex>=i.length)){var r=n(i,e.lastIndex);if(r&&""===r.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return r}}}return s};return n}function bt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function xt(t,e,n){var i,s,o,a,l;return h().w(function(u){for(;;)switch(u.n){case 0:return s=e,o=!!e.tupleStream,a=h().m(function e(i,s){var a,l,u,d,p,f,m,y,g;return h().w(function(e){for(;;)switch(e.n){case 0:a=0,l=0;case 1:if(!(0===a&&l<t.terms.length)){e.n=11;break}return u=t.terms[l],d=i,p=n,o&&(d=i["@"],p=V(n,i)),e.d(c(q(u.expression,d,p)),2);case 2:return f=e.v,d=s,p=n,o&&(d=s["@"],p=V(n,s)),e.d(c(q(u.expression,d,p)),3);case 3:if(m=e.v,y=r(f),g=r(m),"undefined"!==y){e.n=4;break}return a="undefined"===g?0:1,e.a(3,10);case 4:if("undefined"!==g){e.n=5;break}return a=-1,e.a(3,10);case 5:if(!("string"!==y&&"number"!==y||"string"!==g&&"number"!==g)){e.n=6;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==y&&"number"!==y?f:m};case 6:if(y===g){e.n=7;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:f,value2:m};case 7:if(f!==m){e.n=8;break}return e.a(3,10);case 8:a=f<m?-1:1;case 9:!0===u.descending&&(a=-a);case 10:l++,e.n=1;break;case 11:return e.a(2,1===a)}},e)}),l={environment:n,input:e},u.d(c(d.sort.apply(l,[s,a])),1);case 1:return i=u.v,u.a(2,i)}},M)}function vt(t,e,n){return Ct(h().m(function e(i){var o,a,l,u,d,f,m,y,g,b,x,v,w;return h().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==i){e.n=1;break}return e.a(2,void 0);case 1:if(o=n.lookup("clone"),D(o)){e.n=2;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 2:return e.d(c(St(o,[i],null,n)),3);case 3:return a=e.v,e.d(c(q(t.pattern,a,n)),4);case 4:if(void 0===(l=e.v)){e.n=12;break}Array.isArray(l)||(l=[l]),u=0;case 5:if(!(u<l.length)){e.n=12;break}return d=l[u],e.d(c(q(t.update,d,n)),6);case 6:if(f=e.v,"undefined"===(m=r(f))){e.n=8;break}if("object"===m&&null!==f&&!Array.isArray(f)){e.n=7;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:f};case 7:y=s(p.keys(f));try{for(y.s();!(g=y.n()).done;)b=g.value,d[b]=f[b]}catch(t){y.e(t)}finally{y.f()}case 8:if(void 0===t.delete){e.n=11;break}return e.d(c(q(t.delete,d,n)),9);case 9:if(void 0===(x=e.v)){e.n=11;break}if(v=x,Array.isArray(x)||(x=[x]),P(x)){e.n=10;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:v};case 10:for(w=0;w<x.length;w++)"object"===r(d)&&null!==d&&delete d[x[w]];case 11:u++,e.n=5;break;case 12:return e.a(2,a)}},e)}),"<(oa):o>")}var wt=f("function($f, $g) { function($x){ $g($f($x)) } }");function _t(t,e,n){var i,r,s,o;return h().w(function(a){for(;;)switch(a.n){case 0:return a.d(c(q(t.lhs,e,n)),1);case 1:if(r=a.v,"function"!==t.rhs.type){a.n=3;break}return a.d(c(Mt(t.rhs,e,n,{context:r})),2);case 2:i=a.v,a.n=10;break;case 3:return a.d(c(q(t.rhs,e,n)),4);case 4:if(s=a.v,D(s)){a.n=5;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 5:if(!D(r)){a.n=8;break}return a.d(c(q(wt,null,n)),6);case 6:return o=a.v,a.d(c(St(o,[r,s],null,n)),7);case 7:i=a.v,a.n=10;break;case 8:return a.d(c(St(s,[r],null,n)),9);case 9:i=a.v;case 10:return a.a(2,i)}},S)}function Mt(t,e,n,i){var s,o,a,l,u,d,p;return h().w(function(f){for(;;)switch(f.p=f.n){case 0:return f.d(c(q(t.procedure,e,n)),1);case 1:if(void 0!==(o=f.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){f.n=2;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 2:a=[],void 0!==i&&a.push(i.context),l=h().m(function i(){var r,s;return h().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(q(t.arguments[u],e,n)),1);case 1:r=i.v,D(r)?(s=h().m(function t(){var e,i,s,o=arguments;return h().w(function(t){for(;;)switch(t.n){case 0:for(e=o.length,i=new Array(e),s=0;s<e;s++)i[s]=o[s];return t.d(c(St(r,i,null,n)),1);case 1:return t.a(2,t.v)}},t)}),s.arity=B(r),a.push(s)):a.push(r);case 2:return i.a(2)}},i)}),u=0;case 3:if(!(u<t.arguments.length)){f.n=5;break}return f.d(c(l()),4);case 4:u++,f.n=3;break;case 5:return d="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.p=6,"object"===r(o)&&(o.token=d,o.position=t.position),f.d(c(St(o,a,e,n)),7);case 7:s=f.v,f.n=9;break;case 8:throw f.p=8,(p=f.v).position||(p.position=t.position),p.token||(p.token=d),p;case 9:return f.a(2,s)}},k,null,[[6,8]])}function St(t,e,n,i){var r,s,o,a,l;return h().w(function(h){for(;;)switch(h.n){case 0:return h.d(c(kt(t,e,n,i)),1);case 1:r=h.v;case 2:if(!N(r)||!0!==r.thunk){h.n=9;break}return h.d(c(q(r.body.procedure,r.input,r.environment)),3);case 3:s=h.v,"variable"===r.body.procedure.type&&(s.token=r.body.procedure.value),s.position=r.body.procedure.position,o=[],a=0;case 4:if(!(a<r.body.arguments.length)){h.n=7;break}return l=o,h.d(c(q(r.body.arguments[a],r.input,r.environment)),5);case 5:l.push.call(l,h.v);case 6:a++,h.n=4;break;case 7:return h.d(c(kt(s,o,n,i)),8);case 8:r=h.v,h.n=2;break;case 9:return h.a(2,r)}},A)}function kt(t,e,n,i){var r,s,o,a;return h().w(function(h){for(;;)switch(h.p=h.n){case 0:if(h.p=0,s=e,t&&(s=Tt(t.signature,e,n)),!N(t)){h.n=2;break}return h.d(c(It(t,s)),1);case 1:r=h.v,h.n=9;break;case 2:if(!t||!0!==t._jsonata_function){h.n=5;break}if(o={environment:i,input:n},r=t.implementation.apply(o,s),!L(r)){h.n=4;break}return h.d(c(r),3);case 3:r=h.v;case 4:h.n=9;break;case 5:if("function"!=typeof t){h.n=8;break}if(r=t.apply(n,s),!L(r)){h.n=7;break}return h.d(c(r),6);case 6:r=h.v;case 7:h.n=9;break;case 8:throw{code:"T1006",stack:(new Error).stack};case 9:h.n=11;break;case 10:throw h.p=10,a=h.v,t&&(void 0===a.token&&void 0!==t.token&&(a.token=t.token),a.position=t.position||a.position),a;case 11:return h.a(2,r)}},z,null,[[0,10]])}function At(t,e,n){var i={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(i.thunk=!0),i.apply=h().m(function t(n,r){return h().w(function(t){for(;;)switch(t.n){case 0:return t.d(c(St(i,r,e,n.environment)),1);case 1:return t.a(2,t.v)}},t)}),i}function zt(t,e,n){var i,r,s,o,a,l;return h().w(function(h){for(;;)switch(h.n){case 0:r=[],s=0;case 1:if(!(s<t.arguments.length)){h.n=5;break}if("operator"!==(o=t.arguments[s]).type||"?"!==o.value){h.n=2;break}r.push(o),h.n=4;break;case 2:return l=r,h.d(c(q(o,e,n)),3);case 3:l.push.call(l,h.v);case 4:s++,h.n=1;break;case 5:return h.d(c(q(t.procedure,e,n)),6);case 6:if(void 0!==(a=h.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){h.n=7;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 7:if(!N(a)){h.n=8;break}i=Ot(a,r),h.n=11;break;case 8:if(!a||!0!==a._jsonata_function){h.n=9;break}i=Et(a.implementation,r),h.n=11;break;case 9:if("function"!=typeof a){h.n=10;break}i=Et(a,r),h.n=11;break;case 10:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 11:return h.a(2,i)}},T)}function Tt(t,e,n){return void 0===t?e:t.validate(e,n)}function It(t,e){var n,i;return h().w(function(r){for(;;)switch(r.n){case 0:if(i=Dt(t.environment),Array.prototype.forEach.call(t.arguments,function(t,n){i.bind(t.value,e[n])}),"function"!=typeof t.body){r.n=2;break}return r.d(c(jt(t.body,i)),1);case 1:n=r.v,r.n=4;break;case 2:return r.d(c(q(t.body,t.input,i)),3);case 3:n=r.v;case 4:return r.a(2,n)}},I)}function Ot(t,e){var n=Dt(t.environment),i=[];return Array.prototype.forEach.call(t.arguments,function(t,r){var s=e[r];s&&"operator"===s.type&&"?"===s.value?i.push(t):n.bind(t.value,s)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:i,body:t.body}}function Et(t,e){var n=Pt(t),i="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",r=f(i);return r.body=t,Ot(r,e)}function jt(t,e){var n,i,r,s;return h().w(function(o){for(;;)switch(o.n){case 0:if(n=Pt(t),i=n.map(function(t){return e.lookup(t.trim())}),r={environment:e},s=t.apply(r,i),!L(s)){o.n=2;break}return o.d(c(s),1);case 1:s=o.v;case 2:return o.a(2,s)}},O)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Ct(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=m(e)),n}function Rt(t,e){var n,i,r,s,o;return h().w(function(a){for(;;)switch(a.p=a.n){case 0:if(void 0!==t){a.n=1;break}return a.a(2,void 0);case 1:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!F(n)&&((n=R(n)).outerWrapper=!0)),a.p=2,i=f(t,!1),a.n=4;break;case 3:throw a.p=3,Lt(s=a.v),{stack:(new Error).stack,code:"D3120",value:s.message,error:s};case 4:return a.p=4,a.d(c(q(i,n,this.environment)),5);case 5:r=a.v,a.n=7;break;case 6:throw a.p=6,Lt(o=a.v),{stack:(new Error).stack,code:"D3121",value:o.message,error:o};case 7:return a.a(2,r)}},E,this,[[4,6],[2,3]])}function Ft(t){if(void 0!==t)return JSON.parse(d.string(t))}function Dt(t){var e=Object.create(null);return{bind:function(t,n){e[t]=n},lookup:function(n){var i;return Object.prototype.hasOwnProperty.call(e,n)?i=e[n]:t&&(i=t.lookup(n)),i},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}W.bind("sum",Ct(d.sum,"<a<n>:n>")),W.bind("count",Ct(d.count,"<a:n>")),W.bind("max",Ct(d.max,"<a<n>:n>")),W.bind("min",Ct(d.min,"<a<n>:n>")),W.bind("average",Ct(d.average,"<a<n>:n>")),W.bind("string",Ct(d.string,"<x-b?:s>")),W.bind("substring",Ct(d.substring,"<s-nn?:s>")),W.bind("substringBefore",Ct(d.substringBefore,"<s-s:s>")),W.bind("substringAfter",Ct(d.substringAfter,"<s-s:s>")),W.bind("lowercase",Ct(d.lowercase,"<s-:s>")),W.bind("uppercase",Ct(d.uppercase,"<s-:s>")),W.bind("length",Ct(d.length,"<s-:n>")),W.bind("trim",Ct(d.trim,"<s-:s>")),W.bind("pad",Ct(d.pad,"<s-ns?:s>")),W.bind("match",Ct(d.match,"<s-f<s:o>n?:a<o>>")),W.bind("contains",Ct(d.contains,"<s-(sf):b>")),W.bind("replace",Ct(d.replace,"<s-(sf)(sf)n?:s>")),W.bind("split",Ct(d.split,"<s-(sf)n?:a<s>>")),W.bind("join",Ct(d.join,"<a<s>s?:s>")),W.bind("formatNumber",Ct(d.formatNumber,"<n-so?:s>")),W.bind("formatBase",Ct(d.formatBase,"<n-n?:s>")),W.bind("formatInteger",Ct(u.formatInteger,"<n-s:s>")),W.bind("parseInteger",Ct(u.parseInteger,"<s-s:n>")),W.bind("number",Ct(d.number,"<(nsb)-:n>")),W.bind("floor",Ct(d.floor,"<n-:n>")),W.bind("ceil",Ct(d.ceil,"<n-:n>")),W.bind("round",Ct(d.round,"<n-n?:n>")),W.bind("abs",Ct(d.abs,"<n-:n>")),W.bind("sqrt",Ct(d.sqrt,"<n-:n>")),W.bind("power",Ct(d.power,"<n-n:n>")),W.bind("random",Ct(d.random,"<:n>")),W.bind("boolean",Ct(d.boolean,"<x-:b>")),W.bind("not",Ct(d.not,"<x-:b>")),W.bind("map",Ct(d.map,"<af>")),W.bind("zip",Ct(d.zip,"<a+>")),W.bind("filter",Ct(d.filter,"<af>")),W.bind("single",Ct(d.single,"<af?>")),W.bind("reduce",Ct(d.foldLeft,"<afj?:j>")),W.bind("sift",Ct(d.sift,"<o-f?:o>")),W.bind("keys",Ct(d.keys,"<x-:a<s>>")),W.bind("lookup",Ct(d.lookup,"<x-s:x>")),W.bind("append",Ct(d.append,"<xx:a>")),W.bind("exists",Ct(d.exists,"<x:b>")),W.bind("spread",Ct(d.spread,"<x-:a<o>>")),W.bind("merge",Ct(d.merge,"<a<o>:o>")),W.bind("reverse",Ct(d.reverse,"<a:a>")),W.bind("each",Ct(d.each,"<o-f:a>")),W.bind("error",Ct(d.error,"<s?:x>")),W.bind("assert",Ct(d.assert,"<bs?:x>")),W.bind("type",Ct(d.type,"<x:s>")),W.bind("sort",Ct(d.sort,"<af?:a>")),W.bind("shuffle",Ct(d.shuffle,"<a:a>")),W.bind("distinct",Ct(d.distinct,"<x:x>")),W.bind("base64encode",Ct(d.base64encode,"<s-:s>")),W.bind("base64decode",Ct(d.base64decode,"<s-:s>")),W.bind("encodeUrlComponent",Ct(d.encodeUrlComponent,"<s-:s>")),W.bind("encodeUrl",Ct(d.encodeUrl,"<s-:s>")),W.bind("decodeUrlComponent",Ct(d.decodeUrlComponent,"<s-:s>")),W.bind("decodeUrl",Ct(d.decodeUrl,"<s-:s>")),W.bind("eval",Ct(Rt,"<sx?:x>")),W.bind("toMillis",Ct(u.toMillis,"<s-s?:n>")),W.bind("fromMillis",Ct(u.fromMillis,"<n-s?s?:s>")),W.bind("clone",Ct(Ft,"<(oa)-:o>"));var Nt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1013:"Object property names starting with _jsonata_ are reserved for internal use: {{value}}",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Lt(t){var e=Nt[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function Bt(t,e){var n,i;try{n=f(t,e&&e.recover),i=n.errors,delete n.errors}catch(t){throw Lt(t),t}var r=Dt(W),o=new Date;return r.bind("now",Ct(function(t,e){return u.fromMillis(o.getTime(),t,e)},"<s?s?:s>")),r.bind("millis",Ct(function(){return o.getTime()},"<:n>")),e&&e.RegexEngine?Bt.RegexEngine=e.RegexEngine:Bt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==i){var c={code:"S0500",position:0};throw Lt(c),c}if(void 0!==e){var h;h=Dt(r);var l,u=s(p.keys(e));try{for(u.s();!(l=u.n()).done;){var d=l.value;h.bind(d,e[d])}}catch(c){u.e(c)}finally{u.f()}}else h=r;var f,m;if(h.bind("$",t),o=new Date,h.timestamp=o,Array.isArray(t)&&!F(t)&&((t=R(t)).outerWrapper=!0),"function"==typeof a){h.async=!0;var y=function(t){Lt(t),a(t,null)},g=function(t){(f=m.next(t)).done?a(null,f.value):f.value.then(g).catch(y)};m=q(n,t,h),(f=m.next()).value.then(g).catch(y)}else try{for(m=q(n,t,h),f=m.next();!f.done;)f=m.next(f.value);return f.value}catch(c){throw Lt(c),c}},assign:function(t,e){r.bind(t,e)},registerFunction:function(t,e,n){var i=Ct(e,n);r.bind(t,i)},ast:function(){return n},errors:function(){return i}}}return Bt.parser=f,Bt}();e.exports=y},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var i=t("./signature"),r=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},n=function(n){var i=0,r=n.length,s=function(t,e){return{type:t,value:e,position:i}},o=function(){for(var t,e,s=i,o=0;i<r;){var a=n.charAt(i);if("/"===a&&"\\"!==n.charAt(i-1)&&0===o){if(""===(t=n.substring(s,i)))throw{code:"S0301",stack:(new Error).stack,position:i};for(i++,a=n.charAt(i),s=i;"i"===a||"m"===a;)i++,a=n.charAt(i);return e=n.substring(s,i)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(i-1)||o++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(i-1)||o--,i++}throw{code:"S0302",stack:(new Error).stack,position:i}},a=function(c){if(i>=r)return null;for(var h=n.charAt(i);i<r&&" \t\n\r\v".indexOf(h)>-1;)i++,h=n.charAt(i);if("/"===h&&"*"===n.charAt(i+1)){var l=i;for(i+=2,h=n.charAt(i);"*"!==h||"/"!==n.charAt(i+1);)if(h=n.charAt(++i),i>=r)throw{code:"S0106",stack:(new Error).stack,position:l};return i+=2,h=n.charAt(i),a(c)}if(!0!==c&&"/"===h)return i++,s("regex",o());if("."===h&&"."===n.charAt(i+1))return i+=2,s("operator","..");if(":"===h&&"="===n.charAt(i+1))return i+=2,s("operator",":=");if("!"===h&&"="===n.charAt(i+1))return i+=2,s("operator","!=");if(">"===h&&"="===n.charAt(i+1))return i+=2,s("operator",">=");if("<"===h&&"="===n.charAt(i+1))return i+=2,s("operator","<=");if("*"===h&&"*"===n.charAt(i+1))return i+=2,s("operator","**");if("~"===h&&">"===n.charAt(i+1))return i+=2,s("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return i++,s("operator",h);if('"'===h||"'"===h){var u=h;i++;for(var d="";i<r;){if("\\"===(h=n.charAt(i)))if(i++,h=n.charAt(i),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:i,token:h};var p=n.substr(i+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:i};var f=parseInt(p,16);d+=String.fromCharCode(f),i+=4}else{if(h===u)return i++,s("string",d);d+=h}i++}throw{code:"S0101",stack:(new Error).stack,position:i}}var m,y=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(i));if(null!==y){var g=parseFloat(y[0]);if(!isNaN(g)&&isFinite(g))return i+=y[0].length,s("number",g);throw{code:"S0102",stack:(new Error).stack,position:i,token:y[0]}}if("`"===h){i++;var b=n.indexOf("`",i);if(-1!==b)return m=n.substring(i,b),i=b+1,s("name",m);throw i=r,{code:"S0105",stack:(new Error).stack,position:i}}for(var x,v=i;;)if(x=n.charAt(v),v===r||" \t\n\r\v".indexOf(x)>-1||Object.prototype.hasOwnProperty.call(t,x)){if("$"===n.charAt(i))return m=n.substring(i+1,v),i=v,s("variable",m);switch(m=n.substring(i,v),i=v,m){case"or":case"in":case"and":return s("operator",m);case"true":return s("value",!0);case"false":return s("value",!1);case"null":return s("value",null);default:return i===r&&""===m?null:s("name",m)}}else v++};return a},r=function(e,r){var s,o,a=Object.create(null),c=[],h=function(){var t=[];"(end)"!==s.id&&t.push({type:s.type,value:s.value,position:s.position});for(var e=o();null!==e;)t.push(e),e=o();return t},l={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(r)return t.remaining=h(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(l)).id=n.value=t,n.lbp=e,a[t]=n),n},d=function(t){if(r){t.remaining=h(),c.push(t);var e=a["(error)"];return(s=Object.create(e)).error=t,s.type="(error)",s}throw t.stack=(new Error).stack,t},p=function(t,n){if(t&&s.id!==t){var i={code:"(end)"===s.id?"S0203":"S0202",position:s.position,token:s.value,value:t};return d(i)}var r=o(n);if(null===r)return(s=a["(end)"]).position=e.length,s;var c,h=r.value,l=r.type;switch(l){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[h]))return d({code:"S0204",stack:(new Error).stack,position:r.position,token:h});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":l="regex",c=a["(regex)"];break;default:return d({code:"S0205",stack:(new Error).stack,position:r.position,token:h})}return(s=Object.create(c)).value=h,s.type=l,s.position=r.position,s},f=function(t){var e,n=s;for(p(null,!0),e=n.nud();t<s.lbp;)n=s,p(),e=n.led(e);return e},m=function(t){u(t,0).nud=function(){return this}},y=function(e,n,i){var r=n||t[e],s=u(e,r);return s.led=i||function(t){return this.lhs=t,this.rhs=f(r),this.type="binary",this},s},g=function(t,e,n){var i=u(t,e);return i.led=n,i},b=function(t,e){var n=u(t);return n.nud=e||function(){return this.expression=f(70),this.type="unary",this},n};m("(end)"),m("(name)"),m("(literal)"),m("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),y("."),y("+"),y("-"),y("*"),y("/"),y("%"),y("="),y("<"),y(">"),y("!="),y("<="),y(">="),y("&"),y("and"),y("or"),y("in"),m("and"),m("or"),m("in"),b("-"),y("~>"),g("(error)",10,function(t){return this.lhs=t,this.error=s.error,this.remaining=h(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),y("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==s.id)for(;"operator"===s.type&&"?"===s.id?(this.type="partial",this.arguments.push(s),p("?")):this.arguments.push(f(0)),","===s.id;)p(",");if(p(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach(function(t,e){if("variable"!==t.type)return d({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===s.id){for(var e=s.position,n=1,r="<";n>0&&"{"!==s.id&&"(end)"!==s.id;){var o=p();">"===o.id?n--:"<"===o.id&&n++,r+=o.value}p(">");try{this.signature=i(r)}catch(t){return t.position=e+t.offset,d(t)}}p("{"),this.body=f(0),p("}")}return this}),b("(",function(){for(var t=[];")"!==s.id&&(t.push(f(0)),";"===s.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==s.id)for(;;){var e=f(0);if(".."===s.id){var n={type:"binary",value:"..",position:s.position,lhs:e};p(".."),n.rhs=f(0),e=n}if(t.push(e),","!==s.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this}),y("[",t["["],function(e){if("]"===s.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this}),y("^",t["^"],function(t){p("(");for(var e=[];;){var n={descending:!1};if("<"===s.id?p("<"):">"===s.id&&(n.descending=!0,p(">")),n.expression=f(0),e.push(n),","!==s.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var x=function(t){var e=[];if("}"!==s.id)for(;;){var n=f(0);p(":");var i=f(0);if(e.push([n,i]),","!==s.id)break;p(",")}return p("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};b("{",x),y("{",t["{"],x),g(":=",t[":="],function(e){return"variable"!==e.type?d({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)}),y("@",t["@"],function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),y("#",t["#"],function(e){return this.lhs=e,this.rhs=f(t["#"]),"variable"!==this.rhs.type?d({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),y("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=f(0),":"===s.id&&(p(":"),this.else=f(0)),this}),b("|",function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===s.id&&(p(","),this.delete=f(0)),p("|"),this});var v=function(t){var e;if("function"!==t.type||t.predicate)if("condition"===t.type)t.then=v(t.then),void 0!==t.else&&(t.else=v(t.else)),e=t;else if("block"===t.type){var n=t.expressions.length;n>0&&(t.expressions[n-1]=v(t.expressions[n-1])),e=t}else e=t;else{var i={type:"lambda",thunk:!0,arguments:[],position:t.position};i.body=t,e=i}return e},w=0,_=0,M=[],S=function(t,e){switch(t.type){case"name":case"wildcard":e.level--,0===e.level&&(void 0===t.ancestor||(M[e.index].slot.label=t.ancestor.label),t.ancestor=e,t.tuple=!0);break;case"parent":e.level++;break;case"block":t.expressions.length>0&&(t.tuple=!0,e=S(t.expressions[t.expressions.length-1],e));break;case"path":t.tuple=!0;var n=t.steps.length-1;for(e=S(t.steps[n--],e);e.level>0&&n>=0;)e=S(t.steps[n--],e);break;default:throw{code:"S0217",token:t.type,position:t.position}}return e},k=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},A=function(t){var e=t.steps.length-1,n=t.steps[e],i=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&i.push(n.slot);for(var r=0;r<i.length;r++){var s=i[r];for(e=t.steps.length-2;s.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[s]:t.seekingParent.push(s);break}for(var o=t.steps[e--];e>=0&&o.focus&&t.steps[e].focus;)o=t.steps[e--];s=S(o,s)}}},z=function(t){var e;switch(t.type){case"binary":switch(t.value){case".":var n=z(t.lhs);e="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(e.seekingParent=[n.slot]);var i=z(t.rhs);"function"===i.type&&"path"===i.procedure.type&&1===i.procedure.steps.length&&"name"===i.procedure.steps[0].type&&"function"===e.steps[e.steps.length-1].type&&(e.steps[e.steps.length-1].nextFunction=i.procedure.steps[0].value),"path"===i.type?Array.prototype.push.apply(e.steps,i.steps):(void 0!==i.predicate&&(i.stages=i.predicate,delete i.predicate),e.steps.push(i)),e.steps.filter(function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type}).forEach(function(t){t.type="name"}),e.steps.filter(function(t){return!0===t.keepArray}).length>0&&(e.keepSingletonArray=!0);var s=e.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var o=e.steps[e.steps.length-1];"unary"===o.type&&"["===o.value&&(o.consarray=!0),A(e);break;case"[":var a=e=z(t.lhs),h="predicate";if("path"===e.type&&(a=e.steps[e.steps.length-1],h="stages"),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:t.position};void 0===a[h]&&(a[h]=[]);var l=z(t.rhs);void 0!==l.seekingParent&&(l.seekingParent.forEach(function(t){1===t.level?S(a,t):t.level--}),k(a,l)),a[h].push({type:"filter",expr:l,position:t.position});break;case"{":if(void 0!==(e=z(t.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:t.position};e.group={lhs:t.rhs.map(function(t){return[z(t[0]),z(t[1])]}),position:t.position};break;case"^":"path"!==(e=z(t.lhs)).type&&(e={type:"path",steps:[e]});var u={type:"sort",position:t.position};u.terms=t.rhs.map(function(t){var e=z(t.expression);return k(u,e),{descending:t.descending,expression:e}}),e.steps.push(u),A(e);break;case":=":(e={type:"bind",value:t.value,position:t.position}).lhs=z(t.lhs),e.rhs=z(t.rhs),k(e,e.rhs);break;case"@":if(e=z(t.lhs),a=e,"path"===e.type&&(a=e.steps[e.steps.length-1]),void 0!==a.stages||void 0!==a.predicate)throw{code:"S0215",stack:(new Error).stack,position:t.position};if("sort"===a.type)throw{code:"S0216",stack:(new Error).stack,position:t.position};t.keepArray&&(a.keepArray=!0),a.focus=t.rhs.value,a.tuple=!0;break;case"#":e=z(t.lhs),a=e,"path"===e.type?a=e.steps[e.steps.length-1]:(e={type:"path",steps:[e]},void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate)),void 0===a.stages?a.index=t.rhs.value:a.stages.push({type:"index",value:t.rhs.value,position:t.position}),a.tuple=!0;break;case"~>":(e={type:"apply",value:t.value,position:t.position}).lhs=z(t.lhs),e.rhs=z(t.rhs);break;default:(e={type:t.type,value:t.value,position:t.position}).lhs=z(t.lhs),e.rhs=z(t.rhs),k(e,e.lhs),k(e,e.rhs)}break;case"unary":e={type:t.type,value:t.value,position:t.position},"["===t.value?e.expressions=t.expressions.map(function(t){var n=z(t);return k(e,n),n}):"{"===t.value?e.lhs=t.lhs.map(function(t){var n=z(t[0]);k(e,n);var i=z(t[1]);return k(e,i),[n,i]}):(e.expression=z(t.expression),"-"===t.value&&"number"===e.expression.type?(e=e.expression).value=-e.value:k(e,e.expression));break;case"function":case"partial":(e={type:t.type,name:t.name,value:t.value,position:t.position}).arguments=t.arguments.map(function(t){var n=z(t);return k(e,n),n}),e.procedure=z(t.procedure);break;case"lambda":e={type:t.type,arguments:t.arguments,signature:t.signature,position:t.position};var d=z(t.body);e.body=v(d);break;case"condition":(e={type:t.type,position:t.position}).condition=z(t.condition),k(e,e.condition),e.then=z(t.then),k(e,e.then),void 0!==t.else&&(e.else=z(t.else),k(e,e.else));break;case"transform":(e={type:t.type,position:t.position}).pattern=z(t.pattern),e.update=z(t.update),void 0!==t.delete&&(e.delete=z(t.delete));break;case"block":(e={type:t.type,position:t.position}).expressions=t.expressions.map(function(t){var n=z(t);return k(e,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(e.consarray=!0),n});break;case"name":e={type:"path",steps:[t]},t.keepArray&&(e.keepSingletonArray=!0);break;case"parent":e={type:"parent",slot:{label:"!"+w++,level:1,index:_++}},M.push(e);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":e=t;break;case"operator":if("and"===t.value||"or"===t.value||"in"===t.value)t.type="name",e=z(t);else{if("?"!==t.value)throw{code:"S0201",stack:(new Error).stack,position:t.position,token:t.value};e=t}break;case"error":e=t,t.lhs&&(e=z(t.lhs));break;default:var p="S0206";"(end)"===t.id&&(p="S0207");var f={code:p,position:t.position,token:t.value};if(r)return c.push(f),{type:"error",error:f};throw f.stack=(new Error).stack,f}return t.keepArray&&(e.keepArray=!0),e};o=n(e),p();var T=f(0);if("(end)"!==s.id){var I={code:"S0201",position:s.position,token:s.value};d(I)}if("parent"===(T=z(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return c.length>0&&(T.errors=c),T};return r}();e.exports=r},{"./signature":5}],5:[function(t,e,n){function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}var r=t("./utils"),s=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,s=[],o=Object.create(null),a=o;n<e.length;){var c=e.charAt(n);if(":"===c)break;var h=function(){s.push(o),a=o,o=Object.create(null)},l=function(t,e,n,i){for(var r=1,s=e;s<t.length;)if(s++,(c=t.charAt(s))===i){if(0===--r)break}else c===n&&r++;return s};switch(c){case"s":case"n":case"b":case"l":case"o":o.regex="["+c+"m]",o.type=c,h();break;case"a":o.regex="[asnblfom]",o.type=c,o.array=!0,h();break;case"f":o.regex="f",o.type=c,h();break;case"j":o.regex="[asnblom]",o.type=c,h();break;case"x":o.regex="[asnblfom]",o.type=c,h();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var u=l(e,n,"(",")"),d=e.substring(n+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:n};o.regex="["+d+"m]",o.type="("+d+")",n=u,h();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var p=l(e,n,"<",">");a.subtype=e.substring(n+1,p),n=p}n++}var f="^"+s.map(function(t){return"("+t.regex+")"}).join("")+"$",m=new RegExp(f),y=function(t){var e;if(r.isFunction(t))e="f";else switch(i(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},g=function(t,e){for(var n="^",i=0,r=0;r<s.length;r++){n+=s[r].regex;var o=e.match(n);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1};i=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1}};return{definition:e,validate:function(e,n){var i="";e.forEach(function(t){i+=y(t)});var r=m.exec(i);if(r){var o=[],a=0;return s.forEach(function(i,s){var c=e[a],h=r[s+1];if(""===h)if(i.context&&i.contextRegex){var l=y(n);if(!i.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};o.push(n)}else o.push(c),a++;else h.split("").forEach(function(n){if("a"===i.type){if("m"===n)c=void 0;else{c=e[a];var r=!0;if(void 0!==i.subtype)if("a"!==n&&h!==i.subtype)r=!1;else if("a"===n&&c.length>0){var s=y(c[0]);r=s===i.subtype.charAt(0)&&0===c.filter(function(t){return y(t)!==s}).length}if(!r)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[i.subtype]};"a"!==n&&(c=[c])}o.push(c),a++}else o.push(c),a++})}),o}g(e,i)}}}return e}();e.exports=s},{"./utils":6}],6:[function(t,e,n){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter(function(t){return"string"!=typeof t}).length),e}function n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function r(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function s(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function h(t){return t&&!0===t._jsonata_lambda}var l=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function u(t){return"object"===o(t)&&null!==t&&l in t&&"next"in t&&"function"==typeof t.next}function d(t,e){if(t===e)return!0;if("object"===o(t)&&"object"===o(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!d(t[n],e[n]))return!1;return!0}var i=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(i.length!==r.length)return!1;for(i=i.sort(),r=r.sort(),n=0;n<i.length;n++)if(i[n]!==r[n])return!1;for(n=0;n<i.length;n++){var s=i[n];if(!d(t[s],e[s]))return!1}return!0}return!1}function p(t){var e,n=[],r=i(t);try{for(r.s();!(e=r.n()).done;){var s=e.value;n.push(s)}}catch(t){r.e(t)}finally{r.f()}return n}function f(t){return"object"===o(t)&&null!==t?Object.keys(t):[]}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:r,isSequence:s,isFunction:a,isLambda:h,isIterable:u,getFunctionArity:c,isDeepEqual:d,stringToArray:p,keys:f}}();e.exports=a},{}]},{},[3])(3)}(Ta)),Ta.exports),Oa=ka(Ia);const Ea=function(t){return t};function ja(t){if(!t)return Ea;try{const e=Oa(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return wa(t),Ea}}function Pa(t,e){if(!e)return;const n=Ho(t),i=null==n?"":String(n);return Object.prototype.hasOwnProperty.call(e,i)?e[i]:e.default}const Ca=t=>null==t||""===t?void 0:parseFloat(String(t));function Ra(t,e,n){for(const n of e)if(void 0!==n.value&&n.value===t)return n.result;const i=Ho(t);if(null==i)return n;const r=Number(i);if(Number.isNaN(r))return n;for(const t of e){const e=Ca(t.min),n=Ca(t.max);if((void 0!==e||void 0!==n)&&(r>=(e??-1/0)&&r<(n??1/0)))return t.result}return n}function Fa(t){return Number(Ho(t))}function Da(t){return t}function Na(t){return function(t){const e=Ho(t);return null==e?"":String(e)}(t)}function La(t){return Fa(t)}function Ba(t){return Pa(t,this.param)}function Ua(t){const{param:e}=this;if(!e)return;return Ra(t,Object.keys(e).filter(t=>"default"!==t).map(t=>{const[n,i]=t.split("~");return{min:""===n?null:n,max:void 0===i||""===i?null:i,result:e[t]}}),e.default)}function Wa(t){const{param:e}=this;if(!e)return;const n=Number(e.scale??1),i=Number(e.offset??0);return Fa(t)*n+i}function qa(t){return Fa(t)*Math.PI/180}function $a(){}const Va=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const Ya=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],Ha=new Array(Ya.length).fill(void 0),Ga=Object.getPrototypeOf(async function(){}).constructor;function Xa(t,e){!function(t){for(const e of Va)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const n=function(t){return/\bawait\b/.test(t)}(t),i=new(n?Ga:Function)(...e,...Ya,t);return function(t,...e){return i.call(t,...e,...Ha)}}function Za(t,e,n,i,r){switch(n){case"value":return"text"===r||"string"===r?Na.bind(t):"number"===r?La.bind(t):Da.bind(e);case"map":return Ba.bind(t);case"range":return Ua.bind(t);case"scale":return Wa.bind(t);case"radian":return qa.bind(t);case"eval":return function(t){try{const e=Xa(t,["value","targets","scene"]);return function(t,n){try{const i=e(this,t,n,globalThis.scene);return i&&"function"==typeof i.then?i.catch(t=>{wa(t)}):i}catch(t){return void wa(t)}}}catch(t){return wa(t),$a}}(i).bind(e);default:return Da.bind(e)}}class Ja{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:i,param:r,accessor:s}=t;this._model=t,this.evaluator=Za(this,this.owner,i,r,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=ja(s);const o=e.match(/\[(.*?)\]/);if(o){const[t,e]=o[1].split(":");this.propAccessor=ja(t),this.partAccessor=ja(e)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function Qa(t,e,n,i){const r=e.split(".");if(1===r.length)return void(t[e]=i?{...t[e],...n}:n);const s=r[0],o=void 0!==t[s]?t[s]:"function"==typeof t.get?t.get(s):void 0,a=o?{...o}:{};let c=a;for(let t=1;t<r.length-1;t++)c[r[t]]=c[r[t]]?{...c[r[t]]}:{},c=c[r[t]];const h=r[r.length-1];c[h]=i?{...c[h],...n}:n,t[s]=a}function Ka(t,e,n,i){t.forEach(t=>Qa(t,e,n,i))}function tc(t,e,n,i){t&&"function"==typeof t.then?t.then(t=>{void 0!==n&&void 0!==i&&n._dataGeneration!==i||e(t)}).catch(t=>wa(t)):e(t)}function ec(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,n=this;this.mappings&&this.mappings.forEach(t=>{try{let i,{source:r,target:s,property:o,accessor:a,propAccessor:c,partAccessor:h,ndnsp:l=!1,partial:u=!1}=t;s=(s||"(self)").trim(),t.rule||(t.rule="value"),r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),i=this.root.findById(r)?.data||{}):i=this.data;const d=a(i);if("(root)"==s||"(key)"==s){if(null==d)return;const i=Object.keys(d||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();i.length>0&&i.forEach(i=>{tc(t.evaluator(d[i.get("id")],[i]),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Qa(i,o,t,u)},n,e)})}else if(s.startsWith("[")){if(null==d)return;if(d instanceof Array)d.forEach(i=>{const r=c(i);if(r){const s=this.root.findOrCreate(r);s&&tc(t.evaluator(h(i),s),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ka(s,o,t,u)},n,e)}});else{if(!(d instanceof Object))throw String("mapping data should be an object to target property-id.("+d+")");{const i=c(d);if(i){const r=this.root.findOrCreate(i);r&&tc(t.evaluator(h(d),r),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ka(r,o,t,u)},n,e)}}}}else{const i=this.root.findAll(s,this);i.length>0&&tc(t.evaluator(d,i),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ka(i,o,t,u)},n,e)}}catch(e){wa(e,this,t)}})}function nc(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),ec.call(this,!0)}function ic(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new Ja({target:"(self)",rule:"value",...t},this))):(wa("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function rc(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function sc(t,e){this.disposeMappings(),ec.call(this)}function oc(t,e,n,i,r,s){e.complete?t.drawImage(e,n,i,r,s):e.addEventListener("load",()=>{this.invalidate()})}function ac(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const cc="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),hc={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},lc=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";hc.FONT_FAMILY=e||n};let uc;function dc(t,e,n,i,r){const{alpha:s=1}=i,o=r.fillStyle;if(t.globalAlpha*=s,o)if("string"==typeof o)t.fillStyle=o,t.fill();else if("object"==typeof o)if("gradient"==o.type){t.translate(n.x,n.y);let i,{width:r,height:s}=e;if("linear"==o.gradientType){const e=3.141592653589793,n="number"==typeof o.rotation&&Number.isFinite(o.rotation)?o.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let o=Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));o-=o-(r+s)/3,i=t.createLinearGradient(o*Math.cos(n+e),o*Math.sin(n+e),o*Math.cos(n),o*Math.sin(n))}else i=t.createLinearGradient((r-4)/2*Math.cos(n+e),(s-4)/2*Math.sin(n+e),(r-4)/2*Math.cos(n),(s-4)/2*Math.sin(n))}else if("radial"==o.gradientType){const e=.95*Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));switch(o.center){case"center":default:i=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":i=t.createRadialGradient(-r/2,-s/2,0,-r/2,-s/2,2*e);break;case"right-top":i=t.createRadialGradient(r/2,-s/2,0,r/2,-s/2,2*e);break;case"left-bottom":i=t.createRadialGradient(-r/2,s/2,0,-r/2,s/2,2*e);break;case"right-bottom":i=t.createRadialGradient(r/2,s/2,0,r/2,s/2,2*e)}}(Array.isArray(o.colorStops)?o.colorStops:Array.isArray(o.gradientStops)?o.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{i.addColorStop(t.position,t.color)}catch(e){_a("Invalid Color for colorstop : ",t.color),i.addColorStop(t.position,"#fff")}}),t.fillStyle=i,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==o.type&&o.image)if(o.guideOnly&&1!=r.app.mode)o.color&&(t.fillStyle=o.color,t.fill());else{r.prepareFillIf(!r._pattern_image_origin);const n=r._pattern_image;if(!n||!n.width||!n.height)return;let i=0,s=0,a=0,c=0,h=e.left,l=e.top;if(!o.fitPattern){i=o.offsetX,s=o.offsetY;const t=o.width?o.width:n.width,r=o.height?o.height:n.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-r/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-r;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-r;break;case"left":a=0,c=e.height/2-r/2;break;case"right":a=e.width-t,c=e.height/2-r/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-r}h+=i+a,l+=s+c}t.translate(h,l),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete r._pattern_image,delete r._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-l)}}function pc(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const i=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return i._pattern_image=i._pattern_image_origin,void t(this);let e=n.width||this.width,r=n.height||this.height;n.fitPattern&&(e=i.bounds.width,r=i.bounds.height);const s=uc(e,r);s.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,r),i._pattern_image=s,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(n.image)}catch(t){e(t)}}function fc(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{wa(t)})}function mc(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function yc(t,e,n){let{strokeStyle:i,lineDash:r,lineWidth:s,lineCap:o,lineJoin:a,alpha:c}=e;if(i&&0!=s){if(o&&(t.lineCap=o),r){const e="round"==o;switch(r){case"solid":r=[0,0];break;case"round-dot":r=e?[0,2*s]:[s,s];break;case"square-dot":r=e?[s,2*s]:[2*s,s];break;case"dash":r=e?[3*s,2.5*s]:[4*s,1.5*s];break;case"dash-dot":r=e?[3*s,3*s,0,3*s]:[4*s,2*s,s,2*s];break;case"long-dash":r=e?[5*s,4*s]:[6*s,3*s];break;case"long-dash-dot":r=e?[5*s,3*s,0,3*s]:[6*s,2*s,s,2*s];break;case"long-dash-dot-dot":r=e?[5*s,2*s,0,2*s,0,2*s]:[6*s,s,s,s,s,s]}Array.isArray(r)||(r=[]),t.setLineDash(r)}t.globalAlpha*=c,t.strokeStyle=i,t.lineWidth=s,t.lineJoin=a,t.stroke()}}function gc(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let i;for(;null!==(i=e.exec(t));)i[1]?n.push({text:i[2],bold:!0,italic:!1}):i[3]?n.push({text:i[4],bold:!1,italic:!0}):i[5]&&n.push({text:i[5],bold:!1,italic:!1});return n}function bc(t,e,n,i=0){if(e.text.length<2)return e;let r=2;for(;r<e.text.length;r++){const s=e.text.substring(0,r);if(!(t.measureText(s).width+(r-1)*i<n))break}return{...e,text:e.text.substring(0,r-1)}}function xc(t,e,n,i,r,s=0){const o=String(e).split("\n");return i?[].concat(...o.map(e=>function(t,e,n,i=0){const r=[];let s=[],o=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-o,h=t.measureText(a).width+(a.length-1)*i;if(h<=c)s.push({...e,text:a}),o+=h,a="";else{const n=bc(t,{...e,text:a},c,i);s.push(n),r.push(s),s=[],o=0,a=a.substring(n.text.length)}}}),s.length>0&&r.push(s),r}(t,r?gc(e):[{text:e,bold:!1,italic:!1}],n,s))):o.map(t=>r?gc(t):[{text:t,bold:!1,italic:!1}])}function vc(t,e,n,i,r,s,o=0){if(!i)return[];t.save(),t.font=n;const a=xc(t,i,e,!!r,s,o);return t.restore(),a}function wc(t){const{fontFamily:e=hc.FONT_FAMILY,bold:n=hc.BOLD,italic:i=hc.ITALIC,fontSize:r=hc.FONT_SIZE}=t,s=[];return n&&s.push("bold"),i&&s.push("italic"),s.push(r+"px"),s.push(e),s.join(" ")}function _c(t,e){const n=t.bold||e.bold,i=t.italic||e.italic;return wc({...t,bold:n,italic:i})}function Mc(t,e,n,i){let{alpha:r,rotation:s,keepTextAngle:o=!1,fontColor:a=hc.FONT_COLOR,textAlign:c=hc.TEXT_ALIGN,textBaseline:h=hc.TEXT_BASELINE,textBackgroundStyle:l,fontSize:u,lineHeight:d,textWrap:p,textOverflow:f,letterSpacing:m=0}=i;r=void 0!==r?r:1,u||=hc.FONT_SIZE,d||=1.2*u,t.save();const{left:y,top:g,width:b,height:x}=e;if(s&&o&&(t.translate(y+b/2,g+x/2),t.rotate(-s),t.translate(-(y+b/2),-(g+x/2))),t.beginPath(),t.font=wc(i),!p&&f){const e=function(t,e,n,i){const r="ellipsis"===t?"…":"",s=e.measureText(r).width,o=[];let a=0;for(const r of n){const n=[];for(const c of r){const r=e.measureText(c.text).width;if(!(a+r<=i-("ellipsis"===t?s:0))){const r=Sc(e,c,i-a-("ellipsis"===t?s:0),t);return n.push(r),o.push(n),o}n.push(c),a+=r}o.push(n),a=0}return o}(f,t,n,b);n=e}const v=n.length*d;let w;switch(h){case"top":w=g,t.textBaseline="top";break;case"bottom":w=g+x-v+d,t.textBaseline="bottom";break;default:w=g+x/2-v/2+d/2,t.textBaseline="middle"}t.globalAlpha*=r,t.fillStyle=a,n.forEach((e,r)=>{const s=w+r*d,o=function(t,e,n,i=0){return e.reduce((e,r)=>(t.font=_c(n,r),e+t.measureText(r.text).width+i*(r.text.length-1)),0)}(t,e,i,m);let h=y;switch(c){case"left":case"justify":h=y;break;case"right":h=y+b-o;break;case"center":h=y+(b-o)/2}if(l&&(t.fillStyle=l,function(t,e,n,i,r,s=0,o=!1,a=!0){s="number"==typeof s?{tl:s,tr:s,br:s,bl:s}:{tl:0,tr:0,br:0,bl:0,...s},t.beginPath(),t.moveTo(e+s.tl,n),t.lineTo(e+i-s.tr,n),t.quadraticCurveTo(e+i,n,e+i,n+s.tr),t.lineTo(e+i,n+r-s.br),t.quadraticCurveTo(e+i,n+r,e+i-s.br,n+r),t.lineTo(e+s.bl,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s.bl),t.lineTo(e,n+s.tl),t.quadraticCurveTo(e,n,e+s.tl,n),t.closePath(),o&&t.fill(),a&&t.stroke()}(t,h-4,s-u/2-4,o+8,u+8,4,!0,!1),t.fillStyle=a),"justify"===c&&r<n.length-1&&e.length>1){const n=b-o,r=e.length-1,a=n/r;e.forEach((e,n)=>{t.font=_c(i,e),t.fillText(e.text,h,s),h+=t.measureText(e.text).width+(n<r?a:0)})}else e.forEach(e=>{t.font=_c(i,e),[...e.text].forEach(e=>{t.fillText(e,h,s),h+=t.measureText(e).width+m})})}),t.restore()}function Sc(t,e,n,i){let r="";for(let i=0;i<e.text.length;i++){const s=r+e.text[i];if(t.measureText(s).width>n)break;r=s}return{...e,text:r+("ellipsis"===i?"…":"")}}function kc(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{lc()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(lc),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{lc()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),lc(),uc="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const Ac=[];function zc(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(1!==r.x||1!==r.y?(t=(t-n.x)/r.x,e=(e-n.y)/r.y):(t-=n.x,e-=n.y),0!==i){const n=Math.cos(-i),r=Math.sin(-i),s=t*r+e*n;t=t*n-e*r,e=s}return{x:t+n.x,y:e+n.y}}function Tc(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(t-=n.x,e-=n.y,0!==i){const n=Math.cos(i),r=Math.sin(i),s=t*r+e*n;t=t*n-e*r,e=s}return 1!==r.x||1!==r.y?{x:t*r.x+n.x,y:e*r.y+n.y}:{x:t+n.x,y:e+n.y}}function Ic(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=zc(t,e,n,i,r);return n&&(s.x-=n.x,s.y-=n.y),s}return zc(t,e,n=n||this.rotatePoint,i,r)}function Oc(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=Tc(t,e,void 0,i+(this._delta?.theta??0),r);return n&&(s.x+=n.x,s.y+=n.y),s}n=n||this.rotatePoint;const{theta:s=0,tx:o=0,ty:a=0,sx:c=1,sy:h=1}=this._delta||{};if(0===s&&0===o&&0===a&&1===c&&1===h)return Tc(t,e,n,i,r);return Tc(t+o,e+a,{x:n.x+o,y:n.y+a},i+s,{x:r.x*c,y:r.y*h})}function Ec(t,e,n){n=n||this.rootModel;const i=this.transcoordS2T(t,e,n);return Tc(i.x,i.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function jc(t,e,n){n=n||this.rootModel,Ac.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Ac.push(t);let i=this.transcoordS2P(t,e);for(let t=0;t<Ac.length;t++){const e=Ac[t],n=e.bounds;i.x+=n.left,i.y+=n.top,i=e.transcoordS2P(i.x,i.y)}return i}function Pc(t,e,n){n=n||this.rootModel,Ac.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Ac.push(t);let i={x:t,y:e};for(let t=Ac.length-1;t>=0;t--){const e=Ac[t];i=e.transcoordP2S(i.x,i.y);const n=e.bounds;i.x-=n.left,i.y-=n.top}return i}function Cc(t,e,n){const i=this.transcoordT2P(t,e,n);return this.transcoordP2S(i.x,i.y)}function Rc(t,e,n){const i=this.rootModel,r=this.transcoordS2T(t,e,i);return n.transcoordT2S(r.x,r.y,i)}function Fc(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:i={x:0,y:0},scale:r={x:1,y:1},rotation:s=0}=n.model,o=zc(t,e,i,s,r);return i&&(o.x-=i.x,o.y-=i.y),n===this?o:this.transcoordT2S(o.x,o.y,n)}function Dc(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let i;if(i=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return i;const{translate:r={x:0,y:0},rotation:s=0,scale:o={x:1,y:1}}=n.model;return i=Tc(i.x,i.y,void 0,s+n._delta.theta,o),r&&(i.x+=r.x,i.y+=r.y),i}function Nc(t){const e=t.element,n=t.fillStyle,i=e.style;if(n)if("string"==typeof n)i.backgroundColor=n;else switch(n.type){case"pattern":if(i.backgroundImage="url("+n.image+")",i.backgroundColor="transparent",n.fitPattern?i.backgroundSize="100% 100%":n.width||n.height?i.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:i.backgroundSize="contain",n.fitPattern)i.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:r,align:s,color:o}=n;if(r&&(i.backgroundRepeat="no-repeat"),o&&(i.backgroundColor=o),s)switch(s){case"center":i.backgroundPosition="center center";break;case"left-top":i.backgroundPosition="left top";break;case"left-bottom":i.backgroundPosition="left bottom";break;case"right-top":i.backgroundPosition="right top";break;case"right-bottom":i.backgroundPosition="right bottom";break;case"left":i.backgroundPosition="left center";break;case"right":i.backgroundPosition="right center";break;case"top":i.backgroundPosition="center top";break;case"bottom":i.backgroundPosition="center bottom"}else t||e?i.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete i.backgroundPosition}break;case"gradient":i.background=function(t,e){const n=e.colorStops,i=e.gradientType;if(n instanceof Array&&n.length>0)switch(i){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:i}=t.bounds;switch(e){case"center":return[n/2,i/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,i];default:return[n,i]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else i.background="transparent"}const Lc={x:1,y:1},Bc={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function Uc(t,e){let n=this.bounds,i=this.rotatePoint;const r=this.get("rotation"),s=this.get("scale");if(t){const i=t.call(e,n);i&&(n=i)}const{left:o,top:a,width:c,height:h}=n;let l=[{x:o,y:a},{x:o+c,y:a+h}];l=l.map(t=>Tc(t.x,t.y,i,r,s));let u=l[0],d=l[1];i={x:(u.x+d.x)/2,y:(u.y+d.y)/2},l=l.map(t=>zc(t.x,t.y,i,r,s)),u=l[0],d=l[1],this.bounds={left:u.x,top:u.y,width:d.x-u.x,height:d.y-u.y}}function Wc(t,e,n){let i=this.path,r=this.rotatePoint;t&&(i=t.call(n,i));let s=i.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(n,s);t&&(s=t)}const o={x:0,y:0};let a,c,h,l;i=s.map(t=>this.fromParent(t.x,t.y,o)),a=c=i[0].x,h=l=i[0].y;for(let t=1;t<i.length;t++){const e=i[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<h?h=e.y:e.y>l&&(l=e.y)}r={x:(a+c)/2,y:(h+l)/2},r=this.toParent(r.x,r.y,o),this.path=s.map(t=>{const e=this.fromParent(t.x,t.y,r);return{...t,x:e.x,y:e.y}})}const qc=new Map;let $c=null;function Vc(){$c&&($c(),$c=null)}function Yc(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var Hc=new class{add(t){var e;Yc(t)&&!qc.has(t)&&(qc.set(t,0),e=t?.root,$c||($c=xn.subscribe(t=>{if(0===t)return;const e=[];for(const[n,i]of qc){if(!Yc(n)){e.push(n);continue}const r=i+t;r>=n.retention?e.push(n):qc.set(n,r)}for(const t of e){qc.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){wa("RetentionManager removeSelf failed:",t)}}0===qc.size&&Vc()},{description:"retention timer",component:e,getTargets:()=>Array.from(qc.keys()),metadata:{get count(){return qc.size},get preview(){return Array.from(qc.entries()).slice(0,3).map(([t,e])=>({type:t?.state?.type,id:t?.state?.id??"-",retentionMs:t?.retention,remainingMs:Math.max(0,Math.round(t?.retention-e))}))}}})))}remove(t){qc.delete(t)&&0===qc.size&&Vc()}touch(t){t&&qc.has(t)&&qc.set(t,0)}dispose(){Vc(),qc.clear()}get length(){return qc.size}};const Gc=function(t){return t};function Xc(t){const e=t.indexOf("||");let n="",i="";-1!=e&&(n=t,i=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const r=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),s=r.slice(1);return{defaultValue:i,match:t,originText:n||t,target:r[0],accessor:s.length>0?function(t){return s.reduce((t,e)=>t?t[e]:void 0,t)}:Gc}}function Zc(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>Xc(t))[0];if(n)return n.accessor(this.getState(n.target));const i=(e.match(/\${[^}]*}/)||[]).map(t=>Xc(t))[0];if(i){const t=this.root.findById(i.target);return i.accessor(this.getState(t))}return t}function Jc(t,e){if(!t)return;const n=String(t),i=e||Ho,r=(n.match(/#{(\S*)}/gi)||[]).map(t=>Xc(t)),s=(n.match(/\${[^}]*}/gi)||[]).map(t=>Xc(t));if(0==r.length&&0==s.length)return n;let o=n;return r.forEach(t=>{const e=i(t.accessor(this.getState(t.target)));o=o.replace(t.match,void 0===e?"":e)}),s.forEach(t=>{const e=this.root.findById(t.target),n=i(t.accessor(e&&e.data));o=o.replace(t.match,void 0===n?"":n)}),o}function Qc(t,e,n){if(!t)return;const i=n||Ho,r=String(t),s=(r.match(/#{[^}]*}/gi)||[]).map(t=>Xc(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>Xc(t));return 0!=s.length||0!=o.length?function(){let t=r;return s.forEach(n=>{const r=i(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===r?n.defaultValue||"":r)}),o.forEach(n=>{const r=e.root.findById(n.target),s=i(n.accessor(r&&r.data));t=t.replace(n.originText,void 0===s?n.defaultValue||"":s)}),t}:void 0}class Kc{constructor(){}static registerDecorator(t,e){Kc.constructors.set(t,e)}static create(t,e,n={},i){const r=Kc.constructors.get(t);if(!r)throw new Error(`unknown decorator type: ${t}`);return new r(i,e,n)}}function th(t,e){const n=e.x-t.x,i=e.y-t.y,r=Math.sqrt(n*n+i*i);if(!Wn(t))return r;const s=qn(t,e,t.bulge);if(!s)return r;const o=Math.min(s.radius,r/2),a=2*Math.asin(o/s.radius);return s.radius*a}function eh(t,e){const n=t.path.slice();if(!n||!n.length)return void wa("path should not be empty");let i=1;const r=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[i];)r.push(th(n[i-1],n[i])),i++;const s=r.reduce(function(t,e){return t+e},0);i=0;let o=0;do{o+=r[i++]}while(o/s<e);o-=r[--i];e=(e-o/s)*(s/r[i]);const a=n[i%n.length],c=n[(i+1)%n.length],{x:h,y:l}=function(t,e,n){if(Wn(t)){const i=qn(t,e,t.bulge);if(i){let t=i.endAngle-i.startAngle;i.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=i.startAngle+n*t;return{x:i.cx+i.radius*Math.cos(e),y:i.cy+i.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*n),y:t.y+Math.round((e.y-t.y)*n)}}(a,c,e);return t.toScene(h,l)}function nh(t,e){return!1}function ih({x:t,y:e},...n){const i=this.path,r=t,s=e;this.path=i.map(t=>({...t,x:t.x+r,y:t.y+s}))}function rh(t){const e=t??this.center.x,{rotation:n}=this.state,i=this.fillStyle;if(this.set("rotation",2*Math.PI-n),i&&"gradient"===i.type&&"linear"===i.gradientType){const t=Po(i);t.rotation=(Math.PI-parseFloat(i.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({...t,x:2*e-t.x,y:t.y}))}function sh(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}function oh(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let i=t.width-e.width,r=t.height-e.height;i*n>r?r=i*n:i=r/n;let s=t.left-e.left,o=t.top-e.top;return 0!=s&&0!=o?(o=-r,s=-i):0!=s?s=-i:0!=o&&(o=-r),{left:e.left+s,top:e.top+o,width:e.width+i,height:e.height+r}}return t}function ah(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function ch(t){return eh(this,t||0)}function hh(){const t=this.path;let e,n,i,r;e=n=t[0].x,i=r=t[0].y;for(let s=1;s<t.length;s++){const o=t[s];o.x<e?e=o.x:o.x>n&&(n=o.x),o.y<i?i=o.y:o.y>r&&(r=o.y)}return{left:e,top:i,width:n-e,height:r-i}}function lh(t){const e=this.bounds;if(Math.round(100*t.width)/100==Math.round(100*e.width)/100&&Math.round(100*t.height)/100==Math.round(100*e.height)/100&&Math.round(100*t.left)/100==Math.round(100*e.left)/100&&Math.round(100*t.top)/100==Math.round(100*e.top)/100)return;const n=0==e.width?1:t.width/e.width,i=0==e.height?1:t.height/e.height;this.path=this.path.map(r=>({...r,x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i}))}function uh(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function dh(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const e=this.center;if(Math.round(100*t.x)/100==Math.round(100*e.x)/100&&Math.round(100*t.y)/100==Math.round(100*e.y)/100)return;const n=t.x-e.x,i=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+n,y:t.y+i}))}function ph(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function fh(t){const{x:e,y:n,z:i}=t||{};this.center={x:e,y:n},isNaN(i)||this.setState("zPos",Number(i))}function mh(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function yh(t){const{x:e,y:n,z:i}=t;this.setState({rotationX:e,rotationY:n,rotation:-i})}function gh(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function bh(t){const{width:e,height:n,depth:i}=t,{top:r,left:s}=this.bounds;this.bounds={top:r,left:s,width:e,height:n},this.setState("depth",i)}function xh(){return wa("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function vh(t){wa("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function wh(){return this.path}function _h(){return this.center}function Mh(){return this.nature.mutable}function Sh(){return this.nature.resizable&&!this.stuck}function kh(){return this.nature.rotatable&&!this.stuck}Kc.constructors=new Map;const Ah={x:1,y:1};function zh(t,e,n){const{offsetX:i,offsetY:r,blur:s,color:o}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??Ah;t.shadowOffsetX=i*a.x*cc,t.shadowOffsetY=r*a.y*cc,t.shadowBlur=s*a.x*cc,t.shadowColor=o}function Th(t){const e=t?.app;if(!e?.isEditMode)return!1;const n=e.focusFilter;return!!(t.hidden||n&&!n(t))}function Ih(t){t.save(),this.prerender(t);const e=this.app,n=!0===t.__inHiddenSubtree;e?.isEditMode&&((Th(this)||n)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=n,t.restore()}function Oh(t){const e=this.rotatePoint,{scale:n,rotation:i,shadow:r,alpha:s}=this.state,o=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(i||0)+this._delta.theta,{tx:h=0,ty:l=0}=this._delta,u=(s||1)-this._delta.fade;(h||l)&&t.translate(h,l),(1!=o||1!=a||c)&&(t.translate(e.x,e.y),1==o&&1==a||t.scale(o,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),u&&(t.globalAlpha=u),r&&zh(t,r,this)}function Eh(t){}function jh(t){this.drawText(t)}function Ph(t,e){t(this)}function Ch(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{wa(t)})}function Rh(t){!this.textHidden&&this.text&&this.hasTextProperty&&Mc(t,this.textBounds,this.textLines(t),this.state)}function Fh(t,e){yc(t,e?{...this.state,...e}:this.state)}function Dh(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(dc(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function Nh(){return this.get("strokeStyle")}function Lh(t){this.set("strokeStyle",t)}function Bh(){return this.getState("fillStyle")}function Uh(t){this.setState("fillStyle",t)}function Wh(){return this.get("fontColor")}function qh(t){this.set("fontColor",String(Ho(t)))}function $h(){return this.getState("rotation")}function Vh(t){this.setState("rotation",Number(Ho(t)))}function Yh(){return this.app.isEditMode?["decotag","data-spread"]:[]}function Hh(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function Gh(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function Xh(t){this.setState("hidden",t)}function Zh(){return this.state.tag}function Jh(t){this.setState("tag",t)}function Qh(){}function Kh(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function tl(){const t=this.getState("text");return null==t?"":String(t)}function el(t){const{textWrap:e,supportMarkdown:n}=this.state;return vc(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function nl(){return wc(this.model)}function il(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function rl(){return this._text_substitutor||(this._text_substitutor=Qc(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function sl(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,i,r,s,o,a,c,h,l,u,d,p=t.length,f=t.search(/[0-9\-\+#]/),m=f>0?t.substring(0,f):"",y=t.split("").reverse().join(""),g=y.search(/[0-9\-\+#]/),b=p-g,x=t.substring(b,b+1),v=b+("."===x||","===x?1:0),w=g>0?t.substring(v,p):"";if(n=(e="-"===(t=t.substring(f,v)).charAt(0)?-e:+e)<0?e=-e:0,i=t.match(/[^\d\-\+#]/g),r=".",s=i&&i[1]&&i[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),h=e.split("."),(!h[1]||h[1]&&h[1].length<=a)&&(e=(+e).toFixed(a+1)),l=t[0].split(s),t[0]=l.join(""),o=t[0]&&t[0].indexOf("0"),o>-1)for(;h[0].length<t[0].length-o;)h[0]="0"+h[0];else 0===+h[0]&&(h[0]="");if((e=e.split("."))[0]=h[0],c=l[1]&&l[l.length-1].length,c){for(u=e[0],y="",b=u.length%c,p=u.length,v=0;v<p;v++)y+=u.charAt(v),!((v-b+1)%c)&&v<p-c&&(y+=s);e[0]=y}return e[1]=t[1]&&e[1]?"."+e[1]:"",i=e.join(""),"0"!==i&&""!==i||(n=!1),d="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",m+(d+i)+w}(t,this.textSubstitutor()):this.textSubstitutor()}function ol(t){delete this._text_substitutor;const e=Ho(t);this.setState("text",null==e?"":String(e))}function al(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:i}=this.state;i||=0,t||=0,e||=0,n||=0;const{left:r,top:s,width:o,height:a}=this.bounds;return{left:r+e,top:s+t,width:Math.max(o-e-n,0),height:Math.max(a-t-i,0)}}function cl(){return 0}function hl(){return!!this._textHidden}function ll(t){this._textHidden=!!t,this.invalidate()}function ul(){return!0}function dl(t){return t}function pl(t){return Math.pow(t,2)}function fl(t){return 1-Math.sin(Math.acos(t))}function ml(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function yl(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function gl(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var bl={linear:dl,quad:pl,circ:fl,back:ml,bounce:yl,elastic:gl},xl=Object.freeze({__proto__:null,back:ml,bounce:yl,circ:fl,default:bl,elastic:gl,linear:dl,quad:pl});class vl{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:i,ease:r}=this.config;let s;s="string"==typeof n?bl[n]:n,this.delta="out"===r?function(t,e){return function(n){return 1-t(1-n,e)}}(s,i):"inout"===r?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(s,i):s,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:i=0,onComplete:r}=this.config;this._started=!0;const s=this.config?.type??"animation";let o=0,a=0;const c=()=>xn.simTime,h=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(r);0==o&&(o=c(),this.client?.touch?.());const l=c()-o,u=Math.max((l-e)%(t+i),0)/t,d=i<=0&&a>u;if(a=u,u>=1||d){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(r),void(o=0);if(i>0)return this._unsub?.(),this._unsub=null,void(this._timeout=setTimeout(()=>{this._timeout=null,this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(()=>{this._timeout=null,this._started&&(this._unsub=xn.subscribe(h,{description:`animation: ${s}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:i}}))},i/2)},i/2))}else this.step(this.delta(u)),this.client&&this.client.invalidate?.()};this._unsub=xn.subscribe(h,{description:`animation: ${s}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:i}})}stop(t){this._unsub&&(this._unsub(),this._unsub=null),this._timeout&&clearTimeout(this._timeout),this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const wl={rotation:class extends vl{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends vl{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let i=t*n;t<1/4?i*=-1:t<3/4?i-=2*e:i=n-i,this.client.delta?.("theta",i)}},heartbeat:class extends vl{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let i;i=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:i,sy:i,sz:i})}},moving:class extends vl{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends vl{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let i={tx:0,ty:0};const r=this.client.delta("");r&&"object"==typeof r&&"tx"in r&&"ty"in r&&(i=r);const{tx:s,ty:o}=i,a=n.outline(t),{x:c,y:h}=this.client.center,l=this.client.toScene(c,h);this.client.delta({tx:a.x-l.x+s,ty:a.y-l.y+o})}},fade:class extends vl{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,i=Math.max(Math.min(e,n,1),0),r=2*(Math.min(Math.max(e,n,1),1)-i);let s;s=t<.5?r*t:(1-t)*r,this.client.delta?.("fade",s)}},waypoint:class extends vl{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,i=t.center,{x:r,y:s}=e.toScene(n.x,n.y),{x:o,y:a}=t.toScene(i.x,i.y);this._startX=r,this._startY=s,this._endX=o,this._endY=a;const c=this.config.yawOffset??Math.PI/2,h=Math.atan2(a-s,o-r)+c;this.client.location={x:r,y:s},this.client.setState("rotation",h),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};const _l={gradation:function(t,e,n){const{subType:i,from:r,to:s,colors:o}=n;let a;switch(i){case"linear":default:a=e.createLinearGradient(r.x,r.y,s.x,s.y);break;case"radial":a=e.createRadialGradient(r.x,r.y,r.r,s.x,s.y,s.r)}o&&(o.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:zh};function Ml(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:n,component:i,step:r=()=>{},onStart:s,onProgress:o,onComplete:a,options:c,repeat:h=!1,delta:l}=t;let u;u="string"==typeof l?xl[l]:l||dl,"out"===n?u=function(t,e){return function(n){return 1-t(1-n,e)}}(u,c):"inout"===n&&(u=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(u,c));let d=!1,p=null;return{start:function(){if(d)return this;if(i?.root?.app?.suppressAnimations)return this;d=!0,s&&s();let t=0;const n=()=>xn.simTime;return p=xn.subscribe(()=>{if(!d)return;if(i?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=n());const s=(n()-t)/e,a=h?s%1:Math.min(s,1);r(u(a,c)),o&&o(a),!(s>=1)||h&&d||(this.stop(),t=0)},{description:"animate()",component:i,metadata:{duration:e,repeat:h}}),this},stop:function(){return d=!1,p&&(p(),p=null),a&&a(),this}}}({component:this,...t}),this._animate}function Sl(t,e){return function(t,e,n){const i=_l[n.type];i&&i(t,e,n)}(this,t,e)}const kl=100;function Al(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*kl)/kl}return e}}function zl(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*kl)/kl):delete t[e]:"object"==typeof n&&zl(n)}return t}function Tl(...t){return JSON.stringify(this.hierarchy,Al,...t)}function Il(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Ol(t){this.rootModel.closeScene(t)}function El(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function jl(){this.parent&&this.parent.invalidate()}function Pl(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function Cl(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function Rl(){return this.getState("data")}function Fl(t){this.setState("data",t),this.touch()}function Dl(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function Nl(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function Ll(){return Number(this.get("retention"))||0}function Bl(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const n=e.type?wl[e.type]:void 0;return n?new n(t,e):null}(this,t.oncreate))}return this._animation}}function Ul(){return!!this.animation?.started}function Wl(t){this.animation&&(this.animation.started=t)}function ql(){}function $l(t,e,n,i){const r=e.get("class");if(!r)return!1;return(r.split(" ")||[]).indexOf(t.substr(1))>=0}function Vl(t,e,n,i){return t==e.get("type")}function Yl(t,e,n,i,r,s){return t(e,n,i,r)&&s.push(n),n.components&&n.components.forEach(n=>{Yl(t,e,n,i,r,s)}),s}function Hl(t,e,n,i){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function Gl(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let i;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":i=$l;break;case"(":i=Hl;break;default:i=Vl}return Yl(i,t,e,n,e,[])}function Xl(t,...e){if(t(this,...e))return this}function Zl(t,...e){return"string"==typeof t?Gl(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function Jl(t,e,n){if(!this.capturable||n?.(this))return!1;const i=this.fromParent(t,e);return this.contains(i.x,i.y)?this:void 0}function Ql(t){return this.anchors.find(e=>e.name===t)}function Kl(t){return!0}function tu(t){return this._parent.getContext(t??this)}function eu(){return this.isRoot()?this:this.parent&&this.parent.root}function nu(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function iu(){return this._parent}function ru(t){this._parent=t}function su(){return this.nature.anchors||[]}function ou(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function au(){if(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))return!0;const t=this.app?.focusFilter;return!(!this.app?.isEditMode||!t||t(this))}function cu(){if(!1===this.get("capturable"))return!1;const t=this.app?.isEditMode;if(!t&&this.hidden)return!1;if(t){if(this.get("locked"))return!1;const t=this.app.focusFilter;if(t&&!t(this))return!1}return!0}function hu(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function lu(){return this.app&&this.app.isViewMode&&this.state.origin||""}function uu(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function du(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const pu={},fu={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},mu=[],yu=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),gu={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let bu=0;const xu={};const vu=new FinalizationRegistry(t=>{!function(t){bu--;let e=xu[t];e||(e=xu[t]={up:0,down:0}),e.down++}(t)});class wu{static get nature(){return fu}static register(t,e){if(!e)return pu[t];pu[t]=e}static types(){return Object.keys(pu)}static get residents(){return xu}static get residentsCount(){return bu}static registerDecorator(t,e){Kc.registerDecorator(t,e)}constructor(t,e){if(this._readyInvoked=!1,this._app=e,this._model=t||{},this._model.event&&"object"==typeof this._model.event&&!Array.isArray(this._model.event)&&!Array.isArray(this._model.eventHandlers)){const t=function(t){if(!t||"object"!=typeof t||Array.isArray(t))return[];const e={tap:"click",hover:"mouseenter",dblclick:"dblclick",longpress:"longpress"},n=[];for(const i of Object.keys(t)){const r=e[i];if(!r)continue;const s=t[i];if(s&&"object"==typeof s){if("script"===s.action){const t="string"==typeof s.value?s.value:s.value&&"object"==typeof s.value?s.value.script:"";t&&n.push({trigger:r,action:"script",code:t,target:s.target});continue}n.push({trigger:r,action:s.action,target:s.target,value:s.value,options:{emphasize:s.emphasize,restore:s.restore,pressed:s.pressed,...s.options??{}}})}}return n}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=Po(gu),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??!0))&&(this.animation.started=!0),this.clearCache(),Hc.add(this),function(t){bu++;let e=xu[t];e||(e=xu[t]={up:0,down:0}),e.up++}(this._model.type),vu.register(this,this._model.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}invokeReady(){if(!this._readyInvoked)return this._readyInvoked=!0,this.ready()}touch(){this.updatedAt=performance.now(),Hc.touch(this)}clearCache(...t){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=Po(gu))}dispose(){this.resetAnimation(),this.disposeMappings();const t=this.parent;t&&"function"==typeof t.removeItem&&-1!==t._items?.indexOf?.(this)&&t.removeItem(this),t?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&Hc.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&Hc.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get refid(){return this.get("refid")}get hierarchy(){const t=Po(this._model);return this.volatile.forEach(e=>{delete t[e]}),zl(t)}get volatile(){return mu}_applyProps(t,e,n){const i={},r={};let s=!1;const o=Po(e),a=this;if(Object.getOwnPropertyNames(o).forEach(function(e){const c=n.getBeforeVal(e),h=o[e];!n.sensitive&&function(t,e){return cs(t,e)}(c,h)||(r[e]=c,i[e]=h,t[e]=h,n.clearState&&delete a._state[e],s=!0)}),s){this._cachedState=null;Object.keys(i).some(t=>!yu.has(t))&&this.clearCache(),i.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(i,r),i.hasOwnProperty("fillStyle")&&this.onchangeFill(i,r),n.afterFillStyle&&n.afterFillStyle(i,r),i.hasOwnProperty("data")&&this.onchangeData(i,r),this.onchange&&this.onchange(i,r),this.trigger("change",i,r)}return this}contains(t,e){return nh.call(this,t,e)}move(t,...e){ih.call(this,t,...e)}symmetryX(t){rh.call(this,t)}symmetryY(t){sh.call(this,t)}adjustResize(t,e,n){return oh.call(this,t,e,n)}adjustRotation(t,e){return ah.call(this,t,e)}outline(t){return ch.call(this,t)}get bounds(){return hh.call(this)}set bounds(t){lh.call(this,t)}get center(){return uh.call(this)}set center(t){dh.call(this,t)}get location(){return ph.call(this)}set location(t){fh.call(this,t)}get rotate(){return mh.call(this)}set rotate(t){yh.call(this,t)}get dimension(){return gh.call(this)}set dimension(t){bh.call(this,t)}get path(){return xh.call(this)}set path(t){vh.call(this,t)}get drawPath(){return wh.call(this)}get rotatePoint(){return _h.call(this)}get mutable(){return Mh.call(this)}get resizable(){return Sh.call(this)}get rotatable(){return kh.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&Ih.call(this,t)}prerender(t){Oh.call(this,t)}render(t){Eh.call(this,t)}postrender(t){jh.call(this,t)}prepare(t,e){Ph.call(this,t,e)}prepareIf(t){Ch.call(this,t)}drawText(t){Rh.call(this,t)}drawStroke(t,e){Fh.call(this,t,e)}drawFill(t,e){Dh.call(this,t,e)}get strokeStyle(){return Nh.call(this)}set strokeStyle(t){Lh.call(this,t)}get fillStyle(){return Bh.call(this)}set fillStyle(t){Uh.call(this,t)}get fontColor(){return Wh.call(this)}set fontColor(t){qh.call(this,t)}get rotation(){return $h.call(this)}set rotation(t){Vh.call(this,t)}get decorators(){return Yh.call(this)}get decotag(){return Hh.call(this)}get hidden(){return Gh.call(this)}set hidden(t){Xh.call(this,t)}get tag(){return Zh.call(this)}set tag(t){Jh.call(this,t)}get appendum(){return Qh.call(this)}set appendum(t){Kh.call(this,t)}defaultTextSubstitutor(){return tl.call(this)}textLines(t){return el.call(this,t)}get font(){return nl.call(this)}get lineHeight(){return il.call(this)}get textSubstitutor(){return rl.call(this)}get text(){return sl.call(this)}set text(t){ol.call(this,t)}get textBounds(){return al.call(this)}get textRotation(){return cl.call(this)}get textHidden(){return hl.call(this)}set textHidden(t){ll.call(this,t)}get hasTextProperty(){return ul.call(this)}animate(t){return Ml.call(this,t)}effect(t,e){return Sl.call(this,t,e)}serialize(...t){return Tl.call(this,...t)}trim(){Il.call(this)}closeScene(t){Ol.call(this,t)}delta(t,e){return El.call(this,t,e)}invalidate(){jl.call(this)}get value(){return Pl.call(this)}set value(t){Cl.call(this,t)}get data(){return Rl.call(this)}set data(t){Fl.call(this,t)}set tap(t){Dl.call(this,t)}get mappings(){return Nl.call(this)}get retention(){return Ll.call(this)}get animation(){return Bl.call(this)}get started(){return Ul.call(this)}set started(t){Wl.call(this,t)}get controls(){return ql.call(this)}findFirst(t,...e){return Xl.call(this,t,...e)}findAll(t,...e){return Zl.call(this,t,...e)}capture(t,e,n){return Jl.call(this,t,e,n)}findAnchor(t){return Ql.call(this,t)}isDescendible(t){return Kl.call(this,t)}getContext(t){return tu.call(this,t)}get root(){return eu.call(this)}get rootModel(){return nu.call(this)}get parent(){return iu.call(this)}set parent(t){ru.call(this,t)}get anchors(){return su.call(this)}get scalable(){return ou.call(this)}get stuck(){return au.call(this)}get capturable(){return cu.call(this)}get position(){return hu.call(this)}get origin(){return lu.call(this)}get offset(){return uu.call(this)}get app(){return du.call(this)}drawEffect(t){ac.call(this,t)}prepareFill(t,e){pc.call(this,t,e)}prepareFillIf(t){fc.call(this,t)}onchangeFill(t,e){mc.call(this,t,e)}drawImage(t,e,n,i,r,s){oc.call(this,t,e,n,i,r,s)}mutateBounds(t,e){Uc.call(this,t,e)}mutatePath(t,e,n){Wc.call(this,t,e,n)}access(t){return Zc.call(this,t)}substitute(t,e){return Jc.call(this,t,e)}onchangeMappings(t,e){sc.call(this,t,e)}onchangeData(t,e){nc.call(this,t,e)}buildMappings(){ic.call(this)}executeMappings(t){ec.call(this,t)}disposeMappings(){rc.call(this)}ondropfile(t,e){kc.call(this,t,e)}transcoordS2P(t,e,n){return Oc.call(this,t,e,n)}transcoordP2S(t,e,n){return Ic.call(this,t,e,n)}transcoordS2T(t,e,n){return jc.call(this,t,e,n)}transcoordT2P(t,e,n){return Pc.call(this,t,e,n)}transcoordT2S(t,e,n){return Cc.call(this,t,e,n)}transcoordS2TR(t,e,n){return Ec.call(this,t,e,n)}transcoordS2O(t,e,n){return Rc.call(this,t,e,n)}transcoordC2S(t,e,n){return Fc.call(this,t,e,n)}transcoordS2C(t,e,n){return Dc.call(this,t,e,n)}toParent(t,e,n){return Oc.call(this,t,e,n)}fromParent(t,e,n){return Ic.call(this,t,e,n)}toScene(t,e,n){return jc.call(this,t,e,n)}fromScene(t,e,n){return Cc.call(this,t,e,n)}toLocal(t,e,n){return Fc.call(this,t,e,n)}toGlobal(t,e,n){return Dc.call(this,t,e,n)}toOther(t,e,n){return Rc.call(this,t,e,n)}on(t,e,n){return ma.call(this,t,e,n)}off(t,e,n){return ya.call(this,t,e,n)}once(t,e,n){return ga.call(this,t,e,n)}trigger(t,...e){return ba.call(this,t,...e)}delegate_on(t){return xa.call(this,t)}delegate_off(t){return va.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}wu.capabilities=[],wu.requires3d=!1,wu.union=function(t){let e=0,n=0,i=0,r=0,s=!1;return t.forEach(t=>{s?(e=Math.min(t.left,e),n=Math.min(t.top,n),i=Math.max(t.left+t.width,i),r=Math.max(t.top+t.height,r)):(e=t.left,n=t.top,i=t.left+t.width,r=t.top+t.height,s=!0)}),{left:e,top:n,width:i-e,height:r-n}},wu.transcoordR=zc,wu.transcoordRR=Tc,wu.createCanvas=uc,wu.memoize=Ma,wu.mixin=function t(e,n){if(n instanceof Array)n.forEach(n=>t(e,n));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(n)>=0)return e;if(e.mixingIn.indexOf(n)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(n),n.call(e),e.mixingIn.pop(),e.mixedIn.push(n)}return e},wu.drawText=Mc,wu.font=wc,wu.textLines=vc,wu.drawStroke=yc,wu.drawFill=dc,wu.reposition=function(t){let{id:e,scale:n=Lc,bold:i,italic:r,fontFamily:s="",textAlign:o,textBaseline:a,textOverflow:c,paddingTop:h,paddingBottom:l,paddingLeft:u,paddingRight:d,fontSize:p=hc.FONT_SIZE,lineWidth:f=0,lineHeight:m,lineDash:y}=t.state;l||=0,h||=0,u||=0,d||=0;const g=t.state.class,{strokeStyle:b,rotation:x=0,fontColor:v,hidden:w}=t,{left:_,top:M,width:S,height:k}=t.bounds,A=t.element;if(A.hidden=!t.app?.isEditMode&&w,e&&(A.id=e),g&&(A.className=g),Object.assign(A.style,Bc,{fontFamily:s,fontSize:p+"px",width:S+"px",height:k+"px",paddingTop:h+"px",paddingRight:d+"px",paddingBottom:l+"px",paddingLeft:u+"px",border:f+"px",borderColor:b,borderStyle:f>0?y||hc.LINE_DASH:"",color:v,fontWeight:i?"bold":"",fontStyle:r?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:a,lineHeight:void 0===m?"":m+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:_+"px",top:M+"px"}),Nc(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,i=e.offsetY??e.top??0,r=e.blur??e.blurSize??0,s=e.color??"transparent";t.element.style.boxShadow=`${n}px ${i}px ${r}px ${s}`}(t),t.isIn3DSpace())return;const z=t.delta(),T=(n&&n.x||1)*z.sx,I=(n&&n.y||1)*z.sy,O=(x||0)+z.theta,E=z.tx||0,j=z.ty||0;A.style.transform=`rotate(${O}rad) translate(${E}px, ${j}px) scale(${T}, ${I}) perspective(1px)`},wu.RetentionManager=Hc,wu.template=function(t,e,n){var i=Ks.imports._.templateSettings||Ks;n&&As(t,e,n)&&(e=void 0),t=Zs(t),e=Ts({},e,i,Bs);var r=Ts({},e.imports,i.imports,Bs),s=Lr(r),o=function(t,e){return Ds(e,function(e){return t[e]})}(r,s);hs(s,function(t){if(io.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,h=0,l=e.interpolate||so,u="__p += '",d=RegExp((e.escape||so).source+"|"+l.source+"|"+(l===qs?ro:so).source+"|"+(e.evaluate||so).source+"|$","g"),p=ao.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,function(e,n,i,r,s,o){return i||(i=r),u+=t.slice(h,o).replace(oo,Ws),n&&(a=!0,u+="' +\n__e("+n+") +\n'"),s&&(c=!0,u+="';\n"+s+";\n__p += '"),i&&(u+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),h=o+e.length,e}),u+="';\n";var f=ao.call(e,"variable")&&e.variable;if(f){if(io.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(c?u.replace(to,""):u).replace(eo,"$1").replace(no,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var m=Fs(function(){return Function(s,p+"return "+u).apply(void 0,o)});if(m.source=u,Rs(m))throw m;return m},wu.buildSubstitutor=Qc,["rotatePoint","font","lineHeight","retention"].forEach(t=>wu.memoize(wu.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>wu.memoize(wu.prototype,t,!0));const _u=new WeakMap,Mu=new WeakMap;function Su(t){const e=t?.state?.id;return null==e||""===e?null:String(e)}function ku(t,e){if(!t||null==e)return null;const n=_u.get(t),i=n?.get(String(e));return i?function(t,e){const n=e?.parent;return!!n&&Array.isArray(n._items)&&n._items.includes(e)&&n.root===t}(t,i)?i:(n.delete(String(e)),null):null}function Au(t,e){zu(e);const n=t?.root,i=Su(e);if(!n||!i||n===t)return;const r=_u.get(n)??new Map;_u.set(n,r),r.set(i,e),Mu.set(e,{root:n,id:i})}function zu(t){const e=t&&Mu.get(t);if(!e)return;Mu.delete(t);const n=_u.get(e.root);n&&n.get(e.id)===t&&n.delete(e.id)}const Tu=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]);function Iu(t){return class extends t{constructor(){super(...arguments),this._itemIssues=[],this._itemsStale=!1,this._lastItemIds=new Set}_itemsFromData(){return!0}_currentKeyOf(t){const e=this._keyedById()?t?.state?.id:t?.[mn];return null!=e?String(e):null}get itemIssues(){return this._itemIssues}get itemsStale(){return this._itemsStale}_sayItemIssues(t,e){const n=this._itemIssues.length>0||this._itemsStale;this._itemIssues=t,this._itemsStale=e,(n||t.length>0||e)&&this.trigger?.("item-issues",this,t,e)}_keyedById(){return!1}async ready(){if(await super.ready(),!this._itemsFromData())return;const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)&&this._itemsFromData()){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(!this._itemsFromData())return this.state?.data;if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){if(this._keyedById())return this._reconcileItemsById(t);const e=new Map;for(const n of t){const t=this._recordKey(n);t&&e.set(t,n)}const n=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&n.set(e,t)}for(const[t,i]of n)if(!e.has(t)){try{this.removeItem(i,!0)}catch{}zu(i);try{i?.dispose?.()}catch{}}for(const[t,i]of e){if(n.has(t))continue;if(null==i.itemId)continue;const e=this._createItemFromRecord(i);if(e){e[mn]=t;try{this.handoverIn(e)}catch{}}}for(const[t,i]of e){const e=n.get(t);if(e&&i.itemState&&"function"==typeof e.setState)try{e.setState(i.itemState)}catch{}}}_reconcileItemsById(t){const e=new Map;t.forEach((t,n)=>{const i=this._recordKey(t);i&&(e.get(i)??e.set(i,[]).get(i)).push(n)});const n=[...e].filter(([,t])=>t.length>1);if(n.length>0)return void this._sayItemIssues(n.map(([t,e])=>({code:"item-duplicate",id:t,at:e})),!0);const i=new Map;for(const e of t)i.set(this._recordKey(e),e);const r=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&r.set(e,t)}const s=this._lastItemIds,o=this.root,a=[];for(const[t,e]of r)i.has(t)||setTimeout(()=>{if(e.parent===this){try{this.removeItem(e,!0)}catch{}zu(e);try{e?.dispose?.()}catch{}}},0);for(const[t,e]of i){if(r.has(t))continue;const n=ku(o,t);let i,c=!1;if(n&&n.parent!==this){if(s.has(t)){const e=n.parent?.state?.id;a.push({code:"item-repeat-report",id:t,holder:null!=e?String(e):null});continue}i=n,c=!!n.parent}else i=this._createItemFromRecord(e);if(!i)continue;i[mn]=e.slotId;const h=c?this.itemMoveAnimation():null,l={...e.slotId?{slotId:e.slotId}:{},...h?{animated:!0,...h}:{}};try{this.handoverIn(i,Object.keys(l).length?l:void 0)}catch{}}for(const[t,e]of i){const n=r.get(t);if(n){if(e.itemState&&"function"==typeof n.setState)try{n.setState(e.itemState)}catch{}if(e.itemType&&n.state?.type!==e.itemType&&"function"==typeof n.setState)try{n.setState({type:e.itemType})}catch{}if(n[mn]!==e.slotId){n[mn]=e.slotId;try{this.handoverIn(n,e.slotId?{slotId:e.slotId}:void 0)}catch{}}}}this._orderItemsAs([...i.keys()]),this._lastItemIds=new Set(i.keys()),this._sayItemIssues(a,!1)}itemMoveAnimation(){return null}_orderItemsAs(t){const e=new Map(t.map((t,e)=>[t,e])),n=this._items.filter(t=>e.has(this._currentKeyOf(t)??"")),i=[...n].sort((t,n)=>e.get(this._currentKeyOf(t))-e.get(this._currentKeyOf(n)));if(i.every((t,e)=>t===n[e]))return;let r=0;for(let t=0;t<this._items.length;t++)e.has(this._currentKeyOf(this._items[t])??"")&&(this._items[t]=i[r++]);const s=this.seatHeldItem;if("function"==typeof s)for(const t of i)s.call(this,t,{slotId:t[mn]})}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,i=[];for(const t of this._items){const e=t[mn];null!=e?n.set(String(e),t):i.push(t)}for(const i of t){const t=n.get(i)??null;e.push(this._slotRecordOf(i,t))}for(const t of i)e.push(this._slotRecordOf("",t));for(const[i,r]of n)t.includes(i)||e.push(this._slotRecordOf(i,r));return e}_recordKey(t){return this._keyedById()?null!=t.itemId?String(t.itemId):"":t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const i of n)i in e&&void 0!==e[i]&&(t[i]=e[i]);return Object.keys(t).length>0?t:void 0}const i={};for(const t of Object.keys(e))Tu.has(t)||t.startsWith("_")||(i[t]=e[t]);return Object.keys(i).length>0?i:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=wu.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}class Ou extends wu{set rotationX(t){this.setState("rotationX",t)}get rotationX(){return this.getState("rotationX")}set rotationY(t){this.setState("rotationY",t)}get rotationY(){return this.getState("rotationY")}set rotationZ(t){this.setState("rotation",t)}get rotationZ(){return this.getState("rotation")}set zPos(t){this.setState("zPos",t)}get zPos(){return this.getState("zPos")}set depth(t){this.setState("depth",t)}get depth(){return this.getState("depth")}postrender(t){this.drawFill(t,void 0),this.drawStroke(t,void 0),super.postrender(t)}render(t){const e=this.drawPath,{round:n=0}=this.state;if(!(e.length<=1)){t.beginPath();for(let i=0;i<e.length;i++){const r=e[(i-1+e.length)%e.length],s=e[(i+e.length)%e.length],o=e[(i+1)%e.length];if(r.x===s.x&&r.y===s.y)continue;const a=Yn(s,n);let c=Math.sqrt((r.x-s.x)*(r.x-s.x)+(r.y-s.y)*(r.y-s.y)),h=0!==c?Math.atan2(r.x-s.x,r.y-s.y):0,l=Math.sin(h)*Math.min(a,c/2)+s.x,u=Math.cos(h)*Math.min(a,c/2)+s.y;const d=a>0||0!==c?{x:l,y:u}:s;c=Math.sqrt((o.x-s.x)*(o.x-s.x)+(o.y-s.y)*(o.y-s.y)),h=0!==c?Math.atan2(o.x-s.x,o.y-s.y):0,l=Math.sin(h)*Math.min(a,c/2)+s.x,u=Math.cos(h)*Math.min(a,c/2)+s.y;const p=a>0||0!==c?{x:l,y:u}:s;if(0==i?t.moveTo(d.x,d.y):t.lineTo(d.x,d.y),a>0&&t.quadraticCurveTo(s.x,s.y,p.x,p.y),Wn(s)){const e=Yn(o,n),i=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),r=0!==i?Math.atan2(s.x-o.x,s.y-o.y):0,a=Math.sin(r)*Math.min(e,i/2)+o.x,c=Math.cos(r)*Math.min(e,i/2)+o.y,h=qn({x:p.x,y:p.y},{x:a,y:c},s.bulge);h&&t.arc(h.cx,h.cy,h.radius,h.startAngle,h.endAngle,h.clockwise)}}t.closePath()}}}function Eu(t){const e=class extends t{contains(t,e){const{left:n,top:i,width:r,height:s,lineWidth:o=0}=this.state,a=o/2;return t<Math.max(n+r,n)+a&&t>Math.min(n+r,n)-a&&e<Math.max(i+s,i)+a&&e>Math.min(i+s,i)-a}set path(t){const e=t[0],n=t[2];this.set({left:e.x,top:e.y,width:n.x-e.x,height:n.y-e.y})}get path(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return{left:t,top:e,width:n,height:i}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){let{round:e=0}=this.model;const{left:n,top:i,width:r,height:s}=this.bounds;t.translate(n,i),t.beginPath(),e=function(t,e,n){return Math.max(0,Math.min(t,Math.min(n,e)/2))}(e,r,s),e>0?t.roundRect(0,0,r,s,e):t.rect(0,0,r,s),t.translate(-n,-i)}};return Ma(e.prototype,"path",!1),Ma(e.prototype,"bounds",!0),e}const ju=new WeakMap,Pu="__canonicalMaterial",Cu="base";function Ru(t){return Math.max(0,Math.round(100*t)/100)}function Fu(t){const e=[];var n;return null!=t.color&&e.push("c:"+(n=t.color,new Nt(n).getHexString())),null!=t.opacityFactor&&Ru(t.opacityFactor)<1&&e.push("o:"+Ru(t.opacityFactor)),e.join("|")}function Du(t,e){const n=Fu(e);if(""===n)return t;let i=ju.get(t);i||ju.set(t,i=new Map);let r=i.get(n);return r||(r=t.clone(),r.userData={__isVariant:!0,[Cu]:t},i.set(n,r)),function(t,e,n){if(null!=n.color&&t.color&&t.color.set(n.color),null!=n.opacityFactor){t.opacity=e.opacity*Ru(n.opacityFactor);const i=t.opacity<1||!!e.transparent;t.transparent!==i&&(t.transparent=i,t.needsUpdate=!0)}}(r,t,e),r}function Nu(t){t.traverse?.(t=>{const e=t.userData?.[Pu];e&&(t.material=e,delete t.userData[Pu])})}!function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n)}({aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"});const Lu=.001,Bu={default:{metalness:0,roughness:.4},metal:{metalness:1,roughness:.3,envMapIntensity:1},glass:{metalness:0,roughness:.1,opacity:.3,envMapIntensity:1.5},plastic:{metalness:0,roughness:.4},wood:{metalness:0,roughness:.8,envMapIntensity:.3},ceramic:{metalness:.1,roughness:.2,envMapIntensity:.3},rubber:{metalness:0,roughness:.9,envMapIntensity:.3}};function Uu(t){if(!t)return{metalness:0,roughness:.4,emissive:"#000000",emissiveIntensity:0,opacity:1,envMapIntensity:.5,side:"double",flatShading:!1,castShadow:!0,receiveShadow:!1};const e=Bu[t.preset??"default"]??Bu.default;return{metalness:t.metalness??e.metalness,roughness:t.roughness??e.roughness,emissive:t.emissive??"#000000",emissiveIntensity:t.emissiveIntensity??0,opacity:t.opacity??e.opacity??1,envMapIntensity:t.envMapIntensity??e.envMapIntensity??.5,side:t.side??"double",flatShading:t.flatShading??!1,castShadow:t.castShadow??!0,receiveShadow:t.receiveShadow??!1}}const Wu=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap"];function qu(t){const e=t.userData;if(!e?.__bankOwned&&!e?.__isVariant){for(const e of Wu){const n=t[e];n?.dispose()}!function(t){const e=ju.get(t);if(e){for(const t of e.values())t.dispose();ju.delete(t)}}(t),t.dispose()}}function $u(t){t.traverse(t=>{const e=t.userData?.dispose;if("function"==typeof e)try{e()}catch{}if(t.geometry&&!0!==t.geometry.userData?.__bankOwned&&t.geometry.dispose(),t.material){const e=Array.isArray(t.material)?t.material:[t.material];for(const t of e)qu(t)}})}function Vu(t,e){e&&(!0===e.mirror&&(t.wrapS=y,t.repeat.x=-t.repeat.x,t.offset.x=1-t.offset.x),e.rotation&&(t.center.set(.5,.5),t.rotation=e.rotation*Math.PI/180))}function Yu(t){const e=function(t,e,n){const i=document.createElement("canvas");i.width=e,i.height=n;const r=i.getContext("2d");if(!r)return null;let s;if("radial"===t.gradientType){const i=e/2,o=n/2,a=Math.max(e,n)/2;switch(t.center){case"left-top":s=r.createRadialGradient(0,0,0,0,0,2*a);break;case"right-top":s=r.createRadialGradient(e,0,0,e,0,2*a);break;case"left-bottom":s=r.createRadialGradient(0,n,0,0,n,2*a);break;case"right-bottom":s=r.createRadialGradient(e,n,0,e,n,2*a);break;default:s=r.createRadialGradient(i,o,0,i,o,a)}}else{const i=t.rotation??0,o=e/2,a=n/2,c=Math.cos(i)*o,h=Math.sin(i)*a;s=r.createLinearGradient(o-c,a-h,o+c,a+h)}const o=Array.isArray(t.colorStops)?t.colorStops:Array.isArray(t.gradientStops)?t.gradientStops:[];for(const t of o)if(t.position>=0&&t.position<=1)try{s.addColorStop(t.position,t.color)}catch{s.addColorStop(t.position,"#fff")}return r.fillStyle=s,r.fillRect(0,0,e,n),i}(t,256,256);if(!e)return;const n=new sn(e);return n.colorSpace=b,n.needsUpdate=!0,n}function Hu(t,e,n){const i=void 0!==e?e:t.state.fillStyle;if(!i||"object"!=typeof i)return;const r=i;if("pattern"===r.type&&r.image)return function(t,e,n){const{width:i,height:r}=t.bounds,s=Math.abs(i)||1,o=Math.abs(r)||1,a=new it;a.colorSpace=b;const c=new Image;"data"!==String(e.image).substring(0,4)&&(c.crossOrigin="anonymous"),c.onload=()=>{if(e.fitPattern){const t=2*s,n=2*o,i=document.createElement("canvas");i.width=t,i.height=n;const r=i.getContext("2d");if(!r)return;e.color&&(r.fillStyle=e.color,r.fillRect(0,0,t,n)),r.drawImage(c,0,0,t,n),a.image=i,a.wrapS=g,a.wrapT=g,a.repeat.set(1,1),a.offset.set(0,0)}else if(e.noRepeat){const t=2*s,n=2*o,i=2*(e.width||c.naturalWidth),r=2*(e.height||c.naturalHeight),h=2*(e.offsetX||0),l=2*(e.offsetY||0);let u=0,d=0;switch(e.align){case"center":u=(t-i)/2,d=(n-r)/2;break;case"left-top":break;case"left-bottom":d=n-r;break;case"right-top":u=t-i;break;case"right-bottom":u=t-i,d=n-r;break;case"left":d=(n-r)/2;break;case"right":u=t-i,d=(n-r)/2;break;case"top":u=(t-i)/2;break;case"bottom":u=(t-i)/2,d=n-r}const p=document.createElement("canvas");p.width=t,p.height=n;const f=p.getContext("2d");if(!f)return;e.color&&(f.fillStyle=e.color,f.fillRect(0,0,t,n)),f.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,h+u,l+d,i,r),a.image=p,a.wrapS=g,a.wrapT=g,a.repeat.set(1,1),a.offset.set(0,0)}else{const t=e.width||c.naturalWidth,n=e.height||c.naturalHeight,i=2*t,r=2*n,h=document.createElement("canvas");h.width=i,h.height=r;const l=h.getContext("2d");if(!l)return;e.color&&(l.fillStyle=e.color,l.fillRect(0,0,i,r)),l.drawImage(c,0,0,i,r);let u=0,d=0;switch(e.align){case"center":u=(s-t)/2,d=(o-n)/2;break;case"left-top":break;case"left-bottom":d=o-n;break;case"right-top":u=s-t;break;case"right-bottom":u=s-t,d=o-n;break;case"left":d=(o-n)/2;break;case"right":u=s-t,d=(o-n)/2;break;case"top":u=(s-t)/2;break;case"bottom":u=(s-t)/2,d=o-n}const p=(e.offsetX||0)+u,f=(e.offsetY||0)+d;a.image=h,a.wrapS=y,a.wrapT=y,a.repeat.set(s/t,o/n),a.offset.set(-p/t,f/n)}a.minFilter=1006,Vu(a,n),a.needsUpdate=!0,t.invalidate()},c.onerror=t=>{wa("Pattern texture load error:",t)};const h=e.image;c.src=t.app.url(h);const l=t.root?.app?.loadTracker;if(l){const t=new Promise((t,e)=>{c.addEventListener("load",()=>t(),{once:!0}),c.addEventListener("error",()=>e(),{once:!0})});l.track(`pattern:${h}`,"pattern",h,t)}return a}(t,r,n);if("gradient"===r.type){if(Array.isArray(r.colorStops)&&r.colorStops.length>0||Array.isArray(r.gradientStops)&&r.gradientStops.length>0){const t=Yu(r);return t&&Vu(t,n),t}}}const Gu={policy:"state-driven"};function Xu(t){return"state-driven"===t.policy}const Zu=0;function Ju(t,e){const n=function(t){return t&&Number.isFinite(t)?{enabled:!0,factor:t,units:t}:{enabled:!1,factor:0,units:0}}(e);t.traverse(t=>{const e=t;if(!e.isMesh&&!t.isLine&&!t.isPoints)return;const i=e.material;if(i)if(Array.isArray(i))for(const t of i)Qu(t,n);else Qu(i,n)})}function Qu(t,e){t.polygonOffset=e.enabled,t.polygonOffsetFactor=e.factor,t.polygonOffsetUnits=e.units,t.needsUpdate=!0}const Ku=Object.freeze(["mm","cm","m","in"]);function td(t){const e=(n=t?.mmPerUnit,"number"==typeof n&&Number.isFinite(n)&&n>0);var n;const i=t?.displayUnit;return{mmPerUnit:e?t.mmPerUnit:1,known:e,displayUnit:Ku.includes(i)?i:"mm"}}const ed=(t,e)=>t/e.mmPerUnit;function nd(t){return td(t?.rootModel?.state)}function id(t,e){for(let n=t.parent;n;n=n.parent)if(n===e)return!0;return!1}function rd(t,e){return-1!==t.findIndex(t=>t in e)}const sd=()=>{};class od{static buildFillStyleTexture(t,e,n){return Hu(t,e,n)}constructor(t){this._focused=!1,this._suppressOnchange=!1,this._onchangeWrapper=(t,e,n)=>{this._suppressOnchange||n&&n.origin&&n.origin!==this._component||this.onchange(t,e)},this.suppressTransform=!1,this._dimensionScale={x:1,y:1,z:1},this._component=t,this.object3d=this.getObject3dInstance(),this.component.on("change",this._onchangeWrapper)}update(){this.clear(),this.build(),this.layoutHeldItems(),this.updateTransform(),this.updateFillStyle(),this.updateStrokeStyle(),this.updateAlpha(),this.applyFocusDim(),this.updateHidden(),this.updateText(),this._applyZPriority(),this._applyRaycastTarget()}_applyZPriority(){const t=this.component.state?.zPriority,e="number"==typeof t&&Number.isFinite(t)?t:this.zPriority;0!==e&&Ju(this.object3d,e)}get zPriority(){return Zu}getObject3dInstance(){return new jt}build(){this.object3d.userData.context=this;const t=Uu(this.component.state.material3d),{cast:e,receive:n}=this.resolveShadow(t.castShadow,t.receiveShadow);this._applyShadow(e,n),this.object3d.name=this.component.state.id}updateMaterial3d(){const t=Uu(this.component.state.material3d),{cast:e,receive:n}=this.resolveShadow(t.castShadow,t.receiveShadow);this._applyShadow(e,n)}resolveShadow(t=!0,e=!1){return{cast:t,receive:e}}_applyShadow(t,e){const n=i=>{i.castShadow=t,i.receiveShadow=e;for(const t of i.children){const e=t.userData?.context;e&&e!==this||n(t)}};n(this.object3d)}get gizmoTransformable(){return!0}get allowedGizmoModes(){return null}get component(){return this._component}get threeContainer(){let t=this.component;for(;t;){if("is3dContainer"in t&&t.is3dContainer())return t;t=t.parent}}get focused(){return this._focused}set focused(t){this._focused=t,t&&(this._focusedAt=performance.now())}dispose(){this.component.off("change",this._onchangeWrapper),this.clear()}clear(){for(const t of this.component?._items??[]){const e=t?._realObject?.object3d;e?.parent&&e.parent!==this.object3d&&id(e,this.object3d)&&e.removeFromParent()}const t=[];for(const e of this.object3d.children){const n=e.userData?.context;n&&n!==this&&n instanceof od?t.push(e):(Nu(e),$u(e))}this._components3D=void 0,this.object3d.userData={},this.object3d.clear();for(const e of t)this.object3d.add(e);return this.object3d}get placement(){return this._transientPlacement??Gu}setTransientPlacement(t){this._transientPlacement=t}clearTransientPlacement(){this._transientPlacement=void 0}layoutHeldItems(){const t=this.component,e=t?._items??[];if(0===e.length||"function"!=typeof t.placementFor)return;const n=new Set((t.slots??[]).map(t=>t?.id)),i=new Set((t.outsideSlots?.()??[]).map(t=>t?.id));let r=0;for(const s of e){const e=s?._transferSlotId;if(null!=e&&i.has(e)){s?._realObject?.object3d&&t.seatHeldItem?.(s,{slotId:e});continue}if(null!=e&&n.has(e)){s?._realObject?.object3d&&t.seatHeldItem?.(s,{slotId:e});continue}const o=s?._realObject?.object3d;if(!o){r++;continue}const a=t.placementFor(s,{index:r,occupantCount:r});r++,a?.position&&(o.parent!==this.object3d&&this.object3d.attach(o),o.position.set(a.position.x,a.position.y,a.position.z),a.rotation?o.quaternion.set(a.rotation.x,a.rotation.y,a.rotation.z,a.rotation.w):o.quaternion.identity())}}updateTransform(){if(this.suppressTransform)return;if(!Xu(this.placement))return;if(this.component.state.screenFixed&&this.component.isHTMLElement()){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{};return this.object3d.position.set(t-n/2,-(e-i/2),0),void this.object3d.rotation.set(0,0,0)}const{x:t,y:e,z:n}=this.position,{x:i,y:r,z:s}=this.rotation,{x:o,y:a,z:c}=this.scale;this.object3d.position.set(t,e,n),this.object3d.rotation.set(i,r,s),this.applyScale(o,a,c)}get position(){const{x:t,y:e,z:n}=this.center;return{x:t,y:n,z:e}}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:n=0}=this.component.state;return{x:t,y:-n,z:e}}get scale(){const{scale:t}=this.component.state,e="number"==typeof t?t:t?.x??1;return{x:e,y:e,z:e}}get cx(){const{x:t=0}=this.component.center,{width:e=0}=this.component.parent?.bounds??{},{tx:n=0}=this.component.delta();return t+n-e/2}get cy(){const{y:t=0}=this.component.center,{height:e=0}=this.component.parent?.bounds??{},{ty:n=0}=this.component.delta();return t+n-e/2}get cz(){const t=this.effectiveZPos,{tz:e=0}=this.component.delta(),n=this.component.parent?._realObject,i=n?.geometricOffsetY??0,r=n?.receivingSurfaceY??0;return t+e+this.syncZPosOffset-i+r}get receivingSurfaceY(){return 0}surfaceAtLocalY(t){return t+this.geometricOffsetY}placementSurfaceY(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return this.surfaceAtLocalY(0);case"inverted":return this.surfaceAtLocalY(-t);default:return this.surfaceAtLocalY(t)}}get effectiveZPos(){const t=this.component.state.zPos;if("number"==typeof t&&Number.isFinite(t))return t;const e=this.component.effectiveZPos;return"number"==typeof e&&Number.isFinite(e)?e:0}get geometricOffsetY(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get scenePlacement(){const t=this.component.rootModel??this.component,e=t?.state?.placement;return"space"===e||"inverted"===e?e:"floor"}get sceneHeights(){return function(t){const e=t?.rootModel??t,n=e?.state?.heights,i="number"==typeof n?.floor&&Number.isFinite(n.floor)?n.floor:0,r=td(e?.state),s=(e?.components??[]).find(t=>"number"==typeof t?.workEnvironmentCeiling);if(s&&Number.isFinite(s.workEnvironmentCeiling))return{floor:ed(i,r),ceiling:s.workEnvironmentCeiling};const o="number"==typeof n?.ceiling&&Number.isFinite(n.ceiling)?n.ceiling:3e3;return{floor:ed(i,r),ceiling:ed(o,r)}}(this.component)}get placementMode(){return this.scenePlacement}get components3D(){return this._components3D&&this._components3D.parent===this.object3d||(this._components3D=new Pt,this.object3d.add(this._components3D)),this._components3D.position.y=-this.geometricOffsetY,this._components3D}get center(){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{},{tx:r=0,ty:s=0}=this.component.delta();return{x:t+r-n/2,y:e+s-i/2,z:this.cz}}freezeDimension(){this._frozenDimension={...this.dimension}}unfreezeDimension(){delete this._frozenDimension}get dimension(){if(this._frozenDimension)return this._frozenDimension;const{width:t,height:e}=this.component.bounds;return{width:Math.abs(t)||1,height:Math.abs(e)||1,depth:this.effectiveDepth}}get effectiveDepth(){const t=this.component.state.depth;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const e=this.component.effectiveDepth;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:1}updatePosition(){const{x:t=0,y:e=0,z:n=0}=this.position;this.object3d.position.set(t,e,n)}updateRotate(){const{x:t=0,y:e=0,z:n=0}=this.rotation;this.object3d.rotation.set(t,e,n)}get dimensionScale(){return this._dimensionScale}setDimensionScale(t,e,n){Number.isFinite(t)&&Number.isFinite(e)&&Number.isFinite(n)&&(this._dimensionScale={x:t,y:e,z:n},this.updateScale())}applyScale(t,e,n){const i=this.restingScale();this.object3d.scale.set(Math.max(t*i.x,Lu),Math.max(e*i.y,Lu),Math.max(n*i.z,Lu))}restingScale(){const t=this._dimensionScale,e=this.displayScale,n=this._nodeScale??{x:1,y:1,z:1};return{x:t.x*e/n.x,y:t.y*e/n.y,z:t.z*e/n.z}}get displayScale(){return this._displayScale??1}setTransientDisplayScale(t,e){if(!(Number.isFinite(t)&&t>0))return;const n=e&&[e.x,e.y,e.z].every(t=>Number.isFinite(t)&&t>0)?{...e}:this._nodeScale;var i,r;t===this.displayScale&&(i=n,r=this._nodeScale,(i?.x??1)===(r?.x??1)&&(i?.y??1)===(r?.y??1)&&(i?.z??1)===(r?.z??1))||(this._displayScale=t,this._nodeScale=n,this.updateScale())}updateScale(){const{x:t=1,y:e=1,z:n=1}=this.scale;this.applyScale(t,e,n)}syncAnimationDelta(){if(this.suppressTransform)return;const t=this.component.delta();this.updatePosition();const{rotationX:e=0,rotationY:n=0,rotation:i=0}=this.component.state,r=t.theta||0,s=t.rx||0,o=t.ry||0,a=t.rz||0;this.object3d.rotation.set(e+s,-(i+r)+o,n+a);const{scale:c}=this.component.state,h="number"==typeof c?c:c?.x??1,l=t.sx??1,u=t.sy??1,d=t.sz??1;this.applyScale(h*l,h*u,h*d);const p=t.fade||0;if(0!==p){const t=(this.component.state.alpha??1)*(1-p);this.object3d.traverse(e=>{if(e.isMesh&&e.material){const n=Array.isArray(e.material)?e.material:[e.material];for(const e of n)e.opacity=t,e.transparent=e.opacity<1}})}}updateDimension(){this.clear(),this.build()}updateAlpha(){this.applyMaterialOpacity()}isModelingFaint(){return Th(this.component)}applyMaterialOpacity(){const t=this.component.state.alpha,e=null==t?1:t,n=this.isModelingFaint(),i=t=>{t.material&&function(t,e,n){if(!t.material)return;let i=t.userData[Pu];i||(i=t.material,t.userData[Pu]=i);const r=t=>{const i=t?.userData?.[Cu]??t;return n?Du(i,{opacityFactor:.5}):e<1?Du(i,{color:t.color,opacityFactor:e}):t};t.material=Array.isArray(i)?i.map(r):r(i)}(t,e,n);for(const e of t.children){const t=e.userData?.context;t&&t!==this&&t instanceof od||i(e)}};i(this.object3d)}applyFocusDim(){this.applyMaterialOpacity()}updateHidden(){const t=this.component.app;if(t?.isEditMode)return this.object3d.visible=!0,void this.applyFocusDim();this.object3d.visible=!this.component.state.hidden}updateStrokeStyle(){}updateFillStyle(){}updateText(){}topOutline(){return null}_applyRaycastTarget(){const t=this.component.state.raycastTarget;let e;if("boolean"==typeof t)e=t;else{const t=this.component.constructor;e=!1!==t.raycastTargetDefault}const n=t=>{const i=t.userData?.context;if(t===this.object3d||!i||i===this){t.userData?.alwaysRaycast||(e?delete t.raycast:t.raycast=sd);for(const e of t.children)n(e)}};n(this.object3d)}get syncZPosOffset(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get textSurfaceYOffset(){return this.effectiveDepth-this.syncZPosOffset}syncFromObject3D(){const t=this.object3d,e=this._component,{width:n=0,height:i=0}=e.parent?.bounds??{},r=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0,e.bounds={left:t.position.x-s+n/2-r.width/2,top:t.position.z-o+i/2-r.height/2,width:r.width,height:r.height};const c=this.component.parent?._realObject,h=c?.geometricOffsetY??0;e.set({zPos:t.position.y-a-this.syncZPosOffset+h,rotationX:t.rotation.x,rotation:-t.rotation.y,rotationY:t.rotation.z}),this._suppressOnchange=!1}onGizmoDragEnd(t){}applyDimensionFromGizmo(t){this._suppressOnchange=!0,this._component.set(t),this._suppressOnchange=!1}onchange(t,e){if("screenFixed"in t&&this.updateTransform(),rd(["cx","cy","cz","zPos","left","top"],t)&&!this.suppressTransform&&Xu(this.placement)&&this.updatePosition(),rd(["width","height","depth","lineWidth","round","rx","ry","rz"],t)&&(this.updateDimension(),"depth"in t)){this.updatePosition();const t=this.component.components;if(t)for(const e of t){const t=e?._realObject;t?.updateTransform&&t.updateTransform()}}if(rd(["segments","heightSegments"],t)&&this.update(),rd(["rotationX","rotationY","rotation"],t)&&this.updateRotate(),"scale"in t&&this.updateScale(),"hidden"in t&&this.updateHidden(),"alpha"in t&&this.updateAlpha(),"strokeStyle"in t&&this.updateStrokeStyle(),"fillStyle"in t&&this.updateFillStyle(),rd(["text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline"],t))this._lastText=this.component.hasTextProperty?this.component.text:"",this.updateText();else if(rd(["value","data"],t)){const t=this.component.hasTextProperty?this.component.text:"";t!==this._lastText&&(this._lastText=t,this.updateText())}"material3d"in t&&this.updateMaterial3d(),"raycastTarget"in t&&this._applyRaycastTarget()}}const ad=new Map;function cd(t){return t.userData.__bankOwned=!0,t}const hd={primitive(t){const e="primitive::"+function(t){switch(t.kind){case"cylinder":return`cylinder|${t.segments??0}`;case"sphere":return`sphere|${t.segments??0}|${t.heightSegments??0}`;default:return t.kind}}(t);let n=ad.get(e);return n||ad.set(e,n=cd(function(t){switch(t.kind){case"box":return new on(1,1,1);case"plane":return new cn(1,1);case"cylinder":return new an(.5,.5,1,t.segments??16);case"sphere":return new hn(.5,t.segments??16,t.heightSegments??Math.max(2,Math.round((t.segments??16)/2)))}}(t))),n},shaped(t,e){const n="shaped::"+t;let i=ad.get(n);return i||ad.set(n,i=cd(e())),i},owns:t=>!0===t.userData?.__bankOwned,get size(){return ad.size},has:t=>ad.has("primitive::"+t)||ad.has("shaped::"+t),dispose(){for(const t of ad.values())t.dispose();ad.clear()}};let ld=null;const ud=new Set;let dd=null;function pd(){for(const t of[...ud]){const e=t.deref();e?e.refreshLook():ud.delete(t)}}function fd(t){dd?.(),ld=t,dd=t?t.subscribe(pd):null,pd()}function md(t){return ld?.dimsOf(t)??null}const yd=t=>Number(t.component.state.depth)||t.depth,gd="#9e9e9e";class bd extends(Eu(Ou)){constructor(){super(...arguments),this._look=null,this._lookKey=null,this._seatDims=null}get itemTypeCode(){return this.state.type}get drawnAsItem(){return!0}get isItem(){return!0}is3dish(){return!0}get lookNow(){return this._look}get look(){this._lookRef||ud.add(this._lookRef=new WeakRef(this));const t=ld?.keyFor(this)??null;return(t!==this._lookKey||t&&!this._look)&&(this._look?.dispose(),this._look=t?ld?.lookFor(this)??null:null,this._lookKey=this._look?t:null,this.fitLook()),this._look}get seatDims(){return this._seatDims}takeSeatDims(t){var e,n;(e=t,n=this._seatDims,e===n||e&&n&&e.width===n.width&&e.depth===n.depth&&e.height===n.height)||(this._seatDims=t?{...t}:null,this.sized||(this.fitLook(),this._realObject?.rebuildLook?.(),this.invalidate?.()))}fitLook(){this._look&&!this.sized&&this._seatDims&&this._look.fitTo(this._seatDims)}refreshLook(){const t=ld?.keyFor(this)??null;if(t===this._lookKey&&(!t||this._look))return;this._look?.dispose(),this._look=null,this._lookKey=null;const e=this._realObject;if(e&&e instanceof xd!==this.drawnAsItem){const t=this.parent;t?.trigger?.("item-remake",t,this),t?._reseatSlot?.(this[mn])}else e?.rebuildLook?.();this.invalidate?.()}onchange(t,e){super.onchange?.(t,e),"type"in t&&(this.refreshLook(),this.parent?._reseatSlot?.(this[mn])),"data"in t&&this._look&&this._look.component.set("data",t.data)}get sized(){const{width:t=0,height:e=0,depth:n=0}=this.state;return t>0&&e>0&&n>0}get shownSize(){if(this.sized){const{width:t,height:e,depth:n}=this.state;return{width:t,height:e,depth:n}}const t=nd(this).mmPerUnit;if(this._seatDims)return{width:this._seatDims.width/t,height:this._seatDims.depth/t,depth:this._seatDims.height/t};const e=this.look;if(e)return{width:Number(e.component.state.width)||0,height:Number(e.component.state.height)||0,depth:yd(e)};const n=200/t;return{width:n,height:n,depth:n}}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;if(n>0&&i>0)return super.bounds;const r=this.shownSize;return{left:t,top:e,width:r.width,height:r.height}}render(t){const{left:e,top:n,width:i,height:r}=this.bounds,s=this.look;if(s){const o=s.component,a={left:e+(i-(Number(o.state.width)||0))/2,top:n+(r-(Number(o.state.height)||0))/2};return o.state.left===a.left&&o.state.top===a.top||o.set(a),void o.render(t)}t.save(),t.fillStyle=this.state.fillStyle||gd,t.strokeStyle=this.state.strokeStyle||"#616161",t.lineWidth=1,this.sized||t.setLineDash([4,3]),t.beginPath(),t.rect(e,n,i,r),this.sized&&t.fill(),t.stroke(),t.restore()}buildRealObject(){return this.drawnAsItem?new xd(this):void 0}dispose(){this._lookRef&&ud.delete(this._lookRef),this._look?.dispose(),this._look=null,super.dispose()}}class xd extends od{constructor(){super(...arguments),this.box=null,this.shown=null}getObject3dInstance(){return new Pt}build(){super.build(),this.rebuildLook()}rebuildLook(){this.box&&(this.object3d.remove(this.box),this.box.material.dispose(),this.box=null),this.shown&&(this.object3d.remove(this.shown),this.shown=null);const t=this.component,e=t.look,n=t.shownSize;if(e){const t=e.component.realObject,i=t?.object3d;if(!t||!i)return;return t.suppressTransform=!0,i.position.set(0,(yd(e)-n.depth)/2,0),i.quaternion.identity(),this.object3d.add(i),void(this.shown=i)}const i=new nn(hd.primitive({kind:"box"}),new ln({color:t.state.fillStyle||gd,wireframe:!t.sized&&!t.seatDims}));i.scale.set(n.width,n.depth,n.height),this.object3d.add(i),this.box=i}dispose(){const t=this.component.lookNow,e=t?.component._realObject;e&&(e.dispose(),t.component._realObject=void 0),super.dispose(),this.component._realObject===this&&(this.component._realObject=void 0)}clear(){return this.box=null,this.shown=null,super.clear()}}const vd="item-types",wd=64,_d=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function Md(t){if(!_d(t)||!Array.isArray(t.types))return{types:new Map,issues:[{code:"item-types-shape"}]};const e=[],n=new Map;t.types.forEach((t,i)=>{const r=_d(t)?t:{},s=r.code;if("string"!=typeof s||!s||s!==s.trim()||s.length>64)return e.push({code:"item-type-code",at:i});const o=r.figure;if(null!=o&&("string"!=typeof o||!o))return e.push({code:"item-type-figure",at:i});const a="string"==typeof r.name&&r.name?r.name:s,c=n.get(s);c?c.at.push(i):n.set(s,{type:{code:s,name:a,figure:o??null},at:[i]})});const i=new Map;for(const[t,{type:r,at:s}]of n)s.length>1?e.push({code:"item-type-duplicate",id:t,at:s}):i.set(t,r);return{types:i,issues:e}}function Sd(t,e=vd){const n=(t??[]).filter(t=>t?.type===e&&t.active);if(0===n.length)return{types:new Map,issues:[]};if(n.length>1)return{types:new Map,issues:[{code:"item-types-active-many",names:n.map(t=>String(t.name??""))}]};let i=n[0].value;if("string"==typeof i)try{i=JSON.parse(i)}catch{return{types:new Map,issues:[{code:"item-types-shape"}]}}return Md(i)}function kd(t){return _d(t)&&t.types instanceof Map&&Array.isArray(t.issues)}function Ad(t){const e=t?.root;return e&&e!==t?e.itemTypes:t?.itemTypes}function zd(t,e){const n=e?.itemTypeCode??e?.state?.type??e?.type;return"string"==typeof n?t.types.get(n)??null:null}class Td extends Error{code;path;details;constructor(t,e,n,i){super(`${t}: ${e}: ${n}`),this.name="FigureContractError",this.code=t,this.path=e,void 0!==i&&(this.details=i)}}function Id(t,e,n){return n?{code:t,path:e,params:n}:{code:t,path:e}}const Od="holder",Ed=t=>"number"==typeof t&&Number.isFinite(t),jd=t=>Ed(t)&&t>0,Pd=t=>Number.isSafeInteger(t)&&t>0;function Cd(t,e,n){const i=t?.allowed;if(i&&"object"==typeof i)for(const t of["width","depth","height"])jd(i[t])||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else n.push(Id("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||Pd(t.stackLimit)||t.stackLimit===1/0||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||Ed(t.rotation)||n.push(Id("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||n.push(Id("ARRAY_REQUIRED",`${e}.accepts`))}function Rd(t,e={}){const n=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Id("TIERS_REQUIRED","tiers")];const i=e.anchors?new Set(e.anchors):null,r=new Set;return t.tiers.forEach((t,e)=>{const s=`tiers[${e}]`;if(!t||"object"!=typeof t)return void n.push(Id("OBJECT_REQUIRED",s));if(Pd(t.tierNo)?r.has(t.tierNo)?n.push(Id("TIER_NUMBER_DUPLICATE",`${s}.tierNo`,{tierNo:t.tierNo})):r.add(t.tierNo):n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?i&&!i.has(t.anchorId)&&n.push(Id("ANCHOR_UNKNOWN",`${s}.anchorId`,{anchorId:t.anchorId})):n.push(Id("ANCHOR_REQUIRED",`${s}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||n.push(Id("MOUNT_INVALID",`${s}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])Ed(t.position[e])||n.push(Id("FINITE_NUMBER_REQUIRED",`${s}.position.${e}`));else n.push(Id("OBJECT_REQUIRED",`${s}.position`));Ed(t.rotation)||n.push(Id("FINITE_NUMBER_REQUIRED",`${s}.rotation`));const o=t.layout;switch(o?.pattern){case"SINGLE":Cd(o.slot,`${s}.layout.slot`,n);break;case"ROW":Pd(o.count)||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.layout.count`)),jd(o.pitch)||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch`)),"X"!==o.axis&&"Z"!==o.axis&&n.push(Id("AXIS_INVALID",`${s}.layout.axis`)),Cd(o.slot,`${s}.layout.slot`,n);break;case"GRID":Pd(o.rows)||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.layout.rows`)),Pd(o.cols)||n.push(Id("POSITIVE_INTEGER_REQUIRED",`${s}.layout.cols`)),jd(o.pitch?.x)||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch.x`)),jd(o.pitch?.z)||n.push(Id("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch.z`)),Cd(o.slot,`${s}.layout.slot`,n);break;case"CUSTOM":{if(!Array.isArray(o.slots)){n.push(Id("ARRAY_REQUIRED",`${s}.layout.slots`));break}o.slots.length||n.push(Id("SLOTS_REQUIRED",`${s}.layout.slots`));const t=new Set;o.slots.forEach((e,i)=>{const r=`${s}.layout.slots[${i}]`;Pd(e?.slotNo)?t.has(e.slotNo)?n.push(Id("SLOT_NUMBER_DUPLICATE",`${r}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):n.push(Id("POSITIVE_INTEGER_REQUIRED",`${r}.slotNo`)),Ed(e?.offset?.x)&&Ed(e?.offset?.z)||n.push(Id("FINITE_NUMBER_REQUIRED",`${r}.offset`)),Cd(e,r,n)});break}default:n.push(Id("PATTERN_INVALID",`${s}.layout.pattern`))}}),n}function Fd(t,e=""){const n=[],i=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,n)=>i(t,`${e}[${n}]`));else if(t&&"object"==typeof t)for(const[n,r]of Object.entries(t))i(r,e?`${e}.${n}`:n)}else n.push(Id("NOT_PERSISTABLE",e,{value:String(t)}))};return i(t,e),n}function Dd(t){switch(t.pattern){case"SINGLE":return 1;case"ROW":return t.count;case"GRID":return t.rows*t.cols;case"CUSTOM":return t.slots.length}}function Nd(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:Dd(t)},(t,e)=>e+1)}function Ld(t,e,n,i,r="ROW_MAJOR"){switch(r){case"ROW_MAJOR":return(n-1)*e+i;case"COL_MAJOR":return(i-1)*t+n;case"SERPENTINE_ROW":return(n-1)*e+(n%2==1?i:e-i+1);case"SERPENTINE_COL":return(i-1)*t+(i%2==1?n:t-n+1)}}function Bd(t,e,n,i="ROW_MAJOR"){const r=n-1;switch(i){case"ROW_MAJOR":return{r:Math.floor(r/e)+1,c:r%e+1};case"COL_MAJOR":return{r:r%t+1,c:Math.floor(r/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(r/e)+1,n=r%e+1;return{r:t,c:t%2==1?n:e-n+1}}case"SERPENTINE_COL":{const e=Math.floor(r/t)+1,n=r%t+1;return{r:e%2==1?n:t-n+1,c:e}}}}const Ud=(t,e)=>e&&0!==t?-t:t;function Wd(t,e,n={}){const i=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!i||!Pd(e.slot))return null;const r=i.layout;let s,o,a;switch(r.pattern){case"SINGLE":if(1!==e.slot)return null;s=r.slot,o={x:0,z:0};break;case"ROW":{if(e.slot>r.count)return null;const t=Ud((e.slot-1-(r.count-1)/2)*r.pitch,"MAX"===r.origin);s=r.slot,o="X"===r.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>r.rows*r.cols)return null;const{r:t,c:n}=Bd(r.rows,r.cols,e.slot,r.order),i=r.origin??{x:"MIN",z:"MIN"};s=r.slot,o={x:Ud((n-1-(r.cols-1)/2)*r.pitch.x,"MAX"===i.x),z:Ud((t-1-(r.rows-1)/2)*r.pitch.z,"MAX"===i.z)};break}case"CUSTOM":{const t=r.slots.find(t=>t.slotNo===e.slot);if(!t)return null;s=t,o={...t.offset},a=t.name;break}}return{tier:i.tierNo,slotNo:e.slot,name:a,anchorId:i.anchorId,mount:i.mount,tierPosition:{...i.position},tierRotation:i.rotation,offset:o,allowed:{...s.allowed},accepts:s.accepts?[...s.accepts]:void 0,stackLimit:s.stackLimit??n.defaultStackLimit??1,rotation:s.rotation??0}}function qd(t){return`t${t.tier}_s${t.slot}`}function $d(t){const e="string"==typeof t?/^t(\d+)_s(\d+)$/.exec(t):null;return e?{tier:Number(e[1]),slot:Number(e[2])}:null}function*Vd(t){for(const e of t?.tiers??[])for(const t of Nd(e.layout))yield{tier:e.tierNo,slot:t}}function Yd(t,e,n){if(!n)return{x:t,z:e};const i=n*Math.PI/180,r=Math.cos(i),s=Math.sin(i),o=t=>Math.round(1e9*t)/1e9;return{x:o(t*r+e*s),z:o(-t*s+e*r)}}function Hd(t){const e=Yd(t.offset.x,t.offset.z,t.tierRotation);return{position:{x:t.tierPosition.x+e.x,y:t.tierPosition.y,z:t.tierPosition.z+e.z},rotation:t.tierRotation+t.rotation}}const Gd=.05,Xd=t=>!!t&&jd(t.width)&&jd(t.depth)&&jd(t.height);function Zd(t,e){const n=e*Math.PI/180,i=Math.abs(Math.cos(n)),r=Math.abs(Math.sin(n)),s=t=>Math.round(1e9*t)/1e9;return{width:s(t.width*i+t.depth*r),depth:s(t.width*r+t.depth*i)}}function Jd(t,e,n=0,i=.05){if(!Xd(t))return null;if(!Ed(n)||!Ed(i)||i<0||i>=1)return null;const r=Zd(t,e.rotation),s=Math.min(1,Math.min(e.allowed.width/r.width,e.allowed.depth/r.depth)*(1-i)),o=t.height*s;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(n+o/2),z:0},rotation:0,scale:s}}function Qd(t,e,n=0,i=.05){const r=Jd(t,e,n,i);if(!r)return null;const s=Hd(e);return{position:{x:s.position.x,y:s.position.y+r.position.y,z:s.position.z},rotation:s.rotation,scale:r.scale}}function Kd(t,e,n=.05){let i=0;return t.map(t=>{const r=t?Qd(t,e,i,n):null;return r&&(i+=t.height*r.scale),r})}const tp=1e-6;function ep(t,e){const n=Hd(t),i=t.allowed.width/2,r=t.allowed.depth/2,s=[[-i,-r],[i,-r],[i,r],[-i,r]].map(([t,e])=>{const i=Yd(t,e,n.rotation);return{x:n.position.x+i.x,z:n.position.z+i.z}}),o=Yd(1,0,n.rotation),a=Yd(0,1,n.rotation),c="HANG"===t.mount?-1:1,h=[n.position.y,n.position.y+c*t.allowed.height],l=s.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:s,axes:[o,a],y0:Math.min(...h),y1:Math.max(...h),minX:Math.min(...l),maxX:Math.max(...l)}}function np(t,e){for(const n of[...t.axes,...e.axes]){const i=t.corners.map(t=>t.x*n.x+t.z*n.z),r=e.corners.map(t=>t.x*n.x+t.z*n.z);if(Math.min(Math.max(...i),Math.max(...r))-Math.max(Math.min(...i),Math.min(...r))<=tp)return!1}return!0}function ip(t,e={}){const n=[],i=new Map;t.tiers.forEach((e,n)=>{const r=i.get(e.anchorId)??[];i.set(e.anchorId,r);for(const i of Nd(e.layout))r.push(ep(Wd(t,{tier:e.tierNo,slot:i}),n))});for(const[t,r]of i){const i=e.anchorFaces?.[t];if(i)for(const t of r)t.corners.some(t=>Math.abs(t.x)-i.width/2>tp||Math.abs(t.z)-i.depth/2>tp)&&n.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else n.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const s=[...r].sort((t,e)=>t.minX-e.minX);for(let t=0;t<s.length;t++){const e=s[t];for(let i=t+1;i<s.length&&s[i].minX<e.maxX-tp;i++){const t=s[i];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=tp)continue;if(!np(e,t))continue;const[r,o]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];n.push({code:"SLOT_OVERLAP",path:`tiers[${o.tierIndex}]`,params:{tier:o.tier,slot:o.slot,otherTier:r.tier,otherSlot:r.slot}})}}}return n}function rp(t,e,n=[],i={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const r=i.normalizeType??(t=>null==t?"":String(t)),s=[];let o=!1;if(t.accepts){const n=r(e.type);n?t.accepts.map(r).includes(n)||s.push("TYPE_NOT_ACCEPTED"):o=!0}if(n.length+1>t.stackLimit&&s.push("STACK_LIMIT_EXCEEDED"),Xd(e.dims)){const i=Zd(e.dims,t.rotation);if(i.width>t.allowed.width&&s.push("WIDTH_EXCEEDED"),i.depth>t.allowed.depth&&s.push("DEPTH_EXCEEDED"),n.every(t=>Xd(t.dims))){n.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&s.push("HEIGHT_EXCEEDED")}else o=!0}else o=!0;return s.length?{verdict:"NG",reasons:o?[...s,"SPEC_UNKNOWN"]:s}:o?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}function sp(t){const e=(t,e,n)=>{throw new Td("ITEM_SNAPSHOT",t,e,n)},n=t;n&&"object"==typeof n&&"string"==typeof n.revision&&Array.isArray(n.items)||e("snapshot","a revision and a list of items",{reason:"item-snapshot-shape"});const i=new Set,r=new Map;n.items.forEach((t,n)=>{const s=`items[${n}]`;t&&"string"==typeof t.itemId&&t.itemId&&"string"==typeof t.slotId&&t.slotId||e(s,"an item id and a slot id",{reason:"item-snapshot-shape"}),(!Number.isSafeInteger(t.stackIndex)||t.stackIndex<0)&&e(`${s}.stackIndex`,"a whole number from 0",{reason:"item-snapshot-shape"}),void 0!==t.type&&"string"!=typeof t.type&&e(`${s}.type`,"a type name",{reason:"item-snapshot-shape"}),void 0===t.dims||t.dims&&["width","depth","height"].every(e=>{return"number"==typeof(n=t.dims[e])&&Number.isFinite(n)&&t.dims[e]>0;var n})||e(`${s}.dims`,"three positive numbers in mm",{reason:"item-invalid-dimensions",item:t.itemId}),i.has(t.itemId)&&e(s,`${t.itemId} is in the snapshot twice`,{reason:"item-duplicate",item:t.itemId}),i.add(t.itemId),r.set(t.slotId,[...r.get(t.slotId)??[],t.stackIndex])});for(const[t,n]of r){const i=[...n].sort((t,e)=>t-e);i.forEach((n,r)=>{n!==r&&e("items",`the stack in ${t} has ${i.join(", ")}; each height once, from 0`,{reason:"item-stack-index",slot:t,heights:i})})}}function op(t,e,n){const i=null!=e?{source:"override",raw:e}:t?{source:"figure",raw:t}:void 0;if(!i)return{source:"none",status:"none",issues:[]};const r=function(t,e){const n=Rd(t,{anchors:[...e]});if(n.length)return n;const i=Fd(t);if(i.length)return i;const r=[],s=t=>Array.isArray(t)&&0===t.length;return t.tiers.forEach((t,e)=>{const n=t.layout;"CUSTOM"===n.pattern?n.slots.forEach((t,n)=>s(t.accepts)&&r.push(Id("ACCEPTS_EMPTY",`tiers[${e}].layout.slots[${n}].accepts`))):s(n.slot.accepts)&&r.push(Id("ACCEPTS_EMPTY",`tiers[${e}].layout.slot.accepts`))}),r}(i.raw,n);return r.length?{source:i.source,status:"invalid",issues:r,refusal:{code:"SLOT_LAYOUT",details:{reason:"slot-layout-issues",issues:r}}}:{source:i.source,status:"valid",layout:i.raw,issues:[]}}function ap(t,e){const n=new Map;for(const i of t._items??[]){if(e&&i===e.item)continue;const t=i?.[mn];"string"==typeof t&&t&&(n.get(t)??n.set(t,[]).get(t)).push(i)}return e&&(n.get(e.slotId)??n.set(e.slotId,[]).get(e.slotId)).push(e.item),n}function cp(t,e=""){return hp(t,ap(t),e).snapshot}function hp(t,e,n){const i=new Map,r=new Set,s=[];let o=0;for(const[n,a]of e)a.forEach((e,a)=>{let c=Su(e);c&&!r.has(c)||(c=`#${o}`),o++,r.add(c),i.set(e,c);const h=t.itemTypeOf?.(e)??null,l=t.itemDimsOf?.(e)??null;s.push({itemId:c,slotId:n,stackIndex:a,...h?{type:h}:{},...l?{dims:l}:{}})});return{snapshot:{revision:n,items:s},ids:i}}function lp(t){return{tier:0,slotNo:0,anchorId:t.anchorId,mount:t.mount??"ON",tierPosition:{...t.frame.position},tierRotation:t.frame.rotation,offset:{x:0,z:0},allowed:{width:1/0,depth:1/0,height:1/0},stackLimit:1/0,rotation:0}}function up(t,e){const n=Hd(t),i=e?.position.y??0;return{position:{x:n.position.x,y:n.position.y+i,z:n.position.z},rotation:n.rotation,scale:e?.scale??1}}function dp(t,e,n,i,r,s){if(!t.itemShownDimsOf)return;let o=0;for(const a of i){const i=r.get(a),c=t.itemDimsOf?.(a)??("seated"===i.status?null:t.itemShownDimsOf(a,n,e)),h="seated"===i.status?i.inSlot:c?Jd(c,n,o,s):null;if(!h||!c)return;o+=c.height*h.scale,"seated"!==i.status&&r.set(a,{...i,inSlot:h,inAnchor:up(n,h),shrunk:h.scale<1,dims:c})}}function pp(t,e){const n=t.effectiveLayout?.layout,i=new Map((t.outsideSlots?.()??[]).map(t=>[t.id,t])),r=ap(t,e),s=new Map,o=new Map;for(const[e,n]of r){const r=i.get(e);if(!r){o.set(e,n);continue}const a=lp(r);let c=0,h=!0;n.forEach((n,i)=>{const o=t.itemDimsOf?.(n)??null,l={slotId:e,stackIndex:i,outside:!0,anchorId:r.anchorId,shrunk:!1,dims:o},u=h&&o?Jd(o,a,c,0):null;if(!u){const t=h?"size-unknown":"below-unknown";return h=!1,s.set(n,{...l,status:"unconfirmed",why:t,inSlot:null,inAnchor:up(a,null)})}c+=o.height,s.set(n,{...l,status:"seated",inSlot:u,inAnchor:up(a,u)})}),dp(t,e,a,n,s,0)}const{snapshot:a,ids:c}=hp(t,o,""),h=new Map(function(t,e,n={}){sp(e);const i=n.margin??Gd,r=new Map;for(const t of e.items)r.set(t.slotId,[...r.get(t.slotId)??[],t]);const s=new Map;for(const[e,o]of r){const r=[...o].sort((t,e)=>t.stackIndex-e.stackIndex),a=t?$d(e):null,c=a?Wd(t,a):null;let h=0,l=!0;r.forEach((t,o)=>{const a=rp(c,{type:t.type,dims:t.dims??null},r.slice(0,o).map(t=>({type:t.type,dims:t.dims??null})),n.normalizeType?{normalizeType:n.normalizeType}:{}),u={itemId:t.itemId,slotId:e,stackIndex:t.stackIndex,fit:a};if(!c)return s.set(t.itemId,{...u,status:"unplaced",why:"slot-absent",seat:null,shrunk:!1});if(!l)return s.set(t.itemId,{...u,status:"unconfirmed",why:"below-unknown",seat:null,shrunk:!1});const d=t.dims?Jd(t.dims,c,h,i):null;if(!d)return l=!1,s.set(t.itemId,{...u,status:"unconfirmed",why:"size-unknown",seat:null,shrunk:!1});h+=t.dims.height*d.scale,s.set(t.itemId,{...u,status:"seated",seat:d,shrunk:d.scale<1})})}return e.items.map(t=>s.get(t.itemId))}(n,a).map(t=>[t.itemId,t]));for(const[e,i]of c){const r=h.get(i),o=n?$d(r.slotId):null,a=o?Wd(n,o):null;s.set(e,{slotId:r.slotId,stackIndex:r.stackIndex,status:r.status,...r.why?{why:r.why}:{},fit:r.fit,outside:!1,anchorId:a?.anchorId??null,inSlot:r.seat,inAnchor:a&&"unplaced"!==r.status?up(a,r.seat):null,shrunk:r.shrunk,dims:t.itemDimsOf?.(e)??null})}for(const[e,i]of o){const r=n?$d(e):null,o=r?Wd(n,r):null;o&&dp(t,e,o,i,s,Gd)}return s}const fp=[{id:"__default__",maxCount:1/0}];function mp(t){const e={id:qd({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function yp(t,e,n){const i=t.itemTypeOf?t.itemTypeOf(n):n?.state?.type??n?.type;return e.accepts?!!i&&e.accepts.includes(i):!e.allowedTypes?.length||!!i&&e.allowedTypes.includes(i)}function gp(t){var e;return e=class extends t{get slotLayout(){}get effectiveLayout(){const t=this.slotLayout,e=this.state?.slotLayout,n=this.slotAnchors(),i=n.join("\n"),r=this.__effectiveLayout;if(r&&r.declared===t&&r.override===e&&r.anchors===i)return r.value;const s=op(t,e,n);return this.__effectiveLayout={declared:t,override:e,anchors:i,value:s},s}slotAnchors(){return[Od]}anchorObject3D(t){const e=this._realObject?.object3d;return t===Od&&e?function(t){let e=t.userData.itemAnchor;if(!e||e.parent!==t){const n=new Pt;n.name="item-anchor";const i=n.updateMatrix.bind(n);n.updateMatrix=()=>{const t=n.parent?.scale;t&&n.scale.set(1/(t.x||1),1/(t.y||1),1/(t.z||1)),i()},t.add(n),t.userData.itemAnchor=n,e=n}return e.updateMatrix(),e}(e):null}outsideSlots(){return[]}itemTypeOf(t){const e=Ad(this);if(e)return zd(e,t)?.code??null;const n=t?.state?.type??t?.type;return"string"==typeof n&&n?n:null}get mmPerSceneUnit(){return nd(this).mmPerUnit}itemDimsOf(t){const e=function(t,e){const[n,i,r]=[Number(t?.state?.width),Number(t?.state?.height),Number(t?.state?.depth)];return[n,i,r].every(t=>Number.isFinite(t)&&t>0)?{width:n*e,depth:i*e,height:r*e}:null}(t,this.mmPerSceneUnit);return e||(Ad(this)?null:md(t))}itemShownDimsOf(t,e,n){if(!Ad(this))return null;const{width:i,depth:r,height:s}=e.allowed;if(![i,r,s].every(t=>Number.isFinite(t)&&t>0))return md(t);return{width:i,depth:r,height:s/(Number.isFinite(e.stackLimit)&&e.stackLimit>0?e.stackLimit:1)}}itemSeatOf(t,e){const n=e??t?.[mn];if("string"!=typeof n||!n)return null;return pp(this,t?.[mn]===n&&this._items?.includes(t)?void 0:{item:t,slotId:n}).get(t)??null}get slots(){const t=this.effectiveLayout.layout;if(!t)return[];const e=[];for(const n of Vd(t)){const i=Wd(t,n);i&&e.push(mp(i))}return e}slotById(t){const e=this.outsideSlots().find(e=>e.id===t);if(e)return{id:e.id,maxCount:1/0};const n=this.effectiveLayout.layout;if(n){const e=$d(t),i=e?Wd(n,e):null;return i?mp(i):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,n=0,i){const r=this.effectiveLayout.layout,s=r?$d(t):null,o=s?Wd(r,s):null,a=o?Qd(e,o,n,i):null;return a?{...a,anchorId:o.anchorId}:null}get arrangementStrategy(){return f}canReceive(t,e){const n=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return Sn.log({role:"target",contract:"canReceive",component:this,args:{carrier:dn(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:fp;for(const n of e){if(!yp(this,n,t))continue;const e=n.maxCount??this.arrangementStrategy.capacity(n),i=this._countOccupied(n.id);if(!(i>=e))return Sn.log({role:"target",contract:"findSlot",component:this,args:{carrier:dn(t)},result:{slotId:n.id,occupied:i,max:e}}),n}return Sn.log({role:"target",contract:"findSlot",component:this,args:{carrier:dn(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const n=this._realObject?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const i=new N;n.getWorldQuaternion(i);const r=new N(e.x,e.y,e.z,e.w);return i.clone().multiply(r)}deliveryWorldPosition(t){const e=this._realObject,n=e?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const i=new L;n.getWorldPosition(i);const r=this._receivingSurfaceLocalY();if(null!==r){const t=new L(0,r,0);return n.localToWorld(t),{x:i.x,y:t.y,z:i.z}}return{x:i.x,y:i.y,z:i.z}}attachPointFor(t,e){const n=e?.slotId??t?.[mn];if(!n)return null;if("none"!==this.effectiveLayout.status||this.outsideSlots().length){const e=this.itemSeatOf(t,n),i=e?.anchorId&&e.inAnchor?this.anchorObject3D(e.anchorId):null;if(!e||!i)return null;const r=this.mmPerSceneUnit,s=e.inAnchor;return{attach:i,localPosition:{x:s.position.x/r,y:s.position.y/r,z:s.position.z/r},localRotation:{x:0,y:s.rotation*Math.PI/180,z:0},carryPolicy:"slot",displayScale:s.scale,slotId:n,seat:e}}const i=this.slots.find(t=>t.id===n);return i?{position:i.localPosition??{x:0,y:0,z:0},rotation:i.localRotation??{x:0,y:0,z:0},slotId:i.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,i=n?n.state??{}:t??{},r={width:Number(i.width)||0,height:Number(i.height)||0,depth:Number(i.depth)||0},s=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!s)return null;const o=e.index??this._countOccupied(s.id),a=e.occupantCount??o,c=this.arrangementStrategy.positionAt(o,s,a,n??{state:{...r}});if(!c)return null;const h=Number(this.state?.width)||0,l=Number(this.state?.height)||0,u=c.x+r.width/2-h/2,d=c.y+r.height/2-l/2,p=this._realObject,f=p?.placementMode??"floor",m="space"===f?0:"inverted"===f?-r.depth/2:r.depth/2,y=this._receivingSurfaceLocalY();let g;g=null!==y?y+m:s.localPosition&&Number.isFinite(s.localPosition.z)?s.localPosition.z+m:m-(p?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??r,s)??void 0;return b?{position:{x:u,y:g,z:d},rotation:b}:{position:{x:u,y:g,z:d}}}_zPosFromSeatY(t,e,n){const i=this._realObject,r=i?.receivingSurfaceY??0,s=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===r&&!s)return null;const o=Number(e)||0,a=i?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-o/2:o/2)+(i?.geometricOffsetY??0)-r}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!yp(this,t,e))return null;const n=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<n?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[mn]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[mn]===t).length:0}},e.__hasCapacity=!0,e}function bp(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return[];const o="number"==typeof t.rotation?t.rotation:0,a=Math.cos(o),c=Math.sin(o),h=n+r/2,l=i+s/2,u="inbound"===e?-1:1;return[{lx:-r/2,lz:0,odx:-1,odz:0},{lx:r/2,lz:0,odx:1,odz:0},{lx:0,lz:-s/2,odx:0,odz:-1},{lx:0,lz:s/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:h+e*a-n*c,z:l+e*c+n*a}),direction:{x:u*(t.odx*a-t.odz*c),z:u*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?s/2:r/2}})}function xp(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return{inbounds:[],outbounds:[]};const o="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&r<s,h=n+r/2,l=i+s/2,u=c?s/2:r/2,d=c?0:1,p=c?1:0,f=Math.cos(o),m=Math.sin(o),y=(t,e)=>({x:h+t*f-e*m,z:l+t*m+e*f}),g=c?{lx:0,lz:-u}:{lx:-u,lz:0},b=c?{lx:0,lz:u}:{lx:u,lz:0},x=y(g.lx,g.lz),v=y(b.lx,b.lz),w={x:d*f-p*m,z:d*m+p*f},_=Math.hypot(w.x,w.z)||1,M={x:w.x/_,z:w.z/_},S={x:-M.x,z:-M.z},k=(c?r:s)/2;return a?{inbounds:[{worldPos:v,direction:S,halfSpan:k}],outbounds:[{worldPos:x,direction:S,halfSpan:k}]}:{inbounds:[{worldPos:x,direction:M,halfSpan:k}],outbounds:[{worldPos:v,direction:M,halfSpan:k}]}}function vp(t){const e=t.left??0,n=t.top??0,i=t.width??0,r=t.height??0;if(i<=0||r<=0)return null;const s="number"==typeof t.rotation?t.rotation:0,o="vertical"===t.orientation||"horizontal"!==t.orientation&&i<r,a=e+i/2,c=n+r/2,h=o?r/2:i/2,l=Math.cos(s),u=Math.sin(s),d=(t,e)=>({x:a+t*l-e*u,z:c+t*u+e*l});return{start:o?d(0,-h):d(-h,0),end:o?d(0,h):d(h,0)}}function wp(t){const e=t.cx??0,n=t.cy??0,i=Math.abs(t.rx??100),r=Math.abs(t.ry??100),s=t.ratio??50,o=(i+i*s/100)/2,a=(r+r*s/100)/2,c=t.startAngle??0,h=t.endAngle??Math.PI/2,l="reverse"===t.status;if(i<=0||r<=0)return{inbounds:[],outbounds:[]};const u={x:e+o*Math.sin(c),z:n-a*Math.cos(c)},d={x:e+o*Math.sin(h),z:n-a*Math.cos(h)},p={x:Math.cos(c),z:Math.sin(c)},f={x:Math.cos(h),z:Math.sin(h)};return l?{inbounds:[{worldPos:d,direction:{x:-f.x,z:-f.z}}],outbounds:[{worldPos:u,direction:{x:-p.x,z:-p.z}}]}:{inbounds:[{worldPos:u,direction:p}],outbounds:[{worldPos:d,direction:f}]}}function _p(t){const e=xp(t),n=e.outbounds[0];if(!n)return{inbounds:bp(t,"inbound"),outbounds:[]};const i=bp(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,i=t.worldPos.z-n.worldPos.z;return Math.hypot(e,i)>1}),r=n.direction,s=[];for(const t of i){const e=t.direction.x*r.x+t.direction.z*r.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+r.x,i=t.direction.z+r.z,o=Math.hypot(n,i)||1;s.push({worldPos:t.worldPos,direction:{x:n/o,z:i/o},halfSpan:t.halfSpan})}return{inbounds:[...i,...s],outbounds:e.outbounds}}function Mp(t,e,n={}){const i=n.distance??5,r=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<r)return!1;const s=t.worldPos.x-e.worldPos.x,o=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,r=t.direction.z;if(Math.abs(s*n+o*r)>i)return!1;const a=Math.abs(s*-r+o*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(s,o)<=i}function Sp(t,e,n,i=0){const r=n.width??0,s=n.height??0;if(r<=0||s<=0)return!1;const o=(n.left??0)+r/2,a=(n.top??0)+s/2,c="number"==typeof n.rotation?n.rotation:0,h=Math.cos(-c),l=Math.sin(-c),u=t-o,d=e-a,p=u*h-d*l,f=u*l+d*h;return Math.abs(p)<=r/2+i&&Math.abs(f)<=s/2+i}function kp(t,e,n){const i=n.width??0,r=n.height??0;if(i<=0||r<=0)return 1/0;const s=(n.left??0)+i/2,o=(n.top??0)+r/2;let a=t.x-s,c=t.z-o,h=e.x,l=e.z;const u="number"==typeof n.rotation?n.rotation:0;if(0!==u){const t=Math.cos(-u),e=Math.sin(-u),n=a*e+c*t,i=h*e+l*t;a=a*t-c*e,c=n,h=h*t-l*e,l=i}const d=i/2,p=r/2;let f=-1/0,m=1/0;if(Math.abs(h)<1e-9){if(a<-d||a>d)return 1/0}else{const t=(-d-a)/h,e=(d-a)/h;f=Math.max(f,Math.min(t,e)),m=Math.min(m,Math.max(t,e))}if(Math.abs(l)<1e-9){if(c<-p||c>p)return 1/0}else{const t=(-p-c)/l,e=(p-c)/l;f=Math.max(f,Math.min(t,e)),m=Math.min(m,Math.max(t,e))}return m<f?1/0:f>=0?f:m>=0?Math.min(-f,m):-m}function Ap(t,e,n,i=6){return!!Sp(t.worldPos.x,t.worldPos.z,e,i)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function zp(t,e,n){return t.outbounds.map(t=>{const i=[];for(const r of e){let e=null;for(const i of r.topology.inbounds){if(!Mp(t,i,n))continue;const r=t.worldPos.x-i.worldPos.x,s=t.worldPos.z-i.worldPos.z,o=Math.hypot(r,s);(null===e||o<e)&&(e=o)}if(null===e&&r.bounds){const i=r.topology.outbounds[0]?.direction,s=!(r.topology.outbounds&&r.topology.outbounds.length)?n?.sinkMargin??30:6;if(Ap(t,r.bounds,i,s)){const n=kp(t.worldPos,t.direction,r.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(r.bounds.left??0)+(r.bounds.width??0)/2,i=(r.bounds.top??0)+(r.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-i)+1e3}}}null!==e&&i.push({id:r.id,dist:e})}return 0===i.length?null:(i.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),i[0].id)})}function Tp(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const i=new Map,r=new Set;for(const n of t){const s=t.filter(t=>t.id!==n.id),o=zp(n.topology,s,e);i.set(n.id,o);for(const t of o)null!=t&&r.add(t)}const s=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const s=i.get(t)??[];s.includes(e)||(s.push(e),i.set(t,s),r.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])s(e.id,t);for(const t of e.links.upstream??[])s(t,e.id)}const o=new Set,a=new Set;for(const e of t){(i.get(e.id)??[]).some(t=>null!=t)||o.add(e.id),r.has(e.id)||a.add(e.id)}return{nodes:n,out:i,sinks:o,sources:a}}function Ip(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const i=new Set([e]);for(const r of function(t,e,n){const i=n.get(e);if(i)return i;const r=new Set,s=[e],o=new Set([e]);for(;s.length;){const e=s.shift();for(const n of t.out.get(e)??[])null!=n&&(r.add(n),o.has(n)||(o.add(n),s.push(n)))}return n.set(e,r),r}(t,e,n))i.add(r);return i})}function Op(t,e,n,i){return e===n?0:function(t,e,n){const i=n.get(e);if(i)return i;const r=new Map([[e,0]]),s=[e];for(;s.length;){const e=s.shift(),n=r.get(e);for(const i of t.out.get(e)??[])null==i||r.has(i)||(r.set(i,n+1),s.push(i))}return n.set(e,r),r}(t,e,i).get(n)??1/0}function Ep(t,e,n){const i=t.out.get(e)??[],r=new Map,s=[];for(let e=0;e<i.length;e++){const o=i[e];if(null==o)continue;const a=o===n?0:Op(t,o,n,r);a!==1/0&&s.push({i:e,hops:1+a})}return s.sort((t,e)=>t.hops-e.hops||t.i-e.i),s.map(t=>t.i)}function jp(t,e,n){const i=Ep(t,e,n);return i.length?i[0]:-1}function Pp(t,e,n){return e===n||Ep(t,e,n).length>0}function Cp(t,e){const n=new Set;for(const i of Ip(t,e))for(const e of i)t.sinks.has(e)&&n.add(e);return n}function Rp(t,e,n){return Fp(t,e,n).map(t=>t.index)}function Fp(t,e,n){const i=n instanceof Set?n:new Set(n);if(0===i.size)return[];const r=t.out.get(e)??[],s=new Map,o=[...i].sort(),a=[];for(let e=0;e<r.length;e++){const n=r[e];if(null==n)continue;let i=1/0,c="";for(const e of o){const r=1+(n===e?0:Op(t,n,e,s));r<i&&(i=r,c=e)}i!==1/0&&a.push({index:e,hops:i,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Dp(t,e={}){const n=[],i=e.loopCapableIds??new Set,r=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const i=t.nodes.get(e);if(!i||!i.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(r.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const s=function(t){const e=[],n=[...t.nodes.keys()].sort(),i=new Set,r=[],s=new Set,o=n=>{i.add(n),r.push(n),s.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(s.has(a)){const t=r.indexOf(a),n=r.slice(t),i=n.indexOf([...n].sort()[0]),s=[...n.slice(i),...n.slice(0,i)],o=s.join("→");e.some(t=>t.join("→")===o)||e.push(s)}else i.has(a)||o(a);r.pop(),s.delete(n)};for(const t of n)i.has(t)||o(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of s){t.some(t=>i.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const o=e.routingWeights;if(o)for(const[t,e]of[...o].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...r].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Np(t,e){if(!t)return[];const n=[],i=new Set,r=t=>{if(!t||i.has(t))return;if(i.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,i=t.refid??t.state?.refid,r="string"==typeof e&&e.length>0?e:null!=i?String(i):void 0;if(r)try{const e=t.getSegmentTopology(),i=t.state??{},s={left:i.left,top:i.top,width:i.width,height:i.height,rotation:i.rotation};e&&n.push({id:r,topology:e,bounds:s})}catch{}}const s=t?.components;if(Array.isArray(s))for(const t of s)r(t)};return r(t),n}function Lp(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const i=t.getSegmentTopology();if(!i||0===i.outbounds.length)return null;const r=zp(i,Np(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of r)if(t)return t;return null}function Bp(t){return!!t&&"function"==typeof t.routingConstraints}function Up(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Wp(t,e=16){const n=[],i=t.parent??t.rootModel??t.root;if(!i)return n;const r=Lp(t);if(!r)return n;const s=Vp(i,r);if(!s)return n;const o=[{segment:s,accumulated:{},pathIds:[r],visited:new Set([r])}];for(;o.length>0;){const t=o.shift();if(t.pathIds.length>e)continue;const r=Bp(t.segment)?t.segment.routingConstraints():null;if(r&&r.length>0)for(const e of r)for(const r of e.candidates){const s=qp(t.accumulated,r);if(!s)continue;const a=$p(t.segment,e.portId,i);a&&!t.visited.has(a.state?.id??"")?o.push({segment:a,accumulated:s,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:s,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Up(t.segment)){const e=t.segment.acceptedCarrierData(),i=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:i});else for(const r of e){const e=qp(t.accumulated,r);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:i})}continue}const e=Lp(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const r=Vp(i,e);if(!r)continue;o.push({segment:r,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function qp(t,e){const n={...t};for(const[t,i]of Object.entries(e)){if(t in n&&n[t]!==i)return null;n[t]=i}return n}function $p(t,e,n){if("straight"===e&&t.state?.downstreamRef)return Vp(n,t.state.downstreamRef);const i=Vp(n,e);if(i)return i;const r=Lp(t);return r?Vp(n,r):null}function Vp(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,i=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const r=t.components;if(Array.isArray(r))for(const t of r){const e=i(t);if(e)return e}return null};return i(t)}function Yp(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function Hp(t,e,n=5,i=[],r=n){const s=t.length,o=new Array(s).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,h=[],l=new Map,u=[],d=new Map;for(const t of i){const e=Array.isArray(t),n=e?t:t.positions,i=e?void 0:t.kind;if(!n.length)continue;const r=h.length;h.push({pos:n[0],members:[]});for(const t of n)u.push({pos:t,pt:r});i&&d.set(r,i)}const p=(t,e)=>{const i=c(t,e),r=l.get(`${t}:${"end"===e?"start":"end"}`),s=[];for(const t of u)Yp(t.pos,i)<=n&&!s.includes(t.pt)&&s.push(t.pt);for(let t=0;t<h.length;t++)Yp(h[t].pos,i)<=n&&!s.includes(t)&&s.push(t);let o=s.find(t=>t!==r)??-1;o<0&&(o=h.length,h.push({pos:i,members:[]})),h[o].members.push({seg:t,end:e}),l.set(`${t}:${e}`,o)};for(let t=0;t<s;t++)p(t,"start"),p(t,"end");const f=new Set,m=new Set,y=new Set;{const t=t=>{let e=-1,n=1/0;for(let i=0;i<h.length;i++){const r=Yp(h[i].pos,t);r<n&&(n=r,e=i)}for(const i of u){const r=Yp(i.pos,t);r<n&&(n=r,e=i.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:i}=t(n.pos);e>=0&&i<=r&&(f.add(e),("source"===n.kind?m:y).add(e))}}for(const[t,e]of d)f.add(t),("source"===e?m:y).add(t);const g=(t,e)=>"end"===e!==o[t],b=[],x=(e,n)=>{if(void 0===o[e])return o[e]=n,void b.push(e);o[e]!==n&&a.add(t[e].id)},v=t=>{for(const e of["start","end"]){const n=l.get(`${t}:${e}`);if(void 0===n)continue;const i=h[n];if(2!==i.members.length||f.has(n))continue;const r=i.members[0],s=r.seg===t&&r.end===e?i.members[1]:r;if(s.seg===t)continue;const a="end"===e!==o[t],c="end"===s.end!==!a;x(s.seg,c)}},w=()=>{for(;b.length;)v(b.shift())},_=t=>{let e=-1,n="start",i=1/0;for(let r=0;r<s;r++)for(const s of["start","end"]){const o=Yp(c(r,s),t.pos);o<i&&(i=o,e=r,n=s)}if(e<0||i>r)return;const o="source"===t.kind?"end"===n:"start"===n;x(e,o)};for(const t of e)"source"===t.kind&&_(t);w();for(const t of e)"sink"===t.kind&&_(t);w();let M=!0;for(;M;){M=!1;for(const t of h){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===o[t.seg]);if(1!==e.length)continue;let n=0,i=0;for(const e of t.members)void 0!==o[e.seg]&&(g(e.seg,e.end)?n++:i++);const r=e[0];let s;0===i&&n>0?s="end"===r.end:0===n&&i>0&&(s="start"===r.end),void 0!==s&&(o[r.seg]=s,b.push(r.seg),w(),M=!0)}}if(o.some(t=>void 0===t)&&m.size>0&&y.size>0){const t=t=>{const e=new Array(h.length).fill(1/0),n=[];for(const i of t)e[i]=0,n.push(i);for(;n.length;){const t=n.shift();for(const i of h[t].members){const r=l.get(`${i.seg}:${"start"===i.end?"end":"start"}`);void 0!==r&&e[r]>e[t]+1&&(e[r]=e[t]+1,n.push(r))}}return e},e=t(m),n=t(y);for(let t=0;t<s;t++){if(void 0!==o[t])continue;const i=l.get(`${t}:start`),r=l.get(`${t}:end`);if(void 0===i||void 0===r)continue;if(h[i].members.length<2||h[r].members.length<2)continue;if(e[i]===1/0||e[r]===1/0||n[i]===1/0||n[r]===1/0)continue;let s;e[i]!==e[r]?s=e[i]<e[r]:n[i]!==n[r]&&(s=n[r]<n[i]),void 0!==s&&(o[t]=!s,b.push(t))}w()}const S=new Map;for(let e=0;e<s;e++)S.set(t[e].id,void 0===o[e]?"unknown":o[e]?"reverse":"forward");return{directions:S,conflicts:[...a]}}function Gp(...t){}function Xp(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function Zp(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*Jp(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*Jp(t)}function Qp(t,e,n){const i=e.width??0,r=e.height??0;if(i<=0||r<=0)return!1;const s=(e.left??0)+i/2,o=(e.top??0)+r/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-s,h=t.z-o,l=Math.cos(-a),u=Math.sin(-a),d=c*l-h*u,p=c*u+h*l;return Math.abs(d)<=i/2+n&&Math.abs(p)<=r/2+n}function Kp(t){const e=[],n=[],i=[],r=[];for(const s of Jp(t)){const t=Zp(s);if(!t)continue;if(s.flowOrientable){const n=vp(s.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof s.openings){const t=s.state??{};(t.width??0)>0&&(t.height??0)>0&&r.push(t);continue}let o;try{o=s.getSegmentTopology()}catch{continue}if(!o)continue;const a=o.inbounds??[],c=o.outbounds??[],h="function"==typeof s.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||h))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&i.push({positions:t})}}for(const t of r){const r=[];for(const n of e)for(const e of[n.start,n.end])Qp(e,t,16)&&r.push(e);let s=!1,o=!1;for(const e of n)Qp(e.pos,t,16)&&("sink"===e.kind?s=!0:o=!0);const a=s&&!o?"sink":o&&!s?"source":void 0;(r.length>=2||a&&r.length>=1)&&i.push({positions:r,kind:a})}if(0===e.length||0===n.length)return e.length,n.length,new Map;const s=Hp(e,n,8,i,60).directions;return e.length,n.length,i.length,[...s].map(([t,e])=>`#${t}:${e}`).join(" "),s}function tf(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:Kp(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const i=Zp(t),r=i?n.map.get(i):void 0;return"reverse"===r||"forward"!==r&&void 0}function ef(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function nf(t,e,n,i){if(!t||!e)return null;const r=[],s=t=>{if(!t||t===i)return;if(function(t,e){const n=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(n)&&n.includes(e)}(t,e)&&ef(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(t);e&&r.push({id:e,component:t,distance:t.distanceToBoardPoint(n.x,n.y)})}const o=t.components;if(Array.isArray(o))for(const t of o)s(t)};return s(t),0===r.length?null:(r.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),r[0])}function rf(t){return!!t&&"function"==typeof t.routingDestination}function sf(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*of(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*of(t)}function af(t){const e=[],n=new Map,i=new Map,r=new Set,s=[];for(const o of of(t)){"function"==typeof o?.registerWithHost&&s.push(o);const t="function"==typeof o?.getSegmentTopology,a="function"==typeof o?.routingLinks?o.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||rf(o)||c||ef(o)))continue;const h=sf(o);if(!h)continue;let l={inbounds:[],outbounds:[]};if(t){try{l=o.getSegmentTopology()}catch{continue}if(!l)continue}const u=o.state??{},d={left:u.left,top:u.top,width:u.width,height:u.height,rotation:u.rotation};if(e.push({id:h,topology:l,bounds:d,links:a}),i.set(h,o),rf(o)){r.add(h);const t=o.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(h),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:i,routingTargetIds:r,stationClients:s}}function cf(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:i,components:r,routingTargetIds:s,stationClients:o}=af(t),a=Tp(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const i=[...e].sort((t,e)=>{const n=sf(t)??"",i=sf(e)??"";return n.localeCompare(i)});for(const e of i){const n=e.declaredHostRef?.();let i=null;if(n&&(i=t.findById?.(n)??null),!i){const n=e.hostCapability?.(),r=e.hostFacingPoint?.();n&&r&&(i=nf(t,n,r,e)?.component??null)}i&&"function"==typeof e.registerWithHost&&e.registerWithHost(i)}const r=e=>{if(!e)return;if(ef(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const i=t.findById?.(n);i&&e.registerDivertStation(n,i)}const n=e.components;if(Array.isArray(n))for(const t of n)r(t)};r(t)}(t,o);const c=new Set;for(const[t,e]of r){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const h=new Map;for(const t of s){const e=r.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&h.set(t,n)}}const l=Dp(a,{routingTargetIds:s,loopCapableIds:c,routingWeights:h});if(l.length>0&&"undefined"!=typeof console){const t=l.filter(t=>"error"===t.severity),e=l.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,l):console.info(`[FlowGraph] ${e.length} warning(s):`,l)}e={graph:a,destToSinks:i,components:r,issues:l},t.__flowGraph=e}return e}function hf(t){return cf(t)?.issues??[]}function lf(t){const e=cf(t);return e&&e.graph.nodes.size>0?e.graph:null}function uf(t,e){return cf(t)?.destToSinks.get(e)??[]}function df(t,e){return cf(t)?.components.get(e)}function pf(t){const e=cf(t);return e?[...e.destToSinks.keys()]:[]}function ff(t){return sf(t)}function mf(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function yf(t,e,n,i,r){if(1===i.length)return i[0];switch(t){case"index":default:return i[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),i[t%i.length]}case"weight":{const t=i.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(r.get(t.target))),s=t.reduce((t,e)=>t+e,0);if(s<=0)return i[0];const o=n.counters.get(e)??0;n.counters.set(e,o+1);let a=o%s;for(let e=0;e<i.length;e++){if(a<t[e])return i[e];a-=t[e]}return i[i.length-1]}case"utilization":{let t=1/0,e=i[0];for(const n of i){const i=mf(r.get(n.target));i<t&&(t=i,e=n)}return e}}}function gf(t,e,n){const i=t?.root;if(!i)return null;const r=e?.state?.meta?.destination;if("string"!=typeof r||0===r.length)return null;const s=cf(i);if(!s||0===s.graph.nodes.size)return null;const o=sf(t);if(!o)return null;let a=s.destToSinks.get(r)??[];0===a.length&&(a=[r]);const c=Fp(s.graph,o,a);if(0===c.length)return null;const h=s.graph.out.get(o)??[],l=c.filter(t=>{const n=h[t.index],i=n?s.components.get(n):null;return!i||"function"!=typeof i.canReceive||i.canReceive(e)});if(0===l.length)return h[c[0].index]??null;const u=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const i=e?.state?.routingBalancingPolicy;return i||"round-robin"}(t,i),d=yf(u,o,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(i),l,s.components);return h[d.index]??null}n({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slotLayout","get slots","slotById","slotSeatTransform","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),n({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,lf(t)}catch{return null}}}catch{}function bf(t,e,n){const i=gf(t,e,n);if(null==i)return null;const r=t?.root,s=df(r,i)??r?.findById?.(i)??null;return s?{targetId:i,component:s,origin:"explicit"}:null}function xf(t){const e=t?.root,n=lf(e),i=ff(t);if(!n||!i)return null;const r=(n.out.get(i)??[]).find(Boolean);if(!r)return null;const s=df(e,r)??e?.findById?.(r)??null;return s?{id:r,component:s}:null}function vf(t){const e=ff(t);return e?wf(t?.root,e):[]}function wf(t,e){if(!t||!e)return[];const n=lf(t);if(!n)return[];const i=new Set;for(const r of Cp(n,e)){const e=df(t,r);if(rf(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&i.add(t)}}return[...i]}function _f(t,e){if(!t||!e)return[];const n=lf(t);if(!n)return[];const i=new Map;for(const t of n.out.values())for(const e of t)null!=e&&i.set(e,(i.get(e)??0)+1);const r=new Map;for(const s of Cp(n,e)){const e=df(t,s);if(!rf(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let o=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(o=t)}null===o&&(o=i.get(s)??0,0===o&&(o=1)),r.set(n,(r.get(n)??0)+o)}return[...r].map(([t,e])=>({value:t,weight:e}))}function Mf(t){return lf(t)}function Sf(t){const e=lf(t);if(!e)return[];const n=new Set,i=new Set,r=t=>{if(!t)return;const s=ff(t);if(s&&e.nodes.has(s)){rf(t)&&n.add(s);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&i.add(s)}const o=t.components;if(Array.isArray(o))for(const t of o)r(t)};return r(t),Dp(e,{routingTargetIds:n,loopCapableIds:i})}function kf(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let i=0;for(const e of t)if(i+=e.weight,n<i)return e.value;return t[t.length-1].value}const Af={next:bf,downstream:xf,reachableDestinations:vf,reachableDestinationsFrom:wf,reachableDestinationsWeightedFrom:_f,pickWeightedDestination:kf,graphFor:Mf,validate:Sf};function zf(t){try{t()}catch(t){_a("[holdable] a listener of a handover failed; the handover stands",t)}}function Tf(t){if(!t?.traverse||!t.matrixWorld)return null;t.updateWorldMatrix(!0,!0);const e=t.matrixWorld.clone().invert(),n=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];return t.traverse(t=>{const r=t.isMesh?t.geometry:null;if(!r)return;r.boundingBox||r.computeBoundingBox?.();const s=r.boundingBox;if(!s)return;const o=t.matrixWorld.clone().premultiply(e),a=s.min.constructor;for(const t of[s.min.x,s.max.x])for(const e of[s.min.y,s.max.y])for(const r of[s.min.z,s.max.z]){const s=new a(t,e,r).applyMatrix4(o);[s.x,s.y,s.z].forEach((t,e)=>{n[e]=Math.min(n[e],t),i[e]=Math.max(i[e],t)})}}),Number.isFinite(n[0])?{x:i[0]-n[0],y:i[1]-n[1],z:i[2]-n[2]}:null}function If(t){let e=0;for(let n=t;n&&!n.isRootModel?.();n=n.parent)e+=n.state?.rotation||0;return e}function Of(t){const e=t?.shownSize;return e&&[e.width,e.height,e.depth].every(Number.isFinite)?{...e}:null}function Ef(t,e){if("function"!=typeof t?.toScene)return null;try{const n=t.bounds,i=t.center,r=t.toScene(i.x,i.y),s={x:r.x,y:r.y,rotation:If(e),width:n.width,height:n.height};return Object.values(s).every(Number.isFinite)?s:null}catch{return null}}function jf(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const i=t.prototype?.attachPointFor;return"function"==typeof i?i.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,t.delegate_on?.(this),Au(this,t),!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n)if(this._items.splice(n,1),t.parent=null,t.delegate_off?.(this),this._reseatSlot(t[mn]),e)t._realObject?.setTransientDisplayScale?.(1);else{if(zu(t),function(t){const e=t?._realObject?.object3d;if(!e?.parent)return;let n=e.parent;for(;n.parent;)n=n.parent;n!==e.parent&&(n.updateWorldMatrix?.(!0,!1),e.updateWorldMatrix?.(!0,!1),n.attach(e))}(t),t._realObject?.setTransientDisplayScale?.(1,{x:1,y:1,z:1}),"function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=e?.slotId,i=e?.toParent3D,r=i?null:this.attachPointFor?.(t,{slotId:n}),s=e?.animated?function(t){const e=t?._realObject?.object3d;let n=null;if(e?.parent){e.updateWorldMatrix(!0,!1);const t=e.position.clone(),i=e.quaternion.clone(),r=e.scale.clone();e.matrixWorld.decompose(t,i,r),n={position:t,quaternion:i,scale:r}}return{world3D:n,world2D:t?.parent?Ef(t,t.parent):null,shown:Of(t),content:n?Tf(e):null}}(t):null,o=t.parent,a=o===this?t[mn]:void 0;o&&("function"==typeof o.removeComponent&&-1!==o._components?.indexOf?.(t)&&o.removeComponent(t,!0),o!==this&&"function"==typeof o.removeItem&&-1!==o._items?.indexOf?.(t)&&o.removeItem(t,!0));const c=-1===this._items.indexOf(t);c&&(this._items.push(t),t.delegate_on?.(this)),t.parent=this,void 0!==n&&(t[mn]=n),Au(this,t);const h=!!t._realObject?.object3d;h&&this.seatHeldItem(t,{toParent3D:i,slotId:n,point:r}),void 0!==a&&a!==t[mn]&&this._reseatSlot(a),c&&zf(()=>this.trigger?.("hold",this,t,this._items.length-1)),h||this.seatHeldItem(t,{toParent3D:i,slotId:n,point:r}),zf(()=>t.held?.(this)),s&&function(t,e,n,i){const r=t.root?.transitionEffect;if(!r)return;const s=i.duration??2e3,o=i.ease??"inout",a=e._realObject?.object3d;if(n.world3D&&a?.parent){const t={pos:a.position.clone(),quat:a.quaternion.clone()},i={x:a.scale.x,y:a.scale.y,z:a.scale.z},c=a.parent;c.updateWorldMatrix(!0,!1);const h=c.matrixWorld.clone().invert(),l=a.matrixWorld.clone().compose(n.world3D.position,n.world3D.quaternion,n.world3D.scale).premultiply(h),u=a.position.clone(),d=a.quaternion.clone(),p=a.scale.clone();l.decompose(u,d,p);const f=(t,e)=>t&&e&&t>0&&e>0?t/e:1,m=n.content?Tf(a):null,y=Of(e),g=n.content&&m?{x:p.x*f(n.content.x,m.x),y:p.y*f(n.content.y,m.y),z:p.z*f(n.content.z,m.z)}:{x:p.x*f(n.shown?.width,y?.width),y:p.y*f(n.shown?.depth,y?.depth),z:p.z*f(n.shown?.height,y?.height)};return void r.begin(e,{from3D:{pos:u,quat:d,fromScale:g,toScale:i},to3D:t,duration:s,ease:o,keepSuppressed:!0,placementAfter:e._realObject.placement})}const c=n.world2D?Ef(e,t):null;n.world2D&&c&&r.begin(e,{fromWorld:n.world2D,toWorld:c,duration:s,ease:o})}(this,t,s,e),zf(()=>this._bumpReceived?.(t))}seatHeldItem(t,e={}){t.realObject;const n=t._realObject,i=n?.object3d;if(i){let r,s,o=e.toParent3D,a="world-preserve",c=1,h=null;if(!o){const n=void 0!==e.point?e.point:this.attachPointFor?.(t,{slotId:e.slotId});n?.attach&&(o=n.attach,r=n.localPosition,s=n.localRotation,a=n.carryPolicy??"world-preserve",c=n.displayScale??1,h=n.seat?.dims??null)}o&&i.parent!==o&&(o.updateWorldMatrix?.(!0,!1),i.updateWorldMatrix?.(!0,!1),o.attach(i),n.suppressTransform=!0),o&&(r&&i.position.set(r.x,r.y,r.z),"world-preserve"!==a?s?i.rotation.set(s.x,s.y,s.z):i.quaternion.identity():s&&i.rotation.set(s.x,s.y,s.z),n?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),n?.setTransientDisplayScale?.(c,function(t){if(!t?.matrixWorld)return;let e=t;for(;e.parent;)e=e.parent;t.updateWorldMatrix?.(!0,!1);const n=t.matrixWorld.elements,i=t=>Math.hypot(n[t],n[t+1],n[t+2]),r=e.scale??{x:1,y:1,z:1};return{x:i(0)/(r.x||1),y:i(4)/(r.y||1),z:i(8)/(r.z||1)}}(o)),t.takeSeatDims?.(h))}}_reseatSlot(t){if(null!=t)for(const e of this._items.slice())e?.[mn]===t&&e._realObject?.object3d&&this.seatHeldItem(e,{slotId:t})}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t){zu(e);try{e.dispose?.()}catch{}}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,i,r){for(let s=this._items.length-1;s>=0;s--){const o=this._items[s],a="static"===o.position?o.capture?.(t,e,r):o.capture?.(n,i,r);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const i=e.bounds;!e.showOverflow&&i&&(t.beginPath(),t.rect(i.left,i.top,i.width,i.height),t.clip(),t.closePath());const{left:r=0,top:s=0}=e.state??{};t.translate(r,s),this._drawItems(t),t.translate(-r,-s),t.restore()}capture(t,e,n){const i=this,r=this._items;if(r&&r.length>0&&!i.app?.isEditMode&&(!i.app||i.app.isEditMode||!i.hidden)){const r=i.fromParent?.(t,e);if(r&&i.contains?.(r.x,r.y)){const s=i.bounds,o=this._captureItems(r.x-s.left,r.y-s.top,t,e,n);if(o)return o}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Pf(t,e,n){return void 0!==n?t._slotIfAvailable(t.slotById(n),e):t.findSlot(e)}function Cf(t){var e;return(e=class extends t{reserve(t,e){const n=Pf(this,t,e?.slotId);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){Sn.log({role:"target",contract:"receive:enter",component:this,args:{carrier:dn(t),options:e}});const n=this.reserve(t,e);if(!n){Sn.log({role:"target",contract:"receive:reject",component:this,args:{carrier:dn(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,e,n={}){const i=t.slot,r=this._countOccupied(i.id),s=this.arrangementStrategy.positionAt(r,i,r,e);Sn.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:r,slotId:i.id,occupantCount:r,carrier:dn(e)},result:s});const o=function(t,e,n,i,r){const s={},o=t.placementFor?.(e,{slot:n,index:i,occupantCount:i})??null;if(Sn.log({role:"target",contract:"placementFor",component:t,args:{carrier:dn(e),slotId:n.id,index:i},result:o}),o){const i=e.state??{},r=t.state??{};s.left=o.position.x-(Number(i.width)||0)/2+(Number(r.width)||0)/2,s.top=o.position.z-(Number(i.height)||0)/2+(Number(r.height)||0)/2;const a=t._zPosFromSeatY(o.position.y,i.depth,n);null!==a&&(s.zPos=a),o.rotation&&fn(s,o.rotation)}else{if(r&&(s.left=r.x,s.top=r.y),0!==(t._realObject?.receivingSurfaceY??0))s.zPos=0;else if(n.localPosition&&Number.isFinite(n.localPosition.z)){const e=t._realObject?.geometricOffsetY??0;s.zPos=n.localPosition.z+e}const i=t.acceptanceRotation?.(e,n);Sn.log({role:"target",contract:"acceptanceRotation",component:t,args:{carrier:dn(e),slotId:n.id},result:i}),i&&fn(s,i)}const a=t.normalizePose?.(e,n);return"function"==typeof t.normalizePose&&Sn.log({role:"target",contract:"normalizePose",component:t,args:{carrier:dn(e),slotId:n.id},result:a}),a&&Object.assign(s,a),s}(this,e,i,r,s),a=e._realObject;let c,h;a?.object3d&&(a.object3d.updateWorldMatrix(!0,!1),c=new L,h=new N,a.object3d.getWorldPosition(c),a.object3d.getWorldQuaternion(h));const{animated:l=!1,duration:u,ease:d}=n;if("function"==typeof this.handoverIn?this.handoverIn(e,{slotId:i.id}):(e[mn]=i.id,this.reparent?.(e,{animated:l,duration:u,ease:d})),!l&&e._realObject&&(e._realObject.suppressTransform=!1),Object.keys(o).length){try{e.setState?.(o)}catch(t){_a("[transferable] the received item's state could not be set; the handover stands",t)}Sn.log({role:"target",contract:"receive:setState",component:this,args:{carrier:dn(e),keys:Object.keys(o)}})}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:i.id,preReceiveWorldPos:c,preReceiveWorldQuat:h}),Sn.log({role:"target",contract:"receive:done",component:this,args:{carrier:dn(e),slotId:i.id}})}async dispatch(t,e,n={}){const i=new Tn({source:this,target:e,carrier:t,options:n}),r=await i.execute();"rolled-back"!==r.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:r.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t,e){const n=(()=>{const n=this.slots;if(!n.length)return{ok:!1,reason:"no-slots-defined"};if(void 0!==e?.slotId){if(!this.slotById(e.slotId))return{ok:!1,reason:"slot-absent"};const n=Pf(this,t,e.slotId);return n?{ok:!0,slot:n}:{ok:!1,reason:"slot-unavailable"}}const i=this.findSlot(t);if(!i){const e=t?.state?.type??t?.type;for(const t of n)if(!t.allowedTypes?.length||!e||t.allowedTypes.includes(e))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:i}})();return Sn.log({role:"target",contract:"canAccept",component:this,args:{carrier:dn(t)},result:n.ok?{ok:!0,slotId:n.slot.id}:{ok:!1,reason:n.reason}}),n}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}function Rf(t){var e;const n=!!t.__hasCapacity,i=!!t.__hasTransferable,r=n?t:gp(t),s=i?r:Cf(r),o=[...t.capabilities??[]];n||o.push("Capacity","PlacementSurface"),i||o.push("Transferable"),o.push("Holdable","FlowNode");var a,c,h;return Iu((e=class extends(jf(s)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},a=e,"symbol"==typeof(c="FlowNodeMixed")&&(c=c.description?"[".concat(c.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:h?"".concat(h," ",c):c}),e.capabilities=Object.freeze(o),e.isFlowNode=!0,e))}function Ff(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,n({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),n({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),n({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});export{Un as BULGE_EPSILON,gp as Capacity,ni as CapacityEventTracker,ri as CenteringQueueStrategy,m as CenteringSlotStrategy,Gd as DEFAULT_SEAT_MARGIN,p as FixedSlotStrategy,Af as FlowEngine,Rf as FlowNode,ai as GridStacking,Od as HOLDER_ANCHOR,jf as Holdable,vd as ITEM_TYPES_THEME,wd as ITEM_TYPE_CODE_MAX,bd as Item,xd as ItemRealObject,Iu as ItemsDataBinding,Rn as NavGraph,oi as PatternStacking,Jn as PolygonPathPolyline,Pn as ReservationTable,mn as TRANSFER_SLOT_KEY,Tn as Transfer,ci as VolumeStacking,$d as addressOfSlotId,pf as allDestinations,Mp as anchorsConnect,yf as applyPolicy,fn as applySeatingRotation,hi as applyStackLayout,wp as arcSegmentTopology,ii as autoWireBackPressure,Tp as buildFlowGraph,Nn as buildNavGraph,Vn as bulgeFromDrag,$n as bulgeHandlePosition,Pp as canReach,t as capability,d as chooseNearestPickupFrame,Np as collectAdjacentSegments,df as componentForNode,qn as computeArcParams,Kp as computeFlowMap,si as computeStackPositions,Hn as cornerHandlePosition,Gn as cornerRadiusFromDrag,Ap as deliversInto,xf as downstream,Yn as effectiveCornerRadius,Wp as enumerateDataScenarios,u as filterByToolType,nf as findNearestWithCapability,f as fixedSlotStrategy,Qn as flattenPolygonPath,lf as flowGraphFor,hf as flowGraphIssues,tf as flowReverseFor,li as footprint2D,xn as frameClock,Xp as ftId,Gp as ftrace,r as getAllCapabilityMeta,i as getCapabilityMeta,yn as globalSimClock,Mf as graphFor,Bd as gridCellOf,Ld as gridSlotNo,Wn as hasArc,ti as hasCapacity,ei as inferCapacity,Lp as inferDownstreamId,Hp as inferFlowDirections,Ff as isFlowNode,ef as isGeometricHost,kd as isItemTypeTable,rf as isRoutingTarget,ku as itemById,Su as itemIdOf,md as itemLookDimsOf,pp as itemSeatsOf,zd as itemTypeEntryOf,Ad as itemTypeTableOf,Sd as itemTypesFromThemes,rp as judgeItemFit,Id as layoutIssue,zp as matchOutbounds,bf as next,jp as nextHop,Ep as nextHops,Rp as nextHopsToAny,Fp as nextHopsToAnyDetailed,ff as nodeIdOf,cp as occupancySnapshotOf,Fd as persistenceIssues,kf as pickWeightedDestination,Ln as planPathAStar,Bn as planToReservations,Sp as pointInRotatedRect,Kn as polygonPathLength,o as quatFromYaw,kp as rayAbsDistanceToRect,Ip as reachableByOutbound,vf as reachableDestinations,wf as reachableDestinationsFrom,_f as reachableDestinationsWeightedFrom,Cp as reachableSinks,Md as readItemTypes,An as receiptToJSON,bp as rectFaceAnchors,h as rectangularFootprintFrames,n as registerCapabilityMeta,Cn as reservationTable,Pa as resolveLegend,Ra as resolveLegendEntries,gf as resolveNextHop,Wd as resolveSlot,Zd as rotatedFootprint,Jd as seatInSlot,Qd as seatTransform,fd as setItemLookProvider,uf as sinksForDestination,Vd as slotAddresses,Dd as slotCount,Hd as slotFrame,qd as slotIdOf,Nd as slotNumbers,ip as slotSpaceWarnings,Kd as stackSeatTransforms,jn as standardYieldPolicy,vp as straightSegmentEndpoints,_p as straightSegmentMultiInbound,xp as straightSegmentTopology,l as topApproachFrame,In as transferLog,Sn as transferTracer,Xn as uniformZ,Sf as validate,Dp as validateFlowGraph,Rd as validateSlotLayout};