curvy 2.0.0-alpha.13 → 2.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/cubic2d.d.ts +92 -3
- package/dist/curve/curve2d.d.ts +81 -0
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/linear2d.d.ts +113 -3
- package/dist/curve/quadratic2d.d.ts +92 -3
- package/dist/curve/rationalCubic2d.d.ts +100 -38
- package/dist/interval/index.mjs +2 -2
- package/dist/matrix/index.mjs +47 -1
- package/dist/matrix/index.mjs.map +1 -1
- package/dist/matrix/matrix3x3.d.ts +87 -1
- package/dist/matrix/matrix4x4.d.ts +57 -6
- package/dist/matrix/traits.d.ts +34 -0
- package/dist/monotonicity/index.mjs +1 -1
- package/dist/monotonicity/monotonicity.d.ts +25 -0
- package/dist/number.d.ts +53 -0
- package/dist/number.mjs +56 -1
- package/dist/number.mjs.map +1 -1
- package/dist/path/cubic2d.d.ts +22 -0
- package/dist/path/index.mjs +25 -149
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/linear2d.d.ts +24 -0
- package/dist/path/path2d.d.ts +54 -0
- package/dist/path/quadratic2d.d.ts +22 -0
- package/dist/path/rationalCubic2d.d.ts +21 -0
- package/dist/polynomial/index.mjs +2 -2
- package/dist/shared/affine2d-Dvna84gc.mjs +332 -0
- package/dist/shared/affine2d-Dvna84gc.mjs.map +1 -0
- package/dist/shared/{characteristic-BkEr-rr8.mjs → characteristic--7nC4Q_a.mjs} +4 -5
- package/dist/shared/characteristic--7nC4Q_a.mjs.map +1 -0
- package/dist/shared/{cubic-BL6dpuHh.mjs → cubic-BiGuAnZ0.mjs} +56 -27
- package/dist/shared/cubic-BiGuAnZ0.mjs.map +1 -0
- package/dist/shared/{interval-Dm35Xhy4.mjs → interval-Dcqpo73t.mjs} +5 -5
- package/dist/shared/interval-Dcqpo73t.mjs.map +1 -0
- package/dist/shared/{interval2d-AtneyI45.mjs → interval2d-C2Pk66-2.mjs} +3 -3
- package/dist/shared/{interval2d-AtneyI45.mjs.map → interval2d-C2Pk66-2.mjs.map} +1 -1
- package/dist/shared/matrix3x3.internal-Cod-r7H3.mjs +233 -0
- package/dist/shared/matrix3x3.internal-Cod-r7H3.mjs.map +1 -0
- package/dist/shared/{matrix4x4-BWmf4lZM.mjs → matrix4x4-BrqgYZCD.mjs} +72 -223
- package/dist/shared/matrix4x4-BrqgYZCD.mjs.map +1 -0
- package/dist/shared/monotonicity-DNxBoC7F.mjs +64 -0
- package/dist/shared/monotonicity-DNxBoC7F.mjs.map +1 -0
- package/dist/shared/{quadratic-DPrUsFCp.mjs → quadratic-BmMqkvxx.mjs} +2 -2
- package/dist/shared/{quadratic-DPrUsFCp.mjs.map → quadratic-BmMqkvxx.mjs.map} +1 -1
- package/dist/shared/{rationalCubic2d-H1J2Fjyy.mjs → rationalCubic2d-CZiP8nIq.mjs} +282 -326
- package/dist/shared/rationalCubic2d-CZiP8nIq.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-CeHgpNht.mjs → rationalCubic2d-gM7VeiiT.mjs} +585 -125
- package/dist/shared/rationalCubic2d-gM7VeiiT.mjs.map +1 -0
- package/dist/shared/{solution-B2JdOZpe.mjs → solution-BW0BBMXI.mjs} +22 -6
- package/dist/shared/solution-BW0BBMXI.mjs.map +1 -0
- package/dist/shared/{vector2-CSkaMXvp.mjs → vector2-DuA3EmfL.mjs} +5 -3
- package/dist/shared/vector2-DuA3EmfL.mjs.map +1 -0
- package/dist/shared/{vector2.internal-DP1nTBdS.mjs → vector2.internal-rPnW0RCx.mjs} +10 -5
- package/dist/shared/vector2.internal-rPnW0RCx.mjs.map +1 -0
- package/dist/shared/{vector3-CR2LPV03.mjs → vector3-oxtggkDp.mjs} +2 -2
- package/dist/shared/{vector3-CR2LPV03.mjs.map → vector3-oxtggkDp.mjs.map} +1 -1
- package/dist/shared/vector3.internal-CfWHl9SG.mjs +135 -0
- package/dist/shared/vector3.internal-CfWHl9SG.mjs.map +1 -0
- package/dist/shared/{vector4-PO_7EYd-.mjs → vector4-DGHuCvTV.mjs} +2 -2
- package/dist/shared/{vector4-PO_7EYd-.mjs.map → vector4-DGHuCvTV.mjs.map} +1 -1
- package/dist/shared/vector4.internal-DH5DzNYO.mjs +116 -0
- package/dist/shared/vector4.internal-DH5DzNYO.mjs.map +1 -0
- package/dist/solution/index.mjs +1 -1
- package/dist/solution/solution.d.ts +16 -0
- package/dist/splines/basis2d.d.ts +64 -0
- package/dist/splines/bezier2d.d.ts +72 -0
- package/dist/splines/cardinal2d.d.ts +78 -0
- package/dist/splines/hermite2d.d.ts +76 -0
- package/dist/splines/index.mjs +109 -15
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/linear2d.d.ts +65 -0
- package/dist/splines/rationalBezier2d.d.ts +76 -0
- package/dist/transform/affine2d.d.ts +339 -0
- package/dist/transform/affine2d.internal.d.ts +2 -0
- package/dist/transform/index.d.ts +3 -0
- package/dist/transform/index.mjs +2 -0
- package/dist/transform/traits.d.ts +19 -0
- package/dist/vector/index.mjs +3 -3
- package/dist/vector/vector2.d.ts +49 -0
- package/package.json +5 -1
- package/dist/shared/characteristic-BkEr-rr8.mjs.map +0 -1
- package/dist/shared/cubic-BL6dpuHh.mjs.map +0 -1
- package/dist/shared/interval-Dm35Xhy4.mjs.map +0 -1
- package/dist/shared/matrix4x4-BWmf4lZM.mjs.map +0 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +0 -34
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +0 -1
- package/dist/shared/solution-B2JdOZpe.mjs.map +0 -1
- package/dist/shared/vector2-CSkaMXvp.mjs.map +0 -1
- package/dist/shared/vector2.internal-DP1nTBdS.mjs.map +0 -1
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs +0 -246
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rationalCubic2d-CZiP8nIq.mjs","names":["Interval.unit","Solution.one","Solution.isNone","Solution.none","Interval2d.union","methods","Path2d.makeMethods","linearCurveInternal.Ops","isLinearPath2d","make","fromArray","append","length","solve","toPathData","isContinuous","asContinuous","isIncreasingX","isDecreasingX","isMonotonicX","isIncreasingY","isDecreasingY","isMonotonicY","asIncreasingX","asDecreasingX","asMonotonicX","asIncreasingY","asDecreasingY","asMonotonicY","solveAtX","solveAtY","boundingBox","transform","make","internal.make","fromArray","internal.fromArray","internal.isLinearPath2d","append","internal.append","length","internal.length","solve","internal.solve","toPathData","internal.toPathData","isContinuous","internal.isContinuous","asContinuous","internal.asContinuous","isIncreasingX","internal.isIncreasingX","isDecreasingX","internal.isDecreasingX","isMonotonicX","internal.isMonotonicX","isIncreasingY","internal.isIncreasingY","isDecreasingY","internal.isDecreasingY","isMonotonicY","internal.isMonotonicY","asIncreasingX","internal.asIncreasingX","asDecreasingX","internal.asDecreasingX","asMonotonicX","internal.asMonotonicX","asIncreasingY","internal.asIncreasingY","asDecreasingY","internal.asDecreasingY","asMonotonicY","internal.asMonotonicY","solveAtX","internal.solveAtX","solveAtY","internal.solveAtY","boundingBox","internal.boundingBox","transform","internal.transform","Path2d.makeMethods","cubicCurveInternal.Ops","isCubicPath2d","make","fromArray","append","length","solve","toPathData","isContinuous","asContinuous","isIncreasingX","isDecreasingX","isMonotonicX","isIncreasingY","isDecreasingY","isMonotonicY","asIncreasingX","asDecreasingX","asMonotonicX","asIncreasingY","asDecreasingY","asMonotonicY","solveAtX","solveAtY","boundingBox","transform","CubicCurve2d.length","Interval.unit","derivative","cubicCurveInternal.derivative","Interval.make","Vector2.magnitude","QuadraticCurve2d.solve","solveByDistance","Path2d.Path2dImpl","CubicCurve2d.solve","make","internal.make","fromArray","internal.fromArray","internal.isCubicPath2d","append","internal.append","internal.length","solve","internal.solve","internal.toPathData","internal.isContinuous","internal.asContinuous","internal.isIncreasingX","internal.isDecreasingX","internal.isMonotonicX","internal.isIncreasingY","internal.isDecreasingY","internal.isMonotonicY","internal.asIncreasingX","internal.asDecreasingX","internal.asMonotonicX","internal.asIncreasingY","internal.asDecreasingY","internal.asMonotonicY","internal.solveAtX","internal.solveAtY","internal.solveByDistance","boundingBox","internal.boundingBox","transform","internal.transform","isRationalCubicPath2d","make","fromArray","append","solve","RationalCubicCurve2d.solve","boundingBox","RationalCubicCurve2d.boundingBox","Interval2d.union","approximateAsCubicPath","RationalCubicCurve2d.approximateAsCubicCurves","CubicPath2d.fromArray","transform","RationalCubicCurve2d.transform","internal.isRationalCubicPath2d","internal.make","internal.fromArray","internal.append","internal.solve","internal.boundingBox","internal.approximateAsCubicPath","internal.transform"],"sources":["../../src/path/path2d.ts","../../src/path/linear2d.internal.ts","../../src/path/linear2d.ts","../../src/path/cubic2d.internal.ts","../../src/path/cubic2d.ts","../../src/path/rationalCubic2d.internal.ts","../../src/path/rationalCubic2d.ts"],"sourcesContent":["import type { Curve2dOps } from '../curve/curve2d.ts'\nimport * as Interval from '../interval/interval.ts'\nimport * as Interval2d from '../interval/interval2d.ts'\nimport { coincident } from '../number.ts'\nimport * as Solution from '../solution/solution.ts'\nimport type { Affine2d } from '../transform/affine2d.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport {\n PathTraits,\n type Continuous,\n type DecreasingX,\n type DecreasingY,\n type IncreasingX,\n type IncreasingY,\n type MonotonicX,\n type MonotonicY,\n} from './traits.ts'\n\n/**\n * Generic 2D path — a sequence of curves of a single kind `C` plus optional\n * trait brands (`Continuous`, `MonotonicX`, etc.) tracking properties of the\n * path as a whole.\n *\n * Each concrete path kind (`LinearPath2d`, `QuadraticPath2d`, `CubicPath2d`)\n * is a `Path2d<TheirCurveKind, Trait>` plus a per-kind `TypeId` slot for\n * cheap runtime identification. The per-kind modules re-export an operation\n * surface derived from {@link makeMethods} over their curve's\n * {@link Curve2dOps}.\n *\n * @since 2.0.0\n */\nexport interface Path2d<C, Trait = unknown> extends Pipeable, Iterable<C> {\n readonly [PathTraits]: Trait\n}\n\n/**\n * Concrete implementation backing every `Path2d<C>`. The per-kind `TypeId`\n * symbol is stamped onto each instance as a dynamic property at the symbol\n * key it identifies, so the existing per-kind `is{Linear,Quadratic,Cubic}Path2d`\n * typeguards continue to work as `TypeId in p` checks.\n *\n * @internal\n */\nexport class Path2dImpl<C> extends Pipeable implements Path2d<C, unknown> {\n declare readonly [PathTraits]: unknown\n readonly curves: ReadonlyArray<C>\n\n constructor(typeId: symbol, curves: ReadonlyArray<C>) {\n super()\n ;(this as unknown as Record<symbol, symbol>)[typeId] = typeId\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<C> {\n return this.curves[Symbol.iterator]()\n }\n}\n\n/**\n * Builds the bundle of generic path operations for a curve kind `C`, given\n * that curve's {@link Curve2dOps} and the per-kind `TypeId` symbol. Each\n * polynomial-degree path module calls this once and re-exports the returned\n * functions with curve-narrowed signatures.\n *\n * `ops` and `typeId` are captured by closure, so the returned operations\n * incur no per-call lookup overhead.\n *\n * @since 2.0.0\n */\nexport const makeMethods = <C>(typeId: symbol, ops: Curve2dOps<C>) => {\n const fromArray = (curves: ReadonlyArray<C>): Path2d<C> => new Path2dImpl(typeId, curves)\n\n const make = (...curves: ReadonlyArray<C>): Path2d<C> => fromArray(curves)\n\n const append = dual<(c: C) => (p: Path2d<C>) => Path2d<C>, (p: Path2d<C>, c: C) => Path2d<C>>(\n 2,\n (p: Path2d<C>, c: C) => fromArray([...p, c]),\n )\n\n const length = (p: Path2d<C>): number => {\n let total = 0\n for (const curve of p) {\n total += ops.length(curve, Interval.unit)\n }\n return total\n }\n\n const solve = dual<\n (u: number) => (p: Path2d<C>) => Vector2,\n (p: Path2d<C>, u: number) => Vector2\n >(2, (p: Path2d<C>, u: number) => {\n const curves = p instanceof Path2dImpl ? (p.curves as ReadonlyArray<C>) : [...p]\n if (u === 1) {\n return ops.solve(curves.at(-1) as C, 1)\n }\n const t = u * curves.length\n const i = Math.floor(t)\n return ops.solve(curves[i] as C, t - i)\n })\n\n const toPathData = (p: Path2d<C>): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const start = ops.startPoint(curve)\n const end = ops.endPoint(curve)\n\n if (!coincident(start.x, prevEndX) || !coincident(start.y, prevEndY)) {\n result += ` M ${start.x},${start.y}`\n }\n result += ` ${ops.toPathDataSegment(curve)}`\n\n prevEndX = end.x\n prevEndY = end.y\n }\n\n return result.slice(1)\n }\n\n const isContinuous = <T>(p: Path2d<C, T>): p is Path2d<C, T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const start = ops.startPoint(curve)\n if (!first && (!coincident(start.x, prevEndX) || !coincident(start.y, prevEndY))) {\n return false\n }\n const end = ops.endPoint(curve)\n prevEndX = end.x\n prevEndY = end.y\n first = false\n }\n return true\n }\n\n // Per-axis monotonicity for the path: every segment's axis polynomial must\n // be strictly monotonic over the unit interval AND adjacent segments' axis\n // ranges must not overlap — a knot that backtracks within the coincidence\n // band counts as continuous rather than as a reversal.\n const isIncreasingX = <T>(p: Path2d<C, T>): p is Path2d<C, T & IncreasingX> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!ops.isIncreasingX(c)) {\n return false\n }\n const start = ops.startPoint(c).x\n if (start < prevEnd && !coincident(start, prevEnd)) {\n return false\n }\n prevEnd = ops.endPoint(c).x\n }\n return true\n }\n\n const isDecreasingX = <T>(p: Path2d<C, T>): p is Path2d<C, T & DecreasingX> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!ops.isDecreasingX(c)) {\n return false\n }\n const start = ops.startPoint(c).x\n if (start > prevEnd && !coincident(start, prevEnd)) {\n return false\n }\n prevEnd = ops.endPoint(c).x\n }\n return true\n }\n\n const isMonotonicX = <T>(p: Path2d<C, T>): p is Path2d<C, T & MonotonicX> =>\n isIncreasingX(p) || isDecreasingX(p)\n\n const isIncreasingY = <T>(p: Path2d<C, T>): p is Path2d<C, T & IncreasingY> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!ops.isIncreasingY(c)) {\n return false\n }\n const start = ops.startPoint(c).y\n if (start < prevEnd && !coincident(start, prevEnd)) {\n return false\n }\n prevEnd = ops.endPoint(c).y\n }\n return true\n }\n\n const isDecreasingY = <T>(p: Path2d<C, T>): p is Path2d<C, T & DecreasingY> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!ops.isDecreasingY(c)) {\n return false\n }\n const start = ops.startPoint(c).y\n if (start > prevEnd && !coincident(start, prevEnd)) {\n return false\n }\n prevEnd = ops.endPoint(c).y\n }\n return true\n }\n\n const isMonotonicY = <T>(p: Path2d<C, T>): p is Path2d<C, T & MonotonicY> =>\n isIncreasingY(p) || isDecreasingY(p)\n\n // solveAtX / solveAtY on a monotonic-axis path. Two defenses against float\n // drift at interior knots, where two adjacent segments both bracket the\n // query and the per-curve inverse may return `none` for both:\n // 1. Snap to t=0/t=1 endpoint y when the query is coincident with a\n // segment's start or end — bypasses polynomial inversion at knots.\n // 2. Fall through to the next bracketing segment on `none`. `MonotonicX`/Y\n // admits at most one real solution across the path, so retrying is safe.\n const solveAtX = dual(2, (p: Path2d<C>, x: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const start = ops.startPoint(c)\n const end = ops.endPoint(c)\n const lo = Math.min(start.x, end.x)\n const hi = Math.max(start.x, end.x)\n if ((x >= lo && x <= hi) || coincident(x, lo) || coincident(x, hi)) {\n if (coincident(x, start.x)) {\n return Solution.one(start.y)\n }\n if (coincident(x, end.x)) {\n return Solution.one(end.y)\n }\n const sol = ops.solveAtX(c, x)\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n })\n\n const solveAtY = dual(2, (p: Path2d<C>, y: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const start = ops.startPoint(c)\n const end = ops.endPoint(c)\n const lo = Math.min(start.y, end.y)\n const hi = Math.max(start.y, end.y)\n if ((y >= lo && y <= hi) || coincident(y, lo) || coincident(y, hi)) {\n if (coincident(y, start.y)) {\n return Solution.one(start.x)\n }\n if (coincident(y, end.y)) {\n return Solution.one(end.x)\n }\n const sol = ops.solveAtY(c, y)\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n })\n\n const boundingBox = (p: Path2d<C>): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n let acc = ops.boundingBox(first.value as C)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, ops.boundingBox(next.value))\n }\n return acc\n }\n\n // Per-curve transform: the curve-level op already encodes the right\n // coefficient-vs-position split for its degree, so the path-level call is\n // just a map. Trait brands are dropped — affine maps preserve continuity\n // (since image of a connected set is connected) but can flip monotonicity\n // sense (a reflection inverts increasing → decreasing) so the brands must\n // be reasserted on the result if the caller still wants them.\n const transform = dual<\n (a: Affine2d) => (p: Path2d<C>) => Path2d<C>,\n (p: Path2d<C>, a: Affine2d) => Path2d<C>\n >(2, (p: Path2d<C>, a: Affine2d) => {\n const curves: Array<C> = []\n for (const c of p) {\n curves.push(ops.transform(c, a))\n }\n return fromArray(curves)\n })\n\n return {\n fromArray,\n make,\n append,\n length,\n solve,\n toPathData,\n isContinuous,\n isIncreasingX,\n isDecreasingX,\n isMonotonicX,\n isIncreasingY,\n isDecreasingY,\n isMonotonicY,\n solveAtX,\n solveAtY,\n boundingBox,\n transform,\n }\n}\n","import type * as LinearCurve2d from '../curve/linear2d.ts'\nimport * as linearCurveInternal from '../curve/linear2d.internal.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type { Interval2d } from '../interval/interval2d.ts'\nimport { invariant } from '../utils.ts'\nimport type { LinearPath2d } from './linear2d.ts'\nimport * as Path2d from './path2d.ts'\nimport {\n type Continuous,\n type DecreasingX,\n type DecreasingY,\n type IncreasingX,\n type IncreasingY,\n type MonotonicX,\n type MonotonicY,\n} from './traits.ts'\n\nexport const LinearPath2dTypeId: unique symbol = Symbol('curvy/path/linear2d')\nexport type LinearPath2dTypeId = typeof LinearPath2dTypeId\n\n// Generic operation surface, built once for LinearCurve2d's Ops.\nconst methods = Path2d.makeMethods(LinearPath2dTypeId, linearCurveInternal.Ops)\n\n/** @internal */\nexport const isLinearPath2d = (p: unknown): p is LinearPath2d =>\n typeof p === 'object' && p !== null && LinearPath2dTypeId in p\n\n/** @internal */\nexport const make = methods.make as (\n ...curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>\n) => LinearPath2d\n\n/** @internal */\nexport const fromArray = methods.fromArray as (\n curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>,\n) => LinearPath2d\n\n/** @internal */\nexport const append = methods.append as never\n\n/** @internal */\nexport const length = methods.length as (p: LinearPath2d) => number\n\n/** @internal */\nexport const solve = methods.solve as never\n\n/** @internal */\nexport const toPathData = methods.toPathData as (p: LinearPath2d) => string\n\n/** @internal */\nexport const isContinuous = methods.isContinuous as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & Continuous>\n\n/** @internal */\nexport const asContinuous = <T>(p: LinearPath2d<T>): LinearPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'linear path is not continuous')\n return p\n}\n\n/** @internal */\nexport const isIncreasingX = methods.isIncreasingX as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & IncreasingX>\n\n/** @internal */\nexport const isDecreasingX = methods.isDecreasingX as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & DecreasingX>\n\n/** @internal */\nexport const isMonotonicX = methods.isMonotonicX as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & MonotonicX>\n\n/** @internal */\nexport const isIncreasingY = methods.isIncreasingY as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & IncreasingY>\n\n/** @internal */\nexport const isDecreasingY = methods.isDecreasingY as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & DecreasingY>\n\n/** @internal */\nexport const isMonotonicY = methods.isMonotonicY as unknown as <T>(\n p: LinearPath2d<T>,\n) => p is LinearPath2d<T & MonotonicY>\n\n/** @internal */\nexport const asIncreasingX = <T>(p: LinearPath2d<T>): LinearPath2d<T & IncreasingX> => {\n invariant(isIncreasingX(p), 'linear path is not increasing in x')\n return p\n}\n\n/** @internal */\nexport const asDecreasingX = <T>(p: LinearPath2d<T>): LinearPath2d<T & DecreasingX> => {\n invariant(isDecreasingX(p), 'linear path is not decreasing in x')\n return p\n}\n\n/** @internal */\nexport const asMonotonicX = <T>(p: LinearPath2d<T>): LinearPath2d<T & MonotonicX> => {\n invariant(isMonotonicX(p), 'linear path is not monotonic in x')\n return p\n}\n\n/** @internal */\nexport const asIncreasingY = <T>(p: LinearPath2d<T>): LinearPath2d<T & IncreasingY> => {\n invariant(isIncreasingY(p), 'linear path is not increasing in y')\n return p\n}\n\n/** @internal */\nexport const asDecreasingY = <T>(p: LinearPath2d<T>): LinearPath2d<T & DecreasingY> => {\n invariant(isDecreasingY(p), 'linear path is not decreasing in y')\n return p\n}\n\n/** @internal */\nexport const asMonotonicY = <T>(p: LinearPath2d<T>): LinearPath2d<T & MonotonicY> => {\n invariant(isMonotonicY(p), 'linear path is not monotonic in y')\n return p\n}\n\n/** @internal */\nexport const solveAtX = methods.solveAtX as never\n\n/** @internal */\nexport const solveAtY = methods.solveAtY as never\n\n/** @internal */\nexport const boundingBox = methods.boundingBox as (p: LinearPath2d) => Interval2d<Closed, Closed>\n\n/** @internal */\nexport const transform = methods.transform as never\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { LinearCurve2d } from '../curve/linear2d.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Affine2d } from '../transform/affine2d.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPath2dTypeId } from './linear2d.internal.ts'\nimport * as internal from './linear2d.internal.ts'\nimport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n PathTraits,\n} from './traits.ts'\n\nexport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n} from './traits.ts'\n\n/**\n * A linear path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`. A `Continuous` path's `toPathData`\n * skips the per-segment discontinuity check.\n *\n * @since 1.0.0\n */\nexport interface LinearPath2d<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `LinearPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.make\n\n/**\n * Creates a new `LinearPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `LinearPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPath2d: (p: unknown) => p is LinearPath2d = internal.isLinearPath2d\n\nexport const append: {\n /**\n * Appends a linear curve to a linear path.\n *\n * @param c - The linear curve to append.\n * @returns A function that takes a linear path and returns a new linear path.\n * @since 1.0.0\n */\n (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d\n /**\n * Appends a linear curve to a linear path.\n *\n * @param p - The linear path to append to.\n * @param c - The linear curve to append.\n * @returns A new `LinearPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: LinearPath2d, c: LinearCurve2d): LinearPath2d\n} = internal.append\n\n/**\n * Calculates the length of a linear path.\n *\n * @param p - The linear path to calculate the length of.\n * @returns The length of the linear path.\n * @since 1.0.0\n */\nexport const length: (p: LinearPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a linear path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a linear path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: LinearPath2d) => Vector2\n /**\n * Solves a linear path for a given parameter.\n *\n * @param p - The linear path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point on the linear path.\n * @since 1.0.0\n */\n (p: LinearPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a linear path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `L` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The linear path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: LinearPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join\n * points.\n *\n * @param p - The linear path to check.\n * @returns `true` when the path is continuous (G⁰).\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the linear path is continuous, throwing on failure.\n *\n * @param p - The linear path to assert against.\n * @returns The same path, typed with the `Continuous` brand.\n * @throws When the path has a discontinuity between adjacent curves.\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: LinearPath2d<T>) => LinearPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & IncreasingX>` when every segment's x-polynomial is\n * strictly increasing and adjacent segments' x-ranges don't overlap.\n *\n * @since 2.0.0\n */\nexport const isIncreasingX: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & IncreasingX> =\n internal.isIncreasingX\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & DecreasingX>` when every segment's x-polynomial is\n * strictly decreasing and adjacent segments' x-ranges don't overlap.\n *\n * @since 2.0.0\n */\nexport const isDecreasingX: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & DecreasingX> =\n internal.isDecreasingX\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & MonotonicX>` when the path is either increasing or\n * decreasing in x along its full parameter domain.\n *\n * @since 2.0.0\n */\nexport const isMonotonicX: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & MonotonicX> =\n internal.isMonotonicX\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & IncreasingY>`. The y-axis analog of {@link isIncreasingX}.\n *\n * @since 2.0.0\n */\nexport const isIncreasingY: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & IncreasingY> =\n internal.isIncreasingY\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & DecreasingY>`. The y-axis analog of {@link isDecreasingX}.\n *\n * @since 2.0.0\n */\nexport const isDecreasingY: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & DecreasingY> =\n internal.isDecreasingY\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & MonotonicY>`. The y-axis analog of {@link isMonotonicX}.\n *\n * @since 2.0.0\n */\nexport const isMonotonicY: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & MonotonicY> =\n internal.isMonotonicY\n\n/**\n * Asserts that the path is strictly increasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingX: <T>(p: LinearPath2d<T>) => LinearPath2d<T & IncreasingX> =\n internal.asIncreasingX\n\n/**\n * Asserts that the path is strictly decreasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingX: <T>(p: LinearPath2d<T>) => LinearPath2d<T & DecreasingX> =\n internal.asDecreasingX\n\n/**\n * Asserts that the path is monotonic in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicX: <T>(p: LinearPath2d<T>) => LinearPath2d<T & MonotonicX> =\n internal.asMonotonicX\n\n/**\n * Asserts that the path is strictly increasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingY: <T>(p: LinearPath2d<T>) => LinearPath2d<T & IncreasingY> =\n internal.asIncreasingY\n\n/**\n * Asserts that the path is strictly decreasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingY: <T>(p: LinearPath2d<T>) => LinearPath2d<T & DecreasingY> =\n internal.asDecreasingY\n\n/**\n * Asserts that the path is monotonic in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicY: <T>(p: LinearPath2d<T>) => LinearPath2d<T & MonotonicY> =\n internal.asMonotonicY\n\nexport const solveAtX: {\n /**\n * Evaluates the path's y value at a given x. Requires the path to carry the\n * `MonotonicX` brand — without it, an x query could match multiple\n * segments and the return cardinality would be unbounded.\n *\n * Returns `Solution.none` when x falls outside the path's x-range.\n *\n * @param p - A path branded `MonotonicX`.\n * @param x - The x coordinate.\n * @returns The y value at x, or `none` when x is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicX>(p: LinearPath2d<T>, x: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (x: number): <T extends MonotonicX>(p: LinearPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the path's x value at a given y. Requires the path to carry the\n * `MonotonicY` brand. Returns `Solution.none` when y is outside the path's\n * y-range.\n *\n * @param p - A path branded `MonotonicY`.\n * @param y - The y coordinate.\n * @returns The x value at y, or `none` when y is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicY>(p: LinearPath2d<T>, y: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (y: number): <T extends MonotonicY>(p: LinearPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtY as never\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The linear path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.0.0\n */\nexport const boundingBox: (p: LinearPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n\nexport const transform: {\n /**\n * Applies an `Affine2d` transform to every curve in a `LinearPath2d`,\n * returning a new path whose image is the affine image of the original.\n * Trait brands are dropped — affine maps can flip the sense of monotonicity\n * (a reflection turns `IncreasingX` into `DecreasingX`), so any brands the\n * caller still wants must be reasserted on the result.\n *\n * @param p - The linear path.\n * @param a - The affine transform.\n * @returns A new unbranded `LinearPath2d` whose curves are the affine images of the input's.\n * @since 2.0.0\n */\n (p: LinearPath2d, a: Affine2d): LinearPath2d\n /**\n * Applies an `Affine2d` transform to every curve in a `LinearPath2d`.\n *\n * @param a - The affine transform.\n * @returns A function that takes a `LinearPath2d` and returns the transformed path.\n * @since 2.0.0\n */\n (a: Affine2d): (p: LinearPath2d) => LinearPath2d\n} = internal.transform\n","import * as CubicCurve2d from '../curve/cubic2d.ts'\nimport * as cubicCurveInternal from '../curve/cubic2d.internal.ts'\nimport * as QuadraticCurve2d from '../curve/quadratic2d.ts'\nimport * as Interval from '../interval/interval.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type { Interval2d } from '../interval/interval2d.ts'\nimport { RELATIVE_TOLERANCE } from '../number.ts'\nimport { dual, invariant } from '../utils.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport type { CubicPath2d } from './cubic2d.ts'\nimport * as Path2d from './path2d.ts'\nimport {\n type Continuous,\n type DecreasingX,\n type DecreasingY,\n type IncreasingX,\n type IncreasingY,\n type MonotonicX,\n type MonotonicY,\n} from './traits.ts'\n\nexport const CubicPath2dTypeId: unique symbol = Symbol('curvy/path/cubic2d')\nexport type CubicPath2dTypeId = typeof CubicPath2dTypeId\n\n// Generic operation surface, built once for CubicCurve2d's Ops.\nconst methods = Path2d.makeMethods(CubicPath2dTypeId, cubicCurveInternal.Ops)\n\n/** @internal */\nexport const isCubicPath2d = (p: unknown): p is CubicPath2d =>\n typeof p === 'object' && p !== null && CubicPath2dTypeId in p\n\n// The cubic path enforces a non-empty curve list. Wrap the generic factories\n// to check the invariant; the generic builders accept empty arrays as a\n// matter of structural minimality, but the cubic-specific contract is stricter.\n/** @internal */\nexport const make = (...curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>): CubicPath2d => {\n invariant(curves.length > 0, 'cubic path requires at least one curve')\n return methods.make(...curves) as CubicPath2d\n}\n\n/** @internal */\nexport const fromArray = (curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>): CubicPath2d => {\n invariant(curves.length > 0, 'cubic path requires at least one curve')\n return methods.fromArray(curves) as CubicPath2d\n}\n\n/** @internal */\nexport const append = methods.append as never\n\n/** @internal */\nexport const length = methods.length as (p: CubicPath2d) => number\n\n/** @internal */\nexport const solve = methods.solve as never\n\n/** @internal */\nexport const toPathData = methods.toPathData as (p: CubicPath2d) => string\n\n/** @internal */\nexport const isContinuous = methods.isContinuous as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & Continuous>\n\n/** @internal */\nexport const asContinuous = <T>(p: CubicPath2d<T>): CubicPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'cubic path is not continuous')\n return p\n}\n\n/** @internal */\nexport const isIncreasingX = methods.isIncreasingX as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & IncreasingX>\n\n/** @internal */\nexport const isDecreasingX = methods.isDecreasingX as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & DecreasingX>\n\n/** @internal */\nexport const isMonotonicX = methods.isMonotonicX as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & MonotonicX>\n\n/** @internal */\nexport const isIncreasingY = methods.isIncreasingY as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & IncreasingY>\n\n/** @internal */\nexport const isDecreasingY = methods.isDecreasingY as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & DecreasingY>\n\n/** @internal */\nexport const isMonotonicY = methods.isMonotonicY as unknown as <T>(\n p: CubicPath2d<T>,\n) => p is CubicPath2d<T & MonotonicY>\n\n/** @internal */\nexport const asIncreasingX = <T>(p: CubicPath2d<T>): CubicPath2d<T & IncreasingX> => {\n invariant(isIncreasingX(p), 'cubic path is not increasing in x')\n return p\n}\n\n/** @internal */\nexport const asDecreasingX = <T>(p: CubicPath2d<T>): CubicPath2d<T & DecreasingX> => {\n invariant(isDecreasingX(p), 'cubic path is not decreasing in x')\n return p\n}\n\n/** @internal */\nexport const asMonotonicX = <T>(p: CubicPath2d<T>): CubicPath2d<T & MonotonicX> => {\n invariant(isMonotonicX(p), 'cubic path is not monotonic in x')\n return p\n}\n\n/** @internal */\nexport const asIncreasingY = <T>(p: CubicPath2d<T>): CubicPath2d<T & IncreasingY> => {\n invariant(isIncreasingY(p), 'cubic path is not increasing in y')\n return p\n}\n\n/** @internal */\nexport const asDecreasingY = <T>(p: CubicPath2d<T>): CubicPath2d<T & DecreasingY> => {\n invariant(isDecreasingY(p), 'cubic path is not decreasing in y')\n return p\n}\n\n/** @internal */\nexport const asMonotonicY = <T>(p: CubicPath2d<T>): CubicPath2d<T & MonotonicY> => {\n invariant(isMonotonicY(p), 'cubic path is not monotonic in y')\n return p\n}\n\n/** @internal */\nexport const solveAtX = methods.solveAtX as never\n\n/** @internal */\nexport const solveAtY = methods.solveAtY as never\n\n/** @internal */\nexport const boundingBox = methods.boundingBox as (p: CubicPath2d) => Interval2d<Closed, Closed>\n\n/** @internal */\nexport const transform = methods.transform as never\n\n// Cubic-specific arc-length sampling. Cached by path identity since paths are\n// immutable. Lives here rather than in the generic Path2d because the inner\n// Newton iteration uses the cubic-curve derivative directly.\n\n// Cumulative segment lengths cache. lengths[k] = total length through segment k.\nconst cumulativeLengthCache = new WeakMap<CubicPath2d, ReadonlyArray<number>>()\n\nconst getCumulativeLengths = (p: CubicPath2d): ReadonlyArray<number> => {\n let cached = cumulativeLengthCache.get(p)\n if (cached === undefined) {\n const lengths: Array<number> = []\n let total = 0\n for (const curve of p) {\n total += CubicCurve2d.length(curve, Interval.unit)\n lengths.push(total)\n }\n cached = lengths\n cumulativeLengthCache.set(p, cached)\n }\n return cached\n}\n\n// Newton's method to find the local parameter t ∈ [0, 1] within `curve` such\n// that the arc length from 0 to t equals `target`. Each iteration costs one\n// GL32 quadrature plus one velocity eval; converges in 3–5 iterations for\n// well-behaved curves. Falls back to bisection on cusps where speed → 0.\nconst solveCurveByDistance = (\n curve: CubicCurve2d.CubicCurve2d,\n target: number,\n segmentLength: number,\n): number => {\n if (target <= 0) {\n return 0\n }\n if (target >= segmentLength) {\n return 1\n }\n\n const derivative = cubicCurveInternal.derivative(curve)\n\n let t = target / segmentLength\n let lo = 0\n let hi = 1\n\n for (let iter = 0; iter < 16; iter++) {\n const currentLength = CubicCurve2d.length(curve, Interval.make(0, t))\n const error = currentLength - target\n\n // Converged when the remaining arc-length error reaches the noise floor\n // relative to the segment. An absolute criterion demands unreachable\n // precision on long segments (burning every iteration) and stops a step\n // early on short ones.\n if (Math.abs(error) <= RELATIVE_TOLERANCE * segmentLength) {\n return t\n }\n\n if (error > 0) {\n hi = t\n } else {\n lo = t\n }\n\n const speed = Vector2.magnitude(QuadraticCurve2d.solve(derivative, t))\n if (speed === 0) {\n // cusp — bisect instead\n t = (lo + hi) / 2\n continue\n }\n\n const next = t - error / speed\n // bracket-clamp Newton step; if it leaves the bracket, fall back to bisection\n t = next > lo && next < hi ? next : (lo + hi) / 2\n }\n\n return t\n}\n\n/** @internal */\nexport const solveByDistance = dual<\n (s: number) => (p: CubicPath2d) => Vector2.Vector2,\n (p: CubicPath2d, s: number) => Vector2.Vector2\n>(2, (p: CubicPath2d, s: number) => {\n if (s <= 0) {\n return methods.solve(p, 0)\n }\n if (s >= 1) {\n return methods.solve(p, 1)\n }\n\n const lengths = getCumulativeLengths(p)\n const total = lengths[lengths.length - 1] as number\n const target = s * total\n\n // find segment k such that lengths[k-1] ≤ target ≤ lengths[k]\n let k = 0\n while (k < lengths.length - 1 && (lengths[k] as number) < target) {\n k++\n }\n\n const segmentStart = k === 0 ? 0 : (lengths[k - 1] as number)\n const segmentEnd = lengths[k] as number\n const segmentLength = segmentEnd - segmentStart\n const segmentTarget = target - segmentStart\n\n const curves =\n p instanceof Path2d.Path2dImpl ? (p.curves as ReadonlyArray<CubicCurve2d.CubicCurve2d>) : [...p]\n const curve = curves[k] as CubicCurve2d.CubicCurve2d\n const localT = solveCurveByDistance(curve, segmentTarget, segmentLength)\n\n return CubicCurve2d.solve(curve, localT)\n})\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { CubicCurve2d } from '../curve/cubic2d.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Affine2d } from '../transform/affine2d.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { CubicPath2dTypeId } from './cubic2d.internal.ts'\nimport * as internal from './cubic2d.internal.ts'\nimport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n PathTraits,\n} from './traits.ts'\n\nexport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n} from './traits.ts'\n\n/**\n * A cubic path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`.\n *\n * @since 1.0.0\n */\nexport interface CubicPath2d<out Trait = unknown> extends Pipeable, Iterable<CubicCurve2d> {\n readonly [CubicPath2dTypeId]: CubicPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `CubicPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `CubicPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<CubicCurve2d>) => CubicPath2d = internal.make\n\n/**\n * Creates a new `CubicPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `CubicPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<CubicCurve2d>) => CubicPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `CubicPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `CubicPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicPath2d: (p: unknown) => p is CubicPath2d = internal.isCubicPath2d\n\nexport const append: {\n /**\n * Appends a cubic curve to a cubic path.\n *\n * @param c - The cubic curve to append.\n * @returns A function that takes a cubic path and returns a new cubic path.\n * @since 1.0.0\n */\n (c: CubicCurve2d): (p: CubicPath2d) => CubicPath2d\n /**\n * Appends a cubic curve to a cubic path.\n *\n * @param p - The cubic path to append to.\n * @param c - The cubic curve to append.\n * @returns A new cubic path.\n * @since 1.0.0\n */\n (p: CubicPath2d, c: CubicCurve2d): CubicPath2d\n} = internal.append\n\n/**\n * Calculates the length of a cubic path.\n *\n * @param p - The cubic path to calculate the length of.\n * @returns The length of the cubic path.\n * @since 1.0.0\n */\nexport const length: (p: CubicPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a cubic path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a cubic path and returns the solved vector.\n * @since 1.0.0\n */\n (u: number): (p: CubicPath2d) => Vector2\n /**\n * Solves a cubic path for a given parameter.\n *\n * @param p - The cubic path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved vector.\n * @since 1.0.0\n */\n (p: CubicPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a cubic path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `C` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The cubic path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: CubicPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & Continuous>` when adjacent curves connect.\n *\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the cubic path is continuous, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: CubicPath2d<T>) => CubicPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & IncreasingX>` when every segment's x-polynomial is\n * strictly increasing on `[0, 1]` and adjacent segments' x-ranges don't\n * overlap.\n *\n * @since 2.0.0\n */\nexport const isIncreasingX: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & IncreasingX> =\n internal.isIncreasingX\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & DecreasingX>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasingX: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & DecreasingX> =\n internal.isDecreasingX\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & MonotonicX>`.\n *\n * @since 2.0.0\n */\nexport const isMonotonicX: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & MonotonicX> =\n internal.isMonotonicX\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & IncreasingY>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasingY: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & IncreasingY> =\n internal.isIncreasingY\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & DecreasingY>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasingY: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & DecreasingY> =\n internal.isDecreasingY\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & MonotonicY>`.\n *\n * @since 2.0.0\n */\nexport const isMonotonicY: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & MonotonicY> =\n internal.isMonotonicY\n\n/**\n * Asserts that the path is strictly increasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingX: <T>(p: CubicPath2d<T>) => CubicPath2d<T & IncreasingX> =\n internal.asIncreasingX\n\n/**\n * Asserts that the path is strictly decreasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingX: <T>(p: CubicPath2d<T>) => CubicPath2d<T & DecreasingX> =\n internal.asDecreasingX\n\n/**\n * Asserts that the path is monotonic in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicX: <T>(p: CubicPath2d<T>) => CubicPath2d<T & MonotonicX> =\n internal.asMonotonicX\n\n/**\n * Asserts that the path is strictly increasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingY: <T>(p: CubicPath2d<T>) => CubicPath2d<T & IncreasingY> =\n internal.asIncreasingY\n\n/**\n * Asserts that the path is strictly decreasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingY: <T>(p: CubicPath2d<T>) => CubicPath2d<T & DecreasingY> =\n internal.asDecreasingY\n\n/**\n * Asserts that the path is monotonic in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicY: <T>(p: CubicPath2d<T>) => CubicPath2d<T & MonotonicY> =\n internal.asMonotonicY\n\nexport const solveAtX: {\n /**\n * Evaluates the path's y value at a given x. Requires the path to carry\n * the `MonotonicX` brand. Returns `Solution.none` when x is outside the\n * path's x-range.\n *\n * @param p - A path branded `MonotonicX`.\n * @param x - The x coordinate.\n * @returns The y value at x, or `none` when x is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicX>(p: CubicPath2d<T>, x: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (x: number): <T extends MonotonicX>(p: CubicPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the path's x value at a given y. Requires the path to carry\n * the `MonotonicY` brand. Returns `Solution.none` when y is outside the\n * path's y-range.\n *\n * @param p - A path branded `MonotonicY`.\n * @param y - The y coordinate.\n * @returns The x value at y, or `none` when y is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicY>(p: CubicPath2d<T>, y: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (y: number): <T extends MonotonicY>(p: CubicPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtY as never\n\nexport const solveByDistance: {\n /**\n * Solves a cubic path by normalized arc length. Unlike {@link solve}, which\n * is parameterized by curve `u`, this samples points at constant speed along\n * the path — `s = 0.5` returns the point exactly halfway along the curve by\n * arc length, regardless of how the underlying parameterization stretches.\n *\n * Cumulative segment lengths are cached by path identity so repeated calls\n * with the same path are fast.\n *\n * @param p - The cubic path to sample.\n * @param s - Normalized arc length in `[0, 1]`. Values outside the range are\n * clamped to path endpoints.\n * @returns The point on the path at the given normalized arc length.\n * @since 1.1.0\n */\n (p: CubicPath2d, s: number): Vector2\n /**\n * Solves a cubic path by normalized arc length.\n *\n * @param s - Normalized arc length in `[0, 1]`.\n * @returns A function that takes a cubic path and returns the point at that\n * arc length.\n * @since 1.1.0\n */\n (s: number): (p: CubicPath2d) => Vector2\n} = internal.solveByDistance\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The cubic path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.0.0\n */\nexport const boundingBox: (p: CubicPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n\nexport const transform: {\n /**\n * Applies an `Affine2d` transform to every curve in a `CubicPath2d`,\n * returning a new path whose image is the affine image of the original.\n * Trait brands are dropped.\n *\n * @param p - The cubic path.\n * @param a - The affine transform.\n * @returns A new unbranded `CubicPath2d` whose curves are the affine images of the input's.\n * @since 2.0.0\n */\n (p: CubicPath2d, a: Affine2d): CubicPath2d\n /**\n * Applies an `Affine2d` transform to every curve in a `CubicPath2d`.\n *\n * @param a - The affine transform.\n * @returns A function that takes a `CubicPath2d` and returns the transformed path.\n * @since 2.0.0\n */\n (a: Affine2d): (p: CubicPath2d) => CubicPath2d\n} = internal.transform\n","import type * as CubicCurve2d from '../curve/cubic2d.ts'\nimport * as RationalCubicCurve2d from '../curve/rationalCubic2d.ts'\nimport type * as Interval from '../interval/interval.ts'\nimport * as Interval2d from '../interval/interval2d.ts'\nimport type * as Affine2d from '../transform/affine2d.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport type * as Vector2 from '../vector/vector2.ts'\nimport * as CubicPath2d from './cubic2d.ts'\nimport type { RationalCubicPath2d } from './rationalCubic2d.ts'\n\nexport const RationalCubicPath2dTypeId: unique symbol = Symbol('curvy/path/rationalCubic2d')\nexport type RationalCubicPath2dTypeId = typeof RationalCubicPath2dTypeId\n\n/** @internal */\nexport class RationalCubicPath2dImpl extends Pipeable implements RationalCubicPath2d {\n readonly [RationalCubicPath2dTypeId]: RationalCubicPath2dTypeId = RationalCubicPath2dTypeId\n\n readonly curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>\n\n constructor(curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>) {\n invariant(curves.length > 0, 'rational cubic path requires at least one curve')\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<RationalCubicCurve2d.RationalCubicCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const isRationalCubicPath2d = (p: unknown): p is RationalCubicPath2d =>\n typeof p === 'object' && p !== null && RationalCubicPath2dTypeId in p\n\n/** @internal */\nexport const make = (\n ...curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>\n): RationalCubicPath2d => new RationalCubicPath2dImpl(curves)\n\n/** @internal */\nexport const fromArray = (\n curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>,\n): RationalCubicPath2d => new RationalCubicPath2dImpl(curves)\n\n/** @internal */\nexport const append = dual<\n (c: RationalCubicCurve2d.RationalCubicCurve2d) => (p: RationalCubicPath2d) => RationalCubicPath2d,\n (p: RationalCubicPath2d, c: RationalCubicCurve2d.RationalCubicCurve2d) => RationalCubicPath2d\n>(2, (p, c) => fromArray([...p, c]))\n\n/** @internal */\nexport const solve = dual<\n (u: number) => (p: RationalCubicPath2d) => Vector2.Vector2,\n (p: RationalCubicPath2d, u: number) => Vector2.Vector2\n>(2, (p: RationalCubicPath2d, u: number) => {\n const curves = p instanceof RationalCubicPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as RationalCubicCurve2d.RationalCubicCurve2d\n return RationalCubicCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as RationalCubicCurve2d.RationalCubicCurve2d\n return RationalCubicCurve2d.solve(curve, t - i)\n})\n\n// Path-level bounding box: per-segment box is delegated to the curve module\n// (subdivision + hull union, tight to within `tolerance` per side); the path\n// box is then their union. Since each segment box's slack is ≤ tolerance per\n// side, the unioned box's slack is also ≤ tolerance per side — the same\n// guarantee holds at the path level.\n/** @internal */\nexport const boundingBox = dual<\n (\n tolerance: number,\n ) => (p: RationalCubicPath2d) => Interval2d.Interval2d<Interval.Closed, Interval.Closed>,\n (\n p: RationalCubicPath2d,\n tolerance: number,\n ) => Interval2d.Interval2d<Interval.Closed, Interval.Closed>\n>(2, (p: RationalCubicPath2d, tolerance: number) => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n let acc = RationalCubicCurve2d.boundingBox(\n first.value as RationalCubicCurve2d.RationalCubicCurve2d,\n tolerance,\n )\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, RationalCubicCurve2d.boundingBox(next.value, tolerance))\n }\n return acc\n})\n\n// Path-level approximation: per-segment approximation is delegated to the\n// curve module; we just concat the results. Segment count grows from N\n// (input) to roughly N × k where k depends on weight magnitude and tolerance —\n// uniform-weight segments stay 1:1.\n/** @internal */\nexport const approximateAsCubicPath = dual<\n (tolerance: number) => (p: RationalCubicPath2d) => CubicPath2d.CubicPath2d,\n (p: RationalCubicPath2d, tolerance: number) => CubicPath2d.CubicPath2d\n>(2, (p: RationalCubicPath2d, tolerance: number) => {\n const curves: Array<CubicCurve2d.CubicCurve2d> = []\n for (const segment of p) {\n for (const approx of RationalCubicCurve2d.approximateAsCubicCurves(segment, tolerance)) {\n curves.push(approx)\n }\n }\n return CubicPath2d.fromArray(curves)\n})\n\n/** @internal */\nexport const transform = dual<\n (a: Affine2d.Affine2d) => (p: RationalCubicPath2d) => RationalCubicPath2d,\n (p: RationalCubicPath2d, a: Affine2d.Affine2d) => RationalCubicPath2d\n>(2, (p: RationalCubicPath2d, a: Affine2d.Affine2d) => {\n const curves: Array<RationalCubicCurve2d.RationalCubicCurve2d> = []\n for (const segment of p) {\n curves.push(RationalCubicCurve2d.transform(segment, a))\n }\n return fromArray(curves)\n})\n","import type { RationalCubicCurve2d } from '../curve/rationalCubic2d.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type { Interval2d } from '../interval/interval2d.ts'\nimport type { Affine2d } from '../transform/affine2d.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { CubicPath2d } from './cubic2d.ts'\nimport type { RationalCubicPath2dTypeId } from './rationalCubic2d.internal.ts'\nimport * as internal from './rationalCubic2d.internal.ts'\n\n/**\n * A rational cubic path in 2D space.\n *\n * Holds a non-empty sequence of `RationalCubicCurve2d` segments; iteration\n * yields the segments in order. The path parameter `u ∈ [0, 1]` is mapped\n * uniformly across segments — `u = 0` is the start of the first segment,\n * `u = 1` is the end of the last segment, and intermediate values pick a\n * segment by index and a local parameter within it.\n *\n * Counterpart to `CubicPath2d` for curves whose evaluation includes the\n * homogeneous-to-plane projection.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 2.0.0\n */\nexport interface RationalCubicPath2d extends Pipeable, Iterable<RationalCubicCurve2d> {\n readonly [RationalCubicPath2dTypeId]: RationalCubicPath2dTypeId\n}\n\n/**\n * Checks if a value is a `RationalCubicPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `RationalCubicPath2d`, `false` otherwise.\n * @since 2.0.0\n */\nexport const isRationalCubicPath2d: (p: unknown) => p is RationalCubicPath2d =\n internal.isRationalCubicPath2d\n\n/**\n * Creates a new `RationalCubicPath2d` from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `RationalCubicPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<RationalCubicCurve2d>) => RationalCubicPath2d =\n internal.make\n\n/**\n * Creates a new `RationalCubicPath2d` from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `RationalCubicPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<RationalCubicCurve2d>) => RationalCubicPath2d =\n internal.fromArray\n\nexport const append: {\n /**\n * Appends a curve to a `RationalCubicPath2d`.\n *\n * @param c - The curve to append.\n * @returns A function that takes a path and returns a new path with the appended curve.\n * @since 2.0.0\n */\n (c: RationalCubicCurve2d): (p: RationalCubicPath2d) => RationalCubicPath2d\n /**\n * Appends a curve to a `RationalCubicPath2d`.\n *\n * @param p - The path to append to.\n * @param c - The curve to append.\n * @returns A new path with the appended curve.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, c: RationalCubicCurve2d): RationalCubicPath2d\n} = internal.append\n\nexport const solve: {\n /**\n * Evaluates the rational cubic path at parameter `u ∈ [0, 1]`.\n *\n * Picks the segment containing `u` (uniform mapping across segments) and\n * delegates to `RationalCubicCurve2d.solve` on that segment with the local\n * parameter.\n *\n * @param p - The path to evaluate.\n * @param u - The path parameter in `[0, 1]`.\n * @returns The point on the path at parameter `u`.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, u: number): Vector2\n /**\n * Evaluates the rational cubic path at parameter `u ∈ [0, 1]`.\n *\n * @param u - The path parameter in `[0, 1]`.\n * @returns A function that takes a path and returns the point at `u`.\n * @since 2.0.0\n */\n (u: number): (p: RationalCubicPath2d) => Vector2\n} = internal.solve\n\nexport const boundingBox: {\n /**\n * Computes a closed axis-aligned bounding box for a rational cubic path,\n * tight to within `tolerance` per side.\n *\n * Per-segment delegates to `RationalCubicCurve2d.boundingBox(c, tolerance)`\n * — recursive subdivision producing a hull-AABB union tight to within\n * `tolerance` per side. The path box is the union of segment boxes; since\n * each segment box has slack ≤ tolerance per side, so does the union.\n *\n * @param p - The rational cubic path.\n * @param tolerance - Maximum allowed slack per side; must be positive.\n * @returns A closed `Interval2d` enclosing the path, tight to within `tolerance`.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, tolerance: number): Interval2d<Closed, Closed>\n /**\n * Computes a closed axis-aligned bounding box for a rational cubic path.\n *\n * @param tolerance - Maximum allowed slack per side; must be positive.\n * @returns A function that takes a path and returns its bounding box.\n * @since 2.0.0\n */\n (tolerance: number): (p: RationalCubicPath2d) => Interval2d<Closed, Closed>\n} = internal.boundingBox\n\nexport const approximateAsCubicPath: {\n /**\n * Approximates the rational cubic path as a `CubicPath2d` via per-segment\n * recursive subdivision. Each input segment is split until its midpoint\n * deviates from a polynomial-cubic candidate by at most `tolerance`; the\n * surviving candidates are concatenated into a new path.\n *\n * Lossy in general — only exact when every input segment has uniform\n * weights, in which case segment count is preserved. Tighter tolerance\n * produces more segments.\n *\n * @param p - The rational cubic path to approximate.\n * @param tolerance - Maximum allowed midpoint deviation per segment; must be positive.\n * @returns A new `CubicPath2d` approximating the input.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, tolerance: number): CubicPath2d\n /**\n * Approximates the rational cubic path as a `CubicPath2d`.\n *\n * @param tolerance - Maximum allowed midpoint deviation per segment; must be positive.\n * @returns A function that takes a rational path and returns its approximation.\n * @since 2.0.0\n */\n (tolerance: number): (p: RationalCubicPath2d) => CubicPath2d\n} = internal.approximateAsCubicPath\n\nexport const transform: {\n /**\n * Applies an `Affine2d` transform to every curve in a `RationalCubicPath2d`,\n * returning a new path whose image is the affine image of the original.\n *\n * @param p - The rational cubic path.\n * @param a - The affine transform.\n * @returns A new `RationalCubicPath2d` whose curves are the affine images of the input's.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, a: Affine2d): RationalCubicPath2d\n /**\n * Applies an `Affine2d` transform to every curve in a `RationalCubicPath2d`.\n *\n * @param a - The affine transform.\n * @returns A function that takes a `RationalCubicPath2d` and returns the transformed path.\n * @since 2.0.0\n */\n (a: Affine2d): (p: RationalCubicPath2d) => RationalCubicPath2d\n} = internal.transform\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,IAAa,aAAb,cAAmC,SAAuC;CAExE;CAEA,YAAY,QAAgB,QAA0B;EACpD,OAAO;EACN,KAA4C,UAAU;EACvD,KAAK,SAAS;;CAGhB,CAAC,OAAO,YAAyB;EAC/B,OAAO,KAAK,OAAO,OAAO,WAAW;;;;;;;;;;;;;;AAezC,MAAa,eAAkB,QAAgB,QAAuB;CACpE,MAAM,aAAa,WAAwC,IAAI,WAAW,QAAQ,OAAO;CAEzF,MAAM,QAAQ,GAAG,WAAwC,UAAU,OAAO;CAE1E,MAAM,SAAS,KACb,IACC,GAAc,MAAS,UAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAC7C;CAED,MAAM,UAAU,MAAyB;EACvC,IAAI,QAAQ;EACZ,KAAK,MAAM,SAAS,GAClB,SAAS,IAAI,OAAO,OAAOA,KAAc;EAE3C,OAAO;;CAGT,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