svg-path-commander 2.0.9 → 2.1.0

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/.eslintrc.cjs +1 -0
  2. package/README.md +4 -4
  3. package/dist/svg-path-commander.cjs +1 -1
  4. package/dist/svg-path-commander.cjs.map +1 -1
  5. package/dist/svg-path-commander.d.ts +156 -39
  6. package/dist/svg-path-commander.js +1 -1
  7. package/dist/svg-path-commander.js.map +1 -1
  8. package/dist/svg-path-commander.mjs +869 -705
  9. package/dist/svg-path-commander.mjs.map +1 -1
  10. package/package.json +22 -24
  11. package/src/convert/pathToAbsolute.ts +1 -1
  12. package/src/convert/pathToCurve.ts +1 -1
  13. package/src/convert/pathToRelative.ts +1 -1
  14. package/src/index.ts +30 -26
  15. package/src/interface.ts +32 -32
  16. package/src/math/arcTools.ts +217 -0
  17. package/src/math/bezier.ts +261 -0
  18. package/src/math/cubicTools.ts +81 -0
  19. package/src/math/lineTools.ts +52 -0
  20. package/src/math/quadTools.ts +79 -0
  21. package/src/parser/isMoveCommand.ts +17 -0
  22. package/src/parser/parsePathString.ts +1 -1
  23. package/src/parser/scanSegment.ts +12 -3
  24. package/src/process/normalizePath.ts +1 -1
  25. package/src/process/replaceArc.ts +52 -0
  26. package/src/process/splitPath.ts +1 -1
  27. package/src/process/transformPath.ts +14 -34
  28. package/src/types.ts +5 -0
  29. package/src/util/distanceEpsilon.ts +3 -0
  30. package/src/util/getClosestPoint.ts +1 -1
  31. package/src/util/getPathBBox.ts +4 -3
  32. package/src/util/getPointAtLength.ts +3 -3
  33. package/src/util/getPropertiesAtLength.ts +2 -1
  34. package/src/util/getPropertiesAtPoint.ts +4 -1
  35. package/src/util/getTotalLength.ts +2 -2
  36. package/src/util/isPointInStroke.ts +2 -1
  37. package/src/util/pathFactory.ts +130 -0
  38. package/src/util/shapeToPathArray.ts +8 -4
  39. package/test/class.test.ts +501 -0
  40. package/test/fixtures/getMarkup.ts +17 -0
  41. package/{cypress → test}/fixtures/shapes.js +18 -18
  42. package/{cypress → test}/fixtures/simpleShapes.js +6 -6
  43. package/test/static.test.ts +304 -0
  44. package/tsconfig.json +9 -4
  45. package/{vite.config.ts → vite.config.mts} +10 -1
  46. package/vitest.config-ui.mts +26 -0
  47. package/vitest.config.mts +26 -0
  48. package/cypress/e2e/svg-path-commander.spec.ts +0 -868
  49. package/cypress/plugins/esbuild-istanbul.ts +0 -50
  50. package/cypress/plugins/tsCompile.ts +0 -34
  51. package/cypress/support/commands.ts +0 -37
  52. package/cypress/support/e2e.ts +0 -21
  53. package/cypress/test.html +0 -36
  54. package/src/util/pathLengthFactory.ts +0 -114
  55. package/src/util/segmentArcFactory.ts +0 -219
  56. package/src/util/segmentCubicFactory.ts +0 -114
  57. package/src/util/segmentLineFactory.ts +0 -45
  58. package/src/util/segmentQuadFactory.ts +0 -109
  59. /package/{cypress/fixtures/shapeObjects.js → test/fixtures/shapeObjects.ts} +0 -0
