modern-path2d 1.3.3 → 1.3.5

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
@@ -512,7 +512,6 @@ function parseArcCommand(path, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, s
512
512
  }
513
513
 
514
514
  const RE$3 = {
515
- SEPARATOR: /[ \t\r\n,.\-+]/,
516
515
  WHITESPACE: /[ \t\r\n]/,
517
516
  DIGIT: /\d/,
518
517
  SIGN: /[-+]/,
@@ -1982,105 +1981,116 @@ class RoundCurve extends Curve {
1982
1981
  return [this._center];
1983
1982
  }
1984
1983
  _getAdaptiveVerticesByArc(output = []) {
1985
- const { cx, cy, rx, ry, dx, dy, startAngle, endAngle, clockwise: _clockwise } = this;
1986
- const clockwise = !_clockwise;
1987
- const x = cx;
1988
- const y = cy;
1989
- const start = startAngle;
1990
- const end = endAngle;
1991
- let dist = Math.abs(start - end);
1992
- if (!clockwise && start > end) {
1984
+ const { cx, cy, rx, ry, dx, dy, startAngle, endAngle, clockwise, rotate } = this;
1985
+ const counterclockwise = !clockwise;
1986
+ let dist = Math.abs(startAngle - endAngle);
1987
+ if (!counterclockwise && startAngle > endAngle) {
1993
1988
  dist = 2 * Math.PI - dist;
1994
- } else if (clockwise && end > start) {
1989
+ } else if (counterclockwise && endAngle > startAngle) {
1995
1990
  dist = 2 * Math.PI - dist;
1996
1991
  }
1997
- let steps = Math.max(6, Math.floor(6 * rx ** (1 / 3) * (dist / Math.PI)));
1998
- steps = Math.max(steps, 3);
1992
+ const steps = Math.max(12, Math.floor(12 * rx ** (1 / 3) * (dist / Math.PI)));
1999
1993
  let f = dist / steps;
2000
- let t = start;
2001
- f *= clockwise ? -1 : 1;
1994
+ let t = startAngle;
1995
+ f *= counterclockwise ? -1 : 1;
1996
+ const cos = Math.cos(counterclockwise ? rotate : -rotate);
1997
+ const sin = Math.sin(counterclockwise ? rotate : -rotate);
2002
1998
  for (let i = 0; i < steps + 1; i++) {
2003
- const cs = Math.cos(t);
2004
- const sn = Math.sin(t);
2005
- const nx = x + dx + cs * rx;
2006
- const ny = y + dy + sn * ry;
2007
- output.push(nx, ny);
1999
+ const _dx = dx + Math.cos(t) * rx;
2000
+ const _dy = dy + Math.sin(t) * ry;
2001
+ const __dx = _dx * cos - _dy * sin;
2002
+ const __dy = _dx * sin + _dy * cos;
2003
+ output.push(cx + __dx, cy + __dy);
2008
2004
  t += f;
2009
2005
  }
2010
2006
  return output;
2011
2007
  }
2012
2008
  _getAdaptiveVerticesByCircle(output = []) {
2013
- const { cx, cy, rx, ry, dx, dy } = this;
2009
+ const { cx, cy, rx, ry, dx, dy, rotate, clockwise } = this;
2014
2010
  if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {
2015
2011
  return output;
2016
2012
  }
2017
2013
  const n = Math.ceil(2.3 * Math.sqrt(rx + ry));
2018
- const x = cx;
2019
- const y = cy;
2020
2014
  const m = n * 8 + (dx ? 4 : 0) + (dy ? 4 : 0);
2015
+ const array = [];
2021
2016
  if (m === 0) {
2022
2017
  return output;
2018
+ } else {
2019
+ const start = array.length;
2020
+ if (n === 0) {
2021
+ array[start] = array[start + 6] = cx + dx;
2022
+ array[start + 1] = array[start + 3] = cy + dy;
2023
+ array[start + 2] = array[start + 4] = cx - dx;
2024
+ array[start + 5] = array[start + 7] = cy - dy;
2025
+ } else {
2026
+ let j1 = start;
2027
+ let j2 = start + n * 4 + (dx ? 2 : 0) + 2;
2028
+ let j3 = j2;
2029
+ let j4 = m;
2030
+ let _dx = dx + rx;
2031
+ let _dy = dy;
2032
+ let x1 = cx + _dx;
2033
+ let x2 = cx - _dx;
2034
+ let y1 = cy + _dy;
2035
+ array[j1++] = x1;
2036
+ array[j1++] = y1;
2037
+ array[--j2] = y1;
2038
+ array[--j2] = x2;
2039
+ if (dy) {
2040
+ const y22 = cy - _dy;
2041
+ array[j3++] = x2;
2042
+ array[j3++] = y22;
2043
+ array[--j4] = y22;
2044
+ array[--j4] = x1;
2045
+ }
2046
+ for (let i = 1; i < n; i++) {
2047
+ const t = Math.PI / 2 * (i / n);
2048
+ const _dx2 = dx + Math.cos(t) * rx;
2049
+ const _dy2 = dy + Math.sin(t) * ry;
2050
+ const x12 = cx + _dx2;
2051
+ const x22 = cx - _dx2;
2052
+ const y12 = cy + _dy2;
2053
+ const y22 = cy - _dy2;
2054
+ array[j1++] = x12;
2055
+ array[j1++] = y12;
2056
+ array[--j2] = y12;
2057
+ array[--j2] = x22;
2058
+ array[j3++] = x22;
2059
+ array[j3++] = y22;
2060
+ array[--j4] = y22;
2061
+ array[--j4] = x12;
2062
+ }
2063
+ _dx = dx;
2064
+ _dy = dy + ry;
2065
+ x1 = cx + _dx;
2066
+ x2 = cx - _dx;
2067
+ y1 = cy + _dy;
2068
+ const y2 = cy - _dy;
2069
+ array[j1++] = x1;
2070
+ array[j1++] = y1;
2071
+ array[--j4] = y2;
2072
+ array[--j4] = x1;
2073
+ if (dx) {
2074
+ array[j1++] = x2;
2075
+ array[j1++] = y1;
2076
+ array[--j4] = y2;
2077
+ array[--j4] = x2;
2078
+ }
2079
+ }
2023
2080
  }
2024
- const start = output.length;
2025
- if (n === 0) {
2026
- output[start] = output[start + 6] = x + dx;
2027
- output[start + 1] = output[start + 3] = y + dy;
2028
- output[start + 2] = output[start + 4] = x - dx;
2029
- output[start + 5] = output[start + 7] = y - dy;
2030
- return output;
2031
- }
2032
- let j1 = start;
2033
- let j2 = start + n * 4 + (dx ? 2 : 0) + 2;
2034
- let j3 = j2;
2035
- let j4 = m;
2036
- let x0 = dx + rx;
2037
- let y0 = dy;
2038
- let x1 = x + x0;
2039
- let x2 = x - x0;
2040
- let y1 = y + y0;
2041
- output[j1++] = x1;
2042
- output[j1++] = y1;
2043
- output[--j2] = y1;
2044
- output[--j2] = x2;
2045
- if (dy) {
2046
- const y22 = y - y0;
2047
- output[j3++] = x2;
2048
- output[j3++] = y22;
2049
- output[--j4] = y22;
2050
- output[--j4] = x1;
2051
- }
2052
- for (let i = 1; i < n; i++) {
2053
- const a = Math.PI / 2 * (i / n);
2054
- const x02 = dx + Math.cos(a) * rx;
2055
- const y02 = dy + Math.sin(a) * ry;
2056
- const x12 = x + x02;
2057
- const x22 = x - x02;
2058
- const y12 = y + y02;
2059
- const y22 = y - y02;
2060
- output[j1++] = x12;
2061
- output[j1++] = y12;
2062
- output[--j2] = y12;
2063
- output[--j2] = x22;
2064
- output[j3++] = x22;
2065
- output[j3++] = y22;
2066
- output[--j4] = y22;
2067
- output[--j4] = x12;
2068
- }
2069
- x0 = dx;
2070
- y0 = dy + ry;
2071
- x1 = x + x0;
2072
- x2 = x - x0;
2073
- y1 = y + y0;
2074
- const y2 = y - y0;
2075
- output[j1++] = x1;
2076
- output[j1++] = y1;
2077
- output[--j4] = y2;
2078
- output[--j4] = x1;
2079
- if (dx) {
2080
- output[j1++] = x2;
2081
- output[j1++] = y1;
2082
- output[--j4] = y2;
2083
- output[--j4] = x2;
2081
+ const cos = Math.cos(clockwise ? -rotate : rotate);
2082
+ const sin = Math.sin(clockwise ? -rotate : rotate);
2083
+ for (let i = 0; i < array.length; i += 2) {
2084
+ const x = array[i];
2085
+ const y = array[i + 1];
2086
+ const _dx = x - cx;
2087
+ const _dy = y - cy;
2088
+ const __dx = _dx * cos - _dy * sin;
2089
+ const __dy = _dx * sin + _dy * cos;
2090
+ output.push(
2091
+ cx + __dx,
2092
+ cy + __dy
2093
+ );
2084
2094
  }
2085
2095
  return output;
2086
2096
  }
@@ -2090,22 +2100,6 @@ class RoundCurve extends Curve {
2090
2100
  }
2091
2101
  return this._getAdaptiveVerticesByArc(output);
2092
2102
  }
2093
- getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
2094
- const { cx, cy, rx, ry, rotate } = this;
2095
- const cosTheta = Math.cos(rotate);
2096
- const sinTheta = Math.sin(rotate);
2097
- const halfWidth = Math.sqrt(
2098
- rx * rx * cosTheta * cosTheta + ry * ry * sinTheta * sinTheta
2099
- );
2100
- const halfHeight = Math.sqrt(
2101
- rx * rx * sinTheta * sinTheta + ry * ry * cosTheta * cosTheta
2102
- );
2103
- min.x = Math.min(min.x, cx - halfWidth);
2104
- min.y = Math.min(min.y, cy - halfHeight);
2105
- max.x = Math.max(max.x, cx + halfWidth);
2106
- max.y = Math.max(max.y, cy + halfHeight);
2107
- return { min: min.finite(), max: max.finite() };
2108
- }
2109
2103
  copy(source) {
2110
2104
  super.copy(source);
2111
2105
  this.cx = source.cx;
@@ -2984,7 +2978,7 @@ class CurvePath extends CompositeCurve {
2984
2978
  this.curves.push(new LineCurve(end.clone(), start.clone()));
2985
2979
  end.copy(start);
2986
2980
  }
2987
- this.startPoint = undefined;
2981
+ this.startPoint = void 0;
2988
2982
  }
2989
2983
  return this;
2990
2984
  }
@@ -3458,7 +3452,7 @@ class Path2D extends CompositeCurve {
3458
3452
  return { indices, vertices };
3459
3453
  }
3460
3454
  getBoundingBox(withStyle = true) {
3461
- const { min, max } = this.getMinMax(undefined, undefined, withStyle);
3455
+ const { min, max } = this.getMinMax(void 0, void 0, withStyle);
3462
3456
  return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
3463
3457
  }
