svg-path-commander 0.1.10 → 0.1.11-alpha1

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.
Files changed (59) hide show
  1. package/dist/svg-path-commander.esm.js +73 -73
  2. package/dist/svg-path-commander.esm.min.js +2 -2
  3. package/dist/svg-path-commander.js +72 -72
  4. package/dist/svg-path-commander.min.js +2 -2
  5. package/package.json +2 -3
  6. package/src/convert/pathToAbsolute.js +4 -4
  7. package/src/convert/pathToCurve.js +2 -2
  8. package/src/convert/pathToRelative.js +4 -4
  9. package/src/convert/pathToString.js +1 -1
  10. package/src/parser/finalizeSegment.js +1 -1
  11. package/src/parser/parsePathString.js +2 -2
  12. package/src/parser/pathParser.js +1 -1
  13. package/src/parser/scanFlag.js +1 -1
  14. package/src/parser/scanParam.js +1 -1
  15. package/src/parser/scanSegment.js +1 -1
  16. package/src/parser/skipSpaces.js +1 -1
  17. package/src/process/clonePath.js +1 -1
  18. package/src/process/fixArc.js +1 -1
  19. package/src/process/getSVGMatrix.js +1 -1
  20. package/src/process/normalizePath.js +2 -2
  21. package/src/process/normalizeSegment.js +1 -1
  22. package/src/process/optimizePath.js +3 -3
  23. package/src/process/projection2d.js +1 -1
  24. package/src/process/reverseCurve.js +2 -2
  25. package/src/process/reversePath.js +2 -2
  26. package/src/process/roundPath.js +4 -4
  27. package/src/process/segmentToCubic.js +3 -3
  28. package/src/process/splitCubic.js +1 -1
  29. package/src/process/splitPath.js +1 -1
  30. package/src/process/transformPath.js +2 -2
  31. package/src/svg-path-commander.js +4 -4
  32. package/src/util/getCubicSize.js +1 -1
  33. package/src/util/getDrawDirection.js +1 -1
  34. package/src/util/getPathArea.js +1 -1
  35. package/src/util/getPathBBox.js +2 -2
  36. package/src/util/getPathLength.js +1 -1
  37. package/src/util/getPointAtLength.js +1 -1
  38. package/src/util/isAbsoluteArray.js +1 -1
  39. package/src/util/isCurveArray.js +1 -1
  40. package/src/util/isNormalizedArray.js +1 -1
  41. package/src/util/isPathArray.js +1 -1
  42. package/src/util/isRelativeArray.js +1 -1
  43. package/src/util/shapeToPath.js +12 -12
  44. package/types/index.d.ts +122 -48
  45. package/types/parser/finalizeSegment.d.ts +1 -1
  46. package/types/parser/scanFlag.d.ts +1 -1
  47. package/types/parser/scanParam.d.ts +1 -1
  48. package/types/parser/scanSegment.d.ts +1 -1
  49. package/types/parser/skipSpaces.d.ts +1 -1
  50. package/types/process/getSVGMatrix.d.ts +1 -1
  51. package/types/process/optimizePath.d.ts +1 -1
  52. package/types/process/projection2d.d.ts +1 -1
  53. package/types/process/segmentToCubic.d.ts +1 -1
  54. package/types/svg-path-commander.d.ts +2 -2
  55. package/types/util/getCubicSize.d.ts +1 -1
  56. package/types/util/getPathBBox.d.ts +1 -1
  57. package/types/util/shapeToPath.d.ts +6 -6
  58. package/index.js +0 -3
  59. package/rollup.config.js +0 -58
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVGPathCommander v0.1.10 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v0.1.11alpha1 (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
  */
@@ -23,7 +23,7 @@ const paramsCount = {
23
23
  /**
24
24
  * Breaks the parsing of a pathString once a segment is finalized.
25
25
  *
26
- * @param {svgpcNS.pathParser} path the `PathParser` instance
26
+ * @param {SVGPathCommander.PathParser} path the `PathParser` instance
27
27
  */
28
28
  function finalizeSegment(path) {
29
29
  let pathCommand = path.pathValue[path.segmentStart];
@@ -53,7 +53,7 @@ const invalidPathValue = 'Invalid path value';
53
53
  * Validates an A (arc-to) specific path command value.
54
54
  * Usually a `large-arc-flag` or `sweep-flag`.
55
55
  *
56
- * @param {svgpcNS.pathParser} path the `PathParser` instance
56
+ * @param {SVGPathCommander.PathParser} path the `PathParser` instance
57
57
  */
58
58
  function scanFlag(path) {
59
59
  const { index } = path;
@@ -88,7 +88,7 @@ function isDigit(code) {
88
88
  * Validates every character of the path string,
89
89
  * every path command, negative numbers or floating point numbers.
90
90
  *
91
- * @param {svgpcNS.pathParser} path the `PathParser` instance
91
+ * @param {SVGPathCommander.PathParser} path the `PathParser` instance
92
92
  */
93
93
  function scanParam(path) {
94
94
  const { max, pathValue, index: start } = path;
@@ -200,7 +200,7 @@ function isSpace(ch) {
200
200
  * path string every time it encounters any kind of
201
201
  * space character.
202
202
  *
203
- * @param {svgpcNS.pathParser} path the `PathParser` instance
203
+ * @param {SVGPathCommander.PathParser} path the `PathParser` instance
204
204
  */
205
205
  function skipSpaces(path) {
206
206
  const { pathValue, max } = path;
@@ -264,7 +264,7 @@ function isArcCommand(code) {
264
264
  * Scans every character in the path string to determine
265
265
  * where a segment starts and where it ends.
266
266
  *
267
- * @param {svgpcNS.pathParser} path the `PathParser` instance
267
+ * @param {SVGPathCommander.PathParser} path the `PathParser` instance
268
268
  */
269
269
  function scanSegment(path) {
270
270
  const { max, pathValue, index } = path;
@@ -324,7 +324,7 @@ function scanSegment(path) {
324
324
  /**
325
325
  * Returns a clone of an existing `pathArray`.
326
326
  *
327
- * @param {svgpcNS.pathArray | any[] | string} path the source `pathArray`
327
+ * @param {SVGPathCommander.pathArray | any[] | string} path the source `pathArray`
328
328
  * @returns {any} the cloned `pathArray`
329
329
  */
330
330
  function clonePath(path) {
@@ -342,7 +342,7 @@ function clonePath(path) {
342
342
  * @param {string} pathString
343
343
  */
344
344
  function PathParser(pathString) {
345
- /** @type {svgpcNS.pathArray} */
345
+ /** @type {SVGPathCommander.pathArray} */
346
346
  this.segments = [];
347
347
  /** @type {string} */
348
348
  this.pathValue = pathString;
@@ -363,7 +363,7 @@ function PathParser(pathString) {
363
363
  /**
364
364
  * Iterates an array to check if it's an actual `pathArray`.
365
365
  *
366
- * @param {string | svgpcNS.pathArray} path the `pathArray` to be checked
366
+ * @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
367
367
  * @returns {boolean} iteration result
368
368
  */
369
369
  function isPathArray(path) {
@@ -377,8 +377,8 @@ function isPathArray(path) {
377
377
  * Parses a path string value and returns an array
378
378
  * of segments we like to call `pathArray`.
379
379
  *
380
- * @param {svgpcNS.pathArray | string} pathInput the string to be parsed
381
- * @returns {svgpcNS.pathArray} the resulted `pathArray`
380
+ * @param {SVGPathCommander.pathArray | string} pathInput the string to be parsed
381
+ * @returns {SVGPathCommander.pathArray} the resulted `pathArray`
382
382
  */
383
383
  function parsePathString(pathInput) {
384
384
  if (isPathArray(pathInput)) {
@@ -411,7 +411,7 @@ function parsePathString(pathInput) {
411
411
  * Iterates an array to check if it's a `pathArray`
412
412
  * with all absolute values.
413
413
  *
414
- * @param {string | svgpcNS.pathArray} path the `pathArray` to be checked
414
+ * @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
415
415
  * @returns {boolean} iteration result
416
416
  */
417
417
  function isAbsoluteArray(path) {
@@ -423,8 +423,8 @@ function isAbsoluteArray(path) {
423
423
  * Parses a path string value or object and returns an array
424
424
  * of segments, all converted to absolute values.
425
425
  *
426
- * @param {svgpcNS.pathArray | string} pathInput the path string | object
427
- * @returns {svgpcNS.pathArray} the resulted `pathArray` with absolute values
426
+ * @param {SVGPathCommander.pathArray | string} pathInput the path string | object
427
+ * @returns {SVGPathCommander.pathArray} the resulted `pathArray` with absolute values
428
428
  */
429
429
  function pathToAbsolute(pathInput) {
430
430
  if (isAbsoluteArray(pathInput)) {
@@ -433,7 +433,7 @@ function pathToAbsolute(pathInput) {
433
433
 
434
434
  const path = parsePathString(pathInput);
435
435
  const ii = path.length;
436
- /** @type {svgpcNS.pathArray} */
436
+ /** @type {SVGPathCommander.pathArray} */
437
437
  const resultArray = [];
438
438
  let x = 0;
439
439
  let y = 0;
@@ -454,7 +454,7 @@ function pathToAbsolute(pathInput) {
454
454
  const segment = path[i];
455
455
  const [pathCommand] = segment;
456
456
  const absCommand = pathCommand.toUpperCase();
457
- /** @type {svgpcNS.pathSegment} */
457
+ /** @type {SVGPathCommander.pathSegment} */
458
458
  // @ts-ignore -- trust me
459
459
  const absoluteSegment = [];
460
460
  let newSeg = [];
@@ -523,7 +523,7 @@ function pathToAbsolute(pathInput) {
523
523
  * Iterates an array to check if it's a `pathArray`
524
524
  * with relative values.
525
525
  *
526
- * @param {string | svgpcNS.pathArray} path the `pathArray` to be checked
526
+ * @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
527
527
  * @returns {boolean} iteration result
528
528
  */
529
529
  function isRelativeArray(path) {
@@ -535,8 +535,8 @@ function isRelativeArray(path) {
535
535
  * Parses a path string value or object and returns an array
536
536
  * of segments, all converted to relative values.
537
537
  *
538
- * @param {string | svgpcNS.pathArray} pathInput the path string | object
539
- * @returns {svgpcNS.pathArray} the resulted `pathArray` with relative values
538
+ * @param {string | SVGPathCommander.pathArray} pathInput the path string | object
539
+ * @returns {SVGPathCommander.pathArray} the resulted `pathArray` with relative values
540
540
  */
541
541
  function pathToRelative(pathInput) {
542
542
  if (isRelativeArray(pathInput)) {
@@ -545,7 +545,7 @@ function pathToRelative(pathInput) {
545
545
 
546
546
  const path = parsePathString(pathInput);
547
547
  const ii = path.length;
548
- /** @type {svgpcNS.pathArray} */
548
+ /** @type {SVGPathCommander.pathArray} */
549
549
  const resultArray = [];
550
550
  let x = 0;
551
551
  let y = 0;
@@ -566,7 +566,7 @@ function pathToRelative(pathInput) {
566
566
  const segment = path[i];
567
567
  const [pathCommand] = segment;
568
568
  const relativeCommand = pathCommand.toLowerCase();
569
- /** @type {svgpcNS.pathSegment} */
569
+ /** @type {SVGPathCommander.pathSegment} */
570
570
  // @ts-ignore -- trust me DON'T CHANGE
571
571
  const relativeSegment = [];
572
572
  let newSeg = [];
@@ -631,9 +631,9 @@ function pathToRelative(pathInput) {
631
631
  * Rounds the values of a `pathArray` instance to
632
632
  * a specified amount of decimals and returns it.
633
633
  *
634
- * @param {svgpcNS.pathArray} path the source `pathArray`
634
+ * @param {SVGPathCommander.pathArray} path the source `pathArray`
635
635
  * @param {number | boolean | null} round the amount of decimals to round numbers to
636
- * @returns {svgpcNS.pathArray} the resulted `pathArray` with rounded values
636
+ * @returns {SVGPathCommander.pathArray} the resulted `pathArray` with rounded values
637
637
  */
638
638
  function roundPath(path, round) {
639
639
  const { round: defaultRound, decimals: defaultDecimals } = SVGPCO;
@@ -643,10 +643,10 @@ function roundPath(path, round) {
643
643
  if (round === false || (!defaultRound && !decimalsOption)) return clonePath(path);
644
644
 
645
645
  const dc = 10 ** decimalsOption;
646
- /** @type {svgpcNS.pathArray} */
646
+ /** @type {SVGPathCommander.pathArray} */
647
647
  const result = [];
648
648
  const pl = path.length;
649
- /** @type {svgpcNS.pathSegment} */
649
+ /** @type {SVGPathCommander.pathSegment} */
650
650
  let segment;
651
651
  /** @type {number} */
652
652
  let n = 0;
@@ -672,7 +672,7 @@ function roundPath(path, round) {
672
672
  * Returns a valid `d` attribute string value created
673
673
  * by rounding values and concatenating the `pathArray` segments.
674
674
  *
675
- * @param {svgpcNS.pathArray} path the `pathArray` object
675
+ * @param {SVGPathCommander.pathArray} path the `pathArray` object
676
676
  * @param {any} round amount of decimals to round values to
677
677
  * @returns {string} the concatenated path string
678
678
  */
@@ -718,7 +718,7 @@ function shorthandToCubic(x1, y1, x2, y2, prevCommand) {
718
718
  /**
719
719
  * Normalizes a single segment of a `pathArray` object.
720
720
  *
721
- * @param {svgpcNS.pathSegment} segment the segment object
721
+ * @param {SVGPathCommander.pathSegment} segment the segment object
722
722
  * @param {any} params the coordinates of the previous segment
723
723
  * @param {string} prevCommand the path command of the previous segment
724
724
  * @returns {any} the normalized segment
@@ -761,7 +761,7 @@ function normalizeSegment(segment, params, prevCommand) {
761
761
  * with all segments are in non-shorthand notation
762
762
  * with absolute values.
763
763
  *
764
- * @param {string | svgpcNS.pathArray} path the `pathArray` to be checked
764
+ * @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
765
765
  * @returns {boolean} iteration result
766
766
  */
767
767
  function isNormalizedArray(path) {
@@ -776,8 +776,8 @@ function isNormalizedArray(path) {
776
776
  * * convert segments to absolute values
777
777
  * * convert shorthand path commands to their non-shorthand notation
778
778
  *
779
- * @param {string | svgpcNS.pathArray} pathInput the string to be parsed or 'pathArray'
780
- * @returns {svgpcNS.pathArray} the normalized `pathArray`
779
+ * @param {string | SVGPathCommander.pathArray} pathInput the string to be parsed or 'pathArray'
780
+ * @returns {SVGPathCommander.pathArray} the normalized `pathArray`
781
781
  */
782
782
  function normalizePath(pathInput) { // path|pathString
783
783
  if (Array.isArray(pathInput) && isNormalizedArray(pathInput)) {
@@ -821,8 +821,8 @@ function normalizePath(pathInput) { // path|pathString
821
821
  * Reverses all segments and their values of a `pathArray`
822
822
  * and returns a new instance.
823
823
  *
824
- * @param {svgpcNS.pathArray} pathInput the source `pathArray`
825
- * @returns {svgpcNS.pathArray} the reversed `pathArray`
824
+ * @param {SVGPathCommander.pathArray} pathInput the source `pathArray`
825
+ * @returns {SVGPathCommander.pathArray} the reversed `pathArray`
826
826
  */
827
827
  function reversePath(pathInput) {
828
828
  const absolutePath = pathToAbsolute(pathInput);
@@ -911,7 +911,7 @@ function reversePath(pathInput) {
911
911
  * In the process, values are converted to absolute
912
912
  * for visual consistency.
913
913
  *
914
- * @param {svgpcNS.pathArray | string} pathInput the cubic-bezier parameters
914
+ * @param {SVGPathCommander.pathArray | string} pathInput the cubic-bezier parameters
915
915
  * @return {string[]} an array with all sub-path strings
916
916
  */
917
917
  function splitPath(pathInput) {
@@ -928,9 +928,9 @@ function splitPath(pathInput) {
928
928
  * * create a new `pathArray` with elements with shortest segments
929
929
  * from absolute and relative `pathArray`s
930
930
  *
931
- * @param {string | svgpcNS.pathArray} pathInput a string or `pathArray`
932
- * @param {number | null} round the amount of decimals to round values to
933
- * @returns {svgpcNS.pathArray} the optimized `pathArray`
931
+ * @param {string | SVGPathCommander.pathArray} pathInput a string or `pathArray`
932
+ * @param {number | boolean | null} round the amount of decimals to round values to
933
+ * @returns {SVGPathCommander.pathArray} the optimized `pathArray`
934
934
  */
935
935
  function optimizePath(pathInput, round) {
936
936
  const absolutePath = roundPath(pathToAbsolute(pathInput), round);
@@ -1176,9 +1176,9 @@ function lineToCubic(x1, y1, x2, y2) {
1176
1176
  /**
1177
1177
  * Converts any segment to C (cubic-bezier).
1178
1178
  *
1179
- * @param {svgpcNS.pathSegment} segment the source segment
1180
- * @param {svgpcNS.parserParams} params the source segment parameters
1181
- * @returns {svgpcNS.pathSegment} the cubic-bezier segment
1179
+ * @param {SVGPathCommander.pathSegment} segment the source segment
1180
+ * @param {SVGPathCommander.parserParams} params the source segment parameters
1181
+ * @returns {SVGPathCommander.pathSegment} the cubic-bezier segment
1182
1182
  */
1183
1183
  function segmentToCubic(segment, params) {
1184
1184
  if (!'TQ'.includes(segment[0])) {
@@ -1214,7 +1214,7 @@ function segmentToCubic(segment, params) {
1214
1214
  /**
1215
1215
  * Splits an extended A (arc-to) segment into two cubic-bezier segments.
1216
1216
  *
1217
- * @param {svgpcNS.pathArray} path the `pathArray` this segment belongs to
1217
+ * @param {SVGPathCommander.pathArray} path the `pathArray` this segment belongs to
1218
1218
  * @param {string[]} allPathCommands all previous path commands
1219
1219
  * @param {Number} i the index of the segment
1220
1220
  */
@@ -2040,7 +2040,7 @@ CSSMatrix.fromString = fromString;
2040
2040
  /**
2041
2041
  * Returns a transformation matrix to apply to `<path>` elements.
2042
2042
  *
2043
- * @param {svgpcNS.transformObject} transform the `transformObject`
2043
+ * @param {SVGPathCommander.transformObject} transform the `transformObject`
2044
2044
  * @returns {CSSMatrix} a new transformation matrix
2045
2045
  */
2046
2046
  function getSVGMatrix(transform) {
@@ -2176,7 +2176,7 @@ function transformEllipse(m, rx, ry, ax) {
2176
2176
  * Details =>
2177
2177
  * https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel
2178
2178
  *
2179
- * @param {svgpcNS.CSSMatrix} m the transformation matrix
2179
+ * @param {SVGPathCommander.CSSMatrix} m the transformation matrix
2180
2180
  * @param {Number[]} point2D the initial [x,y] coordinates
2181
2181
  * @param {number[]} origin the initial [x,y] coordinates
2182
2182
  * @returns {Number[]} the projected [x,y] coordinates
@@ -2204,9 +2204,9 @@ function projection2d(m, point2D, origin) {
2204
2204
  * Since *SVGElement* doesn't support 3D transformation, this function
2205
2205
  * creates a 2D projection of the <path> element.
2206
2206
  *
2207
- * @param {svgpcNS.pathArray} path the `pathArray` to apply transformation
2207
+ * @param {SVGPathCommander.pathArray} path the `pathArray` to apply transformation
2208
2208
  * @param {any} transform the transform functions `Object`
2209
- * @returns {svgpcNS.pathArray} the resulted `pathArray`
2209
+ * @returns {SVGPathCommander.pathArray} the resulted `pathArray`
2210
2210
  */
2211
2211
  function transformPath(path, transform) {
2212
2212
  let x = 0; let y = 0; let i; let j; let ii; let jj; let lx; let ly; let te;
@@ -2338,7 +2338,7 @@ function transformPath(path, transform) {
2338
2338
  * @param {number} c2y the second control point Y
2339
2339
  * @param {number} p2x the ending point X
2340
2340
  * @param {number} p2y the ending point Y
2341
- * @returns {svgpcNS.segmentLimits} the length of the cubic-bezier segment
2341
+ * @returns {SVGPathCommander.segmentLimits} the length of the cubic-bezier segment
2342
2342
  */
2343
2343
  function getCubicSize(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
2344
2344
  let a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x);
@@ -2394,7 +2394,7 @@ function getCubicSize(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
2394
2394
  * Iterates an array to check if it's a `pathArray`
2395
2395
  * with all C (cubic bezier) segments.
2396
2396
  *
2397
- * @param {string | svgpcNS.pathArray} path the `Array` to be checked
2397
+ * @param {string | SVGPathCommander.pathArray} path the `Array` to be checked
2398
2398
  * @returns {boolean} iteration result
2399
2399
  */
2400
2400
  function isCurveArray(path) {
@@ -2406,8 +2406,8 @@ function isCurveArray(path) {
2406
2406
  * Parses a path string value or 'pathArray' and returns a new one
2407
2407
  * in which all segments are converted to cubic-bezier.
2408
2408
  *
2409
- * @param {string | svgpcNS.pathArray} pathInput the string to be parsed or object
2410
- * @returns {svgpcNS.pathArray} the resulted `pathArray` converted to cubic-bezier
2409
+ * @param {string | SVGPathCommander.pathArray} pathInput the string to be parsed or object
2410
+ * @returns {SVGPathCommander.pathArray} the resulted `pathArray` converted to cubic-bezier
2411
2411
  */
2412
2412
  function pathToCurve(pathInput) {
2413
2413
  if (isCurveArray(pathInput)) {
@@ -2445,8 +2445,8 @@ function pathToCurve(pathInput) {
2445
2445
  /**
2446
2446
  * Returns the bounding box of a shape.
2447
2447
  *
2448
- * @param {svgpcNS.pathArray} path the shape `pathArray`
2449
- * @returns {svgpcNS.pathBBox} the length of the cubic-bezier segment
2448
+ * @param {SVGPathCommander.pathArray} path the shape `pathArray`
2449
+ * @returns {SVGPathCommander.pathBBox} the length of the cubic-bezier segment
2450
2450
  */
2451
2451
  function getPathBBox(path) {
2452
2452
  if (!path) {
@@ -2527,7 +2527,7 @@ function getCubicSegArea(x0, y0, x1, y1, x2, y2, x3, y3) {
2527
2527
  *
2528
2528
  * => https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
2529
2529
  *
2530
- * @param {svgpcNS.pathArray} path the shape `pathArray`
2530
+ * @param {SVGPathCommander.pathArray} path the shape `pathArray`
2531
2531
  * @returns {number} the length of the cubic-bezier segment
2532
2532
  */
2533
2533
  function getPathArea(path) {
@@ -2611,7 +2611,7 @@ function getSegCubicLength(x1, y1, x2, y2, x3, y3, x4, y4, z) {
2611
2611
  * or the equivalent to `shape.getTotalLength()`
2612
2612
  * pathToCurve version
2613
2613
  *
2614
- * @param {svgpcNS.pathArray} path the ending point Y
2614
+ * @param {SVGPathCommander.pathArray} path the ending point Y
2615
2615
  * @returns {number} the shape total length
2616
2616
  */
2617
2617
  function getPathLength(path) {
@@ -2628,7 +2628,7 @@ function getPathLength(path) {
2628
2628
  * Check if a path is drawn clockwise and returns true if so,
2629
2629
  * false otherwise.
2630
2630
  *
2631
- * @param {string | svgpcNS.pathArray} path the path string or `pathArray`
2631
+ * @param {string | SVGPathCommander.pathArray} path the path string or `pathArray`
2632
2632
  * @returns {boolean} true when clockwise or false if not
2633
2633
  */
2634
2634
  function getDrawDirection(path) {
@@ -2638,7 +2638,7 @@ function getDrawDirection(path) {
2638
2638
  /**
2639
2639
  * Returns [x,y] coordinates of a point at a given length of a shape.
2640
2640
  *
2641
- * @param {string | svgpcNS.pathArray} path the `pathArray` to look into
2641
+ * @param {string | SVGPathCommander.pathArray} path the `pathArray` to look into
2642
2642
  * @param {number} length the length of the shape to look at
2643
2643
  * @returns {number[]} the requested [x,y] coordinates
2644
2644
  */
@@ -2706,8 +2706,8 @@ const shapeParams = {
2706
2706
  /**
2707
2707
  * Returns a new `pathArray` from line attributes.
2708
2708
  *
2709
- * @param {svgpcNS.lineAttr} attr shape configuration
2710
- * @return {svgpcNS.pathArray} a new line `pathArray`
2709
+ * @param {SVGPathCommander.lineAttr} attr shape configuration
2710
+ * @return {SVGPathCommander.pathArray} a new line `pathArray`
2711
2711
  */
2712
2712
  function getLinePath(attr) {
2713
2713
  const {
@@ -2719,11 +2719,11 @@ function getLinePath(attr) {
2719
2719
  /**
2720
2720
  * Returns a new `pathArray` like from polyline/polygon attributes.
2721
2721
  *
2722
- * @param {svgpcNS.polyAttr} attr shape configuration
2723
- * @return {svgpcNS.pathArray} a new polygon/polyline `pathArray`
2722
+ * @param {SVGPathCommander.polyAttr} attr shape configuration
2723
+ * @return {SVGPathCommander.pathArray} a new polygon/polyline `pathArray`
2724
2724
  */
2725
2725
  function getPolyPath(attr) {
2726
- /** @type {svgpcNS.pathArray} */
2726
+ /** @type {SVGPathCommander.pathArray} */
2727
2727
  const pathArray = [];
2728
2728
  const points = attr.points.split(/[\s|,]/).map(Number);
2729
2729
 
@@ -2739,8 +2739,8 @@ function getPolyPath(attr) {
2739
2739
  /**
2740
2740
  * Returns a new `pathArray` from circle attributes.
2741
2741
  *
2742
- * @param {svgpcNS.circleAttr} attr shape configuration
2743
- * @return {svgpcNS.pathArray} a circle `pathArray`
2742
+ * @param {SVGPathCommander.circleAttr} attr shape configuration
2743
+ * @return {SVGPathCommander.pathArray} a circle `pathArray`
2744
2744
  */
2745
2745
  function getCirclePath(attr) {
2746
2746
  const {
@@ -2757,8 +2757,8 @@ function getCirclePath(attr) {
2757
2757
  /**
2758
2758
  * Returns a new `pathArray` from ellipse attributes.
2759
2759
  *
2760
- * @param {svgpcNS.ellipseAttr} attr shape configuration
2761
- * @return {svgpcNS.pathArray} an ellipse `pathArray`
2760
+ * @param {SVGPathCommander.ellipseAttr} attr shape configuration
2761
+ * @return {SVGPathCommander.pathArray} an ellipse `pathArray`
2762
2762
  */
2763
2763
  function getEllipsePath(attr) {
2764
2764
  const {
@@ -2775,8 +2775,8 @@ function getEllipsePath(attr) {
2775
2775
  /**
2776
2776
  * Returns a new `pathArray` like from rect attributes.
2777
2777
  *
2778
- * @param {svgpcNS.rectAttr} attr object with properties above
2779
- * @return {svgpcNS.pathArray} a new `pathArray` from `<rect>` attributes
2778
+ * @param {SVGPathCommander.rectAttr} attr object with properties above
2779
+ * @return {SVGPathCommander.pathArray} a new `pathArray` from `<rect>` attributes
2780
2780
  */
2781
2781
  function getRectanglePath(attr) {
2782
2782
  const x = +attr.x || 0;
@@ -2824,7 +2824,7 @@ function getRectanglePath(attr) {
2824
2824
  * The newly created `<path>` element keeps all non-specific
2825
2825
  * attributes like `class`, `fill`, etc.
2826
2826
  *
2827
- * @param {svgpcNS.shapeTypes} element target shape
2827
+ * @param {SVGPathCommander.shapeTypes} element target shape
2828
2828
  * @param {boolean} replace option to replace target
2829
2829
  * @return {?SVGPathElement} the newly created `<path>` element
2830
2830
  */
@@ -2879,8 +2879,8 @@ function shapeToPath(element, replace) {
2879
2879
  * Reverses all segments and their values from a `pathArray`
2880
2880
  * which consists of only C (cubic-bezier) path commands.
2881
2881
  *
2882
- * @param {svgpcNS.pathArray} path the source `pathArray`
2883
- * @returns {svgpcNS.pathArray} the reversed `pathArray`
2882
+ * @param {SVGPathCommander.pathArray} path the source `pathArray`
2883
+ * @returns {SVGPathCommander.pathArray} the reversed `pathArray`
2884
2884
  */
2885
2885
  function reverseCurve(path) {
2886
2886
  const rotatedCurve = path.slice(1)
@@ -2896,7 +2896,7 @@ function reverseCurve(path) {
2896
2896
  .concat(rotatedCurve.map((x) => ['C'].concat(x.slice(2))));
2897
2897
  }
2898
2898
 
2899
- var version = "0.1.10";
2899
+ var version = "0.1.11alpha1";
2900
2900
 
2901
2901
  // @ts-ignore
2902
2902
 
@@ -2948,7 +2948,7 @@ class SVGPathCommander {
2948
2948
  /**
2949
2949
  * @constructor
2950
2950
  * @param {string} pathValue the path string
2951
- * @param {any} config instance options
2951
+ * @param {SVGPathCommander.options} config instance options
2952
2952
  */
2953
2953
  constructor(pathValue, config) {
2954
2954
  const options = config || {};
@@ -2965,7 +2965,7 @@ class SVGPathCommander {
2965
2965
  this.round = decimals;
2966
2966
  // ZERO | FALSE will disable rounding numbers
2967
2967
 
2968
- /** @type {svgpcNS.pathArray} */
2968
+ /** @type {SVGPathCommander.pathArray} */
2969
2969
  this.segments = parsePathString(pathValue);
2970
2970
 
2971
2971
  /** * @type {string} */
@@ -3006,7 +3006,7 @@ class SVGPathCommander {
3006
3006
  const split = splitPath(this.toString());
3007
3007
  const subPath = split.length > 1 ? split : 0;
3008
3008
  /**
3009
- * @param {svgpcNS.pathArray} x
3009
+ * @param {import("../types").pathArray} x
3010
3010
  * @param {number} i
3011
3011
  */
3012
3012
  const reverser = (x, i) => {
@@ -3057,7 +3057,7 @@ class SVGPathCommander {
3057
3057
 
3058
3058
  /**
3059
3059
  * Transform path using values from an `Object` defined as `transformObject`.
3060
- * @see svgpcNS.transformObject for a quick refference
3060
+ * @see SVGPathCommander.transformObject for a quick refference
3061
3061
  *
3062
3062
  * @param {Object.<string, (number | number[])>} source a `transformObject`as described above
3063
3063
  * @public
@@ -1,2 +1,2 @@
1
- // SVGPathCommander v0.1.10 | thednp © 2021 | MIT-License
2
- const t={origin:[0,0],decimals:4,round:1},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].concat(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 a(t){const{max:e,pathValue:n,index:r}=t;let a,i=r,c=!1,o=!1,m=!1,l=!1;if(i>=e)t.err=`Invalid path value at ${i}: missing param ${n[i]}`;else if(a=n.charCodeAt(i),43!==a&&45!==a||(i+=1,a=i<e?n.charCodeAt(i):0),s(a)||46===a){if(46!==a){if(c=48===a,i+=1,a=i<e?n.charCodeAt(i):0,c&&i<e&&a&&s(a))return void(t.err=`Invalid path value at index ${r}: ${n[r]} illegal number`);for(;i<e&&s(n.charCodeAt(i));)i+=1,o=!0;a=i<e?n.charCodeAt(i):0}if(46===a){for(l=!0,i+=1;s(n.charCodeAt(i));)i+=1,m=!0;a=i<e?n.charCodeAt(i):0}if(101===a||69===a){if(l&&!o&&!m)return void(t.err=`Invalid path value at index ${i}: ${n[i]} invalid float exponent`);if(i+=1,a=i<e?n.charCodeAt(i):0,43!==a&&45!==a||(i+=1),!(i<e&&s(n.charCodeAt(i))))return void(t.err=`Invalid path value at index ${i}: ${n[i]} invalid float exponent`);for(;i<e&&s(n.charCodeAt(i));)i+=1}t.index=i,t.param=+t.pathValue.slice(r,i)}else t.err=`Invalid path value at index ${i}: ${n[i]} is not a number`}function i(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 c(t){return t>=48&&t<=57||43===t||45===t||46===t}function o(t){const{max:s,pathValue:o,index:m}=t,l=o.charCodeAt(m),u=e[o[m].toLowerCase()];if(t.segmentStart=m,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}}(l))if(t.index+=1,i(t),t.data=[],u){for(;;){for(let e=u;e>0;e-=1){if(97!=(32|l)||3!==e&&4!==e?a(t):r(t),t.err.length)return;t.data.push(t.param),i(t),t.index<s&&44===o.charCodeAt(t.index)&&(t.index+=1,i(t))}if(t.index>=t.max)break;if(!c(o.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`Invalid path value: ${o[m]} not a path command`}function m(t){return Array.isArray(t)?t.map(t=>Array.isArray(t)?m(t):Number.isNaN(+t)?t:+t):t}function l(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function u(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&/[achlmqstvz]/gi.test(n)})}function h(t){if(u(t))return m(t);const e=new l(""+t);for(i(e);e.index<e.max&&!e.err.length;)o(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 Array.isArray(t)&&u(t)&&t.every(t=>t[0]===t[0].toUpperCase())}function y(t){if(f(t))return m(t);const e=h(t),n=e.length,r=[];let s=0,a=0,i=0,c=0,o=0;"M"===e[0][0]&&(s=+e[0][1],a=+e[0][2],i=s,c=a,o+=1,r.push(["M",s,a]));for(let t=o;t<n;t+=1){const n=e[t],[o]=n,m=o.toUpperCase(),l=[];let u=[];if(o!==m)switch(l[0]=m,m){case"A":u=n.slice(1,-2).concat([+n[6]+s,+n[7]+a]);for(let t=0;t<u.length;t+=1)l.push(u[t]);break;case"V":l[1]=+n[1]+a;break;case"H":l[1]=+n[1]+s;break;default:"M"===m&&(i=+n[1]+s,c=+n[2]+a);for(let t=1;t<n.length;t+=1)l.push(+n[t]+(t%2?s:a))}else for(let t=0;t<n.length;t+=1)l.push(n[t]);r.push(l);const h=l.length;switch(m){case"Z":s=i,a=c;break;case"H":s=+l[1];break;case"V":a=+l[1];break;default:s=+l[h-2],a=+l[h-1],"M"===m&&(i=s,c=a)}}return r}function p(t){return Array.isArray(t)&&u(t)&&t.slice(1).every(t=>t[0]===t[0].toLowerCase())}function x(t){if(p(t))return m(t);const e=h(t),n=e.length,r=[];let s=0,a=0,i=0,c=0,o=0;"M"===e[0][0]&&(s=+e[0][1],a=+e[0][2],i=s,c=a,o+=1,r.push(["M",s,a]));for(let t=o;t<n;t+=1){const n=e[t],[o]=n,m=o.toLowerCase(),l=[];let u=[];if(o!==m)switch(l[0]=m,m){case"a":u=n.slice(1,-2).concat([+n[6]-s,+n[7]-a]);for(let t=0;t<u.length;t+=1)l.push(u[t]);break;case"v":l[1]=+n[1]-a;break;default:for(let t=1;t<n.length;t+=1)l.push(+n[t]-(t%2?s:a));"m"===m&&(i=+n[1],c=+n[2])}else{"m"===o&&(i=+n[1]+s,c=+n[2]+a);for(let t=0;t<n.length;t+=1)l.push(n[t])}r.push(l);const h=l.length;switch(l[0]){case"z":s=i,a=c;break;case"h":s+=+l[h-1];break;case"v":a+=+l[h-1];break;default:s+=+r[t][h-2],a+=+r[t][h-1]}}return r}function d(e,n){const{round:r,decimals:s}=t,a=n&&!Number.isNaN(+n)?+n:r&&s;if(!1===n||!r&&!a)return m(e);const i=10**a,c=[],o=e.length;let l,u=0,h=[];for(let t=0;t<o;t+=1){h=e[t],l=[""];for(let t=0;t<h.length;t+=1)t?(u=+h[t],l.push(t&&u%1!=0?Math.round(u*i)/i:u)):l[t]=h[t];c.push(l)}return c}function g(t,e){return d(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function M(t,e,n){const[r]=t,s=t.slice(1);let a=t.slice();if("TQ".includes(t[0])||(e.qx=null,e.qy=null),"H"===r)a=["L",t[1],e.y1];else if("V"===r)a=["L",e.x1,t[1]];else if("S"===r){const{x1:t,y1:r}=function(t,e,n,r,s){return"CS".indexOf(s)>-1?{x1:2*t-n,y1:2*e-r}:{x1:t,y1:e}}(e.x1,e.y1,e.x2,e.y2,n);e.x1=t,e.y1=r,a=["C",t,r].concat(s)}else if("T"===r){const{qx:t,qy:r}=function(t,e,n,r,s){return"QT".indexOf(s)>-1?{qx:2*t-n,qy:2*e-r}:{qx:t,qy:e}}(e.x1,e.y1,e.qx,e.qy,n);e.qx=t,e.qy=r,a=["Q",t,r].concat(s)}else if("Q"===r){const[t,n]=s;e.qx=t,e.qy=n}return a}function b(t){return Array.isArray(t)&&u(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"ACLMQZ".includes(t[0])})}function A(t){if(Array.isArray(t)&&b(t))return m(t);const e=y(t),n={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null},r=[],s=e.length;let a,i,c="",o="";for(let t=0;t<s;t+=1)[c]=e[t],r[t]=c,t&&(o=r[t-1]),e[t]=M(e[t],n,o),a=e[t],i=a.length,n.x1=+a[i-2],n.y1=+a[i-1],n.x2=+a[i-4]||n.x1,n.y2=+a[i-3]||n.y1;return e}function w(t){const e=y(t),n="Z"===e.slice(-1)[0][0];let r=[],s=0;return r=A(e).map((t,n)=>(s=t.length,{seg:e[n],n:t,c:e[n][0],x:t[s-2],y:t[s-1]})).map((t,e,r)=>{const s=t.seg,a=t.n,i=e&&r[e-1],c=r[e+1]&&r[e+1],o=t.c,m=r.length,l=e?r[e-1].x:r[m-1].x,u=e?r[e-1].y:r[m-1].y;let h=[];switch(o){case"M":h=n?["Z"]:[o,l,u];break;case"A":h=s.slice(0,-3).concat([1===s[5]?0:1,l,u]);break;case"C":h=c&&"S"===c.c?["S",s[1],s[2],l,u]:[o,s[3],s[4],s[1],s[2],l,u];break;case"S":h=i&&"CS".indexOf(i.c)>-1&&(!c||c&&"S"!==c.c)?["C",a[3],a[4],a[1],a[2],l,u]:[o,a[1],a[2],l,u];break;case"Q":h=c&&"T"===c.c?["T",l,u]:s.slice(0,-2).concat([l,u]);break;case"T":h=i&&"QT".indexOf(i.c)>-1&&(!c||c&&"T"!==c.c)?["Q",a[1],a[2],l,u]:[o,l,u];break;case"Z":h=["M",l,u];break;case"H":h=[o,l];break;case"V":h=[o,u];break;default:h=s.slice(0,-2).concat([l,u])}return h}),n?r.reverse():[r[0]].concat(r.slice(1).reverse())}function v(t){return g(y(t),0).replace(/(m|M)/g,"|$1").split("|").map(t=>t.trim()).filter(t=>t)}function N(t,e){const n=d(y(t),e),r=d(x(t),e);return n.map((t,e)=>e?t.join("").length<r[e].join("").length?t:r[e]:t)}function C(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function S(t,e,n,r,s,a,i,c,o,m){let l=t,u=e,h=n,f=r,y=c,p=o;const x=120*Math.PI/180,d=Math.PI/180*(+s||0);let g,M,b,A,w,v=[];if(m)[M,b,A,w]=m;else{g=C(l,u,-d),l=g.x,u=g.y,g=C(y,p,-d),y=g.x,p=g.y;const t=(l-y)/2,e=(u-p)/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,c=(a===i?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));A=c*h*e/f+(l+y)/2,w=c*-f*t/h+(u+p)/2,M=(Math.asin((u-w)/f)*10**9>>0)/10**9,b=(Math.asin((p-w)/f)*10**9>>0)/10**9,M=l<A?Math.PI-M:M,b=y<A?Math.PI-b:b,M<0&&(M=2*Math.PI+M),b<0&&(b=2*Math.PI+b),i&&M>b&&(M-=2*Math.PI),!i&&b>M&&(b-=2*Math.PI)}let N=b-M;if(Math.abs(N)>x){const t=b,e=y,n=p;b=M+x*(i&&b>M?1:-1),y=A+h*Math.cos(b),p=w+f*Math.sin(b),v=S(y,p,h,f,s,0,i,e,n,[b,t,A,w])}N=b-M;const k=Math.cos(M),q=Math.sin(M),P=Math.cos(b),I=Math.sin(b),T=Math.tan(N/4),$=4/3*h*T,V=4/3*f*T,z=[l,u],L=[l+$*q,u-V*k],E=[y+$*I,p-V*P],O=[y,p];if(L[0]=2*z[0]-L[0],L[1]=2*z[1]-L[1],m)return[L,E,O].concat(v);v=[L,E,O].concat(v).join().split(",");const j=[];for(let t=0,e=v.length;t<e;t+=1)j[t]=t%2?C(v[t-1],v[t],d).y:C(v[t],v[t+1],d).x;return j}function k(t,e,n,r,s,a){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*a+2/3*r,s,a]}function q(t,e,n,r,s,a,i,c,o){const m=1-o;return{x:m**3*t+m*m*3*o*n+3*m*o*o*s+o**3*i,y:m**3*e+m*m*3*o*r+3*m*o*o*a+o**3*c}}function P(t,e,n){const[r,s]=t,[a,i]=e;return[r+(a-r)*n,s+(i-s)*n]}function I(t,e,n,r){const s=.5,a=[t,e],i=[n,r],c=P(a,i,s),o=P(i,c,s),m=P(c,o,s),l=P(o,m,s),u=P(m,l,s),h=q.apply(0,a.concat(c,m,u,s)),f=q.apply(0,u.concat(l,o,i,0));return[h.x,h.y,f.x,f.y,n,r]}function T(t,e){"TQ".includes(t[0])||(e.qx=null,e.qy=null);const[n,r]=t.slice(1);switch(t[0]){case"M":return e.x=+n,e.y=+r,t;case"A":return["C"].concat(S.apply(0,[e.x1,e.y1].concat(t.slice(1))));case"Q":return e.qx=+n,e.qy=+r,["C"].concat(k.apply(0,[e.x1,e.y1].concat(t.slice(1))));case"L":return["C"].concat(I(e.x1,e.y1,t[1],t[2]));case"Z":return["C"].concat(I(e.x1,e.y1,e.x,e.y))}return t}function $(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"].concat(r.splice(0,6)));t.splice(n,1)}}function V(t){if(!t.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);const e=new Y,n=Array.from(t);if(16===n.length){const[t,r,s,a,i,c,o,m,l,u,h,f,y,p,x,d]=n;e.m11=t,e.a=t,e.m21=i,e.c=i,e.m31=l,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=c,e.d=c,e.m32=u,e.m42=p,e.f=p,e.m13=s,e.m23=o,e.m33=h,e.m43=x,e.m14=a,e.m24=m,e.m34=f,e.m44=d}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,a,i,c]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=a,e.d=a,e.m41=i,e.e=i,e.m42=c,e.f=c}}return e}function z(t){if([Y,DOMMatrix].some(e=>t instanceof e)||"object"==typeof t&&["m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44"].every(e=>e in t))return V([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 compatible object.`)}function L(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new Y;const r=`CSSMatrix: invalid transform string "${t}"`;let s=!0;return e.split(")").filter(t=>t).map(t=>{const[e,n]=t.split("(");if(!n)throw TypeError(r);const a=n.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[i,c,o,m]=a;return s&&("matrix3d"===e||"rotate3d"===e&&[i,c].every(t=>!Number.isNaN(+t)&&0!==t)&&m||["rotateX","rotateY"].includes(e)&&i||"translate3d"===e&&[i,c,o].every(t=>!Number.isNaN(+t))&&o||"scale3d"===e&&[i,c,o].every(t=>!Number.isNaN(+t)&&t!==i))&&(s=!1),{prop:e,components:a}}).forEach(t=>{const{prop:e,components:a}=t,[i,c,o,m]=a,l=[i,c,o],u=[i,c,o,m];if("perspective"!==e||s)if(e.includes("matrix")){const t=a.map(t=>Math.abs(t)<1e-6?0:t);[6,16].includes(t.length)&&(n=n.multiply(V(t)))}else if(["translate","translate3d"].some(t=>e===t)&&i)n=n.translate(i,c||0,o||0);else if("rotate3d"===e&&u.every(t=>!Number.isNaN(+t))&&m)n=n.rotateAxisAngle(i,c,o,m);else if("scale3d"===e&&l.every(t=>!Number.isNaN(+t))&&l.some(t=>1!==t))n=n.scale(i,c,o);else if("rotate"===e&&i)n=n.rotate(0,0,i);else if("scale"!==e||Number.isNaN(i)||1===i)if("skew"===e&&(i||c))n=i?n.skewX(i):n,n=c?n.skewY(c):n;else{if(!/[XYZ]/.test(e)||!i)throw TypeError(r);if(e.includes("skew"))n=n[e](i);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),a=[0===s?i:0,1===s?i:0,2===s?i:0];n=n[t](...a)}}else{const t=Number.isNaN(+c)?i:c;n=n.scale(i,t,1)}else n.m34=-1/i}),n}function E(t,e,n){const r=new Y;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function O(t,e,n){const r=new Y,s=Math.PI/180,a=t*s,i=e*s,c=n*s,o=Math.cos(a),m=-Math.sin(a),l=Math.cos(i),u=-Math.sin(i),h=Math.cos(c),f=-Math.sin(c),y=l*h,p=-l*f;r.m11=y,r.a=y,r.m12=p,r.b=p,r.m13=u;const x=m*u*h+o*f;r.m21=x,r.c=x;const d=o*h-m*u*f;return r.m22=d,r.d=d,r.m23=-m*l,r.m31=m*f-o*u*h,r.m32=m*h+o*u*f,r.m33=o*l,r}function j(t,e,n,r){const s=new Y,a=r*(Math.PI/360),i=Math.sin(a),c=Math.cos(a),o=i*i,m=Math.sqrt(t*t+e*e+n*n);let l=t,u=e,h=n;0===m?(l=0,u=0,h=1):(l/=m,u/=m,h/=m);const f=l*l,y=u*u,p=h*h,x=1-2*(y+p)*o;s.m11=x,s.a=x;const d=2*(l*u*o+h*i*c);s.m12=d,s.b=d,s.m13=2*(l*h*o-u*i*c);const g=2*(u*l*o-h*i*c);s.m21=g,s.c=g;const M=1-2*(p+f)*o;return s.m22=M,s.d=M,s.m23=2*(u*h*o+l*i*c),s.m31=2*(h*l*o+u*i*c),s.m32=2*(h*u*o-l*i*c),s.m33=1-2*(f+y)*o,s}function D(t,e,n){const r=new Y;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function Z(t){const e=new Y,n=t*Math.PI/180,r=Math.tan(n);return e.m21=r,e.c=r,e}function X(t){const e=new Y,n=t*Math.PI/180,r=Math.tan(n);return e.m12=r,e.b=r,e}function Q(t,e){return V([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 Y{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){let n=t;return t instanceof Array&&(t[0]instanceof Array&&[16,6].includes(t[0].length)||"string"==typeof t[0]||[Y,DOMMatrix].some(e=>t[0]instanceof e))&&([n]=t),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[DOMMatrix,Y].some(e=>t instanceof e)?z(t):"string"==typeof t&&t.length&&"none"!==t?L(t):Array.isArray(t)?V(t):this}toString(){const t=this.toArray().join(",");return`${this.is2D?"matrix":"matrix3d"}(${t})`}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)}toJSON(){return JSON.parse(JSON.stringify(this))}multiply(t){return Q(this,t)}translate(t,e,n){let r=e,s=n;return null==s&&(s=0),null==r&&(r=0),Q(this,E(t,r,s))}scale(t,e,n){let r=e,s=n;return null==r&&(r=t),null==s&&(s=t),Q(this,D(t,r,s))}rotate(t,e,n){let r=t,s=e,a=n;return null==s&&(s=0),null==a&&(a=r,r=0),Q(this,O(r,s,a))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(t)))throw new TypeError("CSSMatrix: expecting 4 values");return Q(this,j(t,e,n,r))}skewX(t){return Q(this,Z(t))}skewY(t){return Q(this,X(t))}transformPoint(t){let e=E(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,a=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:n/a,y:r/a,z:s/a,w:a}}}function H(t){let e=new Y;const{origin:n}=t,r=n[0],s=n[1],{translate:a}=t,{rotate:i}=t,{skew:c}=t,{scale:o}=t;return(Array.isArray(a)&&a.some(t=>0!=+t)||!Number.isNaN(a))&&(e=Array.isArray(a)?e.translate(+a[0]||0,+a[1]||0,+a[2]||0):e.translate(+a||0,0,0)),(i||c||o)&&(e=e.translate(+r,+s),i&&(e=Array.isArray(i)&&i.some(t=>0!=+t)?e.rotate(+i[0]||0,+i[1]||0,+i[2]||0):e.rotate(0,0,+i||0)),Array.isArray(c)&&c.some(t=>0!=+t)&&(Array.isArray(c)?(e=c[0]?e.skewX(+c[0]||0):e,e=c[1]?e.skewY(+c[1]||0):e):e=e.skewX(+c||0)),(!Number.isNaN(o)||Array.isArray(o)&&o.some(t=>1!=+t))&&(e=Array.isArray(o)?e.scale(+o[0]||1,+o[1]||1,+o[2]||1):e.scale(+o||1,+o||1,+o||1)),e=e.translate(-r,-s)),e}function R(t,e,n){const r=t.transformPoint({x:e[0],y:e[1],z:0,w:1}),s=n[0]||0,a=n[1]||0,i=n[2]||0,c=r.x-s,o=r.y-a,m=r.z-i;return[c*(Math.abs(i)/Math.abs(m))+s,o*(Math.abs(i)/Math.abs(m))+a]}function J(t,e){let n,r,s,a,i,c,o,l=0,u=0;const h=y(t),f=A(h),p=H(e),x=Object.keys(e),{origin:d}=e,{a:g,b:M,c:b,d:w,e:v,f:N}=p,C=[g,M,b,w,v,N],S={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};let k=[],q=0,P="",I=[];const V=[];let z=[];if(!p.isIdentity){for(n=0,s=h.length;n<s;n+=1)k=h[n],h[n]&&([P]=k),V[n]=P,"A"!==P||p.is2D&&["skewX","skewY"].find(t=>x.includes(t))||(k=T(f[n],S),h[n]=T(f[n],S),$(h,V,n),f[n]=T(f[n],S),$(f,V,n),s=Math.max(h.length,f.length)),k=f[n],q=k.length,S.x1=+k[q-2],S.y1=+k[q-1],S.x2=+k[q-4]||S.x1,S.y2=+k[q-3]||S.y1,z={s:h[n],c:h[n][0]},"Z"!==P&&(z.x=S.x1,z.y=S.y1),I=I.concat(z);return I.map(t=>{switch(P=t.c,k=t.s,P){case"A":return o=function(t,e,n,r){const s=Math.cos(r*Math.PI/180),a=Math.sin(r*Math.PI/180),i=[e*(t[0]*s+t[2]*a),e*(t[1]*s+t[3]*a),n*(-t[0]*a+t[2]*s),n*(-t[1]*a+t[3]*s)],c=i[0]*i[0]+i[2]*i[2],o=i[1]*i[1]+i[3]*i[3];let m=((i[0]-i[3])*(i[0]-i[3])+(i[2]+i[1])*(i[2]+i[1]))*((i[0]+i[3])*(i[0]+i[3])+(i[2]-i[1])*(i[2]-i[1]));const l=(c+o)/2;if(m<1e-9*l){const t=Math.sqrt(l);return{rx:t,ry:t,ax:0}}const u=i[0]*i[1]+i[2]*i[3];m=Math.sqrt(m);const h=l+m/2,f=l-m/2;let y,p,x=Math.abs(u)<1e-9&&Math.abs(h-o)<1e-9?90:Math.atan(Math.abs(u)>Math.abs(h-o)?(h-c)/u:u/(h-o)*180)/Math.PI;return x>=0?(y=Math.sqrt(h),p=Math.sqrt(f)):(x+=90,y=Math.sqrt(f),p=Math.sqrt(h)),{rx:y,ry:p,ax:x}}(C,k[1],k[2],k[3]),C[0]*C[3]-C[1]*C[2]<0&&(k[5]=+k[5]?0:1),[i,c]=R(p,[k[6],k[7]],d),k=l===i&&u===c||o.rx<1e-9*o.ry||o.ry<1e-9*o.rx?["L",i,c]:[P,o.rx,o.ry,o.ax,k[4],k[5],i,c],l=i,u=c,k;case"L":case"H":case"V":return[i,c]=R(p,[t.x,t.y],d),l!==i&&u!==c?k=["L",i,c]:u===c?k=["H",i]:l===i&&(k=["V",c]),l=i,u=c,k;default:for(r=1,a=k.length;r<a;r+=2)[l,u]=R(p,[k[r],k[r+1]],d),k[r]=l,k[r+1]=u;return k}})}return m(h)}function B(t,e,n,r,s,a,i,c){let o=s-2*n+t-(i-2*s+n),m=2*(n-t)-2*(s-n),l=t-n,u=(-m+Math.sqrt(m*m-4*o*l))/2/o,h=(-m-Math.sqrt(m*m-4*o*l))/2/o;const f=[e,c],y=[t,i];let p;return Math.abs(u)>"1e12"&&(u=.5),Math.abs(h)>"1e12"&&(h=.5),u>0&&u<1&&(p=q(t,e,n,r,s,a,i,c,u),y.push(p.x),f.push(p.y)),h>0&&h<1&&(p=q(t,e,n,r,s,a,i,c,h),y.push(p.x),f.push(p.y)),o=a-2*r+e-(c-2*a+r),m=2*(r-e)-2*(a-r),l=e-r,u=(-m+Math.sqrt(m*m-4*o*l))/2/o,h=(-m-Math.sqrt(m*m-4*o*l))/2/o,Math.abs(u)>"1e12"&&(u=.5),Math.abs(h)>"1e12"&&(h=.5),u>0&&u<1&&(p=q(t,e,n,r,s,a,i,c,u),y.push(p.x),f.push(p.y)),h>0&&h<1&&(p=q(t,e,n,r,s,a,i,c,h),y.push(p.x),f.push(p.y)),{min:{x:Math.min.apply(0,y),y:Math.min.apply(0,f)},max:{x:Math.max.apply(0,y),y:Math.max.apply(0,f)}}}function F(t){return Array.isArray(t)&&u(t)&&t.slice(1).every(t=>"C"===t[0])}function G(t){if(F(t))return m(t);const e=A(t),n={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null},r=[];let s="",a=e.length;for(let t=0;t<a;t+=1){const i=e[t],c=i.length;i&&([s]=i),r[t]=s,e[t]=T(i,n),$(e,r,t),a=e.length,n.x1=+i[c-2],n.y1=+i[c-1],n.x2=+i[c-4]||n.x1,n.y2=+i[c-3]||n.y1}return e}function U(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0};const e=G(t);let n=0,r=0,s=[],a=[];e.forEach(t=>{const[e,i]=t.slice(-2);if("M"===t[0])n=+e,r=+i,s.push(e),a.push(i);else{const c=B.apply(0,[n,r].concat(t.slice(1)));s=s.concat(c.min.x,c.max.x),a=a.concat(c.min.y,c.max.y),n=+e,r=+i}});const i=Math.min.apply(0,s),c=Math.min.apply(0,a),o=Math.max.apply(0,s),m=Math.max.apply(0,a),l=o-i,u=m-c;return{width:l,height:u,x:i,y:c,x2:o,y2:m,cx:i+l/2,cy:c+u/2}}function K(t,e,n,r,s,a,i,c){return 3*((c-e)*(n+s)-(i-t)*(r+a)+r*(t-s)-n*(e-a)+c*(s+t/3)-i*(a+e/3))/20}function W(t){let e=0,n=0,r=0,s=0,a=0;return G(t).map(t=>{switch(t[0]){case"M":case"Z":return r="M"===t[0]?t[1]:r,s="M"===t[0]?t[2]:s,e=r,n=s,0;default:return a=K.apply(0,[e,n].concat(t.slice(1))),[e,n]=t.slice(-2),a}}).reduce((t,e)=>t+e,0)}function _(t,e,n,r,s){return s*(s*(-3*t+9*e-9*n+3*r)+6*t-12*e+6*n)-3*t+3*e}function tt(t,e,n,r,s,a,i,c,o){let m=o;(null===o||Number.isNaN(+o))&&(m=1),m>1&&(m=1),m<0&&(m=0);const l=m/2;let u=0,h=0,f=0,y=0;const p=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472];return[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816].forEach((o,m)=>{u=l*o+l,h=_(t,n,s,i,u),f=_(e,r,a,c,u),y+=p[m]*Math.sqrt(h*h+f*f)}),l*y}Y.Translate=E,Y.Rotate=O,Y.RotateAxisAngle=j,Y.Scale=D,Y.SkewX=Z,Y.SkewY=X,Y.Multiply=Q,Y.fromArray=V,Y.fromMatrix=z,Y.fromString=L;const et={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};const nt={CSSMatrix:Y,parsePathString:h,isPathArray:u,isCurveArray:F,isAbsoluteArray:f,isRelativeArray:p,isNormalizedArray:b,isValidPath:function(t){if("string"!=typeof t)return!1;const e=new l(t);for(i(e);e.index<e.max&&!e.err.length;)o(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:y,pathToRelative:x,pathToCurve:G,pathToString:g,getDrawDirection:function(t){return W(G(t))>=0},getPathArea:W,getPathBBox:U,getPathLength:function(t){let e=0;return G(t).forEach((t,n,r)=>{e+="M"===t[0]?0:tt.apply(0,r[n-1].slice(-2).concat(t.slice(1)))}),e},getPointAtLength:function(t,e){let n,r,s,a=0;return G(t).map((t,i,c)=>(r=i?c[i-1].slice(-2).concat(t.slice(1)):t.slice(1),n=i?tt.apply(0,r):0,a+=n,s=0===i?{x:r[0],y:r[1]}:a>e&&e>a-n?q.apply(0,r.concat(1-(a-e)/n)):null,s)).filter(t=>t).slice(-1)[0]},clonePath:m,splitPath:v,roundPath:d,optimizePath:N,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?r[n-1].slice(-2).concat(e.slice(1)):t[0].slice(1).concat(e.slice(1))).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M"].concat(e[0].slice(0,2))].concat(e.map(t=>["C"].concat(t.slice(2))))},reversePath:w,normalizePath:A,transformPath:J,getSVGMatrix:H,shapeToPath:function(e,n){if(!Object.keys(et).concat(["glyph"]).some(t=>e.tagName===t))throw TypeError(`shapeToPath: ${e} is not SVGElement`);const r=document.createElementNS("http://www.w3.org/2000/svg","path"),s=e.tagName,a=et[s],i={};let c;i.type=s,a.forEach(t=>{i[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:t,value:e})=>{a.includes(t)||r.setAttribute(t,e)});const{round:o,decimals:m}=t,l=o&&m?m:null;return"circle"===s?c=g(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]]}(i),l):"ellipse"===s?c=g(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]]}(i),l):["polyline","polygon"].includes(s)?c=g(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.concat([["z"]]):e}(i),l):"rect"===s?c=g(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let a=+t.rx,i=+t.ry;return a||i?(a=a||i,i=i||a,2*a>r&&(a-=(2*a-r)/2),2*i>s&&(i-=(2*i-s)/2),[["M",e+a,n],["h",r-2*a],["s",a,0,a,i],["v",s-2*i],["s",0,i,-a,i],["h",2*a-r],["s",-a,0,-a,-i],["v",2*i-s],["s",0,-i,a,-i]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(i),l):"line"===s?c=g(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",+e,+n],["L",+r,+s]]}(i),l):"glyph"===s&&(c=e.getAttribute("d")),c?(r.setAttribute("d",c),n&&(e.before(r,e),e.remove()),r):null},options:t,Version:"0.1.10"};class rt{constructor(e,n){const r=n||{};let{round:s}=t;const{round:a}=r;(a&&0==+a||!1===a)&&(s=0);const{decimals:i}=s?r||t:{decimals:!1};return this.round=i,this.segments=h(e),this.pathValue=e,this}toAbsolute(){const{segments:t}=this;return this.segments=y(t),this}toRelative(){const{segments:t}=this;return this.segments=x(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=v(this.toString()),r=n.length>1?n:0,s=r&&m(r).map((e,n)=>t?n?w(e):h(e):w(e));let a=[];return a=r?s.flat(1):t?e:w(e),this.segments=m(a),this}normalize(){const{segments:t}=this;return this.segments=A(t),this}optimize(){const{segments:t}=this;return this.segments=N(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=t||{},{segments:n}=this;if(!e.origin){const t=U(n);e.origin=[+t.cx,+t.cy]}return this.segments=J(n,e),this}flipX(){return this.transform({rotate:[180,0,0]}),this}flipY(){return this.transform({rotate:[0,180,0]}),this}toString(){return g(this.segments,this.round)}}Object.keys(nt).forEach(t=>{rt[t]=nt[t]});export{rt as default};
1
+ // SVGPathCommander v0.1.11alpha1 | thednp © 2021 | MIT-License
2
+ const t={origin:[0,0],decimals:4,round:1},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].concat(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 a(t){const{max:e,pathValue:n,index:r}=t;let a,i=r,c=!1,o=!1,m=!1,l=!1;if(i>=e)t.err=`Invalid path value at ${i}: missing param ${n[i]}`;else if(a=n.charCodeAt(i),43!==a&&45!==a||(i+=1,a=i<e?n.charCodeAt(i):0),s(a)||46===a){if(46!==a){if(c=48===a,i+=1,a=i<e?n.charCodeAt(i):0,c&&i<e&&a&&s(a))return void(t.err=`Invalid path value at index ${r}: ${n[r]} illegal number`);for(;i<e&&s(n.charCodeAt(i));)i+=1,o=!0;a=i<e?n.charCodeAt(i):0}if(46===a){for(l=!0,i+=1;s(n.charCodeAt(i));)i+=1,m=!0;a=i<e?n.charCodeAt(i):0}if(101===a||69===a){if(l&&!o&&!m)return void(t.err=`Invalid path value at index ${i}: ${n[i]} invalid float exponent`);if(i+=1,a=i<e?n.charCodeAt(i):0,43!==a&&45!==a||(i+=1),!(i<e&&s(n.charCodeAt(i))))return void(t.err=`Invalid path value at index ${i}: ${n[i]} invalid float exponent`);for(;i<e&&s(n.charCodeAt(i));)i+=1}t.index=i,t.param=+t.pathValue.slice(r,i)}else t.err=`Invalid path value at index ${i}: ${n[i]} is not a number`}function i(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 c(t){return t>=48&&t<=57||43===t||45===t||46===t}function o(t){const{max:s,pathValue:o,index:m}=t,l=o.charCodeAt(m),u=e[o[m].toLowerCase()];if(t.segmentStart=m,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}}(l))if(t.index+=1,i(t),t.data=[],u){for(;;){for(let e=u;e>0;e-=1){if(97!=(32|l)||3!==e&&4!==e?a(t):r(t),t.err.length)return;t.data.push(t.param),i(t),t.index<s&&44===o.charCodeAt(t.index)&&(t.index+=1,i(t))}if(t.index>=t.max)break;if(!c(o.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`Invalid path value: ${o[m]} not a path command`}function m(t){return Array.isArray(t)?t.map(t=>Array.isArray(t)?m(t):Number.isNaN(+t)?t:+t):t}function l(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function u(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&/[achlmqstvz]/gi.test(n)})}function h(t){if(u(t))return m(t);const e=new l(""+t);for(i(e);e.index<e.max&&!e.err.length;)o(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 Array.isArray(t)&&u(t)&&t.every(t=>t[0]===t[0].toUpperCase())}function y(t){if(f(t))return m(t);const e=h(t),n=e.length,r=[];let s=0,a=0,i=0,c=0,o=0;"M"===e[0][0]&&(s=+e[0][1],a=+e[0][2],i=s,c=a,o+=1,r.push(["M",s,a]));for(let t=o;t<n;t+=1){const n=e[t],[o]=n,m=o.toUpperCase(),l=[];let u=[];if(o!==m)switch(l[0]=m,m){case"A":u=n.slice(1,-2).concat([+n[6]+s,+n[7]+a]);for(let t=0;t<u.length;t+=1)l.push(u[t]);break;case"V":l[1]=+n[1]+a;break;case"H":l[1]=+n[1]+s;break;default:"M"===m&&(i=+n[1]+s,c=+n[2]+a);for(let t=1;t<n.length;t+=1)l.push(+n[t]+(t%2?s:a))}else for(let t=0;t<n.length;t+=1)l.push(n[t]);r.push(l);const h=l.length;switch(m){case"Z":s=i,a=c;break;case"H":s=+l[1];break;case"V":a=+l[1];break;default:s=+l[h-2],a=+l[h-1],"M"===m&&(i=s,c=a)}}return r}function p(t){return Array.isArray(t)&&u(t)&&t.slice(1).every(t=>t[0]===t[0].toLowerCase())}function x(t){if(p(t))return m(t);const e=h(t),n=e.length,r=[];let s=0,a=0,i=0,c=0,o=0;"M"===e[0][0]&&(s=+e[0][1],a=+e[0][2],i=s,c=a,o+=1,r.push(["M",s,a]));for(let t=o;t<n;t+=1){const n=e[t],[o]=n,m=o.toLowerCase(),l=[];let u=[];if(o!==m)switch(l[0]=m,m){case"a":u=n.slice(1,-2).concat([+n[6]-s,+n[7]-a]);for(let t=0;t<u.length;t+=1)l.push(u[t]);break;case"v":l[1]=+n[1]-a;break;default:for(let t=1;t<n.length;t+=1)l.push(+n[t]-(t%2?s:a));"m"===m&&(i=+n[1],c=+n[2])}else{"m"===o&&(i=+n[1]+s,c=+n[2]+a);for(let t=0;t<n.length;t+=1)l.push(n[t])}r.push(l);const h=l.length;switch(l[0]){case"z":s=i,a=c;break;case"h":s+=+l[h-1];break;case"v":a+=+l[h-1];break;default:s+=+r[t][h-2],a+=+r[t][h-1]}}return r}function d(e,n){const{round:r,decimals:s}=t,a=n&&!Number.isNaN(+n)?+n:r&&s;if(!1===n||!r&&!a)return m(e);const i=10**a,c=[],o=e.length;let l,u=0,h=[];for(let t=0;t<o;t+=1){h=e[t],l=[""];for(let t=0;t<h.length;t+=1)t?(u=+h[t],l.push(t&&u%1!=0?Math.round(u*i)/i:u)):l[t]=h[t];c.push(l)}return c}function g(t,e){return d(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function M(t,e,n){const[r]=t,s=t.slice(1);let a=t.slice();if("TQ".includes(t[0])||(e.qx=null,e.qy=null),"H"===r)a=["L",t[1],e.y1];else if("V"===r)a=["L",e.x1,t[1]];else if("S"===r){const{x1:t,y1:r}=function(t,e,n,r,s){return"CS".indexOf(s)>-1?{x1:2*t-n,y1:2*e-r}:{x1:t,y1:e}}(e.x1,e.y1,e.x2,e.y2,n);e.x1=t,e.y1=r,a=["C",t,r].concat(s)}else if("T"===r){const{qx:t,qy:r}=function(t,e,n,r,s){return"QT".indexOf(s)>-1?{qx:2*t-n,qy:2*e-r}:{qx:t,qy:e}}(e.x1,e.y1,e.qx,e.qy,n);e.qx=t,e.qy=r,a=["Q",t,r].concat(s)}else if("Q"===r){const[t,n]=s;e.qx=t,e.qy=n}return a}function b(t){return Array.isArray(t)&&u(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"ACLMQZ".includes(t[0])})}function A(t){if(Array.isArray(t)&&b(t))return m(t);const e=y(t),n={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null},r=[],s=e.length;let a,i,c="",o="";for(let t=0;t<s;t+=1)[c]=e[t],r[t]=c,t&&(o=r[t-1]),e[t]=M(e[t],n,o),a=e[t],i=a.length,n.x1=+a[i-2],n.y1=+a[i-1],n.x2=+a[i-4]||n.x1,n.y2=+a[i-3]||n.y1;return e}function w(t){const e=y(t),n="Z"===e.slice(-1)[0][0];let r=[],s=0;return r=A(e).map((t,n)=>(s=t.length,{seg:e[n],n:t,c:e[n][0],x:t[s-2],y:t[s-1]})).map((t,e,r)=>{const s=t.seg,a=t.n,i=e&&r[e-1],c=r[e+1]&&r[e+1],o=t.c,m=r.length,l=e?r[e-1].x:r[m-1].x,u=e?r[e-1].y:r[m-1].y;let h=[];switch(o){case"M":h=n?["Z"]:[o,l,u];break;case"A":h=s.slice(0,-3).concat([1===s[5]?0:1,l,u]);break;case"C":h=c&&"S"===c.c?["S",s[1],s[2],l,u]:[o,s[3],s[4],s[1],s[2],l,u];break;case"S":h=i&&"CS".indexOf(i.c)>-1&&(!c||c&&"S"!==c.c)?["C",a[3],a[4],a[1],a[2],l,u]:[o,a[1],a[2],l,u];break;case"Q":h=c&&"T"===c.c?["T",l,u]:s.slice(0,-2).concat([l,u]);break;case"T":h=i&&"QT".indexOf(i.c)>-1&&(!c||c&&"T"!==c.c)?["Q",a[1],a[2],l,u]:[o,l,u];break;case"Z":h=["M",l,u];break;case"H":h=[o,l];break;case"V":h=[o,u];break;default:h=s.slice(0,-2).concat([l,u])}return h}),n?r.reverse():[r[0]].concat(r.slice(1).reverse())}function v(t){return g(y(t),0).replace(/(m|M)/g,"|$1").split("|").map(t=>t.trim()).filter(t=>t)}function N(t,e){const n=d(y(t),e),r=d(x(t),e);return n.map((t,e)=>e?t.join("").length<r[e].join("").length?t:r[e]:t)}function C(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function S(t,e,n,r,s,a,i,c,o,m){let l=t,u=e,h=n,f=r,y=c,p=o;const x=120*Math.PI/180,d=Math.PI/180*(+s||0);let g,M,b,A,w,v=[];if(m)[M,b,A,w]=m;else{g=C(l,u,-d),l=g.x,u=g.y,g=C(y,p,-d),y=g.x,p=g.y;const t=(l-y)/2,e=(u-p)/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,c=(a===i?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));A=c*h*e/f+(l+y)/2,w=c*-f*t/h+(u+p)/2,M=(Math.asin((u-w)/f)*10**9>>0)/10**9,b=(Math.asin((p-w)/f)*10**9>>0)/10**9,M=l<A?Math.PI-M:M,b=y<A?Math.PI-b:b,M<0&&(M=2*Math.PI+M),b<0&&(b=2*Math.PI+b),i&&M>b&&(M-=2*Math.PI),!i&&b>M&&(b-=2*Math.PI)}let N=b-M;if(Math.abs(N)>x){const t=b,e=y,n=p;b=M+x*(i&&b>M?1:-1),y=A+h*Math.cos(b),p=w+f*Math.sin(b),v=S(y,p,h,f,s,0,i,e,n,[b,t,A,w])}N=b-M;const k=Math.cos(M),q=Math.sin(M),P=Math.cos(b),I=Math.sin(b),T=Math.tan(N/4),$=4/3*h*T,V=4/3*f*T,z=[l,u],L=[l+$*q,u-V*k],E=[y+$*I,p-V*P],O=[y,p];if(L[0]=2*z[0]-L[0],L[1]=2*z[1]-L[1],m)return[L,E,O].concat(v);v=[L,E,O].concat(v).join().split(",");const j=[];for(let t=0,e=v.length;t<e;t+=1)j[t]=t%2?C(v[t-1],v[t],d).y:C(v[t],v[t+1],d).x;return j}function k(t,e,n,r,s,a){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*a+2/3*r,s,a]}function q(t,e,n,r,s,a,i,c,o){const m=1-o;return{x:m**3*t+m*m*3*o*n+3*m*o*o*s+o**3*i,y:m**3*e+m*m*3*o*r+3*m*o*o*a+o**3*c}}function P(t,e,n){const[r,s]=t,[a,i]=e;return[r+(a-r)*n,s+(i-s)*n]}function I(t,e,n,r){const s=.5,a=[t,e],i=[n,r],c=P(a,i,s),o=P(i,c,s),m=P(c,o,s),l=P(o,m,s),u=P(m,l,s),h=q.apply(0,a.concat(c,m,u,s)),f=q.apply(0,u.concat(l,o,i,0));return[h.x,h.y,f.x,f.y,n,r]}function T(t,e){"TQ".includes(t[0])||(e.qx=null,e.qy=null);const[n,r]=t.slice(1);switch(t[0]){case"M":return e.x=+n,e.y=+r,t;case"A":return["C"].concat(S.apply(0,[e.x1,e.y1].concat(t.slice(1))));case"Q":return e.qx=+n,e.qy=+r,["C"].concat(k.apply(0,[e.x1,e.y1].concat(t.slice(1))));case"L":return["C"].concat(I(e.x1,e.y1,t[1],t[2]));case"Z":return["C"].concat(I(e.x1,e.y1,e.x,e.y))}return t}function $(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"].concat(r.splice(0,6)));t.splice(n,1)}}function V(t){if(!t.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);const e=new Y,n=Array.from(t);if(16===n.length){const[t,r,s,a,i,c,o,m,l,u,h,f,y,p,x,d]=n;e.m11=t,e.a=t,e.m21=i,e.c=i,e.m31=l,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=c,e.d=c,e.m32=u,e.m42=p,e.f=p,e.m13=s,e.m23=o,e.m33=h,e.m43=x,e.m14=a,e.m24=m,e.m34=f,e.m44=d}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,a,i,c]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=a,e.d=a,e.m41=i,e.e=i,e.m42=c,e.f=c}}return e}function z(t){if([Y,DOMMatrix].some(e=>t instanceof e)||"object"==typeof t&&["m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44"].every(e=>e in t))return V([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 compatible object.`)}function L(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new Y;const r=`CSSMatrix: invalid transform string "${t}"`;let s=!0;return e.split(")").filter(t=>t).map(t=>{const[e,n]=t.split("(");if(!n)throw TypeError(r);const a=n.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[i,c,o,m]=a;return s&&("matrix3d"===e||"rotate3d"===e&&[i,c].every(t=>!Number.isNaN(+t)&&0!==t)&&m||["rotateX","rotateY"].includes(e)&&i||"translate3d"===e&&[i,c,o].every(t=>!Number.isNaN(+t))&&o||"scale3d"===e&&[i,c,o].every(t=>!Number.isNaN(+t)&&t!==i))&&(s=!1),{prop:e,components:a}}).forEach(t=>{const{prop:e,components:a}=t,[i,c,o,m]=a,l=[i,c,o],u=[i,c,o,m];if("perspective"!==e||s)if(e.includes("matrix")){const t=a.map(t=>Math.abs(t)<1e-6?0:t);[6,16].includes(t.length)&&(n=n.multiply(V(t)))}else if(["translate","translate3d"].some(t=>e===t)&&i)n=n.translate(i,c||0,o||0);else if("rotate3d"===e&&u.every(t=>!Number.isNaN(+t))&&m)n=n.rotateAxisAngle(i,c,o,m);else if("scale3d"===e&&l.every(t=>!Number.isNaN(+t))&&l.some(t=>1!==t))n=n.scale(i,c,o);else if("rotate"===e&&i)n=n.rotate(0,0,i);else if("scale"!==e||Number.isNaN(i)||1===i)if("skew"===e&&(i||c))n=i?n.skewX(i):n,n=c?n.skewY(c):n;else{if(!/[XYZ]/.test(e)||!i)throw TypeError(r);if(e.includes("skew"))n=n[e](i);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),a=[0===s?i:0,1===s?i:0,2===s?i:0];n=n[t](...a)}}else{const t=Number.isNaN(+c)?i:c;n=n.scale(i,t,1)}else n.m34=-1/i}),n}function E(t,e,n){const r=new Y;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function O(t,e,n){const r=new Y,s=Math.PI/180,a=t*s,i=e*s,c=n*s,o=Math.cos(a),m=-Math.sin(a),l=Math.cos(i),u=-Math.sin(i),h=Math.cos(c),f=-Math.sin(c),y=l*h,p=-l*f;r.m11=y,r.a=y,r.m12=p,r.b=p,r.m13=u;const x=m*u*h+o*f;r.m21=x,r.c=x;const d=o*h-m*u*f;return r.m22=d,r.d=d,r.m23=-m*l,r.m31=m*f-o*u*h,r.m32=m*h+o*u*f,r.m33=o*l,r}function j(t,e,n,r){const s=new Y,a=r*(Math.PI/360),i=Math.sin(a),c=Math.cos(a),o=i*i,m=Math.sqrt(t*t+e*e+n*n);let l=t,u=e,h=n;0===m?(l=0,u=0,h=1):(l/=m,u/=m,h/=m);const f=l*l,y=u*u,p=h*h,x=1-2*(y+p)*o;s.m11=x,s.a=x;const d=2*(l*u*o+h*i*c);s.m12=d,s.b=d,s.m13=2*(l*h*o-u*i*c);const g=2*(u*l*o-h*i*c);s.m21=g,s.c=g;const M=1-2*(p+f)*o;return s.m22=M,s.d=M,s.m23=2*(u*h*o+l*i*c),s.m31=2*(h*l*o+u*i*c),s.m32=2*(h*u*o-l*i*c),s.m33=1-2*(f+y)*o,s}function D(t,e,n){const r=new Y;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function Z(t){const e=new Y,n=t*Math.PI/180,r=Math.tan(n);return e.m21=r,e.c=r,e}function X(t){const e=new Y,n=t*Math.PI/180,r=Math.tan(n);return e.m12=r,e.b=r,e}function Q(t,e){return V([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 Y{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){let n=t;return t instanceof Array&&(t[0]instanceof Array&&[16,6].includes(t[0].length)||"string"==typeof t[0]||[Y,DOMMatrix].some(e=>t[0]instanceof e))&&([n]=t),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[DOMMatrix,Y].some(e=>t instanceof e)?z(t):"string"==typeof t&&t.length&&"none"!==t?L(t):Array.isArray(t)?V(t):this}toString(){const t=this.toArray().join(",");return`${this.is2D?"matrix":"matrix3d"}(${t})`}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)}toJSON(){return JSON.parse(JSON.stringify(this))}multiply(t){return Q(this,t)}translate(t,e,n){let r=e,s=n;return null==s&&(s=0),null==r&&(r=0),Q(this,E(t,r,s))}scale(t,e,n){let r=e,s=n;return null==r&&(r=t),null==s&&(s=t),Q(this,D(t,r,s))}rotate(t,e,n){let r=t,s=e,a=n;return null==s&&(s=0),null==a&&(a=r,r=0),Q(this,O(r,s,a))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(t)))throw new TypeError("CSSMatrix: expecting 4 values");return Q(this,j(t,e,n,r))}skewX(t){return Q(this,Z(t))}skewY(t){return Q(this,X(t))}transformPoint(t){let e=E(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,a=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:n/a,y:r/a,z:s/a,w:a}}}function H(t){let e=new Y;const{origin:n}=t,r=n[0],s=n[1],{translate:a}=t,{rotate:i}=t,{skew:c}=t,{scale:o}=t;return(Array.isArray(a)&&a.some(t=>0!=+t)||!Number.isNaN(a))&&(e=Array.isArray(a)?e.translate(+a[0]||0,+a[1]||0,+a[2]||0):e.translate(+a||0,0,0)),(i||c||o)&&(e=e.translate(+r,+s),i&&(e=Array.isArray(i)&&i.some(t=>0!=+t)?e.rotate(+i[0]||0,+i[1]||0,+i[2]||0):e.rotate(0,0,+i||0)),Array.isArray(c)&&c.some(t=>0!=+t)&&(Array.isArray(c)?(e=c[0]?e.skewX(+c[0]||0):e,e=c[1]?e.skewY(+c[1]||0):e):e=e.skewX(+c||0)),(!Number.isNaN(o)||Array.isArray(o)&&o.some(t=>1!=+t))&&(e=Array.isArray(o)?e.scale(+o[0]||1,+o[1]||1,+o[2]||1):e.scale(+o||1,+o||1,+o||1)),e=e.translate(-r,-s)),e}function R(t,e,n){const r=t.transformPoint({x:e[0],y:e[1],z:0,w:1}),s=n[0]||0,a=n[1]||0,i=n[2]||0,c=r.x-s,o=r.y-a,m=r.z-i;return[c*(Math.abs(i)/Math.abs(m))+s,o*(Math.abs(i)/Math.abs(m))+a]}function J(t,e){let n,r,s,a,i,c,o,l=0,u=0;const h=y(t),f=A(h),p=H(e),x=Object.keys(e),{origin:d}=e,{a:g,b:M,c:b,d:w,e:v,f:N}=p,C=[g,M,b,w,v,N],S={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};let k=[],q=0,P="",I=[];const V=[];let z=[];if(!p.isIdentity){for(n=0,s=h.length;n<s;n+=1)k=h[n],h[n]&&([P]=k),V[n]=P,"A"!==P||p.is2D&&["skewX","skewY"].find(t=>x.includes(t))||(k=T(f[n],S),h[n]=T(f[n],S),$(h,V,n),f[n]=T(f[n],S),$(f,V,n),s=Math.max(h.length,f.length)),k=f[n],q=k.length,S.x1=+k[q-2],S.y1=+k[q-1],S.x2=+k[q-4]||S.x1,S.y2=+k[q-3]||S.y1,z={s:h[n],c:h[n][0]},"Z"!==P&&(z.x=S.x1,z.y=S.y1),I=I.concat(z);return I.map(t=>{switch(P=t.c,k=t.s,P){case"A":return o=function(t,e,n,r){const s=Math.cos(r*Math.PI/180),a=Math.sin(r*Math.PI/180),i=[e*(t[0]*s+t[2]*a),e*(t[1]*s+t[3]*a),n*(-t[0]*a+t[2]*s),n*(-t[1]*a+t[3]*s)],c=i[0]*i[0]+i[2]*i[2],o=i[1]*i[1]+i[3]*i[3];let m=((i[0]-i[3])*(i[0]-i[3])+(i[2]+i[1])*(i[2]+i[1]))*((i[0]+i[3])*(i[0]+i[3])+(i[2]-i[1])*(i[2]-i[1]));const l=(c+o)/2;if(m<1e-9*l){const t=Math.sqrt(l);return{rx:t,ry:t,ax:0}}const u=i[0]*i[1]+i[2]*i[3];m=Math.sqrt(m);const h=l+m/2,f=l-m/2;let y,p,x=Math.abs(u)<1e-9&&Math.abs(h-o)<1e-9?90:Math.atan(Math.abs(u)>Math.abs(h-o)?(h-c)/u:u/(h-o)*180)/Math.PI;return x>=0?(y=Math.sqrt(h),p=Math.sqrt(f)):(x+=90,y=Math.sqrt(f),p=Math.sqrt(h)),{rx:y,ry:p,ax:x}}(C,k[1],k[2],k[3]),C[0]*C[3]-C[1]*C[2]<0&&(k[5]=+k[5]?0:1),[i,c]=R(p,[k[6],k[7]],d),k=l===i&&u===c||o.rx<1e-9*o.ry||o.ry<1e-9*o.rx?["L",i,c]:[P,o.rx,o.ry,o.ax,k[4],k[5],i,c],l=i,u=c,k;case"L":case"H":case"V":return[i,c]=R(p,[t.x,t.y],d),l!==i&&u!==c?k=["L",i,c]:u===c?k=["H",i]:l===i&&(k=["V",c]),l=i,u=c,k;default:for(r=1,a=k.length;r<a;r+=2)[l,u]=R(p,[k[r],k[r+1]],d),k[r]=l,k[r+1]=u;return k}})}return m(h)}function B(t,e,n,r,s,a,i,c){let o=s-2*n+t-(i-2*s+n),m=2*(n-t)-2*(s-n),l=t-n,u=(-m+Math.sqrt(m*m-4*o*l))/2/o,h=(-m-Math.sqrt(m*m-4*o*l))/2/o;const f=[e,c],y=[t,i];let p;return Math.abs(u)>"1e12"&&(u=.5),Math.abs(h)>"1e12"&&(h=.5),u>0&&u<1&&(p=q(t,e,n,r,s,a,i,c,u),y.push(p.x),f.push(p.y)),h>0&&h<1&&(p=q(t,e,n,r,s,a,i,c,h),y.push(p.x),f.push(p.y)),o=a-2*r+e-(c-2*a+r),m=2*(r-e)-2*(a-r),l=e-r,u=(-m+Math.sqrt(m*m-4*o*l))/2/o,h=(-m-Math.sqrt(m*m-4*o*l))/2/o,Math.abs(u)>"1e12"&&(u=.5),Math.abs(h)>"1e12"&&(h=.5),u>0&&u<1&&(p=q(t,e,n,r,s,a,i,c,u),y.push(p.x),f.push(p.y)),h>0&&h<1&&(p=q(t,e,n,r,s,a,i,c,h),y.push(p.x),f.push(p.y)),{min:{x:Math.min.apply(0,y),y:Math.min.apply(0,f)},max:{x:Math.max.apply(0,y),y:Math.max.apply(0,f)}}}function F(t){return Array.isArray(t)&&u(t)&&t.slice(1).every(t=>"C"===t[0])}function G(t){if(F(t))return m(t);const e=A(t),n={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null},r=[];let s="",a=e.length;for(let t=0;t<a;t+=1){const i=e[t],c=i.length;i&&([s]=i),r[t]=s,e[t]=T(i,n),$(e,r,t),a=e.length,n.x1=+i[c-2],n.y1=+i[c-1],n.x2=+i[c-4]||n.x1,n.y2=+i[c-3]||n.y1}return e}function U(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0};const e=G(t);let n=0,r=0,s=[],a=[];e.forEach(t=>{const[e,i]=t.slice(-2);if("M"===t[0])n=+e,r=+i,s.push(e),a.push(i);else{const c=B.apply(0,[n,r].concat(t.slice(1)));s=s.concat(c.min.x,c.max.x),a=a.concat(c.min.y,c.max.y),n=+e,r=+i}});const i=Math.min.apply(0,s),c=Math.min.apply(0,a),o=Math.max.apply(0,s),m=Math.max.apply(0,a),l=o-i,u=m-c;return{width:l,height:u,x:i,y:c,x2:o,y2:m,cx:i+l/2,cy:c+u/2}}function K(t,e,n,r,s,a,i,c){return 3*((c-e)*(n+s)-(i-t)*(r+a)+r*(t-s)-n*(e-a)+c*(s+t/3)-i*(a+e/3))/20}function W(t){let e=0,n=0,r=0,s=0,a=0;return G(t).map(t=>{switch(t[0]){case"M":case"Z":return r="M"===t[0]?t[1]:r,s="M"===t[0]?t[2]:s,e=r,n=s,0;default:return a=K.apply(0,[e,n].concat(t.slice(1))),[e,n]=t.slice(-2),a}}).reduce((t,e)=>t+e,0)}function _(t,e,n,r,s){return s*(s*(-3*t+9*e-9*n+3*r)+6*t-12*e+6*n)-3*t+3*e}function tt(t,e,n,r,s,a,i,c,o){let m=o;(null===o||Number.isNaN(+o))&&(m=1),m>1&&(m=1),m<0&&(m=0);const l=m/2;let u=0,h=0,f=0,y=0;const p=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472];return[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816].forEach((o,m)=>{u=l*o+l,h=_(t,n,s,i,u),f=_(e,r,a,c,u),y+=p[m]*Math.sqrt(h*h+f*f)}),l*y}Y.Translate=E,Y.Rotate=O,Y.RotateAxisAngle=j,Y.Scale=D,Y.SkewX=Z,Y.SkewY=X,Y.Multiply=Q,Y.fromArray=V,Y.fromMatrix=z,Y.fromString=L;const et={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};const nt={CSSMatrix:Y,parsePathString:h,isPathArray:u,isCurveArray:F,isAbsoluteArray:f,isRelativeArray:p,isNormalizedArray:b,isValidPath:function(t){if("string"!=typeof t)return!1;const e=new l(t);for(i(e);e.index<e.max&&!e.err.length;)o(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:y,pathToRelative:x,pathToCurve:G,pathToString:g,getDrawDirection:function(t){return W(G(t))>=0},getPathArea:W,getPathBBox:U,getPathLength:function(t){let e=0;return G(t).forEach((t,n,r)=>{e+="M"===t[0]?0:tt.apply(0,r[n-1].slice(-2).concat(t.slice(1)))}),e},getPointAtLength:function(t,e){let n,r,s,a=0;return G(t).map((t,i,c)=>(r=i?c[i-1].slice(-2).concat(t.slice(1)):t.slice(1),n=i?tt.apply(0,r):0,a+=n,s=0===i?{x:r[0],y:r[1]}:a>e&&e>a-n?q.apply(0,r.concat(1-(a-e)/n)):null,s)).filter(t=>t).slice(-1)[0]},clonePath:m,splitPath:v,roundPath:d,optimizePath:N,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?r[n-1].slice(-2).concat(e.slice(1)):t[0].slice(1).concat(e.slice(1))).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M"].concat(e[0].slice(0,2))].concat(e.map(t=>["C"].concat(t.slice(2))))},reversePath:w,normalizePath:A,transformPath:J,getSVGMatrix:H,shapeToPath:function(e,n){if(!Object.keys(et).concat(["glyph"]).some(t=>e.tagName===t))throw TypeError(`shapeToPath: ${e} is not SVGElement`);const r=document.createElementNS("http://www.w3.org/2000/svg","path"),s=e.tagName,a=et[s],i={};let c;i.type=s,a.forEach(t=>{i[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:t,value:e})=>{a.includes(t)||r.setAttribute(t,e)});const{round:o,decimals:m}=t,l=o&&m?m:null;return"circle"===s?c=g(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]]}(i),l):"ellipse"===s?c=g(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]]}(i),l):["polyline","polygon"].includes(s)?c=g(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.concat([["z"]]):e}(i),l):"rect"===s?c=g(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let a=+t.rx,i=+t.ry;return a||i?(a=a||i,i=i||a,2*a>r&&(a-=(2*a-r)/2),2*i>s&&(i-=(2*i-s)/2),[["M",e+a,n],["h",r-2*a],["s",a,0,a,i],["v",s-2*i],["s",0,i,-a,i],["h",2*a-r],["s",-a,0,-a,-i],["v",2*i-s],["s",0,-i,a,-i]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(i),l):"line"===s?c=g(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",+e,+n],["L",+r,+s]]}(i),l):"glyph"===s&&(c=e.getAttribute("d")),c?(r.setAttribute("d",c),n&&(e.before(r,e),e.remove()),r):null},options:t,Version:"0.1.11alpha1"};class rt{constructor(e,n){const r=n||{};let{round:s}=t;const{round:a}=r;(a&&0==+a||!1===a)&&(s=0);const{decimals:i}=s?r||t:{decimals:!1};return this.round=i,this.segments=h(e),this.pathValue=e,this}toAbsolute(){const{segments:t}=this;return this.segments=y(t),this}toRelative(){const{segments:t}=this;return this.segments=x(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=v(this.toString()),r=n.length>1?n:0,s=r&&m(r).map((e,n)=>t?n?w(e):h(e):w(e));let a=[];return a=r?s.flat(1):t?e:w(e),this.segments=m(a),this}normalize(){const{segments:t}=this;return this.segments=A(t),this}optimize(){const{segments:t}=this;return this.segments=N(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=t||{},{segments:n}=this;if(!e.origin){const t=U(n);e.origin=[+t.cx,+t.cy]}return this.segments=J(n,e),this}flipX(){return this.transform({rotate:[180,0,0]}),this}flipY(){return this.transform({rotate:[0,180,0]}),this}toString(){return g(this.segments,this.round)}}Object.keys(nt).forEach(t=>{rt[t]=nt[t]});export{rt as default};