@thatopen/services 0.23.0 → 0.25.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/index.es.js CHANGED
@@ -1,265 +1,265 @@
1
- var cs = Object.defineProperty;
2
- var ve = (n) => {
3
- throw TypeError(n);
1
+ var Ks = Object.defineProperty;
2
+ var Re = (r) => {
3
+ throw TypeError(r);
4
4
  };
5
- var hs = (n, t, e) => t in n ? cs(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var T = (n, t, e) => hs(n, typeof t != "symbol" ? t + "" : t, e), Lt = (n, t, e) => t.has(n) || ve("Cannot " + e);
7
- var l = (n, t, e) => (Lt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? ve("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), _ = (n, t, e, s) => (Lt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Lt(n, t, "access private method"), e);
8
- const B = /* @__PURE__ */ Object.create(null);
9
- B.open = "0";
10
- B.close = "1";
11
- B.ping = "2";
12
- B.pong = "3";
13
- B.message = "4";
14
- B.upgrade = "5";
15
- B.noop = "6";
16
- const kt = /* @__PURE__ */ Object.create(null);
17
- Object.keys(B).forEach((n) => {
18
- kt[B[n]] = n;
5
+ var zs = (r, t, e) => t in r ? Ks(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
6
+ var I = (r, t, e) => zs(r, typeof t != "symbol" ? t + "" : t, e), Vt = (r, t, e) => t.has(r) || Re("Cannot " + e);
7
+ var u = (r, t, e) => (Vt(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? Re("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), _ = (r, t, e, s) => (Vt(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), a = (r, t, e) => (Vt(r, t, "access private method"), e);
8
+ const F = /* @__PURE__ */ Object.create(null);
9
+ F.open = "0";
10
+ F.close = "1";
11
+ F.ping = "2";
12
+ F.pong = "3";
13
+ F.message = "4";
14
+ F.upgrade = "5";
15
+ F.noop = "6";
16
+ const xt = /* @__PURE__ */ Object.create(null);
17
+ Object.keys(F).forEach((r) => {
18
+ xt[F[r]] = r;
19
19
  });
20
- const Ht = { type: "error", data: "parser error" }, Le = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Fe = typeof ArrayBuffer == "function", qe = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, fe = ({ type: n, data: t }, e, s) => Le && t instanceof Blob ? e ? s(t) : Ee(t, s) : Fe && (t instanceof ArrayBuffer || qe(t)) ? e ? s(t) : Ee(new Blob([t]), s) : s(B[n] + (t || "")), Ee = (n, t) => {
20
+ const zt = { type: "error", data: "parser error" }, ze = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Xe = typeof ArrayBuffer == "function", Qe = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer, be = ({ type: r, data: t }, e, s) => ze && t instanceof Blob ? e ? s(t) : $e(t, s) : Xe && (t instanceof ArrayBuffer || Qe(t)) ? e ? s(t) : $e(new Blob([t]), s) : s(F[r] + (t || "")), $e = (r, t) => {
21
21
  const e = new FileReader();
22
22
  return e.onload = function() {
23
23
  const s = e.result.split(",")[1];
24
24
  t("b" + (s || ""));
25
- }, e.readAsDataURL(n);
25
+ }, e.readAsDataURL(r);
26
26
  };
27
- function Te(n) {
28
- return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
27
+ function Ne(r) {
28
+ return r instanceof Uint8Array ? r : r instanceof ArrayBuffer ? new Uint8Array(r) : new Uint8Array(r.buffer, r.byteOffset, r.byteLength);
29
29
  }
30
- let Ft;
31
- function ls(n, t) {
32
- if (Le && n.data instanceof Blob)
33
- return n.data.arrayBuffer().then(Te).then(t);
34
- if (Fe && (n.data instanceof ArrayBuffer || qe(n.data)))
35
- return t(Te(n.data));
36
- fe(n, !1, (e) => {
37
- Ft || (Ft = new TextEncoder()), t(Ft.encode(e));
30
+ let Gt;
31
+ function Xs(r, t) {
32
+ if (ze && r.data instanceof Blob)
33
+ return r.data.arrayBuffer().then(Ne).then(t);
34
+ if (Xe && (r.data instanceof ArrayBuffer || Qe(r.data)))
35
+ return t(Ne(r.data));
36
+ be(r, !1, (e) => {
37
+ Gt || (Gt = new TextEncoder()), t(Gt.encode(e));
38
38
  });
39
39
  }
40
- const Se = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", lt = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
- for (let n = 0; n < Se.length; n++)
42
- lt[Se.charCodeAt(n)] = n;
43
- const us = (n) => {
44
- let t = n.length * 0.75, e = n.length, s, r = 0, i, o, c, u;
45
- n[n.length - 1] === "=" && (t--, n[n.length - 2] === "=" && t--);
46
- const f = new ArrayBuffer(t), y = new Uint8Array(f);
40
+ const Pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", yt = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
+ for (let r = 0; r < Pe.length; r++)
42
+ yt[Pe.charCodeAt(r)] = r;
43
+ const Qs = (r) => {
44
+ let t = r.length * 0.75, e = r.length, s, n = 0, i, o, h, d;
45
+ r[r.length - 1] === "=" && (t--, r[r.length - 2] === "=" && t--);
46
+ const f = new ArrayBuffer(t), c = new Uint8Array(f);
47
47
  for (s = 0; s < e; s += 4)
48
- i = lt[n.charCodeAt(s)], o = lt[n.charCodeAt(s + 1)], c = lt[n.charCodeAt(s + 2)], u = lt[n.charCodeAt(s + 3)], y[r++] = i << 2 | o >> 4, y[r++] = (o & 15) << 4 | c >> 2, y[r++] = (c & 3) << 6 | u & 63;
48
+ i = yt[r.charCodeAt(s)], o = yt[r.charCodeAt(s + 1)], h = yt[r.charCodeAt(s + 2)], d = yt[r.charCodeAt(s + 3)], c[n++] = i << 2 | o >> 4, c[n++] = (o & 15) << 4 | h >> 2, c[n++] = (h & 3) << 6 | d & 63;
49
49
  return f;
50
- }, ds = typeof ArrayBuffer == "function", pe = (n, t) => {
51
- if (typeof n != "string")
50
+ }, Zs = typeof ArrayBuffer == "function", _e = (r, t) => {
51
+ if (typeof r != "string")
52
52
  return {
53
53
  type: "message",
54
- data: De(n, t)
54
+ data: Ze(r, t)
55
55
  };
56
- const e = n.charAt(0);
56
+ const e = r.charAt(0);
57
57
  return e === "b" ? {
58
58
  type: "message",
59
- data: fs(n.substring(1), t)
60
- } : kt[e] ? n.length > 1 ? {
61
- type: kt[e],
62
- data: n.substring(1)
59
+ data: tr(r.substring(1), t)
60
+ } : xt[e] ? r.length > 1 ? {
61
+ type: xt[e],
62
+ data: r.substring(1)
63
63
  } : {
64
- type: kt[e]
65
- } : Ht;
66
- }, fs = (n, t) => {
67
- if (ds) {
68
- const e = us(n);
69
- return De(e, t);
64
+ type: xt[e]
65
+ } : zt;
66
+ }, tr = (r, t) => {
67
+ if (Zs) {
68
+ const e = Qs(r);
69
+ return Ze(e, t);
70
70
  } else
71
- return { base64: !0, data: n };
72
- }, De = (n, t) => {
71
+ return { base64: !0, data: r };
72
+ }, Ze = (r, t) => {
73
73
  switch (t) {
74
74
  case "blob":
75
- return n instanceof Blob ? n : new Blob([n]);
75
+ return r instanceof Blob ? r : new Blob([r]);
76
76
  case "arraybuffer":
77
77
  default:
78
- return n instanceof ArrayBuffer ? n : n.buffer;
79
- }
80
- }, Ue = "", ps = (n, t) => {
81
- const e = n.length, s = new Array(e);
82
- let r = 0;
83
- n.forEach((i, o) => {
84
- fe(i, !1, (c) => {
85
- s[o] = c, ++r === e && t(s.join(Ue));
78
+ return r instanceof ArrayBuffer ? r : r.buffer;
79
+ }
80
+ }, ts = "", er = (r, t) => {
81
+ const e = r.length, s = new Array(e);
82
+ let n = 0;
83
+ r.forEach((i, o) => {
84
+ be(i, !1, (h) => {
85
+ s[o] = h, ++n === e && t(s.join(ts));
86
86
  });
87
87
  });
88
- }, ys = (n, t) => {
89
- const e = n.split(Ue), s = [];
90
- for (let r = 0; r < e.length; r++) {
91
- const i = pe(e[r], t);
88
+ }, sr = (r, t) => {
89
+ const e = r.split(ts), s = [];
90
+ for (let n = 0; n < e.length; n++) {
91
+ const i = _e(e[n], t);
92
92
  if (s.push(i), i.type === "error")
93
93
  break;
94
94
  }
95
95
  return s;
96
96
  };
97
- function ms() {
97
+ function rr() {
98
98
  return new TransformStream({
99
- transform(n, t) {
100
- ls(n, (e) => {
99
+ transform(r, t) {
100
+ Xs(r, (e) => {
101
101
  const s = e.length;
102
- let r;
102
+ let n;
103
103
  if (s < 126)
104
- r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, s);
104
+ n = new Uint8Array(1), new DataView(n.buffer).setUint8(0, s);
105
105
  else if (s < 65536) {
106
- r = new Uint8Array(3);
107
- const i = new DataView(r.buffer);
106
+ n = new Uint8Array(3);
107
+ const i = new DataView(n.buffer);
108
108
  i.setUint8(0, 126), i.setUint16(1, s);
109
109
  } else {
110
- r = new Uint8Array(9);
111
- const i = new DataView(r.buffer);
110
+ n = new Uint8Array(9);
111
+ const i = new DataView(n.buffer);
112
112
  i.setUint8(0, 127), i.setBigUint64(1, BigInt(s));
113
113
  }
114
- n.data && typeof n.data != "string" && (r[0] |= 128), t.enqueue(r), t.enqueue(e);
114
+ r.data && typeof r.data != "string" && (n[0] |= 128), t.enqueue(n), t.enqueue(e);
115
115
  });
116
116
  }
117
117
  });
118
118
  }
119
- let qt;
120
- function Et(n) {
121
- return n.reduce((t, e) => t + e.length, 0);
119
+ let Ht;
120
+ function It(r) {
121
+ return r.reduce((t, e) => t + e.length, 0);
122
122
  }
123
- function Tt(n, t) {
124
- if (n[0].length === t)
125
- return n.shift();
123
+ function Ot(r, t) {
124
+ if (r[0].length === t)
125
+ return r.shift();
126
126
  const e = new Uint8Array(t);
127
127
  let s = 0;
128
- for (let r = 0; r < t; r++)
129
- e[r] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
130
- return n.length && s < n[0].length && (n[0] = n[0].slice(s)), e;
128
+ for (let n = 0; n < t; n++)
129
+ e[n] = r[0][s++], s === r[0].length && (r.shift(), s = 0);
130
+ return r.length && s < r[0].length && (r[0] = r[0].slice(s)), e;
131
131
  }
132
- function gs(n, t) {
133
- qt || (qt = new TextDecoder());
132
+ function nr(r, t) {
133
+ Ht || (Ht = new TextDecoder());
134
134
  const e = [];
135
- let s = 0, r = -1, i = !1;
135
+ let s = 0, n = -1, i = !1;
136
136
  return new TransformStream({
137
- transform(o, c) {
137
+ transform(o, h) {
138
138
  for (e.push(o); ; ) {
139
139
  if (s === 0) {
140
- if (Et(e) < 1)
140
+ if (It(e) < 1)
141
141
  break;
142
- const u = Tt(e, 1);
143
- i = (u[0] & 128) === 128, r = u[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
142
+ const d = Ot(e, 1);
143
+ i = (d[0] & 128) === 128, n = d[0] & 127, n < 126 ? s = 3 : n === 126 ? s = 1 : s = 2;
144
144
  } else if (s === 1) {
145
- if (Et(e) < 2)
145
+ if (It(e) < 2)
146
146
  break;
147
- const u = Tt(e, 2);
148
- r = new DataView(u.buffer, u.byteOffset, u.length).getUint16(0), s = 3;
147
+ const d = Ot(e, 2);
148
+ n = new DataView(d.buffer, d.byteOffset, d.length).getUint16(0), s = 3;
149
149
  } else if (s === 2) {
150
- if (Et(e) < 8)
150
+ if (It(e) < 8)
151
151
  break;
152
- const u = Tt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), y = f.getUint32(0);
153
- if (y > Math.pow(2, 21) - 1) {
154
- c.enqueue(Ht);
152
+ const d = Ot(e, 8), f = new DataView(d.buffer, d.byteOffset, d.length), c = f.getUint32(0);
153
+ if (c > Math.pow(2, 21) - 1) {
154
+ h.enqueue(zt);
155
155
  break;
156
156
  }
157
- r = y * Math.pow(2, 32) + f.getUint32(4), s = 3;
157
+ n = c * Math.pow(2, 32) + f.getUint32(4), s = 3;
158
158
  } else {
159
- if (Et(e) < r)
159
+ if (It(e) < n)
160
160
  break;
161
- const u = Tt(e, r);
162
- c.enqueue(pe(i ? u : qt.decode(u), t)), s = 0;
161
+ const d = Ot(e, n);
162
+ h.enqueue(_e(i ? d : Ht.decode(d), t)), s = 0;
163
163
  }
164
- if (r === 0 || r > n) {
165
- c.enqueue(Ht);
164
+ if (n === 0 || n > r) {
165
+ h.enqueue(zt);
166
166
  break;
167
167
  }
168
168
  }
169
169
  }
170
170
  });
171
171
  }
172
- const je = 4;
173
- function v(n) {
174
- if (n) return ws(n);
172
+ const es = 4;
173
+ function E(r) {
174
+ if (r) return ir(r);
175
175
  }
176
- function ws(n) {
177
- for (var t in v.prototype)
178
- n[t] = v.prototype[t];
179
- return n;
176
+ function ir(r) {
177
+ for (var t in E.prototype)
178
+ r[t] = E.prototype[t];
179
+ return r;
180
180
  }
181
- v.prototype.on = v.prototype.addEventListener = function(n, t) {
182
- return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(t), this;
181
+ E.prototype.on = E.prototype.addEventListener = function(r, t) {
182
+ return this._callbacks = this._callbacks || {}, (this._callbacks["$" + r] = this._callbacks["$" + r] || []).push(t), this;
183
183
  };
184
- v.prototype.once = function(n, t) {
184
+ E.prototype.once = function(r, t) {
185
185
  function e() {
186
- this.off(n, e), t.apply(this, arguments);
186
+ this.off(r, e), t.apply(this, arguments);
187
187
  }
188
- return e.fn = t, this.on(n, e), this;
188
+ return e.fn = t, this.on(r, e), this;
189
189
  };
190
- v.prototype.off = v.prototype.removeListener = v.prototype.removeAllListeners = v.prototype.removeEventListener = function(n, t) {
190
+ E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(r, t) {
191
191
  if (this._callbacks = this._callbacks || {}, arguments.length == 0)
192
192
  return this._callbacks = {}, this;
193
- var e = this._callbacks["$" + n];
193
+ var e = this._callbacks["$" + r];
194
194
  if (!e) return this;
195
195
  if (arguments.length == 1)
196
- return delete this._callbacks["$" + n], this;
197
- for (var s, r = 0; r < e.length; r++)
198
- if (s = e[r], s === t || s.fn === t) {
199
- e.splice(r, 1);
196
+ return delete this._callbacks["$" + r], this;
197
+ for (var s, n = 0; n < e.length; n++)
198
+ if (s = e[n], s === t || s.fn === t) {
199
+ e.splice(n, 1);
200
200
  break;
201
201
  }
202
- return e.length === 0 && delete this._callbacks["$" + n], this;
202
+ return e.length === 0 && delete this._callbacks["$" + r], this;
203
203
  };
204
- v.prototype.emit = function(n) {
204
+ E.prototype.emit = function(r) {
205
205
  this._callbacks = this._callbacks || {};
206
- for (var t = new Array(arguments.length - 1), e = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
206
+ for (var t = new Array(arguments.length - 1), e = this._callbacks["$" + r], s = 1; s < arguments.length; s++)
207
207
  t[s - 1] = arguments[s];
208
208
  if (e) {
209
209
  e = e.slice(0);
210
- for (var s = 0, r = e.length; s < r; ++s)
210
+ for (var s = 0, n = e.length; s < n; ++s)
211
211
  e[s].apply(this, t);
212
212
  }
213
213
  return this;
214
214
  };
215
- v.prototype.emitReserved = v.prototype.emit;
216
- v.prototype.listeners = function(n) {
217
- return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
215
+ E.prototype.emitReserved = E.prototype.emit;
216
+ E.prototype.listeners = function(r) {
217
+ return this._callbacks = this._callbacks || {}, this._callbacks["$" + r] || [];
218
218
  };
219
- v.prototype.hasListeners = function(n) {
220
- return !!this.listeners(n).length;
219
+ E.prototype.hasListeners = function(r) {
220
+ return !!this.listeners(r).length;
221
221
  };
222
- const Pt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), I = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), bs = "arraybuffer";
223
- function Me(n, ...t) {
224
- return t.reduce((e, s) => (n.hasOwnProperty(s) && (e[s] = n[s]), e), {});
222
+ const Dt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), R = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), or = "arraybuffer";
223
+ function ss(r, ...t) {
224
+ return t.reduce((e, s) => (r.hasOwnProperty(s) && (e[s] = r[s]), e), {});
225
225
  }
226
- const _s = I.setTimeout, vs = I.clearTimeout;
227
- function Bt(n, t) {
228
- t.useNativeTimers ? (n.setTimeoutFn = _s.bind(I), n.clearTimeoutFn = vs.bind(I)) : (n.setTimeoutFn = I.setTimeout.bind(I), n.clearTimeoutFn = I.clearTimeout.bind(I));
226
+ const ar = R.setTimeout, cr = R.clearTimeout;
227
+ function Ut(r, t) {
228
+ t.useNativeTimers ? (r.setTimeoutFn = ar.bind(R), r.clearTimeoutFn = cr.bind(R)) : (r.setTimeoutFn = R.setTimeout.bind(R), r.clearTimeoutFn = R.clearTimeout.bind(R));
229
229
  }
230
- const Es = 1.33;
231
- function Ts(n) {
232
- return typeof n == "string" ? Ss(n) : Math.ceil((n.byteLength || n.size) * Es);
230
+ const hr = 1.33;
231
+ function lr(r) {
232
+ return typeof r == "string" ? ur(r) : Math.ceil((r.byteLength || r.size) * hr);
233
233
  }
234
- function Ss(n) {
234
+ function ur(r) {
235
235
  let t = 0, e = 0;
236
- for (let s = 0, r = n.length; s < r; s++)
237
- t = n.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
236
+ for (let s = 0, n = r.length; s < n; s++)
237
+ t = r.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
238
238
  return e;
239
239
  }
240
- function He() {
240
+ function rs() {
241
241
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
242
242
  }
243
- function ks(n) {
243
+ function dr(r) {
244
244
  let t = "";
245
- for (let e in n)
246
- n.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(n[e]));
245
+ for (let e in r)
246
+ r.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(r[e]));
247
247
  return t;
248
248
  }
249
- function Os(n) {
250
- let t = {}, e = n.split("&");
251
- for (let s = 0, r = e.length; s < r; s++) {
249
+ function fr(r) {
250
+ let t = {}, e = r.split("&");
251
+ for (let s = 0, n = e.length; s < n; s++) {
252
252
  let i = e[s].split("=");
253
253
  t[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
254
254
  }
255
255
  return t;
256
256
  }
257
- class Is extends Error {
257
+ class pr extends Error {
258
258
  constructor(t, e, s) {
259
259
  super(t), this.description = e, this.context = s, this.type = "TransportError";
260
260
  }
261
261
  }
262
- class ye extends v {
262
+ class Ee extends E {
263
263
  /**
264
264
  * Transport abstract constructor.
265
265
  *
@@ -267,7 +267,7 @@ class ye extends v {
267
267
  * @protected
268
268
  */
269
269
  constructor(t) {
270
- super(), this.writable = !1, Bt(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
270
+ super(), this.writable = !1, Ut(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
271
271
  }
272
272
  /**
273
273
  * Emits an error.
@@ -279,7 +279,7 @@ class ye extends v {
279
279
  * @protected
280
280
  */
281
281
  onError(t, e, s) {
282
- return super.emitReserved("error", new Is(t, e, s)), this;
282
+ return super.emitReserved("error", new pr(t, e, s)), this;
283
283
  }
284
284
  /**
285
285
  * Opens the transport.
@@ -316,7 +316,7 @@ class ye extends v {
316
316
  * @protected
317
317
  */
318
318
  onData(t) {
319
- const e = pe(t, this.socket.binaryType);
319
+ const e = _e(t, this.socket.binaryType);
320
320
  this.onPacket(e);
321
321
  }
322
322
  /**
@@ -353,11 +353,11 @@ class ye extends v {
353
353
  return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
354
354
  }
355
355
  _query(t) {
356
- const e = ks(t);
356
+ const e = dr(t);
357
357
  return e.length ? "?" + e : "";
358
358
  }
359
359
  }
360
- class As extends ye {
360
+ class yr extends Ee {
361
361
  constructor() {
362
362
  super(...arguments), this._polling = !1;
363
363
  }
@@ -413,7 +413,7 @@ class As extends ye {
413
413
  return this.onClose({ description: "transport closed by the server" }), !1;
414
414
  this.onPacket(s);
415
415
  };
416
- ys(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
416
+ sr(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
417
417
  }
418
418
  /**
419
419
  * For polling, send a close packet.
@@ -433,7 +433,7 @@ class As extends ye {
433
433
  * @protected
434
434
  */
435
435
  write(t) {
436
- this.writable = !1, ps(t, (e) => {
436
+ this.writable = !1, er(t, (e) => {
437
437
  this.doWrite(e, () => {
438
438
  this.writable = !0, this.emitReserved("drain");
439
439
  });
@@ -446,18 +446,18 @@ class As extends ye {
446
446
  */
447
447
  uri() {
448
448
  const t = this.opts.secure ? "https" : "http", e = this.query || {};
449
- return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = He()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
449
+ return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = rs()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
450
450
  }
451
451
  }
452
- let Ge = !1;
452
+ let ns = !1;
453
453
  try {
454
- Ge = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
454
+ ns = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
455
455
  } catch {
456
456
  }
457
- const xs = Ge;
458
- function $s() {
457
+ const mr = ns;
458
+ function gr() {
459
459
  }
460
- class Cs extends As {
460
+ class wr extends yr {
461
461
  /**
462
462
  * XHR Polling constructor.
463
463
  *
@@ -483,8 +483,8 @@ class Cs extends As {
483
483
  method: "POST",
484
484
  data: t
485
485
  });
486
- s.on("success", e), s.on("error", (r, i) => {
487
- this.onError("xhr post error", r, i);
486
+ s.on("success", e), s.on("error", (n, i) => {
487
+ this.onError("xhr post error", n, i);
488
488
  });
489
489
  }
490
490
  /**
@@ -499,7 +499,7 @@ class Cs extends As {
499
499
  }), this.pollXhr = t;
500
500
  }
501
501
  }
502
- class P extends v {
502
+ class L extends E {
503
503
  /**
504
504
  * Request constructor
505
505
  *
@@ -507,7 +507,7 @@ class P extends v {
507
507
  * @package
508
508
  */
509
509
  constructor(t, e, s) {
510
- super(), this.createRequest = t, Bt(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
510
+ super(), this.createRequest = t, Ut(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
511
511
  }
512
512
  /**
513
513
  * Creates the XHR object and sends the request.
@@ -516,7 +516,7 @@ class P extends v {
516
516
  */
517
517
  _create() {
518
518
  var t;
519
- const e = Me(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
519
+ const e = ss(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
520
520
  e.xdomain = !!this._opts.xd;
521
521
  const s = this._xhr = this.createRequest(e);
522
522
  try {
@@ -524,8 +524,8 @@ class P extends v {
524
524
  try {
525
525
  if (this._opts.extraHeaders) {
526
526
  s.setDisableHeaderCheck && s.setDisableHeaderCheck(!0);
527
- for (let r in this._opts.extraHeaders)
528
- this._opts.extraHeaders.hasOwnProperty(r) && s.setRequestHeader(r, this._opts.extraHeaders[r]);
527
+ for (let n in this._opts.extraHeaders)
528
+ this._opts.extraHeaders.hasOwnProperty(n) && s.setRequestHeader(n, this._opts.extraHeaders[n]);
529
529
  }
530
530
  } catch {
531
531
  }
@@ -539,21 +539,21 @@ class P extends v {
539
539
  } catch {
540
540
  }
541
541
  (t = this._opts.cookieJar) === null || t === void 0 || t.addCookies(s), "withCredentials" in s && (s.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (s.timeout = this._opts.requestTimeout), s.onreadystatechange = () => {
542
- var r;
543
- s.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
542
+ var n;
543
+ s.readyState === 3 && ((n = this._opts.cookieJar) === null || n === void 0 || n.parseCookies(
544
544
  // @ts-ignore
545
545
  s.getResponseHeader("set-cookie")
546
546
  )), s.readyState === 4 && (s.status === 200 || s.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
547
547
  this._onError(typeof s.status == "number" ? s.status : 0);
548
548
  }, 0));
549
549
  }, s.send(this._data);
550
- } catch (r) {
550
+ } catch (n) {
551
551
  this.setTimeoutFn(() => {
552
- this._onError(r);
552
+ this._onError(n);
553
553
  }, 0);
554
554
  return;
555
555
  }
556
- typeof document < "u" && (this._index = P.requestsCount++, P.requests[this._index] = this);
556
+ typeof document < "u" && (this._index = L.requestsCount++, L.requests[this._index] = this);
557
557
  }
558
558
  /**
559
559
  * Called upon error.
@@ -570,12 +570,12 @@ class P extends v {
570
570
  */
571
571
  _cleanup(t) {
572
572
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
573
- if (this._xhr.onreadystatechange = $s, t)
573
+ if (this._xhr.onreadystatechange = gr, t)
574
574
  try {
575
575
  this._xhr.abort();
576
576
  } catch {
577
577
  }
578
- typeof document < "u" && delete P.requests[this._index], this._xhr = null;
578
+ typeof document < "u" && delete L.requests[this._index], this._xhr = null;
579
579
  }
580
580
  }
581
581
  /**
@@ -596,61 +596,61 @@ class P extends v {
596
596
  this._cleanup();
597
597
  }
598
598
  }
599
- P.requestsCount = 0;
600
- P.requests = {};
599
+ L.requestsCount = 0;
600
+ L.requests = {};
601
601
  if (typeof document < "u") {
602
602
  if (typeof attachEvent == "function")
603
- attachEvent("onunload", ke);
603
+ attachEvent("onunload", Be);
604
604
  else if (typeof addEventListener == "function") {
605
- const n = "onpagehide" in I ? "pagehide" : "unload";
606
- addEventListener(n, ke, !1);
605
+ const r = "onpagehide" in R ? "pagehide" : "unload";
606
+ addEventListener(r, Be, !1);
607
607
  }
608
608
  }
609
- function ke() {
610
- for (let n in P.requests)
611
- P.requests.hasOwnProperty(n) && P.requests[n].abort();
609
+ function Be() {
610
+ for (let r in L.requests)
611
+ L.requests.hasOwnProperty(r) && L.requests[r].abort();
612
612
  }
613
- const Rs = function() {
614
- const n = Ve({
613
+ const br = function() {
614
+ const r = is({
615
615
  xdomain: !1
616
616
  });
617
- return n && n.responseType !== null;
617
+ return r && r.responseType !== null;
618
618
  }();
619
- class Ns extends Cs {
619
+ class _r extends wr {
620
620
  constructor(t) {
621
621
  super(t);
622
622
  const e = t && t.forceBase64;
623
- this.supportsBinary = Rs && !e;
623
+ this.supportsBinary = br && !e;
624
624
  }
625
625
  request(t = {}) {
626
- return Object.assign(t, { xd: this.xd }, this.opts), new P(Ve, this.uri(), t);
626
+ return Object.assign(t, { xd: this.xd }, this.opts), new L(is, this.uri(), t);
627
627
  }
628
628
  }
629
- function Ve(n) {
630
- const t = n.xdomain;
629
+ function is(r) {
630
+ const t = r.xdomain;
631
631
  try {
632
- if (typeof XMLHttpRequest < "u" && (!t || xs))
632
+ if (typeof XMLHttpRequest < "u" && (!t || mr))
633
633
  return new XMLHttpRequest();
634
634
  } catch {
635
635
  }
636
636
  if (!t)
637
637
  try {
638
- return new I[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
638
+ return new R[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
639
639
  } catch {
640
640
  }
641
641
  }
642
- const Je = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
- class Ps extends ye {
642
+ const os = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
+ class Er extends Ee {
644
644
  get name() {
645
645
  return "websocket";
646
646
  }
647
647
  doOpen() {
648
- const t = this.uri(), e = this.opts.protocols, s = Je ? {} : Me(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
648
+ const t = this.uri(), e = this.opts.protocols, s = os ? {} : ss(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
649
649
  this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
650
650
  try {
651
651
  this.ws = this.createSocket(t, e, s);
652
- } catch (r) {
653
- return this.emitReserved("error", r);
652
+ } catch (n) {
653
+ return this.emitReserved("error", n);
654
654
  }
655
655
  this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
656
656
  }
@@ -670,13 +670,13 @@ class Ps extends ye {
670
670
  write(t) {
671
671
  this.writable = !1;
672
672
  for (let e = 0; e < t.length; e++) {
673
- const s = t[e], r = e === t.length - 1;
674
- fe(s, this.supportsBinary, (i) => {
673
+ const s = t[e], n = e === t.length - 1;
674
+ be(s, this.supportsBinary, (i) => {
675
675
  try {
676
676
  this.doWrite(s, i);
677
677
  } catch {
678
678
  }
679
- r && Pt(() => {
679
+ n && Dt(() => {
680
680
  this.writable = !0, this.emitReserved("drain");
681
681
  }, this.setTimeoutFn);
682
682
  });
@@ -693,19 +693,19 @@ class Ps extends ye {
693
693
  */
694
694
  uri() {
695
695
  const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
696
- return this.opts.timestampRequests && (e[this.opts.timestampParam] = He()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
696
+ return this.opts.timestampRequests && (e[this.opts.timestampParam] = rs()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
697
697
  }
698
698
  }
699
- const Dt = I.WebSocket || I.MozWebSocket;
700
- class Bs extends Ps {
699
+ const Jt = R.WebSocket || R.MozWebSocket;
700
+ class vr extends Er {
701
701
  createSocket(t, e, s) {
702
- return Je ? new Dt(t, e, s) : e ? new Dt(t, e) : new Dt(t);
702
+ return os ? new Jt(t, e, s) : e ? new Jt(t, e) : new Jt(t);
703
703
  }
704
704
  doWrite(t, e) {
705
705
  this.ws.send(e);
706
706
  }
707
707
  }
708
- class Ls extends ye {
708
+ class Tr extends Ee {
709
709
  get name() {
710
710
  return "webtransport";
711
711
  }
@@ -721,12 +721,12 @@ class Ls extends ye {
721
721
  this.onError("webtransport error", t);
722
722
  }), this._transport.ready.then(() => {
723
723
  this._transport.createBidirectionalStream().then((t) => {
724
- const e = gs(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = ms();
725
- r.readable.pipeTo(t.writable), this._writer = r.writable.getWriter();
724
+ const e = nr(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), n = rr();
725
+ n.readable.pipeTo(t.writable), this._writer = n.writable.getWriter();
726
726
  const i = () => {
727
- s.read().then(({ done: c, value: u }) => {
728
- c || (this.onPacket(u), i());
729
- }).catch((c) => {
727
+ s.read().then(({ done: h, value: d }) => {
728
+ h || (this.onPacket(d), i());
729
+ }).catch((h) => {
730
730
  });
731
731
  };
732
732
  i();
@@ -738,9 +738,9 @@ class Ls extends ye {
738
738
  write(t) {
739
739
  this.writable = !1;
740
740
  for (let e = 0; e < t.length; e++) {
741
- const s = t[e], r = e === t.length - 1;
741
+ const s = t[e], n = e === t.length - 1;
742
742
  this._writer.write(s).then(() => {
743
- r && Pt(() => {
743
+ n && Dt(() => {
744
744
  this.writable = !0, this.emitReserved("drain");
745
745
  }, this.setTimeoutFn);
746
746
  });
@@ -751,11 +751,11 @@ class Ls extends ye {
751
751
  (t = this._transport) === null || t === void 0 || t.close();
752
752
  }
753
753
  }
754
- const Fs = {
755
- websocket: Bs,
756
- webtransport: Ls,
757
- polling: Ns
758
- }, qs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Ds = [
754
+ const Sr = {
755
+ websocket: vr,
756
+ webtransport: Tr,
757
+ polling: _r
758
+ }, Ir = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Or = [
759
759
  "source",
760
760
  "protocol",
761
761
  "authority",
@@ -771,31 +771,31 @@ const Fs = {
771
771
  "query",
772
772
  "anchor"
773
773
  ];
774
- function Gt(n) {
775
- if (n.length > 8e3)
774
+ function Xt(r) {
775
+ if (r.length > 8e3)
776
776
  throw "URI too long";
777
- const t = n, e = n.indexOf("["), s = n.indexOf("]");
778
- e != -1 && s != -1 && (n = n.substring(0, e) + n.substring(e, s).replace(/:/g, ";") + n.substring(s, n.length));
779
- let r = qs.exec(n || ""), i = {}, o = 14;
777
+ const t = r, e = r.indexOf("["), s = r.indexOf("]");
778
+ e != -1 && s != -1 && (r = r.substring(0, e) + r.substring(e, s).replace(/:/g, ";") + r.substring(s, r.length));
779
+ let n = Ir.exec(r || ""), i = {}, o = 14;
780
780
  for (; o--; )
781
- i[Ds[o]] = r[o] || "";
782
- return e != -1 && s != -1 && (i.source = t, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = Us(i, i.path), i.queryKey = js(i, i.query), i;
781
+ i[Or[o]] = n[o] || "";
782
+ return e != -1 && s != -1 && (i.source = t, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = Ar(i, i.path), i.queryKey = kr(i, i.query), i;
783
783
  }
784
- function Us(n, t) {
784
+ function Ar(r, t) {
785
785
  const e = /\/{2,9}/g, s = t.replace(e, "/").split("/");
786
786
  return (t.slice(0, 1) == "/" || t.length === 0) && s.splice(0, 1), t.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
787
787
  }
788
- function js(n, t) {
788
+ function kr(r, t) {
789
789
  const e = {};
790
- return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
791
- r && (e[r] = i);
790
+ return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, n, i) {
791
+ n && (e[n] = i);
792
792
  }), e;
793
793
  }
794
- const Vt = typeof addEventListener == "function" && typeof removeEventListener == "function", Ot = [];
795
- Vt && addEventListener("offline", () => {
796
- Ot.forEach((n) => n());
794
+ const Qt = typeof addEventListener == "function" && typeof removeEventListener == "function", Ct = [];
795
+ Qt && addEventListener("offline", () => {
796
+ Ct.forEach((r) => r());
797
797
  }, !1);
798
- class Y extends v {
798
+ class X extends E {
799
799
  /**
800
800
  * Socket constructor.
801
801
  *
@@ -803,13 +803,13 @@ class Y extends v {
803
803
  * @param {Object} opts - options
804
804
  */
805
805
  constructor(t, e) {
806
- if (super(), this.binaryType = bs, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
807
- const s = Gt(t);
806
+ if (super(), this.binaryType = or, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
807
+ const s = Xt(t);
808
808
  e.hostname = s.host, e.secure = s.protocol === "https" || s.protocol === "wss", e.port = s.port, s.query && (e.query = s.query);
809
- } else e.host && (e.hostname = Gt(e.host).host);
810
- Bt(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.transports.forEach((s) => {
811
- const r = s.prototype.name;
812
- this.transports.push(r), this._transportsByName[r] = s;
809
+ } else e.host && (e.hostname = Xt(e.host).host);
810
+ Ut(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.transports.forEach((s) => {
811
+ const n = s.prototype.name;
812
+ this.transports.push(n), this._transportsByName[n] = s;
813
813
  }), this.opts = Object.assign({
814
814
  path: "/engine.io",
815
815
  agent: !1,
@@ -824,13 +824,13 @@ class Y extends v {
824
824
  },
825
825
  transportOptions: {},
826
826
  closeOnBeforeunload: !1
827
- }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Os(this.opts.query)), Vt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
827
+ }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = fr(this.opts.query)), Qt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
828
828
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
829
829
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
830
830
  this._onClose("transport close", {
831
831
  description: "network connection lost"
832
832
  });
833
- }, Ot.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
833
+ }, Ct.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
834
834
  }
835
835
  /**
836
836
  * Creates transport of the given type.
@@ -841,7 +841,7 @@ class Y extends v {
841
841
  */
842
842
  createTransport(t) {
843
843
  const e = Object.assign({}, this.opts.query);
844
- e.EIO = je, e.transport = t, this.id && (e.sid = this.id);
844
+ e.EIO = es, e.transport = t, this.id && (e.sid = this.id);
845
845
  const s = Object.assign({}, this.opts, {
846
846
  query: e,
847
847
  socket: this,
@@ -863,7 +863,7 @@ class Y extends v {
863
863
  }, 0);
864
864
  return;
865
865
  }
866
- const t = this.opts.rememberUpgrade && Y.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
866
+ const t = this.opts.rememberUpgrade && X.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
867
867
  this.readyState = "opening";
868
868
  const e = this.createTransport(t);
869
869
  e.open(), this.setTransport(e);
@@ -882,7 +882,7 @@ class Y extends v {
882
882
  * @private
883
883
  */
884
884
  onOpen() {
885
- this.readyState = "open", Y.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
885
+ this.readyState = "open", X.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
886
886
  }
887
887
  /**
888
888
  * Handles a packet.
@@ -958,8 +958,8 @@ class Y extends v {
958
958
  return this.writeBuffer;
959
959
  let e = 1;
960
960
  for (let s = 0; s < this.writeBuffer.length; s++) {
961
- const r = this.writeBuffer[s].data;
962
- if (r && (e += Ts(r)), s > 0 && e > this._maxPayload)
961
+ const n = this.writeBuffer[s].data;
962
+ if (n && (e += lr(n)), s > 0 && e > this._maxPayload)
963
963
  return this.writeBuffer.slice(0, s);
964
964
  e += 2;
965
965
  }
@@ -979,7 +979,7 @@ class Y extends v {
979
979
  if (!this._pingTimeoutTime)
980
980
  return !0;
981
981
  const t = Date.now() > this._pingTimeoutTime;
982
- return t && (this._pingTimeoutTime = 0, Pt(() => {
982
+ return t && (this._pingTimeoutTime = 0, Dt(() => {
983
983
  this._onClose("ping timeout");
984
984
  }, this.setTimeoutFn)), t;
985
985
  }
@@ -1014,8 +1014,8 @@ class Y extends v {
1014
1014
  * @param {Function} fn - callback function.
1015
1015
  * @private
1016
1016
  */
1017
- _sendPacket(t, e, s, r) {
1018
- if (typeof e == "function" && (r = e, e = void 0), typeof s == "function" && (r = s, s = null), this.readyState === "closing" || this.readyState === "closed")
1017
+ _sendPacket(t, e, s, n) {
1018
+ if (typeof e == "function" && (n = e, e = void 0), typeof s == "function" && (n = s, s = null), this.readyState === "closing" || this.readyState === "closed")
1019
1019
  return;
1020
1020
  s = s || {}, s.compress = s.compress !== !1;
1021
1021
  const i = {
@@ -1023,7 +1023,7 @@ class Y extends v {
1023
1023
  data: e,
1024
1024
  options: s
1025
1025
  };
1026
- this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
1026
+ this.emitReserved("packetCreate", i), this.writeBuffer.push(i), n && this.once("flush", n), this.flush();
1027
1027
  }
1028
1028
  /**
1029
1029
  * Closes the connection.
@@ -1046,7 +1046,7 @@ class Y extends v {
1046
1046
  * @private
1047
1047
  */
1048
1048
  _onError(t) {
1049
- if (Y.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1049
+ if (X.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1050
1050
  return this.transports.shift(), this._open();
1051
1051
  this.emitReserved("error", t), this._onClose("transport error", t);
1052
1052
  }
@@ -1057,16 +1057,16 @@ class Y extends v {
1057
1057
  */
1058
1058
  _onClose(t, e) {
1059
1059
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
1060
- if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Vt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
- const s = Ot.indexOf(this._offlineEventListener);
1062
- s !== -1 && Ot.splice(s, 1);
1060
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Qt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
+ const s = Ct.indexOf(this._offlineEventListener);
1062
+ s !== -1 && Ct.splice(s, 1);
1063
1063
  }
1064
1064
  this.readyState = "closed", this.id = null, this.emitReserved("close", t, e), this.writeBuffer = [], this._prevBufferLen = 0;
1065
1065
  }
1066
1066
  }
1067
1067
  }
1068
- Y.protocol = je;
1069
- class Ms extends Y {
1068
+ X.protocol = es;
1069
+ class xr extends X {
1070
1070
  constructor() {
1071
1071
  super(...arguments), this._upgrades = [];
1072
1072
  }
@@ -1083,42 +1083,42 @@ class Ms extends Y {
1083
1083
  */
1084
1084
  _probe(t) {
1085
1085
  let e = this.createTransport(t), s = !1;
1086
- Y.priorWebsocketSuccess = !1;
1087
- const r = () => {
1088
- s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (w) => {
1086
+ X.priorWebsocketSuccess = !1;
1087
+ const n = () => {
1088
+ s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (g) => {
1089
1089
  if (!s)
1090
- if (w.type === "pong" && w.data === "probe") {
1090
+ if (g.type === "pong" && g.data === "probe") {
1091
1091
  if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
1092
1092
  return;
1093
- Y.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1094
- s || this.readyState !== "closed" && (y(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
1093
+ X.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1094
+ s || this.readyState !== "closed" && (c(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
1095
1095
  });
1096
1096
  } else {
1097
- const C = new Error("probe error");
1098
- C.transport = e.name, this.emitReserved("upgradeError", C);
1097
+ const v = new Error("probe error");
1098
+ v.transport = e.name, this.emitReserved("upgradeError", v);
1099
1099
  }
1100
1100
  }));
1101
1101
  };
1102
1102
  function i() {
1103
- s || (s = !0, y(), e.close(), e = null);
1103
+ s || (s = !0, c(), e.close(), e = null);
1104
1104
  }
1105
- const o = (w) => {
1106
- const C = new Error("probe error: " + w);
1107
- C.transport = e.name, i(), this.emitReserved("upgradeError", C);
1105
+ const o = (g) => {
1106
+ const v = new Error("probe error: " + g);
1107
+ v.transport = e.name, i(), this.emitReserved("upgradeError", v);
1108
1108
  };
1109
- function c() {
1109
+ function h() {
1110
1110
  o("transport closed");
1111
1111
  }
1112
- function u() {
1112
+ function d() {
1113
1113
  o("socket closed");
1114
1114
  }
1115
- function f(w) {
1116
- e && w.name !== e.name && i();
1115
+ function f(g) {
1116
+ e && g.name !== e.name && i();
1117
1117
  }
1118
- const y = () => {
1119
- e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", c), this.off("close", u), this.off("upgrading", f);
1118
+ const c = () => {
1119
+ e.removeListener("open", n), e.removeListener("error", o), e.removeListener("close", h), this.off("close", d), this.off("upgrading", f);
1120
1120
  };
1121
- e.once("open", r), e.once("error", o), e.once("close", c), this.once("close", u), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
1121
+ e.once("open", n), e.once("error", o), e.once("close", h), this.once("close", d), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
1122
1122
  s || e.open();
1123
1123
  }, 200) : e.open();
1124
1124
  }
@@ -1138,82 +1138,82 @@ class Ms extends Y {
1138
1138
  return e;
1139
1139
  }
1140
1140
  }
1141
- let Hs = class extends Ms {
1141
+ let Cr = class extends xr {
1142
1142
  constructor(t, e = {}) {
1143
- const s = typeof t == "object", r = s ? { ...t } : { ...e };
1144
- (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => Fs[i]).filter((i) => !!i)), super(s ? r : t, r);
1143
+ const s = typeof t == "object", n = s ? { ...t } : { ...e };
1144
+ (!n.transports || n.transports && typeof n.transports[0] == "string") && (n.transports = (n.transports || ["polling", "websocket", "webtransport"]).map((i) => Sr[i]).filter((i) => !!i)), super(s ? n : t, n);
1145
1145
  }
1146
1146
  };
1147
- function Gs(n, t = "", e) {
1148
- let s = n;
1149
- e = e || typeof location < "u" && location, n == null && (n = e.protocol + "//" + e.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = e.protocol + n : n = e.host + n), /^(https?|wss?):\/\//.test(n) || (typeof e < "u" ? n = e.protocol + "//" + n : n = "https://" + n), s = Gt(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1147
+ function Rr(r, t = "", e) {
1148
+ let s = r;
1149
+ e = e || typeof location < "u" && location, r == null && (r = e.protocol + "//" + e.host), typeof r == "string" && (r.charAt(0) === "/" && (r.charAt(1) === "/" ? r = e.protocol + r : r = e.host + r), /^(https?|wss?):\/\//.test(r) || (typeof e < "u" ? r = e.protocol + "//" + r : r = "https://" + r), s = Xt(r)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1150
1150
  const i = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
1151
1151
  return s.id = s.protocol + "://" + i + ":" + s.port + t, s.href = s.protocol + "://" + i + (e && e.port === s.port ? "" : ":" + s.port), s;
1152
1152
  }
1153
- const Vs = typeof ArrayBuffer == "function", Js = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, Ye = Object.prototype.toString, Ys = typeof Blob == "function" || typeof Blob < "u" && Ye.call(Blob) === "[object BlobConstructor]", Ws = typeof File == "function" || typeof File < "u" && Ye.call(File) === "[object FileConstructor]";
1154
- function me(n) {
1155
- return Vs && (n instanceof ArrayBuffer || Js(n)) || Ys && n instanceof Blob || Ws && n instanceof File;
1153
+ const $r = typeof ArrayBuffer == "function", Nr = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r.buffer instanceof ArrayBuffer, as = Object.prototype.toString, Pr = typeof Blob == "function" || typeof Blob < "u" && as.call(Blob) === "[object BlobConstructor]", Br = typeof File == "function" || typeof File < "u" && as.call(File) === "[object FileConstructor]";
1154
+ function ve(r) {
1155
+ return $r && (r instanceof ArrayBuffer || Nr(r)) || Pr && r instanceof Blob || Br && r instanceof File;
1156
1156
  }
1157
- function It(n, t) {
1158
- if (!n || typeof n != "object")
1157
+ function Rt(r, t) {
1158
+ if (!r || typeof r != "object")
1159
1159
  return !1;
1160
- if (Array.isArray(n)) {
1161
- for (let e = 0, s = n.length; e < s; e++)
1162
- if (It(n[e]))
1160
+ if (Array.isArray(r)) {
1161
+ for (let e = 0, s = r.length; e < s; e++)
1162
+ if (Rt(r[e]))
1163
1163
  return !0;
1164
1164
  return !1;
1165
1165
  }
1166
- if (me(n))
1166
+ if (ve(r))
1167
1167
  return !0;
1168
- if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
1169
- return It(n.toJSON(), !0);
1170
- for (const e in n)
1171
- if (Object.prototype.hasOwnProperty.call(n, e) && It(n[e]))
1168
+ if (r.toJSON && typeof r.toJSON == "function" && arguments.length === 1)
1169
+ return Rt(r.toJSON(), !0);
1170
+ for (const e in r)
1171
+ if (Object.prototype.hasOwnProperty.call(r, e) && Rt(r[e]))
1172
1172
  return !0;
1173
1173
  return !1;
1174
1174
  }
1175
- function Ks(n) {
1176
- const t = [], e = n.data, s = n;
1177
- return s.data = Jt(e, t), s.attachments = t.length, { packet: s, buffers: t };
1175
+ function Lr(r) {
1176
+ const t = [], e = r.data, s = r;
1177
+ return s.data = Zt(e, t), s.attachments = t.length, { packet: s, buffers: t };
1178
1178
  }
1179
- function Jt(n, t) {
1180
- if (!n)
1181
- return n;
1182
- if (me(n)) {
1179
+ function Zt(r, t) {
1180
+ if (!r)
1181
+ return r;
1182
+ if (ve(r)) {
1183
1183
  const e = { _placeholder: !0, num: t.length };
1184
- return t.push(n), e;
1185
- } else if (Array.isArray(n)) {
1186
- const e = new Array(n.length);
1187
- for (let s = 0; s < n.length; s++)
1188
- e[s] = Jt(n[s], t);
1184
+ return t.push(r), e;
1185
+ } else if (Array.isArray(r)) {
1186
+ const e = new Array(r.length);
1187
+ for (let s = 0; s < r.length; s++)
1188
+ e[s] = Zt(r[s], t);
1189
1189
  return e;
1190
- } else if (typeof n == "object" && !(n instanceof Date)) {
1190
+ } else if (typeof r == "object" && !(r instanceof Date)) {
1191
1191
  const e = {};
1192
- for (const s in n)
1193
- Object.prototype.hasOwnProperty.call(n, s) && (e[s] = Jt(n[s], t));
1192
+ for (const s in r)
1193
+ Object.prototype.hasOwnProperty.call(r, s) && (e[s] = Zt(r[s], t));
1194
1194
  return e;
1195
1195
  }
1196
- return n;
1196
+ return r;
1197
1197
  }
1198
- function zs(n, t) {
1199
- return n.data = Yt(n.data, t), delete n.attachments, n;
1198
+ function Fr(r, t) {
1199
+ return r.data = te(r.data, t), delete r.attachments, r;
1200
1200
  }
1201
- function Yt(n, t) {
1202
- if (!n)
1203
- return n;
1204
- if (n && n._placeholder === !0) {
1205
- if (typeof n.num == "number" && n.num >= 0 && n.num < t.length)
1206
- return t[n.num];
1201
+ function te(r, t) {
1202
+ if (!r)
1203
+ return r;
1204
+ if (r && r._placeholder === !0) {
1205
+ if (typeof r.num == "number" && r.num >= 0 && r.num < t.length)
1206
+ return t[r.num];
1207
1207
  throw new Error("illegal attachments");
1208
- } else if (Array.isArray(n))
1209
- for (let e = 0; e < n.length; e++)
1210
- n[e] = Yt(n[e], t);
1211
- else if (typeof n == "object")
1212
- for (const e in n)
1213
- Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Yt(n[e], t));
1214
- return n;
1208
+ } else if (Array.isArray(r))
1209
+ for (let e = 0; e < r.length; e++)
1210
+ r[e] = te(r[e], t);
1211
+ else if (typeof r == "object")
1212
+ for (const e in r)
1213
+ Object.prototype.hasOwnProperty.call(r, e) && (r[e] = te(r[e], t));
1214
+ return r;
1215
1215
  }
1216
- const Xs = [
1216
+ const qr = [
1217
1217
  "connect",
1218
1218
  // used on the client side
1219
1219
  "connect_error",
@@ -1227,11 +1227,11 @@ const Xs = [
1227
1227
  "removeListener"
1228
1228
  // used by the Node.js EventEmitter
1229
1229
  ];
1230
- var g;
1231
- (function(n) {
1232
- n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
1233
- })(g || (g = {}));
1234
- class Qs {
1230
+ var w;
1231
+ (function(r) {
1232
+ r[r.CONNECT = 0] = "CONNECT", r[r.DISCONNECT = 1] = "DISCONNECT", r[r.EVENT = 2] = "EVENT", r[r.ACK = 3] = "ACK", r[r.CONNECT_ERROR = 4] = "CONNECT_ERROR", r[r.BINARY_EVENT = 5] = "BINARY_EVENT", r[r.BINARY_ACK = 6] = "BINARY_ACK";
1233
+ })(w || (w = {}));
1234
+ class Dr {
1235
1235
  /**
1236
1236
  * Encoder constructor
1237
1237
  *
@@ -1247,8 +1247,8 @@ class Qs {
1247
1247
  * @param {Object} obj - packet object
1248
1248
  */
1249
1249
  encode(t) {
1250
- return (t.type === g.EVENT || t.type === g.ACK) && It(t) ? this.encodeAsBinary({
1251
- type: t.type === g.EVENT ? g.BINARY_EVENT : g.BINARY_ACK,
1250
+ return (t.type === w.EVENT || t.type === w.ACK) && Rt(t) ? this.encodeAsBinary({
1251
+ type: t.type === w.EVENT ? w.BINARY_EVENT : w.BINARY_ACK,
1252
1252
  nsp: t.nsp,
1253
1253
  data: t.data,
1254
1254
  id: t.id
@@ -1259,7 +1259,7 @@ class Qs {
1259
1259
  */
1260
1260
  encodeAsString(t) {
1261
1261
  let e = "" + t.type;
1262
- return (t.type === g.BINARY_EVENT || t.type === g.BINARY_ACK) && (e += t.attachments + "-"), t.nsp && t.nsp !== "/" && (e += t.nsp + ","), t.id != null && (e += t.id), t.data != null && (e += JSON.stringify(t.data, this.replacer)), e;
1262
+ return (t.type === w.BINARY_EVENT || t.type === w.BINARY_ACK) && (e += t.attachments + "-"), t.nsp && t.nsp !== "/" && (e += t.nsp + ","), t.id != null && (e += t.id), t.data != null && (e += JSON.stringify(t.data, this.replacer)), e;
1263
1263
  }
1264
1264
  /**
1265
1265
  * Encode packet as 'buffer sequence' by removing blobs, and
@@ -1267,11 +1267,11 @@ class Qs {
1267
1267
  * a list of buffers.
1268
1268
  */
1269
1269
  encodeAsBinary(t) {
1270
- const e = Ks(t), s = this.encodeAsString(e.packet), r = e.buffers;
1271
- return r.unshift(s), r;
1270
+ const e = Lr(t), s = this.encodeAsString(e.packet), n = e.buffers;
1271
+ return n.unshift(s), n;
1272
1272
  }
1273
1273
  }
1274
- class ge extends v {
1274
+ class Te extends E {
1275
1275
  /**
1276
1276
  * Decoder constructor
1277
1277
  */
@@ -1292,9 +1292,9 @@ class ge extends v {
1292
1292
  if (this.reconstructor)
1293
1293
  throw new Error("got plaintext data when reconstructing a packet");
1294
1294
  e = this.decodeString(t);
1295
- const s = e.type === g.BINARY_EVENT;
1296
- s || e.type === g.BINARY_ACK ? (e.type = s ? g.EVENT : g.ACK, this.reconstructor = new Zs(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
- } else if (me(t) || t.base64)
1295
+ const s = e.type === w.BINARY_EVENT;
1296
+ s || e.type === w.BINARY_ACK ? (e.type = s ? w.EVENT : w.ACK, this.reconstructor = new Ur(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
+ } else if (ve(t) || t.base64)
1298
1298
  if (this.reconstructor)
1299
1299
  e = this.reconstructor.takeBinaryData(t), e && (this.reconstructor = null, super.emitReserved("decoded", e));
1300
1300
  else
@@ -1313,21 +1313,21 @@ class ge extends v {
1313
1313
  const s = {
1314
1314
  type: Number(t.charAt(0))
1315
1315
  };
1316
- if (g[s.type] === void 0)
1316
+ if (w[s.type] === void 0)
1317
1317
  throw new Error("unknown packet type " + s.type);
1318
- if (s.type === g.BINARY_EVENT || s.type === g.BINARY_ACK) {
1318
+ if (s.type === w.BINARY_EVENT || s.type === w.BINARY_ACK) {
1319
1319
  const i = e + 1;
1320
1320
  for (; t.charAt(++e) !== "-" && e != t.length; )
1321
1321
  ;
1322
1322
  const o = t.substring(i, e);
1323
1323
  if (o != Number(o) || t.charAt(e) !== "-")
1324
1324
  throw new Error("Illegal attachments");
1325
- const c = Number(o);
1326
- if (!tn(c) || c < 0)
1325
+ const h = Number(o);
1326
+ if (!jr(h) || h < 0)
1327
1327
  throw new Error("Illegal attachments");
1328
- if (c > this.opts.maxAttachments)
1328
+ if (h > this.opts.maxAttachments)
1329
1329
  throw new Error("too many attachments");
1330
- s.attachments = c;
1330
+ s.attachments = h;
1331
1331
  }
1332
1332
  if (t.charAt(e + 1) === "/") {
1333
1333
  const i = e + 1;
@@ -1336,8 +1336,8 @@ class ge extends v {
1336
1336
  s.nsp = t.substring(i, e);
1337
1337
  } else
1338
1338
  s.nsp = "/";
1339
- const r = t.charAt(e + 1);
1340
- if (r !== "" && Number(r) == r) {
1339
+ const n = t.charAt(e + 1);
1340
+ if (n !== "" && Number(n) == n) {
1341
1341
  const i = e + 1;
1342
1342
  for (; ++e; ) {
1343
1343
  const o = t.charAt(e);
@@ -1352,7 +1352,7 @@ class ge extends v {
1352
1352
  }
1353
1353
  if (t.charAt(++e)) {
1354
1354
  const i = this.tryParse(t.substr(e));
1355
- if (ge.isPayloadValid(s.type, i))
1355
+ if (Te.isPayloadValid(s.type, i))
1356
1356
  s.data = i;
1357
1357
  else
1358
1358
  throw new Error("invalid payload");
@@ -1368,17 +1368,17 @@ class ge extends v {
1368
1368
  }
1369
1369
  static isPayloadValid(t, e) {
1370
1370
  switch (t) {
1371
- case g.CONNECT:
1372
- return Oe(e);
1373
- case g.DISCONNECT:
1371
+ case w.CONNECT:
1372
+ return Le(e);
1373
+ case w.DISCONNECT:
1374
1374
  return e === void 0;
1375
- case g.CONNECT_ERROR:
1376
- return typeof e == "string" || Oe(e);
1377
- case g.EVENT:
1378
- case g.BINARY_EVENT:
1379
- return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Xs.indexOf(e[0]) === -1);
1380
- case g.ACK:
1381
- case g.BINARY_ACK:
1375
+ case w.CONNECT_ERROR:
1376
+ return typeof e == "string" || Le(e);
1377
+ case w.EVENT:
1378
+ case w.BINARY_EVENT:
1379
+ return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && qr.indexOf(e[0]) === -1);
1380
+ case w.ACK:
1381
+ case w.BINARY_ACK:
1382
1382
  return Array.isArray(e);
1383
1383
  }
1384
1384
  }
@@ -1389,7 +1389,7 @@ class ge extends v {
1389
1389
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1390
1390
  }
1391
1391
  }
1392
- class Zs {
1392
+ class Ur {
1393
1393
  constructor(t) {
1394
1394
  this.packet = t, this.buffers = [], this.reconPack = t;
1395
1395
  }
@@ -1403,7 +1403,7 @@ class Zs {
1403
1403
  */
1404
1404
  takeBinaryData(t) {
1405
1405
  if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
1406
- const e = zs(this.reconPack, this.buffers);
1406
+ const e = Fr(this.reconPack, this.buffers);
1407
1407
  return this.finishedReconstruction(), e;
1408
1408
  }
1409
1409
  return null;
@@ -1415,26 +1415,26 @@ class Zs {
1415
1415
  this.reconPack = null, this.buffers = [];
1416
1416
  }
1417
1417
  }
1418
- const tn = Number.isInteger || function(n) {
1419
- return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1418
+ const jr = Number.isInteger || function(r) {
1419
+ return typeof r == "number" && isFinite(r) && Math.floor(r) === r;
1420
1420
  };
1421
- function Oe(n) {
1422
- return Object.prototype.toString.call(n) === "[object Object]";
1421
+ function Le(r) {
1422
+ return Object.prototype.toString.call(r) === "[object Object]";
1423
1423
  }
1424
- const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1424
+ const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1425
1425
  __proto__: null,
1426
- Decoder: ge,
1427
- Encoder: Qs,
1426
+ Decoder: Te,
1427
+ Encoder: Dr,
1428
1428
  get PacketType() {
1429
- return g;
1429
+ return w;
1430
1430
  }
1431
1431
  }, Symbol.toStringTag, { value: "Module" }));
1432
- function $(n, t, e) {
1433
- return n.on(t, e), function() {
1434
- n.off(t, e);
1432
+ function N(r, t, e) {
1433
+ return r.on(t, e), function() {
1434
+ r.off(t, e);
1435
1435
  };
1436
1436
  }
1437
- const sn = Object.freeze({
1437
+ const Vr = Object.freeze({
1438
1438
  connect: 1,
1439
1439
  connect_error: 1,
1440
1440
  disconnect: 1,
@@ -1443,7 +1443,7 @@ const sn = Object.freeze({
1443
1443
  newListener: 1,
1444
1444
  removeListener: 1
1445
1445
  });
1446
- class We extends v {
1446
+ class cs extends E {
1447
1447
  /**
1448
1448
  * `Socket` constructor.
1449
1449
  */
@@ -1477,10 +1477,10 @@ class We extends v {
1477
1477
  return;
1478
1478
  const t = this.io;
1479
1479
  this.subs = [
1480
- $(t, "open", this.onopen.bind(this)),
1481
- $(t, "packet", this.onpacket.bind(this)),
1482
- $(t, "error", this.onerror.bind(this)),
1483
- $(t, "close", this.onclose.bind(this))
1480
+ N(t, "open", this.onopen.bind(this)),
1481
+ N(t, "packet", this.onpacket.bind(this)),
1482
+ N(t, "error", this.onerror.bind(this)),
1483
+ N(t, "close", this.onclose.bind(this))
1484
1484
  ];
1485
1485
  }
1486
1486
  /**
@@ -1558,39 +1558,39 @@ class We extends v {
1558
1558
  * @return self
1559
1559
  */
1560
1560
  emit(t, ...e) {
1561
- var s, r, i;
1562
- if (sn.hasOwnProperty(t))
1561
+ var s, n, i;
1562
+ if (Vr.hasOwnProperty(t))
1563
1563
  throw new Error('"' + t.toString() + '" is a reserved event name');
1564
1564
  if (e.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1565
1565
  return this._addToQueue(e), this;
1566
1566
  const o = {
1567
- type: g.EVENT,
1567
+ type: w.EVENT,
1568
1568
  data: e
1569
1569
  };
1570
1570
  if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
1571
- const y = this.ids++, w = e.pop();
1572
- this._registerAckCallback(y, w), o.id = y;
1571
+ const c = this.ids++, g = e.pop();
1572
+ this._registerAckCallback(c, g), o.id = c;
1573
1573
  }
1574
- const c = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable, u = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
1575
- return this.flags.volatile && !c || (u ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1574
+ const h = (n = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || n === void 0 ? void 0 : n.writable, d = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
1575
+ return this.flags.volatile && !h || (d ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1576
1576
  }
1577
1577
  /**
1578
1578
  * @private
1579
1579
  */
1580
1580
  _registerAckCallback(t, e) {
1581
1581
  var s;
1582
- const r = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
1583
- if (r === void 0) {
1582
+ const n = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
1583
+ if (n === void 0) {
1584
1584
  this.acks[t] = e;
1585
1585
  return;
1586
1586
  }
1587
1587
  const i = this.io.setTimeoutFn(() => {
1588
1588
  delete this.acks[t];
1589
- for (let c = 0; c < this.sendBuffer.length; c++)
1590
- this.sendBuffer[c].id === t && this.sendBuffer.splice(c, 1);
1589
+ for (let h = 0; h < this.sendBuffer.length; h++)
1590
+ this.sendBuffer[h].id === t && this.sendBuffer.splice(h, 1);
1591
1591
  e.call(this, new Error("operation has timed out"));
1592
- }, r), o = (...c) => {
1593
- this.io.clearTimeoutFn(i), e.apply(this, c);
1592
+ }, n), o = (...h) => {
1593
+ this.io.clearTimeoutFn(i), e.apply(this, h);
1594
1594
  };
1595
1595
  o.withError = !0, this.acks[t] = o;
1596
1596
  }
@@ -1611,8 +1611,8 @@ class We extends v {
1611
1611
  * @return a Promise that will be fulfilled when the server acknowledges the event
1612
1612
  */
1613
1613
  emitWithAck(t, ...e) {
1614
- return new Promise((s, r) => {
1615
- const i = (o, c) => o ? r(o) : s(c);
1614
+ return new Promise((s, n) => {
1615
+ const i = (o, h) => o ? n(o) : s(h);
1616
1616
  i.withError = !0, e.push(i), this.emit(t, ...e);
1617
1617
  });
1618
1618
  }
@@ -1631,7 +1631,7 @@ class We extends v {
1631
1631
  args: t,
1632
1632
  flags: Object.assign({ fromQueue: !0 }, this.flags)
1633
1633
  };
1634
- t.push((r, ...i) => (this._queue[0], r !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), e && e(r)) : (this._queue.shift(), e && e(null, ...i)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
1634
+ t.push((n, ...i) => (this._queue[0], n !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), e && e(n)) : (this._queue.shift(), e && e(null, ...i)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
1635
1635
  }
1636
1636
  /**
1637
1637
  * Send the first packet of the queue, and wait for an acknowledgement from the server.
@@ -1672,7 +1672,7 @@ class We extends v {
1672
1672
  */
1673
1673
  _sendConnectPacket(t) {
1674
1674
  this.packet({
1675
- type: g.CONNECT,
1675
+ type: w.CONNECT,
1676
1676
  data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, t) : t
1677
1677
  });
1678
1678
  }
@@ -1718,21 +1718,21 @@ class We extends v {
1718
1718
  onpacket(t) {
1719
1719
  if (t.nsp === this.nsp)
1720
1720
  switch (t.type) {
1721
- case g.CONNECT:
1721
+ case w.CONNECT:
1722
1722
  t.data && t.data.sid ? this.onconnect(t.data.sid, t.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
1723
1723
  break;
1724
- case g.EVENT:
1725
- case g.BINARY_EVENT:
1724
+ case w.EVENT:
1725
+ case w.BINARY_EVENT:
1726
1726
  this.onevent(t);
1727
1727
  break;
1728
- case g.ACK:
1729
- case g.BINARY_ACK:
1728
+ case w.ACK:
1729
+ case w.BINARY_ACK:
1730
1730
  this.onack(t);
1731
1731
  break;
1732
- case g.DISCONNECT:
1732
+ case w.DISCONNECT:
1733
1733
  this.ondisconnect();
1734
1734
  break;
1735
- case g.CONNECT_ERROR:
1735
+ case w.CONNECT_ERROR:
1736
1736
  this.destroy();
1737
1737
  const s = new Error(t.data.message);
1738
1738
  s.data = t.data.data, this.emitReserved("connect_error", s);
@@ -1765,11 +1765,11 @@ class We extends v {
1765
1765
  ack(t) {
1766
1766
  const e = this;
1767
1767
  let s = !1;
1768
- return function(...r) {
1768
+ return function(...n) {
1769
1769
  s || (s = !0, e.packet({
1770
- type: g.ACK,
1770
+ type: w.ACK,
1771
1771
  id: t,
1772
- data: r
1772
+ data: n
1773
1773
  }));
1774
1774
  };
1775
1775
  }
@@ -1836,7 +1836,7 @@ class We extends v {
1836
1836
  * @return self
1837
1837
  */
1838
1838
  disconnect() {
1839
- return this.connected && this.packet({ type: g.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1839
+ return this.connected && this.packet({ type: w.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1840
1840
  }
1841
1841
  /**
1842
1842
  * Alias for {@link disconnect()}.
@@ -2035,39 +2035,39 @@ class We extends v {
2035
2035
  }
2036
2036
  }
2037
2037
  }
2038
- function ct(n) {
2039
- n = n || {}, this.ms = n.min || 100, this.max = n.max || 1e4, this.factor = n.factor || 2, this.jitter = n.jitter > 0 && n.jitter <= 1 ? n.jitter : 0, this.attempts = 0;
2038
+ function ft(r) {
2039
+ r = r || {}, this.ms = r.min || 100, this.max = r.max || 1e4, this.factor = r.factor || 2, this.jitter = r.jitter > 0 && r.jitter <= 1 ? r.jitter : 0, this.attempts = 0;
2040
2040
  }
2041
- ct.prototype.duration = function() {
2042
- var n = this.ms * Math.pow(this.factor, this.attempts++);
2041
+ ft.prototype.duration = function() {
2042
+ var r = this.ms * Math.pow(this.factor, this.attempts++);
2043
2043
  if (this.jitter) {
2044
- var t = Math.random(), e = Math.floor(t * this.jitter * n);
2045
- n = Math.floor(t * 10) & 1 ? n + e : n - e;
2044
+ var t = Math.random(), e = Math.floor(t * this.jitter * r);
2045
+ r = Math.floor(t * 10) & 1 ? r + e : r - e;
2046
2046
  }
2047
- return Math.min(n, this.max) | 0;
2047
+ return Math.min(r, this.max) | 0;
2048
2048
  };
2049
- ct.prototype.reset = function() {
2049
+ ft.prototype.reset = function() {
2050
2050
  this.attempts = 0;
2051
2051
  };
2052
- ct.prototype.setMin = function(n) {
2053
- this.ms = n;
2052
+ ft.prototype.setMin = function(r) {
2053
+ this.ms = r;
2054
2054
  };
2055
- ct.prototype.setMax = function(n) {
2056
- this.max = n;
2055
+ ft.prototype.setMax = function(r) {
2056
+ this.max = r;
2057
2057
  };
2058
- ct.prototype.setJitter = function(n) {
2059
- this.jitter = n;
2058
+ ft.prototype.setJitter = function(r) {
2059
+ this.jitter = r;
2060
2060
  };
2061
- class Wt extends v {
2061
+ class ee extends E {
2062
2062
  constructor(t, e) {
2063
2063
  var s;
2064
- super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Bt(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new ct({
2064
+ super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Ut(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new ft({
2065
2065
  min: this.reconnectionDelay(),
2066
2066
  max: this.reconnectionDelayMax(),
2067
2067
  jitter: this.randomizationFactor()
2068
2068
  }), this.timeout(e.timeout == null ? 2e4 : e.timeout), this._readyState = "closed", this.uri = t;
2069
- const r = e.parser || en;
2070
- this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
2069
+ const n = e.parser || Mr;
2070
+ this.encoder = new n.Encoder(), this.decoder = new n.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
2071
2071
  }
2072
2072
  reconnection(t) {
2073
2073
  return arguments.length ? (this._reconnection = !!t, t || (this.skipReconnect = !0), this) : this._reconnection;
@@ -2109,23 +2109,23 @@ class Wt extends v {
2109
2109
  open(t) {
2110
2110
  if (~this._readyState.indexOf("open"))
2111
2111
  return this;
2112
- this.engine = new Hs(this.uri, this.opts);
2112
+ this.engine = new Cr(this.uri, this.opts);
2113
2113
  const e = this.engine, s = this;
2114
2114
  this._readyState = "opening", this.skipReconnect = !1;
2115
- const r = $(e, "open", function() {
2115
+ const n = N(e, "open", function() {
2116
2116
  s.onopen(), t && t();
2117
- }), i = (c) => {
2118
- this.cleanup(), this._readyState = "closed", this.emitReserved("error", c), t ? t(c) : this.maybeReconnectOnOpen();
2119
- }, o = $(e, "error", i);
2117
+ }), i = (h) => {
2118
+ this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), t ? t(h) : this.maybeReconnectOnOpen();
2119
+ }, o = N(e, "error", i);
2120
2120
  if (this._timeout !== !1) {
2121
- const c = this._timeout, u = this.setTimeoutFn(() => {
2122
- r(), i(new Error("timeout")), e.close();
2123
- }, c);
2124
- this.opts.autoUnref && u.unref(), this.subs.push(() => {
2125
- this.clearTimeoutFn(u);
2121
+ const h = this._timeout, d = this.setTimeoutFn(() => {
2122
+ n(), i(new Error("timeout")), e.close();
2123
+ }, h);
2124
+ this.opts.autoUnref && d.unref(), this.subs.push(() => {
2125
+ this.clearTimeoutFn(d);
2126
2126
  });
2127
2127
  }
2128
- return this.subs.push(r), this.subs.push(o), this;
2128
+ return this.subs.push(n), this.subs.push(o), this;
2129
2129
  }
2130
2130
  /**
2131
2131
  * Alias for open()
@@ -2145,12 +2145,12 @@ class Wt extends v {
2145
2145
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
2146
2146
  const t = this.engine;
2147
2147
  this.subs.push(
2148
- $(t, "ping", this.onping.bind(this)),
2149
- $(t, "data", this.ondata.bind(this)),
2150
- $(t, "error", this.onerror.bind(this)),
2151
- $(t, "close", this.onclose.bind(this)),
2148
+ N(t, "ping", this.onping.bind(this)),
2149
+ N(t, "data", this.ondata.bind(this)),
2150
+ N(t, "error", this.onerror.bind(this)),
2151
+ N(t, "close", this.onclose.bind(this)),
2152
2152
  // @ts-ignore
2153
- $(this.decoder, "decoded", this.ondecoded.bind(this))
2153
+ N(this.decoder, "decoded", this.ondecoded.bind(this))
2154
2154
  );
2155
2155
  }
2156
2156
  /**
@@ -2179,7 +2179,7 @@ class Wt extends v {
2179
2179
  * @private
2180
2180
  */
2181
2181
  ondecoded(t) {
2182
- Pt(() => {
2182
+ Dt(() => {
2183
2183
  this.emitReserved("packet", t);
2184
2184
  }, this.setTimeoutFn);
2185
2185
  }
@@ -2199,7 +2199,7 @@ class Wt extends v {
2199
2199
  */
2200
2200
  socket(t, e) {
2201
2201
  let s = this.nsps[t];
2202
- return s ? this._autoConnect && !s.active && s.connect() : (s = new We(this, t, e), this.nsps[t] = s), s;
2202
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new cs(this, t, e), this.nsps[t] = s), s;
2203
2203
  }
2204
2204
  /**
2205
2205
  * Called upon a socket close.
@@ -2277,8 +2277,8 @@ class Wt extends v {
2277
2277
  const e = this.backoff.duration();
2278
2278
  this._reconnecting = !0;
2279
2279
  const s = this.setTimeoutFn(() => {
2280
- t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((r) => {
2281
- r ? (t._reconnecting = !1, t.reconnect(), this.emitReserved("reconnect_error", r)) : t.onreconnect();
2280
+ t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((n) => {
2281
+ n ? (t._reconnecting = !1, t.reconnect(), this.emitReserved("reconnect_error", n)) : t.onreconnect();
2282
2282
  }));
2283
2283
  }, e);
2284
2284
  this.opts.autoUnref && s.unref(), this.subs.push(() => {
@@ -2296,45 +2296,108 @@ class Wt extends v {
2296
2296
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
2297
2297
  }
2298
2298
  }
2299
- const ht = {};
2300
- function pt(n, t) {
2301
- typeof n == "object" && (t = n, n = void 0), t = t || {};
2302
- const e = Gs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = ht[r] && i in ht[r].nsps, c = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2303
- let u;
2304
- return c ? u = new Wt(s, t) : (ht[r] || (ht[r] = new Wt(s, t)), u = ht[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
2299
+ const pt = {};
2300
+ function bt(r, t) {
2301
+ typeof r == "object" && (t = r, r = void 0), t = t || {};
2302
+ const e = Rr(r, t.path || "/socket.io"), s = e.source, n = e.id, i = e.path, o = pt[n] && i in pt[n].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2303
+ let d;
2304
+ return h ? d = new ee(s, t) : (pt[n] || (pt[n] = new ee(s, t)), d = pt[n]), e.query && !t.query && (t.query = e.queryKey), d.socket(e.path, t);
2305
2305
  }
2306
- Object.assign(pt, {
2307
- Manager: Wt,
2308
- Socket: We,
2309
- io: pt,
2310
- connect: pt
2306
+ Object.assign(bt, {
2307
+ Manager: ee,
2308
+ Socket: cs,
2309
+ io: bt,
2310
+ connect: bt
2311
2311
  });
2312
- const Kt = "thatopen/document@1", Ie = "document.json", Ae = () => `v-${Date.now()}`;
2313
- function nn(n) {
2314
- return String(n._id ?? n.id ?? "");
2312
+ const qt = "thatopen/document@1", Fe = "document.json", Gr = [
2313
+ "pdf",
2314
+ "txt",
2315
+ "md",
2316
+ "json",
2317
+ "csv",
2318
+ "tsv",
2319
+ "frag"
2320
+ ], qe = () => `v-${Date.now()}`;
2321
+ function At(r) {
2322
+ return String(r._id ?? r.id ?? "");
2315
2323
  }
2316
- var yt, zt;
2317
- class Ke {
2324
+ var tt, ls, se;
2325
+ class hs {
2318
2326
  constructor(t, e) {
2319
- b(this, yt);
2327
+ b(this, tt);
2320
2328
  this.client = t, this.projectId = e;
2321
2329
  }
2330
+ /**
2331
+ * Every document of the project: the folders that carry a descriptor.
2332
+ * Plain folders and loose files simply do not appear. One folder listing
2333
+ * for the project plus one file listing and one descriptor download per
2334
+ * folder, fetched in parallel — the storage offers nothing cheaper yet.
2335
+ */
2336
+ async list() {
2337
+ const t = await this.client.listFolders({
2338
+ projectId: this.projectId
2339
+ });
2340
+ return (await Promise.all(
2341
+ t.map(async (s) => {
2342
+ const n = At(s), i = await this.descriptor(n);
2343
+ return i ? { folderId: n, descriptor: i } : null;
2344
+ })
2345
+ )).filter((s) => s !== null);
2346
+ }
2347
+ /**
2348
+ * Converts a loose file into a document: creates the document folder next
2349
+ * to the file, moves the file inside (moving preserves its id), and writes
2350
+ * the descriptor with the file as `native` — and as `views[0]` too when its
2351
+ * format views itself ({@link SELF_VIEWING_FORMATS}; override per call with
2352
+ * `selfView`).
2353
+ *
2354
+ * A file that carries a processed derivative (the old `derivedFileId` link
2355
+ * in its version metadata — an IFC's frag, a LAS's potree) brings it along:
2356
+ * the derivative moves into the same folder and becomes a view, so the
2357
+ * document is born ready to visualize and the link concept retires.
2358
+ */
2359
+ async fromFile(t, e) {
2360
+ const s = await this.client.getFile(t), n = String(s.name ?? ""), i = De(n, s.fileExtension), o = (e == null ? void 0 : e.name) ?? n.replace(/\.[^.]+$/, "") ?? n, h = await this.client.createFolder(
2361
+ o,
2362
+ s.folderId ? String(s.folderId) : void 0,
2363
+ this.projectId
2364
+ ), d = At(h);
2365
+ await this.client.updateFile(t, { parentFolderId: d });
2366
+ const f = [], c = await a(this, tt, ls).call(this, s);
2367
+ if (c)
2368
+ try {
2369
+ const V = await this.client.getFile(c);
2370
+ await this.client.updateFile(c, { parentFolderId: d }), f.push({
2371
+ fileId: c,
2372
+ format: De(String(V.name ?? ""), V.fileExtension)
2373
+ });
2374
+ } catch {
2375
+ }
2376
+ ((e == null ? void 0 : e.selfView) ?? Gr.includes(i)) && f.push({ fileId: t, format: i });
2377
+ const v = {
2378
+ schema: qt,
2379
+ name: o,
2380
+ native: { fileId: t, format: i },
2381
+ views: f
2382
+ };
2383
+ return await this.setDescriptor(d, v), { folderId: d, descriptor: v };
2384
+ }
2322
2385
  /**
2323
2386
  * The document's descriptor, read and validated, or null when the folder
2324
2387
  * has none yet (an old folder, or a plain folder that is not a document).
2325
2388
  */
2326
2389
  async descriptor(t) {
2327
- const e = await a(this, yt, zt).call(this, t);
2390
+ const e = await a(this, tt, se).call(this, t);
2328
2391
  if (!e) return null;
2329
- const r = await (await this.client.downloadFile(e.id)).text();
2330
- if (!r.trim()) return null;
2392
+ const n = await (await this.client.downloadFile(e.id)).text();
2393
+ if (!n.trim()) return null;
2331
2394
  let i;
2332
2395
  try {
2333
- i = JSON.parse(r);
2396
+ i = JSON.parse(n);
2334
2397
  } catch {
2335
2398
  return null;
2336
2399
  }
2337
- return rn(i);
2400
+ return Hr(i);
2338
2401
  }
2339
2402
  /**
2340
2403
  * The first view whose format appears in `formats` — searched in the ORDER
@@ -2345,8 +2408,8 @@ class Ke {
2345
2408
  async view(t, e) {
2346
2409
  const s = await this.descriptor(t);
2347
2410
  if (!s) return null;
2348
- for (const r of e) {
2349
- const i = s.views.find((o) => o.format === r);
2411
+ for (const n of e) {
2412
+ const i = s.views.find((o) => o.format === n);
2350
2413
  if (i) return i;
2351
2414
  }
2352
2415
  return null;
@@ -2364,7 +2427,7 @@ class Ke {
2364
2427
  "This folder has no document descriptor yet: call setDescriptor first."
2365
2428
  );
2366
2429
  s.views = [
2367
- ...s.views.filter((r) => r.format !== e.format),
2430
+ ...s.views.filter((n) => n.format !== e.format),
2368
2431
  e
2369
2432
  ], await this.setDescriptor(t, s);
2370
2433
  }
@@ -2372,129 +2435,148 @@ class Ke {
2372
2435
  async setDescriptor(t, e) {
2373
2436
  const s = {
2374
2437
  ...e,
2375
- schema: Kt,
2438
+ schema: qt,
2376
2439
  views: e.views ?? []
2377
- }, r = new Blob([JSON.stringify(s)], {
2440
+ }, n = new Blob([JSON.stringify(s)], {
2378
2441
  type: "application/json"
2379
- }), i = await a(this, yt, zt).call(this, t);
2442
+ }), i = await a(this, tt, se).call(this, t);
2380
2443
  if (i) {
2381
2444
  await this.client.updateFile(i.id, {
2382
- file: r,
2383
- versionTag: Ae()
2445
+ file: n,
2446
+ versionTag: qe()
2384
2447
  });
2385
2448
  return;
2386
2449
  }
2387
2450
  await this.client.createFile({
2388
- file: r,
2389
- name: Ie,
2390
- versionTag: Ae(),
2451
+ file: n,
2452
+ name: Fe,
2453
+ versionTag: qe(),
2391
2454
  parentFolderId: t,
2392
2455
  projectId: this.projectId
2393
2456
  });
2394
2457
  }
2395
2458
  }
2396
- yt = new WeakSet(), zt = async function(t) {
2459
+ tt = new WeakSet(), ls = async function(t) {
2460
+ const e = [...t.versions ?? []].sort(
2461
+ (s, n) => String(n.createdAt ?? "").localeCompare(String(s.createdAt ?? ""))
2462
+ );
2463
+ for (const s of e)
2464
+ try {
2465
+ const n = await this.client.getFileVersionMetadata(
2466
+ At(t),
2467
+ s.tag
2468
+ ), i = n == null ? void 0 : n.derivedFileId;
2469
+ if (typeof i == "string" && i) return i;
2470
+ } catch {
2471
+ }
2472
+ }, se = async function(t) {
2397
2473
  const s = (await this.client.listFiles({ folderId: t })).find(
2398
- (r) => String(r.name ?? "") === Ie
2474
+ (n) => String(n.name ?? "") === Fe
2399
2475
  );
2400
- return s ? { id: nn(s) } : void 0;
2476
+ return s ? { id: At(s) } : void 0;
2401
2477
  };
2402
- function rn(n) {
2403
- if (!n || typeof n != "object") return null;
2404
- const t = n;
2405
- if (t.schema !== Kt || typeof t.name != "string") return null;
2478
+ function De(r, t) {
2479
+ const e = (t ?? "").replace(/^\./, "").toLowerCase();
2480
+ if (e) return e;
2481
+ const s = r.lastIndexOf(".");
2482
+ return s > 0 ? r.slice(s + 1).toLowerCase() : "";
2483
+ }
2484
+ function Hr(r) {
2485
+ if (!r || typeof r != "object") return null;
2486
+ const t = r;
2487
+ if (t.schema !== qt || typeof t.name != "string") return null;
2406
2488
  const e = Array.isArray(t.views) ? t.views.filter(
2407
2489
  (i) => !!i && typeof i == "object" && typeof i.fileId == "string" && typeof i.format == "string"
2408
- ) : [], s = t.native, r = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string";
2490
+ ) : [], s = t.native, n = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string";
2409
2491
  return {
2410
- schema: Kt,
2492
+ schema: qt,
2411
2493
  name: t.name,
2412
- ...r ? { native: { fileId: s.fileId, format: s.format } } : {},
2494
+ ...n ? { native: { fileId: s.fileId, format: s.format } } : {},
2413
2495
  views: e
2414
2496
  };
2415
2497
  }
2416
- class xe extends Error {
2498
+ class Ue extends Error {
2417
2499
  constructor(t, e) {
2418
2500
  super(
2419
2501
  `The document history advanced while this version was being prepared: expected head ${t}, found ${e ?? "none"}. Read the timeline again and rebuild on the new head.`
2420
2502
  ), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
2421
2503
  }
2422
2504
  }
2423
- const $e = "bimterop", Xt = "revitflow_history.json", Q = "revitflow_ops.json", Ce = "revitflow/ops@1", ze = "revitflow_model.frag", Xe = "revitflow_", on = "bimterop-locks-anchor", St = () => `v-${Date.now()}`;
2424
- function Qe(n, t) {
2425
- return n.filter((e) => String(e.parentId ?? "") === t);
2505
+ const je = "bimterop", re = "revitflow_history.json", rt = "revitflow_ops.json", Me = "revitflow/ops@1", us = "revitflow_model.frag", ds = "revitflow_", Jr = "bimterop-locks-anchor", kt = () => `v-${Date.now()}`;
2506
+ function fs(r, t) {
2507
+ return r.filter((e) => String(e.parentId ?? "") === t);
2426
2508
  }
2427
- function N(n) {
2428
- return String(n._id ?? n.id ?? "");
2509
+ function B(r) {
2510
+ return String(r._id ?? r.id ?? "");
2429
2511
  }
2430
- var x, mt, Qt;
2431
- class an {
2512
+ var $, _t, ne;
2513
+ class Yr {
2432
2514
  constructor(t, e) {
2433
- b(this, mt);
2434
- b(this, x);
2515
+ b(this, _t);
2516
+ b(this, $);
2435
2517
  this.client = t, this.projectId = e;
2436
2518
  }
2437
2519
  /** The project's connected documents. */
2438
2520
  async docs() {
2439
- const t = await a(this, mt, Qt).call(this);
2521
+ const t = await a(this, _t, ne).call(this);
2440
2522
  if (!t) return [];
2441
2523
  const e = await this.client.listFolders({
2442
2524
  parentFolderId: t,
2443
2525
  projectId: this.projectId
2444
2526
  }), s = [];
2445
- for (const r of Qe(e, t)) {
2446
- const i = String(r.name ?? ""), o = i.indexOf("-");
2527
+ for (const n of fs(e, t)) {
2528
+ const i = String(n.name ?? ""), o = i.indexOf("-");
2447
2529
  if (o <= 0) continue;
2448
- const u = (await this.client.listFiles({
2449
- folderId: N(r)
2530
+ const d = (await this.client.listFiles({
2531
+ folderId: B(n)
2450
2532
  })).map(
2451
- (w) => String(w.name ?? "")
2452
- ), f = u.find((w) => w === ze) ?? u.find(
2453
- (w) => w.endsWith(".frag") && !w.startsWith(Xe)
2454
- ), y = u.includes(Xt) || u.includes(Q) || !!f;
2533
+ (g) => String(g.name ?? "")
2534
+ ), f = d.find((g) => g === us) ?? d.find(
2535
+ (g) => g.endsWith(".frag") && !g.startsWith(ds)
2536
+ ), c = d.includes(re) || d.includes(rt) || !!f;
2455
2537
  s.push({
2456
2538
  source: i.slice(0, o),
2457
2539
  docId: i.slice(o + 1),
2458
- folderId: N(r),
2540
+ folderId: B(n),
2459
2541
  modelName: f,
2460
- ...y ? {} : { empty: !0 }
2542
+ ...c ? {} : { empty: !0 }
2461
2543
  });
2462
2544
  }
2463
2545
  return s;
2464
2546
  }
2465
2547
  /** One document's history. `source` and `docId` as {@link docs} lists them. */
2466
2548
  doc(t, e) {
2467
- return new cn(this.client, this, t, e);
2549
+ return new Wr(this.client, this, t, e);
2468
2550
  }
2469
2551
  /** @internal The `bimterop` folder id, resolved once. */
2470
2552
  async rootFolderId(t = !1) {
2471
- if (l(this, x)) return l(this, x);
2472
- const e = await a(this, mt, Qt).call(this);
2553
+ if (u(this, $)) return u(this, $);
2554
+ const e = await a(this, _t, ne).call(this);
2473
2555
  if (e) return e;
2474
2556
  if (!t) return;
2475
2557
  const s = await this.client.createFolder(
2476
- $e,
2558
+ je,
2477
2559
  void 0,
2478
2560
  this.projectId
2479
2561
  );
2480
- return _(this, x, N(s)), l(this, x);
2562
+ return _(this, $, B(s)), u(this, $);
2481
2563
  }
2482
2564
  }
2483
- x = new WeakMap(), mt = new WeakSet(), Qt = async function() {
2484
- if (l(this, x)) return l(this, x);
2565
+ $ = new WeakMap(), _t = new WeakSet(), ne = async function() {
2566
+ if (u(this, $)) return u(this, $);
2485
2567
  const e = (await this.client.listFolders({
2486
2568
  projectId: this.projectId
2487
2569
  })).find(
2488
- (s) => String(s.name ?? "") === $e && !s.parentId
2570
+ (s) => String(s.name ?? "") === je && !s.parentId
2489
2571
  );
2490
- return e && _(this, x, N(e)), l(this, x);
2572
+ return e && _(this, $, B(e)), u(this, $);
2491
2573
  };
2492
- var q, d, Z, tt, F, Zt, ut, et, te, At, dt, xt, ee, Ze;
2493
- class cn {
2494
- constructor(t, e, s, r) {
2495
- b(this, d);
2496
- b(this, q);
2497
- this.client = t, this.project = e, this.source = s, this.docId = r;
2574
+ var U, p, nt, it, D, ie, mt, ot, oe, $t, gt, Nt, ae, ps;
2575
+ class Wr {
2576
+ constructor(t, e, s, n) {
2577
+ b(this, p);
2578
+ b(this, U);
2579
+ this.client = t, this.project = e, this.source = s, this.docId = n;
2498
2580
  }
2499
2581
  // ─── Reading ───────────────────────────────────────────────────────────────
2500
2582
  /**
@@ -2503,8 +2585,8 @@ class cn {
2503
2585
  * Each version gets its `ordinal` filled in.
2504
2586
  */
2505
2587
  async timeline() {
2506
- const t = await a(this, d, At).call(this);
2507
- return ts((t == null ? void 0 : t.commits) ?? []);
2588
+ const t = await a(this, p, $t).call(this);
2589
+ return ys((t == null ? void 0 : t.commits) ?? []);
2508
2590
  }
2509
2591
  /** The head of the timeline, or null before the first sync. */
2510
2592
  async latest() {
@@ -2524,7 +2606,7 @@ class cn {
2524
2606
  }
2525
2607
  /** The visible model .frag as last fully exported. */
2526
2608
  async model() {
2527
- const t = await a(this, d, et).call(this);
2609
+ const t = await a(this, p, ot).call(this);
2528
2610
  if (!t)
2529
2611
  throw new Error(
2530
2612
  `Document ${this.source}-${this.docId} has no model file yet.`
@@ -2533,7 +2615,7 @@ class cn {
2533
2615
  }
2534
2616
  /** The document folder's item id — the id the CDE knows this document by. */
2535
2617
  async folderId() {
2536
- return await a(this, d, F).call(this, !1);
2618
+ return await a(this, p, D).call(this, !1);
2537
2619
  }
2538
2620
  // ─── The document descriptor ───────────────────────────────────────────────
2539
2621
  /**
@@ -2541,7 +2623,7 @@ class cn {
2541
2623
  * not carry one yet — an old folder from before descriptors existed.
2542
2624
  */
2543
2625
  async descriptor() {
2544
- return await l(this, d, Z).descriptor(await a(this, d, F).call(this, !1));
2626
+ return await u(this, p, nt).descriptor(await a(this, p, D).call(this, !1));
2545
2627
  }
2546
2628
  /**
2547
2629
  * The first view whose format appears in `formats`, searched in the order
@@ -2549,17 +2631,17 @@ class cn {
2549
2631
  * model .frag on a descriptor-less folder, so old documents keep viewing.
2550
2632
  */
2551
2633
  async view(t) {
2552
- const e = await a(this, d, F).call(this, !1), s = await l(this, d, Z).descriptor(e);
2634
+ const e = await a(this, p, D).call(this, !1), s = await u(this, p, nt).descriptor(e);
2553
2635
  if (s) {
2554
2636
  for (const i of t) {
2555
- const o = s.views.find((c) => c.format === i);
2637
+ const o = s.views.find((h) => h.format === i);
2556
2638
  if (o) return o;
2557
2639
  }
2558
2640
  return null;
2559
2641
  }
2560
2642
  if (!t.includes("frag")) return null;
2561
- const r = await a(this, d, et).call(this);
2562
- return r ? { fileId: r.id, format: "frag" } : null;
2643
+ const n = await a(this, p, ot).call(this);
2644
+ return n ? { fileId: n.id, format: "frag" } : null;
2563
2645
  }
2564
2646
  /**
2565
2647
  * Registers a renderable representation, creating the descriptor when the
@@ -2567,14 +2649,14 @@ class cn {
2567
2649
  * One view per format: a same-format view is replaced, not accumulated.
2568
2650
  */
2569
2651
  async addView(t) {
2570
- const e = await a(this, d, F).call(this, !0);
2571
- if (await l(this, d, Z).descriptor(e)) {
2572
- await l(this, d, Z).addView(e, t);
2652
+ const e = await a(this, p, D).call(this, !0);
2653
+ if (await u(this, p, nt).descriptor(e)) {
2654
+ await u(this, p, nt).addView(e, t);
2573
2655
  return;
2574
2656
  }
2575
- const r = await a(this, d, et).call(this);
2576
- await l(this, d, Z).setDescriptor(e, {
2577
- name: (r == null ? void 0 : r.name.replace(/\.frag$/, "")) ?? l(this, d, tt),
2657
+ const n = await a(this, p, ot).call(this);
2658
+ await u(this, p, nt).setDescriptor(e, {
2659
+ name: (n == null ? void 0 : n.name.replace(/\.frag$/, "")) ?? u(this, p, it),
2578
2660
  views: [t]
2579
2661
  });
2580
2662
  }
@@ -2587,32 +2669,32 @@ class cn {
2587
2669
  * claims counts only for the earliest one, matching the plugins' rule.
2588
2670
  */
2589
2671
  async ownership() {
2590
- const t = await a(this, d, ut).call(this, on);
2672
+ const t = await a(this, p, mt).call(this, Jr);
2591
2673
  if (!t) return [];
2592
2674
  const e = await this.client.getHiddenFilesByParent(t.id), s = await Promise.all(
2593
2675
  e.map(async (o) => {
2594
2676
  try {
2595
- const c = N(o), u = await this.client.downloadHiddenFile(c), f = JSON.parse(await u.text());
2677
+ const h = B(o), d = await this.client.downloadHiddenFile(h), f = JSON.parse(await d.text());
2596
2678
  return !f || typeof f != "object" || !("revitflowlock" in f) || !Array.isArray(f.keys) ? null : {
2597
2679
  owner: String(f.user ?? ""),
2598
- keys: f.keys.filter((y) => typeof y == "string")
2680
+ keys: f.keys.filter((c) => typeof c == "string")
2599
2681
  };
2600
2682
  } catch {
2601
2683
  return null;
2602
2684
  }
2603
2685
  })
2604
- ), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
2686
+ ), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
2605
2687
  for (const o of s)
2606
2688
  if (o)
2607
- for (const c of o.keys) {
2608
- if (!c || r.has(c)) continue;
2609
- r.add(c);
2610
- const u = i.get(o.owner) ?? [];
2611
- u.push(c), i.set(o.owner, u);
2689
+ for (const h of o.keys) {
2690
+ if (!h || n.has(h)) continue;
2691
+ n.add(h);
2692
+ const d = i.get(o.owner) ?? [];
2693
+ d.push(h), i.set(o.owner, d);
2612
2694
  }
2613
- return [...i.entries()].map(([o, c]) => ({
2695
+ return [...i.entries()].map(([o, h]) => ({
2614
2696
  owner: o,
2615
- elements: c
2697
+ elements: h
2616
2698
  }));
2617
2699
  }
2618
2700
  // ─── Writing versions ─────────────────────────────────────────────────────
@@ -2623,55 +2705,55 @@ class cn {
2623
2705
  * silent fork.
2624
2706
  */
2625
2707
  async sync(t) {
2626
- var c;
2627
- const e = await a(this, d, F).call(this, !0);
2628
- let s = await a(this, d, At).call(this) ?? {
2708
+ var h;
2709
+ const e = await a(this, p, D).call(this, !0);
2710
+ let s = await a(this, p, $t).call(this) ?? {
2629
2711
  model: this.docId,
2630
2712
  commits: []
2631
2713
  };
2632
- const r = Re(s.commits);
2633
- if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
2634
- throw new xe(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2714
+ const n = Ve(s.commits);
2715
+ if (t.expectedLatestGuid !== void 0 && (n == null ? void 0 : n.guid) !== t.expectedLatestGuid)
2716
+ throw new Ue(t.expectedLatestGuid, n == null ? void 0 : n.guid);
2635
2717
  const i = {
2636
- guid: se(),
2637
- ...r ? { parents: [r.guid] } : {},
2718
+ guid: ce(),
2719
+ ...n ? { parents: [n.guid] } : {},
2638
2720
  author: t.author,
2639
2721
  source: t.source,
2640
2722
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2641
2723
  ...t.message ? { message: t.message } : {},
2642
2724
  ...t.userId ? { userId: t.userId } : {},
2643
- ...(c = t.appliedOps) != null && c.length ? { appliedOps: t.appliedOps } : {},
2725
+ ...(h = t.appliedOps) != null && h.length ? { appliedOps: t.appliedOps } : {},
2644
2726
  changes: t.changes,
2645
- counts: hn(t.changes)
2727
+ counts: Kr(t.changes)
2646
2728
  };
2647
- if (t.model && (await a(this, d, Ze).call(this, e, t.model), i.full = !0), t.delta) {
2648
- const u = await a(this, d, et).call(this);
2649
- if (!u)
2729
+ if (t.model && (await a(this, p, ps).call(this, e, t.model), i.full = !0), t.delta) {
2730
+ const d = await a(this, p, ot).call(this);
2731
+ if (!d)
2650
2732
  throw new Error(
2651
2733
  "A delta needs the model file to hang from: sync a full model first."
2652
2734
  );
2653
2735
  const f = await this.client.createHiddenFile(
2654
2736
  t.delta,
2655
- u.id
2737
+ d.id
2656
2738
  );
2657
2739
  i.deltaId = String(
2658
2740
  f._id ?? f.id
2659
2741
  );
2660
2742
  }
2661
- const o = await a(this, d, At).call(this);
2743
+ const o = await a(this, p, $t).call(this);
2662
2744
  if (o) {
2663
2745
  s = o;
2664
- const u = Re(s.commits);
2665
- if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
2666
- throw new xe(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2667
- u && !i.parents && (i.parents = [u.guid]);
2746
+ const d = Ve(s.commits);
2747
+ if (t.expectedLatestGuid !== void 0 && (d == null ? void 0 : d.guid) !== t.expectedLatestGuid)
2748
+ throw new Ue(t.expectedLatestGuid, d == null ? void 0 : d.guid);
2749
+ d && !i.parents && (i.parents = [d.guid]);
2668
2750
  }
2669
- return s.commits.push(i), await a(this, d, xt).call(this, e, Xt, s), i;
2751
+ return s.commits.push(i), await a(this, p, Nt).call(this, e, re, s), i;
2670
2752
  }
2671
2753
  // ─── Suggestions (change requests) ────────────────────────────────────────
2672
2754
  /** Every suggestion in the document's queue, pending or resolved. */
2673
2755
  async suggestions() {
2674
- const t = await a(this, d, dt).call(this);
2756
+ const t = await a(this, p, gt).call(this);
2675
2757
  return (t == null ? void 0 : t.ops) ?? [];
2676
2758
  }
2677
2759
  /** The suggestions still waiting for the owner, oldest first. */
@@ -2683,8 +2765,8 @@ class cn {
2683
2765
  * uploaded as a hidden file under the suggestions index.
2684
2766
  */
2685
2767
  async suggest(t) {
2686
- const e = await a(this, d, F).call(this, !0), s = await a(this, d, dt).call(this) ?? { schema: Ce, ops: [] }, r = await a(this, d, ut).call(this, Q), i = {
2687
- opId: t.opId ?? se(),
2768
+ const e = await a(this, p, D).call(this, !0), s = await a(this, p, gt).call(this) ?? { schema: Me, ops: [] }, n = await a(this, p, mt).call(this, rt), i = {
2769
+ opId: t.opId ?? ce(),
2688
2770
  to: t.to ?? this.source,
2689
2771
  title: t.title,
2690
2772
  verb: t.verb,
@@ -2697,16 +2779,16 @@ class cn {
2697
2779
  ...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
2698
2780
  };
2699
2781
  if (t.payload) {
2700
- const c = r ?? await a(this, d, ee).call(this, e, Q, s), u = await this.client.createHiddenFile(
2782
+ const h = n ?? await a(this, p, ae).call(this, e, rt, s), d = await this.client.createHiddenFile(
2701
2783
  t.payload,
2702
- c.id
2784
+ h.id
2703
2785
  );
2704
2786
  i.fragId = String(
2705
- u._id ?? u.id
2787
+ d._id ?? d.id
2706
2788
  );
2707
2789
  }
2708
- const o = await a(this, d, dt).call(this) ?? s;
2709
- return o.schema ?? (o.schema = Ce), o.ops.push(i), await a(this, d, xt).call(this, e, Q, o), i;
2790
+ const o = await a(this, p, gt).call(this) ?? s;
2791
+ return o.schema ?? (o.schema = Me), o.ops.push(i), await a(this, p, Nt).call(this, e, rt, o), i;
2710
2792
  }
2711
2793
  /** A suggestion's .frag payload. */
2712
2794
  async suggestionPayload(t) {
@@ -2720,20 +2802,20 @@ class cn {
2720
2802
  * use it for `discarded`.
2721
2803
  */
2722
2804
  async resolveSuggestion(t, e) {
2723
- const s = await a(this, d, F).call(this, !1);
2805
+ const s = await a(this, p, D).call(this, !1);
2724
2806
  if (!s) throw new Error("This document has no suggestion queue.");
2725
- const r = await a(this, d, dt).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
2726
- if (!r || !i)
2807
+ const n = await a(this, p, gt).call(this), i = n == null ? void 0 : n.ops.find((o) => o.opId === t);
2808
+ if (!n || !i)
2727
2809
  throw new Error(`No suggestion ${t} in this document's queue.`);
2728
- return Object.assign(i, e), await a(this, d, xt).call(this, s, Q, r), i;
2810
+ return Object.assign(i, e), await a(this, p, Nt).call(this, s, rt, n), i;
2729
2811
  }
2730
2812
  }
2731
- q = new WeakMap(), d = new WeakSet(), Z = function() {
2732
- return new Ke(this.client, this.project.projectId);
2733
- }, tt = function() {
2813
+ U = new WeakMap(), p = new WeakSet(), nt = function() {
2814
+ return new hs(this.client, this.project.projectId);
2815
+ }, it = function() {
2734
2816
  return `${this.source}-${this.docId}`;
2735
- }, F = async function(t) {
2736
- if (l(this, q)) return l(this, q);
2817
+ }, D = async function(t) {
2818
+ if (u(this, U)) return u(this, U);
2737
2819
  const e = await this.project.rootFolderId(t);
2738
2820
  if (!e)
2739
2821
  throw new Error(
@@ -2742,153 +2824,153 @@ q = new WeakMap(), d = new WeakSet(), Z = function() {
2742
2824
  const s = await this.client.listFolders({
2743
2825
  parentFolderId: e,
2744
2826
  projectId: this.project.projectId
2745
- }), r = Qe(s, e).find(
2746
- (o) => String(o.name ?? "") === l(this, d, tt)
2827
+ }), n = fs(s, e).find(
2828
+ (o) => String(o.name ?? "") === u(this, p, it)
2747
2829
  );
2748
- if (r)
2749
- return _(this, q, N(r)), l(this, q);
2830
+ if (n)
2831
+ return _(this, U, B(n)), u(this, U);
2750
2832
  if (!t)
2751
2833
  throw new Error(
2752
- `Document ${l(this, d, tt)} does not exist in this project.`
2834
+ `Document ${u(this, p, it)} does not exist in this project.`
2753
2835
  );
2754
2836
  const i = await this.client.createFolder(
2755
- l(this, d, tt),
2837
+ u(this, p, it),
2756
2838
  e,
2757
2839
  this.project.projectId
2758
2840
  );
2759
- return _(this, q, N(i)), l(this, q);
2760
- }, Zt = async function() {
2761
- const t = await a(this, d, F).call(this, !1);
2841
+ return _(this, U, B(i)), u(this, U);
2842
+ }, ie = async function() {
2843
+ const t = await a(this, p, D).call(this, !1);
2762
2844
  return (await this.client.listFiles({ folderId: t })).map((s) => ({
2763
- id: N(s),
2845
+ id: B(s),
2764
2846
  name: String(s.name ?? "")
2765
2847
  }));
2766
- }, ut = async function(t) {
2848
+ }, mt = async function(t) {
2767
2849
  try {
2768
- return (await a(this, d, Zt).call(this)).find((e) => e.name === t);
2850
+ return (await a(this, p, ie).call(this)).find((e) => e.name === t);
2769
2851
  } catch {
2770
2852
  return;
2771
2853
  }
2772
- }, et = async function() {
2854
+ }, ot = async function() {
2773
2855
  try {
2774
- const t = await a(this, d, Zt).call(this);
2775
- return t.find((e) => e.name === ze) ?? t.find(
2776
- (e) => e.name.endsWith(".frag") && !e.name.startsWith(Xe)
2856
+ const t = await a(this, p, ie).call(this);
2857
+ return t.find((e) => e.name === us) ?? t.find(
2858
+ (e) => e.name.endsWith(".frag") && !e.name.startsWith(ds)
2777
2859
  );
2778
2860
  } catch {
2779
2861
  return;
2780
2862
  }
2781
- }, te = async function(t) {
2782
- const e = await a(this, d, ut).call(this, t);
2863
+ }, oe = async function(t) {
2864
+ const e = await a(this, p, mt).call(this, t);
2783
2865
  if (!e) return;
2784
- const r = await (await this.client.downloadFile(e.id)).text();
2785
- if (r.trim())
2786
- return JSON.parse(r);
2787
- }, At = function() {
2788
- return a(this, d, te).call(this, Xt);
2789
- }, dt = function() {
2790
- return a(this, d, te).call(this, Q);
2791
- }, xt = async function(t, e, s) {
2792
- const r = new Blob([JSON.stringify(s)], {
2866
+ const n = await (await this.client.downloadFile(e.id)).text();
2867
+ if (n.trim())
2868
+ return JSON.parse(n);
2869
+ }, $t = function() {
2870
+ return a(this, p, oe).call(this, re);
2871
+ }, gt = function() {
2872
+ return a(this, p, oe).call(this, rt);
2873
+ }, Nt = async function(t, e, s) {
2874
+ const n = new Blob([JSON.stringify(s)], {
2793
2875
  type: "application/json"
2794
- }), i = await a(this, d, ut).call(this, e);
2876
+ }), i = await a(this, p, mt).call(this, e);
2795
2877
  return i ? (await this.client.updateFile(i.id, {
2796
- file: r,
2797
- versionTag: St()
2798
- }), i) : await a(this, d, ee).call(this, t, e, s);
2799
- }, ee = async function(t, e, s) {
2800
- const r = new Blob([JSON.stringify(s)], {
2878
+ file: n,
2879
+ versionTag: kt()
2880
+ }), i) : await a(this, p, ae).call(this, t, e, s);
2881
+ }, ae = async function(t, e, s) {
2882
+ const n = new Blob([JSON.stringify(s)], {
2801
2883
  type: "application/json"
2802
2884
  }), i = await this.client.createFile({
2803
- file: r,
2885
+ file: n,
2804
2886
  name: e,
2805
- versionTag: St(),
2887
+ versionTag: kt(),
2806
2888
  parentFolderId: t,
2807
2889
  projectId: this.project.projectId
2808
2890
  }), o = i.item;
2809
- return { id: N(o ?? i), name: e };
2810
- }, Ze = async function(t, e) {
2811
- const s = await a(this, d, et).call(this);
2891
+ return { id: B(o ?? i), name: e };
2892
+ }, ps = async function(t, e) {
2893
+ const s = await a(this, p, ot).call(this);
2812
2894
  if (s)
2813
2895
  return await this.client.updateFile(s.id, {
2814
2896
  file: e,
2815
- versionTag: St()
2897
+ versionTag: kt()
2816
2898
  }), s;
2817
- const r = `${l(this, d, tt)}.frag`, i = await this.client.createFile({
2899
+ const n = `${u(this, p, it)}.frag`, i = await this.client.createFile({
2818
2900
  file: e,
2819
- name: r,
2820
- versionTag: St(),
2901
+ name: n,
2902
+ versionTag: kt(),
2821
2903
  parentFolderId: t,
2822
2904
  projectId: this.project.projectId
2823
2905
  }), o = i.item;
2824
- return { id: N(o ?? i), name: r };
2906
+ return { id: B(o ?? i), name: n };
2825
2907
  };
2826
- function hn(n) {
2908
+ function Kr(r) {
2827
2909
  const t = { added: 0, modified: 0, removed: 0 };
2828
- for (const e of n)
2910
+ for (const e of r)
2829
2911
  e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
2830
2912
  return t;
2831
2913
  }
2832
- function ts(n) {
2833
- var u;
2834
- if (n.length <= 1)
2835
- return n.forEach((f, y) => f.ordinal = y), [...n];
2836
- const t = new Map(n.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
2837
- for (const f of n) {
2838
- const y = (u = f.parents) == null ? void 0 : u[0];
2839
- if (y && t.has(y)) {
2840
- const w = e.get(y) ?? [];
2841
- w.push(f), e.set(y, w);
2914
+ function ys(r) {
2915
+ var d;
2916
+ if (r.length <= 1)
2917
+ return r.forEach((f, c) => f.ordinal = c), [...r];
2918
+ const t = new Map(r.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
2919
+ for (const f of r) {
2920
+ const c = (d = f.parents) == null ? void 0 : d[0];
2921
+ if (c && t.has(c)) {
2922
+ const g = e.get(c) ?? [];
2923
+ g.push(f), e.set(c, g);
2842
2924
  } else
2843
2925
  s.push(f);
2844
2926
  }
2845
- const r = (f, y) => String(f.timestamp).localeCompare(String(y.timestamp));
2846
- s.sort(r);
2847
- const i = [], o = [...s].reverse(), c = /* @__PURE__ */ new Set();
2927
+ const n = (f, c) => String(f.timestamp).localeCompare(String(c.timestamp));
2928
+ s.sort(n);
2929
+ const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
2848
2930
  for (; o.length; ) {
2849
2931
  const f = o.pop();
2850
- if (c.has(f.guid)) continue;
2851
- c.add(f.guid), i.push(f);
2852
- const y = (e.get(f.guid) ?? []).sort(r);
2853
- for (let w = y.length - 1; w >= 0; w--) o.push(y[w]);
2854
- }
2855
- for (const f of n)
2856
- c.has(f.guid) || i.push(f);
2857
- return i.forEach((f, y) => f.ordinal = y), i;
2932
+ if (h.has(f.guid)) continue;
2933
+ h.add(f.guid), i.push(f);
2934
+ const c = (e.get(f.guid) ?? []).sort(n);
2935
+ for (let g = c.length - 1; g >= 0; g--) o.push(c[g]);
2936
+ }
2937
+ for (const f of r)
2938
+ h.has(f.guid) || i.push(f);
2939
+ return i.forEach((f, c) => f.ordinal = c), i;
2858
2940
  }
2859
- function Re(n) {
2860
- const t = ts(n);
2941
+ function Ve(r) {
2942
+ const t = ys(r);
2861
2943
  return t[t.length - 1];
2862
2944
  }
2863
- function se() {
2864
- const n = globalThis.crypto;
2865
- return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
2945
+ function ce() {
2946
+ const r = globalThis.crypto;
2947
+ return r != null && r.randomUUID ? r.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
2866
2948
  const e = Math.random() * 16 | 0;
2867
2949
  return (t === "x" ? e : e & 3 | 8).toString(16);
2868
2950
  });
2869
2951
  }
2870
- var H, gt, ne;
2871
- class ln {
2952
+ var Y, Et, he;
2953
+ class zr {
2872
2954
  constructor(t) {
2873
- b(this, gt);
2874
- b(this, H, /* @__PURE__ */ new Map());
2955
+ b(this, Et);
2956
+ b(this, Y, /* @__PURE__ */ new Map());
2875
2957
  this.client = t;
2876
2958
  }
2877
2959
  /** Registers a recipe. One per name; a second with the same name throws. */
2878
2960
  register(t) {
2879
- if (l(this, H).has(t.name))
2961
+ if (u(this, Y).has(t.name))
2880
2962
  throw new Error(`A recipe named "${t.name}" is already registered.`);
2881
- l(this, H).set(t.name, t);
2963
+ u(this, Y).set(t.name, t);
2882
2964
  }
2883
2965
  /** The registered recipes, optionally filtered by target application. */
2884
2966
  list(t) {
2885
- return [...l(this, H).values()].filter(
2967
+ return [...u(this, Y).values()].filter(
2886
2968
  (s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
2887
2969
  );
2888
2970
  }
2889
2971
  /** A registered recipe by name, or undefined. */
2890
2972
  get(t) {
2891
- return l(this, H).get(t);
2973
+ return u(this, Y).get(t);
2892
2974
  }
2893
2975
  /**
2894
2976
  * Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
@@ -2897,9 +2979,9 @@ class ln {
2897
2979
  * included, with no second run. Discard it and the plan never happened.
2898
2980
  */
2899
2981
  async plan(t, e) {
2900
- const { base: s, opId: r, result: i } = await a(this, gt, ne).call(this, t, e);
2982
+ const { base: s, opId: n, result: i } = await a(this, Et, he).call(this, t, e);
2901
2983
  return {
2902
- opId: r,
2984
+ opId: n,
2903
2985
  projectId: e.projectId,
2904
2986
  target: e.target,
2905
2987
  ...s != null && s.guid ? { baseCommitGuid: s.guid } : {},
@@ -2930,7 +3012,7 @@ class ln {
2930
3012
  * to show the tallies before queueing.
2931
3013
  */
2932
3014
  async run(t, e) {
2933
- const { targetDoc: s, base: r, opId: i, result: o } = await a(this, gt, ne).call(this, t, e);
3015
+ const { targetDoc: s, base: n, opId: i, result: o } = await a(this, Et, he).call(this, t, e);
2934
3016
  return { suggestion: await s.suggest({
2935
3017
  opId: i,
2936
3018
  title: o.title,
@@ -2939,31 +3021,31 @@ class ln {
2939
3021
  payload: o.payload,
2940
3022
  targets: o.targets,
2941
3023
  userId: e.userId,
2942
- baseCommitGuid: r == null ? void 0 : r.guid
3024
+ baseCommitGuid: n == null ? void 0 : n.guid
2943
3025
  }), result: o };
2944
3026
  }
2945
3027
  }
2946
- H = new WeakMap(), gt = new WeakSet(), ne = async function(t, e) {
2947
- const s = l(this, H).get(t);
3028
+ Y = new WeakMap(), Et = new WeakSet(), he = async function(t, e) {
3029
+ const s = u(this, Y).get(t);
2948
3030
  if (!s) throw new Error(`No recipe named "${t}" is registered.`);
2949
3031
  if (s.to !== e.target.source)
2950
3032
  throw new Error(
2951
3033
  `Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
2952
3034
  );
2953
- const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = se(), c = await s.run({
3035
+ const n = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await n.latest(), o = ce(), h = await s.run({
2954
3036
  client: this.client,
2955
3037
  projectId: e.projectId,
2956
- targetDoc: r,
3038
+ targetDoc: n,
2957
3039
  opId: o,
2958
3040
  input: e.input,
2959
3041
  settings: e.settings ?? {}
2960
3042
  });
2961
- return { recipe: s, targetDoc: r, base: i, opId: o, result: c };
3043
+ return { recipe: s, targetDoc: n, base: i, opId: o, result: h };
2962
3044
  };
2963
- const Ne = 100;
2964
- function un(n) {
3045
+ const Ge = 100;
3046
+ function Xr(r) {
2965
3047
  try {
2966
- const t = JSON.parse(n);
3048
+ const t = JSON.parse(r);
2967
3049
  if (t && typeof t == "object") {
2968
3050
  const e = t;
2969
3051
  return {
@@ -2976,31 +3058,31 @@ function un(n) {
2976
3058
  }
2977
3059
  return {};
2978
3060
  }
2979
- function dn(n) {
2980
- if (!n || typeof n != "object") return;
2981
- const t = n.retryAfter;
3061
+ function Qr(r) {
3062
+ if (!r || typeof r != "object") return;
3063
+ const t = r.retryAfter;
2982
3064
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
2983
3065
  }
2984
- class we extends Error {
2985
- constructor(e, s, r, i) {
2986
- const o = un(r);
3066
+ class Se extends Error {
3067
+ constructor(e, s, n, i) {
3068
+ const o = Xr(n);
2987
3069
  super(o.message ?? `${s || "Request failed"} (${e})`);
2988
- T(this, "status");
2989
- T(this, "code");
2990
- T(this, "details");
2991
- T(this, "body");
3070
+ I(this, "status");
3071
+ I(this, "code");
3072
+ I(this, "details");
3073
+ I(this, "body");
2992
3074
  /**
2993
3075
  * Seconds to wait before retrying, taken from the `Retry-After` header or
2994
3076
  * from `details.retryAfter`. Only present on rate-limited (429) responses.
2995
3077
  */
2996
- T(this, "retryAfter");
2997
- this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? dn(o.details);
3078
+ I(this, "retryAfter");
3079
+ this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = n, this.retryAfter = i ?? Qr(o.details);
2998
3080
  }
2999
3081
  }
3000
- const R = "item/folder", m = "item", j = "processor", fn = "npm-registry", L = "hidden", Ut = "FILE", jt = "TOOL", Mt = "APP", pn = 500, Pe = 3e4, yn = 0.25, mn = (n) => new Promise((t) => setTimeout(t, n));
3001
- function gn(n) {
3002
- var r, i;
3003
- const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
3082
+ const P = "item/folder", m = "item", H = "processor", Zr = "npm-registry", q = "hidden", Yt = "FILE", Wt = "TOOL", Kt = "APP", tn = 500, He = 3e4, en = 0.25, sn = (r) => new Promise((t) => setTimeout(t, r));
3083
+ function rn(r) {
3084
+ var n, i;
3085
+ const t = (i = (n = r.headers) == null ? void 0 : n.get) == null ? void 0 : i.call(n, "Retry-After");
3004
3086
  if (!t) return;
3005
3087
  const e = Number(t);
3006
3088
  if (Number.isFinite(e)) return Math.max(0, e);
@@ -3008,18 +3090,18 @@ function gn(n) {
3008
3090
  if (!Number.isNaN(s))
3009
3091
  return Math.max(0, (s - Date.now()) / 1e3);
3010
3092
  }
3011
- function wn(n) {
3012
- return n instanceof we ? n.status === 429 || n.status >= 500 : !0;
3093
+ function nn(r) {
3094
+ return r instanceof Se ? r.status === 429 || r.status >= 500 : !0;
3013
3095
  }
3014
- function bn(n, t) {
3096
+ function on(r, t) {
3015
3097
  const e = Math.min(
3016
- pn * 2 ** t,
3017
- Pe
3018
- ), s = e * yn * Math.random(), r = n instanceof we && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
3019
- return r != null ? Math.min(r, Pe) + s : e + s;
3098
+ tn * 2 ** t,
3099
+ He
3100
+ ), s = e * en * Math.random(), n = r instanceof Se && r.retryAfter != null ? r.retryAfter * 1e3 : void 0;
3101
+ return n != null ? Math.min(n, He) + s : e + s;
3020
3102
  }
3021
- var h, ie, p, M, wt, ft, $t, Ct, oe, ae, es;
3022
- const be = class be {
3103
+ var l, ue, y, J, vt, wt, Pt, Bt, de, fe, ms;
3104
+ const Ie = class Ie {
3023
3105
  /**
3024
3106
  * Creates a new EngineServicesClient instance.
3025
3107
  * @param accessToken - API access token (obtained from the platform dashboard)
@@ -3028,31 +3110,31 @@ const be = class be {
3028
3110
  * @param props - Optional configuration (retry count, auth mode, etc.).
3029
3111
  */
3030
3112
  constructor(t, e, s) {
3031
- b(this, h);
3032
- T(this, "apiUrl");
3033
- T(this, "accessToken");
3034
- T(this, "wsUrl");
3035
- T(this, "retries");
3036
- T(this, "useBearer");
3037
- T(this, "builtInGlobals", null);
3113
+ b(this, l);
3114
+ I(this, "apiUrl");
3115
+ I(this, "accessToken");
3116
+ I(this, "wsUrl");
3117
+ I(this, "retries");
3118
+ I(this, "useBearer");
3119
+ I(this, "builtInGlobals", null);
3038
3120
  /**
3039
3121
  * URL of a local execution server (e.g. `http://localhost:4001`).
3040
3122
  * When set, execution methods are routed to this server instead of the cloud API.
3041
3123
  * Set to `null` to disable local routing and use the cloud API.
3042
3124
  */
3043
- T(this, "localServerUrl", null);
3125
+ I(this, "localServerUrl", null);
3044
3126
  /**
3045
3127
  * The platform context this client was created with.
3046
3128
  * Contains `appId`, `projectId`, `accessToken`, and `apiUrl`.
3047
3129
  * Populated automatically when using {@link fromPlatformContext}.
3048
3130
  */
3049
- T(this, "context");
3050
- b(this, wt);
3051
- const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
3052
- let c = e;
3053
- if (c.charAt(c.length - 1) === "/" && (c = c.slice(0, -1)), this.apiUrl = `${c}/api`, this.accessToken = t, this.wsUrl = c, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
3054
- let u = o;
3055
- u.charAt(u.length - 1) === "/" && (u = u.slice(0, -1)), this.localServerUrl = u;
3131
+ I(this, "context");
3132
+ b(this, vt);
3133
+ const { retries: n = 0, useBearer: i = !1, localServerUrl: o } = s || {};
3134
+ let h = e;
3135
+ if (h.charAt(h.length - 1) === "/" && (h = h.slice(0, -1)), this.apiUrl = `${h}/api`, this.accessToken = t, this.wsUrl = h, this.retries = n, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
3136
+ let d = o;
3137
+ d.charAt(d.length - 1) === "/" && (d = d.slice(0, -1)), this.localServerUrl = d;
3056
3138
  }
3057
3139
  }
3058
3140
  /**
@@ -3072,7 +3154,7 @@ const be = class be {
3072
3154
  * ```
3073
3155
  */
3074
3156
  static fromPlatformContext(t) {
3075
- const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new be(e.accessToken, e.apiUrl, {
3157
+ const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new Ie(e.accessToken, e.apiUrl, {
3076
3158
  ...t,
3077
3159
  useBearer: !0
3078
3160
  });
@@ -3148,7 +3230,7 @@ const be = class be {
3148
3230
  * cleaning logic is applied identically.
3149
3231
  */
3150
3232
  async request(t, e, s) {
3151
- return a(this, h, p).call(this, t, e, s);
3233
+ return a(this, l, y).call(this, t, e, s);
3152
3234
  }
3153
3235
  // ─── Files ───────────────────────────────────────────────────────
3154
3236
  /**
@@ -3157,12 +3239,12 @@ const be = class be {
3157
3239
  * @returns Array of file items.
3158
3240
  */
3159
3241
  async listFiles(t) {
3160
- const { folderId: e, archived: s, projectId: r } = t || {};
3161
- return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, { query: { itemType: Ut, archived: s } }) : await a(this, h, p).call(this, "GET", `${m}`, {
3242
+ const { folderId: e, archived: s, projectId: n } = t || {};
3243
+ return e ? await a(this, l, y).call(this, "GET", `${P}/${e}/items`, { query: { itemType: Yt, archived: s } }) : await a(this, l, y).call(this, "GET", `${m}`, {
3162
3244
  query: {
3163
- itemType: Ut,
3245
+ itemType: Yt,
3164
3246
  archived: s,
3165
- ...r && { projectId: r }
3247
+ ...n && { projectId: n }
3166
3248
  }
3167
3249
  });
3168
3250
  }
@@ -3173,7 +3255,7 @@ const be = class be {
3173
3255
  * @returns The file item, optionally with version history.
3174
3256
  */
3175
3257
  async getFile(t, e) {
3176
- return await a(this, h, ae).call(this, t, e);
3258
+ return await a(this, l, fe).call(this, t, e);
3177
3259
  }
3178
3260
  /**
3179
3261
  * Uploads a new file.
@@ -3181,7 +3263,7 @@ const be = class be {
3181
3263
  * @returns The created item and its first version.
3182
3264
  */
3183
3265
  async createFile(t) {
3184
- return await a(this, h, Ct).call(this, t, Ut);
3266
+ return await a(this, l, Bt).call(this, t, Yt);
3185
3267
  }
3186
3268
  /**
3187
3269
  * Updates an existing file. Can rename, move to a different folder,
@@ -3191,21 +3273,21 @@ const be = class be {
3191
3273
  * @returns The updated item and/or the new version.
3192
3274
  */
3193
3275
  async updateFile(t, e) {
3194
- return await a(this, h, oe).call(this, t, e);
3276
+ return await a(this, l, de).call(this, t, e);
3195
3277
  }
3196
3278
  /**
3197
3279
  * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
3198
3280
  * @param fileId - The file's unique identifier.
3199
3281
  */
3200
3282
  async archiveFile(t) {
3201
- return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3283
+ return await a(this, l, y).call(this, "DELETE", `${m}/${t}`);
3202
3284
  }
3203
3285
  /**
3204
3286
  * Recovers a previously archived file.
3205
3287
  * @param fileId - The file's unique identifier.
3206
3288
  */
3207
3289
  async recoverFile(t) {
3208
- return await a(this, h, p).call(this, "PUT", `${m}/${t}/recover`);
3290
+ return await a(this, l, y).call(this, "PUT", `${m}/${t}/recover`);
3209
3291
  }
3210
3292
  /**
3211
3293
  * Downloads a file's content. Returns the raw fetch Response.
@@ -3214,7 +3296,7 @@ const be = class be {
3214
3296
  * @returns A fetch Response containing the file data.
3215
3297
  */
3216
3298
  async downloadFile(t, e) {
3217
- return await a(this, h, $t).call(this, t, e);
3299
+ return await a(this, l, Pt).call(this, t, e);
3218
3300
  }
3219
3301
  /**
3220
3302
  * Retrieves the free-JSON metadata for a specific file version.
@@ -3224,10 +3306,10 @@ const be = class be {
3224
3306
  * @param params - Optional flags such as `withDraft`.
3225
3307
  */
3226
3308
  async getFileVersionMetadata(t, e, s) {
3227
- const { withDraft: r } = s || {};
3228
- return await a(this, h, p).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3309
+ const { withDraft: n } = s || {};
3310
+ return await a(this, l, y).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3229
3311
  query: {
3230
- ...r && { withDraft: "true" }
3312
+ ...n && { withDraft: "true" }
3231
3313
  }
3232
3314
  });
3233
3315
  }
@@ -3238,7 +3320,7 @@ const be = class be {
3238
3320
  * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
3239
3321
  */
3240
3322
  async updateFileVersionMetadata(t, e, s) {
3241
- return await a(this, h, p).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3323
+ return await a(this, l, y).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3242
3324
  body: JSON.stringify({ metadata: s }),
3243
3325
  contentType: "application/json"
3244
3326
  });
@@ -3249,7 +3331,7 @@ const be = class be {
3249
3331
  * @param versionTag - The version tag.
3250
3332
  */
3251
3333
  async deleteFileVersionMetadata(t, e) {
3252
- return await a(this, h, p).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
3334
+ return await a(this, l, y).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
3253
3335
  }
3254
3336
  /**
3255
3337
  * Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
@@ -3266,9 +3348,9 @@ const be = class be {
3266
3348
  */
3267
3349
  async getFileVersionMetadataBatch(t, e) {
3268
3350
  const { withDraft: s } = e || {};
3269
- return await a(this, h, ft).call(this, t, async (r) => (await a(this, h, p).call(this, "POST", `${m}/batch/version-metadata`, {
3351
+ return await a(this, l, wt).call(this, t, async (n) => (await a(this, l, y).call(this, "POST", `${m}/batch/version-metadata`, {
3270
3352
  body: JSON.stringify({
3271
- entries: r,
3353
+ entries: n,
3272
3354
  ...s !== void 0 && { withDraft: s }
3273
3355
  }),
3274
3356
  contentType: "application/json"
@@ -3281,12 +3363,12 @@ const be = class be {
3281
3363
  * @returns Array of folder items.
3282
3364
  */
3283
3365
  async listFolders(t) {
3284
- const { archived: e, parentFolderId: s, projectId: r } = t || {};
3285
- return await a(this, h, p).call(this, "GET", R, {
3366
+ const { archived: e, parentFolderId: s, projectId: n } = t || {};
3367
+ return await a(this, l, y).call(this, "GET", P, {
3286
3368
  query: {
3287
3369
  parentFolderId: s,
3288
3370
  archived: e,
3289
- ...r && { projectId: r }
3371
+ ...n && { projectId: n }
3290
3372
  }
3291
3373
  });
3292
3374
  }
@@ -3295,7 +3377,7 @@ const be = class be {
3295
3377
  * @param folderId - The folder's unique identifier.
3296
3378
  */
3297
3379
  async getFolder(t) {
3298
- return await a(this, h, p).call(this, "GET", `${R}/${t}`);
3380
+ return await a(this, l, y).call(this, "GET", `${P}/${t}`);
3299
3381
  }
3300
3382
  /**
3301
3383
  * Batch variant of {@link getFolder}. Resolves a known set of folder ids in
@@ -3311,7 +3393,7 @@ const be = class be {
3311
3393
  * @param folderIds - The folder ids to resolve.
3312
3394
  */
3313
3395
  async getFoldersBatch(t) {
3314
- return await a(this, h, ft).call(this, t, async (e) => (await a(this, h, p).call(this, "POST", `${m}/batch/folders`, {
3396
+ return await a(this, l, wt).call(this, t, async (e) => (await a(this, l, y).call(this, "POST", `${m}/batch/folders`, {
3315
3397
  body: JSON.stringify({ folderIds: e }),
3316
3398
  contentType: "application/json"
3317
3399
  })).results);
@@ -3323,7 +3405,7 @@ const be = class be {
3323
3405
  * @returns The created folder.
3324
3406
  */
3325
3407
  async createFolder(t, e, s) {
3326
- return await a(this, h, p).call(this, "POST", R, {
3408
+ return await a(this, l, y).call(this, "POST", P, {
3327
3409
  body: JSON.stringify({
3328
3410
  name: t,
3329
3411
  ...e && { parentId: e },
@@ -3340,7 +3422,7 @@ const be = class be {
3340
3422
  */
3341
3423
  async updateFolder(t, e) {
3342
3424
  const { name: s } = e;
3343
- return await a(this, h, p).call(this, "PUT", `${R}/${t}`, {
3425
+ return await a(this, l, y).call(this, "PUT", `${P}/${t}`, {
3344
3426
  body: JSON.stringify({ name: s }),
3345
3427
  contentType: "application/json"
3346
3428
  });
@@ -3350,14 +3432,14 @@ const be = class be {
3350
3432
  * @param folderId - The folder's unique identifier.
3351
3433
  */
3352
3434
  async archiveFolder(t) {
3353
- return await a(this, h, p).call(this, "DELETE", `${R}/${t}`);
3435
+ return await a(this, l, y).call(this, "DELETE", `${P}/${t}`);
3354
3436
  }
3355
3437
  /**
3356
3438
  * Recovers a previously archived folder.
3357
3439
  * @param folderId - The folder's unique identifier.
3358
3440
  */
3359
3441
  async recoverFolder(t) {
3360
- return await a(this, h, p).call(this, "PUT", `${R}/${t}/recover`);
3442
+ return await a(this, l, y).call(this, "PUT", `${P}/${t}/recover`);
3361
3443
  }
3362
3444
  /**
3363
3445
  * Downloads an entire folder as a ZIP archive.
@@ -3365,7 +3447,7 @@ const be = class be {
3365
3447
  * @returns A fetch Response containing the ZIP data.
3366
3448
  */
3367
3449
  async downloadFolder(t) {
3368
- return await a(this, h, M).call(this, `${R}/${t}/download`);
3450
+ return await a(this, l, J).call(this, `${P}/${t}/download`);
3369
3451
  }
3370
3452
  // ─── Components ──────────────────────────────────────────────────
3371
3453
  /**
@@ -3374,17 +3456,17 @@ const be = class be {
3374
3456
  * @returns Array of component items.
3375
3457
  */
3376
3458
  async listComponents(t) {
3377
- const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3378
- return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, {
3459
+ const { folderId: e, ShowVersions: s, projectId: n } = t || {};
3460
+ return e ? await a(this, l, y).call(this, "GET", `${P}/${e}/items`, {
3379
3461
  query: {
3380
- itemType: jt,
3462
+ itemType: Wt,
3381
3463
  ...s && { ShowVersions: s }
3382
3464
  }
3383
- }) : await a(this, h, p).call(this, "GET", `${m}`, {
3465
+ }) : await a(this, l, y).call(this, "GET", `${m}`, {
3384
3466
  query: {
3385
- itemType: jt,
3467
+ itemType: Wt,
3386
3468
  ...s && { ShowVersions: s },
3387
- ...r && { projectId: r }
3469
+ ...n && { projectId: n }
3388
3470
  }
3389
3471
  });
3390
3472
  }
@@ -3394,7 +3476,7 @@ const be = class be {
3394
3476
  * @param props - Options such as whether to include versions.
3395
3477
  */
3396
3478
  async getComponent(t, e) {
3397
- return await a(this, h, ae).call(this, t, e);
3479
+ return await a(this, l, fe).call(this, t, e);
3398
3480
  }
3399
3481
  /**
3400
3482
  * Creates a new component with the given file and version properties.
@@ -3403,7 +3485,7 @@ const be = class be {
3403
3485
  */
3404
3486
  async createComponent(t) {
3405
3487
  const { componentProps: e } = t;
3406
- return await a(this, h, Ct).call(this, t, jt, e);
3488
+ return await a(this, l, Bt).call(this, t, Wt, e);
3407
3489
  }
3408
3490
  /**
3409
3491
  * Updates an existing component. Can rename, move, and/or upload a new version.
@@ -3413,7 +3495,7 @@ const be = class be {
3413
3495
  */
3414
3496
  async updateComponent(t, e) {
3415
3497
  const { componentProps: s } = e;
3416
- return await a(this, h, oe).call(this, t, e, s);
3498
+ return await a(this, l, de).call(this, t, e, s);
3417
3499
  }
3418
3500
  /**
3419
3501
  * Downloads a component's full ZIP file. Returns the raw fetch Response.
@@ -3422,7 +3504,7 @@ const be = class be {
3422
3504
  * @returns A fetch Response containing the ZIP data.
3423
3505
  */
3424
3506
  async downloadComponent(t, e) {
3425
- return await a(this, h, $t).call(this, t, e);
3507
+ return await a(this, l, Pt).call(this, t, e);
3426
3508
  }
3427
3509
  /**
3428
3510
  * Downloads only the JavaScript bundle from a component's ZIP.
@@ -3432,11 +3514,11 @@ const be = class be {
3432
3514
  * @returns A fetch Response containing the bundle JavaScript text.
3433
3515
  */
3434
3516
  async downloadComponentBundle(t, e) {
3435
- const { versionTag: s, withDraft: r } = e || {};
3436
- return await a(this, h, M).call(this, `${m}/${t}/download/bundle`, {
3517
+ const { versionTag: s, withDraft: n } = e || {};
3518
+ return await a(this, l, J).call(this, `${m}/${t}/download/bundle`, {
3437
3519
  query: {
3438
3520
  ...s && { versionTag: s },
3439
- ...r && { withDraft: r }
3521
+ ...n && { withDraft: n }
3440
3522
  }
3441
3523
  });
3442
3524
  }
@@ -3445,14 +3527,14 @@ const be = class be {
3445
3527
  * @param componentId - The component's unique identifier.
3446
3528
  */
3447
3529
  async archiveComponent(t) {
3448
- return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3530
+ return await a(this, l, y).call(this, "DELETE", `${m}/${t}`);
3449
3531
  }
3450
3532
  /**
3451
3533
  * Recovers a previously archived component.
3452
3534
  * @param componentId - The component's unique identifier.
3453
3535
  */
3454
3536
  async recoverComponent(t) {
3455
- return await a(this, h, p).call(this, "PUT", `${m}/${t}/recover`);
3537
+ return await a(this, l, y).call(this, "PUT", `${m}/${t}/recover`);
3456
3538
  }
3457
3539
  // ─── Built-in Components ─────────────────────────────────────────
3458
3540
  /**
@@ -3461,7 +3543,7 @@ const be = class be {
3461
3543
  * @returns The component's JavaScript source code as a string.
3462
3544
  */
3463
3545
  async getBuiltInComponent(t) {
3464
- return await (await a(this, h, M).call(this, `built-in/${t}/bundle`)).text();
3546
+ return await (await a(this, l, J).call(this, `built-in/${t}/bundle`)).text();
3465
3547
  }
3466
3548
  /**
3467
3549
  * Fetches a built-in component bundle, evaluates it, and registers it
@@ -3490,9 +3572,9 @@ const be = class be {
3490
3572
  * ```
3491
3573
  */
3492
3574
  async initBuiltInComponent(t, e, s) {
3493
- const r = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), c = o.map((w) => i[w]), f = new Function(...o, `${r}
3494
- return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3495
- e.get(y);
3575
+ const n = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((g) => i[g]), f = new Function(...o, `${n}
3576
+ return main;`)(...h), c = (f == null ? void 0 : f.componentDefinition) ?? f;
3577
+ e.get(c);
3496
3578
  }
3497
3579
  /**
3498
3580
  * Loads multiple built-in components in parallel.
@@ -3534,13 +3616,13 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3534
3616
  * ```
3535
3617
  */
3536
3618
  async setup(t, ...e) {
3537
- var o, c;
3538
- const s = t.OBC, r = t.BUI;
3619
+ var o, h;
3620
+ const s = t.OBC, n = t.BUI;
3539
3621
  if (!(s != null && s.Components))
3540
3622
  throw new Error("globals.OBC must include Components");
3541
- if (!(r != null && r.Manager)) throw new Error("globals.BUI must include Manager");
3623
+ if (!(n != null && n.Manager)) throw new Error("globals.BUI must include Manager");
3542
3624
  const i = new s.Components();
3543
- return r.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(i, ...e), i.init(), (c = (o = this.context.appEventOrchestrator) == null ? void 0 : o.appLoaded) == null || c.call(o), { components: i };
3625
+ return n.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(i, ...e), i.init(), (h = (o = this.context.appEventOrchestrator) == null ? void 0 : o.appLoaded) == null || h.call(o), { components: i };
3544
3626
  }
3545
3627
  /**
3546
3628
  * Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
@@ -3548,8 +3630,8 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3548
3630
  * @param data - Arbitrary error data to send to the platform.
3549
3631
  */
3550
3632
  throwError(t, e) {
3551
- var s, r;
3552
- (r = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || r.call(s, t, e);
3633
+ var s, n;
3634
+ (n = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || n.call(s, t, e);
3553
3635
  }
3554
3636
  // ─── Apps ────────────────────────────────────────────────────────
3555
3637
  /**
@@ -3558,17 +3640,17 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3558
3640
  * @returns Array of app items.
3559
3641
  */
3560
3642
  async listApps(t) {
3561
- const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3562
- return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, {
3643
+ const { folderId: e, ShowVersions: s, projectId: n } = t || {};
3644
+ return e ? await a(this, l, y).call(this, "GET", `${P}/${e}/items`, {
3563
3645
  query: {
3564
- itemType: Mt,
3646
+ itemType: Kt,
3565
3647
  ...s && { ShowVersions: s }
3566
3648
  }
3567
- }) : await a(this, h, p).call(this, "GET", `${m}`, {
3649
+ }) : await a(this, l, y).call(this, "GET", `${m}`, {
3568
3650
  query: {
3569
- itemType: Mt,
3651
+ itemType: Kt,
3570
3652
  ...s && { ShowVersions: s },
3571
- ...r && { projectId: r }
3653
+ ...n && { projectId: n }
3572
3654
  }
3573
3655
  });
3574
3656
  }
@@ -3579,7 +3661,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3579
3661
  */
3580
3662
  async createApp(t) {
3581
3663
  const { appProps: e } = t;
3582
- return await a(this, h, Ct).call(this, t, Mt, e);
3664
+ return await a(this, l, Bt).call(this, t, Kt, e);
3583
3665
  }
3584
3666
  /**
3585
3667
  * Downloads an app's full ZIP file. Returns the raw fetch Response.
@@ -3588,7 +3670,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3588
3670
  * @returns A fetch Response containing the ZIP data.
3589
3671
  */
3590
3672
  async downloadApp(t, e) {
3591
- return await a(this, h, $t).call(this, t, e);
3673
+ return await a(this, l, Pt).call(this, t, e);
3592
3674
  }
3593
3675
  /**
3594
3676
  * Downloads only the JavaScript bundle from an app's ZIP.
@@ -3598,11 +3680,11 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3598
3680
  * @returns A fetch Response containing the bundle JavaScript text.
3599
3681
  */
3600
3682
  async downloadAppBundle(t, e) {
3601
- const { versionTag: s, withDraft: r } = e || {};
3602
- return await a(this, h, M).call(this, `${m}/${t}/download/bundle`, {
3683
+ const { versionTag: s, withDraft: n } = e || {};
3684
+ return await a(this, l, J).call(this, `${m}/${t}/download/bundle`, {
3603
3685
  query: {
3604
3686
  ...s && { versionTag: s },
3605
- ...r && { withDraft: r }
3687
+ ...n && { withDraft: n }
3606
3688
  }
3607
3689
  });
3608
3690
  }
@@ -3611,7 +3693,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3611
3693
  * @param appId - The app's unique identifier.
3612
3694
  */
3613
3695
  async archiveApp(t) {
3614
- return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3696
+ return await a(this, l, y).call(this, "DELETE", `${m}/${t}`);
3615
3697
  }
3616
3698
  // ─── NPM Registry ────────────────────────────────────────────────
3617
3699
  /**
@@ -3623,7 +3705,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3623
3705
  * @returns The registry, scope, read-only token, and assembled `.npmrc`.
3624
3706
  */
3625
3707
  async getNpmCredentials() {
3626
- return await a(this, h, p).call(this, "GET", `${fn}/credentials`);
3708
+ return await a(this, l, y).call(this, "GET", `${Zr}/credentials`);
3627
3709
  }
3628
3710
  // ─── Execution ───────────────────────────────────────────────────
3629
3711
  /**
@@ -3642,7 +3724,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3642
3724
  */
3643
3725
  async executeComponent(t, e, s) {
3644
3726
  if (this.localServerUrl) {
3645
- const r = `${this.localServerUrl}/api/${j}/${t}/execute`, i = await fetch(r, {
3727
+ const n = `${this.localServerUrl}/api/${H}/${t}/execute`, i = await fetch(n, {
3646
3728
  method: "POST",
3647
3729
  headers: { "Content-Type": "application/json" },
3648
3730
  body: JSON.stringify(e)
@@ -3655,7 +3737,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3655
3737
  }
3656
3738
  return await i.json();
3657
3739
  }
3658
- return await a(this, h, p).call(this, "POST", `${j}/${t}/execute`, {
3740
+ return await a(this, l, y).call(this, "POST", `${H}/${t}/execute`, {
3659
3741
  body: JSON.stringify(e),
3660
3742
  query: { ...s && { versionTag: s } },
3661
3743
  contentType: "application/json"
@@ -3667,16 +3749,16 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3667
3749
  */
3668
3750
  async abortExecution(t) {
3669
3751
  if (this.localServerUrl) {
3670
- const e = `${this.localServerUrl}/api/${j}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
3752
+ const e = `${this.localServerUrl}/api/${H}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
3671
3753
  if (!s.ok) {
3672
- const r = await s.text().catch(() => "");
3754
+ const n = await s.text().catch(() => "");
3673
3755
  throw new Error(
3674
- `Local server request failed: ${s.status} - ${r}`
3756
+ `Local server request failed: ${s.status} - ${n}`
3675
3757
  );
3676
3758
  }
3677
3759
  return await s.json();
3678
3760
  }
3679
- return await a(this, h, p).call(this, "POST", `${j}/progress/${t}/abort`);
3761
+ return await a(this, l, y).call(this, "POST", `${H}/progress/${t}/abort`);
3680
3762
  }
3681
3763
  /**
3682
3764
  * Lists all executions for a given component.
@@ -3693,7 +3775,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3693
3775
  */
3694
3776
  async listExecutions(t, e) {
3695
3777
  if (this.localServerUrl) {
3696
- const s = e ? `?projectId=${encodeURIComponent(e)}` : "", r = `${this.localServerUrl}/api/${j}/${t}/progress${s}`, i = await fetch(r);
3778
+ const s = e ? `?projectId=${encodeURIComponent(e)}` : "", n = `${this.localServerUrl}/api/${H}/${t}/progress${s}`, i = await fetch(n);
3697
3779
  if (!i.ok) {
3698
3780
  const o = await i.text().catch(() => "");
3699
3781
  throw new Error(
@@ -3702,7 +3784,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3702
3784
  }
3703
3785
  return await i.json();
3704
3786
  }
3705
- return await a(this, h, p).call(this, "GET", `${j}/${t}/progress`, { query: { ...e && { projectId: e } } });
3787
+ return await a(this, l, y).call(this, "GET", `${H}/${t}/progress`, { query: { ...e && { projectId: e } } });
3706
3788
  }
3707
3789
  /**
3708
3790
  * Gets details of a specific execution, including its messages.
@@ -3711,16 +3793,16 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3711
3793
  */
3712
3794
  async getExecution(t) {
3713
3795
  if (this.localServerUrl) {
3714
- const e = `${this.localServerUrl}/api/${j}/progress/${t}`, s = await fetch(e);
3796
+ const e = `${this.localServerUrl}/api/${H}/progress/${t}`, s = await fetch(e);
3715
3797
  if (!s.ok) {
3716
- const r = await s.text().catch(() => "");
3798
+ const n = await s.text().catch(() => "");
3717
3799
  throw new Error(
3718
- `Local server request failed: ${s.status} - ${r}`
3800
+ `Local server request failed: ${s.status} - ${n}`
3719
3801
  );
3720
3802
  }
3721
3803
  return await s.json();
3722
3804
  }
3723
- return await a(this, h, p).call(this, "GET", `${j}/progress/${t}`);
3805
+ return await a(this, l, y).call(this, "GET", `${H}/progress/${t}`);
3724
3806
  }
3725
3807
  /**
3726
3808
  * Subscribes to real-time execution progress via WebSocket.
@@ -3729,15 +3811,15 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3729
3811
  * @param onUpdateCallback - Callback invoked on each progress/result event.
3730
3812
  */
3731
3813
  async onExecutionProgress(t, e) {
3732
- const s = this.localServerUrl ?? this.wsUrl, r = await pt(s, {
3814
+ const s = this.localServerUrl ?? this.wsUrl, n = await bt(s, {
3733
3815
  auth: { accessToken: this.accessToken },
3734
3816
  transports: ["websocket"]
3735
3817
  });
3736
- r.on("connect", function() {
3737
- r.emit("executionSubscription", JSON.stringify({ executionId: t })), r.on("execution", (i) => {
3818
+ n.on("connect", function() {
3819
+ n.emit("executionSubscription", JSON.stringify({ executionId: t })), n.on("execution", (i) => {
3738
3820
  e(i);
3739
3821
  });
3740
- }), r.on("connect_error", function(i) {
3822
+ }), n.on("connect_error", function(i) {
3741
3823
  console.log(i);
3742
3824
  });
3743
3825
  }
@@ -3748,7 +3830,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3748
3830
  * renderable views. See `src/core/documents.ts` for the model and schema.
3749
3831
  */
3750
3832
  documents(t) {
3751
- return new Ke(this, t);
3833
+ return new hs(this, t);
3752
3834
  }
3753
3835
  /**
3754
3836
  * A project's history of connected documents (Revit models, AutoCAD
@@ -3757,14 +3839,14 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3757
3839
  * or write it; the storage underneath is private and will move.
3758
3840
  */
3759
3841
  history(t) {
3760
- return new an(this, t);
3842
+ return new Yr(this, t);
3761
3843
  }
3762
3844
  /**
3763
3845
  * The recipe registry and runner: scripts that write change requests in a
3764
3846
  * native application's language. See `src/core/recipes.ts`.
3765
3847
  */
3766
3848
  get recipes() {
3767
- return l(this, wt) ?? _(this, wt, new ln(this)), l(this, wt);
3849
+ return u(this, vt) ?? _(this, vt, new zr(this)), u(this, vt);
3768
3850
  }
3769
3851
  // ─── Hidden Files ────────────────────────────────────────────────
3770
3852
  /**
@@ -3777,9 +3859,9 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3777
3859
  * @returns The hidden file ID.
3778
3860
  */
3779
3861
  async createHiddenFile(t, e, s) {
3780
- const r = new FormData();
3781
- return r.append("file", t), r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, h, p).call(this, "POST", `${m}/${L}`, {
3782
- body: r
3862
+ const n = new FormData();
3863
+ return n.append("file", t), n.append("parentItemId", e), s != null && n.append("tag", s), await a(this, l, y).call(this, "POST", `${m}/${q}`, {
3864
+ body: n
3783
3865
  });
3784
3866
  }
3785
3867
  /**
@@ -3793,11 +3875,11 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3793
3875
  * @returns One result per uploaded file, in order, each with its hidden file ID.
3794
3876
  */
3795
3877
  async createHiddenFilesBatch(t, e, s) {
3796
- const r = new FormData();
3878
+ const n = new FormData();
3797
3879
  for (const i of t)
3798
- r.append("files", i);
3799
- return r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, h, p).call(this, "POST", `${m}/${L}/batch`, {
3800
- body: r
3880
+ n.append("files", i);
3881
+ return n.append("parentItemId", e), s != null && n.append("tag", s), await a(this, l, y).call(this, "POST", `${m}/${q}/batch`, {
3882
+ body: n
3801
3883
  });
3802
3884
  }
3803
3885
  /**
@@ -3805,21 +3887,21 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3805
3887
  * @param hiddenId - The hidden file's unique identifier.
3806
3888
  */
3807
3889
  async deleteHiddenFile(t) {
3808
- return await a(this, h, p).call(this, "DELETE", `${m}/${L}/${t}`);
3890
+ return await a(this, l, y).call(this, "DELETE", `${m}/${q}/${t}`);
3809
3891
  }
3810
3892
  /**
3811
3893
  * Gets metadata for a hidden file.
3812
3894
  * @param hiddenId - The hidden file's unique identifier.
3813
3895
  */
3814
3896
  async getHiddenFile(t) {
3815
- return await a(this, h, p).call(this, "GET", `${m}/${L}/${t}`);
3897
+ return await a(this, l, y).call(this, "GET", `${m}/${q}/${t}`);
3816
3898
  }
3817
3899
  /**
3818
3900
  * Downloads a hidden file's content. Returns the raw fetch Response.
3819
3901
  * @param hiddenId - The hidden file's unique identifier.
3820
3902
  */
3821
3903
  async downloadHiddenFile(t) {
3822
- return await a(this, h, M).call(this, `${m}/${L}/${t}/download`);
3904
+ return await a(this, l, J).call(this, `${m}/${q}/${t}/download`);
3823
3905
  }
3824
3906
  /**
3825
3907
  * Mints a short-lived presigned URL for a hidden file so the browser can
@@ -3839,7 +3921,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3839
3921
  * an ISO timestamp when it stops working.
3840
3922
  */
3841
3923
  async getHiddenFileSignedUrl(t, e) {
3842
- return await a(this, h, p).call(this, "GET", `${m}/${L}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
3924
+ return await a(this, l, y).call(this, "GET", `${m}/${q}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
3843
3925
  }
3844
3926
  /**
3845
3927
  * Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
@@ -3860,7 +3942,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3860
3942
  * 900 (15 min) server-side; values are clamped to that range.
3861
3943
  */
3862
3944
  async getHiddenFileSignedUrlsBatch(t, e) {
3863
- return await a(this, h, ft).call(this, t, async (s) => (await a(this, h, p).call(this, "POST", `${m}/${L}/signed-url/batch`, {
3945
+ return await a(this, l, wt).call(this, t, async (s) => (await a(this, l, y).call(this, "POST", `${m}/${q}/signed-url/batch`, {
3864
3946
  body: JSON.stringify({
3865
3947
  hiddenFileIds: s,
3866
3948
  ...e != null && { expiresIn: e }
@@ -3876,14 +3958,14 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3876
3958
  * @returns Array of hidden file entities.
3877
3959
  */
3878
3960
  async getHiddenFilesByParent(t, e) {
3879
- return await a(this, h, p).call(this, "GET", `${m}/${t}/${L}`, { ...e != null && { query: { tag: e } } });
3961
+ return await a(this, l, y).call(this, "GET", `${m}/${t}/${q}`, { ...e != null && { query: { tag: e } } });
3880
3962
  }
3881
3963
  /**
3882
3964
  * Deletes all hidden files attached to a parent item.
3883
3965
  * @param parentFileId - The parent item's unique identifier.
3884
3966
  */
3885
3967
  async deleteHiddenFilesByParent(t) {
3886
- return await a(this, h, p).call(this, "DELETE", `${m}/${t}/${L}`);
3968
+ return await a(this, l, y).call(this, "DELETE", `${m}/${t}/${q}`);
3887
3969
  }
3888
3970
  // ─── Icons ───────────────────────────────────────────────────────
3889
3971
  /**
@@ -3895,7 +3977,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3895
3977
  */
3896
3978
  async uploadItemIcon(t, e) {
3897
3979
  const s = new FormData();
3898
- return s.append("icon", e), await a(this, h, p).call(this, "PUT", `${m}/${t}/icon`, {
3980
+ return s.append("icon", e), await a(this, l, y).call(this, "PUT", `${m}/${t}/icon`, {
3899
3981
  body: s
3900
3982
  });
3901
3983
  }
@@ -3905,7 +3987,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3905
3987
  * @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
3906
3988
  */
3907
3989
  async getItemIcon(t) {
3908
- return await a(this, h, M).call(this, `${m}/${t}/icon`);
3990
+ return await a(this, l, J).call(this, `${m}/${t}/icon`);
3909
3991
  }
3910
3992
  /**
3911
3993
  * Removes the icon from an item.
@@ -3913,7 +3995,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3913
3995
  * @returns The updated item with icon fields removed.
3914
3996
  */
3915
3997
  async removeItemIcon(t) {
3916
- return await a(this, h, p).call(this, "DELETE", `${m}/${t}/icon`);
3998
+ return await a(this, l, y).call(this, "DELETE", `${m}/${t}/icon`);
3917
3999
  }
3918
4000
  // ─── General Item Operations ─────────────────────────────────────
3919
4001
  /**
@@ -3923,7 +4005,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3923
4005
  * @returns The updated item.
3924
4006
  */
3925
4007
  async updateItem(t, e) {
3926
- return await a(this, h, p).call(this, "PUT", `${m}/${t}`, {
4008
+ return await a(this, l, y).call(this, "PUT", `${m}/${t}`, {
3927
4009
  body: JSON.stringify(e),
3928
4010
  contentType: "application/json"
3929
4011
  });
@@ -3938,9 +4020,9 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3938
4020
  * @param metadata - Optional free-JSON metadata to store on the new version.
3939
4021
  * @returns The created version.
3940
4022
  */
3941
- async createVersion(t, e, s, r, i) {
4023
+ async createVersion(t, e, s, n, i) {
3942
4024
  const o = new FormData();
3943
- return o.append("file", e), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await a(this, h, p).call(this, "POST", `${m}/${t}/version`, { body: o });
4025
+ return o.append("file", e), o.append("versionTag", s), n && o.append("extraProps", JSON.stringify(n)), i && o.append("metadata", JSON.stringify(i)), await a(this, l, y).call(this, "POST", `${m}/${t}/version`, { body: o });
3944
4026
  }
3945
4027
  /**
3946
4028
  * Lists versions of an item. Pass `archived: true` to fetch only archived
@@ -3950,7 +4032,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3950
4032
  * @returns Array of versions, sorted by creation date descending.
3951
4033
  */
3952
4034
  async listVersions(t, e = {}) {
3953
- return await a(this, h, p).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
4035
+ return await a(this, l, y).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
3954
4036
  }
3955
4037
  /**
3956
4038
  * Batch variant of {@link listVersions}. Lists the versions of many items in
@@ -3969,9 +4051,9 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3969
4051
  */
3970
4052
  async listVersionsBatch(t, e = {}) {
3971
4053
  const { archived: s } = e;
3972
- return await a(this, h, ft).call(this, t, async (r) => (await a(this, h, p).call(this, "POST", `${m}/batch/versions`, {
4054
+ return await a(this, l, wt).call(this, t, async (n) => (await a(this, l, y).call(this, "POST", `${m}/batch/versions`, {
3973
4055
  body: JSON.stringify({
3974
- itemIds: r,
4056
+ itemIds: n,
3975
4057
  ...s !== void 0 && { archived: s }
3976
4058
  }),
3977
4059
  contentType: "application/json"
@@ -3987,7 +4069,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3987
4069
  * @returns The archived version.
3988
4070
  */
3989
4071
  async archiveVersion(t, e) {
3990
- return await a(this, h, p).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
4072
+ return await a(this, l, y).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
3991
4073
  }
3992
4074
  /**
3993
4075
  * Recovers a previously archived version, restoring it to the active list.
@@ -3996,7 +4078,7 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3996
4078
  * @returns The recovered version.
3997
4079
  */
3998
4080
  async recoverVersion(t, e) {
3999
- return await a(this, h, p).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
4081
+ return await a(this, l, y).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
4000
4082
  }
4001
4083
  /**
4002
4084
  * Permanently deletes a version, including its file in object storage.
@@ -4005,59 +4087,59 @@ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
4005
4087
  * @param versionTag - The version's tag (e.g. "v2").
4006
4088
  */
4007
4089
  async deleteVersion(t, e) {
4008
- return await a(this, h, p).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
4090
+ return await a(this, l, y).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
4009
4091
  }
4010
4092
  };
4011
- h = new WeakSet(), ie = function(t) {
4093
+ l = new WeakSet(), ue = function(t) {
4012
4094
  return `${this.apiUrl}/${t}`;
4013
- }, p = async function(t, e, s) {
4014
- const { body: r, query: i, contentType: o, retries: c, responseType: u, retryAttempt: f } = s || {}, y = a(this, h, ie).call(this, e), w = a(this, h, es).call(this, i), C = await this.resolveAccessToken(), as = {
4015
- ...w,
4016
- ...this.useBearer ? {} : { accessToken: C }
4095
+ }, y = async function(t, e, s) {
4096
+ const { body: n, query: i, contentType: o, retries: h, responseType: d, retryAttempt: f } = s || {}, c = a(this, l, ue).call(this, e), g = a(this, l, ms).call(this, i), v = await this.resolveAccessToken(), V = {
4097
+ ...g,
4098
+ ...this.useBearer ? {} : { accessToken: v }
4017
4099
  };
4018
4100
  try {
4019
- const A = await fetch(
4020
- y + "?" + new URLSearchParams(as).toString(),
4101
+ const O = await fetch(
4102
+ c + "?" + new URLSearchParams(V).toString(),
4021
4103
  {
4022
4104
  method: t,
4023
4105
  headers: {
4024
4106
  Accept: "application/json",
4025
4107
  ...o && { "Content-Type": o },
4026
- ...this.useBearer && { Authorization: `Bearer ${C}` }
4108
+ ...this.useBearer && { Authorization: `Bearer ${v}` }
4027
4109
  },
4028
- ...r && { body: r }
4110
+ ...n && { body: n }
4029
4111
  }
4030
4112
  );
4031
- if (!A.ok) {
4032
- const z = await A.text().then((vt) => vt).catch(() => "");
4033
- throw new we(
4034
- A.status,
4035
- A.statusText,
4036
- z,
4037
- gn(A)
4113
+ if (!O.ok) {
4114
+ const k = await O.text().then((et) => et).catch(() => "");
4115
+ throw new Se(
4116
+ O.status,
4117
+ O.statusText,
4118
+ k,
4119
+ rn(O)
4038
4120
  );
4039
4121
  }
4040
- return u === "blob" ? await A.blob() : A.json().then((z) => z).catch(() => {
4122
+ return d === "blob" ? await O.blob() : O.json().then((k) => k).catch(() => {
4041
4123
  });
4042
- } catch (A) {
4043
- const z = c ?? this.retries;
4044
- if (z > 0 && wn(A)) {
4045
- const vt = f ?? 0;
4046
- return await mn(bn(A, vt)), await a(this, h, p).call(this, t, e, {
4124
+ } catch (O) {
4125
+ const k = h ?? this.retries;
4126
+ if (k > 0 && nn(O)) {
4127
+ const et = f ?? 0;
4128
+ return await sn(on(O, et)), await a(this, l, y).call(this, t, e, {
4047
4129
  ...s,
4048
- retries: z - 1,
4049
- retryAttempt: vt + 1
4130
+ retries: k - 1,
4131
+ retryAttempt: et + 1
4050
4132
  });
4051
4133
  }
4052
- throw A;
4134
+ throw O;
4053
4135
  }
4054
- }, M = async function(t, e) {
4055
- const { query: s } = e || {}, r = a(this, h, ie).call(this, t), i = await this.resolveAccessToken(), o = {
4136
+ }, J = async function(t, e) {
4137
+ const { query: s } = e || {}, n = a(this, l, ue).call(this, t), i = await this.resolveAccessToken(), o = {
4056
4138
  ...s,
4057
4139
  ...this.useBearer ? {} : { accessToken: i }
4058
4140
  };
4059
4141
  return await fetch(
4060
- r + "?" + new URLSearchParams(o).toString(),
4142
+ n + "?" + new URLSearchParams(o).toString(),
4061
4143
  {
4062
4144
  method: "GET",
4063
4145
  ...this.useBearer && {
@@ -4065,146 +4147,146 @@ h = new WeakSet(), ie = function(t) {
4065
4147
  }
4066
4148
  }
4067
4149
  );
4068
- }, wt = new WeakMap(), ft = async function(t, e) {
4150
+ }, vt = new WeakMap(), wt = async function(t, e) {
4069
4151
  if (!t.length) return [];
4070
4152
  const s = [];
4071
- for (let i = 0; i < t.length; i += Ne)
4072
- s.push(t.slice(i, i + Ne));
4153
+ for (let i = 0; i < t.length; i += Ge)
4154
+ s.push(t.slice(i, i + Ge));
4073
4155
  return (await Promise.all(s.map(e))).flat();
4074
- }, $t = async function(t, e) {
4075
- const { versionTag: s, withDraft: r } = e || {};
4076
- return await a(this, h, M).call(this, `${m}/${t}/download`, {
4156
+ }, Pt = async function(t, e) {
4157
+ const { versionTag: s, withDraft: n } = e || {};
4158
+ return await a(this, l, J).call(this, `${m}/${t}/download`, {
4077
4159
  query: {
4078
4160
  ...s && { versionTag: s },
4079
- ...r && { withDraft: r }
4161
+ ...n && { withDraft: n }
4080
4162
  }
4081
4163
  });
4082
- }, Ct = async function(t, e, s) {
4083
- const { name: r, versionTag: i, parentFolderId: o, projectId: c, file: u, metadata: f } = t, y = new FormData();
4084
- return y.append("file", u), y.append("name", r), y.append("versionTag", i), y.append("itemType", e), o && y.append("folderId", o), c && y.append("projectId", c), s && y.append("extraProps", JSON.stringify(s)), f && y.append("metadata", JSON.stringify(f)), await a(this, h, p).call(this, "POST", m, {
4085
- body: y
4164
+ }, Bt = async function(t, e, s) {
4165
+ const { name: n, versionTag: i, parentFolderId: o, projectId: h, file: d, metadata: f } = t, c = new FormData();
4166
+ return c.append("file", d), c.append("name", n), c.append("versionTag", i), c.append("itemType", e), o && c.append("folderId", o), h && c.append("projectId", h), s && c.append("extraProps", JSON.stringify(s)), f && c.append("metadata", JSON.stringify(f)), await a(this, l, y).call(this, "POST", m, {
4167
+ body: c
4086
4168
  });
4087
- }, oe = async function(t, e, s) {
4088
- const { name: r, versionTag: i, parentFolderId: o, file: c, metadata: u } = e;
4089
- let f, y;
4090
- if (c) {
4091
- const w = new FormData();
4092
- w.append("file", c), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), y = await a(this, h, p).call(this, "POST", `${m}/${t}/version`, {
4093
- body: w
4169
+ }, de = async function(t, e, s) {
4170
+ const { name: n, versionTag: i, parentFolderId: o, file: h, metadata: d } = e;
4171
+ let f, c;
4172
+ if (h) {
4173
+ const g = new FormData();
4174
+ g.append("file", h), i && g.append("versionTag", i), s && g.append("extraProps", JSON.stringify(s)), d && g.append("metadata", JSON.stringify(d)), c = await a(this, l, y).call(this, "POST", `${m}/${t}/version`, {
4175
+ body: g
4094
4176
  });
4095
4177
  }
4096
- if (r || o) {
4097
- const w = {
4098
- ...r && { name: r },
4178
+ if (n || o) {
4179
+ const g = {
4180
+ ...n && { name: n },
4099
4181
  ...o && { folderId: o }
4100
- }, C = JSON.stringify(w);
4101
- f = await a(this, h, p).call(this, "PUT", `${m}/${t}`, {
4102
- body: C,
4182
+ }, v = JSON.stringify(g);
4183
+ f = await a(this, l, y).call(this, "PUT", `${m}/${t}`, {
4184
+ body: v,
4103
4185
  contentType: "application/json"
4104
4186
  });
4105
4187
  }
4106
- return { item: f, version: y };
4107
- }, ae = async function(t, e) {
4188
+ return { item: f, version: c };
4189
+ }, fe = async function(t, e) {
4108
4190
  const { showVersions: s = !1 } = e || {};
4109
- return await a(this, h, p).call(this, "GET", `${m}/${t}`, {
4191
+ return await a(this, l, y).call(this, "GET", `${m}/${t}`, {
4110
4192
  query: { showVersions: s }
4111
4193
  });
4112
- }, es = function(t) {
4194
+ }, ms = function(t) {
4113
4195
  return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
4114
- (e, [s, r]) => (e[s] = r, e),
4196
+ (e, [s, n]) => (e[s] = n, e),
4115
4197
  {}
4116
4198
  );
4117
4199
  };
4118
- let re = be;
4119
- function _n() {
4200
+ let le = Ie;
4201
+ function an() {
4120
4202
  if (typeof window > "u" || window.parent === window)
4121
4203
  throw new Error(
4122
4204
  "client.channel only works inside a That Open app, which runs in an iframe of the platform."
4123
4205
  );
4124
4206
  return {
4125
- post: (n) => window.parent.postMessage(n, "*"),
4126
- listen: (n) => {
4207
+ post: (r) => window.parent.postMessage(r, "*"),
4208
+ listen: (r) => {
4127
4209
  const t = (e) => {
4128
- e.source === window.parent && n(e.data);
4210
+ e.source === window.parent && r(e.data);
4129
4211
  };
4130
4212
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
4131
4213
  }
4132
4214
  };
4133
4215
  }
4134
- const ce = "channel:", vn = 1e4;
4135
- function Rt(n) {
4216
+ const pe = "channel:", cn = 1e4;
4217
+ function Lt(r) {
4136
4218
  try {
4137
- n();
4219
+ r();
4138
4220
  } catch (t) {
4139
4221
  console.error("[channel] a listener threw:", t);
4140
4222
  }
4141
4223
  }
4142
- var D, k, O, nt, rt, it, S, he, le, st;
4143
- class ss {
4224
+ var j, x, C, ct, ht, lt, A, ye, me, at;
4225
+ class gs {
4144
4226
  constructor(t, e) {
4145
- b(this, S);
4146
- b(this, D, !1);
4147
- b(this, k, []);
4148
- b(this, O, []);
4149
- b(this, nt, /* @__PURE__ */ new Set());
4150
- b(this, rt, /* @__PURE__ */ new Set());
4151
- b(this, it, /* @__PURE__ */ new Set());
4227
+ b(this, A);
4228
+ b(this, j, !1);
4229
+ b(this, x, []);
4230
+ b(this, C, []);
4231
+ b(this, ct, /* @__PURE__ */ new Set());
4232
+ b(this, ht, /* @__PURE__ */ new Set());
4233
+ b(this, lt, /* @__PURE__ */ new Set());
4152
4234
  this.transport = t, this.controls = e;
4153
4235
  }
4154
4236
  /** Whether the platform has confirmed this tab is in the room. */
4155
4237
  get joined() {
4156
- return l(this, D);
4238
+ return u(this, j);
4157
4239
  }
4158
4240
  /** Who else is in the room right now, as the platform last reported. */
4159
4241
  get peers() {
4160
- return l(this, k);
4242
+ return u(this, x);
4161
4243
  }
4162
4244
  /**
4163
4245
  * Enters the room. Resolves when the platform confirms; rejects if it
4164
4246
  * refuses or does not answer in time. Joining twice is harmless.
4165
4247
  */
4166
4248
  join() {
4167
- return l(this, D) ? Promise.resolve() : a(this, S, he).call(this, "joined", this.controls.join);
4249
+ return u(this, j) ? Promise.resolve() : a(this, A, ye).call(this, "joined", this.controls.join);
4168
4250
  }
4169
4251
  /** Leaves the room. Handlers stay registered, so `join()` resumes them. */
4170
4252
  leave() {
4171
- return !l(this, D) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, he).call(this, "left", this.controls.leave);
4253
+ return !u(this, j) && !u(this, C).some((t) => t.want === "joined") ? Promise.resolve() : a(this, A, ye).call(this, "left", this.controls.leave);
4172
4254
  }
4173
4255
  /** Fires when `joined` or `peers` changes. Returns a function that stops it. */
4174
4256
  onChange(t) {
4175
- return l(this, nt).add(t), () => void l(this, nt).delete(t);
4257
+ return u(this, ct).add(t), () => void u(this, ct).delete(t);
4176
4258
  }
4177
4259
  onPeerJoined(t) {
4178
- return l(this, rt).add(t), () => void l(this, rt).delete(t);
4260
+ return u(this, ht).add(t), () => void u(this, ht).delete(t);
4179
4261
  }
4180
4262
  onPeerLeft(t) {
4181
- return l(this, it).add(t), () => void l(this, it).delete(t);
4263
+ return u(this, lt).add(t), () => void u(this, lt).delete(t);
4182
4264
  }
4183
4265
  /** @internal */
4184
4266
  applyJoined() {
4185
- _(this, D, !0), a(this, S, le).call(this, "joined"), a(this, S, st).call(this);
4267
+ _(this, j, !0), a(this, A, me).call(this, "joined"), a(this, A, at).call(this);
4186
4268
  }
4187
4269
  /** @internal */
4188
4270
  applyLeft() {
4189
- _(this, D, !1), _(this, k, []), a(this, S, le).call(this, "left"), a(this, S, st).call(this);
4271
+ _(this, j, !1), _(this, x, []), a(this, A, me).call(this, "left"), a(this, A, at).call(this);
4190
4272
  }
4191
4273
  /** @internal */
4192
4274
  applyPeers(t) {
4193
- _(this, k, t), a(this, S, st).call(this);
4275
+ _(this, x, t), a(this, A, at).call(this);
4194
4276
  }
4195
4277
  /** @internal */
4196
4278
  applyPeerJoined(t) {
4197
- !l(this, D) || l(this, k).some((e) => e.from === t.from) || (_(this, k, [...l(this, k), t]), l(this, rt).forEach((e) => Rt(() => e(t))), a(this, S, st).call(this));
4279
+ !u(this, j) || u(this, x).some((e) => e.from === t.from) || (_(this, x, [...u(this, x), t]), u(this, ht).forEach((e) => Lt(() => e(t))), a(this, A, at).call(this));
4198
4280
  }
4199
4281
  /** @internal */
4200
4282
  applyPeerLeft(t) {
4201
- const e = l(this, k).find((s) => s.from === t);
4202
- e && (_(this, k, l(this, k).filter((s) => s.from !== t)), l(this, it).forEach((s) => Rt(() => s(e))), a(this, S, st).call(this));
4283
+ const e = u(this, x).find((s) => s.from === t);
4284
+ e && (_(this, x, u(this, x).filter((s) => s.from !== t)), u(this, lt).forEach((s) => Lt(() => s(e))), a(this, A, at).call(this));
4203
4285
  }
4204
4286
  /** @internal */
4205
4287
  failPending(t) {
4206
- const e = l(this, O);
4207
- return _(this, O, []), e.forEach((s) => {
4288
+ const e = u(this, C);
4289
+ return _(this, C, []), e.forEach((s) => {
4208
4290
  clearTimeout(s.timer), s.reject(t);
4209
4291
  }), e.length > 0;
4210
4292
  }
@@ -4212,77 +4294,77 @@ class ss {
4212
4294
  this.transport.post(t);
4213
4295
  }
4214
4296
  }
4215
- D = new WeakMap(), k = new WeakMap(), O = new WeakMap(), nt = new WeakMap(), rt = new WeakMap(), it = new WeakMap(), S = new WeakSet(), he = function(t, e) {
4216
- return new Promise((s, r) => {
4297
+ j = new WeakMap(), x = new WeakMap(), C = new WeakMap(), ct = new WeakMap(), ht = new WeakMap(), lt = new WeakMap(), A = new WeakSet(), ye = function(t, e) {
4298
+ return new Promise((s, n) => {
4217
4299
  const i = {
4218
4300
  want: t,
4219
4301
  resolve: s,
4220
- reject: r,
4302
+ reject: n,
4221
4303
  timer: setTimeout(() => {
4222
- _(this, O, l(this, O).filter((o) => o !== i)), r(
4304
+ _(this, C, u(this, C).filter((o) => o !== i)), n(
4223
4305
  new Error(
4224
4306
  `The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
4225
4307
  )
4226
4308
  );
4227
- }, vn)
4309
+ }, cn)
4228
4310
  };
4229
- l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
4311
+ u(this, C).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
4230
4312
  });
4231
- }, le = function(t) {
4232
- const e = l(this, O).filter((s) => s.want === t);
4233
- _(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
4313
+ }, me = function(t) {
4314
+ const e = u(this, C).filter((s) => s.want === t);
4315
+ _(this, C, u(this, C).filter((s) => s.want !== t)), e.forEach((s) => {
4234
4316
  clearTimeout(s.timer), s.resolve();
4235
4317
  });
4236
- }, st = function() {
4237
- l(this, nt).forEach((t) => Rt(t));
4318
+ }, at = function() {
4319
+ u(this, ct).forEach((t) => Lt(t));
4238
4320
  };
4239
- var ot;
4240
- class En extends ss {
4321
+ var ut;
4322
+ class hn extends gs {
4241
4323
  /** @internal Use `client.channel.collab()`. */
4242
4324
  constructor(e) {
4243
4325
  super(e, {
4244
4326
  join: { action: "joinCollab" },
4245
4327
  leave: { action: "leaveCollab" }
4246
4328
  });
4247
- b(this, ot, /* @__PURE__ */ new Map());
4329
+ b(this, ut, /* @__PURE__ */ new Map());
4248
4330
  }
4249
4331
  /**
4250
4332
  * Listens for an event other tabs send. Any number of listeners per event.
4251
4333
  * @returns a function that removes the listener.
4252
4334
  */
4253
4335
  on(e, s) {
4254
- const r = l(this, ot).get(e) ?? /* @__PURE__ */ new Set();
4255
- return r.add(s), l(this, ot).set(e, r), () => void r.delete(s);
4336
+ const n = u(this, ut).get(e) ?? /* @__PURE__ */ new Set();
4337
+ return n.add(s), u(this, ut).set(e, n), () => void n.delete(s);
4256
4338
  }
4257
4339
  /**
4258
4340
  * Sends an event to the other tabs in the room. Does nothing while this tab
4259
4341
  * is not in it, matching what the platform does with a message from outside.
4260
4342
  */
4261
4343
  send(e, s) {
4262
- if (e.startsWith(ce))
4263
- throw new Error(`Message types starting with '${ce}' are reserved.`);
4344
+ if (e.startsWith(pe))
4345
+ throw new Error(`Message types starting with '${pe}' are reserved.`);
4264
4346
  this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
4265
4347
  }
4266
4348
  accepts(e) {
4267
4349
  return e === void 0 || e === "collab";
4268
4350
  }
4269
4351
  async handle(e) {
4270
- const s = l(this, ot).get(e.type);
4352
+ const s = u(this, ut).get(e.type);
4271
4353
  if (!(s != null && s.size)) return { handled: !1 };
4272
- const r = ns(e);
4273
- return s.forEach((i) => Rt(() => i(e.payload, r))), { handled: !0 };
4354
+ const n = ws(e);
4355
+ return s.forEach((i) => Lt(() => i(e.payload, n))), { handled: !0 };
4274
4356
  }
4275
4357
  }
4276
- ot = new WeakMap();
4277
- var G;
4278
- class Tn extends ss {
4358
+ ut = new WeakMap();
4359
+ var W;
4360
+ class ln extends gs {
4279
4361
  /** @internal Use `client.channel.external(kind)`. */
4280
4362
  constructor(e, s) {
4281
4363
  super(e, {
4282
4364
  join: { action: "joinExternal", kind: s },
4283
4365
  leave: { action: "leaveExternal", kind: s }
4284
4366
  });
4285
- b(this, G, /* @__PURE__ */ new Map());
4367
+ b(this, W, /* @__PURE__ */ new Map());
4286
4368
  this.kind = s;
4287
4369
  }
4288
4370
  /**
@@ -4296,43 +4378,43 @@ class Tn extends ss {
4296
4378
  * @returns a function that removes the handler.
4297
4379
  */
4298
4380
  on(e, s) {
4299
- if (l(this, G).has(e))
4381
+ if (u(this, W).has(e))
4300
4382
  throw new Error(
4301
4383
  `"${e}" already has a handler in this room. Remove it first.`
4302
4384
  );
4303
- return l(this, G).set(e, s), () => void l(this, G).delete(e);
4385
+ return u(this, W).set(e, s), () => void u(this, W).delete(e);
4304
4386
  }
4305
4387
  accepts(e, s) {
4306
4388
  return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
4307
4389
  }
4308
4390
  /** @internal Whether this room has any handler at all. */
4309
4391
  get hasHandlers() {
4310
- return l(this, G).size > 0;
4392
+ return u(this, W).size > 0;
4311
4393
  }
4312
4394
  async handle(e) {
4313
- const s = l(this, G).get(e.type);
4395
+ const s = u(this, W).get(e.type);
4314
4396
  if (!s) return { handled: !1 };
4315
4397
  try {
4316
- return { handled: !0, value: await s(e.payload, ns(e)) };
4317
- } catch (r) {
4398
+ return { handled: !0, value: await s(e.payload, ws(e)) };
4399
+ } catch (n) {
4318
4400
  return {
4319
4401
  handled: !0,
4320
- error: r instanceof Error ? r.message : String(r)
4402
+ error: n instanceof Error ? n.message : String(n)
4321
4403
  };
4322
4404
  }
4323
4405
  }
4324
4406
  }
4325
- G = new WeakMap();
4326
- function ns(n) {
4407
+ W = new WeakMap();
4408
+ function ws(r) {
4327
4409
  return {
4328
- from: n.from,
4329
- at: n.at,
4330
- requestId: n.requestId,
4331
- kind: n.kind
4410
+ from: r.from,
4411
+ at: r.at,
4412
+ requestId: r.requestId,
4413
+ kind: r.kind
4332
4414
  };
4333
4415
  }
4334
- function Sn(n) {
4335
- const t = n;
4416
+ function un(r) {
4417
+ const t = r;
4336
4418
  if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
4337
4419
  const e = t.message;
4338
4420
  return !e || typeof e.type != "string" ? null : {
@@ -4345,20 +4427,20 @@ function Sn(n) {
4345
4427
  kind: typeof e.kind == "string" ? e.kind : void 0
4346
4428
  };
4347
4429
  }
4348
- var K, bt, U, V, J, E, ue, Nt, rs, is, os, de;
4349
- class kn {
4430
+ var Z, Tt, M, K, z, T, ge, Ft, bs, _s, Es, we;
4431
+ class dn {
4350
4432
  constructor(t) {
4351
- b(this, E);
4352
- b(this, K);
4353
- b(this, bt);
4354
- b(this, U);
4355
- b(this, V, /* @__PURE__ */ new Map());
4356
- b(this, J, /* @__PURE__ */ new Set());
4357
- _(this, K, t), _(this, bt, t.listen((e) => void a(this, E, rs).call(this, e)));
4433
+ b(this, T);
4434
+ b(this, Z);
4435
+ b(this, Tt);
4436
+ b(this, M);
4437
+ b(this, K, /* @__PURE__ */ new Map());
4438
+ b(this, z, /* @__PURE__ */ new Set());
4439
+ _(this, Z, t), _(this, Tt, t.listen((e) => void a(this, T, bs).call(this, e)));
4358
4440
  }
4359
4441
  /** The collaboration room for this app. Always the same instance. */
4360
4442
  collab() {
4361
- return l(this, U) ?? _(this, U, new En(l(this, K))), l(this, U);
4443
+ return u(this, M) ?? _(this, M, new hn(u(this, Z))), u(this, M);
4362
4444
  }
4363
4445
  /**
4364
4446
  * The room for commands from this account's external tools of one `kind`
@@ -4367,71 +4449,71 @@ class kn {
4367
4449
  */
4368
4450
  external(t) {
4369
4451
  const e = t ?? "";
4370
- let s = l(this, V).get(e);
4371
- return s || (s = new Tn(l(this, K), t), l(this, V).set(e, s)), s;
4452
+ let s = u(this, K).get(e);
4453
+ return s || (s = new ln(u(this, Z), t), u(this, K).set(e, s)), s;
4372
4454
  }
4373
4455
  /** Stops listening. For tests and teardown; an app normally never calls it. */
4374
4456
  dispose() {
4375
- l(this, bt).call(this);
4457
+ u(this, Tt).call(this);
4376
4458
  }
4377
4459
  }
4378
- K = new WeakMap(), bt = new WeakMap(), U = new WeakMap(), V = new WeakMap(), J = new WeakMap(), E = new WeakSet(), ue = function() {
4379
- return [...l(this, U) ? [l(this, U)] : [], ...l(this, V).values()];
4380
- }, Nt = function(t, e) {
4381
- if (t === "collab") return l(this, U);
4460
+ Z = new WeakMap(), Tt = new WeakMap(), M = new WeakMap(), K = new WeakMap(), z = new WeakMap(), T = new WeakSet(), ge = function() {
4461
+ return [...u(this, M) ? [u(this, M)] : [], ...u(this, K).values()];
4462
+ }, Ft = function(t, e) {
4463
+ if (t === "collab") return u(this, M);
4382
4464
  if (t === "external")
4383
- return l(this, V).get(typeof e == "string" ? e : "");
4384
- }, rs = async function(t) {
4385
- const e = Sn(t);
4465
+ return u(this, K).get(typeof e == "string" ? e : "");
4466
+ }, bs = async function(t) {
4467
+ const e = un(t);
4386
4468
  if (e) {
4387
- if (e.type.startsWith(ce)) {
4388
- a(this, E, is).call(this, e);
4469
+ if (e.type.startsWith(pe)) {
4470
+ a(this, T, _s).call(this, e);
4389
4471
  return;
4390
4472
  }
4391
- await a(this, E, os).call(this, e);
4473
+ await a(this, T, Es).call(this, e);
4392
4474
  }
4393
- }, is = function(t) {
4394
- var s, r, i;
4475
+ }, _s = function(t) {
4476
+ var s, n, i;
4395
4477
  const e = t.payload ?? {};
4396
4478
  switch (t.type) {
4397
4479
  case "channel:joined":
4398
- (s = a(this, E, Nt).call(this, e.scope, e.kind)) == null || s.applyJoined();
4480
+ (s = a(this, T, Ft).call(this, e.scope, e.kind)) == null || s.applyJoined();
4399
4481
  break;
4400
4482
  case "channel:left":
4401
- (r = a(this, E, Nt).call(this, e.scope, e.kind)) == null || r.applyLeft();
4483
+ (n = a(this, T, Ft).call(this, e.scope, e.kind)) == null || n.applyLeft();
4402
4484
  break;
4403
4485
  case "channel:peers":
4404
- (i = a(this, E, Nt).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
4486
+ (i = a(this, T, Ft).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
4405
4487
  break;
4406
4488
  case "channel:peer-joined":
4407
4489
  case "channel:peer-left": {
4408
4490
  if (!e.from) break;
4409
- const o = e.scope === "collab" ? [l(this, U)] : [...l(this, V).values()].filter(
4410
- (c) => c.accepts("external", e.kind)
4491
+ const o = e.scope === "collab" ? [u(this, M)] : [...u(this, K).values()].filter(
4492
+ (h) => h.accepts("external", e.kind)
4411
4493
  );
4412
- for (const c of o)
4413
- t.type === "channel:peer-joined" ? c == null || c.applyPeerJoined({ from: e.from, kind: e.kind }) : c == null || c.applyPeerLeft(e.from);
4494
+ for (const h of o)
4495
+ t.type === "channel:peer-joined" ? h == null || h.applyPeerJoined({ from: e.from, kind: e.kind }) : h == null || h.applyPeerLeft(e.from);
4414
4496
  break;
4415
4497
  }
4416
4498
  case "channel:error": {
4417
4499
  const o = new Error(String(t.payload));
4418
- a(this, E, ue).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
4500
+ a(this, T, ge).call(this).map((d) => d.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
4419
4501
  break;
4420
4502
  }
4421
4503
  }
4422
- }, os = async function(t) {
4423
- const e = a(this, E, ue).call(this).filter((i) => i.accepts(t.scope, t.kind));
4504
+ }, Es = async function(t) {
4505
+ const e = a(this, T, ge).call(this).filter((i) => i.accepts(t.scope, t.kind));
4424
4506
  let s = !1;
4425
4507
  for (const i of e) {
4426
4508
  const o = await i.handle(t);
4427
- o.handled && (s = !0, t.requestId && a(this, E, de).call(this, t.requestId, o));
4509
+ o.handled && (s = !0, t.requestId && a(this, T, we).call(this, t.requestId, o));
4428
4510
  }
4429
- t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, E, de).call(this, t.requestId, {
4511
+ t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, T, we).call(this, t.requestId, {
4430
4512
  handled: !0,
4431
4513
  error: `No handler for "${t.type}".`
4432
4514
  });
4433
- }, de = function(t, e) {
4434
- l(this, J).has(t) || (l(this, J).add(t), l(this, J).size > 500 && l(this, J).delete(l(this, J).values().next().value), l(this, K).post({
4515
+ }, we = function(t, e) {
4516
+ u(this, z).has(t) || (u(this, z).add(t), u(this, z).size > 500 && u(this, z).delete(u(this, z).values().next().value), u(this, Z).post({
4435
4517
  type: "APP_CHANNEL_PUBLISH",
4436
4518
  message: {
4437
4519
  type: e.error === void 0 ? "reply" : "reply-error",
@@ -4440,9 +4522,9 @@ K = new WeakMap(), bt = new WeakMap(), U = new WeakMap(), V = new WeakMap(), J =
4440
4522
  }
4441
4523
  }));
4442
4524
  };
4443
- const W = "project", X = "notifications";
4444
- var at, _t;
4445
- const _e = class _e extends re {
4525
+ const Q = "project", st = "notifications";
4526
+ var dt, St;
4527
+ const Oe = class Oe extends le {
4446
4528
  /**
4447
4529
  * @param token - A bearer JWT, OR a function returning the current JWT
4448
4530
  * (sync or async). When a function is passed, it's invoked before every
@@ -4451,14 +4533,14 @@ const _e = class _e extends re {
4451
4533
  * @param props - Optional client configuration. `useBearer` is forced to
4452
4534
  * `true` and cannot be overridden.
4453
4535
  */
4454
- constructor(e, s, r) {
4455
- super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
4456
- b(this, at);
4457
- b(this, _t);
4458
- typeof e == "function" && _(this, at, e);
4536
+ constructor(e, s, n) {
4537
+ super(typeof e == "string" ? e : "", s, { ...n, useBearer: !0 });
4538
+ b(this, dt);
4539
+ b(this, St);
4540
+ typeof e == "function" && _(this, dt, e);
4459
4541
  }
4460
4542
  async resolveAccessToken() {
4461
- return l(this, at) ? await l(this, at).call(this) : super.resolveAccessToken();
4543
+ return u(this, dt) ? await u(this, dt).call(this) : super.resolveAccessToken();
4462
4544
  }
4463
4545
  /**
4464
4546
  * Creates a client from the platform context injected into
@@ -4467,8 +4549,8 @@ const _e = class _e extends re {
4467
4549
  * carries a fresh JWT on every navigation.
4468
4550
  */
4469
4551
  static fromPlatformContext(e) {
4470
- const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new _e(s.accessToken, s.apiUrl, e);
4471
- return r.context = s, r;
4552
+ const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, n = new Oe(s.accessToken, s.apiUrl, e);
4553
+ return n.context = s, n;
4472
4554
  }
4473
4555
  /**
4474
4556
  * The platform channel, from inside an app: a collaboration room shared with
@@ -4495,7 +4577,7 @@ const _e = class _e extends re {
4495
4577
  * ```
4496
4578
  */
4497
4579
  get channel() {
4498
- return l(this, _t) ?? _(this, _t, new kn(_n())), l(this, _t);
4580
+ return u(this, St) ?? _(this, St, new dn(an())), u(this, St);
4499
4581
  }
4500
4582
  // ─── Projects (JWT-only backend routes) ──────────────────────────
4501
4583
  /**
@@ -4514,14 +4596,14 @@ const _e = class _e extends re {
4514
4596
  * ```
4515
4597
  */
4516
4598
  async listProjects() {
4517
- return await this.request("GET", W);
4599
+ return await this.request("GET", Q);
4518
4600
  }
4519
4601
  /**
4520
4602
  * Gets a project by ID. JWT-only — lives here because
4521
4603
  * `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
4522
4604
  */
4523
4605
  async getProject(e) {
4524
- return await this.request("GET", `${W}/${e}`);
4606
+ return await this.request("GET", `${Q}/${e}`);
4525
4607
  }
4526
4608
  /**
4527
4609
  * Gets the full project data (users, roles, files, folders) for a project.
@@ -4530,7 +4612,7 @@ const _e = class _e extends re {
4530
4612
  async getProjectData(e) {
4531
4613
  return await this.request(
4532
4614
  "GET",
4533
- `${W}/${e}/data`
4615
+ `${Q}/${e}/data`
4534
4616
  );
4535
4617
  }
4536
4618
  // ─── Account ──────────────────────────────────────────────────────
@@ -4555,7 +4637,7 @@ const _e = class _e extends re {
4555
4637
  async checkPermission(e) {
4556
4638
  return await this.request(
4557
4639
  "GET",
4558
- `${W}/permissions/check`,
4640
+ `${Q}/permissions/check`,
4559
4641
  { query: e }
4560
4642
  );
4561
4643
  }
@@ -4564,7 +4646,7 @@ const _e = class _e extends re {
4564
4646
  * single round-trip; results come back in the same order as `checks`.
4565
4647
  */
4566
4648
  async checkPermissionBatch(e) {
4567
- return (await this.request("POST", `${W}/permissions/check/batch`, {
4649
+ return (await this.request("POST", `${Q}/permissions/check/batch`, {
4568
4650
  body: JSON.stringify({ checks: e }),
4569
4651
  contentType: "application/json"
4570
4652
  })).results;
@@ -4592,7 +4674,7 @@ const _e = class _e extends re {
4592
4674
  * ```
4593
4675
  */
4594
4676
  async getNotifications(e) {
4595
- return await this.request("GET", X, {
4677
+ return await this.request("GET", st, {
4596
4678
  query: {
4597
4679
  ...(e == null ? void 0 : e.cursor) !== void 0 && { cursor: e.cursor },
4598
4680
  ...(e == null ? void 0 : e.limit) !== void 0 && { limit: String(e.limit) }
@@ -4606,7 +4688,7 @@ const _e = class _e extends re {
4606
4688
  async getUnreadNotificationCount() {
4607
4689
  return (await this.request(
4608
4690
  "GET",
4609
- `${X}/unread-count`
4691
+ `${st}/unread-count`
4610
4692
  )).count;
4611
4693
  }
4612
4694
  /**
@@ -4617,7 +4699,7 @@ const _e = class _e extends re {
4617
4699
  async markNotificationsRead(e) {
4618
4700
  return await this.request(
4619
4701
  "POST",
4620
- `${X}/mark-read`,
4702
+ `${st}/mark-read`,
4621
4703
  {
4622
4704
  body: JSON.stringify({ ids: e }),
4623
4705
  contentType: "application/json"
@@ -4628,7 +4710,7 @@ const _e = class _e extends re {
4628
4710
  async markAllNotificationsRead() {
4629
4711
  return await this.request(
4630
4712
  "POST",
4631
- `${X}/mark-all-read`
4713
+ `${st}/mark-all-read`
4632
4714
  );
4633
4715
  }
4634
4716
  /**
@@ -4638,7 +4720,7 @@ const _e = class _e extends re {
4638
4720
  async getNotificationSubscriptions() {
4639
4721
  return await this.request(
4640
4722
  "GET",
4641
- `${X}/subscriptions`
4723
+ `${st}/subscriptions`
4642
4724
  );
4643
4725
  }
4644
4726
  /**
@@ -4652,7 +4734,7 @@ const _e = class _e extends re {
4652
4734
  async unsubscribeFromAutomation(e) {
4653
4735
  return await this.request(
4654
4736
  "DELETE",
4655
- `${X}/subscriptions/${e}`
4737
+ `${st}/subscriptions/${e}`
4656
4738
  );
4657
4739
  }
4658
4740
  /**
@@ -4673,12 +4755,12 @@ const _e = class _e extends re {
4673
4755
  * });
4674
4756
  * ```
4675
4757
  */
4676
- async subscribeToAutomation(e, s, r) {
4758
+ async subscribeToAutomation(e, s, n) {
4677
4759
  return await this.request(
4678
4760
  "POST",
4679
- `${W}/${e}/events/hooks/${s}/subscription`,
4761
+ `${Q}/${e}/events/hooks/${s}/subscription`,
4680
4762
  {
4681
- body: JSON.stringify(r ?? {}),
4763
+ body: JSON.stringify(n ?? {}),
4682
4764
  contentType: "application/json"
4683
4765
  }
4684
4766
  );
@@ -4690,12 +4772,12 @@ const _e = class _e extends re {
4690
4772
  * Throws if the user is not subscribed; use {@link subscribeToAutomation}
4691
4773
  * to create one.
4692
4774
  */
4693
- async updateAutomationSubscription(e, s, r) {
4775
+ async updateAutomationSubscription(e, s, n) {
4694
4776
  return await this.request(
4695
4777
  "PATCH",
4696
- `${W}/${e}/events/hooks/${s}/subscription`,
4778
+ `${Q}/${e}/events/hooks/${s}/subscription`,
4697
4779
  {
4698
- body: JSON.stringify(r),
4780
+ body: JSON.stringify(n),
4699
4781
  contentType: "application/json"
4700
4782
  }
4701
4783
  );
@@ -4727,57 +4809,247 @@ const _e = class _e extends re {
4727
4809
  * ```
4728
4810
  */
4729
4811
  async onNotification(e) {
4730
- const s = await this.resolveAccessToken(), r = pt(`${this.socketOrigin}/notifications`, {
4812
+ const s = await this.resolveAccessToken(), n = bt(`${this.socketOrigin}/notifications`, {
4731
4813
  auth: { accessToken: s },
4732
4814
  transports: ["websocket"]
4733
4815
  });
4734
- return r.on(
4816
+ return n.on(
4735
4817
  "notification.created",
4736
4818
  (i) => e({ type: "created", id: i == null ? void 0 : i.id })
4737
- ), r.on(
4819
+ ), n.on(
4738
4820
  "notification.read",
4739
4821
  (i) => e({ type: "read", id: i == null ? void 0 : i.id })
4740
- ), r.on(
4822
+ ), n.on(
4741
4823
  "notifications.allRead",
4742
4824
  (i) => e({ type: "allRead", batch: i == null ? void 0 : i.batch })
4743
- ), () => r.disconnect();
4825
+ ), () => n.disconnect();
4744
4826
  }
4745
4827
  };
4746
- at = new WeakMap(), _t = new WeakMap();
4747
- let Be = _e;
4748
- const An = {
4828
+ dt = new WeakMap(), St = new WeakMap();
4829
+ let Je = Oe;
4830
+ const fn = "flow:", pn = "flow:op", yn = "flow:source", mn = "revitflow/op@2", Ye = "REVITFLOWCHANGE", We = "REVITFLOWOPERATION";
4831
+ class En {
4832
+ constructor(t) {
4833
+ I(this, "changes", []);
4834
+ this.target = t;
4835
+ }
4836
+ /** How many changes are queued. An operation with none is refused by `build`. */
4837
+ get length() {
4838
+ return this.changes.length;
4839
+ }
4840
+ // The envelope, readable. Whoever writes the queue entry has to put the SAME
4841
+ // values in it as the payload carries — an entry that disagrees with its own
4842
+ // payload is a row describing a different operation — so they are exposed
4843
+ // here rather than passed twice by every caller.
4844
+ get batchId() {
4845
+ return this.target.batchId;
4846
+ }
4847
+ get title() {
4848
+ return this.target.title ?? `${this.changes.length} change(s)`;
4849
+ }
4850
+ get author() {
4851
+ return this.target.author ?? "app";
4852
+ }
4853
+ get userId() {
4854
+ return this.target.userId;
4855
+ }
4856
+ get baseCommit() {
4857
+ return this.target.baseCommit;
4858
+ }
4859
+ /**
4860
+ * Create something. There is no id yet: the attributes describe what it is,
4861
+ * the placement says where it goes, and the operation answers with the id
4862
+ * it got.
4863
+ */
4864
+ add(t, e = {}) {
4865
+ return this.changes.push({ op: "add", attrs: this.pack(t, e) }), this;
4866
+ }
4867
+ /** Write attributes onto an item that already exists, named by the id the target published. */
4868
+ set(t, e, s = {}) {
4869
+ return this.requireId(t, "set"), this.changes.push({ op: "set", item: t, attrs: this.pack(e, s) }), this;
4870
+ }
4871
+ /** Delete an item. Whatever the target cascades along with it is reported, not guessed at here. */
4872
+ remove(t) {
4873
+ return this.requireId(t, "remove"), this.changes.push({ op: "remove", item: t, attrs: {} }), this;
4874
+ }
4875
+ /**
4876
+ * A label for what this operation mostly does. Derived, never read to
4877
+ * decide anything: one operation may add, set and remove at once and still
4878
+ * be atomic, so what each change does is written on the change.
4879
+ */
4880
+ get summary() {
4881
+ const t = new Set(this.changes.map((e) => e.op));
4882
+ return t.size === 1 ? [...t][0] : "mixed";
4883
+ }
4884
+ /**
4885
+ * The .frag bytes, zlib-deflated, ready to upload as the operation's
4886
+ * payload.
4887
+ *
4888
+ * `opId` is taken rather than generated so the caller can put the same id
4889
+ * in the queue entry it writes next ({@link Recipes} mints it before the
4890
+ * run); an id this class invented and did not return would have to be dug
4891
+ * back out of the bytes.
4892
+ */
4893
+ async build(t) {
4894
+ if (this.changes.length === 0)
4895
+ throw new Error(
4896
+ "An operation with no changes is not an operation. Add at least one."
4897
+ );
4898
+ const e = {
4899
+ schema: mn,
4900
+ opId: t,
4901
+ // Through the getters, so the envelope and the queue entry cannot drift
4902
+ // into disagreeing about the same operation.
4903
+ batchId: this.batchId ?? t,
4904
+ targetProject: this.target.project,
4905
+ targetDocument: this.target.document,
4906
+ baseCommit: this.baseCommit,
4907
+ author: this.author,
4908
+ ...this.userId ? { userId: this.userId } : {},
4909
+ title: this.title,
4910
+ summary: this.summary
4911
+ }, [s, n] = await gn();
4912
+ return wn(
4913
+ this.flatbuffer(s, n, t, JSON.stringify(e))
4914
+ );
4915
+ }
4916
+ // ---------------------------------------------------------------------------------------------
4917
+ /** Placement rides in the attributes, in the same string form the target published. */
4918
+ pack(t, e) {
4919
+ const s = {};
4920
+ for (const [n, i] of Object.entries(t ?? {}))
4921
+ n.startsWith(fn) || (s[n] = String(i));
4922
+ return e.position && (s.Position = e.position.map(Ke).join(",")), e.rotationDeg !== void 0 && (s.Rotation = Ke(e.rotationDeg)), e.source && (s[yn] = e.source), s;
4923
+ }
4924
+ requireId(t, e) {
4925
+ if (!t || !t.trim())
4926
+ throw new Error(`A '${e}' has to name the item it acts on.`);
4927
+ }
4928
+ /**
4929
+ * The buffer itself.
4930
+ *
4931
+ * Laid out exactly as the C# writer lays it out, because the add-in's
4932
+ * reader is the one that has to accept both: items first and the container
4933
+ * after, ids handed out by one monotonic counter, attributes as
4934
+ * `[name, value, type]` JSON triples, and a Meshes table that exists but is
4935
+ * empty.
4936
+ *
4937
+ * Empty rather than absent: the reader asks for it unconditionally, and a
4938
+ * model that draws nothing is still a model. Nothing here gets a sample —
4939
+ * an item with no triangles must not have one, because a sample's bounding
4940
+ * box would then have no size and the reader turns a box into a "dimension"
4941
+ * and rejects a falsy one.
4942
+ */
4943
+ flatbuffer(t, e, s, n) {
4944
+ const { Attribute: i, Meshes: o, Model: h, SpatialStructure: d, Transform: f } = e, c = new t.Builder(1024), g = this.changes.length, v = new Uint32Array(g);
4945
+ let V = 1;
4946
+ for (let S = 0; S < g; S++) v[S] = V++;
4947
+ const O = V++, k = (S) => (S(c, 0), c.endVector()), et = o.createShellsVector(c, []), vs = o.createCircleExtrusionsVector(c, []), Ts = k(o.startSamplesVector), Ss = k(o.startRepresentationsVector), Is = k(o.startMaterialsVector), Os = k(o.startLocalTransformsVector), As = k(o.startGlobalTransformsVector), ks = o.createMeshesItemsVector(c, []), xs = o.createMaterialIdsVector(c, []), Cs = o.createRepresentationIdsVector(c, []), Rs = o.createSampleIdsVector(c, []), $s = o.createLocalTransformIdsVector(c, []), Ns = o.createGlobalTransformIdsVector(c, []);
4948
+ o.startMeshes(c), o.addCoordinates(c, f.createTransform(c, 0, 0, 0, 1, 0, 0, 0, 1, 0)), o.addGlobalTransforms(c, As), o.addShells(c, et), o.addRepresentations(c, Ss), o.addSamples(c, Ts), o.addLocalTransforms(c, Os), o.addMaterials(c, Is), o.addCircleExtrusions(c, vs), o.addMeshesItems(c, ks), o.addRepresentationIds(c, Cs), o.addSampleIds(c, Rs), o.addMaterialIds(c, xs), o.addLocalTransformIds(c, $s), o.addGlobalTransformIds(c, Ns);
4949
+ const Ps = o.endMeshes(c), Bs = c.createString(n), jt = /* @__PURE__ */ new Set(), Mt = [];
4950
+ for (const S of this.changes) {
4951
+ const G = [], Js = {
4952
+ [pn]: S.op,
4953
+ ...S.attrs
4954
+ };
4955
+ for (const [Ys, Ws] of Object.entries(Js)) {
4956
+ const Ce = JSON.stringify([Ys, Ws, "IFCTEXT"]);
4957
+ jt.add(Ce), G.push(c.createString(Ce));
4958
+ }
4959
+ Mt.push(
4960
+ i.createAttribute(c, i.createDataVector(c, G))
4961
+ );
4962
+ }
4963
+ {
4964
+ const S = JSON.stringify(["Name", s, "IFCLABEL"]);
4965
+ jt.add(S);
4966
+ const G = i.createDataVector(c, [c.createString(S)]);
4967
+ Mt.push(i.createAttribute(c, G));
4968
+ }
4969
+ const Ls = h.createAttributesVector(c, Mt), Fs = h.createUniqueAttributesVector(
4970
+ c,
4971
+ [...jt].map((S) => c.createString(S))
4972
+ ), Ae = this.changes.map(
4973
+ () => c.createString(Ye)
4974
+ );
4975
+ Ae.push(c.createString(We));
4976
+ const qs = h.createCategoriesVector(c, Ae), ke = [], xe = [];
4977
+ this.changes.forEach((S, G) => {
4978
+ S.item && (ke.push(c.createString(S.item)), xe.push(v[G]));
4979
+ });
4980
+ const Ds = h.createGuidsVector(c, ke), Us = h.createGuidsItemsVector(c, xe), js = h.createLocalIdsVector(c, [...v, O]), Ms = this.changes.map(
4981
+ (S, G) => d.createSpatialStructure(
4982
+ c,
4983
+ v[G],
4984
+ c.createString(Ye),
4985
+ 0
4986
+ )
4987
+ ), Vs = d.createSpatialStructure(
4988
+ c,
4989
+ O,
4990
+ c.createString(We),
4991
+ d.createChildrenVector(c, Ms)
4992
+ ), Gs = c.createString(s);
4993
+ h.startModel(c), h.addMeshes(c, Ps), h.addMetadata(c, Bs), h.addAttributes(c, Ls), h.addUniqueAttributes(c, Fs), h.addLocalIds(c, js), h.addCategories(c, qs), h.addGuidsItems(c, Us), h.addGuids(c, Ds), h.addGuid(c, Gs), h.addSpatialStructure(c, Vs), h.addMaxLocalId(c, V);
4994
+ const Hs = h.endModel(c);
4995
+ return h.finishModelBuffer(c, Hs), c.asUint8Array();
4996
+ }
4997
+ }
4998
+ async function gn() {
4999
+ try {
5000
+ return await Promise.all([
5001
+ import("flatbuffers"),
5002
+ import("@thatopen/fragments")
5003
+ ]);
5004
+ } catch (r) {
5005
+ throw new Error(
5006
+ `OperationBuilder needs the optional peers \`flatbuffers\` and \`@thatopen/fragments\` installed — add them to the app that authors operations. (${r instanceof Error ? r.message : String(r)})`
5007
+ );
5008
+ }
5009
+ }
5010
+ function Ke(r) {
5011
+ return Number.isFinite(r) ? String(r) : "0";
5012
+ }
5013
+ async function wn(r) {
5014
+ const t = new Blob([r]).stream().pipeThrough(new CompressionStream("deflate"));
5015
+ return new Uint8Array(await new Response(t).arrayBuffer());
5016
+ }
5017
+ const vn = {
4749
5018
  MAX_FIELDS: 200,
4750
5019
  MAX_KEY_LENGTH: 50,
4751
5020
  MAX_VALUE_LENGTH: 50
4752
- }, xn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, $n = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, Cn = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, Rn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Nn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Pn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, Bn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Ln = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Fn = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
5021
+ }, Tn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, Sn = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, In = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, On = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, An = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, kn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, xn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Cn = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Rn = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
4753
5022
  export {
4754
- xn as CDEManager,
4755
- kn as ChannelClient,
4756
- ss as ChannelRoom,
4757
- $n as ClashesManager,
4758
- En as CollabRoom,
4759
- Ie as DOCUMENT_FILE,
4760
- Kt as DOCUMENT_SCHEMA,
4761
- re as EngineServicesClient,
4762
- Tn as ExternalRoom,
4763
- Cn as FileList,
4764
- cn as FlowDoc,
4765
- Rn as GISManager,
4766
- Nn as GitHistoryManager,
4767
- Pn as HelloWorld,
4768
- An as METADATA_LIMITS,
4769
- Be as PlatformClient,
4770
- Ke as ProjectDocuments,
4771
- an as ProjectHistory,
4772
- Bn as ProjectManager,
4773
- ln as Recipes,
4774
- we as RequestError,
4775
- Ne as STORAGE_BATCH_MAX,
4776
- xe as StaleHistoryError,
4777
- Ln as TopicsManager,
4778
- Fn as UIManager,
4779
- se as mintGuid,
4780
- ts as orderByGraph,
4781
- _n as windowTransport
5023
+ Tn as CDEManager,
5024
+ dn as ChannelClient,
5025
+ gs as ChannelRoom,
5026
+ Sn as ClashesManager,
5027
+ hn as CollabRoom,
5028
+ Fe as DOCUMENT_FILE,
5029
+ qt as DOCUMENT_SCHEMA,
5030
+ le as EngineServicesClient,
5031
+ ln as ExternalRoom,
5032
+ In as FileList,
5033
+ Wr as FlowDoc,
5034
+ On as GISManager,
5035
+ An as GitHistoryManager,
5036
+ kn as HelloWorld,
5037
+ vn as METADATA_LIMITS,
5038
+ mn as OP_SCHEMA,
5039
+ En as OperationBuilder,
5040
+ Je as PlatformClient,
5041
+ hs as ProjectDocuments,
5042
+ Yr as ProjectHistory,
5043
+ xn as ProjectManager,
5044
+ zr as Recipes,
5045
+ Se as RequestError,
5046
+ Gr as SELF_VIEWING_FORMATS,
5047
+ Ge as STORAGE_BATCH_MAX,
5048
+ Ue as StaleHistoryError,
5049
+ Cn as TopicsManager,
5050
+ Rn as UIManager,
5051
+ ce as mintGuid,
5052
+ ys as orderByGraph,
5053
+ an as windowTransport
4782
5054
  };
4783
5055
  //# sourceMappingURL=index.es.js.map