3464
3458
  drawTo(ctx, style = {}) {
@@ -3511,7 +3505,7 @@ class Path2D extends CompositeCurve {
3511
3505
  };
3512
3506
  const cssStyle = {};
3513
3507
  for (const key in style) {
3514
- if (style[key] !== undefined) {
3508
+ if (style[key] !== void 0) {
3515
3509
  cssStyle[toKebabCase(key)] = style[key];
3516
3510
  }
3517
3511
  }
@@ -3520,7 +3514,7 @@ class Path2D extends CompositeCurve {
3520
3514
  });
3521
3515
  let cssText = "";
3522
3516
  for (const key in cssStyle) {
3523
- if (cssStyle[key] !== undefined) {
3517
+ if (cssStyle[key] !== void 0) {
3524
3518
  cssText += `${key}:${cssStyle[key]};`;
3525
3519
  }
3526
3520
  }
@@ -3541,7 +3535,7 @@ class Path2DSet {
3541
3535
  }
3542
3536
  getBoundingBox(withStyle = true) {
3543
3537
  if (!this.paths.length) {
3544
- return undefined;
3538
+ return void 0;
3545
3539
  }
3546
3540
  const min = Vector2.MAX;
3547
3541
  const max = Vector2.MIN;
@@ -3739,7 +3733,7 @@ const unitConversion = {
3739
3733
  };
3740
3734
  function parseFloatWithUnits(string) {
3741
3735
  let theUnit = "px";
3742
- if (typeof string === "string" || string instanceof String) {
3736
+ if (typeof string === "string") {
3743
3737
  for (let i = 0, n = units.length; i < n; i++) {
3744
3738
  const u = units[i];
3745
3739
  if (string.endsWith(u)) {
package/dist/index.d.cts CHANGED
@@ -207,10 +207,6 @@ declare class RoundCurve extends Curve {
207
207
  protected _getAdaptiveVerticesByArc(output?: number[]): number[];
208
208
  protected _getAdaptiveVerticesByCircle(output?: number[]): number[];
209
209
  getAdaptiveVertices(output?: number[]): number[];
210
- getMinMax(min?: Vector2, max?: Vector2): {
211
- min: Vector2;
212
- max: Vector2;
213
- };
214
210
  copy(source: RoundCurve): this;
215
211
  }
216
212
 
@@ -582,4 +578,5 @@ declare function svgToDOM(svg: string | SVGElement): SVGElement;
582
578
 
583
579
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
584
580
 
585
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, type DrawPointOptions, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, type FillRule, type FillTriangulateOptions, type FillTriangulatedResult, type LineCap, LineCurve, type LineJoin, type LineStyle, Matrix3, Path2D, type Path2DCommand, type Path2DData, type Path2DDrawStyle, Path2DSet, type Path2DStyle, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, type StrokeTriangulateOptions, type StrokeTriangulatedResult, Vector2, type VectorLike, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, parseArcCommand, parsePathDataArgs, pointInPolygon, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDOM, svgToPath2DSet };
581
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, Matrix3, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, parseArcCommand, parsePathDataArgs, pointInPolygon, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDOM, svgToPath2DSet };
582
+ export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, VectorLike };
package/dist/index.d.mts CHANGED
@@ -207,10 +207,6 @@ declare class RoundCurve extends Curve {
207
207
  protected _getAdaptiveVerticesByArc(output?: number[]): number[];
208
208
  protected _getAdaptiveVerticesByCircle(output?: number[]): number[];
209
209
  getAdaptiveVertices(output?: number[]): number[];
210
- getMinMax(min?: Vector2, max?: Vector2): {
211
- min: Vector2;
212
- max: Vector2;
213
- };
214
210
  copy(source: RoundCurve): this;
215
211
  }
216
212
 
@@ -582,4 +578,5 @@ declare function svgToDOM(svg: string | SVGElement): SVGElement;
582
578
 
583
579
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
584
580
 
585
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, type DrawPointOptions, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, type FillRule, type FillTriangulateOptions, type FillTriangulatedResult, type LineCap, LineCurve, type LineJoin, type LineStyle, Matrix3, Path2D, type Path2DCommand, type Path2DData, type Path2DDrawStyle, Path2DSet, type Path2DStyle, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, type StrokeTriangulateOptions, type StrokeTriangulatedResult, Vector2, type VectorLike, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, parseArcCommand, parsePathDataArgs, pointInPolygon, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDOM, svgToPath2DSet };
581
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, Matrix3, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, parseArcCommand, parsePathDataArgs, pointInPolygon, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDOM, svgToPath2DSet };
582
+ export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, VectorLike };
package/dist/index.d.ts CHANGED
@@ -207,10 +207,6 @@ declare class RoundCurve extends Curve {
207
207
  protected _getAdaptiveVerticesByArc(output?: number[]): number[];
208
208
  protected _getAdaptiveVerticesByCircle(output?: number[]): number[];
209
209
  getAdaptiveVertices(output?: number[]): number[];
210
- getMinMax(min?: Vector2, max?: Vector2): {
211
- min: Vector2;
212
- max: Vector2;
213
- };
214
210
  copy(source: RoundCurve): this;
215
211
  }
216
212
 
@@ -582,4 +578,5 @@ declare function svgToDOM(svg: string | SVGElement): SVGElement;
582
578
 
583
579
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
584
580
 
585
- export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, type DrawPointOptions, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, type FillRule, type FillTriangulateOptions, type FillTriangulatedResult, type LineCap, LineCurve, type LineJoin, type LineStyle, Matrix3, Path2D, type Path2DCommand, type Path2DData, type Path2DDrawStyle, Path2DSet, type Path2DStyle, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, type StrokeTriangulateOptions, type StrokeTriangulatedResult, Vector2, type VectorLike, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, parseArcCommand, parsePathDataArgs, pointInPolygon, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDOM, svgToPath2DSet };
581
+ export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, Matrix3, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, parseArcCommand, parsePathDataArgs, pointInPolygon, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDOM, svgToPath2DSet };
582
+ export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, VectorLike };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(T,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(T=typeof globalThis<"u"?globalThis:T||self,O(T.modernPath2d={}))})(this,function(T){"use strict";var _n=Object.defineProperty;var Vn=(T,O,nt)=>O in T?_n(T,O,{enumerable:!0,configurable:!0,writable:!0,value:nt}):T[O]=nt;var X=(T,O,nt)=>Vn(T,typeof O!="symbol"?O+"":O,nt);function O(i,e,t,n={}){const{radius:r=1}=n;i.moveTo(e,t),i.arc(e,t,r,0,Math.PI*2)}const nt={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function bt(i,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:c=0,strokeDasharray:h=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:f=0,shadowBlur:y=0,shadowColor:x="rgba(0, 0, 0, 0)"}=e;i.fillStyle=t,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=nt[s],i.miterLimit=c,i.setLineDash(h),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=f,i.shadowBlur=y,i.shadowColor=x}class d{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new d(1/0,1/0)}static get MIN(){return new d(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,o=-(this.y-t.y),s=Math.sin(n),c=Math.cos(n);return this.set(t.x+(r*c-o*s),t.y-(r*s+o*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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}){const r=e<0?n.x-this.x+n.x:this.x,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(e)*o),this.y=n.y+(o+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new d(this.x,this.y)}}class U{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}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 d((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new U;if(e.length===1)return e[0].clone();const t=e[0],n=e.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new U(n.left,n.top,n.right-n.left,n.bottom-n.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 U(this.left,this.top,this.width,this.height)}}class R{constructor(e=1,t=0,n=0,r=0,o=1,s=0,c=0,h=0,a=1){X(this,"elements",[]);this.set(e,t,n,r,o,s,c,h,a)}set(e,t,n,r,o,s,c,h,a){const l=this.elements;return l[0]=e,l[1]=r,l[2]=c,l[3]=t,l[4]=o,l[5]=h,l[6]=n,l[7]=s,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,s=n[0],c=n[3],h=n[6],a=n[1],l=n[4],f=n[7],y=n[2],x=n[5],u=n[8],g=r[0],m=r[3],v=r[6],k=r[1],w=r[4],P=r[7],I=r[2],E=r[5],p=r[8];return o[0]=s*g+c*k+h*I,o[3]=s*m+c*w+h*E,o[6]=s*v+c*P+h*p,o[1]=a*g+l*k+f*I,o[4]=a*m+l*w+f*E,o[7]=a*v+l*P+f*p,o[2]=y*g+x*k+u*I,o[5]=y*m+x*w+u*E,o[8]=y*v+x*P+u*p,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],s=e[4],c=e[5],h=e[6],a=e[7],l=e[8],f=l*s-c*a,y=c*h-l*o,x=a*o-s*h,u=t*f+n*y+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/u;return e[0]=f*g,e[1]=(r*a-l*n)*g,e[2]=(c*n-r*s)*g,e[3]=y*g,e[4]=(l*t-r*h)*g,e[5]=(r*o-c*t)*g,e[6]=x*g,e[7]=(n*h-a*t)*g,e[8]=(s*t-n*o)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(At.makeScale(e,t)),this}rotate(e){return this.premultiply(At.makeRotation(-e)),this}translate(e,t){return this.premultiply(At.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const At=new R;function zt(i,e,t,n){const r=i*t+e*n,o=Math.sqrt(i*i+e*e)*Math.sqrt(t*t+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-e*t<0&&(s=-s),s}function Zt(i,e,t,n,r,o,s,c){if(e===0||t===0){i.lineTo(c.x,c.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const h=(s.x-c.x)/2,a=(s.y-c.y)/2,l=Math.cos(n)*h+Math.sin(n)*a,f=-Math.sin(n)*h+Math.cos(n)*a;let y=e*e,x=t*t;const u=l*l,g=f*f,m=u/y+g/x;if(m>1){const q=Math.sqrt(m);e=q*e,t=q*t,y=e*e,x=t*t}const v=y*g+x*u,k=(y*x-v)/v;let w=Math.sqrt(Math.max(0,k));r===o&&(w=-w);const P=w*e*f/t,I=-w*t*l/e,E=Math.cos(n)*P-Math.sin(n)*I+(s.x+c.x)/2,p=Math.sin(n)*P+Math.cos(n)*I+(s.y+c.y)/2,M=zt(1,0,(l-P)/e,(f-I)/t),D=zt((l-P)/e,(f-I)/t,(-l-P)/e,(-f-I)/t)%(Math.PI*2);i.ellipse(E,p,e,t,n,M,M+D,o===0)}const V={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function z(i,e,t=0){let c=0,h=!0,a="",l="";const f=[];function y(m,v,k){const w=new SyntaxError(`Unexpected character "${m}" at index ${v}.`);throw w.partial=k,w}function x(){a!==""&&(l===""?f.push(Number(a)):f.push(Number(a)*10**Number(l))),a="",l=""}let u;const g=i.length;for(let m=0;m<g;m++){if(u=i[m],Array.isArray(e)&&e.includes(f.length%t)&&V.FLAGS.test(u)){c=1,a=u,x();continue}if(c===0){if(V.WHITESPACE.test(u))continue;if(V.DIGIT.test(u)||V.SIGN.test(u)){c=1,a=u;continue}if(V.POINT.test(u)){c=2,a=u;continue}V.COMMA.test(u)&&(h&&y(u,m,f),h=!0)}if(c===1){if(V.DIGIT.test(u)){a+=u;continue}if(V.POINT.test(u)){a+=u,c=2;continue}if(V.EXP.test(u)){c=3;continue}V.SIGN.test(u)&&a.length===1&&V.SIGN.test(a[0])&&y(u,m,f)}if(c===2){if(V.DIGIT.test(u)){a+=u;continue}if(V.EXP.test(u)){c=3;continue}V.POINT.test(u)&&a[a.length-1]==="."&&y(u,m,f)}if(c===3){if(V.DIGIT.test(u)){l+=u;continue}if(V.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&V.SIGN.test(l)&&y(u,m,f)}}V.WHITESPACE.test(u)?(x(),c=0,h=!1):V.COMMA.test(u)?(x(),c=0,h=!0):V.SIGN.test(u)?(x(),c=1,a=u):V.POINT.test(u)?(x(),c=2,a=u):y(u,m,f)}return x(),f}function st(i,e){return i-(e-i)}function kt(i,e){const t=new d,n=new d;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?t.add(s):t.copy(s),e.moveTo(t.x,t.y),n.copy(t);else if(s.type==="h"||s.type==="H")s.type==="h"?t.x+=s.x:t.x=s.x,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="v"||s.type==="V")s.type==="v"?t.y+=s.y:t.y=s.y,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="l"||s.type==="L")s.type==="l"?t.add(s):t.copy(s),e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="c"||s.type==="C")s.type==="c"?(e.bezierCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(e.quadraticCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x,t.y+s.y),n.x=t.x+s.x1,n.y=t.y+s.y1,t.add(s)):(e.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,t.copy(s));else if(s.type==="t"||s.type==="T"){const c=st(t.x,n.x),h=st(t.y,n.y);n.x=c,n.y=h,s.type==="t"?(e.quadraticCurveTo(c,h,t.x+s.x,t.y+s.y),t.add(s)):(e.quadraticCurveTo(c,h,s.x,s.y),t.copy(s))}else if(s.type==="a"||s.type==="A"){const c=t.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;t.add(s)}else{if(t.equals(s))continue;t.copy(s)}n.copy(t),Zt(e,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,c,t)}else s.type==="z"||s.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",s)}}function jt(i){let e,t;const n=[];for(let r=0,o=i.length;r<o;r++){const s=i[r];switch(s.type){case"m":case"M":if(s.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&s.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y},e={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),t={x:s.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),t={x:(t==null?void 0:t.x)??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"c":case"C":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"a":case"A":n.push(`${s.type} ${s.rx} ${s.ry} ${s.angle} ${s.largeArcFlag} ${s.sweepFlag} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const Ae=/[a-df-z][^a-df-z]*/gi;function It(i){const e=[],t=i.match(Ae);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],s=o.charAt(0),c=o.slice(1).trim();let h;switch(s){case"m":case"M":h=z(c);for(let a=0,l=h.length;a<l;a+=2)a===0?e.push({type:s,x:h[a],y:h[a+1]}):e.push({type:s==="m"?"l":"L",x:h[a],y:h[a+1]});break;case"h":case"H":h=z(c);for(let a=0,l=h.length;a<l;a++)e.push({type:s,x:h[a]});break;case"v":case"V":h=z(c);for(let a=0,l=h.length;a<l;a++)e.push({type:s,y:h[a]});break;case"l":case"L":h=z(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:s,x:h[a],y:h[a+1]});break;case"c":case"C":h=z(c);for(let a=0,l=h.length;a<l;a+=6)e.push({type:s,x1:h[a],y1:h[a+1],x2:h[a+2],y2:h[a+3],x:h[a+4],y:h[a+5]});break;case"s":case"S":h=z(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:s,x2:h[a],y2:h[a+1],x:h[a+2],y:h[a+3]});break;case"q":case"Q":h=z(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:s,x1:h[a],y1:h[a+1],x:h[a+2],y:h[a+3]});break;case"t":case"T":h=z(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:s,x:h[a],y:h[a+1]});break;case"a":case"A":h=z(c,[3,4],7);for(let a=0,l=h.length;a<l;a+=7)e.push({type:s,rx:h[a],ry:h[a+1],angle:h[a+2],largeArcFlag:h[a+3],sweepFlag:h[a+4],x:h[a+5],y:h[a+6]});break;case"z":case"Z":e.push({type:s});break;default:console.warn(o)}}return e}function St(i,e,t,n,r){const o=(n-e)*.5,s=(r-t)*.5,c=i*i,h=i*c;return(2*t-2*n+o+s)*h+(-3*t+3*n-2*o-s)*c+o*i+t}function ke(i,e){const t=1-i;return t*t*t*e}function Ie(i,e){const t=1-i;return 3*t*t*i*e}function Se(i,e){return 3*(1-i)*i*i*e}function Ee(i,e){return i*i*i*e}function Et(i,e,t,n,r){return ke(i,e)+Ie(i,t)+Se(i,n)+Ee(i,r)}function $e(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Bt(i,0,r,t,!0);const s=[];if(!o||o.next===o.prev)return s;let c,h,a;if(n&&(o=Ve(i,e,o,t)),i.length>80*t){c=1/0,h=1/0;let l=-1/0,f=-1/0;for(let y=t;y<r;y+=t){const x=i[y],u=i[y+1];x<c&&(c=x),u<h&&(h=u),x>l&&(l=x),u>f&&(f=u)}a=Math.max(l-c,f-h),a=a!==0?32767/a:0}return ot(o,s,t,c,h,a,0),s}function Bt(i,e,t,n,r){let o;if(r===Ue(i,e,t,n)>0)for(let s=e;s<t;s+=n)o=Wt(s/n|0,i[s],i[s+1],o);else for(let s=t-n;s>=e;s-=n)o=Wt(s/n|0,i[s],i[s+1],o);return o&&it(o,o.next)&&(at(o),o=o.next),o}function H(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(it(t,t.next)||F(t.prev,t,t.next)===0)){if(at(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ot(i,e,t,n,r,o,s){if(!i)return;!s&&o&&ze(i,n,r,o);let c=i;for(;i.prev!==i.next;){const h=i.prev,a=i.next;if(o?Fe(i,n,r,o):Le(i)){e.push(h.i,i.i,a.i),at(i),i=a.next,c=a.next;continue}if(i=a,i===c){s?s===1?(i=Ne(H(i),e),ot(i,e,t,n,r,o,2)):s===2&&_e(i,e,t,n,r,o):ot(H(i),e,t,n,r,o,1);break}}}function Le(i){const e=i.prev,t=i,n=i.next;if(F(e,t,n)>=0)return!1;const r=e.x,o=t.x,s=n.x,c=e.y,h=t.y,a=n.y,l=Math.min(r,o,s),f=Math.min(c,h,a),y=Math.max(r,o,s),x=Math.max(c,h,a);let u=n.next;for(;u!==e;){if(u.x>=l&&u.x<=y&&u.y>=f&&u.y<=x&&ct(r,c,o,h,s,a,u.x,u.y)&&F(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function Fe(i,e,t,n){const r=i.prev,o=i,s=i.next;if(F(r,o,s)>=0)return!1;const c=r.x,h=o.x,a=s.x,l=r.y,f=o.y,y=s.y,x=Math.min(c,h,a),u=Math.min(l,f,y),g=Math.max(c,h,a),m=Math.max(l,f,y),v=$t(x,u,e,t,n),k=$t(g,m,e,t,n);let w=i.prevZ,P=i.nextZ;for(;w&&w.z>=v&&P&&P.z<=k;){if(w.x>=x&&w.x<=g&&w.y>=u&&w.y<=m&&w!==r&&w!==s&&ct(c,l,h,f,a,y,w.x,w.y)&&F(w.prev,w,w.next)>=0||(w=w.prevZ,P.x>=x&&P.x<=g&&P.y>=u&&P.y<=m&&P!==r&&P!==s&&ct(c,l,h,f,a,y,P.x,P.y)&&F(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;w&&w.z>=v;){if(w.x>=x&&w.x<=g&&w.y>=u&&w.y<=m&&w!==r&&w!==s&&ct(c,l,h,f,a,y,w.x,w.y)&&F(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;P&&P.z<=k;){if(P.x>=x&&P.x<=g&&P.y>=u&&P.y<=m&&P!==r&&P!==s&&ct(c,l,h,f,a,y,P.x,P.y)&&F(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function Ne(i,e){let t=i;do{const n=t.prev,r=t.next.next;!it(n,r)&&Xt(n,t,t.next,r)&&ht(n,r)&&ht(r,n)&&(e.push(n.i,t.i,r.i),at(t),at(t.next),t=i=r),t=t.next}while(t!==i);return H(t)}function _e(i,e,t,n,r,o){let s=i;do{let c=s.next.next;for(;c!==s.prev;){if(s.i!==c.i&&Be(s,c)){let h=Ut(s,c);s=H(s,s.next),h=H(h,h.next),ot(s,e,t,n,r,o,0),ot(h,e,t,n,r,o,0);return}c=c.next}s=s.next}while(s!==i)}function Ve(i,e,t,n){const r=[];for(let o=0,s=e.length;o<s;o++){const c=e[o]*n,h=o<s-1?e[o+1]*n:i.length,a=Bt(i,c,h,n,!1);a===a.next&&(a.steiner=!0),r.push(je(a))}r.sort(De);for(let o=0;o<r.length;o++)t=qe(r[o],t);return t}function De(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function qe(i,e){const t=Oe(i,e);if(!t)return e;const n=Ut(t,i);return H(n,n.next),H(t,t.next)}function Oe(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,s;if(it(i,t))return t;do{if(it(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>o&&(o=f,s=t.x<t.next.x?t:t.next,f===n))return s}t=t.next}while(t!==e);if(!s)return null;const c=s,h=s.x,a=s.y;let l=1/0;t=s;do{if(n>=t.x&&t.x>=h&&n!==t.x&&Gt(r<a?n:o,r,h,a,r<a?o:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);ht(t,i)&&(f<l||f===l&&(t.x>s.x||t.x===s.x&&Re(s,t)))&&(s=t,l=f)}t=t.next}while(t!==c);return s}function Re(i,e){return F(i.prev,i,e.prev)<0&&F(e.next,i,i.next)<0}function ze(i,e,t,n){let r=i;do r.z===0&&(r.z=$t(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Ze(r)}function Ze(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let s=n,c=0;for(let a=0;a<t&&(c++,s=s.nextZ,!!s);a++);let h=t;for(;c>0||h>0&&s;)c!==0&&(h===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,c--):(r=s,s=s.nextZ,h--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,t*=2}while(e>1);return i}function $t(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function je(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Gt(i,e,t,n,r,o,s,c){return(r-s)*(e-c)>=(i-s)*(o-c)&&(i-s)*(n-c)>=(t-s)*(e-c)&&(t-s)*(o-c)>=(r-s)*(n-c)}function ct(i,e,t,n,r,o,s,c){return!(i===s&&e===c)&&Gt(i,e,t,n,r,o,s,c)}function Be(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Ge(i,e)&&(ht(i,e)&&ht(e,i)&&Xe(i,e)&&(F(i.prev,i,e.prev)||F(i,e.prev,e))||it(i,e)&&F(i.prev,i,i.next)>0&&F(e.prev,e,e.next)>0)}function F(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function it(i,e){return i.x===e.x&&i.y===e.y}function Xt(i,e,t,n){const r=pt(F(i,e,t)),o=pt(F(i,e,n)),s=pt(F(t,n,i)),c=pt(F(t,n,e));return!!(r!==o&&s!==c||r===0&&gt(i,t,e)||o===0&&gt(i,n,e)||s===0&&gt(t,i,n)||c===0&&gt(t,e,n))}function gt(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function pt(i){return i>0?1:i<0?-1:0}function Ge(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Xt(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ht(i,e){return F(i.prev,i,i.next)<0?F(i,e,i.next)>=0&&F(i,i.prev,e)>=0:F(i,e,i.prev)<0||F(i,i.next,e)<0}function Xe(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Ut(i,e){const t=Lt(i.i,i.x,i.y),n=Lt(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Wt(i,e,t,n){const r=Lt(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function at(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Lt(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ue(i,e,t,n){let r=0;for(let o=e,s=t-n;o<t;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Ft(i,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=t.length/o,indicesOffset:c=n.length}=e;const h=$e(i,r,2);if(h.length){for(let l=0;l<h.length;l+=3)n[c++]=h[l]+s,n[c++]=h[l+1]+s,n[c++]=h[l+2]+s;let a=s*o;for(let l=0;l<i.length;l+=2)t[a]=i[l],t[a+1]=i[l+1],a+=o}return{vertices:t,indices:n}}const We=8,dt=11920929e-14,He=1;function Ht(i,e,t,n,r,o,s,c,h=.5,a=[]){const f=Math.min(.99,Math.max(0,h));let y=(He-f)/1;return y*=y,Nt(i,e,t,n,r,o,s,c,a,y,0),a.push(s,c),a}function Nt(i,e,t,n,r,o,s,c,h,a,l){if(l>We)return;const f=(i+t)/2,y=(e+n)/2,x=(t+r)/2,u=(n+o)/2,g=(r+s)/2,m=(o+c)/2,v=(f+x)/2,k=(y+u)/2,w=(x+g)/2,P=(u+m)/2,I=(v+w)/2,E=(k+P)/2;if(l>0){let p=s-i,M=c-e;const D=Math.abs((t-s)*M-(n-c)*p),q=Math.abs((r-s)*M-(o-c)*p);if(D>dt&&q>dt){if((D+q)*(D+q)<=a*(p*p+M*M)){h.push(I,E);return}}else if(D>dt){if(D*D<=a*(p*p+M*M)){h.push(I,E);return}}else if(q>dt){if(q*q<=a*(p*p+M*M)){h.push(I,E);return}}else if(p=I-(i+s)/2,M=E-(e+c)/2,p*p+M*M<=a){h.push(I,E);return}}Nt(i,e,f,y,v,k,I,E,h,a,l+1),Nt(I,E,w,P,g,m,s,c,h,a,l+1)}const Qe=8,Ye=11920929e-14,Je=1;function Qt(i,e,t,n,r,o,s=.5,c=[]){const a=Math.min(.99,Math.max(0,s));let l=(Je-a)/1;return l*=l,_t(c,i,e,t,n,r,o,l,0),c.push(r,o),c}function _t(i,e,t,n,r,o,s,c,h){if(h>Qe)return;const a=(e+n)/2,l=(t+r)/2,f=(n+o)/2,y=(r+s)/2,x=(a+f)/2,u=(l+y)/2;let g=o-e,m=s-t;const v=Math.abs((n-o)*m-(r-s)*g);if(v>Ye){if(v*v<=c*(g*g+m*m)){i.push(x,u);return}}else if(g=x-(e+o)/2,m=u-(t+s)/2,g*g+m*m<=c){i.push(x,u);return}_t(i,e,t,a,l,x,u,c,h+1),_t(i,x,u,f,y,o,s,c,h+1)}function Ke(i){let e=0;const t=i.length;for(let n=0;n<t;n+=2){const r=i[n],o=i[n+1],s=i[(n+2)%(t-1)],c=i[(n+3)%t];e+=r*c-s*o}return e/2}function Yt(i,e){let t=!1;const[n,r]=i,o=e.length/2;for(let s=0,c=o-1;s<o;c=s++){const h=e[s*2],a=e[s*2+1],l=e[c*2],f=e[c*2+1];a>r!=f>r&&n<(l-h)*(r-a)/(f-a)+h&&(t=!t)}return t}function tn(i,e){const t=1-i;return t*t*e}function en(i,e){return 2*(1-i)*i*e}function nn(i,e){return i*i*e}function Vt(i,e,t,n){return tn(i,e)+en(i,t)+nn(i,n)}const sn=1e-4,Jt=1e-4;function Kt(i,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=e,c=sn;if(i.length===0)return{vertices:t,indices:n};const h=r;let a=h.alignment;if(r.alignment!==.5){let L=rn(i);o&&(L*=-1),a=(a-.5)*L+.5}const l={x:i[0],y:i[1]},f={x:i[i.length-2],y:i[i.length-1]},y=s,x=Math.abs(l.x-f.x)<c&&Math.abs(l.y-f.y)<c;if(y){i=i.slice(),x&&(i.pop(),i.pop(),f.x=i[i.length-2],f.y=i[i.length-1]);const L=(l.x+f.x)*.5,W=(f.y+l.y)*.5;i.unshift(L,W),i.push(L,W)}const u=t,g=i.length/2;let m=i.length;const v=u.length/2,k=h.width/2,w=k*k,P=h.miterLimit*h.miterLimit;let I=i[0],E=i[1],p=i[2],M=i[3],D=0,q=0,b=-(E-M),A=I-p,N=0,_=0,B=Math.sqrt(b*b+A*A);b/=B,A/=B,b*=k,A*=k;const Pe=a,C=(1-Pe)*2,S=Pe*2;y||(h.cap==="round"?m+=Q(I-b*(C-S)*.5,E-A*(C-S)*.5,I-b*C,E-A*C,I+b*S,E+A*S,u,!0)+2:h.cap==="square"&&(m+=te(I,E,b,A,C,S,!0,u))),u.push(I-b*C,E-A*C),u.push(I+b*S,E+A*S);for(let L=1;L<g-1;++L){I=i[(L-1)*2],E=i[(L-1)*2+1],p=i[L*2],M=i[L*2+1],D=i[(L+1)*2],q=i[(L+1)*2+1],b=-(E-M),A=I-p,B=Math.sqrt(b*b+A*A),b/=B,A/=B,b*=k,A*=k,N=-(M-q),_=p-D,B=Math.sqrt(N*N+_*_),N/=B,_/=B,N*=k,_*=k;const W=p-I,ut=E-M,ft=p-D,yt=q-M,ve=W*ft+ut*yt,vt=ut*ft-yt*W,xt=vt<0;if(Math.abs(vt)<.001*Math.abs(ve)){u.push(p-b*C,M-A*C),u.push(p+b*S,M+A*S),ve>=0&&(h.join==="round"?m+=Q(p,M,p-b*C,M-A*C,p-N*C,M-_*C,u,!1)+4:m+=2,u.push(p-N*S,M-_*S),u.push(p+N*C,M+_*C));continue}const Te=(-b+I)*(-A+M)-(-b+p)*(-A+E),Ce=(-N+D)*(-_+M)-(-N+p)*(-_+q),Tt=(W*Ce-ft*Te)/vt,Ct=(yt*Te-ut*Ce)/vt,Rt=(Tt-p)*(Tt-p)+(Ct-M)*(Ct-M),J=p+(Tt-p)*C,K=M+(Ct-M)*C,tt=p-(Tt-p)*S,et=M-(Ct-M)*S,Fn=Math.min(W*W+ut*ut,ft*ft+yt*yt),be=xt?C:S,Nn=Fn+be*be*w;Rt<=Nn?h.join==="bevel"||Rt/w>P?(xt?(u.push(J,K),u.push(p+b*S,M+A*S),u.push(J,K),u.push(p+N*S,M+_*S)):(u.push(p-b*C,M-A*C),u.push(tt,et),u.push(p-N*C,M-_*C),u.push(tt,et)),m+=2):h.join==="round"?xt?(u.push(J,K),u.push(p+b*S,M+A*S),m+=Q(p,M,p+b*S,M+A*S,p+N*S,M+_*S,u,!0)+4,u.push(J,K),u.push(p+N*S,M+_*S)):(u.push(p-b*C,M-A*C),u.push(tt,et),m+=Q(p,M,p-b*C,M-A*C,p-N*C,M-_*C,u,!1)+4,u.push(p-N*C,M-_*C),u.push(tt,et)):(u.push(J,K),u.push(tt,et)):(u.push(p-b*C,M-A*C),u.push(p+b*S,M+A*S),h.join==="round"?xt?m+=Q(p,M,p+b*S,M+A*S,p+N*S,M+_*S,u,!0)+2:m+=Q(p,M,p-b*C,M-A*C,p-N*C,M-_*C,u,!1)+2:h.join==="miter"&&Rt/w<=P&&(xt?(u.push(tt,et),u.push(tt,et)):(u.push(J,K),u.push(J,K)),m+=2),u.push(p-N*C,M-_*C),u.push(p+N*S,M+_*S),m+=2)}I=i[(g-2)*2],E=i[(g-2)*2+1],p=i[(g-1)*2],M=i[(g-1)*2+1],b=-(E-M),A=I-p,B=Math.sqrt(b*b+A*A),b/=B,A/=B,b*=k,A*=k,u.push(p-b*C,M-A*C),u.push(p+b*S,M+A*S),y||(h.cap==="round"?m+=Q(p-b*(C-S)*.5,M-A*(C-S)*.5,p-b*C,M-A*C,p+b*S,M+A*S,u,!1)+2:h.cap==="square"&&(m+=te(p,M,b,A,C,S,!1,u)));const Ln=Jt*Jt;for(let L=v;L<m+v-2;++L)I=u[L*2],E=u[L*2+1],p=u[(L+1)*2],M=u[(L+1)*2+1],D=u[(L+2)*2],q=u[(L+2)*2+1],!(Math.abs(I*(M-q)+p*(q-E)+D*(E-M))<Ln)&&n.push(L,L+1,L+2);return{vertices:t,indices:n}}function rn(i){const e=i.length;if(e<6)return 1;let t=0;for(let n=0,r=i[e-2],o=i[e-1];n<e;n+=2){const s=i[n],c=i[n+1];t+=(s-r)*(c+o),r=s,o=c}return t<0?-1:1}function te(i,e,t,n,r,o,s,c){const h=i-t*r,a=e-n*r,l=i+t*o,f=e+n*o;let y,x;s?(y=n,x=-t):(y=-n,x=t);const u=h+y,g=a+x,m=l+y,v=f+x;return c.push(u,g),c.push(m,v),2}function Q(i,e,t,n,r,o,s,c){const h=t-i,a=n-e;let l=Math.atan2(h,a),f=Math.atan2(r-i,o-e);c&&l<f?l+=Math.PI*2:!c&&l>f&&(f+=Math.PI*2);let y=l;const x=f-l,u=Math.abs(x),g=Math.sqrt(h*h+a*a),m=(15*u*Math.sqrt(g)/Math.PI>>0)+1,v=x/m;if(y+=v,c){s.push(i,e),s.push(t,n);for(let k=1,w=y;k<m;k++,w+=v)s.push(i,e),s.push(i+Math.sin(w)*g,e+Math.cos(w)*g);s.push(i,e),s.push(r,o)}else{s.push(t,n),s.push(i,e);for(let k=1,w=y;k<m;k++,w+=v)s.push(i+Math.sin(w)*g,e+Math.cos(w)*g),s.push(i,e);s.push(r,o),s.push(i,e)}return m*2}class Y{constructor(){X(this,"arcLengthDivision",200);X(this,"_arcLengths")}getPointAt(e,t=new d){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){const t=typeof e=="function";return this.getControlPointRefs().forEach(n=>{t?e(n):n.applyMatrix3(e)}),this}getUnevenVertices(e=5,t=[]){const n=new d;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){const n=new d;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,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){const o=e[n],s=e[n+1];t.push(new d(o,s))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenVertices(e):n=this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),o=1;o<=e;o++){const s=this.getPoint(o/e);n+=s.distanceTo(r),t.push(n),r=s}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/n[0];let s=0,c=0,h=r-1,a;for(;c<=h;)if(s=Math.floor(c+(h-c)/2),a=n[s]-o,a<0)c=s+1;else if(a>0)h=s-1;else{h=s;break}if(s=h,n[s]===o)return s/(r-1);const l=n[s],y=n[s+1]-l,x=(o-l)/y;return(s+x)/(r-1)}getTangent(e,t=new d){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new d){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,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(e)<t)return o;s.x<e.x?n=o:r=o}return o}getMinMax(e=d.MAX,t=d.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];e.min(s),t.max(s)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new U(e.x,e.y,t.x-e.x,t.y-e.y)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return Ft(this.getFillVertices(e),e)}strokeTriangulate(e){return Kt(this.getAdaptiveVertices(),e)}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return jt(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}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const on=new R,ee=new R,ne=new R,mt=new d;class Dt extends Y{constructor(e=new d,t=new d,n=new d,r=0,o=0,s=Math.PI*2,c=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=c}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}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const n=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new d){const n=this._getDeltaAngle(),r=this.startAngle+e*n;let o=this.cx+this.rx*Math.cos(r),s=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const c=Math.cos(this.rotate),h=Math.sin(this.rotate),a=o-this.cx,l=s-this.cy;o=a*c-l*h+this.cx,s=a*h+l*c+this.cy}return t.set(o,s)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:c,rotate:h}=this,a=e+n*Math.cos(o)*Math.cos(h)-r*Math.sin(o)*Math.sin(h),l=t+n*Math.cos(o)*Math.sin(h)+r*Math.sin(o)*Math.cos(h),f=Math.abs(o-s),y=f>Math.PI?1:0,x=c?1:0,u=h*180/Math.PI;if(f>=2*Math.PI){const g=o+Math.PI,m=e+n*Math.cos(g)*Math.cos(h)-r*Math.sin(g)*Math.sin(h),v=t+n*Math.cos(g)*Math.sin(h)+r*Math.sin(g)*Math.cos(h);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:m,y:v},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const g=e+n*Math.cos(s)*Math.cos(h)-r*Math.sin(s)*Math.sin(h),m=t+n*Math.cos(s)*Math.sin(h)+r*Math.sin(s)*Math.cos(h);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:y,sweepFlag:x,x:g,y:m}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:s,startAngle:c,endAngle:h,clockwise:a}=this;return e.ellipse(t,n,r,o,s,c,h,!a),this}applyTransform(e){return mt.set(this.cx,this.cy),mt.applyMatrix3(e),this.cx=mt.x,this.cy=mt.y,an(e)?cn(this,e):hn(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:c,startAngle:h,endAngle:a,clockwise:l}=this,f=!l,y=t,x=n,u=h,g=a;let m=Math.abs(u-g);(!f&&u>g||f&&g>u)&&(m=2*Math.PI-m);let v=Math.max(6,Math.floor(6*r**(1/3)*(m/Math.PI)));v=Math.max(v,3);let k=m/v,w=u;k*=f?-1:1;for(let P=0;P<v+1;P++){const I=Math.cos(w),E=Math.sin(w),p=y+s+I*r,M=x+c+E*o;e.push(p,M),w+=k}return e}_getAdaptiveVerticesByCircle(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:c}=this;if(!(r>=0&&o>=0&&s>=0&&c>=0))return e;const h=Math.ceil(2.3*Math.sqrt(r+o)),a=t,l=n,f=h*8+(s?4:0)+(c?4:0);if(f===0)return e;const y=e.length;if(h===0)return e[y]=e[y+6]=a+s,e[y+1]=e[y+3]=l+c,e[y+2]=e[y+4]=a-s,e[y+5]=e[y+7]=l-c,e;let x=y,u=y+h*4+(s?2:0)+2,g=u,m=f,v=s+r,k=c,w=a+v,P=a-v,I=l+k;if(e[x++]=w,e[x++]=I,e[--u]=I,e[--u]=P,c){const p=l-k;e[g++]=P,e[g++]=p,e[--m]=p,e[--m]=w}for(let p=1;p<h;p++){const M=Math.PI/2*(p/h),D=s+Math.cos(M)*r,q=c+Math.sin(M)*o,b=a+D,A=a-D,N=l+q,_=l-q;e[x++]=b,e[x++]=N,e[--u]=N,e[--u]=A,e[g++]=A,e[g++]=_,e[--m]=_,e[--m]=b}v=s,k=c+o,w=a+v,P=a-v,I=l+k;const E=l-k;return e[x++]=w,e[x++]=I,e[--m]=E,e[--m]=w,s&&(e[x++]=P,e[x++]=I,e[--m]=E,e[--m]=P),e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}getMinMax(e=d.MAX,t=d.MIN){const{cx:n,cy:r,rx:o,ry:s,rotate:c}=this,h=Math.cos(c),a=Math.sin(c),l=Math.sqrt(o*o*h*h+s*s*a*a),f=Math.sqrt(o*o*a*a+s*s*h*h);return e.x=Math.min(e.x,n-l),e.y=Math.min(e.y,r-f),t.x=Math.max(t.x,n+l),t.y=Math.max(t.y,r+f),{min:e.finite(),max:t.finite()}}copy(e){return super.copy(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 cn(i,e){const t=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new d(t*r,t*o),c=new d(-n*o,n*r),h=s.applyMatrix3(e),a=c.applyMatrix3(e),l=on.set(h.x,a.x,0,h.y,a.y,0,0,0,1),f=ee.copy(l).invert(),u=ne.copy(f).transpose().multiply(f).elements,g=ln(u[0],u[1],u[4]),m=Math.sqrt(g.rt1),v=Math.sqrt(g.rt2);if(i.rx=1/m,i.ry=1/v,i.rotate=Math.atan2(g.sn,g.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=ee.set(m,0,0,0,v,0,0,0,1),P=ne.set(g.cs,g.sn,0,-g.sn,g.cs,0,0,0,1),I=w.multiply(P).multiply(l),E=p=>{const{x:M,y:D}=new d(Math.cos(p),Math.sin(p)).applyMatrix3(I);return Math.atan2(D,M)};i.startAngle=E(i.startAngle),i.endAngle=E(i.endAngle),se(e)&&(i.clockwise=!i.clockwise)}}function hn(i,e){const t=ie(e),n=re(e);i.rx*=t,i.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);i.rotate+=r,se(e)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function se(i){const e=i.elements;return e[0]*e[4]-e[1]*e[3]<0}function an(i){const e=i.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=ie(i),r=re(i);return Math.abs(t/(n*r))>Number.EPSILON}function ie(i){const e=i.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function re(i){const e=i.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function ln(i,e,t){let n,r,o,s,c;const h=i+t,a=i-t,l=Math.sqrt(a*a+4*e*e);return h>0?(n=.5*(h+l),c=1/n,r=i*c*t-e*c*e):h<0?r=.5*(h-l):(n=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(e)?(c=-2*e/o,s=1/Math.sqrt(1+c*c),o=c*s):Math.abs(e)===0?(o=1,s=0):(c=-.5*o/e,o=1/Math.sqrt(1+c*c),s=c*o),a>0&&(c=o,o=-s,s=c),{rt1:n,rt2:r,cs:o,sn:s}}class oe extends Dt{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,s=!1){super(new d(e,t),new d(n,n),new d,0,r,o,s)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;return e.arc(t,n,r,o,s,!c),this}getAdaptiveVertices(e=[]){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;let h=Math.abs(o-s);(!c&&o>s||c&&s>o)&&(h=2*Math.PI-h);let a=Math.max(6,Math.floor(6*r**(1/3)*(h/Math.PI)));a=Math.max(a,3);let l=h/a,f=o;l*=c?1:-1;for(let y=0;y<a+1;y++){const x=Math.cos(f),u=Math.sin(f),g=t+x*r,m=n+u*r;e.push(g,m),f+=l}return e}}class Z extends Y{constructor(e=new d,t=new d){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new Z(new d(e,t),new d(n,r))}getPoint(e,t=new d){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new d){return this.getPoint(e,t)}getTangent(e,t=new d){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new d){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=d.MAX,t=d.MIN){const{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(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}getFillVertices(e={}){var l,f;const 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),o=Math.max(this.p1.y,this.p2.y),s=t,c=r,h=n-t||((l=e.style)==null?void 0:l.strokeWidth)||0,a=o-r||((f=e.style)==null?void 0:f.strokeWidth)||0;return[s,c,s+h,c,s+h,c+a,s,c+a]}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class rt extends Y{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof rt?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new d){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,c=this.curves[o],h=c.getLength();return c.getPointAt(h===0?0:1-s/h,t)}o++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){const 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);{const t=[];let n;return this.curves.forEach(r=>{let o;r instanceof Z?o=r.getAdaptiveVertices():o=r.getFillVertices(e),t.push(...o),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=d.MAX,t=d.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new U(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Mt extends Y{constructor(e=new d,t=new d,n=new d,r=new d){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,s,c,h){return new Mt(new d(e,t),new d(n,r),new d(o,s),new d(c,h))}getPoint(e,t=new d){const{p1:n,cp1:r,cp2:o,p2:s}=this;return t.set(Et(e,n.x,r.x,o.x,s.x),Et(e,n.y,r.y,o.y,s.y))}getAdaptiveVertices(e=[]){return Ht(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){const r=t*t-4*e*n;if(r<0)return[];const o=Math.sqrt(r),s=(-t+o)/(2*e),c=(-t-o)/(2*e);return[s,c].filter(h=>h>=0&&h<=1)}getMinMax(e=d.MAX,t=d.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,c=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),h=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),a=[0,1,...c,...h];return((f,y)=>{for(const x of f)for(let u=0;u<=y;u++){const g=u/y-.5,m=Math.min(1,Math.max(0,x+g)),v=this.getPoint(m);e.x=Math.min(e.x,v.x),e.y=Math.min(e.y,v.y),t.x=Math.max(t.x,v.x),t.y=Math.max(t.y,v.y)}})(a,10),{min:e.finite(),max:t.finite()}}toCommands(){const{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){const{p1:t,cp1:n,cp2:r,p2:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class ce extends Dt{constructor(e=0,t=0,n=1,r=1,o=0,s=0,c=Math.PI*2,h=!1){super(new d(e,t),new d(n,r),new d,o,s,c,h)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class qt extends rt{}class un extends qt{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(){const{cx:e,cy:t,radius:n,sideCount:r}=this,o=[];for(let c=0;c<r;c++){const h=c*2*Math.PI/r-.5*Math.PI;o.push(new d(n*Math.cos(h),n*Math.sin(h)).add({x:e,y:t}))}const s=[];for(let c=0;c<r;c++)s.push(new Z(o[c],o[(c+1)%r]));return this.curves=s,this}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}}class wt extends Y{constructor(e=new d,t=new d,n=new d){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,s){return new wt(new d(e,t),new d(n,r),new d(o,s))}getPoint(e,t=new d){const{p1:n,cp:r,p2:o}=this;return t.set(Vt(e,n.x,r.x,o.x),Vt(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return Qt(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=d.MAX,t=d.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),c=.5*(n.y+r.y),h=.5*(n.x+o.x),a=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,s,h),e.y=Math.min(e.y,n.y,o.y,c,a),t.x=Math.max(t.x,n.x,o.x,s,h),t.y=Math.max(t.y,n.y,o.y,c,a),{min:e.finite(),max:t.finite()}}toCommands(){const{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){const{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}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class he extends qt{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(){const{x:e,y:t,width:n,height:r}=this,o=[new d(e,t),new d(e+n,t),new d(e+n,t+r),new d(e,t+r)];return this.curves=[new Z(o[0],o[1]),new Z(o[1],o[2]),new Z(o[2],o[3]),new Z(o[3],o[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){const{x:t,y:n,width:r,height:o}=this;return[t,n,t+r,n,t+r,n+o,t,n+o]}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class ae extends Dt{constructor(e=0,t=0,n=1,r=1,o=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:o}=this,s=n/2,c=r/2,h=e+s,a=t+c,l=Math.max(0,Math.min(o,Math.min(s,c))),f=l;return this._center=new d(h,a),this._radius=new d(l,f),this._diff=new d(s-l,c-f),this}drawTo(e){const{x:t,y:n,width:r,height:o,radius:s}=this;return e.roundRect(t,n,r,o,s),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class le extends Y{constructor(e=[]){super(),this.points=e}getPoint(e,t=new d){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),s=r-o,c=n[o===0?o:o-1],h=n[o],a=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return t.set(St(s,c.x,h.x,a.x,l.x),St(s,c.y,h.y,a.y,l.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class lt extends rt{constructor(t){super();X(this,"startPoint");X(this,"currentPoint");X(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:o,y:s}=t[n];this.lineTo(o,s)}return this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,n=[]){return this._closeVertices(super.getUnevenVertices(t,n))}getSpacedVertices(t=40,n=[]){return this._closeVertices(super.getSpacedVertices(t,n))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new d(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new Z(n.clone(),t.clone())),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new d(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(Z.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,o,s,c){const h=this.currentPoint;return h!=null&&h.equals({x:s,y:c})||this.curves.push(Mt.from((h==null?void 0:h.x)??0,(h==null?void 0:h.y)??0,t,n,r,o,s,c)),this._setCurrentPoint({x:s,y:c}),this}quadraticCurveTo(t,n,r,o){const s=this.currentPoint;return s!=null&&s.equals({x:r,y:o})||this.curves.push(wt.from((s==null?void 0:s.x)??0,(s==null?void 0:s.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,s,c){const h=new oe(t,n,r,o,s,!c);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeArc(t,n,r,o,s,c){var h,a;return t+=((h=this.currentPoint)==null?void 0:h.x)??0,n+=((a=this.currentPoint)==null?void 0:a.y)??0,this.arc(t,n,r,o,s,c),this}arcTo(t,n,r,o,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,s,c,h,a=!0){const l=new ce(t,n,r,o,s,c,h,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,n,r,o,s,c,h,a){var l,f;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((f=this.currentPoint)==null?void 0:f.y)??0,this.ellipse(t,n,r,o,s,c,h,a),this}rect(t,n,r,o){const s=new he(t,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,s){const c=new ae(t,n,r,o,s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new d;return this.curves.push(new le([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function fn(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function yn(i,e,t,n){const r=e.clone().sub(i),o=n.clone().sub(t),s=t.clone().sub(i),c=r.cross(o);if(c===0)return new d((i.x+t.x)/2,(i.y+t.y)/2);const h=s.cross(o)/c;return Math.abs(h)>1?new d((i.x+t.x)/2,(i.y+t.y)/2):new d(i.x+h*r.x,i.y+h*r.y)}class j extends rt{constructor(t,n={}){super();X(this,"currentCurve",new lt);X(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof j?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}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)}addPath(t){const n=this.curves.findIndex(r=>r===this.currentCurve);return n>-1&&this.curves.splice(n,1),t instanceof j?this.curves.push(...t.curves.filter(r=>r.curves.length).map(r=>r.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new lt().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new lt,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,o,s,c){return this.currentCurve.bezierCurveTo(t,n,r,o,s,c),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,s,c){return this.currentCurve.arc(t,n,r,o,s,c),this}arcTo(t,n,r,o,s){return this.currentCurve.arcTo(t,n,r,o,s),this}ellipse(t,n,r,o,s,c,h,a){return this.currentCurve.ellipse(t,n,r,o,s,c,h,a),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,s){return this.currentCurve.roundRect(t,n,r,o,s),this}reset(){return this.currentCurve=new lt,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.getFlatCurves(),r=[],o=[],s=[];n.forEach((h,a)=>{const l=h.getControlPointRefs(),f=h.isClockwise();s[a]=l,o[a]=f;const y=l[0],x=l[l.length-1]??y;r.push({start:f?x:y,end:f?y:x,index:a})});const c=[];return r.forEach((h,a)=>{c[a]=[],r.forEach((l,f)=>{var y;l.start&&h.end&&f!==a&&((y=l.start)!=null&&y.equals(h.end))&&c[a].push(l.index)})}),n.forEach((h,a)=>{const l=o[a];s[a].forEach(f=>{f.add(h.getNormal(h.getTForPoint(f)).scale(l?t:-t))})}),c.forEach((h,a)=>{const l=s[a];h.forEach(f=>{const y=s[f],x=yn(l[l.length-1],l[l.length-2]??l[l.length-1],y[0],y[1]??y[0]);x&&(l[l.length-1].copy(x),y[0].copy(x))})}),this}getMinMax(t=d.MAX,n=d.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,n),r&&o>1){const c=o/2,h=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const f=s.getPoint(l),y=s.getNormal(l),x=y.clone().scale(h?c:-c),u=y.clone().scale(h?-c:c);a.push(f.clone().add(x),f.clone().add(u),f.clone().add({x:c,y:0}),f.clone().add({x:-c,y:0}),f.clone().add({x:0,y:c}),f.clone().add({x:0,y:-c}),f.clone().add({x:c,y:c}),f.clone().add({x:-c,y:-c}))}t.min(...a),n.max(...a)}}),{min:t.finite(),max:n.finite()}}strokeTriangulate(t){const n=(t==null?void 0:t.indices)??[],r=(t==null?void 0:t.vertices)??[];return this.curves.forEach(o=>{o.strokeTriangulate({...t,indices:n,vertices:r,style:{...this.style}})}),{indices:n,vertices:r}}fillTriangulate(t){const n={...t,style:{...this.style,...t==null?void 0:t.style}},r=n.indices??[],o=n.vertices??[];if((n.style.fillRule??"nonzero")==="nonzero"){const c=this.curves.map(l=>l.getFillVertices(n)),h=new Map,a=new Set;for(let l=0;l<c.length;l++){const f=[];for(let y=0;y<c.length;y++)l!==y&&Yt([c[l][0],c[l][1]],c[y])&&f.push(y);f.length&&(f.forEach(y=>{let x=h.get(y);x||(x=new Set,h.set(y,x)),x.add(l)}),a.add(l))}c.forEach((l,f)=>{var u;if(a.has(f)||!l.length)return;const y=l.slice(),x=[];(u=h.get(f))==null||u.forEach(g=>{x.push(y.length/2),y.push(...c[g])}),Ft(y,{...t,indices:r,vertices:o,holes:x,style:{...this.style}})})}else this.curves.forEach(c=>{c.fillTriangulate({...t,indices:r,vertices:o,style:{...this.style}})});return{indices:r,vertices:o}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new U(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),bt(t,n),this.curves.forEach(s=>{s.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),bt(t,n),this.getControlPointRefs().forEach(s=>{O(t,s.x,s.y,{radius:4})}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSVGPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},n={};for(const o in t)t[o]!==void 0&&(n[fn(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class ue{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=d.MAX,n=d.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new U(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSVGString(e=this.paths.map(n=>n.fillTriangulate()),t=0){let n="";const r={x:-t,y:-t},o={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:h,indices:a})=>{const l=f=>{const y=h[f*2],x=h[f*2+1];return r.x=Math.min(r.x,y+t),o.x=Math.max(o.x,y+t),r.y=Math.min(r.y,x+t),o.y=Math.max(o.y,x+t),[y,x]};for(let f=0,y=a.length;f<y;f+=3){const x=l(a[f]),u=l(a[f+1]),g=l(a[f+2]);n+=`<polygon points="${x.join(",")} ${u.join(",")} ${g.join(",")}" fill="black" />`}});const c=[r.x,r.y,o.x-r.x,o.y-r.y];return`<svg width="${c[2]}" height="${c[3]}" viewBox="${c.join(" ")}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}toTriangulatedSVG(e,t){return new DOMParser().parseFromString(this.toTriangulatedSVGString(e,t),"image/svg+xml").documentElement}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${n} ${r}" width="${n}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:o,width:s,height:c}=this.getBoundingBox(),h=document.createElement("canvas");h.width=s*t,h.height=c*t,h.style.width=`${s}px`,h.style.height=`${c}px`;const a=h.getContext("2d");return a&&(a.scale(t,t),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,n)})),h}}class xn{constructor(e,t,n=1,r=1){X(this,"controlPoints",[]);this.rows=e,this.cols=t,this.width=n,this.height=r;for(let o=0;o<e;o++){this.controlPoints[o]=[];for(let s=0;s<t;s++)this.controlPoints[o][s]={x:s/(t-1)*n,y:o/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}}function fe(i){const e=[];return e[0]=(1-i)**3/6,e[1]=(3*i**3-6*i**2+4)/6,e[2]=(-3*i**3+3*i**2+3*i+1)/6,e[3]=i**3/6,e}function gn(i,e,t=e.width,n=e.height){const r=i.x/t*(e.cols-1),o=i.y/n*(e.rows-1),s=Math.floor(r),c=Math.floor(o),h=r-s,a=o-c,l=fe(h),f=fe(a);let y=0,x=0;for(let u=0;u<4;u++)for(let g=0;g<4;g++){const m=Math.min(Math.max(c-1+u,0),e.rows-1),v=Math.min(Math.max(s-1+g,0),e.cols-1),k=e.controlPoints[m][v],w=l[g]*f[u];y+=k.x*w,x+=k.y*w}i.set(y,x)}const ye="data:image/svg+xml;",xe=`${ye}base64,`,ge=`${ye}charset=utf8,`;function pe(i){if(typeof i=="string"){let e;i.startsWith(xe)?(i=i.substring(xe.length,i.length),e=atob(i)):i.startsWith(ge)?(i=i.substring(ge.length,i.length),e=decodeURIComponent(i)):e=i;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
2
- ${e}`);return t.documentElement}else return i}const pn="px",dn=90,de=["mm","cm","in","pt","pc","px"],me={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 $(i){let e="px";if(typeof i=="string"||i instanceof String)for(let n=0,r=de.length;n<r;n++){const o=de[n];if(i.endsWith(o)){e=o,i=i.substring(0,i.length-o.length);break}}let t;return t=me[e][pn],t<0&&(t=me[e].in*dn),t*Number.parseFloat(i)}const mn=new R,Pt=new R,Me=new R,we=new R;function Mn(i,e,t){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=wn(i);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function wn(i){const e=new R,t=mn;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&e.translate($(i.getAttribute("x")),$(i.getAttribute("y"))),i.hasAttribute("transform")){const n=i.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const s=o.indexOf("("),c=o.length;if(s>0&&s<c){const h=o.slice(0,s),a=z(o.slice(s+1));switch(t.identity(),h){case"translate":if(a.length>=1){const l=a[0];let f=0;a.length>=2&&(f=a[1]),t.translate(l,f)}break;case"rotate":if(a.length>=1){let l=0,f=0,y=0;l=a[0]*Math.PI/180,a.length>=3&&(f=a[1],y=a[2]),Pt.makeTranslation(-f,-y),Me.makeRotation(l),we.multiplyMatrices(Me,Pt),Pt.makeTranslation(f,y),t.multiplyMatrices(Pt,we)}break;case"scale":a.length>=1&&t.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&t.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&t.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&t.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}e.premultiply(t)}}return e}function Pn(i){return new j().arc($(i.getAttribute("cx")||0),$(i.getAttribute("cy")||0),$(i.getAttribute("r")||0),0,Math.PI*2)}function vn(i,e){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let t=0;t<i.sheet.cssRules.length;t++){const n=i.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,c=0;c<s;c++){const h=n.style.item(c);o[h]=n.style.getPropertyValue(h)}for(let s=0;s<r.length;s++)e[r[s]]=Object.assign(e[r[s]]||{},{...o})}}function Tn(i){return new j().ellipse($(i.getAttribute("cx")||0),$(i.getAttribute("cy")||0),$(i.getAttribute("rx")||0),$(i.getAttribute("ry")||0),0,0,Math.PI*2)}function Cn(i){return new j().moveTo($(i.getAttribute("x1")||0),$(i.getAttribute("y1")||0)).lineTo($(i.getAttribute("x2")||0),$(i.getAttribute("y2")||0))}function bn(i){const e=new j,t=i.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const An=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function kn(i){var n;const e=new j;let t=0;return(n=i.getAttribute("points"))==null||n.replace(An,(r,o,s)=>{const c=$(o),h=$(s);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,r}),e.currentCurve.autoClose=!0,e}const In=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Sn(i){var n;const e=new j;let t=0;return(n=i.getAttribute("points"))==null||n.replace(In,(r,o,s)=>{const c=$(o),h=$(s);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,r}),e.currentCurve.autoClose=!1,e}function En(i){const e=$(i.getAttribute("x")||0),t=$(i.getAttribute("y")||0),n=$(i.getAttribute("rx")||i.getAttribute("ry")||0),r=$(i.getAttribute("ry")||i.getAttribute("rx")||0),o=$(i.getAttribute("width")),s=$(i.getAttribute("height")),c=1-.551915024494,h=new j;return h.moveTo(e+n,t),h.lineTo(e+o-n,t),(n!==0||r!==0)&&h.bezierCurveTo(e+o-n*c,t,e+o,t+r*c,e+o,t+r),h.lineTo(e+o,t+s-r),(n!==0||r!==0)&&h.bezierCurveTo(e+o,t+s-r*c,e+o-n*c,t+s,e+o-n,t+s),h.lineTo(e+n,t+s),(n!==0||r!==0)&&h.bezierCurveTo(e+n*c,t+s,e,t+s-r*c,e,t+s-r),h.lineTo(e,t+r),(n!==0||r!==0)&&h.bezierCurveTo(e,t+r*c,e+n*c,t,e+n,t),h}function G(i,e,t){e=Object.assign({},e);let n={};if(i.hasAttribute("class")){const a=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)n=Object.assign(n,t[`.${a[l]}`])}i.hasAttribute("id")&&(n=Object.assign(n,t[`#${i.getAttribute("id")}`]));for(let a=i.style.length,l=0;l<a;l++){const f=i.style.item(l),y=i.style.getPropertyValue(f);e[f]=y,n[f]=y}function r(a,l,f=o){i.hasAttribute(a)&&(e[l]=f(i.getAttribute(a))),n[a]&&(e[l]=f(n[a]))}function o(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function s(a){return Math.max(0,Math.min(1,$(a)))}function c(a){return Math.max(0,$(a))}function h(a){return a.split(" ").filter(l=>l!=="").map(l=>$(l))}return r("fill","fill"),r("fill-opacity","fillOpacity",s),r("fill-rule","fillRule"),r("opacity","opacity",s),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",s),r("stroke-width","strokeWidth",c),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",c),r("stroke-dasharray","strokeDasharray",h),r("stroke-dashoffset","strokeDashoffset",$),r("visibility","visibility"),e}function Ot(i,e,t=[],n={}){var f;if(i.nodeType!==1)return t;let r=!1,o=null,s={...e};switch(i.nodeName){case"svg":s=G(i,s,n);break;case"style":vn(i,n);break;case"g":s=G(i,s,n);break;case"path":s=G(i,s,n),i.hasAttribute("d")&&(o=bn(i));break;case"rect":s=G(i,s,n),o=En(i);break;case"polygon":s=G(i,s,n),o=kn(i);break;case"polyline":s=G(i,s,n),o=Sn(i);break;case"circle":s=G(i,s,n),o=Pn(i);break;case"ellipse":s=G(i,s,n),o=Tn(i);break;case"line":s=G(i,s,n),o=Cn(i);break;case"defs":r=!0;break;case"use":{s=G(i,s,n);const x=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),u=(f=i.viewportElement)==null?void 0:f.getElementById(x);u?Ot(u,s,t,n):console.warn(`'use node' references non-existent node id: ${x}`);break}default:console.warn(i);break}if(s.display==="none")return t;const c=new R,h=[],a=Mn(i,c,h);o&&(o.applyTransform(c),t.push(o),o.style={...s});const l=i.childNodes;for(let y=0,x=l.length;y<x;y++){const u=l[y];r&&u.nodeName!=="style"&&u.nodeName!=="defs"||Ot(u,s,t,n)}return a&&(h.pop(),h.length>0?c.copy(h[h.length-1]):c.identity()),t}function $n(i){var t;const e=pe(i);return new ue(Ot(e,{}),(t=e.getAttribute("viewBox"))==null?void 0:t.trim().split(" ").map(n=>Number(n)))}T.ArcCurve=oe,T.BoundingBox=U,T.CompositeCurve=rt,T.CubicBezierCurve=Mt,T.Curve=Y,T.CurvePath=lt,T.EllipseCurve=ce,T.EquilateralPloygonCurve=un,T.FFDControlGrid=xn,T.LineCurve=Z,T.Matrix3=R,T.Path2D=j,T.Path2DSet=ue,T.PloygonCurve=qt,T.QuadraticBezierCurve=wt,T.RectangleCurve=he,T.RoundRectangleCurve=ae,T.SplineCurve=le,T.Vector2=d,T.applyFFD=gn,T.catmullRom=St,T.cubicBezier=Et,T.drawPoint=O,T.fillTriangulate=Ft,T.getAdaptiveCubicBezierCurvePoints=Ht,T.getAdaptiveQuadraticBezierCurvePoints=Qt,T.getDirectedArea=Ke,T.parseArcCommand=Zt,T.parsePathDataArgs=z,T.pointInPolygon=Yt,T.quadraticBezier=Vt,T.setCanvasContext=bt,T.strokeTriangulate=Kt,T.svgPathCommandsAddToPath2D=kt,T.svgPathCommandsToData=jt,T.svgPathDataToCommands=It,T.svgToDOM=pe,T.svgToPath2DSet=$n,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
1
+ (function(T,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(T=typeof globalThis<"u"?globalThis:T||self,O(T.modernPath2d={}))})(this,function(T){"use strict";var Nn=Object.defineProperty;var Vn=(T,O,nt)=>O in T?Nn(T,O,{enumerable:!0,configurable:!0,writable:!0,value:nt}):T[O]=nt;var U=(T,O,nt)=>Vn(T,typeof O!="symbol"?O+"":O,nt);function O(i,e,t,n={}){const{radius:r=1}=n;i.moveTo(e,t),i.arc(e,t,r,0,Math.PI*2)}const nt={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function At(i,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:c=0,strokeDasharray:h=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:x="rgba(0, 0, 0, 0)"}=e;i.fillStyle=t,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=nt[s],i.miterLimit=c,i.setLineDash(h),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=y,i.shadowBlur=f,i.shadowColor=x}class m{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new m(1/0,1/0)}static get MIN(){return new m(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,o=-(this.y-t.y),s=Math.sin(n),c=Math.cos(n);return this.set(t.x+(r*c-o*s),t.y-(r*s+o*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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}){const r=e<0?n.x-this.x+n.x:this.x,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(e)*o),this.y=n.y+(o+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new m(this.x,this.y)}}class X{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}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 m((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new X;if(e.length===1)return e[0].clone();const t=e[0],n=e.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new X(n.left,n.top,n.right-n.left,n.bottom-n.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 X(this.left,this.top,this.width,this.height)}}class z{constructor(e=1,t=0,n=0,r=0,o=1,s=0,c=0,h=0,a=1){U(this,"elements",[]);this.set(e,t,n,r,o,s,c,h,a)}set(e,t,n,r,o,s,c,h,a){const l=this.elements;return l[0]=e,l[1]=r,l[2]=c,l[3]=t,l[4]=o,l[5]=h,l[6]=n,l[7]=s,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,s=n[0],c=n[3],h=n[6],a=n[1],l=n[4],y=n[7],f=n[2],x=n[5],u=n[8],p=r[0],d=r[3],v=r[6],A=r[1],w=r[4],P=r[7],b=r[2],S=r[5],g=r[8];return o[0]=s*p+c*A+h*b,o[3]=s*d+c*w+h*S,o[6]=s*v+c*P+h*g,o[1]=a*p+l*A+y*b,o[4]=a*d+l*w+y*S,o[7]=a*v+l*P+y*g,o[2]=f*p+x*A+u*b,o[5]=f*d+x*w+u*S,o[8]=f*v+x*P+u*g,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],s=e[4],c=e[5],h=e[6],a=e[7],l=e[8],y=l*s-c*a,f=c*h-l*o,x=a*o-s*h,u=t*y+n*f+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/u;return e[0]=y*p,e[1]=(r*a-l*n)*p,e[2]=(c*n-r*s)*p,e[3]=f*p,e[4]=(l*t-r*h)*p,e[5]=(r*o-c*t)*p,e[6]=x*p,e[7]=(n*h-a*t)*p,e[8]=(s*t-n*o)*p,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(kt.makeScale(e,t)),this}rotate(e){return this.premultiply(kt.makeRotation(-e)),this}translate(e,t){return this.premultiply(kt.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const kt=new z;function Zt(i,e,t,n){const r=i*t+e*n,o=Math.sqrt(i*i+e*e)*Math.sqrt(t*t+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-e*t<0&&(s=-s),s}function jt(i,e,t,n,r,o,s,c){if(e===0||t===0){i.lineTo(c.x,c.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const h=(s.x-c.x)/2,a=(s.y-c.y)/2,l=Math.cos(n)*h+Math.sin(n)*a,y=-Math.sin(n)*h+Math.cos(n)*a;let f=e*e,x=t*t;const u=l*l,p=y*y,d=u/f+p/x;if(d>1){const L=Math.sqrt(d);e=L*e,t=L*t,f=e*e,x=t*t}const v=f*p+x*u,A=(f*x-v)/v;let w=Math.sqrt(Math.max(0,A));r===o&&(w=-w);const P=w*e*y/t,b=-w*t*l/e,S=Math.cos(n)*P-Math.sin(n)*b+(s.x+c.x)/2,g=Math.sin(n)*P+Math.cos(n)*b+(s.y+c.y)/2,M=Zt(1,0,(l-P)/e,(y-b)/t),q=Zt((l-P)/e,(y-b)/t,(-l-P)/e,(-y-b)/t)%(Math.PI*2);i.ellipse(S,g,e,t,n,M,M+q,o===0)}const D={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Z(i,e,t=0){let c=0,h=!0,a="",l="";const y=[];function f(d,v,A){const w=new SyntaxError(`Unexpected character "${d}" at index ${v}.`);throw w.partial=A,w}function x(){a!==""&&(l===""?y.push(Number(a)):y.push(Number(a)*10**Number(l))),a="",l=""}let u;const p=i.length;for(let d=0;d<p;d++){if(u=i[d],Array.isArray(e)&&e.includes(y.length%t)&&D.FLAGS.test(u)){c=1,a=u,x();continue}if(c===0){if(D.WHITESPACE.test(u))continue;if(D.DIGIT.test(u)||D.SIGN.test(u)){c=1,a=u;continue}if(D.POINT.test(u)){c=2,a=u;continue}D.COMMA.test(u)&&(h&&f(u,d,y),h=!0)}if(c===1){if(D.DIGIT.test(u)){a+=u;continue}if(D.POINT.test(u)){a+=u,c=2;continue}if(D.EXP.test(u)){c=3;continue}D.SIGN.test(u)&&a.length===1&&D.SIGN.test(a[0])&&f(u,d,y)}if(c===2){if(D.DIGIT.test(u)){a+=u;continue}if(D.EXP.test(u)){c=3;continue}D.POINT.test(u)&&a[a.length-1]==="."&&f(u,d,y)}if(c===3){if(D.DIGIT.test(u)){l+=u;continue}if(D.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&D.SIGN.test(l)&&f(u,d,y)}}D.WHITESPACE.test(u)?(x(),c=0,h=!1):D.COMMA.test(u)?(x(),c=0,h=!0):D.SIGN.test(u)?(x(),c=1,a=u):D.POINT.test(u)?(x(),c=2,a=u):f(u,d,y)}return x(),y}function st(i,e){return i-(e-i)}function It(i,e){const t=new m,n=new m;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?t.add(s):t.copy(s),e.moveTo(t.x,t.y),n.copy(t);else if(s.type==="h"||s.type==="H")s.type==="h"?t.x+=s.x:t.x=s.x,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="v"||s.type==="V")s.type==="v"?t.y+=s.y:t.y=s.y,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="l"||s.type==="L")s.type==="l"?t.add(s):t.copy(s),e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="c"||s.type==="C")s.type==="c"?(e.bezierCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(e.quadraticCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x,t.y+s.y),n.x=t.x+s.x1,n.y=t.y+s.y1,t.add(s)):(e.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,t.copy(s));else if(s.type==="t"||s.type==="T"){const c=st(t.x,n.x),h=st(t.y,n.y);n.x=c,n.y=h,s.type==="t"?(e.quadraticCurveTo(c,h,t.x+s.x,t.y+s.y),t.add(s)):(e.quadraticCurveTo(c,h,s.x,s.y),t.copy(s))}else if(s.type==="a"||s.type==="A"){const c=t.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;t.add(s)}else{if(t.equals(s))continue;t.copy(s)}n.copy(t),jt(e,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,c,t)}else s.type==="z"||s.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",s)}}function Bt(i){let e,t;const n=[];for(let r=0,o=i.length;r<o;r++){const s=i[r];switch(s.type){case"m":case"M":if(s.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&s.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y},e={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),t={x:s.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),t={x:(t==null?void 0:t.x)??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"c":case"C":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"a":case"A":n.push(`${s.type} ${s.rx} ${s.ry} ${s.angle} ${s.largeArcFlag} ${s.sweepFlag} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const Ae=/[a-df-z][^a-df-z]*/gi;function St(i){const e=[],t=i.match(Ae);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],s=o.charAt(0),c=o.slice(1).trim();let h;switch(s){case"m":case"M":h=Z(c);for(let a=0,l=h.length;a<l;a+=2)a===0?e.push({type:s,x:h[a],y:h[a+1]}):e.push({type:s==="m"?"l":"L",x:h[a],y:h[a+1]});break;case"h":case"H":h=Z(c);for(let a=0,l=h.length;a<l;a++)e.push({type:s,x:h[a]});break;case"v":case"V":h=Z(c);for(let a=0,l=h.length;a<l;a++)e.push({type:s,y:h[a]});break;case"l":case"L":h=Z(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:s,x:h[a],y:h[a+1]});break;case"c":case"C":h=Z(c);for(let a=0,l=h.length;a<l;a+=6)e.push({type:s,x1:h[a],y1:h[a+1],x2:h[a+2],y2:h[a+3],x:h[a+4],y:h[a+5]});break;case"s":case"S":h=Z(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:s,x2:h[a],y2:h[a+1],x:h[a+2],y:h[a+3]});break;case"q":case"Q":h=Z(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:s,x1:h[a],y1:h[a+1],x:h[a+2],y:h[a+3]});break;case"t":case"T":h=Z(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:s,x:h[a],y:h[a+1]});break;case"a":case"A":h=Z(c,[3,4],7);for(let a=0,l=h.length;a<l;a+=7)e.push({type:s,rx:h[a],ry:h[a+1],angle:h[a+2],largeArcFlag:h[a+3],sweepFlag:h[a+4],x:h[a+5],y:h[a+6]});break;case"z":case"Z":e.push({type:s});break;default:console.warn(o)}}return e}function Et(i,e,t,n,r){const o=(n-e)*.5,s=(r-t)*.5,c=i*i,h=i*c;return(2*t-2*n+o+s)*h+(-3*t+3*n-2*o-s)*c+o*i+t}function ke(i,e){const t=1-i;return t*t*t*e}function Ie(i,e){const t=1-i;return 3*t*t*i*e}function Se(i,e){return 3*(1-i)*i*i*e}function Ee(i,e){return i*i*i*e}function _t(i,e,t,n,r){return ke(i,e)+Ie(i,t)+Se(i,n)+Ee(i,r)}function _e(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Gt(i,0,r,t,!0);const s=[];if(!o||o.next===o.prev)return s;let c,h,a;if(n&&(o=Ve(i,e,o,t)),i.length>80*t){c=1/0,h=1/0;let l=-1/0,y=-1/0;for(let f=t;f<r;f+=t){const x=i[f],u=i[f+1];x<c&&(c=x),u<h&&(h=u),x>l&&(l=x),u>y&&(y=u)}a=Math.max(l-c,y-h),a=a!==0?32767/a:0}return ot(o,s,t,c,h,a,0),s}function Gt(i,e,t,n,r){let o;if(r===Xe(i,e,t,n)>0)for(let s=e;s<t;s+=n)o=Ht(s/n|0,i[s],i[s+1],o);else for(let s=t-n;s>=e;s-=n)o=Ht(s/n|0,i[s],i[s+1],o);return o&&it(o,o.next)&&(at(o),o=o.next),o}function H(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(it(t,t.next)||F(t.prev,t,t.next)===0)){if(at(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ot(i,e,t,n,r,o,s){if(!i)return;!s&&o&&ze(i,n,r,o);let c=i;for(;i.prev!==i.next;){const h=i.prev,a=i.next;if(o?Le(i,n,r,o):$e(i)){e.push(h.i,i.i,a.i),at(i),i=a.next,c=a.next;continue}if(i=a,i===c){s?s===1?(i=Fe(H(i),e),ot(i,e,t,n,r,o,2)):s===2&&Ne(i,e,t,n,r,o):ot(H(i),e,t,n,r,o,1);break}}}function $e(i){const e=i.prev,t=i,n=i.next;if(F(e,t,n)>=0)return!1;const r=e.x,o=t.x,s=n.x,c=e.y,h=t.y,a=n.y,l=Math.min(r,o,s),y=Math.min(c,h,a),f=Math.max(r,o,s),x=Math.max(c,h,a);let u=n.next;for(;u!==e;){if(u.x>=l&&u.x<=f&&u.y>=y&&u.y<=x&&ct(r,c,o,h,s,a,u.x,u.y)&&F(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function Le(i,e,t,n){const r=i.prev,o=i,s=i.next;if(F(r,o,s)>=0)return!1;const c=r.x,h=o.x,a=s.x,l=r.y,y=o.y,f=s.y,x=Math.min(c,h,a),u=Math.min(l,y,f),p=Math.max(c,h,a),d=Math.max(l,y,f),v=$t(x,u,e,t,n),A=$t(p,d,e,t,n);let w=i.prevZ,P=i.nextZ;for(;w&&w.z>=v&&P&&P.z<=A;){if(w.x>=x&&w.x<=p&&w.y>=u&&w.y<=d&&w!==r&&w!==s&&ct(c,l,h,y,a,f,w.x,w.y)&&F(w.prev,w,w.next)>=0||(w=w.prevZ,P.x>=x&&P.x<=p&&P.y>=u&&P.y<=d&&P!==r&&P!==s&&ct(c,l,h,y,a,f,P.x,P.y)&&F(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;w&&w.z>=v;){if(w.x>=x&&w.x<=p&&w.y>=u&&w.y<=d&&w!==r&&w!==s&&ct(c,l,h,y,a,f,w.x,w.y)&&F(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;P&&P.z<=A;){if(P.x>=x&&P.x<=p&&P.y>=u&&P.y<=d&&P!==r&&P!==s&&ct(c,l,h,y,a,f,P.x,P.y)&&F(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function Fe(i,e){let t=i;do{const n=t.prev,r=t.next.next;!it(n,r)&&Xt(n,t,t.next,r)&&ht(n,r)&&ht(r,n)&&(e.push(n.i,t.i,r.i),at(t),at(t.next),t=i=r),t=t.next}while(t!==i);return H(t)}function Ne(i,e,t,n,r,o){let s=i;do{let c=s.next.next;for(;c!==s.prev;){if(s.i!==c.i&&Be(s,c)){let h=Wt(s,c);s=H(s,s.next),h=H(h,h.next),ot(s,e,t,n,r,o,0),ot(h,e,t,n,r,o,0);return}c=c.next}s=s.next}while(s!==i)}function Ve(i,e,t,n){const r=[];for(let o=0,s=e.length;o<s;o++){const c=e[o]*n,h=o<s-1?e[o+1]*n:i.length,a=Gt(i,c,h,n,!1);a===a.next&&(a.steiner=!0),r.push(je(a))}r.sort(De);for(let o=0;o<r.length;o++)t=qe(r[o],t);return t}function De(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function qe(i,e){const t=Oe(i,e);if(!t)return e;const n=Wt(t,i);return H(n,n.next),H(t,t.next)}function Oe(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,s;if(it(i,t))return t;do{if(it(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const y=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(y<=n&&y>o&&(o=y,s=t.x<t.next.x?t:t.next,y===n))return s}t=t.next}while(t!==e);if(!s)return null;const c=s,h=s.x,a=s.y;let l=1/0;t=s;do{if(n>=t.x&&t.x>=h&&n!==t.x&&Ut(r<a?n:o,r,h,a,r<a?o:n,r,t.x,t.y)){const y=Math.abs(r-t.y)/(n-t.x);ht(t,i)&&(y<l||y===l&&(t.x>s.x||t.x===s.x&&Re(s,t)))&&(s=t,l=y)}t=t.next}while(t!==c);return s}function Re(i,e){return F(i.prev,i,e.prev)<0&&F(e.next,i,i.next)<0}function ze(i,e,t,n){let r=i;do r.z===0&&(r.z=$t(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Ze(r)}function Ze(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let s=n,c=0;for(let a=0;a<t&&(c++,s=s.nextZ,!!s);a++);let h=t;for(;c>0||h>0&&s;)c!==0&&(h===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,c--):(r=s,s=s.nextZ,h--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,t*=2}while(e>1);return i}function $t(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function je(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Ut(i,e,t,n,r,o,s,c){return(r-s)*(e-c)>=(i-s)*(o-c)&&(i-s)*(n-c)>=(t-s)*(e-c)&&(t-s)*(o-c)>=(r-s)*(n-c)}function ct(i,e,t,n,r,o,s,c){return!(i===s&&e===c)&&Ut(i,e,t,n,r,o,s,c)}function Be(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Ge(i,e)&&(ht(i,e)&&ht(e,i)&&Ue(i,e)&&(F(i.prev,i,e.prev)||F(i,e.prev,e))||it(i,e)&&F(i.prev,i,i.next)>0&&F(e.prev,e,e.next)>0)}function F(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function it(i,e){return i.x===e.x&&i.y===e.y}function Xt(i,e,t,n){const r=dt(F(i,e,t)),o=dt(F(i,e,n)),s=dt(F(t,n,i)),c=dt(F(t,n,e));return!!(r!==o&&s!==c||r===0&&gt(i,t,e)||o===0&&gt(i,n,e)||s===0&&gt(t,i,n)||c===0&&gt(t,e,n))}function gt(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function dt(i){return i>0?1:i<0?-1:0}function Ge(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Xt(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ht(i,e){return F(i.prev,i,i.next)<0?F(i,e,i.next)>=0&&F(i,i.prev,e)>=0:F(i,e,i.prev)<0||F(i,i.next,e)<0}function Ue(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Wt(i,e){const t=Lt(i.i,i.x,i.y),n=Lt(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Ht(i,e,t,n){const r=Lt(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function at(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Lt(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Xe(i,e,t,n){let r=0;for(let o=e,s=t-n;o<t;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Ft(i,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=t.length/o,indicesOffset:c=n.length}=e;const h=_e(i,r,2);if(h.length){for(let l=0;l<h.length;l+=3)n[c++]=h[l]+s,n[c++]=h[l+1]+s,n[c++]=h[l+2]+s;let a=s*o;for(let l=0;l<i.length;l+=2)t[a]=i[l],t[a+1]=i[l+1],a+=o}return{vertices:t,indices:n}}const We=8,mt=11920929e-14,He=1;function Qt(i,e,t,n,r,o,s,c,h=.5,a=[]){const y=Math.min(.99,Math.max(0,h));let f=(He-y)/1;return f*=f,Nt(i,e,t,n,r,o,s,c,a,f,0),a.push(s,c),a}function Nt(i,e,t,n,r,o,s,c,h,a,l){if(l>We)return;const y=(i+t)/2,f=(e+n)/2,x=(t+r)/2,u=(n+o)/2,p=(r+s)/2,d=(o+c)/2,v=(y+x)/2,A=(f+u)/2,w=(x+p)/2,P=(u+d)/2,b=(v+w)/2,S=(A+P)/2;if(l>0){let g=s-i,M=c-e;const q=Math.abs((t-s)*M-(n-c)*g),L=Math.abs((r-s)*M-(o-c)*g);if(q>mt&&L>mt){if((q+L)*(q+L)<=a*(g*g+M*M)){h.push(b,S);return}}else if(q>mt){if(q*q<=a*(g*g+M*M)){h.push(b,S);return}}else if(L>mt){if(L*L<=a*(g*g+M*M)){h.push(b,S);return}}else if(g=b-(i+s)/2,M=S-(e+c)/2,g*g+M*M<=a){h.push(b,S);return}}Nt(i,e,y,f,v,A,b,S,h,a,l+1),Nt(b,S,w,P,p,d,s,c,h,a,l+1)}const Qe=8,Ye=11920929e-14,Je=1;function Yt(i,e,t,n,r,o,s=.5,c=[]){const a=Math.min(.99,Math.max(0,s));let l=(Je-a)/1;return l*=l,Vt(c,i,e,t,n,r,o,l,0),c.push(r,o),c}function Vt(i,e,t,n,r,o,s,c,h){if(h>Qe)return;const a=(e+n)/2,l=(t+r)/2,y=(n+o)/2,f=(r+s)/2,x=(a+y)/2,u=(l+f)/2;let p=o-e,d=s-t;const v=Math.abs((n-o)*d-(r-s)*p);if(v>Ye){if(v*v<=c*(p*p+d*d)){i.push(x,u);return}}else if(p=x-(e+o)/2,d=u-(t+s)/2,p*p+d*d<=c){i.push(x,u);return}Vt(i,e,t,a,l,x,u,c,h+1),Vt(i,x,u,y,f,o,s,c,h+1)}function Ke(i){let e=0;const t=i.length;for(let n=0;n<t;n+=2){const r=i[n],o=i[n+1],s=i[(n+2)%(t-1)],c=i[(n+3)%t];e+=r*c-s*o}return e/2}function Jt(i,e){let t=!1;const[n,r]=i,o=e.length/2;for(let s=0,c=o-1;s<o;c=s++){const h=e[s*2],a=e[s*2+1],l=e[c*2],y=e[c*2+1];a>r!=y>r&&n<(l-h)*(r-a)/(y-a)+h&&(t=!t)}return t}function tn(i,e){const t=1-i;return t*t*e}function en(i,e){return 2*(1-i)*i*e}function nn(i,e){return i*i*e}function Dt(i,e,t,n){return tn(i,e)+en(i,t)+nn(i,n)}const sn=1e-4,Kt=1e-4;function te(i,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=e,c=sn;if(i.length===0)return{vertices:t,indices:n};const h=r;let a=h.alignment;if(r.alignment!==.5){let $=rn(i);o&&($*=-1),a=(a-.5)*$+.5}const l={x:i[0],y:i[1]},y={x:i[i.length-2],y:i[i.length-1]},f=s,x=Math.abs(l.x-y.x)<c&&Math.abs(l.y-y.y)<c;if(f){i=i.slice(),x&&(i.pop(),i.pop(),y.x=i[i.length-2],y.y=i[i.length-1]);const $=(l.x+y.x)*.5,W=(y.y+l.y)*.5;i.unshift($,W),i.push($,W)}const u=t,p=i.length/2;let d=i.length;const v=u.length/2,A=h.width/2,w=A*A,P=h.miterLimit*h.miterLimit;let b=i[0],S=i[1],g=i[2],M=i[3],q=0,L=0,k=-(S-M),I=b-g,N=0,V=0,R=Math.sqrt(k*k+I*I);k/=R,I/=R,k*=A,I*=A;const ut=a,C=(1-ut)*2,E=ut*2;f||(h.cap==="round"?d+=Q(b-k*(C-E)*.5,S-I*(C-E)*.5,b-k*C,S-I*C,b+k*E,S+I*E,u,!0)+2:h.cap==="square"&&(d+=ee(b,S,k,I,C,E,!0,u))),u.push(b-k*C,S-I*C),u.push(b+k*E,S+I*E);for(let $=1;$<p-1;++$){b=i[($-1)*2],S=i[($-1)*2+1],g=i[$*2],M=i[$*2+1],q=i[($+1)*2],L=i[($+1)*2+1],k=-(S-M),I=b-g,R=Math.sqrt(k*k+I*I),k/=R,I/=R,k*=A,I*=A,N=-(M-L),V=g-q,R=Math.sqrt(N*N+V*V),N/=R,V/=R,N*=A,V*=A;const W=g-b,ft=S-M,yt=g-q,xt=L-M,ve=W*yt+ft*xt,Tt=ft*yt-xt*W,pt=Tt<0;if(Math.abs(Tt)<.001*Math.abs(ve)){u.push(g-k*C,M-I*C),u.push(g+k*E,M+I*E),ve>=0&&(h.join==="round"?d+=Q(g,M,g-k*C,M-I*C,g-N*C,M-V*C,u,!1)+4:d+=2,u.push(g-N*E,M-V*E),u.push(g+N*C,M+V*C));continue}const Te=(-k+b)*(-I+M)-(-k+g)*(-I+S),Ce=(-N+q)*(-V+M)-(-N+g)*(-V+L),Ct=(W*Ce-yt*Te)/Tt,bt=(xt*Te-ft*Ce)/Tt,zt=(Ct-g)*(Ct-g)+(bt-M)*(bt-M),J=g+(Ct-g)*C,K=M+(bt-M)*C,tt=g-(Ct-g)*E,et=M-(bt-M)*E,Ln=Math.min(W*W+ft*ft,yt*yt+xt*xt),be=pt?C:E,Fn=Ln+be*be*w;zt<=Fn?h.join==="bevel"||zt/w>P?(pt?(u.push(J,K),u.push(g+k*E,M+I*E),u.push(J,K),u.push(g+N*E,M+V*E)):(u.push(g-k*C,M-I*C),u.push(tt,et),u.push(g-N*C,M-V*C),u.push(tt,et)),d+=2):h.join==="round"?pt?(u.push(J,K),u.push(g+k*E,M+I*E),d+=Q(g,M,g+k*E,M+I*E,g+N*E,M+V*E,u,!0)+4,u.push(J,K),u.push(g+N*E,M+V*E)):(u.push(g-k*C,M-I*C),u.push(tt,et),d+=Q(g,M,g-k*C,M-I*C,g-N*C,M-V*C,u,!1)+4,u.push(g-N*C,M-V*C),u.push(tt,et)):(u.push(J,K),u.push(tt,et)):(u.push(g-k*C,M-I*C),u.push(g+k*E,M+I*E),h.join==="round"?pt?d+=Q(g,M,g+k*E,M+I*E,g+N*E,M+V*E,u,!0)+2:d+=Q(g,M,g-k*C,M-I*C,g-N*C,M-V*C,u,!1)+2:h.join==="miter"&&zt/w<=P&&(pt?(u.push(tt,et),u.push(tt,et)):(u.push(J,K),u.push(J,K)),d+=2),u.push(g-N*C,M-V*C),u.push(g+N*E,M+V*E),d+=2)}b=i[(p-2)*2],S=i[(p-2)*2+1],g=i[(p-1)*2],M=i[(p-1)*2+1],k=-(S-M),I=b-g,R=Math.sqrt(k*k+I*I),k/=R,I/=R,k*=A,I*=A,u.push(g-k*C,M-I*C),u.push(g+k*E,M+I*E),f||(h.cap==="round"?d+=Q(g-k*(C-E)*.5,M-I*(C-E)*.5,g-k*C,M-I*C,g+k*E,M+I*E,u,!1)+2:h.cap==="square"&&(d+=ee(g,M,k,I,C,E,!1,u)));const $n=Kt*Kt;for(let $=v;$<d+v-2;++$)b=u[$*2],S=u[$*2+1],g=u[($+1)*2],M=u[($+1)*2+1],q=u[($+2)*2],L=u[($+2)*2+1],!(Math.abs(b*(M-L)+g*(L-S)+q*(S-M))<$n)&&n.push($,$+1,$+2);return{vertices:t,indices:n}}function rn(i){const e=i.length;if(e<6)return 1;let t=0;for(let n=0,r=i[e-2],o=i[e-1];n<e;n+=2){const s=i[n],c=i[n+1];t+=(s-r)*(c+o),r=s,o=c}return t<0?-1:1}function ee(i,e,t,n,r,o,s,c){const h=i-t*r,a=e-n*r,l=i+t*o,y=e+n*o;let f,x;s?(f=n,x=-t):(f=-n,x=t);const u=h+f,p=a+x,d=l+f,v=y+x;return c.push(u,p),c.push(d,v),2}function Q(i,e,t,n,r,o,s,c){const h=t-i,a=n-e;let l=Math.atan2(h,a),y=Math.atan2(r-i,o-e);c&&l<y?l+=Math.PI*2:!c&&l>y&&(y+=Math.PI*2);let f=l;const x=y-l,u=Math.abs(x),p=Math.sqrt(h*h+a*a),d=(15*u*Math.sqrt(p)/Math.PI>>0)+1,v=x/d;if(f+=v,c){s.push(i,e),s.push(t,n);for(let A=1,w=f;A<d;A++,w+=v)s.push(i,e),s.push(i+Math.sin(w)*p,e+Math.cos(w)*p);s.push(i,e),s.push(r,o)}else{s.push(t,n),s.push(i,e);for(let A=1,w=f;A<d;A++,w+=v)s.push(i+Math.sin(w)*p,e+Math.cos(w)*p),s.push(i,e);s.push(r,o),s.push(i,e)}return d*2}class Y{constructor(){U(this,"arcLengthDivision",200);U(this,"_arcLengths")}getPointAt(e,t=new m){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){const t=typeof e=="function";return this.getControlPointRefs().forEach(n=>{t?e(n):n.applyMatrix3(e)}),this}getUnevenVertices(e=5,t=[]){const n=new m;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){const n=new m;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,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){const o=e[n],s=e[n+1];t.push(new m(o,s))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenVertices(e):n=this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),o=1;o<=e;o++){const s=this.getPoint(o/e);n+=s.distanceTo(r),t.push(n),r=s}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/n[0];let s=0,c=0,h=r-1,a;for(;c<=h;)if(s=Math.floor(c+(h-c)/2),a=n[s]-o,a<0)c=s+1;else if(a>0)h=s-1;else{h=s;break}if(s=h,n[s]===o)return s/(r-1);const l=n[s],f=n[s+1]-l,x=(o-l)/f;return(s+x)/(r-1)}getTangent(e,t=new m){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new m){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,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(e)<t)return o;s.x<e.x?n=o:r=o}return o}getMinMax(e=m.MAX,t=m.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];e.min(s),t.max(s)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new X(e.x,e.y,t.x-e.x,t.y-e.y)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return Ft(this.getFillVertices(e),e)}strokeTriangulate(e){return te(this.getAdaptiveVertices(),e)}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return Bt(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}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const on=new z,ne=new z,se=new z,Mt=new m;class qt extends Y{constructor(e=new m,t=new m,n=new m,r=0,o=0,s=Math.PI*2,c=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=c}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}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const n=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new m){const n=this._getDeltaAngle(),r=this.startAngle+e*n;let o=this.cx+this.rx*Math.cos(r),s=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const c=Math.cos(this.rotate),h=Math.sin(this.rotate),a=o-this.cx,l=s-this.cy;o=a*c-l*h+this.cx,s=a*h+l*c+this.cy}return t.set(o,s)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:c,rotate:h}=this,a=e+n*Math.cos(o)*Math.cos(h)-r*Math.sin(o)*Math.sin(h),l=t+n*Math.cos(o)*Math.sin(h)+r*Math.sin(o)*Math.cos(h),y=Math.abs(o-s),f=y>Math.PI?1:0,x=c?1:0,u=h*180/Math.PI;if(y>=2*Math.PI){const p=o+Math.PI,d=e+n*Math.cos(p)*Math.cos(h)-r*Math.sin(p)*Math.sin(h),v=t+n*Math.cos(p)*Math.sin(h)+r*Math.sin(p)*Math.cos(h);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:d,y:v},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const p=e+n*Math.cos(s)*Math.cos(h)-r*Math.sin(s)*Math.sin(h),d=t+n*Math.cos(s)*Math.sin(h)+r*Math.sin(s)*Math.cos(h);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:f,sweepFlag:x,x:p,y:d}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:s,startAngle:c,endAngle:h,clockwise:a}=this;return e.ellipse(t,n,r,o,s,c,h,!a),this}applyTransform(e){return Mt.set(this.cx,this.cy),Mt.applyMatrix3(e),this.cx=Mt.x,this.cy=Mt.y,an(e)?cn(this,e):hn(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:c,startAngle:h,endAngle:a,clockwise:l,rotate:y}=this,f=!l;let x=Math.abs(h-a);(!f&&h>a||f&&a>h)&&(x=2*Math.PI-x);const u=Math.max(12,Math.floor(12*r**(1/3)*(x/Math.PI)));let p=x/u,d=h;p*=f?-1:1;const v=Math.cos(f?y:-y),A=Math.sin(f?y:-y);for(let w=0;w<u+1;w++){const P=s+Math.cos(d)*r,b=c+Math.sin(d)*o,S=P*v-b*A,g=P*A+b*v;e.push(t+S,n+g),d+=p}return e}_getAdaptiveVerticesByCircle(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:c,rotate:h,clockwise:a}=this;if(!(r>=0&&o>=0&&s>=0&&c>=0))return e;const l=Math.ceil(2.3*Math.sqrt(r+o)),y=l*8+(s?4:0)+(c?4:0),f=[];if(y===0)return e;{const p=f.length;if(l===0)f[p]=f[p+6]=t+s,f[p+1]=f[p+3]=n+c,f[p+2]=f[p+4]=t-s,f[p+5]=f[p+7]=n-c;else{let d=p,v=p+l*4+(s?2:0)+2,A=v,w=y,P=s+r,b=c,S=t+P,g=t-P,M=n+b;if(f[d++]=S,f[d++]=M,f[--v]=M,f[--v]=g,c){const L=n-b;f[A++]=g,f[A++]=L,f[--w]=L,f[--w]=S}for(let L=1;L<l;L++){const k=Math.PI/2*(L/l),I=s+Math.cos(k)*r,N=c+Math.sin(k)*o,V=t+I,R=t-I,ut=n+N,C=n-N;f[d++]=V,f[d++]=ut,f[--v]=ut,f[--v]=R,f[A++]=R,f[A++]=C,f[--w]=C,f[--w]=V}P=s,b=c+o,S=t+P,g=t-P,M=n+b;const q=n-b;f[d++]=S,f[d++]=M,f[--w]=q,f[--w]=S,s&&(f[d++]=g,f[d++]=M,f[--w]=q,f[--w]=g)}}const x=Math.cos(a?-h:h),u=Math.sin(a?-h:h);for(let p=0;p<f.length;p+=2){const d=f[p],v=f[p+1],A=d-t,w=v-n,P=A*x-w*u,b=A*u+w*x;e.push(t+P,n+b)}return e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}copy(e){return super.copy(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 cn(i,e){const t=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new m(t*r,t*o),c=new m(-n*o,n*r),h=s.applyMatrix3(e),a=c.applyMatrix3(e),l=on.set(h.x,a.x,0,h.y,a.y,0,0,0,1),y=ne.copy(l).invert(),u=se.copy(y).transpose().multiply(y).elements,p=ln(u[0],u[1],u[4]),d=Math.sqrt(p.rt1),v=Math.sqrt(p.rt2);if(i.rx=1/d,i.ry=1/v,i.rotate=Math.atan2(p.sn,p.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=ne.set(d,0,0,0,v,0,0,0,1),P=se.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),b=w.multiply(P).multiply(l),S=g=>{const{x:M,y:q}=new m(Math.cos(g),Math.sin(g)).applyMatrix3(b);return Math.atan2(q,M)};i.startAngle=S(i.startAngle),i.endAngle=S(i.endAngle),ie(e)&&(i.clockwise=!i.clockwise)}}function hn(i,e){const t=re(e),n=oe(e);i.rx*=t,i.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);i.rotate+=r,ie(e)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ie(i){const e=i.elements;return e[0]*e[4]-e[1]*e[3]<0}function an(i){const e=i.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=re(i),r=oe(i);return Math.abs(t/(n*r))>Number.EPSILON}function re(i){const e=i.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function oe(i){const e=i.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function ln(i,e,t){let n,r,o,s,c;const h=i+t,a=i-t,l=Math.sqrt(a*a+4*e*e);return h>0?(n=.5*(h+l),c=1/n,r=i*c*t-e*c*e):h<0?r=.5*(h-l):(n=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(e)?(c=-2*e/o,s=1/Math.sqrt(1+c*c),o=c*s):Math.abs(e)===0?(o=1,s=0):(c=-.5*o/e,o=1/Math.sqrt(1+c*c),s=c*o),a>0&&(c=o,o=-s,s=c),{rt1:n,rt2:r,cs:o,sn:s}}class ce extends qt{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,s=!1){super(new m(e,t),new m(n,n),new m,0,r,o,s)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;return e.arc(t,n,r,o,s,!c),this}getAdaptiveVertices(e=[]){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;let h=Math.abs(o-s);(!c&&o>s||c&&s>o)&&(h=2*Math.PI-h);let a=Math.max(6,Math.floor(6*r**(1/3)*(h/Math.PI)));a=Math.max(a,3);let l=h/a,y=o;l*=c?1:-1;for(let f=0;f<a+1;f++){const x=Math.cos(y),u=Math.sin(y),p=t+x*r,d=n+u*r;e.push(p,d),y+=l}return e}}class j extends Y{constructor(e=new m,t=new m){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new j(new m(e,t),new m(n,r))}getPoint(e,t=new m){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new m){return this.getPoint(e,t)}getTangent(e,t=new m){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new m){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=m.MAX,t=m.MIN){const{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(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}getFillVertices(e={}){var l,y;const 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),o=Math.max(this.p1.y,this.p2.y),s=t,c=r,h=n-t||((l=e.style)==null?void 0:l.strokeWidth)||0,a=o-r||((y=e.style)==null?void 0:y.strokeWidth)||0;return[s,c,s+h,c,s+h,c+a,s,c+a]}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class rt extends Y{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof rt?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new m){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,c=this.curves[o],h=c.getLength();return c.getPointAt(h===0?0:1-s/h,t)}o++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){const 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);{const t=[];let n;return this.curves.forEach(r=>{let o;r instanceof j?o=r.getAdaptiveVertices():o=r.getFillVertices(e),t.push(...o),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=m.MAX,t=m.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new X(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class wt extends Y{constructor(e=new m,t=new m,n=new m,r=new m){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,s,c,h){return new wt(new m(e,t),new m(n,r),new m(o,s),new m(c,h))}getPoint(e,t=new m){const{p1:n,cp1:r,cp2:o,p2:s}=this;return t.set(_t(e,n.x,r.x,o.x,s.x),_t(e,n.y,r.y,o.y,s.y))}getAdaptiveVertices(e=[]){return Qt(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){const r=t*t-4*e*n;if(r<0)return[];const o=Math.sqrt(r),s=(-t+o)/(2*e),c=(-t-o)/(2*e);return[s,c].filter(h=>h>=0&&h<=1)}getMinMax(e=m.MAX,t=m.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,c=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),h=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),a=[0,1,...c,...h];return((y,f)=>{for(const x of y)for(let u=0;u<=f;u++){const p=u/f-.5,d=Math.min(1,Math.max(0,x+p)),v=this.getPoint(d);e.x=Math.min(e.x,v.x),e.y=Math.min(e.y,v.y),t.x=Math.max(t.x,v.x),t.y=Math.max(t.y,v.y)}})(a,10),{min:e.finite(),max:t.finite()}}toCommands(){const{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){const{p1:t,cp1:n,cp2:r,p2:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class he extends qt{constructor(e=0,t=0,n=1,r=1,o=0,s=0,c=Math.PI*2,h=!1){super(new m(e,t),new m(n,r),new m,o,s,c,h)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Ot extends rt{}class un extends Ot{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(){const{cx:e,cy:t,radius:n,sideCount:r}=this,o=[];for(let c=0;c<r;c++){const h=c*2*Math.PI/r-.5*Math.PI;o.push(new m(n*Math.cos(h),n*Math.sin(h)).add({x:e,y:t}))}const s=[];for(let c=0;c<r;c++)s.push(new j(o[c],o[(c+1)%r]));return this.curves=s,this}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}}class Pt extends Y{constructor(e=new m,t=new m,n=new m){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,s){return new Pt(new m(e,t),new m(n,r),new m(o,s))}getPoint(e,t=new m){const{p1:n,cp:r,p2:o}=this;return t.set(Dt(e,n.x,r.x,o.x),Dt(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return Yt(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=m.MAX,t=m.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),c=.5*(n.y+r.y),h=.5*(n.x+o.x),a=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,s,h),e.y=Math.min(e.y,n.y,o.y,c,a),t.x=Math.max(t.x,n.x,o.x,s,h),t.y=Math.max(t.y,n.y,o.y,c,a),{min:e.finite(),max:t.finite()}}toCommands(){const{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){const{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}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class ae extends Ot{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(){const{x:e,y:t,width:n,height:r}=this,o=[new m(e,t),new m(e+n,t),new m(e+n,t+r),new m(e,t+r)];return this.curves=[new j(o[0],o[1]),new j(o[1],o[2]),new j(o[2],o[3]),new j(o[3],o[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){const{x:t,y:n,width:r,height:o}=this;return[t,n,t+r,n,t+r,n+o,t,n+o]}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class le extends qt{constructor(e=0,t=0,n=1,r=1,o=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:o}=this,s=n/2,c=r/2,h=e+s,a=t+c,l=Math.max(0,Math.min(o,Math.min(s,c))),y=l;return this._center=new m(h,a),this._radius=new m(l,y),this._diff=new m(s-l,c-y),this}drawTo(e){const{x:t,y:n,width:r,height:o,radius:s}=this;return e.roundRect(t,n,r,o,s),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class ue extends Y{constructor(e=[]){super(),this.points=e}getPoint(e,t=new m){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),s=r-o,c=n[o===0?o:o-1],h=n[o],a=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return t.set(Et(s,c.x,h.x,a.x,l.x),Et(s,c.y,h.y,a.y,l.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class lt extends rt{constructor(t){super();U(this,"startPoint");U(this,"currentPoint");U(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:o,y:s}=t[n];this.lineTo(o,s)}return this}addCommands(t){return It(t,this),this}addData(t){return this.addCommands(St(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,n=[]){return this._closeVertices(super.getUnevenVertices(t,n))}getSpacedVertices(t=40,n=[]){return this._closeVertices(super.getSpacedVertices(t,n))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new m(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new j(n.clone(),t.clone())),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new m(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(j.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,o,s,c){const h=this.currentPoint;return h!=null&&h.equals({x:s,y:c})||this.curves.push(wt.from((h==null?void 0:h.x)??0,(h==null?void 0:h.y)??0,t,n,r,o,s,c)),this._setCurrentPoint({x:s,y:c}),this}quadraticCurveTo(t,n,r,o){const s=this.currentPoint;return s!=null&&s.equals({x:r,y:o})||this.curves.push(Pt.from((s==null?void 0:s.x)??0,(s==null?void 0:s.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,s,c){const h=new ce(t,n,r,o,s,!c);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeArc(t,n,r,o,s,c){var h,a;return t+=((h=this.currentPoint)==null?void 0:h.x)??0,n+=((a=this.currentPoint)==null?void 0:a.y)??0,this.arc(t,n,r,o,s,c),this}arcTo(t,n,r,o,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,s,c,h,a=!0){const l=new he(t,n,r,o,s,c,h,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,n,r,o,s,c,h,a){var l,y;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((y=this.currentPoint)==null?void 0:y.y)??0,this.ellipse(t,n,r,o,s,c,h,a),this}rect(t,n,r,o){const s=new ae(t,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,s){const c=new le(t,n,r,o,s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new m;return this.curves.push(new ue([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function fn(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function yn(i,e,t,n){const r=e.clone().sub(i),o=n.clone().sub(t),s=t.clone().sub(i),c=r.cross(o);if(c===0)return new m((i.x+t.x)/2,(i.y+t.y)/2);const h=s.cross(o)/c;return Math.abs(h)>1?new m((i.x+t.x)/2,(i.y+t.y)/2):new m(i.x+h*r.x,i.y+h*r.y)}class B extends rt{constructor(t,n={}){super();U(this,"currentCurve",new lt);U(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof B?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}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)}addPath(t){const n=this.curves.findIndex(r=>r===this.currentCurve);return n>-1&&this.curves.splice(n,1),t instanceof B?this.curves.push(...t.curves.filter(r=>r.curves.length).map(r=>r.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new lt().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new lt,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,o,s,c){return this.currentCurve.bezierCurveTo(t,n,r,o,s,c),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,s,c){return this.currentCurve.arc(t,n,r,o,s,c),this}arcTo(t,n,r,o,s){return this.currentCurve.arcTo(t,n,r,o,s),this}ellipse(t,n,r,o,s,c,h,a){return this.currentCurve.ellipse(t,n,r,o,s,c,h,a),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,s){return this.currentCurve.roundRect(t,n,r,o,s),this}reset(){return this.currentCurve=new lt,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return It(t,this),this}addData(t){return this.addCommands(St(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.getFlatCurves(),r=[],o=[],s=[];n.forEach((h,a)=>{const l=h.getControlPointRefs(),y=h.isClockwise();s[a]=l,o[a]=y;const f=l[0],x=l[l.length-1]??f;r.push({start:y?x:f,end:y?f:x,index:a})});const c=[];return r.forEach((h,a)=>{c[a]=[],r.forEach((l,y)=>{var f;l.start&&h.end&&y!==a&&((f=l.start)!=null&&f.equals(h.end))&&c[a].push(l.index)})}),n.forEach((h,a)=>{const l=o[a];s[a].forEach(y=>{y.add(h.getNormal(h.getTForPoint(y)).scale(l?t:-t))})}),c.forEach((h,a)=>{const l=s[a];h.forEach(y=>{const f=s[y],x=yn(l[l.length-1],l[l.length-2]??l[l.length-1],f[0],f[1]??f[0]);x&&(l[l.length-1].copy(x),f[0].copy(x))})}),this}getMinMax(t=m.MAX,n=m.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,n),r&&o>1){const c=o/2,h=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const y=s.getPoint(l),f=s.getNormal(l),x=f.clone().scale(h?c:-c),u=f.clone().scale(h?-c:c);a.push(y.clone().add(x),y.clone().add(u),y.clone().add({x:c,y:0}),y.clone().add({x:-c,y:0}),y.clone().add({x:0,y:c}),y.clone().add({x:0,y:-c}),y.clone().add({x:c,y:c}),y.clone().add({x:-c,y:-c}))}t.min(...a),n.max(...a)}}),{min:t.finite(),max:n.finite()}}strokeTriangulate(t){const n=(t==null?void 0:t.indices)??[],r=(t==null?void 0:t.vertices)??[];return this.curves.forEach(o=>{o.strokeTriangulate({...t,indices:n,vertices:r,style:{...this.style}})}),{indices:n,vertices:r}}fillTriangulate(t){const n={...t,style:{...this.style,...t==null?void 0:t.style}},r=n.indices??[],o=n.vertices??[];if((n.style.fillRule??"nonzero")==="nonzero"){const c=this.curves.map(l=>l.getFillVertices(n)),h=new Map,a=new Set;for(let l=0;l<c.length;l++){const y=[];for(let f=0;f<c.length;f++)l!==f&&Jt([c[l][0],c[l][1]],c[f])&&y.push(f);y.length&&(y.forEach(f=>{let x=h.get(f);x||(x=new Set,h.set(f,x)),x.add(l)}),a.add(l))}c.forEach((l,y)=>{var u;if(a.has(y)||!l.length)return;const f=l.slice(),x=[];(u=h.get(y))==null||u.forEach(p=>{x.push(f.length/2),f.push(...c[p])}),Ft(f,{...t,indices:r,vertices:o,holes:x,style:{...this.style}})})}else this.curves.forEach(c=>{c.fillTriangulate({...t,indices:r,vertices:o,style:{...this.style}})});return{indices:r,vertices:o}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new X(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.curves.forEach(s=>{s.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.getControlPointRefs().forEach(s=>{O(t,s.x,s.y,{radius:4})}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSVGPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},n={};for(const o in t)t[o]!==void 0&&(n[fn(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class fe{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=m.MAX,n=m.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new X(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSVGString(e=this.paths.map(n=>n.fillTriangulate()),t=0){let n="";const r={x:-t,y:-t},o={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:h,indices:a})=>{const l=y=>{const f=h[y*2],x=h[y*2+1];return r.x=Math.min(r.x,f+t),o.x=Math.max(o.x,f+t),r.y=Math.min(r.y,x+t),o.y=Math.max(o.y,x+t),[f,x]};for(let y=0,f=a.length;y<f;y+=3){const x=l(a[y]),u=l(a[y+1]),p=l(a[y+2]);n+=`<polygon points="${x.join(",")} ${u.join(",")} ${p.join(",")}" fill="black" />`}});const c=[r.x,r.y,o.x-r.x,o.y-r.y];return`<svg width="${c[2]}" height="${c[3]}" viewBox="${c.join(" ")}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}toTriangulatedSVG(e,t){return new DOMParser().parseFromString(this.toTriangulatedSVGString(e,t),"image/svg+xml").documentElement}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${n} ${r}" width="${n}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:o,width:s,height:c}=this.getBoundingBox(),h=document.createElement("canvas");h.width=s*t,h.height=c*t,h.style.width=`${s}px`,h.style.height=`${c}px`;const a=h.getContext("2d");return a&&(a.scale(t,t),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,n)})),h}}class xn{constructor(e,t,n=1,r=1){U(this,"controlPoints",[]);this.rows=e,this.cols=t,this.width=n,this.height=r;for(let o=0;o<e;o++){this.controlPoints[o]=[];for(let s=0;s<t;s++)this.controlPoints[o][s]={x:s/(t-1)*n,y:o/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}}function ye(i){const e=[];return e[0]=(1-i)**3/6,e[1]=(3*i**3-6*i**2+4)/6,e[2]=(-3*i**3+3*i**2+3*i+1)/6,e[3]=i**3/6,e}function pn(i,e,t=e.width,n=e.height){const r=i.x/t*(e.cols-1),o=i.y/n*(e.rows-1),s=Math.floor(r),c=Math.floor(o),h=r-s,a=o-c,l=ye(h),y=ye(a);let f=0,x=0;for(let u=0;u<4;u++)for(let p=0;p<4;p++){const d=Math.min(Math.max(c-1+u,0),e.rows-1),v=Math.min(Math.max(s-1+p,0),e.cols-1),A=e.controlPoints[d][v],w=l[p]*y[u];f+=A.x*w,x+=A.y*w}i.set(f,x)}const xe="data:image/svg+xml;",pe=`${xe}base64,`,ge=`${xe}charset=utf8,`;function de(i){if(typeof i=="string"){let e;i.startsWith(pe)?(i=i.substring(pe.length,i.length),e=atob(i)):i.startsWith(ge)?(i=i.substring(ge.length,i.length),e=decodeURIComponent(i)):e=i;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
2
+ ${e}`);return t.documentElement}else return i}const gn="px",dn=90,me=["mm","cm","in","pt","pc","px"],Me={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 _(i){let e="px";if(typeof i=="string")for(let n=0,r=me.length;n<r;n++){const o=me[n];if(i.endsWith(o)){e=o,i=i.substring(0,i.length-o.length);break}}let t;return t=Me[e][gn],t<0&&(t=Me[e].in*dn),t*Number.parseFloat(i)}const mn=new z,vt=new z,we=new z,Pe=new z;function Mn(i,e,t){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=wn(i);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function wn(i){const e=new z,t=mn;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&e.translate(_(i.getAttribute("x")),_(i.getAttribute("y"))),i.hasAttribute("transform")){const n=i.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const s=o.indexOf("("),c=o.length;if(s>0&&s<c){const h=o.slice(0,s),a=Z(o.slice(s+1));switch(t.identity(),h){case"translate":if(a.length>=1){const l=a[0];let y=0;a.length>=2&&(y=a[1]),t.translate(l,y)}break;case"rotate":if(a.length>=1){let l=0,y=0,f=0;l=a[0]*Math.PI/180,a.length>=3&&(y=a[1],f=a[2]),vt.makeTranslation(-y,-f),we.makeRotation(l),Pe.multiplyMatrices(we,vt),vt.makeTranslation(y,f),t.multiplyMatrices(vt,Pe)}break;case"scale":a.length>=1&&t.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&t.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&t.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&t.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}e.premultiply(t)}}return e}function Pn(i){return new B().arc(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("r")||0),0,Math.PI*2)}function vn(i,e){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let t=0;t<i.sheet.cssRules.length;t++){const n=i.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,c=0;c<s;c++){const h=n.style.item(c);o[h]=n.style.getPropertyValue(h)}for(let s=0;s<r.length;s++)e[r[s]]=Object.assign(e[r[s]]||{},{...o})}}function Tn(i){return new B().ellipse(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("rx")||0),_(i.getAttribute("ry")||0),0,0,Math.PI*2)}function Cn(i){return new B().moveTo(_(i.getAttribute("x1")||0),_(i.getAttribute("y1")||0)).lineTo(_(i.getAttribute("x2")||0),_(i.getAttribute("y2")||0))}function bn(i){const e=new B,t=i.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const An=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function kn(i){var n;const e=new B;let t=0;return(n=i.getAttribute("points"))==null||n.replace(An,(r,o,s)=>{const c=_(o),h=_(s);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,r}),e.currentCurve.autoClose=!0,e}const In=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Sn(i){var n;const e=new B;let t=0;return(n=i.getAttribute("points"))==null||n.replace(In,(r,o,s)=>{const c=_(o),h=_(s);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,r}),e.currentCurve.autoClose=!1,e}function En(i){const e=_(i.getAttribute("x")||0),t=_(i.getAttribute("y")||0),n=_(i.getAttribute("rx")||i.getAttribute("ry")||0),r=_(i.getAttribute("ry")||i.getAttribute("rx")||0),o=_(i.getAttribute("width")),s=_(i.getAttribute("height")),c=1-.551915024494,h=new B;return h.moveTo(e+n,t),h.lineTo(e+o-n,t),(n!==0||r!==0)&&h.bezierCurveTo(e+o-n*c,t,e+o,t+r*c,e+o,t+r),h.lineTo(e+o,t+s-r),(n!==0||r!==0)&&h.bezierCurveTo(e+o,t+s-r*c,e+o-n*c,t+s,e+o-n,t+s),h.lineTo(e+n,t+s),(n!==0||r!==0)&&h.bezierCurveTo(e+n*c,t+s,e,t+s-r*c,e,t+s-r),h.lineTo(e,t+r),(n!==0||r!==0)&&h.bezierCurveTo(e,t+r*c,e+n*c,t,e+n,t),h}function G(i,e,t){e=Object.assign({},e);let n={};if(i.hasAttribute("class")){const a=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)n=Object.assign(n,t[`.${a[l]}`])}i.hasAttribute("id")&&(n=Object.assign(n,t[`#${i.getAttribute("id")}`]));for(let a=i.style.length,l=0;l<a;l++){const y=i.style.item(l),f=i.style.getPropertyValue(y);e[y]=f,n[y]=f}function r(a,l,y=o){i.hasAttribute(a)&&(e[l]=y(i.getAttribute(a))),n[a]&&(e[l]=y(n[a]))}function o(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function s(a){return Math.max(0,Math.min(1,_(a)))}function c(a){return Math.max(0,_(a))}function h(a){return a.split(" ").filter(l=>l!=="").map(l=>_(l))}return r("fill","fill"),r("fill-opacity","fillOpacity",s),r("fill-rule","fillRule"),r("opacity","opacity",s),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",s),r("stroke-width","strokeWidth",c),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",c),r("stroke-dasharray","strokeDasharray",h),r("stroke-dashoffset","strokeDashoffset",_),r("visibility","visibility"),e}function Rt(i,e,t=[],n={}){var y;if(i.nodeType!==1)return t;let r=!1,o=null,s={...e};switch(i.nodeName){case"svg":s=G(i,s,n);break;case"style":vn(i,n);break;case"g":s=G(i,s,n);break;case"path":s=G(i,s,n),i.hasAttribute("d")&&(o=bn(i));break;case"rect":s=G(i,s,n),o=En(i);break;case"polygon":s=G(i,s,n),o=kn(i);break;case"polyline":s=G(i,s,n),o=Sn(i);break;case"circle":s=G(i,s,n),o=Pn(i);break;case"ellipse":s=G(i,s,n),o=Tn(i);break;case"line":s=G(i,s,n),o=Cn(i);break;case"defs":r=!0;break;case"use":{s=G(i,s,n);const x=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),u=(y=i.viewportElement)==null?void 0:y.getElementById(x);u?Rt(u,s,t,n):console.warn(`'use node' references non-existent node id: ${x}`);break}default:console.warn(i);break}if(s.display==="none")return t;const c=new z,h=[],a=Mn(i,c,h);o&&(o.applyTransform(c),t.push(o),o.style={...s});const l=i.childNodes;for(let f=0,x=l.length;f<x;f++){const u=l[f];r&&u.nodeName!=="style"&&u.nodeName!=="defs"||Rt(u,s,t,n)}return a&&(h.pop(),h.length>0?c.copy(h[h.length-1]):c.identity()),t}function _n(i){var t;const e=de(i);return new fe(Rt(e,{}),(t=e.getAttribute("viewBox"))==null?void 0:t.trim().split(" ").map(n=>Number(n)))}T.ArcCurve=ce,T.BoundingBox=X,T.CompositeCurve=rt,T.CubicBezierCurve=wt,T.Curve=Y,T.CurvePath=lt,T.EllipseCurve=he,T.EquilateralPloygonCurve=un,T.FFDControlGrid=xn,T.LineCurve=j,T.Matrix3=z,T.Path2D=B,T.Path2DSet=fe,T.PloygonCurve=Ot,T.QuadraticBezierCurve=Pt,T.RectangleCurve=ae,T.RoundRectangleCurve=le,T.SplineCurve=ue,T.Vector2=m,T.applyFFD=pn,T.catmullRom=Et,T.cubicBezier=_t,T.drawPoint=O,T.fillTriangulate=Ft,T.getAdaptiveCubicBezierCurvePoints=Qt,T.getAdaptiveQuadraticBezierCurvePoints=Yt,T.getDirectedArea=Ke,T.parseArcCommand=jt,T.parsePathDataArgs=Z,T.pointInPolygon=Jt,T.quadraticBezier=Dt,T.setCanvasContext=At,T.strokeTriangulate=te,T.svgPathCommandsAddToPath2D=It,T.svgPathCommandsToData=Bt,T.svgPathDataToCommands=St,T.svgToDOM=de,T.svgToPath2DSet=_n,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -506,7 +506,6 @@ function parseArcCommand(path, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, s
506
506
  }
507
507
 
508
508
  const RE$3 = {
509
- SEPARATOR: /[ \t\r\n,.\-+]/,
510
509
  WHITESPACE: /[ \t\r\n]/,
511
510
  DIGIT: /\d/,
512
511
  SIGN: /[-+]/,
@@ -1976,105 +1975,116 @@ class RoundCurve extends Curve {
1976
1975
  return [this._center];
1977
1976
  }
1978
1977
  _getAdaptiveVerticesByArc(output = []) {
1979
- const { cx, cy, rx, ry, dx, dy, startAngle, endAngle, clockwise: _clockwise } = this;
1980
- const clockwise = !_clockwise;
1981
- const x = cx;
1982
- const y = cy;
1983
- const start = startAngle;
1984
- const end = endAngle;
1985
- let dist = Math.abs(start - end);
1986
- if (!clockwise && start > end) {
1978
+ const { cx, cy, rx, ry, dx, dy, startAngle, endAngle, clockwise, rotate } = this;
1979
+ const counterclockwise = !clockwise;
1980
+ let dist = Math.abs(startAngle - endAngle);
1981
+ if (!counterclockwise && startAngle > endAngle) {
1987
1982
  dist = 2 * Math.PI - dist;
1988
- } else if (clockwise && end > start) {
1983
+ } else if (counterclockwise && endAngle > startAngle) {
1989
1984
  dist = 2 * Math.PI - dist;
1990
1985
  }
1991
- let steps = Math.max(6, Math.floor(6 * rx ** (1 / 3) * (dist / Math.PI)));
1992
- steps = Math.max(steps, 3);
1986
+ const steps = Math.max(12, Math.floor(12 * rx ** (1 / 3) * (dist / Math.PI)));
1993
1987
  let f = dist / steps;
1994
- let t = start;
1995
- f *= clockwise ? -1 : 1;
1988
+ let t = startAngle;
1989
+ f *= counterclockwise ? -1 : 1;
1990
+ const cos = Math.cos(counterclockwise ? rotate : -rotate);
1991
+ const sin = Math.sin(counterclockwise ? rotate : -rotate);
1996
1992
  for (let i = 0; i < steps + 1; i++) {
1997
- const cs = Math.cos(t);
1998
- const sn = Math.sin(t);
1999
- const nx = x + dx + cs * rx;
2000
- const ny = y + dy + sn * ry;
2001
- output.push(nx, ny);
1993
+ const _dx = dx + Math.cos(t) * rx;
1994
+ const _dy = dy + Math.sin(t) * ry;
1995
+ const __dx = _dx * cos - _dy * sin;
1996
+ const __dy = _dx * sin + _dy * cos;
1997
+ output.push(cx + __dx, cy + __dy);
2002
1998
  t += f;
2003
1999
  }
2004
2000
  return output;
2005
2001
  }
2006
2002
  _getAdaptiveVerticesByCircle(output = []) {
2007
- const { cx, cy, rx, ry, dx, dy } = this;
2003
+ const { cx, cy, rx, ry, dx, dy, rotate, clockwise } = this;
2008
2004
  if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {
2009
2005
  return output;
2010
2006
  }
2011
2007
  const n = Math.ceil(2.3 * Math.sqrt(rx + ry));
2012
- const x = cx;
2013
- const y = cy;
2014
2008
  const m = n * 8 + (dx ? 4 : 0) + (dy ? 4 : 0);
2009
+ const array = [];
2015
2010
  if (m === 0) {
2016
2011
  return output;
2012
+ } else {
2013
+ const start = array.length;
2014
+ if (n === 0) {
2015
+ array[start] = array[start + 6] = cx + dx;
2016
+ array[start + 1] = array[start + 3] = cy + dy;
2017
+ array[start + 2] = array[start + 4] = cx - dx;
2018
+ array[start + 5] = array[start + 7] = cy - dy;
2019
+ } else {
2020
+ let j1 = start;
2021
+ let j2 = start + n * 4 + (dx ? 2 : 0) + 2;
2022
+ let j3 = j2;
2023
+ let j4 = m;
2024
+ let _dx = dx + rx;
2025
+ let _dy = dy;
2026
+ let x1 = cx + _dx;
2027
+ let x2 = cx - _dx;
2028
+ let y1 = cy + _dy;
2029
+ array[j1++] = x1;
2030
+ array[j1++] = y1;
2031
+ array[--j2] = y1;
2032
+ array[--j2] = x2;
2033
+ if (dy) {
2034
+ const y22 = cy - _dy;
2035
+ array[j3++] = x2;
2036
+ array[j3++] = y22;
2037
+ array[--j4] = y22;
2038
+ array[--j4] = x1;
2039
+ }
2040
+ for (let i = 1; i < n; i++) {
2041
+ const t = Math.PI / 2 * (i / n);
2042
+ const _dx2 = dx + Math.cos(t) * rx;
2043
+ const _dy2 = dy + Math.sin(t) * ry;
2044
+ const x12 = cx + _dx2;
2045
+ const x22 = cx - _dx2;
2046
+ const y12 = cy + _dy2;
2047
+ const y22 = cy - _dy2;
2048
+ array[j1++] = x12;
2049
+ array[j1++] = y12;
2050
+ array[--j2] = y12;
2051
+ array[--j2] = x22;
2052
+ array[j3++] = x22;
2053
+ array[j3++] = y22;
2054
+ array[--j4] = y22;
2055
+ array[--j4] = x12;
2056
+ }
2057
+ _dx = dx;
2058
+ _dy = dy + ry;
2059
+ x1 = cx + _dx;
2060
+ x2 = cx - _dx;
2061
+ y1 = cy + _dy;
2062
+ const y2 = cy - _dy;
2063
+ array[j1++] = x1;
2064
+ array[j1++] = y1;
2065
+ array[--j4] = y2;
2066
+ array[--j4] = x1;
2067
+ if (dx) {
2068
+ array[j1++] = x2;
2069
+ array[j1++] = y1;
2070
+ array[--j4] = y2;
2071
+ array[--j4] = x2;
2072
+ }
2073
+ }
2017
2074
  }
2018
- const start = output.length;
2019
- if (n === 0) {
2020
- output[start] = output[start + 6] = x + dx;
2021
- output[start + 1] = output[start + 3] = y + dy;
2022
- output[start + 2] = output[start + 4] = x - dx;
2023
- output[start + 5] = output[start + 7] = y - dy;
2024
- return output;
2025
- }
2026
- let j1 = start;
2027
- let j2 = start + n * 4 + (dx ? 2 : 0) + 2;
2028
- let j3 = j2;
2029
- let j4 = m;
2030
- let x0 = dx + rx;
2031
- let y0 = dy;
2032
- let x1 = x + x0;
2033
- let x2 = x - x0;
2034
- let y1 = y + y0;
2035
- output[j1++] = x1;
2036
- output[j1++] = y1;
2037
- output[--j2] = y1;
2038
- output[--j2] = x2;
2039
- if (dy) {
2040
- const y22 = y - y0;
2041
- output[j3++] = x2;
2042
- output[j3++] = y22;
2043
- output[--j4] = y22;
2044
- output[--j4] = x1;
2045
- }
2046
- for (let i = 1; i < n; i++) {
2047
- const a = Math.PI / 2 * (i / n);
2048
- const x02 = dx + Math.cos(a) * rx;
2049
- const y02 = dy + Math.sin(a) * ry;
2050
- const x12 = x + x02;
2051
- const x22 = x - x02;
2052
- const y12 = y + y02;
2053
- const y22 = y - y02;
2054
- output[j1++] = x12;
2055
- output[j1++] = y12;
2056
- output[--j2] = y12;
2057
- output[--j2] = x22;
2058
- output[j3++] = x22;
2059
- output[j3++] = y22;
2060
- output[--j4] = y22;
2061
- output[--j4] = x12;
2062
- }
2063
- x0 = dx;
2064
- y0 = dy + ry;
2065
- x1 = x + x0;
2066
- x2 = x - x0;
2067
- y1 = y + y0;
2068
- const y2 = y - y0;
2069
- output[j1++] = x1;
2070
- output[j1++] = y1;
2071
- output[--j4] = y2;
2072
- output[--j4] = x1;
2073
- if (dx) {
2074
- output[j1++] = x2;
2075
- output[j1++] = y1;
2076
- output[--j4] = y2;
2077
- output[--j4] = x2;
2075
+ const cos = Math.cos(clockwise ? -rotate : rotate);
2076
+ const sin = Math.sin(clockwise ? -rotate : rotate);
2077
+ for (let i = 0; i < array.length; i += 2) {
2078
+ const x = array[i];
2079
+ const y = array[i + 1];
2080
+ const _dx = x - cx;
2081
+ const _dy = y - cy;
2082
+ const __dx = _dx * cos - _dy * sin;
2083
+ const __dy = _dx * sin + _dy * cos;
2084
+ output.push(
2085
+ cx + __dx,
2086
+ cy + __dy
2087
+ );
2078
2088
  }
2079
2089
  return output;
2080
2090
  }
@@ -2084,22 +2094,6 @@ class RoundCurve extends Curve {
2084
2094
  }
2085
2095
  return this._getAdaptiveVerticesByArc(output);
2086
2096
  }
2087
- getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
2088
- const { cx, cy, rx, ry, rotate } = this;
2089
- const cosTheta = Math.cos(rotate);
2090
- const sinTheta = Math.sin(rotate);
2091
- const halfWidth = Math.sqrt(
2092
- rx * rx * cosTheta * cosTheta + ry * ry * sinTheta * sinTheta
2093
- );
2094
- const halfHeight = Math.sqrt(
2095
- rx * rx * sinTheta * sinTheta + ry * ry * cosTheta * cosTheta
2096
- );
2097
- min.x = Math.min(min.x, cx - halfWidth);
2098
- min.y = Math.min(min.y, cy - halfHeight);
2099
- max.x = Math.max(max.x, cx + halfWidth);
2100
- max.y = Math.max(max.y, cy + halfHeight);
2101
- return { min: min.finite(), max: max.finite() };
2102
- }
2103
2097
  copy(source) {
2104
2098
  super.copy(source);
2105
2099
  this.cx = source.cx;
@@ -2978,7 +2972,7 @@ class CurvePath extends CompositeCurve {
2978
2972
  this.curves.push(new LineCurve(end.clone(), start.clone()));
2979
2973
  end.copy(start);
2980
2974
  }
2981
- this.startPoint = undefined;
2975
+ this.startPoint = void 0;
2982
2976
  }
2983
2977
  return this;
2984
2978
  }
@@ -3452,7 +3446,7 @@ class Path2D extends CompositeCurve {
3452
3446
  return { indices, vertices };
3453
3447
  }
3454
3448
  getBoundingBox(withStyle = true) {
3455
- const { min, max } = this.getMinMax(undefined, undefined, withStyle);
3449
+ const { min, max } = this.getMinMax(void 0, void 0, withStyle);
3456
3450
  return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
3457
3451
  }
3458
3452
  drawTo(ctx, style = {}) {
@@ -3505,7 +3499,7 @@ class Path2D extends CompositeCurve {
3505
3499
  };
3506
3500
  const cssStyle = {};
3507
3501
  for (const key in style) {
3508
- if (style[key] !== undefined) {
3502
+ if (style[key] !== void 0) {
3509
3503
  cssStyle[toKebabCase(key)] = style[key];
3510
3504
  }
3511
3505
  }
@@ -3514,7 +3508,7 @@ class Path2D extends CompositeCurve {
3514
3508
  });
3515
3509
  let cssText = "";
3516
3510
  for (const key in cssStyle) {
3517
- if (cssStyle[key] !== undefined) {
3511
+ if (cssStyle[key] !== void 0) {
3518
3512
  cssText += `${key}:${cssStyle[key]};`;
3519
3513
  }
3520
3514
  }
@@ -3535,7 +3529,7 @@ class Path2DSet {
3535
3529
  }
3536
3530
  getBoundingBox(withStyle = true) {
3537
3531
  if (!this.paths.length) {
3538
- return undefined;
3532
+ return void 0;
3539
3533
  }
3540
3534
  const min = Vector2.MAX;
3541
3535
  const max = Vector2.MIN;
@@ -3733,7 +3727,7 @@ const unitConversion = {
3733
3727
  };
3734
3728
  function parseFloatWithUnits(string) {
3735
3729
  let theUnit = "px";
3736
- if (typeof string === "string" || string instanceof String) {
3730
+ if (typeof string === "string") {
3737
3731
  for (let i = 0, n = units.length; i < n; i++) {
3738
3732
  const u = units[i];
3739
3733
  if (string.endsWith(u)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "1.3.3",
4
+ "version": "1.3.5",
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",
@@ -59,18 +59,18 @@
59
59
  "earcut": "^3.0.1"
60
60
  },
61
61
  "devDependencies": {
62
- "@antfu/eslint-config": "^3.14.0",
62
+ "@antfu/eslint-config": "^4.14.1",
63
63
  "@types/earcut": "^3.0.0",
64
- "@types/node": "^22.10.7",
65
- "bumpp": "^9.10.1",
64
+ "@types/node": "^24.0.0",
65
+ "bumpp": "^10.1.1",
66
66
  "conventional-changelog-cli": "^5.0.0",
67
- "eslint": "^9.18.0",
68
- "lint-staged": "^15.4.1",
69
- "simple-git-hooks": "^2.11.1",
70
- "typescript": "^5.7.3",
71
- "unbuild": "^3.3.1",
72
- "vite": "^6.0.8",
73
- "vitest": "^3.0.2"
67
+ "eslint": "^9.28.0",
68
+ "lint-staged": "^16.1.0",
69
+ "simple-git-hooks": "^2.13.0",
70
+ "typescript": "^5.8.3",
71
+ "unbuild": "^3.5.0",
72
+ "vite": "^6.3.5",
73
+ "vitest": "^3.2.3"
74
74
  },
75
75
  "simple-git-hooks": {
76
76
  "pre-commit": "pnpm lint-staged"