@synnaxlabs/freighter 0.48.0 → 0.50.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
@@ -1,36 +1,36 @@
1
- import O, { z as s } from "zod";
2
- const _e = (r) => {
1
+ import b, { z as s } from "zod";
2
+ const Xe = (r) => {
3
3
  const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
4
4
  return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
5
- }, Ae = (r) => {
6
- const e = (t, n = oe) => {
5
+ }, Ne = (r) => {
6
+ const e = (t, n = se) => {
7
7
  if (typeof t == "string") return r(t);
8
8
  if (Array.isArray(t)) return t.map((c) => e(c, n));
9
- if (!se(t)) return t;
10
- n = nt(n);
11
- const i = {}, a = t;
12
- return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), n) : (Object.keys(a).forEach((c) => {
13
- let d = a[c];
9
+ if (!te(t)) return t;
10
+ n = tt(n);
11
+ const i = {}, o = t;
12
+ return "toJSON" in o && typeof o.toJSON == "function" ? e(o.toJSON(), n) : (Object.keys(o).forEach((c) => {
13
+ let d = o[c];
14
14
  const w = r(c);
15
- n.recursive && (se(d) ? be(d) || (d = e(d, n)) : n.recursiveInArray && we(d) && (d = [...d].map((h) => {
15
+ n.recursive && (te(d) ? pe(d) || (d = e(d, n)) : n.recursiveInArray && ye(d) && (d = [...d].map((h) => {
16
16
  let g = h;
17
- return se(h) ? be(g) || (g = e(h, n)) : we(h) && (g = e({ key: h }, n).key), g;
17
+ return te(h) ? pe(g) || (g = e(h, n)) : ye(h) && (g = e({ key: h }, n).key), g;
18
18
  }))), i[w] = d;
19
19
  }), i);
20
20
  };
21
21
  return e;
22
- }, Ue = Ae(_e), et = (r) => (
22
+ }, Ee = Ne(Xe), Qe = (r) => (
23
23
  // Don't convert the first character and don't convert a character that is after a
24
24
  // non-alphanumeric character
25
25
  r.replace(
26
26
  /([a-z0-9])([A-Z])/g,
27
27
  (e, t, n) => `${t}_${n.toLowerCase()}`
28
28
  )
29
- ), tt = Ae(et), rt = [Number, String, Uint8Array], oe = {
29
+ ), _e = Ne(Qe), et = [Number, String, Uint8Array], se = {
30
30
  recursive: !0,
31
31
  recursiveInArray: !0
32
- }, nt = (r = oe) => (r.recursive == null ? r = oe : r.recursiveInArray ??= !1, r), we = (r) => r != null && Array.isArray(r), se = (r) => r != null && typeof r == "object" && !Array.isArray(r), be = (r) => rt.some((e) => r instanceof e);
33
- let st = class {
32
+ }, tt = (r = se) => (r.recursive == null ? r = se : r.recursiveInArray ??= !1, r), ye = (r) => r != null && Array.isArray(r), te = (r) => r != null && typeof r == "object" && !Array.isArray(r), pe = (r) => et.some((e) => r instanceof e);
33
+ class rt {
34
34
  contentType = "application/json";
35
35
  decoder;
36
36
  encoder;
@@ -44,16 +44,16 @@ let st = class {
44
44
  return this.decodeString(this.decoder.decode(e), t);
45
45
  }
46
46
  decodeString(e, t) {
47
- const n = JSON.parse(e), i = Ue(n);
47
+ const n = JSON.parse(e), i = Ee(n);
48
48
  return t != null ? t.parse(i) : i;
49
49
  }
50
50
  encodeString(e) {
51
- const t = tt(e);
51
+ const t = _e(e);
52
52
  return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
53
53
  }
54
- };
55
- const ue = new st(), A = (r) => r != null && typeof r == "object" && "value" in r;
56
- let W = class {
54
+ }
55
+ const ie = new rt(), A = (r) => r != null && typeof r == "object" && "value" in r;
56
+ class Z {
57
57
  /** The underlying primitive value */
58
58
  value;
59
59
  constructor(e) {
@@ -72,25 +72,25 @@ let W = class {
72
72
  toString() {
73
73
  return this.value.toString();
74
74
  }
75
- };
76
- const it = (r) => r != null && typeof r == "object" && "toString" in r, at = (r, e = !1) => {
77
- const t = it(r) ? "stringer" : typeof r;
75
+ }
76
+ const nt = (r) => r != null && typeof r == "object" && "toString" in r, st = (r, e = !1) => {
77
+ const t = nt(r) ? "stringer" : typeof r;
78
78
  let n;
79
79
  switch (t) {
80
80
  case "string":
81
- n = (i, a) => i.localeCompare(a);
81
+ n = (i, o) => i.localeCompare(o);
82
82
  break;
83
83
  case "stringer":
84
- n = (i, a) => i.toString().localeCompare(a.toString());
84
+ n = (i, o) => i.toString().localeCompare(o.toString());
85
85
  break;
86
86
  case "number":
87
- n = (i, a) => Number(i) - Number(a);
87
+ n = (i, o) => Number(i) - Number(o);
88
88
  break;
89
89
  case "bigint":
90
- n = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
90
+ n = (i, o) => BigInt(i) - BigInt(o) > 0n ? 1 : -1;
91
91
  break;
92
92
  case "boolean":
93
- n = (i, a) => Number(i) - Number(a);
93
+ n = (i, o) => Number(i) - Number(o);
94
94
  break;
95
95
  case "undefined":
96
96
  n = () => 0;
@@ -98,38 +98,35 @@ const it = (r) => r != null && typeof r == "object" && "toString" in r, at = (r,
98
98
  default:
99
99
  return console.warn(`sortFunc: unknown type ${t}`), () => -1;
100
100
  }
101
- return e ? ot(n) : n;
102
- }, ot = (r) => (e, t) => r(t, e), _ = s.tuple([s.number(), s.number()]);
103
- s.tuple([s.bigint(), s.bigint()]);
104
- const Me = s.object({ width: s.number(), height: s.number() }), ut = s.object({
105
- signedWidth: s.number(),
106
- signedHeight: s.number()
107
- }), lt = ["width", "height"];
108
- s.enum(lt);
109
- const ct = ["start", "center", "end"], ht = ["signedWidth", "signedHeight"];
110
- s.enum(ht);
111
- const Q = s.object({ x: s.number(), y: s.number() }), ft = s.object({ clientX: s.number(), clientY: s.number() }), dt = ["x", "y"], $e = s.enum(dt), Ce = ["top", "right", "bottom", "left"];
112
- s.enum(Ce);
113
- const gt = ["left", "right"], Be = s.enum(gt), pt = ["top", "bottom"], Re = s.enum(pt), De = ["center"], Oe = s.enum(De), mt = [...Ce, ...De], Le = s.enum(mt);
114
- s.enum(ct);
115
- const yt = ["first", "last"];
116
- s.enum(yt);
117
- const wt = s.object({ lower: s.number(), upper: s.number() }), bt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
- s.union([wt, _]);
119
- s.union([bt, _]);
120
- s.enum([...$e.options, ...Le.options]);
121
- s.enum(["x", "left", "right"]);
122
- s.enum(["y", "top", "bottom"]);
123
- s.union([$e, Le, s.instanceof(String)]);
124
- const ee = (r) => (e, t) => {
101
+ return e ? it(n) : n;
102
+ }, it = (r) => (e, t) => r(t, e);
103
+ let Ae = (r, e = 21) => (t = e) => {
104
+ let n = "", i = t | 0;
105
+ for (; i--; )
106
+ n += r[Math.random() * r.length | 0];
107
+ return n;
108
+ };
109
+ const xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", at = `0123456789${xe}`, ot = 11, ut = Ae(xe, 1), lt = Ae(at, ot - 1), ct = () => `${ut()}${lt()}`, ht = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, ft = 2 ** 12 - 1, ae = 2n ** 63n - 1n, dt = 2 ** 63 - 1, _ = (r) => (e, t) => {
125
110
  if (typeof e == "bigint") {
126
- if (Ot(t))
111
+ if (gt(t))
127
112
  return r(e, BigInt(t));
128
113
  const n = r(Number(e), Number(t));
129
114
  return typeof n == "number" ? BigInt(Math.round(n)) : n;
130
115
  }
131
116
  return r(Number(e), Number(t));
132
- }, te = ee((r, e) => r - e), re = ee((r, e) => r + e), Ot = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), $ = ee((r, e) => r * e), ne = ee((r, e) => r / e), L = (r, e, t) => {
117
+ }, V = _((r, e) => r - e), $ = _((r, e) => r + e), gt = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), M = _((r, e) => r * e), ee = _((r, e) => r / e), Ue = s.tuple([s.number(), s.number()]), Me = s.object({ width: s.number(), height: s.number() }), mt = s.object({
118
+ signedWidth: s.number(),
119
+ signedHeight: s.number()
120
+ }), yt = ["start", "center", "end"], G = s.object({ x: s.number(), y: s.number() }), pt = s.object({ clientX: s.number(), clientY: s.number() }), wt = ["x", "y"], Ce = s.enum(wt), Be = ["top", "right", "bottom", "left"];
121
+ s.enum(Be);
122
+ const bt = ["left", "right"], Re = s.enum(bt), Ot = ["top", "bottom"], De = s.enum(Ot), Le = ["center"], we = s.enum(Le), Tt = [...Be, ...Le], $e = s.enum(Tt);
123
+ s.enum(yt);
124
+ const vt = ["first", "last"];
125
+ s.enum(vt);
126
+ s.object({ lower: s.number(), upper: s.number() });
127
+ s.enum([...Ce.options, ...$e.options]);
128
+ s.union([Ce, $e, s.instanceof(String)]);
129
+ const k = (r, e, t) => {
133
130
  const n = {};
134
131
  if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof r == "number" || typeof r == "bigint")
135
132
  e != null ? (n.lower = r, n.upper = e) : (n.lower = typeof r == "bigint" ? 0n : 0, n.upper = r);
@@ -138,34 +135,34 @@ const ee = (r) => (e, t) => {
138
135
  [n.lower, n.upper] = r;
139
136
  } else
140
137
  n.lower = r.lower, n.upper = r.upper;
141
- return t?.makeValid ? Tt(n) : n;
142
- }, Tt = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, Te = (r, e) => {
143
- const t = L(r);
138
+ return t?.makeValid ? St(n) : n;
139
+ }, St = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, be = (r, e) => {
140
+ const t = k(r);
144
141
  return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
145
142
  };
146
143
  s.object({
147
- x: Be.or(Oe),
148
- y: Re.or(Oe)
144
+ x: Re.or(we),
145
+ y: De.or(we)
149
146
  });
150
- const vt = s.object({ x: Be, y: Re }), It = Object.freeze({ x: "left", y: "top" }), St = (r, e) => r.x === e.x && r.y === e.y, ve = s.union([
147
+ const ke = s.object({ x: Re, y: De }), It = Object.freeze({ x: "left", y: "top" }), Nt = (r, e) => r.x === e.x && r.y === e.y, Oe = s.union([
151
148
  s.number(),
152
- Q,
153
- _,
149
+ G,
150
+ Ue,
154
151
  Me,
155
- ut,
156
- ft
157
- ]), Nt = (r, e) => {
152
+ mt,
153
+ pt
154
+ ]), Et = (r, e) => {
158
155
  if (typeof r == "string") {
159
156
  if (e === void 0) throw new Error("The y coordinate must be given.");
160
157
  return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
161
158
  }
162
159
  return typeof r == "number" ? { x: r, y: e ?? r } : Array.isArray(r) ? { x: r[0], y: r[1] } : "signedWidth" in r ? { x: r.signedWidth, y: r.signedHeight } : "clientX" in r ? { x: r.clientX, y: r.clientY } : "width" in r ? { x: r.width, y: r.height } : { x: r.x, y: r.y };
163
- }, Ie = Object.freeze({ x: 0, y: 0 }), H = s.union([s.number(), s.string()]);
160
+ }, Te = Object.freeze({ x: 0, y: 0 }), K = s.union([s.number(), s.string()]);
164
161
  s.object({
165
- top: H,
166
- left: H,
167
- width: H,
168
- height: H
162
+ top: K,
163
+ left: K,
164
+ width: K,
165
+ height: K
169
166
  });
170
167
  s.object({
171
168
  left: s.number(),
@@ -174,61 +171,61 @@ s.object({
174
171
  bottom: s.number()
175
172
  });
176
173
  s.object({
177
- one: Q,
178
- two: Q,
179
- root: vt
174
+ one: G,
175
+ two: G,
176
+ root: ke
180
177
  });
181
- const ge = (r, e, t = 0, n = 0, i) => {
182
- const a = {
183
- one: { ...Ie },
184
- two: { ...Ie },
178
+ const he = (r, e, t = 0, n = 0, i) => {
179
+ const o = {
180
+ one: { ...Te },
181
+ two: { ...Te },
185
182
  root: i ?? It
186
183
  };
187
184
  if (typeof r == "number") {
188
185
  if (typeof e != "number")
189
186
  throw new Error("Box constructor called with invalid arguments");
190
- return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
191
- }
192
- return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (a.one = { x: r.left, y: r.top }, a.two = { x: r.right, y: r.bottom }, a) : (a.one = r, e == null ? a.two = { x: a.one.x + t, y: a.one.y + n } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
193
- x: a.one.x + e.width,
194
- y: a.one.y + e.height
195
- } : "signedWidth" in e ? a.two = {
196
- x: a.one.x + e.signedWidth,
197
- y: a.one.y + e.signedHeight
198
- } : a.two = e, a));
199
- }, ie = (r) => {
200
- const e = ge(r);
187
+ return o.one = { x: r, y: e }, o.two = { x: o.one.x + t, y: o.one.y + n }, o;
188
+ }
189
+ return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (o.one = { x: r.left, y: r.top }, o.two = { x: r.right, y: r.bottom }, o) : (o.one = r, e == null ? o.two = { x: o.one.x + t, y: o.one.y + n } : typeof e == "number" ? o.two = { x: o.one.x + e, y: o.one.y + t } : "width" in e ? o.two = {
190
+ x: o.one.x + e.width,
191
+ y: o.one.y + e.height
192
+ } : "signedWidth" in e ? o.two = {
193
+ x: o.one.x + e.signedWidth,
194
+ y: o.one.y + e.signedHeight
195
+ } : o.two = e, o));
196
+ }, re = (r) => {
197
+ const e = he(r);
201
198
  return { lower: e.one.x, upper: e.two.x };
202
- }, ae = (r) => {
203
- const e = ge(r);
199
+ }, ne = (r) => {
200
+ const e = he(r);
204
201
  return { lower: e.one.y, upper: e.two.y };
205
- }, Et = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, xt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
- s.union([Me, xt, Q, _]);
207
- const At = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
208
- s.object({ offset: ve, scale: ve });
202
+ }, At = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, xt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
203
+ s.union([Me, xt, G, Ue]);
204
+ const Ut = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
205
+ s.object({ offset: Oe, scale: Oe });
209
206
  s.object({ offset: s.number(), scale: s.number() });
210
- const Ut = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
207
+ const Mt = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
211
208
  e,
212
209
  i ? n - r : n + r
213
- ], Mt = (r) => (e, t, n, i) => [
210
+ ], Ct = (r) => (e, t, n, i) => [
214
211
  e,
215
212
  i ? n / r : n * r
216
- ], $t = (r) => (e, t, n) => {
213
+ ], Bt = (r) => (e, t, n) => {
217
214
  if (e === null) return [r, n];
218
- const { lower: i, upper: a } = e, { lower: c, upper: d } = r, w = a - i, h = d - c;
215
+ const { lower: i, upper: o } = e, { lower: c, upper: d } = r, w = o - i, h = d - c;
219
216
  if (t === "dimension") return [r, n * (h / w)];
220
217
  const g = (n - i) * (h / w) + c;
221
218
  return [r, g];
222
- }, Ct = (r) => (e, t, n) => [r, n], Bt = () => (r, e, t) => {
219
+ }, Rt = (r) => (e, t, n) => [r, n], Dt = () => (r, e, t) => {
223
220
  if (r === null) throw new Error("cannot invert without bounds");
224
221
  if (e === "dimension") return [r, t];
225
222
  const { lower: n, upper: i } = r;
226
223
  return [r, i - (t - n)];
227
- }, Rt = (r) => (e, t, n) => {
228
- const { lower: i, upper: a } = r;
229
- return n = At(n, i, a), [e, n];
224
+ }, Lt = (r) => (e, t, n) => {
225
+ const { lower: i, upper: o } = r;
226
+ return n = Ut(n, i, o), [e, n];
230
227
  };
231
- let Se = class P {
228
+ class R {
232
229
  ops = [];
233
230
  currBounds = null;
234
231
  currType = null;
@@ -242,7 +239,7 @@ let Se = class P {
242
239
  * @param value - The amount to translate by.
243
240
  */
244
241
  static translate(e) {
245
- return new P().translate(e);
242
+ return new R().translate(e);
246
243
  }
247
244
  /**
248
245
  * @returns a new scale with a magnification as its first operation. Any number provided
@@ -250,10 +247,10 @@ let Se = class P {
250
247
  * @param value - The amount to translate by.
251
248
  */
252
249
  static magnify(e) {
253
- return new P().magnify(e);
250
+ return new R().magnify(e);
254
251
  }
255
252
  static scale(e, t) {
256
- return new P().scale(e, t);
253
+ return new R().scale(e, t);
257
254
  }
258
255
  /**
259
256
  * @returns a copy of the scale with a translation as its next operation. Any
@@ -262,7 +259,7 @@ let Se = class P {
262
259
  * @param value - The amount to translate by.
263
260
  */
264
261
  translate(e) {
265
- const t = this.new(), n = Ut(e);
262
+ const t = this.new(), n = Mt(e);
266
263
  return n.type = "translate", t.ops.push(n), t;
267
264
  }
268
265
  /**
@@ -272,23 +269,23 @@ let Se = class P {
272
269
  * @param value - The amount to magnify by.
273
270
  */
274
271
  magnify(e) {
275
- const t = this.new(), n = Mt(e);
272
+ const t = this.new(), n = Ct(e);
276
273
  return n.type = "magnify", t.ops.push(n), t;
277
274
  }
278
275
  scale(e, t) {
279
- const n = L(e, t), i = this.new(), a = $t(n);
280
- return a.type = "scale", i.ops.push(a), i;
276
+ const n = k(e, t), i = this.new(), o = Bt(n);
277
+ return o.type = "scale", i.ops.push(o), i;
281
278
  }
282
279
  clamp(e, t) {
283
- const n = L(e, t), i = this.new(), a = Rt(n);
284
- return a.type = "clamp", i.ops.push(a), i;
280
+ const n = k(e, t), i = this.new(), o = Lt(n);
281
+ return o.type = "clamp", i.ops.push(o), i;
285
282
  }
286
283
  reBound(e, t) {
287
- const n = L(e, t), i = this.new(), a = Ct(n);
288
- return a.type = "re-bound", i.ops.push(a), i;
284
+ const n = k(e, t), i = this.new(), o = Rt(n);
285
+ return o.type = "re-bound", i.ops.push(o), i;
289
286
  }
290
287
  invert() {
291
- const e = Bt();
288
+ const e = Dt();
292
289
  e.type = "invert";
293
290
  const t = this.new();
294
291
  return t.ops.push(e), t;
@@ -300,12 +297,12 @@ let Se = class P {
300
297
  return this.exec("dimension", e);
301
298
  }
302
299
  new() {
303
- const e = new P();
300
+ const e = new R();
304
301
  return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
305
302
  }
306
303
  exec(e, t) {
307
304
  return this.currBounds = null, this.ops.reduce(
308
- ([n, i], a) => a(n, e, i, this.reversed),
305
+ ([n, i], o) => o(n, e, i, this.reversed),
309
306
  [null, t]
310
307
  )[1];
311
308
  }
@@ -316,47 +313,48 @@ let Se = class P {
316
313
  return e.ops.forEach((n, i) => {
317
314
  if (n.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
318
315
  return;
319
- const a = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
320
- a !== -1 && t.push([i, a]);
316
+ const o = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
317
+ o !== -1 && t.push([i, o]);
321
318
  }), t.forEach(([n, i]) => {
322
- const a = e.ops.slice(n, i);
323
- a.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...a);
319
+ const o = e.ops.slice(n, i);
320
+ o.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...o);
324
321
  }), e.reversed = !e.reversed, e;
325
322
  }
326
323
  get transform() {
327
324
  return { scale: this.dim(1), offset: this.pos(0) };
328
325
  }
329
- static IDENTITY = new P();
330
- }, tn = class M {
326
+ static IDENTITY = new R();
327
+ }
328
+ class U {
331
329
  x;
332
330
  y;
333
331
  currRoot;
334
- constructor(e = new Se(), t = new Se(), n = null) {
332
+ constructor(e = new R(), t = new R(), n = null) {
335
333
  this.x = e, this.y = t, this.currRoot = n;
336
334
  }
337
335
  static translate(e, t) {
338
- return new M().translate(e, t);
336
+ return new U().translate(e, t);
339
337
  }
340
338
  static translateX(e) {
341
- return new M().translateX(e);
339
+ return new U().translateX(e);
342
340
  }
343
341
  static translateY(e) {
344
- return new M().translateY(e);
342
+ return new U().translateY(e);
345
343
  }
346
344
  static clamp(e) {
347
- return new M().clamp(e);
345
+ return new U().clamp(e);
348
346
  }
349
347
  static magnify(e) {
350
- return new M().magnify(e);
348
+ return new U().magnify(e);
351
349
  }
352
350
  static scale(e) {
353
- return new M().scale(e);
351
+ return new U().scale(e);
354
352
  }
355
353
  static reBound(e) {
356
- return new M().reBound(e);
354
+ return new U().reBound(e);
357
355
  }
358
356
  translate(e, t) {
359
- const n = Nt(e, t), i = this.copy();
357
+ const n = Et(e, t), i = this.copy();
360
358
  return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
361
359
  }
362
360
  translateX(e) {
@@ -373,22 +371,22 @@ let Se = class P {
373
371
  }
374
372
  scale(e) {
375
373
  const t = this.copy();
376
- if (Et(e)) {
374
+ if (At(e)) {
377
375
  const n = this.currRoot;
378
- return t.currRoot = e.root, n != null && !St(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(ie(e)), t.y = t.y.scale(ae(e)), t;
376
+ return t.currRoot = e.root, n != null && !Nt(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(re(e)), t.y = t.y.scale(ne(e)), t;
379
377
  }
380
378
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
381
379
  }
382
380
  reBound(e) {
383
381
  const t = this.copy();
384
- return t.x = this.x.reBound(ie(e)), t.y = this.y.reBound(ae(e)), t;
382
+ return t.x = this.x.reBound(re(e)), t.y = this.y.reBound(ne(e)), t;
385
383
  }
386
384
  clamp(e) {
387
385
  const t = this.copy();
388
- return t.x = this.x.clamp(ie(e)), t.y = this.y.clamp(ae(e)), t;
386
+ return t.x = this.x.clamp(re(e)), t.y = this.y.clamp(ne(e)), t;
389
387
  }
390
388
  copy() {
391
- const e = new M();
389
+ const e = new U();
392
390
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
393
391
  }
394
392
  reverse() {
@@ -402,7 +400,7 @@ let Se = class P {
402
400
  return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
403
401
  }
404
402
  box(e) {
405
- return ge(
403
+ return he(
406
404
  this.pos(e.one),
407
405
  this.pos(e.two),
408
406
  0,
@@ -416,18 +414,21 @@ let Se = class P {
416
414
  offset: this.pos({ x: 0, y: 0 })
417
415
  };
418
416
  }
419
- static IDENTITY = new M();
420
- }, Pe = (r, e = 21) => (t = e) => {
421
- let n = "", i = t | 0;
422
- for (; i--; )
423
- n += r[Math.random() * r.length | 0];
424
- return n;
425
- };
426
- const ke = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Dt = `0123456789${ke}`, Lt = 11, Pt = Pe(ke, 1), kt = Pe(Dt, Lt - 1), jt = () => `${Pt()}${kt()}`, Yt = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, qt = s.enum(["static", "dynamic"]), le = 2n ** 63n - 1n, Ft = 2 ** 63 - 1, Ne = 365, J = 30, Wt = s.union([
417
+ static IDENTITY = new U();
418
+ }
419
+ const $t = G.extend({
420
+ root: ke,
421
+ units: b.object({
422
+ x: b.enum(["px", "decimal"]),
423
+ y: b.enum(["px", "decimal"])
424
+ })
425
+ });
426
+ $t.partial({ root: !0, units: !0 });
427
+ const kt = s.enum(["static", "dynamic"]), ve = 365, X = 30, Pt = s.union([
427
428
  s.tuple([s.int()]),
428
429
  s.tuple([s.int(), s.int().min(1).max(12)]),
429
430
  s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
430
- ]), je = (r, e) => {
431
+ ]), Pe = (r, e) => {
431
432
  const t = new u(e);
432
433
  if (![
433
434
  l.DAY,
@@ -444,7 +445,7 @@ const ke = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Dt = `0123456
444
445
  const n = r.valueOf() % t.valueOf();
445
446
  return r instanceof u ? new u(n) : new l(n);
446
447
  };
447
- class u extends W {
448
+ class u extends Z {
448
449
  constructor(e, t = "UTC") {
449
450
  if (e == null) super(u.now().valueOf());
450
451
  else if (e instanceof Date)
@@ -454,7 +455,7 @@ class u extends W {
454
455
  else if (Array.isArray(e)) super(u.parseDate(e));
455
456
  else {
456
457
  let n = 0n;
457
- e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === Ft ? e = le : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), A(e) && (e = e.value), super(BigInt(e.valueOf()) + n);
458
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === dt ? e = ae : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), A(e) && (e = e.value), super(BigInt(e.valueOf()) + n);
458
459
  }
459
460
  }
460
461
  static parseDate([e = 1970, t = 1, n = 1]) {
@@ -469,9 +470,9 @@ class u extends W {
469
470
  return this.value;
470
471
  }
471
472
  static parseTimeString(e, t = "UTC") {
472
- const [n, i, a] = e.split(":");
473
+ const [n, i, o] = e.split(":");
473
474
  let c = "00", d = "00";
474
- a != null && ([c, d] = a.split("."));
475
+ o != null && ([c, d] = o.split("."));
475
476
  let w = u.hours(parseInt(n ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(d ?? "00")));
476
477
  return t === "local" && (w = w.add(u.utcOffset)), w.valueOf();
477
478
  }
@@ -479,14 +480,14 @@ class u extends W {
479
480
  if (!e.includes("/") && !e.includes("-"))
480
481
  return u.parseTimeString(e, t);
481
482
  if (e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/) != null) {
482
- let i = e, a = 0;
483
+ let i = e, o = 0;
483
484
  if (e.includes(".")) {
484
485
  const h = e.split(".");
485
486
  i = h[0];
486
487
  const g = h[1] || "0";
487
- a = parseInt(g.padEnd(3, "0").slice(0, 3));
488
+ o = parseInt(g.padEnd(3, "0").slice(0, 3));
488
489
  }
489
- const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`), d = BigInt(c.getTime()) * u.MILLISECOND.valueOf(), w = BigInt(a) * u.MILLISECOND.valueOf();
490
+ const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`), d = BigInt(c.getTime()) * u.MILLISECOND.valueOf(), w = BigInt(o) * u.MILLISECOND.valueOf();
490
491
  return d + w;
491
492
  }
492
493
  const n = new Date(e);
@@ -551,7 +552,7 @@ class u extends W {
551
552
  * valid, regardless of the TimeStamp order.
552
553
  */
553
554
  range(e) {
554
- return new E(this, e).makeValid();
555
+ return new I(this, e).makeValid();
555
556
  }
556
557
  /**
557
558
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -620,7 +621,7 @@ class u extends W {
620
621
  * TimeSpan.
621
622
  */
622
623
  add(e) {
623
- return new u(re(this.valueOf(), new l(e).valueOf()));
624
+ return new u($(this.valueOf(), new l(e).valueOf()));
624
625
  }
625
626
  /**
626
627
  * Subtracts a TimeSpan from the TimeStamp.
@@ -630,7 +631,7 @@ class u extends W {
630
631
  * TimeSpan.
631
632
  */
632
633
  sub(e) {
633
- return new u(te(this.valueOf(), new l(e).valueOf()));
634
+ return new u(V(this.valueOf(), new l(e).valueOf()));
634
635
  }
635
636
  /**
636
637
  * @returns the floating point number of hours since the unix epoch to the timestamp
@@ -821,7 +822,7 @@ class u extends W {
821
822
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
822
823
  */
823
824
  remainder(e) {
824
- return je(this, e);
825
+ return Pe(this, e);
825
826
  }
826
827
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
827
828
  get isToday() {
@@ -936,7 +937,7 @@ class u extends W {
936
937
  /** One day after the unix epoch */
937
938
  static DAY = u.days(1);
938
939
  /** The maximum possible value for a timestamp */
939
- static MAX = new u(le);
940
+ static MAX = new u(ae);
940
941
  /** The minimum possible value for a timestamp */
941
942
  static MIN = new u(0);
942
943
  /** The unix epoch */
@@ -950,7 +951,7 @@ class u extends W {
950
951
  s.bigint().transform((e) => new u(e)),
951
952
  s.date().transform((e) => new u(e)),
952
953
  s.custom((e) => e instanceof l).transform((e) => new u(e)),
953
- Wt.transform((e) => new u(e))
954
+ Pt.transform((e) => new u(e))
954
955
  ]);
955
956
  /**
956
957
  * Sorts two timestamps.
@@ -964,7 +965,7 @@ class u extends W {
964
965
  return Number(e.valueOf() - t.valueOf());
965
966
  }
966
967
  }
967
- class l extends W {
968
+ class l extends Z {
968
969
  constructor(e) {
969
970
  typeof e == "number" && (e = Math.trunc(e.valueOf())), A(e) && (e = e.value), super(BigInt(e.valueOf()));
970
971
  }
@@ -1036,7 +1037,7 @@ class l extends W {
1036
1037
  * @returns A new TimeSpan representing the remainder.
1037
1038
  */
1038
1039
  remainder(e) {
1039
- return je(this, e);
1040
+ return Pe(this, e);
1040
1041
  }
1041
1042
  /**
1042
1043
  * Truncates the TimeSpan to the nearest multiple of the given span.
@@ -1059,65 +1060,65 @@ class l extends W {
1059
1060
  */
1060
1061
  toString(e = "full") {
1061
1062
  if (e === "semantic") return this.toSemanticString();
1062
- const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), a = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), d = this.truncate(l.MICROSECOND), w = this.truncate(l.NANOSECOND), h = t, g = n.sub(t), b = i.sub(n), f = a.sub(i), v = c.sub(a), x = d.sub(c), U = w.sub(d);
1063
- let m = "";
1064
- return h.isZero || (m += `${h.days}d `), g.isZero || (m += `${g.hours}h `), b.isZero || (m += `${b.minutes}m `), f.isZero || (m += `${f.seconds}s `), v.isZero || (m += `${v.milliseconds}ms `), x.isZero || (m += `${x.microseconds}µs `), U.isZero || (m += `${U.nanoseconds}ns`), m.trim();
1063
+ const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), o = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), d = this.truncate(l.MICROSECOND), w = this.truncate(l.NANOSECOND), h = t, g = n.sub(t), O = i.sub(n), f = o.sub(i), T = c.sub(o), E = d.sub(c), x = w.sub(d);
1064
+ let y = "";
1065
+ return h.isZero || (y += `${h.days}d `), g.isZero || (y += `${g.hours}h `), O.isZero || (y += `${O.minutes}m `), f.isZero || (y += `${f.seconds}s `), T.isZero || (y += `${T.milliseconds}ms `), E.isZero || (y += `${E.microseconds}µs `), x.isZero || (y += `${x.nanoseconds}ns`), y.trim();
1065
1066
  }
1066
1067
  toSemanticString() {
1067
1068
  const e = this.valueOf() < 0n ? -this.valueOf() : this.valueOf(), t = new l(e), n = this.valueOf() < 0n;
1068
1069
  if (t.valueOf() === 0n) return "0s";
1069
1070
  if (t.lessThan(l.SECOND)) return "< 1s";
1070
- const i = t.days, a = t.hours, c = t.minutes, d = t.seconds, w = Math.floor(i / Ne), h = Math.floor(i / J), g = Math.floor(i / 7), b = Math.floor(i), f = Math.floor(a), v = Math.floor(c), x = Math.floor(d), U = n ? "-" : "";
1071
+ const i = t.days, o = t.hours, c = t.minutes, d = t.seconds, w = Math.floor(i / ve), h = Math.floor(i / X), g = Math.floor(i / 7), O = Math.floor(i), f = Math.floor(o), T = Math.floor(c), E = Math.floor(d), x = n ? "-" : "";
1071
1072
  if (w >= 1) {
1072
- let m = `${w}y`;
1073
+ let y = `${w}y`;
1073
1074
  if (w < 2) {
1074
- const I = Math.floor(
1075
- i % Ne / J
1075
+ const v = Math.floor(
1076
+ i % ve / X
1076
1077
  );
1077
- I > 0 && (m += ` ${I}mo`);
1078
+ v > 0 && (y += ` ${v}mo`);
1078
1079
  }
1079
- return U + m;
1080
+ return x + y;
1080
1081
  }
1081
- if (g >= 1 && i < J && i % 7 === 0) {
1082
- let m = `${g}w`;
1083
- const I = Math.floor(i % 7), D = Math.floor(a - g * 7 * 24);
1084
- return g < 2 && (I > 0 ? m += ` ${I}d` : D > 0 && D < 24 && (m += ` ${D}h`)), U + m;
1082
+ if (g >= 1 && i < X && i % 7 === 0) {
1083
+ let y = `${g}w`;
1084
+ const v = Math.floor(i % 7), L = Math.floor(o - g * 7 * 24);
1085
+ return g < 2 && (v > 0 ? y += ` ${v}d` : L > 0 && L < 24 && (y += ` ${L}h`)), x + y;
1085
1086
  }
1086
1087
  if (h >= 1) {
1087
- let m = `${h}mo`;
1088
+ let y = `${h}mo`;
1088
1089
  if (h < 3) {
1089
- const I = Math.floor(i % J);
1090
- I > 0 && (m += ` ${I}d`);
1090
+ const v = Math.floor(i % X);
1091
+ v > 0 && (y += ` ${v}d`);
1091
1092
  }
1092
- return U + m;
1093
+ return x + y;
1093
1094
  }
1094
1095
  if (g >= 1) {
1095
- let m = `${g}w`;
1096
- const I = Math.floor(i % 7), D = Math.floor(a - g * 7 * 24);
1097
- return g < 2 && (I > 0 ? m += ` ${I}d` : D > 0 && D < 24 && (m += ` ${D}h`)), U + m;
1096
+ let y = `${g}w`;
1097
+ const v = Math.floor(i % 7), L = Math.floor(o - g * 7 * 24);
1098
+ return g < 2 && (v > 0 ? y += ` ${v}d` : L > 0 && L < 24 && (y += ` ${L}h`)), x + y;
1098
1099
  }
1099
- if (b >= 1) {
1100
- let m = `${b}d`;
1101
- const I = Math.floor(a - b * 24);
1102
- return b < 2 && I > 0 && (m += ` ${I}h`), U + m;
1100
+ if (O >= 1) {
1101
+ let y = `${O}d`;
1102
+ const v = Math.floor(o - O * 24);
1103
+ return O < 2 && v > 0 && (y += ` ${v}h`), x + y;
1103
1104
  }
1104
1105
  if (f >= 1) {
1105
- let m = `${f}h`;
1106
+ let y = `${f}h`;
1106
1107
  if (f < 3) {
1107
- const I = Math.floor(c - f * 60);
1108
- I > 0 && (m += ` ${I}m`);
1108
+ const v = Math.floor(c - f * 60);
1109
+ v > 0 && (y += ` ${v}m`);
1109
1110
  }
1110
- return U + m;
1111
+ return x + y;
1111
1112
  }
1112
- if (v >= 1) {
1113
- let m = `${v}m`;
1114
- if (v < 5) {
1115
- const I = Math.floor(d - v * 60);
1116
- I > 0 && (m += ` ${I}s`);
1113
+ if (T >= 1) {
1114
+ let y = `${T}m`;
1115
+ if (T < 5) {
1116
+ const v = Math.floor(d - T * 60);
1117
+ v > 0 && (y += ` ${v}s`);
1117
1118
  }
1118
- return U + m;
1119
+ return x + y;
1119
1120
  }
1120
- return `${U}${x}s`;
1121
+ return `${x}${E}s`;
1121
1122
  }
1122
1123
  /**
1123
1124
  * Multiplies the TimeSpan by a scalar value.
@@ -1126,7 +1127,7 @@ class l extends W {
1126
1127
  * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
1127
1128
  */
1128
1129
  mult(e) {
1129
- return new l($(this.valueOf(), e));
1130
+ return new l(M(this.valueOf(), e));
1130
1131
  }
1131
1132
  /**
1132
1133
  * Divides the TimeSpan by a scalar value.
@@ -1135,7 +1136,7 @@ class l extends W {
1135
1136
  * @returns A new TimeSpan that is this TimeSpan divided by the provided value.
1136
1137
  */
1137
1138
  div(e) {
1138
- return new l(ne(this.valueOf(), e));
1139
+ return new l(ee(this.valueOf(), e));
1139
1140
  }
1140
1141
  /** @returns the decimal number of days in the TimeSpan. */
1141
1142
  get days() {
@@ -1215,7 +1216,7 @@ class l extends W {
1215
1216
  * @returns A TimeSpan representing the given number of microseconds.
1216
1217
  */
1217
1218
  static microseconds(e = 1) {
1218
- return l.nanoseconds($(e, 1e3));
1219
+ return l.nanoseconds(M(e, 1e3));
1219
1220
  }
1220
1221
  /** A microsecond. */
1221
1222
  static MICROSECOND = l.microseconds(1);
@@ -1226,7 +1227,7 @@ class l extends W {
1226
1227
  * @returns A TimeSpan representing the given number of milliseconds.
1227
1228
  */
1228
1229
  static milliseconds(e = 1) {
1229
- return l.microseconds($(e, 1e3));
1230
+ return l.microseconds(M(e, 1e3));
1230
1231
  }
1231
1232
  /** A millisecond. */
1232
1233
  static MILLISECOND = l.milliseconds(1);
@@ -1237,7 +1238,7 @@ class l extends W {
1237
1238
  * @returns A TimeSpan representing the given number of seconds.
1238
1239
  */
1239
1240
  static seconds(e = 1) {
1240
- return l.milliseconds($(e, 1e3));
1241
+ return l.milliseconds(M(e, 1e3));
1241
1242
  }
1242
1243
  /** A second. */
1243
1244
  static SECOND = l.seconds(1);
@@ -1248,7 +1249,7 @@ class l extends W {
1248
1249
  * @returns A TimeSpan representing the given number of minutes.
1249
1250
  */
1250
1251
  static minutes(e = 1) {
1251
- return l.seconds($(e, 60));
1252
+ return l.seconds(M(e, 60));
1252
1253
  }
1253
1254
  /** A minute. */
1254
1255
  static MINUTE = l.minutes(1);
@@ -1259,7 +1260,7 @@ class l extends W {
1259
1260
  * @returns A TimeSpan representing the given number of hours.
1260
1261
  */
1261
1262
  static hours(e) {
1262
- return l.minutes($(e, 60));
1263
+ return l.minutes(M(e, 60));
1263
1264
  }
1264
1265
  /** Represents an hour. */
1265
1266
  static HOUR = l.hours(1);
@@ -1270,12 +1271,12 @@ class l extends W {
1270
1271
  * @returns A TimeSpan representing the given number of days.
1271
1272
  */
1272
1273
  static days(e) {
1273
- return l.hours($(e, 24));
1274
+ return l.hours(M(e, 24));
1274
1275
  }
1275
1276
  /** Represents a day. */
1276
1277
  static DAY = l.days(1);
1277
1278
  /** The maximum possible value for a TimeSpan. */
1278
- static MAX = new l(le);
1279
+ static MAX = new l(ae);
1279
1280
  /** The minimum possible value for a TimeSpan. */
1280
1281
  static MIN = new l(0);
1281
1282
  /** The zero value for a TimeSpan. */
@@ -1291,7 +1292,7 @@ class l extends W {
1291
1292
  s.custom((e) => e instanceof N).transform((e) => new l(e))
1292
1293
  ]);
1293
1294
  }
1294
- class N extends W {
1295
+ class N extends Z {
1295
1296
  constructor(e) {
1296
1297
  A(e) && (e = e.value), super(e.valueOf());
1297
1298
  }
@@ -1328,7 +1329,7 @@ class N extends W {
1328
1329
  * @returns The number of bytes in the given TimeSpan at this rate.
1329
1330
  */
1330
1331
  byteCount(e, t) {
1331
- return this.sampleCount(e) * new y(t).valueOf();
1332
+ return this.sampleCount(e) * new p(t).valueOf();
1332
1333
  }
1333
1334
  /**
1334
1335
  * Calculates a TimeSpan given the number of samples at this rate.
@@ -1347,7 +1348,7 @@ class N extends W {
1347
1348
  * @returns A TimeSpan that corresponds to the given number of bytes.
1348
1349
  */
1349
1350
  byteSpan(e, t) {
1350
- return this.span(e.valueOf() / new y(t).valueOf());
1351
+ return this.span(e.valueOf() / new p(t).valueOf());
1351
1352
  }
1352
1353
  /**
1353
1354
  * Adds another Rate to this Rate.
@@ -1356,7 +1357,7 @@ class N extends W {
1356
1357
  * @returns A new Rate representing the sum of the two rates.
1357
1358
  */
1358
1359
  add(e) {
1359
- return new N(re(this.valueOf(), new N(e).valueOf()));
1360
+ return new N($(this.valueOf(), new N(e).valueOf()));
1360
1361
  }
1361
1362
  /**
1362
1363
  * Subtracts another Rate from this Rate.
@@ -1365,7 +1366,7 @@ class N extends W {
1365
1366
  * @returns A new Rate representing the difference of the two rates.
1366
1367
  */
1367
1368
  sub(e) {
1368
- return new N(te(this.valueOf(), new N(e).valueOf()));
1369
+ return new N(V(this.valueOf(), new N(e).valueOf()));
1369
1370
  }
1370
1371
  /**
1371
1372
  * Multiplies this Rate by a scalar value.
@@ -1374,7 +1375,7 @@ class N extends W {
1374
1375
  * @returns A new Rate representing this Rate multiplied by the value.
1375
1376
  */
1376
1377
  mult(e) {
1377
- return new N($(this.valueOf(), e));
1378
+ return new N(M(this.valueOf(), e));
1378
1379
  }
1379
1380
  /**
1380
1381
  * Divides this Rate by a scalar value.
@@ -1383,7 +1384,7 @@ class N extends W {
1383
1384
  * @returns A new Rate representing this Rate divided by the value.
1384
1385
  */
1385
1386
  div(e) {
1386
- return new N(ne(this.valueOf(), e));
1387
+ return new N(ee(this.valueOf(), e));
1387
1388
  }
1388
1389
  /**
1389
1390
  * Creates a Rate representing the given number of Hz.
@@ -1409,7 +1410,7 @@ class N extends W {
1409
1410
  s.instanceof(N)
1410
1411
  ]);
1411
1412
  }
1412
- class y extends W {
1413
+ class p extends Z {
1413
1414
  /**
1414
1415
  * Creates a Density representing the given number of bytes per value.
1415
1416
  *
@@ -1436,7 +1437,7 @@ class y extends W {
1436
1437
  * @returns A Size representing the given number of values.
1437
1438
  */
1438
1439
  size(e) {
1439
- return new p(e * this.valueOf());
1440
+ return new m(e * this.valueOf());
1440
1441
  }
1441
1442
  /**
1442
1443
  * Adds another Density to this Density.
@@ -1445,7 +1446,7 @@ class y extends W {
1445
1446
  * @returns A new Density representing the sum of the two densities.
1446
1447
  */
1447
1448
  add(e) {
1448
- return new y(re(this.valueOf(), new y(e).valueOf()));
1449
+ return new p($(this.valueOf(), new p(e).valueOf()));
1449
1450
  }
1450
1451
  /**
1451
1452
  * Subtracts another Density from this Density.
@@ -1454,7 +1455,7 @@ class y extends W {
1454
1455
  * @returns A new Density representing the difference of the two densities.
1455
1456
  */
1456
1457
  sub(e) {
1457
- return new y(te(this.valueOf(), new y(e).valueOf()));
1458
+ return new p(V(this.valueOf(), new p(e).valueOf()));
1458
1459
  }
1459
1460
  /**
1460
1461
  * Multiplies this Density by a scalar value.
@@ -1463,7 +1464,7 @@ class y extends W {
1463
1464
  * @returns A new Density representing this Density multiplied by the value.
1464
1465
  */
1465
1466
  mult(e) {
1466
- return new y($(this.valueOf(), e));
1467
+ return new p(M(this.valueOf(), e));
1467
1468
  }
1468
1469
  /**
1469
1470
  * Divides this Density by a scalar value.
@@ -1472,27 +1473,27 @@ class y extends W {
1472
1473
  * @returns A new Density representing this Density divided by the value.
1473
1474
  */
1474
1475
  div(e) {
1475
- return new y(ne(this.valueOf(), e));
1476
+ return new p(ee(this.valueOf(), e));
1476
1477
  }
1477
1478
  /** Unknown/Invalid Density. */
1478
- static UNKNOWN = new y(0);
1479
+ static UNKNOWN = new p(0);
1479
1480
  /** 128 bits per value. */
1480
- static BIT128 = new y(16);
1481
+ static BIT128 = new p(16);
1481
1482
  /** 64 bits per value. */
1482
- static BIT64 = new y(8);
1483
+ static BIT64 = new p(8);
1483
1484
  /** 32 bits per value. */
1484
- static BIT32 = new y(4);
1485
+ static BIT32 = new p(4);
1485
1486
  /** 16 bits per value. */
1486
- static BIT16 = new y(2);
1487
+ static BIT16 = new p(2);
1487
1488
  /** 8 bits per value. */
1488
- static BIT8 = new y(1);
1489
+ static BIT8 = new p(1);
1489
1490
  /** A zod schema for validating and transforming densities */
1490
1491
  static z = s.union([
1491
- s.number().transform((e) => new y(e)),
1492
- s.instanceof(y)
1492
+ s.number().transform((e) => new p(e)),
1493
+ s.instanceof(p)
1493
1494
  ]);
1494
1495
  }
1495
- class E {
1496
+ class I {
1496
1497
  /**
1497
1498
  * The starting TimeStamp of the TimeRange.
1498
1499
  *
@@ -1560,7 +1561,7 @@ class E {
1560
1561
  * @returns A TimeRange with the start and end swapped.
1561
1562
  */
1562
1563
  swap() {
1563
- return new E(this.end, this.start);
1564
+ return new I(this.end, this.start);
1564
1565
  }
1565
1566
  get numericBounds() {
1566
1567
  return {
@@ -1612,11 +1613,11 @@ class E {
1612
1613
  const n = this.makeValid();
1613
1614
  if (this.equals(e)) return !0;
1614
1615
  if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1615
- const i = u.max(n.start, e.start), a = u.min(n.end, e.end);
1616
- return a.before(i) ? !1 : new l(a.sub(i)).greaterThanOrEqual(t);
1616
+ const i = u.max(n.start, e.start), o = u.min(n.end, e.end);
1617
+ return o.before(i) ? !1 : new l(o.sub(i)).greaterThanOrEqual(t);
1617
1618
  }
1618
1619
  contains(e) {
1619
- return e instanceof E ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1620
+ return e instanceof I ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1620
1621
  }
1621
1622
  /**
1622
1623
  * Returns a new TimeRange that is bound by the given TimeRange.
@@ -1630,23 +1631,23 @@ class E {
1630
1631
  * console.log(bounded); // TimeRange(1500, 2000)
1631
1632
  */
1632
1633
  boundBy(e) {
1633
- const t = new E(this.start, this.end);
1634
+ const t = new I(this.start, this.end);
1634
1635
  return e.start.after(this.start) && (t.start = e.start), e.start.after(this.end) && (t.end = e.start), e.end.before(this.end) && (t.end = e.end), e.end.before(this.start) && (t.start = e.end), t;
1635
1636
  }
1636
1637
  static max(...e) {
1637
- return new E(
1638
+ return new I(
1638
1639
  u.min(...e.map((t) => t.start)),
1639
1640
  u.max(...e.map((t) => t.end))
1640
1641
  );
1641
1642
  }
1642
1643
  /** The maximum possible time range. */
1643
- static MAX = new E(u.MIN, u.MAX);
1644
+ static MAX = new I(u.MIN, u.MAX);
1644
1645
  /** A time range whose start and end are both zero. */
1645
- static ZERO = new E(u.ZERO, u.ZERO);
1646
+ static ZERO = new I(u.ZERO, u.ZERO);
1646
1647
  /** A zod schema for validating and transforming time ranges */
1647
1648
  static z = s.union([
1648
- s.object({ start: u.z, end: u.z }).transform((e) => new E(e.start, e.end)),
1649
- s.instanceof(E)
1649
+ s.object({ start: u.z, end: u.z }).transform((e) => new I(e.start, e.end)),
1650
+ s.instanceof(I)
1650
1651
  ]);
1651
1652
  /**
1652
1653
  * Sorts two time ranges. The range with the earlier start time is considered less than
@@ -1663,28 +1664,22 @@ class E {
1663
1664
  return u.sort(e.start, t.start) || u.sort(e.end, t.end);
1664
1665
  }
1665
1666
  /**
1666
- * Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
1667
- * merges any overlapping ranges.
1667
+ * Merges the given time ranges into a single time range.
1668
1668
  *
1669
- * @param ranges - The list of `TimeRange`s to simplify.
1670
- * @returns A list of simplified `TimeRange`s.
1669
+ * @param ranges - The list of `CrudeTimeRange`s to merge.
1670
+ * @returns A new `TimeRange` that is the union of the given time ranges - the start
1671
+ * is the minimum of the start times and the end is the maximum of the end times.
1671
1672
  */
1672
- static simplify(e) {
1673
- return e.map((t) => t.makeValid()).sort((t, n) => E.sort(t, n)).reduce((t, n) => {
1674
- if (n.span.isZero) return t;
1675
- if (t.length === 0)
1676
- return t.push(n), t;
1677
- const i = t[t.length - 1];
1678
- return i.overlapsWith(n) || i.end.equals(n.start) ? i.end = u.max(i.end, n.end) : t.push(n), t;
1679
- }, []);
1673
+ static merge(...e) {
1674
+ return I.max(...e.map((t) => new I(t).makeValid()));
1680
1675
  }
1681
1676
  }
1682
- let T = class o extends W {
1677
+ class a extends Z {
1683
1678
  constructor(e) {
1684
- if (A(e) && (e = e.value), e instanceof o || typeof e == "string" || typeof e.valueOf() == "string")
1679
+ if (A(e) && (e = e.value), e instanceof a || typeof e == "string" || typeof e.valueOf() == "string")
1685
1680
  super(e.valueOf());
1686
1681
  else {
1687
- const t = o.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1682
+ const t = a.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1688
1683
  if (t == null)
1689
1684
  throw new Error(`unable to find data type for ${e.toString()}`);
1690
1685
  super(t.valueOf());
@@ -1694,7 +1689,7 @@ let T = class o extends W {
1694
1689
  * @returns the TypedArray constructor for the DataType.
1695
1690
  */
1696
1691
  get Array() {
1697
- const e = o.ARRAY_CONSTRUCTORS.get(this.toString());
1692
+ const e = a.ARRAY_CONSTRUCTORS.get(this.toString());
1698
1693
  if (e == null)
1699
1694
  throw new Error(`unable to find array constructor for ${this.valueOf()}`);
1700
1695
  return e;
@@ -1714,7 +1709,7 @@ let T = class o extends W {
1714
1709
  /** @returns a string representation of the DataType. If short is true, a 1-4
1715
1710
  * character representation (i64, str, etc.) is returned instead. */
1716
1711
  toString(e = !1) {
1717
- return e ? o.SHORT_STRINGS.get(this.valueOf()) ?? this.valueOf() : this.valueOf();
1712
+ return e ? a.SHORT_STRINGS.get(this.valueOf()) ?? this.valueOf() : this.valueOf();
1718
1713
  }
1719
1714
  /**
1720
1715
  * @returns true if the DataType has a variable density.
@@ -1722,7 +1717,7 @@ let T = class o extends W {
1722
1717
  * @example DataType.INT32.isVariable // false
1723
1718
  */
1724
1719
  get isVariable() {
1725
- return this.equals(o.JSON) || this.equals(o.STRING);
1720
+ return this.equals(a.JSON) || this.equals(a.STRING);
1726
1721
  }
1727
1722
  /**
1728
1723
  * @returns true if the DataType is numeric.
@@ -1730,7 +1725,7 @@ let T = class o extends W {
1730
1725
  * @example DataType.STRING.isNumeric // false
1731
1726
  */
1732
1727
  get isNumeric() {
1733
- return !this.isVariable && !this.equals(o.UUID);
1728
+ return !this.isVariable && !this.equals(a.UUID);
1734
1729
  }
1735
1730
  /**
1736
1731
  * @returns true if the DataType is an integer.
@@ -1755,7 +1750,7 @@ let T = class o extends W {
1755
1750
  * @example DataType.FLOAT32.density // Density.BIT32
1756
1751
  */
1757
1752
  get density() {
1758
- const e = o.DENSITIES.get(this.toString());
1753
+ const e = a.DENSITIES.get(this.toString());
1759
1754
  if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
1760
1755
  return e;
1761
1756
  }
@@ -1765,7 +1760,7 @@ let T = class o extends W {
1765
1760
  * @example DataType.INT32.isUnsigned // false
1766
1761
  */
1767
1762
  get isUnsignedInteger() {
1768
- return this.equals(o.UINT8) || this.equals(o.UINT16) || this.equals(o.UINT32) || this.equals(o.UINT64);
1763
+ return this.equals(a.UINT8) || this.equals(a.UINT16) || this.equals(a.UINT32) || this.equals(a.UINT64);
1769
1764
  }
1770
1765
  /**
1771
1766
  * @returns true if the DataType is a signed integer.
@@ -1773,11 +1768,11 @@ let T = class o extends W {
1773
1768
  * @example DataType.UINT32.isSigned // false
1774
1769
  */
1775
1770
  get isSignedInteger() {
1776
- return this.equals(o.INT8) || this.equals(o.INT16) || this.equals(o.INT32) || this.equals(o.INT64);
1771
+ return this.equals(a.INT8) || this.equals(a.INT16) || this.equals(a.INT32) || this.equals(a.INT64);
1777
1772
  }
1778
1773
  /** @returns true if the data type can be cast to the other data type without loss of precision. */
1779
1774
  canSafelyCastTo(e) {
1780
- return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(o.INT32) && e.equals(o.FLOAT64) || this.equals(o.INT8) && e.equals(o.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
1775
+ return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(a.INT32) && e.equals(a.FLOAT64) || this.equals(a.INT8) && e.equals(a.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
1781
1776
  }
1782
1777
  /** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
1783
1778
  canCastTo(e) {
@@ -1794,129 +1789,129 @@ let T = class o extends W {
1794
1789
  }
1795
1790
  /** @returns true if the data type uses bigints to store values. */
1796
1791
  get usesBigInt() {
1797
- return o.BIG_INT_TYPES.some((e) => e.equals(this));
1792
+ return a.BIG_INT_TYPES.some((e) => e.equals(this));
1798
1793
  }
1799
1794
  /** Represents an Unknown/Invalid DataType. */
1800
- static UNKNOWN = new o("unknown");
1795
+ static UNKNOWN = new a("unknown");
1801
1796
  /** Represents a 64-bit floating point value. */
1802
- static FLOAT64 = new o("float64");
1797
+ static FLOAT64 = new a("float64");
1803
1798
  /** Represents a 32-bit floating point value. */
1804
- static FLOAT32 = new o("float32");
1799
+ static FLOAT32 = new a("float32");
1805
1800
  /** Represents a 64-bit signed integer value. */
1806
- static INT64 = new o("int64");
1801
+ static INT64 = new a("int64");
1807
1802
  /** Represents a 32-bit signed integer value. */
1808
- static INT32 = new o("int32");
1803
+ static INT32 = new a("int32");
1809
1804
  /** Represents a 16-bit signed integer value. */
1810
- static INT16 = new o("int16");
1805
+ static INT16 = new a("int16");
1811
1806
  /** Represents a 8-bit signed integer value. */
1812
- static INT8 = new o("int8");
1807
+ static INT8 = new a("int8");
1813
1808
  /** Represents a 64-bit unsigned integer value. */
1814
- static UINT64 = new o("uint64");
1809
+ static UINT64 = new a("uint64");
1815
1810
  /** Represents a 32-bit unsigned integer value. */
1816
- static UINT32 = new o("uint32");
1811
+ static UINT32 = new a("uint32");
1817
1812
  /** Represents a 16-bit unsigned integer value. */
1818
- static UINT16 = new o("uint16");
1813
+ static UINT16 = new a("uint16");
1819
1814
  /** Represents a 8-bit unsigned integer value. */
1820
- static UINT8 = new o("uint8");
1815
+ static UINT8 = new a("uint8");
1821
1816
  /** Represents a boolean value. Stored as a 8-bit unsigned integer. */
1822
- static BOOLEAN = new o("boolean");
1817
+ static BOOLEAN = new a("boolean");
1823
1818
  /** Represents a 64-bit unix epoch. */
1824
- static TIMESTAMP = new o("timestamp");
1819
+ static TIMESTAMP = new a("timestamp");
1825
1820
  /** Represents a UUID data type. */
1826
- static UUID = new o("uuid");
1821
+ static UUID = new a("uuid");
1827
1822
  /** Represents a string data type. Strings have an unknown density, and are separate
1828
1823
  * by a newline character. */
1829
- static STRING = new o("string");
1824
+ static STRING = new a("string");
1830
1825
  /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1831
1826
  * newline character. */
1832
- static JSON = new o("json");
1827
+ static JSON = new a("json");
1833
1828
  static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
1834
- [o.UINT8.toString(), Uint8Array],
1835
- [o.UINT16.toString(), Uint16Array],
1836
- [o.UINT32.toString(), Uint32Array],
1837
- [o.UINT64.toString(), BigUint64Array],
1838
- [o.FLOAT32.toString(), Float32Array],
1839
- [o.FLOAT64.toString(), Float64Array],
1840
- [o.INT8.toString(), Int8Array],
1841
- [o.INT16.toString(), Int16Array],
1842
- [o.INT32.toString(), Int32Array],
1843
- [o.INT64.toString(), BigInt64Array],
1844
- [o.TIMESTAMP.toString(), BigInt64Array],
1845
- [o.STRING.toString(), Uint8Array],
1846
- [o.JSON.toString(), Uint8Array],
1847
- [o.UUID.toString(), Uint8Array]
1829
+ [a.UINT8.toString(), Uint8Array],
1830
+ [a.UINT16.toString(), Uint16Array],
1831
+ [a.UINT32.toString(), Uint32Array],
1832
+ [a.UINT64.toString(), BigUint64Array],
1833
+ [a.FLOAT32.toString(), Float32Array],
1834
+ [a.FLOAT64.toString(), Float64Array],
1835
+ [a.INT8.toString(), Int8Array],
1836
+ [a.INT16.toString(), Int16Array],
1837
+ [a.INT32.toString(), Int32Array],
1838
+ [a.INT64.toString(), BigInt64Array],
1839
+ [a.TIMESTAMP.toString(), BigInt64Array],
1840
+ [a.STRING.toString(), Uint8Array],
1841
+ [a.JSON.toString(), Uint8Array],
1842
+ [a.UUID.toString(), Uint8Array]
1848
1843
  ]);
1849
1844
  static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
1850
- [Uint8Array.name, o.UINT8],
1851
- [Uint16Array.name, o.UINT16],
1852
- [Uint32Array.name, o.UINT32],
1853
- [BigUint64Array.name, o.UINT64],
1854
- [Float32Array.name, o.FLOAT32],
1855
- [Float64Array.name, o.FLOAT64],
1856
- [Int8Array.name, o.INT8],
1857
- [Int16Array.name, o.INT16],
1858
- [Int32Array.name, o.INT32],
1859
- [BigInt64Array.name, o.INT64]
1845
+ [Uint8Array.name, a.UINT8],
1846
+ [Uint16Array.name, a.UINT16],
1847
+ [Uint32Array.name, a.UINT32],
1848
+ [BigUint64Array.name, a.UINT64],
1849
+ [Float32Array.name, a.FLOAT32],
1850
+ [Float64Array.name, a.FLOAT64],
1851
+ [Int8Array.name, a.INT8],
1852
+ [Int16Array.name, a.INT16],
1853
+ [Int32Array.name, a.INT32],
1854
+ [BigInt64Array.name, a.INT64]
1860
1855
  ]);
1861
1856
  static DENSITIES = /* @__PURE__ */ new Map([
1862
- [o.UINT8.toString(), y.BIT8],
1863
- [o.UINT16.toString(), y.BIT16],
1864
- [o.UINT32.toString(), y.BIT32],
1865
- [o.UINT64.toString(), y.BIT64],
1866
- [o.FLOAT32.toString(), y.BIT32],
1867
- [o.FLOAT64.toString(), y.BIT64],
1868
- [o.INT8.toString(), y.BIT8],
1869
- [o.INT16.toString(), y.BIT16],
1870
- [o.INT32.toString(), y.BIT32],
1871
- [o.INT64.toString(), y.BIT64],
1872
- [o.TIMESTAMP.toString(), y.BIT64],
1873
- [o.STRING.toString(), y.UNKNOWN],
1874
- [o.JSON.toString(), y.UNKNOWN],
1875
- [o.UUID.toString(), y.BIT128]
1857
+ [a.UINT8.toString(), p.BIT8],
1858
+ [a.UINT16.toString(), p.BIT16],
1859
+ [a.UINT32.toString(), p.BIT32],
1860
+ [a.UINT64.toString(), p.BIT64],
1861
+ [a.FLOAT32.toString(), p.BIT32],
1862
+ [a.FLOAT64.toString(), p.BIT64],
1863
+ [a.INT8.toString(), p.BIT8],
1864
+ [a.INT16.toString(), p.BIT16],
1865
+ [a.INT32.toString(), p.BIT32],
1866
+ [a.INT64.toString(), p.BIT64],
1867
+ [a.TIMESTAMP.toString(), p.BIT64],
1868
+ [a.STRING.toString(), p.UNKNOWN],
1869
+ [a.JSON.toString(), p.UNKNOWN],
1870
+ [a.UUID.toString(), p.BIT128]
1876
1871
  ]);
1877
1872
  /** All the data types. */
1878
1873
  static ALL = [
1879
- o.UNKNOWN,
1880
- o.FLOAT64,
1881
- o.FLOAT32,
1882
- o.INT64,
1883
- o.INT32,
1884
- o.INT16,
1885
- o.INT8,
1886
- o.UINT64,
1887
- o.UINT32,
1888
- o.UINT16,
1889
- o.UINT8,
1890
- o.TIMESTAMP,
1891
- o.UUID,
1892
- o.STRING,
1893
- o.JSON
1874
+ a.UNKNOWN,
1875
+ a.FLOAT64,
1876
+ a.FLOAT32,
1877
+ a.INT64,
1878
+ a.INT32,
1879
+ a.INT16,
1880
+ a.INT8,
1881
+ a.UINT64,
1882
+ a.UINT32,
1883
+ a.UINT16,
1884
+ a.UINT8,
1885
+ a.TIMESTAMP,
1886
+ a.UUID,
1887
+ a.STRING,
1888
+ a.JSON
1894
1889
  ];
1895
1890
  static SHORT_STRINGS = /* @__PURE__ */ new Map([
1896
- [o.UINT8.toString(), "u8"],
1897
- [o.UINT16.toString(), "u16"],
1898
- [o.UINT32.toString(), "u32"],
1899
- [o.UINT64.toString(), "u64"],
1900
- [o.INT8.toString(), "i8"],
1901
- [o.INT16.toString(), "i16"],
1902
- [o.INT32.toString(), "i32"],
1903
- [o.INT64.toString(), "i64"],
1904
- [o.FLOAT32.toString(), "f32"],
1905
- [o.FLOAT64.toString(), "f64"],
1906
- [o.BOOLEAN.toString(), "bool"],
1907
- [o.TIMESTAMP.toString(), "ts"],
1908
- [o.UUID.toString(), "uuid"],
1909
- [o.STRING.toString(), "str"],
1910
- [o.JSON.toString(), "json"]
1891
+ [a.UINT8.toString(), "u8"],
1892
+ [a.UINT16.toString(), "u16"],
1893
+ [a.UINT32.toString(), "u32"],
1894
+ [a.UINT64.toString(), "u64"],
1895
+ [a.INT8.toString(), "i8"],
1896
+ [a.INT16.toString(), "i16"],
1897
+ [a.INT32.toString(), "i32"],
1898
+ [a.INT64.toString(), "i64"],
1899
+ [a.FLOAT32.toString(), "f32"],
1900
+ [a.FLOAT64.toString(), "f64"],
1901
+ [a.BOOLEAN.toString(), "bool"],
1902
+ [a.TIMESTAMP.toString(), "ts"],
1903
+ [a.UUID.toString(), "uuid"],
1904
+ [a.STRING.toString(), "str"],
1905
+ [a.JSON.toString(), "json"]
1911
1906
  ]);
1912
- static BIG_INT_TYPES = [o.INT64, o.UINT64, o.TIMESTAMP];
1907
+ static BIG_INT_TYPES = [a.INT64, a.UINT64, a.TIMESTAMP];
1913
1908
  /** A zod schema for a DataType. */
1914
1909
  static z = s.union([
1915
- s.string().transform((e) => new o(e)),
1916
- s.instanceof(o)
1910
+ s.string().transform((e) => new a(e)),
1911
+ s.instanceof(a)
1917
1912
  ]);
1918
- };
1919
- class p extends W {
1913
+ }
1914
+ class m extends Z {
1920
1915
  constructor(e) {
1921
1916
  A(e) && (e = e.value), super(e.valueOf());
1922
1917
  }
@@ -1930,11 +1925,11 @@ class p extends W {
1930
1925
  }
1931
1926
  /** @returns a new Size representing the sum of the two Sizes. */
1932
1927
  add(e) {
1933
- return A(e) && (e = e.value), new p(re(this.valueOf(), e.valueOf()));
1928
+ return A(e) && (e = e.value), new m($(this.valueOf(), e.valueOf()));
1934
1929
  }
1935
1930
  /** @returns a new Size representing the difference of the two Sizes. */
1936
1931
  sub(e) {
1937
- return A(e) && (e = e.value), new p(te(this.valueOf(), e.valueOf()));
1932
+ return A(e) && (e = e.value), new m(V(this.valueOf(), e.valueOf()));
1938
1933
  }
1939
1934
  /**
1940
1935
  * Multiplies this Size by a scalar value.
@@ -1943,7 +1938,7 @@ class p extends W {
1943
1938
  * @returns A new Size representing this Size multiplied by the value.
1944
1939
  */
1945
1940
  mult(e) {
1946
- return new p($(this.valueOf(), e));
1941
+ return new m(M(this.valueOf(), e));
1947
1942
  }
1948
1943
  /**
1949
1944
  * Divides this Size by a scalar value.
@@ -1952,39 +1947,39 @@ class p extends W {
1952
1947
  * @returns A new Size representing this Size divided by the value.
1953
1948
  */
1954
1949
  div(e) {
1955
- return new p(ne(this.valueOf(), e));
1950
+ return new m(ee(this.valueOf(), e));
1956
1951
  }
1957
1952
  /** @returns a new Size representing the truncated value of the Size. */
1958
1953
  truncate(e) {
1959
- return new p(
1960
- Math.trunc(this.valueOf() / new p(e).valueOf()) * new p(e).valueOf()
1954
+ return new m(
1955
+ Math.trunc(this.valueOf() / new m(e).valueOf()) * new m(e).valueOf()
1961
1956
  );
1962
1957
  }
1963
1958
  /** @returns a new Size representing the remainder of the Size. */
1964
1959
  remainder(e) {
1965
- return p.bytes(this.valueOf() % new p(e).valueOf());
1960
+ return m.bytes(this.valueOf() % new m(e).valueOf());
1966
1961
  }
1967
1962
  /** @returns the number of gigabytes in the Size. */
1968
1963
  get gigabytes() {
1969
- return this.valueOf() / p.GIGABYTE.valueOf();
1964
+ return this.valueOf() / m.GIGABYTE.valueOf();
1970
1965
  }
1971
1966
  /** @returns the number of megabytes in the Size. */
1972
1967
  get megabytes() {
1973
- return this.valueOf() / p.MEGABYTE.valueOf();
1968
+ return this.valueOf() / m.MEGABYTE.valueOf();
1974
1969
  }
1975
1970
  /** @returns the number of kilobytes in the Size. */
1976
1971
  get kilobytes() {
1977
- return this.valueOf() / p.KILOBYTE.valueOf();
1972
+ return this.valueOf() / m.KILOBYTE.valueOf();
1978
1973
  }
1979
1974
  /** @returns the number of terabytes in the Size. */
1980
1975
  get terabytes() {
1981
- return this.valueOf() / p.TERABYTE.valueOf();
1976
+ return this.valueOf() / m.TERABYTE.valueOf();
1982
1977
  }
1983
1978
  /** @returns a nicely formatted string representation of the Size. */
1984
1979
  toString() {
1985
- const e = this.truncate(p.TERABYTE), t = this.truncate(p.GIGABYTE), n = this.truncate(p.MEGABYTE), i = this.truncate(p.KILOBYTE), a = this.truncate(p.BYTE), c = e, d = t.sub(e), w = n.sub(t), h = i.sub(n), g = a.sub(i);
1986
- let b = "";
1987
- return c.isZero || (b += `${c.terabytes}TB `), d.isZero || (b += `${d.gigabytes}GB `), w.isZero || (b += `${w.megabytes}MB `), h.isZero || (b += `${h.kilobytes}KB `), (!g.isZero || b === "") && (b += `${g.valueOf()}B`), b.trim();
1980
+ const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), o = this.truncate(m.BYTE), c = e, d = t.sub(e), w = n.sub(t), h = i.sub(n), g = o.sub(i);
1981
+ let O = "";
1982
+ return c.isZero || (O += `${c.terabytes}TB `), d.isZero || (O += `${d.gigabytes}GB `), w.isZero || (O += `${w.megabytes}MB `), h.isZero || (O += `${h.kilobytes}KB `), (!g.isZero || O === "") && (O += `${g.valueOf()}B`), O.trim();
1988
1983
  }
1989
1984
  /**
1990
1985
  * Creates a Size from the given number of bytes.
@@ -1993,10 +1988,10 @@ class p extends W {
1993
1988
  * @returns A Size representing the given number of bytes.
1994
1989
  */
1995
1990
  static bytes(e = 1) {
1996
- return new p(e);
1991
+ return new m(e);
1997
1992
  }
1998
1993
  /** A single byte */
1999
- static BYTE = new p(1);
1994
+ static BYTE = new m(1);
2000
1995
  /**
2001
1996
  * Creates a Size from the given number if kilobytes.
2002
1997
  *
@@ -2004,10 +1999,10 @@ class p extends W {
2004
1999
  * @returns A Size representing the given number of kilobytes.
2005
2000
  */
2006
2001
  static kilobytes(e = 1) {
2007
- return p.bytes(new p(e).valueOf() * 1e3);
2002
+ return m.bytes(new m(e).valueOf() * 1e3);
2008
2003
  }
2009
2004
  /** A kilobyte */
2010
- static KILOBYTE = p.kilobytes(1);
2005
+ static KILOBYTE = m.kilobytes(1);
2011
2006
  /**
2012
2007
  * Creates a Size from the given number of megabytes.
2013
2008
  *
@@ -2015,10 +2010,10 @@ class p extends W {
2015
2010
  * @returns A Size representing the given number of megabytes.
2016
2011
  */
2017
2012
  static megabytes(e = 1) {
2018
- return p.kilobytes(new p(e).valueOf() * 1e3);
2013
+ return m.kilobytes(new m(e).valueOf() * 1e3);
2019
2014
  }
2020
2015
  /** A megabyte */
2021
- static MEGABYTE = p.megabytes(1);
2016
+ static MEGABYTE = m.megabytes(1);
2022
2017
  /**
2023
2018
  * Creates a Size from the given number of gigabytes.
2024
2019
  *
@@ -2026,10 +2021,10 @@ class p extends W {
2026
2021
  * @returns A Size representing the given number of gigabytes.
2027
2022
  */
2028
2023
  static gigabytes(e = 1) {
2029
- return p.megabytes(new p(e).valueOf() * 1e3);
2024
+ return m.megabytes(new m(e).valueOf() * 1e3);
2030
2025
  }
2031
2026
  /** A gigabyte */
2032
- static GIGABYTE = p.gigabytes(1);
2027
+ static GIGABYTE = m.gigabytes(1);
2033
2028
  /**
2034
2029
  * Creates a Size from the given number of terabytes.
2035
2030
  *
@@ -2037,16 +2032,16 @@ class p extends W {
2037
2032
  * @returns A Size representing the given number of terabytes.
2038
2033
  */
2039
2034
  static terabytes(e) {
2040
- return p.gigabytes(new p(e).valueOf() * 1e3);
2035
+ return m.gigabytes(new m(e).valueOf() * 1e3);
2041
2036
  }
2042
2037
  /** A terabyte. */
2043
- static TERABYTE = p.terabytes(1);
2038
+ static TERABYTE = m.terabytes(1);
2044
2039
  /** The zero value for Size */
2045
- static ZERO = new p(0);
2040
+ static ZERO = new m(0);
2046
2041
  /** A zod schema for a Size. */
2047
2042
  static z = s.union([
2048
- s.number().transform((e) => new p(e)),
2049
- s.instanceof(p)
2043
+ s.number().transform((e) => new m(e)),
2044
+ s.instanceof(m)
2050
2045
  ]);
2051
2046
  /** @returns true if the Size is zero. */
2052
2047
  get isZero() {
@@ -2069,36 +2064,36 @@ s.union([
2069
2064
  s.instanceof(Int32Array),
2070
2065
  s.instanceof(BigInt64Array)
2071
2066
  ]);
2072
- const Ye = (r) => {
2067
+ const je = (r) => {
2073
2068
  const e = typeof r;
2074
2069
  return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof u || r instanceof l || r instanceof Date;
2075
- }, Zt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : X(t, -n), X = (r, e) => e == 0 ? r : r == 0 ? e : typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : Number(r) + Number(e), zt = /^(?:[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;
2076
- function Gt(r) {
2077
- return typeof r == "string" && zt.test(r);
2070
+ }, jt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : V(t, n), 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;
2071
+ function qt(r) {
2072
+ return typeof r == "string" && Yt.test(r);
2078
2073
  }
2079
2074
  const S = [];
2080
2075
  for (let r = 0; r < 256; ++r)
2081
2076
  S.push((r + 256).toString(16).slice(1));
2082
- function Vt(r, e = 0) {
2077
+ function Ft(r, e = 0) {
2083
2078
  return (S[r[e + 0]] + S[r[e + 1]] + S[r[e + 2]] + S[r[e + 3]] + "-" + S[r[e + 4]] + S[r[e + 5]] + "-" + S[r[e + 6]] + S[r[e + 7]] + "-" + S[r[e + 8]] + S[r[e + 9]] + "-" + S[r[e + 10]] + S[r[e + 11]] + S[r[e + 12]] + S[r[e + 13]] + S[r[e + 14]] + S[r[e + 15]]).toLowerCase();
2084
2079
  }
2085
- function Ht(r, e = 0) {
2086
- const t = Vt(r, e);
2087
- if (!Gt(t))
2080
+ function Zt(r, e = 0) {
2081
+ const t = Ft(r, e);
2082
+ if (!qt(t))
2088
2083
  throw TypeError("Stringified UUID is invalid");
2089
2084
  return t;
2090
2085
  }
2091
2086
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2092
- const qe = (r, e) => Ht(r, e), B = -1, Jt = s.string().transform(
2087
+ const Ye = (r, e) => Zt(r, e), B = -1, Wt = s.string().transform(
2093
2088
  (r) => new Uint8Array(
2094
2089
  atob(r).split("").map((e) => e.charCodeAt(0))
2095
2090
  ).buffer
2096
- ), Kt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), ce = 10, Xt = (r, e) => {
2091
+ ), zt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), oe = 10, Gt = (r, e) => {
2097
2092
  if (r === "number" && !e.isNumeric)
2098
2093
  throw new Error(`cannot convert series of type ${e.toString()} to number`);
2099
2094
  if (r === "bigint" && !e.usesBigInt)
2100
2095
  throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
2101
- }, Fe = "sy_x_telem_series";
2096
+ }, qe = "sy_x_telem_series";
2102
2097
  class C {
2103
2098
  /**
2104
2099
  * A unique identifier for the series. If specified by the user, it is their
@@ -2110,7 +2105,7 @@ class C {
2110
2105
  * A discriminator used for identifying instances of the series class even
2111
2106
  * when bundlers mangle the class name.
2112
2107
  */
2113
- discriminator = Fe;
2108
+ discriminator = qe;
2114
2109
  /** The data type of the series. */
2115
2110
  dataType;
2116
2111
  /**
@@ -2126,7 +2121,7 @@ class C {
2126
2121
  /** The underlying data. */
2127
2122
  _data;
2128
2123
  /** The time range occupied by the series' data. */
2129
- timeRange = E.ZERO;
2124
+ timeRange = I.ZERO;
2130
2125
  /**
2131
2126
  * Alignment defines the location of the series relative to other series in a logical
2132
2127
  * group. Useful for defining the position of the series within a channel's data.
@@ -2155,16 +2150,16 @@ class C {
2155
2150
  * can be constructed into a series.
2156
2151
  */
2157
2152
  static crudeZ = s.object({
2158
- timeRange: E.z.optional(),
2159
- dataType: T.z,
2153
+ timeRange: I.z.optional(),
2154
+ dataType: a.z,
2160
2155
  alignment: s.coerce.bigint().optional(),
2161
2156
  data: s.union([
2162
- Jt,
2163
- Kt,
2157
+ Wt,
2158
+ zt,
2164
2159
  s.instanceof(ArrayBuffer),
2165
2160
  s.instanceof(Uint8Array)
2166
2161
  ]),
2167
- glBufferUsage: qt.optional().default("static").optional()
2162
+ glBufferUsage: kt.default("static").optional()
2168
2163
  });
2169
2164
  /**
2170
2165
  * A zod schema that validates and constructs a series from it's crude
@@ -2245,30 +2240,30 @@ class C {
2245
2240
  * @throws Error if data type cannot be inferred from input
2246
2241
  */
2247
2242
  constructor(e) {
2248
- Qt(e) && (e = { data: e }), e.data ??= [];
2243
+ Vt(e) && (e = { data: e }), e.data ??= [];
2249
2244
  const {
2250
2245
  dataType: t,
2251
2246
  timeRange: n,
2252
2247
  sampleOffset: i = 0,
2253
- glBufferUsage: a = "static",
2248
+ glBufferUsage: o = "static",
2254
2249
  alignment: c = 0n,
2255
2250
  alignmentMultiple: d = 1n,
2256
- key: w = jt(),
2251
+ key: w = ct(),
2257
2252
  data: h
2258
2253
  } = e;
2259
- if (_t(h)) {
2254
+ if (Ht(h)) {
2260
2255
  const f = h;
2261
2256
  this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this.timeRange = f.timeRange, this.alignment = f.alignment, this.alignmentMultiple = f.alignmentMultiple, this.cachedMin = f.cachedMin, this.cachedMax = f.cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this.cachedLength = f.cachedLength;
2262
2257
  return;
2263
2258
  }
2264
- const g = Ye(h), b = Array.isArray(h);
2265
- if (t != null) this.dataType = new T(t);
2259
+ const g = je(h), O = Array.isArray(h);
2260
+ if (t != null) this.dataType = new a(t);
2266
2261
  else {
2267
2262
  if (h instanceof ArrayBuffer)
2268
2263
  throw new Error(
2269
2264
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
2270
2265
  );
2271
- if (b || g) {
2266
+ if (O || g) {
2272
2267
  let f = h;
2273
2268
  if (!g) {
2274
2269
  if (h.length === 0)
@@ -2277,42 +2272,42 @@ class C {
2277
2272
  );
2278
2273
  f = h[0];
2279
2274
  }
2280
- if (typeof f == "string") this.dataType = T.STRING;
2281
- else if (typeof f == "number") this.dataType = T.FLOAT64;
2282
- else if (typeof f == "bigint") this.dataType = T.INT64;
2283
- else if (typeof f == "boolean") this.dataType = T.BOOLEAN;
2275
+ if (typeof f == "string") this.dataType = a.STRING;
2276
+ else if (typeof f == "number") this.dataType = a.FLOAT64;
2277
+ else if (typeof f == "bigint") this.dataType = a.INT64;
2278
+ else if (typeof f == "boolean") this.dataType = a.BOOLEAN;
2284
2279
  else if (f instanceof u || f instanceof Date || f instanceof u)
2285
- this.dataType = T.TIMESTAMP;
2286
- else if (typeof f == "object") this.dataType = T.JSON;
2280
+ this.dataType = a.TIMESTAMP;
2281
+ else if (typeof f == "object") this.dataType = a.JSON;
2287
2282
  else
2288
2283
  throw new Error(
2289
2284
  `cannot infer data type of ${typeof f} when constructing a Series from a JS array`
2290
2285
  );
2291
- } else this.dataType = new T(h);
2286
+ } else this.dataType = new a(h);
2292
2287
  }
2293
- if (!b && !g) this._data = h;
2294
- else if (b && h.length === 0)
2288
+ if (!O && !g) this._data = h;
2289
+ else if (O && h.length === 0)
2295
2290
  this._data = new this.dataType.Array([]).buffer;
2296
2291
  else {
2297
2292
  let f = g ? [h] : h;
2298
- const v = f[0];
2299
- (v instanceof u || v instanceof Date || v instanceof l) && (f = f.map((x) => new u(x).valueOf())), this.dataType.equals(T.STRING) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
2293
+ const T = f[0];
2294
+ (T instanceof u || T instanceof Date || T instanceof l) && (f = f.map((E) => new u(E).valueOf())), this.dataType.equals(a.STRING) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
2300
2295
  `)}
2301
- `).buffer) : this.dataType.equals(T.JSON) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(
2302
- `${f.map((x) => ue.encodeString(x)).join(`
2296
+ `).buffer) : this.dataType.equals(a.JSON) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(
2297
+ `${f.map((E) => ie.encodeString(E)).join(`
2303
2298
  `)}
2304
2299
  `
2305
- ).buffer) : this.dataType.usesBigInt && typeof v == "number" ? this._data = new this.dataType.Array(
2306
- f.map((x) => BigInt(Math.round(x)))
2307
- ).buffer : !this.dataType.usesBigInt && typeof v == "bigint" ? this._data = new this.dataType.Array(
2300
+ ).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
2301
+ f.map((E) => BigInt(Math.round(E)))
2302
+ ).buffer : !this.dataType.usesBigInt && typeof T == "bigint" ? this._data = new this.dataType.Array(
2308
2303
  f.map(Number)
2309
2304
  ).buffer : this._data = new this.dataType.Array(f).buffer;
2310
2305
  }
2311
- this.key = w, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? E.ZERO, this.gl = {
2306
+ this.key = w, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? I.ZERO, this.gl = {
2312
2307
  control: null,
2313
2308
  buffer: null,
2314
2309
  prevBuffer: 0,
2315
- bufferUsage: a
2310
+ bufferUsage: o
2316
2311
  };
2317
2312
  }
2318
2313
  /**
@@ -2325,8 +2320,8 @@ class C {
2325
2320
  static alloc({ capacity: e, dataType: t, ...n }) {
2326
2321
  if (e === 0)
2327
2322
  throw new Error("[Series] - cannot allocate an array of length 0");
2328
- const i = new new T(t).Array(e), a = new C({ data: i.buffer, dataType: t, ...n });
2329
- return a.writePos = 0, a;
2323
+ const i = new new a(t).Array(e), o = new C({ data: i.buffer, dataType: t, ...n });
2324
+ return o.writePos = 0, o;
2330
2325
  }
2331
2326
  /**
2332
2327
  * @returns the number of references to this series i.e. the number of times this
@@ -2415,16 +2410,16 @@ class C {
2415
2410
  * @returns An array of values parsed from the JSON series.
2416
2411
  */
2417
2412
  parseJSON(e) {
2418
- if (!this.dataType.equals(T.JSON))
2413
+ if (!this.dataType.equals(a.JSON))
2419
2414
  throw new Error("cannot parse non-JSON series as JSON");
2420
- return this.toStrings().map((t) => e.parse(ue.decodeString(t)));
2415
+ return this.toStrings().map((t) => e.parse(ie.decodeString(t)));
2421
2416
  }
2422
2417
  /**
2423
2418
  * Returns the capacity of the series in bytes.
2424
2419
  * @returns The size of the underlying buffer in bytes.
2425
2420
  */
2426
2421
  get byteCapacity() {
2427
- return new p(this.underlyingData.byteLength);
2422
+ return new m(this.underlyingData.byteLength);
2428
2423
  }
2429
2424
  /**
2430
2425
  * Returns the capacity of the series in samples.
@@ -2440,7 +2435,7 @@ class C {
2440
2435
  * @returns The size of the data in bytes.
2441
2436
  */
2442
2437
  get byteLength() {
2443
- return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new p(this.writePos) : this.dataType.density.size(this.writePos);
2438
+ return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new m(this.writePos) : this.dataType.density.size(this.writePos);
2444
2439
  }
2445
2440
  /**
2446
2441
  * Returns the number of samples in this array.
@@ -2456,7 +2451,7 @@ class C {
2456
2451
  let e = 0;
2457
2452
  const t = [0];
2458
2453
  return this.data.forEach((n, i) => {
2459
- n === ce && (e++, t.push(i + 1));
2454
+ n === oe && (e++, t.push(i + 1));
2460
2455
  }), this._cachedIndexes = t, this.cachedLength = e, e;
2461
2456
  }
2462
2457
  /**
@@ -2472,7 +2467,7 @@ class C {
2472
2467
  if (this.dataType.equals(e)) return this;
2473
2468
  const n = new e.Array(this.length);
2474
2469
  for (let i = 0; i < this.length; i++)
2475
- n[i] = Zt(this.dataType, e, this.data[i], t);
2470
+ n[i] = jt(this.dataType, e, this.data[i], t);
2476
2471
  return new C({
2477
2472
  data: n.buffer,
2478
2473
  dataType: e,
@@ -2484,7 +2479,7 @@ class C {
2484
2479
  }
2485
2480
  calcRawMax() {
2486
2481
  if (this.length === 0) return -1 / 0;
2487
- if (this.dataType.equals(T.TIMESTAMP))
2482
+ if (this.dataType.equals(a.TIMESTAMP))
2488
2483
  this.cachedMax = this.data[this.data.length - 1];
2489
2484
  else if (this.dataType.usesBigInt) {
2490
2485
  const e = this.data;
@@ -2502,11 +2497,11 @@ class C {
2502
2497
  calcMax() {
2503
2498
  if (this.dataType.isVariable)
2504
2499
  throw new Error("cannot calculate maximum on a variable length data type");
2505
- return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), X(this.cachedMax, this.sampleOffset));
2500
+ return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), $(this.cachedMax, this.sampleOffset));
2506
2501
  }
2507
2502
  calcRawMin() {
2508
2503
  if (this.length === 0) return 1 / 0;
2509
- if (this.dataType.equals(T.TIMESTAMP)) this.cachedMin = this.data[0];
2504
+ if (this.dataType.equals(a.TIMESTAMP)) this.cachedMin = this.data[0];
2510
2505
  else if (this.dataType.usesBigInt) {
2511
2506
  const e = this.data;
2512
2507
  this.cachedMin = e.reduce((t, n) => t < n ? t : n);
@@ -2523,11 +2518,11 @@ class C {
2523
2518
  calcMin() {
2524
2519
  if (this.dataType.isVariable)
2525
2520
  throw new Error("cannot calculate minimum on a variable length data type");
2526
- return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), X(this.cachedMin, this.sampleOffset));
2521
+ return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), $(this.cachedMin, this.sampleOffset));
2527
2522
  }
2528
2523
  /** @returns the bounds of the series. */
2529
2524
  get bounds() {
2530
- return L(Number(this.min), Number(this.max), { makeValid: !1 });
2525
+ return k(Number(this.min), Number(this.max), { makeValid: !1 });
2531
2526
  }
2532
2527
  maybeRecomputeMinMax(e) {
2533
2528
  if (this.cachedMin != null) {
@@ -2549,18 +2544,18 @@ class C {
2549
2544
  }
2550
2545
  at(e, t = !1) {
2551
2546
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
2552
- if (this.dataType.equals(T.UUID)) return this.atUUID(e, t);
2547
+ if (this.dataType.equals(a.UUID)) return this.atUUID(e, t);
2553
2548
  e < 0 && (e = this.length + e);
2554
2549
  const n = this.data[e];
2555
2550
  if (n == null) {
2556
2551
  if (t === !0) throw new Error(`[series] - no value at index ${e}`);
2557
2552
  return;
2558
2553
  }
2559
- return X(n, this.sampleOffset);
2554
+ return $(n, this.sampleOffset);
2560
2555
  }
2561
2556
  atUUID(e, t) {
2562
2557
  e < 0 && (e = this.length + e);
2563
- const n = qe(
2558
+ const n = Ye(
2564
2559
  new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
2565
2560
  );
2566
2561
  if (n == null) {
@@ -2576,7 +2571,7 @@ class C {
2576
2571
  else {
2577
2572
  e < 0 && (e = this.length + e);
2578
2573
  for (let c = 0; c < this.data.length; c++)
2579
- if (this.data[c] === ce) {
2574
+ if (this.data[c] === oe) {
2580
2575
  if (e === 0) {
2581
2576
  i = c;
2582
2577
  break;
@@ -2588,8 +2583,8 @@ class C {
2588
2583
  return;
2589
2584
  }
2590
2585
  }
2591
- const a = this.data.slice(n, i);
2592
- return this.dataType.equals(T.STRING) ? new TextDecoder().decode(a) : Ue(JSON.parse(new TextDecoder().decode(a)));
2586
+ const o = this.data.slice(n, i);
2587
+ return this.dataType.equals(a.STRING) ? new TextDecoder().decode(o) : Ee(JSON.parse(new TextDecoder().decode(o)));
2593
2588
  }
2594
2589
  /**
2595
2590
  * @returns the index of the first sample that is greater than or equal to the given value.
@@ -2598,11 +2593,11 @@ class C {
2598
2593
  */
2599
2594
  binarySearch(e) {
2600
2595
  let t = 0, n = this.length - 1;
2601
- const i = at(e);
2596
+ const i = st(e);
2602
2597
  for (; t <= n; ) {
2603
- const a = Math.floor((t + n) / 2), c = i(this.at(a, !0), e);
2604
- if (c === 0) return a;
2605
- c < 0 ? t = a + 1 : n = a - 1;
2598
+ const o = Math.floor((t + n) / 2), c = i(this.at(o, !0), e);
2599
+ if (c === 0) return o;
2600
+ c < 0 ? t = o + 1 : n = o - 1;
2606
2601
  }
2607
2602
  return t;
2608
2603
  }
@@ -2614,14 +2609,14 @@ class C {
2614
2609
  * be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
2615
2610
  */
2616
2611
  updateGLBuffer(e) {
2617
- if (this.gl.control = e, !this.dataType.equals(T.FLOAT32) && !this.dataType.equals(T.UINT8))
2612
+ if (this.gl.control = e, !this.dataType.equals(a.FLOAT32) && !this.dataType.equals(a.UINT8))
2618
2613
  throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2619
2614
  const { buffer: t, bufferUsage: n, prevBuffer: i } = this.gl;
2620
2615
  if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
2621
2616
  if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
2622
2617
  i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
2623
- const a = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
2624
- e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
2618
+ const o = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
2619
+ e.bufferSubData(e.ARRAY_BUFFER, o, c.buffer), this.gl.prevBuffer = this.writePos;
2625
2620
  } else
2626
2621
  e.bufferData(
2627
2622
  e.ARRAY_BUFFER,
@@ -2630,7 +2625,7 @@ class C {
2630
2625
  ), this.gl.prevBuffer = B;
2631
2626
  }
2632
2627
  as(e) {
2633
- return Xt(e, this.dataType), this;
2628
+ return Gt(e, this.dataType), this;
2634
2629
  }
2635
2630
  /** @returns a digest containing information about the series. */
2636
2631
  get digest() {
@@ -2639,8 +2634,8 @@ class C {
2639
2634
  dataType: this.dataType.toString(),
2640
2635
  sampleOffset: this.sampleOffset,
2641
2636
  alignment: {
2642
- lower: xe(this.alignmentBounds.lower),
2643
- upper: xe(this.alignmentBounds.upper),
2637
+ lower: Ie(this.alignmentBounds.lower),
2638
+ upper: Ie(this.alignmentBounds.upper),
2644
2639
  multiple: this.alignmentMultiple
2645
2640
  },
2646
2641
  timeRange: this.timeRange.toString(),
@@ -2658,7 +2653,7 @@ class C {
2658
2653
  * is exclusive.
2659
2654
  */
2660
2655
  get alignmentBounds() {
2661
- return L(
2656
+ return k(
2662
2657
  this.alignment,
2663
2658
  this.alignment + BigInt(this.length) * this.alignmentMultiple
2664
2659
  );
@@ -2678,10 +2673,10 @@ class C {
2678
2673
  }
2679
2674
  [Symbol.iterator]() {
2680
2675
  if (this.dataType.isVariable) {
2681
- const e = new er(this);
2682
- return this.dataType.equals(T.JSON) ? new tr(e) : e;
2676
+ const e = new Jt(this);
2677
+ return this.dataType.equals(a.JSON) ? new fe(e) : e;
2683
2678
  }
2684
- return this.dataType.equals(T.UUID) ? new rr(this) : new nr(this);
2679
+ return this.dataType.equals(a.UUID) ? new Kt(this) : new Xt(this);
2685
2680
  }
2686
2681
  /**
2687
2682
  * Returns a slice of the series from start to end.
@@ -2708,7 +2703,7 @@ class C {
2708
2703
  * @returns An iterator over the specified range.
2709
2704
  */
2710
2705
  subIterator(e, t) {
2711
- return new Ee(this, e, t ?? this.length);
2706
+ return new Se(this, e, t ?? this.length);
2712
2707
  }
2713
2708
  /**
2714
2709
  * Returns an iterator over a portion of the series based on alignment.
@@ -2722,7 +2717,7 @@ class C {
2722
2717
  ), i = Math.ceil(
2723
2718
  Number(t - this.alignment) / Number(this.alignmentMultiple)
2724
2719
  );
2725
- return new Ee(this, n, i);
2720
+ return new Se(this, n, i);
2726
2721
  }
2727
2722
  subBytes(e, t) {
2728
2723
  if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
@@ -2757,7 +2752,7 @@ class C {
2757
2752
  return new C({
2758
2753
  data: this.buffer,
2759
2754
  dataType: this.dataType,
2760
- timeRange: E.ZERO,
2755
+ timeRange: I.ZERO,
2761
2756
  sampleOffset: this.sampleOffset,
2762
2757
  glBufferUsage: "static",
2763
2758
  alignment: e
@@ -2781,21 +2776,21 @@ class C {
2781
2776
  return e += "])", e;
2782
2777
  }
2783
2778
  }
2784
- const Qt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof C ? !0 : Ye(r), _t = Yt(Fe, C);
2785
- class Ee {
2779
+ const Vt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof C ? !0 : je(r), Ht = ht(qe, C);
2780
+ class Se {
2786
2781
  series;
2787
2782
  end;
2788
2783
  index;
2789
2784
  constructor(e, t, n) {
2790
2785
  this.series = e;
2791
- const i = L(0, e.length + 1);
2792
- this.end = Te(i, n), this.index = Te(i, t);
2786
+ const i = k(0, e.length + 1);
2787
+ this.end = be(i, n), this.index = be(i, t);
2793
2788
  }
2794
2789
  next() {
2795
2790
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
2796
2791
  }
2797
2792
  }
2798
- let er = class {
2793
+ class Jt {
2799
2794
  series;
2800
2795
  index;
2801
2796
  decoder;
@@ -2808,11 +2803,12 @@ let er = class {
2808
2803
  }
2809
2804
  next() {
2810
2805
  const e = this.index, t = this.series.data;
2811
- for (; this.index < t.length && t[this.index] !== ce; ) this.index++;
2806
+ for (; this.index < t.length && t[this.index] !== oe; ) this.index++;
2812
2807
  const n = this.index;
2813
2808
  return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
2814
2809
  }
2815
- }, tr = class We {
2810
+ }
2811
+ class fe {
2816
2812
  wrapped;
2817
2813
  static schema = s.record(s.string(), s.unknown());
2818
2814
  constructor(e) {
@@ -2822,27 +2818,27 @@ let er = class {
2822
2818
  const e = this.wrapped.next();
2823
2819
  return e.done === !0 ? { done: !0, value: void 0 } : {
2824
2820
  done: !1,
2825
- value: ue.decodeString(e.value, We.schema)
2821
+ value: ie.decodeString(e.value, fe.schema)
2826
2822
  };
2827
2823
  }
2828
- };
2829
- class rr {
2824
+ }
2825
+ class Kt {
2830
2826
  series;
2831
2827
  index;
2832
2828
  data;
2833
2829
  density;
2834
2830
  constructor(e) {
2835
- if (!e.dataType.equals(T.UUID))
2831
+ if (!e.dataType.equals(a.UUID))
2836
2832
  throw new Error("cannot create a UUID series iterator for a non-UUID series");
2837
- this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = T.UUID.density.valueOf();
2833
+ this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = a.UUID.density.valueOf();
2838
2834
  }
2839
2835
  next() {
2840
2836
  if (this.index >= this.series.length) return { done: !0, value: void 0 };
2841
- const e = qe(this.data, this.index * this.density);
2837
+ const e = Ye(this.data, this.index * this.density);
2842
2838
  return this.index++, { done: !1, value: e };
2843
2839
  }
2844
2840
  }
2845
- let nr = class {
2841
+ class Xt {
2846
2842
  series;
2847
2843
  index;
2848
2844
  constructor(e) {
@@ -2854,77 +2850,14 @@ let nr = class {
2854
2850
  value: this.series.at(this.index++, !0)
2855
2851
  };
2856
2852
  }
2857
- };
2858
- const xe = (r) => {
2853
+ }
2854
+ const Ie = (r) => {
2859
2855
  const e = r >> 32n, t = r & 0xffffffffn;
2860
2856
  return { domain: e, sample: t };
2861
- };
2862
- s.object({ key: s.string(), value: s.string() });
2863
- s.record(
2864
- s.union([s.number(), s.string(), s.symbol()]),
2865
- s.unknown()
2866
- );
2867
- const sr = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2868
- sr();
2869
- const ir = ["macOS", "Windows", "Linux"], ar = ["macos", "windows", "linux"], or = {
2870
- macos: "macOS",
2871
- windows: "Windows",
2872
- linux: "Linux"
2873
- };
2874
- s.enum(ir).or(
2875
- s.enum(ar).transform((r) => or[r])
2876
- );
2877
- const ur = (...r) => r.map(Ze).join(""), Ze = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), lr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, cr = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
2878
- class z {
2879
- protocol;
2880
- host;
2881
- port;
2882
- path;
2883
- /**
2884
- * @param host - The hostname or IP address of the server.
2885
- * @param port - The port number of the server.
2886
- * @param protocol - The protocol to use for all requests. Defaults to "".
2887
- * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
2888
- */
2889
- constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
2890
- this.protocol = n, this.host = e, this.port = t, this.path = Ze(i);
2891
- }
2892
- /**
2893
- * Replaces creates a new URL with the specified properties replaced.
2894
- * @param props - The properties to replace.
2895
- * @returns a new URL.
2896
- */
2897
- replace(e) {
2898
- return new z({
2899
- host: e.host ?? this.host,
2900
- port: e.port ?? this.port,
2901
- protocol: e.protocol ?? this.protocol,
2902
- pathPrefix: e.pathPrefix ?? this.path
2903
- });
2904
- }
2905
- /**
2906
- * Creates a new url with the given path appended to the current path.
2907
- * @param path - the path to append to the URL.
2908
- * @returns a new URL.
2909
- */
2910
- child(e) {
2911
- return new z({
2912
- ...this,
2913
- pathPrefix: ur(this.path, e)
2914
- });
2915
- }
2916
- /** @returns a string representation of the url */
2917
- toString() {
2918
- return lr(
2919
- `${this.protocol}://${this.host}:${this.port}/${this.path}`
2920
- );
2921
- }
2922
- static UNKNOWN = new z({ host: "unknown", port: 0 });
2923
- }
2924
- const hr = async (r) => await new Promise(
2857
+ }, Qt = async (r) => await new Promise(
2925
2858
  (e) => setTimeout(e, l.fromMilliseconds(r).milliseconds)
2926
2859
  );
2927
- class fr {
2860
+ class _t {
2928
2861
  config;
2929
2862
  retries;
2930
2863
  interval;
@@ -2933,7 +2866,7 @@ class fr {
2933
2866
  baseInterval: new l(e?.baseInterval ?? l.seconds(1)),
2934
2867
  maxRetries: e?.maxRetries ?? 5,
2935
2868
  scale: e?.scale ?? 1,
2936
- sleepFn: e?.sleepFn ?? hr
2869
+ sleepFn: e?.sleepFn ?? Qt
2937
2870
  }, this.retries = 0, this.interval = new l(this.config.baseInterval);
2938
2871
  }
2939
2872
  async wait() {
@@ -2947,165 +2880,178 @@ class fr {
2947
2880
  this.retries = 0, this.interval = this.config.baseInterval;
2948
2881
  }
2949
2882
  }
2950
- const dr = s.object({
2883
+ const er = s.object({
2951
2884
  baseInterval: l.z.optional(),
2952
2885
  maxRetries: s.number().optional(),
2953
2886
  scale: s.number().optional()
2954
- }), gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2887
+ }), tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2955
2888
  __proto__: null,
2956
- Breaker: fr,
2957
- breakerConfigZ: dr
2958
- }, Symbol.toStringTag, { value: "Module" })), pr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, ze = s.string().regex(pr), j = s.number().min(0).max(255), Ge = s.number().min(0).max(1), Ve = s.tuple([j, j, j, Ge]), mr = s.tuple([j, j, j]), yr = s.object({ rgba255: Ve }), wr = s.number().min(0).max(360), br = s.number().min(0).max(100), Or = s.number().min(0).max(100), Tr = s.tuple([wr, br, Or, Ge]), pe = s.union([ze, mr, Ve, Tr, yr]), vr = pe.transform((r) => me(r)), me = (r, e = 1) => {
2959
- if (r = pe.parse(r), typeof r == "string") return Ir(r, e);
2889
+ Breaker: _t,
2890
+ breakerConfigZ: er
2891
+ }, Symbol.toStringTag, { value: "Module" })), rr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Fe = s.string().regex(rr), j = s.number().min(0).max(255), Ze = s.number().min(0).max(1), We = s.tuple([j, j, j, Ze]), nr = s.tuple([j, j, j]), sr = s.object({ rgba255: We }), ir = s.number().min(0).max(360), ar = s.number().min(0).max(100), or = s.number().min(0).max(100), ur = s.tuple([ir, ar, or, Ze]), de = s.union([Fe, nr, We, ur, sr]), lr = de.transform((r) => ge(r)), ge = (r, e = 1) => {
2892
+ if (r = de.parse(r), typeof r == "string") return cr(r, e);
2960
2893
  if (Array.isArray(r)) {
2961
2894
  if (r.length < 3 || r.length > 4)
2962
2895
  throw new Error(`Invalid color: [${r.join(", ")}]`);
2963
2896
  return r.length === 3 ? [...r, e] : r;
2964
2897
  }
2965
2898
  return r.rgba255;
2966
- }, Ir = (r, e = 1) => (r = ze.parse(r), r = Sr(r), [
2967
- K(r, 0),
2968
- K(r, 2),
2969
- K(r, 4),
2970
- r.length === 8 ? K(r, 6) / 255 : e
2971
- ]), K = (r, e) => parseInt(r.slice(e, e + 2), 16), Sr = (r) => r.startsWith("#") ? r.slice(1) : r;
2972
- me("#000000");
2973
- me("#ffffff");
2974
- const Nr = s.object({
2899
+ }, cr = (r, e = 1) => (r = Fe.parse(r), r = hr(r), [
2900
+ Q(r, 0),
2901
+ Q(r, 2),
2902
+ Q(r, 4),
2903
+ r.length === 8 ? Q(r, 6) / 255 : e
2904
+ ]), Q = (r, e) => parseInt(r.slice(e, e + 2), 16), hr = (r) => r.startsWith("#") ? r.slice(1) : r;
2905
+ ge("#000000");
2906
+ ge("#ffffff");
2907
+ const fr = s.object({
2975
2908
  key: s.string(),
2976
- color: pe,
2909
+ color: de,
2977
2910
  position: s.number(),
2978
2911
  switched: s.boolean().optional()
2979
2912
  });
2980
- s.array(Nr);
2981
- const Er = s.object({
2913
+ s.array(fr);
2914
+ const dr = s.object({
2982
2915
  key: s.string(),
2983
2916
  name: s.string(),
2984
- color: vr
2917
+ color: lr
2985
2918
  });
2986
2919
  s.object({
2987
2920
  key: s.string(),
2988
2921
  name: s.string(),
2989
- swatches: s.array(Er)
2922
+ swatches: s.array(dr)
2990
2923
  });
2991
2924
  s.int().min(0).max(255);
2992
2925
  s.object({
2993
2926
  name: s.string(),
2994
2927
  key: s.string()
2995
2928
  });
2996
- const xr = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), Ar = (r, e) => {
2929
+ const gr = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), mr = (r, e) => {
2997
2930
  const t = Symbol.for(r);
2998
- if (!xr(t)) {
2931
+ if (!gr(t)) {
2999
2932
  const n = e();
3000
2933
  Object.defineProperty(globalThis, t, { value: n });
3001
2934
  }
3002
2935
  return () => globalThis[t];
3003
- }, He = "sy_x_error", Ur = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), G = (r) => class Z extends Error {
3004
- static discriminator = He;
3005
- discriminator = Z.discriminator;
2936
+ }, ze = "sy_x_error", yr = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), H = (r) => class W extends Error {
2937
+ static discriminator = ze;
2938
+ discriminator = W.discriminator;
3006
2939
  static TYPE = r;
3007
- type = Z.TYPE;
3008
- static matches = Ur(r);
3009
- matches = Z.matches;
2940
+ type = W.TYPE;
2941
+ static matches = yr(r);
2942
+ matches = W.matches;
3010
2943
  constructor(t, n) {
3011
- super(t, n), this.name = Z.TYPE;
2944
+ super(t, n), this.name = W.TYPE;
3012
2945
  }
3013
2946
  static sub(t) {
3014
- return G(`${r}.${t}`);
2947
+ return H(`${r}.${t}`);
3015
2948
  }
3016
- }, Je = (r) => {
2949
+ }, Ge = (r) => {
3017
2950
  if (r == null || typeof r != "object") return !1;
3018
2951
  const e = r;
3019
- if (e.discriminator !== He) return !1;
2952
+ if (e.discriminator !== ze) return !1;
3020
2953
  if (!("type" in e))
3021
2954
  throw new Error(
3022
2955
  `X Error is missing its type property: ${JSON.stringify(e)}`
3023
2956
  );
3024
2957
  return !0;
3025
- }, k = "unknown", he = "nil";
3026
- class Mr {
2958
+ }, P = "unknown", ue = "nil";
2959
+ class pr {
3027
2960
  providers = [];
3028
2961
  register(e) {
3029
2962
  this.providers.push(e);
3030
2963
  }
3031
2964
  encode(e) {
3032
- if (e == null) return { type: he, data: "" };
3033
- if (Je(e))
2965
+ if (e == null) return { type: ue, data: "" };
2966
+ if (Ge(e))
3034
2967
  for (const t of this.providers) {
3035
2968
  const n = t.encode(e);
3036
2969
  if (n != null) return n;
3037
2970
  }
3038
- if (e instanceof Error) return { type: k, data: e.message };
3039
- if (typeof e == "string") return { type: k, data: e };
2971
+ if (e instanceof Error) return { type: P, data: e.message };
2972
+ if (typeof e == "string") return { type: P, data: e };
3040
2973
  try {
3041
- return { type: k, data: JSON.stringify(e) };
2974
+ return { type: P, data: JSON.stringify(e) };
3042
2975
  } catch {
3043
- return { type: k, data: "unable to encode error information" };
2976
+ return { type: P, data: "unable to encode error information" };
3044
2977
  }
3045
2978
  }
3046
2979
  decode(e) {
3047
- if (e == null || e.type === he) return null;
3048
- if (e.type === k) return new fe(e.data);
2980
+ if (e == null || e.type === ue) return null;
2981
+ if (e.type === P) return new le(e.data);
3049
2982
  for (const t of this.providers) {
3050
2983
  const n = t.decode(e);
3051
2984
  if (n != null) return n;
3052
2985
  }
3053
- return new fe(e.data);
2986
+ return new le(e.data);
3054
2987
  }
3055
2988
  }
3056
- const ye = Ar("synnax-error-registry", () => new Mr()), $r = ({ encode: r, decode: e }) => ye().register({ encode: r, decode: e }), Cr = (r) => ye().encode(r), Br = (r) => r == null ? null : ye().decode(r);
3057
- class fe extends G("unknown") {
2989
+ const me = mr("synnax-error-registry", () => new pr()), wr = ({ encode: r, decode: e }) => me().register({ encode: r, decode: e }), br = (r) => me().encode(r), Or = (r) => r == null ? null : me().decode(r);
2990
+ class le extends H("unknown") {
3058
2991
  }
3059
- const Rr = s.object({ type: s.string(), data: s.string() });
3060
- class Dr extends G("canceled") {
2992
+ const Tr = s.object({ type: s.string(), data: s.string() });
2993
+ class vr extends H("canceled") {
3061
2994
  }
3062
- class Lr extends G("not_implemented") {
2995
+ class Sr extends H("not_implemented") {
3063
2996
  }
3064
- const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2997
+ const D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3065
2998
  __proto__: null,
3066
- Canceled: Dr,
3067
- NONE: he,
3068
- NotImplemented: Lr,
3069
- UNKNOWN: k,
3070
- Unknown: fe,
3071
- createTyped: G,
3072
- decode: Br,
3073
- encode: Cr,
3074
- isTyped: Je,
3075
- payloadZ: Rr,
3076
- register: $r
3077
- }, Symbol.toStringTag, { value: "Module" })), Pr = O.object({
3078
- jsonrpc: O.literal("2.0"),
3079
- method: O.string(),
2999
+ Canceled: vr,
3000
+ NONE: ue,
3001
+ NotImplemented: Sr,
3002
+ UNKNOWN: P,
3003
+ Unknown: le,
3004
+ createTyped: H,
3005
+ decode: Or,
3006
+ encode: br,
3007
+ isTyped: Ge,
3008
+ payloadZ: Tr,
3009
+ register: wr
3010
+ }, Symbol.toStringTag, { value: "Module" })), Ir = b.object({
3011
+ jsonrpc: b.literal("2.0"),
3012
+ method: b.string(),
3080
3013
  // params should be z.union([z.record(z.string(), z.json()),
3081
3014
  // z.array(z.json())]).optional() but the VSCode JSON RPC implementation uses a looser
3082
3015
  // definition of params then in the JSON-RPC spec.
3083
- params: O.any().optional(),
3084
- id: O.union([O.string(), O.number(), O.null()]).optional()
3085
- }), Ke = O.object({
3086
- jsonrpc: O.literal("2.0"),
3087
- id: O.union([O.string(), O.number(), O.null()])
3088
- }), kr = Ke.extend({
3089
- result: O.json()
3090
- }), jr = Ke.extend({
3091
- error: O.object({
3092
- code: O.number().int(),
3016
+ params: b.any().optional(),
3017
+ id: b.union([b.string(), b.number(), b.null()]).optional()
3018
+ }), Ve = b.object({
3019
+ jsonrpc: b.literal("2.0"),
3020
+ id: b.union([b.string(), b.number(), b.null()])
3021
+ }), Nr = Ve.extend({
3022
+ result: b.json()
3023
+ }), Er = Ve.extend({
3024
+ error: b.object({
3025
+ code: b.number().int(),
3093
3026
  // This should be z.string(), but the VSCode JSON RPC implementation uses a looser
3094
3027
  // definition of error than the JSON-RPC spec.
3095
- message: O.string().optional(),
3096
- data: O.json().optional()
3028
+ message: b.string().optional(),
3029
+ data: b.json().optional()
3097
3030
  })
3098
- }), Yr = O.union([kr, jr]);
3099
- O.union([Pr, Yr]);
3100
- const qr = O.uuid();
3101
- O.object({
3102
- key: qr,
3103
- name: O.string().min(1),
3104
- color: O.string()
3031
+ }), Ar = b.union([Nr, Er]);
3032
+ b.union([Ir, Ar]);
3033
+ s.object({ key: s.string(), value: s.string() });
3034
+ const xr = b.uuid();
3035
+ b.object({
3036
+ key: xr,
3037
+ name: b.string().min(1),
3038
+ color: b.string()
3105
3039
  });
3106
3040
  s.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);
3107
- const Fr = ["standard", "scientific", "engineering"];
3108
- s.enum(Fr);
3041
+ const Ur = ["standard", "scientific", "engineering"];
3042
+ s.enum(Ur);
3043
+ const Mr = s.union([s.string(), s.number()]);
3044
+ s.record(Mr, s.unknown());
3045
+ const Cr = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
3046
+ Cr();
3047
+ const Br = ["macOS", "Windows", "Linux"], Rr = ["macos", "windows", "linux"], Dr = {
3048
+ macos: "macOS",
3049
+ windows: "Windows",
3050
+ linux: "Linux"
3051
+ };
3052
+ s.enum(Br).or(
3053
+ s.enum(Rr).transform((r) => Dr[r])
3054
+ );
3109
3055
  s.enum([
3110
3056
  "success",
3111
3057
  "info",
@@ -3118,35 +3064,83 @@ s.object({
3118
3064
  stack: s.string(),
3119
3065
  error: s.instanceof(Error)
3120
3066
  });
3121
- class V extends R.createTyped("freighter") {
3067
+ const Lr = (...r) => r.map(He).join(""), He = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), $r = (r) => r.endsWith("/") ? r.slice(0, -1) : r, kr = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
3068
+ class z {
3069
+ protocol;
3070
+ host;
3071
+ port;
3072
+ path;
3073
+ /**
3074
+ * @param host - The hostname or IP address of the server.
3075
+ * @param port - The port number of the server.
3076
+ * @param protocol - The protocol to use for all requests. Defaults to "".
3077
+ * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
3078
+ */
3079
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
3080
+ this.protocol = n, this.host = e, this.port = t, this.path = He(i);
3081
+ }
3082
+ /**
3083
+ * Replaces creates a new URL with the specified properties replaced.
3084
+ * @param props - The properties to replace.
3085
+ * @returns a new URL.
3086
+ */
3087
+ replace(e) {
3088
+ return new z({
3089
+ host: e.host ?? this.host,
3090
+ port: e.port ?? this.port,
3091
+ protocol: e.protocol ?? this.protocol,
3092
+ pathPrefix: e.pathPrefix ?? this.path
3093
+ });
3094
+ }
3095
+ /**
3096
+ * Creates a new url with the given path appended to the current path.
3097
+ * @param path - the path to append to the URL.
3098
+ * @returns a new URL.
3099
+ */
3100
+ child(e) {
3101
+ return new z({
3102
+ ...this,
3103
+ pathPrefix: Lr(this.path, e)
3104
+ });
3105
+ }
3106
+ /** @returns a string representation of the url */
3107
+ toString() {
3108
+ return $r(
3109
+ `${this.protocol}://${this.host}:${this.port}/${this.path}`
3110
+ );
3111
+ }
3112
+ static UNKNOWN = new z({ host: "unknown", port: 0 });
3113
+ }
3114
+ s.int().min(0).max(ft);
3115
+ class J extends D.createTyped("freighter") {
3122
3116
  }
3123
- class Y extends V.sub("eof") {
3117
+ class Y extends J.sub("eof") {
3124
3118
  constructor() {
3125
3119
  super("EOF");
3126
3120
  }
3127
3121
  }
3128
- class q extends V.sub("stream_closed") {
3122
+ class q extends J.sub("stream_closed") {
3129
3123
  constructor() {
3130
3124
  super("StreamClosed");
3131
3125
  }
3132
3126
  }
3133
- class F extends V.sub("unreachable") {
3127
+ class F extends J.sub("unreachable") {
3134
3128
  url;
3135
3129
  constructor(e = {}) {
3136
3130
  const { message: t = "Unreachable", url: n = z.UNKNOWN } = e;
3137
3131
  super(t), this.url = n;
3138
3132
  }
3139
3133
  }
3140
- const Wr = (r) => {
3141
- if (!r.type.startsWith(V.TYPE)) return null;
3134
+ const Pr = (r) => {
3135
+ if (!r.type.startsWith(J.TYPE)) return null;
3142
3136
  if (Y.matches(r)) return { type: Y.TYPE, data: "EOF" };
3143
3137
  if (q.matches(r))
3144
3138
  return { type: q.TYPE, data: "StreamClosed" };
3145
3139
  if (F.matches(r))
3146
3140
  return { type: F.TYPE, data: "Unreachable" };
3147
3141
  throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
3148
- }, Zr = (r) => {
3149
- if (!r.type.startsWith(V.TYPE)) return null;
3142
+ }, jr = (r) => {
3143
+ if (!r.type.startsWith(J.TYPE)) return null;
3150
3144
  switch (r.type) {
3151
3145
  case Y.TYPE:
3152
3146
  return new Y();
@@ -3155,14 +3149,14 @@ const Wr = (r) => {
3155
3149
  case F.TYPE:
3156
3150
  return new F();
3157
3151
  default:
3158
- throw new R.Unknown(`Unknown error type: ${r.data}`);
3152
+ throw new D.Unknown(`Unknown error type: ${r.data}`);
3159
3153
  }
3160
3154
  };
3161
- R.register({
3162
- encode: Wr,
3163
- decode: Zr
3155
+ D.register({
3156
+ encode: Pr,
3157
+ decode: jr
3164
3158
  });
3165
- class Xe {
3159
+ class Je {
3166
3160
  middleware = [];
3167
3161
  /** Implements the Transport interface */
3168
3162
  use(...e) {
@@ -3179,47 +3173,47 @@ class Xe {
3179
3173
  */
3180
3174
  async executeMiddleware(e, t) {
3181
3175
  let n = 0;
3182
- const i = async (a) => {
3183
- if (n === this.middleware.length) return await t(a);
3176
+ const i = async (o) => {
3177
+ if (n === this.middleware.length) return await t(o);
3184
3178
  const c = this.middleware[n];
3185
- return n++, await c(a, i);
3179
+ return n++, await c(o, i);
3186
3180
  };
3187
3181
  return await i(e);
3188
3182
  }
3189
3183
  }
3190
- const Qe = "Content-Type", zr = /* @__PURE__ */ new Set([
3184
+ const Ke = "Content-Type", Yr = /* @__PURE__ */ new Set([
3191
3185
  "ECONNREFUSED",
3192
3186
  "ECONNRESET",
3193
3187
  "ETIMEDOUT",
3194
3188
  "EPIPE",
3195
3189
  "UND_ERR_CONNECT_TIMEOUT",
3196
3190
  "UND_ERR_SOCKET"
3197
- ]), Gr = (r) => {
3191
+ ]), qr = (r) => {
3198
3192
  const e = r?.cause?.code ?? r?.code ?? r?.errno;
3199
- if (typeof e == "string" && zr.has(e)) return !0;
3193
+ if (typeof e == "string" && Yr.has(e)) return !0;
3200
3194
  if (r.name === "TypeError") {
3201
3195
  const t = String(r.message || "").toLowerCase();
3202
3196
  if (/load failed|failed to fetch|networkerror|network error/.test(t))
3203
3197
  return typeof navigator < "u" && navigator.onLine === !1, !0;
3204
3198
  }
3205
3199
  return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
3206
- }, Vr = 400;
3207
- class sn extends Xe {
3200
+ }, Fr = 400;
3201
+ class Hr extends Je {
3208
3202
  endpoint;
3209
3203
  encoder;
3210
3204
  constructor(e, t, n = !1) {
3211
3205
  return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, {
3212
- get: (i, a, c) => a === "endpoint" ? this.endpoint : Reflect.get(i, a, c)
3206
+ get: (i, o, c) => o === "endpoint" ? this.endpoint : Reflect.get(i, o, c)
3213
3207
  });
3214
3208
  }
3215
3209
  get headers() {
3216
3210
  return {
3217
- [Qe]: this.encoder.contentType
3211
+ [Ke]: this.encoder.contentType
3218
3212
  };
3219
3213
  }
3220
3214
  async send(e, t, n, i) {
3221
3215
  t = n?.parse(t);
3222
- let a = null;
3216
+ let o = null;
3223
3217
  const c = this.endpoint.child(e), d = {};
3224
3218
  d.method = "POST", d.body = this.encoder.encode(t ?? {});
3225
3219
  const [, w] = await this.executeMiddleware(
@@ -3235,37 +3229,37 @@ class sn extends Xe {
3235
3229
  ...this.headers,
3236
3230
  ...h.params
3237
3231
  };
3238
- let b;
3232
+ let O;
3239
3233
  try {
3240
- b = await fetch(h.target, d);
3241
- } catch (v) {
3242
- if (!(v instanceof Error)) throw v;
3243
- return [g, Gr(v) ? new F({ url: c }) : v];
3234
+ O = await fetch(h.target, d);
3235
+ } catch (T) {
3236
+ if (!(T instanceof Error)) throw T;
3237
+ return [g, qr(T) ? new F({ url: c }) : T];
3244
3238
  }
3245
- const f = await b.arrayBuffer();
3246
- if (b?.ok)
3247
- return i != null && (a = this.encoder.decode(f, i)), [g, null];
3239
+ const f = await O.arrayBuffer();
3240
+ if (O?.ok)
3241
+ return i != null && (o = this.encoder.decode(f, i)), [g, null];
3248
3242
  try {
3249
- if (b.status !== Vr)
3250
- return [g, new Error(b.statusText)];
3251
- const v = this.encoder.decode(f, R.payloadZ), x = R.decode(v);
3252
- return [g, x];
3253
- } catch (v) {
3243
+ if (O.status !== Fr)
3244
+ return [g, new Error(O.statusText)];
3245
+ const T = this.encoder.decode(f, D.payloadZ), E = D.decode(T);
3246
+ return [g, E];
3247
+ } catch (T) {
3254
3248
  return [
3255
3249
  g,
3256
3250
  new Error(
3257
- `[freighter] - failed to decode error: ${b.statusText}: ${v.message}`
3251
+ `[freighter] - failed to decode error: ${O.statusText}: ${T.message}`
3258
3252
  )
3259
3253
  ];
3260
3254
  }
3261
3255
  }
3262
3256
  );
3263
3257
  if (w != null) return [null, w];
3264
- if (a == null) throw new Error("Response must be defined");
3265
- return [a, null];
3258
+ if (o == null) throw new Error("Response must be defined");
3259
+ return [o, null];
3266
3260
  }
3267
3261
  }
3268
- const an = (r, e) => {
3262
+ const Jr = (r, e) => {
3269
3263
  class t {
3270
3264
  wrapped;
3271
3265
  constructor(i) {
@@ -3274,10 +3268,10 @@ const an = (r, e) => {
3274
3268
  use(...i) {
3275
3269
  this.wrapped.use(...i);
3276
3270
  }
3277
- async send(i, a, c, d) {
3278
- const w = new gr.Breaker(e);
3271
+ async send(i, o, c, d) {
3272
+ const w = new tr.Breaker(e);
3279
3273
  do {
3280
- const [h, g] = await this.wrapped.send(i, a, c, d);
3274
+ const [h, g] = await this.wrapped.send(i, o, c, d);
3281
3275
  if (g == null) return [h, null];
3282
3276
  if (!F.matches(g)) return [null, g];
3283
3277
  if (console.warn(`[freighter] ${w.retryMessage}`, g), !await w.wait()) return [h, g];
@@ -3285,16 +3279,16 @@ const an = (r, e) => {
3285
3279
  }
3286
3280
  }
3287
3281
  return new t(r);
3288
- }, on = async (r, e, t, n, i) => {
3289
- const [a, c] = await r.send(e, t, n, i);
3282
+ }, Kr = async (r, e, t, n, i) => {
3283
+ const [o, c] = await r.send(e, t, n, i);
3290
3284
  if (c != null) throw c;
3291
- return a;
3292
- }, Hr = s.object({
3285
+ return o;
3286
+ }, Zr = s.object({
3293
3287
  type: s.enum(["data", "close", "open"]),
3294
3288
  payload: s.unknown(),
3295
- error: s.optional(R.payloadZ)
3289
+ error: s.optional(D.payloadZ)
3296
3290
  });
3297
- class Jr {
3291
+ class Wr {
3298
3292
  codec;
3299
3293
  reqSchema;
3300
3294
  resSchema;
@@ -3310,7 +3304,7 @@ class Jr {
3310
3304
  const e = await this.receiveMsg();
3311
3305
  if (e.type !== "open") {
3312
3306
  if (e.error == null) throw new Error("Message error must be defined");
3313
- return R.decode(e.error);
3307
+ return D.decode(e.error);
3314
3308
  }
3315
3309
  return null;
3316
3310
  }
@@ -3326,7 +3320,7 @@ class Jr {
3326
3320
  const e = await this.receiveMsg();
3327
3321
  if (e.type === "close") {
3328
3322
  if (e.error == null) throw new Error("Message error must be defined");
3329
- if (this.serverClosed = R.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3323
+ if (this.serverClosed = D.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3330
3324
  return [null, this.serverClosed];
3331
3325
  }
3332
3326
  return [this.resSchema.parse(e.payload), null];
@@ -3359,20 +3353,20 @@ class Jr {
3359
3353
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
3360
3354
  }
3361
3355
  onMessage(e) {
3362
- this.addMessage(this.codec.decode(e.data, Hr));
3356
+ this.addMessage(this.codec.decode(e.data, Zr));
3363
3357
  }
3364
3358
  onClose(e) {
3365
3359
  this.addMessage({
3366
3360
  type: "close",
3367
3361
  error: {
3368
- type: e.code === Xr ? Y.TYPE : q.TYPE,
3362
+ type: e.code === Gr ? Y.TYPE : q.TYPE,
3369
3363
  data: ""
3370
3364
  }
3371
3365
  });
3372
3366
  }
3373
3367
  }
3374
- const Kr = "freighterctx", Xr = 1e3;
3375
- class de extends Xe {
3368
+ const zr = "freighterctx", Gr = 1e3;
3369
+ class ce extends Je {
3376
3370
  baseUrl;
3377
3371
  encoder;
3378
3372
  secure;
@@ -3386,43 +3380,43 @@ class de extends Xe {
3386
3380
  super(), this.secure = n, this.baseUrl = e.replace({ protocol: n ? "wss" : "ws" }), this.encoder = t;
3387
3381
  }
3388
3382
  withCodec(e) {
3389
- const t = new de(this.baseUrl, e, this.secure);
3383
+ const t = new ce(this.baseUrl, e, this.secure);
3390
3384
  return t.use(...this.middleware), t;
3391
3385
  }
3392
3386
  /** Implements the StreamClient interface. */
3393
3387
  async stream(e, t, n) {
3394
3388
  let i;
3395
- const [, a] = await this.executeMiddleware(
3389
+ const [, o] = await this.executeMiddleware(
3396
3390
  { target: e, protocol: "websocket", params: {}, role: "client" },
3397
3391
  async (c) => {
3398
3392
  const d = new WebSocket(this.buildURL(e, c)), w = { ...c, params: {} };
3399
- d.binaryType = de.MESSAGE_TYPE;
3393
+ d.binaryType = ce.MESSAGE_TYPE;
3400
3394
  const h = await this.wrapSocket(d, t, n);
3401
3395
  return h instanceof Error ? [w, h] : (i = h, [w, null]);
3402
3396
  }
3403
3397
  );
3404
- if (a != null) throw a;
3398
+ if (o != null) throw o;
3405
3399
  return i;
3406
3400
  }
3407
3401
  buildURL(e, t) {
3408
- const n = cr(
3402
+ const n = kr(
3409
3403
  {
3410
- [Qe]: this.encoder.contentType,
3404
+ [Ke]: this.encoder.contentType,
3411
3405
  ...t.params
3412
3406
  },
3413
- Kr
3407
+ zr
3414
3408
  );
3415
3409
  return this.baseUrl.child(e).toString() + n;
3416
3410
  }
3417
3411
  async wrapSocket(e, t, n) {
3418
3412
  return await new Promise((i) => {
3419
3413
  e.onopen = () => {
3420
- const a = new Jr(e, this.encoder, t, n);
3421
- a.receiveOpenAck().then((c) => {
3422
- c != null ? i(c) : i(a);
3414
+ const o = new Wr(e, this.encoder, t, n);
3415
+ o.receiveOpenAck().then((c) => {
3416
+ c != null ? i(c) : i(o);
3423
3417
  }).catch((c) => i(c));
3424
- }, e.onerror = (a) => {
3425
- const c = a;
3418
+ }, e.onerror = (o) => {
3419
+ const c = o;
3426
3420
  i(new Error(c.message));
3427
3421
  };
3428
3422
  });
@@ -3430,10 +3424,10 @@ class de extends Xe {
3430
3424
  }
3431
3425
  export {
3432
3426
  Y as EOF,
3433
- sn as HTTPClient,
3427
+ Hr as HTTPClient,
3434
3428
  q as StreamClosed,
3435
3429
  F as Unreachable,
3436
- de as WebSocketClient,
3437
- on as sendRequired,
3438
- an as unaryWithBreaker
3430
+ ce as WebSocketClient,
3431
+ Kr as sendRequired,
3432
+ Jr as unaryWithBreaker
3439
3433
  };