@thatopen/services 0.20.0 → 0.22.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,10 +1,10 @@
1
- var Xe = Object.defineProperty;
2
- var fe = (n) => {
1
+ var es = Object.defineProperty;
2
+ var ge = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var ze = (n, t, e) => t in n ? Xe(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var T = (n, t, e) => ze(n, typeof t != "symbol" ? t + "" : t, e), Nt = (n, t, e) => t.has(n) || fe("Cannot " + e);
7
- var l = (n, t, e) => (Nt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), _ = (n, t, e) => t.has(n) ? fe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), b = (n, t, e, s) => (Nt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Nt(n, t, "access private method"), e);
5
+ var ss = (n, t, e) => t in n ? es(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var T = (n, t, e) => ss(n, typeof t != "symbol" ? t + "" : t, e), Pt = (n, t, e) => t.has(n) || ge("Cannot " + e);
7
+ var l = (n, t, e) => (Pt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? ge("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), _ = (n, t, e, s) => (Pt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Pt(n, t, "access private method"), e);
8
8
  const P = /* @__PURE__ */ Object.create(null);
9
9
  P.open = "0";
10
10
  P.close = "1";
@@ -13,63 +13,63 @@ P.pong = "3";
13
13
  P.message = "4";
14
14
  P.upgrade = "5";
15
15
  P.noop = "6";
16
- const bt = /* @__PURE__ */ Object.create(null);
16
+ const Et = /* @__PURE__ */ Object.create(null);
17
17
  Object.keys(P).forEach((n) => {
18
- bt[P[n]] = n;
18
+ Et[P[n]] = n;
19
19
  });
20
- const Dt = { type: "error", data: "parser error" }, xe = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ie = typeof ArrayBuffer == "function", $e = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, ie = ({ type: n, data: t }, e, s) => xe && t instanceof Blob ? e ? s(t) : pe(t, s) : Ie && (t instanceof ArrayBuffer || $e(t)) ? e ? s(t) : pe(new Blob([t]), s) : s(P[n] + (t || "")), pe = (n, t) => {
20
+ const jt = { type: "error", data: "parser error" }, $e = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ce = typeof ArrayBuffer == "function", Re = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, he = ({ type: n, data: t }, e, s) => $e && t instanceof Blob ? e ? s(t) : we(t, s) : Ce && (t instanceof ArrayBuffer || Re(t)) ? e ? s(t) : we(new Blob([t]), s) : s(P[n] + (t || "")), we = (n, 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
25
  }, e.readAsDataURL(n);
26
26
  };
27
- function ye(n) {
27
+ function be(n) {
28
28
  return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
29
29
  }
30
- let Pt;
31
- function Qe(n, t) {
32
- if (xe && n.data instanceof Blob)
33
- return n.data.arrayBuffer().then(ye).then(t);
34
- if (Ie && (n.data instanceof ArrayBuffer || $e(n.data)))
35
- return t(ye(n.data));
36
- ie(n, !1, (e) => {
37
- Pt || (Pt = new TextEncoder()), t(Pt.encode(e));
30
+ let Bt;
31
+ function ns(n, t) {
32
+ if ($e && n.data instanceof Blob)
33
+ return n.data.arrayBuffer().then(be).then(t);
34
+ if (Ce && (n.data instanceof ArrayBuffer || Re(n.data)))
35
+ return t(be(n.data));
36
+ he(n, !1, (e) => {
37
+ Bt || (Bt = new TextEncoder()), t(Bt.encode(e));
38
38
  });
39
39
  }
40
- const me = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ot = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
- for (let n = 0; n < me.length; n++)
42
- ot[me.charCodeAt(n)] = n;
43
- const Ze = (n) => {
40
+ const _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ot = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
+ for (let n = 0; n < _e.length; n++)
42
+ ot[_e.charCodeAt(n)] = n;
43
+ const rs = (n) => {
44
44
  let t = n.length * 0.75, e = n.length, s, r = 0, i, o, h, u;
45
45
  n[n.length - 1] === "=" && (t--, n[n.length - 2] === "=" && t--);
46
- const f = new ArrayBuffer(t), y = new Uint8Array(f);
46
+ const f = new ArrayBuffer(t), p = new Uint8Array(f);
47
47
  for (s = 0; s < e; s += 4)
48
- i = ot[n.charCodeAt(s)], o = ot[n.charCodeAt(s + 1)], h = ot[n.charCodeAt(s + 2)], u = ot[n.charCodeAt(s + 3)], y[r++] = i << 2 | o >> 4, y[r++] = (o & 15) << 4 | h >> 2, y[r++] = (h & 3) << 6 | u & 63;
48
+ i = ot[n.charCodeAt(s)], o = ot[n.charCodeAt(s + 1)], h = ot[n.charCodeAt(s + 2)], u = ot[n.charCodeAt(s + 3)], p[r++] = i << 2 | o >> 4, p[r++] = (o & 15) << 4 | h >> 2, p[r++] = (h & 3) << 6 | u & 63;
49
49
  return f;
50
- }, ts = typeof ArrayBuffer == "function", oe = (n, t) => {
50
+ }, is = typeof ArrayBuffer == "function", le = (n, t) => {
51
51
  if (typeof n != "string")
52
52
  return {
53
53
  type: "message",
54
- data: Re(n, t)
54
+ data: Ne(n, t)
55
55
  };
56
56
  const e = n.charAt(0);
57
57
  return e === "b" ? {
58
58
  type: "message",
59
- data: es(n.substring(1), t)
60
- } : bt[e] ? n.length > 1 ? {
61
- type: bt[e],
59
+ data: os(n.substring(1), t)
60
+ } : Et[e] ? n.length > 1 ? {
61
+ type: Et[e],
62
62
  data: n.substring(1)
63
63
  } : {
64
- type: bt[e]
65
- } : Dt;
66
- }, es = (n, t) => {
67
- if (ts) {
68
- const e = Ze(n);
69
- return Re(e, t);
64
+ type: Et[e]
65
+ } : jt;
66
+ }, os = (n, t) => {
67
+ if (is) {
68
+ const e = rs(n);
69
+ return Ne(e, t);
70
70
  } else
71
71
  return { base64: !0, data: n };
72
- }, Re = (n, t) => {
72
+ }, Ne = (n, t) => {
73
73
  switch (t) {
74
74
  case "blob":
75
75
  return n instanceof Blob ? n : new Blob([n]);
@@ -77,27 +77,27 @@ const Ze = (n) => {
77
77
  default:
78
78
  return n instanceof ArrayBuffer ? n : n.buffer;
79
79
  }
80
- }, Ce = "", ss = (n, t) => {
80
+ }, Pe = "", as = (n, t) => {
81
81
  const e = n.length, s = new Array(e);
82
82
  let r = 0;
83
83
  n.forEach((i, o) => {
84
- ie(i, !1, (h) => {
85
- s[o] = h, ++r === e && t(s.join(Ce));
84
+ he(i, !1, (h) => {
85
+ s[o] = h, ++r === e && t(s.join(Pe));
86
86
  });
87
87
  });
88
- }, ns = (n, t) => {
89
- const e = n.split(Ce), s = [];
88
+ }, cs = (n, t) => {
89
+ const e = n.split(Pe), s = [];
90
90
  for (let r = 0; r < e.length; r++) {
91
- const i = oe(e[r], t);
91
+ const i = le(e[r], t);
92
92
  if (s.push(i), i.type === "error")
93
93
  break;
94
94
  }
95
95
  return s;
96
96
  };
97
- function rs() {
97
+ function hs() {
98
98
  return new TransformStream({
99
99
  transform(n, t) {
100
- Qe(n, (e) => {
100
+ ns(n, (e) => {
101
101
  const s = e.length;
102
102
  let r;
103
103
  if (s < 126)
@@ -116,11 +116,11 @@ function rs() {
116
116
  }
117
117
  });
118
118
  }
119
- let Bt;
120
- function gt(n) {
119
+ let Lt;
120
+ function wt(n) {
121
121
  return n.reduce((t, e) => t + e.length, 0);
122
122
  }
123
- function wt(n, t) {
123
+ function bt(n, t) {
124
124
  if (n[0].length === t)
125
125
  return n.shift();
126
126
  const e = new Uint8Array(t);
@@ -129,51 +129,51 @@ function wt(n, t) {
129
129
  e[r] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
130
130
  return n.length && s < n[0].length && (n[0] = n[0].slice(s)), e;
131
131
  }
132
- function is(n, t) {
133
- Bt || (Bt = new TextDecoder());
132
+ function ls(n, t) {
133
+ Lt || (Lt = new TextDecoder());
134
134
  const e = [];
135
135
  let s = 0, r = -1, i = !1;
136
136
  return new TransformStream({
137
137
  transform(o, h) {
138
138
  for (e.push(o); ; ) {
139
139
  if (s === 0) {
140
- if (gt(e) < 1)
140
+ if (wt(e) < 1)
141
141
  break;
142
- const u = wt(e, 1);
142
+ const u = bt(e, 1);
143
143
  i = (u[0] & 128) === 128, r = u[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
144
144
  } else if (s === 1) {
145
- if (gt(e) < 2)
145
+ if (wt(e) < 2)
146
146
  break;
147
- const u = wt(e, 2);
147
+ const u = bt(e, 2);
148
148
  r = new DataView(u.buffer, u.byteOffset, u.length).getUint16(0), s = 3;
149
149
  } else if (s === 2) {
150
- if (gt(e) < 8)
150
+ if (wt(e) < 8)
151
151
  break;
152
- const u = wt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), y = f.getUint32(0);
153
- if (y > Math.pow(2, 21) - 1) {
154
- h.enqueue(Dt);
152
+ const u = bt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), p = f.getUint32(0);
153
+ if (p > Math.pow(2, 21) - 1) {
154
+ h.enqueue(jt);
155
155
  break;
156
156
  }
157
- r = y * Math.pow(2, 32) + f.getUint32(4), s = 3;
157
+ r = p * Math.pow(2, 32) + f.getUint32(4), s = 3;
158
158
  } else {
159
- if (gt(e) < r)
159
+ if (wt(e) < r)
160
160
  break;
161
- const u = wt(e, r);
162
- h.enqueue(oe(i ? u : Bt.decode(u), t)), s = 0;
161
+ const u = bt(e, r);
162
+ h.enqueue(le(i ? u : Lt.decode(u), t)), s = 0;
163
163
  }
164
164
  if (r === 0 || r > n) {
165
- h.enqueue(Dt);
165
+ h.enqueue(jt);
166
166
  break;
167
167
  }
168
168
  }
169
169
  }
170
170
  });
171
171
  }
172
- const Ne = 4;
172
+ const Be = 4;
173
173
  function E(n) {
174
- if (n) return os(n);
174
+ if (n) return us(n);
175
175
  }
176
- function os(n) {
176
+ function us(n) {
177
177
  for (var t in E.prototype)
178
178
  n[t] = E.prototype[t];
179
179
  return n;
@@ -219,34 +219,34 @@ E.prototype.listeners = function(n) {
219
219
  E.prototype.hasListeners = function(n) {
220
220
  return !!this.listeners(n).length;
221
221
  };
222
- const Rt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), A = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), as = "arraybuffer";
223
- function Pe(n, ...t) {
222
+ const Rt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), A = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), ds = "arraybuffer";
223
+ function Le(n, ...t) {
224
224
  return t.reduce((e, s) => (n.hasOwnProperty(s) && (e[s] = n[s]), e), {});
225
225
  }
226
- const cs = A.setTimeout, hs = A.clearTimeout;
227
- function Ct(n, t) {
228
- t.useNativeTimers ? (n.setTimeoutFn = cs.bind(A), n.clearTimeoutFn = hs.bind(A)) : (n.setTimeoutFn = A.setTimeout.bind(A), n.clearTimeoutFn = A.clearTimeout.bind(A));
226
+ const fs = A.setTimeout, ps = A.clearTimeout;
227
+ function Nt(n, t) {
228
+ t.useNativeTimers ? (n.setTimeoutFn = fs.bind(A), n.clearTimeoutFn = ps.bind(A)) : (n.setTimeoutFn = A.setTimeout.bind(A), n.clearTimeoutFn = A.clearTimeout.bind(A));
229
229
  }
230
- const ls = 1.33;
231
- function us(n) {
232
- return typeof n == "string" ? ds(n) : Math.ceil((n.byteLength || n.size) * ls);
230
+ const ys = 1.33;
231
+ function ms(n) {
232
+ return typeof n == "string" ? gs(n) : Math.ceil((n.byteLength || n.size) * ys);
233
233
  }
234
- function ds(n) {
234
+ function gs(n) {
235
235
  let t = 0, e = 0;
236
236
  for (let s = 0, r = n.length; s < r; s++)
237
237
  t = n.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 Be() {
240
+ function qe() {
241
241
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
242
242
  }
243
- function fs(n) {
243
+ function ws(n) {
244
244
  let t = "";
245
245
  for (let e in n)
246
246
  n.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(n[e]));
247
247
  return t;
248
248
  }
249
- function ps(n) {
249
+ function bs(n) {
250
250
  let t = {}, e = n.split("&");
251
251
  for (let s = 0, r = e.length; s < r; s++) {
252
252
  let i = e[s].split("=");
@@ -254,12 +254,12 @@ function ps(n) {
254
254
  }
255
255
  return t;
256
256
  }
257
- class ys extends Error {
257
+ class _s 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 ae extends E {
262
+ class ue extends E {
263
263
  /**
264
264
  * Transport abstract constructor.
265
265
  *
@@ -267,7 +267,7 @@ class ae extends E {
267
267
  * @protected
268
268
  */
269
269
  constructor(t) {
270
- super(), this.writable = !1, Ct(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
270
+ super(), this.writable = !1, Nt(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 ae extends E {
279
279
  * @protected
280
280
  */
281
281
  onError(t, e, s) {
282
- return super.emitReserved("error", new ys(t, e, s)), this;
282
+ return super.emitReserved("error", new _s(t, e, s)), this;
283
283
  }
284
284
  /**
285
285
  * Opens the transport.
@@ -316,7 +316,7 @@ class ae extends E {
316
316
  * @protected
317
317
  */
318
318
  onData(t) {
319
- const e = oe(t, this.socket.binaryType);
319
+ const e = le(t, this.socket.binaryType);
320
320
  this.onPacket(e);
321
321
  }
322
322
  /**
@@ -353,11 +353,11 @@ class ae extends E {
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 = fs(t);
356
+ const e = ws(t);
357
357
  return e.length ? "?" + e : "";
358
358
  }
359
359
  }
360
- class ms extends ae {
360
+ class Es extends ue {
361
361
  constructor() {
362
362
  super(...arguments), this._polling = !1;
363
363
  }
@@ -413,7 +413,7 @@ class ms extends ae {
413
413
  return this.onClose({ description: "transport closed by the server" }), !1;
414
414
  this.onPacket(s);
415
415
  };
416
- ns(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
416
+ cs(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 ms extends ae {
433
433
  * @protected
434
434
  */
435
435
  write(t) {
436
- this.writable = !1, ss(t, (e) => {
436
+ this.writable = !1, as(t, (e) => {
437
437
  this.doWrite(e, () => {
438
438
  this.writable = !0, this.emitReserved("drain");
439
439
  });
@@ -446,18 +446,18 @@ class ms extends ae {
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] = Be()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
449
+ return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = qe()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
450
450
  }
451
451
  }
452
- let Le = !1;
452
+ let Fe = !1;
453
453
  try {
454
- Le = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
454
+ Fe = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
455
455
  } catch {
456
456
  }
457
- const gs = Le;
458
- function ws() {
457
+ const vs = Fe;
458
+ function Ts() {
459
459
  }
460
- class _s extends ms {
460
+ class Ss extends Es {
461
461
  /**
462
462
  * XHR Polling constructor.
463
463
  *
@@ -507,7 +507,7 @@ class N extends E {
507
507
  * @package
508
508
  */
509
509
  constructor(t, e, s) {
510
- super(), this.createRequest = t, Ct(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, Nt(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 N extends E {
516
516
  */
517
517
  _create() {
518
518
  var t;
519
- const e = Pe(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
519
+ const e = Le(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 {
@@ -570,7 +570,7 @@ class N extends E {
570
570
  */
571
571
  _cleanup(t) {
572
572
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
573
- if (this._xhr.onreadystatechange = ws, t)
573
+ if (this._xhr.onreadystatechange = Ts, t)
574
574
  try {
575
575
  this._xhr.abort();
576
576
  } catch {
@@ -600,36 +600,36 @@ N.requestsCount = 0;
600
600
  N.requests = {};
601
601
  if (typeof document < "u") {
602
602
  if (typeof attachEvent == "function")
603
- attachEvent("onunload", ge);
603
+ attachEvent("onunload", Ee);
604
604
  else if (typeof addEventListener == "function") {
605
605
  const n = "onpagehide" in A ? "pagehide" : "unload";
606
- addEventListener(n, ge, !1);
606
+ addEventListener(n, Ee, !1);
607
607
  }
608
608
  }
609
- function ge() {
609
+ function Ee() {
610
610
  for (let n in N.requests)
611
611
  N.requests.hasOwnProperty(n) && N.requests[n].abort();
612
612
  }
613
- const bs = function() {
614
- const n = qe({
613
+ const ks = function() {
614
+ const n = Ue({
615
615
  xdomain: !1
616
616
  });
617
617
  return n && n.responseType !== null;
618
618
  }();
619
- class Es extends _s {
619
+ class Os extends Ss {
620
620
  constructor(t) {
621
621
  super(t);
622
622
  const e = t && t.forceBase64;
623
- this.supportsBinary = bs && !e;
623
+ this.supportsBinary = ks && !e;
624
624
  }
625
625
  request(t = {}) {
626
- return Object.assign(t, { xd: this.xd }, this.opts), new N(qe, this.uri(), t);
626
+ return Object.assign(t, { xd: this.xd }, this.opts), new N(Ue, this.uri(), t);
627
627
  }
628
628
  }
629
- function qe(n) {
629
+ function Ue(n) {
630
630
  const t = n.xdomain;
631
631
  try {
632
- if (typeof XMLHttpRequest < "u" && (!t || gs))
632
+ if (typeof XMLHttpRequest < "u" && (!t || vs))
633
633
  return new XMLHttpRequest();
634
634
  } catch {
635
635
  }
@@ -639,13 +639,13 @@ function qe(n) {
639
639
  } catch {
640
640
  }
641
641
  }
642
- const Fe = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
- class vs extends ae {
642
+ const De = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
+ class As extends ue {
644
644
  get name() {
645
645
  return "websocket";
646
646
  }
647
647
  doOpen() {
648
- const t = this.uri(), e = this.opts.protocols, s = Fe ? {} : Pe(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 = De ? {} : Le(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);
@@ -671,7 +671,7 @@ class vs extends ae {
671
671
  this.writable = !1;
672
672
  for (let e = 0; e < t.length; e++) {
673
673
  const s = t[e], r = e === t.length - 1;
674
- ie(s, this.supportsBinary, (i) => {
674
+ he(s, this.supportsBinary, (i) => {
675
675
  try {
676
676
  this.doWrite(s, i);
677
677
  } catch {
@@ -693,19 +693,19 @@ class vs extends ae {
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] = Be()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
696
+ return this.opts.timestampRequests && (e[this.opts.timestampParam] = qe()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
697
697
  }
698
698
  }
699
- const Lt = A.WebSocket || A.MozWebSocket;
700
- class Ts extends vs {
699
+ const qt = A.WebSocket || A.MozWebSocket;
700
+ class Is extends As {
701
701
  createSocket(t, e, s) {
702
- return Fe ? new Lt(t, e, s) : e ? new Lt(t, e) : new Lt(t);
702
+ return De ? new qt(t, e, s) : e ? new qt(t, e) : new qt(t);
703
703
  }
704
704
  doWrite(t, e) {
705
705
  this.ws.send(e);
706
706
  }
707
707
  }
708
- class Ss extends ae {
708
+ class xs extends ue {
709
709
  get name() {
710
710
  return "webtransport";
711
711
  }
@@ -721,7 +721,7 @@ class Ss extends ae {
721
721
  this.onError("webtransport error", t);
722
722
  }), this._transport.ready.then(() => {
723
723
  this._transport.createBidirectionalStream().then((t) => {
724
- const e = is(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = rs();
724
+ const e = ls(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = hs();
725
725
  r.readable.pipeTo(t.writable), this._writer = r.writable.getWriter();
726
726
  const i = () => {
727
727
  s.read().then(({ done: h, value: u }) => {
@@ -751,11 +751,11 @@ class Ss extends ae {
751
751
  (t = this._transport) === null || t === void 0 || t.close();
752
752
  }
753
753
  }
754
- const ks = {
755
- websocket: Ts,
756
- webtransport: Ss,
757
- polling: Es
758
- }, Os = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, As = [
754
+ const $s = {
755
+ websocket: Is,
756
+ webtransport: xs,
757
+ polling: Os
758
+ }, Cs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Rs = [
759
759
  "source",
760
760
  "protocol",
761
761
  "authority",
@@ -771,31 +771,31 @@ const ks = {
771
771
  "query",
772
772
  "anchor"
773
773
  ];
774
- function jt(n) {
774
+ function Mt(n) {
775
775
  if (n.length > 8e3)
776
776
  throw "URI too long";
777
777
  const t = n, e = n.indexOf("["), s = n.indexOf("]");
778
778
  e != -1 && s != -1 && (n = n.substring(0, e) + n.substring(e, s).replace(/:/g, ";") + n.substring(s, n.length));
779
- let r = Os.exec(n || ""), i = {}, o = 14;
779
+ let r = Cs.exec(n || ""), i = {}, o = 14;
780
780
  for (; o--; )
781
- i[As[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 = xs(i, i.path), i.queryKey = Is(i, i.query), i;
781
+ i[Rs[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 = Ns(i, i.path), i.queryKey = Ps(i, i.query), i;
783
783
  }
784
- function xs(n, t) {
784
+ function Ns(n, 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 Is(n, t) {
788
+ function Ps(n, t) {
789
789
  const e = {};
790
790
  return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
791
791
  r && (e[r] = i);
792
792
  }), e;
793
793
  }
794
- const Mt = typeof addEventListener == "function" && typeof removeEventListener == "function", Et = [];
795
- Mt && addEventListener("offline", () => {
796
- Et.forEach((n) => n());
794
+ const Ht = typeof addEventListener == "function" && typeof removeEventListener == "function", vt = [];
795
+ Ht && addEventListener("offline", () => {
796
+ vt.forEach((n) => n());
797
797
  }, !1);
798
- class V extends E {
798
+ class J extends E {
799
799
  /**
800
800
  * Socket constructor.
801
801
  *
@@ -803,11 +803,11 @@ class V extends E {
803
803
  * @param {Object} opts - options
804
804
  */
805
805
  constructor(t, e) {
806
- if (super(), this.binaryType = as, 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 = jt(t);
806
+ if (super(), this.binaryType = ds, 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 = Mt(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 = jt(e.host).host);
810
- Ct(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) => {
809
+ } else e.host && (e.hostname = Mt(e.host).host);
810
+ Nt(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
811
  const r = s.prototype.name;
812
812
  this.transports.push(r), this._transportsByName[r] = s;
813
813
  }), this.opts = Object.assign({
@@ -824,13 +824,13 @@ class V extends E {
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 = ps(this.opts.query)), Mt && (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 = bs(this.opts.query)), Ht && (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
- }, Et.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
833
+ }, vt.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 V extends E {
841
841
  */
842
842
  createTransport(t) {
843
843
  const e = Object.assign({}, this.opts.query);
844
- e.EIO = Ne, e.transport = t, this.id && (e.sid = this.id);
844
+ e.EIO = Be, 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 V extends E {
863
863
  }, 0);
864
864
  return;
865
865
  }
866
- const t = this.opts.rememberUpgrade && V.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
866
+ const t = this.opts.rememberUpgrade && J.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 V extends E {
882
882
  * @private
883
883
  */
884
884
  onOpen() {
885
- this.readyState = "open", V.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
885
+ this.readyState = "open", J.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
886
886
  }
887
887
  /**
888
888
  * Handles a packet.
@@ -959,7 +959,7 @@ class V extends E {
959
959
  let e = 1;
960
960
  for (let s = 0; s < this.writeBuffer.length; s++) {
961
961
  const r = this.writeBuffer[s].data;
962
- if (r && (e += us(r)), s > 0 && e > this._maxPayload)
962
+ if (r && (e += ms(r)), s > 0 && e > this._maxPayload)
963
963
  return this.writeBuffer.slice(0, s);
964
964
  e += 2;
965
965
  }
@@ -1046,7 +1046,7 @@ class V extends E {
1046
1046
  * @private
1047
1047
  */
1048
1048
  _onError(t) {
1049
- if (V.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1049
+ if (J.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 V extends E {
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(), Mt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
- const s = Et.indexOf(this._offlineEventListener);
1062
- s !== -1 && Et.splice(s, 1);
1060
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Ht && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
+ const s = vt.indexOf(this._offlineEventListener);
1062
+ s !== -1 && vt.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
- V.protocol = Ne;
1069
- class $s extends V {
1068
+ J.protocol = Be;
1069
+ class Bs extends J {
1070
1070
  constructor() {
1071
1071
  super(...arguments), this._upgrades = [];
1072
1072
  }
@@ -1083,28 +1083,28 @@ class $s extends V {
1083
1083
  */
1084
1084
  _probe(t) {
1085
1085
  let e = this.createTransport(t), s = !1;
1086
- V.priorWebsocketSuccess = !1;
1086
+ J.priorWebsocketSuccess = !1;
1087
1087
  const r = () => {
1088
1088
  s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (w) => {
1089
1089
  if (!s)
1090
1090
  if (w.type === "pong" && w.data === "probe") {
1091
1091
  if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
1092
1092
  return;
1093
- V.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
+ J.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1094
+ s || this.readyState !== "closed" && (p(), 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 R = new Error("probe error");
1098
- R.transport = e.name, this.emitReserved("upgradeError", R);
1097
+ const C = new Error("probe error");
1098
+ C.transport = e.name, this.emitReserved("upgradeError", C);
1099
1099
  }
1100
1100
  }));
1101
1101
  };
1102
1102
  function i() {
1103
- s || (s = !0, y(), e.close(), e = null);
1103
+ s || (s = !0, p(), e.close(), e = null);
1104
1104
  }
1105
1105
  const o = (w) => {
1106
- const R = new Error("probe error: " + w);
1107
- R.transport = e.name, i(), this.emitReserved("upgradeError", R);
1106
+ const C = new Error("probe error: " + w);
1107
+ C.transport = e.name, i(), this.emitReserved("upgradeError", C);
1108
1108
  };
1109
1109
  function h() {
1110
1110
  o("transport closed");
@@ -1115,7 +1115,7 @@ class $s extends V {
1115
1115
  function f(w) {
1116
1116
  e && w.name !== e.name && i();
1117
1117
  }
1118
- const y = () => {
1118
+ const p = () => {
1119
1119
  e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", h), this.off("close", u), this.off("upgrading", f);
1120
1120
  };
1121
1121
  e.once("open", r), e.once("error", o), e.once("close", h), this.once("close", u), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
@@ -1138,67 +1138,67 @@ class $s extends V {
1138
1138
  return e;
1139
1139
  }
1140
1140
  }
1141
- let Rs = class extends $s {
1141
+ let Ls = class extends Bs {
1142
1142
  constructor(t, e = {}) {
1143
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) => ks[i]).filter((i) => !!i)), super(s ? r : t, r);
1144
+ (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => $s[i]).filter((i) => !!i)), super(s ? r : t, r);
1145
1145
  }
1146
1146
  };
1147
- function Cs(n, t = "", e) {
1147
+ function qs(n, t = "", e) {
1148
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 = jt(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
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 = Mt(n)), 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 Ns = typeof ArrayBuffer == "function", Ps = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, Ue = Object.prototype.toString, Bs = typeof Blob == "function" || typeof Blob < "u" && Ue.call(Blob) === "[object BlobConstructor]", Ls = typeof File == "function" || typeof File < "u" && Ue.call(File) === "[object FileConstructor]";
1154
- function ce(n) {
1155
- return Ns && (n instanceof ArrayBuffer || Ps(n)) || Bs && n instanceof Blob || Ls && n instanceof File;
1153
+ const Fs = typeof ArrayBuffer == "function", Us = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, je = Object.prototype.toString, Ds = typeof Blob == "function" || typeof Blob < "u" && je.call(Blob) === "[object BlobConstructor]", js = typeof File == "function" || typeof File < "u" && je.call(File) === "[object FileConstructor]";
1154
+ function de(n) {
1155
+ return Fs && (n instanceof ArrayBuffer || Us(n)) || Ds && n instanceof Blob || js && n instanceof File;
1156
1156
  }
1157
- function vt(n, t) {
1157
+ function Tt(n, t) {
1158
1158
  if (!n || typeof n != "object")
1159
1159
  return !1;
1160
1160
  if (Array.isArray(n)) {
1161
1161
  for (let e = 0, s = n.length; e < s; e++)
1162
- if (vt(n[e]))
1162
+ if (Tt(n[e]))
1163
1163
  return !0;
1164
1164
  return !1;
1165
1165
  }
1166
- if (ce(n))
1166
+ if (de(n))
1167
1167
  return !0;
1168
1168
  if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
1169
- return vt(n.toJSON(), !0);
1169
+ return Tt(n.toJSON(), !0);
1170
1170
  for (const e in n)
1171
- if (Object.prototype.hasOwnProperty.call(n, e) && vt(n[e]))
1171
+ if (Object.prototype.hasOwnProperty.call(n, e) && Tt(n[e]))
1172
1172
  return !0;
1173
1173
  return !1;
1174
1174
  }
1175
- function qs(n) {
1175
+ function Ms(n) {
1176
1176
  const t = [], e = n.data, s = n;
1177
- return s.data = Ht(e, t), s.attachments = t.length, { packet: s, buffers: t };
1177
+ return s.data = Gt(e, t), s.attachments = t.length, { packet: s, buffers: t };
1178
1178
  }
1179
- function Ht(n, t) {
1179
+ function Gt(n, t) {
1180
1180
  if (!n)
1181
1181
  return n;
1182
- if (ce(n)) {
1182
+ if (de(n)) {
1183
1183
  const e = { _placeholder: !0, num: t.length };
1184
1184
  return t.push(n), e;
1185
1185
  } else if (Array.isArray(n)) {
1186
1186
  const e = new Array(n.length);
1187
1187
  for (let s = 0; s < n.length; s++)
1188
- e[s] = Ht(n[s], t);
1188
+ e[s] = Gt(n[s], t);
1189
1189
  return e;
1190
1190
  } else if (typeof n == "object" && !(n instanceof Date)) {
1191
1191
  const e = {};
1192
1192
  for (const s in n)
1193
- Object.prototype.hasOwnProperty.call(n, s) && (e[s] = Ht(n[s], t));
1193
+ Object.prototype.hasOwnProperty.call(n, s) && (e[s] = Gt(n[s], t));
1194
1194
  return e;
1195
1195
  }
1196
1196
  return n;
1197
1197
  }
1198
- function Fs(n, t) {
1199
- return n.data = Gt(n.data, t), delete n.attachments, n;
1198
+ function Hs(n, t) {
1199
+ return n.data = Vt(n.data, t), delete n.attachments, n;
1200
1200
  }
1201
- function Gt(n, t) {
1201
+ function Vt(n, t) {
1202
1202
  if (!n)
1203
1203
  return n;
1204
1204
  if (n && n._placeholder === !0) {
@@ -1207,13 +1207,13 @@ function Gt(n, t) {
1207
1207
  throw new Error("illegal attachments");
1208
1208
  } else if (Array.isArray(n))
1209
1209
  for (let e = 0; e < n.length; e++)
1210
- n[e] = Gt(n[e], t);
1210
+ n[e] = Vt(n[e], t);
1211
1211
  else if (typeof n == "object")
1212
1212
  for (const e in n)
1213
- Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Gt(n[e], t));
1213
+ Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Vt(n[e], t));
1214
1214
  return n;
1215
1215
  }
1216
- const Us = [
1216
+ const Gs = [
1217
1217
  "connect",
1218
1218
  // used on the client side
1219
1219
  "connect_error",
@@ -1231,7 +1231,7 @@ var g;
1231
1231
  (function(n) {
1232
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
1233
  })(g || (g = {}));
1234
- class Ds {
1234
+ class Vs {
1235
1235
  /**
1236
1236
  * Encoder constructor
1237
1237
  *
@@ -1247,7 +1247,7 @@ class Ds {
1247
1247
  * @param {Object} obj - packet object
1248
1248
  */
1249
1249
  encode(t) {
1250
- return (t.type === g.EVENT || t.type === g.ACK) && vt(t) ? this.encodeAsBinary({
1250
+ return (t.type === g.EVENT || t.type === g.ACK) && Tt(t) ? this.encodeAsBinary({
1251
1251
  type: t.type === g.EVENT ? g.BINARY_EVENT : g.BINARY_ACK,
1252
1252
  nsp: t.nsp,
1253
1253
  data: t.data,
@@ -1267,11 +1267,11 @@ class Ds {
1267
1267
  * a list of buffers.
1268
1268
  */
1269
1269
  encodeAsBinary(t) {
1270
- const e = qs(t), s = this.encodeAsString(e.packet), r = e.buffers;
1270
+ const e = Ms(t), s = this.encodeAsString(e.packet), r = e.buffers;
1271
1271
  return r.unshift(s), r;
1272
1272
  }
1273
1273
  }
1274
- class he extends E {
1274
+ class fe extends E {
1275
1275
  /**
1276
1276
  * Decoder constructor
1277
1277
  */
@@ -1293,8 +1293,8 @@ class he extends E {
1293
1293
  throw new Error("got plaintext data when reconstructing a packet");
1294
1294
  e = this.decodeString(t);
1295
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 js(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
- } else if (ce(t) || t.base64)
1296
+ s || e.type === g.BINARY_ACK ? (e.type = s ? g.EVENT : g.ACK, this.reconstructor = new Js(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
+ } else if (de(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
@@ -1323,7 +1323,7 @@ class he extends E {
1323
1323
  if (o != Number(o) || t.charAt(e) !== "-")
1324
1324
  throw new Error("Illegal attachments");
1325
1325
  const h = Number(o);
1326
- if (!Ms(h) || h < 0)
1326
+ if (!Ys(h) || h < 0)
1327
1327
  throw new Error("Illegal attachments");
1328
1328
  if (h > this.opts.maxAttachments)
1329
1329
  throw new Error("too many attachments");
@@ -1352,7 +1352,7 @@ class he extends E {
1352
1352
  }
1353
1353
  if (t.charAt(++e)) {
1354
1354
  const i = this.tryParse(t.substr(e));
1355
- if (he.isPayloadValid(s.type, i))
1355
+ if (fe.isPayloadValid(s.type, i))
1356
1356
  s.data = i;
1357
1357
  else
1358
1358
  throw new Error("invalid payload");
@@ -1369,14 +1369,14 @@ class he extends E {
1369
1369
  static isPayloadValid(t, e) {
1370
1370
  switch (t) {
1371
1371
  case g.CONNECT:
1372
- return we(e);
1372
+ return ve(e);
1373
1373
  case g.DISCONNECT:
1374
1374
  return e === void 0;
1375
1375
  case g.CONNECT_ERROR:
1376
- return typeof e == "string" || we(e);
1376
+ return typeof e == "string" || ve(e);
1377
1377
  case g.EVENT:
1378
1378
  case g.BINARY_EVENT:
1379
- return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Us.indexOf(e[0]) === -1);
1379
+ return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Gs.indexOf(e[0]) === -1);
1380
1380
  case g.ACK:
1381
1381
  case g.BINARY_ACK:
1382
1382
  return Array.isArray(e);
@@ -1389,7 +1389,7 @@ class he extends E {
1389
1389
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1390
1390
  }
1391
1391
  }
1392
- class js {
1392
+ class Js {
1393
1393
  constructor(t) {
1394
1394
  this.packet = t, this.buffers = [], this.reconPack = t;
1395
1395
  }
@@ -1403,7 +1403,7 @@ class js {
1403
1403
  */
1404
1404
  takeBinaryData(t) {
1405
1405
  if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
1406
- const e = Fs(this.reconPack, this.buffers);
1406
+ const e = Hs(this.reconPack, this.buffers);
1407
1407
  return this.finishedReconstruction(), e;
1408
1408
  }
1409
1409
  return null;
@@ -1415,16 +1415,16 @@ class js {
1415
1415
  this.reconPack = null, this.buffers = [];
1416
1416
  }
1417
1417
  }
1418
- const Ms = Number.isInteger || function(n) {
1418
+ const Ys = Number.isInteger || function(n) {
1419
1419
  return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1420
1420
  };
1421
- function we(n) {
1421
+ function ve(n) {
1422
1422
  return Object.prototype.toString.call(n) === "[object Object]";
1423
1423
  }
1424
- const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1424
+ const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1425
1425
  __proto__: null,
1426
- Decoder: he,
1427
- Encoder: Ds,
1426
+ Decoder: fe,
1427
+ Encoder: Vs,
1428
1428
  get PacketType() {
1429
1429
  return g;
1430
1430
  }
@@ -1434,7 +1434,7 @@ function $(n, t, e) {
1434
1434
  n.off(t, e);
1435
1435
  };
1436
1436
  }
1437
- const Gs = Object.freeze({
1437
+ const Ks = Object.freeze({
1438
1438
  connect: 1,
1439
1439
  connect_error: 1,
1440
1440
  disconnect: 1,
@@ -1443,7 +1443,7 @@ const Gs = Object.freeze({
1443
1443
  newListener: 1,
1444
1444
  removeListener: 1
1445
1445
  });
1446
- class De extends E {
1446
+ class Me extends E {
1447
1447
  /**
1448
1448
  * `Socket` constructor.
1449
1449
  */
@@ -1559,7 +1559,7 @@ class De extends E {
1559
1559
  */
1560
1560
  emit(t, ...e) {
1561
1561
  var s, r, i;
1562
- if (Gs.hasOwnProperty(t))
1562
+ if (Ks.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;
@@ -1568,8 +1568,8 @@ class De extends E {
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 p = this.ids++, w = e.pop();
1572
+ this._registerAckCallback(p, w), o.id = p;
1573
1573
  }
1574
1574
  const h = (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
1575
  return this.flags.volatile && !h || (u ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
@@ -2035,10 +2035,10 @@ class De extends E {
2035
2035
  }
2036
2036
  }
2037
2037
  }
2038
- function nt(n) {
2038
+ function rt(n) {
2039
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;
2040
2040
  }
2041
- nt.prototype.duration = function() {
2041
+ rt.prototype.duration = function() {
2042
2042
  var n = this.ms * Math.pow(this.factor, this.attempts++);
2043
2043
  if (this.jitter) {
2044
2044
  var t = Math.random(), e = Math.floor(t * this.jitter * n);
@@ -2046,27 +2046,27 @@ nt.prototype.duration = function() {
2046
2046
  }
2047
2047
  return Math.min(n, this.max) | 0;
2048
2048
  };
2049
- nt.prototype.reset = function() {
2049
+ rt.prototype.reset = function() {
2050
2050
  this.attempts = 0;
2051
2051
  };
2052
- nt.prototype.setMin = function(n) {
2052
+ rt.prototype.setMin = function(n) {
2053
2053
  this.ms = n;
2054
2054
  };
2055
- nt.prototype.setMax = function(n) {
2055
+ rt.prototype.setMax = function(n) {
2056
2056
  this.max = n;
2057
2057
  };
2058
- nt.prototype.setJitter = function(n) {
2058
+ rt.prototype.setJitter = function(n) {
2059
2059
  this.jitter = n;
2060
2060
  };
2061
- class Vt extends E {
2061
+ class Jt 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, Ct(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 nt({
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, Nt(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 rt({
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 || Hs;
2069
+ const r = e.parser || Ws;
2070
2070
  this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
2071
2071
  }
2072
2072
  reconnection(t) {
@@ -2109,7 +2109,7 @@ class Vt extends E {
2109
2109
  open(t) {
2110
2110
  if (~this._readyState.indexOf("open"))
2111
2111
  return this;
2112
- this.engine = new Rs(this.uri, this.opts);
2112
+ this.engine = new Ls(this.uri, this.opts);
2113
2113
  const e = this.engine, s = this;
2114
2114
  this._readyState = "opening", this.skipReconnect = !1;
2115
2115
  const r = $(e, "open", function() {
@@ -2199,7 +2199,7 @@ class Vt extends E {
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 De(this, t, e), this.nsps[t] = s), s;
2202
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new Me(this, t, e), this.nsps[t] = s), s;
2203
2203
  }
2204
2204
  /**
2205
2205
  * Called upon a socket close.
@@ -2296,87 +2296,99 @@ class Vt extends E {
2296
2296
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
2297
2297
  }
2298
2298
  }
2299
- const rt = {};
2299
+ const it = {};
2300
2300
  function ut(n, t) {
2301
2301
  typeof n == "object" && (t = n, n = void 0), t = t || {};
2302
- const e = Cs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = rt[r] && i in rt[r].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2302
+ const e = qs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = it[r] && i in it[r].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2303
2303
  let u;
2304
- return h ? u = new Vt(s, t) : (rt[r] || (rt[r] = new Vt(s, t)), u = rt[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
2304
+ return h ? u = new Jt(s, t) : (it[r] || (it[r] = new Jt(s, t)), u = it[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
2305
2305
  }
2306
2306
  Object.assign(ut, {
2307
- Manager: Vt,
2308
- Socket: De,
2307
+ Manager: Jt,
2308
+ Socket: Me,
2309
2309
  io: ut,
2310
2310
  connect: ut
2311
2311
  });
2312
- class _e extends Error {
2312
+ class Te extends Error {
2313
2313
  constructor(t, e) {
2314
2314
  super(
2315
2315
  `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.`
2316
2316
  ), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
2317
2317
  }
2318
2318
  }
2319
- const be = "bimterop", Ee = "revitflow_history.json", it = "revitflow_ops.json", ve = "revitflow/ops@1", Vs = "revitflow_model.frag", Js = "revitflow_", _t = () => `v-${Date.now()}`;
2320
- function Y(n) {
2319
+ const Se = "bimterop", Yt = "revitflow_history.json", z = "revitflow_ops.json", ke = "revitflow/ops@1", He = "revitflow_model.frag", Ge = "revitflow_", _t = () => `v-${Date.now()}`;
2320
+ function Ve(n, t) {
2321
+ return n.filter((e) => String(e.parentId ?? "") === t);
2322
+ }
2323
+ function j(n) {
2321
2324
  return String(n._id ?? n.id ?? "");
2322
2325
  }
2323
- var I, dt, Jt;
2324
- class Ys {
2326
+ var x, dt, Wt;
2327
+ class Xs {
2325
2328
  constructor(t, e) {
2326
- _(this, dt);
2327
- _(this, I);
2329
+ b(this, dt);
2330
+ b(this, x);
2328
2331
  this.client = t, this.projectId = e;
2329
2332
  }
2330
2333
  /** The project's connected documents. */
2331
2334
  async docs() {
2332
- const t = await a(this, dt, Jt).call(this);
2335
+ const t = await a(this, dt, Wt).call(this);
2333
2336
  if (!t) return [];
2334
2337
  const e = await this.client.listFolders({
2335
2338
  parentFolderId: t,
2336
2339
  projectId: this.projectId
2337
2340
  }), s = [];
2338
- for (const r of e) {
2341
+ for (const r of Ve(e, t)) {
2339
2342
  const i = String(r.name ?? ""), o = i.indexOf("-");
2340
- o <= 0 || s.push({
2343
+ if (o <= 0) continue;
2344
+ const u = (await this.client.listFiles({
2345
+ folderId: j(r)
2346
+ })).map(
2347
+ (w) => String(w.name ?? "")
2348
+ ), f = u.find((w) => w === He) ?? u.find(
2349
+ (w) => w.endsWith(".frag") && !w.startsWith(Ge)
2350
+ ), p = u.includes(Yt) || u.includes(z) || !!f;
2351
+ s.push({
2341
2352
  source: i.slice(0, o),
2342
2353
  docId: i.slice(o + 1),
2343
- modelName: void 0
2354
+ modelName: f,
2355
+ ...p ? {} : { empty: !0 }
2344
2356
  });
2345
2357
  }
2346
2358
  return s;
2347
2359
  }
2348
2360
  /** One document's history. `source` and `docId` as {@link docs} lists them. */
2349
2361
  doc(t, e) {
2350
- return new Ws(this.client, this, t, e);
2362
+ return new zs(this.client, this, t, e);
2351
2363
  }
2352
2364
  /** @internal The `bimterop` folder id, resolved once. */
2353
2365
  async rootFolderId(t = !1) {
2354
- if (l(this, I)) return l(this, I);
2355
- const e = await a(this, dt, Jt).call(this);
2366
+ if (l(this, x)) return l(this, x);
2367
+ const e = await a(this, dt, Wt).call(this);
2356
2368
  if (e) return e;
2357
2369
  if (!t) return;
2358
2370
  const s = await this.client.createFolder(
2359
- be,
2371
+ Se,
2360
2372
  void 0,
2361
2373
  this.projectId
2362
2374
  );
2363
- return b(this, I, Y(s)), l(this, I);
2375
+ return _(this, x, j(s)), l(this, x);
2364
2376
  }
2365
2377
  }
2366
- I = new WeakMap(), dt = new WeakSet(), Jt = async function() {
2367
- if (l(this, I)) return l(this, I);
2378
+ x = new WeakMap(), dt = new WeakSet(), Wt = async function() {
2379
+ if (l(this, x)) return l(this, x);
2368
2380
  const e = (await this.client.listFolders({
2369
2381
  projectId: this.projectId
2370
2382
  })).find(
2371
- (s) => String(s.name ?? "") === be && !s.parentId
2383
+ (s) => String(s.name ?? "") === Se && !s.parentId
2372
2384
  );
2373
- return e && b(this, I, Y(e)), l(this, I);
2385
+ return e && _(this, x, j(e)), l(this, x);
2374
2386
  };
2375
- var L, p, at, ct, Yt, Tt, St, Wt, kt, ht, Ot, Kt, je;
2376
- class Ws {
2387
+ var L, y, at, ct, Kt, St, kt, Xt, Ot, ht, At, zt, Je;
2388
+ class zs {
2377
2389
  constructor(t, e, s, r) {
2378
- _(this, p);
2379
- _(this, L);
2390
+ b(this, y);
2391
+ b(this, L);
2380
2392
  this.client = t, this.project = e, this.source = s, this.docId = r;
2381
2393
  }
2382
2394
  // ─── Reading ───────────────────────────────────────────────────────────────
@@ -2386,8 +2398,8 @@ class Ws {
2386
2398
  * Each version gets its `ordinal` filled in.
2387
2399
  */
2388
2400
  async timeline() {
2389
- const t = await a(this, p, kt).call(this);
2390
- return Me((t == null ? void 0 : t.commits) ?? []);
2401
+ const t = await a(this, y, Ot).call(this);
2402
+ return Ye((t == null ? void 0 : t.commits) ?? []);
2391
2403
  }
2392
2404
  /** The head of the timeline, or null before the first sync. */
2393
2405
  async latest() {
@@ -2407,7 +2419,7 @@ class Ws {
2407
2419
  }
2408
2420
  /** The visible model .frag as last fully exported. */
2409
2421
  async model() {
2410
- const t = await a(this, p, St).call(this);
2422
+ const t = await a(this, y, kt).call(this);
2411
2423
  if (!t)
2412
2424
  throw new Error(
2413
2425
  `Document ${this.source}-${this.docId} has no model file yet.`
@@ -2423,16 +2435,16 @@ class Ws {
2423
2435
  */
2424
2436
  async sync(t) {
2425
2437
  var h;
2426
- const e = await a(this, p, ct).call(this, !0);
2427
- let s = await a(this, p, kt).call(this) ?? {
2438
+ const e = await a(this, y, ct).call(this, !0);
2439
+ let s = await a(this, y, Ot).call(this) ?? {
2428
2440
  model: this.docId,
2429
2441
  commits: []
2430
2442
  };
2431
- const r = Te(s.commits);
2443
+ const r = Oe(s.commits);
2432
2444
  if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
2433
- throw new _e(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2445
+ throw new Te(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2434
2446
  const i = {
2435
- guid: Se(),
2447
+ guid: Qt(),
2436
2448
  ...r ? { parents: [r.guid] } : {},
2437
2449
  author: t.author,
2438
2450
  source: t.source,
@@ -2441,10 +2453,10 @@ class Ws {
2441
2453
  ...t.userId ? { userId: t.userId } : {},
2442
2454
  ...(h = t.appliedOps) != null && h.length ? { appliedOps: t.appliedOps } : {},
2443
2455
  changes: t.changes,
2444
- counts: Ks(t.changes)
2456
+ counts: Qs(t.changes)
2445
2457
  };
2446
- if (t.model && (await a(this, p, je).call(this, e, t.model), i.full = !0), t.delta) {
2447
- const u = await a(this, p, St).call(this);
2458
+ if (t.model && (await a(this, y, Je).call(this, e, t.model), i.full = !0), t.delta) {
2459
+ const u = await a(this, y, kt).call(this);
2448
2460
  if (!u)
2449
2461
  throw new Error(
2450
2462
  "A delta needs the model file to hang from: sync a full model first."
@@ -2457,20 +2469,20 @@ class Ws {
2457
2469
  f._id ?? f.id
2458
2470
  );
2459
2471
  }
2460
- const o = await a(this, p, kt).call(this);
2472
+ const o = await a(this, y, Ot).call(this);
2461
2473
  if (o) {
2462
2474
  s = o;
2463
- const u = Te(s.commits);
2475
+ const u = Oe(s.commits);
2464
2476
  if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
2465
- throw new _e(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2477
+ throw new Te(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2466
2478
  u && !i.parents && (i.parents = [u.guid]);
2467
2479
  }
2468
- return s.commits.push(i), await a(this, p, Ot).call(this, e, Ee, s), i;
2480
+ return s.commits.push(i), await a(this, y, At).call(this, e, Yt, s), i;
2469
2481
  }
2470
2482
  // ─── Suggestions (change requests) ────────────────────────────────────────
2471
2483
  /** Every suggestion in the document's queue, pending or resolved. */
2472
2484
  async suggestions() {
2473
- const t = await a(this, p, ht).call(this);
2485
+ const t = await a(this, y, ht).call(this);
2474
2486
  return (t == null ? void 0 : t.ops) ?? [];
2475
2487
  }
2476
2488
  /** The suggestions still waiting for the owner, oldest first. */
@@ -2482,8 +2494,8 @@ class Ws {
2482
2494
  * uploaded as a hidden file under the suggestions index.
2483
2495
  */
2484
2496
  async suggest(t) {
2485
- const e = await a(this, p, ct).call(this, !0), s = await a(this, p, ht).call(this) ?? { schema: ve, ops: [] }, r = await a(this, p, Tt).call(this, it), i = {
2486
- opId: Se(),
2497
+ const e = await a(this, y, ct).call(this, !0), s = await a(this, y, ht).call(this) ?? { schema: ke, ops: [] }, r = await a(this, y, St).call(this, z), i = {
2498
+ opId: t.opId ?? Qt(),
2487
2499
  title: t.title,
2488
2500
  verb: t.verb,
2489
2501
  author: t.author,
@@ -2495,7 +2507,7 @@ class Ws {
2495
2507
  ...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
2496
2508
  };
2497
2509
  if (t.payload) {
2498
- const h = r ?? await a(this, p, Kt).call(this, e, it, s), u = await this.client.createHiddenFile(
2510
+ const h = r ?? await a(this, y, zt).call(this, e, z, s), u = await this.client.createHiddenFile(
2499
2511
  t.payload,
2500
2512
  h.id
2501
2513
  );
@@ -2503,8 +2515,8 @@ class Ws {
2503
2515
  u._id ?? u.id
2504
2516
  );
2505
2517
  }
2506
- const o = await a(this, p, ht).call(this) ?? s;
2507
- return o.schema ?? (o.schema = ve), o.ops.push(i), await a(this, p, Ot).call(this, e, it, o), i;
2518
+ const o = await a(this, y, ht).call(this) ?? s;
2519
+ return o.schema ?? (o.schema = ke), o.ops.push(i), await a(this, y, At).call(this, e, z, o), i;
2508
2520
  }
2509
2521
  /** A suggestion's .frag payload. */
2510
2522
  async suggestionPayload(t) {
@@ -2518,15 +2530,15 @@ class Ws {
2518
2530
  * use it for `discarded`.
2519
2531
  */
2520
2532
  async resolveSuggestion(t, e) {
2521
- const s = await a(this, p, ct).call(this, !1);
2533
+ const s = await a(this, y, ct).call(this, !1);
2522
2534
  if (!s) throw new Error("This document has no suggestion queue.");
2523
- const r = await a(this, p, ht).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
2535
+ const r = await a(this, y, ht).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
2524
2536
  if (!r || !i)
2525
2537
  throw new Error(`No suggestion ${t} in this document's queue.`);
2526
- return Object.assign(i, e), await a(this, p, Ot).call(this, s, it, r), i;
2538
+ return Object.assign(i, e), await a(this, y, At).call(this, s, z, r), i;
2527
2539
  }
2528
2540
  }
2529
- L = new WeakMap(), p = new WeakSet(), at = function() {
2541
+ L = new WeakMap(), y = new WeakSet(), at = function() {
2530
2542
  return `${this.source}-${this.docId}`;
2531
2543
  }, ct = async function(t) {
2532
2544
  if (l(this, L)) return l(this, L);
@@ -2535,64 +2547,64 @@ L = new WeakMap(), p = new WeakSet(), at = function() {
2535
2547
  throw new Error(
2536
2548
  `Project ${this.project.projectId} has no connected documents yet.`
2537
2549
  );
2538
- const r = (await this.client.listFolders({
2550
+ const s = await this.client.listFolders({
2539
2551
  parentFolderId: e,
2540
2552
  projectId: this.project.projectId
2541
- })).find(
2542
- (o) => String(o.name ?? "") === l(this, p, at)
2553
+ }), r = Ve(s, e).find(
2554
+ (o) => String(o.name ?? "") === l(this, y, at)
2543
2555
  );
2544
2556
  if (r)
2545
- return b(this, L, Y(r)), l(this, L);
2557
+ return _(this, L, j(r)), l(this, L);
2546
2558
  if (!t)
2547
2559
  throw new Error(
2548
- `Document ${l(this, p, at)} does not exist in this project.`
2560
+ `Document ${l(this, y, at)} does not exist in this project.`
2549
2561
  );
2550
2562
  const i = await this.client.createFolder(
2551
- l(this, p, at),
2563
+ l(this, y, at),
2552
2564
  e,
2553
2565
  this.project.projectId
2554
2566
  );
2555
- return b(this, L, Y(i)), l(this, L);
2556
- }, Yt = async function() {
2557
- const t = await a(this, p, ct).call(this, !1);
2567
+ return _(this, L, j(i)), l(this, L);
2568
+ }, Kt = async function() {
2569
+ const t = await a(this, y, ct).call(this, !1);
2558
2570
  return (await this.client.listFiles({ folderId: t })).map((s) => ({
2559
- id: Y(s),
2571
+ id: j(s),
2560
2572
  name: String(s.name ?? "")
2561
2573
  }));
2562
- }, Tt = async function(t) {
2574
+ }, St = async function(t) {
2563
2575
  try {
2564
- return (await a(this, p, Yt).call(this)).find((e) => e.name === t);
2576
+ return (await a(this, y, Kt).call(this)).find((e) => e.name === t);
2565
2577
  } catch {
2566
2578
  return;
2567
2579
  }
2568
- }, St = async function() {
2580
+ }, kt = async function() {
2569
2581
  try {
2570
- const t = await a(this, p, Yt).call(this);
2571
- return t.find((e) => e.name === Vs) ?? t.find(
2572
- (e) => e.name.endsWith(".frag") && !e.name.startsWith(Js)
2582
+ const t = await a(this, y, Kt).call(this);
2583
+ return t.find((e) => e.name === He) ?? t.find(
2584
+ (e) => e.name.endsWith(".frag") && !e.name.startsWith(Ge)
2573
2585
  );
2574
2586
  } catch {
2575
2587
  return;
2576
2588
  }
2577
- }, Wt = async function(t) {
2578
- const e = await a(this, p, Tt).call(this, t);
2589
+ }, Xt = async function(t) {
2590
+ const e = await a(this, y, St).call(this, t);
2579
2591
  if (!e) return;
2580
2592
  const r = await (await this.client.downloadFile(e.id)).text();
2581
2593
  if (r.trim())
2582
2594
  return JSON.parse(r);
2583
- }, kt = function() {
2584
- return a(this, p, Wt).call(this, Ee);
2595
+ }, Ot = function() {
2596
+ return a(this, y, Xt).call(this, Yt);
2585
2597
  }, ht = function() {
2586
- return a(this, p, Wt).call(this, it);
2587
- }, Ot = async function(t, e, s) {
2598
+ return a(this, y, Xt).call(this, z);
2599
+ }, At = async function(t, e, s) {
2588
2600
  const r = new Blob([JSON.stringify(s)], {
2589
2601
  type: "application/json"
2590
- }), i = await a(this, p, Tt).call(this, e);
2602
+ }), i = await a(this, y, St).call(this, e);
2591
2603
  return i ? (await this.client.updateFile(i.id, {
2592
2604
  file: r,
2593
2605
  versionTag: _t()
2594
- }), i) : await a(this, p, Kt).call(this, t, e, s);
2595
- }, Kt = async function(t, e, s) {
2606
+ }), i) : await a(this, y, zt).call(this, t, e, s);
2607
+ }, zt = async function(t, e, s) {
2596
2608
  const r = new Blob([JSON.stringify(s)], {
2597
2609
  type: "application/json"
2598
2610
  }), i = await this.client.createFile({
@@ -2602,122 +2614,162 @@ L = new WeakMap(), p = new WeakSet(), at = function() {
2602
2614
  parentFolderId: t,
2603
2615
  projectId: this.project.projectId
2604
2616
  }), o = i.item;
2605
- return { id: Y(o ?? i), name: e };
2606
- }, je = async function(t, e) {
2607
- const s = await a(this, p, St).call(this);
2617
+ return { id: j(o ?? i), name: e };
2618
+ }, Je = async function(t, e) {
2619
+ const s = await a(this, y, kt).call(this);
2608
2620
  if (s)
2609
2621
  return await this.client.updateFile(s.id, {
2610
2622
  file: e,
2611
2623
  versionTag: _t()
2612
2624
  }), s;
2613
- const r = `${l(this, p, at)}.frag`, i = await this.client.createFile({
2625
+ const r = `${l(this, y, at)}.frag`, i = await this.client.createFile({
2614
2626
  file: e,
2615
2627
  name: r,
2616
2628
  versionTag: _t(),
2617
2629
  parentFolderId: t,
2618
2630
  projectId: this.project.projectId
2619
2631
  }), o = i.item;
2620
- return { id: Y(o ?? i), name: r };
2632
+ return { id: j(o ?? i), name: r };
2621
2633
  };
2622
- function Ks(n) {
2634
+ function Qs(n) {
2623
2635
  const t = { added: 0, modified: 0, removed: 0 };
2624
2636
  for (const e of n)
2625
2637
  e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
2626
2638
  return t;
2627
2639
  }
2628
- function Me(n) {
2640
+ function Ye(n) {
2629
2641
  var u;
2630
2642
  if (n.length <= 1)
2631
- return n.forEach((f, y) => f.ordinal = y), [...n];
2643
+ return n.forEach((f, p) => f.ordinal = p), [...n];
2632
2644
  const t = new Map(n.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
2633
2645
  for (const f of n) {
2634
- const y = (u = f.parents) == null ? void 0 : u[0];
2635
- if (y && t.has(y)) {
2636
- const w = e.get(y) ?? [];
2637
- w.push(f), e.set(y, w);
2646
+ const p = (u = f.parents) == null ? void 0 : u[0];
2647
+ if (p && t.has(p)) {
2648
+ const w = e.get(p) ?? [];
2649
+ w.push(f), e.set(p, w);
2638
2650
  } else
2639
2651
  s.push(f);
2640
2652
  }
2641
- const r = (f, y) => String(f.timestamp).localeCompare(String(y.timestamp));
2653
+ const r = (f, p) => String(f.timestamp).localeCompare(String(p.timestamp));
2642
2654
  s.sort(r);
2643
2655
  const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
2644
2656
  for (; o.length; ) {
2645
2657
  const f = o.pop();
2646
2658
  if (h.has(f.guid)) continue;
2647
2659
  h.add(f.guid), i.push(f);
2648
- const y = (e.get(f.guid) ?? []).sort(r);
2649
- for (let w = y.length - 1; w >= 0; w--) o.push(y[w]);
2660
+ const p = (e.get(f.guid) ?? []).sort(r);
2661
+ for (let w = p.length - 1; w >= 0; w--) o.push(p[w]);
2650
2662
  }
2651
2663
  for (const f of n)
2652
2664
  h.has(f.guid) || i.push(f);
2653
- return i.forEach((f, y) => f.ordinal = y), i;
2665
+ return i.forEach((f, p) => f.ordinal = p), i;
2654
2666
  }
2655
- function Te(n) {
2656
- const t = Me(n);
2667
+ function Oe(n) {
2668
+ const t = Ye(n);
2657
2669
  return t[t.length - 1];
2658
2670
  }
2659
- function Se() {
2671
+ function Qt() {
2660
2672
  const n = globalThis.crypto;
2661
2673
  return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
2662
2674
  const e = Math.random() * 16 | 0;
2663
2675
  return (t === "x" ? e : e & 3 | 8).toString(16);
2664
2676
  });
2665
2677
  }
2666
- var j;
2667
- class Xs {
2678
+ var M, ft, Zt;
2679
+ class Zs {
2668
2680
  constructor(t) {
2669
- _(this, j, /* @__PURE__ */ new Map());
2681
+ b(this, ft);
2682
+ b(this, M, /* @__PURE__ */ new Map());
2670
2683
  this.client = t;
2671
2684
  }
2672
2685
  /** Registers a recipe. One per name; a second with the same name throws. */
2673
2686
  register(t) {
2674
- if (l(this, j).has(t.name))
2687
+ if (l(this, M).has(t.name))
2675
2688
  throw new Error(`A recipe named "${t.name}" is already registered.`);
2676
- l(this, j).set(t.name, t);
2689
+ l(this, M).set(t.name, t);
2677
2690
  }
2678
2691
  /** The registered recipes, optionally filtered by target application. */
2679
2692
  list(t) {
2680
- return [...l(this, j).values()].filter(
2693
+ return [...l(this, M).values()].filter(
2681
2694
  (s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
2682
2695
  );
2683
2696
  }
2684
2697
  /** A registered recipe by name, or undefined. */
2685
2698
  get(t) {
2686
- return l(this, j).get(t);
2699
+ return l(this, M).get(t);
2700
+ }
2701
+ /**
2702
+ * Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
2703
+ * {@link RecipePlan} — the result to show (title, tallies, targets) plus
2704
+ * everything {@link queue} needs to queue EXACTLY this, payload and opId
2705
+ * included, with no second run. Discard it and the plan never happened.
2706
+ */
2707
+ async plan(t, e) {
2708
+ const { base: s, opId: r, result: i } = await a(this, ft, Zt).call(this, t, e);
2709
+ return {
2710
+ opId: r,
2711
+ projectId: e.projectId,
2712
+ target: e.target,
2713
+ ...s != null && s.guid ? { baseCommitGuid: s.guid } : {},
2714
+ result: i
2715
+ };
2716
+ }
2717
+ /**
2718
+ * Queues exactly what {@link plan} planned: same opId, same payload, no
2719
+ * second execution. The pair plan → confirm → queue is the UI flow; `run`
2720
+ * is the one-shot shortcut.
2721
+ */
2722
+ async queue(t, e) {
2723
+ return { suggestion: await this.client.history(t.projectId).doc(t.target.source, t.target.docId).suggest({
2724
+ opId: t.opId,
2725
+ title: t.result.title,
2726
+ verb: t.result.verb,
2727
+ author: e.author,
2728
+ payload: t.result.payload,
2729
+ targets: t.result.targets,
2730
+ userId: e.userId,
2731
+ baseCommitGuid: t.baseCommitGuid
2732
+ }), result: t.result };
2687
2733
  }
2688
2734
  /**
2689
2735
  * Runs a recipe and queues its suggestion on the target document. Safe to
2690
2736
  * call freely: nothing touches the native application until its owner
2691
- * accepts the suggestion there.
2737
+ * accepts the suggestion there. Use {@link plan} first when the app wants
2738
+ * to show the tallies before queueing.
2692
2739
  */
2693
2740
  async run(t, e) {
2694
- const s = l(this, j).get(t);
2695
- if (!s) throw new Error(`No recipe named "${t}" is registered.`);
2696
- if (s.to !== e.target.source)
2697
- throw new Error(
2698
- `Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
2699
- );
2700
- const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = await s.run({
2701
- client: this.client,
2702
- projectId: e.projectId,
2703
- targetDoc: r,
2704
- input: e.input,
2705
- settings: e.settings ?? {}
2706
- });
2707
- return { suggestion: await r.suggest({
2741
+ const { targetDoc: s, base: r, opId: i, result: o } = await a(this, ft, Zt).call(this, t, e);
2742
+ return { suggestion: await s.suggest({
2743
+ opId: i,
2708
2744
  title: o.title,
2709
2745
  verb: o.verb,
2710
2746
  author: e.author,
2711
2747
  payload: o.payload,
2712
2748
  targets: o.targets,
2713
2749
  userId: e.userId,
2714
- baseCommitGuid: i == null ? void 0 : i.guid
2750
+ baseCommitGuid: r == null ? void 0 : r.guid
2715
2751
  }), result: o };
2716
2752
  }
2717
2753
  }
2718
- j = new WeakMap();
2719
- const ke = 100;
2720
- function zs(n) {
2754
+ M = new WeakMap(), ft = new WeakSet(), Zt = async function(t, e) {
2755
+ const s = l(this, M).get(t);
2756
+ if (!s) throw new Error(`No recipe named "${t}" is registered.`);
2757
+ if (s.to !== e.target.source)
2758
+ throw new Error(
2759
+ `Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
2760
+ );
2761
+ const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = Qt(), h = await s.run({
2762
+ client: this.client,
2763
+ projectId: e.projectId,
2764
+ targetDoc: r,
2765
+ opId: o,
2766
+ input: e.input,
2767
+ settings: e.settings ?? {}
2768
+ });
2769
+ return { recipe: s, targetDoc: r, base: i, opId: o, result: h };
2770
+ };
2771
+ const Ae = 100;
2772
+ function tn(n) {
2721
2773
  try {
2722
2774
  const t = JSON.parse(n);
2723
2775
  if (t && typeof t == "object") {
@@ -2732,14 +2784,14 @@ function zs(n) {
2732
2784
  }
2733
2785
  return {};
2734
2786
  }
2735
- function Qs(n) {
2787
+ function en(n) {
2736
2788
  if (!n || typeof n != "object") return;
2737
2789
  const t = n.retryAfter;
2738
2790
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
2739
2791
  }
2740
- class le extends Error {
2792
+ class pe extends Error {
2741
2793
  constructor(e, s, r, i) {
2742
- const o = zs(r);
2794
+ const o = tn(r);
2743
2795
  super(o.message ?? `${s || "Request failed"} (${e})`);
2744
2796
  T(this, "status");
2745
2797
  T(this, "code");
@@ -2750,11 +2802,11 @@ class le extends Error {
2750
2802
  * from `details.retryAfter`. Only present on rate-limited (429) responses.
2751
2803
  */
2752
2804
  T(this, "retryAfter");
2753
- this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? Qs(o.details);
2805
+ this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? en(o.details);
2754
2806
  }
2755
2807
  }
2756
- const C = "item/folder", m = "item", U = "processor", Zs = "npm-registry", B = "hidden", qt = "FILE", Ft = "TOOL", Ut = "APP", tn = 500, Oe = 3e4, en = 0.25, sn = (n) => new Promise((t) => setTimeout(t, n));
2757
- function nn(n) {
2808
+ const R = "item/folder", m = "item", U = "processor", sn = "npm-registry", B = "hidden", Ft = "FILE", Ut = "TOOL", Dt = "APP", nn = 500, Ie = 3e4, rn = 0.25, on = (n) => new Promise((t) => setTimeout(t, n));
2809
+ function an(n) {
2758
2810
  var r, i;
2759
2811
  const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
2760
2812
  if (!t) return;
@@ -2764,18 +2816,18 @@ function nn(n) {
2764
2816
  if (!Number.isNaN(s))
2765
2817
  return Math.max(0, (s - Date.now()) / 1e3);
2766
2818
  }
2767
- function rn(n) {
2768
- return n instanceof le ? n.status === 429 || n.status >= 500 : !0;
2819
+ function cn(n) {
2820
+ return n instanceof pe ? n.status === 429 || n.status >= 500 : !0;
2769
2821
  }
2770
- function on(n, t) {
2822
+ function hn(n, t) {
2771
2823
  const e = Math.min(
2772
- tn * 2 ** t,
2773
- Oe
2774
- ), s = e * en * Math.random(), r = n instanceof le && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
2775
- return r != null ? Math.min(r, Oe) + s : e + s;
2824
+ nn * 2 ** t,
2825
+ Ie
2826
+ ), s = e * rn * Math.random(), r = n instanceof pe && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
2827
+ return r != null ? Math.min(r, Ie) + s : e + s;
2776
2828
  }
2777
- var c, zt, d, D, ft, lt, At, xt, Qt, Zt, He;
2778
- const ue = class ue {
2829
+ var c, ee, d, D, pt, lt, It, xt, se, ne, We;
2830
+ const ye = class ye {
2779
2831
  /**
2780
2832
  * Creates a new EngineServicesClient instance.
2781
2833
  * @param accessToken - API access token (obtained from the platform dashboard)
@@ -2784,7 +2836,7 @@ const ue = class ue {
2784
2836
  * @param props - Optional configuration (retry count, auth mode, etc.).
2785
2837
  */
2786
2838
  constructor(t, e, s) {
2787
- _(this, c);
2839
+ b(this, c);
2788
2840
  T(this, "apiUrl");
2789
2841
  T(this, "accessToken");
2790
2842
  T(this, "wsUrl");
@@ -2803,7 +2855,7 @@ const ue = class ue {
2803
2855
  * Populated automatically when using {@link fromPlatformContext}.
2804
2856
  */
2805
2857
  T(this, "context");
2806
- _(this, ft);
2858
+ b(this, pt);
2807
2859
  const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
2808
2860
  let h = e;
2809
2861
  if (h.charAt(h.length - 1) === "/" && (h = h.slice(0, -1)), this.apiUrl = `${h}/api`, this.accessToken = t, this.wsUrl = h, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
@@ -2828,7 +2880,7 @@ const ue = class ue {
2828
2880
  * ```
2829
2881
  */
2830
2882
  static fromPlatformContext(t) {
2831
- const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new ue(e.accessToken, e.apiUrl, {
2883
+ const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new ye(e.accessToken, e.apiUrl, {
2832
2884
  ...t,
2833
2885
  useBearer: !0
2834
2886
  });
@@ -2914,9 +2966,9 @@ const ue = class ue {
2914
2966
  */
2915
2967
  async listFiles(t) {
2916
2968
  const { folderId: e, archived: s, projectId: r } = t || {};
2917
- return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, { query: { itemType: qt, archived: s } }) : await a(this, c, d).call(this, "GET", `${m}`, {
2969
+ return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, { query: { itemType: Ft, archived: s } }) : await a(this, c, d).call(this, "GET", `${m}`, {
2918
2970
  query: {
2919
- itemType: qt,
2971
+ itemType: Ft,
2920
2972
  archived: s,
2921
2973
  ...r && { projectId: r }
2922
2974
  }
@@ -2929,7 +2981,7 @@ const ue = class ue {
2929
2981
  * @returns The file item, optionally with version history.
2930
2982
  */
2931
2983
  async getFile(t, e) {
2932
- return await a(this, c, Zt).call(this, t, e);
2984
+ return await a(this, c, ne).call(this, t, e);
2933
2985
  }
2934
2986
  /**
2935
2987
  * Uploads a new file.
@@ -2937,7 +2989,7 @@ const ue = class ue {
2937
2989
  * @returns The created item and its first version.
2938
2990
  */
2939
2991
  async createFile(t) {
2940
- return await a(this, c, xt).call(this, t, qt);
2992
+ return await a(this, c, xt).call(this, t, Ft);
2941
2993
  }
2942
2994
  /**
2943
2995
  * Updates an existing file. Can rename, move to a different folder,
@@ -2947,7 +2999,7 @@ const ue = class ue {
2947
2999
  * @returns The updated item and/or the new version.
2948
3000
  */
2949
3001
  async updateFile(t, e) {
2950
- return await a(this, c, Qt).call(this, t, e);
3002
+ return await a(this, c, se).call(this, t, e);
2951
3003
  }
2952
3004
  /**
2953
3005
  * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
@@ -2970,7 +3022,7 @@ const ue = class ue {
2970
3022
  * @returns A fetch Response containing the file data.
2971
3023
  */
2972
3024
  async downloadFile(t, e) {
2973
- return await a(this, c, At).call(this, t, e);
3025
+ return await a(this, c, It).call(this, t, e);
2974
3026
  }
2975
3027
  /**
2976
3028
  * Retrieves the free-JSON metadata for a specific file version.
@@ -3038,7 +3090,7 @@ const ue = class ue {
3038
3090
  */
3039
3091
  async listFolders(t) {
3040
3092
  const { archived: e, parentFolderId: s, projectId: r } = t || {};
3041
- return await a(this, c, d).call(this, "GET", C, {
3093
+ return await a(this, c, d).call(this, "GET", R, {
3042
3094
  query: {
3043
3095
  parentFolderId: s,
3044
3096
  archived: e,
@@ -3051,7 +3103,7 @@ const ue = class ue {
3051
3103
  * @param folderId - The folder's unique identifier.
3052
3104
  */
3053
3105
  async getFolder(t) {
3054
- return await a(this, c, d).call(this, "GET", `${C}/${t}`);
3106
+ return await a(this, c, d).call(this, "GET", `${R}/${t}`);
3055
3107
  }
3056
3108
  /**
3057
3109
  * Batch variant of {@link getFolder}. Resolves a known set of folder ids in
@@ -3079,7 +3131,7 @@ const ue = class ue {
3079
3131
  * @returns The created folder.
3080
3132
  */
3081
3133
  async createFolder(t, e, s) {
3082
- return await a(this, c, d).call(this, "POST", C, {
3134
+ return await a(this, c, d).call(this, "POST", R, {
3083
3135
  body: JSON.stringify({
3084
3136
  name: t,
3085
3137
  ...e && { parentId: e },
@@ -3096,7 +3148,7 @@ const ue = class ue {
3096
3148
  */
3097
3149
  async updateFolder(t, e) {
3098
3150
  const { name: s } = e;
3099
- return await a(this, c, d).call(this, "PUT", `${C}/${t}`, {
3151
+ return await a(this, c, d).call(this, "PUT", `${R}/${t}`, {
3100
3152
  body: JSON.stringify({ name: s }),
3101
3153
  contentType: "application/json"
3102
3154
  });
@@ -3106,14 +3158,14 @@ const ue = class ue {
3106
3158
  * @param folderId - The folder's unique identifier.
3107
3159
  */
3108
3160
  async archiveFolder(t) {
3109
- return await a(this, c, d).call(this, "DELETE", `${C}/${t}`);
3161
+ return await a(this, c, d).call(this, "DELETE", `${R}/${t}`);
3110
3162
  }
3111
3163
  /**
3112
3164
  * Recovers a previously archived folder.
3113
3165
  * @param folderId - The folder's unique identifier.
3114
3166
  */
3115
3167
  async recoverFolder(t) {
3116
- return await a(this, c, d).call(this, "PUT", `${C}/${t}/recover`);
3168
+ return await a(this, c, d).call(this, "PUT", `${R}/${t}/recover`);
3117
3169
  }
3118
3170
  /**
3119
3171
  * Downloads an entire folder as a ZIP archive.
@@ -3121,7 +3173,7 @@ const ue = class ue {
3121
3173
  * @returns A fetch Response containing the ZIP data.
3122
3174
  */
3123
3175
  async downloadFolder(t) {
3124
- return await a(this, c, D).call(this, `${C}/${t}/download`);
3176
+ return await a(this, c, D).call(this, `${R}/${t}/download`);
3125
3177
  }
3126
3178
  // ─── Components ──────────────────────────────────────────────────
3127
3179
  /**
@@ -3131,14 +3183,14 @@ const ue = class ue {
3131
3183
  */
3132
3184
  async listComponents(t) {
3133
3185
  const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3134
- return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
3186
+ return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, {
3135
3187
  query: {
3136
- itemType: Ft,
3188
+ itemType: Ut,
3137
3189
  ...s && { ShowVersions: s }
3138
3190
  }
3139
3191
  }) : await a(this, c, d).call(this, "GET", `${m}`, {
3140
3192
  query: {
3141
- itemType: Ft,
3193
+ itemType: Ut,
3142
3194
  ...s && { ShowVersions: s },
3143
3195
  ...r && { projectId: r }
3144
3196
  }
@@ -3150,7 +3202,7 @@ const ue = class ue {
3150
3202
  * @param props - Options such as whether to include versions.
3151
3203
  */
3152
3204
  async getComponent(t, e) {
3153
- return await a(this, c, Zt).call(this, t, e);
3205
+ return await a(this, c, ne).call(this, t, e);
3154
3206
  }
3155
3207
  /**
3156
3208
  * Creates a new component with the given file and version properties.
@@ -3159,7 +3211,7 @@ const ue = class ue {
3159
3211
  */
3160
3212
  async createComponent(t) {
3161
3213
  const { componentProps: e } = t;
3162
- return await a(this, c, xt).call(this, t, Ft, e);
3214
+ return await a(this, c, xt).call(this, t, Ut, e);
3163
3215
  }
3164
3216
  /**
3165
3217
  * Updates an existing component. Can rename, move, and/or upload a new version.
@@ -3169,7 +3221,7 @@ const ue = class ue {
3169
3221
  */
3170
3222
  async updateComponent(t, e) {
3171
3223
  const { componentProps: s } = e;
3172
- return await a(this, c, Qt).call(this, t, e, s);
3224
+ return await a(this, c, se).call(this, t, e, s);
3173
3225
  }
3174
3226
  /**
3175
3227
  * Downloads a component's full ZIP file. Returns the raw fetch Response.
@@ -3178,7 +3230,7 @@ const ue = class ue {
3178
3230
  * @returns A fetch Response containing the ZIP data.
3179
3231
  */
3180
3232
  async downloadComponent(t, e) {
3181
- return await a(this, c, At).call(this, t, e);
3233
+ return await a(this, c, It).call(this, t, e);
3182
3234
  }
3183
3235
  /**
3184
3236
  * Downloads only the JavaScript bundle from a component's ZIP.
@@ -3247,8 +3299,8 @@ const ue = class ue {
3247
3299
  */
3248
3300
  async initBuiltInComponent(t, e, s) {
3249
3301
  const r = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((w) => i[w]), f = new Function(...o, `${r}
3250
- return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3251
- e.get(y);
3302
+ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3303
+ e.get(p);
3252
3304
  }
3253
3305
  /**
3254
3306
  * Loads multiple built-in components in parallel.
@@ -3315,14 +3367,14 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3315
3367
  */
3316
3368
  async listApps(t) {
3317
3369
  const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3318
- return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
3370
+ return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, {
3319
3371
  query: {
3320
- itemType: Ut,
3372
+ itemType: Dt,
3321
3373
  ...s && { ShowVersions: s }
3322
3374
  }
3323
3375
  }) : await a(this, c, d).call(this, "GET", `${m}`, {
3324
3376
  query: {
3325
- itemType: Ut,
3377
+ itemType: Dt,
3326
3378
  ...s && { ShowVersions: s },
3327
3379
  ...r && { projectId: r }
3328
3380
  }
@@ -3335,7 +3387,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3335
3387
  */
3336
3388
  async createApp(t) {
3337
3389
  const { appProps: e } = t;
3338
- return await a(this, c, xt).call(this, t, Ut, e);
3390
+ return await a(this, c, xt).call(this, t, Dt, e);
3339
3391
  }
3340
3392
  /**
3341
3393
  * Downloads an app's full ZIP file. Returns the raw fetch Response.
@@ -3344,7 +3396,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3344
3396
  * @returns A fetch Response containing the ZIP data.
3345
3397
  */
3346
3398
  async downloadApp(t, e) {
3347
- return await a(this, c, At).call(this, t, e);
3399
+ return await a(this, c, It).call(this, t, e);
3348
3400
  }
3349
3401
  /**
3350
3402
  * Downloads only the JavaScript bundle from an app's ZIP.
@@ -3379,7 +3431,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3379
3431
  * @returns The registry, scope, read-only token, and assembled `.npmrc`.
3380
3432
  */
3381
3433
  async getNpmCredentials() {
3382
- return await a(this, c, d).call(this, "GET", `${Zs}/credentials`);
3434
+ return await a(this, c, d).call(this, "GET", `${sn}/credentials`);
3383
3435
  }
3384
3436
  // ─── Execution ───────────────────────────────────────────────────
3385
3437
  /**
@@ -3505,14 +3557,14 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3505
3557
  * or write it; the storage underneath is private and will move.
3506
3558
  */
3507
3559
  history(t) {
3508
- return new Ys(this, t);
3560
+ return new Xs(this, t);
3509
3561
  }
3510
3562
  /**
3511
3563
  * The recipe registry and runner: scripts that write change requests in a
3512
3564
  * native application's language. See `src/core/recipes.ts`.
3513
3565
  */
3514
3566
  get recipes() {
3515
- return l(this, ft) ?? b(this, ft, new Xs(this)), l(this, ft);
3567
+ return l(this, pt) ?? _(this, pt, new Zs(this)), l(this, pt);
3516
3568
  }
3517
3569
  // ─── Hidden Files ────────────────────────────────────────────────
3518
3570
  /**
@@ -3756,51 +3808,51 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3756
3808
  return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
3757
3809
  }
3758
3810
  };
3759
- c = new WeakSet(), zt = function(t) {
3811
+ c = new WeakSet(), ee = function(t) {
3760
3812
  return `${this.apiUrl}/${t}`;
3761
3813
  }, d = async function(t, e, s) {
3762
- const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, y = a(this, c, zt).call(this, e), w = a(this, c, He).call(this, i), R = await this.resolveAccessToken(), Ke = {
3814
+ const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, p = a(this, c, ee).call(this, e), w = a(this, c, We).call(this, i), C = await this.resolveAccessToken(), ts = {
3763
3815
  ...w,
3764
- ...this.useBearer ? {} : { accessToken: R }
3816
+ ...this.useBearer ? {} : { accessToken: C }
3765
3817
  };
3766
3818
  try {
3767
- const x = await fetch(
3768
- y + "?" + new URLSearchParams(Ke).toString(),
3819
+ const I = await fetch(
3820
+ p + "?" + new URLSearchParams(ts).toString(),
3769
3821
  {
3770
3822
  method: t,
3771
3823
  headers: {
3772
3824
  Accept: "application/json",
3773
3825
  ...o && { "Content-Type": o },
3774
- ...this.useBearer && { Authorization: `Bearer ${R}` }
3826
+ ...this.useBearer && { Authorization: `Bearer ${C}` }
3775
3827
  },
3776
3828
  ...r && { body: r }
3777
3829
  }
3778
3830
  );
3779
- if (!x.ok) {
3780
- const K = await x.text().then((mt) => mt).catch(() => "");
3781
- throw new le(
3782
- x.status,
3783
- x.statusText,
3831
+ if (!I.ok) {
3832
+ const K = await I.text().then((gt) => gt).catch(() => "");
3833
+ throw new pe(
3834
+ I.status,
3835
+ I.statusText,
3784
3836
  K,
3785
- nn(x)
3837
+ an(I)
3786
3838
  );
3787
3839
  }
3788
- return u === "blob" ? await x.blob() : x.json().then((K) => K).catch(() => {
3840
+ return u === "blob" ? await I.blob() : I.json().then((K) => K).catch(() => {
3789
3841
  });
3790
- } catch (x) {
3842
+ } catch (I) {
3791
3843
  const K = h ?? this.retries;
3792
- if (K > 0 && rn(x)) {
3793
- const mt = f ?? 0;
3794
- return await sn(on(x, mt)), await a(this, c, d).call(this, t, e, {
3844
+ if (K > 0 && cn(I)) {
3845
+ const gt = f ?? 0;
3846
+ return await on(hn(I, gt)), await a(this, c, d).call(this, t, e, {
3795
3847
  ...s,
3796
3848
  retries: K - 1,
3797
- retryAttempt: mt + 1
3849
+ retryAttempt: gt + 1
3798
3850
  });
3799
3851
  }
3800
- throw x;
3852
+ throw I;
3801
3853
  }
3802
3854
  }, D = async function(t, e) {
3803
- const { query: s } = e || {}, r = a(this, c, zt).call(this, t), i = await this.resolveAccessToken(), o = {
3855
+ const { query: s } = e || {}, r = a(this, c, ee).call(this, t), i = await this.resolveAccessToken(), o = {
3804
3856
  ...s,
3805
3857
  ...this.useBearer ? {} : { accessToken: i }
3806
3858
  };
@@ -3813,13 +3865,13 @@ c = new WeakSet(), zt = function(t) {
3813
3865
  }
3814
3866
  }
3815
3867
  );
3816
- }, ft = new WeakMap(), lt = async function(t, e) {
3868
+ }, pt = new WeakMap(), lt = async function(t, e) {
3817
3869
  if (!t.length) return [];
3818
3870
  const s = [];
3819
- for (let i = 0; i < t.length; i += ke)
3820
- s.push(t.slice(i, i + ke));
3871
+ for (let i = 0; i < t.length; i += Ae)
3872
+ s.push(t.slice(i, i + Ae));
3821
3873
  return (await Promise.all(s.map(e))).flat();
3822
- }, At = async function(t, e) {
3874
+ }, It = async function(t, e) {
3823
3875
  const { versionTag: s, withDraft: r } = e || {};
3824
3876
  return await a(this, c, D).call(this, `${m}/${t}/download`, {
3825
3877
  query: {
@@ -3828,16 +3880,16 @@ c = new WeakSet(), zt = function(t) {
3828
3880
  }
3829
3881
  });
3830
3882
  }, xt = async function(t, e, s) {
3831
- const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, y = new FormData();
3832
- return y.append("file", u), y.append("name", r), y.append("versionTag", i), y.append("itemType", e), o && y.append("folderId", o), h && y.append("projectId", h), s && y.append("extraProps", JSON.stringify(s)), f && y.append("metadata", JSON.stringify(f)), await a(this, c, d).call(this, "POST", m, {
3833
- body: y
3883
+ const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, p = new FormData();
3884
+ return p.append("file", u), p.append("name", r), p.append("versionTag", i), p.append("itemType", e), o && p.append("folderId", o), h && p.append("projectId", h), s && p.append("extraProps", JSON.stringify(s)), f && p.append("metadata", JSON.stringify(f)), await a(this, c, d).call(this, "POST", m, {
3885
+ body: p
3834
3886
  });
3835
- }, Qt = async function(t, e, s) {
3887
+ }, se = async function(t, e, s) {
3836
3888
  const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: u } = e;
3837
- let f, y;
3889
+ let f, p;
3838
3890
  if (h) {
3839
3891
  const w = new FormData();
3840
- w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), y = await a(this, c, d).call(this, "POST", `${m}/${t}/version`, {
3892
+ w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), p = await a(this, c, d).call(this, "POST", `${m}/${t}/version`, {
3841
3893
  body: w
3842
3894
  });
3843
3895
  }
@@ -3845,26 +3897,26 @@ c = new WeakSet(), zt = function(t) {
3845
3897
  const w = {
3846
3898
  ...r && { name: r },
3847
3899
  ...o && { folderId: o }
3848
- }, R = JSON.stringify(w);
3900
+ }, C = JSON.stringify(w);
3849
3901
  f = await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
3850
- body: R,
3902
+ body: C,
3851
3903
  contentType: "application/json"
3852
3904
  });
3853
3905
  }
3854
- return { item: f, version: y };
3855
- }, Zt = async function(t, e) {
3906
+ return { item: f, version: p };
3907
+ }, ne = async function(t, e) {
3856
3908
  const { showVersions: s = !1 } = e || {};
3857
3909
  return await a(this, c, d).call(this, "GET", `${m}/${t}`, {
3858
3910
  query: { showVersions: s }
3859
3911
  });
3860
- }, He = function(t) {
3912
+ }, We = function(t) {
3861
3913
  return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
3862
3914
  (e, [s, r]) => (e[s] = r, e),
3863
3915
  {}
3864
3916
  );
3865
3917
  };
3866
- let Xt = ue;
3867
- function an() {
3918
+ let te = ye;
3919
+ function ln() {
3868
3920
  if (typeof window > "u" || window.parent === window)
3869
3921
  throw new Error(
3870
3922
  "client.channel only works inside a That Open app, which runs in an iframe of the platform."
@@ -3879,24 +3931,24 @@ function an() {
3879
3931
  }
3880
3932
  };
3881
3933
  }
3882
- const te = "channel:", cn = 1e4;
3883
- function It(n) {
3934
+ const re = "channel:", un = 1e4;
3935
+ function $t(n) {
3884
3936
  try {
3885
3937
  n();
3886
3938
  } catch (t) {
3887
3939
  console.error("[channel] a listener threw:", t);
3888
3940
  }
3889
3941
  }
3890
- var q, k, O, Q, Z, tt, S, ee, se, z;
3891
- class Ge {
3942
+ var q, k, O, Z, tt, et, S, ie, oe, Q;
3943
+ class Ke {
3892
3944
  constructor(t, e) {
3893
- _(this, S);
3894
- _(this, q, !1);
3895
- _(this, k, []);
3896
- _(this, O, []);
3897
- _(this, Q, /* @__PURE__ */ new Set());
3898
- _(this, Z, /* @__PURE__ */ new Set());
3899
- _(this, tt, /* @__PURE__ */ new Set());
3945
+ b(this, S);
3946
+ b(this, q, !1);
3947
+ b(this, k, []);
3948
+ b(this, O, []);
3949
+ b(this, Z, /* @__PURE__ */ new Set());
3950
+ b(this, tt, /* @__PURE__ */ new Set());
3951
+ b(this, et, /* @__PURE__ */ new Set());
3900
3952
  this.transport = t, this.controls = e;
3901
3953
  }
3902
3954
  /** Whether the platform has confirmed this tab is in the room. */
@@ -3912,47 +3964,47 @@ class Ge {
3912
3964
  * refuses or does not answer in time. Joining twice is harmless.
3913
3965
  */
3914
3966
  join() {
3915
- return l(this, q) ? Promise.resolve() : a(this, S, ee).call(this, "joined", this.controls.join);
3967
+ return l(this, q) ? Promise.resolve() : a(this, S, ie).call(this, "joined", this.controls.join);
3916
3968
  }
3917
3969
  /** Leaves the room. Handlers stay registered, so `join()` resumes them. */
3918
3970
  leave() {
3919
- return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, ee).call(this, "left", this.controls.leave);
3971
+ return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, ie).call(this, "left", this.controls.leave);
3920
3972
  }
3921
3973
  /** Fires when `joined` or `peers` changes. Returns a function that stops it. */
3922
3974
  onChange(t) {
3923
- return l(this, Q).add(t), () => void l(this, Q).delete(t);
3975
+ return l(this, Z).add(t), () => void l(this, Z).delete(t);
3924
3976
  }
3925
3977
  onPeerJoined(t) {
3926
- return l(this, Z).add(t), () => void l(this, Z).delete(t);
3978
+ return l(this, tt).add(t), () => void l(this, tt).delete(t);
3927
3979
  }
3928
3980
  onPeerLeft(t) {
3929
- return l(this, tt).add(t), () => void l(this, tt).delete(t);
3981
+ return l(this, et).add(t), () => void l(this, et).delete(t);
3930
3982
  }
3931
3983
  /** @internal */
3932
3984
  applyJoined() {
3933
- b(this, q, !0), a(this, S, se).call(this, "joined"), a(this, S, z).call(this);
3985
+ _(this, q, !0), a(this, S, oe).call(this, "joined"), a(this, S, Q).call(this);
3934
3986
  }
3935
3987
  /** @internal */
3936
3988
  applyLeft() {
3937
- b(this, q, !1), b(this, k, []), a(this, S, se).call(this, "left"), a(this, S, z).call(this);
3989
+ _(this, q, !1), _(this, k, []), a(this, S, oe).call(this, "left"), a(this, S, Q).call(this);
3938
3990
  }
3939
3991
  /** @internal */
3940
3992
  applyPeers(t) {
3941
- b(this, k, t), a(this, S, z).call(this);
3993
+ _(this, k, t), a(this, S, Q).call(this);
3942
3994
  }
3943
3995
  /** @internal */
3944
3996
  applyPeerJoined(t) {
3945
- !l(this, q) || l(this, k).some((e) => e.from === t.from) || (b(this, k, [...l(this, k), t]), l(this, Z).forEach((e) => It(() => e(t))), a(this, S, z).call(this));
3997
+ !l(this, q) || l(this, k).some((e) => e.from === t.from) || (_(this, k, [...l(this, k), t]), l(this, tt).forEach((e) => $t(() => e(t))), a(this, S, Q).call(this));
3946
3998
  }
3947
3999
  /** @internal */
3948
4000
  applyPeerLeft(t) {
3949
4001
  const e = l(this, k).find((s) => s.from === t);
3950
- e && (b(this, k, l(this, k).filter((s) => s.from !== t)), l(this, tt).forEach((s) => It(() => s(e))), a(this, S, z).call(this));
4002
+ e && (_(this, k, l(this, k).filter((s) => s.from !== t)), l(this, et).forEach((s) => $t(() => s(e))), a(this, S, Q).call(this));
3951
4003
  }
3952
4004
  /** @internal */
3953
4005
  failPending(t) {
3954
4006
  const e = l(this, O);
3955
- return b(this, O, []), e.forEach((s) => {
4007
+ return _(this, O, []), e.forEach((s) => {
3956
4008
  clearTimeout(s.timer), s.reject(t);
3957
4009
  }), e.length > 0;
3958
4010
  }
@@ -3960,77 +4012,77 @@ class Ge {
3960
4012
  this.transport.post(t);
3961
4013
  }
3962
4014
  }
3963
- q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), S = new WeakSet(), ee = function(t, e) {
4015
+ q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), S = new WeakSet(), ie = function(t, e) {
3964
4016
  return new Promise((s, r) => {
3965
4017
  const i = {
3966
4018
  want: t,
3967
4019
  resolve: s,
3968
4020
  reject: r,
3969
4021
  timer: setTimeout(() => {
3970
- b(this, O, l(this, O).filter((o) => o !== i)), r(
4022
+ _(this, O, l(this, O).filter((o) => o !== i)), r(
3971
4023
  new Error(
3972
4024
  `The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
3973
4025
  )
3974
4026
  );
3975
- }, cn)
4027
+ }, un)
3976
4028
  };
3977
4029
  l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
3978
4030
  });
3979
- }, se = function(t) {
4031
+ }, oe = function(t) {
3980
4032
  const e = l(this, O).filter((s) => s.want === t);
3981
- b(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
4033
+ _(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
3982
4034
  clearTimeout(s.timer), s.resolve();
3983
4035
  });
3984
- }, z = function() {
3985
- l(this, Q).forEach((t) => It(t));
4036
+ }, Q = function() {
4037
+ l(this, Z).forEach((t) => $t(t));
3986
4038
  };
3987
- var et;
3988
- class hn extends Ge {
4039
+ var st;
4040
+ class dn extends Ke {
3989
4041
  /** @internal Use `client.channel.collab()`. */
3990
4042
  constructor(e) {
3991
4043
  super(e, {
3992
4044
  join: { action: "joinCollab" },
3993
4045
  leave: { action: "leaveCollab" }
3994
4046
  });
3995
- _(this, et, /* @__PURE__ */ new Map());
4047
+ b(this, st, /* @__PURE__ */ new Map());
3996
4048
  }
3997
4049
  /**
3998
4050
  * Listens for an event other tabs send. Any number of listeners per event.
3999
4051
  * @returns a function that removes the listener.
4000
4052
  */
4001
4053
  on(e, s) {
4002
- const r = l(this, et).get(e) ?? /* @__PURE__ */ new Set();
4003
- return r.add(s), l(this, et).set(e, r), () => void r.delete(s);
4054
+ const r = l(this, st).get(e) ?? /* @__PURE__ */ new Set();
4055
+ return r.add(s), l(this, st).set(e, r), () => void r.delete(s);
4004
4056
  }
4005
4057
  /**
4006
4058
  * Sends an event to the other tabs in the room. Does nothing while this tab
4007
4059
  * is not in it, matching what the platform does with a message from outside.
4008
4060
  */
4009
4061
  send(e, s) {
4010
- if (e.startsWith(te))
4011
- throw new Error(`Message types starting with '${te}' are reserved.`);
4062
+ if (e.startsWith(re))
4063
+ throw new Error(`Message types starting with '${re}' are reserved.`);
4012
4064
  this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
4013
4065
  }
4014
4066
  accepts(e) {
4015
4067
  return e === void 0 || e === "collab";
4016
4068
  }
4017
4069
  async handle(e) {
4018
- const s = l(this, et).get(e.type);
4070
+ const s = l(this, st).get(e.type);
4019
4071
  if (!(s != null && s.size)) return { handled: !1 };
4020
- const r = Ve(e);
4021
- return s.forEach((i) => It(() => i(e.payload, r))), { handled: !0 };
4072
+ const r = Xe(e);
4073
+ return s.forEach((i) => $t(() => i(e.payload, r))), { handled: !0 };
4022
4074
  }
4023
4075
  }
4024
- et = new WeakMap();
4025
- var M;
4026
- class ln extends Ge {
4076
+ st = new WeakMap();
4077
+ var H;
4078
+ class fn extends Ke {
4027
4079
  /** @internal Use `client.channel.external(kind)`. */
4028
4080
  constructor(e, s) {
4029
4081
  super(e, {
4030
4082
  join: { action: "joinExternal", kind: s },
4031
4083
  leave: { action: "leaveExternal", kind: s }
4032
4084
  });
4033
- _(this, M, /* @__PURE__ */ new Map());
4085
+ b(this, H, /* @__PURE__ */ new Map());
4034
4086
  this.kind = s;
4035
4087
  }
4036
4088
  /**
@@ -4044,24 +4096,24 @@ class ln extends Ge {
4044
4096
  * @returns a function that removes the handler.
4045
4097
  */
4046
4098
  on(e, s) {
4047
- if (l(this, M).has(e))
4099
+ if (l(this, H).has(e))
4048
4100
  throw new Error(
4049
4101
  `"${e}" already has a handler in this room. Remove it first.`
4050
4102
  );
4051
- return l(this, M).set(e, s), () => void l(this, M).delete(e);
4103
+ return l(this, H).set(e, s), () => void l(this, H).delete(e);
4052
4104
  }
4053
4105
  accepts(e, s) {
4054
4106
  return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
4055
4107
  }
4056
4108
  /** @internal Whether this room has any handler at all. */
4057
4109
  get hasHandlers() {
4058
- return l(this, M).size > 0;
4110
+ return l(this, H).size > 0;
4059
4111
  }
4060
4112
  async handle(e) {
4061
- const s = l(this, M).get(e.type);
4113
+ const s = l(this, H).get(e.type);
4062
4114
  if (!s) return { handled: !1 };
4063
4115
  try {
4064
- return { handled: !0, value: await s(e.payload, Ve(e)) };
4116
+ return { handled: !0, value: await s(e.payload, Xe(e)) };
4065
4117
  } catch (r) {
4066
4118
  return {
4067
4119
  handled: !0,
@@ -4070,8 +4122,8 @@ class ln extends Ge {
4070
4122
  }
4071
4123
  }
4072
4124
  }
4073
- M = new WeakMap();
4074
- function Ve(n) {
4125
+ H = new WeakMap();
4126
+ function Xe(n) {
4075
4127
  return {
4076
4128
  from: n.from,
4077
4129
  at: n.at,
@@ -4079,7 +4131,7 @@ function Ve(n) {
4079
4131
  kind: n.kind
4080
4132
  };
4081
4133
  }
4082
- function un(n) {
4134
+ function pn(n) {
4083
4135
  const t = n;
4084
4136
  if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
4085
4137
  const e = t.message;
@@ -4093,20 +4145,20 @@ function un(n) {
4093
4145
  kind: typeof e.kind == "string" ? e.kind : void 0
4094
4146
  };
4095
4147
  }
4096
- var W, pt, F, H, G, v, ne, $t, Je, Ye, We, re;
4097
- class dn {
4148
+ var W, yt, F, G, V, v, ae, Ct, ze, Qe, Ze, ce;
4149
+ class yn {
4098
4150
  constructor(t) {
4099
- _(this, v);
4100
- _(this, W);
4101
- _(this, pt);
4102
- _(this, F);
4103
- _(this, H, /* @__PURE__ */ new Map());
4104
- _(this, G, /* @__PURE__ */ new Set());
4105
- b(this, W, t), b(this, pt, t.listen((e) => void a(this, v, Je).call(this, e)));
4151
+ b(this, v);
4152
+ b(this, W);
4153
+ b(this, yt);
4154
+ b(this, F);
4155
+ b(this, G, /* @__PURE__ */ new Map());
4156
+ b(this, V, /* @__PURE__ */ new Set());
4157
+ _(this, W, t), _(this, yt, t.listen((e) => void a(this, v, ze).call(this, e)));
4106
4158
  }
4107
4159
  /** The collaboration room for this app. Always the same instance. */
4108
4160
  collab() {
4109
- return l(this, F) ?? b(this, F, new hn(l(this, W))), l(this, F);
4161
+ return l(this, F) ?? _(this, F, new dn(l(this, W))), l(this, F);
4110
4162
  }
4111
4163
  /**
4112
4164
  * The room for commands from this account's external tools of one `kind`
@@ -4115,46 +4167,46 @@ class dn {
4115
4167
  */
4116
4168
  external(t) {
4117
4169
  const e = t ?? "";
4118
- let s = l(this, H).get(e);
4119
- return s || (s = new ln(l(this, W), t), l(this, H).set(e, s)), s;
4170
+ let s = l(this, G).get(e);
4171
+ return s || (s = new fn(l(this, W), t), l(this, G).set(e, s)), s;
4120
4172
  }
4121
4173
  /** Stops listening. For tests and teardown; an app normally never calls it. */
4122
4174
  dispose() {
4123
- l(this, pt).call(this);
4175
+ l(this, yt).call(this);
4124
4176
  }
4125
4177
  }
4126
- W = new WeakMap(), pt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G = new WeakMap(), v = new WeakSet(), ne = function() {
4127
- return [...l(this, F) ? [l(this, F)] : [], ...l(this, H).values()];
4128
- }, $t = function(t, e) {
4178
+ W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), G = new WeakMap(), V = new WeakMap(), v = new WeakSet(), ae = function() {
4179
+ return [...l(this, F) ? [l(this, F)] : [], ...l(this, G).values()];
4180
+ }, Ct = function(t, e) {
4129
4181
  if (t === "collab") return l(this, F);
4130
4182
  if (t === "external")
4131
- return l(this, H).get(typeof e == "string" ? e : "");
4132
- }, Je = async function(t) {
4133
- const e = un(t);
4183
+ return l(this, G).get(typeof e == "string" ? e : "");
4184
+ }, ze = async function(t) {
4185
+ const e = pn(t);
4134
4186
  if (e) {
4135
- if (e.type.startsWith(te)) {
4136
- a(this, v, Ye).call(this, e);
4187
+ if (e.type.startsWith(re)) {
4188
+ a(this, v, Qe).call(this, e);
4137
4189
  return;
4138
4190
  }
4139
- await a(this, v, We).call(this, e);
4191
+ await a(this, v, Ze).call(this, e);
4140
4192
  }
4141
- }, Ye = function(t) {
4193
+ }, Qe = function(t) {
4142
4194
  var s, r, i;
4143
4195
  const e = t.payload ?? {};
4144
4196
  switch (t.type) {
4145
4197
  case "channel:joined":
4146
- (s = a(this, v, $t).call(this, e.scope, e.kind)) == null || s.applyJoined();
4198
+ (s = a(this, v, Ct).call(this, e.scope, e.kind)) == null || s.applyJoined();
4147
4199
  break;
4148
4200
  case "channel:left":
4149
- (r = a(this, v, $t).call(this, e.scope, e.kind)) == null || r.applyLeft();
4201
+ (r = a(this, v, Ct).call(this, e.scope, e.kind)) == null || r.applyLeft();
4150
4202
  break;
4151
4203
  case "channel:peers":
4152
- (i = a(this, v, $t).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
4204
+ (i = a(this, v, Ct).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
4153
4205
  break;
4154
4206
  case "channel:peer-joined":
4155
4207
  case "channel:peer-left": {
4156
4208
  if (!e.from) break;
4157
- const o = e.scope === "collab" ? [l(this, F)] : [...l(this, H).values()].filter(
4209
+ const o = e.scope === "collab" ? [l(this, F)] : [...l(this, G).values()].filter(
4158
4210
  (h) => h.accepts("external", e.kind)
4159
4211
  );
4160
4212
  for (const h of o)
@@ -4163,23 +4215,23 @@ W = new WeakMap(), pt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G =
4163
4215
  }
4164
4216
  case "channel:error": {
4165
4217
  const o = new Error(String(t.payload));
4166
- a(this, v, ne).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
4218
+ a(this, v, ae).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
4167
4219
  break;
4168
4220
  }
4169
4221
  }
4170
- }, We = async function(t) {
4171
- const e = a(this, v, ne).call(this).filter((i) => i.accepts(t.scope, t.kind));
4222
+ }, Ze = async function(t) {
4223
+ const e = a(this, v, ae).call(this).filter((i) => i.accepts(t.scope, t.kind));
4172
4224
  let s = !1;
4173
4225
  for (const i of e) {
4174
4226
  const o = await i.handle(t);
4175
- o.handled && (s = !0, t.requestId && a(this, v, re).call(this, t.requestId, o));
4227
+ o.handled && (s = !0, t.requestId && a(this, v, ce).call(this, t.requestId, o));
4176
4228
  }
4177
- t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, re).call(this, t.requestId, {
4229
+ t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, ce).call(this, t.requestId, {
4178
4230
  handled: !0,
4179
4231
  error: `No handler for "${t.type}".`
4180
4232
  });
4181
- }, re = function(t, e) {
4182
- l(this, G).has(t) || (l(this, G).add(t), l(this, G).size > 500 && l(this, G).delete(l(this, G).values().next().value), l(this, W).post({
4233
+ }, ce = function(t, e) {
4234
+ l(this, V).has(t) || (l(this, V).add(t), l(this, V).size > 500 && l(this, V).delete(l(this, V).values().next().value), l(this, W).post({
4183
4235
  type: "APP_CHANNEL_PUBLISH",
4184
4236
  message: {
4185
4237
  type: e.error === void 0 ? "reply" : "reply-error",
@@ -4188,9 +4240,9 @@ W = new WeakMap(), pt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G =
4188
4240
  }
4189
4241
  }));
4190
4242
  };
4191
- const J = "project", X = "notifications";
4192
- var st, yt;
4193
- const de = class de extends Xt {
4243
+ const Y = "project", X = "notifications";
4244
+ var nt, mt;
4245
+ const me = class me extends te {
4194
4246
  /**
4195
4247
  * @param token - A bearer JWT, OR a function returning the current JWT
4196
4248
  * (sync or async). When a function is passed, it's invoked before every
@@ -4201,12 +4253,12 @@ const de = class de extends Xt {
4201
4253
  */
4202
4254
  constructor(e, s, r) {
4203
4255
  super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
4204
- _(this, st);
4205
- _(this, yt);
4206
- typeof e == "function" && b(this, st, e);
4256
+ b(this, nt);
4257
+ b(this, mt);
4258
+ typeof e == "function" && _(this, nt, e);
4207
4259
  }
4208
4260
  async resolveAccessToken() {
4209
- return l(this, st) ? await l(this, st).call(this) : super.resolveAccessToken();
4261
+ return l(this, nt) ? await l(this, nt).call(this) : super.resolveAccessToken();
4210
4262
  }
4211
4263
  /**
4212
4264
  * Creates a client from the platform context injected into
@@ -4215,7 +4267,7 @@ const de = class de extends Xt {
4215
4267
  * carries a fresh JWT on every navigation.
4216
4268
  */
4217
4269
  static fromPlatformContext(e) {
4218
- const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new de(s.accessToken, s.apiUrl, e);
4270
+ const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new me(s.accessToken, s.apiUrl, e);
4219
4271
  return r.context = s, r;
4220
4272
  }
4221
4273
  /**
@@ -4243,7 +4295,7 @@ const de = class de extends Xt {
4243
4295
  * ```
4244
4296
  */
4245
4297
  get channel() {
4246
- return l(this, yt) ?? b(this, yt, new dn(an())), l(this, yt);
4298
+ return l(this, mt) ?? _(this, mt, new yn(ln())), l(this, mt);
4247
4299
  }
4248
4300
  // ─── Projects (JWT-only backend routes) ──────────────────────────
4249
4301
  /**
@@ -4262,14 +4314,14 @@ const de = class de extends Xt {
4262
4314
  * ```
4263
4315
  */
4264
4316
  async listProjects() {
4265
- return await this.request("GET", J);
4317
+ return await this.request("GET", Y);
4266
4318
  }
4267
4319
  /**
4268
4320
  * Gets a project by ID. JWT-only — lives here because
4269
4321
  * `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
4270
4322
  */
4271
4323
  async getProject(e) {
4272
- return await this.request("GET", `${J}/${e}`);
4324
+ return await this.request("GET", `${Y}/${e}`);
4273
4325
  }
4274
4326
  /**
4275
4327
  * Gets the full project data (users, roles, files, folders) for a project.
@@ -4278,7 +4330,7 @@ const de = class de extends Xt {
4278
4330
  async getProjectData(e) {
4279
4331
  return await this.request(
4280
4332
  "GET",
4281
- `${J}/${e}/data`
4333
+ `${Y}/${e}/data`
4282
4334
  );
4283
4335
  }
4284
4336
  // ─── Account ──────────────────────────────────────────────────────
@@ -4303,7 +4355,7 @@ const de = class de extends Xt {
4303
4355
  async checkPermission(e) {
4304
4356
  return await this.request(
4305
4357
  "GET",
4306
- `${J}/permissions/check`,
4358
+ `${Y}/permissions/check`,
4307
4359
  { query: e }
4308
4360
  );
4309
4361
  }
@@ -4312,7 +4364,7 @@ const de = class de extends Xt {
4312
4364
  * single round-trip; results come back in the same order as `checks`.
4313
4365
  */
4314
4366
  async checkPermissionBatch(e) {
4315
- return (await this.request("POST", `${J}/permissions/check/batch`, {
4367
+ return (await this.request("POST", `${Y}/permissions/check/batch`, {
4316
4368
  body: JSON.stringify({ checks: e }),
4317
4369
  contentType: "application/json"
4318
4370
  })).results;
@@ -4424,7 +4476,7 @@ const de = class de extends Xt {
4424
4476
  async subscribeToAutomation(e, s, r) {
4425
4477
  return await this.request(
4426
4478
  "POST",
4427
- `${J}/${e}/events/hooks/${s}/subscription`,
4479
+ `${Y}/${e}/events/hooks/${s}/subscription`,
4428
4480
  {
4429
4481
  body: JSON.stringify(r ?? {}),
4430
4482
  contentType: "application/json"
@@ -4441,7 +4493,7 @@ const de = class de extends Xt {
4441
4493
  async updateAutomationSubscription(e, s, r) {
4442
4494
  return await this.request(
4443
4495
  "PATCH",
4444
- `${J}/${e}/events/hooks/${s}/subscription`,
4496
+ `${Y}/${e}/events/hooks/${s}/subscription`,
4445
4497
  {
4446
4498
  body: JSON.stringify(r),
4447
4499
  contentType: "application/json"
@@ -4491,37 +4543,38 @@ const de = class de extends Xt {
4491
4543
  ), () => r.disconnect();
4492
4544
  }
4493
4545
  };
4494
- st = new WeakMap(), yt = new WeakMap();
4495
- let Ae = de;
4496
- const yn = {
4546
+ nt = new WeakMap(), mt = new WeakMap();
4547
+ let xe = me;
4548
+ const wn = {
4497
4549
  MAX_FIELDS: 200,
4498
4550
  MAX_KEY_LENGTH: 50,
4499
4551
  MAX_VALUE_LENGTH: 50
4500
- }, mn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, gn = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, wn = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, _n = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, bn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, En = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, vn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Tn = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Sn = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
4552
+ }, bn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, _n = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, En = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, vn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Tn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Sn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, kn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, On = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, An = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
4501
4553
  export {
4502
- mn as CDEManager,
4503
- dn as ChannelClient,
4504
- Ge as ChannelRoom,
4505
- gn as ClashesManager,
4506
- hn as CollabRoom,
4507
- Xt as EngineServicesClient,
4508
- ln as ExternalRoom,
4509
- wn as FileList,
4510
- Ws as FlowDoc,
4511
- _n as GISManager,
4512
- bn as GitHistoryManager,
4513
- En as HelloWorld,
4514
- yn as METADATA_LIMITS,
4515
- Ae as PlatformClient,
4516
- Ys as ProjectHistory,
4517
- vn as ProjectManager,
4518
- Xs as Recipes,
4519
- le as RequestError,
4520
- ke as STORAGE_BATCH_MAX,
4521
- _e as StaleHistoryError,
4522
- Tn as TopicsManager,
4523
- Sn as UIManager,
4524
- Me as orderByGraph,
4525
- an as windowTransport
4554
+ bn as CDEManager,
4555
+ yn as ChannelClient,
4556
+ Ke as ChannelRoom,
4557
+ _n as ClashesManager,
4558
+ dn as CollabRoom,
4559
+ te as EngineServicesClient,
4560
+ fn as ExternalRoom,
4561
+ En as FileList,
4562
+ zs as FlowDoc,
4563
+ vn as GISManager,
4564
+ Tn as GitHistoryManager,
4565
+ Sn as HelloWorld,
4566
+ wn as METADATA_LIMITS,
4567
+ xe as PlatformClient,
4568
+ Xs as ProjectHistory,
4569
+ kn as ProjectManager,
4570
+ Zs as Recipes,
4571
+ pe as RequestError,
4572
+ Ae as STORAGE_BATCH_MAX,
4573
+ Te as StaleHistoryError,
4574
+ On as TopicsManager,
4575
+ An as UIManager,
4576
+ Qt as mintGuid,
4577
+ Ye as orderByGraph,
4578
+ ln as windowTransport
4526
4579
  };
4527
4580
  //# sourceMappingURL=index.es.js.map