svg-path-commander 2.2.1 → 2.2.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.min.js","names":[],"sources":["../package.json","../node_modules/.pnpm/@thednp+dommatrix@3.0.4/node_modules/@thednp/dommatrix/dist/dommatrix.mjs","../src/math/midPoint.ts","../src/math/distanceSquareRoot.ts","../src/math/lineTools.ts","../src/math/arcTools.ts","../src/math/bezier.ts","../src/math/cubicTools.ts","../src/math/quadTools.ts","../src/math/polygonTools.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/options/options.ts","../src/parser/paramsCount.ts","../src/parser/finalizeSegment.ts","../src/util/error.ts","../src/parser/scanFlag.ts","../src/parser/isDigit.ts","../src/parser/invalidPathValue.ts","../src/parser/scanParam.ts","../src/parser/isSpace.ts","../src/parser/skipSpaces.ts","../src/parser/isPathCommand.ts","../src/parser/isDigitStart.ts","../src/parser/isArcCommand.ts","../src/parser/isMoveCommand.ts","../src/parser/scanSegment.ts","../src/parser/pathParser.ts","../src/parser/parsePathString.ts","../src/process/absolutizeSegment.ts","../src/process/iterate.ts","../src/convert/pathToAbsolute.ts","../src/process/relativizeSegment.ts","../src/convert/pathToRelative.ts","../src/process/arcToCubic.ts","../src/process/quadToCubic.ts","../src/process/lineToCubic.ts","../src/process/segmentToCubic.ts","../src/process/normalizeSegment.ts","../src/parser/paramsParser.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/distanceEpsilon.ts","../src/process/normalizePath.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getClosestPoint.ts","../src/util/getPathArea.ts","../src/util/getDrawDirection.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isPathArray.ts","../src/util/isAbsoluteArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeParams.ts","../src/util/isElement.ts","../src/util/shapeToPathArray.ts","../src/util/shapeToPath.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.ts","../src/process/shortenSegment.ts","../src/process/roundSegment.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/getSVGMatrix.ts","../src/process/projection2d.ts","../src/process/transformPath.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/pathToPolyline.ts","../src/morph/splitLineToCount.ts","../src/morph/getPathSplits.ts","../src/morph/splitLinePathToCount.ts","../src/morph/splitCubicToCount.ts","../src/morph/splitCurvePathToCount.ts","../src/morph/getRotatedPath.ts","../src/morph/equalizeSegments.ts","../src/intersect/isPointInsideBBox.ts","../src/intersect/boundingBoxIntersect.ts","../src/morph/createPlaceholder.ts","../src/morph/matchPaths.ts","../src/morph/classifyPaths.ts","../src/morph/equalizePaths.ts","../src/intersect/interHelper.ts","../src/intersect/pathIntersection.ts","../src/main.ts","../src/index.ts"],"sourcesContent":["","//#region src/index.ts\nvar e = {\n\ta: 1,\n\tb: 0,\n\tc: 0,\n\td: 1,\n\te: 0,\n\tf: 0,\n\tm11: 1,\n\tm12: 0,\n\tm13: 0,\n\tm14: 0,\n\tm21: 0,\n\tm22: 1,\n\tm23: 0,\n\tm24: 0,\n\tm31: 0,\n\tm32: 0,\n\tm33: 1,\n\tm34: 0,\n\tm41: 0,\n\tm42: 0,\n\tm43: 0,\n\tm44: 1,\n\tis2D: !0,\n\tisIdentity: !0\n}, t = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((e) => typeof e == \"number\")) && [6, 16].some((t) => e.length === t), n = (t) => t instanceof DOMMatrix || t instanceof h || typeof t == \"object\" && Object.keys(e).every((e) => t && e in t), r = (e) => {\n\tlet n = new h(), r = Array.from(e);\n\tif (!t(r)) throw TypeError(`CSSMatrix: \"${r.join(\",\")}\" must be an array with 6/16 numbers.`);\n\t// istanbul ignore else @preserve\n\tif (r.length === 16) {\n\t\tlet [e, t, i, a, o, s, c, l, u, d, f, p, m, h, g, _] = r;\n\t\tn.m11 = e, n.a = e, n.m21 = o, n.c = o, n.m31 = u, n.m41 = m, n.e = m, n.m12 = t, n.b = t, n.m22 = s, n.d = s, n.m32 = d, n.m42 = h, n.f = h, n.m13 = i, n.m23 = c, n.m33 = f, n.m43 = g, n.m14 = a, n.m24 = l, n.m34 = p, n.m44 = _;\n\t} else if (r.length === 6) {\n\t\tlet [e, t, i, a, o, s] = r;\n\t\tn.m11 = e, n.a = e, n.m12 = t, n.b = t, n.m21 = i, n.c = i, n.m22 = a, n.d = a, n.m41 = o, n.e = o, n.m42 = s, n.f = s;\n\t}\n\treturn n;\n}, i = (e) => {\n\tif (n(e)) return r([\n\t\te.m11,\n\t\te.m12,\n\t\te.m13,\n\t\te.m14,\n\t\te.m21,\n\t\te.m22,\n\t\te.m23,\n\t\te.m24,\n\t\te.m31,\n\t\te.m32,\n\t\te.m33,\n\t\te.m34,\n\t\te.m41,\n\t\te.m42,\n\t\te.m43,\n\t\te.m44\n\t]);\n\tthrow TypeError(`CSSMatrix: \"${JSON.stringify(e)}\" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);\n}, a = (e) => {\n\tif (typeof e != \"string\") throw TypeError(`CSSMatrix: \"${JSON.stringify(e)}\" is not a string.`);\n\tlet t = String(e).replace(/\\s/g, \"\"), n = new h(), i = `CSSMatrix: invalid transform string \"${e}\"`;\n\treturn t.split(\")\").filter((e) => e).forEach((e) => {\n\t\tlet [t, a] = e.split(\"(\");\n\t\tif (!a) throw TypeError(i);\n\t\tlet o = a.split(\",\").map((e) => e.includes(\"rad\") ? 180 / Math.PI * parseFloat(e) : parseFloat(e)), [s, c, l, u] = o, d = [\n\t\t\ts,\n\t\t\tc,\n\t\t\tl\n\t\t], f = [\n\t\t\ts,\n\t\t\tc,\n\t\t\tl,\n\t\t\tu\n\t\t];\n\t\tif (t === \"perspective\" && s && [c, l].every((e) => e === void 0)) n.m34 = -1 / s;\n\t\telse if (t.includes(\"matrix\") && [6, 16].includes(o.length) && o.every((e) => !Number.isNaN(+e))) {\n\t\t\tlet e = o.map((e) => Math.abs(e) < 1e-6 ? 0 : e);\n\t\t\tn.multiplySelf(r(e));\n\t\t} else if (t === \"translate3d\" && d.every((e) => !Number.isNaN(+e))) n.translateSelf(s, c, l);\n\t\telse if (t === \"translate\" && s && l === void 0) n.translateSelf(s, c || 0, 0);\n\t\telse if (t === \"rotate3d\" && f.every((e) => !Number.isNaN(+e)) && u) n.rotateAxisAngleSelf(s, c, l, u);\n\t\telse if (t === \"rotate\" && s && [c, l].every((e) => e === void 0)) n.rotateSelf(0, 0, s);\n\t\telse if (t === \"scale3d\" && d.every((e) => !Number.isNaN(+e)) && d.some((e) => e !== 1)) n.scaleSelf(s, c, l);\n\t\telse if (t === \"scale\" && !Number.isNaN(s) && (s !== 1 || c !== 1) && l === void 0) {\n\t\t\tlet e = Number.isNaN(+c) ? s : c;\n\t\t\tn.scaleSelf(s, e, 1);\n\t\t} else if (t === \"skew\" && (s || !Number.isNaN(s) && c) && l === void 0) n.skewSelf(s, c || 0);\n\t\telse if ([\n\t\t\t\"translate\",\n\t\t\t\"rotate\",\n\t\t\t\"scale\",\n\t\t\t\"skew\"\n\t\t].some((e) => t.includes(e)) && /[XYZ]/.test(t) && s && [c, l].every((e) => e === void 0)) if (t === \"skewX\" || t === \"skewY\") n[t === \"skewX\" ? \"skewXSelf\" : \"skewYSelf\"](s);\n\t\telse {\n\t\t\tlet e = t.replace(/[XYZ]/, \"\"), r = t.replace(e, \"\"), i = [\n\t\t\t\t\"X\",\n\t\t\t\t\"Y\",\n\t\t\t\t\"Z\"\n\t\t\t].indexOf(r), a = e === \"scale\" ? 1 : 0, o = e + \"Self\", c = [\n\t\t\t\ti === 0 ? s : a,\n\t\t\t\ti === 1 ? s : a,\n\t\t\t\ti === 2 ? s : a\n\t\t\t];\n\t\t\tn[o](...c);\n\t\t}\n\t\telse throw TypeError(i);\n\t}), n;\n}, o = (e, t) => t ? [\n\te.a,\n\te.b,\n\te.c,\n\te.d,\n\te.e,\n\te.f\n] : [\n\te.m11,\n\te.m12,\n\te.m13,\n\te.m14,\n\te.m21,\n\te.m22,\n\te.m23,\n\te.m24,\n\te.m31,\n\te.m32,\n\te.m33,\n\te.m34,\n\te.m41,\n\te.m42,\n\te.m43,\n\te.m44\n], s = (e, t, n) => {\n\tlet r = new h();\n\treturn r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = n, r;\n}, c = (e, t, n) => {\n\tlet r = new h(), i = Math.PI / 180, a = e * i, o = t * i, s = n * i, c = Math.cos(a), l = -Math.sin(a), u = Math.cos(o), d = -Math.sin(o), f = Math.cos(s), p = -Math.sin(s), m = u * f, g = -u * p;\n\tr.m11 = m, r.a = m, r.m12 = g, r.b = g, r.m13 = d;\n\tlet _ = l * d * f + c * p;\n\tr.m21 = _, r.c = _;\n\tlet v = c * f - l * d * p;\n\treturn r.m22 = v, r.d = v, r.m23 = -l * u, r.m31 = l * p - c * d * f, r.m32 = l * f + c * d * p, r.m33 = c * u, r;\n}, l = (e = 0, t = 0, n = 0, r = 0) => {\n\tlet i = new h(), a = Math.sqrt(e * e + t * t + n * n);\n\tif (a === 0) return i;\n\tlet o = e / a, s = t / a, c = n / a, l = Math.PI / 360 * r, u = Math.sin(l), d = Math.cos(l), f = u * u, p = o * o, m = s * s, g = c * c, _ = 1 - 2 * (m + g) * f;\n\ti.m11 = _, i.a = _;\n\tlet v = 2 * (o * s * f + c * u * d);\n\ti.m12 = v, i.b = v, i.m13 = 2 * (o * c * f - s * u * d);\n\tlet y = 2 * (s * o * f - c * u * d);\n\ti.m21 = y, i.c = y;\n\tlet b = 1 - 2 * (g + p) * f;\n\treturn i.m22 = b, i.d = b, i.m23 = 2 * (s * c * f + o * u * d), i.m31 = 2 * (c * o * f + s * u * d), i.m32 = 2 * (c * s * f - o * u * d), i.m33 = 1 - 2 * (p + m) * f, i;\n}, u = (e, t, n) => {\n\tlet r = new h();\n\treturn r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = n, r;\n}, d = (e, t) => {\n\tlet n = new h();\n\tif (e) {\n\t\tlet t = e * Math.PI / 180, r = Math.tan(t);\n\t\tn.m21 = r, n.c = r;\n\t}\n\tif (t) {\n\t\tlet e = t * Math.PI / 180, r = Math.tan(e);\n\t\tn.m12 = r, n.b = r;\n\t}\n\treturn n;\n}, f = (e) => d(e, 0), p = (e) => d(0, e), m = (e, t) => r([\n\tt.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41,\n\tt.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42,\n\tt.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43,\n\tt.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44,\n\tt.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41,\n\tt.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42,\n\tt.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43,\n\tt.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44,\n\tt.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41,\n\tt.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42,\n\tt.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43,\n\tt.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44,\n\tt.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41,\n\tt.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42,\n\tt.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43,\n\tt.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44\n]), h = class {\n\tstatic Translate = s;\n\tstatic Rotate = c;\n\tstatic RotateAxisAngle = l;\n\tstatic Scale = u;\n\tstatic SkewX = f;\n\tstatic SkewY = p;\n\tstatic Skew = d;\n\tstatic Multiply = m;\n\tstatic fromArray = r;\n\tstatic fromMatrix = i;\n\tstatic fromString = a;\n\tstatic toArray = o;\n\tstatic isCompatibleArray = t;\n\tstatic isCompatibleObject = n;\n\tconstructor(e) {\n\t\treturn this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.e = 0, this.f = 0, this.m11 = 1, this.m12 = 0, this.m13 = 0, this.m14 = 0, this.m21 = 0, this.m22 = 1, this.m23 = 0, this.m24 = 0, this.m31 = 0, this.m32 = 0, this.m33 = 1, this.m34 = 0, this.m41 = 0, this.m42 = 0, this.m43 = 0, this.m44 = 1, e ? this.setMatrixValue(e) : this;\n\t}\n\tget isIdentity() {\n\t\treturn this.m11 === 1 && this.m12 === 0 && this.m13 === 0 && this.m14 === 0 && this.m21 === 0 && this.m22 === 1 && this.m23 === 0 && this.m24 === 0 && this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m41 === 0 && this.m42 === 0 && this.m43 === 0 && this.m44 === 1;\n\t}\n\tget is2D() {\n\t\treturn this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;\n\t}\n\tsetMatrixValue(e) {\n\t\treturn typeof e == \"string\" && e.length && e !== \"none\" ? a(e) : Array.isArray(e) || e instanceof Float64Array || e instanceof Float32Array ? r(e) : typeof e == \"object\" ? i(e) : this;\n\t}\n\ttoFloat32Array(e) {\n\t\treturn Float32Array.from(o(this, e));\n\t}\n\ttoFloat64Array(e) {\n\t\treturn Float64Array.from(o(this, e));\n\t}\n\ttoString() {\n\t\tlet { is2D: e } = this, t = this.toFloat64Array(e).join(\", \");\n\t\treturn `${e ? \"matrix\" : \"matrix3d\"}(${t})`;\n\t}\n\ttoJSON() {\n\t\tlet { is2D: e, isIdentity: t } = this;\n\t\treturn {\n\t\t\t...this,\n\t\t\tis2D: e,\n\t\t\tisIdentity: t\n\t\t};\n\t}\n\tmultiply(e) {\n\t\treturn m(this, e);\n\t}\n\ttranslate(e, t, n) {\n\t\treturn this.multiply(s(e, t ?? 0, n ?? 0));\n\t}\n\tscale(e, t, n) {\n\t\treturn this.multiply(u(e, t ?? e, n ?? 1));\n\t}\n\trotate(e, t, n) {\n\t\tlet r = e, i = t || 0, a = n || 0;\n\t\treturn typeof e == \"number\" && t === void 0 && n === void 0 && (a = r, r = 0, i = 0), this.multiply(c(r, i, a));\n\t}\n\trotateAxisAngle(e = 0, t = 0, n = 0, r = 0) {\n\t\tif ([\n\t\t\te,\n\t\t\tt,\n\t\t\tn,\n\t\t\tr\n\t\t].some((e) => !Number.isFinite(e))) throw TypeError(\"CSSMatrix: expecting 4 values\");\n\t\treturn Math.sqrt(e * e + t * t + n * n) === 0 ? i(this) : this.multiply(l(e, t, n, r));\n\t}\n\tskewX(e) {\n\t\treturn this.multiply(f(e));\n\t}\n\tskewY(e) {\n\t\treturn this.multiply(p(e));\n\t}\n\tskew(e, t) {\n\t\treturn this.multiply(d(e, t));\n\t}\n\tmultiplySelf(e) {\n\t\tlet t = m(this, e);\n\t\treturn Object.assign(this, t), this;\n\t}\n\ttranslateSelf(e, t, n) {\n\t\treturn this.multiplySelf(s(e, t ?? 0, n ?? 0));\n\t}\n\tscaleSelf(e, t, n) {\n\t\treturn this.multiplySelf(u(e, t ?? e, n ?? 1));\n\t}\n\trotateSelf(e, t, n) {\n\t\tlet r = e, i = t || 0, a = n || 0;\n\t\treturn typeof e == \"number\" && t === void 0 && n === void 0 && (a = r, r = 0, i = 0), this.multiplySelf(c(r, i, a));\n\t}\n\trotateAxisAngleSelf(e = 0, t = 0, n = 0, r = 0) {\n\t\tif ([\n\t\t\te,\n\t\t\tt,\n\t\t\tn,\n\t\t\tr\n\t\t].some((e) => !Number.isFinite(e))) throw TypeError(\"CSSMatrix: expecting 4 values\");\n\t\treturn Math.sqrt(e * e + t * t + n * n) === 0 ? this : this.multiplySelf(l(e, t, n, r));\n\t}\n\tskewXSelf(e) {\n\t\treturn this.multiplySelf(f(e));\n\t}\n\tskewYSelf(e) {\n\t\treturn this.multiplySelf(p(e));\n\t}\n\tskewSelf(e, t) {\n\t\treturn this.multiplySelf(d(e, t));\n\t}\n\ttransformPoint(e) {\n\t\tlet t = this.m11 * e.x + this.m21 * e.y + this.m31 * e.z + this.m41 * e.w, n = this.m12 * e.x + this.m22 * e.y + this.m32 * e.z + this.m42 * e.w, r = this.m13 * e.x + this.m23 * e.y + this.m33 * e.z + this.m43 * e.w, i = this.m14 * e.x + this.m24 * e.y + this.m34 * e.z + this.m44 * e.w;\n\t\treturn e instanceof DOMPoint ? new DOMPoint(t, n, r, i) : {\n\t\t\tx: t,\n\t\t\ty: n,\n\t\t\tz: r,\n\t\t\tw: i\n\t\t};\n\t}\n};\n//#endregion\nexport { h as default };\n\n//# sourceMappingURL=dommatrix.mjs.map","import { PointTuple } from \"../types\";\n\n/**\n * Returns the coordinates of a specified distance\n * ratio between two points.\n *\n * @param a the first point coordinates\n * @param b the second point coordinates\n * @param t the ratio\n * @returns the midpoint coordinates\n */\nexport const midPoint = (\n [ax, ay]: PointTuple,\n [bx, by]: PointTuple,\n t: number,\n): PointTuple => {\n return [ax + (bx - ax) * t, ay + (by - ay) * t];\n};\n","import { type PointTuple } from \"../types\";\n\n/**\n * Returns the square root of the distance\n * between two given points.\n *\n * @param a the first point coordinates\n * @param b the second point coordinates\n * @returns the distance value\n */\nexport const distanceSquareRoot = (a: PointTuple, b: PointTuple) => {\n return Math.sqrt(\n (a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]),\n );\n};\n","import { midPoint } from \"./midPoint\";\nimport { distanceSquareRoot } from \"./distanceSquareRoot\";\n\n/**\n * Returns length for line segments (MoveTo, LineTo).\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the line segment length\n */\nconst getLineLength = (x1: number, y1: number, x2: number, y2: number) => {\n return distanceSquareRoot([x1, y1], [x2, y2]);\n};\n\n/**\n * Returns a point along the line segments (MoveTo, LineTo).\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to point in [0-1] range\n * @returns the point at length\n */\nconst getPointAtLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n distance?: number,\n) => {\n let point = { x: x1, y: y1 };\n\n /* istanbul ignore else @preserve */\n if (typeof distance === \"number\") {\n const length = distanceSquareRoot([x1, y1], [x2, y2]);\n if (distance <= 0) {\n point = { x: x1, y: y1 };\n } else if (distance >= length) {\n point = { x: x2, y: y2 };\n } else {\n const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);\n point = { x, y };\n }\n }\n return point;\n};\n\n/**\n * Returns bounding box for line segments (MoveTo, LineTo).\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the bounding box for line segments\n */\nconst getLineBBox = (x1: number, y1: number, x2: number, y2: number) => {\n const { min, max } = Math;\n\n return [min(x1, x2), min(y1, y2), max(x1, x2), max(y1, y2)] as [\n number,\n number,\n number,\n number,\n ];\n};\n\nconst lineTools = {\n getLineBBox,\n getLineLength,\n getPointAtLineLength,\n};\n\nexport { getLineBBox, getLineLength, getPointAtLineLength, lineTools };\n","import { getPointAtLineLength } from \"./lineTools\";\nimport type { Point, PointTuple } from \"../types\";\n\n/**\n * Returns the Arc segment length.\n * @param rx radius along X axis\n * @param ry radius along Y axis\n * @param theta the angle in radians\n * @returns the arc length\n */\nconst arcLength = (rx: number, ry: number, theta: number) => {\n const halfTheta = theta / 2;\n const sinHalfTheta = Math.sin(halfTheta);\n const cosHalfTheta = Math.cos(halfTheta);\n const term1 = rx ** 2 * sinHalfTheta ** 2;\n const term2 = ry ** 2 * cosHalfTheta ** 2;\n const length = Math.sqrt(term1 + term2) * theta;\n return Math.abs(length);\n};\n\n/**\n * Find point on ellipse at given angle around ellipse (theta);\n * @param cx the center X\n * @param cy the center Y\n * @param rx the radius X\n * @param ry the radius Y\n * @param alpha the arc rotation angle in radians\n * @param theta the arc sweep angle in radians\n * @returns a point around ellipse at given angle\n */\nconst arcPoint = (\n cx: number,\n cy: number,\n rx: number,\n ry: number,\n alpha: number,\n theta: number,\n) => {\n const { sin, cos } = Math;\n // theta is angle in radians around arc\n // alpha is angle of rotation of ellipse in radians\n const cosA = cos(alpha);\n const sinA = sin(alpha);\n const x = rx * cos(theta);\n const y = ry * sin(theta);\n\n return [cx + cosA * x - sinA * y, cy + sinA * x + cosA * y] as PointTuple;\n};\n\n/**\n * Returns the angle between two points.\n * @param v0 starting point\n * @param v1 ending point\n * @returns the angle in radian\n */\nconst angleBetween = (v0: Point, v1: Point) => {\n const { x: v0x, y: v0y } = v0;\n const { x: v1x, y: v1y } = v1;\n const p = v0x * v1x + v0y * v1y;\n const n = Math.sqrt((v0x ** 2 + v0y ** 2) * (v1x ** 2 + v1y ** 2));\n const sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;\n return sign * Math.acos(p / n);\n};\n\n/**\n * Returns the following properties for an Arc segment: center, start angle,\n * end angle, and radiuses on X and Y axis.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param RX the radius on X axis\n * @param RY the radius on Y axis\n * @param angle the ellipse rotation in degrees\n * @param LAF the large arc flag\n * @param SF the sweep flag\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns properties specific to Arc segments\n */\nconst getArcProps = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n) => {\n const { abs, sin, cos, sqrt, PI } = Math;\n let rx = abs(RX);\n let ry = abs(RY);\n const xRot = ((angle % 360) + 360) % 360;\n const xRotRad = xRot * (PI / 180);\n\n // istanbul ignore next @preserve\n if (x1 === x && y1 === y) {\n return {\n rx,\n ry,\n startAngle: 0,\n endAngle: 0,\n center: { x, y },\n };\n }\n\n if (rx === 0 || ry === 0) {\n return {\n rx,\n ry,\n startAngle: 0,\n endAngle: 0,\n center: { x: (x + x1) / 2, y: (y + y1) / 2 },\n };\n }\n\n const dx = (x1 - x) / 2;\n const dy = (y1 - y) / 2;\n\n const transformedPoint = {\n x: cos(xRotRad) * dx + sin(xRotRad) * dy,\n y: -sin(xRotRad) * dx + cos(xRotRad) * dy,\n };\n\n const radiiCheck = transformedPoint.x ** 2 / rx ** 2 +\n transformedPoint.y ** 2 / ry ** 2;\n\n if (radiiCheck > 1) {\n rx *= sqrt(radiiCheck);\n ry *= sqrt(radiiCheck);\n }\n\n const cSquareNumerator = rx ** 2 * ry ** 2 -\n rx ** 2 * transformedPoint.y ** 2 - ry ** 2 * transformedPoint.x ** 2;\n const cSquareRootDenom = rx ** 2 * transformedPoint.y ** 2 +\n ry ** 2 * transformedPoint.x ** 2;\n\n let cRadicand = cSquareNumerator / cSquareRootDenom;\n /* istanbul ignore next @preserve */\n cRadicand = cRadicand < 0 ? 0 : cRadicand;\n const cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);\n const transformedCenter = {\n x: cCoef * ((rx * transformedPoint.y) / ry),\n y: cCoef * (-(ry * transformedPoint.x) / rx),\n };\n\n const center = {\n x: cos(xRotRad) * transformedCenter.x - sin(xRotRad) * transformedCenter.y +\n (x1 + x) / 2,\n y: sin(xRotRad) * transformedCenter.x + cos(xRotRad) * transformedCenter.y +\n (y1 + y) / 2,\n };\n\n const startVector = {\n x: (transformedPoint.x - transformedCenter.x) / rx,\n y: (transformedPoint.y - transformedCenter.y) / ry,\n };\n\n const startAngle = angleBetween({ x: 1, y: 0 }, startVector);\n\n const endVector = {\n x: (-transformedPoint.x - transformedCenter.x) / rx,\n y: (-transformedPoint.y - transformedCenter.y) / ry,\n };\n\n let sweepAngle = angleBetween(startVector, endVector);\n if (!SF && sweepAngle > 0) {\n sweepAngle -= 2 * PI;\n } else if (SF && sweepAngle < 0) {\n sweepAngle += 2 * PI;\n }\n sweepAngle %= 2 * PI;\n\n const endAngle = startAngle + sweepAngle;\n\n // point.ellipticalArcStartAngle = startAngle;\n // point.ellipticalArcEndAngle = startAngle + sweepAngle;\n // point.ellipticalArcAngle = alpha;\n\n // point.ellipticalArcCenter = center;\n // point.resultantRx = rx;\n // point.resultantRy = ry;\n\n return {\n center,\n startAngle,\n endAngle,\n rx,\n ry,\n };\n};\n\n/**\n * Returns the length of an Arc segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the length of the Arc segment\n */\nconst getArcLength = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n) => {\n const { rx, ry, startAngle, endAngle } = getArcProps(\n x1,\n y1,\n RX,\n RY,\n angle,\n LAF,\n SF,\n x,\n y,\n );\n return arcLength(rx, ry, endAngle - startAngle);\n};\n\n/**\n * Returns a point along an Arc segment at a given distance.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param RX the radius on X axis\n * @param RY the radius on Y axis\n * @param angle the ellipse rotation in degrees\n * @param LAF the large arc flag\n * @param SF the sweep flag\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance along the arc\n * @returns a point along the Arc segment\n */\nconst getPointAtArcLength = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n distance?: number,\n) => {\n let point = { x: x1, y: y1 };\n const { center, rx, ry, startAngle, endAngle } = getArcProps(\n x1,\n y1,\n RX,\n RY,\n angle,\n LAF,\n SF,\n x,\n y,\n );\n\n /* istanbul ignore else @preserve */\n if (typeof distance === \"number\") {\n const length = arcLength(rx, ry, endAngle - startAngle);\n if (distance <= 0) {\n point = { x: x1, y: y1 };\n } else if (distance >= length) {\n point = { x, y };\n } else {\n /* istanbul ignore next @preserve */\n if (x1 === x && y1 === y) {\n return { x, y };\n }\n /* istanbul ignore next @preserve */\n if (rx === 0 || ry === 0) {\n return getPointAtLineLength(x1, y1, x, y, distance);\n }\n const { PI, cos, sin } = Math;\n const sweepAngle = endAngle - startAngle;\n const xRot = ((angle % 360) + 360) % 360;\n const xRotRad = xRot * (PI / 180);\n const alpha = startAngle + sweepAngle * (distance / length);\n const ellipseComponentX = rx * cos(alpha);\n const ellipseComponentY = ry * sin(alpha);\n\n point = {\n x: cos(xRotRad) * ellipseComponentX - sin(xRotRad) * ellipseComponentY +\n center.x,\n y: sin(xRotRad) * ellipseComponentX + cos(xRotRad) * ellipseComponentY +\n center.y,\n };\n }\n }\n\n return point;\n};\n\n/**\n * Returns the extrema for an Arc segment in the following format:\n * [MIN_X, MIN_Y, MAX_X, MAX_Y]\n *\n * @see https://github.com/herrstrietzel/svg-pathdata-getbbox\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param RX the radius on X axis\n * @param RY the radius on Y axis\n * @param angle the ellipse rotation in degrees\n * @param LAF the large arc flag\n * @param SF the sweep flag\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the extrema of the Arc segment\n */\nconst getArcBBox = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n) => {\n const { center, rx, ry, startAngle, endAngle } = getArcProps(\n x1,\n y1,\n RX,\n RY,\n angle,\n LAF,\n SF,\n x,\n y,\n );\n const deltaAngle = endAngle - startAngle;\n const { min, max, tan, atan2, PI } = Math;\n\n // circle/elipse center coordinates\n const { x: cx, y: cy } = center;\n\n // rotation to radians\n const alpha = (angle * PI) / 180;\n const tangent = tan(alpha);\n\n /**\n * find min/max from zeroes of directional derivative along x and y\n * along x axis\n */\n const theta = atan2(-ry * tangent, rx);\n const angle1 = theta;\n const angle2 = theta + PI;\n const angle3 = atan2(ry, rx * tangent);\n const angle4 = angle3 + PI;\n const xArray = [x];\n const yArray = [y];\n\n // inner bounding box\n let xMin = min(x1, x);\n let xMax = max(x1, x);\n let yMin = min(y1, y);\n let yMax = max(y1, y);\n\n // on path point close after start\n const angleAfterStart = endAngle - deltaAngle * 0.00001;\n const pP2 = arcPoint(cx, cy, rx, ry, alpha, angleAfterStart);\n\n // on path point close before end\n const angleBeforeEnd = endAngle - deltaAngle * 0.99999;\n const pP3 = arcPoint(cx, cy, rx, ry, alpha, angleBeforeEnd);\n\n /**\n * expected extremes\n * if leaving inner bounding box\n * (between segment start and end point)\n * otherwise exclude elliptic extreme points\n */\n\n // right\n if (pP2[0] > xMax || pP3[0] > xMax) {\n // get point for this theta\n const p1 = arcPoint(cx, cy, rx, ry, alpha, angle1);\n xArray.push(p1[0]);\n yArray.push(p1[1]);\n }\n\n // left\n if (pP2[0] < xMin || pP3[0] < xMin) {\n // get anti-symmetric point\n const p2 = arcPoint(cx, cy, rx, ry, alpha, angle2);\n xArray.push(p2[0]);\n yArray.push(p2[1]);\n }\n\n // top\n if (pP2[1] < yMin || pP3[1] < yMin) {\n // get anti-symmetric point\n const p4 = arcPoint(cx, cy, rx, ry, alpha, angle4);\n xArray.push(p4[0]);\n yArray.push(p4[1]);\n }\n\n // bottom\n if (pP2[1] > yMax || pP3[1] > yMax) {\n // get point for this theta\n const p3 = arcPoint(cx, cy, rx, ry, alpha, angle3);\n xArray.push(p3[0]);\n yArray.push(p3[1]);\n }\n\n xMin = min.apply([], xArray);\n yMin = min.apply([], yArray);\n xMax = max.apply([], xArray);\n yMax = max.apply([], yArray);\n\n return [xMin, yMin, xMax, yMax] as [number, number, number, number];\n};\n\nconst arcTools = {\n angleBetween,\n arcLength,\n arcPoint,\n getArcBBox,\n getArcLength,\n getArcProps,\n getPointAtArcLength,\n};\n\nexport {\n angleBetween,\n arcLength,\n arcPoint,\n arcTools,\n getArcBBox,\n getArcLength,\n getArcProps,\n getPointAtArcLength,\n};\n","import type {\n CubicCoordinates,\n CubicPoints,\n DeriveCallback,\n DerivedCubicPoints,\n DerivedPoint,\n DerivedQuadPoints,\n PointTuple,\n QuadCoordinates,\n QuadPoints,\n} from \"../types\";\n\n/**\n * Tools from bezier.js by Mike 'Pomax' Kamermans\n * @see https://github.com/Pomax/bezierjs\n */\n\nconst Tvalues = [\n -0.0640568928626056260850430826247450385909,\n 0.0640568928626056260850430826247450385909,\n -0.1911188674736163091586398207570696318404,\n 0.1911188674736163091586398207570696318404,\n -0.3150426796961633743867932913198102407864,\n 0.3150426796961633743867932913198102407864,\n -0.4337935076260451384870842319133497124524,\n 0.4337935076260451384870842319133497124524,\n -0.5454214713888395356583756172183723700107,\n 0.5454214713888395356583756172183723700107,\n -0.6480936519369755692524957869107476266696,\n 0.6480936519369755692524957869107476266696,\n -0.7401241915785543642438281030999784255232,\n 0.7401241915785543642438281030999784255232,\n -0.8200019859739029219539498726697452080761,\n 0.8200019859739029219539498726697452080761,\n -0.8864155270044010342131543419821967550873,\n 0.8864155270044010342131543419821967550873,\n -0.9382745520027327585236490017087214496548,\n 0.9382745520027327585236490017087214496548,\n -0.9747285559713094981983919930081690617411,\n 0.9747285559713094981983919930081690617411,\n -0.9951872199970213601799974097007368118745,\n 0.9951872199970213601799974097007368118745,\n];\n\nconst Cvalues = [\n 0.1279381953467521569740561652246953718517,\n 0.1279381953467521569740561652246953718517,\n 0.1258374563468282961213753825111836887264,\n 0.1258374563468282961213753825111836887264,\n 0.121670472927803391204463153476262425607,\n 0.121670472927803391204463153476262425607,\n 0.1155056680537256013533444839067835598622,\n 0.1155056680537256013533444839067835598622,\n 0.1074442701159656347825773424466062227946,\n 0.1074442701159656347825773424466062227946,\n 0.0976186521041138882698806644642471544279,\n 0.0976186521041138882698806644642471544279,\n 0.086190161531953275917185202983742667185,\n 0.086190161531953275917185202983742667185,\n 0.0733464814110803057340336152531165181193,\n 0.0733464814110803057340336152531165181193,\n 0.0592985849154367807463677585001085845412,\n 0.0592985849154367807463677585001085845412,\n 0.0442774388174198061686027482113382288593,\n 0.0442774388174198061686027482113382288593,\n 0.0285313886289336631813078159518782864491,\n 0.0285313886289336631813078159518782864491,\n 0.0123412297999871995468056670700372915759,\n 0.0123412297999871995468056670700372915759,\n];\n\n/**\n * @param points\n * @returns\n */\nconst deriveBezier = (points: QuadPoints | CubicPoints) => {\n const dpoints = [] as (DerivedCubicPoints | DerivedQuadPoints)[];\n for (let p = points, d = p.length, c = d - 1; d > 1; d -= 1, c -= 1) {\n const list = [] as unknown as DerivedCubicPoints | DerivedQuadPoints;\n for (let j = 0; j < c; j += 1) {\n list.push({\n x: c * (p[j + 1].x - p[j].x),\n y: c * (p[j + 1].y - p[j].y),\n t: 0,\n });\n }\n dpoints.push(list);\n p = list;\n }\n return dpoints;\n};\n\n/**\n * @param points\n * @param t\n */\nconst computeBezier = (\n points: DerivedQuadPoints | DerivedCubicPoints,\n t: number,\n) => {\n // shortcuts\n /* istanbul ignore next @preserve */\n if (t === 0) {\n points[0].t = 0;\n return points[0];\n }\n\n const order = points.length - 1;\n\n /* istanbul ignore next @preserve */\n if (t === 1) {\n points[order].t = 1;\n return points[order];\n }\n\n const mt = 1 - t;\n let p = points as typeof points | [\n DerivedPoint,\n DerivedPoint,\n DerivedPoint,\n DerivedPoint,\n ];\n\n // constant?\n /* istanbul ignore next @preserve */\n if (order === 0) {\n points[0].t = t;\n return points[0];\n }\n\n // linear?\n /* istanbul ignore else @preserve */\n if (order === 1) {\n return {\n x: mt * p[0].x + t * p[1].x,\n y: mt * p[0].y + t * p[1].y,\n t,\n };\n }\n\n // quadratic/cubic curve?\n const mt2 = mt * mt;\n const t2 = t * t;\n let a = 0;\n let b = 0;\n let c = 0;\n let d = 0;\n /* istanbul ignore else @preserve */\n if (order === 2) {\n p = [p[0], p[1], p[2], { x: 0, y: 0 } as DerivedPoint];\n a = mt2;\n b = mt * t * 2;\n c = t2;\n } else if (order === 3) {\n a = mt2 * mt;\n b = mt2 * t * 3;\n c = mt * t2 * 3;\n d = t * t2;\n }\n return {\n x: a * p[0].x + b * p[1].x + c * p[2].x + d * p[3].x,\n y: a * p[0].y + b * p[1].y + c * p[2].y + d * p[3].y,\n t,\n };\n};\n\nconst calculateBezier = (derivativeFn: DeriveCallback, t: number) => {\n const d = derivativeFn(t);\n const l = d.x * d.x + d.y * d.y;\n\n return Math.sqrt(l);\n};\n\nconst bezierLength = (derivativeFn: DeriveCallback) => {\n const z = 0.5;\n const len = Tvalues.length;\n\n let sum = 0;\n\n for (let i = 0, t; i < len; i++) {\n t = z * Tvalues[i] + z;\n sum += Cvalues[i] * calculateBezier(derivativeFn, t);\n }\n return z * sum;\n};\n\n/**\n * Returns the length of CubicBezier / Quad segment.\n * @param curve cubic / quad bezier segment\n */\nconst getBezierLength = (curve: CubicCoordinates | QuadCoordinates) => {\n const points = [] as unknown as CubicPoints | QuadPoints;\n for (let idx = 0, len = curve.length, step = 2; idx < len; idx += step) {\n points.push({\n x: curve[idx],\n y: curve[idx + 1],\n });\n }\n const dpoints = deriveBezier(points);\n return bezierLength((t: number) => {\n return computeBezier(dpoints[0], t);\n });\n};\n\n// Precision for consider cubic polynom as quadratic one\nconst CBEZIER_MINMAX_EPSILON = 0.00000001;\n\n/**\n * Returns the most extreme points in a Quad Bezier segment.\n * @param A an array which consist of X/Y values\n */\n// https://github.com/kpym/SVGPathy/blob/acd1a50c626b36d81969f6e98e8602e128ba4302/lib/box.js#L89\nconst minmaxQ = ([v1, cp, v2]: [number, number, number]) => {\n const min = Math.min(v1, v2);\n const max = Math.max(v1, v2);\n\n /* istanbul ignore next @preserve */\n if (cp >= v1 ? v2 >= cp : v2 <= cp) {\n // if no extremum in ]0,1[\n return [min, max] as PointTuple;\n }\n\n // check if the extremum E is min or max\n const E = (v1 * v2 - cp * cp) / (v1 - 2 * cp + v2);\n return (E < min ? [E, max] : [min, E]) as PointTuple;\n};\n\n/**\n * Returns the most extreme points in a Cubic Bezier segment.\n * @param A an array which consist of X/Y values\n * @see https://github.com/kpym/SVGPathy/blob/acd1a50c626b36d81969f6e98e8602e128ba4302/lib/box.js#L127\n */\nconst minmaxC = ([v1, cp1, cp2, v2]: [number, number, number, number]) => {\n const K = v1 - 3 * cp1 + 3 * cp2 - v2;\n\n // if the polynomial is (almost) quadratic and not cubic\n /* istanbul ignore next @preserve */\n if (Math.abs(K) < CBEZIER_MINMAX_EPSILON) {\n if (v1 === v2 && v1 === cp1) {\n // no curve, point targeting same location\n return [v1, v2] as PointTuple;\n }\n\n return minmaxQ([v1, -0.5 * v1 + 1.5 * cp1, v1 - 3 * cp1 + 3 * cp2]);\n }\n\n // the reduced discriminant of the derivative\n const T = -v1 * cp2 + v1 * v2 - cp1 * cp2 - cp1 * v2 + cp1 * cp1 + cp2 * cp2;\n\n // if the polynomial is monotone in [0,1]\n if (T <= 0) {\n return [Math.min(v1, v2), Math.max(v1, v2)] as PointTuple;\n }\n const S = Math.sqrt(T);\n\n // potential extrema\n let min = Math.min(v1, v2);\n let max = Math.max(v1, v2);\n\n const L = v1 - 2 * cp1 + cp2;\n // check local extrema\n for (let R = (L + S) / K, i = 1; i <= 2; R = (L - S) / K, i++) {\n // istanbul ignore next @preserve\n if (R > 0 && R < 1) {\n // if the extrema is for R in [0,1]\n const Q = v1 * (1 - R) * (1 - R) * (1 - R) +\n cp1 * 3 * (1 - R) * (1 - R) * R + cp2 * 3 * (1 - R) * R * R +\n v2 * R * R * R;\n if (Q < min) {\n min = Q;\n }\n if (Q > max) {\n max = Q;\n }\n }\n }\n\n return [min, max] as PointTuple;\n};\nconst bezierTools = {\n bezierLength,\n calculateBezier,\n CBEZIER_MINMAX_EPSILON,\n computeBezier,\n Cvalues,\n deriveBezier,\n getBezierLength,\n minmaxC,\n minmaxQ,\n Tvalues,\n};\n\nexport {\n bezierLength,\n bezierTools,\n calculateBezier,\n CBEZIER_MINMAX_EPSILON,\n computeBezier,\n Cvalues,\n deriveBezier,\n getBezierLength,\n minmaxC,\n minmaxQ,\n Tvalues,\n};\n","import { getBezierLength, minmaxC } from \"./bezier\";\nimport { BBoxMaxima, type CubicCoordinates } from \"../types\";\n\n/**\n * Returns a point at a given length of a CubicBezier segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param t a [0-1] ratio\n * @returns the point at cubic-bezier segment length\n */\nconst getPointAtCubicSegmentLength = (\n [x1, y1, c1x, c1y, c2x, c2y, x2, y2]: CubicCoordinates,\n t: number,\n) => {\n const t1 = 1 - t;\n return {\n x: t1 ** 3 * x1 + 3 * t1 ** 2 * t * c1x + 3 * t1 * t ** 2 * c2x +\n t ** 3 * x2,\n y: t1 ** 3 * y1 + 3 * t1 ** 2 * t * c1y + 3 * t1 * t ** 2 * c2y +\n t ** 3 * y2,\n };\n};\n\n/**\n * Returns the length of a CubicBezier segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the CubicBezier segment length\n */\nconst getCubicLength = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n) => {\n return getBezierLength([x1, y1, c1x, c1y, c2x, c2y, x2, y2]);\n};\n\n/**\n * Returns the point along a CubicBezier segment at a given distance.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to look at\n * @returns the point at CubicBezier length\n */\nconst getPointAtCubicLength = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n distance?: number,\n) => {\n const distanceIsNumber = typeof distance === \"number\";\n let point = { x: x1, y: y1 };\n /* istanbul ignore else @preserve */\n if (distanceIsNumber) {\n const currentLength = getBezierLength([x1, y1, c1x, c1y, c2x, c2y, x2, y2]);\n if (distance <= 0) {\n // first point already defined\n } else if (distance >= currentLength) {\n point = { x: x2, y: y2 };\n } else {\n point = getPointAtCubicSegmentLength(\n [x1, y1, c1x, c1y, c2x, c2y, x2, y2],\n distance / currentLength,\n );\n }\n }\n return point;\n};\n\n/**\n * Returns the bounding box of a CubicBezier segment in the following format:\n * [MIN_X, MIN_Y, MAX_X, MAX_Y]\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the extrema of the CubicBezier segment\n */\nconst getCubicBBox = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n): BBoxMaxima => {\n const cxMinMax = minmaxC([x1, c1x, c2x, x2]);\n const cyMinMax = minmaxC([y1, c1y, c2y, y2]);\n\n return [cxMinMax[0], cyMinMax[0], cxMinMax[1], cyMinMax[1]];\n};\n\nconst cubicTools = {\n getCubicBBox,\n getCubicLength,\n getPointAtCubicLength,\n getPointAtCubicSegmentLength,\n};\n\nexport {\n cubicTools,\n getCubicBBox,\n getCubicLength,\n getPointAtCubicLength,\n getPointAtCubicSegmentLength,\n};\n","import { getBezierLength, minmaxQ } from \"./bezier\";\nimport { type QuadCoordinates } from \"../types\";\n\n/**\n * Returns the {x,y} coordinates of a point at a\n * given length of a quadratic-bezier segment.\n *\n * @see https://github.com/substack/point-at-length\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param t a [0-1] ratio\n * @returns the requested {x,y} coordinates\n */\nconst getPointAtQuadSegmentLength = (\n [x1, y1, cx, cy, x2, y2]: QuadCoordinates,\n t: number,\n) => {\n const t1 = 1 - t;\n return {\n x: t1 ** 2 * x1 + 2 * t1 * t * cx + t ** 2 * x2,\n y: t1 ** 2 * y1 + 2 * t1 * t * cy + t ** 2 * y2,\n };\n};\n\n/**\n * Returns the length of a QuadraticBezier segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the QuadraticBezier segment length\n */\nconst getQuadLength = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n) => {\n return getBezierLength([x1, y1, cx, cy, x2, y2]);\n};\n\n/**\n * Returns the point along a QuadraticBezier segment at a given distance.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to look at\n * @returns the point at QuadraticBezier length\n */\nconst getPointAtQuadLength = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n distance?: number,\n) => {\n const distanceIsNumber = typeof distance === \"number\";\n let point = { x: x1, y: y1 };\n\n /* istanbul ignore else @preserve */\n if (distanceIsNumber) {\n const currentLength = getBezierLength([x1, y1, cx, cy, x2, y2]);\n if (distance <= 0) {\n // first point already defined\n } else if (distance >= currentLength) {\n point = { x: x2, y: y2 };\n } else {\n point = getPointAtQuadSegmentLength(\n [x1, y1, cx, cy, x2, y2],\n distance / currentLength,\n );\n }\n }\n return point;\n};\n\n/**\n * Returns the bounding box of a QuadraticBezier segment in the following format:\n * [MIN_X, MIN_Y, MAX_X, MAX_Y]\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the extrema of the QuadraticBezier segment\n */\nconst getQuadBBox = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n) => {\n const cxMinMax = minmaxQ([x1, cx, x2]);\n const cyMinMax = minmaxQ([y1, cy, y2]);\n return [cxMinMax[0], cyMinMax[0], cxMinMax[1], cyMinMax[1]] as [\n number,\n number,\n number,\n number,\n ];\n};\nconst quadTools = {\n getPointAtQuadLength,\n getPointAtQuadSegmentLength,\n getQuadBBox,\n getQuadLength,\n};\n\nexport {\n getPointAtQuadLength,\n getPointAtQuadSegmentLength,\n getQuadBBox,\n getQuadLength,\n quadTools,\n};\n","import { distanceSquareRoot } from \"./distanceSquareRoot\";\nimport { type PointTuple } from \"../types\";\n\n/**\n * d3-polygon-area\n * @see https://github.com/d3/d3-polygon\n *\n * Returns the area of a polygon.\n *\n * @param polygon Array of [x, y]\n * @returns Signed area\n */\nconst polygonArea = (polygon: PointTuple[]) => {\n const n = polygon.length;\n let i = -1;\n let a: PointTuple;\n let b = polygon[n - 1];\n let area = 0;\n\n while (++i < n) {\n a = b;\n b = polygon[i];\n area += a[1] * b[0] - a[0] * b[1];\n }\n\n return area / 2;\n};\n\n/**\n * d3-polygon-length\n * https://github.com/d3/d3-polygon\n *\n * Returns the perimeter of a polygon.\n *\n * @param polygon an array of coordinates\n * @returns the polygon length\n */\nconst polygonLength = (polygon: PointTuple[]) => {\n return polygon.reduce((length, point, i) => {\n if (i) {\n return length + distanceSquareRoot(polygon[i - 1], point);\n }\n return 0;\n }, 0);\n};\n\n/**\n * Computes the centroid (geometric center) of a polygon.\n * Uses average of all endpoint coordinates (robust for polygons and curves).\n *\n * @param polygon A polygon with consists of [x, y] tuples\n * @returns [x, y] centroid\n */\nconst polygonCentroid = (polygon: PointTuple[]): PointTuple => {\n if (polygon.length === 0) return [0, 0];\n\n let sumX = 0;\n let sumY = 0;\n\n for (const [x, y] of polygon) {\n sumX += x;\n sumY += y;\n }\n\n const count = polygon.length;\n return [sumX / count, sumY / count];\n};\n\nconst polygonTools = {\n polygonArea,\n polygonLength,\n polygonCentroid,\n};\n\nexport { polygonArea, polygonCentroid, polygonLength, polygonTools };\n","/**\n * Returns an {x,y} vector rotated by a given\n * angle in radian.\n *\n * @param x the initial vector x\n * @param y the initial vector y\n * @param rad the radian vector angle\n * @returns the rotated vector\n */\nexport const rotateVector = (\n x: number,\n y: number,\n rad: number,\n): { x: number; y: number } => {\n const { sin, cos } = Math;\n const X = x * cos(rad) - y * sin(rad);\n const Y = x * sin(rad) + y * cos(rad);\n return { x: X, y: Y };\n};\n","/**\n * Rounds a number to the specified number of decimal places.\n *\n * @param n - The number to round\n * @param round - Number of decimal places\n * @returns The rounded number\n */\nexport const roundTo = (n: number, round: number) => {\n const pow = round >= 1 ? 10 ** round : 1;\n\n return round > 0 ? Math.round(n * pow) / pow : Math.round(n);\n};\n","import { Options } from \"../interface\";\n\n/** SVGPathCommander default options */\nexport const defaultOptions: Options = {\n origin: [0, 0, 0],\n round: 4,\n};\n","/** Segment params length */\n\nexport const paramsCounts = {\n a: 7,\n c: 6,\n h: 1,\n l: 2,\n m: 2,\n r: 4,\n q: 4,\n s: 4,\n t: 2,\n v: 1,\n z: 0,\n};\n","import { paramsCounts } from \"./paramsCount\";\nimport { PathParser } from \"./pathParser\";\nimport type { PathCommand, PathSegment, RelativeCommand } from \"../types\";\n\n/**\n * Breaks the parsing of a pathString once a segment is finalized.\n *\n * @param path - The PathParser instance\n */\nexport const finalizeSegment = (path: PathParser) => {\n let pathCommand = path.pathValue[path.segmentStart] as PathCommand;\n let relativeCommand = pathCommand.toLowerCase() as RelativeCommand;\n const { data } = path;\n\n while (data.length >= paramsCounts[relativeCommand]) {\n // overloaded `moveTo`\n // https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts\n if (relativeCommand === \"m\" && data.length > 2) {\n path.segments.push(\n [pathCommand as PathCommand | number].concat(\n data.splice(0, 2) as number[],\n ) as PathSegment,\n );\n relativeCommand = \"l\";\n pathCommand = pathCommand === \"m\" ? \"l\" : \"L\";\n } else {\n path.segments.push(\n [pathCommand as PathCommand | number].concat(\n data.splice(0, paramsCounts[relativeCommand]) as number[],\n ) as PathSegment,\n );\n }\n\n if (!paramsCounts[relativeCommand]) {\n break;\n }\n }\n};\n","/** Error prefix used in all SVGPathCommander TypeError messages. */\nexport const error = \"SVGPathCommanderError\";\n","import { error } from \"../util/error\";\nimport type { PathParser } from \"./pathParser\";\n\n/**\n * Validates an A (arc-to) specific path command value.\n * Usually a `large-arc-flag` or `sweep-flag`.\n *\n * @param path - The PathParser instance\n */\nexport const scanFlag = (path: PathParser) => {\n const { index, pathValue } = path;\n const code = pathValue.charCodeAt(index);\n\n if (code === 0x30 /* 0 */) {\n path.param = 0;\n path.index += 1;\n return;\n }\n\n if (code === 0x31 /* 1 */) {\n path.param = 1;\n path.index += 1;\n return;\n }\n\n path.err = `${error}: invalid Arc flag \"${\n pathValue[index]\n }\", expecting 0 or 1 at index ${index}`;\n};\n","import { DigitNumber } from \"../types\";\n\n/**\n * Checks if a character is a digit.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isDigit = (code: number): code is DigitNumber => {\n return code >= 48 && code <= 57; // 0..9\n};\n","/** Error message prefix used when a path string cannot be parsed. */\nexport const invalidPathValue = \"Invalid path value\";\n","import { isDigit } from \"./isDigit\";\nimport { invalidPathValue } from \"./invalidPathValue\";\nimport { error } from \"../util/error\";\nimport type { PathParser } from \"./pathParser\";\n\n/**\n * Validates every character of the path string,\n * every path command, negative numbers or floating point numbers.\n *\n * @param path - The PathParser instance\n */\nexport const scanParam = (path: PathParser) => {\n const { max, pathValue, index: start } = path;\n let index = start;\n let zeroFirst = false;\n let hasCeiling = false;\n let hasDecimal = false;\n let hasDot = false;\n let ch;\n\n if (index >= max) {\n path.err =\n `${error}: ${invalidPathValue} at index ${index}, \"pathValue\" is missing param`;\n return;\n }\n ch = pathValue.charCodeAt(index);\n\n if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {\n index += 1;\n // ch = (index < max) ? pathValue.charCodeAt(index) : 0;\n ch = pathValue.charCodeAt(index);\n }\n\n // This logic is shamelessly borrowed from Esprima\n // https://github.com/ariya/esprimas\n if (!isDigit(ch) && ch !== 0x2e /* . */) {\n // path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${\n pathValue[index]\n }\" is not a number`;\n return;\n }\n\n if (ch !== 0x2e /* . */) {\n zeroFirst = ch === 0x30 /* 0 */;\n index += 1;\n\n ch = pathValue.charCodeAt(index);\n\n if (zeroFirst && index < max) {\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDigit(ch)) {\n // path.err = 'SvgPath: numbers started with `0` such as `09`\n // are illegal (at pos ' + start + ')';\n path.err = `${error}: ${invalidPathValue} at index ${start}, \"${\n pathValue[start]\n }\" illegal number`;\n return;\n }\n }\n\n while (index < max && isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n hasCeiling = true;\n }\n\n ch = pathValue.charCodeAt(index);\n }\n\n if (ch === 0x2e /* . */) {\n hasDot = true;\n index += 1;\n while (isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n hasDecimal = true;\n }\n\n ch = pathValue.charCodeAt(index);\n }\n\n if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {\n if (hasDot && !hasCeiling && !hasDecimal) {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${\n pathValue[index]\n }\" invalid float exponent`;\n return;\n }\n\n index += 1;\n\n ch = pathValue.charCodeAt(index);\n\n if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {\n index += 1;\n }\n if (index < max && isDigit(pathValue.charCodeAt(index))) {\n while (index < max && isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n }\n } else {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${\n pathValue[index]\n }\" invalid integer exponent`;\n return;\n }\n }\n\n path.index = index;\n path.param = +path.pathValue.slice(start, index);\n};\n","import type { SpaceNumber } from \"../types\";\n\n/**\n * Checks if the character is a space.\n *\n * @param ch the character to check\n * @returns check result\n */\n\nexport const isSpace = (ch: number): ch is SpaceNumber => {\n const allSpaces = [\n // Special spaces\n 0x1680,\n 0x180e,\n 0x2000,\n 0x2001,\n 0x2002,\n 0x2003,\n 0x2004,\n 0x2005,\n 0x2006,\n 0x2007,\n 0x2008,\n 0x2009,\n 0x200a,\n 0x202f,\n 0x205f,\n 0x3000,\n 0xfeff,\n // Line terminators\n 0x0a,\n 0x0d,\n 0x2028,\n 0x2029,\n // White spaces\n 0x20,\n 0x09,\n 0x0b,\n 0x0c,\n 0xa0,\n ];\n\n return allSpaces.includes(ch);\n};\n","import { isSpace } from \"./isSpace\";\nimport type { PathParser } from \"./pathParser\";\n\n/**\n * Points the parser to the next character in the\n * path string every time it encounters any kind of\n * space character.\n *\n * @param path - The PathParser instance\n */\nexport const skipSpaces = (path: PathParser) => {\n const { pathValue, max } = path;\n while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {\n path.index += 1;\n }\n};\n","import type { PathCommandNumber } from \"../types\";\n\n/**\n * Checks if the character is a path command.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isPathCommand = (code: number): code is PathCommandNumber => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n switch (code | 0x20) {\n case 0x6d /* m */:\n case 0x7a /* z */:\n case 0x6c /* l */:\n case 0x68 /* h */:\n case 0x76 /* v */:\n case 0x63 /* c */:\n case 0x73 /* s */:\n case 0x71 /* q */:\n case 0x74 /* t */:\n case 0x61 /* a */:\n // case 0x72/* r */:\n return true;\n default:\n return false;\n }\n};\n","import { isDigit } from \"./isDigit\";\nimport type { DigitNumber } from \"../types\";\n\n/**\n * Checks if the character is or belongs to a number.\n * [0-9]|+|-|.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isDigitStart = (\n code: number,\n): code is DigitNumber | 0x2b | 0x2d | 0x2e => {\n return isDigit(code) /* 0..9 */ || code === 0x2b /* + */ ||\n code === 0x2d /* - */ || code === 0x2e; /* . */\n};\n","/**\n * Checks if the character is an A (arc-to) path command.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isArcCommand = (code: number): code is 0x61 => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n return (code | 0x20) === 0x61;\n};\n","/**\n * Checks if the character is a MoveTo command.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isMoveCommand = (code: number): code is 0x6d | 0x4d => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n switch (code | 0x20) {\n case 0x6d /* m */:\n case 0x4d /* M */:\n return true;\n default:\n return false;\n }\n};\n","import { finalizeSegment } from \"./finalizeSegment\";\nimport { paramsCounts } from \"./paramsCount\";\nimport { scanFlag } from \"./scanFlag\";\nimport { scanParam } from \"./scanParam\";\nimport { skipSpaces } from \"./skipSpaces\";\nimport { isPathCommand } from \"./isPathCommand\";\nimport { isDigitStart } from \"./isDigitStart\";\nimport { isArcCommand } from \"./isArcCommand\";\nimport { isMoveCommand } from \"./isMoveCommand\";\nimport { invalidPathValue } from \"./invalidPathValue\";\nimport { error } from \"../util/error\";\n\nimport { type PathParser } from \"./pathParser\";\nimport type { PathSegment, RelativeCommand } from \"../types\";\n\n/**\n * Scans every character in the path string to determine\n * where a segment starts and where it ends.\n *\n * @param path - The PathParser instance\n */\nexport const scanSegment = (path: PathParser) => {\n const { max, pathValue, index, segments } = path;\n const cmdCode = pathValue.charCodeAt(index);\n const reqParams =\n paramsCounts[pathValue[index].toLowerCase() as RelativeCommand];\n\n path.segmentStart = index;\n\n // segments always start with a path command\n if (!isPathCommand(cmdCode)) {\n path.err = `${error}: ${invalidPathValue} \"${\n pathValue[index]\n }\" is not a path command at index ${index}`;\n return;\n }\n\n // after a Z segment, we only expect a MoveTo path command\n const lastSegment = segments[segments.length - 1] as PathSegment | undefined;\n if (\n !isMoveCommand(cmdCode) &&\n lastSegment?.[0]?.toLocaleLowerCase() === \"z\"\n ) {\n path.err = `${error}: ${invalidPathValue} \"${\n pathValue[index]\n }\" is not a MoveTo path command at index ${index}`;\n return;\n }\n\n path.index += 1;\n skipSpaces(path);\n\n path.data = [];\n\n if (!reqParams) {\n // Z\n finalizeSegment(path);\n return;\n }\n\n for (;;) {\n for (let i = reqParams; i > 0; i -= 1) {\n if (isArcCommand(cmdCode) && (i === 3 || i === 4)) scanFlag(path);\n else scanParam(path);\n\n if (path.err.length) {\n return;\n }\n path.data.push(path.param);\n\n skipSpaces(path);\n\n // after ',' param is mandatory\n if (\n path.index < max &&\n pathValue.charCodeAt(path.index) === 0x2c /* , */\n ) {\n path.index += 1;\n skipSpaces(path);\n }\n }\n\n if (path.index >= path.max) {\n break;\n }\n\n // Stop on next segment\n if (!isDigitStart(pathValue.charCodeAt(path.index))) {\n break;\n }\n }\n\n finalizeSegment(path);\n};\n","import type { PathArray, PathSegment } from \"../types\";\n\n/**\n * The `PathParser` is used by the `parsePathString` static method\n * to generate a `pathArray`.\n *\n * @param pathString - The SVG path string to parse\n */\nexport class PathParser {\n declare segments: PathArray | PathSegment[];\n declare pathValue: string;\n declare max: number;\n declare index: number;\n declare param: number;\n declare segmentStart: number;\n declare data: (string | number)[];\n declare err: string;\n\n constructor(pathString: string) {\n this.segments = [];\n this.pathValue = pathString;\n this.max = pathString.length;\n this.index = 0;\n this.param = 0.0;\n this.segmentStart = 0;\n this.data = [];\n this.err = \"\";\n }\n}\n","import { scanSegment } from \"./scanSegment\";\nimport { skipSpaces } from \"./skipSpaces\";\nimport { PathParser } from \"./pathParser\";\nimport type { PathArray } from \"../types\";\n\n/**\n * Parses a path string value and returns an array\n * of segments we like to call `PathArray`.\n *\n * If parameter value is already a `PathArray`,\n * return a clone of it.\n\n * @example\n * parsePathString(\"M 0 0L50 50\")\n * // => [[\"M\",0,0],[\"L\",50,50]]\n *\n * @param pathInput the string to be parsed\n * @returns the resulted `pathArray` or error string\n */\nexport const parsePathString = <T extends PathArray>(pathInput: string | T) => {\n if (typeof pathInput !== \"string\") {\n return pathInput.slice(0) as T;\n }\n\n const path = new PathParser(pathInput);\n\n skipSpaces(path);\n\n while (path.index < path.max && !path.err.length) {\n scanSegment(path);\n }\n\n // handle valid paths first\n // handle errors second\n if (!path.err.length) {\n if (path.segments.length) {\n /**\n * force absolute first M\n * getPathBBox calculation requires first segment to be absolute\n * @see https://github.com/thednp/svg-path-commander/pull/49\n */\n path.segments[0][0] = \"M\";\n }\n } else {\n throw TypeError(path.err);\n }\n\n return path.segments as PathArray;\n};\n","import type {\n AbsoluteCommand,\n AbsoluteSegment,\n ASegment,\n CSegment,\n HSegment,\n LSegment,\n MSegment,\n PathSegment,\n QSegment,\n SSegment,\n TSegment,\n VSegment,\n} from \"../types\";\n\n/**\n * Returns an absolute segment of a `PathArray` object.\n *\n * @param segment the segment object\n * @param index the segment index\n * @param lastX the last known X value\n * @param lastY the last known Y value\n * @returns the absolute segment\n */\nexport const absolutizeSegment = (\n segment: PathSegment,\n index: number,\n lastX: number,\n lastY: number,\n) => {\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase() as AbsoluteCommand;\n const isAbsolute = absCommand === pathCommand;\n\n /* istanbul ignore else @preserve */\n if (index === 0 || isAbsolute) return segment as MSegment | AbsoluteSegment;\n // const values = segment.slice(1) as number[];\n if (absCommand === \"A\") {\n return [\n absCommand,\n segment[1],\n segment[2],\n segment[3],\n segment[4],\n segment[5],\n (segment as ASegment)[6] + lastX,\n (segment as ASegment)[7] + lastY,\n ] as ASegment;\n } else if (absCommand === \"V\") {\n return [absCommand, (segment as VSegment)[1] + lastY] as VSegment;\n } else if (absCommand === \"H\") {\n return [absCommand, (segment as HSegment)[1] + lastX] as HSegment;\n } else if (absCommand === \"L\") {\n return [\n absCommand,\n (segment as LSegment)[1] + lastX,\n (segment as LSegment)[2] + lastY,\n ] as LSegment;\n } else {\n // use brakets for `eslint: no-case-declaration`\n // https://stackoverflow.com/a/50753272/803358\n const absValues = [] as number[];\n const seglen = segment.length;\n for (let j = 1; j < seglen; j += 1) {\n absValues.push((segment[j] as number) + (j % 2 ? lastX : lastY));\n }\n // for c, s, q, t\n return [absCommand as typeof absCommand | number].concat(absValues) as\n | MSegment\n | QSegment\n | TSegment\n | SSegment\n | CSegment;\n }\n};\n","// import paramsParser from '../parser/paramsParser';\nimport type { AbsoluteCommand, IteratorCallback, PathArray } from \"../types\";\n\n/**\n * Iterates over a `PathArray`, executing a callback for each segment.\n * The callback can:\n * - Read current position (`x`, `y`)\n * - Modify the segment (return new segment)\n * - Stop early (return `false`)\n *\n * The iterator maintains accurate current point (`x`, `y`) and subpath start (`mx`, `my`)\n * while correctly handling relative/absolute commands, including H/V and Z.\n *\n * **Important**: If the callback returns a new segment with more coordinates (e.g., Q → C),\n * the path length may increase, and iteration will continue over new segments.\n *\n * @template T - Specific PathArray type (e.g., CurveArray, PolylineArray)\n * @param path - The source `PathArray` to iterate over\n * @param iterator - Callback function for each segment\n * @param iterator.segment - Current path segment\n * @param iterator.index - Index of current segment\n * @param iterator.x - Current X position (after applying relative offset)\n * @param iterator.y - Current Y position (after applying relative offset)\n * @returns The modified `path` (or original if no changes)\n *\n * @example\n * iterate(path, (seg, i, x, y) => {\n * if (seg[0] === 'L') return ['C', x, y, seg[1], seg[2], seg[1], seg[2]];\n * });\n */\nexport const iterate = <T extends PathArray>(\n path: T,\n iterator: IteratorCallback<T>,\n) => {\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n let i = 0;\n while (i < path.length) {\n const segment = path[i];\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase() as AbsoluteCommand;\n const isRelative = absCommand !== pathCommand;\n\n const iteratorResult = iterator(segment, i, x, y);\n // some methods like getPointAtLength would like to break\n // when task is complete\n if (iteratorResult === false) {\n break;\n }\n\n // segment = path[i];\n if (absCommand === \"Z\") {\n x = mx;\n y = my;\n } else if (absCommand === \"H\") {\n x = (segment[1] as number) + (isRelative ? x : 0);\n } else if (absCommand === \"V\") {\n y = (segment[1] as number) + (isRelative ? y : 0);\n } else {\n const segLen = segment.length;\n\n x = (segment[segLen - 2] as number) + (isRelative ? x : 0);\n y = (segment[segLen - 1] as number) + (isRelative ? y : 0);\n\n if (absCommand === \"M\") {\n mx = x;\n my = y;\n }\n }\n\n if (iteratorResult) {\n path[i] = iteratorResult;\n }\n\n i += 1;\n }\n return path as T;\n};\n","import type { AbsoluteArray, PathArray } from \"../types\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { absolutizeSegment } from \"../process/absolutizeSegment\";\nimport { iterate } from \"../process/iterate\";\n\n/**\n * Parses a path string value or object and returns an array\n * of segments, all converted to absolute values.\n *\n * @param pathInput - The path string or PathArray\n * @returns The resulted PathArray with absolute values\n *\n * @example\n * ```ts\n * pathToAbsolute('M10 10l80 80')\n * // => [['M', 10, 10], ['L', 90, 90]]\n * ```\n */\nexport const pathToAbsolute = <T extends PathArray>(pathInput: string | T) => {\n const path = parsePathString(pathInput);\n\n return iterate(path, absolutizeSegment) as AbsoluteArray;\n};\n","import type {\n aSegment,\n cSegment,\n hSegment,\n lSegment,\n MSegment,\n PathSegment,\n qSegment,\n RelativeCommand,\n RelativeSegment,\n sSegment,\n tSegment,\n vSegment,\n} from \"../types\";\n\n/**\n * Returns a relative segment of a `PathArray` object.\n *\n * @param segment the segment object\n * @param index the segment index\n * @param lastX the last known X value\n * @param lastY the last known Y value\n * @returns the relative segment\n */\nexport const relativizeSegment = (\n segment: PathSegment,\n index: number,\n lastX: number,\n lastY: number,\n) => {\n const [pathCommand] = segment;\n const relCommand = pathCommand.toLowerCase() as RelativeCommand;\n const isRelative = pathCommand === relCommand;\n\n /* istanbul ignore else @preserve */\n if (index === 0 || isRelative) return segment as MSegment | RelativeSegment;\n\n if (relCommand === \"a\") {\n return [\n relCommand,\n segment[1],\n segment[2],\n segment[3],\n segment[4],\n segment[5],\n (segment as aSegment)[6] - lastX,\n (segment as aSegment)[7] - lastY,\n ] as aSegment;\n } else if (relCommand === \"v\") {\n return [relCommand, (segment as vSegment)[1] - lastY] as vSegment;\n } else if (relCommand === \"h\") {\n return [relCommand, (segment as hSegment)[1] - lastX] as hSegment;\n } else if (relCommand === \"l\") {\n return [\n relCommand,\n (segment as lSegment)[1] - lastX,\n (segment as lSegment)[2] - lastY,\n ] as lSegment;\n } else {\n // use brakets for `eslint: no-case-declaration`\n // https://stackoverflow.com/a/50753272/803358\n const relValues = [] as number[];\n const seglen = segment.length;\n for (let j = 1; j < seglen; j += 1) {\n relValues.push((segment[j] as number) - (j % 2 ? lastX : lastY));\n }\n // for c, s, q, t\n return [relCommand as RelativeCommand | number].concat(relValues) as\n | qSegment\n | tSegment\n | sSegment\n | cSegment;\n }\n};\n","import type { PathArray, RelativeArray } from \"../types\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { iterate } from \"../process/iterate\";\nimport { relativizeSegment } from \"../process/relativizeSegment\";\n\n/**\n * Parses a path string value or object and returns an array\n * of segments, all converted to relative values.\n *\n * @param pathInput - The path string or PathArray\n * @returns The resulted PathArray with relative values\n *\n * @example\n * ```ts\n * pathToRelative('M10 10L90 90')\n * // => [['M', 10, 10], ['l', 80, 80]]\n * ```\n */\nexport const pathToRelative = <T extends PathArray>(\n pathInput: string | T,\n): RelativeArray => {\n const path = parsePathString(pathInput);\n\n return iterate(path, relativizeSegment) as RelativeArray;\n};\n","import { rotateVector } from \"../math/rotateVector\";\n\n/**\n * Converts A (arc-to) segments to C (cubic-bezier-to).\n *\n * For more information of where this math came from visit:\n * http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n *\n * @param X1 the starting x position\n * @param Y1 the starting y position\n * @param RX x-radius of the arc\n * @param RY y-radius of the arc\n * @param angle x-axis-rotation of the arc\n * @param LAF large-arc-flag of the arc\n * @param SF sweep-flag of the arc\n * @param X2 the ending x position\n * @param Y2 the ending y position\n * @param recursive the parameters needed to split arc into 2 segments\n * @returns the resulting cubic-bezier segment(s)\n */\nexport const arcToCubic = (\n X1: number,\n Y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n X2: number,\n Y2: number,\n recursive?: [number, number, number, number],\n): number[] => {\n let x1 = X1;\n let y1 = Y1;\n let rx = RX;\n let ry = RY;\n let x2 = X2;\n let y2 = Y2;\n // for more information of where this Math came from visit:\n // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n const d120 = (Math.PI * 120) / 180;\n\n const rad = (Math.PI / 180) * (+angle || 0);\n let res = [] as number[];\n let xy;\n let f1;\n let f2;\n let cx;\n let cy;\n\n if (!recursive) {\n xy = rotateVector(x1, y1, -rad);\n x1 = xy.x;\n y1 = xy.y;\n xy = rotateVector(x2, y2, -rad);\n x2 = xy.x;\n y2 = xy.y;\n\n const x = (x1 - x2) / 2;\n const y = (y1 - y2) / 2;\n let h = (x * x) / (rx * rx) + (y * y) / (ry * ry);\n if (h > 1) {\n h = Math.sqrt(h);\n rx *= h;\n ry *= h;\n }\n const rx2 = rx * rx;\n const ry2 = ry * ry;\n\n const k = (LAF === SF ? -1 : 1) *\n Math.sqrt(\n Math.abs(\n (rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x),\n ),\n );\n\n cx = (k * rx * y) / ry + (x1 + x2) / 2;\n cy = (k * -ry * x) / rx + (y1 + y2) / 2;\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise\n f1 = Math.asin(((((y1 - cy) / ry) * 10 ** 9) >> 0) / 10 ** 9);\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise\n f2 = Math.asin(((((y2 - cy) / ry) * 10 ** 9) >> 0) / 10 ** 9);\n\n f1 = x1 < cx ? Math.PI - f1 : f1;\n f2 = x2 < cx ? Math.PI - f2 : f2;\n if (f1 < 0) f1 = Math.PI * 2 + f1;\n if (f2 < 0) f2 = Math.PI * 2 + f2;\n if (SF && f1 > f2) {\n f1 -= Math.PI * 2;\n }\n if (!SF && f2 > f1) {\n f2 -= Math.PI * 2;\n }\n } else {\n [f1, f2, cx, cy] = recursive;\n }\n let df = f2 - f1;\n if (Math.abs(df) > d120) {\n const f2old = f2;\n const x2old = x2;\n const y2old = y2;\n f2 = f1 + d120 * (SF && f2 > f1 ? 1 : -1);\n x2 = cx + rx * Math.cos(f2);\n y2 = cy + ry * Math.sin(f2);\n res = arcToCubic(x2, y2, rx, ry, angle, 0, SF, x2old, y2old, [\n f2,\n f2old,\n cx,\n cy,\n ]);\n }\n df = f2 - f1;\n const c1 = Math.cos(f1);\n const s1 = Math.sin(f1);\n const c2 = Math.cos(f2);\n const s2 = Math.sin(f2);\n const t = Math.tan(df / 4);\n const hx = (4 / 3) * rx * t;\n const hy = (4 / 3) * ry * t;\n const m1 = [x1, y1];\n const m2 = [x1 + hx * s1, y1 - hy * c1];\n const m3 = [x2 + hx * s2, y2 - hy * c2];\n const m4 = [x2, y2];\n m2[0] = 2 * m1[0] - m2[0];\n m2[1] = 2 * m1[1] - m2[1];\n if (recursive) {\n return [m2[0], m2[1], m3[0], m3[1], m4[0], m4[1]].concat(res);\n }\n res = [m2[0], m2[1], m3[0], m3[1], m4[0], m4[1]].concat(res);\n const newres = [];\n for (let i = 0, ii = res.length; i < ii; i += 1) {\n newres[i] = i % 2\n ? rotateVector(res[i - 1], res[i], rad).y\n : rotateVector(res[i], res[i + 1], rad).x;\n }\n return newres;\n};\n","/**\n * Converts a Q (quadratic-bezier) segment to C (cubic-bezier).\n *\n * @param x1 curve start x\n * @param y1 curve start y\n * @param qx control point x\n * @param qy control point y\n * @param x2 curve end x\n * @param y2 curve end y\n * @returns the cubic-bezier segment\n */\nexport const quadToCubic = (\n x1: number,\n y1: number,\n qx: number,\n qy: number,\n x2: number,\n y2: number,\n): [number, number, number, number, number, number] => {\n const r13 = 1 / 3;\n const r23 = 2 / 3;\n return [\n r13 * x1 + r23 * qx, // cpx1\n r13 * y1 + r23 * qy, // cpy1\n r13 * x2 + r23 * qx, // cpx2\n r13 * y2 + r23 * qy, // cpy2\n x2,\n y2, // x,y\n ];\n};\n","import { midPoint } from \"../math/midPoint\";\n\n/**\n * Converts an L (line-to) segment to C (cubic-bezier).\n *\n * @param x1 line start x\n * @param y1 line start y\n * @param x2 line end x\n * @param y2 line end y\n * @returns the cubic-bezier segment\n */\nexport const lineToCubic = (x1: number, y1: number, x2: number, y2: number) => {\n const c1 = midPoint([x1, y1], [x2, y2], 1.0 / 3.0);\n const c2 = midPoint([x1, y1], [x2, y2], 2.0 / 3.0);\n return [c1[0], c1[1], c2[0], c2[1], x2, y2];\n};\n","import { arcToCubic } from \"./arcToCubic\";\nimport { quadToCubic } from \"./quadToCubic\";\nimport { lineToCubic } from \"./lineToCubic\";\nimport type { CSegment, MSegment, PathSegment } from \"../types\";\nimport type { ParserParams } from \"../interface\";\n\n/**\n * Converts any segment to C (cubic-bezier).\n *\n * @param segment the source segment\n * @param params the source segment parameters\n * @returns the cubic-bezier segment\n */\nexport const segmentToCubic = (segment: PathSegment, params: ParserParams) => {\n const pathCommand = segment[0];\n const values = segment.slice(1).map(Number);\n const [x, y] = values;\n // let args;\n // const { x1: px1, y1: py1, x: px, y: py } = params;\n const { x1: px1, y1: py1 } = params;\n\n if (!\"TQ\".includes(pathCommand)) {\n params.qx = null;\n params.qy = null;\n }\n\n if (pathCommand === \"M\") {\n params.mx = x;\n params.my = y;\n params.x = x;\n params.y = y;\n return segment;\n } else if (pathCommand === \"A\") {\n return [\"C\" as string | number].concat(\n arcToCubic(\n px1,\n py1,\n values[0],\n values[1],\n values[2],\n values[3],\n values[4],\n values[5],\n values[6],\n ),\n ) as CSegment;\n } else if (pathCommand === \"Q\") {\n params.qx = x;\n params.qy = y;\n return [\"C\" as string | number].concat(\n quadToCubic(px1, py1, values[0], values[1], values[2], values[3]),\n ) as CSegment;\n } else if (pathCommand === \"L\") {\n return [\"C\" as string | number].concat(\n lineToCubic(px1, py1, x, y),\n ) as CSegment;\n } else if (pathCommand === \"Z\") {\n return [\"C\" as string | number].concat(\n lineToCubic(px1, py1, params.mx, params.my),\n ) as CSegment;\n }\n\n return segment as MSegment | CSegment;\n};\n","import type { ParserParams } from \"../interface\";\nimport type {\n ASegment,\n CSegment,\n HSegment,\n LSegment,\n MSegment,\n NormalSegment,\n PathCommand,\n PathSegment,\n PointTuple,\n QSegment,\n VSegment,\n} from \"../types\";\n\n/**\n * Normalizes a single segment of a `pathArray` object.\n *\n * @param segment the segment object\n * @param params the normalization parameters\n * @returns the normalized segment\n */\nexport const normalizeSegment = (\n segment: PathSegment,\n params: ParserParams,\n) => {\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = pathCommand !== absCommand;\n const { x1: px1, y1: py1, x2: px2, y2: py2, x, y } = params;\n const values = segment.slice(1) as number[];\n let absValues = values.map((n, j) => n + (isRelative ? (j % 2 ? y : x) : 0));\n\n if (!\"TQ\".includes(absCommand)) {\n // optional but good to be cautious\n params.qx = null;\n params.qy = null;\n }\n\n // istanbul ignore else @preserve\n if (absCommand === \"A\") {\n absValues = values.slice(0, -2).concat(\n values[5] + (isRelative ? x : 0),\n values[6] + (isRelative ? y : 0),\n );\n\n return [\"A\" as PathCommand | number].concat(absValues) as ASegment;\n } else if (absCommand === \"H\") {\n return [\n \"L\",\n (segment as HSegment)[1] + (isRelative ? x : 0),\n py1,\n ] as LSegment;\n } else if (absCommand === \"V\") {\n return [\n \"L\",\n px1,\n (segment as VSegment)[1] + (isRelative ? y : 0),\n ] as LSegment;\n } else if (absCommand === \"L\") {\n return [\n \"L\",\n (segment as LSegment)[1] + (isRelative ? x : 0),\n (segment as LSegment)[2] + (isRelative ? y : 0),\n ] as LSegment;\n } else if (absCommand === \"M\") {\n return [\n \"M\",\n (segment as MSegment)[1] + (isRelative ? x : 0),\n (segment as MSegment)[2] + (isRelative ? y : 0),\n ] as MSegment;\n } else if (absCommand === \"C\") {\n return [\"C\" as PathCommand | number].concat(absValues) as CSegment;\n } else if (absCommand === \"S\") {\n const x1 = px1 * 2 - px2;\n const y1 = py1 * 2 - py2;\n params.x1 = x1;\n params.y1 = y1;\n return [\"C\", x1, y1].concat(absValues) as CSegment;\n } else if (absCommand === \"T\") {\n const qx = px1 * 2 - (params.qx ? params.qx : /* istanbul ignore next */ 0);\n const qy = py1 * 2 - (params.qy ? params.qy : /* istanbul ignore next */ 0);\n params.qx = qx;\n params.qy = qy;\n return [\"Q\", qx, qy].concat(absValues) as QSegment;\n } else if (absCommand === \"Q\") {\n const [nqx, nqy] = absValues as PointTuple;\n params.qx = nqx;\n params.qy = nqy;\n return [\"Q\" as PathCommand | number].concat(absValues) as QSegment;\n } else if (absCommand === \"Z\") {\n return [\"Z\"] as NormalSegment;\n }\n\n // istanbul ignore next @preserve\n return segment as NormalSegment;\n};\n","import type { ParserParams } from \"../interface\";\n\n/**\n * Default parser parameters object used to track position state\n * while iterating through path segments.\n */\nexport const paramsParser: ParserParams = {\n mx: 0,\n my: 0,\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n x: 0,\n y: 0,\n qx: null,\n qy: null,\n};\n","import { segmentToCubic } from \"../process/segmentToCubic\";\nimport { AbsoluteCommand, CSegment, CurveArray, PathArray } from \"../types\";\nimport { iterate } from \"../process/iterate\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { normalizeSegment } from \"../process/normalizeSegment\";\nimport { paramsParser } from \"../parser/paramsParser\";\n\n/**\n * Parses a path string or PathArray and returns a new one\n * in which all segments are converted to cubic-bezier.\n *\n * @param pathInput - The path string or PathArray\n * @returns The resulted CurveArray with all segments as cubic beziers\n *\n * @example\n * ```ts\n * pathToCurve('M10 50q15 -25 30 0')\n * // => [['M', 10, 50], ['C', 25, 25, 40, 50, 40, 50]]\n * ```\n */\nexport const pathToCurve = <T extends PathArray>(\n pathInput: string | T,\n): CurveArray => {\n const params = { ...paramsParser };\n const path = parsePathString(pathInput);\n // let mx = 0;\n // let my = 0;\n\n return iterate(path, (seg, index, lastX, lastY) => {\n params.x = lastX;\n params.y = lastY;\n const normalSegment = normalizeSegment(seg, params);\n if (normalSegment[0] === \"M\") {\n params.mx = normalSegment[1];\n params.my = normalSegment[2];\n }\n let result = segmentToCubic(normalSegment, params);\n const isLongArc = result[0] === \"C\" && result.length > 7;\n\n if (isLongArc) {\n path.splice(\n index + 1,\n 0,\n [\"C\" as AbsoluteCommand | number].concat(result.slice(7)) as CSegment,\n );\n result = result.slice(0, 7) as CSegment;\n }\n\n const seglen = result.length;\n params.x1 = +result[seglen - 2];\n params.y1 = +result[seglen - 1];\n params.x2 = +result[seglen - 4] || params.x1;\n params.y2 = +result[seglen - 3] || params.y1;\n\n return result;\n }) as CurveArray;\n};\n","import type { PathArray, PathSegment } from \"../types\";\nimport { defaultOptions } from \"../options/options\";\nimport { roundTo } from \"../math/roundTo\";\n\n/**\n * Returns a valid `d` attribute string value created\n * by rounding values and concatenating the PathArray segments.\n *\n * @param path - The PathArray object\n * @param roundOption - Amount of decimals to round values to, or \"off\"\n * @returns The concatenated path string\n *\n * @example\n * ```ts\n * pathToString([['M', 10, 10], ['L', 90, 90]], 2)\n * // => 'M10 10L90 90'\n * ```\n */\nexport const pathToString = <T extends PathArray>(\n path: T,\n roundOption?: number | \"off\",\n): string => {\n const pathLen = path.length;\n let { round } = defaultOptions;\n let segment = path[0] as PathSegment;\n let result = \"\";\n\n // allow for ZERO decimals\n round = roundOption === \"off\"\n ? roundOption\n : typeof roundOption === \"number\" && roundOption >= 0\n ? roundOption\n : typeof round === \"number\" && round >= 0\n ? round\n : \"off\";\n\n for (let i = 0; i < pathLen; i += 1) {\n segment = path[i];\n const [pathCommand] = segment;\n const values = segment.slice(1) as number[];\n result += pathCommand;\n if (round === \"off\") {\n result += values.join(\" \");\n } else {\n let j = 0;\n const valLen = values.length;\n while (j < valLen) {\n result += roundTo(values[j], round);\n if (j !== valLen - 1) result += \" \";\n j += 1;\n }\n }\n }\n\n return result;\n};\n","import { iterate } from \"../process/iterate\";\nimport { PathBBox } from \"../interface\";\nimport { LSegment, MSegment, PathArray, PointTuple } from \"../types\";\nimport { getLineBBox } from \"../math/lineTools\";\nimport { getArcBBox } from \"../math/arcTools\";\nimport { getCubicBBox } from \"../math/cubicTools\";\nimport { getQuadBBox } from \"../math/quadTools\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { absolutizeSegment } from \"../process/absolutizeSegment\";\n\n/**\n * Calculates the bounding box of a path.\n *\n * @param pathInput - The path string or PathArray\n * @returns An object with width, height, x, y, x2, y2, cx, cy, cz properties\n *\n * @example\n * ```ts\n * getPathBBox('M0 0L100 0L100 100L0 100Z')\n * // => { x: 0, y: 0, width: 100, height: 100, x2: 100, y2: 100, cx: 50, cy: 50, cz: 150 }\n * ```\n */\nexport const getPathBBox = <T extends PathArray>(pathInput: T | string) => {\n if (!pathInput) {\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n x2: 0,\n y2: 0,\n cx: 0,\n cy: 0,\n cz: 0,\n };\n }\n\n const path = parsePathString(pathInput);\n let pathCommand = \"M\";\n let mx = 0;\n let my = 0;\n const { max, min } = Math;\n let xMin = Infinity;\n let yMin = Infinity;\n let xMax = -Infinity;\n let yMax = -Infinity;\n let minX = 0;\n let minY = 0;\n let maxX = 0;\n let maxY = 0;\n let paramX1 = 0;\n let paramY1 = 0;\n let paramX2 = 0;\n let paramY2 = 0;\n let paramQX = 0;\n let paramQY = 0;\n\n iterate(path, (seg, index, lastX, lastY) => {\n [pathCommand] = seg;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = absCommand !== pathCommand;\n const absoluteSegment = isRelative\n ? absolutizeSegment(seg, index, lastX, lastY)\n : (seg.slice(0) as typeof seg);\n\n const normalSegment = absCommand === \"V\"\n ? ([\"L\", lastX, absoluteSegment[1]] as LSegment)\n : absCommand === \"H\"\n ? ([\"L\", absoluteSegment[1], lastY] as LSegment)\n : absoluteSegment;\n\n [pathCommand] = normalSegment;\n\n if (!\"TQ\".includes(absCommand)) {\n // optional but good to be cautious\n paramQX = 0;\n paramQY = 0;\n }\n\n // this segment is always ZERO\n /* istanbul ignore else @preserve */\n if (pathCommand === \"M\") {\n [, mx, my] = normalSegment as MSegment;\n minX = mx;\n minY = my;\n maxX = mx;\n maxY = my;\n } else if (pathCommand === \"L\") {\n [minX, minY, maxX, maxY] = getLineBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"A\") {\n [minX, minY, maxX, maxY] = getArcBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n normalSegment[7] as number,\n );\n } else if (pathCommand === \"S\") {\n const cp1x = paramX1 * 2 - paramX2;\n const cp1y = paramY1 * 2 - paramY2;\n\n [minX, minY, maxX, maxY] = getCubicBBox(\n lastX,\n lastY,\n cp1x,\n cp1y,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"C\") {\n [minX, minY, maxX, maxY] = getCubicBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n );\n } else if (pathCommand === \"T\") {\n paramQX = paramX1 * 2 - paramQX;\n paramQY = paramY1 * 2 - paramQY;\n [minX, minY, maxX, maxY] = getQuadBBox(\n lastX,\n lastY,\n paramQX,\n paramQY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"Q\") {\n paramQX = normalSegment[1] as number;\n paramQY = normalSegment[2] as number;\n [minX, minY, maxX, maxY] = getQuadBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"Z\") {\n [minX, minY, maxX, maxY] = getLineBBox(lastX, lastY, mx, my);\n }\n xMin = min(minX, xMin);\n yMin = min(minY, yMin);\n xMax = max(maxX, xMax);\n yMax = max(maxY, yMax);\n\n // update params\n [paramX1, paramY1] = pathCommand === \"Z\"\n ? [mx, my]\n : (normalSegment.slice(-2) as PointTuple);\n [paramX2, paramY2] = pathCommand === \"C\"\n ? ([normalSegment[3], normalSegment[4]] as PointTuple)\n : pathCommand === \"S\"\n ? ([normalSegment[1], normalSegment[2]] as PointTuple)\n : [paramX1, paramY1];\n });\n\n const width = xMax - xMin;\n const height = yMax - yMin;\n\n return {\n width,\n height,\n x: xMin,\n y: yMin,\n x2: xMax,\n y2: yMax,\n cx: xMin + width / 2,\n cy: yMin + height / 2,\n // an estimated guess\n cz: Math.max(width, height) + Math.min(width, height) / 2,\n } satisfies PathBBox;\n};\n","import type { LSegment, MSegment, PathArray, PointTuple } from \"../types\";\nimport { getLineLength } from \"../math/lineTools\";\nimport { getArcLength } from \"../math/arcTools\";\nimport { getCubicLength } from \"../math/cubicTools\";\nimport { getQuadLength } from \"../math/quadTools\";\nimport { iterate } from \"../process/iterate\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { absolutizeSegment } from \"../process/absolutizeSegment\";\n\n/**\n * Returns the total length of a path, equivalent to `shape.getTotalLength()`.\n *\n * @param pathInput - The target path string or PathArray\n * @returns The total length of the path\n *\n * @example\n * ```ts\n * getTotalLength('M0 0L100 0L100 100L0 100Z')\n * // => 300\n * ```\n */\nexport const getTotalLength = <T extends PathArray>(pathInput: string | T) => {\n const path = parsePathString(pathInput);\n let paramX1 = 0;\n let paramY1 = 0;\n let paramX2 = 0;\n let paramY2 = 0;\n let paramQX = 0;\n let paramQY = 0;\n let pathCommand = \"M\";\n let mx = 0;\n let my = 0;\n let totalLength = 0;\n\n iterate(path, (seg, index, lastX, lastY) => {\n [pathCommand] = seg;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = absCommand !== pathCommand;\n const absoluteSegment = isRelative\n ? absolutizeSegment(seg, index, lastX, lastY)\n : (seg.slice(0) as typeof seg);\n\n const normalSegment = absCommand === \"V\"\n ? ([\"L\", lastX, absoluteSegment[1]] as LSegment)\n : absCommand === \"H\"\n ? ([\"L\", absoluteSegment[1], lastY] as LSegment)\n : absoluteSegment;\n [pathCommand] = normalSegment;\n\n if (!\"TQ\".includes(absCommand)) {\n // optional but good to be cautious\n paramQX = 0;\n paramQY = 0;\n }\n\n // this segment is always ZERO\n /* istanbul ignore else @preserve */\n if (pathCommand === \"M\") {\n // remember mx, my for Z\n [, mx, my] = normalSegment as MSegment;\n } else if (pathCommand === \"L\") {\n totalLength += getLineLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"A\") {\n totalLength += getArcLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n normalSegment[7] as number,\n );\n } else if (pathCommand === \"S\") {\n const cp1x = paramX1 * 2 - paramX2;\n const cp1y = paramY1 * 2 - paramY2;\n\n totalLength += getCubicLength(\n lastX,\n lastY,\n cp1x,\n cp1y,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"C\") {\n totalLength += getCubicLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n );\n } else if (pathCommand === \"T\") {\n paramQX = paramX1 * 2 - paramQX;\n paramQY = paramY1 * 2 - paramQY;\n totalLength += getQuadLength(\n lastX,\n lastY,\n paramQX,\n paramQY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"Q\") {\n paramQX = normalSegment[1] as number;\n paramQY = normalSegment[2] as number;\n totalLength += getQuadLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"Z\") {\n totalLength += getLineLength(lastX, lastY, mx, my);\n }\n\n // update params\n [paramX1, paramY1] = pathCommand === \"Z\"\n ? [mx, my]\n : (normalSegment.slice(-2) as PointTuple);\n [paramX2, paramY2] = pathCommand === \"C\"\n ? ([normalSegment[3], normalSegment[4]] as PointTuple)\n : pathCommand === \"S\"\n ? ([normalSegment[1], normalSegment[2]] as PointTuple)\n : [paramX1, paramY1];\n });\n\n return totalLength;\n};\n","/** Small threshold value used for floating-point distance comparisons in path calculations. */\nconst DISTANCE_EPSILON = 0.00001;\n\nexport default DISTANCE_EPSILON;\n","import type { NormalArray, PathArray } from \"../types\";\nimport { normalizeSegment } from \"./normalizeSegment\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { paramsParser } from \"../parser/paramsParser\";\nimport { iterate } from \"./iterate\";\n\n/**\n * Parses a path string or PathArray, then iterates the result for:\n * * converting segments to absolute values\n * * converting shorthand commands to their non-shorthand notation\n *\n * @param pathInput - The path string or PathArray\n * @returns The normalized PathArray\n *\n * @example\n * ```ts\n * normalizePath('M10 90s20 -80 40 -80s20 80 40 80')\n * // => [['M', 10, 90], ['C', 30, 90, 25, 10, 50, 10], ['C', 75, 10, 70, 90, 90, 90]]\n * ```\n */\nexport const normalizePath = (pathInput: string | PathArray): NormalArray => {\n const path = parsePathString(pathInput);\n const params = { ...paramsParser };\n\n return iterate(path, (seg, _, lastX, lastY) => {\n params.x = lastX;\n params.y = lastY;\n const result = normalizeSegment(seg, params);\n\n const seglen = result.length;\n params.x1 = +result[seglen - 2];\n params.y1 = +result[seglen - 1];\n params.x2 = +result[seglen - 4] || params.x1;\n params.y2 = +result[seglen - 3] || params.y1;\n\n return result;\n }) as NormalArray;\n};\n","import DISTANCE_EPSILON from \"./distanceEpsilon\";\nimport type { MSegment, PathArray, PointTuple } from \"../types\";\nimport { iterate } from \"../process/iterate\";\nimport { getLineLength, getPointAtLineLength } from \"../math/lineTools\";\nimport { getArcLength, getPointAtArcLength } from \"../math/arcTools\";\nimport { getCubicLength, getPointAtCubicLength } from \"../math/cubicTools\";\nimport { getPointAtQuadLength, getQuadLength } from \"../math/quadTools\";\nimport { normalizePath } from \"../process/normalizePath\";\n\n/**\n * Returns [x,y] coordinates of a point at a given length along a path.\n *\n * @param pathInput - The PathArray or path string to look into\n * @param distance - The distance along the path\n * @returns The requested {x, y} point coordinates\n *\n * @example\n * ```ts\n * getPointAtLength('M0 0L100 0L100 100Z', 50)\n * // => { x: 50, y: 0 }\n * ```\n */\nexport const getPointAtLength = <T extends PathArray>(\n pathInput: string | T,\n distance?: number,\n) => {\n const path = normalizePath(pathInput);\n let isM = false;\n let data = [] as number[];\n let x = 0;\n let y = 0;\n let [mx, my] = path[0].slice(1) as PointTuple;\n const distanceIsNumber = typeof distance === \"number\";\n let point = { x: mx, y: my };\n let length = 0;\n let POINT = point;\n let totalLength = 0;\n\n if (!distanceIsNumber || distance < DISTANCE_EPSILON) return point;\n\n iterate(path, (seg, _, lastX, lastY) => {\n const pathCommand = seg[0];\n isM = pathCommand === \"M\";\n data = !isM ? [lastX, lastY].concat(seg.slice(1) as number[]) : data;\n\n // this segment is always ZERO\n /* istanbul ignore else @preserve */\n if (isM) {\n // remember mx, my for Z\n [, mx, my] = seg as MSegment;\n point = { x: mx, y: my };\n length = 0;\n } else if (pathCommand === \"L\") {\n point = getPointAtLineLength(\n data[0],\n data[1],\n data[2],\n data[3],\n distance - totalLength,\n );\n length = getLineLength(data[0], data[1], data[2], data[3]);\n } else if (pathCommand === \"A\") {\n point = getPointAtArcLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n data[8],\n distance - totalLength,\n );\n length = getArcLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n data[8],\n );\n } else if (pathCommand === \"C\") {\n point = getPointAtCubicLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n distance - totalLength,\n );\n length = getCubicLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n );\n } else if (pathCommand === \"Q\") {\n point = getPointAtQuadLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n distance - totalLength,\n );\n length = getQuadLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n );\n } else if (pathCommand === \"Z\") {\n data = [lastX, lastY, mx, my];\n point = { x: mx, y: my };\n\n length = getLineLength(data[0], data[1], data[2], data[3]);\n }\n\n [x, y] = data.slice(-2);\n\n if (totalLength < distance) {\n POINT = point;\n } else {\n // totalLength >= distance\n // stop right here\n // stop iterator now!\n return false;\n }\n\n totalLength += length;\n return;\n });\n\n // native `getPointAtLength` behavior when the given distance\n // is higher than total length\n if (distance > totalLength - DISTANCE_EPSILON) {\n return { x, y };\n }\n\n return POINT;\n};\n","import type { PathArray, PathSegment } from \"../types\";\nimport type { SegmentProperties } from \"../interface\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { getTotalLength } from \"./getTotalLength\";\n\n/**\n * Returns the segment, its index and length as well as\n * the length to that segment at a given length in a path.\n *\n * @param pathInput target `pathArray`\n * @param distance the given length\n * @returns the requested properties\n */\nexport const getPropertiesAtLength = <T extends PathArray>(\n pathInput: string | T,\n distance?: number,\n): SegmentProperties => {\n const pathArray = parsePathString(pathInput);\n\n let pathTemp = pathArray.slice(0) as T;\n let pathLength = getTotalLength(pathTemp);\n let index = pathTemp.length - 1;\n let lengthAtSegment = 0;\n let length = 0;\n let segment = pathArray[0] as PathSegment;\n\n // If the path is empty, return 0.\n if (index <= 0 || !distance || !Number.isFinite(distance)) {\n return {\n segment,\n index: 0,\n length,\n lengthAtSegment,\n };\n }\n\n if (distance >= pathLength) {\n pathTemp = pathArray.slice(0, -1) as T;\n lengthAtSegment = getTotalLength(pathTemp);\n length = pathLength - lengthAtSegment;\n segment = pathArray[index];\n return {\n segment,\n index,\n length,\n lengthAtSegment,\n };\n }\n\n const segments = [] as SegmentProperties[];\n while (index > 0) {\n segment = pathTemp[index];\n pathTemp = pathTemp.slice(0, -1) as T;\n lengthAtSegment = getTotalLength(pathTemp);\n length = pathLength - lengthAtSegment;\n pathLength = lengthAtSegment;\n\n segments.push({\n segment,\n index,\n length,\n lengthAtSegment,\n });\n index -= 1;\n }\n\n return segments.find(\n ({ lengthAtSegment: l }) => l <= distance,\n ) as SegmentProperties;\n};\n","import type { PathArray, Point } from \"../types\";\nimport type { PointProperties } from \"../interface\";\nimport { getPointAtLength } from \"./getPointAtLength\";\nimport { getPropertiesAtLength } from \"./getPropertiesAtLength\";\nimport { getTotalLength } from \"./getTotalLength\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { normalizePath } from \"../process/normalizePath\";\n\n/**\n * Returns the point and segment in path closest to a given point as well as\n * the distance to the path stroke.\n *\n * @see https://bl.ocks.org/mbostock/8027637\n *\n * @param pathInput target `pathArray`\n * @param point the given point\n * @returns the requested properties\n */\nexport const getPropertiesAtPoint = <T extends PathArray>(\n pathInput: string | T,\n point: Point,\n): PointProperties => {\n const path = parsePathString(pathInput);\n const normalPath = normalizePath(path);\n const pathLength = getTotalLength(normalPath);\n const distanceTo = (p: Point) => {\n const dx = p.x - point.x;\n const dy = p.y - point.y;\n return dx * dx + dy * dy;\n };\n let precision = 8;\n let scan: Point;\n let closest = { x: 0, y: 0 }; // make TS happy\n let scanDistance = 0;\n let bestLength = 0;\n let bestDistance = Infinity;\n\n // linear scan for coarse approximation\n for (let scanLength = 0; scanLength <= pathLength; scanLength += precision) {\n scan = getPointAtLength(normalPath, scanLength);\n scanDistance = distanceTo(scan);\n\n if (scanDistance < bestDistance) {\n closest = scan;\n bestLength = scanLength;\n bestDistance = scanDistance;\n }\n }\n\n // binary search for precise estimate\n precision /= 2;\n let before: { x: number; y: number };\n let after: { x: number; y: number };\n let beforeLength = 0;\n let afterLength = 0;\n let beforeDistance = 0;\n let afterDistance = 0;\n\n while (precision > 0.000001) {\n beforeLength = bestLength - precision;\n before = getPointAtLength(normalPath, beforeLength);\n beforeDistance = distanceTo(before);\n afterLength = bestLength + precision;\n after = getPointAtLength(normalPath, afterLength);\n afterDistance = distanceTo(after);\n\n if (beforeLength >= 0 && beforeDistance < bestDistance) {\n closest = before;\n bestLength = beforeLength;\n bestDistance = beforeDistance;\n } else if (afterLength <= pathLength && afterDistance < bestDistance) {\n closest = after;\n bestLength = afterLength;\n bestDistance = afterDistance;\n } else {\n precision /= 2;\n }\n if (precision < 0.00001) break;\n }\n\n const segment = getPropertiesAtLength(path, bestLength);\n const distance = Math.sqrt(bestDistance);\n\n return { closest, distance, segment };\n};\n","import type { PathArray } from \"../types\";\nimport { getPropertiesAtPoint } from \"./getPropertiesAtPoint\";\n\n/**\n * Returns the point in path closest to a given point.\n *\n * @param pathInput target `pathArray`\n * @param point the given point\n * @returns the best match\n */\nexport const getClosestPoint = (\n pathInput: string | PathArray,\n point: { x: number; y: number },\n) => {\n return getPropertiesAtPoint(pathInput, point).closest;\n};\n","import { pathToCurve } from \"../convert/pathToCurve\";\nimport type { PathArray, PointTuple } from \"../types\";\n\n/**\n * Returns the area of a single cubic-bezier segment.\n *\n * http://objectmix.com/graphics/133553-area-closed-bezier-curve.html\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the area of the cubic-bezier segment\n */\nconst getCubicSegArea = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n) => {\n return (\n (3 *\n ((y2 - y1) * (c1x + c2x) -\n (x2 - x1) * (c1y + c2y) +\n c1y * (x1 - c2x) -\n c1x * (y1 - c2y) +\n y2 * (c2x + x1 / 3) -\n x2 * (c2y + y1 / 3))) /\n 20\n );\n};\n\n/**\n * Returns the signed area of a shape.\n *\n * @author Jürg Lehni & Jonathan Puckey\n *\n * @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js\n *\n * @param path - The shape PathArray\n * @returns The signed area of the shape (positive for clockwise, negative for counter-clockwise)\n *\n * @example\n * ```ts\n * getPathArea([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])\n * // => -10000 (counter-clockwise square)\n * ```\n */\nexport const getPathArea = <T extends PathArray>(path: T) => {\n let x = 0;\n let y = 0;\n let len = 0;\n\n return pathToCurve(path)\n .map((seg) => {\n switch (seg[0]) {\n case \"M\":\n [, x, y] = seg;\n return 0;\n default:\n len = getCubicSegArea(\n x,\n y,\n seg[1],\n seg[2],\n seg[3],\n seg[4],\n seg[5],\n seg[6],\n );\n [x, y] = seg.slice(-2) as PointTuple;\n return len;\n }\n })\n .reduce((a, b) => a + b, 0);\n};\n","import { getPathArea } from \"./getPathArea\";\nimport { pathToCurve } from \"../convert/pathToCurve\";\nimport type { PathArray } from \"../types\";\n\n/**\n * Check if a path is drawn clockwise and returns true if so,\n * false otherwise.\n *\n * @param path the path string or `pathArray`\n * @returns true when clockwise or false if not\n */\nexport const getDrawDirection = (path: string | PathArray) => {\n return getPathArea(pathToCurve(path)) >= 0;\n};\n","import type { PathArray, PathSegment } from \"../types\";\nimport { getPropertiesAtLength } from \"./getPropertiesAtLength\";\n\n/**\n * Returns the segment at a given length.\n *\n * @param pathInput the target `pathArray`\n * @param distance the distance in path to look at\n * @returns the requested segment\n */\nexport const getSegmentAtLength = <T extends PathArray>(\n pathInput: string | T,\n distance?: number,\n): PathSegment | undefined => {\n return getPropertiesAtLength(pathInput, distance).segment;\n};\n","import type { SegmentProperties } from \"../interface\";\nimport type { PathArray } from \"../types\";\nimport { getPropertiesAtPoint } from \"./getPropertiesAtPoint\";\n\n/**\n * Returns the path segment which contains a given point.\n *\n * @param path the `pathArray` to look into\n * @param point the point of the shape to look for\n * @returns the requested segment\n */\nexport const getSegmentOfPoint = <T extends PathArray>(\n path: string | T,\n point: { x: number; y: number },\n): SegmentProperties | undefined => {\n return getPropertiesAtPoint(path, point).segment;\n};\n","import type { PathArray, PathSegment, RelativeCommand } from \"../types\";\nimport { paramsCounts } from \"../parser/paramsCount\";\n\n/**\n * Iterates an array to check if it's an actual `pathArray`.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nexport const isPathArray = (path: unknown): path is PathArray => {\n return (\n Array.isArray(path) &&\n path.every((seg: PathSegment) => {\n const lk = seg[0].toLowerCase() as RelativeCommand;\n return (\n paramsCounts[lk] === seg.length - 1 &&\n \"achlmqstvz\".includes(lk) &&\n (seg.slice(1) as unknown[]).every(Number.isFinite)\n );\n }) &&\n path.length > 0\n );\n};\n","import type { AbsoluteArray } from \"../types\";\nimport { isPathArray } from \"./isPathArray\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all absolute values.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nexport const isAbsoluteArray = (path: unknown): path is AbsoluteArray => {\n return (\n isPathArray(path) &&\n // `isPathArray` also checks if it's `Array`\n path.every(([x]) => x === x.toUpperCase())\n );\n};\n","import type { NormalArray } from \"../types\";\nimport { isAbsoluteArray } from \"./isAbsoluteArray\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all segments in non-shorthand notation\n * with absolute values.\n *\n * @param path - the array to be checked\n * @returns true if the array is a normalized path array\n */\nexport const isNormalizedArray = (path: unknown): path is NormalArray => {\n // `isAbsoluteArray` also checks if it's `Array`\n return isAbsoluteArray(path) && path.every(([pc]) => \"ACLMQZ\".includes(pc));\n};\n","import { isNormalizedArray } from \"./isNormalizedArray\";\nimport { PathArray, PolygonArray } from \"../types\";\n/**\n * Checks if a path is a polygon (only M, L, H, V, Z commands).\n * @param pathArray PathArray (pre-normalize if needed)\n * @returns boolean\n */\nexport const isPolygonArray = (path: PathArray): path is PolygonArray => {\n return isNormalizedArray(path) && path.every(([pc]) => \"MLVHZ\".includes(pc));\n};\n","import { CurveArray } from \"../types\";\nimport { isNormalizedArray } from \"./isNormalizedArray\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all C (cubic bezier) segments.\n *\n * @param path the `Array` to be checked\n * @returns iteration result\n */\nexport const isCurveArray = (path: unknown): path is CurveArray => {\n // `isPathArray` also checks if it's `Array`\n return isNormalizedArray(path) && path.every(([pc]) => \"MC\".includes(pc));\n};\n","import type { PathArray } from \"../types\";\nimport { getPropertiesAtPoint } from \"./getPropertiesAtPoint\";\nimport DISTANCE_EPSILON from \"./distanceEpsilon\";\n\n/**\n * Checks if a given point is in the stroke of a path.\n *\n * @param pathInput target path\n * @param point the given `{x,y}` point\n * @returns the query result\n */\nexport const isPointInStroke = <T extends PathArray>(\n pathInput: string | T,\n point: { x: number; y: number },\n) => {\n const { distance } = getPropertiesAtPoint(pathInput, point);\n return Math.abs(distance) < DISTANCE_EPSILON; // 0.01 might be more permissive\n};\n","import type { RelativeArray } from \"../types\";\nimport { isPathArray } from \"./isPathArray\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with relative values.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nexport const isRelativeArray = (path: unknown): path is RelativeArray => {\n return (\n isPathArray(path) &&\n // `isPathArray` checks if it's `Array`\n path.slice(1).every(([pc]) => pc === pc.toLowerCase())\n );\n};\n","import { scanSegment } from \"../parser/scanSegment\";\nimport { skipSpaces } from \"../parser/skipSpaces\";\nimport { PathParser } from \"../parser/pathParser\";\n\n/**\n * Parses a path string value to determine its validity\n * then returns true if it's valid or false otherwise.\n *\n * @param pathString the path string to be parsed\n * @returns the path string validity\n */\nexport const isValidPath = (pathString: string) => {\n if (typeof pathString !== \"string\" || !pathString.length) {\n return false;\n }\n\n const path = new PathParser(pathString);\n\n skipSpaces(path);\n\n while (path.index < path.max && !path.err.length) {\n scanSegment(path);\n }\n\n return !path.err.length && \"mM\".includes(path.segments[0][0]);\n};\n","// src/morph/samplePolygon.ts\n\nimport { error } from \"../util/error\";\nimport { iterate } from \"../process/iterate\";\nimport type { NormalArray, PointTuple } from \"../types\";\n\n/**\n * Samples points from a path to form a polygon approximation.\n * Collects endpoints of each segment (M start + ends of L/C/etc).\n *\n * If `sampleSize` parameter is provided, it will return a polygon\n * equivalent to the original `PathArray`.\n * @param path `PolygonPathArray` or `CurvePathArray`\n * @returns Array of [x, y] points\n */\nexport function samplePolygon<T extends NormalArray>(\n path: T,\n): PointTuple[] {\n const points: PointTuple[] = [];\n\n let [mx, my] = [0, 0];\n\n iterate(path, (seg) => {\n const cmd = seg[0];\n if (cmd === \"M\") {\n [mx, my] = [seg[1] as number, seg[2] as number];\n points.push([mx, my]);\n } else if (cmd === \"L\") {\n points.push([seg[1] as number, seg[2] as number]);\n } else if (cmd === \"C\") {\n points.push([seg[5] as number, seg[6] as number]);\n } else if (cmd === \"A\") {\n points.push([seg[6] as number, seg[7] as number]);\n } else if (cmd === \"Z\") {\n points.push([mx, my]);\n } else {\n throw new TypeError(`${error}: path command \"${cmd}\" is not supported`);\n }\n });\n\n return points;\n}\n","import type { ShapeParams } from \"../interface\";\n\n/**\n * Supported shapes and their specific parameters.\n */\nexport const shapeParams: ShapeParams = {\n line: [\"x1\", \"y1\", \"x2\", \"y2\"],\n circle: [\"cx\", \"cy\", \"r\"],\n ellipse: [\"cx\", \"cy\", \"rx\", \"ry\"],\n rect: [\"width\", \"height\", \"x\", \"y\", \"rx\", \"ry\"],\n polygon: [\"points\"],\n polyline: [\"points\"],\n glyph: [\"d\"],\n};\n","/**\n * Checks if a value is a DOM Element.\n *\n * @param node - The value to check\n * @returns True if the value is a DOM Element (nodeType === 1)\n */\nexport const isElement = (node?: unknown): node is Element =>\n node !== undefined && node !== null &&\n typeof node === \"object\" &&\n (node as Node).nodeType === 1; // ELEMENT_NODE\n","import type {\n CircleAttr,\n EllipseAttr,\n GlyphAttr,\n LineAttr,\n PolyAttr,\n RectAttr,\n ShapeParams,\n} from \"../interface\";\nimport type { PathArray, PathSegment, ShapeOps, ShapeTypes } from \"../types\";\nimport { error } from \"./error\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { shapeParams } from \"./shapeParams\";\nimport { isPathArray } from \"./isPathArray\";\nimport { isElement } from \"./isElement\";\n\n/**\n * Returns a new PathArray from line attributes.\n *\n * @param attr - Shape configuration with x1, y1, x2, y2\n * @returns A new line PathArray\n *\n * @example\n * ```ts\n * getLinePath({ x1: 0, y1: 0, x2: 100, y2: 100 })\n * // => [['M', 0, 0], ['L', 100, 100]]\n * ```\n */\nexport const getLinePath = (attr: LineAttr): PathArray => {\n let { x1, y1, x2, y2 } = attr;\n [x1, y1, x2, y2] = [x1, y1, x2, y2].map((a) => +a);\n return [\n [\"M\", x1, y1],\n [\"L\", x2, y2],\n ];\n};\n\n/**\n * Returns a new PathArray from polyline/polygon attributes.\n *\n * @param attr - Shape configuration with points string\n * @returns A new polygon/polyline PathArray\n *\n * @example\n * ```ts\n * getPolyPath({ type: 'polygon', points: '0,0 100,0 100,100 0,100' })\n * // => [['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['z']]\n * ```\n */\nexport const getPolyPath = (attr: PolyAttr): PathArray => {\n const pathArray = [] as PathSegment[];\n const points = (attr.points || \"\")\n .trim()\n .split(/[\\s|,]/)\n .map((a) => +a);\n\n let index = 0;\n while (index < points.length) {\n pathArray.push([index ? \"L\" : \"M\", points[index], points[index + 1]]);\n index += 2;\n }\n\n return (\n attr.type === \"polygon\" ? [...pathArray, [\"z\"]] : pathArray\n ) as PathArray;\n};\n\n/**\n * Returns a new PathArray from circle attributes.\n *\n * @param attr - Shape configuration with cx, cy, r\n * @returns A circle PathArray\n *\n * @example\n * ```ts\n * getCirclePath({ cx: 50, cy: 50, r: 25 })\n * // => [['M', 25, 50], ['a', 25, 25, 0, 1, 0, 50, 0], ['a', 25, 25, 0, 1, 0, -50, 0]]\n * ```\n */\nexport const getCirclePath = (attr: CircleAttr): PathArray => {\n let { cx, cy, r } = attr;\n [cx, cy, r] = [cx, cy, r].map((a) => +a);\n\n return [\n [\"M\", cx - r, cy],\n [\"a\", r, r, 0, 1, 0, 2 * r, 0],\n [\"a\", r, r, 0, 1, 0, -2 * r, 0],\n ];\n};\n\n/**\n * Returns a new PathArray from ellipse attributes.\n *\n * @param attr - Shape configuration with cx, cy, rx, ry\n * @returns An ellipse PathArray\n *\n * @example\n * ```ts\n * getEllipsePath({ cx: 50, cy: 50, rx: 30, ry: 20 })\n * // => [['M', 20, 50], ['a', 30, 20, 0, 1, 0, 60, 0], ['a', 30, 20, 0, 1, 0, -60, 0]]\n * ```\n */\nexport const getEllipsePath = (attr: EllipseAttr): PathArray => {\n let { cx, cy } = attr;\n let rx = attr.rx || 0;\n let ry = attr.ry || rx;\n [cx, cy, rx, ry] = [cx, cy, rx, ry].map((a) => +a);\n\n return [\n [\"M\", cx - rx, cy],\n [\"a\", rx, ry, 0, 1, 0, 2 * rx, 0],\n [\"a\", rx, ry, 0, 1, 0, -2 * rx, 0],\n ];\n};\n\n/**\n * Returns a new PathArray from rect attributes.\n *\n * @param attr - Object with x, y, width, height, and optional rx/ry\n * @returns A new PathArray from `<rect>` attributes\n *\n * @example\n * ```ts\n * getRectanglePath({ x: 0, y: 0, width: 100, height: 50, ry: 10 })\n * // => [['M', 10, 0], ['h', 80], ['a', 10, 10, 0, 0, 1, 10, 10], ...]\n * ```\n */\nexport const getRectanglePath = (attr: RectAttr): PathArray => {\n const x = +attr.x || 0;\n const y = +attr.y || 0;\n const w = +attr.width;\n const h = +attr.height;\n let rx = +(attr.rx || 0);\n let ry = +(attr.ry || rx);\n\n // Validity checks from http://www.w3.org/TR/SVG/shapes.html#RectElement:\n if (rx || ry) {\n // rx = !rx ? ry : rx;\n // ry = !ry ? rx : ry;\n\n /* istanbul ignore else @preserve */\n if (rx * 2 > w) rx -= (rx * 2 - w) / 2;\n /* istanbul ignore else @preserve */\n if (ry * 2 > h) ry -= (ry * 2 - h) / 2;\n\n return [\n [\"M\", x + rx, y],\n [\"h\", w - rx * 2],\n [\"s\", rx, 0, rx, ry],\n [\"v\", h - ry * 2],\n [\"s\", 0, ry, -rx, ry],\n [\"h\", -w + rx * 2],\n [\"s\", -rx, 0, -rx, -ry],\n [\"v\", -h + ry * 2],\n [\"s\", 0, -ry, rx, -ry],\n ];\n }\n\n return [[\"M\", x, y], [\"h\", w], [\"v\", h], [\"H\", x], [\"Z\"]];\n};\n\n/**\n * Returns a new `pathArray` created from attributes of a `<line>`, `<polyline>`,\n * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>`, <path> or `<glyph>`.\n *\n * It can also work with an options object, see the type below\n * @see ShapeOps\n *\n * @param element target shape\n * @returns the newly created `<path>` element\n */\nexport const shapeToPathArray = (element: ShapeTypes | ShapeOps) => {\n const supportedShapes = Object.keys(shapeParams) as (keyof ShapeParams)[];\n const targetIsElement = isElement(element);\n const tagName = targetIsElement ? element.tagName : null;\n\n if (tagName && [...supportedShapes, \"path\"].every((s) => tagName !== s)) {\n throw TypeError(`${error}: \"${tagName}\" is not SVGElement`);\n }\n\n const type = (\n targetIsElement ? tagName : (element as ShapeOps).type\n ) as ShapeOps[\"type\"];\n const shapeAttrs = shapeParams[type] as string[];\n const config = { type } as Record<string, string>;\n\n if (targetIsElement) {\n shapeAttrs.forEach((p) => {\n config[p] = element.getAttribute(p) as string;\n });\n } else {\n Object.assign(config, element);\n }\n\n // set d\n let pathArray = [] as unknown as PathArray;\n\n /* istanbul ignore else */\n if (type === \"circle\") {\n pathArray = getCirclePath(config as unknown as CircleAttr);\n } else if (type === \"ellipse\") {\n pathArray = getEllipsePath(config as unknown as EllipseAttr);\n } else if ([\"polyline\", \"polygon\"].includes(type)) {\n pathArray = getPolyPath(config as unknown as PolyAttr);\n } else if (type === \"rect\") {\n pathArray = getRectanglePath(config as unknown as RectAttr);\n } else if (type === \"line\") {\n pathArray = getLinePath(config as unknown as LineAttr);\n } else if ([\"glyph\", \"path\"].includes(type)) {\n pathArray = parsePathString(\n targetIsElement\n ? element.getAttribute(\"d\") || /* istanbul ignore next @preserve */ \"\"\n : (element as GlyphAttr).d || \"\",\n );\n }\n\n // replace target element\n if (isPathArray(pathArray) && pathArray.length) {\n return pathArray;\n }\n return false;\n};\n","import type { ShapeParams } from \"../interface\";\nimport type { ShapeOps, ShapeTypes } from \"../types\";\nimport { pathToString } from \"../convert/pathToString\";\nimport { defaultOptions } from \"../options/options\";\nimport { error } from \"./error\";\nimport { isValidPath } from \"./isValidPath\";\nimport { isElement } from \"./isElement\";\nimport { shapeToPathArray } from \"./shapeToPathArray\";\nimport { shapeParams } from \"./shapeParams\";\n\n/**\n * Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,\n * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter\n * is `true`, it will replace the target. The default `ownerDocument` is your current\n * `document` browser page, if you want to use in server-side using `jsdom`, you can\n * pass the `jsdom` `document` to `ownDocument`.\n *\n * It can also work with an options object, see the type below\n * @see ShapeOps\n *\n * The newly created `<path>` element keeps all non-specific\n * attributes like `class`, `fill`, etc.\n *\n * @param element - Target shape element or shape options object\n * @param replace - Option to replace target element\n * @param ownerDocument - Document for creating the element\n * @returns The newly created `<path>` element, or false if the path is invalid\n *\n * @example\n * ```ts\n * const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle')\n * circle.setAttribute('cx', '50')\n * circle.setAttribute('cy', '50')\n * circle.setAttribute('r', '25')\n * const path = shapeToPath(circle)\n * path.getAttribute('d')\n * // => 'M50 25A25 25 0 1 1 50 75A25 25 0 1 1 50 25Z'\n * ```\n */\nexport const shapeToPath = (\n element: ShapeTypes | ShapeOps,\n replace?: boolean,\n ownerDocument?: Document,\n): SVGPathElement | false => {\n const doc = ownerDocument || document;\n const supportedShapes = Object.keys(shapeParams) as (keyof ShapeParams)[];\n const targetIsElement = isElement(element);\n const tagName = targetIsElement ? element.tagName : null;\n\n if (tagName === \"path\") {\n throw TypeError(`${error}: \"${tagName}\" is already SVGPathElement`);\n }\n if (tagName && supportedShapes.every((s) => tagName !== s)) {\n throw TypeError(`${error}: \"${tagName}\" is not SVGElement`);\n }\n\n const path = doc.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n const type =\n (targetIsElement ? tagName : (element as ShapeOps).type) as ShapeOps[\n \"type\"\n ];\n const shapeAttrs = shapeParams[type] as string[];\n const config = { type } as Record<string, string>;\n\n // set d\n const round = defaultOptions.round as number;\n const pathArray = shapeToPathArray(element);\n const description = pathArray && pathArray.length\n ? pathToString(pathArray, round)\n : \"\";\n\n if (targetIsElement) {\n shapeAttrs.forEach((p) => {\n config[p] = element.getAttribute(p) as string;\n });\n // set no-specific shape attributes: fill, stroke, etc\n for (let i = 0; i < element.attributes.length; i++) {\n const attr = element.attributes[i];\n if (attr && !shapeAttrs.includes(attr.name)) {\n path.setAttribute(attr.name, attr.value);\n }\n }\n } else {\n Object.assign(config, element);\n // set no-specific shape attributes: fill, stroke, etc\n Object.keys(config).forEach((k) => {\n if (!shapeAttrs.includes(k) && k !== \"type\") {\n path.setAttribute(\n k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`),\n config[k],\n );\n }\n });\n }\n\n // replace target element\n if (isValidPath(description)) {\n path.setAttribute(\"d\", description);\n if (replace && targetIsElement) {\n element.before(path, element);\n element.remove();\n }\n return path;\n }\n return false;\n};\n","import { type PathArray } from \"../types\";\nimport { error } from \"./error\";\nimport { isPathArray } from \"./isPathArray\";\n\n/**\n * Determines if an SVG path contains multiple subpaths.\n * Accepts path string or PathArray.\n * @param path - 'M10,10 L20,20 Z M30,30 L40,40' → true\n * @returns boolean\n */\nexport const isMultiPath = <T extends PathArray>(\n path: string | T,\n): boolean => {\n if (typeof path === \"string\") {\n // Count all 'M' and 'm' occurrences\n const matches = path.match(/[Mm]/g);\n return matches ? matches.length > 1 : false;\n }\n\n // istanbul ignore else\n if (isPathArray(path)) {\n let moveCount = 0;\n for (const segment of path) {\n if (segment[0].toUpperCase() === \"M\") {\n moveCount++;\n if (moveCount > 1) return true;\n }\n }\n return false;\n }\n\n throw new TypeError(error + \": expected string or PathArray\");\n};\n","import { isNormalizedArray } from \"./isNormalizedArray\";\nimport { PathArray, PolylineArray } from \"../types\";\n/**\n * Checks if a path is a polyline (only M, L, H, V commands).\n * @param pathArray PathArray (pre-normalize if needed)\n * @returns boolean\n */\nexport function isPolylineArray(path: PathArray): path is PolylineArray {\n return isNormalizedArray(path) && path.every(([pc]) => \"MLVH\".includes(pc));\n}\n","import { PathArray } from \"../types\";\n\n/**\n * Check if a PathArray is closed, which means its last segment is a Z.\n * @param path\n * @returns true if the path is closed\n */\nexport const isClosedPath = <T extends PathArray>(path: T) => {\n return path[path.length - 1][0].toUpperCase() === \"Z\";\n};\n","import { defaultOptions } from \"../options/options\";\nimport type { ParserParams } from \"../interface\";\nimport { roundTo } from \"../math/roundTo\";\nimport type {\n AbsoluteSegment,\n NormalSegment,\n PathCommand,\n ShortSegment,\n SSegment,\n TSegment,\n} from \"../types\";\n\n/**\n * Shorten a single segment of a `pathArray` object.\n *\n * @param segment the `absoluteSegment` object\n * @param normalSegment the `normalSegment` object\n * @param params the coordinates of the previous segment\n * @param prevCommand the path command of the previous segment\n * @returns the shortened segment\n */\nexport const shortenSegment = (\n segment: AbsoluteSegment,\n normalSegment: NormalSegment,\n params: ParserParams,\n prevCommand: PathCommand,\n): ShortSegment => {\n const [pathCommand] = segment;\n const { round: defaultRound } = defaultOptions;\n const round = typeof defaultRound === \"number\"\n ? defaultRound\n : /* istanbul ignore next */ 4;\n const normalValues = normalSegment.slice(1) as number[];\n const { x1, y1, x2, y2, x, y } = params;\n const [nx, ny] = normalValues.slice(-2);\n const result = segment;\n\n if (!\"TQ\".includes(pathCommand)) {\n // optional but good to be cautious\n params.qx = null;\n params.qy = null;\n }\n\n if (pathCommand === \"L\") {\n if (roundTo(x, round) === roundTo(nx, round)) {\n return [\"V\", ny];\n } else if (roundTo(y, round) === roundTo(ny, round)) {\n return [\"H\", nx];\n }\n } else if (pathCommand === \"C\") {\n const [nx1, ny1] = normalValues;\n params.x1 = nx1;\n params.y1 = ny1;\n\n if (\n \"CS\".includes(prevCommand) &&\n ((roundTo(nx1, round) === roundTo(x1 * 2 - x2, round) &&\n roundTo(ny1, round) === roundTo(y1 * 2 - y2, round)) ||\n (roundTo(x1, round) === roundTo(x2 * 2 - x, round) &&\n roundTo(y1, round) === roundTo(y2 * 2 - y, round)))\n ) {\n return [\n \"S\",\n normalValues[2],\n normalValues[3],\n normalValues[4],\n normalValues[5],\n ] as SSegment;\n }\n } else if (pathCommand === \"Q\") {\n const [qx, qy] = normalValues;\n params.qx = qx;\n params.qy = qy;\n\n if (\n \"QT\".includes(prevCommand) &&\n roundTo(qx, round) === roundTo(x1 * 2 - x2, round) &&\n roundTo(qy, round) === roundTo(y1 * 2 - y2, round)\n ) {\n return [\"T\", normalValues[2], normalValues[3]] as TSegment;\n }\n }\n\n // ['V', 'H', 'S', 'T', 'Z'].includes(pathCommand)\n return result as ShortSegment;\n};\n","import type { PathCommand, PathSegment } from \"../types\";\nimport { roundTo } from \"../math/roundTo\";\n\n/**\n * Rounds the numeric values of a path segment to the specified precision.\n *\n * @param segment - The path segment to round\n * @param roundOption - Number of decimal places\n * @returns The rounded segment\n */\nexport const roundSegment = <T extends PathSegment>(\n segment: T,\n roundOption: number,\n) => {\n const values = (segment.slice(1) as number[]).map((n) =>\n roundTo(n, roundOption)\n );\n return [segment[0] as PathCommand | number].concat(values) as T;\n};\n","import type {\n AbsoluteSegment,\n PathArray,\n PathCommand,\n PathSegment,\n} from \"../types\";\nimport { pathToAbsolute } from \"../convert/pathToAbsolute\";\nimport { shortenSegment } from \"./shortenSegment\";\nimport { paramsParser } from \"../parser/paramsParser\";\nimport { iterate } from \"./iterate\";\nimport { normalizeSegment } from \"./normalizeSegment\";\nimport { relativizeSegment } from \"./relativizeSegment\";\nimport { roundSegment } from \"./roundSegment\";\n\n/**\n * Optimizes a PathArray:\n * * converts segments to shorthand if possible\n * * selects shortest representation from absolute and relative forms\n *\n * @param pathInput - A path string or PathArray\n * @param roundOption - Number of decimal places for rounding\n * @returns The optimized PathArray\n *\n * @example\n * ```ts\n * optimizePath('M10 10L10 10L90 90', 2)\n * // => [['M', 10, 10], ['l', 0, 0], ['l', 80, 80]]\n * ```\n */\nexport const optimizePath = <T extends PathArray>(\n pathInput: T,\n roundOption?: number,\n): PathArray => {\n const path = pathToAbsolute(pathInput);\n // allow for ZERO decimals or use an aggressive value of 2\n const round = typeof roundOption === \"number\" && roundOption >= 0\n ? roundOption\n : 2;\n // this utility overrides the iterator params\n const optimParams = { ...paramsParser };\n\n const allPathCommands = [] as PathCommand[];\n let pathCommand = \"M\" as PathCommand;\n let prevCommand = \"Z\" as PathCommand;\n\n return iterate(path, (seg, i, lastX, lastY) => {\n optimParams.x = lastX;\n optimParams.y = lastY;\n const normalizedSegment = normalizeSegment(seg, optimParams);\n let result: PathSegment = seg;\n pathCommand = seg[0];\n\n // Save current path command\n allPathCommands[i] = pathCommand;\n if (i) {\n // Get previous path command for `shortenSegment`\n prevCommand = allPathCommands[i - 1];\n const shortSegment = shortenSegment(\n seg as AbsoluteSegment,\n normalizedSegment,\n optimParams,\n prevCommand,\n );\n const absSegment = roundSegment(shortSegment, round);\n const absString = absSegment.join(\"\");\n const relativeSegment = relativizeSegment(shortSegment, i, lastX, lastY);\n const relSegment = roundSegment(relativeSegment, round);\n const relString = relSegment.join(\"\");\n result = absString.length < relString.length ? absSegment : relSegment;\n }\n\n const seglen = normalizedSegment.length;\n optimParams.x1 = +normalizedSegment[seglen - 2];\n optimParams.y1 = +normalizedSegment[seglen - 1];\n optimParams.x2 = +normalizedSegment[seglen - 4] || optimParams.x1;\n optimParams.y2 = +normalizedSegment[seglen - 3] || optimParams.y1;\n\n return result;\n });\n};\n","import type {\n // ASegment,\n CSegment,\n // HSegment,\n // MSegment,\n PathArray,\n PathSegment,\n PointTuple,\n QSegment,\n SSegment,\n TSegment,\n // VSegment,\n} from \"../types\";\nimport { pathToAbsolute } from \"../convert/pathToAbsolute\";\nimport { normalizePath } from \"./normalizePath\";\nimport { iterate } from \"./iterate\";\n\n/**\n * Reverses all segments of a PathArray and returns a new PathArray\n * with absolute values.\n *\n * @param pathInput - The source PathArray\n * @returns The reversed PathArray\n *\n * @example\n * ```ts\n * reversePath([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])\n * // => [['M', 0, 100], ['L', 0, 0], ['L', 100, 0], ['L', 100, 100], ['Z']]\n * ```\n */\nexport const reversePath = <T extends PathArray>(pathInput: T) => {\n const absolutePath = pathToAbsolute(pathInput);\n const normalizedPath = normalizePath(absolutePath);\n const pLen = absolutePath.length;\n const isClosed = absolutePath[pLen - 1][0] === \"Z\";\n\n const reversedPath = iterate(absolutePath, (segment, i) => {\n const normalizedSegment = normalizedPath[i];\n const prevSeg = i && absolutePath[i - 1];\n const prevCommand = prevSeg && prevSeg[0];\n const nextSeg = absolutePath[i + 1];\n const nextCommand = nextSeg && nextSeg[0];\n const pathCommand = segment[0];\n const [x, y] = normalizedPath[i ? i - 1 : pLen - 1].slice(-2) as PointTuple;\n let result = segment;\n\n switch (pathCommand) {\n case \"M\":\n result = isClosed ? [\"Z\"] : [pathCommand, x, y];\n break;\n case \"A\":\n result = [\n pathCommand,\n segment[1],\n segment[2],\n segment[3],\n segment[4],\n segment[5] === 1 ? 0 : 1,\n x,\n y,\n ];\n break;\n case \"C\":\n if (nextSeg && nextCommand === \"S\") {\n result = [\"S\", segment[1], segment[2], x, y];\n } else {\n result = [\n pathCommand,\n segment[3],\n segment[4],\n segment[1],\n segment[2],\n x,\n y,\n ];\n }\n break;\n case \"S\":\n if (\n prevCommand &&\n \"CS\".includes(prevCommand) &&\n (!nextSeg || nextCommand !== \"S\")\n ) {\n result = [\n \"C\",\n normalizedSegment[3],\n normalizedSegment[4],\n normalizedSegment[1],\n normalizedSegment[2],\n x,\n y,\n ] as CSegment;\n } else {\n result = [\n pathCommand,\n normalizedSegment[1],\n normalizedSegment[2],\n x,\n y,\n ] as SSegment;\n }\n break;\n case \"Q\":\n if (nextSeg && nextCommand === \"T\") {\n result = [\"T\", x, y] as TSegment;\n } else {\n result = [pathCommand, segment[1], segment[2], x, y];\n }\n break;\n case \"T\":\n if (\n prevCommand &&\n \"QT\".includes(prevCommand) &&\n (!nextSeg || nextCommand !== \"T\")\n ) {\n result = [\n \"Q\",\n normalizedSegment[1],\n normalizedSegment[2],\n x,\n y,\n ] as QSegment;\n } else {\n result = [pathCommand, x, y] as TSegment;\n }\n break;\n case \"Z\":\n result = [\"M\", x, y];\n break;\n case \"H\":\n result = [pathCommand, x];\n break;\n case \"V\":\n result = [pathCommand, y];\n break;\n default:\n result = [pathCommand as typeof pathCommand | number].concat(\n segment.slice(1, -2),\n x,\n y,\n ) as typeof segment;\n }\n\n return result;\n });\n\n return (\n isClosed\n ? reversedPath.reverse()\n : [reversedPath[0] as PathSegment].concat(reversedPath.slice(1).reverse())\n ) as T;\n};\n","// import paramsParser from \"../parser/paramsParser\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport type {\n AbsoluteCommand,\n HSegment,\n MSegment,\n PathArray,\n PointTuple,\n VSegment,\n} from \"../types\";\nimport { iterate } from \"./iterate\";\n\n/**\n * Split a path string or PathArray into an array of sub-paths.\n *\n * In the process, values are converted to absolute\n * for visual consistency.\n *\n * @param pathInput - The source path string or PathArray\n * @returns An array of sub-path PathArrays\n *\n * @example\n * ```ts\n * splitPath('M0 0L100 0ZM200 0L300 0Z')\n * // => [\n * // [['M', 0, 0], ['L', 100, 0], ['Z']],\n * // [['M', 200, 0], ['L', 300, 0], ['Z']]\n * // ]\n * ```\n */\nexport const splitPath = <T extends PathArray>(pathInput: T | string): T[] => {\n const composite: T[] = [];\n const parsedPath = parsePathString(pathInput);\n let path = [] as unknown as T;\n let pi = -1;\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n iterate(parsedPath, (seg, _, prevX, prevY) => {\n const cmd = seg[0];\n const absCommand = cmd.toUpperCase() as AbsoluteCommand;\n const isRelative = cmd === cmd.toLowerCase();\n const values = seg.slice(1) as number[];\n\n if (absCommand === \"M\") {\n pi += 1;\n\n [x, y] = values as PointTuple;\n x += isRelative ? prevX : 0;\n y += isRelative ? prevY : 0;\n mx = x;\n my = y;\n path = [\n (isRelative ? [absCommand, mx, my] : seg) as MSegment,\n ] as unknown as T;\n } else {\n if (absCommand === \"Z\") {\n x = mx;\n y = my;\n } else if (absCommand === \"H\") {\n [, x] = seg as HSegment;\n x += isRelative ? prevX : /* istanbul ignore next @preserve */ 0;\n } else if (absCommand === \"V\") {\n [, y] = seg as VSegment;\n y += isRelative ? prevY : /* istanbul ignore next @preserve */ 0;\n } else {\n [x, y] = seg.slice(-2) as PointTuple;\n x += isRelative ? prevX : 0;\n y += isRelative ? prevY : 0;\n }\n path.push(seg);\n }\n\n composite[pi] = path;\n });\n\n return composite;\n};\nexport default splitPath;\n","import CSSMatrix from \"@thednp/dommatrix\";\n// import type { TransformObject } from '../interface';\nimport type { TransformObjectValues } from \"../types\";\n\n/**\n * Returns a transformation matrix to apply to `<path>` elements.\n *\n * @see TransformObjectValues\n *\n * @param transform the `transformObject`\n * @returns a new transformation matrix\n */\nexport const getSVGMatrix = (transform: TransformObjectValues): CSSMatrix => {\n let matrix = new CSSMatrix();\n const { origin } = transform;\n const [originX, originY] = origin as [number, number, number];\n const { translate } = transform;\n const { rotate } = transform;\n const { skew } = transform;\n const { scale } = transform;\n\n // set translate\n if (\n Array.isArray(translate) &&\n translate.length >= 2 &&\n translate.every((x) => !Number.isNaN(+x)) &&\n translate.some((x) => x !== 0)\n ) {\n matrix = matrix.translate(...(translate as [number, number, number?]));\n } else if (typeof translate === \"number\" && !Number.isNaN(translate)) {\n matrix = matrix.translate(translate);\n }\n\n if (rotate || skew || scale) {\n // set SVG transform-origin, always defined\n matrix = matrix.translate(originX, originY);\n\n // set rotation\n if (\n Array.isArray(rotate) &&\n rotate.length >= 2 &&\n rotate.every((x) => !Number.isNaN(+x)) &&\n rotate.some((x) => x !== 0)\n ) {\n matrix = matrix.rotate(...(rotate as [number, number, number?]));\n } else if (typeof rotate === \"number\" && !Number.isNaN(rotate)) {\n matrix = matrix.rotate(rotate);\n }\n\n // set skew(s)\n if (\n Array.isArray(skew) && skew.length === 2 && skew.every((x) =>\n !Number.isNaN(+x)\n ) && skew.some((x) => x !== 0)\n ) {\n matrix = skew[0] ? matrix.skewX(skew[0]) : matrix;\n matrix = skew[1] ? matrix.skewY(skew[1]) : matrix;\n } else if (typeof skew === \"number\" && !Number.isNaN(skew)) {\n matrix = matrix.skewX(skew);\n }\n\n // set scale\n if (\n Array.isArray(scale) && scale.length >= 2 && scale.every((x) =>\n !Number.isNaN(+x)\n ) && scale.some((x) => x !== 1)\n ) {\n matrix = matrix.scale(...(scale as [number, number, number?]));\n } else if (typeof scale === \"number\" && !Number.isNaN(scale)) {\n matrix = matrix.scale(scale);\n }\n // set SVG transform-origin\n matrix = matrix.translate(-originX, -originY);\n }\n\n return matrix;\n};\n","import CSSMatrix from \"@thednp/dommatrix\";\nimport { type PointTuple } from \"../types\";\n\n/**\n * Transforms a specified point using a matrix, returning a new\n * Tuple *Object* comprising of the transformed point.\n * Neither the matrix nor the original point are altered.\n *\n * @copyright thednp © 2021\n *\n * @param cssm CSSMatrix instance\n * @param v Tuple\n * @returns the resulting Tuple\n */\nconst translatePoint = (\n cssm: CSSMatrix,\n v: [number, number, number, number],\n): [number, number, number, number] => {\n let m = CSSMatrix.Translate(v[0], v[1], v[2]);\n\n [, , , m.m44] = v;\n m = cssm.multiply(m);\n\n return [m.m41, m.m42, m.m43, m.m44];\n};\n\n/**\n * Returns the [x,y] projected coordinates for a given an [x,y] point\n * and an [x,y,z] perspective origin point.\n *\n * Equation found here =>\n * http://en.wikipedia.org/wiki/3D_projection#Diagram\n * Details =>\n * https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel\n *\n * @param m the transformation matrix\n * @param point2D the initial [x,y] coordinates\n * @param origin the [x,y,z] transform origin\n * @returns the projected [x,y] coordinates\n */\nexport const projection2d = (\n m: CSSMatrix,\n point2D: PointTuple,\n origin: [number, number, number],\n): PointTuple => {\n const [originX, originY, originZ] = origin;\n const [x, y, z] = translatePoint(m, [point2D[0], point2D[1], 0, 1]);\n\n const relativePositionX = x - originX;\n const relativePositionY = y - originY;\n const relativePositionZ = z - originZ;\n\n return [\n // protect against division by ZERO\n relativePositionX * (Math.abs(originZ) / Math.abs(relativePositionZ) || 1) +\n originX,\n relativePositionY * (Math.abs(originZ) / Math.abs(relativePositionZ) || 1) +\n originY,\n ];\n};\n","import { getSVGMatrix } from \"./getSVGMatrix\";\nimport { projection2d } from \"./projection2d\";\nimport { defaultOptions } from \"../options/options\";\nimport type {\n AbsoluteArray,\n AbsoluteSegment,\n CSegment,\n LSegment,\n PathArray,\n TransformObjectValues,\n} from \"../types\";\nimport type { TransformObject } from \"../interface\";\nimport { iterate } from \"./iterate\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { absolutizeSegment } from \"./absolutizeSegment\";\nimport { arcToCubic } from \"./arcToCubic\";\n\n/**\n * Apply a 2D / 3D transformation to a PathArray.\n *\n * Since SVGElement doesn't support 3D transformation, this function\n * creates a 2D projection of the path element.\n *\n * @param pathInput - The PathArray or path string to transform\n * @param transform - The transform functions object (translate, rotate, skew, scale, origin)\n * @returns The transformed PathArray\n *\n * @example\n * ```ts\n * transformPath('M0 0L100 0L100 100L0 100Z', { translate: [10, 20], scale: 2 })\n * // => [['M', 10, 20], ['L', 210, 20], ['L', 210, 220], ['L', 10, 220], ['Z']]\n * ```\n */\nexport const transformPath = <T extends PathArray>(\n pathInput: T | string,\n transform?: Partial<TransformObject>,\n): T | AbsoluteArray => {\n // last x and y transformed values\n let x = 0;\n let y = 0;\n // new x and y transformed\n let lx = 0;\n let ly = 0;\n // segment params iteration index and length\n let j = 0;\n let jj = 0;\n // transform uses it's own set of params\n const path = parsePathString(pathInput);\n const transformProps = transform && Object.keys(transform);\n\n // when used as a static method, invalidate somehow\n if (!transform || (transformProps && !transformProps.length)) {\n return path.slice(0) as T;\n }\n\n // transform origin is extremely important\n if (!transform.origin) {\n Object.assign(transform, { origin: defaultOptions.origin });\n }\n const origin = transform.origin as [number, number, number];\n const matrixInstance = getSVGMatrix(transform as TransformObjectValues);\n\n if (matrixInstance.isIdentity) return path.slice(0) as T;\n\n return iterate(path, (seg, index, lastX, lastY) => {\n let [pathCommand] = seg;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = absCommand !== pathCommand;\n const absoluteSegment = isRelative\n ? absolutizeSegment(seg, index, lastX, lastY)\n : (seg.slice(0) as AbsoluteSegment);\n\n let result = absCommand === \"A\"\n // ? segmentToCubic(absoluteSegment, transformParams)\n ? ([\"C\" as string | number].concat(\n arcToCubic(\n lastX,\n lastY,\n absoluteSegment[1] as number,\n absoluteSegment[2] as number,\n absoluteSegment[3] as number,\n absoluteSegment[4] as number,\n absoluteSegment[5] as number,\n absoluteSegment[6] as number,\n absoluteSegment[7] as number,\n ),\n ) as CSegment)\n : absCommand === \"V\"\n ? ([\"L\", lastX, absoluteSegment[1]] as LSegment)\n : absCommand === \"H\"\n ? ([\"L\", absoluteSegment[1], lastY] as LSegment)\n : absoluteSegment;\n\n // update pathCommand\n pathCommand = result[0];\n const isLongArc = pathCommand === \"C\" && result.length > 7;\n const tempSegment = (\n isLongArc ? result.slice(0, 7) : result.slice(0)\n ) as AbsoluteSegment;\n\n if (isLongArc) {\n path.splice(\n index + 1,\n 0,\n [\"C\" as typeof pathCommand | number].concat(\n result.slice(7),\n ) as CSegment,\n );\n result = tempSegment as CSegment;\n }\n\n if (pathCommand === \"L\") {\n [lx, ly] = projection2d(\n matrixInstance,\n [(result as LSegment)[1], (result as LSegment)[2]],\n origin,\n );\n\n /* istanbul ignore else @preserve */\n if (x !== lx && y !== ly) {\n result = [\"L\", lx, ly];\n } else if (y === ly) {\n result = [\"H\", lx];\n } else if (x === lx) {\n result = [\"V\", ly];\n }\n } else {\n for (j = 1, jj = result.length; j < jj; j += 2) {\n [lx, ly] = projection2d(\n matrixInstance,\n [+result[j], +result[j + 1]],\n origin,\n );\n result[j] = lx;\n result[j + 1] = ly;\n }\n }\n // now update x and y\n x = lx;\n y = ly;\n\n return result;\n }) as AbsoluteArray;\n};\n","import type { CSegment, CurveArray, MSegment, PathCommand } from \"../types\";\n\n/**\n * Reverses all segments of a `pathArray`\n * which consists of only C (cubic-bezier) path commands.\n *\n * @param path the source `pathArray`\n * @returns the reversed `pathArray`\n */\nexport const reverseCurve = (path: CurveArray) => {\n const rotatedCurve = path\n .slice(1)\n .map((x, i, curveOnly) =>\n !i\n ? path[0].slice(1).concat(x.slice(1) as number[])\n : curveOnly[i - 1].slice(-2).concat(x.slice(1))\n )\n .map((x) => x.map((_, i) => x[x.length - i - 2 * (1 - (i % 2))]))\n .reverse() as (MSegment | CSegment)[];\n\n return [[\"M\" as PathCommand | number].concat(rotatedCurve[0].slice(0, 2))]\n .concat(\n rotatedCurve.map((x) => [\"C\" as PathCommand | number].concat(x.slice(2))),\n ) as CurveArray;\n};\n","import type { PathArray } from \"../types\";\nimport { defaultOptions } from \"../options/options\";\nimport { iterate } from \"./iterate\";\nimport { roundSegment } from \"./roundSegment\";\n\n/**\n * Rounds the values of a `pathArray` instance to\n * a specified amount of decimals and returns it.\n *\n * @param path the source `pathArray`\n * @param roundOption the amount of decimals to round numbers to\n * @returns the resulted `pathArray` with rounded values\n */\nexport const roundPath = <T extends PathArray>(\n path: T,\n roundOption?: number | \"off\",\n): T => {\n let { round } = defaultOptions;\n // allow for ZERO decimals\n round = roundOption === \"off\"\n ? roundOption\n : typeof roundOption === \"number\" && roundOption >= 0\n ? roundOption\n : typeof round === \"number\" && round >= 0\n ? round\n : \"off\";\n\n /* istanbul ignore else @preserve */\n if (round === \"off\") return path.slice(0) as T;\n\n return iterate(path, (segment) => {\n return roundSegment(segment, round);\n });\n};\n","// src/morph/fixPath.ts\nimport type { PathArray } from \"../types\";\nimport { parsePathString } from \"../parser/parsePathString\";\nimport { normalizePath } from \"../process/normalizePath\";\nimport { isClosedPath } from \"../util/isClosedPath\";\n\n/**\n * Checks a `PathArray` for an unnecessary `Z` segment\n * and removes it. The `PathArray` is modified in place.\n * In short, if the segment before `Z` extends to `M`,\n * the `Z` segment must be removed.\n *\n * The `pathInput` must be a single path, without\n * sub-paths. For multi-path `<path>` elements,\n * use `splitPath` first and apply this utility on each\n * sub-path separately.\n *\n * @param pathInput the `pathArray` source\n * @returns void\n */\nexport const fixPath = <T extends PathArray>(pathInput: T | string) => {\n const pathArray = parsePathString(pathInput);\n\n /* istanbul ignore else */\n if (isClosedPath(pathArray)) {\n const normalArray = normalizePath(pathArray);\n const length = pathArray.length;\n const segBeforeZ = length - 2;\n const [mx, my] = normalArray[0].slice(1);\n const [x, y] = normalArray[segBeforeZ].slice(-2);\n\n if (mx === x && my === y) {\n pathArray.splice(length - 1, 1);\n }\n }\n};\n","// src/morph/splitCubicSegment.ts\n\nimport { midPoint } from \"../math/midPoint\";\nimport { CubicCoordinates } from \"../types\";\n\n/**\n * Split a cubic Bézier into two cubics at parameter t [0–1].\n *\n * @param x1 - Start point X\n * @param y1 - Start point Y\n * @param x2 - First control point X\n * @param y2 - First control point Y\n * @param x3 - Second control point X\n * @param y3 - Second control point Y\n * @param x4 - End point X\n * @param y4 - End point Y\n * @param t - Parameter in range [0, 1] at which to split\n * @returns Array of two cubic segments, each as [x1,y1, x2,y2, x3,y3, x4,y4]\n */\nexport function splitCubicSegment(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n x4: number,\n y4: number,\n t: number,\n): [CubicCoordinates, CubicCoordinates] {\n const [px01, py01] = midPoint([x1, y1], [x2, y2], t);\n const [px12, py12] = midPoint([x2, y2], [x3, y3], t);\n const [px23, py23] = midPoint([x3, y3], [x4, y4], t);\n\n const [cx0, cy0] = midPoint([px01, py01], [px12, py12], t);\n const [cx1, cy1] = midPoint([px12, py12], [px23, py23], t);\n\n const [px, py] = midPoint([cx0, cy0], [cx1, cy1], t);\n\n return [\n [x1, y1, px01, py01, cx0, cy0, px, py], // first segment\n [px, py, cx1, cy1, px23, py23, x4, y4], // second segment\n ];\n}\n","// src/convert/pathToPolyline.ts\nimport type {\n LSegment,\n PointTuple,\n PolygonArray,\n PolylineArray,\n // PathArray,\n} from \"../types\";\nimport { normalizePath } from \"../process/normalizePath\";\nimport { isPolygonArray } from \"../util/isPolygonArray\";\nimport { isPolylineArray } from \"../util/isPolylineArray\";\nimport { isClosedPath } from \"../util/isClosedPath\";\nimport { error } from \"../util/error\";\n\n/**\n * Converts any `PolyLineArray`/`PolygonArray` path (closed or open) to an explicit polyline (M + L*).\n * If the path is closed (has Z), the Z is replaced with an explicit L back to the initial M point.\n * This allows uniform processing without special-casing Z.\n *\n * @param path string or PathArray\n * @returns PolylineArray (M + L*) — never contains Z\n */\nexport const pathToPolyline = <T extends PolygonArray | PolylineArray>(\n path: string | T,\n): PolylineArray => {\n const normal = normalizePath(path);\n if (!isPolygonArray(normal) && !isPolylineArray(normal)) {\n throw TypeError(\n `${error}: pathValue is not a polyline/polygon`,\n );\n }\n\n // If not closed, return as-is (already a polyline)\n if (!isClosedPath(normal)) {\n return normal as PolylineArray;\n }\n\n // Closed → replace Z with explicit L to initial M\n const result: PolylineArray = [normal[0]]; // Keep M\n const [mx, my] = normal[0].slice(1) as PointTuple;\n\n for (let i = 1; i < normal.length; i++) {\n const seg = normal[i];\n if (seg[0].toUpperCase() === \"Z\") {\n result.push([\"L\", mx, my]);\n } else {\n result.push(seg as LSegment);\n }\n }\n\n return result;\n};\n","// src/morph/splitLineToCount.ts\n\n/**\n * Split a line segment into `count` smaller segments of equal length\n * using the same repeated front-cutting strategy as splitCubicToCount.\n *\n * Does NOT mutate input.\n *\n * @param x1 - Start point X\n * @param y1 - Start point Y\n * @param x2 - End point X\n * @param y2 - End point Y\n * @param count - Number of segments to split into\n * @returns Array of `count` line segments, each as [x1, y1, x2, y2]\n */\nexport default function splitLineToCount(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n count: number,\n): Array<[number, number, number, number]> {\n if (count <= 1) return [[x1, y1, x2, y2]];\n\n const result: Array<[number, number, number, number]> = [];\n const dx = x2 - x1;\n const dy = y2 - y1;\n\n let currentX = x1;\n let currentY = y1;\n\n // Loop count times to produce count segments\n // We generate points at 1/count, 2/count, ..., count/count\n let i = 0;\n while (i < count) {\n const t = 1 / (count - i);\n const nextX = x1 + t * dx;\n const nextY = y1 + t * dy;\n\n result.push([currentX, currentY, nextX, nextY]);\n\n currentX = nextX;\n currentY = nextY;\n i++;\n }\n\n return result;\n}\n","// src/morph/getPathSplits.ts\n\nimport type { CSegment, CurveArray, PointTuple, PolylineArray } from \"../types\";\nimport { getLineLength } from \"../math/lineTools\";\nimport { getCubicLength } from \"../math/cubicTools\";\nimport { getTotalLength } from \"../util/getTotalLength\";\nimport { isPolylineArray } from \"../util/isPolylineArray\";\nimport { error } from \"../util/error\";\nimport { iterate } from \"../process/iterate\";\n\n/**\n * Determine the right amount of splits for each segment in a given PathArray\n * and for a target total amount of sub-segments.\n * For a triangle path \"M0,0 L600,300 L0,600 Z\" we have 3 equal lines,\n * we can easily do 4 splits per line and go to town, however, most triangles\n * are not even so we need to take side lengths into account.\n * @param path The target PathArray\n * @param target The total amount of sub-segments\n * @returns an array of numbers reprezenting the sub-segment count for each segment\n */\nexport function getPathSplits<T extends PolylineArray | CurveArray>(\n path: T,\n target: number,\n): number[] {\n if (target <= 1) throw new TypeError(`${error}: target must be >= 2`);\n\n const totalLength = getTotalLength(path);\n if (totalLength === 0) return Array(path.length).fill(1);\n\n const idealSegLen = totalLength / target; // minus M segment\n const isPoly = isPolylineArray(path);\n\n const splits: number[] = [1]; // M gets 0 splits\n const lengths: number[] = [0]; // M has 0 length\n\n // First pass: measure each segment length\n iterate(path, (seg, i, prevX, prevY) => {\n if (i > 0) {\n const [endX, endY] = seg.slice(-2) as PointTuple;\n const segLen = isPoly\n ? getLineLength(prevX, prevY, endX, endY)\n : getCubicLength(\n prevX,\n prevY,\n seg[1],\n seg[2],\n (seg as CSegment)[3],\n (seg as CSegment)[4],\n (seg as CSegment)[5],\n (seg as CSegment)[6],\n );\n lengths.push(segLen);\n splits.push(1); // placeholder\n }\n });\n\n // Second pass: distribute splits proportionally\n let totalAllocated = 1; // 1 stands for first M segment\n\n for (let i = 1; i < lengths.length; i++) {\n const segLen = lengths[i];\n const desired = segLen > idealSegLen ? Math.round(segLen / idealSegLen) : 1;\n\n splits[i] = desired;\n totalAllocated += desired;\n }\n\n // Third pass: adjust to hit exact target\n let diff = target - totalAllocated;\n\n if (diff !== 0) {\n const candidates: PointTuple[] = [];\n for (let i = 1; i < lengths.length; i++) {\n // istanbul ignore else\n if (lengths[i] > 0) {\n candidates.push([i, lengths[i]]);\n }\n }\n\n const cLen = candidates.length;\n\n // istanbul ignore else - impossible to test that edge case\n if (diff < 0) {\n // sort ascending\n candidates.sort((a, b) => a[1] - b[1]);\n for (let i = 0; i < cLen; i++) {\n const idx = candidates[i][0];\n if (splits[idx] > 1 && candidates[i][1] > 0) {\n splits[idx]--;\n diff++;\n }\n if (diff === 0) break;\n else if (i === cLen - 1) i = 0;\n }\n } else if (diff > 0) {\n // sort descending\n candidates.sort((a, b) => b[1] - a[1]);\n for (let i = 0; i < cLen; i++) {\n const idx = candidates[i][0];\n if (candidates[i][1] > 0) {\n splits[idx]++;\n diff--;\n }\n if (diff === 0) break;\n else if (i === cLen - 1) i = 0;\n }\n }\n }\n return splits;\n}\n","// src/morph/splitLinePathToCount.ts\n\nimport type { PointTuple, PolylineArray } from \"../types\";\nimport splitLineToCount from \"./splitLineToCount\";\nimport { getPathSplits } from \"./getPathSplits\";\nimport { error } from \"../util/error\";\n\n/**\n * Splits a PolylineArray so that it has exactly `target` line segments.\n *\n * @param path - The polyline array to split\n * @param target - The desired number of line segments\n * @returns The modified polyline array with the target segment count\n */\nexport function splitLinePathToCount<T extends PolylineArray>(\n path: T,\n target: number,\n): T {\n if (path.length < 2 || target <= 1) return path;\n\n const splits = getPathSplits(path, target);\n let totalAdded = 0;\n\n const newPath = [path[0]] as unknown as T;\n const pathLen = path.length;\n let currentX = path[0][1];\n let currentY = path[0][2];\n\n // Build path using splits\n for (let i = 1; i < pathLen; i++) {\n const seg = path[i];\n const [endX, endY] = seg.slice(1) as PointTuple;\n\n const count = splits[i];\n\n // istanbul ignore else\n if (count >= 1) {\n const subLines = splitLineToCount(currentX, currentY, endX, endY, count);\n\n for (const sub of subLines) {\n newPath.push([\"L\", sub[2], sub[3]]);\n totalAdded++;\n }\n }\n\n currentX = endX;\n currentY = endY;\n }\n\n // Final safety: if somehow still wrong, log it\n // istanbul ignore if - this might possibly be impossible to test\n if (newPath.length !== target) {\n console.warn(\n `${error}: requested ${target} segments, got ${newPath.length}. Adjusted on last segment.`,\n );\n }\n\n return newPath;\n}\n","// src/morph/splitCubicToCount.ts\n\nimport { CubicCoordinates } from \"../types\";\nimport { splitCubicSegment } from \"./splitCubicSegment\";\n\n/**\n * Split a cubic Bézier into `count` segments of roughly equal parameter length.\n * Does NOT mutate input parameters.\n *\n * @param x1 - Start point X\n * @param y1 - Start point Y\n * @param x2 - First control point X\n * @param y2 - First control point Y\n * @param x3 - Second control point X\n * @param y3 - Second control point Y\n * @param x4 - End point X\n * @param y4 - End point Y\n * @param count - Number of segments to split into\n * @returns Array of `count` cubic segments, each as [x1,y1,x2,y2,x3,y3,x4,y4]\n */\nexport function splitCubicToCount(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n x4: number,\n y4: number,\n count: number,\n): Array<CubicCoordinates> {\n if (count <= 1) return [[x1, y1, x2, y2, x3, y3, x4, y4]];\n\n const result: Array<CubicCoordinates> = [];\n\n // Work on local copies to avoid mutating inputs\n let cx1 = x1;\n let cy1 = y1;\n let cx2 = x2;\n let cy2 = y2;\n let cx3 = x3;\n let cy3 = y3;\n let cx4 = x4;\n let cy4 = y4;\n\n let i = 0;\n while (i < count) {\n const t = 1 / (count - i);\n const [first, second] = splitCubicSegment(\n cx1,\n cy1,\n cx2,\n cy2,\n cx3,\n cy3,\n cx4,\n cy4,\n t,\n );\n\n result.push(first);\n\n // Update working curve to the remaining (second) part\n [cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4] = second;\n i++;\n }\n\n return result;\n}\n","// src/morph/splitCubicPathToCount.ts\nimport type { CSegment, CurveArray, PointTuple } from \"../types\";\nimport { splitCubicToCount } from \"./splitCubicToCount.ts\";\nimport { getPathSplits } from \"./getPathSplits.ts\";\nimport { error } from \"../util/error.ts\";\n\n/**\n * Splits a CurveArray so that it has exactly `target` cubic segments.\n *\n * @param path - The curve array to split\n * @param target - The desired number of cubic segments\n * @returns The modified curve array with the target segment count\n */\nexport function splitCurvePathToCount<T extends CurveArray>(\n path: T,\n target: number,\n): T {\n // istanbul ignore else\n if (path.length < 2 || target <= 1) return path;\n\n const splits = getPathSplits(path, target);\n let totalAdded = 0;\n\n const newPath = [path[0]] as unknown as T; // keep M\n const pathLen = path.length;\n let currentX = path[0][1];\n let currentY = path[0][2];\n\n for (let i = 1; i < pathLen; i++) {\n const seg = path[i] as CSegment /*| ZSegment*/;\n const [endX, endY] = seg.slice(-2) as PointTuple;\n\n const count = splits[i];\n\n // istanbul ignore else\n if (count >= 1) {\n const subs = splitCubicToCount(\n currentX,\n currentY,\n seg[1],\n seg[2],\n seg[3],\n seg[4],\n seg[5],\n seg[6],\n count,\n );\n\n for (const sub of subs) {\n newPath.push([\"C\", sub[2], sub[3], sub[4], sub[5], sub[6], sub[7]]);\n totalAdded++;\n }\n }\n currentX = endX;\n currentY = endY;\n }\n\n // Final safety: if somehow still wrong, log it\n // istanbul ignore if\n if (newPath.length !== target) {\n console.warn(\n `${error}: requested ${target} segments, got ${newPath.length}.`,\n );\n }\n\n return newPath;\n}\n","// src/morph/getRotatedPath.ts\n\nimport {\n CSegment,\n // CurveArray,\n LSegment,\n MorphPathArray,\n MSegment,\n PointTuple,\n // PolylineArray,\n ZSegment,\n} from \"../types.ts\";\nimport { error } from \"../util/error.ts\";\n\n/**\n * Returns all possible rotations of a path (line or curve) by shifting the start point.\n * Each rotation is a new PathArray starting at a different original segment.\n *\n * @param path PathArray (M + L/C + optional Z) — must be single subpath, normalized\n * @returns PathArray[] — array of all possible rotations\n */\nexport function getRotations<T extends MorphPathArray>(a: T) {\n const pathLen = a.length;\n const pointCount = pathLen - 1;\n let path: T;\n const result = [] as T[];\n\n for (let idx = 0; idx < pathLen; idx++) {\n path = [] as unknown as T;\n for (let i = 0; i < pathLen; i++) {\n let oldSegIdx = idx + i;\n let seg: LSegment | CSegment | MSegment | ZSegment;\n\n if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === \"M\")) {\n seg = a[oldSegIdx];\n path.push([\"M\", ...seg.slice(-2)] as MSegment);\n continue;\n }\n if (oldSegIdx >= pathLen) {\n oldSegIdx -= pointCount;\n }\n path.push(a[oldSegIdx] as never);\n }\n result.push(path);\n }\n return result;\n}\n\n/**\n * Finds the best rotation of pathA to match pathB by minimizing sum of squared distances\n * between corresponding endpoints.\n *\n * Works with both polygon (L) and curve (C) arrays.\n *\n * @param pathA PathArray to rotate (will be modified in rotation options)\n * @param pathB PathArray reference (fixed)\n * @returns PathArray — best rotation of pathA\n */\nexport function getRotatedPath<T extends MorphPathArray>(\n pathA: T,\n pathB: T,\n computedRotations?: T[],\n): T {\n const rotations = computedRotations || getRotations(pathA);\n const segCountA = pathA.length;\n const segCountB = pathB.length;\n\n if (segCountA !== segCountB) {\n throw new TypeError(\n error +\n \": paths must have the same number of segments after equalization\",\n );\n }\n\n let bestIndex = 0;\n let minDistanceSq = Infinity;\n\n for (let ri = 0; ri < rotations.length; ri++) {\n const rotation = rotations[ri];\n const rLen = rotation.length;\n let sumDistSq = 0;\n\n // Compare endpoints of each segment (skip M, use end coords of L/C)\n for (let i = 0; i < rLen; i++) {\n const segA = rotation[i];\n const segB = pathB[i];\n\n const endA = segA.slice(-2) as PointTuple;\n const endB = segB.slice(-2) as PointTuple;\n\n const dx = endA[0] - endB[0];\n const dy = endA[1] - endB[1];\n sumDistSq += dx * dx + dy * dy;\n }\n\n if (sumDistSq < minDistanceSq) {\n minDistanceSq = sumDistSq;\n bestIndex = ri;\n }\n }\n\n return rotations[bestIndex];\n}\n","// src/morph/equalizeSegments.ts\nimport type {\n CurveArray,\n EqualizationOptions,\n MorphPathArray,\n PathArray,\n PolylineArray,\n} from \"../types\";\nimport { pathToCurve } from \"../convert/pathToCurve\";\nimport { pathToPolyline } from \"./pathToPolyline\";\nimport { reversePath } from \"../process/reversePath\";\nimport { normalizePath } from \"../process/normalizePath\";\nimport { splitLinePathToCount } from \"./splitLinePathToCount\";\nimport { splitCurvePathToCount } from \"./splitCurvePathToCount\";\nimport { samplePolygon } from \"./samplePolygon\";\nimport { polygonArea } from \"../math/polygonTools\";\nimport { getRotatedPath } from \"./getRotatedPath\";\nimport { fixPath } from \"./fixPath\";\nimport { isPolygonArray } from \"../util/isPolygonArray\";\nimport { isPolylineArray } from \"../util/isPolylineArray\";\nimport { getTotalLength } from \"../util/getTotalLength\";\nimport { roundPath } from \"../process/roundPath\";\n\nconst equalizeSegmentsDefaults: EqualizationOptions = {\n mode: \"auto\", // \"line\" | \"curve\" | \"auto\"\n sampleSize: 10, // for line option\n roundValues: 4, // 4 decimals\n reverse: true,\n close: false,\n target: undefined,\n};\n\n/**\n * Equalizes two paths for morphing (single subpath only).\n *\n * @see https://minus-ze.ro/posts/morphing-arbitrary-paths-in-svg/\n * @param path1 - First path string or PathArray\n * @param path2 - Second path string or PathArray\n * @param initialCfg - Equalization options\n * @returns Tuple of two equalized MorphPathArrays\n *\n * @example\n * ```ts\n * const [eq1, eq2] = equalizeSegments('M0 0L100 0L50 100Z', 'M0 0L100 0L100 100L0 100Z')\n * // eq1.length === eq2.length\n * ```\n */\nexport const equalizeSegments = (\n path1: PathArray | string,\n path2: PathArray | string,\n initialCfg: EqualizationOptions = {},\n): [MorphPathArray, MorphPathArray] => {\n const { close, mode, reverse, roundValues, target: initialTarget } = Object\n .assign(equalizeSegmentsDefaults, initialCfg);\n let p1 = normalizePath(path1) as MorphPathArray;\n let p2 = normalizePath(path2) as MorphPathArray;\n\n // fix paths\n fixPath(p1);\n fixPath(p2);\n\n let bothPoly = (isPolygonArray(p1) || isPolylineArray(p1)) &&\n (isPolygonArray(p2) || isPolylineArray(p2));\n\n if (bothPoly && mode === \"auto\") {\n p1 = pathToPolyline(p1 as PolylineArray);\n p2 = pathToPolyline(p2 as PolylineArray);\n } else {\n bothPoly = false;\n p1 = pathToCurve(p1);\n p2 = pathToCurve(p2);\n }\n\n // Sample and check draw direction\n const area1 = polygonArea(samplePolygon(p1));\n const area2 = polygonArea(samplePolygon(p2));\n\n if (reverse !== false && (Math.sign(area1) !== Math.sign(area2))) {\n p2 = reversePath(p2);\n }\n\n // Get segment counts\n const segCount1 = p1.length;\n const segCount2 = p2.length;\n const minTarget = Math.max(segCount1, segCount2);\n let target = minTarget;\n\n if (typeof initialTarget !== \"number\") {\n const len1 = getTotalLength(p1);\n const len2 = getTotalLength(p2);\n const avgLen = (len1 + len2) / 2;\n const maxSegCount = Math.max(segCount1, segCount2);\n const avgSegLen = avgLen / maxSegCount;\n const idealSegCount = Math.max(\n minTarget,\n Math.round(avgLen / Math.max(avgSegLen, 1)),\n );\n target = Math.min(idealSegCount, Math.max(segCount1, segCount2) * 3);\n } else {\n if (initialTarget >= minTarget) target = initialTarget;\n else {\n console.warn(\n 'equalizeSegments \"target\" option: ' + initialTarget +\n \", expected >= \" + minTarget,\n );\n }\n }\n\n let equalP1: MorphPathArray = p1;\n let equalP2: MorphPathArray = p2;\n\n if (bothPoly) {\n equalP1 = splitLinePathToCount(\n p1 as PolylineArray,\n target,\n ) as MorphPathArray;\n equalP2 = splitLinePathToCount(\n p2 as PolylineArray,\n target,\n ) as MorphPathArray;\n } else {\n equalP1 = splitCurvePathToCount(p1 as CurveArray, target) as MorphPathArray;\n equalP2 = splitCurvePathToCount(p2 as CurveArray, target) as MorphPathArray;\n }\n\n // Point alignment\n equalP2 = getRotatedPath(equalP2, equalP1);\n\n if (typeof roundValues === \"number\" && roundValues !== 4) {\n equalP1 = roundPath(equalP1, roundValues);\n equalP2 = roundPath(equalP2, roundValues);\n }\n\n if (close) {\n equalP1.push([\"Z\"] as never);\n equalP2.push([\"Z\"] as never);\n }\n\n return [equalP1, equalP2];\n};\n","import type { BBoxMaxima, PointTuple } from \"../types.ts\";\n\n/**\n * Checks if a point is inside a bounding box.\n *\n * @param bbox - The bounding box as [minX, minY, maxX, maxY]\n * @param point - The point as [x, y]\n * @returns True if the point is inside or on the edge of the bounding box\n */\nexport const isPointInsideBBox = (\n bbox: BBoxMaxima,\n [x, y]: PointTuple,\n): boolean => {\n const [minX, minY, maxX, maxY] = bbox;\n return x >= minX && x <= maxX && y >= minY && y <= maxY;\n};\n","import type { BBoxMaxima } from \"../types.ts\";\n\nimport { isPointInsideBBox } from \"./isPointInsideBBox.ts\";\n\n/**\n * Checks if two bounding boxes intersect.\n *\n * @param a - First bounding box as [minX, minY, maxX, maxY]\n * @param b - Second bounding box as [minX, minY, maxX, maxY]\n * @returns True if the bounding boxes overlap\n */\nexport const boundingBoxIntersect = (a: BBoxMaxima, b: BBoxMaxima): boolean => {\n const [ax1, ay1, ax2, ay2] = a;\n const [bx1, by1, bx2, by2] = b;\n // return ax1 <= bx2 && ax2 >= bx1 && ay1 <= by2 && ay2 >= by1;\n return (\n isPointInsideBBox(b, [ax1, ay1]) ||\n isPointInsideBBox(b, [ax2, ay1]) ||\n isPointInsideBBox(b, [ax1, ay2]) ||\n isPointInsideBBox(b, [ax2, ay2]) ||\n isPointInsideBBox(a, [bx1, by1]) ||\n isPointInsideBBox(a, [bx2, by1]) ||\n isPointInsideBBox(a, [bx1, by2]) ||\n isPointInsideBBox(a, [bx2, by2]) ||\n // edge overlap without corner inside\n (ax1 < bx2 && ax1 > bx1 || bx1 < ax2 && bx1 > ax1) &&\n (ay1 < by2 && ay1 > by1 || by1 < ay2 && by1 > ay1)\n );\n};\n","import type { NormalArray } from \"../types.ts\";\n\n/**\n * Create a degenerate `PathArray` at a given coordinate\n * to serve as a pair for another `PathArray`.\n * @param param0 An [x, y] tuple for the coordinate\n * @returns A new degenerate `PathArray`\n */\nexport const createPlaceholder = (\n [atx, aty]: [number, number],\n): NormalArray => {\n // Tiny square at point\n const r = 0.001;\n return [\n [\"M\", atx, aty],\n [\"L\", atx + r, aty],\n [\"L\", atx + r, aty + r],\n [\"L\", atx, aty + r],\n [\"L\", atx, aty],\n [\"Z\"],\n ];\n};\n","import type { NormalArray, PathFeature, PointTuple } from \"../types.ts\";\nimport { isPointInsideBBox } from \"../intersect/isPointInsideBBox.ts\";\nimport { boundingBoxIntersect } from \"../intersect/boundingBoxIntersect.ts\";\nimport { createPlaceholder } from \"./createPlaceholder\";\n\ninterface CandidateScore {\n index: number;\n hasOverlap: boolean;\n boxIntersect: boolean;\n sizeDifference: number;\n centeredDistance: number;\n}\n\nfunction getBestMatch(\n target: PathFeature,\n candidates: PathFeature[],\n): PathFeature | null {\n const targetBBox = target.bbox;\n\n // Single pass: collect metrics for every candidate\n const potentialCandidates: CandidateScore[] = [];\n\n for (let i = 0; i < candidates.length; i++) {\n const { bbox, size } = candidates[i];\n\n const dx = targetBBox.cx - bbox.cx;\n const dy = targetBBox.cy - bbox.cy;\n const centeredDistance = Math.sqrt(dx * dx + dy * dy);\n\n const sizeDifference = Math.abs(target.size - size) /\n Math.max(target.size, size, 1e-6);\n\n const hasOverlap = isPointInsideBBox(\n [targetBBox.x, targetBBox.y, targetBBox.x2, targetBBox.y2],\n [bbox.cx, bbox.cy],\n ) || isPointInsideBBox(\n [bbox.x, bbox.y, bbox.x2, bbox.y2],\n [targetBBox.cx, targetBBox.cy],\n );\n\n const boxIntersect = boundingBoxIntersect(\n [targetBBox.x, targetBBox.y, targetBBox.x2, targetBBox.y2],\n [bbox.x, bbox.y, bbox.x2, bbox.y2],\n );\n\n potentialCandidates.push({\n index: i,\n hasOverlap,\n boxIntersect,\n sizeDifference,\n centeredDistance,\n });\n }\n\n // Filter phase: strict overlap — pick smallest distance\n const overlaping = potentialCandidates.filter((c) =>\n c.hasOverlap && c.boxIntersect\n );\n if (overlaping.length > 0) {\n let best = overlaping[0];\n for (let i = 1; i < overlaping.length; i++) {\n if (overlaping[i].centeredDistance < best.centeredDistance) {\n best = overlaping[i];\n }\n }\n return candidates.splice(best.index, 1)[0];\n }\n\n return null;\n}\n\n/**\n * Matches paths from two sets by proximity and size similarity.\n * Unmatched paths receive placeholder paths at their centroid.\n *\n * @param fromPaths - Source path features to match from\n * @param toPaths - Target path features to match to\n * @returns Array of paired NormalArrays [from, to]\n */\nexport function matchPaths(\n fromPaths: PathFeature[],\n toPaths: PathFeature[],\n): [NormalArray, NormalArray][] {\n const pairs: [NormalArray, NormalArray][] = [];\n\n fromPaths.sort((a, b) => b.size - a.size);\n toPaths.sort((a, b) => b.size - a.size);\n\n while (fromPaths.length > 0) {\n const from = fromPaths.shift()!;\n const bestTo = getBestMatch(from, toPaths);\n\n if (bestTo) {\n pairs.push([from.path, bestTo.path]);\n } else {\n const fromCentroid: PointTuple = [from.bbox.cx, from.bbox.cy];\n pairs.push([from.path, createPlaceholder(fromCentroid)]);\n }\n }\n\n while (toPaths.length > 0) {\n const to = toPaths.shift()!;\n const toCentroid: PointTuple = [to.bbox.cx, to.bbox.cy];\n pairs.push([createPlaceholder(toCentroid), to.path]);\n }\n\n return pairs;\n}\n","import type { NormalArray, PathFeature } from \"../types.ts\";\nimport { getPathBBox } from \"../util/getPathBBox.ts\";\nimport { polygonArea } from \"../math/polygonTools.ts\";\nimport { samplePolygon } from \"./samplePolygon.ts\";\nimport { isPolygonArray } from \"../util/isPolygonArray.ts\";\nimport { isPolylineArray } from \"../util/isPolylineArray.ts\";\n\n/**\n * Classifies paths into outer (containing) and inner (hole) paths.\n *\n * @param paths - Array of normalized path arrays to classify\n * @returns Object with `outers` (containing shapes) and `inners` (holes)\n */\nexport const classifyPaths = (\n paths: NormalArray[],\n): {\n outers: PathFeature[];\n inners: PathFeature[];\n} => {\n const outers: PathFeature[] = [];\n const inners: PathFeature[] = [];\n\n for (const path of paths) {\n const signedArea = polygonArea(samplePolygon(path));\n const bbox = getPathBBox(path);\n const feature: PathFeature = {\n isPoly: isPolygonArray(path) || isPolylineArray(path),\n size: bbox.width * bbox.height,\n path,\n signedArea,\n area: Math.abs(signedArea),\n bbox,\n };\n\n if (signedArea > 0) {\n outers.push(feature);\n } else {\n inners.push(feature);\n }\n }\n\n return { outers, inners };\n};\n","import type {\n MorphPathArray,\n PathArray,\n PathsEqualizationOptions,\n} from \"../types.ts\";\nimport { isMultiPath } from \"../util/isMultiPath\";\nimport { splitPath } from \"../process/splitPath\";\nimport { equalizeSegments } from \"./equalizeSegments\";\nimport { matchPaths } from \"./matchPaths\";\nimport { normalizePath } from \"../process/normalizePath\";\nimport { reversePath } from \"../process/reversePath\";\nimport { polygonArea } from \"../math/polygonTools\";\nimport { samplePolygon } from \"./samplePolygon\";\nimport { classifyPaths } from \"./classifyPaths.ts\";\n\nconst equalizePathsDefaults: PathsEqualizationOptions = {\n mode: \"auto\", // \"line\" | \"curve\" | \"auto\"\n roundValues: 4, // 4 decimals\n close: false,\n sampleSize: 10,\n};\n\n/**\n * Equalizes two paths for morphing (single/multi subpath).\n *\n * @see https://minus-ze.ro/posts/morphing-arbitrary-paths-in-svg/\n * @param pathInput1 - First path string or PathArray\n * @param pathInput2 - Second path string or PathArray\n * @param initialCfg - Configuration options for equalization\n * @returns Tuple of two equalized MorphPathArrays\n *\n * @example\n * ```ts\n * const [eq1, eq2] = equalizePaths('M0 0L100 0L50 100Z', 'M0 0L100 0L100 100L0 100Z')\n * // eq1.length === eq2.length — ready for morphing\n * ```\n */\nexport const equalizePaths = (\n pathInput1: string | PathArray,\n pathInput2: string | PathArray,\n initialCfg = {},\n) => {\n const cfg = Object.assign(equalizePathsDefaults, initialCfg);\n const p1 = normalizePath(pathInput1);\n const p2 = normalizePath(pathInput2);\n\n const multi1 = isMultiPath(p1);\n const multi2 = isMultiPath(p2);\n\n if (!multi1 && !multi2) {\n // Single subpath — use fast path\n return equalizeSegments(p1, p2, cfg);\n }\n\n // Global direction alignment (optional — helps with overall winding)\n const globalArea1 = polygonArea(samplePolygon(p1));\n const globalArea2 = polygonArea(samplePolygon(p2));\n\n let path1 = p1;\n let path2 = p2;\n\n // all paths must be clockwise\n if (Math.sign(globalArea1) < 0) {\n path1 = reversePath(path1);\n }\n if (Math.sign(globalArea2) < 0) {\n path2 = reversePath(path2);\n }\n\n // Multi-subpath: split and match\n const multiPath1 = splitPath(path1);\n const multiPath2 = splitPath(path2);\n\n const { outers: outers1, inners: inners1 } = classifyPaths(multiPath1);\n const { outers: outers2, inners: inners2 } = classifyPaths(multiPath2);\n\n // Match outers\n const outerPairs = matchPaths(outers1, outers2);\n\n // Match holes (simple: pair by area, ignore nesting for now)\n const innerPairs = matchPaths(inners1, inners2);\n\n // Equalize each pair\n const equalizedPairs: [MorphPathArray, MorphPathArray][] = [];\n\n for (const [from, to] of [...outerPairs, ...innerPairs]) {\n const [eqFrom, eqTo] = equalizeSegments(from, to, {\n ...cfg,\n reverse: false,\n });\n equalizedPairs.push([eqFrom, eqTo]);\n }\n\n // Reassemble into final morphable paths\n const finalFrom = equalizedPairs.map((p) => p[0]).flat() as MorphPathArray;\n const finalTo = equalizedPairs.map((p) => p[1]).flat() as MorphPathArray;\n\n return [finalFrom, finalTo] as [MorphPathArray, MorphPathArray];\n};\n","import type {\n CubicCoordinates,\n IntersectionOptions,\n IntersectionPoint,\n PointAtLength,\n} from \"../types.ts\";\nimport {\n getCubicBBox,\n getCubicLength,\n getPointAtCubicLength,\n} from \"../math/cubicTools.ts\";\nimport { distanceEpsilon } from \"../util.ts\";\nimport { roundTo } from \"../math/roundTo.ts\";\nimport { boundingBoxIntersect } from \"./boundingBoxIntersect.ts\";\n\nconst intersect = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n x4: number,\n y4: number,\n) => {\n if (\n Math.max(x1, x2) < Math.min(x3, x4) ||\n Math.min(x1, x2) > Math.max(x3, x4) ||\n Math.max(y1, y2) < Math.min(y3, y4) ||\n Math.min(y1, y2) > Math.max(y3, y4)\n ) {\n return;\n }\n const nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),\n ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),\n denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);\n\n if (!denominator) {\n return;\n }\n const px = nx / denominator,\n py = ny / denominator,\n px2 = roundTo(px, 2),\n py2 = roundTo(py, 2);\n if (\n px2 < roundTo(Math.min(x1, x2), 2) ||\n px2 > roundTo(Math.max(x1, x2), 2) ||\n px2 < roundTo(Math.min(x3, x4), 2) ||\n px2 > roundTo(Math.max(x3, x4), 2) ||\n py2 < roundTo(Math.min(y1, y2), 2) ||\n py2 > roundTo(Math.max(y1, y2), 2) ||\n py2 < roundTo(Math.min(y3, y4), 2) ||\n py2 > roundTo(Math.max(y3, y4), 2)\n ) {\n return;\n }\n return { x: px, y: py };\n};\n\nexport const interHelper = (\n bez1: CubicCoordinates,\n bez2: CubicCoordinates,\n config?: IntersectionOptions,\n) => {\n const bbox1 = getCubicBBox(...bez1);\n const bbox2 = getCubicBBox(...bez2);\n const { justCount, epsilon } = Object.assign({\n justCount: true,\n epsilon: distanceEpsilon,\n }, config);\n\n if (!boundingBoxIntersect(bbox1, bbox2)) {\n return justCount ? 0 : [] as IntersectionPoint[];\n }\n const l1 = getCubicLength(...bez1),\n l2 = getCubicLength(...bez2),\n n1 = Math.max((l1 / 5) >> 0, 1),\n n2 = Math.max((l2 / 5) >> 0, 1),\n points1: PointAtLength[] = [],\n points2: PointAtLength[] = [],\n xy: Record<string, string> = {};\n // deno-lint-ignore prefer-const\n let res = justCount ? 0 : [] as IntersectionPoint[];\n for (let i = 0; i < n1 + 1; i++) {\n const p = getPointAtCubicLength(...bez1, (i / n1) * l1);\n points1.push({ x: p.x, y: p.y, t: i / n1 });\n }\n for (let i = 0; i < n2 + 1; i++) {\n const p = getPointAtCubicLength(...bez2, (i / n2) * l2);\n points2.push({ x: p.x, y: p.y, t: i / n2 });\n }\n for (let i = 0; i < n1; i++) {\n for (let j = 0; j < n2; j++) {\n const maxLimit = 1 + epsilon,\n di = points1[i],\n di1 = points1[i + 1],\n dj = points2[j],\n dj1 = points2[j + 1],\n ci = Math.abs(di1.x - di.x) < .001 ? \"y\" : \"x\",\n cj = Math.abs(dj1.x - dj.x) < .001 ? \"y\" : \"x\",\n is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);\n if (is) {\n if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {\n continue;\n }\n xy[is.x.toFixed(4)] = is.y.toFixed(4);\n const t1 = di.t +\n Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),\n t2 = dj.t +\n Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);\n\n // istanbul ignore else\n if (t1 >= 0 && t1 <= maxLimit && t2 >= 0 && t2 <= maxLimit) {\n if (justCount) {\n (res as number)++;\n } else {\n (res as IntersectionPoint[]).push({\n x: is.x,\n y: is.y,\n t1: Math.min(t1, 1),\n t2: Math.min(t2, 1),\n });\n }\n }\n }\n }\n }\n return res;\n};\n","import type {\n CubicCoordinates,\n IntersectionPoint,\n PathArray,\n} from \"../types.ts\";\nimport { pathToCurve } from \"../convert/pathToCurve.ts\";\nimport { interHelper } from \"./interHelper.ts\";\n\n/**\n * Finds intersection points between two paths.\n *\n * @param pathInput1 - First path string or PathArray\n * @param pathInput2 - Second path string or PathArray\n * @param justCount - If true, returns the count of intersections; if false, returns the intersection points\n * @returns The number of intersections (when justCount is true) or an array of IntersectionPoint objects\n *\n * @example\n * ```ts\n * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)\n * // => 1\n * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)\n * // => [{ x: 50, y: 25, t1: 0.5, t2: 0.5 }]\n * ```\n */\nexport const pathsIntersection = <T extends string | PathArray>(\n pathInput1: T,\n pathInput2: T,\n justCount = /* istanbul ignore next */ true,\n) => {\n const path1 = pathToCurve(pathInput1);\n const path2 = pathToCurve(pathInput2);\n let x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n x1m = 0,\n y1m = 0,\n x2m = 0,\n y2m = 0,\n bez1: CubicCoordinates = [x1, y1, x1, y1, x1m, y1m, x1m, y1m],\n bez2: CubicCoordinates = [x2, y2, x2, y2, x2m, y2m, x2m, y2m],\n countResult = 0;\n const pointsResult: IntersectionPoint[] = [];\n const pathLen1 = path1.length;\n const pathLen2 = path2.length;\n\n for (let i = 0; i < pathLen1; i++) {\n const seg1 = path1[i];\n if (seg1[0] == \"M\") {\n x1 = seg1[1];\n y1 = seg1[2];\n x1m = x1;\n y1m = y1;\n } else {\n /* istanbul ignore else */\n if (seg1[0] == \"C\") {\n bez1 = [x1, y1, seg1[1], seg1[2], seg1[3], seg1[4], seg1[5], seg1[6]];\n x1 = bez1[6];\n y1 = bez1[7];\n } else {\n bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];\n x1 = x1m;\n y1 = y1m;\n }\n for (let j = 0; j < pathLen2; j++) {\n const seg2 = path2[j];\n // istanbul ignore else\n if (seg2[0] == \"M\") {\n x2 = seg2[1];\n y2 = seg2[2];\n x2m = x2;\n y2m = y2;\n } else if (seg2[0] == \"C\") {\n bez2 = [\n x2,\n y2,\n seg2[1],\n seg2[2],\n seg2[3],\n seg2[4],\n seg2[5],\n seg2[6],\n ];\n x2 = bez2[6];\n y2 = bez2[7];\n // dead code, pathToCurve is almost always made of M/C\n // } else {\n // bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];\n // x2 = x2m;\n // y2 = y2m;\n }\n const intr = interHelper(bez1, bez2, { justCount });\n if (justCount) {\n // (res as number) += intr;\n countResult += intr as number;\n } else {\n // Include additional segment properties, maybe not\n // const kk = (intr as IntersectionPoint[]).length;\n // for (let k = 0; k < kk; k++) {\n // intr[k].segment1 = i;\n // intr[k].segment2 = j;\n // intr[k].bez1 = bez1;\n // intr[k].bez2 = bez2;\n // }\n // (res as IntersectionPoint[]) = (res as IntersectionPoint[]).concat(intr);\n pointsResult.push(...intr as IntersectionPoint[]);\n }\n }\n }\n }\n return justCount ? countResult : pointsResult;\n};\n","\"use strict\";\nimport { version } from \"../package.json\";\nimport CSSMatrix from \"@thednp/dommatrix\";\nimport { arcTools } from \"./math/arcTools.ts\";\nimport { bezierTools } from \"./math/bezier.ts\";\nimport { cubicTools } from \"./math/cubicTools.ts\";\nimport { lineTools } from \"./math/lineTools.ts\";\nimport { quadTools } from \"./math/quadTools.ts\";\nimport { polygonTools } from \"./math/polygonTools.ts\";\n\nimport { distanceSquareRoot } from \"./math/distanceSquareRoot.ts\";\nimport { midPoint } from \"./math/midPoint.ts\";\nimport { rotateVector } from \"./math/rotateVector.ts\";\nimport { roundTo } from \"./math/roundTo.ts\";\n\nimport type { PathArray, PointTuple, TransformObjectValues } from \"./types.ts\";\nimport type {\n Options,\n TransformEntries,\n TransformObject,\n} from \"./interface.ts\";\nimport { defaultOptions } from \"./options/options.ts\";\n\nimport { pathToAbsolute } from \"./convert/pathToAbsolute.ts\";\nimport { pathToRelative } from \"./convert/pathToRelative.ts\";\nimport { pathToCurve } from \"./convert/pathToCurve.ts\";\nimport { pathToString } from \"./convert/pathToString.ts\";\n\nimport { error } from \"./util/error.ts\";\nimport { parsePathString } from \"./parser/parsePathString.ts\";\nimport { finalizeSegment } from \"./parser/finalizeSegment.ts\";\nimport { invalidPathValue } from \"./parser/invalidPathValue.ts\";\nimport { isArcCommand } from \"./parser/isArcCommand.ts\";\nimport { isDigit } from \"./parser/isDigit.ts\";\nimport { isDigitStart } from \"./parser/isDigitStart.ts\";\nimport { isMoveCommand } from \"./parser/isMoveCommand.ts\";\nimport { isPathCommand } from \"./parser/isPathCommand.ts\";\nimport { isSpace } from \"./parser/isSpace.ts\";\nimport { paramsCounts } from \"./parser/paramsCount.ts\";\nimport { paramsParser } from \"./parser/paramsParser.ts\";\nimport { PathParser } from \"./parser/pathParser.ts\";\nimport { scanFlag } from \"./parser/scanFlag.ts\";\nimport { scanParam } from \"./parser/scanParam.ts\";\nimport { scanSegment } from \"./parser/scanSegment.ts\";\nimport { skipSpaces } from \"./parser/skipSpaces.ts\";\nimport { getPathBBox } from \"./util/getPathBBox.ts\";\nimport { getTotalLength } from \"./util/getTotalLength.ts\";\nimport { getClosestPoint } from \"./util/getClosestPoint.ts\";\nimport { getDrawDirection } from \"./util/getDrawDirection.ts\";\nimport { getPathArea } from \"./util/getPathArea.ts\";\nimport { getPointAtLength } from \"./util/getPointAtLength.ts\";\nimport { getPropertiesAtLength } from \"./util/getPropertiesAtLength.ts\";\nimport { getPropertiesAtPoint } from \"./util/getPropertiesAtPoint.ts\";\nimport { getSegmentAtLength } from \"./util/getSegmentAtLength.ts\";\nimport { getSegmentOfPoint } from \"./util/getSegmentOfPoint.ts\";\nimport { isAbsoluteArray } from \"./util/isAbsoluteArray.ts\";\nimport { isPolygonArray } from \"./util/isPolygonArray.ts\";\nimport { isCurveArray } from \"./util/isCurveArray.ts\";\nimport { isNormalizedArray } from \"./util/isNormalizedArray.ts\";\nimport { isPathArray } from \"./util/isPathArray.ts\";\nimport { isPointInStroke } from \"./util/isPointInStroke.ts\";\nimport { isRelativeArray } from \"./util/isRelativeArray.ts\";\nimport { isValidPath } from \"./util/isValidPath.ts\";\nimport { samplePolygon } from \"./morph/samplePolygon.ts\";\nimport { shapeParams } from \"./util/shapeParams.ts\";\nimport { shapeToPath } from \"./util/shapeToPath.ts\";\nimport { shapeToPathArray } from \"./util/shapeToPathArray.ts\";\nimport { isMultiPath } from \"./util/isMultiPath.ts\";\nimport { isPolylineArray } from \"./util/isPolylineArray.ts\";\nimport { isClosedPath } from \"./util/isClosedPath.ts\";\n\nimport { normalizePath } from \"./process/normalizePath.ts\";\nimport { optimizePath } from \"./process/optimizePath.ts\";\nimport { reversePath } from \"./process/reversePath.ts\";\nimport { splitPath } from \"./process/splitPath.ts\";\nimport { transformPath } from \"./process/transformPath.ts\";\nimport { absolutizeSegment } from \"./process/absolutizeSegment.ts\";\nimport { arcToCubic } from \"./process/arcToCubic.ts\";\nimport { getSVGMatrix } from \"./process/getSVGMatrix.ts\";\nimport { iterate } from \"./process/iterate.ts\";\nimport { lineToCubic } from \"./process/lineToCubic.ts\";\nimport { normalizeSegment } from \"./process/normalizeSegment.ts\";\nimport { projection2d } from \"./process/projection2d.ts\";\nimport { quadToCubic } from \"./process/quadToCubic.ts\";\nimport { relativizeSegment } from \"./process/relativizeSegment.ts\";\nimport { reverseCurve } from \"./process/reverseCurve.ts\";\nimport { roundPath } from \"./process/roundPath.ts\";\nimport { roundSegment } from \"./process/roundSegment.ts\";\nimport { segmentToCubic } from \"./process/segmentToCubic.ts\";\nimport { shortenSegment } from \"./process/shortenSegment.ts\";\n\nimport { fixPath } from \"./morph/fixPath.ts\";\nimport { splitCubicSegment } from \"./morph/splitCubicSegment.ts\";\nimport { equalizeSegments } from \"./morph/equalizeSegments.ts\";\nimport { equalizePaths } from \"./morph/equalizePaths.ts\";\nimport { pathsIntersection } from \"./intersect/pathIntersection.ts\";\nimport { boundingBoxIntersect } from \"./intersect/boundingBoxIntersect.ts\";\nimport { isPointInsideBBox } from \"./intersect/isPointInsideBBox.ts\";\nimport distanceEpsilon from \"./util/distanceEpsilon.ts\";\n\n/**\n * Creates a new SVGPathCommander instance with the following properties:\n * * segments: `pathArray`\n * * round: number\n * * origin: [number, number, number?]\n *\n * @class\n * @author thednp <https://github.com/thednp/svg-path-commander>\n * @returns a new SVGPathCommander instance\n */\nclass SVGPathCommander {\n // declare class properties\n declare segments: PathArray;\n declare round: number | \"off\";\n declare origin: [number, number, number];\n\n /**\n * @constructor\n * @param pathValue the path string\n * @param config instance options\n */\n constructor(pathValue: string, config?: Partial<Options>) {\n const instanceOptions = config || {};\n const undefPath = typeof pathValue === \"undefined\";\n\n if (undefPath || !pathValue.length) {\n throw TypeError(\n `${error}: \"pathValue\" is ${undefPath ? \"undefined\" : \"empty\"}`,\n );\n }\n\n this.segments = parsePathString(pathValue);\n\n // // set instance options.round\n const { round: roundOption, origin: originOption } = instanceOptions;\n let round: number | \"off\";\n\n if (Number.isInteger(roundOption) || roundOption === \"off\") {\n round = roundOption as number | \"off\";\n } else {\n round = defaultOptions.round as number;\n }\n\n // set instance options.origin\n // the SVGPathCommander class will always override the default origin\n let origin = defaultOptions.origin as [number, number, number];\n /* istanbul ignore else @preserve */\n if (Array.isArray(originOption) && originOption.length >= 2) {\n const [originX, originY, originZ] = originOption.map(Number);\n origin = [\n !Number.isNaN(originX) ? originX : 0,\n !Number.isNaN(originY) ? originY : 0,\n !Number.isNaN(originZ) ? originZ : 0,\n ];\n }\n\n this.round = round;\n this.origin = origin;\n\n return this;\n }\n get bbox() {\n return getPathBBox(this.segments);\n }\n get length() {\n return getTotalLength(this.segments);\n }\n\n /**\n * Returns the path bounding box, equivalent to native `path.getBBox()`.\n *\n * @public\n * @returns the pathBBox\n */\n getBBox() {\n return this.bbox;\n }\n\n /**\n * Returns the total path length, equivalent to native `path.getTotalLength()`.\n *\n * @public\n * @returns the path total length\n */\n getTotalLength() {\n return this.length;\n }\n\n /**\n * Returns an `{x,y}` point in the path stroke at a given length,\n * equivalent to the native `path.getPointAtLength()`.\n *\n * @public\n * @param length the length\n * @returns the requested point\n */\n getPointAtLength(length: number) {\n return getPointAtLength(this.segments, length);\n }\n\n /**\n * Convert path to absolute values.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 10l80 80').toAbsolute().toString()\n * // => 'M10 10L90 90'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n toAbsolute() {\n const { segments } = this;\n this.segments = pathToAbsolute(segments);\n return this;\n }\n\n /**\n * Convert path to relative values.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 10L90 90').toRelative().toString()\n * // => 'M10 10l80 80'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n toRelative() {\n const { segments } = this;\n this.segments = pathToRelative(segments);\n return this;\n }\n\n /**\n * Convert path to cubic-bezier values. In addition, un-necessary `Z`\n * segment is removed if previous segment extends to the `M` segment.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 50q15 -25 30 0').toCurve().toString()\n * // => 'M10 50C25 25 40 50 40 50'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n toCurve() {\n const { segments } = this;\n this.segments = pathToCurve(segments);\n return this;\n }\n\n /**\n * Reverse the order of the segments and their values.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M0 0L100 0L100 100L0 100Z').reverse().toString()\n * // => 'M0 100L0 0L100 0L100 100Z'\n * ```\n *\n * @param onlySubpath - option to reverse all sub-paths except first\n * @returns this for chaining\n * @public\n */\n reverse(onlySubpath?: boolean) {\n const { segments } = this;\n const split = splitPath(segments);\n const subPath = split.length > 1 ? split : false;\n\n const absoluteMultiPath = subPath\n ? subPath.map((x, i) => {\n if (onlySubpath) {\n return i ? reversePath(x) : x.slice(0);\n }\n return reversePath(x);\n })\n : segments.slice(0);\n\n let path = [] as unknown as PathArray;\n if (subPath) {\n path = absoluteMultiPath.flat(1) as PathArray;\n } else {\n path = onlySubpath ? segments : reversePath(segments);\n }\n\n this.segments = path.slice(0) as PathArray;\n return this;\n }\n\n /**\n * Normalize path in 2 steps:\n * * convert `pathArray`(s) to absolute values\n * * convert shorthand notation to standard notation\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 90s20 -80 40 -80s20 80 40 80').normalize().toString()\n * // => 'M10 90C30 90 25 10 50 10C75 10 70 90 90 90'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n normalize() {\n const { segments } = this;\n this.segments = normalizePath(segments);\n return this;\n }\n\n /**\n * Optimize `pathArray` values:\n * * convert segments to absolute and/or relative values\n * * select segments with shortest resulted string\n * * round values to the specified `decimals` option value\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 10L10 10L90 90').optimize().toString()\n * // => 'M10 10l0 0 80 80'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n optimize() {\n const { segments } = this;\n const round = this.round === \"off\" ? 2 : this.round;\n\n this.segments = optimizePath(segments, round);\n return this;\n }\n\n /**\n * Transform path using values from an `Object` defined as `transformObject`.\n *\n * @see TransformObject for a quick reference\n *\n * @param source a `transformObject` as described above\n * @returns this for chaining\n * @public\n */\n transform(source?: Partial<TransformObject>) {\n if (\n !source ||\n typeof source !== \"object\" ||\n (typeof source === \"object\" &&\n ![\"translate\", \"rotate\", \"skew\", \"scale\"].some((x) => x in source))\n ) {\n return this;\n }\n\n const {\n segments,\n origin: [cx, cy, cz],\n } = this;\n const transform = {} as TransformObjectValues;\n for (const [k, v] of Object.entries(source) as TransformEntries) {\n // istanbul ignore else @preserve\n if (k === \"skew\" && Array.isArray(v)) {\n transform[k] = v.map(Number) as PointTuple;\n } else if (\n (k === \"rotate\" ||\n k === \"translate\" ||\n k === \"origin\" ||\n k === \"scale\") &&\n Array.isArray(v)\n ) {\n transform[k] = v.map(Number) as [number, number, number];\n } else if (k !== \"origin\" && typeof Number(v) === \"number\") {\n transform[k] = Number(v);\n }\n }\n\n // if origin is not specified\n // it's important that we have one\n const { origin } = transform;\n\n if (Array.isArray(origin) && origin.length >= 2) {\n const [originX, originY, originZ] = origin.map(Number);\n transform.origin = [\n !Number.isNaN(originX) ? originX : cx,\n !Number.isNaN(originY) ? originY : cy,\n originZ || cz,\n ];\n } else {\n transform.origin = [cx, cy, cz];\n }\n\n this.segments = transformPath(segments, transform);\n return this;\n }\n\n /**\n * Rotate path 180deg vertically.\n *\n * @example\n * ```ts\n * const path = new SVGPathCommander('M0 0L100 0L100 100L0 100Z')\n * path.flipX().toString()\n * ```\n *\n * @returns this for chaining\n * @public\n */\n flipX() {\n const { cx, cy } = this.bbox;\n this.transform({ rotate: [0, 180, 0], origin: [cx, cy, 0] });\n return this;\n }\n\n /**\n * Rotate path 180deg horizontally.\n *\n * @example\n * ```ts\n * const path = new SVGPathCommander('M0 0L100 0L100 100L0 100Z')\n * path.flipY().toString()\n * ```\n *\n * @returns this for chaining\n * @public\n */\n flipY() {\n const { cx, cy } = this.bbox;\n this.transform({ rotate: [180, 0, 0], origin: [cx, cy, 0] });\n return this;\n }\n\n /**\n * Export the current path to be used\n * for the `d` (description) attribute.\n *\n * @public\n * @returns the path string\n */\n toString() {\n return pathToString(this.segments, this.round);\n }\n\n /**\n * Remove the instance.\n *\n * @public\n * @returns void\n */\n dispose() {\n Object.keys(this).forEach((key) => delete this[key as keyof typeof this]);\n }\n\n static options = defaultOptions;\n static CSSMatrix = CSSMatrix;\n static arcTools = arcTools;\n static bezierTools = bezierTools;\n static cubicTools = cubicTools;\n static lineTools = lineTools;\n static polygonTools = polygonTools;\n static quadTools = quadTools;\n\n static pathToAbsolute = pathToAbsolute;\n static pathToRelative = pathToRelative;\n static pathToCurve = pathToCurve;\n static pathToString = pathToString;\n\n static distanceSquareRoot = distanceSquareRoot;\n static midPoint = midPoint;\n static rotateVector = rotateVector;\n static roundTo = roundTo;\n\n static parsePathString = parsePathString;\n static finalizeSegment = finalizeSegment;\n static invalidPathValue = invalidPathValue;\n\n static isArcCommand = isArcCommand;\n static isDigit = isDigit;\n static isDigitStart = isDigitStart;\n static isMoveCommand = isMoveCommand;\n static isPathCommand = isPathCommand;\n static isSpace = isSpace;\n\n static paramsCount = paramsCounts;\n static paramsParser = paramsParser;\n static PathParser = PathParser;\n static scanFlag = scanFlag;\n static scanParam = scanParam;\n static scanSegment = scanSegment;\n static skipSpaces = skipSpaces;\n\n static distanceEpsilon = distanceEpsilon;\n\n static fixPath = fixPath;\n static getClosestPoint = getClosestPoint;\n static getDrawDirection = getDrawDirection;\n static getPathArea = getPathArea;\n static getPathBBox = getPathBBox;\n static getPointAtLength = getPointAtLength;\n static getPropertiesAtLength = getPropertiesAtLength;\n static getPropertiesAtPoint = getPropertiesAtPoint;\n static getSegmentAtLength = getSegmentAtLength;\n static getSegmentOfPoint = getSegmentOfPoint;\n static getTotalLength = getTotalLength;\n\n static isAbsoluteArray = isAbsoluteArray;\n static isCurveArray = isCurveArray;\n static isPolygonArray = isPolygonArray;\n static isNormalizedArray = isNormalizedArray;\n static isPathArray = isPathArray;\n static isPointInStroke = isPointInStroke;\n static isRelativeArray = isRelativeArray;\n static isValidPath = isValidPath;\n\n static samplePolygon = samplePolygon;\n static shapeParams = shapeParams;\n static shapeToPath = shapeToPath;\n static shapeToPathArray = shapeToPathArray;\n\n static absolutizeSegment = absolutizeSegment;\n static arcToCubic = arcToCubic;\n static getSVGMatrix = getSVGMatrix;\n static iterate = iterate;\n static lineToCubic = lineToCubic;\n static normalizePath = normalizePath;\n static normalizeSegment = normalizeSegment;\n static optimizePath = optimizePath;\n static projection2d = projection2d;\n static quadToCubic = quadToCubic;\n static relativizeSegment = relativizeSegment;\n static reverseCurve = reverseCurve;\n static reversePath = reversePath;\n static roundPath = roundPath;\n static roundSegment = roundSegment;\n static segmentToCubic = segmentToCubic;\n static shortenSegment = shortenSegment;\n static splitPath = splitPath;\n static equalizePaths = equalizePaths;\n static equalizeSegments = equalizeSegments;\n static splitCubicSegment = splitCubicSegment;\n static transformPath = transformPath;\n static isPointInsideBBox = isPointInsideBBox;\n static pathsIntersection = pathsIntersection;\n static boundingBoxIntersect = boundingBoxIntersect;\n static isMultiPath = isMultiPath;\n static isClosedPath = isClosedPath;\n static isPolylineArray = isPolylineArray;\n static version = version;\n}\n\nexport default SVGPathCommander;\n","\"use strict\";\n\nimport SVGPathCommander from \"./main.ts\";\n\nexport * from \"./types.ts\";\nexport * from \"./interface.ts\";\n\nexport default SVGPathCommander;\nexport {};\n"],"x_google_ignoreList":[1],"mappings":";kPCCI,EAAI,CACP,EAAG,EACH,EAAG,EAC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M,iBAAe,GAErB,OAAE,kBAAA,wBAEF,OAAO,aAAe,GACtB,OAAO,QAAG,EACV,OAAO,YAAc,0BAErB,OAAM,iBAAoB,GAC1B,OAAI,aAAgB,GACpB,OAAI,aAAkB,GACtB,OAAO,YAAa,GACpB,OAAO,kBAAoB,GAC3B,OAAM,aAAa,GACnB,OAAK,YAAA,EACL,OAAI,UAAK,GACT,OAAI,aAAkB,GACtB,OAAE,eAAA,4BAEF,OAAO,UAAW,GAClB,OAAE,cAAW,GACb,OAAA,iBAAA,+BAEA,OAAE,cAAA,GACF,OAAG,kBAAmB,EACtB,OAAC,kBAAA,GACD,OAAI,qBAAA,GACJ,OAAM,YAAA,GACN,OAAG,aAAiB,GACpB,OAAO,gBAAkB,EACzB,OAAK,QAAA"}
1
+ {"version":3,"file":"index.min.js","names":["distanceEpsilon","distanceEpsilon","pkg.version"],"sources":["../package.json","../node_modules/.pnpm/@thednp+dommatrix@3.0.6/node_modules/@thednp/dommatrix/dist/dommatrix.mjs","../src/math/midPoint.ts","../src/math/distanceSquareRoot.ts","../src/math/lineTools.ts","../src/math/bezier.ts","../src/math/arcTools.ts","../src/math/cubicTools.ts","../src/math/quadTools.ts","../src/math/polygonTools.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/options/options.ts","../src/parser/paramsCount.ts","../src/parser/finalizeSegment.ts","../src/util/error.ts","../src/parser/scanFlag.ts","../src/parser/isDigit.ts","../src/parser/invalidPathValue.ts","../src/parser/scanParam.ts","../src/parser/isSpace.ts","../src/parser/skipSpaces.ts","../src/parser/isPathCommand.ts","../src/parser/isDigitStart.ts","../src/parser/isArcCommand.ts","../src/parser/isMoveCommand.ts","../src/parser/scanSegment.ts","../src/parser/pathParser.ts","../src/parser/parsePathString.ts","../src/process/absolutizeSegment.ts","../src/process/iterate.ts","../src/convert/pathToAbsolute.ts","../src/process/relativizeSegment.ts","../src/convert/pathToRelative.ts","../src/process/arcToCubic.ts","../src/process/quadToCubic.ts","../src/process/lineToCubic.ts","../src/process/segmentToCubic.ts","../src/process/normalizeSegment.ts","../src/parser/paramsParser.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/distanceEpsilon.ts","../src/process/normalizePath.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getClosestPoint.ts","../src/util/getPathArea.ts","../src/util/getDrawDirection.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isPathArray.ts","../src/util/isAbsoluteArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeParams.ts","../src/util/isElement.ts","../src/util/shapeToPathArray.ts","../src/util/shapeToPath.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.ts","../src/process/shortenSegment.ts","../src/process/roundSegment.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/getSVGMatrix.ts","../src/process/projection2d.ts","../src/process/transformPath.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/pathToPolyline.ts","../src/morph/splitLineToCount.ts","../src/morph/getPathSplits.ts","../src/morph/splitLinePathToCount.ts","../src/morph/splitCubicToCount.ts","../src/morph/splitCurvePathToCount.ts","../src/morph/getRotatedPath.ts","../src/morph/equalizeSegments.ts","../src/intersect/isPointInsideBBox.ts","../src/intersect/boundingBoxIntersect.ts","../src/morph/createPlaceholder.ts","../src/morph/matchPaths.ts","../src/morph/classifyPaths.ts","../src/morph/equalizePaths.ts","../src/intersect/interHelper.ts","../src/intersect/pathIntersection.ts","../src/main.ts","../src/index.ts"],"sourcesContent":["","//#region src/index.ts\n/** A model for JSONMatrix */\nconst JSON_MATRIX = {\n\ta: 1,\n\tb: 0,\n\tc: 0,\n\td: 1,\n\te: 0,\n\tf: 0,\n\tm11: 1,\n\tm12: 0,\n\tm13: 0,\n\tm14: 0,\n\tm21: 0,\n\tm22: 1,\n\tm23: 0,\n\tm24: 0,\n\tm31: 0,\n\tm32: 0,\n\tm33: 1,\n\tm34: 0,\n\tm41: 0,\n\tm42: 0,\n\tm43: 0,\n\tm44: 1,\n\tis2D: true,\n\tisIdentity: true\n};\n/** Checks if an array is compatible with CSSMatrix */\nconst isCompatibleArray = (array) => {\n\treturn (array instanceof Float64Array || array instanceof Float32Array || Array.isArray(array) && array.every((x) => typeof x === \"number\")) && [6, 16].some((x) => array.length === x);\n};\n/** Checks if an object is compatible with CSSMatrix */\nconst isCompatibleObject = (object) => {\n\treturn typeof DOMMatrix !== \"undefined\" && object instanceof DOMMatrix || object instanceof CSSMatrix || typeof object === \"object\" && Object.keys(JSON_MATRIX).every((k) => object && k in object);\n};\n/**\n* Creates a new mutable `CSSMatrix` instance given an array of 16/6 floating point values.\n* This static method invalidates arrays that contain non-number elements.\n*\n* If the array has six values, the result is a 2D matrix; if the array has 16 values,\n* the result is a 3D matrix. Otherwise, a TypeError exception is thrown.\n*\n* @param array an `Array` to feed values from.\n* @return the resulted matrix.\n*/\nconst fromArray = (array) => {\n\tconst m = new CSSMatrix();\n\tconst a = Array.from(array);\n\tif (!isCompatibleArray(a)) throw TypeError(`CSSMatrix: \"${a.join(\",\")}\" must be an array with 6/16 numbers.`);\n\t// istanbul ignore else @preserve\n\tif (a.length === 16) {\n\t\tconst [m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44] = a;\n\t\tm.m11 = m11;\n\t\tm.a = m11;\n\t\tm.m21 = m21;\n\t\tm.c = m21;\n\t\tm.m31 = m31;\n\t\tm.m41 = m41;\n\t\tm.e = m41;\n\t\tm.m12 = m12;\n\t\tm.b = m12;\n\t\tm.m22 = m22;\n\t\tm.d = m22;\n\t\tm.m32 = m32;\n\t\tm.m42 = m42;\n\t\tm.f = m42;\n\t\tm.m13 = m13;\n\t\tm.m23 = m23;\n\t\tm.m33 = m33;\n\t\tm.m43 = m43;\n\t\tm.m14 = m14;\n\t\tm.m24 = m24;\n\t\tm.m34 = m34;\n\t\tm.m44 = m44;\n\t} else if (a.length === 6) {\n\t\tconst [M11, M12, M21, M22, M41, M42] = a;\n\t\tm.m11 = M11;\n\t\tm.a = M11;\n\t\tm.m12 = M12;\n\t\tm.b = M12;\n\t\tm.m21 = M21;\n\t\tm.c = M21;\n\t\tm.m22 = M22;\n\t\tm.d = M22;\n\t\tm.m41 = M41;\n\t\tm.e = M41;\n\t\tm.m42 = M42;\n\t\tm.f = M42;\n\t}\n\treturn m;\n};\n/**\n* Creates a new mutable `CSSMatrix` instance given an existing matrix or a\n* `DOMMatrix` instance which provides the values for its properties.\n*\n* @param m the source matrix to feed values from.\n* @return the resulted matrix.\n*/\nconst fromMatrix = (m) => {\n\tif (isCompatibleObject(m)) return fromArray([\n\t\tm.m11,\n\t\tm.m12,\n\t\tm.m13,\n\t\tm.m14,\n\t\tm.m21,\n\t\tm.m22,\n\t\tm.m23,\n\t\tm.m24,\n\t\tm.m31,\n\t\tm.m32,\n\t\tm.m33,\n\t\tm.m34,\n\t\tm.m41,\n\t\tm.m42,\n\t\tm.m43,\n\t\tm.m44\n\t]);\n\tthrow TypeError(`CSSMatrix: \"${JSON.stringify(m)}\" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);\n};\n/**\n* Creates a new mutable `CSSMatrix` given any valid CSS transform string,\n* or what we call `TransformList`:\n*\n* * `matrix(a, b, c, d, e, f)` - valid matrix() transform function\n* * `matrix3d(m11, m12, m13, ...m44)` - valid matrix3d() transform function\n* * `translate(tx, ty) rotateX(alpha)` - any valid transform function(s)\n*\n* @copyright thednp © 2021\n*\n* @param source valid CSS transform string syntax.\n* @return the resulted matrix.\n*/\nconst fromString = (source) => {\n\tif (typeof source !== \"string\") throw TypeError(`CSSMatrix: \"${JSON.stringify(source)}\" is not a string.`);\n\tconst str = String(source).replace(/\\s/g, \"\");\n\tconst m = new CSSMatrix();\n\tconst invalidStringError = `CSSMatrix: invalid transform string \"${source}\"`;\n\tstr.split(\")\").filter((f) => f).forEach((tf) => {\n\t\tconst [prop, value] = tf.split(\"(\");\n\t\tif (!value) throw TypeError(invalidStringError);\n\t\tconst components = value.split(\",\").map((n) => n.includes(\"rad\") ? parseFloat(n) * (180 / Math.PI) : parseFloat(n));\n\t\tconst [x, y, z, a] = components;\n\t\tconst xyz = [\n\t\t\tx,\n\t\t\ty,\n\t\t\tz\n\t\t];\n\t\tconst xyza = [\n\t\t\tx,\n\t\t\ty,\n\t\t\tz,\n\t\t\ta\n\t\t];\n\t\tif (prop === \"perspective\" && x && [y, z].every((n) => n === void 0)) m.m34 = -1 / x;\n\t\telse if (prop.includes(\"matrix\") && [6, 16].includes(components.length) && components.every((n) => !Number.isNaN(+n))) {\n\t\t\tconst values = components.map((n) => Math.abs(n) < 1e-6 ? 0 : n);\n\t\t\tm.multiplySelf(fromArray(values));\n\t\t} else if (prop === \"translate3d\" && xyz.every((n) => !Number.isNaN(+n))) m.translateSelf(x, y, z);\n\t\telse if (prop === \"translate\" && x && z === void 0) m.translateSelf(x, y || 0, 0);\n\t\telse if (prop === \"rotate3d\" && xyza.every((n) => !Number.isNaN(+n)) && a) m.rotateAxisAngleSelf(x, y, z, a);\n\t\telse if (prop === \"rotate\" && x && [y, z].every((n) => n === void 0)) m.rotateSelf(0, 0, x);\n\t\telse if (prop === \"scale3d\" && xyz.every((n) => !Number.isNaN(+n)) && xyz.some((n) => n !== 1)) m.scaleSelf(x, y, z);\n\t\telse if (prop === \"scale\" && !Number.isNaN(x) && (x !== 1 || y !== 1) && z === void 0) {\n\t\t\tconst sy = Number.isNaN(+y) ? x : y;\n\t\t\tm.scaleSelf(x, sy, 1);\n\t\t} else if (prop === \"skew\" && (x || !Number.isNaN(x) && y) && z === void 0) m.skewSelf(x, y || 0);\n\t\telse if ([\n\t\t\t\"translate\",\n\t\t\t\"rotate\",\n\t\t\t\"scale\",\n\t\t\t\"skew\"\n\t\t].some((p) => prop.includes(p)) && /[XYZ]/.test(prop) && x && [y, z].every((n) => n === void 0)) if (\"skewX\" === prop || \"skewY\" === prop) m[\"skewX\" === prop ? \"skewXSelf\" : \"skewYSelf\"](x);\n\t\telse {\n\t\t\tconst fn = prop.replace(/[XYZ]/, \"\");\n\t\t\tconst axis = prop.replace(fn, \"\");\n\t\t\tconst idx = [\n\t\t\t\t\"X\",\n\t\t\t\t\"Y\",\n\t\t\t\t\"Z\"\n\t\t\t].indexOf(axis);\n\t\t\tconst def = fn === \"scale\" ? 1 : 0;\n\t\t\tconst method = fn + \"Self\";\n\t\t\tconst axeValues = [\n\t\t\t\tidx === 0 ? x : def,\n\t\t\t\tidx === 1 ? x : def,\n\t\t\t\tidx === 2 ? x : def\n\t\t\t];\n\t\t\tm[method](...axeValues);\n\t\t}\n\t\telse throw TypeError(invalidStringError);\n\t});\n\treturn m;\n};\n/**\n* Returns an *Array* containing elements which comprise the matrix.\n* The method can return either the 16 elements or the 6 elements\n* depending on the value of the `is2D` parameter.\n*\n* @param m the source matrix to feed values from.\n* @param is2D *Array* representation of the matrix\n* @return an *Array* representation of the matrix\n*/\nconst toArray = (m, is2D) => {\n\tif (is2D) return [\n\t\tm.a,\n\t\tm.b,\n\t\tm.c,\n\t\tm.d,\n\t\tm.e,\n\t\tm.f\n\t];\n\treturn [\n\t\tm.m11,\n\t\tm.m12,\n\t\tm.m13,\n\t\tm.m14,\n\t\tm.m21,\n\t\tm.m22,\n\t\tm.m23,\n\t\tm.m24,\n\t\tm.m31,\n\t\tm.m32,\n\t\tm.m33,\n\t\tm.m34,\n\t\tm.m41,\n\t\tm.m42,\n\t\tm.m43,\n\t\tm.m44\n\t];\n};\n/**\n* Creates a new `CSSMatrix` for the translation matrix and returns it.\n* This method is equivalent to the CSS `translate3d()` function.\n*\n* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate3d\n*\n* @param x the `x-axis` position.\n* @param y the `y-axis` position.\n* @param z the `z-axis` position.\n* @return the resulted matrix.\n*/\nconst Translate = (x, y, z) => {\n\tconst m = new CSSMatrix();\n\tm.m41 = x;\n\tm.e = x;\n\tm.m42 = y;\n\tm.f = y;\n\tm.m43 = z;\n\treturn m;\n};\n/**\n* Creates a new `CSSMatrix` for the rotation matrix and returns it.\n*\n* http://en.wikipedia.org/wiki/Rotation_matrix\n*\n* @param rx the `x-axis` rotation.\n* @param ry the `y-axis` rotation.\n* @param rz the `z-axis` rotation.\n* @return the resulted matrix.\n*/\nconst Rotate = (rx, ry, rz) => {\n\tconst m = new CSSMatrix();\n\tconst degToRad = Math.PI / 180;\n\tconst radX = rx * degToRad;\n\tconst radY = ry * degToRad;\n\tconst radZ = rz * degToRad;\n\tconst cosx = Math.cos(radX);\n\tconst sinx = -Math.sin(radX);\n\tconst cosy = Math.cos(radY);\n\tconst siny = -Math.sin(radY);\n\tconst cosz = Math.cos(radZ);\n\tconst sinz = -Math.sin(radZ);\n\tconst m11 = cosy * cosz;\n\tconst m12 = -cosy * sinz;\n\tm.m11 = m11;\n\tm.a = m11;\n\tm.m12 = m12;\n\tm.b = m12;\n\tm.m13 = siny;\n\tconst m21 = sinx * siny * cosz + cosx * sinz;\n\tm.m21 = m21;\n\tm.c = m21;\n\tconst m22 = cosx * cosz - sinx * siny * sinz;\n\tm.m22 = m22;\n\tm.d = m22;\n\tm.m23 = -sinx * cosy;\n\tm.m31 = sinx * sinz - cosx * siny * cosz;\n\tm.m32 = sinx * cosz + cosx * siny * sinz;\n\tm.m33 = cosx * cosy;\n\treturn m;\n};\n/**\n* Creates a new `CSSMatrix` for the rotation matrix and returns it.\n* This method is equivalent to the CSS `rotate3d()` function.\n*\n* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d\n*\n* @param x the `x-axis` vector length.\n* @param y the `y-axis` vector length.\n* @param z the `z-axis` vector length.\n* @param alpha the value in degrees of the rotation.\n* @return the resulted matrix.\n*/\nconst RotateAxisAngle = (x = 0, y = 0, z = 0, alpha = 0) => {\n\tconst m = new CSSMatrix();\n\tconst length = Math.sqrt(x * x + y * y + z * z);\n\tif (length === 0) return m;\n\tconst X = x / length;\n\tconst Y = y / length;\n\tconst Z = z / length;\n\tconst angle = alpha * (Math.PI / 360);\n\tconst sinA = Math.sin(angle);\n\tconst cosA = Math.cos(angle);\n\tconst sinA2 = sinA * sinA;\n\tconst x2 = X * X;\n\tconst y2 = Y * Y;\n\tconst z2 = Z * Z;\n\tconst m11 = 1 - 2 * (y2 + z2) * sinA2;\n\tm.m11 = m11;\n\tm.a = m11;\n\tconst m12 = 2 * (X * Y * sinA2 + Z * sinA * cosA);\n\tm.m12 = m12;\n\tm.b = m12;\n\tm.m13 = 2 * (X * Z * sinA2 - Y * sinA * cosA);\n\tconst m21 = 2 * (Y * X * sinA2 - Z * sinA * cosA);\n\tm.m21 = m21;\n\tm.c = m21;\n\tconst m22 = 1 - 2 * (z2 + x2) * sinA2;\n\tm.m22 = m22;\n\tm.d = m22;\n\tm.m23 = 2 * (Y * Z * sinA2 + X * sinA * cosA);\n\tm.m31 = 2 * (Z * X * sinA2 + Y * sinA * cosA);\n\tm.m32 = 2 * (Z * Y * sinA2 - X * sinA * cosA);\n\tm.m33 = 1 - 2 * (x2 + y2) * sinA2;\n\treturn m;\n};\n/**\n* Creates a new `CSSMatrix` for the scale matrix and returns it.\n* This method is equivalent to the CSS `scale3d()` function, except it doesn't\n* accept {x, y, z} transform origin parameters.\n*\n* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale3d\n*\n* @param x the `x-axis` scale.\n* @param y the `y-axis` scale.\n* @param z the `z-axis` scale.\n* @return the resulted matrix.\n*/\nconst Scale = (x, y, z) => {\n\tconst m = new CSSMatrix();\n\tm.m11 = x;\n\tm.a = x;\n\tm.m22 = y;\n\tm.d = y;\n\tm.m33 = z;\n\treturn m;\n};\n/**\n* Creates a new `CSSMatrix` for the shear of both the `x-axis` and`y-axis`\n* matrix and returns it. This method is equivalent to the CSS `skew()` function.\n*\n* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew\n*\n* @param angleX the X-angle in degrees.\n* @param angleY the Y-angle in degrees.\n* @return the resulted matrix.\n*/\nconst Skew = (angleX, angleY) => {\n\tconst m = new CSSMatrix();\n\tif (angleX) {\n\t\tconst radX = angleX * Math.PI / 180;\n\t\tconst tX = Math.tan(radX);\n\t\tm.m21 = tX;\n\t\tm.c = tX;\n\t}\n\tif (angleY) {\n\t\tconst radY = angleY * Math.PI / 180;\n\t\tconst tY = Math.tan(radY);\n\t\tm.m12 = tY;\n\t\tm.b = tY;\n\t}\n\treturn m;\n};\n/**\n* Creates a new `CSSMatrix` for the shear of the `x-axis` rotation matrix and\n* returns it. This method is equivalent to the CSS `skewX()` function.\n*\n* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewX\n*\n* @param angle the angle in degrees.\n* @return the resulted matrix.\n*/\nconst SkewX = (angle) => {\n\treturn Skew(angle, 0);\n};\n/**\n* Creates a new `CSSMatrix` for the shear of the `y-axis` rotation matrix and\n* returns it. This method is equivalent to the CSS `skewY()` function.\n*\n* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skewY\n*\n* @param angle the angle in degrees.\n* @return the resulted matrix.\n*/\nconst SkewY = (angle) => {\n\treturn Skew(0, angle);\n};\n/**\n* Creates a new `CSSMatrix` resulted from the multiplication of two matrixes\n* and returns it. Both matrixes are not changed.\n*\n* @param m1 the first matrix.\n* @param m2 the second matrix.\n* @return the resulted matrix.\n*/\nconst Multiply = (m1, m2) => {\n\tconst m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41;\n\tconst m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42;\n\tconst m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43;\n\tconst m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44;\n\tconst m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41;\n\tconst m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42;\n\tconst m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43;\n\tconst m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44;\n\tconst m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41;\n\tconst m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42;\n\tconst m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43;\n\tconst m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44;\n\tconst m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41;\n\tconst m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42;\n\tconst m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43;\n\tconst m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44;\n\treturn fromArray([\n\t\tm11,\n\t\tm12,\n\t\tm13,\n\t\tm14,\n\t\tm21,\n\t\tm22,\n\t\tm23,\n\t\tm24,\n\t\tm31,\n\t\tm32,\n\t\tm33,\n\t\tm34,\n\t\tm41,\n\t\tm42,\n\t\tm43,\n\t\tm44\n\t]);\n};\n/**\n* Creates and returns a new `DOMMatrix` compatible instance\n* with equivalent instance methods.\n*\n* @class CSSMatrix\n*\n* @author thednp <https://github.com/thednp>\n* @link homepage <https://thednp.github.io/dommatrix/>\n* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix\n*/\nvar CSSMatrix = class {\n\t/** Returns a new translation matrix. See the `Translate` helper. */\n\tstatic Translate = Translate;\n\t/** Returns a new rotation matrix. See the `Rotate` helper. */\n\tstatic Rotate = Rotate;\n\t/** Returns a new rotation matrix about a vector. See the `RotateAxisAngle` helper. */\n\tstatic RotateAxisAngle = RotateAxisAngle;\n\t/** Returns a new scale matrix. See the `Scale` helper. */\n\tstatic Scale = Scale;\n\t/** Returns a new skew-X matrix. See the `SkewX` helper. */\n\tstatic SkewX = SkewX;\n\t/** Returns a new skew-Y matrix. See the `SkewY` helper. */\n\tstatic SkewY = SkewY;\n\t/** Returns a new skew matrix. See the `Skew` helper. */\n\tstatic Skew = Skew;\n\t/** Returns the multiplication of two matrices. See the `Multiply` helper. */\n\tstatic Multiply = Multiply;\n\t/** Creates a new matrix from an array of 6/16 numbers. See the `fromArray` helper. */\n\tstatic fromArray = fromArray;\n\t/** Creates a new matrix from an existing matrix or a JSON object. See the `fromMatrix` helper. */\n\tstatic fromMatrix = fromMatrix;\n\t/** Creates a new matrix from a CSS transform string. See the `fromString` helper. */\n\tstatic fromString = fromString;\n\t/** Returns an *Array* of 6/16 values from a compatible matrix. See the `toArray` helper. */\n\tstatic toArray = toArray;\n\t/** Checks if a value is a compatible 6/16 number array. See the `isCompatibleArray` helper. */\n\tstatic isCompatibleArray = isCompatibleArray;\n\t/** Checks if a value is a `CSSMatrix` / `DOMMatrix` / `JSONMatrix` object. See the `isCompatibleObject` helper. */\n\tstatic isCompatibleObject = isCompatibleObject;\n\t/**\n\t* @constructor\n\t* @param init accepts all parameter configurations:\n\t* * valid CSS transform string,\n\t* * CSSMatrix/DOMMatrix instance,\n\t* * a 6/16 elements *Array*.\n\t*/\n\tconstructor(init) {\n\t\tthis.a = 1;\n\t\tthis.b = 0;\n\t\tthis.c = 0;\n\t\tthis.d = 1;\n\t\tthis.e = 0;\n\t\tthis.f = 0;\n\t\tthis.m11 = 1;\n\t\tthis.m12 = 0;\n\t\tthis.m13 = 0;\n\t\tthis.m14 = 0;\n\t\tthis.m21 = 0;\n\t\tthis.m22 = 1;\n\t\tthis.m23 = 0;\n\t\tthis.m24 = 0;\n\t\tthis.m31 = 0;\n\t\tthis.m32 = 0;\n\t\tthis.m33 = 1;\n\t\tthis.m34 = 0;\n\t\tthis.m41 = 0;\n\t\tthis.m42 = 0;\n\t\tthis.m43 = 0;\n\t\tthis.m44 = 1;\n\t\tif (init) return this.setMatrixValue(init);\n\t\treturn this;\n\t}\n\t/**\n\t* A `Boolean` whose value is `true` if the matrix is the identity matrix. The identity\n\t* matrix is one in which every value is 0 except those on the main diagonal from top-left\n\t* to bottom-right corner (in other words, where the offsets in each direction are equal).\n\t*\n\t* @return the current property value\n\t*/\n\tget isIdentity() {\n\t\treturn this.m11 === 1 && this.m12 === 0 && this.m13 === 0 && this.m14 === 0 && this.m21 === 0 && this.m22 === 1 && this.m23 === 0 && this.m24 === 0 && this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m41 === 0 && this.m42 === 0 && this.m43 === 0 && this.m44 === 1;\n\t}\n\t/**\n\t* A `Boolean` flag whose value is `true` if the matrix was initialized as a 2D matrix\n\t* and `false` if the matrix is 3D.\n\t*\n\t* @return the current property value\n\t*/\n\tget is2D() {\n\t\treturn this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;\n\t}\n\t/**\n\t* The `setMatrixValue` method replaces the existing matrix with one computed\n\t* in the browser. EG: `matrix(1,0.25,-0.25,1,0,0)`\n\t*\n\t* The method accepts any *Array* values, the result of\n\t* `DOMMatrix` instance method `toFloat64Array()` / `toFloat32Array()` calls\n\t* or `CSSMatrix` instance method `toArray()`.\n\t*\n\t* This method expects valid *matrix()* / *matrix3d()* string values, as well\n\t* as other transform functions like *translateX(10px)*.\n\t*\n\t* @param source\n\t* @return the matrix instance\n\t*/\n\tsetMatrixValue(source) {\n\t\tif (typeof source === \"string\" && source.length && source !== \"none\") return fromString(source);\n\t\tif (Array.isArray(source) || source instanceof Float64Array || source instanceof Float32Array) return fromArray(source);\n\t\tif (typeof source === \"object\") return fromMatrix(source);\n\t\treturn this;\n\t}\n\t/**\n\t* Returns a *Float32Array* containing elements which comprise the matrix.\n\t* The method can return either the 16 elements or the 6 elements\n\t* depending on the value of the `is2D` parameter.\n\t*\n\t* @param is2D *Array* representation of the matrix\n\t* @return an *Array* representation of the matrix\n\t*/\n\ttoFloat32Array(is2D) {\n\t\treturn Float32Array.from(toArray(this, is2D));\n\t}\n\t/**\n\t* Returns a *Float64Array* containing elements which comprise the matrix.\n\t* The method can return either the 16 elements or the 6 elements\n\t* depending on the value of the `is2D` parameter.\n\t*\n\t* @param is2D *Array* representation of the matrix\n\t* @return an *Array* representation of the matrix\n\t*/\n\ttoFloat64Array(is2D) {\n\t\treturn Float64Array.from(toArray(this, is2D));\n\t}\n\t/**\n\t* Creates and returns a string representation of the matrix in `CSS` matrix syntax,\n\t* using the appropriate `CSS` matrix notation.\n\t*\n\t* matrix3d *matrix3d(m11, m12, m13, m14, m21, ...)*\n\t* matrix *matrix(a, b, c, d, e, f)*\n\t*\n\t* @return a string representation of the matrix\n\t*/\n\ttoString() {\n\t\tconst { is2D } = this;\n\t\tconst values = this.toFloat64Array(is2D).join(\", \");\n\t\treturn `${is2D ? \"matrix\" : \"matrix3d\"}(${values})`;\n\t}\n\t/**\n\t* Returns a JSON representation of the `CSSMatrix` instance, a standard *Object*\n\t* that includes `{a,b,c,d,e,f}` and `{m11,m12,m13,..m44}` properties as well\n\t* as the `is2D` & `isIdentity` properties.\n\t*\n\t* The result can also be used as a second parameter for the `fromMatrix` static method\n\t* to load values into another matrix instance.\n\t*\n\t* @return an *Object* with all matrix values.\n\t*/\n\ttoJSON() {\n\t\tconst { is2D, isIdentity } = this;\n\t\treturn {\n\t\t\t...this,\n\t\t\tis2D,\n\t\t\tisIdentity\n\t\t};\n\t}\n\t/**\n\t* The Multiply method returns a new CSSMatrix which is the result of this\n\t* matrix multiplied by the passed matrix, with the passed matrix to the right.\n\t* This matrix is not modified.\n\t*\n\t* @param m2 CSSMatrix\n\t* @return The resulted matrix.\n\t*/\n\tmultiply(m2) {\n\t\treturn Multiply(this, m2);\n\t}\n\t/**\n\t* The translate method returns a new matrix which is this matrix post\n\t* multiplied by a translation matrix containing the passed values. If the z\n\t* component is undefined, a 0 value is used in its place. This matrix is not\n\t* modified.\n\t*\n\t* @param x X component of the translation value.\n\t* @param y Y component of the translation value.\n\t* @param z Z component of the translation value.\n\t* @return The resulted matrix\n\t*/\n\ttranslate(x, y, z) {\n\t\treturn this.multiply(Translate(x, y ?? 0, z ?? 0));\n\t}\n\t/**\n\t* The scale method returns a new matrix which is this matrix post multiplied by\n\t* a scale matrix containing the passed values. If the z component is undefined,\n\t* a 1 value is used in its place. If the y component is undefined, the x\n\t* component value is used in its place. This matrix is not modified.\n\t*\n\t* @param x The X component of the scale value.\n\t* @param y The Y component of the scale value.\n\t* @param z The Z component of the scale value.\n\t* @return The resulted matrix\n\t*/\n\tscale(x, y, z) {\n\t\treturn this.multiply(Scale(x, y ?? x, z ?? 1));\n\t}\n\t/**\n\t* The rotate method returns a new matrix which is this matrix post multiplied\n\t* by each of 3 rotation matrices about the major axes, first X, then Y, then Z.\n\t* If the y and z components are undefined, the x value is used to rotate the\n\t* object about the z axis, as though the vector (0,0,x) were passed. All\n\t* rotation values are in degrees. This matrix is not modified.\n\t*\n\t* @param rx The X component of the rotation, or Z if Y and Z are null.\n\t* @param ry The (optional) Y component of the rotation value.\n\t* @param rz The (optional) Z component of the rotation value.\n\t* @return The resulted matrix\n\t*/\n\trotate(rx, ry, rz) {\n\t\tlet RX = rx;\n\t\tlet RY = ry || 0;\n\t\tlet RZ = rz || 0;\n\t\tif (typeof rx === \"number\" && typeof ry === \"undefined\" && typeof rz === \"undefined\") {\n\t\t\tRZ = RX;\n\t\t\tRX = 0;\n\t\t\tRY = 0;\n\t\t}\n\t\treturn this.multiply(Rotate(RX, RY, RZ));\n\t}\n\t/**\n\t* The rotateAxisAngle method returns a new matrix which is this matrix post\n\t* multiplied by a rotation matrix with the given axis and `angle`. The right-hand\n\t* rule is used to determine the direction of rotation. All rotation values are\n\t* in degrees. This matrix is not modified.\n\t*\n\t* @param x The X component of the axis vector.\n\t* @param y The Y component of the axis vector.\n\t* @param z The Z component of the axis vector.\n\t* @param angle The angle of rotation about the axis vector, in degrees.\n\t* @return The resulted matrix\n\t*/\n\trotateAxisAngle(x = 0, y = 0, z = 0, angle = 0) {\n\t\tif ([\n\t\t\tx,\n\t\t\ty,\n\t\t\tz,\n\t\t\tangle\n\t\t].some((n) => !Number.isFinite(n))) throw new TypeError(\"CSSMatrix: expecting 4 values\");\n\t\tif (Math.sqrt(x * x + y * y + z * z) === 0) return fromMatrix(this);\n\t\treturn this.multiply(RotateAxisAngle(x, y, z, angle));\n\t}\n\t/**\n\t* Specifies a skew transformation along the `x-axis` by the given angle.\n\t* This matrix is not modified.\n\t*\n\t* @param angle The angle amount in degrees to skew.\n\t* @return The resulted matrix\n\t*/\n\tskewX(angle) {\n\t\treturn this.multiply(SkewX(angle));\n\t}\n\t/**\n\t* Specifies a skew transformation along the `y-axis` by the given angle.\n\t* This matrix is not modified.\n\t*\n\t* @param angle The angle amount in degrees to skew.\n\t* @return The resulted matrix\n\t*/\n\tskewY(angle) {\n\t\treturn this.multiply(SkewY(angle));\n\t}\n\t/**\n\t* Specifies a skew transformation along both the `x-axis` and `y-axis`.\n\t* This matrix is not modified.\n\t*\n\t* @param angleX The X-angle amount in degrees to skew.\n\t* @param angleY The angle amount in degrees to skew.\n\t* @return The resulted matrix\n\t*/\n\tskew(angleX, angleY) {\n\t\treturn this.multiply(Skew(angleX, angleY));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with another matrix.\n\t* This is the mutable version of multiply().\n\t*\n\t* @param m2 The matrix to multiply with\n\t* @return this matrix (modified)\n\t*/\n\tmultiplySelf(m2) {\n\t\tconst result = Multiply(this, m2);\n\t\tObject.assign(this, result);\n\t\treturn this;\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a translation matrix.\n\t* This is the mutable version of translate().\n\t*\n\t* @param x X component of the translation value.\n\t* @param y Y component of the translation value.\n\t* @param z Z component of the translation value.\n\t* @return this matrix (modified)\n\t*/\n\ttranslateSelf(x, y, z) {\n\t\treturn this.multiplySelf(Translate(x, y ?? 0, z ?? 0));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a scale matrix.\n\t* This is the mutable version of scale().\n\t*\n\t* @param x The X component of the scale value.\n\t* @param y The Y component of the scale value.\n\t* @param z The Z component of the scale value.\n\t* @return this matrix (modified)\n\t*/\n\tscaleSelf(x, y, z) {\n\t\treturn this.multiplySelf(Scale(x, y ?? x, z ?? 1));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a rotation matrix.\n\t* This is the mutable version of rotate().\n\t*\n\t* @param rx The X component of the rotation, or Z if Y and Z are null.\n\t* @param ry The (optional) Y component of the rotation value.\n\t* @param rz The (optional) Z component of the rotation value.\n\t* @return this matrix (modified)\n\t*/\n\trotateSelf(rx, ry, rz) {\n\t\tlet RX = rx;\n\t\tlet RY = ry || 0;\n\t\tlet RZ = rz || 0;\n\t\tif (typeof rx === \"number\" && typeof ry === \"undefined\" && typeof rz === \"undefined\") {\n\t\t\tRZ = RX;\n\t\t\tRX = 0;\n\t\t\tRY = 0;\n\t\t}\n\t\treturn this.multiplySelf(Rotate(RX, RY, RZ));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a rotation matrix\n\t* with the given axis and angle.\n\t* This is the mutable version of rotateAxisAngle().\n\t*\n\t* @param x The X component of the axis vector.\n\t* @param y The Y component of the axis vector.\n\t* @param z The Z component of the axis vector.\n\t* @param angle The angle of rotation about the axis vector, in degrees.\n\t* @return this matrix (modified)\n\t*/\n\trotateAxisAngleSelf(x = 0, y = 0, z = 0, angle = 0) {\n\t\tif ([\n\t\t\tx,\n\t\t\ty,\n\t\t\tz,\n\t\t\tangle\n\t\t].some((n) => !Number.isFinite(n))) throw new TypeError(\"CSSMatrix: expecting 4 values\");\n\t\tif (Math.sqrt(x * x + y * y + z * z) === 0) return this;\n\t\treturn this.multiplySelf(RotateAxisAngle(x, y, z, angle));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a skewX matrix.\n\t* This is the mutable version of skewX().\n\t*\n\t* @param angle The angle amount in degrees to skew.\n\t* @return this matrix (modified)\n\t*/\n\tskewXSelf(angle) {\n\t\treturn this.multiplySelf(SkewX(angle));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a skewY matrix.\n\t* This is the mutable version of skewY().\n\t*\n\t* @param angle The angle amount in degrees to skew.\n\t* @return this matrix (modified)\n\t*/\n\tskewYSelf(angle) {\n\t\treturn this.multiplySelf(SkewY(angle));\n\t}\n\t/**\n\t* Modifies the current matrix by post-multiplying it with a skew matrix.\n\t* This is the mutable version of skew().\n\t*\n\t* @param angleX The X-angle amount in degrees to skew.\n\t* @param angleY The Y-angle amount in degrees to skew.\n\t* @return this matrix (modified)\n\t*/\n\tskewSelf(angleX, angleY) {\n\t\treturn this.multiplySelf(Skew(angleX, angleY));\n\t}\n\t/**\n\t* Transforms a specified vector using the matrix, returning a new\n\t* {x,y,z,w} Tuple *Object* comprising the transformed vector.\n\t* Neither the matrix nor the original vector are altered.\n\t*\n\t* The method is equivalent with `transformPoint()` method\n\t* of the `DOMMatrix` constructor.\n\t*\n\t* @param t Tuple with `{x,y,z,w}` components\n\t* @return the resulting Tuple\n\t*/\n\ttransformPoint(t) {\n\t\tconst x = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w;\n\t\tconst y = this.m12 * t.x + this.m22 * t.y + this.m32 * t.z + this.m42 * t.w;\n\t\tconst z = this.m13 * t.x + this.m23 * t.y + this.m33 * t.z + this.m43 * t.w;\n\t\tconst w = this.m14 * t.x + this.m24 * t.y + this.m34 * t.z + this.m44 * t.w;\n\t\treturn typeof DOMPoint !== \"undefined\" && t instanceof DOMPoint ? new DOMPoint(x, y, z, w) : {\n\t\t\tx,\n\t\t\ty,\n\t\t\tz,\n\t\t\tw\n\t\t};\n\t}\n};\n//#endregion\nexport { CSSMatrix as default };\n\n//# sourceMappingURL=dommatrix.mjs.map","import type { PointTuple } from \"../types.ts\";\n\n/**\n * Returns the coordinates of a specified distance\n * ratio between two points.\n *\n * @param a the first point coordinates\n * @param b the second point coordinates\n * @param t the ratio\n * @returns the midpoint coordinates\n */\nexport const midPoint = (\n [ax, ay]: PointTuple,\n [bx, by]: PointTuple,\n t: number,\n): PointTuple => {\n return [ax + (bx - ax) * t, ay + (by - ay) * t];\n};\n","import type { PointTuple } from \"../types.ts\";\n\n/**\n * Returns the square root of the distance\n * between two given points.\n *\n * @param a the first point coordinates\n * @param b the second point coordinates\n * @returns the distance value\n */\nexport const distanceSquareRoot = (a: PointTuple, b: PointTuple): number => {\n return Math.sqrt(\n (a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]),\n );\n};\n","import { midPoint } from \"./midPoint.ts\";\nimport { distanceSquareRoot } from \"./distanceSquareRoot.ts\";\n\n/**\n * Returns length for line segments (MoveTo, LineTo).\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the line segment length\n */\nconst getLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => {\n return distanceSquareRoot([x1, y1], [x2, y2]);\n};\n\n/**\n * Returns a point along the line segments (MoveTo, LineTo).\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to point in [0-1] range\n * @returns the point at length\n */\nconst getPointAtLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n distance?: number,\n): { x: number; y: number } => {\n let point = { x: x1, y: y1 };\n\n /* istanbul ignore else @preserve */\n if (typeof distance === \"number\") {\n const length = distanceSquareRoot([x1, y1], [x2, y2]);\n if (distance <= 0) {\n point = { x: x1, y: y1 };\n } else if (distance >= length) {\n point = { x: x2, y: y2 };\n } else {\n const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);\n point = { x, y };\n }\n }\n return point;\n};\n\n/**\n * Returns bounding box for line segments (MoveTo, LineTo).\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the bounding box for line segments\n */\nconst getLineBBox = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): [number, number, number, number] => {\n const { min, max } = Math;\n\n return [min(x1, x2), min(y1, y2), max(x1, x2), max(y1, y2)] as [\n number,\n number,\n number,\n number,\n ];\n};\n\n/** The tools for line segment computation. */\nconst lineTools = {\n getLineBBox,\n getLineLength,\n getPointAtLineLength,\n};\n\nexport { getLineBBox, getLineLength, getPointAtLineLength, lineTools };\n","import type {\n CubicCoordinates,\n CubicPoints,\n DeriveCallback,\n DerivedCubicPoints,\n DerivedPoint,\n DerivedQuadPoints,\n PointTuple,\n QuadCoordinates,\n QuadPoints,\n} from \"../types.ts\";\n\n/**\n * Tools from bezier.js by Mike 'Pomax' Kamermans\n * @see https://github.com/Pomax/bezierjs\n */\n\nconst Tvalues = [\n -0.0640568928626056260850430826247450385909,\n 0.0640568928626056260850430826247450385909,\n -0.1911188674736163091586398207570696318404,\n 0.1911188674736163091586398207570696318404,\n -0.3150426796961633743867932913198102407864,\n 0.3150426796961633743867932913198102407864,\n -0.4337935076260451384870842319133497124524,\n 0.4337935076260451384870842319133497124524,\n -0.5454214713888395356583756172183723700107,\n 0.5454214713888395356583756172183723700107,\n -0.6480936519369755692524957869107476266696,\n 0.6480936519369755692524957869107476266696,\n -0.7401241915785543642438281030999784255232,\n 0.7401241915785543642438281030999784255232,\n -0.8200019859739029219539498726697452080761,\n 0.8200019859739029219539498726697452080761,\n -0.8864155270044010342131543419821967550873,\n 0.8864155270044010342131543419821967550873,\n -0.9382745520027327585236490017087214496548,\n 0.9382745520027327585236490017087214496548,\n -0.9747285559713094981983919930081690617411,\n 0.9747285559713094981983919930081690617411,\n -0.9951872199970213601799974097007368118745,\n 0.9951872199970213601799974097007368118745,\n];\n\n/** The weights for the 32-point Gauss-Legendre quadrature. */\nconst Cvalues = [\n 0.1279381953467521569740561652246953718517,\n 0.1279381953467521569740561652246953718517,\n 0.1258374563468282961213753825111836887264,\n 0.1258374563468282961213753825111836887264,\n 0.121670472927803391204463153476262425607,\n 0.121670472927803391204463153476262425607,\n 0.1155056680537256013533444839067835598622,\n 0.1155056680537256013533444839067835598622,\n 0.1074442701159656347825773424466062227946,\n 0.1074442701159656347825773424466062227946,\n 0.0976186521041138882698806644642471544279,\n 0.0976186521041138882698806644642471544279,\n 0.086190161531953275917185202983742667185,\n 0.086190161531953275917185202983742667185,\n 0.0733464814110803057340336152531165181193,\n 0.0733464814110803057340336152531165181193,\n 0.0592985849154367807463677585001085845412,\n 0.0592985849154367807463677585001085845412,\n 0.0442774388174198061686027482113382288593,\n 0.0442774388174198061686027482113382288593,\n 0.0285313886289336631813078159518782864491,\n 0.0285313886289336631813078159518782864491,\n 0.0123412297999871995468056670700372915759,\n 0.0123412297999871995468056670700372915759,\n];\n\n/**\n * @param points\n * @returns\n */\nconst deriveBezier = (\n points: QuadPoints | CubicPoints,\n): (DerivedQuadPoints | DerivedCubicPoints)[] => {\n const dpoints = [] as (DerivedCubicPoints | DerivedQuadPoints)[];\n for (let p = points, d = p.length, c = d - 1; d > 1; d -= 1, c -= 1) {\n const list = [] as unknown as DerivedCubicPoints | DerivedQuadPoints;\n for (let j = 0; j < c; j += 1) {\n list.push({\n x: c * (p[j + 1].x - p[j].x),\n y: c * (p[j + 1].y - p[j].y),\n t: 0,\n });\n }\n dpoints.push(list);\n p = list;\n }\n return dpoints;\n};\n\n/**\n * @param points\n * @param t\n */\nconst computeBezier = (\n points: DerivedQuadPoints | DerivedCubicPoints,\n t: number,\n): DerivedPoint => {\n // shortcuts\n /* istanbul ignore next @preserve */\n if (t === 0) {\n points[0].t = 0;\n return points[0];\n }\n\n const order = points.length - 1;\n\n /* istanbul ignore next @preserve */\n if (t === 1) {\n points[order].t = 1;\n return points[order];\n }\n\n const mt = 1 - t;\n let p = points as typeof points | [\n DerivedPoint,\n DerivedPoint,\n DerivedPoint,\n DerivedPoint,\n ];\n\n // constant?\n /* istanbul ignore next @preserve */\n if (order === 0) {\n points[0].t = t;\n return points[0];\n }\n\n // linear?\n /* istanbul ignore else @preserve */\n if (order === 1) {\n return {\n x: mt * p[0].x + t * p[1].x,\n y: mt * p[0].y + t * p[1].y,\n t,\n };\n }\n\n // quadratic/cubic curve?\n const mt2 = mt * mt;\n const t2 = t * t;\n let a = 0;\n let b = 0;\n let c = 0;\n let d = 0;\n /* istanbul ignore else @preserve */\n if (order === 2) {\n p = [p[0], p[1], p[2], { x: 0, y: 0 } as DerivedPoint];\n a = mt2;\n b = mt * t * 2;\n c = t2;\n } else if (order === 3) {\n a = mt2 * mt;\n b = mt2 * t * 3;\n c = mt * t2 * 3;\n d = t * t2;\n }\n return {\n x: a * p[0].x + b * p[1].x + c * p[2].x + d * p[3].x,\n y: a * p[0].y + b * p[1].y + c * p[2].y + d * p[3].y,\n t,\n };\n};\n\n/**\n * Calculates the speed (derivative magnitude) of a Bezier curve at parameter `t`.\n *\n * @param derivativeFn the curve derivative function\n * @param t the sampled point ratio in `[0-1]`\n * @returns the curve speed at parameter `t`\n */\nconst calculateBezier = (derivativeFn: DeriveCallback, t: number): number => {\n const d = derivativeFn(t);\n const l = d.x * d.x + d.y * d.y;\n\n return Math.sqrt(l);\n};\n\n/**\n * Returns the total arc length of a Bezier segment.\n *\n * @param derivativeFn the curve derivative function\n * @returns the total arc length\n */\nconst bezierLength = (derivativeFn: DeriveCallback): number => {\n return bezierLengthAtT(derivativeFn, 1);\n};\n\n/**\n * Returns the arc length of a Bezier segment from its start point\n * up to a given `t` ratio, by integrating the curve speed `|B'(t)|`\n * over the `[0, t]` interval with Gauss-Legendre quadrature.\n *\n * @param derivativeFn the curve derivative function\n * @param t the sampled point ratio in `[0-1]`\n * @returns the arc length up to parameter `t`\n */\nconst bezierLengthAtT = (derivativeFn: DeriveCallback, t: number): number => {\n const z = t / 2;\n const len = Tvalues.length;\n\n let sum = 0;\n\n for (let i = 0, tMid; i < len; i++) {\n tMid = z * Tvalues[i] + z;\n sum += Cvalues[i] * calculateBezier(derivativeFn, tMid);\n }\n return z * sum;\n};\n\n/**\n * Builds the Bezier points array from a curve coordinates array.\n * @param curve cubic / quad bezier segment\n */\nconst getBezierPoints = (\n curve: CubicCoordinates | QuadCoordinates,\n): CubicPoints | QuadPoints => {\n const points = [] as unknown as CubicPoints | QuadPoints;\n for (let idx = 0, len = curve.length, step = 2; idx < len; idx += step) {\n points.push({\n x: curve[idx],\n y: curve[idx + 1],\n });\n }\n return points;\n};\n\n/**\n * Returns the arc length of a Bezier segment from its start point\n * up to a given `t` ratio, for the segment given by its coordinates.\n *\n * @param curve cubic / quad bezier segment\n * @param t the sampled point ratio in `[0-1]`\n * @returns the arc length up to parameter `t`\n */\nconst getBezierLengthAtT = (\n curve: CubicCoordinates | QuadCoordinates,\n t: number,\n): number => {\n const dpoints = deriveBezier(getBezierPoints(curve));\n return bezierLengthAtT((ratio: number) => {\n return computeBezier(dpoints[0], ratio);\n }, t);\n};\n\n/**\n * Returns the `t` parameter of a Bezier segment at which the cumulative\n * arc length equals the given `distance`, found by interval bisection.\n *\n * @param curve cubic / quad bezier segment\n * @param distance the distance along the segment in `[0, length]`\n * @returns the `t` parameter in `[0-1]`\n */\nconst getTAtBezierLength = (\n curve: CubicCoordinates | QuadCoordinates,\n distance: number,\n): number => {\n const dpoints = deriveBezier(getBezierPoints(curve));\n const derivativeFn = (ratio: number) => {\n return computeBezier(dpoints[0], ratio);\n };\n let lo = 0;\n let hi = 1;\n for (let i = 0; i < 25; i += 1) {\n const mid = (lo + hi) / 2;\n if (bezierLengthAtT(derivativeFn, mid) < distance) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n return (lo + hi) / 2;\n};\n\n/**\n * Returns the length of CubicBezier / Quad segment.\n * @param curve cubic / quad bezier segment\n */\nconst getBezierLength = (curve: CubicCoordinates | QuadCoordinates): number => {\n const points = getBezierPoints(curve);\n const dpoints = deriveBezier(points);\n return bezierLength((t: number) => {\n return computeBezier(dpoints[0], t);\n });\n};\n\n// Precision for consider cubic polynom as quadratic one\n/** The precision threshold to consider a cubic polynomial as quadratic. */\nconst CBEZIER_MINMAX_EPSILON = 0.00000001;\n\n/**\n * Returns the most extreme points in a Quad Bezier segment.\n * @param A an array which consist of X/Y values\n */\n// https://github.com/kpym/SVGPathy/blob/acd1a50c626b36d81969f6e98e8602e128ba4302/lib/box.js#L89\nconst minmaxQ = ([v1, cp, v2]: [number, number, number]): PointTuple => {\n const min = Math.min(v1, v2);\n const max = Math.max(v1, v2);\n\n /* istanbul ignore next @preserve */\n if (cp >= v1 ? v2 >= cp : v2 <= cp) {\n // if no extremum in ]0,1[\n return [min, max] as PointTuple;\n }\n\n // check if the extremum E is min or max\n const E = (v1 * v2 - cp * cp) / (v1 - 2 * cp + v2);\n return (E < min ? [E, max] : [min, E]) as PointTuple;\n};\n\n/**\n * Returns the most extreme points in a Cubic Bezier segment.\n * @param A an array which consist of X/Y values\n * @see https://github.com/kpym/SVGPathy/blob/acd1a50c626b36d81969f6e98e8602e128ba4302/lib/box.js#L127\n */\nconst minmaxC = (\n [v1, cp1, cp2, v2]: [number, number, number, number],\n): PointTuple => {\n const K = v1 - 3 * cp1 + 3 * cp2 - v2;\n\n // if the polynomial is (almost) quadratic and not cubic\n /* istanbul ignore next @preserve */\n if (Math.abs(K) < CBEZIER_MINMAX_EPSILON) {\n if (v1 === v2 && v1 === cp1) {\n // no curve, point targeting same location\n return [v1, v2] as PointTuple;\n }\n\n return minmaxQ([v1, -0.5 * v1 + 1.5 * cp1, v1 - 3 * cp1 + 3 * cp2]);\n }\n\n // the reduced discriminant of the derivative\n const T = -v1 * cp2 + v1 * v2 - cp1 * cp2 - cp1 * v2 + cp1 * cp1 + cp2 * cp2;\n\n // if the polynomial is monotone in [0,1]\n if (T <= 0) {\n return [Math.min(v1, v2), Math.max(v1, v2)] as PointTuple;\n }\n const S = Math.sqrt(T);\n\n // potential extrema\n let min = Math.min(v1, v2);\n let max = Math.max(v1, v2);\n\n const L = v1 - 2 * cp1 + cp2;\n // check local extrema\n for (let R = (L + S) / K, i = 1; i <= 2; R = (L - S) / K, i++) {\n // istanbul ignore next @preserve\n if (R > 0 && R < 1) {\n // if the extrema is for R in [0,1]\n const Q = v1 * (1 - R) * (1 - R) * (1 - R) +\n cp1 * 3 * (1 - R) * (1 - R) * R + cp2 * 3 * (1 - R) * R * R +\n v2 * R * R * R;\n if (Q < min) {\n min = Q;\n }\n if (Q > max) {\n max = Q;\n }\n }\n }\n\n return [min, max] as PointTuple;\n};\n/** The tools for Bezier curve computation. */\nconst bezierTools = {\n bezierLength,\n bezierLengthAtT,\n calculateBezier,\n CBEZIER_MINMAX_EPSILON,\n computeBezier,\n Cvalues,\n deriveBezier,\n getBezierLength,\n getBezierLengthAtT,\n getBezierPoints,\n getTAtBezierLength,\n minmaxC,\n minmaxQ,\n Tvalues,\n};\n\nexport {\n bezierLength,\n bezierLengthAtT,\n bezierTools,\n calculateBezier,\n CBEZIER_MINMAX_EPSILON,\n computeBezier,\n Cvalues,\n deriveBezier,\n getBezierLength,\n getBezierLengthAtT,\n getBezierPoints,\n getTAtBezierLength,\n minmaxC,\n minmaxQ,\n Tvalues,\n};\n","import { getPointAtLineLength } from \"./lineTools.ts\";\nimport { Cvalues, Tvalues } from \"./bezier.ts\";\nimport type { Point, PointTuple } from \"../types.ts\";\n\n/**\n * Returns the signed arc length of an ellipse segment from angle `0` up to\n * the given `theta` angle, by integrating the curve speed\n * `|sqrt(rx^2 * sin^2(phi) + ry^2 * cos^2(phi))|` over the `[0, theta]`\n * interval with Gauss-Legendre quadrature.\n *\n * @param rx radius along X axis\n * @param ry radius along Y axis\n * @param theta the angle in radians\n * @returns the signed arc length\n */\nconst arcLengthAtAngle = (rx: number, ry: number, theta: number): number => {\n const sign = theta < 0 ? -1 : 1;\n const absTheta = Math.abs(theta);\n const step = Math.PI / 2;\n\n let total = 0;\n let remaining = absTheta;\n let offset = 0;\n\n while (remaining > 0) {\n const span = Math.min(step, remaining);\n const z = span / 2;\n\n let sum = 0;\n for (let i = 0, len = Tvalues.length; i < len; i += 1) {\n const phi = offset + z * Tvalues[i] + z;\n sum += Cvalues[i] * Math.sqrt(\n (rx * Math.sin(phi)) ** 2 +\n (ry * Math.cos(phi)) ** 2,\n );\n }\n total += z * sum;\n offset += span;\n remaining -= span;\n }\n return sign * total;\n};\n\n/**\n * Returns the signed arc length of an ellipse segment between two angles.\n * @param rx radius along X axis\n * @param ry radius along Y axis\n * @param from the start angle in radians\n * @param to the end angle in radians\n * @returns the signed arc length\n */\nconst arcLengthBetween = (\n rx: number,\n ry: number,\n from: number,\n to: number,\n): number => {\n return arcLengthAtAngle(rx, ry, to) - arcLengthAtAngle(rx, ry, from);\n};\n\n/**\n * Returns the Arc segment length.\n * @param rx radius along X axis\n * @param ry radius along Y axis\n * @param theta the angle in radians\n * @returns the arc length\n */\nconst arcLength = (rx: number, ry: number, theta: number): number => {\n return Math.abs(arcLengthAtAngle(rx, ry, theta));\n};\n\n/**\n * Find point on ellipse at given angle around ellipse (theta);\n * @param cx the center X\n * @param cy the center Y\n * @param rx the radius X\n * @param ry the radius Y\n * @param alpha the arc rotation angle in radians\n * @param theta the arc sweep angle in radians\n * @returns a point around ellipse at given angle\n */\nconst arcPoint = (\n cx: number,\n cy: number,\n rx: number,\n ry: number,\n alpha: number,\n theta: number,\n): PointTuple => {\n const { sin, cos } = Math;\n // theta is angle in radians around arc\n // alpha is angle of rotation of ellipse in radians\n const cosA = cos(alpha);\n const sinA = sin(alpha);\n const x = rx * cos(theta);\n const y = ry * sin(theta);\n\n return [cx + cosA * x - sinA * y, cy + sinA * x + cosA * y] as PointTuple;\n};\n\n/**\n * Returns the angle between two points.\n * @param v0 starting point\n * @param v1 ending point\n * @returns the angle in radian\n */\nconst angleBetween = (v0: Point, v1: Point): number => {\n const { x: v0x, y: v0y } = v0;\n const { x: v1x, y: v1y } = v1;\n const p = v0x * v1x + v0y * v1y;\n const n = Math.sqrt((v0x ** 2 + v0y ** 2) * (v1x ** 2 + v1y ** 2));\n const sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;\n return sign * Math.acos(p / n);\n};\n\n/**\n * Returns the following properties for an Arc segment: center, start angle,\n * end angle, and radiuses on X and Y axis.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param RX the radius on X axis\n * @param RY the radius on Y axis\n * @param angle the ellipse rotation in degrees\n * @param LAF the large arc flag\n * @param SF the sweep flag\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns properties specific to Arc segments\n */\nconst getArcProps = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n): {\n rx: number;\n ry: number;\n startAngle: number;\n endAngle: number;\n center: { x: number; y: number };\n} => {\n const { abs, sin, cos, sqrt, PI } = Math;\n let rx = abs(RX);\n let ry = abs(RY);\n const xRot = ((angle % 360) + 360) % 360;\n const xRotRad = xRot * (PI / 180);\n\n // istanbul ignore next @preserve\n if (x1 === x && y1 === y) {\n return {\n rx,\n ry,\n startAngle: 0,\n endAngle: 0,\n center: { x, y },\n };\n }\n\n if (rx === 0 || ry === 0) {\n return {\n rx,\n ry,\n startAngle: 0,\n endAngle: 0,\n center: { x: (x + x1) / 2, y: (y + y1) / 2 },\n };\n }\n\n const dx = (x1 - x) / 2;\n const dy = (y1 - y) / 2;\n\n const transformedPoint = {\n x: cos(xRotRad) * dx + sin(xRotRad) * dy,\n y: -sin(xRotRad) * dx + cos(xRotRad) * dy,\n };\n\n const radiiCheck = transformedPoint.x ** 2 / rx ** 2 +\n transformedPoint.y ** 2 / ry ** 2;\n\n if (radiiCheck > 1) {\n rx *= sqrt(radiiCheck);\n ry *= sqrt(radiiCheck);\n }\n\n const cSquareNumerator = rx ** 2 * ry ** 2 -\n rx ** 2 * transformedPoint.y ** 2 - ry ** 2 * transformedPoint.x ** 2;\n const cSquareRootDenom = rx ** 2 * transformedPoint.y ** 2 +\n ry ** 2 * transformedPoint.x ** 2;\n\n let cRadicand = cSquareNumerator / cSquareRootDenom;\n /* istanbul ignore next @preserve */\n cRadicand = cRadicand < 0 ? 0 : cRadicand;\n const cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);\n const transformedCenter = {\n x: cCoef * ((rx * transformedPoint.y) / ry),\n y: cCoef * (-(ry * transformedPoint.x) / rx),\n };\n\n const center = {\n x: cos(xRotRad) * transformedCenter.x - sin(xRotRad) * transformedCenter.y +\n (x1 + x) / 2,\n y: sin(xRotRad) * transformedCenter.x + cos(xRotRad) * transformedCenter.y +\n (y1 + y) / 2,\n };\n\n const startVector = {\n x: (transformedPoint.x - transformedCenter.x) / rx,\n y: (transformedPoint.y - transformedCenter.y) / ry,\n };\n\n const startAngle = angleBetween({ x: 1, y: 0 }, startVector);\n\n const endVector = {\n x: (-transformedPoint.x - transformedCenter.x) / rx,\n y: (-transformedPoint.y - transformedCenter.y) / ry,\n };\n\n let sweepAngle = angleBetween(startVector, endVector);\n if (!SF && sweepAngle > 0) {\n sweepAngle -= 2 * PI;\n } else if (SF && sweepAngle < 0) {\n sweepAngle += 2 * PI;\n }\n sweepAngle %= 2 * PI;\n\n const endAngle = startAngle + sweepAngle;\n\n // point.ellipticalArcStartAngle = startAngle;\n // point.ellipticalArcEndAngle = startAngle + sweepAngle;\n // point.ellipticalArcAngle = alpha;\n\n // point.ellipticalArcCenter = center;\n // point.resultantRx = rx;\n // point.resultantRy = ry;\n\n return {\n center,\n startAngle,\n endAngle,\n rx,\n ry,\n };\n};\n\n/**\n * Returns the length of an Arc segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the length of the Arc segment\n */\nconst getArcLength = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n): number => {\n const { rx, ry, startAngle, endAngle } = getArcProps(\n x1,\n y1,\n RX,\n RY,\n angle,\n LAF,\n SF,\n x,\n y,\n );\n return Math.abs(arcLengthBetween(rx, ry, startAngle, endAngle));\n};\n\n/**\n * Returns a point along an Arc segment at a given distance.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param RX the radius on X axis\n * @param RY the radius on Y axis\n * @param angle the ellipse rotation in degrees\n * @param LAF the large arc flag\n * @param SF the sweep flag\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance along the arc\n * @returns a point along the Arc segment\n */\nconst getPointAtArcLength = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n distance?: number,\n): { x: number; y: number } => {\n let point = { x: x1, y: y1 };\n const { center, rx, ry, startAngle, endAngle } = getArcProps(\n x1,\n y1,\n RX,\n RY,\n angle,\n LAF,\n SF,\n x,\n y,\n );\n\n /* istanbul ignore else @preserve */\n if (typeof distance === \"number\") {\n const sweepAngle = endAngle - startAngle;\n const length = Math.abs(arcLengthBetween(rx, ry, startAngle, endAngle));\n if (distance <= 0) {\n point = { x: x1, y: y1 };\n } else if (distance >= length) {\n point = { x, y };\n } else {\n /* istanbul ignore next @preserve */\n if (x1 === x && y1 === y) {\n return { x, y };\n }\n /* istanbul ignore next @preserve */\n if (rx === 0 || ry === 0) {\n return getPointAtLineLength(x1, y1, x, y, distance);\n }\n const { PI, cos, sin } = Math;\n const xRot = ((angle % 360) + 360) % 360;\n const xRotRad = xRot * (PI / 180);\n\n let lo = 0;\n let hi = 1;\n for (let i = 0; i < 25; i += 1) {\n const mid = (lo + hi) / 2;\n if (\n Math.abs(\n arcLengthBetween(rx, ry, startAngle, startAngle + sweepAngle * mid),\n ) < distance\n ) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n const alpha = startAngle + sweepAngle * ((lo + hi) / 2);\n const ellipseComponentX = rx * cos(alpha);\n const ellipseComponentY = ry * sin(alpha);\n\n point = {\n x: cos(xRotRad) * ellipseComponentX - sin(xRotRad) * ellipseComponentY +\n center.x,\n y: sin(xRotRad) * ellipseComponentX + cos(xRotRad) * ellipseComponentY +\n center.y,\n };\n }\n }\n\n return point;\n};\n\n/**\n * Returns the extrema for an Arc segment in the following format:\n * [MIN_X, MIN_Y, MAX_X, MAX_Y]\n *\n * @see https://github.com/herrstrietzel/svg-pathdata-getbbox\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param RX the radius on X axis\n * @param RY the radius on Y axis\n * @param angle the ellipse rotation in degrees\n * @param LAF the large arc flag\n * @param SF the sweep flag\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the extrema of the Arc segment\n */\nconst getArcBBox = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n): [number, number, number, number] => {\n const { center, rx, ry, startAngle, endAngle } = getArcProps(\n x1,\n y1,\n RX,\n RY,\n angle,\n LAF,\n SF,\n x,\n y,\n );\n const deltaAngle = endAngle - startAngle;\n const { min, max, tan, atan2, PI } = Math;\n\n // circle/elipse center coordinates\n const { x: cx, y: cy } = center;\n\n // rotation to radians\n const alpha = (angle * PI) / 180;\n const tangent = tan(alpha);\n\n /**\n * find min/max from zeroes of directional derivative along x and y\n * along x axis\n */\n const theta = atan2(-ry * tangent, rx);\n const angle1 = theta;\n const angle2 = theta + PI;\n const angle3 = atan2(ry, rx * tangent);\n const angle4 = angle3 + PI;\n const xArray = [x];\n const yArray = [y];\n\n // inner bounding box\n let xMin = min(x1, x);\n let xMax = max(x1, x);\n let yMin = min(y1, y);\n let yMax = max(y1, y);\n\n // on path point close after start\n const angleAfterStart = endAngle - deltaAngle * 0.00001;\n const pP2 = arcPoint(cx, cy, rx, ry, alpha, angleAfterStart);\n\n // on path point close before end\n const angleBeforeEnd = endAngle - deltaAngle * 0.99999;\n const pP3 = arcPoint(cx, cy, rx, ry, alpha, angleBeforeEnd);\n\n /**\n * expected extremes\n * if leaving inner bounding box\n * (between segment start and end point)\n * otherwise exclude elliptic extreme points\n */\n\n // right\n if (pP2[0] > xMax || pP3[0] > xMax) {\n // get point for this theta\n const p1 = arcPoint(cx, cy, rx, ry, alpha, angle1);\n xArray.push(p1[0]);\n yArray.push(p1[1]);\n }\n\n // left\n if (pP2[0] < xMin || pP3[0] < xMin) {\n // get anti-symmetric point\n const p2 = arcPoint(cx, cy, rx, ry, alpha, angle2);\n xArray.push(p2[0]);\n yArray.push(p2[1]);\n }\n\n // top\n if (pP2[1] < yMin || pP3[1] < yMin) {\n // get anti-symmetric point\n const p4 = arcPoint(cx, cy, rx, ry, alpha, angle4);\n xArray.push(p4[0]);\n yArray.push(p4[1]);\n }\n\n // bottom\n if (pP2[1] > yMax || pP3[1] > yMax) {\n // get point for this theta\n const p3 = arcPoint(cx, cy, rx, ry, alpha, angle3);\n xArray.push(p3[0]);\n yArray.push(p3[1]);\n }\n\n xMin = min.apply([], xArray);\n yMin = min.apply([], yArray);\n xMax = max.apply([], xArray);\n yMax = max.apply([], yArray);\n\n return [xMin, yMin, xMax, yMax] as [number, number, number, number];\n};\n\n/** The tools for elliptical arc computation. */\nconst arcTools = {\n angleBetween,\n arcLength,\n arcLengthAtAngle,\n arcLengthBetween,\n arcPoint,\n getArcBBox,\n getArcLength,\n getArcProps,\n getPointAtArcLength,\n};\n\nexport {\n angleBetween,\n arcLength,\n arcLengthAtAngle,\n arcLengthBetween,\n arcPoint,\n arcTools,\n getArcBBox,\n getArcLength,\n getArcProps,\n getPointAtArcLength,\n};\n","import { getBezierLength, getTAtBezierLength, minmaxC } from \"./bezier.ts\";\nimport type { BBoxMaxima, CubicCoordinates } from \"../types.ts\";\n\n/**\n * Returns a point at a given length of a CubicBezier segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param t a [0-1] ratio\n * @returns the point at cubic-bezier segment length\n */\nconst getPointAtCubicSegmentLength = (\n [x1, y1, c1x, c1y, c2x, c2y, x2, y2]: CubicCoordinates,\n t: number,\n): { x: number; y: number } => {\n const t1 = 1 - t;\n return {\n x: t1 ** 3 * x1 + 3 * t1 ** 2 * t * c1x + 3 * t1 * t ** 2 * c2x +\n t ** 3 * x2,\n y: t1 ** 3 * y1 + 3 * t1 ** 2 * t * c1y + 3 * t1 * t ** 2 * c2y +\n t ** 3 * y2,\n };\n};\n\n/**\n * Returns the length of a CubicBezier segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the CubicBezier segment length\n */\nconst getCubicLength = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n): number => {\n return getBezierLength([x1, y1, c1x, c1y, c2x, c2y, x2, y2]);\n};\n\n/**\n * Returns the point along a CubicBezier segment at a given distance.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to look at\n * @returns the point at CubicBezier length\n */\nconst getPointAtCubicLength = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n distance?: number,\n): { x: number; y: number } => {\n const distanceIsNumber = typeof distance === \"number\";\n let point = { x: x1, y: y1 };\n /* istanbul ignore else @preserve */\n if (distanceIsNumber) {\n const coords = [x1, y1, c1x, c1y, c2x, c2y, x2, y2] as CubicCoordinates;\n const currentLength = getBezierLength(coords);\n if (distance <= 0) {\n // first point already defined\n } else if (distance >= currentLength) {\n point = { x: x2, y: y2 };\n } else {\n const t = getTAtBezierLength(coords, distance);\n point = getPointAtCubicSegmentLength(coords, t);\n }\n }\n return point;\n};\n\n/**\n * Returns the bounding box of a CubicBezier segment in the following format:\n * [MIN_X, MIN_Y, MAX_X, MAX_Y]\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the extrema of the CubicBezier segment\n */\nconst getCubicBBox = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n): BBoxMaxima => {\n const cxMinMax = minmaxC([x1, c1x, c2x, x2]);\n const cyMinMax = minmaxC([y1, c1y, c2y, y2]);\n\n return [cxMinMax[0], cyMinMax[0], cxMinMax[1], cyMinMax[1]];\n};\n\n/** The tools for cubic Bezier computation. */\nconst cubicTools = {\n getCubicBBox,\n getCubicLength,\n getPointAtCubicLength,\n getPointAtCubicSegmentLength,\n};\n\nexport {\n cubicTools,\n getCubicBBox,\n getCubicLength,\n getPointAtCubicLength,\n getPointAtCubicSegmentLength,\n};\n","import { getBezierLength, getTAtBezierLength, minmaxQ } from \"./bezier.ts\";\nimport type { QuadCoordinates } from \"../types.ts\";\n\n/**\n * Returns the {x,y} coordinates of a point at a\n * given length of a quadratic-bezier segment.\n *\n * @see https://github.com/substack/point-at-length\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param t a [0-1] ratio\n * @returns the requested {x,y} coordinates\n */\nconst getPointAtQuadSegmentLength = (\n [x1, y1, cx, cy, x2, y2]: QuadCoordinates,\n t: number,\n): { x: number; y: number } => {\n const t1 = 1 - t;\n return {\n x: t1 ** 2 * x1 + 2 * t1 * t * cx + t ** 2 * x2,\n y: t1 ** 2 * y1 + 2 * t1 * t * cy + t ** 2 * y2,\n };\n};\n\n/**\n * Returns the length of a QuadraticBezier segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the QuadraticBezier segment length\n */\nconst getQuadLength = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n): number => {\n return getBezierLength([x1, y1, cx, cy, x2, y2]);\n};\n\n/**\n * Returns the point along a QuadraticBezier segment at a given distance.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to look at\n * @returns the point at QuadraticBezier length\n */\nconst getPointAtQuadLength = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n distance?: number,\n): { x: number; y: number } => {\n const distanceIsNumber = typeof distance === \"number\";\n let point = { x: x1, y: y1 };\n\n /* istanbul ignore else @preserve */\n if (distanceIsNumber) {\n const coords = [x1, y1, cx, cy, x2, y2] as QuadCoordinates;\n const currentLength = getBezierLength(coords);\n if (distance <= 0) {\n // first point already defined\n } else if (distance >= currentLength) {\n point = { x: x2, y: y2 };\n } else {\n const t = getTAtBezierLength(coords, distance);\n point = getPointAtQuadSegmentLength(coords, t);\n }\n }\n return point;\n};\n\n/**\n * Returns the bounding box of a QuadraticBezier segment in the following format:\n * [MIN_X, MIN_Y, MAX_X, MAX_Y]\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the extrema of the QuadraticBezier segment\n */\nconst getQuadBBox = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n): [number, number, number, number] => {\n const cxMinMax = minmaxQ([x1, cx, x2]);\n const cyMinMax = minmaxQ([y1, cy, y2]);\n return [cxMinMax[0], cyMinMax[0], cxMinMax[1], cyMinMax[1]] as [\n number,\n number,\n number,\n number,\n ];\n};\n/** The tools for quadratic Bezier computation. */\nconst quadTools = {\n getPointAtQuadLength,\n getPointAtQuadSegmentLength,\n getQuadBBox,\n getQuadLength,\n};\n\nexport {\n getPointAtQuadLength,\n getPointAtQuadSegmentLength,\n getQuadBBox,\n getQuadLength,\n quadTools,\n};\n","import { distanceSquareRoot } from \"./distanceSquareRoot.ts\";\nimport type { PointTuple } from \"../types.ts\";\n\n/**\n * d3-polygon-area\n * @see https://github.com/d3/d3-polygon\n *\n * Returns the area of a polygon.\n *\n * @param polygon Array of [x, y]\n * @returns Signed area\n */\nconst polygonArea = (polygon: PointTuple[]): number => {\n const n = polygon.length;\n let i = -1;\n let a: PointTuple;\n let b = polygon[n - 1];\n let area = 0;\n\n while (++i < n) {\n a = b;\n b = polygon[i];\n area += a[1] * b[0] - a[0] * b[1];\n }\n\n return area / 2;\n};\n\n/**\n * d3-polygon-length\n * https://github.com/d3/d3-polygon\n *\n * Returns the perimeter of a polygon.\n *\n * @param polygon an array of coordinates\n * @returns the polygon length\n */\nconst polygonLength = (polygon: PointTuple[]): number => {\n return polygon.reduce((length, point, i) => {\n if (i) {\n return length + distanceSquareRoot(polygon[i - 1], point);\n }\n return 0;\n }, 0);\n};\n\n/**\n * Computes the centroid (geometric center) of a polygon.\n * Uses average of all endpoint coordinates (robust for polygons and curves).\n *\n * @param polygon A polygon with consists of [x, y] tuples\n * @returns [x, y] centroid\n */\nconst polygonCentroid = (polygon: PointTuple[]): PointTuple => {\n if (polygon.length === 0) return [0, 0];\n\n let sumX = 0;\n let sumY = 0;\n\n for (const [x, y] of polygon) {\n sumX += x;\n sumY += y;\n }\n\n const count = polygon.length;\n return [sumX / count, sumY / count];\n};\n\n/** The tools for polygon computation. */\nconst polygonTools = {\n polygonArea,\n polygonLength,\n polygonCentroid,\n};\n\nexport { polygonArea, polygonCentroid, polygonLength, polygonTools };\n","/**\n * Returns an {x,y} vector rotated by a given\n * angle in radian.\n *\n * @param x the initial vector x\n * @param y the initial vector y\n * @param rad the radian vector angle\n * @returns the rotated vector\n */\nexport const rotateVector = (\n x: number,\n y: number,\n rad: number,\n): { x: number; y: number } => {\n const { sin, cos } = Math;\n const X = x * cos(rad) - y * sin(rad);\n const Y = x * sin(rad) + y * cos(rad);\n return { x: X, y: Y };\n};\n","/**\n * Rounds a number to the specified number of decimal places.\n *\n * @param n - The number to round\n * @param round - Number of decimal places\n * @returns The rounded number\n */\nexport const roundTo = (n: number, round: number): number => {\n const pow = round >= 1 ? 10 ** round : 1;\n\n return round > 0 ? Math.round(n * pow) / pow : Math.round(n);\n};\n","import type { Options } from \"../interface.ts\";\n\n/** SVGPathCommander default options */\nexport const defaultOptions: Options = {\n origin: [0, 0, 0],\n round: 4,\n};\n","/** Segment params length */\n\nexport const paramsCounts = {\n a: 7,\n c: 6,\n h: 1,\n l: 2,\n m: 2,\n r: 4,\n q: 4,\n s: 4,\n t: 2,\n v: 1,\n z: 0,\n};\n","import { paramsCounts } from \"./paramsCount.ts\";\nimport type { PathParser } from \"./pathParser.ts\";\nimport type { PathCommand, PathSegment, RelativeCommand } from \"../types.ts\";\n\n/**\n * Breaks the parsing of a pathString once a segment is finalized.\n *\n * @param path - The PathParser instance\n */\nexport const finalizeSegment = (path: PathParser): void => {\n let pathCommand = path.pathValue[path.segmentStart] as PathCommand;\n let relativeCommand = pathCommand.toLowerCase() as RelativeCommand;\n const { data } = path;\n\n while (data.length >= paramsCounts[relativeCommand]) {\n // overloaded `moveTo`\n // https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts\n if (relativeCommand === \"m\" && data.length > 2) {\n path.segments.push(\n [pathCommand as PathCommand | number].concat(\n data.splice(0, 2) as number[],\n ) as PathSegment,\n );\n relativeCommand = \"l\";\n pathCommand = pathCommand === \"m\" ? \"l\" : \"L\";\n } else {\n path.segments.push(\n [pathCommand as PathCommand | number].concat(\n data.splice(0, paramsCounts[relativeCommand]) as number[],\n ) as PathSegment,\n );\n }\n\n if (!paramsCounts[relativeCommand]) {\n break;\n }\n }\n};\n","/** Error prefix used in all SVGPathCommander TypeError messages. */\nexport const error = \"SVGPathCommanderError\";\n","import { error } from \"../util/error.ts\";\nimport type { PathParser } from \"./pathParser.ts\";\n\n/**\n * Validates an A (arc-to) specific path command value.\n * Usually a `large-arc-flag` or `sweep-flag`.\n *\n * @param path - The PathParser instance\n */\nexport const scanFlag = (path: PathParser) => {\n const { index, pathValue } = path;\n const code = pathValue.charCodeAt(index);\n\n if (code === 0x30 /* 0 */) {\n path.param = 0;\n path.index += 1;\n return;\n }\n\n if (code === 0x31 /* 1 */) {\n path.param = 1;\n path.index += 1;\n return;\n }\n\n path.err = `${error}: invalid Arc flag \"${\n pathValue[index]\n }\", expecting 0 or 1 at index ${index}`;\n};\n","import type { DigitNumber } from \"../types.ts\";\n\n/**\n * Checks if a character is a digit.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isDigit = (code: number): code is DigitNumber => {\n return code >= 48 && code <= 57; // 0..9\n};\n","/** Error message prefix used when a path string cannot be parsed. */\nexport const invalidPathValue = \"Invalid path value\";\n","import { isDigit } from \"./isDigit.ts\";\nimport { invalidPathValue } from \"./invalidPathValue.ts\";\nimport { error } from \"../util/error.ts\";\nimport type { PathParser } from \"./pathParser.ts\";\n\n/**\n * Validates every character of the path string,\n * every path command, negative numbers or floating point numbers.\n *\n * @param path - The PathParser instance\n */\nexport const scanParam = (path: PathParser) => {\n const { max, pathValue, index: start } = path;\n let index = start;\n let zeroFirst = false;\n let hasCeiling = false;\n let hasDecimal = false;\n let hasDot = false;\n let ch;\n\n if (index >= max) {\n path.err =\n `${error}: ${invalidPathValue} at index ${index}, \"pathValue\" is missing param`;\n return;\n }\n ch = pathValue.charCodeAt(index);\n\n if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {\n index += 1;\n // ch = (index < max) ? pathValue.charCodeAt(index) : 0;\n ch = pathValue.charCodeAt(index);\n }\n\n // This logic is shamelessly borrowed from Esprima\n // https://github.com/ariya/esprimas\n if (!isDigit(ch) && ch !== 0x2e /* . */) {\n // path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${\n pathValue[index]\n }\" is not a number`;\n return;\n }\n\n if (ch !== 0x2e /* . */) {\n zeroFirst = ch === 0x30 /* 0 */;\n index += 1;\n\n ch = pathValue.charCodeAt(index);\n\n if (zeroFirst && index < max) {\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDigit(ch)) {\n // path.err = 'SvgPath: numbers started with `0` such as `09`\n // are illegal (at pos ' + start + ')';\n path.err = `${error}: ${invalidPathValue} at index ${start}, \"${\n pathValue[start]\n }\" illegal number`;\n return;\n }\n }\n\n while (index < max && isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n hasCeiling = true;\n }\n\n ch = pathValue.charCodeAt(index);\n }\n\n if (ch === 0x2e /* . */) {\n hasDot = true;\n index += 1;\n while (isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n hasDecimal = true;\n }\n\n ch = pathValue.charCodeAt(index);\n }\n\n if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {\n if (hasDot && !hasCeiling && !hasDecimal) {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${\n pathValue[index]\n }\" invalid float exponent`;\n return;\n }\n\n index += 1;\n\n ch = pathValue.charCodeAt(index);\n\n if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {\n index += 1;\n }\n if (index < max && isDigit(pathValue.charCodeAt(index))) {\n while (index < max && isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n }\n } else {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${\n pathValue[index]\n }\" invalid integer exponent`;\n return;\n }\n }\n\n path.index = index;\n path.param = +path.pathValue.slice(start, index);\n};\n","import type { SpaceNumber } from \"../types.ts\";\n\n/**\n * Checks if the character is a space.\n *\n * @param ch the character to check\n * @returns check result\n */\n\nexport const isSpace = (ch: number): ch is SpaceNumber => {\n const allSpaces = [\n // Special spaces\n 0x1680,\n 0x180e,\n 0x2000,\n 0x2001,\n 0x2002,\n 0x2003,\n 0x2004,\n 0x2005,\n 0x2006,\n 0x2007,\n 0x2008,\n 0x2009,\n 0x200a,\n 0x202f,\n 0x205f,\n 0x3000,\n 0xfeff,\n // Line terminators\n 0x0a,\n 0x0d,\n 0x2028,\n 0x2029,\n // White spaces\n 0x20,\n 0x09,\n 0x0b,\n 0x0c,\n 0xa0,\n ];\n\n return allSpaces.includes(ch);\n};\n","import { isSpace } from \"./isSpace.ts\";\nimport type { PathParser } from \"./pathParser.ts\";\n\n/**\n * Points the parser to the next character in the\n * path string every time it encounters any kind of\n * space character.\n *\n * @param path - The PathParser instance\n */\nexport const skipSpaces = (path: PathParser): void => {\n const { pathValue, max } = path;\n while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {\n path.index += 1;\n }\n};\n","import type { PathCommandNumber } from \"../types.ts\";\n\n/**\n * Checks if the character is a path command.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isPathCommand = (code: number): code is PathCommandNumber => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n switch (code | 0x20) {\n case 0x6d /* m */:\n case 0x7a /* z */:\n case 0x6c /* l */:\n case 0x68 /* h */:\n case 0x76 /* v */:\n case 0x63 /* c */:\n case 0x73 /* s */:\n case 0x71 /* q */:\n case 0x74 /* t */:\n case 0x61 /* a */:\n // case 0x72/* r */:\n return true;\n default:\n return false;\n }\n};\n","import { isDigit } from \"./isDigit.ts\";\nimport type { DigitNumber } from \"../types.ts\";\n\n/**\n * Checks if the character is or belongs to a number.\n * [0-9]|+|-|.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isDigitStart = (\n code: number,\n): code is DigitNumber | 0x2b | 0x2d | 0x2e => {\n return isDigit(code) /* 0..9 */ || code === 0x2b /* + */ ||\n code === 0x2d /* - */ || code === 0x2e; /* . */\n};\n","/**\n * Checks if the character is an A (arc-to) path command.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isArcCommand = (code: number): code is 0x61 => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n return (code | 0x20) === 0x61;\n};\n","/**\n * Checks if the character is a MoveTo command.\n *\n * @param code the character to check\n * @returns check result\n */\nexport const isMoveCommand = (code: number): code is 0x6d | 0x4d => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n switch (code | 0x20) {\n case 0x6d /* m */:\n case 0x4d /* M */:\n return true;\n default:\n return false;\n }\n};\n","import { finalizeSegment } from \"./finalizeSegment.ts\";\nimport { paramsCounts } from \"./paramsCount.ts\";\nimport { scanFlag } from \"./scanFlag.ts\";\nimport { scanParam } from \"./scanParam.ts\";\nimport { skipSpaces } from \"./skipSpaces.ts\";\nimport { isPathCommand } from \"./isPathCommand.ts\";\nimport { isDigitStart } from \"./isDigitStart.ts\";\nimport { isArcCommand } from \"./isArcCommand.ts\";\nimport { isMoveCommand } from \"./isMoveCommand.ts\";\nimport { invalidPathValue } from \"./invalidPathValue.ts\";\nimport { error } from \"../util/error.ts\";\n\nimport type { PathParser } from \"./pathParser.ts\";\nimport type { PathSegment, RelativeCommand } from \"../types.ts\";\n\n/**\n * Scans every character in the path string to determine\n * where a segment starts and where it ends.\n *\n * @param path - The PathParser instance\n */\nexport const scanSegment = (path: PathParser) => {\n const { max, pathValue, index, segments } = path;\n const cmdCode = pathValue.charCodeAt(index);\n const reqParams =\n paramsCounts[pathValue[index].toLowerCase() as RelativeCommand];\n\n path.segmentStart = index;\n\n // segments always start with a path command\n if (!isPathCommand(cmdCode)) {\n path.err = `${error}: ${invalidPathValue} \"${\n pathValue[index]\n }\" is not a path command at index ${index}`;\n return;\n }\n\n // after a Z segment, we only expect a MoveTo path command\n const lastSegment = segments[segments.length - 1] as PathSegment | undefined;\n if (\n !isMoveCommand(cmdCode) &&\n lastSegment?.[0]?.toLocaleLowerCase() === \"z\"\n ) {\n path.err = `${error}: ${invalidPathValue} \"${\n pathValue[index]\n }\" is not a MoveTo path command at index ${index}`;\n return;\n }\n\n path.index += 1;\n skipSpaces(path);\n\n path.data = [];\n\n if (!reqParams) {\n // Z\n finalizeSegment(path);\n return;\n }\n\n for (;;) {\n for (let i = reqParams; i > 0; i -= 1) {\n if (isArcCommand(cmdCode) && (i === 3 || i === 4)) scanFlag(path);\n else scanParam(path);\n\n if (path.err.length) {\n return;\n }\n path.data.push(path.param);\n\n skipSpaces(path);\n\n // after ',' param is mandatory\n if (\n path.index < max &&\n pathValue.charCodeAt(path.index) === 0x2c /* , */\n ) {\n path.index += 1;\n skipSpaces(path);\n }\n }\n\n if (path.index >= path.max) {\n break;\n }\n\n // Stop on next segment\n if (!isDigitStart(pathValue.charCodeAt(path.index))) {\n break;\n }\n }\n\n finalizeSegment(path);\n};\n","import type { PathArray, PathSegment } from \"../types.ts\";\n\n/**\n * The `PathParser` is used by the `parsePathString` static method\n * to generate a `pathArray`.\n *\n * @param pathString - The SVG path string to parse\n */\nexport class PathParser {\n declare segments: PathArray | PathSegment[];\n declare pathValue: string;\n declare max: number;\n declare index: number;\n declare param: number;\n declare segmentStart: number;\n declare data: (string | number)[];\n declare err: string;\n\n constructor(pathString: string) {\n this.segments = [];\n this.pathValue = pathString;\n this.max = pathString.length;\n this.index = 0;\n this.param = 0.0;\n this.segmentStart = 0;\n this.data = [];\n this.err = \"\";\n }\n}\n","import { scanSegment } from \"./scanSegment.ts\";\nimport { skipSpaces } from \"./skipSpaces.ts\";\nimport { PathParser } from \"./pathParser.ts\";\nimport type { PathArray } from \"../types.ts\";\n\n/**\n * Parses a path string value and returns an array\n * of segments we like to call `PathArray`.\n *\n * If parameter value is already a `PathArray`,\n * return a clone of it.\n\n * @example\n * parsePathString(\"M 0 0L50 50\")\n * // => [[\"M\",0,0],[\"L\",50,50]]\n *\n * @param pathInput the string to be parsed\n * @returns the resulted `pathArray` or error string\n */\nexport const parsePathString = <T extends PathArray>(\n pathInput: string | T,\n): PathArray => {\n if (typeof pathInput !== \"string\") {\n return pathInput.slice(0) as T;\n }\n\n const path = new PathParser(pathInput);\n\n skipSpaces(path);\n\n while (path.index < path.max && !path.err.length) {\n scanSegment(path);\n }\n\n // handle valid paths first\n // handle errors second\n if (!path.err.length) {\n if (path.segments.length) {\n /**\n * force absolute first M\n * getPathBBox calculation requires first segment to be absolute\n * @see https://github.com/thednp/svg-path-commander/pull/49\n */\n path.segments[0][0] = \"M\";\n }\n } else {\n throw TypeError(path.err);\n }\n\n return path.segments as PathArray;\n};\n","import type {\n AbsoluteCommand,\n AbsoluteSegment,\n ASegment,\n CSegment,\n HSegment,\n LSegment,\n MSegment,\n PathSegment,\n QSegment,\n SSegment,\n TSegment,\n VSegment,\n} from \"../types.ts\";\n\n/**\n * Returns an absolute segment of a `PathArray` object.\n *\n * @param segment the segment object\n * @param index the segment index\n * @param lastX the last known X value\n * @param lastY the last known Y value\n * @returns the absolute segment\n */\nexport const absolutizeSegment = (\n segment: PathSegment,\n index: number,\n lastX: number,\n lastY: number,\n): AbsoluteSegment => {\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase() as AbsoluteCommand;\n const isAbsolute = absCommand === pathCommand;\n\n /* istanbul ignore else @preserve */\n if (index === 0 || isAbsolute) return segment as MSegment | AbsoluteSegment;\n // const values = segment.slice(1) as number[];\n if (absCommand === \"A\") {\n return [\n absCommand,\n segment[1],\n segment[2],\n segment[3],\n segment[4],\n segment[5],\n (segment as ASegment)[6] + lastX,\n (segment as ASegment)[7] + lastY,\n ] as ASegment;\n } else if (absCommand === \"V\") {\n return [absCommand, (segment as VSegment)[1] + lastY] as VSegment;\n } else if (absCommand === \"H\") {\n return [absCommand, (segment as HSegment)[1] + lastX] as HSegment;\n } else if (absCommand === \"L\") {\n return [\n absCommand,\n (segment as LSegment)[1] + lastX,\n (segment as LSegment)[2] + lastY,\n ] as LSegment;\n } else {\n // use brakets for `eslint: no-case-declaration`\n // https://stackoverflow.com/a/50753272/803358\n const absValues = [] as number[];\n const seglen = segment.length;\n for (let j = 1; j < seglen; j += 1) {\n absValues.push((segment[j] as number) + (j % 2 ? lastX : lastY));\n }\n // for c, s, q, t\n return [absCommand as typeof absCommand | number].concat(absValues) as\n | MSegment\n | QSegment\n | TSegment\n | SSegment\n | CSegment;\n }\n};\n","// import paramsParser from \"../parser/paramsParser.ts\";\nimport type { AbsoluteCommand, IteratorCallback, PathArray } from \"../types.ts\";\n\n/**\n * Iterates over a `PathArray`, executing a callback for each segment.\n * The callback can:\n * - Read current position (`x`, `y`)\n * - Modify the segment (return new segment)\n * - Stop early (return `false`)\n *\n * The iterator maintains accurate current point (`x`, `y`) and subpath start (`mx`, `my`)\n * while correctly handling relative/absolute commands, including H/V and Z.\n *\n * **Important**: If the callback returns a new segment with more coordinates (e.g., Q → C),\n * the path length may increase, and iteration will continue over new segments.\n *\n * @template T - Specific PathArray type (e.g., CurveArray, PolylineArray)\n * @param path - The source `PathArray` to iterate over\n * @param iterator - Callback function for each segment\n * @param iterator.segment - Current path segment\n * @param iterator.index - Index of current segment\n * @param iterator.x - Current X position (after applying relative offset)\n * @param iterator.y - Current Y position (after applying relative offset)\n * @returns The modified `path` (or original if no changes)\n *\n * @example\n * iterate(path, (seg, i, x, y) => {\n * if (seg[0] === 'L') return ['C', x, y, seg[1], seg[2], seg[1], seg[2]];\n * });\n */\nexport const iterate = <T extends PathArray>(\n path: T,\n iterator: IteratorCallback<T>,\n): T => {\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n let i = 0;\n while (i < path.length) {\n const segment = path[i];\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase() as AbsoluteCommand;\n const isRelative = absCommand !== pathCommand;\n\n const iteratorResult = iterator(segment, i, x, y);\n // some methods like getPointAtLength would like to break\n // when task is complete\n if (iteratorResult === false) {\n break;\n }\n\n // segment = path[i];\n if (absCommand === \"Z\") {\n x = mx;\n y = my;\n } else if (absCommand === \"H\") {\n x = (segment[1] as number) + (isRelative ? x : 0);\n } else if (absCommand === \"V\") {\n y = (segment[1] as number) + (isRelative ? y : 0);\n } else {\n const segLen = segment.length;\n\n x = (segment[segLen - 2] as number) + (isRelative ? x : 0);\n y = (segment[segLen - 1] as number) + (isRelative ? y : 0);\n\n if (absCommand === \"M\") {\n mx = x;\n my = y;\n }\n }\n\n if (iteratorResult) {\n path[i] = iteratorResult;\n }\n\n i += 1;\n }\n return path as T;\n};\n","import type { AbsoluteArray, PathArray } from \"../types.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { absolutizeSegment } from \"../process/absolutizeSegment.ts\";\nimport { iterate } from \"../process/iterate.ts\";\n\n/**\n * Parses a path string value or object and returns an array\n * of segments, all converted to absolute values.\n *\n * @param pathInput - The path string or PathArray\n * @returns The resulted PathArray with absolute values\n *\n * @example\n * ```ts\n * pathToAbsolute('M10 10l80 80')\n * // => [['M', 10, 10], ['L', 90, 90]]\n * ```\n */\nexport const pathToAbsolute = <T extends PathArray>(\n pathInput: string | T,\n): AbsoluteArray => {\n const path = parsePathString(pathInput);\n\n return iterate(path, absolutizeSegment) as AbsoluteArray;\n};\n","import type {\n aSegment,\n cSegment,\n hSegment,\n lSegment,\n MSegment,\n PathSegment,\n qSegment,\n RelativeCommand,\n RelativeSegment,\n sSegment,\n tSegment,\n vSegment,\n} from \"../types.ts\";\n\n/**\n * Returns a relative segment of a `PathArray` object.\n *\n * @param segment the segment object\n * @param index the segment index\n * @param lastX the last known X value\n * @param lastY the last known Y value\n * @returns the relative segment\n */\nexport const relativizeSegment = (\n segment: PathSegment,\n index: number,\n lastX: number,\n lastY: number,\n): MSegment | RelativeSegment => {\n const [pathCommand] = segment;\n const relCommand = pathCommand.toLowerCase() as RelativeCommand;\n const isRelative = pathCommand === relCommand;\n\n /* istanbul ignore else @preserve */\n if (index === 0 || isRelative) return segment as MSegment | RelativeSegment;\n\n if (relCommand === \"a\") {\n return [\n relCommand,\n segment[1],\n segment[2],\n segment[3],\n segment[4],\n segment[5],\n (segment as aSegment)[6] - lastX,\n (segment as aSegment)[7] - lastY,\n ] as aSegment;\n } else if (relCommand === \"v\") {\n return [relCommand, (segment as vSegment)[1] - lastY] as vSegment;\n } else if (relCommand === \"h\") {\n return [relCommand, (segment as hSegment)[1] - lastX] as hSegment;\n } else if (relCommand === \"l\") {\n return [\n relCommand,\n (segment as lSegment)[1] - lastX,\n (segment as lSegment)[2] - lastY,\n ] as lSegment;\n } else {\n // use brakets for `eslint: no-case-declaration`\n // https://stackoverflow.com/a/50753272/803358\n const relValues = [] as number[];\n const seglen = segment.length;\n for (let j = 1; j < seglen; j += 1) {\n relValues.push((segment[j] as number) - (j % 2 ? lastX : lastY));\n }\n // for c, s, q, t\n return [relCommand as RelativeCommand | number].concat(relValues) as\n | qSegment\n | tSegment\n | sSegment\n | cSegment;\n }\n};\n","import type { PathArray, RelativeArray } from \"../types.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { iterate } from \"../process/iterate.ts\";\nimport { relativizeSegment } from \"../process/relativizeSegment.ts\";\n\n/**\n * Parses a path string value or object and returns an array\n * of segments, all converted to relative values.\n *\n * @param pathInput - The path string or PathArray\n * @returns The resulted PathArray with relative values\n *\n * @example\n * ```ts\n * pathToRelative('M10 10L90 90')\n * // => [['M', 10, 10], ['l', 80, 80]]\n * ```\n */\nexport const pathToRelative = <T extends PathArray>(\n pathInput: string | T,\n): RelativeArray => {\n const path = parsePathString(pathInput);\n\n return iterate(path, relativizeSegment) as RelativeArray;\n};\n","import { rotateVector } from \"../math/rotateVector.ts\";\n\n/**\n * Converts A (arc-to) segments to C (cubic-bezier-to).\n *\n * For more information of where this math came from visit:\n * http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n *\n * @param X1 the starting x position\n * @param Y1 the starting y position\n * @param RX x-radius of the arc\n * @param RY y-radius of the arc\n * @param angle x-axis-rotation of the arc\n * @param LAF large-arc-flag of the arc\n * @param SF sweep-flag of the arc\n * @param X2 the ending x position\n * @param Y2 the ending y position\n * @param recursive the parameters needed to split arc into 2 segments\n * @returns the resulting cubic-bezier segment(s)\n */\nexport const arcToCubic = (\n X1: number,\n Y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n X2: number,\n Y2: number,\n recursive?: [number, number, number, number],\n): number[] => {\n let x1 = X1;\n let y1 = Y1;\n let rx = RX;\n let ry = RY;\n let x2 = X2;\n let y2 = Y2;\n // for more information of where this Math came from visit:\n // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n const d120 = (Math.PI * 120) / 180;\n\n const rad = (Math.PI / 180) * (+angle || 0);\n let res = [] as number[];\n let xy;\n let f1;\n let f2;\n let cx;\n let cy;\n\n if (!recursive) {\n xy = rotateVector(x1, y1, -rad);\n x1 = xy.x;\n y1 = xy.y;\n xy = rotateVector(x2, y2, -rad);\n x2 = xy.x;\n y2 = xy.y;\n\n const x = (x1 - x2) / 2;\n const y = (y1 - y2) / 2;\n let h = (x * x) / (rx * rx) + (y * y) / (ry * ry);\n if (h > 1) {\n h = Math.sqrt(h);\n rx *= h;\n ry *= h;\n }\n const rx2 = rx * rx;\n const ry2 = ry * ry;\n\n const k = (LAF === SF ? -1 : 1) *\n Math.sqrt(\n Math.abs(\n (rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x),\n ),\n );\n\n cx = (k * rx * y) / ry + (x1 + x2) / 2;\n cy = (k * -ry * x) / rx + (y1 + y2) / 2;\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise\n f1 = Math.asin(((((y1 - cy) / ry) * 10 ** 9) >> 0) / 10 ** 9);\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise\n f2 = Math.asin(((((y2 - cy) / ry) * 10 ** 9) >> 0) / 10 ** 9);\n\n f1 = x1 < cx ? Math.PI - f1 : f1;\n f2 = x2 < cx ? Math.PI - f2 : f2;\n if (f1 < 0) f1 = Math.PI * 2 + f1;\n if (f2 < 0) f2 = Math.PI * 2 + f2;\n if (SF && f1 > f2) {\n f1 -= Math.PI * 2;\n }\n if (!SF && f2 > f1) {\n f2 -= Math.PI * 2;\n }\n } else {\n [f1, f2, cx, cy] = recursive;\n }\n let df = f2 - f1;\n if (Math.abs(df) > d120) {\n const f2old = f2;\n const x2old = x2;\n const y2old = y2;\n f2 = f1 + d120 * (SF && f2 > f1 ? 1 : -1);\n x2 = cx + rx * Math.cos(f2);\n y2 = cy + ry * Math.sin(f2);\n res = arcToCubic(x2, y2, rx, ry, angle, 0, SF, x2old, y2old, [\n f2,\n f2old,\n cx,\n cy,\n ]);\n }\n df = f2 - f1;\n const c1 = Math.cos(f1);\n const s1 = Math.sin(f1);\n const c2 = Math.cos(f2);\n const s2 = Math.sin(f2);\n const t = Math.tan(df / 4);\n const hx = (4 / 3) * rx * t;\n const hy = (4 / 3) * ry * t;\n const m1 = [x1, y1];\n const m2 = [x1 + hx * s1, y1 - hy * c1];\n const m3 = [x2 + hx * s2, y2 - hy * c2];\n const m4 = [x2, y2];\n m2[0] = 2 * m1[0] - m2[0];\n m2[1] = 2 * m1[1] - m2[1];\n if (recursive) {\n return [m2[0], m2[1], m3[0], m3[1], m4[0], m4[1]].concat(res);\n }\n res = [m2[0], m2[1], m3[0], m3[1], m4[0], m4[1]].concat(res);\n const newres = [];\n for (let i = 0, ii = res.length; i < ii; i += 1) {\n newres[i] = i % 2\n ? rotateVector(res[i - 1], res[i], rad).y\n : rotateVector(res[i], res[i + 1], rad).x;\n }\n return newres;\n};\n","/**\n * Converts a Q (quadratic-bezier) segment to C (cubic-bezier).\n *\n * @param x1 curve start x\n * @param y1 curve start y\n * @param qx control point x\n * @param qy control point y\n * @param x2 curve end x\n * @param y2 curve end y\n * @returns the cubic-bezier segment\n */\nexport const quadToCubic = (\n x1: number,\n y1: number,\n qx: number,\n qy: number,\n x2: number,\n y2: number,\n): [number, number, number, number, number, number] => {\n const r13 = 1 / 3;\n const r23 = 2 / 3;\n return [\n r13 * x1 + r23 * qx, // cpx1\n r13 * y1 + r23 * qy, // cpy1\n r13 * x2 + r23 * qx, // cpx2\n r13 * y2 + r23 * qy, // cpy2\n x2,\n y2, // x,y\n ];\n};\n","import { midPoint } from \"../math/midPoint.ts\";\n\n/**\n * Converts an L (line-to) segment to C (cubic-bezier).\n *\n * @param x1 line start x\n * @param y1 line start y\n * @param x2 line end x\n * @param y2 line end y\n * @returns the cubic-bezier segment\n */\nexport const lineToCubic = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number[] => {\n const c1 = midPoint([x1, y1], [x2, y2], 1.0 / 3.0);\n const c2 = midPoint([x1, y1], [x2, y2], 2.0 / 3.0);\n return [c1[0], c1[1], c2[0], c2[1], x2, y2];\n};\n","import { arcToCubic } from \"./arcToCubic.ts\";\nimport { quadToCubic } from \"./quadToCubic.ts\";\nimport { lineToCubic } from \"./lineToCubic.ts\";\nimport type { CSegment, MSegment, PathSegment } from \"../types.ts\";\nimport type { ParserParams } from \"../interface.ts\";\n\n/**\n * Converts any segment to C (cubic-bezier).\n *\n * @param segment the source segment\n * @param params the source segment parameters\n * @returns the cubic-bezier segment\n */\nexport const segmentToCubic = (\n segment: PathSegment,\n params: ParserParams,\n): MSegment | CSegment => {\n const pathCommand = segment[0];\n const values = segment.slice(1).map(Number);\n const [x, y] = values;\n // let args;\n // const { x1: px1, y1: py1, x: px, y: py } = params;\n const { x1: px1, y1: py1 } = params;\n\n if (!\"TQ\".includes(pathCommand)) {\n params.qx = null;\n params.qy = null;\n }\n\n if (pathCommand === \"M\") {\n params.mx = x;\n params.my = y;\n params.x = x;\n params.y = y;\n return segment;\n } else if (pathCommand === \"A\") {\n return [\"C\" as string | number].concat(\n arcToCubic(\n px1,\n py1,\n values[0],\n values[1],\n values[2],\n values[3],\n values[4],\n values[5],\n values[6],\n ),\n ) as CSegment;\n } else if (pathCommand === \"Q\") {\n params.qx = x;\n params.qy = y;\n return [\"C\" as string | number].concat(\n quadToCubic(px1, py1, values[0], values[1], values[2], values[3]),\n ) as CSegment;\n } else if (pathCommand === \"L\") {\n return [\"C\" as string | number].concat(\n lineToCubic(px1, py1, x, y),\n ) as CSegment;\n } else if (pathCommand === \"Z\") {\n return [\"C\" as string | number].concat(\n lineToCubic(px1, py1, params.mx, params.my),\n ) as CSegment;\n }\n\n return segment as MSegment | CSegment;\n};\n","import type { ParserParams } from \"../interface.ts\";\nimport type {\n ASegment,\n CSegment,\n HSegment,\n LSegment,\n MSegment,\n NormalSegment,\n PathCommand,\n PathSegment,\n PointTuple,\n QSegment,\n VSegment,\n} from \"../types.ts\";\n\n/**\n * Normalizes a single segment of a `pathArray` object.\n *\n * @param segment the segment object\n * @param params the normalization parameters\n * @returns the normalized segment\n */\nexport const normalizeSegment = (\n segment: PathSegment,\n params: ParserParams,\n): NormalSegment => {\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = pathCommand !== absCommand;\n const { x1: px1, y1: py1, x2: px2, y2: py2, x, y } = params;\n const values = segment.slice(1) as number[];\n let absValues = values.map((n, j) => n + (isRelative ? (j % 2 ? y : x) : 0));\n\n if (!\"TQ\".includes(absCommand)) {\n // optional but good to be cautious\n params.qx = null;\n params.qy = null;\n }\n\n // istanbul ignore else @preserve\n if (absCommand === \"A\") {\n absValues = values.slice(0, -2).concat(\n values[5] + (isRelative ? x : 0),\n values[6] + (isRelative ? y : 0),\n );\n\n return [\"A\" as PathCommand | number].concat(absValues) as ASegment;\n } else if (absCommand === \"H\") {\n return [\n \"L\",\n (segment as HSegment)[1] + (isRelative ? x : 0),\n py1,\n ] as LSegment;\n } else if (absCommand === \"V\") {\n return [\n \"L\",\n px1,\n (segment as VSegment)[1] + (isRelative ? y : 0),\n ] as LSegment;\n } else if (absCommand === \"L\") {\n return [\n \"L\",\n (segment as LSegment)[1] + (isRelative ? x : 0),\n (segment as LSegment)[2] + (isRelative ? y : 0),\n ] as LSegment;\n } else if (absCommand === \"M\") {\n return [\n \"M\",\n (segment as MSegment)[1] + (isRelative ? x : 0),\n (segment as MSegment)[2] + (isRelative ? y : 0),\n ] as MSegment;\n } else if (absCommand === \"C\") {\n return [\"C\" as PathCommand | number].concat(absValues) as CSegment;\n } else if (absCommand === \"S\") {\n const x1 = px1 * 2 - px2;\n const y1 = py1 * 2 - py2;\n params.x1 = x1;\n params.y1 = y1;\n return [\"C\", x1, y1].concat(absValues) as CSegment;\n } else if (absCommand === \"T\") {\n const qx = px1 * 2 - (params.qx ? params.qx : /* istanbul ignore next */ 0);\n const qy = py1 * 2 - (params.qy ? params.qy : /* istanbul ignore next */ 0);\n params.qx = qx;\n params.qy = qy;\n return [\"Q\", qx, qy].concat(absValues) as QSegment;\n } else if (absCommand === \"Q\") {\n const [nqx, nqy] = absValues as PointTuple;\n params.qx = nqx;\n params.qy = nqy;\n return [\"Q\" as PathCommand | number].concat(absValues) as QSegment;\n } else if (absCommand === \"Z\") {\n return [\"Z\"] as NormalSegment;\n }\n\n // istanbul ignore next @preserve\n return segment as NormalSegment;\n};\n","import type { ParserParams } from \"../interface.ts\";\n\n/**\n * Default parser parameters object used to track position state\n * while iterating through path segments.\n */\nexport const paramsParser: ParserParams = {\n mx: 0,\n my: 0,\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n x: 0,\n y: 0,\n qx: null,\n qy: null,\n};\n","import { segmentToCubic } from \"../process/segmentToCubic.ts\";\nimport type {\n AbsoluteCommand,\n CSegment,\n CurveArray,\n PathArray,\n} from \"../types.ts\";\nimport { iterate } from \"../process/iterate.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { normalizeSegment } from \"../process/normalizeSegment.ts\";\nimport { paramsParser } from \"../parser/paramsParser.ts\";\n\n/**\n * Parses a path string or PathArray and returns a new one\n * in which all segments are converted to cubic-bezier.\n *\n * @param pathInput - The path string or PathArray\n * @returns The resulted CurveArray with all segments as cubic beziers\n *\n * @example\n * ```ts\n * pathToCurve('M10 50q15 -25 30 0')\n * // => [['M', 10, 50], ['C', 25, 25, 40, 50, 40, 50]]\n * ```\n */\nexport const pathToCurve = <T extends PathArray>(\n pathInput: string | T,\n): CurveArray => {\n const params = { ...paramsParser };\n const path = parsePathString(pathInput);\n // let mx = 0;\n // let my = 0;\n\n return iterate(path, (seg, index, lastX, lastY) => {\n params.x = lastX;\n params.y = lastY;\n const normalSegment = normalizeSegment(seg, params);\n if (normalSegment[0] === \"M\") {\n params.mx = normalSegment[1];\n params.my = normalSegment[2];\n }\n let result = segmentToCubic(normalSegment, params);\n const isLongArc = result[0] === \"C\" && result.length > 7;\n\n if (isLongArc) {\n path.splice(\n index + 1,\n 0,\n [\"C\" as AbsoluteCommand | number].concat(result.slice(7)) as CSegment,\n );\n result = result.slice(0, 7) as CSegment;\n }\n\n const seglen = result.length;\n params.x1 = +result[seglen - 2];\n params.y1 = +result[seglen - 1];\n params.x2 = +result[seglen - 4] || params.x1;\n params.y2 = +result[seglen - 3] || params.y1;\n\n return result;\n }) as CurveArray;\n};\n","import type { PathArray, PathSegment } from \"../types.ts\";\nimport { defaultOptions } from \"../options/options.ts\";\nimport { roundTo } from \"../math/roundTo.ts\";\n\n/**\n * Returns a valid `d` attribute string value created\n * by rounding values and concatenating the PathArray segments.\n *\n * @param path - The PathArray object\n * @param roundOption - Amount of decimals to round values to, or \"off\"\n * @returns The concatenated path string\n *\n * @example\n * ```ts\n * pathToString([['M', 10, 10], ['L', 90, 90]], 2)\n * // => 'M10 10L90 90'\n * ```\n */\nexport const pathToString = <T extends PathArray>(\n path: T,\n roundOption?: number | \"off\",\n): string => {\n const pathLen = path.length;\n let { round } = defaultOptions;\n let segment = path[0] as PathSegment;\n let result = \"\";\n\n // allow for ZERO decimals\n round = roundOption === \"off\"\n ? roundOption\n : typeof roundOption === \"number\" && roundOption >= 0\n ? roundOption\n : typeof round === \"number\" && round >= 0\n ? round\n : \"off\";\n\n for (let i = 0; i < pathLen; i += 1) {\n segment = path[i];\n const [pathCommand] = segment;\n const values = segment.slice(1) as number[];\n result += pathCommand;\n if (round === \"off\") {\n result += values.join(\" \");\n } else {\n let j = 0;\n const valLen = values.length;\n while (j < valLen) {\n result += roundTo(values[j], round);\n if (j !== valLen - 1) result += \" \";\n j += 1;\n }\n }\n }\n\n return result;\n};\n","import { iterate } from \"../process/iterate.ts\";\nimport type { PathBBox } from \"../interface.ts\";\nimport type { LSegment, MSegment, PathArray, PointTuple } from \"../types.ts\";\nimport { getLineBBox } from \"../math/lineTools.ts\";\nimport { getArcBBox } from \"../math/arcTools.ts\";\nimport { getCubicBBox } from \"../math/cubicTools.ts\";\nimport { getQuadBBox } from \"../math/quadTools.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { absolutizeSegment } from \"../process/absolutizeSegment.ts\";\n\n/**\n * Calculates the bounding box of a path.\n *\n * @param pathInput - The path string or PathArray\n * @returns An object with width, height, x, y, x2, y2, cx, cy, cz properties\n *\n * @example\n * ```ts\n * getPathBBox('M0 0L100 0L100 100L0 100Z')\n * // => { x: 0, y: 0, width: 100, height: 100, x2: 100, y2: 100, cx: 50, cy: 50, cz: 150 }\n * ```\n */\nexport const getPathBBox = <T extends PathArray>(\n pathInput: T | string,\n): {\n x: number;\n y: number;\n width: number;\n height: number;\n x2: number;\n y2: number;\n cx: number;\n cy: number;\n cz: number;\n} => {\n if (!pathInput) {\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n x2: 0,\n y2: 0,\n cx: 0,\n cy: 0,\n cz: 0,\n };\n }\n\n const path = parsePathString(pathInput);\n let pathCommand = \"M\";\n let mx = 0;\n let my = 0;\n const { max, min } = Math;\n let xMin = Infinity;\n let yMin = Infinity;\n let xMax = -Infinity;\n let yMax = -Infinity;\n let minX = 0;\n let minY = 0;\n let maxX = 0;\n let maxY = 0;\n let paramX1 = 0;\n let paramY1 = 0;\n let paramX2 = 0;\n let paramY2 = 0;\n let paramQX = 0;\n let paramQY = 0;\n\n iterate(path, (seg, index, lastX, lastY) => {\n [pathCommand] = seg;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = absCommand !== pathCommand;\n const absoluteSegment = isRelative\n ? absolutizeSegment(seg, index, lastX, lastY)\n : (seg.slice(0) as typeof seg);\n\n const normalSegment = absCommand === \"V\"\n ? ([\"L\", lastX, absoluteSegment[1]] as LSegment)\n : absCommand === \"H\"\n ? ([\"L\", absoluteSegment[1], lastY] as LSegment)\n : absoluteSegment;\n\n [pathCommand] = normalSegment;\n\n if (!\"TQ\".includes(absCommand)) {\n // optional but good to be cautious\n paramQX = 0;\n paramQY = 0;\n }\n\n // this segment is always ZERO\n /* istanbul ignore else @preserve */\n if (pathCommand === \"M\") {\n [, mx, my] = normalSegment as MSegment;\n minX = mx;\n minY = my;\n maxX = mx;\n maxY = my;\n } else if (pathCommand === \"L\") {\n [minX, minY, maxX, maxY] = getLineBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"A\") {\n [minX, minY, maxX, maxY] = getArcBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n normalSegment[7] as number,\n );\n } else if (pathCommand === \"S\") {\n const cp1x = paramX1 * 2 - paramX2;\n const cp1y = paramY1 * 2 - paramY2;\n\n [minX, minY, maxX, maxY] = getCubicBBox(\n lastX,\n lastY,\n cp1x,\n cp1y,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"C\") {\n [minX, minY, maxX, maxY] = getCubicBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n );\n } else if (pathCommand === \"T\") {\n paramQX = paramX1 * 2 - paramQX;\n paramQY = paramY1 * 2 - paramQY;\n [minX, minY, maxX, maxY] = getQuadBBox(\n lastX,\n lastY,\n paramQX,\n paramQY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"Q\") {\n paramQX = normalSegment[1] as number;\n paramQY = normalSegment[2] as number;\n [minX, minY, maxX, maxY] = getQuadBBox(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"Z\") {\n [minX, minY, maxX, maxY] = getLineBBox(lastX, lastY, mx, my);\n }\n xMin = min(minX, xMin);\n yMin = min(minY, yMin);\n xMax = max(maxX, xMax);\n yMax = max(maxY, yMax);\n\n // update params\n [paramX1, paramY1] = pathCommand === \"Z\"\n ? [mx, my]\n : (normalSegment.slice(-2) as PointTuple);\n [paramX2, paramY2] = pathCommand === \"C\"\n ? ([normalSegment[3], normalSegment[4]] as PointTuple)\n : pathCommand === \"S\"\n ? ([normalSegment[1], normalSegment[2]] as PointTuple)\n : [paramX1, paramY1];\n });\n\n const width = xMax - xMin;\n const height = yMax - yMin;\n\n return {\n width,\n height,\n x: xMin,\n y: yMin,\n x2: xMax,\n y2: yMax,\n cx: xMin + width / 2,\n cy: yMin + height / 2,\n // an estimated guess\n cz: Math.max(width, height) + Math.min(width, height) / 2,\n } satisfies PathBBox;\n};\n","import type { LSegment, MSegment, PathArray, PointTuple } from \"../types.ts\";\nimport { getLineLength } from \"../math/lineTools.ts\";\nimport { getArcLength } from \"../math/arcTools.ts\";\nimport { getCubicLength } from \"../math/cubicTools.ts\";\nimport { getQuadLength } from \"../math/quadTools.ts\";\nimport { iterate } from \"../process/iterate.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { absolutizeSegment } from \"../process/absolutizeSegment.ts\";\n\n/**\n * Returns the total length of a path, equivalent to `shape.getTotalLength()`.\n *\n * @param pathInput - The target path string or PathArray\n * @returns The total length of the path\n *\n * @example\n * ```ts\n * getTotalLength('M0 0L100 0L100 100L0 100Z')\n * // => 300\n * ```\n */\nexport const getTotalLength = <T extends PathArray>(\n pathInput: string | T,\n): number => {\n const path = parsePathString(pathInput);\n let paramX1 = 0;\n let paramY1 = 0;\n let paramX2 = 0;\n let paramY2 = 0;\n let paramQX = 0;\n let paramQY = 0;\n let pathCommand = \"M\";\n let mx = 0;\n let my = 0;\n let totalLength = 0;\n\n iterate(path, (seg, index, lastX, lastY) => {\n [pathCommand] = seg;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = absCommand !== pathCommand;\n const absoluteSegment = isRelative\n ? absolutizeSegment(seg, index, lastX, lastY)\n : (seg.slice(0) as typeof seg);\n\n const normalSegment = absCommand === \"V\"\n ? ([\"L\", lastX, absoluteSegment[1]] as LSegment)\n : absCommand === \"H\"\n ? ([\"L\", absoluteSegment[1], lastY] as LSegment)\n : absoluteSegment;\n [pathCommand] = normalSegment;\n\n if (!\"TQ\".includes(absCommand)) {\n // optional but good to be cautious\n paramQX = 0;\n paramQY = 0;\n }\n\n // this segment is always ZERO\n /* istanbul ignore else @preserve */\n if (pathCommand === \"M\") {\n // remember mx, my for Z\n [, mx, my] = normalSegment as MSegment;\n } else if (pathCommand === \"L\") {\n totalLength += getLineLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"A\") {\n totalLength += getArcLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n normalSegment[7] as number,\n );\n } else if (pathCommand === \"S\") {\n const cp1x = paramX1 * 2 - paramX2;\n const cp1y = paramY1 * 2 - paramY2;\n\n totalLength += getCubicLength(\n lastX,\n lastY,\n cp1x,\n cp1y,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"C\") {\n totalLength += getCubicLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n normalSegment[5] as number,\n normalSegment[6] as number,\n );\n } else if (pathCommand === \"T\") {\n paramQX = paramX1 * 2 - paramQX;\n paramQY = paramY1 * 2 - paramQY;\n totalLength += getQuadLength(\n lastX,\n lastY,\n paramQX,\n paramQY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n );\n } else if (pathCommand === \"Q\") {\n paramQX = normalSegment[1] as number;\n paramQY = normalSegment[2] as number;\n totalLength += getQuadLength(\n lastX,\n lastY,\n normalSegment[1] as number,\n normalSegment[2] as number,\n normalSegment[3] as number,\n normalSegment[4] as number,\n );\n } else if (pathCommand === \"Z\") {\n totalLength += getLineLength(lastX, lastY, mx, my);\n }\n\n // update params\n [paramX1, paramY1] = pathCommand === \"Z\"\n ? [mx, my]\n : (normalSegment.slice(-2) as PointTuple);\n [paramX2, paramY2] = pathCommand === \"C\"\n ? ([normalSegment[3], normalSegment[4]] as PointTuple)\n : pathCommand === \"S\"\n ? ([normalSegment[1], normalSegment[2]] as PointTuple)\n : [paramX1, paramY1];\n });\n\n return totalLength;\n};\n","/** Small threshold value used for floating-point distance comparisons in path calculations. */\nconst DISTANCE_EPSILON = 0.00001;\n\nexport default DISTANCE_EPSILON;\n","import type { NormalArray, PathArray } from \"../types.ts\";\nimport { normalizeSegment } from \"./normalizeSegment.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { paramsParser } from \"../parser/paramsParser.ts\";\nimport { iterate } from \"./iterate.ts\";\n\n/**\n * Parses a path string or PathArray, then iterates the result for:\n * * converting segments to absolute values\n * * converting shorthand commands to their non-shorthand notation\n *\n * @param pathInput - The path string or PathArray\n * @returns The normalized PathArray\n *\n * @example\n * ```ts\n * normalizePath('M10 90s20 -80 40 -80s20 80 40 80')\n * // => [['M', 10, 90], ['C', 30, 90, 25, 10, 50, 10], ['C', 75, 10, 70, 90, 90, 90]]\n * ```\n */\nexport const normalizePath = <T extends string | PathArray>(\n pathInput: T,\n): NormalArray => {\n const path = parsePathString(pathInput);\n const params = { ...paramsParser };\n\n return iterate(path, (seg, _, lastX, lastY) => {\n params.x = lastX;\n params.y = lastY;\n const result = normalizeSegment(seg, params);\n\n const seglen = result.length;\n params.x1 = +result[seglen - 2];\n params.y1 = +result[seglen - 1];\n params.x2 = +result[seglen - 4] || params.x1;\n params.y2 = +result[seglen - 3] || params.y1;\n\n return result;\n }) as NormalArray;\n};\n","import DISTANCE_EPSILON from \"./distanceEpsilon.ts\";\nimport type { MSegment, PathArray, PointTuple } from \"../types.ts\";\nimport { iterate } from \"../process/iterate.ts\";\nimport { getLineLength, getPointAtLineLength } from \"../math/lineTools.ts\";\nimport { getArcLength, getPointAtArcLength } from \"../math/arcTools.ts\";\nimport { getCubicLength, getPointAtCubicLength } from \"../math/cubicTools.ts\";\nimport { getPointAtQuadLength, getQuadLength } from \"../math/quadTools.ts\";\nimport { normalizePath } from \"../process/normalizePath.ts\";\n\n/**\n * Returns [x,y] coordinates of a point at a given length along a path.\n *\n * @param pathInput - The PathArray or path string to look into\n * @param distance - The distance along the path\n * @returns The requested {x, y} point coordinates\n *\n * @example\n * ```ts\n * getPointAtLength('M0 0L100 0L100 100Z', 50)\n * // => { x: 50, y: 0 }\n * ```\n */\nexport const getPointAtLength = <T extends PathArray>(\n pathInput: string | T,\n distance?: number,\n): { x: number; y: number } => {\n const path = normalizePath(pathInput);\n let isM = false;\n let data = [] as number[];\n let [mx, my] = path[0].slice(1) as PointTuple;\n const distanceIsNumber = typeof distance === \"number\";\n let point = { x: mx, y: my };\n let length = 0;\n let POINT = point;\n let totalLength = 0;\n\n if (!distanceIsNumber || distance < DISTANCE_EPSILON) return point;\n\n iterate(path, (seg, _, lastX, lastY) => {\n const pathCommand = seg[0];\n isM = pathCommand === \"M\";\n data = !isM ? [lastX, lastY].concat(seg.slice(1) as number[]) : data;\n\n // this segment is always ZERO\n /* istanbul ignore else @preserve */\n if (isM) {\n // remember mx, my for Z\n [, mx, my] = seg as MSegment;\n point = { x: mx, y: my };\n length = 0;\n } else if (pathCommand === \"L\") {\n point = getPointAtLineLength(\n data[0],\n data[1],\n data[2],\n data[3],\n distance - totalLength,\n );\n length = getLineLength(data[0], data[1], data[2], data[3]);\n } else if (pathCommand === \"A\") {\n point = getPointAtArcLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n data[8],\n distance - totalLength,\n );\n length = getArcLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n data[8],\n );\n } else if (pathCommand === \"C\") {\n point = getPointAtCubicLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n distance - totalLength,\n );\n length = getCubicLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n data[6],\n data[7],\n );\n } else if (pathCommand === \"Q\") {\n point = getPointAtQuadLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n distance - totalLength,\n );\n length = getQuadLength(\n data[0],\n data[1],\n data[2],\n data[3],\n data[4],\n data[5],\n );\n } else if (pathCommand === \"Z\") {\n data = [lastX, lastY, mx, my];\n point = getPointAtLineLength(\n data[0],\n data[1],\n data[2],\n data[3],\n distance - totalLength,\n );\n\n length = getLineLength(data[0], data[1], data[2], data[3]);\n }\n\n if (totalLength < distance) {\n POINT = point;\n } else {\n // totalLength >= distance\n // stop right here\n // stop iterator now!\n return false;\n }\n\n totalLength += length;\n return;\n });\n\n // native `getPointAtLength` behavior when the given distance\n // is higher than total length: clamp to the last point on path\n // (captured by POINT in the last processed segment; using x, y\n // would erroneously reflect the start of the *next* segment at\n // interior segment boundaries — see #61).\n return POINT;\n};\n","import type { PathArray, PathSegment } from \"../types.ts\";\nimport type { SegmentProperties } from \"../interface.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { getTotalLength } from \"./getTotalLength.ts\";\n\n/**\n * Returns the segment, its index and length as well as\n * the length to that segment at a given length in a path.\n *\n * @param pathInput target `pathArray`\n * @param distance the given length\n * @returns the requested properties\n */\nexport const getPropertiesAtLength = <T extends PathArray>(\n pathInput: string | T,\n distance?: number,\n): SegmentProperties => {\n const pathArray = parsePathString(pathInput);\n\n let pathTemp = pathArray.slice(0) as T;\n let pathLength = getTotalLength(pathTemp);\n let index = pathTemp.length - 1;\n let lengthAtSegment = 0;\n let length = 0;\n let segment = pathArray[0] as PathSegment;\n\n // If the path is empty, return 0.\n if (index <= 0 || !distance || !Number.isFinite(distance)) {\n return {\n segment,\n index: 0,\n length,\n lengthAtSegment,\n };\n }\n\n if (distance >= pathLength) {\n pathTemp = pathArray.slice(0, -1) as T;\n lengthAtSegment = getTotalLength(pathTemp);\n length = pathLength - lengthAtSegment;\n segment = pathArray[index];\n return {\n segment,\n index,\n length,\n lengthAtSegment,\n };\n }\n\n const segments = [] as SegmentProperties[];\n while (index > 0) {\n segment = pathTemp[index];\n pathTemp = pathTemp.slice(0, -1) as T;\n lengthAtSegment = getTotalLength(pathTemp);\n length = pathLength - lengthAtSegment;\n pathLength = lengthAtSegment;\n\n segments.push({\n segment,\n index,\n length,\n lengthAtSegment,\n });\n index -= 1;\n }\n\n return segments.find(\n ({ lengthAtSegment: l }) => l <= distance,\n ) as SegmentProperties;\n};\n","import type { PathArray, Point } from \"../types.ts\";\nimport type { PointProperties } from \"../interface.ts\";\nimport { getPointAtLength } from \"./getPointAtLength.ts\";\nimport { getPropertiesAtLength } from \"./getPropertiesAtLength.ts\";\nimport { getTotalLength } from \"./getTotalLength.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { normalizePath } from \"../process/normalizePath.ts\";\n\n/**\n * Returns the point and segment in path closest to a given point as well as\n * the distance to the path stroke.\n *\n * @see https://bl.ocks.org/mbostock/8027637\n *\n * @param pathInput target `pathArray`\n * @param point the given point\n * @returns the requested properties\n */\nexport const getPropertiesAtPoint = <T extends PathArray>(\n pathInput: string | T,\n point: Point,\n): PointProperties => {\n const path = parsePathString(pathInput);\n const normalPath = normalizePath(path);\n const pathLength = getTotalLength(normalPath);\n const distanceTo = (p: Point) => {\n const dx = p.x - point.x;\n const dy = p.y - point.y;\n return dx * dx + dy * dy;\n };\n let precision = 8;\n let scan: Point;\n let closest = { x: 0, y: 0 }; // make TS happy\n let scanDistance = 0;\n let bestLength = 0;\n let bestDistance = Infinity;\n\n // linear scan for coarse approximation\n for (let scanLength = 0; scanLength <= pathLength; scanLength += precision) {\n scan = getPointAtLength(normalPath, scanLength);\n scanDistance = distanceTo(scan);\n\n if (scanDistance < bestDistance) {\n closest = scan;\n bestLength = scanLength;\n bestDistance = scanDistance;\n }\n }\n\n // binary search for precise estimate\n precision /= 2;\n let before: { x: number; y: number };\n let after: { x: number; y: number };\n let beforeLength = 0;\n let afterLength = 0;\n let beforeDistance = 0;\n let afterDistance = 0;\n\n while (precision > 0.000001) {\n beforeLength = bestLength - precision;\n before = getPointAtLength(normalPath, beforeLength);\n beforeDistance = distanceTo(before);\n afterLength = bestLength + precision;\n after = getPointAtLength(normalPath, afterLength);\n afterDistance = distanceTo(after);\n\n if (beforeLength >= 0 && beforeDistance < bestDistance) {\n closest = before;\n bestLength = beforeLength;\n bestDistance = beforeDistance;\n } else if (afterLength <= pathLength && afterDistance < bestDistance) {\n closest = after;\n bestLength = afterLength;\n bestDistance = afterDistance;\n } else {\n precision /= 2;\n }\n if (precision < 0.00001) break;\n }\n\n const segment = getPropertiesAtLength(path, bestLength);\n const distance = Math.sqrt(bestDistance);\n\n return { closest, distance, segment };\n};\n","import type { PathArray } from \"../types.ts\";\nimport { getPropertiesAtPoint } from \"./getPropertiesAtPoint.ts\";\n\n/**\n * Returns the point in path closest to a given point.\n *\n * @param pathInput target `pathArray`\n * @param point the given point\n * @returns the best match\n */\nexport const getClosestPoint = (\n pathInput: string | PathArray,\n point: { x: number; y: number },\n): { x: number; y: number } => {\n return getPropertiesAtPoint(pathInput, point).closest;\n};\n","import { pathToCurve } from \"../convert/pathToCurve.ts\";\nimport type { PathArray, PointTuple } from \"../types.ts\";\n\n/**\n * Returns the area of a single cubic-bezier segment.\n *\n * http://objectmix.com/graphics/133553-area-closed-bezier-curve.html\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the area of the cubic-bezier segment\n */\nconst getCubicSegArea = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n) => {\n return (\n (3 *\n ((y2 - y1) * (c1x + c2x) -\n (x2 - x1) * (c1y + c2y) +\n c1y * (x1 - c2x) -\n c1x * (y1 - c2y) +\n y2 * (c2x + x1 / 3) -\n x2 * (c2y + y1 / 3))) /\n 20\n );\n};\n\n/**\n * Returns the signed area of a shape.\n *\n * @author Jürg Lehni & Jonathan Puckey\n *\n * @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js\n *\n * @param path - The shape PathArray\n * @returns The signed area of the shape (positive for clockwise, negative for counter-clockwise)\n *\n * @example\n * ```ts\n * getPathArea([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])\n * // => -10000 (counter-clockwise square)\n * ```\n */\nexport const getPathArea = <T extends PathArray | string>(path: T): number => {\n let x = 0;\n let y = 0;\n let len = 0;\n\n return pathToCurve(path)\n .map((seg) => {\n switch (seg[0]) {\n case \"M\":\n [, x, y] = seg;\n return 0;\n default:\n len = getCubicSegArea(\n x,\n y,\n seg[1],\n seg[2],\n seg[3],\n seg[4],\n seg[5],\n seg[6],\n );\n [x, y] = seg.slice(-2) as PointTuple;\n return len;\n }\n })\n .reduce((a, b) => a + b, 0);\n};\n","import { getPathArea } from \"./getPathArea.ts\";\nimport { pathToCurve } from \"../convert/pathToCurve.ts\";\nimport type { PathArray } from \"../types.ts\";\n\n/**\n * Check if a path is drawn clockwise and returns true if so,\n * false otherwise.\n *\n * @param path the path string or `pathArray`\n * @returns true when clockwise or false if not\n */\nexport const getDrawDirection = (path: string | PathArray): boolean => {\n return getPathArea(pathToCurve(path)) >= 0;\n};\n","import type { PathArray, PathSegment } from \"../types.ts\";\nimport { getPropertiesAtLength } from \"./getPropertiesAtLength.ts\";\n\n/**\n * Returns the segment at a given length.\n *\n * @param pathInput the target `pathArray`\n * @param distance the distance in path to look at\n * @returns the requested segment\n */\nexport const getSegmentAtLength = <T extends PathArray>(\n pathInput: string | T,\n distance?: number,\n): PathSegment | undefined => {\n return getPropertiesAtLength(pathInput, distance).segment;\n};\n","import type { SegmentProperties } from \"../interface.ts\";\nimport type { PathArray } from \"../types.ts\";\nimport { getPropertiesAtPoint } from \"./getPropertiesAtPoint.ts\";\n\n/**\n * Returns the path segment which contains a given point.\n *\n * @param path the `pathArray` to look into\n * @param point the point of the shape to look for\n * @returns the requested segment\n */\nexport const getSegmentOfPoint = <T extends PathArray>(\n path: string | T,\n point: { x: number; y: number },\n): SegmentProperties | undefined => {\n return getPropertiesAtPoint(path, point).segment;\n};\n","import type { PathArray, PathSegment, RelativeCommand } from \"../types.ts\";\nimport { paramsCounts } from \"../parser/paramsCount.ts\";\n\n/**\n * Iterates an array to check if it's an actual `pathArray`.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nexport const isPathArray = (path: unknown): path is PathArray => {\n return (\n Array.isArray(path) &&\n path.every((seg: PathSegment) => {\n const lk = seg[0].toLowerCase() as RelativeCommand;\n return (\n paramsCounts[lk] === seg.length - 1 &&\n \"achlmqstvz\".includes(lk) &&\n (seg.slice(1) as unknown[]).every(Number.isFinite)\n );\n }) &&\n path.length > 0\n );\n};\n","import type { AbsoluteArray } from \"../types.ts\";\nimport { isPathArray } from \"./isPathArray.ts\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all absolute values.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nexport const isAbsoluteArray = (path: unknown): path is AbsoluteArray => {\n return (\n isPathArray(path) &&\n // `isPathArray` also checks if it's `Array`\n path.every(([x]) => x === x.toUpperCase())\n );\n};\n","import type { NormalArray } from \"../types.ts\";\nimport { isAbsoluteArray } from \"./isAbsoluteArray.ts\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all segments in non-shorthand notation\n * with absolute values.\n *\n * @param path - the array to be checked\n * @returns true if the array is a normalized path array\n */\nexport const isNormalizedArray = (path: unknown): path is NormalArray => {\n // `isAbsoluteArray` also checks if it's `Array`\n return isAbsoluteArray(path) && path.every(([pc]) => \"ACLMQZ\".includes(pc));\n};\n","import { isNormalizedArray } from \"./isNormalizedArray.ts\";\nimport type { PathArray, PolygonArray } from \"../types.ts\";\n/**\n * Checks if a path is a polygon (only M, L, H, V, Z commands).\n * @param pathArray PathArray (pre-normalize if needed)\n * @returns boolean\n */\nexport const isPolygonArray = (path: PathArray): path is PolygonArray => {\n return isNormalizedArray(path) && path.every(([pc]) => \"MLVHZ\".includes(pc));\n};\n","import type { CurveArray } from \"../types.ts\";\nimport { isNormalizedArray } from \"./isNormalizedArray.ts\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all C (cubic bezier) segments.\n *\n * @param path the `Array` to be checked\n * @returns iteration result\n */\nexport const isCurveArray = (path: unknown): path is CurveArray => {\n // `isPathArray` also checks if it's `Array`\n return isNormalizedArray(path) && path.every(([pc]) => \"MC\".includes(pc));\n};\n","import type { PathArray } from \"../types.ts\";\nimport { getPropertiesAtPoint } from \"./getPropertiesAtPoint.ts\";\nimport DISTANCE_EPSILON from \"./distanceEpsilon.ts\";\n\n/**\n * Checks if a given point is in the stroke of a path.\n *\n * @param pathInput target path\n * @param point the given `{x,y}` point\n * @returns the query result\n */\nexport const isPointInStroke = <T extends PathArray>(\n pathInput: string | T,\n point: { x: number; y: number },\n): boolean => {\n const { distance } = getPropertiesAtPoint(pathInput, point);\n return Math.abs(distance) < DISTANCE_EPSILON; // 0.01 might be more permissive\n};\n","import type { RelativeArray } from \"../types.ts\";\nimport { isPathArray } from \"./isPathArray.ts\";\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with relative values.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nexport const isRelativeArray = (path: unknown): path is RelativeArray => {\n return (\n isPathArray(path) &&\n // `isPathArray` checks if it's `Array`\n path.slice(1).every(([pc]) => pc === pc.toLowerCase())\n );\n};\n","import { scanSegment } from \"../parser/scanSegment.ts\";\nimport { skipSpaces } from \"../parser/skipSpaces.ts\";\nimport { PathParser } from \"../parser/pathParser.ts\";\n\n/**\n * Parses a path string value to determine its validity\n * then returns true if it's valid or false otherwise.\n *\n * @param pathString the path string to be parsed\n * @returns the path string validity\n */\nexport const isValidPath = (pathString: string): boolean => {\n if (typeof pathString !== \"string\" || !pathString.length) {\n return false;\n }\n\n const path = new PathParser(pathString);\n\n skipSpaces(path);\n\n while (path.index < path.max && !path.err.length) {\n scanSegment(path);\n }\n\n return !path.err.length && \"mM\".includes(path.segments[0][0]);\n};\n","// src/morph/samplePolygon.ts\n\nimport { error } from \"../util/error.ts\";\nimport { iterate } from \"../process/iterate.ts\";\nimport type { NormalArray, PointTuple } from \"../types.ts\";\n\n/**\n * Samples points from a path to form a polygon approximation.\n * Collects endpoints of each segment (M start + ends of L/C/etc).\n *\n * If `sampleSize` parameter is provided, it will return a polygon\n * equivalent to the original `PathArray`.\n * @param path `PolygonPathArray` or `CurvePathArray`\n * @returns Array of [x, y] points\n */\nexport function samplePolygon<T extends NormalArray>(\n path: T,\n): PointTuple[] {\n const points: PointTuple[] = [];\n\n let [mx, my] = [0, 0];\n\n iterate(path, (seg) => {\n const cmd = seg[0];\n if (cmd === \"M\") {\n [mx, my] = [seg[1] as number, seg[2] as number];\n points.push([mx, my]);\n } else if (cmd === \"L\") {\n points.push([seg[1] as number, seg[2] as number]);\n } else if (cmd === \"C\") {\n points.push([seg[5] as number, seg[6] as number]);\n } else if (cmd === \"A\") {\n points.push([seg[6] as number, seg[7] as number]);\n } else if (cmd === \"Z\") {\n points.push([mx, my]);\n } else {\n throw new TypeError(`${error}: path command \"${cmd}\" is not supported`);\n }\n });\n\n return points;\n}\n","import type { ShapeParams } from \"../interface.ts\";\n\n/**\n * Supported shapes and their specific parameters.\n */\nexport const shapeParams: ShapeParams = {\n line: [\"x1\", \"y1\", \"x2\", \"y2\"],\n circle: [\"cx\", \"cy\", \"r\"],\n ellipse: [\"cx\", \"cy\", \"rx\", \"ry\"],\n rect: [\"width\", \"height\", \"x\", \"y\", \"rx\", \"ry\"],\n polygon: [\"points\"],\n polyline: [\"points\"],\n glyph: [\"d\"],\n};\n","/**\n * Checks if a value is a DOM Element.\n *\n * @param node - The value to check\n * @returns True if the value is a DOM Element (nodeType === 1)\n */\nexport const isElement = (node?: unknown): node is Element =>\n node !== undefined && node !== null &&\n typeof node === \"object\" &&\n (node as Node).nodeType === 1; // ELEMENT_NODE\n","import type {\n CircleAttr,\n EllipseAttr,\n GlyphAttr,\n LineAttr,\n PolyAttr,\n RectAttr,\n ShapeParams,\n} from \"../interface.ts\";\nimport type { PathArray, PathSegment, ShapeOps, ShapeTypes } from \"../types.ts\";\nimport { error } from \"./error.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { shapeParams } from \"./shapeParams.ts\";\nimport { isPathArray } from \"./isPathArray.ts\";\nimport { isElement } from \"./isElement.ts\";\n\n/**\n * Returns a new PathArray from line attributes.\n *\n * @param attr - Shape configuration with x1, y1, x2, y2\n * @returns A new line PathArray\n *\n * @example\n * ```ts\n * getLinePath({ x1: 0, y1: 0, x2: 100, y2: 100 })\n * // => [['M', 0, 0], ['L', 100, 100]]\n * ```\n */\nexport const getLinePath = (attr: LineAttr): PathArray => {\n let { x1, y1, x2, y2 } = attr;\n [x1, y1, x2, y2] = [x1, y1, x2, y2].map((a) => +a);\n return [\n [\"M\", x1, y1],\n [\"L\", x2, y2],\n ];\n};\n\n/**\n * Returns a new PathArray from polyline/polygon attributes.\n *\n * @param attr - Shape configuration with points string\n * @returns A new polygon/polyline PathArray\n *\n * @example\n * ```ts\n * getPolyPath({ type: 'polygon', points: '0,0 100,0 100,100 0,100' })\n * // => [['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['z']]\n * ```\n */\nexport const getPolyPath = (attr: PolyAttr): PathArray => {\n const pathArray = [] as PathSegment[];\n const points = (attr.points || \"\")\n .trim()\n .split(/[\\s|,]/)\n .map((a) => +a);\n\n let index = 0;\n while (index < points.length) {\n pathArray.push([index ? \"L\" : \"M\", points[index], points[index + 1]]);\n index += 2;\n }\n\n return (\n attr.type === \"polygon\" ? [...pathArray, [\"z\"]] : pathArray\n ) as PathArray;\n};\n\n/**\n * Returns a new PathArray from circle attributes.\n *\n * @param attr - Shape configuration with cx, cy, r\n * @returns A circle PathArray\n *\n * @example\n * ```ts\n * getCirclePath({ cx: 50, cy: 50, r: 25 })\n * // => [['M', 25, 50], ['a', 25, 25, 0, 1, 0, 50, 0], ['a', 25, 25, 0, 1, 0, -50, 0]]\n * ```\n */\nexport const getCirclePath = (attr: CircleAttr): PathArray => {\n let { cx, cy, r } = attr;\n [cx, cy, r] = [cx, cy, r].map((a) => +a);\n\n return [\n [\"M\", cx - r, cy],\n [\"a\", r, r, 0, 1, 0, 2 * r, 0],\n [\"a\", r, r, 0, 1, 0, -2 * r, 0],\n ];\n};\n\n/**\n * Returns a new PathArray from ellipse attributes.\n *\n * @param attr - Shape configuration with cx, cy, rx, ry\n * @returns An ellipse PathArray\n *\n * @example\n * ```ts\n * getEllipsePath({ cx: 50, cy: 50, rx: 30, ry: 20 })\n * // => [['M', 20, 50], ['a', 30, 20, 0, 1, 0, 60, 0], ['a', 30, 20, 0, 1, 0, -60, 0]]\n * ```\n */\nexport const getEllipsePath = (attr: EllipseAttr): PathArray => {\n let { cx, cy } = attr;\n let rx = attr.rx || 0;\n let ry = attr.ry || rx;\n [cx, cy, rx, ry] = [cx, cy, rx, ry].map((a) => +a);\n\n return [\n [\"M\", cx - rx, cy],\n [\"a\", rx, ry, 0, 1, 0, 2 * rx, 0],\n [\"a\", rx, ry, 0, 1, 0, -2 * rx, 0],\n ];\n};\n\n/**\n * Returns a new PathArray from rect attributes.\n *\n * @param attr - Object with x, y, width, height, and optional rx/ry\n * @returns A new PathArray from `<rect>` attributes\n *\n * @example\n * ```ts\n * getRectanglePath({ x: 0, y: 0, width: 100, height: 50, ry: 10 })\n * // => [['M', 10, 0], ['h', 80], ['a', 10, 10, 0, 0, 1, 10, 10], ...]\n * ```\n */\nexport const getRectanglePath = (attr: RectAttr): PathArray => {\n const x = +attr.x || 0;\n const y = +attr.y || 0;\n const w = +attr.width;\n const h = +attr.height;\n let rx = +(attr.rx || 0);\n let ry = +(attr.ry || rx);\n\n // Validity checks from http://www.w3.org/TR/SVG/shapes.html#RectElement:\n if (rx || ry) {\n // rx = !rx ? ry : rx;\n // ry = !ry ? rx : ry;\n\n /* istanbul ignore else @preserve */\n if (rx * 2 > w) rx -= (rx * 2 - w) / 2;\n /* istanbul ignore else @preserve */\n if (ry * 2 > h) ry -= (ry * 2 - h) / 2;\n\n return [\n [\"M\", x + rx, y],\n [\"h\", w - rx * 2],\n [\"s\", rx, 0, rx, ry],\n [\"v\", h - ry * 2],\n [\"s\", 0, ry, -rx, ry],\n [\"h\", -w + rx * 2],\n [\"s\", -rx, 0, -rx, -ry],\n [\"v\", -h + ry * 2],\n [\"s\", 0, -ry, rx, -ry],\n ];\n }\n\n return [[\"M\", x, y], [\"h\", w], [\"v\", h], [\"H\", x], [\"Z\"]];\n};\n\n/**\n * Returns a new `pathArray` created from attributes of a `<line>`, `<polyline>`,\n * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>`, <path> or `<glyph>`.\n *\n * It can also work with an options object, see the type below\n * @see ShapeOps\n *\n * @param element target shape\n * @returns the newly created `<path>` element\n */\nexport const shapeToPathArray = (\n element: ShapeTypes | ShapeOps,\n): false | PathArray => {\n const supportedShapes = Object.keys(shapeParams) as (keyof ShapeParams)[];\n const targetIsElement = isElement(element);\n const tagName = targetIsElement ? element.tagName : null;\n\n if (tagName && [...supportedShapes, \"path\"].every((s) => tagName !== s)) {\n throw TypeError(`${error}: \"${tagName}\" is not SVGElement`);\n }\n\n const type = (\n targetIsElement ? tagName : (element as ShapeOps).type\n ) as ShapeOps[\"type\"];\n const shapeAttrs = shapeParams[type] as string[];\n const config = { type } as Record<string, string>;\n\n if (targetIsElement) {\n shapeAttrs.forEach((p) => {\n config[p] = element.getAttribute(p) as string;\n });\n } else {\n Object.assign(config, element);\n }\n\n // set d\n let pathArray = [] as unknown as PathArray;\n\n /* istanbul ignore else */\n if (type === \"circle\") {\n pathArray = getCirclePath(config as unknown as CircleAttr);\n } else if (type === \"ellipse\") {\n pathArray = getEllipsePath(config as unknown as EllipseAttr);\n } else if ([\"polyline\", \"polygon\"].includes(type)) {\n pathArray = getPolyPath(config as unknown as PolyAttr);\n } else if (type === \"rect\") {\n pathArray = getRectanglePath(config as unknown as RectAttr);\n } else if (type === \"line\") {\n pathArray = getLinePath(config as unknown as LineAttr);\n } else if ([\"glyph\", \"path\"].includes(type)) {\n pathArray = parsePathString(\n targetIsElement\n ? element.getAttribute(\"d\") || /* istanbul ignore next @preserve */ \"\"\n : (element as GlyphAttr).d || \"\",\n );\n }\n\n // replace target element\n if (isPathArray(pathArray) && pathArray.length) {\n return pathArray;\n }\n return false;\n};\n","import type { ShapeParams } from \"../interface.ts\";\nimport type { ShapeOps, ShapeTypes } from \"../types.ts\";\nimport { pathToString } from \"../convert/pathToString.ts\";\nimport { defaultOptions } from \"../options/options.ts\";\nimport { error } from \"./error.ts\";\nimport { isValidPath } from \"./isValidPath.ts\";\nimport { isElement } from \"./isElement.ts\";\nimport { shapeToPathArray } from \"./shapeToPathArray.ts\";\nimport { shapeParams } from \"./shapeParams.ts\";\n\n/**\n * Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,\n * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter\n * is `true`, it will replace the target. The default `ownerDocument` is your current\n * `document` browser page, if you want to use in server-side using `jsdom`, you can\n * pass the `jsdom` `document` to `ownDocument`.\n *\n * It can also work with an options object, see the type below\n * @see ShapeOps\n *\n * The newly created `<path>` element keeps all non-specific\n * attributes like `class`, `fill`, etc.\n *\n * @param element - Target shape element or shape options object\n * @param replace - Option to replace target element\n * @param ownerDocument - Document for creating the element\n * @returns The newly created `<path>` element, or false if the path is invalid\n *\n * @example\n * ```ts\n * const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle')\n * circle.setAttribute('cx', '50')\n * circle.setAttribute('cy', '50')\n * circle.setAttribute('r', '25')\n * const path = shapeToPath(circle)\n * path.getAttribute('d')\n * // => 'M50 25A25 25 0 1 1 50 75A25 25 0 1 1 50 25Z'\n * ```\n */\nexport const shapeToPath = (\n element: ShapeTypes | ShapeOps,\n replace?: boolean,\n ownerDocument?: Document,\n): SVGPathElement | false => {\n const doc = ownerDocument || document;\n const supportedShapes = Object.keys(shapeParams) as (keyof ShapeParams)[];\n const targetIsElement = isElement(element);\n const tagName = targetIsElement ? element.tagName : null;\n\n if (tagName === \"path\") {\n throw TypeError(`${error}: \"${tagName}\" is already SVGPathElement`);\n }\n if (tagName && supportedShapes.every((s) => tagName !== s)) {\n throw TypeError(`${error}: \"${tagName}\" is not SVGElement`);\n }\n\n const path = doc.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n const type =\n (targetIsElement ? tagName : (element as ShapeOps).type) as ShapeOps[\n \"type\"\n ];\n const shapeAttrs = shapeParams[type] as string[];\n const config = { type } as Record<string, string>;\n\n // set d\n const round = defaultOptions.round as number;\n const pathArray = shapeToPathArray(element);\n const description = pathArray && pathArray.length\n ? pathToString(pathArray, round)\n : \"\";\n\n if (targetIsElement) {\n shapeAttrs.forEach((p) => {\n config[p] = element.getAttribute(p) as string;\n });\n // set no-specific shape attributes: fill, stroke, etc\n for (let i = 0; i < element.attributes.length; i++) {\n const attr = element.attributes[i];\n if (attr && !shapeAttrs.includes(attr.name)) {\n path.setAttribute(attr.name, attr.value);\n }\n }\n } else {\n Object.assign(config, element);\n // set no-specific shape attributes: fill, stroke, etc\n Object.keys(config).forEach((k) => {\n if (!shapeAttrs.includes(k) && k !== \"type\") {\n path.setAttribute(\n k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`),\n config[k],\n );\n }\n });\n }\n\n // replace target element\n if (isValidPath(description)) {\n path.setAttribute(\"d\", description);\n if (replace && targetIsElement) {\n element.before(path, element);\n element.remove();\n }\n return path;\n }\n return false;\n};\n","import type { PathArray } from \"../types.ts\";\nimport { error } from \"./error.ts\";\nimport { isPathArray } from \"./isPathArray.ts\";\n\n/**\n * Determines if an SVG path contains multiple subpaths.\n * Accepts path string or PathArray.\n * @param path - 'M10,10 L20,20 Z M30,30 L40,40' → true\n * @returns boolean\n */\nexport const isMultiPath = <T extends PathArray>(\n path: string | T,\n): boolean => {\n if (typeof path === \"string\") {\n // Count all 'M' and 'm' occurrences\n const matches = path.match(/[Mm]/g);\n return matches ? matches.length > 1 : false;\n }\n\n // istanbul ignore else\n if (isPathArray(path)) {\n let moveCount = 0;\n for (const segment of path) {\n if (segment[0].toUpperCase() === \"M\") {\n moveCount++;\n if (moveCount > 1) return true;\n }\n }\n return false;\n }\n\n throw new TypeError(error + \": expected string or PathArray\");\n};\n","import { isNormalizedArray } from \"./isNormalizedArray.ts\";\nimport type { PathArray, PolylineArray } from \"../types.ts\";\n/**\n * Checks if a path is a polyline (only M, L, H, V commands).\n * @param pathArray PathArray (pre-normalize if needed)\n * @returns boolean\n */\nexport function isPolylineArray(path: PathArray): path is PolylineArray {\n return isNormalizedArray(path) && path.every(([pc]) => \"MLVH\".includes(pc));\n}\n","import type { PathArray } from \"../types.ts\";\n\n/**\n * Check if a PathArray is closed, which means its last segment is a Z.\n * @param path\n * @returns true if the path is closed\n */\nexport const isClosedPath = <T extends PathArray>(path: T): boolean => {\n return path[path.length - 1][0].toUpperCase() === \"Z\";\n};\n","import { defaultOptions } from \"../options/options.ts\";\nimport type { ParserParams } from \"../interface.ts\";\nimport { roundTo } from \"../math/roundTo.ts\";\nimport type {\n AbsoluteSegment,\n NormalSegment,\n PathCommand,\n ShortSegment,\n SSegment,\n TSegment,\n} from \"../types.ts\";\n\n/**\n * Shorten a single segment of a `pathArray` object.\n *\n * @param segment the `absoluteSegment` object\n * @param normalSegment the `normalSegment` object\n * @param params the coordinates of the previous segment\n * @param prevCommand the path command of the previous segment\n * @returns the shortened segment\n */\nexport const shortenSegment = (\n segment: AbsoluteSegment,\n normalSegment: NormalSegment,\n params: ParserParams,\n prevCommand: PathCommand,\n): ShortSegment => {\n const [pathCommand] = segment;\n const { round: defaultRound } = defaultOptions;\n const round = typeof defaultRound === \"number\"\n ? defaultRound\n : /* istanbul ignore next */ 4;\n const normalValues = normalSegment.slice(1) as number[];\n const { x1, y1, x2, y2, x, y } = params;\n const [nx, ny] = normalValues.slice(-2);\n const result = segment;\n\n if (!\"TQ\".includes(pathCommand)) {\n // optional but good to be cautious\n params.qx = null;\n params.qy = null;\n }\n\n if (pathCommand === \"L\") {\n if (roundTo(x, round) === roundTo(nx, round)) {\n return [\"V\", ny];\n } else if (roundTo(y, round) === roundTo(ny, round)) {\n return [\"H\", nx];\n }\n } else if (pathCommand === \"C\") {\n const [nx1, ny1] = normalValues;\n params.x1 = nx1;\n params.y1 = ny1;\n\n if (\n \"CS\".includes(prevCommand) &&\n ((roundTo(nx1, round) === roundTo(x1 * 2 - x2, round) &&\n roundTo(ny1, round) === roundTo(y1 * 2 - y2, round)) ||\n (roundTo(x1, round) === roundTo(x2 * 2 - x, round) &&\n roundTo(y1, round) === roundTo(y2 * 2 - y, round)))\n ) {\n return [\n \"S\",\n normalValues[2],\n normalValues[3],\n normalValues[4],\n normalValues[5],\n ] as SSegment;\n }\n } else if (pathCommand === \"Q\") {\n const [qx, qy] = normalValues;\n params.qx = qx;\n params.qy = qy;\n\n if (\n \"QT\".includes(prevCommand) &&\n roundTo(qx, round) === roundTo(x1 * 2 - x2, round) &&\n roundTo(qy, round) === roundTo(y1 * 2 - y2, round)\n ) {\n return [\"T\", normalValues[2], normalValues[3]] as TSegment;\n }\n }\n\n // ['V', 'H', 'S', 'T', 'Z'].includes(pathCommand)\n return result as ShortSegment;\n};\n","import type { PathCommand, PathSegment } from \"../types.ts\";\nimport { roundTo } from \"../math/roundTo.ts\";\n\n/**\n * Rounds the numeric values of a path segment to the specified precision.\n *\n * @param segment - The path segment to round\n * @param roundOption - Number of decimal places\n * @returns The rounded segment\n */\nexport const roundSegment = <T extends PathSegment>(\n segment: T,\n roundOption: number,\n): T => {\n const values = (segment.slice(1) as number[]).map((n) =>\n roundTo(n, roundOption)\n );\n return [segment[0] as PathCommand | number].concat(values) as T;\n};\n","import type {\n AbsoluteSegment,\n PathArray,\n PathCommand,\n PathSegment,\n} from \"../types.ts\";\nimport { pathToAbsolute } from \"../convert/pathToAbsolute.ts\";\nimport { shortenSegment } from \"./shortenSegment.ts\";\nimport { paramsParser } from \"../parser/paramsParser.ts\";\nimport { iterate } from \"./iterate.ts\";\nimport { normalizeSegment } from \"./normalizeSegment.ts\";\nimport { relativizeSegment } from \"./relativizeSegment.ts\";\nimport { roundSegment } from \"./roundSegment.ts\";\n\n/**\n * Optimizes a PathArray:\n * * converts segments to shorthand if possible\n * * selects shortest representation from absolute and relative forms\n *\n * @param pathInput - A path string or PathArray\n * @param roundOption - Number of decimal places for rounding\n * @returns The optimized PathArray\n *\n * @example\n * ```ts\n * optimizePath('M10 10L10 10L90 90', 2)\n * // => [['M', 10, 10], ['l', 0, 0], ['l', 80, 80]]\n * ```\n */\nexport const optimizePath = <T extends string | PathArray>(\n pathInput: T,\n roundOption?: number,\n): PathArray => {\n const path = pathToAbsolute(pathInput);\n // allow for ZERO decimals or use an aggressive value of 2\n const round = typeof roundOption === \"number\" && roundOption >= 0\n ? roundOption\n : 2;\n // this utility overrides the iterator params\n const optimParams = { ...paramsParser };\n\n const allPathCommands = [] as PathCommand[];\n let pathCommand = \"M\" as PathCommand;\n let prevCommand = \"Z\" as PathCommand;\n\n return iterate(path, (seg, i, lastX, lastY) => {\n optimParams.x = lastX;\n optimParams.y = lastY;\n const normalizedSegment = normalizeSegment(seg, optimParams);\n let result: PathSegment = seg;\n pathCommand = seg[0];\n\n // Save current path command\n allPathCommands[i] = pathCommand;\n if (i) {\n // Get previous path command for `shortenSegment`\n prevCommand = allPathCommands[i - 1];\n const shortSegment = shortenSegment(\n seg as AbsoluteSegment,\n normalizedSegment,\n optimParams,\n prevCommand,\n );\n const absSegment = roundSegment(shortSegment, round);\n const absString = absSegment.join(\"\");\n const relativeSegment = relativizeSegment(shortSegment, i, lastX, lastY);\n const relSegment = roundSegment(relativeSegment, round);\n const relString = relSegment.join(\"\");\n result = absString.length < relString.length ? absSegment : relSegment;\n }\n\n const seglen = normalizedSegment.length;\n optimParams.x1 = +normalizedSegment[seglen - 2];\n optimParams.y1 = +normalizedSegment[seglen - 1];\n optimParams.x2 = +normalizedSegment[seglen - 4] || optimParams.x1;\n optimParams.y2 = +normalizedSegment[seglen - 3] || optimParams.y1;\n\n return result;\n });\n};\n","import type {\n // ASegment,\n CSegment,\n // HSegment,\n // MSegment,\n PathArray,\n PathSegment,\n PointTuple,\n QSegment,\n SSegment,\n TSegment,\n // VSegment,\n} from \"../types.ts\";\nimport { pathToAbsolute } from \"../convert/pathToAbsolute.ts\";\nimport { normalizePath } from \"./normalizePath.ts\";\nimport { iterate } from \"./iterate.ts\";\n\n/**\n * Reverses all segments of a PathArray and returns a new PathArray\n * with absolute values.\n *\n * @param pathInput - The source PathArray\n * @returns The reversed PathArray\n *\n * @example\n * ```ts\n * reversePath([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])\n * // => [['M', 0, 100], ['L', 0, 0], ['L', 100, 0], ['L', 100, 100], ['Z']]\n * ```\n */\nexport const reversePath = <T extends PathArray>(pathInput: T): T => {\n const absolutePath = pathToAbsolute(pathInput);\n const normalizedPath = normalizePath(absolutePath);\n const pLen = absolutePath.length;\n const isClosed = absolutePath[pLen - 1][0] === \"Z\";\n\n const reversedPath = iterate(absolutePath, (segment, i) => {\n const normalizedSegment = normalizedPath[i];\n const prevSeg = i && absolutePath[i - 1];\n const prevCommand = prevSeg && prevSeg[0];\n const nextSeg = absolutePath[i + 1];\n const nextCommand = nextSeg && nextSeg[0];\n const pathCommand = segment[0];\n const [x, y] = normalizedPath[i ? i - 1 : pLen - 1].slice(-2) as PointTuple;\n let result = segment;\n\n switch (pathCommand) {\n case \"M\":\n result = isClosed ? [\"Z\"] : [pathCommand, x, y];\n break;\n case \"A\":\n result = [\n pathCommand,\n segment[1],\n segment[2],\n segment[3],\n segment[4],\n segment[5] === 1 ? 0 : 1,\n x,\n y,\n ];\n break;\n case \"C\":\n if (nextSeg && nextCommand === \"S\") {\n result = [\"S\", segment[1], segment[2], x, y];\n } else {\n result = [\n pathCommand,\n segment[3],\n segment[4],\n segment[1],\n segment[2],\n x,\n y,\n ];\n }\n break;\n case \"S\":\n if (\n prevCommand &&\n \"CS\".includes(prevCommand) &&\n (!nextSeg || nextCommand !== \"S\")\n ) {\n result = [\n \"C\",\n normalizedSegment[3],\n normalizedSegment[4],\n normalizedSegment[1],\n normalizedSegment[2],\n x,\n y,\n ] as CSegment;\n } else {\n result = [\n pathCommand,\n normalizedSegment[1],\n normalizedSegment[2],\n x,\n y,\n ] as SSegment;\n }\n break;\n case \"Q\":\n if (nextSeg && nextCommand === \"T\") {\n result = [\"T\", x, y] as TSegment;\n } else {\n result = [pathCommand, segment[1], segment[2], x, y];\n }\n break;\n case \"T\":\n if (\n prevCommand &&\n \"QT\".includes(prevCommand) &&\n (!nextSeg || nextCommand !== \"T\")\n ) {\n result = [\n \"Q\",\n normalizedSegment[1],\n normalizedSegment[2],\n x,\n y,\n ] as QSegment;\n } else {\n result = [pathCommand, x, y] as TSegment;\n }\n break;\n case \"Z\":\n result = [\"M\", x, y];\n break;\n case \"H\":\n result = [pathCommand, x];\n break;\n case \"V\":\n result = [pathCommand, y];\n break;\n default:\n result = [pathCommand as typeof pathCommand | number].concat(\n segment.slice(1, -2),\n x,\n y,\n ) as typeof segment;\n }\n\n return result;\n });\n\n return (\n isClosed\n ? reversedPath.reverse()\n : [reversedPath[0] as PathSegment].concat(reversedPath.slice(1).reverse())\n ) as T;\n};\n","// import paramsParser from \"../parser/paramsParser.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport type {\n AbsoluteCommand,\n HSegment,\n MSegment,\n PathArray,\n PointTuple,\n VSegment,\n} from \"../types.ts\";\nimport { iterate } from \"./iterate.ts\";\n\n/**\n * Split a path string or PathArray into an array of sub-paths.\n *\n * In the process, values are converted to absolute\n * for visual consistency.\n *\n * @param pathInput - The source path string or PathArray\n * @returns An array of sub-path PathArrays\n *\n * @example\n * ```ts\n * splitPath('M0 0L100 0ZM200 0L300 0Z')\n * // => [\n * // [['M', 0, 0], ['L', 100, 0], ['Z']],\n * // [['M', 200, 0], ['L', 300, 0], ['Z']]\n * // ]\n * ```\n */\nexport const splitPath = <T extends PathArray>(pathInput: T | string): T[] => {\n const composite: T[] = [];\n const parsedPath = parsePathString(pathInput);\n let path = [] as unknown as T;\n let pi = -1;\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n iterate(parsedPath, (seg, _, prevX, prevY) => {\n const cmd = seg[0];\n const absCommand = cmd.toUpperCase() as AbsoluteCommand;\n const isRelative = cmd === cmd.toLowerCase();\n const values = seg.slice(1) as number[];\n\n if (absCommand === \"M\") {\n pi += 1;\n\n [x, y] = values as PointTuple;\n x += isRelative ? prevX : 0;\n y += isRelative ? prevY : 0;\n mx = x;\n my = y;\n path = [\n (isRelative ? [absCommand, mx, my] : seg) as MSegment,\n ] as unknown as T;\n } else {\n if (absCommand === \"Z\") {\n x = mx;\n y = my;\n } else if (absCommand === \"H\") {\n [, x] = seg as HSegment;\n x += isRelative ? prevX : /* istanbul ignore next @preserve */ 0;\n } else if (absCommand === \"V\") {\n [, y] = seg as VSegment;\n y += isRelative ? prevY : /* istanbul ignore next @preserve */ 0;\n } else {\n [x, y] = seg.slice(-2) as PointTuple;\n x += isRelative ? prevX : 0;\n y += isRelative ? prevY : 0;\n }\n path.push(seg);\n }\n\n composite[pi] = path;\n });\n\n return composite;\n};\nexport default splitPath;\n","import CSSMatrix from \"@thednp/dommatrix\";\n// import type { TransformObject } from \"../interface.ts\";\nimport type { TransformObjectValues } from \"../types.ts\";\n\n/**\n * Returns a transformation matrix to apply to `<path>` elements.\n *\n * @see TransformObjectValues\n *\n * @param transform the `transformObject`\n * @returns a new transformation matrix\n */\nexport const getSVGMatrix = (transform: TransformObjectValues): CSSMatrix => {\n let matrix = new CSSMatrix();\n const { origin } = transform;\n const [originX, originY] = origin as [number, number, number];\n const { translate } = transform;\n const { rotate } = transform;\n const { skew } = transform;\n const { scale } = transform;\n\n // set translate\n if (\n Array.isArray(translate) &&\n translate.length >= 2 &&\n translate.every((x) => !Number.isNaN(+x)) &&\n translate.some((x) => x !== 0)\n ) {\n matrix = matrix.translate(...(translate as [number, number, number?]));\n } else if (typeof translate === \"number\" && !Number.isNaN(translate)) {\n matrix = matrix.translate(translate);\n }\n\n if (rotate || skew || scale) {\n // set SVG transform-origin, always defined\n matrix = matrix.translate(originX, originY);\n\n // set rotation\n if (\n Array.isArray(rotate) &&\n rotate.length >= 2 &&\n rotate.every((x) => !Number.isNaN(+x)) &&\n rotate.some((x) => x !== 0)\n ) {\n matrix = matrix.rotate(...(rotate as [number, number, number?]));\n } else if (typeof rotate === \"number\" && !Number.isNaN(rotate)) {\n matrix = matrix.rotate(rotate);\n }\n\n // set skew(s)\n if (\n Array.isArray(skew) && skew.length === 2 && skew.every((x) =>\n !Number.isNaN(+x)\n ) && skew.some((x) => x !== 0)\n ) {\n matrix = skew[0] ? matrix.skewX(skew[0]) : matrix;\n matrix = skew[1] ? matrix.skewY(skew[1]) : matrix;\n } else if (typeof skew === \"number\" && !Number.isNaN(skew)) {\n matrix = matrix.skewX(skew);\n }\n\n // set scale\n if (\n Array.isArray(scale) && scale.length >= 2 && scale.every((x) =>\n !Number.isNaN(+x)\n ) && scale.some((x) => x !== 1)\n ) {\n matrix = matrix.scale(...(scale as [number, number, number?]));\n } else if (typeof scale === \"number\" && !Number.isNaN(scale)) {\n matrix = matrix.scale(scale);\n }\n // set SVG transform-origin\n matrix = matrix.translate(-originX, -originY);\n }\n\n return matrix;\n};\n","import CSSMatrix from \"@thednp/dommatrix\";\nimport type { PointTuple } from \"../types.ts\";\n\n/**\n * Transforms a specified point using a matrix, returning a new\n * Tuple *Object* comprising of the transformed point.\n * Neither the matrix nor the original point are altered.\n *\n * @copyright thednp © 2021\n *\n * @param cssm CSSMatrix instance\n * @param v Tuple\n * @returns the resulting Tuple\n */\nconst translatePoint = (\n cssm: CSSMatrix,\n v: [number, number, number, number],\n): [number, number, number, number] => {\n let m = CSSMatrix.Translate(v[0], v[1], v[2]);\n\n [, , , m.m44] = v;\n m = cssm.multiply(m);\n\n return [m.m41, m.m42, m.m43, m.m44];\n};\n\n/**\n * Returns the [x,y] projected coordinates for a given an [x,y] point\n * and an [x,y,z] perspective origin point.\n *\n * Equation found here =>\n * http://en.wikipedia.org/wiki/3D_projection#Diagram\n * Details =>\n * https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel\n *\n * @param m the transformation matrix\n * @param point2D the initial [x,y] coordinates\n * @param origin the [x,y,z] transform origin\n * @returns the projected [x,y] coordinates\n */\nexport const projection2d = (\n m: CSSMatrix,\n point2D: PointTuple,\n origin: [number, number, number],\n): PointTuple => {\n const [originX, originY, originZ] = origin;\n const [x, y, z] = translatePoint(m, [point2D[0], point2D[1], 0, 1]);\n\n const relativePositionX = x - originX;\n const relativePositionY = y - originY;\n const relativePositionZ = z - originZ;\n\n return [\n // protect against division by ZERO\n relativePositionX * (Math.abs(originZ) / Math.abs(relativePositionZ) || 1) +\n originX,\n relativePositionY * (Math.abs(originZ) / Math.abs(relativePositionZ) || 1) +\n originY,\n ];\n};\n","import { getSVGMatrix } from \"./getSVGMatrix.ts\";\nimport { projection2d } from \"./projection2d.ts\";\nimport { defaultOptions } from \"../options/options.ts\";\nimport type {\n AbsoluteArray,\n AbsoluteSegment,\n CSegment,\n LSegment,\n PathArray,\n TransformObjectValues,\n} from \"../types.ts\";\nimport type { TransformObject } from \"../interface.ts\";\nimport { iterate } from \"./iterate.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { absolutizeSegment } from \"./absolutizeSegment.ts\";\nimport { arcToCubic } from \"./arcToCubic.ts\";\n\n/**\n * Apply a 2D / 3D transformation to a PathArray.\n *\n * Since SVGElement doesn't support 3D transformation, this function\n * creates a 2D projection of the path element.\n *\n * @param pathInput - The PathArray or path string to transform\n * @param transform - The transform functions object (translate, rotate, skew, scale, origin)\n * @returns The transformed PathArray\n *\n * @example\n * ```ts\n * transformPath('M0 0L100 0L100 100L0 100Z', { translate: [10, 20], scale: 2 })\n * // => [['M', 10, 20], ['L', 210, 20], ['L', 210, 220], ['L', 10, 220], ['Z']]\n * ```\n */\nexport const transformPath = <T extends PathArray>(\n pathInput: T | string,\n transform?: Partial<TransformObject>,\n): T | AbsoluteArray => {\n // last x and y transformed values\n let x = 0;\n let y = 0;\n // new x and y transformed\n let lx = 0;\n let ly = 0;\n // segment params iteration index and length\n let j = 0;\n let jj = 0;\n // transform uses it's own set of params\n const path = parsePathString(pathInput);\n const transformProps = transform && Object.keys(transform);\n\n // when used as a static method, invalidate somehow\n if (!transform || (transformProps && !transformProps.length)) {\n return path.slice(0) as T;\n }\n\n // transform origin is extremely important\n if (!transform.origin) {\n Object.assign(transform, { origin: defaultOptions.origin });\n }\n const origin = transform.origin as [number, number, number];\n const matrixInstance = getSVGMatrix(transform as TransformObjectValues);\n\n if (matrixInstance.isIdentity) return path.slice(0) as T;\n\n return iterate(path, (seg, index, lastX, lastY) => {\n let [pathCommand] = seg;\n const absCommand = pathCommand.toUpperCase();\n const isRelative = absCommand !== pathCommand;\n const absoluteSegment = isRelative\n ? absolutizeSegment(seg, index, lastX, lastY)\n : (seg.slice(0) as AbsoluteSegment);\n\n let result = absCommand === \"A\"\n // ? segmentToCubic(absoluteSegment, transformParams)\n ? ([\"C\" as string | number].concat(\n arcToCubic(\n lastX,\n lastY,\n absoluteSegment[1] as number,\n absoluteSegment[2] as number,\n absoluteSegment[3] as number,\n absoluteSegment[4] as number,\n absoluteSegment[5] as number,\n absoluteSegment[6] as number,\n absoluteSegment[7] as number,\n ),\n ) as CSegment)\n : absCommand === \"V\"\n ? ([\"L\", lastX, absoluteSegment[1]] as LSegment)\n : absCommand === \"H\"\n ? ([\"L\", absoluteSegment[1], lastY] as LSegment)\n : absoluteSegment;\n\n // update pathCommand\n pathCommand = result[0];\n const isLongArc = pathCommand === \"C\" && result.length > 7;\n const tempSegment = (\n isLongArc ? result.slice(0, 7) : result.slice(0)\n ) as AbsoluteSegment;\n\n if (isLongArc) {\n path.splice(\n index + 1,\n 0,\n [\"C\" as typeof pathCommand | number].concat(\n result.slice(7),\n ) as CSegment,\n );\n result = tempSegment as CSegment;\n }\n\n if (pathCommand === \"L\") {\n [lx, ly] = projection2d(\n matrixInstance,\n [(result as LSegment)[1], (result as LSegment)[2]],\n origin,\n );\n\n /* istanbul ignore else @preserve */\n if (x !== lx && y !== ly) {\n result = [\"L\", lx, ly];\n } else if (y === ly) {\n result = [\"H\", lx];\n } else if (x === lx) {\n result = [\"V\", ly];\n }\n } else {\n for (j = 1, jj = result.length; j < jj; j += 2) {\n [lx, ly] = projection2d(\n matrixInstance,\n [+result[j], +result[j + 1]],\n origin,\n );\n result[j] = lx;\n result[j + 1] = ly;\n }\n }\n // now update x and y\n x = lx;\n y = ly;\n\n return result;\n }) as AbsoluteArray;\n};\n","import type { CSegment, CurveArray, MSegment, PathCommand } from \"../types.ts\";\n\n/**\n * Reverses all segments of a `pathArray`\n * which consists of only C (cubic-bezier) path commands.\n *\n * @param path the source `pathArray`\n * @returns the reversed `pathArray`\n */\nexport const reverseCurve = (path: CurveArray): CurveArray => {\n const rotatedCurve = path\n .slice(1)\n .map((x, i, curveOnly) =>\n !i\n ? path[0].slice(1).concat(x.slice(1) as number[])\n : curveOnly[i - 1].slice(-2).concat(x.slice(1))\n )\n .map((x) => x.map((_, i) => x[x.length - i - 2 * (1 - (i % 2))]))\n .reverse() as (MSegment | CSegment)[];\n\n return [[\"M\" as PathCommand | number].concat(rotatedCurve[0].slice(0, 2))]\n .concat(\n rotatedCurve.map((x) => [\"C\" as PathCommand | number].concat(x.slice(2))),\n ) as CurveArray;\n};\n","import type { PathArray } from \"../types.ts\";\nimport { defaultOptions } from \"../options/options.ts\";\nimport { iterate } from \"./iterate.ts\";\nimport { roundSegment } from \"./roundSegment.ts\";\n\n/**\n * Rounds the values of a `pathArray` instance to\n * a specified amount of decimals and returns it.\n *\n * @param path the source `pathArray`\n * @param roundOption the amount of decimals to round numbers to\n * @returns the resulted `pathArray` with rounded values\n */\nexport const roundPath = <T extends PathArray>(\n path: T,\n roundOption?: number | \"off\",\n): T => {\n let { round } = defaultOptions;\n // allow for ZERO decimals\n round = roundOption === \"off\"\n ? roundOption\n : typeof roundOption === \"number\" && roundOption >= 0\n ? roundOption\n : typeof round === \"number\" && round >= 0\n ? round\n : \"off\";\n\n /* istanbul ignore else @preserve */\n if (round === \"off\") return path.slice(0) as T;\n\n return iterate(path, (segment) => {\n return roundSegment(segment, round);\n });\n};\n","// src/morph/fixPath.ts\nimport type { PathArray } from \"../types.ts\";\nimport { parsePathString } from \"../parser/parsePathString.ts\";\nimport { normalizePath } from \"../process/normalizePath.ts\";\nimport { isClosedPath } from \"../util/isClosedPath.ts\";\n\n/**\n * Checks a `PathArray` for an unnecessary `Z` segment\n * and removes it. The `PathArray` is modified in place.\n * In short, if the segment before `Z` extends to `M`,\n * the `Z` segment must be removed.\n *\n * The `pathInput` must be a single path, without\n * sub-paths. For multi-path `<path>` elements,\n * use `splitPath` first and apply this utility on each\n * sub-path separately.\n *\n * @param pathInput the `pathArray` source\n * @returns void\n */\nexport const fixPath = <T extends PathArray>(pathInput: T | string): void => {\n const pathArray = parsePathString(pathInput);\n\n /* istanbul ignore else */\n if (isClosedPath(pathArray)) {\n const normalArray = normalizePath(pathArray);\n const length = pathArray.length;\n const segBeforeZ = length - 2;\n const [mx, my] = normalArray[0].slice(1);\n const [x, y] = normalArray[segBeforeZ].slice(-2);\n\n if (mx === x && my === y) {\n pathArray.splice(length - 1, 1);\n }\n }\n};\n","// src/morph/splitCubicSegment.ts\n\nimport { midPoint } from \"../math/midPoint.ts\";\nimport type { CubicCoordinates } from \"../types.ts\";\n\n/**\n * Split a cubic Bézier into two cubics at parameter t [0–1].\n *\n * @param x1 - Start point X\n * @param y1 - Start point Y\n * @param x2 - First control point X\n * @param y2 - First control point Y\n * @param x3 - Second control point X\n * @param y3 - Second control point Y\n * @param x4 - End point X\n * @param y4 - End point Y\n * @param t - Parameter in range [0, 1] at which to split\n * @returns Array of two cubic segments, each as [x1,y1, x2,y2, x3,y3, x4,y4]\n */\nexport function splitCubicSegment(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n x4: number,\n y4: number,\n t: number,\n): [CubicCoordinates, CubicCoordinates] {\n const [px01, py01] = midPoint([x1, y1], [x2, y2], t);\n const [px12, py12] = midPoint([x2, y2], [x3, y3], t);\n const [px23, py23] = midPoint([x3, y3], [x4, y4], t);\n\n const [cx0, cy0] = midPoint([px01, py01], [px12, py12], t);\n const [cx1, cy1] = midPoint([px12, py12], [px23, py23], t);\n\n const [px, py] = midPoint([cx0, cy0], [cx1, cy1], t);\n\n return [\n [x1, y1, px01, py01, cx0, cy0, px, py], // first segment\n [px, py, cx1, cy1, px23, py23, x4, y4], // second segment\n ];\n}\n","// src/convert/pathToPolyline.ts\nimport type {\n LSegment,\n PointTuple,\n PolygonArray,\n PolylineArray,\n // PathArray,\n} from \"../types.ts\";\nimport { normalizePath } from \"../process/normalizePath.ts\";\nimport { isPolygonArray } from \"../util/isPolygonArray.ts\";\nimport { isPolylineArray } from \"../util/isPolylineArray.ts\";\nimport { isClosedPath } from \"../util/isClosedPath.ts\";\nimport { error } from \"../util/error.ts\";\n\n/**\n * Converts any `PolyLineArray`/`PolygonArray` path (closed or open) to an explicit polyline (M + L*).\n * If the path is closed (has Z), the Z is replaced with an explicit L back to the initial M point.\n * This allows uniform processing without special-casing Z.\n *\n * @param path string or PathArray\n * @returns PolylineArray (M + L*) — never contains Z\n */\nexport const pathToPolyline = <T extends PolygonArray | PolylineArray>(\n path: string | T,\n): PolylineArray => {\n const normal = normalizePath(path);\n if (!isPolygonArray(normal) && !isPolylineArray(normal)) {\n throw TypeError(\n `${error}: pathValue is not a polyline/polygon`,\n );\n }\n\n // If not closed, return as-is (already a polyline)\n if (!isClosedPath(normal)) {\n return normal as PolylineArray;\n }\n\n // Closed → replace Z with explicit L to initial M\n const result: PolylineArray = [normal[0]]; // Keep M\n const [mx, my] = normal[0].slice(1) as PointTuple;\n\n for (let i = 1; i < normal.length; i++) {\n const seg = normal[i];\n if (seg[0].toUpperCase() === \"Z\") {\n result.push([\"L\", mx, my]);\n } else {\n result.push(seg as LSegment);\n }\n }\n\n return result;\n};\n","// src/morph/splitLineToCount.ts\n\n/**\n * Split a line segment into `count` smaller segments of equal length\n * using the same repeated front-cutting strategy as splitCubicToCount.\n *\n * Does NOT mutate input.\n *\n * @param x1 - Start point X\n * @param y1 - Start point Y\n * @param x2 - End point X\n * @param y2 - End point Y\n * @param count - Number of segments to split into\n * @returns Array of `count` line segments, each as [x1, y1, x2, y2]\n */\nexport default function splitLineToCount(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n count: number,\n): Array<[number, number, number, number]> {\n if (count <= 1) return [[x1, y1, x2, y2]];\n\n const result: Array<[number, number, number, number]> = [];\n const dx = x2 - x1;\n const dy = y2 - y1;\n\n let currentX = x1;\n let currentY = y1;\n\n // Loop count times to produce count segments\n // We generate points at 1/count, 2/count, ..., count/count\n let i = 0;\n while (i < count) {\n const t = 1 / (count - i);\n const nextX = x1 + t * dx;\n const nextY = y1 + t * dy;\n\n result.push([currentX, currentY, nextX, nextY]);\n\n currentX = nextX;\n currentY = nextY;\n i++;\n }\n\n return result;\n}\n","// src/morph/getPathSplits.ts\n\nimport type {\n CSegment,\n CurveArray,\n PointTuple,\n PolylineArray,\n} from \"../types.ts\";\nimport { getLineLength } from \"../math/lineTools.ts\";\nimport { getCubicLength } from \"../math/cubicTools.ts\";\nimport { getTotalLength } from \"../util/getTotalLength.ts\";\nimport { isPolylineArray } from \"../util/isPolylineArray.ts\";\nimport { error } from \"../util/error.ts\";\nimport { iterate } from \"../process/iterate.ts\";\n\n/**\n * Determine the right amount of splits for each segment in a given PathArray\n * and for a target total amount of sub-segments.\n * For a triangle path \"M0,0 L600,300 L0,600 Z\" we have 3 equal lines,\n * we can easily do 4 splits per line and go to town, however, most triangles\n * are not even so we need to take side lengths into account.\n * @param path The target PathArray\n * @param target The total amount of sub-segments\n * @returns an array of numbers reprezenting the sub-segment count for each segment\n */\nexport function getPathSplits<T extends PolylineArray | CurveArray>(\n path: T,\n target: number,\n): number[] {\n if (target <= 1) throw new TypeError(`${error}: target must be >= 2`);\n\n const totalLength = getTotalLength(path);\n if (totalLength === 0) return Array(path.length).fill(1);\n\n const idealSegLen = totalLength / target; // minus M segment\n const isPoly = isPolylineArray(path);\n\n const splits: number[] = [1]; // M gets 0 splits\n const lengths: number[] = [0]; // M has 0 length\n\n // First pass: measure each segment length\n iterate(path, (seg, i, prevX, prevY) => {\n if (i > 0) {\n const [endX, endY] = seg.slice(-2) as PointTuple;\n const segLen = isPoly\n ? getLineLength(prevX, prevY, endX, endY)\n : getCubicLength(\n prevX,\n prevY,\n seg[1],\n seg[2],\n (seg as CSegment)[3],\n (seg as CSegment)[4],\n (seg as CSegment)[5],\n (seg as CSegment)[6],\n );\n lengths.push(segLen);\n splits.push(1); // placeholder\n }\n });\n\n // Second pass: distribute splits proportionally\n let totalAllocated = 1; // 1 stands for first M segment\n\n for (let i = 1; i < lengths.length; i++) {\n const segLen = lengths[i];\n const desired = segLen > idealSegLen ? Math.round(segLen / idealSegLen) : 1;\n\n splits[i] = desired;\n totalAllocated += desired;\n }\n\n // Third pass: adjust to hit exact target\n let diff = target - totalAllocated;\n\n if (diff !== 0) {\n const candidates: PointTuple[] = [];\n for (let i = 1; i < lengths.length; i++) {\n // istanbul ignore else\n if (lengths[i] > 0) {\n candidates.push([i, lengths[i]]);\n }\n }\n\n const cLen = candidates.length;\n\n // istanbul ignore else - impossible to test that edge case\n if (diff < 0) {\n // sort ascending\n candidates.sort((a, b) => a[1] - b[1]);\n for (let i = 0; i < cLen; i++) {\n const idx = candidates[i][0];\n if (splits[idx] > 1 && candidates[i][1] > 0) {\n splits[idx]--;\n diff++;\n }\n if (diff === 0) break;\n else if (i === cLen - 1) i = 0;\n }\n } else if (diff > 0) {\n // sort descending\n candidates.sort((a, b) => b[1] - a[1]);\n for (let i = 0; i < cLen; i++) {\n const idx = candidates[i][0];\n if (candidates[i][1] > 0) {\n splits[idx]++;\n diff--;\n }\n if (diff === 0) break;\n else if (i === cLen - 1) i = 0;\n }\n }\n }\n return splits;\n}\n","// src/morph/splitLinePathToCount.ts\n\nimport type { PointTuple, PolylineArray } from \"../types.ts\";\nimport splitLineToCount from \"./splitLineToCount.ts\";\nimport { getPathSplits } from \"./getPathSplits.ts\";\nimport { error } from \"../util/error.ts\";\n\n/**\n * Splits a PolylineArray so that it has exactly `target` line segments.\n *\n * @param path - The polyline array to split\n * @param target - The desired number of line segments\n * @returns The modified polyline array with the target segment count\n */\nexport function splitLinePathToCount<T extends PolylineArray>(\n path: T,\n target: number,\n): T {\n if (path.length < 2 || target <= 1) return path;\n\n const splits = getPathSplits(path, target);\n let totalAdded = 0;\n\n const newPath = [path[0]] as unknown as T;\n const pathLen = path.length;\n let currentX = path[0][1];\n let currentY = path[0][2];\n\n // Build path using splits\n for (let i = 1; i < pathLen; i++) {\n const seg = path[i];\n const [endX, endY] = seg.slice(1) as PointTuple;\n\n const count = splits[i];\n\n // istanbul ignore else\n if (count >= 1) {\n const subLines = splitLineToCount(currentX, currentY, endX, endY, count);\n\n for (const sub of subLines) {\n newPath.push([\"L\", sub[2], sub[3]]);\n totalAdded++;\n }\n }\n\n currentX = endX;\n currentY = endY;\n }\n\n // Final safety: if somehow still wrong, log it\n // istanbul ignore if - this might possibly be impossible to test\n if (newPath.length !== target) {\n console.warn(\n `${error}: requested ${target} segments, got ${newPath.length}. Adjusted on last segment.`,\n );\n }\n\n return newPath;\n}\n","// src/morph/splitCubicToCount.ts\n\nimport type { CubicCoordinates } from \"../types.ts\";\nimport { splitCubicSegment } from \"./splitCubicSegment.ts\";\n\n/**\n * Split a cubic Bézier into `count` segments of roughly equal parameter length.\n * Does NOT mutate input parameters.\n *\n * @param x1 - Start point X\n * @param y1 - Start point Y\n * @param x2 - First control point X\n * @param y2 - First control point Y\n * @param x3 - Second control point X\n * @param y3 - Second control point Y\n * @param x4 - End point X\n * @param y4 - End point Y\n * @param count - Number of segments to split into\n * @returns Array of `count` cubic segments, each as [x1,y1,x2,y2,x3,y3,x4,y4]\n */\nexport function splitCubicToCount(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n x4: number,\n y4: number,\n count: number,\n): Array<CubicCoordinates> {\n if (count <= 1) return [[x1, y1, x2, y2, x3, y3, x4, y4]];\n\n const result: Array<CubicCoordinates> = [];\n\n // Work on local copies to avoid mutating inputs\n let cx1 = x1;\n let cy1 = y1;\n let cx2 = x2;\n let cy2 = y2;\n let cx3 = x3;\n let cy3 = y3;\n let cx4 = x4;\n let cy4 = y4;\n\n let i = 0;\n while (i < count) {\n const t = 1 / (count - i);\n const [first, second] = splitCubicSegment(\n cx1,\n cy1,\n cx2,\n cy2,\n cx3,\n cy3,\n cx4,\n cy4,\n t,\n );\n\n result.push(first);\n\n // Update working curve to the remaining (second) part\n [cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4] = second;\n i++;\n }\n\n return result;\n}\n","// src/morph/splitCubicPathToCount.ts\nimport type { CSegment, CurveArray, PointTuple } from \"../types.ts\";\nimport { splitCubicToCount } from \"./splitCubicToCount.ts\";\nimport { getPathSplits } from \"./getPathSplits.ts\";\nimport { error } from \"../util/error.ts\";\n\n/**\n * Splits a CurveArray so that it has exactly `target` cubic segments.\n *\n * @param path - The curve array to split\n * @param target - The desired number of cubic segments\n * @returns The modified curve array with the target segment count\n */\nexport function splitCurvePathToCount<T extends CurveArray>(\n path: T,\n target: number,\n): T {\n // istanbul ignore else\n if (path.length < 2 || target <= 1) return path;\n\n const splits = getPathSplits(path, target);\n let totalAdded = 0;\n\n const newPath = [path[0]] as unknown as T; // keep M\n const pathLen = path.length;\n let currentX = path[0][1];\n let currentY = path[0][2];\n\n for (let i = 1; i < pathLen; i++) {\n const seg = path[i] as CSegment /*| ZSegment*/;\n const [endX, endY] = seg.slice(-2) as PointTuple;\n\n const count = splits[i];\n\n // istanbul ignore else\n if (count >= 1) {\n const subs = splitCubicToCount(\n currentX,\n currentY,\n seg[1],\n seg[2],\n seg[3],\n seg[4],\n seg[5],\n seg[6],\n count,\n );\n\n for (const sub of subs) {\n newPath.push([\"C\", sub[2], sub[3], sub[4], sub[5], sub[6], sub[7]]);\n totalAdded++;\n }\n }\n currentX = endX;\n currentY = endY;\n }\n\n // Final safety: if somehow still wrong, log it\n // istanbul ignore if\n if (newPath.length !== target) {\n console.warn(\n `${error}: requested ${target} segments, got ${newPath.length}.`,\n );\n }\n\n return newPath;\n}\n","// src/morph/getRotatedPath.ts\n\nimport type {\n CSegment,\n // CurveArray,\n LSegment,\n MorphPathArray,\n MSegment,\n PointTuple,\n // PolylineArray,\n ZSegment,\n} from \"../types.ts\";\nimport { error } from \"../util/error.ts\";\n\n/**\n * Returns all possible rotations of a path (line or curve) by shifting the start point.\n * Each rotation is a new PathArray starting at a different original segment.\n *\n * @param path PathArray (M + L/C + optional Z) — must be single subpath, normalized\n * @returns PathArray[] — array of all possible rotations\n */\nexport function getRotations<T extends MorphPathArray>(a: T) {\n const pathLen = a.length;\n const pointCount = pathLen - 1;\n let path: T;\n const result = [] as T[];\n\n for (let idx = 0; idx < pathLen; idx++) {\n path = [] as unknown as T;\n for (let i = 0; i < pathLen; i++) {\n let oldSegIdx = idx + i;\n let seg: LSegment | CSegment | MSegment | ZSegment;\n\n if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === \"M\")) {\n seg = a[oldSegIdx];\n path.push([\"M\", ...seg.slice(-2)] as MSegment);\n continue;\n }\n if (oldSegIdx >= pathLen) {\n oldSegIdx -= pointCount;\n }\n path.push(a[oldSegIdx] as never);\n }\n result.push(path);\n }\n return result;\n}\n\n/**\n * Finds the best rotation of pathA to match pathB by minimizing sum of squared distances\n * between corresponding endpoints.\n *\n * Works with both polygon (L) and curve (C) arrays.\n *\n * @param pathA PathArray to rotate (will be modified in rotation options)\n * @param pathB PathArray reference (fixed)\n * @returns PathArray — best rotation of pathA\n */\nexport function getRotatedPath<T extends MorphPathArray>(\n pathA: T,\n pathB: T,\n computedRotations?: T[],\n): T {\n const rotations = computedRotations || getRotations(pathA);\n const segCountA = pathA.length;\n const segCountB = pathB.length;\n\n if (segCountA !== segCountB) {\n throw new TypeError(\n error +\n \": paths must have the same number of segments after equalization\",\n );\n }\n\n let bestIndex = 0;\n let minDistanceSq = Infinity;\n\n for (let ri = 0; ri < rotations.length; ri++) {\n const rotation = rotations[ri];\n const rLen = rotation.length;\n let sumDistSq = 0;\n\n // Compare endpoints of each segment (skip M, use end coords of L/C)\n for (let i = 0; i < rLen; i++) {\n const segA = rotation[i];\n const segB = pathB[i];\n\n const endA = segA.slice(-2) as PointTuple;\n const endB = segB.slice(-2) as PointTuple;\n\n const dx = endA[0] - endB[0];\n const dy = endA[1] - endB[1];\n sumDistSq += dx * dx + dy * dy;\n }\n\n if (sumDistSq < minDistanceSq) {\n minDistanceSq = sumDistSq;\n bestIndex = ri;\n }\n }\n\n return rotations[bestIndex];\n}\n","// src/morph/equalizeSegments.ts\nimport type {\n CurveArray,\n EqualizationOptions,\n MorphPathArray,\n PathArray,\n PolylineArray,\n} from \"../types.ts\";\nimport { pathToCurve } from \"../convert/pathToCurve.ts\";\nimport { pathToPolyline } from \"./pathToPolyline.ts\";\nimport { reversePath } from \"../process/reversePath.ts\";\nimport { normalizePath } from \"../process/normalizePath.ts\";\nimport { splitLinePathToCount } from \"./splitLinePathToCount.ts\";\nimport { splitCurvePathToCount } from \"./splitCurvePathToCount.ts\";\nimport { samplePolygon } from \"./samplePolygon.ts\";\nimport { polygonArea } from \"../math/polygonTools.ts\";\nimport { getRotatedPath } from \"./getRotatedPath.ts\";\nimport { fixPath } from \"./fixPath.ts\";\nimport { isPolygonArray } from \"../util/isPolygonArray.ts\";\nimport { isPolylineArray } from \"../util/isPolylineArray.ts\";\nimport { getTotalLength } from \"../util/getTotalLength.ts\";\nimport { roundPath } from \"../process/roundPath.ts\";\n\nconst equalizeSegmentsDefaults: EqualizationOptions = {\n mode: \"auto\", // \"line\" | \"curve\" | \"auto\"\n sampleSize: 10, // for line option\n roundValues: 4, // 4 decimals\n reverse: true,\n close: false,\n target: undefined,\n};\n\n/**\n * Equalizes two paths for morphing (single subpath only).\n *\n * @see https://minus-ze.ro/posts/morphing-arbitrary-paths-in-svg/\n * @param path1 - First path string or PathArray\n * @param path2 - Second path string or PathArray\n * @param initialCfg - Equalization options\n * @returns Tuple of two equalized MorphPathArrays\n *\n * @example\n * ```ts\n * const [eq1, eq2] = equalizeSegments('M0 0L100 0L50 100Z', 'M0 0L100 0L100 100L0 100Z')\n * // eq1.length === eq2.length\n * ```\n */\nexport const equalizeSegments = (\n path1: PathArray | string,\n path2: PathArray | string,\n initialCfg: EqualizationOptions = {},\n): [MorphPathArray, MorphPathArray] => {\n const { close, mode, reverse, roundValues, target: initialTarget } = Object\n .assign(equalizeSegmentsDefaults, initialCfg);\n let p1 = normalizePath(path1) as MorphPathArray;\n let p2 = normalizePath(path2) as MorphPathArray;\n\n // fix paths\n fixPath(p1);\n fixPath(p2);\n\n let bothPoly = (isPolygonArray(p1) || isPolylineArray(p1)) &&\n (isPolygonArray(p2) || isPolylineArray(p2));\n\n if (bothPoly && mode === \"auto\") {\n p1 = pathToPolyline(p1 as PolylineArray);\n p2 = pathToPolyline(p2 as PolylineArray);\n } else {\n bothPoly = false;\n p1 = pathToCurve(p1);\n p2 = pathToCurve(p2);\n }\n\n // Sample and check draw direction\n const area1 = polygonArea(samplePolygon(p1));\n const area2 = polygonArea(samplePolygon(p2));\n\n if (reverse !== false && (Math.sign(area1) !== Math.sign(area2))) {\n p2 = reversePath(p2);\n }\n\n // Get segment counts\n const segCount1 = p1.length;\n const segCount2 = p2.length;\n const minTarget = Math.max(segCount1, segCount2);\n let target = minTarget;\n\n if (typeof initialTarget !== \"number\") {\n const len1 = getTotalLength(p1);\n const len2 = getTotalLength(p2);\n const avgLen = (len1 + len2) / 2;\n const maxSegCount = Math.max(segCount1, segCount2);\n const avgSegLen = avgLen / maxSegCount;\n const idealSegCount = Math.max(\n minTarget,\n Math.round(avgLen / Math.max(avgSegLen, 1)),\n );\n target = Math.min(idealSegCount, Math.max(segCount1, segCount2) * 3);\n } else {\n if (initialTarget >= minTarget) target = initialTarget;\n else {\n console.warn(\n 'equalizeSegments \"target\" option: ' + initialTarget +\n \", expected >= \" + minTarget,\n );\n }\n }\n\n let equalP1: MorphPathArray = p1;\n let equalP2: MorphPathArray = p2;\n\n if (bothPoly) {\n equalP1 = splitLinePathToCount(\n p1 as PolylineArray,\n target,\n ) as MorphPathArray;\n equalP2 = splitLinePathToCount(\n p2 as PolylineArray,\n target,\n ) as MorphPathArray;\n } else {\n equalP1 = splitCurvePathToCount(p1 as CurveArray, target) as MorphPathArray;\n equalP2 = splitCurvePathToCount(p2 as CurveArray, target) as MorphPathArray;\n }\n\n // Point alignment\n equalP2 = getRotatedPath(equalP2, equalP1);\n\n if (typeof roundValues === \"number\" && roundValues !== 4) {\n equalP1 = roundPath(equalP1, roundValues);\n equalP2 = roundPath(equalP2, roundValues);\n }\n\n if (close) {\n equalP1.push([\"Z\"] as never);\n equalP2.push([\"Z\"] as never);\n }\n\n return [equalP1, equalP2];\n};\n","import type { BBoxMaxima, PointTuple } from \"../types.ts\";\n\n/**\n * Checks if a point is inside a bounding box.\n *\n * @param bbox - The bounding box as [minX, minY, maxX, maxY]\n * @param point - The point as [x, y]\n * @returns True if the point is inside or on the edge of the bounding box\n */\nexport const isPointInsideBBox = (\n bbox: BBoxMaxima,\n [x, y]: PointTuple,\n): boolean => {\n const [minX, minY, maxX, maxY] = bbox;\n return x >= minX && x <= maxX && y >= minY && y <= maxY;\n};\n","import type { BBoxMaxima } from \"../types.ts\";\n\nimport { isPointInsideBBox } from \"./isPointInsideBBox.ts\";\n\n/**\n * Checks if two bounding boxes intersect.\n *\n * @param a - First bounding box as [minX, minY, maxX, maxY]\n * @param b - Second bounding box as [minX, minY, maxX, maxY]\n * @returns True if the bounding boxes overlap\n */\nexport const boundingBoxIntersect = (a: BBoxMaxima, b: BBoxMaxima): boolean => {\n const [ax1, ay1, ax2, ay2] = a;\n const [bx1, by1, bx2, by2] = b;\n // return ax1 <= bx2 && ax2 >= bx1 && ay1 <= by2 && ay2 >= by1;\n return (\n isPointInsideBBox(b, [ax1, ay1]) ||\n isPointInsideBBox(b, [ax2, ay1]) ||\n isPointInsideBBox(b, [ax1, ay2]) ||\n isPointInsideBBox(b, [ax2, ay2]) ||\n isPointInsideBBox(a, [bx1, by1]) ||\n isPointInsideBBox(a, [bx2, by1]) ||\n isPointInsideBBox(a, [bx1, by2]) ||\n isPointInsideBBox(a, [bx2, by2]) ||\n // edge overlap without corner inside\n (ax1 < bx2 && ax1 > bx1 || bx1 < ax2 && bx1 > ax1) &&\n (ay1 < by2 && ay1 > by1 || by1 < ay2 && by1 > ay1)\n );\n};\n","import type { NormalArray } from \"../types.ts\";\n\n/**\n * Create a degenerate `PathArray` at a given coordinate\n * to serve as a pair for another `PathArray`.\n * @param param0 An [x, y] tuple for the coordinate\n * @returns A new degenerate `PathArray`\n */\nexport const createPlaceholder = (\n [atx, aty]: [number, number],\n): NormalArray => {\n // Tiny square at point\n const r = 0.001;\n return [\n [\"M\", atx, aty],\n [\"L\", atx + r, aty],\n [\"L\", atx + r, aty + r],\n [\"L\", atx, aty + r],\n [\"L\", atx, aty],\n [\"Z\"],\n ];\n};\n","import type { NormalArray, PathFeature, PointTuple } from \"../types.ts\";\nimport { isPointInsideBBox } from \"../intersect/isPointInsideBBox.ts\";\nimport { boundingBoxIntersect } from \"../intersect/boundingBoxIntersect.ts\";\nimport { createPlaceholder } from \"./createPlaceholder.ts\";\n\ninterface CandidateScore {\n index: number;\n hasOverlap: boolean;\n boxIntersect: boolean;\n sizeDifference: number;\n centeredDistance: number;\n}\n\nfunction getBestMatch(\n target: PathFeature,\n candidates: PathFeature[],\n): PathFeature | null {\n const targetBBox = target.bbox;\n\n // Single pass: collect metrics for every candidate\n const potentialCandidates: CandidateScore[] = [];\n\n for (let i = 0; i < candidates.length; i++) {\n const { bbox, size } = candidates[i];\n\n const dx = targetBBox.cx - bbox.cx;\n const dy = targetBBox.cy - bbox.cy;\n const centeredDistance = Math.sqrt(dx * dx + dy * dy);\n\n const sizeDifference = Math.abs(target.size - size) /\n Math.max(target.size, size, 1e-6);\n\n const hasOverlap = isPointInsideBBox(\n [targetBBox.x, targetBBox.y, targetBBox.x2, targetBBox.y2],\n [bbox.cx, bbox.cy],\n ) || isPointInsideBBox(\n [bbox.x, bbox.y, bbox.x2, bbox.y2],\n [targetBBox.cx, targetBBox.cy],\n );\n\n const boxIntersect = boundingBoxIntersect(\n [targetBBox.x, targetBBox.y, targetBBox.x2, targetBBox.y2],\n [bbox.x, bbox.y, bbox.x2, bbox.y2],\n );\n\n potentialCandidates.push({\n index: i,\n hasOverlap,\n boxIntersect,\n sizeDifference,\n centeredDistance,\n });\n }\n\n // Filter phase: strict overlap — pick smallest distance\n const overlaping = potentialCandidates.filter((c) =>\n c.hasOverlap && c.boxIntersect\n );\n if (overlaping.length > 0) {\n let best = overlaping[0];\n for (let i = 1; i < overlaping.length; i++) {\n if (overlaping[i].centeredDistance < best.centeredDistance) {\n best = overlaping[i];\n }\n }\n return candidates.splice(best.index, 1)[0];\n }\n\n return null;\n}\n\n/**\n * Matches paths from two sets by proximity and size similarity.\n * Unmatched paths receive placeholder paths at their centroid.\n *\n * @param fromPaths - Source path features to match from\n * @param toPaths - Target path features to match to\n * @returns Array of paired NormalArrays [from, to]\n */\nexport function matchPaths(\n fromPaths: PathFeature[],\n toPaths: PathFeature[],\n): [NormalArray, NormalArray][] {\n const pairs: [NormalArray, NormalArray][] = [];\n\n fromPaths.sort((a, b) => b.size - a.size);\n toPaths.sort((a, b) => b.size - a.size);\n\n while (fromPaths.length > 0) {\n const from = fromPaths.shift()!;\n const bestTo = getBestMatch(from, toPaths);\n\n if (bestTo) {\n pairs.push([from.path, bestTo.path]);\n } else {\n const fromCentroid: PointTuple = [from.bbox.cx, from.bbox.cy];\n pairs.push([from.path, createPlaceholder(fromCentroid)]);\n }\n }\n\n while (toPaths.length > 0) {\n const to = toPaths.shift()!;\n const toCentroid: PointTuple = [to.bbox.cx, to.bbox.cy];\n pairs.push([createPlaceholder(toCentroid), to.path]);\n }\n\n return pairs;\n}\n","import type { NormalArray, PathFeature } from \"../types.ts\";\nimport { getPathBBox } from \"../util/getPathBBox.ts\";\nimport { polygonArea } from \"../math/polygonTools.ts\";\nimport { samplePolygon } from \"./samplePolygon.ts\";\nimport { isPolygonArray } from \"../util/isPolygonArray.ts\";\nimport { isPolylineArray } from \"../util/isPolylineArray.ts\";\n\n/**\n * Classifies paths into outer (containing) and inner (hole) paths.\n *\n * @param paths - Array of normalized path arrays to classify\n * @returns Object with `outers` (containing shapes) and `inners` (holes)\n */\nexport const classifyPaths = (\n paths: NormalArray[],\n): {\n outers: PathFeature[];\n inners: PathFeature[];\n} => {\n const outers: PathFeature[] = [];\n const inners: PathFeature[] = [];\n\n for (const path of paths) {\n const signedArea = polygonArea(samplePolygon(path));\n const bbox = getPathBBox(path);\n const feature: PathFeature = {\n isPoly: isPolygonArray(path) || isPolylineArray(path),\n size: bbox.width * bbox.height,\n path,\n signedArea,\n area: Math.abs(signedArea),\n bbox,\n };\n\n if (signedArea > 0) {\n outers.push(feature);\n } else {\n inners.push(feature);\n }\n }\n\n return { outers, inners };\n};\n","import type {\n MorphPathArray,\n PathArray,\n PathsEqualizationOptions,\n} from \"../types.ts\";\nimport { isMultiPath } from \"../util/isMultiPath.ts\";\nimport { splitPath } from \"../process/splitPath.ts\";\nimport { equalizeSegments } from \"./equalizeSegments.ts\";\nimport { matchPaths } from \"./matchPaths.ts\";\nimport { normalizePath } from \"../process/normalizePath.ts\";\nimport { reversePath } from \"../process/reversePath.ts\";\nimport { polygonArea } from \"../math/polygonTools.ts\";\nimport { samplePolygon } from \"./samplePolygon.ts\";\nimport { classifyPaths } from \"./classifyPaths.ts\";\n\nconst equalizePathsDefaults: PathsEqualizationOptions = {\n mode: \"auto\", // \"line\" | \"curve\" | \"auto\"\n roundValues: 4, // 4 decimals\n close: false,\n sampleSize: 10,\n};\n\n/**\n * Equalizes two paths for morphing (single/multi subpath).\n *\n * @see https://minus-ze.ro/posts/morphing-arbitrary-paths-in-svg/\n * @param pathInput1 - First path string or PathArray\n * @param pathInput2 - Second path string or PathArray\n * @param initialCfg - Configuration options for equalization\n * @returns Tuple of two equalized MorphPathArrays\n *\n * @example\n * ```ts\n * const [eq1, eq2] = equalizePaths('M0 0L100 0L50 100Z', 'M0 0L100 0L100 100L0 100Z')\n * // eq1.length === eq2.length — ready for morphing\n * ```\n */\nexport const equalizePaths = (\n pathInput1: string | PathArray,\n pathInput2: string | PathArray,\n initialCfg = {},\n): [MorphPathArray, MorphPathArray] => {\n const cfg = Object.assign(equalizePathsDefaults, initialCfg);\n const p1 = normalizePath(pathInput1);\n const p2 = normalizePath(pathInput2);\n\n const multi1 = isMultiPath(p1);\n const multi2 = isMultiPath(p2);\n\n if (!multi1 && !multi2) {\n // Single subpath — use fast path\n return equalizeSegments(p1, p2, cfg);\n }\n\n // Global direction alignment (optional — helps with overall winding)\n const globalArea1 = polygonArea(samplePolygon(p1));\n const globalArea2 = polygonArea(samplePolygon(p2));\n\n let path1 = p1;\n let path2 = p2;\n\n // all paths must be clockwise\n if (Math.sign(globalArea1) < 0) {\n path1 = reversePath(path1);\n }\n if (Math.sign(globalArea2) < 0) {\n path2 = reversePath(path2);\n }\n\n // Multi-subpath: split and match\n const multiPath1 = splitPath(path1);\n const multiPath2 = splitPath(path2);\n\n const { outers: outers1, inners: inners1 } = classifyPaths(multiPath1);\n const { outers: outers2, inners: inners2 } = classifyPaths(multiPath2);\n\n // Match outers\n const outerPairs = matchPaths(outers1, outers2);\n\n // Match holes (simple: pair by area, ignore nesting for now)\n const innerPairs = matchPaths(inners1, inners2);\n\n // Equalize each pair\n const equalizedPairs: [MorphPathArray, MorphPathArray][] = [];\n\n for (const [from, to] of [...outerPairs, ...innerPairs]) {\n const [eqFrom, eqTo] = equalizeSegments(from, to, {\n ...cfg,\n reverse: false,\n });\n equalizedPairs.push([eqFrom, eqTo]);\n }\n\n // Reassemble into final morphable paths\n const finalFrom = equalizedPairs.map((p) => p[0]).flat() as MorphPathArray;\n const finalTo = equalizedPairs.map((p) => p[1]).flat() as MorphPathArray;\n\n return [finalFrom, finalTo] as [MorphPathArray, MorphPathArray];\n};\n","import type {\n CubicCoordinates,\n IntersectionOptions,\n IntersectionPoint,\n PointAtLength,\n} from \"../types.ts\";\nimport {\n getCubicBBox,\n getCubicLength,\n getPointAtCubicLength,\n} from \"../math/cubicTools.ts\";\nimport { distanceEpsilon } from \"../util.ts\";\nimport { roundTo } from \"../math/roundTo.ts\";\nimport { boundingBoxIntersect } from \"./boundingBoxIntersect.ts\";\n\nconst intersect = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n x4: number,\n y4: number,\n) => {\n if (\n Math.max(x1, x2) < Math.min(x3, x4) ||\n Math.min(x1, x2) > Math.max(x3, x4) ||\n Math.max(y1, y2) < Math.min(y3, y4) ||\n Math.min(y1, y2) > Math.max(y3, y4)\n ) {\n return;\n }\n const nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),\n ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),\n denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);\n\n if (!denominator) {\n return;\n }\n const px = nx / denominator,\n py = ny / denominator,\n px2 = roundTo(px, 2),\n py2 = roundTo(py, 2);\n if (\n px2 < roundTo(Math.min(x1, x2), 2) ||\n px2 > roundTo(Math.max(x1, x2), 2) ||\n px2 < roundTo(Math.min(x3, x4), 2) ||\n px2 > roundTo(Math.max(x3, x4), 2) ||\n py2 < roundTo(Math.min(y1, y2), 2) ||\n py2 > roundTo(Math.max(y1, y2), 2) ||\n py2 < roundTo(Math.min(y3, y4), 2) ||\n py2 > roundTo(Math.max(y3, y4), 2)\n ) {\n return;\n }\n return { x: px, y: py };\n};\n\n/**\n * Returns the intersection point(s) of two cubic Bezier curves.\n *\n * @param bez1 the coordinates of the first cubic Bezier segment\n * @param bez2 the coordinates of the second cubic Bezier segment\n * @param config optional intersection options\n * @returns the intersection points, or `undefined` if the curves do not intersect\n */\nexport const interHelper = (\n bez1: CubicCoordinates,\n bez2: CubicCoordinates,\n config?: IntersectionOptions,\n) => {\n const bbox1 = getCubicBBox(...bez1);\n const bbox2 = getCubicBBox(...bez2);\n const { justCount, epsilon } = Object.assign({\n justCount: true,\n epsilon: distanceEpsilon,\n }, config);\n\n if (!boundingBoxIntersect(bbox1, bbox2)) {\n return justCount ? 0 : [] as IntersectionPoint[];\n }\n const l1 = getCubicLength(...bez1),\n l2 = getCubicLength(...bez2),\n n1 = Math.max((l1 / 5) >> 0, 1),\n n2 = Math.max((l2 / 5) >> 0, 1),\n points1: PointAtLength[] = [],\n points2: PointAtLength[] = [],\n xy: Record<string, string> = {};\n // deno-lint-ignore prefer-const\n let res = justCount ? 0 : [] as IntersectionPoint[];\n for (let i = 0; i < n1 + 1; i++) {\n const p = getPointAtCubicLength(...bez1, (i / n1) * l1);\n points1.push({ x: p.x, y: p.y, t: i / n1 });\n }\n for (let i = 0; i < n2 + 1; i++) {\n const p = getPointAtCubicLength(...bez2, (i / n2) * l2);\n points2.push({ x: p.x, y: p.y, t: i / n2 });\n }\n for (let i = 0; i < n1; i++) {\n for (let j = 0; j < n2; j++) {\n const maxLimit = 1 + epsilon,\n di = points1[i],\n di1 = points1[i + 1],\n dj = points2[j],\n dj1 = points2[j + 1],\n ci = Math.abs(di1.x - di.x) < .001 ? \"y\" : \"x\",\n cj = Math.abs(dj1.x - dj.x) < .001 ? \"y\" : \"x\",\n is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);\n if (is) {\n // istanbul ignore next 2\n if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {\n continue;\n }\n xy[is.x.toFixed(4)] = is.y.toFixed(4);\n const t1 = di.t +\n Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),\n t2 = dj.t +\n Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);\n\n // istanbul ignore else\n if (t1 >= 0 && t1 <= maxLimit && t2 >= 0 && t2 <= maxLimit) {\n if (justCount) {\n (res as number)++;\n } else {\n (res as IntersectionPoint[]).push({\n x: is.x,\n y: is.y,\n t1: Math.min(t1, 1),\n t2: Math.min(t2, 1),\n });\n }\n }\n }\n }\n }\n return res;\n};\n","import type {\n CubicCoordinates,\n IntersectionPoint,\n PathArray,\n} from \"../types.ts\";\nimport { pathToCurve } from \"../convert/pathToCurve.ts\";\nimport { interHelper } from \"./interHelper.ts\";\n\n/**\n * Finds intersection points between two paths.\n *\n * @param pathInput1 - First path string or PathArray\n * @param pathInput2 - Second path string or PathArray\n * @param justCount - If true, returns the count of intersections; if false, returns the intersection points\n * @returns The number of intersections (when justCount is true) or an array of IntersectionPoint objects\n *\n * @example\n * ```ts\n * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)\n * // => 1\n * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)\n * // => [{ x: 50, y: 25, t1: 0.5, t2: 0.5 }]\n * ```\n */\nexport const pathsIntersection = <T extends string | PathArray>(\n pathInput1: T,\n pathInput2: T,\n justCount = /* istanbul ignore next */ true,\n): number | IntersectionPoint[] => {\n const path1 = pathToCurve(pathInput1);\n const path2 = pathToCurve(pathInput2);\n let x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n x1m = 0,\n y1m = 0,\n x2m = 0,\n y2m = 0,\n bez1: CubicCoordinates = [x1, y1, x1, y1, x1m, y1m, x1m, y1m],\n bez2: CubicCoordinates = [x2, y2, x2, y2, x2m, y2m, x2m, y2m],\n countResult = 0;\n const pointsResult: IntersectionPoint[] = [];\n const pathLen1 = path1.length;\n const pathLen2 = path2.length;\n\n for (let i = 0; i < pathLen1; i++) {\n const seg1 = path1[i];\n if (seg1[0] == \"M\") {\n x1 = seg1[1];\n y1 = seg1[2];\n x1m = x1;\n y1m = y1;\n } else {\n /* istanbul ignore else */\n if (seg1[0] == \"C\") {\n bez1 = [x1, y1, seg1[1], seg1[2], seg1[3], seg1[4], seg1[5], seg1[6]];\n x1 = bez1[6];\n y1 = bez1[7];\n } else {\n bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];\n x1 = x1m;\n y1 = y1m;\n }\n for (let j = 0; j < pathLen2; j++) {\n const seg2 = path2[j];\n // istanbul ignore else\n if (seg2[0] == \"M\") {\n x2 = seg2[1];\n y2 = seg2[2];\n x2m = x2;\n y2m = y2;\n } else if (seg2[0] == \"C\") {\n bez2 = [\n x2,\n y2,\n seg2[1],\n seg2[2],\n seg2[3],\n seg2[4],\n seg2[5],\n seg2[6],\n ];\n x2 = bez2[6];\n y2 = bez2[7];\n // dead code, pathToCurve is almost always made of M/C\n // } else {\n // bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];\n // x2 = x2m;\n // y2 = y2m;\n }\n const intr = interHelper(bez1, bez2, { justCount });\n if (justCount) {\n // (res as number) += intr;\n countResult += intr as number;\n } else {\n // Include additional segment properties, maybe not\n // const kk = (intr as IntersectionPoint[]).length;\n // for (let k = 0; k < kk; k++) {\n // intr[k].segment1 = i;\n // intr[k].segment2 = j;\n // intr[k].bez1 = bez1;\n // intr[k].bez2 = bez2;\n // }\n // (res as IntersectionPoint[]) = (res as IntersectionPoint[]).concat(intr);\n pointsResult.push(...intr as IntersectionPoint[]);\n }\n }\n }\n }\n return justCount ? countResult : pointsResult;\n};\n","\"use strict\";\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport CSSMatrix from \"@thednp/dommatrix\";\nimport { arcTools } from \"./math/arcTools.ts\";\nimport { bezierTools } from \"./math/bezier.ts\";\nimport { cubicTools } from \"./math/cubicTools.ts\";\nimport { lineTools } from \"./math/lineTools.ts\";\nimport { quadTools } from \"./math/quadTools.ts\";\nimport { polygonTools } from \"./math/polygonTools.ts\";\n\nimport { distanceSquareRoot } from \"./math/distanceSquareRoot.ts\";\nimport { midPoint } from \"./math/midPoint.ts\";\nimport { rotateVector } from \"./math/rotateVector.ts\";\nimport { roundTo } from \"./math/roundTo.ts\";\n\nimport type { PathArray, PointTuple, TransformObjectValues } from \"./types.ts\";\nimport type {\n Options,\n TransformEntries,\n TransformObject,\n} from \"./interface.ts\";\nimport { defaultOptions } from \"./options/options.ts\";\n\nimport { pathToAbsolute } from \"./convert/pathToAbsolute.ts\";\nimport { pathToRelative } from \"./convert/pathToRelative.ts\";\nimport { pathToCurve } from \"./convert/pathToCurve.ts\";\nimport { pathToString } from \"./convert/pathToString.ts\";\n\nimport { error } from \"./util/error.ts\";\nimport { parsePathString } from \"./parser/parsePathString.ts\";\nimport { finalizeSegment } from \"./parser/finalizeSegment.ts\";\nimport { invalidPathValue } from \"./parser/invalidPathValue.ts\";\nimport { isArcCommand } from \"./parser/isArcCommand.ts\";\nimport { isDigit } from \"./parser/isDigit.ts\";\nimport { isDigitStart } from \"./parser/isDigitStart.ts\";\nimport { isMoveCommand } from \"./parser/isMoveCommand.ts\";\nimport { isPathCommand } from \"./parser/isPathCommand.ts\";\nimport { isSpace } from \"./parser/isSpace.ts\";\nimport { paramsCounts } from \"./parser/paramsCount.ts\";\nimport { paramsParser } from \"./parser/paramsParser.ts\";\nimport { PathParser } from \"./parser/pathParser.ts\";\nimport { scanFlag } from \"./parser/scanFlag.ts\";\nimport { scanParam } from \"./parser/scanParam.ts\";\nimport { scanSegment } from \"./parser/scanSegment.ts\";\nimport { skipSpaces } from \"./parser/skipSpaces.ts\";\nimport { getPathBBox } from \"./util/getPathBBox.ts\";\nimport { getTotalLength } from \"./util/getTotalLength.ts\";\nimport { getClosestPoint } from \"./util/getClosestPoint.ts\";\nimport { getDrawDirection } from \"./util/getDrawDirection.ts\";\nimport { getPathArea } from \"./util/getPathArea.ts\";\nimport { getPointAtLength } from \"./util/getPointAtLength.ts\";\nimport { getPropertiesAtLength } from \"./util/getPropertiesAtLength.ts\";\nimport { getPropertiesAtPoint } from \"./util/getPropertiesAtPoint.ts\";\nimport { getSegmentAtLength } from \"./util/getSegmentAtLength.ts\";\nimport { getSegmentOfPoint } from \"./util/getSegmentOfPoint.ts\";\nimport { isAbsoluteArray } from \"./util/isAbsoluteArray.ts\";\nimport { isPolygonArray } from \"./util/isPolygonArray.ts\";\nimport { isCurveArray } from \"./util/isCurveArray.ts\";\nimport { isNormalizedArray } from \"./util/isNormalizedArray.ts\";\nimport { isPathArray } from \"./util/isPathArray.ts\";\nimport { isPointInStroke } from \"./util/isPointInStroke.ts\";\nimport { isRelativeArray } from \"./util/isRelativeArray.ts\";\nimport { isValidPath } from \"./util/isValidPath.ts\";\nimport { samplePolygon } from \"./morph/samplePolygon.ts\";\nimport { shapeParams } from \"./util/shapeParams.ts\";\nimport { shapeToPath } from \"./util/shapeToPath.ts\";\nimport { shapeToPathArray } from \"./util/shapeToPathArray.ts\";\nimport { isMultiPath } from \"./util/isMultiPath.ts\";\nimport { isPolylineArray } from \"./util/isPolylineArray.ts\";\nimport { isClosedPath } from \"./util/isClosedPath.ts\";\n\nimport { normalizePath } from \"./process/normalizePath.ts\";\nimport { optimizePath } from \"./process/optimizePath.ts\";\nimport { reversePath } from \"./process/reversePath.ts\";\nimport { splitPath } from \"./process/splitPath.ts\";\nimport { transformPath } from \"./process/transformPath.ts\";\nimport { absolutizeSegment } from \"./process/absolutizeSegment.ts\";\nimport { arcToCubic } from \"./process/arcToCubic.ts\";\nimport { getSVGMatrix } from \"./process/getSVGMatrix.ts\";\nimport { iterate } from \"./process/iterate.ts\";\nimport { lineToCubic } from \"./process/lineToCubic.ts\";\nimport { normalizeSegment } from \"./process/normalizeSegment.ts\";\nimport { projection2d } from \"./process/projection2d.ts\";\nimport { quadToCubic } from \"./process/quadToCubic.ts\";\nimport { relativizeSegment } from \"./process/relativizeSegment.ts\";\nimport { reverseCurve } from \"./process/reverseCurve.ts\";\nimport { roundPath } from \"./process/roundPath.ts\";\nimport { roundSegment } from \"./process/roundSegment.ts\";\nimport { segmentToCubic } from \"./process/segmentToCubic.ts\";\nimport { shortenSegment } from \"./process/shortenSegment.ts\";\n\nimport { fixPath } from \"./morph/fixPath.ts\";\nimport { splitCubicSegment } from \"./morph/splitCubicSegment.ts\";\nimport { equalizeSegments } from \"./morph/equalizeSegments.ts\";\nimport { equalizePaths } from \"./morph/equalizePaths.ts\";\nimport { pathsIntersection } from \"./intersect/pathIntersection.ts\";\nimport { boundingBoxIntersect } from \"./intersect/boundingBoxIntersect.ts\";\nimport { isPointInsideBBox } from \"./intersect/isPointInsideBBox.ts\";\nimport distanceEpsilon from \"./util/distanceEpsilon.ts\";\n\n/**\n * Creates a new SVGPathCommander instance with the following properties:\n * * segments: `pathArray`\n * * round: number\n * * origin: [number, number, number?]\n *\n * @class\n * @author thednp <https://github.com/thednp/svg-path-commander>\n * @returns a new SVGPathCommander instance\n */\nclass SVGPathCommander {\n // declare class properties\n declare segments: PathArray;\n declare round: number | \"off\";\n declare origin: [number, number, number];\n\n /**\n * @constructor\n * @param pathValue the path string\n * @param config instance options\n */\n constructor(pathValue: string, config?: Partial<Options>) {\n const instanceOptions = config || {};\n const undefPath = typeof pathValue === \"undefined\";\n\n if (undefPath || !pathValue.length) {\n throw TypeError(\n `${error}: \"pathValue\" is ${undefPath ? \"undefined\" : \"empty\"}`,\n );\n }\n\n this.segments = parsePathString(pathValue);\n\n // // set instance options.round\n const { round: roundOption, origin: originOption } = instanceOptions;\n let round: number | \"off\";\n\n if (Number.isInteger(roundOption) || roundOption === \"off\") {\n round = roundOption as number | \"off\";\n } else {\n round = defaultOptions.round as number;\n }\n\n // set instance options.origin\n // the SVGPathCommander class will always override the default origin\n let origin = defaultOptions.origin as [number, number, number];\n /* istanbul ignore else @preserve */\n if (Array.isArray(originOption) && originOption.length >= 2) {\n const [originX, originY, originZ] = originOption.map(Number);\n origin = [\n !Number.isNaN(originX) ? originX : 0,\n !Number.isNaN(originY) ? originY : 0,\n !Number.isNaN(originZ) ? originZ : 0,\n ];\n }\n\n this.round = round;\n this.origin = origin;\n\n return this;\n }\n get bbox(): {\n x: number;\n y: number;\n width: number;\n height: number;\n x2: number;\n y2: number;\n cx: number;\n cy: number;\n cz: number;\n } {\n return getPathBBox(this.segments);\n }\n get length(): number {\n return getTotalLength(this.segments);\n }\n\n /**\n * Returns the path bounding box, equivalent to native `path.getBBox()`.\n *\n * @public\n * @returns the pathBBox\n */\n getBBox(): {\n x: number;\n y: number;\n width: number;\n height: number;\n x2: number;\n y2: number;\n cx: number;\n cy: number;\n cz: number;\n } {\n return this.bbox;\n }\n\n /**\n * Returns the total path length, equivalent to native `path.getTotalLength()`.\n *\n * @public\n * @returns the path total length\n */\n getTotalLength(): number {\n return this.length;\n }\n\n /**\n * Returns an `{x,y}` point in the path stroke at a given length,\n * equivalent to the native `path.getPointAtLength()`.\n *\n * @public\n * @param length the length\n * @returns the requested point\n */\n getPointAtLength(length: number): { x: number; y: number } {\n return getPointAtLength(this.segments, length);\n }\n\n /**\n * Convert path to absolute values.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 10l80 80').toAbsolute().toString()\n * // => 'M10 10L90 90'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n toAbsolute(): this {\n const { segments } = this;\n this.segments = pathToAbsolute(segments);\n return this;\n }\n\n /**\n * Convert path to relative values.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 10L90 90').toRelative().toString()\n * // => 'M10 10l80 80'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n toRelative(): this {\n const { segments } = this;\n this.segments = pathToRelative(segments);\n return this;\n }\n\n /**\n * Convert path to cubic-bezier values. In addition, un-necessary `Z`\n * segment is removed if previous segment extends to the `M` segment.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 50q15 -25 30 0').toCurve().toString()\n * // => 'M10 50C25 25 40 50 40 50'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n toCurve(): this {\n const { segments } = this;\n this.segments = pathToCurve(segments);\n return this;\n }\n\n /**\n * Reverse the order of the segments and their values.\n *\n * @example\n * ```ts\n * new SVGPathCommander('M0 0L100 0L100 100L0 100Z').reverse().toString()\n * // => 'M0 100L0 0L100 0L100 100Z'\n * ```\n *\n * @param onlySubpath - option to reverse all sub-paths except first\n * @returns this for chaining\n * @public\n */\n reverse(onlySubpath?: boolean): this {\n const { segments } = this;\n const split = splitPath(segments);\n const subPath = split.length > 1 ? split : false;\n\n const absoluteMultiPath = subPath\n ? subPath.map((x, i) => {\n if (onlySubpath) {\n return i ? reversePath(x) : x.slice(0);\n }\n return reversePath(x);\n })\n : segments.slice(0);\n\n let path = [] as unknown as PathArray;\n if (subPath) {\n path = absoluteMultiPath.flat(1) as PathArray;\n } else {\n path = onlySubpath ? segments : reversePath(segments);\n }\n\n this.segments = path.slice(0) as PathArray;\n return this;\n }\n\n /**\n * Normalize path in 2 steps:\n * * convert `pathArray`(s) to absolute values\n * * convert shorthand notation to standard notation\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 90s20 -80 40 -80s20 80 40 80').normalize().toString()\n * // => 'M10 90C30 90 25 10 50 10C75 10 70 90 90 90'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n normalize(): this {\n const { segments } = this;\n this.segments = normalizePath(segments);\n return this;\n }\n\n /**\n * Optimize `pathArray` values:\n * * convert segments to absolute and/or relative values\n * * select segments with shortest resulted string\n * * round values to the specified `decimals` option value\n *\n * @example\n * ```ts\n * new SVGPathCommander('M10 10L10 10L90 90').optimize().toString()\n * // => 'M10 10l0 0 80 80'\n * ```\n *\n * @returns this for chaining\n * @public\n */\n optimize(): this {\n const { segments } = this;\n const round = this.round === \"off\" ? 2 : this.round;\n\n this.segments = optimizePath(segments, round);\n return this;\n }\n\n /**\n * Transform path using values from an `Object` defined as `transformObject`.\n *\n * @see TransformObject for a quick reference\n *\n * @param source a `transformObject` as described above\n * @returns this for chaining\n * @public\n */\n transform(source?: Partial<TransformObject>): this {\n if (\n !source ||\n typeof source !== \"object\" ||\n (typeof source === \"object\" &&\n ![\"translate\", \"rotate\", \"skew\", \"scale\"].some((x) => x in source))\n ) {\n return this;\n }\n\n const {\n segments,\n origin: [cx, cy, cz],\n } = this;\n const transform = {} as TransformObjectValues;\n for (const [k, v] of Object.entries(source) as TransformEntries) {\n // istanbul ignore else @preserve\n if (k === \"skew\" && Array.isArray(v)) {\n transform[k] = v.map(Number) as PointTuple;\n } else if (\n (k === \"rotate\" ||\n k === \"translate\" ||\n k === \"origin\" ||\n k === \"scale\") &&\n Array.isArray(v)\n ) {\n transform[k] = v.map(Number) as [number, number, number];\n } else if (k !== \"origin\" && typeof Number(v) === \"number\") {\n transform[k] = Number(v);\n }\n }\n\n // if origin is not specified\n // it's important that we have one\n const { origin } = transform;\n\n if (Array.isArray(origin) && origin.length >= 2) {\n const [originX, originY, originZ] = origin.map(Number);\n transform.origin = [\n !Number.isNaN(originX) ? originX : cx,\n !Number.isNaN(originY) ? originY : cy,\n originZ || cz,\n ];\n } else {\n transform.origin = [cx, cy, cz];\n }\n\n this.segments = transformPath(segments, transform);\n return this;\n }\n\n /**\n * Rotate path 180deg vertically.\n *\n * @example\n * ```ts\n * const path = new SVGPathCommander('M0 0L100 0L100 100L0 100Z')\n * path.flipX().toString()\n * ```\n *\n * @returns this for chaining\n * @public\n */\n flipX(): this {\n const { cx, cy } = this.bbox;\n this.transform({ rotate: [0, 180, 0], origin: [cx, cy, 0] });\n return this;\n }\n\n /**\n * Rotate path 180deg horizontally.\n *\n * @example\n * ```ts\n * const path = new SVGPathCommander('M0 0L100 0L100 100L0 100Z')\n * path.flipY().toString()\n * ```\n *\n * @returns this for chaining\n * @public\n */\n flipY(): this {\n const { cx, cy } = this.bbox;\n this.transform({ rotate: [180, 0, 0], origin: [cx, cy, 0] });\n return this;\n }\n\n /**\n * Export the current path to be used\n * for the `d` (description) attribute.\n *\n * @public\n * @returns the path string\n */\n toString(): string {\n return pathToString(this.segments, this.round);\n }\n\n /**\n * Remove the instance.\n *\n * @public\n * @returns void\n */\n dispose() {\n Object.keys(this).forEach((key) => delete this[key as keyof typeof this]);\n }\n\n static options = defaultOptions;\n static CSSMatrix = CSSMatrix;\n static arcTools = arcTools;\n static bezierTools = bezierTools;\n static cubicTools = cubicTools;\n static lineTools = lineTools;\n static polygonTools = polygonTools;\n static quadTools = quadTools;\n\n static pathToAbsolute = pathToAbsolute;\n static pathToRelative = pathToRelative;\n static pathToCurve = pathToCurve;\n static pathToString = pathToString;\n\n static distanceSquareRoot = distanceSquareRoot;\n static midPoint = midPoint;\n static rotateVector = rotateVector;\n static roundTo = roundTo;\n\n static parsePathString = parsePathString;\n static finalizeSegment = finalizeSegment;\n static invalidPathValue = invalidPathValue;\n\n static isArcCommand = isArcCommand;\n static isDigit = isDigit;\n static isDigitStart = isDigitStart;\n static isMoveCommand = isMoveCommand;\n static isPathCommand = isPathCommand;\n static isSpace = isSpace;\n\n static paramsCount = paramsCounts;\n static paramsParser = paramsParser;\n static PathParser = PathParser;\n static scanFlag = scanFlag;\n static scanParam = scanParam;\n static scanSegment = scanSegment;\n static skipSpaces = skipSpaces;\n\n static distanceEpsilon = distanceEpsilon;\n\n static fixPath = fixPath;\n static getClosestPoint = getClosestPoint;\n static getDrawDirection = getDrawDirection;\n static getPathArea = getPathArea;\n static getPathBBox = getPathBBox;\n static getPointAtLength = getPointAtLength;\n static getPropertiesAtLength = getPropertiesAtLength;\n static getPropertiesAtPoint = getPropertiesAtPoint;\n static getSegmentAtLength = getSegmentAtLength;\n static getSegmentOfPoint = getSegmentOfPoint;\n static getTotalLength = getTotalLength;\n\n static isAbsoluteArray = isAbsoluteArray;\n static isCurveArray = isCurveArray;\n static isPolygonArray = isPolygonArray;\n static isNormalizedArray = isNormalizedArray;\n static isPathArray = isPathArray;\n static isPointInStroke = isPointInStroke;\n static isRelativeArray = isRelativeArray;\n static isValidPath = isValidPath;\n\n static samplePolygon = samplePolygon;\n static shapeParams = shapeParams;\n static shapeToPath = shapeToPath;\n static shapeToPathArray = shapeToPathArray;\n\n static absolutizeSegment = absolutizeSegment;\n static arcToCubic = arcToCubic;\n static getSVGMatrix = getSVGMatrix;\n static iterate = iterate;\n static lineToCubic = lineToCubic;\n static normalizePath = normalizePath;\n static normalizeSegment = normalizeSegment;\n static optimizePath = optimizePath;\n static projection2d = projection2d;\n static quadToCubic = quadToCubic;\n static relativizeSegment = relativizeSegment;\n static reverseCurve = reverseCurve;\n static reversePath = reversePath;\n static roundPath = roundPath;\n static roundSegment = roundSegment;\n static segmentToCubic = segmentToCubic;\n static shortenSegment = shortenSegment;\n static splitPath = splitPath;\n static equalizePaths = equalizePaths;\n static equalizeSegments = equalizeSegments;\n static splitCubicSegment = splitCubicSegment;\n static transformPath = transformPath;\n static isPointInsideBBox = isPointInsideBBox;\n static pathsIntersection = pathsIntersection;\n static boundingBoxIntersect = boundingBoxIntersect;\n static isMultiPath = isMultiPath;\n static isClosedPath = isClosedPath;\n static isPolylineArray = isPolylineArray;\n static version = pkg.version;\n}\n\nexport default SVGPathCommander;\n","\"use strict\";\n\nimport SVGPathCommander from \"./main.ts\";\n\nexport * from \"./types.ts\";\nexport * from \"./interface.ts\";\n\nexport default SVGPathCommander;\nexport {};\n"],"x_google_ignoreList":[1],"mappings":";kPCEA,IAAM,EAAc,CACnB,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,KAAM,GACN,WAAY,EACb,EAEM,EAAqB,IAClB,aAAiB,cAAgB,aAAiB,cAAgB,MAAM,QAAQ,CAAK,GAAK,EAAM,MAAO,GAAM,OAAO,GAAM,QAAQ,IAAM,CAAC,EAAG,EAAE,CAAC,CAAC,KAAM,GAAM,EAAM,SAAW,CAAC,EAGjL,EAAsB,GACpB,OAAO,UAAc,KAAe,aAAkB,WAAa,aAAkB,GAAa,OAAO,GAAW,UAAY,OAAO,KAAK,CAAW,CAAC,CAAC,MAAO,GAAM,GAAU,KAAK,CAAM,EAY7L,EAAa,GAAU,CAC5B,IAAM,EAAI,IAAI,EACR,EAAI,MAAM,KAAK,CAAK,EAC1B,GAAI,CAAC,EAAkB,CAAC,EAAG,MAAM,UAAU,eAAe,EAAE,KAAK,GAAG,EAAE,sCAAsC,EAE5G,GAAI,EAA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