modern-path2d 1.3.0 → 1.3.1
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 +139 -213
- package/dist/index.js +2 -2
- package/dist/index.mjs +140 -214
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1976,76 +1976,24 @@ class RoundCurve extends Curve {
|
|
|
1976
1976
|
return [this._center];
|
|
1977
1977
|
}
|
|
1978
1978
|
getAdaptivePointArray(output = []) {
|
|
1979
|
-
const { cx, cy, rx, ry,
|
|
1980
|
-
if (!(rx >= 0 && ry >= 0
|
|
1979
|
+
const { cx, cy, rx, ry, startAngle, endAngle, clockwise } = this;
|
|
1980
|
+
if (!(rx >= 0 && ry >= 0)) {
|
|
1981
1981
|
return output;
|
|
1982
1982
|
}
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
return output;
|
|
1989
|
-
}
|
|
1990
|
-
if (n === 0) {
|
|
1991
|
-
output[0] = output[6] = x + dx;
|
|
1992
|
-
output[1] = output[3] = y + dy;
|
|
1993
|
-
output[2] = output[4] = x - dx;
|
|
1994
|
-
output[5] = output[7] = y - dy;
|
|
1995
|
-
return output;
|
|
1996
|
-
}
|
|
1997
|
-
let j1 = 0;
|
|
1998
|
-
let j2 = n * 4 + (dx ? 2 : 0) + 2;
|
|
1999
|
-
let j3 = j2;
|
|
2000
|
-
let j4 = m;
|
|
2001
|
-
let x0 = dx + rx;
|
|
2002
|
-
let y0 = dy;
|
|
2003
|
-
let x1 = x + x0;
|
|
2004
|
-
let x2 = x - x0;
|
|
2005
|
-
let y1 = y + y0;
|
|
2006
|
-
output[j1++] = x1;
|
|
2007
|
-
output[j1++] = y1;
|
|
2008
|
-
output[--j2] = y1;
|
|
2009
|
-
output[--j2] = x2;
|
|
2010
|
-
if (dy) {
|
|
2011
|
-
const y22 = y - y0;
|
|
2012
|
-
output[j3++] = x2;
|
|
2013
|
-
output[j3++] = y22;
|
|
2014
|
-
output[--j4] = y22;
|
|
2015
|
-
output[--j4] = x1;
|
|
1983
|
+
let deltaAngle = endAngle - startAngle;
|
|
1984
|
+
if (!clockwise && deltaAngle > 0) {
|
|
1985
|
+
deltaAngle -= 2 * Math.PI;
|
|
1986
|
+
} else if (clockwise && deltaAngle < 0) {
|
|
1987
|
+
deltaAngle += 2 * Math.PI;
|
|
2016
1988
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
const
|
|
2021
|
-
const
|
|
2022
|
-
const
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2025
|
-
output[j1++] = x12;
|
|
2026
|
-
output[j1++] = y12;
|
|
2027
|
-
output[--j2] = y12;
|
|
2028
|
-
output[--j2] = x22;
|
|
2029
|
-
output[j3++] = x22;
|
|
2030
|
-
output[j3++] = y22;
|
|
2031
|
-
output[--j4] = y22;
|
|
2032
|
-
output[--j4] = x12;
|
|
2033
|
-
}
|
|
2034
|
-
x0 = dx;
|
|
2035
|
-
y0 = dy + ry;
|
|
2036
|
-
x1 = x + x0;
|
|
2037
|
-
x2 = x - x0;
|
|
2038
|
-
y1 = y + y0;
|
|
2039
|
-
const y2 = y - y0;
|
|
2040
|
-
output[j1++] = x1;
|
|
2041
|
-
output[j1++] = y1;
|
|
2042
|
-
output[--j4] = y2;
|
|
2043
|
-
output[--j4] = x1;
|
|
2044
|
-
if (dx) {
|
|
2045
|
-
output[j1++] = x2;
|
|
2046
|
-
output[j1++] = y1;
|
|
2047
|
-
output[--j4] = y2;
|
|
2048
|
-
output[--j4] = x2;
|
|
1989
|
+
const arcLength = Math.abs(deltaAngle);
|
|
1990
|
+
const n = Math.max(1, Math.ceil(arcLength / (Math.PI / 16)));
|
|
1991
|
+
for (let i = 0; i <= n; i++) {
|
|
1992
|
+
const t = i / n;
|
|
1993
|
+
const angle = startAngle + deltaAngle * t;
|
|
1994
|
+
const x = cx + Math.cos(angle) * rx;
|
|
1995
|
+
const y = cy + Math.sin(angle) * ry;
|
|
1996
|
+
output.push(x, y);
|
|
2049
1997
|
}
|
|
2050
1998
|
return output;
|
|
2051
1999
|
}
|
|
@@ -2311,121 +2259,6 @@ class ArcCurve extends RoundCurve {
|
|
|
2311
2259
|
}
|
|
2312
2260
|
}
|
|
2313
2261
|
|
|
2314
|
-
class LineCurve extends Curve {
|
|
2315
|
-
constructor(p1 = new Vector2(), p2 = new Vector2()) {
|
|
2316
|
-
super();
|
|
2317
|
-
this.p1 = p1;
|
|
2318
|
-
this.p2 = p2;
|
|
2319
|
-
}
|
|
2320
|
-
static from(p1x, p1y, p2x, p2y) {
|
|
2321
|
-
return new LineCurve(
|
|
2322
|
-
new Vector2(p1x, p1y),
|
|
2323
|
-
new Vector2(p2x, p2y)
|
|
2324
|
-
);
|
|
2325
|
-
}
|
|
2326
|
-
getPoint(t, output = new Vector2()) {
|
|
2327
|
-
if (t === 1) {
|
|
2328
|
-
output.copy(this.p2);
|
|
2329
|
-
} else {
|
|
2330
|
-
output.copy(this.p2).sub(this.p1).scale(t).add(this.p1);
|
|
2331
|
-
}
|
|
2332
|
-
return output;
|
|
2333
|
-
}
|
|
2334
|
-
getPointAt(u, output = new Vector2()) {
|
|
2335
|
-
return this.getPoint(u, output);
|
|
2336
|
-
}
|
|
2337
|
-
getTangent(_t, output = new Vector2()) {
|
|
2338
|
-
return output.subVectors(this.p2, this.p1).normalize();
|
|
2339
|
-
}
|
|
2340
|
-
getTangentAt(u, output = new Vector2()) {
|
|
2341
|
-
return this.getTangent(u, output);
|
|
2342
|
-
}
|
|
2343
|
-
getControlPointRefs() {
|
|
2344
|
-
return [this.p1, this.p2];
|
|
2345
|
-
}
|
|
2346
|
-
getAdaptivePointArray(output = []) {
|
|
2347
|
-
output.push(
|
|
2348
|
-
this.p1.x,
|
|
2349
|
-
this.p1.y,
|
|
2350
|
-
this.p2.x,
|
|
2351
|
-
this.p2.y
|
|
2352
|
-
);
|
|
2353
|
-
return output;
|
|
2354
|
-
}
|
|
2355
|
-
getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
|
|
2356
|
-
const { p1, p2 } = this;
|
|
2357
|
-
min.x = Math.min(min.x, p1.x, p2.x);
|
|
2358
|
-
min.y = Math.min(min.y, p1.y, p2.y);
|
|
2359
|
-
max.x = Math.max(max.x, p1.x, p2.x);
|
|
2360
|
-
max.y = Math.max(max.y, p1.y, p2.y);
|
|
2361
|
-
return { min: min.finite(), max: max.finite() };
|
|
2362
|
-
}
|
|
2363
|
-
toCommands() {
|
|
2364
|
-
const { p1, p2 } = this;
|
|
2365
|
-
return [
|
|
2366
|
-
{ type: "M", x: p1.x, y: p1.y },
|
|
2367
|
-
{ type: "L", x: p2.x, y: p2.y }
|
|
2368
|
-
];
|
|
2369
|
-
}
|
|
2370
|
-
fillTriangulate(options = {}) {
|
|
2371
|
-
let {
|
|
2372
|
-
vertices = [],
|
|
2373
|
-
indices = [],
|
|
2374
|
-
verticesStride = 2,
|
|
2375
|
-
verticesOffset = vertices.length / verticesStride,
|
|
2376
|
-
indicesOffset = indices.length
|
|
2377
|
-
} = options;
|
|
2378
|
-
const x = this.p1.x;
|
|
2379
|
-
const y = this.p1.y;
|
|
2380
|
-
const width = this.p2.x - this.p1.x || 1;
|
|
2381
|
-
const height = this.p2.y - this.p2.y || 1;
|
|
2382
|
-
const points = [
|
|
2383
|
-
x,
|
|
2384
|
-
y,
|
|
2385
|
-
x + width,
|
|
2386
|
-
y,
|
|
2387
|
-
x + width,
|
|
2388
|
-
y + height,
|
|
2389
|
-
x,
|
|
2390
|
-
y + height
|
|
2391
|
-
];
|
|
2392
|
-
let count = 0;
|
|
2393
|
-
verticesOffset *= verticesStride;
|
|
2394
|
-
vertices[verticesOffset + count] = points[0];
|
|
2395
|
-
vertices[verticesOffset + count + 1] = points[1];
|
|
2396
|
-
count += verticesStride;
|
|
2397
|
-
vertices[verticesOffset + count] = points[2];
|
|
2398
|
-
vertices[verticesOffset + count + 1] = points[3];
|
|
2399
|
-
count += verticesStride;
|
|
2400
|
-
vertices[verticesOffset + count] = points[6];
|
|
2401
|
-
vertices[verticesOffset + count + 1] = points[7];
|
|
2402
|
-
count += verticesStride;
|
|
2403
|
-
vertices[verticesOffset + count] = points[4];
|
|
2404
|
-
vertices[verticesOffset + count + 1] = points[5];
|
|
2405
|
-
count += verticesStride;
|
|
2406
|
-
const verticesIndex = verticesOffset / verticesStride;
|
|
2407
|
-
indices[indicesOffset++] = verticesIndex;
|
|
2408
|
-
indices[indicesOffset++] = verticesIndex + 1;
|
|
2409
|
-
indices[indicesOffset++] = verticesIndex + 2;
|
|
2410
|
-
indices[indicesOffset++] = verticesIndex + 1;
|
|
2411
|
-
indices[indicesOffset++] = verticesIndex + 3;
|
|
2412
|
-
indices[indicesOffset++] = verticesIndex + 2;
|
|
2413
|
-
return { vertices, indices };
|
|
2414
|
-
}
|
|
2415
|
-
drawTo(ctx) {
|
|
2416
|
-
const { p1, p2 } = this;
|
|
2417
|
-
ctx.lineTo(p1.x, p1.y);
|
|
2418
|
-
ctx.lineTo(p2.x, p2.y);
|
|
2419
|
-
return this;
|
|
2420
|
-
}
|
|
2421
|
-
copy(source) {
|
|
2422
|
-
super.copy(source);
|
|
2423
|
-
this.p1.copy(source.p1);
|
|
2424
|
-
this.p2.copy(source.p2);
|
|
2425
|
-
return this;
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
2262
|
class CompositeCurve extends Curve {
|
|
2430
2263
|
constructor(curves = []) {
|
|
2431
2264
|
super();
|
|
@@ -2503,39 +2336,13 @@ class CompositeCurve extends Curve {
|
|
|
2503
2336
|
fillTriangulate(options) {
|
|
2504
2337
|
const indices = options?.indices ?? [];
|
|
2505
2338
|
const vertices = options?.vertices ?? [];
|
|
2506
|
-
const lines = [];
|
|
2507
|
-
const fillLines = () => {
|
|
2508
|
-
if (lines.length) {
|
|
2509
|
-
const pointArray = [];
|
|
2510
|
-
lines.forEach((line) => {
|
|
2511
|
-
const x = line.p1.x;
|
|
2512
|
-
const y = line.p1.y;
|
|
2513
|
-
if (pointArray[pointArray.length - 2] !== x || pointArray[pointArray.length - 1] !== y) {
|
|
2514
|
-
pointArray.push(x, y);
|
|
2515
|
-
}
|
|
2516
|
-
pointArray.push(line.p2.x, line.p2.y);
|
|
2517
|
-
});
|
|
2518
|
-
fillTriangulate(pointArray, {
|
|
2519
|
-
...options,
|
|
2520
|
-
indices,
|
|
2521
|
-
vertices
|
|
2522
|
-
});
|
|
2523
|
-
lines.length = 0;
|
|
2524
|
-
}
|
|
2525
|
-
};
|
|
2526
2339
|
this.curves.forEach((curve) => {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
...options,
|
|
2533
|
-
indices,
|
|
2534
|
-
vertices
|
|
2535
|
-
});
|
|
2536
|
-
}
|
|
2340
|
+
curve.fillTriangulate({
|
|
2341
|
+
...options,
|
|
2342
|
+
indices,
|
|
2343
|
+
vertices
|
|
2344
|
+
});
|
|
2537
2345
|
});
|
|
2538
|
-
fillLines();
|
|
2539
2346
|
return { indices, vertices };
|
|
2540
2347
|
}
|
|
2541
2348
|
applyTransform(transform) {
|
|
@@ -2696,6 +2503,125 @@ class EllipseCurve extends RoundCurve {
|
|
|
2696
2503
|
}
|
|
2697
2504
|
}
|
|
2698
2505
|
|
|
2506
|
+
class LineCurve extends Curve {
|
|
2507
|
+
constructor(p1 = new Vector2(), p2 = new Vector2()) {
|
|
2508
|
+
super();
|
|
2509
|
+
this.p1 = p1;
|
|
2510
|
+
this.p2 = p2;
|
|
2511
|
+
}
|
|
2512
|
+
static from(p1x, p1y, p2x, p2y) {
|
|
2513
|
+
return new LineCurve(
|
|
2514
|
+
new Vector2(p1x, p1y),
|
|
2515
|
+
new Vector2(p2x, p2y)
|
|
2516
|
+
);
|
|
2517
|
+
}
|
|
2518
|
+
getPoint(t, output = new Vector2()) {
|
|
2519
|
+
if (t === 1) {
|
|
2520
|
+
output.copy(this.p2);
|
|
2521
|
+
} else {
|
|
2522
|
+
output.copy(this.p2).sub(this.p1).scale(t).add(this.p1);
|
|
2523
|
+
}
|
|
2524
|
+
return output;
|
|
2525
|
+
}
|
|
2526
|
+
getPointAt(u, output = new Vector2()) {
|
|
2527
|
+
return this.getPoint(u, output);
|
|
2528
|
+
}
|
|
2529
|
+
getTangent(_t, output = new Vector2()) {
|
|
2530
|
+
return output.subVectors(this.p2, this.p1).normalize();
|
|
2531
|
+
}
|
|
2532
|
+
getTangentAt(u, output = new Vector2()) {
|
|
2533
|
+
return this.getTangent(u, output);
|
|
2534
|
+
}
|
|
2535
|
+
getControlPointRefs() {
|
|
2536
|
+
return [this.p1, this.p2];
|
|
2537
|
+
}
|
|
2538
|
+
getAdaptivePointArray(output = []) {
|
|
2539
|
+
output.push(
|
|
2540
|
+
this.p1.x,
|
|
2541
|
+
this.p1.y,
|
|
2542
|
+
this.p2.x,
|
|
2543
|
+
this.p2.y
|
|
2544
|
+
);
|
|
2545
|
+
return output;
|
|
2546
|
+
}
|
|
2547
|
+
getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
|
|
2548
|
+
const { p1, p2 } = this;
|
|
2549
|
+
min.x = Math.min(min.x, p1.x, p2.x);
|
|
2550
|
+
min.y = Math.min(min.y, p1.y, p2.y);
|
|
2551
|
+
max.x = Math.max(max.x, p1.x, p2.x);
|
|
2552
|
+
max.y = Math.max(max.y, p1.y, p2.y);
|
|
2553
|
+
return { min: min.finite(), max: max.finite() };
|
|
2554
|
+
}
|
|
2555
|
+
toCommands() {
|
|
2556
|
+
const { p1, p2 } = this;
|
|
2557
|
+
return [
|
|
2558
|
+
{ type: "M", x: p1.x, y: p1.y },
|
|
2559
|
+
{ type: "L", x: p2.x, y: p2.y }
|
|
2560
|
+
];
|
|
2561
|
+
}
|
|
2562
|
+
fillTriangulate(options = {}) {
|
|
2563
|
+
let {
|
|
2564
|
+
vertices = [],
|
|
2565
|
+
indices = [],
|
|
2566
|
+
verticesStride = 2,
|
|
2567
|
+
verticesOffset = vertices.length / verticesStride,
|
|
2568
|
+
indicesOffset = indices.length
|
|
2569
|
+
} = options;
|
|
2570
|
+
const minX = Math.min(this.p1.x, this.p2.x);
|
|
2571
|
+
const maxX = Math.max(this.p1.x, this.p2.x);
|
|
2572
|
+
const minY = Math.min(this.p1.y, this.p2.y);
|
|
2573
|
+
const maxY = Math.max(this.p1.y, this.p2.y);
|
|
2574
|
+
const x = minX;
|
|
2575
|
+
const y = minY;
|
|
2576
|
+
const width = maxX - minX;
|
|
2577
|
+
const height = maxY - minY;
|
|
2578
|
+
const points = [
|
|
2579
|
+
x,
|
|
2580
|
+
y,
|
|
2581
|
+
x + width,
|
|
2582
|
+
y,
|
|
2583
|
+
x + width,
|
|
2584
|
+
y + height,
|
|
2585
|
+
x,
|
|
2586
|
+
y + height
|
|
2587
|
+
];
|
|
2588
|
+
let count = 0;
|
|
2589
|
+
verticesOffset *= verticesStride;
|
|
2590
|
+
vertices[verticesOffset + count] = points[0];
|
|
2591
|
+
vertices[verticesOffset + count + 1] = points[1];
|
|
2592
|
+
count += verticesStride;
|
|
2593
|
+
vertices[verticesOffset + count] = points[2];
|
|
2594
|
+
vertices[verticesOffset + count + 1] = points[3];
|
|
2595
|
+
count += verticesStride;
|
|
2596
|
+
vertices[verticesOffset + count] = points[6];
|
|
2597
|
+
vertices[verticesOffset + count + 1] = points[7];
|
|
2598
|
+
count += verticesStride;
|
|
2599
|
+
vertices[verticesOffset + count] = points[4];
|
|
2600
|
+
vertices[verticesOffset + count + 1] = points[5];
|
|
2601
|
+
count += verticesStride;
|
|
2602
|
+
const verticesIndex = verticesOffset / verticesStride;
|
|
2603
|
+
indices[indicesOffset++] = verticesIndex;
|
|
2604
|
+
indices[indicesOffset++] = verticesIndex + 1;
|
|
2605
|
+
indices[indicesOffset++] = verticesIndex + 2;
|
|
2606
|
+
indices[indicesOffset++] = verticesIndex + 1;
|
|
2607
|
+
indices[indicesOffset++] = verticesIndex + 3;
|
|
2608
|
+
indices[indicesOffset++] = verticesIndex + 2;
|
|
2609
|
+
return { vertices, indices };
|
|
2610
|
+
}
|
|
2611
|
+
drawTo(ctx) {
|
|
2612
|
+
const { p1, p2 } = this;
|
|
2613
|
+
ctx.lineTo(p1.x, p1.y);
|
|
2614
|
+
ctx.lineTo(p2.x, p2.y);
|
|
2615
|
+
return this;
|
|
2616
|
+
}
|
|
2617
|
+
copy(source) {
|
|
2618
|
+
super.copy(source);
|
|
2619
|
+
this.p1.copy(source.p1);
|
|
2620
|
+
this.p2.copy(source.p2);
|
|
2621
|
+
return this;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2699
2625
|
class PloygonCurve extends CompositeCurve {
|
|
2700
2626
|
//
|
|
2701
2627
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(v,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(v=typeof globalThis<"u"?globalThis:v||self,R(v.modernPath2d={}))})(this,function(v){"use strict";var Nn=Object.defineProperty;var Fn=(v,R,nt)=>R in v?Nn(v,R,{enumerable:!0,configurable:!0,writable:!0,value:nt}):v[R]=nt;var V=(v,R,nt)=>Fn(v,typeof R!="symbol"?R+"":R,nt);function R(i,e,t,n={}){const{radius:r=1}=n;i.moveTo(e,t),i.arc(e,t,r,0,Math.PI*2)}const nt={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function At(i,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:c=0,strokeDasharray:h=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:f=0,shadowBlur:y=0,shadowColor:x="rgba(0, 0, 0, 0)"}=e;i.fillStyle=t,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=nt[s],i.miterLimit=c,i.setLineDash(h),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=f,i.shadowBlur=y,i.shadowColor=x}class p{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new p(1/0,1/0)}static get MIN(){return new p(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,o=-(this.y-t.y),s=Math.sin(n),c=Math.cos(n);return this.set(t.x+(r*c-o*s),t.y-(r*s+o*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){const r=e<0?n.x-this.x+n.x:this.x,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(e)*o),this.y=n.y+(o+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new p(this.x,this.y)}}class X{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new p((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new X;if(e.length===1)return e[0].clone();const t=e[0],n=e.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new X(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new X(this.left,this.top,this.width,this.height)}}class z{constructor(e=1,t=0,n=0,r=0,o=1,s=0,c=0,h=0,a=1){V(this,"elements",[]);this.set(e,t,n,r,o,s,c,h,a)}set(e,t,n,r,o,s,c,h,a){const l=this.elements;return l[0]=e,l[1]=r,l[2]=c,l[3]=t,l[4]=o,l[5]=h,l[6]=n,l[7]=s,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,s=n[0],c=n[3],h=n[6],a=n[1],l=n[4],f=n[7],y=n[2],x=n[5],u=n[8],g=r[0],M=r[3],T=r[6],I=r[1],P=r[4],w=r[7],E=r[2],S=r[5],d=r[8];return o[0]=s*g+c*I+h*E,o[3]=s*M+c*P+h*S,o[6]=s*T+c*w+h*d,o[1]=a*g+l*I+f*E,o[4]=a*M+l*P+f*S,o[7]=a*T+l*w+f*d,o[2]=y*g+x*I+u*E,o[5]=y*M+x*P+u*S,o[8]=y*T+x*w+u*d,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],s=e[4],c=e[5],h=e[6],a=e[7],l=e[8],f=l*s-c*a,y=c*h-l*o,x=a*o-s*h,u=t*f+n*y+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/u;return e[0]=f*g,e[1]=(r*a-l*n)*g,e[2]=(c*n-r*s)*g,e[3]=y*g,e[4]=(l*t-r*h)*g,e[5]=(r*o-c*t)*g,e[6]=x*g,e[7]=(n*h-a*t)*g,e[8]=(s*t-n*o)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(bt.makeScale(e,t)),this}rotate(e){return this.premultiply(bt.makeRotation(-e)),this}translate(e,t){return this.premultiply(bt.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new z;function Zt(i,e,t,n){const r=i*t+e*n,o=Math.sqrt(i*i+e*e)*Math.sqrt(t*t+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-e*t<0&&(s=-s),s}function jt(i,e,t,n,r,o,s,c){if(e===0||t===0){i.lineTo(c.x,c.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const h=(s.x-c.x)/2,a=(s.y-c.y)/2,l=Math.cos(n)*h+Math.sin(n)*a,f=-Math.sin(n)*h+Math.cos(n)*a;let y=e*e,x=t*t;const u=l*l,g=f*f,M=u/y+g/x;if(M>1){const q=Math.sqrt(M);e=q*e,t=q*t,y=e*e,x=t*t}const T=y*g+x*u,I=(y*x-T)/T;let P=Math.sqrt(Math.max(0,I));r===o&&(P=-P);const w=P*e*f/t,E=-P*t*l/e,S=Math.cos(n)*w-Math.sin(n)*E+(s.x+c.x)/2,d=Math.sin(n)*w+Math.cos(n)*E+(s.y+c.y)/2,m=Zt(1,0,(l-w)/e,(f-E)/t),_=Zt((l-w)/e,(f-E)/t,(-l-w)/e,(-f-E)/t)%(Math.PI*2);i.ellipse(S,d,e,t,n,m,m+_,o===0)}const D={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Z(i,e,t=0){let c=0,h=!0,a="",l="";const f=[];function y(M,T,I){const P=new SyntaxError(`Unexpected character "${M}" at index ${T}.`);throw P.partial=I,P}function x(){a!==""&&(l===""?f.push(Number(a)):f.push(Number(a)*10**Number(l))),a="",l=""}let u;const g=i.length;for(let M=0;M<g;M++){if(u=i[M],Array.isArray(e)&&e.includes(f.length%t)&&D.FLAGS.test(u)){c=1,a=u,x();continue}if(c===0){if(D.WHITESPACE.test(u))continue;if(D.DIGIT.test(u)||D.SIGN.test(u)){c=1,a=u;continue}if(D.POINT.test(u)){c=2,a=u;continue}D.COMMA.test(u)&&(h&&y(u,M,f),h=!0)}if(c===1){if(D.DIGIT.test(u)){a+=u;continue}if(D.POINT.test(u)){a+=u,c=2;continue}if(D.EXP.test(u)){c=3;continue}D.SIGN.test(u)&&a.length===1&&D.SIGN.test(a[0])&&y(u,M,f)}if(c===2){if(D.DIGIT.test(u)){a+=u;continue}if(D.EXP.test(u)){c=3;continue}D.POINT.test(u)&&a[a.length-1]==="."&&y(u,M,f)}if(c===3){if(D.DIGIT.test(u)){l+=u;continue}if(D.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&D.SIGN.test(l)&&y(u,M,f)}}D.WHITESPACE.test(u)?(x(),c=0,h=!1):D.COMMA.test(u)?(x(),c=0,h=!0):D.SIGN.test(u)?(x(),c=1,a=u):D.POINT.test(u)?(x(),c=2,a=u):y(u,M,f)}return x(),f}function st(i,e){return i-(e-i)}function kt(i,e){const t=new p,n=new p;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?t.add(s):t.copy(s),e.moveTo(t.x,t.y),n.copy(t);else if(s.type==="h"||s.type==="H")s.type==="h"?t.x+=s.x:t.x=s.x,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="v"||s.type==="V")s.type==="v"?t.y+=s.y:t.y=s.y,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="l"||s.type==="L")s.type==="l"?t.add(s):t.copy(s),e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="c"||s.type==="C")s.type==="c"?(e.bezierCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(e.quadraticCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x,t.y+s.y),n.x=t.x+s.x1,n.y=t.y+s.y1,t.add(s)):(e.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,t.copy(s));else if(s.type==="t"||s.type==="T"){const c=st(t.x,n.x),h=st(t.y,n.y);n.x=c,n.y=h,s.type==="t"?(e.quadraticCurveTo(c,h,t.x+s.x,t.y+s.y),t.add(s)):(e.quadraticCurveTo(c,h,s.x,s.y),t.copy(s))}else if(s.type==="a"||s.type==="A"){const c=t.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;t.add(s)}else{if(t.equals(s))continue;t.copy(s)}n.copy(t),jt(e,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,c,t)}else s.type==="z"||s.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",s)}}function Gt(i){let e,t;const n=[];for(let r=0,o=i.length;r<o;r++){const s=i[r];switch(s.type){case"m":case"M":if(s.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&s.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y},e={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),t={x:s.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),t={x:(t==null?void 0:t.x)??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"c":case"C":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"a":case"A":n.push(`${s.type} ${s.rx} ${s.ry} ${s.angle} ${s.largeArcFlag} ${s.sweepFlag} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const Ae=/[a-df-z][^a-df-z]*/gi;function It(i){const e=[],t=i.match(Ae);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],s=o.charAt(0),c=o.slice(1).trim();let h;switch(s){case"m":case"M":h=Z(c);for(let a=0,l=h.length;a<l;a+=2)a===0?e.push({type:s,x:h[a],y:h[a+1]}):e.push({type:s==="m"?"l":"L",x:h[a],y:h[a+1]});break;case"h":case"H":h=Z(c);for(let a=0,l=h.length;a<l;a++)e.push({type:s,x:h[a]});break;case"v":case"V":h=Z(c);for(let a=0,l=h.length;a<l;a++)e.push({type:s,y:h[a]});break;case"l":case"L":h=Z(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:s,x:h[a],y:h[a+1]});break;case"c":case"C":h=Z(c);for(let a=0,l=h.length;a<l;a+=6)e.push({type:s,x1:h[a],y1:h[a+1],x2:h[a+2],y2:h[a+3],x:h[a+4],y:h[a+5]});break;case"s":case"S":h=Z(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:s,x2:h[a],y2:h[a+1],x:h[a+2],y:h[a+3]});break;case"q":case"Q":h=Z(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:s,x1:h[a],y1:h[a+1],x:h[a+2],y:h[a+3]});break;case"t":case"T":h=Z(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:s,x:h[a],y:h[a+1]});break;case"a":case"A":h=Z(c,[3,4],7);for(let a=0,l=h.length;a<l;a+=7)e.push({type:s,rx:h[a],ry:h[a+1],angle:h[a+2],largeArcFlag:h[a+3],sweepFlag:h[a+4],x:h[a+5],y:h[a+6]});break;case"z":case"Z":e.push({type:s});break;default:console.warn(o)}}return e}function St(i,e,t,n,r){const o=(n-e)*.5,s=(r-t)*.5,c=i*i,h=i*c;return(2*t-2*n+o+s)*h+(-3*t+3*n-2*o-s)*c+o*i+t}function be(i,e){const t=1-i;return t*t*t*e}function ke(i,e){const t=1-i;return 3*t*t*i*e}function Ie(i,e){return 3*(1-i)*i*i*e}function Se(i,e){return i*i*i*e}function Et(i,e,t,n,r){return be(i,e)+ke(i,t)+Ie(i,n)+Se(i,r)}function Ee(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Bt(i,0,r,t,!0);const s=[];if(!o||o.next===o.prev)return s;let c,h,a;if(n&&(o=De(i,e,o,t)),i.length>80*t){c=1/0,h=1/0;let l=-1/0,f=-1/0;for(let y=t;y<r;y+=t){const x=i[y],u=i[y+1];x<c&&(c=x),u<h&&(h=u),x>l&&(l=x),u>f&&(f=u)}a=Math.max(l-c,f-h),a=a!==0?32767/a:0}return ot(o,s,t,c,h,a,0),s}function Bt(i,e,t,n,r){let o;if(r===Ve(i,e,t,n)>0)for(let s=e;s<t;s+=n)o=Wt(s/n|0,i[s],i[s+1],o);else for(let s=t-n;s>=e;s-=n)o=Wt(s/n|0,i[s],i[s+1],o);return o&&it(o,o.next)&&(at(o),o=o.next),o}function H(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(it(t,t.next)||N(t.prev,t,t.next)===0)){if(at(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ot(i,e,t,n,r,o,s){if(!i)return;!s&&o&&ze(i,n,r,o);let c=i;for(;i.prev!==i.next;){const h=i.prev,a=i.next;if(o?$e(i,n,r,o):Le(i)){e.push(h.i,i.i,a.i),at(i),i=a.next,c=a.next;continue}if(i=a,i===c){s?s===1?(i=Ne(H(i),e),ot(i,e,t,n,r,o,2)):s===2&&Fe(i,e,t,n,r,o):ot(H(i),e,t,n,r,o,1);break}}}function Le(i){const e=i.prev,t=i,n=i.next;if(N(e,t,n)>=0)return!1;const r=e.x,o=t.x,s=n.x,c=e.y,h=t.y,a=n.y,l=Math.min(r,o,s),f=Math.min(c,h,a),y=Math.max(r,o,s),x=Math.max(c,h,a);let u=n.next;for(;u!==e;){if(u.x>=l&&u.x<=y&&u.y>=f&&u.y<=x&&ct(r,c,o,h,s,a,u.x,u.y)&&N(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function $e(i,e,t,n){const r=i.prev,o=i,s=i.next;if(N(r,o,s)>=0)return!1;const c=r.x,h=o.x,a=s.x,l=r.y,f=o.y,y=s.y,x=Math.min(c,h,a),u=Math.min(l,f,y),g=Math.max(c,h,a),M=Math.max(l,f,y),T=Lt(x,u,e,t,n),I=Lt(g,M,e,t,n);let P=i.prevZ,w=i.nextZ;for(;P&&P.z>=T&&w&&w.z<=I;){if(P.x>=x&&P.x<=g&&P.y>=u&&P.y<=M&&P!==r&&P!==s&&ct(c,l,h,f,a,y,P.x,P.y)&&N(P.prev,P,P.next)>=0||(P=P.prevZ,w.x>=x&&w.x<=g&&w.y>=u&&w.y<=M&&w!==r&&w!==s&&ct(c,l,h,f,a,y,w.x,w.y)&&N(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;P&&P.z>=T;){if(P.x>=x&&P.x<=g&&P.y>=u&&P.y<=M&&P!==r&&P!==s&&ct(c,l,h,f,a,y,P.x,P.y)&&N(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;w&&w.z<=I;){if(w.x>=x&&w.x<=g&&w.y>=u&&w.y<=M&&w!==r&&w!==s&&ct(c,l,h,f,a,y,w.x,w.y)&&N(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Ne(i,e){let t=i;do{const n=t.prev,r=t.next.next;!it(n,r)&&Vt(n,t,t.next,r)&&ht(n,r)&&ht(r,n)&&(e.push(n.i,t.i,r.i),at(t),at(t.next),t=i=r),t=t.next}while(t!==i);return H(t)}function Fe(i,e,t,n,r,o){let s=i;do{let c=s.next.next;for(;c!==s.prev;){if(s.i!==c.i&&Ge(s,c)){let h=Xt(s,c);s=H(s,s.next),h=H(h,h.next),ot(s,e,t,n,r,o,0),ot(h,e,t,n,r,o,0);return}c=c.next}s=s.next}while(s!==i)}function De(i,e,t,n){const r=[];for(let o=0,s=e.length;o<s;o++){const c=e[o]*n,h=o<s-1?e[o+1]*n:i.length,a=Bt(i,c,h,n,!1);a===a.next&&(a.steiner=!0),r.push(je(a))}r.sort(_e);for(let o=0;o<r.length;o++)t=qe(r[o],t);return t}function _e(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function qe(i,e){const t=Oe(i,e);if(!t)return e;const n=Xt(t,i);return H(n,n.next),H(t,t.next)}function Oe(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,s;if(it(i,t))return t;do{if(it(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>o&&(o=f,s=t.x<t.next.x?t:t.next,f===n))return s}t=t.next}while(t!==e);if(!s)return null;const c=s,h=s.x,a=s.y;let l=1/0;t=s;do{if(n>=t.x&&t.x>=h&&n!==t.x&&Ut(r<a?n:o,r,h,a,r<a?o:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);ht(t,i)&&(f<l||f===l&&(t.x>s.x||t.x===s.x&&Re(s,t)))&&(s=t,l=f)}t=t.next}while(t!==c);return s}function Re(i,e){return N(i.prev,i,e.prev)<0&&N(e.next,i,i.next)<0}function ze(i,e,t,n){let r=i;do r.z===0&&(r.z=Lt(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Ze(r)}function Ze(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let s=n,c=0;for(let a=0;a<t&&(c++,s=s.nextZ,!!s);a++);let h=t;for(;c>0||h>0&&s;)c!==0&&(h===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,c--):(r=s,s=s.nextZ,h--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,t*=2}while(e>1);return i}function Lt(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function je(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Ut(i,e,t,n,r,o,s,c){return(r-s)*(e-c)>=(i-s)*(o-c)&&(i-s)*(n-c)>=(t-s)*(e-c)&&(t-s)*(o-c)>=(r-s)*(n-c)}function ct(i,e,t,n,r,o,s,c){return!(i===s&&e===c)&&Ut(i,e,t,n,r,o,s,c)}function Ge(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Be(i,e)&&(ht(i,e)&&ht(e,i)&&Ue(i,e)&&(N(i.prev,i,e.prev)||N(i,e.prev,e))||it(i,e)&&N(i.prev,i,i.next)>0&&N(e.prev,e,e.next)>0)}function N(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function it(i,e){return i.x===e.x&&i.y===e.y}function Vt(i,e,t,n){const r=gt(N(i,e,t)),o=gt(N(i,e,n)),s=gt(N(t,n,i)),c=gt(N(t,n,e));return!!(r!==o&&s!==c||r===0&&pt(i,t,e)||o===0&&pt(i,n,e)||s===0&&pt(t,i,n)||c===0&&pt(t,e,n))}function pt(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function gt(i){return i>0?1:i<0?-1:0}function Be(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Vt(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ht(i,e){return N(i.prev,i,i.next)<0?N(i,e,i.next)>=0&&N(i,i.prev,e)>=0:N(i,e,i.prev)<0||N(i,i.next,e)<0}function Ue(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Xt(i,e){const t=$t(i.i,i.x,i.y),n=$t(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Wt(i,e,t,n){const r=$t(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function at(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $t(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ve(i,e,t,n){let r=0;for(let o=e,s=t-n;o<t;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Nt(i,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=t.length/o,indicesOffset:c=n.length}=e;const h=Ee(i,r,2);if(h){for(let l=0;l<h.length;l+=3)n[c++]=h[l]+s,n[c++]=h[l+1]+s,n[c++]=h[l+2]+s;let a=s*o;for(let l=0;l<i.length;l+=2)t[a]=i[l],t[a+1]=i[l+1],a+=o}return{vertices:t,indices:n}}const Xe=8,dt=11920929e-14,We=1;function Ht(i,e,t,n,r,o,s,c,h=.5,a=[]){const f=Math.min(.99,Math.max(0,h));let y=(We-f)/1;return y*=y,Ft(i,e,t,n,r,o,s,c,a,y,0),a.push(s,c),a}function Ft(i,e,t,n,r,o,s,c,h,a,l){if(l>Xe)return;const f=(i+t)/2,y=(e+n)/2,x=(t+r)/2,u=(n+o)/2,g=(r+s)/2,M=(o+c)/2,T=(f+x)/2,I=(y+u)/2,P=(x+g)/2,w=(u+M)/2,E=(T+P)/2,S=(I+w)/2;if(l>0){let d=s-i,m=c-e;const _=Math.abs((t-s)*m-(n-c)*d),q=Math.abs((r-s)*m-(o-c)*d);if(_>dt&&q>dt){if((_+q)*(_+q)<=a*(d*d+m*m)){h.push(E,S);return}}else if(_>dt){if(_*_<=a*(d*d+m*m)){h.push(E,S);return}}else if(q>dt){if(q*q<=a*(d*d+m*m)){h.push(E,S);return}}else if(d=E-(i+s)/2,m=S-(e+c)/2,d*d+m*m<=a){h.push(E,S);return}}Ft(i,e,f,y,T,I,E,S,h,a,l+1),Ft(E,S,P,w,g,M,s,c,h,a,l+1)}const He=8,Qe=11920929e-14,Ye=1;function Qt(i,e,t,n,r,o,s=.5,c=[]){const a=Math.min(.99,Math.max(0,s));let l=(Ye-a)/1;return l*=l,Dt(c,i,e,t,n,r,o,l,0),c.push(r,o),c}function Dt(i,e,t,n,r,o,s,c,h){if(h>He)return;const a=(e+n)/2,l=(t+r)/2,f=(n+o)/2,y=(r+s)/2,x=(a+f)/2,u=(l+y)/2;let g=o-e,M=s-t;const T=Math.abs((n-o)*M-(r-s)*g);if(T>Qe){if(T*T<=c*(g*g+M*M)){i.push(x,u);return}}else if(g=x-(e+o)/2,M=u-(t+s)/2,g*g+M*M<=c){i.push(x,u);return}Dt(i,e,t,a,l,x,u,c,h+1),Dt(i,x,u,f,y,o,s,c,h+1)}function Je(i,e){const t=1-i;return t*t*e}function Ke(i,e){return 2*(1-i)*i*e}function tn(i,e){return i*i*e}function _t(i,e,t,n){return Je(i,e)+Ke(i,t)+tn(i,n)}const en=1e-4,Yt=1e-4;function Jt(i,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=e,c=en;if(i.length===0)return{vertices:t,indices:n};const h=r;let a=h.alignment;if(r.alignment!==.5){let $=nn(i);o&&($*=-1),a=(a-.5)*$+.5}const l={x:i[0],y:i[1]},f={x:i[i.length-2],y:i[i.length-1]},y=s,x=Math.abs(l.x-f.x)<c&&Math.abs(l.y-f.y)<c;if(y){i=i.slice(),x&&(i.pop(),i.pop(),f.x=i[i.length-2],f.y=i[i.length-1]);const $=(l.x+f.x)*.5,W=(f.y+l.y)*.5;i.unshift($,W),i.push($,W)}const u=t,g=i.length/2;let M=i.length;const T=u.length/2,I=h.width/2,P=I*I,w=h.miterLimit*h.miterLimit;let E=i[0],S=i[1],d=i[2],m=i[3],_=0,q=0,A=-(S-m),b=E-d,F=0,O=0,B=Math.sqrt(A*A+b*b);A/=B,b/=B,A*=I,b*=I;const Pe=a,C=(1-Pe)*2,k=Pe*2;y||(h.cap==="round"?M+=Q(E-A*(C-k)*.5,S-b*(C-k)*.5,E-A*C,S-b*C,E+A*k,S+b*k,u,!0)+2:h.cap==="square"&&(M+=Kt(E,S,A,b,C,k,!0,u))),u.push(E-A*C,S-b*C),u.push(E+A*k,S+b*k);for(let $=1;$<g-1;++$){E=i[($-1)*2],S=i[($-1)*2+1],d=i[$*2],m=i[$*2+1],_=i[($+1)*2],q=i[($+1)*2+1],A=-(S-m),b=E-d,B=Math.sqrt(A*A+b*b),A/=B,b/=B,A*=I,b*=I,F=-(m-q),O=d-_,B=Math.sqrt(F*F+O*O),F/=B,O/=B,F*=I,O*=I;const W=d-E,ut=S-m,ft=d-_,yt=q-m,we=W*ft+ut*yt,vt=ut*ft-yt*W,xt=vt<0;if(Math.abs(vt)<.001*Math.abs(we)){u.push(d-A*C,m-b*C),u.push(d+A*k,m+b*k),we>=0&&(h.join==="round"?M+=Q(d,m,d-A*C,m-b*C,d-F*C,m-O*C,u,!1)+4:M+=2,u.push(d-F*k,m-O*k),u.push(d+F*C,m+O*C));continue}const ve=(-A+E)*(-b+m)-(-A+d)*(-b+S),Te=(-F+_)*(-O+m)-(-F+d)*(-O+q),Tt=(W*Te-ft*ve)/vt,Ct=(yt*ve-ut*Te)/vt,zt=(Tt-d)*(Tt-d)+(Ct-m)*(Ct-m),J=d+(Tt-d)*C,K=m+(Ct-m)*C,tt=d-(Tt-d)*k,et=m-(Ct-m)*k,Ln=Math.min(W*W+ut*ut,ft*ft+yt*yt),Ce=xt?C:k,$n=Ln+Ce*Ce*P;zt<=$n?h.join==="bevel"||zt/P>w?(xt?(u.push(J,K),u.push(d+A*k,m+b*k),u.push(J,K),u.push(d+F*k,m+O*k)):(u.push(d-A*C,m-b*C),u.push(tt,et),u.push(d-F*C,m-O*C),u.push(tt,et)),M+=2):h.join==="round"?xt?(u.push(J,K),u.push(d+A*k,m+b*k),M+=Q(d,m,d+A*k,m+b*k,d+F*k,m+O*k,u,!0)+4,u.push(J,K),u.push(d+F*k,m+O*k)):(u.push(d-A*C,m-b*C),u.push(tt,et),M+=Q(d,m,d-A*C,m-b*C,d-F*C,m-O*C,u,!1)+4,u.push(d-F*C,m-O*C),u.push(tt,et)):(u.push(J,K),u.push(tt,et)):(u.push(d-A*C,m-b*C),u.push(d+A*k,m+b*k),h.join==="round"?xt?M+=Q(d,m,d+A*k,m+b*k,d+F*k,m+O*k,u,!0)+2:M+=Q(d,m,d-A*C,m-b*C,d-F*C,m-O*C,u,!1)+2:h.join==="miter"&&zt/P<=w&&(xt?(u.push(tt,et),u.push(tt,et)):(u.push(J,K),u.push(J,K)),M+=2),u.push(d-F*C,m-O*C),u.push(d+F*k,m+O*k),M+=2)}E=i[(g-2)*2],S=i[(g-2)*2+1],d=i[(g-1)*2],m=i[(g-1)*2+1],A=-(S-m),b=E-d,B=Math.sqrt(A*A+b*b),A/=B,b/=B,A*=I,b*=I,u.push(d-A*C,m-b*C),u.push(d+A*k,m+b*k),y||(h.cap==="round"?M+=Q(d-A*(C-k)*.5,m-b*(C-k)*.5,d-A*C,m-b*C,d+A*k,m+b*k,u,!1)+2:h.cap==="square"&&(M+=Kt(d,m,A,b,C,k,!1,u)));const En=Yt*Yt;for(let $=T;$<M+T-2;++$)E=u[$*2],S=u[$*2+1],d=u[($+1)*2],m=u[($+1)*2+1],_=u[($+2)*2],q=u[($+2)*2+1],!(Math.abs(E*(m-q)+d*(q-S)+_*(S-m))<En)&&n.push($,$+1,$+2);return{vertices:t,indices:n}}function nn(i){const e=i.length;if(e<6)return 1;let t=0;for(let n=0,r=i[e-2],o=i[e-1];n<e;n+=2){const s=i[n],c=i[n+1];t+=(s-r)*(c+o),r=s,o=c}return t<0?-1:1}function Kt(i,e,t,n,r,o,s,c){const h=i-t*r,a=e-n*r,l=i+t*o,f=e+n*o;let y,x;s?(y=n,x=-t):(y=-n,x=t);const u=h+y,g=a+x,M=l+y,T=f+x;return c.push(u,g),c.push(M,T),2}function Q(i,e,t,n,r,o,s,c){const h=t-i,a=n-e;let l=Math.atan2(h,a),f=Math.atan2(r-i,o-e);c&&l<f?l+=Math.PI*2:!c&&l>f&&(f+=Math.PI*2);let y=l;const x=f-l,u=Math.abs(x),g=Math.sqrt(h*h+a*a),M=(15*u*Math.sqrt(g)/Math.PI>>0)+1,T=x/M;if(y+=T,c){s.push(i,e),s.push(t,n);for(let I=1,P=y;I<M;I++,P+=T)s.push(i,e),s.push(i+Math.sin(P)*g,e+Math.cos(P)*g);s.push(i,e),s.push(r,o)}else{s.push(t,n),s.push(i,e);for(let I=1,P=y;I<M;I++,P+=T)s.push(i+Math.sin(P)*g,e+Math.cos(P)*g),s.push(i,e);s.push(r,o),s.push(i,e)}return M*2}class Y{constructor(){V(this,"arcLengthDivision",200);V(this,"_arcLengths")}getPointAt(e,t=new p){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){const t=typeof e=="function";return this.getControlPointRefs().forEach(n=>{t?e(n):n.applyMatrix3(e)}),this}getUnevenPointArray(e=5,t=[]){const n=new p;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedPointArray(e=5,t=[]){const n=new p;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,n),t.push(n.x,n.y);return t}getAdaptivePointArray(e=[]){return this.getUnevenPointArray(5,e)}_pointArrayToPoint(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){const o=e[n],s=e[n+1];t.push(new p(o,s))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedPointArray(e);return this._pointArrayToPoint(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenPointArray(e);return this._pointArrayToPoint(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptivePointArray();return this._pointArrayToPoint(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenPointArray(e):n=this.getAdaptivePointArray(),this._pointArrayToPoint(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),o=1;o<=e;o++){const s=this.getPoint(o/e);n+=s.distanceTo(r),t.push(n),r=s}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/n[0];let s=0,c=0,h=r-1,a;for(;c<=h;)if(s=Math.floor(c+(h-c)/2),a=n[s]-o,a<0)c=s+1;else if(a>0)h=s-1;else{h=s;break}if(s=h,n[s]===o)return s/(r-1);const l=n[s],y=n[s+1]-l,x=(o-l)/y;return(s+x)/(r-1)}getTangent(e,t=new p){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new p){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(e)<t)return o;s.x<e.x?n=o:r=o}return o}getMinMax(e=p.MAX,t=p.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];e.min(s),t.max(s)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new X(e.x,e.y,t.x-e.x,t.y-e.y)}fillTriangulate(e){return Nt(this.getAdaptivePointArray(),e)}strokeTriangulate(e){return Jt(this.getAdaptivePointArray(),e)}toTriangulatedSVGString(e=this.fillTriangulate(),t=0){const{vertices:n,indices:r}=e,o={x:-t,y:-t},s={x:t,y:t},c=l=>{const f=n[l*2],y=n[l*2+1];return o.x=Math.min(o.x,f+t),s.x=Math.max(s.x,f+t),o.y=Math.min(o.y,y+t),s.y=Math.max(s.y,y+t),[f,y]};let h="";for(let l=0,f=r.length;l<f;l+=3){const y=c(r[l]),x=c(r[l+1]),u=c(r[l+2]);h+=`<polygon points="${y.join(",")} ${x.join(",")} ${u.join(",")}" fill="none" stroke="black" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" />`}const a=[o.x,o.y,s.x-o.x,s.y-o.y];return`<svg width="${a[2]}" height="${a[3]}" viewBox="${a.join(" ")}" xmlns="http://www.w3.org/2000/svg">${h}</svg>`}toTriangulatedSVG(e,t){return new DOMParser().parseFromString(this.toTriangulatedSVGString(e,t),"image/svg+xml").documentElement}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return Gt(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const sn=new z,te=new z,ee=new z,mt=new p;class qt extends Y{constructor(e=new p,t=new p,n=new p,r=0,o=0,s=Math.PI*2,c=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=c}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const n=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new p){const n=this._getDeltaAngle(),r=this.startAngle+e*n;let o=this.cx+this.rx*Math.cos(r),s=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const c=Math.cos(this.rotate),h=Math.sin(this.rotate),a=o-this.cx,l=s-this.cy;o=a*c-l*h+this.cx,s=a*h+l*c+this.cy}return t.set(o,s)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:c,rotate:h}=this,a=e+n*Math.cos(o)*Math.cos(h)-r*Math.sin(o)*Math.sin(h),l=t+n*Math.cos(o)*Math.sin(h)+r*Math.sin(o)*Math.cos(h),f=Math.abs(o-s),y=f>Math.PI?1:0,x=c?1:0,u=h*180/Math.PI;if(f>=2*Math.PI){const g=o+Math.PI,M=e+n*Math.cos(g)*Math.cos(h)-r*Math.sin(g)*Math.sin(h),T=t+n*Math.cos(g)*Math.sin(h)+r*Math.sin(g)*Math.cos(h);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:M,y:T},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const g=e+n*Math.cos(s)*Math.cos(h)-r*Math.sin(s)*Math.sin(h),M=t+n*Math.cos(s)*Math.sin(h)+r*Math.sin(s)*Math.cos(h);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:y,sweepFlag:x,x:g,y:M}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:s,startAngle:c,endAngle:h,clockwise:a}=this;return e.ellipse(t,n,r,o,s,c,h,!a),this}applyTransform(e){return mt.set(this.cx,this.cy),mt.applyMatrix3(e),this.cx=mt.x,this.cy=mt.y,cn(e)?rn(this,e):on(this,e),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:c}=this;if(!(r>=0&&o>=0&&s>=0&&c>=0))return e;const h=Math.ceil(2.3*Math.sqrt(r+o)),a=t,l=n,f=h*8+(s?4:0)+(c?4:0);if(f===0)return e;if(h===0)return e[0]=e[6]=a+s,e[1]=e[3]=l+c,e[2]=e[4]=a-s,e[5]=e[7]=l-c,e;let y=0,x=h*4+(s?2:0)+2,u=x,g=f,M=s+r,T=c,I=a+M,P=a-M,w=l+T;if(e[y++]=I,e[y++]=w,e[--x]=w,e[--x]=P,c){const S=l-T;e[u++]=P,e[u++]=S,e[--g]=S,e[--g]=I}for(let S=1;S<h;S++){const d=Math.PI/2*(S/h),m=s+Math.cos(d)*r,_=c+Math.sin(d)*o,q=a+m,A=a-m,b=l+_,F=l-_;e[y++]=q,e[y++]=b,e[--x]=b,e[--x]=A,e[u++]=A,e[u++]=F,e[--g]=F,e[--g]=q}M=s,T=c+o,I=a+M,P=a-M,w=l+T;const E=l-T;return e[y++]=I,e[y++]=w,e[--g]=E,e[--g]=I,s&&(e[y++]=P,e[y++]=w,e[--g]=E,e[--g]=P),e}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=t.length/r,indicesOffset:s=n.length}=e;const c=this.getAdaptivePointArray();if(c.length===0)return{vertices:t,indices:n};let h=0,a=0;for(let y=0;y<c.length;y+=2)h+=c[y],a+=c[y+1];h/=c.length/2,a/=c.length/2;let l=o;t[l*r]=h,t[l*r+1]=a;const f=l++;for(let y=0;y<c.length;y+=2)t[l*r]=c[y],t[l*r+1]=c[y+1],y>0&&(n[s++]=l,n[s++]=f,n[s++]=l-1),l++;return n[s++]=f+1,n[s++]=f,n[s++]=l-1,{vertices:t,indices:n}}getMinMax(e=p.MAX,t=p.MIN){const{cx:n,cy:r,rx:o,ry:s,rotate:c}=this,h=Math.cos(c),a=Math.sin(c),l=Math.sqrt(o*o*h*h+s*s*a*a),f=Math.sqrt(o*o*a*a+s*s*h*h);return e.x=Math.min(e.x,n-l),e.y=Math.min(e.y,r-f),t.x=Math.max(t.x,n+l),t.y=Math.max(t.y,r+f),{min:e.finite(),max:t.finite()}}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function rn(i,e){const t=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new p(t*r,t*o),c=new p(-n*o,n*r),h=s.applyMatrix3(e),a=c.applyMatrix3(e),l=sn.set(h.x,a.x,0,h.y,a.y,0,0,0,1),f=te.copy(l).invert(),u=ee.copy(f).transpose().multiply(f).elements,g=hn(u[0],u[1],u[4]),M=Math.sqrt(g.rt1),T=Math.sqrt(g.rt2);if(i.rx=1/M,i.ry=1/T,i.rotate=Math.atan2(g.sn,g.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=te.set(M,0,0,0,T,0,0,0,1),w=ee.set(g.cs,g.sn,0,-g.sn,g.cs,0,0,0,1),E=P.multiply(w).multiply(l),S=d=>{const{x:m,y:_}=new p(Math.cos(d),Math.sin(d)).applyMatrix3(E);return Math.atan2(_,m)};i.startAngle=S(i.startAngle),i.endAngle=S(i.endAngle),ne(e)&&(i.clockwise=!i.clockwise)}}function on(i,e){const t=se(e),n=ie(e);i.rx*=t,i.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);i.rotate+=r,ne(e)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ne(i){const e=i.elements;return e[0]*e[4]-e[1]*e[3]<0}function cn(i){const e=i.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=se(i),r=ie(i);return Math.abs(t/(n*r))>Number.EPSILON}function se(i){const e=i.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ie(i){const e=i.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function hn(i,e,t){let n,r,o,s,c;const h=i+t,a=i-t,l=Math.sqrt(a*a+4*e*e);return h>0?(n=.5*(h+l),c=1/n,r=i*c*t-e*c*e):h<0?r=.5*(h-l):(n=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(e)?(c=-2*e/o,s=1/Math.sqrt(1+c*c),o=c*s):Math.abs(e)===0?(o=1,s=0):(c=-.5*o/e,o=1/Math.sqrt(1+c*c),s=c*o),a>0&&(c=o,o=-s,s=c),{rt1:n,rt2:r,cs:o,sn:s}}class re extends qt{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,s=!1){super(new p(e,t),new p(n,n),new p,0,r,o,s)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;return e.arc(t,n,r,o,s,!c),this}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;let h=Math.abs(o-s);(!c&&o>s||c&&s>o)&&(h=2*Math.PI-h);let a=Math.max(6,Math.floor(6*r**(1/3)*(h/Math.PI)));a=Math.max(a,3);let l=h/a,f=o;l*=c?1:-1;for(let y=0;y<a+1;y++){const x=Math.cos(f),u=Math.sin(f),g=t+x*r,M=n+u*r;e.push(g,M),f+=l}return e}}class j extends Y{constructor(e=new p,t=new p){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new j(new p(e,t),new p(n,r))}getPoint(e,t=new p){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new p){return this.getPoint(e,t)}getTangent(e,t=new p){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new p){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=t.length/r,indicesOffset:s=n.length}=e;const c=this.p1.x,h=this.p1.y,a=this.p2.x-this.p1.x||1,l=this.p2.y-this.p2.y||1,f=[c,h,c+a,h,c+a,h+l,c,h+l];let y=0;o*=r,t[o+y]=f[0],t[o+y+1]=f[1],y+=r,t[o+y]=f[2],t[o+y+1]=f[3],y+=r,t[o+y]=f[6],t[o+y+1]=f[7],y+=r,t[o+y]=f[4],t[o+y+1]=f[5],y+=r;const x=o/r;return n[s++]=x,n[s++]=x+1,n[s++]=x+2,n[s++]=x+1,n[s++]=x+3,n[s++]=x+2,{vertices:t,indices:n}}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class rt extends Y{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof rt?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new p){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,c=this.curves[o],h=c.getLength();return c.getPointAt(h===0?0:1-s/h,t)}o++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){return e[t-1]===e[t+1]&&e[t]===e[t+2]&&e.splice(t+1,2),e}getSpacedPointArray(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedPointArray(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptivePointArray(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptivePointArray(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}fillTriangulate(e){const t=(e==null?void 0:e.indices)??[],n=(e==null?void 0:e.vertices)??[],r=[],o=()=>{if(r.length){const s=[];r.forEach(c=>{const h=c.p1.x,a=c.p1.y;(s[s.length-2]!==h||s[s.length-1]!==a)&&s.push(h,a),s.push(c.p2.x,c.p2.y)}),Nt(s,{...e,indices:t,vertices:n}),r.length=0}};return this.curves.forEach(s=>{s instanceof j?r.push(s):(o(),s.fillTriangulate({...e,indices:t,vertices:n}))}),o(),{indices:t,vertices:n}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=p.MAX,t=p.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new X(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Mt extends Y{constructor(e=new p,t=new p,n=new p,r=new p){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,s,c,h){return new Mt(new p(e,t),new p(n,r),new p(o,s),new p(c,h))}getPoint(e,t=new p){const{p1:n,cp1:r,cp2:o,p2:s}=this;return t.set(Et(e,n.x,r.x,o.x,s.x),Et(e,n.y,r.y,o.y,s.y))}getAdaptivePointArray(e=[]){return Ht(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){const r=t*t-4*e*n;if(r<0)return[];const o=Math.sqrt(r),s=(-t+o)/(2*e),c=(-t-o)/(2*e);return[s,c].filter(h=>h>=0&&h<=1)}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,c=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),h=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),a=[0,1,...c,...h];return((f,y)=>{for(const x of f)for(let u=0;u<=y;u++){const g=u/y-.5,M=Math.min(1,Math.max(0,x+g)),T=this.getPoint(M);e.x=Math.min(e.x,T.x),e.y=Math.min(e.y,T.y),t.x=Math.max(t.x,T.x),t.y=Math.max(t.y,T.y)}})(a,10),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp1:n,cp2:r,p2:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class oe extends qt{constructor(e=0,t=0,n=1,r=1,o=0,s=0,c=Math.PI*2,h=!1){super(new p(e,t),new p(n,r),new p,o,s,c,h)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Ot extends rt{}class an extends Ot{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){const{cx:e,cy:t,radius:n,sideCount:r}=this,o=[];for(let c=0;c<r;c++){const h=c*2*Math.PI/r-.5*Math.PI;o.push(new p(n*Math.cos(h),n*Math.sin(h)).add({x:e,y:t}))}const s=[];for(let c=0;c<r;c++)s.push(new j(o[c],o[(c+1)%r]));return this.curves=s,this}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}}class Pt extends Y{constructor(e=new p,t=new p,n=new p){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,s){return new Pt(new p(e,t),new p(n,r),new p(o,s))}getPoint(e,t=new p){const{p1:n,cp:r,p2:o}=this;return t.set(_t(e,n.x,r.x,o.x),_t(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(e=[]){return Qt(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),c=.5*(n.y+r.y),h=.5*(n.x+o.x),a=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,s,h),e.y=Math.min(e.y,n.y,o.y,c,a),t.x=Math.max(t.x,n.x,o.x,s,h),t.y=Math.max(t.y,n.y,o.y,c,a),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp:t,p2:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){const{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class ce extends Ot{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){const{x:e,y:t,width:n,height:r}=this,o=[new p(e,t),new p(e+n,t),new p(e+n,t+r),new p(e,t+r)];return this.curves=[new j(o[0],o[1]),new j(o[1],o[2]),new j(o[2],o[3]),new j(o[3],o[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=t.length/r,indicesOffset:s=n.length}=e;const{x:c,y:h,width:a,height:l}=this,f=[c,h,c+a,h,c+a,h+l,c,h+l];let y=0;o*=r,t[o+y]=f[0],t[o+y+1]=f[1],y+=r,t[o+y]=f[2],t[o+y+1]=f[3],y+=r,t[o+y]=f[6],t[o+y+1]=f[7],y+=r,t[o+y]=f[4],t[o+y+1]=f[5],y+=r;const x=o/r;return n[s++]=x,n[s++]=x+1,n[s++]=x+2,n[s++]=x+1,n[s++]=x+3,n[s++]=x+2,{vertices:t,indices:n}}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class he extends qt{constructor(e=0,t=0,n=1,r=1,o=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:o}=this,s=n/2,c=r/2,h=e+s,a=t+c,l=Math.max(0,Math.min(o,Math.min(s,c))),f=l;return this._center=new p(h,a),this._radius=new p(l,f),this._diff=new p(s-l,c-f),this}drawTo(e){const{x:t,y:n,width:r,height:o,radius:s}=this;return e.roundRect(t,n,r,o,s),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class ae extends Y{constructor(e=[]){super(),this.points=e}getPoint(e,t=new p){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),s=r-o,c=n[o===0?o:o-1],h=n[o],a=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return t.set(St(s,c.x,h.x,a.x,l.x),St(s,c.y,h.y,a.y,l.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class lt extends rt{constructor(t){super();V(this,"startPoint");V(this,"currentPoint");V(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:o,y:s}=t[n];this.lineTo(o,s)}return this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}_closePointArray(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenPointArray(t=40,n=[]){return this._closePointArray(super.getUnevenPointArray(t,n))}getSpacedPointArray(t=40,n=[]){return this._closePointArray(super.getSpacedPointArray(t,n))}getAdaptivePointArray(t=[]){return this._closePointArray(super.getAdaptivePointArray(t))}_setCurrentPoint(t){return this.currentPoint=new p(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new j(n.clone(),t.clone())),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new p(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(j.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,o,s,c){const h=this.currentPoint;return h!=null&&h.equals({x:s,y:c})||this.curves.push(Mt.from((h==null?void 0:h.x)??0,(h==null?void 0:h.y)??0,t,n,r,o,s,c)),this._setCurrentPoint({x:s,y:c}),this}quadraticCurveTo(t,n,r,o){const s=this.currentPoint;return s!=null&&s.equals({x:r,y:o})||this.curves.push(Pt.from((s==null?void 0:s.x)??0,(s==null?void 0:s.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,s,c){const h=new re(t,n,r,o,s,!c);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeArc(t,n,r,o,s,c){var h,a;return t+=((h=this.currentPoint)==null?void 0:h.x)??0,n+=((a=this.currentPoint)==null?void 0:a.y)??0,this.arc(t,n,r,o,s,c),this}arcTo(t,n,r,o,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,s,c,h,a=!0){const l=new oe(t,n,r,o,s,c,h,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,n,r,o,s,c,h,a){var l,f;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((f=this.currentPoint)==null?void 0:f.y)??0,this.ellipse(t,n,r,o,s,c,h,a),this}rect(t,n,r,o){const s=new ce(t,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,s){const c=new he(t,n,r,o,s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new p;return this.curves.push(new ae([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function ln(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function un(i,e,t,n){const r=e.clone().sub(i),o=n.clone().sub(t),s=t.clone().sub(i),c=r.cross(o);if(c===0)return new p((i.x+t.x)/2,(i.y+t.y)/2);const h=s.cross(o)/c;return Math.abs(h)>1?new p((i.x+t.x)/2,(i.y+t.y)/2):new p(i.x+h*r.x,i.y+h*r.y)}class G extends rt{constructor(t,n={}){super();V(this,"currentCurve",new lt);V(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof G?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(t){const n=this.curves.findIndex(r=>r===this.currentCurve);return n>-1&&this.curves.splice(n,1),t instanceof G?this.curves.push(...t.curves.filter(r=>r.curves.length).map(r=>r.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new lt().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new lt,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,o,s,c){return this.currentCurve.bezierCurveTo(t,n,r,o,s,c),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,s,c){return this.currentCurve.arc(t,n,r,o,s,c),this}arcTo(t,n,r,o,s){return this.currentCurve.arcTo(t,n,r,o,s),this}ellipse(t,n,r,o,s,c,h,a){return this.currentCurve.ellipse(t,n,r,o,s,c,h,a),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,s){return this.currentCurve.roundRect(t,n,r,o,s),this}reset(){return this.currentCurve=new lt,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.getFlatCurves(),r=[],o=[],s=[];n.forEach((h,a)=>{const l=h.getControlPointRefs(),f=h.isClockwise();s[a]=l,o[a]=f;const y=l[0],x=l[l.length-1]??y;r.push({start:f?x:y,end:f?y:x,index:a})});const c=[];return r.forEach((h,a)=>{c[a]=[],r.forEach((l,f)=>{var y;l.start&&h.end&&f!==a&&((y=l.start)!=null&&y.equals(h.end))&&c[a].push(l.index)})}),n.forEach((h,a)=>{const l=o[a];s[a].forEach(f=>{f.add(h.getNormal(h.getTForPoint(f)).scale(l?t:-t))})}),c.forEach((h,a)=>{const l=s[a];h.forEach(f=>{const y=s[f],x=un(l[l.length-1],l[l.length-2]??l[l.length-1],y[0],y[1]??y[0]);x&&(l[l.length-1].copy(x),y[0].copy(x))})}),this}getMinMax(t=p.MAX,n=p.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,n),r&&o>1){const c=o/2,h=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const f=s.getPoint(l),y=s.getNormal(l),x=y.clone().scale(h?c:-c),u=y.clone().scale(h?-c:c);a.push(f.clone().add(x),f.clone().add(u),f.clone().add({x:c,y:0}),f.clone().add({x:-c,y:0}),f.clone().add({x:0,y:c}),f.clone().add({x:0,y:-c}),f.clone().add({x:c,y:c}),f.clone().add({x:-c,y:-c}))}t.min(...a),n.max(...a)}}),{min:t.finite(),max:n.finite()}}strokeTriangulate(t){const n=(t==null?void 0:t.indices)??[],r=(t==null?void 0:t.vertices)??[];return this.curves.forEach(o=>{o.strokeTriangulate({...t,indices:n,vertices:r})}),{indices:n,vertices:r}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new X(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.curves.forEach(s=>{s.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.getControlPointRefs().forEach(s=>{R(t,s.x,s.y,{radius:4})}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSVGPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},n={};for(const o in t)t[o]!==void 0&&(n[ln(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class le{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=p.MAX,n=p.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new X(t.x,t.y,n.x-t.x,n.y-t.y)}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${n} ${r}" width="${n}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:o,width:s,height:c}=this.getBoundingBox(),h=document.createElement("canvas");h.width=s*t,h.height=c*t,h.style.width=`${s}px`,h.style.height=`${c}px`;const a=h.getContext("2d");return a&&(a.scale(t,t),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,n)})),h}}class fn{constructor(e,t,n=1,r=1){V(this,"controlPoints",[]);this.rows=e,this.cols=t,this.width=n,this.height=r;for(let o=0;o<e;o++){this.controlPoints[o]=[];for(let s=0;s<t;s++)this.controlPoints[o][s]={x:s/(t-1)*n,y:o/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}}function ue(i){const e=[];return e[0]=(1-i)**3/6,e[1]=(3*i**3-6*i**2+4)/6,e[2]=(-3*i**3+3*i**2+3*i+1)/6,e[3]=i**3/6,e}function yn(i,e,t=e.width,n=e.height){const r=i.x/t*(e.cols-1),o=i.y/n*(e.rows-1),s=Math.floor(r),c=Math.floor(o),h=r-s,a=o-c,l=ue(h),f=ue(a);let y=0,x=0;for(let u=0;u<4;u++)for(let g=0;g<4;g++){const M=Math.min(Math.max(c-1+u,0),e.rows-1),T=Math.min(Math.max(s-1+g,0),e.cols-1),I=e.controlPoints[M][T],P=l[g]*f[u];y+=I.x*P,x+=I.y*P}i.set(y,x)}const fe="data:image/svg+xml;",ye=`${fe}base64,`,xe=`${fe}charset=utf8,`;function pe(i){if(typeof i=="string"){let e;i.startsWith(ye)?(i=i.substring(ye.length,i.length),e=atob(i)):i.startsWith(xe)?(i=i.substring(xe.length,i.length),e=decodeURIComponent(i)):e=i;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
|
|
2
|
-
${e}`);return t.documentElement}else return i}const xn="px",pn=90,ge=["mm","cm","in","pt","pc","px"],de={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 L(i){let e="px";if(typeof i=="string"||i instanceof String)for(let n=0,r=ge.length;n<r;n++){const o=ge[n];if(i.endsWith(o)){e=o,i=i.substring(0,i.length-o.length);break}}let t;return t=de[e][xn],t<0&&(t=de[e].in*pn),t*Number.parseFloat(i)}const gn=new z,wt=new z,me=new z,Me=new z;function dn(i,e,t){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=mn(i);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function mn(i){const e=new z,t=gn;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&e.translate(L(i.getAttribute("x")),L(i.getAttribute("y"))),i.hasAttribute("transform")){const n=i.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const s=o.indexOf("("),
|
|
1
|
+
(function(v,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(v=typeof globalThis<"u"?globalThis:v||self,R(v.modernPath2d={}))})(this,function(v){"use strict";var Nn=Object.defineProperty;var Fn=(v,R,nt)=>R in v?Nn(v,R,{enumerable:!0,configurable:!0,writable:!0,value:nt}):v[R]=nt;var U=(v,R,nt)=>Fn(v,typeof R!="symbol"?R+"":R,nt);function R(i,e,t,n={}){const{radius:r=1}=n;i.moveTo(e,t),i.arc(e,t,r,0,Math.PI*2)}const nt={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ct(i,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:h=0,strokeDasharray:c=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:f=0,shadowBlur:y=0,shadowColor:x="rgba(0, 0, 0, 0)"}=e;i.fillStyle=t,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=nt[s],i.miterLimit=h,i.setLineDash(c),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=f,i.shadowBlur=y,i.shadowColor=x}class p{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new p(1/0,1/0)}static get MIN(){return new p(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,o=-(this.y-t.y),s=Math.sin(n),h=Math.cos(n);return this.set(t.x+(r*h-o*s),t.y-(r*s+o*h)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){const r=e<0?n.x-this.x+n.x:this.x,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(e)*o),this.y=n.y+(o+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new p(this.x,this.y)}}class V{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new p((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new V;if(e.length===1)return e[0].clone();const t=e[0],n=e.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new V(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new V(this.left,this.top,this.width,this.height)}}class z{constructor(e=1,t=0,n=0,r=0,o=1,s=0,h=0,c=0,a=1){U(this,"elements",[]);this.set(e,t,n,r,o,s,h,c,a)}set(e,t,n,r,o,s,h,c,a){const l=this.elements;return l[0]=e,l[1]=r,l[2]=h,l[3]=t,l[4]=o,l[5]=c,l[6]=n,l[7]=s,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,s=n[0],h=n[3],c=n[6],a=n[1],l=n[4],f=n[7],y=n[2],x=n[5],u=n[8],g=r[0],d=r[3],T=r[6],S=r[1],P=r[4],w=r[7],I=r[2],E=r[5],m=r[8];return o[0]=s*g+h*S+c*I,o[3]=s*d+h*P+c*E,o[6]=s*T+h*w+c*m,o[1]=a*g+l*S+f*I,o[4]=a*d+l*P+f*E,o[7]=a*T+l*w+f*m,o[2]=y*g+x*S+u*I,o[5]=y*d+x*P+u*E,o[8]=y*T+x*w+u*m,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],s=e[4],h=e[5],c=e[6],a=e[7],l=e[8],f=l*s-h*a,y=h*c-l*o,x=a*o-s*c,u=t*f+n*y+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/u;return e[0]=f*g,e[1]=(r*a-l*n)*g,e[2]=(h*n-r*s)*g,e[3]=y*g,e[4]=(l*t-r*c)*g,e[5]=(r*o-h*t)*g,e[6]=x*g,e[7]=(n*c-a*t)*g,e[8]=(s*t-n*o)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(bt.makeScale(e,t)),this}rotate(e){return this.premultiply(bt.makeRotation(-e)),this}translate(e,t){return this.premultiply(bt.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new z;function zt(i,e,t,n){const r=i*t+e*n,o=Math.sqrt(i*i+e*e)*Math.sqrt(t*t+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-e*t<0&&(s=-s),s}function Zt(i,e,t,n,r,o,s,h){if(e===0||t===0){i.lineTo(h.x,h.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(s.x-h.x)/2,a=(s.y-h.y)/2,l=Math.cos(n)*c+Math.sin(n)*a,f=-Math.sin(n)*c+Math.cos(n)*a;let y=e*e,x=t*t;const u=l*l,g=f*f,d=u/y+g/x;if(d>1){const O=Math.sqrt(d);e=O*e,t=O*t,y=e*e,x=t*t}const T=y*g+x*u,S=(y*x-T)/T;let P=Math.sqrt(Math.max(0,S));r===o&&(P=-P);const w=P*e*f/t,I=-P*t*l/e,E=Math.cos(n)*w-Math.sin(n)*I+(s.x+h.x)/2,m=Math.sin(n)*w+Math.cos(n)*I+(s.y+h.y)/2,M=zt(1,0,(l-w)/e,(f-I)/t),q=zt((l-w)/e,(f-I)/t,(-l-w)/e,(-f-I)/t)%(Math.PI*2);i.ellipse(E,m,e,t,n,M,M+q,o===0)}const F={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Z(i,e,t=0){let h=0,c=!0,a="",l="";const f=[];function y(d,T,S){const P=new SyntaxError(`Unexpected character "${d}" at index ${T}.`);throw P.partial=S,P}function x(){a!==""&&(l===""?f.push(Number(a)):f.push(Number(a)*10**Number(l))),a="",l=""}let u;const g=i.length;for(let d=0;d<g;d++){if(u=i[d],Array.isArray(e)&&e.includes(f.length%t)&&F.FLAGS.test(u)){h=1,a=u,x();continue}if(h===0){if(F.WHITESPACE.test(u))continue;if(F.DIGIT.test(u)||F.SIGN.test(u)){h=1,a=u;continue}if(F.POINT.test(u)){h=2,a=u;continue}F.COMMA.test(u)&&(c&&y(u,d,f),c=!0)}if(h===1){if(F.DIGIT.test(u)){a+=u;continue}if(F.POINT.test(u)){a+=u,h=2;continue}if(F.EXP.test(u)){h=3;continue}F.SIGN.test(u)&&a.length===1&&F.SIGN.test(a[0])&&y(u,d,f)}if(h===2){if(F.DIGIT.test(u)){a+=u;continue}if(F.EXP.test(u)){h=3;continue}F.POINT.test(u)&&a[a.length-1]==="."&&y(u,d,f)}if(h===3){if(F.DIGIT.test(u)){l+=u;continue}if(F.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&F.SIGN.test(l)&&y(u,d,f)}}F.WHITESPACE.test(u)?(x(),h=0,c=!1):F.COMMA.test(u)?(x(),h=0,c=!0):F.SIGN.test(u)?(x(),h=1,a=u):F.POINT.test(u)?(x(),h=2,a=u):y(u,d,f)}return x(),f}function st(i,e){return i-(e-i)}function kt(i,e){const t=new p,n=new p;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?t.add(s):t.copy(s),e.moveTo(t.x,t.y),n.copy(t);else if(s.type==="h"||s.type==="H")s.type==="h"?t.x+=s.x:t.x=s.x,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="v"||s.type==="V")s.type==="v"?t.y+=s.y:t.y=s.y,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="l"||s.type==="L")s.type==="l"?t.add(s):t.copy(s),e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="c"||s.type==="C")s.type==="c"?(e.bezierCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(e.quadraticCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x,t.y+s.y),n.x=t.x+s.x1,n.y=t.y+s.y1,t.add(s)):(e.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,t.copy(s));else if(s.type==="t"||s.type==="T"){const h=st(t.x,n.x),c=st(t.y,n.y);n.x=h,n.y=c,s.type==="t"?(e.quadraticCurveTo(h,c,t.x+s.x,t.y+s.y),t.add(s)):(e.quadraticCurveTo(h,c,s.x,s.y),t.copy(s))}else if(s.type==="a"||s.type==="A"){const h=t.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;t.add(s)}else{if(t.equals(s))continue;t.copy(s)}n.copy(t),Zt(e,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,h,t)}else s.type==="z"||s.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",s)}}function Gt(i){let e,t;const n=[];for(let r=0,o=i.length;r<o;r++){const s=i[r];switch(s.type){case"m":case"M":if(s.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&s.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y},e={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),t={x:s.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),t={x:(t==null?void 0:t.x)??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"c":case"C":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"a":case"A":n.push(`${s.type} ${s.rx} ${s.ry} ${s.angle} ${s.largeArcFlag} ${s.sweepFlag} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const Ce=/[a-df-z][^a-df-z]*/gi;function It(i){const e=[],t=i.match(Ce);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],s=o.charAt(0),h=o.slice(1).trim();let c;switch(s){case"m":case"M":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)a===0?e.push({type:s,x:c[a],y:c[a+1]}):e.push({type:s==="m"?"l":"L",x:c[a],y:c[a+1]});break;case"h":case"H":c=Z(h);for(let a=0,l=c.length;a<l;a++)e.push({type:s,x:c[a]});break;case"v":case"V":c=Z(h);for(let a=0,l=c.length;a<l;a++)e.push({type:s,y:c[a]});break;case"l":case"L":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)e.push({type:s,x:c[a],y:c[a+1]});break;case"c":case"C":c=Z(h);for(let a=0,l=c.length;a<l;a+=6)e.push({type:s,x1:c[a],y1:c[a+1],x2:c[a+2],y2:c[a+3],x:c[a+4],y:c[a+5]});break;case"s":case"S":c=Z(h);for(let a=0,l=c.length;a<l;a+=4)e.push({type:s,x2:c[a],y2:c[a+1],x:c[a+2],y:c[a+3]});break;case"q":case"Q":c=Z(h);for(let a=0,l=c.length;a<l;a+=4)e.push({type:s,x1:c[a],y1:c[a+1],x:c[a+2],y:c[a+3]});break;case"t":case"T":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)e.push({type:s,x:c[a],y:c[a+1]});break;case"a":case"A":c=Z(h,[3,4],7);for(let a=0,l=c.length;a<l;a+=7)e.push({type:s,rx:c[a],ry:c[a+1],angle:c[a+2],largeArcFlag:c[a+3],sweepFlag:c[a+4],x:c[a+5],y:c[a+6]});break;case"z":case"Z":e.push({type:s});break;default:console.warn(o)}}return e}function St(i,e,t,n,r){const o=(n-e)*.5,s=(r-t)*.5,h=i*i,c=i*h;return(2*t-2*n+o+s)*c+(-3*t+3*n-2*o-s)*h+o*i+t}function be(i,e){const t=1-i;return t*t*t*e}function ke(i,e){const t=1-i;return 3*t*t*i*e}function Ie(i,e){return 3*(1-i)*i*i*e}function Se(i,e){return i*i*i*e}function Et(i,e,t,n,r){return be(i,e)+ke(i,t)+Ie(i,n)+Se(i,r)}function Ee(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Bt(i,0,r,t,!0);const s=[];if(!o||o.next===o.prev)return s;let h,c,a;if(n&&(o=De(i,e,o,t)),i.length>80*t){h=1/0,c=1/0;let l=-1/0,f=-1/0;for(let y=t;y<r;y+=t){const x=i[y],u=i[y+1];x<h&&(h=x),u<c&&(c=u),x>l&&(l=x),u>f&&(f=u)}a=Math.max(l-h,f-c),a=a!==0?32767/a:0}return ot(o,s,t,h,c,a,0),s}function Bt(i,e,t,n,r){let o;if(r===Ue(i,e,t,n)>0)for(let s=e;s<t;s+=n)o=Vt(s/n|0,i[s],i[s+1],o);else for(let s=t-n;s>=e;s-=n)o=Vt(s/n|0,i[s],i[s+1],o);return o&&it(o,o.next)&&(at(o),o=o.next),o}function H(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(it(t,t.next)||N(t.prev,t,t.next)===0)){if(at(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ot(i,e,t,n,r,o,s){if(!i)return;!s&&o&&ze(i,n,r,o);let h=i;for(;i.prev!==i.next;){const c=i.prev,a=i.next;if(o?$e(i,n,r,o):Le(i)){e.push(c.i,i.i,a.i),at(i),i=a.next,h=a.next;continue}if(i=a,i===h){s?s===1?(i=Ne(H(i),e),ot(i,e,t,n,r,o,2)):s===2&&Fe(i,e,t,n,r,o):ot(H(i),e,t,n,r,o,1);break}}}function Le(i){const e=i.prev,t=i,n=i.next;if(N(e,t,n)>=0)return!1;const r=e.x,o=t.x,s=n.x,h=e.y,c=t.y,a=n.y,l=Math.min(r,o,s),f=Math.min(h,c,a),y=Math.max(r,o,s),x=Math.max(h,c,a);let u=n.next;for(;u!==e;){if(u.x>=l&&u.x<=y&&u.y>=f&&u.y<=x&&ct(r,h,o,c,s,a,u.x,u.y)&&N(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function $e(i,e,t,n){const r=i.prev,o=i,s=i.next;if(N(r,o,s)>=0)return!1;const h=r.x,c=o.x,a=s.x,l=r.y,f=o.y,y=s.y,x=Math.min(h,c,a),u=Math.min(l,f,y),g=Math.max(h,c,a),d=Math.max(l,f,y),T=Lt(x,u,e,t,n),S=Lt(g,d,e,t,n);let P=i.prevZ,w=i.nextZ;for(;P&&P.z>=T&&w&&w.z<=S;){if(P.x>=x&&P.x<=g&&P.y>=u&&P.y<=d&&P!==r&&P!==s&&ct(h,l,c,f,a,y,P.x,P.y)&&N(P.prev,P,P.next)>=0||(P=P.prevZ,w.x>=x&&w.x<=g&&w.y>=u&&w.y<=d&&w!==r&&w!==s&&ct(h,l,c,f,a,y,w.x,w.y)&&N(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;P&&P.z>=T;){if(P.x>=x&&P.x<=g&&P.y>=u&&P.y<=d&&P!==r&&P!==s&&ct(h,l,c,f,a,y,P.x,P.y)&&N(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;w&&w.z<=S;){if(w.x>=x&&w.x<=g&&w.y>=u&&w.y<=d&&w!==r&&w!==s&&ct(h,l,c,f,a,y,w.x,w.y)&&N(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Ne(i,e){let t=i;do{const n=t.prev,r=t.next.next;!it(n,r)&&Xt(n,t,t.next,r)&&ht(n,r)&&ht(r,n)&&(e.push(n.i,t.i,r.i),at(t),at(t.next),t=i=r),t=t.next}while(t!==i);return H(t)}function Fe(i,e,t,n,r,o){let s=i;do{let h=s.next.next;for(;h!==s.prev;){if(s.i!==h.i&&Be(s,h)){let c=Ut(s,h);s=H(s,s.next),c=H(c,c.next),ot(s,e,t,n,r,o,0),ot(c,e,t,n,r,o,0);return}h=h.next}s=s.next}while(s!==i)}function De(i,e,t,n){const r=[];for(let o=0,s=e.length;o<s;o++){const h=e[o]*n,c=o<s-1?e[o+1]*n:i.length,a=Bt(i,h,c,n,!1);a===a.next&&(a.steiner=!0),r.push(Ge(a))}r.sort(_e);for(let o=0;o<r.length;o++)t=qe(r[o],t);return t}function _e(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function qe(i,e){const t=Oe(i,e);if(!t)return e;const n=Ut(t,i);return H(n,n.next),H(t,t.next)}function Oe(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,s;if(it(i,t))return t;do{if(it(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>o&&(o=f,s=t.x<t.next.x?t:t.next,f===n))return s}t=t.next}while(t!==e);if(!s)return null;const h=s,c=s.x,a=s.y;let l=1/0;t=s;do{if(n>=t.x&&t.x>=c&&n!==t.x&&jt(r<a?n:o,r,c,a,r<a?o:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);ht(t,i)&&(f<l||f===l&&(t.x>s.x||t.x===s.x&&Re(s,t)))&&(s=t,l=f)}t=t.next}while(t!==h);return s}function Re(i,e){return N(i.prev,i,e.prev)<0&&N(e.next,i,i.next)<0}function ze(i,e,t,n){let r=i;do r.z===0&&(r.z=Lt(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Ze(r)}function Ze(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let s=n,h=0;for(let a=0;a<t&&(h++,s=s.nextZ,!!s);a++);let c=t;for(;h>0||c>0&&s;)h!==0&&(c===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,h--):(r=s,s=s.nextZ,c--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,t*=2}while(e>1);return i}function Lt(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function Ge(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function jt(i,e,t,n,r,o,s,h){return(r-s)*(e-h)>=(i-s)*(o-h)&&(i-s)*(n-h)>=(t-s)*(e-h)&&(t-s)*(o-h)>=(r-s)*(n-h)}function ct(i,e,t,n,r,o,s,h){return!(i===s&&e===h)&&jt(i,e,t,n,r,o,s,h)}function Be(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!je(i,e)&&(ht(i,e)&&ht(e,i)&&Xe(i,e)&&(N(i.prev,i,e.prev)||N(i,e.prev,e))||it(i,e)&&N(i.prev,i,i.next)>0&&N(e.prev,e,e.next)>0)}function N(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function it(i,e){return i.x===e.x&&i.y===e.y}function Xt(i,e,t,n){const r=gt(N(i,e,t)),o=gt(N(i,e,n)),s=gt(N(t,n,i)),h=gt(N(t,n,e));return!!(r!==o&&s!==h||r===0&&pt(i,t,e)||o===0&&pt(i,n,e)||s===0&&pt(t,i,n)||h===0&&pt(t,e,n))}function pt(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function gt(i){return i>0?1:i<0?-1:0}function je(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Xt(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ht(i,e){return N(i.prev,i,i.next)<0?N(i,e,i.next)>=0&&N(i,i.prev,e)>=0:N(i,e,i.prev)<0||N(i,i.next,e)<0}function Xe(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Ut(i,e){const t=$t(i.i,i.x,i.y),n=$t(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Vt(i,e,t,n){const r=$t(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function at(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $t(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ue(i,e,t,n){let r=0;for(let o=e,s=t-n;o<t;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Wt(i,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=t.length/o,indicesOffset:h=n.length}=e;const c=Ee(i,r,2);if(c){for(let l=0;l<c.length;l+=3)n[h++]=c[l]+s,n[h++]=c[l+1]+s,n[h++]=c[l+2]+s;let a=s*o;for(let l=0;l<i.length;l+=2)t[a]=i[l],t[a+1]=i[l+1],a+=o}return{vertices:t,indices:n}}const Ve=8,dt=11920929e-14,We=1;function Ht(i,e,t,n,r,o,s,h,c=.5,a=[]){const f=Math.min(.99,Math.max(0,c));let y=(We-f)/1;return y*=y,Nt(i,e,t,n,r,o,s,h,a,y,0),a.push(s,h),a}function Nt(i,e,t,n,r,o,s,h,c,a,l){if(l>Ve)return;const f=(i+t)/2,y=(e+n)/2,x=(t+r)/2,u=(n+o)/2,g=(r+s)/2,d=(o+h)/2,T=(f+x)/2,S=(y+u)/2,P=(x+g)/2,w=(u+d)/2,I=(T+P)/2,E=(S+w)/2;if(l>0){let m=s-i,M=h-e;const q=Math.abs((t-s)*M-(n-h)*m),O=Math.abs((r-s)*M-(o-h)*m);if(q>dt&&O>dt){if((q+O)*(q+O)<=a*(m*m+M*M)){c.push(I,E);return}}else if(q>dt){if(q*q<=a*(m*m+M*M)){c.push(I,E);return}}else if(O>dt){if(O*O<=a*(m*m+M*M)){c.push(I,E);return}}else if(m=I-(i+s)/2,M=E-(e+h)/2,m*m+M*M<=a){c.push(I,E);return}}Nt(i,e,f,y,T,S,I,E,c,a,l+1),Nt(I,E,P,w,g,d,s,h,c,a,l+1)}const He=8,Qe=11920929e-14,Ye=1;function Qt(i,e,t,n,r,o,s=.5,h=[]){const a=Math.min(.99,Math.max(0,s));let l=(Ye-a)/1;return l*=l,Ft(h,i,e,t,n,r,o,l,0),h.push(r,o),h}function Ft(i,e,t,n,r,o,s,h,c){if(c>He)return;const a=(e+n)/2,l=(t+r)/2,f=(n+o)/2,y=(r+s)/2,x=(a+f)/2,u=(l+y)/2;let g=o-e,d=s-t;const T=Math.abs((n-o)*d-(r-s)*g);if(T>Qe){if(T*T<=h*(g*g+d*d)){i.push(x,u);return}}else if(g=x-(e+o)/2,d=u-(t+s)/2,g*g+d*d<=h){i.push(x,u);return}Ft(i,e,t,a,l,x,u,h,c+1),Ft(i,x,u,f,y,o,s,h,c+1)}function Je(i,e){const t=1-i;return t*t*e}function Ke(i,e){return 2*(1-i)*i*e}function tn(i,e){return i*i*e}function Dt(i,e,t,n){return Je(i,e)+Ke(i,t)+tn(i,n)}const en=1e-4,Yt=1e-4;function Jt(i,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=e,h=en;if(i.length===0)return{vertices:t,indices:n};const c=r;let a=c.alignment;if(r.alignment!==.5){let $=nn(i);o&&($*=-1),a=(a-.5)*$+.5}const l={x:i[0],y:i[1]},f={x:i[i.length-2],y:i[i.length-1]},y=s,x=Math.abs(l.x-f.x)<h&&Math.abs(l.y-f.y)<h;if(y){i=i.slice(),x&&(i.pop(),i.pop(),f.x=i[i.length-2],f.y=i[i.length-1]);const $=(l.x+f.x)*.5,W=(f.y+l.y)*.5;i.unshift($,W),i.push($,W)}const u=t,g=i.length/2;let d=i.length;const T=u.length/2,S=c.width/2,P=S*S,w=c.miterLimit*c.miterLimit;let I=i[0],E=i[1],m=i[2],M=i[3],q=0,O=0,C=-(E-M),b=I-m,D=0,_=0,B=Math.sqrt(C*C+b*b);C/=B,b/=B,C*=S,b*=S;const Pe=a,A=(1-Pe)*2,k=Pe*2;y||(c.cap==="round"?d+=Q(I-C*(A-k)*.5,E-b*(A-k)*.5,I-C*A,E-b*A,I+C*k,E+b*k,u,!0)+2:c.cap==="square"&&(d+=Kt(I,E,C,b,A,k,!0,u))),u.push(I-C*A,E-b*A),u.push(I+C*k,E+b*k);for(let $=1;$<g-1;++$){I=i[($-1)*2],E=i[($-1)*2+1],m=i[$*2],M=i[$*2+1],q=i[($+1)*2],O=i[($+1)*2+1],C=-(E-M),b=I-m,B=Math.sqrt(C*C+b*b),C/=B,b/=B,C*=S,b*=S,D=-(M-O),_=m-q,B=Math.sqrt(D*D+_*_),D/=B,_/=B,D*=S,_*=S;const W=m-I,ut=E-M,ft=m-q,yt=O-M,we=W*ft+ut*yt,vt=ut*ft-yt*W,xt=vt<0;if(Math.abs(vt)<.001*Math.abs(we)){u.push(m-C*A,M-b*A),u.push(m+C*k,M+b*k),we>=0&&(c.join==="round"?d+=Q(m,M,m-C*A,M-b*A,m-D*A,M-_*A,u,!1)+4:d+=2,u.push(m-D*k,M-_*k),u.push(m+D*A,M+_*A));continue}const ve=(-C+I)*(-b+M)-(-C+m)*(-b+E),Te=(-D+q)*(-_+M)-(-D+m)*(-_+O),Tt=(W*Te-ft*ve)/vt,At=(yt*ve-ut*Te)/vt,Rt=(Tt-m)*(Tt-m)+(At-M)*(At-M),J=m+(Tt-m)*A,K=M+(At-M)*A,tt=m-(Tt-m)*k,et=M-(At-M)*k,Ln=Math.min(W*W+ut*ut,ft*ft+yt*yt),Ae=xt?A:k,$n=Ln+Ae*Ae*P;Rt<=$n?c.join==="bevel"||Rt/P>w?(xt?(u.push(J,K),u.push(m+C*k,M+b*k),u.push(J,K),u.push(m+D*k,M+_*k)):(u.push(m-C*A,M-b*A),u.push(tt,et),u.push(m-D*A,M-_*A),u.push(tt,et)),d+=2):c.join==="round"?xt?(u.push(J,K),u.push(m+C*k,M+b*k),d+=Q(m,M,m+C*k,M+b*k,m+D*k,M+_*k,u,!0)+4,u.push(J,K),u.push(m+D*k,M+_*k)):(u.push(m-C*A,M-b*A),u.push(tt,et),d+=Q(m,M,m-C*A,M-b*A,m-D*A,M-_*A,u,!1)+4,u.push(m-D*A,M-_*A),u.push(tt,et)):(u.push(J,K),u.push(tt,et)):(u.push(m-C*A,M-b*A),u.push(m+C*k,M+b*k),c.join==="round"?xt?d+=Q(m,M,m+C*k,M+b*k,m+D*k,M+_*k,u,!0)+2:d+=Q(m,M,m-C*A,M-b*A,m-D*A,M-_*A,u,!1)+2:c.join==="miter"&&Rt/P<=w&&(xt?(u.push(tt,et),u.push(tt,et)):(u.push(J,K),u.push(J,K)),d+=2),u.push(m-D*A,M-_*A),u.push(m+D*k,M+_*k),d+=2)}I=i[(g-2)*2],E=i[(g-2)*2+1],m=i[(g-1)*2],M=i[(g-1)*2+1],C=-(E-M),b=I-m,B=Math.sqrt(C*C+b*b),C/=B,b/=B,C*=S,b*=S,u.push(m-C*A,M-b*A),u.push(m+C*k,M+b*k),y||(c.cap==="round"?d+=Q(m-C*(A-k)*.5,M-b*(A-k)*.5,m-C*A,M-b*A,m+C*k,M+b*k,u,!1)+2:c.cap==="square"&&(d+=Kt(m,M,C,b,A,k,!1,u)));const En=Yt*Yt;for(let $=T;$<d+T-2;++$)I=u[$*2],E=u[$*2+1],m=u[($+1)*2],M=u[($+1)*2+1],q=u[($+2)*2],O=u[($+2)*2+1],!(Math.abs(I*(M-O)+m*(O-E)+q*(E-M))<En)&&n.push($,$+1,$+2);return{vertices:t,indices:n}}function nn(i){const e=i.length;if(e<6)return 1;let t=0;for(let n=0,r=i[e-2],o=i[e-1];n<e;n+=2){const s=i[n],h=i[n+1];t+=(s-r)*(h+o),r=s,o=h}return t<0?-1:1}function Kt(i,e,t,n,r,o,s,h){const c=i-t*r,a=e-n*r,l=i+t*o,f=e+n*o;let y,x;s?(y=n,x=-t):(y=-n,x=t);const u=c+y,g=a+x,d=l+y,T=f+x;return h.push(u,g),h.push(d,T),2}function Q(i,e,t,n,r,o,s,h){const c=t-i,a=n-e;let l=Math.atan2(c,a),f=Math.atan2(r-i,o-e);h&&l<f?l+=Math.PI*2:!h&&l>f&&(f+=Math.PI*2);let y=l;const x=f-l,u=Math.abs(x),g=Math.sqrt(c*c+a*a),d=(15*u*Math.sqrt(g)/Math.PI>>0)+1,T=x/d;if(y+=T,h){s.push(i,e),s.push(t,n);for(let S=1,P=y;S<d;S++,P+=T)s.push(i,e),s.push(i+Math.sin(P)*g,e+Math.cos(P)*g);s.push(i,e),s.push(r,o)}else{s.push(t,n),s.push(i,e);for(let S=1,P=y;S<d;S++,P+=T)s.push(i+Math.sin(P)*g,e+Math.cos(P)*g),s.push(i,e);s.push(r,o),s.push(i,e)}return d*2}class Y{constructor(){U(this,"arcLengthDivision",200);U(this,"_arcLengths")}getPointAt(e,t=new p){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){const t=typeof e=="function";return this.getControlPointRefs().forEach(n=>{t?e(n):n.applyMatrix3(e)}),this}getUnevenPointArray(e=5,t=[]){const n=new p;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedPointArray(e=5,t=[]){const n=new p;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,n),t.push(n.x,n.y);return t}getAdaptivePointArray(e=[]){return this.getUnevenPointArray(5,e)}_pointArrayToPoint(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){const o=e[n],s=e[n+1];t.push(new p(o,s))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedPointArray(e);return this._pointArrayToPoint(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenPointArray(e);return this._pointArrayToPoint(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptivePointArray();return this._pointArrayToPoint(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenPointArray(e):n=this.getAdaptivePointArray(),this._pointArrayToPoint(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),o=1;o<=e;o++){const s=this.getPoint(o/e);n+=s.distanceTo(r),t.push(n),r=s}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/n[0];let s=0,h=0,c=r-1,a;for(;h<=c;)if(s=Math.floor(h+(c-h)/2),a=n[s]-o,a<0)h=s+1;else if(a>0)c=s-1;else{c=s;break}if(s=c,n[s]===o)return s/(r-1);const l=n[s],y=n[s+1]-l,x=(o-l)/y;return(s+x)/(r-1)}getTangent(e,t=new p){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new p){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(e)<t)return o;s.x<e.x?n=o:r=o}return o}getMinMax(e=p.MAX,t=p.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];e.min(s),t.max(s)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new V(e.x,e.y,t.x-e.x,t.y-e.y)}fillTriangulate(e){return Wt(this.getAdaptivePointArray(),e)}strokeTriangulate(e){return Jt(this.getAdaptivePointArray(),e)}toTriangulatedSVGString(e=this.fillTriangulate(),t=0){const{vertices:n,indices:r}=e,o={x:-t,y:-t},s={x:t,y:t},h=l=>{const f=n[l*2],y=n[l*2+1];return o.x=Math.min(o.x,f+t),s.x=Math.max(s.x,f+t),o.y=Math.min(o.y,y+t),s.y=Math.max(s.y,y+t),[f,y]};let c="";for(let l=0,f=r.length;l<f;l+=3){const y=h(r[l]),x=h(r[l+1]),u=h(r[l+2]);c+=`<polygon points="${y.join(",")} ${x.join(",")} ${u.join(",")}" fill="none" stroke="black" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" />`}const a=[o.x,o.y,s.x-o.x,s.y-o.y];return`<svg width="${a[2]}" height="${a[3]}" viewBox="${a.join(" ")}" xmlns="http://www.w3.org/2000/svg">${c}</svg>`}toTriangulatedSVG(e,t){return new DOMParser().parseFromString(this.toTriangulatedSVGString(e,t),"image/svg+xml").documentElement}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return Gt(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const sn=new z,te=new z,ee=new z,mt=new p;class _t extends Y{constructor(e=new p,t=new p,n=new p,r=0,o=0,s=Math.PI*2,h=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=h}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const n=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new p){const n=this._getDeltaAngle(),r=this.startAngle+e*n;let o=this.cx+this.rx*Math.cos(r),s=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const h=Math.cos(this.rotate),c=Math.sin(this.rotate),a=o-this.cx,l=s-this.cy;o=a*h-l*c+this.cx,s=a*c+l*h+this.cy}return t.set(o,s)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:h,rotate:c}=this,a=e+n*Math.cos(o)*Math.cos(c)-r*Math.sin(o)*Math.sin(c),l=t+n*Math.cos(o)*Math.sin(c)+r*Math.sin(o)*Math.cos(c),f=Math.abs(o-s),y=f>Math.PI?1:0,x=h?1:0,u=c*180/Math.PI;if(f>=2*Math.PI){const g=o+Math.PI,d=e+n*Math.cos(g)*Math.cos(c)-r*Math.sin(g)*Math.sin(c),T=t+n*Math.cos(g)*Math.sin(c)+r*Math.sin(g)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:d,y:T},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const g=e+n*Math.cos(s)*Math.cos(c)-r*Math.sin(s)*Math.sin(c),d=t+n*Math.cos(s)*Math.sin(c)+r*Math.sin(s)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:y,sweepFlag:x,x:g,y:d}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:s,startAngle:h,endAngle:c,clockwise:a}=this;return e.ellipse(t,n,r,o,s,h,c,!a),this}applyTransform(e){return mt.set(this.cx,this.cy),mt.applyMatrix3(e),this.cx=mt.x,this.cy=mt.y,cn(e)?rn(this,e):on(this,e),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,ry:o,startAngle:s,endAngle:h,clockwise:c}=this;if(!(r>=0&&o>=0))return e;let a=h-s;!c&&a>0?a-=2*Math.PI:c&&a<0&&(a+=2*Math.PI);const l=Math.abs(a),f=Math.max(1,Math.ceil(l/(Math.PI/16)));for(let y=0;y<=f;y++){const x=y/f,u=s+a*x,g=t+Math.cos(u)*r,d=n+Math.sin(u)*o;e.push(g,d)}return e}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=t.length/r,indicesOffset:s=n.length}=e;const h=this.getAdaptivePointArray();if(h.length===0)return{vertices:t,indices:n};let c=0,a=0;for(let y=0;y<h.length;y+=2)c+=h[y],a+=h[y+1];c/=h.length/2,a/=h.length/2;let l=o;t[l*r]=c,t[l*r+1]=a;const f=l++;for(let y=0;y<h.length;y+=2)t[l*r]=h[y],t[l*r+1]=h[y+1],y>0&&(n[s++]=l,n[s++]=f,n[s++]=l-1),l++;return n[s++]=f+1,n[s++]=f,n[s++]=l-1,{vertices:t,indices:n}}getMinMax(e=p.MAX,t=p.MIN){const{cx:n,cy:r,rx:o,ry:s,rotate:h}=this,c=Math.cos(h),a=Math.sin(h),l=Math.sqrt(o*o*c*c+s*s*a*a),f=Math.sqrt(o*o*a*a+s*s*c*c);return e.x=Math.min(e.x,n-l),e.y=Math.min(e.y,r-f),t.x=Math.max(t.x,n+l),t.y=Math.max(t.y,r+f),{min:e.finite(),max:t.finite()}}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function rn(i,e){const t=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new p(t*r,t*o),h=new p(-n*o,n*r),c=s.applyMatrix3(e),a=h.applyMatrix3(e),l=sn.set(c.x,a.x,0,c.y,a.y,0,0,0,1),f=te.copy(l).invert(),u=ee.copy(f).transpose().multiply(f).elements,g=hn(u[0],u[1],u[4]),d=Math.sqrt(g.rt1),T=Math.sqrt(g.rt2);if(i.rx=1/d,i.ry=1/T,i.rotate=Math.atan2(g.sn,g.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=te.set(d,0,0,0,T,0,0,0,1),w=ee.set(g.cs,g.sn,0,-g.sn,g.cs,0,0,0,1),I=P.multiply(w).multiply(l),E=m=>{const{x:M,y:q}=new p(Math.cos(m),Math.sin(m)).applyMatrix3(I);return Math.atan2(q,M)};i.startAngle=E(i.startAngle),i.endAngle=E(i.endAngle),ne(e)&&(i.clockwise=!i.clockwise)}}function on(i,e){const t=se(e),n=ie(e);i.rx*=t,i.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);i.rotate+=r,ne(e)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ne(i){const e=i.elements;return e[0]*e[4]-e[1]*e[3]<0}function cn(i){const e=i.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=se(i),r=ie(i);return Math.abs(t/(n*r))>Number.EPSILON}function se(i){const e=i.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ie(i){const e=i.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function hn(i,e,t){let n,r,o,s,h;const c=i+t,a=i-t,l=Math.sqrt(a*a+4*e*e);return c>0?(n=.5*(c+l),h=1/n,r=i*h*t-e*h*e):c<0?r=.5*(c-l):(n=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(e)?(h=-2*e/o,s=1/Math.sqrt(1+h*h),o=h*s):Math.abs(e)===0?(o=1,s=0):(h=-.5*o/e,o=1/Math.sqrt(1+h*h),s=h*o),a>0&&(h=o,o=-s,s=h),{rt1:n,rt2:r,cs:o,sn:s}}class re extends _t{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,s=!1){super(new p(e,t),new p(n,n),new p,0,r,o,s)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:h}=this;return e.arc(t,n,r,o,s,!h),this}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:h}=this;let c=Math.abs(o-s);(!h&&o>s||h&&s>o)&&(c=2*Math.PI-c);let a=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI)));a=Math.max(a,3);let l=c/a,f=o;l*=h?1:-1;for(let y=0;y<a+1;y++){const x=Math.cos(f),u=Math.sin(f),g=t+x*r,d=n+u*r;e.push(g,d),f+=l}return e}}class rt extends Y{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof rt?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new p){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,h=this.curves[o],c=h.getLength();return h.getPointAt(c===0?0:1-s/c,t)}o++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){return e[t-1]===e[t+1]&&e[t]===e[t+2]&&e.splice(t+1,2),e}getSpacedPointArray(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedPointArray(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptivePointArray(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptivePointArray(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}fillTriangulate(e){const t=(e==null?void 0:e.indices)??[],n=(e==null?void 0:e.vertices)??[];return this.curves.forEach(r=>{r.fillTriangulate({...e,indices:t,vertices:n})}),{indices:t,vertices:n}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=p.MAX,t=p.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new V(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Mt extends Y{constructor(e=new p,t=new p,n=new p,r=new p){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,s,h,c){return new Mt(new p(e,t),new p(n,r),new p(o,s),new p(h,c))}getPoint(e,t=new p){const{p1:n,cp1:r,cp2:o,p2:s}=this;return t.set(Et(e,n.x,r.x,o.x,s.x),Et(e,n.y,r.y,o.y,s.y))}getAdaptivePointArray(e=[]){return Ht(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){const r=t*t-4*e*n;if(r<0)return[];const o=Math.sqrt(r),s=(-t+o)/(2*e),h=(-t-o)/(2*e);return[s,h].filter(c=>c>=0&&c<=1)}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,h=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),c=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),a=[0,1,...h,...c];return((f,y)=>{for(const x of f)for(let u=0;u<=y;u++){const g=u/y-.5,d=Math.min(1,Math.max(0,x+g)),T=this.getPoint(d);e.x=Math.min(e.x,T.x),e.y=Math.min(e.y,T.y),t.x=Math.max(t.x,T.x),t.y=Math.max(t.y,T.y)}})(a,10),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp1:n,cp2:r,p2:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class oe extends _t{constructor(e=0,t=0,n=1,r=1,o=0,s=0,h=Math.PI*2,c=!1){super(new p(e,t),new p(n,r),new p,o,s,h,c)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class j extends Y{constructor(e=new p,t=new p){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new j(new p(e,t),new p(n,r))}getPoint(e,t=new p){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new p){return this.getPoint(e,t)}getTangent(e,t=new p){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new p){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=t.length/r,indicesOffset:s=n.length}=e;const h=Math.min(this.p1.x,this.p2.x),c=Math.max(this.p1.x,this.p2.x),a=Math.min(this.p1.y,this.p2.y),l=Math.max(this.p1.y,this.p2.y),f=h,y=a,x=c-h,u=l-a,g=[f,y,f+x,y,f+x,y+u,f,y+u];let d=0;o*=r,t[o+d]=g[0],t[o+d+1]=g[1],d+=r,t[o+d]=g[2],t[o+d+1]=g[3],d+=r,t[o+d]=g[6],t[o+d+1]=g[7],d+=r,t[o+d]=g[4],t[o+d+1]=g[5],d+=r;const T=o/r;return n[s++]=T,n[s++]=T+1,n[s++]=T+2,n[s++]=T+1,n[s++]=T+3,n[s++]=T+2,{vertices:t,indices:n}}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class qt extends rt{}class an extends qt{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){const{cx:e,cy:t,radius:n,sideCount:r}=this,o=[];for(let h=0;h<r;h++){const c=h*2*Math.PI/r-.5*Math.PI;o.push(new p(n*Math.cos(c),n*Math.sin(c)).add({x:e,y:t}))}const s=[];for(let h=0;h<r;h++)s.push(new j(o[h],o[(h+1)%r]));return this.curves=s,this}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}}class Pt extends Y{constructor(e=new p,t=new p,n=new p){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,s){return new Pt(new p(e,t),new p(n,r),new p(o,s))}getPoint(e,t=new p){const{p1:n,cp:r,p2:o}=this;return t.set(Dt(e,n.x,r.x,o.x),Dt(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(e=[]){return Qt(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),h=.5*(n.y+r.y),c=.5*(n.x+o.x),a=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,s,c),e.y=Math.min(e.y,n.y,o.y,h,a),t.x=Math.max(t.x,n.x,o.x,s,c),t.y=Math.max(t.y,n.y,o.y,h,a),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp:t,p2:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){const{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class ce extends qt{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){const{x:e,y:t,width:n,height:r}=this,o=[new p(e,t),new p(e+n,t),new p(e+n,t+r),new p(e,t+r)];return this.curves=[new j(o[0],o[1]),new j(o[1],o[2]),new j(o[2],o[3]),new j(o[3],o[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=t.length/r,indicesOffset:s=n.length}=e;const{x:h,y:c,width:a,height:l}=this,f=[h,c,h+a,c,h+a,c+l,h,c+l];let y=0;o*=r,t[o+y]=f[0],t[o+y+1]=f[1],y+=r,t[o+y]=f[2],t[o+y+1]=f[3],y+=r,t[o+y]=f[6],t[o+y+1]=f[7],y+=r,t[o+y]=f[4],t[o+y+1]=f[5],y+=r;const x=o/r;return n[s++]=x,n[s++]=x+1,n[s++]=x+2,n[s++]=x+1,n[s++]=x+3,n[s++]=x+2,{vertices:t,indices:n}}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class he extends _t{constructor(e=0,t=0,n=1,r=1,o=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:o}=this,s=n/2,h=r/2,c=e+s,a=t+h,l=Math.max(0,Math.min(o,Math.min(s,h))),f=l;return this._center=new p(c,a),this._radius=new p(l,f),this._diff=new p(s-l,h-f),this}drawTo(e){const{x:t,y:n,width:r,height:o,radius:s}=this;return e.roundRect(t,n,r,o,s),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class ae extends Y{constructor(e=[]){super(),this.points=e}getPoint(e,t=new p){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),s=r-o,h=n[o===0?o:o-1],c=n[o],a=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return t.set(St(s,h.x,c.x,a.x,l.x),St(s,h.y,c.y,a.y,l.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class lt extends rt{constructor(t){super();U(this,"startPoint");U(this,"currentPoint");U(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:o,y:s}=t[n];this.lineTo(o,s)}return this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}_closePointArray(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenPointArray(t=40,n=[]){return this._closePointArray(super.getUnevenPointArray(t,n))}getSpacedPointArray(t=40,n=[]){return this._closePointArray(super.getSpacedPointArray(t,n))}getAdaptivePointArray(t=[]){return this._closePointArray(super.getAdaptivePointArray(t))}_setCurrentPoint(t){return this.currentPoint=new p(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new j(n.clone(),t.clone())),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new p(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(j.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,o,s,h){const c=this.currentPoint;return c!=null&&c.equals({x:s,y:h})||this.curves.push(Mt.from((c==null?void 0:c.x)??0,(c==null?void 0:c.y)??0,t,n,r,o,s,h)),this._setCurrentPoint({x:s,y:h}),this}quadraticCurveTo(t,n,r,o){const s=this.currentPoint;return s!=null&&s.equals({x:r,y:o})||this.curves.push(Pt.from((s==null?void 0:s.x)??0,(s==null?void 0:s.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,s,h){const c=new re(t,n,r,o,s,!h);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeArc(t,n,r,o,s,h){var c,a;return t+=((c=this.currentPoint)==null?void 0:c.x)??0,n+=((a=this.currentPoint)==null?void 0:a.y)??0,this.arc(t,n,r,o,s,h),this}arcTo(t,n,r,o,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,s,h,c,a=!0){const l=new oe(t,n,r,o,s,h,c,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,n,r,o,s,h,c,a){var l,f;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((f=this.currentPoint)==null?void 0:f.y)??0,this.ellipse(t,n,r,o,s,h,c,a),this}rect(t,n,r,o){const s=new ce(t,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,s){const h=new he(t,n,r,o,s);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new p;return this.curves.push(new ae([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function ln(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function un(i,e,t,n){const r=e.clone().sub(i),o=n.clone().sub(t),s=t.clone().sub(i),h=r.cross(o);if(h===0)return new p((i.x+t.x)/2,(i.y+t.y)/2);const c=s.cross(o)/h;return Math.abs(c)>1?new p((i.x+t.x)/2,(i.y+t.y)/2):new p(i.x+c*r.x,i.y+c*r.y)}class G extends rt{constructor(t,n={}){super();U(this,"currentCurve",new lt);U(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof G?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(t){const n=this.curves.findIndex(r=>r===this.currentCurve);return n>-1&&this.curves.splice(n,1),t instanceof G?this.curves.push(...t.curves.filter(r=>r.curves.length).map(r=>r.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new lt().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new lt,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,o,s,h){return this.currentCurve.bezierCurveTo(t,n,r,o,s,h),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,s,h){return this.currentCurve.arc(t,n,r,o,s,h),this}arcTo(t,n,r,o,s){return this.currentCurve.arcTo(t,n,r,o,s),this}ellipse(t,n,r,o,s,h,c,a){return this.currentCurve.ellipse(t,n,r,o,s,h,c,a),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,s){return this.currentCurve.roundRect(t,n,r,o,s),this}reset(){return this.currentCurve=new lt,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.getFlatCurves(),r=[],o=[],s=[];n.forEach((c,a)=>{const l=c.getControlPointRefs(),f=c.isClockwise();s[a]=l,o[a]=f;const y=l[0],x=l[l.length-1]??y;r.push({start:f?x:y,end:f?y:x,index:a})});const h=[];return r.forEach((c,a)=>{h[a]=[],r.forEach((l,f)=>{var y;l.start&&c.end&&f!==a&&((y=l.start)!=null&&y.equals(c.end))&&h[a].push(l.index)})}),n.forEach((c,a)=>{const l=o[a];s[a].forEach(f=>{f.add(c.getNormal(c.getTForPoint(f)).scale(l?t:-t))})}),h.forEach((c,a)=>{const l=s[a];c.forEach(f=>{const y=s[f],x=un(l[l.length-1],l[l.length-2]??l[l.length-1],y[0],y[1]??y[0]);x&&(l[l.length-1].copy(x),y[0].copy(x))})}),this}getMinMax(t=p.MAX,n=p.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,n),r&&o>1){const h=o/2,c=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const f=s.getPoint(l),y=s.getNormal(l),x=y.clone().scale(c?h:-h),u=y.clone().scale(c?-h:h);a.push(f.clone().add(x),f.clone().add(u),f.clone().add({x:h,y:0}),f.clone().add({x:-h,y:0}),f.clone().add({x:0,y:h}),f.clone().add({x:0,y:-h}),f.clone().add({x:h,y:h}),f.clone().add({x:-h,y:-h}))}t.min(...a),n.max(...a)}}),{min:t.finite(),max:n.finite()}}strokeTriangulate(t){const n=(t==null?void 0:t.indices)??[],r=(t==null?void 0:t.vertices)??[];return this.curves.forEach(o=>{o.strokeTriangulate({...t,indices:n,vertices:r})}),{indices:n,vertices:r}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new V(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),Ct(t,n),this.curves.forEach(s=>{s.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),Ct(t,n),this.getControlPointRefs().forEach(s=>{R(t,s.x,s.y,{radius:4})}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSVGPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},n={};for(const o in t)t[o]!==void 0&&(n[ln(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class le{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=p.MAX,n=p.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new V(t.x,t.y,n.x-t.x,n.y-t.y)}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${n} ${r}" width="${n}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:o,width:s,height:h}=this.getBoundingBox(),c=document.createElement("canvas");c.width=s*t,c.height=h*t,c.style.width=`${s}px`,c.style.height=`${h}px`;const a=c.getContext("2d");return a&&(a.scale(t,t),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,n)})),c}}class fn{constructor(e,t,n=1,r=1){U(this,"controlPoints",[]);this.rows=e,this.cols=t,this.width=n,this.height=r;for(let o=0;o<e;o++){this.controlPoints[o]=[];for(let s=0;s<t;s++)this.controlPoints[o][s]={x:s/(t-1)*n,y:o/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}}function ue(i){const e=[];return e[0]=(1-i)**3/6,e[1]=(3*i**3-6*i**2+4)/6,e[2]=(-3*i**3+3*i**2+3*i+1)/6,e[3]=i**3/6,e}function yn(i,e,t=e.width,n=e.height){const r=i.x/t*(e.cols-1),o=i.y/n*(e.rows-1),s=Math.floor(r),h=Math.floor(o),c=r-s,a=o-h,l=ue(c),f=ue(a);let y=0,x=0;for(let u=0;u<4;u++)for(let g=0;g<4;g++){const d=Math.min(Math.max(h-1+u,0),e.rows-1),T=Math.min(Math.max(s-1+g,0),e.cols-1),S=e.controlPoints[d][T],P=l[g]*f[u];y+=S.x*P,x+=S.y*P}i.set(y,x)}const fe="data:image/svg+xml;",ye=`${fe}base64,`,xe=`${fe}charset=utf8,`;function pe(i){if(typeof i=="string"){let e;i.startsWith(ye)?(i=i.substring(ye.length,i.length),e=atob(i)):i.startsWith(xe)?(i=i.substring(xe.length,i.length),e=decodeURIComponent(i)):e=i;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
|
|
2
|
+
${e}`);return t.documentElement}else return i}const xn="px",pn=90,ge=["mm","cm","in","pt","pc","px"],de={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 L(i){let e="px";if(typeof i=="string"||i instanceof String)for(let n=0,r=ge.length;n<r;n++){const o=ge[n];if(i.endsWith(o)){e=o,i=i.substring(0,i.length-o.length);break}}let t;return t=de[e][xn],t<0&&(t=de[e].in*pn),t*Number.parseFloat(i)}const gn=new z,wt=new z,me=new z,Me=new z;function dn(i,e,t){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=mn(i);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function mn(i){const e=new z,t=gn;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&e.translate(L(i.getAttribute("x")),L(i.getAttribute("y"))),i.hasAttribute("transform")){const n=i.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const s=o.indexOf("("),h=o.length;if(s>0&&s<h){const c=o.slice(0,s),a=Z(o.slice(s+1));switch(t.identity(),c){case"translate":if(a.length>=1){const l=a[0];let f=0;a.length>=2&&(f=a[1]),t.translate(l,f)}break;case"rotate":if(a.length>=1){let l=0,f=0,y=0;l=a[0]*Math.PI/180,a.length>=3&&(f=a[1],y=a[2]),wt.makeTranslation(-f,-y),me.makeRotation(l),Me.multiplyMatrices(me,wt),wt.makeTranslation(f,y),t.multiplyMatrices(wt,Me)}break;case"scale":a.length>=1&&t.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&t.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&t.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&t.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}e.premultiply(t)}}return e}function Mn(i){return new G().arc(L(i.getAttribute("cx")||0),L(i.getAttribute("cy")||0),L(i.getAttribute("r")||0),0,Math.PI*2)}function Pn(i,e){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let t=0;t<i.sheet.cssRules.length;t++){const n=i.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,h=0;h<s;h++){const c=n.style.item(h);o[c]=n.style.getPropertyValue(c)}for(let s=0;s<r.length;s++)e[r[s]]=Object.assign(e[r[s]]||{},{...o})}}function wn(i){return new G().ellipse(L(i.getAttribute("cx")||0),L(i.getAttribute("cy")||0),L(i.getAttribute("rx")||0),L(i.getAttribute("ry")||0),0,0,Math.PI*2)}function vn(i){return new G().moveTo(L(i.getAttribute("x1")||0),L(i.getAttribute("y1")||0)).lineTo(L(i.getAttribute("x2")||0),L(i.getAttribute("y2")||0))}function Tn(i){const e=new G,t=i.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const An=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Cn(i){var n;const e=new G;let t=0;return(n=i.getAttribute("points"))==null||n.replace(An,(r,o,s)=>{const h=L(o),c=L(s);return t===0?e.moveTo(h,c):e.lineTo(h,c),t++,r}),e.currentCurve.autoClose=!0,e}const bn=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function kn(i){var n;const e=new G;let t=0;return(n=i.getAttribute("points"))==null||n.replace(bn,(r,o,s)=>{const h=L(o),c=L(s);return t===0?e.moveTo(h,c):e.lineTo(h,c),t++,r}),e.currentCurve.autoClose=!1,e}function In(i){const e=L(i.getAttribute("x")||0),t=L(i.getAttribute("y")||0),n=L(i.getAttribute("rx")||i.getAttribute("ry")||0),r=L(i.getAttribute("ry")||i.getAttribute("rx")||0),o=L(i.getAttribute("width")),s=L(i.getAttribute("height")),h=1-.551915024494,c=new G;return c.moveTo(e+n,t),c.lineTo(e+o-n,t),(n!==0||r!==0)&&c.bezierCurveTo(e+o-n*h,t,e+o,t+r*h,e+o,t+r),c.lineTo(e+o,t+s-r),(n!==0||r!==0)&&c.bezierCurveTo(e+o,t+s-r*h,e+o-n*h,t+s,e+o-n,t+s),c.lineTo(e+n,t+s),(n!==0||r!==0)&&c.bezierCurveTo(e+n*h,t+s,e,t+s-r*h,e,t+s-r),c.lineTo(e,t+r),(n!==0||r!==0)&&c.bezierCurveTo(e,t+r*h,e+n*h,t,e+n,t),c}function X(i,e,t){e=Object.assign({},e);let n={};if(i.hasAttribute("class")){const a=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)n=Object.assign(n,t[`.${a[l]}`])}i.hasAttribute("id")&&(n=Object.assign(n,t[`#${i.getAttribute("id")}`]));for(let a=i.style.length,l=0;l<a;l++){const f=i.style.item(l),y=i.style.getPropertyValue(f);e[f]=y,n[f]=y}function r(a,l,f=o){i.hasAttribute(a)&&(e[l]=f(i.getAttribute(a))),n[a]&&(e[l]=f(n[a]))}function o(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function s(a){return Math.max(0,Math.min(1,L(a)))}function h(a){return Math.max(0,L(a))}function c(a){return a.split(" ").filter(l=>l!=="").map(l=>L(l))}return r("fill","fill"),r("fill-opacity","fillOpacity",s),r("fill-rule","fillRule"),r("opacity","opacity",s),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",s),r("stroke-width","strokeWidth",h),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",h),r("stroke-dasharray","strokeDasharray",c),r("stroke-dashoffset","strokeDashoffset",L),r("visibility","visibility"),e}function Ot(i,e,t=[],n={}){var f;if(i.nodeType!==1)return t;let r=!1,o=null,s={...e};switch(i.nodeName){case"svg":s=X(i,s,n);break;case"style":Pn(i,n);break;case"g":s=X(i,s,n);break;case"path":s=X(i,s,n),i.hasAttribute("d")&&(o=Tn(i));break;case"rect":s=X(i,s,n),o=In(i);break;case"polygon":s=X(i,s,n),o=Cn(i);break;case"polyline":s=X(i,s,n),o=kn(i);break;case"circle":s=X(i,s,n),o=Mn(i);break;case"ellipse":s=X(i,s,n),o=wn(i);break;case"line":s=X(i,s,n),o=vn(i);break;case"defs":r=!0;break;case"use":{s=X(i,s,n);const x=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),u=(f=i.viewportElement)==null?void 0:f.getElementById(x);u?Ot(u,s,t,n):console.warn(`'use node' references non-existent node id: ${x}`);break}default:console.warn(i);break}if(s.display==="none")return t;const h=new z,c=[],a=dn(i,h,c);o&&(o.applyTransform(h),t.push(o),o.style={...s});const l=i.childNodes;for(let y=0,x=l.length;y<x;y++){const u=l[y];r&&u.nodeName!=="style"&&u.nodeName!=="defs"||Ot(u,s,t,n)}return a&&(c.pop(),c.length>0?h.copy(c[c.length-1]):h.identity()),t}function Sn(i){var t;const e=pe(i);return new le(Ot(e,{}),(t=e.getAttribute("viewBox"))==null?void 0:t.trim().split(" ").map(n=>Number(n)))}v.ArcCurve=re,v.BoundingBox=V,v.CompositeCurve=rt,v.CubicBezierCurve=Mt,v.Curve=Y,v.CurvePath=lt,v.EllipseCurve=oe,v.EquilateralPloygonCurve=an,v.FFDControlGrid=fn,v.LineCurve=j,v.Matrix3=z,v.Path2D=G,v.Path2DSet=le,v.PloygonCurve=qt,v.QuadraticBezierCurve=Pt,v.RectangleCurve=ce,v.RoundRectangleCurve=he,v.SplineCurve=ae,v.Vector2=p,v.applyFFD=yn,v.catmullRom=St,v.cubicBezier=Et,v.drawPoint=R,v.fillTriangulate=Wt,v.getAdaptiveCubicBezierCurvePoints=Ht,v.getAdaptiveQuadraticBezierCurvePoints=Qt,v.parseArcCommand=Zt,v.parsePathDataArgs=Z,v.quadraticBezier=Dt,v.setCanvasContext=Ct,v.strokeTriangulate=Jt,v.svgPathCommandsAddToPath2D=kt,v.svgPathCommandsToData=Gt,v.svgPathDataToCommands=It,v.svgToDOM=pe,v.svgToPath2DSet=Sn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1970,76 +1970,24 @@ class RoundCurve extends Curve {
|
|
|
1970
1970
|
return [this._center];
|
|
1971
1971
|
}
|
|
1972
1972
|
getAdaptivePointArray(output = []) {
|
|
1973
|
-
const { cx, cy, rx, ry,
|
|
1974
|
-
if (!(rx >= 0 && ry >= 0
|
|
1973
|
+
const { cx, cy, rx, ry, startAngle, endAngle, clockwise } = this;
|
|
1974
|
+
if (!(rx >= 0 && ry >= 0)) {
|
|
1975
1975
|
return output;
|
|
1976
1976
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
let j1 = 0;
|
|
1992
|
-
let j2 = n * 4 + (dx ? 2 : 0) + 2;
|
|
1993
|
-
let j3 = j2;
|
|
1994
|
-
let j4 = m;
|
|
1995
|
-
let x0 = dx + rx;
|
|
1996
|
-
let y0 = dy;
|
|
1997
|
-
let x1 = x + x0;
|
|
1998
|
-
let x2 = x - x0;
|
|
1999
|
-
let y1 = y + y0;
|
|
2000
|
-
output[j1++] = x1;
|
|
2001
|
-
output[j1++] = y1;
|
|
2002
|
-
output[--j2] = y1;
|
|
2003
|
-
output[--j2] = x2;
|
|
2004
|
-
if (dy) {
|
|
2005
|
-
const y22 = y - y0;
|
|
2006
|
-
output[j3++] = x2;
|
|
2007
|
-
output[j3++] = y22;
|
|
2008
|
-
output[--j4] = y22;
|
|
2009
|
-
output[--j4] = x1;
|
|
2010
|
-
}
|
|
2011
|
-
for (let i = 1; i < n; i++) {
|
|
2012
|
-
const a = Math.PI / 2 * (i / n);
|
|
2013
|
-
const x02 = dx + Math.cos(a) * rx;
|
|
2014
|
-
const y02 = dy + Math.sin(a) * ry;
|
|
2015
|
-
const x12 = x + x02;
|
|
2016
|
-
const x22 = x - x02;
|
|
2017
|
-
const y12 = y + y02;
|
|
2018
|
-
const y22 = y - y02;
|
|
2019
|
-
output[j1++] = x12;
|
|
2020
|
-
output[j1++] = y12;
|
|
2021
|
-
output[--j2] = y12;
|
|
2022
|
-
output[--j2] = x22;
|
|
2023
|
-
output[j3++] = x22;
|
|
2024
|
-
output[j3++] = y22;
|
|
2025
|
-
output[--j4] = y22;
|
|
2026
|
-
output[--j4] = x12;
|
|
2027
|
-
}
|
|
2028
|
-
x0 = dx;
|
|
2029
|
-
y0 = dy + ry;
|
|
2030
|
-
x1 = x + x0;
|
|
2031
|
-
x2 = x - x0;
|
|
2032
|
-
y1 = y + y0;
|
|
2033
|
-
const y2 = y - y0;
|
|
2034
|
-
output[j1++] = x1;
|
|
2035
|
-
output[j1++] = y1;
|
|
2036
|
-
output[--j4] = y2;
|
|
2037
|
-
output[--j4] = x1;
|
|
2038
|
-
if (dx) {
|
|
2039
|
-
output[j1++] = x2;
|
|
2040
|
-
output[j1++] = y1;
|
|
2041
|
-
output[--j4] = y2;
|
|
2042
|
-
output[--j4] = x2;
|
|
1977
|
+
let deltaAngle = endAngle - startAngle;
|
|
1978
|
+
if (!clockwise && deltaAngle > 0) {
|
|
1979
|
+
deltaAngle -= 2 * Math.PI;
|
|
1980
|
+
} else if (clockwise && deltaAngle < 0) {
|
|
1981
|
+
deltaAngle += 2 * Math.PI;
|
|
1982
|
+
}
|
|
1983
|
+
const arcLength = Math.abs(deltaAngle);
|
|
1984
|
+
const n = Math.max(1, Math.ceil(arcLength / (Math.PI / 16)));
|
|
1985
|
+
for (let i = 0; i <= n; i++) {
|
|
1986
|
+
const t = i / n;
|
|
1987
|
+
const angle = startAngle + deltaAngle * t;
|
|
1988
|
+
const x = cx + Math.cos(angle) * rx;
|
|
1989
|
+
const y = cy + Math.sin(angle) * ry;
|
|
1990
|
+
output.push(x, y);
|
|
2043
1991
|
}
|
|
2044
1992
|
return output;
|
|
2045
1993
|
}
|
|
@@ -2305,121 +2253,6 @@ class ArcCurve extends RoundCurve {
|
|
|
2305
2253
|
}
|
|
2306
2254
|
}
|
|
2307
2255
|
|
|
2308
|
-
class LineCurve extends Curve {
|
|
2309
|
-
constructor(p1 = new Vector2(), p2 = new Vector2()) {
|
|
2310
|
-
super();
|
|
2311
|
-
this.p1 = p1;
|
|
2312
|
-
this.p2 = p2;
|
|
2313
|
-
}
|
|
2314
|
-
static from(p1x, p1y, p2x, p2y) {
|
|
2315
|
-
return new LineCurve(
|
|
2316
|
-
new Vector2(p1x, p1y),
|
|
2317
|
-
new Vector2(p2x, p2y)
|
|
2318
|
-
);
|
|
2319
|
-
}
|
|
2320
|
-
getPoint(t, output = new Vector2()) {
|
|
2321
|
-
if (t === 1) {
|
|
2322
|
-
output.copy(this.p2);
|
|
2323
|
-
} else {
|
|
2324
|
-
output.copy(this.p2).sub(this.p1).scale(t).add(this.p1);
|
|
2325
|
-
}
|
|
2326
|
-
return output;
|
|
2327
|
-
}
|
|
2328
|
-
getPointAt(u, output = new Vector2()) {
|
|
2329
|
-
return this.getPoint(u, output);
|
|
2330
|
-
}
|
|
2331
|
-
getTangent(_t, output = new Vector2()) {
|
|
2332
|
-
return output.subVectors(this.p2, this.p1).normalize();
|
|
2333
|
-
}
|
|
2334
|
-
getTangentAt(u, output = new Vector2()) {
|
|
2335
|
-
return this.getTangent(u, output);
|
|
2336
|
-
}
|
|
2337
|
-
getControlPointRefs() {
|
|
2338
|
-
return [this.p1, this.p2];
|
|
2339
|
-
}
|
|
2340
|
-
getAdaptivePointArray(output = []) {
|
|
2341
|
-
output.push(
|
|
2342
|
-
this.p1.x,
|
|
2343
|
-
this.p1.y,
|
|
2344
|
-
this.p2.x,
|
|
2345
|
-
this.p2.y
|
|
2346
|
-
);
|
|
2347
|
-
return output;
|
|
2348
|
-
}
|
|
2349
|
-
getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
|
|
2350
|
-
const { p1, p2 } = this;
|
|
2351
|
-
min.x = Math.min(min.x, p1.x, p2.x);
|
|
2352
|
-
min.y = Math.min(min.y, p1.y, p2.y);
|
|
2353
|
-
max.x = Math.max(max.x, p1.x, p2.x);
|
|
2354
|
-
max.y = Math.max(max.y, p1.y, p2.y);
|
|
2355
|
-
return { min: min.finite(), max: max.finite() };
|
|
2356
|
-
}
|
|
2357
|
-
toCommands() {
|
|
2358
|
-
const { p1, p2 } = this;
|
|
2359
|
-
return [
|
|
2360
|
-
{ type: "M", x: p1.x, y: p1.y },
|
|
2361
|
-
{ type: "L", x: p2.x, y: p2.y }
|
|
2362
|
-
];
|
|
2363
|
-
}
|
|
2364
|
-
fillTriangulate(options = {}) {
|
|
2365
|
-
let {
|
|
2366
|
-
vertices = [],
|
|
2367
|
-
indices = [],
|
|
2368
|
-
verticesStride = 2,
|
|
2369
|
-
verticesOffset = vertices.length / verticesStride,
|
|
2370
|
-
indicesOffset = indices.length
|
|
2371
|
-
} = options;
|
|
2372
|
-
const x = this.p1.x;
|
|
2373
|
-
const y = this.p1.y;
|
|
2374
|
-
const width = this.p2.x - this.p1.x || 1;
|
|
2375
|
-
const height = this.p2.y - this.p2.y || 1;
|
|
2376
|
-
const points = [
|
|
2377
|
-
x,
|
|
2378
|
-
y,
|
|
2379
|
-
x + width,
|
|
2380
|
-
y,
|
|
2381
|
-
x + width,
|
|
2382
|
-
y + height,
|
|
2383
|
-
x,
|
|
2384
|
-
y + height
|
|
2385
|
-
];
|
|
2386
|
-
let count = 0;
|
|
2387
|
-
verticesOffset *= verticesStride;
|
|
2388
|
-
vertices[verticesOffset + count] = points[0];
|
|
2389
|
-
vertices[verticesOffset + count + 1] = points[1];
|
|
2390
|
-
count += verticesStride;
|
|
2391
|
-
vertices[verticesOffset + count] = points[2];
|
|
2392
|
-
vertices[verticesOffset + count + 1] = points[3];
|
|
2393
|
-
count += verticesStride;
|
|
2394
|
-
vertices[verticesOffset + count] = points[6];
|
|
2395
|
-
vertices[verticesOffset + count + 1] = points[7];
|
|
2396
|
-
count += verticesStride;
|
|
2397
|
-
vertices[verticesOffset + count] = points[4];
|
|
2398
|
-
vertices[verticesOffset + count + 1] = points[5];
|
|
2399
|
-
count += verticesStride;
|
|
2400
|
-
const verticesIndex = verticesOffset / verticesStride;
|
|
2401
|
-
indices[indicesOffset++] = verticesIndex;
|
|
2402
|
-
indices[indicesOffset++] = verticesIndex + 1;
|
|
2403
|
-
indices[indicesOffset++] = verticesIndex + 2;
|
|
2404
|
-
indices[indicesOffset++] = verticesIndex + 1;
|
|
2405
|
-
indices[indicesOffset++] = verticesIndex + 3;
|
|
2406
|
-
indices[indicesOffset++] = verticesIndex + 2;
|
|
2407
|
-
return { vertices, indices };
|
|
2408
|
-
}
|
|
2409
|
-
drawTo(ctx) {
|
|
2410
|
-
const { p1, p2 } = this;
|
|
2411
|
-
ctx.lineTo(p1.x, p1.y);
|
|
2412
|
-
ctx.lineTo(p2.x, p2.y);
|
|
2413
|
-
return this;
|
|
2414
|
-
}
|
|
2415
|
-
copy(source) {
|
|
2416
|
-
super.copy(source);
|
|
2417
|
-
this.p1.copy(source.p1);
|
|
2418
|
-
this.p2.copy(source.p2);
|
|
2419
|
-
return this;
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
2256
|
class CompositeCurve extends Curve {
|
|
2424
2257
|
constructor(curves = []) {
|
|
2425
2258
|
super();
|
|
@@ -2497,39 +2330,13 @@ class CompositeCurve extends Curve {
|
|
|
2497
2330
|
fillTriangulate(options) {
|
|
2498
2331
|
const indices = options?.indices ?? [];
|
|
2499
2332
|
const vertices = options?.vertices ?? [];
|
|
2500
|
-
const lines = [];
|
|
2501
|
-
const fillLines = () => {
|
|
2502
|
-
if (lines.length) {
|
|
2503
|
-
const pointArray = [];
|
|
2504
|
-
lines.forEach((line) => {
|
|
2505
|
-
const x = line.p1.x;
|
|
2506
|
-
const y = line.p1.y;
|
|
2507
|
-
if (pointArray[pointArray.length - 2] !== x || pointArray[pointArray.length - 1] !== y) {
|
|
2508
|
-
pointArray.push(x, y);
|
|
2509
|
-
}
|
|
2510
|
-
pointArray.push(line.p2.x, line.p2.y);
|
|
2511
|
-
});
|
|
2512
|
-
fillTriangulate(pointArray, {
|
|
2513
|
-
...options,
|
|
2514
|
-
indices,
|
|
2515
|
-
vertices
|
|
2516
|
-
});
|
|
2517
|
-
lines.length = 0;
|
|
2518
|
-
}
|
|
2519
|
-
};
|
|
2520
2333
|
this.curves.forEach((curve) => {
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
...options,
|
|
2527
|
-
indices,
|
|
2528
|
-
vertices
|
|
2529
|
-
});
|
|
2530
|
-
}
|
|
2334
|
+
curve.fillTriangulate({
|
|
2335
|
+
...options,
|
|
2336
|
+
indices,
|
|
2337
|
+
vertices
|
|
2338
|
+
});
|
|
2531
2339
|
});
|
|
2532
|
-
fillLines();
|
|
2533
2340
|
return { indices, vertices };
|
|
2534
2341
|
}
|
|
2535
2342
|
applyTransform(transform) {
|
|
@@ -2690,6 +2497,125 @@ class EllipseCurve extends RoundCurve {
|
|
|
2690
2497
|
}
|
|
2691
2498
|
}
|
|
2692
2499
|
|
|
2500
|
+
class LineCurve extends Curve {
|
|
2501
|
+
constructor(p1 = new Vector2(), p2 = new Vector2()) {
|
|
2502
|
+
super();
|
|
2503
|
+
this.p1 = p1;
|
|
2504
|
+
this.p2 = p2;
|
|
2505
|
+
}
|
|
2506
|
+
static from(p1x, p1y, p2x, p2y) {
|
|
2507
|
+
return new LineCurve(
|
|
2508
|
+
new Vector2(p1x, p1y),
|
|
2509
|
+
new Vector2(p2x, p2y)
|
|
2510
|
+
);
|
|
2511
|
+
}
|
|
2512
|
+
getPoint(t, output = new Vector2()) {
|
|
2513
|
+
if (t === 1) {
|
|
2514
|
+
output.copy(this.p2);
|
|
2515
|
+
} else {
|
|
2516
|
+
output.copy(this.p2).sub(this.p1).scale(t).add(this.p1);
|
|
2517
|
+
}
|
|
2518
|
+
return output;
|
|
2519
|
+
}
|
|
2520
|
+
getPointAt(u, output = new Vector2()) {
|
|
2521
|
+
return this.getPoint(u, output);
|
|
2522
|
+
}
|
|
2523
|
+
getTangent(_t, output = new Vector2()) {
|
|
2524
|
+
return output.subVectors(this.p2, this.p1).normalize();
|
|
2525
|
+
}
|
|
2526
|
+
getTangentAt(u, output = new Vector2()) {
|
|
2527
|
+
return this.getTangent(u, output);
|
|
2528
|
+
}
|
|
2529
|
+
getControlPointRefs() {
|
|
2530
|
+
return [this.p1, this.p2];
|
|
2531
|
+
}
|
|
2532
|
+
getAdaptivePointArray(output = []) {
|
|
2533
|
+
output.push(
|
|
2534
|
+
this.p1.x,
|
|
2535
|
+
this.p1.y,
|
|
2536
|
+
this.p2.x,
|
|
2537
|
+
this.p2.y
|
|
2538
|
+
);
|
|
2539
|
+
return output;
|
|
2540
|
+
}
|
|
2541
|
+
getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
|
|
2542
|
+
const { p1, p2 } = this;
|
|
2543
|
+
min.x = Math.min(min.x, p1.x, p2.x);
|
|
2544
|
+
min.y = Math.min(min.y, p1.y, p2.y);
|
|
2545
|
+
max.x = Math.max(max.x, p1.x, p2.x);
|
|
2546
|
+
max.y = Math.max(max.y, p1.y, p2.y);
|
|
2547
|
+
return { min: min.finite(), max: max.finite() };
|
|
2548
|
+
}
|
|
2549
|
+
toCommands() {
|
|
2550
|
+
const { p1, p2 } = this;
|
|
2551
|
+
return [
|
|
2552
|
+
{ type: "M", x: p1.x, y: p1.y },
|
|
2553
|
+
{ type: "L", x: p2.x, y: p2.y }
|
|
2554
|
+
];
|
|
2555
|
+
}
|
|
2556
|
+
fillTriangulate(options = {}) {
|
|
2557
|
+
let {
|
|
2558
|
+
vertices = [],
|
|
2559
|
+
indices = [],
|
|
2560
|
+
verticesStride = 2,
|
|
2561
|
+
verticesOffset = vertices.length / verticesStride,
|
|
2562
|
+
indicesOffset = indices.length
|
|
2563
|
+
} = options;
|
|
2564
|
+
const minX = Math.min(this.p1.x, this.p2.x);
|
|
2565
|
+
const maxX = Math.max(this.p1.x, this.p2.x);
|
|
2566
|
+
const minY = Math.min(this.p1.y, this.p2.y);
|
|
2567
|
+
const maxY = Math.max(this.p1.y, this.p2.y);
|
|
2568
|
+
const x = minX;
|
|
2569
|
+
const y = minY;
|
|
2570
|
+
const width = maxX - minX;
|
|
2571
|
+
const height = maxY - minY;
|
|
2572
|
+
const points = [
|
|
2573
|
+
x,
|
|
2574
|
+
y,
|
|
2575
|
+
x + width,
|
|
2576
|
+
y,
|
|
2577
|
+
x + width,
|
|
2578
|
+
y + height,
|
|
2579
|
+
x,
|
|
2580
|
+
y + height
|
|
2581
|
+
];
|
|
2582
|
+
let count = 0;
|
|
2583
|
+
verticesOffset *= verticesStride;
|
|
2584
|
+
vertices[verticesOffset + count] = points[0];
|
|
2585
|
+
vertices[verticesOffset + count + 1] = points[1];
|
|
2586
|
+
count += verticesStride;
|
|
2587
|
+
vertices[verticesOffset + count] = points[2];
|
|
2588
|
+
vertices[verticesOffset + count + 1] = points[3];
|
|
2589
|
+
count += verticesStride;
|
|
2590
|
+
vertices[verticesOffset + count] = points[6];
|
|
2591
|
+
vertices[verticesOffset + count + 1] = points[7];
|
|
2592
|
+
count += verticesStride;
|
|
2593
|
+
vertices[verticesOffset + count] = points[4];
|
|
2594
|
+
vertices[verticesOffset + count + 1] = points[5];
|
|
2595
|
+
count += verticesStride;
|
|
2596
|
+
const verticesIndex = verticesOffset / verticesStride;
|
|
2597
|
+
indices[indicesOffset++] = verticesIndex;
|
|
2598
|
+
indices[indicesOffset++] = verticesIndex + 1;
|
|
2599
|
+
indices[indicesOffset++] = verticesIndex + 2;
|
|
2600
|
+
indices[indicesOffset++] = verticesIndex + 1;
|
|
2601
|
+
indices[indicesOffset++] = verticesIndex + 3;
|
|
2602
|
+
indices[indicesOffset++] = verticesIndex + 2;
|
|
2603
|
+
return { vertices, indices };
|
|
2604
|
+
}
|
|
2605
|
+
drawTo(ctx) {
|
|
2606
|
+
const { p1, p2 } = this;
|
|
2607
|
+
ctx.lineTo(p1.x, p1.y);
|
|
2608
|
+
ctx.lineTo(p2.x, p2.y);
|
|
2609
|
+
return this;
|
|
2610
|
+
}
|
|
2611
|
+
copy(source) {
|
|
2612
|
+
super.copy(source);
|
|
2613
|
+
this.p1.copy(source.p1);
|
|
2614
|
+
this.p2.copy(source.p2);
|
|
2615
|
+
return this;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2693
2619
|
class PloygonCurve extends CompositeCurve {
|
|
2694
2620
|
//
|
|
2695
2621
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-path2d",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
|
-
"description": "A
|
|
6
|
+
"description": "A Path2D library, fully compatible with Web Path2D, with additional support for triangulate、animation、deformation etc.",
|
|
7
7
|
"author": "wxm",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"homepage": "https://github.com/qq15725/modern-path2d",
|