@synnaxlabs/freighter 0.47.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/freighter.js CHANGED
@@ -1,36 +1,36 @@
1
- import b, { z as s } from "zod";
2
- const tt = (n) => {
3
- const e = n.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
1
+ import O, { z as s } from "zod";
2
+ const _e = (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
- }, Me = (n) => {
6
- const e = (t, r = ue) => {
7
- if (typeof t == "string") return n(t);
8
- if (Array.isArray(t)) return t.map((c) => e(c, r));
9
- if (!ie(t)) return t;
10
- r = it(r);
5
+ }, Ae = (r) => {
6
+ const e = (t, n = oe) => {
7
+ if (typeof t == "string") return r(t);
8
+ if (Array.isArray(t)) return t.map((c) => e(c, n));
9
+ if (!se(t)) return t;
10
+ n = nt(n);
11
11
  const i = {}, a = t;
12
- return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), r) : (Object.keys(a).forEach((c) => {
12
+ return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), n) : (Object.keys(a).forEach((c) => {
13
13
  let d = a[c];
14
- const y = n(c);
15
- r.recursive && (ie(d) ? Te(d) || (d = e(d, r)) : r.recursiveInArray && Oe(d) && (d = [...d].map((f) => {
16
- let g = f;
17
- return ie(f) ? Te(g) || (g = e(f, r)) : Oe(f) && (g = e({ key: f }, r).key), g;
18
- }))), i[y] = d;
14
+ const w = r(c);
15
+ n.recursive && (se(d) ? be(d) || (d = e(d, n)) : n.recursiveInArray && we(d) && (d = [...d].map((h) => {
16
+ let g = h;
17
+ return se(h) ? be(g) || (g = e(h, n)) : we(h) && (g = e({ key: h }, n).key), g;
18
+ }))), i[w] = d;
19
19
  }), i);
20
20
  };
21
21
  return e;
22
- }, $e = Me(tt), nt = (n) => (
22
+ }, Ue = Ae(_e), et = (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, r) => `${t}_${r.toLowerCase()}`
27
+ (e, t, n) => `${t}_${n.toLowerCase()}`
28
28
  )
