@niscorp/prism 0.2.2 → 0.3.0

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 (45) hide show
  1. package/CHANGELOG.md +187 -0
  2. package/DESIGN.md +9 -8
  3. package/DOCS.md +68 -25
  4. package/README.md +35 -22
  5. package/dist/agent.cjs +4 -4
  6. package/dist/agent.js +2 -2
  7. package/dist/{chunk-26VYDHHC.cjs → chunk-66YSI4PX.cjs} +268 -97
  8. package/dist/chunk-66YSI4PX.cjs.map +1 -0
  9. package/dist/{chunk-O3OJAQWA.js → chunk-7VMFSXBM.js} +262 -98
  10. package/dist/chunk-7VMFSXBM.js.map +1 -0
  11. package/dist/{chunk-XRK55NPE.js → chunk-BKXCULZV.js} +5 -3
  12. package/dist/chunk-BKXCULZV.js.map +1 -0
  13. package/dist/{chunk-W32JXP33.cjs → chunk-OLZQK2ZF.cjs} +7 -5
  14. package/dist/chunk-OLZQK2ZF.cjs.map +1 -0
  15. package/dist/examples/index.cjs +25 -2
  16. package/dist/examples/index.cjs.map +1 -1
  17. package/dist/examples/index.d.cts +1 -1
  18. package/dist/examples/index.d.ts +1 -1
  19. package/dist/examples/index.js +25 -2
  20. package/dist/examples/index.js.map +1 -1
  21. package/dist/index.cjs +1224 -137
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +9 -6
  24. package/dist/index.d.ts +9 -6
  25. package/dist/index.js +1120 -26
  26. package/dist/index.js.map +1 -1
  27. package/dist/migrations/index.cjs +15 -7
  28. package/dist/migrations/index.cjs.map +1 -1
  29. package/dist/migrations/index.d.cts +0 -2
  30. package/dist/migrations/index.d.ts +0 -2
  31. package/dist/migrations/index.js +14 -2
  32. package/dist/migrations/index.js.map +1 -1
  33. package/dist/{profiles-C6r-x-Vj.d.cts → profiles-CPVfysxC.d.cts} +2 -1
  34. package/dist/{profiles-C6r-x-Vj.d.ts → profiles-CPVfysxC.d.ts} +2 -1
  35. package/package.json +4 -4
  36. package/dist/chunk-26VYDHHC.cjs.map +0 -1
  37. package/dist/chunk-O3OJAQWA.js.map +0 -1
  38. package/dist/chunk-V426VIRI.cjs +0 -1168
  39. package/dist/chunk-V426VIRI.cjs.map +0 -1
  40. package/dist/chunk-VC4PRB4H.js +0 -1086
  41. package/dist/chunk-VC4PRB4H.js.map +0 -1
  42. package/dist/chunk-W32JXP33.cjs.map +0 -1
  43. package/dist/chunk-XRK55NPE.js.map +0 -1
  44. package/dist/transform-DcVcOBzQ.d.cts +0 -3
  45. package/dist/transform-DcVcOBzQ.d.ts +0 -3
package/dist/index.cjs CHANGED
@@ -1,16 +1,936 @@
1
1
  'use strict';
2
2
 
3
- var chunkW32JXP33_cjs = require('./chunk-W32JXP33.cjs');
4
- var chunkV426VIRI_cjs = require('./chunk-V426VIRI.cjs');
5
- var chunk26VYDHHC_cjs = require('./chunk-26VYDHHC.cjs');
3
+ var chunkOLZQK2ZF_cjs = require('./chunk-OLZQK2ZF.cjs');
4
+ var chunk66YSI4PX_cjs = require('./chunk-66YSI4PX.cjs');
6
5
  var strata = require('@niscorp/strata');
6
+ var dayjs = require('dayjs');
7
+ var utc = require('dayjs/plugin/utc.js');
7
8
 
8
- // src/engine/optimize.ts
9
- var HANDLER_KEY = "__op";
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
12
+ var utc__default = /*#__PURE__*/_interopDefault(utc);
13
+
14
+ // src/utils/issues.ts
15
+ var segmentsOf = (path) => path.map((p) => typeof p === "number" ? p : String(p));
16
+ var explainOne = (issue, prefix) => {
17
+ const here = [...prefix, ...segmentsOf(issue.path)];
18
+ if (issue.code === "invalid_key") return [{ path: here, message: issue.issues[0]?.message ?? issue.message }];
19
+ if (issue.code !== "invalid_union" || issue.errors.length === 0) return [{ path: here, message: issue.message }];
20
+ let best = [];
21
+ let bestDepth = -1;
22
+ for (const branch of issue.errors) {
23
+ const explained = branch.flatMap((i) => explainOne(i, here));
24
+ const depth = Math.max(...explained.map((e) => e.path.length));
25
+ if (depth > bestDepth || depth === bestDepth && explained.length < best.length) {
26
+ best = explained;
27
+ bestDepth = depth;
28
+ }
29
+ }
30
+ return bestDepth <= here.length ? [{ path: here, message: "Not a Prism node: no op matches, and it is not a plain value." }] : best;
31
+ };
32
+ var explainIssues = (issues) => issues.flatMap((i) => explainOne(i, []));
33
+
34
+ // src/sugar/rewriters.ts
35
+ var rewriteSum = (node, recurse) => ({
36
+ $reduce: {
37
+ over: recurse(node.$sum.over),
38
+ as: "__x",
39
+ acc: "__acc",
40
+ init: { $const: 0 },
41
+ body: { $add: [{ $var: "__acc" }, { $var: "__x" }] }
42
+ }
43
+ });
44
+ var rewriteCount = (node, recurse) => ({
45
+ $reduce: {
46
+ over: recurse(node.$count.over),
47
+ as: "__x",
48
+ acc: "__acc",
49
+ init: { $const: 0 },
50
+ body: { $add: [{ $var: "__acc" }, { $const: 1 }] }
51
+ }
52
+ });
53
+ var rewriteAvg = (node, recurse) => {
54
+ const over = recurse(node.$avg.over);
55
+ return {
56
+ $div: [
57
+ {
58
+ $reduce: {
59
+ over,
60
+ as: "__x",
61
+ acc: "__acc",
62
+ init: { $const: 0 },
63
+ body: { $add: [{ $var: "__acc" }, { $var: "__x" }] }
64
+ }
65
+ },
66
+ {
67
+ $reduce: {
68
+ over,
69
+ as: "__x",
70
+ acc: "__acc",
71
+ init: { $const: 0 },
72
+ body: { $add: [{ $var: "__acc" }, { $const: 1 }] }
73
+ }
74
+ }
75
+ ]
76
+ };
77
+ };
78
+ var rewriteMin = (node, recurse) => ({
79
+ $reduce: {
80
+ over: recurse(node.$min.over),
81
+ as: "__x",
82
+ acc: "__acc",
83
+ init: { $const: null },
84
+ body: {
85
+ $case: {
86
+ branches: [
87
+ { when: { $eq: [{ $var: "__acc" }, null] }, then: { $var: "__x" } },
88
+ { when: { $lt: [{ $var: "__x" }, { $var: "__acc" }] }, then: { $var: "__x" } }
89
+ ],
90
+ else: { $var: "__acc" }
91
+ }
92
+ }
93
+ }
94
+ });
95
+ var rewriteMax = (node, recurse) => ({
96
+ $reduce: {
97
+ over: recurse(node.$max.over),
98
+ as: "__x",
99
+ acc: "__acc",
100
+ init: { $const: null },
101
+ body: {
102
+ $case: {
103
+ branches: [
104
+ { when: { $eq: [{ $var: "__acc" }, null] }, then: { $var: "__x" } },
105
+ { when: { $gt: [{ $var: "__x" }, { $var: "__acc" }] }, then: { $var: "__x" } }
106
+ ],
107
+ else: { $var: "__acc" }
108
+ }
109
+ }
110
+ }
111
+ });
112
+ var rewritePluck = (node, recurse) => ({
113
+ $map: {
114
+ over: recurse(node.$pluck.over),
115
+ as: "__item",
116
+ body: { $get: { from: { $var: "__item" }, path: [node.$pluck.key] } }
117
+ }
118
+ });
119
+ var rewriteTake = (node, recurse) => ({
120
+ $slice: {
121
+ from: recurse(node.$take.from),
122
+ start: 0,
123
+ end: node.$take.count
124
+ }
125
+ });
126
+ var rewriteDrop = (node, recurse) => ({
127
+ $slice: {
128
+ from: recurse(node.$drop.from),
129
+ start: node.$drop.count
130
+ }
131
+ });
132
+ var rewriteMatch = (node, recurse) => ({
133
+ $filter: {
134
+ over: recurse(node.$match.over),
135
+ as: node.$match.as,
136
+ when: {
137
+ $contains: {
138
+ value: { $var: node.$match.as },
139
+ search: recurse(node.$match.search)
140
+ }
141
+ }
142
+ }
143
+ });
144
+ var rewriteFlatMap = (node, recurse) => ({
145
+ $flatten: {
146
+ $map: {
147
+ over: recurse(node.$flatMap.over),
148
+ as: node.$flatMap.as,
149
+ body: recurse(node.$flatMap.body)
150
+ }
151
+ }
152
+ });
153
+
154
+ // src/sugar/desugar.ts
155
+ var desugar = (node) => {
156
+ if (node === null || node === void 0) return node;
157
+ if (typeof node !== "object") return node;
158
+ if (Array.isArray(node)) return node.map(desugar);
159
+ if (chunk66YSI4PX_cjs.isWithNode(node)) {
160
+ const bindings = {};
161
+ for (const [name, expr] of Object.entries(node.$with.let)) bindings[name] = desugar(expr);
162
+ return { $with: { let: bindings, value: desugar(node.$with.value) } };
163
+ }
164
+ if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) return { $renameKeys: { ...node.$renameKeys, from: desugar(node.$renameKeys.from) } };
165
+ if (chunk66YSI4PX_cjs.isConstNode(node)) return node;
166
+ if (chunk66YSI4PX_cjs.isSumNode(node)) return rewriteSum(node, desugar);
167
+ if (chunk66YSI4PX_cjs.isAvgNode(node)) return rewriteAvg(node, desugar);
168
+ if (chunk66YSI4PX_cjs.isCountNode(node)) return rewriteCount(node, desugar);
169
+ if (chunk66YSI4PX_cjs.isMinNode(node)) return rewriteMin(node, desugar);
170
+ if (chunk66YSI4PX_cjs.isMaxNode(node)) return rewriteMax(node, desugar);
171
+ if (chunk66YSI4PX_cjs.isPluckNode(node)) return rewritePluck(node, desugar);
172
+ if (chunk66YSI4PX_cjs.isTakeNode(node)) return rewriteTake(node, desugar);
173
+ if (chunk66YSI4PX_cjs.isDropNode(node)) return rewriteDrop(node, desugar);
174
+ if (chunk66YSI4PX_cjs.isMatchNode(node)) return rewriteMatch(node, desugar);
175
+ if (chunk66YSI4PX_cjs.isFlatMapNode(node)) return rewriteFlatMap(node, desugar);
176
+ if (chunk66YSI4PX_cjs.isJsonObject(node)) {
177
+ const result = {};
178
+ for (const [key, value] of Object.entries(node)) {
179
+ result[key] = desugar(value);
180
+ }
181
+ return result;
182
+ }
183
+ return node;
184
+ };
185
+
186
+ // src/engine/budget.ts
187
+ var DEFAULT_LIMITS = { maxSteps: 1e6, maxStringLength: 1e6, maxValues: 1e6 };
188
+ var createBudget = (limits) => ({ limits: { ...DEFAULT_LIMITS, ...limits }, steps: 0, sizes: /* @__PURE__ */ new WeakMap() });
189
+ var refuse = (what, limit) => {
190
+ throw new chunk66YSI4PX_cjs.PrismError(`Evaluation stopped: ${what} (limit ${limit})`, chunk66YSI4PX_cjs.ErrorCode.BUDGET, { details: { limit } });
191
+ };
192
+ var spendStep = (budget) => {
193
+ budget.steps += 1;
194
+ if (budget.steps > budget.limits.maxSteps) refuse("it evaluated too many nodes", budget.limits.maxSteps);
195
+ };
196
+ var sizeOf = (value, budget) => {
197
+ if (value === null || typeof value !== "object") return 1;
198
+ const known = budget.sizes.get(value);
199
+ if (known !== void 0) return known;
200
+ let size = 1;
201
+ for (const inner of Array.isArray(value) ? value : Object.values(value)) {
202
+ size += sizeOf(inner, budget);
203
+ if (size > budget.limits.maxValues) break;
204
+ }
205
+ budget.sizes.set(value, size);
206
+ return size;
207
+ };
208
+ var measureString = (value, budget) => {
209
+ if (typeof value === "string" && value.length > budget.limits.maxStringLength) refuse(`a string of ${value.length} characters`, budget.limits.maxStringLength);
210
+ };
211
+ var measure = (value, budget) => {
212
+ if (budget === void 0) return;
213
+ measureString(value, budget);
214
+ if (value !== null && typeof value === "object" && sizeOf(value, budget) > budget.limits.maxValues) {
215
+ refuse("a result holding too many values", budget.limits.maxValues);
216
+ }
217
+ };
218
+
219
+ // src/ops/core.ops.ts
10
220
  var SEGMENTS_KEY = "__segments";
