@synnaxlabs/freighter 0.44.0 → 0.44.2

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 w, { z as r } from "zod";
2
- const Fe = (n) => {
3
- const e = n.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
1
+ import O, { z as s } from "zod";
2
+ const Xe = (r) => {
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
- }, Te = (n) => {
6
- const e = (t, s = _) => {
7
- if (typeof t == "string") return n(t);
8
- if (Array.isArray(t)) return t.map((l) => e(l, s));
9
- if (!X(t)) return t;
10
- s = ze(s);
11
- const i = {}, o = t;
12
- return "toJSON" in o && typeof o.toJSON == "function" ? e(o.toJSON(), s) : (Object.keys(o).forEach((l) => {
13
- let d = o[l];
14
- const f = n(l);
15
- s.recursive && (X(d) ? he(d) || (d = e(d, s)) : s.recursiveInArray && le(d) && (d = [...d].map((g) => {
16
- let m = g;
17
- return X(g) ? he(m) || (m = e(g, s)) : le(g) && (m = e({ key: g }, s).key), m;
18
- }))), i[f] = d;
5
+ }, Se = (r) => {
6
+ const e = (t, n = ie) => {
7
+ if (typeof t == "string") return r(t);
8
+ if (Array.isArray(t)) return t.map((c) => e(c, n));
9
+ if (!re(t)) return t;
10
+ n = et(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];
14
+ const y = r(c);
15
+ n.recursive && (re(d) ? ye(d) || (d = e(d, n)) : n.recursiveInArray && me(d) && (d = [...d].map((f) => {
16
+ let p = f;
17
+ return re(f) ? ye(p) || (p = e(f, n)) : me(f) && (p = e({ key: f }, n).key), p;
18
+ }))), i[y] = d;
19
19
  }), i);
20
20
  };
21
21
  return e;
22
- }, Oe = Te(Fe), We = (n) => (
22
+ }, Ee = Se(Xe), Ke = (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
- n.replace(
25
+ r.replace(
26
26
  /([a-z0-9])([A-Z])/g,
27
- (e, t, s) => `${t}_${s.toLowerCase()}`
27
+ (e, t, n) => `${t}_${n.toLowerCase()}`
28
28
  )
29
- ), Ze = Te(We), Ve = [Number, String, Uint8Array], _ = {
29
+ ), Qe = Se(Ke), _e = [Number, String, Uint8Array], ie = {
30
30
  recursive: !0,
31
31
  recursiveInArray: !0
32
- }, ze = (n = _) => (n.recursive == null ? n = _ : n.recursiveInArray ??= !1, n), le = (n) => n != null && Array.isArray(n), X = (n) => n != null && typeof n == "object" && !Array.isArray(n), he = (n) => Ve.some((e) => n instanceof e);
33
- let Ge = class {
32
+ }, et = (r = ie) => (r.recursive == null ? r = ie : r.recursiveInArray ??= !1, r), me = (r) => r != null && Array.isArray(r), re = (r) => r != null && typeof r == "object" && !Array.isArray(r), ye = (r) => _e.some((e) => r instanceof e);
33
+ let tt = class {
34
34
  contentType = "application/json";
35
35
  decoder;
36
36
  encoder;
@@ -44,16 +44,16 @@ let Ge = class {
44
44
  return this.decodeString(this.decoder.decode(e), t);
45
45
  }
46
46
  decodeString(e, t) {
47
- const s = JSON.parse(e), i = Oe(s);
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 = Ze(e);
52
- return JSON.stringify(t, (s, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
51
+ const t = Qe(e);
52
+ return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
53
53
  }
54
54
  };
55
- const ee = new Ge();
56
- let j = class {
55
+ const ae = new tt();
56
+ let q = class {
57
57
  /** The underlying primitive value */
58
58
  value;
59
59
  constructor(e) {
@@ -73,152 +73,162 @@ let j = class {
73
73
  return this.value.toString();
74
74
  }
75
75
  };
76
- const Je = (n) => n != null && typeof n == "object" && "toString" in n, He = (n, e = !1) => {
77
- const t = Je(n) ? "stringer" : typeof n;
78
- let s;
76
+ const rt = (r) => r != null && typeof r == "object" && "toString" in r, nt = (r, e = !1) => {
77
+ const t = rt(r) ? "stringer" : typeof r;
78
+ let n;
79
79
  switch (t) {
80
80
  case "string":
81
- s = (i, o) => i.localeCompare(o);
81
+ n = (i, a) => i.localeCompare(a);
82
82
  break;
83
83
  case "stringer":
84
- s = (i, o) => i.toString().localeCompare(o.toString());
84
+ n = (i, a) => i.toString().localeCompare(a.toString());
85
85
  break;
86
86
  case "number":
87
- s = (i, o) => Number(i) - Number(o);
87
+ n = (i, a) => Number(i) - Number(a);
88
88
  break;
89
89
  case "bigint":
90
- s = (i, o) => BigInt(i) - BigInt(o) > 0n ? 1 : -1;
90
+ n = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
91
91
  break;
92
92
  case "boolean":
93
- s = (i, o) => Number(i) - Number(o);
93
+ n = (i, a) => Number(i) - Number(a);
94
94
  break;
95
95
  case "undefined":
96
- s = () => 0;
96
+ n = () => 0;
97
97
  break;
98
98
  default:
99
99
  return console.warn(`sortFunc: unknown type ${t}`), () => -1;
100
100
  }
101
- return e ? Xe(s) : s;
102
- }, Xe = (n) => (e, t) => n(t, e), H = r.tuple([r.number(), r.number()]);
103
- r.tuple([r.bigint(), r.bigint()]);
104
- const ve = r.object({ width: r.number(), height: r.number() }), Ke = r.object({
105
- signedWidth: r.number(),
106
- signedHeight: r.number()
107
- }), Qe = ["width", "height"];
108
- r.enum(Qe);
109
- const _e = ["start", "center", "end"], et = ["signedWidth", "signedHeight"];
110
- r.enum(et);
111
- const J = r.object({ x: r.number(), y: r.number() }), tt = r.object({ clientX: r.number(), clientY: r.number() }), nt = ["x", "y"], Ie = r.enum(nt), Se = ["top", "right", "bottom", "left"];
112
- r.enum(Se);
113
- const st = ["left", "right"], Ne = r.enum(st), rt = ["top", "bottom"], xe = r.enum(rt), Ee = ["center"], fe = r.enum(Ee), it = [...Se, ...Ee], Ae = r.enum(it);
114
- r.enum(_e);
115
- const at = ["first", "last"];
116
- r.enum(at);
117
- const ot = r.object({ lower: r.number(), upper: r.number() }), ut = r.object({ lower: r.bigint(), upper: r.bigint() });
118
- r.union([ot, H]);
119
- r.union([ut, H]);
120
- r.enum([...Ie.options, ...Ae.options]);
121
- r.union([Ie, Ae, r.instanceof(String)]);
122
- const C = (n, e) => typeof n == "bigint" ? n * BigInt(e) : n * Number(e), M = (n, e, t) => {
123
- const s = {};
124
- if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof n == "number" || typeof n == "bigint")
125
- e != null ? (s.lower = n, s.upper = e) : (s.lower = typeof n == "bigint" ? 0n : 0, s.upper = n);
126
- else if (Array.isArray(n)) {
127
- if (n.length !== 2) throw new Error("bounds: expected array of length 2");
128
- [s.lower, s.upper] = n;
101
+ return e ? st(n) : n;
102
+ }, st = (r) => (e, t) => r(t, e), K = s.tuple([s.number(), s.number()]);
103
+ s.tuple([s.bigint(), s.bigint()]);
104
+ const xe = s.object({ width: s.number(), height: s.number() }), it = s.object({
105
+ signedWidth: s.number(),
106
+ signedHeight: s.number()
107
+ }), at = ["width", "height"];
108
+ s.enum(at);
109
+ const ot = ["start", "center", "end"], ut = ["signedWidth", "signedHeight"];
110
+ s.enum(ut);
111
+ const X = s.object({ x: s.number(), y: s.number() }), lt = s.object({ clientX: s.number(), clientY: s.number() }), ct = ["x", "y"], Ae = s.enum(ct), Ue = ["top", "right", "bottom", "left"];
112
+ s.enum(Ue);
113
+ const ht = ["left", "right"], Me = s.enum(ht), ft = ["top", "bottom"], Ce = s.enum(ft), $e = ["center"], we = s.enum($e), dt = [...Ue, ...$e], Be = s.enum(dt);
114
+ s.enum(ot);
115
+ const gt = ["first", "last"];
116
+ s.enum(gt);
117
+ const pt = s.object({ lower: s.number(), upper: s.number() }), mt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
+ s.union([pt, K]);
119
+ s.union([mt, K]);
120
+ s.enum([...Ae.options, ...Be.options]);
121
+ s.enum(["x", "left", "right"]);
122
+ s.enum(["y", "top", "bottom"]);
123
+ s.union([Ae, Be, s.instanceof(String)]);
124
+ const Q = (r) => (e, t) => {
125
+ if (typeof e == "bigint") {
126
+ if (yt(t))
127
+ return r(e, BigInt(t));
128
+ const n = r(Number(e), Number(t));
129
+ return typeof n == "number" ? BigInt(Math.round(n)) : n;
130
+ }
131
+ return r(Number(e), Number(t));
132
+ }, _ = Q((r, e) => r - e), ee = Q((r, e) => r + e), yt = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), U = Q((r, e) => r * e), te = Q((r, e) => r / e), R = (r, e, t) => {
133
+ const n = {};
134
+ if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof r == "number" || typeof r == "bigint")
135
+ e != null ? (n.lower = r, n.upper = e) : (n.lower = typeof r == "bigint" ? 0n : 0, n.upper = r);
136
+ else if (Array.isArray(r)) {
137
+ if (r.length !== 2) throw new Error("bounds: expected array of length 2");
138
+ [n.lower, n.upper] = r;
129
139
  } else
130
- s.lower = n.lower, s.upper = n.upper;
131
- return t?.makeValid ? ct(s) : s;
132
- }, ct = (n) => n.lower > n.upper ? { lower: n.upper, upper: n.lower } : n, de = (n, e) => {
133
- const t = M(n);
140
+ n.lower = r.lower, n.upper = r.upper;
141
+ return t?.makeValid ? wt(n) : n;
142
+ }, wt = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, be = (r, e) => {
143
+ const t = R(r);
134
144
  return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
135
145
  };
136
- r.object({
137
- x: Ne.or(fe),
138
- y: xe.or(fe)
146
+ s.object({
147
+ x: Me.or(we),
148
+ y: Ce.or(we)
139
149
  });
140
- const lt = r.object({ x: Ne, y: xe }), ht = Object.freeze({ x: "left", y: "top" }), ft = (n, e) => n.x === e.x && n.y === e.y, ge = r.union([
141
- r.number(),
142
- J,
143
- H,
144
- ve,
145
- Ke,
146
- tt
147
- ]), dt = (n, e) => {
148
- if (typeof n == "string") {
150
+ const bt = s.object({ x: Me, y: Ce }), Ot = Object.freeze({ x: "left", y: "top" }), Tt = (r, e) => r.x === e.x && r.y === e.y, Oe = s.union([
151
+ s.number(),
152
+ X,
153
+ K,
154
+ xe,
155
+ it,
156
+ lt
157
+ ]), vt = (r, e) => {
158
+ if (typeof r == "string") {
149
159
  if (e === void 0) throw new Error("The y coordinate must be given.");
150
- return n === "x" ? { x: e, y: 0 } : { x: 0, y: e };
151
- }
152
- return typeof n == "number" ? { x: n, y: e ?? n } : Array.isArray(n) ? { x: n[0], y: n[1] } : "signedWidth" in n ? { x: n.signedWidth, y: n.signedHeight } : "clientX" in n ? { x: n.clientX, y: n.clientY } : "width" in n ? { x: n.width, y: n.height } : { x: n.x, y: n.y };
153
- }, pe = Object.freeze({ x: 0, y: 0 }), V = r.union([r.number(), r.string()]);
154
- r.object({
155
- top: V,
156
- left: V,
157
- width: V,
158
- height: V
160
+ return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
161
+ }
162
+ 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
+ }, Te = Object.freeze({ x: 0, y: 0 }), G = s.union([s.number(), s.string()]);
164
+ s.object({
165
+ top: G,
166
+ left: G,
167
+ width: G,
168
+ height: G
159
169
  });
160
- r.object({
161
- left: r.number(),
162
- top: r.number(),
163
- right: r.number(),
164
- bottom: r.number()
170
+ s.object({
171
+ left: s.number(),
172
+ top: s.number(),
173
+ right: s.number(),
174
+ bottom: s.number()
165
175
  });
166
- r.object({
167
- one: J,
168
- two: J,
169
- root: lt
176
+ s.object({
177
+ one: X,
178
+ two: X,
179
+ root: bt
170
180
  });
171
- const ie = (n, e, t = 0, s = 0, i) => {
172
- const o = {
173
- one: { ...pe },
174
- two: { ...pe },
175
- root: i ?? ht
181
+ const fe = (r, e, t = 0, n = 0, i) => {
182
+ const a = {
183
+ one: { ...Te },
184
+ two: { ...Te },
185
+ root: i ?? Ot
176
186
  };
177
- if (typeof n == "number") {
187
+ if (typeof r == "number") {
178
188
  if (typeof e != "number")
179
189
  throw new Error("Box constructor called with invalid arguments");
180
- return o.one = { x: n, y: e }, o.two = { x: o.one.x + t, y: o.one.y + s }, o;
181
- }
182
- return "one" in n && "two" in n && "root" in n ? { ...n, root: i ?? n.root } : ("getBoundingClientRect" in n && (n = n.getBoundingClientRect()), "left" in n ? (o.one = { x: n.left, y: n.top }, o.two = { x: n.right, y: n.bottom }, o) : (o.one = n, e == null ? o.two = { x: o.one.x + t, y: o.one.y + s } : typeof e == "number" ? o.two = { x: o.one.x + e, y: o.one.y + t } : "width" in e ? o.two = {
183
- x: o.one.x + e.width,
184
- y: o.one.y + e.height
185
- } : "signedWidth" in e ? o.two = {
186
- x: o.one.x + e.signedWidth,
187
- y: o.one.y + e.signedHeight
188
- } : o.two = e, o));
189
- }, K = (n) => {
190
- const e = ie(n);
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
+ }, ne = (r) => {
200
+ const e = fe(r);
191
201
  return { lower: e.one.x, upper: e.two.x };
192
- }, Q = (n) => {
193
- const e = ie(n);
202
+ }, se = (r) => {
203
+ const e = fe(r);
194
204
  return { lower: e.one.y, upper: e.two.y };
195
- }, gt = (n) => typeof n != "object" || n == null ? !1 : "one" in n && "two" in n && "root" in n, pt = r.object({ signedWidth: r.number(), signedHeight: r.number() });
196
- r.union([ve, pt, J, H]);
197
- const yt = (n, e, t) => e !== void 0 && n < e ? e : t !== void 0 && n > t ? t : n;
198
- r.object({ offset: ge, scale: ge });
199
- r.object({ offset: r.number(), scale: r.number() });
200
- const mt = (n) => (e, t, s, i) => t === "dimension" ? [e, s] : [
205
+ }, It = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, Nt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
+ s.union([xe, Nt, X, K]);
207
+ const St = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
208
+ s.object({ offset: Oe, scale: Oe });
209
+ s.object({ offset: s.number(), scale: s.number() });
210
+ const Et = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
201
211
  e,
202
- i ? s - n : s + n
203
- ], wt = (n) => (e, t, s, i) => [
212
+ i ? n - r : n + r
213
+ ], xt = (r) => (e, t, n, i) => [
204
214
  e,
205
- i ? s / n : s * n
206
- ], bt = (n) => (e, t, s) => {
207
- if (e === null) return [n, s];
208
- const { lower: i, upper: o } = e, { lower: l, upper: d } = n, f = o - i, g = d - l;
209
- if (t === "dimension") return [n, s * (g / f)];
210
- const m = (s - i) * (g / f) + l;
211
- return [n, m];
212
- }, Tt = (n) => (e, t, s) => [n, s], Ot = () => (n, e, t) => {
213
- if (n === null) throw new Error("cannot invert without bounds");
214
- if (e === "dimension") return [n, t];
215
- const { lower: s, upper: i } = n;
216
- return [n, i - (t - s)];
217
- }, vt = (n) => (e, t, s) => {
218
- const { lower: i, upper: o } = n;
219
- return s = yt(s, i, o), [e, s];
215
+ i ? n / r : n * r
216
+ ], At = (r) => (e, t, n) => {
217
+ if (e === null) return [r, n];
218
+ const { lower: i, upper: a } = e, { lower: c, upper: d } = r, y = a - i, f = d - c;
219
+ if (t === "dimension") return [r, n * (f / y)];
220
+ const p = (n - i) * (f / y) + c;
221
+ return [r, p];
222
+ }, Ut = (r) => (e, t, n) => [r, n], Mt = () => (r, e, t) => {
223
+ if (r === null) throw new Error("cannot invert without bounds");
224
+ if (e === "dimension") return [r, t];
225
+ const { lower: n, upper: i } = r;
226
+ return [r, i - (t - n)];
227
+ }, Ct = (r) => (e, t, n) => {
228
+ const { lower: i, upper: a } = r;
229
+ return n = St(n, i, a), [e, n];
220
230
  };
221
- let ye = class B {
231
+ let ve = class D {
222
232
  ops = [];
223
233
  currBounds = null;
224
234
  currType = null;
@@ -232,7 +242,7 @@ let ye = class B {
232
242
  * @param value - The amount to translate by.
233
243
  */
234
244
  static translate(e) {
235
- return new B().translate(e);
245
+ return new D().translate(e);
236
246
  }
237
247
  /**
238
248
  * @returns a new scale with a magnification as its first operation. Any number provided
@@ -240,10 +250,10 @@ let ye = class B {
240
250
  * @param value - The amount to translate by.
241
251
  */
242
252
  static magnify(e) {
243
- return new B().magnify(e);
253
+ return new D().magnify(e);
244
254
  }
245
255
  static scale(e, t) {
246
- return new B().scale(e, t);
256
+ return new D().scale(e, t);
247
257
  }
248
258
  /**
249
259
  * @returns a copy of the scale with a translation as its next operation. Any
@@ -252,8 +262,8 @@ let ye = class B {
252
262
  * @param value - The amount to translate by.
253
263
  */
254
264
  translate(e) {
255
- const t = this.new(), s = mt(e);
256
- return s.type = "translate", t.ops.push(s), t;
265
+ const t = this.new(), n = Et(e);
266
+ return n.type = "translate", t.ops.push(n), t;
257
267
  }
258
268
  /**
259
269
  * @returns a copy of the scale with a translation as its next operation. Any number
@@ -262,23 +272,23 @@ let ye = class B {
262
272
  * @param value - The amount to magnify by.
263
273
  */
264
274
  magnify(e) {
265
- const t = this.new(), s = wt(e);
266
- return s.type = "magnify", t.ops.push(s), t;
275
+ const t = this.new(), n = xt(e);
276
+ return n.type = "magnify", t.ops.push(n), t;
267
277
  }
268
278
  scale(e, t) {
269
- const s = M(e, t), i = this.new(), o = bt(s);
270
- return o.type = "scale", i.ops.push(o), i;
279
+ const n = R(e, t), i = this.new(), a = At(n);
280
+ return a.type = "scale", i.ops.push(a), i;
271
281
  }
272
282
  clamp(e, t) {
273
- const s = M(e, t), i = this.new(), o = vt(s);
274
- return o.type = "clamp", i.ops.push(o), i;
283
+ const n = R(e, t), i = this.new(), a = Ct(n);
284
+ return a.type = "clamp", i.ops.push(a), i;
275
285
  }
276
286
  reBound(e, t) {
277
- const s = M(e, t), i = this.new(), o = Tt(s);
278
- return o.type = "re-bound", i.ops.push(o), i;
287
+ const n = R(e, t), i = this.new(), a = Ut(n);
288
+ return a.type = "re-bound", i.ops.push(a), i;
279
289
  }
280
290
  invert() {
281
- const e = Ot();
291
+ const e = Mt();
282
292
  e.type = "invert";
283
293
  const t = this.new();
284
294
  return t.ops.push(e), t;
@@ -290,12 +300,12 @@ let ye = class B {
290
300
  return this.exec("dimension", e);
291
301
  }
292
302
  new() {
293
- const e = new B();
303
+ const e = new D();
294
304
  return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
295
305
  }
296
306
  exec(e, t) {
297
307
  return this.currBounds = null, this.ops.reduce(
298
- ([s, i], o) => o(s, e, i, this.reversed),
308
+ ([n, i], a) => a(n, e, i, this.reversed),
299
309
  [null, t]
300
310
  )[1];
301
311
  }
@@ -303,51 +313,51 @@ let ye = class B {
303
313
  const e = this.new();
304
314
  e.ops.reverse();
305
315
  const t = [];
306
- return e.ops.forEach((s, i) => {
307
- if (s.type === "scale" || t.some(([l, d]) => i >= l && i <= d))
316
+ return e.ops.forEach((n, i) => {
317
+ if (n.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
308
318
  return;
309
- const o = e.ops.findIndex((l, d) => l.type === "scale" && d > i);
310
- o !== -1 && t.push([i, o]);
311
- }), t.forEach(([s, i]) => {
312
- const o = e.ops.slice(s, i);
313
- o.unshift(e.ops[i]), e.ops.splice(s, i - s + 1, ...o);
319
+ const a = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
320
+ a !== -1 && t.push([i, a]);
321
+ }), 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);
314
324
  }), e.reversed = !e.reversed, e;
315
325
  }
316
326
  get transform() {
317
327
  return { scale: this.dim(1), offset: this.pos(0) };
318
328
  }
319
- static IDENTITY = new B();
320
- }, Yn = class S {
329
+ static IDENTITY = new D();
330
+ }, Xr = class A {
321
331
  x;
322
332
  y;
323
333
  currRoot;
324
- constructor(e = new ye(), t = new ye(), s = null) {
325
- this.x = e, this.y = t, this.currRoot = s;
334
+ constructor(e = new ve(), t = new ve(), n = null) {
335
+ this.x = e, this.y = t, this.currRoot = n;
326
336
  }
327
337
  static translate(e, t) {
328
- return new S().translate(e, t);
338
+ return new A().translate(e, t);
329
339
  }
330
340
  static translateX(e) {
331
- return new S().translateX(e);
341
+ return new A().translateX(e);
332
342
  }
333
343
  static translateY(e) {
334
- return new S().translateY(e);
344
+ return new A().translateY(e);
335
345
  }
336
346
  static clamp(e) {
337
- return new S().clamp(e);
347
+ return new A().clamp(e);
338
348
  }
339
349
  static magnify(e) {
340
- return new S().magnify(e);
350
+ return new A().magnify(e);
341
351
  }
342
352
  static scale(e) {
343
- return new S().scale(e);
353
+ return new A().scale(e);
344
354
  }
345
355
  static reBound(e) {
346
- return new S().reBound(e);
356
+ return new A().reBound(e);
347
357
  }
348
358
  translate(e, t) {
349
- const s = dt(e, t), i = this.copy();
350
- return i.x = this.x.translate(s.x), i.y = this.y.translate(s.y), i;
359
+ const n = vt(e, t), i = this.copy();
360
+ return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
351
361
  }
352
362
  translateX(e) {
353
363
  const t = this.copy();
@@ -363,22 +373,22 @@ let ye = class B {
363
373
  }
364
374
  scale(e) {
365
375
  const t = this.copy();
366
- if (gt(e)) {
367
- const s = this.currRoot;
368
- return t.currRoot = e.root, s != null && !ft(s, e.root) && (s.x !== e.root.x && (t.x = t.x.invert()), s.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(K(e)), t.y = t.y.scale(Q(e)), t;
376
+ if (It(e)) {
377
+ const n = this.currRoot;
378
+ return t.currRoot = e.root, n != null && !Tt(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(ne(e)), t.y = t.y.scale(se(e)), t;
369
379
  }
370
380
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
371
381
  }
372
382
  reBound(e) {
373
383
  const t = this.copy();
374
- return t.x = this.x.reBound(K(e)), t.y = this.y.reBound(Q(e)), t;
384
+ return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(se(e)), t;
375
385
  }
376
386
  clamp(e) {
377
387
  const t = this.copy();
378
- return t.x = this.x.clamp(K(e)), t.y = this.y.clamp(Q(e)), t;
388
+ return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(se(e)), t;
379
389
  }
380
390
  copy() {
381
- const e = new S();
391
+ const e = new A();
382
392
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
383
393
  }
384
394
  reverse() {
@@ -392,7 +402,7 @@ let ye = class B {
392
402
  return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
393
403
  }
394
404
  box(e) {
395
- return ie(
405
+ return fe(
396
406
  this.pos(e.one),
397
407
  this.pos(e.two),
398
408
  0,
@@ -406,50 +416,50 @@ let ye = class B {
406
416
  offset: this.pos({ x: 0, y: 0 })
407
417
  };
408
418
  }
409
- static IDENTITY = new S();
410
- }, It = (n, e = 21) => (t = e) => {
411
- let s = "", i = t | 0;
419
+ static IDENTITY = new A();
420
+ }, Re = (r, e = 21) => (t = e) => {
421
+ let n = "", i = t | 0;
412
422
  for (; i--; )
413
- s += n[Math.random() * n.length | 0];
414
- return s;
423
+ n += r[Math.random() * r.length | 0];
424
+ return n;
415
425
  };
416
- const St = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Nt = 11, xt = It(St, Nt), Et = () => xt(), At = (n, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === n, Ut = r.enum(["static", "dynamic"]), Mt = r.union([
417
- r.tuple([r.int()]),
418
- r.tuple([r.int(), r.int().min(1).max(12)]),
419
- r.tuple([r.int(), r.int().min(1).max(12), r.int().min(1).max(31)])
420
- ]), Ue = (n, e) => {
421
- const t = new y(e);
426
+ const De = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", $t = `0123456789${De}`, Bt = 11, Rt = Re(De, 1), Dt = Re($t, Bt - 1), Lt = () => `${Rt()}${Dt()}`, Pt = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, kt = s.enum(["static", "dynamic"]), Yt = s.union([
427
+ s.tuple([s.int()]),
428
+ s.tuple([s.int(), s.int().min(1).max(12)]),
429
+ s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
430
+ ]), Le = (r, e) => {
431
+ const t = new o(e);
422
432
  if (![
423
- u.DAY,
424
- u.HOUR,
425
- u.MINUTE,
426
- u.SECOND,
427
- u.MILLISECOND,
428
- u.MICROSECOND,
429
- u.NANOSECOND
433
+ g.DAY,
434
+ g.HOUR,
435
+ g.MINUTE,
436
+ g.SECOND,
437
+ g.MILLISECOND,
438
+ g.MICROSECOND,
439
+ g.NANOSECOND
430
440
  ].some((i) => i.equals(t)))
431
441
  throw new Error(
432
442
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
433
443
  );
434
- const s = n.valueOf() % t.valueOf();
435
- return n instanceof y ? new y(s) : new u(s);
444
+ const n = r.valueOf() % t.valueOf();
445
+ return r instanceof o ? new o(n) : new g(n);
436
446
  };
437
- let y = class c extends j {
447
+ class o extends q {
438
448
  constructor(e, t = "UTC") {
439
- if (e == null) super(c.now().valueOf());
449
+ if (e == null) super(o.now().valueOf());
440
450
  else if (e instanceof Date)
441
- super(BigInt(e.getTime()) * c.MILLISECOND.valueOf());
451
+ super(BigInt(e.getTime()) * o.MILLISECOND.valueOf());
442
452
  else if (typeof e == "string")
443
- super(c.parseDateTimeString(e, t).valueOf());
444
- else if (Array.isArray(e)) super(c.parseDate(e));
453
+ super(o.parseDateTimeString(e, t).valueOf());
454
+ else if (Array.isArray(e)) super(o.parseDate(e));
445
455
  else {
446
- let s = 0n;
447
- e instanceof Number && (e = e.valueOf()), t === "local" && (s = c.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = c.MAX : e = c.MIN)), super(BigInt(e.valueOf()) + s);
456
+ let n = 0n;
457
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = o.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = o.MAX : e = o.MIN)), super(BigInt(e.valueOf()) + n);
448
458
  }
449
459
  }
450
- static parseDate([e = 1970, t = 1, s = 1]) {
451
- const i = new Date(e, t - 1, s, 0, 0, 0, 0);
452
- return new c(BigInt(i.getTime()) * c.MILLISECOND.valueOf()).truncate(c.DAY).valueOf();
460
+ static parseDate([e = 1970, t = 1, n = 1]) {
461
+ const i = new Date(e, t - 1, n, 0, 0, 0, 0);
462
+ return new o(BigInt(i.getTime()) * o.MILLISECOND.valueOf()).truncate(o.DAY).valueOf();
453
463
  }
454
464
  /**
455
465
  * @returns the primitive value of the TimeStamp. Overrides standard JS valueOf()
@@ -459,18 +469,18 @@ let y = class c extends j {
459
469
  return this.value;
460
470
  }
461
471
  static parseTimeString(e, t = "UTC") {
462
- const [s, i, o] = e.split(":");
463
- let l = "00", d = "00";
464
- o != null && ([l, d] = o.split("."));
465
- let f = c.hours(parseInt(s ?? "00")).add(c.minutes(parseInt(i ?? "00"))).add(c.seconds(parseInt(l ?? "00"))).add(c.milliseconds(parseInt(d ?? "00")));
466
- return t === "local" && (f = f.add(c.utcOffset)), f.valueOf();
472
+ const [n, i, a] = e.split(":");
473
+ let c = "00", d = "00";
474
+ a != null && ([c, d] = a.split("."));
475
+ let y = o.hours(parseInt(n ?? "00")).add(o.minutes(parseInt(i ?? "00"))).add(o.seconds(parseInt(c ?? "00"))).add(o.milliseconds(parseInt(d ?? "00")));
476
+ return t === "local" && (y = y.add(o.utcOffset)), y.valueOf();
467
477
  }
468
478
  static parseDateTimeString(e, t = "UTC") {
469
479
  if (!e.includes("/") && !e.includes("-"))
470
- return c.parseTimeString(e, t);
471
- const s = new Date(e);
472
- return e.includes(":") || s.setUTCHours(0, 0, 0, 0), new c(
473
- BigInt(s.getTime()) * c.MILLISECOND.valueOf(),
480
+ return o.parseTimeString(e, t);
481
+ const n = new Date(e);
482
+ return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new o(
483
+ BigInt(n.getTime()) * o.MILLISECOND.valueOf(),
474
484
  t
475
485
  ).valueOf();
476
486
  }
@@ -502,20 +512,20 @@ let y = class c extends j {
502
512
  }
503
513
  }
504
514
  toISOString(e = "UTC") {
505
- return e === "UTC" ? this.date().toISOString() : this.sub(c.utcOffset).date().toISOString();
515
+ return e === "UTC" ? this.date().toISOString() : this.sub(o.utcOffset).date().toISOString();
506
516
  }
507
517
  timeString(e = !1, t = "UTC") {
508
- const s = this.toISOString(t);
509
- return e ? s.slice(11, 23) : s.slice(11, 19);
518
+ const n = this.toISOString(t);
519
+ return e ? n.slice(11, 23) : n.slice(11, 19);
510
520
  }
511
521
  dateString() {
512
- const e = this.date(), t = e.toLocaleString("default", { month: "short" }), s = e.toLocaleString("default", { day: "numeric" });
513
- return `${t} ${s}`;
522
+ const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
523
+ return `${t} ${n}`;
514
524
  }
515
525
  /** @returns The UTC offset for the time zone of the machine. */
516
526
  static get utcOffset() {
517
- return new u(
518
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * c.MINUTE.valueOf()
527
+ return new g(
528
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * o.MINUTE.valueOf()
519
529
  );
520
530
  }
521
531
  /**
@@ -524,7 +534,7 @@ let y = class c extends j {
524
534
  * @param other - The other timestamp.
525
535
  */
526
536
  static since(e) {
527
- return new c().span(e);
537
+ return new o().span(e);
528
538
  }
529
539
  /** @returns A JavaScript Date object representing the TimeStamp. */
530
540
  date() {
@@ -537,7 +547,7 @@ let y = class c extends j {
537
547
  * @returns True if the TimeStamps are equal, false otherwise.
538
548
  */
539
549
  equals(e) {
540
- return this.valueOf() === new c(e).valueOf();
550
+ return this.valueOf() === new o(e).valueOf();
541
551
  }
542
552
  /**
543
553
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -557,7 +567,7 @@ let y = class c extends j {
557
567
  * valid, regardless of the TimeStamp order.
558
568
  */
559
569
  range(e) {
560
- return new v(this, e).makeValid();
570
+ return new F(this, e).makeValid();
561
571
  }
562
572
  /**
563
573
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -586,7 +596,7 @@ let y = class c extends j {
586
596
  * otherwise.
587
597
  */
588
598
  after(e) {
589
- return this.valueOf() > new c(e).valueOf();
599
+ return this.valueOf() > new o(e).valueOf();
590
600
  }
591
601
  /**
592
602
  * Checks if the TimeStamp is after or equal to the given TimeStamp.
@@ -596,7 +606,7 @@ let y = class c extends j {
596
606
  * false otherwise.
597
607
  */
598
608
  afterEq(e) {
599
- return this.valueOf() >= new c(e).valueOf();
609
+ return this.valueOf() >= new o(e).valueOf();
600
610
  }
601
611
  /**
602
612
  * Checks if the TimeStamp is before the given TimeStamp.
@@ -606,7 +616,7 @@ let y = class c extends j {
606
616
  * otherwise.
607
617
  */
608
618
  before(e) {
609
- return this.valueOf() < new c(e).valueOf();
619
+ return this.valueOf() < new o(e).valueOf();
610
620
  }
611
621
  /**
612
622
  * Checks if TimeStamp is before or equal to the current timestamp.
@@ -616,7 +626,7 @@ let y = class c extends j {
616
626
  * false otherwise.
617
627
  */
618
628
  beforeEq(e) {
619
- return this.valueOf() <= new c(e).valueOf();
629
+ return this.valueOf() <= new o(e).valueOf();
620
630
  }
621
631
  /**
622
632
  * Adds a TimeSpan to the TimeStamp.
@@ -626,7 +636,7 @@ let y = class c extends j {
626
636
  * TimeSpan.
627
637
  */
628
638
  add(e) {
629
- return new c(this.valueOf() + BigInt(e.valueOf()));
639
+ return new o(ee(this.valueOf(), new g(e).valueOf()));
630
640
  }
631
641
  /**
632
642
  * Subtracts a TimeSpan from the TimeStamp.
@@ -636,43 +646,43 @@ let y = class c extends j {
636
646
  * TimeSpan.
637
647
  */
638
648
  sub(e) {
639
- return new c(this.valueOf() - BigInt(e.valueOf()));
649
+ return new o(_(this.valueOf(), new g(e).valueOf()));
640
650
  }
641
651
  /**
642
652
  * @returns the floating point number of hours since the unix epoch to the timestamp
643
653
  * value.
644
654
  */
645
655
  get hours() {
646
- return Number(this.valueOf()) / Number(u.HOUR.valueOf());
656
+ return Number(this.valueOf()) / Number(g.HOUR.valueOf());
647
657
  }
648
658
  /**
649
659
  * @returns the floating point number of minutes since the unix epoch to the timestamp
650
660
  * value.
651
661
  */
652
662
  get minutes() {
653
- return Number(this.valueOf()) / Number(u.MINUTE.valueOf());
663
+ return Number(this.valueOf()) / Number(g.MINUTE.valueOf());
654
664
  }
655
665
  /**
656
666
  * @returns the floating point number of days since the unix epoch to the timestamp
657
667
  * value.
658
668
  */
659
669
  get days() {
660
- return Number(this.valueOf()) / Number(u.DAY.valueOf());
670
+ return Number(this.valueOf()) / Number(g.DAY.valueOf());
661
671
  }
662
672
  /**
663
673
  * @returns the floating point number of seconds since the unix epoch to the timestamp
664
674
  * value.
665
675
  */
666
676
  get seconds() {
667
- return Number(this.valueOf()) / Number(u.SECOND.valueOf());
677
+ return Number(this.valueOf()) / Number(g.SECOND.valueOf());
668
678
  }
669
679
  /** @returns the floating point number of milliseconds since the unix epoch. */
670
680
  get milliseconds() {
671
- return Number(this.valueOf()) / Number(c.MILLISECOND.valueOf());
681
+ return Number(this.valueOf()) / Number(o.MILLISECOND.valueOf());
672
682
  }
673
683
  /** @returns the floating point number of microseconds since the unix epoch. */
674
684
  get microseconds() {
675
- return Number(this.valueOf()) / Number(c.MICROSECOND.valueOf());
685
+ return Number(this.valueOf()) / Number(o.MICROSECOND.valueOf());
676
686
  }
677
687
  /**
678
688
  * @returns the floating point number of nanoseconds since the unix epoch.
@@ -692,7 +702,7 @@ let y = class c extends j {
692
702
  */
693
703
  setYear(e) {
694
704
  const t = this.date();
695
- return t.setUTCFullYear(e), new c(t);
705
+ return t.setUTCFullYear(e), new o(t);
696
706
  }
697
707
  /** @returns the integer month that the timestamp corresponds to with its year. */
698
708
  get month() {
@@ -704,7 +714,7 @@ let y = class c extends j {
704
714
  */
705
715
  setMonth(e) {
706
716
  const t = this.date();
707
- return t.setUTCMonth(e), new c(t);
717
+ return t.setUTCMonth(e), new o(t);
708
718
  }
709
719
  /** @returns the integer day that the timestamp corresponds to within its month. */
710
720
  get day() {
@@ -716,7 +726,7 @@ let y = class c extends j {
716
726
  */
717
727
  setDay(e) {
718
728
  const t = this.date();
719
- return t.setUTCDate(e), new c(t);
729
+ return t.setUTCDate(e), new o(t);
720
730
  }
721
731
  /**
722
732
  * @returns the integer hour that the timestamp corresponds to within its day.
@@ -730,7 +740,7 @@ let y = class c extends j {
730
740
  */
731
741
  setHour(e) {
732
742
  const t = this.date();
733
- return t.setUTCHours(e), new c(t, "UTC");
743
+ return t.setUTCHours(e), new o(t, "UTC");
734
744
  }
735
745
  /** @returns the integer minute that the timestamp corresponds to within its hour. */
736
746
  get minute() {
@@ -742,7 +752,7 @@ let y = class c extends j {
742
752
  */
743
753
  setMinute(e) {
744
754
  const t = this.date();
745
- return t.setUTCMinutes(e), new c(t);
755
+ return t.setUTCMinutes(e), new o(t);
746
756
  }
747
757
  /**
748
758
  * @returns the integer second that the timestamp corresponds to within its
@@ -757,7 +767,7 @@ let y = class c extends j {
757
767
  */
758
768
  setSecond(e) {
759
769
  const t = this.date();
760
- return t.setUTCSeconds(e), new c(t);
770
+ return t.setUTCSeconds(e), new o(t);
761
771
  }
762
772
  /**
763
773
  * @reutrns the integer millisecond that the timestamp corresponds to within
@@ -772,7 +782,7 @@ let y = class c extends j {
772
782
  */
773
783
  setMillisecond(e) {
774
784
  const t = this.date();
775
- return t.setUTCMilliseconds(e), new c(t);
785
+ return t.setUTCMilliseconds(e), new o(t);
776
786
  }
777
787
  /** @returns the time stamp formatted as an ISO string. */
778
788
  toString() {
@@ -790,11 +800,11 @@ let y = class c extends j {
790
800
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
791
801
  */
792
802
  remainder(e) {
793
- return Ue(this, e);
803
+ return Le(this, e);
794
804
  }
795
805
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
796
806
  get isToday() {
797
- return this.truncate(u.DAY).equals(c.now().truncate(u.DAY));
807
+ return this.truncate(g.DAY).equals(o.now().truncate(g.DAY));
798
808
  }
799
809
  /**
800
810
  * Truncates the TimeStamp to the nearest multiple of the given span.
@@ -811,7 +821,7 @@ let y = class c extends j {
811
821
  * JavaScript can do).
812
822
  */
813
823
  static now() {
814
- return new c(/* @__PURE__ */ new Date());
824
+ return new o(/* @__PURE__ */ new Date());
815
825
  }
816
826
  /**
817
827
  * Finds the maximum timestamp among the provided timestamps.
@@ -820,9 +830,9 @@ let y = class c extends j {
820
830
  * @returns The maximum (latest) timestamp from the input.
821
831
  */
822
832
  static max(...e) {
823
- let t = c.MIN;
824
- for (const s of e) {
825
- const i = new c(s);
833
+ let t = o.MIN;
834
+ for (const n of e) {
835
+ const i = new o(n);
826
836
  i.after(t) && (t = i);
827
837
  }
828
838
  return t;
@@ -834,9 +844,9 @@ let y = class c extends j {
834
844
  * @returns The minimum (earliest) timestamp from the input.
835
845
  */
836
846
  static min(...e) {
837
- let t = c.MAX;
838
- for (const s of e) {
839
- const i = new c(s);
847
+ let t = o.MAX;
848
+ for (const n of e) {
849
+ const i = new o(n);
840
850
  i.before(t) && (t = i);
841
851
  }
842
852
  return t;
@@ -848,62 +858,62 @@ let y = class c extends j {
848
858
  * @returns A TimeStamp representing the given number of nanoseconds.
849
859
  */
850
860
  static nanoseconds(e, t = "UTC") {
851
- return new c(e, t);
861
+ return new o(e, t);
852
862
  }
853
863
  /** One nanosecond after the unix epoch */
854
- static NANOSECOND = c.nanoseconds(1);
864
+ static NANOSECOND = o.nanoseconds(1);
855
865
  /** @returns a new TimeStamp n microseconds after the unix epoch */
856
866
  static microseconds(e, t = "UTC") {
857
- return c.nanoseconds(e * 1e3, t);
867
+ return o.nanoseconds(e * 1e3, t);
858
868
  }
859
869
  /** One microsecond after the unix epoch */
860
- static MICROSECOND = c.microseconds(1);
870
+ static MICROSECOND = o.microseconds(1);
861
871
  /** @returns a new TimeStamp n milliseconds after the unix epoch */
862
872
  static milliseconds(e, t = "UTC") {
863
- return c.microseconds(e * 1e3, t);
873
+ return o.microseconds(e * 1e3, t);
864
874
  }
865
875
  /** One millisecond after the unix epoch */
866
- static MILLISECOND = c.milliseconds(1);
876
+ static MILLISECOND = o.milliseconds(1);
867
877
  /** @returns a new TimeStamp n seconds after the unix epoch */
868
878
  static seconds(e, t = "UTC") {
869
- return c.milliseconds(e * 1e3, t);
879
+ return o.milliseconds(e * 1e3, t);
870
880
  }
871
881
  /** One second after the unix epoch */
872
- static SECOND = c.seconds(1);
882
+ static SECOND = o.seconds(1);
873
883
  /** @returns a new TimeStamp n minutes after the unix epoch */
874
884
  static minutes(e, t = "UTC") {
875
- return c.seconds(e * 60, t);
885
+ return o.seconds(e * 60, t);
876
886
  }
877
887
  /** One minute after the unix epoch */
878
- static MINUTE = c.minutes(1);
888
+ static MINUTE = o.minutes(1);
879
889
  /** @returns a new TimeStamp n hours after the unix epoch */
880
890
  static hours(e, t = "UTC") {
881
- return c.minutes(e * 60, t);
891
+ return o.minutes(e * 60, t);
882
892
  }
883
893
  /** One hour after the unix epoch */
884
- static HOUR = c.hours(1);
894
+ static HOUR = o.hours(1);
885
895
  /** @returns a new TimeStamp n days after the unix epoch */
886
896
  static days(e, t = "UTC") {
887
- return c.hours(e * 24, t);
897
+ return o.hours(e * 24, t);
888
898
  }
889
899
  /** One day after the unix epoch */
890
- static DAY = c.days(1);
900
+ static DAY = o.days(1);
891
901
  /** The maximum possible value for a timestamp */
892
- static MAX = new c((1n << 63n) - 1n);
902
+ static MAX = new o((1n << 63n) - 1n);
893
903
  /** The minimum possible value for a timestamp */
894
- static MIN = new c(0);
904
+ static MIN = new o(0);
895
905
  /** The unix epoch */
896
- static ZERO = new c(0);
906
+ static ZERO = new o(0);
897
907
  /** A zod schema for validating timestamps */
898
- static z = r.union([
899
- r.instanceof(c),
900
- r.object({ value: r.bigint() }).transform((e) => new c(e.value)),
901
- r.string().transform((e) => new c(BigInt(e))),
902
- r.number().transform((e) => new c(e)),
903
- r.bigint().transform((e) => new c(e)),
904
- r.date().transform((e) => new c(e)),
905
- r.custom((e) => e instanceof u).transform((e) => new c(e)),
906
- Mt.transform((e) => new c(e))
908
+ static z = s.union([
909
+ s.instanceof(o),
910
+ s.object({ value: s.bigint() }).transform((e) => new o(e.value)),
911
+ s.string().transform((e) => new o(BigInt(e))),
912
+ s.number().transform((e) => new o(e)),
913
+ s.bigint().transform((e) => new o(e)),
914
+ s.date().transform((e) => new o(e)),
915
+ s.custom((e) => e instanceof g).transform((e) => new o(e)),
916
+ Yt.transform((e) => new o(e))
907
917
  ]);
908
918
  /**
909
919
  * Sorts two timestamps.
@@ -916,8 +926,8 @@ let y = class c extends j {
916
926
  static sort(e, t) {
917
927
  return Number(e.valueOf() - t.valueOf());
918
928
  }
919
- };
920
- class u extends j {
929
+ }
930
+ let g = class l extends q {
921
931
  constructor(e) {
922
932
  typeof e == "number" && (e = Math.trunc(e.valueOf())), super(BigInt(e.valueOf()));
923
933
  }
@@ -928,7 +938,7 @@ class u extends j {
928
938
  * @returns A TimeSpan representing the given number of seconds.
929
939
  */
930
940
  static fromSeconds(e) {
931
- return e instanceof u ? e : e instanceof me ? e.period : e instanceof y ? new u(e) : ["number", "bigint"].includes(typeof e) ? u.seconds(e) : new u(e);
941
+ return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e);
932
942
  }
933
943
  /**
934
944
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -937,7 +947,7 @@ class u extends j {
937
947
  * @returns A TimeSpan representing the given number of milliseconds.
938
948
  */
939
949
  static fromMilliseconds(e) {
940
- return e instanceof u ? e : e instanceof me ? e.period : e instanceof y ? new u(e) : ["number", "bigint"].includes(typeof e) ? u.milliseconds(e) : new u(e);
950
+ return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e);
941
951
  }
942
952
  /**
943
953
  * @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
@@ -953,7 +963,7 @@ class u extends j {
953
963
  * @returns True if the TimeSpan is less than the other TimeSpan, false otherwise.
954
964
  */
955
965
  lessThan(e) {
956
- return this.valueOf() < new u(e).valueOf();
966
+ return this.valueOf() < new l(e).valueOf();
957
967
  }
958
968
  /**
959
969
  * Checks if the TimeSpan is greater than another TimeSpan.
@@ -962,7 +972,7 @@ class u extends j {
962
972
  * @returns True if the TimeSpan is greater than the other TimeSpan, false otherwise.
963
973
  */
964
974
  greaterThan(e) {
965
- return this.valueOf() > new u(e).valueOf();
975
+ return this.valueOf() > new l(e).valueOf();
966
976
  }
967
977
  /**
968
978
  * Checks if the TimeSpan is less than or equal to another TimeSpan.
@@ -971,7 +981,7 @@ class u extends j {
971
981
  * @returns True if the TimeSpan is less than or equal to the other TimeSpan, false otherwise.
972
982
  */
973
983
  lessThanOrEqual(e) {
974
- return this.valueOf() <= new u(e).valueOf();
984
+ return this.valueOf() <= new l(e).valueOf();
975
985
  }
976
986
  /**
977
987
  * Checks if the TimeSpan is greater than or equal to another TimeSpan.
@@ -980,7 +990,7 @@ class u extends j {
980
990
  * @returns True if the TimeSpan is greater than or equal to the other TimeSpan, false otherwise.
981
991
  */
982
992
  greaterThanOrEqual(e) {
983
- return this.valueOf() >= new u(e).valueOf();
993
+ return this.valueOf() >= new l(e).valueOf();
984
994
  }
985
995
  /**
986
996
  * Calculates the remainder of the TimeSpan when divided by another TimeSpan.
@@ -989,7 +999,7 @@ class u extends j {
989
999
  * @returns A new TimeSpan representing the remainder.
990
1000
  */
991
1001
  remainder(e) {
992
- return Ue(this, e);
1002
+ return Le(this, e);
993
1003
  }
994
1004
  /**
995
1005
  * Truncates the TimeSpan to the nearest multiple of the given span.
@@ -998,7 +1008,7 @@ class u extends j {
998
1008
  * @returns A new TimeSpan that is truncated to the nearest multiple of the given span.
999
1009
  */
1000
1010
  truncate(e) {
1001
- return new u(
1011
+ return new l(
1002
1012
  BigInt(Math.trunc(Number(this.valueOf() / e.valueOf()))) * e.valueOf()
1003
1013
  );
1004
1014
  }
@@ -1008,9 +1018,9 @@ class u extends j {
1008
1018
  * @returns A string representation of the TimeSpan.
1009
1019
  */
1010
1020
  toString() {
1011
- const e = this.truncate(u.DAY), t = this.truncate(u.HOUR), s = this.truncate(u.MINUTE), i = this.truncate(u.SECOND), o = this.truncate(u.MILLISECOND), l = this.truncate(u.MICROSECOND), d = this.truncate(u.NANOSECOND), f = e, g = t.sub(e), m = s.sub(t), h = i.sub(s), I = o.sub(i), b = l.sub(o), Z = d.sub(l);
1012
- let E = "";
1013
- return f.isZero || (E += `${f.days}d `), g.isZero || (E += `${g.hours}h `), m.isZero || (E += `${m.minutes}m `), h.isZero || (E += `${h.seconds}s `), I.isZero || (E += `${I.milliseconds}ms `), b.isZero || (E += `${b.microseconds}µs `), Z.isZero || (E += `${Z.nanoseconds}ns`), E.trim();
1021
+ const e = this.truncate(l.DAY), t = this.truncate(l.HOUR), n = this.truncate(l.MINUTE), i = this.truncate(l.SECOND), a = this.truncate(l.MILLISECOND), c = this.truncate(l.MICROSECOND), d = this.truncate(l.NANOSECOND), y = e, f = t.sub(e), p = n.sub(t), b = i.sub(n), h = a.sub(i), T = c.sub(a), x = d.sub(c);
1022
+ let C = "";
1023
+ return y.isZero || (C += `${y.days}d `), f.isZero || (C += `${f.hours}h `), p.isZero || (C += `${p.minutes}m `), b.isZero || (C += `${b.seconds}s `), h.isZero || (C += `${h.milliseconds}ms `), T.isZero || (C += `${T.microseconds}µs `), x.isZero || (C += `${x.nanoseconds}ns`), C.trim();
1014
1024
  }
1015
1025
  /**
1016
1026
  * Multiplies the TimeSpan by a scalar value.
@@ -1019,31 +1029,40 @@ class u extends j {
1019
1029
  * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
1020
1030
  */
1021
1031
  mult(e) {
1022
- return new u(this.valueOf() * BigInt(e));
1032
+ return new l(U(this.valueOf(), e));
1033
+ }
1034
+ /**
1035
+ * Divides the TimeSpan by a scalar value.
1036
+ *
1037
+ * @param value - The scalar value to divide by.
1038
+ * @returns A new TimeSpan that is this TimeSpan divided by the provided value.
1039
+ */
1040
+ div(e) {
1041
+ return new l(te(this.valueOf(), e));
1023
1042
  }
1024
1043
  /** @returns the decimal number of days in the TimeSpan. */
1025
1044
  get days() {
1026
- return Number(this.valueOf()) / Number(u.DAY.valueOf());
1045
+ return Number(this.valueOf()) / Number(l.DAY.valueOf());
1027
1046
  }
1028
1047
  /** @returns the decimal number of hours in the TimeSpan. */
1029
1048
  get hours() {
1030
- return Number(this.valueOf()) / Number(u.HOUR.valueOf());
1049
+ return Number(this.valueOf()) / Number(l.HOUR.valueOf());
1031
1050
  }
1032
1051
  /** @returns the decimal number of minutes in the TimeSpan. */
1033
1052
  get minutes() {
1034
- return Number(this.valueOf()) / Number(u.MINUTE.valueOf());
1053
+ return Number(this.valueOf()) / Number(l.MINUTE.valueOf());
1035
1054
  }
1036
1055
  /** @returns The number of seconds in the TimeSpan. */
1037
1056
  get seconds() {
1038
- return Number(this.valueOf()) / Number(u.SECOND.valueOf());
1057
+ return Number(this.valueOf()) / Number(l.SECOND.valueOf());
1039
1058
  }
1040
1059
  /** @returns The number of milliseconds in the TimeSpan. */
1041
1060
  get milliseconds() {
1042
- return Number(this.valueOf()) / Number(u.MILLISECOND.valueOf());
1061
+ return Number(this.valueOf()) / Number(l.MILLISECOND.valueOf());
1043
1062
  }
1044
1063
  /** @returns The number of microseconds in the TimeSpan. */
1045
1064
  get microseconds() {
1046
- return Number(this.valueOf()) / Number(u.MICROSECOND.valueOf());
1065
+ return Number(this.valueOf()) / Number(l.MICROSECOND.valueOf());
1047
1066
  }
1048
1067
  /** @returns The number of nanoseconds in the TimeSpan. */
1049
1068
  get nanoseconds() {
@@ -1063,7 +1082,7 @@ class u extends j {
1063
1082
  * @returns True if the TimeSpans are equal, false otherwise.
1064
1083
  */
1065
1084
  equals(e) {
1066
- return this.valueOf() === new u(e).valueOf();
1085
+ return this.valueOf() === new l(e).valueOf();
1067
1086
  }
1068
1087
  /**
1069
1088
  * Adds a TimeSpan to the TimeSpan.
@@ -1071,7 +1090,7 @@ class u extends j {
1071
1090
  * @returns A new TimeSpan representing the sum of the two TimeSpans.
1072
1091
  */
1073
1092
  add(e) {
1074
- return new u(this.valueOf() + new u(e).valueOf());
1093
+ return new l(this.valueOf() + new l(e).valueOf());
1075
1094
  }
1076
1095
  /**
1077
1096
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -1079,7 +1098,7 @@ class u extends j {
1079
1098
  * @param other
1080
1099
  */
1081
1100
  sub(e) {
1082
- return new u(this.valueOf() - new u(e).valueOf());
1101
+ return new l(this.valueOf() - new l(e).valueOf());
1083
1102
  }
1084
1103
  /**
1085
1104
  * Creates a TimeSpan representing the given number of nanoseconds.
@@ -1088,10 +1107,10 @@ class u extends j {
1088
1107
  * @returns A TimeSpan representing the given number of nanoseconds.
1089
1108
  */
1090
1109
  static nanoseconds(e = 1) {
1091
- return new u(e);
1110
+ return new l(e);
1092
1111
  }
1093
1112
  /** A nanosecond. */
1094
- static NANOSECOND = u.nanoseconds(1);
1113
+ static NANOSECOND = l.nanoseconds(1);
1095
1114
  /**
1096
1115
  * Creates a TimeSpan representing the given number of microseconds.
1097
1116
  *
@@ -1099,10 +1118,10 @@ class u extends j {
1099
1118
  * @returns A TimeSpan representing the given number of microseconds.
1100
1119
  */
1101
1120
  static microseconds(e = 1) {
1102
- return u.nanoseconds(C(e, 1e3));
1121
+ return l.nanoseconds(U(e, 1e3));
1103
1122
  }
1104
1123
  /** A microsecond. */
1105
- static MICROSECOND = u.microseconds(1);
1124
+ static MICROSECOND = l.microseconds(1);
1106
1125
  /**
1107
1126
  * Creates a TimeSpan representing the given number of milliseconds.
1108
1127
  *
@@ -1110,10 +1129,10 @@ class u extends j {
1110
1129
  * @returns A TimeSpan representing the given number of milliseconds.
1111
1130
  */
1112
1131
  static milliseconds(e = 1) {
1113
- return u.microseconds(C(e, 1e3));
1132
+ return l.microseconds(U(e, 1e3));
1114
1133
  }
1115
1134
  /** A millisecond. */
1116
- static MILLISECOND = u.milliseconds(1);
1135
+ static MILLISECOND = l.milliseconds(1);
1117
1136
  /**
1118
1137
  * Creates a TimeSpan representing the given number of seconds.
1119
1138
  *
@@ -1121,10 +1140,10 @@ class u extends j {
1121
1140
  * @returns A TimeSpan representing the given number of seconds.
1122
1141
  */
1123
1142
  static seconds(e = 1) {
1124
- return u.milliseconds(C(e, 1e3));
1143
+ return l.milliseconds(U(e, 1e3));
1125
1144
  }
1126
1145
  /** A second. */
1127
- static SECOND = u.seconds(1);
1146
+ static SECOND = l.seconds(1);
1128
1147
  /**
1129
1148
  * Creates a TimeSpan representing the given number of minutes.
1130
1149
  *
@@ -1132,10 +1151,10 @@ class u extends j {
1132
1151
  * @returns A TimeSpan representing the given number of minutes.
1133
1152
  */
1134
1153
  static minutes(e = 1) {
1135
- return u.seconds(C(e, 60));
1154
+ return l.seconds(U(e, 60));
1136
1155
  }
1137
1156
  /** A minute. */
1138
- static MINUTE = u.minutes(1);
1157
+ static MINUTE = l.minutes(1);
1139
1158
  /**
1140
1159
  * Creates a TimeSpan representing the given number of hours.
1141
1160
  *
@@ -1143,10 +1162,10 @@ class u extends j {
1143
1162
  * @returns A TimeSpan representing the given number of hours.
1144
1163
  */
1145
1164
  static hours(e) {
1146
- return u.minutes(C(e, 60));
1165
+ return l.minutes(U(e, 60));
1147
1166
  }
1148
1167
  /** Represents an hour. */
1149
- static HOUR = u.hours(1);
1168
+ static HOUR = l.hours(1);
1150
1169
  /**
1151
1170
  * Creates a TimeSpan representing the given number of days.
1152
1171
  *
@@ -1154,25 +1173,28 @@ class u extends j {
1154
1173
  * @returns A TimeSpan representing the given number of days.
1155
1174
  */
1156
1175
  static days(e) {
1157
- return u.hours(C(e, 24));
1176
+ return l.hours(U(e, 24));
1158
1177
  }
1159
1178
  /** Represents a day. */
1160
- static DAY = u.days(1);
1179
+ static DAY = l.days(1);
1161
1180
  /** The maximum possible value for a TimeSpan. */
1162
- static MAX = new u((1n << 63n) - 1n);
1181
+ static MAX = new l((1n << 63n) - 1n);
1163
1182
  /** The minimum possible value for a TimeSpan. */
1164
- static MIN = new u(0);
1183
+ static MIN = new l(0);
1165
1184
  /** The zero value for a TimeSpan. */
1166
- static ZERO = new u(0);
1185
+ static ZERO = new l(0);
1167
1186
  /** A zod schema for validating and transforming timespans */
1168
- static z = r.union([
1169
- r.object({ value: r.bigint() }).transform((e) => new u(e.value)),
1170
- r.string().transform((e) => new u(BigInt(e))),
1171
- r.number().transform((e) => new u(e)),
1172
- r.instanceof(u)
1187
+ static z = s.union([
1188
+ s.object({ value: s.bigint() }).transform((e) => new l(e.value)),
1189
+ s.string().transform((e) => new l(BigInt(e))),
1190
+ s.number().transform((e) => new l(e)),
1191
+ s.bigint().transform((e) => new l(e)),
1192
+ s.instanceof(l),
1193
+ s.instanceof(o).transform((e) => new l(e)),
1194
+ s.custom((e) => e instanceof S).transform((e) => new l(e))
1173
1195
  ]);
1174
- }
1175
- let me = class $ extends j {
1196
+ };
1197
+ class S extends q {
1176
1198
  constructor(e) {
1177
1199
  super(e.valueOf());
1178
1200
  }
@@ -1182,7 +1204,7 @@ let me = class $ extends j {
1182
1204
  }
1183
1205
  /** @returns The number of seconds in the Rate. */
1184
1206
  equals(e) {
1185
- return this.valueOf() === new $(e).valueOf();
1207
+ return this.valueOf() === new S(e).valueOf();
1186
1208
  }
1187
1209
  /**
1188
1210
  * Calculates the period of the Rate as a TimeSpan.
@@ -1190,7 +1212,7 @@ let me = class $ extends j {
1190
1212
  * @returns A TimeSpan representing the period of the Rate.
1191
1213
  */
1192
1214
  get period() {
1193
- return u.seconds(1 / this.valueOf());
1215
+ return g.seconds(1 / this.valueOf());
1194
1216
  }
1195
1217
  /**
1196
1218
  * Calculates the number of samples in the given TimeSpan at this rate.
@@ -1199,7 +1221,7 @@ let me = class $ extends j {
1199
1221
  * @returns The number of samples in the given TimeSpan at this rate.
1200
1222
  */
1201
1223
  sampleCount(e) {
1202
- return new u(e).seconds * this.valueOf();
1224
+ return new g(e).seconds * this.valueOf();
1203
1225
  }
1204
1226
  /**
1205
1227
  * Calculates the number of bytes in the given TimeSpan at this rate.
@@ -1209,7 +1231,7 @@ let me = class $ extends j {
1209
1231
  * @returns The number of bytes in the given TimeSpan at this rate.
1210
1232
  */
1211
1233
  byteCount(e, t) {
1212
- return this.sampleCount(e) * new O(t).valueOf();
1234
+ return this.sampleCount(e) * new I(t).valueOf();
1213
1235
  }
1214
1236
  /**
1215
1237
  * Calculates a TimeSpan given the number of samples at this rate.
@@ -1218,7 +1240,7 @@ let me = class $ extends j {
1218
1240
  * @returns A TimeSpan that corresponds to the given number of samples.
1219
1241
  */
1220
1242
  span(e) {
1221
- return u.seconds(e / this.valueOf());
1243
+ return g.seconds(e / this.valueOf());
1222
1244
  }
1223
1245
  /**
1224
1246
  * Calculates a TimeSpan given the number of bytes at this rate.
@@ -1230,6 +1252,42 @@ let me = class $ extends j {
1230
1252
  byteSpan(e, t) {
1231
1253
  return this.span(e.valueOf() / t.valueOf());
1232
1254
  }
1255
+ /**
1256
+ * Adds another Rate to this Rate.
1257
+ *
1258
+ * @param other - The Rate to add.
1259
+ * @returns A new Rate representing the sum of the two rates.
1260
+ */
1261
+ add(e) {
1262
+ return new S(ee(this.valueOf(), e.valueOf()));
1263
+ }
1264
+ /**
1265
+ * Subtracts another Rate from this Rate.
1266
+ *
1267
+ * @param other - The Rate to subtract.
1268
+ * @returns A new Rate representing the difference of the two rates.
1269
+ */
1270
+ sub(e) {
1271
+ return new S(_(this.valueOf(), e.valueOf()));
1272
+ }
1273
+ /**
1274
+ * Multiplies this Rate by a scalar value.
1275
+ *
1276
+ * @param value - The scalar value to multiply by.
1277
+ * @returns A new Rate representing this Rate multiplied by the value.
1278
+ */
1279
+ mult(e) {
1280
+ return new S(U(this.valueOf(), e));
1281
+ }
1282
+ /**
1283
+ * Divides this Rate by a scalar value.
1284
+ *
1285
+ * @param value - The scalar value to divide by.
1286
+ * @returns A new Rate representing this Rate divided by the value.
1287
+ */
1288
+ div(e) {
1289
+ return new S(te(this.valueOf(), e));
1290
+ }
1233
1291
  /**
1234
1292
  * Creates a Rate representing the given number of Hz.
1235
1293
  *
@@ -1237,7 +1295,7 @@ let me = class $ extends j {
1237
1295
  * @returns A Rate representing the given number of Hz.
1238
1296
  */
1239
1297
  static hz(e) {
1240
- return new $(e);
1298
+ return new S(e);
1241
1299
  }
1242
1300
  /**
1243
1301
  * Creates a Rate representing the given number of kHz.
@@ -1246,14 +1304,15 @@ let me = class $ extends j {
1246
1304
  * @returns A Rate representing the given number of kHz.
1247
1305
  */
1248
1306
  static khz(e) {
1249
- return $.hz(e * 1e3);
1307
+ return S.hz(e * 1e3);
1250
1308
  }
1251
1309
  /** A zod schema for validating and transforming rates */
1252
- static z = r.union([
1253
- r.number().transform((e) => new $(e)),
1254
- r.instanceof($)
1310
+ static z = s.union([
1311
+ s.number().transform((e) => new S(e)),
1312
+ s.instanceof(S)
1255
1313
  ]);
1256
- }, O = class x extends j {
1314
+ }
1315
+ let I = class N extends q {
1257
1316
  /**
1258
1317
  * Creates a Density representing the given number of bytes per value.
1259
1318
  *
@@ -1280,27 +1339,62 @@ let me = class $ extends j {
1280
1339
  * @returns A Size representing the given number of values.
1281
1340
  */
1282
1341
  size(e) {
1283
- return new p(e * this.valueOf());
1342
+ return new oe(e * this.valueOf());
1343
+ }
1344
+ /**
1345
+ * Adds another Density to this Density.
1346
+ *
1347
+ * @param other - The Density to add.
1348
+ * @returns A new Density representing the sum of the two densities.
1349
+ */
1350
+ add(e) {
1351
+ return new N(ee(this.valueOf(), e.valueOf()));
1352
+ }
1353
+ /**
1354
+ * Subtracts another Density from this Density.
1355
+ *
1356
+ * @param other - The Density to subtract.
1357
+ * @returns A new Density representing the difference of the two densities.
1358
+ */
1359
+ sub(e) {
1360
+ return new N(_(this.valueOf(), e.valueOf()));
1361
+ }
1362
+ /**
1363
+ * Multiplies this Density by a scalar value.
1364
+ *
1365
+ * @param value - The scalar value to multiply by.
1366
+ * @returns A new Density representing this Density multiplied by the value.
1367
+ */
1368
+ mult(e) {
1369
+ return new N(U(this.valueOf(), e));
1370
+ }
1371
+ /**
1372
+ * Divides this Density by a scalar value.
1373
+ *
1374
+ * @param value - The scalar value to divide by.
1375
+ * @returns A new Density representing this Density divided by the value.
1376
+ */
1377
+ div(e) {
1378
+ return new N(te(this.valueOf(), e));
1284
1379
  }
1285
1380
  /** Unknown/Invalid Density. */
1286
- static UNKNOWN = new x(0);
1381
+ static UNKNOWN = new N(0);
1287
1382
  /** 128 bits per value. */
1288
- static BIT128 = new x(16);
1383
+ static BIT128 = new N(16);
1289
1384
  /** 64 bits per value. */
1290
- static BIT64 = new x(8);
1385
+ static BIT64 = new N(8);
1291
1386
  /** 32 bits per value. */
1292
- static BIT32 = new x(4);
1387
+ static BIT32 = new N(4);
1293
1388
  /** 16 bits per value. */
1294
- static BIT16 = new x(2);
1389
+ static BIT16 = new N(2);
1295
1390
  /** 8 bits per value. */
1296
- static BIT8 = new x(1);
1391
+ static BIT8 = new N(1);
1297
1392
  /** A zod schema for validating and transforming densities */
1298
- static z = r.union([
1299
- r.number().transform((e) => new x(e)),
1300
- r.instanceof(x)
1393
+ static z = s.union([
1394
+ s.number().transform((e) => new N(e)),
1395
+ s.instanceof(N)
1301
1396
  ]);
1302
- };
1303
- class v {
1397
+ }, F = class E {
1304
1398
  /**
1305
1399
  * The starting TimeStamp of the TimeRange.
1306
1400
  *
@@ -1326,11 +1420,11 @@ class v {
1326
1420
  * @param end - A TimeStamp representing the end of the range.
1327
1421
  */
1328
1422
  constructor(e, t) {
1329
- typeof e == "object" && "start" in e ? (this.start = new y(e.start), this.end = new y(e.end)) : (this.start = new y(e), this.end = new y(t));
1423
+ typeof e == "object" && "start" in e ? (this.start = new o(e.start), this.end = new o(e.end)) : (this.start = new o(e), this.end = new o(t));
1330
1424
  }
1331
1425
  /** @returns The TimeSpan occupied by the TimeRange. */
1332
1426
  get span() {
1333
- return new u(this.end.valueOf() - this.start.valueOf());
1427
+ return new g(this.end.valueOf() - this.start.valueOf());
1334
1428
  }
1335
1429
  /**
1336
1430
  * Checks if the timestamp is valid i.e. the start is before the end.
@@ -1368,7 +1462,7 @@ class v {
1368
1462
  * @returns A TimeRange with the start and end swapped.
1369
1463
  */
1370
1464
  swap() {
1371
- return new v(this.end, this.start);
1465
+ return new E(this.end, this.start);
1372
1466
  }
1373
1467
  get numericBounds() {
1374
1468
  return {
@@ -1382,11 +1476,11 @@ class v {
1382
1476
  * @param other - The TimeRange to compare to.
1383
1477
  * @returns True if the TimeRange is equal to the given TimeRange.
1384
1478
  */
1385
- equals(e, t = u.ZERO) {
1479
+ equals(e, t = g.ZERO) {
1386
1480
  if (t.isZero)
1387
1481
  return this.start.equals(e.start) && this.end.equals(e.end);
1388
- let s = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1389
- return s < 0 && (s = -s), i < 0 && (i = -i), s <= t.valueOf() && i <= t.valueOf();
1482
+ let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1483
+ return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
1390
1484
  }
1391
1485
  /**
1392
1486
  * Returns a string representation of the TimeRange.
@@ -1415,16 +1509,16 @@ class v {
1415
1509
  * checking for overlap.
1416
1510
  * @returns True if the two TimeRanges overlap, false otherwise.
1417
1511
  */
1418
- overlapsWith(e, t = u.ZERO) {
1512
+ overlapsWith(e, t = g.ZERO) {
1419
1513
  e = e.makeValid();
1420
- const s = this.makeValid();
1514
+ const n = this.makeValid();
1421
1515
  if (this.equals(e)) return !0;
1422
- if (e.end.equals(s.start) || s.end.equals(e.start)) return !1;
1423
- const i = y.max(s.start, e.start), o = y.min(s.end, e.end);
1424
- return o.before(i) ? !1 : new u(o.sub(i)).greaterThanOrEqual(t);
1516
+ if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1517
+ const i = o.max(n.start, e.start), a = o.min(n.end, e.end);
1518
+ return a.before(i) ? !1 : new g(a.sub(i)).greaterThanOrEqual(t);
1425
1519
  }
1426
1520
  contains(e) {
1427
- return e instanceof v ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1521
+ return e instanceof E ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1428
1522
  }
1429
1523
  /**
1430
1524
  * Returns a new TimeRange that is bound by the given TimeRange.
@@ -1438,25 +1532,25 @@ class v {
1438
1532
  * console.log(bounded); // TimeRange(1500, 2000)
1439
1533
  */
1440
1534
  boundBy(e) {
1441
- const t = new v(this.start, this.end);
1535
+ const t = new E(this.start, this.end);
1442
1536
  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;
1443
1537
  }
1444
1538
  static max(...e) {
1445
- return new v(
1446
- y.min(...e.map((t) => t.start)),
1447
- y.max(...e.map((t) => t.end))
1539
+ return new E(
1540
+ o.min(...e.map((t) => t.start)),
1541
+ o.max(...e.map((t) => t.end))
1448
1542
  );
1449
1543
  }
1450
1544
  /** The maximum possible time range. */
1451
- static MAX = new v(y.MIN, y.MAX);
1545
+ static MAX = new E(o.MIN, o.MAX);
1452
1546
  /** The minimum possible time range. */
1453
- static MIN = new v(y.MAX, y.MIN);
1547
+ static MIN = new E(o.MAX, o.MIN);
1454
1548
  /** A time range whose start and end are both zero. */
1455
- static ZERO = new v(y.ZERO, y.ZERO);
1549
+ static ZERO = new E(o.ZERO, o.ZERO);
1456
1550
  /** A zod schema for validating and transforming time ranges */
1457
- static z = r.union([
1458
- r.object({ start: y.z, end: y.z }).transform((e) => new v(e.start, e.end)),
1459
- r.instanceof(v)
1551
+ static z = s.union([
1552
+ s.object({ start: o.z, end: o.z }).transform((e) => new E(e.start, e.end)),
1553
+ s.instanceof(E)
1460
1554
  ]);
1461
1555
  /**
1462
1556
  * Sorts two time ranges. The range with the earlier start time is considered less than
@@ -1470,15 +1564,30 @@ class v {
1470
1564
  * equal.
1471
1565
  */
1472
1566
  static sort(e, t) {
1473
- return y.sort(e.start, t.start) || y.sort(e.end, t.end);
1567
+ return o.sort(e.start, t.start) || o.sort(e.end, t.end);
1474
1568
  }
1475
- }
1476
- class a extends j {
1569
+ /**
1570
+ * Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
1571
+ * merges any overlapping ranges.
1572
+ *
1573
+ * @param ranges - The list of `TimeRange`s to simplify.
1574
+ * @returns A list of simplified `TimeRange`s.
1575
+ */
1576
+ static simplify(e) {
1577
+ return e.map((t) => t.makeValid()).sort((t, n) => E.sort(t, n)).reduce((t, n) => {
1578
+ if (n.isZero) return t;
1579
+ if (t.length === 0)
1580
+ return t.push(n), t;
1581
+ const i = t[t.length - 1];
1582
+ return i.overlapsWith(n) || i.end.equals(n.start) ? i.end = o.max(i.end, n.end) : t.push(n), t;
1583
+ }, []);
1584
+ }
1585
+ }, w = class u extends q {
1477
1586
  constructor(e) {
1478
- if (e instanceof a || typeof e == "string" || typeof e.valueOf() == "string")
1587
+ if (e instanceof u || typeof e == "string" || typeof e.valueOf() == "string")
1479
1588
  super(e.valueOf());
1480
1589
  else {
1481
- const t = a.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1590
+ const t = u.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1482
1591
  if (t == null)
1483
1592
  throw new Error(`unable to find data type for ${e.toString()}`);
1484
1593
  super(t.valueOf());
@@ -1488,7 +1597,7 @@ class a extends j {
1488
1597
  * @returns the TypedArray constructor for the DataType.
1489
1598
  */
1490
1599
  get Array() {
1491
- const e = a.ARRAY_CONSTRUCTORS.get(this.toString());
1600
+ const e = u.ARRAY_CONSTRUCTORS.get(this.toString());
1492
1601
  if (e == null)
1493
1602
  throw new Error(`unable to find array constructor for ${this.valueOf()}`);
1494
1603
  return e;
@@ -1515,7 +1624,7 @@ class a extends j {
1515
1624
  * @example DataType.INT32.isVariable // false
1516
1625
  */
1517
1626
  get isVariable() {
1518
- return this.equals(a.JSON) || this.equals(a.STRING);
1627
+ return this.equals(u.JSON) || this.equals(u.STRING);
1519
1628
  }
1520
1629
  /**
1521
1630
  * @returns true if the DataType is numeric.
@@ -1523,7 +1632,7 @@ class a extends j {
1523
1632
  * @example DataType.STRING.isNumeric // false
1524
1633
  */
1525
1634
  get isNumeric() {
1526
- return !this.isVariable && !this.equals(a.UUID);
1635
+ return !this.isVariable && !this.equals(u.UUID);
1527
1636
  }
1528
1637
  /**
1529
1638
  * @returns true if the DataType is an integer.
@@ -1548,7 +1657,7 @@ class a extends j {
1548
1657
  * @example DataType.FLOAT32.density // Density.BIT32
1549
1658
  */
1550
1659
  get density() {
1551
- const e = a.DENSITIES.get(this.toString());
1660
+ const e = u.DENSITIES.get(this.toString());
1552
1661
  if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
1553
1662
  return e;
1554
1663
  }
@@ -1558,7 +1667,7 @@ class a extends j {
1558
1667
  * @example DataType.INT32.isUnsigned // false
1559
1668
  */
1560
1669
  get isUnsignedInteger() {
1561
- return this.equals(a.UINT8) || this.equals(a.UINT16) || this.equals(a.UINT32) || this.equals(a.UINT64);
1670
+ return this.equals(u.UINT8) || this.equals(u.UINT16) || this.equals(u.UINT32) || this.equals(u.UINT64);
1562
1671
  }
1563
1672
  /**
1564
1673
  * @returns true if the DataType is a signed integer.
@@ -1566,11 +1675,11 @@ class a extends j {
1566
1675
  * @example DataType.UINT32.isSigned // false
1567
1676
  */
1568
1677
  get isSignedInteger() {
1569
- return this.equals(a.INT8) || this.equals(a.INT16) || this.equals(a.INT32) || this.equals(a.INT64);
1678
+ return this.equals(u.INT8) || this.equals(u.INT16) || this.equals(u.INT32) || this.equals(u.INT64);
1570
1679
  }
1571
1680
  /** @returns true if the data type can be cast to the other data type without loss of precision. */
1572
1681
  canSafelyCastTo(e) {
1573
- 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;
1682
+ 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(u.INT32) && e.equals(u.FLOAT64) || this.equals(u.INT8) && e.equals(u.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
1574
1683
  }
1575
1684
  /** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
1576
1685
  canCastTo(e) {
@@ -1587,112 +1696,111 @@ class a extends j {
1587
1696
  }
1588
1697
  /** @returns true if the data type uses bigints to store values. */
1589
1698
  get usesBigInt() {
1590
- return a.BIG_INT_TYPES.some((e) => e.equals(this));
1699
+ return u.BIG_INT_TYPES.some((e) => e.equals(this));
1591
1700
  }
1592
1701
  /** Represents an Unknown/Invalid DataType. */
1593
- static UNKNOWN = new a("unknown");
1702
+ static UNKNOWN = new u("unknown");
1594
1703
  /** Represents a 64-bit floating point value. */
1595
- static FLOAT64 = new a("float64");
1704
+ static FLOAT64 = new u("float64");
1596
1705
  /** Represents a 32-bit floating point value. */
1597
- static FLOAT32 = new a("float32");
1706
+ static FLOAT32 = new u("float32");
1598
1707
  /** Represents a 64-bit signed integer value. */
1599
- static INT64 = new a("int64");
1708
+ static INT64 = new u("int64");
1600
1709
  /** Represents a 32-bit signed integer value. */
1601
- static INT32 = new a("int32");
1710
+ static INT32 = new u("int32");
1602
1711
  /** Represents a 16-bit signed integer value. */
1603
- static INT16 = new a("int16");
1712
+ static INT16 = new u("int16");
1604
1713
  /** Represents a 8-bit signed integer value. */
1605
- static INT8 = new a("int8");
1714
+ static INT8 = new u("int8");
1606
1715
  /** Represents a 64-bit unsigned integer value. */
1607
- static UINT64 = new a("uint64");
1716
+ static UINT64 = new u("uint64");
1608
1717
  /** Represents a 32-bit unsigned integer value. */
1609
- static UINT32 = new a("uint32");
1718
+ static UINT32 = new u("uint32");
1610
1719
  /** Represents a 16-bit unsigned integer value. */
1611
- static UINT16 = new a("uint16");
1720
+ static UINT16 = new u("uint16");
1612
1721
  /** Represents a 8-bit unsigned integer value. */
1613
- static UINT8 = new a("uint8");
1722
+ static UINT8 = new u("uint8");
1614
1723
  /** Represents a boolean value. Alias for UINT8. */
1615
1724
  static BOOLEAN = this.UINT8;
1616
1725
  /** Represents a 64-bit unix epoch. */
1617
- static TIMESTAMP = new a("timestamp");
1726
+ static TIMESTAMP = new u("timestamp");
1618
1727
  /** Represents a UUID data type */
1619
- static UUID = new a("uuid");
1728
+ static UUID = new u("uuid");
1620
1729
  /** Represents a string data type. Strings have an unknown density, and are separate
1621
1730
  * by a newline character. */
1622
- static STRING = new a("string");
1731
+ static STRING = new u("string");
1623
1732
  /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1624
1733
  * newline character. */
1625
- static JSON = new a("json");
1734
+ static JSON = new u("json");
1626
1735
  static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
1627
- [a.UINT8.toString(), Uint8Array],
1628
- [a.UINT16.toString(), Uint16Array],
1629
- [a.UINT32.toString(), Uint32Array],
1630
- [a.UINT64.toString(), BigUint64Array],
1631
- [a.FLOAT32.toString(), Float32Array],
1632
- [a.FLOAT64.toString(), Float64Array],
1633
- [a.INT8.toString(), Int8Array],
1634
- [a.INT16.toString(), Int16Array],
1635
- [a.INT32.toString(), Int32Array],
1636
- [a.INT64.toString(), BigInt64Array],
1637
- [a.TIMESTAMP.toString(), BigInt64Array],
1638
- [a.STRING.toString(), Uint8Array],
1639
- [a.JSON.toString(), Uint8Array],
1640
- [a.UUID.toString(), Uint8Array]
1736
+ [u.UINT8.toString(), Uint8Array],
1737
+ [u.UINT16.toString(), Uint16Array],
1738
+ [u.UINT32.toString(), Uint32Array],
1739
+ [u.UINT64.toString(), BigUint64Array],
1740
+ [u.FLOAT32.toString(), Float32Array],
1741
+ [u.FLOAT64.toString(), Float64Array],
1742
+ [u.INT8.toString(), Int8Array],
1743
+ [u.INT16.toString(), Int16Array],
1744
+ [u.INT32.toString(), Int32Array],
1745
+ [u.INT64.toString(), BigInt64Array],
1746
+ [u.TIMESTAMP.toString(), BigInt64Array],
1747
+ [u.STRING.toString(), Uint8Array],
1748
+ [u.JSON.toString(), Uint8Array],
1749
+ [u.UUID.toString(), Uint8Array]
1641
1750
  ]);
1642
1751
  static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
1643
- [Uint8Array.name, a.UINT8],
1644
- [Uint16Array.name, a.UINT16],
1645
- [Uint32Array.name, a.UINT32],
1646
- [BigUint64Array.name, a.UINT64],
1647
- [Float32Array.name, a.FLOAT32],
1648
- [Float64Array.name, a.FLOAT64],
1649
- [Int8Array.name, a.INT8],
1650
- [Int16Array.name, a.INT16],
1651
- [Int32Array.name, a.INT32],
1652
- [BigInt64Array.name, a.INT64]
1752
+ [Uint8Array.name, u.UINT8],
1753
+ [Uint16Array.name, u.UINT16],
1754
+ [Uint32Array.name, u.UINT32],
1755
+ [BigUint64Array.name, u.UINT64],
1756
+ [Float32Array.name, u.FLOAT32],
1757
+ [Float64Array.name, u.FLOAT64],
1758
+ [Int8Array.name, u.INT8],
1759
+ [Int16Array.name, u.INT16],
1760
+ [Int32Array.name, u.INT32],
1761
+ [BigInt64Array.name, u.INT64]
1653
1762
  ]);
1654
1763
  static DENSITIES = /* @__PURE__ */ new Map([
1655
- [a.UINT8.toString(), O.BIT8],
1656
- [a.UINT16.toString(), O.BIT16],
1657
- [a.UINT32.toString(), O.BIT32],
1658
- [a.UINT64.toString(), O.BIT64],
1659
- [a.FLOAT32.toString(), O.BIT32],
1660
- [a.FLOAT64.toString(), O.BIT64],
1661
- [a.INT8.toString(), O.BIT8],
1662
- [a.INT16.toString(), O.BIT16],
1663
- [a.INT32.toString(), O.BIT32],
1664
- [a.INT64.toString(), O.BIT64],
1665
- [a.TIMESTAMP.toString(), O.BIT64],
1666
- [a.STRING.toString(), O.UNKNOWN],
1667
- [a.JSON.toString(), O.UNKNOWN],
1668
- [a.UUID.toString(), O.BIT128]
1764
+ [u.UINT8.toString(), I.BIT8],
1765
+ [u.UINT16.toString(), I.BIT16],
1766
+ [u.UINT32.toString(), I.BIT32],
1767
+ [u.UINT64.toString(), I.BIT64],
1768
+ [u.FLOAT32.toString(), I.BIT32],
1769
+ [u.FLOAT64.toString(), I.BIT64],
1770
+ [u.INT8.toString(), I.BIT8],
1771
+ [u.INT16.toString(), I.BIT16],
1772
+ [u.INT32.toString(), I.BIT32],
1773
+ [u.INT64.toString(), I.BIT64],
1774
+ [u.TIMESTAMP.toString(), I.BIT64],
1775
+ [u.STRING.toString(), I.UNKNOWN],
1776
+ [u.JSON.toString(), I.UNKNOWN],
1777
+ [u.UUID.toString(), I.BIT128]
1669
1778
  ]);
1670
1779
  /** All the data types. */
1671
1780
  static ALL = [
1672
- a.UNKNOWN,
1673
- a.FLOAT64,
1674
- a.FLOAT32,
1675
- a.INT64,
1676
- a.INT32,
1677
- a.INT16,
1678
- a.INT8,
1679
- a.UINT64,
1680
- a.UINT32,
1681
- a.UINT16,
1682
- a.UINT8,
1683
- a.TIMESTAMP,
1684
- a.UUID,
1685
- a.STRING,
1686
- a.JSON
1781
+ u.UNKNOWN,
1782
+ u.FLOAT64,
1783
+ u.FLOAT32,
1784
+ u.INT64,
1785
+ u.INT32,
1786
+ u.INT16,
1787
+ u.INT8,
1788
+ u.UINT64,
1789
+ u.UINT32,
1790
+ u.UINT16,
1791
+ u.UINT8,
1792
+ u.TIMESTAMP,
1793
+ u.UUID,
1794
+ u.STRING,
1795
+ u.JSON
1687
1796
  ];
1688
- static BIG_INT_TYPES = [a.INT64, a.UINT64, a.TIMESTAMP];
1797
+ static BIG_INT_TYPES = [u.INT64, u.UINT64, u.TIMESTAMP];
1689
1798
  /** A zod schema for a DataType. */
1690
- static z = r.union([
1691
- r.string().transform((e) => new a(e)),
1692
- r.instanceof(a)
1799
+ static z = s.union([
1800
+ s.string().transform((e) => new u(e)),
1801
+ s.instanceof(u)
1693
1802
  ]);
1694
- }
1695
- class p extends j {
1803
+ }, oe = class m extends q {
1696
1804
  constructor(e) {
1697
1805
  super(e.valueOf());
1698
1806
  }
@@ -1706,41 +1814,59 @@ class p extends j {
1706
1814
  }
1707
1815
  /** @returns a new Size representing the sum of the two Sizes. */
1708
1816
  add(e) {
1709
- return p.bytes(this.valueOf() + e.valueOf());
1817
+ return new m(ee(this.valueOf(), e.valueOf()));
1710
1818
  }
1711
1819
  /** @returns a new Size representing the difference of the two Sizes. */
1712
1820
  sub(e) {
1713
- return p.bytes(this.valueOf() - e.valueOf());
1821
+ return new m(_(this.valueOf(), e.valueOf()));
1822
+ }
1823
+ /**
1824
+ * Multiplies this Size by a scalar value.
1825
+ *
1826
+ * @param value - The scalar value to multiply by.
1827
+ * @returns A new Size representing this Size multiplied by the value.
1828
+ */
1829
+ mult(e) {
1830
+ return new m(U(this.valueOf(), e));
1831
+ }
1832
+ /**
1833
+ * Divides this Size by a scalar value.
1834
+ *
1835
+ * @param value - The scalar value to divide by.
1836
+ * @returns A new Size representing this Size divided by the value.
1837
+ */
1838
+ div(e) {
1839
+ return new m(te(this.valueOf(), e));
1714
1840
  }
1715
1841
  /** @returns a new Size representing the truncated value of the Size. */
1716
1842
  truncate(e) {
1717
- return new p(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
1843
+ return new m(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
1718
1844
  }
1719
1845
  /** @returns a new Size representing the remainder of the Size. */
1720
1846
  remainder(e) {
1721
- return p.bytes(this.valueOf() % e.valueOf());
1847
+ return m.bytes(this.valueOf() % e.valueOf());
1722
1848
  }
1723
1849
  /** @returns the number of gigabytes in the Size. */
1724
1850
  get gigabytes() {
1725
- return this.valueOf() / p.GIGABYTE.valueOf();
1851
+ return this.valueOf() / m.GIGABYTE.valueOf();
1726
1852
  }
1727
1853
  /** @returns the number of megabytes in the Size. */
1728
1854
  get megabytes() {
1729
- return this.valueOf() / p.MEGABYTE.valueOf();
1855
+ return this.valueOf() / m.MEGABYTE.valueOf();
1730
1856
  }
1731
1857
  /** @returns the number of kilobytes in the Size. */
1732
1858
  get kilobytes() {
1733
- return this.valueOf() / p.KILOBYTE.valueOf();
1859
+ return this.valueOf() / m.KILOBYTE.valueOf();
1734
1860
  }
1735
1861
  /** @returns the number of terabytes in the Size. */
1736
1862
  get terabytes() {
1737
- return this.valueOf() / p.TERABYTE.valueOf();
1863
+ return this.valueOf() / m.TERABYTE.valueOf();
1738
1864
  }
1739
1865
  /** @returns a nicely formatted string representation of the Size. */
1740
1866
  toString() {
1741
- const e = this.truncate(p.TERABYTE), t = this.truncate(p.GIGABYTE), s = this.truncate(p.MEGABYTE), i = this.truncate(p.KILOBYTE), o = this.truncate(p.BYTE), l = e, d = t.sub(e), f = s.sub(t), g = i.sub(s), m = o.sub(i);
1742
- let h = "";
1743
- return l.isZero || (h += `${l.terabytes}TB `), d.isZero || (h += `${d.gigabytes}GB `), f.isZero || (h += `${f.megabytes}MB `), g.isZero || (h += `${g.kilobytes}KB `), (!m.isZero || h === "") && (h += `${m.valueOf()}B`), h.trim();
1867
+ const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), a = this.truncate(m.BYTE), c = e, d = t.sub(e), y = n.sub(t), f = i.sub(n), p = a.sub(i);
1868
+ let b = "";
1869
+ return c.isZero || (b += `${c.terabytes}TB `), d.isZero || (b += `${d.gigabytes}GB `), y.isZero || (b += `${y.megabytes}MB `), f.isZero || (b += `${f.kilobytes}KB `), (!p.isZero || b === "") && (b += `${p.valueOf()}B`), b.trim();
1744
1870
  }
1745
1871
  /**
1746
1872
  * Creates a Size from the given number of bytes.
@@ -1749,10 +1875,10 @@ class p extends j {
1749
1875
  * @returns A Size representing the given number of bytes.
1750
1876
  */
1751
1877
  static bytes(e = 1) {
1752
- return new p(e);
1878
+ return new m(e);
1753
1879
  }
1754
1880
  /** A single byte */
1755
- static BYTE = new p(1);
1881
+ static BYTE = new m(1);
1756
1882
  /**
1757
1883
  * Creates a Size from the given number if kilobytes.
1758
1884
  *
@@ -1760,10 +1886,10 @@ class p extends j {
1760
1886
  * @returns A Size representing the given number of kilobytes.
1761
1887
  */
1762
1888
  static kilobytes(e = 1) {
1763
- return p.bytes(e.valueOf() * 1e3);
1889
+ return m.bytes(e.valueOf() * 1e3);
1764
1890
  }
1765
1891
  /** A kilobyte */
1766
- static KILOBYTE = p.kilobytes(1);
1892
+ static KILOBYTE = m.kilobytes(1);
1767
1893
  /**
1768
1894
  * Creates a Size from the given number of megabytes.
1769
1895
  *
@@ -1771,10 +1897,10 @@ class p extends j {
1771
1897
  * @returns A Size representing the given number of megabytes.
1772
1898
  */
1773
1899
  static megabytes(e = 1) {
1774
- return p.kilobytes(e.valueOf() * 1e3);
1900
+ return m.kilobytes(e.valueOf() * 1e3);
1775
1901
  }
1776
1902
  /** A megabyte */
1777
- static MEGABYTE = p.megabytes(1);
1903
+ static MEGABYTE = m.megabytes(1);
1778
1904
  /**
1779
1905
  * Creates a Size from the given number of gigabytes.
1780
1906
  *
@@ -1782,10 +1908,10 @@ class p extends j {
1782
1908
  * @returns A Size representing the given number of gigabytes.
1783
1909
  */
1784
1910
  static gigabytes(e = 1) {
1785
- return p.megabytes(e.valueOf() * 1e3);
1911
+ return m.megabytes(e.valueOf() * 1e3);
1786
1912
  }
1787
1913
  /** A gigabyte */
1788
- static GIGABYTE = p.gigabytes(1);
1914
+ static GIGABYTE = m.gigabytes(1);
1789
1915
  /**
1790
1916
  * Creates a Size from the given number of terabytes.
1791
1917
  *
@@ -1793,65 +1919,65 @@ class p extends j {
1793
1919
  * @returns A Size representing the given number of terabytes.
1794
1920
  */
1795
1921
  static terabytes(e) {
1796
- return p.gigabytes(e.valueOf() * 1e3);
1922
+ return m.gigabytes(e.valueOf() * 1e3);
1797
1923
  }
1798
1924
  /** A terabyte. */
1799
- static TERABYTE = p.terabytes(1);
1925
+ static TERABYTE = m.terabytes(1);
1800
1926
  /** The zero value for Size */
1801
- static ZERO = new p(0);
1927
+ static ZERO = new m(0);
1802
1928
  /** A zod schema for a Size. */
1803
- static z = r.union([
1804
- r.number().transform((e) => new p(e)),
1805
- r.instanceof(p)
1929
+ static z = s.union([
1930
+ s.number().transform((e) => new m(e)),
1931
+ s.instanceof(m)
1806
1932
  ]);
1807
1933
  /** @returns true if the Size is zero. */
1808
1934
  get isZero() {
1809
1935
  return this.valueOf() === 0;
1810
1936
  }
1811
- }
1812
- r.union([
1813
- r.instanceof(Uint8Array),
1814
- r.instanceof(Uint16Array),
1815
- r.instanceof(Uint32Array),
1816
- r.instanceof(BigUint64Array),
1817
- r.instanceof(Float32Array),
1818
- r.instanceof(Float64Array),
1819
- r.instanceof(Int8Array),
1820
- r.instanceof(Int16Array),
1821
- r.instanceof(Int32Array),
1822
- r.instanceof(BigInt64Array)
1937
+ };
1938
+ s.union([
1939
+ s.instanceof(Uint8Array),
1940
+ s.instanceof(Uint16Array),
1941
+ s.instanceof(Uint32Array),
1942
+ s.instanceof(BigUint64Array),
1943
+ s.instanceof(Float32Array),
1944
+ s.instanceof(Float64Array),
1945
+ s.instanceof(Int8Array),
1946
+ s.instanceof(Int16Array),
1947
+ s.instanceof(Int32Array),
1948
+ s.instanceof(BigInt64Array)
1823
1949
  ]);
1824
- const Me = (n) => {
1825
- const e = typeof n;
1826
- return e === "string" || e === "number" || e === "boolean" || e === "bigint" || n instanceof y || n instanceof u || n instanceof Date;
1827
- }, Ct = (n, e, t, s = 0) => n.usesBigInt && !e.usesBigInt ? Number(t) - Number(s) : !n.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(s.valueOf()) : G(t, -s), G = (n, e) => e == 0 ? n : n == 0 ? e : typeof n == "bigint" && typeof e == "bigint" || typeof n == "number" && typeof e == "number" ? n + e : Number(n) + Number(e), Bt = /^(?:[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;
1828
- function $t(n) {
1829
- return typeof n == "string" && Bt.test(n);
1950
+ const Pe = (r) => {
1951
+ const e = typeof r;
1952
+ return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof o || r instanceof g || r instanceof Date;
1953
+ }, jt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : H(t, -n), H = (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), qt = /^(?:[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;
1954
+ function Ft(r) {
1955
+ return typeof r == "string" && qt.test(r);
1830
1956
  }
1831
- const T = [];
1832
- for (let n = 0; n < 256; ++n)
1833
- T.push((n + 256).toString(16).slice(1));
1834
- function Rt(n, e = 0) {
1835
- return (T[n[e + 0]] + T[n[e + 1]] + T[n[e + 2]] + T[n[e + 3]] + "-" + T[n[e + 4]] + T[n[e + 5]] + "-" + T[n[e + 6]] + T[n[e + 7]] + "-" + T[n[e + 8]] + T[n[e + 9]] + "-" + T[n[e + 10]] + T[n[e + 11]] + T[n[e + 12]] + T[n[e + 13]] + T[n[e + 14]] + T[n[e + 15]]).toLowerCase();
1957
+ const v = [];
1958
+ for (let r = 0; r < 256; ++r)
1959
+ v.push((r + 256).toString(16).slice(1));
1960
+ function Wt(r, e = 0) {
1961
+ return (v[r[e + 0]] + v[r[e + 1]] + v[r[e + 2]] + v[r[e + 3]] + "-" + v[r[e + 4]] + v[r[e + 5]] + "-" + v[r[e + 6]] + v[r[e + 7]] + "-" + v[r[e + 8]] + v[r[e + 9]] + "-" + v[r[e + 10]] + v[r[e + 11]] + v[r[e + 12]] + v[r[e + 13]] + v[r[e + 14]] + v[r[e + 15]]).toLowerCase();
1836
1962
  }
1837
- function Dt(n, e = 0) {
1838
- const t = Rt(n, e);
1839
- if (!$t(t))
1963
+ function Zt(r, e = 0) {
1964
+ const t = Wt(r, e);
1965
+ if (!Ft(t))
1840
1966
  throw TypeError("Stringified UUID is invalid");
1841
1967
  return t;
1842
1968
  }
1843
1969
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1844
- const Ce = (n, e) => Dt(n, e), A = -1, Lt = r.string().transform(
1845
- (n) => new Uint8Array(
1846
- atob(n).split("").map((e) => e.charCodeAt(0))
1970
+ const ke = (r, e) => Zt(r, e), $ = -1, Vt = s.string().transform(
1971
+ (r) => new Uint8Array(
1972
+ atob(r).split("").map((e) => e.charCodeAt(0))
1847
1973
  ).buffer
1848
- ), Pt = r.union([r.null(), r.undefined()]).transform(() => new Uint8Array().buffer), te = 10, kt = (n, e) => {
1849
- if (n === "number" && !e.isNumeric)
1974
+ ), zt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), ue = 10, Gt = (r, e) => {
1975
+ if (r === "number" && !e.isNumeric)
1850
1976
  throw new Error(`cannot convert series of type ${e.toString()} to number`);
1851
- if (n === "bigint" && !e.usesBigInt)
1977
+ if (r === "bigint" && !e.usesBigInt)
1852
1978
  throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
1853
- }, Be = "sy_x_telem_series";
1854
- class N {
1979
+ }, Ye = "sy_x_telem_series";
1980
+ class M {
1855
1981
  /**
1856
1982
  * A unique identifier for the series. If specified by the user, it is their
1857
1983
  * responsibility to ensure that it is unique. If not specified, a new ID will be
@@ -1862,7 +1988,7 @@ class N {
1862
1988
  * A discriminator used for identifying instances of the series class even
1863
1989
  * when bundlers mangle the class name.
1864
1990
  */
1865
- discriminator = Be;
1991
+ discriminator = Ye;
1866
1992
  /** The data type of the series. */
1867
1993
  dataType;
1868
1994
  /**
@@ -1878,18 +2004,24 @@ class N {
1878
2004
  /** The underlying data. */
1879
2005
  _data;
1880
2006
  /** The time range occupied by the series' data. */
1881
- timeRange = v.ZERO;
2007
+ timeRange = F.ZERO;
1882
2008
  /**
1883
2009
  * Alignment defines the location of the series relative to other series in a logical
1884
2010
  * group. Useful for defining the position of the series within a channel's data.
1885
2011
  */
1886
2012
  alignment = 0n;
2013
+ /**
2014
+ * Alignment multiple defines the number of alignment steps taken per sample. This is
2015
+ * useful for when the samples in a series represent a partial view of the raw data
2016
+ * i.e. decimation or averaging.
2017
+ */
2018
+ alignmentMultiple = 1n;
1887
2019
  /** A cached minimum value. */
1888
2020
  cachedMin;
1889
2021
  /** A cached maximum value. */
1890
2022
  cachedMax;
1891
2023
  /** The write position of the buffer. */
1892
- writePos = A;
2024
+ writePos = $;
1893
2025
  /** Tracks the number of entities currently using this array. */
1894
2026
  _refCount = 0;
1895
2027
  /** Caches the length of the array for variable length data types. */
@@ -1900,23 +2032,23 @@ class N {
1900
2032
  * A zod schema that can be used to validate that a particular value
1901
2033
  * can be constructed into a series.
1902
2034
  */
1903
- static crudeZ = r.object({
1904
- timeRange: v.z.optional(),
1905
- dataType: a.z,
1906
- alignment: r.coerce.bigint().optional(),
1907
- data: r.union([
1908
- Lt,
1909
- Pt,
1910
- r.instanceof(ArrayBuffer),
1911
- r.instanceof(Uint8Array)
2035
+ static crudeZ = s.object({
2036
+ timeRange: F.z.optional(),
2037
+ dataType: w.z,
2038
+ alignment: s.coerce.bigint().optional(),
2039
+ data: s.union([
2040
+ Vt,
2041
+ zt,
2042
+ s.instanceof(ArrayBuffer),
2043
+ s.instanceof(Uint8Array)
1912
2044
  ]),
1913
- glBufferUsage: Ut.optional().default("static").optional()
2045
+ glBufferUsage: kt.optional().default("static").optional()
1914
2046
  });
1915
2047
  /**
1916
2048
  * A zod schema that validates and constructs a series from it's crude
1917
2049
  * representation.
1918
2050
  */
1919
- static z = N.crudeZ.transform((e) => new N(e));
2051
+ static z = M.crudeZ.transform((e) => new M(e));
1920
2052
  /**
1921
2053
  * The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
1922
2054
  *
@@ -1991,73 +2123,74 @@ class N {
1991
2123
  * @throws Error if data type cannot be inferred from input
1992
2124
  */
1993
2125
  constructor(e) {
1994
- jt(e) && (e = { data: e }), e.data ??= [];
2126
+ Jt(e) && (e = { data: e }), e.data ??= [];
1995
2127
  const {
1996
2128
  dataType: t,
1997
- timeRange: s,
2129
+ timeRange: n,
1998
2130
  sampleOffset: i = 0,
1999
- glBufferUsage: o = "static",
2000
- alignment: l = 0n,
2001
- key: d = Et(),
2131
+ glBufferUsage: a = "static",
2132
+ alignment: c = 0n,
2133
+ alignmentMultiple: d = 1n,
2134
+ key: y = Lt(),
2002
2135
  data: f
2003
2136
  } = e;
2004
- if (Yt(f)) {
2137
+ if (Ht(f)) {
2005
2138
  const h = f;
2006
- this.key = h.key, this.dataType = h.dataType, this.sampleOffset = h.sampleOffset, this.gl = h.gl, this._data = h._data, this.timeRange = h.timeRange, this.alignment = h.alignment, this.cachedMin = h.cachedMin, this.cachedMax = h.cachedMax, this.writePos = h.writePos, this._refCount = h._refCount, this.cachedLength = h.cachedLength;
2139
+ this.key = h.key, this.dataType = h.dataType, this.sampleOffset = h.sampleOffset, this.gl = h.gl, this._data = h._data, this.timeRange = h.timeRange, this.alignment = h.alignment, this.alignmentMultiple = h.alignmentMultiple, this.cachedMin = h.cachedMin, this.cachedMax = h.cachedMax, this.writePos = h.writePos, this._refCount = h._refCount, this.cachedLength = h.cachedLength;
2007
2140
  return;
2008
2141
  }
2009
- const g = Me(f), m = Array.isArray(f);
2010
- if (t != null) this.dataType = new a(t);
2142
+ const p = Pe(f), b = Array.isArray(f);
2143
+ if (t != null) this.dataType = new w(t);
2011
2144
  else {
2012
2145
  if (f instanceof ArrayBuffer)
2013
2146
  throw new Error(
2014
2147
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
2015
2148
  );
2016
- if (m || g) {
2149
+ if (b || p) {
2017
2150
  let h = f;
2018
- if (!g) {
2151
+ if (!p) {
2019
2152
  if (f.length === 0)
2020
2153
  throw new Error(
2021
2154
  "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
2022
2155
  );
2023
2156
  h = f[0];
2024
2157
  }
2025
- if (typeof h == "string") this.dataType = a.STRING;
2026
- else if (typeof h == "number") this.dataType = a.FLOAT64;
2027
- else if (typeof h == "bigint") this.dataType = a.INT64;
2028
- else if (typeof h == "boolean") this.dataType = a.BOOLEAN;
2029
- else if (h instanceof y || h instanceof Date || h instanceof y)
2030
- this.dataType = a.TIMESTAMP;
2031
- else if (typeof h == "object") this.dataType = a.JSON;
2158
+ if (typeof h == "string") this.dataType = w.STRING;
2159
+ else if (typeof h == "number") this.dataType = w.FLOAT64;
2160
+ else if (typeof h == "bigint") this.dataType = w.INT64;
2161
+ else if (typeof h == "boolean") this.dataType = w.BOOLEAN;
2162
+ else if (h instanceof o || h instanceof Date || h instanceof o)
2163
+ this.dataType = w.TIMESTAMP;
2164
+ else if (typeof h == "object") this.dataType = w.JSON;
2032
2165
  else
2033
2166
  throw new Error(
2034
2167
  `cannot infer data type of ${typeof h} when constructing a Series from a JS array`
2035
2168
  );
2036
- } else this.dataType = new a(f);
2169
+ } else this.dataType = new w(f);
2037
2170
  }
2038
- if (!m && !g) this._data = f;
2039
- else if (m && f.length === 0)
2171
+ if (!b && !p) this._data = f;
2172
+ else if (b && f.length === 0)
2040
2173
  this._data = new this.dataType.Array([]).buffer;
2041
2174
  else {
2042
- let h = g ? [f] : f;
2043
- const I = h[0];
2044
- (I instanceof y || I instanceof Date || I instanceof u) && (h = h.map((b) => new y(b).valueOf())), this.dataType.equals(a.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
2175
+ let h = p ? [f] : f;
2176
+ const T = h[0];
2177
+ (T instanceof o || T instanceof Date || T instanceof g) && (h = h.map((x) => new o(x).valueOf())), this.dataType.equals(w.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
2045
2178
  `)}
2046
- `).buffer) : this.dataType.equals(a.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
2047
- `${h.map((b) => ee.encodeString(b)).join(`
2179
+ `).buffer) : this.dataType.equals(w.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
2180
+ `${h.map((x) => ae.encodeString(x)).join(`
2048
2181
  `)}
2049
2182
  `
2050
- ).buffer) : this.dataType.usesBigInt && typeof I == "number" ? this._data = new this.dataType.Array(
2051
- h.map((b) => BigInt(Math.round(b)))
2052
- ).buffer : !this.dataType.usesBigInt && typeof I == "bigint" ? this._data = new this.dataType.Array(
2183
+ ).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
2184
+ h.map((x) => BigInt(Math.round(x)))
2185
+ ).buffer : !this.dataType.usesBigInt && typeof T == "bigint" ? this._data = new this.dataType.Array(
2053
2186
  h.map(Number)
2054
2187
  ).buffer : this._data = new this.dataType.Array(h).buffer;
2055
2188
  }
2056
- this.key = d, this.alignment = l, this.sampleOffset = i ?? 0, this.timeRange = s ?? v.ZERO, this.gl = {
2189
+ this.key = y, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? F.ZERO, this.gl = {
2057
2190
  control: null,
2058
2191
  buffer: null,
2059
2192
  prevBuffer: 0,
2060
- bufferUsage: o
2193
+ bufferUsage: a
2061
2194
  };
2062
2195
  }
2063
2196
  /**
@@ -2067,11 +2200,11 @@ class N {
2067
2200
  * @param args.dataType the data type of the series.
2068
2201
  * @param args.rest the rest of the arguments to pass to the series constructor.
2069
2202
  */
2070
- static alloc({ capacity: e, dataType: t, ...s }) {
2203
+ static alloc({ capacity: e, dataType: t, ...n }) {
2071
2204
  if (e === 0)
2072
2205
  throw new Error("[Series] - cannot allocate an array of length 0");
2073
- const i = new new a(t).Array(e), o = new N({ data: i.buffer, dataType: t, ...s });
2074
- return o.writePos = 0, o;
2206
+ const i = new new w(t).Array(e), a = new M({ data: i.buffer, dataType: t, ...n });
2207
+ return a.writePos = 0, a;
2075
2208
  }
2076
2209
  /**
2077
2210
  * @returns the number of references to this series i.e. the number of times this
@@ -2113,14 +2246,14 @@ class N {
2113
2246
  return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
2114
2247
  }
2115
2248
  writeVariable(e) {
2116
- if (this.writePos === A) return 0;
2117
- const t = this.byteCapacity.valueOf() - this.writePos, s = e.subBytes(0, t);
2118
- return this.writeToUnderlyingData(s), this.writePos += s.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += s.length, this.calculateCachedLength()), s.length;
2249
+ if (this.writePos === $) return 0;
2250
+ const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
2251
+ return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += n.length, this.calculateCachedLength()), n.length;
2119
2252
  }
2120
2253
  writeFixed(e) {
2121
- if (this.writePos === A) return 0;
2122
- const t = this.capacity - this.writePos, s = e.sub(0, t);
2123
- return this.writeToUnderlyingData(s), this.cachedLength = void 0, this.maybeRecomputeMinMax(s), this.writePos += s.length, s.length;
2254
+ if (this.writePos === $) return 0;
2255
+ const t = this.capacity - this.writePos, n = e.sub(0, t);
2256
+ return this.writeToUnderlyingData(n), this.cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
2124
2257
  }
2125
2258
  writeToUnderlyingData(e) {
2126
2259
  this.underlyingData.set(
@@ -2141,7 +2274,7 @@ class N {
2141
2274
  * @returns A typed array containing the series data.
2142
2275
  */
2143
2276
  get data() {
2144
- return this.writePos === A ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2277
+ return this.writePos === $ ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2145
2278
  }
2146
2279
  /**
2147
2280
  * Returns an array of the values in the series as strings.
@@ -2160,16 +2293,16 @@ class N {
2160
2293
  * @returns An array of values parsed from the JSON series.
2161
2294
  */
2162
2295
  parseJSON(e) {
2163
- if (!this.dataType.equals(a.JSON))
2296
+ if (!this.dataType.equals(w.JSON))
2164
2297
  throw new Error("cannot parse non-JSON series as JSON");
2165
- return this.toStrings().map((t) => e.parse(ee.decodeString(t)));
2298
+ return this.toStrings().map((t) => e.parse(ae.decodeString(t)));
2166
2299
  }
2167
2300
  /**
2168
2301
  * Returns the capacity of the series in bytes.
2169
2302
  * @returns The size of the underlying buffer in bytes.
2170
2303
  */
2171
2304
  get byteCapacity() {
2172
- return new p(this.underlyingData.byteLength);
2305
+ return new oe(this.underlyingData.byteLength);
2173
2306
  }
2174
2307
  /**
2175
2308
  * Returns the capacity of the series in samples.
@@ -2185,7 +2318,7 @@ class N {
2185
2318
  * @returns The size of the data in bytes.
2186
2319
  */
2187
2320
  get byteLength() {
2188
- return this.writePos === A ? this.byteCapacity : this.dataType.isVariable ? new p(this.writePos) : this.dataType.density.size(this.writePos);
2321
+ return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new oe(this.writePos) : this.dataType.density.size(this.writePos);
2189
2322
  }
2190
2323
  /**
2191
2324
  * Returns the number of samples in this array.
@@ -2193,15 +2326,15 @@ class N {
2193
2326
  * @returns The number of samples in the series.
2194
2327
  */
2195
2328
  get length() {
2196
- return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === A ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
2329
+ return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === $ ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
2197
2330
  }
2198
2331
  calculateCachedLength() {
2199
2332
  if (!this.dataType.isVariable)
2200
2333
  throw new Error("cannot calculate length of a non-variable length data type");
2201
2334
  let e = 0;
2202
2335
  const t = [0];
2203
- return this.data.forEach((s, i) => {
2204
- s === te && (e++, t.push(i + 1));
2336
+ return this.data.forEach((n, i) => {
2337
+ n === ue && (e++, t.push(i + 1));
2205
2338
  }), this._cachedIndexes = t, this.cachedLength = e, e;
2206
2339
  }
2207
2340
  /**
@@ -2215,11 +2348,11 @@ class N {
2215
2348
  */
2216
2349
  convert(e, t = 0) {
2217
2350
  if (this.dataType.equals(e)) return this;
2218
- const s = new e.Array(this.length);
2351
+ const n = new e.Array(this.length);
2219
2352
  for (let i = 0; i < this.length; i++)
2220
- s[i] = Ct(this.dataType, e, this.data[i], t);
2221
- return new N({
2222
- data: s.buffer,
2353
+ n[i] = jt(this.dataType, e, this.data[i], t);
2354
+ return new M({
2355
+ data: n.buffer,
2223
2356
  dataType: e,
2224
2357
  timeRange: this.timeRange,
2225
2358
  sampleOffset: t,
@@ -2229,14 +2362,14 @@ class N {
2229
2362
  }
2230
2363
  calcRawMax() {
2231
2364
  if (this.length === 0) return -1 / 0;
2232
- if (this.dataType.equals(a.TIMESTAMP))
2365
+ if (this.dataType.equals(w.TIMESTAMP))
2233
2366
  this.cachedMax = this.data[this.data.length - 1];
2234
2367
  else if (this.dataType.usesBigInt) {
2235
2368
  const e = this.data;
2236
- this.cachedMax = e.reduce((t, s) => t > s ? t : s);
2369
+ this.cachedMax = e.reduce((t, n) => t > n ? t : n);
2237
2370
  } else {
2238
2371
  const e = this.data;
2239
- this.cachedMax = e.reduce((t, s) => t > s ? t : s);
2372
+ this.cachedMax = e.reduce((t, n) => t > n ? t : n);
2240
2373
  }
2241
2374
  return this.cachedMax;
2242
2375
  }
@@ -2247,17 +2380,17 @@ class N {
2247
2380
  calcMax() {
2248
2381
  if (this.dataType.isVariable)
2249
2382
  throw new Error("cannot calculate maximum on a variable length data type");
2250
- return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), G(this.cachedMax, this.sampleOffset));
2383
+ return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), H(this.cachedMax, this.sampleOffset));
2251
2384
  }
2252
2385
  calcRawMin() {
2253
2386
  if (this.length === 0) return 1 / 0;
2254
- if (this.dataType.equals(a.TIMESTAMP)) this.cachedMin = this.data[0];
2387
+ if (this.dataType.equals(w.TIMESTAMP)) this.cachedMin = this.data[0];
2255
2388
  else if (this.dataType.usesBigInt) {
2256
2389
  const e = this.data;
2257
- this.cachedMin = e.reduce((t, s) => t < s ? t : s);
2390
+ this.cachedMin = e.reduce((t, n) => t < n ? t : n);
2258
2391
  } else {
2259
2392
  const e = this.data;
2260
- this.cachedMin = e.reduce((t, s) => t < s ? t : s);
2393
+ this.cachedMin = e.reduce((t, n) => t < n ? t : n);
2261
2394
  }
2262
2395
  return this.cachedMin;
2263
2396
  }
@@ -2268,11 +2401,11 @@ class N {
2268
2401
  calcMin() {
2269
2402
  if (this.dataType.isVariable)
2270
2403
  throw new Error("cannot calculate minimum on a variable length data type");
2271
- return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), G(this.cachedMin, this.sampleOffset));
2404
+ return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), H(this.cachedMin, this.sampleOffset));
2272
2405
  }
2273
2406
  /** @returns the bounds of the series. */
2274
2407
  get bounds() {
2275
- return M(Number(this.min), Number(this.max), { makeValid: !1 });
2408
+ return R(Number(this.min), Number(this.max), { makeValid: !1 });
2276
2409
  }
2277
2410
  maybeRecomputeMinMax(e) {
2278
2411
  if (this.cachedMin != null) {
@@ -2285,56 +2418,56 @@ class N {
2285
2418
  }
2286
2419
  }
2287
2420
  atAlignment(e, t) {
2288
- const s = Number(e - this.alignment);
2289
- if (s < 0 || s >= this.length) {
2290
- if (t === !0) throw new Error(`[series] - no value at index ${s}`);
2421
+ const n = Number((e - this.alignment) / this.alignmentMultiple);
2422
+ if (n < 0 || n >= this.length) {
2423
+ if (t === !0) throw new Error(`[series] - no value at index ${n}`);
2291
2424
  return;
2292
2425
  }
2293
- return this.at(s, t);
2426
+ return this.at(n, t);
2294
2427
  }
2295
2428
  at(e, t = !1) {
2296
2429
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
2297
- if (this.dataType.equals(a.UUID)) return this.atUUID(e, t);
2430
+ if (this.dataType.equals(w.UUID)) return this.atUUID(e, t);
2298
2431
  e < 0 && (e = this.length + e);
2299
- const s = this.data[e];
2300
- if (s == null) {
2432
+ const n = this.data[e];
2433
+ if (n == null) {
2301
2434
  if (t === !0) throw new Error(`[series] - no value at index ${e}`);
2302
2435
  return;
2303
2436
  }
2304
- return G(s, this.sampleOffset);
2437
+ return H(n, this.sampleOffset);
2305
2438
  }
2306
2439
  atUUID(e, t) {
2307
2440
  e < 0 && (e = this.length + e);
2308
- const s = Ce(
2441
+ const n = ke(
2309
2442
  new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
2310
2443
  );
2311
- if (s == null) {
2444
+ if (n == null) {
2312
2445
  if (t) throw new Error(`[series] - no value at index ${e}`);
2313
2446
  return;
2314
2447
  }
2315
- return s;
2448
+ return n;
2316
2449
  }
2317
2450
  atVariable(e, t) {
2318
- let s = 0, i = 0;
2451
+ let n = 0, i = 0;
2319
2452
  if (this._cachedIndexes != null)
2320
- s = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
2453
+ n = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
2321
2454
  else {
2322
2455
  e < 0 && (e = this.length + e);
2323
- for (let l = 0; l < this.data.length; l++)
2324
- if (this.data[l] === te) {
2456
+ for (let c = 0; c < this.data.length; c++)
2457
+ if (this.data[c] === ue) {
2325
2458
  if (e === 0) {
2326
- i = l;
2459
+ i = c;
2327
2460
  break;
2328
2461
  }
2329
- s = l + 1, e--;
2462
+ n = c + 1, e--;
2330
2463
  }
2331
- if (i === 0 && (i = this.data.length), s >= i || e > 0) {
2464
+ if (i === 0 && (i = this.data.length), n >= i || e > 0) {
2332
2465
  if (t) throw new Error(`[series] - no value at index ${e}`);
2333
2466
  return;
2334
2467
  }
2335
2468
  }
2336
- const o = this.data.slice(s, i);
2337
- return this.dataType.equals(a.STRING) ? new TextDecoder().decode(o) : Oe(JSON.parse(new TextDecoder().decode(o)));
2469
+ const a = this.data.slice(n, i);
2470
+ return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) : Ee(JSON.parse(new TextDecoder().decode(a)));
2338
2471
  }
2339
2472
  /**
2340
2473
  * @returns the index of the first sample that is greater than or equal to the given value.
@@ -2342,12 +2475,12 @@ class N {
2342
2475
  * @param value the value to search for.
2343
2476
  */
2344
2477
  binarySearch(e) {
2345
- let t = 0, s = this.length - 1;
2346
- const i = He(e);
2347
- for (; t <= s; ) {
2348
- const o = Math.floor((t + s) / 2), l = i(this.at(o, !0), e);
2349
- if (l === 0) return o;
2350
- l < 0 ? t = o + 1 : s = o - 1;
2478
+ let t = 0, n = this.length - 1;
2479
+ const i = nt(e);
2480
+ for (; t <= n; ) {
2481
+ const a = Math.floor((t + n) / 2), c = i(this.at(a, !0), e);
2482
+ if (c === 0) return a;
2483
+ c < 0 ? t = a + 1 : n = a - 1;
2351
2484
  }
2352
2485
  return t;
2353
2486
  }
@@ -2359,23 +2492,23 @@ class N {
2359
2492
  * be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
2360
2493
  */
2361
2494
  updateGLBuffer(e) {
2362
- if (this.gl.control = e, !this.dataType.equals(a.FLOAT32) && !this.dataType.equals(a.UINT8))
2495
+ if (this.gl.control = e, !this.dataType.equals(w.FLOAT32) && !this.dataType.equals(w.UINT8))
2363
2496
  throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2364
- const { buffer: t, bufferUsage: s, prevBuffer: i } = this.gl;
2497
+ const { buffer: t, bufferUsage: n, prevBuffer: i } = this.gl;
2365
2498
  if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
2366
- if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== A) {
2499
+ if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== $) {
2367
2500
  i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
2368
- const o = this.dataType.density.size(i).valueOf(), l = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
2369
- e.bufferSubData(e.ARRAY_BUFFER, o, l.buffer), this.gl.prevBuffer = this.writePos;
2501
+ const a = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
2502
+ e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
2370
2503
  } else
2371
2504
  e.bufferData(
2372
2505
  e.ARRAY_BUFFER,
2373
2506
  this.buffer,
2374
- s === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2375
- ), this.gl.prevBuffer = A;
2507
+ n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2508
+ ), this.gl.prevBuffer = $;
2376
2509
  }
2377
2510
  as(e) {
2378
- return kt(e, this.dataType), this;
2511
+ return Gt(e, this.dataType), this;
2379
2512
  }
2380
2513
  /** @returns a digest containing information about the series. */
2381
2514
  get digest() {
@@ -2384,8 +2517,8 @@ class N {
2384
2517
  dataType: this.dataType.toString(),
2385
2518
  sampleOffset: this.sampleOffset,
2386
2519
  alignment: {
2387
- lower: be(this.alignmentBounds.lower),
2388
- upper: be(this.alignmentBounds.upper)
2520
+ lower: Ne(this.alignmentBounds.lower),
2521
+ upper: Ne(this.alignmentBounds.upper)
2389
2522
  },
2390
2523
  timeRange: this.timeRange.toString(),
2391
2524
  length: this.length,
@@ -2402,7 +2535,10 @@ class N {
2402
2535
  * is exclusive.
2403
2536
  */
2404
2537
  get alignmentBounds() {
2405
- return M(this.alignment, this.alignment + BigInt(this.length));
2538
+ return R(
2539
+ this.alignment,
2540
+ this.alignment + BigInt(this.length) * this.alignmentMultiple
2541
+ );
2406
2542
  }
2407
2543
  maybeGarbageCollectGLBuffer(e) {
2408
2544
  this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
@@ -2419,10 +2555,10 @@ class N {
2419
2555
  }
2420
2556
  [Symbol.iterator]() {
2421
2557
  if (this.dataType.isVariable) {
2422
- const e = new qt(this);
2423
- return this.dataType.equals(a.JSON) ? new ae(e) : e;
2558
+ const e = new Xt(this);
2559
+ return this.dataType.equals(w.JSON) ? new Kt(e) : e;
2424
2560
  }
2425
- return this.dataType.equals(a.UUID) ? new Ft(this) : new Wt(this);
2561
+ return this.dataType.equals(w.UUID) ? new Qt(this) : new _t(this);
2426
2562
  }
2427
2563
  /**
2428
2564
  * Returns a slice of the series from start to end.
@@ -2449,7 +2585,7 @@ class N {
2449
2585
  * @returns An iterator over the specified range.
2450
2586
  */
2451
2587
  subIterator(e, t) {
2452
- return new we(this, e, t ?? this.length);
2588
+ return new Ie(this, e, t ?? this.length);
2453
2589
  }
2454
2590
  /**
2455
2591
  * Returns an iterator over a portion of the series based on alignment.
@@ -2458,17 +2594,18 @@ class N {
2458
2594
  * @returns An iterator over the specified alignment range.
2459
2595
  */
2460
2596
  subAlignmentIterator(e, t) {
2461
- return new we(
2462
- this,
2463
- Number(e - this.alignment),
2464
- Number(t - this.alignment)
2597
+ const n = Math.ceil(
2598
+ Number(e - this.alignment) / Number(this.alignmentMultiple)
2599
+ ), i = Math.ceil(
2600
+ Number(t - this.alignment) / Number(this.alignmentMultiple)
2465
2601
  );
2602
+ return new Ie(this, n, i);
2466
2603
  }
2467
2604
  subBytes(e, t) {
2468
2605
  if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
2469
- const s = this.data.subarray(e, t);
2470
- return new N({
2471
- data: s,
2606
+ const n = this.data.subarray(e, t);
2607
+ return new M({
2608
+ data: n,
2472
2609
  dataType: this.dataType,
2473
2610
  timeRange: this.timeRange,
2474
2611
  sampleOffset: this.sampleOffset,
@@ -2476,10 +2613,10 @@ class N {
2476
2613
  alignment: this.alignment + BigInt(e)
2477
2614
  });
2478
2615
  }
2479
- sliceSub(e, t, s) {
2480
- if (t <= 0 && (s == null || s >= this.length)) return this;
2616
+ sliceSub(e, t, n) {
2617
+ if (t <= 0 && (n == null || n >= this.length)) return this;
2481
2618
  let i;
2482
- return e ? i = this.data.subarray(t, s) : i = this.data.slice(t, s), new N({
2619
+ return e ? i = this.data.subarray(t, n) : i = this.data.slice(t, n), new M({
2483
2620
  data: i,
2484
2621
  dataType: this.dataType,
2485
2622
  timeRange: this.timeRange,
@@ -2494,10 +2631,10 @@ class N {
2494
2631
  * @returns A new series with the specified alignment.
2495
2632
  */
2496
2633
  reAlign(e) {
2497
- return new N({
2634
+ return new M({
2498
2635
  data: this.buffer,
2499
2636
  dataType: this.dataType,
2500
- timeRange: v.ZERO,
2637
+ timeRange: F.ZERO,
2501
2638
  sampleOffset: this.sampleOffset,
2502
2639
  glBufferUsage: "static",
2503
2640
  alignment: e
@@ -2521,20 +2658,21 @@ class N {
2521
2658
  return e += "])", e;
2522
2659
  }
2523
2660
  }
2524
- const jt = (n) => n == null ? !1 : Array.isArray(n) || n instanceof ArrayBuffer || ArrayBuffer.isView(n) && !(n instanceof DataView) || n instanceof N ? !0 : Me(n), Yt = At(Be, N);
2525
- let we = class {
2661
+ const Jt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof M ? !0 : Pe(r), Ht = Pt(Ye, M);
2662
+ class Ie {
2526
2663
  series;
2527
2664
  end;
2528
2665
  index;
2529
- constructor(e, t, s) {
2666
+ constructor(e, t, n) {
2530
2667
  this.series = e;
2531
- const i = M(0, e.length);
2532
- this.end = de(i, s), this.index = de(i, t);
2668
+ const i = R(0, e.length + 1);
2669
+ this.end = be(i, n), this.index = be(i, t);
2533
2670
  }
2534
2671
  next() {
2535
2672
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
2536
2673
  }
2537
- }, qt = class {
2674
+ }
2675
+ class Xt {
2538
2676
  series;
2539
2677
  index;
2540
2678
  decoder;
@@ -2547,14 +2685,14 @@ let we = class {
2547
2685
  }
2548
2686
  next() {
2549
2687
  const e = this.index, t = this.series.data;
2550
- for (; this.index < t.length && t[this.index] !== te; ) this.index++;
2551
- const s = this.index;
2552
- return e === s ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, s)) });
2688
+ for (; this.index < t.length && t[this.index] !== ue; ) this.index++;
2689
+ const n = this.index;
2690
+ return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
2553
2691
  }
2554
- };
2555
- class ae {
2692
+ }
2693
+ let Kt = class je {
2556
2694
  wrapped;
2557
- static schema = r.record(r.string(), r.unknown());
2695
+ static schema = s.record(s.string(), s.unknown());
2558
2696
  constructor(e) {
2559
2697
  this.wrapped = e;
2560
2698
  }
@@ -2562,27 +2700,27 @@ class ae {
2562
2700
  const e = this.wrapped.next();
2563
2701
  return e.done === !0 ? { done: !0, value: void 0 } : {
2564
2702
  done: !1,
2565
- value: ee.decodeString(e.value, ae.schema)
2703
+ value: ae.decodeString(e.value, je.schema)
2566
2704
  };
2567
2705
  }
2568
- }
2569
- class Ft {
2706
+ };
2707
+ class Qt {
2570
2708
  series;
2571
2709
  index;
2572
2710
  data;
2573
2711
  density;
2574
2712
  constructor(e) {
2575
- if (!e.dataType.equals(a.UUID))
2713
+ if (!e.dataType.equals(w.UUID))
2576
2714
  throw new Error("cannot create a UUID series iterator for a non-UUID series");
2577
- this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = a.UUID.density.valueOf();
2715
+ this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = w.UUID.density.valueOf();
2578
2716
  }
2579
2717
  next() {
2580
2718
  if (this.index >= this.series.length) return { done: !0, value: void 0 };
2581
- const e = Ce(this.data, this.index * this.density);
2719
+ const e = ke(this.data, this.index * this.density);
2582
2720
  return this.index++, { done: !1, value: e };
2583
2721
  }
2584
2722
  }
2585
- class Wt {
2723
+ let _t = class {
2586
2724
  series;
2587
2725
  index;
2588
2726
  constructor(e) {
@@ -2594,28 +2732,28 @@ class Wt {
2594
2732
  value: this.series.at(this.index++, !0)
2595
2733
  };
2596
2734
  }
2597
- }
2598
- const be = (n) => {
2599
- const e = n >> 32n, t = n & 0xffffffffn;
2735
+ };
2736
+ const Ne = (r) => {
2737
+ const e = r >> 32n, t = r & 0xffffffffn;
2600
2738
  return { domain: e, sample: t };
2601
2739
  };
2602
- r.object({ key: r.string(), value: r.string() });
2603
- r.record(
2604
- r.union([r.number(), r.string(), r.symbol()]),
2605
- r.unknown()
2740
+ s.object({ key: s.string(), value: s.string() });
2741
+ s.record(
2742
+ s.union([s.number(), s.string(), s.symbol()]),
2743
+ s.unknown()
2606
2744
  );
2607
- const Zt = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2608
- Zt();
2609
- const Vt = ["macOS", "Windows", "Linux"], zt = ["macos", "windows", "linux"], Gt = {
2745
+ const er = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2746
+ er();
2747
+ const tr = ["macOS", "Windows", "Linux"], rr = ["macos", "windows", "linux"], nr = {
2610
2748
  macos: "macOS",
2611
2749
  windows: "Windows",
2612
2750
  linux: "Linux"
2613
2751
  };
2614
- r.enum(Vt).or(
2615
- r.enum(zt).transform((n) => Gt[n])
2752
+ s.enum(tr).or(
2753
+ s.enum(rr).transform((r) => nr[r])
2616
2754
  );
2617
- const Jt = (...n) => n.map($e).join(""), $e = (n) => (n.endsWith("/") || (n += "/"), n.startsWith("/") && (n = n.slice(1)), n), Ht = (n) => n.endsWith("/") ? n.slice(0, -1) : n, Xt = (n, e = "") => n === null ? "" : `?${Object.entries(n).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, s]) => `${e}${t}=${s}`).join("&")}`;
2618
- class q {
2755
+ const sr = (...r) => r.map(qe).join(""), qe = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), ir = (r) => r.endsWith("/") ? r.slice(0, -1) : r, ar = (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("&")}`;
2756
+ class Z {
2619
2757
  protocol;
2620
2758
  host;
2621
2759
  port;
@@ -2626,8 +2764,8 @@ class q {
2626
2764
  * @param protocol - The protocol to use for all requests. Defaults to "".
2627
2765
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
2628
2766
  */
2629
- constructor({ host: e, port: t, protocol: s = "", pathPrefix: i = "" }) {
2630
- this.protocol = s, this.host = e, this.port = t, this.path = $e(i);
2767
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
2768
+ this.protocol = n, this.host = e, this.port = t, this.path = qe(i);
2631
2769
  }
2632
2770
  /**
2633
2771
  * Replaces creates a new URL with the specified properties replaced.
@@ -2635,7 +2773,7 @@ class q {
2635
2773
  * @returns a new URL.
2636
2774
  */
2637
2775
  replace(e) {
2638
- return new q({
2776
+ return new Z({
2639
2777
  host: e.host ?? this.host,
2640
2778
  port: e.port ?? this.port,
2641
2779
  protocol: e.protocol ?? this.protocol,
@@ -2648,196 +2786,199 @@ class q {
2648
2786
  * @returns a new URL.
2649
2787
  */
2650
2788
  child(e) {
2651
- return new q({
2789
+ return new Z({
2652
2790
  ...this,
2653
- pathPrefix: Jt(this.path, e)
2791
+ pathPrefix: sr(this.path, e)
2654
2792
  });
2655
2793
  }
2656
2794
  /** @returns a string representation of the url */
2657
2795
  toString() {
2658
- return Ht(
2796
+ return ir(
2659
2797
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
2660
2798
  );
2661
2799
  }
2662
- static UNKNOWN = new q({ host: "unknown", port: 0 });
2800
+ static UNKNOWN = new Z({ host: "unknown", port: 0 });
2663
2801
  }
2664
- const Kt = async (n) => await new Promise(
2665
- (e) => setTimeout(e, u.fromMilliseconds(n).milliseconds)
2802
+ const or = async (r) => await new Promise(
2803
+ (e) => setTimeout(e, g.fromMilliseconds(r).milliseconds)
2666
2804
  );
2667
- class Qt {
2805
+ class ur {
2668
2806
  config;
2669
2807
  retries;
2670
2808
  interval;
2671
2809
  constructor(e) {
2672
2810
  this.config = {
2673
- baseInterval: new u(e?.baseInterval ?? u.seconds(1)),
2811
+ baseInterval: new g(e?.baseInterval ?? g.seconds(1)),
2674
2812
  maxRetries: e?.maxRetries ?? 5,
2675
2813
  scale: e?.scale ?? 1,
2676
- sleepFn: e?.sleepFn ?? Kt
2677
- }, this.retries = 0, this.interval = new u(this.config.baseInterval);
2814
+ sleepFn: e?.sleepFn ?? or
2815
+ }, this.retries = 0, this.interval = new g(this.config.baseInterval);
2678
2816
  }
2679
2817
  async wait() {
2680
- const { maxRetries: e, scale: t, sleepFn: s } = this.config;
2681
- return this.retries >= e ? !1 : (await s(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
2818
+ const { maxRetries: e, scale: t, sleepFn: n } = this.config;
2819
+ return this.retries >= e ? !1 : (await n(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
2820
+ }
2821
+ get retryMessage() {
2822
+ return `breaker triggered ${this.retries + 1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`;
2682
2823
  }
2683
2824
  reset() {
2684
2825
  this.retries = 0, this.interval = this.config.baseInterval;
2685
2826
  }
2686
2827
  }
2687
- const _t = r.object({
2688
- baseInterval: u.z.optional(),
2689
- maxRetries: r.number().optional(),
2690
- scale: r.number().optional()
2691
- }), en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2828
+ const lr = s.object({
2829
+ baseInterval: g.z.optional(),
2830
+ maxRetries: s.number().optional(),
2831
+ scale: s.number().optional()
2832
+ }), cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2692
2833
  __proto__: null,
2693
- Breaker: Qt,
2694
- breakerConfigZ: _t
2695
- }, Symbol.toStringTag, { value: "Module" })), tn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Re = r.string().regex(tn), D = r.number().min(0).max(255), De = r.number().min(0).max(1), Le = r.tuple([D, D, D, De]), nn = r.tuple([D, D, D]), sn = r.object({ rgba255: Le }), rn = r.number().min(0).max(360), an = r.number().min(0).max(100), on = r.number().min(0).max(100), un = r.tuple([rn, an, on, De]), oe = r.union([Re, nn, Le, un, sn]), cn = oe.transform((n) => ue(n)), ue = (n, e = 1) => {
2696
- if (n = oe.parse(n), typeof n == "string") return ln(n, e);
2697
- if (Array.isArray(n)) {
2698
- if (n.length < 3 || n.length > 4)
2699
- throw new Error(`Invalid color: [${n.join(", ")}]`);
2700
- return n.length === 3 ? [...n, e] : n;
2701
- }
2702
- return n.rgba255;
2703
- }, ln = (n, e = 1) => (n = Re.parse(n), n = hn(n), [
2704
- z(n, 0),
2705
- z(n, 2),
2706
- z(n, 4),
2707
- n.length === 8 ? z(n, 6) / 255 : e
2708
- ]), z = (n, e) => parseInt(n.slice(e, e + 2), 16), hn = (n) => n.startsWith("#") ? n.slice(1) : n;
2709
- ue("#000000");
2710
- ue("#ffffff");
2711
- const fn = r.object({
2712
- key: r.string(),
2713
- color: oe,
2714
- position: r.number(),
2715
- switched: r.boolean().optional()
2834
+ Breaker: ur,
2835
+ breakerConfigZ: lr
2836
+ }, Symbol.toStringTag, { value: "Module" })), hr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Fe = s.string().regex(hr), P = s.number().min(0).max(255), We = s.number().min(0).max(1), Ze = s.tuple([P, P, P, We]), fr = s.tuple([P, P, P]), dr = s.object({ rgba255: Ze }), gr = s.number().min(0).max(360), pr = s.number().min(0).max(100), mr = s.number().min(0).max(100), yr = s.tuple([gr, pr, mr, We]), de = s.union([Fe, fr, Ze, yr, dr]), wr = de.transform((r) => ge(r)), ge = (r, e = 1) => {
2837
+ if (r = de.parse(r), typeof r == "string") return br(r, e);
2838
+ if (Array.isArray(r)) {
2839
+ if (r.length < 3 || r.length > 4)
2840
+ throw new Error(`Invalid color: [${r.join(", ")}]`);
2841
+ return r.length === 3 ? [...r, e] : r;
2842
+ }
2843
+ return r.rgba255;
2844
+ }, br = (r, e = 1) => (r = Fe.parse(r), r = Or(r), [
2845
+ J(r, 0),
2846
+ J(r, 2),
2847
+ J(r, 4),
2848
+ r.length === 8 ? J(r, 6) / 255 : e
2849
+ ]), J = (r, e) => parseInt(r.slice(e, e + 2), 16), Or = (r) => r.startsWith("#") ? r.slice(1) : r;
2850
+ ge("#000000");
2851
+ ge("#ffffff");
2852
+ const Tr = s.object({
2853
+ key: s.string(),
2854
+ color: de,
2855
+ position: s.number(),
2856
+ switched: s.boolean().optional()
2716
2857
  });
2717
- r.array(fn);
2718
- const dn = r.object({
2719
- key: r.string(),
2720
- name: r.string(),
2721
- color: cn
2858
+ s.array(Tr);
2859
+ const vr = s.object({
2860
+ key: s.string(),
2861
+ name: s.string(),
2862
+ color: wr
2722
2863
  });
2723
- r.object({
2724
- key: r.string(),
2725
- name: r.string(),
2726
- swatches: r.array(dn)
2864
+ s.object({
2865
+ key: s.string(),
2866
+ name: s.string(),
2867
+ swatches: s.array(vr)
2727
2868
  });
2728
- r.int().min(0).max(255);
2729
- r.object({
2730
- name: r.string(),
2731
- key: r.string()
2869
+ s.int().min(0).max(255);
2870
+ s.object({
2871
+ name: s.string(),
2872
+ key: s.string()
2732
2873
  });
2733
- const gn = (n) => Object.getOwnPropertySymbols(globalThis).includes(n), pn = (n, e) => {
2734
- const t = Symbol.for(n);
2735
- if (!gn(t)) {
2736
- const s = e();
2737
- Object.defineProperty(globalThis, t, { value: s });
2874
+ const Ir = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), Nr = (r, e) => {
2875
+ const t = Symbol.for(r);
2876
+ if (!Ir(t)) {
2877
+ const n = e();
2878
+ Object.defineProperty(globalThis, t, { value: n });
2738
2879
  }
2739
2880
  return () => globalThis[t];
2740
- }, Pe = "sy_x_error", yn = (n) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(n) : e instanceof Error ? e.message.startsWith(n) : typeof e != "string" ? !1 : e.startsWith(n), F = (n) => class Y extends Error {
2741
- static discriminator = Pe;
2742
- discriminator = Y.discriminator;
2743
- static TYPE = n;
2744
- type = Y.TYPE;
2745
- static matches = yn(n);
2746
- matches = Y.matches;
2747
- constructor(t, s) {
2748
- super(t, s), this.name = Y.TYPE;
2881
+ }, Ve = "sy_x_error", Sr = (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), V = (r) => class W extends Error {
2882
+ static discriminator = Ve;
2883
+ discriminator = W.discriminator;
2884
+ static TYPE = r;
2885
+ type = W.TYPE;
2886
+ static matches = Sr(r);
2887
+ matches = W.matches;
2888
+ constructor(t, n) {
2889
+ super(t, n), this.name = W.TYPE;
2749
2890
  }
2750
2891
  static sub(t) {
2751
- return F(`${n}.${t}`);
2892
+ return V(`${r}.${t}`);
2752
2893
  }
2753
- }, ke = (n) => {
2754
- if (n == null || typeof n != "object") return !1;
2755
- const e = n;
2756
- if (e.discriminator !== Pe) return !1;
2894
+ }, ze = (r) => {
2895
+ if (r == null || typeof r != "object") return !1;
2896
+ const e = r;
2897
+ if (e.discriminator !== Ve) return !1;
2757
2898
  if (!("type" in e))
2758
2899
  throw new Error(
2759
2900
  `X Error is missing its type property: ${JSON.stringify(e)}`
2760
2901
  );
2761
2902
  return !0;
2762
- }, R = "unknown", ne = "nil";
2763
- class mn {
2903
+ }, L = "unknown", le = "nil";
2904
+ class Er {
2764
2905
  providers = [];
2765
2906
  register(e) {
2766
2907
  this.providers.push(e);
2767
2908
  }
2768
2909
  encode(e) {
2769
- if (e == null) return { type: ne, data: "" };
2770
- if (ke(e))
2910
+ if (e == null) return { type: le, data: "" };
2911
+ if (ze(e))
2771
2912
  for (const t of this.providers) {
2772
- const s = t.encode(e);
2773
- if (s != null) return s;
2913
+ const n = t.encode(e);
2914
+ if (n != null) return n;
2774
2915
  }
2775
- if (e instanceof Error) return { type: R, data: e.message };
2776
- if (typeof e == "string") return { type: R, data: e };
2916
+ if (e instanceof Error) return { type: L, data: e.message };
2917
+ if (typeof e == "string") return { type: L, data: e };
2777
2918
  try {
2778
- return { type: R, data: JSON.stringify(e) };
2919
+ return { type: L, data: JSON.stringify(e) };
2779
2920
  } catch {
2780
- return { type: R, data: "unable to encode error information" };
2921
+ return { type: L, data: "unable to encode error information" };
2781
2922
  }
2782
2923
  }
2783
2924
  decode(e) {
2784
- if (e == null || e.type === ne) return null;
2785
- if (e.type === R) return new se(e.data);
2925
+ if (e == null || e.type === le) return null;
2926
+ if (e.type === L) return new ce(e.data);
2786
2927
  for (const t of this.providers) {
2787
- const s = t.decode(e);
2788
- if (s != null) return s;
2928
+ const n = t.decode(e);
2929
+ if (n != null) return n;
2789
2930
  }
2790
- return new se(e.data);
2931
+ return new ce(e.data);
2791
2932
  }
2792
2933
  }
2793
- const ce = pn("synnax-error-registry", () => new mn()), wn = ({ encode: n, decode: e }) => ce().register({ encode: n, decode: e }), bn = (n) => ce().encode(n), Tn = (n) => n == null ? null : ce().decode(n);
2794
- class se extends F("unknown") {
2934
+ const pe = Nr("synnax-error-registry", () => new Er()), xr = ({ encode: r, decode: e }) => pe().register({ encode: r, decode: e }), Ar = (r) => pe().encode(r), Ur = (r) => r == null ? null : pe().decode(r);
2935
+ class ce extends V("unknown") {
2795
2936
  }
2796
- const On = r.object({ type: r.string(), data: r.string() });
2797
- class vn extends F("canceled") {
2937
+ const Mr = s.object({ type: s.string(), data: s.string() });
2938
+ class Cr extends V("canceled") {
2798
2939
  }
2799
- class In extends F("not_implemented") {
2940
+ class $r extends V("not_implemented") {
2800
2941
  }
2801
- const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2942
+ const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2802
2943
  __proto__: null,
2803
- Canceled: vn,
2804
- NONE: ne,
2805
- NotImplemented: In,
2806
- UNKNOWN: R,
2807
- Unknown: se,
2808
- createTyped: F,
2809
- decode: Tn,
2810
- encode: bn,
2811
- isTyped: ke,
2812
- payloadZ: On,
2813
- register: wn
2814
- }, Symbol.toStringTag, { value: "Module" })), Sn = w.object({
2815
- jsonrpc: w.literal("2.0"),
2816
- method: w.string(),
2944
+ Canceled: Cr,
2945
+ NONE: le,
2946
+ NotImplemented: $r,
2947
+ UNKNOWN: L,
2948
+ Unknown: ce,
2949
+ createTyped: V,
2950
+ decode: Ur,
2951
+ encode: Ar,
2952
+ isTyped: ze,
2953
+ payloadZ: Mr,
2954
+ register: xr
2955
+ }, Symbol.toStringTag, { value: "Module" })), Br = O.object({
2956
+ jsonrpc: O.literal("2.0"),
2957
+ method: O.string(),
2817
2958
  // params should be z.union([z.record(z.string(), z.json()),
2818
2959
  // z.array(z.json())]).optional() but the VSCode JSON RPC implementation uses a looser
2819
2960
  // definition of params then in the JSON-RPC spec.
2820
- params: w.any().optional(),
2821
- id: w.union([w.string(), w.number(), w.null()]).optional()
2822
- }), je = w.object({
2823
- jsonrpc: w.literal("2.0"),
2824
- id: w.union([w.string(), w.number(), w.null()])
2825
- }), Nn = je.extend({
2826
- result: w.json()
2827
- }), xn = je.extend({
2828
- error: w.object({
2829
- code: w.number().int(),
2961
+ params: O.any().optional(),
2962
+ id: O.union([O.string(), O.number(), O.null()]).optional()
2963
+ }), Ge = O.object({
2964
+ jsonrpc: O.literal("2.0"),
2965
+ id: O.union([O.string(), O.number(), O.null()])
2966
+ }), Rr = Ge.extend({
2967
+ result: O.json()
2968
+ }), Dr = Ge.extend({
2969
+ error: O.object({
2970
+ code: O.number().int(),
2830
2971
  // This should be z.string(), but the VSCode JSON RPC implementation uses a looser
2831
2972
  // definition of error than the JSON-RPC spec.
2832
- message: w.string().optional(),
2833
- data: w.json().optional()
2973
+ message: O.string().optional(),
2974
+ data: O.json().optional()
2834
2975
  })
2835
- }), En = w.union([Nn, xn]);
2836
- w.union([Sn, En]);
2837
- r.string().regex(/^\d+\.\d+\.\d+$/);
2838
- const An = ["standard", "scientific", "engineering"];
2839
- r.enum(An);
2840
- r.enum([
2976
+ }), Lr = O.union([Rr, Dr]);
2977
+ O.union([Br, Lr]);
2978
+ s.string().regex(/^\d+\.\d+\.\d+$/);
2979
+ const Pr = ["standard", "scientific", "engineering"];
2980
+ s.enum(Pr);
2981
+ s.enum([
2841
2982
  "success",
2842
2983
  "info",
2843
2984
  "warning",
@@ -2845,51 +2986,51 @@ r.enum([
2845
2986
  "loading",
2846
2987
  "disabled"
2847
2988
  ]);
2848
- class W extends U.createTyped("freighter") {
2989
+ class z extends B.createTyped("freighter") {
2849
2990
  }
2850
- class L extends W.sub("eof") {
2991
+ class k extends z.sub("eof") {
2851
2992
  constructor() {
2852
2993
  super("EOF");
2853
2994
  }
2854
2995
  }
2855
- class P extends W.sub("stream_closed") {
2996
+ class Y extends z.sub("stream_closed") {
2856
2997
  constructor() {
2857
2998
  super("StreamClosed");
2858
2999
  }
2859
3000
  }
2860
- class k extends W.sub("unreachable") {
3001
+ class j extends z.sub("unreachable") {
2861
3002
  url;
2862
3003
  constructor(e = {}) {
2863
- const { message: t = "Unreachable", url: s = q.UNKNOWN } = e;
2864
- super(t), this.url = s;
3004
+ const { message: t = "Unreachable", url: n = Z.UNKNOWN } = e;
3005
+ super(t), this.url = n;
2865
3006
  }
2866
3007
  }
2867
- const Un = (n) => {
2868
- if (!n.type.startsWith(W.TYPE)) return null;
2869
- if (L.matches(n)) return { type: L.TYPE, data: "EOF" };
2870
- if (P.matches(n))
2871
- return { type: P.TYPE, data: "StreamClosed" };
2872
- if (k.matches(n))
2873
- return { type: k.TYPE, data: "Unreachable" };
2874
- throw new Error(`Unknown error type: ${n.type}: ${n.message}`);
2875
- }, Mn = (n) => {
2876
- if (!n.type.startsWith(W.TYPE)) return null;
2877
- switch (n.type) {
2878
- case L.TYPE:
2879
- return new L();
2880
- case P.TYPE:
2881
- return new P();
3008
+ const kr = (r) => {
3009
+ if (!r.type.startsWith(z.TYPE)) return null;
3010
+ if (k.matches(r)) return { type: k.TYPE, data: "EOF" };
3011
+ if (Y.matches(r))
3012
+ return { type: Y.TYPE, data: "StreamClosed" };
3013
+ if (j.matches(r))
3014
+ return { type: j.TYPE, data: "Unreachable" };
3015
+ throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
3016
+ }, Yr = (r) => {
3017
+ if (!r.type.startsWith(z.TYPE)) return null;
3018
+ switch (r.type) {
2882
3019
  case k.TYPE:
2883
3020
  return new k();
3021
+ case Y.TYPE:
3022
+ return new Y();
3023
+ case j.TYPE:
3024
+ return new j();
2884
3025
  default:
2885
- throw new U.Unknown(`Unknown error type: ${n.data}`);
3026
+ throw new B.Unknown(`Unknown error type: ${r.data}`);
2886
3027
  }
2887
3028
  };
2888
- U.register({
2889
- encode: Un,
2890
- decode: Mn
3029
+ B.register({
3030
+ encode: kr,
3031
+ decode: Yr
2891
3032
  });
2892
- class Ye {
3033
+ class Je {
2893
3034
  middleware = [];
2894
3035
  /** Implements the Transport interface */
2895
3036
  use(...e) {
@@ -2905,78 +3046,94 @@ class Ye {
2905
3046
  * @returns An error if one was encountered, otherwise undefined.
2906
3047
  */
2907
3048
  async executeMiddleware(e, t) {
2908
- let s = 0;
2909
- const i = async (o) => {
2910
- if (s === this.middleware.length) return await t(o);
2911
- const l = this.middleware[s];
2912
- return s++, await l(o, i);
3049
+ let n = 0;
3050
+ const i = async (a) => {
3051
+ if (n === this.middleware.length) return await t(a);
3052
+ const c = this.middleware[n];
3053
+ return n++, await c(a, i);
2913
3054
  };
2914
3055
  return await i(e);
2915
3056
  }
2916
3057
  }
2917
- const qe = "Content-Type", Cn = (n) => typeof n.cause == "object" && n.cause !== null && "code" in n.cause && n.cause.code === "ECONNREFUSED", Bn = 400;
2918
- class Wn extends Ye {
3058
+ const He = "Content-Type", jr = /* @__PURE__ */ new Set([
3059
+ "ECONNREFUSED",
3060
+ "ECONNRESET",
3061
+ "ETIMEDOUT",
3062
+ "EPIPE",
3063
+ "UND_ERR_CONNECT_TIMEOUT",
3064
+ "UND_ERR_SOCKET"
3065
+ ]), qr = (r) => {
3066
+ const e = r?.cause?.code ?? r?.code ?? r?.errno;
3067
+ if (typeof e == "string" && jr.has(e)) return !0;
3068
+ if (r.name === "TypeError") {
3069
+ const t = String(r.message || "").toLowerCase();
3070
+ if (/load failed|failed to fetch|networkerror|network error/.test(t))
3071
+ return typeof navigator < "u" && navigator.onLine === !1, !0;
3072
+ }
3073
+ return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
3074
+ }, Fr = 400;
3075
+ class Qr extends Je {
2919
3076
  endpoint;
2920
3077
  encoder;
2921
- constructor(e, t, s = !1) {
2922
- return super(), this.endpoint = e.replace({ protocol: s ? "https" : "http" }), this.encoder = t, new Proxy(this, {
2923
- get: (i, o, l) => o === "endpoint" ? this.endpoint : Reflect.get(i, o, l)
3078
+ constructor(e, t, n = !1) {
3079
+ return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, {
3080
+ get: (i, a, c) => a === "endpoint" ? this.endpoint : Reflect.get(i, a, c)
2924
3081
  });
2925
3082
  }
2926
3083
  get headers() {
2927
3084
  return {
2928
- [qe]: this.encoder.contentType
3085
+ [He]: this.encoder.contentType
2929
3086
  };
2930
3087
  }
2931
- async send(e, t, s, i) {
2932
- t = s?.parse(t);
2933
- let o = null;
2934
- const l = this.endpoint.child(e), d = {};
3088
+ async send(e, t, n, i) {
3089
+ t = n?.parse(t);
3090
+ let a = null;
3091
+ const c = this.endpoint.child(e), d = {};
2935
3092
  d.method = "POST", d.body = this.encoder.encode(t ?? {});
2936
- const [, f] = await this.executeMiddleware(
3093
+ const [, y] = await this.executeMiddleware(
2937
3094
  {
2938
- target: l.toString(),
3095
+ target: c.toString(),
2939
3096
  protocol: this.endpoint.protocol,
2940
3097
  params: {},
2941
3098
  role: "client"
2942
3099
  },
2943
- async (g) => {
2944
- const m = { ...g, params: {} };
3100
+ async (f) => {
3101
+ const p = { ...f, params: {} };
2945
3102
  d.headers = {
2946
3103
  ...this.headers,
2947
- ...g.params
3104
+ ...f.params
2948
3105
  };
2949
- let h;
3106
+ let b;
2950
3107
  try {
2951
- h = await fetch(g.target, d);
2952
- } catch (b) {
2953
- if (!(b instanceof Error)) throw b;
2954
- return [m, Cn(b) ? new k({ url: l }) : b];
3108
+ b = await fetch(f.target, d);
3109
+ } catch (T) {
3110
+ if (!(T instanceof Error)) throw T;
3111
+ return [p, qr(T) ? new j({ url: c }) : T];
2955
3112
  }
2956
- const I = await h.arrayBuffer();
2957
- if (h?.ok)
2958
- return i != null && (o = this.encoder.decode(I, i)), [m, null];
3113
+ const h = await b.arrayBuffer();
3114
+ if (b?.ok)
3115
+ return i != null && (a = this.encoder.decode(h, i)), [p, null];
2959
3116
  try {
2960
- if (h.status !== Bn)
2961
- return [m, new Error(h.statusText)];
2962
- const b = this.encoder.decode(I, U.payloadZ), Z = U.decode(b);
2963
- return [m, Z];
2964
- } catch (b) {
3117
+ if (b.status !== Fr)
3118
+ return [p, new Error(b.statusText)];
3119
+ const T = this.encoder.decode(h, B.payloadZ), x = B.decode(T);
3120
+ return [p, x];
3121
+ } catch (T) {
2965
3122
  return [
2966
- m,
3123
+ p,
2967
3124
  new Error(
2968
- `[freighter] - failed to decode error: ${h.statusText}: ${b.message}`
3125
+ `[freighter] - failed to decode error: ${b.statusText}: ${T.message}`
2969
3126
  )
2970
3127
  ];
2971
3128
  }
2972
3129
  }
2973
3130
  );
2974
- if (f != null) return [null, f];
2975
- if (o == null) throw new Error("Response must be defined");
2976
- return [o, null];
3131
+ if (y != null) return [null, y];
3132
+ if (a == null) throw new Error("Response must be defined");
3133
+ return [a, null];
2977
3134
  }
2978
3135
  }
2979
- const Zn = (n, e) => {
3136
+ const _r = (r, e) => {
2980
3137
  class t {
2981
3138
  wrapped;
2982
3139
  constructor(i) {
@@ -2985,27 +3142,27 @@ const Zn = (n, e) => {
2985
3142
  use(...i) {
2986
3143
  this.wrapped.use(...i);
2987
3144
  }
2988
- async send(i, o, l, d) {
2989
- const f = new en.Breaker(e);
3145
+ async send(i, a, c, d) {
3146
+ const y = new cr.Breaker(e);
2990
3147
  do {
2991
- const [g, m] = await this.wrapped.send(i, o, l, d);
2992
- if (m == null) return [g, null];
2993
- if (!k.matches(m)) return [null, m];
2994
- if (!await f.wait()) return [g, m];
3148
+ const [f, p] = await this.wrapped.send(i, a, c, d);
3149
+ if (p == null) return [f, null];
3150
+ if (!j.matches(p)) return [null, p];
3151
+ if (console.warn(`[freighter] ${y.retryMessage}`, p), !await y.wait()) return [f, p];
2995
3152
  } while (!0);
2996
3153
  }
2997
3154
  }
2998
- return new t(n);
2999
- }, Vn = async (n, e, t, s, i) => {
3000
- const [o, l] = await n.send(e, t, s, i);
3001
- if (l != null) throw l;
3002
- return o;
3003
- }, $n = r.object({
3004
- type: r.enum(["data", "close", "open"]),
3005
- payload: r.unknown(),
3006
- error: r.optional(U.payloadZ)
3155
+ return new t(r);
3156
+ }, en = async (r, e, t, n, i) => {
3157
+ const [a, c] = await r.send(e, t, n, i);
3158
+ if (c != null) throw c;
3159
+ return a;
3160
+ }, Wr = s.object({
3161
+ type: s.enum(["data", "close", "open"]),
3162
+ payload: s.unknown(),
3163
+ error: s.optional(B.payloadZ)
3007
3164
  });
3008
- class Rn {
3165
+ class Zr {
3009
3166
  codec;
3010
3167
  reqSchema;
3011
3168
  resSchema;
@@ -3014,21 +3171,21 @@ class Rn {
3014
3171
  sendClosed;
3015
3172
  receiveDataQueue = [];
3016
3173
  receiveCallbacksQueue = [];
3017
- constructor(e, t, s, i) {
3018
- this.codec = t, this.reqSchema = s, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
3174
+ constructor(e, t, n, i) {
3175
+ this.codec = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
3019
3176
  }
3020
3177
  async receiveOpenAck() {
3021
3178
  const e = await this.receiveMsg();
3022
3179
  if (e.type !== "open") {
3023
3180
  if (e.error == null) throw new Error("Message error must be defined");
3024
- return U.decode(e.error);
3181
+ return B.decode(e.error);
3025
3182
  }
3026
3183
  return null;
3027
3184
  }
3028
3185
  /** Implements the Stream protocol */
3029
3186
  send(e) {
3030
- if (this.serverClosed != null) return new L();
3031
- if (this.sendClosed) throw new P();
3187
+ if (this.serverClosed != null) return new k();
3188
+ if (this.sendClosed) throw new Y();
3032
3189
  return this.ws.send(this.codec.encode({ type: "data", payload: e })), null;
3033
3190
  }
3034
3191
  /** Implements the Stream protocol */
@@ -3037,7 +3194,7 @@ class Rn {
3037
3194
  const e = await this.receiveMsg();
3038
3195
  if (e.type === "close") {
3039
3196
  if (e.error == null) throw new Error("Message error must be defined");
3040
- if (this.serverClosed = U.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3197
+ if (this.serverClosed = B.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3041
3198
  return [null, this.serverClosed];
3042
3199
  }
3043
3200
  return [this.resSchema.parse(e.payload), null];
@@ -3059,7 +3216,7 @@ class Rn {
3059
3216
  async receiveMsg() {
3060
3217
  const e = this.receiveDataQueue.shift();
3061
3218
  return e ?? await new Promise(
3062
- (t, s) => this.receiveCallbacksQueue.push({ resolve: t, reject: s })
3219
+ (t, n) => this.receiveCallbacksQueue.push({ resolve: t, reject: n })
3063
3220
  );
3064
3221
  }
3065
3222
  addMessage(e) {
@@ -3070,20 +3227,20 @@ class Rn {
3070
3227
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
3071
3228
  }
3072
3229
  onMessage(e) {
3073
- this.addMessage(this.codec.decode(e.data, $n));
3230
+ this.addMessage(this.codec.decode(e.data, Wr));
3074
3231
  }
3075
3232
  onClose(e) {
3076
3233
  this.addMessage({
3077
3234
  type: "close",
3078
3235
  error: {
3079
- type: e.code === Ln ? L.TYPE : P.TYPE,
3236
+ type: e.code === zr ? k.TYPE : Y.TYPE,
3080
3237
  data: ""
3081
3238
  }
3082
3239
  });
3083
3240
  }
3084
3241
  }
3085
- const Dn = "freighterctx", Ln = 1e3;
3086
- class re extends Ye {
3242
+ const Vr = "freighterctx", zr = 1e3;
3243
+ class he extends Je {
3087
3244
  baseUrl;
3088
3245
  encoder;
3089
3246
  secure;
@@ -3093,58 +3250,58 @@ class re extends Ye {
3093
3250
  * responses.
3094
3251
  * @param baseEndpoint - A base url to use as a prefix for all requests.
3095
3252
  */
3096
- constructor(e, t, s = !1) {
3097
- super(), this.secure = s, this.baseUrl = e.replace({ protocol: s ? "wss" : "ws" }), this.encoder = t;
3253
+ constructor(e, t, n = !1) {
3254
+ super(), this.secure = n, this.baseUrl = e.replace({ protocol: n ? "wss" : "ws" }), this.encoder = t;
3098
3255
  }
3099
3256
  withCodec(e) {
3100
- const t = new re(this.baseUrl, e, this.secure);
3257
+ const t = new he(this.baseUrl, e, this.secure);
3101
3258
  return t.use(...this.middleware), t;
3102
3259
  }
3103
3260
  /** Implements the StreamClient interface. */
3104
- async stream(e, t, s) {
3261
+ async stream(e, t, n) {
3105
3262
  let i;
3106
- const [, o] = await this.executeMiddleware(
3263
+ const [, a] = await this.executeMiddleware(
3107
3264
  { target: e, protocol: "websocket", params: {}, role: "client" },
3108
- async (l) => {
3109
- const d = new WebSocket(this.buildURL(e, l)), f = { ...l, params: {} };
3110
- d.binaryType = re.MESSAGE_TYPE;
3111
- const g = await this.wrapSocket(d, t, s);
3112
- return g instanceof Error ? [f, g] : (i = g, [f, null]);
3265
+ async (c) => {
3266
+ const d = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
3267
+ d.binaryType = he.MESSAGE_TYPE;
3268
+ const f = await this.wrapSocket(d, t, n);
3269
+ return f instanceof Error ? [y, f] : (i = f, [y, null]);
3113
3270
  }
3114
3271
  );
3115
- if (o != null) throw o;
3272
+ if (a != null) throw a;
3116
3273
  return i;
3117
3274
  }
3118
3275
  buildURL(e, t) {
3119
- const s = Xt(
3276
+ const n = ar(
3120
3277
  {
3121
- [qe]: this.encoder.contentType,
3278
+ [He]: this.encoder.contentType,
3122
3279
  ...t.params
3123
3280
  },
3124
- Dn
3281
+ Vr
3125
3282
  );
3126
- return this.baseUrl.child(e).toString() + s;
3283
+ return this.baseUrl.child(e).toString() + n;
3127
3284
  }
3128
- async wrapSocket(e, t, s) {
3285
+ async wrapSocket(e, t, n) {
3129
3286
  return await new Promise((i) => {
3130
3287
  e.onopen = () => {
3131
- const o = new Rn(e, this.encoder, t, s);
3132
- o.receiveOpenAck().then((l) => {
3133
- l != null ? i(l) : i(o);
3134
- }).catch((l) => i(l));
3135
- }, e.onerror = (o) => {
3136
- const l = o;
3137
- i(new Error(l.message));
3288
+ const a = new Zr(e, this.encoder, t, n);
3289
+ a.receiveOpenAck().then((c) => {
3290
+ c != null ? i(c) : i(a);
3291
+ }).catch((c) => i(c));
3292
+ }, e.onerror = (a) => {
3293
+ const c = a;
3294
+ i(new Error(c.message));
3138
3295
  };
3139
3296
  });
3140
3297
  }
3141
3298
  }
3142
3299
  export {
3143
- L as EOF,
3144
- Wn as HTTPClient,
3145
- P as StreamClosed,
3146
- k as Unreachable,
3147
- re as WebSocketClient,
3148
- Vn as sendRequired,
3149
- Zn as unaryWithBreaker
3300
+ k as EOF,
3301
+ Qr as HTTPClient,
3302
+ Y as StreamClosed,
3303
+ j as Unreachable,
3304
+ he as WebSocketClient,
3305
+ en as sendRequired,
3306
+ _r as unaryWithBreaker
3150
3307
  };