@milaboratories/pl-model-common 1.15.8 → 1.16.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 (50) hide show
  1. package/dist/{base32-encode.d.ts → base32_encode.d.ts} +1 -1
  2. package/dist/{base32-encode.d.ts.map → base32_encode.d.ts.map} +1 -1
  3. package/dist/bmodel/block_config.d.ts +42 -0
  4. package/dist/bmodel/block_config.d.ts.map +1 -0
  5. package/dist/bmodel/code.d.ts +11 -0
  6. package/dist/bmodel/code.d.ts.map +1 -0
  7. package/dist/bmodel/container.d.ts +46 -0
  8. package/dist/bmodel/container.d.ts.map +1 -0
  9. package/dist/bmodel/index.d.ts +6 -0
  10. package/dist/bmodel/index.d.ts.map +1 -0
  11. package/dist/bmodel/normalization.d.ts +10 -0
  12. package/dist/bmodel/normalization.d.ts.map +1 -0
  13. package/dist/{block.d.ts → bmodel/types.d.ts} +1 -1
  14. package/dist/bmodel/types.d.ts.map +1 -0
  15. package/dist/drivers/pframe/table_calculate.d.ts +10 -1
  16. package/dist/drivers/pframe/table_calculate.d.ts.map +1 -1
  17. package/dist/drivers/pframe/table_common.d.ts +1 -0
  18. package/dist/drivers/pframe/table_common.d.ts.map +1 -1
  19. package/dist/flags/block_flags.d.ts +20 -0
  20. package/dist/flags/block_flags.d.ts.map +1 -0
  21. package/dist/flags/flag_utils.d.ts +56 -0
  22. package/dist/flags/flag_utils.d.ts.map +1 -0
  23. package/dist/flags/index.d.ts +4 -0
  24. package/dist/flags/index.d.ts.map +1 -0
  25. package/dist/flags/type_utils.d.ts +35 -0
  26. package/dist/flags/type_utils.d.ts.map +1 -0
  27. package/dist/index.d.ts +3 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +742 -572
  32. package/dist/index.mjs.map +1 -1
  33. package/package.json +2 -2
  34. package/src/bmodel/block_config.ts +69 -0
  35. package/src/bmodel/code.ts +12 -0
  36. package/src/bmodel/container.ts +58 -0
  37. package/src/bmodel/index.ts +5 -0
  38. package/src/bmodel/normalization.ts +111 -0
  39. package/src/drivers/pframe/table_calculate.ts +13 -1
  40. package/src/drivers/pframe/table_common.ts +15 -0
  41. package/src/flags/block_flags.ts +43 -0
  42. package/src/flags/flag_utils.test.ts +162 -0
  43. package/src/flags/flag_utils.ts +104 -0
  44. package/src/flags/index.ts +3 -0
  45. package/src/flags/type_utils.ts +43 -0
  46. package/src/index.ts +3 -1
  47. package/src/plid.ts +1 -1
  48. package/dist/block.d.ts.map +0 -1
  49. /package/src/{base32-encode.ts → base32_encode.ts} +0 -0
  50. /package/src/{block.ts → bmodel/types.ts} +0 -0
