@milaboratories/pl-model-common 1.19.7 → 1.19.8

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 (236) hide show
  1. package/dist/author_marker.d.ts +0 -1
  2. package/dist/base32_encode.cjs +56 -0
  3. package/dist/base32_encode.cjs.map +1 -0
  4. package/dist/base32_encode.d.ts +0 -1
  5. package/dist/base32_encode.js +54 -0
  6. package/dist/base32_encode.js.map +1 -0
  7. package/dist/block_state.d.ts +0 -1
  8. package/dist/bmodel/block_config.cjs +15 -0
  9. package/dist/bmodel/block_config.cjs.map +1 -0
  10. package/dist/bmodel/block_config.d.ts +0 -1
  11. package/dist/bmodel/block_config.js +13 -0
  12. package/dist/bmodel/block_config.js.map +1 -0
  13. package/dist/bmodel/code.d.ts +0 -1
  14. package/dist/bmodel/container.d.ts +0 -1
  15. package/dist/bmodel/index.d.ts +0 -1
  16. package/dist/bmodel/normalization.cjs +86 -0
  17. package/dist/bmodel/normalization.cjs.map +1 -0
  18. package/dist/bmodel/normalization.d.ts +0 -1
  19. package/dist/bmodel/normalization.js +84 -0
  20. package/dist/bmodel/normalization.js.map +1 -0
  21. package/dist/bmodel/types.d.ts +0 -1
  22. package/dist/branding.d.ts +0 -1
  23. package/dist/common_types.d.ts +0 -1
  24. package/dist/driver_kit.d.ts +0 -1
  25. package/dist/drivers/blob.cjs +27 -0
  26. package/dist/drivers/blob.cjs.map +1 -0
  27. package/dist/drivers/blob.d.ts +0 -1
  28. package/dist/drivers/blob.js +23 -0
  29. package/dist/drivers/blob.js.map +1 -0
  30. package/dist/drivers/index.d.ts +0 -1
  31. package/dist/drivers/interfaces.d.ts +0 -1
  32. package/dist/drivers/log.cjs +9 -0
  33. package/dist/drivers/log.cjs.map +1 -0
  34. package/dist/drivers/log.d.ts +0 -1
  35. package/dist/drivers/log.js +7 -0
  36. package/dist/drivers/log.js.map +1 -0
  37. package/dist/drivers/ls.cjs +39 -0
  38. package/dist/drivers/ls.cjs.map +1 -0
  39. package/dist/drivers/ls.d.ts +0 -1
  40. package/dist/drivers/ls.js +34 -0
  41. package/dist/drivers/ls.js.map +1 -0
  42. package/dist/drivers/pframe/column_filter.d.ts +0 -1
  43. package/dist/drivers/pframe/data_info.cjs +275 -0
  44. package/dist/drivers/pframe/data_info.cjs.map +1 -0
  45. package/dist/drivers/pframe/data_info.d.ts +0 -1
  46. package/dist/drivers/pframe/data_info.js +266 -0
  47. package/dist/drivers/pframe/data_info.js.map +1 -0
  48. package/dist/drivers/pframe/data_types.cjs +91 -0
  49. package/dist/drivers/pframe/data_types.cjs.map +1 -0
  50. package/dist/drivers/pframe/data_types.d.ts +0 -1
  51. package/dist/drivers/pframe/data_types.js +83 -0
  52. package/dist/drivers/pframe/data_types.js.map +1 -0
  53. package/dist/drivers/pframe/driver.d.ts +0 -1
  54. package/dist/drivers/pframe/find_columns.d.ts +0 -1
  55. package/dist/drivers/pframe/index.d.ts +0 -1
  56. package/dist/drivers/pframe/linker_columns.cjs +218 -0
  57. package/dist/drivers/pframe/linker_columns.cjs.map +1 -0
  58. package/dist/drivers/pframe/linker_columns.d.ts +0 -1
  59. package/dist/drivers/pframe/linker_columns.js +216 -0
  60. package/dist/drivers/pframe/linker_columns.js.map +1 -0
  61. package/dist/drivers/pframe/pframe.d.ts +0 -1
  62. package/dist/drivers/pframe/spec/anchored.cjs +234 -0
  63. package/dist/drivers/pframe/spec/anchored.cjs.map +1 -0
  64. package/dist/drivers/pframe/spec/anchored.d.ts +0 -1
  65. package/dist/drivers/pframe/spec/anchored.js +231 -0
  66. package/dist/drivers/pframe/spec/anchored.js.map +1 -0
  67. package/dist/drivers/pframe/spec/filtered_column.cjs +13 -0
  68. package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -0
  69. package/dist/drivers/pframe/spec/filtered_column.d.ts +0 -1
  70. package/dist/drivers/pframe/spec/filtered_column.js +11 -0
  71. package/dist/drivers/pframe/spec/filtered_column.js.map +1 -0
  72. package/dist/drivers/pframe/spec/ids.cjs +24 -0
  73. package/dist/drivers/pframe/spec/ids.cjs.map +1 -0
  74. package/dist/drivers/pframe/spec/ids.d.ts +0 -1
  75. package/dist/drivers/pframe/spec/ids.js +21 -0
  76. package/dist/drivers/pframe/spec/ids.js.map +1 -0
  77. package/dist/drivers/pframe/spec/index.d.ts +0 -1
  78. package/dist/drivers/pframe/spec/native_id.cjs +20 -0
  79. package/dist/drivers/pframe/spec/native_id.cjs.map +1 -0
  80. package/dist/drivers/pframe/spec/native_id.d.ts +0 -1
  81. package/dist/drivers/pframe/spec/native_id.js +18 -0
  82. package/dist/drivers/pframe/spec/native_id.js.map +1 -0
  83. package/dist/drivers/pframe/spec/selectors.cjs +120 -0
  84. package/dist/drivers/pframe/spec/selectors.cjs.map +1 -0
  85. package/dist/drivers/pframe/spec/selectors.d.ts +0 -1
  86. package/dist/drivers/pframe/spec/selectors.js +116 -0
  87. package/dist/drivers/pframe/spec/selectors.js.map +1 -0
  88. package/dist/drivers/pframe/spec/spec.cjs +361 -0
  89. package/dist/drivers/pframe/spec/spec.cjs.map +1 -0
  90. package/dist/drivers/pframe/spec/spec.d.ts +0 -1
  91. package/dist/drivers/pframe/spec/spec.js +332 -0
  92. package/dist/drivers/pframe/spec/spec.js.map +1 -0
  93. package/dist/drivers/pframe/table.d.ts +0 -1
  94. package/dist/drivers/pframe/table_calculate.cjs +43 -0
  95. package/dist/drivers/pframe/table_calculate.cjs.map +1 -0
  96. package/dist/drivers/pframe/table_calculate.d.ts +0 -1
  97. package/dist/drivers/pframe/table_calculate.js +40 -0
  98. package/dist/drivers/pframe/table_calculate.js.map +1 -0
  99. package/dist/drivers/pframe/table_common.cjs +19 -0
  100. package/dist/drivers/pframe/table_common.cjs.map +1 -0
  101. package/dist/drivers/pframe/table_common.d.ts +0 -1
  102. package/dist/drivers/pframe/table_common.js +17 -0
  103. package/dist/drivers/pframe/table_common.js.map +1 -0
  104. package/dist/drivers/pframe/type_util.d.ts +0 -1
  105. package/dist/drivers/pframe/unique_values.d.ts +0 -1
  106. package/dist/drivers/upload.d.ts +0 -1
  107. package/dist/drivers/urls.cjs +14 -0
  108. package/dist/drivers/urls.cjs.map +1 -0
  109. package/dist/drivers/urls.d.ts +0 -1
  110. package/dist/drivers/urls.js +11 -0
  111. package/dist/drivers/urls.js.map +1 -0
  112. package/dist/errors.cjs +141 -0
  113. package/dist/errors.cjs.map +1 -0
  114. package/dist/errors.d.ts +0 -1
  115. package/dist/errors.js +121 -0
  116. package/dist/errors.js.map +1 -0
  117. package/dist/flags/block_flags.cjs +8 -0
  118. package/dist/flags/block_flags.cjs.map +1 -0
  119. package/dist/flags/block_flags.d.ts +0 -1
  120. package/dist/flags/block_flags.js +5 -0
  121. package/dist/flags/block_flags.js.map +1 -0
  122. package/dist/flags/flag_utils.cjs +100 -0
  123. package/dist/flags/flag_utils.cjs.map +1 -0
  124. package/dist/flags/flag_utils.d.ts +0 -1
  125. package/dist/flags/flag_utils.js +94 -0
  126. package/dist/flags/flag_utils.js.map +1 -0
  127. package/dist/flags/index.d.ts +0 -1
  128. package/dist/flags/type_utils.d.ts +0 -1
  129. package/dist/index.cjs +151 -0
  130. package/dist/index.cjs.map +1 -0
  131. package/dist/index.d.ts +10 -12
  132. package/dist/index.js +27 -1
  133. package/dist/index.js.map +1 -1
  134. package/dist/json.cjs +18 -0
  135. package/dist/json.cjs.map +1 -0
  136. package/dist/json.d.ts +0 -1
  137. package/dist/json.js +14 -0
  138. package/dist/json.js.map +1 -0
  139. package/dist/navigation.cjs +6 -0
  140. package/dist/navigation.cjs.map +1 -0
  141. package/dist/navigation.d.ts +0 -1
  142. package/dist/navigation.js +4 -0
  143. package/dist/navigation.js.map +1 -0
  144. package/dist/plid.cjs +37 -0
  145. package/dist/plid.cjs.map +1 -0
  146. package/dist/plid.d.ts +0 -1
  147. package/dist/plid.js +30 -0
  148. package/dist/plid.js.map +1 -0
  149. package/dist/pool/entry.d.ts +0 -1
  150. package/dist/pool/index.d.ts +0 -1
  151. package/dist/pool/query.cjs +49 -0
  152. package/dist/pool/query.cjs.map +1 -0
  153. package/dist/pool/query.d.ts +0 -1
  154. package/dist/pool/query.js +47 -0
  155. package/dist/pool/query.js.map +1 -0
  156. package/dist/pool/spec.cjs +67 -0
  157. package/dist/pool/spec.cjs.map +1 -0
  158. package/dist/pool/spec.d.ts +0 -1
  159. package/dist/pool/spec.js +59 -0
  160. package/dist/pool/spec.js.map +1 -0
  161. package/dist/ref.cjs +88 -0
  162. package/dist/ref.cjs.map +1 -0
  163. package/dist/ref.d.ts +0 -1
  164. package/dist/ref.js +82 -0
  165. package/dist/ref.js.map +1 -0
  166. package/dist/utag.d.ts +0 -1
  167. package/dist/util.cjs +8 -0
  168. package/dist/util.cjs.map +1 -0
  169. package/dist/util.d.ts +0 -1
  170. package/dist/util.js +6 -0
  171. package/dist/util.js.map +1 -0
  172. package/dist/value_or_error.cjs +8 -0
  173. package/dist/value_or_error.cjs.map +1 -0
  174. package/dist/value_or_error.d.ts +0 -1
  175. package/dist/value_or_error.js +6 -0
  176. package/dist/value_or_error.js.map +1 -0
  177. package/package.json +13 -11
  178. package/src/index.ts +10 -11
  179. package/dist/author_marker.d.ts.map +0 -1
  180. package/dist/base32_encode.d.ts.map +0 -1
  181. package/dist/block_state.d.ts.map +0 -1
  182. package/dist/bmodel/block_config.d.ts.map +0 -1
  183. package/dist/bmodel/code.d.ts.map +0 -1
  184. package/dist/bmodel/container.d.ts.map +0 -1
  185. package/dist/bmodel/index.d.ts.map +0 -1
  186. package/dist/bmodel/normalization.d.ts.map +0 -1
  187. package/dist/bmodel/types.d.ts.map +0 -1
  188. package/dist/branding.d.ts.map +0 -1
  189. package/dist/common_types.d.ts.map +0 -1
  190. package/dist/driver_kit.d.ts.map +0 -1
  191. package/dist/drivers/blob.d.ts.map +0 -1
  192. package/dist/drivers/index.d.ts.map +0 -1
  193. package/dist/drivers/interfaces.d.ts.map +0 -1
  194. package/dist/drivers/log.d.ts.map +0 -1
  195. package/dist/drivers/ls.d.ts.map +0 -1
  196. package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
  197. package/dist/drivers/pframe/data_info.d.ts.map +0 -1
  198. package/dist/drivers/pframe/data_types.d.ts.map +0 -1
  199. package/dist/drivers/pframe/driver.d.ts.map +0 -1
  200. package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
  201. package/dist/drivers/pframe/index.d.ts.map +0 -1
  202. package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
  203. package/dist/drivers/pframe/pframe.d.ts.map +0 -1
  204. package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
  205. package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
  206. package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
  207. package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
  208. package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
  209. package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
  210. package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
  211. package/dist/drivers/pframe/table.d.ts.map +0 -1
  212. package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
  213. package/dist/drivers/pframe/table_common.d.ts.map +0 -1
  214. package/dist/drivers/pframe/type_util.d.ts.map +0 -1
  215. package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
  216. package/dist/drivers/upload.d.ts.map +0 -1
  217. package/dist/drivers/urls.d.ts.map +0 -1
  218. package/dist/errors.d.ts.map +0 -1
  219. package/dist/flags/block_flags.d.ts.map +0 -1
  220. package/dist/flags/flag_utils.d.ts.map +0 -1
  221. package/dist/flags/index.d.ts.map +0 -1
  222. package/dist/flags/type_utils.d.ts.map +0 -1
  223. package/dist/index.d.ts.map +0 -1
  224. package/dist/index.mjs +0 -1587
  225. package/dist/index.mjs.map +0 -1
  226. package/dist/json.d.ts.map +0 -1
  227. package/dist/navigation.d.ts.map +0 -1
  228. package/dist/plid.d.ts.map +0 -1
  229. package/dist/pool/entry.d.ts.map +0 -1
  230. package/dist/pool/index.d.ts.map +0 -1
  231. package/dist/pool/query.d.ts.map +0 -1
  232. package/dist/pool/spec.d.ts.map +0 -1
  233. package/dist/ref.d.ts.map +0 -1
  234. package/dist/utag.d.ts.map +0 -1
  235. package/dist/util.d.ts.map +0 -1
  236. package/dist/value_or_error.d.ts.map +0 -1
