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,306 @@
1
+ import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
+ import { Pipeable, dual, invariant } from "../utils.mjs";
3
+ import { n as contains } from "./interval-05CR6eBf.mjs";
4
+ //#region src/solution/solution.internal.ts
5
+ const EMPTY_ITERATOR = { next: () => ({
6
+ done: true,
7
+ value: void 0
8
+ }) };
9
+ var NoneImpl = class extends Pipeable {
10
+ _tag = "none";
11
+ length = 0;
12
+ [Symbol.iterator]() {
13
+ return EMPTY_ITERATOR;
14
+ }
15
+ };
16
+ var OneImpl = class extends Pipeable {
17
+ value;
18
+ _tag = "one";
19
+ length = 1;
20
+ constructor(value) {
21
+ super();
22
+ this.value = value;
23
+ }
24
+ [Symbol.iterator]() {
25
+ return [this.value][Symbol.iterator]();
26
+ }
27
+ };
28
+ var TwoImpl = class extends Pipeable {
29
+ values;
30
+ _tag = "two";
31
+ length = 2;
32
+ constructor(values) {
33
+ super();
34
+ this.values = values;
35
+ }
36
+ get value() {
37
+ return this.values[0];
38
+ }
39
+ [Symbol.iterator]() {
40
+ return this.values[Symbol.iterator]();
41
+ }
42
+ };
43
+ var ThreeImpl = class extends Pipeable {
44
+ values;
45
+ _tag = "three";
46
+ length = 3;
47
+ constructor(values) {
48
+ super();
49
+ this.values = values;
50
+ }
51
+ get value() {
52
+ return this.values[0];
53
+ }
54
+ [Symbol.iterator]() {
55
+ return this.values[Symbol.iterator]();
56
+ }
57
+ };
58
+ const NONE_INSTANCE = new NoneImpl();
59
+ const none$1 = NONE_INSTANCE;
60
+ const one$1 = (value) => new OneImpl(value);
61
+ const two$1 = (a, b) => new TwoImpl([a, b]);
62
+ const three$1 = (a, b, c) => new ThreeImpl([
63
+ a,
64
+ b,
65
+ c
66
+ ]);
67
+ const fromArray$1 = (arr) => {
68
+ switch (arr.length) {
69
+ case 0: return NONE_INSTANCE;
70
+ case 1: return one$1(arr[0]);
71
+ case 2: return two$1(arr[0], arr[1]);
72
+ case 3: return three$1(arr[0], arr[1], arr[2]);
73
+ default: invariant(false, `Solution can hold at most 3 values, got ${arr.length}`);
74
+ }
75
+ };
76
+ const isNone$1 = (s) => s._tag === "none";
77
+ const isSome$1 = (s) => s._tag !== "none";
78
+ const valueOrUndefined$1 = (s) => isNone$1(s) ? void 0 : s.value;
79
+ const last$1 = ((s) => {
80
+ switch (s._tag) {
81
+ case "none": return;
82
+ case "one": return s.value;
83
+ case "two": return s.values[1];
84
+ case "three": return s.values[2];
85
+ }
86
+ });
87
+ const min$1 = ((s) => {
88
+ switch (s._tag) {
89
+ case "none": return;
90
+ case "one": return s.value;
91
+ case "two": return Math.min(s.values[0], s.values[1]);
92
+ case "three": return Math.min(s.values[0], s.values[1], s.values[2]);
93
+ }
94
+ });
95
+ const max$1 = ((s) => {
96
+ switch (s._tag) {
97
+ case "none": return;
98
+ case "one": return s.value;
99
+ case "two": return Math.max(s.values[0], s.values[1]);
100
+ case "three": return Math.max(s.values[0], s.values[1], s.values[2]);
101
+ }
102
+ });
103
+ const unsafeLast$1 = (s) => {
104
+ invariant(isSome$1(s), "Solution.unsafeLast on empty Solution");
105
+ return last$1(s);
106
+ };
107
+ const unsafeMin$1 = (s) => {
108
+ invariant(isSome$1(s), "Solution.unsafeMin on empty Solution");
109
+ return min$1(s);
110
+ };
111
+ const unsafeMax$1 = (s) => {
112
+ invariant(isSome$1(s), "Solution.unsafeMax on empty Solution");
113
+ return max$1(s);
114
+ };
115
+ const filter$1 = (s, predicate) => {
116
+ switch (s._tag) {
117
+ case "none": return s;
118
+ case "one": return predicate(s.value) ? s : NONE_INSTANCE;
119
+ case "two": {
120
+ const a = predicate(s.values[0]);
121
+ const b = predicate(s.values[1]);
122
+ if (a && b) return s;
123
+ if (a) return one$1(s.values[0]);
124
+ if (b) return one$1(s.values[1]);
125
+ return NONE_INSTANCE;
126
+ }
127
+ case "three": {
128
+ const survivors = [];
129
+ if (predicate(s.values[0])) survivors.push(s.values[0]);
130
+ if (predicate(s.values[1])) survivors.push(s.values[1]);
131
+ if (predicate(s.values[2])) survivors.push(s.values[2]);
132
+ return fromArray$1(survivors);
133
+ }
134
+ }
135
+ };
136
+ const clip$1 = dual(2, (s, i) => filter$1(s, (v) => contains(i, v)));
137
+ const map$1 = dual(2, (s, f) => {
138
+ switch (s._tag) {
139
+ case "none": return s;
140
+ case "one": return one$1(f(s.value));
141
+ case "two": return two$1(f(s.values[0]), f(s.values[1]));
142
+ case "three": return three$1(f(s.values[0]), f(s.values[1]), f(s.values[2]));
143
+ }
144
+ });
145
+ const match$1 = dual(2, (self, matcher) => isNone$1(self) ? matcher.onNone() : matcher.onSome(self));
146
+ //#endregion
147
+ //#region src/solution/solution.ts
148
+ var solution_exports = /* @__PURE__ */ __exportAll({
149
+ clip: () => clip,
150
+ filter: () => filter,
151
+ fromArray: () => fromArray,
152
+ isNone: () => isNone,
153
+ isSome: () => isSome,
154
+ last: () => last,
155
+ map: () => map,
156
+ match: () => match,
157
+ max: () => max,
158
+ min: () => min,
159
+ none: () => none,
160
+ one: () => one,
161
+ three: () => three,
162
+ two: () => two,
163
+ unsafeLast: () => unsafeLast,
164
+ unsafeMax: () => unsafeMax,
165
+ unsafeMin: () => unsafeMin,
166
+ valueOrUndefined: () => valueOrUndefined
167
+ });
168
+ /**
169
+ * The empty solution. Reused across calls — never reallocated.
170
+ *
171
+ * @since 2.0.0
172
+ */
173
+ const none = none$1;
174
+ /**
175
+ * Constructs a single-value solution.
176
+ *
177
+ * @since 2.0.0
178
+ */
179
+ const one = one$1;
180
+ /**
181
+ * Constructs a two-value solution.
182
+ *
183
+ * @since 2.0.0
184
+ */
185
+ const two = two$1;
186
+ /**
187
+ * Constructs a three-value solution.
188
+ *
189
+ * @since 2.0.0
190
+ */
191
+ const three = three$1;
192
+ /**
193
+ * Constructs a `Solution<T>` from a runtime array. Throws if the array has
194
+ * more than three elements.
195
+ *
196
+ * @since 2.0.0
197
+ */
198
+ const fromArray = fromArray$1;
199
+ /**
200
+ * Type-narrowing predicate: refines `Solution<T>` to `None`.
201
+ *
202
+ * @since 2.0.0
203
+ */
204
+ const isNone = isNone$1;
205
+ /**
206
+ * Type-narrowing predicate: refines `Solution<T>` to `Some<T>` (non-empty).
207
+ * After narrowing, `.value` is directly accessible without further checks.
208
+ *
209
+ * @since 2.0.0
210
+ */
211
+ const isSome = isSome$1;
212
+ /**
213
+ * Returns the primary (first) value if the solution is non-empty, or
214
+ * `undefined` if empty. Pair with `.value` access on `Some<T>`-narrowed
215
+ * inputs to avoid the `undefined` possibility.
216
+ *
217
+ * @since 2.0.0
218
+ */
219
+ const valueOrUndefined = valueOrUndefined$1;
220
+ /**
221
+ * Returns the last value in the solution, or `undefined` if empty. When
222
+ * called on a `Some<T>`, the result is guaranteed to be `T`.
223
+ *
224
+ * @since 2.0.0
225
+ */
226
+ const last = last$1;
227
+ /**
228
+ * Returns the smallest numeric value in the solution, or `undefined` if empty.
229
+ * When called on a `Some<number>`, the result is guaranteed to be `number`.
230
+ *
231
+ * @since 2.0.0
232
+ */
233
+ const min = min$1;
234
+ /**
235
+ * Returns the largest numeric value in the solution, or `undefined` if empty.
236
+ * When called on a `Some<number>`, the result is guaranteed to be `number`.
237
+ *
238
+ * @since 2.0.0
239
+ */
240
+ const max = max$1;
241
+ /**
242
+ * Returns the last value in the solution. Throws if empty.
243
+ *
244
+ * @since 2.0.0
245
+ */
246
+ const unsafeLast = unsafeLast$1;
247
+ /**
248
+ * Returns the smallest numeric value in the solution. Throws on empty.
249
+ *
250
+ * @since 2.0.0
251
+ */
252
+ const unsafeMin = unsafeMin$1;
253
+ /**
254
+ * Returns the largest numeric value in the solution. Throws on empty.
255
+ *
256
+ * @since 2.0.0
257
+ */
258
+ const unsafeMax = unsafeMax$1;
259
+ /**
260
+ * Filters the solution by a predicate. Result cardinality is at most that of
261
+ * the input.
262
+ *
263
+ * @since 2.0.0
264
+ */
265
+ const filter = filter$1;
266
+ /**
267
+ * Restricts the solution to values contained within an interval. Endpoint
268
+ * inclusivity follows the interval's `kind` — pass an open variant (e.g.
269
+ * `Interval.makeOpen(0, 1)` or `Interval.unitOpen`) for strict containment.
270
+ *
271
+ * @param s - The solution to clip.
272
+ * @param i - The interval to retain values within.
273
+ * @since 2.0.0
274
+ */
275
+ const clip = clip$1;
276
+ /**
277
+ * Maps every value in the solution to a new value. Result cardinality matches
278
+ * the input.
279
+ *
280
+ * @since 2.0.0
281
+ */
282
+ const map = map$1;
283
+ /**
284
+ * Pattern matches on a solution, calling `onNone` for the empty case and
285
+ * `onSome` for any non-empty case. The `onSome` parameter is typed against
286
+ * the input's narrowed shape — for an `AtMostOne<T>` input, `onSome` receives
287
+ * `One<T>` and can read `.value` directly.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * const result = polynomial.pipe(
292
+ * LinearPolynomial.solveInverse(0),
293
+ * Solution.match({
294
+ * onNone: () => null,
295
+ * onSome: ({ value }) => Math.abs(value),
296
+ * }),
297
+ * )
298
+ * ```
299
+ *
300
+ * @since 2.0.0
301
+ */
302
+ const match = match$1;
303
+ //#endregion
304
+ export { match as a, solution_exports as c, map as i, two as l, fromArray as n, none as o, isNone as r, one as s, clip as t };
305
+
306
+ //# sourceMappingURL=solution-CrtLfqEq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solution-CrtLfqEq.mjs","names":["none","one","two","three","fromArray","isNone","isSome","valueOrUndefined","last","min","max","unsafeLast","unsafeMin","unsafeMax","filter","clip","Interval.contains","map","match","internal.none","internal.one","internal.two","internal.three","internal.fromArray","internal.isNone","internal.isSome","internal.valueOrUndefined","internal.last","internal.min","internal.max","internal.unsafeLast","internal.unsafeMin","internal.unsafeMax","internal.filter","internal.clip","internal.map","internal.match"],"sources":["../../src/solution/solution.internal.ts","../../src/solution/solution.ts"],"sourcesContent":["import * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport type {\n AtMostOne,\n AtMostThree,\n AtMostTwo,\n None,\n One,\n Solution,\n Some,\n Three,\n Two,\n} from './solution'\nimport { invariant } from '../utils'\n\n// Empty iterator — shared across all None instances since None has no data.\nconst EMPTY_ITERATOR: Iterator<never> = {\n next: () => ({ done: true, value: undefined as never }),\n}\n\nclass NoneImpl extends Pipeable implements None {\n readonly _tag = 'none' as const\n readonly length = 0 as const;\n\n [Symbol.iterator](): Iterator<never> {\n return EMPTY_ITERATOR\n }\n}\n\nclass OneImpl<T> extends Pipeable implements One<T> {\n readonly _tag = 'one' as const\n readonly length = 1 as const\n\n constructor(readonly value: T) {\n super()\n }\n\n [Symbol.iterator](): Iterator<T> {\n return [this.value][Symbol.iterator]()\n }\n}\n\nclass TwoImpl<T> extends Pipeable implements Two<T> {\n readonly _tag = 'two' as const\n readonly length = 2 as const\n\n constructor(readonly values: readonly [T, T]) {\n super()\n }\n\n get value(): T {\n return this.values[0]\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this.values[Symbol.iterator]()\n }\n}\n\nclass ThreeImpl<T> extends Pipeable implements Three<T> {\n readonly _tag = 'three' as const\n readonly length = 3 as const\n\n constructor(readonly values: readonly [T, T, T]) {\n super()\n }\n\n get value(): T {\n return this.values[0]\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this.values[Symbol.iterator]()\n }\n}\n\nexport const NONE_INSTANCE: None = new NoneImpl()\n\nexport const none: None = NONE_INSTANCE\n\nexport const one = <T>(value: T): One<T> => new OneImpl(value)\n\nexport const two = <T>(a: T, b: T): Two<T> => new TwoImpl([a, b])\n\nexport const three = <T>(a: T, b: T, c: T): Three<T> => new ThreeImpl([a, b, c])\n\nexport const fromArray = <T>(arr: ReadonlyArray<T>): Solution<T> => {\n switch (arr.length) {\n case 0:\n return NONE_INSTANCE\n case 1:\n return one(arr[0] as T)\n case 2:\n return two(arr[0] as T, arr[1] as T)\n case 3:\n return three(arr[0] as T, arr[1] as T, arr[2] as T)\n default:\n invariant(false, `Solution can hold at most 3 values, got ${arr.length}`)\n }\n}\n\nexport const isNone = <T>(s: Solution<T>): s is None => s._tag === 'none'\n\nexport const isSome = <T>(s: Solution<T>): s is Some<T> => s._tag !== 'none'\n\nexport const valueOrUndefined = <T>(s: Solution<T>): T | undefined =>\n isNone(s) ? undefined : s.value\n\nexport const last: {\n <T>(s: Some<T>): T\n <T>(s: Solution<T>): T | undefined\n} = (<T>(s: Solution<T>): T | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return s.values[1]\n case 'three':\n return s.values[2]\n }\n}) as never\n\nexport const min: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = ((s: Solution<number>): number | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return Math.min(s.values[0], s.values[1])\n case 'three':\n return Math.min(s.values[0], s.values[1], s.values[2])\n }\n}) as never\n\nexport const max: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = ((s: Solution<number>): number | undefined => {\n switch (s._tag) {\n case 'none':\n return undefined\n case 'one':\n return s.value\n case 'two':\n return Math.max(s.values[0], s.values[1])\n case 'three':\n return Math.max(s.values[0], s.values[1], s.values[2])\n }\n}) as never\n\nexport const unsafeLast = <T>(s: Solution<T>): T => {\n invariant(isSome(s), 'Solution.unsafeLast on empty Solution')\n return last(s)\n}\n\nexport const unsafeMin = (s: Solution<number>): number => {\n invariant(isSome(s), 'Solution.unsafeMin on empty Solution')\n return min(s)\n}\n\nexport const unsafeMax = (s: Solution<number>): number => {\n invariant(isSome(s), 'Solution.unsafeMax on empty Solution')\n return max(s)\n}\n\nexport const filter = <T>(s: Solution<T>, predicate: (v: T) => boolean): Solution<T> => {\n switch (s._tag) {\n case 'none':\n return s\n case 'one':\n return predicate(s.value) ? s : NONE_INSTANCE\n case 'two': {\n const a = predicate(s.values[0])\n const b = predicate(s.values[1])\n if (a && b) {\n return s\n }\n if (a) {\n return one(s.values[0])\n }\n if (b) {\n return one(s.values[1])\n }\n return NONE_INSTANCE\n }\n case 'three': {\n const survivors: Array<T> = []\n if (predicate(s.values[0])) {\n survivors.push(s.values[0])\n }\n if (predicate(s.values[1])) {\n survivors.push(s.values[1])\n }\n if (predicate(s.values[2])) {\n survivors.push(s.values[2])\n }\n return fromArray(survivors)\n }\n }\n}\n\nexport const clip = dual(\n 2,\n (s: Solution<number>, i: Interval.Interval): Solution<number> =>\n filter(s, (v) => Interval.contains(i, v)),\n)\n\nexport const map = dual(2, <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B> => {\n switch (s._tag) {\n case 'none':\n return s\n case 'one':\n return one(f(s.value))\n case 'two':\n return two(f(s.values[0]), f(s.values[1]))\n case 'three':\n return three(f(s.values[0]), f(s.values[1]), f(s.values[2]))\n }\n})\n\nexport const match = dual(\n 2,\n <T, A, B>(\n self: Solution<T>,\n matcher: { readonly onNone: () => A; readonly onSome: (s: Some<T>) => B },\n ): A | B => (isNone(self) ? matcher.onNone() : matcher.onSome(self)),\n)\n\n// Re-export type aliases that the namespace consumers expect to see at runtime.\n// (Pure type re-exports — no runtime cost.)\nexport type { AtMostOne, AtMostThree, AtMostTwo, None, One, Solution, Some, Three, Two }\n","import type { Interval } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport * as internal from './solution.internal'\n\n/**\n * A `Solution<T>` represents the result of an operation that may produce\n * between zero and three values of `T`. It generalizes the zoo of \"0 or 1\",\n * \"0 to 2\", \"0 to 3\" return shapes used throughout curvy under one type, and\n * provides a small namespace of operations (`value`, `last`, `min`, `max`,\n * `filter`, `map`, `match`, …) for working with the result.\n *\n * Each variant carries a `_tag` discriminator and a `length` field, is\n * iterable via `Symbol.iterator` (so existing `for..of` and spread patterns\n * keep working), and is `Pipeable` (so a `Solution` value can be the head of\n * a `pipe` chain).\n *\n * Variant-specific accessors:\n * - `One<T>`, `Two<T>`, and `Three<T>` all expose `.value: T` (the first /\n * primary value).\n * - `Two<T>` and `Three<T>` additionally expose `.values: readonly [T, ...]`\n * for explicit positional access.\n *\n * Operations that return narrower cardinalities (e.g. inverse-solving a\n * monotonic polynomial) use the `AtMost{One,Two,Three}` aliases to express\n * \"this could be empty, but it'll have at most N values.\"\n *\n * @since 2.0.0\n */\nexport type Solution<T> = None | One<T> | Two<T> | Three<T>\n\n/**\n * The empty solution.\n *\n * @since 2.0.0\n */\nexport interface None extends Pipeable, Iterable<never> {\n readonly _tag: 'none'\n readonly length: 0\n}\n\n/** @since 2.0.0 */\nexport interface One<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'one'\n readonly length: 1\n readonly value: T\n}\n\n/** @since 2.0.0 */\nexport interface Two<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'two'\n readonly length: 2\n readonly value: T\n readonly values: readonly [T, T]\n}\n\n/** @since 2.0.0 */\nexport interface Three<T> extends Pipeable, Iterable<T> {\n readonly _tag: 'three'\n readonly length: 3\n readonly value: T\n readonly values: readonly [T, T, T]\n}\n\n/**\n * Any non-empty solution. All `Some<T>` values expose `.value: T` directly —\n * no narrowing required to read the primary value.\n *\n * @since 2.0.0\n */\nexport type Some<T> = One<T> | Two<T> | Three<T>\n\n/**\n * `None | One<T>` — return type of operations that produce at most one value\n * (e.g. inverse-solving a strictly monotonic polynomial).\n *\n * @since 2.0.0\n */\nexport type AtMostOne<T> = None | One<T>\n\n/**\n * `None | One<T> | Two<T>` — return type of operations that produce at most\n * two values (e.g. inverse-solving an unrestricted quadratic polynomial).\n *\n * @since 2.0.0\n */\nexport type AtMostTwo<T> = None | One<T> | Two<T>\n\n/**\n * `None | One<T> | Two<T> | Three<T>` — equivalent to `Solution<T>`.\n *\n * @since 2.0.0\n */\nexport type AtMostThree<T> = Solution<T>\n\n/**\n * The empty solution. Reused across calls — never reallocated.\n *\n * @since 2.0.0\n */\nexport const none: None = internal.none\n\n/**\n * Constructs a single-value solution.\n *\n * @since 2.0.0\n */\nexport const one: <T>(value: T) => One<T> = internal.one\n\n/**\n * Constructs a two-value solution.\n *\n * @since 2.0.0\n */\nexport const two: <T>(a: T, b: T) => Two<T> = internal.two\n\n/**\n * Constructs a three-value solution.\n *\n * @since 2.0.0\n */\nexport const three: <T>(a: T, b: T, c: T) => Three<T> = internal.three\n\n/**\n * Constructs a `Solution<T>` from a runtime array. Throws if the array has\n * more than three elements.\n *\n * @since 2.0.0\n */\nexport const fromArray: <T>(arr: ReadonlyArray<T>) => Solution<T> = internal.fromArray\n\n/**\n * Type-narrowing predicate: refines `Solution<T>` to `None`.\n *\n * @since 2.0.0\n */\nexport const isNone: <T>(s: Solution<T>) => s is None = internal.isNone\n\n/**\n * Type-narrowing predicate: refines `Solution<T>` to `Some<T>` (non-empty).\n * After narrowing, `.value` is directly accessible without further checks.\n *\n * @since 2.0.0\n */\nexport const isSome: <T>(s: Solution<T>) => s is Some<T> = internal.isSome\n\n/**\n * Returns the primary (first) value if the solution is non-empty, or\n * `undefined` if empty. Pair with `.value` access on `Some<T>`-narrowed\n * inputs to avoid the `undefined` possibility.\n *\n * @since 2.0.0\n */\nexport const valueOrUndefined: <T>(s: Solution<T>) => T | undefined = internal.valueOrUndefined\n\n/**\n * Returns the last value in the solution, or `undefined` if empty. When\n * called on a `Some<T>`, the result is guaranteed to be `T`.\n *\n * @since 2.0.0\n */\nexport const last: {\n <T>(s: Some<T>): T\n <T>(s: Solution<T>): T | undefined\n} = internal.last\n\n/**\n * Returns the smallest numeric value in the solution, or `undefined` if empty.\n * When called on a `Some<number>`, the result is guaranteed to be `number`.\n *\n * @since 2.0.0\n */\nexport const min: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = internal.min\n\n/**\n * Returns the largest numeric value in the solution, or `undefined` if empty.\n * When called on a `Some<number>`, the result is guaranteed to be `number`.\n *\n * @since 2.0.0\n */\nexport const max: {\n (s: Some<number>): number\n (s: Solution<number>): number | undefined\n} = internal.max\n\n/**\n * Returns the last value in the solution. Throws if empty.\n *\n * @since 2.0.0\n */\nexport const unsafeLast: <T>(s: Solution<T>) => T = internal.unsafeLast\n\n/**\n * Returns the smallest numeric value in the solution. Throws on empty.\n *\n * @since 2.0.0\n */\nexport const unsafeMin: (s: Solution<number>) => number = internal.unsafeMin\n\n/**\n * Returns the largest numeric value in the solution. Throws on empty.\n *\n * @since 2.0.0\n */\nexport const unsafeMax: (s: Solution<number>) => number = internal.unsafeMax\n\n/**\n * Filters the solution by a predicate. Result cardinality is at most that of\n * the input.\n *\n * @since 2.0.0\n */\nexport const filter: <T>(s: Solution<T>, predicate: (v: T) => boolean) => Solution<T> =\n internal.filter\n\n/**\n * Restricts the solution to values contained within an interval. Endpoint\n * inclusivity follows the interval's `kind` — pass an open variant (e.g.\n * `Interval.makeOpen(0, 1)` or `Interval.unitOpen`) for strict containment.\n *\n * @param s - The solution to clip.\n * @param i - The interval to retain values within.\n * @since 2.0.0\n */\nexport const clip: {\n (i: Interval): (s: Solution<number>) => Solution<number>\n (s: Solution<number>, i: Interval): Solution<number>\n} = internal.clip\n\n/**\n * Maps every value in the solution to a new value. Result cardinality matches\n * the input.\n *\n * @since 2.0.0\n */\nexport const map: {\n <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B>\n <A, B>(f: (v: A) => B): (s: Solution<A>) => Solution<B>\n} = internal.map\n\n// Drops `None` from the union of the input solution type — used by `match` to\n// give `onSome` a tighter parameter type. Distributive: a `Solution.AtMostOne<T>`\n// becomes `One<T>`; a full `Solution<T>` keeps `Some<T>`.\ntype SomeOf<S> = S extends None ? never : S\n\n/**\n * Pattern matches on a solution, calling `onNone` for the empty case and\n * `onSome` for any non-empty case. The `onSome` parameter is typed against\n * the input's narrowed shape — for an `AtMostOne<T>` input, `onSome` receives\n * `One<T>` and can read `.value` directly.\n *\n * @example\n * ```ts\n * const result = polynomial.pipe(\n * LinearPolynomial.solveInverse(0),\n * Solution.match({\n * onNone: () => null,\n * onSome: ({ value }) => Math.abs(value),\n * }),\n * )\n * ```\n *\n * @since 2.0.0\n */\nexport const match: {\n <S extends Solution<unknown>, A, B>(\n self: S,\n matcher: { readonly onNone: () => A; readonly onSome: (s: SomeOf<S>) => B },\n ): A | B\n <S extends Solution<unknown>, A, B>(matcher: {\n readonly onNone: () => A\n readonly onSome: (s: SomeOf<S>) => B\n }): (self: S) => A | B\n} = internal.match as never\n"],"mappings":";;;;AAgBA,MAAM,iBAAkC,EACtC,aA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;;;;;;;;;;;;;;;;;;;;;;ACrID,MAAa,OAAac;;;;;;AAO1B,MAAa,MAA+BC;;;;;;AAO5C,MAAa,MAAiCC;;;;;;AAO9C,MAAa,QAA2CC;;;;;;;AAQxD,MAAa,YAAuDC;;;;;;AAOpE,MAAa,SAA2CC;;;;;;;AAQxD,MAAa,SAA8CC;;;;;;;;AAS3D,MAAa,mBAAyDC;;;;;;;AAQtE,MAAa,OAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;AAOJ,MAAa,aAAuCC;;;;;;AAOpD,MAAa,YAA6CC;;;;;;AAO1D,MAAa,YAA6CC;;;;;;;AAQ1D,MAAa,SACXC;;;;;;;;;;AAWF,MAAa,OAGTC;;;;;;;AAQJ,MAAa,MAGTC;;;;;;;;;;;;;;;;;;;;AA0BJ,MAAa,QASTC"}
@@ -0,0 +1,251 @@
1
+ import { t as Pipeable } from "./utils-MCckigYk.mjs";
2
+ import { r as Interval } from "./interval-Dy-RMEE3.mjs";
3
+
4
+ //#region src/solution/solution.d.ts
5
+ declare namespace solution_d_exports {
6
+ export { AtMostOne, AtMostThree, AtMostTwo, None, One, Solution, Some, Three, Two, clip, filter, fromArray, isNone, isSome, last, map, match, max, min, none, one, three, two, unsafeLast, unsafeMax, unsafeMin, valueOrUndefined };
7
+ }
8
+ /**
9
+ * A `Solution<T>` represents the result of an operation that may produce
10
+ * between zero and three values of `T`. It generalizes the zoo of "0 or 1",
11
+ * "0 to 2", "0 to 3" return shapes used throughout curvy under one type, and
12
+ * provides a small namespace of operations (`value`, `last`, `min`, `max`,
13
+ * `filter`, `map`, `match`, …) for working with the result.
14
+ *
15
+ * Each variant carries a `_tag` discriminator and a `length` field, is
16
+ * iterable via `Symbol.iterator` (so existing `for..of` and spread patterns
17
+ * keep working), and is `Pipeable` (so a `Solution` value can be the head of
18
+ * a `pipe` chain).
19
+ *
20
+ * Variant-specific accessors:
21
+ * - `One<T>`, `Two<T>`, and `Three<T>` all expose `.value: T` (the first /
22
+ * primary value).
23
+ * - `Two<T>` and `Three<T>` additionally expose `.values: readonly [T, ...]`
24
+ * for explicit positional access.
25
+ *
26
+ * Operations that return narrower cardinalities (e.g. inverse-solving a
27
+ * monotonic polynomial) use the `AtMost{One,Two,Three}` aliases to express
28
+ * "this could be empty, but it'll have at most N values."
29
+ *
30
+ * @since 2.0.0
31
+ */
32
+ type Solution<T> = None | One<T> | Two<T> | Three<T>;
33
+ /**
34
+ * The empty solution.
35
+ *
36
+ * @since 2.0.0
37
+ */
38
+ interface None extends Pipeable, Iterable<never> {
39
+ readonly _tag: 'none';
40
+ readonly length: 0;
41
+ }
42
+ /** @since 2.0.0 */
43
+ interface One<T> extends Pipeable, Iterable<T> {
44
+ readonly _tag: 'one';
45
+ readonly length: 1;
46
+ readonly value: T;
47
+ }
48
+ /** @since 2.0.0 */
49
+ interface Two<T> extends Pipeable, Iterable<T> {
50
+ readonly _tag: 'two';
51
+ readonly length: 2;
52
+ readonly value: T;
53
+ readonly values: readonly [T, T];
54
+ }
55
+ /** @since 2.0.0 */
56
+ interface Three<T> extends Pipeable, Iterable<T> {
57
+ readonly _tag: 'three';
58
+ readonly length: 3;
59
+ readonly value: T;
60
+ readonly values: readonly [T, T, T];
61
+ }
62
+ /**
63
+ * Any non-empty solution. All `Some<T>` values expose `.value: T` directly —
64
+ * no narrowing required to read the primary value.
65
+ *
66
+ * @since 2.0.0
67
+ */
68
+ type Some<T> = One<T> | Two<T> | Three<T>;
69
+ /**
70
+ * `None | One<T>` — return type of operations that produce at most one value
71
+ * (e.g. inverse-solving a strictly monotonic polynomial).
72
+ *
73
+ * @since 2.0.0
74
+ */
75
+ type AtMostOne<T> = None | One<T>;
76
+ /**
77
+ * `None | One<T> | Two<T>` — return type of operations that produce at most
78
+ * two values (e.g. inverse-solving an unrestricted quadratic polynomial).
79
+ *
80
+ * @since 2.0.0
81
+ */
82
+ type AtMostTwo<T> = None | One<T> | Two<T>;
83
+ /**
84
+ * `None | One<T> | Two<T> | Three<T>` — equivalent to `Solution<T>`.
85
+ *
86
+ * @since 2.0.0
87
+ */
88
+ type AtMostThree<T> = Solution<T>;
89
+ /**
90
+ * The empty solution. Reused across calls — never reallocated.
91
+ *
92
+ * @since 2.0.0
93
+ */
94
+ declare const none: None;
95
+ /**
96
+ * Constructs a single-value solution.
97
+ *
98
+ * @since 2.0.0
99
+ */
100
+ declare const one: <T>(value: T) => One<T>;
101
+ /**
102
+ * Constructs a two-value solution.
103
+ *
104
+ * @since 2.0.0
105
+ */
106
+ declare const two: <T>(a: T, b: T) => Two<T>;
107
+ /**
108
+ * Constructs a three-value solution.
109
+ *
110
+ * @since 2.0.0
111
+ */
112
+ declare const three: <T>(a: T, b: T, c: T) => Three<T>;
113
+ /**
114
+ * Constructs a `Solution<T>` from a runtime array. Throws if the array has
115
+ * more than three elements.
116
+ *
117
+ * @since 2.0.0
118
+ */
119
+ declare const fromArray: <T>(arr: ReadonlyArray<T>) => Solution<T>;
120
+ /**
121
+ * Type-narrowing predicate: refines `Solution<T>` to `None`.
122
+ *
123
+ * @since 2.0.0
124
+ */
125
+ declare const isNone: <T>(s: Solution<T>) => s is None;
126
+ /**
127
+ * Type-narrowing predicate: refines `Solution<T>` to `Some<T>` (non-empty).
128
+ * After narrowing, `.value` is directly accessible without further checks.
129
+ *
130
+ * @since 2.0.0
131
+ */
132
+ declare const isSome: <T>(s: Solution<T>) => s is Some<T>;
133
+ /**
134
+ * Returns the primary (first) value if the solution is non-empty, or
135
+ * `undefined` if empty. Pair with `.value` access on `Some<T>`-narrowed
136
+ * inputs to avoid the `undefined` possibility.
137
+ *
138
+ * @since 2.0.0
139
+ */
140
+ declare const valueOrUndefined: <T>(s: Solution<T>) => T | undefined;
141
+ /**
142
+ * Returns the last value in the solution, or `undefined` if empty. When
143
+ * called on a `Some<T>`, the result is guaranteed to be `T`.
144
+ *
145
+ * @since 2.0.0
146
+ */
147
+ declare const last: {
148
+ <T>(s: Some<T>): T;
149
+ <T>(s: Solution<T>): T | undefined;
150
+ };
151
+ /**
152
+ * Returns the smallest numeric value in the solution, or `undefined` if empty.
153
+ * When called on a `Some<number>`, the result is guaranteed to be `number`.
154
+ *
155
+ * @since 2.0.0
156
+ */
157
+ declare const min: {
158
+ (s: Some<number>): number;
159
+ (s: Solution<number>): number | undefined;
160
+ };
161
+ /**
162
+ * Returns the largest numeric value in the solution, or `undefined` if empty.
163
+ * When called on a `Some<number>`, the result is guaranteed to be `number`.
164
+ *
165
+ * @since 2.0.0
166
+ */
167
+ declare const max: {
168
+ (s: Some<number>): number;
169
+ (s: Solution<number>): number | undefined;
170
+ };
171
+ /**
172
+ * Returns the last value in the solution. Throws if empty.
173
+ *
174
+ * @since 2.0.0
175
+ */
176
+ declare const unsafeLast: <T>(s: Solution<T>) => T;
177
+ /**
178
+ * Returns the smallest numeric value in the solution. Throws on empty.
179
+ *
180
+ * @since 2.0.0
181
+ */
182
+ declare const unsafeMin: (s: Solution<number>) => number;
183
+ /**
184
+ * Returns the largest numeric value in the solution. Throws on empty.
185
+ *
186
+ * @since 2.0.0
187
+ */
188
+ declare const unsafeMax: (s: Solution<number>) => number;
189
+ /**
190
+ * Filters the solution by a predicate. Result cardinality is at most that of
191
+ * the input.
192
+ *
193
+ * @since 2.0.0
194
+ */
195
+ declare const filter: <T>(s: Solution<T>, predicate: (v: T) => boolean) => Solution<T>;
196
+ /**
197
+ * Restricts the solution to values contained within an interval. Endpoint
198
+ * inclusivity follows the interval's `kind` — pass an open variant (e.g.
199
+ * `Interval.makeOpen(0, 1)` or `Interval.unitOpen`) for strict containment.
200
+ *
201
+ * @param s - The solution to clip.
202
+ * @param i - The interval to retain values within.
203
+ * @since 2.0.0
204
+ */
205
+ declare const clip: {
206
+ (i: Interval): (s: Solution<number>) => Solution<number>;
207
+ (s: Solution<number>, i: Interval): Solution<number>;
208
+ };
209
+ /**
210
+ * Maps every value in the solution to a new value. Result cardinality matches
211
+ * the input.
212
+ *
213
+ * @since 2.0.0
214
+ */
215
+ declare const map: {
216
+ <A, B>(s: Solution<A>, f: (v: A) => B): Solution<B>;
217
+ <A, B>(f: (v: A) => B): (s: Solution<A>) => Solution<B>;
218
+ };
219
+ type SomeOf<S> = S extends None ? never : S;
220
+ /**
221
+ * Pattern matches on a solution, calling `onNone` for the empty case and
222
+ * `onSome` for any non-empty case. The `onSome` parameter is typed against
223
+ * the input's narrowed shape — for an `AtMostOne<T>` input, `onSome` receives
224
+ * `One<T>` and can read `.value` directly.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * const result = polynomial.pipe(
229
+ * LinearPolynomial.solveInverse(0),
230
+ * Solution.match({
231
+ * onNone: () => null,
232
+ * onSome: ({ value }) => Math.abs(value),
233
+ * }),
234
+ * )
235
+ * ```
236
+ *
237
+ * @since 2.0.0
238
+ */
239
+ declare const match: {
240
+ <S extends Solution<unknown>, A, B>(self: S, matcher: {
241
+ readonly onNone: () => A;
242
+ readonly onSome: (s: SomeOf<S>) => B;
243
+ }): A | B;
244
+ <S extends Solution<unknown>, A, B>(matcher: {
245
+ readonly onNone: () => A;
246
+ readonly onSome: (s: SomeOf<S>) => B;
247
+ }): (self: S) => A | B;
248
+ };
249
+ //#endregion
250
+ export { solution_d_exports as a, One as i, AtMostThree as n, AtMostTwo as r, AtMostOne as t };
251
+ //# sourceMappingURL=solution-sNQ-ZVhN.d.mts.map