modern-path2d 0.1.1 → 0.1.2

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.cjs CHANGED
@@ -1,5 +1,145 @@
1
1
  'use strict';
2
2
 
3
+ class Point2D {
4
+ constructor(x = 0, y = 0) {
5
+ this.x = x;
6
+ this.y = y;
7
+ }
8
+ static get MAX() {
9
+ return new Point2D(Infinity, Infinity);
10
+ }
11
+ static get MIN() {
12
+ return new Point2D(-Infinity, -Infinity);
13
+ }
14
+ set(x, y) {
15
+ this.x = x;
16
+ this.y = y;
17
+ return this;
18
+ }
19
+ add(point) {
20
+ this.x += point.x;
21
+ this.y += point.y;
22
+ return this;
23
+ }
24
+ sub(point) {
25
+ this.x -= point.x;
26
+ this.y -= point.y;
27
+ return this;
28
+ }
29
+ distanceTo(point) {
30
+ return Math.sqrt(this.distanceToSquared(point));
31
+ }
32
+ distanceToSquared(point) {
33
+ const dx = this.x - point.x;
34
+ const dy = this.y - point.y;
35
+ return dx * dx + dy * dy;
36
+ }
37
+ length() {
38
+ return Math.sqrt(this.x * this.x + this.y * this.y);
39
+ }
40
+ multiplyScalar(scalar) {
41
+ this.x *= scalar;
42
+ this.y *= scalar;
43
+ return this;
44
+ }
45
+ divideScalar(scalar) {
46
+ return this.multiplyScalar(1 / scalar);
47
+ }
48
+ subVectors(a, b) {
49
+ this.x = a.x - b.x;
50
+ this.y = a.y - b.y;
51
+ return this;
52
+ }
53
+ normalize() {
54
+ return this.divideScalar(this.length() || 1);
55
+ }
56
+ lerpVectors(v1, v2, alpha) {
57
+ this.x = v1.x + (v2.x - v1.x) * alpha;
58
+ this.y = v1.y + (v2.y - v1.y) * alpha;
59
+ return this;
60
+ }
61
+ equals(point) {
62
+ return this.x === point.x && this.y === point.y;
63
+ }
64
+ applyMatrix3(matrix3) {
65
+ const [a, c, tx, b, d, ty] = matrix3.elements;
66
+ const { x, y } = this;
67
+ this.set(
68
+ a * x + c * y + tx,
69
+ b * x + d * y + ty
70
+ );
71
+ return this;
72
+ }
73
+ copy(point) {
74
+ this.x = point.x;
75
+ this.y = point.y;
76
+ return this;
77
+ }
78
+ clone() {
79
+ return new Point2D(this.x, this.y);
80
+ }
81
+ }
82
+
83
+ class BoundingBox {
84
+ constructor(left = 0, top = 0, width = 0, height = 0) {
85
+ this.left = left;
86
+ this.top = top;
87
+ this.width = width;
88
+ this.height = height;
89
+ }
90
+ get x() {
91
+ return this.left;
92
+ }
93
+ set x(val) {
94
+ this.left = val;
95
+ }
96
+ get y() {
97
+ return this.top;
98
+ }
99
+ set y(val) {
100
+ this.top = val;
101
+ }
102
+ get right() {
103
+ return this.left + this.width;
104
+ }
105
+ get bottom() {
106
+ return this.top + this.height;
107
+ }
108
+ static from(...boxes) {
109
+ const firstBox = boxes[0];
110
+ const merged = boxes.slice(1).reduce(
111
+ (merged2, box) => {
112
+ merged2.left = Math.min(merged2.left, box.left);
113
+ merged2.top = Math.min(merged2.top, box.top);
114
+ merged2.right = Math.max(merged2.right, box.right);
115
+ merged2.bottom = Math.max(merged2.bottom, box.bottom);
116
+ return merged2;
117
+ },
118
+ {
119
+ left: firstBox?.left ?? 0,
120
+ top: firstBox?.top ?? 0,
121
+ right: firstBox?.right ?? 0,
122
+ bottom: firstBox?.bottom ?? 0
123
+ }
124
+ );
125
+ return new BoundingBox(merged.left, merged.top, merged.right - merged.left, merged.bottom - merged.top);
126
+ }
127
+ translate(tx, ty) {
128
+ this.left += tx;
129
+ this.top += ty;
130
+ return this;
131
+ }
132
+ getCenterPoint() {
133
+ return new Point2D((this.left + this.right) / 2, (this.top + this.bottom) / 2);
134
+ }
135
+ clone() {
136
+ return new BoundingBox(this.left, this.top, this.width, this.height);
137
+ }
138
+ toArray() {
139
+ return [this.left, this.top, this.width, this.height];
140
+ }
141
+ }
142
+
3
143
  var __defProp$6 = Object.defineProperty;
4
144
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
145
  var __publicField$6 = (obj, key, value) => {
@@ -202,86 +342,6 @@ class Matrix3 {
202
342
  }
203
343
  const _m3 = /* @__PURE__ */ new Matrix3();
204
344
 
205
- class Point2D {
206
- constructor(x = 0, y = 0) {
207
- this.x = x;
208
- this.y = y;
209
- }
210
- static get MAX() {
211
- return new Point2D(Infinity, Infinity);
212
- }
213
- static get MIN() {
214
- return new Point2D(-Infinity, -Infinity);
215
- }
216
- set(x, y) {
217
- this.x = x;
218
- this.y = y;
219
- return this;
220
- }
221
- add(point) {
222
- this.x += point.x;
223
- this.y += point.y;
224
- return this;
225
- }
226
- sub(point) {
227
- this.x -= point.x;
228
- this.y -= point.y;
229
- return this;
230
- }
231
- distanceTo(point) {
232
- return Math.sqrt(this.distanceToSquared(point));
233
- }
234
- distanceToSquared(point) {
235
- const dx = this.x - point.x;
236
- const dy = this.y - point.y;
237
- return dx * dx + dy * dy;
238
- }
239
- length() {
240
- return Math.sqrt(this.x * this.x + this.y * this.y);
241
- }
242
- multiplyScalar(scalar) {
243
- this.x *= scalar;
244
- this.y *= scalar;
245
- return this;
246
- }
247
- divideScalar(scalar) {
248
- return this.multiplyScalar(1 / scalar);
249
- }
250
- subVectors(a, b) {
251
- this.x = a.x - b.x;
252
- this.y = a.y - b.y;
253
- return this;
254
- }
255
- normalize() {
256
- return this.divideScalar(this.length() || 1);
257
- }
258
- lerpVectors(v1, v2, alpha) {
259
- this.x = v1.x + (v2.x - v1.x) * alpha;
260
- this.y = v1.y + (v2.y - v1.y) * alpha;
261
- return this;
262
- }
263
- equals(point) {
264
- return this.x === point.x && this.y === point.y;
265
- }
266
- applyMatrix3(matrix3) {
267
- const [a, c, tx, b, d, ty] = matrix3.elements;
268
- const { x, y } = this;
269
- this.set(
270
- a * x + c * y + tx,
271
- b * x + d * y + ty
272
- );
273
- return this;
274
- }
275
- copy(point) {
276
- this.x = point.x;
277
- this.y = point.y;
278
- return this;
279
- }
280
- clone() {
281
- return new Point2D(this.x, this.y);
282
- }
283
- }
284
-
285
345
  function svgAngle(ux, uy, vx, vy) {
286
346
  const dot = ux * vx + uy * vy;
287
347
  const len = Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);
@@ -2067,16 +2127,12 @@ class Path2D {
2067
2127
  }
2068
2128
  getBoundingBox() {
2069
2129
  const { min, max } = this.getMinMax();
2070
- return {
2071
- x: min.x,
2072
- y: min.y,
2073
- left: min.x,
2074
- top: min.y,
2075
- right: max.x,
2076
- bottom: max.y,
2077
- width: max.x - min.x,
2078
- height: max.y - min.y
2079
- };
2130
+ return new BoundingBox(
2131
+ min.x,
2132
+ min.y,
2133
+ max.x - min.x,
2134
+ max.y - min.y
2135
+ );
2080
2136
  }
2081
2137
  getCommands() {
2082
2138
  return this.paths.flatMap((path) => path.curves.flatMap((curve) => curve.getCommands()));
@@ -2622,6 +2678,7 @@ function parseSvg(svg) {
2622
2678
  });
2623
2679
  }
2624
2680
 
2681
+ exports.BoundingBox = BoundingBox;
2625
2682
  exports.CircleCurve = CircleCurve;
2626
2683
  exports.CubicBezierCurve = CubicBezierCurve;
2627
2684
  exports.Curve = Curve;
package/dist/index.d.cts CHANGED
@@ -42,6 +42,25 @@ declare class Point2D {
42
42
  clone(): Point2D;
43
43
  }
44
44
 
