vvplot 0.6.0 → 0.7.1

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.
@@ -0,0 +1,498 @@
1
+ // \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esmMin = (fn, res, err) => () => {
9
+ if (err) throw err[0];
10
+ try {
11
+ return fn && (res = fn(fn = 0)), res;
12
+ } catch (e) {
13
+ throw err = [e], e;
14
+ }
15
+ };
16
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
17
+ var __exportAll = (all, no_symbols) => {
18
+ let target = {};
19
+ for (var name in all) __defProp(target, name, {
20
+ get: all[name],
21
+ enumerable: true
22
+ });
23
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
24
+ return target;
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
28
+ key = keys[i];
29
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
30
+ get: ((k) => from[k]).bind(null, key),
31
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
32
+ });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
37
+ value: mod,
38
+ enumerable: true
39
+ }) : target, mod));
40
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ // src/js/utils.js
42
+ var utils_exports = /* @__PURE__ */ __exportAll({
43
+ Asis: () => Asis,
44
+ EnumElement: () => EnumElement,
45
+ EnumLevel: () => EnumLevel,
46
+ categorize: () => categorize,
47
+ deepEqual: () => deepEqual,
48
+ interaction: () => interaction,
49
+ intraaction: () => intraaction,
50
+ intrazip: () => intrazip,
51
+ is_categorical: () => is_categorical,
52
+ is_continuous: () => is_continuous,
53
+ numutils: () => numutils,
54
+ obj_merge: () => obj_merge,
55
+ oob_censor: () => oob_censor,
56
+ oob_squish_any: () => oob_squish_any,
57
+ oob_squish_infinite: () => oob_squish_infinite,
58
+ plus: () => plus,
59
+ str_c: () => str_c,
60
+ unique: () => unique,
61
+ vecutils: () => vecutils
62
+ });
63
+ var AsisString = class extends String {
64
+ static #cache = /* @__PURE__ */ new Map();
65
+ constructor(str) {
66
+ const x = String(str);
67
+ if (new.target.#cache.has(x)) return new.target.#cache.get(x);
68
+ super(x);
69
+ new.target.#cache.set(x, this);
70
+ }
71
+ };
72
+ var AsisNumber = class extends Number {
73
+ static #cache = /* @__PURE__ */ new Map();
74
+ constructor(num) {
75
+ const n = Number(num);
76
+ if (new.target.#cache.has(n)) return new.target.#cache.get(n);
77
+ super(n);
78
+ new.target.#cache.set(n, this);
79
+ }
80
+ };
81
+ var Asis = class {
82
+ static #cache = /* @__PURE__ */ new Map();
83
+ constructor(value) {
84
+ if (typeof value === "string" || value instanceof String) return new AsisString(value);
85
+ if (typeof value === "number" || value instanceof Number) return new AsisNumber(value);
86
+ throw new Error("Unsupported type");
87
+ }
88
+ static [Symbol.hasInstance](obj) {
89
+ return obj instanceof AsisString || obj instanceof AsisNumber;
90
+ }
91
+ };
92
+ var EnumElement = class {
93
+ constructor(label, value, level) {
94
+ this.label = label;
95
+ this.value = value;
96
+ this.level = level;
97
+ }
98
+ toString() {
99
+ return this.label;
100
+ }
101
+ valueOf() {
102
+ return this.value;
103
+ }
104
+ toJSON() {
105
+ return this.label;
106
+ }
107
+ };
108
+ var EnumLevel = class extends Array {
109
+ /**
110
+ * return:
111
+ * x if x is a EnumLevel
112
+ * new EnumLevel from distinct values of x, ordered by natural order, if x is iterable
113
+ * new EnumLevel from keys of x, orderd by coresponing values, if x is an object
114
+ * @param {*} x
115
+ * @param {function} [sortkey]
116
+ * @returns {EnumLevel}
117
+ */
118
+ static from(x) {
119
+ if (x instanceof this) return x;
120
+ if (x[Symbol.iterator]) {
121
+ let lvl = unique(Array.from(x).filter((x) => !(x instanceof Asis) && x != null).map((x) => String(x))).sort((a, b) => compare(a, b, { numeric: true }));
122
+ return new this(...lvl);
123
+ } else if (typeof x === "object") {
124
+ let lvl = Object.keys(x).map((x) => String(x)).sort((a, b) => compare(x[a], x[b]));
125
+ return new this(...lvl);
126
+ }
127
+ throw new Error(`Invalid level values: ${x}`);
128
+ }
129
+ /**
130
+ * Check if two EnumLevel are equal, i.e. they have the same labels in the same order
131
+ * @param {string[]} level
132
+ */
133
+ static isEqual(a, b) {
134
+ if (a instanceof this && b instanceof this) return a.length === b.length && Array(a.length).fill().every((_, i) => a[i].label === b[i].label);
135
+ }
136
+ /**
137
+ * build a EnumLevel
138
+ * @param {string[]} level
139
+ */
140
+ constructor(...level) {
141
+ level = level.map((x, i) => new EnumElement(String(x), i));
142
+ level.forEach((l) => l.level = level);
143
+ level.mapping = Object.fromEntries(level.map((fct) => [fct, fct]));
144
+ Object.setPrototypeOf(level, new.target.prototype);
145
+ return level;
146
+ }
147
+ /**
148
+ * get the level instance by index or key
149
+ * @param {(number|string)} idx
150
+ * @returns {EnumElement}
151
+ */
152
+ getItem(idx) {
153
+ if (typeof idx === "number" || idx instanceof Number) return this[idx];
154
+ else return this.mapping[idx];
155
+ }
156
+ /**
157
+ * convert an array to a GEnum array
158
+ * @param {string[]} arr array to be converted, preferably a string array (items of other types will be converted to string)
159
+ * @returns {EnumElement[]}
160
+ */
161
+ apply(arr) {
162
+ let result = arr.map((x) => x instanceof Asis ? x : this.mapping[x]);
163
+ result.level = this;
164
+ return result;
165
+ }
166
+ };
167
+ function is_continuous(x) {
168
+ return typeof x === "number" || x instanceof Number || x instanceof Date;
169
+ }
170
+ function is_categorical(v) {
171
+ return typeof v === "string" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "object" && v !== null && typeof v.valueOf() !== "number" && typeof v.valueOf() !== "bigint";
172
+ }
173
+ /**
174
+ * Add two numeric values, with special handling of semantic values.
175
+ * - If `a` is `null` or `undefined`, return `a`.
176
+ * - If `a` is a `Date`, return a new `Date` with the time value of `a` plus `b`.
177
+ * - Otherwise, return the sum of `a` and `b`.
178
+ * @param {number|Date|null|undefined} a The first value to add.
179
+ * @param {number} b The second value to add.
180
+ * @returns The sum of the two values.
181
+ */
182
+ function plus(a, b = 0) {
183
+ if (b == 0 || a == null) return a;
184
+ if (a instanceof Date) return new a.constructor(+a + b);
185
+ return +a + b;
186
+ }
187
+ var numutils = {
188
+ min(arr, { na_rm = true, infinity_rm = true } = {}) {
189
+ if (na_rm) arr = arr.filter(is_continuous);
190
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
191
+ return Array.from(arr).reduce((a, b) => a < b ? a : b, Infinity);
192
+ },
193
+ max(arr, { na_rm = true, infinity_rm = true } = {}) {
194
+ if (na_rm) arr = arr.filter(is_continuous);
195
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
196
+ return Array.from(arr).reduce((a, b) => a > b ? a : b, -Infinity);
197
+ },
198
+ sum(arr, { na_rm = true, infinity_rm = true } = {}) {
199
+ if (na_rm) arr = arr.filter(is_continuous);
200
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
201
+ return Array.from(arr).reduce((a, b) => a + b, 0);
202
+ },
203
+ diff(arr, { na_rm = true, infinity_rm = true } = {}) {
204
+ if (na_rm) arr = arr.filter(is_continuous);
205
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
206
+ return Array.from(arr).slice(1).map((v, i) => v - arr[i]);
207
+ },
208
+ mean(arr, { na_rm = true, infinity_rm = true } = {}) {
209
+ if (na_rm) arr = arr.filter(is_continuous);
210
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
211
+ if (arr.length == 0) return NaN;
212
+ return Array.from(arr).reduce((a, v) => a + v, 0) / arr.length;
213
+ },
214
+ sd(arr, { na_rm = true, infinity_rm = true } = {}) {
215
+ if (na_rm) arr = arr.filter(is_continuous);
216
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
217
+ if (arr.length <= 1) return NaN;
218
+ let mean = Array.from(arr).reduce((a, v) => a + v, 0) / arr.length;
219
+ return Math.sqrt(Array.from(arr).reduce((a, v) => a + (v - mean) ** 2, 0) / (arr.length - 1));
220
+ },
221
+ quantile(arr, p, { na_rm = true, infinity_rm = true } = {}) {
222
+ if (na_rm) arr = arr.filter(is_continuous);
223
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
224
+ if (arr.length == 0) return NaN;
225
+ arr = Array.from(arr).sort((a, b) => a - b);
226
+ let idx = (arr.length - 1) * p, lo = Math.floor(idx), hi = Math.ceil(idx);
227
+ if (lo == hi) return arr[lo];
228
+ return arr[lo] * (hi - idx) + arr[hi] * (idx - lo);
229
+ },
230
+ extent(arr, { na_rm = true, infinity_rm = true } = {}) {
231
+ if (na_rm) arr = arr.filter(is_continuous);
232
+ if (infinity_rm) arr = arr.filter((x) => isFinite(x));
233
+ if (arr.length == 0) return new Array(2);
234
+ let min = Array.from(arr).reduce((a, b) => a < b ? a : b, Infinity), max = Array.from(arr).reduce((a, b) => a > b ? a : b, -Infinity);
235
+ return Object.assign([min, max], {
236
+ min,
237
+ max
238
+ });
239
+ }
240
+ };
241
+ var vecutils = {
242
+ coalesce(value, defaultValue) {
243
+ if (Array.isArray(defaultValue)) {
244
+ if (!Array.isArray(value) || value.length != defaultValue.length) throw new Error("Value and defaultValue must be arrays of the same length");
245
+ return value.map((v, i) => v == null ? defaultValue[i] : v);
246
+ }
247
+ if (Array.isArray(value)) return value.map((v) => v ?? defaultValue);
248
+ return value ?? defaultValue;
249
+ },
250
+ sum(...values) {
251
+ if (values.some((x) => x == null)) return null;
252
+ if (values.some((x) => !Array.isArray(x) && typeof x != "number")) throw new Error("Arguments must be numbers or arrays");
253
+ let nums = values.filter((x) => !Array.isArray(x)).reduce((s, a) => +a + s, 0);
254
+ values = values.filter((x) => Array.isArray(x));
255
+ if (values.length == 0) return [nums];
256
+ let length = values[0].length;
257
+ if (values.some((v) => v.length != length)) throw new Error("Arrays must have the same length");
258
+ return Array.from({ length }, (_, i) => values.reduce((s, a) => +(a[i] ?? void 0) + s, nums));
259
+ },
260
+ opposite(value) {
261
+ if (value == null) return null;
262
+ if (!Array.isArray(value) && typeof value != "number") throw new Error("Arguments must be numbers or arrays");
263
+ if (Array.isArray(value)) return value.map((v) => v == null ? v : -v);
264
+ return -value;
265
+ },
266
+ concat(...values) {
267
+ if (values.some((x) => x == null)) return null;
268
+ let arrs = values.filter((x) => Array.isArray(x));
269
+ if (arrs.length == 0) return [values.join("")];
270
+ if (values.some((v) => v.length == 0)) return [];
271
+ let length = arrs[0].length;
272
+ if (arrs.some((v) => v.length != length)) throw new Error("Arrays must have the same length");
273
+ return Array.from({ length }, (_, i) => values.map((a) => Array.isArray(a) ? a[i] : a).join(""));
274
+ },
275
+ apply(func, ...values) {
276
+ if (values.some((x) => x == null)) return null;
277
+ let arrs = values.filter((x) => Array.isArray(x));
278
+ if (arrs.length == 0) return [func(...values)];
279
+ if (values.some((v) => v.length == 0)) return [];
280
+ let length = arrs[0].length;
281
+ if (arrs.some((v) => v.length != length)) throw new Error("Arrays must have the same length");
282
+ return Array.from({ length }, (_, i) => func(...values.map((a) => Array.isArray(a) ? a[i] : a)));
283
+ }
284
+ };
285
+ /**
286
+ * (shallow) merge array of objects, from left to right
287
+ * `undefined` will be ignored
288
+ * `null` will reset the merge
289
+ * @param {Array} arr
290
+ * @returns {Object|null}
291
+ */
292
+ function obj_merge(...arr) {
293
+ arr = arr.filter((x) => x !== void 0);
294
+ if (arr.length == 0) return void 0;
295
+ arr = arr.slice(arr.findIndex((x) => x == null) + 1);
296
+ if (arr.length == 0) return null;
297
+ return arr.reduce((a, c) => {
298
+ for (let k in c) if (c[k] !== void 0) a[k] = c[k];
299
+ return a;
300
+ }, {});
301
+ }
302
+ /**
303
+ * concatenate strings, with special handling of `undefined` and `null`
304
+ * - if any argument is `undefined`, return `undefined`
305
+ * - else if any argument is `null`, return `null`
306
+ * - else return concatenated string
307
+ * @param {...(string|undefined|null)} args
308
+ * @returns {string|undefined|null}
309
+ */
310
+ function str_c(...args) {
311
+ if (args.some((x) => x === void 0)) return void 0;
312
+ if (args.some((x) => x === null)) return null;
313
+ return args.join("");
314
+ }
315
+ /**
316
+ * return unique values in an array
317
+ * @param {Array} arr
318
+ * @param {function} [key] function to get the key of an item, default to identity function
319
+ * @param {function} [priority] function to get the priority of an item when there are duplicate keys, default to keep the first one
320
+ * @returns {Array}
321
+ */
322
+ function unique(arr, key = null, priority = null) {
323
+ let map = /* @__PURE__ */ new Map();
324
+ for (let i in arr) {
325
+ let k = key ? key(arr[i]) : arr[i];
326
+ if (!map.has(k)) map.set(k, arr[i]);
327
+ else if (priority) map.set(k, priority(map.get(k), arr[i]));
328
+ }
329
+ return Array.from(map.values());
330
+ }
331
+ /**
332
+ * natural comparation of two item
333
+ * @param {*} a
334
+ * @param {*} b
335
+ * @returns {number}
336
+ */
337
+ function compare(a, b, { numeric = false } = {}) {
338
+ if (typeof a != "number" || typeof b != "number") return String(a).localeCompare(String(b), void 0, { numeric });
339
+ return a - b;
340
+ }
341
+ /**
342
+ * turn out-of-bounds values to NaN
343
+ * @param {number} value
344
+ * @param {Object} option
345
+ * @param {number} option.min lower bound
346
+ * @param {number} option.max upper bound
347
+ * @returns {number}
348
+ */
349
+ function oob_censor(value, { min, max }) {
350
+ if (value < min || value > max) return NaN;
351
+ return value;
352
+ }
353
+ /**
354
+ * turn out-of-bounds values to bounds
355
+ * @param {number} value
356
+ * @param {Object} option
357
+ * @param {number} option.min lower bound
358
+ * @param {number} option.max upper bound
359
+ * @returns {number}
360
+ */
361
+ function oob_squish_any(value, { min, max }) {
362
+ if (value < min) return min;
363
+ if (value > max) return max;
364
+ return value;
365
+ }
366
+ /**
367
+ * turn infinite values to bounds
368
+ * @param {number} value
369
+ * @param {Object} option
370
+ * @param {number} option.min lower bound
371
+ * @param {number} option.max upper bound
372
+ * @returns {number}
373
+ */
374
+ function oob_squish_infinite(value, { min, max }) {
375
+ if (value == -Infinity) return min;
376
+ if (value == Infinity) return max;
377
+ return value;
378
+ }
379
+ /**
380
+ * test deep equality between two values
381
+ * @param {*} a
382
+ * @param {*} b
383
+ * @param {function(*, *, number): boolean | undefined} [comparer] optional comparer function, will be applied before deep comparison, should return true/false or undefined (to continue deep comparison)
384
+ * @param {number} [level=0] the current depth of the comparison
385
+ * @returns {boolean}
386
+ */
387
+ function deepEqual(a, b, comparer, level = 0) {
388
+ if (level > 25) throw new Error("deepEqual: maximum recursion depth exceeded");
389
+ if (comparer != null && typeof comparer !== "function") throw new Error("comparer must be a function");
390
+ if (a === b) return true;
391
+ if (comparer != null) {
392
+ let res = comparer(a, b, level);
393
+ if (res === true || res === false || res instanceof Boolean) return Boolean(res);
394
+ }
395
+ if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) return false;
396
+ let aKeys = Object.keys(a), bKeys = Object.keys(b);
397
+ if (aKeys.length !== bKeys.length) return false;
398
+ for (let key of aKeys) if (!deepEqual(a[key], b[key], comparer, level + 1)) return false;
399
+ return true;
400
+ }
401
+ /**
402
+ * Create a shallow categorical representation for a list of object.
403
+ * @param {object[]} array
404
+ * @param {function} [comparer] optional comparer function, will be passed to `deepEqual` to decide equality.
405
+ * @returns {number[]} result
406
+ * @returns {Array[]} result.categories
407
+ */
408
+ function categorize(array, comparer) {
409
+ if (!Array.isArray(array)) throw new Error("Argument must be an array");
410
+ let categories = [], result = [];
411
+ for (let i = 0; i < array.length; i++) {
412
+ let obj = array[i];
413
+ let idx = categories.findIndex((cat) => deepEqual(cat, obj, comparer));
414
+ if (idx === -1) {
415
+ categories.push(obj);
416
+ idx = categories.length - 1;
417
+ }
418
+ result.push(idx);
419
+ }
420
+ result.categories = categories;
421
+ return result;
422
+ }
423
+ /**
424
+ * Create a categorical representation for lists of data.
425
+ * i.e. `categorize` for multiple arrays
426
+ * @param {...any} arrays
427
+ * @returns {number[]} result
428
+ * @returns {Array[]} result.categories
429
+ */
430
+ function interaction(...arrays) {
431
+ if (arrays.length == 0) return null;
432
+ let length = arrays.filter((x) => Array.isArray(x)).reduce((l, arr) => {
433
+ if (Array.isArray(arr)) {
434
+ if (l == null) return arr.length;
435
+ if (l != arr.length) throw new Error("Arrays must have the same length");
436
+ }
437
+ return l;
438
+ }, null) ?? 0;
439
+ let categories = [], result = [];
440
+ for (let i = 0; i < length; i++) {
441
+ let arr = arrays.map((x) => Array.isArray(x) ? x[i] : x);
442
+ let idx = categories.findIndex((x) => x.every((v, j) => v === arr[j]));
443
+ if (idx === -1) {
444
+ categories.push(arr);
445
+ idx = categories.length - 1;
446
+ }
447
+ result.push(idx);
448
+ }
449
+ result.categories = categories;
450
+ return result;
451
+ }
452
+ /**
453
+ * Create a categorical representation for lists of data.
454
+ * i.e. `interaction` with key names
455
+ * @param {Object} arrays
456
+ * @returns {number[]} result
457
+ * @returns {object[]} result.categories
458
+ */
459
+ function intraaction(arrays) {
460
+ if (Object.keys(arrays).length == 0) return null;
461
+ let length = Object.values(arrays).filter((x) => Array.isArray(x)).reduce((l, arr) => {
462
+ if (Array.isArray(arr)) {
463
+ if (l == null) return arr.length;
464
+ if (l != arr.length) throw new Error("Arrays must have the same length");
465
+ }
466
+ return l;
467
+ }, null) ?? 0;
468
+ let keys = Object.keys(arrays);
469
+ let categories = [], result = [];
470
+ for (let i = 0; i < length; i++) {
471
+ let arr = Object.fromEntries(keys.map((k) => [k, Array.isArray(arrays[k]) ? arrays[k][i] : arrays[k]]));
472
+ let idx = categories.findIndex((x) => keys.every((k) => x[k] === arr[k]));
473
+ if (idx === -1) {
474
+ categories.push(arr);
475
+ idx = categories.length - 1;
476
+ }
477
+ result.push(idx);
478
+ }
479
+ result.categories = categories;
480
+ return result;
481
+ }
482
+ /**
483
+ * Turn dict of arrays into array of dicts
484
+ * @param {Object} arrays dict of arrays
485
+ * @returns {object[]} array of dicts
486
+ */
487
+ function intrazip(arrays) {
488
+ if (Object.keys(arrays).length == 0) return [];
489
+ let length = Object.values(arrays).filter((x) => Array.isArray(x)).reduce((l, arr) => {
490
+ if (Array.isArray(arr)) {
491
+ if (l == null) return arr.length;
492
+ if (l != arr.length) throw new Error("Arrays must have the same length");
493
+ }
494
+ return l;
495
+ }, null) ?? 0;
496
+ return Array.from({ length }, (_, i) => Object.fromEntries(Object.keys(arrays).map((k) => [k, Array.isArray(arrays[k]) ? arrays[k][i] : arrays[k]])));
497
+ }
498
+ export { Asis, EnumElement, EnumLevel, __commonJSMin, __esmMin, __exportAll, __toCommonJS, __toESM, categorize, deepEqual, interaction, intraaction, intrazip, is_categorical, is_continuous, numutils, obj_merge, oob_censor, oob_squish_any, oob_squish_infinite, plus, str_c, unique, utils_exports, vecutils };
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,o)=>(o=n==null?{}:e(i(n)),l(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e),f=/* @__PURE__ */ c({Asis:()=>h,EnumElement:()=>g,EnumLevel:()=>_,categorize:()=>j,deepEqual:()=>A,interaction:()=>M,intraaction:()=>N,intrazip:()=>P,is_categorical:()=>y,is_continuous:()=>v,numutils:()=>x,obj_merge:()=>C,oob_censor:()=>D,oob_squish_any:()=>O,oob_squish_infinite:()=>k,plus:()=>b,str_c:()=>w,unique:()=>T,vecutils:()=>S}),p=class extends String{static#e=/* @__PURE__ */ new Map;constructor(e){let t=String(e);if(new.target.#e.has(t))return new.target.#e.get(t);super(t),new.target.#e.set(t,this)}},m=class extends Number{static#e=/* @__PURE__ */ new Map;constructor(e){let t=Number(e);if(new.target.#e.has(t))return new.target.#e.get(t);super(t),new.target.#e.set(t,this)}},h=class{constructor(e){if(typeof e==`string`||e instanceof String)return new p(e);if(typeof e==`number`||e instanceof Number)return new m(e);throw Error(`Unsupported type`)}static[Symbol.hasInstance](e){return e instanceof p||e instanceof m}},g=class{constructor(e,t,n){this.label=e,this.value=t,this.level=n}toString(){return this.label}valueOf(){return this.value}toJSON(){return this.label}},_=class extends Array{static from(e){if(e instanceof this)return e;if(e[Symbol.iterator]){let t=T(Array.from(e).filter(e=>!(e instanceof h)&&e!=null).map(e=>String(e))).sort((e,t)=>E(e,t,{numeric:!0}));return new this(...t)}if(typeof e==`object`){let t=Object.keys(e).map(e=>String(e)).sort((t,n)=>E(e[t],e[n]));return new this(...t)}throw Error(`Invalid level values: ${e}`)}static isEqual(e,t){if(e instanceof this&&t instanceof this)return e.length===t.length&&Array(e.length).fill().every((n,r)=>e[r].label===t[r].label)}constructor(...e){return e=e.map((e,t)=>new g(String(e),t)),e.forEach(t=>t.level=e),e.mapping=Object.fromEntries(e.map(e=>[e,e])),Object.setPrototypeOf(e,new.target.prototype),e}getItem(e){return typeof e==`number`||e instanceof Number?this[e]:this.mapping[e]}apply(e){let t=e.map(e=>e instanceof h?e:this.mapping[e]);return t.level=this,t}};function v(e){return typeof e==`number`||e instanceof Number||e instanceof Date}function y(e){return typeof e==`string`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`object`&&!!e&&typeof e.valueOf()!=`number`&&typeof e.valueOf()!=`bigint`}function b(e,t=0){return t==0||e==null?e:e instanceof Date?new e.constructor(+e+t):+e+t}var x={min(e,{na_rm:t=!0,infinity_rm:n=!0}={}){return t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),Array.from(e).reduce((e,t)=>e<t?e:t,1/0)},max(e,{na_rm:t=!0,infinity_rm:n=!0}={}){return t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),Array.from(e).reduce((e,t)=>e>t?e:t,-1/0)},sum(e,{na_rm:t=!0,infinity_rm:n=!0}={}){return t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),Array.from(e).reduce((e,t)=>e+t,0)},diff(e,{na_rm:t=!0,infinity_rm:n=!0}={}){return t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),Array.from(e).slice(1).map((t,n)=>t-e[n])},mean(e,{na_rm:t=!0,infinity_rm:n=!0}={}){return t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),e.length==0?NaN:Array.from(e).reduce((e,t)=>e+t,0)/e.length},sd(e,{na_rm:t=!0,infinity_rm:n=!0}={}){if(t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),e.length<=1)return NaN;let r=Array.from(e).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(Array.from(e).reduce((e,t)=>e+(t-r)**2,0)/(e.length-1))},quantile(e,t,{na_rm:n=!0,infinity_rm:r=!0}={}){if(n&&(e=e.filter(v)),r&&(e=e.filter(e=>isFinite(e))),e.length==0)return NaN;e=Array.from(e).sort((e,t)=>e-t);let i=(e.length-1)*t,a=Math.floor(i),o=Math.ceil(i);return a==o?e[a]:e[a]*(o-i)+e[o]*(i-a)},extent(e,{na_rm:t=!0,infinity_rm:n=!0}={}){if(t&&(e=e.filter(v)),n&&(e=e.filter(e=>isFinite(e))),e.length==0)return[,,];let r=Array.from(e).reduce((e,t)=>e<t?e:t,1/0),i=Array.from(e).reduce((e,t)=>e>t?e:t,-1/0);return Object.assign([r,i],{min:r,max:i})}},S={coalesce(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!=t.length)throw Error(`Value and defaultValue must be arrays of the same length`);return e.map((e,n)=>e??t[n])}return Array.isArray(e)?e.map(e=>e??t):e??t},sum(...e){if(e.some(e=>e==null))return null;if(e.some(e=>!Array.isArray(e)&&typeof e!=`number`))throw Error(`Arguments must be numbers or arrays`);let t=e.filter(e=>!Array.isArray(e)).reduce((e,t)=>+t+e,0);if(e=e.filter(e=>Array.isArray(e)),e.length==0)return[t];let n=e[0].length;if(e.some(e=>e.length!=n))throw Error(`Arrays must have the same length`);return Array.from({length:n},(n,r)=>e.reduce((e,t)=>+(t[r]??void 0)+e,t))},opposite(e){if(e==null)return null;if(!Array.isArray(e)&&typeof e!=`number`)throw Error(`Arguments must be numbers or arrays`);return Array.isArray(e)?e.map(e=>e==null?e:-e):-e},concat(...e){if(e.some(e=>e==null))return null;let t=e.filter(e=>Array.isArray(e));if(t.length==0)return[e.join(``)];if(e.some(e=>e.length==0))return[];let n=t[0].length;if(t.some(e=>e.length!=n))throw Error(`Arrays must have the same length`);return Array.from({length:n},(t,n)=>e.map(e=>Array.isArray(e)?e[n]:e).join(``))},apply(e,...t){if(t.some(e=>e==null))return null;let n=t.filter(e=>Array.isArray(e));if(n.length==0)return[e(...t)];if(t.some(e=>e.length==0))return[];let r=n[0].length;if(n.some(e=>e.length!=r))throw Error(`Arrays must have the same length`);return Array.from({length:r},(n,r)=>e(...t.map(e=>Array.isArray(e)?e[r]:e)))}};function C(...e){if(e=e.filter(e=>e!==void 0),e.length!=0)return e=e.slice(e.findIndex(e=>e==null)+1),e.length==0?null:e.reduce((e,t)=>{for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e},{})}function w(...e){if(!e.some(e=>e===void 0))return e.some(e=>e===null)?null:e.join(``)}function T(e,t=null,n=null){let r=/* @__PURE__ */ new Map;for(let i in e){let a=t?t(e[i]):e[i];r.has(a)?n&&r.set(a,n(r.get(a),e[i])):r.set(a,e[i])}return Array.from(r.values())}function E(e,t,{numeric:n=!1}={}){return typeof e!=`number`||typeof t!=`number`?String(e).localeCompare(String(t),void 0,{numeric:n}):e-t}function D(e,{min:t,max:n}){return e<t||e>n?NaN:e}function O(e,{min:t,max:n}){return e<t?t:e>n?n:e}function k(e,{min:t,max:n}){return e==-1/0?t:e==1/0?n:e}function A(e,t,n,r=0){if(r>25)throw Error(`deepEqual: maximum recursion depth exceeded`);if(n!=null&&typeof n!=`function`)throw Error(`comparer must be a function`);if(e===t)return!0;if(n!=null){let i=n(e,t,r);if(i===!0||i===!1||i instanceof Boolean)return!!i}if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let a of i)if(!A(e[a],t[a],n,r+1))return!1;return!0}function j(e,t){if(!Array.isArray(e))throw Error(`Argument must be an array`);let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=n.findIndex(e=>A(e,a,t));o===-1&&(n.push(a),o=n.length-1),r.push(o)}return r.categories=n,r}function M(...e){if(e.length==0)return null;let t=e.filter(e=>Array.isArray(e)).reduce((e,t)=>{if(Array.isArray(t)){if(e==null)return t.length;if(e!=t.length)throw Error(`Arrays must have the same length`)}return e},null)??0,n=[],r=[];for(let i=0;i<t;i++){let t=e.map(e=>Array.isArray(e)?e[i]:e),a=n.findIndex(e=>e.every((e,n)=>e===t[n]));a===-1&&(n.push(t),a=n.length-1),r.push(a)}return r.categories=n,r}function N(e){if(Object.keys(e).length==0)return null;let t=Object.values(e).filter(e=>Array.isArray(e)).reduce((e,t)=>{if(Array.isArray(t)){if(e==null)return t.length;if(e!=t.length)throw Error(`Arrays must have the same length`)}return e},null)??0,n=Object.keys(e),r=[],i=[];for(let a=0;a<t;a++){let t=Object.fromEntries(n.map(t=>[t,Array.isArray(e[t])?e[t][a]:e[t]])),o=r.findIndex(e=>n.every(n=>e[n]===t[n]));o===-1&&(r.push(t),o=r.length-1),i.push(o)}return i.categories=r,i}function P(e){if(Object.keys(e).length==0)return[];let t=Object.values(e).filter(e=>Array.isArray(e)).reduce((e,t)=>{if(Array.isArray(t)){if(e==null)return t.length;if(e!=t.length)throw Error(`Arrays must have the same length`)}return e},null)??0;return Array.from({length:t},(t,n)=>Object.fromEntries(Object.keys(e).map(t=>[t,Array.isArray(e[t])?e[t][n]:e[t]])))}export{c as C,o as S,u as T,w as _,A as a,S as b,P as c,x as d,C as f,b as g,k as h,j as i,y as l,O as m,g as n,M as o,D as p,_ as r,N as s,h as t,v as u,T as v,d as w,s as x,f as y};