curvy 1.0.9 → 2.0.0-alpha.2

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 (173) hide show
  1. package/dist/characteristic/index.d.mts +88 -0
  2. package/dist/characteristic/index.mjs +2 -0
  3. package/dist/curve/index.d.mts +2 -0
  4. package/dist/curve/index.mjs +2 -0
  5. package/dist/interval/index.d.mts +3 -0
  6. package/dist/interval/index.mjs +3 -0
  7. package/dist/matrix/index.d.mts +2 -0
  8. package/dist/matrix/index.mjs +267 -0
  9. package/dist/matrix/index.mjs.map +1 -0
  10. package/dist/number.d.mts +280 -0
  11. package/dist/number.mjs +140 -0
  12. package/dist/number.mjs.map +1 -0
  13. package/dist/path/index.d.mts +261 -0
  14. package/dist/path/index.mjs +325 -0
  15. package/dist/path/index.mjs.map +1 -0
  16. package/dist/polynomial/index.d.mts +2 -0
  17. package/dist/polynomial/index.mjs +3 -0
  18. package/dist/shared/characteristic-B9nCh_cx.mjs +104 -0
  19. package/dist/shared/characteristic-B9nCh_cx.mjs.map +1 -0
  20. package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
  21. package/dist/shared/cubic-BajUY0JT.d.mts +1100 -0
  22. package/dist/shared/cubic-CpHAx8cC.mjs +479 -0
  23. package/dist/shared/cubic-CpHAx8cC.mjs.map +1 -0
  24. package/dist/shared/interval-05CR6eBf.mjs +421 -0
  25. package/dist/shared/interval-05CR6eBf.mjs.map +1 -0
  26. package/dist/shared/interval-Dy-RMEE3.d.mts +533 -0
  27. package/dist/shared/interval2d-8IBZnUOq.mjs +108 -0
  28. package/dist/shared/interval2d-8IBZnUOq.mjs.map +1 -0
  29. package/dist/shared/interval2d-C2id9u31.d.mts +172 -0
  30. package/dist/shared/matrix4x4-Ck2WROK-.mjs +440 -0
  31. package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +1 -0
  32. package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +1183 -0
  33. package/dist/shared/quadratic-CamozcFc.mjs +330 -0
  34. package/dist/shared/quadratic-CamozcFc.mjs.map +1 -0
  35. package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +308 -0
  36. package/dist/shared/rationalCubic2d-BEgUGSFf.mjs +295 -0
  37. package/dist/shared/rationalCubic2d-BEgUGSFf.mjs.map +1 -0
  38. package/dist/shared/rationalCubic2d-Bys2Uory.mjs +695 -0
  39. package/dist/shared/rationalCubic2d-Bys2Uory.mjs.map +1 -0
  40. package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +818 -0
  41. package/dist/shared/solution-CrtLfqEq.mjs +306 -0
  42. package/dist/shared/solution-CrtLfqEq.mjs.map +1 -0
  43. package/dist/shared/solution-sNQ-ZVhN.d.mts +251 -0
  44. package/dist/{pipe.d.mts → shared/utils-MCckigYk.d.mts} +44 -26
  45. package/dist/shared/vector2-CL1HDdPr.mjs +187 -0
  46. package/dist/shared/vector2-CL1HDdPr.mjs.map +1 -0
  47. package/dist/shared/vector2-DPUY3_eA.d.mts +470 -0
  48. package/dist/shared/vector2.internal-DU_E808S.mjs +97 -0
  49. package/dist/shared/vector2.internal-DU_E808S.mjs.map +1 -0
  50. package/dist/shared/vector3-D-tv_aKL.mjs +204 -0
  51. package/dist/shared/vector3-D-tv_aKL.mjs.map +1 -0
  52. package/dist/shared/vector3-DqeOZtOB.d.mts +703 -0
  53. package/dist/shared/vector4-5KbjoHVj.mjs +109 -0
  54. package/dist/shared/vector4-5KbjoHVj.mjs.map +1 -0
  55. package/dist/shared/vector4.internal-5XcaX12X.mjs +163 -0
  56. package/dist/shared/vector4.internal-5XcaX12X.mjs.map +1 -0
  57. package/dist/solution/index.d.mts +2 -0
  58. package/dist/solution/index.mjs +2 -0
  59. package/dist/splines/index.d.mts +701 -0
  60. package/dist/splines/index.mjs +734 -0
  61. package/dist/splines/index.mjs.map +1 -0
  62. package/dist/utils.d.mts +2 -205
  63. package/dist/utils.mjs +88 -52
  64. package/dist/utils.mjs.map +1 -1
  65. package/dist/vector/index.d.mts +3 -0
  66. package/dist/vector/index.mjs +4 -0
  67. package/package.json +49 -92
  68. package/dist/curve/cubic2d.d.mts +0 -109
  69. package/dist/curve/cubic2d.d.ts +0 -109
  70. package/dist/curve/cubic2d.mjs +0 -80
  71. package/dist/curve/cubic2d.mjs.map +0 -1
  72. package/dist/curve/linear2d.d.mts +0 -94
  73. package/dist/curve/linear2d.d.ts +0 -94
  74. package/dist/curve/linear2d.mjs +0 -46
  75. package/dist/curve/linear2d.mjs.map +0 -1
  76. package/dist/curve/quadratic2d.d.mts +0 -117
  77. package/dist/curve/quadratic2d.d.ts +0 -117
  78. package/dist/curve/quadratic2d.mjs +0 -82
  79. package/dist/curve/quadratic2d.mjs.map +0 -1
  80. package/dist/interval.d.mts +0 -251
  81. package/dist/interval.d.ts +0 -251
  82. package/dist/interval.mjs +0 -86
  83. package/dist/interval.mjs.map +0 -1
  84. package/dist/matrix/matrix2x2.d.mts +0 -320
  85. package/dist/matrix/matrix2x2.d.ts +0 -320
  86. package/dist/matrix/matrix2x2.mjs +0 -25
  87. package/dist/matrix/matrix2x2.mjs.map +0 -1
  88. package/dist/matrix/matrix3x3.d.mts +0 -370
  89. package/dist/matrix/matrix3x3.d.ts +0 -370
  90. package/dist/matrix/matrix3x3.mjs +0 -28
  91. package/dist/matrix/matrix3x3.mjs.map +0 -1
  92. package/dist/matrix/matrix4x4.d.mts +0 -381
  93. package/dist/matrix/matrix4x4.d.ts +0 -381
  94. package/dist/matrix/matrix4x4.mjs +0 -178
  95. package/dist/matrix/matrix4x4.mjs.map +0 -1
  96. package/dist/path/cubic2d.d.mts +0 -95
  97. package/dist/path/cubic2d.d.ts +0 -95
  98. package/dist/path/cubic2d.mjs +0 -60
  99. package/dist/path/cubic2d.mjs.map +0 -1
  100. package/dist/path/linear2d.d.mts +0 -95
  101. package/dist/path/linear2d.d.ts +0 -95
  102. package/dist/path/linear2d.mjs +0 -53
  103. package/dist/path/linear2d.mjs.map +0 -1
  104. package/dist/path/quadratic2d.d.mts +0 -95
  105. package/dist/path/quadratic2d.d.ts +0 -95
  106. package/dist/path/quadratic2d.mjs +0 -57
  107. package/dist/path/quadratic2d.mjs.map +0 -1
  108. package/dist/pipe.d.ts +0 -58
  109. package/dist/pipe.mjs +0 -92
  110. package/dist/pipe.mjs.map +0 -1
  111. package/dist/polynomial/cubic.d.mts +0 -7
  112. package/dist/polynomial/cubic.d.ts +0 -7
  113. package/dist/polynomial/cubic.mjs +0 -133
  114. package/dist/polynomial/cubic.mjs.map +0 -1
  115. package/dist/polynomial/linear.d.mts +0 -7
  116. package/dist/polynomial/linear.d.ts +0 -7
  117. package/dist/polynomial/linear.mjs +0 -24
  118. package/dist/polynomial/linear.mjs.map +0 -1
  119. package/dist/polynomial/quadratic.d.mts +0 -7
  120. package/dist/polynomial/quadratic.d.ts +0 -7
  121. package/dist/polynomial/quadratic.mjs +0 -27
  122. package/dist/polynomial/quadratic.mjs.map +0 -1
  123. package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
  124. package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
  125. package/dist/shared/curvy.BkkW8Tx9.mjs +0 -102
  126. package/dist/shared/curvy.BkkW8Tx9.mjs.map +0 -1
  127. package/dist/shared/curvy.BxdGW9he.mjs +0 -116
  128. package/dist/shared/curvy.BxdGW9he.mjs.map +0 -1
  129. package/dist/shared/curvy.C_sCeg9J.mjs +0 -66
  130. package/dist/shared/curvy.C_sCeg9J.mjs.map +0 -1
  131. package/dist/shared/curvy.Cg8lZVUz.d.ts +0 -688
  132. package/dist/shared/curvy.DCt1gGII.mjs +0 -147
  133. package/dist/shared/curvy.DCt1gGII.mjs.map +0 -1
  134. package/dist/shared/curvy.DJ4xO0al.mjs +0 -63
  135. package/dist/shared/curvy.DJ4xO0al.mjs.map +0 -1
  136. package/dist/shared/curvy.DmVFTi0N.mjs +0 -35
  137. package/dist/shared/curvy.DmVFTi0N.mjs.map +0 -1
  138. package/dist/shared/curvy.FDaj5rlj.d.mts +0 -688
  139. package/dist/shared/curvy.lktriTpx.mjs +0 -101
  140. package/dist/shared/curvy.lktriTpx.mjs.map +0 -1
  141. package/dist/shared/curvy.mLFprrGm.mjs +0 -85
  142. package/dist/shared/curvy.mLFprrGm.mjs.map +0 -1
  143. package/dist/shared/curvy.r6f1j287.mjs +0 -76
  144. package/dist/shared/curvy.r6f1j287.mjs.map +0 -1
  145. package/dist/splines/basis2d.d.mts +0 -130
  146. package/dist/splines/basis2d.d.ts +0 -130
  147. package/dist/splines/basis2d.mjs +0 -90
  148. package/dist/splines/basis2d.mjs.map +0 -1
  149. package/dist/splines/bezier2d.d.mts +0 -182
  150. package/dist/splines/bezier2d.d.ts +0 -182
  151. package/dist/splines/bezier2d.mjs +0 -23
  152. package/dist/splines/bezier2d.mjs.map +0 -1
  153. package/dist/splines/cardinal2d.d.mts +0 -178
  154. package/dist/splines/cardinal2d.d.ts +0 -178
  155. package/dist/splines/cardinal2d.mjs +0 -114
  156. package/dist/splines/cardinal2d.mjs.map +0 -1
  157. package/dist/splines/hermite2d.d.mts +0 -124
  158. package/dist/splines/hermite2d.d.ts +0 -124
  159. package/dist/splines/hermite2d.mjs +0 -63
  160. package/dist/splines/hermite2d.mjs.map +0 -1
  161. package/dist/utils.d.ts +0 -205
  162. package/dist/vector/vector2.d.mts +0 -324
  163. package/dist/vector/vector2.d.ts +0 -324
  164. package/dist/vector/vector2.mjs +0 -30
  165. package/dist/vector/vector2.mjs.map +0 -1
  166. package/dist/vector/vector3.d.mts +0 -417
  167. package/dist/vector/vector3.d.ts +0 -417
  168. package/dist/vector/vector3.mjs +0 -38
  169. package/dist/vector/vector3.mjs.map +0 -1
  170. package/dist/vector/vector4.d.mts +0 -205
  171. package/dist/vector/vector4.d.ts +0 -205
  172. package/dist/vector/vector4.mjs +0 -20
  173. package/dist/vector/vector4.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["Vector2.makeWeighted","isRationalBezier2d","Vector3.make","make","fromArray","fromPoints","fromBezier","toPath","RationalCubicCurve2d.fromBezierPoints","RationalCubicPath2d.fromArray","subdivide","Solution.none","Vector2.make","Solution.one","Vector4.transpose","CubicCurve2d.fromPolynomials","Characteristic.apply","Matrix4x4.inverse","Characteristic.cubicBezier","Matrix4x4.multiply","isCubicBezier2d","make","fromArray","append","Matrix4x4.vectorProductLeft","Vector4.make","Vector2.make","appendTangentAligned","appendCurvatureAligned","appendVelocityAligned","appendAccelerationAligned","toPath","CubicPath2d.make","fromRational","RationalBezier2dInternal.toBezierPoints","Solution.one","subdivide","make","internal.make","fromArray","internal.fromArray","internal.isCubicBezier2d","append","internal.append","internal.appendTangentAligned","internal.appendCurvatureAligned","internal.appendVelocityAligned","internal.appendAccelerationAligned","toPath","internal.toPath","internal.fromRational","subdivide","internal.subdivide","isCardinal2d","make","fromArray","append","prepend","withDuplicatedEndpoints","withReflectedEndpoints","scale","Vector2.subtract","Vector2.scale","Vector2.add","toPath","CubicPath2d.make","Characteristic.cubicCardinal","toBezier","bezierInternal.fromBasis","internal.isCardinal2d","make","internal.make","fromArray","internal.fromArray","append","internal.append","prepend","internal.prepend","internal.withDuplicatedEndpoints","internal.withReflectedEndpoints","toPath","internal.toPath","toBezier","internal.toBezier","isHermite2d","make","fromArray","append","prepend","toPath","CubicPath2d.make","Characteristic.cubicHermite","toBezier","bezierInternal.fromBasis","internal.isHermite2d","make","internal.make","fromArray","internal.fromArray","append","internal.append","prepend","internal.prepend","toPath","internal.toPath","toBezier","internal.toBezier","isBasis2d","make","fromArray","append","prepend","withTriplicatedEndpoints","toPath","CubicPath2d.make","Characteristic.cubicBasisSpline","toBezier","bezierInternal.fromBasis","internal.isBasis2d","make","internal.make","fromArray","internal.fromArray","internal.append","internal.prepend","internal.withTriplicatedEndpoints","toPath","internal.toPath","internal.toBezier","internal.isRationalBezier2d","internal.make","internal.fromArray","internal.fromPoints","internal.fromBezier","internal.toPath","internal.subdivide"],"sources":["../../src/splines/rationalBezier2d.internal.ts","../../src/splines/util.ts","../../src/splines/bezier2d.internal.ts","../../src/splines/bezier2d.ts","../../src/splines/cardinal2d.internal.ts","../../src/splines/cardinal2d.ts","../../src/splines/hermite2d.internal.ts","../../src/splines/hermite2d.ts","../../src/splines/basis2d.internal.ts","../../src/splines/basis2d.ts","../../src/splines/rationalBezier2d.ts"],"sourcesContent":["import * as RationalCubicCurve2d from '../curve/rationalCubic2d'\nimport * as RationalCubicPath2d from '../path/rationalCubic2d'\nimport { dual, Pipeable } from '../utils'\nimport * as Solution from '../solution/solution'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport * as Vector2 from '../vector/vector2'\nimport * as Vector3 from '../vector/vector3'\nimport type { Bezier2d } from './bezier2d'\nimport type { RationalBezier2d } from './rationalBezier2d'\n\nexport const RationalBezier2dTypeId = Symbol('curvy/splines/rationalBezier2d')\nexport type RationalBezier2dTypeId = typeof RationalBezier2dTypeId\n\n// Internally each control point is stored in homogeneous form as\n// `(w·x, w·y, w)`. De Casteljau in 3D plus a final projection (`x/w`, `y/w`)\n// is exactly the rational evaluator, so the homogeneous form keeps the hot\n// paths identical to the non-rational case modulo one division at the end.\n\nclass RationalBezier2dImpl extends Pipeable implements RationalBezier2d {\n readonly [RationalBezier2dTypeId]: RationalBezier2dTypeId = RationalBezier2dTypeId\n\n readonly homogeneous: ReadonlyArray<Vector3.Vector3>\n\n constructor(homogeneous: ReadonlyArray<Vector3.Vector3>) {\n invariant(homogeneous.length >= 4, 'rational cubic splines require 4 or more points')\n invariant(homogeneous.length % 3 === 1, 'rational cubic splines require (n * 3) + 1 points')\n super()\n this.homogeneous = homogeneous\n }\n\n *[Symbol.iterator](): IterableIterator<Vector2.Weighted> {\n for (const h of this.homogeneous) {\n yield Vector2.makeWeighted(h.x / h.z, h.y / h.z, h.z)\n }\n }\n}\n\nexport const isRationalBezier2d = (p: unknown): p is RationalBezier2d =>\n typeof p === 'object' && p !== null && RationalBezier2dTypeId in p\n\nconst lift = (p: Vector2.Weighted): Vector3.Vector3 =>\n Vector3.make(p.x * p.weight, p.y * p.weight, p.weight)\n\nexport const make = (\n p0: Vector2.Weighted,\n p1: Vector2.Weighted,\n p2: Vector2.Weighted,\n p3: Vector2.Weighted,\n): RationalBezier2d => new RationalBezier2dImpl([lift(p0), lift(p1), lift(p2), lift(p3)])\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Weighted>): RationalBezier2d =>\n new RationalBezier2dImpl(points.map(lift))\n\nexport const fromPoints = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n): RationalBezier2d =>\n new RationalBezier2dImpl([\n Vector3.make(p0.x, p0.y, 1),\n Vector3.make(p1.x, p1.y, 1),\n Vector3.make(p2.x, p2.y, 1),\n Vector3.make(p3.x, p3.y, 1),\n ])\n\nexport const fromBezier = (b: Bezier2d): RationalBezier2d => {\n const homogeneous: Array<Vector3.Vector3> = []\n for (const p of b) {\n homogeneous.push(Vector3.make(p.x, p.y, 1))\n }\n return new RationalBezier2dImpl(homogeneous)\n}\n\nconst homogeneousOf = (r: RationalBezier2d): ReadonlyArray<Vector3.Vector3> =>\n r instanceof RationalBezier2dImpl ? r.homogeneous : Array.from(r, lift)\n\n// Conversion from spline form (piecewise Bernstein weighted control points)\n// to path form (per-segment monomial polynomials with shared denominator).\n// Each segment's four homogeneous control points expand into three cubic\n// polynomials — x, y, w — via the same Bernstein-to-monomial mapping that\n// drives `Bezier2d.toPath`, just running on three channels instead of two.\nexport const toPath = (r: RationalBezier2d): RationalCubicPath2d.RationalCubicPath2d => {\n const homogeneous = homogeneousOf(r)\n const segmentCount = (homogeneous.length - 1) / 3\n const curves: Array<RationalCubicCurve2d.RationalCubicCurve2d> = []\n\n for (let i = 0; i < segmentCount; i++) {\n const base = i * 3\n const h0 = homogeneous[base] as Vector3.Vector3\n const h1 = homogeneous[base + 1] as Vector3.Vector3\n const h2 = homogeneous[base + 2] as Vector3.Vector3\n const h3 = homogeneous[base + 3] as Vector3.Vector3\n\n // Project each homogeneous CP back to its weighted form for the\n // `fromBezierPoints` constructor. The constructor re-lifts internally;\n // the round-trip is exact to within 1–2 ULPs for finite positive weights\n // and the conversion is a one-shot, not a hot path.\n curves.push(\n RationalCubicCurve2d.fromBezierPoints(\n Vector2.makeWeighted(h0.x / h0.z, h0.y / h0.z, h0.z),\n Vector2.makeWeighted(h1.x / h1.z, h1.y / h1.z, h1.z),\n Vector2.makeWeighted(h2.x / h2.z, h2.y / h2.z, h2.z),\n Vector2.makeWeighted(h3.x / h3.z, h3.y / h3.z, h3.z),\n ),\n )\n }\n\n return RationalCubicPath2d.fromArray(curves)\n}\n\nexport const subdivide = dual<\n (u: number) => (r: RationalBezier2d) => [RationalBezier2d, RationalBezier2d],\n (r: RationalBezier2d, u: number) => [RationalBezier2d, RationalBezier2d]\n>(2, (r: RationalBezier2d, u: number): [RationalBezier2d, RationalBezier2d] => {\n invariant(u > 0 && u < 1, 'subdivide parameter u must be in the open interval (0, 1)')\n\n const homogeneous = homogeneousOf(r)\n const segmentCount = (homogeneous.length - 1) / 3\n const t = u * segmentCount\n const i = Math.floor(t)\n const localT = t - i\n\n // exact segment boundary: no de Casteljau needed, just slice\n if (localT === 0) {\n return [\n new RationalBezier2dImpl(homogeneous.slice(0, i * 3 + 1)),\n new RationalBezier2dImpl(homogeneous.slice(i * 3)),\n ]\n }\n\n const p0 = homogeneous[i * 3] as Vector3.Vector3\n const p1 = homogeneous[i * 3 + 1] as Vector3.Vector3\n const p2 = homogeneous[i * 3 + 2] as Vector3.Vector3\n const p3 = homogeneous[i * 3 + 3] as Vector3.Vector3\n\n // de Casteljau split in homogeneous space — the new control points sit on\n // the lifted curve, so projecting them back yields valid rational beziers\n // on each side. The split point is shared by both halves.\n const q0x = p0.x + (p1.x - p0.x) * localT\n const q0y = p0.y + (p1.y - p0.y) * localT\n const q0w = p0.z + (p1.z - p0.z) * localT\n const q1x = p1.x + (p2.x - p1.x) * localT\n const q1y = p1.y + (p2.y - p1.y) * localT\n const q1w = p1.z + (p2.z - p1.z) * localT\n const q2x = p2.x + (p3.x - p2.x) * localT\n const q2y = p2.y + (p3.y - p2.y) * localT\n const q2w = p2.z + (p3.z - p2.z) * localT\n\n const r0x = q0x + (q1x - q0x) * localT\n const r0y = q0y + (q1y - q0y) * localT\n const r0w = q0w + (q1w - q0w) * localT\n const r1x = q1x + (q2x - q1x) * localT\n const r1y = q1y + (q2y - q1y) * localT\n const r1w = q1w + (q2w - q1w) * localT\n\n const sx = r0x + (r1x - r0x) * localT\n const sy = r0y + (r1y - r0y) * localT\n const sw = r0w + (r1w - r0w) * localT\n\n const q0 = Vector3.make(q0x, q0y, q0w)\n const r0 = Vector3.make(r0x, r0y, r0w)\n const sLeft = Vector3.make(sx, sy, sw)\n const sRight = Vector3.make(sx, sy, sw)\n const r1 = Vector3.make(r1x, r1y, r1w)\n const q2 = Vector3.make(q2x, q2y, q2w)\n\n const leftPoints: Array<Vector3.Vector3> = [...homogeneous.slice(0, i * 3 + 1), q0, r0, sLeft]\n const rightPoints: Array<Vector3.Vector3> = [sRight, r1, q2, ...homogeneous.slice(i * 3 + 3)]\n\n return [new RationalBezier2dImpl(leftPoints), new RationalBezier2dImpl(rightPoints)]\n})\n\n// Bridge consumed by `Bezier2d.fromRational`. Lives here (not in the bezier\n// module) so the value-import dependency is one-directional: the rational\n// module pulls only types from `./bezier2d`, never vice versa. Returns the\n// raw control-point array; the bezier module wraps it in its own type.\nexport const toBezierPoints = (\n r: RationalBezier2d,\n): Solution.AtMostOne<ReadonlyArray<Vector2.Vector2>> => {\n const homogeneous = homogeneousOf(r)\n const w0 = (homogeneous[0] as Vector3.Vector3).z\n const points: Array<Vector2.Vector2> = []\n for (const h of homogeneous) {\n if (!epsEquals(h.z, w0)) {\n return Solution.none\n }\n points.push(Vector2.make(h.x / h.z, h.y / h.z))\n }\n return Solution.one(points)\n}\n","import * as Characteristic from '../characteristic/characteristic'\nimport * as CubicCurve2d from '../curve/cubic2d'\nimport type * as Matrix4x4 from '../matrix/matrix4x4'\nimport type { Vector2 } from '../vector/vector2'\nimport * as Vector4 from '../vector/vector4'\n\nexport function* toPointQuads(points: Iterable<Vector2>, stride: 1 | 2 | 3) {\n let p0: Vector2 | undefined\n let p1: Vector2 | undefined\n let p2: Vector2 | undefined\n let p3: Vector2 | undefined\n\n for (const point of points) {\n if (p0 === undefined) {\n p0 = point\n continue\n }\n\n if (p1 === undefined) {\n p1 = point\n continue\n }\n\n if (p2 === undefined) {\n p2 = point\n continue\n }\n\n p3 = point\n\n yield [p0, p1, p2, p3] as const\n\n if (stride === 1) {\n p0 = p1\n p1 = p2\n p2 = p3\n } else if (stride === 2) {\n p0 = p2\n p1 = p3\n p2 = undefined\n } else if (stride === 3) {\n p0 = p3\n p1 = undefined\n p2 = undefined\n }\n }\n}\n\nexport function* toCurves(\n points: Iterable<Vector2>,\n matrix: Matrix4x4.Matrix4x4,\n stride: 1 | 2 | 3,\n) {\n for (const quad of toPointQuads(points, stride)) {\n const channels = Vector4.transpose(quad, (p) => [p.x, p.y])\n yield CubicCurve2d.fromPolynomials(...Characteristic.apply(matrix, ...channels))\n }\n}\n","import * as Characteristic from '../characteristic/characteristic'\nimport * as Matrix4x4 from '../matrix/matrix4x4'\nimport * as CubicPath2d from '../path/cubic2d'\nimport { dual, Pipeable } from '../utils'\nimport * as Solution from '../solution/solution'\nimport { invariant } from '../utils'\nimport * as Vector2 from '../vector/vector2'\nimport * as Vector4 from '../vector/vector4'\nimport type { Bezier2d } from './bezier2d'\nimport type { RationalBezier2d } from './rationalBezier2d'\nimport * as RationalBezier2dInternal from './rationalBezier2d.internal'\nimport { toCurves, toPointQuads } from './util'\n\nconst characteristicInverse = Matrix4x4.inverse(Characteristic.cubicBezier)\n\n// Maps a source spline's characteristic matrix to its precomputed conversion\n// matrix `M_bezier_inverse · M_source`, so each `fromBasis` call is one\n// matrix-vector product per axis instead of running Cramer's rule per quad.\nconst conversionCache = new WeakMap<Matrix4x4.Matrix4x4, Matrix4x4.Matrix4x4>()\n\nconst getConversionMatrix = (source: Matrix4x4.Matrix4x4): Matrix4x4.Matrix4x4 => {\n let combined = conversionCache.get(source)\n if (combined === undefined) {\n combined = Matrix4x4.multiply(characteristicInverse, source)\n conversionCache.set(source, combined)\n }\n return combined\n}\n\nexport const Bezier2dTypeId = Symbol('curvy/splines/bezier2d')\nexport type Bezier2dTypeId = typeof Bezier2dTypeId\n\nclass Bezier2dImpl extends Pipeable implements Bezier2d {\n readonly [Bezier2dTypeId]: Bezier2dTypeId = Bezier2dTypeId\n\n readonly points: ReadonlyArray<Vector2.Vector2>\n\n constructor(points: ReadonlyArray<Vector2.Vector2>) {\n invariant(points.length >= 4, 'cubic splines requires 4 or more points')\n invariant(points.length % 3 === 1, 'cubic splines requires (n * 3) + 1 points')\n super()\n this.points = points\n }\n\n [Symbol.iterator]() {\n return this.points[Symbol.iterator]()\n }\n}\n\nexport const isCubicBezier2d = (p: unknown): p is Bezier2d =>\n typeof p === 'object' && p !== null && Bezier2dTypeId in p\n\nexport const make = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n) => new Bezier2dImpl([p0, p1, p2, p3])\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Vector2>) => new Bezier2dImpl(points)\n\nexport const append = dual<\n (p1: Vector2.Vector2, p2: Vector2.Vector2, p3: Vector2.Vector2) => (p: Bezier2d) => Bezier2d,\n (p: Bezier2d, p1: Vector2.Vector2, p2: Vector2.Vector2, p3: Vector2.Vector2) => Bezier2d\n>(\n 4,\n (p: Bezier2d, p1: Vector2.Vector2, p2: Vector2.Vector2, p3: Vector2.Vector2) =>\n new Bezier2dImpl((p instanceof Bezier2dImpl ? p.points : Array.from(p)).concat(p1, p2, p3)),\n)\n\nexport const fromBasis = (\n p: Iterable<Vector2.Vector2>,\n matrix: Matrix4x4.Matrix4x4,\n stride: 1 | 2 | 3,\n) => {\n const conversion = getConversionMatrix(matrix)\n\n const points: Array<Vector2.Vector2> = []\n\n let x: Vector4.Vector4 | undefined\n let y: Vector4.Vector4 | undefined\n\n for (const [p0, p1, p2, p3] of toPointQuads(p, stride)) {\n x = Matrix4x4.vectorProductLeft(conversion, Vector4.make(p0.x, p1.x, p2.x, p3.x))\n y = Matrix4x4.vectorProductLeft(conversion, Vector4.make(p0.y, p1.y, p2.y, p3.y))\n\n points.push(Vector2.make(x.x, y.x), Vector2.make(x.y, y.y), Vector2.make(x.z, y.z))\n }\n\n if (x && y) {\n points.push(Vector2.make(x.w, y.w))\n }\n\n return fromArray(points)\n}\n\nexport const appendTangentAligned = dual<\n (a: number, p5: Vector2.Vector2, p6: Vector2.Vector2) => (p: Bezier2d) => Bezier2d,\n (p: Bezier2d, a: number, p5: Vector2.Vector2, p6: Vector2.Vector2) => Bezier2d\n>(4, (p: Bezier2d, a: number, p5: Vector2.Vector2, p6: Vector2.Vector2) => {\n const points = p instanceof Bezier2dImpl ? p.points : Array.from(p)\n const p2 = points[points.length - 2] as Vector2.Vector2\n const p3 = points[points.length - 1] as Vector2.Vector2\n const p4 = Vector2.make(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a)\n\n return append(p, p4, p5, p6)\n})\n\nexport const appendCurvatureAligned = dual(\n 4,\n (p: Bezier2d, a: number, b: number, p6: Vector2.Vector2) => {\n const points = p instanceof Bezier2dImpl ? p.points : Array.from(p)\n const p1 = points[points.length - 3] as Vector2.Vector2\n const p2 = points[points.length - 2] as Vector2.Vector2\n const p3 = points[points.length - 1] as Vector2.Vector2\n\n const p4 = Vector2.make(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a)\n const p5 = Vector2.make(\n p3.x + (p3.x - p2.x) * (2 * a + a ** 2 + b / 2) + (p1.x - p2.x) * a ** 2,\n p3.y + (p3.y - p2.y) * (2 * a + a ** 2 + b / 2) + (p1.y - p2.y) * a ** 2,\n )\n\n return append(p, p4, p5, p6)\n },\n)\n\nexport const appendVelocityAligned = dual<\n (p5: Vector2.Vector2, p6: Vector2.Vector2) => (p: Bezier2d) => Bezier2d,\n (p: Bezier2d, p5: Vector2.Vector2, p6: Vector2.Vector2) => Bezier2d\n>(3, (p: Bezier2d, p5: Vector2.Vector2, p6: Vector2.Vector2) => appendTangentAligned(p, 1, p5, p6))\n\nexport const appendAccelerationAligned = dual<\n (p6: Vector2.Vector2) => (p: Bezier2d) => Bezier2d,\n (p: Bezier2d, p6: Vector2.Vector2) => Bezier2d\n>(2, (p: Bezier2d, p6: Vector2.Vector2) => {\n const points = p instanceof Bezier2dImpl ? p.points : Array.from(p)\n const p1 = points[points.length - 3] as Vector2.Vector2\n const p2 = points[points.length - 2] as Vector2.Vector2\n const p3 = points[points.length - 1] as Vector2.Vector2\n\n const p4 = Vector2.make(2 * p3.x - p2.x, 2 * p3.y - p2.y)\n const p5 = Vector2.make(p1.x + 4 * (p3.x - p2.x), p1.y + 4 * (p3.y - p2.y))\n\n return append(p, p4, p5, p6)\n})\n\nexport const toPath = (p: Bezier2d) =>\n CubicPath2d.make(...toCurves(p, Characteristic.cubicBezier, 3))\n\nexport const fromRational = (r: RationalBezier2d): Solution.AtMostOne<Bezier2d> => {\n const points = RationalBezier2dInternal.toBezierPoints(r)\n if (points._tag === 'none') {\n return points\n }\n return Solution.one(new Bezier2dImpl(points.value))\n}\n\nexport const subdivide = dual<\n (u: number) => (b: Bezier2d) => [Bezier2d, Bezier2d],\n (b: Bezier2d, u: number) => [Bezier2d, Bezier2d]\n>(2, (b: Bezier2d, u: number): [Bezier2d, Bezier2d] => {\n invariant(u > 0 && u < 1, 'subdivide parameter u must be in the open interval (0, 1)')\n\n const points = b instanceof Bezier2dImpl ? b.points : Array.from(b)\n const segmentCount = (points.length - 1) / 3\n const t = u * segmentCount\n const i = Math.floor(t)\n const localT = t - i\n\n // exact segment boundary: no de Casteljau needed, just slice\n if (localT === 0) {\n return [new Bezier2dImpl(points.slice(0, i * 3 + 1)), new Bezier2dImpl(points.slice(i * 3))]\n }\n\n const p0 = points[i * 3] as Vector2.Vector2\n const p1 = points[i * 3 + 1] as Vector2.Vector2\n const p2 = points[i * 3 + 2] as Vector2.Vector2\n const p3 = points[i * 3 + 3] as Vector2.Vector2\n\n // de Casteljau split — produces five new points between p0 and p3:\n // left half: [p0, q0, r0, s], right half: [s, r1, q2, p3]\n const q0x = p0.x + (p1.x - p0.x) * localT\n const q0y = p0.y + (p1.y - p0.y) * localT\n const q1x = p1.x + (p2.x - p1.x) * localT\n const q1y = p1.y + (p2.y - p1.y) * localT\n const q2x = p2.x + (p3.x - p2.x) * localT\n const q2y = p2.y + (p3.y - p2.y) * localT\n\n const r0x = q0x + (q1x - q0x) * localT\n const r0y = q0y + (q1y - q0y) * localT\n const r1x = q1x + (q2x - q1x) * localT\n const r1y = q1y + (q2y - q1y) * localT\n\n const sx = r0x + (r1x - r0x) * localT\n const sy = r0y + (r1y - r0y) * localT\n\n const q0 = Vector2.make(q0x, q0y)\n const r0 = Vector2.make(r0x, r0y)\n const sLeft = Vector2.make(sx, sy)\n const sRight = Vector2.make(sx, sy)\n const r1 = Vector2.make(r1x, r1y)\n const q2 = Vector2.make(q2x, q2y)\n\n const leftPoints: Array<Vector2.Vector2> = [...points.slice(0, i * 3 + 1), q0, r0, sLeft]\n const rightPoints: Array<Vector2.Vector2> = [sRight, r1, q2, ...points.slice(i * 3 + 3)]\n\n return [new Bezier2dImpl(leftPoints), new Bezier2dImpl(rightPoints)]\n})\n","import type { CubicPath2d } from '../path/cubic2d'\nimport type { Pipeable } from '../utils'\nimport type * as Solution from '../solution/solution'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Bezier2dTypeId } from './bezier2d.internal'\nimport * as internal from './bezier2d.internal'\nimport type { RationalBezier2d } from './rationalBezier2d'\n\n/**\n * A Bézier curve in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The characteristic matrix that identifies this spline family lives in the\n * `characteristic` module as `Characteristic.cubicBezier`.\n *\n * @since 1.0.0\n */\nexport interface Bezier2d extends Pipeable {\n readonly [Bezier2dTypeId]: Bezier2dTypeId\n [Symbol.iterator](): IterableIterator<Vector2>\n}\n\n/**\n * Creates a new `Bezier2d` instance.\n *\n * @param p0 - The first control point.\n * @param p1 - The second control point.\n * @param p2 - The third control point.\n * @param p3 - The fourth control point.\n * @returns A new `Bezier2d` instance.\n * @since 1.0.0\n */\nexport const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Bezier2d = internal.make\n\n/**\n * Creates a new `Bezier2d` instance from an array of control points.\n *\n * @param points - The control points.\n * @returns A new `Bezier2d` instance.\n * @since 1.0.0\n */\nexport const fromArray: (points: ReadonlyArray<Vector2>) => Bezier2d = internal.fromArray\n\n/**\n * Checks if a value is a `Bezier2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `Bezier2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicBezier2d: (p: unknown) => p is Bezier2d = internal.isCubicBezier2d\n\nexport const append: {\n /**\n * Appends control points to a `Bezier2d`.\n *\n * @param p1 - The second control point (first tangent).\n * @param p2 - The third control point (second tangent).\n * @param p3 - The fourth control point (end point).\n * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.\n */\n (p1: Vector2, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d\n /**\n * Appends control points to a `Bezier2d`.\n *\n * @param p - The `Bezier2d` to append the control points to.\n * @param p1 - The second control point (first tangent).\n * @param p2 - The third control point (second tangent).\n * @param p3 - The fourth control point (end point).\n * @returns A new `Bezier2d` instance with the appended control points.\n */\n (p: Bezier2d, p1: Vector2, p2: Vector2, p3: Vector2): Bezier2d\n} = internal.append\n\nexport const appendTangentAligned: {\n /**\n * Appends control points to a `Bezier2d` with aligned tangents.\n *\n * @param ratio - The ratio of the tangents.\n * @param p2 - The third control point (second tangent).\n * @param p3 - The fourth control point (end point).\n * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.\n */\n (ratio: number, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d\n /**\n * Appends control points to a `Bezier2d` with aligned tangents.\n *\n * @param p - The `Bezier2d` to append the control points to.\n * @param ratio - The ratio of the tangents.\n * @param p2 - The third control point (second tangent).\n * @param p3 - The fourth control point (end point).\n * @returns A new `Bezier2d` instance with the appended control points.\n */\n (p: Bezier2d, ratio: number, p2: Vector2, p3: Vector2): Bezier2d\n} = internal.appendTangentAligned\n\nexport const appendCurvatureAligned: {\n /**\n * Appends control points to a `Bezier2d` with aligned curvature (G² continuity).\n *\n * @param a - The first curvature parameter.\n * @param b - The second curvature parameter.\n * @param p6 - The sixth control point (end point).\n * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.\n */\n (a: number, b: number, p6: Vector2): (p: Bezier2d) => Bezier2d\n /**\n * Appends control points to a `Bezier2d` with aligned curvature (G² continuity).\n *\n * @param p - The `Bezier2d` to append the control points to.\n * @param a - The first curvature parameter.\n * @param b - The second curvature parameter.\n * @param p6 - The sixth control point (end point).\n * @returns A new `Bezier2d` instance with the appended control points.\n */\n (p: Bezier2d, a: number, b: number, p6: Vector2): Bezier2d\n} = internal.appendCurvatureAligned\n\nexport const appendVelocityAligned: {\n /**\n * Appends control points to a `Bezier2d` with aligned velocity.\n *\n * @param p2 - The second control point (first tangent).\n * @param p3 - The third control point (second tangent).\n * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.\n */\n (p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d\n /**\n * Appends control points to a `Bezier2d` with aligned velocity.\n *\n * @param p - The `Bezier2d` to append the control points to.\n * @param p2 - The second control point (first tangent).\n * @param p3 - The third control point (second tangent).\n * @returns A new `Bezier2d` instance with the appended control points.\n */\n (p: Bezier2d, p2: Vector2, p3: Vector2): Bezier2d\n} = internal.appendVelocityAligned\n\nexport const appendAccelerationAligned: {\n /**\n * Appends control points to a `Bezier2d` with aligned acceleration.\n *\n * @param p3 - The third control point (second tangent).\n * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.\n */\n (p3: Vector2): (p: Bezier2d) => Bezier2d\n /**\n * Appends control points to a `Bezier2d` with aligned acceleration.\n *\n * @param p - The `Bezier2d` to append the control points to.\n * @param p3 - The third control point (second tangent).\n * @returns A new `Bezier2d` instance with the appended control points.\n */\n (p: Bezier2d, p3: Vector2): Bezier2d\n} = internal.appendAccelerationAligned\n\n/**\n * Converts a `Bezier2d` to a `CubicPath2d`.\n *\n * @param p - The `Bezier2d` to convert.\n * @returns A new `CubicPath2d` instance representing the same curve as the `Bezier2d`.\n * @since 1.0.0\n */\nexport const toPath: (p: Bezier2d) => CubicPath2d = internal.toPath\n\n/**\n * Attempts to lower a `RationalBezier2d` to a non-rational `Bezier2d`.\n *\n * Succeeds with `Solution.one(bezier)` when the rational curve's weights are\n * uniform (the curve is mathematically a polynomial Bézier) and returns\n * `Solution.none` otherwise — the rational curve cannot be represented\n * exactly by a non-rational cubic Bézier.\n *\n * @param r - The rational bezier to convert.\n * @returns Either a `Bezier2d` instance or `Solution.none`.\n * @since 2.1.0\n */\nexport const fromRational: (r: RationalBezier2d) => Solution.AtMostOne<Bezier2d> =\n internal.fromRational\n\nexport const subdivide: {\n /**\n * Splits a `Bezier2d` at the given global parameter `u ∈ (0, 1)` using\n * de Casteljau's algorithm. The two returned beziers together trace the\n * same curve as the input — the left covers `[0, u]`, the right covers\n * `[u, 1]`.\n *\n * @param b - The bezier to split.\n * @param u - The split parameter in the open interval `(0, 1)`.\n * @returns A two-element tuple of the left and right halves.\n * @since 1.1.0\n */\n (b: Bezier2d, u: number): [Bezier2d, Bezier2d]\n /**\n * Splits a `Bezier2d` at the given global parameter `u ∈ (0, 1)`.\n *\n * @param u - The split parameter in the open interval `(0, 1)`.\n * @returns A function that takes a bezier and returns the two halves.\n * @since 1.1.0\n */\n (u: number): (b: Bezier2d) => [Bezier2d, Bezier2d]\n} = internal.subdivide\n","import * as Characteristic from '../characteristic/characteristic'\nimport * as CubicPath2d from '../path/cubic2d'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport * as Vector2 from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport * as bezierInternal from './bezier2d.internal'\nimport type { Cardinal2d } from './cardinal2d'\nimport { toCurves } from './util'\n\nexport const Cardinal2dTypeId: unique symbol = Symbol.for('curvy/splines/cardinal2d')\nexport type Cardinal2dTypeId = typeof Cardinal2dTypeId\n\nexport class Cardinal2dImpl extends Pipeable {\n readonly [Cardinal2dTypeId]: Cardinal2dTypeId = Cardinal2dTypeId\n\n readonly points: ReadonlyArray<Vector2.Vector2>\n\n constructor(points: ReadonlyArray<Vector2.Vector2>) {\n invariant(points.length >= 2, 'cardinal splines requires 2 or more points')\n super()\n this.points = points\n }\n\n [Symbol.iterator]() {\n return this.points[Symbol.iterator]()\n }\n}\n\nexport const isCardinal2d = (p: unknown): p is Cardinal2d =>\n typeof p === 'object' && p !== null && Cardinal2dTypeId in p\n\nexport const make = (...points: ReadonlyArray<Vector2.Vector2>) => new Cardinal2dImpl(points)\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Vector2>) => new Cardinal2dImpl(points)\n\nexport const append = dual<\n (...points: ReadonlyArray<Vector2.Vector2>) => (p: Cardinal2d) => Cardinal2d,\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) => Cardinal2d\n>(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) =>\n new Cardinal2dImpl([...p, ...points]),\n)\n\nexport const prepend = dual<\n (...points: ReadonlyArray<Vector2.Vector2>) => (p: Cardinal2d) => Cardinal2d,\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) => Cardinal2d\n>(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) =>\n new Cardinal2dImpl([...points, ...p]),\n)\n\nexport const withDuplicatedEndpoints = (p: Cardinal2d) => {\n const points = p instanceof Cardinal2dImpl ? p.points : [...p]\n return new Cardinal2dImpl([\n points[0] as Vector2.Vector2,\n ...points,\n points[points.length - 1] as Vector2.Vector2,\n ])\n}\n\nexport const withReflectedEndpoints = dual(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, scale = 1) => {\n if (scale === 0) {\n return withDuplicatedEndpoints(p)\n }\n\n const points = p instanceof Cardinal2dImpl ? p.points : [...p]\n const p0 = points[0] as Vector2.Vector2\n const p1 = points[1] as Vector2.Vector2\n\n const p2 = points[points.length - 2] as Vector2.Vector2\n const p3 = points[points.length - 1] as Vector2.Vector2\n\n return new Cardinal2dImpl([\n Vector2.subtract(p1, p0).pipe(Vector2.scale(scale), Vector2.add(p0)),\n ...points,\n Vector2.subtract(p2, p3).pipe(Vector2.scale(scale), Vector2.add(p3)),\n ])\n },\n)\n\n// `cubicCardinal(0.5)` returns the cached Catmull-Rom matrix from a shared\n// per-tension cache in the `characteristic` module — no need to special-case\n// the 0.5 path here.\nexport const toPath = dual(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, scale = 0.5) =>\n CubicPath2d.make(...toCurves(p, Characteristic.cubicCardinal(scale), 1)),\n)\n\nexport const toBezier = (p: Cardinal2d, scale = 0.5): Bezier2d =>\n bezierInternal.fromBasis(p, Characteristic.cubicCardinal(scale), 1)\n","import type { CubicPath2d } from '../path/cubic2d'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport type { Cardinal2dTypeId } from './cardinal2d.internal'\nimport * as internal from './cardinal2d.internal'\n\n/**\n * A Cardinal spline in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The characteristic matrix that identifies this spline family lives in the\n * `characteristic` module as `Characteristic.cubicCardinal(tension)` (and\n * the Catmull-Rom variant as `Characteristic.cubicCatmullRom`).\n *\n * @since 1.0.0\n */\nexport interface Cardinal2d extends Pipeable {\n readonly [Cardinal2dTypeId]: Cardinal2dTypeId\n [Symbol.iterator](): IterableIterator<Vector2>\n}\n\n/**\n * Checks if a value is a `Cardinal2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `Cardinal2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCardinal2d: (p: unknown) => p is Cardinal2d = internal.isCardinal2d\n\n/**\n * Creates a new `Cardinal2d` instance.\n *\n * @param p0 - The first control point.\n * @param p1 - The second control point.\n * @param points - The remaining control points.\n * @returns A new `Cardinal2d` instance.\n * @since 1.0.0\n */\nexport const make: (p0: Vector2, p1: Vector2, ...points: ReadonlyArray<Vector2>) => Cardinal2d =\n internal.make\n\n/**\n * Creates a new `Cardinal2d` instance from an array of control points.\n *\n * @param points - The control points.\n * @returns A new `Cardinal2d` instance.\n * @since 1.0.0\n */\nexport const fromArray: (points: ReadonlyArray<Vector2>) => Cardinal2d = internal.fromArray\n\nexport const append: {\n /**\n * Appends control points to a `Cardinal2d`.\n *\n * @param points - The control points to append.\n * @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the appended control points.\n * @since 1.0.0\n */\n (...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d\n /**\n * Appends control points to a `Cardinal2d`.\n *\n * @param c - The `Cardinal2d` to append the control points to.\n * @param points - The control points to append.\n * @returns A new `Cardinal2d` instance with the appended control points.\n * @since 1.0.0\n */\n (c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d\n} = internal.append\n\nexport const prepend: {\n /**\n * Prepends control points to a `Cardinal2d`.\n *\n * @param points - The control points to prepend.\n * @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the prepended control points.\n * @since 1.0.0\n */\n (...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d\n /**\n * Prepends control points to a `Cardinal2d`.\n *\n * @param c - The `Cardinal2d` to prepend the control points to.\n * @param points - The control points to prepend.\n * @returns A new `Cardinal2d` instance with the prepended control points.\n * @since 1.0.0\n */\n (c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d\n} = internal.prepend\n\n/**\n * Doubles the endpoints of a `Cardinal2d` spline.\n *\n * @param c - The `Cardinal2d` to duplicate the endpoints of.\n * @returns A new `Cardinal2d` instance with the duplicated endpoints.\n * @since 1.0.0\n */\nexport const withDuplicatedEndpoints: (c: Cardinal2d) => Cardinal2d =\n internal.withDuplicatedEndpoints\n\nexport const withReflectedEndpoints: {\n /**\n * Reflects the endpoints of a `Cardinal2d` spline.\n *\n * @param scale - The scale factor for the reflection.\n * @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the reflected endpoints.\n * @since 1.0.0\n */\n (scale: number): (c: Cardinal2d) => Cardinal2d\n /**\n * Reflects the endpoints of a `Cardinal2d` spline.\n *\n * @param c - The `Cardinal2d` to reflect the endpoints of.\n * @param scale - The scale factor for the reflection.\n * @returns A new `Cardinal2d` instance with the reflected endpoints.\n * @since 1.0.0\n */\n (c: Cardinal2d, scale?: number): Cardinal2d\n} = internal.withReflectedEndpoints\n\nexport const toPath: {\n /**\n * Converts a `Cardinal2d` to a `CubicPath2d`.\n *\n * @param scale - The scale factor for the conversion.\n * @returns A Function that takes a `Cardinal2d` and returns a new `CubicPath2d` instance.\n * @since 1.0.0\n */\n (scale: number): (c: Cardinal2d) => CubicPath2d\n /**\n * Converts a `Cardinal2d` to a `CubicPath2d`.\n *\n * @param c - The `Cardinal2d` to convert.\n * @param scale - The scale factor for the conversion.\n * @returns A new `CubicPath2d` instance representing the same curve as the `Cardinal2d`.\n * @since 1.0.0\n */\n (c: Cardinal2d, scale?: number): CubicPath2d\n} = internal.toPath\n\nexport const toBezier: {\n /**\n * Converts a `Cardinal2d` to a `Bezier2d`.\n *\n * @param p - The `Cardinal2d` to convert.\n * @returns A new `Bezier2d` instance representing the same curve as the `Cardinal2d`.\n * @since 1.0.0\n */\n (p: Cardinal2d): Bezier2d\n /**\n * Converts a `Cardinal2d` to a `Bezier2d`.\n *\n * @param p - The `Cardinal2d` to convert.\n * @param scale - The scale factor for the conversion.\n * @returns A new `Bezier2d` instance representing the same curve as the `Cardinal2d`.\n * @since 1.0.0\n */\n (p: Cardinal2d, scale: number): Bezier2d\n} = internal.toBezier\n","import * as Characteristic from '../characteristic/characteristic'\nimport * as CubicPath2d from '../path/cubic2d'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport type * as Vector2 from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport * as bezierInternal from './bezier2d.internal'\nimport type { Hermite2d } from './hermite2d'\nimport { toCurves } from './util'\n\nexport const Hermite2dTypeId = Symbol('curvy/splines/hermite2d')\nexport type Hermite2dTypeId = typeof Hermite2dTypeId\n\nclass Hermite2dImpl extends Pipeable implements Hermite2d {\n readonly [Hermite2dTypeId]: Hermite2dTypeId = Hermite2dTypeId\n\n readonly points: ReadonlyArray<Vector2.Vector2>\n\n constructor(points: ReadonlyArray<Vector2.Vector2>) {\n invariant(points.length >= 4, 'hermite splines requires 4 or more points')\n invariant(points.length % 2 === 0, 'hermite splines requires (n * 2) points')\n\n super()\n this.points = points\n }\n\n [Symbol.iterator]() {\n return this.points[Symbol.iterator]()\n }\n}\n\nexport const isHermite2d = (p: unknown): p is Hermite2d =>\n typeof p === 'object' && p !== null && Hermite2dTypeId in p\n\nexport const make = (\n p0: Vector2.Vector2,\n v0: Vector2.Vector2,\n p1: Vector2.Vector2,\n v1: Vector2.Vector2,\n) => new Hermite2dImpl([p0, v0, p1, v1])\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Vector2>) => new Hermite2dImpl(points)\n\nexport const append = dual<\n (p1: Vector2.Vector2, v1: Vector2.Vector2) => (p: Hermite2d) => Hermite2d,\n (p: Hermite2d, p1: Vector2.Vector2, v1: Vector2.Vector2) => Hermite2d\n>(3, (p: Hermite2d, p1: Vector2.Vector2, v1: Vector2.Vector2) => {\n const points = p instanceof Hermite2dImpl ? p.points : Array.from(p)\n return new Hermite2dImpl(points.concat(p1, v1))\n})\n\nexport const prepend = dual<\n (p0: Vector2.Vector2, v0: Vector2.Vector2) => (p: Hermite2d) => Hermite2d,\n (p: Hermite2d, p0: Vector2.Vector2, v0: Vector2.Vector2) => Hermite2d\n>(3, (p: Hermite2d, p0: Vector2.Vector2, v0: Vector2.Vector2) => {\n const points = p instanceof Hermite2dImpl ? p.points : Array.from(p)\n return new Hermite2dImpl([p0, v0].concat(points))\n})\n\nexport const toPath = (p: Hermite2d) =>\n CubicPath2d.make(...toCurves(p, Characteristic.cubicHermite, 2))\n\nexport const toBezier = (p: Hermite2d): Bezier2d =>\n bezierInternal.fromBasis(p, Characteristic.cubicHermite, 2)\n","import type { CubicPath2d } from '../path/cubic2d'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport * as internal from './hermite2d.internal'\nimport type { Hermite2dTypeId } from './hermite2d.internal'\n\n/**\n * A Hermite spline in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The characteristic matrix that identifies this spline family lives in the\n * `characteristic` module as `Characteristic.cubicHermite`.\n *\n * @since 1.0.0\n */\nexport interface Hermite2d extends Pipeable {\n readonly [Hermite2dTypeId]: Hermite2dTypeId\n\n [Symbol.iterator](): IterableIterator<Vector2>\n}\n\n/**\n * Checks if a value is a `Hermite2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `Hermite2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isHermite2d: (p: unknown) => p is Hermite2d = internal.isHermite2d\n\n/**\n * Creates a new `Hermite2d` instance.\n *\n * @param p0 - The first control point.\n * @param v0 - The first tangent vector.\n * @param p1 - The second control point.\n * @param v1 - The second tangent vector.\n * @returns A new `Hermite2d` instance.\n * @since 1.0.0\n */\nexport const make: (p0: Vector2, v0: Vector2, p1: Vector2, v1: Vector2) => Hermite2d = internal.make\n\n/**\n * Creates a new `Hermite2d` instance from an array of control points.\n *\n * @param points - The control points.\n * @returns A new `Hermite2d` instance.\n * @since 1.0.0\n */\nexport const fromArray: (points: ReadonlyArray<Vector2>) => Hermite2d = internal.fromArray\n\nexport const append: {\n /**\n * Appends a new control point and tangent vector to the Hermite spline.\n *\n * @param p1 - The new control point.\n * @param v1 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the appended control point and tangent vector.\n * @since 1.0.0\n */\n (p1: Vector2, v1: Vector2): (p: Hermite2d) => Hermite2d\n /**\n * Appends a new control point and tangent vector to the Hermite spline.\n *\n * @param p - The `Hermite2d` to append the control point and tangent vector to.\n * @param p1 - The new control point.\n * @param v1 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the appended control point and tangent vector.\n * @since 1.0.0\n */\n (p: Hermite2d, p1: Vector2, v1: Vector2): Hermite2d\n} = internal.append\n\nexport const prepend: {\n /**\n * Prepends a new control point and tangent vector to the Hermite spline.\n *\n * @param p0 - The new control point.\n * @param v0 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the prepended control point and tangent vector.\n * @since 1.0.0\n */\n (p0: Vector2, v0: Vector2): (p: Hermite2d) => Hermite2d\n /**\n * Prepends a new control point and tangent vector to the Hermite spline.\n *\n * @param p - The `Hermite2d` to prepend the control point and tangent vector to.\n * @param p0 - The new control point.\n * @param v0 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the prepended control point and tangent vector.\n * @since 1.0.0\n */\n (p: Hermite2d, p0: Vector2, v0: Vector2): Hermite2d\n} = internal.prepend\n\n/**\n * Creates a new `CubicPath2d` instance from a `Hermite2d`.\n *\n * @param p - The `Hermite2d` to convert.\n * @returns A new `CubicPath2d` instance.\n * @since 1.0.0\n */\nexport const toPath: (p: Hermite2d) => CubicPath2d = internal.toPath\n\n/**\n * Converts a `Hermite2d` to a `Bezier2d`.\n *\n * @param p - The `Hermite2d` to convert.\n * @returns A new `Bezier2d` instance.\n * @since 1.0.0\n */\nexport const toBezier: (p: Hermite2d) => Bezier2d = internal.toBezier\n","import * as Characteristic from '../characteristic/characteristic'\nimport * as CubicPath2d from '../path/cubic2d'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport type * as Vector2 from '../vector/vector2'\nimport type { Basis2d } from './basis2d'\nimport type { Bezier2d } from './bezier2d'\nimport * as bezierInternal from './bezier2d.internal'\nimport { toCurves } from './util'\n\nexport const Basis2dTypeId = Symbol('curvy/splines/basis2d')\nexport type Basis2dTypeId = typeof Basis2dTypeId\n\nclass Basis2dImpl extends Pipeable implements Basis2d {\n readonly [Basis2dTypeId]: Basis2dTypeId = Basis2dTypeId\n\n readonly points: ReadonlyArray<Vector2.Vector2>\n\n constructor(points: ReadonlyArray<Vector2.Vector2>) {\n invariant(points.length >= 4, 'basis splines requires 4 or more points')\n super()\n this.points = points\n }\n\n [Symbol.iterator]() {\n return this.points[Symbol.iterator]()\n }\n}\n\nexport const isBasis2d = (p: unknown): p is Basis2d =>\n typeof p === 'object' && p !== null && Basis2dTypeId in p\n\nexport const make = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n) => new Basis2dImpl([p0, p1, p2, p3])\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Vector2>) => new Basis2dImpl(points)\n\nexport const append = dual<\n (...points: ReadonlyArray<Vector2.Vector2>) => (p: Basis2d) => Basis2d,\n (p: Basis2d, ...points: ReadonlyArray<Vector2.Vector2>) => Basis2d\n>(\n (args) => isBasis2d(args[0]),\n (p: Basis2d, ...points: ReadonlyArray<Vector2.Vector2>) => new Basis2dImpl([...p, ...points]),\n)\n\nexport const prepend = dual<\n (...points: ReadonlyArray<Vector2.Vector2>) => (p: Basis2d) => Basis2d,\n (p: Basis2d, ...points: ReadonlyArray<Vector2.Vector2>) => Basis2d\n>(\n (args) => isBasis2d(args[0]),\n (p: Basis2d, ...points: ReadonlyArray<Vector2.Vector2>) => new Basis2dImpl([...points, ...p]),\n)\n\nexport const withTriplicatedEndpoints = (p: Basis2d) => {\n const points = p instanceof Basis2dImpl ? p.points : [...p]\n return new Basis2dImpl([\n points[0] as Vector2.Vector2,\n points[0] as Vector2.Vector2,\n ...points,\n points[points.length - 1] as Vector2.Vector2,\n points[points.length - 1] as Vector2.Vector2,\n ])\n}\n\nexport const toPath = (p: Basis2d) =>\n CubicPath2d.make(...toCurves(p, Characteristic.cubicBasisSpline, 1))\n\nexport const toBezier = (p: Basis2d): Bezier2d =>\n bezierInternal.fromBasis(p, Characteristic.cubicBasisSpline, 1)\n","import type { CubicPath2d } from '../path/cubic2d'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Basis2dTypeId } from './basis2d.internal'\nimport * as internal from './basis2d.internal'\nimport type { Bezier2d } from './bezier2d'\n\n/**\n * A Basis Spline (uniform cubic B-spline) in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The characteristic matrix that identifies this spline family lives in the\n * `characteristic` module as `Characteristic.cubicBasisSpline`.\n *\n * @since 1.0.0\n */\nexport interface Basis2d extends Pipeable {\n readonly [Basis2dTypeId]: Basis2dTypeId\n [Symbol.iterator](): Iterator<Vector2>\n}\n\n/**\n * Checks if a value is a `Basis2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `Basis2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isBasis2d: (p: unknown) => p is Basis2d = internal.isBasis2d\n\n/**\n * Creates a new `Basis2d` instance.\n *\n * @param p0 - The first control point.\n * @param p1 - The second control point.\n * @param p2 - The third control point.\n * @param p3 - The fourth control point.\n * @returns A new `Basis2d` instance.\n * @since 1.0.0\n */\nexport const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Basis2d = internal.make\n\n/**\n * Creates a new `Basis2d` instance from an array of control points.\n *\n * @param points - The control points.\n * @returns A new `Basis2d` instance.\n * @since 1.0.0\n */\nexport const fromArray: (points: ReadonlyArray<Vector2>) => Basis2d = internal.fromArray\n\nexport const append: {\n /**\n * Appends control points to a `Basis2d`.\n *\n * @param points - The control points to append.\n * @returns A function that takes a `Basis2d` and returns a new `Basis2d` instance with the appended control points.\n * @since 1.0.0\n */\n (...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d\n /**\n * Appends control points to a `Basis2d`.\n *\n * @param p - The `Basis2d` to append the control points to.\n * @param points - The control points to append.\n * @returns A new `Basis2d` instance with the appended control points.\n * @since 1.0.0\n */\n (p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d\n} = internal.append\n\nexport const prepend: {\n /**\n * Prepends control points to a `Basis2d`.\n *\n * @param points - The control points to prepend.\n * @returns A function that takes a `Basis2d` and returns a new `Basis2d` instance with the prepended control points.\n * @since 1.0.0\n */\n (...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d\n /**\n * Prepends control points to a `Basis2d`.\n *\n * @param p - The `Basis2d` to prepend the control points to.\n * @param points - The control points to prepend.\n * @returns A new `Basis2d` instance with the prepended control points.\n * @since 1.0.0\n */\n (p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d\n} = internal.prepend\n\n/**\n * Triplicates the endpoints of a `Basis2d`.\n *\n * This is useful for creating a closed loop spline.\n *\n * @param p - The `Basis2d` to triplicate the endpoints of.\n * @returns A new `Basis2d` instance with the triplicated endpoints.\n * @since 1.0.0\n */\nexport const withTriplicatedEndpoints: (p: Basis2d) => Basis2d = internal.withTriplicatedEndpoints\n\n/**\n * Creates a new `Path2d` from a `Basis2d`.\n *\n * @param p - The `Basis2d` to convert to a `Path2d`.\n * @returns A new `Path2d` instance.\n * @since 1.0.0\n */\nexport const toPath: (p: Basis2d) => CubicPath2d = internal.toPath\n\n/**\n * Converts a `Basis2d` to a `Bezier2d`.\n *\n * @param p - The `Basis2d` to convert.\n * @returns A new `Bezier2d` instance.\n * @since 1.0.0\n */\nexport const toBezier: (p: Basis2d) => Bezier2d = internal.toBezier\n","import type { RationalCubicPath2d } from '../path/rationalCubic2d'\nimport type { Pipeable } from '../utils'\nimport type { Vector2, Weighted } from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport type { RationalBezier2dTypeId } from './rationalBezier2d.internal'\nimport * as internal from './rationalBezier2d.internal'\n\n/**\n * A piecewise rational cubic Bézier curve in 2D space.\n *\n * Each control point is a `Vector2.Weighted` carrying a positive scalar\n * weight; the curve evaluates to `Σ w_i · N_i(t) · P_i / Σ w_i · N_i(t)`,\n * where `N_i` are the cubic Bernstein basis functions. With all weights\n * equal, the curve coincides with a non-rational `Bezier2d`. With unequal\n * weights, the curve can exactly represent conic sections — circles,\n * ellipses, parabolas, and hyperbolas — that polynomial Béziers can only\n * approximate.\n *\n * Internally each control point is stored in homogeneous form `(w·x, w·y, w)`,\n * so de Casteljau evaluation is three independent linear interpolations\n * followed by a single division. Iteration projects back to `Vector2.Weighted`\n * — the same shape accepted by {@link make}.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 2.1.0\n */\nexport interface RationalBezier2d extends Pipeable {\n readonly [RationalBezier2dTypeId]: RationalBezier2dTypeId\n [Symbol.iterator](): IterableIterator<Weighted>\n}\n\n/**\n * Checks if a value is a `RationalBezier2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `RationalBezier2d`, `false` otherwise.\n * @since 2.1.0\n */\nexport const isRationalBezier2d: (p: unknown) => p is RationalBezier2d = internal.isRationalBezier2d\n\n/**\n * Creates a new single-segment `RationalBezier2d` from four weighted control points.\n *\n * Equal weights produce a curve coincident with the corresponding polynomial\n * cubic Bézier; unequal weights produce a true rational curve capable of\n * representing conics exactly.\n *\n * @param p0 - The first weighted control point (curve start).\n * @param p1 - The second weighted control point (start handle).\n * @param p2 - The third weighted control point (end handle).\n * @param p3 - The fourth weighted control point (curve end).\n * @returns A new `RationalBezier2d` instance.\n * @since 2.1.0\n */\nexport const make: (p0: Weighted, p1: Weighted, p2: Weighted, p3: Weighted) => RationalBezier2d =\n internal.make\n\n/**\n * Creates a new `RationalBezier2d` from an array of weighted control points.\n *\n * The array must contain `(n * 3) + 1` entries to describe `n` joined cubic\n * segments.\n *\n * @param points - The weighted control points.\n * @returns A new `RationalBezier2d` instance.\n * @since 2.1.0\n */\nexport const fromArray: (points: ReadonlyArray<Weighted>) => RationalBezier2d = internal.fromArray\n\n/**\n * Creates a new single-segment `RationalBezier2d` from four points with all\n * weights equal to one.\n *\n * Convenience constructor for callers who want the rational evaluator but\n * don't yet have non-unit weights — the resulting curve is mathematically\n * equivalent to the corresponding `Bezier2d.make(p0, p1, p2, p3)` and can\n * later be subdivided or recombined using the rational machinery without\n * conversion overhead.\n *\n * @param p0 - The first control point (curve start).\n * @param p1 - The second control point (start handle).\n * @param p2 - The third control point (end handle).\n * @param p3 - The fourth control point (curve end).\n * @returns A new `RationalBezier2d` with unit weights.\n * @since 2.1.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => RationalBezier2d =\n internal.fromPoints\n\n/**\n * Lifts a non-rational `Bezier2d` into a `RationalBezier2d` by assigning\n * unit weight to every control point. The two curves trace the same path.\n *\n * @param b - The non-rational bezier to lift.\n * @returns A new `RationalBezier2d` with unit weights.\n * @since 2.1.0\n */\nexport const fromBezier: (b: Bezier2d) => RationalBezier2d = internal.fromBezier\n\n/**\n * Converts a `RationalBezier2d` to a `RationalCubicPath2d`.\n *\n * Each segment's four homogeneous control points are expanded into three\n * per-segment monomial cubic polynomials — `x`, `y`, and the shared\n * denominator `w` — yielding a path whose evaluator is three Horner passes\n * plus two divisions per call.\n *\n * Mirrors `Bezier2d.toPath`: spline construction is converted to path\n * evaluation form, and forward evaluation thereafter routes through the\n * path's `solve`.\n *\n * @param r - The rational bezier to convert.\n * @returns A new `RationalCubicPath2d` instance representing the same curve.\n * @since 2.1.0\n */\nexport const toPath: (r: RationalBezier2d) => RationalCubicPath2d = internal.toPath\n\nexport const subdivide: {\n /**\n * Splits a `RationalBezier2d` at the given global parameter `u ∈ (0, 1)`\n * using de Casteljau's algorithm in homogeneous coordinates. The two\n * returned beziers together trace the same curve as the input — the left\n * covers `[0, u]`, the right covers `[u, 1]`.\n *\n * The subdivided halves' control-point weights generally differ from the\n * original's even at unit input weights; this is expected and preserves\n * the curve shape exactly.\n *\n * @param r - The rational bezier to split.\n * @param u - The split parameter in the open interval `(0, 1)`.\n * @returns A two-element tuple of the left and right halves.\n * @since 2.1.0\n */\n (r: RationalBezier2d, u: number): [RationalBezier2d, RationalBezier2d]\n /**\n * Splits a `RationalBezier2d` at the given global parameter `u ∈ (0, 1)`.\n *\n * @param u - The split parameter in the open interval `(0, 1)`.\n * @returns A function that takes a rational bezier and returns the halves.\n * @since 2.1.0\n */\n (u: number): (r: RationalBezier2d) => [RationalBezier2d, RationalBezier2d]\n} = internal.subdivide\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,yBAAyB,OAAO,iCAAiC;AAQ9E,IAAM,uBAAN,cAAmC,SAAqC;CACtE,CAAU,0BAAkD;CAE5D;CAEA,YAAY,aAA6C;EACvD,UAAU,YAAY,UAAU,GAAG,kDAAkD;EACrF,UAAU,YAAY,SAAS,MAAM,GAAG,oDAAoD;EAC5F,OAAO;EACP,KAAK,cAAc;;CAGrB,EAAE,OAAO,YAAgD;EACvD,KAAK,MAAM,KAAK,KAAK,aACnB,MAAMA,aAAqB,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;;;AAK3D,MAAaC,wBAAsB,MACjC,OAAO,MAAM,YAAY,MAAM,QAAQ,0BAA0B;AAEnE,MAAM,QAAQ,MACZC,QAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO;AAExD,MAAaC,UACX,IACA,IACA,IACA,OACqB,IAAI,qBAAqB;CAAC,KAAK,GAAG;CAAE,KAAK,GAAG;CAAE,KAAK,GAAG;CAAE,KAAK,GAAG;CAAC,CAAC;AAEzF,MAAaC,eAAa,WACxB,IAAI,qBAAqB,OAAO,IAAI,KAAK,CAAC;AAE5C,MAAaC,gBACX,IACA,IACA,IACA,OAEA,IAAI,qBAAqB;CACvBH,QAAa,GAAG,GAA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;;;;;;;;;;;;;;;;;AAkB7D,MAAa,SAAuDC;AAEpE,MAAa,YAyBTC"}
