curvy 2.0.0-alpha.11 → 2.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/characteristic/index.mjs +1 -1
  2. package/dist/curve/index.mjs +1 -1
  3. package/dist/curve/rationalCubic2d.d.ts +195 -11
  4. package/dist/interval/index.mjs +1 -1
  5. package/dist/monotonicity/index.d.ts +4 -0
  6. package/dist/monotonicity/index.mjs +2 -0
  7. package/dist/monotonicity/monotonicity.d.ts +80 -0
  8. package/dist/path/index.mjs +16 -387
  9. package/dist/path/index.mjs.map +1 -1
  10. package/dist/path/rationalCubic2d.d.ts +27 -0
  11. package/dist/polynomial/cubic.d.ts +2 -2
  12. package/dist/polynomial/index.mjs +2 -2
  13. package/dist/polynomial/linear.d.ts +7 -7
  14. package/dist/polynomial/quadratic.d.ts +2 -2
  15. package/dist/shared/{characteristic-Hb7F8SBw.mjs → characteristic-BkEr-rr8.mjs} +2 -2
  16. package/dist/shared/{characteristic-Hb7F8SBw.mjs.map → characteristic-BkEr-rr8.mjs.map} +1 -1
  17. package/dist/shared/{cubic-DHJrzZJN.mjs → cubic-BL6dpuHh.mjs} +18 -30
  18. package/dist/shared/cubic-BL6dpuHh.mjs.map +1 -0
  19. package/dist/shared/{interval2d-DPmvk_Qe.mjs → interval2d-AtneyI45.mjs} +1 -1
  20. package/dist/shared/{interval2d-DPmvk_Qe.mjs.map → interval2d-AtneyI45.mjs.map} +1 -1
  21. package/dist/shared/monotonicity-BdebFOtv.mjs +34 -0
  22. package/dist/shared/monotonicity-BdebFOtv.mjs.map +1 -0
  23. package/dist/shared/{quadratic-BZmfZE71.mjs → quadratic-DPrUsFCp.mjs} +9 -9
  24. package/dist/shared/quadratic-DPrUsFCp.mjs.map +1 -0
  25. package/dist/shared/{rationalCubic2d-IroMR6AA.mjs → rationalCubic2d-CeHgpNht.mjs} +373 -79
  26. package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +1 -0
  27. package/dist/shared/{rationalCubic2d-nN-oSrLr.mjs → rationalCubic2d-H1J2Fjyy.mjs} +404 -23
  28. package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +1 -0
  29. package/dist/shared/{solution-B6KY1E7M.mjs → solution-B2JdOZpe.mjs} +1 -1
  30. package/dist/shared/{solution-B6KY1E7M.mjs.map → solution-B2JdOZpe.mjs.map} +1 -1
  31. package/dist/solution/index.mjs +1 -1
  32. package/dist/splines/index.d.ts +3 -0
  33. package/dist/splines/index.mjs +218 -120
  34. package/dist/splines/index.mjs.map +1 -1
  35. package/dist/splines/linear2d.d.ts +102 -0
  36. package/dist/splines/linear2d.internal.d.ts +2 -0
  37. package/package.json +5 -1
  38. package/dist/polynomial/monotonicity.d.ts +0 -3
  39. package/dist/shared/cubic-DHJrzZJN.mjs.map +0 -1
  40. package/dist/shared/quadratic-BZmfZE71.mjs.map +0 -1
  41. package/dist/shared/rationalCubic2d-IroMR6AA.mjs.map +0 -1
  42. package/dist/shared/rationalCubic2d-nN-oSrLr.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rationalCubic2d-H1J2Fjyy.mjs","names":["isLinearPath2d","make","fromArray","append","length","LinearCurve2d.length","Interval.unit","solve","LinearCurve2d.solve","toPathData","isContinuous","asContinuous","isIncreasingX","LinearPolynomial.isIncreasing","isDecreasingX","LinearPolynomial.isDecreasing","isMonotonicX","isIncreasingY","isDecreasingY","isMonotonicY","asIncreasingX","asDecreasingX","asMonotonicX","asIncreasingY","asDecreasingY","asMonotonicY","solveAtX","Solution.one","LinearCurve2d.solveAtX","Solution.isNone","Solution.none","solveAtY","LinearCurve2d.solveAtY","boundingBox","LinearCurve2d.boundingBox","Interval2d.union","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","isCubicPath2d","make","fromArray","append","length","CubicCurve2d.length","Interval.unit","solve","CubicCurve2d.solve","derivative","cubicCurveInternal.derivative","Interval.make","Vector2.magnitude","QuadraticCurve2d.solve","toPathData","isContinuous","asContinuous","isIncreasingX","CubicPolynomial.isIncreasing","isDecreasingX","CubicPolynomial.isDecreasing","isMonotonicX","isIncreasingY","isDecreasingY","isMonotonicY","asIncreasingX","asDecreasingX","asMonotonicX","asIncreasingY","asDecreasingY","asMonotonicY","solveAtX","Solution.one","CubicCurve2d.solveAtX","Solution.isNone","Solution.none","solveAtY","CubicCurve2d.solveAtY","solveByDistance","boundingBox","CubicCurve2d.boundingBox","Interval2d.union","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","isRationalCubicPath2d","make","fromArray","append","solve","RationalCubicCurve2d.solve","boundingBox","RationalCubicCurve2d.boundingBox","Interval2d.union","approximateAsCubicPath","RationalCubicCurve2d.approximateAsCubicCurves","CubicPath2d.fromArray","internal.isRationalCubicPath2d","internal.make","internal.fromArray","internal.append","internal.solve","internal.boundingBox","internal.approximateAsCubicPath"],"sources":["../../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 * as Interval2d from '../interval/interval2d.ts'\nimport * as LinearCurve2d from '../curve/linear2d.ts'\nimport * as Interval from '../interval/interval.ts'\nimport * as LinearPolynomial from '../polynomial/linear.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { EPSILON, epsEquals } from '../number.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPath2d } from './linear2d.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\nexport const LinearPath2dTypeId: unique symbol = Symbol('curvy/path/linear2d')\nexport type LinearPath2dTypeId = typeof LinearPath2dTypeId\n\n/** @internal */\nexport class LinearPath2dImpl extends Pipeable implements LinearPath2d<unknown> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId = LinearPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>\n\n constructor(curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<LinearCurve2d.LinearCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\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 = (...curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>): LinearPath2d =>\n new LinearPath2dImpl(curves)\n\n/** @internal */\nexport const fromArray = (curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) =>\n new LinearPath2dImpl(curves)\n\n/** @internal */\nexport const append = dual<\n (c: LinearCurve2d.LinearCurve2d) => (p: LinearPath2d) => LinearPath2d,\n (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => LinearPath2d\n>(2, (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => fromArray([...p, c]))\n\n/** @internal */\nexport const length = (p: LinearPath2d) => {\n let total = 0\n for (const curve of p) {\n total += LinearCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\n/** @internal */\nexport const solve = dual<\n (u: number) => (p: LinearPath2d) => Vector2,\n (p: LinearPath2d, u: number) => Vector2\n>(2, (p: LinearPath2d, u: number) => {\n const curves = p instanceof LinearPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(curve, t - i)\n})\n\n/** @internal */\nexport const toPathData = (p: LinearPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n const endX = curve.x.c0 + curve.x.c1\n const endY = curve.y.c0 + curve.y.c1\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` L ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\n/** @internal */\nexport const isContinuous = <T>(p: LinearPath2d<T>): p is LinearPath2d<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 startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1\n prevEndY = curve.y.c0 + curve.y.c1\n first = false\n }\n return true\n}\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// Per-axis monotonicity refiners. A path is monotonic-on-an-axis when every\n// segment's per-axis polynomial is strictly monotonic in the same direction\n// AND adjacent segments' ranges on that axis don't overlap (modulo float\n// tolerance) — so the path's u → axis mapping is monotonic across joins.\n\n/** @internal */\nexport const isIncreasingX = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & IncreasingX> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isIncreasing(c.x)) {\n return false\n }\n if (c.x.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingX = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & DecreasingX> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isDecreasing(c.x)) {\n return false\n }\n if (c.x.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicX = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & MonotonicX> =>\n isIncreasingX(p) || isDecreasingX(p)\n\n/** @internal */\nexport const isIncreasingY = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & IncreasingY> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isIncreasing(c.y)) {\n return false\n }\n if (c.y.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingY = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & DecreasingY> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isDecreasing(c.y)) {\n return false\n }\n if (c.y.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicY = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & MonotonicY> =>\n isIncreasingY(p) || isDecreasingY(p)\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// solveAtX/solveAtY for `Monotonic{X,Y}` paths. Two defenses against float\n// drift at interior knots (where adjacent segments both bracket the query):\n// 1. Snap to t=0/t=1 endpoint y when the query is within EPSILON of a\n// segment's start or end.\n// 2. Fall through to the next bracketing segment on `none`. Linear paths\n// don't currently surface drift (degree-1 `c0 + c1 = x` is stable), but\n// the same shape applies for symmetry with quadratic / cubic.\n/** @internal */\nexport const solveAtX = dual(2, (p: LinearPath2d, x: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sx = c.x.c0\n const ex = c.x.c0 + c.x.c1\n const lo = Math.min(sx, ex)\n const hi = Math.max(sx, ex)\n if (x >= lo - EPSILON && x <= hi + EPSILON) {\n if (epsEquals(x, sx)) {\n return Solution.one(c.y.c0)\n }\n if (epsEquals(x, ex)) {\n return Solution.one(c.y.c0 + c.y.c1)\n }\n const sol = LinearCurve2d.solveAtX(c, x)\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const solveAtY = dual(2, (p: LinearPath2d, y: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sy = c.y.c0\n const ey = c.y.c0 + c.y.c1\n const lo = Math.min(sy, ey)\n const hi = Math.max(sy, ey)\n if (y >= lo - EPSILON && y <= hi + EPSILON) {\n if (epsEquals(y, sy)) {\n return Solution.one(c.x.c0)\n }\n if (epsEquals(y, ey)) {\n return Solution.one(c.x.c0 + c.x.c1)\n }\n const sol = LinearCurve2d.solveAtY(c, y)\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const boundingBox = (\n p: LinearPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n // path invariant: at least one curve, so first.value is defined\n let acc = LinearCurve2d.boundingBox(first.value as LinearCurve2d.LinearCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, LinearCurve2d.boundingBox(next.value))\n }\n return acc\n}\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 { 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","import * as Interval2d from '../interval/interval2d.ts'\nimport * 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 * as CubicPolynomial from '../polynomial/cubic.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { EPSILON, epsEquals } from '../number.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport type { CubicPath2d } from './cubic2d.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\nexport const CubicPath2dTypeId: unique symbol = Symbol('curvy/path/cubic2d')\nexport type CubicPath2dTypeId = typeof CubicPath2dTypeId\n\n/** @internal */\nexport class CubicPath2dImpl extends Pipeable implements CubicPath2d<unknown> {\n readonly [CubicPath2dTypeId]: CubicPath2dTypeId = CubicPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>\n\n constructor(curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>) {\n invariant(curves.length > 0, 'cubic path requires at least one curve')\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<CubicCurve2d.CubicCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const isCubicPath2d = (p: unknown): p is CubicPath2d =>\n typeof p === 'object' && p !== null && CubicPath2dTypeId in p\n\n/** @internal */\nexport const make = (...curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>): CubicPath2d =>\n new CubicPath2dImpl(curves)\n\n/** @internal */\nexport const fromArray = (curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>): CubicPath2d =>\n new CubicPath2dImpl(curves)\n\n/** @internal */\nexport const append = dual<\n (c: CubicCurve2d.CubicCurve2d) => (p: CubicPath2d) => CubicPath2d,\n (p: CubicPath2d, c: CubicCurve2d.CubicCurve2d) => CubicPath2d\n>(2, (p: CubicPath2d, c: CubicCurve2d.CubicCurve2d) => fromArray([...p, c]))\n\n/** @internal */\nexport const length = (p: CubicPath2d) => {\n let total = 0\n for (const curve of p) {\n total += CubicCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\n/** @internal */\nexport const solve = dual<\n (u: number) => (p: CubicPath2d) => Vector2.Vector2,\n (p: CubicPath2d, u: number) => Vector2.Vector2\n>(2, (p: CubicPath2d, u: number) => {\n const curves = p instanceof CubicPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as CubicCurve2d.CubicCurve2d\n return CubicCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as CubicCurve2d.CubicCurve2d\n return CubicCurve2d.solve(curve, t - i)\n})\n\n// Cumulative segment lengths cache. lengths[k] = total length through segment k.\n// Cached by path identity since paths are immutable.\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 if (Math.abs(error) < 1e-10) {\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// Cubic Bernstein basis: P(t) = (1-t)³·p0 + 3(1-t)²t·p1 + 3(1-t)t²·p2 + t³·p3\n// expanded gives c0 = p0, c1 = -3p0 + 3p1, c2 = 3p0 - 6p1 + 3p2, c3 = -p0 + 3p1 - 3p2 + p3,\n// so: p0 = c0, p1 = c0 + c1/3, p2 = c0 + 2c1/3 + c2/3, p3 = c0 + c1 + c2 + c3.\n/** @internal */\nexport const toPathData = (p: CubicPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const c0x = curve.x.c0\n const c0y = curve.y.c0\n const c1x = curve.x.c1\n const c1y = curve.y.c1\n const c2x = curve.x.c2\n const c2y = curve.y.c2\n const c3x = curve.x.c3\n const c3y = curve.y.c3\n\n const startX = c0x\n const startY = c0y\n const ctrl1X = c0x + c1x / 3\n const ctrl1Y = c0y + c1y / 3\n const ctrl2X = c0x + (2 * c1x) / 3 + c2x / 3\n const ctrl2Y = c0y + (2 * c1y) / 3 + c2y / 3\n const endX = c0x + c1x + c2x + c3x\n const endY = c0y + c1y + c2y + c3y\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` C ${ctrl1X},${ctrl1Y} ${ctrl2X},${ctrl2Y} ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\n/** @internal */\nexport const isContinuous = <T>(p: CubicPath2d<T>): p is CubicPath2d<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 startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2 + curve.x.c3\n prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2 + curve.y.c3\n first = false\n }\n return true\n}\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// Per-axis monotonicity for the path: every segment's axis polynomial must be\n// strictly monotonic over the unit interval AND adjacent segments' axis\n// ranges must not overlap (modulo EPSILON for float drift).\n/** @internal */\nexport const isIncreasingX = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & IncreasingX> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isIncreasing(c.x, Interval.unit)) {\n return false\n }\n if (c.x.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingX = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & DecreasingX> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isDecreasing(c.x, Interval.unit)) {\n return false\n }\n if (c.x.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicX = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & MonotonicX> =>\n isIncreasingX(p) || isDecreasingX(p)\n\n/** @internal */\nexport const isIncreasingY = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & IncreasingY> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isIncreasing(c.y, Interval.unit)) {\n return false\n }\n if (c.y.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingY = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & DecreasingY> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isDecreasing(c.y, Interval.unit)) {\n return false\n }\n if (c.y.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicY = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & MonotonicY> =>\n isIncreasingY(p) || isDecreasingY(p)\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// At an interior knot, two adjacent segments both bracket the query — one's\n// right endpoint and the next's left endpoint are (within float drift) the\n// same value. The per-curve cubic-root solver can return `none` for both\n// brackets when the true root sits just outside [0, 1] due to that drift. We\n// handle this two ways:\n// 1. If the query is within EPSILON of a segment's start or end, evaluate y\n// directly at t=0 or t=1 — skips polynomial inversion entirely.\n// 2. Otherwise, if a bracketing segment returns `none`, fall through to the\n// next bracketing segment. `MonotonicX` admits at most one real solution\n// across the path, so retrying after `none` is safe.\n/** @internal */\nexport const solveAtX = dual(2, (p: CubicPath2d, x: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sx = c.x.c0\n const ex = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n const lo = Math.min(sx, ex)\n const hi = Math.max(sx, ex)\n if (x >= lo - EPSILON && x <= hi + EPSILON) {\n if (epsEquals(x, sx)) {\n return Solution.one(c.y.c0)\n }\n if (epsEquals(x, ex)) {\n return Solution.one(c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3)\n }\n const sol = CubicCurve2d.solveAtX(c, x) as Solution.AtMostOne<number>\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const solveAtY = dual(2, (p: CubicPath2d, y: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sy = c.y.c0\n const ey = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n const lo = Math.min(sy, ey)\n const hi = Math.max(sy, ey)\n if (y >= lo - EPSILON && y <= hi + EPSILON) {\n if (epsEquals(y, sy)) {\n return Solution.one(c.x.c0)\n }\n if (epsEquals(y, ey)) {\n return Solution.one(c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3)\n }\n const sol = CubicCurve2d.solveAtY(c, y) as Solution.AtMostOne<number>\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\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 solve(p, 0)\n }\n if (s >= 1) {\n return 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 = p instanceof CubicPath2dImpl ? p.curves : [...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\n/** @internal */\nexport const boundingBox = (\n p: CubicPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n let acc = CubicCurve2d.boundingBox(first.value as CubicCurve2d.CubicCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, CubicCurve2d.boundingBox(next.value))\n }\n return acc\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 { 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","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 { 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","import type { RationalCubicCurve2d } from '../curve/rationalCubic2d.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type { Interval2d } from '../interval/interval2d.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"],"mappings":";;;;;;;;;;;AAqBA,MAAa,qBAAoC,OAAO,sBAAsB;;AAI9E,IAAa,mBAAb,cAAsC,SAA0C;CAC9E,CAAU,sBAA0C;CAGpD;CAEA,YAAY,QAAoD;EAC9D,OAAO;EACP,KAAK,SAAS;;CAGhB,CAAC,OAAO,YAAmD;EACzD,OAAO,KAAK,OAAO,OAAO,WAAW;;;;AAKzC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,CAAC,CAAC;;AAGpC,MAAaE,UAAQ,KAGnB,IAAI,GAAwB,MAAc;CAC1C,MAAM,SAAS,aAAa,0BAA0B,EAAE,SAAS,CAAC,GAAG,EAAE;CAEvE,IAAI,MAAM,GAER,OAAOC,QADM,OAAO,GAAG,GACW,EAAM,EAAE;CAG5C,MAAM,IAAI,IAAI,OAAO;CACrB,MAAM,IAAI,KAAK,MAAM,EAAE;CACvB,MAAM,QAAQ,OAAO;CACrB,OAAOA,QAA2B,OAAO,IAAI,EAAE;EAC/C;;AAQF,MAAaC,gBAAc,KAQzB,IAAI,GAAwB,cAAsB;CAClD,MAAM,OAAO,EAAE,OAAO,WAAW;CAEjC,IAAI,MAAMC,cADI,KAAK,MAEjB,CAAM,OACN,UACD;CACD,KAAK,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC,KAAK,MAAM,OAAO,KAAK,MAAM,EACzD,MAAMC,MAAiB,KAAKD,cAAiC,KAAK,OAAO,UAAU,CAAC;CAEtF,OAAO;EACP;;AAOF,MAAaE,2BAAyB,KAGpC,IAAI,GAAwB,cAAsB;CAClD,MAAM,SAA2C,EAAE;CACnD,KAAK,MAAM,WAAW,GACpB,KAAK,MAAM,UAAUC,yBAA8C,SAAS,UAAU,EACpF,OAAO,KAAK,OAAO;CAGvB,OAAOC,YAAsB,OAAO;EACpC;;;;;;;;;;;;;;;;;;;AC3EF,MAAa,wBACXC;;;;;;;;AASF,MAAa,OACXC;;;;;;;;AASF,MAAa,YACXC;AAEF,MAAa,SAkBTC;AAEJ,MAAa,QAsBTC;AAEJ,MAAa,cAwBTC;AAEJ,MAAa,yBAyBTC"}
