@ntf/math 1.4.2 → 1.4.3
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -139,7 +139,7 @@ interface IToBoundingBox {
|
|
|
139
139
|
}
|
|
140
140
|
type BoundingBoxArray = [number, number, number, number];
|
|
141
141
|
type BoundingBoxString = `${number},${number},${number},${number}`;
|
|
142
|
-
type BoundingBoxLike = IBoundingBox | BoundingBoxArray | BoundingBoxString | IToBoundingBox;
|
|
142
|
+
type BoundingBoxLike = IBoundingBox | BoundingBoxArray | BoundingBoxString | IToBoundingBox | number;
|
|
143
143
|
type BoundingBoxArgs = [bbox: BoundingBoxLike] | BoundingBoxArray;
|
|
144
144
|
declare class BoundingBox implements IBoundingBox, IRectangle, IToRectangle, IToString {
|
|
145
145
|
left: number;
|
|
@@ -364,7 +364,7 @@ interface IToQuaternion {
|
|
|
364
364
|
}
|
|
365
365
|
type QuaternionArray = [number, number, number, number];
|
|
366
366
|
type QuaternionString = `${number} + ${number}i + ${number}j + ${number}k`;
|
|
367
|
-
type QuaternionLike = IQuaternion | QuaternionArray | QuaternionString | IToQuaternion;
|
|
367
|
+
type QuaternionLike = IQuaternion | QuaternionArray | QuaternionString | IToQuaternion | number;
|
|
368
368
|
type QuaternionArguments = QuaternionArray | [quaternion: QuaternionLike];
|
|
369
369
|
declare class Quaternion implements IToVec3, IToMat3, IToMat4, IToString {
|
|
370
370
|
w: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ interface IToBoundingBox {
|
|
|
139
139
|
}
|
|
140
140
|
type BoundingBoxArray = [number, number, number, number];
|
|
141
141
|
type BoundingBoxString = `${number},${number},${number},${number}`;
|
|
142
|
-
type BoundingBoxLike = IBoundingBox | BoundingBoxArray | BoundingBoxString | IToBoundingBox;
|
|
142
|
+
type BoundingBoxLike = IBoundingBox | BoundingBoxArray | BoundingBoxString | IToBoundingBox | number;
|
|
143
143
|
type BoundingBoxArgs = [bbox: BoundingBoxLike] | BoundingBoxArray;
|
|
144
144
|
declare class BoundingBox implements IBoundingBox, IRectangle, IToRectangle, IToString {
|
|
145
145
|
left: number;
|
|
@@ -364,7 +364,7 @@ interface IToQuaternion {
|
|
|
364
364
|
}
|
|
365
365
|
type QuaternionArray = [number, number, number, number];
|
|
366
366
|
type QuaternionString = `${number} + ${number}i + ${number}j + ${number}k`;
|
|
367
|
-
type QuaternionLike = IQuaternion | QuaternionArray | QuaternionString | IToQuaternion;
|
|
367
|
+
type QuaternionLike = IQuaternion | QuaternionArray | QuaternionString | IToQuaternion | number;
|
|
368
368
|
type QuaternionArguments = QuaternionArray | [quaternion: QuaternionLike];
|
|
369
369
|
declare class Quaternion implements IToVec3, IToMat3, IToMat4, IToString {
|
|
370
370
|
w: number;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=require(`@ntf/types`);var t=class{};function n(e){if(e!=0){if(e<0)return`-`;if(e>0)return`+`}}var r=class extends Error{constructor(e,t){super(`Can't resolve ${t} to ${e}`),this.target=e,this.value=t}};function i(e,t,n){return e<=t?t:e>=n?n:e}function a(e,t){let n=Math.abs(e),r=Math.abs(t);if(e==0)return Math.log(r);if(t==0)return Math.log(n);if(n<3e3&&r<3e3)return .5*Math.log(e*e+t*t);let i=e/2,a=t/2;return .5*Math.log(i*i+a*a)+Math.LN2}const o=1e-16,s=(e,t,n)=>((typeof e==`number`?1:1n)-n)*e+n*t;var c=class t{x;y;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Vec2`,e)}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,2)||(0,e.isFixedTypeArray)(t,e.isValidNumber,3))return new this(t[0],t[1],t[2]);if((0,e.hasTypedProperty)(t,`toVec2`,`function`))return this.cast(t.toVec2());if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`))return new this(t.x,t.y,(0,e.hasTypedProperty)(t,`w`,`number`)?t.w:void 0);if((0,e.isValidString)(t)){let[n,r]=t.split(`;`);if((0,e.isValidString)(n)){let t=n.split(`,`);if((0,e.isFixedTypeArray)(t,e.isValidString,2))return new this(parseFloat(t[0]),parseFloat(t[1]),(0,e.isValidString)(r)?parseFloat(r):void 0)}}if((0,e.isValidNumber)(t))return new this(t,t)}}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,2)?new this(t[0],t[1]):this.resolve(t[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y)}static clamp(e,t,n){let r=this.resolve(e),a=this.resolve(t),o=this.resolve(n);return new this(i(r.x,a.x,o.x),i(r.y,a.y,o.y))}static get zero(){return new this(0,0)}static get one(){return new this(1,1)}constructor(t,n,r=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),this.x=t,this.y=n,this.w=r}toArray(e=this.w!==1){return e?[this.x,this.y,this.w]:[this.x,this.y]}toJSON(){return{x:this.x,y:this.y,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y};${this.w}`:`${this.x},${this.y}`}get[Symbol.toStringTag](){return`Vec2`}[e.NodeJSCustomInspect](){return`Vec2 <${this.toString()}>`}toSize(){return[this.x,this.y]}toVec3(e=0){return[this.x,this.y,e,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.w]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.w,1]}toHSL(){let e=this.normalize();return[e.x,e.y,e.w]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.w,1]}clone(){return new t(this.x,this.y,this.w)}equals(...e){let n=t.resolveArgs(e);return this.x==n.x&&this.y==n.y}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setW(e){return this.w=e,this}set(...e){let n=t.resolveArgs(e);return this.setX(n.x).setY(n.y)}add(...e){let n=t.resolveArgs(e);return new t(this.x+n.x,this.y+n.y)}offset(...e){let n=t.resolveArgs(e);return this.x+=n.x,this.y+=n.y,this}subtract(...e){let n=t.resolveArgs(e);return new t(this.x-n.x,this.y-n.y)}multiply(e){return new t(this.x*e,this.y*e)}naiveMultiply(...e){let n=t.resolveArgs(e);return new t(this.x*n.x,this.y*n.y)}divide(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1))return new t(this.x/n[0],this.y/n[0]);let r=t.resolveArgs(n);return new t(this.x/r.x,this.y/r.y)}dot(...e){let n=t.resolveArgs(e);return this.x*n.x+this.y*n.y}distance(...e){let n=t.resolveArgs(e);return(n.x-this.x)**2+(n.y-this.y)**2}distanceSquare(...e){let n=t.resolveArgs(e);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}cartesianify(){return new t(this.x*Math.cos(this.y),this.x*Math.sin(this.y))}polarify(){return new t(Math.sqrt(this.x*this.x+this.y*this.y),Math.atan(this.y/this.x))}normalize(){let e=this.length();return e==0?t.zero:new t(this.x/e,this.y/e,this.w/e)}invert(){return this.multiply(-1)}round(){return new t(Math.round(this.x),Math.round(this.y),Math.round(this.w))}},l=class extends t{m;b;static fromPoints(e,t){let n=c.resolve(e),r=c.resolve(t),i=(r.y-n.y)/(r.x-n.x),a=-i*n.x+n.y;return new this(i,a)}constructor(t,n){super(),(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),this.m=t,this.b=n}get(t){return(0,e.checkValidNumber)(t),this.m*t+this.b}roots(){let e=-this.b/this.m;return isNaN(e)?[]:[new c(e,0)]}toString(){let e=n(this.b);return e?`f(x) = ${this.m} * x ${e} ${Math.abs(this.b)}`:`f(x) = ${this.m} * x`}get[Symbol.toStringTag](){return`LinearFunction`}[e.NodeJSCustomInspect](){return`LinearFunction <${this.toString()}>`}},u=class extends t{a;b;c;static get(e,t,n,r){return new this(e,t,n).get(r)}constructor(t,n,r){if(super(),(0,e.checkValidNumber)(t),t===0)throw new e.ExpectedTypeError(`non-zero valid number`,t);(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),this.a=t,this.b=n,this.c=r}get(t){return(0,e.checkValidNumber)(t),this.a*t*t+this.b*t+this.c}roots(){let e=[],t=this.b*this.b-4*this.a*this.c,n=(-this.b+Math.sqrt(t))/(2*this.a),r=(-this.b+Math.sqrt(t))/(2*this.a);return isNaN(n)||e.push(new c(n,0)),!isNaN(r)&&n!=r&&e.push(new c(r,0)),e}toString(e=`standard`){switch(e){default:case`standard`:{let e=n(this.b),t=n(this.c);return e&&t?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x ${t} ${Math.abs(this.c)}`:e?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x`:`f(x) = ${this.a}x^2`}}}get[Symbol.toStringTag](){return`QuadFunction`}[e.NodeJSCustomInspect](){return`QuadFunction <${this.toString()}>`}},d=class t{x;y;z;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Vec3`,e)}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`z`,`number`))return new this(t.x,t.y,t.z,(0,e.hasTypedProperty)(t,`w`,`number`)?t.w:void 0);if((0,e.isValidString)(t)){let[n,r]=t.split(`;`);if((0,e.isValidString)(n)){let t=n.split(`,`);if((0,e.isFixedTypeArray)(t,e.isValidString,3))return new this(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]),(0,e.isValidString)(r)?parseFloat(r):void 0)}}if((0,e.isValidNumber)(t))return new this(t,t,t)}}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)?new this(t[0],t[1],t[2]):this.resolve(t[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y,r.z-n.z)}static clamp(e,t,n){let r=this.resolve(e),a=this.resolve(t),o=this.resolve(n);return new this(i(r.x,a.x,o.x),i(r.y,a.y,o.y),i(r.z,a.z,o.z))}static intersectPlane(e,n,r,i,a){n=this.resolve(n).normalize();let o=-this.resolve(n).dot(e),s=this.resolve(r).dot(n),c=this.resolve(i).dot(n);a=(-o-s)/(c-s);let l=this.resolve(i).subtract(r).multiply(a);return t.resolve(r).add(l)}static get zero(){return new this(0,0,0)}static get one(){return new this(1,1,1)}constructor(t,n,r,i=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(i),this.x=t,this.y=n,this.z=r,this.w=i}toArray(e=this.w!==1){return e?[this.x,this.y,this.z,this.w]:[this.x,this.y,this.z]}toJSON(){return{x:this.x,y:this.y,z:this.z,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y},${this.z};${this.w}`:`${this.x},${this.y},${this.z}`}get[Symbol.toStringTag](){return`Vec3`}[e.NodeJSCustomInspect](){return`Vec3 <${this.toString()}>`}toVec2(){return[this.x,this.y,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.z]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toHSL(){let e=this.normalize();return[e.x,e.y,e.z]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toQuaternion(){return[this.w,this.x,this.y,this.z]}clone(){return new t(this.x,this.y,this.z,this.w)}equals(...e){let n=t.resolveArgs(e);return this.x==n.x&&this.y==n.y&&this.z==n.z}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}set(...e){let n=t.resolveArgs(e);return this.setX(n.x).setY(n.y).setZ(n.z)}add(...e){let n=t.resolveArgs(e);return new t(this.x+n.x,this.y+n.y,this.z+n.z)}offset(...e){let n=t.resolveArgs(e);return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...e){let n=t.resolveArgs(e);return new t(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(e){return new t(this.x*e,this.y*e,this.z*e)}naiveMultiply(...e){let n=t.resolveArgs(e);return new t(this.x*n.x,this.y*n.y,this.z*n.z)}divide(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1))return new t(this.x/n[0],this.y/n[0],this.z/n[0]);let r=t.resolveArgs(n);return new t(this.x/r.x,this.y/r.y,this.z/r.z)}dot(...e){let n=t.resolveArgs(e);return this.x*n.x+this.y*n.y+this.z*n.z}cross(...e){let n=t.resolveArgs(e);return new t(this.y*n.z-this.z*n.y,this.z*n.x-this.x*n.z,this.x*n.y-this.y*n.x)}distance(...e){let n=t.resolveArgs(e);return(n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2}distanceSquare(...e){let n=t.resolveArgs(e);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let e=this.length();return e==0?t.zero:new t(this.x/e,this.y/e,this.z/e,this.w/e)}invert(){return this.multiply(-1)}round(){return new t(Math.round(this.x),Math.round(this.y),Math.round(this.z),Math.round(this.w))}},f=class t{w;x;y;z;static is(e){return this.cast(e)!==void 0}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Quaternion`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toQuaternion`,`function`))return this.cast(t.toQuaternion());if((0,e.hasTypedProperty)(t,`w`,`number`)&&(0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`z`,`number`))return new this(t.w,t.x,t.y,t.z);if((0,e.isValidString)(t)){let n=t.replaceAll(` `,``).split(`+`);if((0,e.isFixedTypeArray)(n,e.isValidString,4)){let[e,t,r,i]=n;if(e&&t?.endsWith(`i`)&&r?.endsWith(`j`)&&i?.endsWith(`k`))return this.cast([parseFloat(e),parseFloat(t.substring(0,t.length-1)),parseFloat(r.substring(0,r.length-1)),parseFloat(i.substring(0,i.length-1))])}}}}static fromAxisAngle(...t){let n=(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new d(t[0],t[1],t[2]):d.resolve(t[0]),r=(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?t[3]:t[1],i=d.resolve(n),a=r*.5,o=Math.sin(a),s=Math.cos(a),c=o/Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z);return new this(s,i.x*c,i.y*c,i.z*c)}static fromEuler(...e){let n=d.resolveArgs(e),r=n.x*.5,i=n.y*.5,a=n.z*.5,o=Math.cos(r),s=Math.cos(i),c=Math.cos(a),l=Math.sin(r),u=Math.sin(i),f=Math.sin(a);return new t(o*s*c-l*u*f,l*s*c-u*f*o,u*o*c-l*f*s,l*u*c+f*o*s)}static get zero(){return new t(0,0,0,0)}constructor(t,n,r,i){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(i),this.w=t,this.x=n,this.y=r,this.z=i}toArray(){return[this.w,this.x,this.y,this.z]}toString(){return`${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`}get[Symbol.toStringTag](){return`Quaternion`}[e.NodeJSCustomInspect](){return`Quaternion <${this.toString()}>`}toJSON(){return{w:this.w,x:this.x,y:this.y,z:this.z}}clone(){return new t(this.w,this.x,this.y,this.z)}add(...e){let n=t.resolveArgs(e);return new t(this.w+n.w,this.x+n.x,this.y+n.y,this.z+n.z)}offset(...e){let n=t.resolveArgs(e);return this.w+=n.w,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...e){let n=t.resolveArgs(e);return new t(this.w-n.w,this.x-n.x,this.y-n.y,this.z-n.z)}negative(){return new t(-this.w,-this.x,-this.y,-this.z)}length(e=!0){let t=this.w*this.w+this.x*this.x+this.y*this.y+this.z*this.z;return e?Math.sqrt(t):t}normalize(){let e=this.length();return e<o?t.zero:(e=1/e,new t(this.w*e,this.x*e,this.y*e,this.z*e))}multiply(...e){let n=t.resolveArgs(e);return new t(this.w*n.w-this.x*n.x-this.y*n.y-this.z*n.z,this.w*n.x+this.x*n.w+this.y*n.z-this.z*n.y,this.w*n.y+this.y*n.w+this.z*n.x-this.x*n.z,this.w*n.z+this.z*n.w+this.x*n.y-this.y*n.x)}multiplyVector(...e){let t=d.resolveArgs(e),n=this.w*t.x+this.y*t.y-this.z*t.y,r=this.w*t.y+this.z*t.x-this.x*t.z,i=this.w*t.z+this.x*t.y-this.y*t.x,a=-this.w*t.x-this.y*t.y-this.z*t.z;return new d(n*this.w+a*-this.x+r*-this.z-i*-this.y,r*this.w+a*-this.y+i*-this.x-n*-this.z,i*this.w+a*-this.z+n*-this.y-r*-this.x)}scale(e){return new t(this.w*e,this.x*e,this.y*e,this.z*e)}dot(...e){let n=t.resolveArgs(e);return this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z}inverse(){let e=this.length(!1);return e==0?t.zero:(e=1/e,new t(this.w*e,-this.x*e,-this.y*e,-this.z*e))}divide(...e){let n=t.resolveArgs(e),r=n.length(!1);return r==0?t.zero:(r=1/r,new t((this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z)*r,(this.x*n.w-this.w*n.x-this.y*n.z+this.z*n.y)*r,(this.y*n.w-this.w*n.y-this.z*n.x+this.x*n.z)*r,(this.z*n.w-this.w*n.z-this.x*n.y+this.y*n.x)*r))}conjugate(){return new t(this.w,-this.x,-this.y,-this.z)}exp(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),n=Math.exp(this.w),r=n*Math.sin(e)/e;return e==0?new t(n,0,0,0):new t(n*Math.cos(e),this.x*r,this.y*r,this.z*r)}log(){if(this.x==0&&this.z==0)return new t(a(this.w,this.x),Math.atan2(this.x,this.w),0,0);let e=this.length(!1),n=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),r=Math.atan2(n,this.w)/e;return new t(Math.log(e)*.5,this.x*r,this.y*r,this.z*r)}toVec3(){return[this.x,this.y,this.z,this.w]}toAxisAngle(){let e=1-this.w*this.w;if(e>o)return new d(this.x,this.y,this.z,0);let t=1/Math.sqrt(e),n=2*Math.acos(this.w);return new d(this.x*t,this.y*t,this.z*t,n)}toEuler(){function e(e){return e>=1?Math.PI/2:e<=-1?-Math.PI/2:Math.asin(e)}return new d(-Math.atan2(2*(this.y*this.z-this.w*this.x),1-2*(this.x*this.x+this.y*this.y)),e(2*(this.x*this.z+this.w*this.y)),-Math.atan2(2*(this.x*this.y-this.w*this.z),1-2*(this.y*this.y+this.z*this.z)))}toMat3(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y)]}toMat4(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),0,2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),0,2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y),0,0,0,0,1]}};function p(e){let t=e<4096,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8;return[(t?(e&3840)>>>8:(e&16711680)>>>16)/255,r/255,n/255]}function m(e){let t=e<65536,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8,i=t?(e&3840)>>>8:(e&16711680)>>>16;return[(t?(e&61440)>>>12:(e&4278190080)>>>24)/255,i/255,r/255,n/255]}function h(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)||e.startsWith(`0x`)}function g(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)?e.substring(1):e.startsWith(`0x`)?e.substring(2):e}function _(e){let t=g(e);return[4,8].includes(t.length)}function v(e){let t=g(e),n=t.length===3,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16);return[r/255,i/255,a/255]}function y(e){let t=g(e),n=t.length===4,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16),o=parseInt(n?t[3]:t.substring(6,8),16);return[r/255,i/255,a/255,o/255]}var b=class t{_red;get red(){return this._red}set red(e){this._red=i(e,0,1)}_green;get green(){return this._green}set green(e){this._green=i(e,0,1)}_blue;get blue(){return this._blue}set blue(e){this._blue=i(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=i(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`RGBAColor`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toRGB`,`function`))return this.cast(t.toRGB());if((0,e.hasTypedProperty)(t,`toRGBA`,`function`))return this.cast(t.toRGBA());if((0,e.hasTypedProperty)(t,`red`,`number`)&&(0,e.hasTypedProperty)(t,`green`,`number`)&&(0,e.hasTypedProperty)(t,`blue`,`number`))return new this(t.red,t.green,t.blue,(0,e.hasTypedProperty)(t,`alpha`,`number`)?t.alpha:void 0);if((0,e.isValidNumber)(t)){let e=t.toString(16).length<=6?p:m;return this.cast(e(t))}if((0,e.isValidString)(t)){if(t.startsWith(`rgb`)){let n=t.startsWith(`rgba`),r=n?5:4,i=t.substring(r,t.indexOf(`)`,r)).split(`,`);if((0,e.isFixedTypeArray)(i,e.isValidString,n?4:3))return this.cast(i.map(e=>parseInt(e)/255))}if(h(t)){let e=_(t)?y:v;return this.cast(e(t))}}}}static is(e){return this.cast(e)!==void 0}constructor(t,n,r,a=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(a),this._red=i(t,0,1),this._green=i(n,0,1),this._blue=i(r,0,1),this._alpha=i(a,0,1)}toArray(e=this._alpha!==1){return e?[this.red,this.green,this.blue,this.alpha]:[this.red,this.green,this.blue]}toJSON(e=this._alpha!==1){return e?{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}:{red:this.red,green:this.green,blue:this.blue}}toString(e=this._alpha!==1){return e?`rgba(${i(this.red*255|0,0,255)},${i(this.green*255|0,0,255)},${i(this.blue*255|0,0,255)},${this.alpha})`:`rgb(${i(this.red*255|0,0,255)},${i(this.green*255|0,0,255)},${i(this.blue*255|0,0,255)})`}get[Symbol.toStringTag](){return`RGBA`}[e.NodeJSCustomInspect](){return`RGBA <${this.toString()}>`}toVec2(){return[this.red,this.green,this.blue]}toVec3(){return[this.red,this.green,this.blue,this.alpha]}toHSL(e=this._alpha!==1){let t=this.red,n=this.green,r=this.blue,i=Math.min(t,n,r),a=Math.max(t,n,r),o=(i+a)/2;if(i==a)return new x(0,0,o,e?this.alpha:void 0);let s=a-i,c=o>.5?s/(2-a-i):s/(a+i);return a==t?new x(((n-r)/s+(n<r?6:0))/6,c,o,e?this.alpha:void 0):a==n?new x(((r-t)/s+2)/6,c,o,e?this.alpha:void 0):a==r?new x(((t-n)/s+4)/6,c,o,e?this.alpha:void 0):new x(0,c,o,e?this.alpha:void 0)}toHSLA(){return this.toHSL(!0)}invert(e=this._alpha!==1){return new t(1-this.red,1-this.green,1-this.blue,e?1-this.alpha:this.alpha)}},x=class t{_hue;get hue(){return this._hue}set hue(e){this._hue=i(e,0,1)}_saturation;get saturation(){return this._saturation}set saturation(e){this._saturation=i(e,0,1)}_luminace;get luminace(){return this._luminace}set luminace(e){this._luminace=i(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=i(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`HSLColor`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toHSL`,`function`))return this.cast(t.toHSL());if((0,e.hasTypedProperty)(t,`toHSLA`,`function`))return this.cast(t.toHSLA());if((0,e.hasTypedProperty)(t,`hue`,`number`)&&(0,e.hasTypedProperty)(t,`saturation`,`number`)&&(0,e.hasTypedProperty)(t,`luminace`,`number`))return new this(t.hue,t.saturation,t.luminace,(0,e.hasTypedProperty)(t,`alpha`,`number`)?t.alpha:void 0);if((0,e.isValidNumber)(t)){let e=t.toString(16).length<=6?p:m;return this.cast(e(t))}if((0,e.isValidString)(t)){if(t.startsWith(`hsl`)){let n=t.startsWith(`hsla`),r=n?5:4,i=t.substring(r,t.indexOf(`)`,r)).split(`,`);if((0,e.isFixedTypeArray)(i,e.isValidString,n?4:3))return this.cast(i.map(e=>parseInt(e)/255))}if(h(t)){let e=_(t)?y:v;return this.cast(e(t))}}}}static is(e){return this.cast(e)!==void 0}constructor(t,n,r,a=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(a),this._hue=i(t,0,1),this._saturation=i(n,0,1),this._luminace=i(r,0,1),this._alpha=i(a,0,1)}toArray(e=this._alpha!==1){return e?[this.hue,this.saturation,this.luminace,this.alpha]:[this.hue,this.saturation,this.luminace]}toJSON(e=this._alpha!==1){return e?{hue:this.hue,saturation:this.saturation,luminace:this.luminace,alpha:this.alpha}:{hue:this.hue,saturation:this.saturation,luminace:this.luminace}}toString(e=this._alpha!==1){return e?`hsla(${i(this.hue*255|0,0,255)},${i(this.saturation*255|0,0,255)},${i(this.luminace*255|0,0,255)},${this.alpha})`:`hsl(${i(this.hue*255|0,0,255)},${i(this.saturation*255|0,0,255)},${i(this.luminace*255|0,0,255)})`}get[Symbol.toStringTag](){return`HSLA`}[e.NodeJSCustomInspect](){return`HSLA <${this.toString()}>`}toRGB(e=this._alpha!==1){if(this.saturation==0)return new b(this.luminace*255,this.luminace*255,this.luminace*255,e?this.alpha:void 0);let t=this.luminace<.5?this.luminace*(1+this.saturation):this.luminace+this.saturation-this.luminace*this.saturation,n=2*this.luminace-t;function r(e){let r=e;return r<0&&r++,r>1&&r--,r<1/6?n+(t-n)*6*r:r<1/2?t:r<2/3?n+(t-n)*(2/3-r)*6:n}return new b(r(this.hue+1/3)*255,r(this.hue)*255,r(this.hue-1/3)*255,e?this.alpha:void 0)}toRGBA(){return this.toRGB(!0)}toVec2(){return[this.hue,this.saturation,this.luminace]}toVec3(){return[this.hue,this.saturation,this.luminace,this.alpha]}invert(e=this._alpha!==1){return new t(1-this.hue,1-this.saturation,1-this.luminace,e?1-this.alpha:this.alpha)}};const S=5381n;function C(e){let t=String(e),n=S;for(let e=0;e<t.length;e++)n=(n<<5n)+n+BigInt(t.charCodeAt(e));return n}const w=14695981039346656037n,T=1099511628211n;function E(e){let t=String(e),n=w;for(let e=0;e<t.length;e++)n*=T,n^=BigInt(t.charCodeAt(e));return n}function D(e){let t=String(e),n=0n;for(let e=0;e<t.length;e++)n=BigInt(t.charCodeAt(e))+(n<<6n)+(n<<16n)-n;return n}const O=e=>e%360,k=e=>O(j(e)),A=e=>e*(180/Math.PI),j=e=>e*(Math.PI/180);var M=class t{radius;get perimeter(){return this.radius*Math.PI*2}get area(){return Math.PI*this.radius**2}position;get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Circle`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)?new this([t[0],t[1]],t[2]):t.length===2?new this(t[0],t[1]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,3))return new this([t[0],t[1]],t[2]);if((0,e.isFixedTypeArray)(t,e.isValidNumber,4)){let e=new this([t[0],t[1]],t[3]);return e.w=t[2],e}if((0,e.hasTypedProperty)(t,`toCircle`,`function`))return this.cast(t.toCircle());if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`radius`,`number`))return new this((0,e.hasTypedProperty)(t,`w`,`number`)?[t.x,t.y,t.w]:[t.x,t.y],t.radius);if((0,e.isValidString)(t)){let[e,n]=t.split(`|`),r=c.cast(e);if(r===void 0||n===void 0)return;let i=parseFloat(n);if(!isNaN(i))return new this(r,i)}}}static is(e){return this.cast(e)!==void 0}constructor(t,n){(0,e.checkValidNumber)(n),this.position=c.resolve(t),this.radius=n}toArray(){return[...this.position.toArray(),this.radius]}toJSON(){return{...this.position.toJSON(),radius:this.radius}}toString(){return`${this.position.toString()}|${this.radius}`}get[Symbol.toStringTag](){return`Circle`}[e.NodeJSCustomInspect](){return`Circle <${this.toString()}>`}clone(){return new t(this.position.clone(),this.radius)}toVec2(){return[this.x,this.y,this.w]}equals(...e){let n=t.resolveArgs(e);return n.position.equals(n.position)&&this.radius==n.radius}inside(...e){let n=t.resolveArgs(e),r=n.x-this.x,i=n.y-this.y;return Math.sqrt(r*r+(i+i))<=this.radius+n.radius}insidePoint(...e){return this.position.distance(c.resolveArgs(e))<=this.radius}},N=class t{left;right;top;bottom;get width(){return this.right-this.left}set width(e){this.right=this.left+e}get height(){return this.bottom-this.top}set height(e){this.bottom=this.top+e}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}w=1;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`BoundingBox`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toBoundingBox`,`function`))return this.cast(t.toBoundingBox());if((0,e.hasTypedProperty)(t,`left`,`number`)&&(0,e.hasTypedProperty)(t,`right`,`number`)&&(0,e.hasTypedProperty)(t,`top`,`number`)&&(0,e.hasTypedProperty)(t,`bottom`,`number`))return new this(t.left,t.right,t.top,t.bottom);if((0,e.isValidString)(t)){let n=t.split(`,`);if((0,e.isFixedTypeArray)(n,e.isValidString,4))return this.cast(n.map(e=>parseFloat(e)))}}}static is(e){return this.cast(e)!==void 0}constructor(t,n,r,i){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(i),this.left=t,this.right=n,this.top=r,this.bottom=i}toArray(){return[this.left,this.right,this.top,this.bottom]}toString(){return`${this.left},${this.right},${this.top},${this.bottom}`}get[Symbol.toStringTag](){return`BoundingBox`}[e.NodeJSCustomInspect](){return`BoundingBox <${this.toString()}>`}toJSON(){return{left:this.left,top:this.top,right:this.right,bottom:this.bottom}}clone(){return new t(this.left,this.right,this.top,this.bottom)}equals(...e){let n=t.resolveArgs(e);return this.left===n.left&&this.right===n.right&&this.top===n.top&&this.bottom===n.bottom}toSize(){return[this.width,this.height]}toVec2(){return[this.left,this.top]}toRectangle(){return[this.left,this.top,this.width,this.height]}inside(...e){let n=t.resolve(e);return this.right>=n.left&&n.right>=this.left&&this.bottom>=n.top&&n.bottom>=this.top}insidePoint(...e){let t=c.resolveArgs(e);return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}insideCircle(...e){let t=M.resolveArgs(e),n=c.resolve(t).add(t.radius),r=new c(this.width/2,this.height/2),i=new c(this.left+r.x,this.top+r.y),a=n.subtract(i),o=c.clamp(a,r.invert(),r);return a=i.add(o).subtract(n),a.length()<t.radius}},P=class t{width;height;get aspectRatio(){return this.height/this.width}get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Square`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,2)?new this(t[0],t[1]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,2))return new this(t[0],t[1]);if((0,e.hasTypedProperty)(t,`toSize`,`function`))return this.cast(t.toSize());if((0,e.hasTypedProperty)(t,`width`,`number`)&&(0,e.hasTypedProperty)(t,`height`,`number`))return new this(t.width,t.height);if((0,e.isValidString)(t)){let n=t.split(`x`).map(e=>parseFloat(e));if((0,e.isFixedTypeArray)(n,e.isValidNumber,2))return this.cast(n)}if((0,e.isValidNumber)(t))return new this(t,t)}}static is(e){return this.cast(e)!==void 0}constructor(t,n){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),this.width=t,this.height=n}toArray(){return[this.width,this.height]}toString(){return`${this.width}x${this.height}`}get[Symbol.toStringTag](){return`Size`}[e.NodeJSCustomInspect](){return`Size <${this.toString()}>`}toJSON(){return{width:this.width,height:this.height}}clone(){return new t(this.width,this.height)}equals(...e){let n=t.resolveArgs(e);return this.width==n.width&&this.height==n.height}toVec2(){return[this.width,this.height]}},F=class t{position;size;get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}get width(){return this.size.width}set width(e){this.size.width=e}get height(){return this.size.height}set height(e){this.size.height=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Rectangle`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this([t[0],t[1]],[t[2],t[3]]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this([t[0],t[1]],[t[2],t[3]]);if((0,e.isFixedTypeArray)(t,e.isValidNumber,5)){let e=new this([t[0],t[1]],[t[3],t[4]]);return e.w=t[2],e}if((0,e.isValidString)(t)){let[e,n]=t.split(`|`),r=c.cast(e),i=P.cast(n);if(r===void 0||i===void 0)return;let a=new this([r.x,r.y],[i.width,i.height]);return a.w=r.w,a}if((0,e.hasTypedProperty)(t,`toRectangle`,`function`))return this.cast(t.toRectangle());if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`width`,`number`)&&(0,e.hasTypedProperty)(t,`height`,`number`)){let n=new this([t.x,t.y],[t.width,t.height]);return(0,e.hasTypedProperty)(t,`w`,`number`)&&(n.w=t.w),n}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){this.position=c.resolve(e),this.size=P.resolve(t)}toArray(e=this.w!==1){return[...this.position.toArray(e),...this.size.toArray()]}toString(e=this.w!==1){return`${this.position.toString(e)}|${this.size.toString()}`}get[Symbol.toStringTag](){return`Rectangle`}[e.NodeJSCustomInspect](){return`Rectangle <${this.toString()}>`}toJSON(){return{...this.position.toJSON(),...this.size.toJSON()}}toBoundingBox(){return[this.x,this.x+this.width,this.y,this.y+this.height]}toVec2(){return[this.x,this.y,this.w]}toSize(){return[this.width,this.height]}clone(){return new t(this.position.clone(),this.size.clone())}equals(...e){let n=t.resolveArgs(e);return this.position.equals(n.position)&&this.size.equals(n.size)}},I=class{constructor(e,t,n){this.A=e,this.B=t,this.C=n}get alpha(){return Math.acos((this.b*this.b+this.c*this.c-this.a*this.a)/(2*this.b*this.c))}get beta(){return Math.acos((this.c*this.c+this.a*this.a-this.b*this.b)/(2*this.c*this.a))}get gamma(){return Math.acos((this.a*this.a+this.b*this.b-this.c*this.c)/(2*this.a*this.b))}get perimeter(){return this.a+this.b+this.c}get semiperimeter(){return this.perimeter/2}get area(){return Math.sqrt(this.semiperimeter*(this.semiperimeter-this.a)*(this.semiperimeter-this.b)*(this.semiperimeter-this.c))}get base(){return 2*(this.area/(this.a*Math.sin(this.gamma)))}get height(){return 2*(this.area/this.base)}toString(){return`${this.A}|${this.B}|${this.C}`}get[Symbol.toStringTag](){return`Triangle`}[e.NodeJSCustomInspect](){return`Triangle <${this.toString()}>`}},L=class extends I{get a(){return c.fromPoints(this.B,this.C).length()}get b(){return c.fromPoints(this.A,this.C).length()}get c(){return c.fromPoints(this.A,this.B).length()}},R=class extends I{get a(){return d.fromPoints(this.B,this.C).length()}get b(){return d.fromPoints(this.A,this.C).length()}get c(){return d.fromPoints(this.A,this.B).length()}},z=class t{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m10(){return this._raw[3]}set m10(e){this._raw[3]=e}get m11(){return this._raw[4]}set m11(e){this._raw[4]=e}get m12(){return this._raw[5]}set m12(e){this._raw[5]=e}get m20(){return this._raw[6]}set m20(e){this._raw[6]=e}get m21(){return this._raw[7]}set m21(e){this._raw[7]=e}get m22(){return this._raw[8]}set m22(e){this._raw[8]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Mat3`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,9)?new this(t):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,9))return new this(t);if((0,e.isFixedArray)(t,3)){let n=t[0],r=t[1],i=t[2];if((0,e.isFixedTypeArray)(n,e.isValidNumber,3)&&(0,e.isFixedTypeArray)(r,e.isValidNumber,3)&&(0,e.isFixedTypeArray)(i,e.isValidNumber,3))return new this([n[0],n[1],n[2],r[0],r[1],r[2],i[0],i[1],i[2]])}if((0,e.isValidString)(t)){let n=t.split(`,`);if((0,e.isFixedTypeArray)(n,e.isValidString,9))return this.cast(n.map(e=>parseFloat(e)))}if((0,e.hasTypedProperty)(t,`toMat3`,`function`))return this.cast(t.toMat3());if((0,e.hasTypedProperty)(t,`m00`,`number`)&&(0,e.hasTypedProperty)(t,`m01`,`number`)&&(0,e.hasTypedProperty)(t,`m02`,`number`)&&(0,e.hasTypedProperty)(t,`m10`,`number`)&&(0,e.hasTypedProperty)(t,`m11`,`number`)&&(0,e.hasTypedProperty)(t,`m12`,`number`)&&(0,e.hasTypedProperty)(t,`m20`,`number`)&&(0,e.hasTypedProperty)(t,`m21`,`number`)&&(0,e.hasTypedProperty)(t,`m22`,`number`))return new this([t.m00,t.m01,t.m02,t.m10,t.m11,t.m12,t.m20,t.m21,t.m22]);if((0,e.isValidNumber)(t))return new this([t,t,t,t,t,t,t,t,t])}}static is(e){return this.cast(e)!==void 0}static projection(e,t){return new this([2/e,0,0,0,-2/t,0,-1,1,1])}constructor(t=[1,0,0,0,1,0,0,0,1]){(0,e.checkFixedTypeArray)(t,e.isValidNumber,9),this._raw=t}toArray(){return[this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22]}toNestetArray(){return[[this.m00,this.m01,this.m02],[this.m10,this.m11,this.m12],[this.m20,this.m21,this.m22]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m10:this.m10,m11:this.m11,m12:this.m12,m20:this.m20,m21:this.m21,m22:this.m22}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`}get[Symbol.toStringTag](){return`Mat3`}[e.NodeJSCustomInspect](){return`Mat3 <${this.toString()}>`}clone(){return new t([this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22])}equals(...e){let n=t.resolveArgs(e);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1))return new t([this.m00*n[0],this.m01*n[0],this.m02*n[0],this.m10*n[0],this.m11*n[0],this.m12*n[0],this.m20*n[0],this.m21*n[0],this.m22*n[0]]);let r=t.resolveArgs(n);return new t([r.m00*this.m00+r.m01*this.m10+r.m02*this.m20,r.m00*this.m01+r.m01*this.m11+r.m02*this.m21,r.m00*this.m02+r.m01*this.m12+r.m02*this.m22,r.m10*this.m00+r.m11*this.m10+r.m12*this.m20,r.m10*this.m01+r.m11*this.m11+r.m12*this.m21,r.m10*this.m02+r.m11*this.m12+r.m12*this.m22,r.m20*this.m00+r.m21*this.m10+r.m22*this.m20,r.m20*this.m01+r.m21*this.m11+r.m22*this.m21,r.m20*this.m02+r.m21*this.m12+r.m22*this.m22])}translate(...e){let t=c.resolveArgs(e);return this.multiply([1,0,0,0,1,0,t.x,t.y,1])}rotate(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,-n,0,n,t,0,0,0,1])}scale(...e){let t=c.resolve(e);return this.multiply([t.x,0,0,0,t.y,0,0,0,1])}determinant(){return this.m00*this.m11*this.m22-this.m21*this.m12-this.m01*this.m10*this.m22-this.m12*this.m20+this.m02*this.m10*this.m21-this.m11*this.m20}inverse(){let e=this.determinant();return new t([(this.m11*this.m22-this.m21*this.m12)*e,(this.m02*this.m21-this.m01*this.m22)*e,(this.m01*this.m12-this.m02*this.m11)*e,(this.m12*this.m20-this.m10*this.m22)*e,(this.m00*this.m22-this.m02*this.m20)*e,(this.m10*this.m02-this.m00*this.m12)*e,(this.m10*this.m21-this.m20*this.m11)*e,(this.m20*this.m01-this.m00*this.m21)*e,(this.m00*this.m11-this.m10*this.m01)*e])}toMat4(){return[this.m00,this.m01,this.m02,0,this.m10,this.m11,this.m12,0,this.m20,this.m20,this.m22,0,0,0,0,1]}},B=class t{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m03(){return this._raw[3]}set m03(e){this._raw[3]=e}get m10(){return this._raw[4]}set m10(e){this._raw[4]=e}get m11(){return this._raw[5]}set m11(e){this._raw[5]=e}get m12(){return this._raw[6]}set m12(e){this._raw[6]=e}get m13(){return this._raw[7]}set m13(e){this._raw[7]=e}get m20(){return this._raw[8]}set m20(e){this._raw[8]=e}get m21(){return this._raw[9]}set m21(e){this._raw[9]=e}get m22(){return this._raw[10]}set m22(e){this._raw[10]=e}get m23(){return this._raw[11]}set m23(e){this._raw[11]=e}get m30(){return this._raw[12]}set m30(e){this._raw[12]=e}get m31(){return this._raw[13]}set m31(e){this._raw[13]=e}get m32(){return this._raw[14]}set m32(e){this._raw[14]=e}get m33(){return this._raw[15]}set m33(e){this._raw[15]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Mat4`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,16)?new this(t):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,16))return new this(t);if((0,e.isFixedArray)(t,4)){let n=t[0],r=t[1],i=t[2],a=t[3];if((0,e.isFixedTypeArray)(n,e.isValidNumber,4)&&(0,e.isFixedTypeArray)(r,e.isValidNumber,4)&&(0,e.isFixedTypeArray)(i,e.isValidNumber,4)&&(0,e.isFixedTypeArray)(a,e.isValidNumber,4))return new this([n[0],n[1],n[2],n[3],r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3],a[0],a[1],a[2],a[3]])}if((0,e.isValidString)(t)){let n=t.split(`,`);if((0,e.isFixedTypeArray)(n,e.isValidString,16))return this.cast(n.map(e=>parseFloat(e)))}if((0,e.hasTypedProperty)(t,`toMat4`,`function`))return this.cast(t.toMat4());if((0,e.hasTypedProperty)(t,`m00`,`number`)&&(0,e.hasTypedProperty)(t,`m01`,`number`)&&(0,e.hasTypedProperty)(t,`m02`,`number`)&&(0,e.hasTypedProperty)(t,`m03`,`number`)&&(0,e.hasTypedProperty)(t,`m10`,`number`)&&(0,e.hasTypedProperty)(t,`m11`,`number`)&&(0,e.hasTypedProperty)(t,`m12`,`number`)&&(0,e.hasTypedProperty)(t,`m13`,`number`)&&(0,e.hasTypedProperty)(t,`m20`,`number`)&&(0,e.hasTypedProperty)(t,`m21`,`number`)&&(0,e.hasTypedProperty)(t,`m22`,`number`)&&(0,e.hasTypedProperty)(t,`m23`,`number`)&&(0,e.hasTypedProperty)(t,`m30`,`number`)&&(0,e.hasTypedProperty)(t,`m31`,`number`)&&(0,e.hasTypedProperty)(t,`m32`,`number`)&&(0,e.hasTypedProperty)(t,`m33`,`number`))return new this([t.m00,t.m01,t.m02,t.m03,t.m10,t.m11,t.m12,t.m13,t.m20,t.m21,t.m22,t.m23,t.m30,t.m31,t.m32,t.m33]);if((0,e.isValidNumber)(t))return new this([t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t])}}static is(e){return this.cast(e)!==void 0}static orthographic(...t){let n=(0,e.isFixedTypeArray)(t,e.isValidNumber,6)?new N(t[0],t[1],t[2],t[3]):N.resolve(t[0]),r=(0,e.isFixedTypeArray)(t,e.isValidNumber,6)?t[4]:t[1],i=(0,e.isFixedTypeArray)(t,e.isValidNumber,6)?t[5]:t[2];return new this([2/(n.right-n.left),0,0,0,0,2/(n.top-n.bottom),0,0,0,0,2/(r-i),0,(n.left+n.right)/(n.left-n.right),(n.bottom+n.top)/(n.bottom-n.top),(r+i)/(r-i),1])}static perspective(e,t,n,r){let i=Math.tan(Math.PI*.5-.5*e),a=1/(n-r);return new this([i/t,0,0,0,0,i,0,0,0,0,(n+r)*a,-1,0,0,n*r*a*2,0])}static pointAt(e,t,n){let r=d.resolve(t).subtract(e).normalize(),i=r.multiply(d.resolve(n).dot(r)),a=d.resolve(n).subtract(i).normalize(),o=a.cross(r),s=d.resolve(e);return new this([o.x,o.y,o.z,0,a.x,a.y,a.z,0,r.x,r.y,r.z,0,s.x,s.y,s.z,1])}constructor(t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]){(0,e.checkFixedTypeArray)(t,e.isValidNumber,16),this._raw=t}toArray(){return[this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33]}toNestetArray(){return[[this.m00,this.m01,this.m02,this.m03],[this.m10,this.m11,this.m12,this.m13],[this.m20,this.m21,this.m22,this.m23],[this.m30,this.m31,this.m32,this.m33]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m03:this.m03,m10:this.m10,m11:this.m11,m12:this.m12,m13:this.m13,m20:this.m20,m21:this.m21,m22:this.m22,m23:this.m23,m30:this.m20,m31:this.m21,m32:this.m22,m33:this.m23}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`}get[Symbol.toStringTag](){return`Mat4`}[e.NodeJSCustomInspect](){return`Mat4 <${this.toString()}>`}clone(){return new t([this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33])}equals(...e){let n=t.resolveArgs(e);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1)){let e=n[0];return new t([this.m00*e,this.m01*e,this.m02*e,this.m03*e,this.m10*e,this.m11*e,this.m12*e,this.m13*e,this.m20*e,this.m21*e,this.m22*e,this.m23*e,this.m30*e,this.m31*e,this.m32*e,this.m33*e])}let r=d.cast(n[0]);if(r!==void 0){let e=new d(r.x*this.m00+r.y*this.m10+r.z*this.m20+this.m30,r.x*this.m01+r.y*this.m11+r.z*this.m21+this.m31,r.x*this.m02+r.y*this.m12+r.z*this.m22+this.m32,r.x*this.m03+r.y*this.m13+r.z*this.m23+this.m33);return e.w==0?e:e.divide(e.w)}let i=t.resolveArgs(n);return new t([i.m00*this.m00+i.m01*this.m10+i.m02*this.m20+i.m03*this.m30,i.m00*this.m01+i.m01*this.m11+i.m02*this.m21+i.m03*this.m31,i.m00*this.m02+i.m01*this.m12+i.m02*this.m22+i.m03*this.m32,i.m00*this.m03+i.m01*this.m13+i.m02*this.m23+i.m03*this.m33,i.m10*this.m00+i.m11*this.m10+i.m12*this.m20+i.m13*this.m30,i.m10*this.m01+i.m11*this.m11+i.m12*this.m21+i.m13*this.m31,i.m10*this.m02+i.m11*this.m12+i.m12*this.m22+i.m13*this.m32,i.m10*this.m03+i.m11*this.m13+i.m12*this.m23+i.m13*this.m33,i.m20*this.m00+i.m21*this.m10+i.m22*this.m20+i.m23*this.m30,i.m20*this.m01+i.m21*this.m11+i.m22*this.m21+i.m23*this.m31,i.m20*this.m02+i.m21*this.m12+i.m22*this.m22+i.m23*this.m32,i.m20*this.m03+i.m21*this.m13+i.m22*this.m23+i.m23*this.m33,i.m30*this.m00+i.m31*this.m10+i.m32*this.m20+i.m33*this.m30,i.m30*this.m01+i.m31*this.m11+i.m32*this.m21+i.m33*this.m31,i.m30*this.m02+i.m31*this.m12+i.m32*this.m22+i.m33*this.m32,i.m30*this.m03+i.m31*this.m13+i.m32*this.m23+i.m33*this.m33])}translate(...e){let t=d.resolveArgs(e);return this.multiply([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}rotateX(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([1,0,0,0,0,t,n,0,0,-n,t,0,0,0,0,1])}rotateY(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,0,-n,0,0,1,0,0,n,0,t,0,0,0,0,1])}rotateZ(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,n,0,0,-n,t,0,0,0,0,1,0,0,0,0,1])}rotate(...e){let t=d.resolveArgs(e);return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z)}scale(...e){let t=d.resolveArgs(e);return this.multiply([t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1])}inverse(){return new t([this.m00,this.m10,this.m20,0,this.m01,this.m11,this.m21,0,this.m02,this.m12,this.m22,0,-(this.m30*this.m00+this.m31*this.m10+this.m32*this.m20),-(this.m30*this.m01+this.m31*this.m11+this.m32*this.m21),-(this.m30*this.m02+this.m31*this.m12+this.m32*this.m22),1])}toMat3(){return[this.m00,this.m01,this.m03,this.m10,this.m11,this.m13,this.m30,this.m31,this.m33]}};let V;(function(t){function n(e,t=!1){let n=[];try{let t=b.resolve(e);n.push(t)}catch{}try{let t=x.resolve(e);n.push(t)}catch{}let r=t?1:0,i=n[r];if(i)return i;let a=n[r+1];if(a)return a}t.cast=n;function i(e,t=!1){let i=n(e,t);if(i!==void 0)return i;throw new r(`Color`,e)}t.resolve=i;function a(t,n=!1){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?i(t,n):i(t[0],n)}t.resolveArgs=a})(V||={});var H=class{origin=c.zero;localPosition;localRotation;get localRotationDegree(){return A(this.localRotation)}set localRotationDegree(e){this.localRotation=j(e)}localScale;get globalPosition(){let e=c.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=0,t=this;for(;t!==void 0;)e+=t.localRotation,t=t.parent;return e}get globalRotationDegree(){return A(this.globalRotation)}get globalScale(){let e=c.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(t,n,r,i){this.parent=i,(0,e.checkValidNumber)(n),this.localPosition=c.resolve(t),this.localRotation=n,this.localScale=c.resolve(r)}toString(){return`${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[e.NodeJSCustomInspect](){return`Transform2D <${this.toString()}>`}toMat3(){return new z().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition)}toGlobalMat3(){let e=new z,t=this;for(;t!==void 0;)e=e.multiply(t.toMat3()),t=t.parent;return e}},U=class{origin=d.zero;localPosition;localRotation;localScale;get globalPosition(){let e=d.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=f.zero,t=this;for(;t!==void 0;)e=e.add(t.localRotation),t=t.parent;return e}get globalScale(){let e=d.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,r){this.parent=r,this.localPosition=d.resolve(e),this.localRotation=f.resolve(t),this.localScale=d.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[e.NodeJSCustomInspect](){return`Transform2D <${this.toString()}>`}toMat4(){return new B().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition)}toGlobalMat4(){let e=new B,t=this;for(;t!==void 0;)e=e.multiply(t.toMat4()),t=t.parent;return e}};Object.defineProperty(exports,`AnyColor`,{enumerable:!0,get:function(){return V}}),exports.BoundingBox=N,exports.Circle=M,exports.DJB2_OFFSET=S,exports.EPSILON=o,exports.FNV1_OFFSET=w,exports.FNV1_PRIME=T,exports.HSLA=x,exports.LinearFunction=l,exports.MAX_ANGLE_DEGREE=360,exports.Mat3=z,exports.Mat4=B,exports.MathFunction=t,exports.QuadFunction=u,exports.Quaternion=f,exports.RGBA=b,exports.Rectangle=F,exports.ResolveError=r,exports.Size=P,exports.Transform2D=H,exports.Transform3D=U,exports.Triangle=I,exports.Triangle2D=L,exports.Triangle3D=R,exports.Vec2=c,exports.Vec3=d,exports.clamp=i,exports.clampAngleDegree=O,exports.clampAngleRadian=k,exports.degreeToRadian=j,exports.djb2=C,exports.fnv1=E,exports.hasHexNumberAlpha=_,exports.hexNumberToRGB=v,exports.hexNumberToRGBA=y,exports.isHexNumber=h,exports.lerp=s,exports.logHypot=a,exports.numberToRGB=p,exports.numberToRGBA=m,exports.radianToDegree=A,exports.sdbm=D,exports.signCharacter=n;
|
|
1
|
+
let e=require(`@ntf/types`);var t=class{};function n(e){if(e!=0){if(e<0)return`-`;if(e>0)return`+`}}var r=class extends Error{constructor(e,t){super(`Can't resolve ${t} to ${e}`),this.target=e,this.value=t}};function i(e,t,n){return e<=t?t:e>=n?n:e}function a(e,t){let n=Math.abs(e),r=Math.abs(t);if(e==0)return Math.log(r);if(t==0)return Math.log(n);if(n<3e3&&r<3e3)return .5*Math.log(e*e+t*t);let i=e/2,a=t/2;return .5*Math.log(i*i+a*a)+Math.LN2}const o=1e-16,s=(e,t,n)=>((typeof e==`number`?1:1n)-n)*e+n*t;var c=class t{x;y;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Vec2`,e)}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let[n,r]=t.split(`;`);if((0,e.isValidString)(n)){let t=n.split(`,`);if((0,e.isFixedTypeArray)(t,e.isValidString,2))return new this(parseFloat(t[0]),parseFloat(t[1]),(0,e.isValidString)(r)?parseFloat(r):void 0)}}if((0,e.isValidNumber)(t))return new this(t,t);if((0,e.isFixedTypeArray)(t,e.isValidNumber,2)||(0,e.isFixedTypeArray)(t,e.isValidNumber,3))return new this(t[0],t[1],t[2]);if((0,e.hasTypedProperty)(t,`toVec2`,`function`))return this.cast(t.toVec2());if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`))return new this(t.x,t.y,(0,e.hasTypedProperty)(t,`w`,`number`)?t.w:void 0)}}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,2)?new this(t[0],t[1]):this.resolve(t[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y)}static clamp(e,t,n){let r=this.resolve(e),a=this.resolve(t),o=this.resolve(n);return new this(i(r.x,a.x,o.x),i(r.y,a.y,o.y))}static get zero(){return new this(0,0)}static get one(){return new this(1,1)}constructor(t,n,r=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),this.x=t,this.y=n,this.w=r}toArray(e=this.w!==1){return e?[this.x,this.y,this.w]:[this.x,this.y]}toJSON(){return{x:this.x,y:this.y,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y};${this.w}`:`${this.x},${this.y}`}get[Symbol.toStringTag](){return`Vec2`}[e.NodeJSCustomInspect](){return`Vec2 <${this.toString()}>`}toSize(){return[this.x,this.y]}toVec3(e=0){return[this.x,this.y,e,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.w]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.w,1]}toHSL(){let e=this.normalize();return[e.x,e.y,e.w]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.w,1]}clone(){return new t(this.x,this.y,this.w)}equals(...e){let n=t.resolveArgs(e);return this.x==n.x&&this.y==n.y}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setW(e){return this.w=e,this}set(...e){let n=t.resolveArgs(e);return this.setX(n.x).setY(n.y)}add(...e){let n=t.resolveArgs(e);return new t(this.x+n.x,this.y+n.y)}offset(...e){let n=t.resolveArgs(e);return this.x+=n.x,this.y+=n.y,this}subtract(...e){let n=t.resolveArgs(e);return new t(this.x-n.x,this.y-n.y)}multiply(e){return new t(this.x*e,this.y*e)}naiveMultiply(...e){let n=t.resolveArgs(e);return new t(this.x*n.x,this.y*n.y)}divide(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1))return new t(this.x/n[0],this.y/n[0]);let r=t.resolveArgs(n);return new t(this.x/r.x,this.y/r.y)}dot(...e){let n=t.resolveArgs(e);return this.x*n.x+this.y*n.y}distance(...e){let n=t.resolveArgs(e);return(n.x-this.x)**2+(n.y-this.y)**2}distanceSquare(...e){let n=t.resolveArgs(e);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}cartesianify(){return new t(this.x*Math.cos(this.y),this.x*Math.sin(this.y))}polarify(){return new t(Math.sqrt(this.x*this.x+this.y*this.y),Math.atan(this.y/this.x))}normalize(){let e=this.length();return e==0?t.zero:new t(this.x/e,this.y/e,this.w/e)}invert(){return this.multiply(-1)}round(){return new t(Math.round(this.x),Math.round(this.y),Math.round(this.w))}},l=class extends t{m;b;static fromPoints(e,t){let n=c.resolve(e),r=c.resolve(t),i=(r.y-n.y)/(r.x-n.x),a=-i*n.x+n.y;return new this(i,a)}constructor(t,n){super(),(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),this.m=t,this.b=n}get(t){return(0,e.checkValidNumber)(t),this.m*t+this.b}roots(){let e=-this.b/this.m;return isNaN(e)?[]:[new c(e,0)]}toString(){let e=n(this.b);return e?`f(x) = ${this.m} * x ${e} ${Math.abs(this.b)}`:`f(x) = ${this.m} * x`}get[Symbol.toStringTag](){return`LinearFunction`}[e.NodeJSCustomInspect](){return`LinearFunction <${this.toString()}>`}},u=class extends t{a;b;c;static get(e,t,n,r){return new this(e,t,n).get(r)}constructor(t,n,r){if(super(),(0,e.checkValidNumber)(t),t===0)throw new e.ExpectedTypeError(`non-zero valid number`,t);(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),this.a=t,this.b=n,this.c=r}get(t){return(0,e.checkValidNumber)(t),this.a*t*t+this.b*t+this.c}roots(){let e=[],t=this.b*this.b-4*this.a*this.c,n=(-this.b+Math.sqrt(t))/(2*this.a),r=(-this.b+Math.sqrt(t))/(2*this.a);return isNaN(n)||e.push(new c(n,0)),!isNaN(r)&&n!=r&&e.push(new c(r,0)),e}toString(e=`standard`){switch(e){default:case`standard`:{let e=n(this.b),t=n(this.c);return e&&t?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x ${t} ${Math.abs(this.c)}`:e?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x`:`f(x) = ${this.a}x^2`}}}get[Symbol.toStringTag](){return`QuadFunction`}[e.NodeJSCustomInspect](){return`QuadFunction <${this.toString()}>`}},d=class t{x;y;z;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Vec3`,e)}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let[n,r]=t.split(`;`);if((0,e.isValidString)(n)){let t=n.split(`,`);if((0,e.isFixedTypeArray)(t,e.isValidString,3))return new this(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]),(0,e.isValidString)(r)?parseFloat(r):void 0)}}if((0,e.isValidNumber)(t))return new this(t,t,t);if((0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`z`,`number`))return new this(t.x,t.y,t.z,(0,e.hasTypedProperty)(t,`w`,`number`)?t.w:void 0)}}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)?new this(t[0],t[1],t[2]):this.resolve(t[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y,r.z-n.z)}static clamp(e,t,n){let r=this.resolve(e),a=this.resolve(t),o=this.resolve(n);return new this(i(r.x,a.x,o.x),i(r.y,a.y,o.y),i(r.z,a.z,o.z))}static intersectPlane(e,n,r,i,a){n=this.resolve(n).normalize();let o=-this.resolve(n).dot(e),s=this.resolve(r).dot(n),c=this.resolve(i).dot(n);a=(-o-s)/(c-s);let l=this.resolve(i).subtract(r).multiply(a);return t.resolve(r).add(l)}static get zero(){return new this(0,0,0)}static get one(){return new this(1,1,1)}constructor(t,n,r,i=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(i),this.x=t,this.y=n,this.z=r,this.w=i}toArray(e=this.w!==1){return e?[this.x,this.y,this.z,this.w]:[this.x,this.y,this.z]}toJSON(){return{x:this.x,y:this.y,z:this.z,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y},${this.z};${this.w}`:`${this.x},${this.y},${this.z}`}get[Symbol.toStringTag](){return`Vec3`}[e.NodeJSCustomInspect](){return`Vec3 <${this.toString()}>`}toVec2(){return[this.x,this.y,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.z]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toHSL(){let e=this.normalize();return[e.x,e.y,e.z]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toQuaternion(){return[this.w,this.x,this.y,this.z]}clone(){return new t(this.x,this.y,this.z,this.w)}equals(...e){let n=t.resolveArgs(e);return this.x==n.x&&this.y==n.y&&this.z==n.z}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}set(...e){let n=t.resolveArgs(e);return this.setX(n.x).setY(n.y).setZ(n.z)}add(...e){let n=t.resolveArgs(e);return new t(this.x+n.x,this.y+n.y,this.z+n.z)}offset(...e){let n=t.resolveArgs(e);return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...e){let n=t.resolveArgs(e);return new t(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(e){return new t(this.x*e,this.y*e,this.z*e)}naiveMultiply(...e){let n=t.resolveArgs(e);return new t(this.x*n.x,this.y*n.y,this.z*n.z)}divide(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1))return new t(this.x/n[0],this.y/n[0],this.z/n[0]);let r=t.resolveArgs(n);return new t(this.x/r.x,this.y/r.y,this.z/r.z)}dot(...e){let n=t.resolveArgs(e);return this.x*n.x+this.y*n.y+this.z*n.z}cross(...e){let n=t.resolveArgs(e);return new t(this.y*n.z-this.z*n.y,this.z*n.x-this.x*n.z,this.x*n.y-this.y*n.x)}distance(...e){let n=t.resolveArgs(e);return(n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2}distanceSquare(...e){let n=t.resolveArgs(e);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let e=this.length();return e==0?t.zero:new t(this.x/e,this.y/e,this.z/e,this.w/e)}invert(){return this.multiply(-1)}round(){return new t(Math.round(this.x),Math.round(this.y),Math.round(this.z),Math.round(this.w))}},f=class t{w;x;y;z;static is(e){return this.cast(e)!==void 0}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Quaternion`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let n=t.replaceAll(` `,``).split(`+`);if((0,e.isFixedTypeArray)(n,e.isValidString,4)){let[e,t,r,i]=n;if(e&&t?.endsWith(`i`)&&r?.endsWith(`j`)&&i?.endsWith(`k`))return this.cast([parseFloat(e),parseFloat(t.substring(0,t.length-1)),parseFloat(r.substring(0,r.length-1)),parseFloat(i.substring(0,i.length-1))])}}if((0,e.isValidNumber)(t))return new this(t,t,t,t);if((0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toQuaternion`,`function`))return this.cast(t.toQuaternion());if((0,e.hasTypedProperty)(t,`w`,`number`)&&(0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`z`,`number`))return new this(t.w,t.x,t.y,t.z)}}static fromAxisAngle(...t){let n=(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new d(t[0],t[1],t[2]):d.resolve(t[0]),r=(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?t[3]:t[1],i=d.resolve(n),a=r*.5,o=Math.sin(a),s=Math.cos(a),c=o/Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z);return new this(s,i.x*c,i.y*c,i.z*c)}static fromEuler(...e){let n=d.resolveArgs(e),r=n.x*.5,i=n.y*.5,a=n.z*.5,o=Math.cos(r),s=Math.cos(i),c=Math.cos(a),l=Math.sin(r),u=Math.sin(i),f=Math.sin(a);return new t(o*s*c-l*u*f,l*s*c-u*f*o,u*o*c-l*f*s,l*u*c+f*o*s)}static get zero(){return new t(0,0,0,0)}constructor(t,n,r,i){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(i),this.w=t,this.x=n,this.y=r,this.z=i}toArray(){return[this.w,this.x,this.y,this.z]}toString(){return`${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`}get[Symbol.toStringTag](){return`Quaternion`}[e.NodeJSCustomInspect](){return`Quaternion <${this.toString()}>`}toJSON(){return{w:this.w,x:this.x,y:this.y,z:this.z}}clone(){return new t(this.w,this.x,this.y,this.z)}add(...e){let n=t.resolveArgs(e);return new t(this.w+n.w,this.x+n.x,this.y+n.y,this.z+n.z)}offset(...e){let n=t.resolveArgs(e);return this.w+=n.w,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...e){let n=t.resolveArgs(e);return new t(this.w-n.w,this.x-n.x,this.y-n.y,this.z-n.z)}negative(){return new t(-this.w,-this.x,-this.y,-this.z)}length(e=!0){let t=this.w*this.w+this.x*this.x+this.y*this.y+this.z*this.z;return e?Math.sqrt(t):t}normalize(){let e=this.length();return e<o?t.zero:(e=1/e,new t(this.w*e,this.x*e,this.y*e,this.z*e))}multiply(...e){let n=t.resolveArgs(e);return new t(this.w*n.w-this.x*n.x-this.y*n.y-this.z*n.z,this.w*n.x+this.x*n.w+this.y*n.z-this.z*n.y,this.w*n.y+this.y*n.w+this.z*n.x-this.x*n.z,this.w*n.z+this.z*n.w+this.x*n.y-this.y*n.x)}multiplyVector(...e){let t=d.resolveArgs(e),n=this.w*t.x+this.y*t.y-this.z*t.y,r=this.w*t.y+this.z*t.x-this.x*t.z,i=this.w*t.z+this.x*t.y-this.y*t.x,a=-this.w*t.x-this.y*t.y-this.z*t.z;return new d(n*this.w+a*-this.x+r*-this.z-i*-this.y,r*this.w+a*-this.y+i*-this.x-n*-this.z,i*this.w+a*-this.z+n*-this.y-r*-this.x)}scale(e){return new t(this.w*e,this.x*e,this.y*e,this.z*e)}dot(...e){let n=t.resolveArgs(e);return this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z}inverse(){let e=this.length(!1);return e==0?t.zero:(e=1/e,new t(this.w*e,-this.x*e,-this.y*e,-this.z*e))}divide(...e){let n=t.resolveArgs(e),r=n.length(!1);return r==0?t.zero:(r=1/r,new t((this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z)*r,(this.x*n.w-this.w*n.x-this.y*n.z+this.z*n.y)*r,(this.y*n.w-this.w*n.y-this.z*n.x+this.x*n.z)*r,(this.z*n.w-this.w*n.z-this.x*n.y+this.y*n.x)*r))}conjugate(){return new t(this.w,-this.x,-this.y,-this.z)}exp(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),n=Math.exp(this.w),r=n*Math.sin(e)/e;return e==0?new t(n,0,0,0):new t(n*Math.cos(e),this.x*r,this.y*r,this.z*r)}log(){if(this.x==0&&this.z==0)return new t(a(this.w,this.x),Math.atan2(this.x,this.w),0,0);let e=this.length(!1),n=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),r=Math.atan2(n,this.w)/e;return new t(Math.log(e)*.5,this.x*r,this.y*r,this.z*r)}toVec3(){return[this.x,this.y,this.z,this.w]}toAxisAngle(){let e=1-this.w*this.w;if(e>o)return new d(this.x,this.y,this.z,0);let t=1/Math.sqrt(e),n=2*Math.acos(this.w);return new d(this.x*t,this.y*t,this.z*t,n)}toEuler(){function e(e){return e>=1?Math.PI/2:e<=-1?-Math.PI/2:Math.asin(e)}return new d(-Math.atan2(2*(this.y*this.z-this.w*this.x),1-2*(this.x*this.x+this.y*this.y)),e(2*(this.x*this.z+this.w*this.y)),-Math.atan2(2*(this.x*this.y-this.w*this.z),1-2*(this.y*this.y+this.z*this.z)))}toMat3(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y)]}toMat4(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),0,2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),0,2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y),0,0,0,0,1]}};function p(e){let t=e<4096,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8;return[(t?(e&3840)>>>8:(e&16711680)>>>16)/255,r/255,n/255]}function m(e){let t=e<65536,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8,i=t?(e&3840)>>>8:(e&16711680)>>>16;return[(t?(e&61440)>>>12:(e&4278190080)>>>24)/255,i/255,r/255,n/255]}function h(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)||e.startsWith(`0x`)}function g(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)?e.substring(1):e.startsWith(`0x`)?e.substring(2):e}function _(e){let t=g(e);return[4,8].includes(t.length)}function v(e){let t=g(e),n=t.length===3,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16);return[r/255,i/255,a/255]}function y(e){let t=g(e),n=t.length===4,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16),o=parseInt(n?t[3]:t.substring(6,8),16);return[r/255,i/255,a/255,o/255]}var b=class t{_red;get red(){return this._red}set red(e){this._red=i(e,0,1)}_green;get green(){return this._green}set green(e){this._green=i(e,0,1)}_blue;get blue(){return this._blue}set blue(e){this._blue=i(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=i(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`RGBAColor`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toRGB`,`function`))return this.cast(t.toRGB());if((0,e.hasTypedProperty)(t,`toRGBA`,`function`))return this.cast(t.toRGBA());if((0,e.hasTypedProperty)(t,`red`,`number`)&&(0,e.hasTypedProperty)(t,`green`,`number`)&&(0,e.hasTypedProperty)(t,`blue`,`number`))return new this(t.red,t.green,t.blue,(0,e.hasTypedProperty)(t,`alpha`,`number`)?t.alpha:void 0);if((0,e.isValidNumber)(t)){let e=t.toString(16).length<=6?p:m;return this.cast(e(t))}if((0,e.isValidString)(t)){if(t.startsWith(`rgb`)){let n=t.startsWith(`rgba`),r=n?5:4,i=t.substring(r,t.indexOf(`)`,r)).split(`,`);if((0,e.isFixedTypeArray)(i,e.isValidString,n?4:3))return this.cast(i.map(e=>parseInt(e)/255))}if(h(t)){let e=_(t)?y:v;return this.cast(e(t))}}}}static is(e){return this.cast(e)!==void 0}constructor(t,n,r,a=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(a),this._red=i(t,0,1),this._green=i(n,0,1),this._blue=i(r,0,1),this._alpha=i(a,0,1)}toArray(e=this._alpha!==1){return e?[this.red,this.green,this.blue,this.alpha]:[this.red,this.green,this.blue]}toJSON(e=this._alpha!==1){return e?{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}:{red:this.red,green:this.green,blue:this.blue}}toString(e=this._alpha!==1){return e?`rgba(${i(this.red*255|0,0,255)},${i(this.green*255|0,0,255)},${i(this.blue*255|0,0,255)},${this.alpha})`:`rgb(${i(this.red*255|0,0,255)},${i(this.green*255|0,0,255)},${i(this.blue*255|0,0,255)})`}get[Symbol.toStringTag](){return`RGBA`}[e.NodeJSCustomInspect](){return`RGBA <${this.toString()}>`}toVec2(){return[this.red,this.green,this.blue]}toVec3(){return[this.red,this.green,this.blue,this.alpha]}toHSL(e=this._alpha!==1){let t=this.red,n=this.green,r=this.blue,i=Math.min(t,n,r),a=Math.max(t,n,r),o=(i+a)/2;if(i==a)return new x(0,0,o,e?this.alpha:void 0);let s=a-i,c=o>.5?s/(2-a-i):s/(a+i);return a==t?new x(((n-r)/s+(n<r?6:0))/6,c,o,e?this.alpha:void 0):a==n?new x(((r-t)/s+2)/6,c,o,e?this.alpha:void 0):a==r?new x(((t-n)/s+4)/6,c,o,e?this.alpha:void 0):new x(0,c,o,e?this.alpha:void 0)}toHSLA(){return this.toHSL(!0)}invert(e=this._alpha!==1){return new t(1-this.red,1-this.green,1-this.blue,e?1-this.alpha:this.alpha)}},x=class t{_hue;get hue(){return this._hue}set hue(e){this._hue=i(e,0,1)}_saturation;get saturation(){return this._saturation}set saturation(e){this._saturation=i(e,0,1)}_luminace;get luminace(){return this._luminace}set luminace(e){this._luminace=i(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=i(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`HSLColor`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toHSL`,`function`))return this.cast(t.toHSL());if((0,e.hasTypedProperty)(t,`toHSLA`,`function`))return this.cast(t.toHSLA());if((0,e.hasTypedProperty)(t,`hue`,`number`)&&(0,e.hasTypedProperty)(t,`saturation`,`number`)&&(0,e.hasTypedProperty)(t,`luminace`,`number`))return new this(t.hue,t.saturation,t.luminace,(0,e.hasTypedProperty)(t,`alpha`,`number`)?t.alpha:void 0);if((0,e.isValidNumber)(t)){let e=t.toString(16).length<=6?p:m;return this.cast(e(t))}if((0,e.isValidString)(t)){if(t.startsWith(`hsl`)){let n=t.startsWith(`hsla`),r=n?5:4,i=t.substring(r,t.indexOf(`)`,r)).split(`,`);if((0,e.isFixedTypeArray)(i,e.isValidString,n?4:3))return this.cast(i.map(e=>parseInt(e)/255))}if(h(t)){let e=_(t)?y:v;return this.cast(e(t))}}}}static is(e){return this.cast(e)!==void 0}constructor(t,n,r,a=1){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(a),this._hue=i(t,0,1),this._saturation=i(n,0,1),this._luminace=i(r,0,1),this._alpha=i(a,0,1)}toArray(e=this._alpha!==1){return e?[this.hue,this.saturation,this.luminace,this.alpha]:[this.hue,this.saturation,this.luminace]}toJSON(e=this._alpha!==1){return e?{hue:this.hue,saturation:this.saturation,luminace:this.luminace,alpha:this.alpha}:{hue:this.hue,saturation:this.saturation,luminace:this.luminace}}toString(e=this._alpha!==1){return e?`hsla(${i(this.hue*255|0,0,255)},${i(this.saturation*255|0,0,255)},${i(this.luminace*255|0,0,255)},${this.alpha})`:`hsl(${i(this.hue*255|0,0,255)},${i(this.saturation*255|0,0,255)},${i(this.luminace*255|0,0,255)})`}get[Symbol.toStringTag](){return`HSLA`}[e.NodeJSCustomInspect](){return`HSLA <${this.toString()}>`}toRGB(e=this._alpha!==1){if(this.saturation==0)return new b(this.luminace*255,this.luminace*255,this.luminace*255,e?this.alpha:void 0);let t=this.luminace<.5?this.luminace*(1+this.saturation):this.luminace+this.saturation-this.luminace*this.saturation,n=2*this.luminace-t;function r(e){let r=e;return r<0&&r++,r>1&&r--,r<1/6?n+(t-n)*6*r:r<1/2?t:r<2/3?n+(t-n)*(2/3-r)*6:n}return new b(r(this.hue+1/3)*255,r(this.hue)*255,r(this.hue-1/3)*255,e?this.alpha:void 0)}toRGBA(){return this.toRGB(!0)}toVec2(){return[this.hue,this.saturation,this.luminace]}toVec3(){return[this.hue,this.saturation,this.luminace,this.alpha]}invert(e=this._alpha!==1){return new t(1-this.hue,1-this.saturation,1-this.luminace,e?1-this.alpha:this.alpha)}};const S=5381n;function C(e){let t=String(e),n=S;for(let e=0;e<t.length;e++)n=(n<<5n)+n+BigInt(t.charCodeAt(e));return n}const w=14695981039346656037n,T=1099511628211n;function E(e){let t=String(e),n=w;for(let e=0;e<t.length;e++)n*=T,n^=BigInt(t.charCodeAt(e));return n}function D(e){let t=String(e),n=0n;for(let e=0;e<t.length;e++)n=BigInt(t.charCodeAt(e))+(n<<6n)+(n<<16n)-n;return n}const O=e=>e%360,k=e=>O(j(e)),A=e=>e*(180/Math.PI),j=e=>e*(Math.PI/180);var M=class t{radius;get perimeter(){return this.radius*Math.PI*2}get area(){return Math.PI*this.radius**2}position;get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Circle`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)?new this([t[0],t[1]],t[2]):t.length===2?new this(t[0],t[1]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let[e,n]=t.split(`|`),r=c.cast(e);if(r===void 0||n===void 0)return;let i=parseFloat(n);if(!isNaN(i))return new this(r,i)}if((0,e.isFixedTypeArray)(t,e.isValidNumber,3))return new this([t[0],t[1]],t[2]);if((0,e.isFixedTypeArray)(t,e.isValidNumber,4)){let e=new this([t[0],t[1]],t[3]);return e.w=t[2],e}if((0,e.hasTypedProperty)(t,`toCircle`,`function`))return this.cast(t.toCircle());if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`radius`,`number`))return new this((0,e.hasTypedProperty)(t,`w`,`number`)?[t.x,t.y,t.w]:[t.x,t.y],t.radius)}}static is(e){return this.cast(e)!==void 0}constructor(t,n){(0,e.checkValidNumber)(n),this.position=c.resolve(t),this.radius=n}toArray(){return[...this.position.toArray(),this.radius]}toJSON(){return{...this.position.toJSON(),radius:this.radius}}toString(){return`${this.position.toString()}|${this.radius}`}get[Symbol.toStringTag](){return`Circle`}[e.NodeJSCustomInspect](){return`Circle <${this.toString()}>`}clone(){return new t(this.position.clone(),this.radius)}toVec2(){return[this.x,this.y,this.w]}equals(...e){let n=t.resolveArgs(e);return n.position.equals(n.position)&&this.radius==n.radius}inside(...e){let n=t.resolveArgs(e),r=n.x-this.x,i=n.y-this.y;return Math.sqrt(r*r+(i+i))<=this.radius+n.radius}insidePoint(...e){return this.position.distance(c.resolveArgs(e))<=this.radius}},N=class t{left;right;top;bottom;get width(){return this.right-this.left}set width(e){this.right=this.left+e}get height(){return this.bottom-this.top}set height(e){this.bottom=this.top+e}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}w=1;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`BoundingBox`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this(t[0],t[1],t[2],t[3]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let n=t.split(`,`);if((0,e.isFixedTypeArray)(n,e.isValidString,4))return this.cast(n.map(e=>parseFloat(e)))}if((0,e.isValidNumber)(t))return new this(t,t,t,t);if((0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this(t[0],t[1],t[2],t[3]);if((0,e.hasTypedProperty)(t,`toBoundingBox`,`function`))return this.cast(t.toBoundingBox());if((0,e.hasTypedProperty)(t,`left`,`number`)&&(0,e.hasTypedProperty)(t,`right`,`number`)&&(0,e.hasTypedProperty)(t,`top`,`number`)&&(0,e.hasTypedProperty)(t,`bottom`,`number`))return new this(t.left,t.right,t.top,t.bottom)}}static is(e){return this.cast(e)!==void 0}constructor(t,n,r,i){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),(0,e.checkValidNumber)(r),(0,e.checkValidNumber)(i),this.left=t,this.right=n,this.top=r,this.bottom=i}toArray(){return[this.left,this.right,this.top,this.bottom]}toString(){return`${this.left},${this.right},${this.top},${this.bottom}`}get[Symbol.toStringTag](){return`BoundingBox`}[e.NodeJSCustomInspect](){return`BoundingBox <${this.toString()}>`}toJSON(){return{left:this.left,top:this.top,right:this.right,bottom:this.bottom}}clone(){return new t(this.left,this.right,this.top,this.bottom)}equals(...e){let n=t.resolveArgs(e);return this.left===n.left&&this.right===n.right&&this.top===n.top&&this.bottom===n.bottom}toSize(){return[this.width,this.height]}toVec2(){return[this.left,this.top]}toRectangle(){return[this.left,this.top,this.width,this.height]}inside(...e){let n=t.resolve(e);return this.right>=n.left&&n.right>=this.left&&this.bottom>=n.top&&n.bottom>=this.top}insidePoint(...e){let t=c.resolveArgs(e);return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}insideCircle(...e){let t=M.resolveArgs(e),n=c.resolve(t).add(t.radius),r=new c(this.width/2,this.height/2),i=new c(this.left+r.x,this.top+r.y),a=n.subtract(i),o=c.clamp(a,r.invert(),r);return a=i.add(o).subtract(n),a.length()<t.radius}},P=class t{width;height;get aspectRatio(){return this.height/this.width}get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Square`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,2)?new this(t[0],t[1]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let n=t.split(`x`).map(e=>parseFloat(e));if((0,e.isFixedTypeArray)(n,e.isValidNumber,2))return this.cast(n)}if((0,e.isValidNumber)(t))return new this(t,t);if((0,e.isFixedTypeArray)(t,e.isValidNumber,2))return new this(t[0],t[1]);if((0,e.hasTypedProperty)(t,`toSize`,`function`))return this.cast(t.toSize());if((0,e.hasTypedProperty)(t,`width`,`number`)&&(0,e.hasTypedProperty)(t,`height`,`number`))return new this(t.width,t.height)}}static is(e){return this.cast(e)!==void 0}constructor(t,n){(0,e.checkValidNumber)(t),(0,e.checkValidNumber)(n),this.width=t,this.height=n}toArray(){return[this.width,this.height]}toString(){return`${this.width}x${this.height}`}get[Symbol.toStringTag](){return`Size`}[e.NodeJSCustomInspect](){return`Size <${this.toString()}>`}toJSON(){return{width:this.width,height:this.height}}clone(){return new t(this.width,this.height)}equals(...e){let n=t.resolveArgs(e);return this.width==n.width&&this.height==n.height}toVec2(){return[this.width,this.height]}},F=class t{position;size;get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}get width(){return this.size.width}set width(e){this.size.width=e}get height(){return this.size.height}set height(e){this.size.height=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Rectangle`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?new this([t[0],t[1]],[t[2],t[3]]):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let[e,n]=t.split(`|`),r=c.cast(e),i=P.cast(n);if(r===void 0||i===void 0)return;let a=new this([r.x,r.y],[i.width,i.height]);return a.w=r.w,a}if((0,e.isFixedTypeArray)(t,e.isValidNumber,4))return new this([t[0],t[1]],[t[2],t[3]]);if((0,e.isFixedTypeArray)(t,e.isValidNumber,5)){let e=new this([t[0],t[1]],[t[3],t[4]]);return e.w=t[2],e}if((0,e.hasTypedProperty)(t,`toRectangle`,`function`))return this.cast(t.toRectangle());if((0,e.hasTypedProperty)(t,`x`,`number`)&&(0,e.hasTypedProperty)(t,`y`,`number`)&&(0,e.hasTypedProperty)(t,`width`,`number`)&&(0,e.hasTypedProperty)(t,`height`,`number`)){let n=new this([t.x,t.y],[t.width,t.height]);return(0,e.hasTypedProperty)(t,`w`,`number`)&&(n.w=t.w),n}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){this.position=c.resolve(e),this.size=P.resolve(t)}toArray(e=this.w!==1){return[...this.position.toArray(e),...this.size.toArray()]}toString(e=this.w!==1){return`${this.position.toString(e)}|${this.size.toString()}`}get[Symbol.toStringTag](){return`Rectangle`}[e.NodeJSCustomInspect](){return`Rectangle <${this.toString()}>`}toJSON(){return{...this.position.toJSON(),...this.size.toJSON()}}toBoundingBox(){return[this.x,this.x+this.width,this.y,this.y+this.height]}toVec2(){return[this.x,this.y,this.w]}toSize(){return[this.width,this.height]}clone(){return new t(this.position.clone(),this.size.clone())}equals(...e){let n=t.resolveArgs(e);return this.position.equals(n.position)&&this.size.equals(n.size)}},I=class{constructor(e,t,n){this.A=e,this.B=t,this.C=n}get alpha(){return Math.acos((this.b*this.b+this.c*this.c-this.a*this.a)/(2*this.b*this.c))}get beta(){return Math.acos((this.c*this.c+this.a*this.a-this.b*this.b)/(2*this.c*this.a))}get gamma(){return Math.acos((this.a*this.a+this.b*this.b-this.c*this.c)/(2*this.a*this.b))}get perimeter(){return this.a+this.b+this.c}get semiperimeter(){return this.perimeter/2}get area(){return Math.sqrt(this.semiperimeter*(this.semiperimeter-this.a)*(this.semiperimeter-this.b)*(this.semiperimeter-this.c))}get base(){return 2*(this.area/(this.a*Math.sin(this.gamma)))}get height(){return 2*(this.area/this.base)}toString(){return`${this.A}|${this.B}|${this.C}`}get[Symbol.toStringTag](){return`Triangle`}[e.NodeJSCustomInspect](){return`Triangle <${this.toString()}>`}},L=class extends I{get a(){return c.fromPoints(this.B,this.C).length()}get b(){return c.fromPoints(this.A,this.C).length()}get c(){return c.fromPoints(this.A,this.B).length()}},R=class extends I{get a(){return d.fromPoints(this.B,this.C).length()}get b(){return d.fromPoints(this.A,this.C).length()}get c(){return d.fromPoints(this.A,this.B).length()}},z=class t{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m10(){return this._raw[3]}set m10(e){this._raw[3]=e}get m11(){return this._raw[4]}set m11(e){this._raw[4]=e}get m12(){return this._raw[5]}set m12(e){this._raw[5]=e}get m20(){return this._raw[6]}set m20(e){this._raw[6]=e}get m21(){return this._raw[7]}set m21(e){this._raw[7]=e}get m22(){return this._raw[8]}set m22(e){this._raw[8]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Mat3`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,9)?new this(t):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let n=t.split(`,`);if((0,e.isFixedTypeArray)(n,e.isValidString,9))return this.cast(n.map(e=>parseFloat(e)))}if((0,e.isValidNumber)(t))return new this([t,t,t,t,t,t,t,t,t]);if((0,e.isFixedTypeArray)(t,e.isValidNumber,9))return new this(t);if((0,e.isFixedArray)(t,3)){let n=t[0],r=t[1],i=t[2];if((0,e.isFixedTypeArray)(n,e.isValidNumber,3)&&(0,e.isFixedTypeArray)(r,e.isValidNumber,3)&&(0,e.isFixedTypeArray)(i,e.isValidNumber,3))return new this([n[0],n[1],n[2],r[0],r[1],r[2],i[0],i[1],i[2]])}if((0,e.hasTypedProperty)(t,`toMat3`,`function`))return this.cast(t.toMat3());if((0,e.hasTypedProperty)(t,`m00`,`number`)&&(0,e.hasTypedProperty)(t,`m01`,`number`)&&(0,e.hasTypedProperty)(t,`m02`,`number`)&&(0,e.hasTypedProperty)(t,`m10`,`number`)&&(0,e.hasTypedProperty)(t,`m11`,`number`)&&(0,e.hasTypedProperty)(t,`m12`,`number`)&&(0,e.hasTypedProperty)(t,`m20`,`number`)&&(0,e.hasTypedProperty)(t,`m21`,`number`)&&(0,e.hasTypedProperty)(t,`m22`,`number`))return new this([t.m00,t.m01,t.m02,t.m10,t.m11,t.m12,t.m20,t.m21,t.m22])}}static is(e){return this.cast(e)!==void 0}static projection(e,t){return new this([2/e,0,0,0,-2/t,0,-1,1,1])}constructor(t=[1,0,0,0,1,0,0,0,1]){(0,e.checkFixedTypeArray)(t,e.isValidNumber,9),this._raw=t}toArray(){return[this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22]}toNestetArray(){return[[this.m00,this.m01,this.m02],[this.m10,this.m11,this.m12],[this.m20,this.m21,this.m22]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m10:this.m10,m11:this.m11,m12:this.m12,m20:this.m20,m21:this.m21,m22:this.m22}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`}get[Symbol.toStringTag](){return`Mat3`}[e.NodeJSCustomInspect](){return`Mat3 <${this.toString()}>`}clone(){return new t([this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22])}equals(...e){let n=t.resolveArgs(e);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1))return new t([this.m00*n[0],this.m01*n[0],this.m02*n[0],this.m10*n[0],this.m11*n[0],this.m12*n[0],this.m20*n[0],this.m21*n[0],this.m22*n[0]]);let r=t.resolveArgs(n);return new t([r.m00*this.m00+r.m01*this.m10+r.m02*this.m20,r.m00*this.m01+r.m01*this.m11+r.m02*this.m21,r.m00*this.m02+r.m01*this.m12+r.m02*this.m22,r.m10*this.m00+r.m11*this.m10+r.m12*this.m20,r.m10*this.m01+r.m11*this.m11+r.m12*this.m21,r.m10*this.m02+r.m11*this.m12+r.m12*this.m22,r.m20*this.m00+r.m21*this.m10+r.m22*this.m20,r.m20*this.m01+r.m21*this.m11+r.m22*this.m21,r.m20*this.m02+r.m21*this.m12+r.m22*this.m22])}translate(...e){let t=c.resolveArgs(e);return this.multiply([1,0,0,0,1,0,t.x,t.y,1])}rotate(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,-n,0,n,t,0,0,0,1])}scale(...e){let t=c.resolve(e);return this.multiply([t.x,0,0,0,t.y,0,0,0,1])}determinant(){return this.m00*this.m11*this.m22-this.m21*this.m12-this.m01*this.m10*this.m22-this.m12*this.m20+this.m02*this.m10*this.m21-this.m11*this.m20}inverse(){let e=this.determinant();return new t([(this.m11*this.m22-this.m21*this.m12)*e,(this.m02*this.m21-this.m01*this.m22)*e,(this.m01*this.m12-this.m02*this.m11)*e,(this.m12*this.m20-this.m10*this.m22)*e,(this.m00*this.m22-this.m02*this.m20)*e,(this.m10*this.m02-this.m00*this.m12)*e,(this.m10*this.m21-this.m20*this.m11)*e,(this.m20*this.m01-this.m00*this.m21)*e,(this.m00*this.m11-this.m10*this.m01)*e])}toMat4(){return[this.m00,this.m01,this.m02,0,this.m10,this.m11,this.m12,0,this.m20,this.m20,this.m22,0,0,0,0,1]}},B=class t{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m03(){return this._raw[3]}set m03(e){this._raw[3]=e}get m10(){return this._raw[4]}set m10(e){this._raw[4]=e}get m11(){return this._raw[5]}set m11(e){this._raw[5]=e}get m12(){return this._raw[6]}set m12(e){this._raw[6]=e}get m13(){return this._raw[7]}set m13(e){this._raw[7]=e}get m20(){return this._raw[8]}set m20(e){this._raw[8]=e}get m21(){return this._raw[9]}set m21(e){this._raw[9]=e}get m22(){return this._raw[10]}set m22(e){this._raw[10]=e}get m23(){return this._raw[11]}set m23(e){this._raw[11]=e}get m30(){return this._raw[12]}set m30(e){this._raw[12]=e}get m31(){return this._raw[13]}set m31(e){this._raw[13]=e}get m32(){return this._raw[14]}set m32(e){this._raw[14]=e}get m33(){return this._raw[15]}set m33(e){this._raw[15]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new r(`Mat4`,e)}static resolveArgs(t){return(0,e.isFixedTypeArray)(t,e.isValidNumber,16)?new this(t):this.resolve(t[0])}static cast(t){if(!(t==null||t===void 0)){if((0,e.isValidString)(t)){let n=t.split(`,`);if((0,e.isFixedTypeArray)(n,e.isValidString,16))return this.cast(n.map(e=>parseFloat(e)))}if((0,e.isValidNumber)(t))return new this([t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t]);if((0,e.isFixedTypeArray)(t,e.isValidNumber,16))return new this(t);if((0,e.isFixedArray)(t,4)){let n=t[0],r=t[1],i=t[2],a=t[3];if((0,e.isFixedTypeArray)(n,e.isValidNumber,4)&&(0,e.isFixedTypeArray)(r,e.isValidNumber,4)&&(0,e.isFixedTypeArray)(i,e.isValidNumber,4)&&(0,e.isFixedTypeArray)(a,e.isValidNumber,4))return new this([n[0],n[1],n[2],n[3],r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3],a[0],a[1],a[2],a[3]])}if((0,e.hasTypedProperty)(t,`toMat4`,`function`))return this.cast(t.toMat4());if((0,e.hasTypedProperty)(t,`m00`,`number`)&&(0,e.hasTypedProperty)(t,`m01`,`number`)&&(0,e.hasTypedProperty)(t,`m02`,`number`)&&(0,e.hasTypedProperty)(t,`m03`,`number`)&&(0,e.hasTypedProperty)(t,`m10`,`number`)&&(0,e.hasTypedProperty)(t,`m11`,`number`)&&(0,e.hasTypedProperty)(t,`m12`,`number`)&&(0,e.hasTypedProperty)(t,`m13`,`number`)&&(0,e.hasTypedProperty)(t,`m20`,`number`)&&(0,e.hasTypedProperty)(t,`m21`,`number`)&&(0,e.hasTypedProperty)(t,`m22`,`number`)&&(0,e.hasTypedProperty)(t,`m23`,`number`)&&(0,e.hasTypedProperty)(t,`m30`,`number`)&&(0,e.hasTypedProperty)(t,`m31`,`number`)&&(0,e.hasTypedProperty)(t,`m32`,`number`)&&(0,e.hasTypedProperty)(t,`m33`,`number`))return new this([t.m00,t.m01,t.m02,t.m03,t.m10,t.m11,t.m12,t.m13,t.m20,t.m21,t.m22,t.m23,t.m30,t.m31,t.m32,t.m33])}}static is(e){return this.cast(e)!==void 0}static orthographic(...t){let n=(0,e.isFixedTypeArray)(t,e.isValidNumber,6)?new N(t[0],t[1],t[2],t[3]):N.resolve(t[0]),r=(0,e.isFixedTypeArray)(t,e.isValidNumber,6)?t[4]:t[1],i=(0,e.isFixedTypeArray)(t,e.isValidNumber,6)?t[5]:t[2];return new this([2/(n.right-n.left),0,0,0,0,2/(n.top-n.bottom),0,0,0,0,2/(r-i),0,(n.left+n.right)/(n.left-n.right),(n.bottom+n.top)/(n.bottom-n.top),(r+i)/(r-i),1])}static perspective(e,t,n,r){let i=Math.tan(Math.PI*.5-.5*e),a=1/(n-r);return new this([i/t,0,0,0,0,i,0,0,0,0,(n+r)*a,-1,0,0,n*r*a*2,0])}static pointAt(e,t,n){let r=d.resolve(t).subtract(e).normalize(),i=r.multiply(d.resolve(n).dot(r)),a=d.resolve(n).subtract(i).normalize(),o=a.cross(r),s=d.resolve(e);return new this([o.x,o.y,o.z,0,a.x,a.y,a.z,0,r.x,r.y,r.z,0,s.x,s.y,s.z,1])}constructor(t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]){(0,e.checkFixedTypeArray)(t,e.isValidNumber,16),this._raw=t}toArray(){return[this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33]}toNestetArray(){return[[this.m00,this.m01,this.m02,this.m03],[this.m10,this.m11,this.m12,this.m13],[this.m20,this.m21,this.m22,this.m23],[this.m30,this.m31,this.m32,this.m33]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m03:this.m03,m10:this.m10,m11:this.m11,m12:this.m12,m13:this.m13,m20:this.m20,m21:this.m21,m22:this.m22,m23:this.m23,m30:this.m20,m31:this.m21,m32:this.m22,m33:this.m23}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`}get[Symbol.toStringTag](){return`Mat4`}[e.NodeJSCustomInspect](){return`Mat4 <${this.toString()}>`}clone(){return new t([this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33])}equals(...e){let n=t.resolveArgs(e);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...e){let n=t.resolveArgs(e),r=new t;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...n){if((0,e.isFixedTypeArray)(n,e.isValidNumber,1)){let e=n[0];return new t([this.m00*e,this.m01*e,this.m02*e,this.m03*e,this.m10*e,this.m11*e,this.m12*e,this.m13*e,this.m20*e,this.m21*e,this.m22*e,this.m23*e,this.m30*e,this.m31*e,this.m32*e,this.m33*e])}let r=d.cast(n[0]);if(r!==void 0){let e=new d(r.x*this.m00+r.y*this.m10+r.z*this.m20+this.m30,r.x*this.m01+r.y*this.m11+r.z*this.m21+this.m31,r.x*this.m02+r.y*this.m12+r.z*this.m22+this.m32,r.x*this.m03+r.y*this.m13+r.z*this.m23+this.m33);return e.w==0?e:e.divide(e.w)}let i=t.resolveArgs(n);return new t([i.m00*this.m00+i.m01*this.m10+i.m02*this.m20+i.m03*this.m30,i.m00*this.m01+i.m01*this.m11+i.m02*this.m21+i.m03*this.m31,i.m00*this.m02+i.m01*this.m12+i.m02*this.m22+i.m03*this.m32,i.m00*this.m03+i.m01*this.m13+i.m02*this.m23+i.m03*this.m33,i.m10*this.m00+i.m11*this.m10+i.m12*this.m20+i.m13*this.m30,i.m10*this.m01+i.m11*this.m11+i.m12*this.m21+i.m13*this.m31,i.m10*this.m02+i.m11*this.m12+i.m12*this.m22+i.m13*this.m32,i.m10*this.m03+i.m11*this.m13+i.m12*this.m23+i.m13*this.m33,i.m20*this.m00+i.m21*this.m10+i.m22*this.m20+i.m23*this.m30,i.m20*this.m01+i.m21*this.m11+i.m22*this.m21+i.m23*this.m31,i.m20*this.m02+i.m21*this.m12+i.m22*this.m22+i.m23*this.m32,i.m20*this.m03+i.m21*this.m13+i.m22*this.m23+i.m23*this.m33,i.m30*this.m00+i.m31*this.m10+i.m32*this.m20+i.m33*this.m30,i.m30*this.m01+i.m31*this.m11+i.m32*this.m21+i.m33*this.m31,i.m30*this.m02+i.m31*this.m12+i.m32*this.m22+i.m33*this.m32,i.m30*this.m03+i.m31*this.m13+i.m32*this.m23+i.m33*this.m33])}translate(...e){let t=d.resolveArgs(e);return this.multiply([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}rotateX(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([1,0,0,0,0,t,n,0,0,-n,t,0,0,0,0,1])}rotateY(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,0,-n,0,0,1,0,0,n,0,t,0,0,0,0,1])}rotateZ(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,n,0,0,-n,t,0,0,0,0,1,0,0,0,0,1])}rotate(...e){let t=d.resolveArgs(e);return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z)}scale(...e){let t=d.resolveArgs(e);return this.multiply([t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1])}inverse(){return new t([this.m00,this.m10,this.m20,0,this.m01,this.m11,this.m21,0,this.m02,this.m12,this.m22,0,-(this.m30*this.m00+this.m31*this.m10+this.m32*this.m20),-(this.m30*this.m01+this.m31*this.m11+this.m32*this.m21),-(this.m30*this.m02+this.m31*this.m12+this.m32*this.m22),1])}toMat3(){return[this.m00,this.m01,this.m03,this.m10,this.m11,this.m13,this.m30,this.m31,this.m33]}};let V;(function(t){function n(e,t=!1){let n=[];try{let t=b.resolve(e);n.push(t)}catch{}try{let t=x.resolve(e);n.push(t)}catch{}let r=t?1:0,i=n[r];if(i)return i;let a=n[r+1];if(a)return a}t.cast=n;function i(e,t=!1){let i=n(e,t);if(i!==void 0)return i;throw new r(`Color`,e)}t.resolve=i;function a(t,n=!1){return(0,e.isFixedTypeArray)(t,e.isValidNumber,3)||(0,e.isFixedTypeArray)(t,e.isValidNumber,4)?i(t,n):i(t[0],n)}t.resolveArgs=a})(V||={});var H=class{origin=c.zero;localPosition;localRotation;get localRotationDegree(){return A(this.localRotation)}set localRotationDegree(e){this.localRotation=j(e)}localScale;get globalPosition(){let e=c.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=0,t=this;for(;t!==void 0;)e+=t.localRotation,t=t.parent;return e}get globalRotationDegree(){return A(this.globalRotation)}get globalScale(){let e=c.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(t,n,r,i){this.parent=i,(0,e.checkValidNumber)(n),this.localPosition=c.resolve(t),this.localRotation=n,this.localScale=c.resolve(r)}toString(){return`${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[e.NodeJSCustomInspect](){return`Transform2D <${this.toString()}>`}toMat3(){return new z().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition)}toGlobalMat3(){let e=new z,t=this;for(;t!==void 0;)e=e.multiply(t.toMat3()),t=t.parent;return e}},U=class{origin=d.zero;localPosition;localRotation;localScale;get globalPosition(){let e=d.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=f.zero,t=this;for(;t!==void 0;)e=e.add(t.localRotation),t=t.parent;return e}get globalScale(){let e=d.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,r){this.parent=r,this.localPosition=d.resolve(e),this.localRotation=f.resolve(t),this.localScale=d.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[e.NodeJSCustomInspect](){return`Transform2D <${this.toString()}>`}toMat4(){return new B().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition)}toGlobalMat4(){let e=new B,t=this;for(;t!==void 0;)e=e.multiply(t.toMat4()),t=t.parent;return e}};Object.defineProperty(exports,`AnyColor`,{enumerable:!0,get:function(){return V}}),exports.BoundingBox=N,exports.Circle=M,exports.DJB2_OFFSET=S,exports.EPSILON=o,exports.FNV1_OFFSET=w,exports.FNV1_PRIME=T,exports.HSLA=x,exports.LinearFunction=l,exports.MAX_ANGLE_DEGREE=360,exports.Mat3=z,exports.Mat4=B,exports.MathFunction=t,exports.QuadFunction=u,exports.Quaternion=f,exports.RGBA=b,exports.Rectangle=F,exports.ResolveError=r,exports.Size=P,exports.Transform2D=H,exports.Transform3D=U,exports.Triangle=I,exports.Triangle2D=L,exports.Triangle3D=R,exports.Vec2=c,exports.Vec3=d,exports.clamp=i,exports.clampAngleDegree=O,exports.clampAngleRadian=k,exports.degreeToRadian=j,exports.djb2=C,exports.fnv1=E,exports.hasHexNumberAlpha=_,exports.hexNumberToRGB=v,exports.hexNumberToRGBA=y,exports.isHexNumber=h,exports.lerp=s,exports.logHypot=a,exports.numberToRGB=p,exports.numberToRGBA=m,exports.radianToDegree=A,exports.sdbm=D,exports.signCharacter=n;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ExpectedTypeError as e,NodeJSCustomInspect as t,checkFixedTypeArray as n,checkValidNumber as r,hasTypedProperty as i,isFixedArray as a,isFixedTypeArray as o,isValidNumber as s,isValidString as c}from"@ntf/types";var l=class{};function u(e){if(e!=0){if(e<0)return`-`;if(e>0)return`+`}}var d=class extends Error{constructor(e,t){super(`Can't resolve ${t} to ${e}`),this.target=e,this.value=t}};function f(e,t,n){return e<=t?t:e>=n?n:e}function p(e,t){let n=Math.abs(e),r=Math.abs(t);if(e==0)return Math.log(r);if(t==0)return Math.log(n);if(n<3e3&&r<3e3)return .5*Math.log(e*e+t*t);let i=e/2,a=t/2;return .5*Math.log(i*i+a*a)+Math.LN2}const m=1e-16,h=(e,t,n)=>((typeof e==`number`?1:1n)-n)*e+n*t;var g=class e{x;y;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Vec2`,e)}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,2)||o(e,s,3))return new this(e[0],e[1],e[2]);if(i(e,`toVec2`,`function`))return this.cast(e.toVec2());if(i(e,`x`,`number`)&&i(e,`y`,`number`))return new this(e.x,e.y,i(e,`w`,`number`)?e.w:void 0);if(c(e)){let[t,n]=e.split(`;`);if(c(t)){let e=t.split(`,`);if(o(e,c,2))return new this(parseFloat(e[0]),parseFloat(e[1]),c(n)?parseFloat(n):void 0)}}if(s(e))return new this(e,e)}}static resolveArgs(e){return o(e,s,2)?new this(e[0],e[1]):this.resolve(e[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y)}static clamp(e,t,n){let r=this.resolve(e),i=this.resolve(t),a=this.resolve(n);return new this(f(r.x,i.x,a.x),f(r.y,i.y,a.y))}static get zero(){return new this(0,0)}static get one(){return new this(1,1)}constructor(e,t,n=1){r(e),r(t),r(n),this.x=e,this.y=t,this.w=n}toArray(e=this.w!==1){return e?[this.x,this.y,this.w]:[this.x,this.y]}toJSON(){return{x:this.x,y:this.y,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y};${this.w}`:`${this.x},${this.y}`}get[Symbol.toStringTag](){return`Vec2`}[t](){return`Vec2 <${this.toString()}>`}toSize(){return[this.x,this.y]}toVec3(e=0){return[this.x,this.y,e,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.w]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.w,1]}toHSL(){let e=this.normalize();return[e.x,e.y,e.w]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.w,1]}clone(){return new e(this.x,this.y,this.w)}equals(...t){let n=e.resolveArgs(t);return this.x==n.x&&this.y==n.y}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setW(e){return this.w=e,this}set(...t){let n=e.resolveArgs(t);return this.setX(n.x).setY(n.y)}add(...t){let n=e.resolveArgs(t);return new e(this.x+n.x,this.y+n.y)}offset(...t){let n=e.resolveArgs(t);return this.x+=n.x,this.y+=n.y,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.x-n.x,this.y-n.y)}multiply(t){return new e(this.x*t,this.y*t)}naiveMultiply(...t){let n=e.resolveArgs(t);return new e(this.x*n.x,this.y*n.y)}divide(...t){if(o(t,s,1))return new e(this.x/t[0],this.y/t[0]);let n=e.resolveArgs(t);return new e(this.x/n.x,this.y/n.y)}dot(...t){let n=e.resolveArgs(t);return this.x*n.x+this.y*n.y}distance(...t){let n=e.resolveArgs(t);return(n.x-this.x)**2+(n.y-this.y)**2}distanceSquare(...t){let n=e.resolveArgs(t);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}cartesianify(){return new e(this.x*Math.cos(this.y),this.x*Math.sin(this.y))}polarify(){return new e(Math.sqrt(this.x*this.x+this.y*this.y),Math.atan(this.y/this.x))}normalize(){let t=this.length();return t==0?e.zero:new e(this.x/t,this.y/t,this.w/t)}invert(){return this.multiply(-1)}round(){return new e(Math.round(this.x),Math.round(this.y),Math.round(this.w))}},_=class extends l{m;b;static fromPoints(e,t){let n=g.resolve(e),r=g.resolve(t),i=(r.y-n.y)/(r.x-n.x),a=-i*n.x+n.y;return new this(i,a)}constructor(e,t){super(),r(e),r(t),this.m=e,this.b=t}get(e){return r(e),this.m*e+this.b}roots(){let e=-this.b/this.m;return isNaN(e)?[]:[new g(e,0)]}toString(){let e=u(this.b);return e?`f(x) = ${this.m} * x ${e} ${Math.abs(this.b)}`:`f(x) = ${this.m} * x`}get[Symbol.toStringTag](){return`LinearFunction`}[t](){return`LinearFunction <${this.toString()}>`}},v=class extends l{a;b;c;static get(e,t,n,r){return new this(e,t,n).get(r)}constructor(t,n,i){if(super(),r(t),t===0)throw new e(`non-zero valid number`,t);r(n),r(i),this.a=t,this.b=n,this.c=i}get(e){return r(e),this.a*e*e+this.b*e+this.c}roots(){let e=[],t=this.b*this.b-4*this.a*this.c,n=(-this.b+Math.sqrt(t))/(2*this.a),r=(-this.b+Math.sqrt(t))/(2*this.a);return isNaN(n)||e.push(new g(n,0)),!isNaN(r)&&n!=r&&e.push(new g(r,0)),e}toString(e=`standard`){switch(e){default:case`standard`:{let e=u(this.b),t=u(this.c);return e&&t?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x ${t} ${Math.abs(this.c)}`:e?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x`:`f(x) = ${this.a}x^2`}}}get[Symbol.toStringTag](){return`QuadFunction`}[t](){return`QuadFunction <${this.toString()}>`}},y=class e{x;y;z;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Vec3`,e)}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`z`,`number`))return new this(e.x,e.y,e.z,i(e,`w`,`number`)?e.w:void 0);if(c(e)){let[t,n]=e.split(`;`);if(c(t)){let e=t.split(`,`);if(o(e,c,3))return new this(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),c(n)?parseFloat(n):void 0)}}if(s(e))return new this(e,e,e)}}static resolveArgs(e){return o(e,s,3)?new this(e[0],e[1],e[2]):this.resolve(e[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y,r.z-n.z)}static clamp(e,t,n){let r=this.resolve(e),i=this.resolve(t),a=this.resolve(n);return new this(f(r.x,i.x,a.x),f(r.y,i.y,a.y),f(r.z,i.z,a.z))}static intersectPlane(t,n,r,i,a){n=this.resolve(n).normalize();let o=-this.resolve(n).dot(t),s=this.resolve(r).dot(n),c=this.resolve(i).dot(n);a=(-o-s)/(c-s);let l=this.resolve(i).subtract(r).multiply(a);return e.resolve(r).add(l)}static get zero(){return new this(0,0,0)}static get one(){return new this(1,1,1)}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this.x=e,this.y=t,this.z=n,this.w=i}toArray(e=this.w!==1){return e?[this.x,this.y,this.z,this.w]:[this.x,this.y,this.z]}toJSON(){return{x:this.x,y:this.y,z:this.z,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y},${this.z};${this.w}`:`${this.x},${this.y},${this.z}`}get[Symbol.toStringTag](){return`Vec3`}[t](){return`Vec3 <${this.toString()}>`}toVec2(){return[this.x,this.y,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.z]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toHSL(){let e=this.normalize();return[e.x,e.y,e.z]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toQuaternion(){return[this.w,this.x,this.y,this.z]}clone(){return new e(this.x,this.y,this.z,this.w)}equals(...t){let n=e.resolveArgs(t);return this.x==n.x&&this.y==n.y&&this.z==n.z}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}set(...t){let n=e.resolveArgs(t);return this.setX(n.x).setY(n.y).setZ(n.z)}add(...t){let n=e.resolveArgs(t);return new e(this.x+n.x,this.y+n.y,this.z+n.z)}offset(...t){let n=e.resolveArgs(t);return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(t){return new e(this.x*t,this.y*t,this.z*t)}naiveMultiply(...t){let n=e.resolveArgs(t);return new e(this.x*n.x,this.y*n.y,this.z*n.z)}divide(...t){if(o(t,s,1))return new e(this.x/t[0],this.y/t[0],this.z/t[0]);let n=e.resolveArgs(t);return new e(this.x/n.x,this.y/n.y,this.z/n.z)}dot(...t){let n=e.resolveArgs(t);return this.x*n.x+this.y*n.y+this.z*n.z}cross(...t){let n=e.resolveArgs(t);return new e(this.y*n.z-this.z*n.y,this.z*n.x-this.x*n.z,this.x*n.y-this.y*n.x)}distance(...t){let n=e.resolveArgs(t);return(n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2}distanceSquare(...t){let n=e.resolveArgs(t);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let t=this.length();return t==0?e.zero:new e(this.x/t,this.y/t,this.z/t,this.w/t)}invert(){return this.multiply(-1)}round(){return new e(Math.round(this.x),Math.round(this.y),Math.round(this.z),Math.round(this.w))}},b=class e{w;x;y;z;static is(e){return this.cast(e)!==void 0}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Quaternion`,e)}static resolveArgs(e){return o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toQuaternion`,`function`))return this.cast(e.toQuaternion());if(i(e,`w`,`number`)&&i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`z`,`number`))return new this(e.w,e.x,e.y,e.z);if(c(e)){let t=e.replaceAll(` `,``).split(`+`);if(o(t,c,4)){let[e,n,r,i]=t;if(e&&n?.endsWith(`i`)&&r?.endsWith(`j`)&&i?.endsWith(`k`))return this.cast([parseFloat(e),parseFloat(n.substring(0,n.length-1)),parseFloat(r.substring(0,r.length-1)),parseFloat(i.substring(0,i.length-1))])}}}}static fromAxisAngle(...e){let t=o(e,s,4)?new y(e[0],e[1],e[2]):y.resolve(e[0]),n=o(e,s,4)?e[3]:e[1],r=y.resolve(t),i=n*.5,a=Math.sin(i),c=Math.cos(i),l=a/Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return new this(c,r.x*l,r.y*l,r.z*l)}static fromEuler(...t){let n=y.resolveArgs(t),r=n.x*.5,i=n.y*.5,a=n.z*.5,o=Math.cos(r),s=Math.cos(i),c=Math.cos(a),l=Math.sin(r),u=Math.sin(i),d=Math.sin(a);return new e(o*s*c-l*u*d,l*s*c-u*d*o,u*o*c-l*d*s,l*u*c+d*o*s)}static get zero(){return new e(0,0,0,0)}constructor(e,t,n,i){r(e),r(t),r(n),r(i),this.w=e,this.x=t,this.y=n,this.z=i}toArray(){return[this.w,this.x,this.y,this.z]}toString(){return`${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`}get[Symbol.toStringTag](){return`Quaternion`}[t](){return`Quaternion <${this.toString()}>`}toJSON(){return{w:this.w,x:this.x,y:this.y,z:this.z}}clone(){return new e(this.w,this.x,this.y,this.z)}add(...t){let n=e.resolveArgs(t);return new e(this.w+n.w,this.x+n.x,this.y+n.y,this.z+n.z)}offset(...t){let n=e.resolveArgs(t);return this.w+=n.w,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.w-n.w,this.x-n.x,this.y-n.y,this.z-n.z)}negative(){return new e(-this.w,-this.x,-this.y,-this.z)}length(e=!0){let t=this.w*this.w+this.x*this.x+this.y*this.y+this.z*this.z;return e?Math.sqrt(t):t}normalize(){let t=this.length();return t<m?e.zero:(t=1/t,new e(this.w*t,this.x*t,this.y*t,this.z*t))}multiply(...t){let n=e.resolveArgs(t);return new e(this.w*n.w-this.x*n.x-this.y*n.y-this.z*n.z,this.w*n.x+this.x*n.w+this.y*n.z-this.z*n.y,this.w*n.y+this.y*n.w+this.z*n.x-this.x*n.z,this.w*n.z+this.z*n.w+this.x*n.y-this.y*n.x)}multiplyVector(...e){let t=y.resolveArgs(e),n=this.w*t.x+this.y*t.y-this.z*t.y,r=this.w*t.y+this.z*t.x-this.x*t.z,i=this.w*t.z+this.x*t.y-this.y*t.x,a=-this.w*t.x-this.y*t.y-this.z*t.z;return new y(n*this.w+a*-this.x+r*-this.z-i*-this.y,r*this.w+a*-this.y+i*-this.x-n*-this.z,i*this.w+a*-this.z+n*-this.y-r*-this.x)}scale(t){return new e(this.w*t,this.x*t,this.y*t,this.z*t)}dot(...t){let n=e.resolveArgs(t);return this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z}inverse(){let t=this.length(!1);return t==0?e.zero:(t=1/t,new e(this.w*t,-this.x*t,-this.y*t,-this.z*t))}divide(...t){let n=e.resolveArgs(t),r=n.length(!1);return r==0?e.zero:(r=1/r,new e((this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z)*r,(this.x*n.w-this.w*n.x-this.y*n.z+this.z*n.y)*r,(this.y*n.w-this.w*n.y-this.z*n.x+this.x*n.z)*r,(this.z*n.w-this.w*n.z-this.x*n.y+this.y*n.x)*r))}conjugate(){return new e(this.w,-this.x,-this.y,-this.z)}exp(){let t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),n=Math.exp(this.w),r=n*Math.sin(t)/t;return t==0?new e(n,0,0,0):new e(n*Math.cos(t),this.x*r,this.y*r,this.z*r)}log(){if(this.x==0&&this.z==0)return new e(p(this.w,this.x),Math.atan2(this.x,this.w),0,0);let t=this.length(!1),n=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),r=Math.atan2(n,this.w)/t;return new e(Math.log(t)*.5,this.x*r,this.y*r,this.z*r)}toVec3(){return[this.x,this.y,this.z,this.w]}toAxisAngle(){let e=1-this.w*this.w;if(e>m)return new y(this.x,this.y,this.z,0);let t=1/Math.sqrt(e),n=2*Math.acos(this.w);return new y(this.x*t,this.y*t,this.z*t,n)}toEuler(){function e(e){return e>=1?Math.PI/2:e<=-1?-Math.PI/2:Math.asin(e)}return new y(-Math.atan2(2*(this.y*this.z-this.w*this.x),1-2*(this.x*this.x+this.y*this.y)),e(2*(this.x*this.z+this.w*this.y)),-Math.atan2(2*(this.x*this.y-this.w*this.z),1-2*(this.y*this.y+this.z*this.z)))}toMat3(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y)]}toMat4(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),0,2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),0,2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y),0,0,0,0,1]}};function x(e){let t=e<4096,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8;return[(t?(e&3840)>>>8:(e&16711680)>>>16)/255,r/255,n/255]}function S(e){let t=e<65536,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8,i=t?(e&3840)>>>8:(e&16711680)>>>16;return[(t?(e&61440)>>>12:(e&4278190080)>>>24)/255,i/255,r/255,n/255]}function C(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)||e.startsWith(`0x`)}function w(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)?e.substring(1):e.startsWith(`0x`)?e.substring(2):e}function T(e){let t=w(e);return[4,8].includes(t.length)}function E(e){let t=w(e),n=t.length===3,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16);return[r/255,i/255,a/255]}function D(e){let t=w(e),n=t.length===4,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16),o=parseInt(n?t[3]:t.substring(6,8),16);return[r/255,i/255,a/255,o/255]}var O=class e{_red;get red(){return this._red}set red(e){this._red=f(e,0,1)}_green;get green(){return this._green}set green(e){this._green=f(e,0,1)}_blue;get blue(){return this._blue}set blue(e){this._blue=f(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=f(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`RGBAColor`,e)}static resolveArgs(e){return o(e,s,3)||o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toRGB`,`function`))return this.cast(e.toRGB());if(i(e,`toRGBA`,`function`))return this.cast(e.toRGBA());if(i(e,`red`,`number`)&&i(e,`green`,`number`)&&i(e,`blue`,`number`))return new this(e.red,e.green,e.blue,i(e,`alpha`,`number`)?e.alpha:void 0);if(s(e)){let t=e.toString(16).length<=6?x:S;return this.cast(t(e))}if(c(e)){if(e.startsWith(`rgb`)){let t=e.startsWith(`rgba`),n=t?5:4,r=e.substring(n,e.indexOf(`)`,n)).split(`,`);if(o(r,c,t?4:3))return this.cast(r.map(e=>parseInt(e)/255))}if(C(e)){let t=T(e)?D:E;return this.cast(t(e))}}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this._red=f(e,0,1),this._green=f(t,0,1),this._blue=f(n,0,1),this._alpha=f(i,0,1)}toArray(e=this._alpha!==1){return e?[this.red,this.green,this.blue,this.alpha]:[this.red,this.green,this.blue]}toJSON(e=this._alpha!==1){return e?{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}:{red:this.red,green:this.green,blue:this.blue}}toString(e=this._alpha!==1){return e?`rgba(${f(this.red*255|0,0,255)},${f(this.green*255|0,0,255)},${f(this.blue*255|0,0,255)},${this.alpha})`:`rgb(${f(this.red*255|0,0,255)},${f(this.green*255|0,0,255)},${f(this.blue*255|0,0,255)})`}get[Symbol.toStringTag](){return`RGBA`}[t](){return`RGBA <${this.toString()}>`}toVec2(){return[this.red,this.green,this.blue]}toVec3(){return[this.red,this.green,this.blue,this.alpha]}toHSL(e=this._alpha!==1){let t=this.red,n=this.green,r=this.blue,i=Math.min(t,n,r),a=Math.max(t,n,r),o=(i+a)/2;if(i==a)return new k(0,0,o,e?this.alpha:void 0);let s=a-i,c=o>.5?s/(2-a-i):s/(a+i);return a==t?new k(((n-r)/s+(n<r?6:0))/6,c,o,e?this.alpha:void 0):a==n?new k(((r-t)/s+2)/6,c,o,e?this.alpha:void 0):a==r?new k(((t-n)/s+4)/6,c,o,e?this.alpha:void 0):new k(0,c,o,e?this.alpha:void 0)}toHSLA(){return this.toHSL(!0)}invert(t=this._alpha!==1){return new e(1-this.red,1-this.green,1-this.blue,t?1-this.alpha:this.alpha)}},k=class e{_hue;get hue(){return this._hue}set hue(e){this._hue=f(e,0,1)}_saturation;get saturation(){return this._saturation}set saturation(e){this._saturation=f(e,0,1)}_luminace;get luminace(){return this._luminace}set luminace(e){this._luminace=f(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=f(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`HSLColor`,e)}static resolveArgs(e){return o(e,s,3)||o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toHSL`,`function`))return this.cast(e.toHSL());if(i(e,`toHSLA`,`function`))return this.cast(e.toHSLA());if(i(e,`hue`,`number`)&&i(e,`saturation`,`number`)&&i(e,`luminace`,`number`))return new this(e.hue,e.saturation,e.luminace,i(e,`alpha`,`number`)?e.alpha:void 0);if(s(e)){let t=e.toString(16).length<=6?x:S;return this.cast(t(e))}if(c(e)){if(e.startsWith(`hsl`)){let t=e.startsWith(`hsla`),n=t?5:4,r=e.substring(n,e.indexOf(`)`,n)).split(`,`);if(o(r,c,t?4:3))return this.cast(r.map(e=>parseInt(e)/255))}if(C(e)){let t=T(e)?D:E;return this.cast(t(e))}}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this._hue=f(e,0,1),this._saturation=f(t,0,1),this._luminace=f(n,0,1),this._alpha=f(i,0,1)}toArray(e=this._alpha!==1){return e?[this.hue,this.saturation,this.luminace,this.alpha]:[this.hue,this.saturation,this.luminace]}toJSON(e=this._alpha!==1){return e?{hue:this.hue,saturation:this.saturation,luminace:this.luminace,alpha:this.alpha}:{hue:this.hue,saturation:this.saturation,luminace:this.luminace}}toString(e=this._alpha!==1){return e?`hsla(${f(this.hue*255|0,0,255)},${f(this.saturation*255|0,0,255)},${f(this.luminace*255|0,0,255)},${this.alpha})`:`hsl(${f(this.hue*255|0,0,255)},${f(this.saturation*255|0,0,255)},${f(this.luminace*255|0,0,255)})`}get[Symbol.toStringTag](){return`HSLA`}[t](){return`HSLA <${this.toString()}>`}toRGB(e=this._alpha!==1){if(this.saturation==0)return new O(this.luminace*255,this.luminace*255,this.luminace*255,e?this.alpha:void 0);let t=this.luminace<.5?this.luminace*(1+this.saturation):this.luminace+this.saturation-this.luminace*this.saturation,n=2*this.luminace-t;function r(e){let r=e;return r<0&&r++,r>1&&r--,r<1/6?n+(t-n)*6*r:r<1/2?t:r<2/3?n+(t-n)*(2/3-r)*6:n}return new O(r(this.hue+1/3)*255,r(this.hue)*255,r(this.hue-1/3)*255,e?this.alpha:void 0)}toRGBA(){return this.toRGB(!0)}toVec2(){return[this.hue,this.saturation,this.luminace]}toVec3(){return[this.hue,this.saturation,this.luminace,this.alpha]}invert(t=this._alpha!==1){return new e(1-this.hue,1-this.saturation,1-this.luminace,t?1-this.alpha:this.alpha)}};const A=5381n;function j(e){let t=String(e),n=A;for(let e=0;e<t.length;e++)n=(n<<5n)+n+BigInt(t.charCodeAt(e));return n}const M=14695981039346656037n,N=1099511628211n;function P(e){let t=String(e),n=M;for(let e=0;e<t.length;e++)n*=N,n^=BigInt(t.charCodeAt(e));return n}function F(e){let t=String(e),n=0n;for(let e=0;e<t.length;e++)n=BigInt(t.charCodeAt(e))+(n<<6n)+(n<<16n)-n;return n}const I=360,L=e=>e%360,R=e=>L(B(e)),z=e=>e*(180/Math.PI),B=e=>e*(Math.PI/180);var V=class e{radius;get perimeter(){return this.radius*Math.PI*2}get area(){return Math.PI*this.radius**2}position;get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Circle`,e)}static resolveArgs(e){return o(e,s,3)?new this([e[0],e[1]],e[2]):e.length===2?new this(e[0],e[1]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3))return new this([e[0],e[1]],e[2]);if(o(e,s,4)){let t=new this([e[0],e[1]],e[3]);return t.w=e[2],t}if(i(e,`toCircle`,`function`))return this.cast(e.toCircle());if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`radius`,`number`))return new this(i(e,`w`,`number`)?[e.x,e.y,e.w]:[e.x,e.y],e.radius);if(c(e)){let[t,n]=e.split(`|`),r=g.cast(t);if(r===void 0||n===void 0)return;let i=parseFloat(n);if(!isNaN(i))return new this(r,i)}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){r(t),this.position=g.resolve(e),this.radius=t}toArray(){return[...this.position.toArray(),this.radius]}toJSON(){return{...this.position.toJSON(),radius:this.radius}}toString(){return`${this.position.toString()}|${this.radius}`}get[Symbol.toStringTag](){return`Circle`}[t](){return`Circle <${this.toString()}>`}clone(){return new e(this.position.clone(),this.radius)}toVec2(){return[this.x,this.y,this.w]}equals(...t){let n=e.resolveArgs(t);return n.position.equals(n.position)&&this.radius==n.radius}inside(...t){let n=e.resolveArgs(t),r=n.x-this.x,i=n.y-this.y;return Math.sqrt(r*r+(i+i))<=this.radius+n.radius}insidePoint(...e){return this.position.distance(g.resolveArgs(e))<=this.radius}},H=class e{left;right;top;bottom;get width(){return this.right-this.left}set width(e){this.right=this.left+e}get height(){return this.bottom-this.top}set height(e){this.bottom=this.top+e}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}w=1;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`BoundingBox`,e)}static resolveArgs(e){return o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toBoundingBox`,`function`))return this.cast(e.toBoundingBox());if(i(e,`left`,`number`)&&i(e,`right`,`number`)&&i(e,`top`,`number`)&&i(e,`bottom`,`number`))return new this(e.left,e.right,e.top,e.bottom);if(c(e)){let t=e.split(`,`);if(o(t,c,4))return this.cast(t.map(e=>parseFloat(e)))}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i){r(e),r(t),r(n),r(i),this.left=e,this.right=t,this.top=n,this.bottom=i}toArray(){return[this.left,this.right,this.top,this.bottom]}toString(){return`${this.left},${this.right},${this.top},${this.bottom}`}get[Symbol.toStringTag](){return`BoundingBox`}[t](){return`BoundingBox <${this.toString()}>`}toJSON(){return{left:this.left,top:this.top,right:this.right,bottom:this.bottom}}clone(){return new e(this.left,this.right,this.top,this.bottom)}equals(...t){let n=e.resolveArgs(t);return this.left===n.left&&this.right===n.right&&this.top===n.top&&this.bottom===n.bottom}toSize(){return[this.width,this.height]}toVec2(){return[this.left,this.top]}toRectangle(){return[this.left,this.top,this.width,this.height]}inside(...t){let n=e.resolve(t);return this.right>=n.left&&n.right>=this.left&&this.bottom>=n.top&&n.bottom>=this.top}insidePoint(...e){let t=g.resolveArgs(e);return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}insideCircle(...e){let t=V.resolveArgs(e),n=g.resolve(t).add(t.radius),r=new g(this.width/2,this.height/2),i=new g(this.left+r.x,this.top+r.y),a=n.subtract(i),o=g.clamp(a,r.invert(),r);return a=i.add(o).subtract(n),a.length()<t.radius}},U=class e{width;height;get aspectRatio(){return this.height/this.width}get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Square`,e)}static resolveArgs(e){return o(e,s,2)?new this(e[0],e[1]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,2))return new this(e[0],e[1]);if(i(e,`toSize`,`function`))return this.cast(e.toSize());if(i(e,`width`,`number`)&&i(e,`height`,`number`))return new this(e.width,e.height);if(c(e)){let t=e.split(`x`).map(e=>parseFloat(e));if(o(t,s,2))return this.cast(t)}if(s(e))return new this(e,e)}}static is(e){return this.cast(e)!==void 0}constructor(e,t){r(e),r(t),this.width=e,this.height=t}toArray(){return[this.width,this.height]}toString(){return`${this.width}x${this.height}`}get[Symbol.toStringTag](){return`Size`}[t](){return`Size <${this.toString()}>`}toJSON(){return{width:this.width,height:this.height}}clone(){return new e(this.width,this.height)}equals(...t){let n=e.resolveArgs(t);return this.width==n.width&&this.height==n.height}toVec2(){return[this.width,this.height]}},W=class e{position;size;get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}get width(){return this.size.width}set width(e){this.size.width=e}get height(){return this.size.height}set height(e){this.size.height=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Rectangle`,e)}static resolveArgs(e){return o(e,s,4)?new this([e[0],e[1]],[e[2],e[3]]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,4))return new this([e[0],e[1]],[e[2],e[3]]);if(o(e,s,5)){let t=new this([e[0],e[1]],[e[3],e[4]]);return t.w=e[2],t}if(c(e)){let[t,n]=e.split(`|`),r=g.cast(t),i=U.cast(n);if(r===void 0||i===void 0)return;let a=new this([r.x,r.y],[i.width,i.height]);return a.w=r.w,a}if(i(e,`toRectangle`,`function`))return this.cast(e.toRectangle());if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`width`,`number`)&&i(e,`height`,`number`)){let t=new this([e.x,e.y],[e.width,e.height]);return i(e,`w`,`number`)&&(t.w=e.w),t}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){this.position=g.resolve(e),this.size=U.resolve(t)}toArray(e=this.w!==1){return[...this.position.toArray(e),...this.size.toArray()]}toString(e=this.w!==1){return`${this.position.toString(e)}|${this.size.toString()}`}get[Symbol.toStringTag](){return`Rectangle`}[t](){return`Rectangle <${this.toString()}>`}toJSON(){return{...this.position.toJSON(),...this.size.toJSON()}}toBoundingBox(){return[this.x,this.x+this.width,this.y,this.y+this.height]}toVec2(){return[this.x,this.y,this.w]}toSize(){return[this.width,this.height]}clone(){return new e(this.position.clone(),this.size.clone())}equals(...t){let n=e.resolveArgs(t);return this.position.equals(n.position)&&this.size.equals(n.size)}},G=class{constructor(e,t,n){this.A=e,this.B=t,this.C=n}get alpha(){return Math.acos((this.b*this.b+this.c*this.c-this.a*this.a)/(2*this.b*this.c))}get beta(){return Math.acos((this.c*this.c+this.a*this.a-this.b*this.b)/(2*this.c*this.a))}get gamma(){return Math.acos((this.a*this.a+this.b*this.b-this.c*this.c)/(2*this.a*this.b))}get perimeter(){return this.a+this.b+this.c}get semiperimeter(){return this.perimeter/2}get area(){return Math.sqrt(this.semiperimeter*(this.semiperimeter-this.a)*(this.semiperimeter-this.b)*(this.semiperimeter-this.c))}get base(){return 2*(this.area/(this.a*Math.sin(this.gamma)))}get height(){return 2*(this.area/this.base)}toString(){return`${this.A}|${this.B}|${this.C}`}get[Symbol.toStringTag](){return`Triangle`}[t](){return`Triangle <${this.toString()}>`}},K=class extends G{get a(){return g.fromPoints(this.B,this.C).length()}get b(){return g.fromPoints(this.A,this.C).length()}get c(){return g.fromPoints(this.A,this.B).length()}},q=class extends G{get a(){return y.fromPoints(this.B,this.C).length()}get b(){return y.fromPoints(this.A,this.C).length()}get c(){return y.fromPoints(this.A,this.B).length()}},J=class e{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m10(){return this._raw[3]}set m10(e){this._raw[3]=e}get m11(){return this._raw[4]}set m11(e){this._raw[4]=e}get m12(){return this._raw[5]}set m12(e){this._raw[5]=e}get m20(){return this._raw[6]}set m20(e){this._raw[6]=e}get m21(){return this._raw[7]}set m21(e){this._raw[7]=e}get m22(){return this._raw[8]}set m22(e){this._raw[8]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Mat3`,e)}static resolveArgs(e){return o(e,s,9)?new this(e):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,9))return new this(e);if(a(e,3)){let t=e[0],n=e[1],r=e[2];if(o(t,s,3)&&o(n,s,3)&&o(r,s,3))return new this([t[0],t[1],t[2],n[0],n[1],n[2],r[0],r[1],r[2]])}if(c(e)){let t=e.split(`,`);if(o(t,c,9))return this.cast(t.map(e=>parseFloat(e)))}if(i(e,`toMat3`,`function`))return this.cast(e.toMat3());if(i(e,`m00`,`number`)&&i(e,`m01`,`number`)&&i(e,`m02`,`number`)&&i(e,`m10`,`number`)&&i(e,`m11`,`number`)&&i(e,`m12`,`number`)&&i(e,`m20`,`number`)&&i(e,`m21`,`number`)&&i(e,`m22`,`number`))return new this([e.m00,e.m01,e.m02,e.m10,e.m11,e.m12,e.m20,e.m21,e.m22]);if(s(e))return new this([e,e,e,e,e,e,e,e,e])}}static is(e){return this.cast(e)!==void 0}static projection(e,t){return new this([2/e,0,0,0,-2/t,0,-1,1,1])}constructor(e=[1,0,0,0,1,0,0,0,1]){n(e,s,9),this._raw=e}toArray(){return[this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22]}toNestetArray(){return[[this.m00,this.m01,this.m02],[this.m10,this.m11,this.m12],[this.m20,this.m21,this.m22]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m10:this.m10,m11:this.m11,m12:this.m12,m20:this.m20,m21:this.m21,m22:this.m22}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`}get[Symbol.toStringTag](){return`Mat3`}[t](){return`Mat3 <${this.toString()}>`}clone(){return new e([this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22])}equals(...t){let n=e.resolveArgs(t);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...t){if(o(t,s,1))return new e([this.m00*t[0],this.m01*t[0],this.m02*t[0],this.m10*t[0],this.m11*t[0],this.m12*t[0],this.m20*t[0],this.m21*t[0],this.m22*t[0]]);let n=e.resolveArgs(t);return new e([n.m00*this.m00+n.m01*this.m10+n.m02*this.m20,n.m00*this.m01+n.m01*this.m11+n.m02*this.m21,n.m00*this.m02+n.m01*this.m12+n.m02*this.m22,n.m10*this.m00+n.m11*this.m10+n.m12*this.m20,n.m10*this.m01+n.m11*this.m11+n.m12*this.m21,n.m10*this.m02+n.m11*this.m12+n.m12*this.m22,n.m20*this.m00+n.m21*this.m10+n.m22*this.m20,n.m20*this.m01+n.m21*this.m11+n.m22*this.m21,n.m20*this.m02+n.m21*this.m12+n.m22*this.m22])}translate(...e){let t=g.resolveArgs(e);return this.multiply([1,0,0,0,1,0,t.x,t.y,1])}rotate(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,-n,0,n,t,0,0,0,1])}scale(...e){let t=g.resolve(e);return this.multiply([t.x,0,0,0,t.y,0,0,0,1])}determinant(){return this.m00*this.m11*this.m22-this.m21*this.m12-this.m01*this.m10*this.m22-this.m12*this.m20+this.m02*this.m10*this.m21-this.m11*this.m20}inverse(){let t=this.determinant();return new e([(this.m11*this.m22-this.m21*this.m12)*t,(this.m02*this.m21-this.m01*this.m22)*t,(this.m01*this.m12-this.m02*this.m11)*t,(this.m12*this.m20-this.m10*this.m22)*t,(this.m00*this.m22-this.m02*this.m20)*t,(this.m10*this.m02-this.m00*this.m12)*t,(this.m10*this.m21-this.m20*this.m11)*t,(this.m20*this.m01-this.m00*this.m21)*t,(this.m00*this.m11-this.m10*this.m01)*t])}toMat4(){return[this.m00,this.m01,this.m02,0,this.m10,this.m11,this.m12,0,this.m20,this.m20,this.m22,0,0,0,0,1]}},Y=class e{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m03(){return this._raw[3]}set m03(e){this._raw[3]=e}get m10(){return this._raw[4]}set m10(e){this._raw[4]=e}get m11(){return this._raw[5]}set m11(e){this._raw[5]=e}get m12(){return this._raw[6]}set m12(e){this._raw[6]=e}get m13(){return this._raw[7]}set m13(e){this._raw[7]=e}get m20(){return this._raw[8]}set m20(e){this._raw[8]=e}get m21(){return this._raw[9]}set m21(e){this._raw[9]=e}get m22(){return this._raw[10]}set m22(e){this._raw[10]=e}get m23(){return this._raw[11]}set m23(e){this._raw[11]=e}get m30(){return this._raw[12]}set m30(e){this._raw[12]=e}get m31(){return this._raw[13]}set m31(e){this._raw[13]=e}get m32(){return this._raw[14]}set m32(e){this._raw[14]=e}get m33(){return this._raw[15]}set m33(e){this._raw[15]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Mat4`,e)}static resolveArgs(e){return o(e,s,16)?new this(e):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,16))return new this(e);if(a(e,4)){let t=e[0],n=e[1],r=e[2],i=e[3];if(o(t,s,4)&&o(n,s,4)&&o(r,s,4)&&o(i,s,4))return new this([t[0],t[1],t[2],t[3],n[0],n[1],n[2],n[3],r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3]])}if(c(e)){let t=e.split(`,`);if(o(t,c,16))return this.cast(t.map(e=>parseFloat(e)))}if(i(e,`toMat4`,`function`))return this.cast(e.toMat4());if(i(e,`m00`,`number`)&&i(e,`m01`,`number`)&&i(e,`m02`,`number`)&&i(e,`m03`,`number`)&&i(e,`m10`,`number`)&&i(e,`m11`,`number`)&&i(e,`m12`,`number`)&&i(e,`m13`,`number`)&&i(e,`m20`,`number`)&&i(e,`m21`,`number`)&&i(e,`m22`,`number`)&&i(e,`m23`,`number`)&&i(e,`m30`,`number`)&&i(e,`m31`,`number`)&&i(e,`m32`,`number`)&&i(e,`m33`,`number`))return new this([e.m00,e.m01,e.m02,e.m03,e.m10,e.m11,e.m12,e.m13,e.m20,e.m21,e.m22,e.m23,e.m30,e.m31,e.m32,e.m33]);if(s(e))return new this([e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e])}}static is(e){return this.cast(e)!==void 0}static orthographic(...e){let t=o(e,s,6)?new H(e[0],e[1],e[2],e[3]):H.resolve(e[0]),n=o(e,s,6)?e[4]:e[1],r=o(e,s,6)?e[5]:e[2];return new this([2/(t.right-t.left),0,0,0,0,2/(t.top-t.bottom),0,0,0,0,2/(n-r),0,(t.left+t.right)/(t.left-t.right),(t.bottom+t.top)/(t.bottom-t.top),(n+r)/(n-r),1])}static perspective(e,t,n,r){let i=Math.tan(Math.PI*.5-.5*e),a=1/(n-r);return new this([i/t,0,0,0,0,i,0,0,0,0,(n+r)*a,-1,0,0,n*r*a*2,0])}static pointAt(e,t,n){let r=y.resolve(t).subtract(e).normalize(),i=r.multiply(y.resolve(n).dot(r)),a=y.resolve(n).subtract(i).normalize(),o=a.cross(r),s=y.resolve(e);return new this([o.x,o.y,o.z,0,a.x,a.y,a.z,0,r.x,r.y,r.z,0,s.x,s.y,s.z,1])}constructor(e=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]){n(e,s,16),this._raw=e}toArray(){return[this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33]}toNestetArray(){return[[this.m00,this.m01,this.m02,this.m03],[this.m10,this.m11,this.m12,this.m13],[this.m20,this.m21,this.m22,this.m23],[this.m30,this.m31,this.m32,this.m33]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m03:this.m03,m10:this.m10,m11:this.m11,m12:this.m12,m13:this.m13,m20:this.m20,m21:this.m21,m22:this.m22,m23:this.m23,m30:this.m20,m31:this.m21,m32:this.m22,m33:this.m23}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`}get[Symbol.toStringTag](){return`Mat4`}[t](){return`Mat4 <${this.toString()}>`}clone(){return new e([this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33])}equals(...t){let n=e.resolveArgs(t);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...t){if(o(t,s,1)){let n=t[0];return new e([this.m00*n,this.m01*n,this.m02*n,this.m03*n,this.m10*n,this.m11*n,this.m12*n,this.m13*n,this.m20*n,this.m21*n,this.m22*n,this.m23*n,this.m30*n,this.m31*n,this.m32*n,this.m33*n])}let n=y.cast(t[0]);if(n!==void 0){let e=new y(n.x*this.m00+n.y*this.m10+n.z*this.m20+this.m30,n.x*this.m01+n.y*this.m11+n.z*this.m21+this.m31,n.x*this.m02+n.y*this.m12+n.z*this.m22+this.m32,n.x*this.m03+n.y*this.m13+n.z*this.m23+this.m33);return e.w==0?e:e.divide(e.w)}let r=e.resolveArgs(t);return new e([r.m00*this.m00+r.m01*this.m10+r.m02*this.m20+r.m03*this.m30,r.m00*this.m01+r.m01*this.m11+r.m02*this.m21+r.m03*this.m31,r.m00*this.m02+r.m01*this.m12+r.m02*this.m22+r.m03*this.m32,r.m00*this.m03+r.m01*this.m13+r.m02*this.m23+r.m03*this.m33,r.m10*this.m00+r.m11*this.m10+r.m12*this.m20+r.m13*this.m30,r.m10*this.m01+r.m11*this.m11+r.m12*this.m21+r.m13*this.m31,r.m10*this.m02+r.m11*this.m12+r.m12*this.m22+r.m13*this.m32,r.m10*this.m03+r.m11*this.m13+r.m12*this.m23+r.m13*this.m33,r.m20*this.m00+r.m21*this.m10+r.m22*this.m20+r.m23*this.m30,r.m20*this.m01+r.m21*this.m11+r.m22*this.m21+r.m23*this.m31,r.m20*this.m02+r.m21*this.m12+r.m22*this.m22+r.m23*this.m32,r.m20*this.m03+r.m21*this.m13+r.m22*this.m23+r.m23*this.m33,r.m30*this.m00+r.m31*this.m10+r.m32*this.m20+r.m33*this.m30,r.m30*this.m01+r.m31*this.m11+r.m32*this.m21+r.m33*this.m31,r.m30*this.m02+r.m31*this.m12+r.m32*this.m22+r.m33*this.m32,r.m30*this.m03+r.m31*this.m13+r.m32*this.m23+r.m33*this.m33])}translate(...e){let t=y.resolveArgs(e);return this.multiply([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}rotateX(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([1,0,0,0,0,t,n,0,0,-n,t,0,0,0,0,1])}rotateY(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,0,-n,0,0,1,0,0,n,0,t,0,0,0,0,1])}rotateZ(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,n,0,0,-n,t,0,0,0,0,1,0,0,0,0,1])}rotate(...e){let t=y.resolveArgs(e);return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z)}scale(...e){let t=y.resolveArgs(e);return this.multiply([t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1])}inverse(){return new e([this.m00,this.m10,this.m20,0,this.m01,this.m11,this.m21,0,this.m02,this.m12,this.m22,0,-(this.m30*this.m00+this.m31*this.m10+this.m32*this.m20),-(this.m30*this.m01+this.m31*this.m11+this.m32*this.m21),-(this.m30*this.m02+this.m31*this.m12+this.m32*this.m22),1])}toMat3(){return[this.m00,this.m01,this.m03,this.m10,this.m11,this.m13,this.m30,this.m31,this.m33]}};let X;(function(e){function t(e,t=!1){let n=[];try{let t=O.resolve(e);n.push(t)}catch{}try{let t=k.resolve(e);n.push(t)}catch{}let r=t?1:0,i=n[r];if(i)return i;let a=n[r+1];if(a)return a}e.cast=t;function n(e,n=!1){let r=t(e,n);if(r!==void 0)return r;throw new d(`Color`,e)}e.resolve=n;function r(e,t=!1){return o(e,s,3)||o(e,s,4)?n(e,t):n(e[0],t)}e.resolveArgs=r})(X||={});var Z=class{origin=g.zero;localPosition;localRotation;get localRotationDegree(){return z(this.localRotation)}set localRotationDegree(e){this.localRotation=B(e)}localScale;get globalPosition(){let e=g.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=0,t=this;for(;t!==void 0;)e+=t.localRotation,t=t.parent;return e}get globalRotationDegree(){return z(this.globalRotation)}get globalScale(){let e=g.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,i){this.parent=i,r(t),this.localPosition=g.resolve(e),this.localRotation=t,this.localScale=g.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[t](){return`Transform2D <${this.toString()}>`}toMat3(){return new J().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition)}toGlobalMat3(){let e=new J,t=this;for(;t!==void 0;)e=e.multiply(t.toMat3()),t=t.parent;return e}},Q=class{origin=y.zero;localPosition;localRotation;localScale;get globalPosition(){let e=y.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=b.zero,t=this;for(;t!==void 0;)e=e.add(t.localRotation),t=t.parent;return e}get globalScale(){let e=y.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,r){this.parent=r,this.localPosition=y.resolve(e),this.localRotation=b.resolve(t),this.localScale=y.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[t](){return`Transform2D <${this.toString()}>`}toMat4(){return new Y().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition)}toGlobalMat4(){let e=new Y,t=this;for(;t!==void 0;)e=e.multiply(t.toMat4()),t=t.parent;return e}};export{X as AnyColor,H as BoundingBox,V as Circle,A as DJB2_OFFSET,m as EPSILON,M as FNV1_OFFSET,N as FNV1_PRIME,k as HSLA,_ as LinearFunction,I as MAX_ANGLE_DEGREE,J as Mat3,Y as Mat4,l as MathFunction,v as QuadFunction,b as Quaternion,O as RGBA,W as Rectangle,d as ResolveError,U as Size,Z as Transform2D,Q as Transform3D,G as Triangle,K as Triangle2D,q as Triangle3D,g as Vec2,y as Vec3,f as clamp,L as clampAngleDegree,R as clampAngleRadian,B as degreeToRadian,j as djb2,P as fnv1,T as hasHexNumberAlpha,E as hexNumberToRGB,D as hexNumberToRGBA,C as isHexNumber,h as lerp,p as logHypot,x as numberToRGB,S as numberToRGBA,z as radianToDegree,F as sdbm,u as signCharacter};
|
|
1
|
+
import{ExpectedTypeError as e,NodeJSCustomInspect as t,checkFixedTypeArray as n,checkValidNumber as r,hasTypedProperty as i,isFixedArray as a,isFixedTypeArray as o,isValidNumber as s,isValidString as c}from"@ntf/types";var l=class{};function u(e){if(e!=0){if(e<0)return`-`;if(e>0)return`+`}}var d=class extends Error{constructor(e,t){super(`Can't resolve ${t} to ${e}`),this.target=e,this.value=t}};function f(e,t,n){return e<=t?t:e>=n?n:e}function p(e,t){let n=Math.abs(e),r=Math.abs(t);if(e==0)return Math.log(r);if(t==0)return Math.log(n);if(n<3e3&&r<3e3)return .5*Math.log(e*e+t*t);let i=e/2,a=t/2;return .5*Math.log(i*i+a*a)+Math.LN2}const m=1e-16,h=(e,t,n)=>((typeof e==`number`?1:1n)-n)*e+n*t;var g=class e{x;y;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Vec2`,e)}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let[t,n]=e.split(`;`);if(c(t)){let e=t.split(`,`);if(o(e,c,2))return new this(parseFloat(e[0]),parseFloat(e[1]),c(n)?parseFloat(n):void 0)}}if(s(e))return new this(e,e);if(o(e,s,2)||o(e,s,3))return new this(e[0],e[1],e[2]);if(i(e,`toVec2`,`function`))return this.cast(e.toVec2());if(i(e,`x`,`number`)&&i(e,`y`,`number`))return new this(e.x,e.y,i(e,`w`,`number`)?e.w:void 0)}}static resolveArgs(e){return o(e,s,2)?new this(e[0],e[1]):this.resolve(e[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y)}static clamp(e,t,n){let r=this.resolve(e),i=this.resolve(t),a=this.resolve(n);return new this(f(r.x,i.x,a.x),f(r.y,i.y,a.y))}static get zero(){return new this(0,0)}static get one(){return new this(1,1)}constructor(e,t,n=1){r(e),r(t),r(n),this.x=e,this.y=t,this.w=n}toArray(e=this.w!==1){return e?[this.x,this.y,this.w]:[this.x,this.y]}toJSON(){return{x:this.x,y:this.y,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y};${this.w}`:`${this.x},${this.y}`}get[Symbol.toStringTag](){return`Vec2`}[t](){return`Vec2 <${this.toString()}>`}toSize(){return[this.x,this.y]}toVec3(e=0){return[this.x,this.y,e,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.w]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.w,1]}toHSL(){let e=this.normalize();return[e.x,e.y,e.w]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.w,1]}clone(){return new e(this.x,this.y,this.w)}equals(...t){let n=e.resolveArgs(t);return this.x==n.x&&this.y==n.y}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setW(e){return this.w=e,this}set(...t){let n=e.resolveArgs(t);return this.setX(n.x).setY(n.y)}add(...t){let n=e.resolveArgs(t);return new e(this.x+n.x,this.y+n.y)}offset(...t){let n=e.resolveArgs(t);return this.x+=n.x,this.y+=n.y,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.x-n.x,this.y-n.y)}multiply(t){return new e(this.x*t,this.y*t)}naiveMultiply(...t){let n=e.resolveArgs(t);return new e(this.x*n.x,this.y*n.y)}divide(...t){if(o(t,s,1))return new e(this.x/t[0],this.y/t[0]);let n=e.resolveArgs(t);return new e(this.x/n.x,this.y/n.y)}dot(...t){let n=e.resolveArgs(t);return this.x*n.x+this.y*n.y}distance(...t){let n=e.resolveArgs(t);return(n.x-this.x)**2+(n.y-this.y)**2}distanceSquare(...t){let n=e.resolveArgs(t);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}cartesianify(){return new e(this.x*Math.cos(this.y),this.x*Math.sin(this.y))}polarify(){return new e(Math.sqrt(this.x*this.x+this.y*this.y),Math.atan(this.y/this.x))}normalize(){let t=this.length();return t==0?e.zero:new e(this.x/t,this.y/t,this.w/t)}invert(){return this.multiply(-1)}round(){return new e(Math.round(this.x),Math.round(this.y),Math.round(this.w))}},_=class extends l{m;b;static fromPoints(e,t){let n=g.resolve(e),r=g.resolve(t),i=(r.y-n.y)/(r.x-n.x),a=-i*n.x+n.y;return new this(i,a)}constructor(e,t){super(),r(e),r(t),this.m=e,this.b=t}get(e){return r(e),this.m*e+this.b}roots(){let e=-this.b/this.m;return isNaN(e)?[]:[new g(e,0)]}toString(){let e=u(this.b);return e?`f(x) = ${this.m} * x ${e} ${Math.abs(this.b)}`:`f(x) = ${this.m} * x`}get[Symbol.toStringTag](){return`LinearFunction`}[t](){return`LinearFunction <${this.toString()}>`}},v=class extends l{a;b;c;static get(e,t,n,r){return new this(e,t,n).get(r)}constructor(t,n,i){if(super(),r(t),t===0)throw new e(`non-zero valid number`,t);r(n),r(i),this.a=t,this.b=n,this.c=i}get(e){return r(e),this.a*e*e+this.b*e+this.c}roots(){let e=[],t=this.b*this.b-4*this.a*this.c,n=(-this.b+Math.sqrt(t))/(2*this.a),r=(-this.b+Math.sqrt(t))/(2*this.a);return isNaN(n)||e.push(new g(n,0)),!isNaN(r)&&n!=r&&e.push(new g(r,0)),e}toString(e=`standard`){switch(e){default:case`standard`:{let e=u(this.b),t=u(this.c);return e&&t?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x ${t} ${Math.abs(this.c)}`:e?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x`:`f(x) = ${this.a}x^2`}}}get[Symbol.toStringTag](){return`QuadFunction`}[t](){return`QuadFunction <${this.toString()}>`}},y=class e{x;y;z;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Vec3`,e)}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let[t,n]=e.split(`;`);if(c(t)){let e=t.split(`,`);if(o(e,c,3))return new this(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),c(n)?parseFloat(n):void 0)}}if(s(e))return new this(e,e,e);if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`z`,`number`))return new this(e.x,e.y,e.z,i(e,`w`,`number`)?e.w:void 0)}}static resolveArgs(e){return o(e,s,3)?new this(e[0],e[1],e[2]):this.resolve(e[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y,r.z-n.z)}static clamp(e,t,n){let r=this.resolve(e),i=this.resolve(t),a=this.resolve(n);return new this(f(r.x,i.x,a.x),f(r.y,i.y,a.y),f(r.z,i.z,a.z))}static intersectPlane(t,n,r,i,a){n=this.resolve(n).normalize();let o=-this.resolve(n).dot(t),s=this.resolve(r).dot(n),c=this.resolve(i).dot(n);a=(-o-s)/(c-s);let l=this.resolve(i).subtract(r).multiply(a);return e.resolve(r).add(l)}static get zero(){return new this(0,0,0)}static get one(){return new this(1,1,1)}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this.x=e,this.y=t,this.z=n,this.w=i}toArray(e=this.w!==1){return e?[this.x,this.y,this.z,this.w]:[this.x,this.y,this.z]}toJSON(){return{x:this.x,y:this.y,z:this.z,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y},${this.z};${this.w}`:`${this.x},${this.y},${this.z}`}get[Symbol.toStringTag](){return`Vec3`}[t](){return`Vec3 <${this.toString()}>`}toVec2(){return[this.x,this.y,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.z]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toHSL(){let e=this.normalize();return[e.x,e.y,e.z]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toQuaternion(){return[this.w,this.x,this.y,this.z]}clone(){return new e(this.x,this.y,this.z,this.w)}equals(...t){let n=e.resolveArgs(t);return this.x==n.x&&this.y==n.y&&this.z==n.z}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}set(...t){let n=e.resolveArgs(t);return this.setX(n.x).setY(n.y).setZ(n.z)}add(...t){let n=e.resolveArgs(t);return new e(this.x+n.x,this.y+n.y,this.z+n.z)}offset(...t){let n=e.resolveArgs(t);return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(t){return new e(this.x*t,this.y*t,this.z*t)}naiveMultiply(...t){let n=e.resolveArgs(t);return new e(this.x*n.x,this.y*n.y,this.z*n.z)}divide(...t){if(o(t,s,1))return new e(this.x/t[0],this.y/t[0],this.z/t[0]);let n=e.resolveArgs(t);return new e(this.x/n.x,this.y/n.y,this.z/n.z)}dot(...t){let n=e.resolveArgs(t);return this.x*n.x+this.y*n.y+this.z*n.z}cross(...t){let n=e.resolveArgs(t);return new e(this.y*n.z-this.z*n.y,this.z*n.x-this.x*n.z,this.x*n.y-this.y*n.x)}distance(...t){let n=e.resolveArgs(t);return(n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2}distanceSquare(...t){let n=e.resolveArgs(t);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let t=this.length();return t==0?e.zero:new e(this.x/t,this.y/t,this.z/t,this.w/t)}invert(){return this.multiply(-1)}round(){return new e(Math.round(this.x),Math.round(this.y),Math.round(this.z),Math.round(this.w))}},b=class e{w;x;y;z;static is(e){return this.cast(e)!==void 0}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Quaternion`,e)}static resolveArgs(e){return o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let t=e.replaceAll(` `,``).split(`+`);if(o(t,c,4)){let[e,n,r,i]=t;if(e&&n?.endsWith(`i`)&&r?.endsWith(`j`)&&i?.endsWith(`k`))return this.cast([parseFloat(e),parseFloat(n.substring(0,n.length-1)),parseFloat(r.substring(0,r.length-1)),parseFloat(i.substring(0,i.length-1))])}}if(s(e))return new this(e,e,e,e);if(o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toQuaternion`,`function`))return this.cast(e.toQuaternion());if(i(e,`w`,`number`)&&i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`z`,`number`))return new this(e.w,e.x,e.y,e.z)}}static fromAxisAngle(...e){let t=o(e,s,4)?new y(e[0],e[1],e[2]):y.resolve(e[0]),n=o(e,s,4)?e[3]:e[1],r=y.resolve(t),i=n*.5,a=Math.sin(i),c=Math.cos(i),l=a/Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return new this(c,r.x*l,r.y*l,r.z*l)}static fromEuler(...t){let n=y.resolveArgs(t),r=n.x*.5,i=n.y*.5,a=n.z*.5,o=Math.cos(r),s=Math.cos(i),c=Math.cos(a),l=Math.sin(r),u=Math.sin(i),d=Math.sin(a);return new e(o*s*c-l*u*d,l*s*c-u*d*o,u*o*c-l*d*s,l*u*c+d*o*s)}static get zero(){return new e(0,0,0,0)}constructor(e,t,n,i){r(e),r(t),r(n),r(i),this.w=e,this.x=t,this.y=n,this.z=i}toArray(){return[this.w,this.x,this.y,this.z]}toString(){return`${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`}get[Symbol.toStringTag](){return`Quaternion`}[t](){return`Quaternion <${this.toString()}>`}toJSON(){return{w:this.w,x:this.x,y:this.y,z:this.z}}clone(){return new e(this.w,this.x,this.y,this.z)}add(...t){let n=e.resolveArgs(t);return new e(this.w+n.w,this.x+n.x,this.y+n.y,this.z+n.z)}offset(...t){let n=e.resolveArgs(t);return this.w+=n.w,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.w-n.w,this.x-n.x,this.y-n.y,this.z-n.z)}negative(){return new e(-this.w,-this.x,-this.y,-this.z)}length(e=!0){let t=this.w*this.w+this.x*this.x+this.y*this.y+this.z*this.z;return e?Math.sqrt(t):t}normalize(){let t=this.length();return t<m?e.zero:(t=1/t,new e(this.w*t,this.x*t,this.y*t,this.z*t))}multiply(...t){let n=e.resolveArgs(t);return new e(this.w*n.w-this.x*n.x-this.y*n.y-this.z*n.z,this.w*n.x+this.x*n.w+this.y*n.z-this.z*n.y,this.w*n.y+this.y*n.w+this.z*n.x-this.x*n.z,this.w*n.z+this.z*n.w+this.x*n.y-this.y*n.x)}multiplyVector(...e){let t=y.resolveArgs(e),n=this.w*t.x+this.y*t.y-this.z*t.y,r=this.w*t.y+this.z*t.x-this.x*t.z,i=this.w*t.z+this.x*t.y-this.y*t.x,a=-this.w*t.x-this.y*t.y-this.z*t.z;return new y(n*this.w+a*-this.x+r*-this.z-i*-this.y,r*this.w+a*-this.y+i*-this.x-n*-this.z,i*this.w+a*-this.z+n*-this.y-r*-this.x)}scale(t){return new e(this.w*t,this.x*t,this.y*t,this.z*t)}dot(...t){let n=e.resolveArgs(t);return this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z}inverse(){let t=this.length(!1);return t==0?e.zero:(t=1/t,new e(this.w*t,-this.x*t,-this.y*t,-this.z*t))}divide(...t){let n=e.resolveArgs(t),r=n.length(!1);return r==0?e.zero:(r=1/r,new e((this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z)*r,(this.x*n.w-this.w*n.x-this.y*n.z+this.z*n.y)*r,(this.y*n.w-this.w*n.y-this.z*n.x+this.x*n.z)*r,(this.z*n.w-this.w*n.z-this.x*n.y+this.y*n.x)*r))}conjugate(){return new e(this.w,-this.x,-this.y,-this.z)}exp(){let t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),n=Math.exp(this.w),r=n*Math.sin(t)/t;return t==0?new e(n,0,0,0):new e(n*Math.cos(t),this.x*r,this.y*r,this.z*r)}log(){if(this.x==0&&this.z==0)return new e(p(this.w,this.x),Math.atan2(this.x,this.w),0,0);let t=this.length(!1),n=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),r=Math.atan2(n,this.w)/t;return new e(Math.log(t)*.5,this.x*r,this.y*r,this.z*r)}toVec3(){return[this.x,this.y,this.z,this.w]}toAxisAngle(){let e=1-this.w*this.w;if(e>m)return new y(this.x,this.y,this.z,0);let t=1/Math.sqrt(e),n=2*Math.acos(this.w);return new y(this.x*t,this.y*t,this.z*t,n)}toEuler(){function e(e){return e>=1?Math.PI/2:e<=-1?-Math.PI/2:Math.asin(e)}return new y(-Math.atan2(2*(this.y*this.z-this.w*this.x),1-2*(this.x*this.x+this.y*this.y)),e(2*(this.x*this.z+this.w*this.y)),-Math.atan2(2*(this.x*this.y-this.w*this.z),1-2*(this.y*this.y+this.z*this.z)))}toMat3(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y)]}toMat4(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),0,2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),0,2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y),0,0,0,0,1]}};function x(e){let t=e<4096,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8;return[(t?(e&3840)>>>8:(e&16711680)>>>16)/255,r/255,n/255]}function S(e){let t=e<65536,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8,i=t?(e&3840)>>>8:(e&16711680)>>>16;return[(t?(e&61440)>>>12:(e&4278190080)>>>24)/255,i/255,r/255,n/255]}function C(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)||e.startsWith(`0x`)}function w(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)?e.substring(1):e.startsWith(`0x`)?e.substring(2):e}function T(e){let t=w(e);return[4,8].includes(t.length)}function E(e){let t=w(e),n=t.length===3,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16);return[r/255,i/255,a/255]}function D(e){let t=w(e),n=t.length===4,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16),o=parseInt(n?t[3]:t.substring(6,8),16);return[r/255,i/255,a/255,o/255]}var O=class e{_red;get red(){return this._red}set red(e){this._red=f(e,0,1)}_green;get green(){return this._green}set green(e){this._green=f(e,0,1)}_blue;get blue(){return this._blue}set blue(e){this._blue=f(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=f(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`RGBAColor`,e)}static resolveArgs(e){return o(e,s,3)||o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toRGB`,`function`))return this.cast(e.toRGB());if(i(e,`toRGBA`,`function`))return this.cast(e.toRGBA());if(i(e,`red`,`number`)&&i(e,`green`,`number`)&&i(e,`blue`,`number`))return new this(e.red,e.green,e.blue,i(e,`alpha`,`number`)?e.alpha:void 0);if(s(e)){let t=e.toString(16).length<=6?x:S;return this.cast(t(e))}if(c(e)){if(e.startsWith(`rgb`)){let t=e.startsWith(`rgba`),n=t?5:4,r=e.substring(n,e.indexOf(`)`,n)).split(`,`);if(o(r,c,t?4:3))return this.cast(r.map(e=>parseInt(e)/255))}if(C(e)){let t=T(e)?D:E;return this.cast(t(e))}}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this._red=f(e,0,1),this._green=f(t,0,1),this._blue=f(n,0,1),this._alpha=f(i,0,1)}toArray(e=this._alpha!==1){return e?[this.red,this.green,this.blue,this.alpha]:[this.red,this.green,this.blue]}toJSON(e=this._alpha!==1){return e?{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}:{red:this.red,green:this.green,blue:this.blue}}toString(e=this._alpha!==1){return e?`rgba(${f(this.red*255|0,0,255)},${f(this.green*255|0,0,255)},${f(this.blue*255|0,0,255)},${this.alpha})`:`rgb(${f(this.red*255|0,0,255)},${f(this.green*255|0,0,255)},${f(this.blue*255|0,0,255)})`}get[Symbol.toStringTag](){return`RGBA`}[t](){return`RGBA <${this.toString()}>`}toVec2(){return[this.red,this.green,this.blue]}toVec3(){return[this.red,this.green,this.blue,this.alpha]}toHSL(e=this._alpha!==1){let t=this.red,n=this.green,r=this.blue,i=Math.min(t,n,r),a=Math.max(t,n,r),o=(i+a)/2;if(i==a)return new k(0,0,o,e?this.alpha:void 0);let s=a-i,c=o>.5?s/(2-a-i):s/(a+i);return a==t?new k(((n-r)/s+(n<r?6:0))/6,c,o,e?this.alpha:void 0):a==n?new k(((r-t)/s+2)/6,c,o,e?this.alpha:void 0):a==r?new k(((t-n)/s+4)/6,c,o,e?this.alpha:void 0):new k(0,c,o,e?this.alpha:void 0)}toHSLA(){return this.toHSL(!0)}invert(t=this._alpha!==1){return new e(1-this.red,1-this.green,1-this.blue,t?1-this.alpha:this.alpha)}},k=class e{_hue;get hue(){return this._hue}set hue(e){this._hue=f(e,0,1)}_saturation;get saturation(){return this._saturation}set saturation(e){this._saturation=f(e,0,1)}_luminace;get luminace(){return this._luminace}set luminace(e){this._luminace=f(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=f(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`HSLColor`,e)}static resolveArgs(e){return o(e,s,3)||o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toHSL`,`function`))return this.cast(e.toHSL());if(i(e,`toHSLA`,`function`))return this.cast(e.toHSLA());if(i(e,`hue`,`number`)&&i(e,`saturation`,`number`)&&i(e,`luminace`,`number`))return new this(e.hue,e.saturation,e.luminace,i(e,`alpha`,`number`)?e.alpha:void 0);if(s(e)){let t=e.toString(16).length<=6?x:S;return this.cast(t(e))}if(c(e)){if(e.startsWith(`hsl`)){let t=e.startsWith(`hsla`),n=t?5:4,r=e.substring(n,e.indexOf(`)`,n)).split(`,`);if(o(r,c,t?4:3))return this.cast(r.map(e=>parseInt(e)/255))}if(C(e)){let t=T(e)?D:E;return this.cast(t(e))}}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this._hue=f(e,0,1),this._saturation=f(t,0,1),this._luminace=f(n,0,1),this._alpha=f(i,0,1)}toArray(e=this._alpha!==1){return e?[this.hue,this.saturation,this.luminace,this.alpha]:[this.hue,this.saturation,this.luminace]}toJSON(e=this._alpha!==1){return e?{hue:this.hue,saturation:this.saturation,luminace:this.luminace,alpha:this.alpha}:{hue:this.hue,saturation:this.saturation,luminace:this.luminace}}toString(e=this._alpha!==1){return e?`hsla(${f(this.hue*255|0,0,255)},${f(this.saturation*255|0,0,255)},${f(this.luminace*255|0,0,255)},${this.alpha})`:`hsl(${f(this.hue*255|0,0,255)},${f(this.saturation*255|0,0,255)},${f(this.luminace*255|0,0,255)})`}get[Symbol.toStringTag](){return`HSLA`}[t](){return`HSLA <${this.toString()}>`}toRGB(e=this._alpha!==1){if(this.saturation==0)return new O(this.luminace*255,this.luminace*255,this.luminace*255,e?this.alpha:void 0);let t=this.luminace<.5?this.luminace*(1+this.saturation):this.luminace+this.saturation-this.luminace*this.saturation,n=2*this.luminace-t;function r(e){let r=e;return r<0&&r++,r>1&&r--,r<1/6?n+(t-n)*6*r:r<1/2?t:r<2/3?n+(t-n)*(2/3-r)*6:n}return new O(r(this.hue+1/3)*255,r(this.hue)*255,r(this.hue-1/3)*255,e?this.alpha:void 0)}toRGBA(){return this.toRGB(!0)}toVec2(){return[this.hue,this.saturation,this.luminace]}toVec3(){return[this.hue,this.saturation,this.luminace,this.alpha]}invert(t=this._alpha!==1){return new e(1-this.hue,1-this.saturation,1-this.luminace,t?1-this.alpha:this.alpha)}};const A=5381n;function j(e){let t=String(e),n=A;for(let e=0;e<t.length;e++)n=(n<<5n)+n+BigInt(t.charCodeAt(e));return n}const M=14695981039346656037n,N=1099511628211n;function P(e){let t=String(e),n=M;for(let e=0;e<t.length;e++)n*=N,n^=BigInt(t.charCodeAt(e));return n}function F(e){let t=String(e),n=0n;for(let e=0;e<t.length;e++)n=BigInt(t.charCodeAt(e))+(n<<6n)+(n<<16n)-n;return n}const I=360,L=e=>e%360,R=e=>L(B(e)),z=e=>e*(180/Math.PI),B=e=>e*(Math.PI/180);var V=class e{radius;get perimeter(){return this.radius*Math.PI*2}get area(){return Math.PI*this.radius**2}position;get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Circle`,e)}static resolveArgs(e){return o(e,s,3)?new this([e[0],e[1]],e[2]):e.length===2?new this(e[0],e[1]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let[t,n]=e.split(`|`),r=g.cast(t);if(r===void 0||n===void 0)return;let i=parseFloat(n);if(!isNaN(i))return new this(r,i)}if(o(e,s,3))return new this([e[0],e[1]],e[2]);if(o(e,s,4)){let t=new this([e[0],e[1]],e[3]);return t.w=e[2],t}if(i(e,`toCircle`,`function`))return this.cast(e.toCircle());if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`radius`,`number`))return new this(i(e,`w`,`number`)?[e.x,e.y,e.w]:[e.x,e.y],e.radius)}}static is(e){return this.cast(e)!==void 0}constructor(e,t){r(t),this.position=g.resolve(e),this.radius=t}toArray(){return[...this.position.toArray(),this.radius]}toJSON(){return{...this.position.toJSON(),radius:this.radius}}toString(){return`${this.position.toString()}|${this.radius}`}get[Symbol.toStringTag](){return`Circle`}[t](){return`Circle <${this.toString()}>`}clone(){return new e(this.position.clone(),this.radius)}toVec2(){return[this.x,this.y,this.w]}equals(...t){let n=e.resolveArgs(t);return n.position.equals(n.position)&&this.radius==n.radius}inside(...t){let n=e.resolveArgs(t),r=n.x-this.x,i=n.y-this.y;return Math.sqrt(r*r+(i+i))<=this.radius+n.radius}insidePoint(...e){return this.position.distance(g.resolveArgs(e))<=this.radius}},H=class e{left;right;top;bottom;get width(){return this.right-this.left}set width(e){this.right=this.left+e}get height(){return this.bottom-this.top}set height(e){this.bottom=this.top+e}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}w=1;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`BoundingBox`,e)}static resolveArgs(e){return o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let t=e.split(`,`);if(o(t,c,4))return this.cast(t.map(e=>parseFloat(e)))}if(s(e))return new this(e,e,e,e);if(o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toBoundingBox`,`function`))return this.cast(e.toBoundingBox());if(i(e,`left`,`number`)&&i(e,`right`,`number`)&&i(e,`top`,`number`)&&i(e,`bottom`,`number`))return new this(e.left,e.right,e.top,e.bottom)}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i){r(e),r(t),r(n),r(i),this.left=e,this.right=t,this.top=n,this.bottom=i}toArray(){return[this.left,this.right,this.top,this.bottom]}toString(){return`${this.left},${this.right},${this.top},${this.bottom}`}get[Symbol.toStringTag](){return`BoundingBox`}[t](){return`BoundingBox <${this.toString()}>`}toJSON(){return{left:this.left,top:this.top,right:this.right,bottom:this.bottom}}clone(){return new e(this.left,this.right,this.top,this.bottom)}equals(...t){let n=e.resolveArgs(t);return this.left===n.left&&this.right===n.right&&this.top===n.top&&this.bottom===n.bottom}toSize(){return[this.width,this.height]}toVec2(){return[this.left,this.top]}toRectangle(){return[this.left,this.top,this.width,this.height]}inside(...t){let n=e.resolve(t);return this.right>=n.left&&n.right>=this.left&&this.bottom>=n.top&&n.bottom>=this.top}insidePoint(...e){let t=g.resolveArgs(e);return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}insideCircle(...e){let t=V.resolveArgs(e),n=g.resolve(t).add(t.radius),r=new g(this.width/2,this.height/2),i=new g(this.left+r.x,this.top+r.y),a=n.subtract(i),o=g.clamp(a,r.invert(),r);return a=i.add(o).subtract(n),a.length()<t.radius}},U=class e{width;height;get aspectRatio(){return this.height/this.width}get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Square`,e)}static resolveArgs(e){return o(e,s,2)?new this(e[0],e[1]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let t=e.split(`x`).map(e=>parseFloat(e));if(o(t,s,2))return this.cast(t)}if(s(e))return new this(e,e);if(o(e,s,2))return new this(e[0],e[1]);if(i(e,`toSize`,`function`))return this.cast(e.toSize());if(i(e,`width`,`number`)&&i(e,`height`,`number`))return new this(e.width,e.height)}}static is(e){return this.cast(e)!==void 0}constructor(e,t){r(e),r(t),this.width=e,this.height=t}toArray(){return[this.width,this.height]}toString(){return`${this.width}x${this.height}`}get[Symbol.toStringTag](){return`Size`}[t](){return`Size <${this.toString()}>`}toJSON(){return{width:this.width,height:this.height}}clone(){return new e(this.width,this.height)}equals(...t){let n=e.resolveArgs(t);return this.width==n.width&&this.height==n.height}toVec2(){return[this.width,this.height]}},W=class e{position;size;get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}get width(){return this.size.width}set width(e){this.size.width=e}get height(){return this.size.height}set height(e){this.size.height=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Rectangle`,e)}static resolveArgs(e){return o(e,s,4)?new this([e[0],e[1]],[e[2],e[3]]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let[t,n]=e.split(`|`),r=g.cast(t),i=U.cast(n);if(r===void 0||i===void 0)return;let a=new this([r.x,r.y],[i.width,i.height]);return a.w=r.w,a}if(o(e,s,4))return new this([e[0],e[1]],[e[2],e[3]]);if(o(e,s,5)){let t=new this([e[0],e[1]],[e[3],e[4]]);return t.w=e[2],t}if(i(e,`toRectangle`,`function`))return this.cast(e.toRectangle());if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`width`,`number`)&&i(e,`height`,`number`)){let t=new this([e.x,e.y],[e.width,e.height]);return i(e,`w`,`number`)&&(t.w=e.w),t}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){this.position=g.resolve(e),this.size=U.resolve(t)}toArray(e=this.w!==1){return[...this.position.toArray(e),...this.size.toArray()]}toString(e=this.w!==1){return`${this.position.toString(e)}|${this.size.toString()}`}get[Symbol.toStringTag](){return`Rectangle`}[t](){return`Rectangle <${this.toString()}>`}toJSON(){return{...this.position.toJSON(),...this.size.toJSON()}}toBoundingBox(){return[this.x,this.x+this.width,this.y,this.y+this.height]}toVec2(){return[this.x,this.y,this.w]}toSize(){return[this.width,this.height]}clone(){return new e(this.position.clone(),this.size.clone())}equals(...t){let n=e.resolveArgs(t);return this.position.equals(n.position)&&this.size.equals(n.size)}},G=class{constructor(e,t,n){this.A=e,this.B=t,this.C=n}get alpha(){return Math.acos((this.b*this.b+this.c*this.c-this.a*this.a)/(2*this.b*this.c))}get beta(){return Math.acos((this.c*this.c+this.a*this.a-this.b*this.b)/(2*this.c*this.a))}get gamma(){return Math.acos((this.a*this.a+this.b*this.b-this.c*this.c)/(2*this.a*this.b))}get perimeter(){return this.a+this.b+this.c}get semiperimeter(){return this.perimeter/2}get area(){return Math.sqrt(this.semiperimeter*(this.semiperimeter-this.a)*(this.semiperimeter-this.b)*(this.semiperimeter-this.c))}get base(){return 2*(this.area/(this.a*Math.sin(this.gamma)))}get height(){return 2*(this.area/this.base)}toString(){return`${this.A}|${this.B}|${this.C}`}get[Symbol.toStringTag](){return`Triangle`}[t](){return`Triangle <${this.toString()}>`}},K=class extends G{get a(){return g.fromPoints(this.B,this.C).length()}get b(){return g.fromPoints(this.A,this.C).length()}get c(){return g.fromPoints(this.A,this.B).length()}},q=class extends G{get a(){return y.fromPoints(this.B,this.C).length()}get b(){return y.fromPoints(this.A,this.C).length()}get c(){return y.fromPoints(this.A,this.B).length()}},J=class e{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m10(){return this._raw[3]}set m10(e){this._raw[3]=e}get m11(){return this._raw[4]}set m11(e){this._raw[4]=e}get m12(){return this._raw[5]}set m12(e){this._raw[5]=e}get m20(){return this._raw[6]}set m20(e){this._raw[6]=e}get m21(){return this._raw[7]}set m21(e){this._raw[7]=e}get m22(){return this._raw[8]}set m22(e){this._raw[8]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Mat3`,e)}static resolveArgs(e){return o(e,s,9)?new this(e):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let t=e.split(`,`);if(o(t,c,9))return this.cast(t.map(e=>parseFloat(e)))}if(s(e))return new this([e,e,e,e,e,e,e,e,e]);if(o(e,s,9))return new this(e);if(a(e,3)){let t=e[0],n=e[1],r=e[2];if(o(t,s,3)&&o(n,s,3)&&o(r,s,3))return new this([t[0],t[1],t[2],n[0],n[1],n[2],r[0],r[1],r[2]])}if(i(e,`toMat3`,`function`))return this.cast(e.toMat3());if(i(e,`m00`,`number`)&&i(e,`m01`,`number`)&&i(e,`m02`,`number`)&&i(e,`m10`,`number`)&&i(e,`m11`,`number`)&&i(e,`m12`,`number`)&&i(e,`m20`,`number`)&&i(e,`m21`,`number`)&&i(e,`m22`,`number`))return new this([e.m00,e.m01,e.m02,e.m10,e.m11,e.m12,e.m20,e.m21,e.m22])}}static is(e){return this.cast(e)!==void 0}static projection(e,t){return new this([2/e,0,0,0,-2/t,0,-1,1,1])}constructor(e=[1,0,0,0,1,0,0,0,1]){n(e,s,9),this._raw=e}toArray(){return[this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22]}toNestetArray(){return[[this.m00,this.m01,this.m02],[this.m10,this.m11,this.m12],[this.m20,this.m21,this.m22]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m10:this.m10,m11:this.m11,m12:this.m12,m20:this.m20,m21:this.m21,m22:this.m22}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`}get[Symbol.toStringTag](){return`Mat3`}[t](){return`Mat3 <${this.toString()}>`}clone(){return new e([this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22])}equals(...t){let n=e.resolveArgs(t);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...t){if(o(t,s,1))return new e([this.m00*t[0],this.m01*t[0],this.m02*t[0],this.m10*t[0],this.m11*t[0],this.m12*t[0],this.m20*t[0],this.m21*t[0],this.m22*t[0]]);let n=e.resolveArgs(t);return new e([n.m00*this.m00+n.m01*this.m10+n.m02*this.m20,n.m00*this.m01+n.m01*this.m11+n.m02*this.m21,n.m00*this.m02+n.m01*this.m12+n.m02*this.m22,n.m10*this.m00+n.m11*this.m10+n.m12*this.m20,n.m10*this.m01+n.m11*this.m11+n.m12*this.m21,n.m10*this.m02+n.m11*this.m12+n.m12*this.m22,n.m20*this.m00+n.m21*this.m10+n.m22*this.m20,n.m20*this.m01+n.m21*this.m11+n.m22*this.m21,n.m20*this.m02+n.m21*this.m12+n.m22*this.m22])}translate(...e){let t=g.resolveArgs(e);return this.multiply([1,0,0,0,1,0,t.x,t.y,1])}rotate(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,-n,0,n,t,0,0,0,1])}scale(...e){let t=g.resolve(e);return this.multiply([t.x,0,0,0,t.y,0,0,0,1])}determinant(){return this.m00*this.m11*this.m22-this.m21*this.m12-this.m01*this.m10*this.m22-this.m12*this.m20+this.m02*this.m10*this.m21-this.m11*this.m20}inverse(){let t=this.determinant();return new e([(this.m11*this.m22-this.m21*this.m12)*t,(this.m02*this.m21-this.m01*this.m22)*t,(this.m01*this.m12-this.m02*this.m11)*t,(this.m12*this.m20-this.m10*this.m22)*t,(this.m00*this.m22-this.m02*this.m20)*t,(this.m10*this.m02-this.m00*this.m12)*t,(this.m10*this.m21-this.m20*this.m11)*t,(this.m20*this.m01-this.m00*this.m21)*t,(this.m00*this.m11-this.m10*this.m01)*t])}toMat4(){return[this.m00,this.m01,this.m02,0,this.m10,this.m11,this.m12,0,this.m20,this.m20,this.m22,0,0,0,0,1]}},Y=class e{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m03(){return this._raw[3]}set m03(e){this._raw[3]=e}get m10(){return this._raw[4]}set m10(e){this._raw[4]=e}get m11(){return this._raw[5]}set m11(e){this._raw[5]=e}get m12(){return this._raw[6]}set m12(e){this._raw[6]=e}get m13(){return this._raw[7]}set m13(e){this._raw[7]=e}get m20(){return this._raw[8]}set m20(e){this._raw[8]=e}get m21(){return this._raw[9]}set m21(e){this._raw[9]=e}get m22(){return this._raw[10]}set m22(e){this._raw[10]=e}get m23(){return this._raw[11]}set m23(e){this._raw[11]=e}get m30(){return this._raw[12]}set m30(e){this._raw[12]=e}get m31(){return this._raw[13]}set m31(e){this._raw[13]=e}get m32(){return this._raw[14]}set m32(e){this._raw[14]=e}get m33(){return this._raw[15]}set m33(e){this._raw[15]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Mat4`,e)}static resolveArgs(e){return o(e,s,16)?new this(e):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(c(e)){let t=e.split(`,`);if(o(t,c,16))return this.cast(t.map(e=>parseFloat(e)))}if(s(e))return new this([e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e]);if(o(e,s,16))return new this(e);if(a(e,4)){let t=e[0],n=e[1],r=e[2],i=e[3];if(o(t,s,4)&&o(n,s,4)&&o(r,s,4)&&o(i,s,4))return new this([t[0],t[1],t[2],t[3],n[0],n[1],n[2],n[3],r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3]])}if(i(e,`toMat4`,`function`))return this.cast(e.toMat4());if(i(e,`m00`,`number`)&&i(e,`m01`,`number`)&&i(e,`m02`,`number`)&&i(e,`m03`,`number`)&&i(e,`m10`,`number`)&&i(e,`m11`,`number`)&&i(e,`m12`,`number`)&&i(e,`m13`,`number`)&&i(e,`m20`,`number`)&&i(e,`m21`,`number`)&&i(e,`m22`,`number`)&&i(e,`m23`,`number`)&&i(e,`m30`,`number`)&&i(e,`m31`,`number`)&&i(e,`m32`,`number`)&&i(e,`m33`,`number`))return new this([e.m00,e.m01,e.m02,e.m03,e.m10,e.m11,e.m12,e.m13,e.m20,e.m21,e.m22,e.m23,e.m30,e.m31,e.m32,e.m33])}}static is(e){return this.cast(e)!==void 0}static orthographic(...e){let t=o(e,s,6)?new H(e[0],e[1],e[2],e[3]):H.resolve(e[0]),n=o(e,s,6)?e[4]:e[1],r=o(e,s,6)?e[5]:e[2];return new this([2/(t.right-t.left),0,0,0,0,2/(t.top-t.bottom),0,0,0,0,2/(n-r),0,(t.left+t.right)/(t.left-t.right),(t.bottom+t.top)/(t.bottom-t.top),(n+r)/(n-r),1])}static perspective(e,t,n,r){let i=Math.tan(Math.PI*.5-.5*e),a=1/(n-r);return new this([i/t,0,0,0,0,i,0,0,0,0,(n+r)*a,-1,0,0,n*r*a*2,0])}static pointAt(e,t,n){let r=y.resolve(t).subtract(e).normalize(),i=r.multiply(y.resolve(n).dot(r)),a=y.resolve(n).subtract(i).normalize(),o=a.cross(r),s=y.resolve(e);return new this([o.x,o.y,o.z,0,a.x,a.y,a.z,0,r.x,r.y,r.z,0,s.x,s.y,s.z,1])}constructor(e=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]){n(e,s,16),this._raw=e}toArray(){return[this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33]}toNestetArray(){return[[this.m00,this.m01,this.m02,this.m03],[this.m10,this.m11,this.m12,this.m13],[this.m20,this.m21,this.m22,this.m23],[this.m30,this.m31,this.m32,this.m33]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m03:this.m03,m10:this.m10,m11:this.m11,m12:this.m12,m13:this.m13,m20:this.m20,m21:this.m21,m22:this.m22,m23:this.m23,m30:this.m20,m31:this.m21,m32:this.m22,m33:this.m23}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`}get[Symbol.toStringTag](){return`Mat4`}[t](){return`Mat4 <${this.toString()}>`}clone(){return new e([this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33])}equals(...t){let n=e.resolveArgs(t);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...t){if(o(t,s,1)){let n=t[0];return new e([this.m00*n,this.m01*n,this.m02*n,this.m03*n,this.m10*n,this.m11*n,this.m12*n,this.m13*n,this.m20*n,this.m21*n,this.m22*n,this.m23*n,this.m30*n,this.m31*n,this.m32*n,this.m33*n])}let n=y.cast(t[0]);if(n!==void 0){let e=new y(n.x*this.m00+n.y*this.m10+n.z*this.m20+this.m30,n.x*this.m01+n.y*this.m11+n.z*this.m21+this.m31,n.x*this.m02+n.y*this.m12+n.z*this.m22+this.m32,n.x*this.m03+n.y*this.m13+n.z*this.m23+this.m33);return e.w==0?e:e.divide(e.w)}let r=e.resolveArgs(t);return new e([r.m00*this.m00+r.m01*this.m10+r.m02*this.m20+r.m03*this.m30,r.m00*this.m01+r.m01*this.m11+r.m02*this.m21+r.m03*this.m31,r.m00*this.m02+r.m01*this.m12+r.m02*this.m22+r.m03*this.m32,r.m00*this.m03+r.m01*this.m13+r.m02*this.m23+r.m03*this.m33,r.m10*this.m00+r.m11*this.m10+r.m12*this.m20+r.m13*this.m30,r.m10*this.m01+r.m11*this.m11+r.m12*this.m21+r.m13*this.m31,r.m10*this.m02+r.m11*this.m12+r.m12*this.m22+r.m13*this.m32,r.m10*this.m03+r.m11*this.m13+r.m12*this.m23+r.m13*this.m33,r.m20*this.m00+r.m21*this.m10+r.m22*this.m20+r.m23*this.m30,r.m20*this.m01+r.m21*this.m11+r.m22*this.m21+r.m23*this.m31,r.m20*this.m02+r.m21*this.m12+r.m22*this.m22+r.m23*this.m32,r.m20*this.m03+r.m21*this.m13+r.m22*this.m23+r.m23*this.m33,r.m30*this.m00+r.m31*this.m10+r.m32*this.m20+r.m33*this.m30,r.m30*this.m01+r.m31*this.m11+r.m32*this.m21+r.m33*this.m31,r.m30*this.m02+r.m31*this.m12+r.m32*this.m22+r.m33*this.m32,r.m30*this.m03+r.m31*this.m13+r.m32*this.m23+r.m33*this.m33])}translate(...e){let t=y.resolveArgs(e);return this.multiply([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}rotateX(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([1,0,0,0,0,t,n,0,0,-n,t,0,0,0,0,1])}rotateY(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,0,-n,0,0,1,0,0,n,0,t,0,0,0,0,1])}rotateZ(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,n,0,0,-n,t,0,0,0,0,1,0,0,0,0,1])}rotate(...e){let t=y.resolveArgs(e);return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z)}scale(...e){let t=y.resolveArgs(e);return this.multiply([t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1])}inverse(){return new e([this.m00,this.m10,this.m20,0,this.m01,this.m11,this.m21,0,this.m02,this.m12,this.m22,0,-(this.m30*this.m00+this.m31*this.m10+this.m32*this.m20),-(this.m30*this.m01+this.m31*this.m11+this.m32*this.m21),-(this.m30*this.m02+this.m31*this.m12+this.m32*this.m22),1])}toMat3(){return[this.m00,this.m01,this.m03,this.m10,this.m11,this.m13,this.m30,this.m31,this.m33]}};let X;(function(e){function t(e,t=!1){let n=[];try{let t=O.resolve(e);n.push(t)}catch{}try{let t=k.resolve(e);n.push(t)}catch{}let r=t?1:0,i=n[r];if(i)return i;let a=n[r+1];if(a)return a}e.cast=t;function n(e,n=!1){let r=t(e,n);if(r!==void 0)return r;throw new d(`Color`,e)}e.resolve=n;function r(e,t=!1){return o(e,s,3)||o(e,s,4)?n(e,t):n(e[0],t)}e.resolveArgs=r})(X||={});var Z=class{origin=g.zero;localPosition;localRotation;get localRotationDegree(){return z(this.localRotation)}set localRotationDegree(e){this.localRotation=B(e)}localScale;get globalPosition(){let e=g.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=0,t=this;for(;t!==void 0;)e+=t.localRotation,t=t.parent;return e}get globalRotationDegree(){return z(this.globalRotation)}get globalScale(){let e=g.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,i){this.parent=i,r(t),this.localPosition=g.resolve(e),this.localRotation=t,this.localScale=g.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[t](){return`Transform2D <${this.toString()}>`}toMat3(){return new J().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition)}toGlobalMat3(){let e=new J,t=this;for(;t!==void 0;)e=e.multiply(t.toMat3()),t=t.parent;return e}},Q=class{origin=y.zero;localPosition;localRotation;localScale;get globalPosition(){let e=y.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=b.zero,t=this;for(;t!==void 0;)e=e.add(t.localRotation),t=t.parent;return e}get globalScale(){let e=y.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,r){this.parent=r,this.localPosition=y.resolve(e),this.localRotation=b.resolve(t),this.localScale=y.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[t](){return`Transform2D <${this.toString()}>`}toMat4(){return new Y().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition)}toGlobalMat4(){let e=new Y,t=this;for(;t!==void 0;)e=e.multiply(t.toMat4()),t=t.parent;return e}};export{X as AnyColor,H as BoundingBox,V as Circle,A as DJB2_OFFSET,m as EPSILON,M as FNV1_OFFSET,N as FNV1_PRIME,k as HSLA,_ as LinearFunction,I as MAX_ANGLE_DEGREE,J as Mat3,Y as Mat4,l as MathFunction,v as QuadFunction,b as Quaternion,O as RGBA,W as Rectangle,d as ResolveError,U as Size,Z as Transform2D,Q as Transform3D,G as Triangle,K as Triangle2D,q as Triangle3D,g as Vec2,y as Vec3,f as clamp,L as clampAngleDegree,R as clampAngleRadian,B as degreeToRadian,j as djb2,P as fnv1,T as hasHexNumberAlpha,E as hexNumberToRGB,D as hexNumberToRGBA,C as isHexNumber,h as lerp,p as logHypot,x as numberToRGB,S as numberToRGBA,z as radianToDegree,F as sdbm,u as signCharacter};
|