@@ -1,10 +1,10 @@
1
- var te = Object.defineProperty;
2
- var ee = (e, t, n) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var N = (e, t, n) => (ee(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- const mt = {
1
+ var oe = Object.defineProperty;
2
+ var ce = (e, t, n) => t in e ? oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var M = (e, t, n) => ce(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const ht = {
5
5
  origin: [0, 0, 0],
6
6
  round: 4
7
- }, k = "SVGPathCommander Error", U = {
7
+ }, $ = "SVGPathCommander Error", U = {
8
8
  a: 7,
9
9
  c: 6,
10
10
  h: 1,
@@ -16,62 +16,62 @@ const mt = {
16
16
  t: 2,
17
17
  v: 1,
18
18
  z: 0
19
- }, Tt = (e) => {
19
+ }, Lt = (e) => {
20
20
  let t = e.pathValue[e.segmentStart], n = t.toLowerCase();
21
- const { data: r } = e;
22
- for (; r.length >= U[n] && (n === "m" && r.length > 2 ? (e.segments.push([t, ...r.splice(0, 2)]), n = "l", t = t === "m" ? "l" : "L") : e.segments.push([t, ...r.splice(0, U[n])]), !!U[n]); )
21
+ const { data: s } = e;
22
+ for (; s.length >= U[n] && (n === "m" && s.length > 2 ? (e.segments.push([t, ...s.splice(0, 2)]), n = "l", t = t === "m" ? "l" : "L") : e.segments.push([t, ...s.splice(0, U[n])]), !!U[n]); )
23
23
  ;
24
- }, ne = (e) => {
25
- const { index: t, pathValue: n } = e, r = n.charCodeAt(t);
26
- if (r === 48) {
24
+ }, le = (e) => {
25
+ const { index: t, pathValue: n } = e, s = n.charCodeAt(t);
26
+ if (s === 48) {
27
27
  e.param = 0, e.index += 1;
28
28
  return;
29
29
  }
30
- if (r === 49) {
30
+ if (s === 49) {
31
31
  e.param = 1, e.index += 1;
32
32
  return;
33
33
  }
34
- e.err = `${k}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`;
35
- }, D = (e) => e >= 48 && e <= 57, R = "Invalid path value", se = (e) => {
36
- const { max: t, pathValue: n, index: r } = e;
37
- let s = r, i = !1, o = !1, a = !1, l = !1, c;
38
- if (s >= t) {
39
- e.err = `${k}: ${R} at index ${s}, "pathValue" is missing param`;
34
+ e.err = `${$}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`;
35
+ }, X = (e) => e >= 48 && e <= 57, Z = "Invalid path value", ae = (e) => {
36
+ const { max: t, pathValue: n, index: s } = e;
37
+ let r = s, i = !1, o = !1, c = !1, a = !1, l;
38
+ if (r >= t) {
39
+ e.err = `${$}: ${Z} at index ${r}, "pathValue" is missing param`;
40
40
  return;
41
41
  }
42
- if (c = n.charCodeAt(s), (c === 43 || c === 45) && (s += 1, c = n.charCodeAt(s)), !D(c) && c !== 46) {
43
- e.err = `${k}: ${R} at index ${s}, "${n[s]}" is not a number`;
42
+ if (l = n.charCodeAt(r), (l === 43 || l === 45) && (r += 1, l = n.charCodeAt(r)), !X(l) && l !== 46) {
43
+ e.err = `${$}: ${Z} at index ${r}, "${n[r]}" is not a number`;
44
44
  return;
45
45
  }
46
- if (c !== 46) {
47
- if (i = c === 48, s += 1, c = n.charCodeAt(s), i && s < t && c && D(c)) {
48
- e.err = `${k}: ${R} at index ${r}, "${n[r]}" illegal number`;
46
+ if (l !== 46) {
47
+ if (i = l === 48, r += 1, l = n.charCodeAt(r), i && r < t && l && X(l)) {
48
+ e.err = `${$}: ${Z} at index ${s}, "${n[s]}" illegal number`;
49
49
  return;
50
50
  }
51
- for (; s < t && D(n.charCodeAt(s)); )
52
- s += 1, o = !0;
53
- c = n.charCodeAt(s);
54
- }
55
- if (c === 46) {
56
- for (l = !0, s += 1; D(n.charCodeAt(s)); )
57
- s += 1, a = !0;
58
- c = n.charCodeAt(s);
59
- }
60
- if (c === 101 || c === 69) {
61
- if (l && !o && !a) {
62
- e.err = `${k}: ${R} at index ${s}, "${n[s]}" invalid float exponent`;
51
+ for (; r < t && X(n.charCodeAt(r)); )
52
+ r += 1, o = !0;
53
+ l = n.charCodeAt(r);
54
+ }
55
+ if (l === 46) {
56
+ for (a = !0, r += 1; X(n.charCodeAt(r)); )
57
+ r += 1, c = !0;
58
+ l = n.charCodeAt(r);
59
+ }
60
+ if (l === 101 || l === 69) {
61
+ if (a && !o && !c) {
62
+ e.err = `${$}: ${Z} at index ${r}, "${n[r]}" invalid float exponent`;
63
63
  return;
64
64
  }
65
- if (s += 1, c = n.charCodeAt(s), (c === 43 || c === 45) && (s += 1), s < t && D(n.charCodeAt(s)))
66
- for (; s < t && D(n.charCodeAt(s)); )
67
- s += 1;
65
+ if (r += 1, l = n.charCodeAt(r), (l === 43 || l === 45) && (r += 1), r < t && X(n.charCodeAt(r)))
66
+ for (; r < t && X(n.charCodeAt(r)); )
67
+ r += 1;
68
68
  else {
69
- e.err = `${k}: ${R} at index ${s}, "${n[s]}" invalid integer exponent`;
69
+ e.err = `${$}: ${Z} at index ${r}, "${n[r]}" invalid integer exponent`;
70
70
  return;
71
71
  }
72
72
  }
73
- e.index = s, e.param = +e.pathValue.slice(r, s);
74
- }, re = (e) => [
73
+ e.index = r, e.param = +e.pathValue.slice(s, r);
74
+ }, me = (e) => [
75
75
  // Special spaces
76
76
  5760,
77
77
  6158,
@@ -103,9 +103,9 @@ const mt = {
103
103
  160
104
104
  ].includes(e), V = (e) => {
105
105
  const { pathValue: t, max: n } = e;
106
- for (; e.index < n && re(t.charCodeAt(e.index)); )
106
+ for (; e.index < n && me(t.charCodeAt(e.index)); )
107
107
  e.index += 1;
108
- }, ie = (e) => {
108
+ }, he = (e) => {
109
109
  switch (e | 32) {
110
110
  case 109:
111
111
  case 122:
@@ -121,53 +121,67 @@ const mt = {
121
121
  default:
122
122
  return !1;
123
123
  }
124
- }, oe = (e) => D(e) || e === 43 || e === 45 || e === 46, ce = (e) => (e | 32) === 97, jt = (e) => {
125
- const { max: t, pathValue: n, index: r } = e, s = n.charCodeAt(r), i = U[n[r].toLowerCase()];
126
- if (e.segmentStart = r, !ie(s)) {
127
- e.err = `${k}: ${R} "${n[r]}" is not a path command`;
124
+ }, ue = (e) => X(e) || e === 43 || e === 45 || e === 46, fe = (e) => (e | 32) === 97, ge = (e) => {
125
+ switch (e | 32) {
126
+ case 109:
127
+ case 77:
128
+ return !0;
129
+ default:
130
+ return !1;
131
+ }
132
+ }, Dt = (e) => {
133
+ var a;
134
+ const { max: t, pathValue: n, index: s, segments: r } = e, i = n.charCodeAt(s), o = U[n[s].toLowerCase()];
135
+ if (e.segmentStart = s, !he(i)) {
136
+ e.err = `${$}: ${Z} "${n[s]}" is not a path command at index ${s}`;
128
137
  return;
129
138
  }
130
- if (e.index += 1, V(e), e.data = [], !i) {
131
- Tt(e);
139
+ const c = r[r.length - 1];
140
+ if (!ge(i) && ((a = c == null ? void 0 : c[0]) == null ? void 0 : a.toLocaleLowerCase()) === "z") {
141
+ e.err = `${$}: ${Z} "${n[s]}" is not a MoveTo path command at index ${s}`;
142
+ return;
143
+ }
144
+ if (e.index += 1, V(e), e.data = [], !o) {
145
+ Lt(e);
132
146
  return;
133
147
  }
134
148
  for (; ; ) {
135
- for (let o = i; o > 0; o -= 1) {
136
- if (ce(s) && (o === 3 || o === 4) ? ne(e) : se(e), e.err.length)
149
+ for (let l = o; l > 0; l -= 1) {
150
+ if (fe(i) && (l === 3 || l === 4) ? le(e) : ae(e), e.err.length)
137
151
  return;
138
152
  e.data.push(e.param), V(e), e.index < t && n.charCodeAt(e.index) === 44 && (e.index += 1, V(e));
139
153
  }
140
- if (e.index >= e.max || !oe(n.charCodeAt(e.index)))
154
+ if (e.index >= e.max || !ue(n.charCodeAt(e.index)))
141
155
  break;
142
156
  }
143
- Tt(e);
157
+ Lt(e);
144
158
  };
145
- class zt {
159
+ class Rt {
146
160
  constructor(t) {
147
161
  this.segments = [], this.pathValue = t, this.max = t.length, this.index = 0, this.param = 0, this.segmentStart = 0, this.data = [], this.err = "";
148
162
  }
149
163
  }
150
- const _ = (e) => Array.isArray(e) && e.every((t) => {
164
+ const G = (e) => Array.isArray(e) && e.every((t) => {
151
165
  const n = t[0].toLowerCase();
152
166
  return U[n] === t.length - 1 && "achlmqstvz".includes(n) && t.slice(1).every(Number.isFinite);
153
- }) && e.length > 0, Z = (e) => {
154
- if (_(e))
155
- return [...e];
156
- const t = new zt(e);
167
+ }) && e.length > 0, Y = (e) => {
168
+ if (G(e))
169
+ return e.slice(0);
170
+ const t = new Rt(e);
157
171
  for (V(t); t.index < t.max && !t.err.length; )
158
- jt(t);
172
+ Dt(t);
159
173
  if (t.err && t.err.length)
160
174
  throw TypeError(t.err);
161
175
  return t.segments;
162
- }, le = (e) => {
176
+ }, ye = (e) => {
163
177
  const t = e.length;
164
- let n = -1, r, s = e[t - 1], i = 0;
178
+ let n = -1, s, r = e[t - 1], i = 0;
165
179
  for (; ++n < t; )
166
- r = s, s = e[n], i += r[1] * s[0] - r[0] * s[1];
180
+ s = r, r = e[n], i += s[1] * r[0] - s[0] * r[1];
167
181
  return i / 2;
168
- }, W = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), ae = (e) => e.reduce((t, n, r) => r ? t + W(e[r - 1], n) : 0, 0);
169
- var me = Object.defineProperty, he = (e, t, n) => t in e ? me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (he(e, typeof t != "symbol" ? t + "" : t, n), n);
170
- const ue = {
182
+ }, Xt = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), xe = (e) => e.reduce((t, n, s) => s ? t + Xt(e[s - 1], n) : 0, 0);
183
+ var pe = Object.defineProperty, be = (e, t, n) => t in e ? pe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => be(e, typeof t != "symbol" ? t + "" : t, n);
184
+ const de = {
171
185
  a: 1,
172
186
  b: 0,
173
187
  c: 0,
@@ -192,21 +206,21 @@ const ue = {
192
206
  m44: 1,
193
207
  is2D: !0,
194
208
  isIdentity: !0
195
- }, It = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), Dt = (e) => e instanceof DOMMatrix || e instanceof v || typeof e == "object" && Object.keys(ue).every((t) => e && t in e), G = (e) => {
196
- const t = new v(), n = Array.from(e);
197
- if (!It(n))
209
+ }, Zt = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), Yt = (e) => e instanceof DOMMatrix || e instanceof P || typeof e == "object" && Object.keys(de).every((t) => e && t in e), tt = (e) => {
210
+ const t = new P(), n = Array.from(e);
211
+ if (!Zt(n))
198
212
  throw TypeError(`CSSMatrix: "${n.join(",")}" must be an array with 6/16 numbers.`);
199
213
  if (n.length === 16) {
200
- const [r, s, i, o, a, l, c, m, u, y, g, f, h, x, p, b] = n;
201
- t.m11 = r, t.a = r, t.m21 = a, t.c = a, t.m31 = u, t.m41 = h, t.e = h, t.m12 = s, t.b = s, t.m22 = l, t.d = l, t.m32 = y, t.m42 = x, t.f = x, t.m13 = i, t.m23 = c, t.m33 = g, t.m43 = p, t.m14 = o, t.m24 = m, t.m34 = f, t.m44 = b;
214
+ const [s, r, i, o, c, a, l, m, u, y, x, f, h, g, p, b] = n;
215
+ t.m11 = s, t.a = s, t.m21 = c, t.c = c, t.m31 = u, t.m41 = h, t.e = h, t.m12 = r, t.b = r, t.m22 = a, t.d = a, t.m32 = y, t.m42 = g, t.f = g, t.m13 = i, t.m23 = l, t.m33 = x, t.m43 = p, t.m14 = o, t.m24 = m, t.m34 = f, t.m44 = b;
202
216
  } else if (n.length === 6) {
203
- const [r, s, i, o, a, l] = n;
204
- t.m11 = r, t.a = r, t.m12 = s, t.b = s, t.m21 = i, t.c = i, t.m22 = o, t.d = o, t.m41 = a, t.e = a, t.m42 = l, t.f = l;
217
+ const [s, r, i, o, c, a] = n;
218
+ t.m11 = s, t.a = s, t.m12 = r, t.b = r, t.m21 = i, t.c = i, t.m22 = o, t.d = o, t.m41 = c, t.e = c, t.m42 = a, t.f = a;
205
219
  }
206
220
  return t;
207
- }, Zt = (e) => {
208
- if (Dt(e))
209
- return G([
221
+ }, Qt = (e) => {
222
+ if (Yt(e))
223
+ return tt([
210
224
  e.m11,
211
225
  e.m12,
212
226
  e.m13,
@@ -229,44 +243,43 @@ const ue = {
229
243
  if (typeof e != "string")
230
244
  throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);
231
245
  const t = String(e).replace(/\s/g, "");
232
- let n = new v();
233
- const r = `CSSMatrix: invalid transform string "${e}"`;
234
- return t.split(")").filter((s) => s).forEach((s) => {
235
- const [i, o] = s.split("(");
236
- if (!o)
237
- throw TypeError(r);
238
- const a = o.split(",").map((f) => f.includes("rad") ? parseFloat(f) * (180 / Math.PI) : parseFloat(f)), [l, c, m, u] = a, y = [l, c, m], g = [l, c, m, u];
239
- if (i === "perspective" && l && [c, m].every((f) => f === void 0))
240
- n.m34 = -1 / l;
241
- else if (i.includes("matrix") && [6, 16].includes(a.length) && a.every((f) => !Number.isNaN(+f))) {
242
- const f = a.map((h) => Math.abs(h) < 1e-6 ? 0 : h);
243
- n = n.multiply(G(f));
246
+ let n = new P();
247
+ const s = `CSSMatrix: invalid transform string "${e}"`;
248
+ return t.split(")").filter((r) => r).forEach((r) => {
249
+ const [i, o] = r.split("(");
250
+ if (!o) throw TypeError(s);
251
+ const c = o.split(",").map((f) => f.includes("rad") ? parseFloat(f) * (180 / Math.PI) : parseFloat(f)), [a, l, m, u] = c, y = [a, l, m], x = [a, l, m, u];
252
+ if (i === "perspective" && a && [l, m].every((f) => f === void 0))
253
+ n.m34 = -1 / a;
254
+ else if (i.includes("matrix") && [6, 16].includes(c.length) && c.every((f) => !Number.isNaN(+f))) {
255
+ const f = c.map((h) => Math.abs(h) < 1e-6 ? 0 : h);
256
+ n = n.multiply(tt(f));
244
257
  } else if (i === "translate3d" && y.every((f) => !Number.isNaN(+f)))
245
- n = n.translate(l, c, m);
246
- else if (i === "translate" && l && m === void 0)
247
- n = n.translate(l, c || 0, 0);
248
- else if (i === "rotate3d" && g.every((f) => !Number.isNaN(+f)) && u)
249
- n = n.rotateAxisAngle(l, c, m, u);
250
- else if (i === "rotate" && l && [c, m].every((f) => f === void 0))
251
- n = n.rotate(0, 0, l);
258
+ n = n.translate(a, l, m);
259
+ else if (i === "translate" && a && m === void 0)
260
+ n = n.translate(a, l || 0, 0);
261
+ else if (i === "rotate3d" && x.every((f) => !Number.isNaN(+f)) && u)
262
+ n = n.rotateAxisAngle(a, l, m, u);
263
+ else if (i === "rotate" && a && [l, m].every((f) => f === void 0))
264
+ n = n.rotate(0, 0, a);
252
265
  else if (i === "scale3d" && y.every((f) => !Number.isNaN(+f)) && y.some((f) => f !== 1))
253
- n = n.scale(l, c, m);
254
- else if (i === "scale" && !Number.isNaN(l) && l !== 1 && m === void 0) {
255
- const f = Number.isNaN(+c) ? l : c;
256
- n = n.scale(l, f, 1);
257
- } else if (i === "skew" && (l || !Number.isNaN(l) && c) && m === void 0)
258
- n = n.skew(l, c || 0);
259
- else if (["translate", "rotate", "scale", "skew"].some((f) => i.includes(f)) && /[XYZ]/.test(i) && l && [c, m].every((f) => f === void 0))
266
+ n = n.scale(a, l, m);
267
+ else if (i === "scale" && !Number.isNaN(a) && a !== 1 && m === void 0) {
268
+ const f = Number.isNaN(+l) ? a : l;
269
+ n = n.scale(a, f, 1);
270
+ } else if (i === "skew" && (a || !Number.isNaN(a) && l) && m === void 0)
271
+ n = n.skew(a, l || 0);
272
+ else if (["translate", "rotate", "scale", "skew"].some((f) => i.includes(f)) && /[XYZ]/.test(i) && a && [l, m].every((f) => f === void 0))
260
273
  if (i === "skewX" || i === "skewY")
261
- n = n[i](l);
274
+ n = n[i](a);
262
275
  else {
263
- const f = i.replace(/[XYZ]/, ""), h = i.replace(f, ""), x = ["X", "Y", "Z"].indexOf(h), p = f === "scale" ? 1 : 0, b = [x === 0 ? l : p, x === 1 ? l : p, x === 2 ? l : p];
276
+ const f = i.replace(/[XYZ]/, ""), h = i.replace(f, ""), g = ["X", "Y", "Z"].indexOf(h), p = f === "scale" ? 1 : 0, b = [g === 0 ? a : p, g === 1 ? a : p, g === 2 ? a : p];
264
277
  n = n[f](...b);
265
278
  }
266
279
  else
267
- throw TypeError(r);
280
+ throw TypeError(s);
268
281
  }), n;
269
- }, bt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [
282
+ }, dt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [
270
283
  e.m11,
271
284
  e.m12,
272
285
  e.m13,
@@ -283,47 +296,47 @@ const ue = {
283
296
  e.m42,
284
297
  e.m43,
285
298
  e.m44
286
- ], Rt = (e, t, n) => {
287
- const r = new v();
288
- return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = n, r;
289
- }, Xt = (e, t, n) => {
290
- const r = new v(), s = Math.PI / 180, i = e * s, o = t * s, a = n * s, l = Math.cos(i), c = -Math.sin(i), m = Math.cos(o), u = -Math.sin(o), y = Math.cos(a), g = -Math.sin(a), f = m * y, h = -m * g;
291
- r.m11 = f, r.a = f, r.m12 = h, r.b = h, r.m13 = u;
292
- const x = c * u * y + l * g;
293
- r.m21 = x, r.c = x;
294
- const p = l * y - c * u * g;
295
- return r.m22 = p, r.d = p, r.m23 = -c * m, r.m31 = c * g - l * u * y, r.m32 = c * y + l * u * g, r.m33 = l * m, r;
296
- }, Qt = (e, t, n, r) => {
297
- const s = new v(), i = Math.sqrt(e * e + t * t + n * n);
299
+ ], Ht = (e, t, n) => {
300
+ const s = new P();
301
+ return s.m41 = e, s.e = e, s.m42 = t, s.f = t, s.m43 = n, s;
302
+ }, Bt = (e, t, n) => {
303
+ const s = new P(), r = Math.PI / 180, i = e * r, o = t * r, c = n * r, a = Math.cos(i), l = -Math.sin(i), m = Math.cos(o), u = -Math.sin(o), y = Math.cos(c), x = -Math.sin(c), f = m * y, h = -m * x;
304
+ s.m11 = f, s.a = f, s.m12 = h, s.b = h, s.m13 = u;
305
+ const g = l * u * y + a * x;
306
+ s.m21 = g, s.c = g;
307
+ const p = a * y - l * u * x;
308
+ return s.m22 = p, s.d = p, s.m23 = -l * m, s.m31 = l * x - a * u * y, s.m32 = l * y + a * u * x, s.m33 = a * m, s;
309
+ }, Jt = (e, t, n, s) => {
310
+ const r = new P(), i = Math.sqrt(e * e + t * t + n * n);
298
311
  if (i === 0)
299
- return s;
300
- const o = e / i, a = t / i, l = n / i, c = r * (Math.PI / 360), m = Math.sin(c), u = Math.cos(c), y = m * m, g = o * o, f = a * a, h = l * l, x = 1 - 2 * (f + h) * y;
301
- s.m11 = x, s.a = x;
302
- const p = 2 * (o * a * y + l * m * u);
303
- s.m12 = p, s.b = p, s.m13 = 2 * (o * l * y - a * m * u);
304
- const b = 2 * (a * o * y - l * m * u);
305
- s.m21 = b, s.c = b;
306
- const A = 1 - 2 * (h + g) * y;
307
- return s.m22 = A, s.d = A, s.m23 = 2 * (a * l * y + o * m * u), s.m31 = 2 * (l * o * y + a * m * u), s.m32 = 2 * (l * a * y - o * m * u), s.m33 = 1 - 2 * (g + f) * y, s;
308
- }, Ht = (e, t, n) => {
309
- const r = new v();
310
- return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = n, r;
311
- }, ht = (e, t) => {
312
- const n = new v();
312
+ return r;
313
+ const o = e / i, c = t / i, a = n / i, l = s * (Math.PI / 360), m = Math.sin(l), u = Math.cos(l), y = m * m, x = o * o, f = c * c, h = a * a, g = 1 - 2 * (f + h) * y;
314
+ r.m11 = g, r.a = g;
315
+ const p = 2 * (o * c * y + a * m * u);
316
+ r.m12 = p, r.b = p, r.m13 = 2 * (o * a * y - c * m * u);
317
+ const b = 2 * (c * o * y - a * m * u);
318
+ r.m21 = b, r.c = b;
319
+ const v = 1 - 2 * (h + x) * y;
320
+ return r.m22 = v, r.d = v, r.m23 = 2 * (c * a * y + o * m * u), r.m31 = 2 * (a * o * y + c * m * u), r.m32 = 2 * (a * c * y - o * m * u), r.m33 = 1 - 2 * (x + f) * y, r;
321
+ }, _t = (e, t, n) => {
322
+ const s = new P();
323
+ return s.m11 = e, s.a = e, s.m22 = t, s.d = t, s.m33 = n, s;
324
+ }, ut = (e, t) => {
325
+ const n = new P();
313
326
  if (e) {
314
- const r = e * Math.PI / 180, s = Math.tan(r);
315
- n.m21 = s, n.c = s;
327
+ const s = e * Math.PI / 180, r = Math.tan(s);
328
+ n.m21 = r, n.c = r;
316
329
  }
317
330
  if (t) {
318
- const r = t * Math.PI / 180, s = Math.tan(r);
319
- n.m12 = s, n.b = s;
331
+ const s = t * Math.PI / 180, r = Math.tan(s);
332
+ n.m12 = r, n.b = r;
320
333
  }
321
334
  return n;
322
- }, Yt = (e) => ht(e, 0), Bt = (e) => ht(0, e), O = (e, t) => {
323
- const n = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41, r = t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42, s = t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43, i = t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44, o = t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41, a = t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42, l = t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43, c = t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44, m = t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41, u = t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42, y = t.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43, g = t.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44, f = t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41, h = t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42, x = t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43, p = t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44;
324
- return G([n, r, s, i, o, a, l, c, m, u, y, g, f, h, x, p]);
335
+ }, Kt = (e) => ut(e, 0), Ut = (e) => ut(0, e), E = (e, t) => {
336
+ const n = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41, s = t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42, r = t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43, i = t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44, o = t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41, c = t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42, a = t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43, l = t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44, m = t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41, u = t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42, y = t.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43, x = t.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44, f = t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41, h = t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42, g = t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43, p = t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44;
337
+ return tt([n, s, r, i, o, c, a, l, m, u, y, x, f, h, g, p]);
325
338
  };
326
- class v {
339
+ class P {
327
340
  /**
328
341
  * @constructor
329
342
  * @param init accepts all parameter configurations:
@@ -368,7 +381,7 @@ class v {
368
381
  * @return the matrix instance
369
382
  */
370
383
  setMatrixValue(t) {
371
- return typeof t == "string" && t.length && t !== "none" ? Ft(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? G(t) : typeof t == "object" ? Zt(t) : this;
384
+ return typeof t == "string" && t.length && t !== "none" ? Ft(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? tt(t) : typeof t == "object" ? Qt(t) : this;
372
385
  }
373
386
  /**
374
387
  * Returns a *Float32Array* containing elements which comprise the matrix.
@@ -379,7 +392,7 @@ class v {
379
392
  * @return an *Array* representation of the matrix
380
393
  */
381
394
  toFloat32Array(t) {
382
- return Float32Array.from(bt(this, t));
395
+ return Float32Array.from(dt(this, t));
383
396
  }
384
397
  /**
385
398
  * Returns a *Float64Array* containing elements which comprise the matrix.
@@ -390,7 +403,7 @@ class v {
390
403
  * @return an *Array* representation of the matrix
391
404
  */
392
405
  toFloat64Array(t) {
393
- return Float64Array.from(bt(this, t));
406
+ return Float64Array.from(dt(this, t));
394
407
  }
395
408
  /**
396
409
  * Creates and returns a string representation of the matrix in `CSS` matrix syntax,
@@ -428,7 +441,7 @@ class v {
428
441
  * @return The resulted matrix.
429
442
  */
430
443
  multiply(t) {
431
- return O(this, t);
444
+ return E(this, t);
432
445
  }
433
446
  /**
434
447
  * The translate method returns a new matrix which is this matrix post
@@ -441,10 +454,10 @@ class v {
441
454
  * @param z Z component of the translation value.
442
455
  * @return The resulted matrix
443
456
  */
444
- translate(t, n, r) {
445
- const s = t;
446
- let i = n, o = r;
447
- return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0), O(this, Rt(s, i, o));
457
+ translate(t, n, s) {
458
+ const r = t;
459
+ let i = n, o = s;
460
+ return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0), E(this, Ht(r, i, o));
448
461
  }
449
462
  /**
450
463
  * The scale method returns a new matrix which is this matrix post multiplied by
@@ -457,10 +470,10 @@ class v {
457
470
  * @param z The Z component of the scale value.
458
471
  * @return The resulted matrix
459
472
  */
460
- scale(t, n, r) {
461
- const s = t;
462
- let i = n, o = r;
463
- return typeof i > "u" && (i = t), typeof o > "u" && (o = 1), O(this, Ht(s, i, o));
473
+ scale(t, n, s) {
474
+ const r = t;
475
+ let i = n, o = s;
476
+ return typeof i > "u" && (i = t), typeof o > "u" && (o = 1), E(this, _t(r, i, o));
464
477
  }
465
478
  /**
466
479
  * The rotate method returns a new matrix which is this matrix post multiplied
@@ -474,9 +487,9 @@ class v {
474
487
  * @param rz The (optional) Z component of the rotation value.
475
488
  * @return The resulted matrix
476
489
  */
477
- rotate(t, n, r) {
478
- let s = t, i = n || 0, o = r || 0;
479
- return typeof t == "number" && typeof n > "u" && typeof r > "u" && (o = s, s = 0, i = 0), O(this, Xt(s, i, o));
490
+ rotate(t, n, s) {
491
+ let r = t, i = n || 0, o = s || 0;
492
+ return typeof t == "number" && typeof n > "u" && typeof s > "u" && (o = r, r = 0, i = 0), E(this, Bt(r, i, o));
480
493
  }
481
494
  /**
482
495
  * The rotateAxisAngle method returns a new matrix which is this matrix post
@@ -490,10 +503,10 @@ class v {
490
503
  * @param angle The angle of rotation about the axis vector, in degrees.
491
504
  * @return The resulted matrix
492
505
  */
493
- rotateAxisAngle(t, n, r, s) {
494
- if ([t, n, r, s].some((i) => Number.isNaN(+i)))
506
+ rotateAxisAngle(t, n, s, r) {
507
+ if ([t, n, s, r].some((i) => Number.isNaN(+i)))
495
508
  throw new TypeError("CSSMatrix: expecting 4 values");
496
- return O(this, Qt(t, n, r, s));
509
+ return E(this, Jt(t, n, s, r));
497
510
  }
498
511
  /**
499
512
  * Specifies a skew transformation along the `x-axis` by the given angle.
@@ -503,7 +516,7 @@ class v {
503
516
  * @return The resulted matrix
504
517
  */
505
518
  skewX(t) {
506
- return O(this, Yt(t));
519
+ return E(this, Kt(t));
507
520
  }
508
521
  /**
509
522
  * Specifies a skew transformation along the `y-axis` by the given angle.
@@ -513,7 +526,7 @@ class v {
513
526
  * @return The resulted matrix
514
527
  */
515
528
  skewY(t) {
516
- return O(this, Bt(t));
529
+ return E(this, Ut(t));
517
530
  }
518
531
  /**
519
532
  * Specifies a skew transformation along both the `x-axis` and `y-axis`.
@@ -524,7 +537,7 @@ class v {
524
537
  * @return The resulted matrix
525
538
  */
526
539
  skew(t, n) {
527
- return O(this, ht(t, n));
540
+ return E(this, ut(t, n));
528
541
  }
529
542
  /**
530
543
  * Transforms a specified vector using the matrix, returning a new
@@ -538,76 +551,76 @@ class v {
538
551
  * @return the resulting Tuple
539
552
  */
540
553
  transformPoint(t) {
541
- const n = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w, r = this.m12 * t.x + this.m22 * t.y + this.m32 * t.z + this.m42 * t.w, s = this.m13 * t.x + this.m23 * t.y + this.m33 * t.z + this.m43 * t.w, i = this.m14 * t.x + this.m24 * t.y + this.m34 * t.z + this.m44 * t.w;
542
- return t instanceof DOMPoint ? new DOMPoint(n, r, s, i) : {
554
+ const n = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w, s = this.m12 * t.x + this.m22 * t.y + this.m32 * t.z + this.m42 * t.w, r = this.m13 * t.x + this.m23 * t.y + this.m33 * t.z + this.m43 * t.w, i = this.m14 * t.x + this.m24 * t.y + this.m34 * t.z + this.m44 * t.w;
555
+ return t instanceof DOMPoint ? new DOMPoint(n, s, r, i) : {
543
556
  x: n,
544
- y: r,
545
- z: s,
557
+ y: s,
558
+ z: r,
546
559
  w: i
547
560
  };
548
561
  }
549
562
  }
550
- C(v, "Translate", Rt), C(v, "Rotate", Xt), C(v, "RotateAxisAngle", Qt), C(v, "Scale", Ht), C(v, "SkewX", Yt), C(v, "SkewY", Bt), C(v, "Skew", ht), C(v, "Multiply", O), C(v, "fromArray", G), C(v, "fromMatrix", Zt), C(v, "fromString", Ft), C(v, "toArray", bt), C(v, "isCompatibleArray", It), C(v, "isCompatibleObject", Dt);
551
- const wt = (e) => _(e) && // `isPathArray` also checks if it's `Array`
552
- e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
553
- if (wt(e))
554
- return [...e];
555
- const t = Z(e);
556
- let n = 0, r = 0, s = 0, i = 0;
563
+ C(P, "Translate", Ht), C(P, "Rotate", Bt), C(P, "RotateAxisAngle", Jt), C(P, "Scale", _t), C(P, "SkewX", Kt), C(P, "SkewY", Ut), C(P, "Skew", ut), C(P, "Multiply", E), C(P, "fromArray", tt), C(P, "fromMatrix", Qt), C(P, "fromString", Ft), C(P, "toArray", dt), C(P, "isCompatibleArray", Zt), C(P, "isCompatibleObject", Yt);
564
+ const ft = (e) => G(e) && // `isPathArray` also checks if it's `Array`
565
+ e.every(([t]) => t === t.toUpperCase()), H = (e) => {
566
+ if (ft(e))
567
+ return e.slice(0);
568
+ const t = Y(e);
569
+ let n = 0, s = 0, r = 0, i = 0;
557
570
  return t.map((o) => {
558
- const a = o.slice(1).map(Number), [l] = o, c = l.toUpperCase();
559
- if (l === "M")
560
- return [n, r] = a, s = n, i = r, ["M", n, r];
571
+ const c = o.slice(1).map(Number), [a] = o, l = a.toUpperCase();
572
+ if (a === "M")
573
+ return [n, s] = c, r = n, i = s, ["M", n, s];
561
574
  let m = [];
562
- if (l !== c)
563
- if (c === "A")
575
+ if (a !== l)
576
+ if (l === "A")
564
577
  m = [
565
- c,
566
- a[0],
567
- a[1],
568
- a[2],
569
- a[3],
570
- a[4],
571
- a[5] + n,
572
- a[6] + r
578
+ l,
579
+ c[0],
580
+ c[1],
581
+ c[2],
582
+ c[3],
583
+ c[4],
584
+ c[5] + n,
585
+ c[6] + s
573
586
  ];
574
- else if (c === "V")
575
- m = [c, a[0] + r];
576
- else if (c === "H")
577
- m = [c, a[0] + n];
587
+ else if (l === "V")
588
+ m = [l, c[0] + s];
589
+ else if (l === "H")
590
+ m = [l, c[0] + n];
578
591
  else {
579
- const u = a.map((y, g) => y + (g % 2 ? r : n));
580
- m = [c, ...u];
592
+ const u = c.map((y, x) => y + (x % 2 ? s : n));
593
+ m = [l, ...u];
581
594
  }
582
595
  else
583
- m = [c, ...a];
584
- return c === "Z" ? (n = s, r = i) : c === "H" ? [, n] = m : c === "V" ? [, r] = m : ([n, r] = m.slice(-2), c === "M" && (s = n, i = r)), m;
596
+ m = [l, ...c];
597
+ return l === "Z" ? (n = r, s = i) : l === "H" ? [, n] = m : l === "V" ? [, s] = m : ([n, s] = m.slice(-2), l === "M" && (r = n, i = s)), m;
585
598
  });
586
- }, fe = (e, t) => {
587
- const [n] = e, { x1: r, y1: s, x2: i, y2: o } = t, a = e.slice(1).map(Number);
588
- let l = e;
599
+ }, Me = (e, t) => {
600
+ const [n] = e, { x1: s, y1: r, x2: i, y2: o } = t, c = e.slice(1).map(Number);
601
+ let a = e;
589
602
  if ("TQ".includes(n) || (t.qx = null, t.qy = null), n === "H")
590
- l = ["L", e[1], s];
603
+ a = ["L", e[1], r];
591
604
  else if (n === "V")
592
- l = ["L", r, e[1]];
605
+ a = ["L", s, e[1]];
593
606
  else if (n === "S") {
594
- const c = r * 2 - i, m = s * 2 - o;
595
- t.x1 = c, t.y1 = m, l = ["C", c, m, ...a];
607
+ const l = s * 2 - i, m = r * 2 - o;
608
+ t.x1 = l, t.y1 = m, a = ["C", l, m, ...c];
596
609
  } else if (n === "T") {
597
- const c = r * 2 - (t.qx ? t.qx : (
610
+ const l = s * 2 - (t.qx ? t.qx : (
598
611
  /* istanbul ignore next */
599
612
  0
600
- )), m = s * 2 - (t.qy ? t.qy : (
613
+ )), m = r * 2 - (t.qy ? t.qy : (
601
614
  /* istanbul ignore next */
602
615
  0
603
616
  ));
604
- t.qx = c, t.qy = m, l = ["Q", c, m, ...a];
617
+ t.qx = l, t.qy = m, a = ["Q", l, m, ...c];
605
618
  } else if (n === "Q") {
606
- const [c, m] = a;
607
- t.qx = c, t.qy = m;
619
+ const [l, m] = c;
620
+ t.qx = l, t.qy = m;
608
621
  }
609
- return l;
610
- }, vt = (e) => wt(e) && e.every(([t]) => "ACLMQZ".includes(t)), ut = {
622
+ return a;
623
+ }, gt = (e) => ft(e) && e.every(([t]) => "ACLMQZ".includes(t)), et = {
611
624
  x1: 0,
612
625
  y1: 0,
613
626
  x2: 0,
@@ -616,208 +629,348 @@ e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
616
629
  y: 0,
617
630
  qx: null,
618
631
  qy: null
619
- }, z = (e) => {
620
- if (vt(e))
621
- return [...e];
622
- const t = Q(e), n = { ...ut }, r = t.length;
623
- for (let s = 0; s < r; s += 1) {
624
- t[s], t[s] = fe(t[s], n);
625
- const i = t[s], o = i.length;
632
+ }, O = (e) => {
633
+ if (gt(e))
634
+ return e.slice(0);
635
+ const t = H(e), n = { ...et }, s = t.length;
636
+ for (let r = 0; r < s; r += 1) {
637
+ t[r], t[r] = Me(t[r], n);
638
+ const i = t[r], o = i.length;
626
639
  n.x1 = +i[o - 2], n.y1 = +i[o - 1], n.x2 = +i[o - 4] || n.x1, n.y2 = +i[o - 3] || n.y1;
627
640
  }
628
641
  return t;
629
- }, E = (e, t, n) => {
630
- const [r, s] = e, [i, o] = t;
631
- return [r + (i - r) * n, s + (o - s) * n];
632
- }, dt = (e, t, n, r, s) => {
633
- const i = W([e, t], [n, r]);
634
- let o = { x: 0, y: 0 };
635
- if (typeof s == "number")
636
- if (s <= 0)
637
- o = { x: e, y: t };
638
- else if (s >= i)
639
- o = { x: n, y: r };
642
+ }, z = (e, t, n) => {
643
+ const [s, r] = e, [i, o] = t;
644
+ return [s + (i - s) * n, r + (o - r) * n];
645
+ }, Mt = (e, t, n, s, r) => {
646
+ const { min: i, max: o } = Math;
647
+ let c = { x: 0, y: 0 };
648
+ const a = () => Xt([e, t], [n, s]);
649
+ if (typeof r == "number") {
650
+ const l = a();
651
+ if (r <= 0)
652
+ c = { x: e, y: t };
653
+ else if (r >= l)
654
+ c = { x: n, y: s };
640
655
  else {
641
- const [a, l] = E([e, t], [n, r], s / i);
642
- o = { x: a, y: l };
656
+ const [m, u] = z([e, t], [n, s], r / l);
657
+ c = { x: m, y: u };
643
658
  }
659
+ }
644
660
  return {
645
- length: i,
646
- point: o,
647
- min: {
648
- x: Math.min(e, n),
649
- y: Math.min(t, r)
661
+ point: c,
662
+ get length() {
663
+ return a();
650
664
  },
651
- max: {
652
- x: Math.max(e, n),
653
- y: Math.max(t, r)
665
+ get bbox() {
666
+ return {
667
+ min: {
668
+ x: i(e, n),
669
+ y: i(t, s)
670
+ },
671
+ max: {
672
+ x: o(e, n),
673
+ y: o(t, s)
674
+ }
675
+ };
654
676
  }
655
677
  };
656
- }, Lt = (e, t) => {
657
- const { x: n, y: r } = e, { x: s, y: i } = t, o = n * s + r * i, a = Math.sqrt((n ** 2 + r ** 2) * (s ** 2 + i ** 2));
658
- return (n * i - r * s < 0 ? -1 : 1) * Math.acos(o / a);
659
- }, ye = (e, t, n, r, s, i, o, a, l, c) => {
660
- const { abs: m, sin: u, cos: y, sqrt: g, PI: f } = Math;
661
- let h = m(n), x = m(r);
662
- const b = (s % 360 + 360) % 360 * (f / 180);
663
- if (e === a && t === l)
664
- return { x: e, y: t };
665
- if (h === 0 || x === 0)
666
- return dt(e, t, a, l, c).point;
667
- const A = (e - a) / 2, d = (t - l) / 2, M = {
668
- x: y(b) * A + u(b) * d,
669
- y: -u(b) * A + y(b) * d
670
- }, T = M.x ** 2 / h ** 2 + M.y ** 2 / x ** 2;
671
- T > 1 && (h *= g(T), x *= g(T));
672
- const j = h ** 2 * x ** 2 - h ** 2 * M.y ** 2 - x ** 2 * M.x ** 2, H = h ** 2 * M.y ** 2 + x ** 2 * M.x ** 2;
673
- let F = j / H;
674
- F = F < 0 ? 0 : F;
675
- const tt = (i !== o ? 1 : -1) * g(F), S = {
676
- x: tt * (h * M.y / x),
677
- y: tt * (-(x * M.x) / h)
678
- }, et = {
679
- x: y(b) * S.x - u(b) * S.y + (e + a) / 2,
680
- y: u(b) * S.x + y(b) * S.y + (t + l) / 2
681
- }, Y = {
682
- x: (M.x - S.x) / h,
683
- y: (M.y - S.y) / x
684
- }, nt = Lt({ x: 1, y: 0 }, Y), st = {
685
- x: (-M.x - S.x) / h,
686
- y: (-M.y - S.y) / x
687
- };
688
- let $ = Lt(Y, st);
689
- !o && $ > 0 ? $ -= 2 * f : o && $ < 0 && ($ += 2 * f), $ %= 2 * f;
690
- const q = nt + $ * c, B = h * y(q), J = x * u(q);
678
+ }, Ne = (e, t, n) => {
679
+ const s = n / 2, r = Math.sin(s), i = Math.cos(s), o = e ** 2 * r ** 2, c = t ** 2 * i ** 2, a = Math.sqrt(o + c) * n;
680
+ return Math.abs(a);
681
+ }, we = (e, t, n, s, r, i, o) => {
682
+ const { cos: c, sin: a, min: l, max: m } = Math, u = c(r), y = a(r), x = (v) => e + n * c(v) * u - s * a(v) * y, f = (v) => t + s * a(v) * u + n * c(v) * y, h = x(i), g = f(i), p = x(o), b = f(o);
691
683
  return {
692
- x: y(b) * B - u(b) * J + et.x,
693
- y: u(b) * B + y(b) * J + et.y
684
+ min: { x: l(h, p), y: l(g, b) },
685
+ max: { x: m(h, p), y: m(g, b) }
694
686
  };
695
- }, ge = (e, t, n, r, s, i, o, a, l, c) => {
696
- const m = typeof c == "number";
697
- let u = e, y = t, g = 0, f = [u, y, g], h = [u, y], x = 0, p = { x: 0, y: 0 }, b = [{ x: u, y }];
698
- m && c <= 0 && (p = { x: u, y });
699
- const A = 300;
700
- for (let d = 0; d <= A; d += 1) {
701
- if (x = d / A, { x: u, y } = ye(e, t, n, r, s, i, o, a, l, x), b = [...b, { x: u, y }], g += W(h, [u, y]), h = [u, y], m && g > c && c > f[2]) {
702
- const M = (g - c) / (g - f[2]);
703
- p = {
704
- x: h[0] * (1 - M) + f[0] * M,
705
- y: h[1] * (1 - M) + f[1] * M
706
- };
707
- }
708
- f = [u, y, g];
709
- }
710
- return m && c >= g && (p = { x: a, y: l }), {
711
- length: g,
712
- point: p,
713
- min: {
714
- x: Math.min(...b.map((d) => d.x)),
715
- y: Math.min(...b.map((d) => d.y))
687
+ }, $t = (e, t) => {
688
+ const { x: n, y: s } = e, { x: r, y: i } = t, o = n * r + s * i, c = Math.sqrt((n ** 2 + s ** 2) * (r ** 2 + i ** 2));
689
+ return (n * i - s * r < 0 ? -1 : 1) * Math.acos(o / c);
690
+ }, ve = (e, t, n, s, r, i, o, c, a, l) => {
691
+ const { abs: m, sin: u, cos: y, sqrt: x, PI: f } = Math;
692
+ let h = m(n), g = m(s);
693
+ const b = (r % 360 + 360) % 360 * (f / 180);
694
+ if (e === c && t === a)
695
+ return {
696
+ point: { x: c, y: a },
697
+ length: 0,
698
+ bbox: { min: { x: c, y: a }, max: { x: c, y: a } }
699
+ };
700
+ if (h === 0 || g === 0)
701
+ return Mt(e, t, c, a, l);
702
+ const v = (e - c) / 2, d = (t - a) / 2, w = {
703
+ x: y(b) * v + u(b) * d,
704
+ y: -u(b) * v + y(b) * d
705
+ }, T = w.x ** 2 / h ** 2 + w.y ** 2 / g ** 2;
706
+ T > 1 && (h *= x(T), g *= x(T));
707
+ const j = h ** 2 * g ** 2 - h ** 2 * w.y ** 2 - g ** 2 * w.x ** 2, B = h ** 2 * w.y ** 2 + g ** 2 * w.x ** 2;
708
+ let Q = j / B;
709
+ Q = Q < 0 ? 0 : Q;
710
+ const nt = (i !== o ? 1 : -1) * x(Q), q = {
711
+ x: nt * (h * w.y / g),
712
+ y: nt * (-(g * w.x) / h)
713
+ }, D = {
714
+ x: y(b) * q.x - u(b) * q.y + (e + c) / 2,
715
+ y: u(b) * q.x + y(b) * q.y + (t + a) / 2
716
+ }, J = {
717
+ x: (w.x - q.x) / h,
718
+ y: (w.y - q.y) / g
719
+ }, I = $t({ x: 1, y: 0 }, J), st = {
720
+ x: (-w.x - q.x) / h,
721
+ y: (-w.y - q.y) / g
722
+ };
723
+ let L = $t(J, st);
724
+ !o && L > 0 ? L -= 2 * f : o && L < 0 && (L += 2 * f), L %= 2 * f;
725
+ const S = I + L * (l || 0), rt = I + L, _ = h * y(S), K = g * u(S);
726
+ return {
727
+ point: {
728
+ x: y(b) * _ - u(b) * K + D.x,
729
+ y: u(b) * _ + y(b) * K + D.y
730
+ },
731
+ center: D,
732
+ angle: S,
733
+ startAngle: I,
734
+ endAngle: rt,
735
+ radiusX: h,
736
+ radiusY: g,
737
+ get length() {
738
+ return Ne(h, g, L);
716
739
  },
717
- max: {
718
- x: Math.max(...b.map((d) => d.x)),
719
- y: Math.max(...b.map((d) => d.y))
740
+ get bbox() {
741
+ return we(D.x, D.y, h, g, b, I, I + L);
720
742
  }
721
743
  };
722
- }, xe = (e, t, n, r, s, i, o, a, l) => {
723
- const c = 1 - l;
724
- return {
725
- x: c ** 3 * e + 3 * c ** 2 * l * n + 3 * c * l ** 2 * s + l ** 3 * o,
726
- y: c ** 3 * t + 3 * c ** 2 * l * r + 3 * c * l ** 2 * i + l ** 3 * a
744
+ }, Pe = { x: 0, y: 0 }, kt = [
745
+ -0.06405689286260563,
746
+ 0.06405689286260563,
747
+ -0.1911188674736163,
748
+ 0.1911188674736163,
749
+ -0.3150426796961634,
750
+ 0.3150426796961634,
751
+ -0.4337935076260451,
752
+ 0.4337935076260451,
753
+ -0.5454214713888396,
754
+ 0.5454214713888396,
755
+ -0.6480936519369755,
756
+ 0.6480936519369755,
757
+ -0.7401241915785544,
758
+ 0.7401241915785544,
759
+ -0.820001985973903,
760
+ 0.820001985973903,
761
+ -0.8864155270044011,
762
+ 0.8864155270044011,
763
+ -0.9382745520027328,
764
+ 0.9382745520027328,
765
+ -0.9747285559713095,
766
+ 0.9747285559713095,
767
+ -0.9951872199970213,
768
+ 0.9951872199970213
769
+ ], Ae = [
770
+ 0.12793819534675216,
771
+ 0.12793819534675216,
772
+ 0.1258374563468283,
773
+ 0.1258374563468283,
774
+ 0.12167047292780339,
775
+ 0.12167047292780339,
776
+ 0.1155056680537256,
777
+ 0.1155056680537256,
778
+ 0.10744427011596563,
779
+ 0.10744427011596563,
780
+ 0.09761865210411388,
781
+ 0.09761865210411388,
782
+ 0.08619016153195327,
783
+ 0.08619016153195327,
784
+ 0.0733464814110803,
785
+ 0.0733464814110803,
786
+ 0.05929858491543678,
787
+ 0.05929858491543678,
788
+ 0.04427743881741981,
789
+ 0.04427743881741981,
790
+ 0.028531388628933663,
791
+ 0.028531388628933663,
792
+ 0.0123412297999872,
793
+ 0.0123412297999872
794
+ ], Ce = (e) => {
795
+ const t = [];
796
+ for (let n = e, s = n.length, r = s - 1; s > 1; s -= 1, r -= 1) {
797
+ const i = [];
798
+ for (let o = 0; o < r; o += 1)
799
+ i.push({
800
+ x: r * (n[o + 1].x - n[o].x),
801
+ y: r * (n[o + 1].y - n[o].y),
802
+ t: 0
803
+ });
804
+ t.push(i), n = i;
805
+ }
806
+ return t;
807
+ }, Te = (e, t) => {
808
+ if (t === 0)
809
+ return e[0].t = 0, e[0];
810
+ const n = e.length - 1;
811
+ if (t === 1)
812
+ return e[n].t = 1, e[n];
813
+ const s = 1 - t;
814
+ let r = e;
815
+ if (n === 0)
816
+ return e[0].t = t, e[0];
817
+ if (n === 1)
818
+ return {
819
+ x: s * r[0].x + t * r[1].x,
820
+ y: s * r[0].y + t * r[1].y,
821
+ t
822
+ };
823
+ const i = s * s, o = t * t;
824
+ let c = 0, a = 0, l = 0, m = 0;
825
+ return n === 2 ? (r = [r[0], r[1], r[2], Pe], c = i, a = s * t * 2, l = o) : n === 3 && (c = i * s, a = i * t * 3, l = s * o * 3, m = t * o), {
826
+ x: c * r[0].x + a * r[1].x + l * r[2].x + m * r[3].x,
827
+ y: c * r[0].y + a * r[1].y + l * r[2].y + m * r[3].y,
828
+ t
727
829
  };
728
- }, pe = (e, t, n, r, s, i, o, a, l) => {
729
- const c = typeof l == "number";
730
- let m = e, u = t, y = 0, g = [m, u, y], f = [m, u], h = 0, x = { x: 0, y: 0 }, p = [{ x: m, y: u }];
731
- c && l <= 0 && (x = { x: m, y: u });
732
- const b = 300;
733
- for (let A = 0; A <= b; A += 1) {
734
- if (h = A / b, { x: m, y: u } = xe(e, t, n, r, s, i, o, a, h), p = [...p, { x: m, y: u }], y += W(f, [m, u]), f = [m, u], c && y > l && l > g[2]) {
735
- const d = (y - l) / (y - g[2]);
736
- x = {
737
- x: f[0] * (1 - d) + g[0] * d,
738
- y: f[1] * (1 - d) + g[1] * d
739
- };
830
+ }, Le = (e, t) => {
831
+ const n = e(t), s = n.x * n.x + n.y * n.y;
832
+ return Math.sqrt(s);
833
+ }, $e = (e) => {
834
+ const n = kt.length;
835
+ let s = 0;
836
+ for (let r = 0, i; r < n; r++)
837
+ i = 0.5 * kt[r] + 0.5, s += Ae[r] * Le(e, i);
838
+ return 0.5 * s;
839
+ }, Vt = (e) => {
840
+ const t = [];
841
+ for (let s = 0, r = e.length, i = 2; s < r; s += i)
842
+ t.push({
843
+ x: e[s],
844
+ y: e[s + 1]
845
+ });
846
+ const n = Ce(t);
847
+ return $e((s) => Te(n[0], s));
848
+ }, ke = 1e-8, Nt = (e) => {
849
+ const t = Math.min(e[0], e[2]), n = Math.max(e[0], e[2]);
850
+ if (e[1] >= e[0] ? e[2] >= e[1] : e[2] <= e[1])
851
+ return [t, n];
852
+ const s = (e[0] * e[2] - e[1] * e[1]) / (e[0] - 2 * e[1] + e[2]);
853
+ return s < t ? [s, n] : [t, s];
854
+ }, qt = (e) => {
855
+ const t = e[0] - 3 * e[1] + 3 * e[2] - e[3];
856
+ if (Math.abs(t) < ke)
857
+ return e[0] === e[3] && e[0] === e[1] ? [e[0], e[3]] : Nt([e[0], -0.5 * e[0] + 1.5 * e[1], e[0] - 3 * e[1] + 3 * e[2]]);
858
+ const n = -e[0] * e[2] + e[0] * e[3] - e[1] * e[2] - e[1] * e[3] + e[1] * e[1] + e[2] * e[2];
859
+ if (n <= 0)
860
+ return [Math.min(e[0], e[3]), Math.max(e[0], e[3])];
861
+ const s = Math.sqrt(n);
862
+ let r = Math.min(e[0], e[3]), i = Math.max(e[0], e[3]);
863
+ const o = e[0] - 2 * e[1] + e[2];
864
+ for (let c = (o + s) / t, a = 1; a <= 2; c = (o - s) / t, a++)
865
+ if (c > 0 && c < 1) {
866
+ const l = e[0] * (1 - c) * (1 - c) * (1 - c) + e[1] * 3 * (1 - c) * (1 - c) * c + e[2] * 3 * (1 - c) * c * c + e[3] * c * c * c;
867
+ l < r && (r = l), l > i && (i = l);
740
868
  }
741
- g = [m, u, y];
742
- }
743
- return c && l >= y && (x = { x: o, y: a }), {
744
- length: y,
745
- point: x,
746
- min: {
747
- x: Math.min(...p.map((A) => A.x)),
748
- y: Math.min(...p.map((A) => A.y))
869
+ return [r, i];
870
+ }, qe = ([e, t, n, s, r, i, o, c], a) => {
871
+ const l = 1 - a;
872
+ return {
873
+ x: l ** 3 * e + 3 * l ** 2 * a * n + 3 * l * a ** 2 * r + a ** 3 * o,
874
+ y: l ** 3 * t + 3 * l ** 2 * a * s + 3 * l * a ** 2 * i + a ** 3 * c
875
+ };
876
+ }, Se = (e, t, n, s, r, i, o, c, a) => {
877
+ const l = typeof a == "number";
878
+ let m = { x: e, y: t };
879
+ const u = () => Vt([e, t, n, s, r, i, o, c]);
880
+ if (l) {
881
+ const y = u();
882
+ a <= 0 || (a >= y ? m = { x: o, y: c } : m = qe([e, t, n, s, r, i, o, c], a / y));
883
+ }
884
+ return {
885
+ point: m,
886
+ get length() {
887
+ return u();
749
888
  },
750
- max: {
751
- x: Math.max(...p.map((A) => A.x)),
752
- y: Math.max(...p.map((A) => A.y))
889
+ get bbox() {
890
+ const y = qt([e, n, r, o]), x = qt([t, s, i, c]);
891
+ return {
892
+ min: { x: y[0], y: x[0] },
893
+ max: { x: y[1], y: x[1] }
894
+ };
753
895
  }
754
896
  };
755
- }, be = (e, t, n, r, s, i, o) => {
756
- const a = 1 - o;
897
+ }, Ee = ([e, t, n, s, r, i], o) => {
898
+ const c = 1 - o;
757
899
  return {
758
- x: a ** 2 * e + 2 * a * o * n + o ** 2 * s,
759
- y: a ** 2 * t + 2 * a * o * r + o ** 2 * i
900
+ x: c ** 2 * e + 2 * c * o * n + o ** 2 * r,
901
+ y: c ** 2 * t + 2 * c * o * s + o ** 2 * i
760
902
  };
761
- }, de = (e, t, n, r, s, i, o) => {
762
- const a = typeof o == "number";
763
- let l = e, c = t, m = 0, u = [l, c, m], y = [l, c], g = 0, f = { x: 0, y: 0 }, h = [{ x: l, y: c }];
764
- a && o <= 0 && (f = { x: l, y: c });
765
- const x = 300;
766
- for (let p = 0; p <= x; p += 1) {
767
- if (g = p / x, { x: l, y: c } = be(e, t, n, r, s, i, g), h = [...h, { x: l, y: c }], m += W(y, [l, c]), y = [l, c], a && m > o && o > u[2]) {
768
- const b = (m - o) / (m - u[2]);
769
- f = {
770
- x: y[0] * (1 - b) + u[0] * b,
771
- y: y[1] * (1 - b) + u[1] * b
903
+ }, ze = (e, t, n, s, r, i, o) => {
904
+ const c = typeof o == "number";
905
+ let a = { x: e, y: t };
906
+ const l = () => Vt([e, t, n, s, r, i]);
907
+ if (c) {
908
+ const m = l();
909
+ o <= 0 || (o >= m ? a = { x: r, y: i } : a = Ee([e, t, n, s, r, i], o / m));
910
+ }
911
+ return {
912
+ point: a,
913
+ get length() {
914
+ return l();
915
+ },
916
+ get bbox() {
917
+ const m = Nt([e, n, r]), u = Nt([t, s, i]);
918
+ return {
919
+ min: { x: m[0], y: u[0] },
920
+ max: { x: m[1], y: u[1] }
772
921
  };
773
922
  }
774
- u = [l, c, m];
775
- }
776
- return a && o >= m && (f = { x: s, y: i }), {
777
- length: m,
778
- point: f,
779
- min: {
780
- x: Math.min(...h.map((p) => p.x)),
781
- y: Math.min(...h.map((p) => p.y))
782
- },
783
- max: {
784
- x: Math.max(...h.map((p) => p.x)),
785
- y: Math.max(...h.map((p) => p.y))
923
+ };
924
+ }, wt = 1e-5, yt = (e, t) => {
925
+ const n = O(e), s = typeof t == "number";
926
+ let r = !1, i = [], o = "M", c = 0, a = 0, l = 0, m = 0, u = n[0];
927
+ const y = [], x = [];
928
+ let f = { x: 0, y: 0 }, h = { x: 0, y: 0 }, g = f, p = 0, b = {
929
+ point: { x: 0, y: 0 },
930
+ length: 0,
931
+ bbox: {
932
+ min: { x: 0, y: 0 },
933
+ max: { x: 0, y: 0 }
786
934
  }
787
935
  };
788
- }, ft = (e, t) => {
789
- const n = z(e), r = typeof t == "number";
790
- let s, i = [], o, a = 0, l = 0, c = 0, m = 0, u, y = [], g = [], f = 0, h = { x: 0, y: 0 }, x = h, p = h, b = h, A = 0;
791
- for (let d = 0, M = n.length; d < M; d += 1)
792
- u = n[d], [o] = u, s = o === "M", i = s ? i : [a, l, ...u.slice(1)], s ? ([, c, m] = u, h = { x: c, y: m }, x = h, f = 0, r && t < 1e-3 && (b = h)) : o === "L" ? { length: f, min: h, max: x, point: p } = dt(
936
+ for (let v = 0, d = n.length; v < d; v += 1)
937
+ u = n[v], [o] = u, r = o === "M", i = r ? i : [c, a, ...u.slice(1)], s && t < wt && (g = f), r ? ([, l, m] = u, f = { x: l, y: m }, h = { x: l, y: m }, b = {
938
+ point: f,
939
+ length: 0,
940
+ bbox: { min: f, max: h }
941
+ }) : o === "L" ? b = Mt(
793
942
  ...i,
794
- (t || 0) - A
795
- ) : o === "A" ? { length: f, min: h, max: x, point: p } = ge(
943
+ s ? t - p : void 0
944
+ ) : o === "A" ? b = ve(
796
945
  ...i,
797
- (t || 0) - A
798
- ) : o === "C" ? { length: f, min: h, max: x, point: p } = pe(
946
+ s ? t - p : void 0
947
+ ) : o === "C" ? b = Se(
799
948
  ...i,
800
- (t || 0) - A
801
- ) : o === "Q" ? { length: f, min: h, max: x, point: p } = de(
949
+ s ? t - p : void 0
950
+ ) : o === "Q" ? b = ze(
802
951
  ...i,
803
- (t || 0) - A
804
- ) : o === "Z" && (i = [a, l, c, m], { length: f, min: h, max: x, point: p } = dt(
952
+ s ? t - p : void 0
953
+ ) : o === "Z" && (i = [c, a, l, m], b = Mt(
805
954
  ...i,
806
- (t || 0) - A
807
- )), r && A < t && A + f >= t && (b = p), g = [...g, x], y = [...y, h], A += f, [a, l] = o !== "Z" ? u.slice(-2) : [c, m];
808
- return r && t >= A && (b = { x: a, y: l }), {
809
- length: A,
810
- point: b,
811
- min: {
812
- x: Math.min(...y.map((d) => d.x)),
813
- y: Math.min(...y.map((d) => d.y))
814
- },
815
- max: {
816
- x: Math.max(...g.map((d) => d.x)),
817
- y: Math.max(...g.map((d) => d.y))
955
+ s ? t - p : void 0
956
+ )), s && p < t && p + b.length >= t && (g = b.point), y.push(b.bbox.min), x.push(b.bbox.max), p += b.length, [c, a] = o !== "Z" ? u.slice(-2) : [l, m];
957
+ return s && t > p - wt && (g = { x: c, y: a }), {
958
+ point: g,
959
+ length: p,
960
+ get bbox() {
961
+ return {
962
+ min: {
963
+ x: Math.min(...y.map((v) => v.x)),
964
+ y: Math.min(...y.map((v) => v.y))
965
+ },
966
+ max: {
967
+ x: Math.max(...x.map((v) => v.x)),
968
+ y: Math.max(...x.map((v) => v.y))
969
+ }
970
+ };
818
971
  }
819
972
  };
820
- }, kt = (e) => {
973
+ }, St = (e) => {
821
974
  if (!e)
822
975
  return {
823
976
  x: 0,
@@ -830,160 +983,160 @@ e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
830
983
  cy: 0,
831
984
  cz: 0
832
985
  };
833
- const {
834
- min: { x: t, y: n },
835
- max: { x: r, y: s }
836
- } = ft(e), i = r - t, o = s - n;
986
+ const t = yt(e), {
987
+ min: { x: n, y: s },
988
+ max: { x: r, y: i }
989
+ } = t.bbox, o = r - n, c = i - s;
837
990
  return {
838
- width: i,
839
- height: o,
840
- x: t,
841
- y: n,
991
+ width: o,
992
+ height: c,
993
+ x: n,
994
+ y: s,
842
995
  x2: r,
843
- y2: s,
844
- cx: t + i / 2,
845
- cy: n + o / 2,
996
+ y2: i,
997
+ cx: n + o / 2,
998
+ cy: s + c / 2,
846
999
  // an estimted guess
847
- cz: Math.max(i, o) + Math.min(i, o) / 2
1000
+ cz: Math.max(o, c) + Math.min(o, c) / 2
848
1001
  };
849
- }, Mt = (e, t, n) => {
1002
+ }, vt = (e, t, n) => {
850
1003
  if (e[n].length > 7) {
851
1004
  e[n].shift();
852
- const r = e[n];
853
- let s = n;
854
- for (; r.length; )
855
- t[n] = "A", e.splice(s += 1, 0, ["C", ...r.splice(0, 6)]);
1005
+ const s = e[n];
1006
+ let r = n;
1007
+ for (; s.length; )
1008
+ t[n] = "A", e.splice(r += 1, 0, ["C", ...s.splice(0, 6)]);
856
1009
  e.splice(n, 1);
857
1010
  }
858
- }, Jt = (e) => vt(e) && e.every(([t]) => "MC".includes(t)), rt = (e, t, n) => {
859
- const r = e * Math.cos(n) - t * Math.sin(n), s = e * Math.sin(n) + t * Math.cos(n);
860
- return { x: r, y: s };
861
- }, Ut = (e, t, n, r, s, i, o, a, l, c) => {
862
- let m = e, u = t, y = n, g = r, f = a, h = l;
863
- const x = Math.PI * 120 / 180, p = Math.PI / 180 * (+s || 0);
864
- let b = [], A, d, M, T, j;
865
- if (c)
866
- [d, M, T, j] = c;
1011
+ }, Wt = (e) => gt(e) && e.every(([t]) => "MC".includes(t)), it = (e, t, n) => {
1012
+ const s = e * Math.cos(n) - t * Math.sin(n), r = e * Math.sin(n) + t * Math.cos(n);
1013
+ return { x: s, y: r };
1014
+ }, Gt = (e, t, n, s, r, i, o, c, a, l) => {
1015
+ let m = e, u = t, y = n, x = s, f = c, h = a;
1016
+ const g = Math.PI * 120 / 180, p = Math.PI / 180 * (+r || 0);
1017
+ let b = [], v, d, w, T, j;
1018
+ if (l)
1019
+ [d, w, T, j] = l;
867
1020
  else {
868
- A = rt(m, u, -p), m = A.x, u = A.y, A = rt(f, h, -p), f = A.x, h = A.y;
869
- const P = (m - f) / 2, L = (u - h) / 2;
870
- let I = P * P / (y * y) + L * L / (g * g);
871
- I > 1 && (I = Math.sqrt(I), y *= I, g *= I);
872
- const xt = y * y, pt = g * g, Ct = (i === o ? -1 : 1) * Math.sqrt(Math.abs((xt * pt - xt * L * L - pt * P * P) / (xt * L * L + pt * P * P)));
873
- T = Ct * y * L / g + (m + f) / 2, j = Ct * -g * P / y + (u + h) / 2, d = Math.asin(((u - j) / g * 10 ** 9 >> 0) / 10 ** 9), M = Math.asin(((h - j) / g * 10 ** 9 >> 0) / 10 ** 9), d = m < T ? Math.PI - d : d, M = f < T ? Math.PI - M : M, d < 0 && (d = Math.PI * 2 + d), M < 0 && (M = Math.PI * 2 + M), o && d > M && (d -= Math.PI * 2), !o && M > d && (M -= Math.PI * 2);
874
- }
875
- let H = M - d;
876
- if (Math.abs(H) > x) {
877
- const P = M, L = f, I = h;
878
- M = d + x * (o && M > d ? 1 : -1), f = T + y * Math.cos(M), h = j + g * Math.sin(M), b = Ut(f, h, y, g, s, 0, o, L, I, [M, P, T, j]);
879
- }
880
- H = M - d;
881
- const F = Math.cos(d), tt = Math.sin(d), S = Math.cos(M), et = Math.sin(M), Y = Math.tan(H / 4), nt = 4 / 3 * y * Y, st = 4 / 3 * g * Y, $ = [m, u], q = [m + nt * tt, u - st * F], B = [f + nt * et, h - st * S], J = [f, h];
882
- if (q[0] = 2 * $[0] - q[0], q[1] = 2 * $[1] - q[1], c)
883
- return [...q, ...B, ...J, ...b];
884
- b = [...q, ...B, ...J, ...b];
885
- const gt = [];
886
- for (let P = 0, L = b.length; P < L; P += 1)
887
- gt[P] = P % 2 ? rt(b[P - 1], b[P], p).y : rt(b[P], b[P + 1], p).x;
888
- return gt;
889
- }, Me = (e, t, n, r, s, i) => {
890
- const o = 0.3333333333333333, a = 2 / 3;
1021
+ v = it(m, u, -p), m = v.x, u = v.y, v = it(f, h, -p), f = v.x, h = v.y;
1022
+ const A = (m - f) / 2, k = (u - h) / 2;
1023
+ let R = A * A / (y * y) + k * k / (x * x);
1024
+ R > 1 && (R = Math.sqrt(R), y *= R, x *= R);
1025
+ const pt = y * y, bt = x * x, Tt = (i === o ? -1 : 1) * Math.sqrt(Math.abs((pt * bt - pt * k * k - bt * A * A) / (pt * k * k + bt * A * A)));
1026
+ T = Tt * y * k / x + (m + f) / 2, j = Tt * -x * A / y + (u + h) / 2, d = Math.asin(((u - j) / x * 10 ** 9 >> 0) / 10 ** 9), w = Math.asin(((h - j) / x * 10 ** 9 >> 0) / 10 ** 9), d = m < T ? Math.PI - d : d, w = f < T ? Math.PI - w : w, d < 0 && (d = Math.PI * 2 + d), w < 0 && (w = Math.PI * 2 + w), o && d > w && (d -= Math.PI * 2), !o && w > d && (w -= Math.PI * 2);
1027
+ }
1028
+ let B = w - d;
1029
+ if (Math.abs(B) > g) {
1030
+ const A = w, k = f, R = h;
1031
+ w = d + g * (o && w > d ? 1 : -1), f = T + y * Math.cos(w), h = j + x * Math.sin(w), b = Gt(f, h, y, x, r, 0, o, k, R, [w, A, T, j]);
1032
+ }
1033
+ B = w - d;
1034
+ const Q = Math.cos(d), nt = Math.sin(d), q = Math.cos(w), D = Math.sin(w), J = Math.tan(B / 4), I = 4 / 3 * y * J, st = 4 / 3 * x * J, L = [m, u], S = [m + I * nt, u - st * Q], rt = [f + I * D, h - st * q], _ = [f, h];
1035
+ if (S[0] = 2 * L[0] - S[0], S[1] = 2 * L[1] - S[1], l)
1036
+ return [...S, ...rt, ..._, ...b];
1037
+ b = [...S, ...rt, ..._, ...b];
1038
+ const K = [];
1039
+ for (let A = 0, k = b.length; A < k; A += 1)
1040
+ K[A] = A % 2 ? it(b[A - 1], b[A], p).y : it(b[A], b[A + 1], p).x;
1041
+ return K;
1042
+ }, Oe = (e, t, n, s, r, i) => {
1043
+ const o = 0.3333333333333333, c = 2 / 3;
891
1044
  return [
892
- o * e + a * n,
1045
+ o * e + c * n,
893
1046
  // cpx1
894
- o * t + a * r,
1047
+ o * t + c * s,
895
1048
  // cpy1
896
- o * s + a * n,
1049
+ o * r + c * n,
897
1050
  // cpx2
898
- o * i + a * r,
1051
+ o * i + c * s,
899
1052
  // cpy2
900
- s,
1053
+ r,
901
1054
  i
902
1055
  // x,y
903
1056
  ];
904
- }, St = (e, t, n, r) => {
905
- const s = E([e, t], [n, r], 0.3333333333333333), i = E([e, t], [n, r], 2 / 3);
906
- return [...s, ...i, n, r];
907
- }, ot = (e, t) => {
908
- const [n] = e, r = e.slice(1).map(Number), [s, i] = r;
1057
+ }, Et = (e, t, n, s) => {
1058
+ const r = z([e, t], [n, s], 0.3333333333333333), i = z([e, t], [n, s], 2 / 3);
1059
+ return [...r, ...i, n, s];
1060
+ }, ct = (e, t) => {
1061
+ const [n] = e, s = e.slice(1).map(Number), [r, i] = s;
909
1062
  let o;
910
- const { x1: a, y1: l, x: c, y: m } = t;
911
- return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = s, t.y = i, e) : n === "A" ? (o = [a, l, ...r], ["C", ...Ut(...o)]) : n === "Q" ? (t.qx = s, t.qy = i, o = [a, l, ...r], ["C", ...Me(...o)]) : n === "L" ? ["C", ...St(a, l, s, i)] : n === "Z" ? ["C", ...St(a, l, c, m)] : e;
912
- }, ct = (e) => {
913
- if (Jt(e))
914
- return [...e];
915
- const t = z(e), n = { ...ut }, r = [];
916
- let s = "", i = t.length;
1063
+ const { x1: c, y1: a, x: l, y: m } = t;
1064
+ return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = r, t.y = i, e) : n === "A" ? (o = [c, a, ...s], ["C", ...Gt(...o)]) : n === "Q" ? (t.qx = r, t.qy = i, o = [c, a, ...s], ["C", ...Oe(...o)]) : n === "L" ? ["C", ...Et(c, a, r, i)] : n === "Z" ? ["C", ...Et(c, a, l, m)] : e;
1065
+ }, lt = (e) => {
1066
+ if (Wt(e))
1067
+ return e.slice(0);
1068
+ const t = O(e), n = { ...et }, s = [];
1069
+ let r = "", i = t.length;
917
1070
  for (let o = 0; o < i; o += 1) {
918
- [s] = t[o], r[o] = s, t[o] = ot(t[o], n), Mt(t, r, o), i = t.length;
919
- const a = t[o], l = a.length;
920
- n.x1 = +a[l - 2], n.y1 = +a[l - 1], n.x2 = +a[l - 4] || n.x1, n.y2 = +a[l - 3] || n.y1;
1071
+ [r] = t[o], s[o] = r, t[o] = ct(t[o], n), vt(t, s, o), i = t.length;
1072
+ const c = t[o], a = c.length;
1073
+ n.x1 = +c[a - 2], n.y1 = +c[a - 1], n.x2 = +c[a - 4] || n.x1, n.y2 = +c[a - 3] || n.y1;
921
1074
  }
922
1075
  return t;
923
- }, Ae = (e, t, n, r, s, i, o, a) => 3 * ((a - t) * (n + s) - (o - e) * (r + i) + r * (e - s) - n * (t - i) + a * (s + e / 3) - o * (i + t / 3)) / 20, Vt = (e) => {
924
- let t = 0, n = 0, r = 0;
925
- return ct(e).map((s) => {
926
- switch (s[0]) {
1076
+ }, je = (e, t, n, s, r, i, o, c) => 3 * ((c - t) * (n + r) - (o - e) * (s + i) + s * (e - r) - n * (t - i) + c * (r + e / 3) - o * (i + t / 3)) / 20, te = (e) => {
1077
+ let t = 0, n = 0, s = 0;
1078
+ return lt(e).map((r) => {
1079
+ switch (r[0]) {
927
1080
  case "M":
928
- return [, t, n] = s, 0;
1081
+ return [, t, n] = r, 0;
929
1082
  default:
930
- return r = Ae(t, n, ...s.slice(1)), [t, n] = s.slice(-2), r;
1083
+ return s = je(t, n, ...r.slice(1)), [t, n] = r.slice(-2), s;
931
1084
  }
932
- }).reduce((s, i) => s + i, 0);
933
- }, X = (e) => ft(e).length, Ne = (e) => Vt(ct(e)) >= 0, K = (e, t) => ft(e, t).point, Pt = (e, t) => {
934
- const n = Z(e);
935
- let r = [...n], s = X(r), i = r.length - 1, o = 0, a = 0, l = n[0];
936
- const [c, m] = l.slice(-2), u = { x: c, y: m };
1085
+ }).reduce((r, i) => r + i, 0);
1086
+ }, F = (e) => yt(e).length, Ie = (e) => te(lt(e)) >= 0, W = (e, t) => yt(e, t).point, Ct = (e, t) => {
1087
+ const n = Y(e);
1088
+ let s = n.slice(0), r = F(s), i = s.length - 1, o = 0, c = 0, a = n[0];
1089
+ const [l, m] = a.slice(-2), u = { x: l, y: m };
937
1090
  if (i <= 0 || !t || !Number.isFinite(t))
938
1091
  return {
939
- segment: l,
1092
+ segment: a,
940
1093
  index: 0,
941
- length: a,
1094
+ length: c,
942
1095
  point: u,
943
1096
  lengthAtSegment: o
944
1097
  };
945
- if (t >= s)
946
- return r = n.slice(0, -1), o = X(r), a = s - o, {
1098
+ if (t >= r)
1099
+ return s = n.slice(0, -1), o = F(s), c = r - o, {
947
1100
  segment: n[i],
948
1101
  index: i,
949
- length: a,
1102
+ length: c,
950
1103
  lengthAtSegment: o
951
1104
  };
952
1105
  const y = [];
953
1106
  for (; i > 0; )
954
- l = r[i], r = r.slice(0, -1), o = X(r), a = s - o, s = o, y.push({
955
- segment: l,
1107
+ a = s[i], s = s.slice(0, -1), o = F(s), c = r - o, r = o, y.push({
1108
+ segment: a,
956
1109
  index: i,
957
- length: a,
1110
+ length: c,
958
1111
  lengthAtSegment: o
959
1112
  }), i -= 1;
960
- return y.find(({ lengthAtSegment: g }) => g <= t);
961
- }, yt = (e, t) => {
962
- const n = Z(e), r = z(n), s = X(n), i = (d) => {
963
- const M = d.x - t.x, T = d.y - t.y;
964
- return M * M + T * T;
1113
+ return y.find(({ lengthAtSegment: x }) => x <= t);
1114
+ }, xt = (e, t) => {
1115
+ const n = Y(e), s = O(n), r = F(n), i = (d) => {
1116
+ const w = d.x - t.x, T = d.y - t.y;
1117
+ return w * w + T * T;
965
1118
  };
966
- let o = 8, a, l = { x: 0, y: 0 }, c = 0, m = 0, u = 1 / 0;
967
- for (let d = 0; d <= s; d += o)
968
- a = K(r, d), c = i(a), c < u && (l = a, m = d, u = c);
1119
+ let o = 8, c, a = { x: 0, y: 0 }, l = 0, m = 0, u = 1 / 0;
1120
+ for (let d = 0; d <= r; d += o)
1121
+ c = W(s, d), l = i(c), l < u && (a = c, m = d, u = l);
969
1122
  o /= 2;
970
- let y, g, f = 0, h = 0, x = 0, p = 0;
971
- for (; o > 0.5; )
972
- f = m - o, y = K(r, f), x = i(y), h = m + o, g = K(r, h), p = i(g), f >= 0 && x < u ? (l = y, m = f, u = x) : h <= s && p < u ? (l = g, m = h, u = p) : o /= 2;
973
- const b = Pt(n, m), A = Math.sqrt(u);
974
- return { closest: l, distance: A, segment: b };
975
- }, we = (e, t) => yt(e, t).closest, ve = (e, t) => yt(e, t).segment, Pe = (e, t) => Pt(e, t).segment, Ce = (e, t) => {
976
- const { distance: n } = yt(e, t);
977
- return Math.abs(n) < 1e-3;
978
- }, Kt = (e) => {
1123
+ let y, x, f = 0, h = 0, g = 0, p = 0;
1124
+ for (; o > 1e-6 && (f = m - o, y = W(s, f), g = i(y), h = m + o, x = W(s, h), p = i(x), f >= 0 && g < u ? (a = y, m = f, u = g) : h <= r && p < u ? (a = x, m = h, u = p) : o /= 2, !(o < 1e-5)); )
1125
+ ;
1126
+ const b = Ct(n, m), v = Math.sqrt(u);
1127
+ return { closest: a, distance: v, segment: b };
1128
+ }, De = (e, t) => xt(e, t).closest, Re = (e, t) => xt(e, t).segment, Xe = (e, t) => Ct(e, t).segment, Ze = (e, t) => {
1129
+ const { distance: n } = xt(e, t);
1130
+ return Math.abs(n) < wt;
1131
+ }, ee = (e) => {
979
1132
  if (typeof e != "string" || !e.length)
980
1133
  return !1;
981
- const t = new zt(e);
1134
+ const t = new Rt(e);
982
1135
  for (V(t); t.index < t.max && !t.err.length; )
983
- jt(t);
1136
+ Dt(t);
984
1137
  return !t.err.length && "mM".includes(t.segments[0][0]);
985
- }, _t = (e) => _(e) && // `isPathArray` checks if it's `Array`
986
- e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
1138
+ }, ne = (e) => G(e) && // `isPathArray` checks if it's `Array`
1139
+ e.slice(1).every(([t]) => t === t.toLowerCase()), at = {
987
1140
  line: ["x1", "y1", "x2", "y2"],
988
1141
  circle: ["cx", "cy", "r"],
989
1142
  ellipse: ["cx", "cy", "rx", "ry"],
@@ -991,306 +1144,317 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
991
1144
  polygon: ["points"],
992
1145
  polyline: ["points"],
993
1146
  glyph: ["d"]
994
- }, Te = (e) => {
995
- let { x1: t, y1: n, x2: r, y2: s } = e;
996
- return [t, n, r, s] = [t, n, r, s].map((i) => +i), [
1147
+ }, Ye = (e) => {
1148
+ let { x1: t, y1: n, x2: s, y2: r } = e;
1149
+ return [t, n, s, r] = [t, n, s, r].map((i) => +i), [
997
1150
  ["M", t, n],
998
- ["L", r, s]
1151
+ ["L", s, r]
999
1152
  ];
1000
- }, Le = (e) => {
1001
- const t = [], n = (e.points || "").trim().split(/[\s|,]/).map((s) => +s);
1002
- let r = 0;
1003
- for (; r < n.length; )
1004
- t.push([r ? "L" : "M", n[r], n[r + 1]]), r += 2;
1153
+ }, Qe = (e) => {
1154
+ const t = [], n = (e.points || "").trim().split(/[\s|,]/).map((r) => +r);
1155
+ let s = 0;
1156
+ for (; s < n.length; )
1157
+ t.push([s ? "L" : "M", n[s], n[s + 1]]), s += 2;
1005
1158
  return e.type === "polygon" ? [...t, ["z"]] : t;
1006
- }, ke = (e) => {
1007
- let { cx: t, cy: n, r } = e;
1008
- return [t, n, r] = [t, n, r].map((s) => +s), [
1009
- ["M", t - r, n],
1010
- ["a", r, r, 0, 1, 0, 2 * r, 0],
1011
- ["a", r, r, 0, 1, 0, -2 * r, 0]
1159
+ }, Fe = (e) => {
1160
+ let { cx: t, cy: n, r: s } = e;
1161
+ return [t, n, s] = [t, n, s].map((r) => +r), [
1162
+ ["M", t - s, n],
1163
+ ["a", s, s, 0, 1, 0, 2 * s, 0],
1164
+ ["a", s, s, 0, 1, 0, -2 * s, 0]
1012
1165
  ];
1013
- }, Se = (e) => {
1014
- let { cx: t, cy: n } = e, r = e.rx || 0, s = e.ry || r;
1015
- return [t, n, r, s] = [t, n, r, s].map((i) => +i), [
1016
- ["M", t - r, n],
1017
- ["a", r, s, 0, 1, 0, 2 * r, 0],
1018
- ["a", r, s, 0, 1, 0, -2 * r, 0]
1166
+ }, He = (e) => {
1167
+ let { cx: t, cy: n } = e, s = e.rx || 0, r = e.ry || s;
1168
+ return [t, n, s, r] = [t, n, s, r].map((i) => +i), [
1169
+ ["M", t - s, n],
1170
+ ["a", s, r, 0, 1, 0, 2 * s, 0],
1171
+ ["a", s, r, 0, 1, 0, -2 * s, 0]
1019
1172
  ];
1020
- }, $e = (e) => {
1021
- const t = +e.x || 0, n = +e.y || 0, r = +e.width, s = +e.height;
1173
+ }, Be = (e) => {
1174
+ const t = +e.x || 0, n = +e.y || 0, s = +e.width, r = +e.height;
1022
1175
  let i = +(e.rx || 0), o = +(e.ry || i);
1023
- return i || o ? (i * 2 > r && (i -= (i * 2 - r) / 2), o * 2 > s && (o -= (o * 2 - s) / 2), [
1176
+ return i || o ? (i * 2 > s && (i -= (i * 2 - s) / 2), o * 2 > r && (o -= (o * 2 - r) / 2), [
1024
1177
  ["M", t + i, n],
1025
- ["h", r - i * 2],
1178
+ ["h", s - i * 2],
1026
1179
  ["s", i, 0, i, o],
1027
- ["v", s - o * 2],
1180
+ ["v", r - o * 2],
1028
1181
  ["s", 0, o, -i, o],
1029
- ["h", -r + i * 2],
1182
+ ["h", -s + i * 2],
1030
1183
  ["s", -i, 0, -i, -o],
1031
- ["v", -s + o * 2],
1184
+ ["v", -r + o * 2],
1032
1185
  ["s", 0, -o, i, -o]
1033
- ]) : [["M", t, n], ["h", r], ["v", s], ["H", t], ["Z"]];
1034
- }, Wt = (e, t) => {
1035
- const r = (t || document).defaultView || /* istanbul ignore next */
1036
- window, s = Object.keys(lt), i = e instanceof r.SVGElement, o = i ? e.tagName : null;
1037
- if (o && [...s, "path"].every((u) => o !== u))
1038
- throw TypeError(`${k}: "${o}" is not SVGElement`);
1039
- const a = i ? o : e.type, l = lt[a], c = { type: a };
1040
- i ? l.forEach((u) => {
1041
- c[u] = e.getAttribute(u);
1042
- }) : Object.assign(c, e);
1186
+ ]) : [["M", t, n], ["h", s], ["v", r], ["H", t], ["Z"]];
1187
+ }, se = (e, t) => {
1188
+ const s = (t || document).defaultView || /* istanbul ignore next */
1189
+ window, r = Object.keys(at), i = e instanceof s.SVGElement, o = i ? e.tagName : null;
1190
+ if (o && [...r, "path"].every((u) => o !== u))
1191
+ throw TypeError(`${$}: "${o}" is not SVGElement`);
1192
+ const c = i ? o : e.type, a = at[c], l = { type: c };
1193
+ i ? a.forEach((u) => {
1194
+ l[u] = e.getAttribute(u);
1195
+ }) : Object.assign(l, e);
1043
1196
  let m = [];
1044
- return a === "circle" ? m = ke(c) : a === "ellipse" ? m = Se(c) : ["polyline", "polygon"].includes(a) ? m = Le(c) : a === "rect" ? m = $e(c) : a === "line" ? m = Te(c) : ["glyph", "path"].includes(a) && (m = Z(i ? e.getAttribute("d") || "" : e.d || "")), _(m) && m.length ? m : !1;
1045
- }, at = (e, t) => {
1046
- let { round: n } = mt;
1047
- if (t === "off" || n === "off")
1048
- return [...e];
1197
+ return c === "circle" ? m = Fe(l) : c === "ellipse" ? m = He(l) : ["polyline", "polygon"].includes(c) ? m = Qe(l) : c === "rect" ? m = Be(l) : c === "line" ? m = Ye(l) : ["glyph", "path"].includes(c) && (m = Y(
1198
+ i ? e.getAttribute("d") || /* istanbul ignore next @preserve */
1199
+ "" : e.d || ""
1200
+ )), G(m) && m.length ? m : !1;
1201
+ }, mt = (e, t) => {
1202
+ let { round: n } = ht;
1203
+ if (t === "off" || n === "off") return [...e];
1049
1204
  n = typeof t == "number" && t >= 0 ? t : n;
1050
- const r = typeof n == "number" && n >= 1 ? 10 ** n : 1;
1051
- return e.map((s) => {
1052
- const i = s.slice(1).map(Number).map((o) => n ? Math.round(o * r) / r : Math.round(o));
1053
- return [s[0], ...i];
1205
+ const s = typeof n == "number" && n >= 1 ? 10 ** n : 1;
1206
+ return e.map((r) => {
1207
+ const i = r.slice(1).map(Number).map((o) => n ? Math.round(o * s) / s : Math.round(o));
1208
+ return [r[0], ...i];
1054
1209
  });
1055
- }, At = (e, t) => at(e, t).map((n) => n[0] + n.slice(1).join(" ")).join(""), qe = (e, t, n) => {
1056
- const r = n || document, s = r.defaultView || /* istanbul ignore next */
1057
- window, i = Object.keys(lt), o = e instanceof s.SVGElement, a = o ? e.tagName : null;
1058
- if (a === "path")
1059
- throw TypeError(`${k}: "${a}" is already SVGPathElement`);
1060
- if (a && i.every((h) => a !== h))
1061
- throw TypeError(`${k}: "${a}" is not SVGElement`);
1062
- const l = r.createElementNS("http://www.w3.org/2000/svg", "path"), c = o ? a : e.type, m = lt[c], u = { type: c }, y = mt.round, g = Wt(e, r), f = g && g.length ? At(g, y) : "";
1210
+ }, Pt = (e, t) => mt(e, t).map((n) => n[0] + n.slice(1).join(" ")).join(""), Je = (e, t, n) => {
1211
+ const s = n || document, r = s.defaultView || /* istanbul ignore next */
1212
+ window, i = Object.keys(at), o = e instanceof r.SVGElement, c = o ? e.tagName : null;
1213
+ if (c === "path") throw TypeError(`${$}: "${c}" is already SVGPathElement`);
1214
+ if (c && i.every((h) => c !== h)) throw TypeError(`${$}: "${c}" is not SVGElement`);
1215
+ const a = s.createElementNS("http://www.w3.org/2000/svg", "path"), l = o ? c : e.type, m = at[l], u = { type: l }, y = ht.round, x = se(e, s), f = x && x.length ? Pt(x, y) : "";
1063
1216
  return o ? (m.forEach((h) => {
1064
1217
  u[h] = e.getAttribute(h);
1065
- }), Object.values(e.attributes).forEach(({ name: h, value: x }) => {
1066
- m.includes(h) || l.setAttribute(h, x);
1218
+ }), Object.values(e.attributes).forEach(({ name: h, value: g }) => {
1219
+ m.includes(h) || a.setAttribute(h, g);
1067
1220
  })) : (Object.assign(u, e), Object.keys(u).forEach((h) => {
1068
- !m.includes(h) && h !== "type" && l.setAttribute(
1069
- h.replace(/[A-Z]/g, (x) => `-${x.toLowerCase()}`),
1221
+ !m.includes(h) && h !== "type" && a.setAttribute(
1222
+ h.replace(/[A-Z]/g, (g) => `-${g.toLowerCase()}`),
1070
1223
  u[h]
1071
1224
  );
1072
- })), Kt(f) ? (l.setAttribute("d", f), t && o && (e.before(l, e), e.remove()), l) : !1;
1073
- }, $t = (e) => {
1225
+ })), ee(f) ? (a.setAttribute("d", f), t && o && (e.before(a, e), e.remove()), a) : !1;
1226
+ }, zt = (e) => {
1074
1227
  const t = [];
1075
- let n, r = -1;
1076
- return e.forEach((s) => {
1077
- s[0] === "M" ? (n = [s], r += 1) : n = [...n, s], t[r] = n;
1228
+ let n, s = -1;
1229
+ return e.forEach((r) => {
1230
+ r[0] === "M" ? (n = [r], s += 1) : n.push(r), t[s] = n;
1078
1231
  }), t;
1079
- }, Gt = (e) => {
1080
- let t = new v();
1081
- const { origin: n } = e, [r, s] = n, { translate: i } = e, { rotate: o } = e, { skew: a } = e, { scale: l } = e;
1082
- return Array.isArray(i) && i.length >= 2 && i.every((c) => !Number.isNaN(+c)) && i.some((c) => c !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || a || l) && (t = t.translate(r, s), Array.isArray(o) && o.length >= 2 && o.every((c) => !Number.isNaN(+c)) && o.some((c) => c !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(a) && a.length === 2 && a.every((c) => !Number.isNaN(+c)) && a.some((c) => c !== 0) ? (t = a[0] ? t.skewX(a[0]) : t, t = a[1] ? t.skewY(a[1]) : t) : typeof a == "number" && !Number.isNaN(a) && (t = t.skewX(a)), Array.isArray(l) && l.length >= 2 && l.every((c) => !Number.isNaN(+c)) && l.some((c) => c !== 1) ? t = t.scale(...l) : typeof l == "number" && !Number.isNaN(l) && (t = t.scale(l)), t = t.translate(-r, -s)), t;
1083
- }, Nt = (e) => {
1084
- if (_t(e))
1085
- return [...e];
1086
- const t = Z(e);
1087
- let n = 0, r = 0, s = 0, i = 0;
1232
+ }, re = (e) => {
1233
+ let t = new P();
1234
+ const { origin: n } = e, [s, r] = n, { translate: i } = e, { rotate: o } = e, { skew: c } = e, { scale: a } = e;
1235
+ return Array.isArray(i) && i.length >= 2 && i.every((l) => !Number.isNaN(+l)) && i.some((l) => l !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || c || a) && (t = t.translate(s, r), Array.isArray(o) && o.length >= 2 && o.every((l) => !Number.isNaN(+l)) && o.some((l) => l !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(c) && c.length === 2 && c.every((l) => !Number.isNaN(+l)) && c.some((l) => l !== 0) ? (t = c[0] ? t.skewX(c[0]) : t, t = c[1] ? t.skewY(c[1]) : t) : typeof c == "number" && !Number.isNaN(c) && (t = t.skewX(c)), Array.isArray(a) && a.length >= 2 && a.every((l) => !Number.isNaN(+l)) && a.some((l) => l !== 1) ? t = t.scale(...a) : typeof a == "number" && !Number.isNaN(a) && (t = t.scale(a)), t = t.translate(-s, -r)), t;
1236
+ }, At = (e) => {
1237
+ if (ne(e))
1238
+ return e.slice(0);
1239
+ const t = Y(e);
1240
+ let n = 0, s = 0, r = 0, i = 0;
1088
1241
  return t.map((o) => {
1089
- const a = o.slice(1).map(Number), [l] = o, c = l.toLowerCase();
1090
- if (l === "M")
1091
- return [n, r] = a, s = n, i = r, ["M", n, r];
1242
+ const c = o.slice(1).map(Number), [a] = o, l = a.toLowerCase();
1243
+ if (a === "M")
1244
+ return [n, s] = c, r = n, i = s, ["M", n, s];
1092
1245
  let m = [];
1093
- if (l !== c)
1094
- if (c === "a")
1246
+ if (a !== l)
1247
+ if (l === "a")
1095
1248
  m = [
1096
- c,
1097
- a[0],
1098
- a[1],
1099
- a[2],
1100
- a[3],
1101
- a[4],
1102
- a[5] - n,
1103
- a[6] - r
1249
+ l,
1250
+ c[0],
1251
+ c[1],
1252
+ c[2],
1253
+ c[3],
1254
+ c[4],
1255
+ c[5] - n,
1256
+ c[6] - s
1104
1257
  ];
1105
- else if (c === "v")
1106
- m = [c, a[0] - r];
1107
- else if (c === "h")
1108
- m = [c, a[0] - n];
1258
+ else if (l === "v")
1259
+ m = [l, c[0] - s];
1260
+ else if (l === "h")
1261
+ m = [l, c[0] - n];
1109
1262
  else {
1110
- const y = a.map((g, f) => g - (f % 2 ? r : n));
1111
- m = [c, ...y];
1263
+ const y = c.map((x, f) => x - (f % 2 ? s : n));
1264
+ m = [l, ...y];
1112
1265
  }
1113
1266
  else
1114
- l === "m" && (s = a[0] + n, i = a[1] + r), m = [c, ...a];
1267
+ a === "m" && (r = c[0] + n, i = c[1] + s), m = [l, ...c];
1115
1268
  const u = m.length;
1116
- return c === "z" ? (n = s, r = i) : c === "h" ? n += m[1] : c === "v" ? r += m[1] : (n += m[u - 2], r += m[u - 1]), m;
1269
+ return l === "z" ? (n = r, s = i) : l === "h" ? n += m[1] : l === "v" ? s += m[1] : (n += m[u - 2], s += m[u - 1]), m;
1117
1270
  });
1118
- }, Oe = (e, t, n, r) => {
1119
- const [s] = e, i = (p) => Math.round(p * 10 ** 4) / 10 ** 4, o = e.slice(1).map((p) => +p), a = t.slice(1).map((p) => +p), { x1: l, y1: c, x2: m, y2: u, x: y, y: g } = n;
1271
+ }, _e = (e, t, n, s) => {
1272
+ const [r] = e, i = (p) => Math.round(p * 10 ** 4) / 10 ** 4, o = e.slice(1).map((p) => +p), c = t.slice(1).map((p) => +p), { x1: a, y1: l, x2: m, y2: u, x: y, y: x } = n;
1120
1273
  let f = e;
1121
- const [h, x] = a.slice(-2);
1122
- if ("TQ".includes(s) || (n.qx = null, n.qy = null), ["V", "H", "S", "T", "Z"].includes(s))
1123
- f = [s, ...o];
1124
- else if (s === "L")
1125
- i(y) === i(h) ? f = ["V", x] : i(g) === i(x) && (f = ["H", h]);
1126
- else if (s === "C") {
1127
- const [p, b] = a;
1128
- "CS".includes(r) && (i(p) === i(l * 2 - m) && i(b) === i(c * 2 - u) || i(l) === i(m * 2 - y) && i(c) === i(u * 2 - g)) && (f = ["S", ...a.slice(-4)]), n.x1 = p, n.y1 = b;
1129
- } else if (s === "Q") {
1130
- const [p, b] = a;
1131
- n.qx = p, n.qy = b, "QT".includes(r) && (i(p) === i(l * 2 - m) && i(b) === i(c * 2 - u) || i(l) === i(m * 2 - y) && i(c) === i(u * 2 - g)) && (f = ["T", ...a.slice(-2)]);
1274
+ const [h, g] = c.slice(-2);
1275
+ if ("TQ".includes(r) || (n.qx = null, n.qy = null), ["V", "H", "S", "T", "Z"].includes(r))
1276
+ f = [r, ...o];
1277
+ else if (r === "L")
1278
+ i(y) === i(h) ? f = ["V", g] : i(x) === i(g) && (f = ["H", h]);
1279
+ else if (r === "C") {
1280
+ const [p, b] = c;
1281
+ "CS".includes(s) && (i(p) === i(a * 2 - m) && i(b) === i(l * 2 - u) || i(a) === i(m * 2 - y) && i(l) === i(u * 2 - x)) && (f = ["S", ...c.slice(-4)]), n.x1 = p, n.y1 = b;
1282
+ } else if (r === "Q") {
1283
+ const [p, b] = c;
1284
+ n.qx = p, n.qy = b, "QT".includes(s) && (i(p) === i(a * 2 - m) && i(b) === i(l * 2 - u) || i(a) === i(m * 2 - y) && i(l) === i(u * 2 - x)) && (f = ["T", ...c.slice(-2)]);
1132
1285
  }
1133
1286
  return f;
1134
- }, qt = (e, t) => {
1135
- const n = Q(e), r = z(n), s = { ...ut }, i = [], o = n.length;
1136
- let a = "", l = "", c = 0, m = 0, u = 0, y = 0;
1287
+ }, Ot = (e, t) => {
1288
+ const n = H(e), s = O(n), r = { ...et }, i = [], o = n.length;
1289
+ let c = "", a = "", l = 0, m = 0, u = 0, y = 0;
1137
1290
  for (let h = 0; h < o; h += 1) {
1138
- [a] = n[h], i[h] = a, h && (l = i[h - 1]), n[h] = Oe(n[h], r[h], s, l);
1139
- const x = n[h], p = x.length;
1140
- switch (s.x1 = +x[p - 2], s.y1 = +x[p - 1], s.x2 = +x[p - 4] || s.x1, s.y2 = +x[p - 3] || s.y1, a) {
1291
+ [c] = n[h], i[h] = c, h && (a = i[h - 1]), n[h] = _e(n[h], s[h], r, a);
1292
+ const g = n[h], p = g.length;
1293
+ switch (r.x1 = +g[p - 2], r.y1 = +g[p - 1], r.x2 = +g[p - 4] || r.x1, r.y2 = +g[p - 3] || r.y1, c) {
1141
1294
  case "Z":
1142
- c = u, m = y;
1295
+ l = u, m = y;
1143
1296
  break;
1144
1297
  case "H":
1145
- [, c] = x;
1298
+ [, l] = g;
1146
1299
  break;
1147
1300
  case "V":
1148
- [, m] = x;
1301
+ [, m] = g;
1149
1302
  break;
1150
1303
  default:
1151
- [c, m] = x.slice(-2).map(Number), a === "M" && (u = c, y = m);
1304
+ [l, m] = g.slice(-2).map(Number), c === "M" && (u = l, y = m);
1152
1305
  }
1153
- s.x = c, s.y = m;
1306
+ r.x = l, r.y = m;
1154
1307
  }
1155
- const g = at(n, t), f = at(Nt(n), t);
1156
- return g.map((h, x) => x ? h.join("").length < f[x].join("").length ? h : f[x] : h);
1157
- }, Ee = (e) => {
1308
+ const x = mt(n, t), f = mt(At(n), t);
1309
+ return x.map((h, g) => g ? h.join("").length < f[g].join("").length ? h : f[g] : h);
1310
+ }, Ke = (e) => {
1158
1311
  const t = e.slice(1).map(
1159
- (n, r, s) => r ? [...s[r - 1].slice(-2), ...n.slice(1)] : [...e[0].slice(1), ...n.slice(1)]
1160
- ).map((n) => n.map((r, s) => n[n.length - s - 2 * (1 - s % 2)])).reverse();
1312
+ (n, s, r) => s ? [...r[s - 1].slice(-2), ...n.slice(1)] : [...e[0].slice(1), ...n.slice(1)]
1313
+ ).map((n) => n.map((s, r) => n[n.length - r - 2 * (1 - r % 2)])).reverse();
1161
1314
  return [["M", ...t[0].slice(0, 2)], ...t.map((n) => ["C", ...n.slice(2)])];
1162
- }, it = (e) => {
1163
- const t = Q(e), n = t.slice(-1)[0][0] === "Z", r = z(t).map((s, i) => {
1164
- const [o, a] = s.slice(-2).map(Number);
1315
+ }, ot = (e) => {
1316
+ const t = H(e), n = t.slice(-1)[0][0] === "Z", s = O(t).map((r, i) => {
1317
+ const [o, c] = r.slice(-2).map(Number);
1165
1318
  return {
1166
1319
  seg: t[i],
1167
1320
  // absolute
1168
- n: s,
1321
+ n: r,
1169
1322
  // normalized
1170
1323
  c: t[i][0],
1171
1324
  // pathCommand
1172
1325
  x: o,
1173
1326
  // x
1174
- y: a
1327
+ y: c
1175
1328
  // y
1176
1329
  };
1177
- }).map((s, i, o) => {
1178
- const a = s.seg, l = s.n, c = i && o[i - 1], m = o[i + 1], u = s.c, y = o.length, g = i ? o[i - 1].x : o[y - 1].x, f = i ? o[i - 1].y : o[y - 1].y;
1330
+ }).map((r, i, o) => {
1331
+ const c = r.seg, a = r.n, l = i && o[i - 1], m = o[i + 1], u = r.c, y = o.length, x = i ? o[i - 1].x : o[y - 1].x, f = i ? o[i - 1].y : o[y - 1].y;
1179
1332
  let h = [];
1180
1333
  switch (u) {
1181
1334
  case "M":
1182
- h = n ? ["Z"] : [u, g, f];
1335
+ h = n ? ["Z"] : [u, x, f];
1183
1336
  break;
1184
1337
  case "A":
1185
- h = [u, ...a.slice(1, -3), a[5] === 1 ? 0 : 1, g, f];
1338
+ h = [u, ...c.slice(1, -3), c[5] === 1 ? 0 : 1, x, f];
1186
1339
  break;
1187
1340
  case "C":
1188
- m && m.c === "S" ? h = ["S", a[1], a[2], g, f] : h = [u, a[3], a[4], a[1], a[2], g, f];
1341
+ m && m.c === "S" ? h = ["S", c[1], c[2], x, f] : h = [u, c[3], c[4], c[1], c[2], x, f];
1189
1342
  break;
1190
1343
  case "S":
1191
- c && "CS".includes(c.c) && (!m || m.c !== "S") ? h = ["C", l[3], l[4], l[1], l[2], g, f] : h = [u, l[1], l[2], g, f];
1344
+ l && "CS".includes(l.c) && (!m || m.c !== "S") ? h = ["C", a[3], a[4], a[1], a[2], x, f] : h = [u, a[1], a[2], x, f];
1192
1345
  break;
1193
1346
  case "Q":
1194
- m && m.c === "T" ? h = ["T", g, f] : h = [u, ...a.slice(1, -2), g, f];
1347
+ m && m.c === "T" ? h = ["T", x, f] : h = [u, ...c.slice(1, -2), x, f];
1195
1348
  break;
1196
1349
  case "T":
1197
- c && "QT".includes(c.c) && (!m || m.c !== "T") ? h = ["Q", l[1], l[2], g, f] : h = [u, g, f];
1350
+ l && "QT".includes(l.c) && (!m || m.c !== "T") ? h = ["Q", a[1], a[2], x, f] : h = [u, x, f];
1198
1351
  break;
1199
1352
  case "Z":
1200
- h = ["M", g, f];
1353
+ h = ["M", x, f];
1201
1354
  break;
1202
1355
  case "H":
1203
- h = [u, g];
1356
+ h = [u, x];
1204
1357
  break;
1205
1358
  case "V":
1206
1359
  h = [u, f];
1207
1360
  break;
1208
1361
  default:
1209
- h = [u, ...a.slice(1, -2), g, f];
1362
+ h = [u, ...c.slice(1, -2), x, f];
1210
1363
  }
1211
1364
  return h;
1212
1365
  });
1213
- return n ? r.reverse() : [r[0], ...r.slice(1).reverse()];
1214
- }, je = (e, t) => {
1215
- let n = v.Translate(...t.slice(0, -1));
1366
+ return n ? s.reverse() : [s[0], ...s.slice(1).reverse()];
1367
+ }, Ue = (e, t) => {
1368
+ let n = P.Translate(...t.slice(0, -1));
1216
1369
  return [, , , n.m44] = t, n = e.multiply(n), [n.m41, n.m42, n.m43, n.m44];
1217
- }, Ot = (e, t, n) => {
1218
- const [r, s, i] = n, [o, a, l] = je(e, [...t, 0, 1]), c = o - r, m = a - s, u = l - i;
1370
+ }, jt = (e, t, n) => {
1371
+ const [s, r, i] = n, [o, c, a] = Ue(e, [...t, 0, 1]), l = o - s, m = c - r, u = a - i;
1219
1372
  return [
1220
1373
  // protect against division by ZERO
1221
- c * (Math.abs(i) / Math.abs(u) || 1) + r,
1222
- m * (Math.abs(i) / Math.abs(u) || 1) + s
1374
+ l * (Math.abs(i) / Math.abs(u) || 1) + s,
1375
+ m * (Math.abs(i) / Math.abs(u) || 1) + r
1223
1376
  ];
1224
- }, Et = (e, t) => {
1225
- let n = 0, r = 0, s, i, o, a, l, c;
1226
- const m = Q(e), u = t && Object.keys(t);
1227
- if (!t || u && !u.length)
1228
- return [...m];
1229
- const y = z(m);
1377
+ }, ie = (e) => {
1378
+ const t = ft(e) ? e : H(e), n = gt(t) ? t : O(t), s = { ...et }, r = [];
1379
+ let i = [], o = 0, c = "";
1380
+ const a = [];
1381
+ let l = 0, m = t.length;
1382
+ for (l = 0; l < m; l += 1)
1383
+ t[l] && ([c] = t[l]), r[l] = c, c === "A" && (i = ct(n[l], s), t[l] = ct(n[l], s), vt(t, r, l), n[l] = ct(n[l], s), vt(n, r, l), m = Math.max(t.length, n.length)), i = n[l], o = i.length, s.x1 = +i[o - 2], s.y1 = +i[o - 1], s.x2 = +i[o - 4] || s.x1, s.y2 = +i[o - 3] || s.y1, a.push(t[l]);
1384
+ return a;
1385
+ }, It = (e, t) => {
1386
+ let n = 0, s = 0, r, i, o, c, a, l;
1387
+ const m = ie(e), u = t && Object.keys(t);
1388
+ if (!t || u && !u.length) return m.slice(0);
1389
+ const y = O(m);
1230
1390
  if (!t.origin) {
1231
- const { origin: M } = mt;
1232
- Object.assign(t, { origin: M });
1233
- }
1234
- const g = Gt(t), { origin: f } = t, h = { ...ut };
1235
- let x = [], p = 0, b = "", A = [];
1236
- const d = [];
1237
- if (!g.isIdentity) {
1238
- for (s = 0, o = m.length; s < o; s += 1) {
1239
- x = m[s], m[s] && ([b] = x), d[s] = b, b === "A" && (x = ot(y[s], h), m[s] = ot(y[s], h), Mt(m, d, s), y[s] = ot(y[s], h), Mt(y, d, s), o = Math.max(m.length, y.length)), x = y[s], p = x.length, h.x1 = +x[p - 2], h.y1 = +x[p - 1], h.x2 = +x[p - 4] || h.x1, h.y2 = +x[p - 3] || h.y1;
1240
- const M = {
1241
- s: m[s],
1242
- c: m[s][0],
1391
+ const { origin: d } = ht;
1392
+ Object.assign(t, { origin: d });
1393
+ }
1394
+ const x = re(t), { origin: f } = t, h = { ...et };
1395
+ let g = [], p = 0, b = "";
1396
+ const v = [];
1397
+ if (!x.isIdentity) {
1398
+ for (r = 0, o = m.length; r < o; r += 1) {
1399
+ g = y[r], p = g.length, h.x1 = +g[p - 2], h.y1 = +g[p - 1], h.x2 = +g[p - 4] || h.x1, h.y2 = +g[p - 3] || h.y1;
1400
+ const d = {
1401
+ s: m[r],
1402
+ c: m[r][0],
1243
1403
  x: h.x1,
1244
1404
  y: h.y1
1245
1405
  };
1246
- A = [...A, M];
1406
+ v.push(d);
1247
1407
  }
1248
- return A.map((M) => {
1249
- if (b = M.c, x = M.s, b === "L" || b === "H" || b === "V")
1250
- return [l, c] = Ot(g, [M.x, M.y], f), n !== l && r !== c ? x = ["L", l, c] : r === c ? x = ["H", l] : n === l && (x = ["V", c]), n = l, r = c, x;
1251
- for (i = 1, a = x.length; i < a; i += 2)
1252
- [n, r] = Ot(g, [+x[i], +x[i + 1]], f), x[i] = n, x[i + 1] = r;
1253
- return x;
1408
+ return v.map((d) => {
1409
+ if (b = d.c, g = d.s, b === "L" || b === "H" || b === "V")
1410
+ return [a, l] = jt(x, [d.x, d.y], f), n !== a && s !== l ? g = ["L", a, l] : s === l ? g = ["H", a] : n === a && (g = ["V", l]), n = a, s = l, g;
1411
+ for (i = 1, c = g.length; i < c; i += 2)
1412
+ [n, s] = jt(x, [+g[i], +g[i + 1]], f), g[i] = n, g[i + 1] = s;
1413
+ return g;
1254
1414
  });
1255
1415
  }
1256
- return [...m];
1257
- }, ze = (e) => {
1258
- const n = e.slice(0, 2), r = e.slice(2, 4), s = e.slice(4, 6), i = e.slice(6, 8), o = E(n, r, 0.5), a = E(r, s, 0.5), l = E(s, i, 0.5), c = E(o, a, 0.5), m = E(a, l, 0.5), u = E(c, m, 0.5);
1416
+ return m.slice(0);
1417
+ }, Ve = (e) => {
1418
+ const n = e.slice(0, 2), s = e.slice(2, 4), r = e.slice(4, 6), i = e.slice(6, 8), o = z(n, s, 0.5), c = z(s, r, 0.5), a = z(r, i, 0.5), l = z(o, c, 0.5), m = z(c, a, 0.5), u = z(l, m, 0.5);
1259
1419
  return [
1260
- ["C", ...o, ...c, ...u],
1261
- ["C", ...m, ...l, ...i]
1420
+ ["C", ...o, ...l, ...u],
1421
+ ["C", ...m, ...a, ...i]
1262
1422
  ];
1263
1423
  };
1264
- class w {
1424
+ class N {
1265
1425
  /**
1266
1426
  * @constructor
1267
- * @param {string} pathValue the path string
1268
- * @param {any} config instance options
1427
+ * @param pathValue the path string
1428
+ * @param config instance options
1269
1429
  */
1270
1430
  constructor(t, n) {
1271
- const r = n || {}, s = typeof t > "u";
1272
- if (s || !t.length)
1273
- throw TypeError(`${k}: "pathValue" is ${s ? "undefined" : "empty"}`);
1274
- const i = Z(t);
1431
+ const s = n || {}, r = typeof t > "u";
1432
+ if (r || !t.length)
1433
+ throw TypeError(`${$}: "pathValue" is ${r ? "undefined" : "empty"}`);
1434
+ const i = Y(t);
1275
1435
  this.segments = i;
1276
- const { width: o, height: a, cx: l, cy: c, cz: m } = this.getBBox(), { round: u, origin: y } = r;
1277
- let g;
1436
+ const { width: o, height: c, cx: a, cy: l, cz: m } = this.bbox, { round: u, origin: y } = s;
1437
+ let x;
1278
1438
  if (u === "auto") {
1279
- const h = `${Math.floor(Math.max(o, a))}`.length;
1280
- g = h >= 4 ? 0 : 4 - h;
1281
- } else
1282
- Number.isInteger(u) || u === "off" ? g = u : g = mt.round;
1283
- let f;
1439
+ const h = `${Math.floor(Math.max(o, c))}`.length;
1440
+ x = h >= 4 ? 0 : 4 - h;
1441
+ } else Number.isInteger(u) || u === "off" ? x = u : x = ht.round;
1442
+ let f = [a, l, m];
1284
1443
  if (Array.isArray(y) && y.length >= 2) {
1285
- const [h, x, p] = y.map(Number);
1444
+ const [h, g, p] = y.map(Number);
1286
1445
  f = [
1287
- Number.isNaN(h) ? l : h,
1288
- Number.isNaN(x) ? c : x,
1446
+ Number.isNaN(h) ? a : h,
1447
+ Number.isNaN(g) ? l : g,
1289
1448
  Number.isNaN(p) ? m : p
1290
1449
  ];
1291
- } else
1292
- f = [l, c, m];
1293
- return this.round = g, this.origin = f, this;
1450
+ }
1451
+ return this.round = x, this.origin = f, this;
1452
+ }
1453
+ get bbox() {
1454
+ return St(this.segments);
1455
+ }
1456
+ get length() {
1457
+ return F(this.segments);
1294
1458
  }
1295
1459
  /**
1296
1460
  * Returns the path bounding box, equivalent to native `path.getBBox()`.
@@ -1299,7 +1463,7 @@ class w {
1299
1463
  * @returns the pathBBox
1300
1464
  */
1301
1465
  getBBox() {
1302
- return kt(this.segments);
1466
+ return this.bbox;
1303
1467
  }
1304
1468
  /**
1305
1469
  * Returns the total path length, equivalent to native `path.getTotalLength()`.
@@ -1308,7 +1472,7 @@ class w {
1308
1472
  * @returns the path total length
1309
1473
  */
1310
1474
  getTotalLength() {
1311
- return X(this.segments);
1475
+ return this.length;
1312
1476
  }
1313
1477
  /**
1314
1478
  * Returns an `{x,y}` point in the path stroke at a given length,
@@ -1319,7 +1483,7 @@ class w {
1319
1483
  * @returns the requested point
1320
1484
  */
1321
1485
  getPointAtLength(t) {
1322
- return K(this.segments, t);
1486
+ return W(this.segments, t);
1323
1487
  }
1324
1488
  /**
1325
1489
  * Convert path to absolute values
@@ -1328,7 +1492,7 @@ class w {
1328
1492
  */
1329
1493
  toAbsolute() {
1330
1494
  const { segments: t } = this;
1331
- return this.segments = Q(t), this;
1495
+ return this.segments = H(t), this;
1332
1496
  }
1333
1497
  /**
1334
1498
  * Convert path to relative values
@@ -1337,7 +1501,7 @@ class w {
1337
1501
  */
1338
1502
  toRelative() {
1339
1503
  const { segments: t } = this;
1340
- return this.segments = Nt(t), this;
1504
+ return this.segments = At(t), this;
1341
1505
  }
1342
1506
  /**
1343
1507
  * Convert path to cubic-bezier values. In addition, un-necessary `Z`
@@ -1347,7 +1511,7 @@ class w {
1347
1511
  */
1348
1512
  toCurve() {
1349
1513
  const { segments: t } = this;
1350
- return this.segments = ct(t), this;
1514
+ return this.segments = lt(t), this;
1351
1515
  }
1352
1516
  /**
1353
1517
  * Reverse the order of the segments and their values.
@@ -1357,9 +1521,9 @@ class w {
1357
1521
  */
1358
1522
  reverse(t) {
1359
1523
  this.toAbsolute();
1360
- const { segments: n } = this, r = $t(n), s = r.length > 1 ? r : !1, i = s ? [...s].map((a, l) => t ? l ? it(a) : [...a] : it(a)) : [...n];
1524
+ const { segments: n } = this, s = zt(n), r = s.length > 1 ? s : !1, i = r ? r.map((c, a) => t ? a ? ot(c) : c.slice(0) : ot(c)) : n.slice(0);
1361
1525
  let o = [];
1362
- return s ? o = i.flat(1) : o = t ? n : it(n), this.segments = [...o], this;
1526
+ return r ? o = i.flat(1) : o = t ? n : ot(n), this.segments = o.slice(0), this;
1363
1527
  }
1364
1528
  /**
1365
1529
  * Normalize path in 2 steps:
@@ -1370,7 +1534,7 @@ class w {
1370
1534
  */
1371
1535
  normalize() {
1372
1536
  const { segments: t } = this;
1373
- return this.segments = z(t), this;
1537
+ return this.segments = O(t), this;
1374
1538
  }
1375
1539
  /**
1376
1540
  * Optimize `pathArray` values:
@@ -1382,7 +1546,7 @@ class w {
1382
1546
  */
1383
1547
  optimize() {
1384
1548
  const { segments: t } = this;
1385
- return this.segments = qt(t, this.round), this;
1549
+ return this.segments = Ot(t, this.round), this;
1386
1550
  }
1387
1551
  /**
1388
1552
  * Transform path using values from an `Object` defined as `transformObject`.
@@ -1393,21 +1557,21 @@ class w {
1393
1557
  * @public
1394
1558
  */
1395
1559
  transform(t) {
1396
- if (!t || typeof t != "object" || typeof t == "object" && !["translate", "rotate", "skew", "scale"].some((l) => l in t))
1560
+ if (!t || typeof t != "object" || typeof t == "object" && !["translate", "rotate", "skew", "scale"].some((a) => a in t))
1397
1561
  return this;
1398
1562
  const {
1399
1563
  segments: n,
1400
- origin: [r, s, i]
1564
+ origin: [s, r, i]
1401
1565
  } = this, o = {};
1402
- for (const [l, c] of Object.entries(t))
1403
- l === "skew" && Array.isArray(c) || (l === "rotate" || l === "translate" || l === "origin" || l === "scale") && Array.isArray(c) ? o[l] = c.map(Number) : l !== "origin" && typeof Number(c) == "number" && (o[l] = Number(c));
1404
- const { origin: a } = o;
1405
- if (Array.isArray(a) && a.length >= 2) {
1406
- const [l, c, m] = a.map(Number);
1407
- o.origin = [Number.isNaN(l) ? r : l, Number.isNaN(c) ? s : c, m || i];
1566
+ for (const [a, l] of Object.entries(t))
1567
+ a === "skew" && Array.isArray(l) || (a === "rotate" || a === "translate" || a === "origin" || a === "scale") && Array.isArray(l) ? o[a] = l.map(Number) : a !== "origin" && typeof Number(l) == "number" && (o[a] = Number(l));
1568
+ const { origin: c } = o;
1569
+ if (Array.isArray(c) && c.length >= 2) {
1570
+ const [a, l, m] = c.map(Number);
1571
+ o.origin = [Number.isNaN(a) ? s : a, Number.isNaN(l) ? r : l, m || i];
1408
1572
  } else
1409
- o.origin = [r, s, i];
1410
- return this.segments = Et(n, o), this;
1573
+ o.origin = [s, r, i];
1574
+ return this.segments = It(n, o), this;
1411
1575
  }
1412
1576
  /**
1413
1577
  * Rotate path 180deg vertically
@@ -1433,12 +1597,12 @@ class w {
1433
1597
  * @return the path string
1434
1598
  */
1435
1599
  toString() {
1436
- return At(this.segments, this.round);
1600
+ return Pt(this.segments, this.round);
1437
1601
  }
1438
1602
  }
1439
1603
  // bring main utilities to front
1440
- N(w, "CSSMatrix", v), N(w, "getSVGMatrix", Gt), N(w, "getPathBBox", kt), N(w, "getPathArea", Vt), N(w, "getTotalLength", X), N(w, "getDrawDirection", Ne), N(w, "getPointAtLength", K), N(w, "pathLengthFactory", ft), N(w, "getPropertiesAtLength", Pt), N(w, "getPropertiesAtPoint", yt), N(w, "polygonLength", ae), N(w, "polygonArea", le), N(w, "getClosestPoint", we), N(w, "getSegmentOfPoint", ve), N(w, "getSegmentAtLength", Pe), N(w, "isPointInStroke", Ce), N(w, "isValidPath", Kt), N(w, "isPathArray", _), N(w, "isAbsoluteArray", wt), N(w, "isRelativeArray", _t), N(w, "isCurveArray", Jt), N(w, "isNormalizedArray", vt), N(w, "shapeToPath", qe), N(w, "shapeToPathArray", Wt), N(w, "parsePathString", Z), N(w, "roundPath", at), N(w, "splitPath", $t), N(w, "splitCubic", ze), N(w, "optimizePath", qt), N(w, "reverseCurve", Ee), N(w, "reversePath", it), N(w, "normalizePath", z), N(w, "transformPath", Et), N(w, "pathToAbsolute", Q), N(w, "pathToRelative", Nt), N(w, "pathToCurve", ct), N(w, "pathToString", At);
1604
+ M(N, "CSSMatrix", P), M(N, "getSVGMatrix", re), M(N, "getPathBBox", St), M(N, "getPathArea", te), M(N, "getTotalLength", F), M(N, "getDrawDirection", Ie), M(N, "getPointAtLength", W), M(N, "pathFactory", yt), M(N, "getPropertiesAtLength", Ct), M(N, "getPropertiesAtPoint", xt), M(N, "polygonLength", xe), M(N, "polygonArea", ye), M(N, "getClosestPoint", De), M(N, "getSegmentOfPoint", Re), M(N, "getSegmentAtLength", Xe), M(N, "isPointInStroke", Ze), M(N, "isValidPath", ee), M(N, "isPathArray", G), M(N, "isAbsoluteArray", ft), M(N, "isRelativeArray", ne), M(N, "isCurveArray", Wt), M(N, "isNormalizedArray", gt), M(N, "shapeToPath", Je), M(N, "shapeToPathArray", se), M(N, "parsePathString", Y), M(N, "roundPath", mt), M(N, "splitPath", zt), M(N, "splitCubic", Ve), M(N, "replaceArc", ie), M(N, "optimizePath", Ot), M(N, "reverseCurve", Ke), M(N, "reversePath", ot), M(N, "normalizePath", O), M(N, "transformPath", It), M(N, "pathToAbsolute", H), M(N, "pathToRelative", At), M(N, "pathToCurve", lt), M(N, "pathToString", Pt);
1441
1605
  export {
1442
- w as default
1606
+ N as default
1443
1607
  };
1444
1608
  //# sourceMappingURL=svg-path-commander.mjs.map