@@ -349,4 +349,4 @@ const match = match$1;
349
349
  //#endregion
350
350
  export { match as a, solution_exports as c, map as i, two as l, fromArray as n, none as o, isNone as r, one as s, clip as t };
351
351
 
352
- //# sourceMappingURL=solution-B6KY1E7M.mjs.map
352
+ //# sourceMappingURL=solution-B2JdOZpe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"solution-B6KY1E7M.mjs","names":["none","one","two","three","fromArray","isNone","isSome","valueOrUndefined","last","min","max","unsafeValue","unsafeLast","unsafeMin","unsafeMax","filter","clip","Interval.contains","map","match","internal.none","internal.one","internal.two","internal.three","internal.fromArray","internal.isNone","internal.isSome","internal.valueOrUndefined","internal.last","internal.min","internal.max","internal.unsafeValue","internal.unsafeLast","internal.unsafeMin","internal.unsafeMax","internal.filter","internal.clip","internal.map","internal.match"],"sources":["../../src/solution/solution.internal.ts","../../src/solution/solution.ts"],"sourcesContent":["import * as Interval from '../interval/interval.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport type {\n AtMostOne,\n AtMostThree,\n AtMostTwo,\n None,\n One,\n Solution,\n Some,\n Three,\n Two,\n} from './solution.ts'\nimport { invariant } from '../utils.ts'\n\n// Empty iterator — shared across all None instances since None has no data.\nconst EMPTY_ITERATOR: Iterator<never> = {\n next: () => ({ done: true, value: undefined as never }),\n}\n\nclass NoneImpl extends Pipeable implements None {\n readonly _tag = 'none' as const\n readonly length = 0 as const;\n\n [Symbol.iterator](): Iterator<never> {\n return EMPTY_ITERATOR\n }\n}\n\nclass OneImpl<T> extends Pipeable implements One<T> {\n readonly _tag = 'one' as const\n readonly length = 1 as const\n\n constructor(readonly value: T) {\n super()\n }\n\n [Symbol.iterator](): Iterator<T> {\n return [this.value][Symbol.iterator]()\n }\n}\n\nclass TwoImpl<T> extends Pipeable implements Two<T> {\n readonly _tag = 'two' as const\n readonly length = 2 as const\n\n constructor(readonly values: readonly [T, T]) {\n super()\n }\n\n get value(): T {\n return this.values[0]\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this.values[Symbol.iterator]()\n }\n}\n\nclass ThreeImpl<T> extends Pipeable implements Three<T> {\n readonly _tag = 'three' as const\n readonly length = 3 as const\n\n constructor(readonly values: readonly [T, T, T]) {\n super()\n }\n\n get value(): T {\n return this.values[0]\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this.values[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const NONE_INSTANCE: None = new NoneImpl()\n\n/** @internal */\nexport const none: None = NONE_INSTANCE\n\n/** @internal */\nexport const one = <T>(value: T): One<T> => new OneImpl(value)\n\n/** @internal */\nexport const two = <T>(a: T, b: T): Two<T> => new TwoImpl([a, b])\n\n/** @internal */\nexport const three = <T>(a: T, b: T, c: T): Three<T> => new ThreeImpl([a, b, c])\n\n/** @internal */\nexport const fromArray = <T>(arr: ReadonlyArray<T>): Solution<T> => {\n switch (arr.length) {\n case 0:\n return NONE_INSTANCE\n case 1:\n return one(arr[0] as T)\n case 2:\n return two(arr[0] as T, arr[1] as T)\n case 3:\n return three(arr[0] as T, arr[1] as T, arr[2] as T)\n default:\n invariant(false, `Solution can hold at most 3 values, got ${arr.length}`)\n }\n}\n\n/** @internal */\nexport const isNone = <T>(s: Solution<T>): s is None => s._tag === 'none'\n\n/** @internal */\nexport const isSome = <T>(s: Solution<T>): s is Some<T> => s._tag !== 'none'\n\n/** @internal */\nexport const valueOrUndefined = <T>(s: Solution<T>): T | undefined =>\n isNone(s) ? undefined : s.value\n\n/** @internal */\nexport const last: {\n <T>(s: Some<T>): T\n <T>(s: Solution<T>): T | undefined\n} = (<T>(s: Solution<T>): T | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return s.values[1]\n case 'three':\n return s.values[2]\n }\n}) as never\n\n/** @internal */\nexport const min: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = ((s: Solution<number>): number | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return Math.min(s.values[0], s.values[1])\n case 'three':\n return Math.min(s.values[0], s.values[1], s.values[2])\n }\n}) as never\n\n/** @internal */\nexport const max: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = ((s: Solution<number>): number | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return Math.max(s.values[0], s.values[1])\n case 'three':\n return Math.max(s.values[0], s.values[1], s.values[2])\n }\n}) as never\n\n/** @internal */\nexport const unsafeValue = <T>(s: Solution<T>, message?: string): T => {\n invariant(isSome(s), message ?? 'Solution.unsafeValue on empty Solution')\n return s.value\n}\n\n/** @internal */\nexport const unsafeLast = <T>(s: Solution<T>): T => {\n invariant(isSome(s), 'Solution.unsafeLast on empty Solution')\n return last(s)\n}\n\n/** @internal */\nexport const unsafeMin = (s: Solution<number>): number => {\n invariant(isSome(s), 'Solution.unsafeMin on empty Solution')\n return min(s)\n}\n\n/** @internal */\nexport const unsafeMax = (s: Solution<number>): number => {\n invariant(isSome(s), 'Solution.unsafeMax on empty Solution')\n return max(s)\n}\n\n/** @internal */\nexport const filter = <T>(s: Solution<T>, predicate: (v: T) => boolean): Solution<T> => {\n switch (s._tag) {\n case 'none':\n return s\n case 'one':\n return predicate(s.value) ? s : NONE_INSTANCE\n case 'two': {\n const a = predicate(s.values[0])\n const b = predicate(s.values[1])\n if (a && b) {\n return s\n }\n if (a) {\n return one(s.values[0])\n }\n if (b) {\n return one(s.values[1])\n }\n return NONE_INSTANCE\n }\n case 'three': {\n const survivors: Array<T> = []\n if (predicate(s.values[0])) {\n survivors.push(s.values[0])\n }\n if (predicate(s.values[1])) {\n survivors.push(s.values[1])\n }\n if (predicate(s.values[2])) {\n survivors.push(s.values[2])\n }\n return fromArray(survivors)\n }\n }\n}\n\n/** @internal */\nexport const clip = dual(\n 2,\n (s: Solution<number>, i: Interval.Interval): Solution<number> =>\n filter(s, (v) => Interval.contains(i, v)),\n)\n\n/** @internal */\nexport const map = dual(2, <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B> => {\n switch (s._tag) {\n case 'none':\n return s\n case 'one':\n return one(f(s.value))\n case 'two':\n return two(f(s.values[0]), f(s.values[1]))\n case 'three':\n return three(f(s.values[0]), f(s.values[1]), f(s.values[2]))\n }\n})\n\n/** @internal */\nexport const match = dual(\n 2,\n <T, A, B>(\n self: Solution<T>,\n matcher: { readonly onNone: () => A; readonly onSome: (s: Some<T>) => B },\n ): A | B => (isNone(self) ? matcher.onNone() : matcher.onSome(self)),\n)\n\n// Re-export type aliases that the namespace consumers expect to see at runtime.\n// (Pure type re-exports — no runtime cost.)\nexport type { AtMostOne, AtMostThree, AtMostTwo, None, One, Solution, Some, Three, Two }\n","import type { Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport * as internal from './solution.internal.ts'\n\n/**\n * A `Solution<T>` represents the result of an operation that may produce\n * between zero and three values of `T`. It generalizes the zoo of \"0 or 1\",\n * \"0 to 2\", \"0 to 3\" return shapes used throughout curvy under one type, and\n * provides a small namespace of operations (`value`, `last`, `min`, `max`,\n * `filter`, `map`, `match`, …) for working with the result.\n *\n * Each variant carries a `_tag` discriminator and a `length` field, is\n * iterable via `Symbol.iterator` (so existing `for..of` and spread patterns\n * keep working), and is `Pipeable` (so a `Solution` value can be the head of\n * a `pipe` chain).\n *\n * Variant-specific accessors:\n * - `One<T>`, `Two<T>`, and `Three<T>` all expose `.value: T` (the first /\n * primary value).\n * - `Two<T>` and `Three<T>` additionally expose `.values: readonly [T, ...]`\n * for explicit positional access.\n *\n * Operations that return narrower cardinalities (e.g. inverse-solving a\n * monotonic polynomial) use the `AtMost{One,Two,Three}` aliases to express\n * \"this could be empty, but it'll have at most N values.\"\n *\n * @since 2.0.0\n */\nexport type Solution<T> = None | One<T> | Two<T> | Three<T>\n\n/**\n * The empty solution.\n *\n * @since 2.0.0\n */\nexport interface None extends Pipeable, Iterable<never> {\n readonly _tag: 'none'\n readonly length: 0\n}\n\n/** @since 2.0.0 */\nexport interface One<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'one'\n readonly length: 1\n readonly value: T\n}\n\n/** @since 2.0.0 */\nexport interface Two<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'two'\n readonly length: 2\n readonly value: T\n readonly values: readonly [T, T]\n}\n\n/** @since 2.0.0 */\nexport interface Three<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'three'\n readonly length: 3\n readonly value: T\n readonly values: readonly [T, T, T]\n}\n\n/**\n * Any non-empty solution. All `Some<T>` values expose `.value: T` directly —\n * no narrowing required to read the primary value.\n *\n * @since 2.0.0\n */\nexport type Some<T> = One<T> | Two<T> | Three<T>\n\n/**\n * `None | One<T>` — return type of operations that produce at most one value\n * (e.g. inverse-solving a strictly monotonic polynomial).\n *\n * @since 2.0.0\n */\nexport type AtMostOne<T> = None | One<T>\n\n/**\n * `None | One<T> | Two<T>` — return type of operations that produce at most\n * two values (e.g. inverse-solving an unrestricted quadratic polynomial).\n *\n * @since 2.0.0\n */\nexport type AtMostTwo<T> = None | One<T> | Two<T>\n\n/**\n * `None | One<T> | Two<T> | Three<T>` — equivalent to `Solution<T>`.\n *\n * @since 2.0.0\n */\nexport type AtMostThree<T> = Solution<T>\n\n/**\n * The empty solution. Reused across calls — never reallocated.\n *\n * @since 2.0.0\n */\nexport const none: None = internal.none\n\n/**\n * Constructs a single-value solution.\n *\n * @since 2.0.0\n */\nexport const one: <T>(value: T) => One<T> = internal.one\n\n/**\n * Constructs a two-value solution.\n *\n * @since 2.0.0\n */\nexport const two: <T>(a: T, b: T) => Two<T> = internal.two\n\n/**\n * Constructs a three-value solution.\n *\n * @since 2.0.0\n */\nexport const three: <T>(a: T, b: T, c: T) => Three<T> = internal.three\n\n/**\n * Constructs a `Solution<T>` from a runtime array. Throws if the array has\n * more than three elements.\n *\n * @since 2.0.0\n */\nexport const fromArray: <T>(arr: ReadonlyArray<T>) => Solution<T> = internal.fromArray\n\n/**\n * Type-narrowing predicate: refines `Solution<T>` to `None`.\n *\n * @since 2.0.0\n */\nexport const isNone: <T>(s: Solution<T>) => s is None = internal.isNone\n\n/**\n * Type-narrowing predicate: refines `Solution<T>` to `Some<T>` (non-empty).\n * After narrowing, `.value` is directly accessible without further checks.\n *\n * @since 2.0.0\n */\nexport const isSome: <T>(s: Solution<T>) => s is Some<T> = internal.isSome\n\n/**\n * Returns the primary (first) value if the solution is non-empty, or\n * `undefined` if empty. Pair with `.value` access on `Some<T>`-narrowed\n * inputs to avoid the `undefined` possibility.\n *\n * @since 2.0.0\n */\nexport const valueOrUndefined: <T>(s: Solution<T>) => T | undefined = internal.valueOrUndefined\n\n/**\n * Returns the last value in the solution, or `undefined` if empty. When\n * called on a `Some<T>`, the result is guaranteed to be `T`.\n *\n * @since 2.0.0\n */\nexport const last: {\n <T>(s: Some<T>): T\n <T>(s: Solution<T>): T | undefined\n} = internal.last\n\n/**\n * Returns the smallest numeric value in the solution, or `undefined` if empty.\n * When called on a `Some<number>`, the result is guaranteed to be `number`.\n *\n * @since 2.0.0\n */\nexport const min: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = internal.min\n\n/**\n * Returns the largest numeric value in the solution, or `undefined` if empty.\n * When called on a `Some<number>`, the result is guaranteed to be `number`.\n *\n * @since 2.0.0\n */\nexport const max: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = internal.max\n\n/**\n * Returns the primary value of the solution (i.e. `s.value`). Throws on\n * `None`, optionally with a caller-provided message.\n *\n * Useful when the type system can't prove non-emptiness but you have a domain\n * reason to assert it — e.g. inverting a polynomial you know to be monotonic\n * without going through the trait refiner first:\n *\n * ```ts\n * const x = CubicPolynomial.solveInverse(p, y).pipe(\n * Solution.unsafeValue('expected a monotonic inverse'),\n * )\n * ```\n *\n * @since 2.0.0\n */\nexport const unsafeValue: {\n <T>(s: Solution<T>, message?: string): T\n (message: string): <T>(s: Solution<T>) => T\n} = ((...args: ReadonlyArray<unknown>) => {\n if (args.length >= 1 && typeof args[0] === 'object' && args[0] !== null) {\n return internal.unsafeValue(args[0] as Solution<unknown>, args[1] as string | undefined)\n }\n const message = args[0] as string\n return <T>(s: Solution<T>) => internal.unsafeValue(s, message)\n}) as never\n\n/**\n * Returns the last value in the solution. Throws if empty.\n *\n * @since 2.0.0\n */\nexport const unsafeLast: <T>(s: Solution<T>) => T = internal.unsafeLast\n\n/**\n * Returns the smallest numeric value in the solution. Throws on empty.\n *\n * @since 2.0.0\n */\nexport const unsafeMin: (s: Solution<number>) => number = internal.unsafeMin\n\n/**\n * Returns the largest numeric value in the solution. Throws on empty.\n *\n * @since 2.0.0\n */\nexport const unsafeMax: (s: Solution<number>) => number = internal.unsafeMax\n\n/**\n * Filters the solution by a predicate. Result cardinality is at most that of\n * the input.\n *\n * @since 2.0.0\n */\nexport const filter: <T>(s: Solution<T>, predicate: (v: T) => boolean) => Solution<T> =\n internal.filter\n\n/**\n * Restricts the solution to values contained within an interval. Endpoint\n * inclusivity follows the interval's `kind` — pass an open variant (e.g.\n * `Interval.makeOpen(0, 1)` or `Interval.unitOpen`) for strict containment.\n *\n * @param s - The solution to clip.\n * @param i - The interval to retain values within.\n * @since 2.0.0\n */\nexport const clip: {\n (i: Interval): (s: Solution<number>) => Solution<number>\n (s: Solution<number>, i: Interval): Solution<number>\n} = internal.clip\n\n/**\n * Maps every value in the solution to a new value. Result cardinality matches\n * the input.\n *\n * @since 2.0.0\n */\nexport const map: {\n <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B>\n <A, B>(f: (v: A) => B): (s: Solution<A>) => Solution<B>\n} = internal.map\n\n// Drops `None` from the union of the input solution type — used by `match` to\n// give `onSome` a tighter parameter type. Distributive: a `Solution.AtMostOne<T>`\n// becomes `One<T>`; a full `Solution<T>` keeps `Some<T>`.\ntype SomeOf<S> = S extends None ? never : S\n\n/**\n * Pattern matches on a solution, calling `onNone` for the empty case and\n * `onSome` for any non-empty case. The `onSome` parameter is typed against\n * the input's narrowed shape — for an `AtMostOne<T>` input, `onSome` receives\n * `One<T>` and can read `.value` directly.\n *\n * @example\n * ```ts\n * const result = polynomial.pipe(\n * LinearPolynomial.solveInverse(0),\n * Solution.match({\n * onNone: () => null,\n * onSome: ({ value }) => Math.abs(value),\n * }),\n * )\n * ```\n *\n * @since 2.0.0\n */\nexport const match: {\n <S extends Solution<unknown>, A, B>(\n self: S,\n matcher: { readonly onNone: () => A; readonly onSome: (s: SomeOf<S>) => B },\n ): A | B\n <S extends Solution<unknown>, A, B>(matcher: {\n readonly onNone: () => A\n readonly onSome: (s: SomeOf<S>) => B\n }): (self: S) => A | B\n} = internal.match as never\n"],"mappings":";;;;AAgBA,MAAM,iBAAkC,EACtC,aAAa;CAAE,MAAM;CAAM,OAAO,KAAA;CAAoB,GACvD;AAED,IAAM,WAAN,cAAuB,SAAyB;CAC9C,OAAgB;CAChB,SAAkB;CAElB,CAAC,OAAO,YAA6B;EACnC,OAAO;;;AAIX,IAAM,UAAN,cAAyB,SAA2B;CAI7B;CAHrB,OAAgB;CAChB,SAAkB;CAElB,YAAY,OAAmB;EAC7B,OAAO;EADY,KAAA,QAAA;;CAIrB,CAAC,OAAO,YAAyB;EAC/B,OAAO,CAAC,KAAK,MAAM,CAAC,OAAO,WAAW;;;AAI1C,IAAM,UAAN,cAAyB,SAA2B;CAI7B;CAHrB,OAAgB;CAChB,SAAkB;CAElB,YAAY,QAAkC;EAC5C,OAAO;EADY,KAAA,SAAA;;CAIrB,IAAI,QAAW;EACb,OAAO,KAAK,OAAO;;CAGrB,CAAC,OAAO,YAAyB;EAC/B,OAAO,KAAK,OAAO,OAAO,WAAW;;;AAIzC,IAAM,YAAN,cAA2B,SAA6B;CAIjC;CAHrB,OAAgB;CAChB,SAAkB;CAElB,YAAY,QAAqC;EAC/C,OAAO;EADY,KAAA,SAAA;;CAIrB,IAAI,QAAW;EACb,OAAO,KAAK,OAAO;;CAGrB,CAAC,OAAO,YAAyB;EAC/B,OAAO,KAAK,OAAO,OAAO,WAAW;;;;AAKzC,MAAa,gBAAsB,IAAI,UAAU;;AAGjD,MAAaA,SAAa;;AAG1B,MAAaC,SAAU,UAAqB,IAAI,QAAQ,MAAM;;AAG9D,MAAaC,SAAU,GAAM,MAAiB,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;;AAGjE,MAAaC,WAAY,GAAM,GAAM,MAAmB,IAAI,UAAU;CAAC;CAAG;CAAG;CAAE,CAAC;;AA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EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,OAAO,GAAG,CAAC;EAC5C,KAAK,SACH,OAAOC,QAAM,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,OAAO,GAAG,CAAC;;EAEhE;;AAGF,MAAagB,UAAQ,KACnB,IAEE,MACA,YACWd,SAAO,KAAK,GAAG,QAAQ,QAAQ,GAAG,QAAQ,OAAO,KAAK,CACpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9JD,MAAa,OAAae;;;;;;AAO1B,MAAa,MAA+BC;;;;;;AAO5C,MAAa,MAAiCC;;;;;;AAO9C,MAAa,QAA2CC;;;;;;;AAQxD,MAAa,YAAuDC;;;;;;AAOpE,MAAa,SAA2CC;;;;;;;AAQxD,MAAa,SAA8CC;;;;;;;;AAS3D,MAAa,mBAAyDC;;;;;;;AAQtE,MAAa,OAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;;;;;;;;;;;AAkBJ,MAAa,gBAGP,GAAG,SAAiC;CACxC,IAAI,KAAK,UAAU,KAAK,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO,MACjE,OAAOC,cAAqB,KAAK,IAAyB,KAAK,GAAyB;CAE1F,MAAM,UAAU,KAAK;CACrB,QAAW,MAAmBA,cAAqB,GAAG,QAAQ;;;;;;;AAQhE,MAAa,aAAuCC;;;;;;AAOpD,MAAa,YAA6CC;;;;;;AAO1D,MAAa,YAA6CC;;;;;;;AAQ1D,MAAa,SACXC;;;;;;;;;;AAWF,MAAa,OAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;;;;;;;;;;;;;;AA0BJ,MAAa,QASTC"}
1
+ {"version":3,"file":"solution-B2JdOZpe.mjs","names":["none","one","two","three","fromArray","isNone","isSome","valueOrUndefined","last","min","max","unsafeValue","unsafeLast","unsafeMin","unsafeMax","filter","clip","Interval.contains","map","match","internal.none","internal.one","internal.two","internal.three","internal.fromArray","internal.isNone","internal.isSome","internal.valueOrUndefined","internal.last","internal.min","internal.max","internal.unsafeValue","internal.unsafeLast","internal.unsafeMin","internal.unsafeMax","internal.filter","internal.clip","internal.map","internal.match"],"sources":["../../src/solution/solution.internal.ts","../../src/solution/solution.ts"],"sourcesContent":["import * as Interval from '../interval/interval.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport type {\n AtMostOne,\n AtMostThree,\n AtMostTwo,\n None,\n One,\n Solution,\n Some,\n Three,\n Two,\n} from './solution.ts'\nimport { invariant } from '../utils.ts'\n\n// Empty iterator — shared across all None instances since None has no data.\nconst EMPTY_ITERATOR: Iterator<never> = {\n next: () => ({ done: true, value: undefined as never }),\n}\n\nclass NoneImpl extends Pipeable implements None {\n readonly _tag = 'none' as const\n readonly length = 0 as const;\n\n [Symbol.iterator](): Iterator<never> {\n return EMPTY_ITERATOR\n }\n}\n\nclass OneImpl<T> extends Pipeable implements One<T> {\n readonly _tag = 'one' as const\n readonly length = 1 as const\n\n constructor(readonly value: T) {\n super()\n }\n\n [Symbol.iterator](): Iterator<T> {\n return [this.value][Symbol.iterator]()\n }\n}\n\nclass TwoImpl<T> extends Pipeable implements Two<T> {\n readonly _tag = 'two' as const\n readonly length = 2 as const\n\n constructor(readonly values: readonly [T, T]) {\n super()\n }\n\n get value(): T {\n return this.values[0]\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this.values[Symbol.iterator]()\n }\n}\n\nclass ThreeImpl<T> extends Pipeable implements Three<T> {\n readonly _tag = 'three' as const\n readonly length = 3 as const\n\n constructor(readonly values: readonly [T, T, T]) {\n super()\n }\n\n get value(): T {\n return this.values[0]\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this.values[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const NONE_INSTANCE: None = new NoneImpl()\n\n/** @internal */\nexport const none: None = NONE_INSTANCE\n\n/** @internal */\nexport const one = <T>(value: T): One<T> => new OneImpl(value)\n\n/** @internal */\nexport const two = <T>(a: T, b: T): Two<T> => new TwoImpl([a, b])\n\n/** @internal */\nexport const three = <T>(a: T, b: T, c: T): Three<T> => new ThreeImpl([a, b, c])\n\n/** @internal */\nexport const fromArray = <T>(arr: ReadonlyArray<T>): Solution<T> => {\n switch (arr.length) {\n case 0:\n return NONE_INSTANCE\n case 1:\n return one(arr[0] as T)\n case 2:\n return two(arr[0] as T, arr[1] as T)\n case 3:\n return three(arr[0] as T, arr[1] as T, arr[2] as T)\n default:\n invariant(false, `Solution can hold at most 3 values, got ${arr.length}`)\n }\n}\n\n/** @internal */\nexport const isNone = <T>(s: Solution<T>): s is None => s._tag === 'none'\n\n/** @internal */\nexport const isSome = <T>(s: Solution<T>): s is Some<T> => s._tag !== 'none'\n\n/** @internal */\nexport const valueOrUndefined = <T>(s: Solution<T>): T | undefined =>\n isNone(s) ? undefined : s.value\n\n/** @internal */\nexport const last: {\n <T>(s: Some<T>): T\n <T>(s: Solution<T>): T | undefined\n} = (<T>(s: Solution<T>): T | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return s.values[1]\n case 'three':\n return s.values[2]\n }\n}) as never\n\n/** @internal */\nexport const min: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = ((s: Solution<number>): number | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return Math.min(s.values[0], s.values[1])\n case 'three':\n return Math.min(s.values[0], s.values[1], s.values[2])\n }\n}) as never\n\n/** @internal */\nexport const max: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = ((s: Solution<number>): number | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return Math.max(s.values[0], s.values[1])\n case 'three':\n return Math.max(s.values[0], s.values[1], s.values[2])\n }\n}) as never\n\n/** @internal */\nexport const unsafeValue = <T>(s: Solution<T>, message?: string): T => {\n invariant(isSome(s), message ?? 'Solution.unsafeValue on empty Solution')\n return s.value\n}\n\n/** @internal */\nexport const unsafeLast = <T>(s: Solution<T>): T => {\n invariant(isSome(s), 'Solution.unsafeLast on empty Solution')\n return last(s)\n}\n\n/** @internal */\nexport const unsafeMin = (s: Solution<number>): number => {\n invariant(isSome(s), 'Solution.unsafeMin on empty Solution')\n return min(s)\n}\n\n/** @internal */\nexport const unsafeMax = (s: Solution<number>): number => {\n invariant(isSome(s), 'Solution.unsafeMax on empty Solution')\n return max(s)\n}\n\n/** @internal */\nexport const filter = <T>(s: Solution<T>, predicate: (v: T) => boolean): Solution<T> => {\n switch (s._tag) {\n case 'none':\n return s\n case 'one':\n return predicate(s.value) ? s : NONE_INSTANCE\n case 'two': {\n const a = predicate(s.values[0])\n const b = predicate(s.values[1])\n if (a && b) {\n return s\n }\n if (a) {\n return one(s.values[0])\n }\n if (b) {\n return one(s.values[1])\n }\n return NONE_INSTANCE\n }\n case 'three': {\n const survivors: Array<T> = []\n if (predicate(s.values[0])) {\n survivors.push(s.values[0])\n }\n if (predicate(s.values[1])) {\n survivors.push(s.values[1])\n }\n if (predicate(s.values[2])) {\n survivors.push(s.values[2])\n }\n return fromArray(survivors)\n }\n }\n}\n\n/** @internal */\nexport const clip = dual(\n 2,\n (s: Solution<number>, i: Interval.Interval): Solution<number> =>\n filter(s, (v) => Interval.contains(i, v)),\n)\n\n/** @internal */\nexport const map = dual(2, <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B> => {\n switch (s._tag) {\n case 'none':\n return s\n case 'one':\n return one(f(s.value))\n case 'two':\n return two(f(s.values[0]), f(s.values[1]))\n case 'three':\n return three(f(s.values[0]), f(s.values[1]), f(s.values[2]))\n }\n})\n\n/** @internal */\nexport const match = dual(\n 2,\n <T, A, B>(\n self: Solution<T>,\n matcher: { readonly onNone: () => A; readonly onSome: (s: Some<T>) => B },\n ): A | B => (isNone(self) ? matcher.onNone() : matcher.onSome(self)),\n)\n\n// Re-export type aliases that the namespace consumers expect to see at runtime.\n// (Pure type re-exports — no runtime cost.)\nexport type { AtMostOne, AtMostThree, AtMostTwo, None, One, Solution, Some, Three, Two }\n","import type { Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport * as internal from './solution.internal.ts'\n\n/**\n * A `Solution<T>` represents the result of an operation that may produce\n * between zero and three values of `T`. It generalizes the zoo of \"0 or 1\",\n * \"0 to 2\", \"0 to 3\" return shapes used throughout curvy under one type, and\n * provides a small namespace of operations (`value`, `last`, `min`, `max`,\n * `filter`, `map`, `match`, …) for working with the result.\n *\n * Each variant carries a `_tag` discriminator and a `length` field, is\n * iterable via `Symbol.iterator` (so existing `for..of` and spread patterns\n * keep working), and is `Pipeable` (so a `Solution` value can be the head of\n * a `pipe` chain).\n *\n * Variant-specific accessors:\n * - `One<T>`, `Two<T>`, and `Three<T>` all expose `.value: T` (the first /\n * primary value).\n * - `Two<T>` and `Three<T>` additionally expose `.values: readonly [T, ...]`\n * for explicit positional access.\n *\n * Operations that return narrower cardinalities (e.g. inverse-solving a\n * monotonic polynomial) use the `AtMost{One,Two,Three}` aliases to express\n * \"this could be empty, but it'll have at most N values.\"\n *\n * @since 2.0.0\n */\nexport type Solution<T> = None | One<T> | Two<T> | Three<T>\n\n/**\n * The empty solution.\n *\n * @since 2.0.0\n */\nexport interface None extends Pipeable, Iterable<never> {\n readonly _tag: 'none'\n readonly length: 0\n}\n\n/** @since 2.0.0 */\nexport interface One<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'one'\n readonly length: 1\n readonly value: T\n}\n\n/** @since 2.0.0 */\nexport interface Two<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'two'\n readonly length: 2\n readonly value: T\n readonly values: readonly [T, T]\n}\n\n/** @since 2.0.0 */\nexport interface Three<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'three'\n readonly length: 3\n readonly value: T\n readonly values: readonly [T, T, T]\n}\n\n/**\n * Any non-empty solution. All `Some<T>` values expose `.value: T` directly —\n * no narrowing required to read the primary value.\n *\n * @since 2.0.0\n */\nexport type Some<T> = One<T> | Two<T> | Three<T>\n\n/**\n * `None | One<T>` — return type of operations that produce at most one value\n * (e.g. inverse-solving a strictly monotonic polynomial).\n *\n * @since 2.0.0\n */\nexport type AtMostOne<T> = None | One<T>\n\n/**\n * `None | One<T> | Two<T>` — return type of operations that produce at most\n * two values (e.g. inverse-solving an unrestricted quadratic polynomial).\n *\n * @since 2.0.0\n */\nexport type AtMostTwo<T> = None | One<T> | Two<T>\n\n/**\n * `None | One<T> | Two<T> | Three<T>` — equivalent to `Solution<T>`.\n *\n * @since 2.0.0\n */\nexport type AtMostThree<T> = Solution<T>\n\n/**\n * The empty solution. Reused across calls — never reallocated.\n *\n * @since 2.0.0\n */\nexport const none: None = internal.none\n\n/**\n * Constructs a single-value solution.\n *\n * @since 2.0.0\n */\nexport const one: <T>(value: T) => One<T> = internal.one\n\n/**\n * Constructs a two-value solution.\n *\n * @since 2.0.0\n */\nexport const two: <T>(a: T, b: T) => Two<T> = internal.two\n\n/**\n * Constructs a three-value solution.\n *\n * @since 2.0.0\n */\nexport const three: <T>(a: T, b: T, c: T) => Three<T> = internal.three\n\n/**\n * Constructs a `Solution<T>` from a runtime array. Throws if the array has\n * more than three elements.\n *\n * @since 2.0.0\n */\nexport const fromArray: <T>(arr: ReadonlyArray<T>) => Solution<T> = internal.fromArray\n\n/**\n * Type-narrowing predicate: refines `Solution<T>` to `None`.\n *\n * @since 2.0.0\n */\nexport const isNone: <T>(s: Solution<T>) => s is None = internal.isNone\n\n/**\n * Type-narrowing predicate: refines `Solution<T>` to `Some<T>` (non-empty).\n * After narrowing, `.value` is directly accessible without further checks.\n *\n * @since 2.0.0\n */\nexport const isSome: <T>(s: Solution<T>) => s is Some<T> = internal.isSome\n\n/**\n * Returns the primary (first) value if the solution is non-empty, or\n * `undefined` if empty. Pair with `.value` access on `Some<T>`-narrowed\n * inputs to avoid the `undefined` possibility.\n *\n * @since 2.0.0\n */\nexport const valueOrUndefined: <T>(s: Solution<T>) => T | undefined = internal.valueOrUndefined\n\n/**\n * Returns the last value in the solution, or `undefined` if empty. When\n * called on a `Some<T>`, the result is guaranteed to be `T`.\n *\n * @since 2.0.0\n */\nexport const last: {\n <T>(s: Some<T>): T\n <T>(s: Solution<T>): T | undefined\n} = internal.last\n\n/**\n * Returns the smallest numeric value in the solution, or `undefined` if empty.\n * When called on a `Some<number>`, the result is guaranteed to be `number`.\n *\n * @since 2.0.0\n */\nexport const min: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = internal.min\n\n/**\n * Returns the largest numeric value in the solution, or `undefined` if empty.\n * When called on a `Some<number>`, the result is guaranteed to be `number`.\n *\n * @since 2.0.0\n */\nexport const max: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = internal.max\n\n/**\n * Returns the primary value of the solution (i.e. `s.value`). Throws on\n * `None`, optionally with a caller-provided message.\n *\n * Useful when the type system can't prove non-emptiness but you have a domain\n * reason to assert it — e.g. inverting a polynomial you know to be monotonic\n * without going through the trait refiner first:\n *\n * ```ts\n * const x = CubicPolynomial.solveInverse(p, y).pipe(\n * Solution.unsafeValue('expected a monotonic inverse'),\n * )\n * ```\n *\n * @since 2.0.0\n */\nexport const unsafeValue: {\n <T>(s: Solution<T>, message?: string): T\n (message: string): <T>(s: Solution<T>) => T\n} = ((...args: ReadonlyArray<unknown>) => {\n if (args.length >= 1 && typeof args[0] === 'object' && args[0] !== null) {\n return internal.unsafeValue(args[0] as Solution<unknown>, args[1] as string | undefined)\n }\n const message = args[0] as string\n return <T>(s: Solution<T>) => internal.unsafeValue(s, message)\n}) as never\n\n/**\n * Returns the last value in the solution. Throws if empty.\n *\n * @since 2.0.0\n */\nexport const unsafeLast: <T>(s: Solution<T>) => T = internal.unsafeLast\n\n/**\n * Returns the smallest numeric value in the solution. Throws on empty.\n *\n * @since 2.0.0\n */\nexport const unsafeMin: (s: Solution<number>) => number = internal.unsafeMin\n\n/**\n * Returns the largest numeric value in the solution. Throws on empty.\n *\n * @since 2.0.0\n */\nexport const unsafeMax: (s: Solution<number>) => number = internal.unsafeMax\n\n/**\n * Filters the solution by a predicate. Result cardinality is at most that of\n * the input.\n *\n * @since 2.0.0\n */\nexport const filter: <T>(s: Solution<T>, predicate: (v: T) => boolean) => Solution<T> =\n internal.filter\n\n/**\n * Restricts the solution to values contained within an interval. Endpoint\n * inclusivity follows the interval's `kind` — pass an open variant (e.g.\n * `Interval.makeOpen(0, 1)` or `Interval.unitOpen`) for strict containment.\n *\n * @param s - The solution to clip.\n * @param i - The interval to retain values within.\n * @since 2.0.0\n */\nexport const clip: {\n (i: Interval): (s: Solution<number>) => Solution<number>\n (s: Solution<number>, i: Interval): Solution<number>\n} = internal.clip\n\n/**\n * Maps every value in the solution to a new value. Result cardinality matches\n * the input.\n *\n * @since 2.0.0\n */\nexport const map: {\n <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B>\n <A, B>(f: (v: A) => B): (s: Solution<A>) => Solution<B>\n} = internal.map\n\n// Drops `None` from the union of the input solution type — used by `match` to\n// give `onSome` a tighter parameter type. Distributive: a `Solution.AtMostOne<T>`\n// becomes `One<T>`; a full `Solution<T>` keeps `Some<T>`.\ntype SomeOf<S> = S extends None ? never : S\n\n/**\n * Pattern matches on a solution, calling `onNone` for the empty case and\n * `onSome` for any non-empty case. The `onSome` parameter is typed against\n * the input's narrowed shape — for an `AtMostOne<T>` input, `onSome` receives\n * `One<T>` and can read `.value` directly.\n *\n * @example\n * ```ts\n * const result = polynomial.pipe(\n * LinearPolynomial.solveInverse(0),\n * Solution.match({\n * onNone: () => null,\n * onSome: ({ value }) => Math.abs(value),\n * }),\n * )\n * ```\n *\n * @since 2.0.0\n */\nexport const match: {\n <S extends Solution<unknown>, A, B>(\n self: S,\n matcher: { readonly onNone: () => A; readonly onSome: (s: SomeOf<S>) => B },\n ): A | B\n <S extends Solution<unknown>, A, B>(matcher: {\n readonly onNone: () => A\n readonly onSome: (s: SomeOf<S>) => B\n }): (self: S) => A | B\n} = internal.match as never\n"],"mappings":";;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G,EAAE,EAAE,EAAE,OAAO,GAAG,CAAC;;EAEhE;;AAGF,MAAagB,UAAQ,KACnB,IAEE,MACA,YACWd,SAAO,KAAK,GAAG,QAAQ,QAAQ,GAAG,QAAQ,OAAO,KAAK,CACpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9JD,MAAa,OAAae;;;;;;AAO1B,MAAa,MAA+BC;;;;;;AAO5C,MAAa,MAAiCC;;;;;;AAO9C,MAAa,QAA2CC;;;;;;;AAQxD,MAAa,YAAuDC;;;;;;AAOpE,MAAa,SAA2CC;;;;;;;AAQxD,MAAa,SAA8CC;;;;;;;;AAS3D,MAAa,mBAAyDC;;;;;;;AAQtE,MAAa,OAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;;;;;;;;;;;AAkBJ,MAAa,gBAGP,GAAG,SAAiC;CACxC,IAAI,KAAK,UAAU,KAAK,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO,MACjE,OAAOC,cAAqB,KAAK,IAAyB,KAAK,GAAyB;CAE1F,MAAM,UAAU,KAAK;CACrB,QAAW,MAAmBA,cAAqB,GAAG,QAAQ;;;;;;;AAQhE,MAAa,aAAuCC;;;;;;AAOpD,MAAa,YAA6CC;;;;;;AAO1D,MAAa,YAA6CC;;;;;;;AAQ1D,MAAa,SACXC;;;;;;;;;;AAWF,MAAa,OAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;;;;;;;;;;;;;;AA0BJ,MAAa,QASTC"}
@@ -1,2 +1,2 @@
1
- import { c as solution_exports } from "../shared/solution-B6KY1E7M.mjs";
1
+ import { c as solution_exports } from "../shared/solution-B2JdOZpe.mjs";
2
2
  export { solution_exports as Solution };
@@ -2,6 +2,7 @@ import * as Bezier2dNs from './bezier2d.ts';
2
2
  import * as Cardinal2dNs from './cardinal2d.ts';
3
3
  import * as Hermite2dNs from './hermite2d.ts';
4
4
  import * as Basis2dNs from './basis2d.ts';
5
+ import * as Linear2dNs from './linear2d.ts';
5
6
  import * as RationalBezier2dNs from './rationalBezier2d.ts';
6
7
  export type Bezier2d = Bezier2dNs.Bezier2d;
7
8
  export { Bezier2dNs as Bezier2d };
@@ -11,5 +12,7 @@ export type Hermite2d = Hermite2dNs.Hermite2d;
11
12
  export { Hermite2dNs as Hermite2d };
12
13
  export type Basis2d = Basis2dNs.Basis2d;
13
14
  export { Basis2dNs as Basis2d };
15
+ export type Linear2d = Linear2dNs.Linear2d;
16
+ export { Linear2dNs as Linear2d };
14
17
  export type RationalBezier2d = RationalBezier2dNs.RationalBezier2d;
15
18
  export { RationalBezier2dNs as RationalBezier2d };