modern-path2d 1.5.6 → 1.6.0

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
@@ -189,11 +189,9 @@ class Vector2 {
189
189
  return Math.sqrt(this.lengthSquared());
190
190
  }
191
191
  scale(sx, sy = sx, origin = { x: 0, y: 0 }) {
192
- const x = sx < 0 ? origin.x - this._x + origin.x : this._x;
193
- const y = sy < 0 ? origin.y - this._y + origin.y : this._y;
194
192
  return this.set(
195
- x * Math.abs(sx),
196
- y * Math.abs(sy)
193
+ origin.x + (this._x - origin.x) * sx,
194
+ origin.y + (this._y - origin.y) * sy
197
195
  );
198
196
  }
199
197
  skew(ax, ay = 0, origin = { x: 0, y: 0 }) {
@@ -590,7 +588,7 @@ function getDirectedArea(vertices) {
590
588
  for (let i = 0; i < n; i += 2) {
591
589
  const x0 = vertices[i];
592
590
  const y0 = vertices[i + 1];
593
- const x1 = vertices[(i + 2) % (n - 1)];
591
+ const x1 = vertices[(i + 2) % n];
594
592
  const y1 = vertices[(i + 3) % n];
595
593
  area += x0 * y1 - x1 * y0;
596
594
  }
@@ -1741,8 +1739,14 @@ function getReflection(a, b) {
1741
1739
  function svgPathCommandsAddToPath2D(commands, path) {
1742
1740
  const current = new Vector2();
1743
1741
  const control = new Vector2();
1742
+ let prevType = "";
1744
1743
  for (let i = 0, l = commands.length; i < l; i++) {
1745
1744
  const cmd = commands[i];
1745
+ if ((cmd.type === "s" || cmd.type === "S") && !"CcSs".includes(prevType)) {
1746
+ control.copyFrom(current);
1747
+ } else if ((cmd.type === "t" || cmd.type === "T") && !"QqTt".includes(prevType)) {
1748
+ control.copyFrom(current);
1749
+ }
1746
1750
  if (cmd.type === "m" || cmd.type === "M") {
1747
1751
  if (cmd.type === "m") {
1748
1752
  current.add(cmd);
@@ -1901,6 +1905,7 @@ function svgPathCommandsAddToPath2D(commands, path) {
1901
1905
  } else {
1902
1906
  console.warn("Unsupported commands", cmd);
1903
1907
  }
1908
+ prevType = cmd.type;
1904
1909
  }
1905
1910
  }
1906
1911
 
@@ -2325,10 +2330,14 @@ function parsePolylineNode(node) {
2325
2330
  function parseRectNode(node) {
2326
2331
  const x = parseFloatWithUnits(node.getAttribute("x") || 0);
2327
2332
  const y = parseFloatWithUnits(node.getAttribute("y") || 0);
2328
- const rx = parseFloatWithUnits(node.getAttribute("rx") || node.getAttribute("ry") || 0);
2329
- const ry = parseFloatWithUnits(node.getAttribute("ry") || node.getAttribute("rx") || 0);
2333
+ const rxAttr = node.getAttribute("rx");
2334
+ const ryAttr = node.getAttribute("ry");
2335
+ let rx = parseFloatWithUnits(rxAttr ?? ryAttr ?? 0);
2336
+ let ry = parseFloatWithUnits(ryAttr ?? rxAttr ?? 0);
2330
2337
  const w = parseFloatWithUnits(node.getAttribute("width"));
2331
2338
  const h = parseFloatWithUnits(node.getAttribute("height"));
2339
+ rx = Math.max(0, Math.min(rx, w / 2));
2340
+ ry = Math.max(0, Math.min(ry, h / 2));
2332
2341
  const bci = 1 - 0.551915024494;
2333
2342
  const path = new Path2D();
2334
2343
  path.moveTo(x + rx, y);
@@ -3114,6 +3123,8 @@ function eigenDecomposition(A, B, C) {
3114
3123
  rt2 = A * t * C - B * t * B;
3115
3124
  } else if (sm < 0) {
3116
3125
  rt2 = 0.5 * (sm - rt);
3126
+ t = 1 / rt2;
3127
+ rt1 = A * t * C - B * t * B;
3117
3128
  } else {
3118
3129
  rt1 = 0.5 * rt;
3119
3130
  rt2 = -0.5 * rt;
@@ -3279,20 +3290,26 @@ class CompositeCurve extends Curve {
3279
3290
  getPoint(t, output = new Vector2()) {
3280
3291
  const d = t * this.getLength();
3281
3292
  const lengths = this.getLengths();
3282
- let i = 0;
3283
- while (i < lengths.length) {
3284
- if (lengths[i] >= d) {
3285
- const diff = lengths[i] - d;
3286
- const curve = this.curves[i];
3287
- const length = curve.getLength();
3288
- return curve.getPointAt(
3289
- length === 0 ? 0 : 1 - diff / length,
3290
- output
3291
- );
3293
+ const n = lengths.length;
3294
+ if (n === 0)
3295
+ return output;
3296
+ let lo = 0;
3297
+ let hi = n - 1;
3298
+ while (lo < hi) {
3299
+ const mid = lo + hi >>> 1;
3300
+ if (lengths[mid] < d) {
3301
+ lo = mid + 1;
3302
+ } else {
3303
+ hi = mid;
3292
3304
  }
3293
- i++;
3294
3305
  }
3295
- return output;
3306
+ const diff = lengths[lo] - d;
3307
+ const curve = this.curves[lo];
3308
+ const length = curve.getLength();
3309
+ return curve.getPointAt(
3310
+ length === 0 ? 0 : 1 - diff / length,
3311
+ output
3312
+ );
3296
3313
  }
3297
3314
  getLengths() {
3298
3315
  if (this._lengths.length !== this.curves.length) {
@@ -3441,6 +3458,12 @@ class CubicBezierCurve extends Curve {
3441
3458
  return [this.p1, this.cp1, this.cp2, this.p2];
3442
3459
  }
3443
3460
  _solveQuadratic(a, b, c) {
3461
+ if (Math.abs(a) < 1e-12) {
3462
+ if (Math.abs(b) < 1e-12)
3463
+ return [];
3464
+ const t = -c / b;
3465
+ return t >= 0 && t <= 1 ? [t] : [];
3466
+ }
3444
3467
  const discriminant = b * b - 4 * a * c;
3445
3468
  if (discriminant < 0)
3446
3469
  return [];
@@ -3452,30 +3475,23 @@ class CubicBezierCurve extends Curve {
3452
3475
  getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
3453
3476
  const { p1, cp1, cp2, p2 } = this;
3454
3477
  const dxRoots = this._solveQuadratic(
3455
- 3 * (cp1.x - p1.x),
3456
- 6 * (cp2.x - cp1.x),
3457
- 3 * (p2.x - cp2.x)
3478
+ 3 * (-p1.x + 3 * cp1.x - 3 * cp2.x + p2.x),
3479
+ 6 * (p1.x - 2 * cp1.x + cp2.x),
3480
+ 3 * (cp1.x - p1.x)
3458
3481
  );
3459
3482
  const dyRoots = this._solveQuadratic(
3460
- 3 * (cp1.y - p1.y),
3461
- 6 * (cp2.y - cp1.y),
3462
- 3 * (p2.y - cp2.y)
3483
+ 3 * (-p1.y + 3 * cp1.y - 3 * cp2.y + p2.y),
3484
+ 6 * (p1.y - 2 * cp1.y + cp2.y),
3485
+ 3 * (cp1.y - p1.y)
3463
3486
  );
3464
3487
  const tValues = [0, 1, ...dxRoots, ...dyRoots];
3465
- const samplePoints = (tValues2, precision) => {
3466
- for (const t of tValues2) {
3467
- for (let i = 0; i <= precision; i++) {
3468
- const delta = i / precision - 0.5;
3469
- const refinedT = Math.min(1, Math.max(0, t + delta));
3470
- const point = this.getPoint(refinedT);
3471
- min.x = Math.min(min.x, point.x);
3472
- min.y = Math.min(min.y, point.y);
3473
- max.x = Math.max(max.x, point.x);
3474
- max.y = Math.max(max.y, point.y);
3475
- }
3476
- }
3477
- };
3478
- samplePoints(tValues, 10);
3488
+ for (const t of tValues) {
3489
+ const point = this.getPoint(t);
3490
+ min.x = Math.min(min.x, point.x);
3491
+ min.y = Math.min(min.y, point.y);
3492
+ max.x = Math.max(max.x, point.x);
3493
+ max.y = Math.max(max.y, point.y);
3494
+ }
3479
3495
  return { min: min.finite(), max: max.finite() };
3480
3496
  }
3481
3497
  toCommands() {
@@ -3528,11 +3544,11 @@ class EllipseCurve extends RoundCurve {
3528
3544
  }
3529
3545
  }
3530
3546
 
3531
- class PloygonCurve extends CompositeCurve {
3547
+ class PolygonCurve extends CompositeCurve {
3532
3548
  //
3533
3549
  }
3534
3550
 
3535
- class EquilateralPloygonCurve extends PloygonCurve {
3551
+ class EquilateralPolygonCurve extends PolygonCurve {
3536
3552
  constructor(cx = 0, cy = 0, radius = 1, sideCount = 3) {
3537
3553
  super();
3538
3554
  this.cx = cx;
@@ -3615,14 +3631,25 @@ class QuadraticBezierCurve extends Curve {
3615
3631
  }
3616
3632
  getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
3617
3633
  const { p1, cp, p2 } = this;
3618
- const x1 = 0.5 * (p1.x + cp.x);
3619
- const y1 = 0.5 * (p1.y + cp.y);
3620
- const x2 = 0.5 * (p1.x + p2.x);
3621
- const y2 = 0.5 * (p1.y + p2.y);
3622
- min.x = Math.min(min.x, p1.x, p2.x, x1, x2);
3623
- min.y = Math.min(min.y, p1.y, p2.y, y1, y2);
3624
- max.x = Math.max(max.x, p1.x, p2.x, x1, x2);
3625
- max.y = Math.max(max.y, p1.y, p2.y, y1, y2);
3634
+ const extrema = (a, b, c) => {
3635
+ const denom = a - 2 * b + c;
3636
+ if (Math.abs(denom) < 1e-12)
3637
+ return null;
3638
+ const t = (a - b) / denom;
3639
+ return t > 0 && t < 1 ? t : null;
3640
+ };
3641
+ const tx = extrema(p1.x, cp.x, p2.x);
3642
+ const ty = extrema(p1.y, cp.y, p2.y);
3643
+ const xs = [p1.x, p2.x];
3644
+ const ys = [p1.y, p2.y];
3645
+ if (tx !== null)
3646
+ xs.push(quadraticBezier(tx, p1.x, cp.x, p2.x));
3647
+ if (ty !== null)
3648
+ ys.push(quadraticBezier(ty, p1.y, cp.y, p2.y));
3649
+ min.x = Math.min(min.x, ...xs);
3650
+ min.y = Math.min(min.y, ...ys);
3651
+ max.x = Math.max(max.x, ...xs);
3652
+ max.y = Math.max(max.y, ...ys);
3626
3653
  return { min: min.finite(), max: max.finite() };
3627
3654
  }
3628
3655
  toCommands() {
@@ -3647,7 +3674,7 @@ class QuadraticBezierCurve extends Curve {
3647
3674
  }
3648
3675
  }
3649
3676
 
3650
- class RectangleCurve extends PloygonCurve {
3677
+ class RectangleCurve extends PolygonCurve {
3651
3678
  constructor(x = 0, y = 0, width = 0, height = 0) {
3652
3679
  super();
3653
3680
  this.x = x;
@@ -4055,13 +4082,11 @@ class Path2D extends CompositeCurve {
4055
4082
  return this;
4056
4083
  }
4057
4084
  moveTo(x, y) {
4058
- if (!this.currentCurve.currentPoint?.equals({ x, y })) {
4059
- if (this.currentCurve.curves.length) {
4060
- this.currentCurve = new CurvePath();
4061
- this.curves.push(this.currentCurve);
4062
- }
4063
- this.currentCurve.moveTo(x, y);
4085
+ if (this.currentCurve.curves.length) {
4086
+ this.currentCurve = new CurvePath();
4087
+ this.curves.push(this.currentCurve);
4064
4088
  }
4089
+ this.currentCurve.moveTo(x, y);
4065
4090
  return this;
4066
4091
  }
4067
4092
  lineTo(x, y) {
@@ -4529,14 +4554,14 @@ exports.CubicBezierCurve = CubicBezierCurve;
4529
4554
  exports.Curve = Curve;
4530
4555
  exports.CurvePath = CurvePath;
4531
4556
  exports.EllipseCurve = EllipseCurve;
4532
- exports.EquilateralPloygonCurve = EquilateralPloygonCurve;
4557
+ exports.EquilateralPolygonCurve = EquilateralPolygonCurve;
4533
4558
  exports.FFDControlGrid = FFDControlGrid;
4534
4559
  exports.LineCurve = LineCurve;
4535
4560
  exports.PI = PI;
4536
4561
  exports.PI_2 = PI_2;
4537
4562
  exports.Path2D = Path2D;
4538
4563
  exports.Path2DSet = Path2DSet;
4539
- exports.PloygonCurve = PloygonCurve;
4564
+ exports.PolygonCurve = PolygonCurve;
4540
4565
  exports.QuadraticBezierCurve = QuadraticBezierCurve;
4541
4566
  exports.RectangleCurve = RectangleCurve;
4542
4567
  exports.RoundRectangleCurve = RoundRectangleCurve;
package/dist/index.d.cts CHANGED
@@ -483,17 +483,17 @@ declare class LineCurve extends Curve {
483
483
  copyFrom(source: LineCurve): this;
484
484
  }
485
485
 
486
- declare class PloygonCurve extends CompositeCurve<LineCurve> {
486
+ declare class PolygonCurve extends CompositeCurve<LineCurve> {
487
487
  }
488
488
 
489
- declare class EquilateralPloygonCurve extends PloygonCurve {
489
+ declare class EquilateralPolygonCurve extends PolygonCurve {
490
490
  cx: number;
491
491
  cy: number;
492
492
  radius: number;
493
493
  sideCount: number;
494
494
  constructor(cx?: number, cy?: number, radius?: number, sideCount?: number);
495
495
  update(): this;
496
- copyFrom(source: EquilateralPloygonCurve): this;
496
+ copyFrom(source: EquilateralPolygonCurve): this;
497
497
  }
498
498
 
499
499
  declare class QuadraticBezierCurve extends Curve {
@@ -514,7 +514,7 @@ declare class QuadraticBezierCurve extends Curve {
514
514
  copyFrom(source: QuadraticBezierCurve): this;
515
515
  }
516
516
 
517
- declare class RectangleCurve extends PloygonCurve {
517
+ declare class RectangleCurve extends PolygonCurve {
518
518
  x: number;
519
519
  y: number;
520
520
  width: number;
@@ -694,5 +694,5 @@ declare function svgToDom(svg: string | SVGElement): SVGElement;
694
694
 
695
695
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
696
696
 
697
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
697
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPolygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PolygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
698
698
  export type { CssFunction, CssFunctionArg, DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, ParseCssFunctionContext, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, TransformableObject, TriangulatedResult, Vector2Like };
package/dist/index.d.mts CHANGED
@@ -483,17 +483,17 @@ declare class LineCurve extends Curve {
483
483
  copyFrom(source: LineCurve): this;
484
484
  }
485
485
 
486
- declare class PloygonCurve extends CompositeCurve<LineCurve> {
486
+ declare class PolygonCurve extends CompositeCurve<LineCurve> {
487
487
  }
488
488
 
489
- declare class EquilateralPloygonCurve extends PloygonCurve {
489
+ declare class EquilateralPolygonCurve extends PolygonCurve {
490
490
  cx: number;
491
491
  cy: number;
492
492
  radius: number;
493
493
  sideCount: number;
494
494
  constructor(cx?: number, cy?: number, radius?: number, sideCount?: number);
495
495
  update(): this;
496
- copyFrom(source: EquilateralPloygonCurve): this;
496
+ copyFrom(source: EquilateralPolygonCurve): this;
497
497
  }
498
498
 
499
499
  declare class QuadraticBezierCurve extends Curve {
@@ -514,7 +514,7 @@ declare class QuadraticBezierCurve extends Curve {
514
514
  copyFrom(source: QuadraticBezierCurve): this;
515
515
  }
516
516
 
517
- declare class RectangleCurve extends PloygonCurve {
517
+ declare class RectangleCurve extends PolygonCurve {
518
518
  x: number;
519
519
  y: number;
520
520
  width: number;
@@ -694,5 +694,5 @@ declare function svgToDom(svg: string | SVGElement): SVGElement;
694
694
 
695
695
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
696
696
 
697
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
697
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPolygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PolygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
698
698
  export type { CssFunction, CssFunctionArg, DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, ParseCssFunctionContext, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, TransformableObject, TriangulatedResult, Vector2Like };
package/dist/index.d.ts CHANGED
@@ -483,17 +483,17 @@ declare class LineCurve extends Curve {
483
483
  copyFrom(source: LineCurve): this;
484
484
  }
485
485
 
486
- declare class PloygonCurve extends CompositeCurve<LineCurve> {
486
+ declare class PolygonCurve extends CompositeCurve<LineCurve> {
487
487
  }
488
488
 
489
- declare class EquilateralPloygonCurve extends PloygonCurve {
489
+ declare class EquilateralPolygonCurve extends PolygonCurve {
490
490
  cx: number;
491
491
  cy: number;
492
492
  radius: number;
493
493
  sideCount: number;
494
494
  constructor(cx?: number, cy?: number, radius?: number, sideCount?: number);
495
495
  update(): this;
496
- copyFrom(source: EquilateralPloygonCurve): this;
496
+ copyFrom(source: EquilateralPolygonCurve): this;
497
497
  }
498
498
 
499
499
  declare class QuadraticBezierCurve extends Curve {
@@ -514,7 +514,7 @@ declare class QuadraticBezierCurve extends Curve {
514
514
  copyFrom(source: QuadraticBezierCurve): this;
515
515
  }
516
516
 
517
- declare class RectangleCurve extends PloygonCurve {
517
+ declare class RectangleCurve extends PolygonCurve {
518
518
  x: number;
519
519
  y: number;
520
520
  width: number;
@@ -694,5 +694,5 @@ declare function svgToDom(svg: string | SVGElement): SVGElement;
694
694
 
695
695
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
696
696
 
697
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
697
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPolygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PolygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
698
698
  export type { CssFunction, CssFunctionArg, DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, ParseCssFunctionContext, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, TransformableObject, TriangulatedResult, Vector2Like };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.modernPath2d={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,n,r={}){let{radius:i=1}=r;e.moveTo(t,n),e.arc(t,n,i,0,Math.PI*2)}var n={arcs:`bevel`,bevel:`bevel`,miter:`miter`,"miter-clip":`miter`,round:`round`};function r(e,t){let{fill:r=`#000`,stroke:i=`none`,strokeWidth:a=i===`none`?0:1,strokeLinecap:o=`round`,strokeLinejoin:s=`miter`,strokeMiterlimit:c=0,strokeDasharray:l=[],strokeDashoffset:u=0,shadowOffsetX:d=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:m=`rgba(0, 0, 0, 0)`}=t;e.fillStyle=r,e.strokeStyle=i,e.lineWidth=a,e.lineCap=o,e.lineJoin=n[s],e.miterLimit=c,e.setLineDash(l),e.lineDashOffset=u,e.shadowOffsetX=d,e.shadowOffsetY=f,e.shadowBlur=p,e.shadowColor=m}var i=class e{static get MAX(){return new e(1/0,1/0)}static get MIN(){return new e(-1/0,-1/0)}static lerp(t,n,r){return new e(n.x,n.y).clone().sub(t).multiply(r).add(t)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._onUpdate?.(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._onUpdate?.(this))}constructor(e=0,t=0,n){this._x=e,this._y=t,this._onUpdate=n}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._onUpdate?.(this)),this}add(e){return this.set(this._x+e.x,this._y+e.y)}sub(e){return this.set(this._x-e.x,this._y-e.y)}subVectors(e,t){return this.set(e.x-t.x,e.y-t.y)}multiply(e=0,t=e){return this.set(this._x*e,this._y*t)}divide(e=0,t=e){return this.set(this._x/e,this._y/t)}cross(e){return this._x*e.y-this._y*e.x}dot(e){return this._x*e.x+this._y*e.y}rotate(e,t={x:0,y:0}){let{x:n,y:r}=this,i=Math.cos(e),a=Math.sin(e);return this.set((n-t.x)*i-(r-t.y)*a+t.x,(n-t.x)*a+(r-t.y)*i+t.y)}getLength(){let{x:e,y:t}=this;return Math.sqrt(e*e+t*t)}getAngle(){return Math.atan2(-this.x,-this.y)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){let e=1/(this.getLength()||1);return this.set(this.x*e,this.y*e),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._onUpdate?.(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return this._x===e.x&&this._y===e.y}get array(){return[this.x,this.y]}finite(){return this.set(Number.isFinite(this._x)?this._x:0,Number.isFinite(this._y)?this._y:0)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){let r=e<0?n.x-this._x+n.x:this._x,i=t<0?n.y-this._y+n.y:this._y;return this.set(r*Math.abs(e),i*Math.abs(t))}skew(e,t=0,n={x:0,y:0}){let r=this._x-n.x,i=this._y-n.y;return this.set(n.x+(r+Math.tan(e)*i),n.y+(i+Math.tan(t)*r))}clampMin(...e){return this.set(Math.min(this._x,...e.map(e=>e.x)),Math.min(this._y,...e.map(e=>e.y)))}clampMax(...e){return this.set(Math.max(this.x,...e.map(e=>e.x)),Math.max(this.y,...e.map(e=>e.y)))}clone(t){return new e(this._x,this._y,t??this._onUpdate)}toJSON(){return{x:this._x,y:this._y}}destroy(){this._onUpdate=void 0}},a=class e{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}get center(){return new i((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}static from(...t){if(t.length===0)return new e;if(t.length===1)return t[0].clone();let n=t[0],r=t.slice(1).reduce((e,t)=>(e.left=Math.min(e.left,t.left),e.top=Math.min(e.top,t.top),e.right=Math.max(e.right,t.right),e.bottom=Math.max(e.bottom,t.bottom),e),{left:n?.left??0,top:n?.top??0,right:n?.right??0,bottom:n?.bottom??0});return new e(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new e(this.left,this.top,this.width,this.height)}};function o(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}var s=Math.PI,c=s*2;function l(e){return e.replace(/[^a-z0-9]/gi,`-`).replace(/\B([A-Z])/g,`-$1`).toLowerCase()}function u(e,t,n,r){let a=t.clone().sub(e),o=r.clone().sub(n),s=n.clone().sub(e),c=a.cross(o);if(c===0)return new i((e.x+n.x)/2,(e.y+n.y)/2);let l=s.cross(o)/c;return Math.abs(l)>1?new i((e.x+n.x)/2,(e.y+n.y)/2):new i(e.x+l*a.x,e.y+l*a.y)}var d=/([\w-]+)\((.+?)\)/g,f=/[^,]+/g,p=/([-e.\d]+)(.*)/;function m(e,t={}){let n=[],r;for(;(r=d.exec(e))!==null;){let[,e,i]=r;e&&n.push({name:e,args:h(e,i,t)})}return n}function h(e,t,n={}){let r=[],i,a=0;for(;(i=f.exec(t))!==null;)r.push(g(e,i[0],{...n,index:a++}));return r}function g(e,t,n={}){let{width:r=1,height:i=1,index:a=0}=n,o=t.match(p),s={unit:o?.[2]??null,value:t,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(e){case`scale`:case`scaleX`:case`scaleY`:case`scale3d`:s.normalizedDefaultIntValue=1;break}switch(s.unit){case`%`:s.normalizedIntValue=s.intValue/100;break;case`rad`:s.normalizedIntValue=s.intValue/c;break;case`deg`:s.normalizedIntValue=s.intValue/360;break;case`px`:switch(a){case 0:s.normalizedIntValue=s.intValue/r;break;case 1:s.normalizedIntValue=s.intValue/i;break}break;default:s.normalizedIntValue=s.intValue;break}return s}function _(e,t){let n=1-e;return n*n*n*t}function v(e,t){let n=1-e;return 3*n*n*e*t}function y(e,t){return 3*(1-e)*e*e*t}function b(e,t){return e*e*e*t}function x(e,t,n,r,i){return _(e,t)+v(e,n)+y(e,r)+b(e,i)}function S(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=C(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=A(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return T(a,o,n,s,c,l,0),o}function C(e,t,n,r,i){let a;if(i===pe(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=de(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=de(i/r|0,e[i],e[i+1],a);return a&&R(a,a.next)&&(B(a),a=a.next),a}function w(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(R(n,n.next)||L(n.prev,n,n.next)===0)){if(B(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function T(e,t,n,r,i,a,o){if(!e)return;!o&&a&&F(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?D(e,r,i,a):E(e)){t.push(c.i,e.i,l.i),B(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=O(w(e),t),T(e,t,n,r,i,a,2)):o===2&&k(e,t,n,r,i,a):T(w(e),t,n,r,i,a,1);break}}}function E(e){let t=e.prev,n=e,r=e.next;if(L(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&re(i,s,a,c,o,l,m.x,m.y)&&L(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function D(e,t,n,r){let i=e.prev,a=e,o=e.next;if(L(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=ee(p,m,t,n,r),v=ee(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&re(s,u,c,d,l,f,y.x,y.y)&&L(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&re(s,u,c,d,l,f,b.x,b.y)&&L(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&re(s,u,c,d,l,f,y.x,y.y)&&L(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&re(s,u,c,d,l,f,b.x,b.y)&&L(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function O(e,t){let n=e;do{let r=n.prev,i=n.next.next;!R(r,i)&&ae(r,n,n.next,i)&&z(r,i)&&z(i,r)&&(t.push(r.i,n.i,i.i),B(n),B(n.next),n=e=i),n=n.next}while(n!==e);return w(n)}function k(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&ie(o,e)){let s=ue(o,e);o=w(o,o.next),s=w(s,s.next),T(o,t,n,r,i,a,0),T(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function A(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=C(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(te(o))}i.sort(j);for(let e=0;e<i.length;e++)n=M(i[e],n);return n}function j(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function M(e,t){let n=N(e,t);if(!n)return t;let r=ue(n,e);return w(r,r.next),w(n,n.next)}function N(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(R(e,n))return n;do{if(R(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&ne(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);z(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&P(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function P(e,t){return L(e.prev,e,t.prev)<0&&L(t.next,e,e.next)<0}function F(e,t,n,r){let i=e;do i.z===0&&(i.z=ee(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,I(i)}function I(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function ee(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function te(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function ne(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function re(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&ne(e,t,n,r,i,a,o,s)}function ie(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ce(e,t)&&(z(e,t)&&z(t,e)&&le(e,t)&&(L(e.prev,e,t.prev)||L(e,t.prev,t))||R(e,t)&&L(e.prev,e,e.next)>0&&L(t.prev,t,t.next)>0)}function L(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function R(e,t){return e.x===t.x&&e.y===t.y}function ae(e,t,n,r){let i=se(L(e,t,n)),a=se(L(e,t,r)),o=se(L(n,r,e)),s=se(L(n,r,t));return!!(i!==a&&o!==s||i===0&&oe(e,n,t)||a===0&&oe(e,r,t)||o===0&&oe(n,e,r)||s===0&&oe(n,t,r))}function oe(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function se(e){return e>0?1:e<0?-1:0}function ce(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ae(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function z(e,t){return L(e.prev,e,e.next)<0?L(e,t,e.next)>=0&&L(e,e.prev,t)>=0:L(e,t,e.prev)<0||L(e,e.next,t)<0}function le(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function ue(e,t){let n=fe(e.i,e.x,e.y),r=fe(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function de(e,t,n,r){let i=fe(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function B(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function fe(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function pe(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function me(e,t={}){let{vertices:n=[],indices:r=[],holes:i=[],verticesStride:a=2,verticesOffset:o=n.length/a,indicesOffset:s=r.length}=t,c=S(e,i,2);if(c.length){for(let e=0;e<c.length;e+=3)r[s++]=c[e]+o,r[s++]=c[e+1]+o,r[s++]=c[e+2]+o;let t=o*a;for(let r=0;r<e.length;r+=2)n[t]=e[r],n[t+1]=e[r+1],t+=a}return{vertices:n,indices:r}}var he=8,ge=1.1920929e-7,_e=1,ve=.01,V=0,H=0;function ye(e,t,n,r,i,a,o,s,c=.5,l=[]){let u=(_e-Math.min(.99,Math.max(0,c)))/1;return u*=u,be(e,t,n,r,i,a,o,s,l,u,0),l.push(o,s),l}function be(e,t,n,r,i,a,o,s,c,l,u){if(u>he)return;let d=Math.PI,f=(e+n)/2,p=(t+r)/2,m=(n+i)/2,h=(r+a)/2,g=(i+o)/2,_=(a+s)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(h+_)/2,S=(v+b)/2,C=(y+x)/2;if(u>0){let u=o-e,f=s-t,p=Math.abs((n-o)*f-(r-s)*u),m=Math.abs((i-o)*f-(a-s)*u),h,g;if(p>ge&&m>ge){if((p+m)*(p+m)<=l*(u*u+f*f)){if(V<ve){c.push(S,C);return}let l=Math.atan2(a-r,i-n);if(h=Math.abs(l-Math.atan2(r-t,n-e)),g=Math.abs(Math.atan2(s-a,o-i)-l),h>=d&&(h=2*d-h),g>=d&&(g=2*d-g),h+g<V){c.push(S,C);return}if(H!==0){if(h>H){c.push(n,r);return}if(g>H){c.push(i,a);return}}}}else if(p>ge){if(p*p<=l*(u*u+f*f)){if(V<ve){c.push(S,C);return}if(h=Math.abs(Math.atan2(a-r,i-n)-Math.atan2(r-t,n-e)),h>=d&&(h=2*d-h),h<V){c.push(n,r),c.push(i,a);return}if(H!==0&&h>H){c.push(n,r);return}}}else if(m>ge){if(m*m<=l*(u*u+f*f)){if(V<ve){c.push(S,C);return}if(h=Math.abs(Math.atan2(s-a,o-i)-Math.atan2(a-r,i-n)),h>=d&&(h=2*d-h),h<V){c.push(n,r),c.push(i,a);return}if(H!==0&&h>H){c.push(i,a);return}}}else if(u=S-(e+o)/2,f=C-(t+s)/2,u*u+f*f<=l){c.push(S,C);return}}be(e,t,f,p,v,y,S,C,c,l,u+1),be(S,C,b,x,g,_,o,s,c,l,u+1)}var xe=8,Se=1.1920929e-7,Ce=1,we=.01,Te=0;function Ee(e,t,n,r,i,a,o=.5,s=[]){let c=(Ce-Math.min(.99,Math.max(0,o)))/1;return c*=c,De(s,e,t,n,r,i,a,c,0),s.push(i,a),s}function De(e,t,n,r,i,a,o,s,c){if(c>xe)return;let l=Math.PI,u=(t+r)/2,d=(n+i)/2,f=(r+a)/2,p=(i+o)/2,m=(u+f)/2,h=(d+p)/2,g=a-t,_=o-n,v=Math.abs((r-a)*_-(i-o)*g);if(v>Se){if(v*v<=s*(g*g+_*_)){if(Te<we){e.push(m,h);return}let s=Math.abs(Math.atan2(o-i,a-r)-Math.atan2(i-n,r-t));if(s>=l&&(s=2*l-s),s<Te){e.push(m,h);return}}}else if(g=m-(t+a)/2,_=h-(n+o)/2,g*g+_*_<=s){e.push(m,h);return}De(e,t,n,u,d,m,h,s,c+1),De(e,m,h,f,p,a,o,s,c+1)}function Oe(e){let t=0,n=e.length;for(let r=0;r<n;r+=2){let i=e[r],a=e[r+1],o=e[(r+2)%(n-1)],s=e[(r+3)%n];t+=i*s-o*a}return t/2}function ke(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function Ae(e,t,n){let r=n.length,i=0;for(let a=0,o=r-2;a<r;o=a,a+=2){let r=n[a],s=n[a+1],c=n[o],l=n[o+1];s<=t?l>t&&ke(c,l,r,s,e,t)>0&&i++:l<=t&&ke(c,l,r,s,e,t)<0&&i--}return i}function je(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function Me(e){let t=e.map((e,t)=>({index:t})),n=e.map(e=>{let t=e.length;if(!t)return[];let n=[2**53-1,0],r=[0,2**53-1],i=[-(2**53-1),0],a=[0,-(2**53-1)];for(let o=0;o<t;o+=2){let t=e[o],s=e[o+1];n[0]>t&&(n=[t,s]),r[1]>s&&(r=[t,s]),i[0]<t&&(i=[t,s]),a[1]<s&&(a=[t,s])}let o=[(n[0]+i[0])/2,(r[1]+a[1])/2],s,c,l,u,d,f,p,m;for(let n=0;n<t;n+=2){let t=e[n],r=e[n+1],i=Math.abs(t-o[0]),a=Math.abs(r-o[1]);r<o[1]&&(!s||i<s)&&(s=i,l=[t,r]),r>o[1]&&(!c||i<c)&&(c=i,u=[t,r]),t<o[0]&&(!d||a<d)&&(d=a,p=[t,r]),t>o[0]&&(!f||a<f)&&(f=a,m=[t,r])}return[n,r,i,a,l,u,p,m].filter(Boolean)});for(let r=0,i=e.length;r<i;r++){let a=[],o=n[r];for(let t=0;t<i;t++){if(r===t)continue;let i={},s=[];for(let n=0,r=o.length;n<r;n++){let[r,a]=o[n],c=Ae(r,a,e[t]);i[c]=(i[c]??0)+1,s.push(c)}s.filter(e=>e!==0).length>s.filter(e=>e===0).length&&a.push({index:r,parentIndex:t,winding:Number(Array.from(Object.entries(i)).sort((e,t)=>t[1]-e[1])?.[0]?.[0]??0),dist:je(n[r][0],n[t][0])})}a.reduce((e,t)=>e+t.winding,0)!==0&&(a.sort((e,t)=>e.dist-t.dist),t[r]=a[0])}return t}function Ne(e,t){let n=1-e;return n*n*t}function Pe(e,t){return 2*(1-e)*e*t}function Fe(e,t){return e*e*t}function Ie(e,t,n,r){return Ne(e,t)+Pe(e,n)+Fe(e,r)}var Le=1e-4,Re=1e-4;function ze(e,t={}){let{vertices:n=[],indices:r=[],lineStyle:i={alignment:.5,cap:`butt`,join:`miter`,width:1,miterLimit:10},flipAlignment:a=!1,closed:o=!0}=t,s=Le;if(e.length===0)return{vertices:n,indices:r};let c=i,l=c.alignment;if(i.alignment!==.5){let t=Be(e);a&&(t*=-1),l=(l-.5)*t+.5}let u={x:e[0],y:e[1]},d={x:e[e.length-2],y:e[e.length-1]},f=o,p=Math.abs(u.x-d.x)<s&&Math.abs(u.y-d.y)<s;if(f){e=e.slice(),p&&(e.pop(),e.pop(),d.x=e[e.length-2],d.y=e[e.length-1]);let t=(u.x+d.x)*.5,n=(d.y+u.y)*.5;e.unshift(t,n),e.push(t,n)}let m=n,h=e.length/2,g=e.length,_=m.length/2,v=c.width/2,y=v*v,b=c.miterLimit*c.miterLimit,x=e[0],S=e[1],C=e[2],w=e[3],T=0,E=0,D=-(S-w),O=x-C,k=0,A=0,j=Math.sqrt(D*D+O*O);D/=j,O/=j,D*=v,O*=v;let M=l,N=(1-M)*2,P=M*2;f||(c.cap===`round`?g+=U(x-D*(N-P)*.5,S-O*(N-P)*.5,x-D*N,S-O*N,x+D*P,S+O*P,m,!0)+2:c.cap===`square`&&(g+=Ve(x,S,D,O,N,P,!0,m))),m.push(x-D*N,S-O*N),m.push(x+D*P,S+O*P);for(let t=1;t<h-1;++t){x=e[(t-1)*2],S=e[(t-1)*2+1],C=e[t*2],w=e[t*2+1],T=e[(t+1)*2],E=e[(t+1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,k=-(w-E),A=C-T,j=Math.sqrt(k*k+A*A),k/=j,A/=j,k*=v,A*=v;let n=C-x,r=S-w,i=C-T,a=E-w,o=n*i+r*a,s=r*i-a*n,l=s<0;if(Math.abs(s)<.001*Math.abs(o)){m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),o>=0&&(c.join===`round`?g+=U(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4:g+=2,m.push(C-k*P,w-A*P),m.push(C+k*N,w+A*N));continue}let u=(-D+x)*(-O+w)-(-D+C)*(-O+S),d=(-k+T)*(-A+w)-(-k+C)*(-A+E),f=(n*d-i*u)/s,p=(a*u-r*d)/s,h=(f-C)*(f-C)+(p-w)*(p-w),_=C+(f-C)*N,M=w+(p-w)*N,F=C-(f-C)*P,I=w-(p-w)*P,ee=Math.min(n*n+r*r,i*i+a*a),te=l?N:P;h<=ee+te*te*y?c.join===`bevel`||h/y>b?(l?(m.push(_,M),m.push(C+D*P,w+O*P),m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),m.push(C-k*N,w-A*N),m.push(F,I)),g+=2):c.join===`round`?l?(m.push(_,M),m.push(C+D*P,w+O*P),g+=U(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+4,m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),g+=U(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4,m.push(C-k*N,w-A*N),m.push(F,I)):(m.push(_,M),m.push(F,I)):(m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),c.join===`round`?l?g+=U(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+2:g+=U(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+2:c.join===`miter`&&h/y<=b&&(l?(m.push(F,I),m.push(F,I)):(m.push(_,M),m.push(_,M)),g+=2),m.push(C-k*N,w-A*N),m.push(C+k*P,w+A*P),g+=2)}x=e[(h-2)*2],S=e[(h-2)*2+1],C=e[(h-1)*2],w=e[(h-1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),f||(c.cap===`round`?g+=U(C-D*(N-P)*.5,w-O*(N-P)*.5,C-D*N,w-O*N,C+D*P,w+O*P,m,!1)+2:c.cap===`square`&&(g+=Ve(C,w,D,O,N,P,!1,m)));let F=Re*Re;for(let e=_;e<g+_-2;++e)x=m[e*2],S=m[e*2+1],C=m[(e+1)*2],w=m[(e+1)*2+1],T=m[(e+2)*2],E=m[(e+2)*2+1],!(Math.abs(x*(w-E)+C*(E-S)+T*(S-w))<F)&&r.push(e,e+1,e+2);return{vertices:n,indices:r}}function Be(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function Ve(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function U(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}var W=class e{_array;constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}skewX(e){let t=Math.tan(e);return this.a+=t*this.b,this.c+=t*this.d,this.tx+=t*this.ty,this}skewY(e){let t=Math.tan(e);return this.b+=t*this.a,this.d+=t*this.c,this.ty+=t*this.tx,this}skew(e,t){let n=Math.tan(e),r=Math.tan(t),i=this.a,a=this.b,o=this.c,s=this.d,c=this.tx,l=this.ty;return this.a=i+n*a,this.b=r*i+a,this.c=o+n*s,this.d=r*o+s,this.tx=c+n*l,this.ty=r*c+l,this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,n){return this.translate(e,t,n)}translate(e,t,n=0){return this.tx+=e,this.ty+=t,this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,n=1){return this.scale(e,t,n)}scale(e,t,n=1){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}rotate3d(e,t,n,r){let[i,a,o]=this._rotate3d(e,t,n,r);return i&&this.rotateX(i),a&&this.rotateY(a),o&&this.rotateZ(o),this}_rotateToScale(e){let t=e/c;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,n,r){if(e===1&&t===0&&n===0)return[r,0,0];if(e===0&&t===1&&n===0)return[0,r,0];if(e===0&&t===0)return[0,0,r];{let i=Math.cos(r),a=Math.sin(r),o=i+e*e*(1-i),s=e*t*(1-i)-n*a,c=e*n*(1-i)+t*a,l=i+t*t*(1-i),u=t*n*(1-i)-e*a,d=i+n*n*(1-i);return[-Math.atan2(-u,l),-Math.atan2(c,Math.sqrt(u*u+d*d)),-Math.atan2(-s,o)]}}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,l=-Math.atan2(-i,a),u=Math.atan2(r,n),d=Math.abs(l+u);return d<1e-5||Math.abs(c-d)<1e-5?(t.rotation=u,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=l,t.skew.y=u),t.scale.x=Math.sqrt(n*n+r*r),t.scale.y=Math.sqrt(i*i+a*a),t.position.x=o+(e.x*n+e.y*i),t.position.y=s+(e.x*r+e.y*a),t}apply(e,t){t||=new i;let{x:n,y:r}=e;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}affineInvert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t||=new i;let{a:n,b:r,c:a,d:o,tx:s,ty:c}=this,l=1/(n*o+a*-r),u=e.x,d=e.y;return t.x=o*l*u+-a*l*d+(c*a-s*o)*l,t.y=n*l*d+-r*l*u+(-c*n+s*r)*l,t}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}isIdentity(){let{a:e,b:t,c:n,d:r,tx:i,ty:a}=this;return e===1&&t===0&&n===0&&r===1&&i===0&&a===0}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}prependCssTransform(t,n={}){let{width:r=1,height:i=1}=n,a=new e;return m(t,{width:r,height:i}).reverse().forEach(({name:e,args:t})=>{let n=t.map(e=>e.normalizedIntValue);switch(e){case`translateX`:a.translateX(n[0]*r);break;case`translateY`:a.translateY(n[0]*i);break;case`translateZ`:a.translateZ(n[0]);break;case`translate`:a.translate(n[0]*r,(n[1]??n[0])*i);break;case`translate3d`:a.translate3d(n[0]*r,(n[1]??n[0])*i,n[2]??n[1]??n[0]);break;case`scaleX`:a.scaleX(n[0]);break;case`scaleY`:a.scaleY(n[0]);break;case`scale`:a.scale(n[0],n[1]??n[0]);break;case`scale3d`:a.scale3d(n[0],n[1]??n[0],n[2]??n[1]??n[0]);break;case`rotateX`:a.rotateX(n[0]*c);break;case`rotateY`:a.rotateY(n[0]*c);break;case`rotateZ`:a.rotateZ(n[0]*c);break;case`rotate`:a.rotate(n[0]*c);break;case`rotate3d`:a.rotate3d(n[0]*c,(n[1]??n[0])*c,(n[2]??n[1]??n[0])*c,(n[3]??n[2]??n[1]??n[0])*c);break;case`skewX`:a.skewX(n[0]*c);break;case`skewY`:a.skewY(n[0]*c);break;case`skew`:a.skew(n[0]*c,(n[0]??n[1])*c);break;case`matrix`:a.set(n[0],n[1],n[2],n[3],n[4],n[5]);break}}),this.prepend(a),this}clone(){return new e(this.a,this.b,this.c,this.d,this.tx,this.ty)}toArray(e,t){this._array||=new Float32Array(9);let n=t||this._array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}toString(){return`[Transform2D a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}destroy(){this._array=void 0}};function He(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function Ue(e,t,n,r,i,a,o,s){if(t===0||n===0){e.lineTo(s.x,s.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let c=(o.x-s.x)/2,l=(o.y-s.y)/2,u=Math.cos(r)*c+Math.sin(r)*l,d=-Math.sin(r)*c+Math.cos(r)*l,f=t*t,p=n*n,m=u*u,h=d*d,g=m/f+h/p;if(g>1){let e=Math.sqrt(g);t=e*t,n=e*n,f=t*t,p=n*n}let _=f*h+p*m,v=(f*p-_)/_,y=Math.sqrt(Math.max(0,v));i===a&&(y=-y);let b=y*t*d/n,x=-y*n*u/t,S=Math.cos(r)*b-Math.sin(r)*x+(o.x+s.x)/2,C=Math.sin(r)*b+Math.cos(r)*x+(o.y+s.y)/2,w=He(1,0,(u-b)/t,(d-x)/n),T=He((u-b)/t,(d-x)/n,(-u-b)/t,(-d-x)/n)%(Math.PI*2);e.ellipse(S,C,t,n,r,w,w+T,a===0)}var G={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function K(e,t,n=0){let r=0,i=!0,a=``,o=``,s=[];function c(e,t,n){let r=SyntaxError(`Unexpected character "${e}" at index ${t}.`);throw r.partial=n,r}function l(){a!==``&&(o===``?s.push(Number(a)):s.push(Number(a)*10**Number(o))),a=``,o=``}let u,d=e.length;for(let f=0;f<d;f++){if(u=e[f],Array.isArray(t)&&t.includes(s.length%n)&&G.FLAGS.test(u)){r=1,a=u,l();continue}if(r===0){if(G.WHITESPACE.test(u))continue;if(G.DIGIT.test(u)||G.SIGN.test(u)){r=1,a=u;continue}if(G.POINT.test(u)){r=2,a=u;continue}G.COMMA.test(u)&&(i&&c(u,f,s),i=!0)}if(r===1){if(G.DIGIT.test(u)){a+=u;continue}if(G.POINT.test(u)){a+=u,r=2;continue}if(G.EXP.test(u)){r=3;continue}G.SIGN.test(u)&&a.length===1&&G.SIGN.test(a[0])&&c(u,f,s)}if(r===2){if(G.DIGIT.test(u)){a+=u;continue}if(G.EXP.test(u)){r=3;continue}G.POINT.test(u)&&a[a.length-1]===`.`&&c(u,f,s)}if(r===3){if(G.DIGIT.test(u)){o+=u;continue}if(G.SIGN.test(u)){if(o===``){o+=u;continue}o.length===1&&G.SIGN.test(o)&&c(u,f,s)}}G.WHITESPACE.test(u)?(l(),r=0,i=!1):G.COMMA.test(u)?(l(),r=0,i=!0):G.SIGN.test(u)?(l(),r=1,a=u):G.POINT.test(u)?(l(),r=2,a=u):c(u,f,s)}return l(),s}function q(e,t){return e-(t-e)}function We(e,t){let n=new i,r=new i;for(let i=0,a=e.length;i<a;i++){let a=e[i];if(a.type===`m`||a.type===`M`)a.type===`m`?n.add(a):n.copyFrom(a),t.moveTo(n.x,n.y),r.copyFrom(n);else if(a.type===`h`||a.type===`H`)a.type===`h`?n.x+=a.x:n.x=a.x,t.lineTo(n.x,n.y),r.copyFrom(n);else if(a.type===`v`||a.type===`V`)a.type===`v`?n.y+=a.y:n.y=a.y,t.lineTo(n.x,n.y),r.copyFrom(n);else if(a.type===`l`||a.type===`L`)a.type===`l`?n.add(a):n.copyFrom(a),t.lineTo(n.x,n.y),r.copyFrom(n);else if(a.type===`c`||a.type===`C`)a.type===`c`?(t.bezierCurveTo(n.x+a.x1,n.y+a.y1,n.x+a.x2,n.y+a.y2,n.x+a.x,n.y+a.y),r.x=n.x+a.x2,r.y=n.y+a.y2,n.add(a)):(t.bezierCurveTo(a.x1,a.y1,a.x2,a.y2,a.x,a.y),r.x=a.x2,r.y=a.y2,n.copyFrom(a));else if(a.type===`s`||a.type===`S`)a.type===`s`?(t.bezierCurveTo(q(n.x,r.x),q(n.y,r.y),n.x+a.x2,n.y+a.y2,n.x+a.x,n.y+a.y),r.x=n.x+a.x2,r.y=n.y+a.y2,n.add(a)):(t.bezierCurveTo(q(n.x,r.x),q(n.y,r.y),a.x2,a.y2,a.x,a.y),r.x=a.x2,r.y=a.y2,n.copyFrom(a));else if(a.type===`q`||a.type===`Q`)a.type===`q`?(t.quadraticCurveTo(n.x+a.x1,n.y+a.y1,n.x+a.x,n.y+a.y),r.x=n.x+a.x1,r.y=n.y+a.y1,n.add(a)):(t.quadraticCurveTo(a.x1,a.y1,a.x,a.y),r.x=a.x1,r.y=a.y1,n.copyFrom(a));else if(a.type===`t`||a.type===`T`){let e=q(n.x,r.x),i=q(n.y,r.y);r.x=e,r.y=i,a.type===`t`?(t.quadraticCurveTo(e,i,n.x+a.x,n.y+a.y),n.add(a)):(t.quadraticCurveTo(e,i,a.x,a.y),n.copyFrom(a))}else if(a.type===`a`||a.type===`A`){let e=n.clone();if(a.type===`a`){if(a.x===0&&a.y===0)continue;n.add(a)}else{if(n.equals(a))continue;n.copyFrom(a)}r.copyFrom(n),Ue(t,a.rx,a.ry,a.angle,a.largeArcFlag,a.sweepFlag,e,n)}else a.type===`z`||a.type===`Z`?(t.startPoint&&n.copyFrom(t.startPoint),t.closePath()):console.warn(`Unsupported commands`,a)}}function Ge(e){let t,n,r=[];for(let i=0,a=e.length;i<a;i++){let a=e[i];switch(a.type){case`m`:case`M`:if(a.x.toFixed(4)===n?.x.toFixed(4)&&a.y.toFixed(4)===n?.y.toFixed(4))continue;r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y},t={x:a.x,y:a.y};break;case`h`:case`H`:r.push(`${a.type} ${a.x}`),n={x:a.x,y:n?.y??0};break;case`v`:case`V`:r.push(`${a.type} ${a.y}`),n={x:n?.x??0,y:a.y};break;case`l`:case`L`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`c`:case`C`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`s`:case`S`:r.push(`${a.type} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`q`:case`Q`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`t`:case`T`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`a`:case`A`:r.push(`${a.type} ${a.rx} ${a.ry} ${a.angle} ${a.largeArcFlag} ${a.sweepFlag} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`z`:case`Z`:r.push(a.type),t&&(n={x:t.x,y:t.y});break;default:break}}return r.join(` `)}var Ke=/[a-df-z][^a-df-z]*/gi;function qe(e){let t=[],n=e.match(Ke);if(!n)return t;for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.charAt(0),a=r.slice(1).trim(),o;switch(i){case`m`:case`M`:o=K(a);for(let e=0,n=o.length;e<n;e+=2)e===0?t.push({type:i,x:o[e],y:o[e+1]}):t.push({type:i===`m`?`l`:`L`,x:o[e],y:o[e+1]});break;case`h`:case`H`:o=K(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,x:o[e]});break;case`v`:case`V`:o=K(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,y:o[e]});break;case`l`:case`L`:o=K(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`c`:case`C`:o=K(a);for(let e=0,n=o.length;e<n;e+=6)t.push({type:i,x1:o[e],y1:o[e+1],x2:o[e+2],y2:o[e+3],x:o[e+4],y:o[e+5]});break;case`s`:case`S`:o=K(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x2:o[e],y2:o[e+1],x:o[e+2],y:o[e+3]});break;case`q`:case`Q`:o=K(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x1:o[e],y1:o[e+1],x:o[e+2],y:o[e+3]});break;case`t`:case`T`:o=K(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`a`:case`A`:o=K(a,[3,4],7);for(let e=0,n=o.length;e<n;e+=7)t.push({type:i,rx:o[e],ry:o[e+1],angle:o[e+2],largeArcFlag:o[e+3],sweepFlag:o[e+4],x:o[e+5],y:o[e+6]});break;case`z`:case`Z`:t.push({type:i});break;default:console.warn(r)}}return t}var Je=`data:image/svg+xml;`,Ye=`${Je}base64,`,Xe=`${Je}charset=utf8,`;function Ze(e){if(typeof e==`string`){let t;e.startsWith(Ye)?(e=e.substring(Ye.length,e.length),t=atob(e)):e.startsWith(Xe)?(e=e.substring(Xe.length,e.length),t=decodeURIComponent(e)):t=e;let n=new DOMParser().parseFromString(t,`text/xml`),r=n.querySelector(`parsererror`);if(r)throw Error(`${r.textContent??`parser error`}\n${t}`);return n.documentElement}else return e}var Qe=`px`,$e=90,et=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],tt={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 J(e){let t=`px`;if(typeof e==`string`)for(let n=0,r=et.length;n<r;n++){let r=et[n];if(e.endsWith(r)){t=r,e=e.substring(0,e.length-r.length);break}}let n;return t===`px`&&Qe!==`px`?n=tt.in[Qe]/$e:(n=tt[t][Qe],n<0&&(n=tt[t].in*$e)),n*Number.parseFloat(e)}function nt(e,t,n){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let r=rt(e);return n.length>0&&r.prepend(n[n.length-1]),t.copyFrom(r),n.push(r),r}function rt(e){let t=new W;return e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))&&t.translate(J(e.getAttribute(`x`)),J(e.getAttribute(`y`))),e.hasAttribute(`transform`)&&t.prependCssTransform(e.getAttribute(`transform`)),t}function it(e){return new $().arc(J(e.getAttribute(`cx`)||0),J(e.getAttribute(`cy`)||0),J(e.getAttribute(`r`)||0),0,Math.PI*2)}function at(e,t){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let n=0;n<e.sheet.cssRules.length;n++){let r=e.sheet.cssRules[n];if(r.type!==1)continue;let i=r.selectorText.split(/,/g).filter(Boolean).map(e=>e.trim()),a={};for(let e=r.style.length,t=0;t<e;t++){let e=r.style.item(t);a[e]=r.style.getPropertyValue(e)}for(let e=0;e<i.length;e++)t[i[e]]=Object.assign(t[i[e]]||{},{...a})}}function ot(e){return new $().ellipse(J(e.getAttribute(`cx`)||0),J(e.getAttribute(`cy`)||0),J(e.getAttribute(`rx`)||0),J(e.getAttribute(`ry`)||0),0,0,Math.PI*2)}function st(e){return new $().moveTo(J(e.getAttribute(`x1`)||0),J(e.getAttribute(`y1`)||0)).lineTo(J(e.getAttribute(`x2`)||0),J(e.getAttribute(`y2`)||0))}function ct(e){let t=new $,n=e.getAttribute(`d`);return!n||n===`none`?null:(t.addData(n),t)}var lt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ut(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(lt,(e,r,i)=>{let a=J(r),o=J(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!0,t}var dt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ft(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(dt,(e,r,i)=>{let a=J(r),o=J(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!1,t}function pt(e){let t=J(e.getAttribute(`x`)||0),n=J(e.getAttribute(`y`)||0),r=J(e.getAttribute(`rx`)||e.getAttribute(`ry`)||0),i=J(e.getAttribute(`ry`)||e.getAttribute(`rx`)||0),a=J(e.getAttribute(`width`)),o=J(e.getAttribute(`height`)),s=.448084975506,c=new $;return c.moveTo(t+r,n),c.lineTo(t+a-r,n),(r!==0||i!==0)&&c.bezierCurveTo(t+a-r*s,n,t+a,n+i*s,t+a,n+i),c.lineTo(t+a,n+o-i),(r!==0||i!==0)&&c.bezierCurveTo(t+a,n+o-i*s,t+a-r*s,n+o,t+a-r,n+o),c.lineTo(t+r,n+o),(r!==0||i!==0)&&c.bezierCurveTo(t+r*s,n+o,t,n+o-i*s,t,n+o-i),c.lineTo(t,n+i),(r!==0||i!==0)&&c.bezierCurveTo(t,n+i*s,t+r*s,n,t+r,n),c}function Y(e,t,n){t=Object.assign({},t);let r={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)r=Object.assign(r,n[`.${t[e]}`])}e.hasAttribute(`id`)&&(r=Object.assign(r,n[`#${e.getAttribute(`id`)}`]));for(let n=e.style.length,i=0;i<n;i++){let n=e.style.item(i),a=e.style.getPropertyValue(n);t[n]=a,r[n]=a}function i(n,i,o=a){e.hasAttribute(n)&&(t[i]=o(e.getAttribute(n))),r[n]&&(t[i]=o(r[n]))}function a(e){return e.startsWith(`url`)&&console.warn(`url access in attributes is not implemented.`),e}function o(e){return Math.max(0,Math.min(1,J(e)))}function s(e){return Math.max(0,J(e))}function c(e){return e.split(` `).filter(e=>e!==``).map(e=>J(e))}return i(`fill`,`fill`),i(`fill-opacity`,`fillOpacity`,o),i(`fill-rule`,`fillRule`),i(`opacity`,`opacity`,o),i(`stroke`,`stroke`),i(`stroke-opacity`,`strokeOpacity`,o),i(`stroke-width`,`strokeWidth`,s),i(`stroke-linecap`,`strokeLinecap`),i(`stroke-linejoin`,`strokeLinejoin`),i(`stroke-miterlimit`,`strokeMiterlimit`,s),i(`stroke-dasharray`,`strokeDasharray`,c),i(`stroke-dashoffset`,`strokeDashoffset`,J),i(`visibility`,`visibility`),t}function mt(e,t,n=[],r={}){if(e.nodeType!==1)return n;let i=!1,a=null,o={...t};switch(e.nodeName){case`svg`:o=Y(e,o,r);break;case`style`:at(e,r);break;case`g`:o=Y(e,o,r);break;case`path`:o=Y(e,o,r),e.hasAttribute(`d`)&&(a=ct(e));break;case`rect`:o=Y(e,o,r),a=pt(e);break;case`polygon`:o=Y(e,o,r),a=ut(e);break;case`polyline`:o=Y(e,o,r),a=ft(e);break;case`circle`:o=Y(e,o,r),a=it(e);break;case`ellipse`:o=Y(e,o,r),a=ot(e);break;case`line`:o=Y(e,o,r),a=st(e);break;case`defs`:i=!0;break;case`use`:{o=Y(e,o,r);let t=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),i=e.viewportElement?.getElementById(t);i?mt(i,o,n,r):console.warn(`'use node' references non-existent node id: ${t}`);break}default:console.warn(e);break}if(o.display===`none`)return n;let s=new W,c=[],l=nt(e,s,c);a&&(a.applyTransform(s),n.push(a),a.style={...o});let u=e.childNodes;for(let e=0,t=u.length;e<t;e++){let t=u[e];i&&t.nodeName!==`style`&&t.nodeName!==`defs`||mt(t,o,n,r)}return l&&(c.pop(),c.length>0?s.copyFrom(c[c.length-1]):s.identity()),n}function ht(e){let t=Ze(e);return new It(mt(t,{}),t.getAttribute(`viewBox`)?.trim().split(` `).map(e=>Number(e)))}var X=class{arcLengthDivision=200;_lengths=[];getPointAt(e,t=new i){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(e){let t=typeof e==`function`;return this.getControlPointRefs().forEach(n=>{t?e(n):e.apply(n,n)}),this}getUnevenVertices(e=5,t=[]){let n=new i;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPoint(r/i,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){let n=new i;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPointAt(r/i,n),t.push(n.x,n.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){let r=e[n],a=e[n+1];t.push(new i(r,a))}return t}getSpacedPoints(e,t=[]){let n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){let n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){let t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return n=e?this.getUnevenVertices(e):this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){let e=this.getLengths();return e[e.length-1]??0}getLengths(){return this._lengths.length!==this.arcLengthDivision+1&&this.updateLengths(),this._lengths}updateLengths(){let e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),i=1;i<=e;i++){let a=this.getPoint(i/e);n+=a.distanceTo(r),t.push(n),r=a}this._lengths=t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t??e*n[r-1];if(r<2)return i/n[0];let a=0,o=0,s=r-1,c;for(;o<=s;)if(a=Math.floor(o+(s-o)/2),c=n[a]-i,c<0)o=a+1;else if(c>0)s=a-1;else{s=a;break}if(a=Math.max(0,s),n[a]===i)return a/(r-1);let l=n[a],u=n[a+1]-l,d=Math.max(0,(i-l)/u);return(a+d)/(r-1)}getTangent(e,t=new i){let n=1e-4,r=Math.max(0,e-n),a=Math.min(1,e+n);return t.copyFrom(this.getPoint(a).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new i){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,i=(n+r)/2;for(;r-n>t;){i=(n+r)/2;let a=this.getPoint(i);if(a.distanceTo(e)<t)return i;a.x<e.x?n=i:r=i}return i}getMinMax(e=i.MAX,t=i.MIN){let n=this.getPoints();for(let r=0,i=n.length;r<i;r++){let i=n[r];e.clampMin(i),t.clampMax(i)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new a(e.x,e.y,t.x-e.x,t.y-e.y)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return me(this.getFillVertices(e),e)}strokeTriangulate(e){return ze(this.getAdaptiveVertices(),e)}toCommands(){let e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){let r=t[n];n===0?e.push({type:`M`,x:r.x,y:r.y}):e.push({type:`L`,x:r.x,y:r.y})}return e}toData(){return Ge(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case`M`:e.moveTo(t.x,t.y);break;case`L`:e.lineTo(t.x,t.y);break}}),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copyFrom(this)}},gt=new W,_t=new W,vt=new W,Z=new i,yt=class extends X{get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}constructor(e=new i,t=new i,n=new i,r=0,a=0,o=Math.PI*2,s=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=a,this.endAngle=o,this.clockwise=s}isClockwise(){return this.clockwise}_getDeltaAngle(){let e=Math.PI*2,t=this.endAngle-this.startAngle,n=Math.abs(t)<2**-52;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new i){let n=this._getDeltaAngle(),r=this.startAngle+e*n,a=this.cx+this.rx*Math.cos(r),o=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),n=a-this.cx,r=o-this.cy;a=n*e-r*t+this.cx,o=n*t+r*e+this.cy}return t.set(a,o)}toCommands(){let{cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,clockwise:o,rotate:s}=this,c=e+n*Math.cos(i)*Math.cos(s)-r*Math.sin(i)*Math.sin(s),l=t+n*Math.cos(i)*Math.sin(s)+r*Math.sin(i)*Math.cos(s),u=Math.abs(i-a),d=+(u>Math.PI),f=+!!o,p=s*180/Math.PI;if(u>=2*Math.PI){let a=i+Math.PI,o=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),u=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:o,y:u},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:c,y:l}]}else{let i=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),o=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:d,sweepFlag:f,x:i,y:o}]}}drawTo(e){let{cx:t,cy:n,rx:r,ry:i,rotate:a,startAngle:o,endAngle:s,clockwise:c}=this;return e.ellipse(t,n,r,i,a,o,s,!c),this}applyTransform(e){return Z.set(this.cx,this.cy),e.apply(Z,Z),this.cx=Z.x,this.cy=Z.y,Ct(e)?bt(this,e):xt(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,startAngle:s,endAngle:c,clockwise:l,rotate:u}=this,d=!l,f=Math.abs(s-c);(!d&&s>c||d&&c>s)&&(f=2*Math.PI-f);let p=Math.max(12,Math.floor(12*r**(1/3)*(f/Math.PI))),m=f/p,h=s;m*=d?-1:1;let g=Math.cos(d?u:-u),_=Math.sin(d?u:-u);for(let s=0;s<p+1;s++){let s=a+Math.cos(h)*r,c=o+Math.sin(h)*i,l=s*g-c*_,u=s*_+c*g;e.push(t+l,n+u),h+=m}return e}_getAdaptiveVerticesByCircle(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,rotate:s,clockwise:c}=this;if(!(r>=0&&i>=0&&a>=0&&o>=0))return e;let l=Math.ceil(2.3*Math.sqrt(r+i)),u=l*8+(a?4:0)+(o?4:0),d=[];if(u===0)return e;{let e=d.length;if(l===0)d[e]=d[e+6]=t+a,d[e+1]=d[e+3]=n+o,d[e+2]=d[e+4]=t-a,d[e+5]=d[e+7]=n-o;else{let s=e,c=e+l*4+(a?2:0)+2,f=c,p=u,m=a+r,h=o,g=t+m,_=t-m,v=n+h;if(d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,o){let e=n-h;d[f++]=_,d[f++]=e,d[--p]=e,d[--p]=g}for(let e=1;e<l;e++){let u=Math.PI/2*(e/l),m=a+Math.cos(u)*r,h=o+Math.sin(u)*i,g=t+m,_=t-m,v=n+h,y=n-h;d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,d[f++]=_,d[f++]=y,d[--p]=y,d[--p]=g}m=a,h=o+i,g=t+m,_=t-m,v=n+h;let y=n-h;d[s++]=g,d[s++]=v,d[--p]=y,d[--p]=g,a&&(d[s++]=_,d[s++]=v,d[--p]=y,d[--p]=_)}}let f=Math.cos(c?-s:s),p=Math.sin(c?-s:s);for(let r=0;r<d.length;r+=2){let i=d[r],a=d[r+1],o=i-t,s=a-n,c=o*f-s*p,l=o*p+s*f;e.push(t+c,n+l)}return e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}};function bt(e,t){let n=e.rx,r=e.ry,a=Math.cos(e.rotate),o=Math.sin(e.rotate),s=new i(n*a,n*o),c=new i(-r*o,r*a),l=t.a*s.x+t.c*s.y,u=t.b*s.x+t.d*s.y,d=t.a*c.x+t.c*c.y,f=t.b*c.x+t.d*c.y,p=gt.set(l,u,d,f,0,0),{a:m,b:h,c:g,d:_}=_t.copyFrom(p).affineInvert(),v=wt(m*m+h*h,g*m+_*h,g*g+_*_),y=Math.sqrt(v.rt1),b=Math.sqrt(v.rt2);if(e.rx=1/y,e.ry=1/b,e.rotate=Math.atan2(v.sn,v.cs),!((e.endAngle-e.startAngle)%(2*Math.PI)<2**-52)){let n=_t.set(y,0,0,b,0,0),r=vt.set(v.cs,v.sn,-v.sn,v.cs,0,0),i=n.append(r).append(p),a=e=>{let{x:t,y:n}=i.apply({x:Math.cos(e),y:Math.sin(e)});return Math.atan2(n,t)};e.startAngle=a(e.startAngle),e.endAngle=a(e.endAngle),St(t)&&(e.clockwise=!e.clockwise)}}function xt(e,t){let{scale:n}=t.decompose();e.rx*=n.x,e.ry*=n.y;let r=n.x>2**-52?Math.atan2(t.b,t.a):Math.atan2(-t.c,t.d);e.rotate+=r,St(t)&&(e.startAngle*=-1,e.endAngle*=-1,e.clockwise=!e.clockwise)}function St(e){return e.a*e.d-e.c*e.b<0}function Ct(e){let t=e.a*e.c+e.b*e.d;if(t===0)return!1;let{scale:n}=e.decompose();return Math.abs(t/(n.x*n.y))>2**-52}function wt(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?i=.5*(c-u):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}var Tt=class extends yt{constructor(e=0,t=0,n=1,r=0,a=Math.PI*2,o=!1){super(new i(e,t),new i(n,n),new i,0,r,a,o)}drawTo(e){let{cx:t,cy:n,rx:r,startAngle:i,endAngle:a,clockwise:o}=this;return e.arc(t,n,r,i,a,!o),this}},Q=class e extends X{static from(t,n,r,a){return new e(new i(t,n),new i(r,a))}constructor(e=new i,t=new i){super(),this.p1=e,this.p2=t}getPoint(e,t=new i){return e===1?t.copyFrom(this.p2):t.copyFrom(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new i){return this.getPoint(e,t)}getTangent(e,t=new i){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new i){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,p2:t}=this;return[{type:`M`,x:e.x,y:e.y},{type:`L`,x:t.x,y:t.y}]}getFillVertices(e={}){let t=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),i=Math.max(this.p1.y,this.p2.y),a=t,o=r,s=n-t||e.style?.strokeWidth||0,c=i-r||e.style?.strokeWidth||0;return[a,o,a+s,o,a+s,o+c,a,o+c]}drawTo(e){let{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.p2.copyFrom(e.p2),this}},Et=class e extends X{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(t=>t instanceof e?t.getFlatCurves():t)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new i){let n=e*this.getLength(),r=this.getLengths(),a=0;for(;a<r.length;){if(r[a]>=n){let e=r[a]-n,i=this.curves[a],o=i.getLength();return i.getPointAt(o===0?0:1-e/o,t)}a++}return t}getLengths(){return this._lengths.length!==this.curves.length&&this.updateLengths(),this._lengths}updateLengths(){let e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._lengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){let n=[e[t-1],e[t]],r=[e[t+1],e[t+2]];return n[0]===r[0]&&n[1]===r[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{let t=[],n;return this.curves.forEach(r=>{let i;i=r instanceof Q?r.getAdaptiveVertices():r.getFillVertices(e),t.push(...i),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=i.MAX,t=i.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new a(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this}copyFrom(e){return super.copyFrom(e),this.curves=e.curves.map(e=>e.clone()),this}},Dt=class e extends X{static from(t,n,r,a,o,s,c,l){return new e(new i(t,n),new i(r,a),new i(o,s),new i(c,l))}constructor(e=new i,t=new i,n=new i,r=new i){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}getPoint(e,t=new i){let{p1:n,cp1:r,cp2:a,p2:o}=this;return t.set(x(e,n.x,r.x,a.x,o.x),x(e,n.y,r.y,a.y,o.y))}getAdaptiveVertices(e=[]){return ye(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){let r=t*t-4*e*n;if(r<0)return[];let i=Math.sqrt(r);return[(-t+i)/(2*e),(-t-i)/(2*e)].filter(e=>e>=0&&e<=1)}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,cp1:r,cp2:a,p2:o}=this,s=this._solveQuadratic(3*(r.x-n.x),6*(a.x-r.x),3*(o.x-a.x)),c=this._solveQuadratic(3*(r.y-n.y),6*(a.y-r.y),3*(o.y-a.y));return((n,r)=>{for(let i of n)for(let n=0;n<=r;n++){let a=n/r-.5,o=Math.min(1,Math.max(0,i+a)),s=this.getPoint(o);e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),t.x=Math.max(t.x,s.x),t.y=Math.max(t.y,s.y)}})([0,1,...s,...c],10),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:`M`,x:e.x,y:e.y},{type:`C`,x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){let{p1:t,cp1:n,cp2:r,p2:i}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp1.copyFrom(e.cp1),this.cp2.copyFrom(e.cp2),this.p2.copyFrom(e.p2),this}},Ot=class extends yt{constructor(e=0,t=0,n=1,r=1,a=0,o=0,s=Math.PI*2,c=!1){super(new i(e,t),new i(n,r),new i,a,o,s,c)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}},kt=class extends Et{},At=class extends kt{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){let{cx:e,cy:t,radius:n,sideCount:r}=this,a=[];for(let o=0;o<r;o++){let s=o*2*Math.PI/r-.5*Math.PI;a.push(new i(n*Math.cos(s),n*Math.sin(s)).add({x:e,y:t}))}let o=[];for(let e=0;e<r;e++)o.push(new Q(a[e],a[(e+1)%r]));return this.curves=o,this}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}},jt=class e extends X{static from(t,n,r,a,o,s){return new e(new i(t,n),new i(r,a),new i(o,s))}constructor(e=new i,t=new i,n=new i){super(),this.p1=e,this.cp=t,this.p2=n}getPoint(e,t=new i){let{p1:n,cp:r,p2:a}=this;return t.set(Ie(e,n.x,r.x,a.x),Ie(e,n.y,r.y,a.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return Ee(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,cp:r,p2:a}=this,o=.5*(n.x+r.x),s=.5*(n.y+r.y),c=.5*(n.x+a.x),l=.5*(n.y+a.y);return e.x=Math.min(e.x,n.x,a.x,o,c),e.y=Math.min(e.y,n.y,a.y,s,l),t.x=Math.max(t.x,n.x,a.x,o,c),t.y=Math.max(t.y,n.y,a.y,s,l),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp:t,p2:n}=this;return[{type:`M`,x:e.x,y:e.y},{type:`Q`,x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){let{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp.copyFrom(e.cp),this.p2.copyFrom(e.p2),this}},Mt=class extends kt{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,a=[new i(e,t),new i(e+n,t),new i(e+n,t+r),new i(e,t+r)];return this.curves=[new Q(a[0],a[1]),new Q(a[1],a[2]),new Q(a[2],a[3]),new Q(a[3],a[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){let{x:t,y:n,width:r,height:i}=this;return[t,n,t+r,n,t+r,n+i,t,n+i]}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}},Nt=class extends yt{constructor(e=0,t=0,n=1,r=1,i=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.update()}update(){let{x:e,y:t,width:n,height:r,radius:a}=this,o=n/2,s=r/2,c=e+o,l=t+s,u=Math.max(0,Math.min(a,Math.min(o,s))),d=u;return this._center=new i(c,l),this._radius=new i(u,d),this._diff=new i(o-u,s-d),this}drawTo(e){let{x:t,y:n,width:r,height:i,radius:a}=this;return e.roundRect(t,n,r,i,a),this}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}},Pt=class extends X{constructor(e=[]){super(),this.points=e}getPoint(e,t=new i){let{points:n}=this,r=(n.length-1)*e,a=Math.floor(r),s=r-a,c=n[a===0?a:a-1],l=n[a],u=n[a>n.length-2?n.length-1:a+1],d=n[a>n.length-3?n.length-1:a+2];return t.set(o(s,c.x,l.x,u.x,d.x),o(s,c.y,l.y,u.y,d.y)),t}getControlPointRefs(){return this.points}copyFrom(e){super.copyFrom(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}},Ft=class extends Et{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++){let{x:n,y:r}=e[t];this.lineTo(n,r)}return this}addCommands(e){return We(e,this),this}addData(e){return this.addCommands(qe(e)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}_setCurrentPoint(e){return this.currentPoint=new i(e.x,e.y),this.startPoint||=this.currentPoint.clone(),this}_connetLineTo(e){if(this.curves.length>0){let t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){let e=this.startPoint;if(e){let t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Q(t.clone(),e.clone())),t.copyFrom(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new i(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){let n=this.currentPoint;return n?.equals({x:e,y:t})||this.curves.push(Q.from(n?.x??0,n?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,n,r,i,a){let o=this.currentPoint;return o?.equals({x:i,y:a})||this.curves.push(Dt.from(o?.x??0,o?.y??0,e,t,n,r,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(e,t,n,r){let i=this.currentPoint;return i?.equals({x:n,y:r})||this.curves.push(jt.from(i?.x??0,i?.y??0,e,t,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(e,t,n,r,i,a){let o=new Tt(e,t,n,r,i,!a);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(e,t,n,r,i,a){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return console.warn(`Method arcTo not supported yet`),this}ellipse(e,t,n,r,i,a,o,s=!0){let c=new Ot(e,t,n,r,i,a,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,n,r,i,a,o,s){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){let i=new Mt(e,t,n,r);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,n,r,i){let a=new Nt(e,t,n,r,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){let t=this.currentPoint??new i;return this.curves.push(new Pt([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this.autoClose&&e.closePath(),this}copyFrom(e){return super.copyFrom(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}},$=class e extends Et{_meta;currentCurve=new Ft;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??`none`)===`none`?0:1)}constructor(t,n={}){super(),this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof e?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(t){let n=t instanceof e?t.curves:[t];if(n.filter(e=>e.curves.length).length===0)return this;if(!this.currentCurve.curves.length){let e=this.curves.findIndex(e=>e===this.currentCurve);e>-1&&this.curves.splice(e,1)}return this.curves.push(...n.map(e=>e.clone())),this.currentCurve=this.curves[this.curves.length-1],this}closePath(){let e=this.startPoint;return e&&this.currentCurve.curves.length&&(this.currentCurve.closePath(),this.currentCurve=new Ft().moveTo(e.x,e.y),this.curves.push(this.currentCurve)),this}moveTo(e,t){return this.currentCurve.currentPoint?.equals({x:e,y:t})||(this.currentCurve.curves.length&&(this.currentCurve=new Ft,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t)),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a){return this.currentCurve.bezierCurveTo(e,t,n,r,i,a),this}quadraticCurveTo(e,t,n,r){return this.currentCurve.quadraticCurveTo(e,t,n,r),this}arc(e,t,n,r,i,a){return this.currentCurve.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return this.currentCurve.arcTo(e,t,n,r,i),this}ellipse(e,t,n,r,i,a,o,s){return this.currentCurve.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){return this.currentCurve.rect(e,t,n,r),this}roundRect(e,t,n,r,i){return this.currentCurve.roundRect(e,t,n,r,i),this}reset(){return this.currentCurve=new Ft,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return We(e,this),this}addData(e){return this.addCommands(qe(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(e,t,n)}),this}skew(e,t=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(e,t,n)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(e,t)}),this}bold(e){if(e===0)return this;let t=this.getFlatCurves(),n=[],r=[],i=[];t.forEach((e,t)=>{let a=e.getControlPointRefs(),o=e.isClockwise();i[t]=a,r[t]=o;let s=a[0],c=a[a.length-1]??s;n.push({start:o?c:s,end:o?s:c,index:t})});let a=[];return n.forEach((e,t)=>{a[t]=[],n.forEach((n,r)=>{n.start&&e.end&&r!==t&&n.start?.equals(e.end)&&a[t].push(n.index)})}),t.forEach((t,n)=>{let a=r[n];i[n].forEach(n=>{n.add(t.getNormal(t.getTForPoint(n)).scale(a?e:-e))})}),a.forEach((e,t)=>{let n=i[t];e.forEach(e=>{let t=i[e],r=u(n[n.length-1],n[n.length-2]??n[n.length-1],t[0],t[1]??t[0]);r&&(n[n.length-1].copyFrom(r),t[0].copyFrom(r))})}),this}getMinMax(e=i.MAX,t=i.MIN,n=!0){let r=this.strokeWidth;return this.curves.forEach(i=>{if(i.getMinMax(e,t),n&&r>1){let n=r/2,a=i.isClockwise(),o=[];for(let e=0;e<=1;e+=1/i.arcLengthDivision){let t=i.getPoint(e),r=i.getNormal(e),s=r.clone().scale(a?n:-n),c=r.clone().scale(a?-n:n);o.push(t.clone().add(s),t.clone().add(c),t.clone().add({x:n,y:0}),t.clone().add({x:-n,y:0}),t.clone().add({x:0,y:n}),t.clone().add({x:0,y:-n}),t.clone().add({x:n,y:n}),t.clone().add({x:-n,y:-n}))}e.clampMin(...o),t.clampMax(...o)}}),{min:e.finite(),max:t.finite()}}strokeTriangulate(e){let t=e?.indices??[],n=e?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...e,indices:t,vertices:n,style:{...this.style}})}),{indices:t,vertices:n}}fillTriangulate(e){let t={...e,style:{...this.style,...e?.style}},n=t.indices??[],r=t.vertices??[];if((t.style.fillRule??`nonzero`)===`nonzero`){let i=this.curves.map(e=>e.getFillVertices(t)),a=Me(i),o=a.length;for(let t=0;t<o;t++){let s=a[t],c=i[t];if(s.winding||!c.length)continue;let l=c.slice(),u=[];for(let e=0;e<o;e++){let n=a[e];n.parentIndex===t&&(u.push(l.length/2),l.push(...i[n.index]))}me(l,{...e,indices:n,vertices:r,holes:u,style:{...this.style}})}}else this.curves.forEach(t=>{t.fillTriangulate({...e,indices:n,vertices:r,style:{...this.style}})});return{indices:n,vertices:r}}getBoundingBox(e=!0){let{min:t,max:n}=this.getMinMax(void 0,void 0,e);return new a(t.x,t.y,n.x-t.x,n.y-t.y)}drawTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:i=`none`}=t;return e.beginPath(),e.save(),r(e,t),this.curves.forEach(t=>{t.drawTo(e)}),n!==`none`&&e.fill(),i!==`none`&&e.stroke(),e.restore(),this}drawControlPointsTo(e,n={}){n={...this.style,...n};let{fill:i=`#000`,stroke:a=`none`}=n;return e.beginPath(),e.save(),r(e,n),this.getControlPointRefs().forEach(n=>{t(e,n.x,n.y,{radius:4})}),i!==`none`&&e.fill(),a!==`none`&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(` `)}toSvgPathString(){let e={...this.style,fill:this.style.fill??`#000`,stroke:this.style.stroke??`none`},t={};for(let n in e)e[n]!==void 0&&(t[l(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let n=``;for(let e in t)t[e]!==void 0&&(n+=`${e}:${t[e]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copyFrom(e){return super.copyFrom(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}},It=class{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;let t=i.MAX,n=i.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new a(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSvgString(e=this.paths.map(e=>e.fillTriangulate()),t=0){let n=``,r=``,i={x:-t,y:-t},a={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:e,indices:o,points:s=[]})=>{let c=n=>{let r=e[n*2],o=e[n*2+1];return i.x=Math.min(i.x,r+t),a.x=Math.max(a.x,r+t),i.y=Math.min(i.y,o+t),a.y=Math.max(a.y,o+t),[r,o]};for(let e=0,t=o.length;e<t;e+=3){let t=c(o[e]),r=c(o[e+1]),i=c(o[e+2]);n+=`<polygon
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.modernPath2d={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,n,r={}){let{radius:i=1}=r;e.moveTo(t,n),e.arc(t,n,i,0,Math.PI*2)}var n={arcs:`bevel`,bevel:`bevel`,miter:`miter`,"miter-clip":`miter`,round:`round`};function r(e,t){let{fill:r=`#000`,stroke:i=`none`,strokeWidth:a=i===`none`?0:1,strokeLinecap:o=`round`,strokeLinejoin:s=`miter`,strokeMiterlimit:c=0,strokeDasharray:l=[],strokeDashoffset:u=0,shadowOffsetX:d=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:m=`rgba(0, 0, 0, 0)`}=t;e.fillStyle=r,e.strokeStyle=i,e.lineWidth=a,e.lineCap=o,e.lineJoin=n[s],e.miterLimit=c,e.setLineDash(l),e.lineDashOffset=u,e.shadowOffsetX=d,e.shadowOffsetY=f,e.shadowBlur=p,e.shadowColor=m}var i=class e{static get MAX(){return new e(1/0,1/0)}static get MIN(){return new e(-1/0,-1/0)}static lerp(t,n,r){return new e(n.x,n.y).clone().sub(t).multiply(r).add(t)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._onUpdate?.(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._onUpdate?.(this))}constructor(e=0,t=0,n){this._x=e,this._y=t,this._onUpdate=n}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._onUpdate?.(this)),this}add(e){return this.set(this._x+e.x,this._y+e.y)}sub(e){return this.set(this._x-e.x,this._y-e.y)}subVectors(e,t){return this.set(e.x-t.x,e.y-t.y)}multiply(e=0,t=e){return this.set(this._x*e,this._y*t)}divide(e=0,t=e){return this.set(this._x/e,this._y/t)}cross(e){return this._x*e.y-this._y*e.x}dot(e){return this._x*e.x+this._y*e.y}rotate(e,t={x:0,y:0}){let{x:n,y:r}=this,i=Math.cos(e),a=Math.sin(e);return this.set((n-t.x)*i-(r-t.y)*a+t.x,(n-t.x)*a+(r-t.y)*i+t.y)}getLength(){let{x:e,y:t}=this;return Math.sqrt(e*e+t*t)}getAngle(){return Math.atan2(-this.x,-this.y)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){let e=1/(this.getLength()||1);return this.set(this.x*e,this.y*e),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._onUpdate?.(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return this._x===e.x&&this._y===e.y}get array(){return[this.x,this.y]}finite(){return this.set(Number.isFinite(this._x)?this._x:0,Number.isFinite(this._y)?this._y:0)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){return this.set(n.x+(this._x-n.x)*e,n.y+(this._y-n.y)*t)}skew(e,t=0,n={x:0,y:0}){let r=this._x-n.x,i=this._y-n.y;return this.set(n.x+(r+Math.tan(e)*i),n.y+(i+Math.tan(t)*r))}clampMin(...e){return this.set(Math.min(this._x,...e.map(e=>e.x)),Math.min(this._y,...e.map(e=>e.y)))}clampMax(...e){return this.set(Math.max(this.x,...e.map(e=>e.x)),Math.max(this.y,...e.map(e=>e.y)))}clone(t){return new e(this._x,this._y,t??this._onUpdate)}toJSON(){return{x:this._x,y:this._y}}destroy(){this._onUpdate=void 0}},a=class e{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}get center(){return new i((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}static from(...t){if(t.length===0)return new e;if(t.length===1)return t[0].clone();let n=t[0],r=t.slice(1).reduce((e,t)=>(e.left=Math.min(e.left,t.left),e.top=Math.min(e.top,t.top),e.right=Math.max(e.right,t.right),e.bottom=Math.max(e.bottom,t.bottom),e),{left:n?.left??0,top:n?.top??0,right:n?.right??0,bottom:n?.bottom??0});return new e(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new e(this.left,this.top,this.width,this.height)}};function o(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}var s=Math.PI,c=s*2;function l(e){return e.replace(/[^a-z0-9]/gi,`-`).replace(/\B([A-Z])/g,`-$1`).toLowerCase()}function u(e,t,n,r){let a=t.clone().sub(e),o=r.clone().sub(n),s=n.clone().sub(e),c=a.cross(o);if(c===0)return new i((e.x+n.x)/2,(e.y+n.y)/2);let l=s.cross(o)/c;return Math.abs(l)>1?new i((e.x+n.x)/2,(e.y+n.y)/2):new i(e.x+l*a.x,e.y+l*a.y)}var d=/([\w-]+)\((.+?)\)/g,f=/[^,]+/g,p=/([-e.\d]+)(.*)/;function m(e,t={}){let n=[],r;for(;(r=d.exec(e))!==null;){let[,e,i]=r;e&&n.push({name:e,args:h(e,i,t)})}return n}function h(e,t,n={}){let r=[],i,a=0;for(;(i=f.exec(t))!==null;)r.push(g(e,i[0],{...n,index:a++}));return r}function g(e,t,n={}){let{width:r=1,height:i=1,index:a=0}=n,o=t.match(p),s={unit:o?.[2]??null,value:t,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(e){case`scale`:case`scaleX`:case`scaleY`:case`scale3d`:s.normalizedDefaultIntValue=1;break}switch(s.unit){case`%`:s.normalizedIntValue=s.intValue/100;break;case`rad`:s.normalizedIntValue=s.intValue/c;break;case`deg`:s.normalizedIntValue=s.intValue/360;break;case`px`:switch(a){case 0:s.normalizedIntValue=s.intValue/r;break;case 1:s.normalizedIntValue=s.intValue/i;break}break;default:s.normalizedIntValue=s.intValue;break}return s}function _(e,t){let n=1-e;return n*n*n*t}function v(e,t){let n=1-e;return 3*n*n*e*t}function y(e,t){return 3*(1-e)*e*e*t}function b(e,t){return e*e*e*t}function x(e,t,n,r,i){return _(e,t)+v(e,n)+y(e,r)+b(e,i)}function S(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=C(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=A(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return T(a,o,n,s,c,l,0),o}function C(e,t,n,r,i){let a;if(i===me(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=de(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=de(i/r|0,e[i],e[i+1],a);return a&&R(a,a.next)&&(fe(a),a=a.next),a}function w(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(R(n,n.next)||L(n.prev,n,n.next)===0)){if(fe(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function T(e,t,n,r,i,a,o){if(!e)return;!o&&a&&F(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?D(e,r,i,a):E(e)){t.push(c.i,e.i,l.i),fe(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=O(w(e),t),T(e,t,n,r,i,a,2)):o===2&&k(e,t,n,r,i,a):T(w(e),t,n,r,i,a,1);break}}}function E(e){let t=e.prev,n=e,r=e.next;if(L(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&re(i,s,a,c,o,l,m.x,m.y)&&L(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function D(e,t,n,r){let i=e.prev,a=e,o=e.next;if(L(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=ee(p,m,t,n,r),v=ee(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&re(s,u,c,d,l,f,y.x,y.y)&&L(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&re(s,u,c,d,l,f,b.x,b.y)&&L(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&re(s,u,c,d,l,f,y.x,y.y)&&L(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&re(s,u,c,d,l,f,b.x,b.y)&&L(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function O(e,t){let n=e;do{let r=n.prev,i=n.next.next;!R(r,i)&&ae(r,n,n.next,i)&&z(r,i)&&z(i,r)&&(t.push(r.i,n.i,i.i),fe(n),fe(n.next),n=e=i),n=n.next}while(n!==e);return w(n)}function k(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&ie(o,e)){let s=ue(o,e);o=w(o,o.next),s=w(s,s.next),T(o,t,n,r,i,a,0),T(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function A(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=C(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(te(o))}i.sort(j);for(let e=0;e<i.length;e++)n=M(i[e],n);return n}function j(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function M(e,t){let n=N(e,t);if(!n)return t;let r=ue(n,e);return w(r,r.next),w(n,n.next)}function N(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(R(e,n))return n;do{if(R(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&ne(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);z(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&P(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function P(e,t){return L(e.prev,e,t.prev)<0&&L(t.next,e,e.next)<0}function F(e,t,n,r){let i=e;do i.z===0&&(i.z=ee(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,I(i)}function I(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function ee(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function te(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function ne(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function re(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&ne(e,t,n,r,i,a,o,s)}function ie(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ce(e,t)&&(z(e,t)&&z(t,e)&&le(e,t)&&(L(e.prev,e,t.prev)||L(e,t.prev,t))||R(e,t)&&L(e.prev,e,e.next)>0&&L(t.prev,t,t.next)>0)}function L(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function R(e,t){return e.x===t.x&&e.y===t.y}function ae(e,t,n,r){let i=se(L(e,t,n)),a=se(L(e,t,r)),o=se(L(n,r,e)),s=se(L(n,r,t));return!!(i!==a&&o!==s||i===0&&oe(e,n,t)||a===0&&oe(e,r,t)||o===0&&oe(n,e,r)||s===0&&oe(n,t,r))}function oe(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function se(e){return e>0?1:e<0?-1:0}function ce(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ae(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function z(e,t){return L(e.prev,e,e.next)<0?L(e,t,e.next)>=0&&L(e,e.prev,t)>=0:L(e,t,e.prev)<0||L(e,e.next,t)<0}function le(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function ue(e,t){let n=pe(e.i,e.x,e.y),r=pe(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function de(e,t,n,r){let i=pe(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function fe(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function pe(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function me(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function he(e,t={}){let{vertices:n=[],indices:r=[],holes:i=[],verticesStride:a=2,verticesOffset:o=n.length/a,indicesOffset:s=r.length}=t,c=S(e,i,2);if(c.length){for(let e=0;e<c.length;e+=3)r[s++]=c[e]+o,r[s++]=c[e+1]+o,r[s++]=c[e+2]+o;let t=o*a;for(let r=0;r<e.length;r+=2)n[t]=e[r],n[t+1]=e[r+1],t+=a}return{vertices:n,indices:r}}var ge=8,_e=1.1920929e-7,ve=1,ye=.01,B=0,V=0;function be(e,t,n,r,i,a,o,s,c=.5,l=[]){let u=(ve-Math.min(.99,Math.max(0,c)))/1;return u*=u,xe(e,t,n,r,i,a,o,s,l,u,0),l.push(o,s),l}function xe(e,t,n,r,i,a,o,s,c,l,u){if(u>ge)return;let d=Math.PI,f=(e+n)/2,p=(t+r)/2,m=(n+i)/2,h=(r+a)/2,g=(i+o)/2,_=(a+s)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(h+_)/2,S=(v+b)/2,C=(y+x)/2;if(u>0){let u=o-e,f=s-t,p=Math.abs((n-o)*f-(r-s)*u),m=Math.abs((i-o)*f-(a-s)*u),h,g;if(p>_e&&m>_e){if((p+m)*(p+m)<=l*(u*u+f*f)){if(B<ye){c.push(S,C);return}let l=Math.atan2(a-r,i-n);if(h=Math.abs(l-Math.atan2(r-t,n-e)),g=Math.abs(Math.atan2(s-a,o-i)-l),h>=d&&(h=2*d-h),g>=d&&(g=2*d-g),h+g<B){c.push(S,C);return}if(V!==0){if(h>V){c.push(n,r);return}if(g>V){c.push(i,a);return}}}}else if(p>_e){if(p*p<=l*(u*u+f*f)){if(B<ye){c.push(S,C);return}if(h=Math.abs(Math.atan2(a-r,i-n)-Math.atan2(r-t,n-e)),h>=d&&(h=2*d-h),h<B){c.push(n,r),c.push(i,a);return}if(V!==0&&h>V){c.push(n,r);return}}}else if(m>_e){if(m*m<=l*(u*u+f*f)){if(B<ye){c.push(S,C);return}if(h=Math.abs(Math.atan2(s-a,o-i)-Math.atan2(a-r,i-n)),h>=d&&(h=2*d-h),h<B){c.push(n,r),c.push(i,a);return}if(V!==0&&h>V){c.push(i,a);return}}}else if(u=S-(e+o)/2,f=C-(t+s)/2,u*u+f*f<=l){c.push(S,C);return}}xe(e,t,f,p,v,y,S,C,c,l,u+1),xe(S,C,b,x,g,_,o,s,c,l,u+1)}var Se=8,Ce=1.1920929e-7,we=1,Te=.01,Ee=0;function De(e,t,n,r,i,a,o=.5,s=[]){let c=(we-Math.min(.99,Math.max(0,o)))/1;return c*=c,Oe(s,e,t,n,r,i,a,c,0),s.push(i,a),s}function Oe(e,t,n,r,i,a,o,s,c){if(c>Se)return;let l=Math.PI,u=(t+r)/2,d=(n+i)/2,f=(r+a)/2,p=(i+o)/2,m=(u+f)/2,h=(d+p)/2,g=a-t,_=o-n,v=Math.abs((r-a)*_-(i-o)*g);if(v>Ce){if(v*v<=s*(g*g+_*_)){if(Ee<Te){e.push(m,h);return}let s=Math.abs(Math.atan2(o-i,a-r)-Math.atan2(i-n,r-t));if(s>=l&&(s=2*l-s),s<Ee){e.push(m,h);return}}}else if(g=m-(t+a)/2,_=h-(n+o)/2,g*g+_*_<=s){e.push(m,h);return}Oe(e,t,n,u,d,m,h,s,c+1),Oe(e,m,h,f,p,a,o,s,c+1)}function ke(e){let t=0,n=e.length;for(let r=0;r<n;r+=2){let i=e[r],a=e[r+1],o=e[(r+2)%n],s=e[(r+3)%n];t+=i*s-o*a}return t/2}function Ae(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function je(e,t,n){let r=n.length,i=0;for(let a=0,o=r-2;a<r;o=a,a+=2){let r=n[a],s=n[a+1],c=n[o],l=n[o+1];s<=t?l>t&&Ae(c,l,r,s,e,t)>0&&i++:l<=t&&Ae(c,l,r,s,e,t)<0&&i--}return i}function Me(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function Ne(e){let t=e.map((e,t)=>({index:t})),n=e.map(e=>{let t=e.length;if(!t)return[];let n=[2**53-1,0],r=[0,2**53-1],i=[-(2**53-1),0],a=[0,-(2**53-1)];for(let o=0;o<t;o+=2){let t=e[o],s=e[o+1];n[0]>t&&(n=[t,s]),r[1]>s&&(r=[t,s]),i[0]<t&&(i=[t,s]),a[1]<s&&(a=[t,s])}let o=[(n[0]+i[0])/2,(r[1]+a[1])/2],s,c,l,u,d,f,p,m;for(let n=0;n<t;n+=2){let t=e[n],r=e[n+1],i=Math.abs(t-o[0]),a=Math.abs(r-o[1]);r<o[1]&&(!s||i<s)&&(s=i,l=[t,r]),r>o[1]&&(!c||i<c)&&(c=i,u=[t,r]),t<o[0]&&(!d||a<d)&&(d=a,p=[t,r]),t>o[0]&&(!f||a<f)&&(f=a,m=[t,r])}return[n,r,i,a,l,u,p,m].filter(Boolean)});for(let r=0,i=e.length;r<i;r++){let a=[],o=n[r];for(let t=0;t<i;t++){if(r===t)continue;let i={},s=[];for(let n=0,r=o.length;n<r;n++){let[r,a]=o[n],c=je(r,a,e[t]);i[c]=(i[c]??0)+1,s.push(c)}s.filter(e=>e!==0).length>s.filter(e=>e===0).length&&a.push({index:r,parentIndex:t,winding:Number(Array.from(Object.entries(i)).sort((e,t)=>t[1]-e[1])?.[0]?.[0]??0),dist:Me(n[r][0],n[t][0])})}a.reduce((e,t)=>e+t.winding,0)!==0&&(a.sort((e,t)=>e.dist-t.dist),t[r]=a[0])}return t}function Pe(e,t){let n=1-e;return n*n*t}function Fe(e,t){return 2*(1-e)*e*t}function Ie(e,t){return e*e*t}function H(e,t,n,r){return Pe(e,t)+Fe(e,n)+Ie(e,r)}var Le=1e-4,Re=1e-4;function ze(e,t={}){let{vertices:n=[],indices:r=[],lineStyle:i={alignment:.5,cap:`butt`,join:`miter`,width:1,miterLimit:10},flipAlignment:a=!1,closed:o=!0}=t,s=Le;if(e.length===0)return{vertices:n,indices:r};let c=i,l=c.alignment;if(i.alignment!==.5){let t=Be(e);a&&(t*=-1),l=(l-.5)*t+.5}let u={x:e[0],y:e[1]},d={x:e[e.length-2],y:e[e.length-1]},f=o,p=Math.abs(u.x-d.x)<s&&Math.abs(u.y-d.y)<s;if(f){e=e.slice(),p&&(e.pop(),e.pop(),d.x=e[e.length-2],d.y=e[e.length-1]);let t=(u.x+d.x)*.5,n=(d.y+u.y)*.5;e.unshift(t,n),e.push(t,n)}let m=n,h=e.length/2,g=e.length,_=m.length/2,v=c.width/2,y=v*v,b=c.miterLimit*c.miterLimit,x=e[0],S=e[1],C=e[2],w=e[3],T=0,E=0,D=-(S-w),O=x-C,k=0,A=0,j=Math.sqrt(D*D+O*O);D/=j,O/=j,D*=v,O*=v;let M=l,N=(1-M)*2,P=M*2;f||(c.cap===`round`?g+=U(x-D*(N-P)*.5,S-O*(N-P)*.5,x-D*N,S-O*N,x+D*P,S+O*P,m,!0)+2:c.cap===`square`&&(g+=Ve(x,S,D,O,N,P,!0,m))),m.push(x-D*N,S-O*N),m.push(x+D*P,S+O*P);for(let t=1;t<h-1;++t){x=e[(t-1)*2],S=e[(t-1)*2+1],C=e[t*2],w=e[t*2+1],T=e[(t+1)*2],E=e[(t+1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,k=-(w-E),A=C-T,j=Math.sqrt(k*k+A*A),k/=j,A/=j,k*=v,A*=v;let n=C-x,r=S-w,i=C-T,a=E-w,o=n*i+r*a,s=r*i-a*n,l=s<0;if(Math.abs(s)<.001*Math.abs(o)){m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),o>=0&&(c.join===`round`?g+=U(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4:g+=2,m.push(C-k*P,w-A*P),m.push(C+k*N,w+A*N));continue}let u=(-D+x)*(-O+w)-(-D+C)*(-O+S),d=(-k+T)*(-A+w)-(-k+C)*(-A+E),f=(n*d-i*u)/s,p=(a*u-r*d)/s,h=(f-C)*(f-C)+(p-w)*(p-w),_=C+(f-C)*N,M=w+(p-w)*N,F=C-(f-C)*P,I=w-(p-w)*P,ee=Math.min(n*n+r*r,i*i+a*a),te=l?N:P;h<=ee+te*te*y?c.join===`bevel`||h/y>b?(l?(m.push(_,M),m.push(C+D*P,w+O*P),m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),m.push(C-k*N,w-A*N),m.push(F,I)),g+=2):c.join===`round`?l?(m.push(_,M),m.push(C+D*P,w+O*P),g+=U(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+4,m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),g+=U(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4,m.push(C-k*N,w-A*N),m.push(F,I)):(m.push(_,M),m.push(F,I)):(m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),c.join===`round`?l?g+=U(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+2:g+=U(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+2:c.join===`miter`&&h/y<=b&&(l?(m.push(F,I),m.push(F,I)):(m.push(_,M),m.push(_,M)),g+=2),m.push(C-k*N,w-A*N),m.push(C+k*P,w+A*P),g+=2)}x=e[(h-2)*2],S=e[(h-2)*2+1],C=e[(h-1)*2],w=e[(h-1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),f||(c.cap===`round`?g+=U(C-D*(N-P)*.5,w-O*(N-P)*.5,C-D*N,w-O*N,C+D*P,w+O*P,m,!1)+2:c.cap===`square`&&(g+=Ve(C,w,D,O,N,P,!1,m)));let F=Re*Re;for(let e=_;e<g+_-2;++e)x=m[e*2],S=m[e*2+1],C=m[(e+1)*2],w=m[(e+1)*2+1],T=m[(e+2)*2],E=m[(e+2)*2+1],!(Math.abs(x*(w-E)+C*(E-S)+T*(S-w))<F)&&r.push(e,e+1,e+2);return{vertices:n,indices:r}}function Be(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function Ve(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function U(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}var W=class e{_array;constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}skewX(e){let t=Math.tan(e);return this.a+=t*this.b,this.c+=t*this.d,this.tx+=t*this.ty,this}skewY(e){let t=Math.tan(e);return this.b+=t*this.a,this.d+=t*this.c,this.ty+=t*this.tx,this}skew(e,t){let n=Math.tan(e),r=Math.tan(t),i=this.a,a=this.b,o=this.c,s=this.d,c=this.tx,l=this.ty;return this.a=i+n*a,this.b=r*i+a,this.c=o+n*s,this.d=r*o+s,this.tx=c+n*l,this.ty=r*c+l,this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,n){return this.translate(e,t,n)}translate(e,t,n=0){return this.tx+=e,this.ty+=t,this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,n=1){return this.scale(e,t,n)}scale(e,t,n=1){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}rotate3d(e,t,n,r){let[i,a,o]=this._rotate3d(e,t,n,r);return i&&this.rotateX(i),a&&this.rotateY(a),o&&this.rotateZ(o),this}_rotateToScale(e){let t=e/c;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,n,r){if(e===1&&t===0&&n===0)return[r,0,0];if(e===0&&t===1&&n===0)return[0,r,0];if(e===0&&t===0)return[0,0,r];{let i=Math.cos(r),a=Math.sin(r),o=i+e*e*(1-i),s=e*t*(1-i)-n*a,c=e*n*(1-i)+t*a,l=i+t*t*(1-i),u=t*n*(1-i)-e*a,d=i+n*n*(1-i);return[-Math.atan2(-u,l),-Math.atan2(c,Math.sqrt(u*u+d*d)),-Math.atan2(-s,o)]}}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,l=-Math.atan2(-i,a),u=Math.atan2(r,n),d=Math.abs(l+u);return d<1e-5||Math.abs(c-d)<1e-5?(t.rotation=u,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=l,t.skew.y=u),t.scale.x=Math.sqrt(n*n+r*r),t.scale.y=Math.sqrt(i*i+a*a),t.position.x=o+(e.x*n+e.y*i),t.position.y=s+(e.x*r+e.y*a),t}apply(e,t){t||=new i;let{x:n,y:r}=e;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}affineInvert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t||=new i;let{a:n,b:r,c:a,d:o,tx:s,ty:c}=this,l=1/(n*o+a*-r),u=e.x,d=e.y;return t.x=o*l*u+-a*l*d+(c*a-s*o)*l,t.y=n*l*d+-r*l*u+(-c*n+s*r)*l,t}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}isIdentity(){let{a:e,b:t,c:n,d:r,tx:i,ty:a}=this;return e===1&&t===0&&n===0&&r===1&&i===0&&a===0}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}prependCssTransform(t,n={}){let{width:r=1,height:i=1}=n,a=new e;return m(t,{width:r,height:i}).reverse().forEach(({name:e,args:t})=>{let n=t.map(e=>e.normalizedIntValue);switch(e){case`translateX`:a.translateX(n[0]*r);break;case`translateY`:a.translateY(n[0]*i);break;case`translateZ`:a.translateZ(n[0]);break;case`translate`:a.translate(n[0]*r,(n[1]??n[0])*i);break;case`translate3d`:a.translate3d(n[0]*r,(n[1]??n[0])*i,n[2]??n[1]??n[0]);break;case`scaleX`:a.scaleX(n[0]);break;case`scaleY`:a.scaleY(n[0]);break;case`scale`:a.scale(n[0],n[1]??n[0]);break;case`scale3d`:a.scale3d(n[0],n[1]??n[0],n[2]??n[1]??n[0]);break;case`rotateX`:a.rotateX(n[0]*c);break;case`rotateY`:a.rotateY(n[0]*c);break;case`rotateZ`:a.rotateZ(n[0]*c);break;case`rotate`:a.rotate(n[0]*c);break;case`rotate3d`:a.rotate3d(n[0]*c,(n[1]??n[0])*c,(n[2]??n[1]??n[0])*c,(n[3]??n[2]??n[1]??n[0])*c);break;case`skewX`:a.skewX(n[0]*c);break;case`skewY`:a.skewY(n[0]*c);break;case`skew`:a.skew(n[0]*c,(n[0]??n[1])*c);break;case`matrix`:a.set(n[0],n[1],n[2],n[3],n[4],n[5]);break}}),this.prepend(a),this}clone(){return new e(this.a,this.b,this.c,this.d,this.tx,this.ty)}toArray(e,t){this._array||=new Float32Array(9);let n=t||this._array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}toString(){return`[Transform2D a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}destroy(){this._array=void 0}};function He(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function Ue(e,t,n,r,i,a,o,s){if(t===0||n===0){e.lineTo(s.x,s.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let c=(o.x-s.x)/2,l=(o.y-s.y)/2,u=Math.cos(r)*c+Math.sin(r)*l,d=-Math.sin(r)*c+Math.cos(r)*l,f=t*t,p=n*n,m=u*u,h=d*d,g=m/f+h/p;if(g>1){let e=Math.sqrt(g);t=e*t,n=e*n,f=t*t,p=n*n}let _=f*h+p*m,v=(f*p-_)/_,y=Math.sqrt(Math.max(0,v));i===a&&(y=-y);let b=y*t*d/n,x=-y*n*u/t,S=Math.cos(r)*b-Math.sin(r)*x+(o.x+s.x)/2,C=Math.sin(r)*b+Math.cos(r)*x+(o.y+s.y)/2,w=He(1,0,(u-b)/t,(d-x)/n),T=He((u-b)/t,(d-x)/n,(-u-b)/t,(-d-x)/n)%(Math.PI*2);e.ellipse(S,C,t,n,r,w,w+T,a===0)}var G={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function K(e,t,n=0){let r=0,i=!0,a=``,o=``,s=[];function c(e,t,n){let r=SyntaxError(`Unexpected character "${e}" at index ${t}.`);throw r.partial=n,r}function l(){a!==``&&(o===``?s.push(Number(a)):s.push(Number(a)*10**Number(o))),a=``,o=``}let u,d=e.length;for(let f=0;f<d;f++){if(u=e[f],Array.isArray(t)&&t.includes(s.length%n)&&G.FLAGS.test(u)){r=1,a=u,l();continue}if(r===0){if(G.WHITESPACE.test(u))continue;if(G.DIGIT.test(u)||G.SIGN.test(u)){r=1,a=u;continue}if(G.POINT.test(u)){r=2,a=u;continue}G.COMMA.test(u)&&(i&&c(u,f,s),i=!0)}if(r===1){if(G.DIGIT.test(u)){a+=u;continue}if(G.POINT.test(u)){a+=u,r=2;continue}if(G.EXP.test(u)){r=3;continue}G.SIGN.test(u)&&a.length===1&&G.SIGN.test(a[0])&&c(u,f,s)}if(r===2){if(G.DIGIT.test(u)){a+=u;continue}if(G.EXP.test(u)){r=3;continue}G.POINT.test(u)&&a[a.length-1]===`.`&&c(u,f,s)}if(r===3){if(G.DIGIT.test(u)){o+=u;continue}if(G.SIGN.test(u)){if(o===``){o+=u;continue}o.length===1&&G.SIGN.test(o)&&c(u,f,s)}}G.WHITESPACE.test(u)?(l(),r=0,i=!1):G.COMMA.test(u)?(l(),r=0,i=!0):G.SIGN.test(u)?(l(),r=1,a=u):G.POINT.test(u)?(l(),r=2,a=u):c(u,f,s)}return l(),s}function q(e,t){return e-(t-e)}function We(e,t){let n=new i,r=new i,a=``;for(let i=0,o=e.length;i<o;i++){let o=e[i];if(((o.type===`s`||o.type===`S`)&&!`CcSs`.includes(a)||(o.type===`t`||o.type===`T`)&&!`QqTt`.includes(a))&&r.copyFrom(n),o.type===`m`||o.type===`M`)o.type===`m`?n.add(o):n.copyFrom(o),t.moveTo(n.x,n.y),r.copyFrom(n);else if(o.type===`h`||o.type===`H`)o.type===`h`?n.x+=o.x:n.x=o.x,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`v`||o.type===`V`)o.type===`v`?n.y+=o.y:n.y=o.y,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`l`||o.type===`L`)o.type===`l`?n.add(o):n.copyFrom(o),t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`c`||o.type===`C`)o.type===`c`?(t.bezierCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`s`||o.type===`S`)o.type===`s`?(t.bezierCurveTo(q(n.x,r.x),q(n.y,r.y),n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(q(n.x,r.x),q(n.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`q`||o.type===`Q`)o.type===`q`?(t.quadraticCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x,n.y+o.y),r.x=n.x+o.x1,r.y=n.y+o.y1,n.add(o)):(t.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,n.copyFrom(o));else if(o.type===`t`||o.type===`T`){let e=q(n.x,r.x),i=q(n.y,r.y);r.x=e,r.y=i,o.type===`t`?(t.quadraticCurveTo(e,i,n.x+o.x,n.y+o.y),n.add(o)):(t.quadraticCurveTo(e,i,o.x,o.y),n.copyFrom(o))}else if(o.type===`a`||o.type===`A`){let e=n.clone();if(o.type===`a`){if(o.x===0&&o.y===0)continue;n.add(o)}else{if(n.equals(o))continue;n.copyFrom(o)}r.copyFrom(n),Ue(t,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,e,n)}else o.type===`z`||o.type===`Z`?(t.startPoint&&n.copyFrom(t.startPoint),t.closePath()):console.warn(`Unsupported commands`,o);a=o.type}}function Ge(e){let t,n,r=[];for(let i=0,a=e.length;i<a;i++){let a=e[i];switch(a.type){case`m`:case`M`:if(a.x.toFixed(4)===n?.x.toFixed(4)&&a.y.toFixed(4)===n?.y.toFixed(4))continue;r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y},t={x:a.x,y:a.y};break;case`h`:case`H`:r.push(`${a.type} ${a.x}`),n={x:a.x,y:n?.y??0};break;case`v`:case`V`:r.push(`${a.type} ${a.y}`),n={x:n?.x??0,y:a.y};break;case`l`:case`L`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`c`:case`C`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`s`:case`S`:r.push(`${a.type} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`q`:case`Q`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`t`:case`T`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`a`:case`A`:r.push(`${a.type} ${a.rx} ${a.ry} ${a.angle} ${a.largeArcFlag} ${a.sweepFlag} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`z`:case`Z`:r.push(a.type),t&&(n={x:t.x,y:t.y});break;default:break}}return r.join(` `)}var Ke=/[a-df-z][^a-df-z]*/gi;function qe(e){let t=[],n=e.match(Ke);if(!n)return t;for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.charAt(0),a=r.slice(1).trim(),o;switch(i){case`m`:case`M`:o=K(a);for(let e=0,n=o.length;e<n;e+=2)e===0?t.push({type:i,x:o[e],y:o[e+1]}):t.push({type:i===`m`?`l`:`L`,x:o[e],y:o[e+1]});break;case`h`:case`H`:o=K(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,x:o[e]});break;case`v`:case`V`:o=K(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,y:o[e]});break;case`l`:case`L`:o=K(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`c`:case`C`:o=K(a);for(let e=0,n=o.length;e<n;e+=6)t.push({type:i,x1:o[e],y1:o[e+1],x2:o[e+2],y2:o[e+3],x:o[e+4],y:o[e+5]});break;case`s`:case`S`:o=K(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x2:o[e],y2:o[e+1],x:o[e+2],y:o[e+3]});break;case`q`:case`Q`:o=K(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x1:o[e],y1:o[e+1],x:o[e+2],y:o[e+3]});break;case`t`:case`T`:o=K(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`a`:case`A`:o=K(a,[3,4],7);for(let e=0,n=o.length;e<n;e+=7)t.push({type:i,rx:o[e],ry:o[e+1],angle:o[e+2],largeArcFlag:o[e+3],sweepFlag:o[e+4],x:o[e+5],y:o[e+6]});break;case`z`:case`Z`:t.push({type:i});break;default:console.warn(r)}}return t}var Je=`data:image/svg+xml;`,Ye=`${Je}base64,`,Xe=`${Je}charset=utf8,`;function Ze(e){if(typeof e==`string`){let t;e.startsWith(Ye)?(e=e.substring(Ye.length,e.length),t=atob(e)):e.startsWith(Xe)?(e=e.substring(Xe.length,e.length),t=decodeURIComponent(e)):t=e;let n=new DOMParser().parseFromString(t,`text/xml`),r=n.querySelector(`parsererror`);if(r)throw Error(`${r.textContent??`parser error`}\n${t}`);return n.documentElement}else return e}var Qe=`px`,$e=90,et=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],tt={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 J(e){let t=`px`;if(typeof e==`string`)for(let n=0,r=et.length;n<r;n++){let r=et[n];if(e.endsWith(r)){t=r,e=e.substring(0,e.length-r.length);break}}let n;return t===`px`&&Qe!==`px`?n=tt.in[Qe]/$e:(n=tt[t][Qe],n<0&&(n=tt[t].in*$e)),n*Number.parseFloat(e)}function nt(e,t,n){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let r=rt(e);return n.length>0&&r.prepend(n[n.length-1]),t.copyFrom(r),n.push(r),r}function rt(e){let t=new W;return e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))&&t.translate(J(e.getAttribute(`x`)),J(e.getAttribute(`y`))),e.hasAttribute(`transform`)&&t.prependCssTransform(e.getAttribute(`transform`)),t}function it(e){return new $().arc(J(e.getAttribute(`cx`)||0),J(e.getAttribute(`cy`)||0),J(e.getAttribute(`r`)||0),0,Math.PI*2)}function at(e,t){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let n=0;n<e.sheet.cssRules.length;n++){let r=e.sheet.cssRules[n];if(r.type!==1)continue;let i=r.selectorText.split(/,/g).filter(Boolean).map(e=>e.trim()),a={};for(let e=r.style.length,t=0;t<e;t++){let e=r.style.item(t);a[e]=r.style.getPropertyValue(e)}for(let e=0;e<i.length;e++)t[i[e]]=Object.assign(t[i[e]]||{},{...a})}}function ot(e){return new $().ellipse(J(e.getAttribute(`cx`)||0),J(e.getAttribute(`cy`)||0),J(e.getAttribute(`rx`)||0),J(e.getAttribute(`ry`)||0),0,0,Math.PI*2)}function st(e){return new $().moveTo(J(e.getAttribute(`x1`)||0),J(e.getAttribute(`y1`)||0)).lineTo(J(e.getAttribute(`x2`)||0),J(e.getAttribute(`y2`)||0))}function ct(e){let t=new $,n=e.getAttribute(`d`);return!n||n===`none`?null:(t.addData(n),t)}var lt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ut(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(lt,(e,r,i)=>{let a=J(r),o=J(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!0,t}var dt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ft(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(dt,(e,r,i)=>{let a=J(r),o=J(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!1,t}function pt(e){let t=J(e.getAttribute(`x`)||0),n=J(e.getAttribute(`y`)||0),r=e.getAttribute(`rx`),i=e.getAttribute(`ry`),a=J(r??i??0),o=J(i??r??0),s=J(e.getAttribute(`width`)),c=J(e.getAttribute(`height`));a=Math.max(0,Math.min(a,s/2)),o=Math.max(0,Math.min(o,c/2));let l=.448084975506,u=new $;return u.moveTo(t+a,n),u.lineTo(t+s-a,n),(a!==0||o!==0)&&u.bezierCurveTo(t+s-a*l,n,t+s,n+o*l,t+s,n+o),u.lineTo(t+s,n+c-o),(a!==0||o!==0)&&u.bezierCurveTo(t+s,n+c-o*l,t+s-a*l,n+c,t+s-a,n+c),u.lineTo(t+a,n+c),(a!==0||o!==0)&&u.bezierCurveTo(t+a*l,n+c,t,n+c-o*l,t,n+c-o),u.lineTo(t,n+o),(a!==0||o!==0)&&u.bezierCurveTo(t,n+o*l,t+a*l,n,t+a,n),u}function Y(e,t,n){t=Object.assign({},t);let r={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)r=Object.assign(r,n[`.${t[e]}`])}e.hasAttribute(`id`)&&(r=Object.assign(r,n[`#${e.getAttribute(`id`)}`]));for(let n=e.style.length,i=0;i<n;i++){let n=e.style.item(i),a=e.style.getPropertyValue(n);t[n]=a,r[n]=a}function i(n,i,o=a){e.hasAttribute(n)&&(t[i]=o(e.getAttribute(n))),r[n]&&(t[i]=o(r[n]))}function a(e){return e.startsWith(`url`)&&console.warn(`url access in attributes is not implemented.`),e}function o(e){return Math.max(0,Math.min(1,J(e)))}function s(e){return Math.max(0,J(e))}function c(e){return e.split(` `).filter(e=>e!==``).map(e=>J(e))}return i(`fill`,`fill`),i(`fill-opacity`,`fillOpacity`,o),i(`fill-rule`,`fillRule`),i(`opacity`,`opacity`,o),i(`stroke`,`stroke`),i(`stroke-opacity`,`strokeOpacity`,o),i(`stroke-width`,`strokeWidth`,s),i(`stroke-linecap`,`strokeLinecap`),i(`stroke-linejoin`,`strokeLinejoin`),i(`stroke-miterlimit`,`strokeMiterlimit`,s),i(`stroke-dasharray`,`strokeDasharray`,c),i(`stroke-dashoffset`,`strokeDashoffset`,J),i(`visibility`,`visibility`),t}function mt(e,t,n=[],r={}){if(e.nodeType!==1)return n;let i=!1,a=null,o={...t};switch(e.nodeName){case`svg`:o=Y(e,o,r);break;case`style`:at(e,r);break;case`g`:o=Y(e,o,r);break;case`path`:o=Y(e,o,r),e.hasAttribute(`d`)&&(a=ct(e));break;case`rect`:o=Y(e,o,r),a=pt(e);break;case`polygon`:o=Y(e,o,r),a=ut(e);break;case`polyline`:o=Y(e,o,r),a=ft(e);break;case`circle`:o=Y(e,o,r),a=it(e);break;case`ellipse`:o=Y(e,o,r),a=ot(e);break;case`line`:o=Y(e,o,r),a=st(e);break;case`defs`:i=!0;break;case`use`:{o=Y(e,o,r);let t=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),i=e.viewportElement?.getElementById(t);i?mt(i,o,n,r):console.warn(`'use node' references non-existent node id: ${t}`);break}default:console.warn(e);break}if(o.display===`none`)return n;let s=new W,c=[],l=nt(e,s,c);a&&(a.applyTransform(s),n.push(a),a.style={...o});let u=e.childNodes;for(let e=0,t=u.length;e<t;e++){let t=u[e];i&&t.nodeName!==`style`&&t.nodeName!==`defs`||mt(t,o,n,r)}return l&&(c.pop(),c.length>0?s.copyFrom(c[c.length-1]):s.identity()),n}function ht(e){let t=Ze(e);return new It(mt(t,{}),t.getAttribute(`viewBox`)?.trim().split(` `).map(e=>Number(e)))}var X=class{arcLengthDivision=200;_lengths=[];getPointAt(e,t=new i){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(e){let t=typeof e==`function`;return this.getControlPointRefs().forEach(n=>{t?e(n):e.apply(n,n)}),this}getUnevenVertices(e=5,t=[]){let n=new i;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPoint(r/i,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){let n=new i;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPointAt(r/i,n),t.push(n.x,n.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){let r=e[n],a=e[n+1];t.push(new i(r,a))}return t}getSpacedPoints(e,t=[]){let n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){let n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){let t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return n=e?this.getUnevenVertices(e):this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){let e=this.getLengths();return e[e.length-1]??0}getLengths(){return this._lengths.length!==this.arcLengthDivision+1&&this.updateLengths(),this._lengths}updateLengths(){let e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),i=1;i<=e;i++){let a=this.getPoint(i/e);n+=a.distanceTo(r),t.push(n),r=a}this._lengths=t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t??e*n[r-1];if(r<2)return i/n[0];let a=0,o=0,s=r-1,c;for(;o<=s;)if(a=Math.floor(o+(s-o)/2),c=n[a]-i,c<0)o=a+1;else if(c>0)s=a-1;else{s=a;break}if(a=Math.max(0,s),n[a]===i)return a/(r-1);let l=n[a],u=n[a+1]-l,d=Math.max(0,(i-l)/u);return(a+d)/(r-1)}getTangent(e,t=new i){let n=1e-4,r=Math.max(0,e-n),a=Math.min(1,e+n);return t.copyFrom(this.getPoint(a).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new i){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,i=(n+r)/2;for(;r-n>t;){i=(n+r)/2;let a=this.getPoint(i);if(a.distanceTo(e)<t)return i;a.x<e.x?n=i:r=i}return i}getMinMax(e=i.MAX,t=i.MIN){let n=this.getPoints();for(let r=0,i=n.length;r<i;r++){let i=n[r];e.clampMin(i),t.clampMax(i)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new a(e.x,e.y,t.x-e.x,t.y-e.y)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return he(this.getFillVertices(e),e)}strokeTriangulate(e){return ze(this.getAdaptiveVertices(),e)}toCommands(){let e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){let r=t[n];n===0?e.push({type:`M`,x:r.x,y:r.y}):e.push({type:`L`,x:r.x,y:r.y})}return e}toData(){return Ge(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case`M`:e.moveTo(t.x,t.y);break;case`L`:e.lineTo(t.x,t.y);break}}),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copyFrom(this)}},gt=new W,_t=new W,vt=new W,Z=new i,yt=class extends X{get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}constructor(e=new i,t=new i,n=new i,r=0,a=0,o=Math.PI*2,s=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=a,this.endAngle=o,this.clockwise=s}isClockwise(){return this.clockwise}_getDeltaAngle(){let e=Math.PI*2,t=this.endAngle-this.startAngle,n=Math.abs(t)<2**-52;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new i){let n=this._getDeltaAngle(),r=this.startAngle+e*n,a=this.cx+this.rx*Math.cos(r),o=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),n=a-this.cx,r=o-this.cy;a=n*e-r*t+this.cx,o=n*t+r*e+this.cy}return t.set(a,o)}toCommands(){let{cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,clockwise:o,rotate:s}=this,c=e+n*Math.cos(i)*Math.cos(s)-r*Math.sin(i)*Math.sin(s),l=t+n*Math.cos(i)*Math.sin(s)+r*Math.sin(i)*Math.cos(s),u=Math.abs(i-a),d=+(u>Math.PI),f=+!!o,p=s*180/Math.PI;if(u>=2*Math.PI){let a=i+Math.PI,o=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),u=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:o,y:u},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:c,y:l}]}else{let i=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),o=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:d,sweepFlag:f,x:i,y:o}]}}drawTo(e){let{cx:t,cy:n,rx:r,ry:i,rotate:a,startAngle:o,endAngle:s,clockwise:c}=this;return e.ellipse(t,n,r,i,a,o,s,!c),this}applyTransform(e){return Z.set(this.cx,this.cy),e.apply(Z,Z),this.cx=Z.x,this.cy=Z.y,Ct(e)?bt(this,e):xt(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,startAngle:s,endAngle:c,clockwise:l,rotate:u}=this,d=!l,f=Math.abs(s-c);(!d&&s>c||d&&c>s)&&(f=2*Math.PI-f);let p=Math.max(12,Math.floor(12*r**(1/3)*(f/Math.PI))),m=f/p,h=s;m*=d?-1:1;let g=Math.cos(d?u:-u),_=Math.sin(d?u:-u);for(let s=0;s<p+1;s++){let s=a+Math.cos(h)*r,c=o+Math.sin(h)*i,l=s*g-c*_,u=s*_+c*g;e.push(t+l,n+u),h+=m}return e}_getAdaptiveVerticesByCircle(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,rotate:s,clockwise:c}=this;if(!(r>=0&&i>=0&&a>=0&&o>=0))return e;let l=Math.ceil(2.3*Math.sqrt(r+i)),u=l*8+(a?4:0)+(o?4:0),d=[];if(u===0)return e;{let e=d.length;if(l===0)d[e]=d[e+6]=t+a,d[e+1]=d[e+3]=n+o,d[e+2]=d[e+4]=t-a,d[e+5]=d[e+7]=n-o;else{let s=e,c=e+l*4+(a?2:0)+2,f=c,p=u,m=a+r,h=o,g=t+m,_=t-m,v=n+h;if(d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,o){let e=n-h;d[f++]=_,d[f++]=e,d[--p]=e,d[--p]=g}for(let e=1;e<l;e++){let u=Math.PI/2*(e/l),m=a+Math.cos(u)*r,h=o+Math.sin(u)*i,g=t+m,_=t-m,v=n+h,y=n-h;d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,d[f++]=_,d[f++]=y,d[--p]=y,d[--p]=g}m=a,h=o+i,g=t+m,_=t-m,v=n+h;let y=n-h;d[s++]=g,d[s++]=v,d[--p]=y,d[--p]=g,a&&(d[s++]=_,d[s++]=v,d[--p]=y,d[--p]=_)}}let f=Math.cos(c?-s:s),p=Math.sin(c?-s:s);for(let r=0;r<d.length;r+=2){let i=d[r],a=d[r+1],o=i-t,s=a-n,c=o*f-s*p,l=o*p+s*f;e.push(t+c,n+l)}return e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}};function bt(e,t){let n=e.rx,r=e.ry,a=Math.cos(e.rotate),o=Math.sin(e.rotate),s=new i(n*a,n*o),c=new i(-r*o,r*a),l=t.a*s.x+t.c*s.y,u=t.b*s.x+t.d*s.y,d=t.a*c.x+t.c*c.y,f=t.b*c.x+t.d*c.y,p=gt.set(l,u,d,f,0,0),{a:m,b:h,c:g,d:_}=_t.copyFrom(p).affineInvert(),v=wt(m*m+h*h,g*m+_*h,g*g+_*_),y=Math.sqrt(v.rt1),b=Math.sqrt(v.rt2);if(e.rx=1/y,e.ry=1/b,e.rotate=Math.atan2(v.sn,v.cs),!((e.endAngle-e.startAngle)%(2*Math.PI)<2**-52)){let n=_t.set(y,0,0,b,0,0),r=vt.set(v.cs,v.sn,-v.sn,v.cs,0,0),i=n.append(r).append(p),a=e=>{let{x:t,y:n}=i.apply({x:Math.cos(e),y:Math.sin(e)});return Math.atan2(n,t)};e.startAngle=a(e.startAngle),e.endAngle=a(e.endAngle),St(t)&&(e.clockwise=!e.clockwise)}}function xt(e,t){let{scale:n}=t.decompose();e.rx*=n.x,e.ry*=n.y;let r=n.x>2**-52?Math.atan2(t.b,t.a):Math.atan2(-t.c,t.d);e.rotate+=r,St(t)&&(e.startAngle*=-1,e.endAngle*=-1,e.clockwise=!e.clockwise)}function St(e){return e.a*e.d-e.c*e.b<0}function Ct(e){let t=e.a*e.c+e.b*e.d;if(t===0)return!1;let{scale:n}=e.decompose();return Math.abs(t/(n.x*n.y))>2**-52}function wt(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?(i=.5*(c-u),s=1/i,r=e*s*n-t*s*t):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}var Tt=class extends yt{constructor(e=0,t=0,n=1,r=0,a=Math.PI*2,o=!1){super(new i(e,t),new i(n,n),new i,0,r,a,o)}drawTo(e){let{cx:t,cy:n,rx:r,startAngle:i,endAngle:a,clockwise:o}=this;return e.arc(t,n,r,i,a,!o),this}},Q=class e extends X{static from(t,n,r,a){return new e(new i(t,n),new i(r,a))}constructor(e=new i,t=new i){super(),this.p1=e,this.p2=t}getPoint(e,t=new i){return e===1?t.copyFrom(this.p2):t.copyFrom(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new i){return this.getPoint(e,t)}getTangent(e,t=new i){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new i){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,p2:t}=this;return[{type:`M`,x:e.x,y:e.y},{type:`L`,x:t.x,y:t.y}]}getFillVertices(e={}){let t=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),i=Math.max(this.p1.y,this.p2.y),a=t,o=r,s=n-t||e.style?.strokeWidth||0,c=i-r||e.style?.strokeWidth||0;return[a,o,a+s,o,a+s,o+c,a,o+c]}drawTo(e){let{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.p2.copyFrom(e.p2),this}},Et=class e extends X{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(t=>t instanceof e?t.getFlatCurves():t)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new i){let n=e*this.getLength(),r=this.getLengths(),a=r.length;if(a===0)return t;let o=0,s=a-1;for(;o<s;){let e=o+s>>>1;r[e]<n?o=e+1:s=e}let c=r[o]-n,l=this.curves[o],u=l.getLength();return l.getPointAt(u===0?0:1-c/u,t)}getLengths(){return this._lengths.length!==this.curves.length&&this.updateLengths(),this._lengths}updateLengths(){let e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._lengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){let n=[e[t-1],e[t]],r=[e[t+1],e[t+2]];return n[0]===r[0]&&n[1]===r[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{let t=[],n;return this.curves.forEach(r=>{let i;i=r instanceof Q?r.getAdaptiveVertices():r.getFillVertices(e),t.push(...i),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=i.MAX,t=i.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new a(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this}copyFrom(e){return super.copyFrom(e),this.curves=e.curves.map(e=>e.clone()),this}},Dt=class e extends X{static from(t,n,r,a,o,s,c,l){return new e(new i(t,n),new i(r,a),new i(o,s),new i(c,l))}constructor(e=new i,t=new i,n=new i,r=new i){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}getPoint(e,t=new i){let{p1:n,cp1:r,cp2:a,p2:o}=this;return t.set(x(e,n.x,r.x,a.x,o.x),x(e,n.y,r.y,a.y,o.y))}getAdaptiveVertices(e=[]){return be(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){if(Math.abs(e)<1e-12){if(Math.abs(t)<1e-12)return[];let e=-n/t;return e>=0&&e<=1?[e]:[]}let r=t*t-4*e*n;if(r<0)return[];let i=Math.sqrt(r);return[(-t+i)/(2*e),(-t-i)/(2*e)].filter(e=>e>=0&&e<=1)}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,cp1:r,cp2:a,p2:o}=this,s=this._solveQuadratic(3*(-n.x+3*r.x-3*a.x+o.x),6*(n.x-2*r.x+a.x),3*(r.x-n.x)),c=this._solveQuadratic(3*(-n.y+3*r.y-3*a.y+o.y),6*(n.y-2*r.y+a.y),3*(r.y-n.y)),l=[0,1,...s,...c];for(let n of l){let r=this.getPoint(n);e.x=Math.min(e.x,r.x),e.y=Math.min(e.y,r.y),t.x=Math.max(t.x,r.x),t.y=Math.max(t.y,r.y)}return{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:`M`,x:e.x,y:e.y},{type:`C`,x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){let{p1:t,cp1:n,cp2:r,p2:i}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp1.copyFrom(e.cp1),this.cp2.copyFrom(e.cp2),this.p2.copyFrom(e.p2),this}},Ot=class extends yt{constructor(e=0,t=0,n=1,r=1,a=0,o=0,s=Math.PI*2,c=!1){super(new i(e,t),new i(n,r),new i,a,o,s,c)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}},kt=class extends Et{},At=class extends kt{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){let{cx:e,cy:t,radius:n,sideCount:r}=this,a=[];for(let o=0;o<r;o++){let s=o*2*Math.PI/r-.5*Math.PI;a.push(new i(n*Math.cos(s),n*Math.sin(s)).add({x:e,y:t}))}let o=[];for(let e=0;e<r;e++)o.push(new Q(a[e],a[(e+1)%r]));return this.curves=o,this}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}},jt=class e extends X{static from(t,n,r,a,o,s){return new e(new i(t,n),new i(r,a),new i(o,s))}constructor(e=new i,t=new i,n=new i){super(),this.p1=e,this.cp=t,this.p2=n}getPoint(e,t=new i){let{p1:n,cp:r,p2:a}=this;return t.set(H(e,n.x,r.x,a.x),H(e,n.y,r.y,a.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return De(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,cp:r,p2:a}=this,o=(e,t,n)=>{let r=e-2*t+n;if(Math.abs(r)<1e-12)return null;let i=(e-t)/r;return i>0&&i<1?i:null},s=o(n.x,r.x,a.x),c=o(n.y,r.y,a.y),l=[n.x,a.x],u=[n.y,a.y];return s!==null&&l.push(H(s,n.x,r.x,a.x)),c!==null&&u.push(H(c,n.y,r.y,a.y)),e.x=Math.min(e.x,...l),e.y=Math.min(e.y,...u),t.x=Math.max(t.x,...l),t.y=Math.max(t.y,...u),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp:t,p2:n}=this;return[{type:`M`,x:e.x,y:e.y},{type:`Q`,x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){let{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp.copyFrom(e.cp),this.p2.copyFrom(e.p2),this}},Mt=class extends kt{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,a=[new i(e,t),new i(e+n,t),new i(e+n,t+r),new i(e,t+r)];return this.curves=[new Q(a[0],a[1]),new Q(a[1],a[2]),new Q(a[2],a[3]),new Q(a[3],a[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){let{x:t,y:n,width:r,height:i}=this;return[t,n,t+r,n,t+r,n+i,t,n+i]}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}},Nt=class extends yt{constructor(e=0,t=0,n=1,r=1,i=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.update()}update(){let{x:e,y:t,width:n,height:r,radius:a}=this,o=n/2,s=r/2,c=e+o,l=t+s,u=Math.max(0,Math.min(a,Math.min(o,s))),d=u;return this._center=new i(c,l),this._radius=new i(u,d),this._diff=new i(o-u,s-d),this}drawTo(e){let{x:t,y:n,width:r,height:i,radius:a}=this;return e.roundRect(t,n,r,i,a),this}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}},Pt=class extends X{constructor(e=[]){super(),this.points=e}getPoint(e,t=new i){let{points:n}=this,r=(n.length-1)*e,a=Math.floor(r),s=r-a,c=n[a===0?a:a-1],l=n[a],u=n[a>n.length-2?n.length-1:a+1],d=n[a>n.length-3?n.length-1:a+2];return t.set(o(s,c.x,l.x,u.x,d.x),o(s,c.y,l.y,u.y,d.y)),t}getControlPointRefs(){return this.points}copyFrom(e){super.copyFrom(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}},Ft=class extends Et{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++){let{x:n,y:r}=e[t];this.lineTo(n,r)}return this}addCommands(e){return We(e,this),this}addData(e){return this.addCommands(qe(e)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}_setCurrentPoint(e){return this.currentPoint=new i(e.x,e.y),this.startPoint||=this.currentPoint.clone(),this}_connetLineTo(e){if(this.curves.length>0){let t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){let e=this.startPoint;if(e){let t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Q(t.clone(),e.clone())),t.copyFrom(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new i(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){let n=this.currentPoint;return n?.equals({x:e,y:t})||this.curves.push(Q.from(n?.x??0,n?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,n,r,i,a){let o=this.currentPoint;return o?.equals({x:i,y:a})||this.curves.push(Dt.from(o?.x??0,o?.y??0,e,t,n,r,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(e,t,n,r){let i=this.currentPoint;return i?.equals({x:n,y:r})||this.curves.push(jt.from(i?.x??0,i?.y??0,e,t,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(e,t,n,r,i,a){let o=new Tt(e,t,n,r,i,!a);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(e,t,n,r,i,a){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return console.warn(`Method arcTo not supported yet`),this}ellipse(e,t,n,r,i,a,o,s=!0){let c=new Ot(e,t,n,r,i,a,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,n,r,i,a,o,s){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){let i=new Mt(e,t,n,r);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,n,r,i){let a=new Nt(e,t,n,r,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){let t=this.currentPoint??new i;return this.curves.push(new Pt([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this.autoClose&&e.closePath(),this}copyFrom(e){return super.copyFrom(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}},$=class e extends Et{_meta;currentCurve=new Ft;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??`none`)===`none`?0:1)}constructor(t,n={}){super(),this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof e?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(t){let n=t instanceof e?t.curves:[t];if(n.filter(e=>e.curves.length).length===0)return this;if(!this.currentCurve.curves.length){let e=this.curves.findIndex(e=>e===this.currentCurve);e>-1&&this.curves.splice(e,1)}return this.curves.push(...n.map(e=>e.clone())),this.currentCurve=this.curves[this.curves.length-1],this}closePath(){let e=this.startPoint;return e&&this.currentCurve.curves.length&&(this.currentCurve.closePath(),this.currentCurve=new Ft().moveTo(e.x,e.y),this.curves.push(this.currentCurve)),this}moveTo(e,t){return this.currentCurve.curves.length&&(this.currentCurve=new Ft,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a){return this.currentCurve.bezierCurveTo(e,t,n,r,i,a),this}quadraticCurveTo(e,t,n,r){return this.currentCurve.quadraticCurveTo(e,t,n,r),this}arc(e,t,n,r,i,a){return this.currentCurve.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return this.currentCurve.arcTo(e,t,n,r,i),this}ellipse(e,t,n,r,i,a,o,s){return this.currentCurve.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){return this.currentCurve.rect(e,t,n,r),this}roundRect(e,t,n,r,i){return this.currentCurve.roundRect(e,t,n,r,i),this}reset(){return this.currentCurve=new Ft,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return We(e,this),this}addData(e){return this.addCommands(qe(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(e,t,n)}),this}skew(e,t=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(e,t,n)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(e,t)}),this}bold(e){if(e===0)return this;let t=this.getFlatCurves(),n=[],r=[],i=[];t.forEach((e,t)=>{let a=e.getControlPointRefs(),o=e.isClockwise();i[t]=a,r[t]=o;let s=a[0],c=a[a.length-1]??s;n.push({start:o?c:s,end:o?s:c,index:t})});let a=[];return n.forEach((e,t)=>{a[t]=[],n.forEach((n,r)=>{n.start&&e.end&&r!==t&&n.start?.equals(e.end)&&a[t].push(n.index)})}),t.forEach((t,n)=>{let a=r[n];i[n].forEach(n=>{n.add(t.getNormal(t.getTForPoint(n)).scale(a?e:-e))})}),a.forEach((e,t)=>{let n=i[t];e.forEach(e=>{let t=i[e],r=u(n[n.length-1],n[n.length-2]??n[n.length-1],t[0],t[1]??t[0]);r&&(n[n.length-1].copyFrom(r),t[0].copyFrom(r))})}),this}getMinMax(e=i.MAX,t=i.MIN,n=!0){let r=this.strokeWidth;return this.curves.forEach(i=>{if(i.getMinMax(e,t),n&&r>1){let n=r/2,a=i.isClockwise(),o=[];for(let e=0;e<=1;e+=1/i.arcLengthDivision){let t=i.getPoint(e),r=i.getNormal(e),s=r.clone().scale(a?n:-n),c=r.clone().scale(a?-n:n);o.push(t.clone().add(s),t.clone().add(c),t.clone().add({x:n,y:0}),t.clone().add({x:-n,y:0}),t.clone().add({x:0,y:n}),t.clone().add({x:0,y:-n}),t.clone().add({x:n,y:n}),t.clone().add({x:-n,y:-n}))}e.clampMin(...o),t.clampMax(...o)}}),{min:e.finite(),max:t.finite()}}strokeTriangulate(e){let t=e?.indices??[],n=e?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...e,indices:t,vertices:n,style:{...this.style}})}),{indices:t,vertices:n}}fillTriangulate(e){let t={...e,style:{...this.style,...e?.style}},n=t.indices??[],r=t.vertices??[];if((t.style.fillRule??`nonzero`)===`nonzero`){let i=this.curves.map(e=>e.getFillVertices(t)),a=Ne(i),o=a.length;for(let t=0;t<o;t++){let s=a[t],c=i[t];if(s.winding||!c.length)continue;let l=c.slice(),u=[];for(let e=0;e<o;e++){let n=a[e];n.parentIndex===t&&(u.push(l.length/2),l.push(...i[n.index]))}he(l,{...e,indices:n,vertices:r,holes:u,style:{...this.style}})}}else this.curves.forEach(t=>{t.fillTriangulate({...e,indices:n,vertices:r,style:{...this.style}})});return{indices:n,vertices:r}}getBoundingBox(e=!0){let{min:t,max:n}=this.getMinMax(void 0,void 0,e);return new a(t.x,t.y,n.x-t.x,n.y-t.y)}drawTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:i=`none`}=t;return e.beginPath(),e.save(),r(e,t),this.curves.forEach(t=>{t.drawTo(e)}),n!==`none`&&e.fill(),i!==`none`&&e.stroke(),e.restore(),this}drawControlPointsTo(e,n={}){n={...this.style,...n};let{fill:i=`#000`,stroke:a=`none`}=n;return e.beginPath(),e.save(),r(e,n),this.getControlPointRefs().forEach(n=>{t(e,n.x,n.y,{radius:4})}),i!==`none`&&e.fill(),a!==`none`&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(` `)}toSvgPathString(){let e={...this.style,fill:this.style.fill??`#000`,stroke:this.style.stroke??`none`},t={};for(let n in e)e[n]!==void 0&&(t[l(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let n=``;for(let e in t)t[e]!==void 0&&(n+=`${e}:${t[e]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copyFrom(e){return super.copyFrom(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}},It=class{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;let t=i.MAX,n=i.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new a(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSvgString(e=this.paths.map(e=>e.fillTriangulate()),t=0){let n=``,r=``,i={x:-t,y:-t},a={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:e,indices:o,points:s=[]})=>{let c=n=>{let r=e[n*2],o=e[n*2+1];return i.x=Math.min(i.x,r+t),a.x=Math.max(a.x,r+t),i.y=Math.min(i.y,o+t),a.y=Math.max(a.y,o+t),[r,o]};for(let e=0,t=o.length;e<t;e+=3){let t=c(o[e]),r=c(o[e+1]),i=c(o[e+2]);n+=`<polygon
2
2
  points="${t.join(`,`)} ${r.join(`,`)} ${i.join(`,`)}"
3
3
  stroke="#28a745"
4
4
  stroke-width="#stroke-width"
@@ -25,4 +25,4 @@
25
25
  xmlns="http://www.w3.org/2000/svg"
26
26
  >
27
27
  ${this.paths.map(e=>e.toSvgPathString()).join(``)}
28
- </svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),`image/svg+xml`).documentElement}toCanvas(e={}){let{pixelRatio:t=2,...n}=e,{left:r,top:i,width:a,height:o}=this.getBoundingBox(),s=document.createElement(`canvas`);s.width=a*t,s.height=o*t,s.style.width=`${a}px`,s.style.height=`${o}px`;let c=s.getContext(`2d`);return c&&(c.scale(t,t),c.translate(-r,-i),this.paths.forEach(e=>{e.drawTo(c,n)})),s}},Lt=class{controlPoints=[];constructor(e,t,n=1,r=1){this.rows=e,this.cols=t,this.width=n,this.height=r;for(let i=0;i<e;i++){this.controlPoints[i]=[];for(let a=0;a<t;a++)this.controlPoints[i][a]={x:a/(t-1)*n,y:i/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}};function Rt(e){let t=[];return t[0]=(1-e)**3/6,t[1]=(3*e**3-6*e**2+4)/6,t[2]=(-3*e**3+3*e**2+3*e+1)/6,t[3]=e**3/6,t}function zt(e,t,n=t.width,r=t.height){let i=e.x/n*(t.cols-1),a=e.y/r*(t.rows-1),o=Math.floor(i),s=Math.floor(a),c=i-o,l=a-s,u=Rt(c),d=Rt(l),f=0,p=0;for(let e=0;e<4;e++)for(let n=0;n<4;n++){let r=Math.min(Math.max(s-1+e,0),t.rows-1),i=Math.min(Math.max(o-1+n,0),t.cols-1),a=t.controlPoints[r][i],c=u[n]*d[e];f+=a.x*c,p+=a.y*c}e.set(f,p)}e.ArcCurve=Tt,e.BoundingBox=a,e.CompositeCurve=Et,e.CubicBezierCurve=Dt,e.Curve=X,e.CurvePath=Ft,e.EllipseCurve=Ot,e.EquilateralPloygonCurve=At,e.FFDControlGrid=Lt,e.LineCurve=Q,e.PI=s,e.PI_2=c,e.Path2D=$,e.Path2DSet=It,e.PloygonCurve=kt,e.QuadraticBezierCurve=jt,e.RectangleCurve=Mt,e.RoundRectangleCurve=Nt,e.SplineCurve=Pt,e.Transform2D=W,e.Vector2=i,e.applyFFD=zt,e.catmullRom=o,e.cubicBezier=x,e.drawPoint=t,e.fillTriangulate=me,e.getAdaptiveCubicBezierCurvePoints=ye,e.getAdaptiveQuadraticBezierCurvePoints=Ee,e.getDirectedArea=Oe,e.getIntersectionPoint=u,e.nonzeroFillRule=Me,e.parseArcCommand=Ue,e.parseCssArg=g,e.parseCssArgs=h,e.parseCssFunctions=m,e.parsePathDataArgs=K,e.quadraticBezier=Ie,e.setCanvasContext=r,e.strokeTriangulate=ze,e.svgPathCommandsAddToPath2D=We,e.svgPathCommandsToData=Ge,e.svgPathDataToCommands=qe,e.svgToDom=Ze,e.svgToPath2DSet=ht,e.toKebabCase=l});
28
+ </svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),`image/svg+xml`).documentElement}toCanvas(e={}){let{pixelRatio:t=2,...n}=e,{left:r,top:i,width:a,height:o}=this.getBoundingBox(),s=document.createElement(`canvas`);s.width=a*t,s.height=o*t,s.style.width=`${a}px`,s.style.height=`${o}px`;let c=s.getContext(`2d`);return c&&(c.scale(t,t),c.translate(-r,-i),this.paths.forEach(e=>{e.drawTo(c,n)})),s}},Lt=class{controlPoints=[];constructor(e,t,n=1,r=1){this.rows=e,this.cols=t,this.width=n,this.height=r;for(let i=0;i<e;i++){this.controlPoints[i]=[];for(let a=0;a<t;a++)this.controlPoints[i][a]={x:a/(t-1)*n,y:i/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}};function Rt(e){let t=[];return t[0]=(1-e)**3/6,t[1]=(3*e**3-6*e**2+4)/6,t[2]=(-3*e**3+3*e**2+3*e+1)/6,t[3]=e**3/6,t}function zt(e,t,n=t.width,r=t.height){let i=e.x/n*(t.cols-1),a=e.y/r*(t.rows-1),o=Math.floor(i),s=Math.floor(a),c=i-o,l=a-s,u=Rt(c),d=Rt(l),f=0,p=0;for(let e=0;e<4;e++)for(let n=0;n<4;n++){let r=Math.min(Math.max(s-1+e,0),t.rows-1),i=Math.min(Math.max(o-1+n,0),t.cols-1),a=t.controlPoints[r][i],c=u[n]*d[e];f+=a.x*c,p+=a.y*c}e.set(f,p)}e.ArcCurve=Tt,e.BoundingBox=a,e.CompositeCurve=Et,e.CubicBezierCurve=Dt,e.Curve=X,e.CurvePath=Ft,e.EllipseCurve=Ot,e.EquilateralPolygonCurve=At,e.FFDControlGrid=Lt,e.LineCurve=Q,e.PI=s,e.PI_2=c,e.Path2D=$,e.Path2DSet=It,e.PolygonCurve=kt,e.QuadraticBezierCurve=jt,e.RectangleCurve=Mt,e.RoundRectangleCurve=Nt,e.SplineCurve=Pt,e.Transform2D=W,e.Vector2=i,e.applyFFD=zt,e.catmullRom=o,e.cubicBezier=x,e.drawPoint=t,e.fillTriangulate=he,e.getAdaptiveCubicBezierCurvePoints=be,e.getAdaptiveQuadraticBezierCurvePoints=De,e.getDirectedArea=ke,e.getIntersectionPoint=u,e.nonzeroFillRule=Ne,e.parseArcCommand=Ue,e.parseCssArg=g,e.parseCssArgs=h,e.parseCssFunctions=m,e.parsePathDataArgs=K,e.quadraticBezier=H,e.setCanvasContext=r,e.strokeTriangulate=ze,e.svgPathCommandsAddToPath2D=We,e.svgPathCommandsToData=Ge,e.svgPathDataToCommands=qe,e.svgToDom=Ze,e.svgToPath2DSet=ht,e.toKebabCase=l});
package/dist/index.mjs CHANGED
@@ -183,11 +183,9 @@ class Vector2 {
183
183
  return Math.sqrt(this.lengthSquared());
184
184
  }
185
185
  scale(sx, sy = sx, origin = { x: 0, y: 0 }) {
186
- const x = sx < 0 ? origin.x - this._x + origin.x : this._x;
187
- const y = sy < 0 ? origin.y - this._y + origin.y : this._y;
188
186
  return this.set(
189
- x * Math.abs(sx),
190
- y * Math.abs(sy)
187
+ origin.x + (this._x - origin.x) * sx,
188
+ origin.y + (this._y - origin.y) * sy
191
189
  );
192
190
  }
193
191
  skew(ax, ay = 0, origin = { x: 0, y: 0 }) {
@@ -584,7 +582,7 @@ function getDirectedArea(vertices) {
584
582
  for (let i = 0; i < n; i += 2) {
585
583
  const x0 = vertices[i];
586
584
  const y0 = vertices[i + 1];
587
- const x1 = vertices[(i + 2) % (n - 1)];
585
+ const x1 = vertices[(i + 2) % n];
588
586
  const y1 = vertices[(i + 3) % n];
589
587
  area += x0 * y1 - x1 * y0;
590
588
  }
@@ -1735,8 +1733,14 @@ function getReflection(a, b) {
1735
1733
  function svgPathCommandsAddToPath2D(commands, path) {
1736
1734
  const current = new Vector2();
1737
1735
  const control = new Vector2();
1736
+ let prevType = "";
1738
1737
  for (let i = 0, l = commands.length; i < l; i++) {
1739
1738
  const cmd = commands[i];
1739
+ if ((cmd.type === "s" || cmd.type === "S") && !"CcSs".includes(prevType)) {
1740
+ control.copyFrom(current);
1741
+ } else if ((cmd.type === "t" || cmd.type === "T") && !"QqTt".includes(prevType)) {
1742
+ control.copyFrom(current);
1743
+ }
1740
1744
  if (cmd.type === "m" || cmd.type === "M") {
1741
1745
  if (cmd.type === "m") {
1742
1746
  current.add(cmd);
@@ -1895,6 +1899,7 @@ function svgPathCommandsAddToPath2D(commands, path) {
1895
1899
  } else {
1896
1900
  console.warn("Unsupported commands", cmd);
1897
1901
  }
1902
+ prevType = cmd.type;
1898
1903
  }
1899
1904
  }
1900
1905
 
@@ -2319,10 +2324,14 @@ function parsePolylineNode(node) {
2319
2324
  function parseRectNode(node) {
2320
2325
  const x = parseFloatWithUnits(node.getAttribute("x") || 0);
2321
2326
  const y = parseFloatWithUnits(node.getAttribute("y") || 0);
2322
- const rx = parseFloatWithUnits(node.getAttribute("rx") || node.getAttribute("ry") || 0);
2323
- const ry = parseFloatWithUnits(node.getAttribute("ry") || node.getAttribute("rx") || 0);
2327
+ const rxAttr = node.getAttribute("rx");
2328
+ const ryAttr = node.getAttribute("ry");
2329
+ let rx = parseFloatWithUnits(rxAttr ?? ryAttr ?? 0);
2330
+ let ry = parseFloatWithUnits(ryAttr ?? rxAttr ?? 0);
2324
2331
  const w = parseFloatWithUnits(node.getAttribute("width"));
2325
2332
  const h = parseFloatWithUnits(node.getAttribute("height"));
2333
+ rx = Math.max(0, Math.min(rx, w / 2));
2334
+ ry = Math.max(0, Math.min(ry, h / 2));
2326
2335
  const bci = 1 - 0.551915024494;
2327
2336
  const path = new Path2D();
2328
2337
  path.moveTo(x + rx, y);
@@ -3108,6 +3117,8 @@ function eigenDecomposition(A, B, C) {
3108
3117
  rt2 = A * t * C - B * t * B;
3109
3118
  } else if (sm < 0) {
3110
3119
  rt2 = 0.5 * (sm - rt);
3120
+ t = 1 / rt2;
3121
+ rt1 = A * t * C - B * t * B;
3111
3122
  } else {
3112
3123
  rt1 = 0.5 * rt;
3113
3124
  rt2 = -0.5 * rt;
@@ -3273,20 +3284,26 @@ class CompositeCurve extends Curve {
3273
3284
  getPoint(t, output = new Vector2()) {
3274
3285
  const d = t * this.getLength();
3275
3286
  const lengths = this.getLengths();
3276
- let i = 0;
3277
- while (i < lengths.length) {
3278
- if (lengths[i] >= d) {
3279
- const diff = lengths[i] - d;
3280
- const curve = this.curves[i];
3281
- const length = curve.getLength();
3282
- return curve.getPointAt(
3283
- length === 0 ? 0 : 1 - diff / length,
3284
- output
3285
- );
3287
+ const n = lengths.length;
3288
+ if (n === 0)
3289
+ return output;
3290
+ let lo = 0;
3291
+ let hi = n - 1;
3292
+ while (lo < hi) {
3293
+ const mid = lo + hi >>> 1;
3294
+ if (lengths[mid] < d) {
3295
+ lo = mid + 1;
3296
+ } else {
3297
+ hi = mid;
3286
3298
  }
3287
- i++;
3288
3299
  }
3289
- return output;
3300
+ const diff = lengths[lo] - d;
3301
+ const curve = this.curves[lo];
3302
+ const length = curve.getLength();
3303
+ return curve.getPointAt(
3304
+ length === 0 ? 0 : 1 - diff / length,
3305
+ output
3306
+ );
3290
3307
  }
3291
3308
  getLengths() {
3292
3309
  if (this._lengths.length !== this.curves.length) {
@@ -3435,6 +3452,12 @@ class CubicBezierCurve extends Curve {
3435
3452
  return [this.p1, this.cp1, this.cp2, this.p2];
3436
3453
  }
3437
3454
  _solveQuadratic(a, b, c) {
3455
+ if (Math.abs(a) < 1e-12) {
3456
+ if (Math.abs(b) < 1e-12)
3457
+ return [];
3458
+ const t = -c / b;
3459
+ return t >= 0 && t <= 1 ? [t] : [];
3460
+ }
3438
3461
  const discriminant = b * b - 4 * a * c;
3439
3462
  if (discriminant < 0)
3440
3463
  return [];
@@ -3446,30 +3469,23 @@ class CubicBezierCurve extends Curve {
3446
3469
  getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
3447
3470
  const { p1, cp1, cp2, p2 } = this;
3448
3471
  const dxRoots = this._solveQuadratic(
3449
- 3 * (cp1.x - p1.x),
3450
- 6 * (cp2.x - cp1.x),
3451
- 3 * (p2.x - cp2.x)
3472
+ 3 * (-p1.x + 3 * cp1.x - 3 * cp2.x + p2.x),
3473
+ 6 * (p1.x - 2 * cp1.x + cp2.x),
3474
+ 3 * (cp1.x - p1.x)
3452
3475
  );
3453
3476
  const dyRoots = this._solveQuadratic(
3454
- 3 * (cp1.y - p1.y),
3455
- 6 * (cp2.y - cp1.y),
3456
- 3 * (p2.y - cp2.y)
3477
+ 3 * (-p1.y + 3 * cp1.y - 3 * cp2.y + p2.y),
3478
+ 6 * (p1.y - 2 * cp1.y + cp2.y),
3479
+ 3 * (cp1.y - p1.y)
3457
3480
  );
3458
3481
  const tValues = [0, 1, ...dxRoots, ...dyRoots];
3459
- const samplePoints = (tValues2, precision) => {
3460
- for (const t of tValues2) {
3461
- for (let i = 0; i <= precision; i++) {
3462
- const delta = i / precision - 0.5;
3463
- const refinedT = Math.min(1, Math.max(0, t + delta));
3464
- const point = this.getPoint(refinedT);
3465
- min.x = Math.min(min.x, point.x);
3466
- min.y = Math.min(min.y, point.y);
3467
- max.x = Math.max(max.x, point.x);
3468
- max.y = Math.max(max.y, point.y);
3469
- }
3470
- }
3471
- };
3472
- samplePoints(tValues, 10);
3482
+ for (const t of tValues) {
3483
+ const point = this.getPoint(t);
3484
+ min.x = Math.min(min.x, point.x);
3485
+ min.y = Math.min(min.y, point.y);
3486
+ max.x = Math.max(max.x, point.x);
3487
+ max.y = Math.max(max.y, point.y);
3488
+ }
3473
3489
  return { min: min.finite(), max: max.finite() };
3474
3490
  }
3475
3491
  toCommands() {
@@ -3522,11 +3538,11 @@ class EllipseCurve extends RoundCurve {
3522
3538
  }
3523
3539
  }
3524
3540
 
3525
- class PloygonCurve extends CompositeCurve {
3541
+ class PolygonCurve extends CompositeCurve {
3526
3542
  //
3527
3543
  }
3528
3544
 
3529
- class EquilateralPloygonCurve extends PloygonCurve {
3545
+ class EquilateralPolygonCurve extends PolygonCurve {
3530
3546
  constructor(cx = 0, cy = 0, radius = 1, sideCount = 3) {
3531
3547
  super();
3532
3548
  this.cx = cx;
@@ -3609,14 +3625,25 @@ class QuadraticBezierCurve extends Curve {
3609
3625
  }
3610
3626
  getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
3611
3627
  const { p1, cp, p2 } = this;
3612
- const x1 = 0.5 * (p1.x + cp.x);
3613
- const y1 = 0.5 * (p1.y + cp.y);
3614
- const x2 = 0.5 * (p1.x + p2.x);
3615
- const y2 = 0.5 * (p1.y + p2.y);
3616
- min.x = Math.min(min.x, p1.x, p2.x, x1, x2);
3617
- min.y = Math.min(min.y, p1.y, p2.y, y1, y2);
3618
- max.x = Math.max(max.x, p1.x, p2.x, x1, x2);
3619
- max.y = Math.max(max.y, p1.y, p2.y, y1, y2);
3628
+ const extrema = (a, b, c) => {
3629
+ const denom = a - 2 * b + c;
3630
+ if (Math.abs(denom) < 1e-12)
3631
+ return null;
3632
+ const t = (a - b) / denom;
3633
+ return t > 0 && t < 1 ? t : null;
3634
+ };
3635
+ const tx = extrema(p1.x, cp.x, p2.x);
3636
+ const ty = extrema(p1.y, cp.y, p2.y);
3637
+ const xs = [p1.x, p2.x];
3638
+ const ys = [p1.y, p2.y];
3639
+ if (tx !== null)
3640
+ xs.push(quadraticBezier(tx, p1.x, cp.x, p2.x));
3641
+ if (ty !== null)
3642
+ ys.push(quadraticBezier(ty, p1.y, cp.y, p2.y));
3643
+ min.x = Math.min(min.x, ...xs);
3644
+ min.y = Math.min(min.y, ...ys);
3645
+ max.x = Math.max(max.x, ...xs);
3646
+ max.y = Math.max(max.y, ...ys);
3620
3647
  return { min: min.finite(), max: max.finite() };
3621
3648
  }
3622
3649
  toCommands() {
@@ -3641,7 +3668,7 @@ class QuadraticBezierCurve extends Curve {
3641
3668
  }
3642
3669
  }
3643
3670
 
3644
- class RectangleCurve extends PloygonCurve {
3671
+ class RectangleCurve extends PolygonCurve {
3645
3672
  constructor(x = 0, y = 0, width = 0, height = 0) {
3646
3673
  super();
3647
3674
  this.x = x;
@@ -4049,13 +4076,11 @@ class Path2D extends CompositeCurve {
4049
4076
  return this;
4050
4077
  }
4051
4078
  moveTo(x, y) {
4052
- if (!this.currentCurve.currentPoint?.equals({ x, y })) {
4053
- if (this.currentCurve.curves.length) {
4054
- this.currentCurve = new CurvePath();
4055
- this.curves.push(this.currentCurve);
4056
- }
4057
- this.currentCurve.moveTo(x, y);
4079
+ if (this.currentCurve.curves.length) {
4080
+ this.currentCurve = new CurvePath();
4081
+ this.curves.push(this.currentCurve);
4058
4082
  }
4083
+ this.currentCurve.moveTo(x, y);
4059
4084
  return this;
4060
4085
  }
4061
4086
  lineTo(x, y) {
@@ -4516,4 +4541,4 @@ function applyFFD(point, grid, width = grid.width, height = grid.height) {
4516
4541
  point.set(x, y);
4517
4542
  }
4518
4543
 
4519
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
4544
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPolygonCurve, FFDControlGrid, LineCurve, PI, PI_2, Path2D, Path2DSet, PolygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Transform2D, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parseCssArg, parseCssArgs, parseCssFunctions, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "1.5.6",
4
+ "version": "1.6.0",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A Path2D library, fully compatible with Web Path2D, with additional support for triangulate、animation、deformation etc.",
7
7
  "author": "wxm",