svg-path-commander 0.1.23 → 0.1.24
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/README.md +1 -1
- package/dist/svg-path-commander.esm.js +32 -26
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +32 -26
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +1 -1
- package/src/util/getPropertiesAtLength.js +2 -1
- package/src/util/getPropertiesAtPoint.js +3 -2
- package/src/util/pathLengthFactory.js +9 -8
- package/src/util/segmentArcFactory.js +5 -4
- package/src/util/segmentCubicFactory.js +5 -4
- package/src/util/segmentLineFactory.js +1 -1
- package/src/util/segmentQuadFactory.js +5 -4
- package/types/svg-path-commander.d.ts +4 -2
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ For developer guidelines, and a complete list of static methods, head over to th
|
|
|
167
167
|
* all 3d transformations as well as skews will convert `A` (arc) path commands to `C` (cubic bezier) due to the lack of resources;
|
|
168
168
|
* most tools included with **SVGPathCommander** should work in your Node.js apps, but feel free to report any issue;
|
|
169
169
|
* other path commands like `R` (catmulRomBezier), `O`, `U` (ellipse and shorthand ellipse) are not present in the current draft and are not supported;
|
|
170
|
-
* normalization can mean many things to many people and our library is developed to convert path command values to absolute and shorthand to
|
|
170
|
+
* normalization can mean many things to many people and our library is developed to convert path command values to absolute and shorthand to longhand commands to provide a solid foundation for the main processing tools of our library;
|
|
171
171
|
* when compared to the native methods like `SVGPathElement.getTotalLength()` or `SVGPathElement.getPointAtLength()`, the output of our static methods is within a [0.002 - 0.05] margin delta, but from our experience it's proven to be a more consistent outcome.
|
|
172
172
|
|
|
173
173
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v0.1.
|
|
2
|
+
* SVGPathCommander v0.1.24 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2021 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -1035,7 +1035,7 @@ function segmentLineFactory(x1, y1, x2, y2, distance) {
|
|
|
1035
1035
|
if (distance < margin) {
|
|
1036
1036
|
return { x: x1, y: y1 };
|
|
1037
1037
|
}
|
|
1038
|
-
if (distance > length
|
|
1038
|
+
if (distance > length) {
|
|
1039
1039
|
return { x: x2, y: y2 };
|
|
1040
1040
|
}
|
|
1041
1041
|
const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);
|
|
@@ -2614,15 +2614,16 @@ function getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t) {
|
|
|
2614
2614
|
* @returns {{x: number, y: number} | number} the segment length or point
|
|
2615
2615
|
*/
|
|
2616
2616
|
function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
|
|
2617
|
-
|
|
2617
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
2618
2618
|
const lengthMargin = 0.001;
|
|
2619
|
+
let x = x1; let y = y1;
|
|
2619
2620
|
let totalLength = 0;
|
|
2620
2621
|
let prev = [x1, y1, totalLength];
|
|
2621
2622
|
/** @type {[number, number]} */
|
|
2622
2623
|
let cur = [x1, y1];
|
|
2623
2624
|
let t = 0;
|
|
2624
2625
|
|
|
2625
|
-
if (
|
|
2626
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
2626
2627
|
return { x, y };
|
|
2627
2628
|
}
|
|
2628
2629
|
|
|
@@ -2634,7 +2635,7 @@ function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
|
|
|
2634
2635
|
totalLength += distanceSquareRoot(cur, [x, y]);
|
|
2635
2636
|
cur = [x, y];
|
|
2636
2637
|
|
|
2637
|
-
if (
|
|
2638
|
+
if (distanceIsNumber && totalLength >= distance) {
|
|
2638
2639
|
const dv = (totalLength - distance) / (totalLength - prev[2]);
|
|
2639
2640
|
|
|
2640
2641
|
return {
|
|
@@ -2645,7 +2646,7 @@ function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
|
|
|
2645
2646
|
prev = [x, y, totalLength];
|
|
2646
2647
|
}
|
|
2647
2648
|
|
|
2648
|
-
if (
|
|
2649
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
2649
2650
|
return { x: x2, y: y2 };
|
|
2650
2651
|
}
|
|
2651
2652
|
return totalLength;
|
|
@@ -3083,15 +3084,16 @@ function getPathLength(path) {
|
|
|
3083
3084
|
* @returns {{x: number, y: number} | number} the segment length or point
|
|
3084
3085
|
*/
|
|
3085
3086
|
function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
|
|
3086
|
-
let [x, y] = [X1, Y1];
|
|
3087
3087
|
const cubicSeg = arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2);
|
|
3088
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
3089
|
+
let [x, y] = [X1, Y1];
|
|
3088
3090
|
const lengthMargin = 0.001;
|
|
3089
3091
|
let totalLength = 0;
|
|
3090
3092
|
let cubicSubseg = [];
|
|
3091
3093
|
let argsc = [];
|
|
3092
3094
|
let segLen = 0;
|
|
3093
3095
|
|
|
3094
|
-
if (
|
|
3096
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
3095
3097
|
return { x, y };
|
|
3096
3098
|
}
|
|
3097
3099
|
|
|
@@ -3100,7 +3102,7 @@ function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
|
|
|
3100
3102
|
argsc = [x, y, ...cubicSubseg];
|
|
3101
3103
|
// @ts-ignore
|
|
3102
3104
|
segLen = segmentCubicFactory(...argsc);
|
|
3103
|
-
if (
|
|
3105
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3104
3106
|
// @ts-ignore -- this is a `cubicSegment`
|
|
3105
3107
|
return segmentCubicFactory(...argsc, distance - totalLength);
|
|
3106
3108
|
}
|
|
@@ -3108,7 +3110,7 @@ function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
|
|
|
3108
3110
|
[x, y] = cubicSubseg.slice(-2);
|
|
3109
3111
|
}
|
|
3110
3112
|
|
|
3111
|
-
if (
|
|
3113
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
3112
3114
|
return { x: X2, y: Y2 };
|
|
3113
3115
|
}
|
|
3114
3116
|
|
|
@@ -3156,15 +3158,16 @@ function getPointAtQuadSegmentLength(x1, y1, cx, cy, x2, y2, t) {
|
|
|
3156
3158
|
* @returns {{x: number, y: number} | number} the segment length or point
|
|
3157
3159
|
*/
|
|
3158
3160
|
function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
3159
|
-
|
|
3161
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
3160
3162
|
const lengthMargin = 0.001;
|
|
3163
|
+
let x = x1; let y = y1;
|
|
3161
3164
|
let totalLength = 0;
|
|
3162
3165
|
let prev = [x1, y1, totalLength];
|
|
3163
3166
|
/** @type {[number, number]} */
|
|
3164
3167
|
let cur = [x1, y1];
|
|
3165
3168
|
let t = 0;
|
|
3166
3169
|
|
|
3167
|
-
if (
|
|
3170
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
3168
3171
|
return { x, y };
|
|
3169
3172
|
}
|
|
3170
3173
|
|
|
@@ -3176,7 +3179,7 @@ function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
|
3176
3179
|
totalLength += distanceSquareRoot(cur, [x, y]);
|
|
3177
3180
|
cur = [x, y];
|
|
3178
3181
|
|
|
3179
|
-
if (
|
|
3182
|
+
if (distanceIsNumber && totalLength >= distance) {
|
|
3180
3183
|
const dv = (totalLength - distance) / (totalLength - prev[2]);
|
|
3181
3184
|
|
|
3182
3185
|
return {
|
|
@@ -3186,7 +3189,7 @@ function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
|
3186
3189
|
}
|
|
3187
3190
|
prev = [x, y, totalLength];
|
|
3188
3191
|
}
|
|
3189
|
-
if (
|
|
3192
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
3190
3193
|
return { x: x2, y: y2 };
|
|
3191
3194
|
}
|
|
3192
3195
|
return totalLength;
|
|
@@ -3200,6 +3203,8 @@ function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
|
3200
3203
|
* @returns {{x: number, y: number} | number} the total length or point
|
|
3201
3204
|
*/
|
|
3202
3205
|
function pathLengthFactory(pathInput, distance) {
|
|
3206
|
+
const path = fixPath(normalizePath(pathInput));
|
|
3207
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
3203
3208
|
let totalLength = 0;
|
|
3204
3209
|
let isM = true;
|
|
3205
3210
|
/** @type {number[]} */
|
|
@@ -3211,7 +3216,6 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3211
3216
|
let mx = 0;
|
|
3212
3217
|
let my = 0;
|
|
3213
3218
|
let seg;
|
|
3214
|
-
const path = fixPath(normalizePath(pathInput));
|
|
3215
3219
|
|
|
3216
3220
|
for (let i = 0, ll = path.length; i < ll; i += 1) {
|
|
3217
3221
|
seg = path[i];
|
|
@@ -3225,13 +3229,13 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3225
3229
|
// remember mx, my for Z
|
|
3226
3230
|
// @ts-ignore
|
|
3227
3231
|
[, mx, my] = seg;
|
|
3228
|
-
if (
|
|
3232
|
+
if (distanceIsNumber && distance < 0.001) {
|
|
3229
3233
|
return { x: mx, y: my };
|
|
3230
3234
|
}
|
|
3231
3235
|
} else if (pathCommand === 'L') {
|
|
3232
3236
|
// @ts-ignore
|
|
3233
3237
|
segLen = segmentLineFactory(...data);
|
|
3234
|
-
if (
|
|
3238
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3235
3239
|
// @ts-ignore
|
|
3236
3240
|
return segmentLineFactory(...data, distance - totalLength);
|
|
3237
3241
|
}
|
|
@@ -3239,7 +3243,7 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3239
3243
|
} else if (pathCommand === 'A') {
|
|
3240
3244
|
// @ts-ignore
|
|
3241
3245
|
segLen = segmentArcFactory(...data);
|
|
3242
|
-
if (
|
|
3246
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3243
3247
|
// @ts-ignore
|
|
3244
3248
|
return segmentArcFactory(...data, distance - totalLength);
|
|
3245
3249
|
}
|
|
@@ -3247,7 +3251,7 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3247
3251
|
} else if (pathCommand === 'C') {
|
|
3248
3252
|
// @ts-ignore
|
|
3249
3253
|
segLen = segmentCubicFactory(...data);
|
|
3250
|
-
if (
|
|
3254
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3251
3255
|
// @ts-ignore
|
|
3252
3256
|
return segmentCubicFactory(...data, distance - totalLength);
|
|
3253
3257
|
}
|
|
@@ -3255,7 +3259,7 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3255
3259
|
} else if (pathCommand === 'Q') {
|
|
3256
3260
|
// @ts-ignore
|
|
3257
3261
|
segLen = segmentQuadFactory(...data);
|
|
3258
|
-
if (
|
|
3262
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3259
3263
|
// @ts-ignore
|
|
3260
3264
|
return segmentQuadFactory(...data, distance - totalLength);
|
|
3261
3265
|
}
|
|
@@ -3264,7 +3268,7 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3264
3268
|
data = [x, y, mx, my];
|
|
3265
3269
|
// @ts-ignore
|
|
3266
3270
|
segLen = segmentLineFactory(...data);
|
|
3267
|
-
if (
|
|
3271
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3268
3272
|
// @ts-ignore
|
|
3269
3273
|
return segmentLineFactory(...data, distance - totalLength);
|
|
3270
3274
|
}
|
|
@@ -3277,7 +3281,7 @@ function pathLengthFactory(pathInput, distance) {
|
|
|
3277
3281
|
|
|
3278
3282
|
// native `getPointAtLength` behavior when the given distance
|
|
3279
3283
|
// is higher than total length
|
|
3280
|
-
if (
|
|
3284
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
3281
3285
|
return { x, y };
|
|
3282
3286
|
}
|
|
3283
3287
|
|
|
@@ -3336,7 +3340,8 @@ function getPointAtPathLength(pathInput, distance) {
|
|
|
3336
3340
|
}
|
|
3337
3341
|
|
|
3338
3342
|
/**
|
|
3339
|
-
* Returns the
|
|
3343
|
+
* Returns the segment, its index and length as well as
|
|
3344
|
+
* the length to that segment at a given length in a path.
|
|
3340
3345
|
*
|
|
3341
3346
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
3342
3347
|
* @param {number=} distance the given length
|
|
@@ -3396,7 +3401,8 @@ function getPropertiesAtLength(pathInput, distance) {
|
|
|
3396
3401
|
}
|
|
3397
3402
|
|
|
3398
3403
|
/**
|
|
3399
|
-
* Returns the point in path closest to a given point
|
|
3404
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
3405
|
+
* the distance to the path stroke.
|
|
3400
3406
|
* @see https://bl.ocks.org/mbostock/8027637
|
|
3401
3407
|
*
|
|
3402
3408
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
@@ -3460,7 +3466,7 @@ function getPropertiesAtPoint(pathInput, point) {
|
|
|
3460
3466
|
}
|
|
3461
3467
|
}
|
|
3462
3468
|
|
|
3463
|
-
const segment = getPropertiesAtLength(path,
|
|
3469
|
+
const segment = getPropertiesAtLength(path, bestLength);
|
|
3464
3470
|
const distance = Math.sqrt(bestDistance);
|
|
3465
3471
|
|
|
3466
3472
|
return { closest, distance, segment };
|
|
@@ -3790,7 +3796,7 @@ const Util = {
|
|
|
3790
3796
|
options: defaultOptions,
|
|
3791
3797
|
};
|
|
3792
3798
|
|
|
3793
|
-
var version = "0.1.
|
|
3799
|
+
var version = "0.1.24";
|
|
3794
3800
|
|
|
3795
3801
|
// @ts-ignore
|
|
3796
3802
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// SVGPathCommander v0.1.
|
|
2
|
-
const t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function n(t){let n=t.pathValue[t.segmentStart],r=n.toLowerCase(),{data:s}=t;for("m"===r&&s.length>2&&(t.segments.push([n,s[0],s[1]]),s=s.slice(2),r="l",n="m"===n?"l":"L");s.length>=e[r]&&(t.segments.push([n,...s.splice(0,e[r])]),e[r]););}function r(t){const{index:e}=t,n=t.pathValue.charCodeAt(e);return 48===n?(t.param=0,void(t.index+=1)):49===n?(t.param=1,void(t.index+=1)):void(t.err=`Invalid path value: invalid Arc flag "${n}", expecting 0 or 1 at index ${e}`)}function s(t){return t>=48&&t<=57}function i(t){const{max:e,pathValue:n,index:r}=t;let i,a=r,o=!1,m=!1,c=!1,u=!1;if(a>=e)t.err=`Invalid path value at ${a}: missing param ${n[a]}`;else if(i=n.charCodeAt(a),43!==i&&45!==i||(a+=1,i=a<e?n.charCodeAt(a):0),s(i)||46===i){if(46!==i){if(o=48===i,a+=1,i=a<e?n.charCodeAt(a):0,o&&a<e&&i&&s(i))return void(t.err=`Invalid path value at index ${r}: ${n[r]} illegal number`);for(;a<e&&s(n.charCodeAt(a));)a+=1,m=!0;i=a<e?n.charCodeAt(a):0}if(46===i){for(u=!0,a+=1;s(n.charCodeAt(a));)a+=1,c=!0;i=a<e?n.charCodeAt(a):0}if(101===i||69===i){if(u&&!m&&!c)return void(t.err=`Invalid path value at index ${a}: ${n[a]} invalid float exponent`);if(a+=1,i=a<e?n.charCodeAt(a):0,43!==i&&45!==i||(a+=1),!(a<e&&s(n.charCodeAt(a))))return void(t.err=`Invalid path value at index ${a}: ${n[a]} invalid float exponent`);for(;a<e&&s(n.charCodeAt(a));)a+=1}t.index=a,t.param=+t.pathValue.slice(r,a)}else t.err=`Invalid path value at index ${a}: ${n[a]} is not a number`}function a(t){const{pathValue:e,max:n}=t;for(;t.index<n&&(10===(r=e.charCodeAt(t.index))||13===r||8232===r||8233===r||32===r||9===r||11===r||12===r||160===r||r>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(r)>=0);)t.index+=1;var r}function o(t){return t>=48&&t<=57||43===t||45===t||46===t}function m(t){const{max:s,pathValue:m,index:c}=t,u=m.charCodeAt(c),l=e[m[c].toLowerCase()];if(t.segmentStart=c,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(u))if(t.index+=1,a(t),t.data=[],l){for(;;){for(let e=l;e>0;e-=1){if(97!=(32|u)||3!==e&&4!==e?i(t):r(t),t.err.length)return;t.data.push(t.param),a(t),t.index<s&&44===m.charCodeAt(t.index)&&(t.index+=1,a(t))}if(t.index>=t.max)break;if(!o(m.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`Invalid path value: ${m[c]} not a path command`}function c(t){return t.map(t=>Array.isArray(t)?[...t]:t)}function u(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function l(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"achlmqstvz".includes(n)})}function h(t){if(l(t))return c(t);const e=new u(t);for(a(e);e.index<e.max&&!e.err.length;)m(e);return e.err.length?e.segments=[]:e.segments.length&&("mM".includes(e.segments[0][0])?e.segments[0][0]="M":(e.err="Invalid path value: missing M/m",e.segments=[])),e.segments}function f(t){return l(t)&&t.every(t=>t[0]===t[0].toUpperCase())}function y(t){if(f(t))return c(t);const e=h(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toUpperCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"A":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]+n,e[6]+r];break;case"V":m=[o,e[0]+r];break;case"H":m=[o,e[0]+n];break;default:m=[o,...e.map((t,e)=>t+(e%2?r:n))]}else m=[o,...e];const c=m.length;switch(o){case"Z":n=s,r=i;break;case"H":[,n]=m;break;case"V":[,r]=m;break;default:n=m[c-2],r=m[c-1],"M"===o&&(s=n,i=r)}return m})}function x(t){return l(t)&&t.slice(1).every(t=>t[0]===t[0].toLowerCase())}function g(t){if(x(t))return c(t);const e=h(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toLowerCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"a":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]-n,e[6]-r];break;case"v":m=[o,e[0]-r];break;case"h":m=[o,e[0]-n];break;default:m=[o,...e.map((t,e)=>t-(e%2?r:n))],"m"===o&&([n,r]=e,s=n,i=r)}else"m"===a&&(s=e[0]+n,i=e[1]+r),m=[o,...e];const c=m.length;switch(o){case"z":n=s,r=i;break;case"h":n+=m[1];break;case"v":r+=m[1];break;default:n+=m[c-2],r+=m[c-1]}return m})}function p(t,e,n){if(t[n].length>7){t[n].shift();const r=t[n];let s=n;for(;r.length;)e[n]="A",t.splice(s+=1,0,["C",...r.splice(0,6)]);t.splice(n,1)}}function d(t,e,n){const[r]=t,{x1:s,y1:i,x2:a,y2:o}=e,m=t.slice(1).map(Number);let c=t;if("TQ".includes(r)||(e.qx=null,e.qy=null),"H"===r)c=["L",t[1],i];else if("V"===r)c=["L",s,t[1]];else if("S"===r){const{x1:t,y1:r}=function(t,e,n,r,s){return"CS".includes(s)?{x1:2*t-n,y1:2*e-r}:{x1:t,y1:e}}(s,i,a,o,n);e.x1=t,e.y1=r,c=["C",t,r,...m]}else if("T"===r){const{qx:t,qy:r}=function(t,e,n,r,s){return"QT".includes(s)?{qx:2*t-n,qy:2*e-r}:{qx:t,qy:e}}(s,i,e.qx,e.qy,n);e.qx=t,e.qy=r,c=["Q",t,r,...m]}else if("Q"===r){const[t,n]=m;e.qx=t,e.qy=n}return c}function M(t){return f(t)&&t.every(t=>"ACLMQZ".includes(t[0]))}const b={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function v(t){if(M(t))return c(t);const e=y(t),n={...b},r=[],s=e.length;let i="",a="";for(let t=0;t<s;t+=1){[i]=e[t],r[t]=i,t&&(a=r[t-1]),e[t]=d(e[t],n,a);const s=e[t],o=s.length;n.x1=+s[o-2],n.y1=+s[o-1],n.x2=+s[o-4]||n.x1,n.y2=+s[o-3]||n.y1}return e}function N(t){const e=h(t),n=v(e),{length:r}=e,s="Z"===n.slice(-1)[0][0],i=s?r-2:r-1,[a,o]=n[0].slice(1),[m,c]=n[i].slice(-2);return s&&a===m&&o===c?e.slice(0,-1):e}function A(t){return l(t)&&t.every(t=>"MC".includes(t[0]))}function w(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function C(t,e,n,r,s,i,a,o,m,c){let u=t,l=e,h=n,f=r,y=o,x=m;const g=120*Math.PI/180,p=Math.PI/180*(+s||0);let d,M,b,v,N,A=[];if(c)[M,b,v,N]=c;else{d=w(u,l,-p),u=d.x,l=d.y,d=w(y,x,-p),y=d.x,x=d.y;const t=(u-y)/2,e=(l-x)/2;let n=t*t/(h*h)+e*e/(f*f);n>1&&(n=Math.sqrt(n),h*=n,f*=n);const r=h*h,s=f*f,o=(i===a?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));v=o*h*e/f+(u+y)/2,N=o*-f*t/h+(l+x)/2,M=(Math.asin((l-N)/f)*10**9>>0)/10**9,b=(Math.asin((x-N)/f)*10**9>>0)/10**9,M=u<v?Math.PI-M:M,b=y<v?Math.PI-b:b,M<0&&(M=2*Math.PI+M),b<0&&(b=2*Math.PI+b),a&&M>b&&(M-=2*Math.PI),!a&&b>M&&(b-=2*Math.PI)}let S=b-M;if(Math.abs(S)>g){const t=b,e=y,n=x;b=M+g*(a&&b>M?1:-1),y=v+h*Math.cos(b),x=N+f*Math.sin(b),A=C(y,x,h,f,s,0,a,e,n,[b,t,v,N])}S=b-M;const k=Math.cos(M),P=Math.sin(M),q=Math.cos(b),I=Math.sin(b),T=Math.tan(S/4),L=4/3*h*T,V=4/3*f*T,z=[u,l],$=[u+L*P,l-V*k],j=[y+L*I,x-V*q],E=[y,x];if($[0]=2*z[0]-$[0],$[1]=2*z[1]-$[1],c)return[...$,...j,...E,...A];A=[...$,...j,...E,...A];const O=[];for(let t=0,e=A.length;t<e;t+=1)O[t]=t%2?w(A[t-1],A[t],p).y:w(A[t],A[t+1],p).x;return O}function S(t,e,n,r,s,i){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*i+2/3*r,s,i]}function k(t,e,n){const[r,s]=t,[i,a]=e;return[r+(i-r)*n,s+(a-s)*n]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function q(t,e,n,r,s){const i=P([t,e],[n,r]);if("number"==typeof s){if(s<.001)return{x:t,y:e};if(s>i+.001)return{x:n,y:r};const[a,o]=k([t,e],[n,r],s/i);return{x:a,y:o}}return i}function I(t,e,n,r){const s=.5,i=[t,e],a=[n,r],o=k(i,a,s),m=k(a,o,s),c=k(o,m,s),u=k(m,c,s),l=k(c,u,s),h=q(...[...i,...o,...c,...l,s]),f=q(...[...l,...u,...m,...a,0]);return[h.x,h.y,f.x,f.y,n,r]}function T(t,e){const[n]=t,r=t.slice(1).map(t=>+t),[s,i]=r;let a;const{x1:o,y1:m,x:c,y:u}=e;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=s,e.y=i,t;case"A":return a=[o,m,...r],["C",...C(...a)];case"Q":return e.qx=s,e.qy=i,a=[o,m,...r],["C",...S(...a)];case"L":return["C",...I(o,m,s,i)];case"Z":return["C",...I(o,m,c,u)]}return t}function L(t){if(A(t))return c(t);const e=N(v(t)),n={...b},r=[];let s="",i=e.length;for(let t=0;t<i;t+=1){[s]=e[t],r[t]=s,e[t]=T(e[t],n),p(e,r,t),i=e.length;const a=e[t],o=a.length;n.x1=+a[o-2],n.y1=+a[o-1],n.x2=+a[o-4]||n.x1,n.y2=+a[o-3]||n.y1}return e}function V(e,n){let{round:r}=t;if(!1===n||!1===r)return c(e);r=n>=1?n:r;const s=r>=1?10**r:1;return e.map(t=>{const e=t.slice(1).map(Number).map(t=>t%1==0?t:Math.round(t*s)/s);return[t[0],...e]})}function z(t,e){return V(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function $(t){const e=y(t),n="Z"===e.slice(-1)[0][0],r=v(e).map((t,n)=>{const[r,s]=t.slice(-2).map(Number);return{seg:e[n],n:t,c:e[n][0],x:r,y:s}}).map((t,e,r)=>{const s=t.seg,i=t.n,a=e&&r[e-1],o=r[e+1]&&r[e+1],m=t.c,c=r.length,u=e?r[e-1].x:r[c-1].x,l=e?r[e-1].y:r[c-1].y;let h=[];switch(m){case"M":h=n?["Z"]:[m,u,l];break;case"A":h=[m,...s.slice(1,-3),1===s[5]?0:1,u,l];break;case"C":h=o&&"S"===o.c?["S",s[1],s[2],u,l]:[m,s[3],s[4],s[1],s[2],u,l];break;case"S":h=a&&"CS".includes(a.c)&&(!o||o&&"S"!==o.c)?["C",i[3],i[4],i[1],i[2],u,l]:[m,i[1],i[2],u,l];break;case"Q":h=o&&"T"===o.c?["T",u,l]:[m,...s.slice(1,-2),u,l];break;case"T":h=a&&"QT".includes(a.c)&&(!o||o&&"T"!==o.c)?["Q",i[1],i[2],u,l]:[m,u,l];break;case"Z":h=["M",u,l];break;case"H":h=[m,u];break;case"V":h=[m,l];break;default:h=[m,...s.slice(1,-2),u,l]}return h});return n?r.reverse():[r[0],...r.slice(1).reverse()]}function j(t){return z(y(t),0).replace(/(m|M)/g,"|$1").split("|").map(t=>t.trim()).filter(t=>t)}function E(t,e,n,r){const[s]=t,i=t=>Math.round(1e4*t)/1e4,a=t.slice(1).map(t=>+t),o=e.slice(1).map(t=>+t),{x1:m,y1:c,x2:u,y2:l,x:h,y:f}=n;let y=t;const[x,g]=o.slice(-2);if("TQ".includes(s)||(n.qx=null,n.qy=null),["V","H","S","T","Z"].includes(s))y=[s,...a];else if("L"===s)i(h)===i(x)?y=["V",g]:i(f)===i(g)&&(y=["H",x]);else if("C"===s){const[t,e]=o;"CS".includes(r)&&i(t)===i(2*m-u)&&i(e)===i(2*c-l)&&(y=["S",...o.slice(-4)]),n.x1=t,n.y1=e}else if("Q"===s){const[t,e]=o;n.qx=t,n.qy=e,"QT".includes(r)&&i(t)===i(2*m-u)&&i(e)===i(2*c-l)&&(y=["T",...o.slice(-2)])}return y}function O(t,e){const n=y(t),r=v(n),s={...b},i=[],a=n.length;let o="",m="",c=0,u=0,l=0,h=0;for(let t=0;t<a;t+=1){[o]=n[t],i[t]=o,t&&(m=i[t-1]),n[t]=E(n[t],r[t],s,m);const e=n[t],a=e.length;switch(s.x1=+e[a-2],s.y1=+e[a-1],s.x2=+e[a-4]||s.x1,s.y2=+e[a-3]||s.y1,o){case"Z":c=l,u=h;break;case"H":[,c]=e;break;case"V":[,u]=e;break;default:[c,u]=e.slice(-2).map(Number),"M"===o&&(l=c,h=u)}s.x=c,s.y=u}const f=V(n,e),x=V(g(n),e);return f.map((t,e)=>e?t.join("").length<x[e].join("").length?t:x[e]:t)}function Z(t){const e=new U,n=Array.from(t);if(!n.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);if(16===n.length){const[t,r,s,i,a,o,m,c,u,l,h,f,y,x,g,p]=n;e.m11=t,e.a=t,e.m21=a,e.c=a,e.m31=u,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=o,e.d=o,e.m32=l,e.m42=x,e.f=x,e.m13=s,e.m23=m,e.m33=h,e.m43=g,e.m14=i,e.m24=c,e.m34=f,e.m44=p}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,i,a,o]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=i,e.d=i,e.m41=a,e.e=a,e.m42=o,e.f=o}}return e}function Q(t){const e=Object.keys(new U);if("object"==typeof t&&e.every(e=>e in t))return Z([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${t}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function D(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new U;const r=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(t=>t).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(r);const i=s.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[a,o,m,c]=i,u=[a,o,m],l=[a,o,m,c];if("perspective"===e&&a&&[o,m].every(t=>void 0===t))n.m34=-1/a;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(t=>!Number.isNaN(+t))){const t=i.map(t=>Math.abs(t)<1e-6?0:t);n=n.multiply(Z(t))}else if("translate3d"===e&&u.every(t=>!Number.isNaN(+t)))n=n.translate(a,o,m);else if("translate"===e&&a&&void 0===m)n=n.translate(a,o||0,0);else if("rotate3d"===e&&l.every(t=>!Number.isNaN(+t))&&c)n=n.rotateAxisAngle(a,o,m,c);else if("rotate"===e&&a&&[o,m].every(t=>void 0===t))n=n.rotate(0,0,a);else if("scale3d"===e&&u.every(t=>!Number.isNaN(+t))&&u.some(t=>1!==t))n=n.scale(a,o,m);else if("scale"!==e||Number.isNaN(a)||1===a||void 0!==m)if("skew"===e&&a&&void 0===m)n=n.skewX(a),n=o?n.skewY(o):n;else{if(!(/[XYZ]/.test(e)&&a&&[o,m].every(t=>void 0===t)&&["translate","rotate","scale","skew"].some(t=>e.includes(t))))throw TypeError(r);if(["skewX","skewY"].includes(e))n=n[e](a);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),i=[0===s?a:0,1===s?a:0,2===s?a:0];n=n[t](...i)}}else{const t=Number.isNaN(+o)?a:o;n=n.scale(a,t,1)}}),n}function X(t,e,n){const r=new U;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function H(t,e,n){const r=new U,s=Math.PI/180,i=t*s,a=e*s,o=n*s,m=Math.cos(i),c=-Math.sin(i),u=Math.cos(a),l=-Math.sin(a),h=Math.cos(o),f=-Math.sin(o),y=u*h,x=-u*f;r.m11=y,r.a=y,r.m12=x,r.b=x,r.m13=l;const g=c*l*h+m*f;r.m21=g,r.c=g;const p=m*h-c*l*f;return r.m22=p,r.d=p,r.m23=-c*u,r.m31=c*f-m*l*h,r.m32=c*h+m*l*f,r.m33=m*u,r}function Y(t,e,n,r){const s=new U,i=r*(Math.PI/360),a=Math.sin(i),o=Math.cos(i),m=a*a,c=Math.sqrt(t*t+e*e+n*n);let u=t,l=e,h=n;0===c?(u=0,l=0,h=1):(u/=c,l/=c,h/=c);const f=u*u,y=l*l,x=h*h,g=1-2*(y+x)*m;s.m11=g,s.a=g;const p=2*(u*l*m+h*a*o);s.m12=p,s.b=p,s.m13=2*(u*h*m-l*a*o);const d=2*(l*u*m-h*a*o);s.m21=d,s.c=d;const M=1-2*(x+f)*m;return s.m22=M,s.d=M,s.m23=2*(l*h*m+u*a*o),s.m31=2*(h*u*m+l*a*o),s.m32=2*(h*l*m-u*a*o),s.m33=1-2*(f+y)*m,s}function F(t,e,n){const r=new U;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function R(t){const e=new U,n=t*Math.PI/180,r=Math.tan(n);return e.m21=r,e.c=r,e}function B(t){const e=new U,n=t*Math.PI/180,r=Math.tan(n);return e.m12=r,e.b=r,e}function J(t,e){return Z([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class U{constructor(...t){const e=this;if(e.a=1,e.b=0,e.c=0,e.d=1,e.e=0,e.f=0,e.m11=1,e.m12=0,e.m13=0,e.m14=0,e.m21=0,e.m22=1,e.m23=0,e.m24=0,e.m31=0,e.m32=0,e.m33=1,e.m34=0,e.m41=0,e.m42=0,e.m43=0,e.m44=1,t&&t.length){const n=[16,6].some(e=>e===t.length)?t:t[0];return e.setMatrixValue(n)}return e}set isIdentity(t){this.isIdentity=t}get isIdentity(){const t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44}get is2D(){const t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44}set is2D(t){this.is2D=t}setMatrixValue(t){return[Array,Float64Array,Float32Array].some(e=>t instanceof e)?Z(t):"string"==typeof t&&t.length&&"none"!==t?D(t):"object"==typeof t?Q(t):this}toArray(){const t=this;let e;return e=t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44],e.map(t=>Math.abs(t)<1e-6?0:(t*10**6>>0)/10**6)}toString(){const t=this.toArray();return`${this.is2D?"matrix":"matrix3d"}(${t})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return J(this,t)}translate(t,e,n){let r=e,s=n;return void 0===s&&(s=0),void 0===r&&(r=0),J(this,X(t,r,s))}scale(t,e,n){let r=e,s=n;return void 0===r&&(r=t),void 0===s&&(s=1),J(this,F(t,r,s))}rotate(t,e,n){let r=t,s=e,i=n;return void 0===s&&(s=0),void 0===i&&(i=r,r=0),J(this,H(r,s,i))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(t)))throw new TypeError("CSSMatrix: expecting 4 values");return J(this,Y(t,e,n,r))}skewX(t){return J(this,R(t))}skewY(t){return J(this,B(t))}transformPoint(t){let e=X(t.x,t.y,t.z);return e.m44=t.w||1,e=this.multiply(e),{x:e.m41,y:e.m42,z:e.m43,w:e.m44}}transform(t){const e=this,n=e.m11*t.x+e.m12*t.y+e.m13*t.z+e.m14*t.w,r=e.m21*t.x+e.m22*t.y+e.m23*t.z+e.m24*t.w,s=e.m31*t.x+e.m32*t.y+e.m33*t.z+e.m34*t.w,i=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:n/i,y:r/i,z:s/i,w:i}}}Object.assign(U,{Translate:X,Rotate:H,RotateAxisAngle:Y,Scale:F,SkewX:R,SkewY:B,Multiply:J,fromArray:Z,fromMatrix:Q,fromString:D});function G(t,e,n){const[r,s]=e,[i,a,o]=n,m=t.transformPoint({x:r,y:s,z:0,w:1}),c=m.x-i,u=m.y-a,l=m.z-o;return[c*(Math.abs(o)/Math.abs(l))+i,u*(Math.abs(o)/Math.abs(l))+a]}function K(t,e){let n,r,s,i,a,o,m,u=0,l=0;const h=y(t),f=v(h),x=function(t){let e=new U;const{origin:n}=t,[r,s]=n,{translate:i}=t,{rotate:a}=t,{skew:o}=t,{scale:m}=t;return Array.isArray(i)&&i.every(t=>!Number.isNaN(+t))&&i.some(t=>0!==t)?e=e.translate(i[0]||0,i[1]||0,i[2]||0):"number"!=typeof i||Number.isNaN(+i)||(e=e.translate(i||0,0,0)),(a||o||m)&&(e=e.translate(r,s),Array.isArray(a)&&a.every(t=>!Number.isNaN(+t))&&a.some(t=>0!==t)?e=e.rotate(a[0],a[1],a[2]):"number"!=typeof a||Number.isNaN(+a)||(e=e.rotate(0,0,a)),Array.isArray(o)&&o.every(t=>!Number.isNaN(+t))&&o.some(t=>0!==t)?(e=o[0]?e.skewX(o[0]):e,e=o[1]?e.skewY(o[1]):e):"number"!=typeof o||Number.isNaN(+o)||(e=e.skewX(o||0)),Array.isArray(m)&&m.every(t=>!Number.isNaN(+t))&&m.some(t=>1!==t)?e=e.scale(m[0],m[1],m[2]):"number"!=typeof m||Number.isNaN(+m)||(e=e.scale(m||1,m||1,m||1)),e=e.translate(-r,-s)),e}(e),g=Object.keys(e),{origin:d}=e,{a:M,b:N,c:A,d:w,e:C,f:S}=x,k=[M,N,A,w,C,S],P={...b};let q=[],I=0,L="",V=[];const z=[];if(!x.isIdentity){for(n=0,s=h.length;n<s;n+=1){q=h[n],h[n]&&([L]=q),z[n]=L,"A"!==L||x.is2D&&["skewX","skewY"].find(t=>g.includes(t))||(q=T(f[n],P),h[n]=T(f[n],P),p(h,z,n),f[n]=T(f[n],P),p(f,z,n),s=Math.max(h.length,f.length)),q=f[n],I=q.length,P.x1=+q[I-2],P.y1=+q[I-1],P.x2=+q[I-4]||P.x1,P.y2=+q[I-3]||P.y1;const t={s:h[n],c:h[n][0],x:P.x1,y:P.y1};V=[...V,t]}return V.map(t=>{switch(L=t.c,q=t.s,L){case"A":return m=function(t,e,n,r){const s=Math.cos(r*Math.PI/180),i=Math.sin(r*Math.PI/180),a=[e*(t[0]*s+t[2]*i),e*(t[1]*s+t[3]*i),n*(-t[0]*i+t[2]*s),n*(-t[1]*i+t[3]*s)],o=a[0]*a[0]+a[2]*a[2],m=a[1]*a[1]+a[3]*a[3];let c=((a[0]-a[3])*(a[0]-a[3])+(a[2]+a[1])*(a[2]+a[1]))*((a[0]+a[3])*(a[0]+a[3])+(a[2]-a[1])*(a[2]-a[1]));const u=(o+m)/2;if(c<1e-9*u){const t=Math.sqrt(u);return{rx:t,ry:t,ax:0}}const l=a[0]*a[1]+a[2]*a[3];c=Math.sqrt(c);const h=u+c/2,f=u-c/2;let y,x,g=Math.abs(l)<1e-9&&Math.abs(h-m)<1e-9?90:Math.atan(Math.abs(l)>Math.abs(h-m)?(h-o)/l:l/(h-m)*180)/Math.PI;return g>=0?(y=Math.sqrt(h),x=Math.sqrt(f)):(g+=90,y=Math.sqrt(f),x=Math.sqrt(h)),{rx:y,ry:x,ax:g}}(k,q[1],q[2],q[3]),k[0]*k[3]-k[1]*k[2]<0&&(q[5]=q[5]?0:1),[a,o]=G(x,[+q[6],+q[7]],d),q=u===a&&l===o||m.rx<1e-9*m.ry||m.ry<1e-9*m.rx?["L",a,o]:[L,m.rx,m.ry,m.ax,q[4],q[5],a,o],u=a,l=o,q;case"L":case"H":case"V":return[a,o]=G(x,[t.x,t.y],d),u!==a&&l!==o?q=["L",a,o]:l===o?q=["H",a]:u===a&&(q=["V",o]),u=a,l=o,q;default:for(r=1,i=q.length;r<i;r+=2)[u,l]=G(x,[+q[r],+q[r+1]],d),q[r]=u,q[r+1]=l;return q}})}return c(h)}function W(t,e,n,r,s,i,a,o,m){const c=1-m;return{x:c**3*t+3*c**2*m*n+3*c*m**2*s+m**3*a,y:c**3*e+3*c**2*m*r+3*c*m**2*i+m**3*o}}function _(t,e,n,r,s,i,a,o,m){let c=t,u=e;let l=0,h=[t,e,l],f=[t,e],y=0;if("number"==typeof m&&m<.001)return{x:c,y:u};for(let x=0;x<=100;x+=1){if(y=x/100,({x:c,y:u}=W(t,e,n,r,s,i,a,o,y)),l+=P(f,[c,u]),f=[c,u],"number"==typeof m&&l>=m){const t=(l-m)/(l-h[2]);return{x:f[0]*(1-t)+h[0]*t,y:f[1]*(1-t)+h[1]*t}}h=[c,u,l]}return"number"==typeof m&&m>=l?{x:a,y:o}:l}function tt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};const e=L(t);let n=0,r=0,s=[],i=[];e.forEach(t=>{const[e,a]=t.slice(-2).map(Number);if("M"===t[0])n=e,r=a,s.push(e),i.push(a);else{const o=function(t,e,n,r,s,i,a,o){let m=s-2*n+t-(a-2*s+n),c=2*(n-t)-2*(s-n),u=t-n,l=(-c+Math.sqrt(c*c-4*m*u))/2/m,h=(-c-Math.sqrt(c*c-4*m*u))/2/m;const f=[t,a],y=[e,o];let x=0,g=0;return Math.abs(l)>1e12&&(l=.5),Math.abs(h)>1e12&&(h=.5),l>0&&l<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,l)),f.push(x),y.push(g)),h>0&&h<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,h)),f.push(x),y.push(g)),m=i-2*r+e-(o-2*i+r),c=2*(r-e)-2*(i-r),u=e-r,l=(-c+Math.sqrt(c*c-4*m*u))/2/m,h=(-c-Math.sqrt(c*c-4*m*u))/2/m,Math.abs(l)>1e12&&(l=.5),Math.abs(h)>1e12&&(h=.5),l>0&&l<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,l)),f.push(x),y.push(g)),h>0&&h<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,h)),f.push(x),y.push(g)),{min:{x:Math.min(...f),y:Math.min(...y)},max:{x:Math.max(...f),y:Math.max(...y)}}}(...[n,r,...t.slice(1)]);s=[...s,o.min.x,o.max.x],i=[...i,o.min.y,o.max.y],n=e,r=a}});const a=Math.min(...s),o=Math.min(...i),m=Math.max(...s),c=Math.max(...i),u=m-a,l=c-o;return{width:u,height:l,x:a,y:o,x2:m,y2:c,cx:a+u/2,cy:o+l/2,cz:Math.max(u,l)+Math.min(u,l)/2}}Object.assign(U,{Version:"0.0.24"});class et{constructor(e,n){const r=n||{};this.segments=h(e);const s=tt(this.segments),{width:i,height:a,cx:o,cy:m,cz:c}=s;let{round:u,origin:l}=t;const{round:f,origin:y}=r;if("auto"===f){const t=(""+Math.floor(Math.max(i,a))).length;u=t>=4?0:4-t}else(Number.isInteger(f)&&f>=1||!1===f)&&(u=f);if(Array.isArray(y)&&y.length>=2){const[t,e,n]=y.map(Number);l=[Number.isNaN(t)?o:t,Number.isNaN(e)?m:e,n||c]}else l=[o,m,c];return this.round=u,this.origin=l,this}toAbsolute(){const{segments:t}=this;return this.segments=y(t),this}toRelative(){const{segments:t}=this;return this.segments=g(t),this}toCurve(){const{segments:t}=this;return this.segments=L(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=j(this.toString()),r=n.length>1?n:0,s=r&&c(r).map((e,n)=>t?n?$(e):h(e):$(e));let i=[];return i=r?s.flat(1):t?e:$(e),this.segments=c(i),this}normalize(){const{segments:t}=this;return this.segments=v(t),this}optimize(){const{segments:t}=this;return this.segments=O(t,this.round),this}transform(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some(e=>e in t))return this;const e={};Object.keys(t).forEach(n=>{e[n]=Array.isArray(t[n])?[...t[n]]:Number(t[n])});const{segments:n}=this,{origin:r}=e;if(r&&r.length>=2){const[t,n,s]=r.map(Number),[i,a,o]=this.origin;e.origin=[Number.isNaN(t)?i:t,Number.isNaN(n)?a:n,s||o]}else e.origin={...this.origin};return this.segments=K(n,e),this}flipX(){return this.transform({rotate:[180,0,0]}),this}flipY(){return this.transform({rotate:[0,180,0]}),this}toString(){return z(this.segments,this.round)}}function nt(t){let e=0,n=0,r=0;return L(t).map(t=>{switch(t[0]){case"M":return[,e,n]=t,0;default:return r=function(t,e,n,r,s,i,a,o){return 3*((o-e)*(n+s)-(a-t)*(r+i)+r*(t-s)-n*(e-i)+o*(s+t/3)-a*(i+e/3))/20}(e,n,...t.slice(1)),[e,n]=t.slice(-2),r}}).reduce((t,e)=>t+e,0)}function rt(t,e,n,r,s,i,a,o,m,c){let[u,l]=[t,e];const h=C(t,e,n,r,s,i,a,o,m);let f=0,y=[],x=[],g=0;if("number"==typeof c&&c<.001)return{x:u,y:l};for(let t=0,e=h.length;t<e;t+=6){if(y=h.slice(t,t+6),x=[u,l,...y],g=_(...x),"number"==typeof c&&f+g>=c)return _(...x,c-f);f+=g,[u,l]=y.slice(-2)}return"number"==typeof c&&c>=f?{x:o,y:m}:f}function st(t,e,n,r,s,i,a){const o=1-a;return{x:o**2*t+2*o*a*n+a**2*s,y:o**2*e+2*o*a*r+a**2*i}}function it(t,e,n,r,s,i,a){let o=t,m=e;let c=0,u=[t,e,c],l=[t,e],h=0;if("number"==typeof a&&a<.001)return{x:o,y:m};for(let f=0;f<=100;f+=1){if(h=f/100,({x:o,y:m}=st(t,e,n,r,s,i,h)),c+=P(l,[o,m]),l=[o,m],"number"==typeof a&&c>=a){const t=(c-a)/(c-u[2]);return{x:l[0]*(1-t)+u[0]*t,y:l[1]*(1-t)+u[1]*t}}u=[o,m,c]}return"number"==typeof a&&a>=c?{x:s,y:i}:c}function at(t,e){let n,r=0,s=!0,i=[],a="M",o=0,m=0,c=0,u=0,l=0;const h=N(v(t));for(let t=0,f=h.length;t<f;t+=1){if(n=h[t],[a]=n,s="M"===a,i=s?i:[m,c,...n.slice(1)],s){if([,u,l]=n,"number"==typeof e&&e<.001)return{x:u,y:l}}else if("L"===a){if(o=q(...i),e&&r+o>=e)return q(...i,e-r);r+=o}else if("A"===a){if(o=rt(...i),e&&r+o>=e)return rt(...i,e-r);r+=o}else if("C"===a){if(o=_(...i),e&&r+o>=e)return _(...i,e-r);r+=o}else if("Q"===a){if(o=it(...i),e&&r+o>=e)return it(...i,e-r);r+=o}else if("Z"===a){if(i=[m,c,u,l],o=q(...i),e&&r+o>=e)return q(...i,e-r);r+=o}[m,c]="Z"!==a?n.slice(-2):[u,l]}return e&&e>=r?{x:m,y:c}:r}function ot(t){return at(t)}function mt(t,e){return at(t,e)}function ct(t,e){const n=h(t),r=[];let s=[...n],i=ot(s),a=s.length-1,o=0,m=0,c=n[0];const[u,l]=c.slice(-2),f={x:u,y:l};if(a<=0||!e||!Number.isFinite(e))return{segment:c,index:0,length:m,point:f,lengthAtSegment:o};if(e>=i)return s=n.slice(0,-1),o=ot(s),m=i-o,{segment:n[a],index:a,length:m,lengthAtSegment:o};for(;a>0;)c=s[a],s=s.slice(0,-1),o=ot(s),m=i-o,i=o,r.push({segment:c,index:a,length:m,lengthAtSegment:o}),a-=1;return r.find(({lengthAtSegment:t})=>t<=e)}function ut(t,e){const n=N(h(t)),r=v(n),s=ot(n),i=t=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r};let a=8,o={x:0,y:0},m=0,c=o,u=0,l=1/0;for(let t=0;t<=s;t+=a)o=mt(r,t),m=i(o),m<l&&(c=o,u=t,l=m);a/=2;let f={x:0,y:0},y=f,x=0,g=0,p=0,d=0;for(;a>.5;)x=u-a,f=mt(r,x),p=i(f),g=u+a,y=mt(r,g),d=i(y),x>=0&&p<l?(c=f,u=x,l=p):g<=s&&d<l?(c=y,u=g,l=d):a/=2;const M=ct(n,l);return{closest:c,distance:Math.sqrt(l),segment:M}}const lt={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};const ht={CSSMatrix:U,parsePathString:h,isPathArray:l,isCurveArray:A,isAbsoluteArray:f,isRelativeArray:x,isNormalizedArray:M,isValidPath:function(t){if("string"!=typeof t)return!1;const e=new u(t);for(a(e);e.index<e.max&&!e.err.length;)m(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:y,pathToRelative:g,pathToCurve:L,pathToString:z,getDrawDirection:function(t){return nt(L(t))>=0},getPathArea:nt,getPathBBox:tt,getTotalLength:ot,getPathLength:function(t){let e=0;return L(t).forEach((t,n,r)=>{const s="M"!==t[0]?[...r[n-1].slice(-2),...t.slice(1)]:[];e+="M"===t[0]?0:_(...s)}),e},getPointAtLength:mt,getPointAtPathLength:function(t,e){return mt(t,e)},getClosestPoint:function(t,e){return ut(t,e).closest},getSegmentOfPoint:function(t,e){const n=ut(t,e),{segment:r}=n;return void 0!==r?r.segment:null},getPropertiesAtPoint:ut,getPropertiesAtLength:ct,getSegmentAtLength:function(t,e){const n=ct(t,e),{segment:r}=void 0!==n?n:{segment:null};return r},isPointInStroke:function(t,e){const{distance:n}=ut(t,e);return Math.abs(n)<.01},clonePath:c,splitPath:j,fixPath:N,roundPath:V,optimizePath:O,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?[...r[n-1].slice(-2),...e.slice(1)]:[...t[0].slice(1),...e.slice(1)]).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M",...e[0].slice(0,2)],...e.map(t=>["C",...t.slice(2)])]},reversePath:$,normalizePath:v,transformPath:K,shapeToPath:function(e,n){const r=Object.keys(lt),s=e instanceof Element;if(s&&!r.some(t=>e.tagName===t))throw TypeError(`shapeToPath: "${e}" is not SVGElement`);const i=document.createElementNS("http://www.w3.org/2000/svg","path"),a=s?e.tagName:e.type,o={};if(o.type=a,s){const t=lt[a];t.forEach(t=>{o[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:e,value:n})=>{t.includes(e)||i.setAttribute(e,n)})}else Object.assign(o,e);let m;const{round:c}=t;return"circle"===a?m=z(function(t){const{cx:e,cy:n,r:r}=t;return[["M",e-r,n],["a",r,r,0,1,0,2*r,0],["a",r,r,0,1,0,-2*r,0]]}(o),c):"ellipse"===a?m=z(function(t){const{cx:e,cy:n,rx:r,ry:s}=t;return[["M",e-r,n],["a",r,s,0,1,0,2*r,0],["a",r,s,0,1,0,-2*r,0]]}(o),c):["polyline","polygon"].includes(a)?m=z(function(t){const e=[],n=t.points.split(/[\s|,]/).map(Number);let r=0;for(;r<n.length;)e.push([r?"L":"M",n[r],n[r+1]]),r+=2;return"polygon"===t.type?[...e,["z"]]:e}(o),c):"rect"===a?m=z(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let i=+t.rx,a=+t.ry;return i||a?(i=i||a,a=a||i,2*i>r&&(i-=(2*i-r)/2),2*a>s&&(a-=(2*a-s)/2),[["M",e+i,n],["h",r-2*i],["s",i,0,i,a],["v",s-2*a],["s",0,a,-i,a],["h",2*i-r],["s",-i,0,-i,-a],["v",2*a-s],["s",0,-a,i,-a]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(o),c):"line"===a?m=z(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",e,n],["L",r,s]]}(o),c):"glyph"===a&&(m=s?e.getAttribute("d"):e.type),!!m&&(i.setAttribute("d",m),n&&s&&(e.before(i,e),e.remove()),i)},options:t};Object.assign(et,ht,{Version:"0.1.23"});export{et as default};
|
|
1
|
+
// SVGPathCommander v0.1.24 | thednp © 2021 | MIT-License
|
|
2
|
+
const t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function n(t){let n=t.pathValue[t.segmentStart],r=n.toLowerCase(),{data:s}=t;for("m"===r&&s.length>2&&(t.segments.push([n,s[0],s[1]]),s=s.slice(2),r="l",n="m"===n?"l":"L");s.length>=e[r]&&(t.segments.push([n,...s.splice(0,e[r])]),e[r]););}function r(t){const{index:e}=t,n=t.pathValue.charCodeAt(e);return 48===n?(t.param=0,void(t.index+=1)):49===n?(t.param=1,void(t.index+=1)):void(t.err=`Invalid path value: invalid Arc flag "${n}", expecting 0 or 1 at index ${e}`)}function s(t){return t>=48&&t<=57}function i(t){const{max:e,pathValue:n,index:r}=t;let i,a=r,o=!1,m=!1,c=!1,u=!1;if(a>=e)t.err=`Invalid path value at ${a}: missing param ${n[a]}`;else if(i=n.charCodeAt(a),43!==i&&45!==i||(a+=1,i=a<e?n.charCodeAt(a):0),s(i)||46===i){if(46!==i){if(o=48===i,a+=1,i=a<e?n.charCodeAt(a):0,o&&a<e&&i&&s(i))return void(t.err=`Invalid path value at index ${r}: ${n[r]} illegal number`);for(;a<e&&s(n.charCodeAt(a));)a+=1,m=!0;i=a<e?n.charCodeAt(a):0}if(46===i){for(u=!0,a+=1;s(n.charCodeAt(a));)a+=1,c=!0;i=a<e?n.charCodeAt(a):0}if(101===i||69===i){if(u&&!m&&!c)return void(t.err=`Invalid path value at index ${a}: ${n[a]} invalid float exponent`);if(a+=1,i=a<e?n.charCodeAt(a):0,43!==i&&45!==i||(a+=1),!(a<e&&s(n.charCodeAt(a))))return void(t.err=`Invalid path value at index ${a}: ${n[a]} invalid float exponent`);for(;a<e&&s(n.charCodeAt(a));)a+=1}t.index=a,t.param=+t.pathValue.slice(r,a)}else t.err=`Invalid path value at index ${a}: ${n[a]} is not a number`}function a(t){const{pathValue:e,max:n}=t;for(;t.index<n&&(10===(r=e.charCodeAt(t.index))||13===r||8232===r||8233===r||32===r||9===r||11===r||12===r||160===r||r>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(r)>=0);)t.index+=1;var r}function o(t){return t>=48&&t<=57||43===t||45===t||46===t}function m(t){const{max:s,pathValue:m,index:c}=t,u=m.charCodeAt(c),l=e[m[c].toLowerCase()];if(t.segmentStart=c,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(u))if(t.index+=1,a(t),t.data=[],l){for(;;){for(let e=l;e>0;e-=1){if(97!=(32|u)||3!==e&&4!==e?i(t):r(t),t.err.length)return;t.data.push(t.param),a(t),t.index<s&&44===m.charCodeAt(t.index)&&(t.index+=1,a(t))}if(t.index>=t.max)break;if(!o(m.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`Invalid path value: ${m[c]} not a path command`}function c(t){return t.map(t=>Array.isArray(t)?[...t]:t)}function u(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function l(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"achlmqstvz".includes(n)})}function h(t){if(l(t))return c(t);const e=new u(t);for(a(e);e.index<e.max&&!e.err.length;)m(e);return e.err.length?e.segments=[]:e.segments.length&&("mM".includes(e.segments[0][0])?e.segments[0][0]="M":(e.err="Invalid path value: missing M/m",e.segments=[])),e.segments}function f(t){return l(t)&&t.every(t=>t[0]===t[0].toUpperCase())}function y(t){if(f(t))return c(t);const e=h(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toUpperCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"A":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]+n,e[6]+r];break;case"V":m=[o,e[0]+r];break;case"H":m=[o,e[0]+n];break;default:m=[o,...e.map((t,e)=>t+(e%2?r:n))]}else m=[o,...e];const c=m.length;switch(o){case"Z":n=s,r=i;break;case"H":[,n]=m;break;case"V":[,r]=m;break;default:n=m[c-2],r=m[c-1],"M"===o&&(s=n,i=r)}return m})}function x(t){return l(t)&&t.slice(1).every(t=>t[0]===t[0].toLowerCase())}function g(t){if(x(t))return c(t);const e=h(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toLowerCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"a":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]-n,e[6]-r];break;case"v":m=[o,e[0]-r];break;case"h":m=[o,e[0]-n];break;default:m=[o,...e.map((t,e)=>t-(e%2?r:n))],"m"===o&&([n,r]=e,s=n,i=r)}else"m"===a&&(s=e[0]+n,i=e[1]+r),m=[o,...e];const c=m.length;switch(o){case"z":n=s,r=i;break;case"h":n+=m[1];break;case"v":r+=m[1];break;default:n+=m[c-2],r+=m[c-1]}return m})}function p(t,e,n){if(t[n].length>7){t[n].shift();const r=t[n];let s=n;for(;r.length;)e[n]="A",t.splice(s+=1,0,["C",...r.splice(0,6)]);t.splice(n,1)}}function d(t,e,n){const[r]=t,{x1:s,y1:i,x2:a,y2:o}=e,m=t.slice(1).map(Number);let c=t;if("TQ".includes(r)||(e.qx=null,e.qy=null),"H"===r)c=["L",t[1],i];else if("V"===r)c=["L",s,t[1]];else if("S"===r){const{x1:t,y1:r}=function(t,e,n,r,s){return"CS".includes(s)?{x1:2*t-n,y1:2*e-r}:{x1:t,y1:e}}(s,i,a,o,n);e.x1=t,e.y1=r,c=["C",t,r,...m]}else if("T"===r){const{qx:t,qy:r}=function(t,e,n,r,s){return"QT".includes(s)?{qx:2*t-n,qy:2*e-r}:{qx:t,qy:e}}(s,i,e.qx,e.qy,n);e.qx=t,e.qy=r,c=["Q",t,r,...m]}else if("Q"===r){const[t,n]=m;e.qx=t,e.qy=n}return c}function M(t){return f(t)&&t.every(t=>"ACLMQZ".includes(t[0]))}const b={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function v(t){if(M(t))return c(t);const e=y(t),n={...b},r=[],s=e.length;let i="",a="";for(let t=0;t<s;t+=1){[i]=e[t],r[t]=i,t&&(a=r[t-1]),e[t]=d(e[t],n,a);const s=e[t],o=s.length;n.x1=+s[o-2],n.y1=+s[o-1],n.x2=+s[o-4]||n.x1,n.y2=+s[o-3]||n.y1}return e}function N(t){const e=h(t),n=v(e),{length:r}=e,s="Z"===n.slice(-1)[0][0],i=s?r-2:r-1,[a,o]=n[0].slice(1),[m,c]=n[i].slice(-2);return s&&a===m&&o===c?e.slice(0,-1):e}function A(t){return l(t)&&t.every(t=>"MC".includes(t[0]))}function w(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function C(t,e,n,r,s,i,a,o,m,c){let u=t,l=e,h=n,f=r,y=o,x=m;const g=120*Math.PI/180,p=Math.PI/180*(+s||0);let d,M,b,v,N,A=[];if(c)[M,b,v,N]=c;else{d=w(u,l,-p),u=d.x,l=d.y,d=w(y,x,-p),y=d.x,x=d.y;const t=(u-y)/2,e=(l-x)/2;let n=t*t/(h*h)+e*e/(f*f);n>1&&(n=Math.sqrt(n),h*=n,f*=n);const r=h*h,s=f*f,o=(i===a?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));v=o*h*e/f+(u+y)/2,N=o*-f*t/h+(l+x)/2,M=(Math.asin((l-N)/f)*10**9>>0)/10**9,b=(Math.asin((x-N)/f)*10**9>>0)/10**9,M=u<v?Math.PI-M:M,b=y<v?Math.PI-b:b,M<0&&(M=2*Math.PI+M),b<0&&(b=2*Math.PI+b),a&&M>b&&(M-=2*Math.PI),!a&&b>M&&(b-=2*Math.PI)}let S=b-M;if(Math.abs(S)>g){const t=b,e=y,n=x;b=M+g*(a&&b>M?1:-1),y=v+h*Math.cos(b),x=N+f*Math.sin(b),A=C(y,x,h,f,s,0,a,e,n,[b,t,v,N])}S=b-M;const k=Math.cos(M),P=Math.sin(M),q=Math.cos(b),I=Math.sin(b),T=Math.tan(S/4),L=4/3*h*T,V=4/3*f*T,z=[u,l],$=[u+L*P,l-V*k],j=[y+L*I,x-V*q],E=[y,x];if($[0]=2*z[0]-$[0],$[1]=2*z[1]-$[1],c)return[...$,...j,...E,...A];A=[...$,...j,...E,...A];const O=[];for(let t=0,e=A.length;t<e;t+=1)O[t]=t%2?w(A[t-1],A[t],p).y:w(A[t],A[t+1],p).x;return O}function S(t,e,n,r,s,i){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*i+2/3*r,s,i]}function k(t,e,n){const[r,s]=t,[i,a]=e;return[r+(i-r)*n,s+(a-s)*n]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function q(t,e,n,r,s){const i=P([t,e],[n,r]);if("number"==typeof s){if(s<.001)return{x:t,y:e};if(s>i)return{x:n,y:r};const[a,o]=k([t,e],[n,r],s/i);return{x:a,y:o}}return i}function I(t,e,n,r){const s=.5,i=[t,e],a=[n,r],o=k(i,a,s),m=k(a,o,s),c=k(o,m,s),u=k(m,c,s),l=k(c,u,s),h=q(...[...i,...o,...c,...l,s]),f=q(...[...l,...u,...m,...a,0]);return[h.x,h.y,f.x,f.y,n,r]}function T(t,e){const[n]=t,r=t.slice(1).map(t=>+t),[s,i]=r;let a;const{x1:o,y1:m,x:c,y:u}=e;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=s,e.y=i,t;case"A":return a=[o,m,...r],["C",...C(...a)];case"Q":return e.qx=s,e.qy=i,a=[o,m,...r],["C",...S(...a)];case"L":return["C",...I(o,m,s,i)];case"Z":return["C",...I(o,m,c,u)]}return t}function L(t){if(A(t))return c(t);const e=N(v(t)),n={...b},r=[];let s="",i=e.length;for(let t=0;t<i;t+=1){[s]=e[t],r[t]=s,e[t]=T(e[t],n),p(e,r,t),i=e.length;const a=e[t],o=a.length;n.x1=+a[o-2],n.y1=+a[o-1],n.x2=+a[o-4]||n.x1,n.y2=+a[o-3]||n.y1}return e}function V(e,n){let{round:r}=t;if(!1===n||!1===r)return c(e);r=n>=1?n:r;const s=r>=1?10**r:1;return e.map(t=>{const e=t.slice(1).map(Number).map(t=>t%1==0?t:Math.round(t*s)/s);return[t[0],...e]})}function z(t,e){return V(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function $(t){const e=y(t),n="Z"===e.slice(-1)[0][0],r=v(e).map((t,n)=>{const[r,s]=t.slice(-2).map(Number);return{seg:e[n],n:t,c:e[n][0],x:r,y:s}}).map((t,e,r)=>{const s=t.seg,i=t.n,a=e&&r[e-1],o=r[e+1]&&r[e+1],m=t.c,c=r.length,u=e?r[e-1].x:r[c-1].x,l=e?r[e-1].y:r[c-1].y;let h=[];switch(m){case"M":h=n?["Z"]:[m,u,l];break;case"A":h=[m,...s.slice(1,-3),1===s[5]?0:1,u,l];break;case"C":h=o&&"S"===o.c?["S",s[1],s[2],u,l]:[m,s[3],s[4],s[1],s[2],u,l];break;case"S":h=a&&"CS".includes(a.c)&&(!o||o&&"S"!==o.c)?["C",i[3],i[4],i[1],i[2],u,l]:[m,i[1],i[2],u,l];break;case"Q":h=o&&"T"===o.c?["T",u,l]:[m,...s.slice(1,-2),u,l];break;case"T":h=a&&"QT".includes(a.c)&&(!o||o&&"T"!==o.c)?["Q",i[1],i[2],u,l]:[m,u,l];break;case"Z":h=["M",u,l];break;case"H":h=[m,u];break;case"V":h=[m,l];break;default:h=[m,...s.slice(1,-2),u,l]}return h});return n?r.reverse():[r[0],...r.slice(1).reverse()]}function j(t){return z(y(t),0).replace(/(m|M)/g,"|$1").split("|").map(t=>t.trim()).filter(t=>t)}function E(t,e,n,r){const[s]=t,i=t=>Math.round(1e4*t)/1e4,a=t.slice(1).map(t=>+t),o=e.slice(1).map(t=>+t),{x1:m,y1:c,x2:u,y2:l,x:h,y:f}=n;let y=t;const[x,g]=o.slice(-2);if("TQ".includes(s)||(n.qx=null,n.qy=null),["V","H","S","T","Z"].includes(s))y=[s,...a];else if("L"===s)i(h)===i(x)?y=["V",g]:i(f)===i(g)&&(y=["H",x]);else if("C"===s){const[t,e]=o;"CS".includes(r)&&i(t)===i(2*m-u)&&i(e)===i(2*c-l)&&(y=["S",...o.slice(-4)]),n.x1=t,n.y1=e}else if("Q"===s){const[t,e]=o;n.qx=t,n.qy=e,"QT".includes(r)&&i(t)===i(2*m-u)&&i(e)===i(2*c-l)&&(y=["T",...o.slice(-2)])}return y}function O(t,e){const n=y(t),r=v(n),s={...b},i=[],a=n.length;let o="",m="",c=0,u=0,l=0,h=0;for(let t=0;t<a;t+=1){[o]=n[t],i[t]=o,t&&(m=i[t-1]),n[t]=E(n[t],r[t],s,m);const e=n[t],a=e.length;switch(s.x1=+e[a-2],s.y1=+e[a-1],s.x2=+e[a-4]||s.x1,s.y2=+e[a-3]||s.y1,o){case"Z":c=l,u=h;break;case"H":[,c]=e;break;case"V":[,u]=e;break;default:[c,u]=e.slice(-2).map(Number),"M"===o&&(l=c,h=u)}s.x=c,s.y=u}const f=V(n,e),x=V(g(n),e);return f.map((t,e)=>e?t.join("").length<x[e].join("").length?t:x[e]:t)}function Z(t){const e=new U,n=Array.from(t);if(!n.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);if(16===n.length){const[t,r,s,i,a,o,m,c,u,l,h,f,y,x,g,p]=n;e.m11=t,e.a=t,e.m21=a,e.c=a,e.m31=u,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=o,e.d=o,e.m32=l,e.m42=x,e.f=x,e.m13=s,e.m23=m,e.m33=h,e.m43=g,e.m14=i,e.m24=c,e.m34=f,e.m44=p}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,i,a,o]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=i,e.d=i,e.m41=a,e.e=a,e.m42=o,e.f=o}}return e}function Q(t){const e=Object.keys(new U);if("object"==typeof t&&e.every(e=>e in t))return Z([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${t}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function D(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new U;const r=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(t=>t).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(r);const i=s.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[a,o,m,c]=i,u=[a,o,m],l=[a,o,m,c];if("perspective"===e&&a&&[o,m].every(t=>void 0===t))n.m34=-1/a;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(t=>!Number.isNaN(+t))){const t=i.map(t=>Math.abs(t)<1e-6?0:t);n=n.multiply(Z(t))}else if("translate3d"===e&&u.every(t=>!Number.isNaN(+t)))n=n.translate(a,o,m);else if("translate"===e&&a&&void 0===m)n=n.translate(a,o||0,0);else if("rotate3d"===e&&l.every(t=>!Number.isNaN(+t))&&c)n=n.rotateAxisAngle(a,o,m,c);else if("rotate"===e&&a&&[o,m].every(t=>void 0===t))n=n.rotate(0,0,a);else if("scale3d"===e&&u.every(t=>!Number.isNaN(+t))&&u.some(t=>1!==t))n=n.scale(a,o,m);else if("scale"!==e||Number.isNaN(a)||1===a||void 0!==m)if("skew"===e&&a&&void 0===m)n=n.skewX(a),n=o?n.skewY(o):n;else{if(!(/[XYZ]/.test(e)&&a&&[o,m].every(t=>void 0===t)&&["translate","rotate","scale","skew"].some(t=>e.includes(t))))throw TypeError(r);if(["skewX","skewY"].includes(e))n=n[e](a);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),i=[0===s?a:0,1===s?a:0,2===s?a:0];n=n[t](...i)}}else{const t=Number.isNaN(+o)?a:o;n=n.scale(a,t,1)}}),n}function X(t,e,n){const r=new U;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function H(t,e,n){const r=new U,s=Math.PI/180,i=t*s,a=e*s,o=n*s,m=Math.cos(i),c=-Math.sin(i),u=Math.cos(a),l=-Math.sin(a),h=Math.cos(o),f=-Math.sin(o),y=u*h,x=-u*f;r.m11=y,r.a=y,r.m12=x,r.b=x,r.m13=l;const g=c*l*h+m*f;r.m21=g,r.c=g;const p=m*h-c*l*f;return r.m22=p,r.d=p,r.m23=-c*u,r.m31=c*f-m*l*h,r.m32=c*h+m*l*f,r.m33=m*u,r}function Y(t,e,n,r){const s=new U,i=r*(Math.PI/360),a=Math.sin(i),o=Math.cos(i),m=a*a,c=Math.sqrt(t*t+e*e+n*n);let u=t,l=e,h=n;0===c?(u=0,l=0,h=1):(u/=c,l/=c,h/=c);const f=u*u,y=l*l,x=h*h,g=1-2*(y+x)*m;s.m11=g,s.a=g;const p=2*(u*l*m+h*a*o);s.m12=p,s.b=p,s.m13=2*(u*h*m-l*a*o);const d=2*(l*u*m-h*a*o);s.m21=d,s.c=d;const M=1-2*(x+f)*m;return s.m22=M,s.d=M,s.m23=2*(l*h*m+u*a*o),s.m31=2*(h*u*m+l*a*o),s.m32=2*(h*l*m-u*a*o),s.m33=1-2*(f+y)*m,s}function F(t,e,n){const r=new U;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function R(t){const e=new U,n=t*Math.PI/180,r=Math.tan(n);return e.m21=r,e.c=r,e}function B(t){const e=new U,n=t*Math.PI/180,r=Math.tan(n);return e.m12=r,e.b=r,e}function J(t,e){return Z([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class U{constructor(...t){const e=this;if(e.a=1,e.b=0,e.c=0,e.d=1,e.e=0,e.f=0,e.m11=1,e.m12=0,e.m13=0,e.m14=0,e.m21=0,e.m22=1,e.m23=0,e.m24=0,e.m31=0,e.m32=0,e.m33=1,e.m34=0,e.m41=0,e.m42=0,e.m43=0,e.m44=1,t&&t.length){const n=[16,6].some(e=>e===t.length)?t:t[0];return e.setMatrixValue(n)}return e}set isIdentity(t){this.isIdentity=t}get isIdentity(){const t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44}get is2D(){const t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44}set is2D(t){this.is2D=t}setMatrixValue(t){return[Array,Float64Array,Float32Array].some(e=>t instanceof e)?Z(t):"string"==typeof t&&t.length&&"none"!==t?D(t):"object"==typeof t?Q(t):this}toArray(){const t=this;let e;return e=t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44],e.map(t=>Math.abs(t)<1e-6?0:(t*10**6>>0)/10**6)}toString(){const t=this.toArray();return`${this.is2D?"matrix":"matrix3d"}(${t})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return J(this,t)}translate(t,e,n){let r=e,s=n;return void 0===s&&(s=0),void 0===r&&(r=0),J(this,X(t,r,s))}scale(t,e,n){let r=e,s=n;return void 0===r&&(r=t),void 0===s&&(s=1),J(this,F(t,r,s))}rotate(t,e,n){let r=t,s=e,i=n;return void 0===s&&(s=0),void 0===i&&(i=r,r=0),J(this,H(r,s,i))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(t)))throw new TypeError("CSSMatrix: expecting 4 values");return J(this,Y(t,e,n,r))}skewX(t){return J(this,R(t))}skewY(t){return J(this,B(t))}transformPoint(t){let e=X(t.x,t.y,t.z);return e.m44=t.w||1,e=this.multiply(e),{x:e.m41,y:e.m42,z:e.m43,w:e.m44}}transform(t){const e=this,n=e.m11*t.x+e.m12*t.y+e.m13*t.z+e.m14*t.w,r=e.m21*t.x+e.m22*t.y+e.m23*t.z+e.m24*t.w,s=e.m31*t.x+e.m32*t.y+e.m33*t.z+e.m34*t.w,i=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:n/i,y:r/i,z:s/i,w:i}}}Object.assign(U,{Translate:X,Rotate:H,RotateAxisAngle:Y,Scale:F,SkewX:R,SkewY:B,Multiply:J,fromArray:Z,fromMatrix:Q,fromString:D});function G(t,e,n){const[r,s]=e,[i,a,o]=n,m=t.transformPoint({x:r,y:s,z:0,w:1}),c=m.x-i,u=m.y-a,l=m.z-o;return[c*(Math.abs(o)/Math.abs(l))+i,u*(Math.abs(o)/Math.abs(l))+a]}function K(t,e){let n,r,s,i,a,o,m,u=0,l=0;const h=y(t),f=v(h),x=function(t){let e=new U;const{origin:n}=t,[r,s]=n,{translate:i}=t,{rotate:a}=t,{skew:o}=t,{scale:m}=t;return Array.isArray(i)&&i.every(t=>!Number.isNaN(+t))&&i.some(t=>0!==t)?e=e.translate(i[0]||0,i[1]||0,i[2]||0):"number"!=typeof i||Number.isNaN(+i)||(e=e.translate(i||0,0,0)),(a||o||m)&&(e=e.translate(r,s),Array.isArray(a)&&a.every(t=>!Number.isNaN(+t))&&a.some(t=>0!==t)?e=e.rotate(a[0],a[1],a[2]):"number"!=typeof a||Number.isNaN(+a)||(e=e.rotate(0,0,a)),Array.isArray(o)&&o.every(t=>!Number.isNaN(+t))&&o.some(t=>0!==t)?(e=o[0]?e.skewX(o[0]):e,e=o[1]?e.skewY(o[1]):e):"number"!=typeof o||Number.isNaN(+o)||(e=e.skewX(o||0)),Array.isArray(m)&&m.every(t=>!Number.isNaN(+t))&&m.some(t=>1!==t)?e=e.scale(m[0],m[1],m[2]):"number"!=typeof m||Number.isNaN(+m)||(e=e.scale(m||1,m||1,m||1)),e=e.translate(-r,-s)),e}(e),g=Object.keys(e),{origin:d}=e,{a:M,b:N,c:A,d:w,e:C,f:S}=x,k=[M,N,A,w,C,S],P={...b};let q=[],I=0,L="",V=[];const z=[];if(!x.isIdentity){for(n=0,s=h.length;n<s;n+=1){q=h[n],h[n]&&([L]=q),z[n]=L,"A"!==L||x.is2D&&["skewX","skewY"].find(t=>g.includes(t))||(q=T(f[n],P),h[n]=T(f[n],P),p(h,z,n),f[n]=T(f[n],P),p(f,z,n),s=Math.max(h.length,f.length)),q=f[n],I=q.length,P.x1=+q[I-2],P.y1=+q[I-1],P.x2=+q[I-4]||P.x1,P.y2=+q[I-3]||P.y1;const t={s:h[n],c:h[n][0],x:P.x1,y:P.y1};V=[...V,t]}return V.map(t=>{switch(L=t.c,q=t.s,L){case"A":return m=function(t,e,n,r){const s=Math.cos(r*Math.PI/180),i=Math.sin(r*Math.PI/180),a=[e*(t[0]*s+t[2]*i),e*(t[1]*s+t[3]*i),n*(-t[0]*i+t[2]*s),n*(-t[1]*i+t[3]*s)],o=a[0]*a[0]+a[2]*a[2],m=a[1]*a[1]+a[3]*a[3];let c=((a[0]-a[3])*(a[0]-a[3])+(a[2]+a[1])*(a[2]+a[1]))*((a[0]+a[3])*(a[0]+a[3])+(a[2]-a[1])*(a[2]-a[1]));const u=(o+m)/2;if(c<1e-9*u){const t=Math.sqrt(u);return{rx:t,ry:t,ax:0}}const l=a[0]*a[1]+a[2]*a[3];c=Math.sqrt(c);const h=u+c/2,f=u-c/2;let y,x,g=Math.abs(l)<1e-9&&Math.abs(h-m)<1e-9?90:Math.atan(Math.abs(l)>Math.abs(h-m)?(h-o)/l:l/(h-m)*180)/Math.PI;return g>=0?(y=Math.sqrt(h),x=Math.sqrt(f)):(g+=90,y=Math.sqrt(f),x=Math.sqrt(h)),{rx:y,ry:x,ax:g}}(k,q[1],q[2],q[3]),k[0]*k[3]-k[1]*k[2]<0&&(q[5]=q[5]?0:1),[a,o]=G(x,[+q[6],+q[7]],d),q=u===a&&l===o||m.rx<1e-9*m.ry||m.ry<1e-9*m.rx?["L",a,o]:[L,m.rx,m.ry,m.ax,q[4],q[5],a,o],u=a,l=o,q;case"L":case"H":case"V":return[a,o]=G(x,[t.x,t.y],d),u!==a&&l!==o?q=["L",a,o]:l===o?q=["H",a]:u===a&&(q=["V",o]),u=a,l=o,q;default:for(r=1,i=q.length;r<i;r+=2)[u,l]=G(x,[+q[r],+q[r+1]],d),q[r]=u,q[r+1]=l;return q}})}return c(h)}function W(t,e,n,r,s,i,a,o,m){const c=1-m;return{x:c**3*t+3*c**2*m*n+3*c*m**2*s+m**3*a,y:c**3*e+3*c**2*m*r+3*c*m**2*i+m**3*o}}function _(t,e,n,r,s,i,a,o,m){const c="number"==typeof m;let u=t,l=e,h=0,f=[t,e,h],y=[t,e],x=0;if(c&&m<.001)return{x:u,y:l};for(let g=0;g<=100;g+=1){if(x=g/100,({x:u,y:l}=W(t,e,n,r,s,i,a,o,x)),h+=P(y,[u,l]),y=[u,l],c&&h>=m){const t=(h-m)/(h-f[2]);return{x:y[0]*(1-t)+f[0]*t,y:y[1]*(1-t)+f[1]*t}}f=[u,l,h]}return c&&m>=h?{x:a,y:o}:h}function tt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};const e=L(t);let n=0,r=0,s=[],i=[];e.forEach(t=>{const[e,a]=t.slice(-2).map(Number);if("M"===t[0])n=e,r=a,s.push(e),i.push(a);else{const o=function(t,e,n,r,s,i,a,o){let m=s-2*n+t-(a-2*s+n),c=2*(n-t)-2*(s-n),u=t-n,l=(-c+Math.sqrt(c*c-4*m*u))/2/m,h=(-c-Math.sqrt(c*c-4*m*u))/2/m;const f=[t,a],y=[e,o];let x=0,g=0;return Math.abs(l)>1e12&&(l=.5),Math.abs(h)>1e12&&(h=.5),l>0&&l<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,l)),f.push(x),y.push(g)),h>0&&h<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,h)),f.push(x),y.push(g)),m=i-2*r+e-(o-2*i+r),c=2*(r-e)-2*(i-r),u=e-r,l=(-c+Math.sqrt(c*c-4*m*u))/2/m,h=(-c-Math.sqrt(c*c-4*m*u))/2/m,Math.abs(l)>1e12&&(l=.5),Math.abs(h)>1e12&&(h=.5),l>0&&l<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,l)),f.push(x),y.push(g)),h>0&&h<1&&(({x:x,y:g}=_(t,e,n,r,s,i,a,o,h)),f.push(x),y.push(g)),{min:{x:Math.min(...f),y:Math.min(...y)},max:{x:Math.max(...f),y:Math.max(...y)}}}(...[n,r,...t.slice(1)]);s=[...s,o.min.x,o.max.x],i=[...i,o.min.y,o.max.y],n=e,r=a}});const a=Math.min(...s),o=Math.min(...i),m=Math.max(...s),c=Math.max(...i),u=m-a,l=c-o;return{width:u,height:l,x:a,y:o,x2:m,y2:c,cx:a+u/2,cy:o+l/2,cz:Math.max(u,l)+Math.min(u,l)/2}}Object.assign(U,{Version:"0.0.24"});class et{constructor(e,n){const r=n||{};this.segments=h(e);const s=tt(this.segments),{width:i,height:a,cx:o,cy:m,cz:c}=s;let{round:u,origin:l}=t;const{round:f,origin:y}=r;if("auto"===f){const t=(""+Math.floor(Math.max(i,a))).length;u=t>=4?0:4-t}else(Number.isInteger(f)&&f>=1||!1===f)&&(u=f);if(Array.isArray(y)&&y.length>=2){const[t,e,n]=y.map(Number);l=[Number.isNaN(t)?o:t,Number.isNaN(e)?m:e,n||c]}else l=[o,m,c];return this.round=u,this.origin=l,this}toAbsolute(){const{segments:t}=this;return this.segments=y(t),this}toRelative(){const{segments:t}=this;return this.segments=g(t),this}toCurve(){const{segments:t}=this;return this.segments=L(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=j(this.toString()),r=n.length>1?n:0,s=r&&c(r).map((e,n)=>t?n?$(e):h(e):$(e));let i=[];return i=r?s.flat(1):t?e:$(e),this.segments=c(i),this}normalize(){const{segments:t}=this;return this.segments=v(t),this}optimize(){const{segments:t}=this;return this.segments=O(t,this.round),this}transform(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some(e=>e in t))return this;const e={};Object.keys(t).forEach(n=>{e[n]=Array.isArray(t[n])?[...t[n]]:Number(t[n])});const{segments:n}=this,{origin:r}=e;if(r&&r.length>=2){const[t,n,s]=r.map(Number),[i,a,o]=this.origin;e.origin=[Number.isNaN(t)?i:t,Number.isNaN(n)?a:n,s||o]}else e.origin={...this.origin};return this.segments=K(n,e),this}flipX(){return this.transform({rotate:[180,0,0]}),this}flipY(){return this.transform({rotate:[0,180,0]}),this}toString(){return z(this.segments,this.round)}}function nt(t){let e=0,n=0,r=0;return L(t).map(t=>{switch(t[0]){case"M":return[,e,n]=t,0;default:return r=function(t,e,n,r,s,i,a,o){return 3*((o-e)*(n+s)-(a-t)*(r+i)+r*(t-s)-n*(e-i)+o*(s+t/3)-a*(i+e/3))/20}(e,n,...t.slice(1)),[e,n]=t.slice(-2),r}}).reduce((t,e)=>t+e,0)}function rt(t,e,n,r,s,i,a,o,m,c){const u=C(t,e,n,r,s,i,a,o,m),l="number"==typeof c;let[h,f]=[t,e];let y=0,x=[],g=[],p=0;if(l&&c<.001)return{x:h,y:f};for(let t=0,e=u.length;t<e;t+=6){if(x=u.slice(t,t+6),g=[h,f,...x],p=_(...g),l&&y+p>=c)return _(...g,c-y);y+=p,[h,f]=x.slice(-2)}return l&&c>=y?{x:o,y:m}:y}function st(t,e,n,r,s,i,a){const o=1-a;return{x:o**2*t+2*o*a*n+a**2*s,y:o**2*e+2*o*a*r+a**2*i}}function it(t,e,n,r,s,i,a){const o="number"==typeof a;let m=t,c=e,u=0,l=[t,e,u],h=[t,e],f=0;if(o&&a<.001)return{x:m,y:c};for(let y=0;y<=100;y+=1){if(f=y/100,({x:m,y:c}=st(t,e,n,r,s,i,f)),u+=P(h,[m,c]),h=[m,c],o&&u>=a){const t=(u-a)/(u-l[2]);return{x:h[0]*(1-t)+l[0]*t,y:h[1]*(1-t)+l[1]*t}}l=[m,c,u]}return o&&a>=u?{x:s,y:i}:u}function at(t,e){const n=N(v(t)),r="number"==typeof e;let s,i=0,a=!0,o=[],m="M",c=0,u=0,l=0,h=0,f=0;for(let t=0,y=n.length;t<y;t+=1){if(s=n[t],[m]=s,a="M"===m,o=a?o:[u,l,...s.slice(1)],a){if([,h,f]=s,r&&e<.001)return{x:h,y:f}}else if("L"===m){if(c=q(...o),r&&i+c>=e)return q(...o,e-i);i+=c}else if("A"===m){if(c=rt(...o),r&&i+c>=e)return rt(...o,e-i);i+=c}else if("C"===m){if(c=_(...o),r&&i+c>=e)return _(...o,e-i);i+=c}else if("Q"===m){if(c=it(...o),r&&i+c>=e)return it(...o,e-i);i+=c}else if("Z"===m){if(o=[u,l,h,f],c=q(...o),r&&i+c>=e)return q(...o,e-i);i+=c}[u,l]="Z"!==m?s.slice(-2):[h,f]}return r&&e>=i?{x:u,y:l}:i}function ot(t){return at(t)}function mt(t,e){return at(t,e)}function ct(t,e){const n=h(t),r=[];let s=[...n],i=ot(s),a=s.length-1,o=0,m=0,c=n[0];const[u,l]=c.slice(-2),f={x:u,y:l};if(a<=0||!e||!Number.isFinite(e))return{segment:c,index:0,length:m,point:f,lengthAtSegment:o};if(e>=i)return s=n.slice(0,-1),o=ot(s),m=i-o,{segment:n[a],index:a,length:m,lengthAtSegment:o};for(;a>0;)c=s[a],s=s.slice(0,-1),o=ot(s),m=i-o,i=o,r.push({segment:c,index:a,length:m,lengthAtSegment:o}),a-=1;return r.find(({lengthAtSegment:t})=>t<=e)}function ut(t,e){const n=N(h(t)),r=v(n),s=ot(n),i=t=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r};let a=8,o={x:0,y:0},m=0,c=o,u=0,l=1/0;for(let t=0;t<=s;t+=a)o=mt(r,t),m=i(o),m<l&&(c=o,u=t,l=m);a/=2;let f={x:0,y:0},y=f,x=0,g=0,p=0,d=0;for(;a>.5;)x=u-a,f=mt(r,x),p=i(f),g=u+a,y=mt(r,g),d=i(y),x>=0&&p<l?(c=f,u=x,l=p):g<=s&&d<l?(c=y,u=g,l=d):a/=2;const M=ct(n,u);return{closest:c,distance:Math.sqrt(l),segment:M}}const lt={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};const ht={CSSMatrix:U,parsePathString:h,isPathArray:l,isCurveArray:A,isAbsoluteArray:f,isRelativeArray:x,isNormalizedArray:M,isValidPath:function(t){if("string"!=typeof t)return!1;const e=new u(t);for(a(e);e.index<e.max&&!e.err.length;)m(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:y,pathToRelative:g,pathToCurve:L,pathToString:z,getDrawDirection:function(t){return nt(L(t))>=0},getPathArea:nt,getPathBBox:tt,getTotalLength:ot,getPathLength:function(t){let e=0;return L(t).forEach((t,n,r)=>{const s="M"!==t[0]?[...r[n-1].slice(-2),...t.slice(1)]:[];e+="M"===t[0]?0:_(...s)}),e},getPointAtLength:mt,getPointAtPathLength:function(t,e){return mt(t,e)},getClosestPoint:function(t,e){return ut(t,e).closest},getSegmentOfPoint:function(t,e){const n=ut(t,e),{segment:r}=n;return void 0!==r?r.segment:null},getPropertiesAtPoint:ut,getPropertiesAtLength:ct,getSegmentAtLength:function(t,e){const n=ct(t,e),{segment:r}=void 0!==n?n:{segment:null};return r},isPointInStroke:function(t,e){const{distance:n}=ut(t,e);return Math.abs(n)<.01},clonePath:c,splitPath:j,fixPath:N,roundPath:V,optimizePath:O,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?[...r[n-1].slice(-2),...e.slice(1)]:[...t[0].slice(1),...e.slice(1)]).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M",...e[0].slice(0,2)],...e.map(t=>["C",...t.slice(2)])]},reversePath:$,normalizePath:v,transformPath:K,shapeToPath:function(e,n){const r=Object.keys(lt),s=e instanceof Element;if(s&&!r.some(t=>e.tagName===t))throw TypeError(`shapeToPath: "${e}" is not SVGElement`);const i=document.createElementNS("http://www.w3.org/2000/svg","path"),a=s?e.tagName:e.type,o={};if(o.type=a,s){const t=lt[a];t.forEach(t=>{o[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:e,value:n})=>{t.includes(e)||i.setAttribute(e,n)})}else Object.assign(o,e);let m;const{round:c}=t;return"circle"===a?m=z(function(t){const{cx:e,cy:n,r:r}=t;return[["M",e-r,n],["a",r,r,0,1,0,2*r,0],["a",r,r,0,1,0,-2*r,0]]}(o),c):"ellipse"===a?m=z(function(t){const{cx:e,cy:n,rx:r,ry:s}=t;return[["M",e-r,n],["a",r,s,0,1,0,2*r,0],["a",r,s,0,1,0,-2*r,0]]}(o),c):["polyline","polygon"].includes(a)?m=z(function(t){const e=[],n=t.points.split(/[\s|,]/).map(Number);let r=0;for(;r<n.length;)e.push([r?"L":"M",n[r],n[r+1]]),r+=2;return"polygon"===t.type?[...e,["z"]]:e}(o),c):"rect"===a?m=z(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let i=+t.rx,a=+t.ry;return i||a?(i=i||a,a=a||i,2*i>r&&(i-=(2*i-r)/2),2*a>s&&(a-=(2*a-s)/2),[["M",e+i,n],["h",r-2*i],["s",i,0,i,a],["v",s-2*a],["s",0,a,-i,a],["h",2*i-r],["s",-i,0,-i,-a],["v",2*a-s],["s",0,-a,i,-a]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(o),c):"line"===a?m=z(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",e,n],["L",r,s]]}(o),c):"glyph"===a&&(m=s?e.getAttribute("d"):e.type),!!m&&(i.setAttribute("d",m),n&&s&&(e.before(i,e),e.remove()),i)},options:t};Object.assign(et,ht,{Version:"0.1.24"});export{et as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v0.1.
|
|
2
|
+
* SVGPathCommander v0.1.24 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2021 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -1065,7 +1065,7 @@
|
|
|
1065
1065
|
if (distance < margin) {
|
|
1066
1066
|
return { x: x1, y: y1 };
|
|
1067
1067
|
}
|
|
1068
|
-
if (distance > length
|
|
1068
|
+
if (distance > length) {
|
|
1069
1069
|
return { x: x2, y: y2 };
|
|
1070
1070
|
}
|
|
1071
1071
|
var ref = midPoint([x1, y1], [x2, y2], distance / length);
|
|
@@ -2693,15 +2693,16 @@
|
|
|
2693
2693
|
function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
|
|
2694
2694
|
var assign;
|
|
2695
2695
|
|
|
2696
|
-
var
|
|
2696
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
2697
2697
|
var lengthMargin = 0.001;
|
|
2698
|
+
var x = x1; var y = y1;
|
|
2698
2699
|
var totalLength = 0;
|
|
2699
2700
|
var prev = [x1, y1, totalLength];
|
|
2700
2701
|
/** @type {[number, number]} */
|
|
2701
2702
|
var cur = [x1, y1];
|
|
2702
2703
|
var t = 0;
|
|
2703
2704
|
|
|
2704
|
-
if (
|
|
2705
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
2705
2706
|
return { x: x, y: y };
|
|
2706
2707
|
}
|
|
2707
2708
|
|
|
@@ -2713,7 +2714,7 @@
|
|
|
2713
2714
|
totalLength += distanceSquareRoot(cur, [x, y]);
|
|
2714
2715
|
cur = [x, y];
|
|
2715
2716
|
|
|
2716
|
-
if (
|
|
2717
|
+
if (distanceIsNumber && totalLength >= distance) {
|
|
2717
2718
|
var dv = (totalLength - distance) / (totalLength - prev[2]);
|
|
2718
2719
|
|
|
2719
2720
|
return {
|
|
@@ -2724,7 +2725,7 @@
|
|
|
2724
2725
|
prev = [x, y, totalLength];
|
|
2725
2726
|
}
|
|
2726
2727
|
|
|
2727
|
-
if (
|
|
2728
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
2728
2729
|
return { x: x2, y: y2 };
|
|
2729
2730
|
}
|
|
2730
2731
|
return totalLength;
|
|
@@ -3177,17 +3178,18 @@
|
|
|
3177
3178
|
function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
|
|
3178
3179
|
var assign;
|
|
3179
3180
|
|
|
3181
|
+
var cubicSeg = arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2);
|
|
3182
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
3180
3183
|
var ref = [X1, Y1];
|
|
3181
3184
|
var x = ref[0];
|
|
3182
3185
|
var y = ref[1];
|
|
3183
|
-
var cubicSeg = arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2);
|
|
3184
3186
|
var lengthMargin = 0.001;
|
|
3185
3187
|
var totalLength = 0;
|
|
3186
3188
|
var cubicSubseg = [];
|
|
3187
3189
|
var argsc = [];
|
|
3188
3190
|
var segLen = 0;
|
|
3189
3191
|
|
|
3190
|
-
if (
|
|
3192
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
3191
3193
|
return { x: x, y: y };
|
|
3192
3194
|
}
|
|
3193
3195
|
|
|
@@ -3196,7 +3198,7 @@
|
|
|
3196
3198
|
argsc = [x, y ].concat( cubicSubseg);
|
|
3197
3199
|
// @ts-ignore
|
|
3198
3200
|
segLen = segmentCubicFactory.apply(void 0, argsc);
|
|
3199
|
-
if (
|
|
3201
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3200
3202
|
// @ts-ignore -- this is a `cubicSegment`
|
|
3201
3203
|
return segmentCubicFactory.apply(void 0, argsc.concat( [distance - totalLength] ));
|
|
3202
3204
|
}
|
|
@@ -3204,7 +3206,7 @@
|
|
|
3204
3206
|
(assign = cubicSubseg.slice(-2), x = assign[0], y = assign[1]);
|
|
3205
3207
|
}
|
|
3206
3208
|
|
|
3207
|
-
if (
|
|
3209
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
3208
3210
|
return { x: X2, y: Y2 };
|
|
3209
3211
|
}
|
|
3210
3212
|
|
|
@@ -3254,15 +3256,16 @@
|
|
|
3254
3256
|
function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
3255
3257
|
var assign;
|
|
3256
3258
|
|
|
3257
|
-
var
|
|
3259
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
3258
3260
|
var lengthMargin = 0.001;
|
|
3261
|
+
var x = x1; var y = y1;
|
|
3259
3262
|
var totalLength = 0;
|
|
3260
3263
|
var prev = [x1, y1, totalLength];
|
|
3261
3264
|
/** @type {[number, number]} */
|
|
3262
3265
|
var cur = [x1, y1];
|
|
3263
3266
|
var t = 0;
|
|
3264
3267
|
|
|
3265
|
-
if (
|
|
3268
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
3266
3269
|
return { x: x, y: y };
|
|
3267
3270
|
}
|
|
3268
3271
|
|
|
@@ -3274,7 +3277,7 @@
|
|
|
3274
3277
|
totalLength += distanceSquareRoot(cur, [x, y]);
|
|
3275
3278
|
cur = [x, y];
|
|
3276
3279
|
|
|
3277
|
-
if (
|
|
3280
|
+
if (distanceIsNumber && totalLength >= distance) {
|
|
3278
3281
|
var dv = (totalLength - distance) / (totalLength - prev[2]);
|
|
3279
3282
|
|
|
3280
3283
|
return {
|
|
@@ -3284,7 +3287,7 @@
|
|
|
3284
3287
|
}
|
|
3285
3288
|
prev = [x, y, totalLength];
|
|
3286
3289
|
}
|
|
3287
|
-
if (
|
|
3290
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
3288
3291
|
return { x: x2, y: y2 };
|
|
3289
3292
|
}
|
|
3290
3293
|
return totalLength;
|
|
@@ -3300,6 +3303,8 @@
|
|
|
3300
3303
|
function pathLengthFactory(pathInput, distance) {
|
|
3301
3304
|
var assign, assign$1, assign$2;
|
|
3302
3305
|
|
|
3306
|
+
var path = fixPath(normalizePath(pathInput));
|
|
3307
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
3303
3308
|
var totalLength = 0;
|
|
3304
3309
|
var isM = true;
|
|
3305
3310
|
/** @type {number[]} */
|
|
@@ -3311,7 +3316,6 @@
|
|
|
3311
3316
|
var mx = 0;
|
|
3312
3317
|
var my = 0;
|
|
3313
3318
|
var seg;
|
|
3314
|
-
var path = fixPath(normalizePath(pathInput));
|
|
3315
3319
|
|
|
3316
3320
|
for (var i = 0, ll = path.length; i < ll; i += 1) {
|
|
3317
3321
|
seg = path[i];
|
|
@@ -3325,13 +3329,13 @@
|
|
|
3325
3329
|
// remember mx, my for Z
|
|
3326
3330
|
// @ts-ignore
|
|
3327
3331
|
(assign$1 = seg, mx = assign$1[1], my = assign$1[2]);
|
|
3328
|
-
if (
|
|
3332
|
+
if (distanceIsNumber && distance < 0.001) {
|
|
3329
3333
|
return { x: mx, y: my };
|
|
3330
3334
|
}
|
|
3331
3335
|
} else if (pathCommand === 'L') {
|
|
3332
3336
|
// @ts-ignore
|
|
3333
3337
|
segLen = segmentLineFactory.apply(void 0, data);
|
|
3334
|
-
if (
|
|
3338
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3335
3339
|
// @ts-ignore
|
|
3336
3340
|
return segmentLineFactory.apply(void 0, data.concat( [distance - totalLength] ));
|
|
3337
3341
|
}
|
|
@@ -3339,7 +3343,7 @@
|
|
|
3339
3343
|
} else if (pathCommand === 'A') {
|
|
3340
3344
|
// @ts-ignore
|
|
3341
3345
|
segLen = segmentArcFactory.apply(void 0, data);
|
|
3342
|
-
if (
|
|
3346
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3343
3347
|
// @ts-ignore
|
|
3344
3348
|
return segmentArcFactory.apply(void 0, data.concat( [distance - totalLength] ));
|
|
3345
3349
|
}
|
|
@@ -3347,7 +3351,7 @@
|
|
|
3347
3351
|
} else if (pathCommand === 'C') {
|
|
3348
3352
|
// @ts-ignore
|
|
3349
3353
|
segLen = segmentCubicFactory.apply(void 0, data);
|
|
3350
|
-
if (
|
|
3354
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3351
3355
|
// @ts-ignore
|
|
3352
3356
|
return segmentCubicFactory.apply(void 0, data.concat( [distance - totalLength] ));
|
|
3353
3357
|
}
|
|
@@ -3355,7 +3359,7 @@
|
|
|
3355
3359
|
} else if (pathCommand === 'Q') {
|
|
3356
3360
|
// @ts-ignore
|
|
3357
3361
|
segLen = segmentQuadFactory.apply(void 0, data);
|
|
3358
|
-
if (
|
|
3362
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3359
3363
|
// @ts-ignore
|
|
3360
3364
|
return segmentQuadFactory.apply(void 0, data.concat( [distance - totalLength] ));
|
|
3361
3365
|
}
|
|
@@ -3364,7 +3368,7 @@
|
|
|
3364
3368
|
data = [x, y, mx, my];
|
|
3365
3369
|
// @ts-ignore
|
|
3366
3370
|
segLen = segmentLineFactory.apply(void 0, data);
|
|
3367
|
-
if (
|
|
3371
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
3368
3372
|
// @ts-ignore
|
|
3369
3373
|
return segmentLineFactory.apply(void 0, data.concat( [distance - totalLength] ));
|
|
3370
3374
|
}
|
|
@@ -3377,7 +3381,7 @@
|
|
|
3377
3381
|
|
|
3378
3382
|
// native `getPointAtLength` behavior when the given distance
|
|
3379
3383
|
// is higher than total length
|
|
3380
|
-
if (
|
|
3384
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
3381
3385
|
return { x: x, y: y };
|
|
3382
3386
|
}
|
|
3383
3387
|
|
|
@@ -3436,7 +3440,8 @@
|
|
|
3436
3440
|
}
|
|
3437
3441
|
|
|
3438
3442
|
/**
|
|
3439
|
-
* Returns the
|
|
3443
|
+
* Returns the segment, its index and length as well as
|
|
3444
|
+
* the length to that segment at a given length in a path.
|
|
3440
3445
|
*
|
|
3441
3446
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
3442
3447
|
* @param {number=} distance the given length
|
|
@@ -3502,7 +3507,8 @@
|
|
|
3502
3507
|
}
|
|
3503
3508
|
|
|
3504
3509
|
/**
|
|
3505
|
-
* Returns the point in path closest to a given point
|
|
3510
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
3511
|
+
* the distance to the path stroke.
|
|
3506
3512
|
* @see https://bl.ocks.org/mbostock/8027637
|
|
3507
3513
|
*
|
|
3508
3514
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
@@ -3566,7 +3572,7 @@
|
|
|
3566
3572
|
}
|
|
3567
3573
|
}
|
|
3568
3574
|
|
|
3569
|
-
var segment = getPropertiesAtLength(path,
|
|
3575
|
+
var segment = getPropertiesAtLength(path, bestLength);
|
|
3570
3576
|
var distance = Math.sqrt(bestDistance);
|
|
3571
3577
|
|
|
3572
3578
|
return { closest: closest, distance: distance, segment: segment };
|
|
@@ -3898,7 +3904,7 @@
|
|
|
3898
3904
|
options: defaultOptions,
|
|
3899
3905
|
};
|
|
3900
3906
|
|
|
3901
|
-
var version = "0.1.
|
|
3907
|
+
var version = "0.1.24";
|
|
3902
3908
|
|
|
3903
3909
|
// @ts-ignore
|
|
3904
3910
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// SVGPathCommander v0.1.
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SVGPathCommander=e()}(this,(function(){"use strict";var t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function r(t){var r=t.pathValue[t.segmentStart],n=r.toLowerCase(),a=t.data;for("m"===n&&a.length>2&&(t.segments.push([r,a[0],a[1]]),a=a.slice(2),n="l",r="m"===r?"l":"L");a.length>=e[n]&&(t.segments.push([r].concat(a.splice(0,e[n]))),e[n]););}function n(t){var e=t.index,r=t.pathValue.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='Invalid path value: invalid Arc flag "'+r+'", expecting 0 or 1 at index '+e)}function a(t){return t>=48&&t<=57}function i(t){var e,r=t.max,n=t.pathValue,i=t.index,o=i,s=!1,u=!1,c=!1,m=!1;if(o>=r)t.err="Invalid path value at "+o+": missing param "+n[o];else if(43!==(e=n.charCodeAt(o))&&45!==e||(e=(o+=1)<r?n.charCodeAt(o):0),a(e)||46===e){if(46!==e){if(s=48===e,e=(o+=1)<r?n.charCodeAt(o):0,s&&o<r&&e&&a(e))return void(t.err="Invalid path value at index "+i+": "+n[i]+" illegal number");for(;o<r&&a(n.charCodeAt(o));)o+=1,u=!0;e=o<r?n.charCodeAt(o):0}if(46===e){for(m=!0,o+=1;a(n.charCodeAt(o));)o+=1,c=!0;e=o<r?n.charCodeAt(o):0}if(101===e||69===e){if(m&&!u&&!c)return void(t.err="Invalid path value at index "+o+": "+n[o]+" invalid float exponent");if(43!==(e=(o+=1)<r?n.charCodeAt(o):0)&&45!==e||(o+=1),!(o<r&&a(n.charCodeAt(o))))return void(t.err="Invalid path value at index "+o+": "+n[o]+" invalid float exponent");for(;o<r&&a(n.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="Invalid path value at index "+o+": "+n[o]+" is not a number"}function o(t){for(var e,r=t.pathValue,n=t.max;t.index<n&&(10===(e=r.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0);)t.index+=1}function s(t){return t>=48&&t<=57||43===t||45===t||46===t}function u(t){var a=t.max,u=t.pathValue,c=t.index,m=u.charCodeAt(c),f=e[u[c].toLowerCase()];if(t.segmentStart=c,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(m))if(t.index+=1,o(t),t.data=[],f){for(;;){for(var h=f;h>0;h-=1){if(97!=(32|m)||3!==h&&4!==h?i(t):n(t),t.err.length)return;t.data.push(t.param),o(t),t.index<a&&44===u.charCodeAt(t.index)&&(t.index+=1,o(t))}if(t.index>=t.max)break;if(!s(u.charCodeAt(t.index)))break}r(t)}else r(t);else t.err="Invalid path value: "+u[c]+" not a path command"}function c(t){return t.map((function(t){return Array.isArray(t)?[].concat(t):t}))}function m(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function f(t){return Array.isArray(t)&&t.every((function(t){var r=t[0].toLowerCase();return e[r]===t.length-1&&"achlmqstvz".includes(r)}))}function h(t){if(f(t))return c(t);var e=new m(t);for(o(e);e.index<e.max&&!e.err.length;)u(e);return e.err.length?e.segments=[]:e.segments.length&&("mM".includes(e.segments[0][0])?e.segments[0][0]="M":(e.err="Invalid path value: missing M/m",e.segments=[])),e.segments}function l(t){return f(t)&&t.every((function(t){return t[0]===t[0].toUpperCase()}))}function p(t){if(l(t))return c(t);var e=h(t),r=0,n=0,a=0,i=0;return e.map((function(t){var e,o=t.slice(1).map(Number),s=t[0],u=s.toUpperCase();if("M"===s)return r=(e=o)[0],n=e[1],a=r,i=n,["M",r,n];var c=[];if(s!==u)switch(u){case"A":c=[u,o[0],o[1],o[2],o[3],o[4],o[5]+r,o[6]+n];break;case"V":c=[u,o[0]+n];break;case"H":c=[u,o[0]+r];break;default:var m=o.map((function(t,e){return t+(e%2?n:r)}));c=[u].concat(m)}else c=[u].concat(o);var f=c.length;switch(u){case"Z":r=a,n=i;break;case"H":r=c[1];break;case"V":n=c[1];break;default:r=c[f-2],n=c[f-1],"M"===u&&(a=r,i=n)}return c}))}function y(t){return f(t)&&t.slice(1).every((function(t){return t[0]===t[0].toLowerCase()}))}function v(t){if(y(t))return c(t);var e=h(t),r=0,n=0,a=0,i=0;return e.map((function(t){var e,o,s=t.slice(1).map(Number),u=t[0],c=u.toLowerCase();if("M"===u)return r=(e=s)[0],n=e[1],a=r,i=n,["M",r,n];var m=[];if(u!==c)switch(c){case"a":m=[c,s[0],s[1],s[2],s[3],s[4],s[5]-r,s[6]-n];break;case"v":m=[c,s[0]-n];break;case"h":m=[c,s[0]-r];break;default:var f=s.map((function(t,e){return t-(e%2?n:r)}));m=[c].concat(f),"m"===c&&(r=(o=s)[0],n=o[1],a=r,i=n)}else"m"===u&&(a=s[0]+r,i=s[1]+n),m=[c].concat(s);var h=m.length;switch(c){case"z":r=a,n=i;break;case"h":r+=m[1];break;case"v":n+=m[1];break;default:r+=m[h-2],n+=m[h-1]}return m}))}function x(t,e,r){if(t[r].length>7){t[r].shift();for(var n=t[r],a=r;n.length;)e[r]="A",t.splice(a+=1,0,["C"].concat(n.splice(0,6)));t.splice(r,1)}}function d(t,e,r){var n=t[0],a=e.x1,i=e.y1,o=e.x2,s=e.y2,u=t.slice(1).map(Number),c=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)c=["L",t[1],i];else if("V"===n)c=["L",a,t[1]];else if("S"===n){var m=function(t,e,r,n,a){return"CS".includes(a)?{x1:2*t-r,y1:2*e-n}:{x1:t,y1:e}}(a,i,o,s,r),f=m.x1,h=m.y1;e.x1=f,e.y1=h,c=["C",f,h].concat(u)}else if("T"===n){var l=function(t,e,r,n,a){return"QT".includes(a)?{qx:2*t-r,qy:2*e-n}:{qx:t,qy:e}}(a,i,e.qx,e.qy,r),p=l.qx,y=l.qy;e.qx=p,e.qy=y,c=["Q",p,y].concat(u)}else if("Q"===n){var v=u[0],x=u[1];e.qx=v,e.qy=x}return c}function g(t){return l(t)&&t.every((function(t){return"ACLMQZ".includes(t[0])}))}var M={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function b(t){if(g(t))return c(t);for(var e=p(t),r=Object.assign({},M),n=[],a=e.length,i="",o="",s=0;s<a;s+=1){i=e[s][0],n[s]=i,s&&(o=n[s-1]),e[s]=d(e[s],r,o);var u=e[s],m=u.length;r.x1=+u[m-2],r.y1=+u[m-1],r.x2=+u[m-4]||r.x1,r.y2=+u[m-3]||r.y1}return e}function w(t){var e=h(t),r=b(e),n=e.length,a="Z"===r.slice(-1)[0][0],i=a?n-2:n-1,o=r[0].slice(1),s=o[0],u=o[1],c=r[i].slice(-2),m=c[0],f=c[1];return a&&s===m&&u===f?e.slice(0,-1):e}function N(t){return f(t)&&t.every((function(t){return"MC".includes(t[0])}))}function A(t,e,r){return{x:t*Math.cos(r)-e*Math.sin(r),y:t*Math.sin(r)+e*Math.cos(r)}}function C(t,e,r,n,a,i,o,s,u,c){var m,f,h,l,p,y,v=t,x=e,d=r,g=n,M=s,b=u,w=120*Math.PI/180,N=Math.PI/180*(+a||0),S=[];if(c)h=(m=c)[0],l=m[1],p=m[2],y=m[3];else{v=(f=A(v,x,-N)).x,x=f.y;var k=(v-(M=(f=A(M,b,-N)).x))/2,P=(x-(b=f.y))/2,q=k*k/(d*d)+P*P/(g*g);q>1&&(d*=q=Math.sqrt(q),g*=q);var I=d*d,T=g*g,j=(i===o?-1:1)*Math.sqrt(Math.abs((I*T-I*P*P-T*k*k)/(I*P*P+T*k*k)));p=j*d*P/g+(v+M)/2,y=j*-g*k/d+(x+b)/2,h=(Math.asin((x-y)/g)*Math.pow(10,9)>>0)/Math.pow(10,9),l=(Math.asin((b-y)/g)*Math.pow(10,9)>>0)/Math.pow(10,9),h=v<p?Math.PI-h:h,l=M<p?Math.PI-l:l,h<0&&(h=2*Math.PI+h),l<0&&(l=2*Math.PI+l),o&&h>l&&(h-=2*Math.PI),!o&&l>h&&(l-=2*Math.PI)}var L=l-h;if(Math.abs(L)>w){var V=l,O=M,z=b;l=h+w*(o&&l>h?1:-1),S=C(M=p+d*Math.cos(l),b=y+g*Math.sin(l),d,g,a,0,o,O,z,[l,V,p,y])}L=l-h;var E=Math.cos(h),Z=Math.sin(h),Q=Math.cos(l),D=Math.sin(l),X=Math.tan(L/4),H=4/3*d*X,Y=4/3*g*X,F=[v,x],R=[v+H*Z,x-Y*E],B=[M+H*D,b-Y*Q],G=[M,b];if(R[0]=2*F[0]-R[0],R[1]=2*F[1]-R[1],c)return R.concat(B,G,S);for(var J=[],U=0,$=(S=R.concat(B,G,S)).length;U<$;U+=1)J[U]=U%2?A(S[U-1],S[U],N).y:A(S[U],S[U+1],N).x;return J}function S(t,e,r,n,a,i){return[1/3*t+2/3*r,1/3*e+2/3*n,1/3*a+2/3*r,1/3*i+2/3*n,a,i]}function k(t,e,r){var n=t[0],a=t[1];return[n+(e[0]-n)*r,a+(e[1]-a)*r]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function q(t,e,r,n,a){var i=P([t,e],[r,n]);if("number"==typeof a){if(a<.001)return{x:t,y:e};if(a>i+.001)return{x:r,y:n};var o=k([t,e],[r,n],a/i);return{x:o[0],y:o[1]}}return i}function I(t,e,r,n){var a=.5,i=[t,e],o=[r,n],s=k(i,o,a),u=k(o,s,a),c=k(s,u,a),m=k(u,c,a),f=k(c,m,a),h=i.concat(s,c,f,[a]),l=q.apply(void 0,h),p=f.concat(m,u,o,[0]),y=q.apply(void 0,p);return[l.x,l.y,y.x,y.y,r,n]}function T(t,e){var r,n=t[0],a=t.slice(1).map((function(t){return+t})),i=a[0],o=a[1],s=e.x1,u=e.y1,c=e.x,m=e.y;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=i,e.y=o,t;case"A":return r=[s,u].concat(a),["C"].concat(C.apply(void 0,r));case"Q":return e.qx=i,e.qy=o,r=[s,u].concat(a),["C"].concat(S.apply(void 0,r));case"L":return["C"].concat(I(s,u,i,o));case"Z":return["C"].concat(I(s,u,c,m))}return t}function j(t){if(N(t))return c(t);for(var e=w(b(t)),r=Object.assign({},M),n=[],a="",i=e.length,o=0;o<i;o+=1){a=e[o][0],n[o]=a,e[o]=T(e[o],r),x(e,n,o),i=e.length;var s=e[o],u=s.length;r.x1=+s[u-2],r.y1=+s[u-1],r.x2=+s[u-4]||r.x1,r.y2=+s[u-3]||r.y1}return e}function L(e,r){var n=t.round;if(!1===r||!1===n)return c(e);var a=(n=r>=1?r:n)>=1?Math.pow(10,n):1;return e.map((function(t){var e=t.slice(1).map(Number).map((function(t){return t%1==0?t:Math.round(t*a)/a}));return[t[0]].concat(e)}))}function V(t,e){return L(t,e).map((function(t){return t[0]+t.slice(1).join(" ")})).join("")}function O(t){var e=p(t),r="Z"===e.slice(-1)[0][0],n=b(e).map((function(t,r){var n=t.slice(-2).map(Number),a=n[0],i=n[1];return{seg:e[r],n:t,c:e[r][0],x:a,y:i}})).map((function(t,e,n){var a=t.seg,i=t.n,o=e&&n[e-1],s=n[e+1]&&n[e+1],u=t.c,c=n.length,m=e?n[e-1].x:n[c-1].x,f=e?n[e-1].y:n[c-1].y,h=[];switch(u){case"M":h=r?["Z"]:[u,m,f];break;case"A":h=[u].concat(a.slice(1,-3),[1===a[5]?0:1],[m],[f]);break;case"C":h=s&&"S"===s.c?["S",a[1],a[2],m,f]:[u,a[3],a[4],a[1],a[2],m,f];break;case"S":h=o&&"CS".includes(o.c)&&(!s||s&&"S"!==s.c)?["C",i[3],i[4],i[1],i[2],m,f]:[u,i[1],i[2],m,f];break;case"Q":h=s&&"T"===s.c?["T",m,f]:[u].concat(a.slice(1,-2),[m],[f]);break;case"T":h=o&&"QT".includes(o.c)&&(!s||s&&"T"!==s.c)?["Q",i[1],i[2],m,f]:[u,m,f];break;case"Z":h=["M",m,f];break;case"H":h=[u,m];break;case"V":h=[u,f];break;default:h=[u].concat(a.slice(1,-2),[m],[f])}return h}));return r?n.reverse():[n[0]].concat(n.slice(1).reverse())}function z(t){return V(p(t),0).replace(/(m|M)/g,"|$1").split("|").map((function(t){return t.trim()})).filter((function(t){return t}))}function E(t,e,r,n){var a=t[0],i=function(t){return Math.round(t*Math.pow(10,4))/Math.pow(10,4)},o=t.slice(1).map((function(t){return+t})),s=e.slice(1).map((function(t){return+t})),u=r.x1,c=r.y1,m=r.x2,f=r.y2,h=r.x,l=r.y,p=t,y=s.slice(-2),v=y[0],x=y[1];if("TQ".includes(a)||(r.qx=null,r.qy=null),["V","H","S","T","Z"].includes(a))p=[a].concat(o);else if("L"===a)i(h)===i(v)?p=["V",x]:i(l)===i(x)&&(p=["H",v]);else if("C"===a){var d=s[0],g=s[1];"CS".includes(n)&&i(d)===i(2*u-m)&&i(g)===i(2*c-f)&&(p=["S"].concat(s.slice(-4))),r.x1=d,r.y1=g}else if("Q"===a){var M=s[0],b=s[1];r.qx=M,r.qy=b,"QT".includes(n)&&i(M)===i(2*u-m)&&i(b)===i(2*c-f)&&(p=["T"].concat(s.slice(-2)))}return p}function Z(t,e){for(var r,n=p(t),a=b(n),i=Object.assign({},M),o=[],s=n.length,u="",c="",m=0,f=0,h=0,l=0,y=0;y<s;y+=1){u=n[y][0],o[y]=u,y&&(c=o[y-1]),n[y]=E(n[y],a[y],i,c);var x=n[y],d=x.length;switch(i.x1=+x[d-2],i.y1=+x[d-1],i.x2=+x[d-4]||i.x1,i.y2=+x[d-3]||i.y1,u){case"Z":m=h,f=l;break;case"H":m=x[1];break;case"V":f=x[1];break;default:m=(r=x.slice(-2).map(Number))[0],f=r[1],"M"===u&&(h=m,l=f)}i.x=m,i.y=f}var g=L(n,e),w=L(v(n),e);return g.map((function(t,e){return e?t.join("").length<w[e].join("").length?t:w[e]:t}))}function Q(t){var e=new U,r=Array.from(t);if(!r.every((function(t){return!Number.isNaN(t)})))throw TypeError('CSSMatrix: "'+t+'" must only have numbers.');if(16===r.length){var n=r[0],a=r[1],i=r[2],o=r[3],s=r[4],u=r[5],c=r[6],m=r[7],f=r[8],h=r[9],l=r[10],p=r[11],y=r[12],v=r[13],x=r[14],d=r[15];e.m11=n,e.a=n,e.m21=s,e.c=s,e.m31=f,e.m41=y,e.e=y,e.m12=a,e.b=a,e.m22=u,e.d=u,e.m32=h,e.m42=v,e.f=v,e.m13=i,e.m23=c,e.m33=l,e.m43=x,e.m14=o,e.m24=m,e.m34=p,e.m44=d}else{if(6!==r.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");var g=r[0],M=r[1],b=r[2],w=r[3],N=r[4],A=r[5];e.m11=g,e.a=g,e.m12=M,e.b=M,e.m21=b,e.c=b,e.m22=w,e.d=w,e.m41=N,e.e=N,e.m42=A,e.f=A}return e}function D(t){var e=Object.keys(new U);if("object"==typeof t&&e.every((function(e){return e in t})))return Q([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError('CSSMatrix: "'+t+'" is not a DOMMatrix / CSSMatrix / JSON compatible object.')}function X(t){if("string"!=typeof t)throw TypeError('CSSMatrix: "'+t+'" is not a string.');var e=String(t).replace(/\s/g,""),r=new U,n='CSSMatrix: invalid transform string "'+t+'"';return e.split(")").filter((function(t){return t})).forEach((function(t){var e=t.split("("),a=e[0],i=e[1];if(!i)throw TypeError(n);var o=i.split(",").map((function(t){return t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)})),s=o[0],u=o[1],c=o[2],m=o[3],f=[s,u,c],h=[s,u,c,m];if("perspective"===a&&s&&[u,c].every((function(t){return void 0===t})))r.m34=-1/s;else if(a.includes("matrix")&&[6,16].includes(o.length)&&o.every((function(t){return!Number.isNaN(+t)}))){var l=o.map((function(t){return Math.abs(t)<1e-6?0:t}));r=r.multiply(Q(l))}else if("translate3d"===a&&f.every((function(t){return!Number.isNaN(+t)})))r=r.translate(s,u,c);else if("translate"===a&&s&&void 0===c)r=r.translate(s,u||0,0);else if("rotate3d"===a&&h.every((function(t){return!Number.isNaN(+t)}))&&m)r=r.rotateAxisAngle(s,u,c,m);else if("rotate"===a&&s&&[u,c].every((function(t){return void 0===t})))r=r.rotate(0,0,s);else if("scale3d"===a&&f.every((function(t){return!Number.isNaN(+t)}))&&f.some((function(t){return 1!==t})))r=r.scale(s,u,c);else if("scale"!==a||Number.isNaN(s)||1===s||void 0!==c)if("skew"===a&&s&&void 0===c)r=r.skewX(s),r=u?r.skewY(u):r;else{if(!(/[XYZ]/.test(a)&&s&&[u,c].every((function(t){return void 0===t}))&&["translate","rotate","scale","skew"].some((function(t){return a.includes(t)}))))throw TypeError(n);if(["skewX","skewY"].includes(a))r=r[a](s);else{var p=a.replace(/[XYZ]/,""),y=a.replace(p,""),v=["X","Y","Z"].indexOf(y),x=[0===v?s:0,1===v?s:0,2===v?s:0];r=r[p].apply(r,x)}}else{var d=Number.isNaN(+u)?s:u;r=r.scale(s,d,1)}})),r}function H(t,e,r){var n=new U;return n.m41=t,n.e=t,n.m42=e,n.f=e,n.m43=r,n}function Y(t,e,r){var n=new U,a=Math.PI/180,i=t*a,o=e*a,s=r*a,u=Math.cos(i),c=-Math.sin(i),m=Math.cos(o),f=-Math.sin(o),h=Math.cos(s),l=-Math.sin(s),p=m*h,y=-m*l;n.m11=p,n.a=p,n.m12=y,n.b=y,n.m13=f;var v=c*f*h+u*l;n.m21=v,n.c=v;var x=u*h-c*f*l;return n.m22=x,n.d=x,n.m23=-c*m,n.m31=c*l-u*f*h,n.m32=c*h+u*f*l,n.m33=u*m,n}function F(t,e,r,n){var a=new U,i=n*(Math.PI/360),o=Math.sin(i),s=Math.cos(i),u=o*o,c=Math.sqrt(t*t+e*e+r*r),m=t,f=e,h=r;0===c?(m=0,f=0,h=1):(m/=c,f/=c,h/=c);var l=m*m,p=f*f,y=h*h,v=1-2*(p+y)*u;a.m11=v,a.a=v;var x=2*(m*f*u+h*o*s);a.m12=x,a.b=x,a.m13=2*(m*h*u-f*o*s);var d=2*(f*m*u-h*o*s);a.m21=d,a.c=d;var g=1-2*(y+l)*u;return a.m22=g,a.d=g,a.m23=2*(f*h*u+m*o*s),a.m31=2*(h*m*u+f*o*s),a.m32=2*(h*f*u-m*o*s),a.m33=1-2*(l+p)*u,a}function R(t,e,r){var n=new U;return n.m11=t,n.a=t,n.m22=e,n.d=e,n.m33=r,n}function B(t){var e=new U,r=t*Math.PI/180,n=Math.tan(r);return e.m21=n,e.c=n,e}function G(t){var e=new U,r=t*Math.PI/180,n=Math.tan(r);return e.m12=n,e.b=n,e}function J(t,e){return Q([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}var U=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this;if(r.a=1,r.b=0,r.c=0,r.d=1,r.e=0,r.f=0,r.m11=1,r.m12=0,r.m13=0,r.m14=0,r.m21=0,r.m22=1,r.m23=0,r.m24=0,r.m31=0,r.m32=0,r.m33=1,r.m34=0,r.m41=0,r.m42=0,r.m43=0,r.m44=1,t&&t.length){var n=[16,6].some((function(e){return e===t.length}))?t:t[0];return r.setMatrixValue(n)}return r},$={isIdentity:{configurable:!0},is2D:{configurable:!0}};$.isIdentity.set=function(t){this.isIdentity=t},$.isIdentity.get=function(){var t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44},$.is2D.get=function(){var t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44},$.is2D.set=function(t){this.is2D=t},U.prototype.setMatrixValue=function(t){return[Array,Float64Array,Float32Array].some((function(e){return t instanceof e}))?Q(t):"string"==typeof t&&t.length&&"none"!==t?X(t):"object"==typeof t?D(t):this},U.prototype.toArray=function(){var t=this,e=Math.pow(10,6);return(t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]).map((function(t){return Math.abs(t)<1e-6?0:(t*e>>0)/e}))},U.prototype.toString=function(){var t=this.toArray();return(this.is2D?"matrix":"matrix3d")+"("+t+")"},U.prototype.toJSON=function(){var t=this,e=t.is2D,r=t.isIdentity;return Object.assign({},t,{is2D:e,isIdentity:r})},U.prototype.multiply=function(t){return J(this,t)},U.prototype.translate=function(t,e,r){var n=e,a=r;return void 0===a&&(a=0),void 0===n&&(n=0),J(this,H(t,n,a))},U.prototype.scale=function(t,e,r){var n=e,a=r;return void 0===n&&(n=t),void 0===a&&(a=1),J(this,R(t,n,a))},U.prototype.rotate=function(t,e,r){var n=t,a=e,i=r;return void 0===a&&(a=0),void 0===i&&(i=n,n=0),J(this,Y(n,a,i))},U.prototype.rotateAxisAngle=function(t,e,r,n){if([t,e,r,n].some((function(t){return Number.isNaN(t)})))throw new TypeError("CSSMatrix: expecting 4 values");return J(this,F(t,e,r,n))},U.prototype.skewX=function(t){return J(this,B(t))},U.prototype.skewY=function(t){return J(this,G(t))},U.prototype.transformPoint=function(t){var e=H(t.x,t.y,t.z);return e.m44=t.w||1,{x:(e=this.multiply(e)).m41,y:e.m42,z:e.m43,w:e.m44}},U.prototype.transform=function(t){var e=this,r=e.m11*t.x+e.m12*t.y+e.m13*t.z+e.m14*t.w,n=e.m21*t.x+e.m22*t.y+e.m23*t.z+e.m24*t.w,a=e.m31*t.x+e.m32*t.y+e.m33*t.z+e.m34*t.w,i=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:r/i,y:n/i,z:a/i,w:i}},Object.defineProperties(U.prototype,$),Object.assign(U,{Translate:H,Rotate:Y,RotateAxisAngle:F,Scale:R,SkewX:B,SkewY:G,Multiply:J,fromArray:Q,fromMatrix:D,fromString:X});function K(t,e,r){var n=e[0],a=e[1],i=r[0],o=r[1],s=r[2],u=t.transformPoint({x:n,y:a,z:0,w:1}),c=u.x-i,m=u.y-o,f=u.z-s;return[c*(Math.abs(s)/Math.abs(f))+i,m*(Math.abs(s)/Math.abs(f))+o]}function W(t,e){var r,n,a,i,o,s,u,m=0,f=0,h=p(t),l=b(h),y=function(t){var e=new U,r=t.origin,n=r[0],a=r[1],i=t.translate,o=t.rotate,s=t.skew,u=t.scale;return Array.isArray(i)&&i.every((function(t){return!Number.isNaN(+t)}))&&i.some((function(t){return 0!==t}))?e=e.translate(i[0]||0,i[1]||0,i[2]||0):"number"!=typeof i||Number.isNaN(+i)||(e=e.translate(i||0,0,0)),(o||s||u)&&(e=e.translate(n,a),Array.isArray(o)&&o.every((function(t){return!Number.isNaN(+t)}))&&o.some((function(t){return 0!==t}))?e=e.rotate(o[0],o[1],o[2]):"number"!=typeof o||Number.isNaN(+o)||(e=e.rotate(0,0,o)),Array.isArray(s)&&s.every((function(t){return!Number.isNaN(+t)}))&&s.some((function(t){return 0!==t}))?(e=s[0]?e.skewX(s[0]):e,e=s[1]?e.skewY(s[1]):e):"number"!=typeof s||Number.isNaN(+s)||(e=e.skewX(s||0)),Array.isArray(u)&&u.every((function(t){return!Number.isNaN(+t)}))&&u.some((function(t){return 1!==t}))?e=e.scale(u[0],u[1],u[2]):"number"!=typeof u||Number.isNaN(+u)||(e=e.scale(u||1,u||1,u||1)),e=e.translate(-n,-a)),e}(e),v=Object.keys(e),d=e.origin,g=[y.a,y.b,y.c,y.d,y.e,y.f],w=Object.assign({},M),N=[],A=0,C="",S=[],k=[];if(!y.isIdentity){for(r=0,a=h.length;r<a;r+=1){N=h[r],h[r]&&(C=N[0]),k[r]=C,"A"!==C||y.is2D&&["skewX","skewY"].find((function(t){return v.includes(t)}))||(N=T(l[r],w),h[r]=T(l[r],w),x(h,k,r),l[r]=T(l[r],w),x(l,k,r),a=Math.max(h.length,l.length)),A=(N=l[r]).length,w.x1=+N[A-2],w.y1=+N[A-1],w.x2=+N[A-4]||w.x1,w.y2=+N[A-3]||w.y1;var P={s:h[r],c:h[r][0],x:w.x1,y:w.y1};S=S.concat([P])}return S.map((function(t){var e,r,a;switch(C=t.c,N=t.s,C){case"A":return u=function(t,e,r,n){var a=Math.cos(n*Math.PI/180),i=Math.sin(n*Math.PI/180),o=[e*(t[0]*a+t[2]*i),e*(t[1]*a+t[3]*i),r*(-t[0]*i+t[2]*a),r*(-t[1]*i+t[3]*a)],s=o[0]*o[0]+o[2]*o[2],u=o[1]*o[1]+o[3]*o[3],c=((o[0]-o[3])*(o[0]-o[3])+(o[2]+o[1])*(o[2]+o[1]))*((o[0]+o[3])*(o[0]+o[3])+(o[2]-o[1])*(o[2]-o[1])),m=(s+u)/2;if(c<1e-9*m){var f=Math.sqrt(m);return{rx:f,ry:f,ax:0}}var h,l,p=o[0]*o[1]+o[2]*o[3],y=m+(c=Math.sqrt(c))/2,v=m-c/2,x=Math.abs(p)<1e-9&&Math.abs(y-u)<1e-9?90:Math.atan(Math.abs(p)>Math.abs(y-u)?(y-s)/p:p/(y-u)*180)/Math.PI;return x>=0?(h=Math.sqrt(y),l=Math.sqrt(v)):(x+=90,h=Math.sqrt(v),l=Math.sqrt(y)),{rx:h,ry:l,ax:x}}(g,N[1],N[2],N[3]),g[0]*g[3]-g[1]*g[2]<0&&(N[5]=N[5]?0:1),e=K(y,[+N[6],+N[7]],d),o=e[0],s=e[1],N=m===o&&f===s||u.rx<1e-9*u.ry||u.ry<1e-9*u.rx?["L",o,s]:[C,u.rx,u.ry,u.ax,N[4],N[5],o,s],m=o,f=s,N;case"L":case"H":case"V":return r=K(y,[t.x,t.y],d),o=r[0],s=r[1],m!==o&&f!==s?N=["L",o,s]:f===s?N=["H",o]:m===o&&(N=["V",s]),m=o,f=s,N;default:for(n=1,i=N.length;n<i;n+=2)a=K(y,[+N[n],+N[n+1]],d),m=a[0],f=a[1],N[n]=m,N[n+1]=f;return N}}))}return c(h)}function _(t,e,r,n,a,i,o,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*a+Math.pow(u,3)*o,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*i+Math.pow(u,3)*s}}function tt(t,e,r,n,a,i,o,s,u){var c,m=t,f=e,h=0,l=[t,e,h],p=[t,e];if("number"==typeof u&&u<.001)return{x:m,y:f};for(var y=0;y<=100;y+=1){if(h+=P(p,[m=(c=_(t,e,r,n,a,i,o,s,y/100)).x,f=c.y]),p=[m,f],"number"==typeof u&&h>=u){var v=(h-u)/(h-l[2]);return{x:p[0]*(1-v)+l[0]*v,y:p[1]*(1-v)+l[1]*v}}l=[m,f,h]}return"number"==typeof u&&u>=h?{x:o,y:s}:h}function et(t,e,r,n,a,i,o,s){var u,c,m,f,h=a-2*r+t-(o-2*a+r),l=2*(r-t)-2*(a-r),p=t-r,y=(-l+Math.sqrt(l*l-4*h*p))/2/h,v=(-l-Math.sqrt(l*l-4*h*p))/2/h,x=[t,o],d=[e,s],g=0,M=0;return Math.abs(y)>1e12&&(y=.5),Math.abs(v)>1e12&&(v=.5),y>0&&y<1&&(g=(u=tt(t,e,r,n,a,i,o,s,y)).x,M=u.y,x.push(g),d.push(M)),v>0&&v<1&&(g=(c=tt(t,e,r,n,a,i,o,s,v)).x,M=c.y,x.push(g),d.push(M)),h=i-2*n+e-(s-2*i+n),p=e-n,y=(-(l=2*(n-e)-2*(i-n))+Math.sqrt(l*l-4*h*p))/2/h,v=(-l-Math.sqrt(l*l-4*h*p))/2/h,Math.abs(y)>1e12&&(y=.5),Math.abs(v)>1e12&&(v=.5),y>0&&y<1&&(g=(m=tt(t,e,r,n,a,i,o,s,y)).x,M=m.y,x.push(g),d.push(M)),v>0&&v<1&&(g=(f=tt(t,e,r,n,a,i,o,s,v)).x,M=f.y,x.push(g),d.push(M)),{min:{x:Math.min.apply(Math,x),y:Math.min.apply(Math,d)},max:{x:Math.max.apply(Math,x),y:Math.max.apply(Math,d)}}}function rt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var e=j(t),r=0,n=0,a=[],i=[];e.forEach((function(t){var e=t.slice(-2).map(Number),o=e[0],s=e[1];if("M"===t[0])r=o,n=s,a.push(o),i.push(s);else{var u=[r,n].concat(t.slice(1)),c=et.apply(void 0,u);a=a.concat([c.min.x],[c.max.x]),i=i.concat([c.min.y],[c.max.y]),r=o,n=s}}));var o=Math.min.apply(Math,a),s=Math.min.apply(Math,i),u=Math.max.apply(Math,a),c=Math.max.apply(Math,i),m=u-o,f=c-s;return{width:m,height:f,x:o,y:s,x2:u,y2:c,cx:o+m/2,cy:s+f/2,cz:Math.max(m,f)+Math.min(m,f)/2}}Object.assign(U,{Version:"0.0.24"});var nt=function(e,r){var n=r||{};this.segments=h(e);var a=rt(this.segments),i=a.width,o=a.height,s=a.cx,u=a.cy,c=a.cz,m=t.round,f=t.origin,l=n.round,p=n.origin;if("auto"===l){var y=(""+Math.floor(Math.max(i,o))).length;m=y>=4?0:4-y}else(Number.isInteger(l)&&l>=1||!1===l)&&(m=l);if(Array.isArray(p)&&p.length>=2){var v=p.map(Number),x=v[0],d=v[1],g=v[2];f=[Number.isNaN(x)?s:x,Number.isNaN(d)?u:d,g||c]}else f=[s,u,c];return this.round=m,this.origin=f,this};function at(t,e,r,n,a,i,o,s){return 3*((s-e)*(r+a)-(o-t)*(n+i)+n*(t-a)-r*(e-i)+s*(a+t/3)-o*(i+e/3))/20}function it(t){var e=0,r=0,n=0;return j(t).map((function(t){var a,i;switch(t[0]){case"M":return e=(a=t)[1],r=a[2],0;default:return n=at.apply(void 0,[e,r].concat(t.slice(1))),i=t.slice(-2),e=i[0],r=i[1],n}})).reduce((function(t,e){return t+e}),0)}function ot(t,e,r,n,a,i,o,s,u,c){var m,f=[t,e],h=f[0],l=f[1],p=C(t,e,r,n,a,i,o,s,u),y=0,v=[],x=[],d=0;if("number"==typeof c&&c<.001)return{x:h,y:l};for(var g=0,M=p.length;g<M;g+=6){if(v=p.slice(g,g+6),x=[h,l].concat(v),d=tt.apply(void 0,x),"number"==typeof c&&y+d>=c)return tt.apply(void 0,x.concat([c-y]));y+=d,h=(m=v.slice(-2))[0],l=m[1]}return"number"==typeof c&&c>=y?{x:s,y:u}:y}function st(t,e,r,n,a,i,o){var s=1-o;return{x:Math.pow(s,2)*t+2*s*o*r+Math.pow(o,2)*a,y:Math.pow(s,2)*e+2*s*o*n+Math.pow(o,2)*i}}function ut(t,e,r,n,a,i,o){var s,u=t,c=e,m=0,f=[t,e,m],h=[t,e];if("number"==typeof o&&o<.001)return{x:u,y:c};for(var l=0;l<=100;l+=1){if(m+=P(h,[u=(s=st(t,e,r,n,a,i,l/100)).x,c=s.y]),h=[u,c],"number"==typeof o&&m>=o){var p=(m-o)/(m-f[2]);return{x:h[0]*(1-p)+f[0]*p,y:h[1]*(1-p)+f[1]*p}}f=[u,c,m]}return"number"==typeof o&&o>=m?{x:a,y:i}:m}function ct(t,e){for(var r,n,a,i=0,o=!0,s=[],u="M",c=0,m=0,f=0,h=0,l=0,p=w(b(t)),y=0,v=p.length;y<v;y+=1){if(s=(o="M"===(u=(a=p[y])[0]))?s:[m,f].concat(a.slice(1)),o){if(h=(r=a)[1],l=r[2],"number"==typeof e&&e<.001)return{x:h,y:l}}else if("L"===u){if(c=q.apply(void 0,s),e&&i+c>=e)return q.apply(void 0,s.concat([e-i]));i+=c}else if("A"===u){if(c=ot.apply(void 0,s),e&&i+c>=e)return ot.apply(void 0,s.concat([e-i]));i+=c}else if("C"===u){if(c=tt.apply(void 0,s),e&&i+c>=e)return tt.apply(void 0,s.concat([e-i]));i+=c}else if("Q"===u){if(c=ut.apply(void 0,s),e&&i+c>=e)return ut.apply(void 0,s.concat([e-i]));i+=c}else if("Z"===u){if(s=[m,f,h,l],c=q.apply(void 0,s),e&&i+c>=e)return q.apply(void 0,s.concat([e-i]));i+=c}m=(n="Z"!==u?a.slice(-2):[h,l])[0],f=n[1]}return e&&e>=i?{x:m,y:f}:i}function mt(t){return ct(t)}function ft(t,e){return ct(t,e)}function ht(t,e){var r=h(t),n=[],a=[].concat(r),i=mt(a),o=a.length-1,s=0,u=0,c=r[0],m=c.slice(-2),f={x:m[0],y:m[1]};if(o<=0||!e||!Number.isFinite(e))return{segment:c,index:0,length:u,point:f,lengthAtSegment:s};if(e>=i)return u=i-(s=mt(a=r.slice(0,-1))),{segment:r[o],index:o,length:u,lengthAtSegment:s};for(;o>0;)c=a[o],u=i-(s=mt(a=a.slice(0,-1))),i=s,n.push({segment:c,index:o,length:u,lengthAtSegment:s}),o-=1;return n.find((function(t){return t.lengthAtSegment<=e}))}function lt(t,e){for(var r=w(h(t)),n=b(r),a=mt(r),i=function(t){var r=t.x-e.x,n=t.y-e.y;return r*r+n*n},o=8,s={x:0,y:0},u=0,c=s,m=0,f=1/0,l=0;l<=a;l+=o)(u=i(s=ft(n,l)))<f&&(c=s,m=l,f=u);o/=2;for(var p={x:0,y:0},y=p,v=0,x=0,d=0,g=0;o>.5;)d=i(p=ft(n,v=m-o)),g=i(y=ft(n,x=m+o)),v>=0&&d<f?(c=p,m=v,f=d):x<=a&&g<f?(c=y,m=x,f=g):o/=2;var M=ht(r,f);return{closest:c,distance:Math.sqrt(f),segment:M}}nt.prototype.toAbsolute=function(){var t=this.segments;return this.segments=p(t),this},nt.prototype.toRelative=function(){var t=this.segments;return this.segments=v(t),this},nt.prototype.toCurve=function(){var t=this.segments;return this.segments=j(t),this},nt.prototype.reverse=function(t){this.toAbsolute();var e=this.segments,r=z(this.toString()),n=r.length>1?r:0,a=n&&c(n).map((function(e,r){return t?r?O(e):h(e):O(e)})),i=[];return i=n?a.flat(1):t?e:O(e),this.segments=c(i),this},nt.prototype.normalize=function(){var t=this.segments;return this.segments=b(t),this},nt.prototype.optimize=function(){var t=this.segments;return this.segments=Z(t,this.round),this},nt.prototype.transform=function(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some((function(e){return e in t})))return this;var e={};Object.keys(t).forEach((function(r){e[r]=Array.isArray(t[r])?[].concat(t[r]):Number(t[r])}));var r=this.segments,n=e.origin;if(n&&n.length>=2){var a=n.map(Number),i=a[0],o=a[1],s=a[2],u=this.origin,c=u[0],m=u[1],f=u[2];e.origin=[Number.isNaN(i)?c:i,Number.isNaN(o)?m:o,s||f]}else e.origin=Object.assign({},this.origin);return this.segments=W(r,e),this},nt.prototype.flipX=function(){return this.transform({rotate:[180,0,0]}),this},nt.prototype.flipY=function(){return this.transform({rotate:[0,180,0]}),this},nt.prototype.toString=function(){return V(this.segments,this.round)};var pt={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};var yt={CSSMatrix:U,parsePathString:h,isPathArray:f,isCurveArray:N,isAbsoluteArray:l,isRelativeArray:y,isNormalizedArray:g,isValidPath:function(t){if("string"!=typeof t)return!1;var e=new m(t);for(o(e);e.index<e.max&&!e.err.length;)u(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:p,pathToRelative:v,pathToCurve:j,pathToString:V,getDrawDirection:function(t){return it(j(t))>=0},getPathArea:it,getPathBBox:rt,getTotalLength:mt,getPathLength:function(t){var e=0;return j(t).forEach((function(t,r,n){var a="M"!==t[0]?n[r-1].slice(-2).concat(t.slice(1)):[];e+="M"===t[0]?0:tt.apply(void 0,a)})),e},getPointAtLength:ft,getPointAtPathLength:function(t,e){return ft(t,e)},getClosestPoint:function(t,e){return lt(t,e).closest},getSegmentOfPoint:function(t,e){var r=lt(t,e).segment;return void 0!==r?r.segment:null},getPropertiesAtPoint:lt,getPropertiesAtLength:ht,getSegmentAtLength:function(t,e){var r=ht(t,e);return(void 0!==r?r:{segment:null}).segment},isPointInStroke:function(t,e){var r=lt(t,e).distance;return Math.abs(r)<.01},clonePath:c,splitPath:z,fixPath:w,roundPath:L,optimizePath:Z,reverseCurve:function(t){var e=t.slice(1).map((function(e,r,n){return r?n[r-1].slice(-2).concat(e.slice(1)):t[0].slice(1).concat(e.slice(1))})).map((function(t){return t.map((function(e,r){return t[t.length-r-2*(1-r%2)]}))})).reverse();return[["M"].concat(e[0].slice(0,2))].concat(e.map((function(t){return["C"].concat(t.slice(2))})))},reversePath:O,normalizePath:b,transformPath:W,shapeToPath:function(e,r){var n=Object.keys(pt),a=e instanceof Element;if(a&&!n.some((function(t){return e.tagName===t})))throw TypeError('shapeToPath: "'+e+'" is not SVGElement');var i,o=document.createElementNS("http://www.w3.org/2000/svg","path"),s=a?e.tagName:e.type,u={};if(u.type=s,a){var c=pt[s];c.forEach((function(t){u[t]=e.getAttribute(t)})),Object.values(e.attributes).forEach((function(t){var e=t.name,r=t.value;c.includes(e)||o.setAttribute(e,r)}))}else Object.assign(u,e);var m,f,h,l,p=t.round;return"circle"===s?i=V((f=(m=u).cx,h=m.cy,l=m.r,[["M",f-l,h],["a",l,l,0,1,0,2*l,0],["a",l,l,0,1,0,-2*l,0]]),p):"ellipse"===s?i=V(function(t){var e=t.cx,r=t.cy,n=t.rx,a=t.ry;return[["M",e-n,r],["a",n,a,0,1,0,2*n,0],["a",n,a,0,1,0,-2*n,0]]}(u),p):["polyline","polygon"].includes(s)?i=V(function(t){for(var e=[],r=t.points.split(/[\s|,]/).map(Number),n=0;n<r.length;)e.push([n?"L":"M",r[n],r[n+1]]),n+=2;return"polygon"===t.type?e.concat([["z"]]):e}(u),p):"rect"===s?i=V(function(t){var e=+t.x||0,r=+t.y||0,n=+t.width,a=+t.height,i=+t.rx,o=+t.ry;return i||o?(i=i||o,o=o||i,2*i>n&&(i-=(2*i-n)/2),2*o>a&&(o-=(2*o-a)/2),[["M",e+i,r],["h",n-2*i],["s",i,0,i,o],["v",a-2*o],["s",0,o,-i,o],["h",2*i-n],["s",-i,0,-i,-o],["v",2*o-a],["s",0,-o,i,-o]]):[["M",e,r],["h",n],["v",a],["H",e],["Z"]]}(u),p):"line"===s?i=V(function(t){return[["M",t.x1,t.y1],["L",t.x2,t.y2]]}(u),p):"glyph"===s&&(i=a?e.getAttribute("d"):e.type),!!i&&(o.setAttribute("d",i),r&&a&&(e.before(o,e),e.remove()),o)},options:t};return Object.assign(nt,yt,{Version:"0.1.23"}),nt}));
|
|
1
|
+
// SVGPathCommander v0.1.24 | thednp © 2021 | MIT-License
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SVGPathCommander=e()}(this,(function(){"use strict";var t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function r(t){var r=t.pathValue[t.segmentStart],n=r.toLowerCase(),a=t.data;for("m"===n&&a.length>2&&(t.segments.push([r,a[0],a[1]]),a=a.slice(2),n="l",r="m"===r?"l":"L");a.length>=e[n]&&(t.segments.push([r].concat(a.splice(0,e[n]))),e[n]););}function n(t){var e=t.index,r=t.pathValue.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='Invalid path value: invalid Arc flag "'+r+'", expecting 0 or 1 at index '+e)}function a(t){return t>=48&&t<=57}function i(t){var e,r=t.max,n=t.pathValue,i=t.index,o=i,s=!1,u=!1,c=!1,m=!1;if(o>=r)t.err="Invalid path value at "+o+": missing param "+n[o];else if(43!==(e=n.charCodeAt(o))&&45!==e||(e=(o+=1)<r?n.charCodeAt(o):0),a(e)||46===e){if(46!==e){if(s=48===e,e=(o+=1)<r?n.charCodeAt(o):0,s&&o<r&&e&&a(e))return void(t.err="Invalid path value at index "+i+": "+n[i]+" illegal number");for(;o<r&&a(n.charCodeAt(o));)o+=1,u=!0;e=o<r?n.charCodeAt(o):0}if(46===e){for(m=!0,o+=1;a(n.charCodeAt(o));)o+=1,c=!0;e=o<r?n.charCodeAt(o):0}if(101===e||69===e){if(m&&!u&&!c)return void(t.err="Invalid path value at index "+o+": "+n[o]+" invalid float exponent");if(43!==(e=(o+=1)<r?n.charCodeAt(o):0)&&45!==e||(o+=1),!(o<r&&a(n.charCodeAt(o))))return void(t.err="Invalid path value at index "+o+": "+n[o]+" invalid float exponent");for(;o<r&&a(n.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="Invalid path value at index "+o+": "+n[o]+" is not a number"}function o(t){for(var e,r=t.pathValue,n=t.max;t.index<n&&(10===(e=r.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0);)t.index+=1}function s(t){return t>=48&&t<=57||43===t||45===t||46===t}function u(t){var a=t.max,u=t.pathValue,c=t.index,m=u.charCodeAt(c),f=e[u[c].toLowerCase()];if(t.segmentStart=c,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(m))if(t.index+=1,o(t),t.data=[],f){for(;;){for(var h=f;h>0;h-=1){if(97!=(32|m)||3!==h&&4!==h?i(t):n(t),t.err.length)return;t.data.push(t.param),o(t),t.index<a&&44===u.charCodeAt(t.index)&&(t.index+=1,o(t))}if(t.index>=t.max)break;if(!s(u.charCodeAt(t.index)))break}r(t)}else r(t);else t.err="Invalid path value: "+u[c]+" not a path command"}function c(t){return t.map((function(t){return Array.isArray(t)?[].concat(t):t}))}function m(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function f(t){return Array.isArray(t)&&t.every((function(t){var r=t[0].toLowerCase();return e[r]===t.length-1&&"achlmqstvz".includes(r)}))}function h(t){if(f(t))return c(t);var e=new m(t);for(o(e);e.index<e.max&&!e.err.length;)u(e);return e.err.length?e.segments=[]:e.segments.length&&("mM".includes(e.segments[0][0])?e.segments[0][0]="M":(e.err="Invalid path value: missing M/m",e.segments=[])),e.segments}function l(t){return f(t)&&t.every((function(t){return t[0]===t[0].toUpperCase()}))}function p(t){if(l(t))return c(t);var e=h(t),r=0,n=0,a=0,i=0;return e.map((function(t){var e,o=t.slice(1).map(Number),s=t[0],u=s.toUpperCase();if("M"===s)return r=(e=o)[0],n=e[1],a=r,i=n,["M",r,n];var c=[];if(s!==u)switch(u){case"A":c=[u,o[0],o[1],o[2],o[3],o[4],o[5]+r,o[6]+n];break;case"V":c=[u,o[0]+n];break;case"H":c=[u,o[0]+r];break;default:var m=o.map((function(t,e){return t+(e%2?n:r)}));c=[u].concat(m)}else c=[u].concat(o);var f=c.length;switch(u){case"Z":r=a,n=i;break;case"H":r=c[1];break;case"V":n=c[1];break;default:r=c[f-2],n=c[f-1],"M"===u&&(a=r,i=n)}return c}))}function y(t){return f(t)&&t.slice(1).every((function(t){return t[0]===t[0].toLowerCase()}))}function v(t){if(y(t))return c(t);var e=h(t),r=0,n=0,a=0,i=0;return e.map((function(t){var e,o,s=t.slice(1).map(Number),u=t[0],c=u.toLowerCase();if("M"===u)return r=(e=s)[0],n=e[1],a=r,i=n,["M",r,n];var m=[];if(u!==c)switch(c){case"a":m=[c,s[0],s[1],s[2],s[3],s[4],s[5]-r,s[6]-n];break;case"v":m=[c,s[0]-n];break;case"h":m=[c,s[0]-r];break;default:var f=s.map((function(t,e){return t-(e%2?n:r)}));m=[c].concat(f),"m"===c&&(r=(o=s)[0],n=o[1],a=r,i=n)}else"m"===u&&(a=s[0]+r,i=s[1]+n),m=[c].concat(s);var h=m.length;switch(c){case"z":r=a,n=i;break;case"h":r+=m[1];break;case"v":n+=m[1];break;default:r+=m[h-2],n+=m[h-1]}return m}))}function x(t,e,r){if(t[r].length>7){t[r].shift();for(var n=t[r],a=r;n.length;)e[r]="A",t.splice(a+=1,0,["C"].concat(n.splice(0,6)));t.splice(r,1)}}function d(t,e,r){var n=t[0],a=e.x1,i=e.y1,o=e.x2,s=e.y2,u=t.slice(1).map(Number),c=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)c=["L",t[1],i];else if("V"===n)c=["L",a,t[1]];else if("S"===n){var m=function(t,e,r,n,a){return"CS".includes(a)?{x1:2*t-r,y1:2*e-n}:{x1:t,y1:e}}(a,i,o,s,r),f=m.x1,h=m.y1;e.x1=f,e.y1=h,c=["C",f,h].concat(u)}else if("T"===n){var l=function(t,e,r,n,a){return"QT".includes(a)?{qx:2*t-r,qy:2*e-n}:{qx:t,qy:e}}(a,i,e.qx,e.qy,r),p=l.qx,y=l.qy;e.qx=p,e.qy=y,c=["Q",p,y].concat(u)}else if("Q"===n){var v=u[0],x=u[1];e.qx=v,e.qy=x}return c}function g(t){return l(t)&&t.every((function(t){return"ACLMQZ".includes(t[0])}))}var M={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function b(t){if(g(t))return c(t);for(var e=p(t),r=Object.assign({},M),n=[],a=e.length,i="",o="",s=0;s<a;s+=1){i=e[s][0],n[s]=i,s&&(o=n[s-1]),e[s]=d(e[s],r,o);var u=e[s],m=u.length;r.x1=+u[m-2],r.y1=+u[m-1],r.x2=+u[m-4]||r.x1,r.y2=+u[m-3]||r.y1}return e}function w(t){var e=h(t),r=b(e),n=e.length,a="Z"===r.slice(-1)[0][0],i=a?n-2:n-1,o=r[0].slice(1),s=o[0],u=o[1],c=r[i].slice(-2),m=c[0],f=c[1];return a&&s===m&&u===f?e.slice(0,-1):e}function N(t){return f(t)&&t.every((function(t){return"MC".includes(t[0])}))}function A(t,e,r){return{x:t*Math.cos(r)-e*Math.sin(r),y:t*Math.sin(r)+e*Math.cos(r)}}function C(t,e,r,n,a,i,o,s,u,c){var m,f,h,l,p,y,v=t,x=e,d=r,g=n,M=s,b=u,w=120*Math.PI/180,N=Math.PI/180*(+a||0),S=[];if(c)h=(m=c)[0],l=m[1],p=m[2],y=m[3];else{v=(f=A(v,x,-N)).x,x=f.y;var k=(v-(M=(f=A(M,b,-N)).x))/2,P=(x-(b=f.y))/2,q=k*k/(d*d)+P*P/(g*g);q>1&&(d*=q=Math.sqrt(q),g*=q);var I=d*d,T=g*g,j=(i===o?-1:1)*Math.sqrt(Math.abs((I*T-I*P*P-T*k*k)/(I*P*P+T*k*k)));p=j*d*P/g+(v+M)/2,y=j*-g*k/d+(x+b)/2,h=(Math.asin((x-y)/g)*Math.pow(10,9)>>0)/Math.pow(10,9),l=(Math.asin((b-y)/g)*Math.pow(10,9)>>0)/Math.pow(10,9),h=v<p?Math.PI-h:h,l=M<p?Math.PI-l:l,h<0&&(h=2*Math.PI+h),l<0&&(l=2*Math.PI+l),o&&h>l&&(h-=2*Math.PI),!o&&l>h&&(l-=2*Math.PI)}var L=l-h;if(Math.abs(L)>w){var V=l,O=M,z=b;l=h+w*(o&&l>h?1:-1),S=C(M=p+d*Math.cos(l),b=y+g*Math.sin(l),d,g,a,0,o,O,z,[l,V,p,y])}L=l-h;var E=Math.cos(h),Z=Math.sin(h),Q=Math.cos(l),D=Math.sin(l),X=Math.tan(L/4),H=4/3*d*X,Y=4/3*g*X,F=[v,x],R=[v+H*Z,x-Y*E],B=[M+H*D,b-Y*Q],G=[M,b];if(R[0]=2*F[0]-R[0],R[1]=2*F[1]-R[1],c)return R.concat(B,G,S);for(var J=[],U=0,$=(S=R.concat(B,G,S)).length;U<$;U+=1)J[U]=U%2?A(S[U-1],S[U],N).y:A(S[U],S[U+1],N).x;return J}function S(t,e,r,n,a,i){return[1/3*t+2/3*r,1/3*e+2/3*n,1/3*a+2/3*r,1/3*i+2/3*n,a,i]}function k(t,e,r){var n=t[0],a=t[1];return[n+(e[0]-n)*r,a+(e[1]-a)*r]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function q(t,e,r,n,a){var i=P([t,e],[r,n]);if("number"==typeof a){if(a<.001)return{x:t,y:e};if(a>i)return{x:r,y:n};var o=k([t,e],[r,n],a/i);return{x:o[0],y:o[1]}}return i}function I(t,e,r,n){var a=.5,i=[t,e],o=[r,n],s=k(i,o,a),u=k(o,s,a),c=k(s,u,a),m=k(u,c,a),f=k(c,m,a),h=i.concat(s,c,f,[a]),l=q.apply(void 0,h),p=f.concat(m,u,o,[0]),y=q.apply(void 0,p);return[l.x,l.y,y.x,y.y,r,n]}function T(t,e){var r,n=t[0],a=t.slice(1).map((function(t){return+t})),i=a[0],o=a[1],s=e.x1,u=e.y1,c=e.x,m=e.y;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=i,e.y=o,t;case"A":return r=[s,u].concat(a),["C"].concat(C.apply(void 0,r));case"Q":return e.qx=i,e.qy=o,r=[s,u].concat(a),["C"].concat(S.apply(void 0,r));case"L":return["C"].concat(I(s,u,i,o));case"Z":return["C"].concat(I(s,u,c,m))}return t}function j(t){if(N(t))return c(t);for(var e=w(b(t)),r=Object.assign({},M),n=[],a="",i=e.length,o=0;o<i;o+=1){a=e[o][0],n[o]=a,e[o]=T(e[o],r),x(e,n,o),i=e.length;var s=e[o],u=s.length;r.x1=+s[u-2],r.y1=+s[u-1],r.x2=+s[u-4]||r.x1,r.y2=+s[u-3]||r.y1}return e}function L(e,r){var n=t.round;if(!1===r||!1===n)return c(e);var a=(n=r>=1?r:n)>=1?Math.pow(10,n):1;return e.map((function(t){var e=t.slice(1).map(Number).map((function(t){return t%1==0?t:Math.round(t*a)/a}));return[t[0]].concat(e)}))}function V(t,e){return L(t,e).map((function(t){return t[0]+t.slice(1).join(" ")})).join("")}function O(t){var e=p(t),r="Z"===e.slice(-1)[0][0],n=b(e).map((function(t,r){var n=t.slice(-2).map(Number),a=n[0],i=n[1];return{seg:e[r],n:t,c:e[r][0],x:a,y:i}})).map((function(t,e,n){var a=t.seg,i=t.n,o=e&&n[e-1],s=n[e+1]&&n[e+1],u=t.c,c=n.length,m=e?n[e-1].x:n[c-1].x,f=e?n[e-1].y:n[c-1].y,h=[];switch(u){case"M":h=r?["Z"]:[u,m,f];break;case"A":h=[u].concat(a.slice(1,-3),[1===a[5]?0:1],[m],[f]);break;case"C":h=s&&"S"===s.c?["S",a[1],a[2],m,f]:[u,a[3],a[4],a[1],a[2],m,f];break;case"S":h=o&&"CS".includes(o.c)&&(!s||s&&"S"!==s.c)?["C",i[3],i[4],i[1],i[2],m,f]:[u,i[1],i[2],m,f];break;case"Q":h=s&&"T"===s.c?["T",m,f]:[u].concat(a.slice(1,-2),[m],[f]);break;case"T":h=o&&"QT".includes(o.c)&&(!s||s&&"T"!==s.c)?["Q",i[1],i[2],m,f]:[u,m,f];break;case"Z":h=["M",m,f];break;case"H":h=[u,m];break;case"V":h=[u,f];break;default:h=[u].concat(a.slice(1,-2),[m],[f])}return h}));return r?n.reverse():[n[0]].concat(n.slice(1).reverse())}function z(t){return V(p(t),0).replace(/(m|M)/g,"|$1").split("|").map((function(t){return t.trim()})).filter((function(t){return t}))}function E(t,e,r,n){var a=t[0],i=function(t){return Math.round(t*Math.pow(10,4))/Math.pow(10,4)},o=t.slice(1).map((function(t){return+t})),s=e.slice(1).map((function(t){return+t})),u=r.x1,c=r.y1,m=r.x2,f=r.y2,h=r.x,l=r.y,p=t,y=s.slice(-2),v=y[0],x=y[1];if("TQ".includes(a)||(r.qx=null,r.qy=null),["V","H","S","T","Z"].includes(a))p=[a].concat(o);else if("L"===a)i(h)===i(v)?p=["V",x]:i(l)===i(x)&&(p=["H",v]);else if("C"===a){var d=s[0],g=s[1];"CS".includes(n)&&i(d)===i(2*u-m)&&i(g)===i(2*c-f)&&(p=["S"].concat(s.slice(-4))),r.x1=d,r.y1=g}else if("Q"===a){var M=s[0],b=s[1];r.qx=M,r.qy=b,"QT".includes(n)&&i(M)===i(2*u-m)&&i(b)===i(2*c-f)&&(p=["T"].concat(s.slice(-2)))}return p}function Z(t,e){for(var r,n=p(t),a=b(n),i=Object.assign({},M),o=[],s=n.length,u="",c="",m=0,f=0,h=0,l=0,y=0;y<s;y+=1){u=n[y][0],o[y]=u,y&&(c=o[y-1]),n[y]=E(n[y],a[y],i,c);var x=n[y],d=x.length;switch(i.x1=+x[d-2],i.y1=+x[d-1],i.x2=+x[d-4]||i.x1,i.y2=+x[d-3]||i.y1,u){case"Z":m=h,f=l;break;case"H":m=x[1];break;case"V":f=x[1];break;default:m=(r=x.slice(-2).map(Number))[0],f=r[1],"M"===u&&(h=m,l=f)}i.x=m,i.y=f}var g=L(n,e),w=L(v(n),e);return g.map((function(t,e){return e?t.join("").length<w[e].join("").length?t:w[e]:t}))}function Q(t){var e=new U,r=Array.from(t);if(!r.every((function(t){return!Number.isNaN(t)})))throw TypeError('CSSMatrix: "'+t+'" must only have numbers.');if(16===r.length){var n=r[0],a=r[1],i=r[2],o=r[3],s=r[4],u=r[5],c=r[6],m=r[7],f=r[8],h=r[9],l=r[10],p=r[11],y=r[12],v=r[13],x=r[14],d=r[15];e.m11=n,e.a=n,e.m21=s,e.c=s,e.m31=f,e.m41=y,e.e=y,e.m12=a,e.b=a,e.m22=u,e.d=u,e.m32=h,e.m42=v,e.f=v,e.m13=i,e.m23=c,e.m33=l,e.m43=x,e.m14=o,e.m24=m,e.m34=p,e.m44=d}else{if(6!==r.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");var g=r[0],M=r[1],b=r[2],w=r[3],N=r[4],A=r[5];e.m11=g,e.a=g,e.m12=M,e.b=M,e.m21=b,e.c=b,e.m22=w,e.d=w,e.m41=N,e.e=N,e.m42=A,e.f=A}return e}function D(t){var e=Object.keys(new U);if("object"==typeof t&&e.every((function(e){return e in t})))return Q([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError('CSSMatrix: "'+t+'" is not a DOMMatrix / CSSMatrix / JSON compatible object.')}function X(t){if("string"!=typeof t)throw TypeError('CSSMatrix: "'+t+'" is not a string.');var e=String(t).replace(/\s/g,""),r=new U,n='CSSMatrix: invalid transform string "'+t+'"';return e.split(")").filter((function(t){return t})).forEach((function(t){var e=t.split("("),a=e[0],i=e[1];if(!i)throw TypeError(n);var o=i.split(",").map((function(t){return t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)})),s=o[0],u=o[1],c=o[2],m=o[3],f=[s,u,c],h=[s,u,c,m];if("perspective"===a&&s&&[u,c].every((function(t){return void 0===t})))r.m34=-1/s;else if(a.includes("matrix")&&[6,16].includes(o.length)&&o.every((function(t){return!Number.isNaN(+t)}))){var l=o.map((function(t){return Math.abs(t)<1e-6?0:t}));r=r.multiply(Q(l))}else if("translate3d"===a&&f.every((function(t){return!Number.isNaN(+t)})))r=r.translate(s,u,c);else if("translate"===a&&s&&void 0===c)r=r.translate(s,u||0,0);else if("rotate3d"===a&&h.every((function(t){return!Number.isNaN(+t)}))&&m)r=r.rotateAxisAngle(s,u,c,m);else if("rotate"===a&&s&&[u,c].every((function(t){return void 0===t})))r=r.rotate(0,0,s);else if("scale3d"===a&&f.every((function(t){return!Number.isNaN(+t)}))&&f.some((function(t){return 1!==t})))r=r.scale(s,u,c);else if("scale"!==a||Number.isNaN(s)||1===s||void 0!==c)if("skew"===a&&s&&void 0===c)r=r.skewX(s),r=u?r.skewY(u):r;else{if(!(/[XYZ]/.test(a)&&s&&[u,c].every((function(t){return void 0===t}))&&["translate","rotate","scale","skew"].some((function(t){return a.includes(t)}))))throw TypeError(n);if(["skewX","skewY"].includes(a))r=r[a](s);else{var p=a.replace(/[XYZ]/,""),y=a.replace(p,""),v=["X","Y","Z"].indexOf(y),x=[0===v?s:0,1===v?s:0,2===v?s:0];r=r[p].apply(r,x)}}else{var d=Number.isNaN(+u)?s:u;r=r.scale(s,d,1)}})),r}function H(t,e,r){var n=new U;return n.m41=t,n.e=t,n.m42=e,n.f=e,n.m43=r,n}function Y(t,e,r){var n=new U,a=Math.PI/180,i=t*a,o=e*a,s=r*a,u=Math.cos(i),c=-Math.sin(i),m=Math.cos(o),f=-Math.sin(o),h=Math.cos(s),l=-Math.sin(s),p=m*h,y=-m*l;n.m11=p,n.a=p,n.m12=y,n.b=y,n.m13=f;var v=c*f*h+u*l;n.m21=v,n.c=v;var x=u*h-c*f*l;return n.m22=x,n.d=x,n.m23=-c*m,n.m31=c*l-u*f*h,n.m32=c*h+u*f*l,n.m33=u*m,n}function F(t,e,r,n){var a=new U,i=n*(Math.PI/360),o=Math.sin(i),s=Math.cos(i),u=o*o,c=Math.sqrt(t*t+e*e+r*r),m=t,f=e,h=r;0===c?(m=0,f=0,h=1):(m/=c,f/=c,h/=c);var l=m*m,p=f*f,y=h*h,v=1-2*(p+y)*u;a.m11=v,a.a=v;var x=2*(m*f*u+h*o*s);a.m12=x,a.b=x,a.m13=2*(m*h*u-f*o*s);var d=2*(f*m*u-h*o*s);a.m21=d,a.c=d;var g=1-2*(y+l)*u;return a.m22=g,a.d=g,a.m23=2*(f*h*u+m*o*s),a.m31=2*(h*m*u+f*o*s),a.m32=2*(h*f*u-m*o*s),a.m33=1-2*(l+p)*u,a}function R(t,e,r){var n=new U;return n.m11=t,n.a=t,n.m22=e,n.d=e,n.m33=r,n}function B(t){var e=new U,r=t*Math.PI/180,n=Math.tan(r);return e.m21=n,e.c=n,e}function G(t){var e=new U,r=t*Math.PI/180,n=Math.tan(r);return e.m12=n,e.b=n,e}function J(t,e){return Q([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}var U=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this;if(r.a=1,r.b=0,r.c=0,r.d=1,r.e=0,r.f=0,r.m11=1,r.m12=0,r.m13=0,r.m14=0,r.m21=0,r.m22=1,r.m23=0,r.m24=0,r.m31=0,r.m32=0,r.m33=1,r.m34=0,r.m41=0,r.m42=0,r.m43=0,r.m44=1,t&&t.length){var n=[16,6].some((function(e){return e===t.length}))?t:t[0];return r.setMatrixValue(n)}return r},$={isIdentity:{configurable:!0},is2D:{configurable:!0}};$.isIdentity.set=function(t){this.isIdentity=t},$.isIdentity.get=function(){var t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44},$.is2D.get=function(){var t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44},$.is2D.set=function(t){this.is2D=t},U.prototype.setMatrixValue=function(t){return[Array,Float64Array,Float32Array].some((function(e){return t instanceof e}))?Q(t):"string"==typeof t&&t.length&&"none"!==t?X(t):"object"==typeof t?D(t):this},U.prototype.toArray=function(){var t=this,e=Math.pow(10,6);return(t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]).map((function(t){return Math.abs(t)<1e-6?0:(t*e>>0)/e}))},U.prototype.toString=function(){var t=this.toArray();return(this.is2D?"matrix":"matrix3d")+"("+t+")"},U.prototype.toJSON=function(){var t=this,e=t.is2D,r=t.isIdentity;return Object.assign({},t,{is2D:e,isIdentity:r})},U.prototype.multiply=function(t){return J(this,t)},U.prototype.translate=function(t,e,r){var n=e,a=r;return void 0===a&&(a=0),void 0===n&&(n=0),J(this,H(t,n,a))},U.prototype.scale=function(t,e,r){var n=e,a=r;return void 0===n&&(n=t),void 0===a&&(a=1),J(this,R(t,n,a))},U.prototype.rotate=function(t,e,r){var n=t,a=e,i=r;return void 0===a&&(a=0),void 0===i&&(i=n,n=0),J(this,Y(n,a,i))},U.prototype.rotateAxisAngle=function(t,e,r,n){if([t,e,r,n].some((function(t){return Number.isNaN(t)})))throw new TypeError("CSSMatrix: expecting 4 values");return J(this,F(t,e,r,n))},U.prototype.skewX=function(t){return J(this,B(t))},U.prototype.skewY=function(t){return J(this,G(t))},U.prototype.transformPoint=function(t){var e=H(t.x,t.y,t.z);return e.m44=t.w||1,{x:(e=this.multiply(e)).m41,y:e.m42,z:e.m43,w:e.m44}},U.prototype.transform=function(t){var e=this,r=e.m11*t.x+e.m12*t.y+e.m13*t.z+e.m14*t.w,n=e.m21*t.x+e.m22*t.y+e.m23*t.z+e.m24*t.w,a=e.m31*t.x+e.m32*t.y+e.m33*t.z+e.m34*t.w,i=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:r/i,y:n/i,z:a/i,w:i}},Object.defineProperties(U.prototype,$),Object.assign(U,{Translate:H,Rotate:Y,RotateAxisAngle:F,Scale:R,SkewX:B,SkewY:G,Multiply:J,fromArray:Q,fromMatrix:D,fromString:X});function K(t,e,r){var n=e[0],a=e[1],i=r[0],o=r[1],s=r[2],u=t.transformPoint({x:n,y:a,z:0,w:1}),c=u.x-i,m=u.y-o,f=u.z-s;return[c*(Math.abs(s)/Math.abs(f))+i,m*(Math.abs(s)/Math.abs(f))+o]}function W(t,e){var r,n,a,i,o,s,u,m=0,f=0,h=p(t),l=b(h),y=function(t){var e=new U,r=t.origin,n=r[0],a=r[1],i=t.translate,o=t.rotate,s=t.skew,u=t.scale;return Array.isArray(i)&&i.every((function(t){return!Number.isNaN(+t)}))&&i.some((function(t){return 0!==t}))?e=e.translate(i[0]||0,i[1]||0,i[2]||0):"number"!=typeof i||Number.isNaN(+i)||(e=e.translate(i||0,0,0)),(o||s||u)&&(e=e.translate(n,a),Array.isArray(o)&&o.every((function(t){return!Number.isNaN(+t)}))&&o.some((function(t){return 0!==t}))?e=e.rotate(o[0],o[1],o[2]):"number"!=typeof o||Number.isNaN(+o)||(e=e.rotate(0,0,o)),Array.isArray(s)&&s.every((function(t){return!Number.isNaN(+t)}))&&s.some((function(t){return 0!==t}))?(e=s[0]?e.skewX(s[0]):e,e=s[1]?e.skewY(s[1]):e):"number"!=typeof s||Number.isNaN(+s)||(e=e.skewX(s||0)),Array.isArray(u)&&u.every((function(t){return!Number.isNaN(+t)}))&&u.some((function(t){return 1!==t}))?e=e.scale(u[0],u[1],u[2]):"number"!=typeof u||Number.isNaN(+u)||(e=e.scale(u||1,u||1,u||1)),e=e.translate(-n,-a)),e}(e),v=Object.keys(e),d=e.origin,g=[y.a,y.b,y.c,y.d,y.e,y.f],w=Object.assign({},M),N=[],A=0,C="",S=[],k=[];if(!y.isIdentity){for(r=0,a=h.length;r<a;r+=1){N=h[r],h[r]&&(C=N[0]),k[r]=C,"A"!==C||y.is2D&&["skewX","skewY"].find((function(t){return v.includes(t)}))||(N=T(l[r],w),h[r]=T(l[r],w),x(h,k,r),l[r]=T(l[r],w),x(l,k,r),a=Math.max(h.length,l.length)),A=(N=l[r]).length,w.x1=+N[A-2],w.y1=+N[A-1],w.x2=+N[A-4]||w.x1,w.y2=+N[A-3]||w.y1;var P={s:h[r],c:h[r][0],x:w.x1,y:w.y1};S=S.concat([P])}return S.map((function(t){var e,r,a;switch(C=t.c,N=t.s,C){case"A":return u=function(t,e,r,n){var a=Math.cos(n*Math.PI/180),i=Math.sin(n*Math.PI/180),o=[e*(t[0]*a+t[2]*i),e*(t[1]*a+t[3]*i),r*(-t[0]*i+t[2]*a),r*(-t[1]*i+t[3]*a)],s=o[0]*o[0]+o[2]*o[2],u=o[1]*o[1]+o[3]*o[3],c=((o[0]-o[3])*(o[0]-o[3])+(o[2]+o[1])*(o[2]+o[1]))*((o[0]+o[3])*(o[0]+o[3])+(o[2]-o[1])*(o[2]-o[1])),m=(s+u)/2;if(c<1e-9*m){var f=Math.sqrt(m);return{rx:f,ry:f,ax:0}}var h,l,p=o[0]*o[1]+o[2]*o[3],y=m+(c=Math.sqrt(c))/2,v=m-c/2,x=Math.abs(p)<1e-9&&Math.abs(y-u)<1e-9?90:Math.atan(Math.abs(p)>Math.abs(y-u)?(y-s)/p:p/(y-u)*180)/Math.PI;return x>=0?(h=Math.sqrt(y),l=Math.sqrt(v)):(x+=90,h=Math.sqrt(v),l=Math.sqrt(y)),{rx:h,ry:l,ax:x}}(g,N[1],N[2],N[3]),g[0]*g[3]-g[1]*g[2]<0&&(N[5]=N[5]?0:1),e=K(y,[+N[6],+N[7]],d),o=e[0],s=e[1],N=m===o&&f===s||u.rx<1e-9*u.ry||u.ry<1e-9*u.rx?["L",o,s]:[C,u.rx,u.ry,u.ax,N[4],N[5],o,s],m=o,f=s,N;case"L":case"H":case"V":return r=K(y,[t.x,t.y],d),o=r[0],s=r[1],m!==o&&f!==s?N=["L",o,s]:f===s?N=["H",o]:m===o&&(N=["V",s]),m=o,f=s,N;default:for(n=1,i=N.length;n<i;n+=2)a=K(y,[+N[n],+N[n+1]],d),m=a[0],f=a[1],N[n]=m,N[n+1]=f;return N}}))}return c(h)}function _(t,e,r,n,a,i,o,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*a+Math.pow(u,3)*o,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*i+Math.pow(u,3)*s}}function tt(t,e,r,n,a,i,o,s,u){var c,m="number"==typeof u,f=t,h=e,l=0,p=[t,e,l],y=[t,e];if(m&&u<.001)return{x:f,y:h};for(var v=0;v<=100;v+=1){if(l+=P(y,[f=(c=_(t,e,r,n,a,i,o,s,v/100)).x,h=c.y]),y=[f,h],m&&l>=u){var x=(l-u)/(l-p[2]);return{x:y[0]*(1-x)+p[0]*x,y:y[1]*(1-x)+p[1]*x}}p=[f,h,l]}return m&&u>=l?{x:o,y:s}:l}function et(t,e,r,n,a,i,o,s){var u,c,m,f,h=a-2*r+t-(o-2*a+r),l=2*(r-t)-2*(a-r),p=t-r,y=(-l+Math.sqrt(l*l-4*h*p))/2/h,v=(-l-Math.sqrt(l*l-4*h*p))/2/h,x=[t,o],d=[e,s],g=0,M=0;return Math.abs(y)>1e12&&(y=.5),Math.abs(v)>1e12&&(v=.5),y>0&&y<1&&(g=(u=tt(t,e,r,n,a,i,o,s,y)).x,M=u.y,x.push(g),d.push(M)),v>0&&v<1&&(g=(c=tt(t,e,r,n,a,i,o,s,v)).x,M=c.y,x.push(g),d.push(M)),h=i-2*n+e-(s-2*i+n),p=e-n,y=(-(l=2*(n-e)-2*(i-n))+Math.sqrt(l*l-4*h*p))/2/h,v=(-l-Math.sqrt(l*l-4*h*p))/2/h,Math.abs(y)>1e12&&(y=.5),Math.abs(v)>1e12&&(v=.5),y>0&&y<1&&(g=(m=tt(t,e,r,n,a,i,o,s,y)).x,M=m.y,x.push(g),d.push(M)),v>0&&v<1&&(g=(f=tt(t,e,r,n,a,i,o,s,v)).x,M=f.y,x.push(g),d.push(M)),{min:{x:Math.min.apply(Math,x),y:Math.min.apply(Math,d)},max:{x:Math.max.apply(Math,x),y:Math.max.apply(Math,d)}}}function rt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var e=j(t),r=0,n=0,a=[],i=[];e.forEach((function(t){var e=t.slice(-2).map(Number),o=e[0],s=e[1];if("M"===t[0])r=o,n=s,a.push(o),i.push(s);else{var u=[r,n].concat(t.slice(1)),c=et.apply(void 0,u);a=a.concat([c.min.x],[c.max.x]),i=i.concat([c.min.y],[c.max.y]),r=o,n=s}}));var o=Math.min.apply(Math,a),s=Math.min.apply(Math,i),u=Math.max.apply(Math,a),c=Math.max.apply(Math,i),m=u-o,f=c-s;return{width:m,height:f,x:o,y:s,x2:u,y2:c,cx:o+m/2,cy:s+f/2,cz:Math.max(m,f)+Math.min(m,f)/2}}Object.assign(U,{Version:"0.0.24"});var nt=function(e,r){var n=r||{};this.segments=h(e);var a=rt(this.segments),i=a.width,o=a.height,s=a.cx,u=a.cy,c=a.cz,m=t.round,f=t.origin,l=n.round,p=n.origin;if("auto"===l){var y=(""+Math.floor(Math.max(i,o))).length;m=y>=4?0:4-y}else(Number.isInteger(l)&&l>=1||!1===l)&&(m=l);if(Array.isArray(p)&&p.length>=2){var v=p.map(Number),x=v[0],d=v[1],g=v[2];f=[Number.isNaN(x)?s:x,Number.isNaN(d)?u:d,g||c]}else f=[s,u,c];return this.round=m,this.origin=f,this};function at(t,e,r,n,a,i,o,s){return 3*((s-e)*(r+a)-(o-t)*(n+i)+n*(t-a)-r*(e-i)+s*(a+t/3)-o*(i+e/3))/20}function it(t){var e=0,r=0,n=0;return j(t).map((function(t){var a,i;switch(t[0]){case"M":return e=(a=t)[1],r=a[2],0;default:return n=at.apply(void 0,[e,r].concat(t.slice(1))),i=t.slice(-2),e=i[0],r=i[1],n}})).reduce((function(t,e){return t+e}),0)}function ot(t,e,r,n,a,i,o,s,u,c){var m,f=C(t,e,r,n,a,i,o,s,u),h="number"==typeof c,l=[t,e],p=l[0],y=l[1],v=0,x=[],d=[],g=0;if(h&&c<.001)return{x:p,y:y};for(var M=0,b=f.length;M<b;M+=6){if(x=f.slice(M,M+6),d=[p,y].concat(x),g=tt.apply(void 0,d),h&&v+g>=c)return tt.apply(void 0,d.concat([c-v]));v+=g,p=(m=x.slice(-2))[0],y=m[1]}return h&&c>=v?{x:s,y:u}:v}function st(t,e,r,n,a,i,o){var s=1-o;return{x:Math.pow(s,2)*t+2*s*o*r+Math.pow(o,2)*a,y:Math.pow(s,2)*e+2*s*o*n+Math.pow(o,2)*i}}function ut(t,e,r,n,a,i,o){var s,u="number"==typeof o,c=t,m=e,f=0,h=[t,e,f],l=[t,e];if(u&&o<.001)return{x:c,y:m};for(var p=0;p<=100;p+=1){if(f+=P(l,[c=(s=st(t,e,r,n,a,i,p/100)).x,m=s.y]),l=[c,m],u&&f>=o){var y=(f-o)/(f-h[2]);return{x:l[0]*(1-y)+h[0]*y,y:l[1]*(1-y)+h[1]*y}}h=[c,m,f]}return u&&o>=f?{x:a,y:i}:f}function ct(t,e){for(var r,n,a,i=w(b(t)),o="number"==typeof e,s=0,u=!0,c=[],m="M",f=0,h=0,l=0,p=0,y=0,v=0,x=i.length;v<x;v+=1){if(c=(u="M"===(m=(a=i[v])[0]))?c:[h,l].concat(a.slice(1)),u){if(p=(r=a)[1],y=r[2],o&&e<.001)return{x:p,y:y}}else if("L"===m){if(f=q.apply(void 0,c),o&&s+f>=e)return q.apply(void 0,c.concat([e-s]));s+=f}else if("A"===m){if(f=ot.apply(void 0,c),o&&s+f>=e)return ot.apply(void 0,c.concat([e-s]));s+=f}else if("C"===m){if(f=tt.apply(void 0,c),o&&s+f>=e)return tt.apply(void 0,c.concat([e-s]));s+=f}else if("Q"===m){if(f=ut.apply(void 0,c),o&&s+f>=e)return ut.apply(void 0,c.concat([e-s]));s+=f}else if("Z"===m){if(c=[h,l,p,y],f=q.apply(void 0,c),o&&s+f>=e)return q.apply(void 0,c.concat([e-s]));s+=f}h=(n="Z"!==m?a.slice(-2):[p,y])[0],l=n[1]}return o&&e>=s?{x:h,y:l}:s}function mt(t){return ct(t)}function ft(t,e){return ct(t,e)}function ht(t,e){var r=h(t),n=[],a=[].concat(r),i=mt(a),o=a.length-1,s=0,u=0,c=r[0],m=c.slice(-2),f={x:m[0],y:m[1]};if(o<=0||!e||!Number.isFinite(e))return{segment:c,index:0,length:u,point:f,lengthAtSegment:s};if(e>=i)return u=i-(s=mt(a=r.slice(0,-1))),{segment:r[o],index:o,length:u,lengthAtSegment:s};for(;o>0;)c=a[o],u=i-(s=mt(a=a.slice(0,-1))),i=s,n.push({segment:c,index:o,length:u,lengthAtSegment:s}),o-=1;return n.find((function(t){return t.lengthAtSegment<=e}))}function lt(t,e){for(var r=w(h(t)),n=b(r),a=mt(r),i=function(t){var r=t.x-e.x,n=t.y-e.y;return r*r+n*n},o=8,s={x:0,y:0},u=0,c=s,m=0,f=1/0,l=0;l<=a;l+=o)(u=i(s=ft(n,l)))<f&&(c=s,m=l,f=u);o/=2;for(var p={x:0,y:0},y=p,v=0,x=0,d=0,g=0;o>.5;)d=i(p=ft(n,v=m-o)),g=i(y=ft(n,x=m+o)),v>=0&&d<f?(c=p,m=v,f=d):x<=a&&g<f?(c=y,m=x,f=g):o/=2;var M=ht(r,m);return{closest:c,distance:Math.sqrt(f),segment:M}}nt.prototype.toAbsolute=function(){var t=this.segments;return this.segments=p(t),this},nt.prototype.toRelative=function(){var t=this.segments;return this.segments=v(t),this},nt.prototype.toCurve=function(){var t=this.segments;return this.segments=j(t),this},nt.prototype.reverse=function(t){this.toAbsolute();var e=this.segments,r=z(this.toString()),n=r.length>1?r:0,a=n&&c(n).map((function(e,r){return t?r?O(e):h(e):O(e)})),i=[];return i=n?a.flat(1):t?e:O(e),this.segments=c(i),this},nt.prototype.normalize=function(){var t=this.segments;return this.segments=b(t),this},nt.prototype.optimize=function(){var t=this.segments;return this.segments=Z(t,this.round),this},nt.prototype.transform=function(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some((function(e){return e in t})))return this;var e={};Object.keys(t).forEach((function(r){e[r]=Array.isArray(t[r])?[].concat(t[r]):Number(t[r])}));var r=this.segments,n=e.origin;if(n&&n.length>=2){var a=n.map(Number),i=a[0],o=a[1],s=a[2],u=this.origin,c=u[0],m=u[1],f=u[2];e.origin=[Number.isNaN(i)?c:i,Number.isNaN(o)?m:o,s||f]}else e.origin=Object.assign({},this.origin);return this.segments=W(r,e),this},nt.prototype.flipX=function(){return this.transform({rotate:[180,0,0]}),this},nt.prototype.flipY=function(){return this.transform({rotate:[0,180,0]}),this},nt.prototype.toString=function(){return V(this.segments,this.round)};var pt={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};var yt={CSSMatrix:U,parsePathString:h,isPathArray:f,isCurveArray:N,isAbsoluteArray:l,isRelativeArray:y,isNormalizedArray:g,isValidPath:function(t){if("string"!=typeof t)return!1;var e=new m(t);for(o(e);e.index<e.max&&!e.err.length;)u(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:p,pathToRelative:v,pathToCurve:j,pathToString:V,getDrawDirection:function(t){return it(j(t))>=0},getPathArea:it,getPathBBox:rt,getTotalLength:mt,getPathLength:function(t){var e=0;return j(t).forEach((function(t,r,n){var a="M"!==t[0]?n[r-1].slice(-2).concat(t.slice(1)):[];e+="M"===t[0]?0:tt.apply(void 0,a)})),e},getPointAtLength:ft,getPointAtPathLength:function(t,e){return ft(t,e)},getClosestPoint:function(t,e){return lt(t,e).closest},getSegmentOfPoint:function(t,e){var r=lt(t,e).segment;return void 0!==r?r.segment:null},getPropertiesAtPoint:lt,getPropertiesAtLength:ht,getSegmentAtLength:function(t,e){var r=ht(t,e);return(void 0!==r?r:{segment:null}).segment},isPointInStroke:function(t,e){var r=lt(t,e).distance;return Math.abs(r)<.01},clonePath:c,splitPath:z,fixPath:w,roundPath:L,optimizePath:Z,reverseCurve:function(t){var e=t.slice(1).map((function(e,r,n){return r?n[r-1].slice(-2).concat(e.slice(1)):t[0].slice(1).concat(e.slice(1))})).map((function(t){return t.map((function(e,r){return t[t.length-r-2*(1-r%2)]}))})).reverse();return[["M"].concat(e[0].slice(0,2))].concat(e.map((function(t){return["C"].concat(t.slice(2))})))},reversePath:O,normalizePath:b,transformPath:W,shapeToPath:function(e,r){var n=Object.keys(pt),a=e instanceof Element;if(a&&!n.some((function(t){return e.tagName===t})))throw TypeError('shapeToPath: "'+e+'" is not SVGElement');var i,o=document.createElementNS("http://www.w3.org/2000/svg","path"),s=a?e.tagName:e.type,u={};if(u.type=s,a){var c=pt[s];c.forEach((function(t){u[t]=e.getAttribute(t)})),Object.values(e.attributes).forEach((function(t){var e=t.name,r=t.value;c.includes(e)||o.setAttribute(e,r)}))}else Object.assign(u,e);var m,f,h,l,p=t.round;return"circle"===s?i=V((f=(m=u).cx,h=m.cy,l=m.r,[["M",f-l,h],["a",l,l,0,1,0,2*l,0],["a",l,l,0,1,0,-2*l,0]]),p):"ellipse"===s?i=V(function(t){var e=t.cx,r=t.cy,n=t.rx,a=t.ry;return[["M",e-n,r],["a",n,a,0,1,0,2*n,0],["a",n,a,0,1,0,-2*n,0]]}(u),p):["polyline","polygon"].includes(s)?i=V(function(t){for(var e=[],r=t.points.split(/[\s|,]/).map(Number),n=0;n<r.length;)e.push([n?"L":"M",r[n],r[n+1]]),n+=2;return"polygon"===t.type?e.concat([["z"]]):e}(u),p):"rect"===s?i=V(function(t){var e=+t.x||0,r=+t.y||0,n=+t.width,a=+t.height,i=+t.rx,o=+t.ry;return i||o?(i=i||o,o=o||i,2*i>n&&(i-=(2*i-n)/2),2*o>a&&(o-=(2*o-a)/2),[["M",e+i,r],["h",n-2*i],["s",i,0,i,o],["v",a-2*o],["s",0,o,-i,o],["h",2*i-n],["s",-i,0,-i,-o],["v",2*o-a],["s",0,-o,i,-o]]):[["M",e,r],["h",n],["v",a],["H",e],["Z"]]}(u),p):"line"===s?i=V(function(t){return[["M",t.x1,t.y1],["L",t.x2,t.y2]]}(u),p):"glyph"===s&&(i=a?e.getAttribute("d"):e.type),!!i&&(o.setAttribute("d",i),r&&a&&(e.before(o,e),e.remove()),o)},options:t};return Object.assign(nt,yt,{Version:"0.1.24"}),nt}));
|
package/package.json
CHANGED
|
@@ -2,7 +2,8 @@ import parsePathString from '../parser/parsePathString';
|
|
|
2
2
|
import getTotalLength from './getTotalLength';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Returns the
|
|
5
|
+
* Returns the segment, its index and length as well as
|
|
6
|
+
* the length to that segment at a given length in a path.
|
|
6
7
|
*
|
|
7
8
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
8
9
|
* @param {number=} distance the given length
|
|
@@ -6,7 +6,8 @@ import fixPath from '../process/fixPath';
|
|
|
6
6
|
import normalizePath from '../process/normalizePath';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Returns the point in path closest to a given point
|
|
9
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
10
|
+
* the distance to the path stroke.
|
|
10
11
|
* @see https://bl.ocks.org/mbostock/8027637
|
|
11
12
|
*
|
|
12
13
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
@@ -70,7 +71,7 @@ export default function getPropertiesAtPoint(pathInput, point) {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
const segment = getPropertiesAtLength(path,
|
|
74
|
+
const segment = getPropertiesAtLength(path, bestLength);
|
|
74
75
|
const distance = Math.sqrt(bestDistance);
|
|
75
76
|
|
|
76
77
|
return { closest, distance, segment };
|
|
@@ -14,6 +14,8 @@ import segmentQuadFactory from './segmentQuadFactory';
|
|
|
14
14
|
* @returns {{x: number, y: number} | number} the total length or point
|
|
15
15
|
*/
|
|
16
16
|
export default function pathLengthFactory(pathInput, distance) {
|
|
17
|
+
const path = fixPath(normalizePath(pathInput));
|
|
18
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
17
19
|
let totalLength = 0;
|
|
18
20
|
let isM = true;
|
|
19
21
|
/** @type {number[]} */
|
|
@@ -25,7 +27,6 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
25
27
|
let mx = 0;
|
|
26
28
|
let my = 0;
|
|
27
29
|
let seg;
|
|
28
|
-
const path = fixPath(normalizePath(pathInput));
|
|
29
30
|
|
|
30
31
|
for (let i = 0, ll = path.length; i < ll; i += 1) {
|
|
31
32
|
seg = path[i];
|
|
@@ -39,13 +40,13 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
39
40
|
// remember mx, my for Z
|
|
40
41
|
// @ts-ignore
|
|
41
42
|
[, mx, my] = seg;
|
|
42
|
-
if (
|
|
43
|
+
if (distanceIsNumber && distance < 0.001) {
|
|
43
44
|
return { x: mx, y: my };
|
|
44
45
|
}
|
|
45
46
|
} else if (pathCommand === 'L') {
|
|
46
47
|
// @ts-ignore
|
|
47
48
|
segLen = segmentLineFactory(...data);
|
|
48
|
-
if (
|
|
49
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
49
50
|
// @ts-ignore
|
|
50
51
|
return segmentLineFactory(...data, distance - totalLength);
|
|
51
52
|
}
|
|
@@ -53,7 +54,7 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
53
54
|
} else if (pathCommand === 'A') {
|
|
54
55
|
// @ts-ignore
|
|
55
56
|
segLen = segmentArcFactory(...data);
|
|
56
|
-
if (
|
|
57
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
57
58
|
// @ts-ignore
|
|
58
59
|
return segmentArcFactory(...data, distance - totalLength);
|
|
59
60
|
}
|
|
@@ -61,7 +62,7 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
61
62
|
} else if (pathCommand === 'C') {
|
|
62
63
|
// @ts-ignore
|
|
63
64
|
segLen = segmentCubicFactory(...data);
|
|
64
|
-
if (
|
|
65
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
65
66
|
// @ts-ignore
|
|
66
67
|
return segmentCubicFactory(...data, distance - totalLength);
|
|
67
68
|
}
|
|
@@ -69,7 +70,7 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
69
70
|
} else if (pathCommand === 'Q') {
|
|
70
71
|
// @ts-ignore
|
|
71
72
|
segLen = segmentQuadFactory(...data);
|
|
72
|
-
if (
|
|
73
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
73
74
|
// @ts-ignore
|
|
74
75
|
return segmentQuadFactory(...data, distance - totalLength);
|
|
75
76
|
}
|
|
@@ -78,7 +79,7 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
78
79
|
data = [x, y, mx, my];
|
|
79
80
|
// @ts-ignore
|
|
80
81
|
segLen = segmentLineFactory(...data);
|
|
81
|
-
if (
|
|
82
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
82
83
|
// @ts-ignore
|
|
83
84
|
return segmentLineFactory(...data, distance - totalLength);
|
|
84
85
|
}
|
|
@@ -91,7 +92,7 @@ export default function pathLengthFactory(pathInput, distance) {
|
|
|
91
92
|
|
|
92
93
|
// native `getPointAtLength` behavior when the given distance
|
|
93
94
|
// is higher than total length
|
|
94
|
-
if (
|
|
95
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
95
96
|
return { x, y };
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -18,15 +18,16 @@ import arcToCubic from '../process/arcToCubic';
|
|
|
18
18
|
* @returns {{x: number, y: number} | number} the segment length or point
|
|
19
19
|
*/
|
|
20
20
|
export default function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
|
|
21
|
-
let [x, y] = [X1, Y1];
|
|
22
21
|
const cubicSeg = arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2);
|
|
22
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
23
|
+
let [x, y] = [X1, Y1];
|
|
23
24
|
const lengthMargin = 0.001;
|
|
24
25
|
let totalLength = 0;
|
|
25
26
|
let cubicSubseg = [];
|
|
26
27
|
let argsc = [];
|
|
27
28
|
let segLen = 0;
|
|
28
29
|
|
|
29
|
-
if (
|
|
30
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
30
31
|
return { x, y };
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -35,7 +36,7 @@ export default function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2
|
|
|
35
36
|
argsc = [x, y, ...cubicSubseg];
|
|
36
37
|
// @ts-ignore
|
|
37
38
|
segLen = segmentCubicFactory(...argsc);
|
|
38
|
-
if (
|
|
39
|
+
if (distanceIsNumber && totalLength + segLen >= distance) {
|
|
39
40
|
// @ts-ignore -- this is a `cubicSegment`
|
|
40
41
|
return segmentCubicFactory(...argsc, distance - totalLength);
|
|
41
42
|
}
|
|
@@ -43,7 +44,7 @@ export default function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2
|
|
|
43
44
|
[x, y] = cubicSubseg.slice(-2);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
if (
|
|
47
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
47
48
|
return { x: X2, y: Y2 };
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -44,15 +44,16 @@ function getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t) {
|
|
|
44
44
|
* @returns {{x: number, y: number} | number} the segment length or point
|
|
45
45
|
*/
|
|
46
46
|
export default function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
|
|
47
|
-
|
|
47
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
48
48
|
const lengthMargin = 0.001;
|
|
49
|
+
let x = x1; let y = y1;
|
|
49
50
|
let totalLength = 0;
|
|
50
51
|
let prev = [x1, y1, totalLength];
|
|
51
52
|
/** @type {[number, number]} */
|
|
52
53
|
let cur = [x1, y1];
|
|
53
54
|
let t = 0;
|
|
54
55
|
|
|
55
|
-
if (
|
|
56
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
56
57
|
return { x, y };
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -64,7 +65,7 @@ export default function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2,
|
|
|
64
65
|
totalLength += distanceSquareRoot(cur, [x, y]);
|
|
65
66
|
cur = [x, y];
|
|
66
67
|
|
|
67
|
-
if (
|
|
68
|
+
if (distanceIsNumber && totalLength >= distance) {
|
|
68
69
|
const dv = (totalLength - distance) / (totalLength - prev[2]);
|
|
69
70
|
|
|
70
71
|
return {
|
|
@@ -75,7 +76,7 @@ export default function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2,
|
|
|
75
76
|
prev = [x, y, totalLength];
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
if (
|
|
79
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
79
80
|
return { x: x2, y: y2 };
|
|
80
81
|
}
|
|
81
82
|
return totalLength;
|
|
@@ -20,7 +20,7 @@ export default function segmentLineFactory(x1, y1, x2, y2, distance) {
|
|
|
20
20
|
if (distance < margin) {
|
|
21
21
|
return { x: x1, y: y1 };
|
|
22
22
|
}
|
|
23
|
-
if (distance > length
|
|
23
|
+
if (distance > length) {
|
|
24
24
|
return { x: x2, y: y2 };
|
|
25
25
|
}
|
|
26
26
|
const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);
|
|
@@ -41,15 +41,16 @@ function getPointAtQuadSegmentLength(x1, y1, cx, cy, x2, y2, t) {
|
|
|
41
41
|
* @returns {{x: number, y: number} | number} the segment length or point
|
|
42
42
|
*/
|
|
43
43
|
export default function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
44
|
-
|
|
44
|
+
const distanceIsNumber = typeof distance === 'number';
|
|
45
45
|
const lengthMargin = 0.001;
|
|
46
|
+
let x = x1; let y = y1;
|
|
46
47
|
let totalLength = 0;
|
|
47
48
|
let prev = [x1, y1, totalLength];
|
|
48
49
|
/** @type {[number, number]} */
|
|
49
50
|
let cur = [x1, y1];
|
|
50
51
|
let t = 0;
|
|
51
52
|
|
|
52
|
-
if (
|
|
53
|
+
if (distanceIsNumber && distance < lengthMargin) {
|
|
53
54
|
return { x, y };
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -61,7 +62,7 @@ export default function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
|
61
62
|
totalLength += distanceSquareRoot(cur, [x, y]);
|
|
62
63
|
cur = [x, y];
|
|
63
64
|
|
|
64
|
-
if (
|
|
65
|
+
if (distanceIsNumber && totalLength >= distance) {
|
|
65
66
|
const dv = (totalLength - distance) / (totalLength - prev[2]);
|
|
66
67
|
|
|
67
68
|
return {
|
|
@@ -71,7 +72,7 @@ export default function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
|
71
72
|
}
|
|
72
73
|
prev = [x, y, totalLength];
|
|
73
74
|
}
|
|
74
|
-
if (
|
|
75
|
+
if (distanceIsNumber && distance >= totalLength) {
|
|
75
76
|
return { x: x2, y: y2 };
|
|
76
77
|
}
|
|
77
78
|
return totalLength;
|
|
@@ -871,7 +871,8 @@ declare module "svg-path-commander/src/util/getPointAtPathLength" {
|
|
|
871
871
|
}
|
|
872
872
|
declare module "svg-path-commander/src/util/getPropertiesAtLength" {
|
|
873
873
|
/**
|
|
874
|
-
* Returns the
|
|
874
|
+
* Returns the segment, its index and length as well as
|
|
875
|
+
* the length to that segment at a given length in a path.
|
|
875
876
|
*
|
|
876
877
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
877
878
|
* @param {number=} distance the given length
|
|
@@ -881,7 +882,8 @@ declare module "svg-path-commander/src/util/getPropertiesAtLength" {
|
|
|
881
882
|
}
|
|
882
883
|
declare module "svg-path-commander/src/util/getPropertiesAtPoint" {
|
|
883
884
|
/**
|
|
884
|
-
* Returns the point in path closest to a given point
|
|
885
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
886
|
+
* the distance to the path stroke.
|
|
885
887
|
* @see https://bl.ocks.org/mbostock/8027637
|
|
886
888
|
*
|
|
887
889
|
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|