@hatiolab/things-scene 10.1.98 → 10.1.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-types/components/mixins/holdable.d.ts.map +1 -1
- package/dist-types/components/root-container.d.ts +8 -0
- package/dist-types/components/root-container.d.ts.map +1 -1
- package/dist-types/diagnostics/inspector.d.ts.map +1 -1
- package/dist-types/figure/figure-capability.d.ts.map +1 -1
- package/dist-types/figure/figure-instance.d.ts +1 -0
- package/dist-types/figure/figure-instance.d.ts.map +1 -1
- package/dist-types/figure/figure-item-look.d.ts +2 -0
- package/dist-types/figure/figure-item-look.d.ts.map +1 -0
- package/dist-types/figure/figure-real-object.d.ts +16 -10
- package/dist-types/figure/figure-real-object.d.ts.map +1 -1
- package/dist-types/figure/figure-registry.d.ts +2 -6
- package/dist-types/figure/figure-registry.d.ts.map +1 -1
- package/dist-types/items/capacity-mixin.d.ts +56 -3
- package/dist-types/items/capacity-mixin.d.ts.map +1 -1
- package/dist-types/items/index.d.ts +5 -1
- package/dist-types/items/index.d.ts.map +1 -1
- package/dist-types/items/item-registry.d.ts +13 -0
- package/dist-types/items/item-registry.d.ts.map +1 -0
- package/dist-types/items/item-seating.d.ts +72 -0
- package/dist-types/items/item-seating.d.ts.map +1 -0
- package/dist-types/items/item-types.d.ts +61 -0
- package/dist-types/items/item-types.d.ts.map +1 -0
- package/dist-types/items/item.d.ts +333 -0
- package/dist-types/items/item.d.ts.map +1 -0
- package/dist-types/items/items-data-binding.d.ts +40 -1
- package/dist-types/items/items-data-binding.d.ts.map +1 -1
- package/dist-types/search/scene-search-engine.d.ts +1 -0
- package/dist-types/search/scene-search-engine.d.ts.map +1 -1
- package/dist-types/things-scene/create.d.ts +6 -1
- package/dist-types/things-scene/create.d.ts.map +1 -1
- package/dist-types/things-scene/index.d.ts +1 -1
- package/dist-types/things-scene/index.d.ts.map +1 -1
- package/dist-types/threed/real-object.d.ts +22 -6
- package/dist-types/threed/real-object.d.ts.map +1 -1
- package/dist-types/tracker/tracker.d.ts +1 -0
- package/dist-types/tracker/tracker.d.ts.map +1 -1
- package/dist-types/transfer/index.d.ts +1 -1
- package/dist-types/transfer/index.d.ts.map +1 -1
- package/dist-types/transfer/transfer.d.ts.map +1 -1
- package/dist-types/transfer/transferable-mixin.d.ts +9 -3
- package/dist-types/transfer/transferable-mixin.d.ts.map +1 -1
- package/dist-types/transfer/types.d.ts +22 -3
- package/dist-types/transfer/types.d.ts.map +1 -1
- package/dist-types/transition/transition-effect.d.ts +3 -0
- package/dist-types/transition/transition-effect.d.ts.map +1 -1
- package/package.json +1 -1
- package/things-scene-min.js +11 -11
- package/things-scene-min.js.map +1 -1
- package/things-scene-transfer.mjs +3 -3
- package/things-scene.mjs +3 -3
- package/things-scene.mjs.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function t(...t){return e=>{const r=Object.getPrototypeOf(e),n=Array.isArray(r?.capabilities)?r.capabilities:[],i=new Set([...n,...t]);return Object.defineProperty(e,"capabilities",{value:Object.freeze([...i]),writable:!1,configurable:!0}),e}}const e=new Map;function r(t){e.set(t.name,t)}function n(t){return e.get(t)}function i(){return[...e.values()]}const
|
|
1
|
+
function t(...t){return e=>{const r=Object.getPrototypeOf(e),n=Array.isArray(r?.capabilities)?r.capabilities:[],i=new Set([...n,...t]);return Object.defineProperty(e,"capabilities",{value:Object.freeze([...i]),writable:!1,configurable:!0}),e}}const e=new Map;function r(t){e.set(t.name,t)}function n(t){return e.get(t)}function i(){return[...e.values()]}const s={x:0,y:0,z:0,w:1};function o(t){const e=t/2;return{x:0,y:Math.sin(e),z:0,w:Math.cos(e)}}function a(t,e){const r=t.rotation,n=e.rotation,i=e.position,s=r.w*i.x+r.y*i.z-r.z*i.y,o=r.w*i.y+r.z*i.x-r.x*i.z,a=r.w*i.z+r.x*i.y-r.y*i.x,c=-r.x*i.x-r.y*i.y-r.z*i.z,h=s*r.w+c*-r.x+o*-r.z-a*-r.y,l=o*r.w+c*-r.y+a*-r.x-s*-r.z,u=a*r.w+c*-r.z+s*-r.y-o*-r.x,d={x:r.w*n.x+r.x*n.w+r.y*n.z-r.z*n.y,y:r.w*n.y-r.x*n.z+r.y*n.w+r.z*n.x,z:r.w*n.z+r.x*n.y-r.y*n.x+r.z*n.w,w:r.w*n.w-r.x*n.x-r.y*n.y-r.z*n.z};return{position:{x:t.position.x+h,y:t.position.y+l,z:t.position.z+u},rotation:d}}const c={east:{axis:{x:1,y:0,z:0},yaw:0,idSuffix:"east"},west:{axis:{x:-1,y:0,z:0},yaw:Math.PI,idSuffix:"west"},south:{axis:{x:0,y:0,z:1},yaw:-Math.PI/2,idSuffix:"south"},north:{axis:{x:0,y:0,z:-1},yaw:Math.PI/2,idSuffix:"north"}};function h(t){const{carrierWorld:e,width:r,depth:n,entryHeight:i,mountLocalY:h,approachDistance:l,sides:u,toolType:d,tolerance:p,priority:f}=t,m="number"==typeof h?{position:{x:0,y:h,z:0},rotation:{...s}}:void 0,g=r/2,y=n/2;return u.map(t=>{const r=c[t],n="string"==typeof d?d:d[t]??"unknown",s={position:{x:r.axis.x*("east"===t||"west"===t?g:0),y:i,z:r.axis.z*("north"===t||"south"===t?y:0)},rotation:o(r.yaw)},h={position:{x:s.position.x+r.axis.x*l,y:i,z:s.position.z+r.axis.z*l},rotation:o(r.yaw)};return{id:`entry-${r.idSuffix}`,toolType:n,approach:a(e,h),engage:a(e,s),...m?{mount:m}:{},tolerance:p,priority:f}})}function l(t){const{carrierWorld:e,topY:r,approachDistance:n,toolType:i,mountLocalY:o,tolerance:c,priority:h,id:l}=t,u={position:{x:0,y:r,z:0},rotation:{...s}};return{id:l??"top",toolType:i,approach:a(e,{position:{x:0,y:r+n,z:0},rotation:{...s}}),engage:a(e,u),..."number"==typeof o?{mount:{position:{x:0,y:o,z:0},rotation:{...s}}}:{},tolerance:c,priority:h}}function u(t,e){return t.filter(t=>t.toolType===e.toolType)}function d(t,e){if(0===t.length)return null;const r=t.map(t=>{const r=t.approach.position.x-e.x,n=t.approach.position.y-e.y,i=t.approach.position.z-e.z;return{f:t,dist:Math.sqrt(r*r+n*n+i*i)}});return r.sort((t,e)=>{const r=t.f.priority??0,n=e.f.priority??0;return r!==n?r-n:t.dist-e.dist}),r[0].f}class p{positionAt(t,e,r){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const f=new p;class m{constructor(t){this.owner=t}positionAt(t,e,r,n){if(0!==t)return null;const i=this.owner?.state?.width??0,s=this.owner?.state?.height??0,o=n?.state?.width??0,a=n?.state?.height??0;return{x:Math.max(0,(i-o)/2),y:Math.max(0,(s-a)/2),z:0}}capacity(t){return t.maxCount??1}}
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2010-2026 Three.js Authors
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/const y=2e3,m={};function b(...t){t=function(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}(t);const e="THREE."+t.shift();{const r=t[0];r&&r.isStackTrace?console.warn(r.getError(e)):console.warn(e,...t)}}function x(...t){const e=t.join(" ");e in m||(m[e]=!0,b(...t))}function v(t,e,r){return Math.max(e,Math.min(r,t))}class _{static{_.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,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[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=v(this.x,t.x,e.x),this.y=v(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=v(this.x,t,e),this.y=v(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(v(r,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 r=this.dot(t)/e;return Math.acos(v(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,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 r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class w{constructor(t=0,e=0,r=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=n}static slerpFlat(t,e,r,n,i,o,s){let a=r[n+0],c=r[n+1],u=r[n+2],h=r[n+3],l=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(h!==p||a!==l||c!==f||u!==d){let t=a*l+c*f+u*d+h*p;t<0&&(l=-l,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const r=Math.acos(t),n=Math.sin(r);e=Math.sin(e*r)/n,a=a*e+l*(s=Math.sin(s*r)/n),c=c*e+f*s,u=u*e+d*s,h=h*e+p*s}else{a=a*e+l*s,c=c*e+f*s,u=u*e+d*s,h=h*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+h*h);a*=t,c*=t,u*=t,h*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,r,n,i,o){const s=r[n],a=r[n+1],c=r[n+2],u=r[n+3],h=i[o],l=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*h+a*f-c*l,t[e+1]=a*d+u*l+c*h-s*f,t[e+2]=c*d+u*f+s*l-a*h,t[e+3]=u*d-s*h-a*l-c*f,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,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,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 r=t._x,n=t._y,i=t._z,o=t._order,s=Math.cos,a=Math.sin,c=s(r/2),u=s(n/2),h=s(i/2),l=a(r/2),f=a(n/2),d=a(i/2);switch(o){case"XYZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"YXZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"ZXY":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"ZYX":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"YZX":this._x=l*u*h+c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h-l*f*d;break;case"XZY":this._x=l*u*h-c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h+l*f*d;break;default:b("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],n=e[4],i=e[8],o=e[1],s=e[5],a=e[9],c=e[2],u=e[6],h=e[10],l=r+s+h;if(l>0){const t=.5/Math.sqrt(l+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-n)*t}else if(r>s&&r>h){const t=2*Math.sqrt(1+r-s-h);this._w=(u-a)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(i+c)/t}else if(s>h){const t=2*Math.sqrt(1+s-r-h);this._w=(i-c)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+h-r-s);this._w=(o-n)/t,this._x=(i+c)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(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=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(v(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(0===r)return this;const n=Math.min(1,e/r);return this.slerp(t,n),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 r=t._x,n=t._y,i=t._z,o=t._w,s=e._x,a=e._y,c=e._z,u=e._w;return this._x=r*u+o*s+n*c-i*a,this._y=n*u+o*a+i*s-r*c,this._z=i*u+o*c+r*a-n*s,this._w=o*u-r*s-n*a-i*c,this._onChangeCallback(),this}slerp(t,e){let r=t._x,n=t._y,i=t._z,o=t._w,s=this.dot(t);s<0&&(r=-r,n=-n,i=-i,o=-o,s=-s);let a=1-e;if(s<.9995){const t=Math.acos(s),c=Math.sin(t);a=Math.sin(a*t)/c,e=Math.sin(e*t)/c,this._x=this._x*a+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this._onChangeCallback()}else this._x=this._x*a+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this.normalize();return this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),n=Math.sqrt(1-r),i=Math.sqrt(r);return this.set(n*Math.sin(t),n*Math.cos(t),i*Math.sin(e),i*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 k{static{k.prototype.isVector3=!0}constructor(t=0,e=0,r=0){this.x=t,this.y=e,this.z=r}set(t,e,r){return void 0===r&&(r=this.z),this.x=t,this.y=e,this.z=r,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(S.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(S.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,s=t.z,a=t.w,c=2*(o*n-s*r),u=2*(s*e-i*n),h=2*(i*r-o*e);return this.x=e+a*c+o*h-s*u,this.y=r+a*u+s*c-i*h,this.z=n+a*h+i*u-o*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,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,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=v(this.x,t.x,e.x),this.y=v(this.y,t.y,e.y),this.z=v(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=v(this.x,t,e),this.y=v(this.y,t,e),this.z=v(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(v(r,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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,n=t.y,i=t.z,o=e.x,s=e.y,a=e.z;return this.x=n*a-i*s,this.y=i*o-r*a,this.z=r*s-n*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return M.copy(this).projectOnVector(t),this.sub(M)}reflect(t){return this.sub(M.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 r=this.dot(t)/e;return Math.acos(v(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}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,r){const n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,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(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,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,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const M=new k,S=new w;class E{static{E.prototype.isMatrix3=!0}constructor(t,e,r,n,i,o,s,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,r,n,i,o,s,a,c)}set(t,e,r,n,i,o,s,a,c){const u=this.elements;return u[0]=t,u[1]=n,u[2]=s,u[3]=e,u[4]=i,u[5]=a,u[6]=r,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.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 r=t.elements,n=e.elements,i=this.elements,o=r[0],s=r[3],a=r[6],c=r[1],u=r[4],h=r[7],l=r[2],f=r[5],d=r[8],p=n[0],g=n[3],y=n[6],m=n[1],b=n[4],x=n[7],v=n[2],_=n[5],w=n[8];return i[0]=o*p+s*m+a*v,i[3]=o*g+s*b+a*_,i[6]=o*y+s*x+a*w,i[1]=c*p+u*m+h*v,i[4]=c*g+u*b+h*_,i[7]=c*y+u*x+h*w,i[2]=l*p+f*m+d*v,i[5]=l*g+f*b+d*_,i[8]=l*y+f*x+d*w,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],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8];return e*o*u-e*s*c-r*i*u+r*s*a+n*i*c-n*o*a}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=u*o-s*c,l=s*a-u*i,f=c*i-o*a,d=e*h+r*l+n*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return t[0]=h*p,t[1]=(n*c-u*r)*p,t[2]=(s*r-n*o)*p,t[3]=l*p,t[4]=(u*e-n*a)*p,t[5]=(n*i-s*e)*p,t[6]=f*p,t[7]=(r*a-c*e)*p,t[8]=(o*e-r*i)*p,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,r,n,i,o,s){const a=Math.cos(i),c=Math.sin(i);return this.set(r*a,r*c,-r*(a*o+c*s)+o+t,-n*c,n*a,-n*(-c*o+a*s)+s+e,0,0,1),this}scale(t,e){return x("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(z.makeScale(t,e)),this}rotate(t){return x("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(z.makeRotation(-t)),this}translate(t,e){return x("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(z.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),r=Math.sin(t);return this.set(e,-r,0,r,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,r=t.elements;for(let t=0;t<9;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const z=new E;class A{static{A.prototype.isVector4=!0}constructor(t=0,e=0,r=0,n=1){this.x=t,this.y=e,this.z=r,this.w=n}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,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,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,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,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,r,n,i;const o=.01,s=.1,a=t.elements,c=a[0],u=a[4],h=a[8],l=a[1],f=a[5],d=a[9],p=a[2],g=a[6],y=a[10];if(Math.abs(u-l)<o&&Math.abs(h-p)<o&&Math.abs(d-g)<o){if(Math.abs(u+l)<s&&Math.abs(h+p)<s&&Math.abs(d+g)<s&&Math.abs(c+f+y-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(f+1)/2,m=(y+1)/2,b=(u+l)/4,x=(h+p)/4,v=(d+g)/4;return t>a&&t>m?t<o?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(t),n=b/r,i=x/r):a>m?a<o?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(a),r=b/n,i=v/n):m<o?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(m),r=x/i,n=v/i),this.set(r,n,i,e),this}let m=Math.sqrt((g-d)*(g-d)+(h-p)*(h-p)+(l-u)*(l-u));return Math.abs(m)<.001&&(m=1),this.x=(g-d)/m,this.y=(h-p)/m,this.z=(l-u)/m,this.w=Math.acos((c+f+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=v(this.x,t.x,e.x),this.y=v(this.y,t.y,e.y),this.z=v(this.z,t.z,e.z),this.w=v(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=v(this.x,t,e),this.y=v(this.y,t,e),this.z=v(this.z,t,e),this.w=v(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(v(r,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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,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 T{static{T.prototype.isMatrix4=!0}constructor(t,e,r,n,i,o,s,a,c,u,h,l,f,d,p,g){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,r,n,i,o,s,a,c,u,h,l,f,d,p,g)}set(t,e,r,n,i,o,s,a,c,u,h,l,f,d,p,g){const y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=n,y[1]=i,y[5]=o,y[9]=s,y[13]=a,y[2]=c,y[6]=u,y[10]=h,y[14]=l,y[3]=f,y[7]=d,y[11]=p,y[15]=g,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 T).fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[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,r){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),r.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,r=t.elements,n=1/O.setFromMatrixColumn(t,0).length(),i=1/O.setFromMatrixColumn(t,1).length(),o=1/O.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),s=Math.sin(r),a=Math.cos(n),c=Math.sin(n),u=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){const t=o*u,r=o*h,n=s*u,i=s*h;e[0]=a*u,e[4]=-a*h,e[8]=c,e[1]=r+n*c,e[5]=t-i*c,e[9]=-s*a,e[2]=i-t*c,e[6]=n+r*c,e[10]=o*a}else if("YXZ"===t.order){const t=a*u,r=a*h,n=c*u,i=c*h;e[0]=t+i*s,e[4]=n*s-r,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-s,e[2]=r*s-n,e[6]=i+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*u,r=a*h,n=c*u,i=c*h;e[0]=t-i*s,e[4]=-o*h,e[8]=n+r*s,e[1]=r+n*s,e[5]=o*u,e[9]=i-t*s,e[2]=-o*c,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*u,r=o*h,n=s*u,i=s*h;e[0]=a*u,e[4]=n*c-r,e[8]=t*c+i,e[1]=a*h,e[5]=i*c+t,e[9]=r*c-n,e[2]=-c,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=i-t*h,e[8]=n*h+r,e[1]=h,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=r*h+n,e[10]=t-i*h}else if("XZY"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=-h,e[8]=c*u,e[1]=t*h+i,e[5]=o*u,e[9]=r*h-n,e[2]=n*h-r,e[6]=s*u,e[10]=i*h+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(j,t,P)}lookAt(t,e,r){const n=this.elements;return N.subVectors(t,e),0===N.lengthSq()&&(N.z=1),N.normalize(),R.crossVectors(r,N),0===R.lengthSq()&&(1===Math.abs(r.z)?N.x+=1e-4:N.z+=1e-4,N.normalize(),R.crossVectors(r,N)),R.normalize(),C.crossVectors(N,R),n[0]=R.x,n[4]=C.x,n[8]=N.x,n[1]=R.y,n[5]=C.y,n[9]=N.y,n[2]=R.z,n[6]=C.z,n[10]=N.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,o=r[0],s=r[4],a=r[8],c=r[12],u=r[1],h=r[5],l=r[9],f=r[13],d=r[2],p=r[6],g=r[10],y=r[14],m=r[3],b=r[7],x=r[11],v=r[15],_=n[0],w=n[4],k=n[8],M=n[12],S=n[1],E=n[5],z=n[9],A=n[13],T=n[2],O=n[6],I=n[10],j=n[14],P=n[3],R=n[7],C=n[11],N=n[15];return i[0]=o*_+s*S+a*T+c*P,i[4]=o*w+s*E+a*O+c*R,i[8]=o*k+s*z+a*I+c*C,i[12]=o*M+s*A+a*j+c*N,i[1]=u*_+h*S+l*T+f*P,i[5]=u*w+h*E+l*O+f*R,i[9]=u*k+h*z+l*I+f*C,i[13]=u*M+h*A+l*j+f*N,i[2]=d*_+p*S+g*T+y*P,i[6]=d*w+p*E+g*O+y*R,i[10]=d*k+p*z+g*I+y*C,i[14]=d*M+p*A+g*j+y*N,i[3]=m*_+b*S+x*T+v*P,i[7]=m*w+b*E+x*O+v*R,i[11]=m*k+b*z+x*I+v*C,i[15]=m*M+b*A+x*j+v*N,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],r=t[4],n=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],u=t[2],h=t[6],l=t[10],f=t[14],d=t[3],p=t[7],g=t[11],y=t[15],m=a*f-c*l,b=s*f-c*h,x=s*l-a*h,v=o*f-c*u,_=o*l-a*u,w=o*h-s*u;return e*(p*m-g*b+y*x)-r*(d*m-g*v+y*_)+n*(d*b-p*v+y*w)-i*(d*x-p*_+g*w)}determinantAffine(){const t=this.elements,e=t[0],r=t[4],n=t[8],i=t[1],o=t[5],s=t[9],a=t[2],c=t[6],u=t[10];return e*(o*u-s*c)-r*(i*u-s*a)+n*(i*c-o*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,r){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=t[9],l=t[10],f=t[11],d=t[12],p=t[13],g=t[14],y=t[15],m=e*s-r*o,b=e*a-n*o,x=e*c-i*o,v=r*a-n*s,_=r*c-i*s,w=n*c-i*a,k=u*p-h*d,M=u*g-l*d,S=u*y-f*d,E=h*g-l*p,z=h*y-f*p,A=l*y-f*g,T=m*A-b*z+x*E+v*S-_*M+w*k;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/T;return t[0]=(s*A-a*z+c*E)*O,t[1]=(n*z-r*A-i*E)*O,t[2]=(p*w-g*_+y*v)*O,t[3]=(l*_-h*w-f*v)*O,t[4]=(a*S-o*A-c*M)*O,t[5]=(e*A-n*S+i*M)*O,t[6]=(g*x-d*w-y*b)*O,t[7]=(u*w-l*x+f*b)*O,t[8]=(o*z-s*S+c*k)*O,t[9]=(r*S-e*z-i*k)*O,t[10]=(d*_-p*x+y*m)*O,t[11]=(h*x-u*_-f*m)*O,t[12]=(s*M-o*E-a*k)*O,t[13]=(e*E-r*M+n*k)*O,t[14]=(p*b-d*v-g*m)*O,t[15]=(u*v-h*b+l*m)*O,this}scale(t){const e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){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,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),n=Math.sin(e),i=1-r,o=t.x,s=t.y,a=t.z,c=i*o,u=i*s;return this.set(c*o+r,c*s-n*a,c*a+n*s,0,c*s+n*a,u*s+r,u*a-n*o,0,c*a-n*s,u*a+n*o,i*a*a+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,i,o){return this.set(1,r,i,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){const n=this.elements,i=e._x,o=e._y,s=e._z,a=e._w,c=i+i,u=o+o,h=s+s,l=i*c,f=i*u,d=i*h,p=o*u,g=o*h,y=s*h,m=a*c,b=a*u,x=a*h,v=r.x,_=r.y,w=r.z;return n[0]=(1-(p+y))*v,n[1]=(f+x)*v,n[2]=(d-b)*v,n[3]=0,n[4]=(f-x)*_,n[5]=(1-(l+y))*_,n[6]=(g+m)*_,n[7]=0,n[8]=(d+b)*w,n[9]=(g-m)*w,n[10]=(1-(l+p))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const i=this.determinantAffine();if(0===i)return r.set(1,1,1),e.identity(),this;let o=O.set(n[0],n[1],n[2]).length();const s=O.set(n[4],n[5],n[6]).length(),a=O.set(n[8],n[9],n[10]).length();i<0&&(o=-o),I.copy(this);const c=1/o,u=1/s,h=1/a;return I.elements[0]*=c,I.elements[1]*=c,I.elements[2]*=c,I.elements[4]*=u,I.elements[5]*=u,I.elements[6]*=u,I.elements[8]*=h,I.elements[9]*=h,I.elements[10]*=h,e.setFromRotationMatrix(I),r.x=o,r.y=s,r.z=a,this}makePerspective(t,e,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2*i/(e-t),h=2*i/(r-n),l=(e+t)/(e-t),f=(r+n)/(r-n);let d,p;if(a)d=i/(o-i),p=o*i/(o-i);else if(s===y)d=-(o+i)/(o-i),p=-2*o*i/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);d=-o/(o-i),p=-o*i/(o-i)}return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),h=2/(r-n),l=-(e+t)/(e-t),f=-(r+n)/(r-n);let d,p;if(a)d=1/(o-i),p=o/(o-i);else if(s===y)d=-2/(o-i),p=-(o+i)/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);d=-1/(o-i),p=-i/(o-i)}return c[0]=u,c[4]=0,c[8]=0,c[12]=l,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let t=0;t<16;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const O=new k,I=new T,j=new k(0,0,0),P=new k(1,1,1),R=new k,C=new k,N=new k,F=new T,D=new w;class L{constructor(t=0,e=0,r=0,n=L.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=n}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,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,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,r=!0){const n=t.elements,i=n[0],o=n[4],s=n[8],a=n[1],c=n[5],u=n[9],h=n[2],l=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(v(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(l,c),this._z=0);break;case"YXZ":this._x=Math.asin(-v(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(v(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-v(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(l,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(v(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-v(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(l,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:b("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return F.makeRotationFromQuaternion(t),this.setFromRotationMatrix(F,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return D.setFromEuler(this),this.setFromQuaternion(D,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}}L.DEFAULT_ORDER="XYZ";class Y{static{Y.prototype.isMatrix2=!0}constructor(t,e,r,n){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,r,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let r=0;r<4;r++)this.elements[r]=t[r+e];return this}set(t,e,r,n){const i=this.elements;return i[0]=t,i[2]=e,i[1]=r,i[3]=n,this}}function $(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__?b("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const U=new L;function W(t,e){U.setFromQuaternion(new w(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=U.x,t.rotation=-U.y,t.rotationY=U.z}const q="_transferSlotId";const B=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__=B);const G=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,r=this.cacheHit+this.cacheMiss,n=this._getResidents?.()??null;let i=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(i=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const o={fps:i,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:r>0?Math.round(this.cacheHit/r*1e3)/10:0,...n??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,o}};function H(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const X=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 B.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const r=e?.component,n=r?.app??r?.root?.app;if(n&&"boolean"==typeof n.isViewMode&&!n.isViewMode)return()=>{};const i={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(i),this.isRunning||this.start(),()=>{this._ticking?(i._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(i),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,G.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const r=B.tick(e),n=B.now;if(this._ticking=!0,G.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(r,n)}finally{const n=performance.now()-e;t.tickCount++,t.totalDurationMs+=n,t.lastDt=r,t.lastDurationMs=n}}else for(const t of this._subs)t._removed||t.handler(r,n);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(),r=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(r),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,r){const n={id:this._externalNextId++,description:t,source:e,metadata:r,registeredAt:this._realTime};return this._externals.add(n),{update:t=>{n.metadata={...n.metadata??{},...t}},unregister:()=>{this._externals.delete(n)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let r;const n=e.componentRef?.deref();let i;if(n&&(r=H(n)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],r=[];for(const t of e)null!=t&&r.push(H(t));r.length>0&&(i=r)}}catch{}t.push({id:e.id,description:e.description,componentInfo:r,targetInfos:i,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(B.now),isRunning:this.isRunning,speed:B.speed,paused:B.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let V=null;const Z=[],Q=new Set;function J(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const K={beginContext(t){V=t},endContext(){V=null},current:()=>V,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??J(t.component),componentType:t.componentType??(r=t.component,r?.state?.type??r?.type),atSimMs:B.now,args:t.args,result:t.result,error:t.error};var r;V?V.pushTrace(e):(Z.push(e),Z.length>500&&Z.shift(),Q.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...Z],onStandalone:t=>(Q.add(t),()=>{Q.delete(t)}),clearStandalone(){Z.length=0}};function tt(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const r=String(e);return r.length>0?r:void 0}function et(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},r=t.sourceId??tt(t.source),n=t.targetId??tt(t.target),i=t.carrierId??tt(t.carrier);return void 0!==r&&(e.sourceId=r),void 0!==n&&(e.targetId=n),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let rt=1;class nt{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+rt++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:B.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??B.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return it.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=B.now;const t=this.target.canAccept?.(this.carrier);if(t&&t.ok)this._slot=t.slot;else{if(t&&!t.ok&&"no-slots-defined"!==t.reason)return this._rejectReason=t.reason,this._rollback();if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier))return this._rejectReason="cannot-receive",this._rollback();this._slot="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}),this._reservation)?(this._timeline.planEndAt=B.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",it.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=B.now;const t=this._buildReceipt();return it.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.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 K.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 K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){K.beginContext(this),K.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{return await this._executeImpl()}finally{K.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}executeSync(){K.beginContext(this),K.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{K.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=B.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",it.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:tt(this.source),targetId:tt(this.target),carrierId:tt(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 it=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??tt(t.source),r=t.targetId??tt(t.target);if("committed"===t.phase){if(e&&r){const t=e+">"+r;this._flows.set(t,(this._flows.get(t)??0)+1)}r&&this._targetCount.set(r,(this._targetCount.get(r)??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,r)=>{t[r]=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,r){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=it);let ot=1;function st(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const at={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class ct{constructor(t=at){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-"+ot++},r=(this._byResource.get(e.resource)??[]).filter(t=>st(t.timeWindow,e.timeWindow));if(0===r.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const n=r.map(t=>{const r=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:r}});if(n.every(t=>"b-yields"===t.decision)){const n=r.slice();for(const t of n)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:n,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:n}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r.slice(),outcome:"rejected"}),{ok:!1,conflicts:n}}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=>st(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 r=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);r<0?e.push(t):e.splice(r,0,t);let n=this._byReserver.get(t.reserverId);n||(n=[],this._byReserver.set(t.reserverId,n)),n.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const r=e.findIndex(e=>e.id===t.id);if(r<0)return!1;e.splice(r,1),0===e.length&&this._byResource.delete(t.resource);const n=this._byReserver.get(t.reserverId);if(n){const e=n.findIndex(e=>e.id===t.id);e>=0&&n.splice(e,1),0===n.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const ut=new ct;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=ut);class ht{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,r=1/0;for(const n of this.nodes.values()){const i=lt(n.position,t);i<r&&(r=i,e=n)}return e}}function lt(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}function ft(t,e){return Math.sqrt(lt(t,e))}function dt(t,e,r={}){const n=new ht,i=r.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const r=`${e.id}:start`,o=`${e.id}:end`;n.addNode({id:r,position:t[0],type:"lane-start"}),n.addNode({id:o,position:t[t.length-1],type:"lane-end"}),n.laneEndpoints.set(e.id,{startNodeId:r,endNodeId:o});let s=0;for(let e=1;e<t.length;e++)s+=ft(t[e-1],t[e]);const a=s/(e.speedLimit??i)*1e3;n.addEdge({fromNode:r,toNode:o,resource:e.id,distance:s,durationMs:a,forward:!0}),"twoway"===e.direction&&n.addEdge({fromNode:o,toNode:r,resource:e.id,distance:s,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const r of t.lanes){const i=n.laneEndpoints.get(r);if(!i)continue;const o=n.nodes.get(i.startNodeId).position,s=n.nodes.get(i.endNodeId).position;let a=0,c=0,u=0;for(const e of t.lanes){if(e===r)continue;const t=n.laneEndpoints.get(e);if(!t)continue;const i=n.nodes.get(t.startNodeId).position,h=n.nodes.get(t.endNodeId).position;a+=Math.min(lt(o,i),lt(o,h)),c+=Math.min(lt(s,i),lt(s,h)),u++}if(0===u)continue;const h=a<c?i.startNodeId:i.endNodeId;e.push({laneId:r,nodeId:h,pos:n.nodes.get(h).position})}for(let r=0;r<e.length;r++)for(let i=0;i<e.length;i++){if(r===i)continue;const o=e[r],s=e[i],a=ft(o.pos,s.pos);n.addEdge({fromNode:o.nodeId,toNode:s.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return n}function pt(t,e,r,n={}){const i=t.nodes.get(e),o=t.nodes.get(r);if(!i||!o)return null;const s=n.speed?.max??100,a=e=>{const r=t.nodes.get(e);var n,i;return(n=r.position,i=o.position,Math.sqrt(function(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}(n,i)))/s*1e3},c=new Map,u=new Set,h=new Set,l={nodeId:e,gScore:0,fScore:a(e)};c.set(e,l),u.add(e);const f=n.startSimMs??0,d=n.deadlineSimMs;for(;u.size>0;){let e=null,n=null;for(const t of u){const r=c.get(t);(!n||r.fScore<n.fScore||r.fScore===n.fScore&&t<e)&&(n=r,e=t)}if(!n||!e)return null;if(e===r){const t=[];let e=n,r=0;for(;e&&e.cameFromEdge;){const n=e.cameFromEdge,i=f+(e.gScore-n.durationMs);t.unshift({resource:n.resource,timeWindow:{startSimMs:i,endSimMs:i+n.durationMs},fromPos:n.fromPos,toPos:n.toPos}),r+=n.distance,e=c.get(n.fromNodeId)}const i=n.gScore;return void 0!==d&&f+i>d?null:{segments:t,totalDurationMs:i,totalDistance:r}}u.delete(e),h.add(e);for(const r of t.edgesFrom(e)){if(h.has(r.toNode))continue;const e=n.gScore+r.durationMs,i=c.get(r.toNode);if(!i||e<i.gScore){const n=t.nodes.get(r.fromNode),i=t.nodes.get(r.toNode),o={nodeId:r.toNode,gScore:e,fScore:e+a(r.toNode),cameFromEdge:{fromNodeId:r.fromNode,resource:r.resource,distance:r.distance,durationMs:r.durationMs,fromPos:n.position,toPos:i.position}};c.set(r.toNode,o),u.add(r.toNode)}}}return null}function gt(t,e,r=0,n){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:r,metadata:n}))}const yt=.5;function mt(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function bt(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i);if(0===o||!Number.isFinite(r)||Math.abs(r)<1e-9)return null;const s=Math.abs(r),a=(o*o+4*s*s)/(8*s),c=r>0?1:-1,u=a-s,h=(t.x+e.x)/2-c*(i/o)*u,l=(t.y+e.y)/2-c*-(n/o)*u;return{cx:h,cy:l,radius:a,startAngle:Math.atan2(t.y-l,t.x-h),endAngle:Math.atan2(e.y-l,e.x-h),clockwise:r<0}}function xt(t,e,r=0,n=16){const i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o);if(0===s)return null;const a=o/s,c=-(i/s),u=Number.isFinite(r)?r:0,h=Math.abs(u)>=1e-6?u:n;return{x:(t.x+e.x)/2+a*h,y:(t.y+e.y)/2+c*h,perpX:a,perpY:c}}function vt(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i);if(0===o)return 0;const s=i/o,a=-(n/o),c=(t.x+e.x)/2,u=(t.y+e.y)/2;let h=(r.x-c)*s+(r.y-u)*a;if(Math.abs(h)<.5)return 0;return h>o&&(h=o),h<-o&&(h=-o),h}function _t(t,e){const r=t.radius,n=Number.isFinite(e)?e:0;return null!=r&&Number.isFinite(r)?Math.max(0,r):Math.max(0,n)}function wt(t,e,r,n,i=16){const o=t.x-e.x,s=t.y-e.y,a=Math.sqrt(o*o+s*s);if(0===a)return null;const c=r.x-e.x,u=r.y-e.y,h=Math.sqrt(c*c+u*u);if(0===h)return null;const l=o/a+c/h,f=s/a+u/h,d=Math.sqrt(l*l+f*f);if(d<1e-9)return null;const p=l/d,g=f/d,y=Math.max(n,i);return{x:e.x+p*y,y:e.y+g*y,bisectorX:p,bisectorY:g}}function kt(t,e,r,n){const i=t.x-e.x,o=t.y-e.y,s=Math.sqrt(i*i+o*o),a=r.x-e.x,c=r.y-e.y,u=Math.sqrt(a*a+c*c);if(0===s||0===u)return 0;const h=i/s+a/u,l=o/s+c/u,f=Math.sqrt(h*h+l*l);if(f<1e-9)return 0;const d=h/f,p=l/f,g=(n.x-e.x)*d+(n.y-e.y)*p,y=Math.min(s,u)/2;return Math.max(0,Math.min(g,y))}function Mt(t){if(0===t.length)return 0;let e;for(const r of t){const t=r.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 St={closed:!0,round:0,divisions:24};class Et{constructor(t,e){this.points=t,this.closed=e;const r=[0];for(let e=1;e<t.length;e++){const n=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;r.push(r[e-1]+Math.sqrt(n*n+i*i))}this.cumulative=r,this.length=r[r.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 r=t;this.closed?r=(t%e+e)%e:r<0?r=0:r>e&&(r=e);const n=this.cumulative;let i=0,o=n.length-2;for(;i<o;){const t=i+o>>1;n[t+1]<=r?i=t+1:o=t}const s=n[i+1]-n[i],a=s>0?(r-n[i])/s:0,c=this.points[i],u=this.points[i+1],h=u.x-c.x,l=u.y-c.y;return{x:c.x+h*a,y:c.y+l*a,theta:0===h&&0===l?0:Math.atan2(l,h)}}}function zt(t,e={}){const r={...St,...e},n=t.length;if(0===n)return new Et([],r.closed);if(1===n)return new Et([{x:t[0].x,y:t[0].y}],r.closed);const i=[],o=(t,e)=>{if(i.length>0){const r=i[i.length-1];if(Math.abs(r.x-t)<1e-9&&Math.abs(r.y-e)<1e-9)return}i.push({x:t,y:e})},s=(r.closed,n);for(let e=0;e<s;e++){const i=0===e?r.closed?n-1:-1:e-1,s=e===n-1?r.closed?0:-1:e+1,a=i>=0?t[i]:null,c=t[e],u=s>=0?t[s]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const h=a&&u?_t(c,r.round):0;let l,f,d,p;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,r=Math.min(h,t/2);l=Math.sin(e)*r+c.x,f=Math.cos(e)*r+c.y}else l=c.x,f=c.y;if(u){const t=Math.sqrt((u.x-c.x)**2+(u.y-c.y)**2),e=0!==t?Math.atan2(u.x-c.x,u.y-c.y):0,r=Math.min(h,t/2);d=Math.sin(e)*r+c.x,p=Math.cos(e)*r+c.y}else d=c.x,p=c.y;if(o(l,f),h>0&&a&&u)for(let t=1;t<=r.divisions;t++){const e=t/r.divisions,n=1-e;o(n*n*l+2*n*e*c.x+e*e*d,n*n*f+2*n*e*c.y+e*e*p)}else l===d&&f===p||o(d,p);if(u&&mt(c)){const t=_t(u,r.round),e=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),n=0!==e?Math.atan2(c.x-u.x,c.y-u.y):0,i=Math.min(t,e/2),s=bt({x:d,y:p},{x:Math.sin(n)*i+u.x,y:Math.cos(n)*i+u.y},c.bulge);if(s){let t=s.endAngle-s.startAngle;if(s.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=r.divisions;e++){const n=e/r.divisions,i=s.startAngle+t*n;o(s.cx+s.radius*Math.cos(i),s.cy+s.radius*Math.sin(i))}}}}if(r.closed&&i.length>0){const t=i[0],e=i[i.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&i.push({x:t.x,y:t.y})}return new Et(i,r.closed)}function At(t,e){return zt(t,e).length}function Tt(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function Ot(t){if(Tt(t)){const e=t.capacity(),r=t.available();return{capacity:e,available:r,isFull:0===r}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,r="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:r,isFull:0===r}}const e=t?.state?.capacity,r=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-r);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class It{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 jt(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 r=e.onFull(()=>t.pauseEmit()),n=e.onAvailable(()=>t.resumeEmit());return Ot(e).isFull&&t.pauseEmit(),()=>{r?.(),n?.()}}class Pt{constructor(t,e=1,r="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=r}positionAt(t,e,r,n){const i=e.maxCount??1/0;if(t<0||t>=i)return null;const o=this.owner?.state?.width??0,s=this.owner?.state?.height??0,a=n?.state?.width??0,c=n?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(s-c)/2),z:0}:{x:Math.max(0,(o-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function Rt(t,e,r,n,i,o,s){const a=r.w,c=r.h,u=n.w,h=n.h,l=n.d,f=[],d=u+i,p=h+i,g=Math.max(1,Math.floor((a+i)/d)),y=Math.max(1,Math.floor((c+i)/p)),m=g*y,b=o&&o>0?Math.floor(o):4;if("row"===t||"column"===t){const r=s?.advanceAlongX??!1,n=s?.reverse??!1,i=r?g:y,o=r?y:g,u=(t,e,n)=>((t,e,r)=>f.push({x:-a/2+(t+.5)*d,y:r*l+l/2,z:-c/2+(e+.5)*p}))(r?t:e,r?e:t,n);let h=0;for(let r=0;r<i&&h<e;r++){const s=n?i-1-r:r;if("column"===t)for(let t=0;t<o&&h<e;t++)for(let r=0;r<b&&h<e;r++)u(s,t,r),h++;else for(let t=0;t<b&&h<e;t++)for(let r=0;r<o&&h<e;r++)u(s,r,t),h++}return f}if("pyramid"===t){let t=e,r=0;for(;t>0;){const e=Math.max(1,g-r),n=Math.max(1,y-r),i=e*n,s=Math.min(t,i);for(let t=0;t<s;t++){const i=t%e,o=Math.floor(t/e),s=-a/2+(i+(g-e)/2+.5)*d,u=-c/2+(o+(y-n)/2+.5)*p;f.push({x:s,y:r*l+l/2,z:u})}if(t-=s,r++,1===e&&1===n){for(let e=0;e<t;e++)f.push({x:0,y:(r+e)*l+l/2,z:0});break}if(o&&r>=o)break}return f}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let r=0;r<e;r++){const e=Math.floor(r/m),n=r%m,i=n%g,s=Math.floor(n/g),y=(t(2*r)-.5)*u*.2,b=(t(2*r+1)-.5)*h*.2,x=-a/2+(i+.5)*d+y,v=-c/2+(s+.5)*p+b;if(f.push({x:x,y:e*l+l/2,z:v}),o&&e>=o-1&&n===m-1)break}return f}for(let r=0;r<e;r++){const e=Math.floor(r/m);if(o&&e>=o)break;const n=r%m,i=n%g,s=Math.floor(n/g);let u=-a/2+(i+.5)*d;const h=-c/2+(s+.5)*p;"staggered"===t&&e%2==1&&(u+=d/2),f.push({x:u,y:e*l+l/2,z:h})}return f}class Ct{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,r,n={}){const i=n.gap??this.defaults.gap??0,o=n.heightLimit??this.defaults.heightLimit,s=n.fill??this.defaults.fill;return Rt(this.pattern,t,e,r,i,o,s).map(t=>({position:t}))}}class Nt{constructor(t,e,r={}){this.cols=t,this.rows=e,this.defaults=r}layout(t,e,r,n={}){const i=Math.max(1,this.cols),o=Math.max(1,this.rows),s=i*o,a=n.gap??this.defaults.gap??0,c=r.w+a,u=r.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/s),n=e%s,a=n%i,l=Math.floor(n/i);h.push({position:{x:(a-(i-1)/2)*c,z:(l-(o-1)/2)*u,y:t*r.d+r.d/2}})}return h}}class Ft{constructor(t=.1,e=!1,r=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=r}grid(t,e){const r=e.w*this.gapRatio,n=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-r)/(e.w+r))),rows:Math.max(1,Math.floor((t.h-n)/(e.h+n))),pitchX:e.w+r,pitchZ:e.h+n}}capacity(t,e,r){const{cols:n,rows:i}=this.grid(t,e);return n*i*Math.max(1,Math.floor(r))}layout(t,e,r,n={}){const{cols:i,rows:o,pitchX:s,pitchZ:a}=this.grid(e,r),c=r.d+r.d*this.gapRatio,u=null!=n.heightLimit?Math.max(1,Math.floor(n.heightLimit)):1/0,h=Number.isFinite(u),l=this.sliceFirst&&h,f=i*o,d=i*(h?u:1),p=i*o*(h?u:t),g=Math.min(t,p),y=[];for(let t=0;t<g;t++){let e,n,u;if(l){const r=Math.floor(t/d),o=t%d;e=o%i,u=Math.floor(o/i),n=r}else{u=Math.floor(t/f);const r=t%f;e=r%i,n=Math.floor(r/i)}this.fillFromFar&&(n=o-1-n),y.push({position:{x:(e-(i-1)/2)*s,z:(n-(o-1)/2)*a,y:u*c+r.d/2}})}return y}}function Dt(t,e,r,n=0){for(let i=0;i<e.length;i++){const o=e[i],s=r[i];o&&s&&(o.parent!==t&&t.attach(o),o.position.set(s.position.x,n+s.position.y,s.position.z),s.rotation?o.quaternion.set(s.rotation.x,s.rotation.y,s.rotation.z,s.rotation.w):o.quaternion.identity())}}function Lt(t,e,r,n=.12){const i=e.left+e.width/2,o=e.top+e.height/2,s=Math.min(r.w,r.h)*n,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let n=a.get(t);n||(n={x:i+e.position.x-r.w/2+s,y:o+e.position.z-r.h/2+s,w:r.w-2*s,h:r.h-2*s,count:0},a.set(t,n)),n.count++}return[...a.values()]}function Yt(t,e){return t===e||t!=t&&e!=e}function $t(t,e){for(var r=t.length;r--;)if(Yt(t[r][0],e))return r;return-1}var Ut=Array.prototype.splice;function Wt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Wt.prototype.clear=function(){this.__data__=[],this.size=0},Wt.prototype.delete=function(t){var e=this.__data__,r=$t(e,t);return!(r<0)&&(r==e.length-1?e.pop():Ut.call(e,r,1),--this.size,!0)},Wt.prototype.get=function(t){var e=this.__data__,r=$t(e,t);return r<0?void 0:e[r][1]},Wt.prototype.has=function(t){return $t(this.__data__,t)>-1},Wt.prototype.set=function(t,e){var r=this.__data__,n=$t(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var qt="object"==typeof global&&global&&global.Object===Object&&global,Bt="object"==typeof self&&self&&self.Object===Object&&self,Gt=qt||Bt||Function("return this")(),Ht=Gt.Symbol,Xt=Object.prototype,Vt=Xt.hasOwnProperty,Zt=Xt.toString,Qt=Ht?Ht.toStringTag:void 0;var Jt=Object.prototype.toString;var Kt=Ht?Ht.toStringTag:void 0;function te(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Kt&&Kt in Object(t)?function(t){var e=Vt.call(t,Qt),r=t[Qt];try{t[Qt]=void 0;var n=!0}catch(t){}var i=Zt.call(t);return n&&(e?t[Qt]=r:delete t[Qt]),i}(t):function(t){return Jt.call(t)}(t)}function ee(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function re(t){if(!ee(t))return!1;var e=te(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var ne,ie=Gt["__core-js_shared__"],oe=(ne=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+ne:"";var se=Function.prototype.toString;function ae(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ce=/^\[object .+?Constructor\]$/,ue=Function.prototype,he=Object.prototype,le=ue.toString,fe=he.hasOwnProperty,de=RegExp("^"+le.call(fe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pe(t){return!(!ee(t)||(e=t,oe&&oe in e))&&(re(t)?de:ce).test(ae(t));var e}function ge(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return pe(r)?r:void 0}var ye=ge(Gt,"Map"),me=ge(Object,"create");var be=Object.prototype.hasOwnProperty;var xe=Object.prototype.hasOwnProperty;function ve(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _e(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function we(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ve.prototype.clear=function(){this.__data__=me?me(null):{},this.size=0},ve.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ve.prototype.get=function(t){var e=this.__data__;if(me){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return be.call(e,t)?e[t]:void 0},ve.prototype.has=function(t){var e=this.__data__;return me?void 0!==e[t]:xe.call(e,t)},ve.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=me&&void 0===e?"__lodash_hash_undefined__":e,this},we.prototype.clear=function(){this.size=0,this.__data__={hash:new ve,map:new(ye||Wt),string:new ve}},we.prototype.delete=function(t){var e=_e(this,t).delete(t);return this.size-=e?1:0,e},we.prototype.get=function(t){return _e(this,t).get(t)},we.prototype.has=function(t){return _e(this,t).has(t)},we.prototype.set=function(t,e){var r=_e(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function ke(t){var e=this.__data__=new Wt(t);this.size=e.size}ke.prototype.clear=function(){this.__data__=new Wt,this.size=0},ke.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ke.prototype.get=function(t){return this.__data__.get(t)},ke.prototype.has=function(t){return this.__data__.has(t)},ke.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Wt){var n=r.__data__;if(!ye||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new we(n)}return r.set(t,e),this.size=r.size,this};function Me(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new we;++e<r;)this.add(t[e])}function Se(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}Me.prototype.add=Me.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Me.prototype.has=function(t){return this.__data__.has(t)};function Ee(t,e,r,n,i,o){var s=1&r,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),h=o.get(e);if(u&&h)return u==e&&h==t;var l=-1,f=!0,d=2&r?new Me:void 0;for(o.set(t,e),o.set(e,t);++l<a;){var p=t[l],g=e[l];if(n)var y=s?n(g,p,l,e,t,o):n(p,g,l,t,e,o);if(void 0!==y){if(y)continue;f=!1;break}if(d){if(!Se(e,function(t,e){if(s=e,!d.has(s)&&(p===t||i(p,t,r,n,o)))return d.push(e);var s})){f=!1;break}}else if(p!==g&&!i(p,g,r,n,o)){f=!1;break}}return o.delete(t),o.delete(e),f}var ze=Gt.Uint8Array;function Ae(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Te(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Oe=Ht?Ht.prototype:void 0,Ie=Oe?Oe.valueOf:void 0;function je(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var Pe=Array.isArray;function Re(){return[]}var Ce=Object.prototype.propertyIsEnumerable,Ne=Object.getOwnPropertySymbols,Fe=Ne?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,o=[];++r<n;){var s=t[r];e(s,r,t)&&(o[i++]=s)}return o}(Ne(t),function(e){return Ce.call(t,e)}))}:Re;function De(t){return null!=t&&"object"==typeof t}function Le(t){return De(t)&&"[object Arguments]"==te(t)}var Ye=Object.prototype,$e=Ye.hasOwnProperty,Ue=Ye.propertyIsEnumerable,We=Le(function(){return arguments}())?Le:function(t){return De(t)&&$e.call(t,"callee")&&!Ue.call(t,"callee")};var qe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=qe&&"object"==typeof module&&module&&!module.nodeType&&module,Ge=Be&&Be.exports===qe?Gt.Buffer:void 0,He=(Ge?Ge.isBuffer:void 0)||function(){return!1},Xe=/^(?:0|[1-9]\d*)$/;function Ve(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Xe.test(t))&&t>-1&&t%1==0&&t<e}function Ze(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Qe={};function Je(t){return function(e){return t(e)}}Qe["[object Float32Array]"]=Qe["[object Float64Array]"]=Qe["[object Int8Array]"]=Qe["[object Int16Array]"]=Qe["[object Int32Array]"]=Qe["[object Uint8Array]"]=Qe["[object Uint8ClampedArray]"]=Qe["[object Uint16Array]"]=Qe["[object Uint32Array]"]=!0,Qe["[object Arguments]"]=Qe["[object Array]"]=Qe["[object ArrayBuffer]"]=Qe["[object Boolean]"]=Qe["[object DataView]"]=Qe["[object Date]"]=Qe["[object Error]"]=Qe["[object Function]"]=Qe["[object Map]"]=Qe["[object Number]"]=Qe["[object Object]"]=Qe["[object RegExp]"]=Qe["[object Set]"]=Qe["[object String]"]=Qe["[object WeakMap]"]=!1;var Ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,tr=Ke&&"object"==typeof module&&module&&!module.nodeType&&module,er=tr&&tr.exports===Ke&&qt.process,rr=function(){try{var t=tr&&tr.require&&tr.require("util").types;return t||er&&er.binding&&er.binding("util")}catch(t){}}(),nr=rr&&rr.isTypedArray,ir=nr?Je(nr):function(t){return De(t)&&Ze(t.length)&&!!Qe[te(t)]},or=Object.prototype.hasOwnProperty;function sr(t,e){var r=Pe(t),n=!r&&We(t),i=!r&&!n&&He(t),o=!r&&!n&&!i&&ir(t),s=r||n||i||o,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!or.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ve(u,c))||a.push(u);return a}var ar=Object.prototype;function cr(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ar)}function ur(t,e){return function(r){return t(e(r))}}var hr=ur(Object.keys,Object),lr=Object.prototype.hasOwnProperty;function fr(t){if(!cr(t))return hr(t);var e=[];for(var r in Object(t))lr.call(t,r)&&"constructor"!=r&&e.push(r);return e}function dr(t){return null!=t&&Ze(t.length)&&!re(t)}function pr(t){return dr(t)?sr(t):fr(t)}function gr(t){return function(t,e,r){var n=e(t);return Pe(t)?n:je(n,r(t))}(t,pr,Fe)}var yr=Object.prototype.hasOwnProperty;var mr=ge(Gt,"DataView"),br=ge(Gt,"Promise"),xr=ge(Gt,"Set"),vr=ge(Gt,"WeakMap"),_r="[object Map]",wr="[object Promise]",kr="[object Set]",Mr="[object WeakMap]",Sr="[object DataView]",Er=ae(mr),zr=ae(ye),Ar=ae(br),Tr=ae(xr),Or=ae(vr),Ir=te;(mr&&Ir(new mr(new ArrayBuffer(1)))!=Sr||ye&&Ir(new ye)!=_r||br&&Ir(br.resolve())!=wr||xr&&Ir(new xr)!=kr||vr&&Ir(new vr)!=Mr)&&(Ir=function(t){var e=te(t),r="[object Object]"==e?t.constructor:void 0,n=r?ae(r):"";if(n)switch(n){case Er:return Sr;case zr:return _r;case Ar:return wr;case Tr:return kr;case Or:return Mr}return e});var jr="[object Arguments]",Pr="[object Array]",Rr="[object Object]",Cr=Object.prototype.hasOwnProperty;function Nr(t,e,r,n,i,o){var s=Pe(t),a=Pe(e),c=s?Pr:Ir(t),u=a?Pr:Ir(e),h=(c=c==jr?Rr:c)==Rr,l=(u=u==jr?Rr:u)==Rr,f=c==u;if(f&&He(t)){if(!He(e))return!1;s=!0,h=!1}if(f&&!h)return o||(o=new ke),s||ir(t)?Ee(t,e,r,n,i,o):function(t,e,r,n,i,o,s){switch(r){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||!o(new ze(t),new ze(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Yt(+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=Ae;case"[object Set]":var c=1&n;if(a||(a=Te),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var h=Ee(a(t),a(e),n,i,o,s);return s.delete(t),h;case"[object Symbol]":if(Ie)return Ie.call(t)==Ie.call(e)}return!1}(t,e,c,r,n,i,o);if(!(1&r)){var d=h&&Cr.call(t,"__wrapped__"),p=l&&Cr.call(e,"__wrapped__");if(d||p){var g=d?t.value():t,y=p?e.value():e;return o||(o=new ke),i(g,y,r,n,o)}}return!!f&&(o||(o=new ke),function(t,e,r,n,i,o){var s=1&r,a=gr(t),c=a.length;if(c!=gr(e).length&&!s)return!1;for(var u=c;u--;){var h=a[u];if(!(s?h in e:yr.call(e,h)))return!1}var l=o.get(t),f=o.get(e);if(l&&f)return l==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var g=t[h=a[u]],y=e[h];if(n)var m=s?n(y,g,h,e,t,o):n(g,y,h,t,e,o);if(!(void 0===m?g===y||i(g,y,r,n,o):m)){d=!1;break}p||(p="constructor"==h)}if(d&&!p){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||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,r,n,i,o))}function Fr(t,e,r,n,i){return t===e||(null==t||null==e||!De(t)&&!De(e)?t!=t&&e!=e:Nr(t,e,r,n,Fr,i))}var Dr=function(){try{var t=ge(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Lr(t,e,r){"__proto__"==e&&Dr?Dr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Yr=Object.prototype.hasOwnProperty;function $r(t,e,r){var n=t[e];Yr.call(t,e)&&Yt(n,r)&&(void 0!==r||e in t)||Lr(t,e,r)}function Ur(t,e,r,n){var i=!r;r||(r={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),i?Lr(r,a,c):$r(r,a,c)}return r}function Wr(t){return t}function qr(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var Br=Math.max;function Gr(t){return function(){return t}}var Hr=Dr?function(t,e){return Dr(t,"toString",{configurable:!0,enumerable:!1,value:Gr(e),writable:!0})}:Wr,Xr=Date.now;var Vr,Zr,Qr,Jr=(Vr=Hr,Zr=0,Qr=0,function(){var t=Xr(),e=16-(t-Qr);if(Qr=t,e>0){if(++Zr>=800)return arguments[0]}else Zr=0;return Vr.apply(void 0,arguments)});function Kr(t,e){return Jr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,i=-1,o=Br(n.length-e,0),s=Array(o);++i<o;)s[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=r(s),qr(t,this,a)}}(t,e,Wr),t+"")}function tn(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?dr(r)&&Ve(e,r.length):"string"==n&&e in r)&&Yt(r[e],t)}var en=Object.prototype.hasOwnProperty;function rn(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=cr(t),r=[];for(var n in t)("constructor"!=n||!e&&en.call(t,n))&&r.push(n);return r}function nn(t){return dr(t)?sr(t,!0):rn(t)}var on,sn=(on=function(t,e,r,n){Ur(e,nn(e),t,n)},Kr(function(t,e){var r=-1,n=e.length,i=n>1?e[n-1]:void 0,o=n>2?e[2]:void 0;for(i=on.length>3&&"function"==typeof i?(n--,i):void 0,o&&tn(e[0],e[1],o)&&(i=n<3?void 0:i,n=1),t=Object(t);++r<n;){var s=e[r];s&&on(t,s,r,i)}return t})),an=ur(Object.getPrototypeOf,Object),cn=Function.prototype,un=Object.prototype,hn=cn.toString,ln=un.hasOwnProperty,fn=hn.call(Object);function dn(t){if(!De(t))return!1;var e=te(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!De(t)||"[object Object]"!=te(t))return!1;var e=an(t);if(null===e)return!0;var r=ln.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&hn.call(r)==fn}(t)}var pn=Kr(function(t,e){try{return qr(t,void 0,e)}catch(t){return dn(t)?t:new Error(t)}});function gn(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var yn=Object.prototype,mn=yn.hasOwnProperty;function bn(t,e,r,n){return void 0===t||Yt(t,yn[r])&&!mn.call(n,r)?e:t}var xn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function vn(t){return"\\"+xn[t]}var _n=/<%=([\s\S]+?)%>/g;var wn,kn=(wn={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==wn?void 0:wn[t]});function Mn(t){return"symbol"==typeof t||De(t)&&"[object Symbol]"==te(t)}var Sn=Ht?Ht.prototype:void 0,En=Sn?Sn.toString:void 0;function zn(t){if("string"==typeof t)return t;if(Pe(t))return gn(t,zn)+"";if(Mn(t))return En?En.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function An(t){return null==t?"":zn(t)}var Tn=/[&<>"']/g,On=RegExp(Tn.source);var In={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:_n,variable:"",imports:{_:{escape:function(t){return(t=An(t))&&On.test(t)?t.replace(Tn,kn):t}}}},jn=/\b__p \+= '';/g,Pn=/\b(__p \+=) '' \+/g,Rn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Cn=/[()=,{}\[\]\/\s]/,Nn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fn=/($^)/,Dn=/['\n\r\u2028\u2029\\]/g,Ln=Object.prototype.hasOwnProperty;var Yn="object"==typeof exports&&exports&&!exports.nodeType&&exports,$n=Yn&&"object"==typeof module&&module&&!module.nodeType&&module,Un=$n&&$n.exports===Yn?Gt.Buffer:void 0,Wn=Un?Un.allocUnsafe:void 0;var qn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)je(e,Fe(t)),t=an(t);return e}:Re;var Bn=Object.prototype.hasOwnProperty;var Gn=/\w*$/;var Hn=Ht?Ht.prototype:void 0,Xn=Hn?Hn.valueOf:void 0;function Vn(t,e,r){var n,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new ze(a).set(new ze(s)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return o=(i=t).buffer,new i.constructor(o,i.byteOffset,i.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,Gn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Xn?Object(Xn.call(n)):{}}}var Zn=Object.create,Qn=function(){function t(){}return function(e){if(!ee(e))return{};if(Zn)return Zn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();var Jn=rr&&rr.isMap,Kn=Jn?Je(Jn):function(t){return De(t)&&"[object Map]"==Ir(t)};var ti=rr&&rr.isSet,ei=ti?Je(ti):function(t){return De(t)&&"[object Set]"==Ir(t)},ri="[object Arguments]",ni="[object Function]",ii="[object Object]",oi={};function si(t,e,r,n,i,o){var s,a=2&e;if(void 0!==s)return s;if(!ee(t))return t;var c=Pe(t);if(c)return s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Bn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,s);var u=Ir(t),h=u==ni||"[object GeneratorFunction]"==u;if(He(t))return function(t){var e=t.length,r=Wn?Wn(e):new t.constructor(e);return t.copy(r),r}(t);if(u==ii||u==ri||h&&!i)return s=h?{}:function(t){return"function"!=typeof t.constructor||cr(t)?{}:Qn(an(t))}(t),a?function(t,e){return Ur(t,qn(t),e)}(t,function(t,e){return t&&Ur(e,nn(e),t)}(s,t)):function(t,e){return Ur(t,Fe(t),e)}(t,function(t,e){return t&&Ur(e,pr(e),t)}(s,t));if(!oi[u])return i?t:{};s=Vn(t,u),o||(o=new ke);var l=o.get(t);if(l)return l;o.set(t,s),ei(t)?t.forEach(function(n){s.add(si(n,e,r,n,t,o))}):Kn(t)&&t.forEach(function(n,i){s.set(i,si(n,e,r,i,t,o))});var f=c?void 0:gr(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(f||t,function(n,i){f&&(n=t[i=n]),$r(s,i,si(n,e,r,i,t,o))}),s}oi[ri]=oi["[object Array]"]=oi["[object ArrayBuffer]"]=oi["[object DataView]"]=oi["[object Boolean]"]=oi["[object Date]"]=oi["[object Float32Array]"]=oi["[object Float64Array]"]=oi["[object Int8Array]"]=oi["[object Int16Array]"]=oi["[object Int32Array]"]=oi["[object Map]"]=oi["[object Number]"]=oi[ii]=oi["[object RegExp]"]=oi["[object Set]"]=oi["[object String]"]=oi["[object Symbol]"]=oi["[object Uint8Array]"]=oi["[object Uint8ClampedArray]"]=oi["[object Uint16Array]"]=oi["[object Uint32Array]"]=!0,oi["[object Error]"]=oi[ni]=oi["[object WeakMap]"]=!1;function ai(t){return si(t,4)}var ci=/\s/;var ui=/^\s+/;function hi(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ci.test(t.charAt(e)););return e}(t)+1).replace(ui,""):t}var li=/^[-+]0x[0-9a-f]+$/i,fi=/^0b[01]+$/i,di=/^0o[0-7]+$/i,pi=parseInt;var gi=1/0;function yi(t){return t?(t=function(t){if("number"==typeof t)return t;if(Mn(t))return NaN;if(ee(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ee(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=hi(t);var r=fi.test(t);return r||di.test(t)?pi(t.slice(2),r?2:8):li.test(t)?NaN:+t}(t))===gi||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function mi(t,e){var r;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=yi(t),r=e%1;return e==e?r?e-r:e:0}(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=void 0),r}}var bi=Object.prototype.hasOwnProperty;function xi(t){if(null==t)return!0;if(dr(t)&&(Pe(t)||"string"==typeof t||"function"==typeof t.splice||He(t)||ir(t)||We(t)))return!t.length;var e=Ir(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(cr(t))return!fr(t).length;for(var r in t)if(bi.call(t,r))return!1;return!0}let vi=0;function _i(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 wi(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function ki(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Mi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function Si(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Ei(t){if(this.__collection__)return this.__collection__[t]}function zi(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function Ai(t){return this.__collection__?this.__collection__.indexOf(t):-1}function Ti(){return this.__collection__?this.__collection__.length:0}function Oi(){this.__collection__=[]}function Ii(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function ji(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 Pi(t){const e=this.indexOf(t);if(-1==e||0==e)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(r,n)}function Ri(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=r.concat(n,this.__collection__)}class Ci{constructor(){this.__collection__=[],this.insertAt=wi,this.append=ki,this.prepend=Mi,this.remove=Si,this.getAt=Ei,this.forEach=zi,this.indexOf=Ai,this.size=Ti,this.clear=Oi,this.moveForward=Ii,this.moveBackward=ji,this.moveToHead=Pi,this.moveToTail=Ri}}const Ni=/\s+/;function Fi(t,e,r,n){if(!r)return!0;if("object"==typeof r){for(const n in r){const i=r[n];t[e].apply(t,[n,i])}return!1}if(Ni.test(r)){return r.split(Ni).forEach(r=>t[e].apply(t,[r].concat(n))),!1}return!0}const Di=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],Li={withEvent(){Di.forEach(t=>this[t]=Li[t])},on(t,e,r){if(!Fi(this,"on",t,[e,r])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:r,ctx:r||this}),this},once(t,e,r){if(!Fi(this,"once",t,[e,r])||!e)return this;const n=this,i=function(t){return mi(2,t)}(function(){n.off(t,i,r),e.apply(n,arguments)});return i._callback=e,this.on(t,i,r),this},off(t,e,r){if(!this._listeners||!Fi(this,"off",t,[e,r]))return this;if(!t&&!e&&!r)return this._listeners=void 0,this;let n;n=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<n.length;t++){const i=n[t],o=this._listeners?.[i];if(o){const t=[];if(this._listeners[i]=t,e||r)for(let n=0;n<o.length;n++){const i=o[n];(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new Ci),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&&$i(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 r=this._listeners[e.name],n=this._listeners["(all)"];return r&&Yi(r,arguments),n&&Yi(n,arguments),this},trigger(t){G.enabled&&G.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&$i(this._delegators,e),!this._listeners)return this;if(!Fi(this,"trigger",t,e))return this;const r=this._listeners[t],n=this._listeners["(all)"];return r&&Yi(r,e),n&&Yi(n,e),this},stopListening(t,e,r){let n=this._listeningTo;if(!n)return this;const i=!e&&!r;r||"object"!=typeof e||(r=this),t&&(n={},n[t._listenId]=t);for(const t in n){const o=n[t];o.off(e,r,this),(i||xi(o._events))&&delete this._listeningTo[t]}return this}};function Yi(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function $i(t,e){t.forEach(t=>Li.delegate.apply(t,e))}const Ui={listenTo:"on",listenToOnce:"once"};for(const t in Ui){const e=Ui[t];Li[t]=function(t,r,n){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++vi}`);return i[t._listenId]=t,n||"object"!=typeof r||(n=this),t[e](r,n,this),this}}const Wi=Li.on,qi=Li.off,Bi=Li.once,Gi=Li.trigger,Hi=Li.delegate_on,Xi=Li.delegate_off;const Vi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Zi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Qi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ji(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 Ki,to={exports:{}};var eo=(Ki||(Ki=1,function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,s=Object.create(o.prototype),a=new O(n||[]);return i(s,"_invoke",{value:E(t,r,a)}),s}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f="suspendedStart",d="suspendedYield",p="executing",g="completed",y={};function m(){}function b(){}function x(){}var v={};u(v,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(I([])));w&&w!==r&&n.call(w,s)&&(v=w);var k=x.prototype=m.prototype=Object.create(v);function M(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function r(i,o,s,a){var c=l(t[i],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){r("next",t,s,a)},function(t){r("throw",t,s,a)}):e.resolve(h).then(function(t){u.value=t,s(u)},function(t){return r("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e(function(e,i){r(t,n,e,i)})}return o=o?o.then(i,i):i()}})}function E(t,r,n){var i=f;return function(o,s){if(i===p)throw new Error("Generator is already running");if(i===g){if("throw"===o)throw s;return{value:e,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=z(a,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?g:d,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=g,n.method="throw",n.arg=u.arg)}}}function z(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,z(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=l(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var s=o.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function A(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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(t){if(null!=t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=x,i(k,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=u(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,u(t,c,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},M(S.prototype),u(S.prototype,a,function(){return this}),t.AsyncIterator=S,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new S(h(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},M(k),u(k,c,"Generator"),u(k,s,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=I,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(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=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 r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(s)},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 r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"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 r=[],n=0,i="",o=0,s=arguments.length;o!==s;++o){var a=+arguments[o];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?n=r.push(a):(a-=65536,n=r.push(55296+(a>>10),a%1024+56320)),n>=16383&&(i+=t.apply(null,r),r.length=0)}return i+t.apply(null,r)};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,r=e(t,t,t)&&e}catch(t){}return r}(),e=function(t){if(null==this)throw TypeError();var e=String(this),r=e.length,n=t?Number(t):0;if(n!=n&&(n=0),!(n<0||n>=r)){var i,o=e.charCodeAt(n);return o>=55296&&o<=56319&&r>n+1&&(i=e.charCodeAt(n+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};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,r,n){function i(s,a){if(!r[s]){if(!e[s]){if(!a&&Ji)return Ji(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[s]={exports:{}};e[s][0].call(u.exports,function(t){return i(e[s][1][t]||t)},u,u.exports,t,e,r,n)}return r[s].exports}for(var o=Ji,s=0;s<n.length;s++)i(n[s]);return i}return t}()({1:[function(t,e,r){var n=t("./utils"),i=function(){var t=n.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],r=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],i=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],o=["Thousand","Million","Billion","Trillion"];function s(t,n){var s=function t(n,s,a){var c="";if(n<=19)c=(s?" and ":"")+(a?r[n]:e[n]);else if(n<100){var u=Math.floor(n/10),h=n%10;c=(s?" and ":"")+i[u-2],h>0?c+="-"+t(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(n<1e3){var l=Math.floor(n/100),f=n%100;c=(s?", ":"")+e[l]+" Hundred",f>0?c+=t(f,!0,a):a&&(c+="th")}else{var d=Math.floor(Math.log10(n)/3);d>o.length&&(d=o.length);var p=Math.pow(10,3*d),g=Math.floor(n/p),y=n-g*p;c=(s?", ":"")+t(g,!1,!1)+" "+o[d-1],y>0?c+=t(y,!0,a):a&&(c+="th")}return c};return s(t,!1,n)}var a={};function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),r=[0];return e.forEach(function(t){if(t<100){var e=r.pop();e>=1e3&&(r.push(e),e=0),r.push(e+t)}else r.push(r.pop()*t)}),r.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var r=t.toLowerCase();a[r]=10*(e+2),a[r.substring(0,t.length-1)+"ieth"]=a[r]}),a.hundredth=100,o.forEach(function(t,e){var r=t.toLowerCase(),n=Math.pow(10,3*(e+1));a[r]=n,a[r+"th"]=n});var u=[[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"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function l(t){for(var e=0;e<u.length;e++){var r=u[e];if(t>=r[0])return r[1]+l(t-r[0])}return""}function f(t){for(var e=0,r=1,n=t.length-1;n>=0;n--){var i=t[n],o=h[i];o<r?e-=o:(r=o,e+=o)}return e}function d(t,e){for(var r=[],n=e.charCodeAt(0);t>0;)r.unshift(String.fromCharCode((t-1)%26+n)),t=Math.floor((t-1)/26);return r.join("")}function p(t,e){for(var r=e.charCodeAt(0),n=0,i=0;i<t.length;i++)n+=(t.charCodeAt(t.length-i-1)-r+1)*Math.pow(26,i);return n}function g(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"},m={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,r){var n,i=e<0;switch(e=Math.abs(e),r.primary){case y.LETTERS:n=d(e,r.case===m.UPPER?"A":"a");break;case y.ROMAN:n=l(e),r.case===m.UPPER&&(n=n.toUpperCase());break;case y.WORDS:n=s(e,r.ordinal),r.case===m.UPPER?n=n.toUpperCase():r.case===m.LOWER&&(n=n.toLowerCase());break;case y.DECIMAL:n=""+e;var o=r.mandatoryDigits-n.length;if(o>0){var a=new Array(o+1).join("0");n=a+n}if(48!==r.zeroCode&&(n=t(n).map(function(t){return String.fromCodePoint(t.codePointAt(0)+r.zeroCode-48)}).join("")),r.regular)for(var c=Math.floor((n.length-1)/r.groupingSeparators.position);c>0;c--){var u=n.length-c*r.groupingSeparators.position;n=n.substr(0,u)+r.groupingSeparators.character+n.substr(u)}else r.groupingSeparators.reverse().forEach(function(t){var e=n.length-t.position;n=n.substr(0,e)+t.character+n.substr(e)});if(r.ordinal){var h={1:"st",2:"nd",3:"rd"}[n[n.length-1]];(!h||n.length>1&&"1"===n[n.length-2])&&(h="th"),n+=h}break;case y.SEQUENCE:throw{code:"D3130",value:r.token}}return i&&(n="-"+n),n}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 r,n={type:"integer",primary:y.DECIMAL,case:m.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?r=e:(r=e.substring(0,i),"o"===e.substring(i+1)[0]&&(n.ordinal=!0)),r){case"A":n.case=m.UPPER;case"a":n.primary=y.LETTERS;break;case"I":n.case=m.UPPER;case"i":n.primary=y.ROMAN;break;case"W":n.case=m.UPPER,n.primary=y.WORDS;break;case"Ww":n.case=m.TITLE,n.primary=y.WORDS;break;case"w":n.primary=y.WORDS;break;default:var o=null,s=0,a=0,c=[],u=0;if(t(r).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,r=0;r<x.length;r++){var n=x[r];if(t>=n&&t<=n+9){if(e=!0,s++,u++,null===o)o=n;else if(n!==o)throw{code:"D3131"};break}}e||(35===t?(u++,a++):c.push({position:u,character:String.fromCodePoint(t)}))}),s>0){n.primary=y.DECIMAL,n.zeroCode=o,n.mandatoryDigits=s,n.optionalDigits=a;var h=function(t){if(0===t.length)return 0;for(var e=t[0].character,r=1;r<t.length;r++)if(t[r].character!==e)return 0;for(var n=t.map(function(t){return t.position}),i=function t(e,r){return 0===r?e:t(r,e%r)},o=n.reduce(i),s=1;s<=n.length;s++)if(-1===n.indexOf(s*o))return 0;return o}(c);h>0?(n.regular=!0,n.groupingSeparators={position:h,character:c[0].character}):(n.regular=!1,n.groupingSeparators=c)}else n.primary=y.SEQUENCE,n.token=r}return n}var _={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 w(t){for(var e=[],r={type:"datetime",parts:e},n=function(r,n){if(n>r){var i=t.substring(r,n);i=i.split("]]").join("]"),e.push({type:"literal",value:i})}},i=0,o=0;o<t.length;){if("["===t.charAt(o)){if("["===t.charAt(o+1)){n(i,o),e.push({type:"literal",value:"["}),i=o+=2;continue}if(n(i,o),i=o,-1===(o=t.indexOf("]",i)))throw{code:"D3135"};var s,a=t.substring(i+1,o),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},u=a.lastIndexOf(",");if(-1!==u){var h=a.substring(u+1),l=h.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===l?f=h:(f=h.substring(0,l),d=h.substring(l+1));var g={min:p(f),max:p(d)};c.width=g,s=a.substring(1,u)}else s=a.substring(1);if(1===s.length)c.presentation1=s;else if(s.length>1){var y=s.charAt(s.length-1);-1!=="atco".indexOf(y)?(c.presentation2=y,"o"===y&&(c.ordinal=!0),c.presentation1=s.substring(0,s.length-1)):c.presentation1=s}else c.presentation1=_[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=m.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=m.TITLE:c.names=m.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),i=o+1}o++}return n(i,o),r}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M=["January","February","March","April","May","June","July","August","September","October","November","December"],S=864e5,E=function(t){var e=Date.UTC(t.year,t.month),r=new Date(e).getUTCDay();return 0===r&&(r=7),r>4?e+(8-r)*S:e-(r-1)*S},z=function t(e,r){return{year:e,month:r,nextMonth:function(){return 11===r?t(e+1,0):t(e,r+1)},previousMonth:function(){return 0===r?t(e-1,11):t(e,r-1)},nextYear:function(){return t(e+1,r)},previousYear:function(){return t(e-1,r)}}},A=function(t,e){return(e-t)/(7*S)+1},T=function(t,e){var r;switch(e){case"Y":r=t.getUTCFullYear();break;case"M":r=t.getUTCMonth()+1;break;case"D":r=t.getUTCDate();break;case"d":r=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/S+1;break;case"F":0===(r=t.getUTCDay())&&(r=7);break;case"W":var n=z(t.getUTCFullYear(),0),i=E(n),o=Date.UTC(n.year,t.getUTCMonth(),t.getUTCDate()),s=A(i,o);if(s>52)o>=E(n.nextYear())&&(s=1);else if(s<1){var a=E(n.previousYear());s=A(a,o)}r=Math.floor(s);break;case"w":var c=z(t.getUTCFullYear(),t.getUTCMonth()),u=E(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),l=A(u,h);if(l>4)h>=E(c.nextMonth())&&(l=1);else if(l<1){var f=E(c.previousMonth());l=A(f,h)}r=Math.floor(l);break;case"X":var d=z(t.getUTCFullYear(),0),p=E(d),g=E(d.nextYear()),y=t.getTime();r=y<p?d.year-1:y>=g?d.year+1:d.year;break;case"x":var m=z(t.getUTCFullYear(),t.getUTCMonth()),b=E(m),x=m.nextMonth(),v=E(x),_=t.getTime();r=_<b?m.previousMonth().month+1:_>=v?x.month+1:m.month+1;break;case"H":r=t.getUTCHours();break;case"h":r=t.getUTCHours(),0==(r%=12)&&(r=12);break;case"P":r=t.getUTCHours()>=12?"pm":"am";break;case"m":r=t.getUTCMinutes();break;case"s":r=t.getUTCSeconds();break;case"f":r=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":r="ISO"}return r},O=null;function I(t,e,r){var n=0,i=0;if(void 0!==r){var o=parseInt(r);n=Math.floor(o/100),i=o%100}var s,a=function(t,e){var r=T(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(r%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)r=M[r-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};r=k[r]}e.names===m.UPPER?r=r.toUpperCase():e.names===m.LOWER&&(r=r.toLowerCase()),e.width&&r.length>e.width.max&&(r=r.substring(0,e.width.max))}else r=b(r,e.integerFormat);else if("f"===e.component)r=b(r,e.integerFormat);else if("Z"===e.component||"z"===e.component){var o=100*n+i;if(e.integerFormat.regular)r=b(o,e.integerFormat);else{var s=e.integerFormat.mandatoryDigits;if(1===s||2===s)r=b(n,e.integerFormat),0!==i&&(r+=":"+g(i,"00"));else{if(3!==s&&4!==s)throw{code:"D3134",value:s};r=b(o,e.integerFormat)}}o>=0&&(r="+"+r),"z"===e.component&&(r="GMT"+r),0===o&&"t"===e.presentation2&&(r="Z")}return r};void 0===e?(null===O&&(O=w("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),s=O):s=w(e);var c=new Date(t+60*(60*n+i)*1e3),u="";return s.parts.forEach(function(t){"literal"===t.type?u+=t.value:u+=a(c,t)}),u}function j(t){var e={};if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e={};if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var r;Array.isArray(t.integerFormat.groupingSeparators)||(r=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",r&&(e.regex+=r.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var n=0,i=0;return r?(n=Number.parseInt(e.substring(0,e.indexOf(r.character))),i=Number.parseInt(e.substring(e.indexOf(r.character)+1))):e.length-1<=2?n=Number.parseInt(e):(n=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*n+i}}else if(t.integerFormat)t.integerFormat.n=t.n,e=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var n={};if("M"===t.component||"x"===t.component)M.forEach(function(e,r){t.width&&t.width.max?n[e.substring(0,t.width.max)]=r+1:n[e]=r+1});else if("F"===t.component)k.forEach(function(e,r){r>0&&(t.width&&t.width.max?n[e.substring(0,t.width.max)]=r:n[e]=r)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};n={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return n[t]}}return e.component=t.component,e});else{e.type="integer";var r,n=t.case===m.UPPER;switch(r=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=n?"[A-Z]+":"[a-z]+",e.parse=function(t){return p(t,n?"A":"a")};break;case y.ROMAN:e.regex=n?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return f(n?t:t.toUpperCase())};break;case y.WORDS:e.regex="(?:"+Object.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case y.DECIMAL:e.regex="[0-9]".concat(r),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var r=e;return t.ordinal&&(r=e.substring(0,e.length-2)),t.regular?r=r.split(",").join(""):t.groupingSeparators.forEach(function(t){r=r.split(t.character).join("")}),48!==t.zeroCode&&(r=r.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(r)};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 R(t,e){var r=j(w(e)),n="^"+r.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(n,"i").exec(t);if(null!==i){for(var o=161,s=130,a=84,c=72,u=23,h=47,l={},f=1;f<i.length;f++){var d=r.parts[f-1];d.parse&&(l[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(l).length)return;var p=0,g=function(t){p<<=1,p+=t?1:0},y=function(t){return!(~t&p||!(t&p))};"YXMxWwdD".split("").forEach(function(t){return g(l[t])});var m=!y(o)&&y(s),b=y(a),x=!b&&y(c);p=0,"PHhmsf".split("").forEach(function(t){return g(l[t])});var v=!y(u)&&y(h),_=(m?"YD":b?"XxwF":x?"XWF":"YMD")+(v?"Phmsf":"Hmsf"),k=this.environment.timestamp,M=!1,S=!1;if(_.split("").forEach(function(t){if(void 0===l[t])M?(l[t]=-1!=="MDd".indexOf(t)?1:0,S=!0):l[t]=T(k,t);else if(M=!0,S)throw{code:"D3136"}}),l.M>0?l.M-=1:l.M=0,m){var E=Date.UTC(l.Y,0),z=1e3*(l.d-1)*60*60*24,A=new Date(E+z);l.M=A.getUTCMonth(),l.D=A.getUTCDate()}if(b)throw{code:"D3136"};if(x)throw{code:"D3136"};v&&(l.H=12===l.h?0:l.h,1===l.P&&(l.H+=12));var O=Date.UTC(l.Y,l.M,l.D,l.H,l.m,l.s,l.f);return(l.Z||l.z)&&(O-=60*(l.Z||l.z)*1e3),O}}var C=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 N(t,e){if(void 0!==t){if(void 0===e){if(!C.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return R.call(this,t,e)}}function F(t,e,r){if(void 0!==t)return I.call(this,t,e,r)}return{formatInteger:g,parseInteger:P,fromMillis:F,toMillis:N}}();e.exports=i},{"./utils":6}],2:[function(t,e,r){(function(r){(function(){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,o=Object.create(i.prototype),a=new j(n||[]);return s(o,"_invoke",{value:A(t,r,a)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",y="executing",m="completed",b={};function x(){}function v(){}function _(){}var w={};l(w,c,function(){return this});var k=Object.getPrototypeOf,M=k&&k(k(P([])));M&&M!==r&&o.call(M,c)&&(w=M);var S=_.prototype=x.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function z(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==n(l)&&o.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(l).then(function(t){h.value=t,a(h)},function(t){return r("throw",t,a,c)})}c(u.arg)}var i;s(this,"_invoke",{value:function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()}})}function A(e,r,n){var i=p;return function(o,s){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=T(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?m:g,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function T(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return v.prototype=_,s(S,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:v,configurable:!0}),v.displayName=l(_,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,h,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(z.prototype),l(z.prototype,u,function(){return this}),e.AsyncIterator=z,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new z(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},E(S),l(S,h,"Generator"),l(S,c,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=P,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(s)},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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var o=t("./utils"),s=function(){var t=i().mark($),e=i().mark(U),s=i().mark(W),a=i().mark(q),c=i().mark(Q),u=i().mark(ft),h=i().mark(dt),l=i().mark(pt),f=i().mark(yt),d=i().mark(Mt),p=i().mark(At),g=i().mark(It),y=o.isNumeric,m=o.isArrayOfStrings,b=o.isArrayOfNumbers,x=o.createSequence,v=o.isSequence,_=o.isFunction,w=o.isLambda,k=o.isIterable,M=o.getFunctionArity,S=o.isDeepEqual,E=o.stringToArray;function z(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function A(t){return void 0===t?0:t.length}function T(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function O(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function I(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function j(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var r;if("string"==typeof t)r=t;else if(_(t))r="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var n=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),r=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&y(e)?Number(e.toPrecision(15)):e&&_(e)?"":e},n)}return r}}function P(t,e,r){if(void 0!==t){var n=E(t),i=n.length;if(i+e<0&&(e=0),void 0!==r){if(r<=0)return"";var o=e>=0?e+r:i+e+r;return n.slice(e,o).join("")}return n.slice(e).join("")}}function R(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function C(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function N(t){if(void 0!==t)return t.toLowerCase()}function F(t){if(void 0!==t)return t.toUpperCase()}function D(t){if(void 0!==t)return E(t).length}function L(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 Y(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-D(t);if(i>0){var o=new Array(i+1).join(r);r.length>1&&(o=P(o,0,i)),n=e>0?t+o:o+t}else n=t;return n}}function $(e,r){var n;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.apply(this,[r]),!k(n)){t.next=4;break}return t.delegateYield(n,"t0",3);case 3:n=t.t0;case 4:if(!n||"number"==typeof n.start||"number"===n.end||Array.isArray(n.groups)||_(n.next)){t.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}},t,this)}function U(t,r){var n,o;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t){e.next=2;break}return e.abrupt("return",void 0);case 2:if("string"!=typeof r){e.next=6;break}n=-1!==t.indexOf(r),e.next=9;break;case 6:return e.delegateYield($(r,t),"t0",7);case 7:o=e.t0,n=void 0!==o;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e)}function W(t,e,r){var n,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{stack:(new Error).stack,value:r,code:"D3040",index:3};case 4:if(n=x(),!(void 0===r||r>0)){i.next=17;break}return o=0,i.delegateYield($(e,t),"t0",8);case 8:if(void 0===(a=i.t0)){i.next=17;break}case 10:if(void 0===a||!(void 0===r||o<r)){i.next=17;break}return n.push({match:a.match,index:a.start,groups:a.groups}),i.delegateYield($(a.next),"t1",13);case 13:a=i.t1,o++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}},s)}function q(t,e,r,n){var o,s,c,u,h,l,f,d;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(o=this,""!==e){i.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(n<0)){i.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:n,index:4};case 7:if(s="string"==typeof r?function(t){for(var e="",n=0,i=r.indexOf("$",n);-1!==i&&n<r.length;){e+=r.substring(n,i),n=i+1;var o=r.charAt(n);if("$"===o)e+="$",n++;else if("0"===o)e+=t.match,n++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+s),10),s>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,c="",u=0,!(void 0===n||n>0)){i.next=44;break}if(h=0,"string"!=typeof e){i.next=18;break}for(l=t.indexOf(e,u);-1!==l&&(void 0===n||h<n);)c+=t.substring(u,l),c+=r,u=l+e.length,h++,l=t.indexOf(e,u);c+=t.substring(u),i.next=42;break;case 18:return i.delegateYield($(e,t),"t0",19);case 19:if(void 0===(f=i.t0)){i.next=41;break}case 21:if(void 0===f||!(void 0===n||h<n)){i.next=38;break}if(c+=t.substring(u,f.start),d=s.apply(o,[f]),!k(d)){i.next=27;break}return i.delegateYield(d,"t1",26);case 26:d=i.t1;case 27:if("string"!=typeof d){i.next=31;break}c+=d,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:d};case 32:return u=f.start+f.match.length,h++,i.delegateYield($(f.next),"t2",35);case 35:f=i.t2,i.next=21;break;case 38:c+=t.substring(u),i.next=42;break;case 41:c=t;case 42:i.next=45;break;case 44:c=t;case 45:return i.abrupt("return",c);case 46:case"end":return i.stop()}},a,this)}function B(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new r.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 r.Buffer.from(t,"base64").toString("binary")};return e(t)}}function H(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 X(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 V(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 Z(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 Q(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:r,index:3};case 4:if(n=[],!(void 0===r||r>0)){i.next=27;break}if("string"!=typeof e){i.next=10;break}n=t.split(e,r),i.next=27;break;case 10:return o=0,i.delegateYield($(e,t),"t0",12);case 12:if(void 0===(s=i.t0)){i.next=26;break}a=0;case 15:if(void 0===s||!(void 0===r||o<r)){i.next=23;break}return n.push(t.substring(a,s.start)),a=s.end,i.delegateYield($(s.next),"t1",19);case 19:s=i.t1,o++,i.next=15;break;case 23:(void 0===r||o<r)&&n.push(t.substring(a)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}},c)}function J(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function K(t,e,r){if(void 0!==t){var n={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==r&&Object.keys(r).forEach(function(t){n[t]=r[t]});for(var i=[],o=n["zero-digit"].charCodeAt(0),s=o;s<o+10;s++)i.push(String.fromCharCode(s));var a=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),c=e.split(n["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,r,i,o,s=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),c=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),u=t.substring(s.length,t.length-c.length),h=t.indexOf(n["exponent-separator"],s.length);-1===h||h>t.length-c.length?(e=u,r=void 0):(e=u.substring(0,h),r=u.substring(h+1));var l=e.indexOf(n["decimal-separator"]);return-1===l?(i=e,o=c):(i=e.substring(0,l),o=e.substring(l+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:o,subpicture:t}},h=function(t){var e,r,o=t.subpicture,s=o.indexOf(n["decimal-separator"]);s!==o.lastIndexOf(n["decimal-separator"])&&(e="D3081"),o.indexOf(n.percent)!==o.lastIndexOf(n.percent)&&(e="D3082"),o.indexOf(n["per-mille"])!==o.lastIndexOf(n["per-mille"])&&(e="D3083"),-1!==o.indexOf(n.percent)&&-1!==o.indexOf(n["per-mille"])&&(e="D3084");var c=!1;for(r=0;r<t.mantissaPart.length;r++){var u=t.mantissaPart.charAt(r);if(-1!==i.indexOf(u)||u===n.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!==s?o.charAt(s-1)!==n["grouping-separator"]&&o.charAt(s+1)!==n["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===n["grouping-separator"]&&(e="D3088"),-1!==o.indexOf(n["grouping-separator"]+n["grouping-separator"])&&(e="D3089");var h=t.integerPart.indexOf(n.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var l="string"==typeof t.exponentPart;if(l&&t.exponentPart.length>0&&(-1!==o.indexOf(n.percent)||-1!==o.indexOf(n["per-mille"]))&&(e="D3092"),l&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===i.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},l=function(t){var e=function(e,r){for(var o=[],s=e.indexOf(n["grouping-separator"]);-1!==s;){var a=(r?e.substring(0,s):e.substring(s)).split("").filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length;o.push(a),s=t.integerPart.indexOf(n["grouping-separator"],s+1)}return o},r=e(t.integerPart),o=function(t){if(0===t.length)return 0;for(var e=function t(e,r){return 0===r?e:t(r,e%r)},r=t.reduce(e),n=1;n<=t.length;n++)if(-1===t.indexOf(n*r))return 0;return r}(r),s=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,u=t.fractionalPart.split(""),h=u.filter(function(t){return-1!==i.indexOf(t)}).length,l=u.filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===l&&(f?(h=1,l=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(n.digit)&&(a=1),0===a&&0===h&&(h=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:r,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:h,maximumFactionalPartSize:l,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},f=c.map(u);f.forEach(h);var d,p,g,y,m=f.map(l),b=n["minus-sign"],x=n["zero-digit"],v=n["decimal-separator"],_=n["grouping-separator"];if(1===m.length&&(m.push(JSON.parse(JSON.stringify(m[0]))),m[1].prefix=b+m[1].prefix),p=-1!==(d=t>=0?m[0]:m[1]).picture.indexOf(n.percent)?100*t:-1!==d.picture.indexOf(n["per-mille"])?1e3*t:t,0===d.minimumExponentSize)g=p;else{var w=Math.pow(10,d.scalingFactor),k=Math.pow(10,d.scalingFactor-1);for(g=p,y=0;g<k;)g*=10,y-=1;for(;g>w;)g/=10,y+=1}var M=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==x&&(r=r.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),r},S=M(ot(g,d.maximumFactionalPartSize),d.maximumFactionalPartSize),E=S.indexOf(".");for(-1===E?S+=v:S=S.replace(".",v);S.charAt(0)===x;)S=S.substring(1);for(;S.charAt(S.length-1)===x;)S=S.substring(0,S.length-1);E=S.indexOf(v);var z=d.minimumIntegerPartSize-E,A=d.minimumFactionalPartSize-(S.length-E-1);if(S=(z>0?new Array(z+1).join(x):"")+S,S+=A>0?new Array(A+1).join(x):"",E=S.indexOf(v),d.regularGrouping>0)for(var T=Math.floor((E-1)/d.regularGrouping),O=1;O<=T;O++)S=[S.slice(0,E-O*d.regularGrouping),_,S.slice(E-O*d.regularGrouping)].join("");else d.integerPartGroupingPositions.forEach(function(t){S=[S.slice(0,E-t),_,S.slice(E-t)].join(""),E++});if(E=S.indexOf(v),d.fractionalPartGroupingPositions.forEach(function(t){S=[S.slice(0,t+E+1),_,S.slice(t+E+1)].join("")}),E=S.indexOf(v),-1!==d.picture.indexOf(v)&&E!==S.length-1||(S=S.substring(0,S.length-1)),void 0!==y){var I=M(y,0);(z=d.minimumExponentSize-I.length)>0&&(I=new Array(z+1).join(x)+I),S=S+n["exponent-separator"]+(y<0?b:"")+I}return S=d.prefix+S+d.suffix}}function tt(t,e){if(void 0!==t){if(t=ot(t),(e=void 0===e?10:ot(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function et(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 nt(t){if(void 0!==t)return Math.floor(t)}function it(t){if(void 0!==t)return Math.ceil(t)}function ot(t,e){var r;if(void 0!==t){if(e){var n=t.toString().split("e");t=+(n[0]+"e"+(n[1]?+n[1]+e:e))}var i=(r=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(r%2)&&(r-=1),e&&(n=r.toString().split("e"),r=+(n[0]+"e"+(n[1]?+n[1]-e:-e))),Object.is(r,-0)&&(r=0),r}}function st(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function at(t,e){var r;if(void 0!==t){if(r=Math.pow(t,e),!isFinite(r))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return r}}function ct(){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):y(t)?0!==t&&(e=!0):null!==t&&"object"===n(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ht(t){if(void 0!==t)return!ut(t)}function lt(t,e,r,n){var i=[e],o=M(t);return o>=2&&i.push(r),o>=3&&i.push(n),i}function ft(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=x(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return o=lt(e,t[n],n,t),i.delegateYield(e.apply(this,o),"t0",7);case 7:void 0!==(s=i.t0)&&r.push(s);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}},u,this)}function dt(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=x(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return o=t[n],s=lt(e,o,n,t),i.delegateYield(e.apply(this,s),"t0",8);case 8:ut(i.t0)&&r.push(o);case 10:n++,i.next=4;break;case 13:return i.abrupt("return",r);case 14:case"end":return i.stop()}},h,this)}function pt(t,e){var r,n,o,s,a,c,u;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=!1,o=0;case 4:if(!(o<t.length)){i.next=22;break}if(s=t[o],a=!0,void 0===e){i.next=12;break}return c=lt(e,s,o,t),i.delegateYield(e.apply(this,c),"t0",10);case 10:u=i.t0,a=ut(u);case 12:if(!a){i.next=19;break}if(r){i.next=18;break}n=s,r=!0,i.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:o};case 19:o++,i.next=4;break;case 22:if(r){i.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return i.abrupt("return",n);case 25:case"end":return i.stop()}},l,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),n=0;n<r;n++){var i=e.map(function(t){return t[n]});t.push(i)}return t}function yt(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!((o=M(e))<2)){i.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===r&&t.length>0?(n=t[0],s=1):(n=r,s=0);case 6:if(!(s<t.length)){i.next=15;break}return a=[n,t[s]],o>=3&&a.push(s),o>=4&&a.push(t),i.delegateYield(e.apply(this,a),"t0",11);case 11:n=i.t0,s++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},f,this)}function mt(t){var e=x();if(Array.isArray(t)){var r={};t.forEach(function(t){mt(t).forEach(function(t){r[t]=!0})}),e=mt(r)}else null===t||"object"!==n(t)||w(t)||Object.keys(t).forEach(function(t){return e.push(t)});return e}function bt(t,e){var r;if(Array.isArray(t)){r=x();for(var i=0;i<t.length;i++){var o=bt(t[i],e);void 0!==o&&(Array.isArray(o)?o.forEach(function(t){return r.push(t)}):r.push(o))}}else null!==t&&"object"===n(t)&&(r=t[e]);return r}function xt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=x(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function vt(t){return void 0!==t}function _t(t){var e=x();if(Array.isArray(t))t.forEach(function(t){e=xt(e,_t(t))});else if(null===t||"object"!==n(t)||w(t))e=t;else for(var r in t){var i={};i[r]=t[r],e.push(i)}return e}function wt(t){if(void 0!==t){var e={};return t.forEach(function(t){for(var r in t)e[r]=t[r]}),e}}function kt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,r=new Array(e),n=0;n<e;n++)r[e-n-1]=t[n];return r}}function Mt(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r=x(),a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return n=a.t1.value,o=lt(e,t[n],n,t),a.delegateYield(e.apply(this,o),"t2",6);case 6:void 0!==(s=a.t2)&&r.push(s),a.next=2;break;case 10:return a.abrupt("return",r);case 11:case"end":return a.stop()}},d,this)}function St(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function Et(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function zt(t){if(void 0!==t)return null===t?"null":y(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":_(t)?"function":"object"}function At(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==t){a.next=2;break}return a.abrupt("return",void 0);case 2:if(!(t.length<=1)){a.next=4;break}return a.abrupt("return",t);case 4:if(void 0!==e){a.next=10;break}if(b(t)||m(t)){a.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:r=i().mark(function t(e,r){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>r);case 1:case"end":return t.stop()}},t)}),a.next=11;break;case 10:r=e;case 11:return n=i().mark(function t(e,n){var o,s;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=i().mark(function t(e,n,o){return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(0!==n.length){i.next=4;break}Array.prototype.push.apply(e,o),i.next=16;break;case 4:if(0!==o.length){i.next=8;break}Array.prototype.push.apply(e,n),i.next=16;break;case 8:return i.delegateYield(r(n[0],o[0]),"t0",9);case 9:if(!i.t0){i.next=14;break}return e.push(o[0]),i.delegateYield(t(e,n,o.slice(1)),"t1",12);case 12:i.next=16;break;case 14:return e.push(n[0]),i.delegateYield(t(e,n.slice(1),o),"t2",16);case 16:case"end":return i.stop()}},t)}),s=[],t.delegateYield(o(s,e,n),"t0",3);case 3:return t.abrupt("return",s);case 4:case"end":return t.stop()}},t)}),o=i().mark(function t(e){var r,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){i.next=4;break}return i.abrupt("return",e);case 4:return r=Math.floor(e.length/2),o=e.slice(0,r),s=e.slice(r),i.delegateYield(t(o),"t0",8);case 8:return o=i.t0,i.delegateYield(t(s),"t1",10);case 10:return s=i.t1,i.delegateYield(n(o,s),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}},t)}),a.delegateYield(o(t),"t0",14);case 14:return s=a.t0,a.abrupt("return",s);case 16:case"end":return a.stop()}},p)}function Tt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),r=0;r<t.length;r++){var n=Math.floor(Math.random()*(r+1));r!==n&&(e[r]=e[n]),e[n]=t[r]}return e}}function Ot(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=v(t)?x():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,o=0;o<e.length;o++)if(S(n,e[o])){i=!0;break}i||e.push(n)}return e}}function It(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r={},a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=11;break}return n=a.t1.value,o=t[n],s=lt(e,o,n,t),a.delegateYield(e.apply(this,s),"t2",7);case 7:ut(a.t2)&&(r[n]=o),a.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),a.abrupt("return",r);case 13:case"end":return a.stop()}},g,this)}return{sum:z,count:A,max:T,min:O,average:I,string:j,substring:P,substringBefore:R,substringAfter:C,lowercase:N,uppercase:F,length:D,trim:L,pad:Y,match:W,contains:U,replace:q,split:Q,join:J,formatNumber:K,formatBase:tt,number:et,floor:nt,ceil:it,round:ot,abs:rt,sqrt:st,power:at,random:ct,boolean:ut,not:ht,map:ft,zip:gt,filter:dt,single:pt,foldLeft:yt,sift:It,keys:mt,lookup:bt,append:xt,exists:vt,spread:_t,merge:wt,reverse:kt,each:Mt,error:St,assert:Et,type:zt,sort:At,shuffle:Tt,distinct:Ot,base64encode:B,base64decode:G,encodeUrlComponent:H,encodeUrl:X,decodeUrlComponent:V,decodeUrl:Z}}();e.exports=s}).call(this)}).call(this,void 0!==Zi?Zi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,r){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,o=Object.create(i.prototype),a=new j(n||[]);return s(o,"_invoke",{value:A(t,r,a)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",y="executing",m="completed",b={};function x(){}function v(){}function _(){}var w={};l(w,c,function(){return this});var k=Object.getPrototypeOf,M=k&&k(k(P([])));M&&M!==r&&o.call(M,c)&&(w=M);var S=_.prototype=x.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function z(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==n(l)&&o.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(l).then(function(t){h.value=t,a(h)},function(t){return r("throw",t,a,c)})}c(u.arg)}var i;s(this,"_invoke",{value:function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()}})}function A(e,r,n){var i=p;return function(o,s){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=T(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?m:g,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function T(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return v.prototype=_,s(S,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:v,configurable:!0}),v.displayName=l(_,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,h,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(z.prototype),l(z.prototype,u,function(){return this}),e.AsyncIterator=z,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new z(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},E(S),l(S,h,"Generator"),l(S,c,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=P,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(s)},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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var o=t("./datetime"),s=t("./functions"),a=t("./utils"),c=t("./parser"),u=t("./signature"),h=function(){var t=i().mark(Y),e=i().mark($),r=i().mark(W),h=i().mark(q),l=i().mark(B),f=i().mark(G),d=i().mark(H),p=i().mark(X),g=i().mark(ot),y=i().mark(ct),m=i().mark(lt),b=i().mark(ft),x=i().mark(dt),v=i().mark(yt),_=i().mark(xt),w=i().mark(vt),k=i().mark(_t),M=i().mark(wt),S=i().mark(Mt),E=i().mark(Et),z=i().mark(Tt),A=i().mark(jt),T=a.isNumeric,O=a.isArrayOfStrings,I=a.isArrayOfNumbers,j=a.createSequence,P=a.isSequence,R=a.isFunction,C=a.isLambda,N=a.isIterable,F=a.getFunctionArity,D=a.isDeepEqual,L=Rt(null);function Y(e,r,n){var o,s,a,c;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield($(e,r,n),"t1",6);case 6:return o=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(H(e,r,n),"t2",9);case 9:return o=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return o=t.t3,t.abrupt("break",50);case 14:return o=V(e,r),t.abrupt("break",50);case 16:return o=Z(e),t.abrupt("break",50);case 18:return o=Q(e,r),t.abrupt("break",50);case 20:return o=K(e,r),t.abrupt("break",50);case 22:return o=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ft(e,r,n),"t4",25);case 25:return o=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(dt(e,r,n),"t5",28);case 28:return o=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(lt(e,r,n),"t6",31);case 31:return o=t.t6,t.abrupt("break",50);case 33:return o=pt(e),t.abrupt("break",50);case 35:return t.delegateYield(vt(e,r,n),"t7",36);case 36:return o=t.t7,t.abrupt("break",50);case 38:return o=gt(e,r,n),t.abrupt("break",50);case 40:return o=kt(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(Mt(e,r,n),"t8",43);case 43:return o=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(xt(e,r,n),"t9",46);case 46:return o=t.t9,t.abrupt("break",50);case 48:return o=mt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=o&&"function"==typeof o.then||(o=Promise.resolve(o)),!n.async||"function"!=typeof o.then||!e.nextFunction||"function"!=typeof o[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,o;case 56:o=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}a=0;case 59:if(!(a<e.predicate.length)){t.next=65;break}return t.delegateYield(G(e.predicate[a].expr,o,n),"t10",61);case 61:o=t.t10;case 62:a++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,o,n),"t11",67);case 67:o=t.t11;case 68:return(c=n.lookup("__evaluate_exit"))&&c(e,r,n,o),o&&P(o)&&!o.tupleStream&&(e.keepArray&&(o.keepSingleton=!0),0===o.length?o=void 0:1===o.length&&(o=o.keepSingleton?o:o[0])),t.abrupt("return",o);case 72:case"end":return t.stop()}},t)}function $(t,r,n){var o,s,a,c,u,h;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=Array.isArray(r)&&"variable"!==t.steps[0].type?r:j(r),a=!1,c=void 0,u=0;case 4:if(!(u<t.steps.length)){e.next=25;break}if((h=t.steps[u]).tuple&&(a=!0),0!==u||!h.consarray){e.next=12;break}return e.delegateYield(Y(h,o,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield(B(h,o,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(W(h,o,n,u===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(a||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===h.focus&&(o=s);case 22:u++,e.next=4;break;case 25:if(a)if(t.tuple)s=c;else for(s=j(),u=0;u<c.length;u++)s.push(c[u]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=j(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,a?c:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}},e)}function U(t,e){var r=Rt(t);for(var n in e)r.bind(n,e[n]);return r}function W(t,e,n,o){var s,a,c,u,h;return i().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(yt(t,e,n),"t0",2);case 2:if(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(q(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=j(),a=0;case 9:if(!(a<e.length)){r.next=24;break}return r.delegateYield(Y(t,e[a],n),"t2",11);case 11:if(c=r.t2,!t.stages){r.next=20;break}u=0;case 14:if(!(u<t.stages.length)){r.next=20;break}return r.delegateYield(G(t.stages[u].expr,c,n),"t3",16);case 16:c=r.t3;case 17:u++,r.next=14;break;case 20:void 0!==c&&s.push(c);case 21:a++,r.next=9;break;case 24:return h=j(),o&&1===s.length&&Array.isArray(s[0])&&!P(s[0])?h=s[0]:s.forEach(function(t){!Array.isArray(t)||t.cons?h.push(t):t.forEach(function(t){return h.push(t)})}),r.abrupt("return",h);case 27:case"end":return r.stop()}},r)}function q(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:n=e,o=0;case 2:if(!(o<t.length)){i.next=15;break}s=t[o],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(G(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(a=0;a<n.length;a++)n[a][s.value]=a;return i.abrupt("break",12);case 12:o++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},h)}function B(t,e,r,n){var o,s,a,c,u,h,f,d;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(yt(t,r,n),"t0",3);case 3:o=i.t0,i.next=11;break;case 6:return i.delegateYield(yt(t,e,n),"t1",7);case 7:for(s=i.t1,(o=j()).tupleStream=!0,a=0;a<s.length;a++)(c={"@":s[a]})[t.index]=a,o.push(c);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(q(t.stages,o,n),"t2",13);case 13:o=i.t2;case 14:return i.abrupt("return",o);case 15:(o=j()).tupleStream=!0,u=n,void 0===r&&(r=e.map(function(t){return{"@":t}})),h=0;case 20:if(!(h<r.length)){i.next=28;break}return u=U(n,r[h]),i.delegateYield(Y(t,r[h]["@"],u),"t3",23);case 23:if(void 0!==(f=i.t3))for(Array.isArray(f)||(f=[f]),d=0;d<f.length;d++)c={},Object.assign(c,r[h]),f.tupleStream?Object.assign(c,f[d]):(t.focus?(c[t.focus]=f[d],c["@"]=r[h]["@"]):c["@"]=f[d],t.index&&(c[t.index]=d),t.ancestor&&(c[t.ancestor.label]=r[h]["@"])),o.push(c);case 25:h++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(q(t.stages,o,n),"t4",30);case 30:o=i.t4;case 31:return i.abrupt("return",o);case 32:case"end":return i.stop()}},l)}function G(t,e,r){var n,o,a,c,u,h;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=j(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=j(e)),"number"!==t.type){i.next=10;break}(o=Math.floor(t.value))<0&&(o=e.length+o),void 0!==(a=e[o])&&(Array.isArray(a)?n=a:n.push(a)),i.next=23;break;case 10:o=0;case 11:if(!(o<e.length)){i.next=23;break}return a=e[o],c=a,u=r,e.tupleStream&&(c=a["@"],u=U(r,a)),i.delegateYield(Y(t,c,u),"t0",17);case 17:h=i.t0,T(h)&&(h=[h]),I(h)?h.forEach(function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===o&&n.push(a)}):s.boolean(h)&&n.push(a);case 20:o++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}},f)}function H(t,e,r){var n,o,s,a,c;return i().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(Y(t.lhs,e,r),"t0",1);case 1:if(o=u.t0,s=t.value,a=i().mark(function n(){return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(Y(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}},n)}),"and"!==s&&"or"!==s){u.next=15;break}return u.prev=5,u.delegateYield(ot(o,a,s),"t1",7);case 7:return u.abrupt("return",u.t1);case 10:throw u.prev=10,u.t2=u.catch(5),u.t2.position=t.position,u.t2.token=s,u.t2;case 15:return u.delegateYield(a(),"t3",16);case 16:c=u.t3,u.prev=17,u.t4=s,u.next="+"===u.t4||"-"===u.t4||"*"===u.t4||"/"===u.t4||"%"===u.t4?21:"="===u.t4||"!="===u.t4?23:"<"===u.t4||"<="===u.t4||">"===u.t4||">="===u.t4?25:"&"===u.t4?27:".."===u.t4?29:"in"===u.t4?31:33;break;case 21:return n=et(o,c,s),u.abrupt("break",33);case 23:return n=rt(o,c,s),u.abrupt("break",33);case 25:return n=nt(o,c,s),u.abrupt("break",33);case 27:return n=at(o,c),u.abrupt("break",33);case 29:return n=ht(o,c),u.abrupt("break",33);case 31:return n=it(o,c),u.abrupt("break",33);case 33:u.next=40;break;case 35:throw u.prev=35,u.t5=u.catch(17),u.t5.position=t.position,u.t5.token=s,u.t5;case 40:return u.abrupt("return",n);case 41:case"end":return u.stop()}},d,null,[[5,10],[17,35]])}function X(t,e,r){var n,o,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(Y(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!T(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],o=0;case 17:if(!(o<t.expressions.length)){i.next=25;break}return a=t.expressions[o],i.delegateYield(Y(a,e,r),"t2",20);case 20:void 0!==(c=i.t2)&&("["===a.value?n.push(c):n=s.append(n,c));case 22:o++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(ct(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}},p)}function V(t,e,r){return s.lookup(e,t.value)}function Z(t){return t.value}function Q(t,e){var r=j();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach(function(t){var n=e[t];Array.isArray(n)?(n=J(n),r=s.append(r,n)):r.push(n)}),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach(function(t){J(t,e)}):e.push(t),e}function K(t,e){var r,n=j();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach(function(t){tt(t,e)}):null!==t&&"object"===n(t)&&Object.keys(t).forEach(function(r){tt(t[r],e)})}function et(t,e,r){var n;if(void 0!==t&&!T(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!T(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,o=n(t),s=n(e);if("undefined"===o||"undefined"===s)return!1;switch(r){case"=":i=D(t,e);break;case"!=":i=!D(t,e)}return i}function nt(t,e,r){var i,o=n(t),s=n(e);if("undefined"!==o&&"string"!==o&&"number"!==o||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==o&&"number"!==o?t:e};if("undefined"!==o&&"undefined"!==s){if(o!==s)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function ot(t,e,r){var n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=st(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=o,!i.t1){i.next=10;break}return i.t2=st,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=o,i.t5){i.next=18;break}return i.t6=st,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},g)}function st(t){var e=s.boolean(t);return void 0!==e&&e}function at(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function ct(t,e,r){var n,o,a,c,u,h,l,f,d,p,g,m,b;return i().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:n={},o={},a=!(!e||!e.tupleStream),Array.isArray(e)||(e=j(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){y.next=31;break}u=e[c],h=a?U(r,u):r,l=0;case 10:if(!(l<t.lhs.length)){y.next=28;break}return f=t.lhs[l],y.delegateYield(Y(f[0],a?u["@"]:u,h),"t0",13);case 13:if("string"==typeof(d=y.t0)||void 0===d){y.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:d};case 16:if(void 0===d){y.next=25;break}if(p={data:u,exprIndex:l},!o.hasOwnProperty(d)){y.next=24;break}if(o[d].exprIndex===l){y.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:d};case 21:o[d].data=s.append(o[d].data,u),y.next=25;break;case 24:o[d]=p;case 25:l++,y.next=10;break;case 28:c++,y.next=6;break;case 31:y.t1=i().keys(o);case 32:if((y.t2=y.t1()).done){y.next=43;break}return d=y.t2.value,p=o[d],g=p.data,h=r,a&&(m=ut(p.data),g=m["@"],delete m["@"],h=U(r,m)),y.delegateYield(Y(t.lhs[p.exprIndex][1],g,h),"t3",39);case 39:void 0!==(b=y.t3)&&(n[d]=b),y.next=32;break;case 43:return y.abrupt("return",n);case 44:case"end":return y.stop()}},y)}function ut(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=s.append(e[n],t[r][n]);return e}function ht(t,e){var r;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 r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,o=0;i<=e;i++,o++)r[o]=i;return r.sequence=!0,r}function lt(t,e,r){var n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}},m)}function ft(t,e,r){var n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.condition,e,r),"t0",1);case 1:if(o=i.t0,!s.boolean(o)){i.next=7;break}return i.delegateYield(Y(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(Y(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}},b)}function dt(t,e,r){var n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=Rt(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(Y(t.expressions[s],e,o),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}},x)}function pt(t){var e=new Ft.RegexEngine(t.value),r=function r(n,i){var o;e.lastIndex=i||0;var s=e.exec(n);if(null!==s){if(o={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var a=1;a<s.length;a++)o.groups.push(s[a]);o.next=function(){if(!(e.lastIndex>=n.length)){var i=r(n,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return o};return r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function yt(t,e,r){var o,a,c,u,h;return i().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return a=e,c=!!e.tupleStream,u=i().mark(function e(o,s){var a,u,h,l,f,d,p,g,y;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,u=0;case 2:if(!(0===a&&u<t.terms.length)){e.next=35;break}return h=t.terms[u],l=o,f=r,c&&(l=o["@"],f=U(r,o)),e.delegateYield(Y(h.expression,l,f),"t0",8);case 8:return d=e.t0,l=s,f=r,c&&(l=s["@"],f=U(r,s)),e.delegateYield(Y(h.expression,l,f),"t1",13);case 13:if(p=e.t1,g=n(d),y=n(p),"undefined"!==g){e.next=19;break}return a="undefined"===y?0:1,e.abrupt("continue",32);case 19:if("undefined"!==y){e.next=22;break}return a=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==y&&"number"!==y)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?d:p};case 24:if(g===y){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:d,value2:p};case 26:if(d!==p){e.next=30;break}return e.abrupt("continue",32);case 30:a=d<p?-1:1;case 31:!0===h.descending&&(a=-a);case 32:u++,e.next=2;break;case 35:return e.abrupt("return",1===a);case 36:case"end":return e.stop()}},e)}),h={environment:r,input:e},l.delegateYield(s.sort.apply(h,[a,u]),"t0",5);case 5:return o=l.t0,l.abrupt("return",o);case 7:case"end":return l.stop()}},v)}function mt(t,e,r){return It(i().mark(function e(o){var s,a,c,u,h,l,f,d,p,g,y;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==o){e.next=2;break}return e.abrupt("return",void 0);case 2:if(s=r.lookup("clone"),R(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(_t(s,[o],null,r),"t0",6);case 6:return a=e.t0,e.delegateYield(Y(t.pattern,a,r),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),u=0;case 12:if(!(u<c.length)){e.next=35;break}if(!(h=c[u])||!(h.isPrototypeOf(a)||h instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(Y(t.update,h,r),"t2",17);case 17:if(l=e.t2,"undefined"===(f=n(l))){e.next=23;break}if("object"===f&&null!==l&&!Array.isArray(l)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:l};case 22:for(d in l)h[d]=l[d];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(Y(t.delete,h,r),"t3",25);case 25:if(void 0===(p=e.t3)){e.next=32;break}if(g=p,Array.isArray(p)||(p=[p]),O(p)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(y=0;y<p.length;y++)"object"===n(h)&&null!==h&&delete h[p[y]];case 32:u++,e.next=12;break;case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}},e)}),"<(oa):o>")}var bt=c("function($f, $g) { function($x){ $g($f($x)) } }");function xt(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.lhs,e,r),"t0",1);case 1:if(o=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(vt(t.rhs,e,r,{context:o}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(Y(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,R(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!R(o)){i.next=18;break}return i.delegateYield(Y(bt,null,r),"t3",13);case 13:return a=i.t3,i.delegateYield(_t(a,[o,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(_t(s,[o],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},_)}function vt(t,e,r,o){var s,a,c,u,h,l;return i().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.delegateYield(Y(t.procedure,e,r),"t0",1);case 1:if(void 0!==(a=f.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){f.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==o&&c.push(o.context),u=i().mark(function n(){var o,s;return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(Y(t.arguments[h],e,r),"t0",1);case 1:o=n.t0,R(o)?(s=i().mark(function t(){var e,n,s,a=arguments;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=a.length,n=new Array(e),s=0;s<e;s++)n[s]=a[s];return t.delegateYield(_t(o,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}},t)}),s.arity=F(o),c.push(s)):c.push(o);case 3:case"end":return n.stop()}},n)}),h=0;case 8:if(!(h<t.arguments.length)){f.next=13;break}return f.delegateYield(u(),"t1",10);case 10:h++,f.next=8;break;case 13:return l="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.prev=14,"object"===n(a)&&(a.token=l,a.position=t.position),f.delegateYield(_t(a,c,e,r),"t2",17);case 17:s=f.t2,f.next=25;break;case 20:throw f.prev=20,f.t3=f.catch(14),f.t3.position||(f.t3.position=t.position),f.t3.token||(f.t3.token=l),f.t3;case 25:return f.abrupt("return",s);case 26:case"end":return f.stop()}},w,null,[[14,20]])}function _t(t,e,r,n){var o,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(wt(t,e,r,n),"t0",1);case 1:o=i.t0;case 2:if(!C(o)||!0!==o.thunk){i.next=21;break}return i.delegateYield(Y(o.body.procedure,o.input,o.environment),"t1",4);case 4:s=i.t1,"variable"===o.body.procedure.type&&(s.token=o.body.procedure.value),s.position=o.body.procedure.position,a=[],c=0;case 9:if(!(c<o.body.arguments.length)){i.next=17;break}return i.t2=a,i.delegateYield(Y(o.body.arguments[c],o.input,o.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:c++,i.next=9;break;case 17:return i.delegateYield(wt(s,a,r,n),"t5",18);case 18:o=i.t5,i.next=2;break;case 21:return i.abrupt("return",o);case 22:case"end":return i.stop()}},k)}function wt(t,e,r,n){var o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=St(t.signature,e,r)),!C(t)){i.next=8;break}return i.delegateYield(Et(t,s),"t0",5);case 5:o=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(a={environment:n,input:r},o=t.implementation.apply(a,s),!N(o)){i.next=14;break}return i.delegateYield(o,"t1",13);case 13:o=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(o=t.apply(r,s),!N(o)){i.next=21;break}return i.delegateYield(o,"t2",20);case 20:o=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",o);case 31:case"end":return i.stop()}},M,null,[[0,26]])}function kt(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark(function t(r,o){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_t(n,o,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t)}),n}function Mt(t,e,r){var n,o,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(a=t.arguments[s]).type||"?"!==a.value){i.next=8;break}o.push(a),i.next=12;break;case 8:return i.t0=o,i.delegateYield(Y(a,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(Y(t.procedure,e,r),"t3",16);case 16:if(void 0!==(c=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!C(c)){i.next=23;break}n=zt(c,o),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=At(c.implementation,o),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=At(c,o),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}},S)}function St(t,e,r){return void 0===t?e:t.validate(e,r)}function Et(t,e){var r,n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Rt(t.environment),t.arguments.forEach(function(t,r){n.bind(t.value,e[r])}),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Tt(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(Y(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}},E)}function zt(t,e){var r=Rt(t.environment),n=[];return t.arguments.forEach(function(t,i){var o=e[i];o&&"operator"===o.type&&"?"===o.value?n.push(t):r.bind(t.value,o)}),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function At(t,e){var r=Ot(t),n="function("+(r=r.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=c(n);return i.body=t,zt(i,e)}function Tt(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Ot(t),n=r.map(function(t){return e.lookup(t.trim())}),o={environment:e},s=t.apply(o,n),!N(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}},z)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function It(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=u(e)),r}function jt(t,e){var r,n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!P(r)&&((r=j(r)).outerWrapper=!0)),i.prev=4,n=c(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Nt(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(Y(n,r,this.environment),"t1",14);case 14:o=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Nt(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",o);case 22:case"end":return i.stop()}},A,this,[[4,8],[12,17]])}function Pt(t){if(void 0!==t)return JSON.parse(s.string(t))}function Rt(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}L.bind("sum",It(s.sum,"<a<n>:n>")),L.bind("count",It(s.count,"<a:n>")),L.bind("max",It(s.max,"<a<n>:n>")),L.bind("min",It(s.min,"<a<n>:n>")),L.bind("average",It(s.average,"<a<n>:n>")),L.bind("string",It(s.string,"<x-b?:s>")),L.bind("substring",It(s.substring,"<s-nn?:s>")),L.bind("substringBefore",It(s.substringBefore,"<s-s:s>")),L.bind("substringAfter",It(s.substringAfter,"<s-s:s>")),L.bind("lowercase",It(s.lowercase,"<s-:s>")),L.bind("uppercase",It(s.uppercase,"<s-:s>")),L.bind("length",It(s.length,"<s-:n>")),L.bind("trim",It(s.trim,"<s-:s>")),L.bind("pad",It(s.pad,"<s-ns?:s>")),L.bind("match",It(s.match,"<s-f<s:o>n?:a<o>>")),L.bind("contains",It(s.contains,"<s-(sf):b>")),L.bind("replace",It(s.replace,"<s-(sf)(sf)n?:s>")),L.bind("split",It(s.split,"<s-(sf)n?:a<s>>")),L.bind("join",It(s.join,"<a<s>s?:s>")),L.bind("formatNumber",It(s.formatNumber,"<n-so?:s>")),L.bind("formatBase",It(s.formatBase,"<n-n?:s>")),L.bind("formatInteger",It(o.formatInteger,"<n-s:s>")),L.bind("parseInteger",It(o.parseInteger,"<s-s:n>")),L.bind("number",It(s.number,"<(nsb)-:n>")),L.bind("floor",It(s.floor,"<n-:n>")),L.bind("ceil",It(s.ceil,"<n-:n>")),L.bind("round",It(s.round,"<n-n?:n>")),L.bind("abs",It(s.abs,"<n-:n>")),L.bind("sqrt",It(s.sqrt,"<n-:n>")),L.bind("power",It(s.power,"<n-n:n>")),L.bind("random",It(s.random,"<:n>")),L.bind("boolean",It(s.boolean,"<x-:b>")),L.bind("not",It(s.not,"<x-:b>")),L.bind("map",It(s.map,"<af>")),L.bind("zip",It(s.zip,"<a+>")),L.bind("filter",It(s.filter,"<af>")),L.bind("single",It(s.single,"<af?>")),L.bind("reduce",It(s.foldLeft,"<afj?:j>")),L.bind("sift",It(s.sift,"<o-f?:o>")),L.bind("keys",It(s.keys,"<x-:a<s>>")),L.bind("lookup",It(s.lookup,"<x-s:x>")),L.bind("append",It(s.append,"<xx:a>")),L.bind("exists",It(s.exists,"<x:b>")),L.bind("spread",It(s.spread,"<x-:a<o>>")),L.bind("merge",It(s.merge,"<a<o>:o>")),L.bind("reverse",It(s.reverse,"<a:a>")),L.bind("each",It(s.each,"<o-f:a>")),L.bind("error",It(s.error,"<s?:x>")),L.bind("assert",It(s.assert,"<bs?:x>")),L.bind("type",It(s.type,"<x:s>")),L.bind("sort",It(s.sort,"<af?:a>")),L.bind("shuffle",It(s.shuffle,"<a:a>")),L.bind("distinct",It(s.distinct,"<x:x>")),L.bind("base64encode",It(s.base64encode,"<s-:s>")),L.bind("base64decode",It(s.base64decode,"<s-:s>")),L.bind("encodeUrlComponent",It(s.encodeUrlComponent,"<s-:s>")),L.bind("encodeUrl",It(s.encodeUrl,"<s-:s>")),L.bind("decodeUrlComponent",It(s.decodeUrlComponent,"<s-:s>")),L.bind("decodeUrl",It(s.decodeUrl,"<s-:s>")),L.bind("eval",It(jt,"<sx?:x>")),L.bind("toMillis",It(o.toMillis,"<s-s?:n>")),L.bind("fromMillis",It(o.fromMillis,"<n-s?s?:s>")),L.bind("clone",It(Pt,"<(oa)-:o>"));var Ct={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}}",D1010:"Attempted to access the Javascript object prototype",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 Nt(t){var e=Ct[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});r=r.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=r}}function Ft(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Nt(t),t}var i=Rt(L),s=new Date;return i.bind("now",It(function(t,e){return o.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",It(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?Ft.RegexEngine=e.RegexEngine:Ft.RegexEngine=RegExp,{evaluate:function(t,e,o){if(void 0!==n){var a={code:"S0500",position:0};throw Nt(a),a}var c,u,h;if(void 0!==e)for(var l in c=Rt(i),e)c.bind(l,e[l]);else c=i;if(c.bind("$",t),s=new Date,c.timestamp=s,Array.isArray(t)&&!P(t)&&((t=j(t)).outerWrapper=!0),"function"==typeof o){c.async=!0;var f=function(t){Nt(t),o(t,null)},d=function t(e){(u=h.next(e)).done?o(null,u.value):u.value.then(t).catch(f)};h=Y(r,t,c),(u=h.next()).value.then(d).catch(f)}else try{for(h=Y(r,t,c),u=h.next();!u.done;)u=h.next(u.value);return u.value}catch(a){throw Nt(a),a}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=It(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Ft.parser=c,Ft}();e.exports=h},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=t("./signature"),i=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"},r=function(r){var n=0,i=r.length,o=function(t,e){return{type:t,value:e,position:n}},s=function(){for(var t,e,o=n,s=0;n<i;){var a=r.charAt(n);if("/"===a&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(o,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,a=r.charAt(n),o=n;"i"===a||"m"===a;)n++,a=r.charAt(n);return e=r.substring(o,n)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===r.charAt(n-1)||s++,")"!==a&&"]"!==a&&"}"!==a||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}};return function a(c){if(n>=i)return null;for(var u=r.charAt(n);n<i&&" \t\n\r\v".indexOf(u)>-1;)n++,u=r.charAt(n);if("/"===u&&"*"===r.charAt(n+1)){var h=n;for(n+=2,u=r.charAt(n);"*"!==u||"/"!==r.charAt(n+1);)if(u=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:h};return n+=2,u=r.charAt(n),a(c)}if(!0!==c&&"/"===u)return n++,o("regex",s());if("."===u&&"."===r.charAt(n+1))return n+=2,o("operator","..");if(":"===u&&"="===r.charAt(n+1))return n+=2,o("operator",":=");if("!"===u&&"="===r.charAt(n+1))return n+=2,o("operator","!=");if(">"===u&&"="===r.charAt(n+1))return n+=2,o("operator",">=");if("<"===u&&"="===r.charAt(n+1))return n+=2,o("operator","<=");if("*"===u&&"*"===r.charAt(n+1))return n+=2,o("operator","**");if("~"===u&&">"===r.charAt(n+1))return n+=2,o("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return n++,o("operator",u);if('"'===u||"'"===u){var l=u;n++;for(var f="";n<i;){if("\\"===(u=r.charAt(n)))if(n++,u=r.charAt(n),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:n,token:u};var d=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:n};var p=parseInt(d,16);f+=String.fromCharCode(p),n+=4}else{if(u===l)return n++,o("string",f);f+=u}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,y=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==y){var m=parseFloat(y[0]);if(!isNaN(m)&&isFinite(m))return n+=y[0].length,o("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:y[0]}}if("`"===u){n++;var b=r.indexOf("`",n);if(-1!==b)return g=r.substring(n,b),n=b+1,o("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var x,v=n;;)if(x=r.charAt(v),v===i||" \t\n\r\v".indexOf(x)>-1||Object.prototype.hasOwnProperty.call(t,x)){if("$"===r.charAt(n))return g=r.substring(n+1,v),n=v,o("variable",g);switch(g=r.substring(n,v),n=v,g){case"or":case"in":case"and":return o("operator",g);case"true":return o("value",!0);case"false":return o("value",!1);case"null":return o("value",null);default:return n===i&&""===g?null:o("name",g)}}else v++}},i=function(e,i){var o,s,a={},c=[],u=function(){var t=[];"(end)"!==o.id&&t.push({type:o.type,value:o.value,position:o.position});for(var e=s();null!==e;)t.push(e),e=s();return t},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},l=function(t,e){var r=a[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(h)).id=r.value=t,r.lbp=e,a[t]=r),r},f=function(t){if(i){t.remaining=u(),c.push(t);var e=a["(error)"];return(o=Object.create(e)).error=t,o.type="(error)",o}throw t.stack=(new Error).stack,t},d=function(t,r){if(t&&o.id!==t){var n={code:"(end)"===o.id?"S0203":"S0202",position:o.position,token:o.value,value:t};return f(n)}var i=s(r);if(null===i)return(o=a["(end)"]).position=e.length,o;var c,u=i.value,h=i.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(o=Object.create(c)).value=u,o.type=h,o.position=i.position,o},p=function(t){var e,r=o;for(d(null,!0),e=r.nud();t<o.lbp;)r=o,d(),e=r.led(e);return e},g=function(t){l(t,0).nud=function(){return this}},y=function(e,r,n){var i=r||t[e],o=l(e,i);return o.led=n||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},o},m=function(t,e,r){var n=l(t,e);return n.led=r,n},b=function(t,e){var r=l(t);return r.nud=e||function(){return this.expression=p(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),l(":"),l(";"),l(","),l(")"),l("]"),l("}"),l(".."),y("."),y("+"),y("-"),y("*"),y("/"),y("%"),y("="),y("<"),y(">"),y("!="),y("<="),y(">="),y("&"),y("and"),y("or"),y("in"),g("and"),g("or"),g("in"),b("-"),y("~>"),m("(error)",10,function(t){return this.lhs=t,this.error=o.error,this.remaining=u(),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=[],")"!==o.id)for(;"operator"===o.type&&"?"===o.id?(this.type="partial",this.arguments.push(o),d("?")):this.arguments.push(p(0)),","===o.id;)d(",");if(d(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach(function(t,e){if("variable"!==t.type)return f({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===o.id){for(var e=o.position,r=1,i="<";r>0&&"{"!==o.id&&"(end)"!==o.id;){var s=d();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}d(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,f(t)}}d("{"),this.body=p(0),d("}")}return this}),b("(",function(){for(var t=[];")"!==o.id&&(t.push(p(0)),";"===o.id);)d(";");return d(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==o.id)for(;;){var e=p(0);if(".."===o.id){var r={type:"binary",value:"..",position:o.position,lhs:e};d(".."),r.rhs=p(0),e=r}if(t.push(e),","!==o.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this}),y("[",t["["],function(e){if("]"===o.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this}),y("^",t["^"],function(t){d("(");for(var e=[];;){var r={descending:!1};if("<"===o.id?d("<"):">"===o.id&&(r.descending=!0,d(">")),r.expression=p(0),e.push(r),","!==o.id)break;d(",")}return d(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var x=function(t){var e=[];if("}"!==o.id)for(;;){var r=p(0);d(":");var n=p(0);if(e.push([r,n]),","!==o.id)break;d(",")}return d("}",!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),m(":=",t[":="],function(e){return"variable"!==e.type?f({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=p(t[":="]-1),this.type="binary",this)}),y("@",t["@"],function(e){return this.lhs=e,this.rhs=p(t["@"]),"variable"!==this.rhs.type?f({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=p(t["#"]),"variable"!==this.rhs.type?f({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=p(0),":"===o.id&&(d(":"),this.else=p(0)),this}),b("|",function(){return this.type="transform",this.pattern=p(0),d("|"),this.update=p(0),","===o.id&&(d(","),this.delete=p(0)),d("|"),this});var v=function t(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},_=0,w=0,k=[],M=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(k[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},S=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},E=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var o=n[i];for(e=t.steps.length-2;o.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[o]:t.seekingParent.push(o);break}for(var s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];o=M(s,o)}}},z=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var o=t(e.rhs);"function"===o.type&&"path"===o.procedure.type&&1===o.procedure.steps.length&&"name"===o.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=o.procedure.steps[0].value),"path"===o.type?Array.prototype.push.apply(r.steps,o.steps):(void 0!==o.predicate&&(o.stages=o.predicate,delete o.predicate),r.steps.push(o)),r.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"}),r.steps.filter(function(t){return!0===t.keepArray}).length>0&&(r.keepSingletonArray=!0);var s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var a=r.steps[r.steps.length-1];"unary"===a.type&&"["===a.value&&(a.consarray=!0),E(r);break;case"[":var u=r=t(e.lhs),h="predicate";if("path"===r.type&&(u=r.steps[r.steps.length-1],h="stages"),void 0!==u.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===u[h]&&(u[h]=[]);var l=t(e.rhs);void 0!==l.seekingParent&&(l.seekingParent.forEach(function(t){1===t.level?M(u,t):t.level--}),S(u,l)),u[h].push({type:"filter",expr:l,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map(function(e){return[t(e[0]),t(e[1])]}),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var f={type:"sort",position:e.position};f.terms=e.rhs.map(function(e){var r=t(e.expression);return S(f,r),{descending:e.descending,expression:r}}),r.steps.push(f),E(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.rhs);break;case"@":if(r=t(e.lhs),u=r,"path"===r.type&&(u=r.steps[r.steps.length-1]),void 0!==u.stages||void 0!==u.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===u.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(u.keepArray=!0),u.focus=e.rhs.value,u.tuple=!0;break;case"#":r=t(e.lhs),u=r,"path"===r.type?u=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==u.predicate&&(u.stages=u.predicate,delete u.predicate)),void 0===u.stages?u.index=e.rhs.value:u.stages.push({type:"index",value:e.rhs.value,position:e.position}),u.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.lhs),S(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map(function(e){var n=t(e);return S(r,n),n}):"{"===e.value?r.lhs=e.lhs.map(function(e){var n=t(e[0]);S(r,n);var i=t(e[1]);return S(r,i),[n,i]}):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:S(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){var n=t(e);return S(r,n),n}),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var d=t(e.body);r.body=v(d);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),S(r,r.condition),r.then=t(e.then),S(r,r.then),void 0!==e.else&&(r.else=t(e.else),S(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){var n=t(e);return S(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n});break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+_++,level:1,index:w++}},k.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var p="S0206";"(end)"===e.id&&(p="S0207");var g={code:p,position:e.position,token:e.value};if(i)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),d();var A=p(0);if("(end)"!==o.id){var T={code:"S0201",position:o.position,token:o.value};f(T)}if("parent"===(A=z(A)).type||void 0!==A.seekingParent)throw{code:"S0217",token:A.type,position:A.position};return c.length>0&&(A.errors=c),A};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="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},n(t)}var i=t("./utils"),o=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var r=1,o=[],s={},a=s;r<e.length;){var c=e.charAt(r);if(":"===c)break;var u=function(){o.push(s),a=s,s={}},h=function(t,e,r,n){for(var i=1,o=e;o<t.length;)if(o++,(c=t.charAt(o))===n){if(0===--i)break}else c===r&&i++;return o};switch(c){case"s":case"n":case"b":case"l":case"o":s.regex="["+c+"m]",s.type=c,u();break;case"a":s.regex="[asnblfom]",s.type=c,s.array=!0,u();break;case"f":s.regex="f",s.type=c,u();break;case"j":s.regex="[asnblom]",s.type=c,u();break;case"x":s.regex="[asnblfom]",s.type=c,u();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var l=h(e,r,"(",")"),f=e.substring(r+1,l);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:r};s.regex="["+f+"m]",s.type="("+f+")",r=l,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:r};var d=h(e,r,"<",">");a.subtype=e.substring(r+1,d),r=d}r++}var p="^"+o.map(function(t){return"("+t.regex+")"}).join("")+"$",g=new RegExp(p),y=function(t){var e;if(i.isFunction(t))e="f";else switch(n(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},m=function(t,e){for(var r="^",n=0,i=0;i<o.length;i++){r+=o[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach(function(t){n+=y(t)});var i=g.exec(n);if(i){var s=[],a=0;return o.forEach(function(n,o){var c=e[a],u=i[o+1];if(""===u)if(n.context&&n.contextRegex){var h=y(r);if(!n.contextRegex.test(h))throw{code:"T0411",stack:(new Error).stack,value:r,index:a+1};s.push(r)}else s.push(c),a++;else u.split("").forEach(function(r){if("a"===n.type){if("m"===r)c=void 0;else{c=e[a];var i=!0;if(void 0!==n.subtype)if("a"!==r&&u!==n.subtype)i=!1;else if("a"===r&&c.length>0){var o=y(c[0]);i=o===n.subtype.charAt(0)&&0===c.filter(function(t){return y(t)!==o}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[n.subtype]};"a"!==r&&(c=[c])}s.push(c),a++}else s.push(c),a++})}),s}m(e,n)}}}return e}();e.exports=o},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return s="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},s(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 r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter(function(e){return!t(e)}).length),r}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function o(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 u(t){return t&&!0===t._jsonata_lambda}var h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function l(t){return"object"===s(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(!f(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var o=n[r];if(!f(t[o],e[o]))return!1}return!0}return!1}function d(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;r.push(o)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:o,isFunction:a,isLambda:u,isIterable:l,getFunctionArity:c,isDeepEqual:f,stringToArray:d}}();e.exports=a},{}]},{},[3])(3)}(to)),to.exports),ro=Qi(eo);const no=function(t){return t};function io(t){if(!t)return no;try{const e=ro(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Vi(t),no}}function oo(t,e){if(!e)return;const r=_i(t),n=null==r?"":String(r);return Object.prototype.hasOwnProperty.call(e,n)?e[n]:e.default}const so=t=>null==t||""===t?void 0:parseFloat(String(t));function ao(t,e,r){for(const r of e)if(void 0!==r.value&&r.value===t)return r.result;const n=_i(t);if(null==n)return r;const i=Number(n);if(Number.isNaN(i))return r;for(const t of e){const e=so(t.min),r=so(t.max);if((void 0!==e||void 0!==r)&&(i>=(e??-1/0)&&i<(r??1/0)))return t.result}return r}function co(t){return Number(_i(t))}function uo(t){return t}function ho(t){return function(t){const e=_i(t);return null==e?"":String(e)}(t)}function lo(t){return co(t)}function fo(t){return oo(t,this.param)}function po(t){const{param:e}=this;if(!e)return;return ao(t,Object.keys(e).filter(t=>"default"!==t).map(t=>{const[r,n]=t.split("~");return{min:""===r?null:r,max:void 0===n||""===n?null:n,result:e[t]}}),e.default)}function go(t){const{param:e}=this;if(!e)return;const r=Number(e.scale??1),n=Number(e.offset??0);return co(t)*r+n}function yo(t){return co(t)*Math.PI/180}function mo(){}const bo=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const xo=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],vo=new Array(xo.length).fill(void 0),_o=Object.getPrototypeOf(async function(){}).constructor;function wo(t,e){!function(t){for(const e of bo)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const r=function(t){return/\bawait\b/.test(t)}(t),n=new(r?_o:Function)(...e,...xo,t);return function(t,...e){return n.call(t,...e,...vo)}}function ko(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?ho.bind(t):"number"===i?lo.bind(t):uo.bind(e);case"map":return fo.bind(t);case"range":return po.bind(t);case"scale":return go.bind(t);case"radian":return yo.bind(t);case"eval":return function(t){try{const e=wo(t,["value","targets","scene"]);return function(t,r){try{const n=e(this,t,r,globalThis.scene);return n&&"function"==typeof n.then?n.catch(t=>{Vi(t)}):n}catch(t){return void Vi(t)}}}catch(t){return Vi(t),mo}}(n).bind(e);default:return uo.bind(e)}}class Mo{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:r,rule:n,param:i,accessor:o}=t;this._model=t,this.evaluator=ko(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=io(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=io(t),this.partAccessor=io(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 So(t,e,r,n){const i=e.split(".");if(1===i.length)return void(t[e]=n?{...t[e],...r}:r);const o=i[0],s=void 0!==t[o]?t[o]:"function"==typeof t.get?t.get(o):void 0,a=s?{...s}:{};let c=a;for(let t=1;t<i.length-1;t++)c[i[t]]=c[i[t]]?{...c[i[t]]}:{},c=c[i[t]];const u=i[i.length-1];c[u]=n?{...c[u],...r}:r,t[o]=a}function Eo(t,e,r,n){t.forEach(t=>So(t,e,r,n))}function zo(t,e,r,n){t&&"function"==typeof t.then?t.then(t=>{void 0!==r&&void 0!==n&&r._dataGeneration!==n||e(t)}).catch(t=>Vi(t)):e(t)}function Ao(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,r=this;this.mappings&&this.mappings.forEach(t=>{try{let n,{source:i,target:o,property:s,accessor:a,propAccessor:c,partAccessor:u,ndnsp:h=!1,partial:l=!1}=t;o=(o||"(self)").trim(),t.rule||(t.rule="value"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),n=this.root.findById(i)?.data||{}):n=this.data;const f=a(n);if("(root)"==o||"(key)"==o){if(null==f)return;const n=Object.keys(f||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();n.length>0&&n.forEach(n=>{zo(t.evaluator(f[n.get("id")],[n]),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||So(n,s,t,l)},r,e)})}else if(o.startsWith("[")){if(null==f)return;if(f instanceof Array)f.forEach(n=>{const i=c(n);if(i){const o=this.root.findOrCreate(i);o&&zo(t.evaluator(u(n),o),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Eo(o,s,t,l)},r,e)}});else{if(!(f instanceof Object))throw String("mapping data should be an object to target property-id.("+f+")");{const n=c(f);if(n){const i=this.root.findOrCreate(n);i&&zo(t.evaluator(u(f),i),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Eo(i,s,t,l)},r,e)}}}}else{const n=this.root.findAll(o,this);n.length>0&&zo(t.evaluator(f,n),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Eo(n,s,t,l)},r,e)}}catch(e){Vi(e,this,t)}})}function To(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),Ao.call(this,!0)}function Oo(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new Mo({target:"(self)",rule:"value",...t},this))):(Vi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function Io(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function jo(t,e){this.disposeMappings(),Ao.call(this)}function Po(t,e,r,n,i,o){e.complete?t.drawImage(e,r,n,i,o):e.addEventListener("load",()=>{this.invalidate()})}function Ro(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const Co="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),No={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Fo=()=>{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(),r=t.fontFamily||"sans-serif";No.FONT_FAMILY=e||r};let Do;function Lo(t,e,r,n,i){const{alpha:o=1}=n,s=i.fillStyle;if(t.globalAlpha*=o,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(r.x,r.y);let n,{width:i,height:o}=e;if("linear"==s.gradientType){const e=3.141592653589793,r="number"==typeof s.rotation&&Number.isFinite(s.rotation)?s.rotation:0;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));s-=s-(i+o)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(o-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(o-4)/2*Math.sin(r))}else if("radial"==s.gradientType){const e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));switch(s.center){case"center":default:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-o/2,0,-i/2,-o/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-o/2,0,i/2,-o/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,o/2,0,-i/2,o/2,2*e);break;case"right-bottom":n=t.createRadialGradient(i/2,o/2,0,i/2,o/2,2*e)}}(Array.isArray(s.colorStops)?s.colorStops:Array.isArray(s.gradientStops)?s.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){((...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))})("Invalid Color for colorstop : ",t.color),n.addColorStop(t.position,"#fff")}}),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.y)}else if("pattern"==s.type&&s.image)if(s.guideOnly&&1!=i.app.mode)s.color&&(t.fillStyle=s.color,t.fill());else{i.prepareFillIf(!i._pattern_image_origin);const r=i._pattern_image;if(!r||!r.width||!r.height)return;let n=0,o=0,a=0,c=0,u=e.left,h=e.top;if(!s.fitPattern){n=s.offsetX,o=s.offsetY;const t=s.width?s.width:r.width,i=s.height?s.height:r.height;switch(s.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}u+=n+a,h+=o+c}t.translate(u,h),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((r.width-e.width)*(r.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(r,"no-repeat"):t.fillStyle=t.createPattern(r,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-h)}}function Yo(t,e){const r=this.fillStyle;if(!r||"pattern"!=r.type||!r.image)return void t(this);if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);const o=Do(e,i);o.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=o,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.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(r.image)}catch(t){e(t)}}function $o(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Vi(t)})}function Uo(t,e){const r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)}function Wo(t,e,r){let{strokeStyle:n,lineDash:i,lineWidth:o,lineCap:s,lineJoin:a,alpha:c}=e;if(n&&0!=o){if(s&&(t.lineCap=s),i){const e="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=e?[0,2*o]:[o,o];break;case"square-dot":i=e?[o,2*o]:[2*o,o];break;case"dash":i=e?[3*o,2.5*o]:[4*o,1.5*o];break;case"dash-dot":i=e?[3*o,3*o,0,3*o]:[4*o,2*o,o,2*o];break;case"long-dash":i=e?[5*o,4*o]:[6*o,3*o];break;case"long-dash-dot":i=e?[5*o,3*o,0,3*o]:[6*o,2*o,o,2*o];break;case"long-dash-dot-dot":i=e?[5*o,2*o,0,2*o,0,2*o]:[6*o,o,o,o,o,o]}Array.isArray(i)||(i=[]),t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=n,t.lineWidth=o,t.lineJoin=a,t.stroke()}}function qo(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,r=[];let n;for(;null!==(n=e.exec(t));)n[1]?r.push({text:n[2],bold:!0,italic:!1}):n[3]?r.push({text:n[4],bold:!1,italic:!0}):n[5]&&r.push({text:n[5],bold:!1,italic:!1});return r}function Bo(t,e,r,n=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const o=e.text.substring(0,i);if(!(t.measureText(o).width+(i-1)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function Go(t,e,r,n,i,o=0){const s=String(e).split("\n");return n?[].concat(...s.map(e=>function(t,e,r,n=0){const i=[];let o=[],s=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=r-s,u=t.measureText(a).width+(a.length-1)*n;if(u<=c)o.push({...e,text:a}),s+=u,a="";else{const r=Bo(t,{...e,text:a},c,n);o.push(r),i.push(o),o=[],s=0,a=a.substring(r.text.length)}}}),o.length>0&&i.push(o),i}(t,i?qo(e):[{text:e,bold:!1,italic:!1}],r,o))):s.map(t=>i?qo(t):[{text:t,bold:!1,italic:!1}])}function Ho(t,e,r,n,i,o,s=0){if(!n)return[];t.save(),t.font=r;const a=Go(t,n,e,!!i,o,s);return t.restore(),a}function Xo(t){const{fontFamily:e=No.FONT_FAMILY,bold:r=No.BOLD,italic:n=No.ITALIC,fontSize:i=No.FONT_SIZE}=t,o=[];return r&&o.push("bold"),n&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function Vo(t,e){const r=t.bold||e.bold,n=t.italic||e.italic;return Xo({...t,bold:r,italic:n})}function Zo(t,e,r,n){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=No.FONT_COLOR,textAlign:c=No.TEXT_ALIGN,textBaseline:u=No.TEXT_BASELINE,textBackgroundStyle:h,fontSize:l,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:g=0}=n;i=void 0!==i?i:1,l||=No.FONT_SIZE,f||=1.2*l,t.save();const{left:y,top:m,width:b,height:x}=e;if(o&&s&&(t.translate(y+b/2,m+x/2),t.rotate(-o),t.translate(-(y+b/2),-(m+x/2))),t.beginPath(),t.font=Xo(n),!d&&p){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",o=e.measureText(i).width,s=[];let a=0;for(const i of r){const r=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=n-("ellipsis"===t?o:0))){const i=Qo(e,c,n-a-("ellipsis"===t?o:0),t);return r.push(i),s.push(r),s}r.push(c),a+=i}s.push(r),a=0}return s}(p,t,r,b);r=e}const v=r.length*f;let _;switch(u){case"top":_=m,t.textBaseline="top";break;case"bottom":_=m+x-v+f,t.textBaseline="bottom";break;default:_=m+x/2-v/2+f/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach((e,i)=>{const o=_+i*f,s=function(t,e,r,n=0){return e.reduce((e,i)=>(t.font=Vo(r,i),e+t.measureText(i.text).width+n*(i.text.length-1)),0)}(t,e,n,g);let u=y;switch(c){case"left":case"justify":u=y;break;case"right":u=y+b-s;break;case"center":u=y+(b-s)/2}if(h&&(t.fillStyle=h,function(t,e,r,n,i,o=0,s=!1,a=!0){o="number"==typeof o?{tl:o,tr:o,br:o,bl:o}:{tl:0,tr:0,br:0,bl:0,...o},t.beginPath(),t.moveTo(e+o.tl,r),t.lineTo(e+n-o.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+o.tr),t.lineTo(e+n,r+i-o.br),t.quadraticCurveTo(e+n,r+i,e+n-o.br,r+i),t.lineTo(e+o.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-o.bl),t.lineTo(e,r+o.tl),t.quadraticCurveTo(e,r,e+o.tl,r),t.closePath(),s&&t.fill(),a&&t.stroke()}(t,u-4,o-l/2-4,s+8,l+8,4,!0,!1),t.fillStyle=a),"justify"===c&&i<r.length-1&&e.length>1){const r=b-s,i=e.length-1,a=r/i;e.forEach((e,r)=>{t.font=Vo(n,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(r<i?a:0)})}else e.forEach(e=>{t.font=Vo(n,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+g})})}),t.restore()}function Qo(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){const o=i+e.text[n];if(t.measureText(o).width>r)break;i=o}return{...e,text:i+("ellipsis"===n?"…":"")}}function Jo(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Fo()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Fo),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Fo()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Fo(),Do="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const r=document.createElement("canvas");return r.width=t,r.height=e,r};const Ko=[];function ts(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-r.x)/i.x,e=(e-r.y)/i.y):(t-=r.x,e-=r.y),0!==n){const r=Math.cos(-n),i=Math.sin(-n),o=t*i+e*r;t=t*r-e*i,e=o}return{x:t+r.x,y:e+r.y}}function es(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(t-=r.x,e-=r.y,0!==n){const r=Math.cos(n),i=Math.sin(n),o=t*i+e*r;t=t*r-e*i,e=o}return 1!==i.x||1!==i.y?{x:t*i.x+r.x,y:e*i.y+r.y}:{x:t+r.x,y:e+r.y}}function rs(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,o=ts(t,e,r,n,i);return r&&(o.x-=r.x,o.y-=r.y),o}return ts(t,e,r=r||this.rotatePoint,n,i)}function ns(t,e,r){if(!this.parent)return{x:t,y:e};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,o=es(t,e,void 0,n+(this._delta?.theta??0),i);return r&&(o.x+=r.x,o.y+=r.y),o}r=r||this.rotatePoint;const{theta:o=0,tx:s=0,ty:a=0,sx:c=1,sy:u=1}=this._delta||{};if(0===o&&0===s&&0===a&&1===c&&1===u)return es(t,e,r,n,i);return es(t+s,e+a,{x:r.x+s,y:r.y+a},n+o,{x:i.x*c,y:i.y*u})}function is(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return es(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)}function os(t,e,r){r=r||this.rootModel,Ko.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Ko.push(t);let n=this.transcoordS2P(t,e);for(let t=0;t<Ko.length;t++){const e=Ko[t],r=e.bounds;n.x+=r.left,n.y+=r.top,n=e.transcoordS2P(n.x,n.y)}return n}function ss(t,e,r){r=r||this.rootModel,Ko.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Ko.push(t);let n={x:t,y:e};for(let t=Ko.length-1;t>=0;t--){const e=Ko[t];n=e.transcoordP2S(n.x,n.y);const r=e.bounds;n.x-=r.left,n.y-=r.top}return n}function as(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)}function cs(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)}function us(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:o=0}=r.model,s=ts(t,e,n,o,i);return n&&(s.x-=n.x,s.y-=n.y),r===this?s:this.transcoordT2S(s.x,s.y,r)}function hs(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;if(n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e},!this.scalable)return n;const{translate:i={x:0,y:0},rotation:o=0,scale:s={x:1,y:1}}=r.model;return n=es(n.x,n.y,void 0,o+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}function ls(t){const e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:o,color:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),o)switch(o){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){const r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,r)}else n.background="transparent"}const fs={x:1,y:1},ds={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function ps(t,e){let r=this.bounds,n=this.rotatePoint;const i=this.get("rotation"),o=this.get("scale");if(t){const n=t.call(e,r);n&&(r=n)}const{left:s,top:a,width:c,height:u}=r;let h=[{x:s,y:a},{x:s+c,y:a+u}];h=h.map(t=>es(t.x,t.y,n,i,o));let l=h[0],f=h[1];n={x:(l.x+f.x)/2,y:(l.y+f.y)/2},h=h.map(t=>ts(t.x,t.y,n,i,o)),l=h[0],f=h[1],this.bounds={left:l.x,top:l.y,width:f.x-l.x,height:f.y-l.y}}function gs(t,e,r){let n=this.path,i=this.rotatePoint;t&&(n=t.call(r,n));let o=n.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(r,o);t&&(o=t)}const s={x:0,y:0};let a,c,u,h;n=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=n[0].x,u=h=n[0].y;for(let t=1;t<n.length;t++){const e=n[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<u?u=e.y:e.y>h&&(h=e.y)}i={x:(a+c)/2,y:(u+h)/2},i=this.toParent(i.x,i.y,s),this.path=o.map(t=>{const e=this.fromParent(t.x,t.y,i);return{...t,x:e.x,y:e.y}})}const ys=new Map;let ms=null;function bs(){ms&&(ms(),ms=null)}function xs(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var vs=new class{add(t){var e;xs(t)&&!ys.has(t)&&(ys.set(t,0),e=t?.root,ms||(ms=X.subscribe(t=>{if(0===t)return;const e=[];for(const[r,n]of ys){if(!xs(r)){e.push(r);continue}const i=n+t;i>=r.retention?e.push(r):ys.set(r,i)}for(const t of e){ys.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){Vi("RetentionManager removeSelf failed:",t)}}0===ys.size&&bs()},{description:"retention timer",component:e,getTargets:()=>Array.from(ys.keys()),metadata:{get count(){return ys.size},get preview(){return Array.from(ys.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){ys.delete(t)&&0===ys.size&&bs()}touch(t){t&&ys.has(t)&&ys.set(t,0)}dispose(){bs(),ys.clear()}get length(){return ys.size}};const _s=function(t){return t};function ws(t){const e=t.indexOf("||");let r="",n="";-1!=e&&(r=t,n=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),o=i.slice(1);return{defaultValue:n,match:t,originText:r||t,target:i[0],accessor:o.length>0?function(t){return o.reduce((t,e)=>t?t[e]:void 0,t)}:_s}}function ks(t){if(!t)return;const e=String(t),r=(e.match(/#{(\S*)}/)||[]).map(t=>ws(t))[0];if(r)return r.accessor(this.getState(r.target));const n=(e.match(/\${[^}]*}/)||[]).map(t=>ws(t))[0];if(n){const t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}function Ms(t,e){if(!t)return;const r=String(t),n=e||_i,i=(r.match(/#{(\S*)}/gi)||[]).map(t=>ws(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>ws(t));if(0==i.length&&0==o.length)return r;let s=r;return i.forEach(t=>{const e=n(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)}),o.forEach(t=>{const e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)}),s}function Ss(t,e,r){if(!t)return;const n=r||_i,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>ws(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>ws(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(r=>{const i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)}),s.forEach(r=>{const i=e.root.findById(r.target),o=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===o?r.defaultValue||"":o)}),t}:void 0}class Es{constructor(){}static registerDecorator(t,e){Es.constructors.set(t,e)}static create(t,e,r={},n){const i=Es.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(n,e,r)}}function zs(t,e){const r=e.x-t.x,n=e.y-t.y,i=Math.sqrt(r*r+n*n);if(!mt(t))return i;const o=bt(t,e,t.bulge);if(!o)return i;const s=Math.min(o.radius,i/2),a=2*Math.asin(s/o.radius);return o.radius*a}function As(t,e){const r=t.path.slice();if(!r||!r.length)return void Vi("path should not be empty");let n=1;const i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.toScene(r[0].x,r[0].y);if(e>=1)return t.toScene(r[r.length-1].x,r[r.length-1].y);for(;r[n];)i.push(zs(r[n-1],r[n])),n++;const o=i.reduce(function(t,e){return t+e},0);n=0;let s=0;do{s+=i[n++]}while(s/o<e);s-=i[--n];e=(e-s/o)*(o/i[n]);const a=r[n%r.length],c=r[(n+1)%r.length],{x:u,y:h}=function(t,e,r){if(mt(t)){const n=bt(t,e,t.bulge);if(n){let t=n.endAngle-n.startAngle;n.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=n.startAngle+r*t;return{x:n.cx+n.radius*Math.cos(e),y:n.cy+n.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*r),y:t.y+Math.round((e.y-t.y)*r)}}(a,c,e);return t.toScene(u,h)}function Ts(t,e){return!1}function Os({x:t,y:e},...r){const n=this.path,i=t,o=e;this.path=n.map(t=>({...t,x:t.x+i,y:t.y+o}))}function Is(t){const e=t??this.center.x,{rotation:r}=this.state,n=this.fillStyle;if(this.set("rotation",2*Math.PI-r),n&&"gradient"===n.type&&"linear"===n.gradientType){const t=ai(n);t.rotation=(Math.PI-parseFloat(n.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 js(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 Ps(t,e,r){if(r){const e=this.bounds,r=e.height/e.width;let n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let o=t.left-e.left,s=t.top-e.top;return 0!=o&&0!=s?(s=-i,o=-n):0!=o?o=-n:0!=s&&(s=-i),{left:e.left+o,top:e.top+s,width:e.width+n,height:e.height+i}}return t}function Rs(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function Cs(t){return As(this,t||0)}function Ns(){const t=this.path;let e,r,n,i;e=r=t[0].x,n=i=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<e?e=s.x:s.x>r&&(r=s.x),s.y<n?n=s.y:s.y>i&&(i=s.y)}return{left:e,top:n,width:r-e,height:i-n}}function Fs(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 r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))}function Ds(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ls(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 r=t.x-e.x,n=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+r,y:t.y+n}))}function Ys(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function $s(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}function Us(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}function Ws(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}function qs(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}function Bs(t){const{width:e,height:r,depth:n}=t,{top:i,left:o}=this.bounds;this.bounds={top:i,left:o,width:e,height:r},this.setState("depth",n)}function Gs(){return Vi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Hs(t){Vi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Xs(){return this.path}function Vs(){return this.center}function Zs(){return this.nature.mutable}function Qs(){return this.nature.resizable&&!this.stuck}function Js(){return this.nature.rotatable&&!this.stuck}Es.constructors=new Map;const Ks={x:1,y:1};function ta(t,e,r){const{offsetX:n,offsetY:i,blur:o,color:s}=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=r.rootModel.get("scale")??Ks;t.shadowOffsetX=n*a.x*Co,t.shadowOffsetY=i*a.y*Co,t.shadowBlur=o*a.x*Co,t.shadowColor=s}function ea(t){t.save(),this.prerender(t);const e=this.app,r=!0===t.__inHiddenSubtree;e?.isEditMode&&((function(t){const e=t?.app;if(!e?.isEditMode)return!1;const r=e.focusFilter;return!!(t.hidden||r&&!r(t))}(this)||r)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=r,t.restore()}function ra(t){const e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:o}=this.state,s=(r&&r.x||1)*this._delta.sx,a=(r&&r.y||1)*this._delta.sy,c=(n||0)+this._delta.theta,{tx:u=0,ty:h=0}=this._delta,l=(o||1)-this._delta.fade;(u||h)&&t.translate(u,h),(1!=s||1!=a||c)&&(t.translate(e.x,e.y),1==s&&1==a||t.scale(s,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),l&&(t.globalAlpha=l),i&&ta(t,i,this)}function na(t){}function ia(t){this.drawText(t)}function oa(t,e){t(this)}function sa(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Vi(t)})}function aa(t){!this.textHidden&&this.text&&this.hasTextProperty&&Zo(t,this.textBounds,this.textLines(t),this.state)}function ca(t,e){Wo(t,e?{...this.state,...e}:this.state)}function ua(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(Lo(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function ha(){return this.get("strokeStyle")}function la(t){this.set("strokeStyle",t)}function fa(){return this.getState("fillStyle")}function da(t){this.setState("fillStyle",t)}function pa(){return this.get("fontColor")}function ga(t){this.set("fontColor",String(_i(t)))}function ya(){return this.getState("rotation")}function ma(t){this.setState("rotation",Number(_i(t)))}function ba(){return this.app.isEditMode?["decotag","data-spread"]:[]}function xa(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function va(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function _a(t){this.setState("hidden",t)}function wa(){return this.state.tag}function ka(t){this.setState("tag",t)}function Ma(){}function Sa(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function Ea(){const t=this.getState("text");return null==t?"":String(t)}function za(t){const{textWrap:e,supportMarkdown:r}=this.state;return Ho(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}function Aa(){return Xo(this.model)}function Ta(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function Oa(){return this._text_substitutor||(this._text_substitutor=Ss(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function Ia(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let r,n,i,o,s,a,c,u,h,l,f,d=t.length,p=t.search(/[0-9\-\+#]/),g=p>0?t.substring(0,p):"",y=t.split("").reverse().join(""),m=y.search(/[0-9\-\+#]/),b=d-m,x=t.substring(b,b+1),v=b+("."===x||","===x?1:0),_=m>0?t.substring(v,d):"";if(r=(e="-"===(t=t.substring(p,v)).charAt(0)?-e:+e)<0?e=-e:0,n=t.match(/[^\d\-\+#]/g),i=".",o=n&&n[1]&&n[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),u=e.split("."),(!u[1]||u[1]&&u[1].length<=a)&&(e=(+e).toFixed(a+1)),h=t[0].split(o),t[0]=h.join(""),s=t[0]&&t[0].indexOf("0"),s>-1)for(;u[0].length<t[0].length-s;)u[0]="0"+u[0];else 0===+u[0]&&(u[0]="");if((e=e.split("."))[0]=u[0],c=h[1]&&h[h.length-1].length,c){for(l=e[0],y="",b=l.length%c,d=l.length,v=0;v<d;v++)y+=l.charAt(v),!((v-b+1)%c)&&v<d-c&&(y+=o);e[0]=y}return e[1]=t[1]&&e[1]?"."+e[1]:"",n=e.join(""),"0"!==n&&""!==n||(r=!1),f="+"==t[0].substring(0,1)?r?"-":"+":r?"-":"",g+(f+n)+_}(t,this.textSubstitutor()):this.textSubstitutor()}function ja(t){delete this._text_substitutor;const e=_i(t);this.setState("text",null==e?"":String(e))}function Pa(){let{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;const{left:i,top:o,width:s,height:a}=this.bounds;return{left:i+e,top:o+t,width:Math.max(s-e-r,0),height:Math.max(a-t-n,0)}}function Ra(){return 0}function Ca(){return!!this._textHidden}function Na(t){this._textHidden=!!t,this.invalidate()}function Fa(){return!0}function Da(t){return t}function La(t){return Math.pow(t,2)}function Ya(t){return 1-Math.sin(Math.acos(t))}function $a(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function Ua(t){for(let e=0,r=1;;e+=r,r/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(r,2)}function Wa(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var qa={linear:Da,quad:La,circ:Ya,back:$a,bounce:Ua,elastic:Wa},Ba=Object.freeze({__proto__:null,back:$a,bounce:Ua,circ:Ya,default:qa,elastic:Wa,linear:Da,quad:La});class Ga{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:r="linear",options:n,ease:i}=this.config;let o;o="string"==typeof r?qa[r]:r,this.delta="out"===i?function(t,e){return function(r){return 1-t(1-r,e)}}(o,n):"inout"===i?function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(o,n):o,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:r=!1,interval:n=0,onComplete:i}=this.config;this._started=!0;const o=this.config?.type??"animation";let s=0,a=0;const c=()=>X.simTime,u=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(i);0==s&&(s=c(),this.client?.touch?.());const h=c()-s,l=Math.max((h-e)%(t+n),0)/t,f=n<=0&&a>l;if(a=l,l>=1||f){if(this.step(1),this.client&&this.client.invalidate?.(),!r||!this._started)return this.stop(i),void(s=0);if(n>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=X.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}}))},n/2)},n/2))}else this.step(this.delta(l)),this.client&&this.client.invalidate?.()};this._unsub=X.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}})}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 Ha={rotation:class extends Ga{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends Ga{step(t){const{theta:e=.2617993877991494}=this.config,r=4*e;let n=t*r;t<1/4?n*=-1:t<3/4?n-=2*e:n=r-n,this.client.delta?.("theta",n)}},heartbeat:class extends Ga{step(t){const{scale:e=1.3}=this.config,r=2*(e-1);let n;n=t<.5?1+r*t:1+(1-t)*r,this.client.delta?.({sx:n,sy:n,sz:n})}},moving:class extends Ga{step(t){const{x:e=0,y:r=0}=this.config;this.client.delta?.({tx:t*e,ty:t*r})}},outline:class extends Ga{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const r=this.client.root.findById(e);if(!r)return;let n={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(n=i);const{tx:o,ty:s}=n,a=r.outline(t),{x:c,y:u}=this.client.center,h=this.client.toScene(c,u);this.client.delta({tx:a.x-h.x+o,ty:a.y-h.y+s})}},fade:class extends Ga{step(t){const{startAlpha:e=1,endAlpha:r=0}=this.config,n=Math.max(Math.min(e,r,1),0),i=2*(Math.min(Math.max(e,r,1),1)-n);let o;o=t<.5?i*t:(1-t)*i,this.client.delta?.("fade",o)}},waypoint:class extends Ga{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 r=e.center,n=t.center,{x:i,y:o}=e.toScene(r.x,r.y),{x:s,y:a}=t.toScene(n.x,n.y);this._startX=i,this._startY=o,this._endX=s,this._endY=a;const c=this.config.yawOffset??Math.PI/2,u=Math.atan2(a-o,s-i)+c;this.client.location={x:i,y:o},this.client.setState("rotation",u),super.start()}stop(t){const{toComponent:e,finalize:r="snap"}=this.config;if(super.stop(t),"snap"===r&&e){const t=e.center,r=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=r}}step(t){const e=(this._endX-this._startX)*t,r=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+r}}}};const Xa={gradation:function(t,e,r){const{subType:n,from:i,to:o,colors:s}=r;let a;switch(n){case"linear":default:a=e.createLinearGradient(i.x,i.y,o.x,o.y);break;case"radial":a=e.createRadialGradient(i.x,i.y,i.r,o.x,o.y,o.r)}s&&(s.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:ta};function Va(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:r,component:n,step:i=()=>{},onStart:o,onProgress:s,onComplete:a,options:c,repeat:u=!1,delta:h}=t;let l;l="string"==typeof h?Ba[h]:h||Da,"out"===r?l=function(t,e){return function(r){return 1-t(1-r,e)}}(l,c):"inout"===r&&(l=function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(l,c));let f=!1,d=null;return{start:function(){if(f)return this;if(n?.root?.app?.suppressAnimations)return this;f=!0,o&&o();let t=0;const r=()=>X.simTime;return d=X.subscribe(()=>{if(!f)return;if(n?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=r());const o=(r()-t)/e,a=u?o%1:Math.min(o,1);i(l(a,c)),s&&s(a),!(o>=1)||u&&f||(this.stop(),t=0)},{description:"animate()",component:n,metadata:{duration:e,repeat:u}}),this},stop:function(){return f=!1,d&&(d(),d=null),a&&a(),this}}}({component:this,...t}),this._animate}function Za(t,e){return function(t,e,r){const n=Xa[r.type];n&&n(t,e,r)}(this,t,e)}const Qa=100;function Ja(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Qa)/Qa}return e}}function Ka(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const r=t[e];null===r?delete t[e]:"number"==typeof r?Number.isFinite(r)?Number.isInteger(r)||(t[e]=Math.round(r*Qa)/Qa):delete t[e]:"object"==typeof r&&Ka(r)}return t}function tc(...t){return JSON.stringify(this.hierarchy,Ja,...t)}function ec(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function rc(t){this.rootModel.closeScene(t)}function nc(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 ic(){this.parent&&this.parent.invalidate()}function oc(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function sc(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function ac(){return this.getState("data")}function cc(t){this.setState("data",t),this.touch()}function uc(t){const e=this.model.event?.tap;if(e){const{x:t,y:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:r}))}}function hc(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function lc(){return Number(this.get("retention"))||0}function fc(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const r=e.type?Ha[e.type]:void 0;return r?new r(t,e):null}(this,t.oncreate))}return this._animation}}function dc(){return!!this.animation?.started}function pc(t){this.animation&&(this.animation.started=t)}function gc(){}function yc(t,e,r,n){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function mc(t,e,r,n){return t==e.get("type")}function bc(t,e,r,n,i,o){return t(e,r,n,i)&&o.push(r),r.components&&r.components.forEach(r=>{bc(t,e,r,n,i,o)}),o}function xc(t,e,r,n){switch(t){case"(all)":return!0;case"(parent)":return r&&r.parent===e;case"(child)":case"(children)":return r&&r===e.parent;case"(sibling)":case"(siblings)":return r&&r.parent===e.parent&&r!==e;default:return!1}}function vc(t,e,r){if("(root)"==t)return[e];if("(self)"==t)return r?[r]:[];let n;switch(t.charAt(0)){case"#":const r=e.root.findAllById?.(t.substring(1));return r||[];case".":n=yc;break;case"(":n=xc;break;default:n=mc}return bc(n,t,e,r,e,[])}function _c(t,...e){if(t(this,...e))return this}function wc(t,...e){return"string"==typeof t?vc(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function kc(t,e,r){if(!this.capturable||r?.(this))return!1;const n=this.fromParent(t,e);return this.contains(n.x,n.y)?this:void 0}function Mc(t){return this.anchors.find(e=>e.name===t)}function Sc(t){return!0}function Ec(t){return this._parent.getContext(t??this)}function zc(){return this.isRoot()?this:this.parent&&this.parent.root}function Ac(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Tc(){return this._parent}function Oc(t){this._parent=t}function Ic(){return this.nature.anchors||[]}function jc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Pc(){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 Rc(){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 Cc(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Nc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Fc(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Dc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Lc={},Yc={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},$c=[],Uc=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"]),Wc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let qc=0;const Bc={};const Gc=new FinalizationRegistry(t=>{!function(t){qc--;let e=Bc[t];e||(e=Bc[t]={up:0,down:0}),e.down++}(t)});class Hc{static get nature(){return Yc}static register(t,e){if(!e)return Lc[t];Lc[t]=e}static types(){return Object.keys(Lc)}static get residents(){return Bc}static get residentsCount(){return qc}static registerDecorator(t,e){Es.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"},r=[];for(const n of Object.keys(t)){const i=e[n];if(!i)continue;const o=t[n];if(o&&"object"==typeof o){if("script"===o.action){const t="string"==typeof o.value?o.value:o.value&&"object"==typeof o.value?o.value.script:"";t&&r.push({trigger:i,action:"script",code:t,target:o.target});continue}r.push({trigger:i,action:o.action,target:o.target,value:o.value,options:{emphasize:o.emphasize,restore:o.restore,pressed:o.pressed,...o.options??{}}})}}return r}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=ai(Wc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),vs.add(this),function(t){qc++;let e=Bc[t];e||(e=Bc[t]={up:0,down:0}),e.up++}(this._model.type),Gc.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(),vs.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=ai(Wc))}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&&vs.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 r=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return r._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&vs.add(r)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&r.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 r=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return r.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=ai(this._model);return this.volatile.forEach(e=>{delete t[e]}),Ka(t)}get volatile(){return $c}_applyProps(t,e,r){const n={},i={};let o=!1;const s=ai(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=r.getBeforeVal(e),u=s[e];!r.sensitive&&function(t,e){return Fr(t,e)}(c,u)||(i[e]=c,n[e]=u,t[e]=u,r.clearState&&delete a._state[e],o=!0)}),o){this._cachedState=null;Object.keys(n).some(t=>!Uc.has(t))&&this.clearCache(),n.hasOwnProperty("text")&&delete this._text_substitutor,r.beforeFillStyle&&r.beforeFillStyle(n,i),n.hasOwnProperty("fillStyle")&&this.onchangeFill(n,i),r.afterFillStyle&&r.afterFillStyle(n,i),n.hasOwnProperty("data")&&this.onchangeData(n,i),this.onchange&&this.onchange(n,i),this.trigger("change",n,i)}return this}contains(t,e){return Ts.call(this,t,e)}move(t,...e){Os.call(this,t,...e)}symmetryX(t){Is.call(this,t)}symmetryY(t){js.call(this,t)}adjustResize(t,e,r){return Ps.call(this,t,e,r)}adjustRotation(t,e){return Rs.call(this,t,e)}outline(t){return Cs.call(this,t)}get bounds(){return Ns.call(this)}set bounds(t){Fs.call(this,t)}get center(){return Ds.call(this)}set center(t){Ls.call(this,t)}get location(){return Ys.call(this)}set location(t){$s.call(this,t)}get rotate(){return Us.call(this)}set rotate(t){Ws.call(this,t)}get dimension(){return qs.call(this)}set dimension(t){Bs.call(this,t)}get path(){return Gs.call(this)}set path(t){Hs.call(this,t)}get drawPath(){return Xs.call(this)}get rotatePoint(){return Vs.call(this)}get mutable(){return Zs.call(this)}get resizable(){return Qs.call(this)}get rotatable(){return Js.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&&ea.call(this,t)}prerender(t){ra.call(this,t)}render(t){na.call(this,t)}postrender(t){ia.call(this,t)}prepare(t,e){oa.call(this,t,e)}prepareIf(t){sa.call(this,t)}drawText(t){aa.call(this,t)}drawStroke(t,e){ca.call(this,t,e)}drawFill(t,e){ua.call(this,t,e)}get strokeStyle(){return ha.call(this)}set strokeStyle(t){la.call(this,t)}get fillStyle(){return fa.call(this)}set fillStyle(t){da.call(this,t)}get fontColor(){return pa.call(this)}set fontColor(t){ga.call(this,t)}get rotation(){return ya.call(this)}set rotation(t){ma.call(this,t)}get decorators(){return ba.call(this)}get decotag(){return xa.call(this)}get hidden(){return va.call(this)}set hidden(t){_a.call(this,t)}get tag(){return wa.call(this)}set tag(t){ka.call(this,t)}get appendum(){return Ma.call(this)}set appendum(t){Sa.call(this,t)}defaultTextSubstitutor(){return Ea.call(this)}textLines(t){return za.call(this,t)}get font(){return Aa.call(this)}get lineHeight(){return Ta.call(this)}get textSubstitutor(){return Oa.call(this)}get text(){return Ia.call(this)}set text(t){ja.call(this,t)}get textBounds(){return Pa.call(this)}get textRotation(){return Ra.call(this)}get textHidden(){return Ca.call(this)}set textHidden(t){Na.call(this,t)}get hasTextProperty(){return Fa.call(this)}animate(t){return Va.call(this,t)}effect(t,e){return Za.call(this,t,e)}serialize(...t){return tc.call(this,...t)}trim(){ec.call(this)}closeScene(t){rc.call(this,t)}delta(t,e){return nc.call(this,t,e)}invalidate(){ic.call(this)}get value(){return oc.call(this)}set value(t){sc.call(this,t)}get data(){return ac.call(this)}set data(t){cc.call(this,t)}set tap(t){uc.call(this,t)}get mappings(){return hc.call(this)}get retention(){return lc.call(this)}get animation(){return fc.call(this)}get started(){return dc.call(this)}set started(t){pc.call(this,t)}get controls(){return gc.call(this)}findFirst(t,...e){return _c.call(this,t,...e)}findAll(t,...e){return wc.call(this,t,...e)}capture(t,e,r){return kc.call(this,t,e,r)}findAnchor(t){return Mc.call(this,t)}isDescendible(t){return Sc.call(this,t)}getContext(t){return Ec.call(this,t)}get root(){return zc.call(this)}get rootModel(){return Ac.call(this)}get parent(){return Tc.call(this)}set parent(t){Oc.call(this,t)}get anchors(){return Ic.call(this)}get scalable(){return jc.call(this)}get stuck(){return Pc.call(this)}get capturable(){return Rc.call(this)}get position(){return Cc.call(this)}get origin(){return Nc.call(this)}get offset(){return Fc.call(this)}get app(){return Dc.call(this)}drawEffect(t){Ro.call(this,t)}prepareFill(t,e){Yo.call(this,t,e)}prepareFillIf(t){$o.call(this,t)}onchangeFill(t,e){Uo.call(this,t,e)}drawImage(t,e,r,n,i,o){Po.call(this,t,e,r,n,i,o)}mutateBounds(t,e){ps.call(this,t,e)}mutatePath(t,e,r){gs.call(this,t,e,r)}access(t){return ks.call(this,t)}substitute(t,e){return Ms.call(this,t,e)}onchangeMappings(t,e){jo.call(this,t,e)}onchangeData(t,e){To.call(this,t,e)}buildMappings(){Oo.call(this)}executeMappings(t){Ao.call(this,t)}disposeMappings(){Io.call(this)}ondropfile(t,e){Jo.call(this,t,e)}transcoordS2P(t,e,r){return ns.call(this,t,e,r)}transcoordP2S(t,e,r){return rs.call(this,t,e,r)}transcoordS2T(t,e,r){return os.call(this,t,e,r)}transcoordT2P(t,e,r){return ss.call(this,t,e,r)}transcoordT2S(t,e,r){return as.call(this,t,e,r)}transcoordS2TR(t,e,r){return is.call(this,t,e,r)}transcoordS2O(t,e,r){return cs.call(this,t,e,r)}transcoordC2S(t,e,r){return us.call(this,t,e,r)}transcoordS2C(t,e,r){return hs.call(this,t,e,r)}toParent(t,e,r){return ns.call(this,t,e,r)}fromParent(t,e,r){return rs.call(this,t,e,r)}toScene(t,e,r){return os.call(this,t,e,r)}fromScene(t,e,r){return as.call(this,t,e,r)}toLocal(t,e,r){return us.call(this,t,e,r)}toGlobal(t,e,r){return hs.call(this,t,e,r)}toOther(t,e,r){return cs.call(this,t,e,r)}on(t,e,r){return Wi.call(this,t,e,r)}off(t,e,r){return qi.call(this,t,e,r)}once(t,e,r){return Bi.call(this,t,e,r)}trigger(t,...e){return Gi.call(this,t,...e)}delegate_on(t){return Hi.call(this,t)}delegate_off(t){return Xi.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,r){}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){}}Hc.capabilities=[],Hc.requires3d=!1,Hc.union=function(t){let e=0,r=0,n=0,i=0,o=!1;return t.forEach(t=>{o?(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i)):(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height,o=!0)}),{left:e,top:r,width:n-e,height:i-r}},Hc.transcoordR=ts,Hc.transcoordRR=es,Hc.createCanvas=Do,Hc.memoize=function(t,e,r){const n=function(t,e){let r=t;for(;r;){const t=Object.getOwnPropertyDescriptor(r,e);if(t?.get)return t;r=Object.getPrototypeOf(r)}}(t,e);if(!n?.get)return void Vi(`${String(e)} is not defined in ${t.constructor.name}`);const i=n.get,o={get:r?function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};n.set&&(o.set=n.set),Object.defineProperty(t,e,o)},Hc.mixin=function t(e,r){if(r instanceof Array)r.forEach(r=>t(e,r));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(r)>=0)return e;if(e.mixingIn.indexOf(r)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(r),r.call(e),e.mixingIn.pop(),e.mixedIn.push(r)}return e},Hc.drawText=Zo,Hc.font=Xo,Hc.textLines=Ho,Hc.drawStroke=Wo,Hc.drawFill=Lo,Hc.reposition=function(t){let{id:e,scale:r=fs,bold:n,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:h,paddingLeft:l,paddingRight:f,fontSize:d=No.FONT_SIZE,lineWidth:p=0,lineHeight:g,lineDash:y}=t.state;h||=0,u||=0,l||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:x=0,fontColor:v,hidden:_}=t,{left:w,top:k,width:M,height:S}=t.bounds,E=t.element;if(E.hidden=!t.app?.isEditMode&&_,e&&(E.id=e),m&&(E.className=m),Object.assign(E.style,ds,{fontFamily:o,fontSize:d+"px",width:M+"px",height:S+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:h+"px",paddingLeft:l+"px",border:p+"px",borderColor:b,borderStyle:p>0?y||No.LINE_DASH:"",color:v,fontWeight:n?"bold":"",fontStyle:i?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:a,lineHeight:void 0===g?"":g+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:k+"px"}),ls(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,r=e.offsetX??e.left??0,n=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,o=e.color??"transparent";t.element.style.boxShadow=`${r}px ${n}px ${i}px ${o}`}(t),t.isIn3DSpace())return;const z=t.delta(),A=(r&&r.x||1)*z.sx,T=(r&&r.y||1)*z.sy,O=(x||0)+z.theta,I=z.tx||0,j=z.ty||0;E.style.transform=`rotate(${O}rad) translate(${I}px, ${j}px) scale(${A}, ${T}) perspective(1px)`},Hc.RetentionManager=vs,Hc.template=function(t,e,r){var n=In.imports._.templateSettings||In;r&&tn(t,e,r)&&(e=void 0),t=An(t),e=sn({},e,n,bn);var i,o,s=sn({},e.imports,n.imports,bn),a=pr(s),c=function(t,e){return gn(e,function(e){return t[e]})}(s,a),u=0,h=e.interpolate||Fn,l="__p += '",f=RegExp((e.escape||Fn).source+"|"+h.source+"|"+(h===_n?Nn:Fn).source+"|"+(e.evaluate||Fn).source+"|$","g"),d=Ln.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,r,n,s,a,c){return n||(n=s),l+=t.slice(u,c).replace(Dn,vn),r&&(i=!0,l+="' +\n__e("+r+") +\n'"),a&&(o=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+e.length,e}),l+="';\n";var p=Ln.call(e,"variable")&&e.variable;if(p){if(Cn.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else l="with (obj) {\n"+l+"\n}\n";l=(o?l.replace(jn,""):l).replace(Pn,"$1").replace(Rn,"$1;"),l="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var g=pn(function(){return Function(a,d+"return "+l).apply(void 0,c)});if(g.source=l,dn(g))throw g;return g},Hc.buildSubstitutor=Ss,["rotatePoint","font","lineHeight","retention"].forEach(t=>Hc.memoize(Hc.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Hc.memoize(Hc.prototype,t,!0));const Xc=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"]),Vc={},Zc=new WeakMap;function Qc(t){return class extends t{_itemsFromData(){return!0}_currentKeyOf(t){const e=t?.[q];return null!=e?String(e):null}_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){const e=this._keyedById(),r=new Map;for(const e of t){const t=this._recordKey(e);t&&r.set(t,e)}const n=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&n.set(e,t)}const i=e?(t=>{const e=t?.root??Vc;let r=Zc.get(e);return r||Zc.set(e,r=new Map),r})(this):null;for(const[t,o]of n)if(!r.has(t))if(e)setTimeout(()=>{if(o.parent===this){try{this.removeItem(o,!0)}catch{}try{o?.dispose?.()}catch{}i.get(t)?.carrier===o&&i.delete(t)}},0);else{try{this.removeItem(o,!0)}catch{}try{o?.dispose?.()}catch{}}for(const[t,o]of r){if(n.has(t))continue;if(null==o.itemId)continue;const r=i?.get(t),s=r&&r.holder!==this&&r.carrier?.parent===r.holder?r.carrier:this._createItemFromRecord(o);if(s)if(e){s[q]=o.slotId;try{this.handoverIn(s,o.slotId?{slotId:o.slotId}:void 0)}catch{}i.set(t,{holder:this,carrier:s})}else{s[q]=t;try{this.handoverIn(s)}catch{}}}for(const[t,i]of r){const r=n.get(t);if(r){if(i.itemState&&"function"==typeof r.setState)try{r.setState(i.itemState)}catch{}if(e&&r[q]!==i.slotId){r[q]=i.slotId;try{this.handoverIn(r,i.slotId?{slotId:i.slotId}:void 0)}catch{}}}}e&&this._orderItemsAs([...r.keys()])}_orderItemsAs(t){const e=new Map(t.map((t,e)=>[t,e])),r=this._items.filter(t=>e.has(this._currentKeyOf(t)??"")),n=[...r].sort((t,r)=>e.get(this._currentKeyOf(t))-e.get(this._currentKeyOf(r)));if(n.every((t,e)=>t===r[e]))return;let i=0;for(let t=0;t<this._items.length;t++)e.has(this._currentKeyOf(this._items[t])??"")&&(this._items[t]=n[i++]);const o=this.seatHeldItem;if("function"==typeof o)for(const t of n)o.call(this,t,{slotId:t[q]})}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],r=new Map,n=[];for(const t of this._items){const e=t[q];null!=e?r.set(String(e),t):n.push(t)}for(const n of t){const t=r.get(n)??null;e.push(this._slotRecordOf(n,t))}for(const t of n)e.push(this._slotRecordOf("",t));for(const[n,i]of r)t.includes(n)||e.push(this._slotRecordOf(n,i));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const r=e?.state?.id;return{slotId:t,itemId:null!=r?String(r):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const r=this._businessFields?.();if(Array.isArray(r)){if(0===r.length)return;const t={};for(const n of r)n in e&&void 0!==e[n]&&(t[n]=e[n]);return Object.keys(t).length>0?t:void 0}const n={};for(const t of Object.keys(e))Xc.has(t)||t.startsWith("_")||(n[t]=e[t]);return Object.keys(n).length>0?n:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const r=Hc.register?.(e);if(r&&"function"==typeof r){return new r({type:e,...t.itemState??{}})}}catch{}return null}}}function Jc(t,e,r){return r?{code:t,path:e,params:r}:{code:t,path:e}}const Kc="holder",tu=t=>"number"==typeof t&&Number.isFinite(t),eu=t=>tu(t)&&t>0,ru=t=>Number.isSafeInteger(t)&&t>0;function nu(t,e,r){const n=t?.allowed;if(n&&"object"==typeof n)for(const t of["width","depth","height"])eu(n[t])||r.push(Jc("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else r.push(Jc("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||ru(t.stackLimit)||t.stackLimit===1/0||r.push(Jc("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||tu(t.rotation)||r.push(Jc("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||r.push(Jc("ARRAY_REQUIRED",`${e}.accepts`))}function iu(t,e={}){const r=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Jc("TIERS_REQUIRED","tiers")];const n=e.anchors?new Set(e.anchors):null,i=new Set;return t.tiers.forEach((t,e)=>{const o=`tiers[${e}]`;if(!t||"object"!=typeof t)return void r.push(Jc("OBJECT_REQUIRED",o));if(ru(t.tierNo)?i.has(t.tierNo)?r.push(Jc("TIER_NUMBER_DUPLICATE",`${o}.tierNo`,{tierNo:t.tierNo})):i.add(t.tierNo):r.push(Jc("POSITIVE_INTEGER_REQUIRED",`${o}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?n&&!n.has(t.anchorId)&&r.push(Jc("ANCHOR_UNKNOWN",`${o}.anchorId`,{anchorId:t.anchorId})):r.push(Jc("ANCHOR_REQUIRED",`${o}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||r.push(Jc("MOUNT_INVALID",`${o}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])tu(t.position[e])||r.push(Jc("FINITE_NUMBER_REQUIRED",`${o}.position.${e}`));else r.push(Jc("OBJECT_REQUIRED",`${o}.position`));tu(t.rotation)||r.push(Jc("FINITE_NUMBER_REQUIRED",`${o}.rotation`));const s=t.layout;switch(s?.pattern){case"SINGLE":nu(s.slot,`${o}.layout.slot`,r);break;case"ROW":ru(s.count)||r.push(Jc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.count`)),eu(s.pitch)||r.push(Jc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch`)),"X"!==s.axis&&"Z"!==s.axis&&r.push(Jc("AXIS_INVALID",`${o}.layout.axis`)),nu(s.slot,`${o}.layout.slot`,r);break;case"GRID":ru(s.rows)||r.push(Jc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.rows`)),ru(s.cols)||r.push(Jc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.cols`)),eu(s.pitch?.x)||r.push(Jc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.x`)),eu(s.pitch?.z)||r.push(Jc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.z`)),nu(s.slot,`${o}.layout.slot`,r);break;case"CUSTOM":{if(!Array.isArray(s.slots)){r.push(Jc("ARRAY_REQUIRED",`${o}.layout.slots`));break}s.slots.length||r.push(Jc("SLOTS_REQUIRED",`${o}.layout.slots`));const t=new Set;s.slots.forEach((e,n)=>{const i=`${o}.layout.slots[${n}]`;ru(e?.slotNo)?t.has(e.slotNo)?r.push(Jc("SLOT_NUMBER_DUPLICATE",`${i}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):r.push(Jc("POSITIVE_INTEGER_REQUIRED",`${i}.slotNo`)),tu(e?.offset?.x)&&tu(e?.offset?.z)||r.push(Jc("FINITE_NUMBER_REQUIRED",`${i}.offset`)),nu(e,i,r)});break}default:r.push(Jc("PATTERN_INVALID",`${o}.layout.pattern`))}}),r}function ou(t,e=""){const r=[],n=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,r)=>n(t,`${e}[${r}]`));else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))n(i,e?`${e}.${r}`:r)}else r.push(Jc("NOT_PERSISTABLE",e,{value:String(t)}))};return n(t,e),r}function su(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 au(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:su(t)},(t,e)=>e+1)}function cu(t,e,r,n,i="ROW_MAJOR"){switch(i){case"ROW_MAJOR":return(r-1)*e+n;case"COL_MAJOR":return(n-1)*t+r;case"SERPENTINE_ROW":return(r-1)*e+(r%2==1?n:e-n+1);case"SERPENTINE_COL":return(n-1)*t+(n%2==1?r:t-r+1)}}function uu(t,e,r,n="ROW_MAJOR"){const i=r-1;switch(n){case"ROW_MAJOR":return{r:Math.floor(i/e)+1,c:i%e+1};case"COL_MAJOR":return{r:i%t+1,c:Math.floor(i/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(i/e)+1,r=i%e+1;return{r:t,c:t%2==1?r:e-r+1}}case"SERPENTINE_COL":{const e=Math.floor(i/t)+1,r=i%t+1;return{r:e%2==1?r:t-r+1,c:e}}}}const hu=(t,e)=>e&&0!==t?-t:t;function lu(t,e,r={}){const n=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!n||!ru(e.slot))return null;const i=n.layout;let o,s,a;switch(i.pattern){case"SINGLE":if(1!==e.slot)return null;o=i.slot,s={x:0,z:0};break;case"ROW":{if(e.slot>i.count)return null;const t=hu((e.slot-1-(i.count-1)/2)*i.pitch,"MAX"===i.origin);o=i.slot,s="X"===i.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>i.rows*i.cols)return null;const{r:t,c:r}=uu(i.rows,i.cols,e.slot,i.order),n=i.origin??{x:"MIN",z:"MIN"};o=i.slot,s={x:hu((r-1-(i.cols-1)/2)*i.pitch.x,"MAX"===n.x),z:hu((t-1-(i.rows-1)/2)*i.pitch.z,"MAX"===n.z)};break}case"CUSTOM":{const t=i.slots.find(t=>t.slotNo===e.slot);if(!t)return null;o=t,s={...t.offset},a=t.name;break}}return{tier:n.tierNo,slotNo:e.slot,name:a,anchorId:n.anchorId,mount:n.mount,tierPosition:{...n.position},tierRotation:n.rotation,offset:s,allowed:{...o.allowed},accepts:o.accepts?[...o.accepts]:void 0,stackLimit:o.stackLimit??r.defaultStackLimit??1,rotation:o.rotation??0}}function fu(t){return`t${t.tier}_s${t.slot}`}function du(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*pu(t){for(const e of t?.tiers??[])for(const t of au(e.layout))yield{tier:e.tierNo,slot:t}}function gu(t,e,r){if(!r)return{x:t,z:e};const n=r*Math.PI/180,i=Math.cos(n),o=Math.sin(n),s=t=>Math.round(1e9*t)/1e9;return{x:s(t*i+e*o),z:s(-t*o+e*i)}}function yu(t){const e=gu(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 mu=.05,bu=t=>!!t&&eu(t.width)&&eu(t.depth)&&eu(t.height);function xu(t,e){const r=e*Math.PI/180,n=Math.abs(Math.cos(r)),i=Math.abs(Math.sin(r)),o=t=>Math.round(1e9*t)/1e9;return{width:o(t.width*n+t.depth*i),depth:o(t.width*i+t.depth*n)}}function vu(t,e,r=0,n=.05){if(!bu(t))return null;if(!tu(r)||!tu(n)||n<0||n>=1)return null;const i=xu(t,e.rotation),o=Math.min(1,Math.min(e.allowed.width/i.width,e.allowed.depth/i.depth)*(1-n)),s=t.height*o;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(r+s/2),z:0},rotation:0,scale:o}}function _u(t,e,r=0,n=.05){const i=vu(t,e,r,n);if(!i)return null;const o=yu(e);return{position:{x:o.position.x,y:o.position.y+i.position.y,z:o.position.z},rotation:o.rotation,scale:i.scale}}function wu(t,e,r=.05){let n=0;return t.map(t=>{const i=t?_u(t,e,n,r):null;return i&&(n+=t.height*i.scale),i})}const ku=1e-6;function Mu(t,e){const r=yu(t),n=t.allowed.width/2,i=t.allowed.depth/2,o=[[-n,-i],[n,-i],[n,i],[-n,i]].map(([t,e])=>{const n=gu(t,e,r.rotation);return{x:r.position.x+n.x,z:r.position.z+n.z}}),s=gu(1,0,r.rotation),a=gu(0,1,r.rotation),c="HANG"===t.mount?-1:1,u=[r.position.y,r.position.y+c*t.allowed.height],h=o.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:o,axes:[s,a],y0:Math.min(...u),y1:Math.max(...u),minX:Math.min(...h),maxX:Math.max(...h)}}function Su(t,e){for(const r of[...t.axes,...e.axes]){const n=t.corners.map(t=>t.x*r.x+t.z*r.z),i=e.corners.map(t=>t.x*r.x+t.z*r.z);if(Math.min(Math.max(...n),Math.max(...i))-Math.max(Math.min(...n),Math.min(...i))<=ku)return!1}return!0}function Eu(t,e={}){const r=[],n=new Map;t.tiers.forEach((e,r)=>{const i=n.get(e.anchorId)??[];n.set(e.anchorId,i);for(const n of au(e.layout))i.push(Mu(lu(t,{tier:e.tierNo,slot:n}),r))});for(const[t,i]of n){const n=e.anchorFaces?.[t];if(n)for(const t of i)t.corners.some(t=>Math.abs(t.x)-n.width/2>ku||Math.abs(t.z)-n.depth/2>ku)&&r.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else r.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const o=[...i].sort((t,e)=>t.minX-e.minX);for(let t=0;t<o.length;t++){const e=o[t];for(let n=t+1;n<o.length&&o[n].minX<e.maxX-ku;n++){const t=o[n];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=ku)continue;if(!Su(e,t))continue;const[i,s]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];r.push({code:"SLOT_OVERLAP",path:`tiers[${s.tierIndex}]`,params:{tier:s.tier,slot:s.slot,otherTier:i.tier,otherSlot:i.slot}})}}}return r}function zu(t,e,r=[],n={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const i=n.normalizeType??(t=>null==t?"":String(t)),o=[];let s=!1;if(t.accepts){const r=i(e.type);r?t.accepts.map(i).includes(r)||o.push("TYPE_NOT_ACCEPTED"):s=!0}if(r.length+1>t.stackLimit&&o.push("STACK_LIMIT_EXCEEDED"),bu(e.dims)){const n=xu(e.dims,t.rotation);if(n.width>t.allowed.width&&o.push("WIDTH_EXCEEDED"),n.depth>t.allowed.depth&&o.push("DEPTH_EXCEEDED"),r.every(t=>bu(t.dims))){r.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&o.push("HEIGHT_EXCEEDED")}else s=!0}else s=!0;return o.length?{verdict:"NG",reasons:s?[...o,"SPEC_UNKNOWN"]:o}:s?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}const Au=[{id:"__default__",maxCount:1/0}];function Tu(t){const e={id:fu({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function Ou(t,e){const r=e?.state?.type??e?.type;return t.accepts?!!r&&t.accepts.includes(r):!t.allowedTypes?.length||!!r&&t.allowedTypes.includes(r)}function Iu(t){var e;return e=class extends t{get slotLayout(){}get slots(){const t=this.slotLayout;if(!t)return[];const e=[];for(const r of pu(t)){const n=lu(t,r);n&&e.push(Tu(n))}return e}slotById(t){const e=this.slotLayout;if(e){const r=du(t),n=r?lu(e,r):null;return n?Tu(n):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,r=0,n){const i=this.slotLayout,o=i?du(t):null,s=o?lu(i,o):null,a=s?_u(e,s,r,n):null;return a?{...a,anchorId:s.anchorId}:null}get arrangementStrategy(){return p}canReceive(t,e){const r=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return K.log({role:"target",contract:"canReceive",component:this,args:{carrier:$(t)},result:r}),r}findSlot(t){const e=this.slots.length?this.slots:Au;for(const r of e){if(!Ou(r,t))continue;const e=r.maxCount??this.arrangementStrategy.capacity(r),n=this._countOccupied(r.id);if(!(n>=e))return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:$(t)},result:{slotId:r.id,occupied:n,max:e}}),r}return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:$(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const r=this._realObject?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new w;r.getWorldQuaternion(n);const i=new w(e.x,e.y,e.z,e.w);return n.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,r=e?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new k;r.getWorldPosition(n);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new k(0,i,0);return r.localToWorld(t),{x:n.x,y:t.y,z:n.z}}return{x:n.x,y:n.y,z:n.z}}attachPointFor(t){const e=t?.[q];if(!e)return null;const r=this.slots.find(t=>t.id===e);return r?{position:r.localPosition??{x:0,y:0,z:0},rotation:r.localRotation??{x:0,y:0,z:0},slotId:r.id}:null}placementFor(t,e={}){const r=t&&"object"==typeof t&&"state"in t?t:void 0,n=r?r.state??{}:t??{},i={width:Number(n.width)||0,height:Number(n.height)||0,depth:Number(n.depth)||0},o=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!o)return null;const s=e.index??this._countOccupied(o.id),a=e.occupantCount??s,c=this.arrangementStrategy.positionAt(s,o,a,r??{state:{...i}});if(!c)return null;const u=Number(this.state?.width)||0,h=Number(this.state?.height)||0,l=c.x+i.width/2-u/2,f=c.y+i.height/2-h/2,d=this._realObject,p=d?.placementMode??"floor",g="space"===p?0:"inverted"===p?-i.depth/2:i.depth/2,y=this._receivingSurfaceLocalY();let m;m=null!==y?y+g:o.localPosition&&Number.isFinite(o.localPosition.z)?o.localPosition.z+g:g-(d?.geometricOffsetY??0);const b=this.acceptanceRotation?.(r??i,o)??void 0;return b?{position:{x:l,y:m,z:f},rotation:b}:{position:{x:l,y:m,z:f}}}_zPosFromSeatY(t,e,r){const n=this._realObject,i=n?.receivingSurfaceY??0,o=!(!r.localPosition||!Number.isFinite(r.localPosition.z));if(0===i&&!o)return null;const s=Number(e)||0,a=n?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-s/2:s/2)+(n?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!Ou(t,e))return null;const r=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<r?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[q]===t).length;const r=this.components;return r?r.filter(e=>e.parent===this&&e[q]===t).length:0}},e.__hasCapacity=!0,e}function ju(t,e){const r=t.left??0,n=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return[];const s="number"==typeof t.rotation?t.rotation:0,a=Math.cos(s),c=Math.sin(s),u=r+i/2,h=n+o/2,l="inbound"===e?-1:1;return[{lx:-i/2,lz:0,odx:-1,odz:0},{lx:i/2,lz:0,odx:1,odz:0},{lx:0,lz:-o/2,odx:0,odz:-1},{lx:0,lz:o/2,odx:0,odz:1}].map(t=>{var e,r;return{worldPos:(e=t.lx,r=t.lz,{x:u+e*a-r*c,z:h+e*c+r*a}),direction:{x:l*(t.odx*a-t.odz*c),z:l*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Pu(t,e){const r=t.left??0,n=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return{inbounds:[],outbounds:[]};const s="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&i<o,u=r+i/2,h=n+o/2,l=c?o/2:i/2,f=c?0:1,d=c?1:0,p=Math.cos(s),g=Math.sin(s),y=(t,e)=>({x:u+t*p-e*g,z:h+t*g+e*p}),m=c?{lx:0,lz:-l}:{lx:-l,lz:0},b=c?{lx:0,lz:l}:{lx:l,lz:0},x=y(m.lx,m.lz),v=y(b.lx,b.lz),_={x:f*p-d*g,z:f*g+d*p},w=Math.hypot(_.x,_.z)||1,k={x:_.x/w,z:_.z/w},M={x:-k.x,z:-k.z},S=(c?i:o)/2;return a?{inbounds:[{worldPos:v,direction:M,halfSpan:S}],outbounds:[{worldPos:x,direction:M,halfSpan:S}]}:{inbounds:[{worldPos:x,direction:k,halfSpan:S}],outbounds:[{worldPos:v,direction:k,halfSpan:S}]}}function Ru(t){const e=t.left??0,r=t.top??0,n=t.width??0,i=t.height??0;if(n<=0||i<=0)return null;const o="number"==typeof t.rotation?t.rotation:0,s="vertical"===t.orientation||"horizontal"!==t.orientation&&n<i,a=e+n/2,c=r+i/2,u=s?i/2:n/2,h=Math.cos(o),l=Math.sin(o),f=(t,e)=>({x:a+t*h-e*l,z:c+t*l+e*h});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Cu(t){const e=t.cx??0,r=t.cy??0,n=Math.abs(t.rx??100),i=Math.abs(t.ry??100),o=t.ratio??50,s=(n+n*o/100)/2,a=(i+i*o/100)/2,c=t.startAngle??0,u=t.endAngle??Math.PI/2,h="reverse"===t.status;if(n<=0||i<=0)return{inbounds:[],outbounds:[]};const l={x:e+s*Math.sin(c),z:r-a*Math.cos(c)},f={x:e+s*Math.sin(u),z:r-a*Math.cos(u)},d={x:Math.cos(c),z:Math.sin(c)},p={x:Math.cos(u),z:Math.sin(u)};return h?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:l,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:l,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function Nu(t){const e=Pu(t),r=e.outbounds[0];if(!r)return{inbounds:ju(t,"inbound"),outbounds:[]};const n=ju(t,"inbound").filter(t=>{const e=t.worldPos.x-r.worldPos.x,n=t.worldPos.z-r.worldPos.z;return Math.hypot(e,n)>1}),i=r.direction,o=[];for(const t of n){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const r=t.direction.x+i.x,n=t.direction.z+i.z,s=Math.hypot(r,n)||1;o.push({worldPos:t.worldPos,direction:{x:r/s,z:n/s},halfSpan:t.halfSpan})}return{inbounds:[...n,...o],outbounds:e.outbounds}}function Fu(t,e,r={}){const n=r.distance??5,i=r.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<i)return!1;const o=t.worldPos.x-e.worldPos.x,s=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const r=t.direction.x,i=t.direction.z;if(Math.abs(o*r+s*i)>n)return!1;const a=Math.abs(o*-i+s*r);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(o,s)<=n}function Du(t,e,r,n=0){const i=r.width??0,o=r.height??0;if(i<=0||o<=0)return!1;const s=(r.left??0)+i/2,a=(r.top??0)+o/2,c="number"==typeof r.rotation?r.rotation:0,u=Math.cos(-c),h=Math.sin(-c),l=t-s,f=e-a,d=l*u-f*h,p=l*h+f*u;return Math.abs(d)<=i/2+n&&Math.abs(p)<=o/2+n}function Lu(t,e,r){const n=r.width??0,i=r.height??0;if(n<=0||i<=0)return 1/0;const o=(r.left??0)+n/2,s=(r.top??0)+i/2;let a=t.x-o,c=t.z-s,u=e.x,h=e.z;const l="number"==typeof r.rotation?r.rotation:0;if(0!==l){const t=Math.cos(-l),e=Math.sin(-l),r=a*e+c*t,n=u*e+h*t;a=a*t-c*e,c=r,u=u*t-h*e,h=n}const f=n/2,d=i/2;let p=-1/0,g=1/0;if(Math.abs(u)<1e-9){if(a<-f||a>f)return 1/0}else{const t=(-f-a)/u,e=(f-a)/u;p=Math.max(p,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}if(Math.abs(h)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/h,e=(d-c)/h;p=Math.max(p,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}return g<p?1/0:p>=0?p:g>=0?Math.min(-p,g):-g}function Yu(t,e,r,n=6){return!!Du(t.worldPos.x,t.worldPos.z,e,n)&&(!r||t.direction.x*r.x+t.direction.z*r.z>=0)}function $u(t,e,r){return t.outbounds.map(t=>{const n=[];for(const i of e){let e=null;for(const n of i.topology.inbounds){if(!Fu(t,n,r))continue;const i=t.worldPos.x-n.worldPos.x,o=t.worldPos.z-n.worldPos.z,s=Math.hypot(i,o);(null===e||s<e)&&(e=s)}if(null===e&&i.bounds){const n=i.topology.outbounds[0]?.direction,o=!(i.topology.outbounds&&i.topology.outbounds.length)?r?.sinkMargin??30:6;if(Yu(t,i.bounds,n,o)){const r=Lu(t.worldPos,t.direction,i.bounds);if(Number.isFinite(r))e=r+1e3;else{const r=(i.bounds.left??0)+(i.bounds.width??0)/2,n=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-r,t.worldPos.z-n)+1e3}}}null!==e&&n.push({id:i.id,dist:e})}return 0===n.length?null:(n.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),n[0].id)})}function Uu(t,e){const r=new Map;for(const e of t)r.set(e.id,e);const n=new Map,i=new Set;for(const r of t){const o=t.filter(t=>t.id!==r.id),s=$u(r.topology,o,e);n.set(r.id,s);for(const t of s)null!=t&&i.add(t)}const o=(t,e)=>{if(!r.has(t)||!r.has(e)||t===e)return;const o=n.get(t)??[];o.includes(e)||(o.push(e),n.set(t,o),i.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])o(e.id,t);for(const t of e.links.upstream??[])o(t,e.id)}const s=new Set,a=new Set;for(const e of t){(n.get(e.id)??[]).some(t=>null!=t)||s.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:r,out:n,sinks:s,sources:a}}function Wu(t,e){const r=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const n=new Set([e]);for(const i of function(t,e,r){const n=r.get(e);if(n)return n;const i=new Set,o=[e],s=new Set([e]);for(;o.length;){const e=o.shift();for(const r of t.out.get(e)??[])null!=r&&(i.add(r),s.has(r)||(s.add(r),o.push(r)))}return r.set(e,i),i}(t,e,r))n.add(i);return n})}function qu(t,e,r,n){return e===r?0:function(t,e,r){const n=r.get(e);if(n)return n;const i=new Map([[e,0]]),o=[e];for(;o.length;){const e=o.shift(),r=i.get(e);for(const n of t.out.get(e)??[])null==n||i.has(n)||(i.set(n,r+1),o.push(n))}return r.set(e,i),i}(t,e,n).get(r)??1/0}function Bu(t,e,r){const n=t.out.get(e)??[],i=new Map,o=[];for(let e=0;e<n.length;e++){const s=n[e];if(null==s)continue;const a=s===r?0:qu(t,s,r,i);a!==1/0&&o.push({i:e,hops:1+a})}return o.sort((t,e)=>t.hops-e.hops||t.i-e.i),o.map(t=>t.i)}function Gu(t,e,r){const n=Bu(t,e,r);return n.length?n[0]:-1}function Hu(t,e,r){return e===r||Bu(t,e,r).length>0}function Xu(t,e){const r=new Set;for(const n of Wu(t,e))for(const e of n)t.sinks.has(e)&&r.add(e);return r}function Vu(t,e,r){return Zu(t,e,r).map(t=>t.index)}function Zu(t,e,r){const n=r instanceof Set?r:new Set(r);if(0===n.size)return[];const i=t.out.get(e)??[],o=new Map,s=[...n].sort(),a=[];for(let e=0;e<i.length;e++){const r=i[e];if(null==r)continue;let n=1/0,c="";for(const e of s){const i=1+(r===e?0:qu(t,r,e,o));i<n&&(n=i,c=e)}n!==1/0&&a.push({index:e,hops:n,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Qu(t,e={}){const r=[],n=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const n=t.nodes.get(e);if(!n||!n.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||r.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)||(i.has(e)||t.sources.has(e)||r.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const o=function(t){const e=[],r=[...t.nodes.keys()].sort(),n=new Set,i=[],o=new Set,s=r=>{n.add(r),i.push(r),o.add(r);for(const a of t.out.get(r)??[])if(null!=a)if(o.has(a)){const t=i.indexOf(a),r=i.slice(t),n=r.indexOf([...r].sort()[0]),o=[...r.slice(n),...r.slice(0,n)],s=o.join("→");e.some(t=>t.join("→")===s)||e.push(o)}else n.has(a)||s(a);i.pop(),o.delete(r)};for(const t of r)n.has(t)||s(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of o){t.some(t=>n.has(t))||r.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const s=e.routingWeights;if(s)for(const[t,e]of[...s].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&r.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[...i].sort())t.nodes.has(e)&&(a.has(e)||r.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return r.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),r}function Ju(t,e){if(!t)return[];const r=[],n=new Set,i=t=>{if(!t||n.has(t))return;if(n.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,n=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=n?String(n):void 0;if(i)try{const e=t.getSegmentTopology(),n=t.state??{},o={left:n.left,top:n.top,width:n.width,height:n.height,rotation:n.rotation};e&&r.push({id:i,topology:e,bounds:o})}catch{}}const o=t?.components;if(Array.isArray(o))for(const t of o)i(t)};return i(t),r}function Ku(t,e){const r=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof r&&r.length>0)return r;if("function"!=typeof t.getSegmentTopology)return null;const n=t.getSegmentTopology();if(!n||0===n.outbounds.length)return null;const i=$u(n,Ju(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of i)if(t)return t;return null}function th(t){return!!t&&"function"==typeof t.routingConstraints}function eh(t){return!!t&&"function"==typeof t.acceptedCarrierData}function rh(t,e=16){const r=[],n=t.parent??t.rootModel??t.root;if(!n)return r;const i=Ku(t);if(!i)return r;const o=oh(n,i);if(!o)return r;const s=[{segment:o,accumulated:{},pathIds:[i],visited:new Set([i])}];for(;s.length>0;){const t=s.shift();if(t.pathIds.length>e)continue;const i=th(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=nh(t.accumulated,i);if(!o)continue;const a=ih(t.segment,e.portId,n);a&&!t.visited.has(a.state?.id??"")?s.push({segment:a,accumulated:o,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):r.push({data:o,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(eh(t.segment)){const e=t.segment.acceptedCarrierData(),n=t.segment.state?.id;if(0===e.length)r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:n});else for(const i of e){const e=nh(t.accumulated,i);e&&r.push({data:e,weight:1,pathIds:t.pathIds,destination:n})}continue}const e=Ku(t.segment);if(!e||t.visited.has(e)){r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=oh(n,e);if(!i)continue;s.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return r}function nh(t,e){const r={...t};for(const[t,n]of Object.entries(e)){if(t in r&&r[t]!==n)return null;r[t]=n}return r}function ih(t,e,r){if("straight"===e&&t.state?.downstreamRef)return oh(r,t.state.downstreamRef);const n=oh(r,e);if(n)return n;const i=Ku(t);return i?oh(r,i):null}function oh(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const r=new Set,n=t=>{if(!t||r.has(t))return null;if(r.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=n(t);if(e)return e}return null};return n(t)}function sh(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function ah(t,e,r=5,n=[],i=r){const o=t.length,s=new Array(o).fill(void 0),a=new Set,c=(e,r)=>"start"===r?t[e].start:t[e].end,u=[],h=new Map,l=[],f=new Map;for(const t of n){const e=Array.isArray(t),r=e?t:t.positions,n=e?void 0:t.kind;if(!r.length)continue;const i=u.length;u.push({pos:r[0],members:[]});for(const t of r)l.push({pos:t,pt:i});n&&f.set(i,n)}const d=(t,e)=>{const n=c(t,e),i=h.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of l)sh(t.pos,n)<=r&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)sh(u[t].pos,n)<=r&&!o.includes(t)&&o.push(t);let s=o.find(t=>t!==i)??-1;s<0&&(s=u.length,u.push({pos:n,members:[]})),u[s].members.push({seg:t,end:e}),h.set(`${t}:${e}`,s)};for(let t=0;t<o;t++)d(t,"start"),d(t,"end");const p=new Set,g=new Set,y=new Set;{const t=t=>{let e=-1,r=1/0;for(let n=0;n<u.length;n++){const i=sh(u[n].pos,t);i<r&&(r=i,e=n)}for(const n of l){const i=sh(n.pos,t);i<r&&(r=i,e=n.pt)}return{pt:e,d:r}};for(const r of e){const{pt:e,d:n}=t(r.pos);e>=0&&n<=i&&(p.add(e),("source"===r.kind?g:y).add(e))}}for(const[t,e]of f)p.add(t),("source"===e?g:y).add(t);const m=(t,e)=>"end"===e!==s[t],b=[],x=(e,r)=>{if(void 0===s[e])return s[e]=r,void b.push(e);s[e]!==r&&a.add(t[e].id)},v=t=>{for(const e of["start","end"]){const r=h.get(`${t}:${e}`);if(void 0===r)continue;const n=u[r];if(2!==n.members.length||p.has(r))continue;const i=n.members[0],o=i.seg===t&&i.end===e?n.members[1]:i;if(o.seg===t)continue;const a="end"===e!==s[t],c="end"===o.end!==!a;x(o.seg,c)}},_=()=>{for(;b.length;)v(b.shift())},w=t=>{let e=-1,r="start",n=1/0;for(let i=0;i<o;i++)for(const o of["start","end"]){const s=sh(c(i,o),t.pos);s<n&&(n=s,e=i,r=o)}if(e<0||n>i)return;const s="source"===t.kind?"end"===r:"start"===r;x(e,s)};for(const t of e)"source"===t.kind&&w(t);_();for(const t of e)"sink"===t.kind&&w(t);_();let k=!0;for(;k;){k=!1;for(const t of u){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===s[t.seg]);if(1!==e.length)continue;let r=0,n=0;for(const e of t.members)void 0!==s[e.seg]&&(m(e.seg,e.end)?r++:n++);const i=e[0];let o;0===n&&r>0?o="end"===i.end:0===r&&n>0&&(o="start"===i.end),void 0!==o&&(s[i.seg]=o,b.push(i.seg),_(),k=!0)}}if(s.some(t=>void 0===t)&&g.size>0&&y.size>0){const t=t=>{const e=new Array(u.length).fill(1/0),r=[];for(const n of t)e[n]=0,r.push(n);for(;r.length;){const t=r.shift();for(const n of u[t].members){const i=h.get(`${n.seg}:${"start"===n.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,r.push(i))}}return e},e=t(g),r=t(y);for(let t=0;t<o;t++){if(void 0!==s[t])continue;const n=h.get(`${t}:start`),i=h.get(`${t}:end`);if(void 0===n||void 0===i)continue;if(u[n].members.length<2||u[i].members.length<2)continue;if(e[n]===1/0||e[i]===1/0||r[n]===1/0||r[i]===1/0)continue;let o;e[n]!==e[i]?o=e[n]<e[i]:r[n]!==r[i]&&(o=r[i]<r[n]),void 0!==o&&(s[t]=!o,b.push(t))}_()}const M=new Map;for(let e=0;e<o;e++)M.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function ch(...t){}function uh(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function hh(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*lh(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*lh(t)}function fh(t,e,r){const n=e.width??0,i=e.height??0;if(n<=0||i<=0)return!1;const o=(e.left??0)+n/2,s=(e.top??0)+i/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-o,u=t.z-s,h=Math.cos(-a),l=Math.sin(-a),f=c*h-u*l,d=c*l+u*h;return Math.abs(f)<=n/2+r&&Math.abs(d)<=i/2+r}function dh(t){const e=[],r=[],n=[],i=[];for(const o of lh(t)){const t=hh(o);if(!t)continue;if(o.flowOrientable){const r=Ru(o.state??{});r&&e.push({id:t,start:r.start,end:r.end});continue}if("function"==typeof o.openings){const t=o.state??{};(t.width??0)>0&&(t.height??0)>0&&i.push(t);continue}let s;try{s=o.getSegmentTopology()}catch{continue}if(!s)continue;const a=s.inbounds??[],c=s.outbounds??[],u="function"==typeof o.routingDestination;if(0===a.length&&c.length>0)for(const t of c)r.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||u))for(const t of a)r.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&&n.push({positions:t})}}for(const t of i){const i=[];for(const r of e)for(const e of[r.start,r.end])fh(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of r)fh(e.pos,t,16)&&("sink"===e.kind?o=!0:s=!0);const a=o&&!s?"sink":s&&!o?"source":void 0;(i.length>=2||a&&i.length>=1)&&n.push({positions:i,kind:a})}if(0===e.length||0===r.length)return e.length,r.length,new Map;const o=ah(e,r,8,n,60).directions;return e.length,r.length,n.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function ph(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let r=e.__flowOrientation;if(!r){e.__flowComputing=!0;try{r={map:dh(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=r}const n=hh(t),i=n?r.map.get(n):void 0;return"reverse"===i||"forward"!==i&&void 0}function gh(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function yh(t,e,r,n){if(!t||!e)return null;const i=[],o=t=>{if(!t||t===n)return;if(function(t,e){const r=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(r)&&r.includes(e)}(t,e)&&gh(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}(t);e&&i.push({id:e,component:t,distance:t.distanceToBoardPoint(r.x,r.y)})}const s=t.components;if(Array.isArray(s))for(const t of s)o(t)};return o(t),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function mh(t){return!!t&&"function"==typeof t.routingDestination}function bh(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*xh(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*xh(t)}function vh(t){const e=[],r=new Map,n=new Map,i=new Set,o=[];for(const s of xh(t)){"function"==typeof s?.registerWithHost&&o.push(s);const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks?s.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||mh(s)||c||gh(s)))continue;const u=bh(s);if(!u)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=s.getSegmentTopology()}catch{continue}if(!h)continue}const l=s.state??{},f={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation};if(e.push({id:u,topology:h,bounds:f,links:a}),n.set(u,s),mh(s)){i.add(u);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=r.get(t)??[];e.push(u),r.set(t,e)}}}return{nodes:e,destToSinks:r,components:n,routingTargetIds:i,stationClients:o}}function _h(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:r,destToSinks:n,components:i,routingTargetIds:o,stationClients:s}=vh(t),a=Uu(r);!function(t,e){if(!t)return;const r=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)r(t)};r(t);const n=[...e].sort((t,e)=>{const r=bh(t)??"",n=bh(e)??"";return r.localeCompare(n)});for(const e of n){const r=e.declaredHostRef?.();let n=null;if(r&&(n=t.findById?.(r)??null),!n){const r=e.hostCapability?.(),i=e.hostFacingPoint?.();r&&i&&(n=yh(t,r,i,e)?.component??null)}n&&"function"==typeof e.registerWithHost&&e.registerWithHost(n)}const i=e=>{if(!e)return;if(gh(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const r of e.resolveDownstream()){const n=t.findById?.(r);n&&e.registerDivertStation(r,n)}const r=e.components;if(Array.isArray(r))for(const t of r)i(t)};i(t)}(t,s);const c=new Set;for(const[t,e]of i){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const u=new Map;for(const t of o){const e=i.get(t);if("function"==typeof e?.routingWeight){const r=e.routingWeight();"number"==typeof r&&(!Number.isFinite(r)||r<=0)&&u.set(t,r)}}const h=Qu(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:n,components:i,issues:h},t.__flowGraph=e}return e}function wh(t){return _h(t)?.issues??[]}function kh(t){const e=_h(t);return e&&e.graph.nodes.size>0?e.graph:null}function Mh(t,e){return _h(t)?.destToSinks.get(e)??[]}function Sh(t,e){return _h(t)?.components.get(e)}function Eh(t){const e=_h(t);return e?[...e.destToSinks.keys()]:[]}function zh(t){return bh(t)}function Ah(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,r=t?.state?.capacity;return"number"==typeof r&&r>0?e/r:e}function Th(t,e,r,n,i){if(1===n.length)return n[0];switch(t){case"index":default:return n[0];case"round-robin":{const t=r.counters.get(e)??0;return r.counters.set(e,t+1),n[t%n.length]}case"weight":{const t=n.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}(i.get(t.target))),o=t.reduce((t,e)=>t+e,0);if(o<=0)return n[0];const s=r.counters.get(e)??0;r.counters.set(e,s+1);let a=s%o;for(let e=0;e<n.length;e++){if(a<t[e])return n[e];a-=t[e]}return n[n.length-1]}case"utilization":{let t=1/0,e=n[0];for(const r of n){const n=Ah(i.get(r.target));n<t&&(t=n,e=r)}return e}}}function Oh(t,e,r){const n=t?.root;if(!n)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const o=_h(n);if(!o||0===o.graph.nodes.size)return null;const s=bh(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=Zu(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],h=c.filter(t=>{const r=u[t.index],n=r?o.components.get(r):null;return!n||"function"!=typeof n.canReceive||n.canReceive(e)});if(0===h.length)return u[c[0].index]??null;const l=r?.policy??function(t,e){const r=t?.state?.balancingPolicy;if(r)return r;const n=e?.state?.routingBalancingPolicy;return n||"round-robin"}(t,n),f=Th(l,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(n),h,o.components);return u[f.index]??null}r({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"}),r({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,kh(t)}catch{return null}}}catch{}function Ih(t,e,r){const n=Oh(t,e,r);if(null==n)return null;const i=t?.root,o=Sh(i,n)??i?.findById?.(n)??null;return o?{targetId:n,component:o,origin:"explicit"}:null}function jh(t){const e=t?.root,r=kh(e),n=zh(t);if(!r||!n)return null;const i=(r.out.get(n)??[]).find(Boolean);if(!i)return null;const o=Sh(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Ph(t){const e=zh(t);return e?Rh(t?.root,e):[]}function Rh(t,e){if(!t||!e)return[];const r=kh(t);if(!r)return[];const n=new Set;for(const i of Xu(r,e)){const e=Sh(t,i);if(mh(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&n.add(t)}}return[...n]}function Ch(t,e){if(!t||!e)return[];const r=kh(t);if(!r)return[];const n=new Map;for(const t of r.out.values())for(const e of t)null!=e&&n.set(e,(n.get(e)??0)+1);const i=new Map;for(const o of Xu(r,e)){const e=Sh(t,o);if(!mh(e))continue;const r=e.routingDestination();if("string"!=typeof r||0===r.length)continue;let s=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(s=t)}null===s&&(s=n.get(o)??0,0===s&&(s=1)),i.set(r,(i.get(r)??0)+s)}return[...i].map(([t,e])=>({value:t,weight:e}))}function Nh(t){return kh(t)}function Fh(t){const e=kh(t);if(!e)return[];const r=new Set,n=new Set,i=t=>{if(!t)return;const o=zh(t);if(o&&e.nodes.has(o)){mh(t)&&r.add(o);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&n.add(o)}const s=t.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),Qu(e,{routingTargetIds:r,loopCapableIds:n})}function Dh(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 r=Math.random()*e;let n=0;for(const e of t)if(n+=e.weight,r<n)return e.value;return t[t.length-1].value}const Lh={next:Ih,downstream:jh,reachableDestinations:Ph,reachableDestinationsFrom:Rh,reachableDestinationsWeightedFrom:Ch,pickWeightedDestination:Dh,graphFor:Nh,validate:Fh};function Yh(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,r){const n=t.prototype?.attachPointFor;return"function"==typeof n?n.call(this,e,r):null}addItem(t,e){if(!t||this.containsItem(t))return;const r=t.parent;if(r&&"function"==typeof r.removeItem&&r!==this&&r.removeItem(t,!0),this._items.push(t),t.parent=this,!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 r=this._items.indexOf(t);if(-1!==r&&(this._items.splice(r,1),t.parent=null,t._realObject?.setTransientDisplayScale?.(1),!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,r)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const r=t.parent;r&&("function"==typeof r.removeComponent&&-1!==r._components?.indexOf?.(t)&&r.removeComponent(t,!0),r!==this&&"function"==typeof r.removeItem&&-1!==r._items?.indexOf?.(t)&&r.removeItem(t,!0));const n=-1===this._items.indexOf(t);if(n&&this._items.push(t),t.parent=this,n&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}this.seatHeldItem(t,{toParent3D:e?.toParent3D,slotId:e?.slotId}),t.held?.(this),this._bumpReceived?.(t)}seatHeldItem(t,e={}){t.realObject;const r=t._realObject,n=r?.object3d;if(n){let i,o,s=e.toParent3D,a="world-preserve",c=1;if(!s){const r=this.attachPointFor?.(t,{slotId:e.slotId});r?.attach&&(s=r.attach,i=r.localPosition,o=r.localRotation,a=r.carryPolicy??"world-preserve",c=r.displayScale??1)}s&&n.parent!==s&&(s.updateWorldMatrix?.(!0,!1),n.updateWorldMatrix?.(!0,!1),s.attach(n),r.suppressTransform=!0),s&&(i&&n.position.set(i.x,i.y,i.z),"world-preserve"!==a?o?n.rotation.set(o.x,o.y,o.z):n.quaternion.identity():o&&n.rotation.set(o.x,o.y,o.z),r?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),r?.setTransientDisplayScale?.(c))}}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t)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,r,n,i){for(let o=this._items.length-1;o>=0;o--){const s=this._items[o],a="static"===s.position?s.capture?.(t,e,i):s.capture?.(r,n,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const r=this._items;if(!r||0===r.length)return;t.save();const n=e.bounds;!e.showOverflow&&n&&(t.beginPath(),t.rect(n.left,n.top,n.width,n.height),t.clip(),t.closePath());const{left:i=0,top:o=0}=e.state??{};t.translate(i,o),this._drawItems(t),t.translate(-i,-o),t.restore()}capture(t,e,r){const n=this,i=this._items;if(i&&i.length>0&&(!n.app||n.app.isEditMode||!n.hidden)){const i=n.fromParent?.(t,e);if(i&&n.contains?.(i.x,i.y)){const o=n.bounds,s=this._captureItems(i.x-o.left,i.y-o.top,t,e,r);if(s)return s}}return super.capture?.(t,e,r)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function $h(t){var e;const r=!!t.__hasCapacity,n=!!t.__hasTransferable,i=r?t:Iu(t),o=n?i:function(t){var e;return(e=class extends t{reserve(t,e){const r=this.findSlot(t);return r?{slot:r,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){K.log({role:"target",contract:"receive:enter",component:this,args:{carrier:$(t),options:e}});const r=this.reserve(t,e);if(!r){K.log({role:"target",contract:"receive:reject",component:this,args:{carrier:$(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(r,t,e)}commit(t,e,r={}){const n=t.slot,i=this._countOccupied(n.id),o=this.arrangementStrategy.positionAt(i,n,i,e);K.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:i,slotId:n.id,occupantCount:i,carrier:$(e)},result:o}),e[q]=n.id;const s=e._realObject;let a,c;s?.object3d&&(s.object3d.updateWorldMatrix(!0,!1),a=new k,c=new w,s.object3d.getWorldPosition(a),s.object3d.getWorldQuaternion(c));const{animated:u=!1,duration:h,ease:l}=r;"function"==typeof this.handoverIn?this.handoverIn(e,{slotId:n.id}):this.reparent?.(e,{animated:u,duration:h,ease:l}),!u&&e._realObject&&(e._realObject.suppressTransform=!1);{const t={},r=this.placementFor?.(e,{slot:n,index:i,occupantCount:i})??null;if(K.log({role:"target",contract:"placementFor",component:this,args:{carrier:$(e),slotId:n.id,index:i},result:r}),r){const i=e.state??{},o=this.state??{};t.left=r.position.x-(Number(i.width)||0)/2+(Number(o.width)||0)/2,t.top=r.position.z-(Number(i.height)||0)/2+(Number(o.height)||0)/2;const s=this._zPosFromSeatY(r.position.y,i.depth,n);null!==s&&(t.zPos=s),r.rotation&&W(t,r.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(n.localPosition&&Number.isFinite(n.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=n.localPosition.z+e}const r=this.acceptanceRotation?.(e,n);K.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:$(e),slotId:n.id},result:r}),r&&W(t,r)}const s=this.normalizePose?.(e,n);"function"==typeof this.normalizePose&&K.log({role:"target",contract:"normalizePose",component:this,args:{carrier:$(e),slotId:n.id},result:s}),s&&Object.assign(t,s),Object.keys(t).length&&(e.setState?.(t),K.log({role:"target",contract:"receive:setState",component:this,args:{carrier:$(e),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:n.id,preReceiveWorldPos:a,preReceiveWorldQuat:c}),K.log({role:"target",contract:"receive:done",component:this,args:{carrier:$(e),slotId:n.id}})}async dispatch(t,e,r={}){const n=new nt({source:this,target:e,carrier:t,options:r,physical:async()=>{delete t[q]}}),i=await n.execute();"rolled-back"!==i.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:i.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){const e=(()=>{const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const r=this.findSlot(t);if(!r){const r=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!r||t.allowedTypes.includes(r))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:r}})();return K.log({role:"target",contract:"canAccept",component:this,args:{carrier:$(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}(i),s=[...t.capabilities??[]];r||s.push("Capacity","PlacementSurface"),n||s.push("Transferable"),s.push("Holdable","FlowNode");var a,c,u;return Qc((e=class extends(Yh(o)){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 r=this.state?.rejected??0;this.setState?.({rejected:r+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:u?"".concat(u," ",c):c}),e.capabilities=Object.freeze(s),e.isFlowNode=!0,e))}function Uh(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,r({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"}),r({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"}),r({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{yt as BULGE_EPSILON,Iu as Capacity,It as CapacityEventTracker,Pt as CenteringQueueStrategy,g as CenteringSlotStrategy,mu as DEFAULT_SEAT_MARGIN,d as FixedSlotStrategy,Lh as FlowEngine,$h as FlowNode,Nt as GridStacking,Kc as HOLDER_ANCHOR,Yh as Holdable,Qc as ItemsDataBinding,ht as NavGraph,Ct as PatternStacking,Et as PolygonPathPolyline,ct as ReservationTable,q as TRANSFER_SLOT_KEY,nt as Transfer,Ft as VolumeStacking,du as addressOfSlotId,Eh as allDestinations,Fu as anchorsConnect,Th as applyPolicy,W as applySeatingRotation,Dt as applyStackLayout,Cu as arcSegmentTopology,jt as autoWireBackPressure,Uu as buildFlowGraph,dt as buildNavGraph,vt as bulgeFromDrag,xt as bulgeHandlePosition,Hu as canReach,t as capability,f as chooseNearestPickupFrame,Ju as collectAdjacentSegments,Sh as componentForNode,bt as computeArcParams,dh as computeFlowMap,Rt as computeStackPositions,wt as cornerHandlePosition,kt as cornerRadiusFromDrag,Yu as deliversInto,jh as downstream,_t as effectiveCornerRadius,rh as enumerateDataScenarios,l as filterByToolType,yh as findNearestWithCapability,p as fixedSlotStrategy,zt as flattenPolygonPath,kh as flowGraphFor,wh as flowGraphIssues,ph as flowReverseFor,Lt as footprint2D,X as frameClock,uh as ftId,ch as ftrace,i as getAllCapabilityMeta,n as getCapabilityMeta,B as globalSimClock,Nh as graphFor,uu as gridCellOf,cu as gridSlotNo,mt as hasArc,Tt as hasCapacity,Ot as inferCapacity,Ku as inferDownstreamId,ah as inferFlowDirections,Uh as isFlowNode,gh as isGeometricHost,mh as isRoutingTarget,zu as judgeItemFit,Jc as layoutIssue,$u as matchOutbounds,Ih as next,Gu as nextHop,Bu as nextHops,Vu as nextHopsToAny,Zu as nextHopsToAnyDetailed,zh as nodeIdOf,ou as persistenceIssues,Dh as pickWeightedDestination,pt as planPathAStar,gt as planToReservations,Du as pointInRotatedRect,At as polygonPathLength,s as quatFromYaw,Lu as rayAbsDistanceToRect,Wu as reachableByOutbound,Ph as reachableDestinations,Rh as reachableDestinationsFrom,Ch as reachableDestinationsWeightedFrom,Xu as reachableSinks,et as receiptToJSON,ju as rectFaceAnchors,u as rectangularFootprintFrames,r as registerCapabilityMeta,ut as reservationTable,oo as resolveLegend,ao as resolveLegendEntries,Oh as resolveNextHop,lu as resolveSlot,xu as rotatedFootprint,vu as seatInSlot,_u as seatTransform,Mh as sinksForDestination,pu as slotAddresses,su as slotCount,yu as slotFrame,fu as slotIdOf,au as slotNumbers,Eu as slotSpaceWarnings,wu as stackSeatTransforms,at as standardYieldPolicy,Ru as straightSegmentEndpoints,Nu as straightSegmentMultiInbound,Pu as straightSegmentTopology,h as topApproachFrame,it as transferLog,K as transferTracer,Mt as uniformZ,Fh as validate,Qu as validateFlowGraph,iu as validateSlotLayout};
|
|
6
|
+
*/const g=1e3,y=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 r=t[0];r&&r.isStackTrace?console.warn(r.getError(e)):console.warn(e,...t)}}function T(...t){const e="THREE."+(t=A(t)).shift();{const r=t[0];r&&r.isStackTrace?console.error(r.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 r=this._listeners;void 0===r[t]&&(r[t]=[]),-1===r[t].indexOf(e)&&r[t].push(e)}hasEventListener(t,e){const r=this._listeners;return void 0!==r&&(void 0!==r[t]&&-1!==r[t].indexOf(e))}removeEventListener(t,e){const r=this._listeners;if(void 0===r)return;const n=r[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const r=e[t.type];if(void 0!==r){t.target=this;const e=r.slice(0);for(let r=0,n=e.length;r<n;r++)e[r].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 P(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=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&r|128]+E[r>>8&255]+"-"+E[r>>16&255]+E[r>>24&255]+E[255&n]+E[n>>8&255]+E[n>>16&255]+E[n>>24&255]).toLowerCase()}function j(t,e,r){return Math.max(e,Math.min(r,t))}function C(t,e,r){return(1-r)*t+r*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,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[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=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(j(r,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 r=this.dot(t)/e;return Math.acos(j(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,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 r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,s=this.y-t.y;return this.x=i*r-s*n+t.x,this.y=i*n+s*r+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,r=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=n}static slerpFlat(t,e,r,n,i,s,o){let a=r[n+0],c=r[n+1],h=r[n+2],l=r[n+3],u=i[s+0],d=i[s+1],p=i[s+2],f=i[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 r=Math.acos(t),n=Math.sin(r);e=Math.sin(e*r)/n,a=a*e+u*(o=Math.sin(o*r)/n),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,r,n,i,s){const o=r[n],a=r[n+1],c=r[n+2],h=r[n+3],l=i[s],u=i[s+1],d=i[s+2],p=i[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,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,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 r=t._x,n=t._y,i=t._z,s=t._order,o=Math.cos,a=Math.sin,c=o(r/2),h=o(n/2),l=o(i/2),u=a(r/2),d=a(n/2),p=a(i/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 r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],n=e[4],i=e[8],s=e[1],o=e[5],a=e[9],c=e[2],h=e[6],l=e[10],u=r+o+l;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-a)*t,this._y=(i-c)*t,this._z=(s-n)*t}else if(r>o&&r>l){const t=2*Math.sqrt(1+r-o-l);this._w=(h-a)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(i+c)/t}else if(o>l){const t=2*Math.sqrt(1+o-r-l);this._w=(i-c)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(a+h)/t}else{const t=2*Math.sqrt(1+l-r-o);this._w=(s-n)/t,this._x=(i+c)/t,this._y=(a+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(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=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(j(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(0===r)return this;const n=Math.min(1,e/r);return this.slerp(t,n),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 r=t._x,n=t._y,i=t._z,s=t._w,o=e._x,a=e._y,c=e._z,h=e._w;return this._x=r*h+s*o+n*c-i*a,this._y=n*h+s*a+i*o-r*c,this._z=i*h+s*c+r*a-n*o,this._w=s*h-r*o-n*a-i*c,this._onChangeCallback(),this}slerp(t,e){let r=t._x,n=t._y,i=t._z,s=t._w,o=this.dot(t);o<0&&(r=-r,n=-n,i=-i,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+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+s*e,this._onChangeCallback()}else this._x=this._x*a+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+s*e,this.normalize();return this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),n=Math.sqrt(1-r),i=Math.sqrt(r);return this.set(n*Math.sin(t),n*Math.cos(t),i*Math.sin(e),i*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,r=0){this.x=t,this.y=e,this.z=r}set(t,e,r){return void 0===r&&(r=this.z),this.x=t,this.y=e,this.z=r,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,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=t.elements,s=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*s,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*s,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*s,this}applyQuaternion(t){const e=this.x,r=this.y,n=this.z,i=t.x,s=t.y,o=t.z,a=t.w,c=2*(s*n-o*r),h=2*(o*e-i*n),l=2*(i*r-s*e);return this.x=e+a*c+s*l-o*h,this.y=r+a*h+o*c-i*l,this.z=n+a*l+i*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,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,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=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this.z=j(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this.z=j(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(j(r,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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,n=t.y,i=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*s-r*a,this.z=r*o-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}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 r=this.dot(t)/e;return Math.acos(j(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}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,r){const n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,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(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,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,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const B=new L,U=new N;class Y{static{Y.prototype.isMatrix3=!0}constructor(t,e,r,n,i,s,o,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,r,n,i,s,o,a,c)}set(t,e,r,n,i,s,o,a,c){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=i,h[5]=a,h[6]=r,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,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.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 r=t.elements,n=e.elements,i=this.elements,s=r[0],o=r[3],a=r[6],c=r[1],h=r[4],l=r[7],u=r[2],d=r[5],p=r[8],f=n[0],m=n[3],g=n[6],y=n[1],b=n[4],x=n[7],v=n[2],w=n[5],_=n[8];return i[0]=s*f+o*y+a*v,i[3]=s*m+o*b+a*w,i[6]=s*g+o*x+a*_,i[1]=c*f+h*y+l*v,i[4]=c*m+h*b+l*w,i[7]=c*g+h*x+l*_,i[2]=u*f+d*y+p*v,i[5]=u*m+d*b+p*w,i[8]=u*g+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],r=t[1],n=t[2],i=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return e*s*h-e*o*c-r*i*h+r*o*a+n*i*c-n*s*a}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=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*i,d=c*i-s*a,p=e*l+r*u+n*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]=(n*c-h*r)*f,t[2]=(o*r-n*s)*f,t[3]=u*f,t[4]=(h*e-n*a)*f,t[5]=(n*i-o*e)*f,t[6]=d*f,t[7]=(r*a-c*e)*f,t[8]=(s*e-r*i)*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,r,n,i,s,o){const a=Math.cos(i),c=Math.sin(i);return this.set(r*a,r*c,-r*(a*s+c*o)+s+t,-n*c,n*a,-n*(-c*s+a*o)+o+e,0,0,1),this}scale(t,e){return I("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(W.makeScale(t,e)),this}rotate(t){return I("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(W.makeRotation(-t)),this}translate(t,e){return I("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(W.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),r=Math.sin(t);return this.set(e,-r,0,r,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,r=t.elements;for(let t=0;t<9;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const W=new Y,q=(new Y).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$=(new Y).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function V(){const t={enabled:!0,workingColorSpace:x,spaces:{},convert:function(t,e,r){return!1!==this.enabled&&e!==r&&e&&r?(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[r].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].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,r){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,r){return I("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,r)},toWorkingColorSpace:function(e,r){return I("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,r)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],n=[.3127,.329];return t.define({[x]:{primaries:e,whitePoint:n,transfer:v,toXYZ:q,fromXYZ:$,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:b},outputColorSpaceConfig:{drawingBufferColorSpace:b}},[b]:{primaries:e,whitePoint:n,transfer:w,toXYZ:q,fromXYZ:$,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:b}}}),t}const H=V();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 r;if(t instanceof HTMLCanvasElement)r=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),r=Z}return r.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 r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);const n=r.getImageData(0,0,t.width,t.height),i=n.data;for(let t=0;t<i.length;t++)i[t]=255*G(i[t]/255);return r.putImageData(n,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=P(),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 r={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,r=n.length;e<r;e++)n[e].isDataTexture?t.push(tt(n[e].image)):t.push(tt(n[e]))}else t=tt(n);r.url=t}return e||(t.images[this.uuid]=r),r}}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 rt=new L;class nt extends O{constructor(t=nt.DEFAULT_IMAGE,e=nt.DEFAULT_MAPPING,r=1001,n=1001,i=1006,s=1008,o=1023,a=1009,c=nt.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:et++}),this.uuid=P(),this.name="",this.source=new K(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=r,this.wrapT=n,this.magFilter=i,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 Y,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(rt).x}get height(){return this.source.getSize(rt).y}get depth(){return this.source.getSize(rt).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 r=t[e];if(void 0===r){z(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&r&&n.isVector2&&r.isVector2||n&&r&&n.isVector3&&r.isVector3||n&&r&&n.isMatrix3&&r.isMatrix3?n.copy(r):this[e]=r: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 r={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&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}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 g:t.x=t.x-Math.floor(t.x);break;case y: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 g:t.y=t.y-Math.floor(t.y);break;case y: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++}}nt.DEFAULT_IMAGE=null,nt.DEFAULT_MAPPING=300,nt.DEFAULT_ANISOTROPY=1;class it{static{it.prototype.isVector4=!0}constructor(t=0,e=0,r=0,n=1){this.x=t,this.y=e,this.z=r,this.w=n}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,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,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,r=this.y,n=this.z,i=this.w,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*n+s[12]*i,this.y=s[1]*e+s[5]*r+s[9]*n+s[13]*i,this.z=s[2]*e+s[6]*r+s[10]*n+s[14]*i,this.w=s[3]*e+s[7]*r+s[11]*n+s[15]*i,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,r,n,i;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],g=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+g-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(d+1)/2,y=(g+1)/2,b=(h+u)/4,x=(l+f)/4,v=(p+m)/4;return t>a&&t>y?t<s?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(t),n=b/r,i=x/r):a>y?a<s?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(a),r=b/n,i=v/n):y<s?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(y),r=x/i,n=v/i),this.set(r,n,i,e),this}let y=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-h)*(u-h));return Math.abs(y)<.001&&(y=1),this.x=(m-p)/y,this.y=(l-f)/y,this.z=(u-h)/y,this.w=Math.acos((c+d+g-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=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this.z=j(this.z,t.z,e.z),this.w=j(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this.z=j(this.z,t,e),this.w=j(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(j(r,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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,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,r,n,i,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,r,n,i,s,o,a,c,h,l,u,d,p,f,m)}set(t,e,r,n,i,s,o,a,c,h,l,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=s,g[9]=o,g[13]=a,g[2]=c,g[6]=h,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[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,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[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,r){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),r.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,r=t.elements,n=1/ot.setFromMatrixColumn(t,0).length(),i=1/ot.setFromMatrixColumn(t,1).length(),s=1/ot.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*s,e[9]=r[9]*s,e[10]=r[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,n=t.y,i=t.z,s=Math.cos(r),o=Math.sin(r),a=Math.cos(n),c=Math.sin(n),h=Math.cos(i),l=Math.sin(i);if("XYZ"===t.order){const t=s*h,r=s*l,n=o*h,i=o*l;e[0]=a*h,e[4]=-a*l,e[8]=c,e[1]=r+n*c,e[5]=t-i*c,e[9]=-o*a,e[2]=i-t*c,e[6]=n+r*c,e[10]=s*a}else if("YXZ"===t.order){const t=a*h,r=a*l,n=c*h,i=c*l;e[0]=t+i*o,e[4]=n*o-r,e[8]=s*c,e[1]=s*l,e[5]=s*h,e[9]=-o,e[2]=r*o-n,e[6]=i+t*o,e[10]=s*a}else if("ZXY"===t.order){const t=a*h,r=a*l,n=c*h,i=c*l;e[0]=t-i*o,e[4]=-s*l,e[8]=n+r*o,e[1]=r+n*o,e[5]=s*h,e[9]=i-t*o,e[2]=-s*c,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){const t=s*h,r=s*l,n=o*h,i=o*l;e[0]=a*h,e[4]=n*c-r,e[8]=t*c+i,e[1]=a*l,e[5]=i*c+t,e[9]=r*c-n,e[2]=-c,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){const t=s*a,r=s*c,n=o*a,i=o*c;e[0]=a*h,e[4]=i-t*l,e[8]=n*l+r,e[1]=l,e[5]=s*h,e[9]=-o*h,e[2]=-c*h,e[6]=r*l+n,e[10]=t-i*l}else if("XZY"===t.order){const t=s*a,r=s*c,n=o*a,i=o*c;e[0]=a*h,e[4]=-l,e[8]=c*h,e[1]=t*l+i,e[5]=s*h,e[9]=r*l-n,e[2]=n*l-r,e[6]=o*h,e[10]=i*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,r){const n=this.elements;return dt.subVectors(t,e),0===dt.lengthSq()&&(dt.z=1),dt.normalize(),lt.crossVectors(r,dt),0===lt.lengthSq()&&(1===Math.abs(r.z)?dt.x+=1e-4:dt.z+=1e-4,dt.normalize(),lt.crossVectors(r,dt)),lt.normalize(),ut.crossVectors(dt,lt),n[0]=lt.x,n[4]=ut.x,n[8]=dt.x,n[1]=lt.y,n[5]=ut.y,n[9]=dt.y,n[2]=lt.z,n[6]=ut.z,n[10]=dt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,s=r[0],o=r[4],a=r[8],c=r[12],h=r[1],l=r[5],u=r[9],d=r[13],p=r[2],f=r[6],m=r[10],g=r[14],y=r[3],b=r[7],x=r[11],v=r[15],w=n[0],_=n[4],M=n[8],S=n[12],k=n[1],A=n[5],z=n[9],T=n[13],I=n[2],O=n[6],E=n[10],P=n[14],j=n[3],C=n[7],R=n[11],F=n[15];return i[0]=s*w+o*k+a*I+c*j,i[4]=s*_+o*A+a*O+c*C,i[8]=s*M+o*z+a*E+c*R,i[12]=s*S+o*T+a*P+c*F,i[1]=h*w+l*k+u*I+d*j,i[5]=h*_+l*A+u*O+d*C,i[9]=h*M+l*z+u*E+d*R,i[13]=h*S+l*T+u*P+d*F,i[2]=p*w+f*k+m*I+g*j,i[6]=p*_+f*A+m*O+g*C,i[10]=p*M+f*z+m*E+g*R,i[14]=p*S+f*T+m*P+g*F,i[3]=y*w+b*k+x*I+v*j,i[7]=y*_+b*A+x*O+v*C,i[11]=y*M+b*z+x*E+v*R,i[15]=y*S+b*T+x*P+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],r=t[4],n=t[8],i=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],g=t[15],y=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*y-m*b+g*x)-r*(p*y-m*v+g*w)+n*(p*b-f*v+g*_)-i*(p*x-f*w+m*_)}determinantAffine(){const t=this.elements,e=t[0],r=t[4],n=t[8],i=t[1],s=t[5],o=t[9],a=t[2],c=t[6],h=t[10];return e*(s*h-o*c)-r*(i*h-o*a)+n*(i*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,r){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=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],g=t[15],y=e*o-r*s,b=e*a-n*s,x=e*c-i*s,v=r*a-n*o,w=r*c-i*o,_=n*c-i*a,M=h*f-l*p,S=h*m-u*p,k=h*g-d*p,A=l*m-u*f,z=l*g-d*f,T=u*g-d*m,I=y*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]=(n*z-r*T-i*A)*O,t[2]=(f*_-m*w+g*v)*O,t[3]=(u*w-l*_-d*v)*O,t[4]=(a*k-s*T-c*S)*O,t[5]=(e*T-n*k+i*S)*O,t[6]=(m*x-p*_-g*b)*O,t[7]=(h*_-u*x+d*b)*O,t[8]=(s*z-o*k+c*M)*O,t[9]=(r*k-e*z-i*M)*O,t[10]=(p*w-f*x+g*y)*O,t[11]=(l*x-h*w-d*y)*O,t[12]=(o*S-s*A-a*M)*O,t[13]=(e*A-r*S+n*M)*O,t[14]=(f*b-p*v-m*y)*O,t[15]=(h*v-l*b+u*y)*O,this}scale(t){const e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){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,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),n=Math.sin(e),i=1-r,s=t.x,o=t.y,a=t.z,c=i*s,h=i*o;return this.set(c*s+r,c*o-n*a,c*a+n*o,0,c*o+n*a,h*o+r,h*a-n*s,0,c*a-n*o,h*a+n*s,i*a*a+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,i,s){return this.set(1,r,i,0,t,1,s,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){const n=this.elements,i=e._x,s=e._y,o=e._z,a=e._w,c=i+i,h=s+s,l=o+o,u=i*c,d=i*h,p=i*l,f=s*h,m=s*l,g=o*l,y=a*c,b=a*h,x=a*l,v=r.x,w=r.y,_=r.z;return n[0]=(1-(f+g))*v,n[1]=(d+x)*v,n[2]=(p-b)*v,n[3]=0,n[4]=(d-x)*w,n[5]=(1-(u+g))*w,n[6]=(m+y)*w,n[7]=0,n[8]=(p+b)*_,n[9]=(m-y)*_,n[10]=(1-(u+f))*_,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const i=this.determinantAffine();if(0===i)return r.set(1,1,1),e.identity(),this;let s=ot.set(n[0],n[1],n[2]).length();const o=ot.set(n[4],n[5],n[6]).length(),a=ot.set(n[8],n[9],n[10]).length();i<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),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,n,i,s,o=2e3,a=!1){const c=this.elements,h=2*i/(e-t),l=2*i/(r-n),u=(e+t)/(e-t),d=(r+n)/(r-n);let p,f;if(a)p=i/(s-i),f=s*i/(s-i);else if(o===M)p=-(s+i)/(s-i),f=-2*s*i/(s-i);else{if(2001!==o)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);p=-s/(s-i),f=-s*i/(s-i)}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,r,n,i,s,o=2e3,a=!1){const c=this.elements,h=2/(e-t),l=2/(r-n),u=-(e+t)/(e-t),d=-(r+n)/(r-n);let p,f;if(a)p=1/(s-i),f=s/(s-i);else if(o===M)p=-2/(s-i),f=-(s+i)/(s-i);else{if(2001!==o)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);p=-1/(s-i),f=-i/(s-i)}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,r=t.elements;for(let t=0;t<16;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[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,r=0,n=mt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=n}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,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,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,r=!0){const n=t.elements,i=n[0],s=n[4],o=n[8],a=n[1],c=n[5],h=n[9],l=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(j(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-s,i)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-j(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-l,i),this._z=0);break;case"ZXY":this._x=Math.asin(j(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,i));break;case"ZYX":this._y=Math.asin(-j(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(j(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-l,i)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-j(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-h,d),this._y=0);break;default:z("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return pt.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pt,e,r)}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 gt{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 yt=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 Pt extends O{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yt++}),this.uuid=P(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const t=new L,e=new mt,r=new N,n=new L(1,1,1);e._onChange(function(){r.setFromEuler(e,!1)}),r._onChange(function(){e.setFromQuaternion(r,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:r},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new st},normalMatrix:{value:new Y}}),this.matrix=new st,this.matrixWorld=new st,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gt,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,r){t.isVector3?wt.copy(t):wt.set(t,e,r);const n=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),n&&(vt.extractRotation(n.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 r=0,n=this.children.length;r<n;r++){const n=this.children[r].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e,r=[]){this[t]===e&&r.push(this);const n=this.children;for(let i=0,s=n.length;i<s;i++)n[i].getObjectsByProperty(t,e,r);return r}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 r=0,n=e.length;r<n;r++)e[r].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let r=0,n=e.length;r<n;r++)e[r].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,r=t.y,n=t.z,i=this.matrix.elements;i[12]+=e-i[0]*e-i[4]*r-i[8]*n,i[13]+=r-i[1]*e-i[5]*r-i[9]*n,i[14]+=n-i[2]*e-i[6]*r-i[10]*n}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 r=0,n=e.length;r<n;r++){e[r].updateMatrixWorld(t)}}updateWorldMatrix(t,e,r=!1){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0,r)}}}toJSON(t){const e=void 0===t||"string"==typeof t,r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};function i(e,r){return void 0===e[r.uuid]&&(e[r.uuid]=r.toJSON(t)),r.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),!1!==this.static&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),null!==this.pivot&&(n.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(t=>({...t})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(n.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(n.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(n.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=i(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const r=e.shapes;if(Array.isArray(r))for(let e=0,n=r.length;e<n;e++){const n=r[e];i(t.shapes,n)}else i(t.shapes,r)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let r=0,n=this.material.length;r<n;r++)e.push(i(t.materials,this.material[r]));n.material=e}else n.material=i(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const r=this.animations[e];n.animations.push(i(t.animations,r))}}if(e){const e=s(t.geometries),n=s(t.materials),i=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&&(r.geometries=e),n.length>0&&(r.materials=n),i.length>0&&(r.textures=i),o.length>0&&(r.images=o),a.length>0&&(r.shapes=a),c.length>0&&(r.skeletons=c),h.length>0&&(r.animations=h),l.length>0&&(r.nodes=l)}return r.object=n,r;function s(t){const e=[];for(const r in t){const n=t[r];delete n.metadata,e.push(n)}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 r=t.children[e];this.add(r.clone())}return this}}Pt.DEFAULT_UP=new L(0,1,0),Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class jt extends Pt{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,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}class Nt{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(void 0===e&&void 0===r){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,r);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,r,n=H.workingColorSpace){return this.r=t,this.g=e,this.b=r,H.colorSpaceToWorking(this,n),this}setHSL(t,e,r,n=H.workingColorSpace){var i;if(t=(t%(i=1)+i)%i,e=j(e,0,1),r=j(r,0,1),0===e)this.r=this.g=this.b=r;else{const n=r<=.5?r*(1+e):r+e-r*e,i=2*r-n;this.r=Dt(i,n,t+1/3),this.g=Dt(i,n,t),this.b=Dt(i,n,t-1/3)}return H.colorSpaceToWorking(this,n),this}setStyle(t,e=b){function r(e){void 0!==e&&parseFloat(e)<1&&z("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let i;const s=n[1],o=n[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:z("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=n[1],i=r.length;if(3===i)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(6===i)return this.setHex(parseInt(r,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 r=Ct[t.toLowerCase()];return void 0!==r?this.setHex(r,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(j(255*Lt.r,0,255))+256*Math.round(j(255*Lt.g,0,255))+Math.round(j(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 r=Lt.r,n=Lt.g,i=Lt.b,s=Math.max(r,n,i),o=Math.min(r,n,i);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 r:a=(n-i)/t+(n<i?6:0);break;case n:a=(i-r)/t+2;break;case i:a=(r-n)/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,r=Lt.g,n=Lt.b;return t!==b?`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*r)},${Math.round(255*n)})`}offsetHSL(t,e,r){return this.getHSL(Rt),this.setHSL(Rt.h+t,Rt.s+e,Rt.l+r)}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,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(Rt),t.getHSL(Ft);const r=C(Rt.h,Ft.h,e),n=C(Rt.s,Ft.s,e),i=C(Rt.l,Ft.l,e);return this.setHSL(r,n,i),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,r=this.g,n=this.b,i=t.elements;return this.r=i[0]*e+i[3]*r+i[6]*n,this.g=i[1]*e+i[4]*r+i[7]*n,this.b=i[2]*e+i[5]*r+i[8]*n,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,Yt=new L,Wt=new L,qt=new L,$t=new L,Vt=new L,Ht=new L,Gt=new L,Xt=new L,Zt=new it,Jt=new it,Qt=new it;class Kt{constructor(t=new L,e=new L,r=new L){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,n){n.subVectors(r,e),Bt.subVectors(t,e),n.cross(Bt);const i=n.lengthSq();return i>0?n.multiplyScalar(1/Math.sqrt(i)):n.set(0,0,0)}static getBarycoord(t,e,r,n,i){Bt.subVectors(n,e),Ut.subVectors(r,e),Yt.subVectors(t,e);const s=Bt.dot(Bt),o=Bt.dot(Ut),a=Bt.dot(Yt),c=Ut.dot(Ut),h=Ut.dot(Yt),l=s*c-o*o;if(0===l)return i.set(0,0,0),null;const u=1/l,d=(c*a-o*h)*u,p=(s*h-o*a)*u;return i.set(1-d-p,p,d)}static containsPoint(t,e,r,n){return null!==this.getBarycoord(t,e,r,n,Wt)&&(Wt.x>=0&&Wt.y>=0&&Wt.x+Wt.y<=1)}static getInterpolation(t,e,r,n,i,s,o,a){return null===this.getBarycoord(t,e,r,n,Wt)?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(i,Wt.x),a.addScaledVector(s,Wt.y),a.addScaledVector(o,Wt.z),a)}static getInterpolatedAttribute(t,e,r,n,i,s){return Zt.setScalar(0),Jt.setScalar(0),Qt.setScalar(0),Zt.fromBufferAttribute(t,e),Jt.fromBufferAttribute(t,r),Qt.fromBufferAttribute(t,n),s.setScalar(0),s.addScaledVector(Zt,i.x),s.addScaledVector(Jt,i.y),s.addScaledVector(Qt,i.z),s}static isFrontFacing(t,e,r,n){return Bt.subVectors(r,e),Ut.subVectors(t,e),Bt.cross(Ut).dot(n)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,r,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,n),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,r,n,i){return Kt.getInterpolation(t,this.a,this.b,this.c,e,r,n,i)}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 r=this.a,n=this.b,i=this.c;let s,o;qt.subVectors(n,r),$t.subVectors(i,r),Ht.subVectors(t,r);const a=qt.dot(Ht),c=$t.dot(Ht);if(a<=0&&c<=0)return e.copy(r);Gt.subVectors(t,n);const h=qt.dot(Gt),l=$t.dot(Gt);if(h>=0&&l<=h)return e.copy(n);const u=a*l-h*c;if(u<=0&&a>=0&&h<=0)return s=a/(a-h),e.copy(r).addScaledVector(qt,s);Xt.subVectors(t,i);const d=qt.dot(Xt),p=$t.dot(Xt);if(p>=0&&d<=p)return e.copy(i);const f=d*c-a*p;if(f<=0&&c>=0&&p<=0)return o=c/(c-p),e.copy(r).addScaledVector($t,o);const m=h*p-d*l;if(m<=0&&l-h>=0&&d-p>=0)return Vt.subVectors(i,n),o=(l-h)/(l-h+(d-p)),e.copy(n).addScaledVector(Vt,o);const g=1/(m+f+u);return s=f*g,o=u*g,e.copy(r).addScaledVector(qt,s).addScaledVector($t,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,r=t.length;e<r;e+=3)this.expandByPoint(re.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,r=t.count;e<r;e++)this.expandByPoint(re.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const r=re.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),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 r=t.geometry;if(void 0!==r){const n=r.getAttribute("position");if(!0===e&&void 0!==n&&!0!==t.isInstancedMesh)for(let e=0,r=n.count;e<r;e++)!0===t.isMesh?t.getVertexPosition(e,re):re.fromBufferAttribute(n,e),re.applyMatrix4(t.matrixWorld),this.expandByPoint(re);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),ne.copy(t.boundingBox)):(null===r.boundingBox&&r.computeBoundingBox(),ne.copy(r.boundingBox)),ne.applyMatrix4(t.matrixWorld),this.union(ne)}const n=t.children;for(let t=0,r=n.length;t<r;t++)this.expandByObject(n[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,re),re.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(le),ue.subVectors(this.max,le),ie.subVectors(t.a,le),se.subVectors(t.b,le),oe.subVectors(t.c,le),ae.subVectors(se,ie),ce.subVectors(oe,se),he.subVectors(ie,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,ie,se,oe,ue)&&(e=[1,0,0,0,1,0,0,0,1],!!fe(e,ie,se,oe,ue)&&(de.crossVectors(ae,ce),e=[de.x,de.y,de.z],fe(e,ie,se,oe,ue)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,re).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(re).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],re=new L,ne=new te,ie=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,r,n,i){for(let s=0,o=t.length-3;s<=o;s+=3){pe.fromArray(t,s);const o=i.x*Math.abs(pe.x)+i.y*Math.abs(pe.y)+i.z*Math.abs(pe.z),a=e.dot(pe),c=r.dot(pe),h=n.dot(pe);if(Math.max(-Math.max(a,c,h),Math.min(a,c,h))>o)return!1}return!0}const me=new L,ge=new D;let ye=0;class be extends O{constructor(t,e,r=!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:ye++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=r,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,r){t*=this.itemSize,r*=e.itemSize;for(let n=0,i=this.itemSize;n<i;n++)this.array[t+n]=e.array[r+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,r=this.count;e<r;e++)ge.fromBufferAttribute(this,e),ge.applyMatrix3(t),this.setXY(e,ge.x,ge.y);else if(3===this.itemSize)for(let e=0,r=this.count;e<r;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,r=this.count;e<r;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,r=this.count;e<r;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,r=this.count;e<r;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 r=this.array[t*this.itemSize+e];return this.normalized&&(r=R(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=F(r,this.array)),this.array[t*this.itemSize+e]=r,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,r){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),r=F(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,n){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),r=F(r,this.array),n=F(n,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=n,this}setXYZW(t,e,r,n,i){return t*=this.itemSize,this.normalized&&(e=F(e,this.array),r=F(r,this.array),n=F(n,this.array),i=F(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=n,this.array[t+3]=i,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,r){super(new Uint16Array(t),e,r)}}class ve extends be{constructor(t,e,r){super(new Uint32Array(t),e,r)}}class we extends be{constructor(t,e,r){super(new Float32Array(t),e,r)}}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 r=this.center;void 0!==e?r.copy(e):_e.setFromPoints(t).getCenter(r);let n=0;for(let e=0,i=t.length;e<i;e++)n=Math.max(n,r.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),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 r=this.center.distanceToSquared(t);return e.copy(t),r>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),r=.5*(t-this.radius);this.center.addScaledVector(Me,r/t),this.radius+=r}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 Pt,Ie=new L,Oe=new te,Ee=new te,Pe=new L;class je extends O{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ae++}),this.uuid=P(),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,r=0){this.groups.push({start:t,count:e,materialIndex:r})}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 r=this.attributes.normal;if(void 0!==r){const e=(new Y).getNormalMatrix(t);r.applyNormalMatrix(e),r.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.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,r){return ze.makeTranslation(t,e,r),this.applyMatrix4(ze),this}scale(t,e,r){return ze.makeScale(t,e,r),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 r=0,n=t.length;r<n;r++){const n=t[r];e.push(n.x,n.y,n.z||0)}this.setAttribute("position",new we(e,3))}else{const r=Math.min(t.length,e.count);for(let n=0;n<r;n++){const r=t[n];e.setXYZ(n,r.x,r.y,r.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,r=e.length;t<r;t++){const r=e[t];Oe.setFromBufferAttribute(r),this.morphTargetsRelative?(Pe.addVectors(this.boundingBox.min,Oe.min),this.boundingBox.expandByPoint(Pe),Pe.addVectors(this.boundingBox.max,Oe.max),this.boundingBox.expandByPoint(Pe)):(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 r=this.boundingSphere.center;if(Oe.setFromBufferAttribute(t),e)for(let t=0,r=e.length;t<r;t++){const r=e[t];Ee.setFromBufferAttribute(r),this.morphTargetsRelative?(Pe.addVectors(Oe.min,Ee.min),Oe.expandByPoint(Pe),Pe.addVectors(Oe.max,Ee.max),Oe.expandByPoint(Pe)):(Oe.expandByPoint(Ee.min),Oe.expandByPoint(Ee.max))}Oe.getCenter(r);let n=0;for(let e=0,i=t.count;e<i;e++)Pe.fromBufferAttribute(t,e),n=Math.max(n,r.distanceToSquared(Pe));if(e)for(let i=0,s=e.length;i<s;i++){const s=e[i],o=this.morphTargetsRelative;for(let e=0,i=s.count;e<i;e++)Pe.fromBufferAttribute(s,e),o&&(Ie.fromBufferAttribute(t,e),Pe.add(Ie)),n=Math.max(n,r.distanceToSquared(Pe))}this.boundingSphere.radius=Math.sqrt(n),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 r=e.position,n=e.normal,i=e.uv;let s=this.getAttribute("tangent");void 0!==s&&s.count===r.count||(s=new be(new Float32Array(4*r.count),4),this.setAttribute("tangent",s));const o=[],a=[];for(let t=0;t<r.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 g(t,e,n){c.fromBufferAttribute(r,t),h.fromBufferAttribute(r,e),l.fromBufferAttribute(r,n),u.fromBufferAttribute(i,t),d.fromBufferAttribute(i,e),p.fromBufferAttribute(i,n),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[n].add(f),a[t].add(m),a[e].add(m),a[n].add(m))}let y=this.groups;0===y.length&&(y=[{start:0,count:t.count}]);for(let e=0,r=y.length;e<r;++e){const r=y[e],n=r.start;for(let e=n,i=n+r.count;e<i;e+=3)g(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(n,t),w.copy(v);const e=o[t];b.copy(e),b.sub(v.multiplyScalar(v.dot(e))).normalize(),x.crossVectors(w,e);const r=x.dot(a[t])<0?-1:1;s.setXYZW(t,b.x,b.y,b.z,r)}for(let e=0,r=y.length;e<r;++e){const r=y[e],n=r.start;for(let e=n,i=n+r.count;e<i;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 r=this.getAttribute("normal");if(void 0===r||r.count!==e.count)r=new be(new Float32Array(3*e.count),3),this.setAttribute("normal",r);else for(let t=0,e=r.count;t<e;t++)r.setXYZ(t,0,0,0);const n=new L,i=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);n.fromBufferAttribute(e,d),i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,i),l.subVectors(n,i),h.cross(l),o.fromBufferAttribute(r,d),a.fromBufferAttribute(r,p),c.fromBufferAttribute(r,f),o.add(h),a.add(h),c.add(h),r.setXYZ(d,o.x,o.y,o.z),r.setXYZ(p,a.x,a.y,a.z),r.setXYZ(f,c.x,c.y,c.z)}else for(let t=0,o=e.count;t<o;t+=3)n.fromBufferAttribute(e,t+0),i.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,i),l.subVectors(n,i),h.cross(l),r.setXYZ(t+0,h.x,h.y,h.z),r.setXYZ(t+1,h.x,h.y,h.z),r.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)Pe.fromBufferAttribute(t,e),Pe.normalize(),t.setXYZ(e,Pe.x,Pe.y,Pe.z)}toNonIndexed(){function t(t,e){const r=t.array,n=t.itemSize,i=t.normalized,s=new r.constructor(e.length*n);let o=0,a=0;for(let i=0,c=e.length;i<c;i++){o=t.isInterleavedBufferAttribute?e[i]*t.data.stride+t.offset:e[i]*n;for(let t=0;t<n;t++)s[a++]=r[o++]}return new be(s,n,i)}if(null===this.index)return z("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new je,r=this.index.array,n=this.attributes;for(const i in n){const s=t(n[i],r);e.setAttribute(i,s)}const i=this.morphAttributes;for(const n in i){const s=[],o=i[n];for(let e=0,n=o.length;e<n;e++){const n=t(o[e],r);s.push(n)}e.morphAttributes[n]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,r=s.length;t<r;t++){const r=s[t];e.addGroup(r.start,r.count,r.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 r in e)void 0!==e[r]&&(t[r]=e[r]);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 r=this.attributes;for(const e in r){const n=r[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let i=!1;for(const e in this.morphAttributes){const r=this.morphAttributes[e],s=[];for(let e=0,n=r.length;e<n;e++){const n=r[e];s.push(n.toJSON(t.data))}s.length>0&&(n[e]=s,i=!0)}i&&(t.data.morphAttributes=n,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 r=t.index;null!==r&&this.setIndex(r.clone());const n=t.attributes;for(const t in n){const r=n[t];this.setAttribute(t,r.clone(e))}const i=t.morphAttributes;for(const t in i){const r=[],n=i[t];for(let t=0,i=n.length;t<i;t++)r.push(n[t].clone(e));this.morphAttributes[t]=r}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=P(),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 r=t[e];if(void 0===r){z(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(r):n&&n.isVector2&&r&&r.isVector2||n&&n.isEuler&&r&&r.isEuler||n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]=r: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 r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const r in t){const n=t[r];delete n.metadata,e.push(n)}return e}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(r.dispersion=this.dispersion),void 0!==this.iridescence&&(r.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(r.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(r.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapRotation&&(r.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(r.blending=this.blending),0!==this.side&&(r.side=this.side),!0===this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=!0),204!==this.blendSrc&&(r.blendSrc=this.blendSrc),205!==this.blendDst&&(r.blendDst=this.blendDst),100!==this.blendEquation&&(r.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(r.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(r.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(r.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(r.depthFunc=this.depthFunc),!1===this.depthTest&&(r.depthTest=this.depthTest),!1===this.depthWrite&&(r.depthWrite=this.depthWrite),!1===this.colorWrite&&(r.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(r.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(r.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(r.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_&&(r.stencilFail=this.stencilFail),this.stencilZFail!==_&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==_&&(r.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(r.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaHash&&(r.alphaHash=!0),!0===this.alphaToCoverage&&(r.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=!0),!0===this.forceSinglePass&&(r.forceSinglePass=!0),!1===this.allowOverride&&(r.allowOverride=!1),!0===this.wireframe&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=!0),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),!1===this.fog&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData),e){const e=n(t.textures),i=n(t.images);e.length>0&&(r.textures=e),i.length>0&&(r.images=i)}return r}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 r=null;if(null!==e){const t=e.length;r=new Array(t);for(let n=0;n!==t;++n)r[n]=e[n].clone()}return this.clippingPlanes=r,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,Ye=new L;class We{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 r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,r)}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,r,n){De.copy(t).add(e).multiplyScalar(.5),Ne.copy(e).sub(t).normalize(),Le.copy(this.origin).sub(De);const i=.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=i*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=i,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u=-i,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u<=-p?(l=Math.max(0,-(-s*i+o)),u=l>0?-i:Math.min(Math.max(-i,-a),i),d=-l*l+u*(u+2*a)+c):u<=p?(l=0,u=Math.min(Math.max(-i,-a),i),d=u*(u+2*a)+c):(l=Math.max(0,-(s*i+o)),u=l>0?i:Math.min(Math.max(-i,-a),i),d=-l*l+u*(u+2*a)+c);else u=s>0?-i:i,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,l),n&&n.copy(De).addScaledVector(Ne,u),d}intersectSphere(t,e){Fe.subVectors(t.center,this.origin);const r=Fe.dot(this.direction),n=Fe.dot(Fe)-r*r,i=t.radius*t.radius;if(n>i)return null;const s=Math.sqrt(i-n),o=r-s,a=r+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 r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return null===r?null:this.at(r,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 r,n,i,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?(r=(t.min.x-u.x)*c,n=(t.max.x-u.x)*c):(r=(t.max.x-u.x)*c,n=(t.min.x-u.x)*c),h>=0?(i=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(i=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),r>s||i>n?null:((i>r||isNaN(r))&&(r=i),(s<n||isNaN(n))&&(n=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),r>a||o>n?null:((o>r||r!=r)&&(r=o),(a<n||n!=n)&&(n=a),n<0?null:this.at(r>=0?r:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Fe)}intersectTriangle(t,e,r,n,i){Be.subVectors(e,t),Ue.subVectors(r,t),Ye.crossVectors(Be,Ue);let s,o=this.direction.dot(Ye);if(o>0){if(n)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(Ye);return h<0?null:this.at(h/o,i)}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 qe 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 $e=new st,Ve=new We,He=new ke,Ge=new L,Xe=new L,Ze=new L,Je=new L,Qe=new L,Ke=new L,tr=new L,er=new L;class rr extends Pt{constructor(t=new je,e=new qe){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 r=t[e[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=r.length;t<e;t++){const e=r[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const r=this.geometry,n=r.attributes.position,i=r.morphAttributes.position,s=r.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(i&&o){Ke.set(0,0,0);for(let r=0,n=i.length;r<n;r++){const n=o[r],a=i[r];0!==n&&(Qe.fromBufferAttribute(a,t),s?Ke.addScaledVector(Qe,n):Ke.addScaledVector(Qe.sub(e),n))}e.add(Ke)}return e}raycast(t,e){const r=this.geometry,n=this.material,i=this.matrixWorld;if(void 0!==n){if(null===r.boundingSphere&&r.computeBoundingSphere(),He.copy(r.boundingSphere),He.applyMatrix4(i),Ve.copy(t.ray).recast(t.near),!1===He.containsPoint(Ve.origin)){if(null===Ve.intersectSphere(He,Ge))return;if(Ve.origin.distanceToSquared(Ge)>(t.far-t.near)**2)return}$e.copy(i).invert(),Ve.copy(t.ray).applyMatrix4($e),null!==r.boundingBox&&!1===Ve.intersectsBox(r.boundingBox)||this._computeIntersections(t,e,Ve)}}_computeIntersections(t,e,r){let n;const i=this.geometry,s=this.material,o=i.index,a=i.attributes.position,c=i.attributes.uv,h=i.attributes.uv1,l=i.attributes.normal,u=i.groups,d=i.drawRange;if(null!==o)if(Array.isArray(s))for(let i=0,a=u.length;i<a;i++){const a=u[i],p=s[a.materialIndex];for(let i=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));i<s;i+=3){n=nr(this,p,t,r,c,h,l,o.getX(i),o.getX(i+1),o.getX(i+2)),n&&(n.faceIndex=Math.floor(i/3),n.face.materialIndex=a.materialIndex,e.push(n))}}else{for(let i=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);i<a;i+=3){n=nr(this,s,t,r,c,h,l,o.getX(i),o.getX(i+1),o.getX(i+2)),n&&(n.faceIndex=Math.floor(i/3),e.push(n))}}else if(void 0!==a)if(Array.isArray(s))for(let i=0,o=u.length;i<o;i++){const o=u[i],p=s[o.materialIndex];for(let i=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));i<s;i+=3){n=nr(this,p,t,r,c,h,l,i,i+1,i+2),n&&(n.faceIndex=Math.floor(i/3),n.face.materialIndex=o.materialIndex,e.push(n))}}else{for(let i=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);i<o;i+=3){n=nr(this,s,t,r,c,h,l,i,i+1,i+2),n&&(n.faceIndex=Math.floor(i/3),e.push(n))}}}}function nr(t,e,r,n,i,s,o,a,c,h){t.getVertexPosition(a,Xe),t.getVertexPosition(c,Ze),t.getVertexPosition(h,Je);const l=function(t,e,r,n,i,s,o,a){let c;if(c=1===e.side?n.intersectTriangle(o,s,i,!0,a):n.intersectTriangle(i,s,o,0===e.side,a),null===c)return null;er.copy(a),er.applyMatrix4(t.matrixWorld);const h=r.ray.origin.distanceTo(er);return h<r.near||h>r.far?null:{distance:h,point:er.clone(),object:t}}(t,e,r,n,Xe,Ze,Je,tr);if(l){const t=new L;Kt.getBarycoord(tr,Xe,Ze,Je,t),i&&(l.uv=Kt.getInterpolatedAttribute(i,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(n.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 ir extends nt{constructor(t,e,r,n,i,s,o,a,c){super(t,e,r,n,i,s,o,a,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class sr extends je{constructor(t=1,e=1,r=1,n=1,i=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:s};const o=this;n=Math.floor(n),i=Math.floor(i),s=Math.floor(s);const a=[],c=[],h=[],l=[];let u=0,d=0;function p(t,e,r,n,i,s,p,f,m,g,y){const b=s/m,x=p/g,v=s/2,w=p/2,_=f/2,M=m+1,S=g+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*n,z[e]=o*i,z[r]=_,c.push(z.x,z.y,z.z),z[t]=0,z[e]=0,z[r]=f>0?1:-1,h.push(z.x,z.y,z.z),l.push(a/m),l.push(1-s/g),k+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const r=u+e+M*t,n=u+e+M*(t+1),i=u+(e+1)+M*(t+1),s=u+(e+1)+M*t;a.push(r,n,s),a.push(n,i,s),A+=6}o.addGroup(d,A,y),d+=A,u+=k}p("z","y","x",-1,-1,r,e,t,s,i,0),p("z","y","x",1,-1,r,e,-t,s,i,1),p("x","z","y",1,1,t,r,e,n,s,2),p("x","z","y",1,-1,t,r,-e,n,s,3),p("x","y","z",1,-1,t,e,r,n,i,4),p("x","y","z",-1,-1,t,e,-r,n,i,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 sr(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class or extends je{constructor(t=1,e=1,r=1,n=32,i=1,s=!1,o=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a};const c=this;n=Math.floor(n),i=Math.floor(i);const h=[],l=[],u=[],d=[];let p=0;const f=[],m=r/2;let g=0;function y(r){const i=p,s=new D,f=new L;let y=0;const b=!0===r?t:e,x=!0===r?1:-1;for(let t=1;t<=n;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<=n;t++){const e=t/n*a+o,r=Math.cos(e),i=Math.sin(e);f.x=b*i,f.y=m*x,f.z=b*r,l.push(f.x,f.y,f.z),u.push(0,x,0),s.x=.5*r+.5,s.y=.5*i*x+.5,d.push(s.x,s.y),p++}for(let t=0;t<n;t++){const e=i+t,n=v+t;!0===r?h.push(n,n+1,e):h.push(n+1,n,e),y+=3}c.addGroup(g,y,!0===r?1:2),g+=y}!function(){const s=new L,y=new L;let b=0;const x=(e-t)/r;for(let c=0;c<=i;c++){const h=[],g=c/i,b=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,i=e*a+o,c=Math.sin(i),f=Math.cos(i);y.x=b*c,y.y=-g*r+m,y.z=b*f,l.push(y.x,y.y,y.z),s.set(c,x,f).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-g),h.push(p++)}f.push(h)}for(let r=0;r<n;r++)for(let n=0;n<i;n++){const s=f[n][r],o=f[n+1][r],a=f[n+1][r+1],c=f[n][r+1];(t>0||0!==n)&&(h.push(s,o,c),b+=3),(e>0||n!==i-1)&&(h.push(o,a,c),b+=3)}c.addGroup(g,b,0),g+=b}(),!1===s&&(t>0&&y(!0),e>0&&y(!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 or(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ar extends je{constructor(t=1,e=1,r=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:n};const i=t/2,s=e/2,o=Math.floor(r),a=Math.floor(n),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 r=0;r<c;r++){const n=r*l-i;p.push(n,-e,0),f.push(0,0,1),m.push(r/o),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<o;e++){const r=e+c*t,n=e+c*(t+1),i=e+1+c*(t+1),s=e+1+c*t;d.push(r,n,s),d.push(n,i,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 ar(t.width,t.height,t.widthSegments,t.heightSegments)}}class cr extends je{constructor(t=1,e=32,r=16,n=0,i=2*Math.PI,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:i,thetaStart:s,thetaLength:o},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));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<=r;d++){const g=[],y=d/r,b=s+y*o,x=t*Math.cos(b),v=Math.sqrt(t*t-x*x);let w=0;0===d&&0===s?w=.5/e:d===r&&a===Math.PI&&(w=-.5/e);for(let t=0;t<=e;t++){const r=t/e,s=n+r*i;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(r+w,1-y),g.push(c++)}h.push(g)}for(let t=0;t<r;t++)for(let n=0;n<e;n++){const e=h[t][n+1],i=h[t][n],o=h[t+1][n],c=h[t+1][n+1];(0!==t||s>0)&&d.push(e,i,c),(t!==r-1||a<Math.PI)&&d.push(i,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 cr(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class hr 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 lr{static{lr.prototype.isMatrix2=!0}constructor(t,e,r,n){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,r,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let r=0;r<4;r++)this.elements[r]=t[r+e];return this}set(t,e,r,n){const i=this.elements;return i[0]=t,i[2]=e,i[1]=r,i[3]=n,this}}function ur(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 dr=new mt;function pr(t,e){dr.setFromQuaternion(new N(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=dr.x,t.rotation=-dr.y,t.rotationY=dr.z}const fr="_transferSlotId";const mr=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__=mr);const gr=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,r=this.cacheHit+this.cacheMiss,n=this._getResidents?.()??null;let i=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(i=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const s={fps:i,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:r>0?Math.round(this.cacheHit/r*1e3)/10:0,...n??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,s}};function yr(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const br=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 mr.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const r=e?.component,n=r?.app??r?.root?.app;if(n&&"boolean"==typeof n.isViewMode&&!n.isViewMode)return()=>{};const i={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(i),this.isRunning||this.start(),()=>{this._ticking?(i._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(i),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,gr.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const r=mr.tick(e),n=mr.now;if(this._ticking=!0,gr.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(r,n)}finally{const n=performance.now()-e;t.tickCount++,t.totalDurationMs+=n,t.lastDt=r,t.lastDurationMs=n}}else for(const t of this._subs)t._removed||t.handler(r,n);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(),r=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(r),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,r){const n={id:this._externalNextId++,description:t,source:e,metadata:r,registeredAt:this._realTime};return this._externals.add(n),{update:t=>{n.metadata={...n.metadata??{},...t}},unregister:()=>{this._externals.delete(n)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let r;const n=e.componentRef?.deref();let i;if(n&&(r=yr(n)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],r=[];for(const t of e)null!=t&&r.push(yr(t));r.length>0&&(i=r)}}catch{}t.push({id:e.id,description:e.description,componentInfo:r,targetInfos:i,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(mr.now),isRunning:this.isRunning,speed:mr.speed,paused:mr.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let xr=null;const vr=[],wr=new Set;function _r(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const Mr={beginContext(t){xr=t},endContext(){xr=null},current:()=>xr,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??_r(t.component),componentType:t.componentType??(r=t.component,r?.state?.type??r?.type),atSimMs:mr.now,args:t.args,result:t.result,error:t.error};var r;xr?xr.pushTrace(e):(vr.push(e),vr.length>500&&vr.shift(),wr.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...vr],onStandalone:t=>(wr.add(t),()=>{wr.delete(t)}),clearStandalone(){vr.length=0}};function Sr(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const r=String(e);return r.length>0?r:void 0}function kr(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},r=t.sourceId??Sr(t.source),n=t.targetId??Sr(t.target),i=t.carrierId??Sr(t.carrier);return void 0!==r&&(e.sourceId=r),void 0!==n&&(e.targetId=n),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let Ar=1;class zr{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+Ar++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:mr.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??mr.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return Tr.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=mr.now;const t=this.options?.slotId,e=void 0!==t?{slotId:t}:void 0,r=this.target.canAccept?.(this.carrier,e);if(r&&r.ok)this._slot=r.slot;else{if(r&&!r.ok&&"no-slots-defined"!==r.reason)return this._rejectReason=r.reason,this._rollback();if(r||"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=mr.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",Tr.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=mr.now;const t=this._buildReceipt();return Tr.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=mr.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=mr.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=mr.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=mr.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 Mr.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 Mr.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){Mr.beginContext(this),Mr.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:Sr(this.source),target:Sr(this.target),carrier:Sr(this.carrier)}});try{return await this._executeImpl()}finally{Mr.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),Mr.endContext()}}executeSync(){Mr.beginContext(this),Mr.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:Sr(this.source),target:Sr(this.target),carrier:Sr(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=mr.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{Mr.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),Mr.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=mr.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",Tr.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:Sr(this.source),targetId:Sr(this.target),carrierId:Sr(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 Tr=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??Sr(t.source),r=t.targetId??Sr(t.target);if("committed"===t.phase){if(e&&r){const t=e+">"+r;this._flows.set(t,(this._flows.get(t)??0)+1)}r&&this._targetCount.set(r,(this._targetCount.get(r)??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,r)=>{t[r]=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,r){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=Tr);let Ir=1;function Or(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const Er={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class Pr{constructor(t=Er){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-"+Ir++},r=(this._byResource.get(e.resource)??[]).filter(t=>Or(t.timeWindow,e.timeWindow));if(0===r.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const n=r.map(t=>{const r=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:r}});if(n.every(t=>"b-yields"===t.decision)){const n=r.slice();for(const t of n)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:n,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:n}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r.slice(),outcome:"rejected"}),{ok:!1,conflicts:n}}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=>Or(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 r=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);r<0?e.push(t):e.splice(r,0,t);let n=this._byReserver.get(t.reserverId);n||(n=[],this._byReserver.set(t.reserverId,n)),n.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const r=e.findIndex(e=>e.id===t.id);if(r<0)return!1;e.splice(r,1),0===e.length&&this._byResource.delete(t.resource);const n=this._byReserver.get(t.reserverId);if(n){const e=n.findIndex(e=>e.id===t.id);e>=0&&n.splice(e,1),0===n.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const jr=new Pr;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=jr);class Cr{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,r=1/0;for(const n of this.nodes.values()){const i=Rr(n.position,t);i<r&&(r=i,e=n)}return e}}function Rr(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}function Fr(t,e){return Math.sqrt(Rr(t,e))}function Dr(t,e,r={}){const n=new Cr,i=r.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const r=`${e.id}:start`,s=`${e.id}:end`;n.addNode({id:r,position:t[0],type:"lane-start"}),n.addNode({id:s,position:t[t.length-1],type:"lane-end"}),n.laneEndpoints.set(e.id,{startNodeId:r,endNodeId:s});let o=0;for(let e=1;e<t.length;e++)o+=Fr(t[e-1],t[e]);const a=o/(e.speedLimit??i)*1e3;n.addEdge({fromNode:r,toNode:s,resource:e.id,distance:o,durationMs:a,forward:!0}),"twoway"===e.direction&&n.addEdge({fromNode:s,toNode:r,resource:e.id,distance:o,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const r of t.lanes){const i=n.laneEndpoints.get(r);if(!i)continue;const s=n.nodes.get(i.startNodeId).position,o=n.nodes.get(i.endNodeId).position;let a=0,c=0,h=0;for(const e of t.lanes){if(e===r)continue;const t=n.laneEndpoints.get(e);if(!t)continue;const i=n.nodes.get(t.startNodeId).position,l=n.nodes.get(t.endNodeId).position;a+=Math.min(Rr(s,i),Rr(s,l)),c+=Math.min(Rr(o,i),Rr(o,l)),h++}if(0===h)continue;const l=a<c?i.startNodeId:i.endNodeId;e.push({laneId:r,nodeId:l,pos:n.nodes.get(l).position})}for(let r=0;r<e.length;r++)for(let i=0;i<e.length;i++){if(r===i)continue;const s=e[r],o=e[i],a=Fr(s.pos,o.pos);n.addEdge({fromNode:s.nodeId,toNode:o.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return n}function Nr(t,e,r,n={}){const i=t.nodes.get(e),s=t.nodes.get(r);if(!i||!s)return null;const o=n.speed?.max??100,a=e=>{const r=t.nodes.get(e);var n,i;return(n=r.position,i=s.position,Math.sqrt(function(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}(n,i)))/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=n.startSimMs??0,p=n.deadlineSimMs;for(;h.size>0;){let e=null,n=null;for(const t of h){const r=c.get(t);(!n||r.fScore<n.fScore||r.fScore===n.fScore&&t<e)&&(n=r,e=t)}if(!n||!e)return null;if(e===r){const t=[];let e=n,r=0;for(;e&&e.cameFromEdge;){const n=e.cameFromEdge,i=d+(e.gScore-n.durationMs);t.unshift({resource:n.resource,timeWindow:{startSimMs:i,endSimMs:i+n.durationMs},fromPos:n.fromPos,toPos:n.toPos}),r+=n.distance,e=c.get(n.fromNodeId)}const i=n.gScore;return void 0!==p&&d+i>p?null:{segments:t,totalDurationMs:i,totalDistance:r}}h.delete(e),l.add(e);for(const r of t.edgesFrom(e)){if(l.has(r.toNode))continue;const e=n.gScore+r.durationMs,i=c.get(r.toNode);if(!i||e<i.gScore){const n=t.nodes.get(r.fromNode),i=t.nodes.get(r.toNode),s={nodeId:r.toNode,gScore:e,fScore:e+a(r.toNode),cameFromEdge:{fromNodeId:r.fromNode,resource:r.resource,distance:r.distance,durationMs:r.durationMs,fromPos:n.position,toPos:i.position}};c.set(r.toNode,s),h.add(r.toNode)}}}return null}function Lr(t,e,r=0,n){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:r,metadata:n}))}const Br=.5;function Ur(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function Yr(t,e,r){const n=e.x-t.x,i=e.y-t.y,s=Math.sqrt(n*n+i*i);if(0===s||!Number.isFinite(r)||Math.abs(r)<1e-9)return null;const o=Math.abs(r),a=(s*s+4*o*o)/(8*o),c=r>0?1:-1,h=a-o,l=(t.x+e.x)/2-c*(i/s)*h,u=(t.y+e.y)/2-c*-(n/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:r<0}}function Wr(t,e,r=0,n=16){const i=e.x-t.x,s=e.y-t.y,o=Math.sqrt(i*i+s*s);if(0===o)return null;const a=s/o,c=-(i/o),h=Number.isFinite(r)?r:0,l=Math.abs(h)>=1e-6?h:n;return{x:(t.x+e.x)/2+a*l,y:(t.y+e.y)/2+c*l,perpX:a,perpY:c}}function qr(t,e,r){const n=e.x-t.x,i=e.y-t.y,s=Math.sqrt(n*n+i*i);if(0===s)return 0;const o=i/s,a=-(n/s),c=(t.x+e.x)/2,h=(t.y+e.y)/2;let l=(r.x-c)*o+(r.y-h)*a;if(Math.abs(l)<.5)return 0;return l>s&&(l=s),l<-s&&(l=-s),l}function $r(t,e){const r=t.radius,n=Number.isFinite(e)?e:0;return null!=r&&Number.isFinite(r)?Math.max(0,r):Math.max(0,n)}function Vr(t,e,r,n,i=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=r.x-e.x,h=r.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,g=Math.max(n,i);return{x:e.x+f*g,y:e.y+m*g,bisectorX:f,bisectorY:m}}function Hr(t,e,r,n){const i=t.x-e.x,s=t.y-e.y,o=Math.sqrt(i*i+s*s),a=r.x-e.x,c=r.y-e.y,h=Math.sqrt(a*a+c*c);if(0===o||0===h)return 0;const l=i/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=(n.x-e.x)*p+(n.y-e.y)*f,g=Math.min(o,h)/2;return Math.max(0,Math.min(m,g))}function Gr(t){if(0===t.length)return 0;let e;for(const r of t){const t=r.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 Xr={closed:!0,round:0,divisions:24};class Zr{constructor(t,e){this.points=t,this.closed=e;const r=[0];for(let e=1;e<t.length;e++){const n=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;r.push(r[e-1]+Math.sqrt(n*n+i*i))}this.cumulative=r,this.length=r[r.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 r=t;this.closed?r=(t%e+e)%e:r<0?r=0:r>e&&(r=e);const n=this.cumulative;let i=0,s=n.length-2;for(;i<s;){const t=i+s>>1;n[t+1]<=r?i=t+1:s=t}const o=n[i+1]-n[i],a=o>0?(r-n[i])/o:0,c=this.points[i],h=this.points[i+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 Jr(t,e={}){const r={...Xr,...e},n=t.length;if(0===n)return new Zr([],r.closed);if(1===n)return new Zr([{x:t[0].x,y:t[0].y}],r.closed);const i=[],s=(t,e)=>{if(i.length>0){const r=i[i.length-1];if(Math.abs(r.x-t)<1e-9&&Math.abs(r.y-e)<1e-9)return}i.push({x:t,y:e})},o=(r.closed,n);for(let e=0;e<o;e++){const i=0===e?r.closed?n-1:-1:e-1,o=e===n-1?r.closed?0:-1:e+1,a=i>=0?t[i]: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?$r(c,r.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,r=Math.min(l,t/2);u=Math.sin(e)*r+c.x,d=Math.cos(e)*r+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,r=Math.min(l,t/2);p=Math.sin(e)*r+c.x,f=Math.cos(e)*r+c.y}else p=c.x,f=c.y;if(s(u,d),l>0&&a&&h)for(let t=1;t<=r.divisions;t++){const e=t/r.divisions,n=1-e;s(n*n*u+2*n*e*c.x+e*e*p,n*n*d+2*n*e*c.y+e*e*f)}else u===p&&d===f||s(p,f);if(h&&Ur(c)){const t=$r(h,r.round),e=Math.sqrt((c.x-h.x)**2+(c.y-h.y)**2),n=0!==e?Math.atan2(c.x-h.x,c.y-h.y):0,i=Math.min(t,e/2),o=Yr({x:p,y:f},{x:Math.sin(n)*i+h.x,y:Math.cos(n)*i+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<=r.divisions;e++){const n=e/r.divisions,i=o.startAngle+t*n;s(o.cx+o.radius*Math.cos(i),o.cy+o.radius*Math.sin(i))}}}}if(r.closed&&i.length>0){const t=i[0],e=i[i.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&i.push({x:t.x,y:t.y})}return new Zr(i,r.closed)}function Qr(t,e){return Jr(t,e).length}function Kr(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function tn(t){if(Kr(t)){const e=t.capacity(),r=t.available();return{capacity:e,available:r,isFull:0===r}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,r="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:r,isFull:0===r}}const e=t?.state?.capacity,r=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-r);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class en{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 rn(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 r=e.onFull(()=>t.pauseEmit()),n=e.onAvailable(()=>t.resumeEmit());return tn(e).isFull&&t.pauseEmit(),()=>{r?.(),n?.()}}class nn{constructor(t,e=1,r="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=r}positionAt(t,e,r,n){const i=e.maxCount??1/0;if(t<0||t>=i)return null;const s=this.owner?.state?.width??0,o=this.owner?.state?.height??0,a=n?.state?.width??0,c=n?.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 sn(t,e,r,n,i,s,o){const a=r.w,c=r.h,h=n.w,l=n.h,u=n.d,d=[],p=h+i,f=l+i,m=Math.max(1,Math.floor((a+i)/p)),g=Math.max(1,Math.floor((c+i)/f)),y=m*g,b=s&&s>0?Math.floor(s):4;if("row"===t||"column"===t){const r=o?.advanceAlongX??!1,n=o?.reverse??!1,i=r?m:g,s=r?g:m,h=(t,e,n)=>((t,e,r)=>d.push({x:-a/2+(t+.5)*p,y:r*u+u/2,z:-c/2+(e+.5)*f}))(r?t:e,r?e:t,n);let l=0;for(let r=0;r<i&&l<e;r++){const o=n?i-1-r:r;if("column"===t)for(let t=0;t<s&&l<e;t++)for(let r=0;r<b&&l<e;r++)h(o,t,r),l++;else for(let t=0;t<b&&l<e;t++)for(let r=0;r<s&&l<e;r++)h(o,r,t),l++}return d}if("pyramid"===t){let t=e,r=0;for(;t>0;){const e=Math.max(1,m-r),n=Math.max(1,g-r),i=e*n,o=Math.min(t,i);for(let t=0;t<o;t++){const i=t%e,s=Math.floor(t/e),o=-a/2+(i+(m-e)/2+.5)*p,h=-c/2+(s+(g-n)/2+.5)*f;d.push({x:o,y:r*u+u/2,z:h})}if(t-=o,r++,1===e&&1===n){for(let e=0;e<t;e++)d.push({x:0,y:(r+e)*u+u/2,z:0});break}if(s&&r>=s)break}return d}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let r=0;r<e;r++){const e=Math.floor(r/y),n=r%y,i=n%m,o=Math.floor(n/m),g=(t(2*r)-.5)*h*.2,b=(t(2*r+1)-.5)*l*.2,x=-a/2+(i+.5)*p+g,v=-c/2+(o+.5)*f+b;if(d.push({x:x,y:e*u+u/2,z:v}),s&&e>=s-1&&n===y-1)break}return d}for(let r=0;r<e;r++){const e=Math.floor(r/y);if(s&&e>=s)break;const n=r%y,i=n%m,o=Math.floor(n/m);let h=-a/2+(i+.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 on{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,r,n={}){const i=n.gap??this.defaults.gap??0,s=n.heightLimit??this.defaults.heightLimit,o=n.fill??this.defaults.fill;return sn(this.pattern,t,e,r,i,s,o).map(t=>({position:t}))}}class an{constructor(t,e,r={}){this.cols=t,this.rows=e,this.defaults=r}layout(t,e,r,n={}){const i=Math.max(1,this.cols),s=Math.max(1,this.rows),o=i*s,a=n.gap??this.defaults.gap??0,c=r.w+a,h=r.h+a,l=[];for(let e=0;e<t;e++){const t=Math.floor(e/o),n=e%o,a=n%i,u=Math.floor(n/i);l.push({position:{x:(a-(i-1)/2)*c,z:(u-(s-1)/2)*h,y:t*r.d+r.d/2}})}return l}}class cn{constructor(t=.1,e=!1,r=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=r}grid(t,e){const r=e.w*this.gapRatio,n=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-r)/(e.w+r))),rows:Math.max(1,Math.floor((t.h-n)/(e.h+n))),pitchX:e.w+r,pitchZ:e.h+n}}capacity(t,e,r){const{cols:n,rows:i}=this.grid(t,e);return n*i*Math.max(1,Math.floor(r))}layout(t,e,r,n={}){const{cols:i,rows:s,pitchX:o,pitchZ:a}=this.grid(e,r),c=r.d+r.d*this.gapRatio,h=null!=n.heightLimit?Math.max(1,Math.floor(n.heightLimit)):1/0,l=Number.isFinite(h),u=this.sliceFirst&&l,d=i*s,p=i*(l?h:1),f=i*s*(l?h:t),m=Math.min(t,f),g=[];for(let t=0;t<m;t++){let e,n,h;if(u){const r=Math.floor(t/p),s=t%p;e=s%i,h=Math.floor(s/i),n=r}else{h=Math.floor(t/d);const r=t%d;e=r%i,n=Math.floor(r/i)}this.fillFromFar&&(n=s-1-n),g.push({position:{x:(e-(i-1)/2)*o,z:(n-(s-1)/2)*a,y:h*c+r.d/2}})}return g}}function hn(t,e,r,n=0){for(let i=0;i<e.length;i++){const s=e[i],o=r[i];s&&o&&(s.parent!==t&&t.attach(s),s.position.set(o.position.x,n+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 ln(t,e,r,n=.12){const i=e.left+e.width/2,s=e.top+e.height/2,o=Math.min(r.w,r.h)*n,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let n=a.get(t);n||(n={x:i+e.position.x-r.w/2+o,y:s+e.position.z-r.h/2+o,w:r.w-2*o,h:r.h-2*o,count:0},a.set(t,n)),n.count++}return[...a.values()]}function un(t,e){return t===e||t!=t&&e!=e}function dn(t,e){for(var r=t.length;r--;)if(un(t[r][0],e))return r;return-1}var pn=Array.prototype.splice;function fn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}fn.prototype.clear=function(){this.__data__=[],this.size=0},fn.prototype.delete=function(t){var e=this.__data__,r=dn(e,t);return!(r<0)&&(r==e.length-1?e.pop():pn.call(e,r,1),--this.size,!0)},fn.prototype.get=function(t){var e=this.__data__,r=dn(e,t);return r<0?void 0:e[r][1]},fn.prototype.has=function(t){return dn(this.__data__,t)>-1},fn.prototype.set=function(t,e){var r=this.__data__,n=dn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var mn="object"==typeof global&&global&&global.Object===Object&&global,gn="object"==typeof self&&self&&self.Object===Object&&self,yn=mn||gn||Function("return this")(),bn=yn.Symbol,xn=Object.prototype,vn=xn.hasOwnProperty,wn=xn.toString,_n=bn?bn.toStringTag:void 0;var Mn=Object.prototype.toString;var Sn=bn?bn.toStringTag:void 0;function kn(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Sn&&Sn in Object(t)?function(t){var e=vn.call(t,_n),r=t[_n];try{t[_n]=void 0;var n=!0}catch(t){}var i=wn.call(t);return n&&(e?t[_n]=r:delete t[_n]),i}(t):function(t){return Mn.call(t)}(t)}function An(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function zn(t){if(!An(t))return!1;var e=kn(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var Tn,In=yn["__core-js_shared__"],On=(Tn=/[^.]+$/.exec(In&&In.keys&&In.keys.IE_PROTO||""))?"Symbol(src)_1."+Tn:"";var En=Function.prototype.toString;function Pn(t){if(null!=t){try{return En.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var jn=/^\[object .+?Constructor\]$/,Cn=Function.prototype,Rn=Object.prototype,Fn=Cn.toString,Dn=Rn.hasOwnProperty,Nn=RegExp("^"+Fn.call(Dn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ln(t){return!(!An(t)||(e=t,On&&On in e))&&(zn(t)?Nn:jn).test(Pn(t));var e}function Bn(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ln(r)?r:void 0}var Un=Bn(yn,"Map"),Yn=Bn(Object,"create");var Wn=Object.prototype.hasOwnProperty;var qn=Object.prototype.hasOwnProperty;function $n(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Vn(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function Hn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}$n.prototype.clear=function(){this.__data__=Yn?Yn(null):{},this.size=0},$n.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},$n.prototype.get=function(t){var e=this.__data__;if(Yn){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Wn.call(e,t)?e[t]:void 0},$n.prototype.has=function(t){var e=this.__data__;return Yn?void 0!==e[t]:qn.call(e,t)},$n.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Yn&&void 0===e?"__lodash_hash_undefined__":e,this},Hn.prototype.clear=function(){this.size=0,this.__data__={hash:new $n,map:new(Un||fn),string:new $n}},Hn.prototype.delete=function(t){var e=Vn(this,t).delete(t);return this.size-=e?1:0,e},Hn.prototype.get=function(t){return Vn(this,t).get(t)},Hn.prototype.has=function(t){return Vn(this,t).has(t)},Hn.prototype.set=function(t,e){var r=Vn(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Gn(t){var e=this.__data__=new fn(t);this.size=e.size}Gn.prototype.clear=function(){this.__data__=new fn,this.size=0},Gn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Gn.prototype.get=function(t){return this.__data__.get(t)},Gn.prototype.has=function(t){return this.__data__.has(t)},Gn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof fn){var n=r.__data__;if(!Un||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Hn(n)}return r.set(t,e),this.size=r.size,this};function Xn(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Hn;++e<r;)this.add(t[e])}function Zn(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}Xn.prototype.add=Xn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Xn.prototype.has=function(t){return this.__data__.has(t)};function Jn(t,e,r,n,i,s){var o=1&r,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&r?new Xn:void 0;for(s.set(t,e),s.set(e,t);++u<a;){var f=t[u],m=e[u];if(n)var g=o?n(m,f,u,e,t,s):n(f,m,u,t,e,s);if(void 0!==g){if(g)continue;d=!1;break}if(p){if(!Zn(e,function(t,e){if(o=e,!p.has(o)&&(f===t||i(f,t,r,n,s)))return p.push(e);var o})){d=!1;break}}else if(f!==m&&!i(f,m,r,n,s)){d=!1;break}}return s.delete(t),s.delete(e),d}var Qn=yn.Uint8Array;function Kn(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function ti(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var ei=bn?bn.prototype:void 0,ri=ei?ei.valueOf:void 0;function ni(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var ii=Array.isArray;function si(){return[]}var oi=Object.prototype.propertyIsEnumerable,ai=Object.getOwnPropertySymbols,ci=ai?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,s=[];++r<n;){var o=t[r];e(o,r,t)&&(s[i++]=o)}return s}(ai(t),function(e){return oi.call(t,e)}))}:si;function hi(t){return null!=t&&"object"==typeof t}function li(t){return hi(t)&&"[object Arguments]"==kn(t)}var ui=Object.prototype,di=ui.hasOwnProperty,pi=ui.propertyIsEnumerable,fi=li(function(){return arguments}())?li:function(t){return hi(t)&&di.call(t,"callee")&&!pi.call(t,"callee")};var mi="object"==typeof exports&&exports&&!exports.nodeType&&exports,gi=mi&&"object"==typeof module&&module&&!module.nodeType&&module,yi=gi&&gi.exports===mi?yn.Buffer:void 0,bi=(yi?yi.isBuffer:void 0)||function(){return!1},xi=/^(?:0|[1-9]\d*)$/;function vi(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&xi.test(t))&&t>-1&&t%1==0&&t<e}function wi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var _i={};function Mi(t){return function(e){return t(e)}}_i["[object Float32Array]"]=_i["[object Float64Array]"]=_i["[object Int8Array]"]=_i["[object Int16Array]"]=_i["[object Int32Array]"]=_i["[object Uint8Array]"]=_i["[object Uint8ClampedArray]"]=_i["[object Uint16Array]"]=_i["[object Uint32Array]"]=!0,_i["[object Arguments]"]=_i["[object Array]"]=_i["[object ArrayBuffer]"]=_i["[object Boolean]"]=_i["[object DataView]"]=_i["[object Date]"]=_i["[object Error]"]=_i["[object Function]"]=_i["[object Map]"]=_i["[object Number]"]=_i["[object Object]"]=_i["[object RegExp]"]=_i["[object Set]"]=_i["[object String]"]=_i["[object WeakMap]"]=!1;var Si="object"==typeof exports&&exports&&!exports.nodeType&&exports,ki=Si&&"object"==typeof module&&module&&!module.nodeType&&module,Ai=ki&&ki.exports===Si&&mn.process,zi=function(){try{var t=ki&&ki.require&&ki.require("util").types;return t||Ai&&Ai.binding&&Ai.binding("util")}catch(t){}}(),Ti=zi&&zi.isTypedArray,Ii=Ti?Mi(Ti):function(t){return hi(t)&&wi(t.length)&&!!_i[kn(t)]},Oi=Object.prototype.hasOwnProperty;function Ei(t,e){var r=ii(t),n=!r&&fi(t),i=!r&&!n&&bi(t),s=!r&&!n&&!i&&Ii(t),o=r||n||i||s,a=o?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var h in t)!e&&!Oi.call(t,h)||o&&("length"==h||i&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||vi(h,c))||a.push(h);return a}var Pi=Object.prototype;function ji(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Pi)}function Ci(t,e){return function(r){return t(e(r))}}var Ri=Ci(Object.keys,Object),Fi=Object.prototype.hasOwnProperty;function Di(t){if(!ji(t))return Ri(t);var e=[];for(var r in Object(t))Fi.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Ni(t){return null!=t&&wi(t.length)&&!zn(t)}function Li(t){return Ni(t)?Ei(t):Di(t)}function Bi(t){return function(t,e,r){var n=e(t);return ii(t)?n:ni(n,r(t))}(t,Li,ci)}var Ui=Object.prototype.hasOwnProperty;var Yi=Bn(yn,"DataView"),Wi=Bn(yn,"Promise"),qi=Bn(yn,"Set"),$i=Bn(yn,"WeakMap"),Vi="[object Map]",Hi="[object Promise]",Gi="[object Set]",Xi="[object WeakMap]",Zi="[object DataView]",Ji=Pn(Yi),Qi=Pn(Un),Ki=Pn(Wi),ts=Pn(qi),es=Pn($i),rs=kn;(Yi&&rs(new Yi(new ArrayBuffer(1)))!=Zi||Un&&rs(new Un)!=Vi||Wi&&rs(Wi.resolve())!=Hi||qi&&rs(new qi)!=Gi||$i&&rs(new $i)!=Xi)&&(rs=function(t){var e=kn(t),r="[object Object]"==e?t.constructor:void 0,n=r?Pn(r):"";if(n)switch(n){case Ji:return Zi;case Qi:return Vi;case Ki:return Hi;case ts:return Gi;case es:return Xi}return e});var ns="[object Arguments]",is="[object Array]",ss="[object Object]",os=Object.prototype.hasOwnProperty;function as(t,e,r,n,i,s){var o=ii(t),a=ii(e),c=o?is:rs(t),h=a?is:rs(e),l=(c=c==ns?ss:c)==ss,u=(h=h==ns?ss:h)==ss,d=c==h;if(d&&bi(t)){if(!bi(e))return!1;o=!0,l=!1}if(d&&!l)return s||(s=new Gn),o||Ii(t)?Jn(t,e,r,n,i,s):function(t,e,r,n,i,s,o){switch(r){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 Qn(t),new Qn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return un(+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=Kn;case"[object Set]":var c=1&n;if(a||(a=ti),t.size!=e.size&&!c)return!1;var h=o.get(t);if(h)return h==e;n|=2,o.set(t,e);var l=Jn(a(t),a(e),n,i,s,o);return o.delete(t),l;case"[object Symbol]":if(ri)return ri.call(t)==ri.call(e)}return!1}(t,e,c,r,n,i,s);if(!(1&r)){var p=l&&os.call(t,"__wrapped__"),f=u&&os.call(e,"__wrapped__");if(p||f){var m=p?t.value():t,g=f?e.value():e;return s||(s=new Gn),i(m,g,r,n,s)}}return!!d&&(s||(s=new Gn),function(t,e,r,n,i,s){var o=1&r,a=Bi(t),c=a.length;if(c!=Bi(e).length&&!o)return!1;for(var h=c;h--;){var l=a[h];if(!(o?l in e:Ui.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]],g=e[l];if(n)var y=o?n(g,m,l,e,t,s):n(m,g,l,t,e,s);if(!(void 0===y?m===g||i(m,g,r,n,s):y)){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,r,n,i,s))}function cs(t,e,r,n,i){return t===e||(null==t||null==e||!hi(t)&&!hi(e)?t!=t&&e!=e:as(t,e,r,n,cs,i))}var hs=function(){try{var t=Bn(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function ls(t,e,r){"__proto__"==e&&hs?hs(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var us=Object.prototype.hasOwnProperty;function ds(t,e,r){var n=t[e];us.call(t,e)&&un(n,r)&&(void 0!==r||e in t)||ls(t,e,r)}function ps(t,e,r,n){var i=!r;r||(r={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),i?ls(r,a,c):ds(r,a,c)}return r}function fs(t){return t}function ms(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var gs=Math.max;function ys(t){return function(){return t}}var bs=hs?function(t,e){return hs(t,"toString",{configurable:!0,enumerable:!1,value:ys(e),writable:!0})}:fs,xs=Date.now;var vs,ws,_s,Ms=(vs=bs,ws=0,_s=0,function(){var t=xs(),e=16-(t-_s);if(_s=t,e>0){if(++ws>=800)return arguments[0]}else ws=0;return vs.apply(void 0,arguments)});function Ss(t,e){return Ms(function(t,e,r){return e=gs(void 0===e?t.length-1:e,0),function(){for(var n=arguments,i=-1,s=gs(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=r(o),ms(t,this,a)}}(t,e,fs),t+"")}function ks(t,e,r){if(!An(r))return!1;var n=typeof e;return!!("number"==n?Ni(r)&&vi(e,r.length):"string"==n&&e in r)&&un(r[e],t)}var As=Object.prototype.hasOwnProperty;function zs(t){if(!An(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ji(t),r=[];for(var n in t)("constructor"!=n||!e&&As.call(t,n))&&r.push(n);return r}function Ts(t){return Ni(t)?Ei(t,!0):zs(t)}var Is,Os=(Is=function(t,e,r,n){ps(e,Ts(e),t,n)},Ss(function(t,e){var r=-1,n=e.length,i=n>1?e[n-1]:void 0,s=n>2?e[2]:void 0;for(i=Is.length>3&&"function"==typeof i?(n--,i):void 0,s&&ks(e[0],e[1],s)&&(i=n<3?void 0:i,n=1),t=Object(t);++r<n;){var o=e[r];o&&Is(t,o,r,i)}return t})),Es=Ci(Object.getPrototypeOf,Object),Ps=Function.prototype,js=Object.prototype,Cs=Ps.toString,Rs=js.hasOwnProperty,Fs=Cs.call(Object);function Ds(t){if(!hi(t))return!1;var e=kn(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!hi(t)||"[object Object]"!=kn(t))return!1;var e=Es(t);if(null===e)return!0;var r=Rs.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Cs.call(r)==Fs}(t)}var Ns=Ss(function(t,e){try{return ms(t,void 0,e)}catch(t){return Ds(t)?t:new Error(t)}});function Ls(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var Bs=Object.prototype,Us=Bs.hasOwnProperty;function Ys(t,e,r,n){return void 0===t||un(t,Bs[r])&&!Us.call(n,r)?e:t}var Ws={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function qs(t){return"\\"+Ws[t]}var $s=/<%=([\s\S]+?)%>/g;var Vs,Hs=(Vs={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==Vs?void 0:Vs[t]});function Gs(t){return"symbol"==typeof t||hi(t)&&"[object Symbol]"==kn(t)}var Xs=bn?bn.prototype:void 0,Zs=Xs?Xs.toString:void 0;function Js(t){if("string"==typeof t)return t;if(ii(t))return Ls(t,Js)+"";if(Gs(t))return Zs?Zs.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Qs(t){return null==t?"":Js(t)}var Ks=/[&<>"']/g,to=RegExp(Ks.source);var eo={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:$s,variable:"",imports:{_:{escape:function(t){return(t=Qs(t))&&to.test(t)?t.replace(Ks,Hs):t}}}},ro=/\b__p \+= '';/g,no=/\b(__p \+=) '' \+/g,io=/(__e\(.*?\)|\b__t\)) \+\n'';/g,so=/[()=,{}\[\]\/\s]/,oo=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ao=/($^)/,co=/['\n\r\u2028\u2029\\]/g,ho=Object.prototype.hasOwnProperty;var lo="object"==typeof exports&&exports&&!exports.nodeType&&exports,uo=lo&&"object"==typeof module&&module&&!module.nodeType&&module,po=uo&&uo.exports===lo?yn.Buffer:void 0,fo=po?po.allocUnsafe:void 0;var mo=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ni(e,ci(t)),t=Es(t);return e}:si;var go=Object.prototype.hasOwnProperty;var yo=/\w*$/;var bo=bn?bn.prototype:void 0,xo=bo?bo.valueOf:void 0;function vo(t,e,r){var n,i,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new Qn(a).set(new Qn(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(i=t).buffer,new i.constructor(s,i.byteOffset,i.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,yo.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,xo?Object(xo.call(n)):{}}}var wo=Object.create,_o=function(){function t(){}return function(e){if(!An(e))return{};if(wo)return wo(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();var Mo=zi&&zi.isMap,So=Mo?Mi(Mo):function(t){return hi(t)&&"[object Map]"==rs(t)};var ko=zi&&zi.isSet,Ao=ko?Mi(ko):function(t){return hi(t)&&"[object Set]"==rs(t)},zo="[object Arguments]",To="[object Function]",Io="[object Object]",Oo={};function Eo(t,e,r,n,i,s){var o,a=2&e;if(void 0!==o)return o;if(!An(t))return t;var c=ii(t);if(c)return o=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&go.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,o);var h=rs(t),l=h==To||"[object GeneratorFunction]"==h;if(bi(t))return function(t){var e=t.length,r=fo?fo(e):new t.constructor(e);return t.copy(r),r}(t);if(h==Io||h==zo||l&&!i)return o=l?{}:function(t){return"function"!=typeof t.constructor||ji(t)?{}:_o(Es(t))}(t),a?function(t,e){return ps(t,mo(t),e)}(t,function(t,e){return t&&ps(e,Ts(e),t)}(o,t)):function(t,e){return ps(t,ci(t),e)}(t,function(t,e){return t&&ps(e,Li(e),t)}(o,t));if(!Oo[h])return i?t:{};o=vo(t,h),s||(s=new Gn);var u=s.get(t);if(u)return u;s.set(t,o),Ao(t)?t.forEach(function(n){o.add(Eo(n,e,r,n,t,s))}):So(t)&&t.forEach(function(n,i){o.set(i,Eo(n,e,r,i,t,s))});var d=c?void 0:Bi(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(d||t,function(n,i){d&&(n=t[i=n]),ds(o,i,Eo(n,e,r,i,t,s))}),o}Oo[zo]=Oo["[object Array]"]=Oo["[object ArrayBuffer]"]=Oo["[object DataView]"]=Oo["[object Boolean]"]=Oo["[object Date]"]=Oo["[object Float32Array]"]=Oo["[object Float64Array]"]=Oo["[object Int8Array]"]=Oo["[object Int16Array]"]=Oo["[object Int32Array]"]=Oo["[object Map]"]=Oo["[object Number]"]=Oo[Io]=Oo["[object RegExp]"]=Oo["[object Set]"]=Oo["[object String]"]=Oo["[object Symbol]"]=Oo["[object Uint8Array]"]=Oo["[object Uint8ClampedArray]"]=Oo["[object Uint16Array]"]=Oo["[object Uint32Array]"]=!0,Oo["[object Error]"]=Oo[To]=Oo["[object WeakMap]"]=!1;function Po(t){return Eo(t,4)}var jo=/\s/;var Co=/^\s+/;function Ro(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&jo.test(t.charAt(e)););return e}(t)+1).replace(Co,""):t}var Fo=/^[-+]0x[0-9a-f]+$/i,Do=/^0b[01]+$/i,No=/^0o[0-7]+$/i,Lo=parseInt;var Bo=1/0;function Uo(t){return t?(t=function(t){if("number"==typeof t)return t;if(Gs(t))return NaN;if(An(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=An(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ro(t);var r=Do.test(t);return r||No.test(t)?Lo(t.slice(2),r?2:8):Fo.test(t)?NaN:+t}(t))===Bo||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function Yo(t,e){var r;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=Uo(t),r=e%1;return e==e?r?e-r:e:0}(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=void 0),r}}var Wo=Object.prototype.hasOwnProperty;function qo(t){if(null==t)return!0;if(Ni(t)&&(ii(t)||"string"==typeof t||"function"==typeof t.splice||bi(t)||Ii(t)||fi(t)))return!t.length;var e=rs(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(ji(t))return!Di(t).length;for(var r in t)if(Wo.call(t,r))return!1;return!0}let $o=0;function Vo(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 Ho(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function Go(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Xo(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function Zo(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Jo(t){if(this.__collection__)return this.__collection__[t]}function Qo(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function Ko(t){return this.__collection__?this.__collection__.indexOf(t):-1}function ta(){return this.__collection__?this.__collection__.length:0}function ea(){this.__collection__=[]}function ra(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function na(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 ia(t){const e=this.indexOf(t);if(-1==e||0==e)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(r,n)}function sa(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=r.concat(n,this.__collection__)}class oa{constructor(){this.__collection__=[],this.insertAt=Ho,this.append=Go,this.prepend=Xo,this.remove=Zo,this.getAt=Jo,this.forEach=Qo,this.indexOf=Ko,this.size=ta,this.clear=ea,this.moveForward=ra,this.moveBackward=na,this.moveToHead=ia,this.moveToTail=sa}}const aa=/\s+/;function ca(t,e,r,n){if(!r)return!0;if("object"==typeof r){for(const n in r){const i=r[n];t[e].apply(t,[n,i])}return!1}if(aa.test(r)){return r.split(aa).forEach(r=>t[e].apply(t,[r].concat(n))),!1}return!0}const ha=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],la={withEvent(){ha.forEach(t=>this[t]=la[t])},on(t,e,r){if(!ca(this,"on",t,[e,r])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:r,ctx:r||this}),this},once(t,e,r){if(!ca(this,"once",t,[e,r])||!e)return this;const n=this,i=function(t){return Yo(2,t)}(function(){n.off(t,i,r),e.apply(n,arguments)});return i._callback=e,this.on(t,i,r),this},off(t,e,r){if(!this._listeners||!ca(this,"off",t,[e,r]))return this;if(!t&&!e&&!r)return this._listeners=void 0,this;let n;n=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<n.length;t++){const i=n[t],s=this._listeners?.[i];if(s){const t=[];if(this._listeners[i]=t,e||r)for(let n=0;n<s.length;n++){const i=s[n];(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new oa),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&&da(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 r=this._listeners[e.name],n=this._listeners["(all)"];return r&&ua(r,arguments),n&&ua(n,arguments),this},trigger(t){gr.enabled&&gr.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&da(this._delegators,e),!this._listeners)return this;if(!ca(this,"trigger",t,e))return this;const r=this._listeners[t],n=this._listeners["(all)"];return r&&ua(r,e),n&&ua(n,e),this},stopListening(t,e,r){let n=this._listeningTo;if(!n)return this;const i=!e&&!r;r||"object"!=typeof e||(r=this),t&&(n={},n[t._listenId]=t);for(const t in n){const s=n[t];s.off(e,r,this),(i||qo(s._events))&&delete this._listeningTo[t]}return this}};function ua(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function da(t,e){t.forEach(t=>la.delegate.apply(t,e))}const pa={listenTo:"on",listenToOnce:"once"};for(const t in pa){const e=pa[t];la[t]=function(t,r,n){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++$o}`);return i[t._listenId]=t,n||"object"!=typeof r||(n=this),t[e](r,n,this),this}}const fa=la.on,ma=la.off,ga=la.once,ya=la.trigger,ba=la.delegate_on,xa=la.delegate_off;const va=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))},wa=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))};function _a(t,e,r){const n=function(t,e){let r=t;for(;r;){const t=Object.getOwnPropertyDescriptor(r,e);if(t?.get)return t;r=Object.getPrototypeOf(r)}}(t,e);if(!n?.get)return void va(`${String(e)} is not defined in ${t.constructor.name}`);const i=n.get,s={get:r?function(){return e in this.__cache__?gr.enabled&&gr.cacheHit++:(gr.enabled&&gr.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?gr.enabled&&gr.cacheHit++:(gr.enabled&&gr.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};n.set&&(s.set=n.set),Object.defineProperty(t,e,s)}var Ma="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Sa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ka(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 Aa,za={exports:{}};var Ta=(Aa||(Aa=1,function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var s=e&&e.prototype instanceof y?e:y,o=Object.create(s.prototype),a=new O(n||[]);return i(o,"_invoke",{value:A(t,r,a)}),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function y(){}function b(){}function x(){}var v={};h(v,o,function(){return this});var w=Object.getPrototypeOf,_=w&&w(w(E([])));_&&_!==r&&n.call(_,o)&&(v=_);var M=x.prototype=y.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 r(i,s,o,a){var c=u(t[i],t,s);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,o,a)},function(t){r("throw",t,o,a)}):e.resolve(l).then(function(t){h.value=t,o(h)},function(t){return r("throw",t,o,a)})}a(c.arg)}var s;i(this,"_invoke",{value:function(t,n){function i(){return new e(function(e,i){r(t,n,e,i)})}return s=s?s.then(i,i):i()}})}function A(t,r,n){var i=d;return function(s,o){if(i===f)throw new Error("Generator is already running");if(i===m){if("throw"===s)throw o;return{value:e,done:!0}}for(n.method=s,n.arg=o;;){var a=n.delegate;if(a){var c=z(a,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=f;var h=u(t,r,n);if("normal"===h.type){if(i=n.done?m:p,h.arg===g)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function z(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,z(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var s=u(i,t.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,g;var o=s.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}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 r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=x,i(M,"constructor",{value:x,configurable:!0}),i(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,r,n,i,s){void 0===s&&(s=Promise);var o=new k(l(e,r,n,i),s);return t.isGeneratorFunction(r)?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),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,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 r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=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 r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),h=n.call(o,"finallyLoc");if(c&&h){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;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,g):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),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:E(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},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 r=[],n=0,i="",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?n=r.push(a):(a-=65536,n=r.push(55296+(a>>10),a%1024+56320)),n>=16383&&(i+=t.apply(null,r),r.length=0)}return i+t.apply(null,r)};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,r=e(t,t,t)&&e}catch(t){}return r}(),e=function(t){if(null==this)throw TypeError();var e=String(this),r=e.length,n=t?Number(t):0;if(n!=n&&(n=0),!(n<0||n>=r)){var i,s=e.charCodeAt(n);return s>=55296&&s<=56319&&r>n+1&&(i=e.charCodeAt(n+1))>=56320&&i<=57343?1024*(s-55296)+i-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,r,n){function i(o,a){if(!r[o]){if(!e[o]){if(!a&&ka)return ka(o);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[o]={exports:{}};e[o][0].call(h.exports,function(t){return i(e[o][1][t]||t)},h,h.exports,t,e,r,n)}return r[o].exports}for(var s=ka,o=0;o<n.length;o++)i(n[o]);return i}return t}()({1:[function(t,e,r){var n=t("./utils"),i=function(){var t=n.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],r=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],i=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],s=["Thousand","Million","Billion","Trillion"];function o(t,n){var o=function t(n,o,a){var c="";if(n<=19)c=(o?" and ":"")+(a?r[n]:e[n]);else if(n<100){var h=Math.floor(n/10),l=n%10;c=(o?" and ":"")+i[h-2],l>0?c+="-"+t(l,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(n<1e3){var u=Math.floor(n/100),d=n%100;c=(o?", ":"")+e[u]+" Hundred",d>0?c+=t(d,!0,a):a&&(c+="th")}else{var p=Math.floor(Math.log10(n)/3);p>s.length&&(p=s.length);var f=Math.pow(10,3*p),m=Math.floor(n/f),g=n-m*f;c=(o?", ":"")+t(m,!1,!1)+" "+s[p-1],g>0?c+=t(g,!0,a):a&&(c+="th")}return c};return o(t,!1,n)}var a={};function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),r=[0];return e.forEach(function(t){if(t<100){var e=r.pop();e>=1e3&&(r.push(e),e=0),r.push(e+t)}else r.push(r.pop()*t)}),r.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var r=t.toLowerCase();a[r]=10*(e+2),a[r.substring(0,t.length-1)+"ieth"]=a[r]}),a.hundredth=100,s.forEach(function(t,e){var r=t.toLowerCase(),n=Math.pow(10,3*(e+1));a[r]=n,a[r+"th"]=n});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 r=h[e];if(t>=r[0])return r[1]+u(t-r[0])}return""}function d(t){for(var e=0,r=1,n=t.length-1;n>=0;n--){var i=t[n],s=l[i];s<r?e-=s:(r=s,e+=s)}return e}function p(t,e){for(var r=[],n=e.charCodeAt(0);t>0;)r.unshift(String.fromCharCode((t-1)%26+n)),t=Math.floor((t-1)/26);return r.join("")}function f(t,e){for(var r=e.charCodeAt(0),n=0,i=0;i<t.length;i++)n+=(t.charCodeAt(t.length-i-1)-r+1)*Math.pow(26,i);return n}function m(t,e){if(void 0!==t)return b(t=Math.floor(t),v(e))}var g={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},y={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,r){var n,i=e<0;switch(e=Math.abs(e),r.primary){case g.LETTERS:n=p(e,r.case===y.UPPER?"A":"a");break;case g.ROMAN:n=u(e),r.case===y.UPPER&&(n=n.toUpperCase());break;case g.WORDS:n=o(e,r.ordinal),r.case===y.UPPER?n=n.toUpperCase():r.case===y.LOWER&&(n=n.toLowerCase());break;case g.DECIMAL:n=""+e;var s=r.mandatoryDigits-n.length;if(s>0){var a=new Array(s+1).join("0");n=a+n}if(48!==r.zeroCode&&(n=t(n).map(function(t){return String.fromCodePoint(t.codePointAt(0)+r.zeroCode-48)}).join("")),r.regular)for(var c=Math.floor((n.length-1)/r.groupingSeparators.position);c>0;c--){var h=n.length-c*r.groupingSeparators.position;n=n.substr(0,h)+r.groupingSeparators.character+n.substr(h)}else r.groupingSeparators.reverse().forEach(function(t){var e=n.length-t.position;n=n.substr(0,e)+t.character+n.substr(e)});if(r.ordinal){var l={1:"st",2:"nd",3:"rd"}[n[n.length-1]];(!l||n.length>1&&"1"===n[n.length-2])&&(l="th"),n+=l}break;case g.SEQUENCE:throw{code:"D3130",value:r.token}}return i&&(n="-"+n),n}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 r,n={type:"integer",primary:g.DECIMAL,case:y.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?r=e:(r=e.substring(0,i),"o"===e.substring(i+1)[0]&&(n.ordinal=!0)),r){case"A":n.case=y.UPPER;case"a":n.primary=g.LETTERS;break;case"I":n.case=y.UPPER;case"i":n.primary=g.ROMAN;break;case"W":n.case=y.UPPER,n.primary=g.WORDS;break;case"Ww":n.case=y.TITLE,n.primary=g.WORDS;break;case"w":n.primary=g.WORDS;break;default:var s=null,o=0,a=0,c=[],h=0;if(t(r).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,r=0;r<x.length;r++){var n=x[r];if(t>=n&&t<=n+9){if(e=!0,o++,h++,null===s)s=n;else if(n!==s)throw{code:"D3131"};break}}e||(35===t?(h++,a++):c.push({position:h,character:String.fromCodePoint(t)}))}),o>0){n.primary=g.DECIMAL,n.zeroCode=s,n.mandatoryDigits=o,n.optionalDigits=a;var l=function(t){if(0===t.length)return 0;for(var e=t[0].character,r=1;r<t.length;r++)if(t[r].character!==e)return 0;for(var n=t.map(function(t){return t.position}),i=function t(e,r){return 0===r?e:t(r,e%r)},s=n.reduce(i),o=1;o<=n.length;o++)if(-1===n.indexOf(o*s))return 0;return s}(c);l>0?(n.regular=!0,n.groupingSeparators={position:l,character:c[0].character}):(n.regular=!1,n.groupingSeparators=c)}else n.primary=g.SEQUENCE,n.token=r}return n}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=[],r={type:"datetime",parts:e},n=function(r,n){if(n>r){var i=t.substring(r,n);i=i.split("]]").join("]"),e.push({type:"literal",value:i})}},i=0,s=0;s<t.length;){if("["===t.charAt(s)){if("["===t.charAt(s+1)){n(i,s),e.push({type:"literal",value:"["}),i=s+=2;continue}if(n(i,s),i=s,-1===(s=t.indexOf("]",i)))throw{code:"D3135"};var o,a=t.substring(i+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 g=o.charAt(o.length-1);-1!=="atco".indexOf(g)?(c.presentation2=g,"o"===g&&(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=y.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=y.TITLE:c.names=y.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),i=s+1}s++}return n(i,s),r}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),r=new Date(e).getUTCDay();return 0===r&&(r=7),r>4?e+(8-r)*k:e-(r-1)*k},z=function t(e,r){return{year:e,month:r,nextMonth:function(){return 11===r?t(e+1,0):t(e,r+1)},previousMonth:function(){return 0===r?t(e-1,11):t(e,r-1)},nextYear:function(){return t(e+1,r)},previousYear:function(){return t(e-1,r)}}},T=function(t,e){return(e-t)/(7*k)+1},I=function(t,e){var r;switch(e){case"Y":r=t.getUTCFullYear();break;case"M":r=t.getUTCMonth()+1;break;case"D":r=t.getUTCDate();break;case"d":r=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/k+1;break;case"F":0===(r=t.getUTCDay())&&(r=7);break;case"W":var n=z(t.getUTCFullYear(),0),i=A(n),s=Date.UTC(n.year,t.getUTCMonth(),t.getUTCDate()),o=T(i,s);if(o>52)s>=A(n.nextYear())&&(o=1);else if(o<1){var a=A(n.previousYear());o=T(a,s)}r=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)}r=Math.floor(u);break;case"X":var p=z(t.getUTCFullYear(),0),f=A(p),m=A(p.nextYear()),g=t.getTime();r=g<f?p.year-1:g>=m?p.year+1:p.year;break;case"x":var y=z(t.getUTCFullYear(),t.getUTCMonth()),b=A(y),x=y.nextMonth(),v=A(x),w=t.getTime();r=w<b?y.previousMonth().month+1:w>=v?x.month+1:y.month+1;break;case"H":r=t.getUTCHours();break;case"h":r=t.getUTCHours(),0==(r%=12)&&(r=12);break;case"P":r=t.getUTCHours()>=12?"pm":"am";break;case"m":r=t.getUTCMinutes();break;case"s":r=t.getUTCSeconds();break;case"f":r=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":r="ISO"}return r},O=null;function E(t,e,r){var n=0,i=0;if(void 0!==r){var s=parseInt(r);n=Math.floor(s/100),i=s%100}var o,a=function(t,e){var r=I(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(r%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)r=S[r-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};r=M[r]}e.names===y.UPPER?r=r.toUpperCase():e.names===y.LOWER&&(r=r.toLowerCase()),e.width&&r.length>e.width.max&&(r=r.substring(0,e.width.max))}else r=b(r,e.integerFormat);else if("f"===e.component)r=b(r,e.integerFormat);else if("Z"===e.component||"z"===e.component){var s=100*n+i;if(e.integerFormat.regular)r=b(s,e.integerFormat);else{var o=e.integerFormat.mandatoryDigits;if(1===o||2===o)r=b(n,e.integerFormat),0!==i&&(r+=":"+m(i,"00"));else{if(3!==o&&4!==o)throw{code:"D3134",value:o};r=b(s,e.integerFormat)}}s>=0&&(r="+"+r),"z"===e.component&&(r="GMT"+r),0===s&&"t"===e.presentation2&&(r="Z")}return r};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*n+i)*1e3),h="";return o.parts.forEach(function(t){"literal"===t.type?h+=t.value:h+=a(c,t)}),h}function P(t){var e={};if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e={};if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var r;Array.isArray(t.integerFormat.groupingSeparators)||(r=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",r&&(e.regex+=r.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var n=0,i=0;return r?(n=Number.parseInt(e.substring(0,e.indexOf(r.character))),i=Number.parseInt(e.substring(e.indexOf(r.character)+1))):e.length-1<=2?n=Number.parseInt(e):(n=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*n+i}}else if(t.integerFormat)t.integerFormat.n=t.n,e=P(t.integerFormat);else{e.regex="[a-zA-Z]+";var n={};if("M"===t.component||"x"===t.component)S.forEach(function(e,r){t.width&&t.width.max?n[e.substring(0,t.width.max)]=r+1:n[e]=r+1});else if("F"===t.component)M.forEach(function(e,r){r>0&&(t.width&&t.width.max?n[e.substring(0,t.width.max)]=r:n[e]=r)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};n={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return n[t]}}return e.component=t.component,e});else{e.type="integer";var r,n=t.case===y.UPPER;switch(r=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case g.LETTERS:e.regex=n?"[A-Z]+":"[a-z]+",e.parse=function(t){return f(t,n?"A":"a")};break;case g.ROMAN:e.regex=n?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return d(n?t:t.toUpperCase())};break;case g.WORDS:e.regex="(?:"+Object.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case g.DECIMAL:e.regex="[0-9]".concat(r),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var r=e;return t.ordinal&&(r=e.substring(0,e.length-2)),t.regular?r=r.split(",").join(""):t.groupingSeparators.forEach(function(t){r=r.split(t.character).join("")}),48!==t.zeroCode&&(r=r.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(r)};break;case g.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function j(t,e){if(void 0!==t)return P(v(e)).parse(t)}function C(t,e){var r=P(_(e)),n="^"+r.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(n,"i").exec(t);if(null!==i){for(var s=161,o=130,a=84,c=72,h=23,l=47,u={},d=1;d<i.length;d++){var p=r.parts[d-1];p.parse&&(u[p.component]=p.parse(i[d]))}if(0===Object.getOwnPropertyNames(u).length)return;var f=0,m=function(t){f<<=1,f+=t?1:0},g=function(t){return!(~t&f||!(t&f))};"YXMxWwdD".split("").forEach(function(t){return m(u[t])});var y=!g(s)&&g(o),b=g(a),x=!b&&g(c);f=0,"PHhmsf".split("").forEach(function(t){return m(u[t])});var v=!g(h)&&g(l),w=(y?"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,y){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,r){if(void 0!==t)return E.call(this,t,e,r)}return{formatInteger:m,parseInteger:j,fromMillis:D,toMillis:F}}();e.exports=i},{"./utils":6}],2:[function(t,e,r){(function(r){(function(){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,s=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",h=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,s=Object.create(i.prototype),a=new P(n||[]);return o(s,"_invoke",{value:T(t,r,a)}),s}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",m="suspendedYield",g="executing",y="completed",b={};function x(){}function v(){}function w(){}var _={};u(_,c,function(){return this});var M=Object.getPrototypeOf,S=M&&M(M(j([])));S&&S!==r&&s.call(S,c)&&(_=S);var k=w.prototype=x.prototype=Object.create(_);function A(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function z(t,e){function r(i,o,a,c){var h=p(t[i],t,o);if("throw"!==h.type){var l=h.arg,u=l.value;return u&&"object"==n(u)&&s.call(u,"__await")?e.resolve(u.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(u).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,c)})}c(h.arg)}var i;o(this,"_invoke",{value:function(t,n){function s(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(s,s):s()}})}function T(e,r,n){var i=f;return function(s,o){if(i===g)throw new Error("Generator is already running");if(i===y){if("throw"===s)throw o;return{value:t,done:!0}}for(n.method=s,n.arg=o;;){var a=n.delegate;if(a){var c=I(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=g;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?y:m,h.arg===b)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=y,n.method="throw",n.arg=h.arg)}}}function I(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var s=p(i,e.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,b;var o=s.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function j(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(s.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(n(e)+" is not iterable")}return v.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=u(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,u(t,l,"GeneratorFunction")),t.prototype=Object.create(k),t},e.awrap=function(t){return{__await:t}},A(z.prototype),u(z.prototype,h,function(){return this}),e.AsyncIterator=z,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var o=new z(d(t,r,n,i),s);return e.isGeneratorFunction(r)?o:o.next().then(function(t){return t.done?t.value:o.next()})},A(k),u(k,l,"Generator"),u(k,c,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=j,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&s.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),h=s.call(o,"finallyLoc");if(c&&h){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:j(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var s=t("./utils"),o=function(){var t=i().mark(U),e=i().mark(Y),o=i().mark(W),a=i().mark(q),c=i().mark(J),h=i().mark(dt),l=i().mark(pt),u=i().mark(ft),d=i().mark(gt),p=i().mark(St),f=i().mark(Tt),m=i().mark(Et),g=s.isNumeric,y=s.isArrayOfStrings,b=s.isArrayOfNumbers,x=s.createSequence,v=s.isSequence,w=s.isFunction,_=s.isLambda,M=s.isIterable,S=s.getFunctionArity,k=s.isDeepEqual,A=s.stringToArray;function z(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function T(t){return void 0===t?0:t.length}function I(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function O(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function E(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function P(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var r;if("string"==typeof t)r=t;else if(w(t))r="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var n=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),r=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&g(e)?Number(e.toPrecision(15)):e&&w(e)?"":e},n)}return r}}function j(t,e,r){if(void 0!==t){var n=A(t),i=n.length;if(i+e<0&&(e=0),void 0!==r){if(r<=0)return"";var s=e>=0?e+r:i+e+r;return n.slice(e,s).join("")}return n.slice(e).join("")}}function C(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function R(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function F(t){if(void 0!==t)return t.toLowerCase()}function D(t){if(void 0!==t)return t.toUpperCase()}function N(t){if(void 0!==t)return A(t).length}function L(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 B(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-N(t);if(i>0){var s=new Array(i+1).join(r);r.length>1&&(s=j(s,0,i)),n=e>0?t+s:s+t}else n=t;return n}}function U(e,r){var n;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.apply(this,[r]),!M(n)){t.next=4;break}return t.delegateYield(n,"t0",3);case 3:n=t.t0;case 4:if(!n||"number"==typeof n.start||"number"===n.end||Array.isArray(n.groups)||w(n.next)){t.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}},t,this)}function Y(t,r){var n,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t){e.next=2;break}return e.abrupt("return",void 0);case 2:if("string"!=typeof r){e.next=6;break}n=-1!==t.indexOf(r),e.next=9;break;case 6:return e.delegateYield(U(r,t),"t0",7);case 7:s=e.t0,n=void 0!==s;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e)}function W(t,e,r){var n,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{stack:(new Error).stack,value:r,code:"D3040",index:3};case 4:if(n=x(),!(void 0===r||r>0)){i.next=17;break}return s=0,i.delegateYield(U(e,t),"t0",8);case 8:if(void 0===(a=i.t0)){i.next=17;break}case 10:if(void 0===a||!(void 0===r||s<r)){i.next=17;break}return n.push({match:a.match,index:a.start,groups:a.groups}),i.delegateYield(U(a.next),"t1",13);case 13:a=i.t1,s++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}},o)}function q(t,e,r,n){var s,o,c,h,l,u,d,p;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(s=this,""!==e){i.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(n<0)){i.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:n,index:4};case 7:if(o="string"==typeof r?function(t){for(var e="",n=0,i=r.indexOf("$",n);-1!==i&&n<r.length;){e+=r.substring(n,i),n=i+1;var s=r.charAt(n);if("$"===s)e+="$",n++;else if("0"===s)e+=t.match,n++;else{var o;if(o=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+o),10),o>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+o-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,c="",h=0,!(void 0===n||n>0)){i.next=44;break}if(l=0,"string"!=typeof e){i.next=18;break}for(u=t.indexOf(e,h);-1!==u&&(void 0===n||l<n);)c+=t.substring(h,u),c+=r,h=u+e.length,l++,u=t.indexOf(e,h);c+=t.substring(h),i.next=42;break;case 18:return i.delegateYield(U(e,t),"t0",19);case 19:if(void 0===(d=i.t0)){i.next=41;break}case 21:if(void 0===d||!(void 0===n||l<n)){i.next=38;break}if(c+=t.substring(h,d.start),p=o.apply(s,[d]),!M(p)){i.next=27;break}return i.delegateYield(p,"t1",26);case 26:p=i.t1;case 27:if("string"!=typeof p){i.next=31;break}c+=p,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:p};case 32:return h=d.start+d.match.length,l++,i.delegateYield(U(d.next),"t2",35);case 35:d=i.t2,i.next=21;break;case 38:c+=t.substring(h),i.next=42;break;case 41:c=t;case 42:i.next=45;break;case 44:c=t;case 45:return i.abrupt("return",c);case 46:case"end":return i.stop()}},a,this)}function $(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new r.Buffer.from(t,"binary").toString("base64")};return e(t)}}function V(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new r.Buffer.from(t,"base64").toString("binary")};return e(t)}}function H(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 G(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 X(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 Z(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 J(t,e,r){var n,s,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:r,index:3};case 4:if(n=[],!(void 0===r||r>0)){i.next=27;break}if("string"!=typeof e){i.next=10;break}n=t.split(e,r),i.next=27;break;case 10:return s=0,i.delegateYield(U(e,t),"t0",12);case 12:if(void 0===(o=i.t0)){i.next=26;break}a=0;case 15:if(void 0===o||!(void 0===r||s<r)){i.next=23;break}return n.push(t.substring(a,o.start)),a=o.end,i.delegateYield(U(o.next),"t1",19);case 19:o=i.t1,s++,i.next=15;break;case 23:(void 0===r||s<r)&&n.push(t.substring(a)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}},c)}function Q(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function K(t,e,r){if(void 0!==t){var n={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==r&&Object.keys(r).forEach(function(t){n[t]=r[t]});for(var i=[],s=n["zero-digit"].charCodeAt(0),o=s;o<s+10;o++)i.push(String.fromCharCode(o));var a=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),c=e.split(n["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var h=function(t){var e,r,i,s,o=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),c=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),h=t.substring(o.length,t.length-c.length),l=t.indexOf(n["exponent-separator"],o.length);-1===l||l>t.length-c.length?(e=h,r=void 0):(e=h.substring(0,l),r=h.substring(l+1));var u=e.indexOf(n["decimal-separator"]);return-1===u?(i=e,s=c):(i=e.substring(0,u),s=e.substring(u+1)),{prefix:o,suffix:c,activePart:h,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:s,subpicture:t}},l=function(t){var e,r,s=t.subpicture,o=s.indexOf(n["decimal-separator"]);o!==s.lastIndexOf(n["decimal-separator"])&&(e="D3081"),s.indexOf(n.percent)!==s.lastIndexOf(n.percent)&&(e="D3082"),s.indexOf(n["per-mille"])!==s.lastIndexOf(n["per-mille"])&&(e="D3083"),-1!==s.indexOf(n.percent)&&-1!==s.indexOf(n["per-mille"])&&(e="D3084");var c=!1;for(r=0;r<t.mantissaPart.length;r++){var h=t.mantissaPart.charAt(r);if(-1!==i.indexOf(h)||h===n.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)!==n["grouping-separator"]&&s.charAt(o+1)!==n["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===n["grouping-separator"]&&(e="D3088"),-1!==s.indexOf(n["grouping-separator"]+n["grouping-separator"])&&(e="D3089");var l=t.integerPart.indexOf(n.digit);-1!==l&&t.integerPart.substring(0,l).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(l=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(l).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var u="string"==typeof t.exponentPart;if(u&&t.exponentPart.length>0&&(-1!==s.indexOf(n.percent)||-1!==s.indexOf(n["per-mille"]))&&(e="D3092"),u&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===i.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},u=function(t){var e=function(e,r){for(var s=[],o=e.indexOf(n["grouping-separator"]);-1!==o;){var a=(r?e.substring(0,o):e.substring(o)).split("").filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length;s.push(a),o=t.integerPart.indexOf(n["grouping-separator"],o+1)}return s},r=e(t.integerPart),s=function(t){if(0===t.length)return 0;for(var e=function t(e,r){return 0===r?e:t(r,e%r)},r=t.reduce(e),n=1;n<=t.length;n++)if(-1===t.indexOf(n*r))return 0;return r}(r),o=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,h=t.fractionalPart.split(""),l=h.filter(function(t){return-1!==i.indexOf(t)}).length,u=h.filter(function(t){return-1!==i.indexOf(t)||t===n.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(n.digit)&&(a=1),0===a&&0===l&&(l=1);var p=0;return d&&(p=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:r,regularGrouping:s,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:o,minimumFactionalPartSize:l,maximumFactionalPartSize:u,minimumExponentSize:p,suffix:t.suffix,picture:t.subpicture}},d=c.map(h);d.forEach(l);var p,f,m,g,y=d.map(u),b=n["minus-sign"],x=n["zero-digit"],v=n["decimal-separator"],w=n["grouping-separator"];if(1===y.length&&(y.push(JSON.parse(JSON.stringify(y[0]))),y[1].prefix=b+y[1].prefix),f=-1!==(p=t>=0?y[0]:y[1]).picture.indexOf(n.percent)?100*t:-1!==p.picture.indexOf(n["per-mille"])?1e3*t:t,0===p.minimumExponentSize)m=f;else{var _=Math.pow(10,p.scalingFactor),M=Math.pow(10,p.scalingFactor-1);for(m=f,g=0;m<M;)m*=10,g-=1;for(;m>_;)m/=10,g+=1}var S=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==x&&(r=r.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),r},k=S(st(m,p.maximumFactionalPartSize),p.maximumFactionalPartSize),A=k.indexOf(".");for(-1===A?k+=v:k=k.replace(".",v);k.charAt(0)===x;)k=k.substring(1);for(;k.charAt(k.length-1)===x;)k=k.substring(0,k.length-1);A=k.indexOf(v);var z=p.minimumIntegerPartSize-A,T=p.minimumFactionalPartSize-(k.length-A-1);if(k=(z>0?new Array(z+1).join(x):"")+k,k+=T>0?new Array(T+1).join(x):"",A=k.indexOf(v),p.regularGrouping>0)for(var I=Math.floor((A-1)/p.regularGrouping),O=1;O<=I;O++)k=[k.slice(0,A-O*p.regularGrouping),w,k.slice(A-O*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach(function(t){k=[k.slice(0,A-t),w,k.slice(A-t)].join(""),A++});if(A=k.indexOf(v),p.fractionalPartGroupingPositions.forEach(function(t){k=[k.slice(0,t+A+1),w,k.slice(t+A+1)].join("")}),A=k.indexOf(v),-1!==p.picture.indexOf(v)&&A!==k.length-1||(k=k.substring(0,k.length-1)),void 0!==g){var E=S(g,0);(z=p.minimumExponentSize-E.length)>0&&(E=new Array(z+1).join(x)+E),k=k+n["exponent-separator"]+(g<0?b:"")+E}return k=p.prefix+k+p.suffix}}function tt(t,e){if(void 0!==t){if(t=st(t),(e=void 0===e?10:st(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function et(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 nt(t){if(void 0!==t)return Math.floor(t)}function it(t){if(void 0!==t)return Math.ceil(t)}function st(t,e){var r;if(void 0!==t){if(e){var n=t.toString().split("e");t=+(n[0]+"e"+(n[1]?+n[1]+e:e))}var i=(r=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(r%2)&&(r-=1),e&&(n=r.toString().split("e"),r=+(n[0]+"e"+(n[1]?+n[1]-e:-e))),Object.is(r,-0)&&(r=0),r}}function ot(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function at(t,e){var r;if(void 0!==t){if(r=Math.pow(t,e),!isFinite(r))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return r}}function ct(){return Math.random()}function ht(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ht(t[0]):t.length>1&&(e=t.filter(function(t){return ht(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):g(t)?0!==t&&(e=!0):null!==t&&"object"===n(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function lt(t){if(void 0!==t)return!ht(t)}function ut(t,e,r,n){var i=[e],s=S(t);return s>=2&&i.push(r),s>=3&&i.push(n),i}function dt(t,e){var r,n,s,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=x(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return s=ut(e,t[n],n,t),i.delegateYield(e.apply(this,s),"t0",7);case 7:void 0!==(o=i.t0)&&r.push(o);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}},h,this)}function pt(t,e){var r,n,s,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=x(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return s=t[n],o=ut(e,s,n,t),i.delegateYield(e.apply(this,o),"t0",8);case 8:ht(i.t0)&&r.push(s);case 10:n++,i.next=4;break;case 13:return i.abrupt("return",r);case 14:case"end":return i.stop()}},l,this)}function ft(t,e){var r,n,s,o,a,c,h;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=!1,s=0;case 4:if(!(s<t.length)){i.next=22;break}if(o=t[s],a=!0,void 0===e){i.next=12;break}return c=ut(e,o,s,t),i.delegateYield(e.apply(this,c),"t0",10);case 10:h=i.t0,a=ht(h);case 12:if(!a){i.next=19;break}if(r){i.next=18;break}n=o,r=!0,i.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:s};case 19:s++,i.next=4;break;case 22:if(r){i.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return i.abrupt("return",n);case 25:case"end":return i.stop()}},u,this)}function mt(){for(var t=[],e=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),n=0;n<r;n++){var i=e.map(function(t){return t[n]});t.push(i)}return t}function gt(t,e,r){var n,s,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!((s=S(e))<2)){i.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===r&&t.length>0?(n=t[0],o=1):(n=r,o=0);case 6:if(!(o<t.length)){i.next=15;break}return a=[n,t[o]],s>=3&&a.push(o),s>=4&&a.push(t),i.delegateYield(e.apply(this,a),"t0",11);case 11:n=i.t0,o++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},d,this)}function yt(t){var e=x();if(Array.isArray(t)){var r={};t.forEach(function(t){yt(t).forEach(function(t){r[t]=!0})}),e=yt(r)}else null===t||"object"!==n(t)||_(t)||Object.keys(t).forEach(function(t){return e.push(t)});return e}function bt(t,e){var r;if(Array.isArray(t)){r=x();for(var i=0;i<t.length;i++){var s=bt(t[i],e);void 0!==s&&(Array.isArray(s)?s.forEach(function(t){return r.push(t)}):r.push(s))}}else null!==t&&"object"===n(t)&&(r=t[e]);return r}function xt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=x(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function vt(t){return void 0!==t}function wt(t){var e=x();if(Array.isArray(t))t.forEach(function(t){e=xt(e,wt(t))});else if(null===t||"object"!==n(t)||_(t))e=t;else for(var r in t){var i={};i[r]=t[r],e.push(i)}return e}function _t(t){if(void 0!==t){var e={};return t.forEach(function(t){for(var r in t)e[r]=t[r]}),e}}function Mt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,r=new Array(e),n=0;n<e;n++)r[e-n-1]=t[n];return r}}function St(t,e){var r,n,s,o;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r=x(),a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return n=a.t1.value,s=ut(e,t[n],n,t),a.delegateYield(e.apply(this,s),"t2",6);case 6:void 0!==(o=a.t2)&&r.push(o),a.next=2;break;case 10:return a.abrupt("return",r);case 11:case"end":return a.stop()}},p,this)}function kt(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function At(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function zt(t){if(void 0!==t)return null===t?"null":g(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":w(t)?"function":"object"}function Tt(t,e){var r,n,s,o;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==t){a.next=2;break}return a.abrupt("return",void 0);case 2:if(!(t.length<=1)){a.next=4;break}return a.abrupt("return",t);case 4:if(void 0!==e){a.next=10;break}if(b(t)||y(t)){a.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:r=i().mark(function t(e,r){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>r);case 1:case"end":return t.stop()}},t)}),a.next=11;break;case 10:r=e;case 11:return n=i().mark(function t(e,n){var s,o;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=i().mark(function t(e,n,s){return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(0!==n.length){i.next=4;break}Array.prototype.push.apply(e,s),i.next=16;break;case 4:if(0!==s.length){i.next=8;break}Array.prototype.push.apply(e,n),i.next=16;break;case 8:return i.delegateYield(r(n[0],s[0]),"t0",9);case 9:if(!i.t0){i.next=14;break}return e.push(s[0]),i.delegateYield(t(e,n,s.slice(1)),"t1",12);case 12:i.next=16;break;case 14:return e.push(n[0]),i.delegateYield(t(e,n.slice(1),s),"t2",16);case 16:case"end":return i.stop()}},t)}),o=[],t.delegateYield(s(o,e,n),"t0",3);case 3:return t.abrupt("return",o);case 4:case"end":return t.stop()}},t)}),s=i().mark(function t(e){var r,s,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){i.next=4;break}return i.abrupt("return",e);case 4:return r=Math.floor(e.length/2),s=e.slice(0,r),o=e.slice(r),i.delegateYield(t(s),"t0",8);case 8:return s=i.t0,i.delegateYield(t(o),"t1",10);case 10:return o=i.t1,i.delegateYield(n(s,o),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}},t)}),a.delegateYield(s(t),"t0",14);case 14:return o=a.t0,a.abrupt("return",o);case 16:case"end":return a.stop()}},f)}function It(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),r=0;r<t.length;r++){var n=Math.floor(Math.random()*(r+1));r!==n&&(e[r]=e[n]),e[n]=t[r]}return e}}function Ot(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=v(t)?x():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,s=0;s<e.length;s++)if(k(n,e[s])){i=!0;break}i||e.push(n)}return e}}function Et(t,e){var r,n,s,o;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r={},a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=11;break}return n=a.t1.value,s=t[n],o=ut(e,s,n,t),a.delegateYield(e.apply(this,o),"t2",7);case 7:ht(a.t2)&&(r[n]=s),a.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),a.abrupt("return",r);case 13:case"end":return a.stop()}},m,this)}return{sum:z,count:T,max:I,min:O,average:E,string:P,substring:j,substringBefore:C,substringAfter:R,lowercase:F,uppercase:D,length:N,trim:L,pad:B,match:W,contains:Y,replace:q,split:J,join:Q,formatNumber:K,formatBase:tt,number:et,floor:nt,ceil:it,round:st,abs:rt,sqrt:ot,power:at,random:ct,boolean:ht,not:lt,map:dt,zip:mt,filter:pt,single:ft,foldLeft:gt,sift:Et,keys:yt,lookup:bt,append:xt,exists:vt,spread:wt,merge:_t,reverse:Mt,each:St,error:kt,assert:At,type:zt,sort:Tt,shuffle:It,distinct:Ot,base64encode:$,base64decode:V,encodeUrlComponent:H,encodeUrl:G,decodeUrlComponent:X,decodeUrl:Z}}();e.exports=o}).call(this)}).call(this,void 0!==Ma?Ma:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,r){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,s=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",h=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,s=Object.create(i.prototype),a=new P(n||[]);return o(s,"_invoke",{value:T(t,r,a)}),s}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",m="suspendedYield",g="executing",y="completed",b={};function x(){}function v(){}function w(){}var _={};u(_,c,function(){return this});var M=Object.getPrototypeOf,S=M&&M(M(j([])));S&&S!==r&&s.call(S,c)&&(_=S);var k=w.prototype=x.prototype=Object.create(_);function A(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function z(t,e){function r(i,o,a,c){var h=p(t[i],t,o);if("throw"!==h.type){var l=h.arg,u=l.value;return u&&"object"==n(u)&&s.call(u,"__await")?e.resolve(u.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(u).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,c)})}c(h.arg)}var i;o(this,"_invoke",{value:function(t,n){function s(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(s,s):s()}})}function T(e,r,n){var i=f;return function(s,o){if(i===g)throw new Error("Generator is already running");if(i===y){if("throw"===s)throw o;return{value:t,done:!0}}for(n.method=s,n.arg=o;;){var a=n.delegate;if(a){var c=I(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=g;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?y:m,h.arg===b)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=y,n.method="throw",n.arg=h.arg)}}}function I(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var s=p(i,e.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,b;var o=s.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function j(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(s.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(n(e)+" is not iterable")}return v.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=u(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,u(t,l,"GeneratorFunction")),t.prototype=Object.create(k),t},e.awrap=function(t){return{__await:t}},A(z.prototype),u(z.prototype,h,function(){return this}),e.AsyncIterator=z,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var o=new z(d(t,r,n,i),s);return e.isGeneratorFunction(r)?o:o.next().then(function(t){return t.done?t.value:o.next()})},A(k),u(k,l,"Generator"),u(k,c,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=j,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&s.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),h=s.call(o,"finallyLoc");if(c&&h){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:j(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var s=t("./datetime"),o=t("./functions"),a=t("./utils"),c=t("./parser"),h=t("./signature"),l=function(){var t=i().mark(B),e=i().mark(U),r=i().mark(W),l=i().mark(q),u=i().mark($),d=i().mark(V),p=i().mark(H),f=i().mark(G),m=i().mark(st),g=i().mark(ct),y=i().mark(ut),b=i().mark(dt),x=i().mark(pt),v=i().mark(gt),w=i().mark(xt),_=i().mark(vt),M=i().mark(wt),S=i().mark(_t),k=i().mark(St),A=i().mark(At),z=i().mark(It),T=i().mark(Pt),I=a.isNumeric,O=a.isArrayOfStrings,E=a.isArrayOfNumbers,P=a.createSequence,j=a.isSequence,C=a.isFunction,R=a.isLambda,F=a.isIterable,D=a.getFunctionArity,N=a.isDeepEqual,L=Ct(null);function B(e,r,n){var s,o,a,c;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:(o=n.lookup("__evaluate_entry"))&&o(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield(U(e,r,n),"t1",6);case 6:return s=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(H(e,r,n),"t2",9);case 9:return s=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(G(e,r,n),"t3",12);case 12:return s=t.t3,t.abrupt("break",50);case 14:return s=X(e,r),t.abrupt("break",50);case 16:return s=Z(e),t.abrupt("break",50);case 18:return s=J(e,r),t.abrupt("break",50);case 20:return s=K(e,r),t.abrupt("break",50);case 22:return s=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(dt(e,r,n),"t4",25);case 25:return s=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,r,n),"t5",28);case 28:return s=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ut(e,r,n),"t6",31);case 31:return s=t.t6,t.abrupt("break",50);case 33:return s=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(vt(e,r,n),"t7",36);case 36:return s=t.t7,t.abrupt("break",50);case 38:return s=mt(e,r,n),t.abrupt("break",50);case 40:return s=Mt(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(St(e,r,n),"t8",43);case 43:return s=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(xt(e,r,n),"t9",46);case 46:return s=t.t9,t.abrupt("break",50);case 48:return s=yt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=s&&"function"==typeof s.then||(s=Promise.resolve(s)),!n.async||"function"!=typeof s.then||!e.nextFunction||"function"!=typeof s[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,s;case 56:s=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}a=0;case 59:if(!(a<e.predicate.length)){t.next=65;break}return t.delegateYield(V(e.predicate[a].expr,s,n),"t10",61);case 61:s=t.t10;case 62:a++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,s,n),"t11",67);case 67:s=t.t11;case 68:return(c=n.lookup("__evaluate_exit"))&&c(e,r,n,s),s&&j(s)&&!s.tupleStream&&(e.keepArray&&(s.keepSingleton=!0),0===s.length?s=void 0:1===s.length&&(s=s.keepSingleton?s:s[0])),t.abrupt("return",s);case 72:case"end":return t.stop()}},t)}function U(t,r,n){var s,o,a,c,h,l;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:s=Array.isArray(r)&&"variable"!==t.steps[0].type?r:P(r),a=!1,c=void 0,h=0;case 4:if(!(h<t.steps.length)){e.next=25;break}if((l=t.steps[h]).tuple&&(a=!0),0!==h||!l.consarray){e.next=12;break}return e.delegateYield(B(l,s,n),"t0",9);case 9:o=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield($(l,s,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(W(l,s,n,h===t.steps.length-1),"t2",18);case 18:o=e.t2;case 19:if(a||void 0!==o&&0!==o.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===l.focus&&(s=o);case 22:h++,e.next=4;break;case 25:if(a)if(t.tuple)o=c;else for(o=P(),h=0;h<c.length;h++)o.push(c[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=P(o)),o.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,a?c:o,n),"t3",29);case 29:o=e.t3;case 30:return e.abrupt("return",o);case 31:case"end":return e.stop()}},e)}function Y(t,e){var r=Ct(t);for(var n in e)r.bind(n,e[n]);return r}function W(t,e,n,s){var o,a,c,h,l;return i().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(gt(t,e,n),"t0",2);case 2:if(o=r.t0,!t.stages){r.next=6;break}return r.delegateYield(q(t.stages,o,n),"t1",5);case 5:o=r.t1;case 6:return r.abrupt("return",o);case 7:o=P(),a=0;case 9:if(!(a<e.length)){r.next=24;break}return r.delegateYield(B(t,e[a],n),"t2",11);case 11:if(c=r.t2,!t.stages){r.next=20;break}h=0;case 14:if(!(h<t.stages.length)){r.next=20;break}return r.delegateYield(V(t.stages[h].expr,c,n),"t3",16);case 16:c=r.t3;case 17:h++,r.next=14;break;case 20:void 0!==c&&o.push(c);case 21:a++,r.next=9;break;case 24:return l=P(),s&&1===o.length&&Array.isArray(o[0])&&!j(o[0])?l=o[0]:o.forEach(function(t){!Array.isArray(t)||t.cons?l.push(t):t.forEach(function(t){return l.push(t)})}),r.abrupt("return",l);case 27:case"end":return r.stop()}},r)}function q(t,e,r){var n,s,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:n=e,s=0;case 2:if(!(s<t.length)){i.next=15;break}o=t[s],i.t0=o.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(V(o.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(a=0;a<n.length;a++)n[a][o.value]=a;return i.abrupt("break",12);case 12:s++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},l)}function $(t,e,r,n){var s,o,a,c,h,l,d,p;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(gt(t,r,n),"t0",3);case 3:s=i.t0,i.next=11;break;case 6:return i.delegateYield(gt(t,e,n),"t1",7);case 7:for(o=i.t1,(s=P()).tupleStream=!0,a=0;a<o.length;a++)(c={"@":o[a]})[t.index]=a,s.push(c);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(q(t.stages,s,n),"t2",13);case 13:s=i.t2;case 14:return i.abrupt("return",s);case 15:(s=P()).tupleStream=!0,h=n,void 0===r&&(r=e.map(function(t){return{"@":t}})),l=0;case 20:if(!(l<r.length)){i.next=28;break}return h=Y(n,r[l]),i.delegateYield(B(t,r[l]["@"],h),"t3",23);case 23:if(void 0!==(d=i.t3))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)c={},Object.assign(c,r[l]),d.tupleStream?Object.assign(c,d[p]):(t.focus?(c[t.focus]=d[p],c["@"]=r[l]["@"]):c["@"]=d[p],t.index&&(c[t.index]=p),t.ancestor&&(c[t.ancestor.label]=r[l]["@"])),s.push(c);case 25:l++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(q(t.stages,s,n),"t4",30);case 30:s=i.t4;case 31:return i.abrupt("return",s);case 32:case"end":return i.stop()}},u)}function V(t,e,r){var n,s,a,c,h,l;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=P(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=P(e)),"number"!==t.type){i.next=10;break}(s=Math.floor(t.value))<0&&(s=e.length+s),void 0!==(a=e[s])&&(Array.isArray(a)?n=a:n.push(a)),i.next=23;break;case 10:s=0;case 11:if(!(s<e.length)){i.next=23;break}return a=e[s],c=a,h=r,e.tupleStream&&(c=a["@"],h=Y(r,a)),i.delegateYield(B(t,c,h),"t0",17);case 17:l=i.t0,I(l)&&(l=[l]),E(l)?l.forEach(function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===s&&n.push(a)}):o.boolean(l)&&n.push(a);case 20:s++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}},d)}function H(t,e,r){var n,s,o,a,c;return i().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.delegateYield(B(t.lhs,e,r),"t0",1);case 1:if(s=h.t0,o=t.value,a=i().mark(function n(){return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(B(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}},n)}),"and"!==o&&"or"!==o){h.next=15;break}return h.prev=5,h.delegateYield(st(s,a,o),"t1",7);case 7:return h.abrupt("return",h.t1);case 10:throw h.prev=10,h.t2=h.catch(5),h.t2.position=t.position,h.t2.token=o,h.t2;case 15:return h.delegateYield(a(),"t3",16);case 16:c=h.t3,h.prev=17,h.t4=o,h.next="+"===h.t4||"-"===h.t4||"*"===h.t4||"/"===h.t4||"%"===h.t4?21:"="===h.t4||"!="===h.t4?23:"<"===h.t4||"<="===h.t4||">"===h.t4||">="===h.t4?25:"&"===h.t4?27:".."===h.t4?29:"in"===h.t4?31:33;break;case 21:return n=et(s,c,o),h.abrupt("break",33);case 23:return n=rt(s,c,o),h.abrupt("break",33);case 25:return n=nt(s,c,o),h.abrupt("break",33);case 27:return n=at(s,c),h.abrupt("break",33);case 29:return n=lt(s,c),h.abrupt("break",33);case 31:return n=it(s,c),h.abrupt("break",33);case 33:h.next=40;break;case 35:throw h.prev=35,h.t5=h.catch(17),h.t5.position=t.position,h.t5.token=o,h.t5;case 40:return h.abrupt("return",n);case 41:case"end":return h.stop()}},p,null,[[5,10],[17,35]])}function G(t,e,r){var n,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(B(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!I(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],s=0;case 17:if(!(s<t.expressions.length)){i.next=25;break}return a=t.expressions[s],i.delegateYield(B(a,e,r),"t2",20);case 20:void 0!==(c=i.t2)&&("["===a.value?n.push(c):n=o.append(n,c));case 22:s++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(ct(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}},f)}function X(t,e,r){return o.lookup(e,t.value)}function Z(t){return t.value}function J(t,e){var r=P();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach(function(t){var n=e[t];Array.isArray(n)?(n=Q(n),r=o.append(r,n)):r.push(n)}),r}function Q(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach(function(t){Q(t,e)}):e.push(t),e}function K(t,e){var r,n=P();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach(function(t){tt(t,e)}):null!==t&&"object"===n(t)&&Object.keys(t).forEach(function(r){tt(t[r],e)})}function et(t,e,r){var n;if(void 0!==t&&!I(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!I(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,s=n(t),o=n(e);if("undefined"===s||"undefined"===o)return!1;switch(r){case"=":i=N(t,e);break;case"!=":i=!N(t,e)}return i}function nt(t,e,r){var i,s=n(t),o=n(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(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function st(t,e,r){var n,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:s=ot(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=s,!i.t1){i.next=10;break}return i.t2=ot,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=s,i.t5){i.next=18;break}return i.t6=ot,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},m)}function ot(t){var e=o.boolean(t);return void 0!==e&&e}function at(t,e){var r="",n="";return void 0!==t&&(r=o.string(t)),void 0!==e&&(n=o.string(e)),r.concat(n)}function ct(t,e,r){var n,s,a,c,h,l,u,d,p,f,m,y,b;return i().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:n={},s={},a=!(!e||!e.tupleStream),Array.isArray(e)||(e=P(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){g.next=31;break}h=e[c],l=a?Y(r,h):r,u=0;case 10:if(!(u<t.lhs.length)){g.next=28;break}return d=t.lhs[u],g.delegateYield(B(d[0],a?h["@"]:h,l),"t0",13);case 13:if("string"==typeof(p=g.t0)||void 0===p){g.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){g.next=25;break}if(f={data:h,exprIndex:u},!s.hasOwnProperty(p)){g.next=24;break}if(s[p].exprIndex===u){g.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:s[p].data=o.append(s[p].data,h),g.next=25;break;case 24:s[p]=f;case 25:u++,g.next=10;break;case 28:c++,g.next=6;break;case 31:g.t1=i().keys(s);case 32:if((g.t2=g.t1()).done){g.next=43;break}return p=g.t2.value,f=s[p],m=f.data,l=r,a&&(y=ht(f.data),m=y["@"],delete y["@"],l=Y(r,y)),g.delegateYield(B(t.lhs[f.exprIndex][1],m,l),"t3",39);case 39:void 0!==(b=g.t3)&&(n[p]=b),g.next=32;break;case 43:return g.abrupt("return",n);case 44:case"end":return g.stop()}},g)}function ht(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=o.append(e[n],t[r][n]);return e}function lt(t,e){var r;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 r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,s=0;i<=e;i++,s++)r[s]=i;return r.sequence=!0,r}function ut(t,e,r){var n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}},y)}function dt(t,e,r){var n,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.condition,e,r),"t0",1);case 1:if(s=i.t0,!o.boolean(s)){i.next=7;break}return i.delegateYield(B(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(B(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}},b)}function pt(t,e,r){var n,s,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:s=Ct(r),o=0;case 2:if(!(o<t.expressions.length)){i.next=8;break}return i.delegateYield(B(t.expressions[o],e,s),"t0",4);case 4:n=i.t0;case 5:o++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}},x)}function ft(t){var e=new Dt.RegexEngine(t.value),r=function r(n,i){var s;e.lastIndex=i||0;var o=e.exec(n);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>=n.length)){var i=r(n,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return s};return r}function mt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function gt(t,e,r){var s,a,c,h,l;return i().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return a=e,c=!!e.tupleStream,h=i().mark(function e(s,o){var a,h,l,u,d,p,f,m,g;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,h=0;case 2:if(!(0===a&&h<t.terms.length)){e.next=35;break}return l=t.terms[h],u=s,d=r,c&&(u=s["@"],d=Y(r,s)),e.delegateYield(B(l.expression,u,d),"t0",8);case 8:return p=e.t0,u=o,d=r,c&&(u=o["@"],d=Y(r,o)),e.delegateYield(B(l.expression,u,d),"t1",13);case 13:if(f=e.t1,m=n(p),g=n(f),"undefined"!==m){e.next=19;break}return a="undefined"===g?0:1,e.abrupt("continue",32);case 19:if("undefined"!==g){e.next=22;break}return a=-1,e.abrupt("continue",32);case 22:if(!("string"!==m&&"number"!==m||"string"!==g&&"number"!==g)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==m&&"number"!==m?p:f};case 24:if(m===g){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:f};case 26:if(p!==f){e.next=30;break}return e.abrupt("continue",32);case 30:a=p<f?-1:1;case 31:!0===l.descending&&(a=-a);case 32:h++,e.next=2;break;case 35:return e.abrupt("return",1===a);case 36:case"end":return e.stop()}},e)}),l={environment:r,input:e},u.delegateYield(o.sort.apply(l,[a,h]),"t0",5);case 5:return s=u.t0,u.abrupt("return",s);case 7:case"end":return u.stop()}},v)}function yt(t,e,r){return Et(i().mark(function e(s){var o,a,c,h,l,u,d,p,f,m,g;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==s){e.next=2;break}return e.abrupt("return",void 0);case 2:if(o=r.lookup("clone"),C(o)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(wt(o,[s],null,r),"t0",6);case 6:return a=e.t0,e.delegateYield(B(t.pattern,a,r),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),h=0;case 12:if(!(h<c.length)){e.next=35;break}if(!(l=c[h])||!(l.isPrototypeOf(a)||l instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(B(t.update,l,r),"t2",17);case 17:if(u=e.t2,"undefined"===(d=n(u))){e.next=23;break}if("object"===d&&null!==u&&!Array.isArray(u)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:u};case 22:for(p in u)l[p]=u[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(B(t.delete,l,r),"t3",25);case 25:if(void 0===(f=e.t3)){e.next=32;break}if(m=f,Array.isArray(f)||(f=[f]),O(f)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:m};case 31:for(g=0;g<f.length;g++)"object"===n(l)&&null!==l&&delete l[f[g]];case 32:h++,e.next=12;break;case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}},e)}),"<(oa):o>")}var bt=c("function($f, $g) { function($x){ $g($f($x)) } }");function xt(t,e,r){var n,s,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.lhs,e,r),"t0",1);case 1:if(s=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(vt(t.rhs,e,r,{context:s}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(B(t.rhs,e,r),"t2",8);case 8:if(o=i.t2,C(o)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 11:if(!C(s)){i.next=18;break}return i.delegateYield(B(bt,null,r),"t3",13);case 13:return a=i.t3,i.delegateYield(wt(a,[s,o],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(wt(o,[s],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},w)}function vt(t,e,r,s){var o,a,c,h,l,u;return i().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(B(t.procedure,e,r),"t0",1);case 1:if(void 0!==(a=d.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){d.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==s&&c.push(s.context),h=i().mark(function n(){var s,o;return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(B(t.arguments[l],e,r),"t0",1);case 1:s=n.t0,C(s)?(o=i().mark(function t(){var e,n,o,a=arguments;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=a.length,n=new Array(e),o=0;o<e;o++)n[o]=a[o];return t.delegateYield(wt(s,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}},t)}),o.arity=D(s),c.push(o)):c.push(s);case 3:case"end":return n.stop()}},n)}),l=0;case 8:if(!(l<t.arguments.length)){d.next=13;break}return d.delegateYield(h(),"t1",10);case 10:l++,d.next=8;break;case 13:return u="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,d.prev=14,"object"===n(a)&&(a.token=u,a.position=t.position),d.delegateYield(wt(a,c,e,r),"t2",17);case 17:o=d.t2,d.next=25;break;case 20:throw d.prev=20,d.t3=d.catch(14),d.t3.position||(d.t3.position=t.position),d.t3.token||(d.t3.token=u),d.t3;case 25:return d.abrupt("return",o);case 26:case"end":return d.stop()}},_,null,[[14,20]])}function wt(t,e,r,n){var s,o,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(_t(t,e,r,n),"t0",1);case 1:s=i.t0;case 2:if(!R(s)||!0!==s.thunk){i.next=21;break}return i.delegateYield(B(s.body.procedure,s.input,s.environment),"t1",4);case 4:o=i.t1,"variable"===s.body.procedure.type&&(o.token=s.body.procedure.value),o.position=s.body.procedure.position,a=[],c=0;case 9:if(!(c<s.body.arguments.length)){i.next=17;break}return i.t2=a,i.delegateYield(B(s.body.arguments[c],s.input,s.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:c++,i.next=9;break;case 17:return i.delegateYield(_t(o,a,r,n),"t5",18);case 18:s=i.t5,i.next=2;break;case 21:return i.abrupt("return",s);case 22:case"end":return i.stop()}},M)}function _t(t,e,r,n){var s,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,o=e,t&&(o=kt(t.signature,e,r)),!R(t)){i.next=8;break}return i.delegateYield(At(t,o),"t0",5);case 5:s=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(a={environment:n,input:r},s=t.implementation.apply(a,o),!F(s)){i.next=14;break}return i.delegateYield(s,"t1",13);case 13:s=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(s=t.apply(r,o),!F(s)){i.next=21;break}return i.delegateYield(s,"t2",20);case 20:s=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",s);case 31:case"end":return i.stop()}},S,null,[[0,26]])}function Mt(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark(function t(r,s){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(wt(n,s,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t)}),n}function St(t,e,r){var n,s,o,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:s=[],o=0;case 2:if(!(o<t.arguments.length)){i.next=15;break}if("operator"!==(a=t.arguments[o]).type||"?"!==a.value){i.next=8;break}s.push(a),i.next=12;break;case 8:return i.t0=s,i.delegateYield(B(a,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:o++,i.next=2;break;case 15:return i.delegateYield(B(t.procedure,e,r),"t3",16);case 16:if(void 0!==(c=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!R(c)){i.next=23;break}n=zt(c,s),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=Tt(c.implementation,s),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=Tt(c,s),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}},k)}function kt(t,e,r){return void 0===t?e:t.validate(e,r)}function At(t,e){var r,n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Ct(t.environment),t.arguments.forEach(function(t,r){n.bind(t.value,e[r])}),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(It(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(B(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}},A)}function zt(t,e){var r=Ct(t.environment),n=[];return t.arguments.forEach(function(t,i){var s=e[i];s&&"operator"===s.type&&"?"===s.value?n.push(t):r.bind(t.value,s)}),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function Tt(t,e){var r=Ot(t),n="function("+(r=r.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=c(n);return i.body=t,zt(i,e)}function It(t,e){var r,n,s,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Ot(t),n=r.map(function(t){return e.lookup(t.trim())}),s={environment:e},o=t.apply(s,n),!F(o)){i.next=7;break}return i.delegateYield(o,"t0",6);case 6:o=i.t0;case 7:return i.abrupt("return",o);case 8:case"end":return i.stop()}},z)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Et(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=h(e)),r}function Pt(t,e){var r,n,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!j(r)&&((r=P(r)).outerWrapper=!0)),i.prev=4,n=c(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Ft(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(B(n,r,this.environment),"t1",14);case 14:s=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Ft(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",s);case 22:case"end":return i.stop()}},T,this,[[4,8],[12,17]])}function jt(t){if(void 0!==t)return JSON.parse(o.string(t))}function Ct(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}L.bind("sum",Et(o.sum,"<a<n>:n>")),L.bind("count",Et(o.count,"<a:n>")),L.bind("max",Et(o.max,"<a<n>:n>")),L.bind("min",Et(o.min,"<a<n>:n>")),L.bind("average",Et(o.average,"<a<n>:n>")),L.bind("string",Et(o.string,"<x-b?:s>")),L.bind("substring",Et(o.substring,"<s-nn?:s>")),L.bind("substringBefore",Et(o.substringBefore,"<s-s:s>")),L.bind("substringAfter",Et(o.substringAfter,"<s-s:s>")),L.bind("lowercase",Et(o.lowercase,"<s-:s>")),L.bind("uppercase",Et(o.uppercase,"<s-:s>")),L.bind("length",Et(o.length,"<s-:n>")),L.bind("trim",Et(o.trim,"<s-:s>")),L.bind("pad",Et(o.pad,"<s-ns?:s>")),L.bind("match",Et(o.match,"<s-f<s:o>n?:a<o>>")),L.bind("contains",Et(o.contains,"<s-(sf):b>")),L.bind("replace",Et(o.replace,"<s-(sf)(sf)n?:s>")),L.bind("split",Et(o.split,"<s-(sf)n?:a<s>>")),L.bind("join",Et(o.join,"<a<s>s?:s>")),L.bind("formatNumber",Et(o.formatNumber,"<n-so?:s>")),L.bind("formatBase",Et(o.formatBase,"<n-n?:s>")),L.bind("formatInteger",Et(s.formatInteger,"<n-s:s>")),L.bind("parseInteger",Et(s.parseInteger,"<s-s:n>")),L.bind("number",Et(o.number,"<(nsb)-:n>")),L.bind("floor",Et(o.floor,"<n-:n>")),L.bind("ceil",Et(o.ceil,"<n-:n>")),L.bind("round",Et(o.round,"<n-n?:n>")),L.bind("abs",Et(o.abs,"<n-:n>")),L.bind("sqrt",Et(o.sqrt,"<n-:n>")),L.bind("power",Et(o.power,"<n-n:n>")),L.bind("random",Et(o.random,"<:n>")),L.bind("boolean",Et(o.boolean,"<x-:b>")),L.bind("not",Et(o.not,"<x-:b>")),L.bind("map",Et(o.map,"<af>")),L.bind("zip",Et(o.zip,"<a+>")),L.bind("filter",Et(o.filter,"<af>")),L.bind("single",Et(o.single,"<af?>")),L.bind("reduce",Et(o.foldLeft,"<afj?:j>")),L.bind("sift",Et(o.sift,"<o-f?:o>")),L.bind("keys",Et(o.keys,"<x-:a<s>>")),L.bind("lookup",Et(o.lookup,"<x-s:x>")),L.bind("append",Et(o.append,"<xx:a>")),L.bind("exists",Et(o.exists,"<x:b>")),L.bind("spread",Et(o.spread,"<x-:a<o>>")),L.bind("merge",Et(o.merge,"<a<o>:o>")),L.bind("reverse",Et(o.reverse,"<a:a>")),L.bind("each",Et(o.each,"<o-f:a>")),L.bind("error",Et(o.error,"<s?:x>")),L.bind("assert",Et(o.assert,"<bs?:x>")),L.bind("type",Et(o.type,"<x:s>")),L.bind("sort",Et(o.sort,"<af?:a>")),L.bind("shuffle",Et(o.shuffle,"<a:a>")),L.bind("distinct",Et(o.distinct,"<x:x>")),L.bind("base64encode",Et(o.base64encode,"<s-:s>")),L.bind("base64decode",Et(o.base64decode,"<s-:s>")),L.bind("encodeUrlComponent",Et(o.encodeUrlComponent,"<s-:s>")),L.bind("encodeUrl",Et(o.encodeUrl,"<s-:s>")),L.bind("decodeUrlComponent",Et(o.decodeUrlComponent,"<s-:s>")),L.bind("decodeUrl",Et(o.decodeUrl,"<s-:s>")),L.bind("eval",Et(Pt,"<sx?:x>")),L.bind("toMillis",Et(s.toMillis,"<s-s?:n>")),L.bind("fromMillis",Et(s.fromMillis,"<n-s?s?:s>")),L.bind("clone",Et(jt,"<(oa)-:o>"));var Rt={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}}",D1010:"Attempted to access the Javascript object prototype",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 Ft(t){var e=Rt[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});r=r.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=r}}function Dt(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Ft(t),t}var i=Ct(L),o=new Date;return i.bind("now",Et(function(t,e){return s.fromMillis(o.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",Et(function(){return o.getTime()},"<:n>")),e&&e.RegexEngine?Dt.RegexEngine=e.RegexEngine:Dt.RegexEngine=RegExp,{evaluate:function(t,e,s){if(void 0!==n){var a={code:"S0500",position:0};throw Ft(a),a}var c,h,l;if(void 0!==e)for(var u in c=Ct(i),e)c.bind(u,e[u]);else c=i;if(c.bind("$",t),o=new Date,c.timestamp=o,Array.isArray(t)&&!j(t)&&((t=P(t)).outerWrapper=!0),"function"==typeof s){c.async=!0;var d=function(t){Ft(t),s(t,null)},p=function t(e){(h=l.next(e)).done?s(null,h.value):h.value.then(t).catch(d)};l=B(r,t,c),(h=l.next()).value.then(p).catch(d)}else try{for(l=B(r,t,c),h=l.next();!h.done;)h=l.next(h.value);return h.value}catch(a){throw Ft(a),a}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=Et(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Dt.parser=c,Dt}();e.exports=l},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=t("./signature"),i=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"},r=function(r){var n=0,i=r.length,s=function(t,e){return{type:t,value:e,position:n}},o=function(){for(var t,e,s=n,o=0;n<i;){var a=r.charAt(n);if("/"===a&&"\\"!==r.charAt(n-1)&&0===o){if(""===(t=r.substring(s,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,a=r.charAt(n),s=n;"i"===a||"m"===a;)n++,a=r.charAt(n);return e=r.substring(s,n)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===r.charAt(n-1)||o++,")"!==a&&"]"!==a&&"}"!==a||"\\"===r.charAt(n-1)||o--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}};return function a(c){if(n>=i)return null;for(var h=r.charAt(n);n<i&&" \t\n\r\v".indexOf(h)>-1;)n++,h=r.charAt(n);if("/"===h&&"*"===r.charAt(n+1)){var l=n;for(n+=2,h=r.charAt(n);"*"!==h||"/"!==r.charAt(n+1);)if(h=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:l};return n+=2,h=r.charAt(n),a(c)}if(!0!==c&&"/"===h)return n++,s("regex",o());if("."===h&&"."===r.charAt(n+1))return n+=2,s("operator","..");if(":"===h&&"="===r.charAt(n+1))return n+=2,s("operator",":=");if("!"===h&&"="===r.charAt(n+1))return n+=2,s("operator","!=");if(">"===h&&"="===r.charAt(n+1))return n+=2,s("operator",">=");if("<"===h&&"="===r.charAt(n+1))return n+=2,s("operator","<=");if("*"===h&&"*"===r.charAt(n+1))return n+=2,s("operator","**");if("~"===h&&">"===r.charAt(n+1))return n+=2,s("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return n++,s("operator",h);if('"'===h||"'"===h){var u=h;n++;for(var d="";n<i;){if("\\"===(h=r.charAt(n)))if(n++,h=r.charAt(n),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:n,token:h};var p=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:n};var f=parseInt(p,16);d+=String.fromCharCode(f),n+=4}else{if(h===u)return n++,s("string",d);d+=h}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var m,g=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==g){var y=parseFloat(g[0]);if(!isNaN(y)&&isFinite(y))return n+=g[0].length,s("number",y);throw{code:"S0102",stack:(new Error).stack,position:n,token:g[0]}}if("`"===h){n++;var b=r.indexOf("`",n);if(-1!==b)return m=r.substring(n,b),n=b+1,s("name",m);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var x,v=n;;)if(x=r.charAt(v),v===i||" \t\n\r\v".indexOf(x)>-1||Object.prototype.hasOwnProperty.call(t,x)){if("$"===r.charAt(n))return m=r.substring(n+1,v),n=v,s("variable",m);switch(m=r.substring(n,v),n=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 n===i&&""===m?null:s("name",m)}}else v++}},i=function(e,i){var s,o,a={},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(i)return t.remaining=h(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var r=a[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(l)).id=r.value=t,r.lbp=e,a[t]=r),r},d=function(t){if(i){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,r){if(t&&s.id!==t){var n={code:"(end)"===s.id?"S0203":"S0202",position:s.position,token:s.value,value:t};return d(n)}var i=o(r);if(null===i)return(s=a["(end)"]).position=e.length,s;var c,h=i.value,l=i.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:i.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:i.position,token:h})}return(s=Object.create(c)).value=h,s.type=l,s.position=i.position,s},f=function(t){var e,r=s;for(p(null,!0),e=r.nud();t<s.lbp;)r=s,p(),e=r.led(e);return e},m=function(t){u(t,0).nud=function(){return this}},g=function(e,r,n){var i=r||t[e],s=u(e,i);return s.led=n||function(t){return this.lhs=t,this.rhs=f(i),this.type="binary",this},s},y=function(t,e,r){var n=u(t,e);return n.led=r,n},b=function(t,e){var r=u(t);return r.nud=e||function(){return this.expression=f(70),this.type="unary",this},r};m("(end)"),m("(name)"),m("(literal)"),m("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),g("."),g("+"),g("-"),g("*"),g("/"),g("%"),g("="),g("<"),g(">"),g("!="),g("<="),g(">="),g("&"),g("and"),g("or"),g("in"),m("and"),m("or"),m("in"),b("-"),g("~>"),y("(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}),g("(",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,r=1,i="<";r>0&&"{"!==s.id&&"(end)"!==s.id;){var o=p();">"===o.id?r--:"<"===o.id&&r++,i+=o.value}p(">");try{this.signature=n(i)}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 r={type:"binary",value:"..",position:s.position,lhs:e};p(".."),r.rhs=f(0),e=r}if(t.push(e),","!==s.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this}),g("[",t["["],function(e){if("]"===s.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this}),g("^",t["^"],function(t){p("(");for(var e=[];;){var r={descending:!1};if("<"===s.id?p("<"):">"===s.id&&(r.descending=!0,p(">")),r.expression=f(0),e.push(r),","!==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 r=f(0);p(":");var n=f(0);if(e.push([r,n]),","!==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),g("{",t["{"],x),y(":=",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)}),g("@",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)}),g("#",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)}),g("?",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(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},w=0,_=0,M=[],S=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(M[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},k=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},A=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var s=n[i];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(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var s=t(e.rhs);"function"===s.type&&"path"===s.procedure.type&&1===s.procedure.steps.length&&"name"===s.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=s.procedure.steps[0].value),"path"===s.type?Array.prototype.push.apply(r.steps,s.steps):(void 0!==s.predicate&&(s.stages=s.predicate,delete s.predicate),r.steps.push(s)),r.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"}),r.steps.filter(function(t){return!0===t.keepArray}).length>0&&(r.keepSingletonArray=!0);var o=r.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var a=r.steps[r.steps.length-1];"unary"===a.type&&"["===a.value&&(a.consarray=!0),A(r);break;case"[":var h=r=t(e.lhs),l="predicate";if("path"===r.type&&(h=r.steps[r.steps.length-1],l="stages"),void 0!==h.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===h[l]&&(h[l]=[]);var u=t(e.rhs);void 0!==u.seekingParent&&(u.seekingParent.forEach(function(t){1===t.level?S(h,t):t.level--}),k(h,u)),h[l].push({type:"filter",expr:u,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map(function(e){return[t(e[0]),t(e[1])]}),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var d={type:"sort",position:e.position};d.terms=e.rhs.map(function(e){var r=t(e.expression);return k(d,r),{descending:e.descending,expression:r}}),r.steps.push(d),A(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),k(r,r.rhs);break;case"@":if(r=t(e.lhs),h=r,"path"===r.type&&(h=r.steps[r.steps.length-1]),void 0!==h.stages||void 0!==h.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===h.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(h.keepArray=!0),h.focus=e.rhs.value,h.tuple=!0;break;case"#":r=t(e.lhs),h=r,"path"===r.type?h=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==h.predicate&&(h.stages=h.predicate,delete h.predicate)),void 0===h.stages?h.index=e.rhs.value:h.stages.push({type:"index",value:e.rhs.value,position:e.position}),h.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),k(r,r.lhs),k(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map(function(e){var n=t(e);return k(r,n),n}):"{"===e.value?r.lhs=e.lhs.map(function(e){var n=t(e[0]);k(r,n);var i=t(e[1]);return k(r,i),[n,i]}):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:k(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){var n=t(e);return k(r,n),n}),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var p=t(e.body);r.body=v(p);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),k(r,r.condition),r.then=t(e.then),k(r,r.then),void 0!==e.else&&(r.else=t(e.else),k(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){var n=t(e);return k(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n});break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+w++,level:1,index:_++}},M.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var f="S0206";"(end)"===e.id&&(f="S0207");var m={code:f,position:e.position,token:e.value};if(i)return c.push(m),{type:"error",error:m};throw m.stack=(new Error).stack,m}return e.keepArray&&(r.keepArray=!0),r};o=r(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 i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="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},n(t)}var i=t("./utils"),s=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var r=1,s=[],o={},a=o;r<e.length;){var c=e.charAt(r);if(":"===c)break;var h=function(){s.push(o),a=o,o={}},l=function(t,e,r,n){for(var i=1,s=e;s<t.length;)if(s++,(c=t.charAt(s))===n){if(0===--i)break}else c===r&&i++;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,r,"(",")"),d=e.substring(r+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:r};o.regex="["+d+"m]",o.type="("+d+")",r=u,h();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:r};var p=l(e,r,"<",">");a.subtype=e.substring(r+1,p),r=p}r++}var f="^"+s.map(function(t){return"("+t.regex+")"}).join("")+"$",m=new RegExp(f),g=function(t){var e;if(i.isFunction(t))e="f";else switch(n(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},y=function(t,e){for(var r="^",n=0,i=0;i<s.length;i++){r+=s[i].regex;var o=e.match(r);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach(function(t){n+=g(t)});var i=m.exec(n);if(i){var o=[],a=0;return s.forEach(function(n,s){var c=e[a],h=i[s+1];if(""===h)if(n.context&&n.contextRegex){var l=g(r);if(!n.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:r,index:a+1};o.push(r)}else o.push(c),a++;else h.split("").forEach(function(r){if("a"===n.type){if("m"===r)c=void 0;else{c=e[a];var i=!0;if(void 0!==n.subtype)if("a"!==r&&h!==n.subtype)i=!1;else if("a"===r&&c.length>0){var s=g(c[0]);i=s===n.subtype.charAt(0)&&0===c.filter(function(t){return g(t)!==s}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[n.subtype]};"a"!==r&&(c=[c])}o.push(c),a++}else o.push(c),a++})}),o}y(e,n)}}}return e}();e.exports=s},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e){r&&(t=r);var n=0,s=function(){};return{s:s,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw o}}}}function i(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}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 r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter(function(e){return!t(e)}).length),r}function i(){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 r=0;r<t.length;r++)if(!d(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var s=n[r];if(!d(t[s],e[s]))return!1}return!0}return!1}function p(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var s=e.value;r.push(s)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:s,isFunction:a,isLambda:h,isIterable:u,getFunctionArity:c,isDeepEqual:d,stringToArray:p}}();e.exports=a},{}]},{},[3])(3)}(za)),za.exports),Ia=Sa(Ta);const Oa=function(t){return t};function Ea(t){if(!t)return Oa;try{const e=Ia(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return va(t),Oa}}function Pa(t,e){if(!e)return;const r=Vo(t),n=null==r?"":String(r);return Object.prototype.hasOwnProperty.call(e,n)?e[n]:e.default}const ja=t=>null==t||""===t?void 0:parseFloat(String(t));function Ca(t,e,r){for(const r of e)if(void 0!==r.value&&r.value===t)return r.result;const n=Vo(t);if(null==n)return r;const i=Number(n);if(Number.isNaN(i))return r;for(const t of e){const e=ja(t.min),r=ja(t.max);if((void 0!==e||void 0!==r)&&(i>=(e??-1/0)&&i<(r??1/0)))return t.result}return r}function Ra(t){return Number(Vo(t))}function Fa(t){return t}function Da(t){return function(t){const e=Vo(t);return null==e?"":String(e)}(t)}function Na(t){return Ra(t)}function La(t){return Pa(t,this.param)}function Ba(t){const{param:e}=this;if(!e)return;return Ca(t,Object.keys(e).filter(t=>"default"!==t).map(t=>{const[r,n]=t.split("~");return{min:""===r?null:r,max:void 0===n||""===n?null:n,result:e[t]}}),e.default)}function Ua(t){const{param:e}=this;if(!e)return;const r=Number(e.scale??1),n=Number(e.offset??0);return Ra(t)*r+n}function Ya(t){return Ra(t)*Math.PI/180}function Wa(){}const qa=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const $a=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],Va=new Array($a.length).fill(void 0),Ha=Object.getPrototypeOf(async function(){}).constructor;function Ga(t,e){!function(t){for(const e of qa)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const r=function(t){return/\bawait\b/.test(t)}(t),n=new(r?Ha:Function)(...e,...$a,t);return function(t,...e){return n.call(t,...e,...Va)}}function Xa(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?Da.bind(t):"number"===i?Na.bind(t):Fa.bind(e);case"map":return La.bind(t);case"range":return Ba.bind(t);case"scale":return Ua.bind(t);case"radian":return Ya.bind(t);case"eval":return function(t){try{const e=Ga(t,["value","targets","scene"]);return function(t,r){try{const n=e(this,t,r,globalThis.scene);return n&&"function"==typeof n.then?n.catch(t=>{va(t)}):n}catch(t){return void va(t)}}}catch(t){return va(t),Wa}}(n).bind(e);default:return Fa.bind(e)}}class Za{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:r,rule:n,param:i,accessor:s}=t;this._model=t,this.evaluator=Xa(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=Ea(s);const o=e.match(/\[(.*?)\]/);if(o){const[t,e]=o[1].split(":");this.propAccessor=Ea(t),this.partAccessor=Ea(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 Ja(t,e,r,n){const i=e.split(".");if(1===i.length)return void(t[e]=n?{...t[e],...r}:r);const s=i[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<i.length-1;t++)c[i[t]]=c[i[t]]?{...c[i[t]]}:{},c=c[i[t]];const h=i[i.length-1];c[h]=n?{...c[h],...r}:r,t[s]=a}function Qa(t,e,r,n){t.forEach(t=>Ja(t,e,r,n))}function Ka(t,e,r,n){t&&"function"==typeof t.then?t.then(t=>{void 0!==r&&void 0!==n&&r._dataGeneration!==n||e(t)}).catch(t=>va(t)):e(t)}function tc(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,r=this;this.mappings&&this.mappings.forEach(t=>{try{let n,{source:i,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"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),n=this.root.findById(i)?.data||{}):n=this.data;const d=a(n);if("(root)"==s||"(key)"==s){if(null==d)return;const n=Object.keys(d||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();n.length>0&&n.forEach(n=>{Ka(t.evaluator(d[n.get("id")],[n]),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Ja(n,o,t,u)},r,e)})}else if(s.startsWith("[")){if(null==d)return;if(d instanceof Array)d.forEach(n=>{const i=c(n);if(i){const s=this.root.findOrCreate(i);s&&Ka(t.evaluator(h(n),s),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Qa(s,o,t,u)},r,e)}});else{if(!(d instanceof Object))throw String("mapping data should be an object to target property-id.("+d+")");{const n=c(d);if(n){const i=this.root.findOrCreate(n);i&&Ka(t.evaluator(h(d),i),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Qa(i,o,t,u)},r,e)}}}}else{const n=this.root.findAll(s,this);n.length>0&&Ka(t.evaluator(d,n),t=>{!o||"(action)"===o||l&&!t&&0!==t&&!1!==t||Qa(n,o,t,u)},r,e)}}catch(e){va(e,this,t)}})}function ec(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),tc.call(this,!0)}function rc(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new Za({target:"(self)",rule:"value",...t},this))):(va("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function nc(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function ic(t,e){this.disposeMappings(),tc.call(this)}function sc(t,e,r,n,i,s){e.complete?t.drawImage(e,r,n,i,s):e.addEventListener("load",()=>{this.invalidate()})}function oc(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const ac="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),cc={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},hc=()=>{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(),r=t.fontFamily||"sans-serif";cc.FONT_FAMILY=e||r};let lc;function uc(t,e,r,n,i){const{alpha:s=1}=n,o=i.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(r.x,r.y);let n,{width:i,height:s}=e;if("linear"==o.gradientType){const e=3.141592653589793,r="number"==typeof o.rotation&&Number.isFinite(o.rotation)?o.rotation:0;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let o=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((s-4)/2,2));o-=o-(i+s)/3,n=t.createLinearGradient(o*Math.cos(r+e),o*Math.sin(r+e),o*Math.cos(r),o*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(s-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(s-4)/2*Math.sin(r))}else if("radial"==o.gradientType){const e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((s-4)/2,2));switch(o.center){case"center":default:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-s/2,0,-i/2,-s/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-s/2,0,i/2,-s/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,s/2,0,-i/2,s/2,2*e);break;case"right-bottom":n=t.createRadialGradient(i/2,s/2,0,i/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{n.addColorStop(t.position,t.color)}catch(e){wa("Invalid Color for colorstop : ",t.color),n.addColorStop(t.position,"#fff")}}),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.y)}else if("pattern"==o.type&&o.image)if(o.guideOnly&&1!=i.app.mode)o.color&&(t.fillStyle=o.color,t.fill());else{i.prepareFillIf(!i._pattern_image_origin);const r=i._pattern_image;if(!r||!r.width||!r.height)return;let n=0,s=0,a=0,c=0,h=e.left,l=e.top;if(!o.fitPattern){n=o.offsetX,s=o.offsetY;const t=o.width?o.width:r.width,i=o.height?o.height:r.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}h+=n+a,l+=s+c}t.translate(h,l),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((r.width-e.width)*(r.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(r,"no-repeat"):t.fillStyle=t.createPattern(r,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-l)}}function dc(t,e){const r=this.fillStyle;if(!r||"pattern"!=r.type||!r.image)return void t(this);if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);const s=lc(e,i);s.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=s,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.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(r.image)}catch(t){e(t)}}function pc(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{va(t)})}function fc(t,e){const r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)}function mc(t,e,r){let{strokeStyle:n,lineDash:i,lineWidth:s,lineCap:o,lineJoin:a,alpha:c}=e;if(n&&0!=s){if(o&&(t.lineCap=o),i){const e="round"==o;switch(i){case"solid":i=[0,0];break;case"round-dot":i=e?[0,2*s]:[s,s];break;case"square-dot":i=e?[s,2*s]:[2*s,s];break;case"dash":i=e?[3*s,2.5*s]:[4*s,1.5*s];break;case"dash-dot":i=e?[3*s,3*s,0,3*s]:[4*s,2*s,s,2*s];break;case"long-dash":i=e?[5*s,4*s]:[6*s,3*s];break;case"long-dash-dot":i=e?[5*s,3*s,0,3*s]:[6*s,2*s,s,2*s];break;case"long-dash-dot-dot":i=e?[5*s,2*s,0,2*s,0,2*s]:[6*s,s,s,s,s,s]}Array.isArray(i)||(i=[]),t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=n,t.lineWidth=s,t.lineJoin=a,t.stroke()}}function gc(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,r=[];let n;for(;null!==(n=e.exec(t));)n[1]?r.push({text:n[2],bold:!0,italic:!1}):n[3]?r.push({text:n[4],bold:!1,italic:!0}):n[5]&&r.push({text:n[5],bold:!1,italic:!1});return r}function yc(t,e,r,n=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const s=e.text.substring(0,i);if(!(t.measureText(s).width+(i-1)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function bc(t,e,r,n,i,s=0){const o=String(e).split("\n");return n?[].concat(...o.map(e=>function(t,e,r,n=0){const i=[];let s=[],o=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=r-o,h=t.measureText(a).width+(a.length-1)*n;if(h<=c)s.push({...e,text:a}),o+=h,a="";else{const r=yc(t,{...e,text:a},c,n);s.push(r),i.push(s),s=[],o=0,a=a.substring(r.text.length)}}}),s.length>0&&i.push(s),i}(t,i?gc(e):[{text:e,bold:!1,italic:!1}],r,s))):o.map(t=>i?gc(t):[{text:t,bold:!1,italic:!1}])}function xc(t,e,r,n,i,s,o=0){if(!n)return[];t.save(),t.font=r;const a=bc(t,n,e,!!i,s,o);return t.restore(),a}function vc(t){const{fontFamily:e=cc.FONT_FAMILY,bold:r=cc.BOLD,italic:n=cc.ITALIC,fontSize:i=cc.FONT_SIZE}=t,s=[];return r&&s.push("bold"),n&&s.push("italic"),s.push(i+"px"),s.push(e),s.join(" ")}function wc(t,e){const r=t.bold||e.bold,n=t.italic||e.italic;return vc({...t,bold:r,italic:n})}function _c(t,e,r,n){let{alpha:i,rotation:s,keepTextAngle:o=!1,fontColor:a=cc.FONT_COLOR,textAlign:c=cc.TEXT_ALIGN,textBaseline:h=cc.TEXT_BASELINE,textBackgroundStyle:l,fontSize:u,lineHeight:d,textWrap:p,textOverflow:f,letterSpacing:m=0}=n;i=void 0!==i?i:1,u||=cc.FONT_SIZE,d||=1.2*u,t.save();const{left:g,top:y,width:b,height:x}=e;if(s&&o&&(t.translate(g+b/2,y+x/2),t.rotate(-s),t.translate(-(g+b/2),-(y+x/2))),t.beginPath(),t.font=vc(n),!p&&f){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",s=e.measureText(i).width,o=[];let a=0;for(const i of r){const r=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=n-("ellipsis"===t?s:0))){const i=Mc(e,c,n-a-("ellipsis"===t?s:0),t);return r.push(i),o.push(r),o}r.push(c),a+=i}o.push(r),a=0}return o}(f,t,r,b);r=e}const v=r.length*d;let w;switch(h){case"top":w=y,t.textBaseline="top";break;case"bottom":w=y+x-v+d,t.textBaseline="bottom";break;default:w=y+x/2-v/2+d/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach((e,i)=>{const s=w+i*d,o=function(t,e,r,n=0){return e.reduce((e,i)=>(t.font=wc(r,i),e+t.measureText(i.text).width+n*(i.text.length-1)),0)}(t,e,n,m);let h=g;switch(c){case"left":case"justify":h=g;break;case"right":h=g+b-o;break;case"center":h=g+(b-o)/2}if(l&&(t.fillStyle=l,function(t,e,r,n,i,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,r),t.lineTo(e+n-s.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+s.tr),t.lineTo(e+n,r+i-s.br),t.quadraticCurveTo(e+n,r+i,e+n-s.br,r+i),t.lineTo(e+s.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-s.bl),t.lineTo(e,r+s.tl),t.quadraticCurveTo(e,r,e+s.tl,r),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&&i<r.length-1&&e.length>1){const r=b-o,i=e.length-1,a=r/i;e.forEach((e,r)=>{t.font=wc(n,e),t.fillText(e.text,h,s),h+=t.measureText(e.text).width+(r<i?a:0)})}else e.forEach(e=>{t.font=wc(n,e),[...e.text].forEach(e=>{t.fillText(e,h,s),h+=t.measureText(e).width+m})})}),t.restore()}function Mc(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){const s=i+e.text[n];if(t.measureText(s).width>r)break;i=s}return{...e,text:i+("ellipsis"===n?"…":"")}}function Sc(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{hc()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(hc),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{hc()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),hc(),lc="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const r=document.createElement("canvas");return r.width=t,r.height=e,r};const kc=[];function Ac(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-r.x)/i.x,e=(e-r.y)/i.y):(t-=r.x,e-=r.y),0!==n){const r=Math.cos(-n),i=Math.sin(-n),s=t*i+e*r;t=t*r-e*i,e=s}return{x:t+r.x,y:e+r.y}}function zc(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(t-=r.x,e-=r.y,0!==n){const r=Math.cos(n),i=Math.sin(n),s=t*i+e*r;t=t*r-e*i,e=s}return 1!==i.x||1!==i.y?{x:t*i.x+r.x,y:e*i.y+r.y}:{x:t+r.x,y:e+r.y}}function Tc(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,s=Ac(t,e,r,n,i);return r&&(s.x-=r.x,s.y-=r.y),s}return Ac(t,e,r=r||this.rotatePoint,n,i)}function Ic(t,e,r){if(!this.parent)return{x:t,y:e};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,s=zc(t,e,void 0,n+(this._delta?.theta??0),i);return r&&(s.x+=r.x,s.y+=r.y),s}r=r||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 zc(t,e,r,n,i);return zc(t+o,e+a,{x:r.x+o,y:r.y+a},n+s,{x:i.x*c,y:i.y*h})}function Oc(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return zc(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)}function Ec(t,e,r){r=r||this.rootModel,kc.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)kc.push(t);let n=this.transcoordS2P(t,e);for(let t=0;t<kc.length;t++){const e=kc[t],r=e.bounds;n.x+=r.left,n.y+=r.top,n=e.transcoordS2P(n.x,n.y)}return n}function Pc(t,e,r){r=r||this.rootModel,kc.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)kc.push(t);let n={x:t,y:e};for(let t=kc.length-1;t>=0;t--){const e=kc[t];n=e.transcoordP2S(n.x,n.y);const r=e.bounds;n.x-=r.left,n.y-=r.top}return n}function jc(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)}function Cc(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)}function Rc(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:s=0}=r.model,o=Ac(t,e,n,s,i);return n&&(o.x-=n.x,o.y-=n.y),r===this?o:this.transcoordT2S(o.x,o.y,r)}function Fc(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;if(n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e},!this.scalable)return n;const{translate:i={x:0,y:0},rotation:s=0,scale:o={x:1,y:1}}=r.model;return n=zc(n.x,n.y,void 0,s+r._delta.theta,o),i&&(n.x+=i.x,n.y+=i.y),n}function Dc(t){const e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:s,color:o}=r;if(i&&(n.backgroundRepeat="no-repeat"),o&&(n.backgroundColor=o),s)switch(s){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){const r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,r)}else n.background="transparent"}const Nc={x:1,y:1},Lc={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function Bc(t,e){let r=this.bounds,n=this.rotatePoint;const i=this.get("rotation"),s=this.get("scale");if(t){const n=t.call(e,r);n&&(r=n)}const{left:o,top:a,width:c,height:h}=r;let l=[{x:o,y:a},{x:o+c,y:a+h}];l=l.map(t=>zc(t.x,t.y,n,i,s));let u=l[0],d=l[1];n={x:(u.x+d.x)/2,y:(u.y+d.y)/2},l=l.map(t=>Ac(t.x,t.y,n,i,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 Uc(t,e,r){let n=this.path,i=this.rotatePoint;t&&(n=t.call(r,n));let s=n.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(r,s);t&&(s=t)}const o={x:0,y:0};let a,c,h,l;n=s.map(t=>this.fromParent(t.x,t.y,o)),a=c=n[0].x,h=l=n[0].y;for(let t=1;t<n.length;t++){const e=n[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)}i={x:(a+c)/2,y:(h+l)/2},i=this.toParent(i.x,i.y,o),this.path=s.map(t=>{const e=this.fromParent(t.x,t.y,i);return{...t,x:e.x,y:e.y}})}const Yc=new Map;let Wc=null;function qc(){Wc&&(Wc(),Wc=null)}function $c(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var Vc=new class{add(t){var e;$c(t)&&!Yc.has(t)&&(Yc.set(t,0),e=t?.root,Wc||(Wc=br.subscribe(t=>{if(0===t)return;const e=[];for(const[r,n]of Yc){if(!$c(r)){e.push(r);continue}const i=n+t;i>=r.retention?e.push(r):Yc.set(r,i)}for(const t of e){Yc.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){va("RetentionManager removeSelf failed:",t)}}0===Yc.size&&qc()},{description:"retention timer",component:e,getTargets:()=>Array.from(Yc.keys()),metadata:{get count(){return Yc.size},get preview(){return Array.from(Yc.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){Yc.delete(t)&&0===Yc.size&&qc()}touch(t){t&&Yc.has(t)&&Yc.set(t,0)}dispose(){qc(),Yc.clear()}get length(){return Yc.size}};const Hc=function(t){return t};function Gc(t){const e=t.indexOf("||");let r="",n="";-1!=e&&(r=t,n=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),s=i.slice(1);return{defaultValue:n,match:t,originText:r||t,target:i[0],accessor:s.length>0?function(t){return s.reduce((t,e)=>t?t[e]:void 0,t)}:Hc}}function Xc(t){if(!t)return;const e=String(t),r=(e.match(/#{(\S*)}/)||[]).map(t=>Gc(t))[0];if(r)return r.accessor(this.getState(r.target));const n=(e.match(/\${[^}]*}/)||[]).map(t=>Gc(t))[0];if(n){const t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}function Zc(t,e){if(!t)return;const r=String(t),n=e||Vo,i=(r.match(/#{(\S*)}/gi)||[]).map(t=>Gc(t)),s=(r.match(/\${[^}]*}/gi)||[]).map(t=>Gc(t));if(0==i.length&&0==s.length)return r;let o=r;return i.forEach(t=>{const e=n(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),r=n(t.accessor(e&&e.data));o=o.replace(t.match,void 0===r?"":r)}),o}function Jc(t,e,r){if(!t)return;const n=r||Vo,i=String(t),s=(i.match(/#{[^}]*}/gi)||[]).map(t=>Gc(t)),o=(i.match(/\${[^}]*}/gi)||[]).map(t=>Gc(t));return 0!=s.length||0!=o.length?function(){let t=i;return s.forEach(r=>{const i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)}),o.forEach(r=>{const i=e.root.findById(r.target),s=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===s?r.defaultValue||"":s)}),t}:void 0}class Qc{constructor(){}static registerDecorator(t,e){Qc.constructors.set(t,e)}static create(t,e,r={},n){const i=Qc.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(n,e,r)}}function Kc(t,e){const r=e.x-t.x,n=e.y-t.y,i=Math.sqrt(r*r+n*n);if(!Ur(t))return i;const s=Yr(t,e,t.bulge);if(!s)return i;const o=Math.min(s.radius,i/2),a=2*Math.asin(o/s.radius);return s.radius*a}function th(t,e){const r=t.path.slice();if(!r||!r.length)return void va("path should not be empty");let n=1;const i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.toScene(r[0].x,r[0].y);if(e>=1)return t.toScene(r[r.length-1].x,r[r.length-1].y);for(;r[n];)i.push(Kc(r[n-1],r[n])),n++;const s=i.reduce(function(t,e){return t+e},0);n=0;let o=0;do{o+=i[n++]}while(o/s<e);o-=i[--n];e=(e-o/s)*(s/i[n]);const a=r[n%r.length],c=r[(n+1)%r.length],{x:h,y:l}=function(t,e,r){if(Ur(t)){const n=Yr(t,e,t.bulge);if(n){let t=n.endAngle-n.startAngle;n.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=n.startAngle+r*t;return{x:n.cx+n.radius*Math.cos(e),y:n.cy+n.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*r),y:t.y+Math.round((e.y-t.y)*r)}}(a,c,e);return t.toScene(h,l)}function eh(t,e){return!1}function rh({x:t,y:e},...r){const n=this.path,i=t,s=e;this.path=n.map(t=>({...t,x:t.x+i,y:t.y+s}))}function nh(t){const e=t??this.center.x,{rotation:r}=this.state,n=this.fillStyle;if(this.set("rotation",2*Math.PI-r),n&&"gradient"===n.type&&"linear"===n.gradientType){const t=Po(n);t.rotation=(Math.PI-parseFloat(n.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 ih(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 sh(t,e,r){if(r){const e=this.bounds,r=e.height/e.width;let n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let s=t.left-e.left,o=t.top-e.top;return 0!=s&&0!=o?(o=-i,s=-n):0!=s?s=-n:0!=o&&(o=-i),{left:e.left+s,top:e.top+o,width:e.width+n,height:e.height+i}}return t}function oh(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function ah(t){return th(this,t||0)}function ch(){const t=this.path;let e,r,n,i;e=r=t[0].x,n=i=t[0].y;for(let s=1;s<t.length;s++){const o=t[s];o.x<e?e=o.x:o.x>r&&(r=o.x),o.y<n?n=o.y:o.y>i&&(i=o.y)}return{left:e,top:n,width:r-e,height:i-n}}function hh(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 r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))}function lh(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function uh(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 r=t.x-e.x,n=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+r,y:t.y+n}))}function dh(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function ph(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}function fh(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}function mh(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}function gh(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}function yh(t){const{width:e,height:r,depth:n}=t,{top:i,left:s}=this.bounds;this.bounds={top:i,left:s,width:e,height:r},this.setState("depth",n)}function bh(){return va("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function xh(t){va("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function vh(){return this.path}function wh(){return this.center}function _h(){return this.nature.mutable}function Mh(){return this.nature.resizable&&!this.stuck}function Sh(){return this.nature.rotatable&&!this.stuck}Qc.constructors=new Map;const kh={x:1,y:1};function Ah(t,e,r){const{offsetX:n,offsetY:i,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=r.rootModel.get("scale")??kh;t.shadowOffsetX=n*a.x*ac,t.shadowOffsetY=i*a.y*ac,t.shadowBlur=s*a.x*ac,t.shadowColor=o}function zh(t){const e=t?.app;if(!e?.isEditMode)return!1;const r=e.focusFilter;return!!(t.hidden||r&&!r(t))}function Th(t){t.save(),this.prerender(t);const e=this.app,r=!0===t.__inHiddenSubtree;e?.isEditMode&&((zh(this)||r)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=r,t.restore()}function Ih(t){const e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:s}=this.state,o=(r&&r.x||1)*this._delta.sx,a=(r&&r.y||1)*this._delta.sy,c=(n||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),i&&Ah(t,i,this)}function Oh(t){}function Eh(t){this.drawText(t)}function Ph(t,e){t(this)}function jh(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{va(t)})}function Ch(t){!this.textHidden&&this.text&&this.hasTextProperty&&_c(t,this.textBounds,this.textLines(t),this.state)}function Rh(t,e){mc(t,e?{...this.state,...e}:this.state)}function Fh(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(uc(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function Dh(){return this.get("strokeStyle")}function Nh(t){this.set("strokeStyle",t)}function Lh(){return this.getState("fillStyle")}function Bh(t){this.setState("fillStyle",t)}function Uh(){return this.get("fontColor")}function Yh(t){this.set("fontColor",String(Vo(t)))}function Wh(){return this.getState("rotation")}function qh(t){this.setState("rotation",Number(Vo(t)))}function $h(){return this.app.isEditMode?["decotag","data-spread"]:[]}function Vh(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function Hh(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function Gh(t){this.setState("hidden",t)}function Xh(){return this.state.tag}function Zh(t){this.setState("tag",t)}function Jh(){}function Qh(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function Kh(){const t=this.getState("text");return null==t?"":String(t)}function tl(t){const{textWrap:e,supportMarkdown:r}=this.state;return xc(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}function el(){return vc(this.model)}function rl(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function nl(){return this._text_substitutor||(this._text_substitutor=Jc(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function il(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let r,n,i,s,o,a,c,h,l,u,d,p=t.length,f=t.search(/[0-9\-\+#]/),m=f>0?t.substring(0,f):"",g=t.split("").reverse().join(""),y=g.search(/[0-9\-\+#]/),b=p-y,x=t.substring(b,b+1),v=b+("."===x||","===x?1:0),w=y>0?t.substring(v,p):"";if(r=(e="-"===(t=t.substring(f,v)).charAt(0)?-e:+e)<0?e=-e:0,n=t.match(/[^\d\-\+#]/g),i=".",s=n&&n[1]&&n[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],g="",b=u.length%c,p=u.length,v=0;v<p;v++)g+=u.charAt(v),!((v-b+1)%c)&&v<p-c&&(g+=s);e[0]=g}return e[1]=t[1]&&e[1]?"."+e[1]:"",n=e.join(""),"0"!==n&&""!==n||(r=!1),d="+"==t[0].substring(0,1)?r?"-":"+":r?"-":"",m+(d+n)+w}(t,this.textSubstitutor()):this.textSubstitutor()}function sl(t){delete this._text_substitutor;const e=Vo(t);this.setState("text",null==e?"":String(e))}function ol(){let{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;const{left:i,top:s,width:o,height:a}=this.bounds;return{left:i+e,top:s+t,width:Math.max(o-e-r,0),height:Math.max(a-t-n,0)}}function al(){return 0}function cl(){return!!this._textHidden}function hl(t){this._textHidden=!!t,this.invalidate()}function ll(){return!0}function ul(t){return t}function dl(t){return Math.pow(t,2)}function pl(t){return 1-Math.sin(Math.acos(t))}function fl(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function ml(t){for(let e=0,r=1;;e+=r,r/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(r,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 yl={linear:ul,quad:dl,circ:pl,back:fl,bounce:ml,elastic:gl},bl=Object.freeze({__proto__:null,back:fl,bounce:ml,circ:pl,default:yl,elastic:gl,linear:ul,quad:dl});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:r="linear",options:n,ease:i}=this.config;let s;s="string"==typeof r?yl[r]:r,this.delta="out"===i?function(t,e){return function(r){return 1-t(1-r,e)}}(s,n):"inout"===i?function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(s,n):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:r=!1,interval:n=0,onComplete:i}=this.config;this._started=!0;const s=this.config?.type??"animation";let o=0,a=0;const c=()=>br.simTime,h=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(i);0==o&&(o=c(),this.client?.touch?.());const l=c()-o,u=Math.max((l-e)%(t+n),0)/t,d=n<=0&&a>u;if(a=u,u>=1||d){if(this.step(1),this.client&&this.client.invalidate?.(),!r||!this._started)return this.stop(i),void(o=0);if(n>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=br.subscribe(h,{description:`animation: ${s}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}}))},n/2)},n/2))}else this.step(this.delta(u)),this.client&&this.client.invalidate?.()};this._unsub=br.subscribe(h,{description:`animation: ${s}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}})}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 vl={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,r=4*e;let n=t*r;t<1/4?n*=-1:t<3/4?n-=2*e:n=r-n,this.client.delta?.("theta",n)}},heartbeat:class extends xl{step(t){const{scale:e=1.3}=this.config,r=2*(e-1);let n;n=t<.5?1+r*t:1+(1-t)*r,this.client.delta?.({sx:n,sy:n,sz:n})}},moving:class extends xl{step(t){const{x:e=0,y:r=0}=this.config;this.client.delta?.({tx:t*e,ty:t*r})}},outline:class extends xl{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const r=this.client.root.findById(e);if(!r)return;let n={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(n=i);const{tx:s,ty:o}=n,a=r.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:r=0}=this.config,n=Math.max(Math.min(e,r,1),0),i=2*(Math.min(Math.max(e,r,1),1)-n);let s;s=t<.5?i*t:(1-t)*i,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 r=e.center,n=t.center,{x:i,y:s}=e.toScene(r.x,r.y),{x:o,y:a}=t.toScene(n.x,n.y);this._startX=i,this._startY=s,this._endX=o,this._endY=a;const c=this.config.yawOffset??Math.PI/2,h=Math.atan2(a-s,o-i)+c;this.client.location={x:i,y:s},this.client.setState("rotation",h),super.start()}stop(t){const{toComponent:e,finalize:r="snap"}=this.config;if(super.stop(t),"snap"===r&&e){const t=e.center,r=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=r}}step(t){const e=(this._endX-this._startX)*t,r=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+r}}}};const wl={gradation:function(t,e,r){const{subType:n,from:i,to:s,colors:o}=r;let a;switch(n){case"linear":default:a=e.createLinearGradient(i.x,i.y,s.x,s.y);break;case"radial":a=e.createRadialGradient(i.x,i.y,i.r,s.x,s.y,s.r)}o&&(o.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:Ah};function _l(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:r,component:n,step:i=()=>{},onStart:s,onProgress:o,onComplete:a,options:c,repeat:h=!1,delta:l}=t;let u;u="string"==typeof l?bl[l]:l||ul,"out"===r?u=function(t,e){return function(r){return 1-t(1-r,e)}}(u,c):"inout"===r&&(u=function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(u,c));let d=!1,p=null;return{start:function(){if(d)return this;if(n?.root?.app?.suppressAnimations)return this;d=!0,s&&s();let t=0;const r=()=>br.simTime;return p=br.subscribe(()=>{if(!d)return;if(n?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=r());const s=(r()-t)/e,a=h?s%1:Math.min(s,1);i(u(a,c)),o&&o(a),!(s>=1)||h&&d||(this.stop(),t=0)},{description:"animate()",component:n,metadata:{duration:e,repeat:h}}),this},stop:function(){return d=!1,p&&(p(),p=null),a&&a(),this}}}({component:this,...t}),this._animate}function Ml(t,e){return function(t,e,r){const n=wl[r.type];n&&n(t,e,r)}(this,t,e)}const Sl=100;function kl(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Sl)/Sl}return e}}function Al(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const r=t[e];null===r?delete t[e]:"number"==typeof r?Number.isFinite(r)?Number.isInteger(r)||(t[e]=Math.round(r*Sl)/Sl):delete t[e]:"object"==typeof r&&Al(r)}return t}function zl(...t){return JSON.stringify(this.hierarchy,kl,...t)}function Tl(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Il(t){this.rootModel.closeScene(t)}function Ol(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 El(){this.parent&&this.parent.invalidate()}function Pl(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function jl(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function Cl(){return this.getState("data")}function Rl(t){this.setState("data",t),this.touch()}function Fl(t){const e=this.model.event?.tap;if(e){const{x:t,y:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:r}))}}function Dl(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function Nl(){return Number(this.get("retention"))||0}function Ll(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const r=e.type?vl[e.type]:void 0;return r?new r(t,e):null}(this,t.oncreate))}return this._animation}}function Bl(){return!!this.animation?.started}function Ul(t){this.animation&&(this.animation.started=t)}function Yl(){}function Wl(t,e,r,n){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function ql(t,e,r,n){return t==e.get("type")}function $l(t,e,r,n,i,s){return t(e,r,n,i)&&s.push(r),r.components&&r.components.forEach(r=>{$l(t,e,r,n,i,s)}),s}function Vl(t,e,r,n){switch(t){case"(all)":return!0;case"(parent)":return r&&r.parent===e;case"(child)":case"(children)":return r&&r===e.parent;case"(sibling)":case"(siblings)":return r&&r.parent===e.parent&&r!==e;default:return!1}}function Hl(t,e,r){if("(root)"==t)return[e];if("(self)"==t)return r?[r]:[];let n;switch(t.charAt(0)){case"#":const r=e.root.findAllById?.(t.substring(1));return r||[];case".":n=Wl;break;case"(":n=Vl;break;default:n=ql}return $l(n,t,e,r,e,[])}function Gl(t,...e){if(t(this,...e))return this}function Xl(t,...e){return"string"==typeof t?Hl(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function Zl(t,e,r){if(!this.capturable||r?.(this))return!1;const n=this.fromParent(t,e);return this.contains(n.x,n.y)?this:void 0}function Jl(t){return this.anchors.find(e=>e.name===t)}function Ql(t){return!0}function Kl(t){return this._parent.getContext(t??this)}function tu(){return this.isRoot()?this:this.parent&&this.parent.root}function eu(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function ru(){return this._parent}function nu(t){this._parent=t}function iu(){return this.nature.anchors||[]}function su(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function ou(){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 au(){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 cu(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function hu(){return this.app&&this.app.isViewMode&&this.state.origin||""}function lu(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function uu(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const du={},pu={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},fu=[],mu=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 yu=0;const bu={};const xu=new FinalizationRegistry(t=>{!function(t){yu--;let e=bu[t];e||(e=bu[t]={up:0,down:0}),e.down++}(t)});class vu{static get nature(){return pu}static register(t,e){if(!e)return du[t];du[t]=e}static types(){return Object.keys(du)}static get residents(){return bu}static get residentsCount(){return yu}static registerDecorator(t,e){Qc.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"},r=[];for(const n of Object.keys(t)){const i=e[n];if(!i)continue;const s=t[n];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&&r.push({trigger:i,action:"script",code:t,target:s.target});continue}r.push({trigger:i,action:s.action,target:s.target,value:s.value,options:{emphasize:s.emphasize,restore:s.restore,pressed:s.pressed,...s.options??{}}})}}return r}(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??1))&&(this.animation.started=!0),this.clearCache(),Vc.add(this),function(t){yu++;let e=bu[t];e||(e=bu[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(),Vc.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&&Vc.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 r=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return r._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&Vc.add(r)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&r.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 r=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return r.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]}),Al(t)}get volatile(){return fu}_applyProps(t,e,r){const n={},i={};let s=!1;const o=Po(e),a=this;if(Object.getOwnPropertyNames(o).forEach(function(e){const c=r.getBeforeVal(e),h=o[e];!r.sensitive&&function(t,e){return cs(t,e)}(c,h)||(i[e]=c,n[e]=h,t[e]=h,r.clearState&&delete a._state[e],s=!0)}),s){this._cachedState=null;Object.keys(n).some(t=>!mu.has(t))&&this.clearCache(),n.hasOwnProperty("text")&&delete this._text_substitutor,r.beforeFillStyle&&r.beforeFillStyle(n,i),n.hasOwnProperty("fillStyle")&&this.onchangeFill(n,i),r.afterFillStyle&&r.afterFillStyle(n,i),n.hasOwnProperty("data")&&this.onchangeData(n,i),this.onchange&&this.onchange(n,i),this.trigger("change",n,i)}return this}contains(t,e){return eh.call(this,t,e)}move(t,...e){rh.call(this,t,...e)}symmetryX(t){nh.call(this,t)}symmetryY(t){ih.call(this,t)}adjustResize(t,e,r){return sh.call(this,t,e,r)}adjustRotation(t,e){return oh.call(this,t,e)}outline(t){return ah.call(this,t)}get bounds(){return ch.call(this)}set bounds(t){hh.call(this,t)}get center(){return lh.call(this)}set center(t){uh.call(this,t)}get location(){return dh.call(this)}set location(t){ph.call(this,t)}get rotate(){return fh.call(this)}set rotate(t){mh.call(this,t)}get dimension(){return gh.call(this)}set dimension(t){yh.call(this,t)}get path(){return bh.call(this)}set path(t){xh.call(this,t)}get drawPath(){return vh.call(this)}get rotatePoint(){return wh.call(this)}get mutable(){return _h.call(this)}get resizable(){return Mh.call(this)}get rotatable(){return Sh.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&&Th.call(this,t)}prerender(t){Ih.call(this,t)}render(t){Oh.call(this,t)}postrender(t){Eh.call(this,t)}prepare(t,e){Ph.call(this,t,e)}prepareIf(t){jh.call(this,t)}drawText(t){Ch.call(this,t)}drawStroke(t,e){Rh.call(this,t,e)}drawFill(t,e){Fh.call(this,t,e)}get strokeStyle(){return Dh.call(this)}set strokeStyle(t){Nh.call(this,t)}get fillStyle(){return Lh.call(this)}set fillStyle(t){Bh.call(this,t)}get fontColor(){return Uh.call(this)}set fontColor(t){Yh.call(this,t)}get rotation(){return Wh.call(this)}set rotation(t){qh.call(this,t)}get decorators(){return $h.call(this)}get decotag(){return Vh.call(this)}get hidden(){return Hh.call(this)}set hidden(t){Gh.call(this,t)}get tag(){return Xh.call(this)}set tag(t){Zh.call(this,t)}get appendum(){return Jh.call(this)}set appendum(t){Qh.call(this,t)}defaultTextSubstitutor(){return Kh.call(this)}textLines(t){return tl.call(this,t)}get font(){return el.call(this)}get lineHeight(){return rl.call(this)}get textSubstitutor(){return nl.call(this)}get text(){return il.call(this)}set text(t){sl.call(this,t)}get textBounds(){return ol.call(this)}get textRotation(){return al.call(this)}get textHidden(){return cl.call(this)}set textHidden(t){hl.call(this,t)}get hasTextProperty(){return ll.call(this)}animate(t){return _l.call(this,t)}effect(t,e){return Ml.call(this,t,e)}serialize(...t){return zl.call(this,...t)}trim(){Tl.call(this)}closeScene(t){Il.call(this,t)}delta(t,e){return Ol.call(this,t,e)}invalidate(){El.call(this)}get value(){return Pl.call(this)}set value(t){jl.call(this,t)}get data(){return Cl.call(this)}set data(t){Rl.call(this,t)}set tap(t){Fl.call(this,t)}get mappings(){return Dl.call(this)}get retention(){return Nl.call(this)}get animation(){return Ll.call(this)}get started(){return Bl.call(this)}set started(t){Ul.call(this,t)}get controls(){return Yl.call(this)}findFirst(t,...e){return Gl.call(this,t,...e)}findAll(t,...e){return Xl.call(this,t,...e)}capture(t,e,r){return Zl.call(this,t,e,r)}findAnchor(t){return Jl.call(this,t)}isDescendible(t){return Ql.call(this,t)}getContext(t){return Kl.call(this,t)}get root(){return tu.call(this)}get rootModel(){return eu.call(this)}get parent(){return ru.call(this)}set parent(t){nu.call(this,t)}get anchors(){return iu.call(this)}get scalable(){return su.call(this)}get stuck(){return ou.call(this)}get capturable(){return au.call(this)}get position(){return cu.call(this)}get origin(){return hu.call(this)}get offset(){return lu.call(this)}get app(){return uu.call(this)}drawEffect(t){oc.call(this,t)}prepareFill(t,e){dc.call(this,t,e)}prepareFillIf(t){pc.call(this,t)}onchangeFill(t,e){fc.call(this,t,e)}drawImage(t,e,r,n,i,s){sc.call(this,t,e,r,n,i,s)}mutateBounds(t,e){Bc.call(this,t,e)}mutatePath(t,e,r){Uc.call(this,t,e,r)}access(t){return Xc.call(this,t)}substitute(t,e){return Zc.call(this,t,e)}onchangeMappings(t,e){ic.call(this,t,e)}onchangeData(t,e){ec.call(this,t,e)}buildMappings(){rc.call(this)}executeMappings(t){tc.call(this,t)}disposeMappings(){nc.call(this)}ondropfile(t,e){Sc.call(this,t,e)}transcoordS2P(t,e,r){return Ic.call(this,t,e,r)}transcoordP2S(t,e,r){return Tc.call(this,t,e,r)}transcoordS2T(t,e,r){return Ec.call(this,t,e,r)}transcoordT2P(t,e,r){return Pc.call(this,t,e,r)}transcoordT2S(t,e,r){return jc.call(this,t,e,r)}transcoordS2TR(t,e,r){return Oc.call(this,t,e,r)}transcoordS2O(t,e,r){return Cc.call(this,t,e,r)}transcoordC2S(t,e,r){return Rc.call(this,t,e,r)}transcoordS2C(t,e,r){return Fc.call(this,t,e,r)}toParent(t,e,r){return Ic.call(this,t,e,r)}fromParent(t,e,r){return Tc.call(this,t,e,r)}toScene(t,e,r){return Ec.call(this,t,e,r)}fromScene(t,e,r){return jc.call(this,t,e,r)}toLocal(t,e,r){return Rc.call(this,t,e,r)}toGlobal(t,e,r){return Fc.call(this,t,e,r)}toOther(t,e,r){return Cc.call(this,t,e,r)}on(t,e,r){return fa.call(this,t,e,r)}off(t,e,r){return ma.call(this,t,e,r)}once(t,e,r){return ga.call(this,t,e,r)}trigger(t,...e){return ya.call(this,t,...e)}delegate_on(t){return ba.call(this,t)}delegate_off(t){return xa.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,r){}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){}}vu.capabilities=[],vu.requires3d=!1,vu.union=function(t){let e=0,r=0,n=0,i=0,s=!1;return t.forEach(t=>{s?(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i)):(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height,s=!0)}),{left:e,top:r,width:n-e,height:i-r}},vu.transcoordR=Ac,vu.transcoordRR=zc,vu.createCanvas=lc,vu.memoize=_a,vu.mixin=function t(e,r){if(r instanceof Array)r.forEach(r=>t(e,r));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(r)>=0)return e;if(e.mixingIn.indexOf(r)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(r),r.call(e),e.mixingIn.pop(),e.mixedIn.push(r)}return e},vu.drawText=_c,vu.font=vc,vu.textLines=xc,vu.drawStroke=mc,vu.drawFill=uc,vu.reposition=function(t){let{id:e,scale:r=Nc,bold:n,italic:i,fontFamily:s="",textAlign:o,textBaseline:a,textOverflow:c,paddingTop:h,paddingBottom:l,paddingLeft:u,paddingRight:d,fontSize:p=cc.FONT_SIZE,lineWidth:f=0,lineHeight:m,lineDash:g}=t.state;l||=0,h||=0,u||=0,d||=0;const y=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),y&&(A.className=y),Object.assign(A.style,Lc,{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?g||cc.LINE_DASH:"",color:v,fontWeight:n?"bold":"",fontStyle:i?"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"}),Dc(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,r=e.offsetX??e.left??0,n=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,s=e.color??"transparent";t.element.style.boxShadow=`${r}px ${n}px ${i}px ${s}`}(t),t.isIn3DSpace())return;const z=t.delta(),T=(r&&r.x||1)*z.sx,I=(r&&r.y||1)*z.sy,O=(x||0)+z.theta,E=z.tx||0,P=z.ty||0;A.style.transform=`rotate(${O}rad) translate(${E}px, ${P}px) scale(${T}, ${I}) perspective(1px)`},vu.RetentionManager=Vc,vu.template=function(t,e,r){var n=eo.imports._.templateSettings||eo;r&&ks(t,e,r)&&(e=void 0),t=Qs(t),e=Os({},e,n,Ys);var i,s,o=Os({},e.imports,n.imports,Ys),a=Li(o),c=function(t,e){return Ls(e,function(e){return t[e]})}(o,a),h=0,l=e.interpolate||ao,u="__p += '",d=RegExp((e.escape||ao).source+"|"+l.source+"|"+(l===$s?oo:ao).source+"|"+(e.evaluate||ao).source+"|$","g"),p=ho.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,function(e,r,n,o,a,c){return n||(n=o),u+=t.slice(h,c).replace(co,qs),r&&(i=!0,u+="' +\n__e("+r+") +\n'"),a&&(s=!0,u+="';\n"+a+";\n__p += '"),n&&(u+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=c+e.length,e}),u+="';\n";var f=ho.call(e,"variable")&&e.variable;if(f){if(so.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(s?u.replace(ro,""):u).replace(no,"$1").replace(io,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var m=Ns(function(){return Function(a,p+"return "+u).apply(void 0,c)});if(m.source=u,Ds(m))throw m;return m},vu.buildSubstitutor=Jc,["rotatePoint","font","lineHeight","retention"].forEach(t=>vu.memoize(vu.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>vu.memoize(vu.prototype,t,!0));const wu=new WeakMap,_u=new WeakMap;function Mu(t){const e=t?.state?.id;return null==e||""===e?null:String(e)}function Su(t,e){if(!t||null==e)return null;const r=wu.get(t),n=r?.get(String(e));return n?function(t,e){const r=e?.parent;return!!r&&Array.isArray(r._items)&&r._items.includes(e)&&r.root===t}(t,n)?n:(r.delete(String(e)),null):null}function ku(t,e){Au(e);const r=t?.root,n=Mu(e);if(!r||!n||r===t)return;const i=wu.get(r)??new Map;wu.set(r,i),i.set(n,e),_u.set(e,{root:r,id:n})}function Au(t){const e=t&&_u.get(t);if(!e)return;_u.delete(t);const r=wu.get(e.root);r&&r.get(e.id)===t&&r.delete(e.id)}const zu=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 Tu(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?.[fr];return null!=e?String(e):null}get itemIssues(){return this._itemIssues}get itemsStale(){return this._itemsStale}_sayItemIssues(t,e){const r=this._itemIssues.length>0||this._itemsStale;this._itemIssues=t,this._itemsStale=e,(r||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 r of t){const t=this._recordKey(r);t&&e.set(t,r)}const r=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&r.set(e,t)}for(const[t,n]of r)if(!e.has(t)){try{this.removeItem(n,!0)}catch{}Au(n);try{n?.dispose?.()}catch{}}for(const[t,n]of e){if(r.has(t))continue;if(null==n.itemId)continue;const e=this._createItemFromRecord(n);if(e){e[fr]=t;try{this.handoverIn(e)}catch{}}}for(const[t,n]of e){const e=r.get(t);if(e&&n.itemState&&"function"==typeof e.setState)try{e.setState(n.itemState)}catch{}}}_reconcileItemsById(t){const e=new Map;t.forEach((t,r)=>{const n=this._recordKey(t);n&&(e.get(n)??e.set(n,[]).get(n)).push(r)});const r=[...e].filter(([,t])=>t.length>1);if(r.length>0)return void this._sayItemIssues(r.map(([t,e])=>({code:"item-duplicate",id:t,at:e})),!0);const n=new Map;for(const e of t)n.set(this._recordKey(e),e);const i=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&i.set(e,t)}const s=this._lastItemIds,o=this.root,a=[];for(const[t,e]of i)n.has(t)||setTimeout(()=>{if(e.parent===this){try{this.removeItem(e,!0)}catch{}Au(e);try{e?.dispose?.()}catch{}}},0);for(const[t,e]of n){if(i.has(t))continue;const r=Su(o,t);let n,c=!1;if(r&&r.parent!==this){if(s.has(t)){const e=r.parent?.state?.id;a.push({code:"item-repeat-report",id:t,holder:null!=e?String(e):null});continue}n=r,c=!!r.parent}else n=this._createItemFromRecord(e);if(!n)continue;n[fr]=e.slotId;const h=c?this.itemMoveAnimation():null,l={...e.slotId?{slotId:e.slotId}:{},...h?{animated:!0,...h}:{}};try{this.handoverIn(n,Object.keys(l).length?l:void 0)}catch{}}for(const[t,e]of n){const r=i.get(t);if(r){if(e.itemState&&"function"==typeof r.setState)try{r.setState(e.itemState)}catch{}if(e.itemType&&r.state?.type!==e.itemType&&"function"==typeof r.setState)try{r.setState({type:e.itemType})}catch{}if(r[fr]!==e.slotId){r[fr]=e.slotId;try{this.handoverIn(r,e.slotId?{slotId:e.slotId}:void 0)}catch{}}}}this._orderItemsAs([...n.keys()]),this._lastItemIds=new Set(n.keys()),this._sayItemIssues(a,!1)}itemMoveAnimation(){return null}_orderItemsAs(t){const e=new Map(t.map((t,e)=>[t,e])),r=this._items.filter(t=>e.has(this._currentKeyOf(t)??"")),n=[...r].sort((t,r)=>e.get(this._currentKeyOf(t))-e.get(this._currentKeyOf(r)));if(n.every((t,e)=>t===r[e]))return;let i=0;for(let t=0;t<this._items.length;t++)e.has(this._currentKeyOf(this._items[t])??"")&&(this._items[t]=n[i++]);const s=this.seatHeldItem;if("function"==typeof s)for(const t of n)s.call(this,t,{slotId:t[fr]})}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],r=new Map,n=[];for(const t of this._items){const e=t[fr];null!=e?r.set(String(e),t):n.push(t)}for(const n of t){const t=r.get(n)??null;e.push(this._slotRecordOf(n,t))}for(const t of n)e.push(this._slotRecordOf("",t));for(const[n,i]of r)t.includes(n)||e.push(this._slotRecordOf(n,i));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 r=e?.state?.id;return{slotId:t,itemId:null!=r?String(r):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const r=this._businessFields?.();if(Array.isArray(r)){if(0===r.length)return;const t={};for(const n of r)n in e&&void 0!==e[n]&&(t[n]=e[n]);return Object.keys(t).length>0?t:void 0}const n={};for(const t of Object.keys(e))zu.has(t)||t.startsWith("_")||(n[t]=e[t]);return Object.keys(n).length>0?n:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const r=vu.register?.(e);if(r&&"function"==typeof r){return new r({type:e,...t.itemState??{}})}}catch{}return null}}}class Iu extends vu{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:r=0}=this.state;if(!(e.length<=1)){t.beginPath();for(let n=0;n<e.length;n++){const i=e[(n-1+e.length)%e.length],s=e[(n+e.length)%e.length],o=e[(n+1)%e.length];if(i.x===s.x&&i.y===s.y)continue;const a=$r(s,r);let c=Math.sqrt((i.x-s.x)*(i.x-s.x)+(i.y-s.y)*(i.y-s.y)),h=0!==c?Math.atan2(i.x-s.x,i.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==n?t.moveTo(d.x,d.y):t.lineTo(d.x,d.y),a>0&&t.quadraticCurveTo(s.x,s.y,p.x,p.y),Ur(s)){const e=$r(o,r),n=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),i=0!==n?Math.atan2(s.x-o.x,s.y-o.y):0,a=Math.sin(i)*Math.min(e,n/2)+o.x,c=Math.cos(i)*Math.min(e,n/2)+o.y,h=Yr({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 Ou(t){const e=class extends t{contains(t,e){const{left:r,top:n,width:i,height:s,lineWidth:o=0}=this.state,a=o/2;return t<Math.max(r+i,r)+a&&t>Math.min(r+i,r)-a&&e<Math.max(n+s,n)+a&&e>Math.min(n+s,n)-a}set path(t){const e=t[0],r=t[2];this.set({left:e.x,top:e.y,width:r.x-e.x,height:r.y-e.y})}get path(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get anchors(){return function(t){const{left:e,top:r,width:n,height:i}=t.bounds,s=e+n/2,o=r+i/2;return[{name:"TOP",position:{x:s,y:r}},{name:"RIGHT",position:{x:e+n,y:o}},{name:"BOTTOM",position:{x:s,y:r+i}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){let{round:e=0}=this.model;const{left:r,top:n,width:i,height:s}=this.bounds;t.translate(r,n),t.beginPath(),e=function(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}(e,i,s),e>0?t.roundRect(0,0,i,s,e):t.rect(0,0,i,s),t.translate(-r,-n)}};return _a(e.prototype,"path",!1),_a(e.prototype,"bounds",!0),e}const Eu=new WeakMap,Pu="__canonicalMaterial",ju="base";function Cu(t){return Math.max(0,Math.round(100*t)/100)}function Ru(t){const e=[];var r;return null!=t.color&&e.push("c:"+(r=t.color,new Nt(r).getHexString())),null!=t.opacityFactor&&Cu(t.opacityFactor)<1&&e.push("o:"+Cu(t.opacityFactor)),e.join("|")}function Fu(t,e){const r=Ru(e);if(""===r)return t;let n=Eu.get(t);n||Eu.set(t,n=new Map);let i=n.get(r);return i||(i=t.clone(),i.userData={__isVariant:!0,[ju]:t},n.set(r,i)),function(t,e,r){if(null!=r.color&&t.color&&t.color.set(r.color),null!=r.opacityFactor){t.opacity=e.opacity*Cu(r.opacityFactor);const n=t.opacity<1||!!e.transparent;t.transparent!==n&&(t.transparent=n,t.needsUpdate=!0)}}(i,t,e),i}function Du(t){t.traverse?.(t=>{const e=t.userData?.[Pu];e&&(t.material=e,delete t.userData[Pu])})}!function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r)}({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 Nu=.001,Lu={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 Bu(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=Lu[t.preset??"default"]??Lu.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 Uu=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap"];function Yu(t){const e=t.userData;if(!e?.__bankOwned&&!e?.__isVariant){for(const e of Uu){const r=t[e];r?.dispose()}!function(t){const e=Eu.get(t);if(e){for(const t of e.values())t.dispose();Eu.delete(t)}}(t),t.dispose()}}function Wu(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)Yu(t)}})}function qu(t,e){e&&(!0===e.mirror&&(t.wrapS=g,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 $u(t){const e=function(t,e,r){const n=document.createElement("canvas");n.width=e,n.height=r;const i=n.getContext("2d");if(!i)return null;let s;if("radial"===t.gradientType){const n=e/2,o=r/2,a=Math.max(e,r)/2;switch(t.center){case"left-top":s=i.createRadialGradient(0,0,0,0,0,2*a);break;case"right-top":s=i.createRadialGradient(e,0,0,e,0,2*a);break;case"left-bottom":s=i.createRadialGradient(0,r,0,0,r,2*a);break;case"right-bottom":s=i.createRadialGradient(e,r,0,e,r,2*a);break;default:s=i.createRadialGradient(n,o,0,n,o,a)}}else{const n=t.rotation??0,o=e/2,a=r/2,c=Math.cos(n)*o,h=Math.sin(n)*a;s=i.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 i.fillStyle=s,i.fillRect(0,0,e,r),n}(t,256,256);if(!e)return;const r=new ir(e);return r.colorSpace=b,r.needsUpdate=!0,r}function Vu(t,e,r){const n=void 0!==e?e:t.state.fillStyle;if(!n||"object"!=typeof n)return;const i=n;if("pattern"===i.type&&i.image)return function(t,e,r){const{width:n,height:i}=t.bounds,s=Math.abs(n)||1,o=Math.abs(i)||1,a=new nt;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,r=2*o,n=document.createElement("canvas");n.width=t,n.height=r;const i=n.getContext("2d");if(!i)return;e.color&&(i.fillStyle=e.color,i.fillRect(0,0,t,r)),i.drawImage(c,0,0,t,r),a.image=n,a.wrapS=y,a.wrapT=y,a.repeat.set(1,1),a.offset.set(0,0)}else if(e.noRepeat){const t=2*s,r=2*o,n=2*(e.width||c.naturalWidth),i=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-n)/2,d=(r-i)/2;break;case"left-top":break;case"left-bottom":d=r-i;break;case"right-top":u=t-n;break;case"right-bottom":u=t-n,d=r-i;break;case"left":d=(r-i)/2;break;case"right":u=t-n,d=(r-i)/2;break;case"top":u=(t-n)/2;break;case"bottom":u=(t-n)/2,d=r-i}const p=document.createElement("canvas");p.width=t,p.height=r;const f=p.getContext("2d");if(!f)return;e.color&&(f.fillStyle=e.color,f.fillRect(0,0,t,r)),f.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,h+u,l+d,n,i),a.image=p,a.wrapS=y,a.wrapT=y,a.repeat.set(1,1),a.offset.set(0,0)}else{const t=e.width||c.naturalWidth,r=e.height||c.naturalHeight,n=2*t,i=2*r,h=document.createElement("canvas");h.width=n,h.height=i;const l=h.getContext("2d");if(!l)return;e.color&&(l.fillStyle=e.color,l.fillRect(0,0,n,i)),l.drawImage(c,0,0,n,i);let u=0,d=0;switch(e.align){case"center":u=(s-t)/2,d=(o-r)/2;break;case"left-top":break;case"left-bottom":d=o-r;break;case"right-top":u=s-t;break;case"right-bottom":u=s-t,d=o-r;break;case"left":d=(o-r)/2;break;case"right":u=s-t,d=(o-r)/2;break;case"top":u=(s-t)/2;break;case"bottom":u=(s-t)/2,d=o-r}const p=(e.offsetX||0)+u,f=(e.offsetY||0)+d;a.image=h,a.wrapS=g,a.wrapT=g,a.repeat.set(s/t,o/r),a.offset.set(-p/t,f/r)}a.minFilter=1006,qu(a,r),a.needsUpdate=!0,t.invalidate()},c.onerror=t=>{va("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,i,r);if("gradient"===i.type){if(Array.isArray(i.colorStops)&&i.colorStops.length>0||Array.isArray(i.gradientStops)&&i.gradientStops.length>0){const t=$u(i);return t&&qu(t,r),t}}}const Hu={policy:"state-driven"};function Gu(t){return"state-driven"===t.policy}const Xu=0;function Zu(t,e){const r=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 n=e.material;if(n)if(Array.isArray(n))for(const t of n)Ju(t,r);else Ju(n,r)})}function Ju(t,e){t.polygonOffset=e.enabled,t.polygonOffsetFactor=e.factor,t.polygonOffsetUnits=e.units,t.needsUpdate=!0}const Qu=Object.freeze(["mm","cm","m","in"]);function Ku(t){const e=(r=t?.mmPerUnit,"number"==typeof r&&Number.isFinite(r)&&r>0);var r;const n=t?.displayUnit;return{mmPerUnit:e?t.mmPerUnit:1,known:e,displayUnit:Qu.includes(n)?n:"mm"}}const td=(t,e)=>t/e.mmPerUnit;function ed(t){return Ku(t?.rootModel?.state)}function rd(t,e){for(let r=t.parent;r;r=r.parent)if(r===e)return!0;return!1}function nd(t,e){return-1!==t.findIndex(t=>t in e)}const id=()=>{};class sd{static buildFillStyleTexture(t,e,r){return Vu(t,e,r)}constructor(t){this._focused=!1,this._suppressOnchange=!1,this._onchangeWrapper=(t,e,r)=>{this._suppressOnchange||r&&r.origin&&r.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&&Zu(this.object3d,e)}get zPriority(){return Xu}getObject3dInstance(){return new Pt}build(){this.object3d.userData.context=this;const t=Bu(this.component.state.material3d),{cast:e,receive:r}=this.resolveShadow(t.castShadow,t.receiveShadow);this._applyShadow(e,r),this.object3d.name=this.component.state.id}updateMaterial3d(){const t=Bu(this.component.state.material3d),{cast:e,receive:r}=this.resolveShadow(t.castShadow,t.receiveShadow);this._applyShadow(e,r)}resolveShadow(t=!0,e=!1){return{cast:t,receive:e}}_applyShadow(t,e){const r=n=>{n.castShadow=t,n.receiveShadow=e;for(const t of n.children){const e=t.userData?.context;e&&e!==this||r(t)}};r(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&&rd(e,this.object3d)&&e.removeFromParent()}const t=[];for(const e of this.object3d.children){const r=e.userData?.context;r&&r!==this&&r instanceof sd?t.push(e):(Du(e),Wu(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??Hu}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 r=new Set((t.slots??[]).map(t=>t?.id)),n=new Set((t.outsideSlots?.()??[]).map(t=>t?.id));let i=0;for(const s of e){const e=s?._transferSlotId;if(null!=e&&n.has(e)){s?._realObject?.object3d&&t.seatHeldItem?.(s,{slotId:e});continue}if(null!=e&&r.has(e)){s?._realObject?.object3d&&t.seatHeldItem?.(s,{slotId:e});continue}const o=s?._realObject?.object3d;if(!o){i++;continue}const a=t.placementFor(s,{index:i,occupantCount:i});i++,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(!Gu(this.placement))return;if(this.component.state.screenFixed&&this.component.isHTMLElement()){const{x:t=0,y:e=0}=this.component.center,{width:r=0,height:n=0}=this.component.parent?.bounds??{};return this.object3d.position.set(t-r/2,-(e-n/2),0),void this.object3d.rotation.set(0,0,0)}const{x:t,y:e,z:r}=this.position,{x:n,y:i,z:s}=this.rotation,{x:o,y:a,z:c}=this.scale;this.object3d.position.set(t,e,r),this.object3d.rotation.set(n,i,s),this.applyScale(o,a,c)}get position(){const{x:t,y:e,z:r}=this.center;return{x:t,y:r,z:e}}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:r=0}=this.component.state;return{x:t,y:-r,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:r=0}=this.component.delta();return t+r-e/2}get cy(){const{y:t=0}=this.component.center,{height:e=0}=this.component.parent?.bounds??{},{ty:r=0}=this.component.delta();return t+r-e/2}get cz(){const t=this.effectiveZPos,{tz:e=0}=this.component.delta(),r=this.component.parent?._realObject,n=r?.geometricOffsetY??0,i=r?.receivingSurfaceY??0;return t+e+this.syncZPosOffset-n+i}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,r="number"==typeof e?.floor&&Number.isFinite(e.floor)?e.floor:0,n="number"==typeof e?.ceiling&&Number.isFinite(e.ceiling)?e.ceiling:3e3,i=Ku(t?.state);return{floor:td(r,i),ceiling:td(n,i)}}get placementMode(){return this.scenePlacement}get components3D(){return this._components3D&&this._components3D.parent===this.object3d||(this._components3D=new jt,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:r=0,height:n=0}=this.component.parent?.bounds??{},{tx:i=0,ty:s=0}=this.component.delta();return{x:t+i-r/2,y:e+s-n/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:r=0}=this.position;this.object3d.position.set(t,e,r)}updateRotate(){const{x:t=0,y:e=0,z:r=0}=this.rotation;this.object3d.rotation.set(t,e,r)}get dimensionScale(){return this._dimensionScale}setDimensionScale(t,e,r){Number.isFinite(t)&&Number.isFinite(e)&&Number.isFinite(r)&&(this._dimensionScale={x:t,y:e,z:r},this.updateScale())}applyScale(t,e,r){const n=this.restingScale();this.object3d.scale.set(Math.max(t*n.x,Nu),Math.max(e*n.y,Nu),Math.max(r*n.z,Nu))}restingScale(){const t=this._dimensionScale,e=this.displayScale,r=this._nodeScale??{x:1,y:1,z:1};return{x:t.x*e/r.x,y:t.y*e/r.y,z:t.z*e/r.z}}get displayScale(){return this._displayScale??1}setTransientDisplayScale(t,e){if(!(Number.isFinite(t)&&t>0))return;const r=e&&[e.x,e.y,e.z].every(t=>Number.isFinite(t)&&t>0)?{...e}:this._nodeScale;var n,i;t===this.displayScale&&(n=r,i=this._nodeScale,(n?.x??1)===(i?.x??1)&&(n?.y??1)===(i?.y??1)&&(n?.z??1)===(i?.z??1))||(this._displayScale=t,this._nodeScale=r,this.updateScale())}updateScale(){const{x:t=1,y:e=1,z:r=1}=this.scale;this.applyScale(t,e,r)}syncAnimationDelta(){if(this.suppressTransform)return;const t=this.component.delta();this.updatePosition();const{rotationX:e=0,rotationY:r=0,rotation:n=0}=this.component.state,i=t.theta||0,s=t.rx||0,o=t.ry||0,a=t.rz||0;this.object3d.rotation.set(e+s,-(n+i)+o,r+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 r=Array.isArray(e.material)?e.material:[e.material];for(const e of r)e.opacity=t,e.transparent=e.opacity<1}})}}updateDimension(){this.clear(),this.build()}updateAlpha(){this.applyMaterialOpacity()}isModelingFaint(){return zh(this.component)}applyMaterialOpacity(){const t=this.component.state.alpha,e=null==t?1:t,r=this.isModelingFaint(),n=t=>{t.material&&function(t,e,r){if(!t.material)return;let n=t.userData[Pu];n||(n=t.material,t.userData[Pu]=n);const i=t=>{const n=t?.userData?.[ju]??t;return r?Fu(n,{opacityFactor:.5}):e<1?Fu(n,{color:t.color,opacityFactor:e}):t};t.material=Array.isArray(n)?n.map(i):i(n)}(t,e,r);for(const e of t.children){const t=e.userData?.context;t&&t!==this&&t instanceof sd||n(e)}};n(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 r=t=>{const n=t.userData?.context;if(t===this.object3d||!n||n===this){t.userData?.alwaysRaycast||(e?delete t.raycast:t.raycast=id);for(const e of t.children)r(e)}};r(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:r=0,height:n=0}=e.parent?.bounds??{},i=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0,e.bounds={left:t.position.x-s+r/2-i.width/2,top:t.position.z-o+n/2-i.height/2,width:i.width,height:i.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(),nd(["cx","cy","cz","zPos","left","top"],t)&&!this.suppressTransform&&Gu(this.placement)&&this.updatePosition(),nd(["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(nd(["segments","heightSegments"],t)&&this.update(),nd(["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(),nd(["text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline"],t))this._lastText=this.component.hasTextProperty?this.component.text:"",this.updateText();else if(nd(["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 od=new Map;function ad(t){return t.userData.__bankOwned=!0,t}const cd={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 r=od.get(e);return r||od.set(e,r=ad(function(t){switch(t.kind){case"box":return new sr(1,1,1);case"plane":return new ar(1,1);case"cylinder":return new or(.5,.5,1,t.segments??16);case"sphere":return new cr(.5,t.segments??16,t.heightSegments??Math.max(2,Math.round((t.segments??16)/2)))}}(t))),r},shaped(t,e){const r="shaped::"+t;let n=od.get(r);return n||od.set(r,n=ad(e())),n},owns:t=>!0===t.userData?.__bankOwned,get size(){return od.size},has:t=>od.has("primitive::"+t)||od.has("shaped::"+t),dispose(){for(const t of od.values())t.dispose();od.clear()}};let hd=null;const ld=new Set;let ud=null;function dd(){for(const t of[...ld]){const e=t.deref();e?e.refreshLook():ld.delete(t)}}function pd(t){ud?.(),hd=t,ud=t?t.subscribe(dd):null,dd()}function fd(t){return hd?.dimsOf(t)??null}const md=t=>Number(t.component.state.depth)||t.depth,gd="#9e9e9e";class yd extends(Ou(Iu)){constructor(){super(...arguments),this._look=null,this._lookKey=null,this._seatDims=null}get isItem(){return!0}is3dish(){return!0}get lookNow(){return this._look}get look(){this._lookRef||ld.add(this._lookRef=new WeakRef(this));const t=hd?.keyFor(this)??null;return(t!==this._lookKey||t&&!this._look)&&(this._look?.dispose(),this._look=t?hd?.lookFor(this)??null:null,this._lookKey=this._look?t:null,this.fitLook()),this._look}get seatDims(){return this._seatDims}takeSeatDims(t){var e,r;(e=t,r=this._seatDims,e===r||e&&r&&e.width===r.width&&e.depth===r.depth&&e.height===r.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=hd?.keyFor(this)??null;(t!==this._lookKey||t&&!this._look)&&(this._look?.dispose(),this._look=null,this._lookKey=null,this._realObject?.rebuildLook?.(),this.invalidate?.())}onchange(t,e){super.onchange?.(t,e),"type"in t&&(this.refreshLook(),this.parent?._reseatSlot?.(this[fr])),"data"in t&&this._look&&this._look.component.set("data",t.data)}get sized(){const{width:t=0,height:e=0,depth:r=0}=this.state;return t>0&&e>0&&r>0}get shownSize(){if(this.sized){const{width:t,height:e,depth:r}=this.state;return{width:t,height:e,depth:r}}const t=ed(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:md(e)};const r=200/t;return{width:r,height:r,depth:r}}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;if(r>0&&n>0)return super.bounds;const i=this.shownSize;return{left:t,top:e,width:i.width,height:i.height}}render(t){const{left:e,top:r,width:n,height:i}=this.bounds,s=this.look;if(s){const o=s.component,a={left:e+(n-(Number(o.state.width)||0))/2,top:r+(i-(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,r,n,i),this.sized&&t.fill(),t.stroke(),t.restore()}buildRealObject(){return new bd(this)}dispose(){this._lookRef&&ld.delete(this._lookRef),this._look?.dispose(),this._look=null,super.dispose()}}class bd extends sd{constructor(){super(...arguments),this.box=null,this.shown=null}getObject3dInstance(){return new jt}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,r=t.shownSize;if(e){const t=e.component.realObject,n=t?.object3d;if(!t||!n)return;return t.suppressTransform=!0,n.position.set(0,(md(e)-r.depth)/2,0),n.quaternion.identity(),this.object3d.add(n),void(this.shown=n)}const n=new rr(cd.primitive({kind:"box"}),new hr({color:t.state.fillStyle||gd,wireframe:!t.sized&&!t.seatDims}));n.scale.set(r.width,r.depth,r.height),this.object3d.add(n),this.box=n}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",vd=64,wd=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function _d(t){if(!wd(t)||!Array.isArray(t.types))return{types:new Map,issues:[{code:"item-types-shape"}]};const e=[],r=new Map;t.types.forEach((t,n)=>{const i=wd(t)?t:{},s=i.code;if("string"!=typeof s||!s||s!==s.trim()||s.length>64)return e.push({code:"item-type-code",at:n});const o=i.figure;if(null!=o&&("string"!=typeof o||!o))return e.push({code:"item-type-figure",at:n});const a="string"==typeof i.name&&i.name?i.name:s,c=r.get(s);c?c.at.push(n):r.set(s,{type:{code:s,name:a,figure:o??null},at:[n]})});const n=new Map;for(const[t,{type:i,at:s}]of r)s.length>1?e.push({code:"item-type-duplicate",id:t,at:s}):n.set(t,i);return{types:n,issues:e}}function Md(t,e=xd){const r=(t??[]).filter(t=>t?.type===e&&t.active);if(0===r.length)return{types:new Map,issues:[]};if(r.length>1)return{types:new Map,issues:[{code:"item-types-active-many",names:r.map(t=>String(t.name??""))}]};let n=r[0].value;if("string"==typeof n)try{n=JSON.parse(n)}catch{return{types:new Map,issues:[{code:"item-types-shape"}]}}return _d(n)}function Sd(t){return wd(t)&&t.types instanceof Map&&Array.isArray(t.issues)}function kd(t){const e=t?.root;return e&&e!==t?e.itemTypes:t?.itemTypes}class Ad extends Error{code;path;details;constructor(t,e,r,n){super(`${t}: ${e}: ${r}`),this.name="FigureContractError",this.code=t,this.path=e,void 0!==n&&(this.details=n)}}function zd(t,e,r){return r?{code:t,path:e,params:r}:{code:t,path:e}}const Td="holder",Id=t=>"number"==typeof t&&Number.isFinite(t),Od=t=>Id(t)&&t>0,Ed=t=>Number.isSafeInteger(t)&&t>0;function Pd(t,e,r){const n=t?.allowed;if(n&&"object"==typeof n)for(const t of["width","depth","height"])Od(n[t])||r.push(zd("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else r.push(zd("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||Ed(t.stackLimit)||t.stackLimit===1/0||r.push(zd("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||Id(t.rotation)||r.push(zd("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||r.push(zd("ARRAY_REQUIRED",`${e}.accepts`))}function jd(t,e={}){const r=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[zd("TIERS_REQUIRED","tiers")];const n=e.anchors?new Set(e.anchors):null,i=new Set;return t.tiers.forEach((t,e)=>{const s=`tiers[${e}]`;if(!t||"object"!=typeof t)return void r.push(zd("OBJECT_REQUIRED",s));if(Ed(t.tierNo)?i.has(t.tierNo)?r.push(zd("TIER_NUMBER_DUPLICATE",`${s}.tierNo`,{tierNo:t.tierNo})):i.add(t.tierNo):r.push(zd("POSITIVE_INTEGER_REQUIRED",`${s}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?n&&!n.has(t.anchorId)&&r.push(zd("ANCHOR_UNKNOWN",`${s}.anchorId`,{anchorId:t.anchorId})):r.push(zd("ANCHOR_REQUIRED",`${s}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||r.push(zd("MOUNT_INVALID",`${s}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])Id(t.position[e])||r.push(zd("FINITE_NUMBER_REQUIRED",`${s}.position.${e}`));else r.push(zd("OBJECT_REQUIRED",`${s}.position`));Id(t.rotation)||r.push(zd("FINITE_NUMBER_REQUIRED",`${s}.rotation`));const o=t.layout;switch(o?.pattern){case"SINGLE":Pd(o.slot,`${s}.layout.slot`,r);break;case"ROW":Ed(o.count)||r.push(zd("POSITIVE_INTEGER_REQUIRED",`${s}.layout.count`)),Od(o.pitch)||r.push(zd("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch`)),"X"!==o.axis&&"Z"!==o.axis&&r.push(zd("AXIS_INVALID",`${s}.layout.axis`)),Pd(o.slot,`${s}.layout.slot`,r);break;case"GRID":Ed(o.rows)||r.push(zd("POSITIVE_INTEGER_REQUIRED",`${s}.layout.rows`)),Ed(o.cols)||r.push(zd("POSITIVE_INTEGER_REQUIRED",`${s}.layout.cols`)),Od(o.pitch?.x)||r.push(zd("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch.x`)),Od(o.pitch?.z)||r.push(zd("POSITIVE_NUMBER_REQUIRED",`${s}.layout.pitch.z`)),Pd(o.slot,`${s}.layout.slot`,r);break;case"CUSTOM":{if(!Array.isArray(o.slots)){r.push(zd("ARRAY_REQUIRED",`${s}.layout.slots`));break}o.slots.length||r.push(zd("SLOTS_REQUIRED",`${s}.layout.slots`));const t=new Set;o.slots.forEach((e,n)=>{const i=`${s}.layout.slots[${n}]`;Ed(e?.slotNo)?t.has(e.slotNo)?r.push(zd("SLOT_NUMBER_DUPLICATE",`${i}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):r.push(zd("POSITIVE_INTEGER_REQUIRED",`${i}.slotNo`)),Id(e?.offset?.x)&&Id(e?.offset?.z)||r.push(zd("FINITE_NUMBER_REQUIRED",`${i}.offset`)),Pd(e,i,r)});break}default:r.push(zd("PATTERN_INVALID",`${s}.layout.pattern`))}}),r}function Cd(t,e=""){const r=[],n=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,r)=>n(t,`${e}[${r}]`));else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))n(i,e?`${e}.${r}`:r)}else r.push(zd("NOT_PERSISTABLE",e,{value:String(t)}))};return n(t,e),r}function Rd(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 Fd(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:Rd(t)},(t,e)=>e+1)}function Dd(t,e,r,n,i="ROW_MAJOR"){switch(i){case"ROW_MAJOR":return(r-1)*e+n;case"COL_MAJOR":return(n-1)*t+r;case"SERPENTINE_ROW":return(r-1)*e+(r%2==1?n:e-n+1);case"SERPENTINE_COL":return(n-1)*t+(n%2==1?r:t-r+1)}}function Nd(t,e,r,n="ROW_MAJOR"){const i=r-1;switch(n){case"ROW_MAJOR":return{r:Math.floor(i/e)+1,c:i%e+1};case"COL_MAJOR":return{r:i%t+1,c:Math.floor(i/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(i/e)+1,r=i%e+1;return{r:t,c:t%2==1?r:e-r+1}}case"SERPENTINE_COL":{const e=Math.floor(i/t)+1,r=i%t+1;return{r:e%2==1?r:t-r+1,c:e}}}}const Ld=(t,e)=>e&&0!==t?-t:t;function Bd(t,e,r={}){const n=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!n||!Ed(e.slot))return null;const i=n.layout;let s,o,a;switch(i.pattern){case"SINGLE":if(1!==e.slot)return null;s=i.slot,o={x:0,z:0};break;case"ROW":{if(e.slot>i.count)return null;const t=Ld((e.slot-1-(i.count-1)/2)*i.pitch,"MAX"===i.origin);s=i.slot,o="X"===i.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>i.rows*i.cols)return null;const{r:t,c:r}=Nd(i.rows,i.cols,e.slot,i.order),n=i.origin??{x:"MIN",z:"MIN"};s=i.slot,o={x:Ld((r-1-(i.cols-1)/2)*i.pitch.x,"MAX"===n.x),z:Ld((t-1-(i.rows-1)/2)*i.pitch.z,"MAX"===n.z)};break}case"CUSTOM":{const t=i.slots.find(t=>t.slotNo===e.slot);if(!t)return null;s=t,o={...t.offset},a=t.name;break}}return{tier:n.tierNo,slotNo:e.slot,name:a,anchorId:n.anchorId,mount:n.mount,tierPosition:{...n.position},tierRotation:n.rotation,offset:o,allowed:{...s.allowed},accepts:s.accepts?[...s.accepts]:void 0,stackLimit:s.stackLimit??r.defaultStackLimit??1,rotation:s.rotation??0}}function Ud(t){return`t${t.tier}_s${t.slot}`}function Yd(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*Wd(t){for(const e of t?.tiers??[])for(const t of Fd(e.layout))yield{tier:e.tierNo,slot:t}}function qd(t,e,r){if(!r)return{x:t,z:e};const n=r*Math.PI/180,i=Math.cos(n),s=Math.sin(n),o=t=>Math.round(1e9*t)/1e9;return{x:o(t*i+e*s),z:o(-t*s+e*i)}}function $d(t){const e=qd(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 Vd=.05,Hd=t=>!!t&&Od(t.width)&&Od(t.depth)&&Od(t.height);function Gd(t,e){const r=e*Math.PI/180,n=Math.abs(Math.cos(r)),i=Math.abs(Math.sin(r)),s=t=>Math.round(1e9*t)/1e9;return{width:s(t.width*n+t.depth*i),depth:s(t.width*i+t.depth*n)}}function Xd(t,e,r=0,n=.05){if(!Hd(t))return null;if(!Id(r)||!Id(n)||n<0||n>=1)return null;const i=Gd(t,e.rotation),s=Math.min(1,Math.min(e.allowed.width/i.width,e.allowed.depth/i.depth)*(1-n)),o=t.height*s;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(r+o/2),z:0},rotation:0,scale:s}}function Zd(t,e,r=0,n=.05){const i=Xd(t,e,r,n);if(!i)return null;const s=$d(e);return{position:{x:s.position.x,y:s.position.y+i.position.y,z:s.position.z},rotation:s.rotation,scale:i.scale}}function Jd(t,e,r=.05){let n=0;return t.map(t=>{const i=t?Zd(t,e,n,r):null;return i&&(n+=t.height*i.scale),i})}const Qd=1e-6;function Kd(t,e){const r=$d(t),n=t.allowed.width/2,i=t.allowed.depth/2,s=[[-n,-i],[n,-i],[n,i],[-n,i]].map(([t,e])=>{const n=qd(t,e,r.rotation);return{x:r.position.x+n.x,z:r.position.z+n.z}}),o=qd(1,0,r.rotation),a=qd(0,1,r.rotation),c="HANG"===t.mount?-1:1,h=[r.position.y,r.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 tp(t,e){for(const r of[...t.axes,...e.axes]){const n=t.corners.map(t=>t.x*r.x+t.z*r.z),i=e.corners.map(t=>t.x*r.x+t.z*r.z);if(Math.min(Math.max(...n),Math.max(...i))-Math.max(Math.min(...n),Math.min(...i))<=Qd)return!1}return!0}function ep(t,e={}){const r=[],n=new Map;t.tiers.forEach((e,r)=>{const i=n.get(e.anchorId)??[];n.set(e.anchorId,i);for(const n of Fd(e.layout))i.push(Kd(Bd(t,{tier:e.tierNo,slot:n}),r))});for(const[t,i]of n){const n=e.anchorFaces?.[t];if(n)for(const t of i)t.corners.some(t=>Math.abs(t.x)-n.width/2>Qd||Math.abs(t.z)-n.depth/2>Qd)&&r.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else r.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const s=[...i].sort((t,e)=>t.minX-e.minX);for(let t=0;t<s.length;t++){const e=s[t];for(let n=t+1;n<s.length&&s[n].minX<e.maxX-Qd;n++){const t=s[n];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=Qd)continue;if(!tp(e,t))continue;const[i,o]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];r.push({code:"SLOT_OVERLAP",path:`tiers[${o.tierIndex}]`,params:{tier:o.tier,slot:o.slot,otherTier:i.tier,otherSlot:i.slot}})}}}return r}function rp(t,e,r=[],n={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const i=n.normalizeType??(t=>null==t?"":String(t)),s=[];let o=!1;if(t.accepts){const r=i(e.type);r?t.accepts.map(i).includes(r)||s.push("TYPE_NOT_ACCEPTED"):o=!0}if(r.length+1>t.stackLimit&&s.push("STACK_LIMIT_EXCEEDED"),Hd(e.dims)){const n=Gd(e.dims,t.rotation);if(n.width>t.allowed.width&&s.push("WIDTH_EXCEEDED"),n.depth>t.allowed.depth&&s.push("DEPTH_EXCEEDED"),r.every(t=>Hd(t.dims))){r.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 np(t){const e=(t,e,r)=>{throw new Ad("ITEM_SNAPSHOT",t,e,r)},r=t;r&&"object"==typeof r&&"string"==typeof r.revision&&Array.isArray(r.items)||e("snapshot","a revision and a list of items",{reason:"item-snapshot-shape"});const n=new Set,i=new Map;r.items.forEach((t,r)=>{const s=`items[${r}]`;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(r=t.dims[e])&&Number.isFinite(r)&&t.dims[e]>0;var r})||e(`${s}.dims`,"three positive numbers in mm",{reason:"item-invalid-dimensions",item:t.itemId}),n.has(t.itemId)&&e(s,`${t.itemId} is in the snapshot twice`,{reason:"item-duplicate",item:t.itemId}),n.add(t.itemId),i.set(t.slotId,[...i.get(t.slotId)??[],t.stackIndex])});for(const[t,r]of i){const n=[...r].sort((t,e)=>t-e);n.forEach((r,i)=>{r!==i&&e("items",`the stack in ${t} has ${n.join(", ")}; each height once, from 0`,{reason:"item-stack-index",slot:t,heights:n})})}}function ip(t,e,r){const n=null!=e?{source:"override",raw:e}:t?{source:"figure",raw:t}:void 0;if(!n)return{source:"none",status:"none",issues:[]};const i=function(t,e){const r=jd(t,{anchors:[...e]});if(r.length)return r;const n=Cd(t);if(n.length)return n;const i=[],s=t=>Array.isArray(t)&&t.length>0;return t.tiers.forEach((t,e)=>{const r=t.layout;"CUSTOM"===r.pattern?r.slots.forEach((t,r)=>s(t.accepts)||i.push(zd("ACCEPTS_REQUIRED",`tiers[${e}].layout.slots[${r}].accepts`))):s(r.slot.accepts)||i.push(zd("ACCEPTS_REQUIRED",`tiers[${e}].layout.slot.accepts`))}),i}(n.raw,r);return i.length?{source:n.source,status:"invalid",issues:i,refusal:{code:"SLOT_LAYOUT",details:{reason:"slot-layout-issues",issues:i}}}:{source:n.source,status:"valid",layout:n.raw,issues:[]}}function sp(t,e){const r=new Map;for(const n of t._items??[]){if(e&&n===e.item)continue;const t=n?.[fr];"string"==typeof t&&t&&(r.get(t)??r.set(t,[]).get(t)).push(n)}return e&&(r.get(e.slotId)??r.set(e.slotId,[]).get(e.slotId)).push(e.item),r}function op(t,e=""){return ap(t,sp(t),e).snapshot}function ap(t,e,r){const n=new Map,i=new Set,s=[];let o=0;for(const[r,a]of e)a.forEach((e,a)=>{let c=Mu(e);c&&!i.has(c)||(c=`#${o}`),o++,i.add(c),n.set(e,c);const h=t.itemTypeOf?.(e)??null,l=t.itemDimsOf?.(e)??null;s.push({itemId:c,slotId:r,stackIndex:a,...h?{type:h}:{},...l?{dims:l}:{}})});return{snapshot:{revision:r,items:s},ids:n}}function cp(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 hp(t,e){const r=$d(t),n=e?.position.y??0;return{position:{x:r.position.x,y:r.position.y+n,z:r.position.z},rotation:r.rotation,scale:e?.scale??1}}function lp(t,e,r,n,i,s){if(!t.itemShownDimsOf)return;let o=0;for(const a of n){const n=i.get(a),c=t.itemDimsOf?.(a)??("seated"===n.status?null:t.itemShownDimsOf(a,r,e)),h="seated"===n.status?n.inSlot:c?Xd(c,r,o,s):null;if(!h||!c)return;o+=c.height*h.scale,"seated"!==n.status&&i.set(a,{...n,inSlot:h,inAnchor:hp(r,h),shrunk:h.scale<1,dims:c})}}function up(t,e){const r=t.effectiveLayout?.layout,n=new Map((t.outsideSlots?.()??[]).map(t=>[t.id,t])),i=sp(t,e),s=new Map,o=new Map;for(const[e,r]of i){const i=n.get(e);if(!i){o.set(e,r);continue}const a=cp(i);let c=0,h=!0;r.forEach((r,n)=>{const o=t.itemDimsOf?.(r)??null,l={slotId:e,stackIndex:n,outside:!0,anchorId:i.anchorId,shrunk:!1,dims:o},u=h&&o?Xd(o,a,c,0):null;if(!u){const t=h?"size-unknown":"below-unknown";return h=!1,s.set(r,{...l,status:"unconfirmed",why:t,inSlot:null,inAnchor:hp(a,null)})}c+=o.height,s.set(r,{...l,status:"seated",inSlot:u,inAnchor:hp(a,u)})}),lp(t,e,a,r,s,0)}const{snapshot:a,ids:c}=ap(t,o,""),h=new Map(function(t,e,r={}){np(e);const n=r.margin??Vd,i=new Map;for(const t of e.items)i.set(t.slotId,[...i.get(t.slotId)??[],t]);const s=new Map;for(const[e,o]of i){const i=[...o].sort((t,e)=>t.stackIndex-e.stackIndex),a=t?Yd(e):null,c=a?Bd(t,a):null;let h=0,l=!0;i.forEach((t,o)=>{const a=rp(c,{type:t.type,dims:t.dims??null},i.slice(0,o).map(t=>({type:t.type,dims:t.dims??null})),r.normalizeType?{normalizeType:r.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?Xd(t.dims,c,h,n):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))}(r,a).map(t=>[t.itemId,t]));for(const[e,n]of c){const i=h.get(n),o=r?Yd(i.slotId):null,a=o?Bd(r,o):null;s.set(e,{slotId:i.slotId,stackIndex:i.stackIndex,status:i.status,...i.why?{why:i.why}:{},fit:i.fit,outside:!1,anchorId:a?.anchorId??null,inSlot:i.seat,inAnchor:a&&"unplaced"!==i.status?hp(a,i.seat):null,shrunk:i.shrunk,dims:t.itemDimsOf?.(e)??null})}for(const[e,n]of o){const i=r?Yd(e):null,o=i?Bd(r,i):null;o&&lp(t,e,o,n,s,Vd)}return s}const dp=[{id:"__default__",maxCount:1/0}];function pp(t){const e={id:Ud({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function fp(t,e,r){const n=t.itemTypeOf?t.itemTypeOf(r):r?.state?.type??r?.type;return e.accepts?!!n&&e.accepts.includes(n):!e.allowedTypes?.length||!!n&&e.allowedTypes.includes(n)}function mp(t){var e;return e=class extends t{get slotLayout(){}get effectiveLayout(){const t=this.slotLayout,e=this.state?.slotLayout,r=this.slotAnchors(),n=r.join("\n"),i=this.__effectiveLayout;if(i&&i.declared===t&&i.override===e&&i.anchors===n)return i.value;const s=ip(t,e,r);return this.__effectiveLayout={declared:t,override:e,anchors:n,value:s},s}slotAnchors(){return[Td]}anchorObject3D(t){const e=this._realObject?.object3d;return t===Td&&e?function(t){let e=t.userData.itemAnchor;if(!e||e.parent!==t){const r=new jt;r.name="item-anchor";const n=r.updateMatrix.bind(r);r.updateMatrix=()=>{const t=r.parent?.scale;t&&r.scale.set(1/(t.x||1),1/(t.y||1),1/(t.z||1)),n()},t.add(r),t.userData.itemAnchor=r,e=r}return e.updateMatrix(),e}(e):null}outsideSlots(){return[]}itemTypeOf(t){const e=kd(this);if(e)return function(t,e){const r=e?.state?.type??e?.type;return"string"==typeof r?t.types.get(r)??null:null}(e,t)?.code??null;const r=t?.state?.type??t?.type;return"string"==typeof r&&r?r:null}get mmPerSceneUnit(){return ed(this).mmPerUnit}itemDimsOf(t){const e=function(t,e){const[r,n,i]=[Number(t?.state?.width),Number(t?.state?.height),Number(t?.state?.depth)];return[r,n,i].every(t=>Number.isFinite(t)&&t>0)?{width:r*e,depth:n*e,height:i*e}:null}(t,this.mmPerSceneUnit);return e||(kd(this)?null:fd(t))}itemShownDimsOf(t,e,r){if(!kd(this))return null;const{width:n,depth:i,height:s}=e.allowed;if(![n,i,s].every(t=>Number.isFinite(t)&&t>0))return fd(t);return{width:n,depth:i,height:s/(Number.isFinite(e.stackLimit)&&e.stackLimit>0?e.stackLimit:1)}}itemSeatOf(t,e){const r=e??t?.[fr];if("string"!=typeof r||!r)return null;return up(this,t?.[fr]===r&&this._items?.includes(t)?void 0:{item:t,slotId:r}).get(t)??null}get slots(){const t=this.effectiveLayout.layout;if(!t)return[];const e=[];for(const r of Wd(t)){const n=Bd(t,r);n&&e.push(pp(n))}return e}slotById(t){const e=this.outsideSlots().find(e=>e.id===t);if(e)return{id:e.id,maxCount:1/0};const r=this.effectiveLayout.layout;if(r){const e=Yd(t),n=e?Bd(r,e):null;return n?pp(n):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,r=0,n){const i=this.effectiveLayout.layout,s=i?Yd(t):null,o=s?Bd(i,s):null,a=o?Zd(e,o,r,n):null;return a?{...a,anchorId:o.anchorId}:null}get arrangementStrategy(){return f}canReceive(t,e){const r=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return Mr.log({role:"target",contract:"canReceive",component:this,args:{carrier:ur(t)},result:r}),r}findSlot(t){const e=this.slots.length?this.slots:dp;for(const r of e){if(!fp(this,r,t))continue;const e=r.maxCount??this.arrangementStrategy.capacity(r),n=this._countOccupied(r.id);if(!(n>=e))return Mr.log({role:"target",contract:"findSlot",component:this,args:{carrier:ur(t)},result:{slotId:r.id,occupied:n,max:e}}),r}return Mr.log({role:"target",contract:"findSlot",component:this,args:{carrier:ur(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const r=this._realObject?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new N;r.getWorldQuaternion(n);const i=new N(e.x,e.y,e.z,e.w);return n.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,r=e?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new L;r.getWorldPosition(n);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new L(0,i,0);return r.localToWorld(t),{x:n.x,y:t.y,z:n.z}}return{x:n.x,y:n.y,z:n.z}}attachPointFor(t,e){const r=e?.slotId??t?.[fr];if(!r)return null;if("none"!==this.effectiveLayout.status||this.outsideSlots().length){const e=this.itemSeatOf(t,r),n=e?.anchorId&&e.inAnchor?this.anchorObject3D(e.anchorId):null;if(!e||!n)return null;const i=this.mmPerSceneUnit,s=e.inAnchor;return{attach:n,localPosition:{x:s.position.x/i,y:s.position.y/i,z:s.position.z/i},localRotation:{x:0,y:s.rotation*Math.PI/180,z:0},carryPolicy:"slot",displayScale:s.scale,slotId:r,seat:e}}const n=this.slots.find(t=>t.id===r);return n?{position:n.localPosition??{x:0,y:0,z:0},rotation:n.localRotation??{x:0,y:0,z:0},slotId:n.id}:null}placementFor(t,e={}){const r=t&&"object"==typeof t&&"state"in t?t:void 0,n=r?r.state??{}:t??{},i={width:Number(n.width)||0,height:Number(n.height)||0,depth:Number(n.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,r??{state:{...i}});if(!c)return null;const h=Number(this.state?.width)||0,l=Number(this.state?.height)||0,u=c.x+i.width/2-h/2,d=c.y+i.height/2-l/2,p=this._realObject,f=p?.placementMode??"floor",m="space"===f?0:"inverted"===f?-i.depth/2:i.depth/2,g=this._receivingSurfaceLocalY();let y;y=null!==g?g+m:s.localPosition&&Number.isFinite(s.localPosition.z)?s.localPosition.z+m:m-(p?.geometricOffsetY??0);const b=this.acceptanceRotation?.(r??i,s)??void 0;return b?{position:{x:u,y:y,z:d},rotation:b}:{position:{x:u,y:y,z:d}}}_zPosFromSeatY(t,e,r){const n=this._realObject,i=n?.receivingSurfaceY??0,s=!(!r.localPosition||!Number.isFinite(r.localPosition.z));if(0===i&&!s)return null;const o=Number(e)||0,a=n?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-o/2:o/2)+(n?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!fp(this,t,e))return null;const r=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<r?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[fr]===t).length;const r=this.components;return r?r.filter(e=>e.parent===this&&e[fr]===t).length:0}},e.__hasCapacity=!0,e}function gp(t,e){const r=t.left??0,n=t.top??0,i=t.width??0,s=t.height??0;if(i<=0||s<=0)return[];const o="number"==typeof t.rotation?t.rotation:0,a=Math.cos(o),c=Math.sin(o),h=r+i/2,l=n+s/2,u="inbound"===e?-1:1;return[{lx:-i/2,lz:0,odx:-1,odz:0},{lx:i/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,r;return{worldPos:(e=t.lx,r=t.lz,{x:h+e*a-r*c,z:l+e*c+r*a}),direction:{x:u*(t.odx*a-t.odz*c),z:u*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?s/2:i/2}})}function yp(t,e){const r=t.left??0,n=t.top??0,i=t.width??0,s=t.height??0;if(i<=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&&i<s,h=r+i/2,l=n+s/2,u=c?s/2:i/2,d=c?0:1,p=c?1:0,f=Math.cos(o),m=Math.sin(o),g=(t,e)=>({x:h+t*f-e*m,z:l+t*m+e*f}),y=c?{lx:0,lz:-u}:{lx:-u,lz:0},b=c?{lx:0,lz:u}:{lx:u,lz:0},x=g(y.lx,y.lz),v=g(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?i: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 bp(t){const e=t.left??0,r=t.top??0,n=t.width??0,i=t.height??0;if(n<=0||i<=0)return null;const s="number"==typeof t.rotation?t.rotation:0,o="vertical"===t.orientation||"horizontal"!==t.orientation&&n<i,a=e+n/2,c=r+i/2,h=o?i/2:n/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 xp(t){const e=t.cx??0,r=t.cy??0,n=Math.abs(t.rx??100),i=Math.abs(t.ry??100),s=t.ratio??50,o=(n+n*s/100)/2,a=(i+i*s/100)/2,c=t.startAngle??0,h=t.endAngle??Math.PI/2,l="reverse"===t.status;if(n<=0||i<=0)return{inbounds:[],outbounds:[]};const u={x:e+o*Math.sin(c),z:r-a*Math.cos(c)},d={x:e+o*Math.sin(h),z:r-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 vp(t){const e=yp(t),r=e.outbounds[0];if(!r)return{inbounds:gp(t,"inbound"),outbounds:[]};const n=gp(t,"inbound").filter(t=>{const e=t.worldPos.x-r.worldPos.x,n=t.worldPos.z-r.worldPos.z;return Math.hypot(e,n)>1}),i=r.direction,s=[];for(const t of n){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const r=t.direction.x+i.x,n=t.direction.z+i.z,o=Math.hypot(r,n)||1;s.push({worldPos:t.worldPos,direction:{x:r/o,z:n/o},halfSpan:t.halfSpan})}return{inbounds:[...n,...s],outbounds:e.outbounds}}function wp(t,e,r={}){const n=r.distance??5,i=r.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<i)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 r=t.direction.x,i=t.direction.z;if(Math.abs(s*r+o*i)>n)return!1;const a=Math.abs(s*-i+o*r);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(s,o)<=n}function _p(t,e,r,n=0){const i=r.width??0,s=r.height??0;if(i<=0||s<=0)return!1;const o=(r.left??0)+i/2,a=(r.top??0)+s/2,c="number"==typeof r.rotation?r.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)<=i/2+n&&Math.abs(f)<=s/2+n}function Mp(t,e,r){const n=r.width??0,i=r.height??0;if(n<=0||i<=0)return 1/0;const s=(r.left??0)+n/2,o=(r.top??0)+i/2;let a=t.x-s,c=t.z-o,h=e.x,l=e.z;const u="number"==typeof r.rotation?r.rotation:0;if(0!==u){const t=Math.cos(-u),e=Math.sin(-u),r=a*e+c*t,n=h*e+l*t;a=a*t-c*e,c=r,h=h*t-l*e,l=n}const d=n/2,p=i/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 Sp(t,e,r,n=6){return!!_p(t.worldPos.x,t.worldPos.z,e,n)&&(!r||t.direction.x*r.x+t.direction.z*r.z>=0)}function kp(t,e,r){return t.outbounds.map(t=>{const n=[];for(const i of e){let e=null;for(const n of i.topology.inbounds){if(!wp(t,n,r))continue;const i=t.worldPos.x-n.worldPos.x,s=t.worldPos.z-n.worldPos.z,o=Math.hypot(i,s);(null===e||o<e)&&(e=o)}if(null===e&&i.bounds){const n=i.topology.outbounds[0]?.direction,s=!(i.topology.outbounds&&i.topology.outbounds.length)?r?.sinkMargin??30:6;if(Sp(t,i.bounds,n,s)){const r=Mp(t.worldPos,t.direction,i.bounds);if(Number.isFinite(r))e=r+1e3;else{const r=(i.bounds.left??0)+(i.bounds.width??0)/2,n=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-r,t.worldPos.z-n)+1e3}}}null!==e&&n.push({id:i.id,dist:e})}return 0===n.length?null:(n.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),n[0].id)})}function Ap(t,e){const r=new Map;for(const e of t)r.set(e.id,e);const n=new Map,i=new Set;for(const r of t){const s=t.filter(t=>t.id!==r.id),o=kp(r.topology,s,e);n.set(r.id,o);for(const t of o)null!=t&&i.add(t)}const s=(t,e)=>{if(!r.has(t)||!r.has(e)||t===e)return;const s=n.get(t)??[];s.includes(e)||(s.push(e),n.set(t,s),i.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){(n.get(e.id)??[]).some(t=>null!=t)||o.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:r,out:n,sinks:o,sources:a}}function zp(t,e){const r=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const n=new Set([e]);for(const i of function(t,e,r){const n=r.get(e);if(n)return n;const i=new Set,s=[e],o=new Set([e]);for(;s.length;){const e=s.shift();for(const r of t.out.get(e)??[])null!=r&&(i.add(r),o.has(r)||(o.add(r),s.push(r)))}return r.set(e,i),i}(t,e,r))n.add(i);return n})}function Tp(t,e,r,n){return e===r?0:function(t,e,r){const n=r.get(e);if(n)return n;const i=new Map([[e,0]]),s=[e];for(;s.length;){const e=s.shift(),r=i.get(e);for(const n of t.out.get(e)??[])null==n||i.has(n)||(i.set(n,r+1),s.push(n))}return r.set(e,i),i}(t,e,n).get(r)??1/0}function Ip(t,e,r){const n=t.out.get(e)??[],i=new Map,s=[];for(let e=0;e<n.length;e++){const o=n[e];if(null==o)continue;const a=o===r?0:Tp(t,o,r,i);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 Op(t,e,r){const n=Ip(t,e,r);return n.length?n[0]:-1}function Ep(t,e,r){return e===r||Ip(t,e,r).length>0}function Pp(t,e){const r=new Set;for(const n of zp(t,e))for(const e of n)t.sinks.has(e)&&r.add(e);return r}function jp(t,e,r){return Cp(t,e,r).map(t=>t.index)}function Cp(t,e,r){const n=r instanceof Set?r:new Set(r);if(0===n.size)return[];const i=t.out.get(e)??[],s=new Map,o=[...n].sort(),a=[];for(let e=0;e<i.length;e++){const r=i[e];if(null==r)continue;let n=1/0,c="";for(const e of o){const i=1+(r===e?0:Tp(t,r,e,s));i<n&&(n=i,c=e)}n!==1/0&&a.push({index:e,hops:n,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Rp(t,e={}){const r=[],n=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const n=t.nodes.get(e);if(!n||!n.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||r.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)||(i.has(e)||t.sources.has(e)||r.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const s=function(t){const e=[],r=[...t.nodes.keys()].sort(),n=new Set,i=[],s=new Set,o=r=>{n.add(r),i.push(r),s.add(r);for(const a of t.out.get(r)??[])if(null!=a)if(s.has(a)){const t=i.indexOf(a),r=i.slice(t),n=r.indexOf([...r].sort()[0]),s=[...r.slice(n),...r.slice(0,n)],o=s.join("→");e.some(t=>t.join("→")===o)||e.push(s)}else n.has(a)||o(a);i.pop(),s.delete(r)};for(const t of r)n.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=>n.has(t))||r.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)&&r.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[...i].sort())t.nodes.has(e)&&(a.has(e)||r.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return r.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),r}function Fp(t,e){if(!t)return[];const r=[],n=new Set,i=t=>{if(!t||n.has(t))return;if(n.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,n=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=n?String(n):void 0;if(i)try{const e=t.getSegmentTopology(),n=t.state??{},s={left:n.left,top:n.top,width:n.width,height:n.height,rotation:n.rotation};e&&r.push({id:i,topology:e,bounds:s})}catch{}}const s=t?.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),r}function Dp(t,e){const r=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof r&&r.length>0)return r;if("function"!=typeof t.getSegmentTopology)return null;const n=t.getSegmentTopology();if(!n||0===n.outbounds.length)return null;const i=kp(n,Fp(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of i)if(t)return t;return null}function Np(t){return!!t&&"function"==typeof t.routingConstraints}function Lp(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Bp(t,e=16){const r=[],n=t.parent??t.rootModel??t.root;if(!n)return r;const i=Dp(t);if(!i)return r;const s=Wp(n,i);if(!s)return r;const o=[{segment:s,accumulated:{},pathIds:[i],visited:new Set([i])}];for(;o.length>0;){const t=o.shift();if(t.pathIds.length>e)continue;const i=Np(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const s=Up(t.accumulated,i);if(!s)continue;const a=Yp(t.segment,e.portId,n);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??""])}):r.push({data:s,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Lp(t.segment)){const e=t.segment.acceptedCarrierData(),n=t.segment.state?.id;if(0===e.length)r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:n});else for(const i of e){const e=Up(t.accumulated,i);e&&r.push({data:e,weight:1,pathIds:t.pathIds,destination:n})}continue}const e=Dp(t.segment);if(!e||t.visited.has(e)){r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=Wp(n,e);if(!i)continue;o.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return r}function Up(t,e){const r={...t};for(const[t,n]of Object.entries(e)){if(t in r&&r[t]!==n)return null;r[t]=n}return r}function Yp(t,e,r){if("straight"===e&&t.state?.downstreamRef)return Wp(r,t.state.downstreamRef);const n=Wp(r,e);if(n)return n;const i=Dp(t);return i?Wp(r,i):null}function Wp(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const r=new Set,n=t=>{if(!t||r.has(t))return null;if(r.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=n(t);if(e)return e}return null};return n(t)}function qp(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function $p(t,e,r=5,n=[],i=r){const s=t.length,o=new Array(s).fill(void 0),a=new Set,c=(e,r)=>"start"===r?t[e].start:t[e].end,h=[],l=new Map,u=[],d=new Map;for(const t of n){const e=Array.isArray(t),r=e?t:t.positions,n=e?void 0:t.kind;if(!r.length)continue;const i=h.length;h.push({pos:r[0],members:[]});for(const t of r)u.push({pos:t,pt:i});n&&d.set(i,n)}const p=(t,e)=>{const n=c(t,e),i=l.get(`${t}:${"end"===e?"start":"end"}`),s=[];for(const t of u)qp(t.pos,n)<=r&&!s.includes(t.pt)&&s.push(t.pt);for(let t=0;t<h.length;t++)qp(h[t].pos,n)<=r&&!s.includes(t)&&s.push(t);let o=s.find(t=>t!==i)??-1;o<0&&(o=h.length,h.push({pos:n,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,g=new Set;{const t=t=>{let e=-1,r=1/0;for(let n=0;n<h.length;n++){const i=qp(h[n].pos,t);i<r&&(r=i,e=n)}for(const n of u){const i=qp(n.pos,t);i<r&&(r=i,e=n.pt)}return{pt:e,d:r}};for(const r of e){const{pt:e,d:n}=t(r.pos);e>=0&&n<=i&&(f.add(e),("source"===r.kind?m:g).add(e))}}for(const[t,e]of d)f.add(t),("source"===e?m:g).add(t);const y=(t,e)=>"end"===e!==o[t],b=[],x=(e,r)=>{if(void 0===o[e])return o[e]=r,void b.push(e);o[e]!==r&&a.add(t[e].id)},v=t=>{for(const e of["start","end"]){const r=l.get(`${t}:${e}`);if(void 0===r)continue;const n=h[r];if(2!==n.members.length||f.has(r))continue;const i=n.members[0],s=i.seg===t&&i.end===e?n.members[1]:i;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,r="start",n=1/0;for(let i=0;i<s;i++)for(const s of["start","end"]){const o=qp(c(i,s),t.pos);o<n&&(n=o,e=i,r=s)}if(e<0||n>i)return;const o="source"===t.kind?"end"===r:"start"===r;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 r=0,n=0;for(const e of t.members)void 0!==o[e.seg]&&(y(e.seg,e.end)?r++:n++);const i=e[0];let s;0===n&&r>0?s="end"===i.end:0===r&&n>0&&(s="start"===i.end),void 0!==s&&(o[i.seg]=s,b.push(i.seg),w(),M=!0)}}if(o.some(t=>void 0===t)&&m.size>0&&g.size>0){const t=t=>{const e=new Array(h.length).fill(1/0),r=[];for(const n of t)e[n]=0,r.push(n);for(;r.length;){const t=r.shift();for(const n of h[t].members){const i=l.get(`${n.seg}:${"start"===n.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,r.push(i))}}return e},e=t(m),r=t(g);for(let t=0;t<s;t++){if(void 0!==o[t])continue;const n=l.get(`${t}:start`),i=l.get(`${t}:end`);if(void 0===n||void 0===i)continue;if(h[n].members.length<2||h[i].members.length<2)continue;if(e[n]===1/0||e[i]===1/0||r[n]===1/0||r[i]===1/0)continue;let s;e[n]!==e[i]?s=e[n]<e[i]:r[n]!==r[i]&&(s=r[i]<r[n]),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 Vp(...t){}function Hp(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function Gp(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*Xp(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*Xp(t)}function Zp(t,e,r){const n=e.width??0,i=e.height??0;if(n<=0||i<=0)return!1;const s=(e.left??0)+n/2,o=(e.top??0)+i/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)<=n/2+r&&Math.abs(p)<=i/2+r}function Jp(t){const e=[],r=[],n=[],i=[];for(const s of Xp(t)){const t=Gp(s);if(!t)continue;if(s.flowOrientable){const r=bp(s.state??{});r&&e.push({id:t,start:r.start,end:r.end});continue}if("function"==typeof s.openings){const t=s.state??{};(t.width??0)>0&&(t.height??0)>0&&i.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)r.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)r.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&&n.push({positions:t})}}for(const t of i){const i=[];for(const r of e)for(const e of[r.start,r.end])Zp(e,t,16)&&i.push(e);let s=!1,o=!1;for(const e of r)Zp(e.pos,t,16)&&("sink"===e.kind?s=!0:o=!0);const a=s&&!o?"sink":o&&!s?"source":void 0;(i.length>=2||a&&i.length>=1)&&n.push({positions:i,kind:a})}if(0===e.length||0===r.length)return e.length,r.length,new Map;const s=$p(e,r,8,n,60).directions;return e.length,r.length,n.length,[...s].map(([t,e])=>`#${t}:${e}`).join(" "),s}function Qp(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let r=e.__flowOrientation;if(!r){e.__flowComputing=!0;try{r={map:Jp(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=r}const n=Gp(t),i=n?r.map.get(n):void 0;return"reverse"===i||"forward"!==i&&void 0}function Kp(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function tf(t,e,r,n){if(!t||!e)return null;const i=[],s=t=>{if(!t||t===n)return;if(function(t,e){const r=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(r)&&r.includes(e)}(t,e)&&Kp(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}(t);e&&i.push({id:e,component:t,distance:t.distanceToBoardPoint(r.x,r.y)})}const o=t.components;if(Array.isArray(o))for(const t of o)s(t)};return s(t),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function ef(t){return!!t&&"function"==typeof t.routingDestination}function rf(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*nf(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*nf(t)}function sf(t){const e=[],r=new Map,n=new Map,i=new Set,s=[];for(const o of nf(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||ef(o)||c||Kp(o)))continue;const h=rf(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}),n.set(h,o),ef(o)){i.add(h);const t=o.routingDestination();if("string"==typeof t&&t.length>0){const e=r.get(t)??[];e.push(h),r.set(t,e)}}}return{nodes:e,destToSinks:r,components:n,routingTargetIds:i,stationClients:s}}function of(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:r,destToSinks:n,components:i,routingTargetIds:s,stationClients:o}=sf(t),a=Ap(r);!function(t,e){if(!t)return;const r=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)r(t)};r(t);const n=[...e].sort((t,e)=>{const r=rf(t)??"",n=rf(e)??"";return r.localeCompare(n)});for(const e of n){const r=e.declaredHostRef?.();let n=null;if(r&&(n=t.findById?.(r)??null),!n){const r=e.hostCapability?.(),i=e.hostFacingPoint?.();r&&i&&(n=tf(t,r,i,e)?.component??null)}n&&"function"==typeof e.registerWithHost&&e.registerWithHost(n)}const i=e=>{if(!e)return;if(Kp(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const r of e.resolveDownstream()){const n=t.findById?.(r);n&&e.registerDivertStation(r,n)}const r=e.components;if(Array.isArray(r))for(const t of r)i(t)};i(t)}(t,o);const c=new Set;for(const[t,e]of i){((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=i.get(t);if("function"==typeof e?.routingWeight){const r=e.routingWeight();"number"==typeof r&&(!Number.isFinite(r)||r<=0)&&h.set(t,r)}}const l=Rp(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:n,components:i,issues:l},t.__flowGraph=e}return e}function af(t){return of(t)?.issues??[]}function cf(t){const e=of(t);return e&&e.graph.nodes.size>0?e.graph:null}function hf(t,e){return of(t)?.destToSinks.get(e)??[]}function lf(t,e){return of(t)?.components.get(e)}function uf(t){const e=of(t);return e?[...e.destToSinks.keys()]:[]}function df(t){return rf(t)}function pf(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,r=t?.state?.capacity;return"number"==typeof r&&r>0?e/r:e}function ff(t,e,r,n,i){if(1===n.length)return n[0];switch(t){case"index":default:return n[0];case"round-robin":{const t=r.counters.get(e)??0;return r.counters.set(e,t+1),n[t%n.length]}case"weight":{const t=n.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}(i.get(t.target))),s=t.reduce((t,e)=>t+e,0);if(s<=0)return n[0];const o=r.counters.get(e)??0;r.counters.set(e,o+1);let a=o%s;for(let e=0;e<n.length;e++){if(a<t[e])return n[e];a-=t[e]}return n[n.length-1]}case"utilization":{let t=1/0,e=n[0];for(const r of n){const n=pf(i.get(r.target));n<t&&(t=n,e=r)}return e}}}function mf(t,e,r){const n=t?.root;if(!n)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const s=of(n);if(!s||0===s.graph.nodes.size)return null;const o=rf(t);if(!o)return null;let a=s.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=Cp(s.graph,o,a);if(0===c.length)return null;const h=s.graph.out.get(o)??[],l=c.filter(t=>{const r=h[t.index],n=r?s.components.get(r):null;return!n||"function"!=typeof n.canReceive||n.canReceive(e)});if(0===l.length)return h[c[0].index]??null;const u=r?.policy??function(t,e){const r=t?.state?.balancingPolicy;if(r)return r;const n=e?.state?.routingBalancingPolicy;return n||"round-robin"}(t,n),d=ff(u,o,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(n),l,s.components);return h[d.index]??null}r({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"}),r({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,cf(t)}catch{return null}}}catch{}function gf(t,e,r){const n=mf(t,e,r);if(null==n)return null;const i=t?.root,s=lf(i,n)??i?.findById?.(n)??null;return s?{targetId:n,component:s,origin:"explicit"}:null}function yf(t){const e=t?.root,r=cf(e),n=df(t);if(!r||!n)return null;const i=(r.out.get(n)??[]).find(Boolean);if(!i)return null;const s=lf(e,i)??e?.findById?.(i)??null;return s?{id:i,component:s}:null}function bf(t){const e=df(t);return e?xf(t?.root,e):[]}function xf(t,e){if(!t||!e)return[];const r=cf(t);if(!r)return[];const n=new Set;for(const i of Pp(r,e)){const e=lf(t,i);if(ef(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&n.add(t)}}return[...n]}function vf(t,e){if(!t||!e)return[];const r=cf(t);if(!r)return[];const n=new Map;for(const t of r.out.values())for(const e of t)null!=e&&n.set(e,(n.get(e)??0)+1);const i=new Map;for(const s of Pp(r,e)){const e=lf(t,s);if(!ef(e))continue;const r=e.routingDestination();if("string"!=typeof r||0===r.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=n.get(s)??0,0===o&&(o=1)),i.set(r,(i.get(r)??0)+o)}return[...i].map(([t,e])=>({value:t,weight:e}))}function wf(t){return cf(t)}function _f(t){const e=cf(t);if(!e)return[];const r=new Set,n=new Set,i=t=>{if(!t)return;const s=df(t);if(s&&e.nodes.has(s)){ef(t)&&r.add(s);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&n.add(s)}const o=t.components;if(Array.isArray(o))for(const t of o)i(t)};return i(t),Rp(e,{routingTargetIds:r,loopCapableIds:n})}function Mf(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 r=Math.random()*e;let n=0;for(const e of t)if(n+=e.weight,r<n)return e.value;return t[t.length-1].value}const Sf={next:gf,downstream:yf,reachableDestinations:bf,reachableDestinationsFrom:xf,reachableDestinationsWeightedFrom:vf,pickWeightedDestination:Mf,graphFor:wf,validate:_f};function kf(t){try{t()}catch(t){wa("[holdable] a listener of a handover failed; the handover stands",t)}}function Af(t){let e=0;for(let r=t;r&&!r.isRootModel?.();r=r.parent)e+=r.state?.rotation||0;return e}function zf(t,e){if("function"!=typeof t?.toScene)return null;try{const r=t.bounds,n=t.center,i=t.toScene(n.x,n.y),s={x:i.x,y:i.y,rotation:Af(e),width:r.width,height:r.height};return Object.values(s).every(Number.isFinite)?s:null}catch{return null}}function Tf(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,r){const n=t.prototype?.attachPointFor;return"function"==typeof n?n.call(this,e,r):null}addItem(t,e){if(!t||this.containsItem(t))return;const r=t.parent;if(r&&"function"==typeof r.removeItem&&r!==this&&r.removeItem(t,!0),this._items.push(t),t.parent=this,ku(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 r=this._items.indexOf(t);if(-1!==r)if(this._items.splice(r,1),t.parent=null,this._reseatSlot(t[fr]),e)t._realObject?.setTransientDisplayScale?.(1);else{if(Au(t),function(t){const e=t?._realObject?.object3d;if(!e?.parent)return;let r=e.parent;for(;r.parent;)r=r.parent;r!==e.parent&&(r.updateWorldMatrix?.(!0,!1),e.updateWorldMatrix?.(!0,!1),r.attach(e))}(t),t._realObject?.setTransientDisplayScale?.(1,{x:1,y:1,z:1}),"function"==typeof this.trigger)try{this.trigger("release",this,t,r)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const r=e?.slotId,n=e?.toParent3D,i=n?null:this.attachPointFor?.(t,{slotId:r}),s=e?.animated?function(t){const e=t?._realObject?.object3d;let r=null;if(e?.parent){e.updateWorldMatrix(!0,!1);const t=e.position.clone(),n=e.quaternion.clone(),i=e.scale.clone();e.matrixWorld.decompose(t,n,i),r={position:t,quaternion:n,scale:i}}return{world3D:r,world2D:t?.parent?zf(t,t.parent):null}}(t):null,o=t.parent,a=o===this?t[fr]: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!==r&&(t[fr]=r),ku(this,t);const h=!!t._realObject?.object3d;h&&this.seatHeldItem(t,{toParent3D:n,slotId:r,point:i}),void 0!==a&&a!==t[fr]&&this._reseatSlot(a),c&&kf(()=>this.trigger?.("hold",this,t,this._items.length-1)),h||this.seatHeldItem(t,{toParent3D:n,slotId:r,point:i}),s&&function(t,e,r,n){const i=t.root?.transitionEffect;if(!i)return;const s=n.duration??2e3,o=n.ease??"inout",a=e._realObject?.object3d;if(r.world3D&&a?.parent){const t={pos:a.position.clone(),quat:a.quaternion.clone()},n={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(r.world3D.position,r.world3D.quaternion,r.world3D.scale).premultiply(h),u=a.position.clone(),d=a.quaternion.clone();return l.decompose(u,d,a.scale.clone()),void i.begin(e,{from3D:{pos:u,quat:d,fromScale:n,toScale:n},to3D:t,duration:s,ease:o,keepSuppressed:!0,placementAfter:e._realObject.placement})}const c=r.world2D?zf(e,t):null;r.world2D&&c&&i.begin(e,{fromWorld:r.world2D,toWorld:c,duration:s,ease:o})}(this,t,s,e),kf(()=>t.held?.(this)),kf(()=>this._bumpReceived?.(t))}seatHeldItem(t,e={}){t.realObject;const r=t._realObject,n=r?.object3d;if(n){let i,s,o=e.toParent3D,a="world-preserve",c=1,h=null;if(!o){const r=void 0!==e.point?e.point:this.attachPointFor?.(t,{slotId:e.slotId});r?.attach&&(o=r.attach,i=r.localPosition,s=r.localRotation,a=r.carryPolicy??"world-preserve",c=r.displayScale??1,h=r.seat?.dims??null)}o&&n.parent!==o&&(o.updateWorldMatrix?.(!0,!1),n.updateWorldMatrix?.(!0,!1),o.attach(n),r.suppressTransform=!0),o&&(i&&n.position.set(i.x,i.y,i.z),"world-preserve"!==a?s?n.rotation.set(s.x,s.y,s.z):n.quaternion.identity():s&&n.rotation.set(s.x,s.y,s.z),r?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),r?.setTransientDisplayScale?.(c,function(t){if(!t?.matrixWorld)return;let e=t;for(;e.parent;)e=e.parent;t.updateWorldMatrix?.(!0,!1);const r=t.matrixWorld.elements,n=t=>Math.hypot(r[t],r[t+1],r[t+2]),i=e.scale??{x:1,y:1,z:1};return{x:n(0)/(i.x||1),y:n(4)/(i.y||1),z:n(8)/(i.z||1)}}(o)),t.takeSeatDims?.(h))}}_reseatSlot(t){if(null!=t)for(const e of this._items.slice())e?.[fr]===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){Au(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,r,n,i){for(let s=this._items.length-1;s>=0;s--){const o=this._items[s],a="static"===o.position?o.capture?.(t,e,i):o.capture?.(r,n,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const r=this._items;if(!r||0===r.length)return;t.save();const n=e.bounds;!e.showOverflow&&n&&(t.beginPath(),t.rect(n.left,n.top,n.width,n.height),t.clip(),t.closePath());const{left:i=0,top:s=0}=e.state??{};t.translate(i,s),this._drawItems(t),t.translate(-i,-s),t.restore()}capture(t,e,r){const n=this,i=this._items;if(i&&i.length>0&&(!n.app||n.app.isEditMode||!n.hidden)){const i=n.fromParent?.(t,e);if(i&&n.contains?.(i.x,i.y)){const s=n.bounds,o=this._captureItems(i.x-s.left,i.y-s.top,t,e,r);if(o)return o}}return super.capture?.(t,e,r)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function If(t,e,r){return void 0!==r?t._slotIfAvailable(t.slotById(r),e):t.findSlot(e)}function Of(t){var e;return(e=class extends t{reserve(t,e){const r=If(this,t,e?.slotId);return r?{slot:r,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){Mr.log({role:"target",contract:"receive:enter",component:this,args:{carrier:ur(t),options:e}});const r=this.reserve(t,e);if(!r){Mr.log({role:"target",contract:"receive:reject",component:this,args:{carrier:ur(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(r,t,e)}commit(t,e,r={}){const n=t.slot,i=this._countOccupied(n.id),s=this.arrangementStrategy.positionAt(i,n,i,e);Mr.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:i,slotId:n.id,occupantCount:i,carrier:ur(e)},result:s});const o=function(t,e,r,n,i){const s={},o=t.placementFor?.(e,{slot:r,index:n,occupantCount:n})??null;if(Mr.log({role:"target",contract:"placementFor",component:t,args:{carrier:ur(e),slotId:r.id,index:n},result:o}),o){const n=e.state??{},i=t.state??{};s.left=o.position.x-(Number(n.width)||0)/2+(Number(i.width)||0)/2,s.top=o.position.z-(Number(n.height)||0)/2+(Number(i.height)||0)/2;const a=t._zPosFromSeatY(o.position.y,n.depth,r);null!==a&&(s.zPos=a),o.rotation&&pr(s,o.rotation)}else{if(i&&(s.left=i.x,s.top=i.y),0!==(t._realObject?.receivingSurfaceY??0))s.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const e=t._realObject?.geometricOffsetY??0;s.zPos=r.localPosition.z+e}const n=t.acceptanceRotation?.(e,r);Mr.log({role:"target",contract:"acceptanceRotation",component:t,args:{carrier:ur(e),slotId:r.id},result:n}),n&&pr(s,n)}const a=t.normalizePose?.(e,r);return"function"==typeof t.normalizePose&&Mr.log({role:"target",contract:"normalizePose",component:t,args:{carrier:ur(e),slotId:r.id},result:a}),a&&Object.assign(s,a),s}(this,e,n,i,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}=r;if("function"==typeof this.handoverIn?this.handoverIn(e,{slotId:n.id}):(e[fr]=n.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){wa("[transferable] the received item's state could not be set; the handover stands",t)}Mr.log({role:"target",contract:"receive:setState",component:this,args:{carrier:ur(e),keys:Object.keys(o)}})}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:n.id,preReceiveWorldPos:c,preReceiveWorldQuat:h}),Mr.log({role:"target",contract:"receive:done",component:this,args:{carrier:ur(e),slotId:n.id}})}async dispatch(t,e,r={}){const n=new zr({source:this,target:e,carrier:t,options:r}),i=await n.execute();"rolled-back"!==i.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:i.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 r=(()=>{const r=this.slots;if(!r.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 r=If(this,t,e.slotId);return r?{ok:!0,slot:r}:{ok:!1,reason:"slot-unavailable"}}const n=this.findSlot(t);if(!n){const e=t?.state?.type??t?.type;for(const t of r)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:n}})();return Mr.log({role:"target",contract:"canAccept",component:this,args:{carrier:ur(t)},result:r.ok?{ok:!0,slotId:r.slot.id}:{ok:!1,reason:r.reason}}),r}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}function Ef(t){var e;const r=!!t.__hasCapacity,n=!!t.__hasTransferable,i=r?t:mp(t),s=n?i:Of(i),o=[...t.capabilities??[]];r||o.push("Capacity","PlacementSurface"),n||o.push("Transferable"),o.push("Holdable","FlowNode");var a,c,h;return Tu((e=class extends(Tf(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 r=this.state?.rejected??0;this.setState?.({rejected:r+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 Pf(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,r({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"}),r({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"}),r({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{Br as BULGE_EPSILON,mp as Capacity,en as CapacityEventTracker,nn as CenteringQueueStrategy,m as CenteringSlotStrategy,Vd as DEFAULT_SEAT_MARGIN,p as FixedSlotStrategy,Sf as FlowEngine,Ef as FlowNode,an as GridStacking,Td as HOLDER_ANCHOR,Tf as Holdable,xd as ITEM_TYPES_THEME,vd as ITEM_TYPE_CODE_MAX,yd as Item,bd as ItemRealObject,Tu as ItemsDataBinding,Cr as NavGraph,on as PatternStacking,Zr as PolygonPathPolyline,Pr as ReservationTable,fr as TRANSFER_SLOT_KEY,zr as Transfer,cn as VolumeStacking,Yd as addressOfSlotId,uf as allDestinations,wp as anchorsConnect,ff as applyPolicy,pr as applySeatingRotation,hn as applyStackLayout,xp as arcSegmentTopology,rn as autoWireBackPressure,Ap as buildFlowGraph,Dr as buildNavGraph,qr as bulgeFromDrag,Wr as bulgeHandlePosition,Ep as canReach,t as capability,d as chooseNearestPickupFrame,Fp as collectAdjacentSegments,lf as componentForNode,Yr as computeArcParams,Jp as computeFlowMap,sn as computeStackPositions,Vr as cornerHandlePosition,Hr as cornerRadiusFromDrag,Sp as deliversInto,yf as downstream,$r as effectiveCornerRadius,Bp as enumerateDataScenarios,u as filterByToolType,tf as findNearestWithCapability,f as fixedSlotStrategy,Jr as flattenPolygonPath,cf as flowGraphFor,af as flowGraphIssues,Qp as flowReverseFor,ln as footprint2D,br as frameClock,Hp as ftId,Vp as ftrace,i as getAllCapabilityMeta,n as getCapabilityMeta,mr as globalSimClock,wf as graphFor,Nd as gridCellOf,Dd as gridSlotNo,Ur as hasArc,Kr as hasCapacity,tn as inferCapacity,Dp as inferDownstreamId,$p as inferFlowDirections,Pf as isFlowNode,Kp as isGeometricHost,Sd as isItemTypeTable,ef as isRoutingTarget,Su as itemById,Mu as itemIdOf,fd as itemLookDimsOf,up as itemSeatsOf,kd as itemTypeTableOf,Md as itemTypesFromThemes,rp as judgeItemFit,zd as layoutIssue,kp as matchOutbounds,gf as next,Op as nextHop,Ip as nextHops,jp as nextHopsToAny,Cp as nextHopsToAnyDetailed,df as nodeIdOf,op as occupancySnapshotOf,Cd as persistenceIssues,Mf as pickWeightedDestination,Nr as planPathAStar,Lr as planToReservations,_p as pointInRotatedRect,Qr as polygonPathLength,o as quatFromYaw,Mp as rayAbsDistanceToRect,zp as reachableByOutbound,bf as reachableDestinations,xf as reachableDestinationsFrom,vf as reachableDestinationsWeightedFrom,Pp as reachableSinks,_d as readItemTypes,kr as receiptToJSON,gp as rectFaceAnchors,h as rectangularFootprintFrames,r as registerCapabilityMeta,jr as reservationTable,Pa as resolveLegend,Ca as resolveLegendEntries,mf as resolveNextHop,Bd as resolveSlot,Gd as rotatedFootprint,Xd as seatInSlot,Zd as seatTransform,pd as setItemLookProvider,hf as sinksForDestination,Wd as slotAddresses,Rd as slotCount,$d as slotFrame,Ud as slotIdOf,Fd as slotNumbers,ep as slotSpaceWarnings,Jd as stackSeatTransforms,Er as standardYieldPolicy,bp as straightSegmentEndpoints,vp as straightSegmentMultiInbound,yp as straightSegmentTopology,l as topApproachFrame,Tr as transferLog,Mr as transferTracer,Gr as uniformZ,_f as validate,Rp as validateFlowGraph,jd as validateSlotLayout};
|