package/dist/index.mjs DELETED
@@ -1,1587 +0,0 @@
1
- var te = Object.defineProperty;
2
- var re = (e, n, t) => n in e ? te(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var b = (e, n, t) => re(e, typeof n != "symbol" ? n + "" : n, t);
4
- import { z as l } from "zod";
5
- import F from "canonicalize";
6
- function Me(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 x(e) {
15
- if (e !== void 0)
16
- return typeof e == "string" ? { __renderLambda: !0, handle: e, retentive: !1 } : e;
17
- }
18
- function Be(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: s,
27
- featureFlags: a,
28
- sections: u,
29
- title: c,
30
- enrichmentTargets: d
31
- } = e.v3, { code: f } = e;
32
- return {
33
- initialArgs: n,
34
- initialUiState: t,
35
- inputsValid: r,
36
- outputs: o,
37
- renderingMode: i,
38
- sdkVersion: s,
39
- featureFlags: a,
40
- sections: u,
41
- title: c,
42
- code: f,
43
- enrichmentTargets: d
44
- };
45
- } else if (e.inputsValid !== void 0) {
46
- const { sdkVersion: n, renderingMode: t, outputs: r, inputsValid: o, sections: i, initialArgs: s, code: a } = e, u = Object.keys(e);
47
- if (n === void 0 || t === void 0 || r === void 0 || o === void 0 || i === void 0 || s === 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: s,
55
- outputs: Object.fromEntries(
56
- Object.entries(r).map(([c, d]) => [c, x(d)])
57
- ),
58
- inputsValid: x(o),
59
- sections: x(i),
60
- initialUiState: void 0,
61
- code: a
62
- };
63
- } else if (e.renderingMode !== void 0) {
64
- const { sdkVersion: n, canRun: t, renderingMode: r, outputs: o, sections: i, initialArgs: s, code: a } = e, u = Object.keys(e);
65
- if (r === void 0 || o === void 0 || t === void 0 || i === void 0 || s === 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: s,
73
- outputs: Object.fromEntries(
74
- Object.entries(o).map(([c, d]) => [c, x(d)])
75
- ),
76
- inputsValid: x(t),
77
- sections: x(i),
78
- initialUiState: void 0,
79
- code: a
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
- function Ue(e) {
89
- return new URL(e).protocol == "plblob+folder:";
90
- }
91
- function qe(e) {
92
- return new URL(e).protocol == "block-ui:";
93
- }
94
- const We = l.object({
95
- /** Included left border. */
96
- from: l.number(),
97
- /** Excluded right border. */
98
- to: l.number()
99
- });
100
- function ze(e, n) {
101
- if (!(e == null || n == null))
102
- return { from: e, to: n };
103
- }
104
- function He(e, n) {
105
- if (e.from < 0 || e.to < 0 || e.from >= e.to)
106
- throw new Error(`${n}: invalid bytes range: ${e}`);
107
- }
108
- function _e(e) {
109
- return e !== void 0 && e.startsWith("log+live://log/");
110
- }
111
- function S(e) {
112
- throw new Error("Unexpected object: " + e);
113
- }
114
- const K = "upload://upload/", V = "index://index/";
115
- function oe(e) {
116
- return e.startsWith(K);
117
- }
118
- function ie(e) {
119
- return e.startsWith(V);
120
- }
121
- function ae(e) {
122
- if (ie(e)) {
123
- const n = e.slice(V.length);
124
- return JSON.parse(decodeURIComponent(n)).path;
125
- } else if (oe(e)) {
126
- const n = e.slice(K.length);
127
- return JSON.parse(decodeURIComponent(n)).localPath;
128
- }
129
- S(e);
130
- }
131
- function se(e) {
132
- return e.replace(/^.*[\\/]/, "");
133
- }
134
- function Ge(e) {
135
- return se(ae(e));
136
- }
137
- function Qe(e) {
138
- if (!e || typeof e != "object")
139
- return !1;
140
- const n = e;
141
- if (!("type" in n))
142
- return !1;
143
- switch (n.type) {
144
- case "Json":
145
- return typeof n.keyLength == "number" && n.data !== void 0 && typeof n.data == "object";
146
- case "JsonPartitioned":
147
- case "BinaryPartitioned":
148
- case "ParquetPartitioned":
149
- return typeof n.partitionKeyLength == "number" && n.parts !== void 0 && typeof n.parts == "object";
150
- default:
151
- return !1;
152
- }
153
- }
154
- function Xe(e, n) {
155
- if (e !== void 0)
156
- switch (e.type) {
157
- case "Json":
158
- return e;
159
- case "JsonPartitioned": {
160
- const t = {};
161
- for (const [r, o] of Object.entries(e.parts))
162
- t[r] = n(o);
163
- return {
164
- ...e,
165
- parts: t
166
- };
167
- }
168
- case "BinaryPartitioned": {
169
- const t = {};
170
- for (const [r, o] of Object.entries(e.parts))
171
- t[r] = {
172
- index: n(o.index),
173
- values: n(o.values)
174
- };
175
- return {
176
- ...e,
177
- parts: t
178
- };
179
- }
180
- case "ParquetPartitioned": {
181
- const t = {};
182
- for (const [r, o] of Object.entries(e.parts))
183
- t[r] = n(o);
184
- return {
185
- ...e,
186
- parts: t
187
- };
188
- }
189
- }
190
- }
191
- function Ye(e, n) {
192
- switch (e.type) {
193
- case "Json":
194
- break;
195
- case "JsonPartitioned": {
196
- Object.values(e.parts).forEach(n);
197
- break;
198
- }
199
- case "BinaryPartitioned": {
200
- Object.values(e.parts).forEach((t) => {
201
- n(t.index), n(t.values);
202
- });
203
- break;
204
- }
205
- case "ParquetPartitioned": {
206
- Object.values(e.parts).forEach(n);
207
- break;
208
- }
209
- }
210
- }
211
- function ue(e) {
212
- if (!e || typeof e != "object")
213
- return !1;
214
- const n = e;
215
- if (!("type" in n))
216
- return !1;
217
- switch (n.type) {
218
- case "Json":
219
- return typeof n.keyLength == "number" && Array.isArray(n.data);
220
- case "JsonPartitioned":
221
- case "BinaryPartitioned":
222
- case "ParquetPartitioned":
223
- return typeof n.partitionKeyLength == "number" && Array.isArray(n.parts);
224
- default:
225
- return !1;
226
- }
227
- }
228
- function Ze(e) {
229
- if (!ue(e)) return !1;
230
- switch (e.type) {
231
- case "JsonPartitioned":
232
- case "BinaryPartitioned":
233
- case "ParquetPartitioned":
234
- return !0;
235
- default:
236
- return !1;
237
- }
238
- }
239
- function en(e) {
240
- switch (e.type) {
241
- case "Json":
242
- return {
243
- type: "Json",
244
- keyLength: e.keyLength,
245
- data: Object.entries(e.data).map(([n, t]) => ({ key: JSON.parse(n), value: t }))
246
- };
247
- case "JsonPartitioned":
248
- return {
249
- type: "JsonPartitioned",
250
- partitionKeyLength: e.partitionKeyLength,
251
- parts: Object.entries(e.parts).map(([n, t]) => ({ key: JSON.parse(n), value: t }))
252
- };
253
- case "BinaryPartitioned":
254
- return {
255
- type: "BinaryPartitioned",
256
- partitionKeyLength: e.partitionKeyLength,
257
- parts: Object.entries(e.parts).map(([n, t]) => ({ key: JSON.parse(n), value: t }))
258
- };
259
- case "ParquetPartitioned":
260
- return {
261
- type: "ParquetPartitioned",
262
- partitionKeyLength: e.partitionKeyLength,
263
- parts: Object.entries(e.parts).map(([n, t]) => ({ key: JSON.parse(n), value: t }))
264
- };
265
- default:
266
- S(e);
267
- }
268
- }
269
- function nn(e) {
270
- switch (e.type) {
271
- case "Json":
272
- return {
273
- type: "Json",
274
- keyLength: e.keyLength,
275
- data: Object.fromEntries(
276
- e.data.map(({ key: n, value: t }) => [JSON.stringify(n), t])
277
- )
278
- };
279
- case "JsonPartitioned":
280
- return {
281
- type: "JsonPartitioned",
282
- partitionKeyLength: e.partitionKeyLength,
283
- parts: Object.fromEntries(
284
- e.parts.map(({ key: n, value: t }) => [JSON.stringify(n), t])
285
- )
286
- };
287
- case "BinaryPartitioned":
288
- return {
289
- type: "BinaryPartitioned",
290
- partitionKeyLength: e.partitionKeyLength,
291
- parts: Object.fromEntries(
292
- e.parts.map(({ key: n, value: t }) => [JSON.stringify(n), t])
293
- )
294
- };
295
- case "ParquetPartitioned":
296
- return {
297
- type: "ParquetPartitioned",
298
- partitionKeyLength: e.partitionKeyLength,
299
- parts: Object.fromEntries(
300
- e.parts.map(({ key: n, value: t }) => [JSON.stringify(n), t])
301
- )
302
- };
303
- default:
304
- S(e);
305
- }
306
- }
307
- function tn(e, n) {
308
- if (e !== void 0)
309
- switch (e.type) {
310
- case "Json":
311
- return e;
312
- case "JsonPartitioned":
313
- return {
314
- ...e,
315
- parts: e.parts.map((t) => ({
316
- key: t.key,
317
- value: n(t.value)
318
- }))
319
- };
320
- case "BinaryPartitioned":
321
- return {
322
- ...e,
323
- parts: e.parts.map((t) => ({
324
- key: t.key,
325
- value: {
326
- index: n(t.value.index),
327
- values: n(t.value.values)
328
- }
329
- }))
330
- };
331
- case "ParquetPartitioned":
332
- return {
333
- ...e,
334
- parts: e.parts.map((t) => ({
335
- key: t.key,
336
- value: n(t.value)
337
- }))
338
- };
339
- }
340
- }
341
- class rn extends Error {
342
- constructor() {
343
- super(...arguments);
344
- b(this, "name", "AbortError");
345
- }
346
- }
347
- class on extends Error {
348
- constructor() {
349
- super(...arguments);
350
- b(this, "name", "UiError");
351
- }
352
- }
353
- function an(e) {
354
- return e instanceof Error && e.name === "AbortError";
355
- }
356
- function ce(e) {
357
- return e instanceof Error ? e.name === "AbortError" || ce(e.cause) : !1;
358
- }
359
- function sn(e) {
360
- return e instanceof Error && e.name === "AggregateError";
361
- }
362
- class le extends Error {
363
- constructor() {
364
- super(...arguments);
365
- b(this, "name", "PFrameError");
366
- }
367
- }
368
- function un(e) {
369
- return e instanceof Error && e.name === "PFrameError";
370
- }
371
- class cn extends le {
372
- constructor() {
373
- super(...arguments);
374
- b(this, "name", "PFrameError.Driver");
375
- }
376
- }
377
- function ln(e) {
378
- return e instanceof Error && e.name === "PFrameError.Driver";
379
- }
380
- function de(e) {
381
- if (typeof e == "string")
382
- return `String value was thrown: ${e}`;
383
- if (e && typeof e == "object")
384
- try {
385
- return `Plain object was thrown: ${JSON.stringify(e)}`;
386
- } catch (n) {
387
- return `Non-serializable object was thrown (JSON.stringify failed: ${n instanceof Error ? n.message : String(n)}): ${String(e)}`;
388
- }
389
- return `Non-Error value (${typeof e}) was thrown: ${e}`;
390
- }
391
- function C(e) {
392
- return e instanceof Error ? e : new Error(de(e));
393
- }
394
- function J(e) {
395
- const n = e.cause ? J(e.cause) : void 0, t = new Error(e.message, n !== void 0 ? { cause: n } : void 0);
396
- return t.name = e.name || "Error", t.stack = e.stack, t;
397
- }
398
- function M(e) {
399
- const n = C(e), t = n.cause ? M(n.cause) : void 0;
400
- return {
401
- name: n.name,
402
- message: n.message,
403
- stack: n.stack,
404
- ...n.cause !== void 0 && { cause: t }
405
- };
406
- }
407
- function dn(e) {
408
- if (e.error)
409
- throw e.error instanceof Error ? e.error : J(e.error);
410
- return e.value;
411
- }
412
- function B(e) {
413
- return e.error ? { error: M(e.error) } : { value: e.value };
414
- }
415
- function fn(e) {
416
- return e.error ? { error: J(e.error) } : { value: e.value };
417
- }
418
- function fe(e) {
419
- try {
420
- return { value: e() };
421
- } catch (n) {
422
- return { error: C(n) };
423
- }
424
- }
425
- async function pe(e) {
426
- try {
427
- return { value: await e() };
428
- } catch (n) {
429
- return { error: C(n) };
430
- }
431
- }
432
- function pn(e) {
433
- const n = fe(e);
434
- return B(n);
435
- }
436
- async function mn(e) {
437
- const n = await pe(e);
438
- return B(n);
439
- }
440
- function hn(e) {
441
- return JSON.stringify(e);
442
- }
443
- function m(e) {
444
- return F(e);
445
- }
446
- function me(e) {
447
- return JSON.parse(e);
448
- }
449
- const g = {
450
- Int: "Int",
451
- Long: "Long",
452
- Float: "Float",
453
- Double: "Double",
454
- String: "String",
455
- Bytes: "Bytes"
456
- };
457
- function I(e, n) {
458
- return e == null ? void 0 : e[n];
459
- }
460
- function j(e, n, t, r = "readMetadataJsonOrThrow") {
461
- const o = I(e, t);
462
- if (o === void 0) return;
463
- const i = n[t];
464
- try {
465
- const s = JSON.parse(o);
466
- return i.parse(s);
467
- } catch (s) {
468
- throw new Error(
469
- `${r} failed, key: ${String(t)}, value: ${o}, error: ${C(s)}`
470
- );
471
- }
472
- }
473
- function U(e, n, t) {
474
- try {
475
- return j(e, n, t);
476
- } catch {
477
- return;
478
- }
479
- }
480
- const yn = {
481
- Alphabet: "pl7.app/alphabet",
482
- BlockId: "pl7.app/blockId"
483
- }, q = {};
484
- function gn(e, n) {
485
- return I(e == null ? void 0 : e.domain, n);
486
- }
487
- function bn(e, n) {
488
- return j(e == null ? void 0 : e.domain, q, n, "readDomainJsonOrThrow");
489
- }
490
- function wn(e, n) {
491
- return U(e == null ? void 0 : e.domain, q, n);
492
- }
493
- const y = {
494
- Alphabet: "pl7.app/alphabet",
495
- DiscreteValues: "pl7.app/discreteValues",
496
- Format: "pl7.app/format",
497
- Graph: {
498
- IsVirtual: "pl7.app/graph/isVirtual"
499
- },
500
- HideDataFromUi: "pl7.app/hideDataFromUi",
501
- IsLinkerColumn: "pl7.app/isLinkerColumn",
502
- Label: "pl7.app/label",
503
- Max: "pl7.app/max",
504
- Min: "pl7.app/min",
505
- Parents: "pl7.app/parents",
506
- Sequence: {
507
- Annotation: {
508
- Mapping: "pl7.app/sequence/annotation/mapping"
509
- },
510
- IsAnnotation: "pl7.app/sequence/isAnnotation"
511
- },
512
- Table: {
513
- FontFamily: "pl7.app/table/fontFamily",
514
- OrderPriority: "pl7.app/table/orderPriority",
515
- Visibility: "pl7.app/table/visibility"
516
- },
517
- Trace: "pl7.app/trace"
518
- }, he = l.object({
519
- type: l.nativeEnum(g),
520
- name: l.string(),
521
- domain: l.record(l.string(), l.string()).optional(),
522
- annotations: l.record(l.string(), l.string()).optional(),
523
- parentAxes: l.array(l.number()).optional()
524
- }).passthrough(), W = {
525
- [y.DiscreteValues]: l.array(l.string()).or(l.array(l.number())),
526
- [y.Graph.IsVirtual]: l.boolean(),
527
- [y.HideDataFromUi]: l.boolean(),
528
- [y.IsLinkerColumn]: l.boolean(),
529
- [y.Max]: l.number(),
530
- [y.Min]: l.number(),
531
- [y.Parents]: l.array(he),
532
- [y.Sequence.Annotation.Mapping]: l.record(l.string(), l.string()),
533
- [y.Sequence.IsAnnotation]: l.boolean(),
534
- [y.Table.OrderPriority]: l.number(),
535
- [y.Trace]: l.record(l.string(), l.unknown())
536
- };
537
- function An(e, n) {
538
- return I(e == null ? void 0 : e.annotations, n);
539
- }
540
- function vn(e, n) {
541
- return j(e == null ? void 0 : e.annotations, W, n, "readAnnotationJsonOrThrow");
542
- }
543
- function z(e, n) {
544
- return U(e == null ? void 0 : e.annotations, W, n);
545
- }
546
- function O(e) {
547
- return { axis: e, children: [] };
548
- }
549
- function k(e) {
550
- const n = O(e);
551
- let t = [n];
552
- for (; t.length; ) {
553
- const r = [];
554
- for (const o of t)
555
- o.children = o.axis.parentAxesSpec.map(O), r.push(...o.children);
556
- t = r;
557
- }
558
- return n;
559
- }
560
- function xn(e) {
561
- const n = /* @__PURE__ */ new Set([m(p(e.axis))]);
562
- let t = [e];
563
- for (; t.length; ) {
564
- const r = [];
565
- for (const o of t)
566
- for (const i of o.children)
567
- n.add(m(p(i.axis))), r.push(i);
568
- t = r;
569
- }
570
- return n;
571
- }
572
- function P(e) {
573
- const n = [e.axis];
574
- let t = [e];
575
- for (; t.length; ) {
576
- const r = [];
577
- for (const o of t)
578
- for (const i of o.children)
579
- n.push(i.axis), r.push(i);
580
- t = r;
581
- }
582
- return n;
583
- }
584
- function D(e) {
585
- return m(P(k(e)).map(p));
586
- }
587
- function ye(e, n) {
588
- if (e.name !== n.name)
589
- return e.name < n.name ? 1 : -1;
590
- if (e.type !== n.type)
591
- return e.type < n.type ? 1 : -1;
592
- const t = m(e.domain ?? {}), r = m(n.domain ?? {});
593
- if (t !== r)
594
- return t < r ? 1 : -1;
595
- const o = D(e), i = D(n);
596
- if (o !== i)
597
- return o < i ? 1 : -1;
598
- const s = m(e.annotations ?? {}), a = m(n.annotations ?? {});
599
- return s !== a ? s < a ? 1 : -1 : 0;
600
- }
601
- function ge(e) {
602
- const n = z(e, y.Parents);
603
- return n === void 0 ? [] : n;
604
- }
605
- function H(e) {
606
- e.parentAxesSpec.forEach(H), e.parentAxesSpec.sort(ye);
607
- }
608
- function be(e) {
609
- let t = [O(e)];
610
- const r = new Set(m(p(e)));
611
- for (; t.length; ) {
612
- const o = [], i = /* @__PURE__ */ new Set();
613
- for (const s of t) {
614
- s.children = s.axis.parentAxesSpec.map(O);
615
- for (const a of s.children) {
616
- const u = m(p(a.axis));
617
- if (!i.has(u)) {
618
- if (o.push(a), i.add(u), r.has(u))
619
- return !0;
620
- r.add(u);
621
- }
622
- }
623
- }
624
- t = o;
625
- }
626
- return !1;
627
- }
628
- function _(e) {
629
- if (!e.length)
630
- return [];
631
- const n = e.map((t) => {
632
- const { parentAxes: r, ...o } = t;
633
- return { ...o, annotations: { ...o.annotations }, parentAxesSpec: [] };
634
- });
635
- return e.forEach((t, r) => {
636
- var i;
637
- const o = n[r];
638
- t.parentAxes ? o.parentAxesSpec = t.parentAxes.map((s) => n[s]) : (o.parentAxesSpec = _(ge(t)), (i = o.annotations) == null || delete i[y.Parents]);
639
- }), n.some(be) ? n.forEach((t) => {
640
- t.parentAxesSpec = [];
641
- }) : n.forEach((t) => {
642
- H(t);
643
- }), n;
644
- }
645
- function kn(e) {
646
- const n = e.map((t) => m(p(t)));
647
- return e.map((t) => {
648
- const o = t.parentAxesSpec.map((a) => m(p(a))).map((a) => n.indexOf(a)), { parentAxesSpec: i, ...s } = t;
649
- return o.length ? { ...s, parentAxes: o } : s;
650
- });
651
- }
652
- const Pn = {
653
- Label: "pl7.app/label",
654
- Table: {
655
- RowSelection: "pl7.app/table/row-selection"
656
- }
657
- };
658
- function Sn(e) {
659
- return {
660
- kind: e.kind,
661
- valueType: e.valueType,
662
- name: e.name,
663
- domain: e.domain,
664
- parentAxes: e.parentAxes,
665
- axesId: G(e.axesSpec)
666
- };
667
- }
668
- function En(e) {
669
- return {
670
- columnId: e.id,
671
- spec: e.spec
672
- };
673
- }
674
- function p(e) {
675
- const { type: n, name: t, domain: r } = e, o = { type: n, name: t };
676
- return r && Object.entries(r).length > 0 && Object.assign(o, { domain: r }), o;
677
- }
678
- function G(e) {
679
- return e.map(p);
680
- }
681
- function On(e) {
682
- return m(p(e));
683
- }
684
- function we(e, n) {
685
- if (e === void 0) return n === void 0;
686
- if (n === void 0) return !0;
687
- for (const t in n)
688
- if (e[t] !== n[t]) return !1;
689
- return !0;
690
- }
691
- function Ae(e, n) {
692
- return e.name === n.name && we(e.domain, n.domain);
693
- }
694
- function Q(e, n) {
695
- const t = Math.floor(n / 8), r = 1 << 7 - n % 8;
696
- return (e[t] & r) > 0;
697
- }
698
- function ve(e, n) {
699
- return Q(e.absent, n);
700
- }
701
- function xe(e, n) {
702
- if (e.isNA) return Q(e.isNA, n);
703
- const t = e.type, r = e.data[n];
704
- switch (t) {
705
- case g.Int:
706
- return r === -2147483648;
707
- case g.Long:
708
- return r === -9007199254740991n;
709
- case g.Float:
710
- return Number.isNaN(r);
711
- case g.Double:
712
- return Number.isNaN(r);
713
- case g.String:
714
- return r === null;
715
- case g.Bytes:
716
- return r === null;
717
- default:
718
- throw Error(`unsupported data type: ${t}`);
719
- }
720
- }
721
- const ke = { type: "absent" };
722
- function Fn(e) {
723
- return typeof e == "object" && e !== null && "type" in e && e.type === "absent";
724
- }
725
- const X = null;
726
- function Pe(e) {
727
- return e === X;
728
- }
729
- function Cn(e, n) {
730
- return !(n ? n(e) : Pe(e));
731
- }
732
- function Y(e, n, t) {
733
- const r = e.type;
734
- if (r === g.Bytes)
735
- throw Error("Bytes not yet supported");
736
- if (t && "dataType" in t && t.dataType !== void 0 && t.dataType !== r)
737
- throw Error(`expected column of type ${t.dataType}, got ${r}`);
738
- if (ve(e, n))
739
- return (t == null ? void 0 : t.absent) !== void 0 ? t.absent : ke;
740
- if (xe(e, n))
741
- return (t == null ? void 0 : t.na) !== void 0 ? t.na : X;
742
- const o = e.data[n];
743
- switch (r) {
744
- case g.Int:
745
- return o;
746
- case g.Long:
747
- return Number(o);
748
- case g.Float:
749
- return o;
750
- case g.Double:
751
- return o;
752
- case g.String:
753
- return o;
754
- }
755
- }
756
- function Ln(e, n, t) {
757
- return Y(e, n, t);
758
- }
759
- function Jn(e, n, t) {
760
- return Y(e, n, t);
761
- }
762
- function In(e, n) {
763
- return { ...e, src: E(e.src, n) };
764
- }
765
- function E(e, n) {
766
- switch (e.type) {
767
- case "column":
768
- return {
769
- type: "column",
770
- column: n(e.column)
771
- };
772
- case "slicedColumn":
773
- return {
774
- type: "slicedColumn",
775
- column: n(e.column),
776
- newId: e.newId,
777
- axisFilters: e.axisFilters
778
- };
779
- case "inlineColumn":
780
- return e;
781
- case "inner":
782
- case "full":
783
- return {
784
- type: e.type,
785
- entries: e.entries.map((t) => E(t, n))
786
- };
787
- case "outer":
788
- return {
789
- type: "outer",
790
- primary: E(e.primary, n),
791
- secondary: e.secondary.map((t) => E(t, n))
792
- };
793
- default:
794
- S(e);
795
- }
796
- }
797
- function jn(e) {
798
- switch (e.type) {
799
- case "axis":
800
- return {
801
- type: "axis",
802
- id: e.id
803
- };
804
- case "column":
805
- return {
806
- type: "column",
807
- id: e.id
808
- };
809
- }
810
- }
811
- function Se(e) {
812
- return F(e);
813
- }
814
- function Dn(e) {
815
- return JSON.parse(e);
816
- }
817
- function N(e) {
818
- return F(p(e));
819
- }
820
- function R(e, n) {
821
- return JSON.stringify([e, n]);
822
- }
823
- class Nn {
824
- /**
825
- * Creates a new anchor context from a set of anchor column specifications
826
- * @param anchors Record of anchor column specifications indexed by anchor ID
827
- */
828
- constructor(n) {
829
- b(this, "domains", /* @__PURE__ */ new Map());
830
- b(this, "axes", /* @__PURE__ */ new Map());
831
- /**
832
- * Domain packs are used to group domain keys that can be anchored to the same anchor
833
- * This is used to optimize the lookup of domain anchors
834
- */
835
- b(this, "domainPacks", []);
836
- /**
837
- * Maps domain packs to anchors
838
- */
839
- b(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
840
- this.anchors = n;
841
- const t = Object.entries(n);
842
- t.sort((r, o) => r[0].localeCompare(o[0]));
843
- for (const [r, o] of t) {
844
- for (let i = 0; i < o.axesSpec.length; i++) {
845
- const s = o.axesSpec[i], a = N(s);
846
- this.axes.set(a, { anchor: r, idx: i });
847
- }
848
- if (o.domain !== void 0) {
849
- const i = Object.entries(o.domain);
850
- i.sort((s, a) => s[0].localeCompare(a[0])), this.domainPackToAnchor.set(JSON.stringify(i), r), this.domainPacks.push(i.map(([s]) => s));
851
- for (const [s, a] of i) {
852
- const u = R(s, a);
853
- this.domains.set(u, r);
854
- }
855
- }
856
- }
857
- }
858
- /**
859
- * Implementation of derive method
860
- */
861
- derive(n, t) {
862
- const r = {
863
- name: n.name,
864
- axes: []
865
- };
866
- let o;
867
- if (n.domain !== void 0)
868
- e:
869
- for (const s of this.domainPacks) {
870
- const a = [];
871
- for (const c of s) {
872
- const d = n.domain[c];
873
- if (d !== void 0)
874
- a.push([c, d]);
875
- else
876
- break e;
877
- }
878
- const u = this.domainPackToAnchor.get(JSON.stringify(a));
879
- if (u !== void 0) {
880
- r.domainAnchor = u, o = new Set(s);
881
- break;
882
- }
883
- }
884
- for (const [s, a] of Object.entries(n.domain ?? {})) {
885
- if (o !== void 0 && o.has(s))
886
- continue;
887
- const u = R(s, a), c = this.domains.get(u);
888
- r.domain ?? (r.domain = {}), r.domain[s] = c ? { anchor: c } : a;
889
- }
890
- if (r.axes = n.axesSpec.map((s) => {
891
- const a = N(s), u = this.axes.get(a);
892
- return u === void 0 ? p(s) : u;
893
- }), !t || t.length === 0)
894
- return r;
895
- const i = [];
896
- for (const s of t) {
897
- const [a, u] = s;
898
- if (typeof a == "number") {
899
- if (a < 0 || a >= n.axesSpec.length)
900
- throw new Error(`Axis index ${a} is out of bounds (0-${n.axesSpec.length - 1})`);
901
- i.push([a, u]);
902
- } else {
903
- const c = n.axesSpec.findIndex((d) => d.name === a);
904
- if (c === -1)
905
- throw new Error(`Axis with name "${a}" not found in the column specification`);
906
- i.push([c, u]);
907
- }
908
- }
909
- return i.sort((s, a) => s[0] - a[0]), {
910
- source: r,
911
- axisFilters: i
912
- };
913
- }
914
- /**
915
- * Derives a canonicalized string representation of an anchored column identifier, can be used as a unique identifier for the column
916
- * @param spec Column specification to anchor
917
- * @param axisFilters Optional axis filters to apply to the column
918
- * @returns A canonicalized string representation of the anchored column identifier
919
- */
920
- deriveS(n, t) {
921
- return Se(this.derive(n, t));
922
- }
923
- }
924
- function Rn(e, n, t) {
925
- const r = { ...n }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
926
- if (r.domainAnchor !== void 0) {
927
- const i = e[r.domainAnchor];
928
- if (!i)
929
- throw new Error(`Anchor "${r.domainAnchor}" not found`);
930
- const s = i.domain || {};
931
- r.domain = { ...s, ...r.domain }, delete r.domainAnchor;
932
- }
933
- if (r.domain) {
934
- const i = {};
935
- for (const [s, a] of Object.entries(r.domain))
936
- if (typeof a == "string")
937
- i[s] = a;
938
- else {
939
- const u = e[a.anchor];
940
- if (!u)
941
- throw new Error(`Anchor "${a.anchor}" not found for domain key "${s}"`);
942
- if (!u.domain || u.domain[s] === void 0) {
943
- if (!o)
944
- throw new Error(`Domain key "${s}" not found in anchor "${a.anchor}"`);
945
- continue;
946
- }
947
- i[s] = u.domain[s];
948
- }
949
- r.domain = i;
950
- }
951
- return r.axes && (r.axes = r.axes.map((i) => Ee(e, i))), r;
952
- }
953
- function Ee(e, n) {
954
- if (!Oe(n))
955
- return n;
956
- const t = n.anchor, r = e[t];
957
- if (!r)
958
- throw new Error(`Anchor "${t}" not found for axis reference`);
959
- if ("idx" in n) {
960
- if (n.idx < 0 || n.idx >= r.axesSpec.length)
961
- throw new Error(`Axis index ${n.idx} out of bounds for anchor "${t}"`);
962
- return r.axesSpec[n.idx];
963
- } else if ("name" in n) {
964
- const o = r.axesSpec.filter((i) => i.name === n.name);
965
- if (o.length > 1)
966
- throw new Error(`Multiple axes with name "${n.name}" found in anchor "${t}"`);
967
- if (o.length === 0)
968
- throw new Error(`Axis with name "${n.name}" not found in anchor "${t}"`);
969
- return o[0];
970
- } else if ("id" in n) {
971
- const o = r.axesSpec.filter((i) => Ae(n.id, p(i)));
972
- if (o.length > 1)
973
- throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);
974
- if (o.length === 0)
975
- throw new Error(`No matching axis found for matcher in anchor "${t}"`);
976
- return o[0];
977
- }
978
- throw new Error("Unsupported axis reference type");
979
- }
980
- function Oe(e) {
981
- return typeof e == "object" && "anchor" in e;
982
- }
983
- function Tn(e) {
984
- return typeof e == "object" && e !== null && "source" in e && "axisFilters" in e;
985
- }
986
- function w(e) {
987
- return e.kind === "PColumn";
988
- }
989
- function Fe(e) {
990
- return w(e.spec);
991
- }
992
- function $n(e) {
993
- return w(e.obj);
994
- }
995
- function Kn(e) {
996
- return w(e.obj.spec);
997
- }
998
- function Vn(e) {
999
- if (!Fe(e)) throw new Error(`not a PColumn (kind = ${e.spec.kind})`);
1000
- return e;
1001
- }
1002
- function Mn(e, n) {
1003
- return e === void 0 ? void 0 : {
1004
- ...e,
1005
- data: n(e.data)
1006
- };
1007
- }
1008
- function Bn(e) {
1009
- const n = /* @__PURE__ */ new Map(), t = (r) => {
1010
- switch (r.type) {
1011
- case "column":
1012
- n.set(r.column.id, r.column);
1013
- return;
1014
- case "slicedColumn":
1015
- n.set(r.column.id, r.column);
1016
- return;
1017
- case "inlineColumn":
1018
- return;
1019
- case "full":
1020
- case "inner":
1021
- for (const o of r.entries) t(o);
1022
- return;
1023
- case "outer":
1024
- t(r.primary);
1025
- for (const o of r.secondary) t(o);
1026
- return;
1027
- default:
1028
- S(r);
1029
- }
1030
- };
1031
- return t(e), [...n.values()];
1032
- }
1033
- function Ce(e) {
1034
- throw new Error("Unexpected object: " + e);
1035
- }
1036
- function L(e, n) {
1037
- switch (e.type) {
1038
- case "and":
1039
- for (const t of e.operands)
1040
- if (!L(t, n)) return !1;
1041
- return !0;
1042
- case "or":
1043
- for (const t of e.operands)
1044
- if (L(t, n)) return !0;
1045
- return !1;
1046
- case "not":
1047
- return !L(e.operand, n);
1048
- case "name":
1049
- return w(n) && n.name === e.name;
1050
- case "name_pattern":
1051
- return w(n) && !!n.name.match(e.pattern);
1052
- case "annotation":
1053
- return w(n) && n.annotations !== void 0 && n.annotations[e.annotation] === e.value;
1054
- case "annotation_pattern":
1055
- return w(n) && n.annotations !== void 0 && n.annotations[e.annotation] !== void 0 && !!n.annotations[e.annotation].match(e.pattern);
1056
- case "has_axes":
1057
- return w(n) && e.axes.every(
1058
- (t) => n.axesSpec.some(
1059
- (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(
1060
- ([o, i]) => r.domain[o] === i
1061
- ))
1062
- )
1063
- );
1064
- default:
1065
- Ce(e);
1066
- }
1067
- }
1068
- function T(e, n) {
1069
- if (e.name !== void 0 && e.name !== n.name)
1070
- return !1;
1071
- if (e.type !== void 0) {
1072
- if (Array.isArray(e.type)) {
1073
- if (!e.type.includes(n.type))
1074
- return !1;
1075
- } else if (e.type !== n.type)
1076
- return !1;
1077
- }
1078
- if (e.domain !== void 0) {
1079
- const t = n.domain || {};
1080
- for (const [r, o] of Object.entries(e.domain))
1081
- if (t[r] !== o)
1082
- return !1;
1083
- }
1084
- return !0;
1085
- }
1086
- function $(e, n) {
1087
- if (n.name !== void 0 && e.name !== n.name || n.namePattern !== void 0 && !new RegExp(n.namePattern).test(e.name))
1088
- return !1;
1089
- if (n.type !== void 0) {
1090
- if (Array.isArray(n.type)) {
1091
- if (!n.type.includes(e.valueType))
1092
- return !1;
1093
- } else if (n.type !== e.valueType)
1094
- return !1;
1095
- }
1096
- if (n.domain !== void 0) {
1097
- const t = e.domain || {};
1098
- for (const [r, o] of Object.entries(n.domain))
1099
- if (t[r] !== o)
1100
- return !1;
1101
- }
1102
- if (n.axes !== void 0) {
1103
- const t = e.axesSpec.map(p);
1104
- if (n.partialAxesMatch) {
1105
- for (const r of n.axes)
1106
- if (!t.some((o) => T(r, o)))
1107
- return !1;
1108
- } else {
1109
- if (t.length !== n.axes.length)
1110
- return !1;
1111
- for (let r = 0; r < n.axes.length; r++)
1112
- if (!T(n.axes[r], t[r]))
1113
- return !1;
1114
- }
1115
- }
1116
- if (n.annotations !== void 0) {
1117
- const t = e.annotations || {};
1118
- for (const [r, o] of Object.entries(n.annotations))
1119
- if (t[r] !== o)
1120
- return !1;
1121
- }
1122
- if (n.annotationPatterns !== void 0) {
1123
- const t = e.annotations || {};
1124
- for (const [r, o] of Object.entries(n.annotationPatterns)) {
1125
- const i = t[r];
1126
- if (i === void 0 || !new RegExp(o).test(i))
1127
- return !1;
1128
- }
1129
- }
1130
- return !0;
1131
- }
1132
- function Un(e) {
1133
- return Array.isArray(e) ? (n) => e.some((t) => w(n) && $(n, t)) : (n) => w(n) && $(n, e);
1134
- }
1135
- function qn(e) {
1136
- const n = {
1137
- kind: e.kind,
1138
- name: e.name
1139
- };
1140
- return e.domain !== void 0 && (n.domain = e.domain), w(e) && (n.axesSpec = G(e.axesSpec)), F(n);
1141
- }
1142
- class A {
1143
- constructor(n) {
1144
- /** Graph of linkers connected by axes (single or grouped by parents) */
1145
- b(this, "data");
1146
- this.data = n;
1147
- }
1148
- get keys() {
1149
- return this.data.keys();
1150
- }
1151
- get keyAxesIds() {
1152
- return [...this.data.keys()].map(me);
1153
- }
1154
- static fromColumns(n) {
1155
- var r, o;
1156
- const t = /* @__PURE__ */ new Map();
1157
- for (const i of n.filter((s) => !!z(s.spec, y.IsLinkerColumn))) {
1158
- const s = A.getAxesGroups(_(i.spec.axesSpec));
1159
- if (s.length !== 2)
1160
- continue;
1161
- const [a, u] = s, c = A.getAxesRoots(a).map((f) => {
1162
- const h = P(k(f));
1163
- return [m(h.map(p)), h];
1164
- }), d = A.getAxesRoots(u).map((f) => {
1165
- const h = P(k(f));
1166
- return [m(h.map(p)), h];
1167
- });
1168
- for (const [f, h] of c)
1169
- t.has(f) || t.set(f, { keyAxesSpec: h, linkWith: /* @__PURE__ */ new Map() });
1170
- for (const [f, h] of d)
1171
- t.has(f) || t.set(f, { keyAxesSpec: h, linkWith: /* @__PURE__ */ new Map() });
1172
- for (const [f] of c)
1173
- for (const [h] of d)
1174
- (r = t.get(f)) == null || r.linkWith.set(h, i), (o = t.get(h)) == null || o.linkWith.set(f, i);
1175
- }
1176
- return new this(t);
1177
- }
1178
- /** Get all available nodes of linker graphs if start from sourceAxesKeys */
1179
- searchAvailableAxesKeys(n) {
1180
- const t = new Set(n), r = /* @__PURE__ */ new Set();
1181
- let o = n;
1182
- for (; o.length; ) {
1183
- const i = [];
1184
- for (const s of o) {
1185
- const a = this.data.get(s);
1186
- if (a)
1187
- for (const u of a.linkWith.keys())
1188
- !r.has(u) && !t.has(u) && (i.push(u), r.add(u));
1189
- }
1190
- o = i;
1191
- }
1192
- return r;
1193
- }
1194
- /** Get all linker columns that are necessary to reach endKey from startKey */
1195
- searchLinkerPath(n, t) {
1196
- const r = {};
1197
- let o = /* @__PURE__ */ new Set([n]);
1198
- const i = /* @__PURE__ */ new Set([n]);
1199
- for (; o.size; ) {
1200
- const s = /* @__PURE__ */ new Set();
1201
- for (const a of o) {
1202
- const u = this.data.get(a);
1203
- if (u)
1204
- for (const c of u.linkWith.keys())
1205
- if (r[c] = a, c === t) {
1206
- const d = [];
1207
- let f = t;
1208
- for (; r[f] !== n; )
1209
- d.push(f), f = r[f];
1210
- return d.push(f), d.map((h) => this.data.get(h).linkWith.get(r[h]));
1211
- } else i.has(c) || (s.add(c), i.add(c));
1212
- }
1213
- o = s;
1214
- }
1215
- return [];
1216
- }
1217
- getLinkerColumnsForAxes({
1218
- from: n,
1219
- to: t,
1220
- throwWhenNoLinkExists: r = !0
1221
- }) {
1222
- const o = n.map(A.getLinkerKeyFromAxisSpec);
1223
- return Array.from(
1224
- new Map(
1225
- A.getAxesRoots(t).map(A.getLinkerKeyFromAxisSpec).flatMap((i) => {
1226
- const s = o.map((a) => this.searchLinkerPath(a, i)).reduce(
1227
- (a, u) => a.length && a.length < u.length || !u.length ? a : u,
1228
- []
1229
- ).map((a) => [a.columnId, a]);
1230
- if (!s.length && r)
1231
- throw Error(`Unable to find linker column for ${i}`);
1232
- return s;
1233
- })
1234
- ).values()
1235
- );
1236
- }
1237
- /** Get list of axisSpecs from keys of linker columns map */
1238
- getAxesListFromKeysList(n) {
1239
- return Array.from(
1240
- new Map(
1241
- n.flatMap((t) => {
1242
- var r;
1243
- return ((r = this.data.get(t)) == null ? void 0 : r.keyAxesSpec) ?? [];
1244
- }).map((t) => [m(p(t)), t])
1245
- ).values()
1246
- );
1247
- }
1248
- /** Get axes of target axes that are impossible to be linked to source axes with current linker map */
1249
- getNonLinkableAxes(n, t) {
1250
- const r = n.map(A.getLinkerKeyFromAxisSpec), o = t.map(A.getLinkerKeyFromAxisSpec);
1251
- return Array.from(
1252
- new Map(
1253
- t.filter((s, a) => {
1254
- const u = o[a];
1255
- return !r.some((c) => this.searchLinkerPath(c, u).length);
1256
- }).flatMap((s) => P(k(s)).map((a) => [m(p(a)), a]))
1257
- ).values()
1258
- );
1259
- }
1260
- /** Get all axes that can be connected to sourceAxes by linkers */
1261
- getReachableByLinkersAxesFromAxes(n) {
1262
- const t = n.map(A.getLinkerKeyFromAxisSpec), r = this.searchAvailableAxesKeys(t);
1263
- return this.getAxesListFromKeysList([...r]);
1264
- }
1265
- static getLinkerKeyFromAxisSpec(n) {
1266
- return m(P(k(n)).map(p));
1267
- }
1268
- /** Split array of axes into several arrays by parents: axes of one group are parents for each other.
1269
- There are no order inside every group. */
1270
- static getAxesGroups(n) {
1271
- switch (n.length) {
1272
- case 0:
1273
- return [];
1274
- case 1:
1275
- return [[n[0]]];
1276
- }
1277
- const t = n.map((u) => m(p(u))), r = n.map(
1278
- (u) => new Set(
1279
- u.parentAxesSpec.map((c) => m(p(c))).map((c) => {
1280
- const d = t.indexOf(c);
1281
- if (d === -1)
1282
- throw new Error(`malformed axesSpec: ${JSON.stringify(n)}, unable to locate parent ${c}`);
1283
- return d;
1284
- })
1285
- )
1286
- ), o = [...n.keys()], i = [], s = /* @__PURE__ */ new Set();
1287
- let a = o.find((u) => !s.has(u));
1288
- for (; a !== void 0; ) {
1289
- const u = [a];
1290
- s.add(a);
1291
- let c = [a];
1292
- for (; c.length; ) {
1293
- const d = /* @__PURE__ */ new Set();
1294
- for (const f of c) {
1295
- const h = r[f];
1296
- o.forEach((v) => {
1297
- if (v === f || s.has(v))
1298
- return;
1299
- (r[v].has(f) || h.has(v)) && (u.push(v), d.add(v), s.add(v));
1300
- });
1301
- }
1302
- c = [...d];
1303
- }
1304
- i.push([...u]), a = o.find((d) => !s.has(d));
1305
- }
1306
- return i.map((u) => u.map((c) => n[c]));
1307
- }
1308
- /** Get all axes that are not parents of any other axis */
1309
- static getAxesRoots(n) {
1310
- const t = new Set(n.flatMap((r) => r.parentAxesSpec).map((r) => m(p(r))));
1311
- return n.filter((r) => !t.has(m(p(r))));
1312
- }
1313
- }
1314
- const Wn = { href: "/" }, zn = l.object({
1315
- __isRef: l.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
1316
- blockId: l.string().describe("Upstream block id"),
1317
- name: l.string().describe("Name of the output provided to the upstream block's output context"),
1318
- requireEnrichments: l.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")
1319
- }).describe(
1320
- "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."
1321
- ).readonly();
1322
- function Hn(e) {
1323
- return typeof e == "object" && e !== null && "__isRef" in e && e.__isRef === !0 && "blockId" in e && "name" in e;
1324
- }
1325
- function _n(e, n, t = !1) {
1326
- return t ? {
1327
- __isRef: !0,
1328
- blockId: e,
1329
- name: n,
1330
- requireEnrichments: !0
1331
- } : {
1332
- __isRef: !0,
1333
- blockId: e,
1334
- name: n
1335
- };
1336
- }
1337
- function Gn(e, n = !0) {
1338
- if (n)
1339
- return {
1340
- ...e,
1341
- requireEnrichments: !0
1342
- };
1343
- {
1344
- const { requireEnrichments: t, ...r } = e;
1345
- return r;
1346
- }
1347
- }
1348
- function Qn(e, n, t = !1) {
1349
- return e.blockId === n.blockId && e.name === n.name && (t || e.requireEnrichments === n.requireEnrichments);
1350
- }
1351
- function Xn(e, n) {
1352
- return e.ok ? { ok: !0, value: n(e.value) } : e;
1353
- }
1354
- function Le(e) {
1355
- if (e instanceof Int8Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray)
1356
- return new DataView(e.buffer, e.byteOffset, e.byteLength);
1357
- if (e instanceof ArrayBuffer) return new DataView(e);
1358
- throw new TypeError(
1359
- "Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray"
1360
- );
1361
- }
1362
- const Je = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", Ie = "0123456789ABCDEFGHIJKLMNOPQRSTUV", je = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
1363
- function Z(e, n, t) {
1364
- t = t || {};
1365
- let r, o;
1366
- switch (n) {
1367
- case "RFC3548":
1368
- case "RFC4648":
1369
- r = Je, o = !0;
1370
- break;
1371
- case "RFC4648-HEX":
1372
- r = Ie, o = !0;
1373
- break;
1374
- case "Crockford":
1375
- r = je, o = !1;
1376
- break;
1377
- default:
1378
- throw new Error("Unknown base32 variant: " + String(n));
1379
- }
1380
- const i = t.padding !== void 0 ? t.padding : o, s = Le(e);
1381
- let a = 0, u = 0, c = "";
1382
- for (let d = 0; d < s.byteLength; d++)
1383
- for (u = u << 8 | s.getUint8(d), a += 8; a >= 5; )
1384
- c += r[u >>> a - 5 & 31], a -= 5;
1385
- if (a > 0 && (c += r[u << 5 - a & 31]), i)
1386
- for (; c.length % 8 !== 0; )
1387
- c += "=";
1388
- return c;
1389
- }
1390
- const ee = 15, De = 24, ne = l.string().length(De).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
1391
- function Yn() {
1392
- const e = new Uint8Array(ee);
1393
- return crypto.getRandomValues(e), ne.parse(Z(e, "RFC4648"));
1394
- }
1395
- function Ne(e) {
1396
- if (e.length !== ee) throw new Error(`Wrong number of bytes: ${e.length}`);
1397
- return ne.parse(Z(e, "RFC4648"));
1398
- }
1399
- async function Zn(e) {
1400
- const n = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", n.encode(e));
1401
- return Ne(new Uint8Array(t.slice(0, 15)));
1402
- }
1403
- const et = ["supportsLazyState"], nt = ["requiresUIAPIVersion", "requiresModelAPIVersion"];
1404
- function tt(e, n, t = !0) {
1405
- return e === void 0 ? !1 : e[n] === t;
1406
- }
1407
- function rt(e) {
1408
- return e === void 0 ? /* @__PURE__ */ new Set() : new Set(Object.entries(e).filter(([n, t]) => n.startsWith("requires") && t === !0).map(([n]) => n));
1409
- }
1410
- function ot(e) {
1411
- return e === void 0 ? /* @__PURE__ */ new Set() : new Set(Object.entries(e).filter(([n, t]) => n.startsWith("supports") && t === !0).map(([n]) => n));
1412
- }
1413
- class Re extends Error {
1414
- constructor(t) {
1415
- super(`Some of the block requirements are not supported by the runtime: ${Array.from(t.entries()).map(([r, o]) => `${r}: ${o}`).join(", ")}`);
1416
- b(this, "name", "IncompatibleFlagsError");
1417
- this.incompatibleFlags = t;
1418
- }
1419
- }
1420
- class it {
1421
- constructor() {
1422
- b(this, "supportedRequirements", /* @__PURE__ */ new Map());
1423
- }
1424
- /**
1425
- * Adds a supported requirement to the runtime capabilities.
1426
- * @param requirement - The requirement.
1427
- * @param value - The value of the requirement. If not provided, defaults to true.
1428
- */
1429
- addSupportedRequirement(n, t = !0) {
1430
- return this.supportedRequirements.has(n) || this.supportedRequirements.set(n, /* @__PURE__ */ new Set()), this.supportedRequirements.get(n).add(t), this;
1431
- }
1432
- /**
1433
- * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
1434
- * @param blockFlags - The block flags.
1435
- * @returns A map of incompatible flags, or undefined if the block flags are compatible.
1436
- */
1437
- getIncompatibleFlags(n) {
1438
- if (n === void 0) return;
1439
- const t = /* @__PURE__ */ new Map();
1440
- for (const [r, o] of Object.entries(n))
1441
- if (r.startsWith("requires")) {
1442
- if (o === void 0) continue;
1443
- const i = this.supportedRequirements.get(r);
1444
- (i === void 0 || !i.has(o)) && t.set(r, o);
1445
- }
1446
- return t.size === 0 ? void 0 : t;
1447
- }
1448
- /**
1449
- * Checks if the block flags are compatible with the runtime capabilities.
1450
- * @param blockFlags - The block flags.
1451
- * @returns True if the block flags are compatible, false otherwise.
1452
- */
1453
- checkCompatibility(n) {
1454
- return this.getIncompatibleFlags(n) === void 0;
1455
- }
1456
- /**
1457
- * Throws an error if the block flags are incompatible with the runtime capabilities.
1458
- * @param blockFlags - The block flags.
1459
- * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
1460
- */
1461
- throwIfIncompatible(n) {
1462
- const t = this.getIncompatibleFlags(n);
1463
- if (t !== void 0)
1464
- throw new Re(t);
1465
- }
1466
- }
1467
- export {
1468
- rn as AbortError,
1469
- nt as AllRequiresFeatureFlags,
1470
- et as AllSupportsFeatureFlags,
1471
- Nn as AnchoredIdDeriver,
1472
- y as Annotation,
1473
- W as AnnotationJson,
1474
- he as AxisSpec,
1475
- Wn as DefaultNavigationState,
1476
- yn as Domain,
1477
- q as DomainJson,
1478
- Re as IncompatibleFlagsError,
1479
- A as LinkerMap,
1480
- Pn as PColumnName,
1481
- cn as PFrameDriverError,
1482
- le as PFrameError,
1483
- ke as PTableAbsent,
1484
- X as PTableNA,
1485
- ne as PlId,
1486
- ee as PlIdBytes,
1487
- De as PlIdLength,
1488
- zn as PlRef,
1489
- We as RangeBytes,
1490
- it as RuntimeCapabilities,
1491
- on as UiError,
1492
- g as ValueType,
1493
- On as canonicalizeAxisId,
1494
- D as canonicalizeAxisWithParents,
1495
- m as canonicalizeJson,
1496
- tt as checkBlockFlag,
1497
- _n as createPlRef,
1498
- en as dataInfoToEntries,
1499
- qn as deriveNativeId,
1500
- J as deserializeError,
1501
- fn as deserializeResult,
1502
- Zn as digestPlId,
1503
- C as ensureError,
1504
- Vn as ensurePColumn,
1505
- nn as entriesToDataInfo,
1506
- L as executePSpecPredicate,
1507
- Bn as extractAllColumns,
1508
- rt as extractAllRequirements,
1509
- ot as extractAllSupports,
1510
- Me as extractCodeWithInfo,
1511
- Be as extractConfigGeneric,
1512
- P as getArrayFromAxisTree,
1513
- G as getAxesId,
1514
- k as getAxesTree,
1515
- p as getAxisId,
1516
- En as getColumnIdAndSpec,
1517
- kn as getDenormalizedAxesList,
1518
- Ge as getFileNameFromHandle,
1519
- ae as getFilePathFromHandle,
1520
- _ as getNormalizedAxesList,
1521
- Sn as getPColumnSpecId,
1522
- jn as getPTableColumnId,
1523
- xn as getSetFromAxisTree,
1524
- ce as hasAbortError,
1525
- an as isAbortError,
1526
- sn as isAggregateError,
1527
- qe as isBlockUIURL,
1528
- Qe as isDataInfo,
1529
- ue as isDataInfoEntries,
1530
- Tn as isFilteredPColumn,
1531
- Ue as isFolderURL,
1532
- ie as isImportFileHandleIndex,
1533
- oe as isImportFileHandleUpload,
1534
- _e as isLiveLog,
1535
- Fe as isPColumn,
1536
- Kn as isPColumnResult,
1537
- w as isPColumnSpec,
1538
- $n as isPColumnSpecResult,
1539
- ln as isPFrameDriverError,
1540
- un as isPFrameError,
1541
- Fn as isPTableAbsent,
1542
- Pe as isPTableNA,
1543
- Cn as isPTableValueAxis,
1544
- Ze as isPartitionedDataInfoEntries,
1545
- Hn as isPlRef,
1546
- Xe as mapDataInfo,
1547
- tn as mapDataInfoEntries,
1548
- E as mapJoinEntry,
1549
- Mn as mapPObjectData,
1550
- In as mapPTableDef,
1551
- Xn as mapValueInVOE,
1552
- T as matchAxis,
1553
- Ae as matchAxisId,
1554
- $ as matchPColumn,
1555
- ze as newRangeBytesOpt,
1556
- Ln as pTableValue,
1557
- Jn as pTableValueBranded,
1558
- Dn as parseColumnId,
1559
- me as parseJson,
1560
- Ne as plId,
1561
- Qn as plRefsEqual,
1562
- An as readAnnotation,
1563
- z as readAnnotationJson,
1564
- vn as readAnnotationJsonOrThrow,
1565
- gn as readDomain,
1566
- wn as readDomainJson,
1567
- bn as readDomainJsonOrThrow,
1568
- I as readMetadata,
1569
- U as readMetadataJson,
1570
- j as readMetadataJsonOrThrow,
1571
- Rn as resolveAnchors,
1572
- Un as selectorsToPredicate,
1573
- M as serializeError,
1574
- B as serializeResult,
1575
- Se as stringifyColumnId,
1576
- hn as stringifyJson,
1577
- Yn as uniquePlId,
1578
- dn as unwrapResult,
1579
- He as validateRangeBytes,
1580
- Ye as visitDataInfo,
1581
- Gn as withEnrichments,
1582
- pn as wrapAndSerialize,
1583
- mn as wrapAndSerializeAsync,
1584
- pe as wrapAsyncCallback,
1585
- fe as wrapCallback
1586
- };
1587
- //# sourceMappingURL=index.mjs.map