package/dist/utils.d.mts CHANGED
@@ -1,205 +1,2 @@
1
- /**
2
- * @since 1.0.0
3
- */
4
- declare const PRECISION = 8;
5
- /**
6
- * Rounding function that rounds a number to a specified precision.
7
- *
8
- * @param value - The number to round.
9
- * @param precision - The number of decimal places to round to (default is 8).
10
- * @returns The rounded number.
11
- * @example
12
- * ```ts
13
- * import { round } from 'curvy/utils'
14
- *
15
- * const roundedValue = round(1.23456789, 4) // 1.2346
16
- * const roundedValue2 = round(1.23456789) // 1.23456789
17
- * ```
18
- * @since 1.0.0
19
- */
20
- declare function round(value: number, precision?: number): number;
21
- /**
22
- * Rounding function that rounds a number down to a specified precision.
23
- *
24
- * @param value - The number to round down.
25
- * @param precision - The number of decimal places to round down to (default is 8).
26
- * @returns The rounded down number.
27
- * @example
28
- * ```ts
29
- * import { roundDown } from 'curvy/utils'
30
- *
31
- * const roundedDownValue = roundDown(1.23456789, 4) // 1.2345
32
- * const roundedDownValue2 = roundDown(1.23456789) // 1.23456789
33
- * ```
34
- * @since 1.0.0
35
- */
36
- declare function roundDown(value: number, precision?: number): number;
37
- /**
38
- * Rounding function that rounds a number up to a specified precision.
39
- *
40
- * @param value - The number to round up.
41
- * @param precision - The number of decimal places to round up to (default is 8).
42
- * @returns The rounded up number.
43
- * @example
44
- * ```ts
45
- * import { roundUp } from 'curvy/utils'
46
- *
47
- * const roundedUpValue = roundUp(1.23456789, 4) // 1.2346
48
- * const roundedUpValue2 = roundUp(1.23456789) // 1.23456789
49
- * ```
50
- * @since 1.0.0
51
- */
52
- declare function roundUp(value: number, precision?: number): number;
53
- /**
54
- * Linear interpolation function.
55
- *
56
- * @param t - The interpolation factor (between 0 and 1).
57
- * @param a - The start value.
58
- * @param b - The end value.
59
- * @returns The interpolated value.
60
- * @example
61
- * ```ts
62
- * import { lerp } from 'curvy/utils'
63
- *
64
- * const interpolatedValue = lerp(0.5, 10, 20) // 15
65
- * const interpolatedValue2 = lerp(0.5)(10, 20) // 15
66
- * ```
67
- * @since 1.0.0
68
- */
69
- declare const lerp: {
70
- (t: number, a: number, b: number): number;
71
- (a: number, b: number): (t: number) => number;
72
- };
73
- /**
74
- * Normalizes a value between two bounds.
75
- *
76
- * @param x - The value to normalize.
77
- * @param a - The lower bound.
78
- * @param b - The upper bound.
79
- * @returns The normalized value.
80
- * @example
81
- * ```ts
82
- * import { normalize } from 'curvy/utils'
83
- *
84
- * const normalizedValue = normalize(15, 10, 20) // 0.5
85
- * const normalizedValue2 = normalize(10, 20)(15) // 0.5
86
- * ```
87
- * @since 1.0.0
88
- */
89
- declare const normalize: {
90
- (x: number, a: number, b: number): number;
91
- (a: number, b: number): (x: number) => number;
92
- };
93
- /**
94
- * Remaps a value from one range to another.
95
- *
96
- * @param x - The value to remap.
97
- * @param x1 - The lower bound of the original range.
98
- * @param x2 - The upper bound of the original range.
99
- * @param y1 - The lower bound of the new range.
100
- * @param y2 - The upper bound of the new range.
101
- * @returns The remapped value.
102
- * @example
103
- * ```ts
104
- * import { remap } from 'curvy/utils'
105
- *
106
- * const remappedValue = remap(15, 10, 20, 0, 100) // 50
107
- * const remappedValue2 = remap(10, 20, 0, 100)(15) // 50
108
- * ```
109
- * @since 1.0.0
110
- */
111
- declare const remap: {
112
- (x: number, x1: number, x2: number, y1: number, y2: number): number;
113
- (x1: number, x2: number, y1: number, y2: number): (x: number) => number;
114
- };
115
- /**
116
- * Clamps a value between two bounds.
117
- *
118
- * @param value - The value to clamp.
119
- * @param min - The lower bound.
120
- * @param max - The upper bound.
121
- * @returns The clamped value.
122
- * @example
123
- * ```ts
124
- * import { clamp } from 'curvy/utils'
125
- *
126
- * const clampedValue = clamp(25, 10, 20) // 20
127
- * const clampedValue2 = clamp(10, 20)(25) // 20
128
- * ```
129
- * @since 1.0.0
130
- */
131
- declare const clamp: {
132
- (value: number, min: number, max: number): number;
133
- (min: number, max: number): (value: number) => number;
134
- };
135
- /**
136
- * Clips a value to a specified range, returning a fallback value if the value is outside the range.
137
- *
138
- * @param value - The value to clip.
139
- * @param min - The lower bound.
140
- * @param max - The upper bound.
141
- * @param onClip - The fallback value to return if the value is outside the range.
142
- * @returns The clipped value or the fallback value.
143
- * @example
144
- * ```ts
145
- * import { clip } from 'curvy/utils'
146
- *
147
- * const clippedValue = clip(25, 10, 20, 15) // 15
148
- * const clippedValue2 = clip(10, 20, 15)(25) // 15
149
- * ```
150
- * @since 1.0.0
151
- */
152
- declare const clip: {
153
- <T>(value: number, min: number, max: number, onClip: T): T | number;
154
- <T>(min: number, max: number, onClip: T): (value: number) => T | number;
155
- };
156
- /**
157
- * Returns the minimum and maximum of two numbers.
158
- *
159
- * @param a - The first number.
160
- * @param b - The second number.
161
- * @returns A tuple containing the minimum and maximum values.
162
- * @example
163
- * ```ts
164
- * import { minMax } from 'curvy/utils'
165
- *
166
- * const [minValue, maxValue] = minMax(10, 20) // [10, 20]
167
- * const [minValue2, maxValue2] = minMax(20, 10) // [10, 20]
168
- * ```
169
- * @since 1.0.0
170
- */
171
- declare function minMax(a: number, b: number): [number, number];
172
- /**
173
- * Calculates the modulus of a number.
174
- *
175
- * @param n - The number to calculate the modulus of.
176
- * @param m - The modulus.
177
- * @returns The modulus of the number.
178
- * @example
179
- * ```ts
180
- * import { mod } from 'curvy/utils'
181
- *
182
- * const modulus = mod(10, 3) // 1
183
- * const modulus2 = mod(-10, 3) // 2
184
- * ```
185
- * @since 1.0.0
186
- */
187
- declare function mod(n: number, m: number): number;
188
- /**
189
- * Asserts that a condition is true, throwing an error with the provided message if it is not.
190
- *
191
- * @param condition - The condition to assert.
192
- * @param message - The error message to throw if the condition is false.
193
- * @throws An error with the provided message if the condition is false.
194
- * @example
195
- * ```ts
196
- * import { invariant } from 'curvy/utils'
197
- *
198
- * invariant(1 + 1 === 2, 'Math is broken!') // No error
199
- * invariant(1 + 1 === 3, 'Math is broken!') // Throws: Math is broken!
200
- * ```
201
- * @since 1.0.0
202
- */
203
- declare function invariant(condition: boolean, message: string): asserts condition;
204
-
205
- export { PRECISION, clamp, clip, invariant, lerp, minMax, mod, normalize, remap, round, roundDown, roundUp };
1
+ import { i as pipe, n as dual, r as invariant, t as Pipeable } from "./shared/utils-MCckigYk.mjs";
2
+ export { Pipeable, dual, invariant, pipe };
package/dist/utils.mjs CHANGED
@@ -1,56 +1,92 @@
1
- import { dual } from './pipe.mjs';
2
-
3
- const PRECISION = 8;
4
- function round(value, precision = PRECISION) {
5
- const scale = 10 ** precision;
6
- const result = Math.round(value * scale) / scale;
7
- if (result === 0) {
8
- return 0;
9
- }
10
- return result;
11
- }
12
- function roundDown(value, precision = PRECISION) {
13
- const scale = 10 ** precision;
14
- const result = Math.floor(value * scale) / scale;
15
- if (result === 0) {
16
- return 0;
17
- }
18
- return result;
19
- }
20
- function roundUp(value, precision = PRECISION) {
21
- const scale = 10 ** precision;
22
- const result = Math.ceil(value * scale) / scale;
23
- if (result === 0) {
24
- return 0;
25
- }
26
- return result;
27
- }
28
- const lerp = dual(3, (t, a, b) => {
29
- return b * t + a * (1 - t);
30
- });
31
- const normalize = dual(3, (x, a, b) => {
32
- return (x - a) / (b - a);
33
- });
34
- const remap = dual(5, (x, x1, x2, y1, y2) => {
35
- return y1 + (x - x1) / (x2 - x1) * (y2 - y1);
36
- });
37
- const clamp = dual(3, (value, min, max) => {
38
- return value < min ? min : value > max ? max : value;
39
- });
40
- const clip = dual(4, (value, min, max, onClip) => {
41
- return value < min ? onClip : value > max ? onClip : value;
42
- });
43
- function minMax(a, b) {
44
- return a < b ? [a, b] : [b, a];
45
- }
46
- function mod(n, m) {
47
- return (n % m + m) % m;
1
+ //#region src/utils.ts
2
+ const dual = (arity, body) => {
3
+ if (typeof arity === "function") {
4
+ const isDataFirst = arity;
5
+ return function() {
6
+ if (isDataFirst(arguments)) return body.apply(this, arguments);
7
+ const args = Array.prototype.slice.call(arguments);
8
+ return (self) => body(self, ...args);
9
+ };
10
+ }
11
+ switch (arity) {
12
+ case 0:
13
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
14
+ case 2: return function() {
15
+ if (arguments.length >= 2) return body(arguments[0], arguments[1]);
16
+ const a = arguments[0];
17
+ return (self) => body(self, a);
18
+ };
19
+ case 3: return function() {
20
+ if (arguments.length >= 3) return body(arguments[0], arguments[1], arguments[2]);
21
+ const a = arguments[0];
22
+ const b = arguments[1];
23
+ return (self) => body(self, a, b);
24
+ };
25
+ case 4: return function() {
26
+ if (arguments.length >= 4) return body(arguments[0], arguments[1], arguments[2], arguments[3]);
27
+ const a = arguments[0];
28
+ const b = arguments[1];
29
+ const c = arguments[2];
30
+ return (self) => body(self, a, b, c);
31
+ };
32
+ case 5: return function() {
33
+ if (arguments.length >= 5) return body(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
34
+ const a = arguments[0];
35
+ const b = arguments[1];
36
+ const c = arguments[2];
37
+ const d = arguments[3];
38
+ return (self) => body(self, a, b, c, d);
39
+ };
40
+ default: return function() {
41
+ if (arguments.length >= arity) return body.apply(this, arguments);
42
+ const args = Array.prototype.slice.call(arguments);
43
+ return (self) => body(self, ...args);
44
+ };
45
+ }
46
+ };
47
+ function pipe(...args) {
48
+ const [a, ab, bc, cd, de, ef, fg, gh, hi] = args;
49
+ switch (args.length) {
50
+ case 1: return a;
51
+ case 2: return ab(a);
52
+ case 3: return bc(ab(a));
53
+ case 4: return cd(bc(ab(a)));
54
+ case 5: return de(cd(bc(ab(a))));
55
+ case 6: return ef(de(cd(bc(ab(a)))));
56
+ case 7: return fg(ef(de(cd(bc(ab(a))))));
57
+ case 8: return gh(fg(ef(de(cd(bc(ab(a)))))));
58
+ case 9: return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
59
+ default: {
60
+ let ret = args[0];
61
+ for (let i = 1; i < args.length; i++) ret = args[i](ret);
62
+ return ret;
63
+ }
64
+ }
48
65
  }
66
+ var Pipeable = class {
67
+ pipe(...args) {
68
+ return pipe(this, ...args);
69
+ }
70
+ };
71
+ /**
72
+ * Asserts that a condition is true, throwing an error with the provided message if it is not.
73
+ *
74
+ * @param condition - The condition to assert.
75
+ * @param message - The error message to throw if the condition is false.
76
+ * @throws An error with the provided message if the condition is false.
77
+ * @example
78
+ * ```ts
79
+ * import { invariant } from 'curvy/utils'
80
+ *
81
+ * invariant(1 + 1 === 2, 'Math is broken!') // No error
82
+ * invariant(1 + 1 === 3, 'Math is broken!') // Throws: Math is broken!
83
+ * ```
84
+ * @since 1.0.0
85
+ */
49
86
  function invariant(condition, message) {
50
- if (!condition) {
51
- throw new Error(message);
52
- }
87
+ if (!condition) throw new Error(message);
53
88
  }
89
+ //#endregion
90
+ export { Pipeable, dual, invariant, pipe };
54
91
 
55
- export { PRECISION, clamp, clip, invariant, lerp, minMax, mod, normalize, remap, round, roundDown, roundUp };
56
- //# sourceMappingURL=utils.mjs.map
92
+ //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../src/utils.ts"],"sourcesContent":["import { dual } from './pipe'\n\n/**\n * @since 1.0.0\n */\nexport const PRECISION = 8\n\n/**\n * Rounding function that rounds a number to a specified precision.\n *\n * @param value - The number to round.\n * @param precision - The number of decimal places to round to (default is 8).\n * @returns The rounded number.\n * @example\n * ```ts\n * import { round } from 'curvy/utils'\n *\n * const roundedValue = round(1.23456789, 4) // 1.2346\n * const roundedValue2 = round(1.23456789) // 1.23456789\n * ```\n * @since 1.0.0\n */\nexport function round(value: number, precision = PRECISION): number {\n const scale = 10 ** precision\n const result = Math.round(value * scale) / scale\n if (result === 0) {\n return 0\n }\n return result\n}\n\n/**\n * Rounding function that rounds a number down to a specified precision.\n *\n * @param value - The number to round down.\n * @param precision - The number of decimal places to round down to (default is 8).\n * @returns The rounded down number.\n * @example\n * ```ts\n * import { roundDown } from 'curvy/utils'\n *\n * const roundedDownValue = roundDown(1.23456789, 4) // 1.2345\n * const roundedDownValue2 = roundDown(1.23456789) // 1.23456789\n * ```\n * @since 1.0.0\n */\nexport function roundDown(value: number, precision = PRECISION): number {\n const scale = 10 ** precision\n const result = Math.floor(value * scale) / scale\n if (result === 0) {\n return 0\n }\n return result\n}\n\n/**\n * Rounding function that rounds a number up to a specified precision.\n *\n * @param value - The number to round up.\n * @param precision - The number of decimal places to round up to (default is 8).\n * @returns The rounded up number.\n * @example\n * ```ts\n * import { roundUp } from 'curvy/utils'\n *\n * const roundedUpValue = roundUp(1.23456789, 4) // 1.2346\n * const roundedUpValue2 = roundUp(1.23456789) // 1.23456789\n * ```\n * @since 1.0.0\n */\nexport function roundUp(value: number, precision = PRECISION): number {\n const scale = 10 ** precision\n const result = Math.ceil(value * scale) / scale\n if (result === 0) {\n return 0\n }\n return result\n}\n\n/**\n * Linear interpolation function.\n *\n * @param t - The interpolation factor (between 0 and 1).\n * @param a - The start value.\n * @param b - The end value.\n * @returns The interpolated value.\n * @example\n * ```ts\n * import { lerp } from 'curvy/utils'\n *\n * const interpolatedValue = lerp(0.5, 10, 20) // 15\n * const interpolatedValue2 = lerp(0.5)(10, 20) // 15\n * ```\n * @since 1.0.0\n */\nexport const lerp: {\n (t: number, a: number, b: number): number\n (a: number, b: number): (t: number) => number\n} = dual(3, (t: number, a: number, b: number): number => {\n return b * t + a * (1 - t)\n})\n\n/**\n * Normalizes a value between two bounds.\n *\n * @param x - The value to normalize.\n * @param a - The lower bound.\n * @param b - The upper bound.\n * @returns The normalized value.\n * @example\n * ```ts\n * import { normalize } from 'curvy/utils'\n *\n * const normalizedValue = normalize(15, 10, 20) // 0.5\n * const normalizedValue2 = normalize(10, 20)(15) // 0.5\n * ```\n * @since 1.0.0\n */\nexport const normalize: {\n (x: number, a: number, b: number): number\n (a: number, b: number): (x: number) => number\n} = dual(3, (x: number, a: number, b: number): number => {\n return (x - a) / (b - a)\n})\n\n/**\n * Remaps a value from one range to another.\n *\n * @param x - The value to remap.\n * @param x1 - The lower bound of the original range.\n * @param x2 - The upper bound of the original range.\n * @param y1 - The lower bound of the new range.\n * @param y2 - The upper bound of the new range.\n * @returns The remapped value.\n * @example\n * ```ts\n * import { remap } from 'curvy/utils'\n *\n * const remappedValue = remap(15, 10, 20, 0, 100) // 50\n * const remappedValue2 = remap(10, 20, 0, 100)(15) // 50\n * ```\n * @since 1.0.0\n */\nexport const remap: {\n (x: number, x1: number, x2: number, y1: number, y2: number): number\n (x1: number, x2: number, y1: number, y2: number): (x: number) => number\n} = dual(5, (x: number, x1: number, x2: number, y1: number, y2: number): number => {\n return y1 + ((x - x1) / (x2 - x1)) * (y2 - y1)\n})\n\n/**\n * Clamps a value between two bounds.\n *\n * @param value - The value to clamp.\n * @param min - The lower bound.\n * @param max - The upper bound.\n * @returns The clamped value.\n * @example\n * ```ts\n * import { clamp } from 'curvy/utils'\n *\n * const clampedValue = clamp(25, 10, 20) // 20\n * const clampedValue2 = clamp(10, 20)(25) // 20\n * ```\n * @since 1.0.0\n */\nexport const clamp: {\n (value: number, min: number, max: number): number\n (min: number, max: number): (value: number) => number\n} = dual(3, (value: number, min: number, max: number) => {\n return value < min ? min : value > max ? max : value\n})\n\n/**\n * Clips a value to a specified range, returning a fallback value if the value is outside the range.\n *\n * @param value - The value to clip.\n * @param min - The lower bound.\n * @param max - The upper bound.\n * @param onClip - The fallback value to return if the value is outside the range.\n * @returns The clipped value or the fallback value.\n * @example\n * ```ts\n * import { clip } from 'curvy/utils'\n *\n * const clippedValue = clip(25, 10, 20, 15) // 15\n * const clippedValue2 = clip(10, 20, 15)(25) // 15\n * ```\n * @since 1.0.0\n */\nexport const clip: {\n <T>(value: number, min: number, max: number, onClip: T): T | number\n <T>(min: number, max: number, onClip: T): (value: number) => T | number\n} = dual(4, (value: number, min: number, max: number, onClip: unknown) => {\n return value < min ? onClip : value > max ? onClip : value\n})\n\n/**\n * Returns the minimum and maximum of two numbers.\n *\n * @param a - The first number.\n * @param b - The second number.\n * @returns A tuple containing the minimum and maximum values.\n * @example\n * ```ts\n * import { minMax } from 'curvy/utils'\n *\n * const [minValue, maxValue] = minMax(10, 20) // [10, 20]\n * const [minValue2, maxValue2] = minMax(20, 10) // [10, 20]\n * ```\n * @since 1.0.0\n */\nexport function minMax(a: number, b: number): [number, number] {\n return a < b ? [a, b] : [b, a]\n}\n\n/**\n * Calculates the modulus of a number.\n *\n * @param n - The number to calculate the modulus of.\n * @param m - The modulus.\n * @returns The modulus of the number.\n * @example\n * ```ts\n * import { mod } from 'curvy/utils'\n *\n * const modulus = mod(10, 3) // 1\n * const modulus2 = mod(-10, 3) // 2\n * ```\n * @since 1.0.0\n */\nexport function mod(n: number, m: number): number {\n return ((n % m) + m) % m\n}\n\n/**\n * Asserts that a condition is true, throwing an error with the provided message if it is not.\n *\n * @param condition - The condition to assert.\n * @param message - The error message to throw if the condition is false.\n * @throws An error with the provided message if the condition is false.\n * @example\n * ```ts\n * import { invariant } from 'curvy/utils'\n *\n * invariant(1 + 1 === 2, 'Math is broken!') // No error\n * invariant(1 + 1 === 3, 'Math is broken!') // Throws: Math is broken!\n * ```\n * @since 1.0.0\n */\nexport function invariant(condition: boolean, message: string): asserts condition {\n if (!condition) {\n throw new Error(message)\n }\n}\n"],"names":[],"mappings":";;AAKO,MAAM,SAAY,GAAA;AAiBT,SAAA,KAAA,CAAM,KAAe,EAAA,SAAA,GAAY,SAAmB,EAAA;AAClE,EAAA,MAAM,QAAQ,EAAM,IAAA,SAAA;AACpB,EAAA,MAAM,MAAS,GAAA,IAAA,CAAK,KAAM,CAAA,KAAA,GAAQ,KAAK,CAAI,GAAA,KAAA;AAC3C,EAAA,IAAI,WAAW,CAAG,EAAA;AAChB,IAAO,OAAA,CAAA;AAAA;AAET,EAAO,OAAA,MAAA;AACT;AAiBgB,SAAA,SAAA,CAAU,KAAe,EAAA,SAAA,GAAY,SAAmB,EAAA;AACtE,EAAA,MAAM,QAAQ,EAAM,IAAA,SAAA;AACpB,EAAA,MAAM,MAAS,GAAA,IAAA,CAAK,KAAM,CAAA,KAAA,GAAQ,KAAK,CAAI,GAAA,KAAA;AAC3C,EAAA,IAAI,WAAW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M,MAAS,GAAA,KAAA,GAAQ,MAAM,MAAS,GAAA,KAAA;AACvD,CAAC;AAiBe,SAAA,MAAA,CAAO,GAAW,CAA6B,EAAA;AAC7D,EAAO,OAAA,CAAA,GAAI,IAAI,CAAC,CAAA,EAAG,CAAC,CAAI,GAAA,CAAC,GAAG,CAAC,CAAA;AAC/B;AAiBgB,SAAA,GAAA,CAAI,GAAW,CAAmB,EAAA;AAChD,EAAS,OAAA,CAAA,CAAA,GAAI,IAAK,CAAK,IAAA,CAAA;AACzB;AAiBgB,SAAA,SAAA,CAAU,WAAoB,OAAoC,EAAA;AAChF,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,OAAO,CAAA;AAAA;AAE3B;;;;"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * pipe() and dual() are slightly modified versions of Effect-TS's pipe() and dual() functions.\n * https://github.com/effect-ts/core/blob/main/src/function.ts\n *\n * The original versions are licensed under the MIT license.\n * This version is licensed under the MIT license.\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: any is used to allow any argument to be passed in\ntype AnyFunction = (...args: Array<any>) => any\n\n// Per-arity helpers use `function` (not arrow) so they can read `arguments`\n// directly. V8 keeps `arguments` virtualized when only `arguments.length`\n// and individual `arguments[i]` accesses are used — no rest-args array\n// allocation per call. The generic / predicate paths fall back to materializing\n// the args because they need to forward an unknown number to either `apply`\n// or a deferred closure.\n\nexport const dual: {\n <DataLast extends AnyFunction, DataFirst extends AnyFunction>(\n arity: Parameters<DataFirst>['length'],\n body: DataFirst,\n ): DataLast & DataFirst\n <DataLast extends AnyFunction, DataFirst extends AnyFunction>(\n isDataFirst: (args: IArguments) => boolean,\n body: DataFirst,\n ): DataLast & DataFirst\n // biome-ignore lint/suspicious/noExplicitAny: dual erases its types at runtime\n} = (arity: any, body: any): any => {\n if (typeof arity === 'function') {\n const isDataFirst = arity\n return function (this: unknown) {\n if (isDataFirst(arguments)) {\n return body.apply(this, arguments)\n }\n const args = Array.prototype.slice.call(arguments)\n return (self: unknown) => body(self, ...args)\n }\n }\n\n switch (arity) {\n case 0:\n case 1:\n throw new RangeError(`Invalid arity ${arity}`)\n\n case 2:\n return function () {\n if (arguments.length >= 2) {\n return body(arguments[0], arguments[1])\n }\n const a = arguments[0]\n return (self: unknown) => body(self, a)\n }\n\n case 3:\n return function () {\n if (arguments.length >= 3) {\n return body(arguments[0], arguments[1], arguments[2])\n }\n const a = arguments[0]\n const b = arguments[1]\n return (self: unknown) => body(self, a, b)\n }\n\n case 4:\n return function () {\n if (arguments.length >= 4) {\n return body(arguments[0], arguments[1], arguments[2], arguments[3])\n }\n const a = arguments[0]\n const b = arguments[1]\n const c = arguments[2]\n return (self: unknown) => body(self, a, b, c)\n }\n\n case 5:\n return function () {\n if (arguments.length >= 5) {\n return body(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])\n }\n const a = arguments[0]\n const b = arguments[1]\n const c = arguments[2]\n const d = arguments[3]\n return (self: unknown) => body(self, a, b, c, d)\n }\n\n default:\n return function (this: unknown) {\n if (arguments.length >= arity) {\n return body.apply(this, arguments)\n }\n const args = Array.prototype.slice.call(arguments)\n return (self: unknown) => body(self, ...args)\n }\n }\n}\n\nexport function pipe<A>(a: A): A\nexport function pipe<A, B = never>(a: A, ab: (a: A) => B): B\nexport function pipe<A, B = never, C = never>(a: A, ab: (a: A) => B, bc: (b: B) => C): C\nexport function pipe<A, B = never, C = never, D = never>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n): D\nexport function pipe<A, B = never, C = never, D = never, E = never>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n): E\nexport function pipe<A, B = never, C = never, D = never, E = never, F = never>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n): F\nexport function pipe<A, B = never, C = never, D = never, E = never, F = never, G = never>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n): G\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n): H\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n): I\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n): J\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n): K\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n): L\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n): M\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n): N\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n no: (n: N) => O,\n): O\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n no: (n: N) => O,\n op: (o: O) => P,\n): P\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n no: (n: N) => O,\n op: (o: O) => P,\n pq: (p: P) => Q,\n): Q\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n no: (n: N) => O,\n op: (o: O) => P,\n pq: (p: P) => Q,\n qr: (q: Q) => R,\n): R\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n S = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n no: (n: N) => O,\n op: (o: O) => P,\n pq: (p: P) => Q,\n qr: (q: Q) => R,\n rs: (r: R) => S,\n): S\nexport function pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n S = never,\n T = never,\n>(\n a: A,\n ab: (a: A) => B,\n bc: (b: B) => C,\n cd: (c: C) => D,\n de: (d: D) => E,\n ef: (e: E) => F,\n fg: (f: F) => G,\n gh: (g: G) => H,\n hi: (h: H) => I,\n ij: (i: I) => J,\n jk: (j: J) => K,\n kl: (k: K) => L,\n lm: (l: L) => M,\n mn: (m: M) => N,\n no: (n: N) => O,\n op: (o: O) => P,\n pq: (p: P) => Q,\n qr: (q: Q) => R,\n rs: (r: R) => S,\n st: (s: S) => T,\n): T\nexport function pipe(...args: [unknown, ...Array<AnyFunction>]): unknown {\n const [a, ab, bc, cd, de, ef, fg, gh, hi] = args as [\n unknown,\n AnyFunction,\n AnyFunction,\n AnyFunction,\n AnyFunction,\n AnyFunction,\n AnyFunction,\n AnyFunction,\n AnyFunction,\n ]\n\n switch (args.length) {\n case 1:\n return a\n case 2:\n return ab(a)\n case 3:\n return bc(ab(a))\n case 4:\n return cd(bc(ab(a)))\n case 5:\n return de(cd(bc(ab(a))))\n case 6:\n return ef(de(cd(bc(ab(a)))))\n case 7:\n return fg(ef(de(cd(bc(ab(a))))))\n case 8:\n return gh(fg(ef(de(cd(bc(ab(a)))))))\n case 9:\n return hi(gh(fg(ef(de(cd(bc(ab(a))))))))\n default: {\n let ret = args[0]\n for (let i = 1; i < args.length; i++) {\n ret = (args[i] as AnyFunction)(ret)\n }\n return ret\n }\n }\n}\n\nexport class Pipeable {\n pipe<A>(this: A): A\n pipe<A, B = never>(this: A, ab: (_: A) => B): B\n pipe<A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C\n pipe<A, B = never, C = never, D = never>(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n ): D\n pipe<A, B = never, C = never, D = never, E = never>(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ): E\n pipe<A, B = never, C = never, D = never, E = never, F = never>(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n ): F\n pipe<A, B = never, C = never, D = never, E = never, F = never, G = never>(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n ): G\n pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never>(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n ): H\n pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never>(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ): I\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n ): J\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n ): K\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n ): L\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n ): M\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n ): N\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n ): O\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n ): P\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n pq: (_: P) => Q,\n ): Q\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n pq: (_: P) => Q,\n qr: (_: Q) => R,\n ): R\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n S = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n pq: (_: P) => Q,\n qr: (_: Q) => R,\n rs: (_: R) => S,\n ): S\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n S = never,\n T = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n pq: (_: P) => Q,\n qr: (_: Q) => R,\n rs: (_: R) => S,\n st: (_: S) => T,\n ): T\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n S = never,\n T = never,\n U = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n pq: (_: P) => Q,\n qr: (_: Q) => R,\n rs: (_: R) => S,\n st: (_: S) => T,\n tu: (_: T) => U,\n ): U\n pipe<\n A,\n B = never,\n C = never,\n D = never,\n E = never,\n F = never,\n G = never,\n H = never,\n I = never,\n J = never,\n K = never,\n L = never,\n M = never,\n N = never,\n O = never,\n P = never,\n Q = never,\n R = never,\n S = never,\n T = never,\n U = never,\n >(\n this: A,\n ab: (_: A) => B,\n bc: (_: B) => C,\n cd: (_: C) => D,\n de: (_: D) => E,\n ef: (_: E) => F,\n fg: (_: F) => G,\n gh: (_: G) => H,\n hi: (_: H) => I,\n ij: (_: I) => J,\n jk: (_: J) => K,\n kl: (_: K) => L,\n lm: (_: L) => M,\n mn: (_: M) => N,\n no: (_: N) => O,\n op: (_: O) => P,\n pq: (_: P) => Q,\n qr: (_: Q) => R,\n rs: (_: R) => S,\n st: (_: S) => T,\n tu: (_: T) => U,\n ): U\n pipe(...args: Array<AnyFunction>) {\n // the assertion is probably wrong but makes typescript let us spread the args into pipe()\n return pipe(this, ...(args as [AnyFunction]))\n }\n}\n\n/**\n * Asserts that a condition is true, throwing an error with the provided message if it is not.\n *\n * @param condition - The condition to assert.\n * @param message - The error message to throw if the condition is false.\n * @throws An error with the provided message if the condition is false.\n * @example\n * ```ts\n * import { invariant } from 'curvy/utils'\n *\n * invariant(1 + 1 === 2, 'Math is broken!') // No error\n * invariant(1 + 1 === 3, 'Math is broken!') // Throws: Math is broken!\n * ```\n * @since 1.0.0\n */\nexport function invariant(condition: boolean, message: string): asserts condition {\n if (!condition) {\n throw new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jD,SAAgB,UAAU,WAAoB,SAAoC;CAChF,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,QAAQ"}
@@ -0,0 +1,3 @@
1
+ import { r as vector2_d_exports } from "../shared/vector2-DPUY3_eA.mjs";
2
+ import { i as vector4_d_exports, n as vector3_d_exports } from "../shared/vector3-DqeOZtOB.mjs";
3
+ export { vector2_d_exports as Vector2, vector3_d_exports as Vector3, vector4_d_exports as Vector4 };
@@ -0,0 +1,4 @@
1
+ import { c as vector2_exports } from "../shared/vector2-CL1HDdPr.mjs";
2
+ import { n as vector3_exports } from "../shared/vector3-D-tv_aKL.mjs";
3
+ import { r as vector4_exports } from "../shared/vector4-5KbjoHVj.mjs";
4
+ export { vector2_exports as Vector2, vector3_exports as Vector3, vector4_exports as Vector4 };