29
- ), rt = Me(nt), st = [Number, String, Uint8Array], ue = {
29
+ ), tt = Ae(et), rt = [Number, String, Uint8Array], oe = {
30
30
  recursive: !0,
31
31
  recursiveInArray: !0
32
- }, it = (n = ue) => (n.recursive == null ? n = ue : n.recursiveInArray ??= !1, n), Oe = (n) => n != null && Array.isArray(n), ie = (n) => n != null && typeof n == "object" && !Array.isArray(n), Te = (n) => st.some((e) => n instanceof e);
33
- let at = class {
32
+ }, nt = (r = oe) => (r.recursive == null ? r = oe : r.recursiveInArray ??= !1, r), we = (r) => r != null && Array.isArray(r), se = (r) => r != null && typeof r == "object" && !Array.isArray(r), be = (r) => rt.some((e) => r instanceof e);
33
+ let st = class {
34
34
  contentType = "application/json";
35
35
  decoder;
36
36
  encoder;
@@ -44,16 +44,16 @@ let at = class {
44
44
  return this.decodeString(this.decoder.decode(e), t);
45
45
  }
46
46
  decodeString(e, t) {
47
- const r = JSON.parse(e), i = $e(r);
47
+ const n = JSON.parse(e), i = Ue(n);
48
48
  return t != null ? t.parse(i) : i;
49
49
  }
50
50
  encodeString(e) {
51
- const t = rt(e);
52
- return JSON.stringify(t, (r, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
51
+ const t = tt(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 le = new at(), U = (n) => n != null && typeof n == "object" && "value" in n;
56
- let Z = class {
55
+ const ue = new st(), A = (r) => r != null && typeof r == "object" && "value" in r;
56
+ let W = class {
57
57
  /** The underlying primitive value */
58
58
  value;
59
59
  constructor(e) {
@@ -73,99 +73,99 @@ let Z = class {
73
73
  return this.value.toString();
74
74
  }
75
75
  };
76
- const ot = (n) => n != null && typeof n == "object" && "toString" in n, ut = (n, e = !1) => {
77
- const t = ot(n) ? "stringer" : typeof n;
78
- let r;
76
+ const it = (r) => r != null && typeof r == "object" && "toString" in r, at = (r, e = !1) => {
77
+ const t = it(r) ? "stringer" : typeof r;
78
+ let n;
79
79
  switch (t) {
80
80
  case "string":
81
- r = (i, a) => i.localeCompare(a);
81
+ n = (i, a) => i.localeCompare(a);
82
82
  break;
83
83
  case "stringer":
84
- r = (i, a) => i.toString().localeCompare(a.toString());
84
+ n = (i, a) => i.toString().localeCompare(a.toString());
85
85
  break;
86
86
  case "number":
87
- r = (i, a) => Number(i) - Number(a);
87
+ n = (i, a) => Number(i) - Number(a);
88
88
  break;
89
89
  case "bigint":
90
- r = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
90
+ n = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
91
91
  break;
92
92
  case "boolean":
93
- r = (i, a) => Number(i) - Number(a);
93
+ n = (i, a) => Number(i) - Number(a);
94
94
  break;
95
95
  case "undefined":
96
- r = () => 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 ? lt(r) : r;
102
- }, lt = (n) => (e, t) => n(t, e), ee = s.tuple([s.number(), s.number()]);
101
+ return e ? ot(n) : n;
102
+ }, ot = (r) => (e, t) => r(t, e), _ = s.tuple([s.number(), s.number()]);
103
103
  s.tuple([s.bigint(), s.bigint()]);
104
- const Ce = s.object({ width: s.number(), height: s.number() }), ct = s.object({
104
+ const Me = s.object({ width: s.number(), height: s.number() }), ut = s.object({
105
105
  signedWidth: s.number(),
106
106
  signedHeight: s.number()
107
- }), ht = ["width", "height"];
107
+ }), lt = ["width", "height"];
108
+ s.enum(lt);
109
+ const ct = ["start", "center", "end"], ht = ["signedWidth", "signedHeight"];
108
110
  s.enum(ht);
109
- const ft = ["start", "center", "end"], dt = ["signedWidth", "signedHeight"];
110
- s.enum(dt);
111
- const _ = s.object({ x: s.number(), y: s.number() }), gt = s.object({ clientX: s.number(), clientY: s.number() }), pt = ["x", "y"], Be = s.enum(pt), Re = ["top", "right", "bottom", "left"];
112
- s.enum(Re);
113
- const mt = ["left", "right"], De = s.enum(mt), yt = ["top", "bottom"], Le = s.enum(yt), Pe = ["center"], ve = s.enum(Pe), wt = [...Re, ...Pe], ke = s.enum(wt);
114
- s.enum(ft);
115
- const bt = ["first", "last"];
116
- s.enum(bt);
117
- const Ot = s.object({ lower: s.number(), upper: s.number() }), Tt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
- s.union([Ot, ee]);
119
- s.union([Tt, ee]);
120
- s.enum([...Be.options, ...ke.options]);
111
+ const Q = s.object({ x: s.number(), y: s.number() }), ft = s.object({ clientX: s.number(), clientY: s.number() }), dt = ["x", "y"], $e = s.enum(dt), Ce = ["top", "right", "bottom", "left"];
112
+ s.enum(Ce);
113
+ const gt = ["left", "right"], Be = s.enum(gt), pt = ["top", "bottom"], Re = s.enum(pt), De = ["center"], Oe = s.enum(De), mt = [...Ce, ...De], Le = s.enum(mt);
114
+ s.enum(ct);
115
+ const yt = ["first", "last"];
116
+ s.enum(yt);
117
+ const wt = s.object({ lower: s.number(), upper: s.number() }), bt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
+ s.union([wt, _]);
119
+ s.union([bt, _]);
120
+ s.enum([...$e.options, ...Le.options]);
121
121
  s.enum(["x", "left", "right"]);
122
122
  s.enum(["y", "top", "bottom"]);
123
- s.union([Be, ke, s.instanceof(String)]);
124
- const te = (n) => (e, t) => {
123
+ s.union([$e, Le, s.instanceof(String)]);
124
+ const ee = (r) => (e, t) => {
125
125
  if (typeof e == "bigint") {
126
- if (vt(t))
127
- return n(e, BigInt(t));
128
- const r = n(Number(e), Number(t));
129
- return typeof r == "number" ? BigInt(Math.round(r)) : r;
130
- }
131
- return n(Number(e), Number(t));
132
- }, ne = te((n, e) => n - e), re = te((n, e) => n + e), vt = (n) => typeof n == "bigint" ? !0 : Number.isInteger(n), C = te((n, e) => n * e), se = te((n, e) => n / e), P = (n, e, t) => {
133
- const r = {};
134
- if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof n == "number" || typeof n == "bigint")
135
- e != null ? (r.lower = n, r.upper = e) : (r.lower = typeof n == "bigint" ? 0n : 0, r.upper = n);
136
- else if (Array.isArray(n)) {
137
- if (n.length !== 2) throw new Error("bounds: expected array of length 2");
138
- [r.lower, r.upper] = n;
126
+ if (Ot(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
+ }, te = ee((r, e) => r - e), re = ee((r, e) => r + e), Ot = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), $ = ee((r, e) => r * e), ne = ee((r, e) => r / e), L = (r, e, t) => {
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;
139
139
  } else
140
- r.lower = n.lower, r.upper = n.upper;
141
- return t?.makeValid ? St(r) : r;
142
- }, St = (n) => n.lower > n.upper ? { lower: n.upper, upper: n.lower } : n, Se = (n, e) => {
143
- const t = P(n);
140
+ n.lower = r.lower, n.upper = r.upper;
141
+ return t?.makeValid ? Tt(n) : n;
142
+ }, Tt = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, Te = (r, e) => {
143
+ const t = L(r);
144
144
  return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
145
145
  };
146
146
  s.object({
147
- x: De.or(ve),
148
- y: Le.or(ve)
147
+ x: Be.or(Oe),
148
+ y: Re.or(Oe)
149
149
  });
150
- const It = s.object({ x: De, y: Le }), Nt = Object.freeze({ x: "left", y: "top" }), Et = (n, e) => n.x === e.x && n.y === e.y, Ie = s.union([
150
+ const vt = s.object({ x: Be, y: Re }), It = Object.freeze({ x: "left", y: "top" }), St = (r, e) => r.x === e.x && r.y === e.y, ve = s.union([
151
151
  s.number(),
152
+ Q,
152
153
  _,
153
- ee,
154
- Ce,
155
- ct,
156
- gt
157
- ]), xt = (n, e) => {
158
- if (typeof n == "string") {
154
+ Me,
155
+ ut,
156
+ ft
157
+ ]), Nt = (r, e) => {
158
+ if (typeof r == "string") {
159
159
  if (e === void 0) throw new Error("The y coordinate must be given.");
160
- return n === "x" ? { x: e, y: 0 } : { x: 0, y: e };
160
+ return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
161
161
  }
162
- 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 };
163
- }, Ne = Object.freeze({ x: 0, y: 0 }), J = s.union([s.number(), s.string()]);
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
+ }, Ie = Object.freeze({ x: 0, y: 0 }), H = s.union([s.number(), s.string()]);
164
164
  s.object({
165
- top: J,
166
- left: J,
167
- width: J,
168
- height: J
165
+ top: H,
166
+ left: H,
167
+ width: H,
168
+ height: H
169
169
  });
170
170
  s.object({
171
171
  left: s.number(),
@@ -174,61 +174,61 @@ s.object({
174
174
  bottom: s.number()
175
175
  });
176
176
  s.object({
177
- one: _,
178
- two: _,
179
- root: It
177
+ one: Q,
178
+ two: Q,
179
+ root: vt
180
180
  });
181
- const me = (n, e, t = 0, r = 0, i) => {
181
+ const ge = (r, e, t = 0, n = 0, i) => {
182
182
  const a = {
183
- one: { ...Ne },
184
- two: { ...Ne },
185
- root: i ?? Nt
183
+ one: { ...Ie },
184
+ two: { ...Ie },
185
+ root: i ?? It
186
186
  };
187
- if (typeof n == "number") {
187
+ if (typeof r == "number") {
188
188
  if (typeof e != "number")
189
189
  throw new Error("Box constructor called with invalid arguments");
190
- return a.one = { x: n, y: e }, a.two = { x: a.one.x + t, y: a.one.y + r }, a;
190
+ return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
191
191
  }
192
- return "one" in n && "two" in n && "root" in n ? { ...n, root: i ?? n.root } : ("getBoundingClientRect" in n && (n = n.getBoundingClientRect()), "left" in n ? (a.one = { x: n.left, y: n.top }, a.two = { x: n.right, y: n.bottom }, a) : (a.one = n, e == null ? a.two = { x: a.one.x + t, y: a.one.y + r } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
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
193
  x: a.one.x + e.width,
194
194
  y: a.one.y + e.height
195
195
  } : "signedWidth" in e ? a.two = {
196
196
  x: a.one.x + e.signedWidth,
197
197
  y: a.one.y + e.signedHeight
198
198
  } : a.two = e, a));
199
- }, ae = (n) => {
200
- const e = me(n);
199
+ }, ie = (r) => {
200
+ const e = ge(r);
201
201
  return { lower: e.one.x, upper: e.two.x };
202
- }, oe = (n) => {
203
- const e = me(n);
202
+ }, ae = (r) => {
203
+ const e = ge(r);
204
204
  return { lower: e.one.y, upper: e.two.y };
205
- }, At = (n) => typeof n != "object" || n == null ? !1 : "one" in n && "two" in n && "root" in n, Ut = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
- s.union([Ce, Ut, _, ee]);
207
- const Mt = (n, e, t) => e !== void 0 && n < e ? e : t !== void 0 && n > t ? t : n;
208
- s.object({ offset: Ie, scale: Ie });
205
+ }, Et = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, xt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
+ s.union([Me, xt, Q, _]);
207
+ const At = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
208
+ s.object({ offset: ve, scale: ve });
209
209
  s.object({ offset: s.number(), scale: s.number() });
210
- const $t = (n) => (e, t, r, i) => t === "dimension" ? [e, r] : [
210
+ const Ut = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
211
211
  e,
212
- i ? r - n : r + n
213
- ], Ct = (n) => (e, t, r, i) => [
212
+ i ? n - r : n + r
213
+ ], Mt = (r) => (e, t, n, i) => [
214
214
  e,
215
- i ? r / n : r * n
216
- ], Bt = (n) => (e, t, r) => {
217
- if (e === null) return [n, r];
218
- const { lower: i, upper: a } = e, { lower: c, upper: d } = n, y = a - i, f = d - c;
219
- if (t === "dimension") return [n, r * (f / y)];
220
- const g = (r - i) * (f / y) + c;
221
- return [n, g];
222
- }, Rt = (n) => (e, t, r) => [n, r], Dt = () => (n, e, t) => {
223
- if (n === null) throw new Error("cannot invert without bounds");
224
- if (e === "dimension") return [n, t];
225
- const { lower: r, upper: i } = n;
226
- return [n, i - (t - r)];
227
- }, Lt = (n) => (e, t, r) => {
228
- const { lower: i, upper: a } = n;
229
- return r = Mt(r, i, a), [e, r];
215
+ i ? n / r : n * r
216
+ ], $t = (r) => (e, t, n) => {
217
+ if (e === null) return [r, n];
218
+ const { lower: i, upper: a } = e, { lower: c, upper: d } = r, w = a - i, h = d - c;
219
+ if (t === "dimension") return [r, n * (h / w)];
220
+ const g = (n - i) * (h / w) + c;
221
+ return [r, g];
222
+ }, Ct = (r) => (e, t, n) => [r, n], Bt = () => (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
+ }, Rt = (r) => (e, t, n) => {
228
+ const { lower: i, upper: a } = r;
229
+ return n = At(n, i, a), [e, n];
230
230
  };
231
- let Ee = class k {
231
+ let Se = class P {
232
232
  ops = [];
233
233
  currBounds = null;
234
234
  currType = null;
@@ -242,7 +242,7 @@ let Ee = class k {
242
242
  * @param value - The amount to translate by.
243
243
  */
244
244
  static translate(e) {
245
- return new k().translate(e);
245
+ return new P().translate(e);
246
246
  }
247
247
  /**
248
248
  * @returns a new scale with a magnification as its first operation. Any number provided
@@ -250,10 +250,10 @@ let Ee = class k {
250
250
  * @param value - The amount to translate by.
251
251
  */
252
252
  static magnify(e) {
253
- return new k().magnify(e);
253
+ return new P().magnify(e);
254
254
  }
255
255
  static scale(e, t) {
256
- return new k().scale(e, t);
256
+ return new P().scale(e, t);
257
257
  }
258
258
  /**
259
259
  * @returns a copy of the scale with a translation as its next operation. Any
@@ -262,8 +262,8 @@ let Ee = class k {
262
262
  * @param value - The amount to translate by.
263
263
  */
264
264
  translate(e) {
265
- const t = this.new(), r = $t(e);
266
- return r.type = "translate", t.ops.push(r), t;
265
+ const t = this.new(), n = Ut(e);
266
+ return n.type = "translate", t.ops.push(n), t;
267
267
  }
268
268
  /**
269
269
  * @returns a copy of the scale with a translation as its next operation. Any number
@@ -272,23 +272,23 @@ let Ee = class k {
272
272
  * @param value - The amount to magnify by.
273
273
  */
274
274
  magnify(e) {
275
- const t = this.new(), r = Ct(e);
276
- return r.type = "magnify", t.ops.push(r), t;
275
+ const t = this.new(), n = Mt(e);
276
+ return n.type = "magnify", t.ops.push(n), t;
277
277
  }
278
278
  scale(e, t) {
279
- const r = P(e, t), i = this.new(), a = Bt(r);
279
+ const n = L(e, t), i = this.new(), a = $t(n);
280
280
  return a.type = "scale", i.ops.push(a), i;
281
281
  }
282
282
  clamp(e, t) {
283
- const r = P(e, t), i = this.new(), a = Lt(r);
283
+ const n = L(e, t), i = this.new(), a = Rt(n);
284
284
  return a.type = "clamp", i.ops.push(a), i;
285
285
  }
286
286
  reBound(e, t) {
287
- const r = P(e, t), i = this.new(), a = Rt(r);
287
+ const n = L(e, t), i = this.new(), a = Ct(n);
288
288
  return a.type = "re-bound", i.ops.push(a), i;
289
289
  }
290
290
  invert() {
291
- const e = Dt();
291
+ const e = Bt();
292
292
  e.type = "invert";
293
293
  const t = this.new();
294
294
  return t.ops.push(e), t;
@@ -300,12 +300,12 @@ let Ee = class k {
300
300
  return this.exec("dimension", e);
301
301
  }
302
302
  new() {
303
- const e = new k();
303
+ const e = new P();
304
304
  return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
305
305
  }
306
306
  exec(e, t) {
307
307
  return this.currBounds = null, this.ops.reduce(
308
- ([r, i], a) => a(r, e, i, this.reversed),
308
+ ([n, i], a) => a(n, e, i, this.reversed),
309
309
  [null, t]
310
310
  )[1];
311
311
  }
@@ -313,51 +313,51 @@ let Ee = class k {
313
313
  const e = this.new();
314
314
  e.ops.reverse();
315
315
  const t = [];
316
- return e.ops.forEach((r, i) => {
317
- if (r.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
316
+ return e.ops.forEach((n, i) => {
317
+ if (n.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
318
318
  return;
319
319
  const a = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
320
320
  a !== -1 && t.push([i, a]);
321
- }), t.forEach(([r, i]) => {
322
- const a = e.ops.slice(r, i);
323
- a.unshift(e.ops[i]), e.ops.splice(r, i - r + 1, ...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);
324
324
  }), e.reversed = !e.reversed, e;
325
325
  }
326
326
  get transform() {
327
327
  return { scale: this.dim(1), offset: this.pos(0) };
328
328
  }
329
- static IDENTITY = new k();
330
- }, sr = class $ {
329
+ static IDENTITY = new P();
330
+ }, tn = class M {
331
331
  x;
332
332
  y;
333
333
  currRoot;
334
- constructor(e = new Ee(), t = new Ee(), r = null) {
335
- this.x = e, this.y = t, this.currRoot = r;
334
+ constructor(e = new Se(), t = new Se(), n = null) {
335
+ this.x = e, this.y = t, this.currRoot = n;
336
336
  }
337
337
  static translate(e, t) {
338
- return new $().translate(e, t);
338
+ return new M().translate(e, t);
339
339
  }
340
340
  static translateX(e) {
341
- return new $().translateX(e);
341
+ return new M().translateX(e);
342
342
  }
343
343
  static translateY(e) {
344
- return new $().translateY(e);
344
+ return new M().translateY(e);
345
345
  }
346
346
  static clamp(e) {
347
- return new $().clamp(e);
347
+ return new M().clamp(e);
348
348
  }
349
349
  static magnify(e) {
350
- return new $().magnify(e);
350
+ return new M().magnify(e);
351
351
  }
352
352
  static scale(e) {
353
- return new $().scale(e);
353
+ return new M().scale(e);
354
354
  }
355
355
  static reBound(e) {
356
- return new $().reBound(e);
356
+ return new M().reBound(e);
357
357
  }
358
358
  translate(e, t) {
359
- const r = xt(e, t), i = this.copy();
360
- return i.x = this.x.translate(r.x), i.y = this.y.translate(r.y), i;
359
+ const n = Nt(e, t), i = this.copy();
360
+ return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
361
361
  }
362
362
  translateX(e) {
363
363
  const t = this.copy();
@@ -373,22 +373,22 @@ let Ee = class k {
373
373
  }
374
374
  scale(e) {
375
375
  const t = this.copy();
376
- if (At(e)) {
377
- const r = this.currRoot;
378
- return t.currRoot = e.root, r != null && !Et(r, e.root) && (r.x !== e.root.x && (t.x = t.x.invert()), r.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ae(e)), t.y = t.y.scale(oe(e)), t;
376
+ if (Et(e)) {
377
+ const n = this.currRoot;
378
+ return t.currRoot = e.root, n != null && !St(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ie(e)), t.y = t.y.scale(ae(e)), t;
379
379
  }
380
380
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
381
381
  }
382
382
  reBound(e) {
383
383
  const t = this.copy();
384
- return t.x = this.x.reBound(ae(e)), t.y = this.y.reBound(oe(e)), t;
384
+ return t.x = this.x.reBound(ie(e)), t.y = this.y.reBound(ae(e)), t;
385
385
  }
386
386
  clamp(e) {
387
387
  const t = this.copy();
388
- return t.x = this.x.clamp(ae(e)), t.y = this.y.clamp(oe(e)), t;
388
+ return t.x = this.x.clamp(ie(e)), t.y = this.y.clamp(ae(e)), t;
389
389
  }
390
390
  copy() {
391
- const e = new $();
391
+ const e = new M();
392
392
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
393
393
  }
394
394
  reverse() {
@@ -402,7 +402,7 @@ let Ee = class k {
402
402
  return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
403
403
  }
404
404
  box(e) {
405
- return me(
405
+ return ge(
406
406
  this.pos(e.one),
407
407
  this.pos(e.two),
408
408
  0,
@@ -416,18 +416,18 @@ let Ee = class k {
416
416
  offset: this.pos({ x: 0, y: 0 })
417
417
  };
418
418
  }
419
- static IDENTITY = new $();
420
- }, je = (n, e = 21) => (t = e) => {
421
- let r = "", i = t | 0;
419
+ static IDENTITY = new M();
420
+ }, Pe = (r, e = 21) => (t = e) => {
421
+ let n = "", i = t | 0;
422
422
  for (; i--; )
423
- r += n[Math.random() * n.length | 0];
424
- return r;
423
+ n += r[Math.random() * r.length | 0];
424
+ return n;
425
425
  };
426
- const Ye = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Pt = `0123456789${Ye}`, kt = 11, jt = je(Ye, 1), Yt = je(Pt, kt - 1), qt = () => `${jt()}${Yt()}`, Ft = (n, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === n, Wt = s.enum(["static", "dynamic"]), ce = 2n ** 63n - 1n, Zt = 2 ** 63 - 1, xe = 365, K = 30, Gt = s.union([
426
+ const ke = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Dt = `0123456789${ke}`, Lt = 11, Pt = Pe(ke, 1), kt = Pe(Dt, Lt - 1), jt = () => `${Pt()}${kt()}`, Yt = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, qt = s.enum(["static", "dynamic"]), le = 2n ** 63n - 1n, Ft = 2 ** 63 - 1, Ne = 365, J = 30, Wt = s.union([
427
427
  s.tuple([s.int()]),
428
428
  s.tuple([s.int(), s.int().min(1).max(12)]),
429
429
  s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
430
- ]), qe = (n, e) => {
430
+ ]), je = (r, e) => {
431
431
  const t = new u(e);
432
432
  if (![
433
433
  l.DAY,
@@ -441,10 +441,10 @@ const Ye = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Pt = `0123456
441
441
  throw new Error(
442
442
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
443
443
  );
444
- const r = n.valueOf() % t.valueOf();
445
- return n instanceof u ? new u(r) : new l(r);
444
+ const n = r.valueOf() % t.valueOf();
445
+ return r instanceof u ? new u(n) : new l(n);
446
446
  };
447
- class u extends Z {
447
+ class u extends W {
448
448
  constructor(e, t = "UTC") {
449
449
  if (e == null) super(u.now().valueOf());
450
450
  else if (e instanceof Date)
@@ -453,12 +453,12 @@ class u extends Z {
453
453
  super(u.parseDateTimeString(e, t).valueOf());
454
454
  else if (Array.isArray(e)) super(u.parseDate(e));
455
455
  else {
456
- let r = 0n;
457
- e instanceof Number && (e = e.valueOf()), t === "local" && (r = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === Zt ? e = ce : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), U(e) && (e = e.value), super(BigInt(e.valueOf()) + r);
456
+ let n = 0n;
457
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === Ft ? e = le : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), A(e) && (e = e.value), super(BigInt(e.valueOf()) + n);
458
458
  }
459
459
  }
460
- static parseDate([e = 1970, t = 1, r = 1]) {
461
- const i = new Date(e, t - 1, r, 0, 0, 0, 0);
460
+ static parseDate([e = 1970, t = 1, n = 1]) {
461
+ const i = new Date(e, t - 1, n, 0, 0, 0, 0);
462
462
  return new u(BigInt(i.getTime()) * u.MILLISECOND.valueOf()).truncate(u.DAY).valueOf();
463
463
  }
464
464
  /**
@@ -469,18 +469,29 @@ class u extends Z {
469
469
  return this.value;
470
470
  }
471
471
  static parseTimeString(e, t = "UTC") {
472
- const [r, i, a] = e.split(":");
472
+ const [n, i, a] = e.split(":");
473
473
  let c = "00", d = "00";
474
474
  a != null && ([c, d] = a.split("."));
475
- let y = u.hours(parseInt(r ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(d ?? "00")));
476
- return t === "local" && (y = y.add(u.utcOffset)), y.valueOf();
475
+ let w = u.hours(parseInt(n ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(d ?? "00")));
476
+ return t === "local" && (w = w.add(u.utcOffset)), w.valueOf();
477
477
  }
478
478
  static parseDateTimeString(e, t = "UTC") {
479
479
  if (!e.includes("/") && !e.includes("-"))
480
480
  return u.parseTimeString(e, t);
481
- const r = new Date(e);
482
- return e.includes(":") || r.setUTCHours(0, 0, 0, 0), new u(
483
- BigInt(r.getTime()) * u.MILLISECOND.valueOf(),
481
+ if (e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/) != null) {
482
+ let i = e, a = 0;
483
+ if (e.includes(".")) {
484
+ const h = e.split(".");
485
+ i = h[0];
486
+ const g = h[1] || "0";
487
+ a = parseInt(g.padEnd(3, "0").slice(0, 3));
488
+ }
489
+ const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`), d = BigInt(c.getTime()) * u.MILLISECOND.valueOf(), w = BigInt(a) * u.MILLISECOND.valueOf();
490
+ return d + w;
491
+ }
492
+ const n = new Date(e);
493
+ return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new u(
494
+ BigInt(n.getTime()) * u.MILLISECOND.valueOf(),
484
495
  t
485
496
  ).valueOf();
486
497
  }
@@ -488,12 +499,12 @@ class u extends Z {
488
499
  return e === "UTC" ? this.date().toISOString() : this.sub(u.utcOffset).date().toISOString();
489
500
  }
490
501
  timeString(e = !1, t = "UTC") {
491
- const r = this.toISOString(t);
492
- return e ? r.slice(11, 23) : r.slice(11, 19);
502
+ const n = this.toISOString(t);
503
+ return e ? n.slice(11, 23) : n.slice(11, 19);
493
504
  }
494
505
  dateString() {
495
- const e = this.date(), t = e.toLocaleString("default", { month: "short" }), r = e.toLocaleString("default", { day: "numeric" });
496
- return `${t} ${r}`;
506
+ const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
507
+ return `${t} ${n}`;
497
508
  }
498
509
  /** @returns The UTC offset for the time zone of the machine. */
499
510
  static get utcOffset() {
@@ -540,7 +551,7 @@ class u extends Z {
540
551
  * valid, regardless of the TimeStamp order.
541
552
  */
542
553
  range(e) {
543
- return new x(this, e).makeValid();
554
+ return new E(this, e).makeValid();
544
555
  }
545
556
  /**
546
557
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -619,7 +630,7 @@ class u extends Z {
619
630
  * TimeSpan.
620
631
  */
621
632
  sub(e) {
622
- return new u(ne(this.valueOf(), new l(e).valueOf()));
633
+ return new u(te(this.valueOf(), new l(e).valueOf()));
623
634
  }
624
635
  /**
625
636
  * @returns the floating point number of hours since the unix epoch to the timestamp
@@ -810,7 +821,7 @@ class u extends Z {
810
821
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
811
822
  */
812
823
  remainder(e) {
813
- return qe(this, e);
824
+ return je(this, e);
814
825
  }
815
826
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
816
827
  get isToday() {
@@ -825,6 +836,22 @@ class u extends Z {
825
836
  truncate(e) {
826
837
  return this.sub(this.remainder(e));
827
838
  }
839
+ /**
840
+ * Determines the appropriate string format based on the span magnitude.
841
+ *
842
+ * @param span - The span that provides context for format selection
843
+ * @returns The appropriate TimeStampStringFormat
844
+ *
845
+ * Rules:
846
+ * - For spans >= 30 days: "shortDate" (e.g., "Nov 5")
847
+ * - For spans >= 1 day: "dateTime" (e.g., "Nov 5 14:23:45")
848
+ * - For spans >= 1 hour: "time" (e.g., "14:23:45")
849
+ * - For spans >= 1 second: "preciseTime" (e.g., "14:23:45.123")
850
+ * - For spans < 1 second: "ISOTime" (full precision time)
851
+ */
852
+ formatBySpan(e) {
853
+ return e.greaterThanOrEqual(l.days(30)) ? "shortDate" : e.greaterThanOrEqual(l.DAY) ? "dateTime" : e.greaterThanOrEqual(l.HOUR) ? "time" : e.greaterThanOrEqual(l.SECOND) ? "preciseTime" : "ISOTime";
854
+ }
828
855
  /**
829
856
  * @returns A new TimeStamp representing the current time in UTC. It's important to
830
857
  * note that this TimeStamp is only accurate to the millisecond level (that's the best
@@ -841,8 +868,8 @@ class u extends Z {
841
868
  */
842
869
  static max(...e) {
843
870
  let t = u.MIN;
844
- for (const r of e) {
845
- const i = new u(r);
871
+ for (const n of e) {
872
+ const i = new u(n);
846
873
  i.after(t) && (t = i);
847
874
  }
848
875
  return t;
@@ -855,8 +882,8 @@ class u extends Z {
855
882
  */
856
883
  static min(...e) {
857
884
  let t = u.MAX;
858
- for (const r of e) {
859
- const i = new u(r);
885
+ for (const n of e) {
886
+ const i = new u(n);
860
887
  i.before(t) && (t = i);
861
888
  }
862
889
  return t;
@@ -909,7 +936,7 @@ class u extends Z {
909
936
  /** One day after the unix epoch */
910
937
  static DAY = u.days(1);
911
938
  /** The maximum possible value for a timestamp */
912
- static MAX = new u(ce);
939
+ static MAX = new u(le);
913
940
  /** The minimum possible value for a timestamp */
914
941
  static MIN = new u(0);
915
942
  /** The unix epoch */
@@ -923,7 +950,7 @@ class u extends Z {
923
950
  s.bigint().transform((e) => new u(e)),
924
951
  s.date().transform((e) => new u(e)),
925
952
  s.custom((e) => e instanceof l).transform((e) => new u(e)),
926
- Gt.transform((e) => new u(e))
953
+ Wt.transform((e) => new u(e))
927
954
  ]);
928
955
  /**
929
956
  * Sorts two timestamps.
@@ -937,9 +964,9 @@ class u extends Z {
937
964
  return Number(e.valueOf() - t.valueOf());
938
965
  }
939
966
  }
940
- class l extends Z {
967
+ class l extends W {
941
968
  constructor(e) {
942
- typeof e == "number" && (e = Math.trunc(e.valueOf())), U(e) && (e = e.value), super(BigInt(e.valueOf()));
969
+ typeof e == "number" && (e = Math.trunc(e.valueOf())), A(e) && (e = e.value), super(BigInt(e.valueOf()));
943
970
  }
944
971
  /**
945
972
  * Creates a TimeSpan representing the given number of seconds.
@@ -948,7 +975,7 @@ class l extends Z {
948
975
  * @returns A TimeSpan representing the given number of seconds.
949
976
  */
950
977
  static fromSeconds(e) {
951
- return e instanceof l ? e : e instanceof E ? e.period : e instanceof u ? new l(e) : (U(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e));
978
+ return e instanceof l ? e : e instanceof N ? e.period : e instanceof u ? new l(e) : (A(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e));
952
979
  }
953
980
  /**
954
981
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -957,7 +984,7 @@ class l extends Z {
957
984
  * @returns A TimeSpan representing the given number of milliseconds.
958
985
  */
959
986
  static fromMilliseconds(e) {
960
- return e instanceof l ? e : e instanceof E ? e.period : e instanceof u ? new l(e) : (U(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e));
987
+ return e instanceof l ? e : e instanceof N ? e.period : e instanceof u ? new l(e) : (A(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e));
961
988
  }
962
989
  /**
963
990
  * @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
@@ -1009,7 +1036,7 @@ class l extends Z {
1009
1036
  * @returns A new TimeSpan representing the remainder.
1010
1037
  */
1011
1038
  remainder(e) {
1012
- return qe(this, e);
1039
+ return je(this, e);
1013
1040
  }
1014
1041
  /**
1015
1042
  * Truncates the TimeSpan to the nearest multiple of the given span.
@@ -1032,65 +1059,65 @@ class l extends Z {
1032
1059
  */
1033
1060
  toString(e = "full") {
1034
1061
  if (e === "semantic") return this.toSemanticString();
1035
- const t = this.truncate(l.DAY), r = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), a = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), d = this.truncate(l.MICROSECOND), y = this.truncate(l.NANOSECOND), f = t, g = r.sub(t), w = i.sub(r), h = a.sub(i), T = c.sub(a), A = d.sub(c), M = y.sub(d);
1062
+ const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), a = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), d = this.truncate(l.MICROSECOND), w = this.truncate(l.NANOSECOND), h = t, g = n.sub(t), b = i.sub(n), f = a.sub(i), v = c.sub(a), x = d.sub(c), U = w.sub(d);
1036
1063
  let m = "";
1037
- return f.isZero || (m += `${f.days}d `), g.isZero || (m += `${g.hours}h `), w.isZero || (m += `${w.minutes}m `), h.isZero || (m += `${h.seconds}s `), T.isZero || (m += `${T.milliseconds}ms `), A.isZero || (m += `${A.microseconds}µs `), M.isZero || (m += `${M.nanoseconds}ns`), m.trim();
1064
+ return h.isZero || (m += `${h.days}d `), g.isZero || (m += `${g.hours}h `), b.isZero || (m += `${b.minutes}m `), f.isZero || (m += `${f.seconds}s `), v.isZero || (m += `${v.milliseconds}ms `), x.isZero || (m += `${x.microseconds}µs `), U.isZero || (m += `${U.nanoseconds}ns`), m.trim();
1038
1065
  }
1039
1066
  toSemanticString() {
1040
- const e = this.valueOf() < 0n ? -this.valueOf() : this.valueOf(), t = new l(e), r = this.valueOf() < 0n;
1067
+ const e = this.valueOf() < 0n ? -this.valueOf() : this.valueOf(), t = new l(e), n = this.valueOf() < 0n;
1041
1068
  if (t.valueOf() === 0n) return "0s";
1042
1069
  if (t.lessThan(l.SECOND)) return "< 1s";
1043
- const i = t.days, a = t.hours, c = t.minutes, d = t.seconds, y = Math.floor(i / xe), f = Math.floor(i / K), g = Math.floor(i / 7), w = Math.floor(i), h = Math.floor(a), T = Math.floor(c), A = Math.floor(d), M = r ? "-" : "";
1044
- if (y >= 1) {
1045
- let m = `${y}y`;
1046
- if (y < 2) {
1047
- const v = Math.floor(
1048
- i % xe / K
1070
+ const i = t.days, a = t.hours, c = t.minutes, d = t.seconds, w = Math.floor(i / Ne), h = Math.floor(i / J), g = Math.floor(i / 7), b = Math.floor(i), f = Math.floor(a), v = Math.floor(c), x = Math.floor(d), U = n ? "-" : "";
1071
+ if (w >= 1) {
1072
+ let m = `${w}y`;
1073
+ if (w < 2) {
1074
+ const I = Math.floor(
1075
+ i % Ne / J
1049
1076
  );
1050
- v > 0 && (m += ` ${v}mo`);
1077
+ I > 0 && (m += ` ${I}mo`);
1051
1078
  }
1052
- return M + m;
1079
+ return U + m;
1053
1080
  }
1054
- if (g >= 1 && i < K && i % 7 === 0) {
1081
+ if (g >= 1 && i < J && i % 7 === 0) {
1055
1082
  let m = `${g}w`;
1056
- const v = Math.floor(i % 7), L = Math.floor(a - g * 7 * 24);
1057
- return g < 2 && (v > 0 ? m += ` ${v}d` : L > 0 && L < 24 && (m += ` ${L}h`)), M + m;
1083
+ const I = Math.floor(i % 7), D = Math.floor(a - g * 7 * 24);
1084
+ return g < 2 && (I > 0 ? m += ` ${I}d` : D > 0 && D < 24 && (m += ` ${D}h`)), U + m;
1058
1085
  }
1059
- if (f >= 1) {
1060
- let m = `${f}mo`;
1061
- if (f < 3) {
1062
- const v = Math.floor(i % K);
1063
- v > 0 && (m += ` ${v}d`);
1086
+ if (h >= 1) {
1087
+ let m = `${h}mo`;
1088
+ if (h < 3) {
1089
+ const I = Math.floor(i % J);
1090
+ I > 0 && (m += ` ${I}d`);
1064
1091
  }
1065
- return M + m;
1092
+ return U + m;
1066
1093
  }
1067
1094
  if (g >= 1) {
1068
1095
  let m = `${g}w`;
1069
- const v = Math.floor(i % 7), L = Math.floor(a - g * 7 * 24);
1070
- return g < 2 && (v > 0 ? m += ` ${v}d` : L > 0 && L < 24 && (m += ` ${L}h`)), M + m;
1096
+ const I = Math.floor(i % 7), D = Math.floor(a - g * 7 * 24);
1097
+ return g < 2 && (I > 0 ? m += ` ${I}d` : D > 0 && D < 24 && (m += ` ${D}h`)), U + m;
1071
1098
  }
1072
- if (w >= 1) {
1073
- let m = `${w}d`;
1074
- const v = Math.floor(a - w * 24);
1075
- return w < 2 && v > 0 && (m += ` ${v}h`), M + m;
1099
+ if (b >= 1) {
1100
+ let m = `${b}d`;
1101
+ const I = Math.floor(a - b * 24);
1102
+ return b < 2 && I > 0 && (m += ` ${I}h`), U + m;
1076
1103
  }
1077
- if (h >= 1) {
1078
- let m = `${h}h`;
1079
- if (h < 3) {
1080
- const v = Math.floor(c - h * 60);
1081
- v > 0 && (m += ` ${v}m`);
1104
+ if (f >= 1) {
1105
+ let m = `${f}h`;
1106
+ if (f < 3) {
1107
+ const I = Math.floor(c - f * 60);
1108
+ I > 0 && (m += ` ${I}m`);
1082
1109
  }
1083
- return M + m;
1110
+ return U + m;
1084
1111
  }
1085
- if (T >= 1) {
1086
- let m = `${T}m`;
1087
- if (T < 5) {
1088
- const v = Math.floor(d - T * 60);
1089
- v > 0 && (m += ` ${v}s`);
1112
+ if (v >= 1) {
1113
+ let m = `${v}m`;
1114
+ if (v < 5) {
1115
+ const I = Math.floor(d - v * 60);
1116
+ I > 0 && (m += ` ${I}s`);
1090
1117
  }
1091
- return M + m;
1118
+ return U + m;
1092
1119
  }
1093
- return `${M}${A}s`;
1120
+ return `${U}${x}s`;
1094
1121
  }
1095
1122
  /**
1096
1123
  * Multiplies the TimeSpan by a scalar value.
@@ -1099,7 +1126,7 @@ class l extends Z {
1099
1126
  * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
1100
1127
  */
1101
1128
  mult(e) {
1102
- return new l(C(this.valueOf(), e));
1129
+ return new l($(this.valueOf(), e));
1103
1130
  }
1104
1131
  /**
1105
1132
  * Divides the TimeSpan by a scalar value.
@@ -1108,7 +1135,7 @@ class l extends Z {
1108
1135
  * @returns A new TimeSpan that is this TimeSpan divided by the provided value.
1109
1136
  */
1110
1137
  div(e) {
1111
- return new l(se(this.valueOf(), e));
1138
+ return new l(ne(this.valueOf(), e));
1112
1139
  }
1113
1140
  /** @returns the decimal number of days in the TimeSpan. */
1114
1141
  get days() {
@@ -1188,7 +1215,7 @@ class l extends Z {
1188
1215
  * @returns A TimeSpan representing the given number of microseconds.
1189
1216
  */
1190
1217
  static microseconds(e = 1) {
1191
- return l.nanoseconds(C(e, 1e3));
1218
+ return l.nanoseconds($(e, 1e3));
1192
1219
  }
1193
1220
  /** A microsecond. */
1194
1221
  static MICROSECOND = l.microseconds(1);
@@ -1199,7 +1226,7 @@ class l extends Z {
1199
1226
  * @returns A TimeSpan representing the given number of milliseconds.
1200
1227
  */
1201
1228
  static milliseconds(e = 1) {
1202
- return l.microseconds(C(e, 1e3));
1229
+ return l.microseconds($(e, 1e3));
1203
1230
  }
1204
1231
  /** A millisecond. */
1205
1232
  static MILLISECOND = l.milliseconds(1);
@@ -1210,7 +1237,7 @@ class l extends Z {
1210
1237
  * @returns A TimeSpan representing the given number of seconds.
1211
1238
  */
1212
1239
  static seconds(e = 1) {
1213
- return l.milliseconds(C(e, 1e3));
1240
+ return l.milliseconds($(e, 1e3));
1214
1241
  }
1215
1242
  /** A second. */
1216
1243
  static SECOND = l.seconds(1);
@@ -1221,7 +1248,7 @@ class l extends Z {
1221
1248
  * @returns A TimeSpan representing the given number of minutes.
1222
1249
  */
1223
1250
  static minutes(e = 1) {
1224
- return l.seconds(C(e, 60));
1251
+ return l.seconds($(e, 60));
1225
1252
  }
1226
1253
  /** A minute. */
1227
1254
  static MINUTE = l.minutes(1);
@@ -1232,7 +1259,7 @@ class l extends Z {
1232
1259
  * @returns A TimeSpan representing the given number of hours.
1233
1260
  */
1234
1261
  static hours(e) {
1235
- return l.minutes(C(e, 60));
1262
+ return l.minutes($(e, 60));
1236
1263
  }
1237
1264
  /** Represents an hour. */
1238
1265
  static HOUR = l.hours(1);
@@ -1243,12 +1270,12 @@ class l extends Z {
1243
1270
  * @returns A TimeSpan representing the given number of days.
1244
1271
  */
1245
1272
  static days(e) {
1246
- return l.hours(C(e, 24));
1273
+ return l.hours($(e, 24));
1247
1274
  }
1248
1275
  /** Represents a day. */
1249
1276
  static DAY = l.days(1);
1250
1277
  /** The maximum possible value for a TimeSpan. */
1251
- static MAX = new l(ce);
1278
+ static MAX = new l(le);
1252
1279
  /** The minimum possible value for a TimeSpan. */
1253
1280
  static MIN = new l(0);
1254
1281
  /** The zero value for a TimeSpan. */
@@ -1261,12 +1288,12 @@ class l extends Z {
1261
1288
  s.bigint().transform((e) => new l(e)),
1262
1289
  s.instanceof(l),
1263
1290
  s.instanceof(u).transform((e) => new l(e)),
1264
- s.custom((e) => e instanceof E).transform((e) => new l(e))
1291
+ s.custom((e) => e instanceof N).transform((e) => new l(e))
1265
1292
  ]);
1266
1293
  }
1267
- class E extends Z {
1294
+ class N extends W {
1268
1295
  constructor(e) {
1269
- U(e) && (e = e.value), super(e.valueOf());
1296
+ A(e) && (e = e.value), super(e.valueOf());
1270
1297
  }
1271
1298
  /** @returns a pretty string representation of the rate in the format "X Hz". */
1272
1299
  toString() {
@@ -1274,7 +1301,7 @@ class E extends Z {
1274
1301
  }
1275
1302
  /** @returns The number of seconds in the Rate. */
1276
1303
  equals(e) {
1277
- return this.valueOf() === new E(e).valueOf();
1304
+ return this.valueOf() === new N(e).valueOf();
1278
1305
  }
1279
1306
  /**
1280
1307
  * Calculates the period of the Rate as a TimeSpan.
@@ -1301,7 +1328,7 @@ class E extends Z {
1301
1328
  * @returns The number of bytes in the given TimeSpan at this rate.
1302
1329
  */
1303
1330
  byteCount(e, t) {
1304
- return this.sampleCount(e) * new I(t).valueOf();
1331
+ return this.sampleCount(e) * new y(t).valueOf();
1305
1332
  }
1306
1333
  /**
1307
1334
  * Calculates a TimeSpan given the number of samples at this rate.
@@ -1320,7 +1347,7 @@ class E extends Z {
1320
1347
  * @returns A TimeSpan that corresponds to the given number of bytes.
1321
1348
  */
1322
1349
  byteSpan(e, t) {
1323
- return this.span(e.valueOf() / new I(t).valueOf());
1350
+ return this.span(e.valueOf() / new y(t).valueOf());
1324
1351
  }
1325
1352
  /**
1326
1353
  * Adds another Rate to this Rate.
@@ -1329,7 +1356,7 @@ class E extends Z {
1329
1356
  * @returns A new Rate representing the sum of the two rates.
1330
1357
  */
1331
1358
  add(e) {
1332
- return new E(re(this.valueOf(), new E(e).valueOf()));
1359
+ return new N(re(this.valueOf(), new N(e).valueOf()));
1333
1360
  }
1334
1361
  /**
1335
1362
  * Subtracts another Rate from this Rate.
@@ -1338,7 +1365,7 @@ class E extends Z {
1338
1365
  * @returns A new Rate representing the difference of the two rates.
1339
1366
  */
1340
1367
  sub(e) {
1341
- return new E(ne(this.valueOf(), new E(e).valueOf()));
1368
+ return new N(te(this.valueOf(), new N(e).valueOf()));
1342
1369
  }
1343
1370
  /**
1344
1371
  * Multiplies this Rate by a scalar value.
@@ -1347,7 +1374,7 @@ class E extends Z {
1347
1374
  * @returns A new Rate representing this Rate multiplied by the value.
1348
1375
  */
1349
1376
  mult(e) {
1350
- return new E(C(this.valueOf(), e));
1377
+ return new N($(this.valueOf(), e));
1351
1378
  }
1352
1379
  /**
1353
1380
  * Divides this Rate by a scalar value.
@@ -1356,7 +1383,7 @@ class E extends Z {
1356
1383
  * @returns A new Rate representing this Rate divided by the value.
1357
1384
  */
1358
1385
  div(e) {
1359
- return new E(se(this.valueOf(), e));
1386
+ return new N(ne(this.valueOf(), e));
1360
1387
  }
1361
1388
  /**
1362
1389
  * Creates a Rate representing the given number of Hz.
@@ -1365,7 +1392,7 @@ class E extends Z {
1365
1392
  * @returns A Rate representing the given number of Hz.
1366
1393
  */
1367
1394
  static hz(e) {
1368
- return new E(e);
1395
+ return new N(e);
1369
1396
  }
1370
1397
  /**
1371
1398
  * Creates a Rate representing the given number of kHz.
@@ -1374,15 +1401,15 @@ class E extends Z {
1374
1401
  * @returns A Rate representing the given number of kHz.
1375
1402
  */
1376
1403
  static khz(e) {
1377
- return E.hz(e * 1e3);
1404
+ return N.hz(e * 1e3);
1378
1405
  }
1379
1406
  /** A zod schema for validating and transforming rates */
1380
1407
  static z = s.union([
1381
- s.number().transform((e) => new E(e)),
1382
- s.instanceof(E)
1408
+ s.number().transform((e) => new N(e)),
1409
+ s.instanceof(N)
1383
1410
  ]);
1384
1411
  }
1385
- let I = class N extends Z {
1412
+ class y extends W {
1386
1413
  /**
1387
1414
  * Creates a Density representing the given number of bytes per value.
1388
1415
  *
@@ -1391,7 +1418,7 @@ let I = class N extends Z {
1391
1418
  * @returns A Density representing the given number of bytes per value.
1392
1419
  */
1393
1420
  constructor(e) {
1394
- U(e) && (e = e.value), super(e.valueOf());
1421
+ A(e) && (e = e.value), super(e.valueOf());
1395
1422
  }
1396
1423
  /**
1397
1424
  * Calculates the number of values in the given Size.
@@ -1409,7 +1436,7 @@ let I = class N extends Z {
1409
1436
  * @returns A Size representing the given number of values.
1410
1437
  */
1411
1438
  size(e) {
1412
- return new he(e * this.valueOf());
1439
+ return new p(e * this.valueOf());
1413
1440
  }
1414
1441
  /**
1415
1442
  * Adds another Density to this Density.
@@ -1418,7 +1445,7 @@ let I = class N extends Z {
1418
1445
  * @returns A new Density representing the sum of the two densities.
1419
1446
  */
1420
1447
  add(e) {
1421
- return new N(re(this.valueOf(), new N(e).valueOf()));
1448
+ return new y(re(this.valueOf(), new y(e).valueOf()));
1422
1449
  }
1423
1450
  /**
1424
1451
  * Subtracts another Density from this Density.
@@ -1427,7 +1454,7 @@ let I = class N extends Z {
1427
1454
  * @returns A new Density representing the difference of the two densities.
1428
1455
  */
1429
1456
  sub(e) {
1430
- return new N(ne(this.valueOf(), new N(e).valueOf()));
1457
+ return new y(te(this.valueOf(), new y(e).valueOf()));
1431
1458
  }
1432
1459
  /**
1433
1460
  * Multiplies this Density by a scalar value.
@@ -1436,7 +1463,7 @@ let I = class N extends Z {
1436
1463
  * @returns A new Density representing this Density multiplied by the value.
1437
1464
  */
1438
1465
  mult(e) {
1439
- return new N(C(this.valueOf(), e));
1466
+ return new y($(this.valueOf(), e));
1440
1467
  }
1441
1468
  /**
1442
1469
  * Divides this Density by a scalar value.
@@ -1445,27 +1472,27 @@ let I = class N extends Z {
1445
1472
  * @returns A new Density representing this Density divided by the value.
1446
1473
  */
1447
1474
  div(e) {
1448
- return new N(se(this.valueOf(), e));
1475
+ return new y(ne(this.valueOf(), e));
1449
1476
  }
1450
1477
  /** Unknown/Invalid Density. */
1451
- static UNKNOWN = new N(0);
1478
+ static UNKNOWN = new y(0);
1452
1479
  /** 128 bits per value. */
1453
- static BIT128 = new N(16);
1480
+ static BIT128 = new y(16);
1454
1481
  /** 64 bits per value. */
1455
- static BIT64 = new N(8);
1482
+ static BIT64 = new y(8);
1456
1483
  /** 32 bits per value. */
1457
- static BIT32 = new N(4);
1484
+ static BIT32 = new y(4);
1458
1485
  /** 16 bits per value. */
1459
- static BIT16 = new N(2);
1486
+ static BIT16 = new y(2);
1460
1487
  /** 8 bits per value. */
1461
- static BIT8 = new N(1);
1488
+ static BIT8 = new y(1);
1462
1489
  /** A zod schema for validating and transforming densities */
1463
1490
  static z = s.union([
1464
- s.number().transform((e) => new N(e)),
1465
- s.instanceof(N)
1491
+ s.number().transform((e) => new y(e)),
1492
+ s.instanceof(y)
1466
1493
  ]);
1467
- };
1468
- class x {
1494
+ }
1495
+ class E {
1469
1496
  /**
1470
1497
  * The starting TimeStamp of the TimeRange.
1471
1498
  *
@@ -1533,7 +1560,7 @@ class x {
1533
1560
  * @returns A TimeRange with the start and end swapped.
1534
1561
  */
1535
1562
  swap() {
1536
- return new x(this.end, this.start);
1563
+ return new E(this.end, this.start);
1537
1564
  }
1538
1565
  get numericBounds() {
1539
1566
  return {
@@ -1550,8 +1577,8 @@ class x {
1550
1577
  equals(e, t = l.ZERO) {
1551
1578
  if (t.isZero)
1552
1579
  return this.start.equals(e.start) && this.end.equals(e.end);
1553
- let r = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1554
- return r < 0 && (r = -r), i < 0 && (i = -i), r <= t.valueOf() && i <= t.valueOf();
1580
+ let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1581
+ return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
1555
1582
  }
1556
1583
  /**
1557
1584
  * Returns a string representation of the TimeRange.
@@ -1582,14 +1609,14 @@ class x {
1582
1609
  */
1583
1610
  overlapsWith(e, t = l.ZERO) {
1584
1611
  e = e.makeValid();
1585
- const r = this.makeValid();
1612
+ const n = this.makeValid();
1586
1613
  if (this.equals(e)) return !0;
1587
- if (e.end.equals(r.start) || r.end.equals(e.start)) return !1;
1588
- const i = u.max(r.start, e.start), a = u.min(r.end, e.end);
1614
+ if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1615
+ const i = u.max(n.start, e.start), a = u.min(n.end, e.end);
1589
1616
  return a.before(i) ? !1 : new l(a.sub(i)).greaterThanOrEqual(t);
1590
1617
  }
1591
1618
  contains(e) {
1592
- return e instanceof x ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1619
+ return e instanceof E ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1593
1620
  }
1594
1621
  /**
1595
1622
  * Returns a new TimeRange that is bound by the given TimeRange.
@@ -1603,23 +1630,23 @@ class x {
1603
1630
  * console.log(bounded); // TimeRange(1500, 2000)
1604
1631
  */
1605
1632
  boundBy(e) {
1606
- const t = new x(this.start, this.end);
1633
+ const t = new E(this.start, this.end);
1607
1634
  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;
1608
1635
  }
1609
1636
  static max(...e) {
1610
- return new x(
1637
+ return new E(
1611
1638
  u.min(...e.map((t) => t.start)),
1612
1639
  u.max(...e.map((t) => t.end))
1613
1640
  );
1614
1641
  }
1615
1642
  /** The maximum possible time range. */
1616
- static MAX = new x(u.MIN, u.MAX);
1643
+ static MAX = new E(u.MIN, u.MAX);
1617
1644
  /** A time range whose start and end are both zero. */
1618
- static ZERO = new x(u.ZERO, u.ZERO);
1645
+ static ZERO = new E(u.ZERO, u.ZERO);
1619
1646
  /** A zod schema for validating and transforming time ranges */
1620
1647
  static z = s.union([
1621
- s.object({ start: u.z, end: u.z }).transform((e) => new x(e.start, e.end)),
1622
- s.instanceof(x)
1648
+ s.object({ start: u.z, end: u.z }).transform((e) => new E(e.start, e.end)),
1649
+ s.instanceof(E)
1623
1650
  ]);
1624
1651
  /**
1625
1652
  * Sorts two time ranges. The range with the earlier start time is considered less than
@@ -1643,18 +1670,18 @@ class x {
1643
1670
  * @returns A list of simplified `TimeRange`s.
1644
1671
  */
1645
1672
  static simplify(e) {
1646
- return e.map((t) => t.makeValid()).sort((t, r) => x.sort(t, r)).reduce((t, r) => {
1647
- if (r.span.isZero) return t;
1673
+ return e.map((t) => t.makeValid()).sort((t, n) => E.sort(t, n)).reduce((t, n) => {
1674
+ if (n.span.isZero) return t;
1648
1675
  if (t.length === 0)
1649
- return t.push(r), t;
1676
+ return t.push(n), t;
1650
1677
  const i = t[t.length - 1];
1651
- return i.overlapsWith(r) || i.end.equals(r.start) ? i.end = u.max(i.end, r.end) : t.push(r), t;
1678
+ return i.overlapsWith(n) || i.end.equals(n.start) ? i.end = u.max(i.end, n.end) : t.push(n), t;
1652
1679
  }, []);
1653
1680
  }
1654
1681
  }
1655
- let O = class o extends Z {
1682
+ let T = class o extends W {
1656
1683
  constructor(e) {
1657
- if (U(e) && (e = e.value), e instanceof o || typeof e == "string" || typeof e.valueOf() == "string")
1684
+ if (A(e) && (e = e.value), e instanceof o || typeof e == "string" || typeof e.valueOf() == "string")
1658
1685
  super(e.valueOf());
1659
1686
  else {
1660
1687
  const t = o.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
@@ -1832,20 +1859,20 @@ let O = class o extends Z {
1832
1859
  [BigInt64Array.name, o.INT64]
1833
1860
  ]);
1834
1861
  static DENSITIES = /* @__PURE__ */ new Map([
1835
- [o.UINT8.toString(), I.BIT8],
1836
- [o.UINT16.toString(), I.BIT16],
1837
- [o.UINT32.toString(), I.BIT32],
1838
- [o.UINT64.toString(), I.BIT64],
1839
- [o.FLOAT32.toString(), I.BIT32],
1840
- [o.FLOAT64.toString(), I.BIT64],
1841
- [o.INT8.toString(), I.BIT8],
1842
- [o.INT16.toString(), I.BIT16],
1843
- [o.INT32.toString(), I.BIT32],
1844
- [o.INT64.toString(), I.BIT64],
1845
- [o.TIMESTAMP.toString(), I.BIT64],
1846
- [o.STRING.toString(), I.UNKNOWN],
1847
- [o.JSON.toString(), I.UNKNOWN],
1848
- [o.UUID.toString(), I.BIT128]
1862
+ [o.UINT8.toString(), y.BIT8],
1863
+ [o.UINT16.toString(), y.BIT16],
1864
+ [o.UINT32.toString(), y.BIT32],
1865
+ [o.UINT64.toString(), y.BIT64],
1866
+ [o.FLOAT32.toString(), y.BIT32],
1867
+ [o.FLOAT64.toString(), y.BIT64],
1868
+ [o.INT8.toString(), y.BIT8],
1869
+ [o.INT16.toString(), y.BIT16],
1870
+ [o.INT32.toString(), y.BIT32],
1871
+ [o.INT64.toString(), y.BIT64],
1872
+ [o.TIMESTAMP.toString(), y.BIT64],
1873
+ [o.STRING.toString(), y.UNKNOWN],
1874
+ [o.JSON.toString(), y.UNKNOWN],
1875
+ [o.UUID.toString(), y.BIT128]
1849
1876
  ]);
1850
1877
  /** All the data types. */
1851
1878
  static ALL = [
@@ -1888,25 +1915,26 @@ let O = class o extends Z {
1888
1915
  s.string().transform((e) => new o(e)),
1889
1916
  s.instanceof(o)
1890
1917
  ]);
1891
- }, he = class p extends Z {
1918
+ };
1919
+ class p extends W {
1892
1920
  constructor(e) {
1893
- U(e) && (e = e.value), super(e.valueOf());
1921
+ A(e) && (e = e.value), super(e.valueOf());
1894
1922
  }
1895
1923
  /** @returns true if the Size is larger than the other size. */
1896
1924
  largerThan(e) {
1897
- return U(e) && (e = e.value), this.valueOf() > e.valueOf();
1925
+ return A(e) && (e = e.value), this.valueOf() > e.valueOf();
1898
1926
  }
1899
1927
  /** @returns true if the Size is smaller than the other size. */
1900
1928
  smallerThan(e) {
1901
- return U(e) && (e = e.value), this.valueOf() < e.valueOf();
1929
+ return A(e) && (e = e.value), this.valueOf() < e.valueOf();
1902
1930
  }
1903
1931
  /** @returns a new Size representing the sum of the two Sizes. */
1904
1932
  add(e) {
1905
- return U(e) && (e = e.value), new p(re(this.valueOf(), e.valueOf()));
1933
+ return A(e) && (e = e.value), new p(re(this.valueOf(), e.valueOf()));
1906
1934
  }
1907
1935
  /** @returns a new Size representing the difference of the two Sizes. */
1908
1936
  sub(e) {
1909
- return U(e) && (e = e.value), new p(ne(this.valueOf(), e.valueOf()));
1937
+ return A(e) && (e = e.value), new p(te(this.valueOf(), e.valueOf()));
1910
1938
  }
1911
1939
  /**
1912
1940
  * Multiplies this Size by a scalar value.
@@ -1915,7 +1943,7 @@ let O = class o extends Z {
1915
1943
  * @returns A new Size representing this Size multiplied by the value.
1916
1944
  */
1917
1945
  mult(e) {
1918
- return new p(C(this.valueOf(), e));
1946
+ return new p($(this.valueOf(), e));
1919
1947
  }
1920
1948
  /**
1921
1949
  * Divides this Size by a scalar value.
@@ -1924,7 +1952,7 @@ let O = class o extends Z {
1924
1952
  * @returns A new Size representing this Size divided by the value.
1925
1953
  */
1926
1954
  div(e) {
1927
- return new p(se(this.valueOf(), e));
1955
+ return new p(ne(this.valueOf(), e));
1928
1956
  }
1929
1957
  /** @returns a new Size representing the truncated value of the Size. */
1930
1958
  truncate(e) {
@@ -1954,9 +1982,9 @@ let O = class o extends Z {
1954
1982
  }
1955
1983
  /** @returns a nicely formatted string representation of the Size. */
1956
1984
  toString() {
1957
- const e = this.truncate(p.TERABYTE), t = this.truncate(p.GIGABYTE), r = this.truncate(p.MEGABYTE), i = this.truncate(p.KILOBYTE), a = this.truncate(p.BYTE), c = e, d = t.sub(e), y = r.sub(t), f = i.sub(r), g = a.sub(i);
1958
- let w = "";
1959
- return c.isZero || (w += `${c.terabytes}TB `), d.isZero || (w += `${d.gigabytes}GB `), y.isZero || (w += `${y.megabytes}MB `), f.isZero || (w += `${f.kilobytes}KB `), (!g.isZero || w === "") && (w += `${g.valueOf()}B`), w.trim();
1985
+ const e = this.truncate(p.TERABYTE), t = this.truncate(p.GIGABYTE), n = this.truncate(p.MEGABYTE), i = this.truncate(p.KILOBYTE), a = this.truncate(p.BYTE), c = e, d = t.sub(e), w = n.sub(t), h = i.sub(n), g = a.sub(i);
1986
+ let b = "";
1987
+ return c.isZero || (b += `${c.terabytes}TB `), d.isZero || (b += `${d.gigabytes}GB `), w.isZero || (b += `${w.megabytes}MB `), h.isZero || (b += `${h.kilobytes}KB `), (!g.isZero || b === "") && (b += `${g.valueOf()}B`), b.trim();
1960
1988
  }
1961
1989
  /**
1962
1990
  * Creates a Size from the given number of bytes.
@@ -2024,7 +2052,7 @@ let O = class o extends Z {
2024
2052
  get isZero() {
2025
2053
  return this.valueOf() === 0;
2026
2054
  }
2027
- };
2055
+ }
2028
2056
  s.object({
2029
2057
  start: s.number(),
2030
2058
  end: s.number()
@@ -2041,37 +2069,37 @@ s.union([
2041
2069
  s.instanceof(Int32Array),
2042
2070
  s.instanceof(BigInt64Array)
2043
2071
  ]);
2044
- const Fe = (n) => {
2045
- const e = typeof n;
2046
- return e === "string" || e === "number" || e === "boolean" || e === "bigint" || n instanceof u || n instanceof l || n instanceof Date;
2047
- }, zt = (n, e, t, r = 0) => n.usesBigInt && !e.usesBigInt ? Number(t) - Number(r) : !n.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(r.valueOf()) : Q(t, -r), Q = (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), Vt = /^(?:[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;
2048
- function Ht(n) {
2049
- return typeof n == "string" && Vt.test(n);
2072
+ const Ye = (r) => {
2073
+ const e = typeof r;
2074
+ return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof u || r instanceof l || r instanceof Date;
2075
+ }, Zt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : X(t, -n), X = (r, e) => e == 0 ? r : r == 0 ? e : typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : Number(r) + Number(e), zt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
2076
+ function Gt(r) {
2077
+ return typeof r == "string" && zt.test(r);
2050
2078
  }
2051
2079
  const S = [];
2052
- for (let n = 0; n < 256; ++n)
2053
- S.push((n + 256).toString(16).slice(1));
2054
- function Jt(n, e = 0) {
2055
- return (S[n[e + 0]] + S[n[e + 1]] + S[n[e + 2]] + S[n[e + 3]] + "-" + S[n[e + 4]] + S[n[e + 5]] + "-" + S[n[e + 6]] + S[n[e + 7]] + "-" + S[n[e + 8]] + S[n[e + 9]] + "-" + S[n[e + 10]] + S[n[e + 11]] + S[n[e + 12]] + S[n[e + 13]] + S[n[e + 14]] + S[n[e + 15]]).toLowerCase();
2080
+ for (let r = 0; r < 256; ++r)
2081
+ S.push((r + 256).toString(16).slice(1));
2082
+ function Vt(r, e = 0) {
2083
+ return (S[r[e + 0]] + S[r[e + 1]] + S[r[e + 2]] + S[r[e + 3]] + "-" + S[r[e + 4]] + S[r[e + 5]] + "-" + S[r[e + 6]] + S[r[e + 7]] + "-" + S[r[e + 8]] + S[r[e + 9]] + "-" + S[r[e + 10]] + S[r[e + 11]] + S[r[e + 12]] + S[r[e + 13]] + S[r[e + 14]] + S[r[e + 15]]).toLowerCase();
2056
2084
  }
2057
- function Kt(n, e = 0) {
2058
- const t = Jt(n, e);
2059
- if (!Ht(t))
2085
+ function Ht(r, e = 0) {
2086
+ const t = Vt(r, e);
2087
+ if (!Gt(t))
2060
2088
  throw TypeError("Stringified UUID is invalid");
2061
2089
  return t;
2062
2090
  }
2063
2091
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2064
- const We = (n, e) => Kt(n, e), R = -1, Xt = s.string().transform(
2065
- (n) => new Uint8Array(
2066
- atob(n).split("").map((e) => e.charCodeAt(0))
2092
+ const qe = (r, e) => Ht(r, e), B = -1, Jt = s.string().transform(
2093
+ (r) => new Uint8Array(
2094
+ atob(r).split("").map((e) => e.charCodeAt(0))
2067
2095
  ).buffer
2068
- ), Qt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), fe = 10, _t = (n, e) => {
2069
- if (n === "number" && !e.isNumeric)
2096
+ ), Kt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), ce = 10, Xt = (r, e) => {
2097
+ if (r === "number" && !e.isNumeric)
2070
2098
  throw new Error(`cannot convert series of type ${e.toString()} to number`);
2071
- if (n === "bigint" && !e.usesBigInt)
2099
+ if (r === "bigint" && !e.usesBigInt)
2072
2100
  throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
2073
- }, Ze = "sy_x_telem_series";
2074
- class B {
2101
+ }, Fe = "sy_x_telem_series";
2102
+ class C {
2075
2103
  /**
2076
2104
  * A unique identifier for the series. If specified by the user, it is their
2077
2105
  * responsibility to ensure that it is unique. If not specified, a new ID will be
@@ -2082,7 +2110,7 @@ class B {
2082
2110
  * A discriminator used for identifying instances of the series class even
2083
2111
  * when bundlers mangle the class name.
2084
2112
  */
2085
- discriminator = Ze;
2113
+ discriminator = Fe;
2086
2114
  /** The data type of the series. */
2087
2115
  dataType;
2088
2116
  /**
@@ -2098,7 +2126,7 @@ class B {
2098
2126
  /** The underlying data. */
2099
2127
  _data;
2100
2128
  /** The time range occupied by the series' data. */
2101
- timeRange = x.ZERO;
2129
+ timeRange = E.ZERO;
2102
2130
  /**
2103
2131
  * Alignment defines the location of the series relative to other series in a logical
2104
2132
  * group. Useful for defining the position of the series within a channel's data.
@@ -2115,7 +2143,7 @@ class B {
2115
2143
  /** A cached maximum value. */
2116
2144
  cachedMax;
2117
2145
  /** The write position of the buffer. */
2118
- writePos = R;
2146
+ writePos = B;
2119
2147
  /** Tracks the number of entities currently using this array. */
2120
2148
  _refCount = 0;
2121
2149
  /** Caches the length of the array for variable length data types. */
@@ -2127,22 +2155,22 @@ class B {
2127
2155
  * can be constructed into a series.
2128
2156
  */
2129
2157
  static crudeZ = s.object({
2130
- timeRange: x.z.optional(),
2131
- dataType: O.z,
2158
+ timeRange: E.z.optional(),
2159
+ dataType: T.z,
2132
2160
  alignment: s.coerce.bigint().optional(),
2133
2161
  data: s.union([
2134
- Xt,
2135
- Qt,
2162
+ Jt,
2163
+ Kt,
2136
2164
  s.instanceof(ArrayBuffer),
2137
2165
  s.instanceof(Uint8Array)
2138
2166
  ]),
2139
- glBufferUsage: Wt.optional().default("static").optional()
2167
+ glBufferUsage: qt.optional().default("static").optional()
2140
2168
  });
2141
2169
  /**
2142
2170
  * A zod schema that validates and constructs a series from it's crude
2143
2171
  * representation.
2144
2172
  */
2145
- static z = B.crudeZ.transform((e) => new B(e));
2173
+ static z = C.crudeZ.transform((e) => new C(e));
2146
2174
  /**
2147
2175
  * The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
2148
2176
  *
@@ -2217,70 +2245,70 @@ class B {
2217
2245
  * @throws Error if data type cannot be inferred from input
2218
2246
  */
2219
2247
  constructor(e) {
2220
- en(e) && (e = { data: e }), e.data ??= [];
2248
+ Qt(e) && (e = { data: e }), e.data ??= [];
2221
2249
  const {
2222
2250
  dataType: t,
2223
- timeRange: r,
2251
+ timeRange: n,
2224
2252
  sampleOffset: i = 0,
2225
2253
  glBufferUsage: a = "static",
2226
2254
  alignment: c = 0n,
2227
2255
  alignmentMultiple: d = 1n,
2228
- key: y = qt(),
2229
- data: f
2256
+ key: w = jt(),
2257
+ data: h
2230
2258
  } = e;
2231
- if (tn(f)) {
2232
- const h = f;
2233
- 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;
2259
+ if (_t(h)) {
2260
+ const f = h;
2261
+ this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this.timeRange = f.timeRange, this.alignment = f.alignment, this.alignmentMultiple = f.alignmentMultiple, this.cachedMin = f.cachedMin, this.cachedMax = f.cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this.cachedLength = f.cachedLength;
2234
2262
  return;
2235
2263
  }
2236
- const g = Fe(f), w = Array.isArray(f);
2237
- if (t != null) this.dataType = new O(t);
2264
+ const g = Ye(h), b = Array.isArray(h);
2265
+ if (t != null) this.dataType = new T(t);
2238
2266
  else {
2239
- if (f instanceof ArrayBuffer)
2267
+ if (h instanceof ArrayBuffer)
2240
2268
  throw new Error(
2241
2269
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
2242
2270
  );
2243
- if (w || g) {
2244
- let h = f;
2271
+ if (b || g) {
2272
+ let f = h;
2245
2273
  if (!g) {
2246
- if (f.length === 0)
2274
+ if (h.length === 0)
2247
2275
  throw new Error(
2248
2276
  "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
2249
2277
  );
2250
- h = f[0];
2278
+ f = h[0];
2251
2279
  }
2252
- if (typeof h == "string") this.dataType = O.STRING;
2253
- else if (typeof h == "number") this.dataType = O.FLOAT64;
2254
- else if (typeof h == "bigint") this.dataType = O.INT64;
2255
- else if (typeof h == "boolean") this.dataType = O.BOOLEAN;
2256
- else if (h instanceof u || h instanceof Date || h instanceof u)
2257
- this.dataType = O.TIMESTAMP;
2258
- else if (typeof h == "object") this.dataType = O.JSON;
2280
+ if (typeof f == "string") this.dataType = T.STRING;
2281
+ else if (typeof f == "number") this.dataType = T.FLOAT64;
2282
+ else if (typeof f == "bigint") this.dataType = T.INT64;
2283
+ else if (typeof f == "boolean") this.dataType = T.BOOLEAN;
2284
+ else if (f instanceof u || f instanceof Date || f instanceof u)
2285
+ this.dataType = T.TIMESTAMP;
2286
+ else if (typeof f == "object") this.dataType = T.JSON;
2259
2287
  else
2260
2288
  throw new Error(
2261
- `cannot infer data type of ${typeof h} when constructing a Series from a JS array`
2289
+ `cannot infer data type of ${typeof f} when constructing a Series from a JS array`
2262
2290
  );
2263
- } else this.dataType = new O(f);
2291
+ } else this.dataType = new T(h);
2264
2292
  }
2265
- if (!w && !g) this._data = f;
2266
- else if (w && f.length === 0)
2293
+ if (!b && !g) this._data = h;
2294
+ else if (b && h.length === 0)
2267
2295
  this._data = new this.dataType.Array([]).buffer;
2268
2296
  else {
2269
- let h = g ? [f] : f;
2270
- const T = h[0];
2271
- (T instanceof u || T instanceof Date || T instanceof l) && (h = h.map((A) => new u(A).valueOf())), this.dataType.equals(O.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
2297
+ let f = g ? [h] : h;
2298
+ const v = f[0];
2299
+ (v instanceof u || v instanceof Date || v instanceof l) && (f = f.map((x) => new u(x).valueOf())), this.dataType.equals(T.STRING) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
2272
2300
  `)}
2273
- `).buffer) : this.dataType.equals(O.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
2274
- `${h.map((A) => le.encodeString(A)).join(`
2301
+ `).buffer) : this.dataType.equals(T.JSON) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(
2302
+ `${f.map((x) => ue.encodeString(x)).join(`
2275
2303
  `)}
2276
2304
  `
2277
- ).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
2278
- h.map((A) => BigInt(Math.round(A)))
2279
- ).buffer : !this.dataType.usesBigInt && typeof T == "bigint" ? this._data = new this.dataType.Array(
2280
- h.map(Number)
2281
- ).buffer : this._data = new this.dataType.Array(h).buffer;
2305
+ ).buffer) : this.dataType.usesBigInt && typeof v == "number" ? this._data = new this.dataType.Array(
2306
+ f.map((x) => BigInt(Math.round(x)))
2307
+ ).buffer : !this.dataType.usesBigInt && typeof v == "bigint" ? this._data = new this.dataType.Array(
2308
+ f.map(Number)
2309
+ ).buffer : this._data = new this.dataType.Array(f).buffer;
2282
2310
  }
2283
- this.key = y, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = r ?? x.ZERO, this.gl = {
2311
+ this.key = w, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? E.ZERO, this.gl = {
2284
2312
  control: null,
2285
2313
  buffer: null,
2286
2314
  prevBuffer: 0,
@@ -2294,10 +2322,10 @@ class B {
2294
2322
  * @param args.dataType the data type of the series.
2295
2323
  * @param args.rest the rest of the arguments to pass to the series constructor.
2296
2324
  */
2297
- static alloc({ capacity: e, dataType: t, ...r }) {
2325
+ static alloc({ capacity: e, dataType: t, ...n }) {
2298
2326
  if (e === 0)
2299
2327
  throw new Error("[Series] - cannot allocate an array of length 0");
2300
- const i = new new O(t).Array(e), a = new B({ data: i.buffer, dataType: t, ...r });
2328
+ const i = new new T(t).Array(e), a = new C({ data: i.buffer, dataType: t, ...n });
2301
2329
  return a.writePos = 0, a;
2302
2330
  }
2303
2331
  /**
@@ -2340,14 +2368,14 @@ class B {
2340
2368
  return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
2341
2369
  }
2342
2370
  writeVariable(e) {
2343
- if (this.writePos === R) return 0;
2344
- const t = this.byteCapacity.valueOf() - this.writePos, r = e.subBytes(0, t);
2345
- return this.writeToUnderlyingData(r), this.writePos += r.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += r.length, this.calculateCachedLength()), r.length;
2371
+ if (this.writePos === B) return 0;
2372
+ const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
2373
+ return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += n.length, this.calculateCachedLength()), n.length;
2346
2374
  }
2347
2375
  writeFixed(e) {
2348
- if (this.writePos === R) return 0;
2349
- const t = this.capacity - this.writePos, r = e.sub(0, t);
2350
- return this.writeToUnderlyingData(r), this.cachedLength = void 0, this.maybeRecomputeMinMax(r), this.writePos += r.length, r.length;
2376
+ if (this.writePos === B) return 0;
2377
+ const t = this.capacity - this.writePos, n = e.sub(0, t);
2378
+ return this.writeToUnderlyingData(n), this.cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
2351
2379
  }
2352
2380
  writeToUnderlyingData(e) {
2353
2381
  this.underlyingData.set(
@@ -2368,7 +2396,7 @@ class B {
2368
2396
  * @returns A typed array containing the series data.
2369
2397
  */
2370
2398
  get data() {
2371
- return this.writePos === R ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2399
+ return this.writePos === B ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2372
2400
  }
2373
2401
  /**
2374
2402
  * Returns an array of the values in the series as strings.
@@ -2387,16 +2415,16 @@ class B {
2387
2415
  * @returns An array of values parsed from the JSON series.
2388
2416
  */
2389
2417
  parseJSON(e) {
2390
- if (!this.dataType.equals(O.JSON))
2418
+ if (!this.dataType.equals(T.JSON))
2391
2419
  throw new Error("cannot parse non-JSON series as JSON");
2392
- return this.toStrings().map((t) => e.parse(le.decodeString(t)));
2420
+ return this.toStrings().map((t) => e.parse(ue.decodeString(t)));
2393
2421
  }
2394
2422
  /**
2395
2423
  * Returns the capacity of the series in bytes.
2396
2424
  * @returns The size of the underlying buffer in bytes.
2397
2425
  */
2398
2426
  get byteCapacity() {
2399
- return new he(this.underlyingData.byteLength);
2427
+ return new p(this.underlyingData.byteLength);
2400
2428
  }
2401
2429
  /**
2402
2430
  * Returns the capacity of the series in samples.
@@ -2412,7 +2440,7 @@ class B {
2412
2440
  * @returns The size of the data in bytes.
2413
2441
  */
2414
2442
  get byteLength() {
2415
- return this.writePos === R ? this.byteCapacity : this.dataType.isVariable ? new he(this.writePos) : this.dataType.density.size(this.writePos);
2443
+ return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new p(this.writePos) : this.dataType.density.size(this.writePos);
2416
2444
  }
2417
2445
  /**
2418
2446
  * Returns the number of samples in this array.
@@ -2420,15 +2448,15 @@ class B {
2420
2448
  * @returns The number of samples in the series.
2421
2449
  */
2422
2450
  get length() {
2423
- return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === R ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
2451
+ return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === B ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
2424
2452
  }
2425
2453
  calculateCachedLength() {
2426
2454
  if (!this.dataType.isVariable)
2427
2455
  throw new Error("cannot calculate length of a non-variable length data type");
2428
2456
  let e = 0;
2429
2457
  const t = [0];
2430
- return this.data.forEach((r, i) => {
2431
- r === fe && (e++, t.push(i + 1));
2458
+ return this.data.forEach((n, i) => {
2459
+ n === ce && (e++, t.push(i + 1));
2432
2460
  }), this._cachedIndexes = t, this.cachedLength = e, e;
2433
2461
  }
2434
2462
  /**
@@ -2442,11 +2470,11 @@ class B {
2442
2470
  */
2443
2471
  convert(e, t = 0) {
2444
2472
  if (this.dataType.equals(e)) return this;
2445
- const r = new e.Array(this.length);
2473
+ const n = new e.Array(this.length);
2446
2474
  for (let i = 0; i < this.length; i++)
2447
- r[i] = zt(this.dataType, e, this.data[i], t);
2448
- return new B({
2449
- data: r.buffer,
2475
+ n[i] = Zt(this.dataType, e, this.data[i], t);
2476
+ return new C({
2477
+ data: n.buffer,
2450
2478
  dataType: e,
2451
2479
  timeRange: this.timeRange,
2452
2480
  sampleOffset: t,
@@ -2456,14 +2484,14 @@ class B {
2456
2484
  }
2457
2485
  calcRawMax() {
2458
2486
  if (this.length === 0) return -1 / 0;
2459
- if (this.dataType.equals(O.TIMESTAMP))
2487
+ if (this.dataType.equals(T.TIMESTAMP))
2460
2488
  this.cachedMax = this.data[this.data.length - 1];
2461
2489
  else if (this.dataType.usesBigInt) {
2462
2490
  const e = this.data;
2463
- this.cachedMax = e.reduce((t, r) => t > r ? t : r);
2491
+ this.cachedMax = e.reduce((t, n) => t > n ? t : n);
2464
2492
  } else {
2465
2493
  const e = this.data;
2466
- this.cachedMax = e.reduce((t, r) => t > r ? t : r);
2494
+ this.cachedMax = e.reduce((t, n) => t > n ? t : n);
2467
2495
  }
2468
2496
  return this.cachedMax;
2469
2497
  }
@@ -2474,17 +2502,17 @@ class B {
2474
2502
  calcMax() {
2475
2503
  if (this.dataType.isVariable)
2476
2504
  throw new Error("cannot calculate maximum on a variable length data type");
2477
- return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), Q(this.cachedMax, this.sampleOffset));
2505
+ return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), X(this.cachedMax, this.sampleOffset));
2478
2506
  }
2479
2507
  calcRawMin() {
2480
2508
  if (this.length === 0) return 1 / 0;
2481
- if (this.dataType.equals(O.TIMESTAMP)) this.cachedMin = this.data[0];
2509
+ if (this.dataType.equals(T.TIMESTAMP)) this.cachedMin = this.data[0];
2482
2510
  else if (this.dataType.usesBigInt) {
2483
2511
  const e = this.data;
2484
- this.cachedMin = e.reduce((t, r) => t < r ? t : r);
2512
+ this.cachedMin = e.reduce((t, n) => t < n ? t : n);
2485
2513
  } else {
2486
2514
  const e = this.data;
2487
- this.cachedMin = e.reduce((t, r) => t < r ? t : r);
2515
+ this.cachedMin = e.reduce((t, n) => t < n ? t : n);
2488
2516
  }
2489
2517
  return this.cachedMin;
2490
2518
  }
@@ -2495,11 +2523,11 @@ class B {
2495
2523
  calcMin() {
2496
2524
  if (this.dataType.isVariable)
2497
2525
  throw new Error("cannot calculate minimum on a variable length data type");
2498
- return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), Q(this.cachedMin, this.sampleOffset));
2526
+ return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), X(this.cachedMin, this.sampleOffset));
2499
2527
  }
2500
2528
  /** @returns the bounds of the series. */
2501
2529
  get bounds() {
2502
- return P(Number(this.min), Number(this.max), { makeValid: !1 });
2530
+ return L(Number(this.min), Number(this.max), { makeValid: !1 });
2503
2531
  }
2504
2532
  maybeRecomputeMinMax(e) {
2505
2533
  if (this.cachedMin != null) {
@@ -2512,56 +2540,56 @@ class B {
2512
2540
  }
2513
2541
  }
2514
2542
  atAlignment(e, t) {
2515
- const r = Number((e - this.alignment) / this.alignmentMultiple);
2516
- if (r < 0 || r >= this.length) {
2517
- if (t === !0) throw new Error(`[series] - no value at index ${r}`);
2543
+ const n = Number((e - this.alignment) / this.alignmentMultiple);
2544
+ if (n < 0 || n >= this.length) {
2545
+ if (t === !0) throw new Error(`[series] - no value at index ${n}`);
2518
2546
  return;
2519
2547
  }
2520
- return this.at(r, t);
2548
+ return this.at(n, t);
2521
2549
  }
2522
2550
  at(e, t = !1) {
2523
2551
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
2524
- if (this.dataType.equals(O.UUID)) return this.atUUID(e, t);
2552
+ if (this.dataType.equals(T.UUID)) return this.atUUID(e, t);
2525
2553
  e < 0 && (e = this.length + e);
2526
- const r = this.data[e];
2527
- if (r == null) {
2554
+ const n = this.data[e];
2555
+ if (n == null) {
2528
2556
  if (t === !0) throw new Error(`[series] - no value at index ${e}`);
2529
2557
  return;
2530
2558
  }
2531
- return Q(r, this.sampleOffset);
2559
+ return X(n, this.sampleOffset);
2532
2560
  }
2533
2561
  atUUID(e, t) {
2534
2562
  e < 0 && (e = this.length + e);
2535
- const r = We(
2563
+ const n = qe(
2536
2564
  new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
2537
2565
  );
2538
- if (r == null) {
2566
+ if (n == null) {
2539
2567
  if (t) throw new Error(`[series] - no value at index ${e}`);
2540
2568
  return;
2541
2569
  }
2542
- return r;
2570
+ return n;
2543
2571
  }
2544
2572
  atVariable(e, t) {
2545
- let r = 0, i = 0;
2573
+ let n = 0, i = 0;
2546
2574
  if (this._cachedIndexes != null)
2547
- r = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
2575
+ n = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
2548
2576
  else {
2549
2577
  e < 0 && (e = this.length + e);
2550
2578
  for (let c = 0; c < this.data.length; c++)
2551
- if (this.data[c] === fe) {
2579
+ if (this.data[c] === ce) {
2552
2580
  if (e === 0) {
2553
2581
  i = c;
2554
2582
  break;
2555
2583
  }
2556
- r = c + 1, e--;
2584
+ n = c + 1, e--;
2557
2585
  }
2558
- if (i === 0 && (i = this.data.length), r >= i || e > 0) {
2586
+ if (i === 0 && (i = this.data.length), n >= i || e > 0) {
2559
2587
  if (t) throw new Error(`[series] - no value at index ${e}`);
2560
2588
  return;
2561
2589
  }
2562
2590
  }
2563
- const a = this.data.slice(r, i);
2564
- return this.dataType.equals(O.STRING) ? new TextDecoder().decode(a) : $e(JSON.parse(new TextDecoder().decode(a)));
2591
+ const a = this.data.slice(n, i);
2592
+ return this.dataType.equals(T.STRING) ? new TextDecoder().decode(a) : Ue(JSON.parse(new TextDecoder().decode(a)));
2565
2593
  }
2566
2594
  /**
2567
2595
  * @returns the index of the first sample that is greater than or equal to the given value.
@@ -2569,12 +2597,12 @@ class B {
2569
2597
  * @param value the value to search for.
2570
2598
  */
2571
2599
  binarySearch(e) {
2572
- let t = 0, r = this.length - 1;
2573
- const i = ut(e);
2574
- for (; t <= r; ) {
2575
- const a = Math.floor((t + r) / 2), c = i(this.at(a, !0), e);
2600
+ let t = 0, n = this.length - 1;
2601
+ const i = at(e);
2602
+ for (; t <= n; ) {
2603
+ const a = Math.floor((t + n) / 2), c = i(this.at(a, !0), e);
2576
2604
  if (c === 0) return a;
2577
- c < 0 ? t = a + 1 : r = a - 1;
2605
+ c < 0 ? t = a + 1 : n = a - 1;
2578
2606
  }
2579
2607
  return t;
2580
2608
  }
@@ -2586,11 +2614,11 @@ class B {
2586
2614
  * be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
2587
2615
  */
2588
2616
  updateGLBuffer(e) {
2589
- if (this.gl.control = e, !this.dataType.equals(O.FLOAT32) && !this.dataType.equals(O.UINT8))
2617
+ if (this.gl.control = e, !this.dataType.equals(T.FLOAT32) && !this.dataType.equals(T.UINT8))
2590
2618
  throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2591
- const { buffer: t, bufferUsage: r, prevBuffer: i } = this.gl;
2619
+ const { buffer: t, bufferUsage: n, prevBuffer: i } = this.gl;
2592
2620
  if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
2593
- if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== R) {
2621
+ if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
2594
2622
  i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
2595
2623
  const a = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
2596
2624
  e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
@@ -2598,11 +2626,11 @@ class B {
2598
2626
  e.bufferData(
2599
2627
  e.ARRAY_BUFFER,
2600
2628
  this.buffer,
2601
- r === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2602
- ), this.gl.prevBuffer = R;
2629
+ n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2630
+ ), this.gl.prevBuffer = B;
2603
2631
  }
2604
2632
  as(e) {
2605
- return _t(e, this.dataType), this;
2633
+ return Xt(e, this.dataType), this;
2606
2634
  }
2607
2635
  /** @returns a digest containing information about the series. */
2608
2636
  get digest() {
@@ -2611,8 +2639,8 @@ class B {
2611
2639
  dataType: this.dataType.toString(),
2612
2640
  sampleOffset: this.sampleOffset,
2613
2641
  alignment: {
2614
- lower: Ue(this.alignmentBounds.lower),
2615
- upper: Ue(this.alignmentBounds.upper),
2642
+ lower: xe(this.alignmentBounds.lower),
2643
+ upper: xe(this.alignmentBounds.upper),
2616
2644
  multiple: this.alignmentMultiple
2617
2645
  },
2618
2646
  timeRange: this.timeRange.toString(),
@@ -2630,7 +2658,7 @@ class B {
2630
2658
  * is exclusive.
2631
2659
  */
2632
2660
  get alignmentBounds() {
2633
- return P(
2661
+ return L(
2634
2662
  this.alignment,
2635
2663
  this.alignment + BigInt(this.length) * this.alignmentMultiple
2636
2664
  );
@@ -2650,10 +2678,10 @@ class B {
2650
2678
  }
2651
2679
  [Symbol.iterator]() {
2652
2680
  if (this.dataType.isVariable) {
2653
- const e = new nn(this);
2654
- return this.dataType.equals(O.JSON) ? new rn(e) : e;
2681
+ const e = new er(this);
2682
+ return this.dataType.equals(T.JSON) ? new tr(e) : e;
2655
2683
  }
2656
- return this.dataType.equals(O.UUID) ? new sn(this) : new an(this);
2684
+ return this.dataType.equals(T.UUID) ? new rr(this) : new nr(this);
2657
2685
  }
2658
2686
  /**
2659
2687
  * Returns a slice of the series from start to end.
@@ -2680,7 +2708,7 @@ class B {
2680
2708
  * @returns An iterator over the specified range.
2681
2709
  */
2682
2710
  subIterator(e, t) {
2683
- return new Ae(this, e, t ?? this.length);
2711
+ return new Ee(this, e, t ?? this.length);
2684
2712
  }
2685
2713
  /**
2686
2714
  * Returns an iterator over a portion of the series based on alignment.
@@ -2689,18 +2717,18 @@ class B {
2689
2717
  * @returns An iterator over the specified alignment range.
2690
2718
  */
2691
2719
  subAlignmentIterator(e, t) {
2692
- const r = Math.ceil(
2720
+ const n = Math.ceil(
2693
2721
  Number(e - this.alignment) / Number(this.alignmentMultiple)
2694
2722
  ), i = Math.ceil(
2695
2723
  Number(t - this.alignment) / Number(this.alignmentMultiple)
2696
2724
  );
2697
- return new Ae(this, r, i);
2725
+ return new Ee(this, n, i);
2698
2726
  }
2699
2727
  subBytes(e, t) {
2700
2728
  if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
2701
- const r = this.data.subarray(e, t);
2702
- return new B({
2703
- data: r,
2729
+ const n = this.data.subarray(e, t);
2730
+ return new C({
2731
+ data: n,
2704
2732
  dataType: this.dataType,
2705
2733
  timeRange: this.timeRange,
2706
2734
  sampleOffset: this.sampleOffset,
@@ -2708,10 +2736,10 @@ class B {
2708
2736
  alignment: this.alignment + BigInt(e)
2709
2737
  });
2710
2738
  }
2711
- sliceSub(e, t, r) {
2712
- if (t <= 0 && (r == null || r >= this.length)) return this;
2739
+ sliceSub(e, t, n) {
2740
+ if (t <= 0 && (n == null || n >= this.length)) return this;
2713
2741
  let i;
2714
- return e ? i = this.data.subarray(t, r) : i = this.data.slice(t, r), new B({
2742
+ return e ? i = this.data.subarray(t, n) : i = this.data.slice(t, n), new C({
2715
2743
  data: i,
2716
2744
  dataType: this.dataType,
2717
2745
  timeRange: this.timeRange,
@@ -2726,10 +2754,10 @@ class B {
2726
2754
  * @returns A new series with the specified alignment.
2727
2755
  */
2728
2756
  reAlign(e) {
2729
- return new B({
2757
+ return new C({
2730
2758
  data: this.buffer,
2731
2759
  dataType: this.dataType,
2732
- timeRange: x.ZERO,
2760
+ timeRange: E.ZERO,
2733
2761
  sampleOffset: this.sampleOffset,
2734
2762
  glBufferUsage: "static",
2735
2763
  alignment: e
@@ -2753,21 +2781,21 @@ class B {
2753
2781
  return e += "])", e;
2754
2782
  }
2755
2783
  }
2756
- const en = (n) => n == null ? !1 : Array.isArray(n) || n instanceof ArrayBuffer || ArrayBuffer.isView(n) && !(n instanceof DataView) || n instanceof B ? !0 : Fe(n), tn = Ft(Ze, B);
2757
- class Ae {
2784
+ const Qt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof C ? !0 : Ye(r), _t = Yt(Fe, C);
2785
+ class Ee {
2758
2786
  series;
2759
2787
  end;
2760
2788
  index;
2761
- constructor(e, t, r) {
2789
+ constructor(e, t, n) {
2762
2790
  this.series = e;
2763
- const i = P(0, e.length + 1);
2764
- this.end = Se(i, r), this.index = Se(i, t);
2791
+ const i = L(0, e.length + 1);
2792
+ this.end = Te(i, n), this.index = Te(i, t);
2765
2793
  }
2766
2794
  next() {
2767
2795
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
2768
2796
  }
2769
2797
  }
2770
- class nn {
2798
+ let er = class {
2771
2799
  series;
2772
2800
  index;
2773
2801
  decoder;
@@ -2780,12 +2808,11 @@ class nn {
2780
2808
  }
2781
2809
  next() {
2782
2810
  const e = this.index, t = this.series.data;
2783
- for (; this.index < t.length && t[this.index] !== fe; ) this.index++;
2784
- const r = this.index;
2785
- return e === r ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, r)) });
2811
+ for (; this.index < t.length && t[this.index] !== ce; ) this.index++;
2812
+ const n = this.index;
2813
+ return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
2786
2814
  }
2787
- }
2788
- let rn = class Ge {
2815
+ }, tr = class We {
2789
2816
  wrapped;
2790
2817
  static schema = s.record(s.string(), s.unknown());
2791
2818
  constructor(e) {
@@ -2795,27 +2822,27 @@ let rn = class Ge {
2795
2822
  const e = this.wrapped.next();
2796
2823
  return e.done === !0 ? { done: !0, value: void 0 } : {
2797
2824
  done: !1,
2798
- value: le.decodeString(e.value, Ge.schema)
2825
+ value: ue.decodeString(e.value, We.schema)
2799
2826
  };
2800
2827
  }
2801
2828
  };
2802
- class sn {
2829
+ class rr {
2803
2830
  series;
2804
2831
  index;
2805
2832
  data;
2806
2833
  density;
2807
2834
  constructor(e) {
2808
- if (!e.dataType.equals(O.UUID))
2835
+ if (!e.dataType.equals(T.UUID))
2809
2836
  throw new Error("cannot create a UUID series iterator for a non-UUID series");
2810
- this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = O.UUID.density.valueOf();
2837
+ this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = T.UUID.density.valueOf();
2811
2838
  }
2812
2839
  next() {
2813
2840
  if (this.index >= this.series.length) return { done: !0, value: void 0 };
2814
- const e = We(this.data, this.index * this.density);
2841
+ const e = qe(this.data, this.index * this.density);
2815
2842
  return this.index++, { done: !1, value: e };
2816
2843
  }
2817
2844
  }
2818
- let an = class {
2845
+ let nr = class {
2819
2846
  series;
2820
2847
  index;
2821
2848
  constructor(e) {
@@ -2828,8 +2855,8 @@ let an = class {
2828
2855
  };
2829
2856
  }
2830
2857
  };
2831
- const Ue = (n) => {
2832
- const e = n >> 32n, t = n & 0xffffffffn;
2858
+ const xe = (r) => {
2859
+ const e = r >> 32n, t = r & 0xffffffffn;
2833
2860
  return { domain: e, sample: t };
2834
2861
  };
2835
2862
  s.object({ key: s.string(), value: s.string() });
@@ -2837,17 +2864,17 @@ s.record(
2837
2864
  s.union([s.number(), s.string(), s.symbol()]),
2838
2865
  s.unknown()
2839
2866
  );
2840
- const on = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2841
- on();
2842
- const un = ["macOS", "Windows", "Linux"], ln = ["macos", "windows", "linux"], cn = {
2867
+ const sr = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2868
+ sr();
2869
+ const ir = ["macOS", "Windows", "Linux"], ar = ["macos", "windows", "linux"], or = {
2843
2870
  macos: "macOS",
2844
2871
  windows: "Windows",
2845
2872
  linux: "Linux"
2846
2873
  };
2847
- s.enum(un).or(
2848
- s.enum(ln).transform((n) => cn[n])
2874
+ s.enum(ir).or(
2875
+ s.enum(ar).transform((r) => or[r])
2849
2876
  );
2850
- const hn = (...n) => n.map(ze).join(""), ze = (n) => (n.endsWith("/") || (n += "/"), n.startsWith("/") && (n = n.slice(1)), n), fn = (n) => n.endsWith("/") ? n.slice(0, -1) : n, dn = (n, e = "") => n === null ? "" : `?${Object.entries(n).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, r]) => `${e}${t}=${r}`).join("&")}`;
2877
+ const ur = (...r) => r.map(Ze).join(""), Ze = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), lr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, cr = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
2851
2878
  class z {
2852
2879
  protocol;
2853
2880
  host;
@@ -2859,8 +2886,8 @@ class z {
2859
2886
  * @param protocol - The protocol to use for all requests. Defaults to "".
2860
2887
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
2861
2888
  */
2862
- constructor({ host: e, port: t, protocol: r = "", pathPrefix: i = "" }) {
2863
- this.protocol = r, this.host = e, this.port = t, this.path = ze(i);
2889
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
2890
+ this.protocol = n, this.host = e, this.port = t, this.path = Ze(i);
2864
2891
  }
2865
2892
  /**
2866
2893
  * Replaces creates a new URL with the specified properties replaced.
@@ -2883,21 +2910,21 @@ class z {
2883
2910
  child(e) {
2884
2911
  return new z({
2885
2912
  ...this,
2886
- pathPrefix: hn(this.path, e)
2913
+ pathPrefix: ur(this.path, e)
2887
2914
  });
2888
2915
  }
2889
2916
  /** @returns a string representation of the url */
2890
2917
  toString() {
2891
- return fn(
2918
+ return lr(
2892
2919
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
2893
2920
  );
2894
2921
  }
2895
2922
  static UNKNOWN = new z({ host: "unknown", port: 0 });
2896
2923
  }
2897
- const gn = async (n) => await new Promise(
2898
- (e) => setTimeout(e, l.fromMilliseconds(n).milliseconds)
2924
+ const hr = async (r) => await new Promise(
2925
+ (e) => setTimeout(e, l.fromMilliseconds(r).milliseconds)
2899
2926
  );
2900
- class pn {
2927
+ class fr {
2901
2928
  config;
2902
2929
  retries;
2903
2930
  interval;
@@ -2906,12 +2933,12 @@ class pn {
2906
2933
  baseInterval: new l(e?.baseInterval ?? l.seconds(1)),
2907
2934
  maxRetries: e?.maxRetries ?? 5,
2908
2935
  scale: e?.scale ?? 1,
2909
- sleepFn: e?.sleepFn ?? gn
2936
+ sleepFn: e?.sleepFn ?? hr
2910
2937
  }, this.retries = 0, this.interval = new l(this.config.baseInterval);
2911
2938
  }
2912
2939
  async wait() {
2913
- const { maxRetries: e, scale: t, sleepFn: r } = this.config;
2914
- return this.retries >= e ? !1 : (await r(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
2940
+ const { maxRetries: e, scale: t, sleepFn: n } = this.config;
2941
+ return this.retries >= e ? !1 : (await n(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
2915
2942
  }
2916
2943
  get retryMessage() {
2917
2944
  return `breaker triggered ${this.retries + 1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`;
@@ -2920,165 +2947,165 @@ class pn {
2920
2947
  this.retries = 0, this.interval = this.config.baseInterval;
2921
2948
  }
2922
2949
  }
2923
- const mn = s.object({
2950
+ const dr = s.object({
2924
2951
  baseInterval: l.z.optional(),
2925
2952
  maxRetries: s.number().optional(),
2926
2953
  scale: s.number().optional()
2927
- }), yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2954
+ }), gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2928
2955
  __proto__: null,
2929
- Breaker: pn,
2930
- breakerConfigZ: mn
2931
- }, Symbol.toStringTag, { value: "Module" })), wn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Ve = s.string().regex(wn), Y = s.number().min(0).max(255), He = s.number().min(0).max(1), Je = s.tuple([Y, Y, Y, He]), bn = s.tuple([Y, Y, Y]), On = s.object({ rgba255: Je }), Tn = s.number().min(0).max(360), vn = s.number().min(0).max(100), Sn = s.number().min(0).max(100), In = s.tuple([Tn, vn, Sn, He]), ye = s.union([Ve, bn, Je, In, On]), Nn = ye.transform((n) => we(n)), we = (n, e = 1) => {
2932
- if (n = ye.parse(n), typeof n == "string") return En(n, e);
2933
- if (Array.isArray(n)) {
2934
- if (n.length < 3 || n.length > 4)
2935
- throw new Error(`Invalid color: [${n.join(", ")}]`);
2936
- return n.length === 3 ? [...n, e] : n;
2937
- }
2938
- return n.rgba255;
2939
- }, En = (n, e = 1) => (n = Ve.parse(n), n = xn(n), [
2940
- X(n, 0),
2941
- X(n, 2),
2942
- X(n, 4),
2943
- n.length === 8 ? X(n, 6) / 255 : e
2944
- ]), X = (n, e) => parseInt(n.slice(e, e + 2), 16), xn = (n) => n.startsWith("#") ? n.slice(1) : n;
2945
- we("#000000");
2946
- we("#ffffff");
2947
- const An = s.object({
2956
+ Breaker: fr,
2957
+ breakerConfigZ: dr
2958
+ }, Symbol.toStringTag, { value: "Module" })), pr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, ze = s.string().regex(pr), j = s.number().min(0).max(255), Ge = s.number().min(0).max(1), Ve = s.tuple([j, j, j, Ge]), mr = s.tuple([j, j, j]), yr = s.object({ rgba255: Ve }), wr = s.number().min(0).max(360), br = s.number().min(0).max(100), Or = s.number().min(0).max(100), Tr = s.tuple([wr, br, Or, Ge]), pe = s.union([ze, mr, Ve, Tr, yr]), vr = pe.transform((r) => me(r)), me = (r, e = 1) => {
2959
+ if (r = pe.parse(r), typeof r == "string") return Ir(r, e);
2960
+ if (Array.isArray(r)) {
2961
+ if (r.length < 3 || r.length > 4)
2962
+ throw new Error(`Invalid color: [${r.join(", ")}]`);
2963
+ return r.length === 3 ? [...r, e] : r;
2964
+ }
2965
+ return r.rgba255;
2966
+ }, Ir = (r, e = 1) => (r = ze.parse(r), r = Sr(r), [
2967
+ K(r, 0),
2968
+ K(r, 2),
2969
+ K(r, 4),
2970
+ r.length === 8 ? K(r, 6) / 255 : e
2971
+ ]), K = (r, e) => parseInt(r.slice(e, e + 2), 16), Sr = (r) => r.startsWith("#") ? r.slice(1) : r;
2972
+ me("#000000");
2973
+ me("#ffffff");
2974
+ const Nr = s.object({
2948
2975
  key: s.string(),
2949
- color: ye,
2976
+ color: pe,
2950
2977
  position: s.number(),
2951
2978
  switched: s.boolean().optional()
2952
2979
  });
2953
- s.array(An);
2954
- const Un = s.object({
2980
+ s.array(Nr);
2981
+ const Er = s.object({
2955
2982
  key: s.string(),
2956
2983
  name: s.string(),
2957
- color: Nn
2984
+ color: vr
2958
2985
  });
2959
2986
  s.object({
2960
2987
  key: s.string(),
2961
2988
  name: s.string(),
2962
- swatches: s.array(Un)
2989
+ swatches: s.array(Er)
2963
2990
  });
2964
2991
  s.int().min(0).max(255);
2965
2992
  s.object({
2966
2993
  name: s.string(),
2967
2994
  key: s.string()
2968
2995
  });
2969
- const Mn = (n) => Object.getOwnPropertySymbols(globalThis).includes(n), $n = (n, e) => {
2970
- const t = Symbol.for(n);
2971
- if (!Mn(t)) {
2972
- const r = e();
2973
- Object.defineProperty(globalThis, t, { value: r });
2996
+ const xr = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), Ar = (r, e) => {
2997
+ const t = Symbol.for(r);
2998
+ if (!xr(t)) {
2999
+ const n = e();
3000
+ Object.defineProperty(globalThis, t, { value: n });
2974
3001
  }
2975
3002
  return () => globalThis[t];
2976
- }, Ke = "sy_x_error", Cn = (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), V = (n) => class G extends Error {
2977
- static discriminator = Ke;
2978
- discriminator = G.discriminator;
2979
- static TYPE = n;
2980
- type = G.TYPE;
2981
- static matches = Cn(n);
2982
- matches = G.matches;
2983
- constructor(t, r) {
2984
- super(t, r), this.name = G.TYPE;
3003
+ }, He = "sy_x_error", Ur = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), G = (r) => class Z extends Error {
3004
+ static discriminator = He;
3005
+ discriminator = Z.discriminator;
3006
+ static TYPE = r;
3007
+ type = Z.TYPE;
3008
+ static matches = Ur(r);
3009
+ matches = Z.matches;
3010
+ constructor(t, n) {
3011
+ super(t, n), this.name = Z.TYPE;
2985
3012
  }
2986
3013
  static sub(t) {
2987
- return V(`${n}.${t}`);
3014
+ return G(`${r}.${t}`);
2988
3015
  }
2989
- }, Xe = (n) => {
2990
- if (n == null || typeof n != "object") return !1;
2991
- const e = n;
2992
- if (e.discriminator !== Ke) return !1;
3016
+ }, Je = (r) => {
3017
+ if (r == null || typeof r != "object") return !1;
3018
+ const e = r;
3019
+ if (e.discriminator !== He) return !1;
2993
3020
  if (!("type" in e))
2994
3021
  throw new Error(
2995
3022
  `X Error is missing its type property: ${JSON.stringify(e)}`
2996
3023
  );
2997
3024
  return !0;
2998
- }, j = "unknown", de = "nil";
2999
- class Bn {
3025
+ }, k = "unknown", he = "nil";
3026
+ class Mr {
3000
3027
  providers = [];
3001
3028
  register(e) {
3002
3029
  this.providers.push(e);
3003
3030
  }
3004
3031
  encode(e) {
3005
- if (e == null) return { type: de, data: "" };
3006
- if (Xe(e))
3032
+ if (e == null) return { type: he, data: "" };
3033
+ if (Je(e))
3007
3034
  for (const t of this.providers) {
3008
- const r = t.encode(e);
3009
- if (r != null) return r;
3035
+ const n = t.encode(e);
3036
+ if (n != null) return n;
3010
3037
  }
3011
- if (e instanceof Error) return { type: j, data: e.message };
3012
- if (typeof e == "string") return { type: j, data: e };
3038
+ if (e instanceof Error) return { type: k, data: e.message };
3039
+ if (typeof e == "string") return { type: k, data: e };
3013
3040
  try {
3014
- return { type: j, data: JSON.stringify(e) };
3041
+ return { type: k, data: JSON.stringify(e) };
3015
3042
  } catch {
3016
- return { type: j, data: "unable to encode error information" };
3043
+ return { type: k, data: "unable to encode error information" };
3017
3044
  }
3018
3045
  }
3019
3046
  decode(e) {
3020
- if (e == null || e.type === de) return null;
3021
- if (e.type === j) return new ge(e.data);
3047
+ if (e == null || e.type === he) return null;
3048
+ if (e.type === k) return new fe(e.data);
3022
3049
  for (const t of this.providers) {
3023
- const r = t.decode(e);
3024
- if (r != null) return r;
3050
+ const n = t.decode(e);
3051
+ if (n != null) return n;
3025
3052
  }
3026
- return new ge(e.data);
3053
+ return new fe(e.data);
3027
3054
  }
3028
3055
  }
3029
- const be = $n("synnax-error-registry", () => new Bn()), Rn = ({ encode: n, decode: e }) => be().register({ encode: n, decode: e }), Dn = (n) => be().encode(n), Ln = (n) => n == null ? null : be().decode(n);
3030
- class ge extends V("unknown") {
3056
+ const ye = Ar("synnax-error-registry", () => new Mr()), $r = ({ encode: r, decode: e }) => ye().register({ encode: r, decode: e }), Cr = (r) => ye().encode(r), Br = (r) => r == null ? null : ye().decode(r);
3057
+ class fe extends G("unknown") {
3031
3058
  }
3032
- const Pn = s.object({ type: s.string(), data: s.string() });
3033
- class kn extends V("canceled") {
3059
+ const Rr = s.object({ type: s.string(), data: s.string() });
3060
+ class Dr extends G("canceled") {
3034
3061
  }
3035
- class jn extends V("not_implemented") {
3062
+ class Lr extends G("not_implemented") {
3036
3063
  }
3037
- const D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3064
+ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3038
3065
  __proto__: null,
3039
- Canceled: kn,
3040
- NONE: de,
3041
- NotImplemented: jn,
3042
- UNKNOWN: j,
3043
- Unknown: ge,
3044
- createTyped: V,
3045
- decode: Ln,
3046
- encode: Dn,
3047
- isTyped: Xe,
3048
- payloadZ: Pn,
3049
- register: Rn
3050
- }, Symbol.toStringTag, { value: "Module" })), Yn = b.object({
3051
- jsonrpc: b.literal("2.0"),
3052
- method: b.string(),
3066
+ Canceled: Dr,
3067
+ NONE: he,
3068
+ NotImplemented: Lr,
3069
+ UNKNOWN: k,
3070
+ Unknown: fe,
3071
+ createTyped: G,
3072
+ decode: Br,
3073
+ encode: Cr,
3074
+ isTyped: Je,
3075
+ payloadZ: Rr,
3076
+ register: $r
3077
+ }, Symbol.toStringTag, { value: "Module" })), Pr = O.object({
3078
+ jsonrpc: O.literal("2.0"),
3079
+ method: O.string(),
3053
3080
  // params should be z.union([z.record(z.string(), z.json()),
3054
3081
  // z.array(z.json())]).optional() but the VSCode JSON RPC implementation uses a looser
3055
3082
  // definition of params then in the JSON-RPC spec.
3056
- params: b.any().optional(),
3057
- id: b.union([b.string(), b.number(), b.null()]).optional()
3058
- }), Qe = b.object({
3059
- jsonrpc: b.literal("2.0"),
3060
- id: b.union([b.string(), b.number(), b.null()])
3061
- }), qn = Qe.extend({
3062
- result: b.json()
3063
- }), Fn = Qe.extend({
3064
- error: b.object({
3065
- code: b.number().int(),
3083
+ params: O.any().optional(),
3084
+ id: O.union([O.string(), O.number(), O.null()]).optional()
3085
+ }), Ke = O.object({
3086
+ jsonrpc: O.literal("2.0"),
3087
+ id: O.union([O.string(), O.number(), O.null()])
3088
+ }), kr = Ke.extend({
3089
+ result: O.json()
3090
+ }), jr = Ke.extend({
3091
+ error: O.object({
3092
+ code: O.number().int(),
3066
3093
  // This should be z.string(), but the VSCode JSON RPC implementation uses a looser
3067
3094
  // definition of error than the JSON-RPC spec.
3068
- message: b.string().optional(),
3069
- data: b.json().optional()
3095
+ message: O.string().optional(),
3096
+ data: O.json().optional()
3070
3097
  })
3071
- }), Wn = b.union([qn, Fn]);
3072
- b.union([Yn, Wn]);
3073
- const Zn = b.uuid();
3074
- b.object({
3075
- key: Zn,
3076
- name: b.string().min(1),
3077
- color: b.string()
3098
+ }), Yr = O.union([kr, jr]);
3099
+ O.union([Pr, Yr]);
3100
+ const qr = O.uuid();
3101
+ O.object({
3102
+ key: qr,
3103
+ name: O.string().min(1),
3104
+ color: O.string()
3078
3105
  });
3079
- s.string().regex(/^\d+\.\d+\.\d+$/);
3080
- const Gn = ["standard", "scientific", "engineering"];
3081
- s.enum(Gn);
3106
+ s.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);
3107
+ const Fr = ["standard", "scientific", "engineering"];
3108
+ s.enum(Fr);
3082
3109
  s.enum([
3083
3110
  "success",
3084
3111
  "info",
@@ -3091,51 +3118,51 @@ s.object({
3091
3118
  stack: s.string(),
3092
3119
  error: s.instanceof(Error)
3093
3120
  });
3094
- class H extends D.createTyped("freighter") {
3121
+ class V extends R.createTyped("freighter") {
3095
3122
  }
3096
- class q extends H.sub("eof") {
3123
+ class Y extends V.sub("eof") {
3097
3124
  constructor() {
3098
3125
  super("EOF");
3099
3126
  }
3100
3127
  }
3101
- class F extends H.sub("stream_closed") {
3128
+ class q extends V.sub("stream_closed") {
3102
3129
  constructor() {
3103
3130
  super("StreamClosed");
3104
3131
  }
3105
3132
  }
3106
- class W extends H.sub("unreachable") {
3133
+ class F extends V.sub("unreachable") {
3107
3134
  url;
3108
3135
  constructor(e = {}) {
3109
- const { message: t = "Unreachable", url: r = z.UNKNOWN } = e;
3110
- super(t), this.url = r;
3136
+ const { message: t = "Unreachable", url: n = z.UNKNOWN } = e;
3137
+ super(t), this.url = n;
3111
3138
  }
3112
3139
  }
3113
- const zn = (n) => {
3114
- if (!n.type.startsWith(H.TYPE)) return null;
3115
- if (q.matches(n)) return { type: q.TYPE, data: "EOF" };
3116
- if (F.matches(n))
3117
- return { type: F.TYPE, data: "StreamClosed" };
3118
- if (W.matches(n))
3119
- return { type: W.TYPE, data: "Unreachable" };
3120
- throw new Error(`Unknown error type: ${n.type}: ${n.message}`);
3121
- }, Vn = (n) => {
3122
- if (!n.type.startsWith(H.TYPE)) return null;
3123
- switch (n.type) {
3140
+ const Wr = (r) => {
3141
+ if (!r.type.startsWith(V.TYPE)) return null;
3142
+ if (Y.matches(r)) return { type: Y.TYPE, data: "EOF" };
3143
+ if (q.matches(r))
3144
+ return { type: q.TYPE, data: "StreamClosed" };
3145
+ if (F.matches(r))
3146
+ return { type: F.TYPE, data: "Unreachable" };
3147
+ throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
3148
+ }, Zr = (r) => {
3149
+ if (!r.type.startsWith(V.TYPE)) return null;
3150
+ switch (r.type) {
3151
+ case Y.TYPE:
3152
+ return new Y();
3124
3153
  case q.TYPE:
3125
3154
  return new q();
3126
3155
  case F.TYPE:
3127
3156
  return new F();
3128
- case W.TYPE:
3129
- return new W();
3130
3157
  default:
3131
- throw new D.Unknown(`Unknown error type: ${n.data}`);
3158
+ throw new R.Unknown(`Unknown error type: ${r.data}`);
3132
3159
  }
3133
3160
  };
3134
- D.register({
3135
- encode: zn,
3136
- decode: Vn
3161
+ R.register({
3162
+ encode: Wr,
3163
+ decode: Zr
3137
3164
  });
3138
- class _e {
3165
+ class Xe {
3139
3166
  middleware = [];
3140
3167
  /** Implements the Transport interface */
3141
3168
  use(...e) {
@@ -3151,94 +3178,94 @@ class _e {
3151
3178
  * @returns An error if one was encountered, otherwise undefined.
3152
3179
  */
3153
3180
  async executeMiddleware(e, t) {
3154
- let r = 0;
3181
+ let n = 0;
3155
3182
  const i = async (a) => {
3156
- if (r === this.middleware.length) return await t(a);
3157
- const c = this.middleware[r];
3158
- return r++, await c(a, i);
3183
+ if (n === this.middleware.length) return await t(a);
3184
+ const c = this.middleware[n];
3185
+ return n++, await c(a, i);
3159
3186
  };
3160
3187
  return await i(e);
3161
3188
  }
3162
3189
  }
3163
- const et = "Content-Type", Hn = /* @__PURE__ */ new Set([
3190
+ const Qe = "Content-Type", zr = /* @__PURE__ */ new Set([
3164
3191
  "ECONNREFUSED",
3165
3192
  "ECONNRESET",
3166
3193
  "ETIMEDOUT",
3167
3194
  "EPIPE",
3168
3195
  "UND_ERR_CONNECT_TIMEOUT",
3169
3196
  "UND_ERR_SOCKET"
3170
- ]), Jn = (n) => {
3171
- const e = n?.cause?.code ?? n?.code ?? n?.errno;
3172
- if (typeof e == "string" && Hn.has(e)) return !0;
3173
- if (n.name === "TypeError") {
3174
- const t = String(n.message || "").toLowerCase();
3197
+ ]), Gr = (r) => {
3198
+ const e = r?.cause?.code ?? r?.code ?? r?.errno;
3199
+ if (typeof e == "string" && zr.has(e)) return !0;
3200
+ if (r.name === "TypeError") {
3201
+ const t = String(r.message || "").toLowerCase();
3175
3202
  if (/load failed|failed to fetch|networkerror|network error/.test(t))
3176
3203
  return typeof navigator < "u" && navigator.onLine === !1, !0;
3177
3204
  }
3178
- return n?.name === "AbortError" || n?.code === "ABORT_ERR", !1;
3179
- }, Kn = 400;
3180
- class ar extends _e {
3205
+ return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
3206
+ }, Vr = 400;
3207
+ class sn extends Xe {
3181
3208
  endpoint;
3182
3209
  encoder;
3183
- constructor(e, t, r = !1) {
3184
- return super(), this.endpoint = e.replace({ protocol: r ? "https" : "http" }), this.encoder = t, new Proxy(this, {
3210
+ constructor(e, t, n = !1) {
3211
+ return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, {
3185
3212
  get: (i, a, c) => a === "endpoint" ? this.endpoint : Reflect.get(i, a, c)
3186
3213
  });
3187
3214
  }
3188
3215
  get headers() {
3189
3216
  return {
3190
- [et]: this.encoder.contentType
3217
+ [Qe]: this.encoder.contentType
3191
3218
  };
3192
3219
  }
3193
- async send(e, t, r, i) {
3194
- t = r?.parse(t);
3220
+ async send(e, t, n, i) {
3221
+ t = n?.parse(t);
3195
3222
  let a = null;
3196
3223
  const c = this.endpoint.child(e), d = {};
3197
3224
  d.method = "POST", d.body = this.encoder.encode(t ?? {});
3198
- const [, y] = await this.executeMiddleware(
3225
+ const [, w] = await this.executeMiddleware(
3199
3226
  {
3200
3227
  target: c.toString(),
3201
3228
  protocol: this.endpoint.protocol,
3202
3229
  params: {},
3203
3230
  role: "client"
3204
3231
  },
3205
- async (f) => {
3206
- const g = { ...f, params: {} };
3232
+ async (h) => {
3233
+ const g = { ...h, params: {} };
3207
3234
  d.headers = {
3208
3235
  ...this.headers,
3209
- ...f.params
3236
+ ...h.params
3210
3237
  };
3211
- let w;
3238
+ let b;
3212
3239
  try {
3213
- w = await fetch(f.target, d);
3214
- } catch (T) {
3215
- if (!(T instanceof Error)) throw T;
3216
- return [g, Jn(T) ? new W({ url: c }) : T];
3240
+ b = await fetch(h.target, d);
3241
+ } catch (v) {
3242
+ if (!(v instanceof Error)) throw v;
3243
+ return [g, Gr(v) ? new F({ url: c }) : v];
3217
3244
  }
3218
- const h = await w.arrayBuffer();
3219
- if (w?.ok)
3220
- return i != null && (a = this.encoder.decode(h, i)), [g, null];
3245
+ const f = await b.arrayBuffer();
3246
+ if (b?.ok)
3247
+ return i != null && (a = this.encoder.decode(f, i)), [g, null];
3221
3248
  try {
3222
- if (w.status !== Kn)
3223
- return [g, new Error(w.statusText)];
3224
- const T = this.encoder.decode(h, D.payloadZ), A = D.decode(T);
3225
- return [g, A];
3226
- } catch (T) {
3249
+ if (b.status !== Vr)
3250
+ return [g, new Error(b.statusText)];
3251
+ const v = this.encoder.decode(f, R.payloadZ), x = R.decode(v);
3252
+ return [g, x];
3253
+ } catch (v) {
3227
3254
  return [
3228
3255
  g,
3229
3256
  new Error(
3230
- `[freighter] - failed to decode error: ${w.statusText}: ${T.message}`
3257
+ `[freighter] - failed to decode error: ${b.statusText}: ${v.message}`
3231
3258
  )
3232
3259
  ];
3233
3260
  }
3234
3261
  }
3235
3262
  );
3236
- if (y != null) return [null, y];
3263
+ if (w != null) return [null, w];
3237
3264
  if (a == null) throw new Error("Response must be defined");
3238
3265
  return [a, null];
3239
3266
  }
3240
3267
  }
3241
- const or = (n, e) => {
3268
+ const an = (r, e) => {
3242
3269
  class t {
3243
3270
  wrapped;
3244
3271
  constructor(i) {
@@ -3248,26 +3275,26 @@ const or = (n, e) => {
3248
3275
  this.wrapped.use(...i);
3249
3276
  }
3250
3277
  async send(i, a, c, d) {
3251
- const y = new yn.Breaker(e);
3278
+ const w = new gr.Breaker(e);
3252
3279
  do {
3253
- const [f, g] = await this.wrapped.send(i, a, c, d);
3254
- if (g == null) return [f, null];
3255
- if (!W.matches(g)) return [null, g];
3256
- if (console.warn(`[freighter] ${y.retryMessage}`, g), !await y.wait()) return [f, g];
3280
+ const [h, g] = await this.wrapped.send(i, a, c, d);
3281
+ if (g == null) return [h, null];
3282
+ if (!F.matches(g)) return [null, g];
3283
+ if (console.warn(`[freighter] ${w.retryMessage}`, g), !await w.wait()) return [h, g];
3257
3284
  } while (!0);
3258
3285
  }
3259
3286
  }
3260
- return new t(n);
3261
- }, ur = async (n, e, t, r, i) => {
3262
- const [a, c] = await n.send(e, t, r, i);
3287
+ return new t(r);
3288
+ }, on = async (r, e, t, n, i) => {
3289
+ const [a, c] = await r.send(e, t, n, i);
3263
3290
  if (c != null) throw c;
3264
3291
  return a;
3265
- }, Xn = s.object({
3292
+ }, Hr = s.object({
3266
3293
  type: s.enum(["data", "close", "open"]),
3267
3294
  payload: s.unknown(),
3268
- error: s.optional(D.payloadZ)
3295
+ error: s.optional(R.payloadZ)
3269
3296
  });
3270
- class Qn {
3297
+ class Jr {
3271
3298
  codec;
3272
3299
  reqSchema;
3273
3300
  resSchema;
@@ -3276,21 +3303,21 @@ class Qn {
3276
3303
  sendClosed;
3277
3304
  receiveDataQueue = [];
3278
3305
  receiveCallbacksQueue = [];
3279
- constructor(e, t, r, i) {
3280
- this.codec = t, this.reqSchema = r, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
3306
+ constructor(e, t, n, i) {
3307
+ this.codec = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
3281
3308
  }
3282
3309
  async receiveOpenAck() {
3283
3310
  const e = await this.receiveMsg();
3284
3311
  if (e.type !== "open") {
3285
3312
  if (e.error == null) throw new Error("Message error must be defined");
3286
- return D.decode(e.error);
3313
+ return R.decode(e.error);
3287
3314
  }
3288
3315
  return null;
3289
3316
  }
3290
3317
  /** Implements the Stream protocol */
3291
3318
  send(e) {
3292
- if (this.serverClosed != null) return new q();
3293
- if (this.sendClosed) throw new F();
3319
+ if (this.serverClosed != null) return new Y();
3320
+ if (this.sendClosed) throw new q();
3294
3321
  return this.ws.send(this.codec.encode({ type: "data", payload: e })), null;
3295
3322
  }
3296
3323
  /** Implements the Stream protocol */
@@ -3299,7 +3326,7 @@ class Qn {
3299
3326
  const e = await this.receiveMsg();
3300
3327
  if (e.type === "close") {
3301
3328
  if (e.error == null) throw new Error("Message error must be defined");
3302
- if (this.serverClosed = D.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3329
+ if (this.serverClosed = R.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3303
3330
  return [null, this.serverClosed];
3304
3331
  }
3305
3332
  return [this.resSchema.parse(e.payload), null];
@@ -3321,7 +3348,7 @@ class Qn {
3321
3348
  async receiveMsg() {
3322
3349
  const e = this.receiveDataQueue.shift();
3323
3350
  return e ?? await new Promise(
3324
- (t, r) => this.receiveCallbacksQueue.push({ resolve: t, reject: r })
3351
+ (t, n) => this.receiveCallbacksQueue.push({ resolve: t, reject: n })
3325
3352
  );
3326
3353
  }
3327
3354
  addMessage(e) {
@@ -3332,20 +3359,20 @@ class Qn {
3332
3359
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
3333
3360
  }
3334
3361
  onMessage(e) {
3335
- this.addMessage(this.codec.decode(e.data, Xn));
3362
+ this.addMessage(this.codec.decode(e.data, Hr));
3336
3363
  }
3337
3364
  onClose(e) {
3338
3365
  this.addMessage({
3339
3366
  type: "close",
3340
3367
  error: {
3341
- type: e.code === er ? q.TYPE : F.TYPE,
3368
+ type: e.code === Xr ? Y.TYPE : q.TYPE,
3342
3369
  data: ""
3343
3370
  }
3344
3371
  });
3345
3372
  }
3346
3373
  }
3347
- const _n = "freighterctx", er = 1e3;
3348
- class pe extends _e {
3374
+ const Kr = "freighterctx", Xr = 1e3;
3375
+ class de extends Xe {
3349
3376
  baseUrl;
3350
3377
  encoder;
3351
3378
  secure;
@@ -3355,42 +3382,42 @@ class pe extends _e {
3355
3382
  * responses.
3356
3383
  * @param baseEndpoint - A base url to use as a prefix for all requests.
3357
3384
  */
3358
- constructor(e, t, r = !1) {
3359
- super(), this.secure = r, this.baseUrl = e.replace({ protocol: r ? "wss" : "ws" }), this.encoder = t;
3385
+ constructor(e, t, n = !1) {
3386
+ super(), this.secure = n, this.baseUrl = e.replace({ protocol: n ? "wss" : "ws" }), this.encoder = t;
3360
3387
  }
3361
3388
  withCodec(e) {
3362
- const t = new pe(this.baseUrl, e, this.secure);
3389
+ const t = new de(this.baseUrl, e, this.secure);
3363
3390
  return t.use(...this.middleware), t;
3364
3391
  }
3365
3392
  /** Implements the StreamClient interface. */
3366
- async stream(e, t, r) {
3393
+ async stream(e, t, n) {
3367
3394
  let i;
3368
3395
  const [, a] = await this.executeMiddleware(
3369
3396
  { target: e, protocol: "websocket", params: {}, role: "client" },
3370
3397
  async (c) => {
3371
- const d = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
3372
- d.binaryType = pe.MESSAGE_TYPE;
3373
- const f = await this.wrapSocket(d, t, r);
3374
- return f instanceof Error ? [y, f] : (i = f, [y, null]);
3398
+ const d = new WebSocket(this.buildURL(e, c)), w = { ...c, params: {} };
3399
+ d.binaryType = de.MESSAGE_TYPE;
3400
+ const h = await this.wrapSocket(d, t, n);
3401
+ return h instanceof Error ? [w, h] : (i = h, [w, null]);
3375
3402
  }
3376
3403
  );
3377
3404
  if (a != null) throw a;
3378
3405
  return i;
3379
3406
  }
3380
3407
  buildURL(e, t) {
3381
- const r = dn(
3408
+ const n = cr(
3382
3409
  {
3383
- [et]: this.encoder.contentType,
3410
+ [Qe]: this.encoder.contentType,
3384
3411
  ...t.params
3385
3412
  },
3386
- _n
3413
+ Kr
3387
3414
  );
3388
- return this.baseUrl.child(e).toString() + r;
3415
+ return this.baseUrl.child(e).toString() + n;
3389
3416
  }
3390
- async wrapSocket(e, t, r) {
3417
+ async wrapSocket(e, t, n) {
3391
3418
  return await new Promise((i) => {
3392
3419
  e.onopen = () => {
3393
- const a = new Qn(e, this.encoder, t, r);
3420
+ const a = new Jr(e, this.encoder, t, n);
3394
3421
  a.receiveOpenAck().then((c) => {
3395
3422
  c != null ? i(c) : i(a);
3396
3423
  }).catch((c) => i(c));
@@ -3402,11 +3429,11 @@ class pe extends _e {
3402
3429
  }
3403
3430
  }
3404
3431
  export {
3405
- q as EOF,
3406
- ar as HTTPClient,
3407
- F as StreamClosed,
3408
- W as Unreachable,
3409
- pe as WebSocketClient,
3410
- ur as sendRequired,
3411
- or as unaryWithBreaker
3432
+ Y as EOF,
3433
+ sn as HTTPClient,
3434
+ q as StreamClosed,
3435
+ F as Unreachable,
3436
+ de as WebSocketClient,
3437
+ on as sendRequired,
3438
+ an as unaryWithBreaker
3412
3439
  };