package/dist/index.mjs CHANGED
@@ -1,319 +1,401 @@
1
- var B = Object.defineProperty;
2
- var j = (n, e, t) => e in n ? B(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var l = (n, e, t) => j(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { z as d } from "zod";
5
- import y from "canonicalize";
6
- const wn = d.object({
1
+ var D = Object.defineProperty;
2
+ var L = (e, n, t) => n in e ? D(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var l = (e, n, t) => L(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { z as p } from "zod";
5
+ import h from "canonicalize";
6
+ function ke(e) {
7
+ if (e.code !== void 0)
8
+ return {
9
+ code: e.code,
10
+ sdkVersion: e.sdkVersion,
11
+ featureFlags: e.featureFlags
12
+ };
13
+ }
14
+ function m(e) {
15
+ if (e !== void 0)
16
+ return typeof e == "string" ? { __renderLambda: !0, handle: e, retentive: !1 } : e;
17
+ }
18
+ function xe(e) {
19
+ if (e.v3 !== void 0) {
20
+ const {
21
+ initialArgs: n,
22
+ initialUiState: t,
23
+ inputsValid: r,
24
+ outputs: o,
25
+ renderingMode: i,
26
+ sdkVersion: a,
27
+ featureFlags: s,
28
+ sections: u,
29
+ title: c,
30
+ enrichmentTargets: f
31
+ } = e.v3, { code: R } = e;
32
+ return {
33
+ initialArgs: n,
34
+ initialUiState: t,
35
+ inputsValid: r,
36
+ outputs: o,
37
+ renderingMode: i,
38
+ sdkVersion: a,
39
+ featureFlags: s,
40
+ sections: u,
41
+ title: c,
42
+ code: R,
43
+ enrichmentTargets: f
44
+ };
45
+ } else if (e.inputsValid !== void 0) {
46
+ const { sdkVersion: n, renderingMode: t, outputs: r, inputsValid: o, sections: i, initialArgs: a, code: s } = e, u = Object.keys(e);
47
+ if (n === void 0 || t === void 0 || r === void 0 || o === void 0 || i === void 0 || a === void 0)
48
+ throw new Error(
49
+ `Malformed config v2. SDK version ${n}; Fields = ${u.join(", ")}`
50
+ );
51
+ return {
52
+ sdkVersion: n,
53
+ renderingMode: t,
54
+ initialArgs: a,
55
+ outputs: Object.fromEntries(
56
+ Object.entries(r).map(([c, f]) => [c, m(f)])
57
+ ),
58
+ inputsValid: m(o),
59
+ sections: m(i),
60
+ initialUiState: void 0,
61
+ code: s
62
+ };
63
+ } else if (e.renderingMode !== void 0) {
64
+ const { sdkVersion: n, canRun: t, renderingMode: r, outputs: o, sections: i, initialArgs: a, code: s } = e, u = Object.keys(e);
65
+ if (r === void 0 || o === void 0 || t === void 0 || i === void 0 || a === void 0)
66
+ throw new Error(
67
+ `Malformed config v1. SDK version ${n}; Fields = ${u.join(", ")}`
68
+ );
69
+ return {
70
+ sdkVersion: n ?? "unknown",
71
+ renderingMode: r,
72
+ initialArgs: a,
73
+ outputs: Object.fromEntries(
74
+ Object.entries(o).map(([c, f]) => [c, m(f)])
75
+ ),
76
+ inputsValid: m(t),
77
+ sections: m(i),
78
+ initialUiState: void 0,
79
+ code: s
80
+ };
81
+ } else {
82
+ const { sdkVersion: n } = e, t = Object.keys(e);
83
+ throw new Error(
84
+ `Config format not supported: SDK = ${n}; Fields = ${t.join(", ")}`
85
+ );
86
+ }
87
+ }
88
+ const Pe = p.object({
7
89
  /** Included left border. */
8
- from: d.number(),
90
+ from: p.number(),
9
91
  /** Excluded right border. */
10
- to: d.number()
92
+ to: p.number()
11
93
  });
12
- function An(n, e) {
13
- if (!(n == null || e == null))
14
- return { from: n, to: e };
15
- }
16
- function xn(n, e) {
17
- if (n.from < 0 || n.to < 0 || n.from >= n.to)
18
- throw new Error(`${e}: invalid bytes range: ${n}`);
19
- }
20
- function Pn(n) {
21
- return n !== void 0 && n.startsWith("log+live://log/");
22
- }
23
- function w(n) {
24
- throw new Error("Unexpected object: " + n);
25
- }
26
- const S = "upload://upload/", C = "index://index/";
27
- function v(n) {
28
- return n.startsWith(S);
29
- }
30
- function F(n) {
31
- return n.startsWith(C);
32
- }
33
- function R(n) {
34
- if (F(n)) {
35
- const e = n.slice(C.length);
36
- return JSON.parse(decodeURIComponent(e)).path;
37
- } else if (v(n)) {
38
- const e = n.slice(S.length);
39
- return JSON.parse(decodeURIComponent(e)).localPath;
94
+ function Ee(e, n) {
95
+ if (!(e == null || n == null))
96
+ return { from: e, to: n };
97
+ }
98
+ function Se(e, n) {
99
+ if (e.from < 0 || e.to < 0 || e.from >= e.to)
100
+ throw new Error(`${n}: invalid bytes range: ${e}`);
101
+ }
102
+ function ve(e) {
103
+ return e !== void 0 && e.startsWith("log+live://log/");
104
+ }
105
+ function A(e) {
106
+ throw new Error("Unexpected object: " + e);
107
+ }
108
+ const N = "upload://upload/", O = "index://index/";
109
+ function B(e) {
110
+ return e.startsWith(N);
111
+ }
112
+ function U(e) {
113
+ return e.startsWith(O);
114
+ }
115
+ function K(e) {
116
+ if (U(e)) {
117
+ const n = e.slice(O.length);
118
+ return JSON.parse(decodeURIComponent(n)).path;
119
+ } else if (B(e)) {
120
+ const n = e.slice(N.length);
121
+ return JSON.parse(decodeURIComponent(n)).localPath;
40
122
  }
41
- w(n);
123
+ A(e);
42
124
  }
43
- function U(n) {
44
- return n.replace(/^.*[\\/]/, "");
125
+ function M(e) {
126
+ return e.replace(/^.*[\\/]/, "");
45
127
  }
46
- function kn(n) {
47
- return U(R(n));
128
+ function Ne(e) {
129
+ return M(K(e));
48
130
  }
49
- function En(n) {
50
- if (!n || typeof n != "object")
131
+ function Oe(e) {
132
+ if (!e || typeof e != "object")
51
133
  return !1;
52
- const e = n;
53
- if (!("type" in e))
134
+ const n = e;
135
+ if (!("type" in n))
54
136
  return !1;
55
- switch (e.type) {
137
+ switch (n.type) {
56
138
  case "Json":
57
- return typeof e.keyLength == "number" && e.data !== void 0 && typeof e.data == "object";
139
+ return typeof n.keyLength == "number" && n.data !== void 0 && typeof n.data == "object";
58
140
  case "JsonPartitioned":
59
- return typeof e.partitionKeyLength == "number" && e.parts !== void 0 && typeof e.parts == "object";
141
+ return typeof n.partitionKeyLength == "number" && n.parts !== void 0 && typeof n.parts == "object";
60
142
  case "BinaryPartitioned":
61
- return typeof e.partitionKeyLength == "number" && e.parts !== void 0 && typeof e.parts == "object";
143
+ return typeof n.partitionKeyLength == "number" && n.parts !== void 0 && typeof n.parts == "object";
62
144
  default:
63
145
  return !1;
64
146
  }
65
147
  }
66
- function Nn(n, e) {
67
- if (n !== void 0)
68
- switch (n.type) {
148
+ function Ce(e, n) {
149
+ if (e !== void 0)
150
+ switch (e.type) {
69
151
  case "Json":
70
- return n;
152
+ return e;
71
153
  case "JsonPartitioned": {
72
154
  const t = {};
73
- for (const [r, o] of Object.entries(n.parts))
74
- t[r] = e(o);
155
+ for (const [r, o] of Object.entries(e.parts))
156
+ t[r] = n(o);
75
157
  return {
76
- ...n,
158
+ ...e,
77
159
  parts: t
78
160
  };
79
161
  }
80
162
  case "BinaryPartitioned": {
81
163
  const t = {};
82
- for (const [r, o] of Object.entries(n.parts))
164
+ for (const [r, o] of Object.entries(e.parts))
83
165
  t[r] = {
84
- index: e(o.index),
85
- values: e(o.values)
166
+ index: n(o.index),
167
+ values: n(o.values)
86
168
  };
87
169
  return {
88
- ...n,
170
+ ...e,
89
171
  parts: t
90
172
  };
91
173
  }
92
174
  }
93
175
  }
94
- function K(n) {
95
- if (!n || typeof n != "object")
176
+ function _(e) {
177
+ if (!e || typeof e != "object")
96
178
  return !1;
97
- const e = n;
98
- if (!("type" in e))
179
+ const n = e;
180
+ if (!("type" in n))
99
181
  return !1;
100
- switch (e.type) {
182
+ switch (n.type) {
101
183
  case "Json":
102
- return typeof e.keyLength == "number" && Array.isArray(e.data);
184
+ return typeof n.keyLength == "number" && Array.isArray(n.data);
103
185
  case "JsonPartitioned":
104
- return typeof e.partitionKeyLength == "number" && Array.isArray(e.parts);
186
+ return typeof n.partitionKeyLength == "number" && Array.isArray(n.parts);
105
187
  case "BinaryPartitioned":
106
- return typeof e.partitionKeyLength == "number" && Array.isArray(e.parts);
188
+ return typeof n.partitionKeyLength == "number" && Array.isArray(n.parts);
107
189
  default:
108
190
  return !1;
109
191
  }
110
192
  }
111
- function Sn(n) {
112
- return K(n) ? n.type === "JsonPartitioned" || n.type === "BinaryPartitioned" : !1;
193
+ function $e(e) {
194
+ return _(e) ? e.type === "JsonPartitioned" || e.type === "BinaryPartitioned" : !1;
113
195
  }
114
- function Cn(n) {
115
- switch (n.type) {
196
+ function Ve(e) {
197
+ switch (e.type) {
116
198
  case "Json": {
117
- const e = Object.entries(n.data).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
199
+ const n = Object.entries(e.data).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
118
200
  return {
119
201
  type: "Json",
120
- keyLength: n.keyLength,
121
- data: e
202
+ keyLength: e.keyLength,
203
+ data: n
122
204
  };
123
205
  }
124
206
  case "JsonPartitioned": {
125
- const e = Object.entries(n.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
207
+ const n = Object.entries(e.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
126
208
  return {
127
209
  type: "JsonPartitioned",
128
- partitionKeyLength: n.partitionKeyLength,
129
- parts: e
210
+ partitionKeyLength: e.partitionKeyLength,
211
+ parts: n
130
212
  };
131
213
  }
132
214
  case "BinaryPartitioned": {
133
- const e = Object.entries(n.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
215
+ const n = Object.entries(e.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
134
216
  return {
135
217
  type: "BinaryPartitioned",
136
- partitionKeyLength: n.partitionKeyLength,
137
- parts: e
218
+ partitionKeyLength: e.partitionKeyLength,
219
+ parts: n
138
220
  };
139
221
  }
140
222
  }
141
223
  }
142
- function Jn(n) {
143
- switch (n.type) {
224
+ function Ie(e) {
225
+ switch (e.type) {
144
226
  case "Json": {
145
- const e = {};
146
- for (const t of n.data)
147
- e[JSON.stringify(t.key)] = t.value;
227
+ const n = {};
228
+ for (const t of e.data)
229
+ n[JSON.stringify(t.key)] = t.value;
148
230
  return {
149
231
  type: "Json",
150
- keyLength: n.keyLength,
151
- data: e
232
+ keyLength: e.keyLength,
233
+ data: n
152
234
  };
153
235
  }
154
236
  case "JsonPartitioned": {
155
- const e = {};
156
- for (const t of n.parts)
157
- e[JSON.stringify(t.key)] = t.value;
237
+ const n = {};
238
+ for (const t of e.parts)
239
+ n[JSON.stringify(t.key)] = t.value;
158
240
  return {
159
241
  type: "JsonPartitioned",
160
- partitionKeyLength: n.partitionKeyLength,
161
- parts: e
242
+ partitionKeyLength: e.partitionKeyLength,
243
+ parts: n
162
244
  };
163
245
  }
164
246
  case "BinaryPartitioned": {
165
- const e = {};
166
- for (const t of n.parts)
167
- e[JSON.stringify(t.key)] = t.value;
247
+ const n = {};
248
+ for (const t of e.parts)
249
+ n[JSON.stringify(t.key)] = t.value;
168
250
  return {
169
251
  type: "BinaryPartitioned",
170
- partitionKeyLength: n.partitionKeyLength,
171
- parts: e
252
+ partitionKeyLength: e.partitionKeyLength,
253
+ parts: n
172
254
  };
173
255
  }
174
256
  }
175
257
  }
176
- function On(n, e) {
177
- if (n !== void 0)
178
- switch (n.type) {
258
+ function je(e, n) {
259
+ if (e !== void 0)
260
+ switch (e.type) {
179
261
  case "Json":
180
- return n;
262
+ return e;
181
263
  case "JsonPartitioned": {
182
- const t = n.parts.map((r) => ({
264
+ const t = e.parts.map((r) => ({
183
265
  key: r.key,
184
- value: e(r.value)
266
+ value: n(r.value)
185
267
  }));
186
268
  return {
187
- ...n,
269
+ ...e,
188
270
  parts: t
189
271
  };
190
272
  }
191
273
  case "BinaryPartitioned": {
192
- const t = n.parts.map((r) => ({
274
+ const t = e.parts.map((r) => ({
193
275
  key: r.key,
194
276
  value: {
195
- index: e(r.value.index),
196
- values: e(r.value.values)
277
+ index: n(r.value.index),
278
+ values: n(r.value.values)
197
279
  }
198
280
  }));
199
281
  return {
200
- ...n,
282
+ ...e,
201
283
  parts: t
202
284
  };
203
285
  }
204
286
  }
205
287
  }
206
- const _ = -2147483648, x = -9007199254740991n, $n = NaN, In = NaN, M = null, T = null;
207
- function g(n, e) {
208
- switch (e) {
288
+ const q = -2147483648, x = -9007199254740991n, Fe = NaN, Je = NaN, T = null, z = null;
289
+ function b(e, n) {
290
+ switch (n) {
209
291
  case "Int":
210
- return n === _;
292
+ return e === q;
211
293
  case "Long":
212
- return n === Number(x) || n === x;
294
+ return e === Number(x) || e === x;
213
295
  case "Float":
214
- return Number.isNaN(n);
296
+ return Number.isNaN(e);
215
297
  case "Double":
216
- return Number.isNaN(n);
298
+ return Number.isNaN(e);
217
299
  case "String":
218
- return n === M;
300
+ return e === T;
219
301
  case "Bytes":
220
- return n === T;
302
+ return e === z;
221
303
  default:
222
- throw Error(`unsupported data type: ${e}`);
304
+ throw Error(`unsupported data type: ${n}`);
223
305
  }
224
306
  }
225
- function Vn(n) {
226
- if (!z(n)) throw new Error(`Expected not-NA PValue, got ${n}`);
227
- return n;
307
+ function Re(e) {
308
+ if (!H(e)) throw new Error(`Expected not-NA PValue, got ${e}`);
309
+ return e;
228
310
  }
229
- function z(n, e) {
230
- if (!e)
231
- return typeof n == "string" || typeof n == "number" && isFinite(n) || typeof n == "bigint";
232
- if (g(n, e)) return !1;
233
- switch (e) {
311
+ function H(e, n) {
312
+ if (!n)
313
+ return typeof e == "string" || typeof e == "number" && isFinite(e) || typeof e == "bigint";
314
+ if (b(e, n)) return !1;
315
+ switch (n) {
234
316
  case "Int":
235
- return typeof n == "number";
317
+ return typeof e == "number";
236
318
  case "Long":
237
- return typeof n == "number" || typeof n == "bigint";
319
+ return typeof e == "number" || typeof e == "bigint";
238
320
  case "Float":
239
- return typeof n == "number";
321
+ return typeof e == "number";
240
322
  case "Double":
241
- return typeof n == "number";
323
+ return typeof e == "number";
242
324
  case "String":
243
- return typeof n == "string";
325
+ return typeof e == "string";
244
326
  case "Bytes":
245
327
  throw Error("Bytes not yet supported");
246
328
  default:
247
- throw Error(`unsupported data type: ${e}`);
329
+ throw Error(`unsupported data type: ${n}`);
248
330
  }
249
331
  }
250
- function H(n, e) {
251
- if (!e)
252
- return n === null || typeof n == "string" || typeof n == "number" || typeof n == "bigint";
253
- if (g(n, e)) return !0;
254
- switch (e) {
332
+ function W(e, n) {
333
+ if (!n)
334
+ return e === null || typeof e == "string" || typeof e == "number" || typeof e == "bigint";
335
+ if (b(e, n)) return !0;
336
+ switch (n) {
255
337
  case "Int":
256
- return typeof n == "number";
338
+ return typeof e == "number";
257
339
  case "Long":
258
- return typeof n == "number" || typeof n == "bigint";
340
+ return typeof e == "number" || typeof e == "bigint";
259
341
  case "Float":
260
- return typeof n == "number";
342
+ return typeof e == "number";
261
343
  case "Double":
262
- return typeof n == "number";
344
+ return typeof e == "number";
263
345
  case "String":
264
- return typeof n == "string";
346
+ return typeof e == "string";
265
347
  case "Bytes":
266
348
  throw Error("Bytes not yet supported");
267
349
  default:
268
- throw Error(`unsupported data type: ${e}`);
350
+ throw Error(`unsupported data type: ${n}`);
269
351
  }
270
352
  }
271
- function Dn(n) {
272
- if (n === null || typeof n == "string" || typeof n == "number") return n;
273
- if (typeof n == "bigint") return { bigint: n.toString() };
274
- throw new Error(`Type ${typeof n} (value ${n}) not yet supported.`);
353
+ function De(e) {
354
+ if (e === null || typeof e == "string" || typeof e == "number") return e;
355
+ if (typeof e == "bigint") return { bigint: e.toString() };
356
+ throw new Error(`Type ${typeof e} (value ${e}) not yet supported.`);
275
357
  }
276
- function q(n, e) {
277
- if (n === null || typeof n == "string" || typeof n == "number" || typeof n == "bigint") {
278
- if (e && !g(n, e) && !H(n, e))
279
- throw new Error(`Unexpected value type, got ${typeof n}, expected ${e}`);
280
- return n;
358
+ function G(e, n) {
359
+ if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "bigint") {
360
+ if (n && !b(e, n) && !W(e, n))
361
+ throw new Error(`Unexpected value type, got ${typeof e}, expected ${n}`);
362
+ return e;
281
363
  }
282
- if (typeof n == "object" && n !== null && "bigint" in n && typeof n.bigint == "string") {
283
- if (e && e !== "Long")
284
- throw new Error(`Unexpected value type, got serialized bigint, expected ${e}`);
285
- return BigInt(n.bigint);
364
+ if (typeof e == "object" && e !== null && "bigint" in e && typeof e.bigint == "string") {
365
+ if (n && n !== "Long")
366
+ throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);
367
+ return BigInt(e.bigint);
286
368
  }
287
- throw new Error(`Unsupported type ${typeof n} (value ${n}).`);
369
+ throw new Error(`Unsupported type ${typeof e} (value ${e}).`);
288
370
  }
289
- function Ln(n) {
290
- if (n = W(n), n === null) throw new Error("Value is null");
291
- return n;
371
+ function Le(e) {
372
+ if (e = X(e), e === null) throw new Error("Value is null");
373
+ return e;
292
374
  }
293
- function W(n) {
294
- if (n = q(n), n === null) return null;
295
- if (typeof n == "string") return n;
296
- if (typeof n == "number") {
297
- if (!isFinite(n)) throw new Error(`Value is not finite (${n})`);
298
- return n;
375
+ function X(e) {
376
+ if (e = G(e), e === null) return null;
377
+ if (typeof e == "string") return e;
378
+ if (typeof e == "number") {
379
+ if (!isFinite(e)) throw new Error(`Value is not finite (${e})`);
380
+ return e;
299
381
  }
300
- if (typeof n == "bigint")
301
- return Number(n);
302
- throw new Error(`Unexpected value type: ${typeof n}`);
303
- }
304
- function X(n, e) {
305
- const t = Math.floor(e / 8), r = 1 << 7 - e % 8;
306
- return (n[t] & r) > 0;
307
- }
308
- const G = { type: "absent" }, Q = null;
309
- function Bn(n) {
310
- return typeof n == "object" && n !== null && n.type === "absent";
311
- }
312
- function jn(n, e, t = {}) {
313
- if (X(n.absent, e))
314
- return t.absent === void 0 ? G : t.absent;
315
- const r = n.data[e], o = n.type;
316
- if (g(r, o)) return t.na === void 0 ? Q : t.na;
382
+ if (typeof e == "bigint")
383
+ return Number(e);
384
+ throw new Error(`Unexpected value type: ${typeof e}`);
385
+ }
386
+ function Q(e, n) {
387
+ const t = Math.floor(n / 8), r = 1 << 7 - n % 8;
388
+ return (e[t] & r) > 0;
389
+ }
390
+ const Y = { type: "absent" }, Z = null;
391
+ function Be(e) {
392
+ return typeof e == "object" && e !== null && e.type === "absent";
393
+ }
394
+ function Ue(e, n, t = {}) {
395
+ if (Q(e.absent, n))
396
+ return t.absent === void 0 ? Y : t.absent;
397
+ const r = e.data[n], o = e.type;
398
+ if (b(r, o)) return t.na === void 0 ? Z : t.na;
317
399
  switch (o) {
318
400
  case "Int":
319
401
  return r;
@@ -331,95 +413,109 @@ function jn(n, e, t = {}) {
331
413
  throw Error(`unsupported data type: ${o}`);
332
414
  }
333
415
  }
334
- function vn(n) {
416
+ function Ke(e) {
335
417
  return {
336
- kind: n.kind,
337
- valueType: n.valueType,
338
- name: n.name,
339
- domain: n.domain,
340
- parentAxes: n.parentAxes,
341
- axesId: J(n.axesSpec)
418
+ kind: e.kind,
419
+ valueType: e.valueType,
420
+ name: e.name,
421
+ domain: e.domain,
422
+ parentAxes: e.parentAxes,
423
+ axesId: C(e.axesSpec)
342
424
  };
343
425
  }
344
- function Fn(n) {
426
+ function Me(e) {
345
427
  return {
346
- columnId: n.id,
347
- spec: n.spec
428
+ columnId: e.id,
429
+ spec: e.spec
348
430
  };
349
431
  }
350
- function p(n) {
351
- const { type: e, name: t, domain: r } = n, o = { type: e, name: t };
432
+ function y(e) {
433
+ const { type: n, name: t, domain: r } = e, o = { type: n, name: t };
352
434
  return r && Object.entries(r).length > 0 && Object.assign(o, { domain: r }), o;
353
435
  }
354
- function J(n) {
355
- return n.map(p);
436
+ function C(e) {
437
+ return e.map(y);
356
438
  }
357
- function Rn(n) {
358
- return y(p(n));
439
+ function _e(e) {
440
+ return h(y(e));
359
441
  }
360
- function Y(n, e) {
361
- if (n === void 0) return e === void 0;
362
- if (e === void 0) return !0;
363
- for (const t in e)
364
- if (n[t] !== e[t]) return !1;
442
+ function ee(e, n) {
443
+ if (e === void 0) return n === void 0;
444
+ if (n === void 0) return !0;
445
+ for (const t in n)
446
+ if (e[t] !== n[t]) return !1;
365
447
  return !0;
366
448
  }
367
- function Z(n, e) {
368
- return n.name === e.name && Y(n.domain, e.domain);
449
+ function ne(e, n) {
450
+ return e.name === n.name && ee(e.domain, n.domain);
369
451
  }
370
- function Un(n, e) {
371
- return { ...n, src: h(n.src, e) };
452
+ function qe(e, n) {
453
+ return { ...e, src: g(e.src, n) };
372
454
  }
373
- function h(n, e) {
374
- switch (n.type) {
455
+ function g(e, n) {
456
+ switch (e.type) {
375
457
  case "column":
376
458
  return {
377
459
  type: "column",
378
- column: e(n.column)
460
+ column: n(e.column)
379
461
  };
380
462
  case "slicedColumn":
381
463
  return {
382
464
  type: "slicedColumn",
383
- column: e(n.column),
384
- newId: n.newId,
385
- axisFilters: n.axisFilters
465
+ column: n(e.column),
466
+ newId: e.newId,
467
+ axisFilters: e.axisFilters
386
468
  };
387
469
  case "inlineColumn":
388
- return n;
470
+ return e;
389
471
  case "inner":
390
472
  case "full":
391
473
  return {
392
- type: n.type,
393
- entries: n.entries.map((t) => h(t, e))
474
+ type: e.type,
475
+ entries: e.entries.map((t) => g(t, n))
394
476
  };
395
477
  case "outer":
396
478
  return {
397
479
  type: "outer",
398
- primary: h(n.primary, e),
399
- secondary: n.secondary.map((t) => h(t, e))
480
+ primary: g(e.primary, n),
481
+ secondary: e.secondary.map((t) => g(t, n))
400
482
  };
401
483
  default:
402
- w(n);
484
+ A(e);
485
+ }
486
+ }
487
+ function Te(e) {
488
+ switch (e.type) {
489
+ case "axis":
490
+ return {
491
+ type: "axis",
492
+ id: e.id
493
+ };
494
+ case "column":
495
+ return {
496
+ type: "column",
497
+ id: e.id
498
+ };
403
499
  }
404
500
  }
405
- function nn(n) {
406
- return y(n);
501
+ function te(e) {
502
+ return h(e);
407
503
  }
408
- function Kn(n) {
409
- return JSON.parse(n);
504
+ function ze(e) {
505
+ return JSON.parse(e);
410
506
  }
411
- function P(n) {
412
- return y(p(n));
507
+ function P(e) {
508
+ return h(y(e));
413
509
  }
414
- function k(n, e) {
415
- return JSON.stringify([n, e]);
510
+ function E(e, n) {
511
+ return JSON.stringify([e, n]);
416
512
  }
417
- class _n {
513
+ class He {
418
514
  /**
419
515
  * Creates a new anchor context from a set of anchor column specifications
420
516
  * @param anchors Record of anchor column specifications indexed by anchor ID
421
517
  */
422
- constructor(e) {
518
+ constructor(n) {
423
519
  l(this, "domains", /* @__PURE__ */ new Map());
424
520
  l(this, "axes", /* @__PURE__ */ new Map());
425
521
  /**
@@ -431,19 +527,19 @@ class _n {
431
527
  * Maps domain packs to anchors
432
528
  */
433
529
  l(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
434
- this.anchors = e;
435
- const t = Object.entries(e);
530
+ this.anchors = n;
531
+ const t = Object.entries(n);
436
532
  t.sort((r, o) => r[0].localeCompare(o[0]));
437
533
  for (const [r, o] of t) {
438
- for (let s = 0; s < o.axesSpec.length; s++) {
439
- const a = o.axesSpec[s], i = P(a);
440
- this.axes.set(i, { anchor: r, idx: s });
534
+ for (let i = 0; i < o.axesSpec.length; i++) {
535
+ const a = o.axesSpec[i], s = P(a);
536
+ this.axes.set(s, { anchor: r, idx: i });
441
537
  }
442
538
  if (o.domain !== void 0) {
443
- const s = Object.entries(o.domain);
444
- s.sort((a, i) => a[0].localeCompare(i[0])), this.domainPackToAnchor.set(JSON.stringify(s), r), this.domainPacks.push(s.map(([a]) => a));
445
- for (const [a, i] of s) {
446
- const u = k(a, i);
539
+ const i = Object.entries(o.domain);
540
+ i.sort((a, s) => a[0].localeCompare(s[0])), this.domainPackToAnchor.set(JSON.stringify(i), r), this.domainPacks.push(i.map(([a]) => a));
541
+ for (const [a, s] of i) {
542
+ const u = E(a, s);
447
543
  this.domains.set(u, r);
448
544
  }
449
545
  }
@@ -452,57 +548,57 @@ class _n {
452
548
  /**
453
549
  * Implementation of derive method
454
550
  */
455
- derive(e, t) {
551
+ derive(n, t) {
456
552
  const r = {
457
- name: e.name,
553
+ name: n.name,
458
554
  axes: []
459
555
  };
460
556
  let o;
461
- if (e.domain !== void 0)
462
- n:
557
+ if (n.domain !== void 0)
558
+ e:
463
559
  for (const a of this.domainPacks) {
464
- const i = [];
560
+ const s = [];
465
561
  for (const c of a) {
466
- const m = e.domain[c];
467
- if (m !== void 0)
468
- i.push([c, m]);
562
+ const f = n.domain[c];
563
+ if (f !== void 0)
564
+ s.push([c, f]);
469
565
  else
470
- break n;
566
+ break e;
471
567
  }
472
- const u = this.domainPackToAnchor.get(JSON.stringify(i));
568
+ const u = this.domainPackToAnchor.get(JSON.stringify(s));
473
569
  if (u !== void 0) {
474
570
  r.domainAnchor = u, o = new Set(a);
475
571
  break;
476
572
  }
477
573
  }
478
- for (const [a, i] of Object.entries(e.domain ?? {})) {
574
+ for (const [a, s] of Object.entries(n.domain ?? {})) {
479
575
  if (o !== void 0 && o.has(a))
480
576
  continue;
481
- const u = k(a, i), c = this.domains.get(u);
482
- r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : i;
577
+ const u = E(a, s), c = this.domains.get(u);
578
+ r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : s;
483
579
  }
484
- if (r.axes = e.axesSpec.map((a) => {
485
- const i = P(a), u = this.axes.get(i);
486
- return u === void 0 ? p(a) : u;
580
+ if (r.axes = n.axesSpec.map((a) => {
581
+ const s = P(a), u = this.axes.get(s);
582
+ return u === void 0 ? y(a) : u;
487
583
  }), !t || t.length === 0)
488
584
  return r;
489
- const s = [];
585
+ const i = [];
490
586
  for (const a of t) {
491
- const [i, u] = a;
492
- if (typeof i == "number") {
493
- if (i < 0 || i >= e.axesSpec.length)
494
- throw new Error(`Axis index ${i} is out of bounds (0-${e.axesSpec.length - 1})`);
495
- s.push([i, u]);
587
+ const [s, u] = a;
588
+ if (typeof s == "number") {
589
+ if (s < 0 || s >= n.axesSpec.length)
590
+ throw new Error(`Axis index ${s} is out of bounds (0-${n.axesSpec.length - 1})`);
591
+ i.push([s, u]);
496
592
  } else {
497
- const c = e.axesSpec.findIndex((m) => m.name === i);
593
+ const c = n.axesSpec.findIndex((f) => f.name === s);
498
594
  if (c === -1)
499
- throw new Error(`Axis with name "${i}" not found in the column specification`);
500
- s.push([c, u]);
595
+ throw new Error(`Axis with name "${s}" not found in the column specification`);
596
+ i.push([c, u]);
501
597
  }
502
598
  }
503
- return s.sort((a, i) => a[0] - i[0]), {
599
+ return i.sort((a, s) => a[0] - s[0]), {
504
600
  source: r,
505
- axisFilters: s
601
+ axisFilters: i
506
602
  };
507
603
  }
508
604
  /**
@@ -511,58 +607,58 @@ class _n {
511
607
  * @param axisFilters Optional axis filters to apply to the column
512
608
  * @returns A canonicalized string representation of the anchored column identifier
513
609
  */
514
- deriveS(e, t) {
515
- return nn(this.derive(e, t));
610
+ deriveS(n, t) {
611
+ return te(this.derive(n, t));
516
612
  }
517
613
  }
518
- function Mn(n, e, t) {
519
- const r = { ...e }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
614
+ function We(e, n, t) {
615
+ const r = { ...n }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
520
616
  if (r.domainAnchor !== void 0) {
521
- const s = n[r.domainAnchor];
522
- if (!s)
617
+ const i = e[r.domainAnchor];
618
+ if (!i)
523
619
  throw new Error(`Anchor "${r.domainAnchor}" not found`);
524
- const a = s.domain || {};
620
+ const a = i.domain || {};
525
621
  r.domain = { ...a, ...r.domain }, delete r.domainAnchor;
526
622
  }
527
623
  if (r.domain) {
528
- const s = {};
529
- for (const [a, i] of Object.entries(r.domain))
530
- if (typeof i == "string")
531
- s[a] = i;
624
+ const i = {};
625
+ for (const [a, s] of Object.entries(r.domain))
626
+ if (typeof s == "string")
627
+ i[a] = s;
532
628
  else {
533
- const u = n[i.anchor];
629
+ const u = e[s.anchor];
534
630
  if (!u)
535
- throw new Error(`Anchor "${i.anchor}" not found for domain key "${a}"`);
631
+ throw new Error(`Anchor "${s.anchor}" not found for domain key "${a}"`);
536
632
  if (!u.domain || u.domain[a] === void 0) {
537
633
  if (!o)
538
- throw new Error(`Domain key "${a}" not found in anchor "${i.anchor}"`);
634
+ throw new Error(`Domain key "${a}" not found in anchor "${s.anchor}"`);
539
635
  continue;
540
636
  }
541
- s[a] = u.domain[a];
637
+ i[a] = u.domain[a];
542
638
  }
543
- r.domain = s;
639
+ r.domain = i;
544
640
  }
545
- return r.axes && (r.axes = r.axes.map((s) => en(n, s))), r;
641
+ return r.axes && (r.axes = r.axes.map((i) => re(e, i))), r;
546
642
  }
547
- function en(n, e) {
548
- if (!tn(e))
549
- return e;
550
- const t = e.anchor, r = n[t];
643
+ function re(e, n) {
644
+ if (!oe(n))
645
+ return n;
646
+ const t = n.anchor, r = e[t];
551
647
  if (!r)
552
648
  throw new Error(`Anchor "${t}" not found for axis reference`);
553
- if ("idx" in e) {
554
- if (e.idx < 0 || e.idx >= r.axesSpec.length)
555
- throw new Error(`Axis index ${e.idx} out of bounds for anchor "${t}"`);
556
- return r.axesSpec[e.idx];
557
- } else if ("name" in e) {
558
- const o = r.axesSpec.filter((s) => s.name === e.name);
649
+ if ("idx" in n) {
650
+ if (n.idx < 0 || n.idx >= r.axesSpec.length)
651
+ throw new Error(`Axis index ${n.idx} out of bounds for anchor "${t}"`);
652
+ return r.axesSpec[n.idx];
653
+ } else if ("name" in n) {
654
+ const o = r.axesSpec.filter((i) => i.name === n.name);
559
655
  if (o.length > 1)
560
- throw new Error(`Multiple axes with name "${e.name}" found in anchor "${t}"`);
656
+ throw new Error(`Multiple axes with name "${n.name}" found in anchor "${t}"`);
561
657
  if (o.length === 0)
562
- throw new Error(`Axis with name "${e.name}" not found in anchor "${t}"`);
658
+ throw new Error(`Axis with name "${n.name}" not found in anchor "${t}"`);
563
659
  return o[0];
564
- } else if ("id" in e) {
565
- const o = r.axesSpec.filter((s) => Z(e.id, p(s)));
660
+ } else if ("id" in n) {
661
+ const o = r.axesSpec.filter((i) => ne(n.id, y(i)));
566
662
  if (o.length > 1)
567
663
  throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);
568
664
  if (o.length === 0)
@@ -571,42 +667,42 @@ function en(n, e) {
571
667
  }
572
668
  throw new Error("Unsupported axis reference type");
573
669
  }
574
- function tn(n) {
575
- return typeof n == "object" && "anchor" in n;
670
+ function oe(e) {
671
+ return typeof e == "object" && "anchor" in e;
576
672
  }
577
- function Tn(n) {
578
- return typeof n == "object" && n !== null && "source" in n && "axisFilters" in n;
673
+ function Ge(e) {
674
+ return typeof e == "object" && e !== null && "source" in e && "axisFilters" in e;
579
675
  }
580
- function f(n) {
581
- return n.kind === "PColumn";
676
+ function d(e) {
677
+ return e.kind === "PColumn";
582
678
  }
583
- function rn(n) {
584
- return f(n.spec);
679
+ function ie(e) {
680
+ return d(e.spec);
585
681
  }
586
- function zn(n) {
587
- return f(n.obj);
682
+ function Xe(e) {
683
+ return d(e.obj);
588
684
  }
589
- function Hn(n) {
590
- return f(n.obj.spec);
685
+ function Qe(e) {
686
+ return d(e.obj.spec);
591
687
  }
592
- function qn(n) {
593
- if (!rn(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
594
- return n;
688
+ function Ye(e) {
689
+ if (!ie(e)) throw new Error(`not a PColumn (kind = ${e.spec.kind})`);
690
+ return e;
595
691
  }
596
- function Wn(n, e) {
597
- return n === void 0 ? void 0 : {
598
- ...n,
599
- data: e(n.data)
692
+ function Ze(e, n) {
693
+ return e === void 0 ? void 0 : {
694
+ ...e,
695
+ data: n(e.data)
600
696
  };
601
697
  }
602
- function Xn(n) {
603
- const e = /* @__PURE__ */ new Map(), t = (r) => {
698
+ function en(e) {
699
+ const n = /* @__PURE__ */ new Map(), t = (r) => {
604
700
  switch (r.type) {
605
701
  case "column":
606
- e.set(r.column.id, r.column);
702
+ n.set(r.column.id, r.column);
607
703
  return;
608
704
  case "slicedColumn":
609
- e.set(r.column.id, r.column);
705
+ n.set(r.column.id, r.column);
610
706
  return;
611
707
  case "inlineColumn":
612
708
  return;
@@ -619,389 +715,463 @@ function Xn(n) {
619
715
  for (const o of r.secondary) t(o);
620
716
  return;
621
717
  default:
622
- w(r);
718
+ A(r);
623
719
  }
624
720
  };
625
- return t(n), [...e.values()];
721
+ return t(e), [...n.values()];
626
722
  }
627
- function on(n) {
628
- throw new Error("Unexpected object: " + n);
723
+ function se(e) {
724
+ throw new Error("Unexpected object: " + e);
629
725
  }
630
- function b(n, e) {
631
- switch (n.type) {
726
+ function w(e, n) {
727
+ switch (e.type) {
632
728
  case "and":
633
- for (const t of n.operands)
634
- if (!b(t, e)) return !1;
729
+ for (const t of e.operands)
730
+ if (!w(t, n)) return !1;
635
731
  return !0;
636
732
  case "or":
637
- for (const t of n.operands)
638
- if (b(t, e)) return !0;
733
+ for (const t of e.operands)
734
+ if (w(t, n)) return !0;
639
735
  return !1;
640
736
  case "not":
641
- return !b(n.operand, e);
737
+ return !w(e.operand, n);
642
738
  case "name":
643
- return f(e) && e.name === n.name;
739
+ return d(n) && n.name === e.name;
644
740
  case "name_pattern":
645
- return f(e) && !!e.name.match(n.pattern);
741
+ return d(n) && !!n.name.match(e.pattern);
646
742
  case "annotation":
647
- return f(e) && e.annotations !== void 0 && e.annotations[n.annotation] === n.value;
743
+ return d(n) && n.annotations !== void 0 && n.annotations[e.annotation] === e.value;
648
744
  case "annotation_pattern":
649
- return f(e) && e.annotations !== void 0 && e.annotations[n.annotation] !== void 0 && !!e.annotations[n.annotation].match(n.pattern);
745
+ return d(n) && n.annotations !== void 0 && n.annotations[e.annotation] !== void 0 && !!n.annotations[e.annotation].match(e.pattern);
650
746
  case "has_axes":
651
- return f(e) && n.axes.every(
652
- (t) => e.axesSpec.some(
747
+ return d(n) && e.axes.every(
748
+ (t) => n.axesSpec.some(
653
749
  (r) => (t.type === void 0 || t.type === r.type) && (t.name === void 0 || t.name === r.name) && (t.domain === void 0 || Object.keys(t.domain).length === 0 || r.domain !== void 0 && Object.entries(t.domain).every(
654
- ([o, s]) => r.domain[o] === s
750
+ ([o, i]) => r.domain[o] === i
655
751
  ))
656
752
  )
657
753
  );
658
754
  default:
659
- on(n);
755
+ se(e);
660
756
  }
661
757
  }
662
- function E(n, e) {
663
- if (n.name !== void 0 && n.name !== e.name)
758
+ function S(e, n) {
759
+ if (e.name !== void 0 && e.name !== n.name)
664
760
  return !1;
665
- if (n.type !== void 0) {
666
- if (Array.isArray(n.type)) {
667
- if (!n.type.includes(e.type))
761
+ if (e.type !== void 0) {
762
+ if (Array.isArray(e.type)) {
763
+ if (!e.type.includes(n.type))
668
764
  return !1;
669
- } else if (n.type !== e.type)
765
+ } else if (e.type !== n.type)
670
766
  return !1;
671
767
  }
672
- if (n.domain !== void 0) {
673
- const t = e.domain || {};
674
- for (const [r, o] of Object.entries(n.domain))
768
+ if (e.domain !== void 0) {
769
+ const t = n.domain || {};
770
+ for (const [r, o] of Object.entries(e.domain))
675
771
  if (t[r] !== o)
676
772
  return !1;
677
773
  }
678
774
  return !0;
679
775
  }
680
- function N(n, e) {
681
- if (e.name !== void 0 && n.name !== e.name || e.namePattern !== void 0 && !new RegExp(e.namePattern).test(n.name))
776
+ function v(e, n) {
777
+ if (n.name !== void 0 && e.name !== n.name || n.namePattern !== void 0 && !new RegExp(n.namePattern).test(e.name))
682
778
  return !1;
683
- if (e.type !== void 0) {
684
- if (Array.isArray(e.type)) {
685
- if (!e.type.includes(n.valueType))
779
+ if (n.type !== void 0) {
780
+ if (Array.isArray(n.type)) {
781
+ if (!n.type.includes(e.valueType))
686
782
  return !1;
687
- } else if (e.type !== n.valueType)
783
+ } else if (n.type !== e.valueType)
688
784
  return !1;
689
785
  }
690
- if (e.domain !== void 0) {
691
- const t = n.domain || {};
692
- for (const [r, o] of Object.entries(e.domain))
786
+ if (n.domain !== void 0) {
787
+ const t = e.domain || {};
788
+ for (const [r, o] of Object.entries(n.domain))
693
789
  if (t[r] !== o)
694
790
  return !1;
695
791
  }
696
- if (e.axes !== void 0) {
697
- const t = n.axesSpec.map(p);
698
- if (e.partialAxesMatch) {
699
- for (const r of e.axes)
700
- if (!t.some((o) => E(r, o)))
792
+ if (n.axes !== void 0) {
793
+ const t = e.axesSpec.map(y);
794
+ if (n.partialAxesMatch) {
795
+ for (const r of n.axes)
796
+ if (!t.some((o) => S(r, o)))
701
797
  return !1;
702
798
  } else {
703
- if (t.length !== e.axes.length)
799
+ if (t.length !== n.axes.length)
704
800
  return !1;
705
- for (let r = 0; r < e.axes.length; r++)
706
- if (!E(e.axes[r], t[r]))
801
+ for (let r = 0; r < n.axes.length; r++)
802
+ if (!S(n.axes[r], t[r]))
707
803
  return !1;
708
804
  }
709
805
  }
710
- if (e.annotations !== void 0) {
711
- const t = n.annotations || {};
712
- for (const [r, o] of Object.entries(e.annotations))
806
+ if (n.annotations !== void 0) {
807
+ const t = e.annotations || {};
808
+ for (const [r, o] of Object.entries(n.annotations))
713
809
  if (t[r] !== o)
714
810
  return !1;
715
811
  }
716
- if (e.annotationPatterns !== void 0) {
717
- const t = n.annotations || {};
718
- for (const [r, o] of Object.entries(e.annotationPatterns)) {
719
- const s = t[r];
720
- if (s === void 0 || !new RegExp(o).test(s))
812
+ if (n.annotationPatterns !== void 0) {
813
+ const t = e.annotations || {};
814
+ for (const [r, o] of Object.entries(n.annotationPatterns)) {
815
+ const i = t[r];
816
+ if (i === void 0 || !new RegExp(o).test(i))
721
817
  return !1;
722
818
  }
723
819
  }
724
820
  return !0;
725
821
  }
726
- function Gn(n) {
727
- return Array.isArray(n) ? (e) => n.some((t) => f(e) && N(e, t)) : (e) => f(e) && N(e, n);
822
+ function nn(e) {
823
+ return Array.isArray(e) ? (n) => e.some((t) => d(n) && v(n, t)) : (n) => d(n) && v(n, e);
728
824
  }
729
- function Qn(n) {
730
- const e = {
731
- kind: n.kind,
732
- name: n.name
825
+ function tn(e) {
826
+ const n = {
827
+ kind: e.kind,
828
+ name: e.name
733
829
  };
734
- return n.domain !== void 0 && (e.domain = n.domain), f(n) && (e.axesSpec = J(n.axesSpec)), y(e);
830
+ return e.domain !== void 0 && (n.domain = e.domain), d(e) && (n.axesSpec = C(e.axesSpec)), h(n);
735
831
  }
736
- const Yn = { href: "/" }, Zn = d.object({
737
- __isRef: d.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
738
- blockId: d.string().describe("Upstream block id"),
739
- name: d.string().describe("Name of the output provided to the upstream block's output context"),
740
- requireEnrichments: d.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
832
+ const rn = { href: "/" }, on = p.object({
833
+ __isRef: p.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
834
+ blockId: p.string().describe("Upstream block id"),
835
+ name: p.string().describe("Name of the output provided to the upstream block's output context"),
836
+ requireEnrichments: p.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
741
837
  }).describe(
742
838
  "Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees."
743
839
  ).readonly();
744
- function ne(n) {
745
- return typeof n == "object" && n !== null && "__isRef" in n && n.__isRef === !0 && "blockId" in n && "name" in n;
840
+ function sn(e) {
841
+ return typeof e == "object" && e !== null && "__isRef" in e && e.__isRef === !0 && "blockId" in e && "name" in e;
746
842
  }
747
- function ee(n, e, t = !1) {
843
+ function an(e, n, t = !1) {
748
844
  return t ? {
749
845
  __isRef: !0,
750
- blockId: n,
751
- name: e,
846
+ blockId: e,
847
+ name: n,
752
848
  requireEnrichments: !0
753
849
  } : {
754
850
  __isRef: !0,
755
- blockId: n,
756
- name: e
851
+ blockId: e,
852
+ name: n
757
853
  };
758
854
  }
759
- function te(n, e = !0) {
760
- if (e)
855
+ function un(e, n = !0) {
856
+ if (n)
761
857
  return {
762
- ...n,
858
+ ...e,
763
859
  requireEnrichments: !0
764
860
  };
765
861
  {
766
- const { requireEnrichments: t, ...r } = n;
862
+ const { requireEnrichments: t, ...r } = e;
767
863
  return r;
768
864
  }
769
865
  }
770
- function re(n, e, t = !1) {
771
- return n.blockId === e.blockId && n.name === e.name && (t || n.requireEnrichments === e.requireEnrichments);
866
+ function cn(e, n, t = !1) {
867
+ return e.blockId === n.blockId && e.name === n.name && (t || e.requireEnrichments === n.requireEnrichments);
772
868
  }
773
- function oe(n, e) {
774
- return n.ok ? { ok: !0, value: e(n.value) } : n;
869
+ function fn(e, n) {
870
+ return e.ok ? { ok: !0, value: n(e.value) } : e;
775
871
  }
776
- function sn(n) {
777
- if (n instanceof Int8Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray)
778
- return new DataView(n.buffer, n.byteOffset, n.byteLength);
779
- if (n instanceof ArrayBuffer) return new DataView(n);
872
+ function ae(e) {
873
+ if (e instanceof Int8Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray)
874
+ return new DataView(e.buffer, e.byteOffset, e.byteLength);
875
+ if (e instanceof ArrayBuffer) return new DataView(e);
780
876
  throw new TypeError(
781
877
  "Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray"
782
878
  );
783
879
  }
784
- const an = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", un = "0123456789ABCDEFGHIJKLMNOPQRSTUV", cn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
785
- function O(n, e, t) {
880
+ const ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ce = "0123456789ABCDEFGHIJKLMNOPQRSTUV", fe = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
881
+ function $(e, n, t) {
786
882
  t = t || {};
787
883
  let r, o;
788
- switch (e) {
884
+ switch (n) {
789
885
  case "RFC3548":
790
886
  case "RFC4648":
791
- r = an, o = !0;
887
+ r = ue, o = !0;
792
888
  break;
793
889
  case "RFC4648-HEX":
794
- r = un, o = !0;
890
+ r = ce, o = !0;
795
891
  break;
796
892
  case "Crockford":
797
- r = cn, o = !1;
893
+ r = fe, o = !1;
798
894
  break;
799
895
  default:
800
- throw new Error("Unknown base32 variant: " + String(e));
801
- }
802
- const s = t.padding !== void 0 ? t.padding : o, a = sn(n);
803
- let i = 0, u = 0, c = "";
804
- for (let m = 0; m < a.byteLength; m++)
805
- for (u = u << 8 | a.getUint8(m), i += 8; i >= 5; )
806
- c += r[u >>> i - 5 & 31], i -= 5;
807
- if (i > 0 && (c += r[u << 5 - i & 31]), s)
896
+ throw new Error("Unknown base32 variant: " + String(n));
897
+ }
898
+ const i = t.padding !== void 0 ? t.padding : o, a = ae(e);
899
+ let s = 0, u = 0, c = "";
900
+ for (let f = 0; f < a.byteLength; f++)
901
+ for (u = u << 8 | a.getUint8(f), s += 8; s >= 5; )
902
+ c += r[u >>> s - 5 & 31], s -= 5;
903
+ if (s > 0 && (c += r[u << 5 - s & 31]), i)
808
904
  for (; c.length % 8 !== 0; )
809
905
  c += "=";
810
906
  return c;
811
907
  }
812
- const $ = 15, fn = 24, I = d.string().length(fn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
813
- function ie() {
814
- const n = new Uint8Array($);
815
- return crypto.getRandomValues(n), I.parse(O(n, "RFC4648"));
908
+ const V = 15, de = 24, I = p.string().length(de).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
909
+ function dn() {
910
+ const e = new Uint8Array(V);
911
+ return crypto.getRandomValues(e), I.parse($(e, "RFC4648"));
816
912
  }
817
- function dn(n) {
818
- if (n.length !== $) throw new Error(`Wrong number of bytes: ${n.length}`);
819
- return I.parse(O(n, "RFC4648"));
913
+ function le(e) {
914
+ if (e.length !== V) throw new Error(`Wrong number of bytes: ${e.length}`);
915
+ return I.parse($(e, "RFC4648"));
820
916
  }
821
- async function se(n) {
822
- const e = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", e.encode(n));
823
- return dn(new Uint8Array(t.slice(0, 15)));
917
+ async function ln(e) {
918
+ const n = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", n.encode(e));
919
+ return le(new Uint8Array(t.slice(0, 15)));
824
920
  }
825
- function ae(n) {
826
- return JSON.stringify(n);
921
+ function pn(e) {
922
+ return JSON.stringify(e);
827
923
  }
828
- function ue(n) {
829
- return y(n);
924
+ function mn(e) {
925
+ return h(e);
830
926
  }
831
- function ce(n) {
832
- return JSON.parse(n);
927
+ function yn(e) {
928
+ return JSON.parse(e);
833
929
  }
834
- class fe extends Error {
930
+ class hn extends Error {
835
931
  constructor() {
836
932
  super(...arguments);
837
933
  l(this, "name", "AbortError");
838
934
  }
839
935
  }
840
- class de extends Error {
936
+ class gn extends Error {
841
937
  constructor() {
842
938
  super(...arguments);
843
939
  l(this, "name", "UiError");
844
940
  }
845
941
  }
846
- function me(n) {
847
- return n instanceof Error && n.name === "AbortError";
942
+ function bn(e) {
943
+ return e instanceof Error && e.name === "AbortError";
848
944
  }
849
- function mn(n) {
850
- return n instanceof Error ? n.name === "AbortError" || mn(n.cause) : !1;
945
+ function pe(e) {
946
+ return e instanceof Error ? e.name === "AbortError" || pe(e.cause) : !1;
851
947
  }
852
- function le(n) {
853
- return n instanceof Error && n.name === "AggregateError";
948
+ function wn(e) {
949
+ return e instanceof Error && e.name === "AggregateError";
854
950
  }
855
- function ln(n) {
856
- if (typeof n == "string")
857
- return `String value was thrown: ${n}`;
858
- if (n && typeof n == "object")
951
+ function me(e) {
952
+ if (typeof e == "string")
953
+ return `String value was thrown: ${e}`;
954
+ if (e && typeof e == "object")
859
955
  try {
860
- return `Plain object was thrown: ${JSON.stringify(n)}`;
861
- } catch (e) {
862
- return `Non-serializable object was thrown (JSON.stringify failed: ${e instanceof Error ? e.message : String(e)}): ${String(n)}`;
956
+ return `Plain object was thrown: ${JSON.stringify(e)}`;
957
+ } catch (n) {
958
+ return `Non-serializable object was thrown (JSON.stringify failed: ${n instanceof Error ? n.message : String(n)}): ${String(e)}`;
863
959
  }
864
- return `Non-Error value (${typeof n}) was thrown: ${n}`;
960
+ return `Non-Error value (${typeof e}) was thrown: ${e}`;
865
961
  }
866
- function A(n) {
867
- return n instanceof Error ? n : new Error(ln(n));
962
+ function k(e) {
963
+ return e instanceof Error ? e : new Error(me(e));
868
964
  }
869
- function V(n) {
870
- const e = n.cause ? V(n.cause) : void 0, t = new Error(n.message, e !== void 0 ? { cause: e } : void 0);
871
- return t.name = n.name || "Error", t.stack = n.stack, t;
965
+ function j(e) {
966
+ const n = e.cause ? j(e.cause) : void 0, t = new Error(e.message, n !== void 0 ? { cause: n } : void 0);
967
+ return t.name = e.name || "Error", t.stack = e.stack, t;
872
968
  }
873
- function D(n) {
874
- const e = A(n), t = e.cause ? D(e.cause) : void 0;
969
+ function F(e) {
970
+ const n = k(e), t = n.cause ? F(n.cause) : void 0;
875
971
  return {
876
- name: e.name,
877
- message: e.message,
878
- stack: e.stack,
879
- ...e.cause !== void 0 && { cause: t }
972
+ name: n.name,
973
+ message: n.message,
974
+ stack: n.stack,
975
+ ...n.cause !== void 0 && { cause: t }
880
976
  };
881
977
  }
882
- function pe(n) {
883
- if (n.error)
884
- throw n.error;
885
- return n.value;
978
+ function An(e) {
979
+ if (e.error)
980
+ throw e.error;
981
+ return e.value;
886
982
  }
887
- function L(n) {
888
- return n.error ? { error: D(n.error) } : { value: n.value };
983
+ function J(e) {
984
+ return e.error ? { error: F(e.error) } : { value: e.value };
889
985
  }
890
- function ye(n) {
891
- return n.error ? { error: V(n.error) } : { value: n.value };
986
+ function kn(e) {
987
+ return e.error ? { error: j(e.error) } : { value: e.value };
892
988
  }
893
- function pn(n) {
989
+ function ye(e) {
894
990
  try {
895
- return { value: n() };
896
- } catch (e) {
897
- return { error: A(e) };
991
+ return { value: e() };
992
+ } catch (n) {
993
+ return { error: k(n) };
898
994
  }
899
995
  }
900
- async function yn(n) {
996
+ async function he(e) {
901
997
  try {
902
- return { value: await n() };
903
- } catch (e) {
904
- return { error: A(e) };
998
+ return { value: await e() };
999
+ } catch (n) {
1000
+ return { error: k(n) };
905
1001
  }
906
1002
  }
907
- function he(n) {
908
- const e = pn(n);
909
- return L(e);
1003
+ function xn(e) {
1004
+ const n = ye(e);
1005
+ return J(n);
1006
+ }
1007
+ async function Pn(e) {
1008
+ const n = await he(e);
1009
+ return J(n);
1010
+ }
1011
+ const En = ["supportsLazyState"], Sn = ["requiresUIAPIVersion", "requiresModelAPIVersion"];
1012
+ function vn(e, n, t = !0) {
1013
+ return e === void 0 ? !1 : e[n] === t;
1014
+ }
1015
+ function Nn(e) {
1016
+ return e === void 0 ? /* @__PURE__ */ new Set() : new Set(Object.entries(e).filter(([n, t]) => n.startsWith("requires") && t === !0).map(([n]) => n));
1017
+ }
1018
+ function On(e) {
1019
+ return e === void 0 ? /* @__PURE__ */ new Set() : new Set(Object.entries(e).filter(([n, t]) => n.startsWith("supports") && t === !0).map(([n]) => n));
910
1020
  }
911
- async function ge(n) {
912
- const e = await yn(n);
913
- return L(e);
1021
+ class ge extends Error {
1022
+ constructor(t) {
1023
+ super(`Some of the block requirements are not supported by the runtime: ${Array.from(t.entries()).map(([r, o]) => `${r}: ${o}`).join(", ")}`);
1024
+ l(this, "name", "IncompatibleFlagsError");
1025
+ this.incompatibleFlags = t;
1026
+ }
1027
+ }
1028
+ class Cn {
1029
+ constructor() {
1030
+ l(this, "supportedRequirements", /* @__PURE__ */ new Map());
1031
+ }
1032
+ /**
1033
+ * Adds a supported requirement to the runtime capabilities.
1034
+ * @param requirement - The requirement.
1035
+ * @param value - The value of the requirement. If not provided, defaults to true.
1036
+ */
1037
+ addSupportedRequirement(n, t = !0) {
1038
+ return this.supportedRequirements.has(n) || this.supportedRequirements.set(n, /* @__PURE__ */ new Set()), this.supportedRequirements.get(n).add(t), this;
1039
+ }
1040
+ /**
1041
+ * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
1042
+ * @param blockFlags - The block flags.
1043
+ * @returns A map of incompatible flags, or undefined if the block flags are compatible.
1044
+ */
1045
+ getIncompatibleFlags(n) {
1046
+ if (n === void 0) return;
1047
+ const t = /* @__PURE__ */ new Map();
1048
+ for (const [r, o] of Object.entries(n))
1049
+ if (r.startsWith("requires")) {
1050
+ if (o === void 0) continue;
1051
+ const i = this.supportedRequirements.get(r);
1052
+ (i === void 0 || !i.has(o)) && t.set(r, o);
1053
+ }
1054
+ return t.size === 0 ? void 0 : t;
1055
+ }
1056
+ /**
1057
+ * Checks if the block flags are compatible with the runtime capabilities.
1058
+ * @param blockFlags - The block flags.
1059
+ * @returns True if the block flags are compatible, false otherwise.
1060
+ */
1061
+ checkCompatibility(n) {
1062
+ return this.getIncompatibleFlags(n) === void 0;
1063
+ }
1064
+ /**
1065
+ * Throws an error if the block flags are incompatible with the runtime capabilities.
1066
+ * @param blockFlags - The block flags.
1067
+ * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
1068
+ */
1069
+ throwIfIncompatible(n) {
1070
+ const t = this.getIncompatibleFlags(n);
1071
+ if (t !== void 0)
1072
+ throw new ge(t);
1073
+ }
914
1074
  }
915
1075
  export {
916
- fe as AbortError,
917
- _n as AnchoredIdDeriver,
918
- Yn as DefaultNavigationState,
919
- G as PTableAbsent,
920
- Q as PTableNA,
921
- T as PValueBytesNA,
922
- In as PValueDoubleNA,
923
- $n as PValueFloatNA,
924
- _ as PValueIntNA,
1076
+ hn as AbortError,
1077
+ Sn as AllRequiresFeatureFlags,
1078
+ En as AllSupportsFeatureFlags,
1079
+ He as AnchoredIdDeriver,
1080
+ rn as DefaultNavigationState,
1081
+ ge as IncompatibleFlagsError,
1082
+ Y as PTableAbsent,
1083
+ Z as PTableNA,
1084
+ z as PValueBytesNA,
1085
+ Je as PValueDoubleNA,
1086
+ Fe as PValueFloatNA,
1087
+ q as PValueIntNA,
925
1088
  x as PValueLongNA,
926
- M as PValueStringNA,
1089
+ T as PValueStringNA,
927
1090
  I as PlId,
928
- $ as PlIdBytes,
929
- fn as PlIdLength,
930
- Zn as PlRef,
931
- wn as RangeBytes,
932
- de as UiError,
933
- Rn as canonicalizeAxisId,
934
- ue as canonicalizeJson,
935
- ee as createPlRef,
936
- Cn as dataInfoToEntries,
937
- Qn as deriveNativeId,
938
- V as deserializeError,
939
- ye as deserializeResult,
940
- se as digestPlId,
941
- A as ensureError,
942
- Vn as ensureNotNAPValue,
943
- qn as ensurePColumn,
944
- Jn as entriesToDataInfo,
945
- b as executePSpecPredicate,
946
- Xn as extractAllColumns,
947
- J as getAxesId,
948
- p as getAxisId,
949
- Fn as getColumnIdAndSpec,
950
- kn as getFileNameFromHandle,
951
- R as getFilePathFromHandle,
952
- vn as getPColumnSpecId,
953
- mn as hasAbortError,
954
- me as isAbortError,
955
- le as isAggregateError,
956
- En as isDataInfo,
957
- K as isDataInfoEntries,
958
- Tn as isFilteredPColumn,
959
- F as isImportFileHandleIndex,
960
- v as isImportFileHandleUpload,
961
- Pn as isLiveLog,
962
- z as isNotNAPValue,
963
- rn as isPColumn,
964
- Hn as isPColumnResult,
965
- f as isPColumnSpec,
966
- zn as isPColumnSpecResult,
967
- Bn as isPTableAbsent,
968
- H as isPValue,
969
- Sn as isPartitionedDataInfoEntries,
970
- ne as isPlRef,
971
- X as isValueAbsent,
972
- g as isValueNA,
973
- Nn as mapDataInfo,
974
- On as mapDataInfoEntries,
975
- h as mapJoinEntry,
976
- Wn as mapPObjectData,
977
- Un as mapPTableDef,
978
- oe as mapValueInVOE,
979
- E as matchAxis,
980
- Z as matchAxisId,
981
- N as matchPColumn,
982
- An as newRangeBytesOpt,
983
- jn as pTableValue,
984
- Ln as pValueToStringOrNumber,
985
- W as pValueToStringOrNumberOrNull,
986
- Kn as parseColumnId,
987
- ce as parseJson,
988
- dn as plId,
989
- re as plRefsEqual,
990
- Mn as resolveAnchors,
991
- q as safeConvertToPValue,
992
- Gn as selectorsToPredicate,
993
- D as serializeError,
994
- L as serializeResult,
995
- nn as stringifyColumnId,
996
- ae as stringifyJson,
997
- Dn as toJsonSafePValue,
998
- ie as uniquePlId,
999
- pe as unwrapResult,
1000
- xn as validateRangeBytes,
1001
- te as withEnrichments,
1002
- he as wrapAndSerialize,
1003
- ge as wrapAndSerializeAsync,
1004
- yn as wrapAsyncCallback,
1005
- pn as wrapCallback
1091
+ V as PlIdBytes,
1092
+ de as PlIdLength,
1093
+ on as PlRef,
1094
+ Pe as RangeBytes,
1095
+ Cn as RuntimeCapabilities,
1096
+ gn as UiError,
1097
+ _e as canonicalizeAxisId,
1098
+ mn as canonicalizeJson,
1099
+ vn as checkBlockFlag,
1100
+ an as createPlRef,
1101
+ Ve as dataInfoToEntries,
1102
+ tn as deriveNativeId,
1103
+ j as deserializeError,
1104
+ kn as deserializeResult,
1105
+ ln as digestPlId,
1106
+ k as ensureError,
1107
+ Re as ensureNotNAPValue,
1108
+ Ye as ensurePColumn,
1109
+ Ie as entriesToDataInfo,
1110
+ w as executePSpecPredicate,
1111
+ en as extractAllColumns,
1112
+ Nn as extractAllRequirements,
1113
+ On as extractAllSupports,
1114
+ ke as extractCodeWithInfo,
1115
+ xe as extractConfigGeneric,
1116
+ C as getAxesId,
1117
+ y as getAxisId,
1118
+ Me as getColumnIdAndSpec,
1119
+ Ne as getFileNameFromHandle,
1120
+ K as getFilePathFromHandle,
1121
+ Ke as getPColumnSpecId,
1122
+ Te as getPTableColumnId,
1123
+ pe as hasAbortError,
1124
+ bn as isAbortError,
1125
+ wn as isAggregateError,
1126
+ Oe as isDataInfo,
1127
+ _ as isDataInfoEntries,
1128
+ Ge as isFilteredPColumn,
1129
+ U as isImportFileHandleIndex,
1130
+ B as isImportFileHandleUpload,
1131
+ ve as isLiveLog,
1132
+ H as isNotNAPValue,
1133
+ ie as isPColumn,
1134
+ Qe as isPColumnResult,
1135
+ d as isPColumnSpec,
1136
+ Xe as isPColumnSpecResult,
1137
+ Be as isPTableAbsent,
1138
+ W as isPValue,
1139
+ $e as isPartitionedDataInfoEntries,
1140
+ sn as isPlRef,
1141
+ Q as isValueAbsent,
1142
+ b as isValueNA,
1143
+ Ce as mapDataInfo,
1144
+ je as mapDataInfoEntries,
1145
+ g as mapJoinEntry,
1146
+ Ze as mapPObjectData,
1147
+ qe as mapPTableDef,
1148
+ fn as mapValueInVOE,
1149
+ S as matchAxis,
1150
+ ne as matchAxisId,
1151
+ v as matchPColumn,
1152
+ Ee as newRangeBytesOpt,
1153
+ Ue as pTableValue,
1154
+ Le as pValueToStringOrNumber,
1155
+ X as pValueToStringOrNumberOrNull,
1156
+ ze as parseColumnId,
1157
+ yn as parseJson,
1158
+ le as plId,
1159
+ cn as plRefsEqual,
1160
+ We as resolveAnchors,
1161
+ G as safeConvertToPValue,
1162
+ nn as selectorsToPredicate,
1163
+ F as serializeError,
1164
+ J as serializeResult,
1165
+ te as stringifyColumnId,
1166
+ pn as stringifyJson,
1167
+ De as toJsonSafePValue,
1168
+ dn as uniquePlId,
1169
+ An as unwrapResult,
1170
+ Se as validateRangeBytes,
1171
+ un as withEnrichments,
1172
+ xn as wrapAndSerialize,
1173
+ Pn as wrapAndSerializeAsync,
1174
+ he as wrapAsyncCallback,
1175
+ ye as wrapCallback
1006
1176
  };
1007
1177
  //# sourceMappingURL=index.mjs.map