modern-path2d 0.1.6 → 0.1.7

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
@@ -1023,8 +1023,18 @@ class Curve {
1023
1023
  }
1024
1024
  /** overrideable */
1025
1025
  getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1026
+ this.getPoints().forEach((point) => {
1027
+ min.x = Math.min(min.x, point.x);
1028
+ min.y = Math.min(min.y, point.y);
1029
+ max.x = Math.max(max.x, point.x);
1030
+ max.y = Math.max(max.y, point.y);
1031
+ });
1026
1032
  return { min, max };
1027
1033
  }
1034
+ getBoundingBox() {
1035
+ const { min, max } = this.getMinMax();
1036
+ return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
1037
+ }
1028
1038
  /** overrideable */
1029
1039
  getCommands() {
1030
1040
  return [];
@@ -1222,35 +1232,33 @@ class EllipseCurve extends Curve {
1222
1232
  return divisions * 2;
1223
1233
  }
1224
1234
  getCommands() {
1225
- const { x, y, radiusX, radiusY, startAngle, endAngle, clockwise } = this;
1226
- const anticlockwise = !clockwise;
1227
- const startX = x + radiusX * Math.cos(startAngle);
1228
- const startY = y + radiusY * Math.sin(startAngle);
1229
- const endX = x + radiusX * Math.cos(endAngle);
1230
- const endY = y + radiusY * Math.sin(endAngle);
1235
+ const { x: cx, y: cy, radiusX: rx, radiusY: ry, startAngle, endAngle, clockwise, rotation } = this;
1236
+ const startX = cx + rx * Math.cos(startAngle) * Math.cos(rotation) - ry * Math.sin(startAngle) * Math.sin(rotation);
1237
+ const startY = cy + rx * Math.cos(startAngle) * Math.sin(rotation) + ry * Math.sin(startAngle) * Math.cos(rotation);
1231
1238
  const angleDiff = Math.abs(startAngle - endAngle);
1232
1239
  const largeArcFlag = angleDiff > Math.PI ? 1 : 0;
1233
- const sweepFlag = anticlockwise ? 0 : 1;
1234
- const midX = x + radiusX * Math.cos(startAngle + (endAngle - startAngle) / 2);
1235
- const midY = y + radiusY * Math.sin(startAngle + (endAngle - startAngle) / 2);
1240
+ const sweepFlag = clockwise ? 1 : 0;
1241
+ const angle = rotation * 180 / Math.PI;
1236
1242
  if (angleDiff >= 2 * Math.PI) {
1243
+ const midAngle = startAngle + Math.PI;
1244
+ const midX = cx + rx * Math.cos(midAngle) * Math.cos(rotation) - ry * Math.sin(midAngle) * Math.sin(rotation);
1245
+ const midY = cy + rx * Math.cos(midAngle) * Math.sin(rotation) + ry * Math.sin(midAngle) * Math.cos(rotation);
1237
1246
  return [
1238
1247
  { type: "M", x: startX, y: startY },
1239
- { type: "A", rx: radiusX, ry: radiusY, angle: 0, largeArcFlag: 1, sweepFlag, x: midX, y: midY },
1240
- { type: "A", rx: radiusX, ry: radiusY, angle: 0, largeArcFlag: 1, sweepFlag, x: startX, y: startY }
1248
+ { type: "A", rx, ry, angle, largeArcFlag: 0, sweepFlag, x: midX, y: midY },
1249
+ { type: "A", rx, ry, angle, largeArcFlag: 0, sweepFlag, x: startX, y: startY }
1241
1250
  ];
1242
1251
  } else {
1252
+ const endX = cx + rx * Math.cos(endAngle) * Math.cos(rotation) - ry * Math.sin(endAngle) * Math.sin(rotation);
1253
+ const endY = cy + rx * Math.cos(endAngle) * Math.sin(rotation) + ry * Math.sin(endAngle) * Math.cos(rotation);
1243
1254
  return [
1244
1255
  { type: "M", x: startX, y: startY },
1245
- { type: "A", rx: radiusX, ry: radiusY, angle: 0, largeArcFlag, sweepFlag, x: endX, y: endY }
1256
+ { type: "A", rx, ry, angle, largeArcFlag, sweepFlag, x: endX, y: endY }
1246
1257
  ];
1247
1258
  }
1248
1259
  }
1249
1260
  drawTo(ctx) {
1250
1261
  const { x, y, radiusX, radiusY, rotation, startAngle, endAngle, clockwise } = this;
1251
- const startX = x + radiusX * Math.cos(startAngle);
1252
- const startY = y + radiusY * Math.sin(startAngle);
1253
- ctx.moveTo(startX, startY);
1254
1262
  ctx.ellipse(
1255
1263
  x,
1256
1264
  y,
@@ -1275,6 +1283,22 @@ class EllipseCurve extends Curve {
1275
1283
  }
1276
1284
  return this;
1277
1285
  }
1286
+ getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1287
+ const { x: cx, y: cy, radiusX: rx, radiusY: ry, rotation: theta } = this;
1288
+ const cosTheta = Math.cos(theta);
1289
+ const sinTheta = Math.sin(theta);
1290
+ const halfWidth = Math.sqrt(
1291
+ rx * rx * cosTheta * cosTheta + ry * ry * sinTheta * sinTheta
1292
+ );
1293
+ const halfHeight = Math.sqrt(
1294
+ rx * rx * sinTheta * sinTheta + ry * ry * cosTheta * cosTheta
1295
+ );
1296
+ min.x = Math.min(min.x, cx - halfWidth);
1297
+ min.y = Math.min(min.y, cy - halfHeight);
1298
+ max.x = Math.max(max.x, cx + halfWidth);
1299
+ max.y = Math.max(max.y, cy + halfHeight);
1300
+ return { min, max };
1301
+ }
1278
1302
  copy(source) {
1279
1303
  super.copy(source);
1280
1304
  this.x = source.x;
@@ -2091,34 +2115,10 @@ class Path2D {
2091
2115
  this.currentPath.absarc(x, y, radius, startAngle, endAngle, !counterclockwise);
2092
2116
  return this;
2093
2117
  }
2118
+ // TODO
2119
+ // eslint-disable-next-line unused-imports/no-unused-vars
2094
2120
  arcTo(x1, y1, x2, y2, radius) {
2095
- const point = this.currentPath.currentPoint;
2096
- const currentX = point.x;
2097
- const currentY = point.y;
2098
- const dx1 = x1 - currentX;
2099
- const dy1 = y1 - currentY;
2100
- const dx2 = x2 - x1;
2101
- const dy2 = y2 - y1;
2102
- const len1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
2103
- const len2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
2104
- if (len1 < radius || len2 < radius) {
2105
- this.lineTo(x2, y2);
2106
- return this;
2107
- }
2108
- const unitV1 = { x: dx1 / len1, y: dy1 / len1 };
2109
- const unitV2 = { x: dx2 / len2, y: dy2 / len2 };
2110
- const centerX = x1 - unitV1.y * radius;
2111
- const centerY = y1 + unitV1.x * radius;
2112
- const startAngle = Math.atan2(unitV1.y, unitV1.x);
2113
- const endAngle = Math.atan2(unitV2.y, unitV2.x);
2114
- let angleDiff = endAngle - startAngle;
2115
- if (angleDiff > Math.PI) {
2116
- angleDiff -= 2 * Math.PI;
2117
- } else if (angleDiff < -Math.PI) {
2118
- angleDiff += 2 * Math.PI;
2119
- }
2120
- this.arc(centerX, centerY, radius, startAngle, startAngle + angleDiff, false);
2121
- this.lineTo(x2, y2);
2121
+ console.warn("Method arcTo not supported yet");
2122
2122
  return this;
2123
2123
  }
2124
2124
  ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
@@ -2155,12 +2155,7 @@ class Path2D {
2155
2155
  }
2156
2156
  getBoundingBox() {
2157
2157
  const { min, max } = this.getMinMax();
2158
- return new BoundingBox(
2159
- min.x,
2160
- min.y,
2161
- max.x - min.x,
2162
- max.y - min.y
2163
- );
2158
+ return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
2164
2159
  }
2165
2160
  getCommands() {
2166
2161
  return this.paths.flatMap((path) => path.curves.flatMap((curve) => curve.getCommands()));
@@ -2170,7 +2165,8 @@ class Path2D {
2170
2165
  }
2171
2166
  getSvgString() {
2172
2167
  const { x, y, width, height } = this.getBoundingBox();
2173
- return `<svg viewBox="${x} ${y} ${width} ${height}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`;
2168
+ const strokeWidth = 1;
2169
+ return `<svg viewBox="${x - strokeWidth} ${y - strokeWidth} ${width + strokeWidth * 2} ${height + strokeWidth * 2}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`;
2174
2170
  }
2175
2171
  getSvgDataUri() {
2176
2172
  return `data:image/svg+xml;base64,${btoa(this.getSvgString())}`;
@@ -2707,10 +2703,9 @@ function parseNode(node, style, paths = []) {
2707
2703
  const dataUri = "data:image/svg+xml;";
2708
2704
  const base64DataUri = `${dataUri}base64,`;
2709
2705
  const utf8DataUri = `${dataUri}charset=utf8,`;
2710
- function parseSvg(svg) {
2711
- let node;
2712
- let xml;
2706
+ function parseSvgToDom(svg) {
2713
2707
  if (typeof svg === "string") {
2708
+ let xml;
2714
2709
  if (svg.startsWith(base64DataUri)) {
2715
2710
  svg = svg.substring(base64DataUri.length, svg.length);
2716
2711
  xml = atob(svg);
@@ -2720,11 +2715,16 @@ function parseSvg(svg) {
2720
2715
  } else {
2721
2716
  xml = svg;
2722
2717
  }
2723
- node = new DOMParser().parseFromString(xml, "image/svg+xml").documentElement;
2718
+ return new DOMParser().parseFromString(
2719
+ xml,
2720
+ "image/svg+xml"
2721
+ ).documentElement;
2724
2722
  } else {
2725
- node = svg;
2723
+ return svg;
2726
2724
  }
2727
- return parseNode(node, {
2725
+ }
2726
+ function parseSvg(svg) {
2727
+ return parseNode(parseSvgToDom(svg), {
2728
2728
  fill: "#000",
2729
2729
  fillOpacity: 1,
2730
2730
  strokeOpacity: 1,
@@ -2751,3 +2751,4 @@ exports.QuadraticBezierCurve = QuadraticBezierCurve;
2751
2751
  exports.RectangularCurve = RectangularCurve;
2752
2752
  exports.SplineCurve = SplineCurve;
2753
2753
  exports.parseSvg = parseSvg;
2754
+ exports.parseSvgToDom = parseSvgToDom;
package/dist/index.d.cts CHANGED
@@ -212,6 +212,7 @@ declare abstract class Curve {
212
212
  min: Point2D;
213
213
  max: Point2D;
214
214
  };
215
+ getBoundingBox(): BoundingBox;
215
216
  /** overrideable */
216
217
  getCommands(): PathCommand[];
217
218
  getData(): string;
@@ -268,6 +269,10 @@ declare class EllipseCurve extends Curve {
268
269
  getCommands(): PathCommand[];
269
270
  drawTo(ctx: CanvasRenderingContext2D): this;
270
271
  transform(matrix: Matrix3): this;
272
+ getMinMax(min?: Point2D, max?: Point2D): {
273
+ min: Point2D;
274
+ max: Point2D;
275
+ };
271
276
  copy(source: EllipseCurve): this;
272
277
  }
273
278
 
@@ -388,6 +393,7 @@ declare class SplineCurve extends Curve {
388
393
  copy(source: SplineCurve): this;
389
394
  }
390
395
 
396
+ declare function parseSvgToDom(svg: string | SVGElement): SVGElement;
391
397
  declare function parseSvg(svg: string | SVGElement): Path2D[];
392
398
 
393
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
399
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg, parseSvgToDom };
package/dist/index.d.mts CHANGED
@@ -212,6 +212,7 @@ declare abstract class Curve {
212
212
  min: Point2D;
213
213
  max: Point2D;
214
214
  };
215
+ getBoundingBox(): BoundingBox;
215
216
  /** overrideable */
216
217
  getCommands(): PathCommand[];
217
218
  getData(): string;
@@ -268,6 +269,10 @@ declare class EllipseCurve extends Curve {
268
269
  getCommands(): PathCommand[];
269
270
  drawTo(ctx: CanvasRenderingContext2D): this;
270
271
  transform(matrix: Matrix3): this;
272
+ getMinMax(min?: Point2D, max?: Point2D): {
273
+ min: Point2D;
274
+ max: Point2D;
275
+ };
271
276
  copy(source: EllipseCurve): this;
272
277
  }
273
278
 
@@ -388,6 +393,7 @@ declare class SplineCurve extends Curve {
388
393
  copy(source: SplineCurve): this;
389
394
  }
390
395
 
396
+ declare function parseSvgToDom(svg: string | SVGElement): SVGElement;
391
397
  declare function parseSvg(svg: string | SVGElement): Path2D[];
392
398
 
393
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
399
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg, parseSvgToDom };
package/dist/index.d.ts CHANGED
@@ -212,6 +212,7 @@ declare abstract class Curve {
212
212
  min: Point2D;
213
213
  max: Point2D;
214
214
  };
215
+ getBoundingBox(): BoundingBox;
215
216
  /** overrideable */
216
217
  getCommands(): PathCommand[];
217
218
  getData(): string;
@@ -268,6 +269,10 @@ declare class EllipseCurve extends Curve {
268
269
  getCommands(): PathCommand[];
269
270
  drawTo(ctx: CanvasRenderingContext2D): this;
270
271
  transform(matrix: Matrix3): this;
272
+ getMinMax(min?: Point2D, max?: Point2D): {
273
+ min: Point2D;
274
+ max: Point2D;
275
+ };
271
276
  copy(source: EllipseCurve): this;
272
277
  }
273
278
 
@@ -388,6 +393,7 @@ declare class SplineCurve extends Curve {
388
393
  copy(source: SplineCurve): this;
389
394
  }
390
395
 
396
+ declare function parseSvgToDom(svg: string | SVGElement): SVGElement;
391
397
  declare function parseSvg(svg: string | SVGElement): Path2D[];
392
398
 
393
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
399
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg, parseSvgToDom };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(M,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(M=typeof globalThis<"u"?globalThis:M||self,u(M.modernPath2d={}))})(this,function(M){"use strict";var Ht=Object.defineProperty;var jt=(M,u,S)=>u in M?Ht(M,u,{enumerable:!0,configurable:!0,writable:!0,value:S}):M[u]=S;var w=(M,u,S)=>jt(M,typeof u!="symbol"?u+"":u,S);class u{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new u(1/0,1/0)}static get MIN(){return new u(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}multiplyScalar(e){return this.x*=e,this.y*=e,this}divideScalar(e){return this.multiplyScalar(1/e)}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}normalize(){return this.divideScalar(this.length()||1)}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new u(this.x,this.y)}}class S{constructor(e=0,t=0,s=0,n=0){this.left=e,this.top=t,this.width=s,this.height=n}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){const t=e[0],s=e.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new S(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new u((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new S(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class I{constructor(e=1,t=0,s=0,n=0,o=1,h=0,a=0,c=0,i=1){w(this,"elements",[]);this.set(e,t,s,n,o,h,a,c,i)}set(e,t,s,n,o,h,a,c,i){const l=this.elements;return l[0]=e,l[1]=n,l[2]=a,l[3]=t,l[4]=o,l[5]=c,l[6]=s,l[7]=h,l[8]=i,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,o=this.elements,h=s[0],a=s[3],c=s[6],i=s[1],l=s[4],y=s[7],p=s[2],x=s[5],f=s[8],g=n[0],m=n[3],T=n[6],C=n[1],P=n[4],A=n[7],b=n[2],$=n[5],z=n[8];return o[0]=h*g+a*C+c*b,o[3]=h*m+a*P+c*$,o[6]=h*T+a*A+c*z,o[1]=i*g+l*C+y*b,o[4]=i*m+l*P+y*$,o[7]=i*T+l*A+y*z,o[2]=p*g+x*C+f*b,o[5]=p*m+x*P+f*$,o[8]=p*T+x*A+f*z,this}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],o=e[3],h=e[4],a=e[5],c=e[6],i=e[7],l=e[8],y=l*h-a*i,p=a*c-l*o,x=i*o-h*c,f=t*y+s*p+n*x;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/f;return e[0]=y*g,e[1]=(n*i-l*s)*g,e[2]=(a*s-n*h)*g,e[3]=p*g,e[4]=(l*t-n*c)*g,e[5]=(n*o-a*t)*g,e[6]=x*g,e[7]=(s*c-i*t)*g,e[8]=(h*t-s*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(U.makeScale(e,t)),this}rotate(e){return this.premultiply(U.makeRotation(-e)),this}translate(e,t){return this.premultiply(U.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const U=new I;function B(r,e,t,s){const n=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let h=Math.acos(Math.max(-1,Math.min(1,n/o)));return r*s-e*t<0&&(h=-h),h}function gt(r,e,t,s,n,o,h,a){if(e===0||t===0){r.lineTo(a.x,a.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(h.x-a.x)/2,i=(h.y-a.y)/2,l=Math.cos(s)*c+Math.sin(s)*i,y=-Math.sin(s)*c+Math.cos(s)*i;let p=e*e,x=t*t;const f=l*l,g=y*y,m=f/p+g/x;if(m>1){const pt=Math.sqrt(m);e=pt*e,t=pt*t,p=e*e,x=t*t}const T=p*g+x*f,C=(p*x-T)/T;let P=Math.sqrt(Math.max(0,C));n===o&&(P=-P);const A=P*e*y/t,b=-P*t*l/e,$=Math.cos(s)*A-Math.sin(s)*b+(h.x+a.x)/2,z=Math.sin(s)*A+Math.cos(s)*b+(h.y+a.y)/2,Y=B(1,0,(l-A)/e,(y-b)/t),V=B((l-A)/e,(y-b)/t,(-l-A)/e,(-y-b)/t)%(Math.PI*2);r.currentPath.absellipse($,z,e,t,Y,Y+V,o===0,s)}function D(r,e){return r-(e-r)}function xt(r,e){const t=new u,s=new u,n=new u;let o=!0,h=!1;for(let a=0,c=r.length;a<c;a++){const i=r[a];if(o&&(h=!0,o=!1),i.type==="m"||i.type==="M")i.type==="m"?(t.x+=i.x,t.y+=i.y):(t.x=i.x,t.y=i.y),s.x=t.x,s.y=t.y,e.moveTo(t.x,t.y),n.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&n.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&n.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?(t.x+=i.x,t.y+=i.y):(t.x=i.x,t.y=i.y),s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),h&&n.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.x+=i.x,t.y+=i.y):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.x=i.x,t.y=i.y),h&&n.copy(t);else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.x+=i.x,t.y+=i.y):(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.x=i.x,t.y=i.y),h&&n.copy(t);else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),s.x=t.x+i.x1,s.y=t.y+i.y1,t.x+=i.x,t.y+=i.y):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),s.x=i.x1,s.y=i.y1,t.x=i.x,t.y=i.y),h&&n.copy(t);else if(i.type==="t"||i.type==="T"){const l=D(t.x,s.x),y=D(t.y,s.y);s.x=l,s.y=y,i.type==="t"?(e.quadraticCurveTo(l,y,t.x+i.x,t.y+i.y),t.x+=i.x,t.y+=i.y):(e.quadraticCurveTo(l,y,i.x,i.y),t.x=i.x,t.y=i.y),h&&n.copy(t)}else if(i.type==="a"||i.type==="A"){if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.x+=i.x,t.y+=i.y}else{if(i.x===t.x&&i.y===t.y)continue;t.x=i.x,t.y=i.y}const l=t.clone();s.x=t.x,s.y=t.y,gt(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,l,t),h&&n.copy(t)}else i.type==="z"||i.type==="Z"?(e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(t.copy(n),e.currentPath.currentPoint.copy(t),o=!0)):console.warn("Unsupported commands",i);h=!1}}const d={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function N(r,e,t=0){let a=0,c=!0,i="",l="";const y=[];function p(m,T,C){const P=new SyntaxError(`Unexpected character "${m}" at index ${T}.`);throw P.partial=C,P}function x(){i!==""&&(l===""?y.push(Number(i)):y.push(Number(i)*10**Number(l))),i="",l=""}let f;const g=r.length;for(let m=0;m<g;m++){if(f=r[m],Array.isArray(e)&&e.includes(y.length%t)&&d.FLAGS.test(f)){a=1,i=f,x();continue}if(a===0){if(d.WHITESPACE.test(f))continue;if(d.DIGIT.test(f)||d.SIGN.test(f)){a=1,i=f;continue}if(d.POINT.test(f)){a=2,i=f;continue}d.COMMA.test(f)&&(c&&p(f,m,y),c=!0)}if(a===1){if(d.DIGIT.test(f)){i+=f;continue}if(d.POINT.test(f)){i+=f,a=2;continue}if(d.EXP.test(f)){a=3;continue}d.SIGN.test(f)&&i.length===1&&d.SIGN.test(i[0])&&p(f,m,y)}if(a===2){if(d.DIGIT.test(f)){i+=f;continue}if(d.EXP.test(f)){a=3;continue}d.POINT.test(f)&&i[i.length-1]==="."&&p(f,m,y)}if(a===3){if(d.DIGIT.test(f)){l+=f;continue}if(d.SIGN.test(f)){if(l===""){l+=f;continue}l.length===1&&d.SIGN.test(l)&&p(f,m,y)}}d.WHITESPACE.test(f)?(x(),a=0,c=!1):d.COMMA.test(f)?(x(),a=0,c=!0):d.SIGN.test(f)?(x(),a=1,i=f):d.POINT.test(f)?(x(),a=2,i=f):p(f,m,y)}return x(),y}function Mt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function mt(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${Mt(r[t])} `;return e}const vt=/[a-df-z][^a-df-z]*/gi;function dt(r){const e=[],t=r.match(vt);if(!t)return e;for(let s=0,n=t.length;s<n;s++){const o=t[s],h=o.charAt(0),a=o.slice(1).trim();let c;switch(h){case"m":case"M":c=N(a);for(let i=0,l=c.length;i<l;i+=2)i===0?e.push({type:h,x:c[i],y:c[i+1]}):e.push({type:h==="m"?"l":"L",x:c[i],y:c[i+1]});break;case"h":case"H":c=N(a);for(let i=0,l=c.length;i<l;i++)e.push({type:h,x:c[i]});break;case"v":case"V":c=N(a);for(let i=0,l=c.length;i<l;i++)e.push({type:h,y:c[i]});break;case"l":case"L":c=N(a);for(let i=0,l=c.length;i<l;i+=2)e.push({type:h,x:c[i],y:c[i+1]});break;case"c":case"C":c=N(a);for(let i=0,l=c.length;i<l;i+=6)e.push({type:h,x1:c[i],y1:c[i+1],x2:c[i+2],y2:c[i+3],x:c[i+4],y:c[i+5]});break;case"s":case"S":c=N(a);for(let i=0,l=c.length;i<l;i+=4)e.push({type:h,x2:c[i],y2:c[i+1],x:c[i+2],y:c[i+3]});break;case"q":case"Q":c=N(a);for(let i=0,l=c.length;i<l;i+=4)e.push({type:h,x1:c[i],y1:c[i+1],x:c[i+2],y:c[i+3]});break;case"t":case"T":c=N(a);for(let i=0,l=c.length;i<l;i+=2)e.push({type:h,x:c[i],y:c[i+1]});break;case"a":case"A":c=N(a,[3,4],7);for(let i=0,l=c.length;i<l;i+=7)e.push({type:h,rx:c[i],ry:c[i+1],angle:c[i+2],largeArcFlag:c[i+3],sweepFlag:c[i+4],x:c[i+5],y:c[i+6]});break;case"z":case"Z":e.push({type:h});break;default:console.warn(o)}}return e}class k{constructor(){w(this,"arcLengthDivisions",200);w(this,"_cacheArcLengths");w(this,"_needsUpdate",!1)}getPointAt(e,t=new u){return this.getPoint(this.getUtoTmapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,n=this.getPoint(0),o=0;t.push(0);for(let h=1;h<=e;h++)s=this.getPoint(h/e),o+=s.distanceTo(n),t.push(o),n=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let n=0;const o=s.length;let h;t?h=t:h=e*s[o-1];let a=0,c=o-1,i;for(;a<=c;)if(n=Math.floor(a+(c-a)/2),i=s[n]-h,i<0)a=n+1;else if(i>0)c=n-1;else{c=n;break}if(n=c,s[n]===h)return n/(o-1);const l=s[n],p=s[n+1]-l,x=(h-l)/p;return(n+x)/(o-1)}getTangent(e,t=new u){let n=e-1e-4,o=e+1e-4;return n<0&&(n=0),o>1&&(o=1),t.copy(this.getPoint(o)).sub(this.getPoint(n)).normalize()}getTangentAt(e,t=new u){return this.getTangent(this.getUtoTmapping(e),t)}transform(e){return this}getDivisions(e){return e}getMinMax(e=u.MAX,t=u.MIN){return{min:e,max:t}}getCommands(){return[]}getData(){return mt(this.getCommands())}drawTo(e){return this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class O extends k{constructor(e,t,s=0,n=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=n}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().multiplyScalar(t))}getTangent(e){const{x:t,y:s}=this.getNormal(e);return new u(-s,t)}getNormal(e){const{start:t,end:s}=this,n=e*(s-t)+t-.5*Math.PI;return new u(Math.cos(n),Math.sin(n))}getMinMax(e=u.MAX,t=u.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function W(r,e,t,s,n){const o=(s-e)*.5,h=(n-t)*.5,a=r*r,c=r*a;return(2*t-2*s+o+h)*c+(-3*t+3*s-2*o-h)*a+o*r+t}function Pt(r,e){const t=1-r;return t*t*e}function Tt(r,e){return 2*(1-r)*r*e}function wt(r,e){return r*r*e}function H(r,e,t,s){return Pt(r,e)+Tt(r,t)+wt(r,s)}function bt(r,e){const t=1-r;return t*t*t*e}function At(r,e){const t=1-r;return 3*t*t*r*e}function Ct(r,e){return 3*(1-r)*r*r*e}function It(r,e){return r*r*r*e}function j(r,e,t,s,n){return bt(r,e)+At(r,t)+Ct(r,s)+It(r,n)}class Z extends k{constructor(e=new u,t=new u,s=new u,n=new u){super(),this.v0=e,this.v1=t,this.v2=s,this.v3=n}getPoint(e,t=new u){const{v0:s,v1:n,v2:o,v3:h}=this;return t.set(j(e,s.x,n.x,o.x,h.x),j(e,s.y,n.y,o.y,h.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this.v3.applyMatrix3(e),this}getMinMax(e=u.MAX,t=u.MIN){const{v0:s,v1:n,v2:o,v3:h}=this;return e.x=Math.min(e.x,s.x,n.x,o.x,h.x),e.y=Math.min(e.y,s.y,n.y,o.y,h.y),t.x=Math.max(t.x,s.x,n.x,o.x,h.x),t.y=Math.max(t.y,s.y,n.y,o.y,h.y),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s,v3:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:n.x,y:n.y}]}drawTo(e){const{v1:t,v2:s,v3:n}=this;return e.bezierCurveTo(t.x,t.y,s.x,s.y,n.x,n.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}}const kt=new I,J=new I,K=new I,R=new u;class tt extends k{constructor(e=0,t=0,s=1,n=1,o=0,h=Math.PI*2,a=!1,c=0){super(),this.x=e,this.y=t,this.radiusX=s,this.radiusY=n,this.startAngle=o,this.endAngle=h,this.clockwise=a,this.rotation=c}getPoint(e,t=new u){const s=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(o?n=0:n=s),this.clockwise&&!o&&(n===s?n=-s:n=n-s);const h=this.startAngle+e*n;let a=this.x+this.radiusX*Math.cos(h),c=this.y+this.radiusY*Math.sin(h);if(this.rotation!==0){const i=Math.cos(this.rotation),l=Math.sin(this.rotation),y=a-this.x,p=c-this.y;a=y*i-p*l+this.x,c=y*l+p*i+this.y}return t.set(a,c)}getDivisions(e=12){return e*2}getCommands(){const{x:e,y:t,radiusX:s,radiusY:n,startAngle:o,endAngle:h,clockwise:a}=this,c=!a,i=e+s*Math.cos(o),l=t+n*Math.sin(o),y=e+s*Math.cos(h),p=t+n*Math.sin(h),x=Math.abs(o-h),f=x>Math.PI?1:0,g=c?0:1,m=e+s*Math.cos(o+(h-o)/2),T=t+n*Math.sin(o+(h-o)/2);return x>=2*Math.PI?[{type:"M",x:i,y:l},{type:"A",rx:s,ry:n,angle:0,largeArcFlag:1,sweepFlag:g,x:m,y:T},{type:"A",rx:s,ry:n,angle:0,largeArcFlag:1,sweepFlag:g,x:i,y:l}]:[{type:"M",x:i,y:l},{type:"A",rx:s,ry:n,angle:0,largeArcFlag:f,sweepFlag:g,x:y,y:p}]}drawTo(e){const{x:t,y:s,radiusX:n,radiusY:o,rotation:h,startAngle:a,endAngle:c,clockwise:i}=this,l=t+n*Math.cos(a),y=s+o*Math.sin(a);return e.moveTo(l,y),e.ellipse(t,s,n,o,h,a,c,!i),this}transform(e){return R.set(this.x,this.y),R.applyMatrix3(e),this.x=R.x,this.y=R.y,Nt(e)?Lt(this,e):St(this,e),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function Lt(r,e){const t=r.radiusX,s=r.radiusY,n=Math.cos(r.rotation),o=Math.sin(r.rotation),h=new u(t*n,t*o),a=new u(-s*o,s*n),c=h.applyMatrix3(e),i=a.applyMatrix3(e),l=kt.set(c.x,i.x,0,c.y,i.y,0,0,0,1),y=J.copy(l).invert(),f=K.copy(y).transpose().multiply(y).elements,g=Et(f[0],f[1],f[4]),m=Math.sqrt(g.rt1),T=Math.sqrt(g.rt2);if(r.radiusX=1/m,r.radiusY=1/T,r.rotation=Math.atan2(g.sn,g.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=J.set(m,0,0,0,T,0,0,0,1),A=K.set(g.cs,g.sn,0,-g.sn,g.cs,0,0,0,1),b=P.multiply(A).multiply(l),$=z=>{const{x:Y,y:V}=new u(Math.cos(z),Math.sin(z)).applyMatrix3(b);return Math.atan2(V,Y)};r.startAngle=$(r.startAngle),r.endAngle=$(r.endAngle),et(e)&&(r.clockwise=!r.clockwise)}}function St(r,e){const t=st(e),s=nt(e);r.radiusX*=t,r.radiusY*=s;const n=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=n,et(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function et(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function Nt(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=st(r),n=nt(r);return Math.abs(t/(s*n))>Number.EPSILON}function st(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function nt(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Et(r,e,t){let s,n,o,h,a;const c=r+t,i=r-t,l=Math.sqrt(i*i+4*e*e);return c>0?(s=.5*(c+l),a=1/s,n=r*a*t-e*a*e):c<0?n=.5*(c-l):(s=.5*l,n=-.5*l),i>0?o=i+l:o=i-l,Math.abs(o)>2*Math.abs(e)?(a=-2*e/o,h=1/Math.sqrt(1+a*a),o=a*h):Math.abs(e)===0?(o=1,h=0):(a=-.5*o/e,o=1/Math.sqrt(1+a*a),h=a*o),i>0&&(a=o,o=-h,h=a),{rt1:s,rt2:n,cs:o,sn:h}}class q extends k{constructor(e=new u,t=new u){super(),this.v1=e,this.v2=t}getPoint(e,t=new u){return e===1?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t=new u){return this.getPoint(e,t)}getTangent(e,t=new u){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t=new u){return this.getTangent(e,t)}transform(e){return this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getDivisions(){return 1}getMinMax(e=u.MAX,t=u.MIN){const{v1:s,v2:n}=this;return e.x=Math.min(e.x,s.x,n.x),e.y=Math.min(e.y,s.y,n.y),t.x=Math.max(t.x,s.x,n.x),t.y=Math.max(t.y,s.y,n.y),{min:e,max:t}}getCommands(){const{v1:e,v2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{v2:t}=this;return e.lineTo(t.x,t.y),this}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class $t extends k{constructor(t,s,n=0,o=1){super();w(this,"curves");w(this,"pointT",0);this.center=t,this.size=s,this.start=n,this.end=o;const{x:h,y:a}=this.center,c=new u(h+.5*this.size,a-.5*this.size),i=new u(h-.5*this.size,a-.5*this.size),l=new u(h,a+.5*this.size),y=new O(c,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),p=new O(i,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),x=new O(l,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),f=new u(h,a+this.size),g=new u(h+this.size,a),m=new u().lerpVectors(g,f,.75),T=new u(h-this.size,a),C=new u().lerpVectors(T,f,.75),P=new q(g,m),A=new q(C,T);this.curves=[y,P,x,A,p]}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let n;const o=.5*Math.PI;return s<o?(n=0,this.pointT=s/o):s<o+.75?(n=1,this.pointT=(s-o)/.75):s<5*Math.PI/8+.75?(n=2,this.pointT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(n=3,this.pointT=(s-5*Math.PI/8-.75)/.75):(n=4,this.pointT=(s-5*Math.PI/8-1.5)/o),this.curves[n]}getTangent(t){return this.getCurrentLine(t).getTangent(this.pointT).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new u(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}transform(t){return this.curves.forEach(s=>s.transform(t)),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class zt extends k{constructor(t,s=0,n=0,o=0,h=1){super();w(this,"curves",[]);w(this,"points",[]);this.center=t,this.radius=s,this.num=n,this.start=o,this.end=h;for(let a=0;a<this.num;a++){let c=a*2*Math.PI/this.num;c-=.5*Math.PI;const i=new u(this.radius*Math.cos(c),this.radius*Math.sin(c));i.add(this.center),this.points.push(i)}for(let a=0;a<this.num;a++)this.curves.push(new q(this.points[a],this.points[(a+1)%this.num]))}getPoint(t){return this.getCurrentLine(t),this.currentLine.getPoint(this.pointK)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const n=s*this.num,o=Math.floor(n);return this.pointK=n-o,this.currentLine=this.curves[o],this.currentLine}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new u(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}transform(t){return this.curves.forEach(s=>s.transform(t)),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class it extends k{constructor(e=new u,t=new u,s=new u){super(),this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new u){const{v0:s,v1:n,v2:o}=this;return t.set(H(e,s.x,n.x,o.x),H(e,s.y,n.y,o.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getMinMax(e=u.MAX,t=u.MIN){const{v0:s,v1:n,v2:o}=this,h=.5*(s.x+n.x),a=.5*(s.y+n.y),c=.5*(s.x+o.x),i=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,h,c),e.y=Math.min(e.y,s.y,o.y,a,i),t.x=Math.max(t.x,s.x,o.x,h,c),t.y=Math.max(t.y,s.y,o.y,a,i),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{v1:t,v2:s}=this;return e.quadraticCurveTo(t.x,t.y,s.x,s.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class rt extends k{constructor(t,s,n=1,o=0,h=1){super();w(this,"curves",[]);w(this,"pointT",0);this.center=t,this.rx=s,this.aspectRatio=n,this.start=o,this.end=h;const{x:a,y:c}=this.center,i=this.rx,l=this.rx/this.aspectRatio,y=[new u(a-i,c-l),new u(a+i,c-l),new u(a+i,c+l),new u(a-i,c+l)];for(let p=0;p<4;p++)this.curves.push(new q(y[p].clone(),y[(p+1)%4].clone()))}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let n;return s<this.aspectRatio?(n=0,this.pointT=s/this.aspectRatio):s<this.aspectRatio+1?(n=1,this.pointT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(n=2,this.pointT=(s-this.aspectRatio-1)/this.aspectRatio):(n=3,this.pointT=(s-2*this.aspectRatio-1)/1),this.curves[n]}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const{v1:s,v2:n}=this.getCurrentLine(t);return new u(n.y-s.y,-(n.x-s.x)).normalize()}transform(t){return this.curves.forEach(s=>s.transform(t)),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ot extends k{constructor(e=[]){super(),this.points=e}getDivisions(e=12){return e*this.points.length}getPoint(e,t=new u){const{points:s}=this,n=(s.length-1)*e,o=Math.floor(n),h=n-o,a=s[o===0?o:o-1],c=s[o],i=s[o>s.length-2?s.length-1:o+1],l=s[o>s.length-3?s.length-1:o+2];return t.set(W(h,a.x,c.x,i.x,l.x),W(h,a.y,c.y,i.y,l.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class X extends k{constructor(t){super();w(this,"curves",[]);w(this,"currentPoint",new u);w(this,"autoClose",!1);w(this,"_cacheLengths",[]);t&&this.setFromPoints(t)}addCurve(t){return this.curves.push(t),this}closePath(){const t=this.curves[0].getPoint(0),s=this.curves[this.curves.length-1].getPoint(1);return t.equals(s)||this.curves.push(new q(s,t)),this}getPoint(t,s=new u){const n=t*this.getLength(),o=this.getCurveLengths();let h=0;for(;h<o.length;){if(o[h]>=n){const a=o[h]-n,c=this.curves[h],i=c.getLength();return c.getPointAt(i===0?0:1-a/i,s)}h++}return s}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let n=0,o=this.curves.length;n<o;n++)s+=this.curves[n].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let n=0;n<=t;n++)s.push(this.getPoint(n/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[];let n;for(let o=0,h=this.curves;o<h.length;o++){const a=h[o],c=a.getPoints(a.getDivisions(t));for(let i=0;i<c.length;i++){const l=c[i];n&&n.equals(l)||(s.push(l),n=l)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,n=t.length;s<n;s++)this.lineTo(t[s].x,t[s].y);return this}bezierCurveTo(t,s,n,o,h,a){return this.curves.push(new Z(this.currentPoint.clone(),new u(t,s),new u(n,o),new u(h,a))),this.currentPoint.set(h,a),this}lineTo(t,s){return this.curves.push(new q(this.currentPoint.clone(),new u(t,s))),this.currentPoint.set(t,s),this}moveTo(t,s){return this.currentPoint.set(t,s),this}quadraticCurveTo(t,s,n,o){return this.curves.push(new it(this.currentPoint.clone(),new u(t,s),new u(n,o))),this.currentPoint.set(n,o),this}rect(t,s,n,o){return this.curves.push(new rt(new u(t+n/2,s+o/2),n/2,n/o)),this.currentPoint.set(t,s),this}splineThru(t){const s=[this.currentPoint.clone()].concat(t);return this.curves.push(new ot(s)),this.currentPoint.copy(t[t.length-1]),this}arc(t,s,n,o,h,a=!1){const c=this.currentPoint;return this.absarc(t+c.x,s+c.y,n,o,h,a),this}absarc(t,s,n,o,h,a=!1){return this.absellipse(t,s,n,n,o,h,a),this}ellipse(t,s,n,o,h,a,c=!1,i=0){const l=this.currentPoint;return this.absellipse(t+l.x,s+l.y,n,o,h,a,c,i),this}absellipse(t,s,n,o,h,a,c=!1,i=0){const l=new tt(t,s,n,o,h,a,c,i);if(this.curves.length>0){const y=l.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(l),this.currentPoint.copy(l.getPoint(1)),this}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}drawTo(t){var n;const s=(n=this.curves[0])==null?void 0:n.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,n=t.curves.length;s<n;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}class L{constructor(e){w(this,"currentPath",new X);w(this,"paths",[this.currentPath]);w(this,"userData");e&&(e instanceof L?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}addPath(e){return e instanceof L?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){return this.currentPath.closePath(),this}moveTo(e,t){const{currentPoint:s,curves:n}=this.currentPath;return(s.x!==e||s.y!==t)&&(n.length?(this.currentPath=new X().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,n,o,h){return this.currentPath.bezierCurveTo(e,t,s,n,o,h),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}arc(e,t,s,n,o,h){return this.currentPath.absarc(e,t,s,n,o,!h),this}arcTo(e,t,s,n,o){const h=this.currentPath.currentPoint,a=h.x,c=h.y,i=e-a,l=t-c,y=s-e,p=n-t,x=Math.sqrt(i*i+l*l),f=Math.sqrt(y*y+p*p);if(x<o||f<o)return this.lineTo(s,n),this;const g={x:i/x,y:l/x},m={x:y/f,y:p/f},T=e-g.y*o,C=t+g.x*o,P=Math.atan2(g.y,g.x);let b=Math.atan2(m.y,m.x)-P;return b>Math.PI?b-=2*Math.PI:b<-Math.PI&&(b+=2*Math.PI),this.arc(T,C,o,P,P+b,!1),this.lineTo(s,n),this}ellipse(e,t,s,n,o,h,a,c){return this.currentPath.absellipse(e,t,s,n,h,a,!c,o),this}rect(e,t,s,n){return this.currentPath.rect(e,t,s,n),this}addCommands(e){return xt(e,this),this}addData(e){return this.addCommands(dt(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}forEachCurve(e){return this.paths.forEach(t=>t.curves.forEach(s=>e(s))),this}transform(e){return this.forEachCurve(t=>t.transform(e)),this}getMinMax(e=u.MAX,t=u.MIN){return this.forEachCurve(s=>s.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new S(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return this.paths.flatMap(e=>e.curves.flatMap(t=>t.getCommands()))}getData(){return this.paths.map(e=>e.getData()).join(" ")}getSvgString(){const{x:e,y:t,width:s,height:n}=this.getBoundingBox();return`<svg viewBox="${e} ${t} ${s} ${n}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`}getSvgDataUri(){return`data:image/svg+xml;base64,${btoa(this.getSvgString())}`}drawTo(e){this.paths.forEach(t=>{t.drawTo(e)})}strokeTo(e){this.drawTo(e),e.stroke()}fillTo(e){this.drawTo(e),e.fill()}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.userData=e.userData,this}toCanvas(e=!0){const t=document.createElement("canvas"),{left:s,top:n,width:o,height:h}=this.getBoundingBox();t.width=o,t.height=h;const a=t.getContext("2d");return a&&(a.translate(-s,-n),e?this.fillTo(a):this.strokeTo(a)),t}clone(){return new this.constructor().copy(this)}}const G="px",at=90,ht=["mm","cm","in","pt","pc","px"],_={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function v(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,n=ht.length;s<n;s++){const o=ht[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&G!=="px"?t=_.in[G]/at:(t=_[e][G],t<0&&(t=_[e].in*at)),t*Number.parseFloat(r)}const qt=new I,F=new I,ct=new I,lt=new I;function Dt(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=Xt(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Xt(r){const e=new I,t=qt;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(v(r.getAttribute("x")),v(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let n=s.length-1;n>=0;n--){const o=s[n].trim();if(o==="")continue;const h=o.indexOf("("),a=o.length;if(h>0&&h<a){const c=o.slice(0,h),i=N(o.slice(h+1));switch(t.identity(),c){case"translate":if(i.length>=1){const l=i[0];let y=0;i.length>=2&&(y=i[1]),t.translate(l,y)}break;case"rotate":if(i.length>=1){let l=0,y=0,p=0;l=i[0]*Math.PI/180,i.length>=3&&(y=i[1],p=i[2]),F.makeTranslation(-y,-p),ct.makeRotation(l),lt.multiplyMatrices(ct,F),F.makeTranslation(y,p),t.multiplyMatrices(F,lt)}break;case"scale":i.length>=1&&t.scale(i[0],i[1]??i[0]);break;case"skewX":i.length===1&&t.set(1,Math.tan(i[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":i.length===1&&t.set(1,0,0,Math.tan(i[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":i.length===6&&t.set(i[0],i[2],i[4],i[1],i[3],i[5],0,0,1);break}}e.premultiply(t)}}return e}function Ot(r){return new L().addPath(new X().absarc(v(r.getAttribute("cx")||0),v(r.getAttribute("cy")||0),v(r.getAttribute("r")||0),0,Math.PI*2))}function Rt(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const n=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<n.length;o++){const h=Object.fromEntries(Object.entries(s.style).filter(([,a])=>a!==""));e[n[o]]=Object.assign(e[n[o]]||{},h)}}}function Ft(r){return new L().addPath(new X().absellipse(v(r.getAttribute("cx")||0),v(r.getAttribute("cy")||0),v(r.getAttribute("rx")||0),v(r.getAttribute("ry")||0),0,Math.PI*2))}function Yt(r){return new L().moveTo(v(r.getAttribute("x1")||0),v(r.getAttribute("y1")||0)).lineTo(v(r.getAttribute("x2")||0),v(r.getAttribute("y2")||0))}function Ut(r){const e=new L,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Gt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function _t(r){var s;const e=new L;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Gt,(n,o,h)=>{const a=v(o),c=v(h);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,n}),e.currentPath.autoClose=!0,e}const Qt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Vt(r){var s;const e=new L;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Qt,(n,o,h)=>{const a=v(o),c=v(h);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,n}),e.currentPath.autoClose=!1,e}function Bt(r){const e=v(r.getAttribute("x")||0),t=v(r.getAttribute("y")||0),s=v(r.getAttribute("rx")||r.getAttribute("ry")||0),n=v(r.getAttribute("ry")||r.getAttribute("rx")||0),o=v(r.getAttribute("width")),h=v(r.getAttribute("height")),a=1-.551915024494,c=new L;return c.moveTo(e+s,t),c.lineTo(e+o-s,t),(s!==0||n!==0)&&c.bezierCurveTo(e+o-s*a,t,e+o,t+n*a,e+o,t+n),c.lineTo(e+o,t+h-n),(s!==0||n!==0)&&c.bezierCurveTo(e+o,t+h-n*a,e+o-s*a,t+h,e+o-s,t+h),c.lineTo(e+s,t+h),(s!==0||n!==0)&&c.bezierCurveTo(e+s*a,t+h,e,t+h-n*a,e,t+h-n),c.lineTo(e,t+n),(s!==0||n!==0)&&c.bezierCurveTo(e,t+n*a,e+s*a,t,e+s,t),c}function E(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const a=r.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<a.length;c++)s=Object.assign(s,t[`.${a[c]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function n(a,c,i){i===void 0&&(i=function(y){return y.startsWith("url")&&console.warn("url access in attributes is not implemented."),y}),r.hasAttribute(a)&&(e[c]=i(r.getAttribute(a))),s[a]&&(e[c]=i(s[a])),r.style&&r.style[a]!==""&&(e[c]=i(r.style[a]))}function o(a){return Math.max(0,Math.min(1,v(a)))}function h(a){return Math.max(0,v(a))}return n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-dashoffset","strokeDashoffset"),n("stroke-dasharray","strokeDasharray"),n("stroke-linecap","strokeLineCap"),n("stroke-linejoin","strokeLineJoin"),n("stroke-miterlimit","strokeMiterLimit",h),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",h),n("visibility","visibility"),e}function Q(r,e,t=[]){var l;if(r.nodeType!==1)return t;let s=!1,n=null;const o={};switch(r.nodeName){case"svg":e=E(r,e,o);break;case"style":Rt(r,o);break;case"g":e=E(r,e,o);break;case"path":e=E(r,e,o),r.hasAttribute("d")&&(n=Ut(r));break;case"rect":e=E(r,e,o),n=Bt(r);break;case"polygon":e=E(r,e,o),n=_t(r);break;case"polyline":e=E(r,e,o),n=Vt(r);break;case"circle":e=E(r,e,o),n=Ot(r);break;case"ellipse":e=E(r,e,o),n=Ft(r);break;case"line":e=E(r,e,o),n=Yt(r);break;case"defs":s=!0;break;case"use":{e=E(r,e,o);const p=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),x=(l=r.viewportElement)==null?void 0:l.getElementById(p);x?Q(x,e,t):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(r);break}const h=new I,a=[],c=Dt(r,h,a);n&&(n.transform(h),t.push(n),n.userData={node:r,style:e});const i=r.childNodes;for(let y=0,p=i.length;y<p;y++){const x=i[y];s&&x.nodeName!=="style"&&x.nodeName!=="defs"||Q(x,e,t)}return c&&(a.pop(),a.length>0?h.copy(a[a.length-1]):h.identity()),t}const ut="data:image/svg+xml;",yt=`${ut}base64,`,ft=`${ut}charset=utf8,`;function Wt(r){let e,t;return typeof r=="string"?(r.startsWith(yt)?(r=r.substring(yt.length,r.length),t=atob(r)):r.startsWith(ft)?(r=r.substring(ft.length,r.length),t=decodeURIComponent(r)):t=r,e=new DOMParser().parseFromString(t,"image/svg+xml").documentElement):e=r,Q(e,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4})}M.BoundingBox=S,M.CircleCurve=O,M.CubicBezierCurve=Z,M.Curve=k,M.CurvePath=X,M.EllipseCurve=tt,M.HeartCurve=$t,M.LineCurve=q,M.Matrix3=I,M.Path2D=L,M.PloygonCurve=zt,M.Point2D=u,M.QuadraticBezierCurve=it,M.RectangularCurve=rt,M.SplineCurve=ot,M.parseSvg=Wt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(M=typeof globalThis<"u"?globalThis:M||self,l(M.modernPath2d={}))})(this,function(M){"use strict";var jt=Object.defineProperty;var Zt=(M,l,A)=>l in M?jt(M,l,{enumerable:!0,configurable:!0,writable:!0,value:A}):M[l]=A;var P=(M,l,A)=>Zt(M,typeof l!="symbol"?l+"":l,A);class l{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new l(1/0,1/0)}static get MIN(){return new l(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}multiplyScalar(e){return this.x*=e,this.y*=e,this}divideScalar(e){return this.multiplyScalar(1/e)}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}normalize(){return this.divideScalar(this.length()||1)}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new l(this.x,this.y)}}class A{constructor(e=0,t=0,s=0,n=0){this.left=e,this.top=t,this.width=s,this.height=n}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){const t=e[0],s=e.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{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 A(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new l((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new A(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class C{constructor(e=1,t=0,s=0,n=0,o=1,c=0,h=0,a=0,i=1){P(this,"elements",[]);this.set(e,t,s,n,o,c,h,a,i)}set(e,t,s,n,o,c,h,a,i){const u=this.elements;return u[0]=e,u[1]=n,u[2]=h,u[3]=t,u[4]=o,u[5]=a,u[6]=s,u[7]=c,u[8]=i,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,o=this.elements,c=s[0],h=s[3],a=s[6],i=s[1],u=s[4],y=s[7],g=s[2],x=s[5],f=s[8],p=n[0],m=n[3],T=n[6],E=n[1],w=n[4],b=n[7],L=n[2],$=n[5],z=n[8];return o[0]=c*p+h*E+a*L,o[3]=c*m+h*w+a*$,o[6]=c*T+h*b+a*z,o[1]=i*p+u*E+y*L,o[4]=i*m+u*w+y*$,o[7]=i*T+u*b+y*z,o[2]=g*p+x*E+f*L,o[5]=g*m+x*w+f*$,o[8]=g*T+x*b+f*z,this}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],o=e[3],c=e[4],h=e[5],a=e[6],i=e[7],u=e[8],y=u*c-h*i,g=h*a-u*o,x=i*o-c*a,f=t*y+s*g+n*x;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/f;return e[0]=y*p,e[1]=(n*i-u*s)*p,e[2]=(h*s-n*c)*p,e[3]=g*p,e[4]=(u*t-n*a)*p,e[5]=(n*o-h*t)*p,e[6]=x*p,e[7]=(s*a-i*t)*p,e[8]=(c*t-s*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(Y.makeScale(e,t)),this}rotate(e){return this.premultiply(Y.makeRotation(-e)),this}translate(e,t){return this.premultiply(Y.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Y=new C;function W(r,e,t,s){const n=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let c=Math.acos(Math.max(-1,Math.min(1,n/o)));return r*s-e*t<0&&(c=-c),c}function xt(r,e,t,s,n,o,c,h){if(e===0||t===0){r.lineTo(h.x,h.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const a=(c.x-h.x)/2,i=(c.y-h.y)/2,u=Math.cos(s)*a+Math.sin(s)*i,y=-Math.sin(s)*a+Math.cos(s)*i;let g=e*e,x=t*t;const f=u*u,p=y*y,m=f/g+p/x;if(m>1){const pt=Math.sqrt(m);e=pt*e,t=pt*t,g=e*e,x=t*t}const T=g*p+x*f,E=(g*x-T)/T;let w=Math.sqrt(Math.max(0,E));n===o&&(w=-w);const b=w*e*y/t,L=-w*t*u/e,$=Math.cos(s)*b-Math.sin(s)*L+(c.x+h.x)/2,z=Math.sin(s)*b+Math.cos(s)*L+(c.y+h.y)/2,U=W(1,0,(u-b)/e,(y-L)/t),Q=W((u-b)/e,(y-L)/t,(-u-b)/e,(-y-L)/t)%(Math.PI*2);r.currentPath.absellipse($,z,e,t,U,U+Q,o===0,s)}function D(r,e){return r-(e-r)}function Mt(r,e){const t=new l,s=new l,n=new l;let o=!0,c=!1;for(let h=0,a=r.length;h<a;h++){const i=r[h];if(o&&(c=!0,o=!1),i.type==="m"||i.type==="M")i.type==="m"?(t.x+=i.x,t.y+=i.y):(t.x=i.x,t.y=i.y),s.x=t.x,s.y=t.y,e.moveTo(t.x,t.y),n.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),c&&n.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),c&&n.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?(t.x+=i.x,t.y+=i.y):(t.x=i.x,t.y=i.y),s.x=t.x,s.y=t.y,e.lineTo(t.x,t.y),c&&n.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.x+=i.x,t.y+=i.y):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.x=i.x,t.y=i.y),c&&n.copy(t);else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.x+=i.x,t.y+=i.y):(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.x=i.x,t.y=i.y),c&&n.copy(t);else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),s.x=t.x+i.x1,s.y=t.y+i.y1,t.x+=i.x,t.y+=i.y):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),s.x=i.x1,s.y=i.y1,t.x=i.x,t.y=i.y),c&&n.copy(t);else if(i.type==="t"||i.type==="T"){const u=D(t.x,s.x),y=D(t.y,s.y);s.x=u,s.y=y,i.type==="t"?(e.quadraticCurveTo(u,y,t.x+i.x,t.y+i.y),t.x+=i.x,t.y+=i.y):(e.quadraticCurveTo(u,y,i.x,i.y),t.x=i.x,t.y=i.y),c&&n.copy(t)}else if(i.type==="a"||i.type==="A"){if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.x+=i.x,t.y+=i.y}else{if(i.x===t.x&&i.y===t.y)continue;t.x=i.x,t.y=i.y}const u=t.clone();s.x=t.x,s.y=t.y,xt(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,u,t),c&&n.copy(t)}else i.type==="z"||i.type==="Z"?(e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(t.copy(n),e.currentPath.currentPoint.copy(t),o=!0)):console.warn("Unsupported commands",i);c=!1}}const d={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function S(r,e,t=0){let h=0,a=!0,i="",u="";const y=[];function g(m,T,E){const w=new SyntaxError(`Unexpected character "${m}" at index ${T}.`);throw w.partial=E,w}function x(){i!==""&&(u===""?y.push(Number(i)):y.push(Number(i)*10**Number(u))),i="",u=""}let f;const p=r.length;for(let m=0;m<p;m++){if(f=r[m],Array.isArray(e)&&e.includes(y.length%t)&&d.FLAGS.test(f)){h=1,i=f,x();continue}if(h===0){if(d.WHITESPACE.test(f))continue;if(d.DIGIT.test(f)||d.SIGN.test(f)){h=1,i=f;continue}if(d.POINT.test(f)){h=2,i=f;continue}d.COMMA.test(f)&&(a&&g(f,m,y),a=!0)}if(h===1){if(d.DIGIT.test(f)){i+=f;continue}if(d.POINT.test(f)){i+=f,h=2;continue}if(d.EXP.test(f)){h=3;continue}d.SIGN.test(f)&&i.length===1&&d.SIGN.test(i[0])&&g(f,m,y)}if(h===2){if(d.DIGIT.test(f)){i+=f;continue}if(d.EXP.test(f)){h=3;continue}d.POINT.test(f)&&i[i.length-1]==="."&&g(f,m,y)}if(h===3){if(d.DIGIT.test(f)){u+=f;continue}if(d.SIGN.test(f)){if(u===""){u+=f;continue}u.length===1&&d.SIGN.test(u)&&g(f,m,y)}}d.WHITESPACE.test(f)?(x(),h=0,a=!1):d.COMMA.test(f)?(x(),h=0,a=!0):d.SIGN.test(f)?(x(),h=1,i=f):d.POINT.test(f)?(x(),h=2,i=f):g(f,m,y)}return x(),y}function mt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function vt(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${mt(r[t])} `;return e}const dt=/[a-df-z][^a-df-z]*/gi;function Pt(r){const e=[],t=r.match(dt);if(!t)return e;for(let s=0,n=t.length;s<n;s++){const o=t[s],c=o.charAt(0),h=o.slice(1).trim();let a;switch(c){case"m":case"M":a=S(h);for(let i=0,u=a.length;i<u;i+=2)i===0?e.push({type:c,x:a[i],y:a[i+1]}):e.push({type:c==="m"?"l":"L",x:a[i],y:a[i+1]});break;case"h":case"H":a=S(h);for(let i=0,u=a.length;i<u;i++)e.push({type:c,x:a[i]});break;case"v":case"V":a=S(h);for(let i=0,u=a.length;i<u;i++)e.push({type:c,y:a[i]});break;case"l":case"L":a=S(h);for(let i=0,u=a.length;i<u;i+=2)e.push({type:c,x:a[i],y:a[i+1]});break;case"c":case"C":a=S(h);for(let i=0,u=a.length;i<u;i+=6)e.push({type:c,x1:a[i],y1:a[i+1],x2:a[i+2],y2:a[i+3],x:a[i+4],y:a[i+5]});break;case"s":case"S":a=S(h);for(let i=0,u=a.length;i<u;i+=4)e.push({type:c,x2:a[i],y2:a[i+1],x:a[i+2],y:a[i+3]});break;case"q":case"Q":a=S(h);for(let i=0,u=a.length;i<u;i+=4)e.push({type:c,x1:a[i],y1:a[i+1],x:a[i+2],y:a[i+3]});break;case"t":case"T":a=S(h);for(let i=0,u=a.length;i<u;i+=2)e.push({type:c,x:a[i],y:a[i+1]});break;case"a":case"A":a=S(h,[3,4],7);for(let i=0,u=a.length;i<u;i+=7)e.push({type:c,rx:a[i],ry:a[i+1],angle:a[i+2],largeArcFlag:a[i+3],sweepFlag:a[i+4],x:a[i+5],y:a[i+6]});break;case"z":case"Z":e.push({type:c});break;default:console.warn(o)}}return e}class I{constructor(){P(this,"arcLengthDivisions",200);P(this,"_cacheArcLengths");P(this,"_needsUpdate",!1)}getPointAt(e,t=new l){return this.getPoint(this.getUtoTmapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,n=this.getPoint(0),o=0;t.push(0);for(let c=1;c<=e;c++)s=this.getPoint(c/e),o+=s.distanceTo(n),t.push(o),n=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let n=0;const o=s.length;let c;t?c=t:c=e*s[o-1];let h=0,a=o-1,i;for(;h<=a;)if(n=Math.floor(h+(a-h)/2),i=s[n]-c,i<0)h=n+1;else if(i>0)a=n-1;else{a=n;break}if(n=a,s[n]===c)return n/(o-1);const u=s[n],g=s[n+1]-u,x=(c-u)/g;return(n+x)/(o-1)}getTangent(e,t=new l){let n=e-1e-4,o=e+1e-4;return n<0&&(n=0),o>1&&(o=1),t.copy(this.getPoint(o)).sub(this.getPoint(n)).normalize()}getTangentAt(e,t=new l){return this.getTangent(this.getUtoTmapping(e),t)}transform(e){return this}getDivisions(e){return e}getMinMax(e=l.MAX,t=l.MIN){return this.getPoints().forEach(s=>{e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),t.x=Math.max(t.x,s.x),t.y=Math.max(t.y,s.y)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new A(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return[]}getData(){return vt(this.getCommands())}drawTo(e){return this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class O extends I{constructor(e,t,s=0,n=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=n}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().multiplyScalar(t))}getTangent(e){const{x:t,y:s}=this.getNormal(e);return new l(-s,t)}getNormal(e){const{start:t,end:s}=this,n=e*(s-t)+t-.5*Math.PI;return new l(Math.cos(n),Math.sin(n))}getMinMax(e=l.MAX,t=l.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function H(r,e,t,s,n){const o=(s-e)*.5,c=(n-t)*.5,h=r*r,a=r*h;return(2*t-2*s+o+c)*a+(-3*t+3*s-2*o-c)*h+o*r+t}function Tt(r,e){const t=1-r;return t*t*e}function wt(r,e){return 2*(1-r)*r*e}function bt(r,e){return r*r*e}function V(r,e,t,s){return Tt(r,e)+wt(r,t)+bt(r,s)}function At(r,e){const t=1-r;return t*t*t*e}function Ct(r,e){const t=1-r;return 3*t*t*r*e}function It(r,e){return 3*(1-r)*r*r*e}function kt(r,e){return r*r*r*e}function j(r,e,t,s,n){return At(r,e)+Ct(r,t)+It(r,s)+kt(r,n)}class Z extends I{constructor(e=new l,t=new l,s=new l,n=new l){super(),this.v0=e,this.v1=t,this.v2=s,this.v3=n}getPoint(e,t=new l){const{v0:s,v1:n,v2:o,v3:c}=this;return t.set(j(e,s.x,n.x,o.x,c.x),j(e,s.y,n.y,o.y,c.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this.v3.applyMatrix3(e),this}getMinMax(e=l.MAX,t=l.MIN){const{v0:s,v1:n,v2:o,v3:c}=this;return e.x=Math.min(e.x,s.x,n.x,o.x,c.x),e.y=Math.min(e.y,s.y,n.y,o.y,c.y),t.x=Math.max(t.x,s.x,n.x,o.x,c.x),t.y=Math.max(t.y,s.y,n.y,o.y,c.y),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s,v3:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:n.x,y:n.y}]}drawTo(e){const{v1:t,v2:s,v3:n}=this;return e.bezierCurveTo(t.x,t.y,s.x,s.y,n.x,n.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}}const Lt=new C,J=new C,K=new C,R=new l;class tt extends I{constructor(e=0,t=0,s=1,n=1,o=0,c=Math.PI*2,h=!1,a=0){super(),this.x=e,this.y=t,this.radiusX=s,this.radiusY=n,this.startAngle=o,this.endAngle=c,this.clockwise=h,this.rotation=a}getPoint(e,t=new l){const s=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(o?n=0:n=s),this.clockwise&&!o&&(n===s?n=-s:n=n-s);const c=this.startAngle+e*n;let h=this.x+this.radiusX*Math.cos(c),a=this.y+this.radiusY*Math.sin(c);if(this.rotation!==0){const i=Math.cos(this.rotation),u=Math.sin(this.rotation),y=h-this.x,g=a-this.y;h=y*i-g*u+this.x,a=y*u+g*i+this.y}return t.set(h,a)}getDivisions(e=12){return e*2}getCommands(){const{x:e,y:t,radiusX:s,radiusY:n,startAngle:o,endAngle:c,clockwise:h,rotation:a}=this,i=e+s*Math.cos(o)*Math.cos(a)-n*Math.sin(o)*Math.sin(a),u=t+s*Math.cos(o)*Math.sin(a)+n*Math.sin(o)*Math.cos(a),y=Math.abs(o-c),g=y>Math.PI?1:0,x=h?1:0,f=a*180/Math.PI;if(y>=2*Math.PI){const p=o+Math.PI,m=e+s*Math.cos(p)*Math.cos(a)-n*Math.sin(p)*Math.sin(a),T=t+s*Math.cos(p)*Math.sin(a)+n*Math.sin(p)*Math.cos(a);return[{type:"M",x:i,y:u},{type:"A",rx:s,ry:n,angle:f,largeArcFlag:0,sweepFlag:x,x:m,y:T},{type:"A",rx:s,ry:n,angle:f,largeArcFlag:0,sweepFlag:x,x:i,y:u}]}else{const p=e+s*Math.cos(c)*Math.cos(a)-n*Math.sin(c)*Math.sin(a),m=t+s*Math.cos(c)*Math.sin(a)+n*Math.sin(c)*Math.cos(a);return[{type:"M",x:i,y:u},{type:"A",rx:s,ry:n,angle:f,largeArcFlag:g,sweepFlag:x,x:p,y:m}]}}drawTo(e){const{x:t,y:s,radiusX:n,radiusY:o,rotation:c,startAngle:h,endAngle:a,clockwise:i}=this;return e.ellipse(t,s,n,o,c,h,a,!i),this}transform(e){return R.set(this.x,this.y),R.applyMatrix3(e),this.x=R.x,this.y=R.y,Et(e)?St(this,e):Nt(this,e),this}getMinMax(e=l.MAX,t=l.MIN){const{x:s,y:n,radiusX:o,radiusY:c,rotation:h}=this,a=Math.cos(h),i=Math.sin(h),u=Math.sqrt(o*o*a*a+c*c*i*i),y=Math.sqrt(o*o*i*i+c*c*a*a);return e.x=Math.min(e.x,s-u),e.y=Math.min(e.y,n-y),t.x=Math.max(t.x,s+u),t.y=Math.max(t.y,n+y),{min:e,max:t}}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function St(r,e){const t=r.radiusX,s=r.radiusY,n=Math.cos(r.rotation),o=Math.sin(r.rotation),c=new l(t*n,t*o),h=new l(-s*o,s*n),a=c.applyMatrix3(e),i=h.applyMatrix3(e),u=Lt.set(a.x,i.x,0,a.y,i.y,0,0,0,1),y=J.copy(u).invert(),f=K.copy(y).transpose().multiply(y).elements,p=$t(f[0],f[1],f[4]),m=Math.sqrt(p.rt1),T=Math.sqrt(p.rt2);if(r.radiusX=1/m,r.radiusY=1/T,r.rotation=Math.atan2(p.sn,p.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=J.set(m,0,0,0,T,0,0,0,1),b=K.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),L=w.multiply(b).multiply(u),$=z=>{const{x:U,y:Q}=new l(Math.cos(z),Math.sin(z)).applyMatrix3(L);return Math.atan2(Q,U)};r.startAngle=$(r.startAngle),r.endAngle=$(r.endAngle),et(e)&&(r.clockwise=!r.clockwise)}}function Nt(r,e){const t=st(e),s=nt(e);r.radiusX*=t,r.radiusY*=s;const n=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=n,et(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function et(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function Et(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=st(r),n=nt(r);return Math.abs(t/(s*n))>Number.EPSILON}function st(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function nt(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function $t(r,e,t){let s,n,o,c,h;const a=r+t,i=r-t,u=Math.sqrt(i*i+4*e*e);return a>0?(s=.5*(a+u),h=1/s,n=r*h*t-e*h*e):a<0?n=.5*(a-u):(s=.5*u,n=-.5*u),i>0?o=i+u:o=i-u,Math.abs(o)>2*Math.abs(e)?(h=-2*e/o,c=1/Math.sqrt(1+h*h),o=h*c):Math.abs(e)===0?(o=1,c=0):(h=-.5*o/e,o=1/Math.sqrt(1+h*h),c=h*o),i>0&&(h=o,o=-c,c=h),{rt1:s,rt2:n,cs:o,sn:c}}class q extends I{constructor(e=new l,t=new l){super(),this.v1=e,this.v2=t}getPoint(e,t=new l){return e===1?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t=new l){return this.getPoint(e,t)}getTangent(e,t=new l){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t=new l){return this.getTangent(e,t)}transform(e){return this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getDivisions(){return 1}getMinMax(e=l.MAX,t=l.MIN){const{v1:s,v2:n}=this;return e.x=Math.min(e.x,s.x,n.x),e.y=Math.min(e.y,s.y,n.y),t.x=Math.max(t.x,s.x,n.x),t.y=Math.max(t.y,s.y,n.y),{min:e,max:t}}getCommands(){const{v1:e,v2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{v2:t}=this;return e.lineTo(t.x,t.y),this}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class zt extends I{constructor(t,s,n=0,o=1){super();P(this,"curves");P(this,"pointT",0);this.center=t,this.size=s,this.start=n,this.end=o;const{x:c,y:h}=this.center,a=new l(c+.5*this.size,h-.5*this.size),i=new l(c-.5*this.size,h-.5*this.size),u=new l(c,h+.5*this.size),y=new O(a,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),g=new O(i,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),x=new O(u,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),f=new l(c,h+this.size),p=new l(c+this.size,h),m=new l().lerpVectors(p,f,.75),T=new l(c-this.size,h),E=new l().lerpVectors(T,f,.75),w=new q(p,m),b=new q(E,T);this.curves=[y,w,x,b,g]}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let n;const o=.5*Math.PI;return s<o?(n=0,this.pointT=s/o):s<o+.75?(n=1,this.pointT=(s-o)/.75):s<5*Math.PI/8+.75?(n=2,this.pointT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(n=3,this.pointT=(s-5*Math.PI/8-.75)/.75):(n=4,this.pointT=(s-5*Math.PI/8-1.5)/o),this.curves[n]}getTangent(t){return this.getCurrentLine(t).getTangent(this.pointT).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new l(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}transform(t){return this.curves.forEach(s=>s.transform(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class qt extends I{constructor(t,s=0,n=0,o=0,c=1){super();P(this,"curves",[]);P(this,"points",[]);this.center=t,this.radius=s,this.num=n,this.start=o,this.end=c;for(let h=0;h<this.num;h++){let a=h*2*Math.PI/this.num;a-=.5*Math.PI;const i=new l(this.radius*Math.cos(a),this.radius*Math.sin(a));i.add(this.center),this.points.push(i)}for(let h=0;h<this.num;h++)this.curves.push(new q(this.points[h],this.points[(h+1)%this.num]))}getPoint(t){return this.getCurrentLine(t),this.currentLine.getPoint(this.pointK)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const n=s*this.num,o=Math.floor(n);return this.pointK=n-o,this.currentLine=this.curves[o],this.currentLine}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const s=this.getCurrentLine(t);return new l(s.v2.y-s.v1.y,-(s.v2.x-s.v1.x)).normalize()}transform(t){return this.curves.forEach(s=>s.transform(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class it extends I{constructor(e=new l,t=new l,s=new l){super(),this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new l){const{v0:s,v1:n,v2:o}=this;return t.set(V(e,s.x,n.x,o.x),V(e,s.y,n.y,o.y)),t}transform(e){return this.v0.applyMatrix3(e),this.v1.applyMatrix3(e),this.v2.applyMatrix3(e),this}getMinMax(e=l.MAX,t=l.MIN){const{v0:s,v1:n,v2:o}=this,c=.5*(s.x+n.x),h=.5*(s.y+n.y),a=.5*(s.x+o.x),i=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,c,a),e.y=Math.min(e.y,s.y,o.y,h,i),t.x=Math.max(t.x,s.x,o.x,c,a),t.y=Math.max(t.y,s.y,o.y,h,i),{min:e,max:t}}getCommands(){const{v0:e,v1:t,v2:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{v1:t,v2:s}=this;return e.quadraticCurveTo(t.x,t.y,s.x,s.y),this}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}}class rt extends I{constructor(t,s,n=1,o=0,c=1){super();P(this,"curves",[]);P(this,"pointT",0);this.center=t,this.rx=s,this.aspectRatio=n,this.start=o,this.end=c;const{x:h,y:a}=this.center,i=this.rx,u=this.rx/this.aspectRatio,y=[new l(h-i,a-u),new l(h+i,a-u),new l(h+i,a+u),new l(h-i,a+u)];for(let g=0;g<4;g++)this.curves.push(new q(y[g].clone(),y[(g+1)%4].clone()))}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}getPoint(t){return this.getCurrentLine(t).getPoint(this.pointT)}getPointAt(t){return this.getPoint(t)}getCurrentLine(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let n;return s<this.aspectRatio?(n=0,this.pointT=s/this.aspectRatio):s<this.aspectRatio+1?(n=1,this.pointT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(n=2,this.pointT=(s-this.aspectRatio-1)/this.aspectRatio):(n=3,this.pointT=(s-2*this.aspectRatio-1)/1),this.curves[n]}getTangent(t){return this.getCurrentLine(t).getTangent(0).normalize()}getNormal(t){const{v1:s,v2:n}=this.getCurrentLine(t);return new l(n.y-s.y,-(n.x-s.x)).normalize()}transform(t){return this.curves.forEach(s=>s.transform(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ot extends I{constructor(e=[]){super(),this.points=e}getDivisions(e=12){return e*this.points.length}getPoint(e,t=new l){const{points:s}=this,n=(s.length-1)*e,o=Math.floor(n),c=n-o,h=s[o===0?o:o-1],a=s[o],i=s[o>s.length-2?s.length-1:o+1],u=s[o>s.length-3?s.length-1:o+2];return t.set(H(c,h.x,a.x,i.x,u.x),H(c,h.y,a.y,i.y,u.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class X extends I{constructor(t){super();P(this,"curves",[]);P(this,"currentPoint",new l);P(this,"autoClose",!1);P(this,"_cacheLengths",[]);t&&this.setFromPoints(t)}addCurve(t){return this.curves.push(t),this}closePath(){const t=this.curves[0].getPoint(0),s=this.curves[this.curves.length-1].getPoint(1);return t.equals(s)||this.curves.push(new q(s,t)),this}getPoint(t,s=new l){const n=t*this.getLength(),o=this.getCurveLengths();let c=0;for(;c<o.length;){if(o[c]>=n){const h=o[c]-n,a=this.curves[c],i=a.getLength();return a.getPointAt(i===0?0:1-h/i,s)}c++}return s}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let n=0,o=this.curves.length;n<o;n++)s+=this.curves[n].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let n=0;n<=t;n++)s.push(this.getPoint(n/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[];let n;for(let o=0,c=this.curves;o<c.length;o++){const h=c[o],a=h.getPoints(h.getDivisions(t));for(let i=0;i<a.length;i++){const u=a[i];n&&n.equals(u)||(s.push(u),n=u)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,n=t.length;s<n;s++)this.lineTo(t[s].x,t[s].y);return this}bezierCurveTo(t,s,n,o,c,h){return this.curves.push(new Z(this.currentPoint.clone(),new l(t,s),new l(n,o),new l(c,h))),this.currentPoint.set(c,h),this}lineTo(t,s){return this.curves.push(new q(this.currentPoint.clone(),new l(t,s))),this.currentPoint.set(t,s),this}moveTo(t,s){return this.currentPoint.set(t,s),this}quadraticCurveTo(t,s,n,o){return this.curves.push(new it(this.currentPoint.clone(),new l(t,s),new l(n,o))),this.currentPoint.set(n,o),this}rect(t,s,n,o){return this.curves.push(new rt(new l(t+n/2,s+o/2),n/2,n/o)),this.currentPoint.set(t,s),this}splineThru(t){const s=[this.currentPoint.clone()].concat(t);return this.curves.push(new ot(s)),this.currentPoint.copy(t[t.length-1]),this}arc(t,s,n,o,c,h=!1){const a=this.currentPoint;return this.absarc(t+a.x,s+a.y,n,o,c,h),this}absarc(t,s,n,o,c,h=!1){return this.absellipse(t,s,n,n,o,c,h),this}ellipse(t,s,n,o,c,h,a=!1,i=0){const u=this.currentPoint;return this.absellipse(t+u.x,s+u.y,n,o,c,h,a,i),this}absellipse(t,s,n,o,c,h,a=!1,i=0){const u=new tt(t,s,n,o,c,h,a,i);if(this.curves.length>0){const y=u.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(u),this.currentPoint.copy(u.getPoint(1)),this}getCommands(){return this.curves.flatMap(t=>t.getCommands())}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}drawTo(t){var n;const s=(n=this.curves[0])==null?void 0:n.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,n=t.curves.length;s<n;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}class k{constructor(e){P(this,"currentPath",new X);P(this,"paths",[this.currentPath]);P(this,"userData");e&&(e instanceof k?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}addPath(e){return e instanceof k?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){return this.currentPath.closePath(),this}moveTo(e,t){const{currentPoint:s,curves:n}=this.currentPath;return(s.x!==e||s.y!==t)&&(n.length?(this.currentPath=new X().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,n,o,c){return this.currentPath.bezierCurveTo(e,t,s,n,o,c),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}arc(e,t,s,n,o,c){return this.currentPath.absarc(e,t,s,n,o,!c),this}arcTo(e,t,s,n,o){return console.warn("Method arcTo not supported yet"),this}ellipse(e,t,s,n,o,c,h,a){return this.currentPath.absellipse(e,t,s,n,c,h,!a,o),this}rect(e,t,s,n){return this.currentPath.rect(e,t,s,n),this}addCommands(e){return Mt(e,this),this}addData(e){return this.addCommands(Pt(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}forEachCurve(e){return this.paths.forEach(t=>t.curves.forEach(s=>e(s))),this}transform(e){return this.forEachCurve(t=>t.transform(e)),this}getMinMax(e=l.MAX,t=l.MIN){return this.forEachCurve(s=>s.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new A(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return this.paths.flatMap(e=>e.curves.flatMap(t=>t.getCommands()))}getData(){return this.paths.map(e=>e.getData()).join(" ")}getSvgString(){const{x:e,y:t,width:s,height:n}=this.getBoundingBox(),o=1;return`<svg viewBox="${e-o} ${t-o} ${s+o*2} ${n+o*2}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`}getSvgDataUri(){return`data:image/svg+xml;base64,${btoa(this.getSvgString())}`}drawTo(e){this.paths.forEach(t=>{t.drawTo(e)})}strokeTo(e){this.drawTo(e),e.stroke()}fillTo(e){this.drawTo(e),e.fill()}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.userData=e.userData,this}toCanvas(e=!0){const t=document.createElement("canvas"),{left:s,top:n,width:o,height:c}=this.getBoundingBox();t.width=o,t.height=c;const h=t.getContext("2d");return h&&(h.translate(-s,-n),e?this.fillTo(h):this.strokeTo(h)),t}clone(){return new this.constructor().copy(this)}}const G="px",at=90,ht=["mm","cm","in","pt","pc","px"],_={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function v(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,n=ht.length;s<n;s++){const o=ht[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&G!=="px"?t=_.in[G]/at:(t=_[e][G],t<0&&(t=_[e].in*at)),t*Number.parseFloat(r)}const Dt=new C,F=new C,ct=new C,ut=new C;function Xt(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=Ot(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Ot(r){const e=new C,t=Dt;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(v(r.getAttribute("x")),v(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let n=s.length-1;n>=0;n--){const o=s[n].trim();if(o==="")continue;const c=o.indexOf("("),h=o.length;if(c>0&&c<h){const a=o.slice(0,c),i=S(o.slice(c+1));switch(t.identity(),a){case"translate":if(i.length>=1){const u=i[0];let y=0;i.length>=2&&(y=i[1]),t.translate(u,y)}break;case"rotate":if(i.length>=1){let u=0,y=0,g=0;u=i[0]*Math.PI/180,i.length>=3&&(y=i[1],g=i[2]),F.makeTranslation(-y,-g),ct.makeRotation(u),ut.multiplyMatrices(ct,F),F.makeTranslation(y,g),t.multiplyMatrices(F,ut)}break;case"scale":i.length>=1&&t.scale(i[0],i[1]??i[0]);break;case"skewX":i.length===1&&t.set(1,Math.tan(i[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":i.length===1&&t.set(1,0,0,Math.tan(i[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":i.length===6&&t.set(i[0],i[2],i[4],i[1],i[3],i[5],0,0,1);break}}e.premultiply(t)}}return e}function Rt(r){return new k().addPath(new X().absarc(v(r.getAttribute("cx")||0),v(r.getAttribute("cy")||0),v(r.getAttribute("r")||0),0,Math.PI*2))}function Ft(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const n=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<n.length;o++){const c=Object.fromEntries(Object.entries(s.style).filter(([,h])=>h!==""));e[n[o]]=Object.assign(e[n[o]]||{},c)}}}function Ut(r){return new k().addPath(new X().absellipse(v(r.getAttribute("cx")||0),v(r.getAttribute("cy")||0),v(r.getAttribute("rx")||0),v(r.getAttribute("ry")||0),0,Math.PI*2))}function Yt(r){return new k().moveTo(v(r.getAttribute("x1")||0),v(r.getAttribute("y1")||0)).lineTo(v(r.getAttribute("x2")||0),v(r.getAttribute("y2")||0))}function Gt(r){const e=new k,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const _t=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Bt(r){var s;const e=new k;let t=0;return(s=r.getAttribute("points"))==null||s.replace(_t,(n,o,c)=>{const h=v(o),a=v(c);return t===0?e.moveTo(h,a):e.lineTo(h,a),t++,n}),e.currentPath.autoClose=!0,e}const Qt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Wt(r){var s;const e=new k;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Qt,(n,o,c)=>{const h=v(o),a=v(c);return t===0?e.moveTo(h,a):e.lineTo(h,a),t++,n}),e.currentPath.autoClose=!1,e}function Ht(r){const e=v(r.getAttribute("x")||0),t=v(r.getAttribute("y")||0),s=v(r.getAttribute("rx")||r.getAttribute("ry")||0),n=v(r.getAttribute("ry")||r.getAttribute("rx")||0),o=v(r.getAttribute("width")),c=v(r.getAttribute("height")),h=1-.551915024494,a=new k;return a.moveTo(e+s,t),a.lineTo(e+o-s,t),(s!==0||n!==0)&&a.bezierCurveTo(e+o-s*h,t,e+o,t+n*h,e+o,t+n),a.lineTo(e+o,t+c-n),(s!==0||n!==0)&&a.bezierCurveTo(e+o,t+c-n*h,e+o-s*h,t+c,e+o-s,t+c),a.lineTo(e+s,t+c),(s!==0||n!==0)&&a.bezierCurveTo(e+s*h,t+c,e,t+c-n*h,e,t+c-n),a.lineTo(e,t+n),(s!==0||n!==0)&&a.bezierCurveTo(e,t+n*h,e+s*h,t,e+s,t),a}function N(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const h=r.getAttribute("class").split(/\s/).filter(Boolean).map(a=>a.trim());for(let a=0;a<h.length;a++)s=Object.assign(s,t[`.${h[a]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function n(h,a,i){i===void 0&&(i=function(y){return y.startsWith("url")&&console.warn("url access in attributes is not implemented."),y}),r.hasAttribute(h)&&(e[a]=i(r.getAttribute(h))),s[h]&&(e[a]=i(s[h])),r.style&&r.style[h]!==""&&(e[a]=i(r.style[h]))}function o(h){return Math.max(0,Math.min(1,v(h)))}function c(h){return Math.max(0,v(h))}return n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-dashoffset","strokeDashoffset"),n("stroke-dasharray","strokeDasharray"),n("stroke-linecap","strokeLineCap"),n("stroke-linejoin","strokeLineJoin"),n("stroke-miterlimit","strokeMiterLimit",c),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",c),n("visibility","visibility"),e}function B(r,e,t=[]){var u;if(r.nodeType!==1)return t;let s=!1,n=null;const o={};switch(r.nodeName){case"svg":e=N(r,e,o);break;case"style":Ft(r,o);break;case"g":e=N(r,e,o);break;case"path":e=N(r,e,o),r.hasAttribute("d")&&(n=Gt(r));break;case"rect":e=N(r,e,o),n=Ht(r);break;case"polygon":e=N(r,e,o),n=Bt(r);break;case"polyline":e=N(r,e,o),n=Wt(r);break;case"circle":e=N(r,e,o),n=Rt(r);break;case"ellipse":e=N(r,e,o),n=Ut(r);break;case"line":e=N(r,e,o),n=Yt(r);break;case"defs":s=!0;break;case"use":{e=N(r,e,o);const g=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),x=(u=r.viewportElement)==null?void 0:u.getElementById(g);x?B(x,e,t):console.warn(`'use node' references non-existent node id: ${g}`);break}default:console.warn(r);break}const c=new C,h=[],a=Xt(r,c,h);n&&(n.transform(c),t.push(n),n.userData={node:r,style:e});const i=r.childNodes;for(let y=0,g=i.length;y<g;y++){const x=i[y];s&&x.nodeName!=="style"&&x.nodeName!=="defs"||B(x,e,t)}return a&&(h.pop(),h.length>0?c.copy(h[h.length-1]):c.identity()),t}const lt="data:image/svg+xml;",yt=`${lt}base64,`,ft=`${lt}charset=utf8,`;function gt(r){if(typeof r=="string"){let e;return r.startsWith(yt)?(r=r.substring(yt.length,r.length),e=atob(r)):r.startsWith(ft)?(r=r.substring(ft.length,r.length),e=decodeURIComponent(r)):e=r,new DOMParser().parseFromString(e,"image/svg+xml").documentElement}else return r}function Vt(r){return B(gt(r),{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4})}M.BoundingBox=A,M.CircleCurve=O,M.CubicBezierCurve=Z,M.Curve=I,M.CurvePath=X,M.EllipseCurve=tt,M.HeartCurve=zt,M.LineCurve=q,M.Matrix3=C,M.Path2D=k,M.PloygonCurve=qt,M.Point2D=l,M.QuadraticBezierCurve=it,M.RectangularCurve=rt,M.SplineCurve=ot,M.parseSvg=Vt,M.parseSvgToDom=gt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1021,8 +1021,18 @@ class Curve {
1021
1021
  }
1022
1022
  /** overrideable */
1023
1023
  getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1024
+ this.getPoints().forEach((point) => {
1025
+ min.x = Math.min(min.x, point.x);
1026
+ min.y = Math.min(min.y, point.y);
1027
+ max.x = Math.max(max.x, point.x);
1028
+ max.y = Math.max(max.y, point.y);
1029
+ });
1024
1030
  return { min, max };
1025
1031
  }
1032
+ getBoundingBox() {
1033
+ const { min, max } = this.getMinMax();
1034
+ return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
1035
+ }
1026
1036
  /** overrideable */
1027
1037
  getCommands() {
1028
1038
  return [];
@@ -1220,35 +1230,33 @@ class EllipseCurve extends Curve {
1220
1230
  return divisions * 2;
1221
1231
  }
1222
1232
  getCommands() {
1223
- const { x, y, radiusX, radiusY, startAngle, endAngle, clockwise } = this;
1224
- const anticlockwise = !clockwise;
1225
- const startX = x + radiusX * Math.cos(startAngle);
1226
- const startY = y + radiusY * Math.sin(startAngle);
1227
- const endX = x + radiusX * Math.cos(endAngle);
1228
- const endY = y + radiusY * Math.sin(endAngle);
1233
+ const { x: cx, y: cy, radiusX: rx, radiusY: ry, startAngle, endAngle, clockwise, rotation } = this;
1234
+ const startX = cx + rx * Math.cos(startAngle) * Math.cos(rotation) - ry * Math.sin(startAngle) * Math.sin(rotation);
1235
+ const startY = cy + rx * Math.cos(startAngle) * Math.sin(rotation) + ry * Math.sin(startAngle) * Math.cos(rotation);
1229
1236
  const angleDiff = Math.abs(startAngle - endAngle);
1230
1237
  const largeArcFlag = angleDiff > Math.PI ? 1 : 0;
1231
- const sweepFlag = anticlockwise ? 0 : 1;
1232
- const midX = x + radiusX * Math.cos(startAngle + (endAngle - startAngle) / 2);
1233
- const midY = y + radiusY * Math.sin(startAngle + (endAngle - startAngle) / 2);
1238
+ const sweepFlag = clockwise ? 1 : 0;
1239
+ const angle = rotation * 180 / Math.PI;
1234
1240
  if (angleDiff >= 2 * Math.PI) {
1241
+ const midAngle = startAngle + Math.PI;
1242
+ const midX = cx + rx * Math.cos(midAngle) * Math.cos(rotation) - ry * Math.sin(midAngle) * Math.sin(rotation);
1243
+ const midY = cy + rx * Math.cos(midAngle) * Math.sin(rotation) + ry * Math.sin(midAngle) * Math.cos(rotation);
1235
1244
  return [
1236
1245
  { type: "M", x: startX, y: startY },
1237
- { type: "A", rx: radiusX, ry: radiusY, angle: 0, largeArcFlag: 1, sweepFlag, x: midX, y: midY },
1238
- { type: "A", rx: radiusX, ry: radiusY, angle: 0, largeArcFlag: 1, sweepFlag, x: startX, y: startY }
1246
+ { type: "A", rx, ry, angle, largeArcFlag: 0, sweepFlag, x: midX, y: midY },
1247
+ { type: "A", rx, ry, angle, largeArcFlag: 0, sweepFlag, x: startX, y: startY }
1239
1248
  ];
1240
1249
  } else {
1250
+ const endX = cx + rx * Math.cos(endAngle) * Math.cos(rotation) - ry * Math.sin(endAngle) * Math.sin(rotation);
1251
+ const endY = cy + rx * Math.cos(endAngle) * Math.sin(rotation) + ry * Math.sin(endAngle) * Math.cos(rotation);
1241
1252
  return [
1242
1253
  { type: "M", x: startX, y: startY },
1243
- { type: "A", rx: radiusX, ry: radiusY, angle: 0, largeArcFlag, sweepFlag, x: endX, y: endY }
1254
+ { type: "A", rx, ry, angle, largeArcFlag, sweepFlag, x: endX, y: endY }
1244
1255
  ];
1245
1256
  }
1246
1257
  }
1247
1258
  drawTo(ctx) {
1248
1259
  const { x, y, radiusX, radiusY, rotation, startAngle, endAngle, clockwise } = this;
1249
- const startX = x + radiusX * Math.cos(startAngle);
1250
- const startY = y + radiusY * Math.sin(startAngle);
1251
- ctx.moveTo(startX, startY);
1252
1260
  ctx.ellipse(
1253
1261
  x,
1254
1262
  y,
@@ -1273,6 +1281,22 @@ class EllipseCurve extends Curve {
1273
1281
  }
1274
1282
  return this;
1275
1283
  }
1284
+ getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1285
+ const { x: cx, y: cy, radiusX: rx, radiusY: ry, rotation: theta } = this;
1286
+ const cosTheta = Math.cos(theta);
1287
+ const sinTheta = Math.sin(theta);
1288
+ const halfWidth = Math.sqrt(
1289
+ rx * rx * cosTheta * cosTheta + ry * ry * sinTheta * sinTheta
1290
+ );
1291
+ const halfHeight = Math.sqrt(
1292
+ rx * rx * sinTheta * sinTheta + ry * ry * cosTheta * cosTheta
1293
+ );
1294
+ min.x = Math.min(min.x, cx - halfWidth);
1295
+ min.y = Math.min(min.y, cy - halfHeight);
1296
+ max.x = Math.max(max.x, cx + halfWidth);
1297
+ max.y = Math.max(max.y, cy + halfHeight);
1298
+ return { min, max };
1299
+ }
1276
1300
  copy(source) {
1277
1301
  super.copy(source);
1278
1302
  this.x = source.x;
@@ -2089,34 +2113,10 @@ class Path2D {
2089
2113
  this.currentPath.absarc(x, y, radius, startAngle, endAngle, !counterclockwise);
2090
2114
  return this;
2091
2115
  }
2116
+ // TODO
2117
+ // eslint-disable-next-line unused-imports/no-unused-vars
2092
2118
  arcTo(x1, y1, x2, y2, radius) {
2093
- const point = this.currentPath.currentPoint;
2094
- const currentX = point.x;
2095
- const currentY = point.y;
2096
- const dx1 = x1 - currentX;
2097
- const dy1 = y1 - currentY;
2098
- const dx2 = x2 - x1;
2099
- const dy2 = y2 - y1;
2100
- const len1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
2101
- const len2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
2102
- if (len1 < radius || len2 < radius) {
2103
- this.lineTo(x2, y2);
2104
- return this;
2105
- }
2106
- const unitV1 = { x: dx1 / len1, y: dy1 / len1 };
2107
- const unitV2 = { x: dx2 / len2, y: dy2 / len2 };
2108
- const centerX = x1 - unitV1.y * radius;
2109
- const centerY = y1 + unitV1.x * radius;
2110
- const startAngle = Math.atan2(unitV1.y, unitV1.x);
2111
- const endAngle = Math.atan2(unitV2.y, unitV2.x);
2112
- let angleDiff = endAngle - startAngle;
2113
- if (angleDiff > Math.PI) {
2114
- angleDiff -= 2 * Math.PI;
2115
- } else if (angleDiff < -Math.PI) {
2116
- angleDiff += 2 * Math.PI;
2117
- }
2118
- this.arc(centerX, centerY, radius, startAngle, startAngle + angleDiff, false);
2119
- this.lineTo(x2, y2);
2119
+ console.warn("Method arcTo not supported yet");
2120
2120
  return this;
2121
2121
  }
2122
2122
  ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
@@ -2153,12 +2153,7 @@ class Path2D {
2153
2153
  }
2154
2154
  getBoundingBox() {
2155
2155
  const { min, max } = this.getMinMax();
2156
- return new BoundingBox(
2157
- min.x,
2158
- min.y,
2159
- max.x - min.x,
2160
- max.y - min.y
2161
- );
2156
+ return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
2162
2157
  }
2163
2158
  getCommands() {
2164
2159
  return this.paths.flatMap((path) => path.curves.flatMap((curve) => curve.getCommands()));
@@ -2168,7 +2163,8 @@ class Path2D {
2168
2163
  }
2169
2164
  getSvgString() {
2170
2165
  const { x, y, width, height } = this.getBoundingBox();
2171
- return `<svg viewBox="${x} ${y} ${width} ${height}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`;
2166
+ const strokeWidth = 1;
2167
+ return `<svg viewBox="${x - strokeWidth} ${y - strokeWidth} ${width + strokeWidth * 2} ${height + strokeWidth * 2}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`;
2172
2168
  }
2173
2169
  getSvgDataUri() {
2174
2170
  return `data:image/svg+xml;base64,${btoa(this.getSvgString())}`;
@@ -2705,10 +2701,9 @@ function parseNode(node, style, paths = []) {
2705
2701
  const dataUri = "data:image/svg+xml;";
2706
2702
  const base64DataUri = `${dataUri}base64,`;
2707
2703
  const utf8DataUri = `${dataUri}charset=utf8,`;
2708
- function parseSvg(svg) {
2709
- let node;
2710
- let xml;
2704
+ function parseSvgToDom(svg) {
2711
2705
  if (typeof svg === "string") {
2706
+ let xml;
2712
2707
  if (svg.startsWith(base64DataUri)) {
2713
2708
  svg = svg.substring(base64DataUri.length, svg.length);
2714
2709
  xml = atob(svg);
@@ -2718,11 +2713,16 @@ function parseSvg(svg) {
2718
2713
  } else {
2719
2714
  xml = svg;
2720
2715
  }
2721
- node = new DOMParser().parseFromString(xml, "image/svg+xml").documentElement;
2716
+ return new DOMParser().parseFromString(
2717
+ xml,
2718
+ "image/svg+xml"
2719
+ ).documentElement;
2722
2720
  } else {
2723
- node = svg;
2721
+ return svg;
2724
2722
  }
2725
- return parseNode(node, {
2723
+ }
2724
+ function parseSvg(svg) {
2725
+ return parseNode(parseSvgToDom(svg), {
2726
2726
  fill: "#000",
2727
2727
  fillOpacity: 1,
2728
2728
  strokeOpacity: 1,
@@ -2733,4 +2733,4 @@ function parseSvg(svg) {
2733
2733
  });
2734
2734
  }
2735
2735
 
2736
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg };
2736
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg, parseSvgToDom };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "description": "A modern Path2D library, fully compatible with Web Path2D, with additional support for path animation, path deformation, path playback, etc.",
7
7
  "author": "wxm",