45
+ declare class BoundingBox {
46
+ left: number;
47
+ top: number;
48
+ width: number;
49
+ height: number;
50
+ get x(): number;
51
+ set x(val: number);
52
+ get y(): number;
53
+ set y(val: number);
54
+ get right(): number;
55
+ get bottom(): number;
56
+ constructor(left?: number, top?: number, width?: number, height?: number);
57
+ static from(...boxes: BoundingBox[]): BoundingBox;
58
+ translate(tx: number, ty: number): this;
59
+ getCenterPoint(): Point2D;
60
+ clone(): BoundingBox;
61
+ toArray(): [number, number, number, number];
62
+ }
63
+
45
64
  declare class CurvePath extends Curve {
46
65
  curves: Curve[];
47
66
  currentPoint: Point2D;
@@ -103,16 +122,7 @@ declare class Path2D<T = any> {
103
122
  min: Point2D;
104
123
  max: Point2D;
105
124
  };
106
- getBoundingBox(): {
107
- x: number;
108
- y: number;
109
- left: number;
110
- top: number;
111
- right: number;
112
- bottom: number;
113
- width: number;
114
- height: number;
115
- };
125
+ getBoundingBox(): BoundingBox;
116
126
  getCommands(): PathCommand[];
117
127
  getData(): string;
118
128
  getSvgString(): string;
@@ -372,4 +382,4 @@ declare class SplineCurve extends Curve {
372
382
 
373
383
  declare function parseSvg(svg: string | SVGElement): Path2D[];
374
384
 
375
- export { CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
385
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
package/dist/index.d.mts CHANGED
@@ -42,6 +42,25 @@ declare class Point2D {
42
42
  clone(): Point2D;
43
43
  }
44
44
 
45
+ declare class BoundingBox {
46
+ left: number;
47
+ top: number;
48
+ width: number;
49
+ height: number;
50
+ get x(): number;
51
+ set x(val: number);
52
+ get y(): number;
53
+ set y(val: number);
54
+ get right(): number;
55
+ get bottom(): number;
56
+ constructor(left?: number, top?: number, width?: number, height?: number);
57
+ static from(...boxes: BoundingBox[]): BoundingBox;
58
+ translate(tx: number, ty: number): this;
59
+ getCenterPoint(): Point2D;
60
+ clone(): BoundingBox;
61
+ toArray(): [number, number, number, number];
62
+ }
63
+
45
64
  declare class CurvePath extends Curve {
46
65
  curves: Curve[];
47
66
  currentPoint: Point2D;
@@ -103,16 +122,7 @@ declare class Path2D<T = any> {
103
122
  min: Point2D;
104
123
  max: Point2D;
105
124
  };
106
- getBoundingBox(): {
107
- x: number;
108
- y: number;
109
- left: number;
110
- top: number;
111
- right: number;
112
- bottom: number;
113
- width: number;
114
- height: number;
115
- };
125
+ getBoundingBox(): BoundingBox;
116
126
  getCommands(): PathCommand[];
117
127
  getData(): string;
118
128
  getSvgString(): string;
@@ -372,4 +382,4 @@ declare class SplineCurve extends Curve {
372
382
 
373
383
  declare function parseSvg(svg: string | SVGElement): Path2D[];
374
384
 
375
- export { CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
385
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
package/dist/index.d.ts CHANGED
@@ -42,6 +42,25 @@ declare class Point2D {
42
42
  clone(): Point2D;
43
43
  }
44
44
 
45
+ declare class BoundingBox {
46
+ left: number;
47
+ top: number;
48
+ width: number;
49
+ height: number;
50
+ get x(): number;
51
+ set x(val: number);
52
+ get y(): number;
53
+ set y(val: number);
54
+ get right(): number;
55
+ get bottom(): number;
56
+ constructor(left?: number, top?: number, width?: number, height?: number);
57
+ static from(...boxes: BoundingBox[]): BoundingBox;
58
+ translate(tx: number, ty: number): this;
59
+ getCenterPoint(): Point2D;
60
+ clone(): BoundingBox;
61
+ toArray(): [number, number, number, number];
62
+ }
63
+
45
64
  declare class CurvePath extends Curve {
46
65
  curves: Curve[];
47
66
  currentPoint: Point2D;
@@ -103,16 +122,7 @@ declare class Path2D<T = any> {
103
122
  min: Point2D;
104
123
  max: Point2D;
105
124
  };
106
- getBoundingBox(): {
107
- x: number;
108
- y: number;
109
- left: number;
110
- top: number;
111
- right: number;
112
- bottom: number;
113
- width: number;
114
- height: number;
115
- };
125
+ getBoundingBox(): BoundingBox;
116
126
  getCommands(): PathCommand[];
117
127
  getData(): string;
118
128
  getSvgString(): string;
@@ -372,4 +382,4 @@ declare class SplineCurve extends Curve {
372
382
 
373
383
  declare function parseSvg(svg: string | SVGElement): Path2D[];
374
384
 
375
- export { CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
385
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(v,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(v=typeof globalThis<"u"?globalThis:v||self,d(v.modernPath2d={}))})(this,function(v){"use strict";var Qt=Object.defineProperty;var Ut=(v,d,$)=>d in v?Qt(v,d,{enumerable:!0,configurable:!0,writable:!0,value:$}):v[d]=$;var b=(v,d,$)=>Ut(v,typeof d!="symbol"?d+"":d,$);class d{constructor(e=1,t=0,s=0,i=0,o=1,h=0,a=0,c=0,n=1){b(this,"elements",[]);this.set(e,t,s,i,o,h,a,c,n)}set(e,t,s,i,o,h,a,c,n){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=o,u[5]=c,u[6]=s,u[7]=h,u[8]=n,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,o=this.elements,h=s[0],a=s[3],c=s[6],n=s[1],u=s[4],y=s[7],p=s[2],x=s[5],g=s[8],f=i[0],M=i[3],w=i[6],k=i[1],T=i[4],C=i[7],A=i[2],E=i[5],z=i[8];return o[0]=h*f+a*k+c*A,o[3]=h*M+a*T+c*E,o[6]=h*w+a*C+c*z,o[1]=n*f+u*k+y*A,o[4]=n*M+u*T+y*E,o[7]=n*w+u*C+y*z,o[2]=p*f+x*k+g*A,o[5]=p*M+x*T+g*E,o[8]=p*w+x*C+g*z,this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],o=e[3],h=e[4],a=e[5],c=e[6],n=e[7],u=e[8],y=u*h-a*n,p=a*c-u*o,x=n*o-h*c,g=t*y+s*p+i*x;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/g;return e[0]=y*f,e[1]=(i*n-u*s)*f,e[2]=(a*s-i*h)*f,e[3]=p*f,e[4]=(u*t-i*c)*f,e[5]=(i*o-a*t)*f,e[6]=x*f,e[7]=(s*c-n*t)*f,e[8]=(h*t-s*o)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply($.makeScale(e,t)),this}rotate(e){return this.premultiply($.makeRotation(-e)),this}translate(e,t){return this.premultiply($.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const $=new d;class l{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new l(1/0,1/0)}static get MIN(){return new l(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}multiplyScalar(e){return this.x*=e,this.y*=e,this}divideScalar(e){return this.multiplyScalar(1/e)}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}normalize(){return this.divideScalar(this.length()||1)}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const[t,s,i,o,h,a]=e.elements,{x:c,y:n}=this;return this.set(t*c+s*n+i,o*c+h*n+a),this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new l(this.x,this.y)}}function U(r,e,t,s){const i=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let h=Math.acos(Math.max(-1,Math.min(1,i/o)));return r*s-e*t<0&&(h=-h),h}function lt(r,e,t,s,i,o,h,a){if(e===0||t===0){r.lineTo(a.x,a.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(h.x-a.x)/2,n=(h.y-a.y)/2,u=Math.cos(s)*c+Math.sin(s)*n,y=-Math.sin(s)*c+Math.cos(s)*n;let p=e*e,x=t*t;const g=u*u,f=y*y,M=g/p+f/x;if(M>1){const ut=Math.sqrt(M);e=ut*e,t=ut*t,p=e*e,x=t*t}const w=p*f+x*g,k=(p*x-w)/w;let T=Math.sqrt(Math.max(0,k));i===o&&(T=-T);const C=T*e*y/t,A=-T*t*u/e,E=Math.cos(s)*C-Math.sin(s)*A+(h.x+a.x)/2,z=Math.sin(s)*C+Math.cos(s)*A+(h.y+a.y)/2,Y=U(1,0,(u-C)/e,(y-A)/t),Q=U((u-C)/e,(y-A)/t,(-u-C)/e,(-y-A)/t)%(Math.PI*2);r.currentPath.absellipse(E,z,e,t,Y,Y+Q,o===0,s)}function D(r,e){return r-(e-r)}function yt(r,e){const t=new l,s=new l,i=new l;let o=!0,h=!1;for(let a=0,c=r.length;a<c;a++){const n=r[a];if(o&&(h=!0,o=!1),n.type==="m"||n.type==="M")n.type==="m"?(t.x+=n.x,t.y+=n.y):(t.x=n.x,t.y=n.y),s.x=t.x,s.y=t.y,e.moveTo(t.x,t.y),a===0&&i.copy(t);else if(n.type==="h"||n.type==="H")n.type==="h"?t.x+=n.x:t.x=n.x,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&i.copy(t);else if(n.type==="v"||n.type==="V")n.type==="v"?t.y+=n.y:t.y=n.y,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&i.copy(t);else if(n.type==="l"||n.type==="L")n.type==="l"?(t.x+=n.x,t.y+=n.y):(t.x=n.x,t.y=n.y),s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&i.copy(t);else if(n.type==="c"||n.type==="C")n.type==="c"?(e.bezierCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.x+=n.x,t.y+=n.y):(e.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.x=n.x,t.y=n.y),h&&i.copy(t);else if(n.type==="s"||n.type==="S")n.type==="s"?(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.x+=n.x,t.y+=n.y):(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.x=n.x,t.y=n.y),h&&i.copy(t);else if(n.type==="q"||n.type==="Q")n.type==="q"?(e.quadraticCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x,t.y+n.y),s.x=t.x+n.x1,s.y=t.y+n.y1,t.x+=n.x,t.y+=n.y):(e.quadraticCurveTo(n.x1,n.y1,n.x,n.y),s.x=n.x1,s.y=n.y1,t.x=n.x,t.y=n.y),h&&i.copy(t);else if(n.type==="t"||n.type==="T"){const u=D(t.x,s.x),y=D(t.y,s.y);s.x=u,s.y=y,n.type==="t"?(e.quadraticCurveTo(u,y,t.x+n.x,t.y+n.y),t.x+=n.x,t.y+=n.y):(e.quadraticCurveTo(u,y,n.x,n.y),t.x=n.x,t.y=n.y),h&&i.copy(t)}else if(n.type==="a"||n.type==="A"){if(n.type==="a"){if(n.x===0&&n.y===0)continue;t.x+=n.x,t.y+=n.y}else{if(n.x===t.x&&n.y===t.y)continue;t.x=n.x,t.y=n.y}const u=t.clone();s.x=t.x,s.y=t.y,lt(e,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,u,t),h&&i.copy(t)}else n.type==="z"||n.type==="Z"?(e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(t.copy(i),e.currentPath.currentPoint.copy(t),o=!0)):console.warn(n);h=!1}}const P={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function S(r,e,t=0){let a=0,c=!0,n="",u="";const y=[];function p(M,w,k){const T=new SyntaxError(`Unexpected character "${M}" at index ${w}.`);throw T.partial=k,T}function x(){n!==""&&(u===""?y.push(Number(n)):y.push(Number(n)*10**Number(u))),n="",u=""}let g;const f=r.length;for(let M=0;M<f;M++){if(g=r[M],Array.isArray(e)&&e.includes(y.length%t)&&P.FLAGS.test(g)){a=1,n=g,x();continue}if(a===0){if(P.WHITESPACE.test(g))continue;if(P.DIGIT.test(g)||P.SIGN.test(g)){a=1,n=g;continue}if(P.POINT.test(g)){a=2,n=g;continue}P.COMMA.test(g)&&(c&&p(g,M,y),c=!0)}if(a===1){if(P.DIGIT.test(g)){n+=g;continue}if(P.POINT.test(g)){n+=g,a=2;continue}if(P.EXP.test(g)){a=3;continue}P.SIGN.test(g)&&n.length===1&&P.SIGN.test(n[0])&&p(g,M,y)}if(a===2){if(P.DIGIT.test(g)){n+=g;continue}if(P.EXP.test(g)){a=3;continue}P.POINT.test(g)&&n[n.length-1]==="."&&p(g,M,y)}if(a===3){if(P.DIGIT.test(g)){u+=g;continue}if(P.SIGN.test(g)){if(u===""){u+=g;continue}u.length===1&&P.SIGN.test(u)&&p(g,M,y)}}P.WHITESPACE.test(g)?(x(),a=0,c=!1):P.COMMA.test(g)?(x(),a=0,c=!0):P.SIGN.test(g)?(x(),a=1,n=g):P.POINT.test(g)?(x(),a=2,n=g):p(g,M,y)}return x(),y}function gt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function pt(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${gt(r[t])} `;return e}const ft=/[a-df-z][^a-df-z]*/gi;function xt(r){const e=[],t=r.match(ft);if(!t)return e;for(let s=0,i=t.length;s<i;s++){const o=t[s],h=o.charAt(0),a=o.slice(1).trim();let c;switch(h){case"m":case"M":c=S(a);for(let n=0,u=c.length;n<u;n+=2)n===0?e.push({type:h,x:c[n],y:c[n+1]}):e.push({type:h==="m"?"l":"L",x:c[n],y:c[n+1]});break;case"h":case"H":c=S(a);for(let n=0,u=c.length;n<u;n++)e.push({type:h,x:c[n]});break;case"v":case"V":c=S(a);for(let n=0,u=c.length;n<u;n++)e.push({type:h,y:c[n]});break;case"l":case"L":c=S(a);for(let n=0,u=c.length;n<u;n+=2)e.push({type:h,x:c[n],y:c[n+1]});break;case"c":case"C":c=S(a);for(let n=0,u=c.length;n<u;n+=6)e.push({type:h,x1:c[n],y1:c[n+1],x2:c[n+2],y2:c[n+3],x:c[n+4],y:c[n+5]});break;case"s":case"S":c=S(a);for(let n=0,u=c.length;n<u;n+=4)e.push({type:h,x2:c[n],y2:c[n+1],x:c[n+2],y:c[n+3]});break;case"q":case"Q":c=S(a);for(let n=0,u=c.length;n<u;n+=4)e.push({type:h,x1:c[n],y1:c[n+1],x:c[n+2],y:c[n+3]});break;case"t":case"T":c=S(a);for(let n=0,u=c.length;n<u;n+=2)e.push({type:h,x:c[n],y:c[n+1]});break;case"a":case"A":c=S(a,[3,4],7);for(let n=0,u=c.length;n<u;n+=7)e.push({type:h,rx:c[n],ry:c[n+1],angle:c[n+2],largeArcFlag:c[n+3],sweepFlag:c[n+4],x:c[n+5],y:c[n+6]});break;case"z":case"Z":e.push({type:h});break;default:console.warn(o)}}return e}class L{constructor(){b(this,"arcLengthDivisions",200);b(this,"_cacheArcLengths");b(this,"_needsUpdate",!1)}getPointAt(e,t=new l){return this.getPoint(this.getUtoTmapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,i=this.getPoint(0),o=0;t.push(0);for(let h=1;h<=e;h++)s=this.getPoint(h/e),o+=s.distanceTo(i),t.push(o),i=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let i=0;const o=s.length;let h;t?h=t:h=e*s[o-1];let a=0,c=o-1,n;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),n=s[i]-h,n<0)a=i+1;else if(n>0)c=i-1;else{c=i;break}if(i=c,s[i]===h)return i/(o-1);const u=s[i],p=s[i+1]-u,x=(h-u)/p;return(i+x)/(o-1)}getTangent(e,t=new l){let i=e-1e-4,o=e+1e-4;return i<0&&(i=0),o>1&&(o=1),t.copy(this.getPoint(o)).sub(this.getPoint(i)).normalize()}getTangentAt(e,t=new l){return this.getTangent(this.getUtoTmapping(e),t)}transform(e){return this}getDivisions(e){return e}getMinMax(e=l.MAX,t=l.MIN){return{min:e,max:t}}getCommands(){return[]}getData(){return pt(this.getCommands())}drawTo(e){return this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class O extends L{constructor(e,t,s=0,i=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=i}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().multiplyScalar(t))}getTangent(e){const{x:t,y:s}=this.getNormal(e);return new l(-s,t)}getNormal(e){const{start:t,end:s}=this,i=e*(s-t)+t-.5*Math.PI;return new l(Math.cos(i),Math.sin(i))}getMinMax(e=l.MAX,t=l.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function V(r,e,t,s,i){const o=(s-e)*.5,h=(i-t)*.5,a=r*r,c=r*a;return(2*t-2*s+o+h)*c+(-3*t+3*s-2*o-h)*a+o*r+t}function Mt(r,e){const t=1-r;return t*t*e}function vt(r,e){return 2*(1-r)*r*e}function mt(r,e){return r*r*e}function H(r,e,t,s){return Mt(r,e)+vt(r,t)+mt(r,s)}function dt(r,e){const t=1-r;return t*t*t*e}function Pt(r,e){const t=1-r;return 3*t*t*r*e}function Tt(r,e){return 3*(1-r)*r*r*e}function wt(r,e){return r*r*r*e}function W(r,e,t,s,i){return dt(r,e)+Pt(r,t)+Tt(r,s)+wt(r,i)}class j extends L{constructor(e=new l,t=new l,s=new l,i=new l){super(),this.v0=e,this.v1=t,this.v2=s,this.v3=i}getPoint(e,t=new l){const{v0:s,v1:i,v2:o,v3:h}=this;return t.set(W(e,s.x,i.x,o.x,h.x),W(e,s.y,i.y,o.y,h.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this.v3.applyMatrix3(e),this}getMinMax(e=l.MAX,t=l.MIN){const{v0:s,v1:i,v2:o,v3:h}=this;return e.x=Math.min(e.x,s.x,i.x,o.x,h.x),e.y=Math.min(e.y,s.y,i.y,o.y,h.y),t.x=Math.max(t.x,s.x,i.x,o.x,h.x),t.y=Math.max(t.y,s.y,i.y,o.y,h.y),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s,v3:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:i.x,y:i.y}]}drawTo(e){const{v0:t,v1:s,v2:i,v3:o}=this;return e.moveTo(t.x,t.y),e.bezierCurveTo(s.x,s.y,i.x,i.y,o.x,o.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}}const bt=new d,Z=new d,J=new d,R=new l;class K extends L{constructor(e=0,t=0,s=1,i=1,o=0,h=Math.PI*2,a=!1,c=0){super(),this.x=e,this.y=t,this.radiusX=s,this.radiusY=i,this.startAngle=o,this.endAngle=h,this.clockwise=a,this.rotation=c}getPoint(e,t=new l){const s=Math.PI*2;let i=this.endAngle-this.startAngle;const o=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=s;for(;i>s;)i-=s;i<Number.EPSILON&&(o?i=0:i=s),this.clockwise&&!o&&(i===s?i=-s:i=i-s);const h=this.startAngle+e*i;let a=this.x+this.radiusX*Math.cos(h),c=this.y+this.radiusY*Math.sin(h);if(this.rotation!==0){const n=Math.cos(this.rotation),u=Math.sin(this.rotation),y=a-this.x,p=c-this.y;a=y*n-p*u+this.x,c=y*u+p*n+this.y}return t.set(a,c)}getDivisions(e=12){return e*2}getCommands(){const{x:e,y:t,radiusX:s,radiusY:i,startAngle:o,endAngle:h,clockwise:a}=this,c=!a,n=e+s*Math.cos(o),u=t+i*Math.sin(o),y=e+s*Math.cos(h),p=t+i*Math.sin(h),x=Math.abs(o-h),g=x>Math.PI?1:0,f=c?0:1,M=e+s*Math.cos(o+(h-o)/2),w=t+i*Math.sin(o+(h-o)/2);return x>=2*Math.PI?[{type:"M",x:n,y:u},{type:"A",rx:s,ry:i,angle:0,largeArcFlag:1,sweepFlag:f,x:M,y:w},{type:"A",rx:s,ry:i,angle:0,largeArcFlag:1,sweepFlag:f,x:n,y:u}]:[{type:"M",x:n,y:u},{type:"A",rx:s,ry:i,angle:0,largeArcFlag:g,sweepFlag:f,x:y,y:p}]}drawTo(e){const{x:t,y:s,radiusX:i,radiusY:o,rotation:h,startAngle:a,endAngle:c,clockwise:n}=this,u=t+i*Math.cos(a),y=s+o*Math.sin(a);return e.moveTo(u,y),e.ellipse(t,s,i,o,h,a,c,!n),this}transform(e){return R.set(this.x,this.y),R.applyMatrix3(e),this.x=R.x,this.y=R.y,It(e)?At(this,e):Ct(this,e),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function At(r,e){const t=r.radiusX,s=r.radiusY,i=Math.cos(r.rotation),o=Math.sin(r.rotation),h=new l(t*i,t*o),a=new l(-s*o,s*i),c=h.applyMatrix3(e),n=a.applyMatrix3(e),u=bt.set(c.x,n.x,0,c.y,n.y,0,0,0,1),y=Z.copy(u).invert(),g=J.copy(y).transpose().multiply(y).elements,f=kt(g[0],g[1],g[4]),M=Math.sqrt(f.rt1),w=Math.sqrt(f.rt2);if(r.radiusX=1/M,r.radiusY=1/w,r.rotation=Math.atan2(f.sn,f.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const T=Z.set(M,0,0,0,w,0,0,0,1),C=J.set(f.cs,f.sn,0,-f.sn,f.cs,0,0,0,1),A=T.multiply(C).multiply(u),E=z=>{const{x:Y,y:Q}=new l(Math.cos(z),Math.sin(z)).applyMatrix3(A);return Math.atan2(Q,Y)};r.startAngle=E(r.startAngle),r.endAngle=E(r.endAngle),tt(e)&&(r.clockwise=!r.clockwise)}}function Ct(r,e){const t=et(e),s=st(e);r.radiusX*=t,r.radiusY*=s;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=i,tt(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function tt(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function It(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=et(r),i=st(r);return Math.abs(t/(s*i))>Number.EPSILON}function et(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function st(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function kt(r,e,t){let s,i,o,h,a;const c=r+t,n=r-t,u=Math.sqrt(n*n+4*e*e);return c>0?(s=.5*(c+u),a=1/s,i=r*a*t-e*a*e):c<0?i=.5*(c-u):(s=.5*u,i=-.5*u),n>0?o=n+u:o=n-u,Math.abs(o)>2*Math.abs(e)?(a=-2*e/o,h=1/Math.sqrt(1+a*a),o=a*h):Math.abs(e)===0?(o=1,h=0):(a=-.5*o/e,o=1/Math.sqrt(1+a*a),h=a*o),n>0&&(a=o,o=-h,h=a),{rt1:s,rt2:i,cs:o,sn:h}}class q extends L{constructor(e=new l,t=new l){super(),this.v1=e,this.v2=t}getPoint(e,t=new l){return e===1?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t=new l){return this.getPoint(e,t)}getTangent(e,t=new l){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t=new l){return this.getTangent(e,t)}transform(e){return this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getDivisions(){return 1}getMinMax(e=l.MAX,t=l.MIN){const{v1:s,v2:i}=this;return e.x=Math.min(e.x,s.x,i.x),e.y=Math.min(e.y,s.y,i.y),t.x=Math.max(t.x,s.x,i.x),t.y=Math.max(t.y,s.y,i.y),{min:e,max:t}}getCommands(){const{v1:e,v2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{v1:t,v2:s}=this;return e.moveTo(t.x,t.y),e.lineTo(s.x,s.y),this}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class Lt extends L{constructor(t,s,i=0,o=1){super();b(this,"curves");b(this,"pointT",0);this.center=t,this.size=s,this.start=i,this.end=o;const{x:h,y:a}=this.center,c=new l(h+.5*this.size,a-.5*this.size),n=new l(h-.5*this.size,a-.5*this.size),u=new l(h,a+.5*this.size),y=new O(c,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),p=new O(n,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),x=new O(u,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),g=new l(h,a+this.size),f=new l(h+this.size,a),M=new l().lerpVectors(f,g,.75),w=new l(h-this.size,a),k=new l().lerpVectors(w,g,.75),T=new q(f,M),C=new q(k,w);this.curves=[y,T,x,C,p]}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let i;const o=.5*Math.PI;return s<o?(i=0,this.pointT=s/o):s<o+.75?(i=1,this.pointT=(s-o)/.75):s<5*Math.PI/8+.75?(i=2,this.pointT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(i=3,this.pointT=(s-5*Math.PI/8-.75)/.75):(i=4,this.pointT=(s-5*Math.PI/8-1.5)/o),this.curves[i]}getTangent(t){return this.getCurrentLine(t).getTangent(this.pointT).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new l(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class St extends L{constructor(t,s=0,i=0,o=0,h=1){super();b(this,"curves",[]);b(this,"points",[]);this.center=t,this.radius=s,this.num=i,this.start=o,this.end=h;for(let a=0;a<this.num;a++){let c=a*2*Math.PI/this.num;c-=.5*Math.PI;const n=new l(this.radius*Math.cos(c),this.radius*Math.sin(c));n.add(this.center),this.points.push(n)}for(let a=0;a<this.num;a++)this.curves.push(new q(this.points[a],this.points[(a+1)%this.num]))}getPoint(t){return this.getCurrentLine(t),this.currentLine.getPoint(this.pointK)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const i=s*this.num,o=Math.floor(i);return this.pointK=i-o,this.currentLine=this.curves[o],this.currentLine}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new l(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class nt extends L{constructor(e=new l,t=new l,s=new l){super(),this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new l){const{v0:s,v1:i,v2:o}=this;return t.set(H(e,s.x,i.x,o.x),H(e,s.y,i.y,o.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getMinMax(e=l.MAX,t=l.MIN){const{v0:s,v1:i,v2:o}=this,h=.5*(s.x+i.x),a=.5*(s.y+i.y),c=.5*(s.x+o.x),n=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,h,c),e.y=Math.min(e.y,s.y,o.y,a,n),t.x=Math.max(t.x,s.x,o.x,h,c),t.y=Math.max(t.y,s.y,o.y,a,n),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{v0:t,v1:s,v2:i}=this;return e.moveTo(t.x,t.y),e.quadraticCurveTo(s.x,s.y,i.x,i.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class it extends L{constructor(t,s,i=1,o=0,h=1){super();b(this,"curves",[]);b(this,"pointT",0);this.center=t,this.rx=s,this.aspectRatio=i,this.start=o,this.end=h;const{x:a,y:c}=this.center,n=this.rx,u=this.rx/this.aspectRatio,y=[new l(a-n,c-u),new l(a+n,c-u),new l(a+n,c+u),new l(a-n,c+u)];for(let p=0;p<4;p++)this.curves.push(new q(y[p],y[(p+1)%4]))}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let i;return s<this.aspectRatio?(i=0,this.pointT=s/this.aspectRatio):s<this.aspectRatio+1?(i=1,this.pointT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(i=2,this.pointT=(s-this.aspectRatio-1)/this.aspectRatio):(i=3,this.pointT=(s-2*this.aspectRatio-1)/1),this.curves[i]}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const{v1:s,v2:i}=this.getCurrentLine(t);return new l(i.y-s.y,-(i.x-s.x)).normalize()}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class rt extends L{constructor(e=[]){super(),this.points=e}getDivisions(e=12){return e*this.points.length}getPoint(e,t=new l){const{points:s}=this,i=(s.length-1)*e,o=Math.floor(i),h=i-o,a=s[o===0?o:o-1],c=s[o],n=s[o>s.length-2?s.length-1:o+1],u=s[o>s.length-3?s.length-1:o+2];return t.set(V(h,a.x,c.x,n.x,u.x),V(h,a.y,c.y,n.y,u.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class X extends L{constructor(t){super();b(this,"curves",[]);b(this,"currentPoint",new l);b(this,"autoClose",!1);b(this,"_cacheLengths",[]);t&&this.setFromPoints(t)}addCurve(t){return this.curves.push(t),this}closePath(){const t=this.curves[0].getPoint(0),s=this.curves[this.curves.length-1].getPoint(1);return t.equals(s)||this.curves.push(new q(s,t)),this}getPoint(t,s=new l){const i=t*this.getLength(),o=this.getCurveLengths();let h=0;for(;h<o.length;){if(o[h]>=i){const a=o[h]-i,c=this.curves[h],n=c.getLength();return c.getPointAt(n===0?0:1-a/n,s)}h++}return s}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let i=0,o=this.curves.length;i<o;i++)s+=this.curves[i].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let i=0;i<=t;i++)s.push(this.getPoint(i/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[];let i;for(let o=0,h=this.curves;o<h.length;o++){const a=h[o],c=a.getPoints(a.getDivisions(t));for(let n=0;n<c.length;n++){const u=c[n];i&&i.equals(u)||(s.push(u),i=u)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,i=t.length;s<i;s++)this.lineTo(t[s].x,t[s].y);return this}bezierCurveTo(t,s,i,o,h,a){return this.curves.push(new j(this.currentPoint.clone(),new l(t,s),new l(i,o),new l(h,a))),this.currentPoint.set(h,a),this}lineTo(t,s){const i=new q(this.currentPoint.clone(),new l(t,s));return this.curves.push(i),this.currentPoint.set(t,s),this}moveTo(t,s){return this.currentPoint.set(t,s),this}quadraticCurveTo(t,s,i,o){return this.curves.push(new nt(this.currentPoint.clone(),new l(t,s),new l(i,o))),this.currentPoint.set(i,o),this}rect(t,s,i,o){return this.curves.push(new it(new l(t+i/2,s+o/2),i/2,i/o)),this.currentPoint.set(t,s),this}splineThru(t){const s=[this.currentPoint.clone()].concat(t);return this.curves.push(new rt(s)),this.currentPoint.copy(t[t.length-1]),this}arc(t,s,i,o,h,a=!1){const c=this.currentPoint;return this.absarc(t+c.x,s+c.y,i,o,h,a),this}absarc(t,s,i,o,h,a=!1){return this.absellipse(t,s,i,i,o,h,a),this}ellipse(t,s,i,o,h,a,c=!1,n=0){const u=this.currentPoint;return this.absellipse(t+u.x,s+u.y,i,o,h,a,c,n),this}absellipse(t,s,i,o,h,a,c=!1,n=0){const u=new K(t,s,i,o,h,a,c,n);if(this.curves.length>0){const y=u.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(u),this.currentPoint.copy(u.getPoint(1)),this}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}copy(t){super.copy(t),this.curves=[];for(let s=0,i=t.curves.length;s<i;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}class I{constructor(e){b(this,"currentPath",new X);b(this,"paths",[this.currentPath]);b(this,"userData");e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){return this.currentPath.closePath(),this}moveTo(e,t){return this.currentPath=new X,this.paths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,i,o,h){return this.currentPath.bezierCurveTo(e,t,s,i,o,h),this}quadraticCurveTo(e,t,s,i){return this.currentPath.quadraticCurveTo(e,t,s,i),this}arc(e,t,s,i,o,h){return this.currentPath.absarc(e,t,s,i,o,!h),this}arcTo(e,t,s,i,o){const h=this.currentPath.currentPoint,a=h.x,c=h.y,n=e-a,u=t-c,y=s-e,p=i-t,x=Math.sqrt(n*n+u*u),g=Math.sqrt(y*y+p*p);if(x<o||g<o)return this.lineTo(s,i),this;const f={x:n/x,y:u/x},M={x:y/g,y:p/g},w=e-f.y*o,k=t+f.x*o,T=Math.atan2(f.y,f.x);let A=Math.atan2(M.y,M.x)-T;return A>Math.PI?A-=2*Math.PI:A<-Math.PI&&(A+=2*Math.PI),this.arc(w,k,o,T,T+A,!1),this.lineTo(s,i),this}ellipse(e,t,s,i,o,h,a,c){return this.currentPath.absellipse(e,t,s,i,h,a,!c,o),this}rect(e,t,s,i){return this.currentPath.rect(e,t,s,i),this}addCommands(e){return yt(e,this),this}addData(e){return this.addCommands(xt(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}forEachCurve(e){return this.paths.forEach(t=>t.curves.forEach(s=>e(s))),this}transform(e){return this.forEachCurve(t=>t.transform(e)),this}getMinMax(e=new l,t=new l){return this.forEachCurve(s=>s.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return{x:e.x,y:e.y,left:e.x,top:e.y,right:t.x,bottom:t.y,width:t.x-e.x,height:t.y-e.y}}getCommands(){return this.paths.flatMap(e=>e.curves.flatMap(t=>t.getCommands()))}getData(){return this.paths.map(e=>e.getData()).join(" ")}getSvgString(){const{x:e,y:t,width:s,height:i}=this.getBoundingBox();return`<svg viewBox="${e} ${t} ${s} ${i}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`}getSvgDataUri(){return`data:image/svg+xml;base64,${btoa(this.getSvgString())}`}drawTo(e){this.forEachCurve(t=>{t.drawTo(e)})}strokeTo(e){this.drawTo(e),e.stroke()}fillTo(e){this.drawTo(e),e.fill()}copy(e){return e.currentPath=this.currentPath.clone(),e.paths=this.paths.map(t=>t.clone()),e.userData=this.userData,this}clone(){return new I().copy(this)}}const _="px",ot=90,at=["mm","cm","in","pt","pc","px"],B={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function m(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,i=at.length;s<i;s++){const o=at[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&_!=="px"?t=B.in[_]/ot:(t=B[e][_],t<0&&(t=B[e].in*ot)),t*Number.parseFloat(r)}const Nt=new d,F=new d,ht=new d,ct=new d;function $t(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=Et(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Et(r){const e=new d,t=Nt;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(m(r.getAttribute("x")),m(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let i=s.length-1;i>=0;i--){const o=s[i].trim();if(o==="")continue;const h=o.indexOf("("),a=o.length;if(h>0&&h<a){const c=o.slice(0,h),n=S(o.slice(h+1));switch(t.identity(),c){case"translate":if(n.length>=1){const u=n[0];let y=0;n.length>=2&&(y=n[1]),t.translate(u,y)}break;case"rotate":if(n.length>=1){let u=0,y=0,p=0;u=n[0]*Math.PI/180,n.length>=3&&(y=n[1],p=n[2]),F.makeTranslation(-y,-p),ht.makeRotation(u),ct.multiplyMatrices(ht,F),F.makeTranslation(y,p),t.multiplyMatrices(F,ct)}break;case"scale":n.length>=1&&t.scale(n[0],n[1]??n[0]);break;case"skewX":n.length===1&&t.set(1,Math.tan(n[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":n.length===1&&t.set(1,0,0,Math.tan(n[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":n.length===6&&t.set(n[0],n[2],n[4],n[1],n[3],n[5],0,0,1);break}}e.premultiply(t)}}return e}function zt(r){return new I().addPath(new X().absarc(m(r.getAttribute("cx")||0),m(r.getAttribute("cy")||0),m(r.getAttribute("r")||0),0,Math.PI*2))}function qt(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const i=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<i.length;o++){const h=Object.fromEntries(Object.entries(s.style).filter(([,a])=>a!==""));e[i[o]]=Object.assign(e[i[o]]||{},h)}}}function Dt(r){return new I().addPath(new X().absellipse(m(r.getAttribute("cx")||0),m(r.getAttribute("cy")||0),m(r.getAttribute("rx")||0),m(r.getAttribute("ry")||0),0,Math.PI*2))}function Xt(r){return new I().moveTo(m(r.getAttribute("x1")||0),m(r.getAttribute("y1")||0)).lineTo(m(r.getAttribute("x2")||0),m(r.getAttribute("y2")||0))}function Ot(r){const e=new I,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Rt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Ft(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Rt,(i,o,h)=>{const a=m(o),c=m(h);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,i}),e.currentPath.autoClose=!0,e}const Yt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function _t(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Yt,(i,o,h)=>{const a=m(o),c=m(h);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,i}),e.currentPath.autoClose=!1,e}function Bt(r){const e=m(r.getAttribute("x")||0),t=m(r.getAttribute("y")||0),s=m(r.getAttribute("rx")||r.getAttribute("ry")||0),i=m(r.getAttribute("ry")||r.getAttribute("rx")||0),o=m(r.getAttribute("width")),h=m(r.getAttribute("height")),a=1-.551915024494,c=new I;return c.moveTo(e+s,t),c.lineTo(e+o-s,t),(s!==0||i!==0)&&c.bezierCurveTo(e+o-s*a,t,e+o,t+i*a,e+o,t+i),c.lineTo(e+o,t+h-i),(s!==0||i!==0)&&c.bezierCurveTo(e+o,t+h-i*a,e+o-s*a,t+h,e+o-s,t+h),c.lineTo(e+s,t+h),(s!==0||i!==0)&&c.bezierCurveTo(e+s*a,t+h,e,t+h-i*a,e,t+h-i),c.lineTo(e,t+i),(s!==0||i!==0)&&c.bezierCurveTo(e,t+i*a,e+s*a,t,e+s,t),c}function N(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const a=r.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<a.length;c++)s=Object.assign(s,t[`.${a[c]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function i(a,c,n){n===void 0&&(n=function(y){return y.startsWith("url")&&console.warn("url access in attributes is not implemented."),y}),r.hasAttribute(a)&&(e[c]=n(r.getAttribute(a))),s[a]&&(e[c]=n(s[a])),r.style&&r.style[a]!==""&&(e[c]=n(r.style[a]))}function o(a){return Math.max(0,Math.min(1,m(a)))}function h(a){return Math.max(0,m(a))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-dashoffset","strokeDashoffset"),i("stroke-dasharray","strokeDasharray"),i("stroke-linecap","strokeLineCap"),i("stroke-linejoin","strokeLineJoin"),i("stroke-miterlimit","strokeMiterLimit",h),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",h),i("visibility","visibility"),e}function G(r,e,t=[]){var u;if(r.nodeType!==1)return t;let s=!1,i=null;const o={};switch(r.nodeName){case"svg":e=N(r,e,o);break;case"style":qt(r,o);break;case"g":e=N(r,e,o);break;case"path":e=N(r,e,o),r.hasAttribute("d")&&(i=Ot(r));break;case"rect":e=N(r,e,o),i=Bt(r);break;case"polygon":e=N(r,e,o),i=Ft(r);break;case"polyline":e=N(r,e,o),i=_t(r);break;case"circle":e=N(r,e,o),i=zt(r);break;case"ellipse":e=N(r,e,o),i=Dt(r);break;case"line":e=N(r,e,o),i=Xt(r);break;case"defs":s=!0;break;case"use":{e=N(r,e,o);const p=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),x=(u=r.viewportElement)==null?void 0:u.getElementById(p);x?G(x,e,t):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(r);break}const h=new d,a=[],c=$t(r,h,a);i&&(i.transform(h),t.push(i),i.userData={node:r,style:e});const n=r.childNodes;for(let y=0,p=n.length;y<p;y++){const x=n[y];s&&x.nodeName!=="style"&&x.nodeName!=="defs"||G(x,e,t)}return c&&(a.pop(),a.length>0?h.copy(a[a.length-1]):h.identity()),t}function Gt(r){let e;return typeof r=="string"?e=new DOMParser().parseFromString(r,"image/svg+xml").documentElement:e=r,G(e,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4})}v.CircleCurve=O,v.CubicBezierCurve=j,v.Curve=L,v.CurvePath=X,v.EllipseCurve=K,v.HeartCurve=Lt,v.LineCurve=q,v.Matrix3=d,v.Path2D=I,v.PloygonCurve=St,v.Point2D=l,v.QuadraticBezierCurve=nt,v.RectangularCurve=it,v.SplineCurve=rt,v.parseSvg=Gt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(M=typeof globalThis<"u"?globalThis:M||self,u(M.modernPath2d={}))})(this,function(M){"use strict";var Vt=Object.defineProperty;var Bt=(M,u,S)=>u in M?Vt(M,u,{enumerable:!0,configurable:!0,writable:!0,value:S}):M[u]=S;var w=(M,u,S)=>Bt(M,typeof u!="symbol"?u+"":u,S);class u{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new u(1/0,1/0)}static get MIN(){return new u(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}multiplyScalar(e){return this.x*=e,this.y*=e,this}divideScalar(e){return this.multiplyScalar(1/e)}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}normalize(){return this.divideScalar(this.length()||1)}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const[t,s,i,o,h,a]=e.elements,{x:c,y:n}=this;return this.set(t*c+s*n+i,o*c+h*n+a),this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new u(this.x,this.y)}}class S{constructor(e=0,t=0,s=0,i=0){this.left=e,this.top=t,this.width=s,this.height=i}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){const t=e[0],s=e.slice(1).reduce((i,o)=>(i.left=Math.min(i.left,o.left),i.top=Math.min(i.top,o.top),i.right=Math.max(i.right,o.right),i.bottom=Math.max(i.bottom,o.bottom),i),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new S(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new u((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new S(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class k{constructor(e=1,t=0,s=0,i=0,o=1,h=0,a=0,c=0,n=1){w(this,"elements",[]);this.set(e,t,s,i,o,h,a,c,n)}set(e,t,s,i,o,h,a,c,n){const l=this.elements;return l[0]=e,l[1]=i,l[2]=a,l[3]=t,l[4]=o,l[5]=c,l[6]=s,l[7]=h,l[8]=n,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,o=this.elements,h=s[0],a=s[3],c=s[6],n=s[1],l=s[4],y=s[7],g=s[2],x=s[5],p=s[8],f=i[0],m=i[3],T=i[6],I=i[1],P=i[4],A=i[7],b=i[2],E=i[5],z=i[8];return o[0]=h*f+a*I+c*b,o[3]=h*m+a*P+c*E,o[6]=h*T+a*A+c*z,o[1]=n*f+l*I+y*b,o[4]=n*m+l*P+y*E,o[7]=n*T+l*A+y*z,o[2]=g*f+x*I+p*b,o[5]=g*m+x*P+p*E,o[8]=g*T+x*A+p*z,this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],o=e[3],h=e[4],a=e[5],c=e[6],n=e[7],l=e[8],y=l*h-a*n,g=a*c-l*o,x=n*o-h*c,p=t*y+s*g+i*x;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=y*f,e[1]=(i*n-l*s)*f,e[2]=(a*s-i*h)*f,e[3]=g*f,e[4]=(l*t-i*c)*f,e[5]=(i*o-a*t)*f,e[6]=x*f,e[7]=(s*c-n*t)*f,e[8]=(h*t-s*o)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(G.makeScale(e,t)),this}rotate(e){return this.premultiply(G.makeRotation(-e)),this}translate(e,t){return this.premultiply(G.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const G=new k;function B(r,e,t,s){const i=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let h=Math.acos(Math.max(-1,Math.min(1,i/o)));return r*s-e*t<0&&(h=-h),h}function yt(r,e,t,s,i,o,h,a){if(e===0||t===0){r.lineTo(a.x,a.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(h.x-a.x)/2,n=(h.y-a.y)/2,l=Math.cos(s)*c+Math.sin(s)*n,y=-Math.sin(s)*c+Math.cos(s)*n;let g=e*e,x=t*t;const p=l*l,f=y*y,m=p/g+f/x;if(m>1){const ut=Math.sqrt(m);e=ut*e,t=ut*t,g=e*e,x=t*t}const T=g*f+x*p,I=(g*x-T)/T;let P=Math.sqrt(Math.max(0,I));i===o&&(P=-P);const A=P*e*y/t,b=-P*t*l/e,E=Math.cos(s)*A-Math.sin(s)*b+(h.x+a.x)/2,z=Math.sin(s)*A+Math.cos(s)*b+(h.y+a.y)/2,Y=B(1,0,(l-A)/e,(y-b)/t),V=B((l-A)/e,(y-b)/t,(-l-A)/e,(-y-b)/t)%(Math.PI*2);r.currentPath.absellipse(E,z,e,t,Y,Y+V,o===0,s)}function D(r,e){return r-(e-r)}function pt(r,e){const t=new u,s=new u,i=new u;let o=!0,h=!1;for(let a=0,c=r.length;a<c;a++){const n=r[a];if(o&&(h=!0,o=!1),n.type==="m"||n.type==="M")n.type==="m"?(t.x+=n.x,t.y+=n.y):(t.x=n.x,t.y=n.y),s.x=t.x,s.y=t.y,e.moveTo(t.x,t.y),a===0&&i.copy(t);else if(n.type==="h"||n.type==="H")n.type==="h"?t.x+=n.x:t.x=n.x,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&i.copy(t);else if(n.type==="v"||n.type==="V")n.type==="v"?t.y+=n.y:t.y=n.y,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&i.copy(t);else if(n.type==="l"||n.type==="L")n.type==="l"?(t.x+=n.x,t.y+=n.y):(t.x=n.x,t.y=n.y),s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&i.copy(t);else if(n.type==="c"||n.type==="C")n.type==="c"?(e.bezierCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.x+=n.x,t.y+=n.y):(e.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.x=n.x,t.y=n.y),h&&i.copy(t);else if(n.type==="s"||n.type==="S")n.type==="s"?(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.x+=n.x,t.y+=n.y):(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.x=n.x,t.y=n.y),h&&i.copy(t);else if(n.type==="q"||n.type==="Q")n.type==="q"?(e.quadraticCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x,t.y+n.y),s.x=t.x+n.x1,s.y=t.y+n.y1,t.x+=n.x,t.y+=n.y):(e.quadraticCurveTo(n.x1,n.y1,n.x,n.y),s.x=n.x1,s.y=n.y1,t.x=n.x,t.y=n.y),h&&i.copy(t);else if(n.type==="t"||n.type==="T"){const l=D(t.x,s.x),y=D(t.y,s.y);s.x=l,s.y=y,n.type==="t"?(e.quadraticCurveTo(l,y,t.x+n.x,t.y+n.y),t.x+=n.x,t.y+=n.y):(e.quadraticCurveTo(l,y,n.x,n.y),t.x=n.x,t.y=n.y),h&&i.copy(t)}else if(n.type==="a"||n.type==="A"){if(n.type==="a"){if(n.x===0&&n.y===0)continue;t.x+=n.x,t.y+=n.y}else{if(n.x===t.x&&n.y===t.y)continue;t.x=n.x,t.y=n.y}const l=t.clone();s.x=t.x,s.y=t.y,yt(e,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,l,t),h&&i.copy(t)}else n.type==="z"||n.type==="Z"?(e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(t.copy(i),e.currentPath.currentPoint.copy(t),o=!0)):console.warn(n);h=!1}}const d={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function N(r,e,t=0){let a=0,c=!0,n="",l="";const y=[];function g(m,T,I){const P=new SyntaxError(`Unexpected character "${m}" at index ${T}.`);throw P.partial=I,P}function x(){n!==""&&(l===""?y.push(Number(n)):y.push(Number(n)*10**Number(l))),n="",l=""}let p;const f=r.length;for(let m=0;m<f;m++){if(p=r[m],Array.isArray(e)&&e.includes(y.length%t)&&d.FLAGS.test(p)){a=1,n=p,x();continue}if(a===0){if(d.WHITESPACE.test(p))continue;if(d.DIGIT.test(p)||d.SIGN.test(p)){a=1,n=p;continue}if(d.POINT.test(p)){a=2,n=p;continue}d.COMMA.test(p)&&(c&&g(p,m,y),c=!0)}if(a===1){if(d.DIGIT.test(p)){n+=p;continue}if(d.POINT.test(p)){n+=p,a=2;continue}if(d.EXP.test(p)){a=3;continue}d.SIGN.test(p)&&n.length===1&&d.SIGN.test(n[0])&&g(p,m,y)}if(a===2){if(d.DIGIT.test(p)){n+=p;continue}if(d.EXP.test(p)){a=3;continue}d.POINT.test(p)&&n[n.length-1]==="."&&g(p,m,y)}if(a===3){if(d.DIGIT.test(p)){l+=p;continue}if(d.SIGN.test(p)){if(l===""){l+=p;continue}l.length===1&&d.SIGN.test(l)&&g(p,m,y)}}d.WHITESPACE.test(p)?(x(),a=0,c=!1):d.COMMA.test(p)?(x(),a=0,c=!0):d.SIGN.test(p)?(x(),a=1,n=p):d.POINT.test(p)?(x(),a=2,n=p):g(p,m,y)}return x(),y}function gt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function ft(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${gt(r[t])} `;return e}const xt=/[a-df-z][^a-df-z]*/gi;function Mt(r){const e=[],t=r.match(xt);if(!t)return e;for(let s=0,i=t.length;s<i;s++){const o=t[s],h=o.charAt(0),a=o.slice(1).trim();let c;switch(h){case"m":case"M":c=N(a);for(let n=0,l=c.length;n<l;n+=2)n===0?e.push({type:h,x:c[n],y:c[n+1]}):e.push({type:h==="m"?"l":"L",x:c[n],y:c[n+1]});break;case"h":case"H":c=N(a);for(let n=0,l=c.length;n<l;n++)e.push({type:h,x:c[n]});break;case"v":case"V":c=N(a);for(let n=0,l=c.length;n<l;n++)e.push({type:h,y:c[n]});break;case"l":case"L":c=N(a);for(let n=0,l=c.length;n<l;n+=2)e.push({type:h,x:c[n],y:c[n+1]});break;case"c":case"C":c=N(a);for(let n=0,l=c.length;n<l;n+=6)e.push({type:h,x1:c[n],y1:c[n+1],x2:c[n+2],y2:c[n+3],x:c[n+4],y:c[n+5]});break;case"s":case"S":c=N(a);for(let n=0,l=c.length;n<l;n+=4)e.push({type:h,x2:c[n],y2:c[n+1],x:c[n+2],y:c[n+3]});break;case"q":case"Q":c=N(a);for(let n=0,l=c.length;n<l;n+=4)e.push({type:h,x1:c[n],y1:c[n+1],x:c[n+2],y:c[n+3]});break;case"t":case"T":c=N(a);for(let n=0,l=c.length;n<l;n+=2)e.push({type:h,x:c[n],y:c[n+1]});break;case"a":case"A":c=N(a,[3,4],7);for(let n=0,l=c.length;n<l;n+=7)e.push({type:h,rx:c[n],ry:c[n+1],angle:c[n+2],largeArcFlag:c[n+3],sweepFlag:c[n+4],x:c[n+5],y:c[n+6]});break;case"z":case"Z":e.push({type:h});break;default:console.warn(o)}}return e}class L{constructor(){w(this,"arcLengthDivisions",200);w(this,"_cacheArcLengths");w(this,"_needsUpdate",!1)}getPointAt(e,t=new u){return this.getPoint(this.getUtoTmapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,i=this.getPoint(0),o=0;t.push(0);for(let h=1;h<=e;h++)s=this.getPoint(h/e),o+=s.distanceTo(i),t.push(o),i=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let i=0;const o=s.length;let h;t?h=t:h=e*s[o-1];let a=0,c=o-1,n;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),n=s[i]-h,n<0)a=i+1;else if(n>0)c=i-1;else{c=i;break}if(i=c,s[i]===h)return i/(o-1);const l=s[i],g=s[i+1]-l,x=(h-l)/g;return(i+x)/(o-1)}getTangent(e,t=new u){let i=e-1e-4,o=e+1e-4;return i<0&&(i=0),o>1&&(o=1),t.copy(this.getPoint(o)).sub(this.getPoint(i)).normalize()}getTangentAt(e,t=new u){return this.getTangent(this.getUtoTmapping(e),t)}transform(e){return this}getDivisions(e){return e}getMinMax(e=u.MAX,t=u.MIN){return{min:e,max:t}}getCommands(){return[]}getData(){return ft(this.getCommands())}drawTo(e){return this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class O extends L{constructor(e,t,s=0,i=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=i}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().multiplyScalar(t))}getTangent(e){const{x:t,y:s}=this.getNormal(e);return new u(-s,t)}getNormal(e){const{start:t,end:s}=this,i=e*(s-t)+t-.5*Math.PI;return new u(Math.cos(i),Math.sin(i))}getMinMax(e=u.MAX,t=u.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function H(r,e,t,s,i){const o=(s-e)*.5,h=(i-t)*.5,a=r*r,c=r*a;return(2*t-2*s+o+h)*c+(-3*t+3*s-2*o-h)*a+o*r+t}function mt(r,e){const t=1-r;return t*t*e}function vt(r,e){return 2*(1-r)*r*e}function dt(r,e){return r*r*e}function W(r,e,t,s){return mt(r,e)+vt(r,t)+dt(r,s)}function Pt(r,e){const t=1-r;return t*t*t*e}function Tt(r,e){const t=1-r;return 3*t*t*r*e}function wt(r,e){return 3*(1-r)*r*r*e}function bt(r,e){return r*r*r*e}function j(r,e,t,s,i){return Pt(r,e)+Tt(r,t)+wt(r,s)+bt(r,i)}class Z extends L{constructor(e=new u,t=new u,s=new u,i=new u){super(),this.v0=e,this.v1=t,this.v2=s,this.v3=i}getPoint(e,t=new u){const{v0:s,v1:i,v2:o,v3:h}=this;return t.set(j(e,s.x,i.x,o.x,h.x),j(e,s.y,i.y,o.y,h.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this.v3.applyMatrix3(e),this}getMinMax(e=u.MAX,t=u.MIN){const{v0:s,v1:i,v2:o,v3:h}=this;return e.x=Math.min(e.x,s.x,i.x,o.x,h.x),e.y=Math.min(e.y,s.y,i.y,o.y,h.y),t.x=Math.max(t.x,s.x,i.x,o.x,h.x),t.y=Math.max(t.y,s.y,i.y,o.y,h.y),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s,v3:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:i.x,y:i.y}]}drawTo(e){const{v0:t,v1:s,v2:i,v3:o}=this;return e.moveTo(t.x,t.y),e.bezierCurveTo(s.x,s.y,i.x,i.y,o.x,o.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}}const At=new k,J=new k,K=new k,R=new u;class tt extends L{constructor(e=0,t=0,s=1,i=1,o=0,h=Math.PI*2,a=!1,c=0){super(),this.x=e,this.y=t,this.radiusX=s,this.radiusY=i,this.startAngle=o,this.endAngle=h,this.clockwise=a,this.rotation=c}getPoint(e,t=new u){const s=Math.PI*2;let i=this.endAngle-this.startAngle;const o=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=s;for(;i>s;)i-=s;i<Number.EPSILON&&(o?i=0:i=s),this.clockwise&&!o&&(i===s?i=-s:i=i-s);const h=this.startAngle+e*i;let a=this.x+this.radiusX*Math.cos(h),c=this.y+this.radiusY*Math.sin(h);if(this.rotation!==0){const n=Math.cos(this.rotation),l=Math.sin(this.rotation),y=a-this.x,g=c-this.y;a=y*n-g*l+this.x,c=y*l+g*n+this.y}return t.set(a,c)}getDivisions(e=12){return e*2}getCommands(){const{x:e,y:t,radiusX:s,radiusY:i,startAngle:o,endAngle:h,clockwise:a}=this,c=!a,n=e+s*Math.cos(o),l=t+i*Math.sin(o),y=e+s*Math.cos(h),g=t+i*Math.sin(h),x=Math.abs(o-h),p=x>Math.PI?1:0,f=c?0:1,m=e+s*Math.cos(o+(h-o)/2),T=t+i*Math.sin(o+(h-o)/2);return x>=2*Math.PI?[{type:"M",x:n,y:l},{type:"A",rx:s,ry:i,angle:0,largeArcFlag:1,sweepFlag:f,x:m,y:T},{type:"A",rx:s,ry:i,angle:0,largeArcFlag:1,sweepFlag:f,x:n,y:l}]:[{type:"M",x:n,y:l},{type:"A",rx:s,ry:i,angle:0,largeArcFlag:p,sweepFlag:f,x:y,y:g}]}drawTo(e){const{x:t,y:s,radiusX:i,radiusY:o,rotation:h,startAngle:a,endAngle:c,clockwise:n}=this,l=t+i*Math.cos(a),y=s+o*Math.sin(a);return e.moveTo(l,y),e.ellipse(t,s,i,o,h,a,c,!n),this}transform(e){return R.set(this.x,this.y),R.applyMatrix3(e),this.x=R.x,this.y=R.y,kt(e)?Ct(this,e):It(this,e),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function Ct(r,e){const t=r.radiusX,s=r.radiusY,i=Math.cos(r.rotation),o=Math.sin(r.rotation),h=new u(t*i,t*o),a=new u(-s*o,s*i),c=h.applyMatrix3(e),n=a.applyMatrix3(e),l=At.set(c.x,n.x,0,c.y,n.y,0,0,0,1),y=J.copy(l).invert(),p=K.copy(y).transpose().multiply(y).elements,f=Lt(p[0],p[1],p[4]),m=Math.sqrt(f.rt1),T=Math.sqrt(f.rt2);if(r.radiusX=1/m,r.radiusY=1/T,r.rotation=Math.atan2(f.sn,f.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=J.set(m,0,0,0,T,0,0,0,1),A=K.set(f.cs,f.sn,0,-f.sn,f.cs,0,0,0,1),b=P.multiply(A).multiply(l),E=z=>{const{x:Y,y:V}=new u(Math.cos(z),Math.sin(z)).applyMatrix3(b);return Math.atan2(V,Y)};r.startAngle=E(r.startAngle),r.endAngle=E(r.endAngle),et(e)&&(r.clockwise=!r.clockwise)}}function It(r,e){const t=st(e),s=nt(e);r.radiusX*=t,r.radiusY*=s;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=i,et(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function et(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function kt(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=st(r),i=nt(r);return Math.abs(t/(s*i))>Number.EPSILON}function st(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function nt(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Lt(r,e,t){let s,i,o,h,a;const c=r+t,n=r-t,l=Math.sqrt(n*n+4*e*e);return c>0?(s=.5*(c+l),a=1/s,i=r*a*t-e*a*e):c<0?i=.5*(c-l):(s=.5*l,i=-.5*l),n>0?o=n+l:o=n-l,Math.abs(o)>2*Math.abs(e)?(a=-2*e/o,h=1/Math.sqrt(1+a*a),o=a*h):Math.abs(e)===0?(o=1,h=0):(a=-.5*o/e,o=1/Math.sqrt(1+a*a),h=a*o),n>0&&(a=o,o=-h,h=a),{rt1:s,rt2:i,cs:o,sn:h}}class q extends L{constructor(e=new u,t=new u){super(),this.v1=e,this.v2=t}getPoint(e,t=new u){return e===1?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t=new u){return this.getPoint(e,t)}getTangent(e,t=new u){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t=new u){return this.getTangent(e,t)}transform(e){return this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getDivisions(){return 1}getMinMax(e=u.MAX,t=u.MIN){const{v1:s,v2:i}=this;return e.x=Math.min(e.x,s.x,i.x),e.y=Math.min(e.y,s.y,i.y),t.x=Math.max(t.x,s.x,i.x),t.y=Math.max(t.y,s.y,i.y),{min:e,max:t}}getCommands(){const{v1:e,v2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{v1:t,v2:s}=this;return e.moveTo(t.x,t.y),e.lineTo(s.x,s.y),this}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class St extends L{constructor(t,s,i=0,o=1){super();w(this,"curves");w(this,"pointT",0);this.center=t,this.size=s,this.start=i,this.end=o;const{x:h,y:a}=this.center,c=new u(h+.5*this.size,a-.5*this.size),n=new u(h-.5*this.size,a-.5*this.size),l=new u(h,a+.5*this.size),y=new O(c,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),g=new O(n,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),x=new O(l,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),p=new u(h,a+this.size),f=new u(h+this.size,a),m=new u().lerpVectors(f,p,.75),T=new u(h-this.size,a),I=new u().lerpVectors(T,p,.75),P=new q(f,m),A=new q(I,T);this.curves=[y,P,x,A,g]}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let i;const o=.5*Math.PI;return s<o?(i=0,this.pointT=s/o):s<o+.75?(i=1,this.pointT=(s-o)/.75):s<5*Math.PI/8+.75?(i=2,this.pointT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(i=3,this.pointT=(s-5*Math.PI/8-.75)/.75):(i=4,this.pointT=(s-5*Math.PI/8-1.5)/o),this.curves[i]}getTangent(t){return this.getCurrentLine(t).getTangent(this.pointT).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new u(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class Nt extends L{constructor(t,s=0,i=0,o=0,h=1){super();w(this,"curves",[]);w(this,"points",[]);this.center=t,this.radius=s,this.num=i,this.start=o,this.end=h;for(let a=0;a<this.num;a++){let c=a*2*Math.PI/this.num;c-=.5*Math.PI;const n=new u(this.radius*Math.cos(c),this.radius*Math.sin(c));n.add(this.center),this.points.push(n)}for(let a=0;a<this.num;a++)this.curves.push(new q(this.points[a],this.points[(a+1)%this.num]))}getPoint(t){return this.getCurrentLine(t),this.currentLine.getPoint(this.pointK)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const i=s*this.num,o=Math.floor(i);return this.pointK=i-o,this.currentLine=this.curves[o],this.currentLine}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new u(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class it extends L{constructor(e=new u,t=new u,s=new u){super(),this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new u){const{v0:s,v1:i,v2:o}=this;return t.set(W(e,s.x,i.x,o.x),W(e,s.y,i.y,o.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getMinMax(e=u.MAX,t=u.MIN){const{v0:s,v1:i,v2:o}=this,h=.5*(s.x+i.x),a=.5*(s.y+i.y),c=.5*(s.x+o.x),n=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,h,c),e.y=Math.min(e.y,s.y,o.y,a,n),t.x=Math.max(t.x,s.x,o.x,h,c),t.y=Math.max(t.y,s.y,o.y,a,n),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{v0:t,v1:s,v2:i}=this;return e.moveTo(t.x,t.y),e.quadraticCurveTo(s.x,s.y,i.x,i.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class rt extends L{constructor(t,s,i=1,o=0,h=1){super();w(this,"curves",[]);w(this,"pointT",0);this.center=t,this.rx=s,this.aspectRatio=i,this.start=o,this.end=h;const{x:a,y:c}=this.center,n=this.rx,l=this.rx/this.aspectRatio,y=[new u(a-n,c-l),new u(a+n,c-l),new u(a+n,c+l),new u(a-n,c+l)];for(let g=0;g<4;g++)this.curves.push(new q(y[g],y[(g+1)%4]))}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let i;return s<this.aspectRatio?(i=0,this.pointT=s/this.aspectRatio):s<this.aspectRatio+1?(i=1,this.pointT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(i=2,this.pointT=(s-this.aspectRatio-1)/this.aspectRatio):(i=3,this.pointT=(s-2*this.aspectRatio-1)/1),this.curves[i]}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const{v1:s,v2:i}=this.getCurrentLine(t);return new u(i.y-s.y,-(i.x-s.x)).normalize()}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ot extends L{constructor(e=[]){super(),this.points=e}getDivisions(e=12){return e*this.points.length}getPoint(e,t=new u){const{points:s}=this,i=(s.length-1)*e,o=Math.floor(i),h=i-o,a=s[o===0?o:o-1],c=s[o],n=s[o>s.length-2?s.length-1:o+1],l=s[o>s.length-3?s.length-1:o+2];return t.set(H(h,a.x,c.x,n.x,l.x),H(h,a.y,c.y,n.y,l.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class X extends L{constructor(t){super();w(this,"curves",[]);w(this,"currentPoint",new u);w(this,"autoClose",!1);w(this,"_cacheLengths",[]);t&&this.setFromPoints(t)}addCurve(t){return this.curves.push(t),this}closePath(){const t=this.curves[0].getPoint(0),s=this.curves[this.curves.length-1].getPoint(1);return t.equals(s)||this.curves.push(new q(s,t)),this}getPoint(t,s=new u){const i=t*this.getLength(),o=this.getCurveLengths();let h=0;for(;h<o.length;){if(o[h]>=i){const a=o[h]-i,c=this.curves[h],n=c.getLength();return c.getPointAt(n===0?0:1-a/n,s)}h++}return s}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let i=0,o=this.curves.length;i<o;i++)s+=this.curves[i].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let i=0;i<=t;i++)s.push(this.getPoint(i/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[];let i;for(let o=0,h=this.curves;o<h.length;o++){const a=h[o],c=a.getPoints(a.getDivisions(t));for(let n=0;n<c.length;n++){const l=c[n];i&&i.equals(l)||(s.push(l),i=l)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,i=t.length;s<i;s++)this.lineTo(t[s].x,t[s].y);return this}bezierCurveTo(t,s,i,o,h,a){return this.curves.push(new Z(this.currentPoint.clone(),new u(t,s),new u(i,o),new u(h,a))),this.currentPoint.set(h,a),this}lineTo(t,s){const i=new q(this.currentPoint.clone(),new u(t,s));return this.curves.push(i),this.currentPoint.set(t,s),this}moveTo(t,s){return this.currentPoint.set(t,s),this}quadraticCurveTo(t,s,i,o){return this.curves.push(new it(this.currentPoint.clone(),new u(t,s),new u(i,o))),this.currentPoint.set(i,o),this}rect(t,s,i,o){return this.curves.push(new rt(new u(t+i/2,s+o/2),i/2,i/o)),this.currentPoint.set(t,s),this}splineThru(t){const s=[this.currentPoint.clone()].concat(t);return this.curves.push(new ot(s)),this.currentPoint.copy(t[t.length-1]),this}arc(t,s,i,o,h,a=!1){const c=this.currentPoint;return this.absarc(t+c.x,s+c.y,i,o,h,a),this}absarc(t,s,i,o,h,a=!1){return this.absellipse(t,s,i,i,o,h,a),this}ellipse(t,s,i,o,h,a,c=!1,n=0){const l=this.currentPoint;return this.absellipse(t+l.x,s+l.y,i,o,h,a,c,n),this}absellipse(t,s,i,o,h,a,c=!1,n=0){const l=new tt(t,s,i,o,h,a,c,n);if(this.curves.length>0){const y=l.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(l),this.currentPoint.copy(l.getPoint(1)),this}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}copy(t){super.copy(t),this.curves=[];for(let s=0,i=t.curves.length;s<i;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}class C{constructor(e){w(this,"currentPath",new X);w(this,"paths",[this.currentPath]);w(this,"userData");e&&(e instanceof C?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}addPath(e){return e instanceof C?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){return this.currentPath.closePath(),this}moveTo(e,t){return this.currentPath=new X,this.paths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,i,o,h){return this.currentPath.bezierCurveTo(e,t,s,i,o,h),this}quadraticCurveTo(e,t,s,i){return this.currentPath.quadraticCurveTo(e,t,s,i),this}arc(e,t,s,i,o,h){return this.currentPath.absarc(e,t,s,i,o,!h),this}arcTo(e,t,s,i,o){const h=this.currentPath.currentPoint,a=h.x,c=h.y,n=e-a,l=t-c,y=s-e,g=i-t,x=Math.sqrt(n*n+l*l),p=Math.sqrt(y*y+g*g);if(x<o||p<o)return this.lineTo(s,i),this;const f={x:n/x,y:l/x},m={x:y/p,y:g/p},T=e-f.y*o,I=t+f.x*o,P=Math.atan2(f.y,f.x);let b=Math.atan2(m.y,m.x)-P;return b>Math.PI?b-=2*Math.PI:b<-Math.PI&&(b+=2*Math.PI),this.arc(T,I,o,P,P+b,!1),this.lineTo(s,i),this}ellipse(e,t,s,i,o,h,a,c){return this.currentPath.absellipse(e,t,s,i,h,a,!c,o),this}rect(e,t,s,i){return this.currentPath.rect(e,t,s,i),this}addCommands(e){return pt(e,this),this}addData(e){return this.addCommands(Mt(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}forEachCurve(e){return this.paths.forEach(t=>t.curves.forEach(s=>e(s))),this}transform(e){return this.forEachCurve(t=>t.transform(e)),this}getMinMax(e=new u,t=new u){return this.forEachCurve(s=>s.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new S(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return this.paths.flatMap(e=>e.curves.flatMap(t=>t.getCommands()))}getData(){return this.paths.map(e=>e.getData()).join(" ")}getSvgString(){const{x:e,y:t,width:s,height:i}=this.getBoundingBox();return`<svg viewBox="${e} ${t} ${s} ${i}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`}getSvgDataUri(){return`data:image/svg+xml;base64,${btoa(this.getSvgString())}`}drawTo(e){this.forEachCurve(t=>{t.drawTo(e)})}strokeTo(e){this.drawTo(e),e.stroke()}fillTo(e){this.drawTo(e),e.fill()}copy(e){return e.currentPath=this.currentPath.clone(),e.paths=this.paths.map(t=>t.clone()),e.userData=this.userData,this}clone(){return new C().copy(this)}}const _="px",at=90,ht=["mm","cm","in","pt","pc","px"],Q={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function v(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,i=ht.length;s<i;s++){const o=ht[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&_!=="px"?t=Q.in[_]/at:(t=Q[e][_],t<0&&(t=Q[e].in*at)),t*Number.parseFloat(r)}const $t=new k,F=new k,ct=new k,lt=new k;function Et(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=zt(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function zt(r){const e=new k,t=$t;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(v(r.getAttribute("x")),v(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let i=s.length-1;i>=0;i--){const o=s[i].trim();if(o==="")continue;const h=o.indexOf("("),a=o.length;if(h>0&&h<a){const c=o.slice(0,h),n=N(o.slice(h+1));switch(t.identity(),c){case"translate":if(n.length>=1){const l=n[0];let y=0;n.length>=2&&(y=n[1]),t.translate(l,y)}break;case"rotate":if(n.length>=1){let l=0,y=0,g=0;l=n[0]*Math.PI/180,n.length>=3&&(y=n[1],g=n[2]),F.makeTranslation(-y,-g),ct.makeRotation(l),lt.multiplyMatrices(ct,F),F.makeTranslation(y,g),t.multiplyMatrices(F,lt)}break;case"scale":n.length>=1&&t.scale(n[0],n[1]??n[0]);break;case"skewX":n.length===1&&t.set(1,Math.tan(n[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":n.length===1&&t.set(1,0,0,Math.tan(n[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":n.length===6&&t.set(n[0],n[2],n[4],n[1],n[3],n[5],0,0,1);break}}e.premultiply(t)}}return e}function qt(r){return new C().addPath(new X().absarc(v(r.getAttribute("cx")||0),v(r.getAttribute("cy")||0),v(r.getAttribute("r")||0),0,Math.PI*2))}function Dt(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const i=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<i.length;o++){const h=Object.fromEntries(Object.entries(s.style).filter(([,a])=>a!==""));e[i[o]]=Object.assign(e[i[o]]||{},h)}}}function Xt(r){return new C().addPath(new X().absellipse(v(r.getAttribute("cx")||0),v(r.getAttribute("cy")||0),v(r.getAttribute("rx")||0),v(r.getAttribute("ry")||0),0,Math.PI*2))}function Ot(r){return new C().moveTo(v(r.getAttribute("x1")||0),v(r.getAttribute("y1")||0)).lineTo(v(r.getAttribute("x2")||0),v(r.getAttribute("y2")||0))}function Rt(r){const e=new C,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Ft=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Yt(r){var s;const e=new C;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Ft,(i,o,h)=>{const a=v(o),c=v(h);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,i}),e.currentPath.autoClose=!0,e}const Gt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function _t(r){var s;const e=new C;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Gt,(i,o,h)=>{const a=v(o),c=v(h);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,i}),e.currentPath.autoClose=!1,e}function Qt(r){const e=v(r.getAttribute("x")||0),t=v(r.getAttribute("y")||0),s=v(r.getAttribute("rx")||r.getAttribute("ry")||0),i=v(r.getAttribute("ry")||r.getAttribute("rx")||0),o=v(r.getAttribute("width")),h=v(r.getAttribute("height")),a=1-.551915024494,c=new C;return c.moveTo(e+s,t),c.lineTo(e+o-s,t),(s!==0||i!==0)&&c.bezierCurveTo(e+o-s*a,t,e+o,t+i*a,e+o,t+i),c.lineTo(e+o,t+h-i),(s!==0||i!==0)&&c.bezierCurveTo(e+o,t+h-i*a,e+o-s*a,t+h,e+o-s,t+h),c.lineTo(e+s,t+h),(s!==0||i!==0)&&c.bezierCurveTo(e+s*a,t+h,e,t+h-i*a,e,t+h-i),c.lineTo(e,t+i),(s!==0||i!==0)&&c.bezierCurveTo(e,t+i*a,e+s*a,t,e+s,t),c}function $(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const a=r.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<a.length;c++)s=Object.assign(s,t[`.${a[c]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function i(a,c,n){n===void 0&&(n=function(y){return y.startsWith("url")&&console.warn("url access in attributes is not implemented."),y}),r.hasAttribute(a)&&(e[c]=n(r.getAttribute(a))),s[a]&&(e[c]=n(s[a])),r.style&&r.style[a]!==""&&(e[c]=n(r.style[a]))}function o(a){return Math.max(0,Math.min(1,v(a)))}function h(a){return Math.max(0,v(a))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-dashoffset","strokeDashoffset"),i("stroke-dasharray","strokeDasharray"),i("stroke-linecap","strokeLineCap"),i("stroke-linejoin","strokeLineJoin"),i("stroke-miterlimit","strokeMiterLimit",h),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",h),i("visibility","visibility"),e}function U(r,e,t=[]){var l;if(r.nodeType!==1)return t;let s=!1,i=null;const o={};switch(r.nodeName){case"svg":e=$(r,e,o);break;case"style":Dt(r,o);break;case"g":e=$(r,e,o);break;case"path":e=$(r,e,o),r.hasAttribute("d")&&(i=Rt(r));break;case"rect":e=$(r,e,o),i=Qt(r);break;case"polygon":e=$(r,e,o),i=Yt(r);break;case"polyline":e=$(r,e,o),i=_t(r);break;case"circle":e=$(r,e,o),i=qt(r);break;case"ellipse":e=$(r,e,o),i=Xt(r);break;case"line":e=$(r,e,o),i=Ot(r);break;case"defs":s=!0;break;case"use":{e=$(r,e,o);const g=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),x=(l=r.viewportElement)==null?void 0:l.getElementById(g);x?U(x,e,t):console.warn(`'use node' references non-existent node id: ${g}`);break}default:console.warn(r);break}const h=new k,a=[],c=Et(r,h,a);i&&(i.transform(h),t.push(i),i.userData={node:r,style:e});const n=r.childNodes;for(let y=0,g=n.length;y<g;y++){const x=n[y];s&&x.nodeName!=="style"&&x.nodeName!=="defs"||U(x,e,t)}return c&&(a.pop(),a.length>0?h.copy(a[a.length-1]):h.identity()),t}function Ut(r){let e;return typeof r=="string"?e=new DOMParser().parseFromString(r,"image/svg+xml").documentElement:e=r,U(e,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4})}M.BoundingBox=S,M.CircleCurve=O,M.CubicBezierCurve=Z,M.Curve=L,M.CurvePath=X,M.EllipseCurve=tt,M.HeartCurve=St,M.LineCurve=q,M.Matrix3=k,M.Path2D=C,M.PloygonCurve=Nt,M.Point2D=u,M.QuadraticBezierCurve=it,M.RectangularCurve=rt,M.SplineCurve=ot,M.parseSvg=Ut,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1,3 +1,143 @@
1
+ class Point2D {
2
+ constructor(x = 0, y = 0) {
3
+ this.x = x;
4
+ this.y = y;
5
+ }
6
+ static get MAX() {
7
+ return new Point2D(Infinity, Infinity);
8
+ }
9
+ static get MIN() {
10
+ return new Point2D(-Infinity, -Infinity);
11
+ }
12
+ set(x, y) {
13
+ this.x = x;
14
+ this.y = y;
15
+ return this;
16
+ }
17
+ add(point) {
18
+ this.x += point.x;
19
+ this.y += point.y;
20
+ return this;
21
+ }
22
+ sub(point) {
23
+ this.x -= point.x;
24
+ this.y -= point.y;
25
+ return this;
26
+ }
27
+ distanceTo(point) {
28
+ return Math.sqrt(this.distanceToSquared(point));
29
+ }
30
+ distanceToSquared(point) {
31
+ const dx = this.x - point.x;
32
+ const dy = this.y - point.y;
33
+ return dx * dx + dy * dy;
34
+ }
35
+ length() {
36
+ return Math.sqrt(this.x * this.x + this.y * this.y);
37
+ }
38
+ multiplyScalar(scalar) {
39
+ this.x *= scalar;
40
+ this.y *= scalar;
41
+ return this;
42
+ }
43
+ divideScalar(scalar) {
44
+ return this.multiplyScalar(1 / scalar);
45
+ }
46
+ subVectors(a, b) {
47
+ this.x = a.x - b.x;
48
+ this.y = a.y - b.y;
49
+ return this;
50
+ }
51
+ normalize() {
52
+ return this.divideScalar(this.length() || 1);
53
+ }
54
+ lerpVectors(v1, v2, alpha) {
55
+ this.x = v1.x + (v2.x - v1.x) * alpha;
56
+ this.y = v1.y + (v2.y - v1.y) * alpha;
57
+ return this;
58
+ }
59
+ equals(point) {
60
+ return this.x === point.x && this.y === point.y;
61
+ }
62
+ applyMatrix3(matrix3) {
63
+ const [a, c, tx, b, d, ty] = matrix3.elements;
64
+ const { x, y } = this;
65
+ this.set(
66
+ a * x + c * y + tx,
67
+ b * x + d * y + ty
68
+ );
69
+ return this;
70
+ }
71
+ copy(point) {
72
+ this.x = point.x;
73
+ this.y = point.y;
74
+ return this;
75
+ }
76
+ clone() {
77
+ return new Point2D(this.x, this.y);
78
+ }
79
+ }
80
+
81
+ class BoundingBox {
82
+ constructor(left = 0, top = 0, width = 0, height = 0) {
83
+ this.left = left;
84
+ this.top = top;
85
+ this.width = width;
86
+ this.height = height;
87
+ }
88
+ get x() {
89
+ return this.left;
90
+ }
91
+ set x(val) {
92
+ this.left = val;
93
+ }
94
+ get y() {
95
+ return this.top;
96
+ }
97
+ set y(val) {
98
+ this.top = val;
99
+ }
100
+ get right() {
101
+ return this.left + this.width;
102
+ }
103
+ get bottom() {
104
+ return this.top + this.height;
105
+ }
106
+ static from(...boxes) {
107
+ const firstBox = boxes[0];
108
+ const merged = boxes.slice(1).reduce(
109
+ (merged2, box) => {
110
+ merged2.left = Math.min(merged2.left, box.left);
111
+ merged2.top = Math.min(merged2.top, box.top);
112
+ merged2.right = Math.max(merged2.right, box.right);
113
+ merged2.bottom = Math.max(merged2.bottom, box.bottom);
114
+ return merged2;
115
+ },
116
+ {
117
+ left: firstBox?.left ?? 0,
118
+ top: firstBox?.top ?? 0,
119
+ right: firstBox?.right ?? 0,
120
+ bottom: firstBox?.bottom ?? 0
121
+ }
122
+ );
123
+ return new BoundingBox(merged.left, merged.top, merged.right - merged.left, merged.bottom - merged.top);
124
+ }
125
+ translate(tx, ty) {
126
+ this.left += tx;
127
+ this.top += ty;
128
+ return this;
129
+ }
130
+ getCenterPoint() {
131
+ return new Point2D((this.left + this.right) / 2, (this.top + this.bottom) / 2);
132
+ }
133
+ clone() {
134
+ return new BoundingBox(this.left, this.top, this.width, this.height);
135
+ }
136
+ toArray() {
137
+ return [this.left, this.top, this.width, this.height];
138
+ }
139
+ }
140
+
1
141
  var __defProp$6 = Object.defineProperty;
2
142
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
143
  var __publicField$6 = (obj, key, value) => {
@@ -200,86 +340,6 @@ class Matrix3 {
200
340
  }
201
341
  const _m3 = /* @__PURE__ */ new Matrix3();
202
342
 
203
- class Point2D {
204
- constructor(x = 0, y = 0) {
205
- this.x = x;
206
- this.y = y;
207
- }
208
- static get MAX() {
209
- return new Point2D(Infinity, Infinity);
210
- }
211
- static get MIN() {
212
- return new Point2D(-Infinity, -Infinity);
213
- }
214
- set(x, y) {
215
- this.x = x;
216
- this.y = y;
217
- return this;
218
- }
219
- add(point) {
220
- this.x += point.x;
221
- this.y += point.y;
222
- return this;
223
- }
224
- sub(point) {
225
- this.x -= point.x;
226
- this.y -= point.y;
227
- return this;
228
- }
229
- distanceTo(point) {
230
- return Math.sqrt(this.distanceToSquared(point));
231
- }
232
- distanceToSquared(point) {
233
- const dx = this.x - point.x;
234
- const dy = this.y - point.y;
235
- return dx * dx + dy * dy;
236
- }
237
- length() {
238
- return Math.sqrt(this.x * this.x + this.y * this.y);
239
- }
240
- multiplyScalar(scalar) {
241
- this.x *= scalar;
242
- this.y *= scalar;
243
- return this;
244
- }
245
- divideScalar(scalar) {
246
- return this.multiplyScalar(1 / scalar);
247
- }
248
- subVectors(a, b) {
249
- this.x = a.x - b.x;
250
- this.y = a.y - b.y;
251
- return this;
252
- }
253
- normalize() {
254
- return this.divideScalar(this.length() || 1);
255
- }
256
- lerpVectors(v1, v2, alpha) {
257
- this.x = v1.x + (v2.x - v1.x) * alpha;
258
- this.y = v1.y + (v2.y - v1.y) * alpha;
259
- return this;
260
- }
261
- equals(point) {
262
- return this.x === point.x && this.y === point.y;
263
- }
264
- applyMatrix3(matrix3) {
265
- const [a, c, tx, b, d, ty] = matrix3.elements;
266
- const { x, y } = this;
267
- this.set(
268
- a * x + c * y + tx,
269
- b * x + d * y + ty
270
- );
271
- return this;
272
- }
273
- copy(point) {
274
- this.x = point.x;
275
- this.y = point.y;
276
- return this;
277
- }
278
- clone() {
279
- return new Point2D(this.x, this.y);
280
- }
281
- }
282
-
283
343
  function svgAngle(ux, uy, vx, vy) {
284
344
  const dot = ux * vx + uy * vy;
285
345
  const len = Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);
@@ -2065,16 +2125,12 @@ class Path2D {
2065
2125
  }
2066
2126
  getBoundingBox() {
2067
2127
  const { min, max } = this.getMinMax();
2068
- return {
2069
- x: min.x,
2070
- y: min.y,
2071
- left: min.x,
2072
- top: min.y,
2073
- right: max.x,
2074
- bottom: max.y,
2075
- width: max.x - min.x,
2076
- height: max.y - min.y
2077
- };
2128
+ return new BoundingBox(
2129
+ min.x,
2130
+ min.y,
2131
+ max.x - min.x,
2132
+ max.y - min.y
2133
+ );
2078
2134
  }
2079
2135
  getCommands() {
2080
2136
  return this.paths.flatMap((path) => path.curves.flatMap((curve) => curve.getCommands()));
@@ -2620,4 +2676,4 @@ function parseSvg(svg) {
2620
2676
  });
2621
2677
  }
2622
2678
 
2623
- export { CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
2679
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "description": "A modern Path2D library, fully compatible with Web Path2D, with additional support for path animation, path deformation, path playback, etc.",
7
7
  "author": "wxm",