11
- var eraseOp = (op) => (node, context, evaluate2) => {
12
- return op.call(void 0, node, context, evaluate2);
221
+ var isSegmentsArray = (value) => Array.isArray(value);
222
+ var opRef = (node, context, _evaluate) => {
223
+ const attached = Reflect.get(node, SEGMENTS_KEY);
224
+ const segments = isSegmentsArray(attached) ? attached : chunk66YSI4PX_cjs.parseJsonPathCached(node.$ref);
225
+ const resolved = chunk66YSI4PX_cjs.getByPath(context.source, segments);
226
+ if (resolved === void 0)
227
+ throw new chunk66YSI4PX_cjs.PrismError("Path not found", chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH, { op: "$ref", path: node.$ref });
228
+ return resolved;
229
+ };
230
+ var copyOf = (value) => {
231
+ if (value === null || typeof value !== "object") return value;
232
+ if (Array.isArray(value)) return value.map(copyOf);
233
+ const copy = {};
234
+ for (const [key, inner] of Object.entries(value)) copy[key] = copyOf(inner);
235
+ return copy;
236
+ };
237
+ var opConst = (node, context, _evaluate) => context.kept === true ? copyOf(node.$const) : node.$const;
238
+ var opVar = (node, context, _evaluate) => {
239
+ const value = context.vars[node.$var];
240
+ if (value === void 0)
241
+ throw new chunk66YSI4PX_cjs.PrismError(`Variable not found: ${node.$var}`, chunk66YSI4PX_cjs.ErrorCode.VAR_NOT_FOUND, { op: "$var", path: node.$var });
242
+ return value;
243
+ };
244
+ var opGet = (node, context, evaluate2) => {
245
+ const { from, path, fallback } = node.$get;
246
+ let current2 = evaluate2(from, context);
247
+ for (const segment of path) {
248
+ const evaluated = typeof segment === "object" && segment !== null ? evaluate2(segment, context) : segment;
249
+ if (typeof evaluated === "number") {
250
+ if (!chunk66YSI4PX_cjs.isJsonArray(current2)) {
251
+ if (fallback !== void 0) return evaluate2(fallback, context);
252
+ throw new chunk66YSI4PX_cjs.PrismError("Expected array for index access", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$get" });
253
+ }
254
+ current2 = current2[evaluated];
255
+ } else {
256
+ const key = String(evaluated);
257
+ if (!chunk66YSI4PX_cjs.isJsonObject(current2)) {
258
+ if (fallback !== void 0) return evaluate2(fallback, context);
259
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for key access", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$get" });
260
+ }
261
+ current2 = current2[key];
262
+ }
263
+ }
264
+ if (current2 === void 0) {
265
+ if (fallback !== void 0) return evaluate2(fallback, context);
266
+ throw new chunk66YSI4PX_cjs.PrismError("Path not found", chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH, { op: "$get" });
267
+ }
268
+ return current2;
269
+ };
270
+ var opWith = (node, context, evaluate2) => {
271
+ const { let: declarations, value } = node.$with;
272
+ const extendedVars = { ...context.vars };
273
+ for (const [name, expr] of Object.entries(declarations)) {
274
+ extendedVars[name] = evaluate2(expr, context);
275
+ measure(extendedVars[name] ?? null, context.budget);
276
+ }
277
+ return evaluate2(value, { ...context, vars: extendedVars });
278
+ };
279
+
280
+ // src/utils/compare.ts
281
+ var jsonEqual = (a, b) => {
282
+ if (a === b) return true;
283
+ if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
284
+ return JSON.stringify(a) === JSON.stringify(b);
285
+ };
286
+ var compare = (a, b) => {
287
+ if (typeof a === "number" && typeof b === "number") return a - b;
288
+ if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
289
+ return void 0;
290
+ };
291
+
292
+ // src/ops/scope.ts
293
+ var loopScope = (context) => {
294
+ const vars = { ...context.vars };
295
+ return { scope: { ...context, vars }, vars };
296
+ };
297
+
298
+ // src/ops/array.ops.ts
299
+ var requireArray = (value, op) => {
300
+ if (!chunk66YSI4PX_cjs.isJsonArray(value))
301
+ throw new chunk66YSI4PX_cjs.PrismError(`Expected array for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
302
+ return value;
303
+ };
304
+ var opMap = (node, context, evaluate2) => {
305
+ const { over, as, body } = node.$map;
306
+ const input = requireArray(evaluate2(over, context), "$map.over");
307
+ const result = [];
308
+ const { scope, vars } = loopScope(context);
309
+ for (const item of input) {
310
+ vars[as] = item;
311
+ result.push(evaluate2(body, scope));
312
+ }
313
+ return result;
314
+ };
315
+ var opFilter = (node, context, evaluate2) => {
316
+ const { over, as, when } = node.$filter;
317
+ const input = requireArray(evaluate2(over, context), "$filter.over");
318
+ const result = [];
319
+ const { scope, vars } = loopScope(context);
320
+ for (const item of input) {
321
+ vars[as] = item;
322
+ const condition = evaluate2(when, scope);
323
+ if (condition) result.push(item);
324
+ }
325
+ return result;
326
+ };
327
+ var opReduce = (node, context, evaluate2) => {
328
+ const { over, as, acc: accName = "acc", init, body } = node.$reduce;
329
+ const input = requireArray(evaluate2(over, context), "$reduce.over");
330
+ let accumulator = evaluate2(init, context);
331
+ const { scope, vars } = loopScope(context);
332
+ for (const item of input) {
333
+ vars[as] = item;
334
+ vars[accName] = accumulator;
335
+ accumulator = evaluate2(body, scope);
336
+ measure(accumulator, context.budget);
337
+ }
338
+ return accumulator;
339
+ };
340
+ var opSlice = (node, context, evaluate2) => {
341
+ const { from, start, end } = node.$slice;
342
+ const input = evaluate2(from, context);
343
+ if (typeof input === "string") return input.slice(start, end);
344
+ if (chunk66YSI4PX_cjs.isJsonArray(input)) return input.slice(start, end);
345
+ throw new chunk66YSI4PX_cjs.PrismError("Expected array or string for $slice", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$slice" });
346
+ };
347
+ var opFlatten = (node, context, evaluate2) => {
348
+ const input = requireArray(evaluate2(node.$flatten, context), "$flatten");
349
+ const result = [];
350
+ for (const item of input) {
351
+ if (chunk66YSI4PX_cjs.isJsonArray(item)) result.push(...item);
352
+ else result.push(item);
353
+ }
354
+ return result;
355
+ };
356
+ var opUnique = (node, context, evaluate2) => {
357
+ const input = requireArray(evaluate2(node.$unique, context), "$unique");
358
+ const seen = /* @__PURE__ */ new Set();
359
+ const result = [];
360
+ for (const item of input) {
361
+ const key = JSON.stringify(item);
362
+ if (!seen.has(key)) {
363
+ seen.add(key);
364
+ result.push(item);
365
+ }
366
+ }
367
+ return result;
368
+ };
369
+ var sortKey = (key) => {
370
+ if (key !== null && typeof key === "object") {
371
+ throw new chunk66YSI4PX_cjs.PrismError(
372
+ `$sortBy.by answered ${Array.isArray(key) ? "a list" : "an object"}; a sort key is a string or a number. To sort by two keys, sort by the second and then by the first: the sort keeps the order of equal items.`,
373
+ chunk66YSI4PX_cjs.ErrorCode.TYPE,
374
+ { op: "$sortBy" }
375
+ );
376
+ }
377
+ return key;
378
+ };
379
+ var NULL_KIND = 3;
380
+ var kindOf = (key) => key === null ? NULL_KIND : typeof key === "number" ? 0 : typeof key === "string" ? 1 : 2;
381
+ var opSortBy = (node, context, evaluate2) => {
382
+ const { over, as, by, dir = "asc" } = node.$sortBy;
383
+ const input = requireArray(evaluate2(over, context), "$sortBy.over");
384
+ const { scope, vars } = loopScope(context);
385
+ const keyed = input.map((item) => {
386
+ vars[as] = item;
387
+ return { item, key: sortKey(evaluate2(by, scope)) };
388
+ });
389
+ keyed.sort((a, b) => {
390
+ const kindA = kindOf(a.key);
391
+ const kindB = kindOf(b.key);
392
+ if (kindA === NULL_KIND || kindB === NULL_KIND) return kindA - kindB;
393
+ const cmp = kindA !== kindB ? kindA - kindB : compare(a.key, b.key) ?? Number(a.key) - Number(b.key);
394
+ return dir === "desc" ? -cmp : cmp;
395
+ });
396
+ return keyed.map((k) => k.item);
397
+ };
398
+
399
+ // src/ops/math.ops.ts
400
+ var requireNumbers = (node, context, evaluate2, op) => {
401
+ const a = evaluate2(node[0], context);
402
+ const b = evaluate2(node[1], context);
403
+ if (typeof a !== "number" || typeof b !== "number")
404
+ throw new chunk66YSI4PX_cjs.PrismError(`Expected numbers for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
405
+ return [a, b];
406
+ };
407
+ var opAdd = (node, context, evaluate2) => {
408
+ const [a, b] = requireNumbers(node.$add, context, evaluate2, "$add");
409
+ return a + b;
410
+ };
411
+ var opSub = (node, context, evaluate2) => {
412
+ const [a, b] = requireNumbers(node.$sub, context, evaluate2, "$sub");
413
+ return a - b;
414
+ };
415
+ var opMul = (node, context, evaluate2) => {
416
+ const [a, b] = requireNumbers(node.$mul, context, evaluate2, "$mul");
417
+ return a * b;
418
+ };
419
+ var opDiv = (node, context, evaluate2) => {
420
+ const [a, b] = requireNumbers(node.$div, context, evaluate2, "$div");
421
+ if (b === 0) throw new chunk66YSI4PX_cjs.PrismError("Division by zero", chunk66YSI4PX_cjs.ErrorCode.DIVISION_BY_ZERO, { op: "$div" });
422
+ return a / b;
423
+ };
424
+ var opMod = (node, context, evaluate2) => {
425
+ const [a, b] = requireNumbers(node.$mod, context, evaluate2, "$mod");
426
+ if (b === 0) throw new chunk66YSI4PX_cjs.PrismError("Division by zero", chunk66YSI4PX_cjs.ErrorCode.DIVISION_BY_ZERO, { op: "$mod" });
427
+ const remainder = a % b;
428
+ if (remainder === 0) return 0;
429
+ return remainder < 0 !== b < 0 ? remainder + b : remainder;
430
+ };
431
+ var ROUNDING = { nearest: Math.round, floor: Math.floor, ceil: Math.ceil };
432
+ var opRound = (node, context, evaluate2) => {
433
+ const value = evaluate2(node.$round.value, context);
434
+ if (typeof value !== "number")
435
+ throw new chunk66YSI4PX_cjs.PrismError("Expected number for $round", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$round" });
436
+ const digits = node.$round.digits ?? 0;
437
+ const factor = Math.pow(10, digits);
438
+ return ROUNDING[node.$round.mode ?? "nearest"](value * factor) / factor;
439
+ };
440
+ var NUMERIC_TEXT = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
441
+ var whatIs = (value) => {
442
+ if (typeof value === "string") return JSON.stringify(value.slice(0, 40));
443
+ if (value === null) return "null";
444
+ if (Array.isArray(value)) return "a list";
445
+ return typeof value === "object" ? "an object" : String(value);
446
+ };
447
+ var opToNumber = (node, context, evaluate2) => {
448
+ const value = evaluate2(node.$toNumber.value, context);
449
+ if (typeof value === "number") return value;
450
+ if (typeof value === "string") {
451
+ const text = value.trim();
452
+ const parsed = NUMERIC_TEXT.test(text) ? Number(text) : Number.NaN;
453
+ if (Number.isFinite(parsed)) return parsed;
454
+ }
455
+ if (node.$toNumber.fallback !== void 0) return evaluate2(node.$toNumber.fallback, context);
456
+ throw new chunk66YSI4PX_cjs.PrismError(`Expected a number or numeric text for $toNumber, got ${whatIs(value)}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$toNumber" });
457
+ };
458
+
459
+ // src/ops/string.ops.ts
460
+ var opJoin = (node, context, evaluate2) => {
461
+ const { parts, sep = "" } = node.$join;
462
+ const list = evaluate2(parts, context);
463
+ if (!Array.isArray(list)) throw new chunk66YSI4PX_cjs.PrismError("Expected $join.parts to evaluate to an array", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$join" });
464
+ return list.map((p) => String(p ?? "")).join(sep);
465
+ };
466
+ var opToString = (node, context, evaluate2) => {
467
+ const value = evaluate2(node.$toString, context);
468
+ if (value === null) return "null";
469
+ if (typeof value === "object") return JSON.stringify(value);
470
+ return String(value);
471
+ };
472
+ var opInterpolate = (node, context, evaluate2) => {
473
+ const { template, values: valuesNode } = node.$interpolate;
474
+ const values = evaluate2(valuesNode, context);
475
+ if (!chunk66YSI4PX_cjs.isJsonObject(values))
476
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $interpolate.values", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$interpolate" });
477
+ return template.replace(
478
+ /\{\{(\w+)\}\}/g,
479
+ (_match, key) => String(values[key] ?? "")
480
+ );
481
+ };
482
+ var fillOne = (value) => {
483
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
484
+ const { phrase, slots } = value;
485
+ if (typeof phrase !== "string" || !chunk66YSI4PX_cjs.isJsonObject(slots)) return value;
486
+ return phrase.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (hole, name) => {
487
+ const slot = slots[name];
488
+ if (slot === void 0 || slot === null) return hole;
489
+ const filled = fillOne(slot);
490
+ return typeof filled === "object" ? hole : String(filled);
491
+ });
492
+ };
493
+ var opFill = (node, context, evaluate2) => fillOne(evaluate2(node.$fill, context));
494
+ var opTrim = (node, context, evaluate2) => {
495
+ const value = evaluate2(node.$trim, context);
496
+ if (typeof value !== "string")
497
+ throw new chunk66YSI4PX_cjs.PrismError("Expected string for $trim", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$trim" });
498
+ return value.trim();
499
+ };
500
+ var opLower = (node, context, evaluate2) => {
501
+ const value = evaluate2(node.$lower, context);
502
+ if (typeof value !== "string")
503
+ throw new chunk66YSI4PX_cjs.PrismError("Expected string for $lower", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$lower" });
504
+ return value.toLowerCase();
505
+ };
506
+ var opUpper = (node, context, evaluate2) => {
507
+ const value = evaluate2(node.$upper, context);
508
+ if (typeof value !== "string")
509
+ throw new chunk66YSI4PX_cjs.PrismError("Expected string for $upper", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$upper" });
510
+ return value.toUpperCase();
511
+ };
512
+ var opSplit = (node, context, evaluate2) => {
513
+ const value = evaluate2(node.$split.value, context);
514
+ if (typeof value !== "string")
515
+ throw new chunk66YSI4PX_cjs.PrismError("Expected string for $split", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$split" });
516
+ return value.split(node.$split.sep);
517
+ };
518
+ var opReplace = (node, context, evaluate2) => {
519
+ const value = evaluate2(node.$replace.value, context);
520
+ if (typeof value !== "string")
521
+ throw new chunk66YSI4PX_cjs.PrismError("Expected string for $replace", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$replace" });
522
+ const { search, replacement, all } = node.$replace;
523
+ return all === true ? value.replaceAll(search, replacement) : value.replace(search, replacement);
524
+ };
525
+
526
+ // src/ops/predicate.ops.ts
527
+ var opEq = (node, context, evaluate2) => {
528
+ const a = evaluate2(node.$eq[0], context);
529
+ const b = evaluate2(node.$eq[1], context);
530
+ return jsonEqual(a, b);
531
+ };
532
+ var opNeq = (node, context, evaluate2) => {
533
+ const a = evaluate2(node.$neq[0], context);
534
+ const b = evaluate2(node.$neq[1], context);
535
+ return !jsonEqual(a, b);
536
+ };
537
+ var compareOp = (pair, context, evaluate2, op, test) => {
538
+ const a = evaluate2(pair[0], context);
539
+ const b = evaluate2(pair[1], context);
540
+ const cmp = compare(a, b);
541
+ if (cmp === void 0)
542
+ throw new chunk66YSI4PX_cjs.PrismError(`Cannot compare values for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
543
+ return test(cmp);
544
+ };
545
+ var opGt = (node, ctx, ev) => compareOp(node.$gt, ctx, ev, "$gt", (c) => c > 0);
546
+ var opGte = (node, ctx, ev) => compareOp(node.$gte, ctx, ev, "$gte", (c) => c >= 0);
547
+ var opLt = (node, ctx, ev) => compareOp(node.$lt, ctx, ev, "$lt", (c) => c < 0);
548
+ var opLte = (node, ctx, ev) => compareOp(node.$lte, ctx, ev, "$lte", (c) => c <= 0);
549
+ var opEmpty = (node, context, evaluate2) => {
550
+ const value = evaluate2(node.$empty, context);
551
+ if (value === null || value === void 0) return true;
552
+ if (typeof value === "string") return value.length === 0;
553
+ if (chunk66YSI4PX_cjs.isJsonArray(value)) return value.length === 0;
554
+ if (chunk66YSI4PX_cjs.isJsonObject(value)) return Object.keys(value).length === 0;
555
+ return false;
13
556
  };
557
+ var opStartsWith = (node, context, evaluate2) => {
558
+ const value = evaluate2(node.$startsWith.value, context);
559
+ const prefix = evaluate2(node.$startsWith.prefix, context);
560
+ if (typeof value !== "string" || typeof prefix !== "string")
561
+ throw new chunk66YSI4PX_cjs.PrismError("Expected strings for $startsWith", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$startsWith" });
562
+ return value.startsWith(prefix);
563
+ };
564
+ var opEndsWith = (node, context, evaluate2) => {
565
+ const value = evaluate2(node.$endsWith.value, context);
566
+ const suffix = evaluate2(node.$endsWith.suffix, context);
567
+ if (typeof value !== "string" || typeof suffix !== "string")
568
+ throw new chunk66YSI4PX_cjs.PrismError("Expected strings for $endsWith", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$endsWith" });
569
+ return value.endsWith(suffix);
570
+ };
571
+ var opContains = (node, context, evaluate2) => {
572
+ const value = evaluate2(node.$contains.value, context);
573
+ const search = evaluate2(node.$contains.search, context);
574
+ if (typeof value !== "string" || typeof search !== "string")
575
+ throw new chunk66YSI4PX_cjs.PrismError("Expected strings for $contains", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$contains" });
576
+ return value.includes(search);
577
+ };
578
+
579
+ // src/ops/logic.ops.ts
580
+ var opNot = (node, context, evaluate2) => !evaluate2(node.$not, context);
581
+ var opAnd = (node, context, evaluate2) => {
582
+ let last = true;
583
+ for (const operand of node.$and) {
584
+ last = evaluate2(operand, context);
585
+ if (!last) return last;
586
+ }
587
+ return last;
588
+ };
589
+ var opOr = (node, context, evaluate2) => {
590
+ let last = false;
591
+ for (const operand of node.$or) {
592
+ last = evaluate2(operand, context);
593
+ if (last) return last;
594
+ }
595
+ return last;
596
+ };
597
+
598
+ // src/ops/structure.ops.ts
599
+ var opMerge = (node, context, evaluate2) => {
600
+ const result = {};
601
+ for (const part of node.$merge) {
602
+ const evaluated = evaluate2(part, context);
603
+ if (!chunk66YSI4PX_cjs.isJsonObject(evaluated))
604
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $merge element", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$merge" });
605
+ Object.assign(result, evaluated);
606
+ }
607
+ return result;
608
+ };
609
+ var opCoalesce = (node, context, evaluate2) => {
610
+ for (const candidate of node.$coalesce) {
611
+ const value = evaluate2(candidate, context);
612
+ if (value !== null && value !== void 0) return value;
613
+ }
614
+ return null;
615
+ };
616
+ var opCase = (node, context, evaluate2) => {
617
+ for (const branch of node.$case.branches) {
618
+ const condition = evaluate2(branch.when, context);
619
+ if (condition) return evaluate2(branch.then, context);
620
+ }
621
+ if (node.$case.else !== void 0) return evaluate2(node.$case.else, context);
622
+ return null;
623
+ };
624
+ var opEntriesOf = (node, context, evaluate2) => {
625
+ const value = evaluate2(node.$entriesOf, context);
626
+ if (!chunk66YSI4PX_cjs.isJsonObject(value))
627
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $entriesOf", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$entriesOf" });
628
+ return Object.entries(value).map(([k, v]) => [k, v]);
629
+ };
630
+ var opKeyBy = (node, context, evaluate2) => {
631
+ const { over, as, key: keyExpr } = node.$keyBy;
632
+ const input = evaluate2(over, context);
633
+ if (!chunk66YSI4PX_cjs.isJsonArray(input))
634
+ throw new chunk66YSI4PX_cjs.PrismError("Expected array for $keyBy.over", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$keyBy" });
635
+ const result = {};
636
+ const { scope, vars } = loopScope(context);
637
+ for (const item of input) {
638
+ vars[as] = item;
639
+ const key = evaluate2(keyExpr, scope);
640
+ result[String(key)] = item;
641
+ }
642
+ return result;
643
+ };
644
+ var opGroupBy = (node, context, evaluate2) => {
645
+ const { over, as, key: keyExpr } = node.$groupBy;
646
+ const input = evaluate2(over, context);
647
+ if (!chunk66YSI4PX_cjs.isJsonArray(input))
648
+ throw new chunk66YSI4PX_cjs.PrismError("Expected array for $groupBy.over", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$groupBy" });
649
+ const result = {};
650
+ const { scope, vars } = loopScope(context);
651
+ for (const item of input) {
652
+ vars[as] = item;
653
+ const key = String(evaluate2(keyExpr, scope));
654
+ if (!result[key]) result[key] = [];
655
+ result[key].push(item);
656
+ }
657
+ return result;
658
+ };
659
+
660
+ // src/ops/object.ops.ts
661
+ var opKeys = (node, context, evaluate2) => {
662
+ const value = evaluate2(node.$keys, context);
663
+ if (!chunk66YSI4PX_cjs.isJsonObject(value))
664
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $keys", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$keys" });
665
+ return Object.keys(value);
666
+ };
667
+ var opValues = (node, context, evaluate2) => {
668
+ const value = evaluate2(node.$values, context);
669
+ if (!chunk66YSI4PX_cjs.isJsonObject(value))
670
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $values", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$values" });
671
+ return Object.values(value);
672
+ };
673
+ var opFromEntries = (node, context, evaluate2) => {
674
+ const value = evaluate2(node.$fromEntries, context);
675
+ if (!chunk66YSI4PX_cjs.isJsonArray(value))
676
+ throw new chunk66YSI4PX_cjs.PrismError("Expected array for $fromEntries", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$fromEntries" });
677
+ const result = {};
678
+ for (const entry of value) {
679
+ if (!chunk66YSI4PX_cjs.isJsonArray(entry) || entry.length < 2)
680
+ throw new chunk66YSI4PX_cjs.PrismError("Expected [key, value] pairs for $fromEntries", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$fromEntries" });
681
+ result[String(entry[0])] = entry[1];
682
+ }
683
+ return result;
684
+ };
685
+ var opPick = (node, context, evaluate2) => {
686
+ const value = evaluate2(node.$pick.from, context);
687
+ if (!chunk66YSI4PX_cjs.isJsonObject(value))
688
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $pick", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$pick" });
689
+ const result = {};
690
+ for (const key of node.$pick.keys) {
691
+ if (key in value) result[key] = value[key];
692
+ }
693
+ return result;
694
+ };
695
+ var opOmit = (node, context, evaluate2) => {
696
+ const value = evaluate2(node.$omit.from, context);
697
+ if (!chunk66YSI4PX_cjs.isJsonObject(value))
698
+ throw new chunk66YSI4PX_cjs.PrismError("Expected object for $omit", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$omit" });
699
+ const keysToOmit = new Set(node.$omit.keys);
700
+ const result = {};
701
+ for (const [k, v] of Object.entries(value)) {
702
+ if (!keysToOmit.has(k)) result[k] = v;
703
+ }
704
+ return result;
705
+ };
706
+ var opType = (node, context, evaluate2) => {
707
+ const value = evaluate2(node.$type, context);
708
+ if (value === null) return "null";
709
+ if (chunk66YSI4PX_cjs.isJsonArray(value)) return "array";
710
+ return typeof value;
711
+ };
712
+ var opLength = (node, context, evaluate2) => {
713
+ const value = evaluate2(node.$length, context);
714
+ if (typeof value === "string") return value.length;
715
+ if (chunk66YSI4PX_cjs.isJsonArray(value)) return value.length;
716
+ throw new chunk66YSI4PX_cjs.PrismError("Expected array or string for $length", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$length" });
717
+ };
718
+
719
+ // src/ops/transform.ops.ts
720
+ var has = (value, path) => {
721
+ let at = value;
722
+ for (const segment of path) {
723
+ if (typeof segment === "number") {
724
+ if (!chunk66YSI4PX_cjs.isJsonArray(at) || segment >= at.length) return false;
725
+ at = at[segment] ?? null;
726
+ } else {
727
+ if (!chunk66YSI4PX_cjs.isJsonObject(at) || !Object.prototype.hasOwnProperty.call(at, segment)) return false;
728
+ at = at[segment] ?? null;
729
+ }
730
+ }
731
+ return true;
732
+ };
733
+ var opHas = (node, context, evaluate2) => has(evaluate2(node.$has.from, context), node.$has.path);
734
+ var opRenameKeys = (node, context, evaluate2) => {
735
+ const value = evaluate2(node.$renameKeys.from, context);
736
+ if (!chunk66YSI4PX_cjs.isJsonObject(value)) throw new chunk66YSI4PX_cjs.PrismError("Expected object for $renameKeys", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$renameKeys" });
737
+ const { map } = node.$renameKeys;
738
+ const renamedTo = new Set(Object.entries(map).filter(([from]) => Object.prototype.hasOwnProperty.call(value, from)).map(([, to]) => to));
739
+ const result = {};
740
+ for (const [key, v] of Object.entries(value)) {
741
+ const target = map[key];
742
+ if (target !== void 0) result[target] = v;
743
+ else if (!renamedTo.has(key)) result[key] = v;
744
+ }
745
+ return result;
746
+ };
747
+ var current = (value, path) => {
748
+ let at = value;
749
+ for (const segment of path) {
750
+ if (typeof segment === "number") at = chunk66YSI4PX_cjs.isJsonArray(at) ? at[segment] ?? null : null;
751
+ else at = chunk66YSI4PX_cjs.isJsonObject(at) ? at[segment] ?? null : null;
752
+ }
753
+ return at;
754
+ };
755
+ var setIn = (value, path, next, full) => {
756
+ const [head, ...rest] = path;
757
+ if (head === void 0) return next;
758
+ if (typeof head === "number") {
759
+ if (!chunk66YSI4PX_cjs.isJsonArray(value) || head >= value.length) {
760
+ throw new chunk66YSI4PX_cjs.PrismError(`No array item at ${full.join(".")}`, chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH, { op: "$update", path: full.join(".") });
761
+ }
762
+ return value.map((item, i) => i === head ? setIn(item, rest, next, full) : item);
763
+ }
764
+ const base = chunk66YSI4PX_cjs.isJsonObject(value) ? value : {};
765
+ return { ...base, [head]: setIn(base[head] ?? null, rest, next, full) };
766
+ };
767
+ var opUpdate = (node, context, evaluate2) => {
768
+ const { from, path, value, as } = node.$update;
769
+ const source = evaluate2(from, context);
770
+ const next = evaluate2(value, { ...context, vars: { ...context.vars, [as ?? "current"]: current(source, path) } });
771
+ return setIn(source, path, next, path);
772
+ };
773
+ var opAssert = (node, context, evaluate2) => {
774
+ if (!evaluate2(node.$assert.when, context)) throw new chunk66YSI4PX_cjs.PrismError(node.$assert.message, chunk66YSI4PX_cjs.ErrorCode.ASSERT, { op: "$assert" });
775
+ return evaluate2(node.$assert.value, context);
776
+ };
777
+ var opWalk = (node, context, evaluate2) => {
778
+ const { over, as, rules, order } = node.$walk;
779
+ const rewrite = (value) => {
780
+ const scope = { ...context, vars: { ...context.vars, [as]: value } };
781
+ for (const rule of rules) {
782
+ if (evaluate2(rule.when, scope)) return { matched: true, value: evaluate2(rule.then, scope) };
783
+ }
784
+ return { matched: false, value };
785
+ };
786
+ const children = (value, visit) => {
787
+ if (chunk66YSI4PX_cjs.isJsonArray(value)) return value.map(visit);
788
+ if (chunk66YSI4PX_cjs.isJsonObject(value)) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, visit(v)]));
789
+ return value;
790
+ };
791
+ const post = (value) => rewrite(children(value, post)).value;
792
+ const pre = (value) => children(rewrite(value).value, pre);
793
+ return (order ?? "post") === "pre" ? pre(evaluate2(over, context)) : post(evaluate2(over, context));
794
+ };
795
+ dayjs__default.default.extend(utc__default.default);
796
+ var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
797
+ var isDateOnly = (value) => typeof value === "string" && DATE_ONLY.test(value);
798
+ var parseDate = (value, op) => {
799
+ if (typeof value !== "string" && typeof value !== "number")
800
+ throw new chunk66YSI4PX_cjs.PrismError(`Expected string or number for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
801
+ const d = isDateOnly(value) ? dayjs__default.default.utc(value) : dayjs__default.default(value);
802
+ if (!d.isValid())
803
+ throw new chunk66YSI4PX_cjs.PrismError(`Invalid date for ${op}: ${String(value)}`, chunk66YSI4PX_cjs.ErrorCode.DATE_INVALID, { op });
804
+ return d;
805
+ };
806
+ var opDate = (node, context, evaluate2) => {
807
+ const value = evaluate2(node.$date.value, context);
808
+ const d = parseDate(value, "$date");
809
+ const instance = node.$date.utc ? d.utc() : d;
810
+ if (node.$date.format) return instance.format(node.$date.format);
811
+ return instance.toISOString();
812
+ };
813
+ var opDateAdd = (node, context, evaluate2) => {
814
+ const value = evaluate2(node.$dateAdd.date, context);
815
+ const d = parseDate(value, "$dateAdd");
816
+ const moved = d.add(node.$dateAdd.amount, node.$dateAdd.unit);
817
+ return isDateOnly(value) ? moved.format("YYYY-MM-DD") : moved.toISOString();
818
+ };
819
+ var opDateDiff = (node, context, evaluate2) => {
820
+ const from = evaluate2(node.$dateDiff.from, context);
821
+ const to = evaluate2(node.$dateDiff.to, context);
822
+ const fromDate = parseDate(from, "$dateDiff.from");
823
+ const toDate = parseDate(to, "$dateDiff.to");
824
+ return toDate.diff(fromDate, node.$dateDiff.unit);
825
+ };
826
+
827
+ // src/ops/intl.ops.ts
828
+ var DATE_FORMATTERS = /* @__PURE__ */ new Map();
829
+ var NUMBER_FORMATTERS = /* @__PURE__ */ new Map();
830
+ var DATE_ONLY2 = /^\d{4}-\d{2}-\d{2}$/;
831
+ var localeOf = (value, op) => {
832
+ if (typeof value !== "string" || value.trim() === "")
833
+ throw new chunk66YSI4PX_cjs.PrismError(`${op} needs a locale tag (e.g. "de-AT")`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
834
+ return value;
835
+ };
836
+ var isBlank = (value) => value === null || value === void 0 || value === "";
837
+ var fallbackOf = (raw, context, evaluate2) => {
838
+ if (raw === void 0) return "";
839
+ const resolved = evaluate2(raw, context);
840
+ return resolved === null || resolved === void 0 ? "" : resolved;
841
+ };
842
+ var numberOf = (value, op) => {
843
+ const parsed = typeof value === "number" ? value : Number(value);
844
+ if (!Number.isFinite(parsed)) throw new chunk66YSI4PX_cjs.PrismError(`${op} expected a number, got ${JSON.stringify(value)}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
845
+ return parsed;
846
+ };
847
+ var opLocaleDate = (node, context, evaluate2) => {
848
+ const spec = node.$localeDate;
849
+ const value = evaluate2(spec.value, context);
850
+ if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
851
+ const locale = localeOf(evaluate2(spec.locale, context), "$localeDate");
852
+ const authored = spec.options ?? { dateStyle: "medium" };
853
+ const dateOnly = typeof value === "string" && DATE_ONLY2.test(value);
854
+ const options = {
855
+ ...authored,
856
+ ...authored.timeZone === void 0 && dateOnly ? { timeZone: "UTC" } : {}
857
+ };
858
+ const parsed = typeof value === "number" ? new Date(value) : new Date(String(value));
859
+ if (Number.isNaN(parsed.getTime()))
860
+ throw new chunk66YSI4PX_cjs.PrismError(`Invalid date for $localeDate: ${String(value)}`, chunk66YSI4PX_cjs.ErrorCode.DATE_INVALID, { op: "$localeDate" });
861
+ const key = `${locale}\0${JSON.stringify(options)}`;
862
+ let formatter = DATE_FORMATTERS.get(key);
863
+ if (formatter === void 0) {
864
+ formatter = new Intl.DateTimeFormat(locale, options);
865
+ DATE_FORMATTERS.set(key, formatter);
866
+ }
867
+ return formatter.format(parsed);
868
+ };
869
+ var minorUnitDivisor = (locale, currency) => {
870
+ const key = `divisor\0${locale}\0${currency}`;
871
+ let formatter = NUMBER_FORMATTERS.get(key);
872
+ if (formatter === void 0) {
873
+ try {
874
+ formatter = new Intl.NumberFormat(locale, { style: "currency", currency });
875
+ } catch {
876
+ return 100;
877
+ }
878
+ NUMBER_FORMATTERS.set(key, formatter);
879
+ }
880
+ return 10 ** (formatter.resolvedOptions().maximumFractionDigits ?? 2);
881
+ };
882
+ var opLocaleMoney = (node, context, evaluate2) => {
883
+ const spec = node.$localeMoney;
884
+ const value = evaluate2(spec.value, context);
885
+ if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
886
+ const locale = localeOf(evaluate2(spec.locale, context), "$localeMoney");
887
+ const rawCurrency = evaluate2(spec.currency, context);
888
+ if (typeof rawCurrency !== "string" || rawCurrency.trim() === "")
889
+ throw new chunk66YSI4PX_cjs.PrismError("$localeMoney needs an ISO-4217 currency code", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$localeMoney" });
890
+ const currency = rawCurrency.toUpperCase();
891
+ const amount = numberOf(value, "$localeMoney");
892
+ const major = spec.minorUnits === false ? amount : amount / minorUnitDivisor(locale, currency);
893
+ const options = {
894
+ style: "currency",
895
+ currency,
896
+ ...spec.digits === void 0 ? {} : { minimumFractionDigits: spec.digits, maximumFractionDigits: spec.digits }
897
+ };
898
+ const key = `${locale}\0${JSON.stringify(options)}`;
899
+ let formatter = NUMBER_FORMATTERS.get(key);
900
+ if (formatter === void 0) {
901
+ try {
902
+ formatter = new Intl.NumberFormat(locale, options);
903
+ } catch {
904
+ return `${currency} ${major.toFixed(spec.digits ?? 2)}`;
905
+ }
906
+ NUMBER_FORMATTERS.set(key, formatter);
907
+ }
908
+ return formatter.format(major);
909
+ };
910
+ var opLocaleNumber = (node, context, evaluate2) => {
911
+ const spec = node.$localeNumber;
912
+ const value = evaluate2(spec.value, context);
913
+ if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
914
+ const locale = localeOf(evaluate2(spec.locale, context), "$localeNumber");
915
+ const options = {
916
+ style: spec.style ?? "decimal",
917
+ ...spec.digits === void 0 ? {} : { maximumFractionDigits: spec.digits },
918
+ ...spec.minDigits === void 0 ? {} : { minimumFractionDigits: spec.minDigits },
919
+ ...spec.compact === true ? { notation: "compact" } : {}
920
+ };
921
+ const key = `${locale}\0${JSON.stringify(options)}`;
922
+ let formatter = NUMBER_FORMATTERS.get(key);
923
+ if (formatter === void 0) {
924
+ formatter = new Intl.NumberFormat(locale, options);
925
+ NUMBER_FORMATTERS.set(key, formatter);
926
+ }
927
+ return formatter.format(numberOf(value, "$localeNumber"));
928
+ };
929
+
930
+ // src/engine/optimize.ts
931
+ var HANDLER_KEY = "__op";
932
+ var SEGMENTS_KEY2 = "__segments";
933
+ var eraseOp = (op) => op;
14
934
  var attachNonEnumerable = (target, key, value) => {
15
935
  Object.defineProperty(target, key, {
16
936
  value,
@@ -19,71 +939,78 @@ var attachNonEnumerable = (target, key, value) => {
19
939
  configurable: true
20
940
  });
21
941
  };
22
- var isPlainObject = (value) => chunk26VYDHHC_cjs.isJsonObject(value);
942
+ var isPlainObject2 = (value) => chunk66YSI4PX_cjs.isJsonObject(value);
943
+ var freezeConstant = (value) => {
944
+ if (value === null || typeof value !== "object" || Object.isFrozen(value)) return;
945
+ Object.freeze(value);
946
+ for (const inner of Object.values(value)) freezeConstant(inner);
947
+ };
23
948
  var resolveHandler = (node) => {
24
- if (chunk26VYDHHC_cjs.isRefNode(node)) return eraseOp(chunkV426VIRI_cjs.opRef);
25
- if (chunk26VYDHHC_cjs.isConstNode(node)) return eraseOp(chunkV426VIRI_cjs.opConst);
26
- if (chunk26VYDHHC_cjs.isVarNode(node)) return eraseOp(chunkV426VIRI_cjs.opVar);
27
- if (chunk26VYDHHC_cjs.isGetNode(node)) return eraseOp(chunkV426VIRI_cjs.opGet);
28
- if (chunk26VYDHHC_cjs.isWithNode(node)) return eraseOp(chunkV426VIRI_cjs.opWith);
29
- if (chunk26VYDHHC_cjs.isMapNode(node)) return eraseOp(chunkV426VIRI_cjs.opMap);
30
- if (chunk26VYDHHC_cjs.isFilterNode(node)) return eraseOp(chunkV426VIRI_cjs.opFilter);
31
- if (chunk26VYDHHC_cjs.isReduceNode(node)) return eraseOp(chunkV426VIRI_cjs.opReduce);
32
- if (chunk26VYDHHC_cjs.isSliceNode(node)) return eraseOp(chunkV426VIRI_cjs.opSlice);
33
- if (chunk26VYDHHC_cjs.isFlattenNode(node)) return eraseOp(chunkV426VIRI_cjs.opFlatten);
34
- if (chunk26VYDHHC_cjs.isUniqueNode(node)) return eraseOp(chunkV426VIRI_cjs.opUnique);
35
- if (chunk26VYDHHC_cjs.isSortByNode(node)) return eraseOp(chunkV426VIRI_cjs.opSortBy);
36
- if (chunk26VYDHHC_cjs.isAddNode(node)) return eraseOp(chunkV426VIRI_cjs.opAdd);
37
- if (chunk26VYDHHC_cjs.isSubNode(node)) return eraseOp(chunkV426VIRI_cjs.opSub);
38
- if (chunk26VYDHHC_cjs.isMulNode(node)) return eraseOp(chunkV426VIRI_cjs.opMul);
39
- if (chunk26VYDHHC_cjs.isDivNode(node)) return eraseOp(chunkV426VIRI_cjs.opDiv);
40
- if (chunk26VYDHHC_cjs.isRoundNode(node)) return eraseOp(chunkV426VIRI_cjs.opRound);
41
- if (chunk26VYDHHC_cjs.isJoinNode(node)) return eraseOp(chunkV426VIRI_cjs.opJoin);
42
- if (chunk26VYDHHC_cjs.isToStringNode(node)) return eraseOp(chunkV426VIRI_cjs.opToString);
43
- if (chunk26VYDHHC_cjs.isInterpolateNode(node)) return eraseOp(chunkV426VIRI_cjs.opInterpolate);
44
- if (chunk26VYDHHC_cjs.isFillNode(node)) return eraseOp(chunkV426VIRI_cjs.opFill);
45
- if (chunk26VYDHHC_cjs.isTrimNode(node)) return eraseOp(chunkV426VIRI_cjs.opTrim);
46
- if (chunk26VYDHHC_cjs.isLowerNode(node)) return eraseOp(chunkV426VIRI_cjs.opLower);
47
- if (chunk26VYDHHC_cjs.isUpperNode(node)) return eraseOp(chunkV426VIRI_cjs.opUpper);
48
- if (chunk26VYDHHC_cjs.isSplitNode(node)) return eraseOp(chunkV426VIRI_cjs.opSplit);
49
- if (chunk26VYDHHC_cjs.isReplaceNode(node)) return eraseOp(chunkV426VIRI_cjs.opReplace);
50
- if (chunk26VYDHHC_cjs.isEqNode(node)) return eraseOp(chunkV426VIRI_cjs.opEq);
51
- if (chunk26VYDHHC_cjs.isNeqNode(node)) return eraseOp(chunkV426VIRI_cjs.opNeq);
52
- if (chunk26VYDHHC_cjs.isGtNode(node)) return eraseOp(chunkV426VIRI_cjs.opGt);
53
- if (chunk26VYDHHC_cjs.isGteNode(node)) return eraseOp(chunkV426VIRI_cjs.opGte);
54
- if (chunk26VYDHHC_cjs.isLtNode(node)) return eraseOp(chunkV426VIRI_cjs.opLt);
55
- if (chunk26VYDHHC_cjs.isLteNode(node)) return eraseOp(chunkV426VIRI_cjs.opLte);
56
- if (chunk26VYDHHC_cjs.isEmptyNode(node)) return eraseOp(chunkV426VIRI_cjs.opEmpty);
57
- if (chunk26VYDHHC_cjs.isStartsWithNode(node)) return eraseOp(chunkV426VIRI_cjs.opStartsWith);
58
- if (chunk26VYDHHC_cjs.isEndsWithNode(node)) return eraseOp(chunkV426VIRI_cjs.opEndsWith);
59
- if (chunk26VYDHHC_cjs.isContainsNode(node)) return eraseOp(chunkV426VIRI_cjs.opContains);
60
- if (chunk26VYDHHC_cjs.isNotNode(node)) return eraseOp(chunkV426VIRI_cjs.opNot);
61
- if (chunk26VYDHHC_cjs.isAndNode(node)) return eraseOp(chunkV426VIRI_cjs.opAnd);
62
- if (chunk26VYDHHC_cjs.isOrNode(node)) return eraseOp(chunkV426VIRI_cjs.opOr);
63
- if (chunk26VYDHHC_cjs.isMergeNode(node)) return eraseOp(chunkV426VIRI_cjs.opMerge);
64
- if (chunk26VYDHHC_cjs.isCoalesceNode(node)) return eraseOp(chunkV426VIRI_cjs.opCoalesce);
65
- if (chunk26VYDHHC_cjs.isCaseNode(node)) return eraseOp(chunkV426VIRI_cjs.opCase);
66
- if (chunk26VYDHHC_cjs.isEntriesOfNode(node)) return eraseOp(chunkV426VIRI_cjs.opEntriesOf);
67
- if (chunk26VYDHHC_cjs.isKeyByNode(node)) return eraseOp(chunkV426VIRI_cjs.opKeyBy);
68
- if (chunk26VYDHHC_cjs.isGroupByNode(node)) return eraseOp(chunkV426VIRI_cjs.opGroupBy);
69
- if (chunk26VYDHHC_cjs.isKeysNode(node)) return eraseOp(chunkV426VIRI_cjs.opKeys);
70
- if (chunk26VYDHHC_cjs.isValuesNode(node)) return eraseOp(chunkV426VIRI_cjs.opValues);
71
- if (chunk26VYDHHC_cjs.isFromEntriesNode(node)) return eraseOp(chunkV426VIRI_cjs.opFromEntries);
72
- if (chunk26VYDHHC_cjs.isPickNode(node)) return eraseOp(chunkV426VIRI_cjs.opPick);
73
- if (chunk26VYDHHC_cjs.isOmitNode(node)) return eraseOp(chunkV426VIRI_cjs.opOmit);
74
- if (chunk26VYDHHC_cjs.isTypeNode(node)) return eraseOp(chunkV426VIRI_cjs.opType);
75
- if (chunk26VYDHHC_cjs.isLengthNode(node)) return eraseOp(chunkV426VIRI_cjs.opLength);
76
- if (chunk26VYDHHC_cjs.isHasNode(node)) return eraseOp(chunkV426VIRI_cjs.opHas);
77
- if (chunk26VYDHHC_cjs.isRenameKeysNode(node)) return eraseOp(chunkV426VIRI_cjs.opRenameKeys);
78
- if (chunk26VYDHHC_cjs.isUpdateNode(node)) return eraseOp(chunkV426VIRI_cjs.opUpdate);
79
- if (chunk26VYDHHC_cjs.isAssertNode(node)) return eraseOp(chunkV426VIRI_cjs.opAssert);
80
- if (chunk26VYDHHC_cjs.isWalkNode(node)) return eraseOp(chunkV426VIRI_cjs.opWalk);
81
- if (chunk26VYDHHC_cjs.isDateNode(node)) return eraseOp(chunkV426VIRI_cjs.opDate);
82
- if (chunk26VYDHHC_cjs.isDateAddNode(node)) return eraseOp(chunkV426VIRI_cjs.opDateAdd);
83
- if (chunk26VYDHHC_cjs.isDateDiffNode(node)) return eraseOp(chunkV426VIRI_cjs.opDateDiff);
84
- if (chunk26VYDHHC_cjs.isLocaleDateNode(node)) return eraseOp(chunkV426VIRI_cjs.opLocaleDate);
85
- if (chunk26VYDHHC_cjs.isLocaleMoneyNode(node)) return eraseOp(chunkV426VIRI_cjs.opLocaleMoney);
86
- if (chunk26VYDHHC_cjs.isLocaleNumberNode(node)) return eraseOp(chunkV426VIRI_cjs.opLocaleNumber);
949
+ if (chunk66YSI4PX_cjs.isRefNode(node)) return eraseOp(opRef);
950
+ if (chunk66YSI4PX_cjs.isConstNode(node)) return eraseOp(opConst);
951
+ if (chunk66YSI4PX_cjs.isVarNode(node)) return eraseOp(opVar);
952
+ if (chunk66YSI4PX_cjs.isGetNode(node)) return eraseOp(opGet);
953
+ if (chunk66YSI4PX_cjs.isWithNode(node)) return eraseOp(opWith);
954
+ if (chunk66YSI4PX_cjs.isMapNode(node)) return eraseOp(opMap);
955
+ if (chunk66YSI4PX_cjs.isFilterNode(node)) return eraseOp(opFilter);
956
+ if (chunk66YSI4PX_cjs.isReduceNode(node)) return eraseOp(opReduce);
957
+ if (chunk66YSI4PX_cjs.isSliceNode(node)) return eraseOp(opSlice);
958
+ if (chunk66YSI4PX_cjs.isFlattenNode(node)) return eraseOp(opFlatten);
959
+ if (chunk66YSI4PX_cjs.isUniqueNode(node)) return eraseOp(opUnique);
960
+ if (chunk66YSI4PX_cjs.isSortByNode(node)) return eraseOp(opSortBy);
961
+ if (chunk66YSI4PX_cjs.isAddNode(node)) return eraseOp(opAdd);
962
+ if (chunk66YSI4PX_cjs.isSubNode(node)) return eraseOp(opSub);
963
+ if (chunk66YSI4PX_cjs.isMulNode(node)) return eraseOp(opMul);
964
+ if (chunk66YSI4PX_cjs.isDivNode(node)) return eraseOp(opDiv);
965
+ if (chunk66YSI4PX_cjs.isRoundNode(node)) return eraseOp(opRound);
966
+ if (chunk66YSI4PX_cjs.isModNode(node)) return eraseOp(opMod);
967
+ if (chunk66YSI4PX_cjs.isToNumberNode(node)) return eraseOp(opToNumber);
968
+ if (chunk66YSI4PX_cjs.isJoinNode(node)) return eraseOp(opJoin);
969
+ if (chunk66YSI4PX_cjs.isToStringNode(node)) return eraseOp(opToString);
970
+ if (chunk66YSI4PX_cjs.isInterpolateNode(node)) return eraseOp(opInterpolate);
971
+ if (chunk66YSI4PX_cjs.isFillNode(node)) return eraseOp(opFill);
972
+ if (chunk66YSI4PX_cjs.isTrimNode(node)) return eraseOp(opTrim);
973
+ if (chunk66YSI4PX_cjs.isLowerNode(node)) return eraseOp(opLower);
974
+ if (chunk66YSI4PX_cjs.isUpperNode(node)) return eraseOp(opUpper);
975
+ if (chunk66YSI4PX_cjs.isSplitNode(node)) return eraseOp(opSplit);
976
+ if (chunk66YSI4PX_cjs.isReplaceNode(node)) return eraseOp(opReplace);
977
+ if (chunk66YSI4PX_cjs.isEqNode(node)) return eraseOp(opEq);
978
+ if (chunk66YSI4PX_cjs.isNeqNode(node)) return eraseOp(opNeq);
979
+ if (chunk66YSI4PX_cjs.isGtNode(node)) return eraseOp(opGt);
980
+ if (chunk66YSI4PX_cjs.isGteNode(node)) return eraseOp(opGte);
981
+ if (chunk66YSI4PX_cjs.isLtNode(node)) return eraseOp(opLt);
982
+ if (chunk66YSI4PX_cjs.isLteNode(node)) return eraseOp(opLte);
983
+ if (chunk66YSI4PX_cjs.isEmptyNode(node)) return eraseOp(opEmpty);
984
+ if (chunk66YSI4PX_cjs.isStartsWithNode(node)) return eraseOp(opStartsWith);
985
+ if (chunk66YSI4PX_cjs.isEndsWithNode(node)) return eraseOp(opEndsWith);
986
+ if (chunk66YSI4PX_cjs.isContainsNode(node)) return eraseOp(opContains);
987
+ if (chunk66YSI4PX_cjs.isNotNode(node)) return eraseOp(opNot);
988
+ if (chunk66YSI4PX_cjs.isAndNode(node)) return eraseOp(opAnd);
989
+ if (chunk66YSI4PX_cjs.isOrNode(node)) return eraseOp(opOr);
990
+ if (chunk66YSI4PX_cjs.isMergeNode(node)) return eraseOp(opMerge);
991
+ if (chunk66YSI4PX_cjs.isCoalesceNode(node)) return eraseOp(opCoalesce);
992
+ if (chunk66YSI4PX_cjs.isCaseNode(node)) return eraseOp(opCase);
993
+ if (chunk66YSI4PX_cjs.isEntriesOfNode(node)) return eraseOp(opEntriesOf);
994
+ if (chunk66YSI4PX_cjs.isKeyByNode(node)) return eraseOp(opKeyBy);
995
+ if (chunk66YSI4PX_cjs.isGroupByNode(node)) return eraseOp(opGroupBy);
996
+ if (chunk66YSI4PX_cjs.isKeysNode(node)) return eraseOp(opKeys);
997
+ if (chunk66YSI4PX_cjs.isValuesNode(node)) return eraseOp(opValues);
998
+ if (chunk66YSI4PX_cjs.isFromEntriesNode(node)) return eraseOp(opFromEntries);
999
+ if (chunk66YSI4PX_cjs.isPickNode(node)) return eraseOp(opPick);
1000
+ if (chunk66YSI4PX_cjs.isOmitNode(node)) return eraseOp(opOmit);
1001
+ if (chunk66YSI4PX_cjs.isTypeNode(node)) return eraseOp(opType);
1002
+ if (chunk66YSI4PX_cjs.isLengthNode(node)) return eraseOp(opLength);
1003
+ if (chunk66YSI4PX_cjs.isHasNode(node)) return eraseOp(opHas);
1004
+ if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) return eraseOp(opRenameKeys);
1005
+ if (chunk66YSI4PX_cjs.isUpdateNode(node)) return eraseOp(opUpdate);
1006
+ if (chunk66YSI4PX_cjs.isAssertNode(node)) return eraseOp(opAssert);
1007
+ if (chunk66YSI4PX_cjs.isWalkNode(node)) return eraseOp(opWalk);
1008
+ if (chunk66YSI4PX_cjs.isDateNode(node)) return eraseOp(opDate);
1009
+ if (chunk66YSI4PX_cjs.isDateAddNode(node)) return eraseOp(opDateAdd);
1010
+ if (chunk66YSI4PX_cjs.isDateDiffNode(node)) return eraseOp(opDateDiff);
1011
+ if (chunk66YSI4PX_cjs.isLocaleDateNode(node)) return eraseOp(opLocaleDate);
1012
+ if (chunk66YSI4PX_cjs.isLocaleMoneyNode(node)) return eraseOp(opLocaleMoney);
1013
+ if (chunk66YSI4PX_cjs.isLocaleNumberNode(node)) return eraseOp(opLocaleNumber);
87
1014
  return void 0;
88
1015
  };
89
1016
  var isFoldableLiteral = (node) => {
@@ -91,8 +1018,8 @@ var isFoldableLiteral = (node) => {
91
1018
  const t = typeof node;
92
1019
  if (t === "string" || t === "number" || t === "boolean") return true;
93
1020
  if (Array.isArray(node)) return node.every(isFoldableLiteral);
94
- if (!isPlainObject(node)) return false;
95
- if (chunk26VYDHHC_cjs.isConstNode(node)) return isFoldableLiteral(node.$const);
1021
+ if (!isPlainObject2(node)) return false;
1022
+ if (chunk66YSI4PX_cjs.isConstNode(node)) return isFoldableLiteral(node.$const);
96
1023
  if (Object.keys(node).some((k) => k.startsWith("$"))) return false;
97
1024
  return Object.values(node).every(isFoldableLiteral);
98
1025
  };
@@ -104,22 +1031,31 @@ var optimizeNode = (node, stats, evaluate2) => {
104
1031
  for (const child of node) out.push(optimizeNode(child, stats, evaluate2));
105
1032
  return out;
106
1033
  }
107
- if (!isPlainObject(node)) return node;
108
- if (chunk26VYDHHC_cjs.isConstNode(node)) {
1034
+ if (!isPlainObject2(node)) return node;
1035
+ if (chunk66YSI4PX_cjs.isConstNode(node)) {
109
1036
  const literal = { ...node };
110
- attachNonEnumerable(literal, HANDLER_KEY, eraseOp(chunkV426VIRI_cjs.opConst));
1037
+ freezeConstant(literal["$const"]);
1038
+ attachNonEnumerable(literal, HANDLER_KEY, eraseOp(opConst));
111
1039
  stats.handlersAttached += 1;
112
1040
  return literal;
113
1041
  }
114
- const keys = Object.keys(node);
115
- const optimized = {};
116
- for (const key of keys) {
117
- optimized[key] = optimizeNode(node[key], stats, evaluate2);
1042
+ const optimizeValues = (record) => {
1043
+ const out = {};
1044
+ for (const key of Object.keys(record)) out[key] = optimizeNode(record[key], stats, evaluate2);
1045
+ return out;
1046
+ };
1047
+ let optimized;
1048
+ if (chunk66YSI4PX_cjs.isWithNode(node)) {
1049
+ optimized = { $with: { let: optimizeValues(node.$with.let), value: optimizeNode(node.$with.value, stats, evaluate2) } };
1050
+ } else if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) {
1051
+ optimized = { $renameKeys: { ...node.$renameKeys, from: optimizeNode(node.$renameKeys.from, stats, evaluate2) } };
1052
+ } else {
1053
+ optimized = optimizeValues(node);
118
1054
  }
119
- if (chunk26VYDHHC_cjs.isRefNode(optimized)) {
120
- const segments = chunkV426VIRI_cjs.parseJsonPath(optimized.$ref);
1055
+ if (chunk66YSI4PX_cjs.isRefNode(optimized)) {
1056
+ const segments = chunk66YSI4PX_cjs.parseJsonPath(optimized.$ref);
121
1057
  if (segments.length > 0) {
122
- attachNonEnumerable(optimized, SEGMENTS_KEY, segments);
1058
+ attachNonEnumerable(optimized, SEGMENTS_KEY2, segments);
123
1059
  stats.refsInlined += 1;
124
1060
  }
125
1061
  }
@@ -128,17 +1064,18 @@ var optimizeNode = (node, stats, evaluate2) => {
128
1064
  attachNonEnumerable(optimized, HANDLER_KEY, handler);
129
1065
  stats.handlersAttached += 1;
130
1066
  }
131
- if (handler !== void 0 && !chunk26VYDHHC_cjs.isConstNode(optimized) && !chunk26VYDHHC_cjs.isRefNode(optimized) && !chunk26VYDHHC_cjs.isVarNode(optimized)) {
1067
+ if (handler !== void 0 && !chunk66YSI4PX_cjs.isConstNode(optimized) && !chunk66YSI4PX_cjs.isRefNode(optimized) && !chunk66YSI4PX_cjs.isVarNode(optimized)) {
132
1068
  const allFoldable = Object.entries(optimized).every(([key, value]) => {
133
- if (key === HANDLER_KEY || key === SEGMENTS_KEY) return true;
1069
+ if (key === HANDLER_KEY || key === SEGMENTS_KEY2) return true;
134
1070
  return isFoldableLiteral(value);
135
1071
  });
136
1072
  if (allFoldable) {
137
- const emptyCtx = { source: {}, vars: {}, budget: chunkV426VIRI_cjs.createBudget() };
1073
+ const emptyCtx = { source: {}, vars: {}, budget: createBudget() };
138
1074
  try {
139
1075
  const folded = handler(optimized, emptyCtx, evaluate2);
140
1076
  const replacement = { $const: folded };
141
- attachNonEnumerable(replacement, HANDLER_KEY, eraseOp(chunkV426VIRI_cjs.opConst));
1077
+ freezeConstant(folded);
1078
+ attachNonEnumerable(replacement, HANDLER_KEY, eraseOp(opConst));
142
1079
  stats.constantsFolded += 1;
143
1080
  return replacement;
144
1081
  } catch {
@@ -157,20 +1094,186 @@ var annotateNode = (node) => {
157
1094
  for (const child of node) annotateNode(child);
158
1095
  return;
159
1096
  }
160
- if (!isPlainObject(node)) return;
161
- if (!chunk26VYDHHC_cjs.isConstNode(node)) {
1097
+ if (!isPlainObject2(node)) return;
1098
+ if (chunk66YSI4PX_cjs.isWithNode(node)) {
1099
+ for (const value of Object.values(node.$with.let)) annotateNode(value);
1100
+ annotateNode(node.$with.value);
1101
+ } else if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) {
1102
+ annotateNode(node.$renameKeys.from);
1103
+ } else if (!chunk66YSI4PX_cjs.isConstNode(node)) {
162
1104
  for (const value of Object.values(node)) annotateNode(value);
1105
+ } else {
1106
+ freezeConstant(node.$const);
163
1107
  }
164
- if (chunk26VYDHHC_cjs.isRefNode(node)) {
165
- const segments = chunkV426VIRI_cjs.parseJsonPath(node.$ref);
166
- if (segments.length > 0) attachNonEnumerable(node, SEGMENTS_KEY, segments);
1108
+ if (chunk66YSI4PX_cjs.isRefNode(node)) {
1109
+ const segments = chunk66YSI4PX_cjs.parseJsonPath(node.$ref);
1110
+ if (segments.length > 0) attachNonEnumerable(node, SEGMENTS_KEY2, segments);
167
1111
  }
168
1112
  const handler = resolveHandler(node);
169
1113
  if (handler !== void 0) attachNonEnumerable(node, HANDLER_KEY, handler);
170
1114
  };
171
1115
  var rehydrate = (core) => annotateNode(core);
172
1116
 
173
- // src/engine/compile.ts
1117
+ // src/engine/evaluate.ts
1118
+ var HANDLER_KEY2 = "__op";
1119
+ var isAttachedFn = (value) => typeof value === "function";
1120
+ var evaluateNode = (node, context) => {
1121
+ const { budget } = context;
1122
+ if (budget === void 0) return evaluateUnbudgeted(node, context);
1123
+ spendStep(budget);
1124
+ const out = evaluateUnbudgeted(node, context);
1125
+ measureString(out, budget);
1126
+ return out;
1127
+ };
1128
+ var evaluateUnbudgeted = (node, context) => {
1129
+ if (node === null || node === void 0) return null;
1130
+ if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") return node;
1131
+ if (Array.isArray(node)) return node.map((n) => evaluateNode(n, context));
1132
+ if (typeof node !== "object") return null;
1133
+ const obj = node;
1134
+ const attached = obj[HANDLER_KEY2];
1135
+ if (isAttachedFn(attached)) return attached(obj, context, evaluateNode);
1136
+ if (chunk66YSI4PX_cjs.isPlainObject(obj)) {
1137
+ const result = {};
1138
+ if (!(chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY in obj)) {
1139
+ for (const key of Object.keys(obj)) result[key] = evaluateNode(obj[key], context);
1140
+ return result;
1141
+ }
1142
+ const optionalFields = new Set(
1143
+ Array.isArray(obj[chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY]) ? obj[chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY] : []
1144
+ );
1145
+ for (const [key, value] of Object.entries(obj)) {
1146
+ if (key === chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY) continue;
1147
+ const isOptional = optionalFields.has(key);
1148
+ try {
1149
+ const evaluated = evaluateNode(value, context);
1150
+ if (isOptional && (evaluated === null || evaluated === void 0)) continue;
1151
+ result[key] = evaluated;
1152
+ } catch (error) {
1153
+ if (isOptional && error instanceof chunk66YSI4PX_cjs.PrismError && error.code === chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH) continue;
1154
+ throw error;
1155
+ }
1156
+ }
1157
+ return result;
1158
+ }
1159
+ if (chunk66YSI4PX_cjs.isRefNode(obj)) return opRef(obj, context);
1160
+ if (chunk66YSI4PX_cjs.isConstNode(obj)) return opConst(obj, context);
1161
+ if (chunk66YSI4PX_cjs.isVarNode(obj)) return opVar(obj, context);
1162
+ if (chunk66YSI4PX_cjs.isGetNode(obj)) return opGet(obj, context, evaluateNode);
1163
+ if (chunk66YSI4PX_cjs.isWithNode(obj)) return opWith(obj, context, evaluateNode);
1164
+ if (chunk66YSI4PX_cjs.isMapNode(obj)) return opMap(obj, context, evaluateNode);
1165
+ if (chunk66YSI4PX_cjs.isFilterNode(obj)) return opFilter(obj, context, evaluateNode);
1166
+ if (chunk66YSI4PX_cjs.isReduceNode(obj)) return opReduce(obj, context, evaluateNode);
1167
+ if (chunk66YSI4PX_cjs.isSliceNode(obj)) return opSlice(obj, context, evaluateNode);
1168
+ if (chunk66YSI4PX_cjs.isFlattenNode(obj)) return opFlatten(obj, context, evaluateNode);
1169
+ if (chunk66YSI4PX_cjs.isUniqueNode(obj)) return opUnique(obj, context, evaluateNode);
1170
+ if (chunk66YSI4PX_cjs.isSortByNode(obj)) return opSortBy(obj, context, evaluateNode);
1171
+ if (chunk66YSI4PX_cjs.isAddNode(obj)) return opAdd(obj, context, evaluateNode);
1172
+ if (chunk66YSI4PX_cjs.isSubNode(obj)) return opSub(obj, context, evaluateNode);
1173
+ if (chunk66YSI4PX_cjs.isMulNode(obj)) return opMul(obj, context, evaluateNode);
1174
+ if (chunk66YSI4PX_cjs.isDivNode(obj)) return opDiv(obj, context, evaluateNode);
1175
+ if (chunk66YSI4PX_cjs.isRoundNode(obj)) return opRound(obj, context, evaluateNode);
1176
+ if (chunk66YSI4PX_cjs.isModNode(obj)) return opMod(obj, context, evaluateNode);
1177
+ if (chunk66YSI4PX_cjs.isToNumberNode(obj)) return opToNumber(obj, context, evaluateNode);
1178
+ if (chunk66YSI4PX_cjs.isJoinNode(obj)) return opJoin(obj, context, evaluateNode);
1179
+ if (chunk66YSI4PX_cjs.isToStringNode(obj)) return opToString(obj, context, evaluateNode);
1180
+ if (chunk66YSI4PX_cjs.isInterpolateNode(obj)) return opInterpolate(obj, context, evaluateNode);
1181
+ if (chunk66YSI4PX_cjs.isFillNode(obj)) return opFill(obj, context, evaluateNode);
1182
+ if (chunk66YSI4PX_cjs.isTrimNode(obj)) return opTrim(obj, context, evaluateNode);
1183
+ if (chunk66YSI4PX_cjs.isLowerNode(obj)) return opLower(obj, context, evaluateNode);
1184
+ if (chunk66YSI4PX_cjs.isUpperNode(obj)) return opUpper(obj, context, evaluateNode);
1185
+ if (chunk66YSI4PX_cjs.isSplitNode(obj)) return opSplit(obj, context, evaluateNode);
1186
+ if (chunk66YSI4PX_cjs.isReplaceNode(obj)) return opReplace(obj, context, evaluateNode);
1187
+ if (chunk66YSI4PX_cjs.isEqNode(obj)) return opEq(obj, context, evaluateNode);
1188
+ if (chunk66YSI4PX_cjs.isNeqNode(obj)) return opNeq(obj, context, evaluateNode);
1189
+ if (chunk66YSI4PX_cjs.isGtNode(obj)) return opGt(obj, context, evaluateNode);
1190
+ if (chunk66YSI4PX_cjs.isGteNode(obj)) return opGte(obj, context, evaluateNode);
1191
+ if (chunk66YSI4PX_cjs.isLtNode(obj)) return opLt(obj, context, evaluateNode);
1192
+ if (chunk66YSI4PX_cjs.isLteNode(obj)) return opLte(obj, context, evaluateNode);
1193
+ if (chunk66YSI4PX_cjs.isEmptyNode(obj)) return opEmpty(obj, context, evaluateNode);
1194
+ if (chunk66YSI4PX_cjs.isStartsWithNode(obj)) return opStartsWith(obj, context, evaluateNode);
1195
+ if (chunk66YSI4PX_cjs.isEndsWithNode(obj)) return opEndsWith(obj, context, evaluateNode);
1196
+ if (chunk66YSI4PX_cjs.isContainsNode(obj)) return opContains(obj, context, evaluateNode);
1197
+ if (chunk66YSI4PX_cjs.isNotNode(obj)) return opNot(obj, context, evaluateNode);
1198
+ if (chunk66YSI4PX_cjs.isAndNode(obj)) return opAnd(obj, context, evaluateNode);
1199
+ if (chunk66YSI4PX_cjs.isOrNode(obj)) return opOr(obj, context, evaluateNode);
1200
+ if (chunk66YSI4PX_cjs.isMergeNode(obj)) return opMerge(obj, context, evaluateNode);
1201
+ if (chunk66YSI4PX_cjs.isCoalesceNode(obj)) return opCoalesce(obj, context, evaluateNode);
1202
+ if (chunk66YSI4PX_cjs.isCaseNode(obj)) return opCase(obj, context, evaluateNode);
1203
+ if (chunk66YSI4PX_cjs.isEntriesOfNode(obj)) return opEntriesOf(obj, context, evaluateNode);
1204
+ if (chunk66YSI4PX_cjs.isKeyByNode(obj)) return opKeyBy(obj, context, evaluateNode);
1205
+ if (chunk66YSI4PX_cjs.isGroupByNode(obj)) return opGroupBy(obj, context, evaluateNode);
1206
+ if (chunk66YSI4PX_cjs.isKeysNode(obj)) return opKeys(obj, context, evaluateNode);
1207
+ if (chunk66YSI4PX_cjs.isValuesNode(obj)) return opValues(obj, context, evaluateNode);
1208
+ if (chunk66YSI4PX_cjs.isFromEntriesNode(obj)) return opFromEntries(obj, context, evaluateNode);
1209
+ if (chunk66YSI4PX_cjs.isPickNode(obj)) return opPick(obj, context, evaluateNode);
1210
+ if (chunk66YSI4PX_cjs.isOmitNode(obj)) return opOmit(obj, context, evaluateNode);
1211
+ if (chunk66YSI4PX_cjs.isTypeNode(obj)) return opType(obj, context, evaluateNode);
1212
+ if (chunk66YSI4PX_cjs.isLengthNode(obj)) return opLength(obj, context, evaluateNode);
1213
+ if (chunk66YSI4PX_cjs.isHasNode(obj)) return opHas(obj, context, evaluateNode);
1214
+ if (chunk66YSI4PX_cjs.isRenameKeysNode(obj)) return opRenameKeys(obj, context, evaluateNode);
1215
+ if (chunk66YSI4PX_cjs.isUpdateNode(obj)) return opUpdate(obj, context, evaluateNode);
1216
+ if (chunk66YSI4PX_cjs.isAssertNode(obj)) return opAssert(obj, context, evaluateNode);
1217
+ if (chunk66YSI4PX_cjs.isWalkNode(obj)) return opWalk(obj, context, evaluateNode);
1218
+ if (chunk66YSI4PX_cjs.isDateNode(obj)) return opDate(obj, context, evaluateNode);
1219
+ if (chunk66YSI4PX_cjs.isDateAddNode(obj)) return opDateAdd(obj, context, evaluateNode);
1220
+ if (chunk66YSI4PX_cjs.isDateDiffNode(obj)) return opDateDiff(obj, context, evaluateNode);
1221
+ if (chunk66YSI4PX_cjs.isLocaleDateNode(obj)) return opLocaleDate(obj, context, evaluateNode);
1222
+ if (chunk66YSI4PX_cjs.isLocaleMoneyNode(obj)) return opLocaleMoney(obj, context, evaluateNode);
1223
+ if (chunk66YSI4PX_cjs.isLocaleNumberNode(obj)) return opLocaleNumber(obj, context, evaluateNode);
1224
+ const unknownKeys = Object.keys(obj).filter((k) => k.startsWith("$"));
1225
+ throw new chunk66YSI4PX_cjs.PrismError("Unsupported node shape", chunk66YSI4PX_cjs.ErrorCode.NODE_SHAPE, {
1226
+ details: { keys: unknownKeys, preview: JSON.stringify(obj).slice(0, 100) }
1227
+ });
1228
+ };
1229
+ var isJsonValue = (value) => {
1230
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
1231
+ if (typeof value === "number") return Number.isFinite(value);
1232
+ if (Array.isArray(value)) return value.every(isJsonValue);
1233
+ if (typeof value !== "object") return false;
1234
+ const proto = Object.getPrototypeOf(value);
1235
+ return (proto === Object.prototype || proto === null) && Object.values(value).every(isJsonValue);
1236
+ };
1237
+ var checked = (config) => {
1238
+ if (strata.exceedsDepth(config)) throw new chunk66YSI4PX_cjs.PrismError("Invalid config", chunk66YSI4PX_cjs.ErrorCode.SCHEMA, { details: { issues: [{ path: "root", message: strata.depthRefusal() }] } });
1239
+ const parsed = chunk66YSI4PX_cjs.ConfigSchema.safeParse(config);
1240
+ if (!parsed.success) {
1241
+ const issues = explainIssues(parsed.error.issues).map((i) => ({ path: i.path.join(".") || "root", message: i.message }));
1242
+ throw new chunk66YSI4PX_cjs.PrismError("Invalid config", chunk66YSI4PX_cjs.ErrorCode.SCHEMA, { details: { issues } });
1243
+ }
1244
+ return desugar(parsed.data);
1245
+ };
1246
+ var run = (tree, source, limits, kept) => {
1247
+ const budget = createBudget(limits);
1248
+ const result = evaluateNode(tree, kept ? { source, vars: {}, budget, kept } : { source, vars: {}, budget });
1249
+ measure(result, budget);
1250
+ return result;
1251
+ };
1252
+ var keptTrees = /* @__PURE__ */ new WeakMap();
1253
+ var evaluate = (config, source, options) => {
1254
+ if (options?.check === "always") {
1255
+ if (!isJsonValue(source)) throw new chunk66YSI4PX_cjs.PrismError("The source must be plain JSON.", chunk66YSI4PX_cjs.ErrorCode.TYPE);
1256
+ return run(checked(config), source, options.limits, false);
1257
+ }
1258
+ const input = source;
1259
+ if (typeof config !== "object" || config === null) return run(checked(config), input, options?.limits, false);
1260
+ let kept = keptTrees.get(config);
1261
+ if (kept === void 0) {
1262
+ kept = { tree: checked(config), optimized: false };
1263
+ keptTrees.set(config, kept);
1264
+ } else if (!kept.optimized) {
1265
+ kept.tree = optimize(kept.tree, evaluateNode).node;
1266
+ kept.optimized = true;
1267
+ }
1268
+ return run(kept.tree, input, options?.limits, true);
1269
+ };
1270
+ var evaluateSafe = (config, source, options) => {
1271
+ try {
1272
+ return { ok: true, data: evaluate(config, source, options) };
1273
+ } catch (error) {
1274
+ return { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
1275
+ }
1276
+ };
174
1277
  var walk = (node, stats, depth) => {
175
1278
  stats.nodeCount++;
176
1279
  if (depth > stats.maxDepth) stats.maxDepth = depth;
@@ -184,7 +1287,7 @@ var walk = (node, stats, depth) => {
184
1287
  for (const child of node) walk(child, stats, depth + 1);
185
1288
  return;
186
1289
  }
187
- if (!chunk26VYDHHC_cjs.isJsonObject(node)) return;
1290
+ if (!chunk66YSI4PX_cjs.isJsonObject(node)) return;
188
1291
  for (const key of Object.keys(node)) {
189
1292
  if (key.startsWith("$")) {
190
1293
  stats.opCount[key] = (stats.opCount[key] ?? 0) + 1;
@@ -204,14 +1307,14 @@ var hashSha256 = async (data) => {
204
1307
  return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
205
1308
  };
206
1309
  var compile = async (config, options) => {
207
- if (strata.exceedsDepth(config)) throw new chunkV426VIRI_cjs.PrismError(`Invalid config: ${strata.depthRefusal()}`, chunkV426VIRI_cjs.ErrorCode.SCHEMA);
208
- const parsed = chunk26VYDHHC_cjs.ConfigSchema.safeParse(config);
1310
+ if (strata.exceedsDepth(config)) throw new chunk66YSI4PX_cjs.PrismError(`Invalid config: ${strata.depthRefusal()}`, chunk66YSI4PX_cjs.ErrorCode.SCHEMA);
1311
+ const parsed = chunk66YSI4PX_cjs.ConfigSchema.safeParse(config);
209
1312
  if (!parsed.success) {
210
- const issues = chunkV426VIRI_cjs.explainIssues(parsed.error.issues).map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
211
- throw new chunkV426VIRI_cjs.PrismError(`Invalid config: ${issues}`, chunkV426VIRI_cjs.ErrorCode.SCHEMA);
1313
+ const issues = explainIssues(parsed.error.issues).map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
1314
+ throw new chunk66YSI4PX_cjs.PrismError(`Invalid config: ${issues}`, chunk66YSI4PX_cjs.ErrorCode.SCHEMA);
212
1315
  }
213
- const desugared = chunkV426VIRI_cjs.desugar(parsed.data);
214
- const { node: core, stats: optimizations } = optimize(desugared, chunkV426VIRI_cjs.evaluateNode);
1316
+ const desugared = desugar(parsed.data);
1317
+ const { node: core, stats: optimizations } = optimize(desugared, evaluateNode);
215
1318
  const stats = {
216
1319
  nodeCount: 0,
217
1320
  maxDepth: 0,
@@ -249,28 +1352,25 @@ var compile = async (config, options) => {
249
1352
  // src/engine/execute.ts
250
1353
  var hydrated = /* @__PURE__ */ new WeakSet();
251
1354
  var execute = (ir, source, limits) => {
252
- if (ir.tables.paths.length > 0) {
253
- chunkV426VIRI_cjs.primeJsonPathCache(ir.tables.paths);
254
- }
255
1355
  const { core } = ir;
256
1356
  if (typeof core === "object" && core !== null && !hydrated.has(core)) {
257
1357
  rehydrate(core);
258
1358
  hydrated.add(core);
259
1359
  }
260
- const budget = chunkV426VIRI_cjs.createBudget(limits);
261
- const result = chunkV426VIRI_cjs.evaluateNode(core, { source, vars: {}, budget });
262
- chunkV426VIRI_cjs.measure(result, budget);
1360
+ const budget = createBudget(limits);
1361
+ const result = evaluateNode(core, { source, vars: {}, budget });
1362
+ measure(result, budget);
263
1363
  return result;
264
1364
  };
265
1365
  var validate = (config) => {
266
1366
  if (strata.exceedsDepth(config)) return { ok: false, issues: [{ path: [], message: strata.depthRefusal() }] };
267
- const parsed = chunk26VYDHHC_cjs.ConfigSchema.safeParse(config);
1367
+ const parsed = chunk66YSI4PX_cjs.ConfigSchema.safeParse(config);
268
1368
  if (!parsed.success) {
269
1369
  return {
270
1370
  ok: false,
271
1371
  // The branch the config meant, with its full path — not the root union's
272
1372
  // "Invalid input" (see utils/issues).
273
- issues: chunkV426VIRI_cjs.explainIssues(parsed.error.issues)
1373
+ issues: explainIssues(parsed.error.issues)
274
1374
  };
275
1375
  }
276
1376
  return { ok: true, data: parsed.data };
@@ -278,57 +1378,44 @@ var validate = (config) => {
278
1378
 
279
1379
  Object.defineProperty(exports, "MAPPING_OPS", {
280
1380
  enumerable: true,
281
- get: function () { return chunkW32JXP33_cjs.MAPPING_OPS; }
1381
+ get: function () { return chunkOLZQK2ZF_cjs.MAPPING_OPS; }
282
1382
  });
283
1383
  Object.defineProperty(exports, "getConfigJsonSchema", {
284
1384
  enumerable: true,
285
- get: function () { return chunkW32JXP33_cjs.getConfigJsonSchema; }
1385
+ get: function () { return chunkOLZQK2ZF_cjs.getConfigJsonSchema; }
286
1386
  });
287
1387
  Object.defineProperty(exports, "getNodeJsonSchema", {
288
1388
  enumerable: true,
289
- get: function () { return chunkW32JXP33_cjs.getNodeJsonSchema; }
1389
+ get: function () { return chunkOLZQK2ZF_cjs.getNodeJsonSchema; }
290
1390
  });
291
1391
  Object.defineProperty(exports, "getProfileJsonSchema", {
292
1392
  enumerable: true,
293
- get: function () { return chunkW32JXP33_cjs.getProfileJsonSchema; }
1393
+ get: function () { return chunkOLZQK2ZF_cjs.getProfileJsonSchema; }
294
1394
  });
295
- Object.defineProperty(exports, "DEFAULT_LIMITS", {
1395
+ Object.defineProperty(exports, "ConfigSchema", {
296
1396
  enumerable: true,
297
- get: function () { return chunkV426VIRI_cjs.DEFAULT_LIMITS; }
1397
+ get: function () { return chunk66YSI4PX_cjs.ConfigSchema; }
298
1398
  });
299
1399
  Object.defineProperty(exports, "ErrorCode", {
300
1400
  enumerable: true,
301
- get: function () { return chunkV426VIRI_cjs.ErrorCode; }
302
- });
303
- Object.defineProperty(exports, "PrismError", {
304
- enumerable: true,
305
- get: function () { return chunkV426VIRI_cjs.PrismError; }
306
- });
307
- Object.defineProperty(exports, "evaluate", {
308
- enumerable: true,
309
- get: function () { return chunkV426VIRI_cjs.evaluate; }
310
- });
311
- Object.defineProperty(exports, "evaluateSafe", {
312
- enumerable: true,
313
- get: function () { return chunkV426VIRI_cjs.evaluateSafe; }
314
- });
315
- Object.defineProperty(exports, "prismTransform", {
316
- enumerable: true,
317
- get: function () { return chunkV426VIRI_cjs.prismTransform; }
318
- });
319
- Object.defineProperty(exports, "ConfigSchema", {
320
- enumerable: true,
321
- get: function () { return chunk26VYDHHC_cjs.ConfigSchema; }
1401
+ get: function () { return chunk66YSI4PX_cjs.ErrorCode; }
322
1402
  });
323
1403
  Object.defineProperty(exports, "NodeSchema", {
324
1404
  enumerable: true,
325
- get: function () { return chunk26VYDHHC_cjs.NodeSchema; }
1405
+ get: function () { return chunk66YSI4PX_cjs.NodeSchema; }
326
1406
  });
327
1407
  Object.defineProperty(exports, "OP_KEYS", {
328
1408
  enumerable: true,
329
- get: function () { return chunk26VYDHHC_cjs.OP_KEYS; }
1409
+ get: function () { return chunk66YSI4PX_cjs.OP_KEYS; }
1410
+ });
1411
+ Object.defineProperty(exports, "PrismError", {
1412
+ enumerable: true,
1413
+ get: function () { return chunk66YSI4PX_cjs.PrismError; }
330
1414
  });
1415
+ exports.DEFAULT_LIMITS = DEFAULT_LIMITS;
331
1416
  exports.compile = compile;
1417
+ exports.evaluate = evaluate;
1418
+ exports.evaluateSafe = evaluateSafe;
332
1419
  exports.execute = execute;
333
1420
  exports.validate = validate;
334
1421
  //# sourceMappingURL=index.cjs.map