@synnaxlabs/freighter 0.30.0 → 0.32.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
- var Ze = Object.defineProperty;
2
- var ze = (r, e, t) => e in r ? Ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var f = (r, e, t) => ze(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { z as s } from "zod";
5
- const Ve = (r) => {
1
+ var it = Object.defineProperty;
2
+ var at = (r, e, t) => e in r ? it(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var p = (r, e, t) => at(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { z as i } from "zod";
5
+ const ot = (r) => {
6
6
  const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
7
7
  return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() ? e : e[0].toLowerCase() + e.slice(1);
8
- }, Ee = (r) => {
9
- const e = (t, n = oe) => {
8
+ }, Le = (r) => {
9
+ const e = (t, n = de) => {
10
10
  if (typeof t == "string") return r(t);
11
11
  if (Array.isArray(t)) return t.map((c) => e(c, n));
12
- if (!te(t)) return t;
13
- n = Je(n);
14
- const i = {}, a = t;
12
+ if (!ue(t)) return t;
13
+ n = lt(n);
14
+ const s = {}, a = t;
15
15
  return Object.keys(a).forEach((c) => {
16
- let h = a[c];
17
- const g = r(c);
18
- n.recursive && (te(h) ? pe(h, n.keepTypesOnRecursion) || (h = e(h, n)) : n.recursiveInArray && fe(h) && (h = [...h].map((m) => {
19
- let O = m;
20
- return te(m) ? pe(O, n.keepTypesOnRecursion) || (O = e(m, n)) : fe(m) && (O = e({ key: m }, n).key), O;
21
- }))), i[g] = h;
22
- }), i;
16
+ let d = a[c];
17
+ const f = r(c);
18
+ n.recursive && (ue(d) ? Oe(d, n.keepTypesOnRecursion) || (d = e(d, n)) : n.recursiveInArray && Te(d) && (d = [...d].map((y) => {
19
+ let T = y;
20
+ return ue(y) ? Oe(T, n.keepTypesOnRecursion) || (T = e(y, n)) : Te(y) && (T = e({ key: y }, n).key), T;
21
+ }))), s[f] = d;
22
+ }), s;
23
23
  };
24
24
  return e;
25
- }, He = Ee(Ve), Ke = (r) => r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`), Xe = Ee(Ke), oe = {
25
+ }, Ye = Le(ot), ut = (r) => r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`), ct = Le(ut), de = {
26
26
  recursive: !0,
27
27
  recursiveInArray: !0,
28
28
  keepTypesOnRecursion: [Number, String, Uint8Array]
29
- }, Je = (r = oe) => (r.recursive == null ? r = oe : r.recursiveInArray == null && (r.recursiveInArray = !1), r), fe = (r) => r != null && Array.isArray(r), te = (r) => r != null && typeof r == "object" && !Array.isArray(r), pe = (r, e) => (e || []).some((t) => r instanceof t), Ae = (r) => r != null && typeof r == "object" && !Array.isArray(r);
30
- var Qe = Object.defineProperty, _e = (r, e, t) => e in r ? Qe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, q = (r, e, t) => _e(r, typeof e != "symbol" ? e + "" : e, t);
31
- let et = class {
29
+ }, lt = (r = de) => (r.recursive == null ? r = de : r.recursiveInArray == null && (r.recursiveInArray = !1), r), Te = (r) => r != null && Array.isArray(r), ue = (r) => r != null && typeof r == "object" && !Array.isArray(r), Oe = (r, e) => (e || []).some((t) => r instanceof t), ke = (r) => r != null && typeof r == "object" && !Array.isArray(r);
30
+ var ht = Object.defineProperty, dt = (r, e, t) => e in r ? ht(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, H = (r, e, t) => dt(r, typeof e != "symbol" ? e + "" : e, t);
31
+ let ft = class {
32
32
  constructor() {
33
- q(this, "contentType", "application/json"), q(this, "decoder"), q(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
33
+ H(this, "contentType", "application/json"), H(this, "decoder"), H(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
34
34
  }
35
35
  encode(e) {
36
36
  return this.encoder.encode(this.encodeString(e)).buffer;
@@ -39,18 +39,18 @@ let et = class {
39
39
  return this.decodeString(this.decoder.decode(e), t);
40
40
  }
41
41
  decodeString(e, t) {
42
- const n = JSON.parse(e), i = He(n);
43
- return t != null ? t.parse(i) : i;
42
+ const n = JSON.parse(e), s = Ye(n);
43
+ return t != null ? t.parse(s) : s;
44
44
  }
45
45
  encodeString(e) {
46
- const t = Xe(e);
47
- return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : Ae(i) && "encode_value" in i ? typeof i.value == "bigint" ? i.value.toString() : i.value : typeof i == "bigint" ? i.toString() : i);
46
+ const t = ct(e);
47
+ return JSON.stringify(t, (n, s) => ArrayBuffer.isView(s) ? Array.from(s) : ke(s) && "encode_value" in s ? typeof s.value == "bigint" ? s.value.toString() : s.value : typeof s == "bigint" ? s.toString() : s);
48
48
  }
49
49
  static registerCustomType() {
50
50
  }
51
- }, tt = class {
51
+ }, gt = class {
52
52
  constructor() {
53
- q(this, "contentType", "text/csv");
53
+ H(this, "contentType", "text/csv");
54
54
  }
55
55
  encode(e) {
56
56
  const t = this.encodeString(e);
@@ -61,28 +61,28 @@ let et = class {
61
61
  return this.decodeString(n, t);
62
62
  }
63
63
  encodeString(e) {
64
- if (!Array.isArray(e) || e.length === 0 || !Ae(e[0]))
64
+ if (!Array.isArray(e) || e.length === 0 || !ke(e[0]))
65
65
  throw new Error("Payload must be an array of objects");
66
66
  const t = Object.keys(e[0]), n = [t.join(",")];
67
- return e.forEach((i) => {
68
- const a = t.map((c) => JSON.stringify(i[c] ?? ""));
67
+ return e.forEach((s) => {
68
+ const a = t.map((c) => JSON.stringify(s[c] ?? ""));
69
69
  n.push(a.join(","));
70
70
  }), n.join(`
71
71
  `);
72
72
  }
73
73
  decodeString(e, t) {
74
- const [n, ...i] = e.trim().split(`
75
- `).map((h) => h.trim());
74
+ const [n, ...s] = e.trim().split(`
75
+ `).map((d) => d.trim());
76
76
  if (n.length === 0)
77
77
  return t != null ? t.parse({}) : {};
78
- const a = n.split(",").map((h) => h.trim()), c = {};
79
- return a.forEach((h) => {
80
- c[h] = [];
81
- }), i.forEach((h) => {
82
- const g = h.split(",").map((m) => m.trim());
83
- a.forEach((m, O) => {
84
- const w = this.parseValue(g[O]);
85
- w != null && c[m].push(w);
78
+ const a = n.split(",").map((d) => d.trim()), c = {};
79
+ return a.forEach((d) => {
80
+ c[d] = [];
81
+ }), s.forEach((d) => {
82
+ const f = d.split(",").map((y) => y.trim());
83
+ a.forEach((y, T) => {
84
+ const l = this.parseValue(f[T]);
85
+ l != null && c[y].push(l);
86
86
  });
87
87
  }), t != null ? t.parse(c) : c;
88
88
  }
@@ -93,9 +93,9 @@ let et = class {
93
93
  }
94
94
  static registerCustomType() {
95
95
  }
96
- }, rt = class {
96
+ }, pt = class {
97
97
  constructor() {
98
- q(this, "contentType", "text/plain");
98
+ H(this, "contentType", "text/plain");
99
99
  }
100
100
  encode(e) {
101
101
  return new TextEncoder().encode(e).buffer;
@@ -105,125 +105,125 @@ let et = class {
105
105
  return t != null ? t.parse(n) : n;
106
106
  }
107
107
  };
108
- new et();
109
- new tt();
110
- new rt();
111
- const Q = s.tuple([s.number(), s.number()]);
112
- s.tuple([s.bigint(), s.bigint()]);
113
- const $e = s.object({ width: s.number(), height: s.number() }), nt = s.object({
114
- signedWidth: s.number(),
115
- signedHeight: s.number()
116
- }), st = ["width", "height"];
117
- s.enum(st);
118
- const it = ["start", "center", "end"], ot = ["signedWidth", "signedHeight"];
119
- s.enum(ot);
120
- const X = s.object({ x: s.number(), y: s.number() }), at = s.object({ clientX: s.number(), clientY: s.number() }), ut = ["x", "y"], xe = s.enum(ut), Ue = ["top", "right", "bottom", "left"];
121
- s.enum(Ue);
122
- const ct = ["left", "right"], Me = s.enum(ct), lt = ["top", "bottom"], Ce = s.enum(lt), Be = ["center"], ye = s.enum(Be), ht = [...Ue, ...Be], Re = s.enum(ht);
123
- s.enum(it);
124
- const dt = ["first", "last"];
125
- s.enum(dt);
126
- const ft = s.object({ lower: s.number(), upper: s.number() }), pt = s.object({ lower: s.bigint(), upper: s.bigint() });
127
- s.union([ft, Q]);
128
- s.union([pt, Q]);
129
- s.union([xe, Re]);
130
- s.union([xe, Re, s.instanceof(String)]);
131
- const re = (r, e) => {
108
+ const _ = new ft();
109
+ new gt();
110
+ new pt();
111
+ const ie = i.tuple([i.number(), i.number()]);
112
+ i.tuple([i.bigint(), i.bigint()]);
113
+ const je = i.object({ width: i.number(), height: i.number() }), yt = i.object({
114
+ signedWidth: i.number(),
115
+ signedHeight: i.number()
116
+ }), mt = ["width", "height"];
117
+ i.enum(mt);
118
+ const wt = ["start", "center", "end"], bt = ["signedWidth", "signedHeight"];
119
+ i.enum(bt);
120
+ const ne = i.object({ x: i.number(), y: i.number() }), Tt = i.object({ clientX: i.number(), clientY: i.number() }), Ot = ["x", "y"], Fe = i.enum(Ot), Ge = ["top", "right", "bottom", "left"];
121
+ i.enum(Ge);
122
+ const vt = ["left", "right"], qe = i.enum(vt), St = ["top", "bottom"], We = i.enum(St), ze = ["center"], ve = i.enum(ze), It = [...Ge, ...ze], Ze = i.enum(It);
123
+ i.enum(wt);
124
+ const Nt = ["first", "last"];
125
+ i.enum(Nt);
126
+ const Et = i.object({ lower: i.number(), upper: i.number() }), At = i.object({ lower: i.bigint(), upper: i.bigint() });
127
+ i.union([Et, ie]);
128
+ i.union([At, ie]);
129
+ i.union([Fe, Ze]);
130
+ i.union([Fe, Ze, i.instanceof(String)]);
131
+ const K = (r, e) => {
132
132
  const t = {};
133
133
  if (typeof r == "number" || typeof r == "bigint")
134
134
  e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
135
135
  else if (Array.isArray(r)) {
136
136
  if (r.length !== 2) throw new Error("bounds: expected array of length 2");
137
137
  [t.lower, t.upper] = r;
138
- } else return ge(r);
139
- return ge(t);
140
- }, ge = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r;
141
- s.object({
142
- x: Me.or(ye),
143
- y: Ce.or(ye)
138
+ } else return Se(r);
139
+ return Se(t);
140
+ }, Se = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r;
141
+ i.object({
142
+ x: qe.or(ve),
143
+ y: We.or(ve)
144
144
  });
145
- const yt = s.object({ x: Me, y: Ce }), gt = Object.freeze({ x: "left", y: "top" }), mt = (r, e) => r.x === e.x && r.y === e.y, me = s.union([
146
- s.number(),
147
- X,
148
- Q,
149
- $e,
150
- nt,
151
- at
152
- ]), wt = (r, e) => {
145
+ const xt = i.object({ x: qe, y: We }), Mt = Object.freeze({ x: "left", y: "top" }), $t = (r, e) => r.x === e.x && r.y === e.y, Ie = i.union([
146
+ i.number(),
147
+ ne,
148
+ ie,
149
+ je,
150
+ yt,
151
+ Tt
152
+ ]), Rt = (r, e) => {
153
153
  if (typeof r == "string") {
154
154
  if (e === void 0) throw new Error("The y coordinate must be given.");
155
155
  return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
156
156
  }
157
157
  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 };
158
- }, we = Object.freeze({ x: 0, y: 0 }), Z = s.union([s.number(), s.string()]);
159
- s.object({
160
- top: Z,
161
- left: Z,
162
- width: Z,
163
- height: Z
158
+ }, Ne = Object.freeze({ x: 0, y: 0 }), X = i.union([i.number(), i.string()]);
159
+ i.object({
160
+ top: X,
161
+ left: X,
162
+ width: X,
163
+ height: X
164
164
  });
165
- s.object({
166
- left: s.number(),
167
- top: s.number(),
168
- right: s.number(),
169
- bottom: s.number()
165
+ i.object({
166
+ left: i.number(),
167
+ top: i.number(),
168
+ right: i.number(),
169
+ bottom: i.number()
170
170
  });
171
- s.object({
172
- one: X,
173
- two: X,
174
- root: yt
171
+ i.object({
172
+ one: ne,
173
+ two: ne,
174
+ root: xt
175
175
  });
176
- const le = (r, e, t = 0, n = 0, i) => {
176
+ const ye = (r, e, t = 0, n = 0, s) => {
177
177
  const a = {
178
- one: { ...we },
179
- two: { ...we },
180
- root: i ?? gt
178
+ one: { ...Ne },
179
+ two: { ...Ne },
180
+ root: s ?? Mt
181
181
  };
182
182
  if (typeof r == "number") {
183
183
  if (typeof e != "number")
184
184
  throw new Error("Box constructor called with invalid arguments");
185
185
  return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
186
186
  }
187
- 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 = {
187
+ return "one" in r && "two" in r && "root" in r ? { ...r, root: s ?? 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 = {
188
188
  x: a.one.x + e.width,
189
189
  y: a.one.y + e.height
190
190
  } : "signedWidth" in e ? a.two = {
191
191
  x: a.one.x + e.signedWidth,
192
192
  y: a.one.y + e.signedHeight
193
193
  } : a.two = e, a));
194
- }, ne = (r) => {
195
- const e = le(r);
194
+ }, ce = (r) => {
195
+ const e = ye(r);
196
196
  return { lower: e.one.x, upper: e.two.x };
197
- }, se = (r) => {
198
- const e = le(r);
197
+ }, le = (r) => {
198
+ const e = ye(r);
199
199
  return { lower: e.one.y, upper: e.two.y };
200
- }, Ot = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
201
- var vt = Object.defineProperty, bt = (r, e, t) => e in r ? vt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, C = (r, e, t) => bt(r, typeof e != "symbol" ? e + "" : e, t);
202
- const Tt = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
203
- s.object({ offset: me, scale: me });
204
- const St = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
200
+ }, Bt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
201
+ var Ut = Object.defineProperty, Ct = (r, e, t) => e in r ? Ut(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, D = (r, e, t) => Ct(r, typeof e != "symbol" ? e + "" : e, t);
202
+ const Dt = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
203
+ i.object({ offset: Ie, scale: Ie });
204
+ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
205
205
  e,
206
- i ? n - r : n + r
207
- ], It = (r) => (e, t, n, i) => [
206
+ s ? n - r : n + r
207
+ ], Lt = (r) => (e, t, n, s) => [
208
208
  e,
209
- i ? n / r : n * r
210
- ], Nt = (r) => (e, t, n) => {
209
+ s ? n / r : n * r
210
+ ], Yt = (r) => (e, t, n) => {
211
211
  if (e === null) return [r, n];
212
- const { lower: i, upper: a } = e, { lower: c, upper: h } = r, g = a - i, m = h - c;
213
- if (t === "dimension") return [r, n * (m / g)];
214
- const O = (n - i) * (m / g) + c;
215
- return [r, O];
216
- }, Et = (r) => (e, t, n) => [r, n], At = () => (r, e, t) => {
212
+ const { lower: s, upper: a } = e, { lower: c, upper: d } = r, f = a - s, y = d - c;
213
+ if (t === "dimension") return [r, n * (y / f)];
214
+ const T = (n - s) * (y / f) + c;
215
+ return [r, T];
216
+ }, kt = (r) => (e, t, n) => [r, n], jt = () => (r, e, t) => {
217
217
  if (r === null) throw new Error("cannot invert without bounds");
218
218
  if (e === "dimension") return [r, t];
219
- const { lower: n, upper: i } = r;
220
- return [r, i - (t - n)];
221
- }, $t = (r) => (e, t, n) => {
222
- const { lower: i, upper: a } = r;
223
- return n = Tt(n, i, a), [e, n];
224
- }, ae = class W {
219
+ const { lower: n, upper: s } = r;
220
+ return [r, s - (t - n)];
221
+ }, Ft = (r) => (e, t, n) => {
222
+ const { lower: s, upper: a } = r;
223
+ return n = Dt(n, s, a), [e, n];
224
+ }, fe = class W {
225
225
  constructor() {
226
- C(this, "ops", []), C(this, "currBounds", null), C(this, "currType", null), C(this, "reversed", !1), this.ops = [];
226
+ D(this, "ops", []), D(this, "currBounds", null), D(this, "currType", null), D(this, "reversed", !1), this.ops = [];
227
227
  }
228
228
  static translate(e) {
229
229
  return new W().translate(e);
@@ -235,27 +235,27 @@ const St = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
235
235
  return new W().scale(e, t);
236
236
  }
237
237
  translate(e) {
238
- const t = this.new(), n = St(e);
238
+ const t = this.new(), n = Pt(e);
239
239
  return n.type = "translate", t.ops.push(n), t;
240
240
  }
241
241
  magnify(e) {
242
- const t = this.new(), n = It(e);
242
+ const t = this.new(), n = Lt(e);
243
243
  return n.type = "magnify", t.ops.push(n), t;
244
244
  }
245
245
  scale(e, t) {
246
- const n = re(e, t), i = this.new(), a = Nt(n);
247
- return a.type = "scale", i.ops.push(a), i;
246
+ const n = K(e, t), s = this.new(), a = Yt(n);
247
+ return a.type = "scale", s.ops.push(a), s;
248
248
  }
249
249
  clamp(e, t) {
250
- const n = re(e, t), i = this.new(), a = $t(n);
251
- return a.type = "clamp", i.ops.push(a), i;
250
+ const n = K(e, t), s = this.new(), a = Ft(n);
251
+ return a.type = "clamp", s.ops.push(a), s;
252
252
  }
253
253
  reBound(e, t) {
254
- const n = re(e, t), i = this.new(), a = Et(n);
255
- return a.type = "re-bound", i.ops.push(a), i;
254
+ const n = K(e, t), s = this.new(), a = kt(n);
255
+ return a.type = "re-bound", s.ops.push(a), s;
256
256
  }
257
257
  invert() {
258
- const e = At();
258
+ const e = jt();
259
259
  e.type = "invert";
260
260
  const t = this.new();
261
261
  return t.ops.push(e), t;
@@ -272,7 +272,7 @@ const St = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
272
272
  }
273
273
  exec(e, t) {
274
274
  return this.currBounds = null, this.ops.reduce(
275
- ([n, i], a) => a(n, e, i, this.reversed),
275
+ ([n, s], a) => a(n, e, s, this.reversed),
276
276
  [null, t]
277
277
  )[1];
278
278
  }
@@ -280,47 +280,47 @@ const St = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
280
280
  const e = this.new();
281
281
  e.ops.reverse();
282
282
  const t = [];
283
- return e.ops.forEach((n, i) => {
284
- if (n.type === "scale" || t.some(([c, h]) => i >= c && i <= h))
283
+ return e.ops.forEach((n, s) => {
284
+ if (n.type === "scale" || t.some(([c, d]) => s >= c && s <= d))
285
285
  return;
286
- const a = e.ops.findIndex((c, h) => c.type === "scale" && h > i);
287
- a !== -1 && t.push([i, a]);
288
- }), t.forEach(([n, i]) => {
289
- const a = e.ops.slice(n, i);
290
- a.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...a);
286
+ const a = e.ops.findIndex((c, d) => c.type === "scale" && d > s);
287
+ a !== -1 && t.push([s, a]);
288
+ }), t.forEach(([n, s]) => {
289
+ const a = e.ops.slice(n, s);
290
+ a.unshift(e.ops[s]), e.ops.splice(n, s - n + 1, ...a);
291
291
  }), e.reversed = !e.reversed, e;
292
292
  }
293
293
  };
294
- C(ae, "IDENTITY", new ae());
295
- let Oe = ae;
296
- const ve = class M {
297
- constructor(e = new Oe(), t = new Oe(), n = null) {
298
- C(this, "x"), C(this, "y"), C(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
294
+ D(fe, "IDENTITY", new fe());
295
+ let Ee = fe;
296
+ const Ae = class U {
297
+ constructor(e = new Ee(), t = new Ee(), n = null) {
298
+ D(this, "x"), D(this, "y"), D(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
299
299
  }
300
300
  static translate(e, t) {
301
- return new M().translate(e, t);
301
+ return new U().translate(e, t);
302
302
  }
303
303
  static translateX(e) {
304
- return new M().translateX(e);
304
+ return new U().translateX(e);
305
305
  }
306
306
  static translateY(e) {
307
- return new M().translateY(e);
307
+ return new U().translateY(e);
308
308
  }
309
309
  static clamp(e) {
310
- return new M().clamp(e);
310
+ return new U().clamp(e);
311
311
  }
312
312
  static magnify(e) {
313
- return new M().magnify(e);
313
+ return new U().magnify(e);
314
314
  }
315
315
  static scale(e) {
316
- return new M().scale(e);
316
+ return new U().scale(e);
317
317
  }
318
318
  static reBound(e) {
319
- return new M().reBound(e);
319
+ return new U().reBound(e);
320
320
  }
321
321
  translate(e, t) {
322
- const n = wt(e, t), i = this.copy();
323
- return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
322
+ const n = Rt(e, t), s = this.copy();
323
+ return s.x = this.x.translate(n.x), s.y = this.y.translate(n.y), s;
324
324
  }
325
325
  translateX(e) {
326
326
  const t = this.copy();
@@ -336,22 +336,22 @@ const ve = class M {
336
336
  }
337
337
  scale(e) {
338
338
  const t = this.copy();
339
- if (Ot(e)) {
339
+ if (Bt(e)) {
340
340
  const n = this.currRoot;
341
- return t.currRoot = e.root, n != null && !mt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ne(e)), t.y = t.y.scale(se(e)), t;
341
+ return t.currRoot = e.root, n != null && !$t(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(ce(e)), t.y = t.y.scale(le(e)), t;
342
342
  }
343
343
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
344
344
  }
345
345
  reBound(e) {
346
346
  const t = this.copy();
347
- return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(se(e)), t;
347
+ return t.x = this.x.reBound(ce(e)), t.y = this.y.reBound(le(e)), t;
348
348
  }
349
349
  clamp(e) {
350
350
  const t = this.copy();
351
- return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(se(e)), t;
351
+ return t.x = this.x.clamp(ce(e)), t.y = this.y.clamp(le(e)), t;
352
352
  }
353
353
  copy() {
354
- const e = new M();
354
+ const e = new U();
355
355
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
356
356
  }
357
357
  reverse() {
@@ -362,7 +362,7 @@ const ve = class M {
362
362
  return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
363
363
  }
364
364
  box(e) {
365
- return le(
365
+ return ye(
366
366
  this.pos(e.one),
367
367
  this.pos(e.two),
368
368
  0,
@@ -371,12 +371,45 @@ const ve = class M {
371
371
  );
372
372
  }
373
373
  };
374
- C(ve, "IDENTITY", new ve());
375
- const xt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
376
- s.union([$e, xt, X, Q]);
377
- var Ut = Object.defineProperty, Mt = (r, e, t) => e in r ? Ut(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => Mt(r, typeof e != "symbol" ? e + "" : e, t);
378
- const De = (r, e) => {
379
- const t = new T(e);
374
+ D(Ae, "IDENTITY", new Ae());
375
+ const Gt = (r) => r != null && typeof r == "object" && "toString" in r, qt = (r, e = !1) => {
376
+ const t = Gt(r) ? "stringer" : typeof r;
377
+ let n;
378
+ switch (t) {
379
+ case "string":
380
+ n = (s, a) => s.localeCompare(a);
381
+ break;
382
+ case "stringer":
383
+ n = (s, a) => s.toString().localeCompare(a.toString());
384
+ break;
385
+ case "number":
386
+ n = (s, a) => Number(s) - Number(a);
387
+ break;
388
+ case "bigint":
389
+ n = (s, a) => BigInt(s) - BigInt(a) > 0n ? 1 : -1;
390
+ break;
391
+ case "boolean":
392
+ n = (s, a) => Number(s) - Number(a);
393
+ break;
394
+ case "undefined":
395
+ n = () => 0;
396
+ break;
397
+ default:
398
+ return console.warn(`sortFunc: unknown type ${t}`), () => -1;
399
+ }
400
+ return e ? Wt(n) : n;
401
+ }, Wt = (r) => (e, t) => r(t, e), zt = i.object({ signedWidth: i.number(), signedHeight: i.number() });
402
+ i.union([je, zt, ne, ie]);
403
+ const Zt = i.bigint().or(i.string().transform(BigInt));
404
+ var Vt = Object.defineProperty, Jt = (r, e, t) => e in r ? Vt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => Jt(r, typeof e != "symbol" ? e + "" : e, t);
405
+ let Ht = (r, e = 21) => (t = e) => {
406
+ let n = "", s = t;
407
+ for (; s--; )
408
+ n += r[Math.random() * r.length | 0];
409
+ return n;
410
+ };
411
+ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt = Ht(Kt, 11), Qt = i.enum(["static", "dynamic"]), Ve = (r, e) => {
412
+ const t = new O(e);
380
413
  if (![
381
414
  S.DAY,
382
415
  S.HOUR,
@@ -385,28 +418,28 @@ const De = (r, e) => {
385
418
  S.MILLISECOND,
386
419
  S.MICROSECOND,
387
420
  S.NANOSECOND
388
- ].some((i) => i.equals(t)))
421
+ ].some((s) => s.equals(t)))
389
422
  throw new Error(
390
423
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
391
424
  );
392
425
  const n = r.valueOf() % t.valueOf();
393
- return r instanceof T ? new T(n) : new S(n);
394
- }, p = class l {
426
+ return r instanceof O ? new O(n) : new S(n);
427
+ }, m = class h {
395
428
  constructor(e, t = "UTC") {
396
- if (u(this, "value"), u(this, "encodeValue", !0), e == null) this.value = l.now().valueOf();
429
+ if (u(this, "value"), u(this, "encodeValue", !0), e == null) this.value = h.now().valueOf();
397
430
  else if (e instanceof Date)
398
- this.value = BigInt(e.getTime()) * l.MILLISECOND.valueOf();
431
+ this.value = BigInt(e.getTime()) * h.MILLISECOND.valueOf();
399
432
  else if (typeof e == "string")
400
- this.value = l.parseDateTimeString(e, t).valueOf();
401
- else if (Array.isArray(e)) this.value = l.parseDate(e);
433
+ this.value = h.parseDateTimeString(e, t).valueOf();
434
+ else if (Array.isArray(e)) this.value = h.parseDate(e);
402
435
  else {
403
436
  let n = BigInt(0);
404
- e instanceof Number && (e = e.valueOf()), t === "local" && (n = l.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = l.MAX : e = l.MIN)), this.value = BigInt(e.valueOf()) + n;
437
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = h.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = h.MAX : e = h.MIN)), this.value = BigInt(e.valueOf()) + n;
405
438
  }
406
439
  }
407
440
  static parseDate([e = 1970, t = 1, n = 1]) {
408
- const i = new Date(e, t - 1, n, 0, 0, 0, 0);
409
- return new l(BigInt(i.getTime()) * l.MILLISECOND.valueOf()).truncate(l.DAY).valueOf();
441
+ const s = new Date(e, t - 1, n, 0, 0, 0, 0);
442
+ return new h(BigInt(s.getTime()) * h.MILLISECOND.valueOf()).truncate(h.DAY).valueOf();
410
443
  }
411
444
  encode() {
412
445
  return this.value.toString();
@@ -415,18 +448,18 @@ const De = (r, e) => {
415
448
  return this.value;
416
449
  }
417
450
  static parseTimeString(e, t = "UTC") {
418
- const [n, i, a] = e.split(":");
419
- let c = "00", h = "00";
420
- a != null && ([c, h] = a.split("."));
421
- let g = l.hours(parseInt(n ?? "00", 10)).add(l.minutes(parseInt(i ?? "00", 10))).add(l.seconds(parseInt(c ?? "00", 10))).add(l.milliseconds(parseInt(h ?? "00", 10)));
422
- return t === "local" && (g = g.add(l.utcOffset)), g.valueOf();
451
+ const [n, s, a] = e.split(":");
452
+ let c = "00", d = "00";
453
+ a != null && ([c, d] = a.split("."));
454
+ let f = h.hours(parseInt(n ?? "00", 10)).add(h.minutes(parseInt(s ?? "00", 10))).add(h.seconds(parseInt(c ?? "00", 10))).add(h.milliseconds(parseInt(d ?? "00", 10)));
455
+ return t === "local" && (f = f.add(h.utcOffset)), f.valueOf();
423
456
  }
424
457
  static parseDateTimeString(e, t = "UTC") {
425
458
  if (!e.includes("/") && !e.includes("-"))
426
- return l.parseTimeString(e, t);
459
+ return h.parseTimeString(e, t);
427
460
  const n = new Date(e);
428
- return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new l(
429
- BigInt(n.getTime()) * l.MILLISECOND.valueOf(),
461
+ return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new h(
462
+ BigInt(n.getTime()) * h.MILLISECOND.valueOf(),
430
463
  t
431
464
  ).valueOf();
432
465
  }
@@ -451,7 +484,7 @@ const De = (r, e) => {
451
484
  }
452
485
  }
453
486
  toISOString(e = "UTC") {
454
- return e === "UTC" ? this.date().toISOString() : this.sub(l.utcOffset).date().toISOString();
487
+ return e === "UTC" ? this.date().toISOString() : this.sub(h.utcOffset).date().toISOString();
455
488
  }
456
489
  timeString(e = !1, t = "UTC") {
457
490
  const n = this.toISOString(t);
@@ -463,7 +496,7 @@ const De = (r, e) => {
463
496
  }
464
497
  static get utcOffset() {
465
498
  return new S(
466
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * l.MINUTE.valueOf()
499
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * h.MINUTE.valueOf()
467
500
  );
468
501
  }
469
502
  /**
@@ -472,7 +505,7 @@ const De = (r, e) => {
472
505
  * @param other - The other timestamp.
473
506
  */
474
507
  static since(e) {
475
- return new l().span(e);
508
+ return new h().span(e);
476
509
  }
477
510
  /** @returns A JavaScript Date object representing the TimeStamp. */
478
511
  date() {
@@ -485,7 +518,7 @@ const De = (r, e) => {
485
518
  * @returns True if the TimeStamps are equal, false otherwise.
486
519
  */
487
520
  equals(e) {
488
- return this.valueOf() === new l(e).valueOf();
521
+ return this.valueOf() === new h(e).valueOf();
489
522
  }
490
523
  /**
491
524
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -505,7 +538,7 @@ const De = (r, e) => {
505
538
  * valid, regardless of the TimeStamp order.
506
539
  */
507
540
  range(e) {
508
- return new Ct(this, e).makeValid();
541
+ return new me(this, e).makeValid();
509
542
  }
510
543
  /**
511
544
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -534,7 +567,7 @@ const De = (r, e) => {
534
567
  * otherwise.
535
568
  */
536
569
  after(e) {
537
- return this.valueOf() > new l(e).valueOf();
570
+ return this.valueOf() > new h(e).valueOf();
538
571
  }
539
572
  /**
540
573
  * Checks if the TimeStamp is after or equal to the given TimeStamp.
@@ -544,7 +577,7 @@ const De = (r, e) => {
544
577
  * false otherwise.
545
578
  */
546
579
  afterEq(e) {
547
- return this.valueOf() >= new l(e).valueOf();
580
+ return this.valueOf() >= new h(e).valueOf();
548
581
  }
549
582
  /**
550
583
  * Checks if the TimeStamp is before the given TimeStamp.
@@ -554,7 +587,7 @@ const De = (r, e) => {
554
587
  * otherwise.
555
588
  */
556
589
  before(e) {
557
- return this.valueOf() < new l(e).valueOf();
590
+ return this.valueOf() < new h(e).valueOf();
558
591
  }
559
592
  /**
560
593
  * Checks if TimeStamp is before or equal to the current timestamp.
@@ -564,7 +597,7 @@ const De = (r, e) => {
564
597
  * false otherwise.
565
598
  */
566
599
  beforeEq(e) {
567
- return this.valueOf() <= new l(e).valueOf();
600
+ return this.valueOf() <= new h(e).valueOf();
568
601
  }
569
602
  /**
570
603
  * Adds a TimeSpan to the TimeStamp.
@@ -574,7 +607,7 @@ const De = (r, e) => {
574
607
  * TimeSpan.
575
608
  */
576
609
  add(e) {
577
- return new l(this.valueOf() + BigInt(e.valueOf()));
610
+ return new h(this.valueOf() + BigInt(e.valueOf()));
578
611
  }
579
612
  /**
580
613
  * Subtracts a TimeSpan from the TimeStamp.
@@ -584,13 +617,13 @@ const De = (r, e) => {
584
617
  * TimeSpan.
585
618
  */
586
619
  sub(e) {
587
- return new l(this.valueOf() - BigInt(e.valueOf()));
620
+ return new h(this.valueOf() - BigInt(e.valueOf()));
588
621
  }
589
622
  /**
590
623
  * @returns The number of milliseconds since the unix epoch.
591
624
  */
592
625
  milliseconds() {
593
- return Number(this.valueOf()) / Number(l.MILLISECOND.valueOf());
626
+ return Number(this.valueOf()) / Number(h.MILLISECOND.valueOf());
594
627
  }
595
628
  toString() {
596
629
  return this.date().toISOString();
@@ -607,11 +640,11 @@ const De = (r, e) => {
607
640
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
608
641
  */
609
642
  remainder(e) {
610
- return De(this, e);
643
+ return Ve(this, e);
611
644
  }
612
645
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
613
646
  get isToday() {
614
- return this.truncate(S.DAY).equals(l.now().truncate(S.DAY));
647
+ return this.truncate(S.DAY).equals(h.now().truncate(S.DAY));
615
648
  }
616
649
  truncate(e) {
617
650
  return this.sub(this.remainder(e));
@@ -622,72 +655,72 @@ const De = (r, e) => {
622
655
  * JavaScript can do).
623
656
  */
624
657
  static now() {
625
- return new l(/* @__PURE__ */ new Date());
658
+ return new h(/* @__PURE__ */ new Date());
626
659
  }
627
660
  static max(...e) {
628
- let t = l.MIN;
661
+ let t = h.MIN;
629
662
  for (const n of e) {
630
- const i = new l(n);
631
- i.after(t) && (t = i);
663
+ const s = new h(n);
664
+ s.after(t) && (t = s);
632
665
  }
633
666
  return t;
634
667
  }
635
668
  static min(...e) {
636
- let t = l.MAX;
669
+ let t = h.MAX;
637
670
  for (const n of e) {
638
- const i = new l(n);
639
- i.before(t) && (t = i);
671
+ const s = new h(n);
672
+ s.before(t) && (t = s);
640
673
  }
641
674
  return t;
642
675
  }
643
676
  /** @returns a new TimeStamp n nanoseconds after the unix epoch */
644
677
  static nanoseconds(e) {
645
- return new l(e);
678
+ return new h(e);
646
679
  }
647
680
  /** @returns a new TimeStamp n microseconds after the unix epoch */
648
681
  static microseconds(e) {
649
- return l.nanoseconds(e * 1e3);
682
+ return h.nanoseconds(e * 1e3);
650
683
  }
651
684
  /** @returns a new TimeStamp n milliseconds after the unix epoch */
652
685
  static milliseconds(e) {
653
- return l.microseconds(e * 1e3);
686
+ return h.microseconds(e * 1e3);
654
687
  }
655
688
  /** @returns a new TimeStamp n seconds after the unix epoch */
656
689
  static seconds(e) {
657
- return l.milliseconds(e * 1e3);
690
+ return h.milliseconds(e * 1e3);
658
691
  }
659
692
  /** @returns a new TimeStamp n minutes after the unix epoch */
660
693
  static minutes(e) {
661
- return l.seconds(e * 60);
694
+ return h.seconds(e * 60);
662
695
  }
663
696
  /** @returns a new TimeStamp n hours after the unix epoch */
664
697
  static hours(e) {
665
- return l.minutes(e * 60);
698
+ return h.minutes(e * 60);
666
699
  }
667
700
  /** @returns a new TimeStamp n days after the unix epoch */
668
701
  static days(e) {
669
- return l.hours(e * 24);
702
+ return h.hours(e * 24);
670
703
  }
671
704
  };
672
- u(p, "NANOSECOND", p.nanoseconds(1)), /** One microsecond after the unix epoch */
673
- u(p, "MICROSECOND", p.microseconds(1)), /** One millisecond after the unix epoch */
674
- u(p, "MILLISECOND", p.milliseconds(1)), /** One second after the unix epoch */
675
- u(p, "SECOND", p.seconds(1)), /** One minute after the unix epoch */
676
- u(p, "MINUTE", p.minutes(1)), /** One hour after the unix epoch */
677
- u(p, "HOUR", p.hours(1)), /** One day after the unix epoch */
678
- u(p, "DAY", p.days(1)), /** The maximum possible value for a timestamp */
679
- u(p, "MAX", new p((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
680
- u(p, "MIN", new p(0)), /** The unix epoch */
681
- u(p, "ZERO", new p(0)), /** A zod schema for validating timestamps */
682
- u(p, "z", s.union([
683
- s.object({ value: s.bigint() }).transform((r) => new p(r.value)),
684
- s.string().transform((r) => new p(BigInt(r))),
685
- s.instanceof(Number).transform((r) => new p(r)),
686
- s.number().transform((r) => new p(r)),
687
- s.instanceof(p)
705
+ u(m, "NANOSECOND", m.nanoseconds(1)), /** One microsecond after the unix epoch */
706
+ u(m, "MICROSECOND", m.microseconds(1)), /** One millisecond after the unix epoch */
707
+ u(m, "MILLISECOND", m.milliseconds(1)), /** One second after the unix epoch */
708
+ u(m, "SECOND", m.seconds(1)), /** One minute after the unix epoch */
709
+ u(m, "MINUTE", m.minutes(1)), /** One hour after the unix epoch */
710
+ u(m, "HOUR", m.hours(1)), /** One day after the unix epoch */
711
+ u(m, "DAY", m.days(1)), /** The maximum possible value for a timestamp */
712
+ u(m, "MAX", new m((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
713
+ u(m, "MIN", new m(0)), /** The unix epoch */
714
+ u(m, "ZERO", new m(0)), /** A zod schema for validating timestamps */
715
+ u(m, "z", i.union([
716
+ i.object({ value: i.bigint() }).transform((r) => new m(r.value)),
717
+ i.string().transform((r) => new m(BigInt(r))),
718
+ i.instanceof(Number).transform((r) => new m(r)),
719
+ i.number().transform((r) => new m(r)),
720
+ i.instanceof(m)
688
721
  ]));
689
- let T = p;
690
- const y = class d {
722
+ let O = m;
723
+ const w = class g {
691
724
  constructor(e) {
692
725
  u(this, "value"), u(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
693
726
  }
@@ -698,52 +731,52 @@ const y = class d {
698
731
  return this.value;
699
732
  }
700
733
  lessThan(e) {
701
- return this.valueOf() < new d(e).valueOf();
734
+ return this.valueOf() < new g(e).valueOf();
702
735
  }
703
736
  greaterThan(e) {
704
- return this.valueOf() > new d(e).valueOf();
737
+ return this.valueOf() > new g(e).valueOf();
705
738
  }
706
739
  lessThanOrEqual(e) {
707
- return this.valueOf() <= new d(e).valueOf();
740
+ return this.valueOf() <= new g(e).valueOf();
708
741
  }
709
742
  greaterThanOrEqual(e) {
710
- return this.valueOf() >= new d(e).valueOf();
743
+ return this.valueOf() >= new g(e).valueOf();
711
744
  }
712
745
  remainder(e) {
713
- return De(this, e);
746
+ return Ve(this, e);
714
747
  }
715
748
  truncate(e) {
716
- return new d(
749
+ return new g(
717
750
  BigInt(Math.trunc(Number(this.valueOf() / e.valueOf()))) * e.valueOf()
718
751
  );
719
752
  }
720
753
  toString() {
721
- const e = this.truncate(d.DAY), t = this.truncate(d.HOUR), n = this.truncate(d.MINUTE), i = this.truncate(d.SECOND), a = this.truncate(d.MILLISECOND), c = this.truncate(d.MICROSECOND), h = this.truncate(d.NANOSECOND), g = e, m = t.sub(e), O = n.sub(t), w = i.sub(n), A = a.sub(i), k = c.sub(a), U = h.sub(c);
722
- let E = "";
723
- return g.isZero || (E += `${g.days}d `), m.isZero || (E += `${m.hours}h `), O.isZero || (E += `${O.minutes}m `), w.isZero || (E += `${w.seconds}s `), A.isZero || (E += `${A.milliseconds}ms `), k.isZero || (E += `${k.microseconds}µs `), U.isZero || (E += `${U.nanoseconds}ns`), E.trim();
754
+ const e = this.truncate(g.DAY), t = this.truncate(g.HOUR), n = this.truncate(g.MINUTE), s = this.truncate(g.SECOND), a = this.truncate(g.MILLISECOND), c = this.truncate(g.MICROSECOND), d = this.truncate(g.NANOSECOND), f = e, y = t.sub(e), T = n.sub(t), l = s.sub(n), E = a.sub(s), R = c.sub(a), B = d.sub(c);
755
+ let x = "";
756
+ return f.isZero || (x += `${f.days}d `), y.isZero || (x += `${y.hours}h `), T.isZero || (x += `${T.minutes}m `), l.isZero || (x += `${l.seconds}s `), E.isZero || (x += `${E.milliseconds}ms `), R.isZero || (x += `${R.microseconds}µs `), B.isZero || (x += `${B.nanoseconds}ns`), x.trim();
724
757
  }
725
758
  /** @returns the decimal number of days in the timespan */
726
759
  get days() {
727
- return Number(this.valueOf()) / Number(d.DAY.valueOf());
760
+ return Number(this.valueOf()) / Number(g.DAY.valueOf());
728
761
  }
729
762
  /** @returns the decimal number of hours in the timespan */
730
763
  get hours() {
731
- return Number(this.valueOf()) / Number(d.HOUR.valueOf());
764
+ return Number(this.valueOf()) / Number(g.HOUR.valueOf());
732
765
  }
733
766
  /** @returns the decimal number of minutes in the timespan */
734
767
  get minutes() {
735
- return Number(this.valueOf()) / Number(d.MINUTE.valueOf());
768
+ return Number(this.valueOf()) / Number(g.MINUTE.valueOf());
736
769
  }
737
770
  /** @returns The number of seconds in the TimeSpan. */
738
771
  get seconds() {
739
- return Number(this.valueOf()) / Number(d.SECOND.valueOf());
772
+ return Number(this.valueOf()) / Number(g.SECOND.valueOf());
740
773
  }
741
774
  /** @returns The number of milliseconds in the TimeSpan. */
742
775
  get milliseconds() {
743
- return Number(this.valueOf()) / Number(d.MILLISECOND.valueOf());
776
+ return Number(this.valueOf()) / Number(g.MILLISECOND.valueOf());
744
777
  }
745
778
  get microseconds() {
746
- return Number(this.valueOf()) / Number(d.MICROSECOND.valueOf());
779
+ return Number(this.valueOf()) / Number(g.MICROSECOND.valueOf());
747
780
  }
748
781
  get nanoseconds() {
749
782
  return Number(this.valueOf());
@@ -762,7 +795,7 @@ const y = class d {
762
795
  * @returns True if the TimeSpans are equal, false otherwise.
763
796
  */
764
797
  equals(e) {
765
- return this.valueOf() === new d(e).valueOf();
798
+ return this.valueOf() === new g(e).valueOf();
766
799
  }
767
800
  /**
768
801
  * Adds a TimeSpan to the TimeSpan.
@@ -770,7 +803,7 @@ const y = class d {
770
803
  * @returns A new TimeSpan representing the sum of the two TimeSpans.
771
804
  */
772
805
  add(e) {
773
- return new d(this.valueOf() + new d(e).valueOf());
806
+ return new g(this.valueOf() + new g(e).valueOf());
774
807
  }
775
808
  /**
776
809
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -778,7 +811,7 @@ const y = class d {
778
811
  * @param other
779
812
  */
780
813
  sub(e) {
781
- return new d(this.valueOf() - new d(e).valueOf());
814
+ return new g(this.valueOf() - new g(e).valueOf());
782
815
  }
783
816
  /**
784
817
  * Creates a TimeSpan representing the given number of nanoseconds.
@@ -787,7 +820,7 @@ const y = class d {
787
820
  * @returns A TimeSpan representing the given number of nanoseconds.
788
821
  */
789
822
  static nanoseconds(e = 1) {
790
- return new d(e);
823
+ return new g(e);
791
824
  }
792
825
  /**
793
826
  * Creates a TimeSpan representing the given number of microseconds.
@@ -796,7 +829,7 @@ const y = class d {
796
829
  * @returns A TimeSpan representing the given number of microseconds.
797
830
  */
798
831
  static microseconds(e = 1) {
799
- return d.nanoseconds(e * 1e3);
832
+ return g.nanoseconds(e * 1e3);
800
833
  }
801
834
  /**
802
835
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -805,7 +838,7 @@ const y = class d {
805
838
  * @returns A TimeSpan representing the given number of milliseconds.
806
839
  */
807
840
  static milliseconds(e = 1) {
808
- return d.microseconds(e * 1e3);
841
+ return g.microseconds(e * 1e3);
809
842
  }
810
843
  /**
811
844
  * Creates a TimeSpan representing the given number of seconds.
@@ -814,7 +847,7 @@ const y = class d {
814
847
  * @returns A TimeSpan representing the given number of seconds.
815
848
  */
816
849
  static seconds(e = 1) {
817
- return d.milliseconds(e * 1e3);
850
+ return g.milliseconds(e * 1e3);
818
851
  }
819
852
  /**
820
853
  * Creates a TimeSpan representing the given number of minutes.
@@ -823,7 +856,7 @@ const y = class d {
823
856
  * @returns A TimeSpan representing the given number of minutes.
824
857
  */
825
858
  static minutes(e) {
826
- return d.seconds(e.valueOf() * 60);
859
+ return g.seconds(e.valueOf() * 60);
827
860
  }
828
861
  /**
829
862
  * Creates a TimeSpan representing the given number of hours.
@@ -832,7 +865,7 @@ const y = class d {
832
865
  * @returns A TimeSpan representing the given number of hours.
833
866
  */
834
867
  static hours(e) {
835
- return d.minutes(e * 60);
868
+ return g.minutes(e * 60);
836
869
  }
837
870
  /**
838
871
  * Creates a TimeSpan representing the given number of days.
@@ -841,28 +874,28 @@ const y = class d {
841
874
  * @returns A TimeSpan representing the given number of days.
842
875
  */
843
876
  static days(e) {
844
- return d.hours(e * 24);
877
+ return g.hours(e * 24);
845
878
  }
846
879
  };
847
- u(y, "NANOSECOND", y.nanoseconds(1)), /** A microsecond. */
848
- u(y, "MICROSECOND", y.microseconds(1)), /** A millisecond. */
849
- u(y, "MILLISECOND", y.milliseconds(1)), /** A second. */
850
- u(y, "SECOND", y.seconds(1)), /** A minute. */
851
- u(y, "MINUTE", y.minutes(1)), /** Represents an hour. */
852
- u(y, "HOUR", y.hours(1)), /** Represents a day. */
853
- u(y, "DAY", y.days(1)), /** The maximum possible value for a TimeSpan. */
854
- u(y, "MAX", new y((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
855
- u(y, "MIN", new y(0)), /** The zero value for a TimeSpan. */
856
- u(y, "ZERO", new y(0)), /** A zod schema for validating and transforming timespans */
857
- u(y, "z", s.union([
858
- s.object({ value: s.bigint() }).transform((r) => new y(r.value)),
859
- s.string().transform((r) => new y(BigInt(r))),
860
- s.instanceof(Number).transform((r) => new y(r)),
861
- s.number().transform((r) => new y(r)),
862
- s.instanceof(y)
880
+ u(w, "NANOSECOND", w.nanoseconds(1)), /** A microsecond. */
881
+ u(w, "MICROSECOND", w.microseconds(1)), /** A millisecond. */
882
+ u(w, "MILLISECOND", w.milliseconds(1)), /** A second. */
883
+ u(w, "SECOND", w.seconds(1)), /** A minute. */
884
+ u(w, "MINUTE", w.minutes(1)), /** Represents an hour. */
885
+ u(w, "HOUR", w.hours(1)), /** Represents a day. */
886
+ u(w, "DAY", w.days(1)), /** The maximum possible value for a TimeSpan. */
887
+ u(w, "MAX", new w((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
888
+ u(w, "MIN", new w(0)), /** The zero value for a TimeSpan. */
889
+ u(w, "ZERO", new w(0)), /** A zod schema for validating and transforming timespans */
890
+ u(w, "z", i.union([
891
+ i.object({ value: i.bigint() }).transform((r) => new w(r.value)),
892
+ i.string().transform((r) => new w(BigInt(r))),
893
+ i.instanceof(Number).transform((r) => new w(r)),
894
+ i.number().transform((r) => new w(r)),
895
+ i.instanceof(w)
863
896
  ]));
864
- let S = y;
865
- const z = class V extends Number {
897
+ let S = w;
898
+ const Q = class ee extends Number {
866
899
  constructor(e) {
867
900
  e instanceof Number ? super(e.valueOf()) : super(e);
868
901
  }
@@ -872,7 +905,7 @@ const z = class V extends Number {
872
905
  }
873
906
  /** @returns The number of seconds in the Rate. */
874
907
  equals(e) {
875
- return this.valueOf() === new V(e).valueOf();
908
+ return this.valueOf() === new ee(e).valueOf();
876
909
  }
877
910
  /**
878
911
  * Calculates the period of the Rate as a TimeSpan.
@@ -899,7 +932,7 @@ const z = class V extends Number {
899
932
  * @returns The number of bytes in the given TimeSpan at this rate.
900
933
  */
901
934
  byteCount(e, t) {
902
- return this.sampleCount(e) * new N(t).valueOf();
935
+ return this.sampleCount(e) * new A(t).valueOf();
903
936
  }
904
937
  /**
905
938
  * Calculates a TimeSpan given the number of samples at this rate.
@@ -927,7 +960,7 @@ const z = class V extends Number {
927
960
  * @returns A Rate representing the given number of Hz.
928
961
  */
929
962
  static hz(e) {
930
- return new V(e);
963
+ return new ee(e);
931
964
  }
932
965
  /**
933
966
  * Creates a Rate representing the given number of kHz.
@@ -936,15 +969,15 @@ const z = class V extends Number {
936
969
  * @returns A Rate representing the given number of kHz.
937
970
  */
938
971
  static khz(e) {
939
- return V.hz(e * 1e3);
972
+ return ee.hz(e * 1e3);
940
973
  }
941
974
  };
942
- u(z, "z", s.union([
943
- s.number().transform((r) => new z(r)),
944
- s.instanceof(Number).transform((r) => new z(r)),
945
- s.instanceof(z)
975
+ u(Q, "z", i.union([
976
+ i.number().transform((r) => new Q(r)),
977
+ i.instanceof(Number).transform((r) => new Q(r)),
978
+ i.instanceof(Q)
946
979
  ]));
947
- const b = class extends Number {
980
+ const I = class extends Number {
948
981
  /**
949
982
  * Creates a Density representing the given number of bytes per value.
950
983
  *
@@ -959,22 +992,22 @@ const b = class extends Number {
959
992
  return e.valueOf() / this.valueOf();
960
993
  }
961
994
  size(e) {
962
- return new Bt(e * this.valueOf());
995
+ return new Je(e * this.valueOf());
963
996
  }
964
997
  };
965
- u(b, "UNKNOWN", new b(0)), /** 128 bits per value. */
966
- u(b, "BIT128", new b(16)), /** 64 bits per value. */
967
- u(b, "BIT64", new b(8)), /** 32 bits per value. */
968
- u(b, "BIT32", new b(4)), /** 16 bits per value. */
969
- u(b, "BIT16", new b(2)), /** 8 bits per value. */
970
- u(b, "BIT8", new b(1)), /** A zod schema for validating and transforming densities */
971
- u(b, "z", s.union([
972
- s.number().transform((r) => new b(r)),
973
- s.instanceof(Number).transform((r) => new b(r)),
974
- s.instanceof(b)
998
+ u(I, "UNKNOWN", new I(0)), /** 128 bits per value. */
999
+ u(I, "BIT128", new I(16)), /** 64 bits per value. */
1000
+ u(I, "BIT64", new I(8)), /** 32 bits per value. */
1001
+ u(I, "BIT32", new I(4)), /** 16 bits per value. */
1002
+ u(I, "BIT16", new I(2)), /** 8 bits per value. */
1003
+ u(I, "BIT8", new I(1)), /** A zod schema for validating and transforming densities */
1004
+ u(I, "z", i.union([
1005
+ i.number().transform((r) => new I(r)),
1006
+ i.instanceof(Number).transform((r) => new I(r)),
1007
+ i.instanceof(I)
975
1008
  ]));
976
- let N = b;
977
- const $ = class H {
1009
+ let A = I;
1010
+ const M = class te {
978
1011
  /**
979
1012
  * Creates a TimeRange from the given start and end TimeStamps.
980
1013
  *
@@ -982,7 +1015,7 @@ const $ = class H {
982
1015
  * @param end - A TimeStamp representing the end of the range.
983
1016
  */
984
1017
  constructor(e, t) {
985
- u(this, "start"), u(this, "end"), typeof e == "object" && "start" in e ? (this.start = new T(e.start), this.end = new T(e.end)) : (this.start = new T(e), this.end = new T(t));
1018
+ u(this, "start"), u(this, "end"), typeof e == "object" && "start" in e ? (this.start = new O(e.start), this.end = new O(e.end)) : (this.start = new O(e), this.end = new O(t));
986
1019
  }
987
1020
  /** @returns The TimeSpan occupied by the TimeRange. */
988
1021
  get span() {
@@ -1024,7 +1057,7 @@ const $ = class H {
1024
1057
  * @returns A TimeRange with the start and end swapped.
1025
1058
  */
1026
1059
  swap() {
1027
- return new H(this.end, this.start);
1060
+ return new te(this.end, this.start);
1028
1061
  }
1029
1062
  /**
1030
1063
  * Checks if the TimeRange is equal to the given TimeRange.
@@ -1054,48 +1087,48 @@ const $ = class H {
1054
1087
  const n = this.makeValid();
1055
1088
  if (this.equals(e)) return !0;
1056
1089
  if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1057
- const i = T.max(n.start, e.start), a = T.min(n.end, e.end);
1058
- return a.before(i) ? !1 : new S(a.sub(i)).greaterThanOrEqual(t);
1090
+ const s = O.max(n.start, e.start), a = O.min(n.end, e.end);
1091
+ return a.before(s) ? !1 : new S(a.sub(s)).greaterThanOrEqual(t);
1059
1092
  }
1060
1093
  roughlyEquals(e, t) {
1061
- let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1062
- return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
1094
+ let n = this.start.sub(e.start).valueOf(), s = this.end.sub(e.end).valueOf();
1095
+ return n < 0 && (n = -n), s < 0 && (s = -s), n <= t.valueOf() && s <= t.valueOf();
1063
1096
  }
1064
1097
  contains(e) {
1065
- return e instanceof H ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1098
+ return e instanceof te ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1066
1099
  }
1067
1100
  boundBy(e) {
1068
- const t = new H(this.start, this.end);
1101
+ const t = new te(this.start, this.end);
1069
1102
  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;
1070
1103
  }
1071
1104
  };
1072
- u($, "MAX", new $(T.MIN, T.MAX)), /** The minimum possible time range. */
1073
- u($, "MIN", new $(T.MAX, T.MIN)), /** A zero time range. */
1074
- u($, "ZERO", new $(T.ZERO, T.ZERO)), /** A zod schema for validating and transforming time ranges */
1075
- u($, "z", s.union([
1076
- s.object({ start: T.z, end: T.z }).transform((r) => new $(r.start, r.end)),
1077
- s.instanceof($)
1105
+ u(M, "MAX", new M(O.MIN, O.MAX)), /** The minimum possible time range. */
1106
+ u(M, "MIN", new M(O.MAX, O.MIN)), /** A zero time range. */
1107
+ u(M, "ZERO", new M(O.ZERO, O.ZERO)), /** A zod schema for validating and transforming time ranges */
1108
+ u(M, "z", i.union([
1109
+ i.object({ start: O.z, end: O.z }).transform((r) => new M(r.start, r.end)),
1110
+ i.instanceof(M)
1078
1111
  ]));
1079
- let Ct = $;
1080
- const o = class x extends String {
1112
+ let me = M;
1113
+ const o = class $ extends String {
1081
1114
  constructor(e) {
1082
- if (e instanceof x || typeof e == "string" || typeof e.valueOf() == "string") {
1115
+ if (e instanceof $ || typeof e == "string" || typeof e.valueOf() == "string") {
1083
1116
  super(e.valueOf());
1084
1117
  return;
1085
1118
  } else {
1086
- const t = x.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1119
+ const t = $.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1087
1120
  if (t != null) {
1088
1121
  super(t.valueOf());
1089
1122
  return;
1090
1123
  }
1091
1124
  }
1092
- throw super(x.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
1125
+ throw super($.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
1093
1126
  }
1094
1127
  /**
1095
1128
  * @returns the TypedArray constructor for the DataType.
1096
1129
  */
1097
1130
  get Array() {
1098
- const e = x.ARRAY_CONSTRUCTORS.get(this.toString());
1131
+ const e = $.ARRAY_CONSTRUCTORS.get(this.toString());
1099
1132
  if (e == null)
1100
1133
  throw new Error(`unable to find array constructor for ${this.valueOf()}`);
1101
1134
  return e;
@@ -1117,10 +1150,10 @@ const o = class x extends String {
1117
1150
  return this.valueOf();
1118
1151
  }
1119
1152
  get isVariable() {
1120
- return this.equals(x.JSON) || this.equals(x.STRING);
1153
+ return this.equals($.JSON) || this.equals($.STRING);
1121
1154
  }
1122
1155
  get isNumeric() {
1123
- return !this.isVariable && !this.equals(x.UUID);
1156
+ return !this.isVariable && !this.equals($.UUID);
1124
1157
  }
1125
1158
  get isInteger() {
1126
1159
  return this.toString().startsWith("int");
@@ -1129,7 +1162,7 @@ const o = class x extends String {
1129
1162
  return this.toString().startsWith("float");
1130
1163
  }
1131
1164
  get density() {
1132
- const e = x.DENSITIES.get(this.toString());
1165
+ const e = $.DENSITIES.get(this.toString());
1133
1166
  if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
1134
1167
  return e;
1135
1168
  }
@@ -1154,7 +1187,7 @@ const o = class x extends String {
1154
1187
  return this.toString();
1155
1188
  }
1156
1189
  get usesBigInt() {
1157
- return x.BIG_INT_TYPES.some((e) => e.equals(this));
1190
+ return $.BIG_INT_TYPES.some((e) => e.equals(this));
1158
1191
  }
1159
1192
  };
1160
1193
  u(o, "UNKNOWN", new o("unknown")), /** Represents a 64-bit floating point value. */
@@ -1201,20 +1234,20 @@ u(o, "JSON", new o("json")), u(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
1201
1234
  [Int32Array.name, o.INT32],
1202
1235
  [BigInt64Array.name, o.INT64]
1203
1236
  ])), u(o, "DENSITIES", /* @__PURE__ */ new Map([
1204
- [o.UINT8.toString(), N.BIT8],
1205
- [o.UINT16.toString(), N.BIT16],
1206
- [o.UINT32.toString(), N.BIT32],
1207
- [o.UINT64.toString(), N.BIT64],
1208
- [o.FLOAT32.toString(), N.BIT32],
1209
- [o.FLOAT64.toString(), N.BIT64],
1210
- [o.INT8.toString(), N.BIT8],
1211
- [o.INT16.toString(), N.BIT16],
1212
- [o.INT32.toString(), N.BIT32],
1213
- [o.INT64.toString(), N.BIT64],
1214
- [o.TIMESTAMP.toString(), N.BIT64],
1215
- [o.STRING.toString(), N.UNKNOWN],
1216
- [o.JSON.toString(), N.UNKNOWN],
1217
- [o.UUID.toString(), N.BIT128]
1237
+ [o.UINT8.toString(), A.BIT8],
1238
+ [o.UINT16.toString(), A.BIT16],
1239
+ [o.UINT32.toString(), A.BIT32],
1240
+ [o.UINT64.toString(), A.BIT64],
1241
+ [o.FLOAT32.toString(), A.BIT32],
1242
+ [o.FLOAT64.toString(), A.BIT64],
1243
+ [o.INT8.toString(), A.BIT8],
1244
+ [o.INT16.toString(), A.BIT16],
1245
+ [o.INT32.toString(), A.BIT32],
1246
+ [o.INT64.toString(), A.BIT64],
1247
+ [o.TIMESTAMP.toString(), A.BIT64],
1248
+ [o.STRING.toString(), A.UNKNOWN],
1249
+ [o.JSON.toString(), A.UNKNOWN],
1250
+ [o.UUID.toString(), A.BIT128]
1218
1251
  ])), /** All the data types. */
1219
1252
  u(o, "ALL", [
1220
1253
  o.UNKNOWN,
@@ -1233,11 +1266,12 @@ u(o, "ALL", [
1233
1266
  o.STRING,
1234
1267
  o.JSON
1235
1268
  ]), u(o, "BIG_INT_TYPES", [o.INT64, o.UINT64, o.TIMESTAMP]), /** A zod schema for a DataType. */
1236
- u(o, "z", s.union([
1237
- s.string().transform((r) => new o(r)),
1238
- s.instanceof(o)
1269
+ u(o, "z", i.union([
1270
+ i.string().transform((r) => new o(r)),
1271
+ i.instanceof(o)
1239
1272
  ]));
1240
- const I = class v extends Number {
1273
+ let b = o;
1274
+ const N = class v extends Number {
1241
1275
  constructor(e) {
1242
1276
  super(e.valueOf());
1243
1277
  }
@@ -1274,9 +1308,9 @@ const I = class v extends Number {
1274
1308
  return this.valueOf() / v.TERABYTE.valueOf();
1275
1309
  }
1276
1310
  toString() {
1277
- const e = this.truncate(v.TERABYTE), t = this.truncate(v.GIGABYTE), n = this.truncate(v.MEGABYTE), i = this.truncate(v.KILOBYTE), a = this.truncate(v.BYTE), c = e, h = t.sub(e), g = n.sub(t), m = i.sub(n), O = a.sub(i);
1278
- let w = "";
1279
- return c.isZero || (w += `${c.terabytes}TB `), h.isZero || (w += `${h.gigabytes}GB `), g.isZero || (w += `${g.megabytes}MB `), m.isZero || (w += `${m.kilobytes}KB `), (!O.isZero || w === "") && (w += `${O.valueOf()}B`), w.trim();
1311
+ const e = this.truncate(v.TERABYTE), t = this.truncate(v.GIGABYTE), n = this.truncate(v.MEGABYTE), s = this.truncate(v.KILOBYTE), a = this.truncate(v.BYTE), c = e, d = t.sub(e), f = n.sub(t), y = s.sub(n), T = a.sub(s);
1312
+ let l = "";
1313
+ return c.isZero || (l += `${c.terabytes}TB `), d.isZero || (l += `${d.gigabytes}GB `), f.isZero || (l += `${f.megabytes}MB `), y.isZero || (l += `${y.kilobytes}KB `), (!T.isZero || l === "") && (l += `${T.valueOf()}B`), l.trim();
1280
1314
  }
1281
1315
  /**
1282
1316
  * Creates a Size from the given number of bytes.
@@ -1327,66 +1361,543 @@ const I = class v extends Number {
1327
1361
  return this.valueOf() === 0;
1328
1362
  }
1329
1363
  };
1330
- u(I, "BYTE", new I(1)), /** A kilobyte */
1331
- u(I, "KILOBYTE", I.kilobytes(1)), /** A megabyte */
1332
- u(I, "MEGABYTE", I.megabytes(1)), /** A gigabyte */
1333
- u(I, "GIGABYTE", I.gigabytes(1)), /** A terabyte. */
1334
- u(I, "TERABYTE", I.terabytes(1)), /** The zero value for Size */
1335
- u(I, "ZERO", new I(0)), /** A zod schema for a Size. */
1336
- u(I, "z", s.union([
1337
- s.number().transform((r) => new I(r)),
1338
- s.instanceof(I)
1364
+ u(N, "BYTE", new N(1)), /** A kilobyte */
1365
+ u(N, "KILOBYTE", N.kilobytes(1)), /** A megabyte */
1366
+ u(N, "MEGABYTE", N.megabytes(1)), /** A gigabyte */
1367
+ u(N, "GIGABYTE", N.gigabytes(1)), /** A terabyte. */
1368
+ u(N, "TERABYTE", N.terabytes(1)), /** The zero value for Size */
1369
+ u(N, "ZERO", new N(0)), /** A zod schema for a Size. */
1370
+ u(N, "z", i.union([
1371
+ i.number().transform((r) => new N(r)),
1372
+ i.instanceof(N)
1339
1373
  ]));
1340
- let Bt = I;
1341
- s.union([
1342
- s.instanceof(Uint8Array),
1343
- s.instanceof(Uint16Array),
1344
- s.instanceof(Uint32Array),
1345
- s.instanceof(BigUint64Array),
1346
- s.instanceof(Float32Array),
1347
- s.instanceof(Float64Array),
1348
- s.instanceof(Int8Array),
1349
- s.instanceof(Int16Array),
1350
- s.instanceof(Int32Array),
1351
- s.instanceof(BigInt64Array)
1374
+ let Je = N;
1375
+ i.union([
1376
+ i.instanceof(Uint8Array),
1377
+ i.instanceof(Uint16Array),
1378
+ i.instanceof(Uint32Array),
1379
+ i.instanceof(BigUint64Array),
1380
+ i.instanceof(Float32Array),
1381
+ i.instanceof(Float64Array),
1382
+ i.instanceof(Int8Array),
1383
+ i.instanceof(Int16Array),
1384
+ i.instanceof(Int32Array),
1385
+ i.instanceof(BigInt64Array)
1352
1386
  ]);
1353
- s.object({
1354
- key: s.string(),
1355
- value: s.string()
1387
+ const He = (r) => {
1388
+ const e = typeof r;
1389
+ return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof O || r instanceof S || r instanceof Date;
1390
+ }, _t = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t) - BigInt(n) : Z(t, -n), er = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof nr ? !0 : He(r), Y = -1, tr = i.string().transform(
1391
+ (r) => new Uint8Array(
1392
+ atob(r).split("").map((e) => e.charCodeAt(0))
1393
+ ).buffer
1394
+ ), rr = i.union([i.null(), i.undefined()]).transform(() => new Uint8Array().buffer), z = class C {
1395
+ constructor(e) {
1396
+ u(this, "key", ""), u(this, "isSynnaxSeries", !0), u(this, "dataType"), u(this, "sampleOffset"), u(this, "gl"), u(this, "_data"), u(this, "_timeRange"), u(this, "alignment", 0n), u(this, "_cachedMin"), u(this, "_cachedMax"), u(this, "writePos", Y), u(this, "_refCount", 0), u(this, "_cachedLength"), er(e) && (e = { data: e });
1397
+ const {
1398
+ dataType: t,
1399
+ timeRange: n,
1400
+ sampleOffset: s = 0,
1401
+ glBufferUsage: a = "static",
1402
+ alignment: c = 0n,
1403
+ key: d = Xt()
1404
+ } = e, f = e.data ?? [];
1405
+ if (f instanceof C || typeof f == "object" && "isSynnaxSeries" in f && f.isSynnaxSeries === !0) {
1406
+ const l = f;
1407
+ this.key = l.key, this.dataType = l.dataType, this.sampleOffset = l.sampleOffset, this.gl = l.gl, this._data = l._data, this._timeRange = l._timeRange, this.alignment = l.alignment, this._cachedMin = l._cachedMin, this._cachedMax = l._cachedMax, this.writePos = l.writePos, this._refCount = l._refCount, this._cachedLength = l._cachedLength;
1408
+ return;
1409
+ }
1410
+ const y = He(f), T = Array.isArray(f);
1411
+ if (t != null) this.dataType = new b(t);
1412
+ else {
1413
+ if (f instanceof ArrayBuffer)
1414
+ throw new Error(
1415
+ "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
1416
+ );
1417
+ if (T || y) {
1418
+ let l = f;
1419
+ if (!y) {
1420
+ if (f.length === 0)
1421
+ throw new Error(
1422
+ "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
1423
+ );
1424
+ l = f[0];
1425
+ }
1426
+ if (typeof l == "string") this.dataType = b.STRING;
1427
+ else if (typeof l == "number") this.dataType = b.FLOAT64;
1428
+ else if (typeof l == "bigint") this.dataType = b.INT64;
1429
+ else if (typeof l == "boolean") this.dataType = b.BOOLEAN;
1430
+ else if (l instanceof O || l instanceof Date || l instanceof O)
1431
+ this.dataType = b.TIMESTAMP;
1432
+ else if (typeof l == "object") this.dataType = b.JSON;
1433
+ else
1434
+ throw new Error(
1435
+ `cannot infer data type of ${typeof l} when constructing a Series from a JS array`
1436
+ );
1437
+ } else this.dataType = new b(f);
1438
+ }
1439
+ if (!T && !y) this._data = f;
1440
+ else {
1441
+ let l = y ? [f] : f;
1442
+ const E = l[0];
1443
+ (E instanceof O || E instanceof Date || E instanceof S) && (l = l.map((R) => new O(R).valueOf())), this.dataType.equals(b.STRING) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(l.join(`
1444
+ `) + `
1445
+ `)) : this.dataType.equals(b.JSON) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(
1446
+ l.map((R) => _.encodeString(R)).join(`
1447
+ `) + `
1448
+ `
1449
+ )) : this._data = new this.dataType.Array(l).buffer;
1450
+ }
1451
+ this.key = d, this.alignment = c, this.sampleOffset = s ?? 0, this._timeRange = n, this.gl = {
1452
+ control: null,
1453
+ buffer: null,
1454
+ prevBuffer: 0,
1455
+ bufferUsage: a
1456
+ };
1457
+ }
1458
+ static alloc({ capacity: e, dataType: t, ...n }) {
1459
+ if (e === 0)
1460
+ throw new Error("[Series] - cannot allocate an array of length 0");
1461
+ const s = new new b(t).Array(e), a = new C({
1462
+ data: s.buffer,
1463
+ dataType: t,
1464
+ ...n
1465
+ });
1466
+ return a.writePos = 0, a;
1467
+ }
1468
+ static generateTimestamps(e, t, n) {
1469
+ const s = n.spanRange(t.span(e)), a = new BigInt64Array(e);
1470
+ for (let c = 0; c < e; c++)
1471
+ a[c] = BigInt(n.add(t.span(c)).valueOf());
1472
+ return new C({ data: a, dataType: b.TIMESTAMP, timeRange: s });
1473
+ }
1474
+ get refCount() {
1475
+ return this._refCount;
1476
+ }
1477
+ static fromStrings(e, t) {
1478
+ const n = new TextEncoder().encode(e.join(`
1479
+ `) + `
1480
+ `);
1481
+ return new C({ data: n, dataType: b.STRING, timeRange: t });
1482
+ }
1483
+ static fromJSON(e, t) {
1484
+ const n = new TextEncoder().encode(
1485
+ e.map((s) => _.encodeString(s)).join(`
1486
+ `) + `
1487
+ `
1488
+ );
1489
+ return new C({ data: n, dataType: b.JSON, timeRange: t });
1490
+ }
1491
+ acquire(e) {
1492
+ this._refCount++, e != null && this.updateGLBuffer(e);
1493
+ }
1494
+ release() {
1495
+ if (this._refCount--, this._refCount === 0 && this.gl.control != null)
1496
+ this.maybeGarbageCollectGLBuffer(this.gl.control);
1497
+ else if (this._refCount < 0)
1498
+ throw new Error("cannot release an array with a negative reference count");
1499
+ }
1500
+ /**
1501
+ * Writes the given series to this series. If the series being written exceeds the
1502
+ * remaining of series being written to, only the portion that fits will be written.
1503
+ * @param other the series to write to this series. The data type of the series written
1504
+ * must be the same as the data type of the series being written to.
1505
+ * @returns the number of samples written. If the entire series fits, this value is
1506
+ * equal to the length of the series being written.
1507
+ */
1508
+ write(e) {
1509
+ if (!e.dataType.equals(this.dataType))
1510
+ throw new Error("buffer must be of the same type as this array");
1511
+ if (this.writePos === Y) return 0;
1512
+ const t = this.capacity - this.writePos, n = t < e.length ? e.slice(0, t) : e;
1513
+ return this.underlyingData.set(
1514
+ n.data,
1515
+ this.writePos
1516
+ ), this.maybeRecomputeMinMax(n), this._cachedLength = void 0, this.writePos += n.length, n.length;
1517
+ }
1518
+ /** @returns the underlying buffer backing this array. */
1519
+ get buffer() {
1520
+ return this._data;
1521
+ }
1522
+ get underlyingData() {
1523
+ return new this.dataType.Array(this._data);
1524
+ }
1525
+ /** @returns a native typed array with the proper data type. */
1526
+ get data() {
1527
+ return this.writePos === Y ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1528
+ }
1529
+ toStrings() {
1530
+ if (!this.dataType.matches(b.STRING, b.UUID))
1531
+ throw new Error("cannot convert non-string series to strings");
1532
+ return new TextDecoder().decode(this.buffer).split(`
1533
+ `).slice(0, -1);
1534
+ }
1535
+ toUUIDs() {
1536
+ if (!this.dataType.equals(b.UUID))
1537
+ throw new Error("cannot convert non-uuid series to uuids");
1538
+ const e = b.UUID.density.valueOf(), t = Array(this.length);
1539
+ for (let n = 0; n < this.length; n++) {
1540
+ const s = this.buffer.slice(n * e, (n + 1) * e), a = Array.from(new Uint8Array(s), (c) => c.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1541
+ t[n] = a;
1542
+ }
1543
+ return t;
1544
+ }
1545
+ parseJSON(e) {
1546
+ if (!this.dataType.equals(b.JSON))
1547
+ throw new Error("cannot convert non-string series to strings");
1548
+ return new TextDecoder().decode(this.buffer).split(`
1549
+ `).slice(0, -1).map((t) => e.parse(_.decodeString(t)));
1550
+ }
1551
+ /** @returns the time range of this array. */
1552
+ get timeRange() {
1553
+ if (this._timeRange == null) throw new Error("time range not set on series");
1554
+ return this._timeRange;
1555
+ }
1556
+ /** @returns the capacity of the series in bytes. */
1557
+ get byteCapacity() {
1558
+ return new Je(this.buffer.byteLength);
1559
+ }
1560
+ /** @returns the capacity of the series in samples. */
1561
+ get capacity() {
1562
+ return this.dataType.density.length(this.byteCapacity);
1563
+ }
1564
+ /** @returns the length of the series in bytes. */
1565
+ get byteLength() {
1566
+ return this.writePos === Y ? this.byteCapacity : this.dataType.density.size(this.writePos);
1567
+ }
1568
+ /** @returns the number of samples in this array. */
1569
+ get length() {
1570
+ return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === Y ? this.data.length : this.writePos;
1571
+ }
1572
+ calculateCachedLength() {
1573
+ if (!this.dataType.isVariable)
1574
+ throw new Error("cannot calculate length of a non-variable length data type");
1575
+ let e = 0;
1576
+ return this.data.forEach((t) => {
1577
+ t === 10 && e++;
1578
+ }), this._cachedLength = e, e;
1579
+ }
1580
+ /**
1581
+ * Creates a new array with a different data type.
1582
+ * @param target the data type to convert to.
1583
+ * @param sampleOffset an offset to apply to each sample. This can help with precision
1584
+ * issues when converting between data types.
1585
+ *
1586
+ * WARNING: This method is expensive and copies the entire underlying array. There
1587
+ * also may be untimely precision issues when converting between data types.
1588
+ */
1589
+ convert(e, t = 0) {
1590
+ if (this.dataType.equals(e)) return this;
1591
+ const n = new e.Array(this.length);
1592
+ for (let s = 0; s < this.length; s++)
1593
+ n[s] = _t(this.dataType, e, this.data[s], t);
1594
+ return new C({
1595
+ data: n.buffer,
1596
+ dataType: e,
1597
+ timeRange: this._timeRange,
1598
+ sampleOffset: t,
1599
+ glBufferUsage: this.gl.bufferUsage,
1600
+ alignment: this.alignment
1601
+ });
1602
+ }
1603
+ calcRawMax() {
1604
+ if (this.length === 0) return -1 / 0;
1605
+ if (this.dataType.equals(b.TIMESTAMP))
1606
+ this._cachedMax = this.data[this.data.length - 1];
1607
+ else if (this.dataType.usesBigInt) {
1608
+ const e = this.data;
1609
+ this._cachedMax = e.reduce((t, n) => t > n ? t : n);
1610
+ } else {
1611
+ const e = this.data;
1612
+ this._cachedMax = e.reduce((t, n) => t > n ? t : n);
1613
+ }
1614
+ return this._cachedMax;
1615
+ }
1616
+ /** @returns the maximum value in the array */
1617
+ get max() {
1618
+ if (this.dataType.isVariable)
1619
+ throw new Error("cannot calculate maximum on a variable length data type");
1620
+ return this.writePos === 0 ? -1 / 0 : (this._cachedMax == null && (this._cachedMax = this.calcRawMax()), Z(this._cachedMax, this.sampleOffset));
1621
+ }
1622
+ calcRawMin() {
1623
+ if (this.length === 0) return 1 / 0;
1624
+ if (this.dataType.equals(b.TIMESTAMP))
1625
+ this._cachedMin = this.data[0];
1626
+ else if (this.dataType.usesBigInt) {
1627
+ const e = this.data;
1628
+ this._cachedMin = e.reduce((t, n) => t < n ? t : n);
1629
+ } else {
1630
+ const e = this.data;
1631
+ this._cachedMin = e.reduce((t, n) => t < n ? t : n);
1632
+ }
1633
+ return this._cachedMin;
1634
+ }
1635
+ /** @returns the minimum value in the array */
1636
+ get min() {
1637
+ if (this.dataType.isVariable)
1638
+ throw new Error("cannot calculate minimum on a variable length data type");
1639
+ return this.writePos === 0 ? 1 / 0 : (this._cachedMin == null && (this._cachedMin = this.calcRawMin()), Z(this._cachedMin, this.sampleOffset));
1640
+ }
1641
+ /** @returns the bounds of this array. */
1642
+ get bounds() {
1643
+ return K(Number(this.min), Number(this.max));
1644
+ }
1645
+ maybeRecomputeMinMax(e) {
1646
+ if (this._cachedMin != null) {
1647
+ const t = e._cachedMin ?? e.calcRawMin();
1648
+ t < this._cachedMin && (this._cachedMin = t);
1649
+ }
1650
+ if (this._cachedMax != null) {
1651
+ const t = e._cachedMax ?? e.calcRawMax();
1652
+ t > this._cachedMax && (this._cachedMax = t);
1653
+ }
1654
+ }
1655
+ enrich() {
1656
+ this.max, this.min;
1657
+ }
1658
+ get range() {
1659
+ return Z(this.max, -this.min);
1660
+ }
1661
+ at(e, t) {
1662
+ if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
1663
+ e < 0 && (e = this.length + e);
1664
+ const n = this.data[e];
1665
+ if (n == null) {
1666
+ if (t === !0) throw new Error(`[series] - no value at index ${e}`);
1667
+ return;
1668
+ }
1669
+ return Z(n, this.sampleOffset);
1670
+ }
1671
+ atVariable(e, t) {
1672
+ e < 0 && (e = this.length + e);
1673
+ let n = 0, s = 0;
1674
+ for (let c = 0; c < this.data.length; c++)
1675
+ if (this.data[c] === 10) {
1676
+ if (e === 0) {
1677
+ s = c;
1678
+ break;
1679
+ }
1680
+ n = c + 1, e--;
1681
+ }
1682
+ if (s === 0 && (s = this.data.length), n >= s || e > 0) {
1683
+ if (t) throw new Error(`[series] - no value at index ${e}`);
1684
+ return;
1685
+ }
1686
+ const a = this.data.slice(n, s);
1687
+ return this.dataType.equals(b.STRING) ? new TextDecoder().decode(a) : Ye(
1688
+ JSON.parse(new TextDecoder().decode(a))
1689
+ );
1690
+ }
1691
+ /**
1692
+ * @returns the index of the first sample that is greater than or equal to the given value.
1693
+ * The underlying array must be sorted. If it is not, the behavior of this method is undefined.
1694
+ * @param value the value to search for.
1695
+ */
1696
+ binarySearch(e) {
1697
+ let t = 0, n = this.length - 1;
1698
+ const s = qt(e);
1699
+ for (; t <= n; ) {
1700
+ const a = Math.floor((t + n) / 2), c = s(this.at(a, !0), e);
1701
+ if (c === 0) return a;
1702
+ c < 0 ? t = a + 1 : n = a - 1;
1703
+ }
1704
+ return t;
1705
+ }
1706
+ updateGLBuffer(e) {
1707
+ if (this.gl.control = e, !this.dataType.equals(b.FLOAT32))
1708
+ throw new Error("Only FLOAT32 arrays can be used in WebGL");
1709
+ const { buffer: t, bufferUsage: n, prevBuffer: s } = this.gl;
1710
+ if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== s)
1711
+ if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== Y) {
1712
+ s === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
1713
+ const a = this.dataType.density.size(s).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1714
+ e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
1715
+ } else
1716
+ e.bufferData(
1717
+ e.ARRAY_BUFFER,
1718
+ this.buffer,
1719
+ n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
1720
+ ), this.gl.prevBuffer = Y;
1721
+ }
1722
+ as(e) {
1723
+ if (e === "string") {
1724
+ if (!this.dataType.equals(b.STRING))
1725
+ throw new Error(
1726
+ `cannot convert series of type ${this.dataType.toString()} to string`
1727
+ );
1728
+ return this;
1729
+ }
1730
+ if (e === "number") {
1731
+ if (!this.dataType.isNumeric)
1732
+ throw new Error(
1733
+ `cannot convert series of type ${this.dataType.toString()} to number`
1734
+ );
1735
+ return this;
1736
+ }
1737
+ if (e === "bigint") {
1738
+ if (!this.dataType.equals(b.INT64))
1739
+ throw new Error(
1740
+ `cannot convert series of type ${this.dataType.toString()} to bigint`
1741
+ );
1742
+ return this;
1743
+ }
1744
+ throw new Error(`cannot convert series to ${e}`);
1745
+ }
1746
+ get digest() {
1747
+ var e;
1748
+ return {
1749
+ key: this.key,
1750
+ dataType: this.dataType.toString(),
1751
+ sampleOffset: this.sampleOffset,
1752
+ alignment: this.alignmentBounds,
1753
+ timeRange: (e = this._timeRange) == null ? void 0 : e.toString(),
1754
+ length: this.length,
1755
+ capacity: this.capacity
1756
+ };
1757
+ }
1758
+ get memInfo() {
1759
+ return {
1760
+ key: this.key,
1761
+ length: this.length,
1762
+ byteLength: this.byteLength,
1763
+ glBuffer: this.gl.buffer != null
1764
+ };
1765
+ }
1766
+ get alignmentBounds() {
1767
+ return K(this.alignment, this.alignment + BigInt(this.length));
1768
+ }
1769
+ maybeGarbageCollectGLBuffer(e) {
1770
+ this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
1771
+ }
1772
+ get glBuffer() {
1773
+ if (this.gl.buffer == null) throw new Error("gl buffer not initialized");
1774
+ return this.gl.prevBuffer !== this.writePos && console.warn("buffer not updated"), this.gl.buffer;
1775
+ }
1776
+ [Symbol.iterator]() {
1777
+ if (this.dataType.isVariable) {
1778
+ const e = new sr(this);
1779
+ return this.dataType.equals(b.JSON) ? new ir(e) : e;
1780
+ }
1781
+ return new ar(this);
1782
+ }
1783
+ slice(e, t) {
1784
+ if (e <= 0 && (t == null || t >= this.length)) return this;
1785
+ const n = this.data.slice(e, t);
1786
+ return new C({
1787
+ data: n,
1788
+ dataType: this.dataType,
1789
+ timeRange: this._timeRange,
1790
+ sampleOffset: this.sampleOffset,
1791
+ glBufferUsage: this.gl.bufferUsage,
1792
+ alignment: this.alignment + BigInt(e)
1793
+ });
1794
+ }
1795
+ reAlign(e) {
1796
+ return new C({
1797
+ data: this.buffer,
1798
+ dataType: this.dataType,
1799
+ timeRange: me.ZERO,
1800
+ sampleOffset: this.sampleOffset,
1801
+ glBufferUsage: "static",
1802
+ alignment: e
1803
+ });
1804
+ }
1805
+ };
1806
+ u(z, "crudeZ", i.object({
1807
+ timeRange: me.z.optional(),
1808
+ dataType: b.z,
1809
+ alignment: Zt.optional(),
1810
+ data: i.union([tr, rr, i.instanceof(ArrayBuffer)]),
1811
+ glBufferUsage: Qt.optional().default("static").optional()
1812
+ })), u(z, "z", z.crudeZ.transform((r) => new z(r)));
1813
+ let nr = z;
1814
+ class sr {
1815
+ constructor(e) {
1816
+ if (u(this, "series"), u(this, "index"), u(this, "decoder"), !e.dataType.isVariable)
1817
+ throw new Error(
1818
+ "cannot create a variable series iterator for a non-variable series"
1819
+ );
1820
+ this.series = e, this.index = 0, this.decoder = new TextDecoder();
1821
+ }
1822
+ next() {
1823
+ const e = this.index, t = this.series.data;
1824
+ for (; this.index < t.length && t[this.index] !== 10; ) this.index++;
1825
+ const n = this.index;
1826
+ return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
1827
+ }
1828
+ [Symbol.iterator]() {
1829
+ return this;
1830
+ }
1831
+ }
1832
+ var xe, Me;
1833
+ class ir {
1834
+ constructor(e) {
1835
+ u(this, "wrapped"), u(this, xe, "JSONSeriesIterator"), this.wrapped = e;
1836
+ }
1837
+ next() {
1838
+ const e = this.wrapped.next();
1839
+ return e.done === !0 ? { done: !0, value: void 0 } : {
1840
+ done: !1,
1841
+ value: _.decodeString(e.value)
1842
+ };
1843
+ }
1844
+ [(Me = Symbol.iterator, xe = Symbol.toStringTag, Me)]() {
1845
+ return this;
1846
+ }
1847
+ }
1848
+ var $e, Re;
1849
+ class ar {
1850
+ constructor(e) {
1851
+ u(this, "series"), u(this, "index"), u(this, $e, "SeriesIterator"), this.series = e, this.index = 0;
1852
+ }
1853
+ next() {
1854
+ return this.index >= this.series.length ? { done: !0, value: void 0 } : {
1855
+ done: !1,
1856
+ value: this.series.at(this.index++, !0)
1857
+ };
1858
+ }
1859
+ [(Re = Symbol.iterator, $e = Symbol.toStringTag, Re)]() {
1860
+ return this;
1861
+ }
1862
+ }
1863
+ const Z = (r, e) => typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : e === 0 ? r : r === 0 ? e : Number(r) + Number(e);
1864
+ i.object({
1865
+ key: i.string(),
1866
+ value: i.string()
1356
1867
  });
1357
- s.record(
1358
- s.union([s.number(), s.string(), s.symbol()]),
1359
- s.unknown()
1868
+ i.record(
1869
+ i.union([i.number(), i.string(), i.symbol()]),
1870
+ i.unknown()
1360
1871
  );
1361
- const Ye = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", Rt = Ye(), Le = ["MacOS", "Windows", "Linux", "Docker"], Dt = s.enum(Le);
1362
- let ie;
1363
- const Yt = () => {
1872
+ const Ke = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", or = Ke(), Xe = ["MacOS", "Windows", "Linux", "Docker"], ur = i.enum(Xe);
1873
+ let he;
1874
+ const cr = () => {
1364
1875
  if (typeof window > "u") return;
1365
1876
  const r = window.navigator.userAgent.toLowerCase();
1366
1877
  if (r.includes("mac")) return "MacOS";
1367
1878
  if (r.includes("win")) return "Windows";
1368
1879
  if (r.includes("linux")) return "Linux";
1369
- }, Lt = (r = {}) => {
1880
+ }, lr = (r = {}) => {
1370
1881
  const { force: e, default: t } = r;
1371
- return e ?? ie ?? (ie = Yt(), ie ?? t);
1372
- }, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1882
+ return e ?? he ?? (he = cr(), he ?? t);
1883
+ }, Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1373
1884
  __proto__: null,
1374
- OPERATING_SYSTEMS: Le,
1375
- RUNTIME: Rt,
1376
- detect: Ye,
1377
- getOS: Lt,
1378
- osZ: Dt
1885
+ OPERATING_SYSTEMS: Xe,
1886
+ RUNTIME: or,
1887
+ detect: Ke,
1888
+ getOS: lr,
1889
+ osZ: ur
1379
1890
  }, Symbol.toStringTag, { value: "Module" }));
1380
- var Pt = Object.defineProperty, jt = (r, e, t) => e in r ? Pt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, F = (r, e, t) => jt(r, typeof e != "symbol" ? e + "" : e, t);
1381
- const kt = (...r) => r.map(je).join(""), je = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Wt = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Ft = (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("&"), ue = class ce {
1891
+ var hr = Object.defineProperty, dr = (r, e, t) => e in r ? hr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, V = (r, e, t) => dr(r, typeof e != "symbol" ? e + "" : e, t);
1892
+ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), gr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, pr = (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("&"), ge = class pe {
1382
1893
  /**
1383
1894
  * @param host - The hostname or IP address of the server.
1384
1895
  * @param port - The port number of the server.
1385
1896
  * @param protocol - The protocol to use for all requests. Defaults to "".
1386
1897
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
1387
1898
  */
1388
- constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
1389
- F(this, "protocol"), F(this, "host"), F(this, "port"), F(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = je(i);
1899
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: s = "" }) {
1900
+ V(this, "protocol"), V(this, "host"), V(this, "port"), V(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = _e(s);
1390
1901
  }
1391
1902
  /**
1392
1903
  * Replaces creates a new URL with the specified properties replaced.
@@ -1394,7 +1905,7 @@ const kt = (...r) => r.map(je).join(""), je = (r) => (r.endsWith("/") || (r += "
1394
1905
  * @returns a new URL.
1395
1906
  */
1396
1907
  replace(e) {
1397
- return new ce({
1908
+ return new pe({
1398
1909
  host: e.host ?? this.host,
1399
1910
  port: e.port ?? this.port,
1400
1911
  protocol: e.protocol ?? this.protocol,
@@ -1407,54 +1918,54 @@ const kt = (...r) => r.map(je).join(""), je = (r) => (r.endsWith("/") || (r += "
1407
1918
  * @returns a new URL.
1408
1919
  */
1409
1920
  child(e) {
1410
- return new ce({
1921
+ return new pe({
1411
1922
  ...this,
1412
- pathPrefix: kt(this.path, e)
1923
+ pathPrefix: fr(this.path, e)
1413
1924
  });
1414
1925
  }
1415
1926
  /** @returns a string representation of the url */
1416
1927
  toString() {
1417
- return Wt(
1928
+ return gr(
1418
1929
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
1419
1930
  );
1420
1931
  }
1421
1932
  };
1422
- F(ue, "UNKNOWN", new ue({ host: "unknown", port: 0 }));
1423
- let Gt = ue;
1424
- var qt = Object.defineProperty, Zt = (r, e, t) => e in r ? qt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, K = (r, e, t) => Zt(r, typeof e != "symbol" ? e + "" : e, t);
1425
- const Y = class extends Number {
1933
+ V(ge, "UNKNOWN", new ge({ host: "unknown", port: 0 }));
1934
+ let yr = ge;
1935
+ var mr = Object.defineProperty, wr = (r, e, t) => e in r ? mr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, re = (r, e, t) => wr(r, typeof e != "symbol" ? e + "" : e, t);
1936
+ const j = class extends Number {
1426
1937
  };
1427
- K(Y, "Absolute", 255), K(Y, "Default", 1), K(Y, "z", s.union([
1428
- s.instanceof(Y),
1429
- s.number().int().min(0).max(255).transform((r) => new Y(r)),
1430
- s.instanceof(Number).transform((r) => new Y(r))
1938
+ re(j, "Absolute", 255), re(j, "Default", 1), re(j, "z", i.union([
1939
+ i.instanceof(j),
1940
+ i.number().int().min(0).max(255).transform((r) => new j(r)),
1941
+ i.instanceof(Number).transform((r) => new j(r))
1431
1942
  ]));
1432
- s.object({
1433
- name: s.string(),
1434
- key: s.string()
1943
+ i.object({
1944
+ name: i.string(),
1945
+ key: i.string()
1435
1946
  });
1436
- const ke = class G extends Error {
1947
+ const et = class J extends Error {
1437
1948
  constructor() {
1438
- super(G.MESSAGE);
1949
+ super(J.MESSAGE);
1439
1950
  }
1440
1951
  /** Returns true if the error or message is a cancellation error" */
1441
1952
  matches(e) {
1442
- return typeof e == "string" ? e.includes(G.MESSAGE) : e instanceof G || e.message.includes(G.MESSAGE);
1953
+ return typeof e == "string" ? e.includes(J.MESSAGE) : e instanceof J || e.message.includes(J.MESSAGE);
1443
1954
  }
1444
1955
  };
1445
- K(ke, "MESSAGE", "canceled");
1446
- let zt = ke;
1447
- new zt();
1448
- s.string().regex(/^\d+\.\d+\.\d+$/);
1449
- const he = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
1450
- class _ extends Error {
1956
+ re(et, "MESSAGE", "canceled");
1957
+ let br = et;
1958
+ new br();
1959
+ i.string().regex(/^\d+\.\d+\.\d+$/);
1960
+ const we = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
1961
+ class ae extends Error {
1451
1962
  constructor(t) {
1452
1963
  super(t);
1453
- f(this, "discriminator", "FreighterError");
1454
- f(this, "type", "");
1964
+ p(this, "discriminator", "FreighterError");
1965
+ p(this, "type", "");
1455
1966
  }
1456
1967
  }
1457
- const Vt = (r) => {
1968
+ const Tr = (r) => {
1458
1969
  if (r == null || typeof r != "object") return !1;
1459
1970
  const e = r;
1460
1971
  if (e.discriminator !== "FreighterError") return !1;
@@ -1463,98 +1974,98 @@ const Vt = (r) => {
1463
1974
  `Freighter error is missing its type property: ${JSON.stringify(e)}`
1464
1975
  );
1465
1976
  return !0;
1466
- }, be = "unknown", Te = "nil", Ht = "freighter", We = s.object({ type: s.string(), data: s.string() });
1467
- class Kt {
1977
+ }, Be = "unknown", Ue = "nil", Or = "freighter", tt = i.object({ type: i.string(), data: i.string() });
1978
+ class vr {
1468
1979
  constructor() {
1469
- f(this, "providers", []);
1980
+ p(this, "providers", []);
1470
1981
  }
1471
1982
  register(e) {
1472
1983
  this.providers.push(e);
1473
1984
  }
1474
1985
  encode(e) {
1475
- if (e == null) return { type: Te, data: "" };
1476
- if (Vt(e))
1986
+ if (e == null) return { type: Ue, data: "" };
1987
+ if (Tr(e))
1477
1988
  for (const t of this.providers) {
1478
1989
  const n = t.encode(e);
1479
1990
  if (n != null) return n;
1480
1991
  }
1481
- return { type: be, data: JSON.stringify(e) };
1992
+ return { type: Be, data: JSON.stringify(e) };
1482
1993
  }
1483
1994
  decode(e) {
1484
- if (e == null || e.type === Te) return null;
1485
- if (e.type === be) return new Se(e.data);
1995
+ if (e == null || e.type === Ue) return null;
1996
+ if (e.type === Be) return new Ce(e.data);
1486
1997
  for (const t of this.providers) {
1487
1998
  const n = t.decode(e);
1488
1999
  if (n != null) return n;
1489
2000
  }
1490
- return new Se(e.data);
2001
+ return new Ce(e.data);
1491
2002
  }
1492
2003
  }
1493
- const de = new Kt(), Xt = ({
2004
+ const be = new vr(), Sr = ({
1494
2005
  encode: r,
1495
2006
  decode: e
1496
- }) => de.register({ encode: r, decode: e }), pr = (r) => de.encode(r), Fe = (r) => de.decode(r);
1497
- class Se extends _ {
2007
+ }) => be.register({ encode: r, decode: e }), Fr = (r) => be.encode(r), rt = (r) => be.decode(r);
2008
+ class Ce extends ae {
1498
2009
  constructor(t) {
1499
2010
  super(t);
1500
- f(this, "type", "unknown");
2011
+ p(this, "type", "unknown");
1501
2012
  }
1502
2013
  }
1503
- const ee = "freighter.", L = class L extends _ {
2014
+ const oe = "freighter.", F = class F extends ae {
1504
2015
  constructor() {
1505
2016
  super("EOF");
1506
- f(this, "type", L.TYPE);
2017
+ p(this, "type", F.TYPE);
1507
2018
  }
1508
2019
  };
1509
- f(L, "TYPE", ee + "eof"), f(L, "matches", he(L.TYPE));
1510
- let B = L;
1511
- const P = class P extends _ {
2020
+ p(F, "TYPE", oe + "eof"), p(F, "matches", we(F.TYPE));
2021
+ let P = F;
2022
+ const G = class G extends ae {
1512
2023
  constructor() {
1513
2024
  super("StreamClosed");
1514
- f(this, "type", P.TYPE);
2025
+ p(this, "type", G.TYPE);
1515
2026
  }
1516
2027
  };
1517
- f(P, "TYPE", ee + "stream_closed"), f(P, "matches", he(P.TYPE));
1518
- let R = P;
1519
- const j = class j extends _ {
2028
+ p(G, "TYPE", oe + "stream_closed"), p(G, "matches", we(G.TYPE));
2029
+ let L = G;
2030
+ const q = class q extends ae {
1520
2031
  constructor(t = {}) {
1521
- const { message: n = "Unreachable", url: i = Gt.UNKNOWN } = t;
2032
+ const { message: n = "Unreachable", url: s = yr.UNKNOWN } = t;
1522
2033
  super(n);
1523
- f(this, "type", j.TYPE);
1524
- f(this, "url");
1525
- this.url = i;
2034
+ p(this, "type", q.TYPE);
2035
+ p(this, "url");
2036
+ this.url = s;
1526
2037
  }
1527
2038
  };
1528
- f(j, "TYPE", ee + "unreachable"), f(j, "matches", he(j.TYPE));
1529
- let D = j;
1530
- const Jt = (r) => {
1531
- if (!r.type.startsWith(Ht)) return null;
1532
- if (B.matches(r)) return { type: B.TYPE, data: "EOF" };
1533
- if (R.matches(r))
1534
- return { type: R.TYPE, data: "StreamClosed" };
1535
- if (D.matches(r))
1536
- return { type: D.TYPE, data: "Unreachable" };
2039
+ p(q, "TYPE", oe + "unreachable"), p(q, "matches", we(q.TYPE));
2040
+ let k = q;
2041
+ const Ir = (r) => {
2042
+ if (!r.type.startsWith(Or)) return null;
2043
+ if (P.matches(r)) return { type: P.TYPE, data: "EOF" };
2044
+ if (L.matches(r))
2045
+ return { type: L.TYPE, data: "StreamClosed" };
2046
+ if (k.matches(r))
2047
+ return { type: k.TYPE, data: "Unreachable" };
1537
2048
  throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
1538
- }, Qt = (r) => {
1539
- if (!r.type.startsWith(ee)) return null;
2049
+ }, Nr = (r) => {
2050
+ if (!r.type.startsWith(oe)) return null;
1540
2051
  switch (r.type) {
1541
- case B.TYPE:
1542
- return new B();
1543
- case R.TYPE:
1544
- return new R();
1545
- case D.TYPE:
1546
- return new D();
2052
+ case P.TYPE:
2053
+ return new P();
2054
+ case L.TYPE:
2055
+ return new L();
2056
+ case k.TYPE:
2057
+ return new k();
1547
2058
  default:
1548
2059
  throw new Error(`Unknown error type: ${r.data}`);
1549
2060
  }
1550
2061
  };
1551
- Xt({
1552
- encode: Jt,
1553
- decode: Qt
2062
+ Sr({
2063
+ encode: Ir,
2064
+ decode: Nr
1554
2065
  });
1555
- class Ge {
2066
+ class nt {
1556
2067
  constructor() {
1557
- f(this, "middleware", []);
2068
+ p(this, "middleware", []);
1558
2069
  }
1559
2070
  /** Implements the Transport interface */
1560
2071
  use(...e) {
@@ -1571,106 +2082,106 @@ class Ge {
1571
2082
  */
1572
2083
  async executeMiddleware(e, t) {
1573
2084
  let n = 0;
1574
- const i = async (a) => {
2085
+ const s = async (a) => {
1575
2086
  if (n === this.middleware.length) return await t(a);
1576
2087
  const c = this.middleware[n];
1577
- return n++, await c(a, i);
2088
+ return n++, await c(a, s);
1578
2089
  };
1579
- return await i(e);
2090
+ return await s(e);
1580
2091
  }
1581
2092
  }
1582
- const qe = "Content-Type", Ie = (r) => {
1583
- if (Pe.RUNTIME !== "node") return fetch;
2093
+ const st = "Content-Type", De = (r) => {
2094
+ if (Qe.RUNTIME !== "node") return fetch;
1584
2095
  const e = require("node-fetch");
1585
2096
  if (r === "http") return e;
1586
2097
  const t = require("https"), n = new t.Agent({ rejectUnauthorized: !1 });
1587
- return async (i, a) => await e(i, { ...a, agent: n });
2098
+ return async (s, a) => await e(s, { ...a, agent: n });
1588
2099
  };
1589
- class yr extends Ge {
1590
- constructor(t, n, i = !1) {
2100
+ class Gr extends nt {
2101
+ constructor(t, n, s = !1) {
1591
2102
  super();
1592
- f(this, "endpoint");
1593
- f(this, "encoder");
1594
- f(this, "fetch");
1595
- return this.endpoint = t.replace({ protocol: i ? "https" : "http" }), this.encoder = n, this.fetch = Ie(this.endpoint.protocol), new Proxy(this, {
1596
- get: (a, c, h) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, h)
2103
+ p(this, "endpoint");
2104
+ p(this, "encoder");
2105
+ p(this, "fetch");
2106
+ return this.endpoint = t.replace({ protocol: s ? "https" : "http" }), this.encoder = n, this.fetch = De(this.endpoint.protocol), new Proxy(this, {
2107
+ get: (a, c, d) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, d)
1597
2108
  });
1598
2109
  }
1599
2110
  get headers() {
1600
2111
  return {
1601
- [qe]: this.encoder.contentType
2112
+ [st]: this.encoder.contentType
1602
2113
  };
1603
2114
  }
1604
- async send(t, n, i, a) {
1605
- n = i == null ? void 0 : i.parse(n);
2115
+ async send(t, n, s, a) {
2116
+ n = s == null ? void 0 : s.parse(n);
1606
2117
  let c = null;
1607
- const h = this.endpoint.child(t), g = {};
1608
- g.method = "POST", g.body = this.encoder.encode(n ?? {});
1609
- const [, m] = await this.executeMiddleware(
2118
+ const d = this.endpoint.child(t), f = {};
2119
+ f.method = "POST", f.body = this.encoder.encode(n ?? {});
2120
+ const [, y] = await this.executeMiddleware(
1610
2121
  {
1611
- target: h.toString(),
2122
+ target: d.toString(),
1612
2123
  protocol: this.endpoint.protocol,
1613
2124
  params: {},
1614
2125
  role: "client"
1615
2126
  },
1616
- async (O) => {
1617
- const w = { ...O, params: {} };
1618
- g.headers = {
2127
+ async (T) => {
2128
+ const l = { ...T, params: {} };
2129
+ f.headers = {
1619
2130
  ...this.headers,
1620
- ...O.params
2131
+ ...T.params
1621
2132
  };
1622
- let A;
2133
+ let E;
1623
2134
  try {
1624
- A = await Ie(O.protocol)(O.target, g);
1625
- } catch (U) {
1626
- let E = U;
1627
- return E.message === "Load failed" && (E = new D({ url: h })), [w, E];
2135
+ E = await De(T.protocol)(T.target, f);
2136
+ } catch (B) {
2137
+ let x = B;
2138
+ return x.message === "Load failed" && (x = new k({ url: d })), [l, x];
1628
2139
  }
1629
- const k = await A.arrayBuffer();
1630
- if (A != null && A.ok)
1631
- return a != null && (c = this.encoder.decode(k, a)), [w, null];
2140
+ const R = await E.arrayBuffer();
2141
+ if (E != null && E.ok)
2142
+ return a != null && (c = this.encoder.decode(R, a)), [l, null];
1632
2143
  try {
1633
- if (A.status !== 400) return [w, new Error(A.statusText)];
1634
- const U = this.encoder.decode(k, We), E = Fe(U);
1635
- return [w, E];
1636
- } catch (U) {
2144
+ if (E.status !== 400) return [l, new Error(E.statusText)];
2145
+ const B = this.encoder.decode(R, tt), x = rt(B);
2146
+ return [l, x];
2147
+ } catch (B) {
1637
2148
  return [
1638
- w,
2149
+ l,
1639
2150
  new Error(
1640
- `[freighter] - failed to decode error: ${A.statusText}: ${U.message}`
2151
+ `[freighter] - failed to decode error: ${E.statusText}: ${B.message}`
1641
2152
  )
1642
2153
  ];
1643
2154
  }
1644
2155
  }
1645
2156
  );
1646
- return [c, m];
2157
+ return [c, y];
1647
2158
  }
1648
2159
  }
1649
- const gr = async (r, e, t, n, i) => {
1650
- const [a, c] = await r.send(e, t, n, i);
2160
+ const qr = async (r, e, t, n, s) => {
2161
+ const [a, c] = await r.send(e, t, n, s);
1651
2162
  if (c != null) throw c;
1652
2163
  return a;
1653
- }, _t = () => Pe.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), er = s.object({
1654
- type: s.union([s.literal("data"), s.literal("close")]),
1655
- payload: s.unknown().optional(),
1656
- error: s.optional(We)
2164
+ }, Er = () => Qe.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), Ar = i.object({
2165
+ type: i.union([i.literal("data"), i.literal("close")]),
2166
+ payload: i.unknown().optional(),
2167
+ error: i.optional(tt)
1657
2168
  });
1658
- class tr {
1659
- constructor(e, t, n, i) {
1660
- f(this, "encoder");
1661
- f(this, "reqSchema");
1662
- f(this, "resSchema");
1663
- f(this, "ws");
1664
- f(this, "serverClosed");
1665
- f(this, "sendClosed");
1666
- f(this, "receiveDataQueue", []);
1667
- f(this, "receiveCallbacksQueue", []);
1668
- this.encoder = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
2169
+ class xr {
2170
+ constructor(e, t, n, s) {
2171
+ p(this, "encoder");
2172
+ p(this, "reqSchema");
2173
+ p(this, "resSchema");
2174
+ p(this, "ws");
2175
+ p(this, "serverClosed");
2176
+ p(this, "sendClosed");
2177
+ p(this, "receiveDataQueue", []);
2178
+ p(this, "receiveCallbacksQueue", []);
2179
+ this.encoder = t, this.reqSchema = n, this.resSchema = s, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
1669
2180
  }
1670
2181
  /** Implements the Stream protocol */
1671
2182
  send(e) {
1672
- if (this.serverClosed != null) return new B();
1673
- if (this.sendClosed) throw new R();
2183
+ if (this.serverClosed != null) return new P();
2184
+ if (this.sendClosed) throw new L();
1674
2185
  return this.ws.send(this.encoder.encode({ type: "data", payload: e })), null;
1675
2186
  }
1676
2187
  /** Implements the Stream protocol */
@@ -1679,7 +2190,7 @@ class tr {
1679
2190
  const e = await this.receiveMsg();
1680
2191
  if (e.type === "close") {
1681
2192
  if (e.error == null) throw new Error("Message error must be defined");
1682
- return this.serverClosed = Fe(e.error), [null, this.serverClosed];
2193
+ return this.serverClosed = rt(e.error), [null, this.serverClosed];
1683
2194
  }
1684
2195
  return [this.resSchema.parse(e.payload), null];
1685
2196
  }
@@ -1708,74 +2219,74 @@ class tr {
1708
2219
  t != null ? t.resolve(e) : this.receiveDataQueue.push(e);
1709
2220
  }
1710
2221
  listenForMessages() {
1711
- this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, er)), this.ws.onclose = (e) => this.addMessage({
2222
+ this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, Ar)), this.ws.onclose = (e) => this.addMessage({
1712
2223
  type: "close",
1713
- error: { type: or(e) ? B.TYPE : R.TYPE, data: "" }
2224
+ error: { type: Ur(e) ? P.TYPE : L.TYPE, data: "" }
1714
2225
  });
1715
2226
  }
1716
2227
  }
1717
- const rr = "freighterctx", nr = 1e3, sr = 1001, ir = [nr, sr], or = (r) => ir.includes(r.code), J = class J extends Ge {
2228
+ const Mr = "freighterctx", $r = 1e3, Rr = 1001, Br = [$r, Rr], Ur = (r) => Br.includes(r.code), se = class se extends nt {
1718
2229
  /**
1719
2230
  * @param encoder - The encoder to use for encoding messages and decoding
1720
2231
  * responses.
1721
2232
  * @param baseEndpoint - A base url to use as a prefix for all requests.
1722
2233
  */
1723
- constructor(t, n, i = !1) {
2234
+ constructor(t, n, s = !1) {
1724
2235
  super();
1725
- f(this, "baseUrl");
1726
- f(this, "encoder");
1727
- this.baseUrl = t.replace({ protocol: i ? "wss" : "ws" }), this.encoder = n;
2236
+ p(this, "baseUrl");
2237
+ p(this, "encoder");
2238
+ this.baseUrl = t.replace({ protocol: s ? "wss" : "ws" }), this.encoder = n;
1728
2239
  }
1729
2240
  /** Implements the StreamClient interface. */
1730
- async stream(t, n, i) {
1731
- const a = _t();
2241
+ async stream(t, n, s) {
2242
+ const a = Er();
1732
2243
  let c;
1733
- const [, h] = await this.executeMiddleware(
2244
+ const [, d] = await this.executeMiddleware(
1734
2245
  { target: t, protocol: "websocket", params: {}, role: "client" },
1735
- async (g) => {
1736
- const m = a(this.buildURL(t, g)), O = { ...g, params: {} };
1737
- m.binaryType = J.MESSAGE_TYPE;
1738
- const w = await this.wrapSocket(m, n, i);
1739
- return w instanceof Error ? [O, w] : (c = w, [O, null]);
2246
+ async (f) => {
2247
+ const y = a(this.buildURL(t, f)), T = { ...f, params: {} };
2248
+ y.binaryType = se.MESSAGE_TYPE;
2249
+ const l = await this.wrapSocket(y, n, s);
2250
+ return l instanceof Error ? [T, l] : (c = l, [T, null]);
1740
2251
  }
1741
2252
  );
1742
- if (h != null) throw h;
2253
+ if (d != null) throw d;
1743
2254
  return c;
1744
2255
  }
1745
2256
  buildURL(t, n) {
1746
- const i = Ft(
2257
+ const s = pr(
1747
2258
  {
1748
- [qe]: this.encoder.contentType,
2259
+ [st]: this.encoder.contentType,
1749
2260
  ...n.params
1750
2261
  },
1751
- rr
2262
+ Mr
1752
2263
  );
1753
- return this.baseUrl.child(t).toString() + i;
2264
+ return this.baseUrl.child(t).toString() + s;
1754
2265
  }
1755
- async wrapSocket(t, n, i) {
2266
+ async wrapSocket(t, n, s) {
1756
2267
  return await new Promise((a) => {
1757
2268
  t.onopen = () => {
1758
- a(new tr(t, this.encoder, n, i));
2269
+ a(new xr(t, this.encoder, n, s));
1759
2270
  }, t.onerror = (c) => {
1760
- const h = c;
1761
- a(new Error(h.message));
2271
+ const d = c;
2272
+ a(new Error(d.message));
1762
2273
  };
1763
2274
  });
1764
2275
  }
1765
2276
  };
1766
- f(J, "MESSAGE_TYPE", "arraybuffer");
1767
- let Ne = J;
2277
+ p(se, "MESSAGE_TYPE", "arraybuffer");
2278
+ let Pe = se;
1768
2279
  export {
1769
- _ as BaseTypedError,
1770
- B as EOF,
1771
- yr as HTTPClient,
1772
- R as StreamClosed,
1773
- D as Unreachable,
1774
- Ne as WebSocketClient,
1775
- Fe as decodeError,
1776
- pr as encodeError,
1777
- he as errorMatcher,
1778
- We as errorZ,
1779
- Xt as registerError,
1780
- gr as sendRequired
2280
+ ae as BaseTypedError,
2281
+ P as EOF,
2282
+ Gr as HTTPClient,
2283
+ L as StreamClosed,
2284
+ k as Unreachable,
2285
+ Pe as WebSocketClient,
2286
+ rt as decodeError,
2287
+ Fr as encodeError,
2288
+ we as errorMatcher,
2289
+ tt as errorZ,
2290
+ Sr as registerError,
2291
+ qr as sendRequired
1781
2292
  };