@platforma-sdk/model 1.27.10 → 1.28.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.
package/dist/index.mjs CHANGED
@@ -1,66 +1,67 @@
1
- var _e = Object.defineProperty;
2
- var Ie = (t, e, n) => e in t ? _e(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var T = (t, e, n) => Ie(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { isPColumn as M, mapPObjectData as ue, selectorsToPredicate as ce, AnchoredIdDeriver as te, isPlRef as Ce, resolveAnchors as Le, isPColumnSpec as J, getAxisId as L, entriesToDataInfo as Te, mapValueInVOE as Fe, ensurePColumn as Re, isDataInfo as me, extractAllColumns as ke, mapPTableDef as De, mapDataInfo as Oe, canonicalizeAxisId as Ee, matchAxisId as G } from "@milaboratories/pl-model-common";
1
+ var je = Object.defineProperty;
2
+ var Ke = (t, e, n) => e in t ? je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var L = (t, e, n) => Ke(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { isPColumn as se, mapPObjectData as ge, isDataInfoEntries as xe, isDataInfo as me, dataInfoToEntries as Ve, resolveAnchors as $e, isPColumnSpec as Z, isPartitionedDataInfoEntries as Je, getAxisId as F, entriesToDataInfo as Ne, selectorsToPredicate as ce, canonicalizeAxisId as Ue, AnchoredIdDeriver as ye, isPlRef as Be, mapValueInVOE as Me, ensurePColumn as Ge, extractAllColumns as We, mapPTableDef as He, mapDataInfo as qe, matchAxisId as G } from "@milaboratories/pl-model-common";
5
5
  export * from "@milaboratories/pl-model-common";
6
- import { z as O } from "zod";
6
+ import { z as K } from "zod";
7
+ import Pe from "canonicalize";
7
8
  export * from "@milaboratories/pl-error-like";
8
- class je extends Error {
9
+ class ze extends Error {
9
10
  constructor(e, n) {
10
11
  super(`${e.length}${n ? "+" : ""} errors, first error: ` + e[0].message), this.errors = e, this.moreErrors = n;
11
12
  }
12
13
  }
13
- function Ve(t) {
14
- if (!t.ok) throw new je(t.errors, t.moreErrors);
14
+ function Ye(t) {
15
+ if (!t.ok) throw new ze(t.errors, t.moreErrors);
15
16
  return t.value;
16
17
  }
17
- function ht(t) {
18
+ function Rt(t) {
18
19
  return new Proxy(t, {
19
20
  get(e, n) {
20
- return Ve(e[n]);
21
+ return Ye(e[n]);
21
22
  }
22
23
  });
23
24
  }
24
- function b(t) {
25
- return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null ? Y(t) : t;
25
+ function S(t) {
26
+ return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null ? ee(t) : t;
26
27
  }
27
28
  function W(t) {
28
29
  return { type: "GetFromCtx", variable: t };
29
30
  }
30
- function gt(t) {
31
+ function Ot(t) {
31
32
  return {
32
33
  type: "Isolate",
33
34
  cfg: t
34
35
  };
35
36
  }
36
- const mt = W("$args"), yt = W("$it"), bt = W("$prod"), vt = W("$staging"), wt = W("$ui");
37
- function Y(t) {
37
+ const jt = W("$args"), Kt = W("$it"), Vt = W("$prod"), $t = W("$staging"), Jt = W("$ui");
38
+ function ee(t) {
38
39
  return { type: "Immediate", value: t };
39
40
  }
40
- function ye(t) {
41
+ function Ce(t) {
41
42
  const e = {};
42
- for (const [n, r] of Object.entries(t)) e[n] = b(r);
43
+ for (const [n, r] of Object.entries(t)) e[n] = S(r);
43
44
  return {
44
45
  type: "MakeObject",
45
46
  template: e
46
47
  };
47
48
  }
48
- function xt(...t) {
49
+ function Nt(...t) {
49
50
  const e = [];
50
- for (const n of t) e.push(b(n));
51
+ for (const n of t) e.push(S(n));
51
52
  return {
52
53
  type: "MakeArray",
53
54
  template: e
54
55
  };
55
56
  }
56
- function X(t, e) {
57
+ function te(t, e) {
57
58
  return {
58
59
  type: "GetJsonField",
59
- source: b(t),
60
- field: b(e)
60
+ source: S(t),
61
+ field: S(e)
61
62
  };
62
63
  }
63
- function At(t, e, n = "$it") {
64
+ function Ut(t, e, n = "$it") {
64
65
  return {
65
66
  type: "MapRecordValues",
66
67
  source: t,
@@ -68,7 +69,7 @@ function At(t, e, n = "$it") {
68
69
  itVar: n
69
70
  };
70
71
  }
71
- function St(t, e, n = "$it") {
72
+ function Bt(t, e, n = "$it") {
72
73
  return {
73
74
  type: "MapArrayValues",
74
75
  source: t,
@@ -76,54 +77,54 @@ function St(t, e, n = "$it") {
76
77
  itVar: n
77
78
  };
78
79
  }
79
- function Pt(t) {
80
+ function Mt(t) {
80
81
  return {
81
82
  type: "Flatten",
82
83
  source: t
83
84
  };
84
85
  }
85
- function _t(t) {
86
+ function Gt(t) {
86
87
  return {
87
88
  type: "IsEmpty",
88
89
  arg: t
89
90
  };
90
91
  }
91
- function It(t) {
92
+ function Wt(t) {
92
93
  return {
93
94
  type: "Not",
94
95
  operand: t
95
96
  };
96
97
  }
97
- function Ct(t, e) {
98
+ function Ht(t, e) {
98
99
  return {
99
100
  type: "And",
100
101
  operand1: t,
101
102
  operand2: e
102
103
  };
103
104
  }
104
- function Lt(t, e) {
105
+ function qt(t, e) {
105
106
  return {
106
107
  type: "Or",
107
108
  operand1: t,
108
109
  operand2: e
109
110
  };
110
111
  }
111
- function Tt(t, e) {
112
+ function zt(t, e) {
112
113
  return {
113
114
  type: "GetResourceField",
114
- source: b(t),
115
- field: b(e)
115
+ source: S(t),
116
+ field: S(e)
116
117
  };
117
118
  }
118
- function Ft() {
119
+ function Yt() {
119
120
  return function(t) {
120
121
  return {
121
122
  type: "GetResourceValueAsJson",
122
- source: b(t)
123
+ source: S(t)
123
124
  };
124
125
  };
125
126
  }
126
- function Rt(t, e, n = "$it") {
127
+ function Xt(t, e, n = "$it") {
127
128
  return {
128
129
  type: "MapResourceFields",
129
130
  source: t,
@@ -131,120 +132,120 @@ function Rt(t, e, n = "$it") {
131
132
  itVar: n
132
133
  };
133
134
  }
134
- function kt(t) {
135
+ function Qt(t) {
135
136
  return {
136
137
  type: "GetBlobContent",
137
- source: b(t)
138
+ source: S(t)
138
139
  };
139
140
  }
140
- function Dt(t) {
141
+ function Zt(t) {
141
142
  return {
142
143
  type: "GetBlobContentAsString",
143
- source: b(t)
144
+ source: S(t)
144
145
  };
145
146
  }
146
- function Ot() {
147
+ function en() {
147
148
  return function(t) {
148
149
  return {
149
150
  type: "GetBlobContentAsJson",
150
- source: b(t)
151
+ source: S(t)
151
152
  };
152
153
  };
153
154
  }
154
- function Et(t) {
155
+ function tn(t) {
155
156
  return {
156
157
  type: "GetDownloadedBlobContent",
157
- source: b(t)
158
+ source: S(t)
158
159
  };
159
160
  }
160
- function jt(t) {
161
+ function nn(t) {
161
162
  return {
162
163
  type: "GetOnDemandBlobContent",
163
- source: b(t)
164
+ source: S(t)
164
165
  };
165
166
  }
166
- function Vt(t, e) {
167
+ function rn(t, e) {
167
168
  return {
168
169
  type: "ExtractArchiveAndGetURL",
169
170
  format: e,
170
- source: b(t)
171
+ source: S(t)
171
172
  };
172
173
  }
173
- function Kt(t) {
174
+ function sn(t) {
174
175
  return {
175
176
  type: "GetImportProgress",
176
- source: b(t)
177
+ source: S(t)
177
178
  };
178
179
  }
179
- function $t(t, e) {
180
+ function on(t, e) {
180
181
  return {
181
182
  type: "GetLastLogs",
182
- source: b(t),
183
+ source: S(t),
183
184
  lines: e
184
185
  };
185
186
  }
186
- function Jt(t, e) {
187
+ function an(t, e) {
187
188
  return {
188
189
  type: "GetProgressLog",
189
- source: b(t),
190
+ source: S(t),
190
191
  patternToSearch: e
191
192
  };
192
193
  }
193
- function Nt(t, e) {
194
+ function ln(t, e) {
194
195
  return {
195
196
  type: "GetProgressLogWithInfo",
196
- source: b(t),
197
+ source: S(t),
197
198
  patternToSearch: e
198
199
  };
199
200
  }
200
- function Bt(t) {
201
+ function un(t) {
201
202
  return {
202
203
  type: "GetLogHandle",
203
- source: b(t)
204
+ source: S(t)
204
205
  };
205
206
  }
206
- function Ke() {
207
+ function Xe() {
207
208
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
208
209
  }
209
- function be(t) {
210
+ function _e(t) {
210
211
  if (t && typeof globalThis.getPlatforma == "function")
211
212
  return globalThis.getPlatforma(t);
212
213
  if (typeof globalThis.platforma < "u") return globalThis.platforma;
213
214
  throw new Error("Can't get platforma instance.");
214
215
  }
215
- function $e() {
216
+ function Qe() {
216
217
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
217
218
  }
218
219
  function h() {
219
220
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
220
221
  throw new Error("Not in config rendering context");
221
222
  }
222
- function q(t, e) {
223
- const n = $e();
223
+ function X(t, e) {
224
+ const n = Qe();
224
225
  if (n === void 0) return !1;
225
226
  if (t in n.callbackRegistry) throw new Error(`Callback with key ${t} already registered.`);
226
227
  return n.callbackRegistry[t] = e, !0;
227
228
  }
228
- const ne = /* @__PURE__ */ new Map();
229
- function Je(t, e) {
229
+ const ae = /* @__PURE__ */ new Map();
230
+ function Ze(t, e) {
230
231
  t in h().callbackRegistry || (h().callbackRegistry[t] = (n) => {
231
- for (const r of ne.get(t))
232
+ for (const r of ae.get(t))
232
233
  r(n);
233
- }, ne.set(t, [])), ne.get(t).push(e);
234
+ }, ae.set(t, [])), ae.get(t).push(e);
234
235
  }
235
- class S {
236
+ class _ {
236
237
  constructor(e, n = (r) => r) {
237
- T(this, "isResolved", !1);
238
- T(this, "resolvedValue");
239
- this.handle = e, this.postProcess = n, Je(e, (r) => {
238
+ L(this, "isResolved", !1);
239
+ L(this, "resolvedValue");
240
+ this.handle = e, this.postProcess = n, Ze(e, (r) => {
240
241
  this.resolvedValue = n(r), this.isResolved = !0;
241
242
  });
242
243
  }
243
244
  map(e) {
244
- return new S(this.handle, (n) => e(this.postProcess(n)));
245
+ return new _(this.handle, (n) => e(this.postProcess(n)));
245
246
  }
246
247
  mapDefined(e) {
247
- return new S(this.handle, (n) => {
248
+ return new _(this.handle, (n) => {
248
249
  const r = this.postProcess(n);
249
250
  return r ? e(r) : void 0;
250
251
  });
@@ -253,7 +254,7 @@ class S {
253
254
  return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
254
255
  }
255
256
  }
256
- function ie(t, e) {
257
+ function pe(t, e) {
257
258
  return t === void 0 ? void 0 : e(t);
258
259
  }
259
260
  class I {
@@ -295,7 +296,7 @@ class I {
295
296
  ...this.resolvePath,
296
297
  ...n.map((i) => typeof i == "string" ? i : i.field)
297
298
  ];
298
- return ie(
299
+ return pe(
299
300
  h().resolveWithCommon(this.handle, e, ...n),
300
301
  (i) => new I(i, r)
301
302
  );
@@ -317,7 +318,7 @@ class I {
317
318
  }
318
319
  getError() {
319
320
  const e = [...this.resolvePath, "error"];
320
- return ie(
321
+ return pe(
321
322
  h().getError(this.handle),
322
323
  (n) => new I(n, e)
323
324
  );
@@ -359,7 +360,7 @@ class I {
359
360
  getPColumns(e = !1, n = "") {
360
361
  const r = this.parsePObjectCollection(e, n);
361
362
  return r === void 0 ? void 0 : Object.entries(r).map(([, s]) => {
362
- if (!M(s)) throw new Error(`not a PColumn (kind = ${s.spec.kind})`);
363
+ if (!se(s)) throw new Error(`not a PColumn (kind = ${s.spec.kind})`);
363
364
  return s;
364
365
  });
365
366
  }
@@ -377,18 +378,18 @@ class I {
377
378
  const i = {};
378
379
  for (const [s, o] of Object.entries(r)) {
379
380
  const a = [...this.resolvePath, s];
380
- i[s] = ue(o, (c) => new I(c, a));
381
+ i[s] = ge(o, (l) => new I(l, a));
381
382
  }
382
383
  return i;
383
384
  }
384
385
  getFileContentAsBase64() {
385
- return new S(h().getBlobContentAsBase64(this.handle));
386
+ return new _(h().getBlobContentAsBase64(this.handle));
386
387
  }
387
388
  getFileContentAsString() {
388
- return new S(h().getBlobContentAsString(this.handle));
389
+ return new _(h().getBlobContentAsString(this.handle));
389
390
  }
390
391
  getFileContentAsJson() {
391
- return new S(
392
+ return new _(
392
393
  h().getBlobContentAsString(this.handle)
393
394
  ).mapDefined((e) => JSON.parse(e));
394
395
  }
@@ -408,7 +409,7 @@ class I {
408
409
  * @returns downloaded file handle
409
410
  */
410
411
  getFileHandle() {
411
- return new S(h().getDownloadedBlobContentHandle(this.handle));
412
+ return new _(h().getDownloadedBlobContentHandle(this.handle));
412
413
  }
413
414
  /**
414
415
  * @deprecated use getFileHandle
@@ -420,7 +421,7 @@ class I {
420
421
  * @returns downloaded file handle
421
422
  */
422
423
  getRemoteFileHandle() {
423
- return new S(h().getOnDemandBlobContentHandle(this.handle));
424
+ return new _(h().getOnDemandBlobContentHandle(this.handle));
424
425
  }
425
426
  /**
426
427
  * @deprecated use getRemoteFileHandle
@@ -432,22 +433,22 @@ class I {
432
433
  * @returns the url to the extracted folder
433
434
  */
434
435
  extractArchiveAndGetURL(e) {
435
- return new S(h().extractArchiveAndGetURL(this.handle, e));
436
+ return new _(h().extractArchiveAndGetURL(this.handle, e));
436
437
  }
437
438
  getImportProgress() {
438
- return new S(h().getImportProgress(this.handle));
439
+ return new _(h().getImportProgress(this.handle));
439
440
  }
440
441
  getLastLogs(e) {
441
- return new S(h().getLastLogs(this.handle, e));
442
+ return new _(h().getLastLogs(this.handle, e));
442
443
  }
443
444
  getProgressLog(e) {
444
- return new S(h().getProgressLog(this.handle, e));
445
+ return new _(h().getProgressLog(this.handle, e));
445
446
  }
446
447
  getProgressLogWithInfo(e) {
447
- return new S(h().getProgressLogWithInfo(this.handle, e));
448
+ return new _(h().getProgressLogWithInfo(this.handle, e));
448
449
  }
449
450
  getLogHandle() {
450
- return new S(h().getLogHandle(this.handle));
451
+ return new _(h().getLogHandle(this.handle));
451
452
  }
452
453
  allFieldsResolved(e = "Input") {
453
454
  switch (e) {
@@ -470,134 +471,134 @@ class I {
470
471
  }, o = e;
471
472
  if (i && (r === "Input" && !this.getInputsLocked() || r === "Output" && !this.getOutputsLocked()))
472
473
  return;
473
- let c = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
474
- (l) => [l, this.resolve({ field: l, assertFieldType: r })]
474
+ let l = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
475
+ (c) => [c, this.resolve({ field: c, assertFieldType: r })]
475
476
  );
476
- return s && (c = c.filter((l) => l[1] !== void 0)), c.map(([l, m]) => o(l, m));
477
+ return s && (l = l.filter((c) => c[1] !== void 0)), l.map(([c, w]) => o(c, w));
477
478
  }
478
479
  }
479
- const ve = "staging", we = "main", Ne = {
480
+ const Ie = "staging", Le = "main", et = {
480
481
  explicitColumnsSupport: !0,
481
482
  inlineColumnsSupport: !0,
482
483
  activeArgs: !0
483
484
  };
484
- function xe(t) {
485
+ function Te(t) {
485
486
  return typeof t == "object" && t !== null && "__awaited_futures__" in t;
486
487
  }
487
- function oe(t, e, n) {
488
+ function de(t, e, n) {
488
489
  if (e.has(n)) return;
489
490
  if (e.add(n), typeof n === "object")
490
- if (xe(n)) n.__awaited_futures__.forEach((i) => t.add(i));
491
+ if (Te(n)) n.__awaited_futures__.forEach((i) => t.add(i));
491
492
  else if (Array.isArray(n))
492
- for (const i of n) oe(t, e, i);
493
+ for (const i of n) de(t, e, i);
493
494
  else
494
495
  for (const [, i] of Object.entries(n))
495
- i !== n && oe(t, e, i);
496
+ i !== n && de(t, e, i);
496
497
  }
497
- function Be(t) {
498
+ function tt(t) {
498
499
  const e = /* @__PURE__ */ new Set();
499
- return oe(e, /* @__PURE__ */ new Set(), t), e;
500
+ return de(e, /* @__PURE__ */ new Set(), t), e;
500
501
  }
501
- const Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
502
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
502
503
  __proto__: null,
503
- GlobalCfgRenderCtxFeatureFlags: Ne,
504
- MainAccessorName: we,
505
- StagingAccessorName: ve,
506
- getAllFutureAwaits: Be,
507
- isFutureAwait: xe
508
- }, Symbol.toStringTag, { value: "Module" })), Ue = "pl7.app/label", Me = "pl7.app/trace", Ge = O.object({
509
- type: O.string(),
510
- importance: O.number().optional(),
511
- id: O.string().optional(),
512
- label: O.string()
513
- }), We = O.array(Ge), He = 1e-3, qe = "__LABEL__", pe = "__LABEL__@1";
514
- function de(t, e, n = {}) {
515
- const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = t.map((f) => {
516
- var R, k;
517
- const p = e(f);
518
- let d, y, g;
519
- "spec" in p && typeof p.spec == "object" ? (d = p.spec, y = p.prefixTrace, g = p.suffixTrace) : d = p;
520
- const v = (R = d.annotations) == null ? void 0 : R[Ue], w = (k = d.annotations) == null ? void 0 : k[Me], x = (w ? We.safeParse(JSON.parse(w)).data : void 0) ?? [], C = [
504
+ GlobalCfgRenderCtxFeatureFlags: et,
505
+ MainAccessorName: Le,
506
+ StagingAccessorName: Ie,
507
+ getAllFutureAwaits: tt,
508
+ isFutureAwait: Te
509
+ }, Symbol.toStringTag, { value: "Module" })), nt = "pl7.app/label", rt = "pl7.app/trace", it = K.object({
510
+ type: K.string(),
511
+ importance: K.number().optional(),
512
+ id: K.string().optional(),
513
+ label: K.string()
514
+ }), st = K.array(it), ot = 1e-3, at = "__LABEL__", ve = "__LABEL__@1";
515
+ function Fe(t, e, n = {}) {
516
+ const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = t.map((u) => {
517
+ var $, q;
518
+ const f = e(u);
519
+ let p, y, v;
520
+ "spec" in f && typeof f.spec == "object" ? (p = f.spec, y = f.prefixTrace, v = f.suffixTrace) : p = f;
521
+ const m = ($ = p.annotations) == null ? void 0 : $[nt], b = (q = p.annotations) == null ? void 0 : q[rt], g = (b ? st.safeParse(JSON.parse(b)).data : void 0) ?? [], A = [
521
522
  ...y ?? [],
522
- ...x,
523
- ...g ?? []
523
+ ...g,
524
+ ...v ?? []
524
525
  ];
525
- if (v) {
526
- const A = { label: v, type: qe, importance: -2 };
527
- n.addLabelAsSuffix ? C.push(A) : C.splice(0, 0, A);
526
+ if (m) {
527
+ const P = { label: m, type: at, importance: -2 };
528
+ n.addLabelAsSuffix ? A.push(P) : A.splice(0, 0, P);
528
529
  }
529
- const P = [], F = /* @__PURE__ */ new Map();
530
- for (let A = C.length - 1; A >= 0; --A) {
531
- const { type: j } = C[A], V = C[A].importance ?? 0, K = (F.get(j) ?? 0) + 1;
532
- F.set(j, K);
533
- const $ = `${j}@${K}`;
534
- i.set($, (i.get($) ?? 0) + 1), r.set(
535
- $,
530
+ const x = [], k = /* @__PURE__ */ new Map();
531
+ for (let P = A.length - 1; P >= 0; --P) {
532
+ const { type: R } = A[P], z = A[P].importance ?? 0, J = (k.get(R) ?? 0) + 1;
533
+ k.set(R, J);
534
+ const E = `${R}@${J}`;
535
+ i.set(E, (i.get(E) ?? 0) + 1), r.set(
536
+ E,
536
537
  Math.max(
537
- r.get($) ?? Number.NEGATIVE_INFINITY,
538
- V - (C.length - A) * He
538
+ r.get(E) ?? Number.NEGATIVE_INFINITY,
539
+ z - (A.length - P) * ot
539
540
  )
540
- ), P.push({ ...C[A], fullType: $, occurenceIndex: K });
541
+ ), x.push({ ...A[P], fullType: E, occurenceIndex: J });
541
542
  }
542
- return P.reverse(), {
543
- value: f,
544
- spec: d,
545
- label: v,
546
- fullTrace: P
543
+ return x.reverse(), {
544
+ value: u,
545
+ spec: p,
546
+ label: m,
547
+ fullTrace: x
547
548
  };
548
- }), o = [], a = [], c = [...r];
549
- c.sort(([, f], [, p]) => p - f);
550
- for (const [f] of c)
551
- f.endsWith("@1") || i.get(f) === t.length ? o.push(f) : a.push(f);
552
- const l = (f) => s.map((p) => {
553
- const d = p.fullTrace.filter((g) => f.has(g.fullType)).map((g) => g.label), y = n.separator ?? " / ";
549
+ }), o = [], a = [], l = [...r];
550
+ l.sort(([, u], [, f]) => f - u);
551
+ for (const [u] of l)
552
+ u.endsWith("@1") || i.get(u) === t.length ? o.push(u) : a.push(u);
553
+ const c = (u) => s.map((f) => {
554
+ const p = f.fullTrace.filter((v) => u.has(v.fullType)).map((v) => v.label), y = n.separator ?? " / ";
554
555
  return {
555
- label: d.join(y),
556
- value: p.value
556
+ label: p.join(y),
557
+ value: f.value
557
558
  };
558
559
  });
559
560
  if (o.length === 0) {
560
561
  if (a.length !== 0) throw new Error("Assertion error.");
561
- return l(new Set(pe));
562
- }
563
- let m = 0, u = 0;
564
- for (; m < o.length; ) {
565
- const f = /* @__PURE__ */ new Set();
566
- n.includeNativeLabel && f.add(pe);
567
- for (let d = 0; d < m; ++d) f.add(o[d]);
568
- f.add(o[u]);
569
- const p = l(f);
570
- if (new Set(p.map((d) => d.label)).size === t.length) return p;
571
- u++, u == o.length && (m++, u = m);
572
- }
573
- return l(/* @__PURE__ */ new Set([...o, ...a]));
574
- }
575
- const H = "PColumnData/", Q = H + "ResourceMap", Z = H + "Partitioned/ResourceMap", N = H + "JsonPartitioned", E = H + "BinaryPartitioned", Ae = H + "Partitioned/", ee = Ae + "JsonPartitioned", B = Ae + "BinaryPartitioned";
576
- function Se(t, e, n, r = [], i) {
562
+ return c(new Set(ve));
563
+ }
564
+ let w = 0, d = 0;
565
+ for (; w < o.length; ) {
566
+ const u = /* @__PURE__ */ new Set();
567
+ n.includeNativeLabel && u.add(ve);
568
+ for (let p = 0; p < w; ++p) u.add(o[p]);
569
+ u.add(o[d]);
570
+ const f = c(u);
571
+ if (new Set(f.map((p) => p.label)).size === t.length) return f;
572
+ d++, d == o.length && (w++, d = w);
573
+ }
574
+ return c(/* @__PURE__ */ new Set([...o, ...a]));
575
+ }
576
+ const H = "PColumnData/", ne = H + "ResourceMap", re = H + "Partitioned/ResourceMap", U = H + "JsonPartitioned", V = H + "BinaryPartitioned", Ee = H + "Partitioned/", ie = Ee + "JsonPartitioned", B = Ee + "BinaryPartitioned";
577
+ function De(t, e, n, r = [], i) {
577
578
  if (t === void 0) return !1;
578
579
  switch (t.resourceType.name) {
579
- case Q: {
580
+ case ne: {
580
581
  let s = t.getInputsLocked();
581
582
  for (const o of t.listInputFields()) {
582
- const a = t.resolve({ field: o, assertFieldType: "Input" }), c = [...r, ...JSON.parse(o)], l = a === void 0 ? void 0 : e(a);
583
- l === void 0 && (s = !1), (l !== void 0 || i) && n.push({ key: c, value: l });
583
+ const a = t.resolve({ field: o, assertFieldType: "Input" }), l = [...r, ...JSON.parse(o)], c = a === void 0 ? void 0 : e(a);
584
+ c === void 0 && (s = !1), (c !== void 0 || i) && n.push({ key: l, value: c });
584
585
  }
585
586
  return s;
586
587
  }
587
- case Z: {
588
+ case re: {
588
589
  let s = t.getInputsLocked();
589
590
  for (const o of t.listInputFields()) {
590
591
  const a = t.resolve({ field: o, assertFieldType: "Input" });
591
592
  if (a === void 0) s = !1;
592
593
  else {
593
- const c = [...r, ...JSON.parse(o)], l = Se(
594
+ const l = [...r, ...JSON.parse(o)], c = De(
594
595
  a,
595
596
  e,
596
597
  n,
597
- c,
598
+ l,
598
599
  i
599
600
  );
600
- s = s && l;
601
+ s = s && c;
601
602
  }
602
603
  }
603
604
  return s;
@@ -606,65 +607,87 @@ function Se(t, e, n, r = [], i) {
606
607
  throw new Error(`Unknown resource type: ${t.resourceType.name}`);
607
608
  }
608
609
  }
609
- function Mt(t, e, n = !1) {
610
+ function pn(t, e, n = !1) {
610
611
  const r = [];
611
- return { isComplete: Se(t, e, r, [], n), data: r };
612
+ return { isComplete: De(t, e, r, [], n), data: r };
612
613
  }
613
- const ae = (t) => {
614
+ const fe = (t) => {
614
615
  if (t.endsWith(".index"))
615
616
  return { baseKey: t.substring(0, t.length - 6), type: "index" };
616
617
  if (t.endsWith(".values"))
617
618
  return { baseKey: t.substring(0, t.length - 7), type: "values" };
618
619
  throw new Error(`key must ends on .index/.values for binary p-column, got: ${t}`);
619
620
  };
620
- function ze(t) {
621
+ function lt(t) {
621
622
  if (!t) return;
622
623
  const e = t.resourceType.name, n = t.getDataAsJson(), r = [];
623
624
  let i = 0;
624
625
  switch (e) {
625
- case Q:
626
+ case ne:
626
627
  i = n.keyLength;
627
628
  break;
628
- case Z:
629
+ case re:
629
630
  i = n.partitionKeyLength + n.keyLength;
630
631
  break;
631
- case N:
632
- case E:
632
+ case U:
633
+ case V:
633
634
  i = n.partitionKeyLength;
634
635
  break;
635
636
  case B:
636
- case ee:
637
+ case ie:
637
638
  i = n.superPartitionKeyLength + n.partitionKeyLength;
638
639
  break;
639
640
  }
640
641
  switch (e) {
641
- case Q:
642
- case N:
643
- case E:
642
+ case ne:
643
+ case U:
644
+ case V:
644
645
  for (let s of t.listInputFields()) {
645
- e === E && (s = ae(s).baseKey);
646
+ e === V && (s = fe(s).baseKey);
646
647
  const o = [...JSON.parse(s)];
647
648
  r.push(o);
648
649
  }
649
650
  break;
650
- case Z:
651
+ case re:
651
652
  case B:
652
- case ee:
653
+ case ie:
653
654
  for (const s of t.listInputFields()) {
654
655
  const o = [...JSON.parse(s)], a = t.resolve({ field: s, assertFieldType: "Input" });
655
656
  if (a !== void 0)
656
- for (let c of a.listInputFields()) {
657
- e === B && (c = ae(c).baseKey);
658
- const l = [...o, ...JSON.parse(c)];
659
- r.push(l);
657
+ for (let l of a.listInputFields()) {
658
+ e === B && (l = fe(l).baseKey);
659
+ const c = [...o, ...JSON.parse(l)];
660
+ r.push(c);
660
661
  }
661
662
  }
662
663
  break;
663
664
  }
664
665
  return { data: r, keyLength: i };
665
666
  }
666
- function Ye(t) {
667
- const e = ze(t);
667
+ function ut(t) {
668
+ if (t.type !== "JsonPartitioned" && t.type !== "BinaryPartitioned")
669
+ throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${t.type}`);
670
+ const { parts: e, partitionKeyLength: n } = t, r = [];
671
+ for (let i = 0; i < n; ++i)
672
+ r.push(/* @__PURE__ */ new Set());
673
+ for (const i of e) {
674
+ const s = i.key;
675
+ if (s.length !== n)
676
+ throw new Error(
677
+ `Key length (${s.length}) does not match partition length (${n}) for key: ${JSON.stringify(
678
+ s
679
+ )}`
680
+ );
681
+ for (let o = 0; o < n; ++o)
682
+ r[o].add(s[o]);
683
+ }
684
+ return r.map((i) => Array.from(i.values()));
685
+ }
686
+ function ct(t) {
687
+ if (t === void 0) return;
688
+ if (xe(t))
689
+ return ut(t);
690
+ const e = lt(t);
668
691
  if (!e) return;
669
692
  const { data: n, keyLength: r } = e, i = [];
670
693
  for (let s = 0; s < r; ++s)
@@ -677,16 +700,16 @@ function Ye(t) {
677
700
  }
678
701
  return i.map((s) => Array.from(s.values()));
679
702
  }
680
- function le(t, e = []) {
681
- if (t === void 0) return;
703
+ function he(t, e = []) {
704
+ if (t === void 0 || !t.getIsReadyOrError()) return;
682
705
  const n = t.resourceType.name, r = t.getDataAsJson();
683
- if (e.length > 0 && (n === ee || n === B))
706
+ if (e.length > 0 && (n === ie || n === B))
684
707
  throw new Error(`Unexpected nested super-partitioned resource: ${n}`);
685
708
  switch (n) {
686
- case Q:
687
- case Z:
709
+ case ne:
710
+ case re:
688
711
  throw new Error(`Only data columns are supported, got: ${n}`);
689
- case N: {
712
+ case U: {
690
713
  if (typeof (r == null ? void 0 : r.partitionKeyLength) != "number")
691
714
  throw new Error(`Missing partitionKeyLength in metadata for ${n}`);
692
715
  const i = [];
@@ -702,21 +725,21 @@ function le(t, e = []) {
702
725
  parts: i
703
726
  };
704
727
  }
705
- case E: {
728
+ case V: {
706
729
  if (typeof (r == null ? void 0 : r.partitionKeyLength) != "number")
707
730
  throw new Error(`Missing partitionKeyLength in metadata for ${n}`);
708
731
  const i = [], s = /* @__PURE__ */ new Map();
709
732
  for (const o of t.listInputFields()) {
710
- const a = ae(o), c = t.resolve({ field: o, assertFieldType: "Input" });
711
- if (c === void 0) return;
712
- let l = s.get(a.baseKey);
713
- l || (l = {}, s.set(a.baseKey, l)), a.type === "index" ? l.index = c : l.values = c;
733
+ const a = fe(o), l = t.resolve({ field: o, assertFieldType: "Input" });
734
+ if (l === void 0) return;
735
+ let c = s.get(a.baseKey);
736
+ c || (c = {}, s.set(a.baseKey, c)), a.type === "index" ? c.index = l : c.values = l;
714
737
  }
715
738
  for (const [o, a] of s.entries()) {
716
739
  if (!a.index || !a.values) return;
717
- const c = [...e, ...JSON.parse(o)];
740
+ const l = [...e, ...JSON.parse(o)];
718
741
  i.push({
719
- key: c,
742
+ key: l,
720
743
  value: {
721
744
  index: a.index,
722
745
  values: a.values
@@ -729,20 +752,20 @@ function le(t, e = []) {
729
752
  parts: i
730
753
  };
731
754
  }
732
- case ee: {
755
+ case ie: {
733
756
  if (typeof (r == null ? void 0 : r.superPartitionKeyLength) != "number" || typeof (r == null ? void 0 : r.partitionKeyLength) != "number")
734
757
  throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${n}`);
735
758
  const i = r.superPartitionKeyLength + r.partitionKeyLength, s = [];
736
759
  for (const o of t.listInputFields()) {
737
760
  const a = t.resolve({ field: o, assertFieldType: "Input" });
738
761
  if (a === void 0) return;
739
- if (a.resourceType.name !== N)
740
- throw new Error(`Expected ${N} inside ${n}, but got ${a.resourceType.name}`);
741
- const c = le(a, JSON.parse(o));
742
- if (c === void 0) return;
743
- if (c.type !== "JsonPartitioned")
744
- throw new Error(`Unexpected inner result type for ${n}: ${c.type}`);
745
- s.push(...c.parts);
762
+ if (a.resourceType.name !== U)
763
+ throw new Error(`Expected ${U} inside ${n}, but got ${a.resourceType.name}`);
764
+ const l = he(a, JSON.parse(o));
765
+ if (l === void 0) return;
766
+ if (l.type !== "JsonPartitioned")
767
+ throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);
768
+ s.push(...l.parts);
746
769
  }
747
770
  return {
748
771
  type: "JsonPartitioned",
@@ -757,13 +780,13 @@ function le(t, e = []) {
757
780
  for (const o of t.listInputFields()) {
758
781
  const a = t.resolve({ field: o, assertFieldType: "Input" });
759
782
  if (a === void 0) return;
760
- if (a.resourceType.name !== E)
761
- throw new Error(`Expected ${E} inside ${n}, but got ${a.resourceType.name}`);
762
- const c = le(a, JSON.parse(o));
763
- if (c === void 0) return;
764
- if (c.type !== "BinaryPartitioned")
765
- throw new Error(`Unexpected inner result type for ${n}: ${c.type}`);
766
- s.push(...c.parts);
783
+ if (a.resourceType.name !== V)
784
+ throw new Error(`Expected ${V} inside ${n}, but got ${a.resourceType.name}`);
785
+ const l = he(a, JSON.parse(o));
786
+ if (l === void 0) return;
787
+ if (l.type !== "BinaryPartitioned")
788
+ throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);
789
+ s.push(...l.parts);
767
790
  }
768
791
  return {
769
792
  type: "BinaryPartitioned",
@@ -775,7 +798,15 @@ function le(t, e = []) {
775
798
  throw new Error(`Unknown resource type: ${n}`);
776
799
  }
777
800
  }
778
- function Xe(t, e) {
801
+ function pt(t) {
802
+ if (t !== void 0) {
803
+ if (xe(t)) return t;
804
+ if (me(t)) return Ve(t);
805
+ if (t instanceof I) return he(t);
806
+ throw new Error(`Unexpected input type: ${typeof t}`);
807
+ }
808
+ }
809
+ function dt(t, e) {
779
810
  const n = [...e].sort((s, o) => o[0] - s[0]);
780
811
  if (t.type === "JsonPartitioned" || t.type === "BinaryPartitioned") {
781
812
  const { partitionKeyLength: s } = t;
@@ -835,32 +866,219 @@ function Xe(t, e) {
835
866
  }
836
867
  }
837
868
  }
838
- function re(t, e) {
839
- if (t === void 0) return e === void 0;
840
- if (e === void 0) return !0;
841
- for (const n in e)
842
- if (t[n] !== e[n]) return !1;
843
- return !0;
844
- }
845
- function fe(t) {
846
- return ue(t, (e) => e instanceof I ? e.handle : me(e) ? Oe(e, (n) => n.handle) : e);
869
+ class ft {
870
+ constructor(e) {
871
+ this.columns = e;
872
+ }
873
+ selectColumns(e) {
874
+ const n = typeof e == "function" ? e : ce(e);
875
+ return this.columns.filter((r) => n(r.spec));
876
+ }
847
877
  }
848
- function Qe(t) {
878
+ function ht(t) {
849
879
  if (t)
850
880
  return t.map((e) => ({
851
- type: `split:${Ee(e.axisId)}`,
881
+ type: `split:${Ue(e.axisId)}`,
852
882
  label: e.label,
853
883
  importance: 1e6
854
884
  // High importance for split filters in labels
855
885
  }));
856
886
  }
857
- function Ze(t) {
887
+ function gt(t) {
858
888
  if (t)
859
889
  return t.map((e) => [e.axisIdx, e.value]);
860
890
  }
861
- class et {
891
+ function mt(t, e) {
892
+ if (!e || e.length === 0) return t;
893
+ const n = [...e].sort((r, i) => r[0] - i[0]);
894
+ return Pe({ id: t, axisFilters: n });
895
+ }
896
+ function yt(t) {
897
+ if (!t || typeof t != "object") return !1;
898
+ const e = t, n = e.domain && typeof e.domain == "object" && Object.values(e.domain).some((i) => typeof i == "object" && i !== null && "anchor" in i), r = e.axes && Array.isArray(e.axes) && e.axes.some((i) => typeof i == "object" && i !== null && "anchor" in i);
899
+ return !!e.domainAnchor || n || r;
900
+ }
901
+ function vt(t) {
902
+ if (typeof t != "object" || !("axes" in t) || t.axes === void 0)
903
+ return [];
904
+ const e = t.axes.map((n, r) => typeof n == "object" && "split" in n && n.split === !0 ? r : -1).filter((n) => n !== -1);
905
+ if (e.length > 0 && t.partialAxesMatch !== void 0)
906
+ throw new Error("Axis splitting is not supported when `partialAxesMatch` is defined.");
907
+ return e.sort((n, r) => n - r), e;
908
+ }
909
+ class be {
910
+ constructor() {
911
+ L(this, "defaultProviderStore", []);
912
+ L(this, "providers", [new ft(this.defaultProviderStore)]);
913
+ L(this, "axisLabelProviders", []);
914
+ }
915
+ addColumnProvider(e) {
916
+ return this.providers.push(e), this;
917
+ }
918
+ addAxisLabelProvider(e) {
919
+ return this.axisLabelProviders.push(e), this;
920
+ }
921
+ addColumns(e) {
922
+ return this.defaultProviderStore.push(...e), this;
923
+ }
924
+ addColumn(e) {
925
+ return this.defaultProviderStore.push(e), this;
926
+ }
927
+ /** Fetches labels for a given axis from the registered providers */
928
+ findLabels(e) {
929
+ for (const n of this.axisLabelProviders) {
930
+ const r = n.findLabels(e);
931
+ if (r) return r;
932
+ }
933
+ }
934
+ getUniversalEntries(e, n) {
935
+ const { anchorCtx: r, labelOps: i, dontWaitAllData: s = !1, overrideLabelAnnotation: o = !1 } = n ?? {}, a = {
936
+ ...o && (i == null ? void 0 : i.includeNativeLabel) !== !1 ? { includeNativeLabel: !0 } : {},
937
+ ...i ?? {}
938
+ }, l = typeof e == "function" ? [e] : Array.isArray(e) ? e : [e], c = [];
939
+ for (const u of l) {
940
+ const f = yt(u);
941
+ let p;
942
+ if (f) {
943
+ if (!r)
944
+ throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");
945
+ p = $e(r.anchors, u);
946
+ } else
947
+ p = u;
948
+ const y = /* @__PURE__ */ new Set(), v = [];
949
+ for (const g of this.providers) {
950
+ const A = g.selectColumns(p);
951
+ for (const x of A) {
952
+ if (y.has(x.id)) throw new Error(`Duplicate column id ${x.id} in provider ${g.constructor.name}`);
953
+ y.add(x.id), v.push(x);
954
+ }
955
+ }
956
+ if (v.length === 0) continue;
957
+ const m = vt(u), b = m.length > 0;
958
+ for (const g of v) {
959
+ if (!Z(g.spec)) continue;
960
+ const A = g.spec;
961
+ if (b) {
962
+ const x = pt(g.data);
963
+ if (!x) {
964
+ if (s) continue;
965
+ return;
966
+ }
967
+ if (!Je(x))
968
+ throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${x.type} for column ${g.id}`);
969
+ const k = ct(x), $ = m[m.length - 1];
970
+ if ($ >= x.partitionKeyLength)
971
+ throw new Error(`Not enough partition keys (${x.partitionKeyLength}) for requested split axes (max index ${$}) in column ${A.name}`);
972
+ const q = m.map((C) => this.findLabels(F(A.axesSpec[C]))), P = [], R = (C, N) => {
973
+ if (N >= m.length) {
974
+ P.push([...C]);
975
+ return;
976
+ }
977
+ const D = m[N];
978
+ if (D >= k.length)
979
+ throw new Error(`Axis index ${D} out of bounds for unique keys array (length ${k.length}) during split key generation for column ${g.id}`);
980
+ const O = k[D];
981
+ if (!O || O.length === 0) {
982
+ P.length = 0;
983
+ return;
984
+ }
985
+ for (const Y of O)
986
+ C.push(Y), R(C, N + 1), C.pop();
987
+ };
988
+ if (R([], 0), P.length === 0)
989
+ continue;
990
+ const z = [...A.axesSpec], J = m.map((C) => C);
991
+ for (let C = m.length - 1; C >= 0; C--)
992
+ z.splice(m[C], 1);
993
+ const E = { ...A, axesSpec: z };
994
+ for (const C of P) {
995
+ const N = C.map((D, O) => {
996
+ const Y = J[O], Re = F(A.axesSpec[Y]), oe = q[O], Oe = (oe == null ? void 0 : oe[D]) ?? String(D);
997
+ return { axisIdx: Y, axisId: Re, value: D, label: Oe };
998
+ });
999
+ c.push({
1000
+ type: "split",
1001
+ originalColumn: g,
1002
+ spec: A,
1003
+ adjustedSpec: E,
1004
+ dataEntries: x,
1005
+ axisFilters: N
1006
+ });
1007
+ }
1008
+ } else
1009
+ c.push({
1010
+ type: "direct",
1011
+ originalColumn: g,
1012
+ spec: A,
1013
+ adjustedSpec: A
1014
+ });
1015
+ }
1016
+ }
1017
+ if (c.length === 0) return [];
1018
+ const w = Fe(
1019
+ c,
1020
+ (u) => ({
1021
+ spec: u.spec,
1022
+ suffixTrace: u.type === "split" ? ht(u.axisFilters) : void 0
1023
+ }),
1024
+ a
1025
+ ), d = [];
1026
+ for (const { value: u, label: f } of w) {
1027
+ const { originalColumn: p, spec: y } = u, v = u.type === "split" ? u.axisFilters : void 0, m = gt(v);
1028
+ let b;
1029
+ r ? b = r.deriveS(y, m) : b = mt(p.id, m);
1030
+ let g = { ...u.adjustedSpec };
1031
+ o && (g = {
1032
+ ...g,
1033
+ annotations: {
1034
+ ...g.annotations ?? {},
1035
+ "pl7.app/label": f
1036
+ }
1037
+ }), d.push({
1038
+ id: b,
1039
+ spec: g,
1040
+ data: () => u.type === "split" ? Ne(dt(u.dataEntries, m)) : u.originalColumn.data,
1041
+ label: f
1042
+ });
1043
+ }
1044
+ return d;
1045
+ }
1046
+ getColumns(e, n) {
1047
+ const r = this.getUniversalEntries(e, {
1048
+ overrideLabelAnnotation: !0,
1049
+ // default for getColumns
1050
+ ...n ?? {}
1051
+ });
1052
+ if (!r) return;
1053
+ const i = [];
1054
+ for (const s of r) {
1055
+ const o = s.data();
1056
+ if (!o) {
1057
+ if (n != null && n.dontWaitAllData) continue;
1058
+ return;
1059
+ }
1060
+ i.push({
1061
+ id: s.id,
1062
+ spec: s.spec,
1063
+ data: o
1064
+ });
1065
+ }
1066
+ return i;
1067
+ }
1068
+ }
1069
+ function le(t, e) {
1070
+ if (t === void 0) return e === void 0;
1071
+ if (e === void 0) return !0;
1072
+ for (const n in e)
1073
+ if (t[n] !== e[n]) return !1;
1074
+ return !0;
1075
+ }
1076
+ function we(t) {
1077
+ return ge(t, (e) => e instanceof I ? e.handle : me(e) ? qe(e, (n) => n.handle) : e);
1078
+ }
1079
+ class bt {
862
1080
  constructor() {
863
- T(this, "ctx", h());
1081
+ L(this, "ctx", h());
864
1082
  }
865
1083
  /**
866
1084
  * @deprecated use getOptions()
@@ -870,7 +1088,7 @@ class et {
870
1088
  }
871
1089
  getOptions(e, n) {
872
1090
  const r = typeof e == "function" ? e : ce(e), i = this.getSpecs().entries.filter((s) => r(s.obj));
873
- return typeof n == "object" || typeof n > "u" ? de(i, (s) => s.obj, n ?? {}).map(({ value: { ref: s }, label: o }) => ({
1091
+ return typeof n == "object" || typeof n > "u" ? Fe(i, (s) => s.obj, n ?? {}).map(({ value: { ref: s }, label: o }) => ({
874
1092
  ref: s,
875
1093
  label: o
876
1094
  })) : i.map((s) => ({
@@ -878,93 +1096,18 @@ class et {
878
1096
  label: n(s.obj, s.ref)
879
1097
  }));
880
1098
  }
881
- /**
882
- * Internal implementation that generates UniversalPColumnEntry objects from the provided
883
- * anchors and selectors.
884
- */
885
- getUniversalPColumnEntries(e, n, r) {
886
- const i = {};
887
- if (!(e instanceof te))
888
- for (const [l, m] of Object.entries(e))
889
- if (Ce(m)) {
890
- const u = this.getPColumnSpecByRef(m);
891
- if (!u)
892
- return;
893
- i[l] = u;
894
- } else
895
- i[l] = m;
896
- const s = typeof n == "function" ? [n] : Array.isArray(n) ? n : [n], o = e instanceof te ? e : new te(i), a = [];
897
- for (const l of s) {
898
- const m = typeof l == "function" ? l : ce(Le(i, l)), u = this.getSpecs().entries.filter(({ obj: p }) => J(p) ? m(p) : !1);
899
- if (u.length === 0)
900
- continue;
901
- const f = typeof l == "object" && "axes" in l && l.axes !== void 0 && l.partialAxesMatch === void 0 ? l.axes.map((p, d) => "split" in p && p.split === !0 ? d : -1).filter((p) => p !== -1) : [];
902
- if (f.sort((p, d) => p - d), f.length > 0) {
903
- const p = f[f.length - 1];
904
- for (const { ref: d, obj: y } of u) {
905
- if (!J(y)) throw new Error(`Assertion failed: expected PColumnSpec, got ${y.kind}`);
906
- const g = this.getDataByRef(d);
907
- if (!g) {
908
- if (r != null && r.dontWaitAllData) continue;
909
- return;
910
- }
911
- if (!M(g)) throw new Error(`Assertion failed: expected PColumn, got ${g.spec.kind}`);
912
- const v = Ye(g.data);
913
- if (!v) {
914
- if (r != null && r.dontWaitAllData) continue;
915
- return;
916
- }
917
- if (p >= v.length)
918
- throw new Error(`Not enough partition keys for the requested split axes in column ${y.name}`);
919
- const w = f.map((P) => this.findLabels(L(y.axesSpec[P]))), x = [], C = (P, F) => {
920
- if (F >= f.length) {
921
- x.push([...P]);
922
- return;
923
- }
924
- const R = f[F], k = v[R];
925
- for (const A of k)
926
- P.push(A), C(P, F + 1), P.pop();
927
- };
928
- C([], 0);
929
- for (const P of x) {
930
- const F = P.map((R, k) => {
931
- const A = f[k], j = L(y.axesSpec[A]), V = w[k], K = (V == null ? void 0 : V[R]) ?? String(R);
932
- return { axisIdx: A, axisId: j, value: R, label: K };
933
- });
934
- a.push({
935
- obj: y,
936
- ref: d,
937
- axisFilters: F
938
- });
939
- }
940
- }
1099
+ resolveAnchorCtx(e) {
1100
+ if (e instanceof ye) return e;
1101
+ const n = {};
1102
+ for (const [r, i] of Object.entries(e))
1103
+ if (Be(i)) {
1104
+ const s = this.getPColumnSpecByRef(i);
1105
+ if (!s)
1106
+ return;
1107
+ n[r] = s;
941
1108
  } else
942
- for (const { ref: p, obj: d } of u)
943
- J(d) && a.push({
944
- obj: d,
945
- ref: p
946
- // No splitFilters needed here
947
- });
948
- }
949
- return a.length === 0 ? [] : de(
950
- a,
951
- (l) => ({
952
- spec: l.obj,
953
- suffixTrace: Qe(l.axisFilters)
954
- // Use helper function
955
- }),
956
- (r == null ? void 0 : r.labelOps) ?? {}
957
- ).map((l) => ({
958
- id: o.deriveS(
959
- l.value.obj,
960
- Ze(l.value.axisFilters)
961
- // Use helper function
962
- ),
963
- obj: l.value.obj,
964
- ref: l.value.ref,
965
- axisFilters: l.value.axisFilters,
966
- label: l.label
967
- }));
1109
+ n[r] = i;
1110
+ return new ye(n);
968
1111
  }
969
1112
  /**
970
1113
  * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
@@ -975,55 +1118,12 @@ class et {
975
1118
  * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
976
1119
  */
977
1120
  getAnchoredPColumns(e, n, r) {
978
- const i = {
979
- ...r,
980
- labelOps: {
981
- includeNativeLabel: !0,
982
- ...(r == null ? void 0 : r.labelOps) || {}
983
- }
984
- }, s = this.getUniversalPColumnEntries(
985
- e,
986
- n,
987
- i
988
- );
989
- if (!s || s.length === 0) return;
990
- const o = [];
991
- for (const a of s) {
992
- const c = this.getPColumnByRef(a.ref);
993
- if (!c) return;
994
- const l = le(c.data);
995
- if (!l) return;
996
- let m = l, u = { ...c.spec };
997
- if (a.axisFilters && a.axisFilters.length > 0) {
998
- const p = a.axisFilters.map((g) => [
999
- g.axisIdx,
1000
- g.value
1001
- ]);
1002
- m = Xe(l, p);
1003
- const d = [...a.axisFilters].map((g) => g.axisIdx).sort((g, v) => v - g), y = [...u.axesSpec];
1004
- for (const g of d)
1005
- y.splice(g, 1);
1006
- u = { ...u, axesSpec: y };
1007
- }
1008
- const f = Te(m);
1009
- u.annotations ? u = {
1010
- ...u,
1011
- annotations: {
1012
- ...u.annotations,
1013
- "pl7.app/label": a.label
1014
- }
1015
- } : u = {
1016
- ...u,
1017
- annotations: {
1018
- "pl7.app/label": a.label
1019
- }
1020
- }, o.push({
1021
- id: a.id,
1022
- spec: u,
1023
- data: f
1121
+ const i = this.resolveAnchorCtx(e);
1122
+ if (i)
1123
+ return new be().addColumnProvider(this).addAxisLabelProvider(this).getColumns(n, {
1124
+ ...r,
1125
+ anchorCtx: i
1024
1126
  });
1025
- }
1026
- return o;
1027
1127
  }
1028
1128
  /**
1029
1129
  * Calculates anchored identifier options for columns matching a given predicate and returns their
@@ -1055,11 +1155,16 @@ class et {
1055
1155
  * or undefined if any PlRef resolution fails.
1056
1156
  */
1057
1157
  getCanonicalOptions(e, n, r) {
1058
- const i = this.getUniversalPColumnEntries(e, n, r);
1059
- if (i)
1060
- return i.map((s) => ({
1061
- value: s.id,
1062
- label: s.label
1158
+ const i = this.resolveAnchorCtx(e);
1159
+ if (!i) return;
1160
+ const s = new be().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(n, {
1161
+ ...r,
1162
+ anchorCtx: i
1163
+ });
1164
+ if (s)
1165
+ return s.map((o) => ({
1166
+ value: o.id,
1167
+ label: o.label
1063
1168
  }));
1064
1169
  }
1065
1170
  /**
@@ -1095,7 +1200,7 @@ class et {
1095
1200
  ref: n.ref,
1096
1201
  obj: {
1097
1202
  ...n.obj,
1098
- data: Fe(
1203
+ data: Me(
1099
1204
  n.obj.data,
1100
1205
  (r) => new I(r, [n.ref.blockId, n.ref.name])
1101
1206
  )
@@ -1124,7 +1229,7 @@ class et {
1124
1229
  )) == null ? void 0 : r.obj;
1125
1230
  const n = this.ctx.getDataFromResultPoolByRef(e.blockId, e.name);
1126
1231
  if (n)
1127
- return ue(
1232
+ return ge(
1128
1233
  n,
1129
1234
  (i) => new I(i, [e.blockId, e.name])
1130
1235
  );
@@ -1137,7 +1242,7 @@ class et {
1137
1242
  getPColumnByRef(e) {
1138
1243
  const n = this.getDataByRef(e);
1139
1244
  if (n)
1140
- return Re(n);
1245
+ return Ge(n);
1141
1246
  }
1142
1247
  /**
1143
1248
  * Returns spec associated with the ref ensuring that it is a p-column spec.
@@ -1147,7 +1252,7 @@ class et {
1147
1252
  getPColumnSpecByRef(e) {
1148
1253
  const n = this.getSpecByRef(e);
1149
1254
  if (n) {
1150
- if (!J(n)) throw new Error(`not a PColumn spec (kind = ${n.kind})`);
1255
+ if (!Z(n)) throw new Error(`not a PColumn spec (kind = ${n.kind})`);
1151
1256
  return n;
1152
1257
  }
1153
1258
  }
@@ -1166,13 +1271,13 @@ class et {
1166
1271
  findDataWithCompatibleSpec(e) {
1167
1272
  const n = [];
1168
1273
  e: for (const r of this.getData().entries) {
1169
- if (!J(r.obj.spec))
1274
+ if (!Z(r.obj.spec))
1170
1275
  continue;
1171
1276
  const i = r.obj.spec;
1172
- if (e.name === i.name && e.valueType === i.valueType && e.axesSpec.length === i.axesSpec.length && re(e.domain, i.domain)) {
1277
+ if (e.name === i.name && e.valueType === i.valueType && e.axesSpec.length === i.axesSpec.length && le(e.domain, i.domain)) {
1173
1278
  for (let s = 0; s < e.axesSpec.length; ++s) {
1174
1279
  const o = e.axesSpec[s], a = i.axesSpec[s];
1175
- if (o.name !== a.name || o.type !== a.type || !re(o.domain, a.domain))
1280
+ if (o.name !== a.name || o.type !== a.type || !le(o.domain, a.domain))
1176
1281
  continue e;
1177
1282
  }
1178
1283
  n.push(r.obj);
@@ -1187,9 +1292,9 @@ class et {
1187
1292
  findLabels(e) {
1188
1293
  const n = this.getData();
1189
1294
  for (const r of n.entries) {
1190
- if (!M(r.obj)) continue;
1295
+ if (!se(r.obj)) continue;
1191
1296
  const i = r.obj.spec;
1192
- if (i.name === "pl7.app/label" && i.axesSpec.length === 1 && i.axesSpec[0].name === e.name && i.axesSpec[0].type === e.type && re(e.domain, i.axesSpec[0].domain)) {
1297
+ if (i.name === "pl7.app/label" && i.axesSpec.length === 1 && i.axesSpec[0].name === e.name && i.axesSpec[0].type === e.type && le(e.domain, i.axesSpec[0].domain)) {
1193
1298
  if (r.obj.data.resourceType.name !== "PColumnData/Json")
1194
1299
  throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);
1195
1300
  return Object.fromEntries(
@@ -1200,15 +1305,50 @@ class et {
1200
1305
  }
1201
1306
  }
1202
1307
  }
1308
+ /**
1309
+ * Selects columns based on the provided selectors, returning PColumn objects
1310
+ * with lazily loaded data.
1311
+ *
1312
+ * @param selectors - A predicate function, a single selector, or an array of selectors.
1313
+ * @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
1314
+ */
1315
+ selectColumns(e) {
1316
+ const n = typeof e == "function" ? e : ce(e);
1317
+ return this.getSpecs().entries.filter(({ obj: i }) => Z(i) ? n(i) : !1).map(({ ref: i, obj: s }) => {
1318
+ const o = s;
1319
+ let a = null;
1320
+ const l = this;
1321
+ return {
1322
+ id: Pe(i),
1323
+ spec: o,
1324
+ get data() {
1325
+ var c;
1326
+ return a !== null || (a = (c = l.getPColumnByRef(i)) == null ? void 0 : c.data), a;
1327
+ }
1328
+ };
1329
+ });
1330
+ }
1331
+ /**
1332
+ * Find labels data for a given axis id of a p-column.
1333
+ * @returns a map of axis value => label
1334
+ */
1335
+ findLabelsForColumnAxis(e, n) {
1336
+ const r = this.findLabels(e.spec.axesSpec[n]);
1337
+ if (r)
1338
+ return Object.fromEntries(e.data.listInputFields().map((i) => {
1339
+ const s = JSON.parse(i);
1340
+ return [s[n], r[s[n]] ?? "Unlabelled"];
1341
+ }));
1342
+ }
1203
1343
  }
1204
- class z {
1344
+ class Q {
1205
1345
  constructor() {
1206
- T(this, "ctx");
1207
- T(this, "args");
1208
- T(this, "uiState");
1346
+ L(this, "ctx");
1347
+ L(this, "args");
1348
+ L(this, "uiState");
1209
1349
  // lazy rendering because this feature is rarely used
1210
- T(this, "_activeArgsCache");
1211
- T(this, "resultPool", new et());
1350
+ L(this, "_activeArgsCache");
1351
+ L(this, "resultPool", new bt());
1212
1352
  this.ctx = h(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : {};
1213
1353
  }
1214
1354
  /**
@@ -1225,16 +1365,16 @@ class z {
1225
1365
  // return this.ctx.featureFlags;
1226
1366
  // }
1227
1367
  getNamedAccessor(e) {
1228
- return ie(
1368
+ return pe(
1229
1369
  this.ctx.getAccessorHandleByName(e),
1230
1370
  (n) => new I(n, [e])
1231
1371
  );
1232
1372
  }
1233
1373
  get prerun() {
1234
- return this.getNamedAccessor(ve);
1374
+ return this.getNamedAccessor(Ie);
1235
1375
  }
1236
1376
  get outputs() {
1237
- return this.getNamedAccessor(we);
1377
+ return this.getNamedAccessor(Le);
1238
1378
  }
1239
1379
  /**
1240
1380
  * Find labels data for a given axis id. It will search for a label column and return its data as a map.
@@ -1249,9 +1389,10 @@ class z {
1249
1389
  const n = e.some((s) => !(s.data instanceof I) || me(s.data)), r = ((i = this.ctx.featureFlags) == null ? void 0 : i.inlineColumnsSupport) === !0;
1250
1390
  if (n && !r) throw Error("Inline or explicit columns not supported");
1251
1391
  }
1392
+ // TODO remove all non-PColumn fields
1252
1393
  createPFrame(e) {
1253
1394
  return this.verifyInlineAndExplicitColumnsSupport(e), this.ctx.createPFrame(
1254
- e.map((n) => fe(n))
1395
+ e.map((n) => we(n))
1255
1396
  );
1256
1397
  }
1257
1398
  createPTable(e) {
@@ -1263,8 +1404,8 @@ class z {
1263
1404
  },
1264
1405
  filters: e.filters ?? [],
1265
1406
  sorting: e.sorting ?? []
1266
- } : n = e, this.verifyInlineAndExplicitColumnsSupport(ke(n.src)), this.ctx.createPTable(
1267
- De(n, (r) => fe(r))
1407
+ } : n = e, this.verifyInlineAndExplicitColumnsSupport(We(n.src)), this.ctx.createPTable(
1408
+ He(n, (r) => we(r))
1268
1409
  );
1269
1410
  }
1270
1411
  /** @deprecated scheduled for removal from SDK */
@@ -1276,19 +1417,19 @@ class z {
1276
1417
  return this.ctx.getCurrentUnstableMarker();
1277
1418
  }
1278
1419
  }
1279
- const U = "1.27.10";
1280
- function tt(t) {
1420
+ const M = "1.28.0";
1421
+ function wt(t) {
1281
1422
  return t.__renderLambda === !0;
1282
1423
  }
1283
- function se(t) {
1424
+ function ue(t) {
1284
1425
  if (t !== void 0)
1285
- return tt(t) ? t.handle : t;
1426
+ return wt(t) ? t.handle : t;
1286
1427
  }
1287
- function D(t) {
1428
+ function j(t) {
1288
1429
  if (t !== void 0)
1289
1430
  return typeof t == "string" ? { __renderLambda: !0, handle: t, retentive: !1 } : t;
1290
1431
  }
1291
- function Gt(t) {
1432
+ function dn(t) {
1292
1433
  if (t.v3 !== void 0) {
1293
1434
  const {
1294
1435
  initialArgs: e,
@@ -1298,8 +1439,8 @@ function Gt(t) {
1298
1439
  renderingMode: s,
1299
1440
  sdkVersion: o,
1300
1441
  sections: a,
1301
- title: c
1302
- } = t.v3, { code: l } = t;
1442
+ title: l
1443
+ } = t.v3, { code: c } = t;
1303
1444
  return {
1304
1445
  initialArgs: e,
1305
1446
  initialUiState: n,
@@ -1308,42 +1449,42 @@ function Gt(t) {
1308
1449
  renderingMode: s,
1309
1450
  sdkVersion: o,
1310
1451
  sections: a,
1311
- title: c,
1312
- code: l
1452
+ title: l,
1453
+ code: c
1313
1454
  };
1314
1455
  } else if (t.inputsValid !== void 0) {
1315
- const { sdkVersion: e, renderingMode: n, outputs: r, inputsValid: i, sections: s, initialArgs: o, code: a } = t, c = Object.keys(t);
1456
+ const { sdkVersion: e, renderingMode: n, outputs: r, inputsValid: i, sections: s, initialArgs: o, code: a } = t, l = Object.keys(t);
1316
1457
  if (e === void 0 || n === void 0 || r === void 0 || i === void 0 || s === void 0 || o === void 0)
1317
1458
  throw new Error(
1318
- `Malformed config v2. SDK version ${e}; Fields = ${c.join(", ")}`
1459
+ `Malformed config v2. SDK version ${e}; Fields = ${l.join(", ")}`
1319
1460
  );
1320
1461
  return {
1321
1462
  sdkVersion: e,
1322
1463
  renderingMode: n,
1323
1464
  initialArgs: o,
1324
1465
  outputs: Object.fromEntries(
1325
- Object.entries(r).map(([l, m]) => [l, D(m)])
1466
+ Object.entries(r).map(([c, w]) => [c, j(w)])
1326
1467
  ),
1327
- inputsValid: D(i),
1328
- sections: D(s),
1468
+ inputsValid: j(i),
1469
+ sections: j(s),
1329
1470
  initialUiState: void 0,
1330
1471
  code: a
1331
1472
  };
1332
1473
  } else if (t.renderingMode !== void 0) {
1333
- const { sdkVersion: e, canRun: n, renderingMode: r, outputs: i, sections: s, initialArgs: o, code: a } = t, c = Object.keys(t);
1474
+ const { sdkVersion: e, canRun: n, renderingMode: r, outputs: i, sections: s, initialArgs: o, code: a } = t, l = Object.keys(t);
1334
1475
  if (r === void 0 || i === void 0 || n === void 0 || s === void 0 || o === void 0)
1335
1476
  throw new Error(
1336
- `Malformed config v1. SDK version ${e}; Fields = ${c.join(", ")}`
1477
+ `Malformed config v1. SDK version ${e}; Fields = ${l.join(", ")}`
1337
1478
  );
1338
1479
  return {
1339
1480
  sdkVersion: e ?? "unknown",
1340
1481
  renderingMode: r,
1341
1482
  initialArgs: o,
1342
1483
  outputs: Object.fromEntries(
1343
- Object.entries(i).map(([l, m]) => [l, D(m)])
1484
+ Object.entries(i).map(([c, w]) => [c, j(w)])
1344
1485
  ),
1345
- inputsValid: D(n),
1346
- sections: D(s),
1486
+ inputsValid: j(n),
1487
+ sections: j(s),
1347
1488
  initialUiState: void 0,
1348
1489
  code: a
1349
1490
  };
@@ -1354,25 +1495,25 @@ function Gt(t) {
1354
1495
  );
1355
1496
  }
1356
1497
  }
1357
- class _ {
1498
+ class T {
1358
1499
  constructor(e, n, r, i, s, o, a) {
1359
1500
  this._renderingMode = e, this._initialArgs = n, this._initialUiState = r, this._outputs = i, this._inputsValid = s, this._sections = o, this._title = a;
1360
1501
  }
1361
1502
  static create(e = "Heavy") {
1362
- return new _(
1503
+ return new T(
1363
1504
  e,
1364
1505
  void 0,
1365
1506
  {},
1366
1507
  {},
1367
- Y(!0),
1368
- Y([]),
1508
+ ee(!0),
1509
+ ee([]),
1369
1510
  void 0
1370
1511
  );
1371
1512
  }
1372
1513
  output(e, n, r = {}) {
1373
1514
  if (typeof n == "function") {
1374
1515
  const i = `output#${e}`;
1375
- return q(i, () => n(new z())), new _(
1516
+ return X(i, () => n(new Q())), new T(
1376
1517
  this._renderingMode,
1377
1518
  this._initialArgs,
1378
1519
  this._initialUiState,
@@ -1389,7 +1530,7 @@ class _ {
1389
1530
  this._title
1390
1531
  );
1391
1532
  } else
1392
- return new _(
1533
+ return new T(
1393
1534
  this._renderingMode,
1394
1535
  this._initialArgs,
1395
1536
  this._initialUiState,
@@ -1407,7 +1548,7 @@ class _ {
1407
1548
  return this.output(e, n, { retentive: !0 });
1408
1549
  }
1409
1550
  argsValid(e) {
1410
- return typeof e == "function" ? (q("inputsValid", () => e(new z())), new _(
1551
+ return typeof e == "function" ? (X("inputsValid", () => e(new Q())), new T(
1411
1552
  this._renderingMode,
1412
1553
  this._initialArgs,
1413
1554
  this._initialUiState,
@@ -1418,7 +1559,7 @@ class _ {
1418
1559
  },
1419
1560
  this._sections,
1420
1561
  this._title
1421
- )) : new _(
1562
+ )) : new T(
1422
1563
  this._renderingMode,
1423
1564
  this._initialArgs,
1424
1565
  this._initialUiState,
@@ -1429,7 +1570,7 @@ class _ {
1429
1570
  );
1430
1571
  }
1431
1572
  sections(e) {
1432
- return Array.isArray(e) ? this.sections(Y(e)) : typeof e == "function" ? (q("sections", () => e(new z())), new _(
1573
+ return Array.isArray(e) ? this.sections(ee(e)) : typeof e == "function" ? (X("sections", () => e(new Q())), new T(
1433
1574
  this._renderingMode,
1434
1575
  this._initialArgs,
1435
1576
  this._initialUiState,
@@ -1437,7 +1578,7 @@ class _ {
1437
1578
  this._inputsValid,
1438
1579
  { __renderLambda: !0, handle: "sections" },
1439
1580
  this._title
1440
- )) : new _(
1581
+ )) : new T(
1441
1582
  this._renderingMode,
1442
1583
  this._initialArgs,
1443
1584
  this._initialUiState,
@@ -1449,7 +1590,7 @@ class _ {
1449
1590
  }
1450
1591
  /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
1451
1592
  title(e) {
1452
- return q("title", () => e(new z())), new _(
1593
+ return X("title", () => e(new Q())), new T(
1453
1594
  this._renderingMode,
1454
1595
  this._initialArgs,
1455
1596
  this._initialUiState,
@@ -1464,7 +1605,7 @@ class _ {
1464
1605
  * @deprecated use {@link withArgs}
1465
1606
  * */
1466
1607
  initialArgs(e) {
1467
- return new _(
1608
+ return new T(
1468
1609
  this._renderingMode,
1469
1610
  e,
1470
1611
  this._initialUiState,
@@ -1476,7 +1617,7 @@ class _ {
1476
1617
  }
1477
1618
  /** Sets initial args for the block, this value must be specified. */
1478
1619
  withArgs(e) {
1479
- return new _(
1620
+ return new T(
1480
1621
  this._renderingMode,
1481
1622
  e,
1482
1623
  this._initialUiState,
@@ -1488,7 +1629,7 @@ class _ {
1488
1629
  }
1489
1630
  /** Defines type and sets initial value for block UiState. */
1490
1631
  withUiState(e) {
1491
- return new _(
1632
+ return new T(
1492
1633
  this._renderingMode,
1493
1634
  this._initialArgs,
1494
1635
  e,
@@ -1505,7 +1646,7 @@ class _ {
1505
1646
  if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
1506
1647
  const e = {
1507
1648
  v3: {
1508
- sdkVersion: U,
1649
+ sdkVersion: M,
1509
1650
  renderingMode: this._renderingMode,
1510
1651
  initialArgs: this._initialArgs,
1511
1652
  initialUiState: this._initialUiState,
@@ -1515,75 +1656,75 @@ class _ {
1515
1656
  outputs: this._outputs
1516
1657
  },
1517
1658
  // fields below are added to allow previous desktop versions read generated configs
1518
- sdkVersion: U,
1659
+ sdkVersion: M,
1519
1660
  renderingMode: this._renderingMode,
1520
1661
  initialArgs: this._initialArgs,
1521
- inputsValid: se(this._inputsValid),
1522
- sections: se(this._sections),
1662
+ inputsValid: ue(this._inputsValid),
1663
+ sections: ue(this._sections),
1523
1664
  outputs: Object.fromEntries(
1524
- Object.entries(this._outputs).map(([n, r]) => [n, se(r)])
1665
+ Object.entries(this._outputs).map(([n, r]) => [n, ue(r)])
1525
1666
  )
1526
1667
  };
1527
- return Ke() ? be({ sdkVersion: U }) : { config: e };
1668
+ return Xe() ? _e({ sdkVersion: M }) : { config: e };
1528
1669
  }
1529
1670
  }
1530
- function Wt(t, e, n, r) {
1531
- var l, m;
1671
+ function fn(t, e, n, r) {
1672
+ var c, w;
1532
1673
  Array.isArray(r) && (r = { filters: r });
1533
- const i = t.resultPool.getData().entries.map((u) => u.obj).filter(M).filter((u) => u.spec.name === "pl7.app/label" && u.spec.axesSpec.length === 1), s = (u, f) => {
1534
- let p = u.toString();
1535
- if (f)
1536
- for (const d in f)
1537
- p += d, p += f[d];
1538
- return p;
1674
+ const i = t.resultPool.getData().entries.map((d) => d.obj).filter(se).filter((d) => d.spec.name === "pl7.app/label" && d.spec.axesSpec.length === 1), s = (d, u) => {
1675
+ let f = d.toString();
1676
+ if (u)
1677
+ for (const p in u)
1678
+ f += p, f += u[p];
1679
+ return f;
1539
1680
  }, o = /* @__PURE__ */ new Map();
1540
- for (const u of e)
1541
- for (const f of u.spec.axesSpec) {
1542
- const p = L(f);
1543
- for (const d of i) {
1544
- const y = d.spec.axesSpec[0], g = L(d.spec.axesSpec[0]);
1545
- if (G(p, g)) {
1546
- const v = Object.keys(p.domain ?? {}).length, w = Object.keys(g.domain ?? {}).length;
1547
- if (v > w) {
1548
- const x = s(d.id, p.domain);
1549
- o.set(x, {
1550
- id: x,
1681
+ for (const d of e)
1682
+ for (const u of d.spec.axesSpec) {
1683
+ const f = F(u);
1684
+ for (const p of i) {
1685
+ const y = p.spec.axesSpec[0], v = F(p.spec.axesSpec[0]);
1686
+ if (G(f, v)) {
1687
+ const m = Object.keys(f.domain ?? {}).length, b = Object.keys(v.domain ?? {}).length;
1688
+ if (m > b) {
1689
+ const g = s(p.id, f.domain);
1690
+ o.set(g, {
1691
+ id: g,
1551
1692
  spec: {
1552
- ...d.spec,
1553
- axesSpec: [{ ...p, annotations: y.annotations }]
1693
+ ...p.spec,
1694
+ axesSpec: [{ ...f, annotations: y.annotations }]
1554
1695
  },
1555
- data: d.data
1696
+ data: p.data
1556
1697
  });
1557
1698
  } else
1558
- o.set(s(d.id), d);
1699
+ o.set(s(p.id), p);
1559
1700
  }
1560
1701
  }
1561
1702
  }
1562
1703
  if ([...e, ...o.values()].some(
1563
- (u) => u.data instanceof I && !u.data.getIsReadyOrError()
1704
+ (d) => d.data instanceof I && !d.data.getIsReadyOrError()
1564
1705
  ))
1565
1706
  return;
1566
1707
  let a = e;
1567
- const c = [];
1708
+ const l = [];
1568
1709
  if (r != null && r.coreColumnPredicate) {
1569
1710
  a = [];
1570
- for (const u of e)
1571
- r.coreColumnPredicate(u.spec) ? a.push(u) : c.push(u);
1711
+ for (const d of e)
1712
+ r.coreColumnPredicate(d.spec) ? a.push(d) : l.push(d);
1572
1713
  }
1573
- return c.push(...o.values()), t.createPTable({
1714
+ return l.push(...o.values()), t.createPTable({
1574
1715
  src: {
1575
1716
  type: "outer",
1576
1717
  primary: {
1577
1718
  type: (r == null ? void 0 : r.coreJoinType) ?? "full",
1578
- entries: a.map((u) => ({ type: "column", column: u }))
1719
+ entries: a.map((d) => ({ type: "column", column: d }))
1579
1720
  },
1580
- secondary: c.map((u) => ({ type: "column", column: u }))
1721
+ secondary: l.map((d) => ({ type: "column", column: d }))
1581
1722
  },
1582
- filters: [...(r == null ? void 0 : r.filters) ?? [], ...((l = n == null ? void 0 : n.pTableParams) == null ? void 0 : l.filters) ?? []],
1583
- sorting: ((m = n == null ? void 0 : n.pTableParams) == null ? void 0 : m.sorting) ?? []
1723
+ filters: [...(r == null ? void 0 : r.filters) ?? [], ...((c = n == null ? void 0 : n.pTableParams) == null ? void 0 : c.filters) ?? []],
1724
+ sorting: ((w = n == null ? void 0 : n.pTableParams) == null ? void 0 : w.sorting) ?? []
1584
1725
  });
1585
1726
  }
1586
- function Ht(t, e, n) {
1727
+ function hn(t, e, n) {
1587
1728
  const r = t.resultPool.findLabels(e);
1588
1729
  return {
1589
1730
  axis: e,
@@ -1594,7 +1735,7 @@ function Ht(t, e, n) {
1594
1735
  defaultValue: n[0]
1595
1736
  };
1596
1737
  }
1597
- const nt = (t, e) => {
1738
+ const At = (t, e) => {
1598
1739
  let n = t.toString();
1599
1740
  return e == null || e.forEach((r) => {
1600
1741
  if (r)
@@ -1602,7 +1743,7 @@ const nt = (t, e) => {
1602
1743
  n += i, n += s;
1603
1744
  }), n;
1604
1745
  };
1605
- function rt(t) {
1746
+ function St(t) {
1606
1747
  if (!t.length)
1607
1748
  return [];
1608
1749
  let e = [[]];
@@ -1613,87 +1754,87 @@ function rt(t) {
1613
1754
  }), e = r;
1614
1755
  }), e;
1615
1756
  }
1616
- function st(t, e) {
1617
- const n = t.spec.axesSpec.map(L);
1618
- return e.spec.axesSpec.map(L).every((i) => n.some((s) => G(s, i) && G(i, s)));
1757
+ function xt(t, e) {
1758
+ const n = t.spec.axesSpec.map(F);
1759
+ return e.spec.axesSpec.map(F).every((i) => n.some((s) => G(s, i) && G(i, s)));
1619
1760
  }
1620
- function Pe(t, e) {
1621
- const n = t.spec.axesSpec.map(L);
1622
- return e.spec.axesSpec.map(L).every((i) => n.some((s) => G(s, i)));
1761
+ function ke(t, e) {
1762
+ const n = t.spec.axesSpec.map(F);
1763
+ return e.spec.axesSpec.map(F).every((i) => n.some((s) => G(s, i)));
1623
1764
  }
1624
- const it = "pl7.app/graph/isVirtual", he = "pl7.app/label";
1625
- function ge(t, e) {
1626
- const n = t.spec.axesSpec.map(L), r = e.spec.axesSpec.map(L);
1627
- if (st(t, e))
1765
+ const Pt = "pl7.app/graph/isVirtual", Ae = "pl7.app/label";
1766
+ function Se(t, e) {
1767
+ const n = t.spec.axesSpec.map(F), r = e.spec.axesSpec.map(F);
1768
+ if (xt(t, e))
1628
1769
  return [];
1629
- if (!Pe(t, e))
1770
+ if (!ke(t, e))
1630
1771
  return [];
1631
- const o = r.map((u) => n.filter((f) => G(f, u))), a = rt(o), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), m = a.map((u) => {
1632
- const f = /* @__PURE__ */ new Set();
1633
- return u.map((p, d) => {
1634
- const y = e.spec.axesSpec[d].domain, g = p.domain;
1635
- return Object.entries(g ?? {}).forEach(([v, w]) => {
1636
- if ((y == null ? void 0 : y[v]) === void 0) {
1637
- const x = JSON.stringify([v, w]);
1638
- f.add(x), c.add(x);
1772
+ const o = r.map((d) => n.filter((u) => G(u, d))), a = St(o), l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), w = a.map((d) => {
1773
+ const u = /* @__PURE__ */ new Set();
1774
+ return d.map((f, p) => {
1775
+ const y = e.spec.axesSpec[p].domain, v = f.domain;
1776
+ return Object.entries(v ?? {}).forEach(([m, b]) => {
1777
+ if ((y == null ? void 0 : y[m]) === void 0) {
1778
+ const g = JSON.stringify([m, b]);
1779
+ u.add(g), l.add(g);
1639
1780
  }
1640
1781
  }), {
1641
- ...p,
1642
- annotations: e.spec.axesSpec[d].annotations
1782
+ ...f,
1783
+ annotations: e.spec.axesSpec[p].annotations
1643
1784
  };
1644
- }), f;
1785
+ }), u;
1645
1786
  });
1646
- return [...c].forEach((u) => {
1647
- m.some((f) => !f.has(u)) && l.add(u);
1648
- }), a.map((u, f) => {
1649
- var v;
1650
- const p = nt(e.id, u.map((w) => w.domain)), d = ((v = e.spec.annotations) == null ? void 0 : v[he]) ?? "", y = [...m[f]].filter((w) => l.has(w)).sort().map((w) => {
1651
- var x;
1652
- return (x = JSON.parse(w)) == null ? void 0 : x[1];
1653
- }).join(" / "), g = {
1787
+ return [...l].forEach((d) => {
1788
+ w.some((u) => !u.has(d)) && c.add(d);
1789
+ }), a.map((d, u) => {
1790
+ var m;
1791
+ const f = At(e.id, d.map((b) => b.domain)), p = ((m = e.spec.annotations) == null ? void 0 : m[Ae]) ?? "", y = [...w[u]].filter((b) => c.has(b)).sort().map((b) => {
1792
+ var g;
1793
+ return (g = JSON.parse(b)) == null ? void 0 : g[1];
1794
+ }).join(" / "), v = {
1654
1795
  ...e.spec.annotations,
1655
- [it]: "true"
1796
+ [Pt]: "true"
1656
1797
  };
1657
- return (d || y) && (g[he] = d && y ? d + " / " + y : d + y), {
1658
- id: p,
1798
+ return (p || y) && (v[Ae] = p && y ? p + " / " + y : p + y), {
1799
+ id: f,
1659
1800
  spec: {
1660
1801
  ...e.spec,
1661
- axesSpec: u.map((w, x) => ({
1662
- ...w,
1663
- annotations: e.spec.axesSpec[x].annotations
1802
+ axesSpec: d.map((b, g) => ({
1803
+ ...b,
1804
+ annotations: e.spec.axesSpec[g].annotations
1664
1805
  })),
1665
- annotations: g
1806
+ annotations: v
1666
1807
  },
1667
1808
  data: e.data
1668
1809
  };
1669
1810
  });
1670
1811
  }
1671
- function ot(t) {
1812
+ function Ct(t) {
1672
1813
  const e = [];
1673
1814
  for (let n = 0; n < t.length; n++)
1674
1815
  for (let r = n + 1; r < t.length; r++) {
1675
1816
  const i = t[n], s = t[r];
1676
1817
  e.push(
1677
- ...ge(i, s),
1678
- ...ge(s, i)
1818
+ ...Se(i, s),
1819
+ ...Se(s, i)
1679
1820
  );
1680
1821
  }
1681
1822
  return e;
1682
1823
  }
1683
- function at(t, e) {
1824
+ function _t(t, e) {
1684
1825
  const n = [...t];
1685
1826
  for (const r of e)
1686
1827
  for (const i of t) {
1687
1828
  if (i.id === r.id)
1688
1829
  break;
1689
- if (Pe(i, r)) {
1830
+ if (ke(i, r)) {
1690
1831
  n.push(r);
1691
1832
  break;
1692
1833
  }
1693
1834
  }
1694
1835
  return n;
1695
1836
  }
1696
- const lt = [
1837
+ const It = [
1697
1838
  "Int",
1698
1839
  "Long",
1699
1840
  "Float",
@@ -1701,15 +1842,15 @@ const lt = [
1701
1842
  "String",
1702
1843
  "Bytes"
1703
1844
  ];
1704
- function qt(t, e) {
1845
+ function gn(t, e) {
1705
1846
  if (e === void 0) return;
1706
- const n = t.resultPool.getData().entries.map((s) => s.obj).filter(M).filter((s) => lt.includes(s.spec.valueType)), r = at(e, n), i = [...r, ...ot(r)];
1847
+ const n = t.resultPool.getData().entries.map((s) => s.obj).filter(se).filter((s) => It.includes(s.spec.valueType)), r = _t(e, n), i = [...r, ...Ct(r)];
1707
1848
  if (!i.some(
1708
1849
  (s) => s.data instanceof I && !s.data.getIsReadyOrError()
1709
1850
  ))
1710
1851
  return t.createPFrame(i);
1711
1852
  }
1712
- class zt {
1853
+ class mn {
1713
1854
  constructor(e) {
1714
1855
  this.handle = e;
1715
1856
  }
@@ -1729,111 +1870,113 @@ class zt {
1729
1870
  return await platforma.pFrameDriver.getUniqueValues(this.handle, e);
1730
1871
  }
1731
1872
  }
1732
- function ut(t) {
1733
- return ye({
1873
+ function Lt(t) {
1874
+ return Ce({
1734
1875
  __isRef: !0,
1735
- blockId: X(t, "blockId"),
1736
- name: X(t, "name")
1876
+ blockId: te(t, "blockId"),
1877
+ name: te(t, "name")
1737
1878
  });
1738
1879
  }
1739
- function Yt(t) {
1740
- return ye({
1741
- ref: ut(X(t, "ref")),
1742
- label: X(t, "label")
1880
+ function yn(t) {
1881
+ return Ce({
1882
+ ref: Lt(te(t, "ref")),
1883
+ label: te(t, "label")
1743
1884
  });
1744
1885
  }
1745
- const Xt = {
1746
- sdkVersion: U
1886
+ const vn = {
1887
+ sdkVersion: M
1747
1888
  };
1748
- function ct() {
1749
- return be({ sdkVersion: U });
1889
+ function Tt() {
1890
+ return _e({ sdkVersion: M });
1750
1891
  }
1751
- function Qt(t) {
1892
+ function bn(t) {
1752
1893
  try {
1753
- return ct();
1894
+ return Tt();
1754
1895
  } catch {
1755
1896
  return t;
1756
1897
  }
1757
1898
  }
1758
- function Zt(t) {
1899
+ function wn(t) {
1759
1900
  if (typeof globalThis.getEnvironmentValue == "function")
1760
1901
  return globalThis.getEnvironmentValue(t);
1761
1902
  }
1762
1903
  export {
1763
- mt as Args,
1764
- _ as BlockModel,
1765
- Xt as CurrentSdkInfo,
1766
- S as FutureRef,
1767
- it as IS_VIRTUAL_COLUMN,
1768
- yt as It,
1769
- Ut as JsRenderInternal,
1770
- he as LABEL_ANNOTATION,
1771
- bt as MainOutputs,
1772
- je as OutputError,
1773
- Ue as PAnnotationLabel,
1774
- Me as PAnnotationTrace,
1775
- zt as PFrameImpl,
1776
- E as RT_BINARY_PARTITIONED,
1904
+ jt as Args,
1905
+ T as BlockModel,
1906
+ vn as CurrentSdkInfo,
1907
+ _ as FutureRef,
1908
+ Pt as IS_VIRTUAL_COLUMN,
1909
+ Kt as It,
1910
+ cn as JsRenderInternal,
1911
+ Ae as LABEL_ANNOTATION,
1912
+ Vt as MainOutputs,
1913
+ ze as OutputError,
1914
+ nt as PAnnotationLabel,
1915
+ rt as PAnnotationTrace,
1916
+ be as PColumnCollection,
1917
+ mn as PFrameImpl,
1918
+ V as RT_BINARY_PARTITIONED,
1777
1919
  B as RT_BINARY_SUPER_PARTITIONED,
1778
- N as RT_JSON_PARTITIONED,
1779
- ee as RT_JSON_SUPER_PARTITIONED,
1780
- Q as RT_RESOURCE_MAP,
1781
- Z as RT_RESOURCE_MAP_PARTITIONED,
1782
- z as RenderCtx,
1783
- et as ResultPool,
1784
- vt as StagingOutputs,
1785
- We as Trace,
1786
- Ge as TraceEntry,
1920
+ U as RT_JSON_PARTITIONED,
1921
+ ie as RT_JSON_SUPER_PARTITIONED,
1922
+ ne as RT_RESOURCE_MAP,
1923
+ re as RT_RESOURCE_MAP_PARTITIONED,
1924
+ Q as RenderCtx,
1925
+ bt as ResultPool,
1926
+ $t as StagingOutputs,
1927
+ st as Trace,
1928
+ it as TraceEntry,
1787
1929
  I as TreeNodeAccessor,
1788
- wt as UiState,
1789
- Ct as and,
1790
- qt as createPFrameForGraphs,
1791
- Wt as createPlDataTable,
1792
- Ht as createPlDataTableSheet,
1793
- de as deriveLabels,
1794
- se as downgradeCfgOrLambda,
1795
- at as enrichColumnsWithCompatible,
1796
- Vt as extractArchiveAndGetURL,
1797
- Gt as extractConfig,
1798
- Xe as filterDataInfoEntries,
1799
- Pt as flatten,
1800
- Yt as fromPlOption,
1801
- ut as fromPlRef,
1802
- ot as getAdditionalColumns,
1803
- kt as getBlobContent,
1804
- Ot as getBlobContentAsJson,
1805
- Dt as getBlobContentAsString,
1806
- Et as getDownloadedBlobContent,
1807
- Zt as getEnvironmentValue,
1930
+ Jt as UiState,
1931
+ Ht as and,
1932
+ pt as convertOrParsePColumnData,
1933
+ gn as createPFrameForGraphs,
1934
+ fn as createPlDataTable,
1935
+ hn as createPlDataTableSheet,
1936
+ Fe as deriveLabels,
1937
+ ue as downgradeCfgOrLambda,
1938
+ _t as enrichColumnsWithCompatible,
1939
+ rn as extractArchiveAndGetURL,
1940
+ dn as extractConfig,
1941
+ dt as filterDataInfoEntries,
1942
+ Mt as flatten,
1943
+ yn as fromPlOption,
1944
+ Lt as fromPlRef,
1945
+ Ct as getAdditionalColumns,
1946
+ Qt as getBlobContent,
1947
+ en as getBlobContentAsJson,
1948
+ Zt as getBlobContentAsString,
1949
+ tn as getDownloadedBlobContent,
1950
+ wn as getEnvironmentValue,
1808
1951
  W as getFromCfg,
1809
- Y as getImmediate,
1810
- Kt as getImportProgress,
1811
- X as getJsonField,
1812
- $t as getLastLogs,
1813
- Bt as getLogHandle,
1814
- jt as getOnDemandBlobContent,
1815
- ze as getPartitionKeysList,
1816
- Qt as getPlatformaOrDefault,
1817
- Jt as getProgressLog,
1818
- Nt as getProgressLogWithInfo,
1819
- ct as getRawPlatformaInstance,
1820
- Tt as getResourceField,
1821
- Ft as getResourceValueAsJson,
1822
- Ye as getUniquePartitionKeys,
1823
- ie as ifDef,
1824
- tt as isConfigLambda,
1825
- _t as isEmpty,
1826
- gt as isolate,
1827
- xt as makeArray,
1828
- ye as makeObject,
1829
- St as mapArrayValues,
1830
- At as mapRecordValues,
1831
- Rt as mapResourceFields,
1832
- It as not,
1833
- Lt as or,
1834
- le as parsePColumnData,
1835
- Mt as parseResourceMap,
1836
- Ve as readOutput,
1837
- ht as wrapOutputs
1952
+ ee as getImmediate,
1953
+ sn as getImportProgress,
1954
+ te as getJsonField,
1955
+ on as getLastLogs,
1956
+ un as getLogHandle,
1957
+ nn as getOnDemandBlobContent,
1958
+ lt as getPartitionKeysList,
1959
+ bn as getPlatformaOrDefault,
1960
+ an as getProgressLog,
1961
+ ln as getProgressLogWithInfo,
1962
+ Tt as getRawPlatformaInstance,
1963
+ zt as getResourceField,
1964
+ Yt as getResourceValueAsJson,
1965
+ ct as getUniquePartitionKeys,
1966
+ pe as ifDef,
1967
+ wt as isConfigLambda,
1968
+ Gt as isEmpty,
1969
+ Ot as isolate,
1970
+ Nt as makeArray,
1971
+ Ce as makeObject,
1972
+ Bt as mapArrayValues,
1973
+ Ut as mapRecordValues,
1974
+ Xt as mapResourceFields,
1975
+ Wt as not,
1976
+ qt as or,
1977
+ he as parsePColumnData,
1978
+ pn as parseResourceMap,
1979
+ Ye as readOutput,
1980
+ Rt as wrapOutputs
1838
1981
  };
1839
1982
  //# sourceMappingURL=index.mjs.map