@synnaxlabs/freighter 0.54.0 → 0.55.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/freighter.js CHANGED
@@ -85,77 +85,194 @@ var n = Object.defineProperty, r = (e, t) => {
85
85
  recursive: !0,
86
86
  recursiveInArray: !0,
87
87
  schema: void 0
88
- }, h = (e) => typeof e == "object" && !!e && !Array.isArray(e), g = (e) => e instanceof Uint8Array || e instanceof Number || e instanceof String, _ = (e) => typeof e == "object" && !!e && !Array.isArray(e), ee = class {
89
- contentType = "application/json";
90
- decoder;
91
- encoder;
92
- constructor() {
93
- this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
94
- }
95
- encode(e, t) {
96
- return this.encoder.encode(this.encodeString(e, t));
88
+ }, h = (e) => typeof e == "object" && !!e && !Array.isArray(e), g = (e) => e instanceof Uint8Array || e instanceof Number || e instanceof String, _ = (e) => typeof e == "object" && !!e && !Array.isArray(e), ee = (e) => {
89
+ if (typeof e != "object" || !e || Array.isArray(e)) return !1;
90
+ let t = Object.getPrototypeOf(e);
91
+ return t === Object.prototype || t === null;
92
+ }, te = (e, t) => {
93
+ let n = e;
94
+ for (let e of t) {
95
+ if (typeof n != "object" || !n) return {
96
+ present: !1,
97
+ value: void 0
98
+ };
99
+ let t = n;
100
+ if (!(e in t)) return {
101
+ present: !1,
102
+ value: void 0
103
+ };
104
+ n = t[e];
97
105
  }
98
- decode(e, t) {
99
- return this.decodeString(this.decoder.decode(e), t);
106
+ return {
107
+ present: !0,
108
+ value: n
109
+ };
110
+ }, ne = (e, t) => {
111
+ let n = Array.isArray(e), r = Array.isArray(t);
112
+ if (n !== r) return !1;
113
+ if (n && r) {
114
+ let n = e, r = t;
115
+ if (n.length !== r.length) return !1;
116
+ for (let e = 0; e < n.length; e++) if (!ne(n[e], r[e])) return !1;
117
+ return !0;
100
118
  }
101
- decodeString(e, t) {
102
- let n = f(JSON.parse(e), { schema: t });
103
- return t == null ? n : t.parse(n);
119
+ if (e == null || t == null || typeof e != "object" || typeof t != "object") return e === t;
120
+ if ("equals" in e) return e.equals(t);
121
+ let i = Object.keys(e), a = Object.keys(t);
122
+ if (i.length !== a.length) return !1;
123
+ for (let n of i) {
124
+ let r = e[n], i = t[n];
125
+ if (typeof r == "object" && typeof i == "object") {
126
+ if (!ne(r, i)) return !1;
127
+ } else if (r !== i) return !1;
104
128
  }
105
- encodeString(e, t) {
106
- let n = p((t == null ? e : t.parse(e)) ?? {}, { schema: t });
107
- return JSON.stringify(n, (e, t) => ArrayBuffer.isView(t) ? Array.from(t) : typeof t == "bigint" ? t.toString() : t);
129
+ return !0;
130
+ }, re = (e, t) => {
131
+ if (typeof e != "object" || !e) return e === t;
132
+ let n = Object.keys(e), r = Object.keys(t);
133
+ if (r.length > n.length) return !1;
134
+ for (let n of r) {
135
+ let r = e[n], i = t[n];
136
+ if (typeof r == "object" && typeof i == "object") {
137
+ if (!re(r, i)) return !1;
138
+ } else if (r !== i) return !1;
108
139
  }
109
- }, te = class {
110
- contentType = "text/csv";
111
- encode(e) {
112
- let t = this.encodeString(e);
113
- return new TextEncoder().encode(t);
140
+ return !0;
141
+ }, ie = (e, ...t) => {
142
+ if (t.length === 0) return e;
143
+ let n = t.shift();
144
+ if (_(e) && _(n)) for (let t in n) try {
145
+ _(n[t]) ? (t in e || Object.assign(e, { [t]: {} }), ie(e[t], n[t])) : Object.assign(e, { [t]: n[t] });
146
+ } catch (e) {
147
+ throw e instanceof TypeError ? TypeError(`.${t}: ${e.message}`, { cause: e }) : e;
114
148
  }
115
- decode(e, t) {
116
- let n = new TextDecoder().decode(e);
117
- return this.decodeString(n, t);
149
+ return ie(e, ...t);
150
+ }, ae = (e) => Object.getOwnPropertySymbols(globalThis).includes(e), oe = (e, t) => {
151
+ let n = Symbol.for(e);
152
+ if (!ae(n)) {
153
+ let e = t();
154
+ Object.defineProperty(globalThis, n, { value: e });
118
155
  }
119
- encodeString(e) {
120
- if (!Array.isArray(e) || e.length === 0 || !_(e[0])) throw Error("Payload must be an array of objects");
121
- let t = Object.keys(e[0]), n = [t.join(",")];
122
- return e.forEach((e) => {
123
- let r = t.map((t) => JSON.stringify(e[t] ?? ""));
124
- n.push(r.join(","));
125
- }), n.join("\n");
156
+ return () => globalThis[n];
157
+ }, v = /* @__PURE__ */ r({
158
+ Canceled: () => _e,
159
+ NONE: () => "nil",
160
+ NotImplemented: () => ve,
161
+ UNKNOWN: () => b,
162
+ Unknown: () => he,
163
+ createTyped: () => y,
164
+ decode: () => me,
165
+ encode: () => pe,
166
+ isTyped: () => le,
167
+ payloadZ: () => ge,
168
+ register: () => fe
169
+ }), se = "sy_x_error", ce = (e) => (t) => typeof t == "object" && t && "type" in t && typeof t.type == "string" ? t.type.startsWith(e) : t instanceof Error ? t.message.startsWith(e) : typeof t == "string" ? t.startsWith(e) : !1, y = (e) => class t extends Error {
170
+ static discriminator = se;
171
+ discriminator = t.discriminator;
172
+ static TYPE = e;
173
+ type = t.TYPE;
174
+ static matches = ce(e);
175
+ matches = t.matches;
176
+ constructor(e, n) {
177
+ super(e, n), this.name = t.TYPE;
126
178
  }
127
- decodeString(e, t) {
128
- let [n, ...r] = e.trim().split("\n").map((e) => e.trim());
129
- if (n.length === 0) return t == null ? {} : t.parse({});
130
- let i = n.split(",").map((e) => e.trim()), a = {};
131
- return i.forEach((e) => {
132
- a[e] = [];
133
- }), r.forEach((e) => {
134
- let t = e.split(",").map((e) => e.trim());
135
- i.forEach((e, n) => {
136
- let r = this.parseValue(t[n]);
137
- r != null && a[e].push(r);
138
- });
139
- }), t == null ? a : t.parse(a);
179
+ static sub(t) {
180
+ return y(`${e}.${t}`);
140
181
  }
141
- parseValue(e) {
142
- if (e == null || e.length === 0) return null;
143
- let t = Number(e);
144
- return isNaN(t) ? e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e : t;
182
+ }, le = (e) => {
183
+ if (typeof e != "object" || !e) return !1;
184
+ let t = e;
185
+ if (t.discriminator !== se) return !1;
186
+ if (!("type" in t)) throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);
187
+ return !0;
188
+ }, b = "unknown", ue = class {
189
+ providers = [];
190
+ register(e) {
191
+ this.providers.push(e);
145
192
  }
146
- }, ne = class {
147
- contentType = "text/plain";
148
193
  encode(e) {
149
- if (typeof e != "string") throw Error("TextCodec.encode payload must be a string");
150
- return new TextEncoder().encode(e);
194
+ if (e == null) return {
195
+ type: "nil",
196
+ data: ""
197
+ };
198
+ if (le(e)) for (let t of this.providers) {
199
+ let n = t.encode(e);
200
+ if (n != null) return n;
201
+ }
202
+ if (e instanceof Error) return {
203
+ type: b,
204
+ data: e.message
205
+ };
206
+ if (typeof e == "string") return {
207
+ type: b,
208
+ data: e
209
+ };
210
+ try {
211
+ return {
212
+ type: b,
213
+ data: JSON.stringify(e)
214
+ };
215
+ } catch {
216
+ return {
217
+ type: b,
218
+ data: "unable to encode error information"
219
+ };
220
+ }
151
221
  }
152
- decode(e, t) {
153
- let n = new TextDecoder().decode(e);
154
- return t == null ? n : t.parse(n);
222
+ decode(e) {
223
+ if (e == null || e.type === "nil") return null;
224
+ if (e.type === "unknown") return new he(e.data);
225
+ for (let t of this.providers) {
226
+ let n = t.decode(e);
227
+ if (n != null) return n;
228
+ }
229
+ return new he(e.data);
155
230
  }
156
- }, re = new ee();
157
- new te(), new ne();
158
- var v = (e) => typeof e == "object" && !!e && "value" in e, y = class {
231
+ }, de = oe("synnax-error-registry", () => new ue()), fe = ({ encode: e, decode: t }) => de().register({
232
+ encode: e,
233
+ decode: t
234
+ }), pe = (e) => de().encode(e), me = (e) => e == null ? null : de().decode(e), he = class extends y("unknown") {}, ge = t.object({
235
+ type: t.string(),
236
+ data: t.string()
237
+ }), _e = class extends y("canceled") {}, ve = class extends y("not_implemented") {}, ye = (e) => {
238
+ if (e.length === 0) return "<root>";
239
+ let t = "";
240
+ return e.forEach((e, n) => {
241
+ typeof e == "number" ? t += `[${e}]` : n === 0 ? t += String(e) : t += `.${String(e)}`;
242
+ }), t;
243
+ }, be = 200, xe = 10, Se = 8, x = (e, t = {}) => {
244
+ let n = t.maxStringLength ?? be, r = t.maxArrayLength ?? xe, i = t.maxDepth ?? Se, a = (e, t) => {
245
+ if (e === null) return null;
246
+ if (e === void 0) return "[undefined]";
247
+ let o = typeof e;
248
+ if (o === "string") {
249
+ let t = e;
250
+ return t.length > n ? `${t.slice(0, n)}…(+${t.length - n} chars)` : t;
251
+ }
252
+ if (o === "number" || o === "boolean") return e;
253
+ if (o === "bigint") return `${e.toString()}n`;
254
+ if (o === "symbol" || o === "function") return `[${o}]`;
255
+ if (Array.isArray(e)) {
256
+ if (t >= i) return `[Array(${e.length})]`;
257
+ let n = e.slice(0, r).map((e) => a(e, t + 1));
258
+ return e.length > r && n.push(`…(+${e.length - r} more)`), n;
259
+ }
260
+ if (ee(e)) {
261
+ if (t >= i) return "[Object]";
262
+ let n = {};
263
+ for (let [r, i] of Object.entries(e)) n[r] = a(i, t + 1);
264
+ return n;
265
+ }
266
+ if (e instanceof Date) return e.toISOString();
267
+ if (e instanceof Error) return `[Error: ${e.message}]`;
268
+ try {
269
+ return `[${Object.prototype.toString.call(e)}]`;
270
+ } catch {
271
+ return "[unknown]";
272
+ }
273
+ };
274
+ return a(e, 0);
275
+ }, Ce = (e, t = {}) => JSON.stringify(x(e, t), null, 2), S = (e) => typeof e == "object" && !!e && "value" in e, C = class {
159
276
  value;
160
277
  constructor(e) {
161
278
  this.value = e;
@@ -169,49 +286,255 @@ var v = (e) => typeof e == "object" && !!e && "value" in e, y = class {
169
286
  toString() {
170
287
  return this.value.toString();
171
288
  }
172
- }, ie = (e) => typeof e == "object" && !!e && "toString" in e, ae = (e, t = !1) => {
173
- let n = ie(e) ? "stringer" : typeof e, r;
174
- switch (n) {
175
- case "string":
176
- r = (e, t) => e.localeCompare(t);
177
- break;
178
- case "stringer":
179
- r = (e, t) => e.toString().localeCompare(t.toString());
180
- break;
181
- case "number":
182
- r = (e, t) => Number(e) - Number(t);
183
- break;
184
- case "bigint":
185
- r = (e, t) => BigInt(e) - BigInt(t) > 0n ? 1 : -1;
186
- break;
187
- case "boolean":
188
- r = (e, t) => Number(e) - Number(t);
189
- break;
190
- case "undefined":
191
- r = () => 0;
192
- break;
193
- default: return console.warn(`sortFunc: unknown type ${n}`), () => -1;
289
+ }, we = (e) => typeof e == "object" && !!e && "toString" in e, Te = (e) => e == null || typeof e != "object" && typeof e != "function", Ee = "value", De = "zod.parse", Oe = "✗", ke = 60, Ae = {
290
+ maxStringLength: 60,
291
+ maxArrayLength: 3,
292
+ maxDepth: 3
293
+ }, je = (e) => e.slice(0, -1), Me = (e) => {
294
+ switch (e.code) {
295
+ case "invalid_type": return `expected ${e.expected}`;
296
+ case "invalid_value": return `expected one of ${JSON.stringify(e.values)}`;
297
+ case "unrecognized_keys": return "unexpected key";
298
+ case "too_small": {
299
+ let t = e.inclusive === !1 ? ">" : ">=";
300
+ return `${e.origin} too small: expected ${t}${e.minimum}`;
301
+ }
302
+ case "too_big": {
303
+ let t = e.inclusive === !1 ? "<" : "<=";
304
+ return `${e.origin} too large: expected ${t}${e.maximum}`;
305
+ }
306
+ case "invalid_format": return `expected ${e.format} format`;
307
+ case "not_multiple_of": return `expected multiple of ${e.divisor}`;
308
+ case "custom": return e.message || "custom validation failed";
309
+ default: return e.message;
310
+ }
311
+ }, Ne = (e, t, n) => {
312
+ let r = JSON.stringify(x(t, n));
313
+ return `${Me(e)}, received ${r}`;
314
+ }, w = (e) => {
315
+ let t = 0;
316
+ for (let n of e) {
317
+ if (n.path.length > t && (t = n.path.length), n.code === "invalid_union" && "errors" in n) for (let e of n.errors) {
318
+ let n = w(e);
319
+ n > t && (t = n);
320
+ }
321
+ if ((n.code === "invalid_key" || n.code === "invalid_element") && "issues" in n) {
322
+ let e = w(n.issues);
323
+ e > t && (t = e);
324
+ }
194
325
  }
195
- return t ? oe(r) : r;
196
- }, oe = (e) => (t, n) => e(n, t), se = (e, t = 21) => (n = t) => {
197
- let r = "", i = n | 0;
198
- for (; i--;) r += e[Math.random() * e.length | 0];
199
- return r;
200
- }, ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", le = `0123456789${ce}`, ue = se(ce, 1), de = se(le, 10), fe = () => `${ue()}${de()}`, pe = (e, t) => (n) => n instanceof t || typeof n == "object" && !!n && "discriminator" in n && n.discriminator === e, me = 2 ** 12 - 1, he = 2 ** 16 - 1, ge = 2 ** 20 - 1, _e = -128, ve = -(2 ** 15), ye = 2 ** 15 - 1, be = -(2n ** 63n), b = 2n ** 63n - 1n, xe = -(2 ** 63), Se = 2 ** 63 - 1, x = (e) => (t, n) => {
326
+ return t;
327
+ }, T = (e, t = []) => {
328
+ let n = [];
329
+ for (let r of e) {
330
+ let e = [...t, ...r.path];
331
+ if (r.code === "invalid_union" && "errors" in r && r.errors.length > 0) {
332
+ let t = r.errors[0], i = w(t);
333
+ for (let e = 1; e < r.errors.length; e++) {
334
+ let n = w(r.errors[e]);
335
+ n > i && (t = r.errors[e], i = n);
336
+ }
337
+ n.push(...T(t, e));
338
+ continue;
339
+ }
340
+ if (r.code === "invalid_element" && "issues" in r && "key" in r && (typeof r.key == "string" || typeof r.key == "number")) {
341
+ n.push(...T(r.issues, [...e, r.key]));
342
+ continue;
343
+ }
344
+ if (r.code === "invalid_key" && "issues" in r) {
345
+ n.push(...T(r.issues, e));
346
+ continue;
347
+ }
348
+ n.push({
349
+ ...r,
350
+ path: e
351
+ });
352
+ }
353
+ return n;
354
+ }, Pe = (e) => {
355
+ let t = [];
356
+ for (let n of e) {
357
+ if (n.code === "unrecognized_keys" && "keys" in n && Array.isArray(n.keys)) {
358
+ for (let e of n.keys) t.push({
359
+ ...n,
360
+ path: [...n.path, e]
361
+ });
362
+ continue;
363
+ }
364
+ t.push(n);
365
+ }
366
+ return t;
367
+ }, Fe = (e, t, n, r) => {
368
+ let i = `${n} `, a = `${n + Oe} `, o = {
369
+ ...Ae,
370
+ ...r
371
+ };
372
+ if (Array.isArray(e)) {
373
+ let e = -1;
374
+ for (let n of t.keys()) {
375
+ let t = Number(n);
376
+ Number.isInteger(t) && t > e && (e = t);
377
+ }
378
+ let n = o.maxArrayLength ?? 3;
379
+ e >= n && (o = {
380
+ ...o,
381
+ maxArrayLength: e + 2
382
+ });
383
+ }
384
+ let s = x(e, o);
385
+ if (typeof s != "object" || !s) {
386
+ let e = JSON.stringify(s), n = t.values().next().value;
387
+ return [`${a}${e}${n ? ` × ${n.reason}` : ""}`];
388
+ }
389
+ let c = [], l = Array.isArray(s);
390
+ c.push(`${n}${l ? "[" : "{"}`);
391
+ let u = [];
392
+ if (l) {
393
+ let e = s;
394
+ for (let n = 0; n < e.length; n++) {
395
+ let r = t.get(String(n));
396
+ u.push({
397
+ content: JSON.stringify(e[n]),
398
+ mark: r && !r.missing ? r : void 0
399
+ });
400
+ }
401
+ } else {
402
+ let e = s;
403
+ for (let n of Object.keys(e)) {
404
+ let r = t.get(n);
405
+ u.push({
406
+ content: `"${n}": ${JSON.stringify(e[n])}`,
407
+ mark: r && !r.missing ? r : void 0
408
+ });
409
+ }
410
+ for (let [e, n] of t.entries()) n.missing && u.push({
411
+ content: `"${e}": <missing>`,
412
+ mark: n
413
+ });
414
+ }
415
+ let d = 0;
416
+ return u.forEach((e, t) => {
417
+ if (e.mark == null) return;
418
+ let n = +(t < u.length - 1), r = e.content.length + n;
419
+ r > d && r <= ke && (d = r);
420
+ }), u.forEach((e, t) => {
421
+ let n = t < u.length - 1 ? "," : "", r = e.content + n;
422
+ if (e.mark != null) {
423
+ let t = " ".repeat(Math.max(2, d - r.length + 2));
424
+ c.push(`${a}${r}${t}× ${e.mark.reason}`);
425
+ } else c.push(`${i}${r}`);
426
+ }), c.push(n + (l ? "]" : "}")), c;
427
+ }, Ie = "__root__", Le = (e, t, n) => {
428
+ let r = /* @__PURE__ */ new Map();
429
+ for (let t of e) {
430
+ let e = t.path.length === 0 ? Ie : `::${ye(je(t.path))}`, n = r.get(e);
431
+ n == null ? r.set(e, [t]) : n.push(t);
432
+ }
433
+ let i = [];
434
+ for (let [e, a] of r) {
435
+ if (e === Ie) {
436
+ i.push(a.map((e) => ` × ${Ne(e, t, n)}`).join("\n"));
437
+ continue;
438
+ }
439
+ let r = je(a[0].path), { present: o, value: s } = te(t, r);
440
+ if (!o) {
441
+ i.push(a.map((e) => ` at ${ye(e.path)}\n × ${Ne(e, t, n)}`).join("\n"));
442
+ continue;
443
+ }
444
+ let c = /* @__PURE__ */ new Map();
445
+ for (let e of a) {
446
+ let n = String(e.path[e.path.length - 1]), r = te(t, e.path);
447
+ c.set(n, {
448
+ reason: Me(e),
449
+ missing: !r.present
450
+ });
451
+ }
452
+ let l = r.length === 0, u = Fe(s, c, l ? " " : " ", n);
453
+ l ? i.push(u.join("\n")) : i.push([` at ${ye(r)}`, ...u].join("\n"));
454
+ }
455
+ return i.join("\n\n");
456
+ }, Re = (e, t) => {
457
+ let n = Object.entries(e);
458
+ return n.every(([, e]) => Te(e)) ? n.map(([e, t]) => `${e}=${typeof t == "string" ? t : String(t)}`).join(", ") : Ce(e, t);
459
+ }, ze = ({ issues: e, input: t, label: n, context: r, formatOptions: i }) => {
460
+ let a = i ?? {}, o = Pe(T(e)), s = [`Failed to parse ${n} (${o.length === 1 ? "1 issue" : `${o.length} issues`})`];
461
+ return s.push(Le(o, t, a)), r != null && Object.keys(r).length > 0 && s.push(` context: ${Re(r, a)}`), s.join("\n\n");
462
+ }, Be = class extends y(De) {
463
+ issues;
464
+ input;
465
+ label;
466
+ context;
467
+ constructor({ issues: e, input: t, label: n, context: r, cause: i, formatOptions: a }) {
468
+ super(ze({
469
+ issues: e,
470
+ input: t,
471
+ label: n,
472
+ context: r,
473
+ formatOptions: a
474
+ }), { cause: i }), this.issues = e, this.input = t, this.label = n, this.context = r;
475
+ }
476
+ toStatus() {
477
+ let e = {
478
+ input: x(this.input),
479
+ issues: this.issues
480
+ };
481
+ return this.context != null && (e.context = this.context), {
482
+ message: `Failed to parse ${this.label}`,
483
+ description: this.message,
484
+ details: e
485
+ };
486
+ }
487
+ };
488
+ fe({
489
+ encode: (e) => {
490
+ if (!Be.matches(e)) return null;
491
+ let t = e, n = {
492
+ label: t.label,
493
+ context: t.context,
494
+ issues: t.issues,
495
+ input: x(t.input)
496
+ };
497
+ return {
498
+ type: De,
499
+ data: JSON.stringify(n)
500
+ };
501
+ },
502
+ decode: (e) => {
503
+ if (e.type !== De) return null;
504
+ let t = JSON.parse(e.data);
505
+ return new Be({
506
+ issues: t.issues,
507
+ input: t.input,
508
+ label: t.label,
509
+ context: t.context
510
+ });
511
+ }
512
+ });
513
+ var Ve = (e, t, n = {}) => {
514
+ let r = e.safeParse(t);
515
+ if (r.success) return r.data;
516
+ throw new Be({
517
+ issues: r.error.issues,
518
+ input: t,
519
+ label: n.label ?? Ee,
520
+ context: n.context,
521
+ cause: r.error
522
+ });
523
+ }, He = 2 ** 12 - 1, Ue = 2 ** 16 - 1, We = 2 ** 20 - 1, Ge = -128, Ke = -(2 ** 15), qe = 2 ** 15 - 1, Je = -(2n ** 63n), E = 2n ** 63n - 1n, Ye = -(2 ** 63), Xe = 2 ** 63 - 1, D = (e) => (t, n) => {
201
524
  if (typeof t == "bigint") {
202
- if (Ce(n)) return e(t, BigInt(n));
525
+ if (Ze(n)) return e(t, BigInt(n));
203
526
  let r = e(Number(t), Number(n));
204
527
  return typeof r == "number" ? BigInt(Math.round(r)) : r;
205
528
  }
206
529
  return e(Number(t), Number(n));
207
- }, S = x((e, t) => e - t), C = x((e, t) => e + t), Ce = (e) => typeof e == "bigint" ? !0 : Number.isInteger(e), w = x((e, t) => e * t), T = x((e, t) => e / t), we = t.tuple([t.number(), t.number()]), Te = t.enum(["x", "y"]), Ee = [
530
+ }, O = D((e, t) => e - t), k = D((e, t) => e + t), Ze = (e) => typeof e == "bigint" ? !0 : Number.isInteger(e), A = D((e, t) => e * t), j = D((e, t) => e / t), Qe = t.tuple([t.number(), t.number()]), $e = t.enum(["x", "y"]), et = [
208
531
  "top",
209
532
  "right",
210
533
  "bottom",
211
534
  "left"
212
535
  ];
213
- t.enum(Ee);
214
- var De = ["left", "right"], Oe = t.enum(De), ke = t.enum(["top", "bottom"]), E = ["center"], Ae = t.enum(E);
536
+ t.enum(et);
537
+ var tt = ["left", "right"], nt = t.enum(tt), rt = t.enum(["top", "bottom"]), it = ["center"], at = t.enum(it);
215
538
  t.enum([
216
539
  "top",
217
540
  "right",
@@ -223,13 +546,13 @@ t.enum([
223
546
  "center",
224
547
  "end"
225
548
  ]), t.enum(["first", "last"]);
226
- var je = t.object({
549
+ var ot = t.object({
227
550
  clientX: t.number(),
228
551
  clientY: t.number()
229
- }), Me = t.object({
552
+ }), st = t.object({
230
553
  width: t.number(),
231
554
  height: t.number()
232
- }), Ne = t.object({
555
+ }), ct = t.object({
233
556
  signedWidth: t.number(),
234
557
  signedHeight: t.number()
235
558
  });
@@ -239,14 +562,14 @@ t.object({
239
562
  }), t.enum([
240
563
  "x",
241
564
  "y",
242
- ...Ee,
243
- ...E
565
+ ...et,
566
+ ...it
244
567
  ]), t.union([
245
- Te,
246
- t.enum([...Ee, ...E]),
568
+ $e,
569
+ t.enum([...et, ...it]),
247
570
  t.instanceof(String)
248
571
  ]);
249
- var D = (e, t, n) => {
572
+ var M = (e, t, n) => {
250
573
  let r = {};
251
574
  if (typeof t == "object" && (n = t, t = void 0), n = {
252
575
  makeValid: !0,
@@ -256,7 +579,7 @@ var D = (e, t, n) => {
256
579
  if (e.length !== 2) throw Error("bounds: expected array of length 2");
257
580
  [r.lower, r.upper] = e;
258
581
  } else r.lower = e.lower, r.upper = e.upper;
259
- return n?.makeValid ? Pe(r) : r;
582
+ return n?.makeValid ? lt(r) : r;
260
583
  };
261
584
  Object.freeze({
262
585
  lower: 0,
@@ -271,451 +594,87 @@ Object.freeze({
271
594
  lower: -1,
272
595
  upper: 1
273
596
  });
274
- var Pe = (e) => e.lower > e.upper ? {
597
+ var lt = (e) => e.lower > e.upper ? {
275
598
  lower: e.upper,
276
599
  upper: e.lower
277
- } : e, Fe = (e, t) => {
278
- let n = D(e);
600
+ } : e, ut = (e, t) => {
601
+ let n = M(e);
279
602
  return t < n.lower ? n.lower : t >= n.upper ? n.upper - (typeof n.upper == "number" ? 1 : 1n) : t;
280
603
  };
281
- t.object({
282
- x: Oe.or(Ae),
283
- y: ke.or(Ae)
284
- });
285
- var Ie = t.object({
286
- x: Oe,
287
- y: ke
288
- }), O = Object.freeze({
289
- x: "left",
290
- y: "top"
291
- }), Le = Object.freeze({
292
- x: "right",
293
- y: "top"
294
- }), Re = Object.freeze({
295
- x: "left",
296
- y: "bottom"
297
- }), ze = Object.freeze({
298
- x: "right",
299
- y: "bottom"
300
- }), Be = Object.freeze({
301
- x: "center",
302
- y: "center"
303
- }), Ve = Object.freeze({
304
- x: "center",
305
- y: "top"
306
- }), He = Object.freeze({
307
- x: "center",
308
- y: "bottom"
309
- }), Ue = Object.freeze({
310
- x: "right",
311
- y: "center"
312
- }), We = Object.freeze({
313
- x: "left",
314
- y: "center"
315
- });
316
- Object.freeze([
317
- We,
318
- Ue,
319
- Ve,
320
- He,
321
- O,
322
- Le,
323
- Re,
324
- ze,
325
- Be
326
- ]);
327
- var Ge = (e, t) => e.x === t.x && e.y === t.y, Ke = (e) => [e.x, e.y];
328
- t.enum([
329
- "top",
330
- "right",
331
- "bottom",
332
- "left"
333
- ]);
334
- var k = t.object({
335
- x: t.number(),
336
- y: t.number()
337
- }), qe = t.union([
338
- t.number(),
339
- k,
340
- we,
341
- Me,
342
- Ne,
343
- je
344
- ]), A = (e, t) => {
345
- if (typeof e == "string") {
346
- if (t === void 0) throw Error("The y coordinate must be given.");
347
- return e === "x" ? {
348
- x: t,
349
- y: 0
350
- } : {
351
- x: 0,
352
- y: t
353
- };
354
- }
355
- return typeof e == "number" ? {
356
- x: e,
357
- y: t ?? e
358
- } : Array.isArray(e) ? {
359
- x: e[0],
360
- y: e[1]
361
- } : "signedWidth" in e ? {
362
- x: e.signedWidth,
363
- y: e.signedHeight
364
- } : "clientX" in e ? {
365
- x: e.clientX,
366
- y: e.clientY
367
- } : "width" in e ? {
368
- x: e.width,
369
- y: e.height
370
- } : {
371
- x: e.x,
372
- y: e.y
373
- };
374
- }, j = Object.freeze({
375
- x: 0,
376
- y: 0
377
- });
378
- Object.freeze({
379
- x: 1,
380
- y: 1
381
- }), Object.freeze({
382
- x: Infinity,
383
- y: Infinity
384
- }), Object.freeze({
385
- x: NaN,
386
- y: NaN
387
- });
388
- var Je = (e, t) => {
389
- let n = A(e);
390
- return {
391
- x: n.x + t,
392
- y: n.y
393
- };
394
- }, Ye = (e, t) => {
395
- let n = A(e);
396
- return {
397
- x: n.x,
398
- y: n.y + t
399
- };
400
- }, Xe = (e, t, n, ...r) => {
401
- if (typeof t == "string") {
402
- if (typeof n != "number") throw Error("The value must be a number.");
403
- return t === "x" ? Je(e, n) : Ye(e, n);
404
- }
405
- if (typeof t == "object" && "x" in t && typeof t.x == "string") {
406
- let r = A(n), i = A(e);
407
- return t.x === "left" ? r.x = -r.x : t.x === "center" && (r.x = 0), t.y === "top" ? r.y = -r.y : t.y === "center" && (r.y = 0), {
408
- x: i.x + r.x,
409
- y: i.y + r.y
410
- };
411
- }
412
- return [
413
- e,
414
- t,
415
- n ?? j,
416
- ...r
417
- ].reduce((e, t) => {
418
- let n = A(t);
419
- return {
420
- x: e.x + n.x,
421
- y: e.y + n.y
422
- };
423
- }, j);
424
- }, M = t.union([t.number(), t.string()]);
425
- t.object({
426
- top: M,
427
- left: M,
428
- width: M,
429
- height: M
430
- }), t.object({
431
- left: t.number(),
432
- top: t.number(),
433
- right: t.number(),
434
- bottom: t.number()
435
- }), t.object({
436
- one: k,
437
- two: k,
438
- root: Ie
439
- });
440
- var N = (e, t, n = 0, r = 0, i) => {
441
- let a = {
442
- one: { ...j },
443
- two: { ...j },
444
- root: i ?? O
445
- };
446
- if (typeof e == "number") {
447
- if (typeof t != "number") throw Error("Box constructor called with invalid arguments");
448
- return a.one = {
449
- x: e,
450
- y: t
451
- }, a.two = {
452
- x: a.one.x + n,
453
- y: a.one.y + r
454
- }, a;
455
- }
456
- return "one" in e && "two" in e && "root" in e ? {
457
- ...e,
458
- root: i ?? e.root
459
- } : ("getBoundingClientRect" in e && (e = e.getBoundingClientRect()), "left" in e ? (a.one = {
460
- x: e.left,
461
- y: e.top
462
- }, a.two = {
463
- x: e.right,
464
- y: e.bottom
465
- }, a) : (a.one = e, t == null ? a.two = {
466
- x: a.one.x + n,
467
- y: a.one.y + r
468
- } : typeof t == "number" ? a.two = {
469
- x: a.one.x + t,
470
- y: a.one.y + n
471
- } : "width" in t ? a.two = {
472
- x: a.one.x + t.width,
473
- y: a.one.y + t.height
474
- } : "signedWidth" in t ? a.two = {
475
- x: a.one.x + t.signedWidth,
476
- y: a.one.y + t.signedHeight
477
- } : a.two = t, a));
478
- }, Ze = (e, t) => {
479
- let n = N(e);
480
- return {
481
- x: t.x === "center" ? nt(n).x : Qe(n, t.x),
482
- y: t.y === "center" ? nt(n).y : Qe(n, t.y)
483
- };
484
- }, Qe = (e, t) => {
485
- let n = N(e), r = Ke(n.root).includes(t) ? Math.min : Math.max;
486
- return De.includes(t) ? r(n.one.x, n.two.x) : r(n.one.y, n.two.y);
487
- }, $e = (e) => {
488
- let t = N(e);
489
- return t.two.x - t.one.x;
490
- }, et = (e) => {
491
- let t = N(e);
492
- return t.two.y - t.one.y;
493
- }, tt = (e) => Ze(e, O), nt = (e) => Xe(tt(e), {
494
- x: $e(e) / 2,
495
- y: et(e) / 2
496
- }), P = (e) => {
497
- let t = N(e);
498
- return {
499
- lower: t.one.x,
500
- upper: t.two.x
501
- };
502
- }, rt = (e) => {
503
- let t = N(e);
504
- return {
505
- lower: t.one.y,
506
- upper: t.two.y
507
- };
508
- }, it = (e) => typeof e != "object" || !e ? !1 : "one" in e && "two" in e && "root" in e;
509
- t.union([
510
- Me,
511
- Ne,
512
- k,
513
- we
514
- ]);
515
- var at = (e, t, n) => t !== void 0 && e < t ? t : n !== void 0 && e > n ? n : e;
516
- t.object({
517
- offset: qe,
518
- scale: qe
519
- }), t.object({
520
- offset: t.number(),
521
- scale: t.number()
522
- });
523
- var ot = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r + e], st = (e) => (t, n, r, i) => [t, i ? r / e : r * e], ct = (e) => (t, n, r) => {
524
- if (t === null) return [e, r];
525
- let { lower: i, upper: a } = t, { lower: o, upper: s } = e, c = a - i, l = s - o;
526
- return n === "dimension" ? [e, l / c * r] : [e, (r - i) * (l / c) + o];
527
- }, lt = (e) => (t, n, r) => [e, r], ut = () => (e, t, n) => {
528
- if (e === null) throw Error("cannot invert without bounds");
529
- if (t === "dimension") return [e, n];
530
- let { lower: r, upper: i } = e;
531
- return [e, i - (n - r)];
532
- }, dt = (e) => (t, n, r) => {
533
- let { lower: i, upper: a } = e;
534
- return r = at(r, i, a), [t, r];
535
- }, ft = class e {
536
- ops = [];
537
- currBounds = null;
538
- currType = null;
539
- reversed = !1;
604
+ t.int().min(Ge).max(127), t.int().min(Ke).max(qe), t.int().min(Ye).max(Xe);
605
+ var dt = t.int().min(0).max(255);
606
+ t.int().min(0).max(He), t.int().min(0).max(Ue), t.int().min(0).max(We);
607
+ var ft = class {
608
+ contentType = "application/json";
609
+ decoder;
610
+ encoder;
540
611
  constructor() {
541
- this.ops = [];
542
- }
543
- static translate(t) {
544
- return new e().translate(t);
545
- }
546
- static magnify(t) {
547
- return new e().magnify(t);
548
- }
549
- static scale(t, n) {
550
- return new e().scale(t, n);
551
- }
552
- translate(e) {
553
- let t = this.new(), n = ot(e);
554
- return n.type = "translate", t.ops.push(n), t;
555
- }
556
- magnify(e) {
557
- let t = this.new(), n = st(e);
558
- return n.type = "magnify", t.ops.push(n), t;
559
- }
560
- scale(e, t) {
561
- let n = D(e, t), r = this.new(), i = ct(n);
562
- return i.type = "scale", r.ops.push(i), r;
563
- }
564
- clamp(e, t) {
565
- let n = D(e, t), r = this.new(), i = dt(n);
566
- return i.type = "clamp", r.ops.push(i), r;
567
- }
568
- reBound(e, t) {
569
- let n = D(e, t), r = this.new(), i = lt(n);
570
- return i.type = "re-bound", r.ops.push(i), r;
571
- }
572
- invert() {
573
- let e = ut();
574
- e.type = "invert";
575
- let t = this.new();
576
- return t.ops.push(e), t;
577
- }
578
- pos(e) {
579
- return this.exec("position", e);
580
- }
581
- dim(e) {
582
- return this.exec("dimension", e);
583
- }
584
- new() {
585
- let t = new e();
586
- return t.ops = this.ops.slice(), t.reversed = this.reversed, t;
587
- }
588
- exec(e, t) {
589
- return this.currBounds = null, this.ops.reduce(([t, n], r) => r(t, e, n, this.reversed), [null, t])[1];
590
- }
591
- reverse() {
592
- let e = this.new();
593
- e.ops.reverse();
594
- let t = [];
595
- return e.ops.forEach((n, r) => {
596
- if (n.type === "scale" || t.some(([e, t]) => r >= e && r <= t)) return;
597
- let i = e.ops.findIndex((e, t) => e.type === "scale" && t > r);
598
- i !== -1 && t.push([r, i]);
599
- }), t.forEach(([t, n]) => {
600
- let r = e.ops.slice(t, n);
601
- r.unshift(e.ops[n]), e.ops.splice(t, n - t + 1, ...r);
602
- }), e.reversed = !e.reversed, e;
603
- }
604
- get transform() {
605
- return {
606
- scale: this.dim(1),
607
- offset: this.pos(0)
608
- };
609
- }
610
- static IDENTITY = new e();
611
- };
612
- (class e {
613
- x;
614
- y;
615
- currRoot;
616
- constructor(e = new ft(), t = new ft(), n = null) {
617
- this.x = e, this.y = t, this.currRoot = n;
618
- }
619
- static translate(t, n) {
620
- return new e().translate(t, n);
621
- }
622
- static translateX(t) {
623
- return new e().translateX(t);
624
- }
625
- static translateY(t) {
626
- return new e().translateY(t);
627
- }
628
- static clamp(t) {
629
- return new e().clamp(t);
630
- }
631
- static magnify(t) {
632
- return new e().magnify(t);
633
- }
634
- static scale(t) {
635
- return new e().scale(t);
636
- }
637
- static reBound(t) {
638
- return new e().reBound(t);
639
- }
640
- translate(e, t) {
641
- let n = A(e, t), r = this.copy();
642
- return r.x = this.x.translate(n.x), r.y = this.y.translate(n.y), r;
643
- }
644
- translateX(e) {
645
- let t = this.copy();
646
- return t.x = this.x.translate(e), t;
647
- }
648
- translateY(e) {
649
- let t = this.copy();
650
- return t.y = this.y.translate(e), t;
651
- }
652
- magnify(e) {
653
- let t = this.copy();
654
- return t.x = this.x.magnify(e.x), t.y = this.y.magnify(e.y), t;
612
+ this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
655
613
  }
656
- scale(e) {
657
- let t = this.copy();
658
- if (it(e)) {
659
- let n = this.currRoot;
660
- return t.currRoot = e.root, n != null && !Ge(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(P(e)), t.y = t.y.scale(rt(e)), t;
661
- }
662
- return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
614
+ encode(e, t) {
615
+ return this.encoder.encode(this.encodeString(e, t));
663
616
  }
664
- reBound(e) {
665
- let t = this.copy();
666
- return t.x = this.x.reBound(P(e)), t.y = this.y.reBound(rt(e)), t;
617
+ decode(e, t) {
618
+ return this.decodeString(this.decoder.decode(e), t);
667
619
  }
668
- clamp(e) {
669
- let t = this.copy();
670
- return t.x = this.x.clamp(P(e)), t.y = this.y.clamp(rt(e)), t;
620
+ decodeString(e, t) {
621
+ let n = f(JSON.parse(e), { schema: t });
622
+ return t == null ? n : Ve(t, n);
671
623
  }
672
- copy() {
673
- let t = new e();
674
- return t.currRoot = this.currRoot, t.x = this.x, t.y = this.y, t;
624
+ encodeString(e, t) {
625
+ let n = p((t == null ? e : Ve(t, e)) ?? {}, { schema: t });
626
+ return JSON.stringify(n, (e, t) => ArrayBuffer.isView(t) ? Array.from(t) : typeof t == "bigint" ? t.toString() : t);
675
627
  }
676
- reverse() {
677
- let e = this.copy();
678
- return e.x = this.x.reverse(), e.y = this.y.reverse(), e;
628
+ }, pt = class {
629
+ contentType = "text/csv";
630
+ encode(e) {
631
+ let t = this.encodeString(e);
632
+ return new TextEncoder().encode(t);
679
633
  }
680
- pos(e) {
681
- return {
682
- x: this.x.pos(e.x),
683
- y: this.y.pos(e.y)
684
- };
634
+ decode(e, t) {
635
+ let n = new TextDecoder().decode(e);
636
+ return this.decodeString(n, t);
685
637
  }
686
- dim(e) {
687
- return {
688
- x: this.x.dim(e.x),
689
- y: this.y.dim(e.y)
690
- };
638
+ encodeString(e) {
639
+ if (!Array.isArray(e) || e.length === 0 || !_(e[0])) throw Error("Payload must be an array of objects");
640
+ let t = Object.keys(e[0]), n = [t.join(",")];
641
+ return e.forEach((e) => {
642
+ let r = t.map((t) => JSON.stringify(e[t] ?? ""));
643
+ n.push(r.join(","));
644
+ }), n.join("\n");
691
645
  }
692
- box(e) {
693
- return N(this.pos(e.one), this.pos(e.two), 0, 0, this.currRoot ?? e.root);
646
+ decodeString(e, t) {
647
+ let [n, ...r] = e.trim().split("\n").map((e) => e.trim());
648
+ if (n.length === 0) return t == null ? {} : t.parse({});
649
+ let i = n.split(",").map((e) => e.trim()), a = {};
650
+ return i.forEach((e) => {
651
+ a[e] = [];
652
+ }), r.forEach((e) => {
653
+ let t = e.split(",").map((e) => e.trim());
654
+ i.forEach((e, n) => {
655
+ let r = this.parseValue(t[n]);
656
+ r != null && a[e].push(r);
657
+ });
658
+ }), t == null ? a : t.parse(a);
694
659
  }
695
- get transform() {
696
- return {
697
- scale: this.dim({
698
- x: 1,
699
- y: 1
700
- }),
701
- offset: this.pos({
702
- x: 0,
703
- y: 0
704
- })
705
- };
660
+ parseValue(e) {
661
+ if (e == null || e.length === 0) return null;
662
+ let t = Number(e);
663
+ return isNaN(t) ? e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e : t;
706
664
  }
707
- static IDENTITY = new e();
708
- }), k.extend({
709
- root: Ie,
710
- units: e.object({
711
- x: e.enum(["px", "decimal"]),
712
- y: e.enum(["px", "decimal"])
713
- })
714
- }).partial({
715
- root: !0,
716
- units: !0
717
- });
718
- var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
665
+ }, mt = class {
666
+ contentType = "text/plain";
667
+ encode(e) {
668
+ if (typeof e != "string") throw Error("TextCodec.encode payload must be a string");
669
+ return new TextEncoder().encode(e);
670
+ }
671
+ decode(e, t) {
672
+ let n = new TextDecoder().decode(e);
673
+ return t == null ? n : t.parse(n);
674
+ }
675
+ }, ht = new ft();
676
+ new pt(), new mt();
677
+ var gt = 365, N = 30, _t = t.union([
719
678
  t.tuple([t.int()]),
720
679
  t.tuple([t.int(), t.int().min(1).max(12)]),
721
680
  t.tuple([
@@ -723,20 +682,20 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
723
682
  t.int().min(1).max(12),
724
683
  t.int().min(1).max(31)
725
684
  ])
726
- ]), gt = (e, t) => {
727
- let n = new I(t);
685
+ ]), vt = (e, t) => {
686
+ let n = new P(t);
728
687
  if (![
729
- L.DAY,
730
- L.HOUR,
731
- L.MINUTE,
732
- L.SECOND,
733
- L.MILLISECOND,
734
- L.MICROSECOND,
735
- L.NANOSECOND
688
+ F.DAY,
689
+ F.HOUR,
690
+ F.MINUTE,
691
+ F.SECOND,
692
+ F.MILLISECOND,
693
+ F.MICROSECOND,
694
+ F.NANOSECOND
736
695
  ].some((e) => e.equals(n))) throw Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");
737
696
  let r = e.valueOf() % n.valueOf();
738
- return e instanceof I ? new I(r) : new L(r);
739
- }, I = class e extends y {
697
+ return e instanceof P ? new P(r) : new F(r);
698
+ }, P = class e extends C {
740
699
  constructor(t, n = "UTC") {
741
700
  if (t == null) super(e.now().valueOf());
742
701
  else if (t instanceof Date) super(BigInt(t.getTime()) * e.MILLISECOND.valueOf());
@@ -744,7 +703,7 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
744
703
  else if (Array.isArray(t)) super(e.parseDate(t));
745
704
  else {
746
705
  let r = 0n;
747
- t instanceof Number && (t = t.valueOf()), n === "local" && (r = e.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = t === Se ? b : Math.trunc(t) : (isNaN(t) && (t = 0), t = t === Infinity ? e.MAX : e.MIN)), v(t) && (t = t.value), super(BigInt(t.valueOf()) + r);
706
+ t instanceof Number && (t = t.valueOf()), n === "local" && (r = e.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = t === Xe ? E : Math.trunc(t) : (isNaN(t) && (t = 0), t = t === Infinity ? e.MAX : e.MIN)), S(t) && (t = t.value), super(BigInt(t.valueOf()) + r);
748
707
  }
749
708
  }
750
709
  static parseDate([t = 1970, n = 1, r = 1]) {
@@ -778,7 +737,7 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
778
737
  }
779
738
  toISOString(t = "UTC") {
780
739
  if (t === "UTC") return this.date().toISOString();
781
- let n = this.date(), r = new L(BigInt(n.getTimezoneOffset()) * e.MINUTE.valueOf());
740
+ let n = this.date(), r = new F(BigInt(n.getTimezoneOffset()) * e.MINUTE.valueOf());
782
741
  return this.sub(r).date().toISOString();
783
742
  }
784
743
  timeString(e = !1, t = "UTC") {
@@ -790,7 +749,7 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
790
749
  return `${e.toLocaleString("default", { month: "short" })} ${e.toLocaleString("default", { day: "numeric" })}`;
791
750
  }
792
751
  static get utcOffset() {
793
- return new L(BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * e.MINUTE.valueOf());
752
+ return new F(BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * e.MINUTE.valueOf());
794
753
  }
795
754
  static since(t) {
796
755
  return new e().span(t);
@@ -805,7 +764,7 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
805
764
  return this.range(e).span;
806
765
  }
807
766
  range(e) {
808
- return new B(this, e).makeValid();
767
+ return new L(this, e).makeValid();
809
768
  }
810
769
  spanRange(e) {
811
770
  return this.range(this.add(e)).makeValid();
@@ -826,22 +785,22 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
826
785
  return this.valueOf() <= new e(t).valueOf();
827
786
  }
828
787
  add(t) {
829
- return new e(C(this.valueOf(), new L(t).valueOf()));
788
+ return new e(k(this.valueOf(), new F(t).valueOf()));
830
789
  }
831
790
  sub(t) {
832
- return new e(S(this.valueOf(), new L(t).valueOf()));
791
+ return new e(O(this.valueOf(), new F(t).valueOf()));
833
792
  }
834
793
  get hours() {
835
- return Number(this.valueOf()) / Number(L.HOUR.valueOf());
794
+ return Number(this.valueOf()) / Number(F.HOUR.valueOf());
836
795
  }
837
796
  get minutes() {
838
- return Number(this.valueOf()) / Number(L.MINUTE.valueOf());
797
+ return Number(this.valueOf()) / Number(F.MINUTE.valueOf());
839
798
  }
840
799
  get days() {
841
- return Number(this.valueOf()) / Number(L.DAY.valueOf());
800
+ return Number(this.valueOf()) / Number(F.DAY.valueOf());
842
801
  }
843
802
  get seconds() {
844
- return Number(this.valueOf()) / Number(L.SECOND.valueOf());
803
+ return Number(this.valueOf()) / Number(F.SECOND.valueOf());
845
804
  }
846
805
  get milliseconds() {
847
806
  return Number(this.valueOf()) / Number(e.MILLISECOND.valueOf());
@@ -963,16 +922,16 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
963
922
  }
964
923
  }
965
924
  remainder(e) {
966
- return gt(this, e);
925
+ return vt(this, e);
967
926
  }
968
927
  get isToday() {
969
- return this.truncate(L.DAY).equals(e.now().truncate(L.DAY));
928
+ return this.truncate(F.DAY).equals(e.now().truncate(F.DAY));
970
929
  }
971
930
  truncate(e) {
972
931
  return this.sub(this.remainder(e));
973
932
  }
974
933
  formatBySpan(e) {
975
- return e.greaterThanOrEqual(L.days(30)) ? "shortDate" : e.greaterThanOrEqual(L.DAY) ? "dateTime" : e.greaterThanOrEqual(L.HOUR) ? "time" : e.greaterThanOrEqual(L.SECOND) ? "preciseTime" : "ISOTime";
934
+ return e.greaterThanOrEqual(F.days(30)) ? "shortDate" : e.greaterThanOrEqual(F.DAY) ? "dateTime" : e.greaterThanOrEqual(F.HOUR) ? "time" : e.greaterThanOrEqual(F.SECOND) ? "preciseTime" : "ISOTime";
976
935
  }
977
936
  static now() {
978
937
  return new e(/* @__PURE__ */ new Date());
@@ -1021,7 +980,7 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1021
980
  return e.hours(t * 24, n);
1022
981
  }
1023
982
  static DAY = e.days(1);
1024
- static MAX = new e(b);
983
+ static MAX = new e(E);
1025
984
  static MIN = new e(0);
1026
985
  static ZERO = new e(0);
1027
986
  static z = t.union([
@@ -1031,21 +990,21 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1031
990
  t.number().transform((t) => new e(t)),
1032
991
  t.bigint().transform((t) => new e(t)),
1033
992
  t.date().transform((t) => new e(t)),
1034
- t.custom((e) => e instanceof L).transform((t) => new e(t)),
1035
- ht.transform((t) => new e(t))
993
+ t.custom((e) => e instanceof F).transform((t) => new e(t)),
994
+ _t.transform((t) => new e(t))
1036
995
  ]);
1037
996
  static sort(e, t) {
1038
997
  return Number(e.valueOf() - t.valueOf());
1039
998
  }
1040
- }, L = class e extends y {
999
+ }, F = class e extends C {
1041
1000
  constructor(e) {
1042
- typeof e == "number" && (e = Math.trunc(e.valueOf())), v(e) && (e = e.value), super(BigInt(e.valueOf()));
1001
+ typeof e == "number" && (e = Math.trunc(e.valueOf())), S(e) && (e = e.value), super(BigInt(e.valueOf()));
1043
1002
  }
1044
1003
  static fromSeconds(t) {
1045
- return t instanceof e ? t : t instanceof R ? t.period : t instanceof I ? new e(t) : (v(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.seconds(t) : new e(t));
1004
+ return t instanceof e ? t : t instanceof yt ? t.period : t instanceof P ? new e(t) : (S(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.seconds(t) : new e(t));
1046
1005
  }
1047
1006
  static fromMilliseconds(t) {
1048
- return t instanceof e ? t : t instanceof R ? t.period : t instanceof I ? new e(t) : (v(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.milliseconds(t) : new e(t));
1007
+ return t instanceof e ? t : t instanceof yt ? t.period : t instanceof P ? new e(t) : (S(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.milliseconds(t) : new e(t));
1049
1008
  }
1050
1009
  valueOf() {
1051
1010
  return this.value;
@@ -1063,7 +1022,7 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1063
1022
  return this.valueOf() >= new e(t).valueOf();
1064
1023
  }
1065
1024
  remainder(e) {
1066
- return gt(this, e);
1025
+ return vt(this, e);
1067
1026
  }
1068
1027
  truncate(t) {
1069
1028
  return new e(BigInt(Math.trunc(Number(this.valueOf() / t.valueOf()))) * t.valueOf());
@@ -1077,23 +1036,23 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1077
1036
  let t = new e(this.valueOf() < 0n ? -this.valueOf() : this.valueOf()), n = this.valueOf() < 0n;
1078
1037
  if (t.valueOf() === 0n) return "0s";
1079
1038
  if (t.lessThan(e.SECOND)) return "< 1s";
1080
- let r = t.days, i = t.hours, a = t.minutes, o = t.seconds, s = Math.floor(r / mt), c = Math.floor(r / F), l = Math.floor(r / 7), u = Math.floor(r), d = Math.floor(i), f = Math.floor(a), p = Math.floor(o), m = n ? "-" : "";
1039
+ let r = t.days, i = t.hours, a = t.minutes, o = t.seconds, s = Math.floor(r / gt), c = Math.floor(r / N), l = Math.floor(r / 7), u = Math.floor(r), d = Math.floor(i), f = Math.floor(a), p = Math.floor(o), m = n ? "-" : "";
1081
1040
  if (s >= 1) {
1082
1041
  let e = `${s}y`;
1083
1042
  if (s < 2) {
1084
- let t = Math.floor(r % mt / F);
1043
+ let t = Math.floor(r % gt / N);
1085
1044
  t > 0 && (e += ` ${t}mo`);
1086
1045
  }
1087
1046
  return m + e;
1088
1047
  }
1089
- if (l >= 1 && r < F && r % 7 == 0) {
1048
+ if (l >= 1 && r < N && r % 7 == 0) {
1090
1049
  let e = `${l}w`, t = Math.floor(r % 7), n = Math.floor(i - l * 7 * 24);
1091
1050
  return l < 2 && (t > 0 ? e += ` ${t}d` : n > 0 && n < 24 && (e += ` ${n}h`)), m + e;
1092
1051
  }
1093
1052
  if (c >= 1) {
1094
1053
  let e = `${c}mo`;
1095
1054
  if (c < 3) {
1096
- let t = Math.floor(r % F);
1055
+ let t = Math.floor(r % N);
1097
1056
  t > 0 && (e += ` ${t}d`);
1098
1057
  }
1099
1058
  return m + e;
@@ -1125,10 +1084,10 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1125
1084
  return `${m}${p}s`;
1126
1085
  }
1127
1086
  mult(t) {
1128
- return new e(w(this.valueOf(), t));
1087
+ return new e(A(this.valueOf(), t));
1129
1088
  }
1130
1089
  div(t) {
1131
- return new e(T(this.valueOf(), t));
1090
+ return new e(j(this.valueOf(), t));
1132
1091
  }
1133
1092
  get days() {
1134
1093
  return Number(this.valueOf()) / Number(e.DAY.valueOf());
@@ -1163,35 +1122,39 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1163
1122
  sub(t) {
1164
1123
  return new e(this.valueOf() - new e(t).valueOf());
1165
1124
  }
1125
+ abs() {
1126
+ let t = this.valueOf();
1127
+ return new e(t < 0n ? -t : t);
1128
+ }
1166
1129
  static nanoseconds(t = 1) {
1167
1130
  return new e(t);
1168
1131
  }
1169
1132
  static NANOSECOND = e.nanoseconds(1);
1170
1133
  static microseconds(t = 1) {
1171
- return e.nanoseconds(w(t, 1e3));
1134
+ return e.nanoseconds(A(t, 1e3));
1172
1135
  }
1173
1136
  static MICROSECOND = e.microseconds(1);
1174
1137
  static milliseconds(t = 1) {
1175
- return e.microseconds(w(t, 1e3));
1138
+ return e.microseconds(A(t, 1e3));
1176
1139
  }
1177
1140
  static MILLISECOND = e.milliseconds(1);
1178
1141
  static seconds(t = 1) {
1179
- return e.milliseconds(w(t, 1e3));
1142
+ return e.milliseconds(A(t, 1e3));
1180
1143
  }
1181
1144
  static SECOND = e.seconds(1);
1182
1145
  static minutes(t = 1) {
1183
- return e.seconds(w(t, 60));
1146
+ return e.seconds(A(t, 60));
1184
1147
  }
1185
1148
  static MINUTE = e.minutes(1);
1186
1149
  static hours(t) {
1187
- return e.minutes(w(t, 60));
1150
+ return e.minutes(A(t, 60));
1188
1151
  }
1189
1152
  static HOUR = e.hours(1);
1190
1153
  static days(t) {
1191
- return e.hours(w(t, 24));
1154
+ return e.hours(A(t, 24));
1192
1155
  }
1193
1156
  static DAY = e.days(1);
1194
- static MAX = new e(b);
1157
+ static MAX = new e(E);
1195
1158
  static MIN = new e(0);
1196
1159
  static ZERO = new e(0);
1197
1160
  static z = t.union([
@@ -1200,472 +1163,938 @@ var pt = t.enum(["static", "dynamic"]), mt = 365, F = 30, ht = t.union([
1200
1163
  t.number().transform((t) => new e(t)),
1201
1164
  t.bigint().transform((t) => new e(t)),
1202
1165
  t.instanceof(e),
1203
- t.instanceof(I).transform((t) => new e(t)),
1204
- t.custom((e) => e instanceof R).transform((t) => new e(t))
1166
+ t.instanceof(P).transform((t) => new e(t)),
1167
+ t.custom((e) => e instanceof yt).transform((t) => new e(t))
1168
+ ]);
1169
+ }, yt = class e extends C {
1170
+ constructor(e) {
1171
+ S(e) && (e = e.value), super(e.valueOf());
1172
+ }
1173
+ toString() {
1174
+ return `${this.valueOf()} Hz`;
1175
+ }
1176
+ equals(t) {
1177
+ return this.valueOf() === new e(t).valueOf();
1178
+ }
1179
+ get period() {
1180
+ return F.seconds(1 / this.valueOf());
1181
+ }
1182
+ sampleCount(e) {
1183
+ return new F(e).seconds * this.valueOf();
1184
+ }
1185
+ byteCount(e, t) {
1186
+ return this.sampleCount(e) * new I(t).valueOf();
1187
+ }
1188
+ span(e) {
1189
+ return F.seconds(e / this.valueOf());
1190
+ }
1191
+ byteSpan(e, t) {
1192
+ return this.span(e.valueOf() / new I(t).valueOf());
1193
+ }
1194
+ add(t) {
1195
+ return new e(k(this.valueOf(), new e(t).valueOf()));
1196
+ }
1197
+ sub(t) {
1198
+ return new e(O(this.valueOf(), new e(t).valueOf()));
1199
+ }
1200
+ mult(t) {
1201
+ return new e(A(this.valueOf(), t));
1202
+ }
1203
+ div(t) {
1204
+ return new e(j(this.valueOf(), t));
1205
+ }
1206
+ static hz(t) {
1207
+ return new e(t);
1208
+ }
1209
+ static khz(t) {
1210
+ return e.hz(t * 1e3);
1211
+ }
1212
+ static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1213
+ }, I = class e extends C {
1214
+ constructor(e) {
1215
+ S(e) && (e = e.value), super(e.valueOf());
1216
+ }
1217
+ length(e) {
1218
+ return e.valueOf() / this.valueOf();
1219
+ }
1220
+ size(e) {
1221
+ return new z(e * this.valueOf());
1222
+ }
1223
+ add(t) {
1224
+ return new e(k(this.valueOf(), new e(t).valueOf()));
1225
+ }
1226
+ sub(t) {
1227
+ return new e(O(this.valueOf(), new e(t).valueOf()));
1228
+ }
1229
+ mult(t) {
1230
+ return new e(A(this.valueOf(), t));
1231
+ }
1232
+ div(t) {
1233
+ return new e(j(this.valueOf(), t));
1234
+ }
1235
+ static UNKNOWN = new e(0);
1236
+ static BIT128 = new e(16);
1237
+ static BIT64 = new e(8);
1238
+ static BIT32 = new e(4);
1239
+ static BIT16 = new e(2);
1240
+ static BIT8 = new e(1);
1241
+ static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1242
+ }, L = class e {
1243
+ start;
1244
+ end;
1245
+ constructor(e, t) {
1246
+ typeof e == "object" && "start" in e ? (this.start = new P(e.start), this.end = new P(e.end)) : (this.start = new P(e), this.end = new P(t));
1247
+ }
1248
+ get span() {
1249
+ return new F(this.end.valueOf() - this.start.valueOf());
1250
+ }
1251
+ get isValid() {
1252
+ return this.start.valueOf() <= this.end.valueOf();
1253
+ }
1254
+ makeValid() {
1255
+ return this.isValid ? this : this.swap();
1256
+ }
1257
+ get isZero() {
1258
+ return this.start.isZero && this.end.isZero;
1259
+ }
1260
+ get numeric() {
1261
+ return {
1262
+ start: Number(this.start.valueOf()),
1263
+ end: Number(this.end.valueOf())
1264
+ };
1265
+ }
1266
+ swap() {
1267
+ return new e(this.end, this.start);
1268
+ }
1269
+ get numericBounds() {
1270
+ return {
1271
+ lower: Number(this.start.valueOf()),
1272
+ upper: Number(this.end.valueOf())
1273
+ };
1274
+ }
1275
+ equals(e, t = F.ZERO) {
1276
+ if (t.isZero) return this.start.equals(e.start) && this.end.equals(e.end);
1277
+ let n = this.start.sub(e.start).valueOf(), r = this.end.sub(e.end).valueOf();
1278
+ return n < 0 && (n = -n), r < 0 && (r = -r), n <= t.valueOf() && r <= t.valueOf();
1279
+ }
1280
+ toString() {
1281
+ return `${this.start.toString()} - ${this.end.toString()}`;
1282
+ }
1283
+ toPrettyString() {
1284
+ return `${this.start.toString("preciseDate")} - ${this.span.toString()}`;
1285
+ }
1286
+ overlapsWith(e, t = F.ZERO) {
1287
+ e = e.makeValid();
1288
+ let n = this.makeValid();
1289
+ if (this.equals(e)) return !0;
1290
+ if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1291
+ let r = P.max(n.start, e.start), i = P.min(n.end, e.end);
1292
+ return i.before(r) ? !1 : new F(i.sub(r)).greaterThanOrEqual(t);
1293
+ }
1294
+ contains(t) {
1295
+ return t instanceof e ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
1296
+ }
1297
+ boundBy(t) {
1298
+ let n = new e(this.start, this.end);
1299
+ return t.start.after(this.start) && (n.start = t.start), t.start.after(this.end) && (n.end = t.start), t.end.before(this.end) && (n.end = t.end), t.end.before(this.start) && (n.start = t.end), n;
1300
+ }
1301
+ static max(...t) {
1302
+ return new e(P.min(...t.map((e) => e.start)), P.max(...t.map((e) => e.end)));
1303
+ }
1304
+ static MAX = new e(P.MIN, P.MAX);
1305
+ static ZERO = new e(P.ZERO, P.ZERO);
1306
+ static z = t.union([t.object({
1307
+ start: P.z,
1308
+ end: P.z
1309
+ }).transform((t) => new e(t.start, t.end)), t.instanceof(e)]);
1310
+ static boundedZ = e.z.refine(({ isValid: e }) => e, { message: "Time range start time must be before or equal to time range end time" }).refine(({ end: e }) => e.valueOf() <= E, { message: "Time range end time must be less than or equal to the maximum value of an int64" }).refine(({ start: e }) => e.valueOf() >= Je, { message: "Time range start time must be greater than or equal to the minimum value of an int64" });
1311
+ static sort(e, t) {
1312
+ return P.sort(e.start, t.start) || P.sort(e.end, t.end);
1313
+ }
1314
+ static merge(...t) {
1315
+ return e.max(...t.map((t) => new e(t).makeValid()));
1316
+ }
1317
+ }, R = class e extends C {
1318
+ constructor(t) {
1319
+ if (S(t) && (t = t.value), t instanceof e || typeof t == "string" || typeof t.valueOf() == "string") super(t.valueOf());
1320
+ else {
1321
+ let n = e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
1322
+ if (n == null) throw Error(`unable to find data type for ${t.toString()}`);
1323
+ super(n.valueOf());
1324
+ }
1325
+ }
1326
+ get Array() {
1327
+ let t = e.ARRAY_CONSTRUCTORS.get(this.toString());
1328
+ if (t == null) throw Error(`unable to find array constructor for ${this.valueOf()}`);
1329
+ return t;
1330
+ }
1331
+ equals(e) {
1332
+ return this.valueOf() === e.valueOf();
1333
+ }
1334
+ matches(...e) {
1335
+ return e.some((e) => this.equals(e));
1336
+ }
1337
+ toString(t = !1) {
1338
+ return t ? e.SHORT_STRINGS.get(this.valueOf()) ?? this.valueOf() : this.valueOf();
1339
+ }
1340
+ get isVariable() {
1341
+ return this.equals(e.JSON) || this.equals(e.STRING) || this.equals(e.BYTES);
1342
+ }
1343
+ get isNumeric() {
1344
+ return !this.isVariable && !this.equals(e.UUID);
1345
+ }
1346
+ get isInteger() {
1347
+ let e = this.toString();
1348
+ return e.startsWith("int") || e.startsWith("uint");
1349
+ }
1350
+ get isFloat() {
1351
+ return this.toString().startsWith("float");
1352
+ }
1353
+ get density() {
1354
+ let t = e.DENSITIES.get(this.toString());
1355
+ if (t == null) throw Error(`unable to find density for ${this.valueOf()}`);
1356
+ return t;
1357
+ }
1358
+ get isUnsignedInteger() {
1359
+ return this.equals(e.UINT8) || this.equals(e.UINT16) || this.equals(e.UINT32) || this.equals(e.UINT64);
1360
+ }
1361
+ get isSignedInteger() {
1362
+ return this.equals(e.INT8) || this.equals(e.INT16) || this.equals(e.INT32) || this.equals(e.INT64);
1363
+ }
1364
+ canSafelyCastTo(t) {
1365
+ return this.equals(t) ? !0 : !this.isNumeric || !t.isNumeric || this.isVariable || t.isVariable || this.isUnsignedInteger && t.isSignedInteger ? !1 : this.isFloat ? t.isFloat && this.density.valueOf() <= t.density.valueOf() : this.equals(e.INT32) && t.equals(e.FLOAT64) || this.equals(e.INT8) && t.equals(e.FLOAT32) ? !0 : this.isInteger && t.isInteger ? this.density.valueOf() <= t.density.valueOf() && this.isUnsignedInteger === t.isUnsignedInteger : !1;
1366
+ }
1367
+ canCastTo(e) {
1368
+ return this.isNumeric && e.isNumeric ? !0 : this.equals(e);
1369
+ }
1370
+ checkArray(e) {
1371
+ return e.constructor === this.Array;
1372
+ }
1373
+ get usesBigInt() {
1374
+ return e.BIG_INT_TYPES.some((e) => e.equals(this));
1375
+ }
1376
+ static UNKNOWN = new e("unknown");
1377
+ static FLOAT64 = new e("float64");
1378
+ static FLOAT32 = new e("float32");
1379
+ static INT64 = new e("int64");
1380
+ static INT32 = new e("int32");
1381
+ static INT16 = new e("int16");
1382
+ static INT8 = new e("int8");
1383
+ static UINT64 = new e("uint64");
1384
+ static UINT32 = new e("uint32");
1385
+ static UINT16 = new e("uint16");
1386
+ static UINT8 = new e("uint8");
1387
+ static TIMESTAMP = new e("timestamp");
1388
+ static UUID = new e("uuid");
1389
+ static STRING = new e("string");
1390
+ static JSON = new e("json");
1391
+ static BYTES = new e("bytes");
1392
+ static ARRAY_CONSTRUCTORS = new Map([
1393
+ [e.UINT8.toString(), Uint8Array],
1394
+ [e.UINT16.toString(), Uint16Array],
1395
+ [e.UINT32.toString(), Uint32Array],
1396
+ [e.UINT64.toString(), BigUint64Array],
1397
+ [e.FLOAT32.toString(), Float32Array],
1398
+ [e.FLOAT64.toString(), Float64Array],
1399
+ [e.INT8.toString(), Int8Array],
1400
+ [e.INT16.toString(), Int16Array],
1401
+ [e.INT32.toString(), Int32Array],
1402
+ [e.INT64.toString(), BigInt64Array],
1403
+ [e.TIMESTAMP.toString(), BigInt64Array],
1404
+ [e.STRING.toString(), Uint8Array],
1405
+ [e.JSON.toString(), Uint8Array],
1406
+ [e.UUID.toString(), Uint8Array],
1407
+ [e.BYTES.toString(), Uint8Array]
1408
+ ]);
1409
+ static ARRAY_CONSTRUCTOR_DATA_TYPES = new Map([
1410
+ [Uint8Array.name, e.UINT8],
1411
+ [Uint16Array.name, e.UINT16],
1412
+ [Uint32Array.name, e.UINT32],
1413
+ [BigUint64Array.name, e.UINT64],
1414
+ [Float32Array.name, e.FLOAT32],
1415
+ [Float64Array.name, e.FLOAT64],
1416
+ [Int8Array.name, e.INT8],
1417
+ [Int16Array.name, e.INT16],
1418
+ [Int32Array.name, e.INT32],
1419
+ [BigInt64Array.name, e.INT64]
1420
+ ]);
1421
+ static DENSITIES = new Map([
1422
+ [e.UINT8.toString(), I.BIT8],
1423
+ [e.UINT16.toString(), I.BIT16],
1424
+ [e.UINT32.toString(), I.BIT32],
1425
+ [e.UINT64.toString(), I.BIT64],
1426
+ [e.FLOAT32.toString(), I.BIT32],
1427
+ [e.FLOAT64.toString(), I.BIT64],
1428
+ [e.INT8.toString(), I.BIT8],
1429
+ [e.INT16.toString(), I.BIT16],
1430
+ [e.INT32.toString(), I.BIT32],
1431
+ [e.INT64.toString(), I.BIT64],
1432
+ [e.TIMESTAMP.toString(), I.BIT64],
1433
+ [e.STRING.toString(), I.UNKNOWN],
1434
+ [e.JSON.toString(), I.UNKNOWN],
1435
+ [e.UUID.toString(), I.BIT128],
1436
+ [e.BYTES.toString(), I.UNKNOWN]
1437
+ ]);
1438
+ static ALL = [
1439
+ e.UNKNOWN,
1440
+ e.UINT8,
1441
+ e.UINT16,
1442
+ e.UINT32,
1443
+ e.UINT64,
1444
+ e.INT8,
1445
+ e.INT16,
1446
+ e.INT32,
1447
+ e.INT64,
1448
+ e.FLOAT32,
1449
+ e.FLOAT64,
1450
+ e.TIMESTAMP,
1451
+ e.UUID,
1452
+ e.STRING,
1453
+ e.JSON,
1454
+ e.BYTES
1455
+ ];
1456
+ static SHORT_STRINGS = new Map([
1457
+ [e.UINT8.toString(), "u8"],
1458
+ [e.UINT16.toString(), "u16"],
1459
+ [e.UINT32.toString(), "u32"],
1460
+ [e.UINT64.toString(), "u64"],
1461
+ [e.INT8.toString(), "i8"],
1462
+ [e.INT16.toString(), "i16"],
1463
+ [e.INT32.toString(), "i32"],
1464
+ [e.INT64.toString(), "i64"],
1465
+ [e.FLOAT32.toString(), "f32"],
1466
+ [e.FLOAT64.toString(), "f64"],
1467
+ [e.TIMESTAMP.toString(), "ts"],
1468
+ [e.UUID.toString(), "uuid"],
1469
+ [e.STRING.toString(), "str"],
1470
+ [e.JSON.toString(), "json"],
1471
+ [e.BYTES.toString(), "bytes"]
1205
1472
  ]);
1206
- }, R = class e extends y {
1473
+ static BIG_INT_TYPES = [
1474
+ e.INT64,
1475
+ e.UINT64,
1476
+ e.TIMESTAMP
1477
+ ];
1478
+ static z = t.union([t.string().transform((t) => new e(t)), t.instanceof(e)]);
1479
+ }, z = class e extends C {
1207
1480
  constructor(e) {
1208
- v(e) && (e = e.value), super(e.valueOf());
1209
- }
1210
- toString() {
1211
- return `${this.valueOf()} Hz`;
1212
- }
1213
- equals(t) {
1214
- return this.valueOf() === new e(t).valueOf();
1215
- }
1216
- get period() {
1217
- return L.seconds(1 / this.valueOf());
1218
- }
1219
- sampleCount(e) {
1220
- return new L(e).seconds * this.valueOf();
1221
- }
1222
- byteCount(e, t) {
1223
- return this.sampleCount(e) * new z(t).valueOf();
1481
+ S(e) && (e = e.value), super(e.valueOf());
1224
1482
  }
1225
- span(e) {
1226
- return L.seconds(e / this.valueOf());
1483
+ largerThan(e) {
1484
+ return S(e) && (e = e.value), this.valueOf() > e.valueOf();
1227
1485
  }
1228
- byteSpan(e, t) {
1229
- return this.span(e.valueOf() / new z(t).valueOf());
1486
+ smallerThan(e) {
1487
+ return S(e) && (e = e.value), this.valueOf() < e.valueOf();
1230
1488
  }
1231
1489
  add(t) {
1232
- return new e(C(this.valueOf(), new e(t).valueOf()));
1490
+ return S(t) && (t = t.value), new e(k(this.valueOf(), t.valueOf()));
1233
1491
  }
1234
1492
  sub(t) {
1235
- return new e(S(this.valueOf(), new e(t).valueOf()));
1493
+ return S(t) && (t = t.value), new e(O(this.valueOf(), t.valueOf()));
1236
1494
  }
1237
1495
  mult(t) {
1238
- return new e(w(this.valueOf(), t));
1496
+ return new e(A(this.valueOf(), t));
1239
1497
  }
1240
1498
  div(t) {
1241
- return new e(T(this.valueOf(), t));
1242
- }
1243
- static hz(t) {
1244
- return new e(t);
1499
+ return new e(j(this.valueOf(), t));
1245
1500
  }
1246
- static khz(t) {
1247
- return e.hz(t * 1e3);
1501
+ truncate(t) {
1502
+ return new e(Math.trunc(this.valueOf() / new e(t).valueOf()) * new e(t).valueOf());
1248
1503
  }
1249
- static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1250
- }, z = class e extends y {
1251
- constructor(e) {
1252
- v(e) && (e = e.value), super(e.valueOf());
1504
+ remainder(t) {
1505
+ return e.bytes(this.valueOf() % new e(t).valueOf());
1253
1506
  }
1254
- length(e) {
1255
- return e.valueOf() / this.valueOf();
1507
+ get gigabytes() {
1508
+ return this.valueOf() / e.GIGABYTE.valueOf();
1256
1509
  }
1257
- size(e) {
1258
- return new H(e * this.valueOf());
1510
+ get megabytes() {
1511
+ return this.valueOf() / e.MEGABYTE.valueOf();
1259
1512
  }
1260
- add(t) {
1261
- return new e(C(this.valueOf(), new e(t).valueOf()));
1513
+ get kilobytes() {
1514
+ return this.valueOf() / e.KILOBYTE.valueOf();
1262
1515
  }
1263
- sub(t) {
1264
- return new e(S(this.valueOf(), new e(t).valueOf()));
1516
+ get terabytes() {
1517
+ return this.valueOf() / e.TERABYTE.valueOf();
1265
1518
  }
1266
- mult(t) {
1267
- return new e(w(this.valueOf(), t));
1519
+ toString() {
1520
+ let t = this.truncate(e.TERABYTE), n = this.truncate(e.GIGABYTE), r = this.truncate(e.MEGABYTE), i = this.truncate(e.KILOBYTE), a = this.truncate(e.BYTE), o = t, s = n.sub(t), c = r.sub(n), l = i.sub(r), u = a.sub(i), d = "";
1521
+ return o.isZero || (d += `${o.terabytes}TB `), s.isZero || (d += `${s.gigabytes}GB `), c.isZero || (d += `${c.megabytes}MB `), l.isZero || (d += `${l.kilobytes}KB `), (!u.isZero || d === "") && (d += `${u.valueOf()}B`), d.trim();
1268
1522
  }
1269
- div(t) {
1270
- return new e(T(this.valueOf(), t));
1523
+ static bytes(t = 1) {
1524
+ return new e(t);
1271
1525
  }
1272
- static UNKNOWN = new e(0);
1273
- static BIT128 = new e(16);
1274
- static BIT64 = new e(8);
1275
- static BIT32 = new e(4);
1276
- static BIT16 = new e(2);
1277
- static BIT8 = new e(1);
1278
- static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1279
- }, B = class e {
1280
- start;
1281
- end;
1282
- constructor(e, t) {
1283
- typeof e == "object" && "start" in e ? (this.start = new I(e.start), this.end = new I(e.end)) : (this.start = new I(e), this.end = new I(t));
1526
+ static BYTE = new e(1);
1527
+ static kilobytes(t = 1) {
1528
+ return e.bytes(new e(t).valueOf() * 1e3);
1284
1529
  }
1285
- get span() {
1286
- return new L(this.end.valueOf() - this.start.valueOf());
1530
+ static KILOBYTE = e.kilobytes(1);
1531
+ static megabytes(t = 1) {
1532
+ return e.kilobytes(new e(t).valueOf() * 1e3);
1287
1533
  }
1288
- get isValid() {
1289
- return this.start.valueOf() <= this.end.valueOf();
1534
+ static MEGABYTE = e.megabytes(1);
1535
+ static gigabytes(t = 1) {
1536
+ return e.megabytes(new e(t).valueOf() * 1e3);
1290
1537
  }
1291
- makeValid() {
1292
- return this.isValid ? this : this.swap();
1538
+ static GIGABYTE = e.gigabytes(1);
1539
+ static terabytes(t) {
1540
+ return e.gigabytes(new e(t).valueOf() * 1e3);
1293
1541
  }
1542
+ static TERABYTE = e.terabytes(1);
1543
+ static ZERO = new e(0);
1544
+ static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1294
1545
  get isZero() {
1295
- return this.start.isZero && this.end.isZero;
1296
- }
1297
- get numeric() {
1298
- return {
1299
- start: Number(this.start.valueOf()),
1300
- end: Number(this.end.valueOf())
1301
- };
1546
+ return this.valueOf() === 0;
1302
1547
  }
1303
- swap() {
1304
- return new e(this.end, this.start);
1548
+ };
1549
+ t.object({
1550
+ start: t.number(),
1551
+ end: t.number()
1552
+ }), t.union([
1553
+ t.instanceof(Uint8Array),
1554
+ t.instanceof(Uint16Array),
1555
+ t.instanceof(Uint32Array),
1556
+ t.instanceof(BigUint64Array),
1557
+ t.instanceof(Float32Array),
1558
+ t.instanceof(Float64Array),
1559
+ t.instanceof(Int8Array),
1560
+ t.instanceof(Int16Array),
1561
+ t.instanceof(Int32Array),
1562
+ t.instanceof(BigInt64Array)
1563
+ ]);
1564
+ var bt = (e) => {
1565
+ let t = typeof e;
1566
+ return t === "string" || t === "number" || t === "boolean" || t === "bigint" || e instanceof P || e instanceof F || e instanceof Date;
1567
+ }, xt = (e, t, n, r = 0) => e.usesBigInt && !t.usesBigInt ? Number(n) - Number(r) : !e.usesBigInt && t.usesBigInt ? BigInt(n.valueOf()) - BigInt(r.valueOf()) : O(n, r);
1568
+ L.z, P.z, F.z, yt.z, z.z, R.z, L.boundedZ;
1569
+ var St = (e, t = !1) => {
1570
+ let n = we(e) ? "stringer" : typeof e, r;
1571
+ switch (n) {
1572
+ case "string":
1573
+ r = (e, t) => e.localeCompare(t);
1574
+ break;
1575
+ case "stringer":
1576
+ r = (e, t) => e.toString().localeCompare(t.toString());
1577
+ break;
1578
+ case "number":
1579
+ r = (e, t) => Number(e) - Number(t);
1580
+ break;
1581
+ case "bigint":
1582
+ r = (e, t) => BigInt(e) - BigInt(t) > 0n ? 1 : -1;
1583
+ break;
1584
+ case "boolean":
1585
+ r = (e, t) => Number(e) - Number(t);
1586
+ break;
1587
+ case "undefined":
1588
+ r = () => 0;
1589
+ break;
1590
+ default: return console.warn(`sortFunc: unknown type ${n}`), () => -1;
1305
1591
  }
1306
- get numericBounds() {
1307
- return {
1308
- lower: Number(this.start.valueOf()),
1309
- upper: Number(this.end.valueOf())
1592
+ return t ? Ct(r) : r;
1593
+ }, Ct = (e) => (t, n) => e(n, t), wt = (e, t = 21) => (n = t) => {
1594
+ let r = "", i = n | 0;
1595
+ for (; i--;) r += e[Math.random() * e.length | 0];
1596
+ return r;
1597
+ }, Tt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Et = `0123456789${Tt}`, Dt = wt(Tt, 1), Ot = wt(Et, 10), kt = () => `${Dt()}${Ot()}`, At = (e, t) => (n) => n instanceof t || typeof n == "object" && !!n && "discriminator" in n && n.discriminator === e;
1598
+ t.object({
1599
+ x: nt.or(at),
1600
+ y: rt.or(at)
1601
+ });
1602
+ var jt = t.object({
1603
+ x: nt,
1604
+ y: rt
1605
+ }), Mt = Object.freeze({
1606
+ x: "left",
1607
+ y: "top"
1608
+ }), Nt = Object.freeze({
1609
+ x: "right",
1610
+ y: "top"
1611
+ }), Pt = Object.freeze({
1612
+ x: "left",
1613
+ y: "bottom"
1614
+ }), Ft = Object.freeze({
1615
+ x: "right",
1616
+ y: "bottom"
1617
+ }), It = Object.freeze({
1618
+ x: "center",
1619
+ y: "center"
1620
+ }), Lt = Object.freeze({
1621
+ x: "center",
1622
+ y: "top"
1623
+ }), Rt = Object.freeze({
1624
+ x: "center",
1625
+ y: "bottom"
1626
+ }), zt = Object.freeze({
1627
+ x: "right",
1628
+ y: "center"
1629
+ }), Bt = Object.freeze({
1630
+ x: "left",
1631
+ y: "center"
1632
+ });
1633
+ Object.freeze([
1634
+ Bt,
1635
+ zt,
1636
+ Lt,
1637
+ Rt,
1638
+ Mt,
1639
+ Nt,
1640
+ Pt,
1641
+ Ft,
1642
+ It
1643
+ ]);
1644
+ var Vt = (e, t) => e.x === t.x && e.y === t.y, Ht = (e) => [e.x, e.y];
1645
+ t.enum([
1646
+ "top",
1647
+ "right",
1648
+ "bottom",
1649
+ "left"
1650
+ ]);
1651
+ var B = t.object({
1652
+ x: t.number(),
1653
+ y: t.number()
1654
+ }), Ut = t.union([
1655
+ t.number(),
1656
+ B,
1657
+ Qe,
1658
+ st,
1659
+ ct,
1660
+ ot
1661
+ ]), V = (e, t) => {
1662
+ if (typeof e == "string") {
1663
+ if (t === void 0) throw Error("The y coordinate must be given.");
1664
+ return e === "x" ? {
1665
+ x: t,
1666
+ y: 0
1667
+ } : {
1668
+ x: 0,
1669
+ y: t
1310
1670
  };
1311
1671
  }
1312
- equals(e, t = L.ZERO) {
1313
- if (t.isZero) return this.start.equals(e.start) && this.end.equals(e.end);
1314
- let n = this.start.sub(e.start).valueOf(), r = this.end.sub(e.end).valueOf();
1315
- return n < 0 && (n = -n), r < 0 && (r = -r), n <= t.valueOf() && r <= t.valueOf();
1316
- }
1317
- toString() {
1318
- return `${this.start.toString()} - ${this.end.toString()}`;
1319
- }
1320
- toPrettyString() {
1321
- return `${this.start.toString("preciseDate")} - ${this.span.toString()}`;
1322
- }
1323
- overlapsWith(e, t = L.ZERO) {
1324
- e = e.makeValid();
1325
- let n = this.makeValid();
1326
- if (this.equals(e)) return !0;
1327
- if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1328
- let r = I.max(n.start, e.start), i = I.min(n.end, e.end);
1329
- return i.before(r) ? !1 : new L(i.sub(r)).greaterThanOrEqual(t);
1330
- }
1331
- contains(t) {
1332
- return t instanceof e ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
1333
- }
1334
- boundBy(t) {
1335
- let n = new e(this.start, this.end);
1336
- return t.start.after(this.start) && (n.start = t.start), t.start.after(this.end) && (n.end = t.start), t.end.before(this.end) && (n.end = t.end), t.end.before(this.start) && (n.start = t.end), n;
1337
- }
1338
- static max(...t) {
1339
- return new e(I.min(...t.map((e) => e.start)), I.max(...t.map((e) => e.end)));
1340
- }
1341
- static MAX = new e(I.MIN, I.MAX);
1342
- static ZERO = new e(I.ZERO, I.ZERO);
1343
- static z = t.union([t.object({
1344
- start: I.z,
1345
- end: I.z
1346
- }).transform((t) => new e(t.start, t.end)), t.instanceof(e)]);
1347
- static boundedZ = e.z.refine(({ isValid: e }) => e, { message: "Time range start time must be before or equal to time range end time" }).refine(({ end: e }) => e.valueOf() <= b, { message: "Time range end time must be less than or equal to the maximum value of an int64" }).refine(({ start: e }) => e.valueOf() >= be, { message: "Time range start time must be greater than or equal to the minimum value of an int64" });
1348
- static sort(e, t) {
1349
- return I.sort(e.start, t.start) || I.sort(e.end, t.end);
1350
- }
1351
- static merge(...t) {
1352
- return e.max(...t.map((t) => new e(t).makeValid()));
1672
+ return typeof e == "number" ? {
1673
+ x: e,
1674
+ y: t ?? e
1675
+ } : Array.isArray(e) ? {
1676
+ x: e[0],
1677
+ y: e[1]
1678
+ } : "signedWidth" in e ? {
1679
+ x: e.signedWidth,
1680
+ y: e.signedHeight
1681
+ } : "clientX" in e ? {
1682
+ x: e.clientX,
1683
+ y: e.clientY
1684
+ } : "width" in e ? {
1685
+ x: e.width,
1686
+ y: e.height
1687
+ } : {
1688
+ x: e.x,
1689
+ y: e.y
1690
+ };
1691
+ }, H = Object.freeze({
1692
+ x: 0,
1693
+ y: 0
1694
+ });
1695
+ Object.freeze({
1696
+ x: 1,
1697
+ y: 1
1698
+ }), Object.freeze({
1699
+ x: Infinity,
1700
+ y: Infinity
1701
+ }), Object.freeze({
1702
+ x: NaN,
1703
+ y: NaN
1704
+ });
1705
+ var Wt = (e, t) => {
1706
+ let n = V(e);
1707
+ return {
1708
+ x: n.x + t,
1709
+ y: n.y
1710
+ };
1711
+ }, Gt = (e, t) => {
1712
+ let n = V(e);
1713
+ return {
1714
+ x: n.x,
1715
+ y: n.y + t
1716
+ };
1717
+ }, Kt = (e, t, n, ...r) => {
1718
+ if (typeof t == "string") {
1719
+ if (typeof n != "number") throw Error("The value must be a number.");
1720
+ return t === "x" ? Wt(e, n) : Gt(e, n);
1353
1721
  }
1354
- }, V = class e extends y {
1355
- constructor(t) {
1356
- if (v(t) && (t = t.value), t instanceof e || typeof t == "string" || typeof t.valueOf() == "string") super(t.valueOf());
1357
- else {
1358
- let n = e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
1359
- if (n == null) throw Error(`unable to find data type for ${t.toString()}`);
1360
- super(n.valueOf());
1361
- }
1722
+ if (typeof t == "object" && "x" in t && typeof t.x == "string") {
1723
+ let r = V(n), i = V(e);
1724
+ return t.x === "left" ? r.x = -r.x : t.x === "center" && (r.x = 0), t.y === "top" ? r.y = -r.y : t.y === "center" && (r.y = 0), {
1725
+ x: i.x + r.x,
1726
+ y: i.y + r.y
1727
+ };
1362
1728
  }
1363
- get Array() {
1364
- let t = e.ARRAY_CONSTRUCTORS.get(this.toString());
1365
- if (t == null) throw Error(`unable to find array constructor for ${this.valueOf()}`);
1366
- return t;
1729
+ return [
1730
+ e,
1731
+ t,
1732
+ n ?? H,
1733
+ ...r
1734
+ ].reduce((e, t) => {
1735
+ let n = V(t);
1736
+ return {
1737
+ x: e.x + n.x,
1738
+ y: e.y + n.y
1739
+ };
1740
+ }, H);
1741
+ }, U = t.union([t.number(), t.string()]);
1742
+ t.object({
1743
+ top: U,
1744
+ left: U,
1745
+ width: U,
1746
+ height: U
1747
+ }), t.object({
1748
+ left: t.number(),
1749
+ top: t.number(),
1750
+ right: t.number(),
1751
+ bottom: t.number()
1752
+ }), t.object({
1753
+ one: B,
1754
+ two: B,
1755
+ root: jt
1756
+ });
1757
+ var W = (e, t, n = 0, r = 0, i) => {
1758
+ let a = {
1759
+ one: { ...H },
1760
+ two: { ...H },
1761
+ root: i ?? Mt
1762
+ };
1763
+ if (typeof e == "number") {
1764
+ if (typeof t != "number") throw Error("Box constructor called with invalid arguments");
1765
+ return a.one = {
1766
+ x: e,
1767
+ y: t
1768
+ }, a.two = {
1769
+ x: a.one.x + n,
1770
+ y: a.one.y + r
1771
+ }, a;
1367
1772
  }
1368
- equals(e) {
1369
- return this.valueOf() === e.valueOf();
1773
+ return "one" in e && "two" in e && "root" in e ? {
1774
+ ...e,
1775
+ root: i ?? e.root
1776
+ } : ("getBoundingClientRect" in e && (e = e.getBoundingClientRect()), "left" in e ? (a.one = {
1777
+ x: e.left,
1778
+ y: e.top
1779
+ }, a.two = {
1780
+ x: e.right,
1781
+ y: e.bottom
1782
+ }, a) : (a.one = e, t == null ? a.two = {
1783
+ x: a.one.x + n,
1784
+ y: a.one.y + r
1785
+ } : typeof t == "number" ? a.two = {
1786
+ x: a.one.x + t,
1787
+ y: a.one.y + n
1788
+ } : "width" in t ? a.two = {
1789
+ x: a.one.x + t.width,
1790
+ y: a.one.y + t.height
1791
+ } : "signedWidth" in t ? a.two = {
1792
+ x: a.one.x + t.signedWidth,
1793
+ y: a.one.y + t.signedHeight
1794
+ } : a.two = t, a));
1795
+ }, qt = (e, t) => {
1796
+ let n = W(e);
1797
+ return {
1798
+ x: t.x === "center" ? Qt(n).x : Jt(n, t.x),
1799
+ y: t.y === "center" ? Qt(n).y : Jt(n, t.y)
1800
+ };
1801
+ }, Jt = (e, t) => {
1802
+ let n = W(e), r = Ht(n.root).includes(t) ? Math.min : Math.max;
1803
+ return tt.includes(t) ? r(n.one.x, n.two.x) : r(n.one.y, n.two.y);
1804
+ }, Yt = (e) => {
1805
+ let t = W(e);
1806
+ return t.two.x - t.one.x;
1807
+ }, Xt = (e) => {
1808
+ let t = W(e);
1809
+ return t.two.y - t.one.y;
1810
+ }, Zt = (e) => qt(e, Mt), Qt = (e) => Kt(Zt(e), {
1811
+ x: Yt(e) / 2,
1812
+ y: Xt(e) / 2
1813
+ }), $t = (e) => {
1814
+ let t = W(e);
1815
+ return {
1816
+ lower: t.one.x,
1817
+ upper: t.two.x
1818
+ };
1819
+ }, en = (e) => {
1820
+ let t = W(e);
1821
+ return {
1822
+ lower: t.one.y,
1823
+ upper: t.two.y
1824
+ };
1825
+ }, tn = (e) => typeof e != "object" || !e ? !1 : "one" in e && "two" in e && "root" in e;
1826
+ t.union([
1827
+ st,
1828
+ ct,
1829
+ B,
1830
+ Qe
1831
+ ]);
1832
+ var nn = (e, t, n) => t !== void 0 && e < t ? t : n !== void 0 && e > n ? n : e;
1833
+ t.object({
1834
+ offset: Ut,
1835
+ scale: Ut
1836
+ }), t.object({
1837
+ offset: t.number(),
1838
+ scale: t.number()
1839
+ });
1840
+ var rn = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r + e], an = (e) => (t, n, r, i) => [t, i ? r / e : r * e], on = (e) => (t, n, r) => {
1841
+ if (t === null) return [e, r];
1842
+ let { lower: i, upper: a } = t, { lower: o, upper: s } = e, c = a - i, l = s - o;
1843
+ return n === "dimension" ? [e, l / c * r] : [e, (r - i) * (l / c) + o];
1844
+ }, sn = (e) => (t, n, r) => [e, r], cn = () => (e, t, n) => {
1845
+ if (e === null) throw Error("cannot invert without bounds");
1846
+ if (t === "dimension") return [e, n];
1847
+ let { lower: r, upper: i } = e;
1848
+ return [e, i - (n - r)];
1849
+ }, ln = (e) => (t, n, r) => {
1850
+ let { lower: i, upper: a } = e;
1851
+ return r = nn(r, i, a), [t, r];
1852
+ }, un = class e {
1853
+ ops = [];
1854
+ currBounds = null;
1855
+ currType = null;
1856
+ reversed = !1;
1857
+ constructor() {
1858
+ this.ops = [];
1370
1859
  }
1371
- matches(...e) {
1372
- return e.some((e) => this.equals(e));
1860
+ static translate(t) {
1861
+ return new e().translate(t);
1373
1862
  }
1374
- toString(t = !1) {
1375
- return t ? e.SHORT_STRINGS.get(this.valueOf()) ?? this.valueOf() : this.valueOf();
1863
+ static magnify(t) {
1864
+ return new e().magnify(t);
1376
1865
  }
1377
- get isVariable() {
1378
- return this.equals(e.JSON) || this.equals(e.STRING) || this.equals(e.BYTES);
1866
+ static scale(t, n) {
1867
+ return new e().scale(t, n);
1379
1868
  }
1380
- get isNumeric() {
1381
- return !this.isVariable && !this.equals(e.UUID);
1869
+ translate(e) {
1870
+ let t = this.new(), n = rn(e);
1871
+ return n.type = "translate", t.ops.push(n), t;
1382
1872
  }
1383
- get isInteger() {
1384
- let e = this.toString();
1385
- return e.startsWith("int") || e.startsWith("uint");
1873
+ magnify(e) {
1874
+ let t = this.new(), n = an(e);
1875
+ return n.type = "magnify", t.ops.push(n), t;
1386
1876
  }
1387
- get isFloat() {
1388
- return this.toString().startsWith("float");
1877
+ scale(e, t) {
1878
+ let n = M(e, t), r = this.new(), i = on(n);
1879
+ return i.type = "scale", r.ops.push(i), r;
1389
1880
  }
1390
- get density() {
1391
- let t = e.DENSITIES.get(this.toString());
1392
- if (t == null) throw Error(`unable to find density for ${this.valueOf()}`);
1393
- return t;
1881
+ clamp(e, t) {
1882
+ let n = M(e, t), r = this.new(), i = ln(n);
1883
+ return i.type = "clamp", r.ops.push(i), r;
1394
1884
  }
1395
- get isUnsignedInteger() {
1396
- return this.equals(e.UINT8) || this.equals(e.UINT16) || this.equals(e.UINT32) || this.equals(e.UINT64);
1885
+ reBound(e, t) {
1886
+ let n = M(e, t), r = this.new(), i = sn(n);
1887
+ return i.type = "re-bound", r.ops.push(i), r;
1397
1888
  }
1398
- get isSignedInteger() {
1399
- return this.equals(e.INT8) || this.equals(e.INT16) || this.equals(e.INT32) || this.equals(e.INT64);
1889
+ invert() {
1890
+ let e = cn();
1891
+ e.type = "invert";
1892
+ let t = this.new();
1893
+ return t.ops.push(e), t;
1400
1894
  }
1401
- canSafelyCastTo(t) {
1402
- return this.equals(t) ? !0 : !this.isNumeric || !t.isNumeric || this.isVariable || t.isVariable || this.isUnsignedInteger && t.isSignedInteger ? !1 : this.isFloat ? t.isFloat && this.density.valueOf() <= t.density.valueOf() : this.equals(e.INT32) && t.equals(e.FLOAT64) || this.equals(e.INT8) && t.equals(e.FLOAT32) ? !0 : this.isInteger && t.isInteger ? this.density.valueOf() <= t.density.valueOf() && this.isUnsignedInteger === t.isUnsignedInteger : !1;
1895
+ pos(e) {
1896
+ return this.exec("position", e);
1403
1897
  }
1404
- canCastTo(e) {
1405
- return this.isNumeric && e.isNumeric ? !0 : this.equals(e);
1898
+ dim(e) {
1899
+ return this.exec("dimension", e);
1406
1900
  }
1407
- checkArray(e) {
1408
- return e.constructor === this.Array;
1901
+ new() {
1902
+ let t = new e();
1903
+ return t.ops = this.ops.slice(), t.reversed = this.reversed, t;
1409
1904
  }
1410
- get usesBigInt() {
1411
- return e.BIG_INT_TYPES.some((e) => e.equals(this));
1905
+ exec(e, t) {
1906
+ return this.currBounds = null, this.ops.reduce(([t, n], r) => r(t, e, n, this.reversed), [null, t])[1];
1412
1907
  }
1413
- static UNKNOWN = new e("unknown");
1414
- static FLOAT64 = new e("float64");
1415
- static FLOAT32 = new e("float32");
1416
- static INT64 = new e("int64");
1417
- static INT32 = new e("int32");
1418
- static INT16 = new e("int16");
1419
- static INT8 = new e("int8");
1420
- static UINT64 = new e("uint64");
1421
- static UINT32 = new e("uint32");
1422
- static UINT16 = new e("uint16");
1423
- static UINT8 = new e("uint8");
1424
- static TIMESTAMP = new e("timestamp");
1425
- static UUID = new e("uuid");
1426
- static STRING = new e("string");
1427
- static JSON = new e("json");
1428
- static BYTES = new e("bytes");
1429
- static ARRAY_CONSTRUCTORS = new Map([
1430
- [e.UINT8.toString(), Uint8Array],
1431
- [e.UINT16.toString(), Uint16Array],
1432
- [e.UINT32.toString(), Uint32Array],
1433
- [e.UINT64.toString(), BigUint64Array],
1434
- [e.FLOAT32.toString(), Float32Array],
1435
- [e.FLOAT64.toString(), Float64Array],
1436
- [e.INT8.toString(), Int8Array],
1437
- [e.INT16.toString(), Int16Array],
1438
- [e.INT32.toString(), Int32Array],
1439
- [e.INT64.toString(), BigInt64Array],
1440
- [e.TIMESTAMP.toString(), BigInt64Array],
1441
- [e.STRING.toString(), Uint8Array],
1442
- [e.JSON.toString(), Uint8Array],
1443
- [e.UUID.toString(), Uint8Array],
1444
- [e.BYTES.toString(), Uint8Array]
1445
- ]);
1446
- static ARRAY_CONSTRUCTOR_DATA_TYPES = new Map([
1447
- [Uint8Array.name, e.UINT8],
1448
- [Uint16Array.name, e.UINT16],
1449
- [Uint32Array.name, e.UINT32],
1450
- [BigUint64Array.name, e.UINT64],
1451
- [Float32Array.name, e.FLOAT32],
1452
- [Float64Array.name, e.FLOAT64],
1453
- [Int8Array.name, e.INT8],
1454
- [Int16Array.name, e.INT16],
1455
- [Int32Array.name, e.INT32],
1456
- [BigInt64Array.name, e.INT64]
1457
- ]);
1458
- static DENSITIES = new Map([
1459
- [e.UINT8.toString(), z.BIT8],
1460
- [e.UINT16.toString(), z.BIT16],
1461
- [e.UINT32.toString(), z.BIT32],
1462
- [e.UINT64.toString(), z.BIT64],
1463
- [e.FLOAT32.toString(), z.BIT32],
1464
- [e.FLOAT64.toString(), z.BIT64],
1465
- [e.INT8.toString(), z.BIT8],
1466
- [e.INT16.toString(), z.BIT16],
1467
- [e.INT32.toString(), z.BIT32],
1468
- [e.INT64.toString(), z.BIT64],
1469
- [e.TIMESTAMP.toString(), z.BIT64],
1470
- [e.STRING.toString(), z.UNKNOWN],
1471
- [e.JSON.toString(), z.UNKNOWN],
1472
- [e.UUID.toString(), z.BIT128],
1473
- [e.BYTES.toString(), z.UNKNOWN]
1474
- ]);
1475
- static ALL = [
1476
- e.UNKNOWN,
1477
- e.UINT8,
1478
- e.UINT16,
1479
- e.UINT32,
1480
- e.UINT64,
1481
- e.INT8,
1482
- e.INT16,
1483
- e.INT32,
1484
- e.INT64,
1485
- e.FLOAT32,
1486
- e.FLOAT64,
1487
- e.TIMESTAMP,
1488
- e.UUID,
1489
- e.STRING,
1490
- e.JSON,
1491
- e.BYTES
1492
- ];
1493
- static SHORT_STRINGS = new Map([
1494
- [e.UINT8.toString(), "u8"],
1495
- [e.UINT16.toString(), "u16"],
1496
- [e.UINT32.toString(), "u32"],
1497
- [e.UINT64.toString(), "u64"],
1498
- [e.INT8.toString(), "i8"],
1499
- [e.INT16.toString(), "i16"],
1500
- [e.INT32.toString(), "i32"],
1501
- [e.INT64.toString(), "i64"],
1502
- [e.FLOAT32.toString(), "f32"],
1503
- [e.FLOAT64.toString(), "f64"],
1504
- [e.TIMESTAMP.toString(), "ts"],
1505
- [e.UUID.toString(), "uuid"],
1506
- [e.STRING.toString(), "str"],
1507
- [e.JSON.toString(), "json"],
1508
- [e.BYTES.toString(), "bytes"]
1509
- ]);
1510
- static BIG_INT_TYPES = [
1511
- e.INT64,
1512
- e.UINT64,
1513
- e.TIMESTAMP
1514
- ];
1515
- static z = t.union([t.string().transform((t) => new e(t)), t.instanceof(e)]);
1516
- }, H = class e extends y {
1517
- constructor(e) {
1518
- v(e) && (e = e.value), super(e.valueOf());
1908
+ reverse() {
1909
+ let e = this.new();
1910
+ e.ops.reverse();
1911
+ let t = [];
1912
+ return e.ops.forEach((n, r) => {
1913
+ if (n.type === "scale" || t.some(([e, t]) => r >= e && r <= t)) return;
1914
+ let i = e.ops.findIndex((e, t) => e.type === "scale" && t > r);
1915
+ i !== -1 && t.push([r, i]);
1916
+ }), t.forEach(([t, n]) => {
1917
+ let r = e.ops.slice(t, n);
1918
+ r.unshift(e.ops[n]), e.ops.splice(t, n - t + 1, ...r);
1919
+ }), e.reversed = !e.reversed, e;
1519
1920
  }
1520
- largerThan(e) {
1521
- return v(e) && (e = e.value), this.valueOf() > e.valueOf();
1921
+ get transform() {
1922
+ return {
1923
+ scale: this.dim(1),
1924
+ offset: this.pos(0)
1925
+ };
1522
1926
  }
1523
- smallerThan(e) {
1524
- return v(e) && (e = e.value), this.valueOf() < e.valueOf();
1927
+ static IDENTITY = new e();
1928
+ };
1929
+ (class e {
1930
+ x;
1931
+ y;
1932
+ currRoot;
1933
+ constructor(e = new un(), t = new un(), n = null) {
1934
+ this.x = e, this.y = t, this.currRoot = n;
1525
1935
  }
1526
- add(t) {
1527
- return v(t) && (t = t.value), new e(C(this.valueOf(), t.valueOf()));
1936
+ static translate(t, n) {
1937
+ return new e().translate(t, n);
1528
1938
  }
1529
- sub(t) {
1530
- return v(t) && (t = t.value), new e(S(this.valueOf(), t.valueOf()));
1939
+ static translateX(t) {
1940
+ return new e().translateX(t);
1531
1941
  }
1532
- mult(t) {
1533
- return new e(w(this.valueOf(), t));
1942
+ static translateY(t) {
1943
+ return new e().translateY(t);
1534
1944
  }
1535
- div(t) {
1536
- return new e(T(this.valueOf(), t));
1945
+ static clamp(t) {
1946
+ return new e().clamp(t);
1537
1947
  }
1538
- truncate(t) {
1539
- return new e(Math.trunc(this.valueOf() / new e(t).valueOf()) * new e(t).valueOf());
1948
+ static magnify(t) {
1949
+ return new e().magnify(t);
1540
1950
  }
1541
- remainder(t) {
1542
- return e.bytes(this.valueOf() % new e(t).valueOf());
1951
+ static scale(t) {
1952
+ return new e().scale(t);
1543
1953
  }
1544
- get gigabytes() {
1545
- return this.valueOf() / e.GIGABYTE.valueOf();
1954
+ static reBound(t) {
1955
+ return new e().reBound(t);
1546
1956
  }
1547
- get megabytes() {
1548
- return this.valueOf() / e.MEGABYTE.valueOf();
1957
+ translate(e, t) {
1958
+ let n = V(e, t), r = this.copy();
1959
+ return r.x = this.x.translate(n.x), r.y = this.y.translate(n.y), r;
1549
1960
  }
1550
- get kilobytes() {
1551
- return this.valueOf() / e.KILOBYTE.valueOf();
1961
+ translateX(e) {
1962
+ let t = this.copy();
1963
+ return t.x = this.x.translate(e), t;
1552
1964
  }
1553
- get terabytes() {
1554
- return this.valueOf() / e.TERABYTE.valueOf();
1965
+ translateY(e) {
1966
+ let t = this.copy();
1967
+ return t.y = this.y.translate(e), t;
1555
1968
  }
1556
- toString() {
1557
- let t = this.truncate(e.TERABYTE), n = this.truncate(e.GIGABYTE), r = this.truncate(e.MEGABYTE), i = this.truncate(e.KILOBYTE), a = this.truncate(e.BYTE), o = t, s = n.sub(t), c = r.sub(n), l = i.sub(r), u = a.sub(i), d = "";
1558
- return o.isZero || (d += `${o.terabytes}TB `), s.isZero || (d += `${s.gigabytes}GB `), c.isZero || (d += `${c.megabytes}MB `), l.isZero || (d += `${l.kilobytes}KB `), (!u.isZero || d === "") && (d += `${u.valueOf()}B`), d.trim();
1969
+ magnify(e) {
1970
+ let t = this.copy();
1971
+ return t.x = this.x.magnify(e.x), t.y = this.y.magnify(e.y), t;
1559
1972
  }
1560
- static bytes(t = 1) {
1561
- return new e(t);
1973
+ scale(e) {
1974
+ let t = this.copy();
1975
+ if (tn(e)) {
1976
+ let n = this.currRoot;
1977
+ return t.currRoot = e.root, n != null && !Vt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale($t(e)), t.y = t.y.scale(en(e)), t;
1978
+ }
1979
+ return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
1562
1980
  }
1563
- static BYTE = new e(1);
1564
- static kilobytes(t = 1) {
1565
- return e.bytes(new e(t).valueOf() * 1e3);
1981
+ reBound(e) {
1982
+ let t = this.copy();
1983
+ return t.x = this.x.reBound($t(e)), t.y = this.y.reBound(en(e)), t;
1566
1984
  }
1567
- static KILOBYTE = e.kilobytes(1);
1568
- static megabytes(t = 1) {
1569
- return e.kilobytes(new e(t).valueOf() * 1e3);
1985
+ clamp(e) {
1986
+ let t = this.copy();
1987
+ return t.x = this.x.clamp($t(e)), t.y = this.y.clamp(en(e)), t;
1570
1988
  }
1571
- static MEGABYTE = e.megabytes(1);
1572
- static gigabytes(t = 1) {
1573
- return e.megabytes(new e(t).valueOf() * 1e3);
1989
+ copy() {
1990
+ let t = new e();
1991
+ return t.currRoot = this.currRoot, t.x = this.x, t.y = this.y, t;
1574
1992
  }
1575
- static GIGABYTE = e.gigabytes(1);
1576
- static terabytes(t) {
1577
- return e.gigabytes(new e(t).valueOf() * 1e3);
1993
+ reverse() {
1994
+ let e = this.copy();
1995
+ return e.x = this.x.reverse(), e.y = this.y.reverse(), e;
1578
1996
  }
1579
- static TERABYTE = e.terabytes(1);
1580
- static ZERO = new e(0);
1581
- static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1582
- get isZero() {
1583
- return this.valueOf() === 0;
1997
+ pos(e) {
1998
+ return {
1999
+ x: this.x.pos(e.x),
2000
+ y: this.y.pos(e.y)
2001
+ };
1584
2002
  }
1585
- };
1586
- t.object({
1587
- start: t.number(),
1588
- end: t.number()
1589
- }), t.union([
1590
- t.instanceof(Uint8Array),
1591
- t.instanceof(Uint16Array),
1592
- t.instanceof(Uint32Array),
1593
- t.instanceof(BigUint64Array),
1594
- t.instanceof(Float32Array),
1595
- t.instanceof(Float64Array),
1596
- t.instanceof(Int8Array),
1597
- t.instanceof(Int16Array),
1598
- t.instanceof(Int32Array),
1599
- t.instanceof(BigInt64Array)
1600
- ]);
1601
- var _t = (e) => {
1602
- let t = typeof e;
1603
- return t === "string" || t === "number" || t === "boolean" || t === "bigint" || e instanceof I || e instanceof L || e instanceof Date;
1604
- }, vt = (e, t, n, r = 0) => e.usesBigInt && !t.usesBigInt ? Number(n) - Number(r) : !e.usesBigInt && t.usesBigInt ? BigInt(n.valueOf()) - BigInt(r.valueOf()) : S(n, r);
1605
- B.z, I.z, L.z, R.z, H.z, V.z, B.boundedZ;
1606
- var yt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1607
- function bt(e) {
1608
- return typeof e == "string" && yt.test(e);
2003
+ dim(e) {
2004
+ return {
2005
+ x: this.x.dim(e.x),
2006
+ y: this.y.dim(e.y)
2007
+ };
2008
+ }
2009
+ box(e) {
2010
+ return W(this.pos(e.one), this.pos(e.two), 0, 0, this.currRoot ?? e.root);
2011
+ }
2012
+ get transform() {
2013
+ return {
2014
+ scale: this.dim({
2015
+ x: 1,
2016
+ y: 1
2017
+ }),
2018
+ offset: this.pos({
2019
+ x: 0,
2020
+ y: 0
2021
+ })
2022
+ };
2023
+ }
2024
+ static IDENTITY = new e();
2025
+ }), B.extend({
2026
+ root: jt,
2027
+ units: e.object({
2028
+ x: e.enum(["px", "decimal"]),
2029
+ y: e.enum(["px", "decimal"])
2030
+ })
2031
+ }).partial({
2032
+ root: !0,
2033
+ units: !0
2034
+ });
2035
+ var dn = t.enum(["static", "dynamic"]), fn = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
2036
+ function pn(e) {
2037
+ return typeof e == "string" && fn.test(e);
1609
2038
  }
1610
- var U = [];
1611
- for (let e = 0; e < 256; ++e) U.push((e + 256).toString(16).slice(1));
1612
- function xt(e, t = 0) {
1613
- return (U[e[t + 0]] + U[e[t + 1]] + U[e[t + 2]] + U[e[t + 3]] + "-" + U[e[t + 4]] + U[e[t + 5]] + "-" + U[e[t + 6]] + U[e[t + 7]] + "-" + U[e[t + 8]] + U[e[t + 9]] + "-" + U[e[t + 10]] + U[e[t + 11]] + U[e[t + 12]] + U[e[t + 13]] + U[e[t + 14]] + U[e[t + 15]]).toLowerCase();
2039
+ var G = [];
2040
+ for (let e = 0; e < 256; ++e) G.push((e + 256).toString(16).slice(1));
2041
+ function mn(e, t = 0) {
2042
+ return (G[e[t + 0]] + G[e[t + 1]] + G[e[t + 2]] + G[e[t + 3]] + "-" + G[e[t + 4]] + G[e[t + 5]] + "-" + G[e[t + 6]] + G[e[t + 7]] + "-" + G[e[t + 8]] + G[e[t + 9]] + "-" + G[e[t + 10]] + G[e[t + 11]] + G[e[t + 12]] + G[e[t + 13]] + G[e[t + 14]] + G[e[t + 15]]).toLowerCase();
1614
2043
  }
1615
- function St(e, t = 0) {
1616
- let n = xt(e, t);
1617
- if (!bt(n)) throw TypeError("Stringified UUID is invalid");
2044
+ function hn(e, t = 0) {
2045
+ let n = mn(e, t);
2046
+ if (!pn(n)) throw TypeError("Stringified UUID is invalid");
1618
2047
  return n;
1619
2048
  }
1620
2049
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1621
- var Ct = (e, t) => St(e, t), W = -1, wt = {
1622
- [Symbol.iterator]: () => wt,
2050
+ var gn = (e, t) => hn(e, t), K = -1, _n = {
2051
+ [Symbol.iterator]: () => _n,
1623
2052
  next: () => ({
1624
2053
  done: !0,
1625
2054
  value: void 0
1626
2055
  })
1627
- }, Tt = t.string().transform((e) => new Uint8Array(atob(e).split("").map((e) => e.charCodeAt(0))).buffer), Et = t.union([t.null(), t.undefined()]).transform(() => new Uint8Array().buffer), Dt = 10, Ot = (e, t) => {
2056
+ }, vn = t.string().transform((e) => new Uint8Array(atob(e).split("").map((e) => e.charCodeAt(0))).buffer), yn = t.union([t.null(), t.undefined()]).transform(() => new Uint8Array().buffer), q = 4, bn = (e, t) => {
1628
2057
  if (e === "number" && !t.isNumeric) throw Error(`cannot convert series of type ${t.toString()} to number`);
1629
2058
  if (e === "bigint" && !t.usesBigInt) throw Error(`cannot convert series of type ${t.toString()} to bigint`);
1630
- }, kt = "sy_x_telem_series", At = class e {
2059
+ }, xn = "sy_x_telem_series", Sn = class e {
1631
2060
  key;
1632
- discriminator = kt;
2061
+ discriminator = xn;
1633
2062
  dataType;
1634
2063
  sampleOffset;
1635
2064
  gl;
1636
2065
  _data;
1637
- timeRange = B.ZERO;
2066
+ timeRange = L.ZERO;
1638
2067
  alignment = 0n;
1639
2068
  alignmentMultiple = 1n;
1640
2069
  cachedMin;
1641
2070
  cachedMax;
1642
- writePos = W;
2071
+ writePos = K;
1643
2072
  _refCount = 0;
1644
2073
  cachedLength;
1645
2074
  _cachedIndexes;
1646
2075
  static crudeZ = t.object({
1647
- timeRange: B.z.optional(),
1648
- dataType: V.z,
2076
+ timeRange: L.z.optional(),
2077
+ dataType: R.z,
1649
2078
  alignment: t.coerce.bigint().optional(),
1650
2079
  data: t.union([
1651
- Tt,
1652
- Et,
2080
+ vn,
2081
+ yn,
1653
2082
  t.instanceof(ArrayBuffer),
1654
2083
  t.instanceof(Uint8Array)
1655
2084
  ]),
1656
- glBufferUsage: pt.default("static").optional()
2085
+ glBufferUsage: dn.default("static").optional()
1657
2086
  });
1658
2087
  static z = e.crudeZ.transform((t) => new e(t));
1659
2088
  constructor(e) {
1660
- jt(e) && (e = { data: e }), e.data ??= [];
1661
- let { dataType: t, timeRange: n, sampleOffset: r = 0, glBufferUsage: i = "static", alignment: a = 0n, alignmentMultiple: o = 1n, key: s = fe(), data: c } = e;
1662
- if (Mt(c)) {
2089
+ Cn(e) && (e = { data: e }), e.data ??= [];
2090
+ let { dataType: t, timeRange: n, sampleOffset: r = 0, glBufferUsage: i = "static", alignment: a = 0n, alignmentMultiple: o = 1n, key: s = kt(), data: c } = e;
2091
+ if (wn(c)) {
1663
2092
  let e = c;
1664
2093
  this.key = e.key, this.dataType = e.dataType, this.sampleOffset = e.sampleOffset, this.gl = e.gl, this._data = e._data, this.timeRange = e.timeRange, this.alignment = e.alignment, this.alignmentMultiple = e.alignmentMultiple, this.cachedMin = e.cachedMin, this.cachedMax = e.cachedMax, this.writePos = e.writePos, this._refCount = e._refCount, this.cachedLength = e.cachedLength;
1665
2094
  return;
1666
2095
  }
1667
- let l = _t(c), u = Array.isArray(c);
1668
- if (t != null) this.dataType = new V(t);
2096
+ let l = bt(c), u = Array.isArray(c);
2097
+ if (t != null) this.dataType = new R(t);
1669
2098
  else if (c instanceof ArrayBuffer) throw Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");
1670
2099
  else if (u || l) {
1671
2100
  let e = c;
@@ -1673,21 +2102,31 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1673
2102
  if (c.length === 0) throw Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");
1674
2103
  e = c[0];
1675
2104
  }
1676
- if (typeof e == "string") this.dataType = V.STRING;
1677
- else if (typeof e == "number") this.dataType = V.FLOAT64;
1678
- else if (typeof e == "bigint") this.dataType = V.INT64;
1679
- else if (typeof e == "boolean") this.dataType = V.UINT8;
1680
- else if (e instanceof I || e instanceof Date || e instanceof I) this.dataType = V.TIMESTAMP;
1681
- else if (typeof e == "object") this.dataType = V.JSON;
2105
+ if (typeof e == "string") this.dataType = R.STRING;
2106
+ else if (typeof e == "number") this.dataType = R.FLOAT64;
2107
+ else if (typeof e == "bigint") this.dataType = R.INT64;
2108
+ else if (typeof e == "boolean") this.dataType = R.UINT8;
2109
+ else if (e instanceof P || e instanceof Date || e instanceof P) this.dataType = R.TIMESTAMP;
2110
+ else if (typeof e == "object") this.dataType = R.JSON;
1682
2111
  else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`);
1683
- } else this.dataType = new V(c);
2112
+ } else this.dataType = new R(c);
1684
2113
  if (!u && !l) this._data = c;
1685
2114
  else if (u && c.length === 0) this._data = new this.dataType.Array([]).buffer;
1686
2115
  else {
1687
2116
  let e = l ? [c] : c, t = e[0];
1688
- (t instanceof I || t instanceof Date || t instanceof L) && (e = e.map((e) => new I(e).valueOf())), this.dataType.equals(V.STRING) ? (this.cachedLength = e.length, this._data = new TextEncoder().encode(`${e.join("\n")}\n`).buffer) : this.dataType.equals(V.JSON) ? (this.cachedLength = e.length, this._data = new TextEncoder().encode(`${e.map((e) => re.encodeString(e)).join("\n")}\n`).buffer) : this.dataType.usesBigInt && typeof t == "number" ? this._data = new this.dataType.Array(e.map((e) => BigInt(Math.round(e)))).buffer : !this.dataType.usesBigInt && typeof t == "bigint" ? this._data = new this.dataType.Array(e.map(Number)).buffer : this._data = new this.dataType.Array(e).buffer;
2117
+ if ((t instanceof P || t instanceof Date || t instanceof F) && (e = e.map((e) => new P(e).valueOf())), this.dataType.equals(R.STRING)) {
2118
+ this.cachedLength = e.length;
2119
+ let t = e.map((e) => new TextEncoder().encode(e)), n = t.reduce((e, t) => e + q + t.byteLength, 0), r = new ArrayBuffer(n), i = new DataView(r), a = new Uint8Array(r), o = 0;
2120
+ for (let e of t) i.setUint32(o, e.byteLength, !0), o += q, a.set(e, o), o += e.byteLength;
2121
+ this._data = r;
2122
+ } else if (this.dataType.equals(R.JSON)) {
2123
+ this.cachedLength = e.length;
2124
+ let t = e.map((e) => new TextEncoder().encode(ht.encodeString(e))), n = t.reduce((e, t) => e + q + t.byteLength, 0), r = new ArrayBuffer(n), i = new DataView(r), a = new Uint8Array(r), o = 0;
2125
+ for (let e of t) i.setUint32(o, e.byteLength, !0), o += q, a.set(e, o), o += e.byteLength;
2126
+ this._data = r;
2127
+ } else this.dataType.usesBigInt && typeof t == "number" ? this._data = new this.dataType.Array(e.map((e) => BigInt(Math.round(e)))).buffer : !this.dataType.usesBigInt && typeof t == "bigint" ? this._data = new this.dataType.Array(e.map(Number)).buffer : this._data = new this.dataType.Array(e).buffer;
1689
2128
  }
1690
- this.key = s, this.alignment = a, this.alignmentMultiple = o, this.sampleOffset = r ?? 0, this.timeRange = n ?? B.ZERO, this.gl = {
2129
+ this.key = s, this.alignment = a, this.alignmentMultiple = o, this.sampleOffset = r ?? 0, this.timeRange = n ?? L.ZERO, this.gl = {
1691
2130
  control: null,
1692
2131
  buffer: null,
1693
2132
  prevBuffer: 0,
@@ -1697,7 +2136,7 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1697
2136
  static alloc({ capacity: t, dataType: n, ...r }) {
1698
2137
  if (t === 0) throw Error("[Series] - cannot allocate an array of length 0");
1699
2138
  let i = new e({
1700
- data: new new V(n).Array(t).buffer,
2139
+ data: new new R(n).Array(t).buffer,
1701
2140
  dataType: n,
1702
2141
  ...r
1703
2142
  });
@@ -1717,12 +2156,19 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1717
2156
  return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
1718
2157
  }
1719
2158
  writeVariable(e) {
1720
- if (this.writePos === W) return 0;
1721
- let t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
1722
- return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += n.length, this.calculateCachedLength()), n.length;
2159
+ if (this.writePos === K) return 0;
2160
+ let t = this.byteCapacity.valueOf() - this.writePos, n = e.buffer, r = e.byteLength.valueOf(), i = new DataView(n), a = 0, o = 0;
2161
+ for (; a + q <= r;) {
2162
+ let e = q + i.getUint32(a, !0);
2163
+ if (a + e > t) break;
2164
+ a += e, o++;
2165
+ }
2166
+ if (a === 0) return 0;
2167
+ let s = e.subBytes(0, a);
2168
+ return this.writeToUnderlyingData(s), this.writePos += a, this.cachedLength = (this.cachedLength ?? 0) + o, this._cachedIndexes = void 0, o;
1723
2169
  }
1724
2170
  writeFixed(e) {
1725
- if (this.writePos === W) return 0;
2171
+ if (this.writePos === K) return 0;
1726
2172
  let t = this.capacity - this.writePos, n = e.sub(0, t);
1727
2173
  return this.writeToUnderlyingData(n), this.cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
1728
2174
  }
@@ -1736,38 +2182,48 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1736
2182
  return new this.dataType.Array(this._data);
1737
2183
  }
1738
2184
  get data() {
1739
- return this.writePos === W ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2185
+ return this.writePos === K ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1740
2186
  }
1741
2187
  toStrings() {
1742
- return this.dataType.isVariable ? new TextDecoder().decode(this.underlyingData).split("\n").slice(0, -1) : Array.from(this).map((e) => e.toString());
2188
+ if (this.dataType.isVariable) {
2189
+ let e = [], t = this.buffer, n = this.byteLength.valueOf(), r = new DataView(t), i = new TextDecoder(), a = 0;
2190
+ for (; a + q <= n;) {
2191
+ let n = r.getUint32(a, !0);
2192
+ a += q, e.push(i.decode(new Uint8Array(t, a, n))), a += n;
2193
+ }
2194
+ return e;
2195
+ }
2196
+ return Array.from(this).map((e) => e.toString());
1743
2197
  }
1744
2198
  parseJSON(e) {
1745
- if (!this.dataType.equals(V.JSON)) throw Error("cannot parse non-JSON series as JSON");
1746
- return this.toStrings().map((t) => e.parse(re.decodeString(t)));
2199
+ if (!this.dataType.equals(R.JSON)) throw Error("cannot parse non-JSON series as JSON");
2200
+ return this.toStrings().map((t) => e.parse(ht.decodeString(t)));
1747
2201
  }
1748
2202
  get byteCapacity() {
1749
- return new H(this.underlyingData.byteLength);
2203
+ return new z(this.underlyingData.byteLength);
1750
2204
  }
1751
2205
  get capacity() {
1752
2206
  return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
1753
2207
  }
1754
2208
  get byteLength() {
1755
- return this.writePos === W ? this.byteCapacity : this.dataType.isVariable ? new H(this.writePos) : this.dataType.density.size(this.writePos);
2209
+ return this.writePos === K ? this.byteCapacity : this.dataType.isVariable ? new z(this.writePos) : this.dataType.density.size(this.writePos);
1756
2210
  }
1757
2211
  get length() {
1758
- return this.cachedLength == null ? this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === W ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos : this.cachedLength;
2212
+ return this.cachedLength == null ? this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === K ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos : this.cachedLength;
1759
2213
  }
1760
2214
  calculateCachedLength() {
1761
2215
  if (!this.dataType.isVariable) throw Error("cannot calculate length of a non-variable length data type");
1762
- let e = 0, t = [0];
1763
- return this.data.forEach((n, r) => {
1764
- n === Dt && (e++, t.push(r + 1));
1765
- }), this._cachedIndexes = t, this.cachedLength = e, e;
2216
+ let e = 0, t = [], n = this.buffer, r = this.byteLength.valueOf(), i = new DataView(n), a = 0;
2217
+ for (; a + q <= r;) {
2218
+ let n = i.getUint32(a, !0);
2219
+ a += q, t.push(a), a += n, e++;
2220
+ }
2221
+ return this._cachedIndexes = t, this.cachedLength = e, e;
1766
2222
  }
1767
2223
  convert(t, n = 0) {
1768
2224
  if (this.dataType.equals(t)) return this;
1769
2225
  let r = new t.Array(this.length);
1770
- for (let e = 0; e < this.length; e++) r[e] = vt(this.dataType, t, this.data[e], n);
2226
+ for (let e = 0; e < this.length; e++) r[e] = xt(this.dataType, t, this.data[e], n);
1771
2227
  return new e({
1772
2228
  data: r.buffer,
1773
2229
  dataType: t,
@@ -1778,27 +2234,27 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1778
2234
  });
1779
2235
  }
1780
2236
  calcRawMax() {
1781
- return this.length === 0 ? -Infinity : (this.dataType.equals(V.TIMESTAMP) ? this.cachedMax = this.data[this.data.length - 1] : (this.dataType.usesBigInt, this.cachedMax = this.data.reduce((e, t) => e > t ? e : t)), this.cachedMax);
2237
+ return this.length === 0 ? -Infinity : (this.dataType.equals(R.TIMESTAMP) ? this.cachedMax = this.data[this.data.length - 1] : (this.dataType.usesBigInt, this.cachedMax = this.data.reduce((e, t) => e > t ? e : t)), this.cachedMax);
1782
2238
  }
1783
2239
  get max() {
1784
2240
  return this.calcMax();
1785
2241
  }
1786
2242
  calcMax() {
1787
2243
  if (this.dataType.isVariable) throw Error("cannot calculate maximum on a variable length data type");
1788
- return this.writePos === 0 ? -Infinity : (this.cachedMax ??= this.calcRawMax(), C(this.cachedMax, this.sampleOffset));
2244
+ return this.writePos === 0 ? -Infinity : (this.cachedMax ??= this.calcRawMax(), k(this.cachedMax, this.sampleOffset));
1789
2245
  }
1790
2246
  calcRawMin() {
1791
- return this.length === 0 ? Infinity : (this.dataType.equals(V.TIMESTAMP) ? this.cachedMin = this.data[0] : (this.dataType.usesBigInt, this.cachedMin = this.data.reduce((e, t) => e < t ? e : t)), this.cachedMin);
2247
+ return this.length === 0 ? Infinity : (this.dataType.equals(R.TIMESTAMP) ? this.cachedMin = this.data[0] : (this.dataType.usesBigInt, this.cachedMin = this.data.reduce((e, t) => e < t ? e : t)), this.cachedMin);
1792
2248
  }
1793
2249
  get min() {
1794
2250
  return this.calcMin();
1795
2251
  }
1796
2252
  calcMin() {
1797
2253
  if (this.dataType.isVariable) throw Error("cannot calculate minimum on a variable length data type");
1798
- return this.writePos === 0 ? Infinity : (this.cachedMin ??= this.calcRawMin(), C(this.cachedMin, this.sampleOffset));
2254
+ return this.writePos === 0 ? Infinity : (this.cachedMin ??= this.calcRawMin(), k(this.cachedMin, this.sampleOffset));
1799
2255
  }
1800
2256
  get bounds() {
1801
- return D(Number(this.min), Number(this.max), { makeValid: !1 });
2257
+ return M(Number(this.min), Number(this.max), { makeValid: !1 });
1802
2258
  }
1803
2259
  maybeRecomputeMinMax(e) {
1804
2260
  if (this.cachedMin != null) {
@@ -1820,18 +2276,18 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1820
2276
  }
1821
2277
  at(e, t = !1) {
1822
2278
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
1823
- if (this.dataType.equals(V.UUID)) return this.atUUID(e, t);
2279
+ if (this.dataType.equals(R.UUID)) return this.atUUID(e, t);
1824
2280
  e < 0 && (e = this.length + e);
1825
2281
  let n = this.data[e];
1826
2282
  if (n == null) {
1827
2283
  if (t === !0) throw Error(`[series] - no value at index ${e}`);
1828
2284
  return;
1829
2285
  }
1830
- return C(n, this.sampleOffset);
2286
+ return k(n, this.sampleOffset);
1831
2287
  }
1832
2288
  atUUID(e, t) {
1833
2289
  e < 0 && (e = this.length + e);
1834
- let n = Ct(new Uint8Array(this.buffer, e * this.dataType.density.valueOf()));
2290
+ let n = gn(new Uint8Array(this.buffer, e * this.dataType.density.valueOf()));
1835
2291
  if (n == null) {
1836
2292
  if (t) throw Error(`[series] - no value at index ${e}`);
1837
2293
  return;
@@ -1839,27 +2295,34 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1839
2295
  return n;
1840
2296
  }
1841
2297
  atVariable(e, t) {
1842
- let n = 0, r = 0;
1843
- if (this._cachedIndexes != null) n = this._cachedIndexes[e], r = this._cachedIndexes[e + 1] - 1;
1844
- else {
2298
+ let n = 0, r = 0, i = this.buffer, a = new DataView(i);
2299
+ if (this._cachedIndexes != null) {
2300
+ if (e < 0 && (e = this._cachedIndexes.length + e), e < 0 || e >= this._cachedIndexes.length) {
2301
+ if (t) throw Error(`[series] - no value at index ${e}`);
2302
+ return;
2303
+ }
2304
+ n = this._cachedIndexes[e], r = a.getUint32(n - q, !0);
2305
+ } else {
1845
2306
  e < 0 && (e = this.length + e);
1846
- for (let t = 0; t < this.data.length; t++) if (this.data[t] === Dt) {
1847
- if (e === 0) {
1848
- r = t;
2307
+ let i = this.byteLength.valueOf(), o = 0, s = !1;
2308
+ for (; o + q <= i;) {
2309
+ let t = a.getUint32(o, !0);
2310
+ if (o += q, e === 0) {
2311
+ n = o, r = t, s = !0;
1849
2312
  break;
1850
2313
  }
1851
- n = t + 1, e--;
2314
+ o += t, e--;
1852
2315
  }
1853
- if (r === 0 && (r = this.data.length), n >= r || e > 0) {
2316
+ if (!s) {
1854
2317
  if (t) throw Error(`[series] - no value at index ${e}`);
1855
2318
  return;
1856
2319
  }
1857
2320
  }
1858
- let i = this.data.slice(n, r);
1859
- return this.dataType.equals(V.STRING) ? new TextDecoder().decode(i) : f(JSON.parse(new TextDecoder().decode(i)));
2321
+ let o = new Uint8Array(i, n, r);
2322
+ return this.dataType.equals(R.STRING) ? new TextDecoder().decode(o) : f(JSON.parse(new TextDecoder().decode(o)));
1860
2323
  }
1861
2324
  binarySearch(e) {
1862
- let t = 0, n = this.length - 1, r = ae(e);
2325
+ let t = 0, n = this.length - 1, r = St(e);
1863
2326
  for (; t <= n;) {
1864
2327
  let i = Math.floor((t + n) / 2), a = r(this.at(i, !0), e);
1865
2328
  if (a === 0) return i;
@@ -1868,16 +2331,16 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1868
2331
  return t;
1869
2332
  }
1870
2333
  updateGLBuffer(e) {
1871
- if (this.gl.control = e, !this.dataType.equals(V.FLOAT32) && !this.dataType.equals(V.UINT8)) throw Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2334
+ if (this.gl.control = e, !this.dataType.equals(R.FLOAT32) && !this.dataType.equals(R.UINT8)) throw Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
1872
2335
  let { buffer: t, bufferUsage: n, prevBuffer: r } = this.gl;
1873
- if (t ?? (this.gl.buffer = e.createBuffer()), this.writePos !== r) if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== W) {
2336
+ if (t ?? (this.gl.buffer = e.createBuffer()), this.writePos !== r) if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== K) {
1874
2337
  r === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
1875
2338
  let t = this.dataType.density.size(r).valueOf(), n = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1876
2339
  e.bufferSubData(e.ARRAY_BUFFER, t, n.buffer), this.gl.prevBuffer = this.writePos;
1877
- } else e.bufferData(e.ARRAY_BUFFER, this.buffer, n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW), this.gl.prevBuffer = W;
2340
+ } else e.bufferData(e.ARRAY_BUFFER, this.buffer, n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW), this.gl.prevBuffer = K;
1878
2341
  }
1879
2342
  as(e) {
1880
- return Ot(e, this.dataType), this;
2343
+ return bn(e, this.dataType), this;
1881
2344
  }
1882
2345
  get digest() {
1883
2346
  return {
@@ -1885,8 +2348,8 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1885
2348
  dataType: this.dataType.toString(),
1886
2349
  sampleOffset: this.sampleOffset,
1887
2350
  alignment: {
1888
- lower: Rt(this.alignmentBounds.lower),
1889
- upper: Rt(this.alignmentBounds.upper),
2351
+ lower: An(this.alignmentBounds.lower),
2352
+ upper: An(this.alignmentBounds.upper),
1890
2353
  multiple: this.alignmentMultiple
1891
2354
  },
1892
2355
  timeRange: this.timeRange.toString(),
@@ -1895,7 +2358,7 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1895
2358
  };
1896
2359
  }
1897
2360
  get alignmentBounds() {
1898
- return D(this.alignment, this.alignment + BigInt(this.length) * this.alignmentMultiple);
2361
+ return M(this.alignment, this.alignment + BigInt(this.length) * this.alignmentMultiple);
1899
2362
  }
1900
2363
  maybeGarbageCollectGLBuffer(e) {
1901
2364
  this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
@@ -1906,10 +2369,10 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1906
2369
  }
1907
2370
  [Symbol.iterator]() {
1908
2371
  if (this.dataType.isVariable) {
1909
- let e = new Pt(this);
1910
- return this.dataType.equals(V.JSON) ? new Ft(e) : e;
2372
+ let e = new En(this);
2373
+ return this.dataType.equals(R.JSON) ? new Dn(e) : e;
1911
2374
  }
1912
- return this.dataType.equals(V.UUID) ? new It(this) : new Lt(this);
2375
+ return this.dataType.equals(R.UUID) ? new On(this) : new kn(this);
1913
2376
  }
1914
2377
  slice(e, t) {
1915
2378
  return this.sliceSub(!1, e, t);
@@ -1918,11 +2381,11 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1918
2381
  return this.sliceSub(!0, e, t);
1919
2382
  }
1920
2383
  subIterator(e, t) {
1921
- return new Nt(this, e, t ?? this.length);
2384
+ return new Tn(this, e, t ?? this.length);
1922
2385
  }
1923
2386
  subAlignmentIterator(e, t) {
1924
2387
  let n = Math.ceil(Number(e - this.alignment) / Number(this.alignmentMultiple)), r = Math.ceil(Number(t - this.alignment) / Number(this.alignmentMultiple));
1925
- return new Nt(this, n, r);
2388
+ return new Tn(this, n, r);
1926
2389
  }
1927
2390
  subBytes(t, n) {
1928
2391
  return t >= 0 && (n == null || n >= this.byteLength.valueOf()) ? this : new e({
@@ -1950,7 +2413,7 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1950
2413
  return new e({
1951
2414
  data: this.buffer,
1952
2415
  dataType: this.dataType,
1953
- timeRange: B.ZERO,
2416
+ timeRange: L.ZERO,
1954
2417
  sampleOffset: this.sampleOffset,
1955
2418
  glBufferUsage: "static",
1956
2419
  alignment: t
@@ -1966,14 +2429,14 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1966
2429
  }
1967
2430
  return e += "])", e;
1968
2431
  }
1969
- }, jt = (e) => e == null ? !1 : Array.isArray(e) || e instanceof ArrayBuffer || ArrayBuffer.isView(e) && !(e instanceof DataView) || e instanceof At ? !0 : _t(e), Mt = pe(kt, At), Nt = class {
2432
+ }, Cn = (e) => e == null ? !1 : Array.isArray(e) || e instanceof ArrayBuffer || ArrayBuffer.isView(e) && !(e instanceof DataView) || e instanceof Sn ? !0 : bt(e), wn = At(xn, Sn), Tn = class {
1970
2433
  series;
1971
2434
  end;
1972
2435
  index;
1973
2436
  constructor(e, t, n) {
1974
2437
  this.series = e;
1975
- let r = D(0, e.length + 1);
1976
- this.end = Fe(r, n), this.index = Fe(r, t);
2438
+ let r = M(0, e.length + 1);
2439
+ this.end = ut(r, n), this.index = ut(r, t);
1977
2440
  }
1978
2441
  next() {
1979
2442
  return this.index >= this.end ? {
@@ -1984,27 +2447,30 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
1984
2447
  value: this.series.at(this.index++, !0)
1985
2448
  };
1986
2449
  }
1987
- }, Pt = class {
2450
+ }, En = class {
1988
2451
  series;
1989
- index;
2452
+ byteOffset;
1990
2453
  decoder;
2454
+ view;
1991
2455
  constructor(e) {
1992
2456
  if (!e.dataType.isVariable) throw Error("cannot create a variable series iterator for a non-variable series");
1993
- this.series = e, this.index = 0, this.decoder = new TextDecoder();
2457
+ this.series = e, this.byteOffset = 0, this.decoder = new TextDecoder(), this.view = new DataView(e.buffer);
1994
2458
  }
1995
2459
  next() {
1996
- let e = this.index, t = this.series.data;
1997
- for (; this.index < t.length && t[this.index] !== Dt;) this.index++;
1998
- let n = this.index;
1999
- return e === n ? {
2460
+ let e = this.series.byteLength.valueOf();
2461
+ if (this.byteOffset + q > e) return {
2000
2462
  done: !0,
2001
2463
  value: void 0
2002
- } : (this.index++, {
2464
+ };
2465
+ let t = this.view.getUint32(this.byteOffset, !0);
2466
+ this.byteOffset += q;
2467
+ let n = this.decoder.decode(new Uint8Array(this.series.buffer, this.byteOffset, t));
2468
+ return this.byteOffset += t, {
2003
2469
  done: !1,
2004
- value: this.decoder.decode(this.series.buffer.slice(e, n))
2005
- });
2470
+ value: n
2471
+ };
2006
2472
  }
2007
- }, Ft = class e {
2473
+ }, Dn = class e {
2008
2474
  wrapped;
2009
2475
  static schema = t.record(t.string(), t.unknown());
2010
2476
  constructor(e) {
@@ -2017,30 +2483,30 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
2017
2483
  value: void 0
2018
2484
  } : {
2019
2485
  done: !1,
2020
- value: re.decodeString(t.value, e.schema)
2486
+ value: ht.decodeString(t.value, e.schema)
2021
2487
  };
2022
2488
  }
2023
- }, It = class {
2489
+ }, On = class {
2024
2490
  series;
2025
2491
  index;
2026
2492
  data;
2027
2493
  density;
2028
2494
  constructor(e) {
2029
- if (!e.dataType.equals(V.UUID)) throw Error("cannot create a UUID series iterator for a non-UUID series");
2030
- this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = V.UUID.density.valueOf();
2495
+ if (!e.dataType.equals(R.UUID)) throw Error("cannot create a UUID series iterator for a non-UUID series");
2496
+ this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = R.UUID.density.valueOf();
2031
2497
  }
2032
2498
  next() {
2033
2499
  if (this.index >= this.series.length) return {
2034
2500
  done: !0,
2035
2501
  value: void 0
2036
2502
  };
2037
- let e = Ct(this.data, this.index * this.density);
2503
+ let e = gn(this.data, this.index * this.density);
2038
2504
  return this.index++, {
2039
2505
  done: !1,
2040
2506
  value: e
2041
2507
  };
2042
2508
  }
2043
- }, Lt = class {
2509
+ }, kn = class {
2044
2510
  series;
2045
2511
  index;
2046
2512
  constructor(e) {
@@ -2055,23 +2521,23 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
2055
2521
  value: this.series.at(this.index++, !0)
2056
2522
  };
2057
2523
  }
2058
- }, Rt = (e) => ({
2524
+ }, An = (e) => ({
2059
2525
  domain: e >> 32n,
2060
2526
  sample: e & 4294967295n
2061
- }), zt = async (e) => await new Promise((t) => setTimeout(t, L.fromMilliseconds(e).milliseconds)), Bt = /* @__PURE__ */ r({
2062
- Breaker: () => Vt,
2063
- breakerConfigZ: () => Ht
2064
- }), Vt = class {
2527
+ }), jn = async (e) => await new Promise((t) => setTimeout(t, F.fromMilliseconds(e).milliseconds)), Mn = /* @__PURE__ */ r({
2528
+ Breaker: () => Nn,
2529
+ breakerConfigZ: () => Pn
2530
+ }), Nn = class {
2065
2531
  config;
2066
2532
  retries;
2067
2533
  interval;
2068
2534
  constructor(e) {
2069
2535
  this.config = {
2070
- baseInterval: new L(e?.baseInterval ?? L.seconds(1)),
2536
+ baseInterval: new F(e?.baseInterval ?? F.seconds(1)),
2071
2537
  maxRetries: e?.maxRetries ?? 5,
2072
2538
  scale: e?.scale ?? 1,
2073
- sleepFn: e?.sleepFn ?? zt
2074
- }, this.retries = 0, this.interval = new L(this.config.baseInterval);
2539
+ sleepFn: e?.sleepFn ?? jn
2540
+ }, this.retries = 0, this.interval = new F(this.config.baseInterval);
2075
2541
  }
2076
2542
  async wait() {
2077
2543
  let { maxRetries: e, scale: t, sleepFn: n } = this.config;
@@ -2083,82 +2549,38 @@ var Ct = (e, t) => St(e, t), W = -1, wt = {
2083
2549
  reset() {
2084
2550
  this.retries = 0, this.interval = this.config.baseInterval;
2085
2551
  }
2086
- }, Ht = t.object({
2087
- baseInterval: L.z.optional(),
2552
+ }, Pn = t.object({
2553
+ baseInterval: F.z.optional(),
2088
2554
  maxRetries: t.number().optional(),
2089
2555
  scale: t.number().optional()
2090
- });
2091
- t.int().min(_e).max(127), t.int().min(ve).max(ye), t.int().min(xe).max(Se);
2092
- var Ut = t.int().min(0).max(255);
2093
- t.int().min(0).max(me), t.int().min(0).max(he), t.int().min(0).max(ge);
2094
- var Wt = (e, t) => {
2095
- let n = Array.isArray(e), r = Array.isArray(t);
2096
- if (n !== r) return !1;
2097
- if (n && r) {
2098
- let n = e, r = t;
2099
- if (n.length !== r.length) return !1;
2100
- for (let e = 0; e < n.length; e++) if (!Wt(n[e], r[e])) return !1;
2101
- return !0;
2102
- }
2103
- if (e == null || t == null || typeof e != "object" || typeof t != "object") return e === t;
2104
- if ("equals" in e) return e.equals(t);
2105
- let i = Object.keys(e), a = Object.keys(t);
2106
- if (i.length !== a.length) return !1;
2107
- for (let n of i) {
2108
- let r = e[n], i = t[n];
2109
- if (typeof r == "object" && typeof i == "object") {
2110
- if (!Wt(r, i)) return !1;
2111
- } else if (r !== i) return !1;
2112
- }
2113
- return !0;
2114
- }, Gt = (e, t) => {
2115
- if (typeof e != "object" || !e) return e === t;
2116
- let n = Object.keys(e), r = Object.keys(t);
2117
- if (r.length > n.length) return !1;
2118
- for (let n of r) {
2119
- let r = e[n], i = t[n];
2120
- if (typeof r == "object" && typeof i == "object") {
2121
- if (!Gt(r, i)) return !1;
2122
- } else if (r !== i) return !1;
2123
- }
2124
- return !0;
2125
- }, Kt = (e, ...t) => {
2126
- if (t.length === 0) return e;
2127
- let n = t.shift();
2128
- if (_(e) && _(n)) for (let t in n) try {
2129
- _(n[t]) ? (t in e || Object.assign(e, { [t]: {} }), Kt(e[t], n[t])) : Object.assign(e, { [t]: n[t] });
2130
- } catch (e) {
2131
- throw e instanceof TypeError ? TypeError(`.${t}: ${e.message}`, { cause: e }) : e;
2132
- }
2133
- return Kt(e, ...t);
2134
- }, qt = t.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i), G = Ut, Jt = t.number().min(0).max(1), Yt = t.tuple([
2135
- G,
2136
- G,
2137
- G,
2138
- Jt
2139
- ]), Xt = t.tuple([
2140
- G,
2141
- G,
2142
- G
2143
- ]), Zt = t.object({ rgba255: Yt }), Qt = t.object({
2144
- r: G,
2145
- g: G,
2146
- b: G,
2147
- a: Jt
2148
- }), $t = t.number().min(0).max(360), en = t.number().min(0).max(100), tn = t.number().min(0).max(100), nn = t.tuple([
2149
- $t,
2150
- en,
2151
- tn,
2152
- Jt
2153
- ]), rn = t.union([
2154
- qt,
2155
- Xt,
2156
- Yt,
2157
- nn,
2158
- Zt,
2159
- Qt
2160
- ]), an = rn.transform((e) => on(e)), on = (e, t = 1) => {
2161
- if (e = rn.parse(e), typeof e == "string") return sn(e, t);
2556
+ }), Fn = t.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i), J = dt, In = t.number().min(0).max(1), Ln = t.tuple([
2557
+ J,
2558
+ J,
2559
+ J,
2560
+ In
2561
+ ]), Rn = t.tuple([
2562
+ J,
2563
+ J,
2564
+ J
2565
+ ]), zn = t.object({ rgba255: Ln }), Bn = t.object({
2566
+ r: J,
2567
+ g: J,
2568
+ b: J,
2569
+ a: In
2570
+ }), Vn = t.number().min(0).max(360), Hn = t.number().min(0).max(100), Un = t.number().min(0).max(100), Wn = t.tuple([
2571
+ Vn,
2572
+ Hn,
2573
+ Un,
2574
+ In
2575
+ ]), Gn = t.union([
2576
+ Fn,
2577
+ Rn,
2578
+ Ln,
2579
+ Wn,
2580
+ zn,
2581
+ Bn
2582
+ ]), Kn = Gn.transform((e) => qn(e)), qn = (e, t = 1) => {
2583
+ if (e = Gn.parse(e), typeof e == "string") return Jn(e, t);
2162
2584
  if (Array.isArray(e)) {
2163
2585
  if (e.length < 3 || e.length > 4) throw Error(`Invalid color: [${e.join(", ")}]`);
2164
2586
  return e.length === 3 ? [...e, t] : e;
@@ -2169,127 +2591,38 @@ var Wt = (e, t) => {
2169
2591
  e.b,
2170
2592
  e.a
2171
2593
  ] : e.rgba255;
2172
- }, sn = (e, t = 1) => (e = qt.parse(e), e = cn(e), [
2173
- K(e, 0),
2174
- K(e, 2),
2175
- K(e, 4),
2176
- e.length === 8 ? K(e, 6) / 255 : t
2177
- ]), K = (e, t) => parseInt(e.slice(t, t + 2), 16), cn = (e) => e.startsWith("#") ? e.slice(1) : e;
2178
- on("#000000"), on("#ffffff");
2179
- var ln = t.object({
2594
+ }, Jn = (e, t = 1) => (e = Fn.parse(e), e = Yn(e), [
2595
+ Y(e, 0),
2596
+ Y(e, 2),
2597
+ Y(e, 4),
2598
+ e.length === 8 ? Y(e, 6) / 255 : t
2599
+ ]), Y = (e, t) => parseInt(e.slice(t, t + 2), 16), Yn = (e) => e.startsWith("#") ? e.slice(1) : e;
2600
+ qn("#000000"), qn("#ffffff");
2601
+ var Xn = t.object({
2180
2602
  key: t.string(),
2181
- color: rn,
2603
+ color: Gn,
2182
2604
  position: t.number(),
2183
2605
  switched: t.boolean().optional()
2184
2606
  });
2185
- t.array(ln);
2186
- var un = t.object({
2607
+ t.array(Xn);
2608
+ var Zn = t.object({
2187
2609
  key: t.string(),
2188
2610
  name: t.string(),
2189
- color: an
2611
+ color: Kn
2190
2612
  });
2191
2613
  t.object({
2192
2614
  key: t.string(),
2193
2615
  name: t.string(),
2194
- swatches: t.array(un)
2616
+ swatches: t.array(Zn)
2195
2617
  });
2196
- var dn = /* @__PURE__ */ function(e) {
2618
+ var Qn = /* @__PURE__ */ function(e) {
2197
2619
  return e[e.exclusive = 0] = "exclusive", e[e.shared = 1] = "shared", e;
2198
2620
  }({});
2199
- t.enum(dn), t.object({
2621
+ t.enum(Qn), t.object({
2200
2622
  key: t.string(),
2201
2623
  name: t.string(),
2202
2624
  group: t.uint32().optional()
2203
- });
2204
- var fn = (e) => Object.getOwnPropertySymbols(globalThis).includes(e), pn = (e, t) => {
2205
- let n = Symbol.for(e);
2206
- if (!fn(n)) {
2207
- let e = t();
2208
- Object.defineProperty(globalThis, n, { value: e });
2209
- }
2210
- return () => globalThis[n];
2211
- }, q = /* @__PURE__ */ r({
2212
- Canceled: () => wn,
2213
- NONE: () => "nil",
2214
- NotImplemented: () => Tn,
2215
- UNKNOWN: () => Y,
2216
- Unknown: () => Sn,
2217
- createTyped: () => J,
2218
- decode: () => xn,
2219
- encode: () => bn,
2220
- isTyped: () => gn,
2221
- payloadZ: () => Cn,
2222
- register: () => yn
2223
- }), mn = "sy_x_error", hn = (e) => (t) => typeof t == "object" && t && "type" in t && typeof t.type == "string" ? t.type.startsWith(e) : t instanceof Error ? t.message.startsWith(e) : typeof t == "string" ? t.startsWith(e) : !1, J = (e) => class t extends Error {
2224
- static discriminator = mn;
2225
- discriminator = t.discriminator;
2226
- static TYPE = e;
2227
- type = t.TYPE;
2228
- static matches = hn(e);
2229
- matches = t.matches;
2230
- constructor(e, n) {
2231
- super(e, n), this.name = t.TYPE;
2232
- }
2233
- static sub(t) {
2234
- return J(`${e}.${t}`);
2235
- }
2236
- }, gn = (e) => {
2237
- if (typeof e != "object" || !e) return !1;
2238
- let t = e;
2239
- if (t.discriminator !== mn) return !1;
2240
- if (!("type" in t)) throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);
2241
- return !0;
2242
- }, Y = "unknown", _n = class {
2243
- providers = [];
2244
- register(e) {
2245
- this.providers.push(e);
2246
- }
2247
- encode(e) {
2248
- if (e == null) return {
2249
- type: "nil",
2250
- data: ""
2251
- };
2252
- if (gn(e)) for (let t of this.providers) {
2253
- let n = t.encode(e);
2254
- if (n != null) return n;
2255
- }
2256
- if (e instanceof Error) return {
2257
- type: Y,
2258
- data: e.message
2259
- };
2260
- if (typeof e == "string") return {
2261
- type: Y,
2262
- data: e
2263
- };
2264
- try {
2265
- return {
2266
- type: Y,
2267
- data: JSON.stringify(e)
2268
- };
2269
- } catch {
2270
- return {
2271
- type: Y,
2272
- data: "unable to encode error information"
2273
- };
2274
- }
2275
- }
2276
- decode(e) {
2277
- if (e == null || e.type === "nil") return null;
2278
- if (e.type === "unknown") return new Sn(e.data);
2279
- for (let t of this.providers) {
2280
- let n = t.decode(e);
2281
- if (n != null) return n;
2282
- }
2283
- return new Sn(e.data);
2284
- }
2285
- }, vn = pn("synnax-error-registry", () => new _n()), yn = ({ encode: e, decode: t }) => vn().register({
2286
- encode: e,
2287
- decode: t
2288
- }), bn = (e) => vn().encode(e), xn = (e) => e == null ? null : vn().decode(e), Sn = class extends J("unknown") {}, Cn = t.object({
2289
- type: t.string(),
2290
- data: t.string()
2291
- }), wn = class extends J("canceled") {}, Tn = class extends J("not_implemented") {};
2292
- t.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/, "must be a valid JSON pointer (RFC 6901)"), t.union([
2625
+ }), t.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/, "must be a valid JSON pointer (RFC 6901)"), t.union([
2293
2626
  t.string(),
2294
2627
  t.number(),
2295
2628
  t.boolean(),
@@ -2303,33 +2636,39 @@ t.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/, "must be a valid JSON pointe
2303
2636
  key: t.string(),
2304
2637
  value: t.string()
2305
2638
  });
2306
- var En = t.uuid();
2639
+ var $n = t.uuid();
2307
2640
  t.object({
2308
- key: En,
2641
+ key: $n,
2309
2642
  name: t.string().min(1),
2310
- color: an
2643
+ color: Kn
2311
2644
  }).partial({ key: !0 }), t.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/), t.enum([
2312
2645
  "standard",
2313
2646
  "scientific",
2314
2647
  "engineering"
2315
- ]), t.union([t.string(), t.number()]), typeof process < "u" && process.versions != null && process.versions.node != null || typeof window > "u" || window.document;
2316
- var Dn = [
2648
+ ]);
2649
+ var er = t.union([t.string(), t.number()]), tr = () => t.record(er, t.unknown());
2650
+ typeof process < "u" && process.versions != null && process.versions.node != null || typeof window > "u" || window.document;
2651
+ var nr = [
2317
2652
  "macOS",
2318
2653
  "Windows",
2319
2654
  "Linux"
2320
- ], On = [
2655
+ ], rr = [
2321
2656
  "macos",
2322
2657
  "windows",
2323
2658
  "linux"
2324
- ], kn = {
2659
+ ], ir = {
2325
2660
  macos: "macOS",
2326
2661
  windows: "Windows",
2327
2662
  linux: "Linux"
2328
2663
  };
2329
- t.enum(Dn).or(t.enum(On).transform((e) => kn[e])), t.object({
2664
+ t.enum(nr).or(t.enum(rr).transform((e) => ir[e])), t.object({
2665
+ message: t.string().optional(),
2666
+ description: t.string().optional(),
2667
+ details: tr().optional()
2668
+ }), t.object({
2330
2669
  stack: t.string(),
2331
2670
  error: t.instanceof(Error)
2332
- }), t.enum([
2671
+ }).and(tr()), t.enum([
2333
2672
  "success",
2334
2673
  "info",
2335
2674
  "warning",
@@ -2337,13 +2676,13 @@ t.enum(Dn).or(t.enum(On).transform((e) => kn[e])), t.object({
2337
2676
  "loading",
2338
2677
  "disabled"
2339
2678
  ]), t.literal("success"), t.literal("info"), t.literal("warning"), t.literal("error"), t.literal("loading"), t.literal("disabled");
2340
- var An = (...e) => e.map(jn).join(""), jn = (e) => (e.endsWith("/") || (e += "/"), e.startsWith("/") && (e = e.slice(1)), e), Mn = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Nn = (e, t = "") => e === null ? "" : `?${Object.entries(e).filter(([, e]) => e == null ? !1 : Array.isArray(e) ? e.length > 0 : !0).map(([e, n]) => `${t}${e}=${n}`).join("&")}`, Pn = class e {
2679
+ var ar = (...e) => e.map(or).join(""), or = (e) => (e.endsWith("/") || (e += "/"), e.startsWith("/") && (e = e.slice(1)), e), sr = (e) => e.endsWith("/") ? e.slice(0, -1) : e, cr = (e, t = "") => e === null ? "" : `?${Object.entries(e).filter(([, e]) => e == null ? !1 : Array.isArray(e) ? e.length > 0 : !0).map(([e, n]) => `${t}${e}=${n}`).join("&")}`, lr = class e {
2341
2680
  protocol;
2342
2681
  host;
2343
2682
  port;
2344
2683
  path;
2345
2684
  constructor({ host: e, port: t, protocol: n = "", pathPrefix: r = "" }) {
2346
- this.protocol = n, this.host = e, this.port = t, this.path = jn(r);
2685
+ this.protocol = n, this.host = e, this.port = t, this.path = or(r);
2347
2686
  }
2348
2687
  replace(t) {
2349
2688
  return new e({
@@ -2356,17 +2695,17 @@ var An = (...e) => e.map(jn).join(""), jn = (e) => (e.endsWith("/") || (e += "/"
2356
2695
  child(t) {
2357
2696
  return new e({
2358
2697
  ...this,
2359
- pathPrefix: An(this.path, t)
2698
+ pathPrefix: ar(this.path, t)
2360
2699
  });
2361
2700
  }
2362
2701
  toString() {
2363
- return Mn(`${this.protocol}://${this.host}:${this.port}/${this.path}`);
2702
+ return sr(`${this.protocol}://${this.host}:${this.port}/${this.path}`);
2364
2703
  }
2365
2704
  static UNKNOWN = new e({
2366
2705
  host: "unknown",
2367
2706
  port: 0
2368
2707
  });
2369
- }, X = class extends q.createTyped("freighter") {}, Z = class extends X.sub("eof") {
2708
+ }, X = class extends v.createTyped("freighter") {}, Z = class extends X.sub("eof") {
2370
2709
  constructor() {
2371
2710
  super("EOF");
2372
2711
  }
@@ -2377,11 +2716,11 @@ var An = (...e) => e.map(jn).join(""), jn = (e) => (e.endsWith("/") || (e += "/"
2377
2716
  }, $ = class extends X.sub("unreachable") {
2378
2717
  url;
2379
2718
  constructor(e = {}) {
2380
- let { message: t = "Unreachable", url: n = Pn.UNKNOWN } = e;
2719
+ let { message: t = "Unreachable", url: n = lr.UNKNOWN } = e;
2381
2720
  super(t), this.url = n;
2382
2721
  }
2383
2722
  };
2384
- q.register({
2723
+ v.register({
2385
2724
  encode: (e) => {
2386
2725
  if (!e.type.startsWith(X.TYPE)) return null;
2387
2726
  if (Z.matches(e)) return {
@@ -2404,13 +2743,13 @@ q.register({
2404
2743
  case Z.TYPE: return new Z();
2405
2744
  case Q.TYPE: return new Q();
2406
2745
  case $.TYPE: return new $();
2407
- default: throw new q.Unknown(`Unknown error type: ${e.data}`);
2746
+ default: throw new v.Unknown(`Unknown error type: ${e.data}`);
2408
2747
  }
2409
2748
  }
2410
2749
  });
2411
2750
  //#endregion
2412
2751
  //#region src/middleware.ts
2413
- var Fn = class {
2752
+ var ur = class {
2414
2753
  middleware = [];
2415
2754
  use(...e) {
2416
2755
  this.middleware.push(...e);
@@ -2423,29 +2762,29 @@ var Fn = class {
2423
2762
  };
2424
2763
  return await r(e);
2425
2764
  }
2426
- }, In = "Content-Type", Ln = new Set([
2765
+ }, dr = "Content-Type", fr = new Set([
2427
2766
  "ECONNREFUSED",
2428
2767
  "ECONNRESET",
2429
2768
  "ETIMEDOUT",
2430
2769
  "EPIPE",
2431
2770
  "UND_ERR_CONNECT_TIMEOUT",
2432
2771
  "UND_ERR_SOCKET"
2433
- ]), Rn = (e) => {
2772
+ ]), pr = (e) => {
2434
2773
  let t = e?.cause?.code ?? e?.code ?? e?.errno;
2435
- if (typeof t == "string" && Ln.has(t)) return !0;
2774
+ if (typeof t == "string" && fr.has(t)) return !0;
2436
2775
  if (e.name === "TypeError") {
2437
2776
  let t = String(e.message || "").toLowerCase();
2438
2777
  if (/load failed|failed to fetch|networkerror|network error/.test(t)) return typeof navigator < "u" && navigator.onLine, !0;
2439
2778
  }
2440
2779
  return e?.name === "AbortError" || e?.code, !1;
2441
- }, zn = 400, Bn = class extends Fn {
2780
+ }, mr = 400, hr = class extends ur {
2442
2781
  endpoint;
2443
2782
  encoder;
2444
2783
  constructor(e, t, n = !1) {
2445
2784
  return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, { get: (e, t, n) => t === "endpoint" ? this.endpoint : Reflect.get(e, t, n) });
2446
2785
  }
2447
2786
  get headers() {
2448
- return { [In]: this.encoder.contentType };
2787
+ return { [dr]: this.encoder.contentType };
2449
2788
  }
2450
2789
  async send(e, t, n, r) {
2451
2790
  let i = null, a = this.endpoint.child(e), o = {};
@@ -2469,14 +2808,14 @@ var Fn = class {
2469
2808
  n = await fetch(e.target, o);
2470
2809
  } catch (e) {
2471
2810
  if (!(e instanceof Error)) throw e;
2472
- return [t, Rn(e) ? new $({ url: a }) : e];
2811
+ return [t, pr(e) ? new $({ url: a }) : e];
2473
2812
  }
2474
2813
  let s = await n.arrayBuffer();
2475
2814
  if (n?.ok) return r != null && (i = this.encoder.decode(s, r)), [t, null];
2476
2815
  try {
2477
- if (n.status !== zn) return [t, Error(n.statusText)];
2478
- let e = this.encoder.decode(s, q.payloadZ);
2479
- return [t, q.decode(e)];
2816
+ if (n.status !== mr) return [t, Error(n.statusText)];
2817
+ let e = this.encoder.decode(s, v.payloadZ);
2818
+ return [t, v.decode(e)];
2480
2819
  } catch (e) {
2481
2820
  return [t, /* @__PURE__ */ Error(`[freighter] - failed to decode error: ${n.statusText}: ${e.message}`)];
2482
2821
  }
@@ -2485,7 +2824,7 @@ var Fn = class {
2485
2824
  if (i == null) throw Error("Response must be defined");
2486
2825
  return [i, null];
2487
2826
  }
2488
- }, Vn = (e, t) => {
2827
+ }, gr = (e, t) => {
2489
2828
  class n {
2490
2829
  wrapped;
2491
2830
  constructor(e) {
@@ -2495,7 +2834,7 @@ var Fn = class {
2495
2834
  this.wrapped.use(...e);
2496
2835
  }
2497
2836
  async send(e, n, r, i) {
2498
- let a = new Bt.Breaker(t);
2837
+ let a = new Mn.Breaker(t);
2499
2838
  do {
2500
2839
  let [t, o] = await this.wrapped.send(e, n, r, i);
2501
2840
  if (o == null) return [t, null];
@@ -2505,19 +2844,19 @@ var Fn = class {
2505
2844
  }
2506
2845
  }
2507
2846
  return new n(e);
2508
- }, Hn = async (e, t, n, r, i) => {
2847
+ }, _r = async (e, t, n, r, i) => {
2509
2848
  let [a, o] = await e.send(t, n, r, i);
2510
2849
  if (o != null) throw o;
2511
2850
  return a;
2512
- }, Un = t.object({
2851
+ }, vr = t.object({
2513
2852
  type: t.enum([
2514
2853
  "data",
2515
2854
  "close",
2516
2855
  "open"
2517
2856
  ]),
2518
2857
  payload: t.unknown(),
2519
- error: t.optional(q.payloadZ)
2520
- }), Wn = class {
2858
+ error: t.optional(v.payloadZ)
2859
+ }), yr = class {
2521
2860
  codec;
2522
2861
  reqSchema;
2523
2862
  resSchema;
@@ -2533,7 +2872,7 @@ var Fn = class {
2533
2872
  let e = await this.receiveMsg();
2534
2873
  if (e.type !== "open") {
2535
2874
  if (e.error == null) throw Error("Message error must be defined");
2536
- return q.decode(e.error);
2875
+ return v.decode(e.error);
2537
2876
  }
2538
2877
  return null;
2539
2878
  }
@@ -2549,7 +2888,7 @@ var Fn = class {
2549
2888
  if (this.serverClosed != null) return [null, this.serverClosed];
2550
2889
  let e = await this.receiveMsg();
2551
2890
  if (e.type === "close") {
2552
- if (e.error == null || (this.serverClosed = q.decode(e.error), this.serverClosed == null)) throw Error("Message error must be defined");
2891
+ if (e.error == null || (this.serverClosed = v.decode(e.error), this.serverClosed == null)) throw Error("Message error must be defined");
2553
2892
  return [null, this.serverClosed];
2554
2893
  }
2555
2894
  return [this.resSchema.parse(e.payload), null];
@@ -2580,18 +2919,18 @@ var Fn = class {
2580
2919
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
2581
2920
  }
2582
2921
  onMessage(e) {
2583
- this.addMessage(this.codec.decode(e.data, Un));
2922
+ this.addMessage(this.codec.decode(e.data, vr));
2584
2923
  }
2585
2924
  onClose(e) {
2586
2925
  this.addMessage({
2587
2926
  type: "close",
2588
2927
  error: {
2589
- type: e.code === Kn ? Z.TYPE : Q.TYPE,
2928
+ type: e.code === xr ? Z.TYPE : Q.TYPE,
2590
2929
  data: ""
2591
2930
  }
2592
2931
  });
2593
2932
  }
2594
- }, Gn = "freighterctx", Kn = 1e3, qn = class e extends Fn {
2933
+ }, br = "freighterctx", xr = 1e3, Sr = class e extends ur {
2595
2934
  baseUrl;
2596
2935
  encoder;
2597
2936
  secure;
@@ -2622,16 +2961,16 @@ var Fn = class {
2622
2961
  return i;
2623
2962
  }
2624
2963
  buildURL(e, t) {
2625
- let n = Nn({
2626
- [In]: this.encoder.contentType,
2964
+ let n = cr({
2965
+ [dr]: this.encoder.contentType,
2627
2966
  ...t.params
2628
- }, Gn);
2967
+ }, br);
2629
2968
  return this.baseUrl.child(e).toString() + n;
2630
2969
  }
2631
2970
  async wrapSocket(e, t, n) {
2632
2971
  return await new Promise((r) => {
2633
2972
  e.onopen = () => {
2634
- let i = new Wn(e, this.encoder, t, n);
2973
+ let i = new yr(e, this.encoder, t, n);
2635
2974
  i.receiveOpenAck().then((e) => {
2636
2975
  r(e ?? i);
2637
2976
  }).catch((e) => r(e));
@@ -2642,4 +2981,4 @@ var Fn = class {
2642
2981
  }
2643
2982
  };
2644
2983
  //#endregion
2645
- export { Z as EOF, Bn as HTTPClient, Q as StreamClosed, $ as Unreachable, qn as WebSocketClient, Hn as sendRequired, Vn as unaryWithBreaker };
2984
+ export { Z as EOF, hr as HTTPClient, Q as StreamClosed, $ as Unreachable, Sr as WebSocketClient, _r as sendRequired, gr as unaryWithBreaker };